| [ Index ] |
PHP Cross Reference of Wordpress 2.7.1 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Template WordPress Administration API. 4 * 5 * A Big Mess. Also some neat functions that are nicely written. 6 * 7 * @package WordPress 8 * @subpackage Administration 9 */ 10 11 // Ugly recursive category stuff. 12 /** 13 * {@internal Missing Short Description}} 14 * 15 * @since unknown 16 * 17 * @param unknown_type $parent 18 * @param unknown_type $level 19 * @param unknown_type $categories 20 * @param unknown_type $page 21 * @param unknown_type $per_page 22 */ 23 function cat_rows( $parent = 0, $level = 0, $categories = 0, $page = 1, $per_page = 20 ) { 24 $count = 0; 25 _cat_rows($categories, $count, $parent, $level, $page, $per_page); 26 } 27 28 /** 29 * {@internal Missing Short Description}} 30 * 31 * @since unknown 32 * 33 * @param unknown_type $categories 34 * @param unknown_type $count 35 * @param unknown_type $parent 36 * @param unknown_type $level 37 * @param unknown_type $page 38 * @param unknown_type $per_page 39 * @return unknown 40 */ 41 function _cat_rows( $categories, &$count, $parent = 0, $level = 0, $page = 1, $per_page = 20 ) { 42 if ( empty($categories) ) { 43 $args = array('hide_empty' => 0); 44 if ( !empty($_GET['s']) ) 45 $args['search'] = $_GET['s']; 46 $categories = get_categories( $args ); 47 } 48 49 if ( !$categories ) 50 return false; 51 52 $children = _get_term_hierarchy('category'); 53 54 $start = ($page - 1) * $per_page; 55 $end = $start + $per_page; 56 $i = -1; 57 ob_start(); 58 foreach ( $categories as $category ) { 59 if ( $count >= $end ) 60 break; 61 62 $i++; 63 64 if ( $category->parent != $parent ) 65 continue; 66 67 // If the page starts in a subtree, print the parents. 68 if ( $count == $start && $category->parent > 0 ) { 69 $my_parents = array(); 70 while ( $my_parent) { 71 $my_parent = get_category($my_parent); 72 $my_parents[] = $my_parent; 73 if ( !$my_parent->parent ) 74 break; 75 $my_parent = $my_parent->parent; 76 } 77 $num_parents = count($my_parents); 78 while( $my_parent = array_pop($my_parents) ) { 79 echo "\t" . _cat_row( $my_parent, $level - $num_parents ); 80 $num_parents--; 81 } 82 } 83 84 if ( $count >= $start ) 85 echo "\t" . _cat_row( $category, $level ); 86 87 unset($categories[$i]); // Prune the working set 88 $count++; 89 90 if ( isset($children[$category->term_id]) ) 91 _cat_rows( $categories, $count, $category->term_id, $level + 1, $page, $per_page ); 92 93 } 94 95 $output = ob_get_contents(); 96 ob_end_clean(); 97 98 echo $output; 99 } 100 101 /** 102 * {@internal Missing Short Description}} 103 * 104 * @since unknown 105 * 106 * @param unknown_type $category 107 * @param unknown_type $level 108 * @param unknown_type $name_override 109 * @return unknown 110 */ 111 function _cat_row( $category, $level, $name_override = false ) { 112 static $row_class = ''; 113 114 $category = get_category( $category, OBJECT, 'display' ); 115 116 $default_cat_id = (int) get_option( 'default_category' ); 117 $pad = str_repeat( '— ', $level ); 118 $name = ( $name_override ? $name_override : $pad . ' ' . $category->name ); 119 $edit_link = "categories.php?action=edit&cat_ID=$category->term_id"; 120 if ( current_user_can( 'manage_categories' ) ) { 121 $edit = "<a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "'>" . attribute_escape( $name ) . '</a><br />'; 122 $actions = array(); 123 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; 124 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>'; 125 if ( $default_cat_id != $category->term_id ) 126 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("categories.php?action=delete&cat_ID=$category->term_id", 'delete-category_' . $category->term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this category '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>"; 127 $action_count = count($actions); 128 $i = 0; 129 $edit .= '<div class="row-actions">'; 130 foreach ( $actions as $action => $link ) { 131 ++$i; 132 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; 133 $edit .= "<span class='$action'>$link$sep</span>"; 134 } 135 $edit .= '</div>'; 136 } else { 137 $edit = $name; 138 } 139 140 $row_class = 'alternate' == $row_class ? '' : 'alternate'; 141 $qe_data = get_category_to_edit($category->term_id); 142 143 $category->count = number_format_i18n( $category->count ); 144 $posts_count = ( $category->count > 0 ) ? "<a href='edit.php?cat=$category->term_id'>$category->count</a>" : $category->count; 145 $output = "<tr id='cat-$category->term_id' class='iedit $row_class'>"; 146 147 $columns = get_column_headers('categories'); 148 $hidden = get_hidden_columns('categories'); 149 foreach ( $columns as $column_name => $column_display_name ) { 150 $class = "class=\"$column_name column-$column_name\""; 151 152 $style = ''; 153 if ( in_array($column_name, $hidden) ) 154 $style = ' style="display:none;"'; 155 156 $attributes = "$class$style"; 157 158 switch ($column_name) { 159 case 'cb': 160 $output .= "<th scope='row' class='check-column'>"; 161 if ( $default_cat_id != $category->term_id ) { 162 $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />"; 163 } else { 164 $output .= " "; 165 } 166 $output .= '</th>'; 167 break; 168 case 'name': 169 $output .= "<td $attributes>$edit"; 170 $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">'; 171 $output .= '<div class="name">' . $qe_data->name . '</div>'; 172 $output .= '<div class="slug">' . $qe_data->slug . '</div>'; 173 $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>'; 174 break; 175 case 'description': 176 $output .= "<td $attributes>$category->description</td>"; 177 break; 178 case 'slug': 179 $output .= "<td $attributes>$category->slug</td>"; 180 break; 181 case 'posts': 182 $attributes = 'class="posts column-posts num"' . $style; 183 $output .= "<td $attributes>$posts_count</td>\n"; 184 } 185 } 186 $output .= '</tr>'; 187 188 return $output; 189 } 190 191 /** 192 * {@internal Missing Short Description}} 193 * 194 * @since 2.7 195 * 196 * Outputs the HTML for the hidden table rows used in Categories, Link Caregories and Tags quick edit. 197 * 198 * @param string $type "tag", "category" or "link-category" 199 * @return 200 */ 201 function inline_edit_term_row($type) { 202 203 if ( ! current_user_can( 'manage_categories' ) ) 204 return; 205 206 $is_tag = $type == 'edit-tags'; 207 $columns = get_column_headers($type); 208 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($type) ) ); 209 $col_count = count($columns) - count($hidden); 210 ?> 211 212 <form method="get" action=""><table style="display: none"><tbody id="inlineedit"> 213 <tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $col_count; ?>"> 214 215 <fieldset><div class="inline-edit-col"> 216 <h4><?php _e( 'Quick Edit' ); ?></h4> 217 218 <label> 219 <span class="title"><?php _e( 'Name' ); ?></span> 220 <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span> 221 </label> 222 223 <label> 224 <span class="title"><?php _e( 'Slug' ); ?></span> 225 <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span> 226 </label> 227 228 <?php if ( 'category' == $type ) : ?> 229 230 <label> 231 <span class="title"><?php _e( 'Parent' ); ?></span> 232 <?php wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('None'))); ?> 233 </label> 234 235 <?php endif; // $type ?> 236 237 </div></fieldset> 238 239 <?php 240 241 $core_columns = array( 'cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true ); 242 243 foreach ( $columns as $column_name => $column_display_name ) { 244 if ( isset( $core_columns[$column_name] ) ) 245 continue; 246 do_action( 'quick_edit_custom_box', $column_name, $type ); 247 } 248 249 ?> 250 251 <p class="inline-edit-save submit"> 252 <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="cancel button-secondary alignleft"><?php _e('Cancel'); ?></a> 253 <?php $update_text = ( $is_tag ) ? __( 'Update Tag' ) : __( 'Update Category' ); ?> 254 <a accesskey="s" href="#inline-edit" title="<?php echo attribute_escape( $update_text ); ?>" class="save button-primary alignright"><?php echo $update_text; ?></a> 255 <img class="waiting" style="display:none;" src="images/loading.gif" alt="" /> 256 <span class="error" style="display:none;"></span> 257 <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?> 258 <br class="clear" /> 259 </p> 260 </td></tr> 261 </tbody></table></form> 262 <?php 263 } 264 265 /** 266 * {@internal Missing Short Description}} 267 * 268 * @since unknown 269 * 270 * @param unknown_type $category 271 * @param unknown_type $name_override 272 * @return unknown 273 */ 274 function link_cat_row( $category, $name_override = false ) { 275 static $row_class = ''; 276 277 if ( !$category = get_term( $category, 'link_category', OBJECT, 'display' ) ) 278 return false; 279 if ( is_wp_error( $category ) ) 280 return $category; 281 282 $default_cat_id = (int) get_option( 'default_link_category' ); 283 $name = ( $name_override ? $name_override : $category->name ); 284 $edit_link = "link-category.php?action=edit&cat_ID=$category->term_id"; 285 if ( current_user_can( 'manage_categories' ) ) { 286 $edit = "<a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "'>$name</a><br />"; 287 $actions = array(); 288 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; 289 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>'; 290 if ( $default_cat_id != $category->term_id ) 291 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link-category.php?action=delete&cat_ID=$category->term_id", 'delete-link-category_' . $category->term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this category '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>"; 292 $action_count = count($actions); 293 $i = 0; 294 $edit .= '<div class="row-actions">'; 295 foreach ( $actions as $action => $link ) { 296 ++$i; 297 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; 298 $edit .= "<span class='$action'>$link$sep</span>"; 299 } 300 $edit .= '</div>'; 301 } else { 302 $edit = $name; 303 } 304 305 $row_class = 'alternate' == $row_class ? '' : 'alternate'; 306 $qe_data = get_term_to_edit($category->term_id, 'link_category'); 307 308 $category->count = number_format_i18n( $category->count ); 309 $count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count; 310 $output = "<tr id='link-cat-$category->term_id' class='iedit $row_class'>"; 311 $columns = get_column_headers('edit-link-categories'); 312 $hidden = get_hidden_columns('edit-link-categories'); 313 foreach ( $columns as $column_name => $column_display_name ) { 314 $class = "class=\"$column_name column-$column_name\""; 315 316 $style = ''; 317 if ( in_array($column_name, $hidden) ) 318 $style = ' style="display:none;"'; 319 320 $attributes = "$class$style"; 321 322 switch ($column_name) { 323 case 'cb': 324 $output .= "<th scope='row' class='check-column'>"; 325 if ( absint( get_option( 'default_link_category' ) ) != $category->term_id ) { 326 $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />"; 327 } else { 328 $output .= " "; 329 } 330 $output .= "</th>"; 331 break; 332 case 'name': 333 $output .= "<td $attributes>$edit"; 334 $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">'; 335 $output .= '<div class="name">' . $qe_data->name . '</div>'; 336 $output .= '<div class="slug">' . $qe_data->slug . '</div>'; 337 $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>'; 338 break; 339 case 'description': 340 $output .= "<td $attributes>$category->description</td>"; 341 break; 342 case 'slug': 343 $output .= "<td $attributes>$category->slug</td>"; 344 break; 345 case 'links': 346 $attributes = 'class="links column-links num"' . $style; 347 $output .= "<td $attributes>$count</td>"; 348 } 349 } 350 $output .= '</tr>'; 351 352 return $output; 353 } 354 355 /** 356 * {@internal Missing Short Description}} 357 * 358 * @since unknown 359 * 360 * @param unknown_type $checked 361 * @param unknown_type $current 362 */ 363 function checked( $checked, $current) { 364 if ( $checked == $current) 365 echo ' checked="checked"'; 366 } 367 368 /** 369 * {@internal Missing Short Description}} 370 * 371 * @since unknown 372 * 373 * @param unknown_type $selected 374 * @param unknown_type $current 375 */ 376 function selected( $selected, $current) { 377 if ( $selected == $current) 378 echo ' selected="selected"'; 379 } 380 381 // 382 // Category Checklists 383 // 384 385 /** 386 * {@internal Missing Short Description}} 387 * 388 * @since unknown 389 * @deprecated Use {@link wp_link_category_checklist()} 390 * @see wp_link_category_checklist() 391 * 392 * @param unknown_type $default 393 * @param unknown_type $parent 394 * @param unknown_type $popular_ids 395 */ 396 function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) { 397 global $post_ID; 398 wp_category_checklist($post_ID); 399 } 400 401 /** 402 * {@internal Missing Short Description}} 403 * 404 * @since unknown 405 */ 406 class Walker_Category_Checklist extends Walker { 407 var $tree_type = 'category'; 408 var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this 409 410 function start_lvl(&$output, $depth, $args) { 411 $indent = str_repeat("\t", $depth); 412 $output .= "$indent<ul class='children'>\n"; 413 } 414 415 function end_lvl(&$output, $depth, $args) { 416 $indent = str_repeat("\t", $depth); 417 $output .= "$indent</ul>\n"; 418 } 419 420 function start_el(&$output, $category, $depth, $args) { 421 extract($args); 422 423 $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : ''; 424 $output .= "\n<li id='category-$category->term_id'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="post_category[]" id="in-category-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . wp_specialchars( apply_filters('the_category', $category->name )) . '</label>'; 425 } 426 427 function end_el(&$output, $category, $depth, $args) { 428 $output .= "</li>\n"; 429 } 430 } 431 432 /** 433 * {@internal Missing Short Description}} 434 * 435 * @since unknown 436 * 437 * @param unknown_type $post_id 438 * @param unknown_type $descendants_and_self 439 * @param unknown_type $selected_cats 440 * @param unknown_type $popular_cats 441 */ 442 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null ) { 443 if ( empty($walker) || !is_a($walker, 'Walker') ) 444 $walker = new Walker_Category_Checklist; 445 446 $descendants_and_self = (int) $descendants_and_self; 447 448 $args = array(); 449 450 if ( is_array( $selected_cats ) ) 451 $args['selected_cats'] = $selected_cats; 452 elseif ( $post_id ) 453 $args['selected_cats'] = wp_get_post_categories($post_id); 454 else 455 $args['selected_cats'] = array(); 456 457 if ( is_array( $popular_cats ) ) 458 $args['popular_cats'] = $popular_cats; 459 else 460 $args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); 461 462 if ( $descendants_and_self ) { 463 $categories = get_categories( "child_of=$descendants_and_self&hierarchical=0&hide_empty=0" ); 464 $self = get_category( $descendants_and_self ); 465 array_unshift( $categories, $self ); 466 } else { 467 $categories = get_categories('get=all'); 468 } 469 470 // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache) 471 $checked_categories = array(); 472 for ( $i = 0; isset($categories[$i]); $i++ ) { 473 if ( in_array($categories[$i]->term_id, $args['selected_cats']) ) { 474 $checked_categories[] = $categories[$i]; 475 unset($categories[$i]); 476 } 477 } 478 479 // Put checked cats on top 480 echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args)); 481 // Then the rest of them 482 echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args)); 483 } 484 485 /** 486 * {@internal Missing Short Description}} 487 * 488 * @since unknown 489 * 490 * @param unknown_type $taxonomy 491 * @param unknown_type $default 492 * @param unknown_type $number 493 * @param unknown_type $echo 494 * @return unknown 495 */ 496 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) { 497 global $post_ID; 498 if ( $post_ID ) 499 $checked_categories = wp_get_post_categories($post_ID); 500 else 501 $checked_categories = array(); 502 $categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) ); 503 504 $popular_ids = array(); 505 foreach ( (array) $categories as $category ) { 506 $popular_ids[] = $category->term_id; 507 if ( !$echo ) // hack for AJAX use 508 continue; 509 $id = "popular-category-$category->term_id"; 510 ?> 511 512 <li id="<?php echo $id; ?>" class="popular-category"> 513 <label class="selectit"> 514 <input id="in-<?php echo $id; ?>" type="checkbox" value="<?php echo (int) $category->term_id; ?>" /> 515 <?php echo wp_specialchars( apply_filters( 'the_category', $category->name ) ); ?> 516 </label> 517 </li> 518 519 <?php 520 } 521 return $popular_ids; 522 } 523 524 /** 525 * {@internal Missing Short Description}} 526 * 527 * @since unknown 528 * @deprecated Use {@link wp_link_category_checklist()} 529 * @see wp_link_category_checklist() 530 * 531 * @param unknown_type $default 532 */ 533 function dropdown_link_categories( $default = 0 ) { 534 global $link_id; 535 536 wp_link_category_checklist($link_id); 537 } 538 539 /** 540 * {@internal Missing Short Description}} 541 * 542 * @since unknown 543 * 544 * @param unknown_type $link_id 545 */ 546 function wp_link_category_checklist( $link_id = 0 ) { 547 $default = 1; 548 549 if ( $link_id ) { 550 $checked_categories = wp_get_link_cats($link_id); 551 552 if ( count( $checked_categories ) == 0 ) { 553 // No selected categories, strange 554 $checked_categories[] = $default; 555 } 556 } else { 557 $checked_categories[] = $default; 558 } 559 560 $categories = get_terms('link_category', 'orderby=count&hide_empty=0'); 561 562 if ( empty($categories) ) 563 return; 564 565 foreach ( $categories as $category ) { 566 $cat_id = $category->term_id; 567 $name = wp_specialchars( apply_filters('the_category', $category->name)); 568 $checked = in_array( $cat_id, $checked_categories ); 569 echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', ($checked ? ' checked="checked"' : "" ), '/> ', $name, "</label></li>"; 570 } 571 } 572 573 // Tag stuff 574 575 // Returns a single tag row (see tag_rows below) 576 // Note: this is also used in admin-ajax.php! 577 /** 578 * {@internal Missing Short Description}} 579 * 580 * @since unknown 581 * 582 * @param unknown_type $tag 583 * @param unknown_type $class 584 * @return unknown 585 */ 586 function _tag_row( $tag, $class = '' ) { 587 $count = number_format_i18n( $tag->count ); 588 $count = ( $count > 0 ) ? "<a href='edit.php?tag=$tag->slug'>$count</a>" : $count; 589 590 $name = apply_filters( 'term_name', $tag->name ); 591 $qe_data = get_term($tag->term_id, 'post_tag', object, 'edit'); 592 $edit_link = "edit-tags.php?action=edit&tag_ID=$tag->term_id"; 593 $out = ''; 594 $out .= '<tr id="tag-' . $tag->term_id . '"' . $class . '>'; 595 $columns = get_column_headers('edit-tags'); 596 $hidden = get_hidden_columns('edit-tags'); 597 foreach ( $columns as $column_name => $column_display_name ) { 598 $class = "class=\"$column_name column-$column_name\""; 599 600 $style = ''; 601 if ( in_array($column_name, $hidden) ) 602 $style = ' style="display:none;"'; 603 604 $attributes = "$class$style"; 605 606 switch ($column_name) { 607 case 'cb': 608 $out .= '<th scope="row" class="check-column"> <input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" /></th>'; 609 break; 610 case 'name': 611 $out .= '<td ' . $attributes . '><strong><a class="row-title" href="' . $edit_link . '" title="' . attribute_escape(sprintf(__('Edit "%s"'), $name)) . '">' . $name . '</a></strong><br />'; 612 $actions = array(); 613 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; 614 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>'; 615 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("edit-tags.php?action=delete&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this tag '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>"; 616 $action_count = count($actions); 617 $i = 0; 618 $out .= '<div class="row-actions">'; 619 foreach ( $actions as $action => $link ) { 620 ++$i; 621 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; 622 $out .= "<span class='$action'>$link$sep</span>"; 623 } 624 $out .= '</div>'; 625 $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">'; 626 $out .= '<div class="name">' . $qe_data->name . '</div>'; 627 $out .= '<div class="slug">' . $qe_data->slug . '</div></div></td>'; 628 break; 629 case 'slug': 630 $out .= "<td $attributes>$tag->slug</td>"; 631 break; 632 case 'posts': 633 $attributes = 'class="posts column-posts num"' . $style; 634 $out .= "<td $attributes>$count</td>"; 635 break; 636 } 637 } 638 639 $out .= '</tr>'; 640 641 return $out; 642 } 643 644 // Outputs appropriate rows for the Nth page of the Tag Management screen, 645 // assuming M tags displayed at a time on the page 646 // Returns the number of tags displayed 647 /** 648 * {@internal Missing Short Description}} 649 * 650 * @since unknown 651 * 652 * @param unknown_type $page 653 * @param unknown_type $pagesize 654 * @param unknown_type $searchterms 655 * @return unknown 656 */ 657 function tag_rows( $page = 1, $pagesize = 20, $searchterms = '' ) { 658 659 // Get a page worth of tags 660 $start = ($page - 1) * $pagesize; 661 662 $args = array('offset' => $start, 'number' => $pagesize, 'hide_empty' => 0); 663 664 if ( !empty( $searchterms ) ) { 665 $args['search'] = $searchterms; 666 } 667 668 $tags = get_terms( 'post_tag', $args ); 669 670 // convert it to table rows 671 $out = ''; 672 $count = 0; 673 foreach( $tags as $tag ) 674 $out .= _tag_row( $tag, ++$count % 2 ? ' class="iedit alternate"' : ' class="iedit"' ); 675 676 // filter and send to screen 677 echo $out; 678 return $count; 679 } 680 681 // define the columns to display, the syntax is 'internal name' => 'display name' 682 /** 683 * {@internal Missing Short Description}} 684 * 685 * @since unknown 686 * 687 * @return unknown 688 */ 689 function wp_manage_posts_columns() { 690 $posts_columns = array(); 691 $posts_columns['cb'] = '<input type="checkbox" />'; 692 $posts_columns['title'] = _c('Post|noun'); 693 $posts_columns['author'] = __('Author'); 694 $posts_columns['categories'] = __('Categories'); 695 $posts_columns['tags'] = __('Tags'); 696 if ( !isset($_GET['post_status']) || !in_array($_GET['post_status'], array('pending', 'draft', 'future')) ) 697 $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>'; 698 $posts_columns['date'] = __('Date'); 699 $posts_columns = apply_filters('manage_posts_columns', $posts_columns); 700 701 return $posts_columns; 702 } 703 704 // define the columns to display, the syntax is 'internal name' => 'display name' 705 /** 706 * {@internal Missing Short Description}} 707 * 708 * @since unknown 709 * 710 * @return unknown 711 */ 712 function wp_manage_media_columns() { 713 $posts_columns = array(); 714 $posts_columns['cb'] = '<input type="checkbox" />'; 715 $posts_columns['icon'] = ''; 716 $posts_columns['media'] = _c('File|media column header'); 717 $posts_columns['author'] = __('Author'); 718 //$posts_columns['tags'] = _c('Tags|media column header'); 719 $posts_columns['parent'] = _c('Attached to|media column header'); 720 $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>'; 721 //$posts_columns['comments'] = __('Comments'); 722 $posts_columns['date'] = _c('Date|media column header'); 723 $posts_columns = apply_filters('manage_media_columns', $posts_columns); 724 725 return $posts_columns; 726 } 727 728 /** 729 * {@internal Missing Short Description}} 730 * 731 * @since unknown 732 * 733 * @return unknown 734 */ 735 function wp_manage_pages_columns() { 736 $posts_columns = array(); 737 $posts_columns['cb'] = '<input type="checkbox" />'; 738 $posts_columns['title'] = __('Title'); 739 $posts_columns['author'] = __('Author'); 740 $post_status = 'all'; 741 if ( !empty($_GET['post_status']) ) 742 $post_status = $_GET['post_status']; 743 if ( !in_array($post_status, array('pending', 'draft', 'future')) ) 744 $posts_columns['comments'] = '<div class="vers"><img alt="" src="images/comment-grey-bubble.png" /></div>'; 745 $posts_columns['date'] = __('Date'); 746 $posts_columns = apply_filters('manage_pages_columns', $posts_columns); 747 748 return $posts_columns; 749 } 750 751 /** 752 * {@internal Missing Short Description}} 753 * 754 * @since unknown 755 * 756 * @param unknown_type $page 757 * @return unknown 758 */ 759 function get_column_headers($page) { 760 global $_wp_column_headers; 761 762 if ( !isset($_wp_column_headers) ) 763 $_wp_column_headers = array(); 764 765 // Store in static to avoid running filters on each call 766 if ( isset($_wp_column_headers[$page]) ) 767 return $_wp_column_headers[$page]; 768 769 switch ($page) { 770 case 'edit': 771 $_wp_column_headers[$page] = wp_manage_posts_columns(); 772 break; 773 case 'edit-pages': 774 $_wp_column_headers[$page] = wp_manage_pages_columns(); 775 break; 776 case 'edit-comments': 777 $_wp_column_headers[$page] = array( 778 'cb' => '<input type="checkbox" />', 779 'author' => __('Author'), 780 'comment' => _c('Comment|noun'), 781 //'date' => __('Submitted'), 782 'response' => __('In Response To') 783 ); 784 785 break; 786 case 'link-manager': 787 $_wp_column_headers[$page] = array( 788 'cb' => '<input type="checkbox" />', 789 'name' => __('Name'), 790 'url' => __('URL'), 791 'categories' => __('Categories'), 792 'rel' => __('rel'), 793 'visible' => __('Visible') 794 ); 795 796 break; 797 case 'upload': 798 $_wp_column_headers[$page] = wp_manage_media_columns(); 799 break; 800 case 'categories': 801 $_wp_column_headers[$page] = array( 802 'cb' => '<input type="checkbox" />', 803 'name' => __('Name'), 804 'description' => __('Description'), 805 'slug' => __('Slug'), 806 'posts' => __('Posts') 807 ); 808 809 break; 810 case 'edit-link-categories': 811 $_wp_column_headers[$page] = array( 812 'cb' => '<input type="checkbox" />', 813 'name' => __('Name'), 814 'description' => __('Description'), 815 'slug' => __('Slug'), 816 'links' => __('Links') 817 ); 818 819 break; 820 case 'edit-tags': 821 $_wp_column_headers[$page] = array( 822 'cb' => '<input type="checkbox" />', 823 'name' => __('Name'), 824 'slug' => __('Slug'), 825 'posts' => __('Posts') 826 ); 827 828 break; 829 case 'users': 830 $_wp_column_headers[$page] = array( 831 'cb' => '<input type="checkbox" />', 832 'username' => __('Username'), 833 'name' => __('Name'), 834 'email' => __('E-mail'), 835 'role' => __('Role'), 836 'posts' => __('Posts') 837 ); 838 break; 839 default : 840 $_wp_column_headers[$page] = array(); 841 } 842 843 $_wp_column_headers[$page] = apply_filters('manage_' . $page . '_columns', $_wp_column_headers[$page]); 844 return $_wp_column_headers[$page]; 845 } 846 847 /** 848 * {@internal Missing Short Description}} 849 * 850 * @since unknown 851 * 852 * @param unknown_type $type 853 * @param unknown_type $id 854 */ 855 function print_column_headers( $type, $id = true ) { 856 $type = str_replace('.php', '', $type); 857 $columns = get_column_headers( $type ); 858 $hidden = get_hidden_columns($type); 859 $styles = array(); 860 // $styles['tag']['posts'] = 'width: 90px;'; 861 // $styles['link-category']['links'] = 'width: 90px;'; 862 // $styles['category']['posts'] = 'width: 90px;'; 863 // $styles['link']['visible'] = 'text-align: center;'; 864 865 foreach ( $columns as $column_key => $column_display_name ) { 866 $class = ' class="manage-column'; 867 868 $class .= " column-$column_key"; 869 870 if ( 'cb' == $column_key ) 871 $class .= ' check-column'; 872 elseif ( in_array($column_key, array('posts', 'comments', 'links')) ) 873 $class .= ' num'; 874 875 $class .= '"'; 876 877 $style = ''; 878 if ( in_array($column_key, $hidden) ) 879 $style = 'display:none;'; 880 881 if ( isset($styles[$type]) && isset($styles[$type][$column_key]) ) 882 $style .= ' ' . $styles[$type][$column_key]; 883 $style = ' style="' . $style . '"'; 884 ?> 885 <th scope="col" <?php echo $id ? "id=\"$column_key\"" : ""; echo $class; echo $style; ?>><?php echo $column_display_name; ?></th> 886 <?php } 887 } 888 889 /** 890 * Register column headers for a particular screen. The header names will be listed in the Screen Options. 891 * 892 * @since 2.7.0 893 * 894 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions. 895 * @param array $columns An array of columns with column IDs as the keys and translated column names as the values 896 * @see get_column_headers(), print_column_headers(), get_hidden_columns() 897 */ 898 function register_column_headers($screen, $columns) { 899 global $_wp_column_headers; 900 901 if ( !isset($_wp_column_headers) ) 902 $_wp_column_headers = array(); 903 904 $_wp_column_headers[$screen] = $columns; 905 } 906 907 /** 908 * {@internal Missing Short Description}} 909 * 910 * @since unknown 911 * 912 * @param unknown_type $page 913 */ 914 function get_hidden_columns($page) { 915 $page = str_replace('.php', '', $page); 916 return (array) get_user_option( 'manage-' . $page . '-columns-hidden', 0, false ); 917 } 918 919 /** 920 * {@internal Missing Short Description}} 921 * 922 * Outputs the quick edit and bulk edit table rows for posts and pages 923 * 924 * @since 2.7 925 * 926 * @param string $type 'post' or 'page' 927 */ 928 function inline_edit_row( $type ) { 929 global $current_user, $mode; 930 931 $is_page = 'page' == $type; 932 if ( $is_page ) { 933 $screen = 'edit-pages'; 934 $post = get_default_page_to_edit(); 935 } else { 936 $screen = 'edit'; 937 $post = get_default_post_to_edit(); 938 } 939 940 $columns = $is_page ? wp_manage_pages_columns() : wp_manage_posts_columns(); 941 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($screen) ) ); 942 $col_count = count($columns) - count($hidden); 943 $m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list'; 944 $can_publish = current_user_can("publish_{$type}s"); 945 $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true ); 946 947 ?> 948 949 <form method="get" action=""><table style="display: none"><tbody id="inlineedit"> 950 <?php 951 $bulk = 0; 952 while ( $bulk < 2 ) { ?> 953 954 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$type "; 955 echo $bulk ? "bulk-edit-row bulk-edit-row-$type" : "quick-edit-row quick-edit-row-$type"; 956 ?>" style="display: none"><td colspan="<?php echo $col_count; ?>"> 957 958 <fieldset class="inline-edit-col-left"><div class="inline-edit-col"> 959 <h4><?php echo $bulk ? ( $is_page ? __( 'Bulk Edit Pages' ) : __( 'Bulk Edit Posts' ) ) : __( 'Quick Edit' ); ?></h4> 960 961 962 <?php if ( $bulk ) : ?> 963 <div id="bulk-title-div"> 964 <div id="bulk-titles"></div> 965 </div> 966 967 <?php else : // $bulk ?> 968 969 <label> 970 <span class="title"><?php _e( 'Title' ); ?></span> 971 <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span> 972 </label> 973 974 <?php endif; // $bulk ?> 975 976 977 <?php if ( !$bulk ) : ?> 978 979 <label> 980 <span class="title"><?php _e( 'Slug' ); ?></span> 981 <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span> 982 </label> 983 984 <label><span class="title"><?php _e( 'Date' ); ?></span></label> 985 <div class="inline-edit-date"> 986 <?php touch_time(1, 1, 4, 1); ?> 987 </div> 988 <br class="clear" /> 989 990 <?php endif; // $bulk 991 992 ob_start(); 993 $authors = get_editable_user_ids( $current_user->id, true, $type ); // TODO: ROLE SYSTEM 994 if ( $authors && count( $authors ) > 1 ) : 995 $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1); 996 if ( $bulk ) 997 $users_opt['show_option_none'] = __('- No Change -'); 998 ?> 999 <label> 1000 <span class="title"><?php _e( 'Author' ); ?></span> 1001 <?php wp_dropdown_users( $users_opt ); ?> 1002 </label> 1003 1004 <?php 1005 endif; // authors 1006 $authors_dropdown = ob_get_clean(); 1007 ?> 1008 1009 <?php if ( !$bulk ) : echo $authors_dropdown; ?> 1010 1011 <div class="inline-edit-group"> 1012 <label class="alignleft"> 1013 <span class="title"><?php _e( 'Password' ); ?></span> 1014 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span> 1015 </label> 1016 1017 <em style="margin:5px 10px 0 0" class="alignleft"><?php echo _c( '–OR–|Between password field and private checkbox on post quick edit interface' ); ?></em> 1018 1019 <label class="alignleft inline-edit-private"> 1020 <input type="checkbox" name="keep_private" value="private" /> 1021 <span class="checkbox-title"><?php echo $is_page ? __('Private page') : __('Private post'); ?></span> 1022 </label> 1023 </div> 1024 1025 <?php endif; ?> 1026 1027 </div></fieldset> 1028 1029 <?php if ( !$is_page && !$bulk ) : ?> 1030 1031 <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col"> 1032 <span class="title inline-edit-categories-label"><?php _e( 'Categories' ); ?> 1033 <span class="catshow"><?php _e('[more]'); ?></span> 1034 <span class="cathide" style="display:none;"><?php _e('[less]'); ?></span> 1035 </span> 1036 <ul class="cat-checklist"> 1037 <?php wp_category_checklist(); ?> 1038 </ul> 1039 </div></fieldset> 1040 1041 <?php endif; // !$is_page && !$bulk ?> 1042 1043 <fieldset class="inline-edit-col-right"><div class="inline-edit-col"> 1044 1045 <?php 1046 if ( $bulk ) 1047 echo $authors_dropdown; 1048 ?> 1049 1050 <?php if ( $is_page ) : ?> 1051 1052 <label> 1053 <span class="title"><?php _e( 'Parent' ); ?></span> 1054 <?php 1055 $dropdown_args = array('selected' => $post->post_parent, 'name' => 'post_parent', 'show_option_none' => __('Main Page (no parent)'), 'option_none_value' => 0, 'sort_column'=> 'menu_order, post_title'); 1056 if ( $bulk ) 1057 $dropdown_args['show_option_no_change'] = __('- No Change -'); 1058 $dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args); 1059 wp_dropdown_pages($dropdown_args); 1060 ?> 1061 </label> 1062 1063 <?php if ( !$bulk ) : ?> 1064 1065 <label> 1066 <span class="title"><?php _e( 'Order' ); ?></span> 1067 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span> 1068 </label> 1069 1070 <?php endif; // !$bulk ?> 1071 1072 <label> 1073 <span class="title"><?php _e( 'Template' ); ?></span> 1074 <select name="page_template"> 1075 <?php if ( $bulk ) : ?> 1076 <option value="-1"><?php _e('- No Change -'); ?></option> 1077 <?php endif; // $bulk ?> 1078 <option value="default"><?php _e( 'Default Template' ); ?></option> 1079 <?php page_template_dropdown() ?> 1080 </select> 1081 </label> 1082 1083 <?php elseif ( !$bulk ) : // $is_page ?> 1084 1085 <label class="inline-edit-tags"> 1086 <span class="title"><?php _e( 'Tags' ); ?></span> 1087 <textarea cols="22" rows="1" name="tags_input" class="tags_input"></textarea> 1088 </label> 1089 1090 <?php endif; // $is_page ?> 1091 1092 <?php if ( $bulk ) : ?> 1093 1094 <div class="inline-edit-group"> 1095 <label class="alignleft"> 1096 <span class="title"><?php _e( 'Comments' ); ?></span> 1097 <select name="comment_status"> 1098 <option value=""><?php _e('- No Change -'); ?></option> 1099 <option value="open"><?php _e('Allow'); ?></option> 1100 <option value="closed"><?php _e('Do not allow'); ?></option> 1101 </select> 1102 </label> 1103 1104 <label class="alignright"> 1105 <span class="title"><?php _e( 'Pings' ); ?></span> 1106 <select name="ping_status"> 1107 <option value=""><?php _e('- No Change -'); ?></option> 1108 <option value="open"><?php _e('Allow'); ?></option> 1109 <option value="closed"><?php _e('Do not allow'); ?></option> 1110 </select> 1111 </label> 1112 </div> 1113 1114 <?php else : // $bulk ?> 1115 1116 <div class="inline-edit-group"> 1117 <label class="alignleft"> 1118 <input type="checkbox" name="comment_status" value="open" /> 1119 <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span> 1120 </label> 1121 1122 <label class="alignleft"> 1123 <input type="checkbox" name="ping_status" value="open" /> 1124 <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span> 1125 </label> 1126 </div> 1127 1128 <?php endif; // $bulk ?> 1129 1130 1131 <div class="inline-edit-group"> 1132 <label class="inline-edit-status alignleft"> 1133 <span class="title"><?php _e( 'Status' ); ?></span> 1134 <select name="_status"> 1135 <?php if ( $bulk ) : ?> 1136 <option value="-1"><?php _e('- No Change -'); ?></option> 1137 <?php endif; // $bulk ?> 1138 <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?> 1139 <option value="publish"><?php _e( 'Published' ); ?></option> 1140 <option value="future"><?php _e( 'Scheduled' ); ?></option> 1141 <?php if ( $bulk ) : ?> 1142 <option value="private"><?php _e('Private') ?></option> 1143 <?php endif; // $bulk ?> 1144 <?php endif; ?> 1145 <option value="pending"><?php _e( 'Pending Review' ); ?></option> 1146 <option value="draft"><?php _e( 'Unpublished' ); ?></option> 1147 </select> 1148 </label> 1149 1150 <?php if ( !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ) : ?> 1151 1152 <?php if ( $bulk ) : ?> 1153 1154 <label class="alignright"> 1155 <span class="title"><?php _e( 'Sticky' ); ?></span> 1156 <select name="sticky"> 1157 <option value="-1"><?php _e( '- No Change -' ); ?></option> 1158 <option value="sticky"><?php _e( 'Sticky' ); ?></option> 1159 <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option> 1160 </select> 1161 </label> 1162 1163 <?php else : // $bulk ?> 1164 1165 <label class="alignleft"> 1166 <input type="checkbox" name="sticky" value="sticky" /> 1167 <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span> 1168 </label> 1169 1170 <?php endif; // $bulk ?> 1171 1172 <?php endif; // !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ?> 1173 1174 </div> 1175 1176 </div></fieldset> 1177 1178 <?php 1179 foreach ( $columns as $column_name => $column_display_name ) { 1180 if ( isset( $core_columns[$column_name] ) ) 1181 continue; 1182 do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $type); 1183 } 1184 ?> 1185 <p class="submit inline-edit-save"> 1186 <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="button-secondary cancel alignleft"><?php _e('Cancel'); ?></a> 1187 <?php if ( ! $bulk ) { 1188 wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); 1189 $update_text = ( $is_page ) ? __( 'Update Page' ) : __( 'Update Post' ); 1190 ?> 1191 <a accesskey="s" href="#inline-edit" title="<?php _e('Update'); ?>" class="button-primary save alignright"><?php echo attribute_escape( $update_text ); ?></a> 1192 <img class="waiting" style="display:none;" src="images/loading.gif" alt="" /> 1193 <?php } else { 1194 $update_text = ( $is_page ) ? __( 'Update Pages' ) : __( 'Update Posts' ); 1195 ?> 1196 <input accesskey="s" class="button-primary alignright" type="submit" name="bulk_edit" value="<?php echo attribute_escape( $update_text ); ?>" /> 1197 <?php } ?> 1198 <input type="hidden" name="post_view" value="<?php echo $m; ?>" /> 1199 <br class="clear" /> 1200 </p> 1201 </td></tr> 1202 <?php 1203 $bulk++; 1204 } ?> 1205 </tbody></table></form> 1206 <?php 1207 } 1208 1209 // adds hidden fields with the data for use in the inline editor for posts and pages 1210 /** 1211 * {@internal Missing Short Description}} 1212 * 1213 * @since unknown 1214 * 1215 * @param unknown_type $post 1216 */ 1217 function get_inline_data($post) { 1218 1219 if ( ! current_user_can('edit_' . $post->post_type, $post->ID) ) 1220 return; 1221 1222 $title = attribute_escape($post->post_title); 1223 1224 echo ' 1225 <div class="hidden" id="inline_' . $post->ID . '"> 1226 <div class="post_title">' . $title . '</div> 1227 <div class="post_name">' . $post->post_name . '</div> 1228 <div class="post_author">' . $post->post_author . '</div> 1229 <div class="comment_status">' . $post->comment_status . '</div> 1230 <div class="ping_status">' . $post->ping_status . '</div> 1231 <div class="_status">' . $post->post_status . '</div> 1232 <div class="jj">' . mysql2date( 'd', $post->post_date ) . '</div> 1233 <div class="mm">' . mysql2date( 'm', $post->post_date ) . '</div> 1234 <div class="aa">' . mysql2date( 'Y', $post->post_date ) . '</div> 1235 <div class="hh">' . mysql2date( 'H', $post->post_date ) . '</div> 1236 <div class="mn">' . mysql2date( 'i', $post->post_date ) . '</div> 1237 <div class="ss">' . mysql2date( 's', $post->post_date ) . '</div> 1238 <div class="post_password">' . wp_specialchars($post->post_password, 1) . '</div>'; 1239 1240 if( $post->post_type == 'page' ) 1241 echo ' 1242 <div class="post_parent">' . $post->post_parent . '</div> 1243 <div class="page_template">' . wp_specialchars(get_post_meta( $post->ID, '_wp_page_template', true ), 1) . '</div> 1244 <div class="menu_order">' . $post->menu_order . '</div>'; 1245 1246 if( $post->post_type == 'post' ) 1247 echo ' 1248 <div class="tags_input">' . wp_specialchars( str_replace( ',', ', ', get_tags_to_edit($post->ID) ), 1) . '</div> 1249 <div class="post_category">' . implode( ',', wp_get_post_categories( $post->ID ) ) . '</div> 1250 <div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>'; 1251 1252 echo '</div>'; 1253 } 1254 1255 /** 1256 * {@internal Missing Short Description}} 1257 * 1258 * @since unknown 1259 * 1260 * @param unknown_type $posts 1261 */ 1262 function post_rows( $posts = array() ) { 1263 global $wp_query, $post, $mode; 1264 1265 add_filter('the_title','wp_specialchars'); 1266 1267 // Create array of post IDs. 1268 $post_ids = array(); 1269 1270 if ( empty($posts) ) 1271 $posts = &$wp_query->posts; 1272 1273 foreach ( $posts as $a_post ) 1274 $post_ids[] = $a_post->ID; 1275 1276 $comment_pending_count = get_pending_comments_num($post_ids); 1277 if ( empty($comment_pending_count) ) 1278 $comment_pending_count = array(); 1279 1280 foreach ( $posts as $post ) { 1281 if ( empty($comment_pending_count[$post->ID]) ) 1282 $comment_pending_count[$post->ID] = 0; 1283 1284 _post_row($post, $comment_pending_count[$post->ID], $mode); 1285 } 1286 } 1287 1288 /** 1289 * {@internal Missing Short Description}} 1290 * 1291 * @since unknown 1292 * 1293 * @param unknown_type $a_post 1294 * @param unknown_type $pending_comments 1295 * @param unknown_type $mode 1296 */ 1297 function _post_row($a_post, $pending_comments, $mode) { 1298 global $post; 1299 static $rowclass; 1300 1301 $global_post = $post; 1302 $post = $a_post; 1303 setup_postdata($post); 1304 1305 $rowclass = 'alternate' == $rowclass ? '' : 'alternate'; 1306 global $current_user; 1307 $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' ); 1308 $edit_link = get_edit_post_link( $post->ID ); 1309 $title = _draft_or_post_title(); 1310 ?> 1311 <tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status ); ?> iedit' valign="top"> 1312 <?php 1313 $posts_columns = get_column_headers('edit'); 1314 $hidden = get_hidden_columns('edit'); 1315 foreach ( $posts_columns as $column_name=>$column_display_name ) { 1316 $class = "class=\"$column_name column-$column_name\""; 1317 1318 $style = ''; 1319 if ( in_array($column_name, $hidden) ) 1320 $style = ' style="display:none;"'; 1321 1322 $attributes = "$class$style"; 1323 1324 switch ($column_name) { 1325 1326 case 'cb': 1327 ?> 1328 <th scope="row" class="check-column"><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th> 1329 <?php 1330 break; 1331 1332 case 'date': 1333 if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) { 1334 $t_time = $h_time = __('Unpublished'); 1335 } else { 1336 $t_time = get_the_time(__('Y/m/d g:i:s A')); 1337 $m_time = $post->post_date; 1338 $time = get_post_time('G', true, $post); 1339 1340 $time_diff = time() - $time; 1341 1342 if ( ( 'future' == $post->post_status) ) { 1343 if ( $time_diff <= 0 ) { 1344 $h_time = sprintf( __('%s from now'), human_time_diff( $time ) ); 1345 } else { 1346 $h_time = $t_time; 1347 $missed = true; 1348 } 1349 } else { 1350 1351 if ( $time_diff > 0 && $time_diff < 24*60*60 ) 1352 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); 1353 else 1354 $h_time = mysql2date(__('Y/m/d'), $m_time); 1355 } 1356 } 1357 1358 echo '<td ' . $attributes . '>'; 1359 if ( 'excerpt' == $mode ) 1360 echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode); 1361 else 1362 echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>'; 1363 echo '<br />'; 1364 if ( 'publish' == $post->post_status ) { 1365 _e('Published'); 1366 } elseif ( 'future' == $post->post_status ) { 1367 if ( isset($missed) ) 1368 echo '<strong class="attention">' . __('Missed schedule') . '</strong>'; 1369 else 1370 _e('Scheduled'); 1371 } else { 1372 _e('Last Modified'); 1373 } 1374 echo '</td>'; 1375 break; 1376 1377 case 'title': 1378 $attributes = 'class="post-title column-title"' . $style; 1379 ?> 1380 <td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong> 1381 <?php 1382 if ( 'excerpt' == $mode ) 1383 the_excerpt(); 1384 1385 $actions = array(); 1386 if ( current_user_can('edit_post', $post->ID) ) { 1387 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . attribute_escape(__('Edit this post')) . '">' . __('Edit') . '</a>'; 1388 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . attribute_escape(__('Edit this post inline')) . '">' . __('Quick Edit') . '</a>'; 1389 $actions['delete'] = "<a class='submitdelete' title='" . attribute_escape(__('Delete this post')) . "' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>"; 1390 } 1391 if ( in_array($post->post_status, array('pending', 'draft')) ) { 1392 if ( current_user_can('edit_post', $post->ID) ) 1393 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . attribute_escape(sprintf(__('Preview "%s"'), $title)) . '" rel="permalink">' . __('Preview') . '</a>'; 1394 } else { 1395 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . attribute_escape(sprintf(__('View "%s"'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 1396 } 1397 $action_count = count($actions); 1398 $i = 0; 1399 echo '<div class="row-actions">'; 1400 foreach ( $actions as $action => $link ) { 1401 ++$i; 1402 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; 1403 echo "<span class='$action'>$link$sep</span>"; 1404 } 1405 echo '</div>'; 1406 1407 get_inline_data($post); 1408 ?> 1409 </td> 1410 <?php 1411 break; 1412 1413 case 'categories': 1414 ?> 1415 <td <?php echo $attributes ?>><?php 1416 $categories = get_the_category(); 1417 if ( !empty( $categories ) ) { 1418 $out = array(); 1419 foreach ( $categories as $c ) 1420 $out[] = "<a href='edit.php?category_name=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>"; 1421 echo join( ', ', $out ); 1422 } else { 1423 _e('Uncategorized'); 1424 } 1425 ?></td> 1426 <?php 1427 break; 1428 1429 case 'tags': 1430 ?> 1431 <td <?php echo $attributes ?>><?php 1432 $tags = get_the_tags($post->ID); 1433 if ( !empty( $tags ) ) { 1434 $out = array(); 1435 foreach ( $tags as $c ) 1436 $out[] = "<a href='edit.php?tag=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>"; 1437 echo join( ', ', $out ); 1438 } else { 1439 _e('No Tags'); 1440 } 1441 ?></td> 1442 <?php 1443 break; 1444 1445 case 'comments': 1446 ?> 1447 <td <?php echo $attributes ?>><div class="post-com-count-wrapper"> 1448 <?php 1449 $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) ); 1450 if ( $pending_comments ) 1451 echo '<strong>'; 1452 comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>'); 1453 if ( $pending_comments ) 1454 echo '</strong>'; 1455 ?> 1456 </div></td> 1457 <?php 1458 break; 1459 1460 case 'author': 1461 ?> 1462 <td <?php echo $attributes ?>><a href="edit.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td> 1463 <?php 1464 break; 1465 1466 case 'control_view': 1467 ?> 1468 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td> 1469 <?php 1470 break; 1471 1472 case 'control_edit': 1473 ?> 1474 <td><?php if ( current_user_can('edit_post', $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td> 1475 <?php 1476 break; 1477 1478 case 'control_delete': 1479 ?> 1480 <td><?php if ( current_user_can('delete_post', $post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&post=$id", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td> 1481 <?php 1482 break; 1483 1484 default: 1485 ?> 1486 <td <?php echo $attributes ?>><?php do_action('manage_posts_custom_column', $column_name, $post->ID); ?></td> 1487 <?php 1488 break; 1489 } 1490 } 1491 ?> 1492 </tr> 1493 <?php 1494 $post = $global_post; 1495 } 1496 1497 /* 1498 * display one row if the page doesn't have any children 1499 * otherwise, display the row and its children in subsequent rows 1500 */ 1501 /** 1502 * {@internal Missing Short Description}} 1503 * 1504 * @since unknown 1505 * 1506 * @param unknown_type $page 1507 * @param unknown_type $level 1508 */ 1509 function display_page_row( $page, $level = 0 ) { 1510 global $post; 1511 static $rowclass; 1512 1513 $post = $page; 1514 setup_postdata($page); 1515 1516 $page->post_title = wp_specialchars( $page->post_title ); 1517 $pad = str_repeat( '— ', $level ); 1518 $id = (int) $page->ID; 1519 $rowclass = 'alternate' == $rowclass ? '' : 'alternate'; 1520 $posts_columns = get_column_headers('edit-pages'); 1521 $hidden = get_hidden_columns('edit-pages'); 1522 $title = _draft_or_post_title(); 1523 ?> 1524 <tr id="page-<?php echo $id; ?>" class="<?php echo $rowclass; ?> iedit"> 1525 <?php 1526 1527 foreach ($posts_columns as $column_name=>$column_display_name) { 1528 $class = "class=\"$column_name column-$column_name\""; 1529 1530 $style = ''; 1531 if ( in_array($column_name, $hidden) ) 1532 $style = ' style="display:none;"'; 1533 1534 $attributes = "$class$style"; 1535 1536 switch ($column_name) { 1537 1538 case 'cb': 1539 ?> 1540 <th scope="row" class="check-column"><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /></th> 1541 <?php 1542 break; 1543 case 'date': 1544 if ( '0000-00-00 00:00:00' == $page->post_date && 'date' == $column_name ) { 1545 $t_time = $h_time = __('Unpublished'); 1546 } else { 1547 $t_time = get_the_time(__('Y/m/d g:i:s A')); 1548 $m_time = $page->post_date; 1549 $time = get_post_time('G', true); 1550 1551 if ( ( abs(time() - $time) ) < 86400 ) { 1552 if ( ( 'future' == $page->post_status) ) 1553 $h_time = sprintf( __('%s from now'), human_time_diff( $time ) ); 1554 else 1555 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); 1556 } else { 1557 $h_time = mysql2date(__('Y/m/d'), $m_time); 1558 } 1559 } 1560 echo '<td ' . $attributes . '>'; 1561 echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $page, $column_name, '') . '</abbr>'; 1562 echo '<br />'; 1563 if ( 'publish' == $page->post_status || 'future' == $page->post_status ) 1564 _e('Published'); 1565 else 1566 _e('Last Modified'); 1567 echo '</td>'; 1568 break; 1569 case 'title': 1570 $attributes = 'class="post-title page-title column-title"' . $style; 1571 $edit_link = get_edit_post_link( $page->ID ); 1572 ?> 1573 <td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_post', $page->ID ) ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states($page); ?></strong> 1574 <?php 1575 $actions = array(); 1576 if ( current_user_can('edit_page', $page->ID) ) { 1577 $actions['edit'] = '<a href="' . $edit_link . '" title="' . attribute_escape(__('Edit this page')) . '">' . __('Edit') . '</a>'; 1578 $actions['inline'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>'; 1579 $actions['delete'] = "<a class='submitdelete' title='" . attribute_escape(__('Delete this page')) . "' href='" . wp_nonce_url("page.php?action=delete&post=$page->ID", 'delete-page_' . $page->ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $page->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this page '%s'\n 'Cancel' to stop, 'OK' to delete."), $page->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>"; 1580 } 1581 if ( in_array($post->post_status, array('pending', 'draft')) ) { 1582 if ( current_user_can('edit_page', $page->ID) ) 1583 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . attribute_escape(sprintf(__('Preview "%s"'), $title)) . '" rel="permalink">' . __('Preview') . '</a>'; 1584 } else { 1585 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . attribute_escape(sprintf(__('View "%s"'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 1586 } 1587 $action_count = count($actions); 1588 1589 $i = 0; 1590 echo '<div class="row-actions">'; 1591 foreach ( $actions as $action => $link ) { 1592 ++$i; 1593 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; 1594 echo "<span class='$action'>$link$sep</span>"; 1595 } 1596 echo '</div>'; 1597 1598 get_inline_data($post); 1599 echo '</td>'; 1600 break; 1601 1602 case 'comments': 1603 ?> 1604 <td <?php echo $attributes ?>><div class="post-com-count-wrapper"> 1605 <?php 1606 $left = get_pending_comments_num( $page->ID ); 1607 $pending_phrase = sprintf( __('%s pending'), number_format( $left ) ); 1608 if ( $left ) 1609 echo '<strong>'; 1610 comments_number("<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>'); 1611 if ( $left ) 1612 echo '</strong>'; 1613 ?> 1614 </div></td> 1615 <?php 1616 break; 1617 1618 case 'author': 1619 ?> 1620 <td <?php echo $attributes ?>><a href="edit-pages.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td> 1621 <?php 1622 break; 1623 1624 default: 1625 ?> 1626 <td <?php echo $attributes ?>><?php do_action('manage_pages_custom_column', $column_name, $id); ?></td> 1627 <?php 1628 break; 1629 } 1630 } 1631 ?> 1632 1633 </tr> 1634 1635 <?php 1636 } 1637 1638 /* 1639 * displays pages in hierarchical order with paging support 1640 */ 1641 /** 1642 * {@internal Missing Short Description}} 1643 * 1644 * @since unknown 1645 * 1646 * @param unknown_type $pages 1647 * @param unknown_type $pagenum 1648 * @param unknown_type $per_page 1649 * @return unknown 1650 */ 1651 function page_rows($pages, $pagenum = 1, $per_page = 20) { 1652 global $wpdb; 1653 1654 $level = 0; 1655 1656 if ( ! $pages ) { 1657 $pages = get_pages( array('sort_column' => 'menu_order') ); 1658 1659 if ( ! $pages ) 1660 return false; 1661 } 1662 1663 /* 1664 * arrange pages into two parts: top level pages and children_pages 1665 * children_pages is two dimensional array, eg. 1666 * children_pages[10][] contains all sub-pages whose parent is 10. 1667 * It only takes O(N) to arrange this and it takes O(1) for subsequent lookup operations 1668 * If searching, ignore hierarchy and treat everything as top level 1669 */ 1670 if ( empty($_GET['s']) ) { 1671 1672 $top_level_pages = array(); 1673 $children_pages = array(); 1674 1675 foreach ( $pages as $page ) { 1676 1677 // catch and repair bad pages 1678 if ( $page->post_parent == $page->ID ) { 1679 $page->post_parent = 0; 1680 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = '0' WHERE ID = %d", $page->ID) ); 1681 clean_page_cache( $page->ID ); 1682 } 1683 1684 if ( 0 == $page->post_parent ) 1685 $top_level_pages[] = $page; 1686 else 1687 $children_pages[ $page->post_parent ][] = $page; 1688 } 1689 1690 $pages = &$top_level_pages; 1691 } 1692 1693 $count = 0; 1694 $start = ($pagenum - 1) * $per_page; 1695 $end = $start + $per_page; 1696 1697 foreach ( $pages as $page ) { 1698 if ( $count >= $end ) 1699 break; 1700 1701 if ( $count >= $start ) 1702 echo "\t" . display_page_row( $page, $level ); 1703 1704 $count++; 1705 1706 if ( isset($children_pages) ) 1707 _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page ); 1708 } 1709 1710 // if it is the last pagenum and there are orphaned pages, display them with paging as well 1711 if ( isset($children_pages) && $count < $end ){ 1712 foreach( $children_pages as $orphans ){ 1713 foreach ( $orphans as $op ) { 1714 if ( $count >= $end ) 1715 break; 1716 if ( $count >= $start ) 1717 echo "\t" . display_page_row( $op, 0 ); 1718 $count++; 1719 } 1720 } 1721 } 1722 } 1723 1724 /* 1725 * Given a top level page ID, display the nested hierarchy of sub-pages 1726 * together with paging support 1727 */ 1728 /** 1729 * {@internal Missing Short Description}} 1730 * 1731 * @since unknown 1732 * 1733 * @param unknown_type $children_pages 1734 * @param unknown_type $count 1735 * @param unknown_type $parent 1736 * @param unknown_type $level 1737 * @param unknown_type $pagenum 1738 * @param unknown_type $per_page 1739 */ 1740 function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) { 1741 1742 if ( ! isset( $children_pages[$parent] ) ) 1743 return; 1744 1745 $start = ($pagenum - 1) * $per_page; 1746 $end = $start + $per_page; 1747 1748 foreach ( $children_pages[$parent] as $page ) { 1749 1750 if ( $count >= $end ) 1751 break; 1752 1753 // If the page starts in a subtree, print the parents. 1754 if ( $count == $start && $page->post_parent > 0 ) { 1755 $my_parents = array(); 1756 $my_parent = $page->post_parent; 1757 while ( $my_parent) { 1758 $my_parent = get_post($my_parent); 1759 $my_parents[] = $my_parent; 1760 if ( !$my_parent->post_parent ) 1761 break; 1762 $my_parent = $my_parent->post_parent; 1763 } 1764 $num_parents = count($my_parents); 1765 while( $my_parent = array_pop($my_parents) ) { 1766 echo "\t" . display_page_row( $my_parent, $level - $num_parents ); 1767 $num_parents--; 1768 } 1769 } 1770 1771 if ( $count >= $start ) 1772 echo "\t" . display_page_row( $page, $level ); 1773 1774 $count++; 1775 1776 _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page ); 1777 } 1778 1779 unset( $children_pages[$parent] ); //required in order to keep track of orphans 1780 } 1781 1782 /** 1783 * {@internal Missing Short Description}} 1784 * 1785 * @since unknown 1786 * 1787 * @param unknown_type $user_object 1788 * @param unknown_type $style 1789 * @param unknown_type $role 1790 * @return unknown 1791 */ 1792 function user_row( $user_object, $style = '', $role = '' ) { 1793 global $wp_roles; 1794 1795 $current_user = wp_get_current_user(); 1796 1797 if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) ) 1798 $user_object = new WP_User( (int) $user_object ); 1799 $email = $user_object->user_email; 1800 $url = $user_object->user_url; 1801 $short_url = str_replace( 'http://', '', $url ); 1802 $short_url = str_replace( 'www.', '', $short_url ); 1803 if ('/' == substr( $short_url, -1 )) 1804 $short_url = substr( $short_url, 0, -1 ); 1805 if ( strlen( $short_url ) > 35 ) 1806 $short_url = substr( $short_url, 0, 32 ).'...'; 1807 $numposts = get_usernumposts( $user_object->ID ); 1808 if ( current_user_can( 'edit_user', $user_object->ID ) ) { 1809 if ($current_user->ID == $user_object->ID) { 1810 $edit_link = 'profile.php'; 1811 } else { 1812 $edit_link = clean_url( add_query_arg( 'wp_http_referer', urlencode( clean_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" ) ); 1813 } 1814 $edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />"; 1815 $actions = array(); 1816 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; 1817 if ( $current_user->ID != $user_object->ID ) 1818 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=delete&user=$user_object->ID", 'bulk-users') . "'>" . __('Delete') . "</a>"; 1819 $action_count = count($actions); 1820 $i = 0; 1821 $edit .= '<div class="row-actions">'; 1822 foreach ( $actions as $action => $link ) { 1823 ++$i; 1824 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; 1825 $edit .= "<span class='$action'>$link$sep</span>"; 1826 } 1827 $edit .= '</div>'; 1828 } else { 1829 $edit = '<strong>' . $user_object->user_login . '</strong>'; 1830 } 1831 $role_name = isset($wp_roles->role_names[$role]) ? translate_with_context($wp_roles->role_names[$role]) : __('None'); 1832 $r = "<tr id='user-$user_object->ID'$style>"; 1833 $columns = get_column_headers('users'); 1834 $hidden = get_hidden_columns('users'); 1835 $avatar = get_avatar( $user_object->user_email, 32 ); 1836 foreach ( $columns as $column_name => $column_display_name ) { 1837 $class = "class=\"$column_name column-$column_name\""; 1838 1839 $style = ''; 1840 if ( in_array($column_name, $hidden) ) 1841 $style = ' style="display:none;"'; 1842 1843 $attributes = "$class$style"; 1844 1845 switch ($column_name) { 1846 case 'cb': 1847 $r .= "<th scope='row' class='check-column'><input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' /></th>"; 1848 break; 1849 case 'username': 1850 $r .= "<td $attributes>$avatar $edit</td>"; 1851 break; 1852 case 'name': 1853 $r .= "<td $attributes>$user_object->first_name $user_object->last_name</td>"; 1854 break; 1855 case 'email': 1856 $r .= "<td $attributes><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td>"; 1857 break; 1858 case 'role': 1859 $r .= "<td $attributes>$role_name</td>"; 1860 break; 1861 case 'posts': 1862 $attributes = 'class="posts column-posts num"' . $style; 1863 $r .= "<td $attributes>"; 1864 if ( $numposts > 0 ) { 1865 $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>"; 1866 $r .= $numposts; 1867 $r .= '</a>'; 1868 } else { 1869 $r .= 0; 1870 } 1871 $r .= "</td>"; 1872 } 1873 } 1874 $r .= '</tr>'; 1875 1876 return $r; 1877 } 1878 1879 /** 1880 * {@internal Missing Short Description}} 1881 * 1882 * @since unknown 1883 * 1884 * @param unknown_type $status 1885 * @param unknown_type $s 1886 * @param unknown_type $start 1887 * @param unknown_type $num 1888 * @param unknown_type $post 1889 * @param unknown_type $type 1890 * @return unknown 1891 */ 1892 function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0, $type = '' ) { 1893 global $wpdb; 1894 1895 $start = abs( (int) $start ); 1896 $num = (int) $num; 1897 $post = (int) $post; 1898 1899 if ( 'moderated' == $status ) 1900 $approved = "comment_approved = '0'"; 1901 elseif ( 'approved' == $status ) 1902 $approved = "comment_approved = '1'"; 1903 elseif ( 'spam' == $status ) 1904 $approved = "comment_approved = 'spam'"; 1905 else 1906 $approved = "( comment_approved = '0' OR comment_approved = '1' )"; 1907 1908 if ( $post ) { 1909 $post = " AND comment_post_ID = '$post'"; 1910 $orderby = "ORDER BY comment_date_gmt ASC LIMIT $start, $num"; 1911 } else { 1912 $post = ''; 1913 $orderby = "ORDER BY comment_date_gmt DESC LIMIT $start, $num"; 1914 } 1915 1916 if ( 'comment' == $type ) 1917 $typesql = "AND comment_type = ''"; 1918 elseif ( 'pingback' == $type ) 1919 $typesql = "AND comment_type = 'pingback'"; 1920 elseif ( 'trackback' == $type ) 1921 $typesql = "AND comment_type = 'trackback'"; 1922 elseif ( 'pings' == $type ) 1923 $typesql = "AND ( comment_type = 'pingback' OR comment_type = 'trackback' )"; 1924 else 1925 $typesql = ''; 1926 1927 if ( $s ) { 1928 $s = $wpdb->escape($s); 1929 $comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE 1930 (comment_author LIKE '%$s%' OR 1931 comment_author_email LIKE '%$s%' OR 1932 comment_author_url LIKE ('%$s%') OR 1933 comment_author_IP LIKE ('%$s%') OR 1934 comment_content LIKE ('%$s%') ) AND 1935 $approved 1936 $typesql 1937 $orderby"); 1938 } else { 1939 $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE $approved $post $typesql $orderby" ); 1940 } 1941 1942 update_comment_cache($comments); 1943 1944 $total = $wpdb->get_var( "SELECT FOUND_ROWS()" ); 1945 1946 return array($comments, $total); 1947 } 1948 1949 /** 1950 * {@internal Missing Short Description}} 1951 * 1952 * @since unknown 1953 * 1954 * @param unknown_type $comment_id 1955 * @param unknown_type $mode 1956 * @param unknown_type $comment_status 1957 * @param unknown_type $checkbox 1958 */ 1959 function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) { 1960 global $comment, $post, $_comment_pending_count; 1961 $comment = get_comment( $comment_id ); 1962 $post = get_post($comment->comment_post_ID); 1963 $the_comment_status = wp_get_comment_status($comment->comment_ID); 1964 1965 $author_url = get_comment_author_url(); 1966 if ( 'http://' == $author_url ) 1967 $author_url = ''; 1968 $author_url_display = $author_url; 1969 $author_url_display = str_replace('http://www.', '', $author_url_display); 1970 $author_url_display = str_replace('http://', '', $author_url_display); 1971 if ( strlen($author_url_display) > 50 ) 1972 $author_url_display = substr($author_url_display, 0, 49) . '...'; 1973 1974 $ptime = date('G', strtotime( $comment->comment_date ) ); 1975 if ( ( abs(time() - $ptime) ) < 86400 ) 1976 $ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) ); 1977 else 1978 $ptime = mysql2date(__('Y/m/d \a\t g:i A'), $comment->comment_date ); 1979 1980 $delete_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) ); 1981 $approve_url = clean_url( wp_nonce_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) ); 1982 $unapprove_url = clean_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) ); 1983 $spam_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) ); 1984 1985 echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>"; 1986 $columns = get_column_headers('edit-comments'); 1987 $hidden = get_hidden_columns('edit-comments'); 1988 foreach ( $columns as $column_name => $column_display_name ) { 1989 $class = "class=\"$column_name column-$column_name\""; 1990 1991 $style = ''; 1992 if ( in_array($column_name, $hidden) ) 1993 $style = ' style="display:none;"'; 1994 1995 $attributes = "$class$style"; 1996 1997 switch ($column_name) { 1998 case 'cb': 1999 if ( !$checkbox ) break; 2000 echo '<th scope="row" class="check-column">'; 2001 if ( current_user_can('edit_post', $post->ID) ) echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />"; 2002 echo '</th>'; 2003 break; 2004 case 'comment': 2005 echo "<td $attributes>"; 2006 echo '<div id="submitted-on">'; 2007 printf(__('Submitted on <a href="%1$s">%2$s at %3$s</a>'), get_comment_link($comment->comment_ID), get_comment_date(__('Y/m/d')), get_comment_date(__('g:ia'))); 2008 echo '</div>'; 2009 comment_text(); ?> 2010 <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden"> 2011 <textarea class="comment" rows="3" cols="10"><?php echo $comment->comment_content; ?></textarea> 2012 <div class="author-email"><?php echo attribute_escape( $comment->comment_author_email ); ?></div> 2013 <div class="author"><?php echo attribute_escape( $comment->comment_author ); ?></div> 2014 <div class="author-url"><?php echo attribute_escape( $comment->comment_author_url ); ?></div> 2015 <div class="comment_status"><?php echo $comment->comment_approved; ?></div> 2016 </div> 2017 <?php 2018 $actions = array(); 2019 2020 if ( current_user_can('edit_post', $post->ID) ) { 2021 $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; 2022 $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; 2023 if ( $comment_status ) { // not looking at all comments 2024 if ( 'approved' == $the_comment_status ) { 2025 $actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved vim-u vim-destructive' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; 2026 unset($actions['approve']); 2027 } else { 2028 $actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved vim-a vim-destructive' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; 2029 unset($actions['unapprove']); 2030 } 2031 } 2032 if ( 'spam' != $the_comment_status ) 2033 $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . __( 'Mark this comment as spam' ) . "'>" . _c( 'Spam|verb' ) . '</a>'; 2034 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>'; 2035 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>'; 2036 $actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\');return false;" class="vim-q" title="'.__('Quick Edit').'" href="#">' . __('Quick Edit') . '</a>'; 2037 if ( 'spam' != $the_comment_status ) 2038 $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\');return false;" class="vim-r" title="'.__('Reply to this comment').'" href="#">' . __('Reply') . '</a>'; 2039 2040 $actions = apply_filters( 'comment_row_actions', $actions, $comment ); 2041 2042 $i = 0; 2043 echo '<div class="row-actions">'; 2044 foreach ( $actions as $action => $link ) { 2045 ++$i; 2046 ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; 2047 2048 // Reply and quickedit need a hide-if-no-js span when not added with ajax 2049 if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax ) 2050 $action .= ' hide-if-no-js'; 2051 2052 echo "<span class='$action'>$sep$link</span>"; 2053 } 2054 echo '</div>'; 2055 } 2056 2057 echo '</td>'; 2058 break; 2059 case 'author': 2060 echo "<td $attributes><strong>"; comment_author(); echo '</strong><br />'; 2061 if ( !empty($author_url) ) 2062 echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />"; 2063 if ( current_user_can( 'edit_post', $post->ID ) ) { 2064 if ( !empty($comment->comment_author_email) ) { 2065 comment_author_email_link(); 2066 echo '<br />'; 2067 } 2068 echo '<a href="edit-comments.php?s='; 2069 comment_author_IP(); 2070 echo '&mode=detail'; 2071 if ( 'spam' == $comment_status ) 2072 echo '&comment_status=spam'; 2073 echo '">'; 2074 comment_author_IP(); 2075 echo '</a>'; 2076 } //current_user_can 2077 echo '</td>'; 2078 break; 2079 case 'date': 2080 echo "<td $attributes>" . get_comment_date(__('Y/m/d \a\t g:ia')) . '</td>'; 2081 break; 2082 case 'response': 2083 if ( 'single' !== $mode ) { 2084 if ( isset( $_comment_pending_count[$post->ID] ) ) { 2085 $pending_comments = absint( $_comment_pending_count[$post->ID] ); 2086 } else { 2087 $_comment_pending_count_temp = (array) get_pending_comments_num( array( $post->ID ) ); 2088 $pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID]; 2089 } 2090 if ( current_user_can( 'edit_post', $post->ID ) ) { 2091 $post_link = "<a href='" . get_edit_post_link($post->ID) . "'>"; 2092 $post_link .= get_the_title($post->ID) . '</a>'; 2093 } else { 2094 $post_link = get_the_title($post->ID); 2095 } 2096 echo "<td $attributes>\n"; 2097 echo $post_link; 2098 2099 echo '<div class="response-links"><span class="post-com-count-wrapper">'; 2100 $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) ); 2101 if ( $pending_comments ) 2102 echo '<strong>'; 2103 comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>'); 2104 if ( $pending_comments ) 2105 echo '</strong>'; 2106 echo '</span> '; 2107 echo "<a href='" . get_permalink( $post->ID ) . "'>#</a>"; 2108 echo '</div></td>'; 2109 } 2110 } 2111 } 2112 echo "</tr>\n"; 2113 } 2114 2115 /** 2116 * {@internal Missing Short Description}} 2117 * 2118 * @since unknown 2119 * 2120 * @param unknown_type $position 2121 * @param unknown_type $checkbox 2122 * @param unknown_type $mode 2123 */ 2124 function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) { 2125 global $current_user; 2126 2127 // allow plugin to replace the popup content 2128 $content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) ); 2129 2130 if ( ! empty($content) ) { 2131 echo $content; 2132 return; 2133 } 2134 2135 $columns = get_column_headers('edit-comments'); 2136 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns('edit-comments') ) ); 2137 $col_count = count($columns) - count($hidden); 2138 2139 ?> 2140 <form method="get" action=""> 2141 <?php if ( $table_row ) : ?> 2142 <table style="display:none;"><tbody id="com-reply"><tr id="replyrow"><td colspan="<?php echo $col_count; ?>"> 2143 <?php else : ?> 2144 <div id="com-reply" style="display:none;"><div id="replyrow"> 2145 <?php endif; ?> 2146 <div id="replyhead" style="display:none;"><?php _e('Reply to Comment'); ?></div> 2147 2148 <div id="edithead" style="display:none;"> 2149 <div class="inside"> 2150 <label for="author"><?php _e('Name') ?></label> 2151 <input type="text" name="newcomment_author" size="50" value="" tabindex="101" id="author" /> 2152 </div> 2153 2154 <div class="inside"> 2155 <label for="author-email"><?php _e('E-mail') ?></label> 2156 <input type="text" name="newcomment_author_email" size="50" value="" tabindex="102" id="author-email" /> 2157 </div> 2158 2159 <div class="inside"> 2160 <label for="author-url"><?php _e('URL') ?></label> 2161 <input type="text" id="author-url" name="newcomment_author_url" size="103" value="" tabindex="103" /> 2162 </div> 2163 <div style="clear:both;"></div> 2164 </div> 2165 2166 <div id="replycontainer"><textarea rows="8" cols="40" name="replycontent" tabindex="104" id="replycontent"></textarea></div> 2167 2168 <p id="replysubmit" class="submit"> 2169 <a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106"><?php _e('Cancel'); ?></a> 2170 <a href="#comments-form" class="save button-primary alignright" tabindex="104"> 2171 <span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span> 2172 <span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a> 2173 <img class="waiting" style="display:none;" src="images/loading.gif" alt="" /> 2174 <span class="error" style="display:none;"></span> 2175 <br class="clear" /> 2176 </p> 2177 2178 <input type="hidden" name="user_ID" id="user_ID" value="<?php echo $current_user->ID; ?>" /> 2179 <input type="hidden" name="action" id="action" value="" /> 2180 <input type="hidden" name="comment_ID" id="comment_ID" value="" /> 2181 <input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" /> 2182 <input type="hidden" name="status" id="status" value="" /> 2183 <input type="hidden" name="position" id="position" value="<?php echo $position; ?>" /> 2184 <input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" /> 2185 <input type="hidden" name="mode" id="mode" value="<?php echo $mode; ?>" /> 2186 <?php wp_nonce_field( 'replyto-comment', '_ajax_nonce', false ); ?> 2187 <?php wp_comment_form_unfiltered_html_nonce(); ?> 2188 <?php if ( $table_row ) : ?> 2189 </td></tr></tbody></table> 2190 <?php else : ?> 2191 </div></div> 2192 <?php endif; ?> 2193 </form> 2194 <?php 2195 } 2196 2197 /** 2198 * {@internal Missing Short Description}} 2199 * 2200 * @since unknown 2201 * 2202 * @param unknown_type $currentcat 2203 * @param unknown_type $currentparent 2204 * @param unknown_type $parent 2205 * @param unknown_type $level 2206 * @param unknown_type $categories 2207 * @return unknown 2208 */ 2209 function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) { 2210 if (!$categories ) 2211 $categories = get_categories( array('hide_empty' => 0) ); 2212 2213 if ( $categories ) { 2214 foreach ( $categories as $category ) { 2215 if ( $currentcat != $category->term_id && $parent == $category->parent) { 2216 $pad = str_repeat( '– ', $level ); 2217 $category->name = wp_specialchars( $category->name ); 2218 echo "\n\t<option value='$category->term_id'"; 2219 if ( $currentparent == $category->term_id ) 2220 echo " selected='selected'"; 2221 echo ">$pad$category->name</option>"; 2222 wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories ); 2223 } 2224 } 2225 } else { 2226 return false; 2227 } 2228 } 2229 2230 /** 2231 * {@internal Missing Short Description}} 2232 * 2233 * @since unknown 2234 * 2235 * @param unknown_type $meta 2236 */ 2237 function list_meta( $meta ) { 2238 // Exit if no meta 2239 if ( ! $meta ) { 2240 echo ' 2241 <table id="list-table" style="display: none;"> 2242 <thead> 2243 <tr> 2244 <th class="left">' . __( 'Name' ) . '</th> 2245 <th>' . __( 'Value' ) . '</th> 2246 </tr> 2247 </thead> 2248 <tbody id="the-list" class="list:meta"> 2249 <tr><td></td></tr> 2250 </tbody> 2251 </table>'; //TBODY needed for list-manipulation JS 2252 return; 2253 } 2254 $count = 0; 2255 ?> 2256 <table id="list-table"> 2257 <thead> 2258 <tr> 2259 <th class="left"><?php _e( 'Name' ) ?></th> 2260 <th><?php _e( 'Value' ) ?></th> 2261 </tr> 2262 </thead> 2263 <tbody id='the-list' class='list:meta'> 2264 <?php 2265 foreach ( $meta as $entry ) 2266 echo _list_meta_row( $entry, $count ); 2267 ?> 2268 </tbody> 2269 </table> 2270 <?php 2271 } 2272 2273 /** 2274 * {@internal Missing Short Description}} 2275 * 2276 * @since unknown 2277 * 2278 * @param unknown_type $entry 2279 * @param unknown_type $count 2280 * @return unknown 2281 */ 2282 function _list_meta_row( $entry, &$count ) { 2283 static $update_nonce = false; 2284 if ( !$update_nonce ) 2285 $update_nonce = wp_create_nonce( 'add-meta' ); 2286 2287 $r = ''; 2288 ++ $count; 2289 if ( $count % 2 ) 2290 $style = 'alternate'; 2291 else 2292 $style = ''; 2293 if ('_' == $entry['meta_key'] { 0 } ) 2294 $style .= ' hidden'; 2295 2296 if ( is_serialized( $entry['meta_value'] ) ) { 2297 if ( is_serialized_string( $entry['meta_value'] ) ) { 2298 // this is a serialized string, so we should display it 2299 $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] ); 2300 } else { 2301 // this is a serialized array/object so we should NOT display it 2302 --$count; 2303 return; 2304 } 2305 } 2306 2307 $entry['meta_key'] = attribute_escape($entry['meta_key']); 2308 $entry['meta_value'] = htmlspecialchars($entry['meta_value']); // using a <textarea /> 2309 $entry['meta_id'] = (int) $entry['meta_id']; 2310 2311 $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] ); 2312 2313 $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>"; 2314 $r .= "\n\t\t<td class='left'><label class='hidden' for='meta[{$entry['meta_id']}][key]'>" . __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' />"; 2315 2316 $r .= "\n\t\t<div class='submit'><input name='deletemeta[{$entry['meta_id']}]' type='submit' "; 2317 $r .= "class='delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta' tabindex='6' value='".attribute_escape(__( 'Delete' ))."' />"; 2318 $r .= "\n\t\t<input name='updatemeta' type='submit' tabindex='6' value='".attribute_escape(__( 'Update' ))."' class='add:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$update_nonce updatemeta' /></div>"; 2319 $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false ); 2320 $r .= "</td>"; 2321 2322 $r .= "\n\t\t<td><label class='hidden' for='meta[{$entry['meta_id']}][value]'>" . __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>"; 2323 return $r; 2324 } 2325 2326 /** 2327 * {@internal Missing Short Description}} 2328 * 2329 * @since unknown 2330 */ 2331 function meta_form() { 2332 global $wpdb; 2333 $limit = (int) apply_filters( 'postmeta_form_limit', 30 ); 2334 $keys = $wpdb->get_col( " 2335 SELECT meta_key 2336 FROM $wpdb->postmeta 2337 WHERE meta_key NOT LIKE '\_%' 2338 GROUP BY meta_key 2339 ORDER BY meta_id DESC 2340 LIMIT $limit" ); 2341 if ( $keys ) 2342 natcasesort($keys); 2343 ?> 2344 <p><strong><?php _e( 'Add new custom field:' ) ?></strong></p> 2345 <table id="newmeta"> 2346 <thead> 2347 <tr> 2348 <th class="left"><label for="metakeyselect"><?php _e( 'Name' ) ?></label></th> 2349 <th><label for="metavalue"><?php _e( 'Value' ) ?></label></th> 2350 </tr> 2351 </thead> 2352 2353 <tbody> 2354 <tr> 2355 <td id="newmetaleft" class="left"> 2356 <?php if ( $keys ) { ?> 2357 <select id="metakeyselect" name="metakeyselect" tabindex="7"> 2358 <option value="#NONE#"><?php _e( '- Select -' ); ?></option> 2359 <?php 2360 2361 foreach ( $keys as $key ) { 2362 $key = attribute_escape( $key ); 2363 echo "\n<option value='$key'>$key</option>"; 2364 } 2365 ?> 2366 </select> 2367 <input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" /> 2368 <a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;"> 2369 <span id="enternew"><?php _e('Enter new'); ?></span> 2370 <span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a> 2371 <?php } else { ?> 2372 <input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" /> 2373 <?php } ?> 2374 </td> 2375 <td><textarea id="metavalue" name="metavalue" rows="2" cols="25" tabindex="8"></textarea></td> 2376 </tr> 2377 2378 <tr><td colspan="2" class="submit"> 2379 <input type="submit" id="addmetasub" name="addmeta" class="add:the-list:newmeta" tabindex="9" value="<?php _e( 'Add Custom Field' ) ?>" /> 2380 <?php wp_nonce_field( 'add-meta', '_ajax_nonce', false ); ?> 2381 </td></tr> 2382 </tbody> 2383 </table> 2384 <?php 2385 2386 } 2387 2388 /** 2389 * {@internal Missing Short Description}} 2390 * 2391 * @since unknown 2392 * 2393 * @param unknown_type $edit 2394 * @param unknown_type $for_post 2395 * @param unknown_type $tab_index 2396 * @param unknown_type $multi 2397 */ 2398 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { 2399 global $wp_locale, $post, $comment; 2400 2401 if ( $for_post ) 2402 $edit = ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ) ? false : true; 2403 2404 $tab_index_attribute = ''; 2405 if ( (int) $tab_index > 0 ) 2406 $tab_index_attribute = " tabindex=\"$tab_index\""; 2407 2408 // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />'; 2409 2410 $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 ); 2411 $post_date = ($for_post) ? $post->post_date : $comment->comment_date; 2412 $jj = ($edit) ? mysql2date( 'd', $post_date ) : gmdate( 'd', $time_adj ); 2413 $mm = ($edit) ? mysql2date( 'm', $post_date ) : gmdate( 'm', $time_adj ); 2414 $aa = ($edit) ? mysql2date( 'Y', $post_date ) : gmdate( 'Y', $time_adj ); 2415 $hh = ($edit) ? mysql2date( 'H', $post_date ) : gmdate( 'H', $time_adj ); 2416 $mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj ); 2417 $ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj ); 2418 2419 $cur_jj = gmdate( 'd', $time_adj ); 2420 $cur_mm = gmdate( 'm', $time_adj ); 2421 $cur_aa = gmdate( 'Y', $time_adj ); 2422 $cur_hh = gmdate( 'H', $time_adj ); 2423 $cur_mn = gmdate( 'i', $time_adj ); 2424 2425 $month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n"; 2426 for ( $i = 1; $i < 13; $i = $i +1 ) { 2427 $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"'; 2428 if ( $i == $mm ) 2429 $month .= ' selected="selected"'; 2430 $month .= '>' . $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) . "</option>\n"; 2431 } 2432 $month .= '</select>'; 2433 2434 $day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />'; 2435 $year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="5"' . $tab_index_attribute . ' autocomplete="off" />'; 2436 $hour = '<input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />'; 2437 $minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />'; 2438 printf(_c('%1$s%2$s, %3$s @ %4$s : %5$s|1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input'), $month, $day, $year, $hour, $minute); 2439 2440 echo '<input type="hidden" id="ss" name="ss" value="' . $ss . '" />'; 2441 2442 if ( $multi ) return; 2443 2444 echo "\n\n"; 2445 foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) { 2446 echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n"; 2447 $cur_timeunit = 'cur_' . $timeunit; 2448 echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n"; 2449 } 2450 ?> 2451 2452 <input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" /> 2453 2454 <p> 2455 <a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e('OK'); ?></a> 2456 <a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js"><?php _e('Cancel'); ?></a> 2457 </p> 2458 <?php 2459 } 2460 2461 /** 2462 * {@internal Missing Short Description}} 2463 * 2464 * @since unknown 2465 * 2466 * @param unknown_type $default 2467 */ 2468 function page_template_dropdown( $default = '' ) { 2469 $templates = get_page_templates(); 2470 ksort( $templates ); 2471 foreach (array_keys( $templates ) as $template ) 2472 : if ( $default == $templates[$template] ) 2473 $selected = " selected='selected'"; 2474 else 2475 $selected = ''; 2476 echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>"; 2477 endforeach; 2478 } 2479 2480 /** 2481 * {@internal Missing Short Description}} 2482 * 2483 * @since unknown 2484 * 2485 * @param unknown_type $default 2486 * @param unknown_type $parent 2487 * @param unknown_type $level 2488 * @return unknown 2489 */ 2490 function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) { 2491 global $wpdb, $post_ID; 2492 $items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent) ); 2493 2494 if ( $items ) { 2495 foreach ( $items as $item ) { 2496 // A page cannot be its own parent. 2497 if (!empty ( $post_ID ) ) { 2498 if ( $item->ID == $post_ID ) { 2499 continue; 2500 } 2501 } 2502 $pad = str_repeat( ' ', $level * 3 ); 2503 if ( $item->ID == $default) 2504 $current = ' selected="selected"'; 2505 else 2506 $current = ''; 2507 2508 echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . wp_specialchars($item->post_title) . "</option>"; 2509 parent_dropdown( $default, $item->ID, $level +1 ); 2510 } 2511 } else { 2512 return false; 2513 } 2514 } 2515 2516 /** 2517 * {@internal Missing Short Description}} 2518 * 2519 * @since unknown 2520 */ 2521 function browse_happy() { 2522 $getit = __( 'WordPress recommends a better browser' ); 2523 echo ' 2524 <div id="bh"><a href="http://browsehappy.com/" title="'.$getit.'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></div> 2525 '; 2526 } 2527 2528 /** 2529 * {@internal Missing Short Description}} 2530 * 2531 * @since unknown 2532 * 2533 * @param unknown_type $id 2534 * @return unknown 2535 */ 2536 function the_attachment_links( $id = false ) { 2537 $id = (int) $id; 2538 $post = & get_post( $id ); 2539 2540 if ( $post->post_type != 'attachment' ) 2541 return false; 2542 2543 $icon = get_attachment_icon( $post->ID ); 2544 $attachment_data = wp_get_attachment_metadata( $id ); 2545 $thumb = isset( $attachment_data['thumb'] ); 2546 ?> 2547 <form id="the-attachment-links"> 2548 <table> 2549 <col /> 2550 <col class="widefat" /> 2551 <tr> 2552 <th scope="row"><?php _e( 'URL' ) ?></th> 2553 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo wp_get_attachment_url(); ?></textarea></td> 2554 </tr> 2555 <?php if ( $icon ) : ?> 2556 <tr> 2557 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th> 2558 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>"><?php echo $icon ?></a></textarea></td> 2559 </tr> 2560 <tr> 2561 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to page' ) : _e( 'Image linked to page' ); ?></th> 2562 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID; ?>"><?php echo $icon ?></a></textarea></td> 2563 </tr> 2564 <?php else : ?> 2565 <tr> 2566 <th scope="row"><?php _e( 'Link to file' ) ?></th> 2567 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>" class="attachmentlink"><?php echo basename( wp_get_attachment_url() ); ?></a></textarea></td> 2568 </tr> 2569 <tr> 2570 <th scope="row"><?php _e( 'Link to page' ) ?></th> 2571 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID ?>"><?php the_title(); ?></a></textarea></td> 2572 </tr> 2573 <?php endif; ?> 2574 </table> 2575 </form> 2576 <?php 2577 } 2578 2579 /** 2580 * {@internal Missing Short Description}} 2581 * 2582 * @since unknown 2583 * 2584 * @param unknown_type $default 2585 */ 2586 function wp_dropdown_roles( $default = false ) { 2587 global $wp_roles; 2588 $p = ''; 2589 $r = ''; 2590 foreach( $wp_roles->role_names as $role => $name ) { 2591 $name = translate_with_context($name); 2592 if ( $default == $role ) // Make default first in list 2593 $p = "\n\t<option selected='selected' value='$role'>$name</option>"; 2594 else 2595 $r .= "\n\t<option value='$role'>$name</option>"; 2596 } 2597 echo $p . $r; 2598 } 2599 2600 /** 2601 * {@internal Missing Short Description}} 2602 * 2603 * @since unknown 2604 * 2605 * @param unknown_type $size 2606 * @return unknown 2607 */ 2608 function wp_convert_hr_to_bytes( $size ) { 2609 $size = strtolower($size); 2610 $bytes = (int) $size; 2611 if ( strpos($size, 'k') !== false ) 2612 $bytes = intval($size) * 1024; 2613 elseif ( strpos($size, 'm') !== false ) 2614 $bytes = intval($size) * 1024 * 1024; 2615 elseif ( strpos($size, 'g') !== false ) 2616 $bytes = intval($size) * 1024 * 1024 * 1024; 2617 return $bytes; 2618 } 2619 2620 /** 2621 * {@internal Missing Short Description}} 2622 * 2623 * @since unknown 2624 * 2625 * @param unknown_type $bytes 2626 * @return unknown 2627 */ 2628 function wp_convert_bytes_to_hr( $bytes ) { 2629 $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' ); 2630 $log = log( $bytes, 1024 ); 2631 $power = (int) $log; 2632 $size = pow(1024, $log - $power); 2633 return $size . $units[$power]; 2634 } 2635 2636 /** 2637 * {@internal Missing Short Description}} 2638 * 2639 * @since unknown 2640 * 2641 * @return unknown 2642 */ 2643 function wp_max_upload_size() { 2644 $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) ); 2645 $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) ); 2646 $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes ); 2647 return $bytes; 2648 } 2649 2650 /** 2651 * {@internal Missing Short Description}} 2652 * 2653 * @since unknown 2654 * 2655 * @param unknown_type $action 2656 */ 2657 function wp_import_upload_form( $action ) { 2658 $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); 2659 $size = wp_convert_bytes_to_hr( $bytes ); 2660 ?> 2661 <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo attribute_escape($action) ?>"> 2662 <p> 2663 <?php wp_nonce_field('import-upload'); ?> 2664 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>) 2665 <input type="file" id="upload" name="import" size="25" /> 2666 <input type="hidden" name="action" value="save" /> 2667 <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" /> 2668 </p> 2669 <p class="submit"> 2670 <input type="submit" class="button" value="<?php _e( 'Upload file and import' ); ?>" /> 2671 </p> 2672 </form> 2673 <?php 2674 } 2675 2676 /** 2677 * {@internal Missing Short Description}} 2678 * 2679 * @since unknown 2680 */ 2681 function wp_remember_old_slug() { 2682 global $post; 2683 $name = attribute_escape($post->post_name); // just in case 2684 if ( strlen($name) ) 2685 echo '<input type="hidden" id="wp-old-slug" name="wp-old-slug" value="' . $name . '" />'; 2686 } 2687 2688 /** 2689 * Add a meta box to an edit form. 2690 * 2691 * @since 2.5.0 2692 * 2693 * @param string $id String for use in the 'id' attribute of tags. 2694 * @param string $title Title of the meta box. 2695 * @param string $callback Function that fills the box with the desired content. The function should echo its output. 2696 * @param string $page The type of edit page on which to show the box (post, page, link). 2697 * @param string $context The context within the page where the boxes should show ('normal', 'advanced'). 2698 * @param string $priority The priority within the context where the boxes should show ('high', 'low'). 2699 */ 2700 function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default') { 2701 global $wp_meta_boxes; 2702 2703 if ( !isset($wp_meta_boxes) ) 2704 $wp_meta_boxes = array(); 2705 if ( !isset($wp_meta_boxes[$page]) ) 2706 $wp_meta_boxes[$page] = array(); 2707 if ( !isset($wp_meta_boxes[$page][$context]) ) 2708 $wp_meta_boxes[$page][$context] = array(); 2709 2710 foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) { 2711 foreach ( array('high', 'core', 'default', 'low') as $a_priority ) { 2712 if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) ) 2713 continue; 2714 2715 // If a core box was previously added or removed by a plugin, don't add. 2716 if ( 'core' == $priority ) { 2717 // If core box previously deleted, don't add 2718 if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] ) 2719 return; 2720 // If box was added with default priority, give it core priority to maintain sort order 2721 if ( 'default' == $a_priority ) { 2722 $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id]; 2723 unset($wp_meta_boxes[$page][$a_context]['default'][$id]); 2724 } 2725 return; 2726 } 2727 // If no priority given and id already present, use existing priority 2728 if ( empty($priority) ) { 2729 $priority = $a_priority; 2730 // else if we're adding to the sorted priortiy, we don't know the title or callback. Glab them from the previously added context/priority. 2731 } elseif ( 'sorted' == $priority ) { 2732 $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title']; 2733 $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback']; 2734 } 2735 // An id can be in only one priority and one context 2736 if ( $priority != $a_priority || $context != $a_context ) 2737 unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]); 2738 } 2739 } 2740 2741 if ( empty($priority) ) 2742 $priority = 'low'; 2743 2744 if ( !isset($wp_meta_boxes[$page][$context][$priority]) ) 2745 $wp_meta_boxes[$page][$context][$priority] = array(); 2746 2747 $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback); 2748 } 2749 2750 /** 2751 * {@internal Missing Short Description}} 2752 * 2753 * @since unknown 2754 * 2755 * @param unknown_type $page 2756 * @param unknown_type $context 2757 * @param unknown_type $object 2758 * @return int number of meta_boxes 2759 */ 2760 function do_meta_boxes($page, $context, $object) { 2761 global $wp_meta_boxes; 2762 static $already_sorted = false; 2763 2764 //do_action('do_meta_boxes', $page, $context, $object); 2765 2766 $hidden = get_hidden_meta_boxes($page); 2767 2768 echo "<div id='$context-sortables' class='meta-box-sortables'>\n"; 2769 2770 $i = 0; 2771 do { 2772 // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose 2773 if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page", 0, false ) ) { 2774 foreach ( $sorted as $box_context => $ids ) 2775 foreach ( explode(',', $ids) as $id ) 2776 if ( $id ) 2777 add_meta_box( $id, null, null, $page, $box_context, 'sorted' ); 2778 } 2779 $already_sorted = true; 2780 2781 if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) ) 2782 break; 2783 2784 foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) { 2785 if ( isset($wp_meta_boxes[$page][$context][$priority]) ) { 2786 foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) { 2787 if ( false == $box || ! $box['title'] ) 2788 continue; 2789 $i++; 2790 $style = ''; 2791 if ( in_array($box['id'], $hidden) ) 2792 $style = 'style="display:none;"'; 2793 echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '" ' . $style . '>' . "\n"; 2794 echo '<div class="handlediv" title="' . __('Click to toggle') . '"><br /></div>'; 2795 echo "<h3 class='hndle'><span>{$box['title']}</span></h3>\n"; 2796 echo '<div class="inside">' . "\n"; 2797 call_user_func($box['callback'], $object, $box); 2798 echo "</div>\n"; 2799 echo "</div>\n"; 2800 } 2801 } 2802 } 2803 } while(0); 2804 2805 echo "</div>"; 2806 2807 return $i; 2808 2809 } 2810 2811 /** 2812 * Remove a meta box from an edit form. 2813 * 2814 * @since 2.6.0 2815 * 2816 * @param string $id String for use in the 'id' attribute of tags. 2817 * @param string $page The type of edit page on which to show the box (post, page, link). 2818 * @param string $context The context within the page where the boxes should show ('normal', 'advanced'). 2819 */ 2820 function remove_meta_box($id, $page, $context) { 2821 global $wp_meta_boxes; 2822 2823 if ( !isset($wp_meta_boxes) ) 2824 $wp_meta_boxes = array(); 2825 if ( !isset($wp_meta_boxes[$page]) ) 2826 $wp_meta_boxes[$page] = array(); 2827 if ( !isset($wp_meta_boxes[$page][$context]) ) 2828 $wp_meta_boxes[$page][$context] = array(); 2829 2830 foreach ( array('high', 'core', 'default', 'low') as $priority ) 2831 $wp_meta_boxes[$page][$context][$priority][$id] = false; 2832 } 2833 2834 /** 2835 * {@internal Missing Short Description}} 2836 * 2837 * @since unknown 2838 * 2839 * @param unknown_type $page 2840 */ 2841 function meta_box_prefs($page) { 2842 global $wp_meta_boxes; 2843 2844 if ( empty($wp_meta_boxes[$page]) ) 2845 return; 2846 2847 $hidden = get_hidden_meta_boxes($page); 2848 2849 foreach ( array_keys($wp_meta_boxes[$page]) as $context ) { 2850 foreach ( array_keys($wp_meta_boxes[$page][$context]) as $priority ) { 2851 foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) { 2852 if ( false == $box || ! $box['title'] ) 2853 continue; 2854 // Submit box cannot be hidden 2855 if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) 2856 continue; 2857 $box_id = $box['id']; 2858 echo '<label for="' . $box_id . '-hide">'; 2859 echo '<input class="hide-postbox-tog" name="' . $box_id . '-hide" type="checkbox" id="' . $box_id . '-hide" value="' . $box_id . '"' . (! in_array($box_id, $hidden) ? ' checked="checked"' : '') . ' />'; 2860 echo "{$box['title']}</label>\n"; 2861 } 2862 } 2863 } 2864 } 2865 2866 function get_hidden_meta_boxes($page) { 2867 $hidden = (array) get_user_option( "meta-box-hidden_$page", 0, false ); 2868 2869 // Hide slug boxes by default 2870 if ( empty($hidden[0]) ) { 2871 if ( 'page' == $page ) 2872 $hidden = array('pageslugdiv'); 2873 elseif ( 'post' == $page ) 2874 $hidden = array('slugdiv'); 2875 } 2876 2877 return $hidden; 2878 } 2879 2880 /** 2881 * Add a new section to a settings page. 2882 * 2883 * @since 2.7.0 2884 * 2885 * @param string $id String for use in the 'id' attribute of tags. 2886 * @param string $title Title of the section. 2887 * @param string $callback Function that fills the section with the desired content. The function should echo its output. 2888 * @param string $page The type of settings page on which to show the section (general, reading, writing, ...). 2889 */ 2890 function add_settings_section($id, $title, $callback, $page) { 2891 global $wp_settings_sections; 2892 2893 if ( !isset($wp_settings_sections) ) 2894 $wp_settings_sections = array(); 2895 if ( !isset($wp_settings_sections[$page]) ) 2896 $wp_settings_sections[$page] = array(); 2897 if ( !isset($wp_settings_sections[$page][$id]) ) 2898 $wp_settings_sections[$page][$id] = array(); 2899 2900 $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback); 2901 } 2902 2903 /** 2904 * Add a new field to a settings page. 2905 * 2906 * @since 2.7.0 2907 * 2908 * @param string $id String for use in the 'id' attribute of tags. 2909 * @param string $title Title of the field. 2910 * @param string $callback Function that fills the field with the desired content. The function should echo its output. 2911 * @param string $page The type of settings page on which to show the field (general, reading, writing, ...). 2912 * @param string $section The section of the settingss page in which to show the box (default, ...). 2913 * @param array $args Additional arguments 2914 */ 2915 function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) { 2916 global $wp_settings_fields; 2917 2918 if ( !isset($wp_settings_fields) ) 2919 $wp_settings_fields = array(); 2920 if ( !isset($wp_settings_fields[$page]) ) 2921 $wp_settings_fields[$page] = array(); 2922 if ( !isset($wp_settings_fields[$page][$section]) ) 2923 $wp_settings_fields[$page][$section] = array(); 2924 2925 $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args); 2926 } 2927 2928 /** 2929 * {@internal Missing Short Description}} 2930 * 2931 * @since unknown 2932 * 2933 * @param unknown_type $page 2934 */ 2935 function do_settings_sections($page) { 2936 global $wp_settings_sections, $wp_settings_fields; 2937 2938 if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) ) 2939 return; 2940 2941 foreach ( (array) $wp_settings_sections[$page] as $section ) { 2942 echo "<h3>{$section['title']}</h3>\n"; 2943 call_user_func($section['callback'], $section); 2944 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) ) 2945 continue; 2946 echo '<table class="form-table">'; 2947 do_settings_fields($page, $section['id']); 2948 echo '</table>'; 2949 } 2950 } 2951 2952 /** 2953 * {@internal Missing Short Description}} 2954 * 2955 * @since unknown 2956 * 2957 * @param unknown_type $page 2958 * @param unknown_type $section 2959 */ 2960 function do_settings_fields($page, $section) { 2961 global $wp_settings_fields; 2962 2963 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) ) 2964 return; 2965 2966 foreach ( (array) $wp_settings_fields[$page][$section] as $field ) { 2967 echo '<tr valign="top">'; 2968 if ( !empty($field['args']['label_for']) ) 2969 echo '<th scope="row"><label for="' . $field['args']['label_for'] . '">' . $field['title'] . '</label></th>'; 2970 else 2971 echo '<th scope="row">' . $field['title'] . '</th>'; 2972 echo '<td>'; 2973 call_user_func($field['callback']); 2974 echo '</td>'; 2975 echo '</tr>'; 2976 } 2977 } 2978 2979 /** 2980 * {@internal Missing Short Description}} 2981 * 2982 * @since unknown 2983 * 2984 * @param unknown_type $page 2985 */ 2986 function manage_columns_prefs($page) { 2987 $columns = get_column_headers($page); 2988 2989 $hidden = get_hidden_columns($page); 2990 2991 foreach ( $columns as $column => $title ) { 2992 // Can't hide these 2993 if ( 'cb' == $column || 'title' == $column || 'name' == $column || 'username' == $column || 'media' == $column || 'comment' == $column ) 2994 continue; 2995 if ( empty($title) ) 2996 continue; 2997 2998 if ( 'comments' == $column ) 2999 $title = __('Comments'); 3000 $id = "$column-hide"; 3001 echo '<label for="' . $id . '">'; 3002 echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . (! in_array($column, $hidden) ? ' checked="checked"' : '') . ' />'; 3003 echo "$title</label>\n"; 3004 } 3005 } 3006 3007 /** 3008 * {@internal Missing Short Description}} 3009 * 3010 * @since unknown 3011 * 3012 * @param unknown_type $found_action 3013 */ 3014 function find_posts_div($found_action = '') { 3015 ?> 3016 <div id="find-posts" class="find-box" style="display:none;"> 3017 <div id="find-posts-head" class="find-box-head"><?php _e('Find Posts or Pages'); ?></div> 3018 <div class="find-box-inside"> 3019 <div class="find-box-search"> 3020 <?php if ( $found_action ) { ?> 3021 <input type="hidden" name="found_action" value="<?php echo $found_action; ?>" /> 3022 <?php } ?> 3023 3024 <input type="hidden" name="affected" id="affected" value="" /> 3025 <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?> 3026 <label class="hidden" for="find-posts-input"><?php _e( 'Search' ); ?></label> 3027 <input type="text" id="find-posts-input" class="search-input" name="ps" value="" /> 3028 <input type="button" onclick="findPosts.send();" value="<?php _e( 'Search' ); ?>" class="button" /><br /> 3029 3030 <input type="radio" name="find-posts-what" id="find-posts-posts" checked="checked" value="posts" /> 3031 <label for="find-posts-posts"><?php _e( 'Posts' ); ?></label> 3032 <input type="radio" name="find-posts-what" id="find-posts-pages" value="pages" /> 3033 <label for="find-posts-pages"><?php _e( 'Pages' ); ?></label> 3034 </div> 3035 <div id="find-posts-response"></div> 3036 </div> 3037 <div class="find-box-buttons"> 3038 <input type="button" class="button" onclick="findPosts.close();" value="<?php _e('Close'); ?>" /> 3039 <input id="find-posts-submit" type="submit" class="button" value="<?php _e('Select'); ?>" /> 3040 </div> 3041 </div> 3042 <script type="text/javascript"> 3043 /* <![CDATA[ */ 3044 (function($){ 3045 findPosts = { 3046 open : function(af_name, af_val) { 3047 var st = document.documentElement.scrollTop || $(document).scrollTop(); 3048 3049 if ( af_name && af_val ) 3050 $('#affected').attr('name', af_name).val(af_val); 3051 3052 $('#find-posts').show().draggable({ 3053 handle: '#find-posts-head' 3054 }).resizable({ 3055 handles: 'all', 3056 minHeight: 150, 3057 minWidth: 280 3058 }).css({'top':st+'px','left':'50%','marginLeft':'-200px'}); 3059 3060 $('.ui-resizable-handle').css({ 3061 'backgroundColor': '#e5e5e5' 3062 }); 3063 3064 $('.ui-resizable-se').css({ 3065 'border': '0 none', 3066 'width': '15px', 3067 'height': '16px', 3068 'background': 'transparent url(images/se.png) no-repeat scroll 0 0' 3069 }); 3070 3071 $('#find-posts-input').focus().keyup(function(e){ 3072 if (e.which == 27) findPosts.close(); // close on Escape 3073 }); 3074 3075 return false; 3076 }, 3077 3078 close : function() { 3079 $('#find-posts-response').html(''); 3080 $('#find-posts').draggable('destroy').resizable('destroy').hide(); 3081 }, 3082 3083 send : function() { 3084 var post = {}; 3085 3086 post['ps'] = $('#find-posts-input').val(); 3087 post['action'] = 'find_posts'; 3088 post['_ajax_nonce'] = $('#_ajax_nonce').val(); 3089 3090 if ( $('#find-posts-pages:checked').val() ) 3091 post['pages'] = 1; 3092 else 3093 post['posts'] = 1; 3094 3095 $.ajax({ 3096 type : 'POST', 3097 url : '<?php echo admin_url('admin-ajax.php'); ?>', 3098 data : post, 3099 success : function(x) { findPosts.show(x); }, 3100 error : function(r) { findPosts.error(r); } 3101 }); 3102 }, 3103 3104 show : function(x) { 3105 3106 if ( typeof(x) == 'string' ) { 3107 this.error({'responseText': x}); 3108 return; 3109 } 3110 3111 var r = wpAjax.parseAjaxResponse(x); 3112 3113 if ( r.errors ) 3114 this.error({'responseText': wpAjax.broken}); 3115 3116 r = r.responses[0]; 3117 $('#find-posts-response').html(r.data); 3118 }, 3119 3120 error : function(r) { 3121 var er = r.statusText; 3122 3123 if ( r.responseText ) 3124 er = r.responseText.replace( /<.[^<>]*?>/g, '' ); 3125 3126 if ( er ) 3127 $('#find-posts-response').html(er); 3128 } 3129 }; 3130 3131 $(document).ready(function(){ 3132 $('#find-posts-submit').click(function(e) { 3133 if ( '' == $('#find-posts-response').html() ) 3134 e.preventDefault(); 3135 }); 3136 }); 3137 })(jQuery); 3138 /* ]]> */ 3139 </script> 3140 <?php 3141 } 3142 3143 /** 3144 * Display the post password. 3145 * 3146 * The password is passed through {@link attribute_escape()} to ensure that it 3147 * is safe for placing in an html attribute. 3148 * 3149 * @uses attribute_escape 3150 * @since 2.7.0 3151 */ 3152 function the_post_password() { 3153 global $post; 3154 if ( isset( $post->post_password ) ) echo attribute_escape( $post->post_password ); 3155 } 3156 3157 /** 3158 * {@internal Missing Short Description}} 3159 * 3160 * @since unknown 3161 */ 3162 function favorite_actions() { 3163 $actions = array( 3164 'post-new.php' => array(__('New Post'), 'edit_posts'), 3165 'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'), 3166 'page-new.php' => array(__('New Page'), 'edit_pages'), 3167 'media-new.php' => array(__('Upload'), 'upload_files'), 3168 'edit-comments.php' => array(__('Comments'), 'moderate_comments') 3169 ); 3170 3171 $actions = apply_filters('favorite_actions', $actions); 3172 3173 $allowed_actions = array(); 3174 foreach ( $actions as $action => $data ) { 3175 if ( current_user_can($data[1]) ) 3176 $allowed_actions[$action] = $data[0]; 3177 } 3178 3179 if ( empty($allowed_actions) ) 3180 return; 3181 3182 $first = array_keys($allowed_actions); 3183 $first = $first[0]; 3184 echo '<div id="favorite-actions">'; 3185 echo '<div id="favorite-first"><a href="' . $first . '">' . $allowed_actions[$first] . '</a></div><div id="favorite-toggle"><br /></div>'; 3186 echo '<div id="favorite-inside">'; 3187 3188 array_shift($allowed_actions); 3189 3190 foreach ( $allowed_actions as $action => $label) { 3191 echo "<div class='favorite-action'><a href='$action'>"; 3192 echo $label; 3193 echo "</a></div>\n"; 3194 } 3195 echo "</div></div>\n"; 3196 } 3197 3198 /** 3199 * Get the post title. 3200 * 3201 * The post title is fetched and if it is blank then a default string is 3202 * returned. 3203 * 3204 * @since 2.7.0 3205 * @param int $id The post id. If not supplied the global $post is used. 3206 * 3207 */ 3208 function _draft_or_post_title($post_id = 0) 3209 { 3210 $title = get_the_title($post_id); 3211 if ( empty($title) ) 3212 $title = __('(no title)'); 3213 return $title; 3214 } 3215 3216 /** 3217 * Display the search query. 3218 * 3219 * A simple wrapper to display the "s" parameter in a GET URI. This function 3220 * should only be used when {@link the_search_query()} cannot. 3221 * 3222 * @uses attribute_escape 3223 * @since 2.7.0 3224 * 3225 */ 3226 function _admin_search_query() { 3227 echo isset($_GET['s']) ? attribute_escape( stripslashes( $_GET['s'] ) ) : ''; 3228 } 3229 3230 /** 3231 * Generic Iframe header for use with Thickbox 3232 * 3233 * @since 2.7.0 3234 * @param string $title Title of the Iframe page. 3235 * @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued). 3236 * 3237 */ 3238 function iframe_header( $title = '', $limit_styles = false) { 3239 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3240 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> 3241 <head> 3242 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> 3243 <title><?php bloginfo('name') ?> › <?php echo $title ?> — <?php _e('WordPress'); ?></title> 3244 <?php 3245 wp_enqueue_style( 'global' ); 3246 wp_enqueue_style( 'colors' ); 3247 if ( ! $limit_styles ) 3248 wp_enqueue_style( 'wp-admin' ); 3249 ?> 3250 <script type="text/javascript"> 3251 //<![CDATA[ 3252 function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}} 3253 //]]> 3254 </script> 3255 <?php 3256 do_action('admin_print_styles'); 3257 do_action('admin_print_scripts'); 3258 do_action('admin_head'); 3259 ?> 3260 </head> 3261 <body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?>> 3262 <?php 3263 } 3264 3265 /** 3266 * Generic Iframe footer for use with Thickbox 3267 * 3268 * @since 2.7.0 3269 * 3270 */ 3271 function iframe_footer() { 3272 echo ' 3273 </body> 3274 </html>'; 3275 } 3276 3277 function _post_states($post) { 3278 $post_states = array(); 3279 if ( isset($_GET['post_status']) ) 3280 $post_status = $_GET['post_status']; 3281 else 3282 $post_status = ''; 3283 3284 if ( !empty($post->post_password) ) 3285 $post_states[] = __('Password protected'); 3286 if ( 'private' == $post->post_status && 'private' != $post_status ) 3287 $post_states[] = __('Private'); 3288 if ( 'draft' == $post->post_status && 'draft' != $post_status ) 3289 $post_states[] = __('Draft'); 3290 if ( 'pending' == $post->post_status && 'pending' != $post_status ) 3291 $post_states[] = __('Pending'); 3292 3293 if ( ! empty($post_states) ) { 3294 $state_count = count($post_states); 3295 $i = 0; 3296 echo ' - '; 3297 foreach ( $post_states as $state ) { 3298 ++$i; 3299 ( $i == $state_count ) ? $sep = '' : $sep = ', '; 3300 echo "<span class='post-state'>$state$sep</span>"; 3301 } 3302 } 3303 } 3304 3305 function screen_meta($screen) { 3306 global $wp_meta_boxes, $_wp_contextual_help; 3307 3308 $screen = str_replace('.php', '', $screen); 3309 $screen = str_replace('-new', '', $screen); 3310 $screen = str_replace('-add', '', $screen); 3311 $screen = apply_filters('screen_meta_screen', $screen); 3312 3313 $column_screens = get_column_headers($screen); 3314 $meta_screens = array('index' => 'dashboard'); 3315 3316 if ( isset($meta_screens[$screen]) ) 3317 $screen = $meta_screens[$screen]; 3318 $show_screen = false; 3319 if ( !empty($wp_meta_boxes[$screen]) || !empty($column_screens) ) 3320 $show_screen = true; 3321 ?> 3322 <div id="screen-meta"> 3323 <?php 3324 if ( $show_screen ) : 3325 ?> 3326 <div id="screen-options-wrap" class="hidden"> 3327 <h5><?php _e('Show on screen') ?></h5> 3328 <form id="adv-settings" action="" method="get"> 3329 <div class="metabox-prefs"> 3330 <?php 3331 if ( !meta_box_prefs($screen) && isset($column_screens) ) { 3332 manage_columns_prefs($screen); 3333 wp_nonce_field( 'hiddencolumns', 'hiddencolumnsnonce', false ); 3334 } 3335 ?> 3336 <br class="clear" /> 3337 </div></form> 3338 </div> 3339 3340 <?php 3341 endif; 3342 3343 global $title; 3344 3345 if ( !isset($_wp_contextual_help) ) 3346 $_wp_contextual_help = array(); 3347 3348 if ( !isset($_wp_contextual_help['post']) ) { 3349 $help = drag_drop_help(); 3350 $help .= '<p>' . __('<a href="http://codex.wordpress.org/Writing_Posts" target="_blank">Writing Posts</a>') . '</p>'; 3351 $_wp_contextual_help['post'] = $help; 3352 } 3353 3354 if ( !isset($_wp_contextual_help['page']) ) { 3355 $help = drag_drop_help(); 3356 $_wp_contextual_help['page'] = $help; 3357 } 3358 3359 if ( !isset($_wp_contextual_help['dashboard']) ) { 3360 $help = drag_drop_help(); 3361 $_wp_contextual_help['dashboard'] = $help; 3362 } 3363 3364 if ( !isset($_wp_contextual_help['link']) ) { 3365 $help = drag_drop_help(); 3366 $_wp_contextual_help['link'] = $help; 3367 } 3368 3369 if ( !isset($_wp_contextual_help['options-general']) ) 3370 $_wp_contextual_help['options-general'] = __('<a href="http://codex.wordpress.org/Settings_General_SubPanel" target="_blank">General Settings</a>'); 3371 3372 $_wp_contextual_help = apply_filters('contextual_help_list', $_wp_contextual_help, $screen); 3373 ?> 3374 <div id="contextual-help-wrap" class="hidden"> 3375 <?php 3376 $contextual_help = ''; 3377 if ( isset($_wp_contextual_help[$screen]) ) { 3378 if ( !empty($title) ) 3379 $contextual_help .= '<h5>' . sprintf(__('Get help with "%s"'), $title) . '</h5>'; 3380 else 3381 $contextual_help .= '<h5>' . __('Get help with this page') . '</h5>'; 3382 $contextual_help .= '<div class="metabox-prefs">' . $_wp_contextual_help[$screen] . "</div>\n"; 3383 3384 $contextual_help .= '<h5>' . __('Other Help') . '</h5>'; 3385 } else { 3386 $contextual_help .= '<h5>' . __('Help') . '</h5>'; 3387 } 3388 3389 $contextual_help .= '<div class="metabox-prefs">'; 3390 $contextual_help .= __('<a href="http://codex.wordpress.org/" target="_blank">Documentation</a>'); 3391 $contextual_help .= '<br />'; 3392 $contextual_help .= __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>'); 3393 $contextual_help .= "</div>\n"; 3394 echo apply_filters('contextual_help', $contextual_help, $screen); 3395 ?> 3396 </div> 3397 3398 <div id="screen-meta-links"> 3399 <div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle"> 3400 <a href="#contextual-help" id="contextual-help-link" class="show-settings"><?php _e('Help') ?></a> 3401 </div> 3402 <?php if ( $show_screen ) { ?> 3403 <div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle"> 3404 <a href="#screen-options" id="show-settings-link" class="show-settings"><?php _e('Screen Options') ?></a> 3405 </div> 3406 <?php } ?> 3407 </div> 3408 </div> 3409 <?php 3410 } 3411 3412 /** 3413 * Add contextual help text for a page 3414 * 3415 * @since 2.7.0 3416 * 3417 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions. 3418 * @param string $help Arbitrary help text 3419 */ 3420 function add_contextual_help($screen, $help) { 3421 global $_wp_contextual_help; 3422 3423 if ( !isset($_wp_contextual_help) ) 3424 $_wp_contextual_help = array(); 3425 3426 $_wp_contextual_help[$screen] = $help; 3427 } 3428 3429 function drag_drop_help() { 3430 return ' 3431 <p>' . __('Most of the modules on this screen can be moved. If you hover your mouse over the title bar of a module you’ll notice the 4 arrow cursor appears to let you know it is movable. Click on it, hold down the mouse button and start dragging the module to a new location. As you drag the module, notice the dotted gray box that also moves. This box indicates where the module will be placed when you release the mouse button.') . '</p> 3432 <p>' . __('The same modules can be expanded and collapsed by clicking once on their title bar and also completely hidden from the Screen Options tab.') . '</p> 3433 '; 3434 } 3435 3436 function screen_icon($name = '') { 3437 global $parent_file, $hook_suffix; 3438 3439 if ( empty($name) ) { 3440 if ( isset($parent_file) && !empty($parent_file) ) 3441 $name = substr($parent_file, 0, -4); 3442 else 3443 $name = str_replace(array('.php', '-new', '-add'), '', $hook_suffix); 3444 } 3445 unset($hook_suffix); 3446 ?> 3447 <div id="icon-<?php echo $name; ?>" class="icon32"><br /></div> 3448 <?php 3449 } 3450 3451 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Mar 23 16:23:02 2009 | Cross-referenced by PHPXref 0.7 |