Ticket #2499: link_categories.diff
File link_categories.diff, 98.7 KB (added by , 19 years ago) |
---|
-
wp-includes/template-functions-category.php
410 410 return false; 411 411 } 412 412 413 function &get_categories($args = '') { 414 global $wpdb, $category_links; 415 416 parse_str($args, $r); 417 418 if ( !isset($r['type']) ) // 'post' or 'link' 419 $r['type'] = 'post'; 420 if ( !isset($r['child_of']) ) 421 $r['child_of'] = 0; 422 if ( !isset($r['orderby']) ) 423 $r['orderby'] = 'name'; 424 if ( !isset($r['order']) ) 425 $r['order'] = 'ASC'; 426 if ( !isset($r['hide_empty']) ) 427 $r['hide_empty'] = true; 428 429 $r['orderby'] = "cat_" . $r['orderby']; 430 431 $exclusions = ''; 432 if ( !empty($r['exclude']) ) { 433 $excategories = preg_split('/[\s,]+/',$r['exclude']); 434 if ( count($excategories) ) { 435 foreach ( $excategories as $excat ) { 436 $exclusions .= ' AND cat_ID <> ' . intval($excat) . ' '; 437 } 438 } 439 } 440 441 if ( $r['hide_empty'] && ( 'link' == $r['type']) ) { 442 if ( empty($category_links) ) { 443 $cat_counts = $wpdb->get_results("SELECT cat_ID, 444 COUNT($wpdb->link2cat.link_id) AS cat_count 445 FROM $wpdb->categories 446 INNER JOIN $wpdb->link2cat ON (cat_ID = category_id) 447 INNER JOIN $wpdb->links ON ($wpdb->link2cat.link_id = $wpdb->links.link_id) 448 GROUP BY category_id"); 449 450 if ( ! empty($cat_counts) ) foreach ( $cat_counts as $cat_count ) { 451 if ( $cat_count > 0) { 452 $category_links[$cat_count->cat_ID] = $cat_count->cat_count; 453 } 454 } 455 } 456 } 457 458 $categories = $wpdb->get_results("SELECT * " . 459 "FROM $wpdb->categories " . 460 "$exclusions " . 461 "ORDER BY " . $r['orderby'] . " " . $r['order']); 462 463 if ( empty($categories) ) 464 return array(); 465 466 if ( $r['hide_empty'] ) { 467 foreach ( $categories as $category ) { 468 $count = 0; 469 if ( 'link' == $r['type'] ) { 470 if ( isset($category_links[$category->cat_ID]) ) 471 $count = $category_links[$category->cat_ID]; 472 } else { 473 $count = $category->category_count; 474 } 475 if ( $count ) 476 $the_categories[] = $category; 477 } 478 $categories = $the_categories; 479 } 480 481 /* if ( $r['child_of'] ) 482 $categories = & get_category_children($r['child_of'], $categories); */ 483 484 return $categories; 485 } 486 413 487 ?> -
wp-includes/links.php
28 28 $limit = -1, $show_updated = 0) { 29 29 global $wpdb; 30 30 $cat_id = -1; 31 $results = $wpdb->get_results("SELECT cat_ id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");31 $results = $wpdb->get_results("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$cat_name'"); 32 32 if ($results) { 33 33 foreach ($results as $result) { 34 $cat_id = $result->cat_ id;34 $cat_id = $result->cat_ID; 35 35 } 36 36 } 37 37 get_links($cat_id, $before, $after, $between, $show_images, $orderby, 38 38 $show_description, $show_rating, $limit, $show_updated); 39 39 } 40 40 41 function bool_from_yn($yn) {42 if ($yn == 'Y') return 1;43 return 0;44 }45 46 41 /** function wp_get_linksbyname() 47 42 ** Gets the links associated with the named category. 48 43 ** Parameters: … … 51 46 function wp_get_linksbyname($category, $args = '') { 52 47 global $wpdb; 53 48 54 $cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, " 55 . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, " 56 . " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_name='$category'"); 49 $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category' LIMIT 1"); 57 50 58 if (! $cat ) {51 if (! $cat_id) 59 52 return; 60 }61 53 62 if (empty($args)) { 63 if ($cat->sort_desc == 'Y') { 64 $cat->sort_order = '_'.$cat->sort_order; 65 } 66 get_links($cat->cat_id, $cat->text_before_link, $cat->text_after_all, 67 $cat->text_after_link, bool_from_yn($cat->show_images), $cat->sort_order, 68 bool_from_yn($cat->show_description), bool_from_yn($cat->show_rating), 69 $cat->list_limit, bool_from_yn($cat->show_updated)); 70 } else { 71 $args = add_query_arg('category', $cat->cat_id, $args); 72 wp_get_links($args); 73 } 54 $args = add_query_arg('category', $cat_id, $args); 55 wp_get_links($args); 74 56 } // end wp_get_linksbyname 75 57 76 58 /** function wp_get_links() … … 83 65 function wp_get_links($args = '') { 84 66 global $wpdb; 85 67 86 if (!empty($args) && false === strpos($args, '=')) { 87 // If args is not a query string, it's a category id. 88 $category = $args; 89 $cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, " 90 . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, " 91 . " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_id=$category"); 92 if ($cat) { 93 if ($cat->sort_desc == 'Y') { 94 $cat->sort_order = '_'.$cat->sort_order; 95 } 96 get_links($cat->cat_id, $cat->text_before_link, $cat->text_after_all, 97 $cat->text_after_link, bool_from_yn($cat->show_images), $cat->sort_order, 98 bool_from_yn($cat->show_description), bool_from_yn($cat->show_rating), 99 $cat->list_limit, bool_from_yn($cat->show_updated)); 100 } 101 } else { 102 parse_str($args); 68 if ( empty($args) ) 69 return; 103 70 104 if (! isset($category)) $category = -1; 105 if (! isset($before)) $before = ''; 106 if (! isset($after)) $after = '<br />'; 107 if (! isset($between)) $between = ' '; 108 if (! isset($show_images)) $show_images = true; 109 if (! isset($orderby)) $orderby = 'name'; 110 if (! isset($show_description)) $show_description = true; 111 if (! isset($show_rating)) $show_rating = false; 112 if (! isset($limit)) $limit = -1; 113 if (! isset($show_updated)) $show_updated = 1; 114 if (! isset($echo)) $echo = true; 115 116 return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo); 71 if ( false === strpos($args, '=') ) { 72 $cat_id = $args; 73 $args = add_query_arg('category', $cat_id, $args); 117 74 } 75 76 parse_str($args); 77 78 if (! isset($category)) $category = -1; 79 if (! isset($before)) $before = ''; 80 if (! isset($after)) $after = '<br />'; 81 if (! isset($between)) $between = ' '; 82 if (! isset($show_images)) $show_images = true; 83 if (! isset($orderby)) $orderby = 'name'; 84 if (! isset($show_description)) $show_description = true; 85 if (! isset($show_rating)) $show_rating = false; 86 if (! isset($limit)) $limit = -1; 87 if (! isset($show_updated)) $show_updated = 1; 88 if (! isset($echo)) $echo = true; 89 90 return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo); 118 91 } // end wp_get_links 119 92 120 93 /** function get_links() … … 154 127 155 128 global $wpdb; 156 129 157 $direction = ' ASC'; 158 $category_query = ''; 159 if ($category != -1) { 160 $category_query = " AND link_category = $category "; 161 } 162 if (get_settings('links_recently_updated_time')) { 163 $recently_updated_test = ", IF (DATE_ADD(link_updated, INTERVAL " . get_settings('links_recently_updated_time') . " MINUTE) >= NOW(), 1,0) as recently_updated "; 164 } else { 165 $recently_updated_test = ''; 166 } 167 if ($show_updated) { 168 $get_updated = ", UNIX_TIMESTAMP(link_updated) AS link_updated_f "; 169 } 130 $results = get_linkz("orderby=$orderby&show_updated=$show_updated&limit=$limit"); 170 131 171 $orderby = strtolower($orderby);172 if ($orderby == '')173 $orderby = 'id';174 if (substr($orderby, 0, 1) == '_') {175 $direction = ' DESC';176 $orderby = substr($orderby, 1);177 }178 179 switch($orderby) {180 case 'length':181 $length = ", CHAR_LENGTH(link_name) AS length";182 break;183 case 'rand':184 $orderby = 'rand()';185 break;186 default:187 $orderby = " link_" . $orderby;188 }189 190 if (!isset($length)) {191 $length = '';192 }193 194 $sql = "SELECT link_url, link_name, link_image, link_target, link_description, link_rating, link_rel $length $recently_updated_test $get_updated FROM $wpdb->links WHERE link_visible = 'Y' " . $category_query;195 $sql .= ' ORDER BY ' . $orderby . $direction;196 /* The next 2 lines implement LIMIT TO processing */197 if ($limit != -1)198 $sql .= " LIMIT $limit";199 $results = $wpdb->get_results($sql);200 132 if (!$results) { 201 133 return; 202 134 } 203 135 136 204 137 $output = ''; 205 138 206 139 foreach ($results as $row) { … … 290 223 ** echo '<li>'.$link->link_name.'</li>'; 291 224 ** } 292 225 **/ 226 // Deprecate in favor of get_linkz(). 293 227 function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) { 294 228 global $wpdb; 295 229 $cat_id = -1; 296 $results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'"); 230 //$results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'"); 231 // TODO: Fix me. 297 232 if ($results) { 298 233 foreach ($results as $result) { 299 234 $cat_id = $result->cat_id; … … 337 272 ** link_rel 338 273 ** link_notes 339 274 **/ 275 // Deprecate in favor of get_linkz(). 340 276 function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) { 341 277 global $wpdb; 342 278 … … 445 381 ** uses 0 446 382 */ 447 383 function get_linkcatname($id = 0) { 448 global $wpdb; 449 $cat_name = ''; 450 if ('' != $id) { 451 $cat_name = $wpdb->get_var("SELECT cat_name FROM $wpdb->linkcategories WHERE cat_id=$id"); 452 } 453 return $cat_name; 384 if ( empty($id) ) 385 return ''; 386 387 $cats = wp_get_link_cats($id); 388 389 if ( empty($cats) || ! is_array($cats) ) 390 return ''; 391 392 $cat_id = $cats[0]; // Take the first cat. 393 394 $cat = get_category($cat_id); 395 return $cat->cat_name; 454 396 } 455 397 456 398 /** function get_get_autotoggle() … … 459 401 ** uses 0 460 402 */ 461 403 function get_autotoggle($id = 0) { 462 global $wpdb; 463 $auto_toggle = $wpdb->get_var("SELECT auto_toggle FROM $wpdb->linkcategories WHERE cat_id=$id"); 464 if ('' == $auto_toggle) 465 $auto_toggle = 'N'; 466 return $auto_toggle; 404 return 0; 467 405 } 468 406 469 407 /** function links_popup_script() … … 511 449 * hide_if_empty (default true) - Supress listing empty link categories 512 450 */ 513 451 function get_links_list($order = 'name', $hide_if_empty = 'obsolete') { 514 global $wpdb;515 516 452 $order = strtolower($order); 517 453 518 454 // Handle link category sorting 455 $direction = 'ASC'; 519 456 if (substr($order,0,1) == '_') { 520 $direction = ' 457 $direction = 'DESC'; 521 458 $order = substr($order,1); 522 459 } 523 460 524 // if 'name' wasn't specified, assume 'id':525 $cat_order = ('name' == $order) ? 'cat_name' : 'cat_id';526 527 461 if (!isset($direction)) $direction = ''; 528 // Fetch the link category data as an array of hashesa529 $cats = $wpdb->get_results("530 SELECT DISTINCT link_category, cat_name, show_images,531 show_description, show_rating, show_updated, sort_order,532 sort_desc, list_limit533 FROM `$wpdb->links`534 LEFT JOIN `$wpdb->linkcategories` ON (link_category = cat_id)535 WHERE link_visible = 'Y'536 AND list_limit <> 0537 ORDER BY $cat_order $direction ", ARRAY_A);538 462 463 $cats = get_categories("type=link&orderby=$order&order=$direction"); 464 539 465 // Display each category 540 466 if ($cats) { 541 467 foreach ($cats as $cat) { 542 468 // Handle each category. 543 // First, fix the sort_order info544 $orderby = $cat['sort_order'];545 $orderby = (bool_from_yn($cat['sort_desc'])?'_':'') . $orderby;546 469 547 470 // Display the category name 548 echo ' <li id="linkcat-' . $cat ['link_category'] . '"><h2>' . $cat['cat_name']. "</h2>\n\t<ul>\n";471 echo ' <li id="linkcat-' . $cat->cat_ID . '"><h2>' . $cat->cat_name . "</h2>\n\t<ul>\n"; 549 472 // Call get_links() with all the appropriate params 550 get_links($cat['link_category'], 551 '<li>',"</li>","\n", 552 bool_from_yn($cat['show_images']), 553 $orderby, 554 bool_from_yn($cat['show_description']), 555 bool_from_yn($cat['show_rating']), 556 $cat['list_limit'], 557 bool_from_yn($cat['show_updated'])); 473 get_links($cat->cat_ID, 474 '<li>',"</li>","\n"); 558 475 559 476 // Close the last category 560 477 echo "\n\t</ul>\n</li>\n"; … … 562 479 } 563 480 } 564 481 482 function get_linkz($args = '') { 483 global $wpdb; 484 485 parse_str($args, $r); 486 487 if ( !isset($r['orderby']) ) 488 $r['orderby'] = 'name'; 489 if ( !isset($r['order']) ) 490 $r['order'] = 'ASC'; 491 if ( !isset($r['limit']) ) 492 $r['limit'] = -1; 493 if ( !isset($r['category']) ) 494 $r['category'] = -1; 495 if ( !isset($r['category_name']) ) 496 $r['category_name'] = ''; 497 if ( !isset($r['hide_invisible']) ) 498 $r['hide_invisible'] = 1; 499 if ( !isset($r['show_updates']) ) 500 $r['show_updated'] = 0; 501 502 $exclusions = ''; 503 if ( !empty($r['exclude']) ) { 504 $exlinks = preg_split('/[\s,]+/',$r['exclude']); 505 if ( count($exlinks) ) { 506 foreach ( $exlinks as $exlink ) { 507 $exclusions .= ' AND link_id <> ' . intval($exlink) . ' '; 508 } 509 } 510 } 511 512 extract($r); 513 514 if ( ! empty($category_name) ) { 515 if ( $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category_name' LIMIT 1") ) 516 $category = $cat_id; 517 } 518 519 $category_query = ''; 520 $join = ''; 521 if ( $category != -1 && !empty($category) ) { 522 $join = " LEFT JOIN $wpdb->link2cat ON ($wpdb->links.link_id = $wpdb->link2cat.link_id) "; 523 524 $category_query = " AND category_id = $category "; 525 } 526 527 if (get_settings('links_recently_updated_time')) { 528 $recently_updated_test = ", IF (DATE_ADD(link_updated, INTERVAL " . get_settings('links_recently_updated_time') . " MINUTE) >= NOW(), 1,0) as recently_updated "; 529 } else { 530 $recently_updated_test = ''; 531 } 532 533 if ($show_updated) { 534 $get_updated = ", UNIX_TIMESTAMP(link_updated) AS link_updated_f "; 535 } 536 537 $orderby = strtolower($r['orderby']); 538 $length = ''; 539 switch ($orderby) { 540 case 'length': 541 $length = ", CHAR_LENGTH(link_name) AS length"; 542 break; 543 case 'rand': 544 $orderby = 'rand()'; 545 break; 546 default: 547 $orderby = "link_" . $orderby; 548 } 549 550 $visible = ''; 551 if ( $hide_invisible ) 552 $visible = "AND link_visible = 'Y'"; 553 554 $query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query"; 555 $query .= " ORDER BY $orderby $order"; 556 if ($limit != -1) 557 $query .= " LIMIT $limit"; 558 559 return $wpdb->get_results($query); 560 } 565 561 ?> 562 No newline at end of file -
wp-includes/version.php
3 3 // This just holds the version number, in a separate file so we can bump it without cluttering the SVN 4 4 5 5 $wp_version = '2.1-alpha1'; 6 $wp_db_version = 35 48;6 $wp_db_version = 3572; 7 7 8 8 ?> 9 No newline at end of file -
wp-includes/functions.php
2409 2409 else 2410 2410 return ''; 2411 2411 } 2412 2413 function bool_from_yn($yn) { 2414 if ($yn == 'Y') return 1; 2415 return 0; 2416 } 2412 2417 ?> -
wp-settings.php
78 78 $wpdb->categories = $table_prefix . 'categories'; 79 79 $wpdb->post2cat = $table_prefix . 'post2cat'; 80 80 $wpdb->comments = $table_prefix . 'comments'; 81 $wpdb->link2cat = $table_prefix . 'link2cat'; 81 82 $wpdb->links = $table_prefix . 'links'; 82 83 $wpdb->linkcategories = $table_prefix . 'linkcategories'; 83 84 $wpdb->options = $table_prefix . 'options'; … … 98 99 $tablecategories = $wpdb->categories; 99 100 $tablepost2cat = $wpdb->post2cat; 100 101 $tablecomments = $wpdb->comments; 102 $tablelink2cat = $wpdb->link2cat; 101 103 $tablelinks = $wpdb->links; 102 104 $tablelinkcategories = $wpdb->linkcategories; 103 105 $tableoptions = $wpdb->options; -
wp-admin/upgrade-functions.php
1 1 <?php 2 2 3 3 require_once(ABSPATH . '/wp-admin/admin-functions.php'); 4 require_once(ABSPATH . '/wp-admin/admin-db.php'); 4 5 require_once(ABSPATH . '/wp-admin/upgrade-schema.php'); 5 6 // Functions to be called in install and upgrade scripts 6 7 function upgrade_all() { … … 33 34 if ( $wp_current_db_version < 3308 ) 34 35 upgrade_160(); 35 36 36 if ( $wp_current_db_version < 35 48)37 if ( $wp_current_db_version < 3572 ) 37 38 upgrade_210(); 38 39 39 40 $wp_rewrite->flush_rules(); … … 366 367 foreach ( $posts as $post ) 367 368 wp_schedule_event(mysql2date('U', $post->post_date), 'once', 'publish_future_post', $post->ID); 368 369 } 370 if ( $wp_current_db_version < 3572 ) { 371 // Create categories for link categories if a category with the same 372 // name doesn't exist. Create a map of link cat IDs to cat IDs. 373 $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories"); 374 foreach ( $link_cats as $link_cat) { 375 if ( $cat_id = category_exists($link_cat->cat_name) ) { 376 $link_cat_id_map[$link_cat->cat_id] = $cat_id; 377 $default_link_cat = $cat_id; 378 } else { 379 $link_cat_id_map[$link_cat->cat_id] = wp_create_category($link_cat->cat_name); 380 $default_link_cat = $link_cat_id_map[$link_cat->cat_id]; 381 } 382 } 383 384 // Associate links to cats. 385 $links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links"); 386 foreach ( $links as $link ) { 387 $link_cat = $link_cat_id_map[$link->link_category]; 388 $cat = $wpdb->get_row("SELECT * FROM $wpdb->link2cat WHERE link_id = $link->link_id AND category_id = $link_cat"); 389 if (!$cat && 0 != $link->link_category) { 390 $wpdb->query("INSERT INTO $wpdb->link2cat (link_id, category_id) 391 VALUES ('$link->link_id', '$link_cat')"); 392 } 393 } 394 395 // Set default to the last category we grabbed during the upgrade loop. 396 update_option('default_link_category', $default_link_cat); 397 } 369 398 } 370 399 371 400 // The functions we use to actually do stuff -
wp-admin/admin-functions.php
476 476 $link->link_description = wp_specialchars($link->link_description); 477 477 $link->link_notes = wp_specialchars($link->link_notes); 478 478 $link->link_rss = wp_specialchars($link->link_rss); 479 $link->post_category = $link->link_category; 479 480 480 481 return $link; 481 482 } … … 507 508 $_POST['link_name'] = wp_specialchars($_POST['link_name']); 508 509 $_POST['link_image'] = wp_specialchars($_POST['link_image']); 509 510 $_POST['link_rss'] = wp_specialchars($_POST['link_rss']); 510 $auto_toggle = get_autotoggle($_POST['link_category']);511 511 512 // if we are in an auto toggle category and this one is visible then we513 // need to make the others invisible before we add this new one.514 // FIXME Add category toggle func.515 //if (($auto_toggle == 'Y') && ($link_visible == 'Y')) {516 // $wpdb->query("UPDATE $wpdb->links set link_visible = 'N' WHERE link_category = $link_category");517 //}518 519 512 if ( !empty($link_id) ) { 520 513 $_POST['link_id'] = $link_id; 521 514 return wp_update_link($_POST); … … 702 695 } 703 696 } 704 697 705 function link_category_dropdown($fieldname, $selected= 0) {698 function return_link_categories_list($parent = 0) { 706 699 global $wpdb; 700 return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY cat_name DESC"); 701 } 707 702 708 $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id"); 709 echo "\n<select name='$fieldname' size='1'>\n"; 710 foreach ($results as $row) { 711 echo "\n\t<option value='$row->cat_id'"; 712 if ($row->cat_id == $selected) 713 echo " selected='selected'"; 714 echo ">$row->cat_id : " . wp_specialchars($row->cat_name); 715 if ($row->auto_toggle == 'Y') 716 echo ' (auto toggle)'; 717 echo "</option>"; 703 function get_nested_link_categories($default = 0, $parent = 0) { 704 global $link_id, $mode, $wpdb; 705 706 if ($link_id) { 707 $checked_categories = $wpdb->get_col(" 708 SELECT category_id 709 FROM $wpdb->categories, $wpdb->link2cat 710 WHERE $wpdb->link2cat.category_id = cat_ID AND $wpdb->link2cat.link_id = '$link_id' 711 "); 712 713 if (count($checked_categories) == 0) { 714 // No selected categories, strange 715 $checked_categories[] = $default; 716 } 717 718 } else { 719 $checked_categories[] = $default; 718 720 } 719 echo "\n</select>\n"; 721 722 $cats = return_link_categories_list($parent); 723 $result = array (); 724 725 if (is_array($cats)) { 726 foreach ($cats as $cat) { 727 $result[$cat]['children'] = get_nested_link_categories($default, $cat); 728 $result[$cat]['cat_ID'] = $cat; 729 $result[$cat]['checked'] = in_array($cat, $checked_categories); 730 $result[$cat]['cat_name'] = get_the_category_by_ID($cat); 731 } 732 } 733 734 usort($result, 'sort_cats'); 735 736 return $result; 720 737 } 721 738 739 function write_nested_link_categories($categories) { 740 foreach ($categories as $category) { 741 echo '<label for="category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="link_category[]" id="category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : ""), '/> ', wp_specialchars($category['cat_name']), "</label>\n"; 742 743 if (isset ($category['children'])) { 744 echo "\n<span class='cat-nest'>\n"; 745 write_nested_link_categories($category['children']); 746 echo "</span>\n"; 747 } 748 } 749 } 750 751 function dropdown_link_categories($default = 0) { 752 write_nested_link_categories(get_nested_link_categories($default)); 753 } 754 722 755 function wp_create_thumbnail($file, $max_side, $effect = '') { 723 756 724 757 // 1 = GIF, 2 = JPEG, 3 = PNG -
wp-admin/admin-db.php
244 244 global $wpdb; 245 245 246 246 $link = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = '$link_id'"); 247 $link->link_category = wp_get_link_cats($link_id); 247 248 248 249 if ( $output == OBJECT ) { 249 250 return $link; … … 280 281 if ( empty($link_notes) ) 281 282 $link_notes = ''; 282 283 284 // Make sure we set a valid category 285 if (0 == count($link_category) || !is_array($link_category)) { 286 $link_category = array(get_option('default_category')); 287 } 288 283 289 if ( $update ) { 284 290 $wpdb->query("UPDATE $wpdb->links SET link_url='$link_url', 285 291 link_name='$link_name', link_image='$link_image', 286 link_target='$link_target', link_category='$link_category',292 link_target='$link_target', 287 293 link_visible='$link_visible', link_description='$link_description', 288 294 link_rating='$link_rating', link_rel='$link_rel', 289 295 link_notes='$link_notes', link_rss = '$link_rss' 290 296 WHERE link_id='$link_id'"); 291 297 } else { 292 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_ category, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$link_category', '$link_description', '$link_visible', '$link_owner', '$link_rating', '$link_rel', '$link_notes', '$link_rss')");298 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$link_description', '$link_visible', '$link_owner', '$link_rating', '$link_rel', '$link_notes', '$link_rss')"); 293 299 $link_id = $wpdb->insert_id; 294 300 } 295 301 302 wp_set_link_cats($link_id, $link_category); 303 296 304 if ( $update ) 297 305 do_action('edit_link', $link_id); 298 306 else … … 311 319 // Escape data pulled from DB. 312 320 $link = add_magic_quotes($link); 313 321 322 // Passed link category list overwrites existing category list if not empty. 323 if ( isset($linkdata['link_category']) && is_array($linkdata['link_category']) 324 && 0 != count($linkdata['link_category']) ) 325 $link_cats = $linkdata['link_category']; 326 else 327 $link_cats = $link['link_category']; 328 314 329 // Merge old and new fields with new fields overwriting old ones. 315 330 $linkdata = array_merge($link, $linkdata); 331 $linkdata['link_category'] = $link_cats; 316 332 317 333 return wp_insert_link($linkdata); 318 334 } … … 321 337 global $wpdb; 322 338 323 339 do_action('delete_link', $link_id); 340 $wpdb->query("DELETE FROM $wpdb->link2cat WHERE link_id = $link_id"); 324 341 return $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$link_id'"); 325 342 } 326 343 344 function wp_get_link_cats($link_ID = 0) { 345 global $wpdb; 346 347 $sql = "SELECT category_id 348 FROM $wpdb->link2cat 349 WHERE link_id = $link_ID 350 ORDER BY category_id"; 351 352 $result = $wpdb->get_col($sql); 353 354 if ( !$result ) 355 $result = array(); 356 357 return array_unique($result); 358 } 359 360 function wp_set_link_cats($link_ID = 0, $link_categories = array()) { 361 global $wpdb; 362 // If $link_categories isn't already an array, make it one: 363 if (!is_array($link_categories) || 0 == count($link_categories)) 364 $link_categories = array(get_option('default_category')); 365 366 $link_categories = array_unique($link_categories); 367 368 // First the old categories 369 $old_categories = $wpdb->get_col(" 370 SELECT category_id 371 FROM $wpdb->link2cat 372 WHERE link_id = $link_ID"); 373 374 if (!$old_categories) { 375 $old_categories = array(); 376 } else { 377 $old_categories = array_unique($old_categories); 378 } 379 380 // Delete any? 381 $delete_cats = array_diff($old_categories,$link_categories); 382 383 if ($delete_cats) { 384 foreach ($delete_cats as $del) { 385 $wpdb->query(" 386 DELETE FROM $wpdb->link2cat 387 WHERE category_id = $del 388 AND link_id = $link_ID 389 "); 390 } 391 } 392 393 // Add any? 394 $add_cats = array_diff($link_categories, $old_categories); 395 396 if ($add_cats) { 397 foreach ($add_cats as $new_cat) { 398 $wpdb->query(" 399 INSERT INTO $wpdb->link2cat (link_id, category_id) 400 VALUES ($link_ID, $new_cat)"); 401 } 402 } 403 } // wp_set_link_cats() 404 327 405 function post_exists($title, $content = '', $post_date = '') { 328 406 global $wpdb; 329 407 -
wp-admin/edit-link-form.php
1 1 <?php 2 2 if ( ! empty($link_id) ) { 3 $editing = true; 4 $heading = __('Edit a link:'); 3 $heading = __('Edit Link'); 5 4 $submit_text = __('Save Changes »'); 6 $form = '<form action="" method="post" name="editlink" id="editlink">';5 $form = '<form name="editlink" id="editlink" method="post" action="link.php">'; 7 6 } else { 8 $editing = false; 9 $heading = __('<strong>Add</strong> a link:'); 7 $heading = __('Create Link'); 10 8 $submit_text = __('Add Link »'); 11 $form = '<form name="addlink" method="post" action="link-manager.php">';9 $form = '<form name="addlink" id="addlink" method="post" action="link.php">'; 12 10 } 13 11 14 12 function xfn_check($class, $value = '', $type = 'check') { … … 28 26 if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"'; 29 27 } 30 28 } 31 32 29 ?> 33 30 34 31 <div class="wrap"> 35 <?php echo $form ?> 36 <h2><?php echo $heading ?></h2> 37 <fieldset class="options"> 38 <legend><?php _e('Basics') ?></legend> 39 <table class="editform" width="100%" cellspacing="2" cellpadding="5"> 40 <tr> 41 <th width="33%" scope="row"><?php _e('URI:') ?></th> 42 <td width="67%"><input type="text" name="link_url" value="<?php echo $link->link_url; ?>" style="width: 95%;" /></td> 43 </tr> 44 <tr> 45 <th scope="row"><?php _e('Link Name:') ?></th> 46 <td><input type="text" name="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></td> 47 </tr> 48 <tr> 49 <th scope="row"><?php _e('Short description:') ?></th> 50 <td><input type="text" name="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></td> 51 </tr> 52 <tr> 53 <th scope="row"><?php _e('Category:') ?></th> 54 <td><?php link_category_dropdown('link_category', $link->link_category); ?></td> 55 </tr> 56 </table> 32 <h2><?php echo $heading ?></h2> 33 <?php echo $form ?> 34 35 <div id="poststuff"> 36 <div id="moremeta"> 37 <div id="grabit" class="dbx-group"> 38 39 <fieldset id="categorydiv" class="dbx-box"> 40 <h3 class="dbx-handle"><?php _e('Categories') ?></h3> 41 <div class="dbx-content"> 42 <p id="jaxcat"></p> 43 <div id="categorychecklist"><?php dropdown_link_categories(get_settings('default_link_category')); ?></div></div> 57 44 </fieldset> 58 <p class="submit"> 59 <input type="submit" name="submit" value="<?php echo $submit_text ?>" /> 60 </p> 61 <fieldset class="options"> 62 <legend><?php _e('Link Relationship (XFN)') ?></legend> 63 <table class="editform" width="100%" cellspacing="2" cellpadding="5"> 64 <tr> 65 <th width="33%" scope="row"><?php _e('rel:') ?></th> 66 <td width="67%"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo $link->link_rel; ?>" /></td> 67 </tr> 68 <tr> 69 <th scope="row"><?php _e('<a href="http://gmpg.org/xfn/">XFN</a> Creator:') ?></th> 70 <td> 71 <table cellpadding="3" cellspacing="5"> 72 <tr> 73 <th scope="row"> <?php _e('identity') ?> </th> 74 <td> 75 <label for="me"> 76 <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> /> 77 <?php _e('another web address of mine') ?></label> 78 </td> 79 </tr> 80 <tr> 81 <th scope="row"> <?php _e('friendship') ?> </th> 82 <td> 83 <label for="contact"> 84 <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php _e('contact') ?></label> 85 <label for="acquaintance"> 86 <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance', 'radio'); ?> /> <?php _e('acquaintance') ?></label> 87 <label id="friend"> 88 <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend', 'radio'); ?> /> <?php _e('friend') ?></label> 89 <label for="friendship"> 90 <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship', '', 'radio'); ?> /> <?php _e('none') ?></label> 91 </td> 92 </tr> 93 <tr> 94 <th scope="row"> <?php _e('physical') ?> </th> 95 <td> 96 <label for="met"> 97 <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> /> 98 <?php _e('met') ?></label> 99 </td> 100 </tr> 101 <tr> 102 <th scope="row"> <?php _e('professional') ?> </th> 103 <td> 104 <label for="co-worker"> 105 <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> /> 106 <?php _e('co-worker') ?></label> 107 <label for="colleague"> 108 <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> /> 109 <?php _e('colleague') ?></label> 110 </td> 111 </tr> 112 <tr> 113 <th scope="row"> <?php _e('geographical') ?> </th> 114 <td> 115 <label for="co-resident"> 116 <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident', 'radio'); ?> /> 117 <?php _e('co-resident') ?></label> 118 <label for="neighbor"> 119 <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor', 'radio'); ?> /> 120 <?php _e('neighbor') ?></label> 121 <label for="geographical"> 122 <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical', '', 'radio'); ?> /> 123 <?php _e('none') ?></label> 124 </td> 125 </tr> 126 <tr> 127 <th scope="row"> <?php _e('family') ?> </th> 128 <td> 129 <label for="child"> 130 <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child', 'radio'); ?> /> 131 <?php _e('child') ?></label> 132 <label for="kin"> 133 <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin', 'radio'); ?> /> 134 <?php _e('kin') ?></label> 135 <label for="parent"> 136 <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent', 'radio'); ?> /> 137 <?php _e('parent') ?></label> 138 <label for="sibling"> 139 <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling', 'radio'); ?> /> 140 <?php _e('sibling') ?></label> 141 <label for="spouse"> 142 <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse', 'radio'); ?> /> 143 <?php _e('spouse') ?></label> 144 <label for="family"> 145 <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family', '', 'radio'); ?> /> 146 <?php _e('none') ?></label> 147 </td> 148 </tr> 149 <tr> 150 <th scope="row"> <?php _e('romantic') ?> </th> 151 <td> 152 <label for="muse"> 153 <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> /> 154 <?php _e('muse') ?></label> 155 <label for="crush"> 156 <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> /> 157 <?php _e('crush') ?></label> 158 <label for="date"> 159 <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> /> 160 <?php _e('date') ?></label> 161 <label for="romantic"> 162 <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> /> 163 <?php _e('sweetheart') ?></label> 164 </td> 165 </tr> 166 </table> 167 </td> 168 </tr> 45 46 <fieldset class="dbx-box"> 47 <h3 class="dbx-handle"><?php _e('Target') ?></h3> 48 <div class="dbx-content"> 49 <label for="link_target_blank" class="selectit"> 50 <input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> /> 51 <code>_blank</code></label> 52 <label for="link_target_top" class="selectit"> 53 <input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> /> 54 <code>_top</code></label> 55 <label for="link_target_none" class="selectit"> 56 <input id="link_target_none" type="radio" name="link_target" value="" <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> /> 57 <?php _e('none') ?></label> 58 </div> 59 </fieldset> 60 61 <fieldset class="dbx-box"> 62 <h3 class="dbx-handle"><?php _e('Visible') ?></h3> 63 <div class="dbx-content"> 64 <label for="link_visible_yes" class="selectit"> 65 <input id="link_visible_yes" type="radio" name="link_visible" <?php if ($link->link_visible == 'Y') echo "checked='checked'"; ?> value="Y" /> 66 <?php _e('Yes') ?></label> 67 <label for="link_visible_no" class="selectit"> 68 <input id="link_visible_no" type="radio" name="link_visible" <?php if ($link->link_visible == 'N') echo "checked='checked'"; ?> value="N" /> 69 <?php _e('No') ?></label> 70 </div> 71 </fieldset> 72 73 </div> 74 </div> 75 76 <fieldset id="uridiv"> 77 <legend><?php _e('URI:') ?></legend> 78 <div><input type="text" name="link_url" value="<?php echo $link->link_url; ?>" style="width: 95%" /></div> 79 </fieldset> 80 81 <fieldset id="namediv"> 82 <legend><?php _e('Name:') ?></legend> 83 <div><input type="text" name="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></div> 84 </fieldset> 85 86 <fieldset id="descdiv"> 87 <legend><?php _e('Description:') ?></legend> 88 <div><input type="text" name="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></div> 89 </fieldset> 90 91 <p class="submit"> 92 <input type="submit" name="submit" value="<?php echo $submit_text ?>" /> 93 </p> 94 95 <div id="advancedstuff" class="dbx-group" > 96 97 <fieldset id="xfn" class="dbx-box"> 98 <h3 class="dbx-handle"><?php _e('Link Relationship (XFN)') ?></h3> 99 <div class="dbx-content"> 100 <table class="editform" width="100%" cellspacing="2" cellpadding="5"> 101 <tr> 102 <th width="33%" scope="row"><?php _e('rel:') ?></th> 103 <td width="67%"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo $link->link_rel; ?>" /></td> 104 </tr> 105 <tr> 106 <th scope="row"><?php _e('<a href="http://gmpg.org/xfn/">XFN</a> Creator:') ?></th> 107 <td> 108 <table cellpadding="3" cellspacing="5"> 109 <tr> 110 <th scope="row"> <?php _e('identity') ?> </th> 111 <td> 112 <label for="me"> 113 <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> /> 114 <?php _e('another web address of mine') ?></label> 115 </td> 116 </tr> 117 <tr> 118 <th scope="row"> <?php _e('friendship') ?> </th> 119 <td> 120 <label for="contact"> 121 <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php _e('contact') ?></label> 122 <label for="acquaintance"> 123 <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance', 'radio'); ?> /> <?php _e('acquaintance') ?></label> 124 <label id="friend"> 125 <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend', 'radio'); ?> /> <?php _e('friend') ?></label> 126 <label for="friendship"> 127 <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship', '', 'radio'); ?> /> <?php _e('none') ?></label> 128 </td> 129 </tr> 130 <tr> 131 <th scope="row"> <?php _e('physical') ?> </th> 132 <td> 133 <label for="met"> 134 <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> /> 135 <?php _e('met') ?></label> 136 </td> 137 </tr> 138 <tr> 139 <th scope="row"> <?php _e('professional') ?> </th> 140 <td> 141 <label for="co-worker"> 142 <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> /> 143 <?php _e('co-worker') ?></label> 144 <label for="colleague"> 145 <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> /> 146 <?php _e('colleague') ?></label> 147 </td> 148 </tr> 149 <tr> 150 <th scope="row"> <?php _e('geographical') ?> </th> 151 <td> 152 <label for="co-resident"> 153 <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident', 'radio'); ?> /> 154 <?php _e('co-resident') ?></label> 155 <label for="neighbor"> 156 <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor', 'radio'); ?> /> 157 <?php _e('neighbor') ?></label> 158 <label for="geographical"> 159 <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical', '', 'radio'); ?> /> 160 <?php _e('none') ?></label> 161 </td> 162 </tr> 163 <tr> 164 <th scope="row"> <?php _e('family') ?> </th> 165 <td> 166 <label for="child"> 167 <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child', 'radio'); ?> /> 168 <?php _e('child') ?></label> 169 <label for="kin"> 170 <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin', 'radio'); ?> /> 171 <?php _e('kin') ?></label> 172 <label for="parent"> 173 <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent', 'radio'); ?> /> 174 <?php _e('parent') ?></label> 175 <label for="sibling"> 176 <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling', 'radio'); ?> /> 177 <?php _e('sibling') ?></label> 178 <label for="spouse"> 179 <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse', 'radio'); ?> /> 180 <?php _e('spouse') ?></label> 181 <label for="family"> 182 <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family', '', 'radio'); ?> /> 183 <?php _e('none') ?></label> 184 </td> 185 </tr> 186 <tr> 187 <th scope="row"> <?php _e('romantic') ?> </th> 188 <td> 189 <label for="muse"> 190 <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> /> 191 <?php _e('muse') ?></label> 192 <label for="crush"> 193 <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> /> 194 <?php _e('crush') ?></label> 195 <label for="date"> 196 <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> /> 197 <?php _e('date') ?></label> 198 <label for="romantic"> 199 <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> /> 200 <?php _e('sweetheart') ?></label> 201 </td> 202 </tr> 203 </table> 204 </td> 205 </tr> 169 206 </table> 207 </div> 170 208 </fieldset> 171 <p class="submit"> 172 <input type="submit" name="submit" value="<?php echo $submit_text ?>" /> 173 </p> 174 <fieldset class="options"> 175 <legend><?php _e('Advanced') ?></legend> 176 <table class="editform" width="100%" cellspacing="2" cellpadding="5"> 177 <tr> 178 <th width="33%" scope="row"><?php _e('Image URI:') ?></th> 179 <td width="67%"><input type="text" name="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td> 180 </tr> 181 <tr> 182 <th scope="row"><?php _e('RSS URI:') ?> </th> 183 <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo $link->link_rss; ?>" size="50" style="width: 95%" /></td> 184 </tr> 185 <tr> 186 <th scope="row"><?php _e('Notes:') ?></th> 187 <td><textarea name="link_notes" cols="50" rows="10" style="width: 95%"><?php echo $link->link_notes; ?></textarea></td> 188 </tr> 189 <tr> 190 <th scope="row"><?php _e('Rating:') ?></th> 191 <td><select name="link_rating" size="1"> 192 <?php 193 for ($r = 0; $r < 10; $r++) { 194 echo(' <option value="'.$r.'" '); 195 if ($link->link_rating == $r) 196 echo 'selected="selected"'; 197 echo('>'.$r.'</option>'); 198 } 199 ?> 200 </select> 201 <?php _e('(Leave at 0 for no rating.)') ?> </td> 202 </tr> 203 <tr> 204 <th scope="row"><?php _e('Target') ?></th> 205 <td><label> 206 <input type="radio" name="link_target" value="_blank" <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> /> 207 <code>_blank</code></label><br /> 208 <label> 209 <input type="radio" name="link_target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> /> 210 <code>_top</code></label><br /> 211 <label> 212 <input type="radio" name="link_target" value="" <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> /> 213 <?php _e('none') ?></label><br /> 214 <?php _e('(Note that the <code>target</code> attribute is illegal in XHTML 1.1 and 1.0 Strict.)') ?></td> 215 </tr> 216 <tr> 217 <th scope="row"><?php _e('Visible:') ?></th> 218 <td><label> 219 <input type="radio" name="link_visible" <?php if ($link->link_visible == 'Y') echo "checked='checked'"; ?> value="Y" /> 220 <?php _e('Yes') ?></label><br /><label> 221 <input type="radio" name="link_visible" <?php if ($link->link_visible == 'N') echo "checked='checked'"; ?> value="N" /> 222 <?php _e('No') ?></label></td> 223 </tr> 209 210 <fieldset id="advanced" class="dbx-box"> 211 <h3 class="dbx-handle"><?php _e('Advanced') ?></h3> 212 <div class="dbx-content"> 213 <table class="editform" width="100%" cellspacing="2" cellpadding="5"> 214 <tr> 215 <th width="33%" scope="row"><?php _e('Image URI:') ?></th> 216 <td width="67%"><input type="text" name="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td> 217 </tr> 218 <tr> 219 <th scope="row"><?php _e('RSS URI:') ?> </th> 220 <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo $link->link_rss; ?>" size="50" style="width: 95%" /></td> 221 </tr> 222 <tr> 223 <th scope="row"><?php _e('Notes:') ?></th> 224 <td><textarea name="link_notes" cols="50" rows="10" style="width: 95%"><?php echo $link->link_notes; ?></textarea></td> 225 </tr> 226 <tr> 227 <th scope="row"><?php _e('Rating:') ?></th> 228 <td><select name="link_rating" size="1"> 229 <?php 230 for ($r = 0; $r < 10; $r++) { 231 echo(' <option value="'.$r.'" '); 232 if ($link->link_rating == $r) 233 echo 'selected="selected"'; 234 echo('>'.$r.'</option>'); 235 } 236 ?></select> <?php _e('(Leave at 0 for no rating.)') ?> 237 </td> 238 </tr> 224 239 </table> 225 240 </fieldset> 226 <p class="submit"><input type="submit" name="submit" value="<?php echo $submit_text ?>" /></p> 227 <?php if ( $editing ) : ?> 228 <input type="hidden" name="action" value="editlink" /> 229 <input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" /> 230 <input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" /> 231 <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" /> 241 </div> 242 243 <?php if ( $link_id ) : ?> 244 <input type="hidden" name="action" value="save" /> 245 <input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" /> 246 <input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" /> 247 <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" /> 232 248 <?php else: ?> 233 <input type="hidden" name="action" value="Add" />249 <input type="hidden" name="action" value="add" /> 234 250 <?php endif; ?> 235 </form> 251 </div> 252 </form> 236 253 </div> 254 No newline at end of file -
wp-admin/menu.php
30 30 31 31 $submenu['link-manager.php'][5] = array(__('Manage Links'), 'manage_links', 'link-manager.php'); 32 32 $submenu['link-manager.php'][10] = array(__('Add Link'), 'manage_links', 'link-add.php'); 33 $submenu['link-manager.php'][15] = array(__('Link Categories'), 'manage_links', 'link-categories.php');34 33 $submenu['link-manager.php'][20] = array(__('Import Links'), 'manage_links', 'link-import.php'); 35 34 36 35 $submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php'); -
wp-admin/admin-header.php
40 40 var manager = new dbxManager('postmeta'); 41 41 <?php break; case 'page.php' : case 'page-new.php' : ?> 42 42 var manager = new dbxManager('pagemeta'); 43 <?php break; case 'link.php' : case 'link-add.php' : ?> 44 var manager = new dbxManager('linkmeta'); 43 45 <?php break; endswitch; ?> 44 46 }); 45 47 //]]> -
wp-admin/link-categories.php
1 <?php2 // Links3 // Copyright (C) 2002, 2003 Mike Little -- mike@zed1.com4 require_once('admin.php');5 $title = __('Link Categories');6 $this_file='link-categories.php';7 $parent_file = 'link-manager.php';8 $list_js = true;9 10 $wpvarstoreset = array('action', 'cat', 'auto_toggle');11 for ($i=0; $i<count($wpvarstoreset); $i += 1) {12 $wpvar = $wpvarstoreset[$i];13 if (!isset($$wpvar)) {14 if (empty($_POST["$wpvar"])) {15 if (empty($_GET["$wpvar"])) {16 $$wpvar = '';17 } else {18 $$wpvar = $_GET["$wpvar"];19 }20 } else {21 $$wpvar = $_POST["$wpvar"];22 }23 }24 }25 26 switch ($action) {27 case 'addcat':28 {29 if ( !current_user_can('manage_links') )30 die (__("Cheatin' uh ?"));31 32 $cat_name = wp_specialchars($_POST['cat_name']);33 $auto_toggle = $_POST['auto_toggle'];34 if ($auto_toggle != 'Y') {35 $auto_toggle = 'N';36 }37 38 $show_images = $_POST['show_images'];39 if ($show_images != 'Y') {40 $show_images = 'N';41 }42 43 $show_description = $_POST['show_description'];44 if ($show_description != 'Y') {45 $show_description = 'N';46 }47 48 $show_rating = $_POST['show_rating'];49 if ($show_rating != 'Y') {50 $show_rating = 'N';51 }52 53 $show_updated = $_POST['show_updated'];54 if ($show_updated != 'Y') {55 $show_updated = 'N';56 }57 58 $sort_order = $_POST['sort_order'];59 60 $sort_desc = $_POST['sort_desc'];61 if ($sort_desc != 'Y') {62 $sort_desc = 'N';63 }64 $text_before_link = $_POST['text_before_link'];65 $text_after_link = $_POST['text_after_link'];66 $text_after_all = $_POST['text_after_all'];67 68 $list_limit = $_POST['list_limit'];69 if ($list_limit == '')70 $list_limit = -1;71 72 $wpdb->query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name, auto_toggle, show_images, show_description, \n" .73 " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, text_after_all, list_limit) \n" .74 " VALUES ('0', '$cat_name', '$auto_toggle', '$show_images', '$show_description', \n" .75 " '$show_rating', '$show_updated', '$sort_order', '$sort_desc', '$text_before_link', '$text_after_link', \n" .76 " '$text_after_all', $list_limit)");77 78 header('Location: link-categories.php');79 break;80 } // end addcat81 case 'Delete':82 {83 $cat_id = (int) $_GET['cat_id'];84 $cat_name=get_linkcatname($cat_id);85 86 if ($cat_id=="1")87 die(sprintf(__("Can't delete the <strong>%s</strong> link category: this is the default one"), $cat_name));88 89 if ( !current_user_can('manage_links') )90 die (__("Cheatin' uh ?"));91 92 $wpdb->query("DELETE FROM $wpdb->linkcategories WHERE cat_id='$cat_id'");93 $wpdb->query("UPDATE $wpdb->links SET link_category=1 WHERE link_category='$cat_id'");94 95 header('Location: link-categories.php');96 break;97 } // end delete98 case 'Edit':99 {100 include_once ('admin-header.php');101 $cat_id = (int) $_GET['cat_id'];102 $row = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "103 . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "104 . " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_id=$cat_id");105 if ($row) {106 if ($row->list_limit == -1) {107 $row->list_limit = '';108 }109 ?>110 111 <div class="wrap">112 <h2><?php printf(__('Edit “%s” Category'), wp_specialchars($row->cat_name)); ?></h2>113 114 <form name="editcat" method="post">115 <input type="hidden" name="action" value="editedcat" />116 <input type="hidden" name="cat_id" value="<?php echo $row->cat_id ?>" />117 <fieldset class="options">118 <legend><?php _e('Category Options') ?></legend>119 <table class="editform" width="100%" cellspacing="2" cellpadding="5">120 <tr>121 <th width="33%" scope="row"><?php _e('Name:') ?></th>122 <td width="67%"><input name="cat_name" type="text" value="<?php echo wp_specialchars($row->cat_name)?>" size="30" /></td>123 </tr>124 <tr>125 <th scope="row"><?php _e('Show:') ?></th>126 <td>127 <label>128 <input type="checkbox" name="show_images" value="Y" <?php checked('Y', $row->show_images); ?> />129 <?php _e('Image') ?></label> <br />130 <label>131 <input type="checkbox" name="show_description" value="Y" <?php checked('Y', $row->show_description); ?> />132 <?php _e('Description') ?></label>133 <?php _e('(shown in <code>title</code> regardless)') ?><br />134 <label>135 <input type="checkbox" name="show_rating" value="Y" <?php checked('Y', $row->show_rating); ?> />136 <?php _e('Rating') ?></label> <br />137 <label>138 <input type="checkbox" name="show_updated" value="Y" <?php checked('Y', $row->show_updated); ?> />139 <?php _e('Updated') ?></label>140 <?php _e('(shown in <code>title</code> regardless)') ?></td>141 </tr>142 <tr>143 <th scope="row"><?php _e('Sort order:') ?></th>144 <td>145 <select name="sort_order" size="1">146 <option value="name" <?php echo ($row->sort_order == 'name') ? 'selected="selected"' : ''?>><?php _e('Name') ?></option>147 <option value="id" <?php echo ($row->sort_order == 'id') ? 'selected' : ''?>><?php _e('Id') ?></option>148 <option value="url" <?php echo ($row->sort_order == 'url') ? 'selected' : ''?>><?php _e('URL') ?></option>149 <option value="rating" <?php echo ($row->sort_order == 'rating') ? 'selected' : ''?>><?php _e('Rating') ?></option>150 <option value="updated" <?php echo ($row->sort_order == 'updated') ? 'selected' : ''?>><?php _e('Updated') ?></option>151 <option value="rand" <?php echo ($row->sort_order == 'rand') ? 'selected' : ''?>><?php _e('Random') ?></option>152 <option value="length" <?php echo ($row->sort_order == 'length') ? 'selected' : ''?>><?php _e('Name Length') ?></option>153 </select>154 <label>155 <input type="checkbox" name="sort_desc" value="Y" <?php checked('Y', $row->sort_desc); ?> />156 <?php _e('Descending') ?></label>157 </td>158 </tr>159 <tr>160 <th scope="row"><?php _e('Limit:') ?></th>161 <td>162 <input type="text" name="list_limit" size="5" value="<?php echo $row->list_limit ?>" />163 <?php _e('(Leave empty for no limit to number of links shown)') ?>164 </td>165 </tr>166 <tr>167 <th scope="row"><?php _e('Toggle:') ?></th>168 <td><label>169 <input type="checkbox" name="auto_toggle" value="Y" <?php checked('Y', $row->auto_toggle); ?> />170 <?php _e('When new link is added toggle all others to be invisible') ?></label></td>171 </tr>172 173 </table>174 </fieldset>175 <fieldset class="options">176 <legend><?php _e('Formatting') ?></legend>177 <table class="editform" width="100%" cellspacing="2" cellpadding="5">178 <tr>179 <th width="33%" scope="row"><?php _e('Before Link:') ?></th>180 <td width="67%"><input type="text" name="text_before_link" size="45" value="<?php echo wp_specialchars($row->text_before_link)?>" /></td>181 </tr>182 <tr>183 <th scope="row"><?php _e('Between Link and Description:') ?></th>184 <td><input type="text" name="text_after_link" size="45" value="<?php echo wp_specialchars($row->text_after_link)?>" /></td>185 </tr>186 <tr>187 <th scope="row"><?php _e('After Link:') ?></th>188 <td><input type="text" name="text_after_all" size="45" value="<?php echo wp_specialchars($row->text_after_all)?>"/></td>189 </tr>190 </table>191 </fieldset>192 <p class="submit"><input type="submit" name="submit" value="<?php _e('Save Category Settings »') ?>" /></p>193 </form>194 195 </div>196 <?php197 } // end if row198 break;199 } // end Edit200 case "editedcat":201 {202 if ( !current_user_can('manage_links') )203 die (__("Cheatin' uh ?"));204 205 $submit=$_POST["submit"];206 if (isset($submit)) {207 208 $cat_id = (int)$_POST["cat_id"];209 210 $cat_name= wp_specialchars($_POST["cat_name"]);211 $auto_toggle = $_POST["auto_toggle"];212 if ($auto_toggle != 'Y') {213 $auto_toggle = 'N';214 }215 216 $show_images = $_POST["show_images"];217 if ($show_images != 'Y') {218 $show_images = 'N';219 }220 221 $show_description = $_POST["show_description"];222 if ($show_description != 'Y') {223 $show_description = 'N';224 }225 226 $show_rating = $_POST["show_rating"];227 if ($show_rating != 'Y') {228 $show_rating = 'N';229 }230 231 $show_updated = $_POST["show_updated"];232 if ($show_updated != 'Y') {233 $show_updated = 'N';234 }235 236 $sort_order = $_POST["sort_order"];237 238 $sort_desc = $_POST["sort_desc"];239 if ($sort_desc != 'Y') {240 $sort_desc = 'N';241 }242 $text_before_link = $_POST["text_before_link"];243 $text_after_link = $_POST["text_after_link"];244 $text_after_all = $_POST["text_after_all"];245 246 $list_limit = $_POST["list_limit"];247 if ($list_limit == '')248 $list_limit = -1;249 250 $wpdb->query("UPDATE $wpdb->linkcategories set251 cat_name='$cat_name',252 auto_toggle='$auto_toggle',253 show_images='$show_images',254 show_description='$show_description',255 show_rating='$show_rating',256 show_updated='$show_updated',257 sort_order='$sort_order',258 sort_desc='$sort_desc',259 text_before_link='$text_before_link',260 text_after_link='$text_after_link',261 text_after_all='$text_after_all',262 list_limit=$list_limit263 WHERE cat_id=$cat_id264 ");265 } // end if save266 267 268 header("Location: link-categories.php");269 break;270 } // end editcat271 default:272 {273 include_once ("admin-header.php");274 if ( !current_user_can('manage_links') )275 die(__("You have do not have sufficient permissions to edit the link categories for this blog. :)"));276 ?>277 278 <div class="wrap">279 <h2><?php _e('Link Categories:') ?></h2>280 <table id="the-list" width="100%" cellpadding="5" cellspacing="0" border="0">281 <tr>282 <th rowspan="2" valign="bottom"><?php _e('Name') ?></th>283 <th rowspan="2" valign="bottom"><?php _e('ID') ?></th>284 <th rowspan="2" valign="bottom"><?php _e('Toggle?') ?></th>285 <th colspan="4" valign="bottom" class="alternate"><?php _e('Show') ?></th>286 <th rowspan="2" valign="bottom"><?php _e('Sort Order') ?></th>287 <th rowspan="2" valign="bottom"><?php _e('Desc?') ?></th>288 <th colspan="3" valign="bottom" class="alternate"><?php _e('Formatting') ?></th>289 <th rowspan="2" valign="bottom"><?php _e('Limit') ?></th>290 <th rowspan="2" colspan="2"> </th>291 </tr>292 <tr>293 <th valign="top"><?php _e('Images') ?></th>294 <th valign="top"><?php _e('Description') ?></th>295 <th valign="top"><?php _e('Rating') ?></th>296 <th valign="top"><?php _e('Updated') ?></th>297 <th valign="top"><?php _e('Before') ?></th>298 <th valign="top"><?php _e('Between') ?></th>299 <th valign="top"><?php _e('After') ?></th>300 </tr>301 <?php302 $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "303 . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "304 . " text_after_all, list_limit FROM $wpdb->linkcategories ORDER BY cat_id");305 $i = 1;306 foreach ($results as $row) {307 if ($row->list_limit == -1) {308 $row->list_limit = __('none');309 }310 $style = ($i % 2) ? ' class="alternate"' : '';311 /*312 Manually internationalize every sort order option.313 */314 switch ($row->sort_order) {315 case 'name':316 $row->sort_order = __('name');317 break;318 case 'id':319 $row->sort_order = __('id');320 break;321 case 'url':322 $row->sort_order = __('url');323 break;324 case 'rating':325 $row->sort_order = __('rating');326 break;327 case 'updated':328 $row->sort_order = __('updated');329 break;330 case 'rand':331 $row->sort_order = __('rand');332 break;333 case 'length':334 $row->sort_order = __('length');335 break;336 }337 ?>338 <tr id="link-category-<?php echo $row->cat_id; ?>" valign="middle" align="center" <?php echo $style ?> style="border-bottom: 1px dotted #9C9A9C;">339 <td><?php echo wp_specialchars($row->cat_name)?></td>340 <td ><?php echo $row->cat_id?></td>341 <td><?php echo $row->auto_toggle == 'Y' ? __('Yes') : __('No') ?></td>342 <td><?php echo $row->show_images == 'Y' ? __('Yes') : __('No') ?></td>343 <td><?php echo $row->show_description == 'Y' ? __('Yes') : __('No') ?></td>344 <td><?php echo $row->show_rating == 'Y' ? __('Yes') : __('No') ?></td>345 <td><?php echo $row->show_updated == 'Y' ? __('Yes') : __('No') ?></td>346 <td><?php echo $row->sort_order ?></td>347 <td><?php echo $row->sort_desc == 'Y' ? __('Yes') : __('No') ?></td>348 <td nowrap="nowrap"><?php echo htmlentities($row->text_before_link)?> </td>349 <td nowrap="nowrap"><?php echo htmlentities($row->text_after_link)?> </td>350 <td nowrap="nowrap"><?php echo htmlentities($row->text_after_all)?></td>351 <td><?php echo $row->list_limit ?></td>352 <td><a href="link-categories.php?cat_id=<?php echo $row->cat_id?>&action=Edit" class="edit"><?php _e('Edit') ?></a></td>353 <td><a href="link-categories.php?cat_id=<?php echo $row->cat_id?>&action=Delete" onclick="return deleteSomething( 'link category', <?php echo $row->cat_id . ", '" . sprintf(__("You are about to delete the "%s" link category.\\n"Cancel" to stop, "OK" to delete."), wp_specialchars($row->cat_name,1)); ?>' );" class="delete"><?php _e('Delete') ?></a></td>354 </tr>355 <?php356 ++$i;357 }358 ?>359 </table>360 <p><?php _e('These are the defaults for when you call a link category with no additional arguments. All of these settings may be overwritten.') ?></p>361 362 <div id="ajax-response"></div>363 364 </div>365 366 <div class="wrap">367 <form name="addcat" method="post">368 <input type="hidden" name="action" value="addcat" />369 <h2><?php _e('Add a Link Category:') ?></h2>370 <fieldset class="options">371 <legend><?php _e('Category Options') ?></legend>372 <table class="editform" width="100%" cellspacing="2" cellpadding="5">373 <tr>374 <th width="33%" scope="row"><?php _e('Name:') ?></th>375 <td width="67%"><input type="text" name="cat_name" size="30" /></td>376 </tr>377 <tr>378 <th scope="row"><?php _e('Show:') ?></th>379 <td>380 <label>381 <input type="checkbox" name="show_images" value="Y" />382 <?php _e('Image') ?></label> <br />383 <label>384 <input type="checkbox" name="show_description" value="Y" />385 <?php _e('Description') ?></label>386 <?php _e('(shown in <code>title</code> regardless)') ?><br />387 <label>388 <input type="checkbox" name="show_rating" value="Y" />389 <?php _e('Rating') ?></label> <br />390 <label>391 <input type="checkbox" name="show_updated" value="Y" />392 <?php _e('Updated') ?></label>393 <?php _e('(shown in <code>title</code> regardless)') ?></td>394 </tr>395 <tr>396 <th scope="row"><?php _e('Sort order:') ?></th>397 <td>398 <select name="sort_order" size="1">399 <option value="name"><?php _e('Name') ?></option>400 <option value="id"><?php _e('Id') ?></option>401 <option value="url"><?php _e('URL') ?></option>402 <option value="rating"><?php _e('Rating') ?></option>403 <option value="updated"><?php _e('Updated') ?></option>404 <option value="rand"><?php _e('Random') ?></option>405 </select>406 <label>407 <input type="checkbox" name="sort_desc" value="Y" />408 <?php _e('Descending') ?></label>409 </td>410 </tr>411 <tr>412 <th scope="row"><?php _e('Limit:') ?></th>413 <td>414 <input type="text" name="list_limit" size="5" value="" /> <?php _e('(Leave empty for no limit to number of links shown)') ?>415 </td>416 </tr>417 <tr>418 <th scope="row"><?php _e('Toggle:') ?></th>419 <td><label>420 <input type="checkbox" name="auto_toggle" value="Y" />421 <?php _e('When new link is added toggle all others to be invisible') ?></label></td>422 </tr>423 424 </table>425 </fieldset>426 <fieldset class="options">427 <legend><?php _e('Formatting') ?></legend>428 <table class="editform" width="100%" cellspacing="2" cellpadding="5">429 <tr>430 <th width="33%" scope="row"><?php _e('Before Link:') ?></th>431 <td width="67%"><input type="text" name="text_before_link" size="45" value="<li>" /></td>432 </tr>433 <tr>434 <th scope="row"><?php _e('Between Link and Description:') ?></th>435 <td><input type="text" name="text_after_link" size="45" value="<br />" /></td>436 </tr>437 <tr>438 <th scope="row"><?php _e('After Link:') ?></th>439 <td><input type="text" name="text_after_all" size="45" value="</li>"/></td>440 </tr>441 </table>442 </fieldset>443 <p class="submit"><input type="submit" name="submit" value="<?php _e('Add Category »') ?>" /></p>444 </form>445 </div>446 <div class="wrap">447 <h3><?php _e('Note:') ?></h3>448 <p><?php printf(__('Deleting a link category does not delete links from that category.<br />It will just set them back to the default category <strong>%s</strong>.'), get_linkcatname(1)) ?></p>449 </div>450 <?php451 break;452 } // end default453 } // end case454 ?>455 <?php include('admin-footer.php'); ?> -
wp-admin/link-add.php
26 26 } 27 27 28 28 $xfn_js = true; 29 $editing = true; 29 30 require('admin-header.php'); 30 31 ?> 31 32 -
wp-admin/link.php
1 <?php 2 require_once ('admin.php'); 3 4 $wpvarstoreset = array ('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'); 5 6 for ($i = 0; $i < count($wpvarstoreset); $i += 1) { 7 $wpvar = $wpvarstoreset[$i]; 8 if (!isset ($$wpvar)) { 9 if (empty ($_POST["$wpvar"])) { 10 if (empty ($_GET["$wpvar"])) { 11 $$wpvar = ''; 12 } else { 13 $$wpvar = $_GET["$wpvar"]; 14 } 15 } else { 16 $$wpvar = $_POST["$wpvar"]; 17 } 18 } 19 } 20 21 if ('' != $_POST['assign']) 22 $action = 'assign'; 23 if ('' != $_POST['visibility']) 24 $action = 'visibility'; 25 if ('' != $_POST['move']) 26 $action = 'move'; 27 if ('' != $_POST['linkcheck']) 28 $linkcheck = $_POST[linkcheck]; 29 30 $this_file = 'link-manager.php'; 31 32 switch ($action) { 33 case 'assign' : 34 check_admin_referer(); 35 36 // check the current user's level first. 37 if (!current_user_can('manage_links')) 38 die(__("Cheatin' uh ?")); 39 40 //for each link id (in $linkcheck[]): if the current user level >= the 41 //userlevel of the owner of the link then we can proceed. 42 43 if (count($linkcheck) == 0) { 44 header('Location: '.$this_file); 45 exit; 46 } 47 $all_links = join(',', $linkcheck); 48 $results = $wpdb->get_results("SELECT link_id, link_owner FROM $wpdb->links LEFT JOIN $wpdb->users ON link_owner = ID WHERE link_id in ($all_links)"); 49 foreach ($results as $row) { 50 $ids_to_change[] = $row->link_id; 51 } 52 53 // should now have an array of links we can change 54 $all_links = join(',', $ids_to_change); 55 $q = $wpdb->query("update $wpdb->links SET link_owner='$newowner' WHERE link_id IN ($all_links)"); 56 57 header('Location: '.$this_file); 58 break; 59 60 case 'visibility' : 61 check_admin_referer(); 62 63 // check the current user's level first. 64 if (!current_user_can('manage_links')) 65 die(__("Cheatin' uh ?")); 66 67 //for each link id (in $linkcheck[]): toggle the visibility 68 if (count($linkcheck) == 0) { 69 header('Location: '.$this_file); 70 exit; 71 } 72 $all_links = join(',', $linkcheck); 73 $results = $wpdb->get_results("SELECT link_id, link_visible FROM $wpdb->links WHERE link_id in ($all_links)"); 74 foreach ($results as $row) { 75 if ($row->link_visible == 'Y') { // ok to proceed 76 $ids_to_turnoff[] = $row->link_id; 77 } else { 78 $ids_to_turnon[] = $row->link_id; 79 } 80 } 81 82 // should now have two arrays of links to change 83 if (count($ids_to_turnoff)) { 84 $all_linksoff = join(',', $ids_to_turnoff); 85 $q = $wpdb->query("update $wpdb->links SET link_visible='N' WHERE link_id IN ($all_linksoff)"); 86 } 87 88 if (count($ids_to_turnon)) { 89 $all_linkson = join(',', $ids_to_turnon); 90 $q = $wpdb->query("update $wpdb->links SET link_visible='Y' WHERE link_id IN ($all_linkson)"); 91 } 92 93 header('Location: '.$this_file); 94 break; 95 96 case 'move' : 97 check_admin_referer(); 98 99 // check the current user's level first. 100 if (!current_user_can('manage_links')) 101 die(__("Cheatin' uh ?")); 102 103 //for each link id (in $linkcheck[]) change category to selected value 104 if (count($linkcheck) == 0) { 105 header('Location: '.$this_file); 106 exit; 107 } 108 $all_links = join(',', $linkcheck); 109 // should now have an array of links we can change 110 //$q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)"); 111 112 header('Location: '.$this_file); 113 break; 114 115 case 'add' : 116 check_admin_referer(); 117 118 add_link(); 119 120 header('Location: '.$_SERVER['HTTP_REFERER'].'?added=true'); 121 break; 122 123 case 'save' : 124 check_admin_referer(); 125 126 $link_id = (int) $_POST['link_id']; 127 edit_link($link_id); 128 129 wp_redirect($this_file); 130 exit; 131 break; 132 133 case 'delete' : 134 check_admin_referer(); 135 136 if (!current_user_can('manage_links')) 137 die(__("Cheatin' uh ?")); 138 139 $link_id = (int) $_GET['link_id']; 140 141 wp_delete_link($link_id); 142 143 wp_redirect($this_file); 144 break; 145 146 case 'edit' : 147 $xfn_js = true; 148 $editing = true; 149 $parent_file = 'link-manager.php'; 150 $submenu_file = 'link-manager.php'; 151 $title = __('Edit Link'); 152 include_once ('admin-header.php'); 153 if (!current_user_can('manage_links')) 154 die(__('You do not have sufficient permissions to edit the links for this blog.')); 155 156 $link_id = (int) $_GET['link_id']; 157 158 if (!$link = get_link_to_edit($link_id)) 159 die(__('Link not found.')); 160 161 include ('edit-link-form.php'); 162 break; 163 164 default : 165 break; 166 } 167 168 include ('admin-footer.php'); 169 ?> 170 No newline at end of file -
wp-admin/link-manager.php
1 1 <?php 2 3 2 4 // Links 3 5 // Copyright (C) 2002, 2003 Mike Little -- mike@zed1.com 4 6 5 require_once ('admin.php');7 require_once ('admin.php'); 6 8 7 9 $title = __('Manage Links'); 8 10 $this_file = $parent_file = 'link-manager.php'; 9 11 $list_js = true; 10 12 11 $wpvarstoreset = array('action','cat_id', 'linkurl', 'name', 'image', 12 'description', 'visible', 'target', 'category', 'link_id', 13 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 14 'notes', 'linkcheck[]'); 13 $wpvarstoreset = array ('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'); 15 14 16 for ($i =0; $i<count($wpvarstoreset); $i += 1) {17 18 if (!isset($$wpvar)) {19 if (empty($_POST["$wpvar"])) {20 if (empty($_GET["$wpvar"])) {21 22 23 24 25 26 27 28 15 for ($i = 0; $i < count($wpvarstoreset); $i += 1) { 16 $wpvar = $wpvarstoreset[$i]; 17 if (!isset ($$wpvar)) { 18 if (empty ($_POST["$wpvar"])) { 19 if (empty ($_GET["$wpvar"])) { 20 $$wpvar = ''; 21 } else { 22 $$wpvar = $_GET["$wpvar"]; 23 } 24 } else { 25 $$wpvar = $_POST["$wpvar"]; 26 } 27 } 29 28 } 30 29 31 $links_show_cat_id = $_COOKIE['links_show_cat_id_' . COOKIEHASH]; 32 $links_show_order = $_COOKIE['links_show_order_' . COOKIEHASH];30 if (empty ($cat_id)) 31 $cat_id = 'all'; 33 32 34 if ('' != $_POST['assign']) $action = 'assign'; 35 if ('' != $_POST['visibility']) $action = 'visibility'; 36 if ('' != $_POST['move']) $action = 'move'; 37 if ('' != $_POST['linkcheck']) $linkcheck = $_POST[linkcheck]; 33 if (empty ($order_by)) 34 $order_by = 'order_name'; 38 35 39 switch ($action) { 40 case 'assign': 41 { 42 check_admin_referer(); 36 $title = __('Manage Links'); 37 include_once ("./admin-header.php"); 43 38 44 // check the current user's level first. 45 if ( !current_user_can('manage_links') ) 46 die (__("Cheatin' uh ?")); 39 if (!current_user_can('manage_links')) 40 die(__("You do not have sufficient permissions to edit the links for this blog.")); 47 41 48 //for each link id (in $linkcheck[]): if the current user level >= the 49 //userlevel of the owner of the link then we can proceed. 50 51 if (count($linkcheck) == 0) { 52 header('Location: ' . $this_file); 53 exit; 54 } 55 $all_links = join(',', $linkcheck); 56 $results = $wpdb->get_results("SELECT link_id, link_owner FROM $wpdb->links LEFT JOIN $wpdb->users ON link_owner = ID WHERE link_id in ($all_links)"); 57 foreach ($results as $row) { 58 $ids_to_change[] = $row->link_id; 59 } 60 61 // should now have an array of links we can change 62 $all_links = join(',', $ids_to_change); 63 $q = $wpdb->query("update $wpdb->links SET link_owner='$newowner' WHERE link_id IN ($all_links)"); 64 65 header('Location: ' . $this_file); 66 break; 67 } 68 case 'visibility': 69 { 70 check_admin_referer(); 71 72 // check the current user's level first. 73 if ( !current_user_can('manage_links') ) 74 die (__("Cheatin' uh ?")); 75 76 //for each link id (in $linkcheck[]): toggle the visibility 77 if (count($linkcheck) == 0) { 78 header('Location: ' . $this_file); 79 exit; 80 } 81 $all_links = join(',', $linkcheck); 82 $results = $wpdb->get_results("SELECT link_id, link_visible FROM $wpdb->links WHERE link_id in ($all_links)"); 83 foreach ($results as $row) { 84 if ($row->link_visible == 'Y') { // ok to proceed 85 $ids_to_turnoff[] = $row->link_id; 86 } else { 87 $ids_to_turnon[] = $row->link_id; 88 } 89 } 90 91 // should now have two arrays of links to change 92 if (count($ids_to_turnoff)) { 93 $all_linksoff = join(',', $ids_to_turnoff); 94 $q = $wpdb->query("update $wpdb->links SET link_visible='N' WHERE link_id IN ($all_linksoff)"); 95 } 96 97 if (count($ids_to_turnon)) { 98 $all_linkson = join(',', $ids_to_turnon); 99 $q = $wpdb->query("update $wpdb->links SET link_visible='Y' WHERE link_id IN ($all_linkson)"); 100 } 101 102 header('Location: ' . $this_file); 103 break; 104 } 105 case 'move': 106 { 107 check_admin_referer(); 108 109 // check the current user's level first. 110 if ( !current_user_can('manage_links') ) 111 die (__("Cheatin' uh ?")); 112 113 //for each link id (in $linkcheck[]) change category to selected value 114 if (count($linkcheck) == 0) { 115 header('Location: ' . $this_file); 116 exit; 117 } 118 $all_links = join(',', $linkcheck); 119 // should now have an array of links we can change 120 $q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)"); 121 122 header('Location: ' . $this_file); 123 break; 124 } 125 126 case 'Add': 127 { 128 check_admin_referer(); 129 130 add_link(); 131 132 header('Location: ' . $_SERVER['HTTP_REFERER'] . '?added=true'); 133 break; 134 } // end Add 135 136 case 'editlink': 137 { 138 139 check_admin_referer(); 140 141 if (isset($links_show_cat_id) && ($links_show_cat_id != '')) 142 $cat_id = $links_show_cat_id; 143 144 if (!isset($cat_id) || ($cat_id == '')) { 145 if (!isset($links_show_cat_id) || ($links_show_cat_id == '')) 146 $cat_id = 'All'; 147 } 148 $links_show_cat_id = $cat_id; 149 150 $link_id = (int) $_POST['link_id']; 151 edit_link($link_id); 152 153 setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600); 154 wp_redirect($this_file); 155 break; 156 } // end Save 157 158 case 'Delete': 159 { 160 check_admin_referer(); 161 162 if ( !current_user_can('manage_links') ) 163 die (__("Cheatin' uh ?")); 164 165 $link_id = (int) $_GET['link_id']; 166 167 wp_delete_link($link_id); 168 169 if (isset($links_show_cat_id) && ($links_show_cat_id != '')) 170 $cat_id = $links_show_cat_id; 171 172 if (!isset($cat_id) || ($cat_id == '')) { 173 if (!isset($links_show_cat_id) || ($links_show_cat_id == '')) 174 $cat_id = 'All'; 175 } 176 $links_show_cat_id = $cat_id; 177 setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600); 178 wp_redirect($this_file); 179 break; 180 } // end Delete 181 182 case 'linkedit': { 183 $xfn_js = true; 184 include_once ('admin-header.php'); 185 if ( !current_user_can('manage_links') ) 186 die(__('You do not have sufficient permissions to edit the links for this blog.')); 187 188 $link_id = (int) $_GET['link_id']; 189 190 if ( !$link = get_link_to_edit($link_id) ) 191 die( __('Link not found.') ); 192 193 include('edit-link-form.php'); 194 break; 195 } // end linkedit 196 case __("Show"): 197 { 198 if (!isset($cat_id) || ($cat_id == '')) { 199 if (!isset($links_show_cat_id) || ($links_show_cat_id == '')) 200 $cat_id = 'All'; 201 } 202 $links_show_cat_id = $cat_id; 203 if (!isset($order_by) || ($order_by == '')) { 204 if (!isset($links_show_order) || ($links_show_order == '')) 205 $order_by = 'order_name'; 206 } 207 $links_show_order = $order_by; 208 //break; fall through 209 } // end Show 210 case "popup": 211 { 212 $link_url = stripslashes($_GET["linkurl"]); 213 $link_name = stripslashes($_GET["name"]); 214 //break; fall through 215 } 216 default: 217 { 218 if (isset($links_show_cat_id) && ($links_show_cat_id != '')) 219 $cat_id = $links_show_cat_id; 220 221 if (!isset($cat_id) || ($cat_id == '')) { 222 if (!isset($links_show_cat_id) || ($links_show_cat_id == '')) 223 $cat_id = 'All'; 224 } 225 $links_show_cat_id = $cat_id; 226 if (isset($links_show_order) && ($links_show_order != '')) 227 $order_by = $links_show_order; 228 229 if (!isset($order_by) || ($order_by == '')) 230 $order_by = 'order_name'; 231 $links_show_order = $order_by; 232 233 setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600); 234 setcookie('links_show_order_' . COOKIEHASH, $links_show_order, time()+600); 235 include_once ("./admin-header.php"); 236 if ( !current_user_can('manage_links') ) 237 die(__("You do not have sufficient permissions to edit the links for this blog.")); 238 239 switch ($order_by) 240 { 241 case 'order_id': $sqlorderby = 'id'; break; 242 case 'order_url': $sqlorderby = 'url'; break; 243 case 'order_desc': $sqlorderby = 'description'; break; 244 case 'order_owner': $sqlorderby = 'owner'; break; 245 case 'order_rating': $sqlorderby = 'rating'; break; 246 case 'order_name': 247 default: $sqlorderby = 'name'; break; 248 } 249 250 if ($action != "popup") { 42 switch ($order_by) { 43 case 'order_id' : 44 $sqlorderby = 'id'; 45 break; 46 case 'order_url' : 47 $sqlorderby = 'url'; 48 break; 49 case 'order_desc' : 50 $sqlorderby = 'description'; 51 break; 52 case 'order_owner' : 53 $sqlorderby = 'owner'; 54 break; 55 case 'order_rating' : 56 $sqlorderby = 'rating'; 57 break; 58 case 'order_name' : 59 default : 60 $sqlorderby = 'name'; 61 break; 62 } 251 63 ?> 252 64 <script type="text/javascript"> 253 65 <!-- … … 266 78 </script> 267 79 268 80 <div class="wrap"> 269 <form name="cats" method="post" action=""> 270 <table width="75%" cellpadding="3" cellspacing="3"> 271 <tr> 272 <td> 273 <?php _e('<strong>Show</strong> links in category:'); ?><br /> 274 </td> 275 <td> 276 <?php _e('<strong>Order</strong> by:');?> 277 </td> 81 <h2><?php _e('Link Management'); ?></h2> 82 <form name="cats" method="post" action=""> 83 <table width="75%" cellpadding="3" cellspacing="3"> 84 <tr> 85 <td> 86 <?php _e('<strong>Show</strong> links in category:'); ?><br /> 87 </td> 88 <td> 89 <?php _e('<strong>Order</strong> by:');?> 90 </td> 278 91 <td> </td> 279 92 </tr> 280 93 <tr> 281 94 <td> 282 <?php 283 $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id"); 284 echo " <select name=\"cat_id\">\n"; 285 echo " <option value=\"All\""; 286 if ($cat_id == 'All') 287 echo " selected='selected'"; 288 echo "> " . __('All') . "</option>\n"; 289 foreach ($results as $row) { 290 echo " <option value=\"".$row->cat_id."\""; 291 if ($row->cat_id == $cat_id) 292 echo " selected='selected'"; 293 echo ">".$row->cat_id.": ".wp_specialchars($row->cat_name); 294 if ($row->auto_toggle == 'Y') 295 echo ' '.__('(auto toggle)'); 296 echo "</option>\n"; 297 } 298 echo " </select>\n"; 299 ?> 300 </td> 301 <td> 302 <select name="order_by"> 303 <option value="order_id" <?php if ($order_by == 'order_id') echo " selected='selected'";?>><?php _e('Link ID') ?></option> 304 <option value="order_name" <?php if ($order_by == 'order_name') echo " selected='selected'";?>><?php _e('Name') ?></option> 305 <option value="order_url" <?php if ($order_by == 'order_url') echo " selected='selected'";?>><?php _e('URI') ?></option> 306 <option value="order_desc" <?php if ($order_by == 'order_desc') echo " selected='selected'";?>><?php _e('Description') ?></option> 307 <option value="order_owner" <?php if ($order_by == 'order_owner') echo " selected='selected'";?>><?php _e('Owner') ?></option> 308 <option value="order_rating" <?php if ($order_by == 'order_rating') echo " selected='selected'";?>><?php _e('Rating') ?></option> 309 </select> 310 </td> 311 <td> 312 <input type="submit" name="action" value="<?php _e('Show') ?>" /> 313 </td> 314 </tr> 315 </table> 316 </form> 95 <?php $categories = get_categories("hide_empty=0"); ?> 96 <select name="cat_id"> 97 <option value="all" <?php echo ($cat_id == 'all') ? " selected='selected'" : ''; ?>><?php _e('All') ?></option> 98 <?php foreach ($categories as $cat): ?> 99 <option value="<?php echo $cat->cat_ID; ?>"<?php echo ($cat->cat_ID == $cat_id) ? " selected='selected'" : ''; ?>><?php echo $cat->cat_ID . ": " . wp_specialchars($cat->cat_name); ?> 100 </option> 101 <?php endforeach; ?> 102 </select> 103 </td> 104 <td> 105 <select name="order_by"> 106 <option value="order_id" <?php if ($order_by == 'order_id') echo " selected='selected'";?>><?php _e('Link ID') ?></option> 107 <option value="order_name" <?php if ($order_by == 'order_name') echo " selected='selected'";?>><?php _e('Name') ?></option> 108 <option value="order_url" <?php if ($order_by == 'order_url') echo " selected='selected'";?>><?php _e('URI') ?></option> 109 <option value="order_desc" <?php if ($order_by == 'order_desc') echo " selected='selected'";?>><?php _e('Description') ?></option> 110 <option value="order_owner" <?php if ($order_by == 'order_owner') echo " selected='selected'";?>><?php _e('Owner') ?></option> 111 <option value="order_rating" <?php if ($order_by == 'order_rating') echo " selected='selected'";?>><?php _e('Rating') ?></option> 112 </select> 113 </td> 114 <td> 115 <input type="submit" name="action" value="<?php _e('Show') ?>" /> 116 </td> 117 </tr> 118 </table> 119 </form> 317 120 318 </div>319 320 121 <form name="links" id="links" method="post" action=""> 321 <div class="wrap"> 322 323 <input type="hidden" name="link_id" value="" /> 324 <input type="hidden" name="action" value="" /> 325 <input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" /> 326 <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" /> 327 <table id="the-list-x" width="100%" cellpadding="3" cellspacing="3"> 328 <tr> 329 <th width="15%"><?php _e('Name') ?></th> 330 <th><?php _e('URI') ?></th> 331 <th><?php _e('Category') ?></th> 332 <th><?php _e('rel') ?></th> 333 <th><?php _e('Image') ?></th> 334 <th><?php _e('Visible') ?></th> 335 <th colspan="2"><?php _e('Action') ?></th> 336 <th> </th> 337 </tr> 122 <input type="hidden" name="link_id" value="" /> 123 <input type="hidden" name="action" value="" /> 124 <input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" /> 125 <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" /> 126 <table id="the-list-x" width="100%" cellpadding="3" cellspacing="3"> 127 <tr> 128 <th width="15%"><?php _e('Name') ?></th> 129 <th><?php _e('URI') ?></th> 130 <th><?php _e('Category') ?></th> 131 <th><?php _e('rel') ?></th> 132 <th><?php _e('Image') ?></th> 133 <th><?php _e('Visible') ?></th> 134 <th colspan="2"><?php _e('Action') ?></th> 135 <th> </th> 136 </tr> 338 137 <?php 339 $sql = "SELECT link_url, link_name, link_image, link_description, link_visible, 340 link_category AS cat_id, cat_name AS category, $wpdb->users.user_login, link_id, 341 link_rating, link_rel 342 FROM $wpdb->links 343 LEFT JOIN $wpdb->linkcategories ON $wpdb->links.link_category = $wpdb->linkcategories.cat_id 344 LEFT JOIN $wpdb->users ON $wpdb->users.ID = $wpdb->links.link_owner "; 138 if ( 'all' == $cat_id ) 139 $cat_id = ''; 140 $links = get_linkz("category=$cat_id&hide_invisible=0&orderby=$sqlorderby&hide_empty=0"); 141 if ($links) 142 foreach ($links as $link) { 143 $link->link_name = wp_specialchars($link->link_name); 144 $link->link_description = wp_specialchars($link->link_description); 145 $link->link_url = wp_specialchars($link->link_url); 146 $link->link_category = wp_get_link_cats($link->link_id); 147 $short_url = str_replace('http://', '', $link->link_url); 148 $short_url = str_replace('www.', '', $short_url); 149 if ('/' == substr($short_url, -1)) 150 $short_url = substr($short_url, 0, -1); 151 if (strlen($short_url) > 35) 152 $short_url = substr($short_url, 0, 32).'...'; 345 153 346 if (isset($cat_id) && ($cat_id != 'All')) { 347 $sql .= " WHERE link_category = $cat_id "; 348 } 349 $sql .= ' ORDER BY link_' . $sqlorderby; 154 $image = ($link->link_image != null) ? __('Yes') : __('No'); 155 $visible = ($link->link_visible == 'Y') ? __('Yes') : __('No'); 156 ++ $i; 157 $style = ($i % 2) ? '' : ' class="alternate"'; 158 ?> 159 <tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>> 160 <td><strong><?php echo $link->link_name; ?></strong><br /> 161 <?php 350 162 351 // echo "$sql";352 $links = $wpdb->get_results($sql);353 if ($links) {354 foreach ($links as $link) {355 $link->link_name = wp_specialchars($link->link_name);356 $link->link_category = wp_specialchars($link->link_category);357 $link->link_description = wp_specialchars($link->link_description);358 $link->link_url = wp_specialchars($link->link_url);359 $short_url = str_replace('http://', '', $link->link_url);360 $short_url = str_replace('www.', '', $short_url);361 if ('/' == substr($short_url, -1))362 $short_url = substr($short_url, 0, -1);363 if (strlen($short_url) > 35)364 $short_url = substr($short_url, 0, 32).'...';365 163 366 $image = ($link->link_image != null) ? __('Yes') : __('No'); 367 $visible = ($link->link_visible == 'Y') ? __('Yes') : __('No'); 368 ++$i; 369 $style = ($i % 2) ? '' : ' class="alternate"'; 164 echo sprintf(__('Description: %s'), $link->link_description)."</td>"; 165 echo "<td><a href=\"$link->link_url\" title=\"".sprintf(__('Visit %s'), $link->link_name)."\">$short_url</a></td>"; 370 166 ?> 371 <tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>> 372 <td><strong><?php echo $link->link_name; ?></strong><br /> 167 <td> 168 <?php 169 170 171 foreach ($link->link_category as $category) { 172 $cat_name = get_the_category_by_ID($category); 173 echo wp_specialchars($cat_name); 174 echo " "; 175 } 176 ?> 177 </td> 178 <td><?php echo $link->link_rel; ?></td> 179 <td align='center'><?php echo $image; ?></td> 180 <td align='center'><?php echo $visible; ?></td> 373 181 <?php 374 echo sprintf(__('Description: %s'), $link->link_description) . "</td>";375 echo "<td><a href=\"$link->link_url\" title=\"" . sprintf(__('Visit %s'), $link->link_name) . "\">$short_url</a></td>";376 echo <<<LINKS377 <td>$link->category</td>378 <td>$link->link_rel</td>379 <td align='center'>$image</td>380 <td align='center'>$visible</td>381 LINKS;382 $show_buttons = 1; // default383 182 384 if ($show_buttons) { 385 echo '<td><a href="link-manager.php?link_id=' . $link->link_id . '&action=linkedit" class="edit">' . __('Edit') . '</a></td>'; 386 echo '<td><a href="link-manager.php?link_id=' . $link->link_id . '&action=Delete"' . " onclick=\"return deleteSomething( 'link', $link->link_id , '" . sprintf(__("You are about to delete the "%s" link to %s.\\n"Cancel" to stop, "OK" to delete."), wp_specialchars($link->link_name,1), wp_specialchars($link->link_url)) . '\' );" class="delete">' . __('Delete') . '</a></td>'; 387 echo '<td><input type="checkbox" name="linkcheck[]" value="' . $link->link_id . '" /></td>'; 388 } else { 389 echo "<td> </td><td> </td><td> </td>\n"; 390 } 183 echo '<td><a href="link.php?link_id='.$link->link_id.'&action=edit" class="edit">'.__('Edit').'</a></td>'; 184 echo '<td><a href="link.php?link_id='.$link->link_id.'&action=delete"'." onclick=\"return deleteSomething( 'link', $link->link_id , '".sprintf(__("You are about to delete the "%s" link to %s.\\n"Cancel" to stop, "OK" to delete."), wp_specialchars($link->link_name, 1), wp_specialchars($link->link_url)).'\' );" class="delete">'.__('Delete').'</a></td>'; 185 echo '<td><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></td>'; 391 186 echo "\n </tr>\n"; 392 } 393 } 187 } 394 188 ?> 395 189 </table> 396 190 … … 406 200 <td> 407 201 <?php _e('Assign ownership to:'); ?> 408 202 <?php 409 $results = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY ID"); 410 echo " <select name=\"newowner\" size=\"1\">\n"; 411 foreach ($results as $row) { 412 echo " <option value=\"".$row->ID."\""; 413 echo ">".$row->user_login; 414 echo "</option>\n"; 415 } 416 echo " </select>\n"; 203 204 $results = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY ID"); 205 echo " <select name=\"newowner\" size=\"1\">\n"; 206 foreach ($results as $row) { 207 echo " <option value=\"".$row->ID."\""; 208 echo ">".$row->user_login; 209 echo "</option>\n"; 210 } 211 echo " </select>\n"; 417 212 ?> 418 213 <input name="assign" type="submit" id="assign" value="<?php _e('Go') ?>" /> 419 214 </td> 420 215 <td> 421 216 <input name="visibility" type="submit" id="visibility" value="<?php _e('Toggle Visibility') ?>" /> 422 217 </td> 423 <td>424 <?php _e('Move to category:'); link_category_dropdown('category'); ?> <input name="move" type="submit" id="move" value="<?php _e('Go') ?>" />425 </td>426 218 <td align="right"> 427 219 <a href="#" onclick="checkAll(document.getElementById('links')); return false; "><?php _e('Toggle Checkboxes') ?></a> 428 220 </td> 429 221 </tr> 430 222 </table> 431 432 <?php433 } // end if !popup434 ?>435 223 </div> 436 224 </form> 437 225 438 439 <?php 440 break; 441 } // end default 442 } // end case 443 ?> 444 445 <?php include('admin-footer.php'); ?> 226 <?php include('admin-footer.php'); ?> 227 No newline at end of file -
wp-admin/install.php
154 154 if ( ! $public ) 155 155 update_option('default_pingback_flag', 0); 156 156 157 // Now drop in some default links158 $wpdb->query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, '".$wpdb->escape(__('Blogroll'))."')");159 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://blogs.linux.ie/xeer/', 'Donncha', 1, 'http://blogs.linux.ie/xeer/feed/', '');");160 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zengun.org/weblog/', 'Michel', 1, 'http://zengun.org/weblog/feed/', '');");161 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://boren.nu/', 'Ryan', 1, 'http://boren.nu/feed/', '');");162 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://photomatt.net/', 'Matt', 1, 'http://xml.photomatt.net/feed/', '');");163 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zed1.com/journalized/', 'Mike', 1, 'http://zed1.com/journalized/feed/', '');");164 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://www.alexking.org/', 'Alex', 1, 'http://www.alexking.org/blog/wp-rss2.php', '');");165 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://dougal.gunters.org/', 'Dougal', 1, 'http://dougal.gunters.org/feed/', '');");166 167 157 // Default category 168 158 $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_count, category_description) VALUES ('0', '".$wpdb->escape(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."', '1', '')"); 169 159 160 // Default link category 161 $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_count, category_description) VALUES ('0', '".$wpdb->escape(__('Blogroll'))."', '".sanitize_title(__('Blogroll'))."', '1', '')"); 162 163 // Now drop in some default links 164 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://blogs.linux.ie/xeer/', 'Donncha', 0, 'http://blogs.linux.ie/xeer/feed/', '');"); 165 $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (1, 2)" ); 166 167 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zengun.org/weblog/', 'Michel', 0, 'http://zengun.org/weblog/feed/', '');"); 168 $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (2, 2)" ); 169 170 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://boren.nu/', 'Ryan', 0, 'http://boren.nu/feed/', '');"); 171 $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (3, 2)" ); 172 173 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://photomatt.net/', 'Matt', 0, 'http://xml.photomatt.net/feed/', '');"); 174 $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (4, 2)" ); 175 176 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zed1.com/journalized/', 'Mike', 0, 'http://zed1.com/journalized/feed/', '');"); 177 $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (5, 2)" ); 178 179 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://www.alexking.org/', 'Alex', 0, 'http://www.alexking.org/blog/wp-rss2.php', '');"); 180 $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (6, 2)" ); 181 182 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://dougal.gunters.org/', 'Dougal', 0, 'http://dougal.gunters.org/feed/', '');"); 183 $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (7, 2)" ); 184 170 185 // First post 171 186 $now = date('Y-m-d H:i:s'); 172 187 $now_gmt = gmdate('Y-m-d H:i:s'); -
wp-admin/options-writing.php
41 41 ?> 42 42 </select></td> 43 43 </tr> 44 <tr valign="top"> 45 <th scope="row"><?php _e('Default link category:') ?></th> 46 <td><select name="default_link_category" id="default_link_category"> 47 <?php 48 foreach ($categories as $category) : 49 if ($category->cat_ID == get_settings('default_link_category')) $selected = " selected='selected'"; 50 else $selected = ''; 51 echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>"; 52 endforeach; 53 ?> 54 </select></td> 55 </tr> 44 56 </table> 45 57 46 58 <fieldset class="options"> … … 90 102 91 103 <p class="submit"> 92 104 <input type="hidden" name="action" value="update" /> 93 <input type="hidden" name="page_options" value="default_post_edit_rows,use_smilies,rich_editing,ping_sites,mailserver_url,mailserver_port,mailserver_login,mailserver_pass,default_category,default_email_category,use_balanceTags " />105 <input type="hidden" name="page_options" value="default_post_edit_rows,use_smilies,rich_editing,ping_sites,mailserver_url,mailserver_port,mailserver_login,mailserver_pass,default_category,default_email_category,use_balanceTags,default_link_category" /> 94 106 <input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" /> 95 107 </p> 96 108 </form> -
wp-admin/upgrade-schema.php
31 31 KEY comment_approved (comment_approved), 32 32 KEY comment_post_ID (comment_post_ID) 33 33 ); 34 CREATE TABLE $wpdb->link2cat ( 35 rel_id bigint(20) NOT NULL auto_increment, 36 link_id bigint(20) NOT NULL default '0', 37 category_id bigint(20) NOT NULL default '0', 38 PRIMARY KEY (rel_id), 39 KEY link_id (link_id,category_id) 40 ); 34 41 CREATE TABLE $wpdb->linkcategories ( 35 42 cat_id bigint(20) NOT NULL auto_increment, 36 43 cat_name tinytext NOT NULL, … … 231 238 } 232 239 // 2.1 233 240 add_option('blog_public', 1); 241 add_option('default_link_category', 2); 234 242 235 243 // Delete unused options 236 244 $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog');