Changes from branches/3.0/wp-admin/includes/template.php at r17412 to trunk/wp-admin/includes/template.php at r17410
- File:
-
- 1 edited
-
trunk/wp-admin/includes/template.php (modified) (66 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/template.php
r17412 r17410 9 9 */ 10 10 11 /**12 * {@internal Missing Short Description}}13 *14 * @since 2.715 *16 * Outputs the HTML for the hidden table rows used in Categories, Link Categories and Tags quick edit.17 *18 * @param string $type "edit-tags", "categoried" or "edit-link-categories"19 * @param string $taxonomy The taxonomy of the row.20 * @return21 */22 function inline_edit_term_row($type, $taxonomy) {23 24 $tax = get_taxonomy($taxonomy);25 if ( ! current_user_can( $tax->cap->edit_terms ) )26 return;27 28 $columns = get_column_headers($type);29 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($type) ) );30 $col_count = count($columns) - count($hidden);31 ?>32 33 <form method="get" action=""><table style="display: none"><tbody id="inlineedit">34 <tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $col_count; ?>">35 36 <fieldset><div class="inline-edit-col">37 <h4><?php _e( 'Quick Edit' ); ?></h4>38 39 <label>40 <span class="title"><?php _e( 'Name' ); ?></span>41 <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span>42 </label>43 <?php if ( !is_multisite() ) { ?>44 <label>45 <span class="title"><?php _e( 'Slug' ); ?></span>46 <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>47 </label>48 <?php } ?>49 50 </div></fieldset>51 52 <?php53 54 $core_columns = array( 'cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true );55 56 foreach ( $columns as $column_name => $column_display_name ) {57 if ( isset( $core_columns[$column_name] ) )58 continue;59 do_action( 'quick_edit_custom_box', $column_name, $type, $taxonomy );60 }61 62 ?>63 64 <p class="inline-edit-save submit">65 <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="cancel button-secondary alignleft"><?php _e('Cancel'); ?></a>66 <?php $update_text = $tax->labels->update_item; ?>67 <a accesskey="s" href="#inline-edit" title="<?php echo esc_attr( $update_text ); ?>" class="save button-primary alignright"><?php echo $update_text; ?></a>68 <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />69 <span class="error" style="display:none;"></span>70 <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?>71 <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $tax->name ); ?>" />72 <br class="clear" />73 </p>74 </td></tr>75 </tbody></table></form>76 <?php77 }78 79 /**80 * {@internal Missing Short Description}}81 *82 * @since unknown83 *84 * @param unknown_type $category85 * @param unknown_type $name_override86 * @return unknown87 */88 function link_cat_row( $category, $name_override = false ) {89 static $row_class = '';90 91 if ( !$category = get_term( $category, 'link_category', OBJECT, 'display' ) )92 return false;93 if ( is_wp_error( $category ) )94 return $category;95 96 $default_cat_id = (int) get_option( 'default_link_category' );97 $name = ( $name_override ? $name_override : $category->name );98 $edit_link = "link-category.php?action=edit&cat_ID=$category->term_id";99 if ( current_user_can( 'manage_categories' ) ) {100 $edit = "<a class='row-title' href='$edit_link' title='" . esc_attr(sprintf(__('Edit “%s”'), $category->name)) . "'>$name</a><br />";101 $actions = array();102 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';103 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';104 if ( $default_cat_id != $category->term_id )105 $actions['delete'] = "<a class='delete:the-list:link-cat-$category->term_id submitdelete' href='" . wp_nonce_url("link-category.php?action=delete&cat_ID=$category->term_id", 'delete-link-category_' . $category->term_id) . "'>" . __('Delete') . "</a>";106 $actions = apply_filters('link_cat_row_actions', $actions, $category);107 $action_count = count($actions);108 $i = 0;109 $edit .= '<div class="row-actions">';110 foreach ( $actions as $action => $link ) {111 ++$i;112 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';113 $edit .= "<span class='$action'>$link$sep</span>";114 }115 $edit .= '</div>';116 } else {117 $edit = $name;118 }119 120 $row_class = 'alternate' == $row_class ? '' : 'alternate';121 $qe_data = get_term_to_edit($category->term_id, 'link_category');122 123 $category->count = number_format_i18n( $category->count );124 $count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count;125 $output = "<tr id='link-cat-$category->term_id' class='iedit $row_class'>";126 $columns = get_column_headers('edit-link-categories');127 $hidden = get_hidden_columns('edit-link-categories');128 foreach ( $columns as $column_name => $column_display_name ) {129 $class = "class=\"$column_name column-$column_name\"";130 131 $style = '';132 if ( in_array($column_name, $hidden) )133 $style = ' style="display:none;"';134 135 $attributes = "$class$style";136 137 switch ($column_name) {138 case 'cb':139 $output .= "<th scope='row' class='check-column'>";140 if ( absint( get_option( 'default_link_category' ) ) != $category->term_id ) {141 $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";142 } else {143 $output .= " ";144 }145 $output .= "</th>";146 break;147 case 'name':148 $output .= "<td $attributes>$edit";149 $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';150 $output .= '<div class="name">' . $qe_data->name . '</div>';151 $output .= '<div class="slug">' . apply_filters('editable_slug', $qe_data->slug) . '</div>';152 $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>';153 break;154 case 'description':155 $output .= "<td $attributes>$category->description</td>";156 break;157 case 'slug':158 $output .= "<td $attributes>" . apply_filters('editable_slug', $category->slug) . "</td>";159 break;160 case 'links':161 $attributes = 'class="links column-links num"' . $style;162 $output .= "<td $attributes>$count</td>";163 break;164 default:165 $output .= "<td $attributes>";166 $output .= apply_filters('manage_link_categories_custom_column', '', $column_name, $category->term_id);167 $output .= "</td>";168 }169 }170 $output .= '</tr>';171 172 return $output;173 }174 11 175 12 // … … 180 17 * {@internal Missing Short Description}} 181 18 * 182 * @since unknown19 * @since 2.5.1 183 20 */ 184 21 class Walker_Category_Checklist extends Walker { … … 218 55 * {@internal Missing Short Description}} 219 56 * 220 * @since unknown57 * @since 2.5.1 221 58 * 222 59 * @param unknown_type $post_id … … 240 77 * Taxonomy independent version of wp_category_checklist 241 78 * 79 * @since 3.0.0 80 * 242 81 * @param int $post_id 243 82 * @param array $args … … 306 145 * {@internal Missing Short Description}} 307 146 * 308 * @since unknown147 * @since 2.5.0 309 148 * 310 149 * @param unknown_type $taxonomy … … 354 193 * {@internal Missing Short Description}} 355 194 * 356 * @since unknown195 * @since 2.5.1 357 196 * 358 197 * @param unknown_type $link_id … … 383 222 } 384 223 385 // Tag stuff386 387 // Returns a single tag row (see tag_rows below)388 // Note: this is also used in admin-ajax.php!389 /**390 * {@internal Missing Short Description}}391 *392 * @since unknown393 *394 * @param unknown_type $tag395 * @param unknown_type $class396 * @return unknown397 */398 function _tag_row( $tag, $level, $taxonomy = 'post_tag' ) {399 global $post_type, $current_screen;400 static $row_class = '';401 $row_class = ($row_class == '' ? ' class="alternate"' : '');402 403 $count = number_format_i18n( $tag->count );404 $tax = get_taxonomy($taxonomy);405 406 if ( 'post_tag' == $taxonomy ) {407 $tagsel = 'tag';408 } elseif ( 'category' == $taxonomy ) {409 $tagsel = 'category_name';410 } elseif ( ! empty($tax->query_var) ) {411 $tagsel = $tax->query_var;412 } else {413 $tagsel = $taxonomy;414 }415 416 $pad = str_repeat( '— ', max(0, $level) );417 $name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag );418 $qe_data = get_term($tag->term_id, $taxonomy, object, 'edit');419 $edit_link = "edit-tags.php?action=edit&taxonomy=$taxonomy&post_type=$post_type&tag_ID=$tag->term_id";420 421 $out = '';422 $out .= '<tr id="tag-' . $tag->term_id . '"' . $row_class . '>';423 424 425 $columns = get_column_headers($current_screen);426 $hidden = get_hidden_columns($current_screen);427 $default_term = get_option('default_' . $taxonomy);428 foreach ( $columns as $column_name => $column_display_name ) {429 $class = "class=\"$column_name column-$column_name\"";430 431 $style = '';432 if ( in_array($column_name, $hidden) )433 $style = ' style="display:none;"';434 435 $attributes = "$class$style";436 437 switch ($column_name) {438 case 'cb':439 if ( current_user_can($tax->cap->delete_terms) && $tag->term_id != $default_term )440 $out .= '<th scope="row" class="check-column"> <input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" /></th>';441 else442 $out .= '<th scope="row" class="check-column"> </th>';443 break;444 case 'name':445 $out .= '<td ' . $attributes . '><strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr(sprintf(__('Edit “%s”'), $name)) . '">' . $name . '</a></strong><br />';446 $actions = array();447 if ( current_user_can($tax->cap->edit_terms) ) {448 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';449 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';450 }451 if ( current_user_can($tax->cap->delete_terms) && $tag->term_id != $default_term )452 $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url("edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "'>" . __('Delete') . "</a>";453 454 $actions = apply_filters('tag_row_actions', $actions, $tag);455 $actions = apply_filters("${taxonomy}_row_actions", $actions, $tag);456 457 $action_count = count($actions);458 $i = 0;459 $out .= '<div class="row-actions">';460 foreach ( $actions as $action => $link ) {461 ++$i;462 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';463 $out .= "<span class='$action'>$link$sep</span>";464 }465 $out .= '</div>';466 $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';467 $out .= '<div class="name">' . $qe_data->name . '</div>';468 $out .= '<div class="slug">' . apply_filters('editable_slug', $qe_data->slug) . '</div>';469 $out .= '<div class="parent">' . $qe_data->parent . '</div></div></td>';470 break;471 case 'description':472 $out .= "<td $attributes>$tag->description</td>";473 break;474 case 'slug':475 $out .= "<td $attributes>" . apply_filters('editable_slug', $tag->slug) . "</td>";476 break;477 case 'posts':478 $attributes = 'class="posts column-posts num"' . $style;479 $out .= "<td $attributes><a href='edit.php?$tagsel=$tag->slug&post_type=$post_type'>$count</a></td>";480 break;481 default:482 $out .= "<td $attributes>";483 $out .= apply_filters("manage_${taxonomy}_custom_column", '', $column_name, $tag->term_id);484 $out .= "</td>";485 }486 }487 488 $out .= "</tr>\n";489 490 return $out;491 }492 493 // Outputs appropriate rows for the Nth page of the Tag Management screen,494 // assuming M tags displayed at a time on the page495 // Returns the number of tags displayed496 /**497 * {@internal Missing Short Description}}498 *499 * @since unknown500 *501 * @param unknown_type $page502 * @param unknown_type $pagesize503 * @param unknown_type $searchterms504 * @return unknown505 */506 function tag_rows( $page = 1, $pagesize = 20, $searchterms = '', $taxonomy = 'post_tag' ) {507 508 // Get a page worth of tags509 $start = ($page - 1) * $pagesize;510 511 $args = array('offset' => $start, 'number' => $pagesize, 'hide_empty' => 0);512 513 if ( !empty( $searchterms ) )514 $args['search'] = $searchterms;515 516 // convert it to table rows517 $out = '';518 $count = 0;519 if ( is_taxonomy_hierarchical($taxonomy) ) {520 // We'll need the full set of terms then.521 $args['number'] = $args['offset'] = 0;522 523 $terms = get_terms( $taxonomy, $args );524 if ( !empty( $searchterms ) ) // Ignore children on searches.525 $children = array();526 else527 $children = _get_term_hierarchy($taxonomy);528 529 // Some funky recursion to get the job done(Paging & parents mainly) is contained within, Skip it for non-hierarchical taxonomies for performance sake530 $out .= _term_rows($taxonomy, $terms, $children, $page, $pagesize, $count);531 } else {532 $terms = get_terms( $taxonomy, $args );533 foreach( $terms as $term )534 $out .= _tag_row( $term, 0, $taxonomy );535 $count = $pagesize; // Only displaying a single page.536 }537 538 echo $out;539 return $count;540 }541 542 function _term_rows( $taxonomy, $terms, &$children, $page = 1, $per_page = 20, &$count, $parent = 0, $level = 0 ) {543 544 $start = ($page - 1) * $per_page;545 $end = $start + $per_page;546 547 $output = '';548 foreach ( $terms as $key => $term ) {549 550 if ( $count >= $end )551 break;552 553 if ( $term->parent != $parent && empty($_GET['s']) )554 continue;555 556 // If the page starts in a subtree, print the parents.557 if ( $count == $start && $term->parent > 0 && empty($_GET['s']) ) {558 $my_parents = $parent_ids = array();559 $p = $term->parent;560 while ( $p ) {561 $my_parent = get_term( $p, $taxonomy );562 $my_parents[] = $my_parent;563 $p = $my_parent->parent;564 if ( in_array($p, $parent_ids) ) // Prevent parent loops.565 break;566 $parent_ids[] = $p;567 }568 unset($parent_ids);569 570 $num_parents = count($my_parents);571 while ( $my_parent = array_pop($my_parents) ) {572 $output .= "\t" . _tag_row( $my_parent, $level - $num_parents, $taxonomy );573 $num_parents--;574 }575 }576 577 if ( $count >= $start )578 $output .= "\t" . _tag_row( $term, $level, $taxonomy );579 580 ++$count;581 582 unset($terms[$key]);583 584 if ( isset($children[$term->term_id]) && empty($_GET['s']) )585 $output .= _term_rows( $taxonomy, $terms, $children, $page, $per_page, $count, $term->term_id, $level + 1 );586 }587 588 return $output;589 }590 591 // define the columns to display, the syntax is 'internal name' => 'display name'592 /**593 * {@internal Missing Short Description}}594 *595 * @since unknown596 *597 * @return unknown598 */599 function wp_manage_posts_columns( $screen = '') {600 if ( empty($screen) )601 $post_type = 'post';602 else603 $post_type = $screen->post_type;604 605 $posts_columns = array();606 $posts_columns['cb'] = '<input type="checkbox" />';607 /* translators: manage posts column name */608 $posts_columns['title'] = _x('Title', 'column name');609 $posts_columns['author'] = __('Author');610 if ( empty($post_type) || is_object_in_taxonomy($post_type, 'category') )611 $posts_columns['categories'] = __('Categories');612 if ( empty($post_type) || is_object_in_taxonomy($post_type, 'post_tag') )613 $posts_columns['tags'] = __('Tags');614 $post_status = !empty($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'all';615 if ( !in_array( $post_status, array('pending', 'draft', 'future') ) && ( empty($post_type) || post_type_supports($post_type, 'comments') ) )616 $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="' . esc_url( admin_url( 'images/comment-grey-bubble.png' ) ) . '" /></div>';617 $posts_columns['date'] = __('Date');618 619 if ( 'page' == $post_type )620 $posts_columns = apply_filters( 'manage_pages_columns', $posts_columns );621 else622 $posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type );623 $posts_columns = apply_filters( "manage_{$post_type}_posts_columns", $posts_columns );624 625 return $posts_columns;626 }627 628 // define the columns to display, the syntax is 'internal name' => 'display name'629 /**630 * {@internal Missing Short Description}}631 *632 * @since unknown633 *634 * @return unknown635 */636 function wp_manage_media_columns() {637 $posts_columns = array();638 $posts_columns['cb'] = '<input type="checkbox" />';639 $posts_columns['icon'] = '';640 /* translators: column name */641 $posts_columns['media'] = _x('File', 'column name');642 $posts_columns['author'] = __('Author');643 //$posts_columns['tags'] = _x('Tags', 'column name');644 /* translators: column name */645 $posts_columns['parent'] = _x('Attached to', 'column name');646 $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="' . esc_url( admin_url( 'images/comment-grey-bubble.png' ) ) . '" /></div>';647 //$posts_columns['comments'] = __('Comments');648 /* translators: column name */649 $posts_columns['date'] = _x('Date', 'column name');650 $posts_columns = apply_filters('manage_media_columns', $posts_columns);651 652 return $posts_columns;653 }654 655 /**656 * {@internal Missing Short Description}}657 *658 * @since unknown659 *660 * @return unknown661 */662 function wp_manage_pages_columns() {663 return wp_manage_posts_columns();664 }665 666 224 /** 667 225 * Get the column headers for a screen 668 226 * 669 * @since unknown227 * @since 2.7.0 670 228 * 671 229 * @param string|object $screen The screen you want the headers for 672 230 * @return array Containing the headers in the format id => UI String 673 231 */ 674 function get_column_headers($screen) { 232 function get_column_headers( $screen ) { 233 if ( is_string( $screen ) ) 234 $screen = convert_to_screen( $screen ); 235 675 236 global $_wp_column_headers; 676 237 677 if ( !isset($_wp_column_headers) ) 678 $_wp_column_headers = array(); 679 680 if ( is_string($screen) ) 681 $screen = convert_to_screen($screen); 682 683 // Store in static to avoid running filters on each call 684 if ( isset($_wp_column_headers[$screen->id]) ) 685 return $_wp_column_headers[$screen->id]; 686 687 switch ($screen->base) { 688 case 'edit': 689 $_wp_column_headers[$screen->id] = wp_manage_posts_columns( $screen ); 690 break; 691 case 'edit-comments': 692 $_wp_column_headers[$screen->id] = array( 693 'cb' => '<input type="checkbox" />', 694 'author' => __('Author'), 695 /* translators: column name */ 696 'comment' => _x('Comment', 'column name'), 697 //'date' => __('Submitted'), 698 'response' => __('In Response To') 699 ); 700 701 break; 702 case 'link-manager': 703 $_wp_column_headers[$screen->id] = array( 704 'cb' => '<input type="checkbox" />', 705 'name' => __('Name'), 706 'url' => __('URL'), 707 'categories' => __('Categories'), 708 'rel' => __('Relationship'), 709 'visible' => __('Visible'), 710 'rating' => __('Rating') 711 ); 712 713 break; 714 case 'upload': 715 $_wp_column_headers[$screen->id] = wp_manage_media_columns(); 716 break; 717 case 'categories': 718 $_wp_column_headers[$screen->id] = array( 719 'cb' => '<input type="checkbox" />', 720 'name' => __('Name'), 721 'description' => __('Description'), 722 'slug' => __('Slug'), 723 'posts' => __('Posts') 724 ); 725 726 break; 727 case 'edit-link-categories': 728 $_wp_column_headers[$screen->id] = array( 729 'cb' => '<input type="checkbox" />', 730 'name' => __('Name'), 731 'description' => __('Description'), 732 'slug' => __('Slug'), 733 'links' => __('Links') 734 ); 735 736 break; 737 case 'edit-tags': 738 $_wp_column_headers[$screen->id] = array( 739 'cb' => '<input type="checkbox" />', 740 'name' => __('Name'), 741 'description' => __('Description'), 742 'slug' => __('Slug'), 743 'posts' => __('Posts') 744 ); 745 746 break; 747 case 'users': 748 $_wp_column_headers[$screen->id] = array( 749 'cb' => '<input type="checkbox" />', 750 'username' => __('Username'), 751 'name' => __('Name'), 752 'email' => __('E-mail'), 753 'role' => __('Role'), 754 'posts' => __('Posts') 755 ); 756 break; 757 default : 758 $_wp_column_headers[$screen->id] = array(); 759 } 760 761 $_wp_column_headers[$screen->id] = apply_filters('manage_' . $screen->id . '_columns', $_wp_column_headers[$screen->id]); 762 return $_wp_column_headers[$screen->id]; 763 } 764 238 if ( !isset( $_wp_column_headers[ $screen->id ] ) ) { 239 $_wp_column_headers[ $screen->id ] = apply_filters( 'manage_' . $screen->id . '_columns', array() ); 240 } 241 242 return $_wp_column_headers[ $screen->id ]; 243 } 244 245 /** 246 * Get a list of hidden columns. 247 * 248 * @since 2.7.0 249 * 250 * @param string|object $screen The screen you want the hidden columns for 251 * @return array 252 */ 253 function get_hidden_columns( $screen ) { 254 if ( is_string( $screen ) ) 255 $screen = convert_to_screen( $screen ); 256 257 return (array) get_user_option( 'manage' . $screen->id . 'columnshidden' ); 258 } 259 260 // adds hidden fields with the data for use in the inline editor for posts and pages 765 261 /** 766 262 * {@internal Missing Short Description}} 767 263 * 768 * @since unknown769 *770 * @param unknown_type $screen771 * @param unknown_type $id772 */773 function print_column_headers( $screen, $id = true ) {774 if ( is_string($screen) )775 $screen = convert_to_screen($screen);776 777 $columns = get_column_headers( $screen );778 $hidden = get_hidden_columns($screen);779 $styles = array();780 781 foreach ( $columns as $column_key => $column_display_name ) {782 $class = ' class="manage-column';783 784 $class .= " column-$column_key";785 786 if ( 'cb' == $column_key )787 $class .= ' check-column';788 elseif ( in_array($column_key, array('posts', 'comments', 'links')) )789 $class .= ' num';790 791 $class .= '"';792 793 $style = '';794 if ( in_array($column_key, $hidden) )795 $style = 'display:none;';796 797 if ( isset($styles[$screen->id]) && isset($styles[$screen->id][$column_key]) )798 $style .= ' ' . $styles[$screen>id][$column_key];799 $style = ' style="' . $style . '"';800 ?>801 <th scope="col" <?php echo $id ? "id=\"$column_key\"" : ""; echo $class; echo $style; ?>><?php echo $column_display_name; ?></th>802 <?php }803 }804 805 /**806 * Register column headers for a particular screen. The header names will be listed in the Screen Options.807 *808 264 * @since 2.7.0 809 *810 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.811 * @param array $columns An array of columns with column IDs as the keys and translated column names as the values812 * @see get_column_headers(), print_column_headers(), get_hidden_columns()813 */814 function register_column_headers($screen, $columns) {815 global $_wp_column_headers;816 817 if ( is_string($screen) )818 $screen = convert_to_screen($screen);819 820 if ( !isset($_wp_column_headers) )821 $_wp_column_headers = array();822 823 $_wp_column_headers[$screen->id] = $columns;824 }825 826 /**827 * {@internal Missing Short Description}}828 *829 * @since unknown830 *831 * @param unknown_type $screen832 */833 function get_hidden_columns($screen) {834 if ( is_string($screen) )835 $screen = convert_to_screen($screen);836 837 return (array) get_user_option( 'manage' . $screen->id. 'columnshidden' );838 }839 840 /**841 * {@internal Missing Short Description}}842 *843 * Outputs the quick edit and bulk edit table rows for posts and pages844 *845 * @since 2.7846 *847 * @param string $screen848 */849 function inline_edit_row( $screen ) {850 global $mode;851 852 if ( is_string($screen) ) {853 $screen = array('id' => 'edit-' . $screen, 'base' => 'edit', 'post_type' => $screen );854 $screen = (object) $screen;855 }856 857 $post = get_default_post_to_edit( $screen->post_type );858 $post_type_object = get_post_type_object( $screen->post_type );859 860 $taxonomy_names = get_object_taxonomies( $screen->post_type );861 $hierarchical_taxonomies = array();862 $flat_taxonomies = array();863 foreach ( $taxonomy_names as $taxonomy_name ) {864 $taxonomy = get_taxonomy( $taxonomy_name);865 866 if ( !$taxonomy->show_ui )867 continue;868 869 if ( $taxonomy->hierarchical )870 $hierarchical_taxonomies[] = $taxonomy;871 else872 $flat_taxonomies[] = $taxonomy;873 }874 875 $columns = wp_manage_posts_columns($screen);876 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($screen) ) );877 $col_count = count($columns) - count($hidden);878 $m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list';879 $can_publish = current_user_can($post_type_object->cap->publish_posts);880 $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );881 882 ?>883 884 <form method="get" action=""><table style="display: none"><tbody id="inlineedit">885 <?php886 $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page';887 $bulk = 0;888 while ( $bulk < 2 ) { ?>889 890 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-$screen->post_type ";891 echo $bulk ? "bulk-edit-row bulk-edit-row-$hclass bulk-edit-$screen->post_type" : "quick-edit-row quick-edit-row-$hclass inline-edit-$screen->post_type";892 ?>" style="display: none"><td colspan="<?php echo $col_count; ?>">893 894 <fieldset class="inline-edit-col-left"><div class="inline-edit-col">895 <h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4>896 897 898 <?php899 900 if ( post_type_supports( $screen->post_type, 'title' ) ) :901 if ( $bulk ) : ?>902 <div id="bulk-title-div">903 <div id="bulk-titles"></div>904 </div>905 906 <?php else : // $bulk ?>907 908 <label>909 <span class="title"><?php _e( 'Title' ); ?></span>910 <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>911 </label>912 913 <label>914 <span class="title"><?php _e( 'Slug' ); ?></span>915 <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>916 </label>917 918 <?php endif; // $bulk919 endif; // post_type_supports title ?>920 921 <?php if ( !$bulk ) : ?>922 <label><span class="title"><?php _e( 'Date' ); ?></span></label>923 <div class="inline-edit-date">924 <?php touch_time(1, 1, 4, 1); ?>925 </div>926 <br class="clear" />927 928 <?php endif; // $bulk929 930 if ( post_type_supports( $screen->post_type, 'author' ) ) :931 $authors = get_editable_user_ids( get_current_user_id(), true, $screen->post_type ); // TODO: ROLE SYSTEM932 $authors_dropdown = '';933 if ( $authors && count( $authors ) > 1 ) :934 $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1, 'echo' => 0);935 if ( $bulk )936 $users_opt['show_option_none'] = __('— No Change —');937 $authors_dropdown = '<label>';938 $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';939 $authors_dropdown .= wp_dropdown_users( $users_opt );940 $authors_dropdown .= '</label>';941 942 endif; // authors943 ?>944 945 <?php if ( !$bulk ) echo $authors_dropdown;946 endif; // post_type_supports author947 948 if ( !$bulk ) :949 ?>950 951 <div class="inline-edit-group">952 <label class="alignleft">953 <span class="title"><?php _e( 'Password' ); ?></span>954 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>955 </label>956 957 <em style="margin:5px 10px 0 0" class="alignleft">958 <?php959 /* translators: Between password field and private checkbox on post quick edit interface */960 echo __( '–OR–' );961 ?>962 </em>963 <label class="alignleft inline-edit-private">964 <input type="checkbox" name="keep_private" value="private" />965 <span class="checkbox-title"><?php echo __('Private'); ?></span>966 </label>967 </div>968 969 <?php endif; ?>970 971 </div></fieldset>972 973 <?php if ( count($hierarchical_taxonomies) && !$bulk ) : ?>974 975 <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">976 977 <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>978 979 <span class="title inline-edit-categories-label"><?php echo esc_html($taxonomy->labels->name) ?>980 <span class="catshow"><?php _e('[more]'); ?></span>981 <span class="cathide" style="display:none;"><?php _e('[less]'); ?></span>982 </span>983 <input type="hidden" name="<?php echo ( $taxonomy->name == 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr($taxonomy->name) . '][]'; ?>" value="0" />984 <ul class="cat-checklist <?php echo esc_attr($taxonomy->name)?>-checklist">985 <?php wp_terms_checklist(null, array('taxonomy' => $taxonomy->name)) ?>986 </ul>987 988 <?php endforeach; //$hierarchical_taxonomies as $taxonomy ?>989 990 </div></fieldset>991 992 <?php endif; // count($hierarchical_taxonomies) && !$bulk ?>993 994 <fieldset class="inline-edit-col-right"><div class="inline-edit-col">995 996 <?php997 if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )998 echo $authors_dropdown;999 ?>1000 1001 <?php if ( $post_type_object->hierarchical ) : ?>1002 1003 <label>1004 <span class="title"><?php _e( 'Parent' ); ?></span>1005 <?php1006 $dropdown_args = array('post_type' => $post_type_object->name, 'selected' => $post->post_parent, 'name' => 'post_parent', 'show_option_none' => __('Main Page (no parent)'), 'option_none_value' => 0, 'sort_column'=> 'menu_order, post_title');1007 if ( $bulk )1008 $dropdown_args['show_option_no_change'] = __('— No Change —');1009 $dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args);1010 wp_dropdown_pages($dropdown_args);1011 ?>1012 </label>1013 1014 <?php if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :1015 if ( !$bulk ) : ?>1016 1017 <label>1018 <span class="title"><?php _e( 'Order' ); ?></span>1019 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>1020 </label>1021 1022 <?php endif; // !$bulk ?>1023 1024 <label>1025 <span class="title"><?php _e( 'Template' ); ?></span>1026 <select name="page_template">1027 <?php if ( $bulk ) : ?>1028 <option value="-1"><?php _e('— No Change —'); ?></option>1029 <?php endif; // $bulk ?>1030 <option value="default"><?php _e( 'Default Template' ); ?></option>1031 <?php page_template_dropdown() ?>1032 </select>1033 </label>1034 1035 <?php1036 endif; // post_type_supports page-attributes1037 endif; // $post_type_object->hierarchical ?>1038 1039 <?php if ( count($flat_taxonomies) && !$bulk ) : ?>1040 1041 <?php foreach ( $flat_taxonomies as $taxonomy ) : ?>1042 1043 <label class="inline-edit-tags">1044 <span class="title"><?php echo esc_html($taxonomy->labels->name) ?></span>1045 <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr($taxonomy->name)?>]" class="tax_input_<?php echo esc_attr($taxonomy->name)?>"></textarea>1046 </label>1047 1048 <?php endforeach; //$flat_taxonomies as $taxonomy ?>1049 1050 <?php endif; // count($flat_taxonomies) && !$bulk ?>1051 1052 <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :1053 if ( $bulk ) : ?>1054 1055 <div class="inline-edit-group">1056 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>1057 <label class="alignleft">1058 <span class="title"><?php _e( 'Comments' ); ?></span>1059 <select name="comment_status">1060 <option value=""><?php _e('— No Change —'); ?></option>1061 <option value="open"><?php _e('Allow'); ?></option>1062 <option value="closed"><?php _e('Do not allow'); ?></option>1063 </select>1064 </label>1065 <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>1066 <label class="alignright">1067 <span class="title"><?php _e( 'Pings' ); ?></span>1068 <select name="ping_status">1069 <option value=""><?php _e('— No Change —'); ?></option>1070 <option value="open"><?php _e('Allow'); ?></option>1071 <option value="closed"><?php _e('Do not allow'); ?></option>1072 </select>1073 </label>1074 <?php endif; ?>1075 </div>1076 1077 <?php else : // $bulk ?>1078 1079 <div class="inline-edit-group">1080 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>1081 <label class="alignleft">1082 <input type="checkbox" name="comment_status" value="open" />1083 <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>1084 </label>1085 <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>1086 <label class="alignleft">1087 <input type="checkbox" name="ping_status" value="open" />1088 <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>1089 </label>1090 <?php endif; ?>1091 </div>1092 1093 <?php endif; // $bulk1094 endif; // post_type_supports comments or pings ?>1095 1096 <div class="inline-edit-group">1097 <label class="inline-edit-status alignleft">1098 <span class="title"><?php _e( 'Status' ); ?></span>1099 <select name="_status">1100 <?php if ( $bulk ) : ?>1101 <option value="-1"><?php _e('— No Change —'); ?></option>1102 <?php endif; // $bulk ?>1103 <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>1104 <option value="publish"><?php _e( 'Published' ); ?></option>1105 <option value="future"><?php _e( 'Scheduled' ); ?></option>1106 <?php if ( $bulk ) : ?>1107 <option value="private"><?php _e('Private') ?></option>1108 <?php endif; // $bulk ?>1109 <?php endif; ?>1110 <option value="pending"><?php _e( 'Pending Review' ); ?></option>1111 <option value="draft"><?php _e( 'Draft' ); ?></option>1112 </select>1113 </label>1114 1115 <?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?>1116 1117 <?php if ( $bulk ) : ?>1118 1119 <label class="alignright">1120 <span class="title"><?php _e( 'Sticky' ); ?></span>1121 <select name="sticky">1122 <option value="-1"><?php _e( '— No Change —' ); ?></option>1123 <option value="sticky"><?php _e( 'Sticky' ); ?></option>1124 <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>1125 </select>1126 </label>1127 1128 <?php else : // $bulk ?>1129 1130 <label class="alignleft">1131 <input type="checkbox" name="sticky" value="sticky" />1132 <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>1133 </label>1134 1135 <?php endif; // $bulk ?>1136 1137 <?php endif; // !$is_page && $can_publish && current_user_can( 'edit_others_cap' ) ?>1138 1139 </div>1140 1141 </div></fieldset>1142 1143 <?php1144 foreach ( $columns as $column_name => $column_display_name ) {1145 if ( isset( $core_columns[$column_name] ) )1146 continue;1147 do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $screen->post_type );1148 }1149 ?>1150 <p class="submit inline-edit-save">1151 <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="button-secondary cancel alignleft"><?php _e('Cancel'); ?></a>1152 <?php if ( ! $bulk ) {1153 wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );1154 $update_text = __( 'Update' );1155 ?>1156 <a accesskey="s" href="#inline-edit" title="<?php _e('Update'); ?>" class="button-primary save alignright"><?php echo esc_attr( $update_text ); ?></a>1157 <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />1158 <?php } else {1159 $update_text = __( 'Update' );1160 ?>1161 <input accesskey="s" class="button-primary alignright" type="submit" name="bulk_edit" value="<?php echo esc_attr( $update_text ); ?>" />1162 <?php } ?>1163 <input type="hidden" name="post_view" value="<?php echo esc_attr($m); ?>" />1164 <input type="hidden" name="screen" value="<?php echo esc_attr($screen->id); ?>" />1165 <br class="clear" />1166 </p>1167 </td></tr>1168 <?php1169 $bulk++;1170 } ?>1171 </tbody></table></form>1172 <?php1173 }1174 1175 // adds hidden fields with the data for use in the inline editor for posts and pages1176 /**1177 * {@internal Missing Short Description}}1178 *1179 * @since unknown1180 265 * 1181 266 * @param unknown_type $post … … 1186 271 return; 1187 272 1188 $title = htmlspecialchars( trim( $post->post_title ), ENT_QUOTES);273 $title = esc_textarea( trim( $post->post_title ) ); 1189 274 1190 275 echo ' … … 1232 317 * {@internal Missing Short Description}} 1233 318 * 1234 * @since unknown 1235 * 1236 * @param unknown_type $posts 1237 */ 1238 function post_rows( $posts = array() ) { 1239 global $wp_query, $post, $mode; 1240 1241 add_filter('the_title','esc_html'); 1242 1243 // Create array of post IDs. 1244 $post_ids = array(); 1245 1246 if ( empty($posts) ) 1247 $posts = &$wp_query->posts; 1248 1249 foreach ( $posts as $a_post ) 1250 $post_ids[] = $a_post->ID; 1251 1252 $comment_pending_count = get_pending_comments_num($post_ids); 1253 1254 foreach ( $posts as $post ) { 1255 if ( empty($comment_pending_count[$post->ID]) ) 1256 $comment_pending_count[$post->ID] = 0; 1257 1258 _post_row($post, $comment_pending_count[$post->ID], $mode); 1259 } 1260 } 1261 1262 /** 1263 * {@internal Missing Short Description}} 1264 * 1265 * @since unknown 1266 * 1267 * @param unknown_type $a_post 1268 * @param unknown_type $pending_comments 1269 * @param unknown_type $mode 1270 */ 1271 function _post_row($a_post, $pending_comments, $mode) { 1272 global $post, $current_screen; 1273 static $rowclass; 1274 1275 $global_post = $post; 1276 $post = $a_post; 1277 setup_postdata($post); 1278 1279 $rowclass = 'alternate' == $rowclass ? '' : 'alternate'; 1280 $post_owner = ( get_current_user_id() == $post->post_author ? 'self' : 'other' ); 1281 $edit_link = get_edit_post_link( $post->ID ); 1282 $title = _draft_or_post_title(); 1283 $post_type_object = get_post_type_object($post->post_type); 1284 ?> 1285 <tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status ); ?> iedit' valign="top"> 1286 <?php 1287 $posts_columns = get_column_headers( $current_screen ); 1288 $hidden = get_hidden_columns( $current_screen ); 1289 foreach ( $posts_columns as $column_name=>$column_display_name ) { 1290 $class = "class=\"$column_name column-$column_name\""; 1291 1292 $style = ''; 1293 if ( in_array($column_name, $hidden) ) 1294 $style = ' style="display:none;"'; 1295 1296 $attributes = "$class$style"; 1297 1298 switch ($column_name) { 1299 1300 case 'cb': 1301 ?> 1302 <th scope="row" class="check-column"><?php if ( current_user_can( $post_type_object->cap->edit_post, $post->ID ) ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th> 1303 <?php 1304 break; 1305 1306 case 'date': 1307 if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) { 1308 $t_time = $h_time = __('Unpublished'); 1309 $time_diff = 0; 1310 } else { 1311 $t_time = get_the_time(__('Y/m/d g:i:s A')); 1312 $m_time = $post->post_date; 1313 $time = get_post_time('G', true, $post); 1314 1315 $time_diff = time() - $time; 1316 1317 if ( $time_diff > 0 && $time_diff < 24*60*60 ) 1318 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); 1319 else 1320 $h_time = mysql2date(__('Y/m/d'), $m_time); 1321 } 1322 1323 echo '<td ' . $attributes . '>'; 1324 if ( 'excerpt' == $mode ) 1325 echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode); 1326 else 1327 echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>'; 1328 echo '<br />'; 1329 if ( 'publish' == $post->post_status ) { 1330 _e('Published'); 1331 } elseif ( 'future' == $post->post_status ) { 1332 if ( $time_diff > 0 ) 1333 echo '<strong class="attention">' . __('Missed schedule') . '</strong>'; 1334 else 1335 _e('Scheduled'); 1336 } else { 1337 _e('Last Modified'); 1338 } 1339 echo '</td>'; 1340 break; 1341 1342 case 'title': 1343 $attributes = 'class="post-title column-title"' . $style; 1344 ?> 1345 <td <?php echo $attributes ?>><strong><?php if ( current_user_can($post_type_object->cap->edit_post, $post->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong> 1346 <?php 1347 if ( 'excerpt' == $mode ) 1348 the_excerpt(); 1349 1350 $actions = array(); 1351 if ( current_user_can($post_type_object->cap->edit_post, $post->ID) && 'trash' != $post->post_status ) { 1352 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this item')) . '">' . __('Edit') . '</a>'; 1353 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this item inline')) . '">' . __('Quick Edit') . '</a>'; 1354 } 1355 if ( current_user_can($post_type_object->cap->delete_post, $post->ID) ) { 1356 if ( 'trash' == $post->post_status ) 1357 $actions['untrash'] = "<a title='" . esc_attr(__('Restore this item from the Trash')) . "' href='" . wp_nonce_url( admin_url( sprintf($post_type_object->_edit_link . '&action=untrash', $post->ID) ), 'untrash-' . $post->post_type . '_' . $post->ID ) . "'>" . __('Restore') . "</a>"; 1358 elseif ( EMPTY_TRASH_DAYS ) 1359 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this item to the Trash')) . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash') . "</a>"; 1360 if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS ) 1361 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this item permanently')) . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete Permanently') . "</a>"; 1362 } 1363 if ( in_array($post->post_status, array('pending', 'draft')) ) { 1364 if ( current_user_can($post_type_object->cap->edit_post, $post->ID) ) 1365 $actions['view'] = '<a href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink($post->ID) ) ) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>'; 1366 } elseif ( 'trash' != $post->post_status ) { 1367 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 1368 } 1369 $actions = apply_filters('post_row_actions', $actions, $post); 1370 $action_count = count($actions); 1371 $i = 0; 1372 echo '<div class="row-actions">'; 1373 foreach ( $actions as $action => $link ) { 1374 ++$i; 1375 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; 1376 echo "<span class='$action'>$link$sep</span>"; 1377 } 1378 echo '</div>'; 1379 1380 get_inline_data($post); 1381 ?> 1382 </td> 1383 <?php 1384 break; 1385 1386 case 'categories': 1387 ?> 1388 <td <?php echo $attributes ?>><?php 1389 $categories = get_the_category(); 1390 if ( !empty( $categories ) ) { 1391 $out = array(); 1392 foreach ( $categories as $c ) 1393 $out[] = "<a href='edit.php?post_type={$post->post_type}&category_name={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>"; 1394 echo join( ', ', $out ); 1395 } else { 1396 _e('Uncategorized'); 1397 } 1398 ?></td> 1399 <?php 1400 break; 1401 1402 case 'tags': 1403 ?> 1404 <td <?php echo $attributes ?>><?php 1405 $tags = get_the_tags($post->ID); 1406 if ( !empty( $tags ) ) { 1407 $out = array(); 1408 foreach ( $tags as $c ) 1409 $out[] = "<a href='edit.php?post_type={$post->post_type}&tag={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>"; 1410 echo join( ', ', $out ); 1411 } else { 1412 _e('No Tags'); 1413 } 1414 ?></td> 1415 <?php 1416 break; 1417 1418 case 'comments': 1419 ?> 1420 <td <?php echo $attributes ?>><div class="post-com-count-wrapper"> 1421 <?php 1422 $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) ); 1423 if ( $pending_comments ) 1424 echo '<strong>'; 1425 comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>'); 1426 if ( $pending_comments ) 1427 echo '</strong>'; 1428 ?> 1429 </div></td> 1430 <?php 1431 break; 1432 1433 case 'author': 1434 ?> 1435 <td <?php echo $attributes ?>><a href="edit.php?post_type=<?php echo $post->post_type; ?>&author=<?php the_author_meta('ID'); ?>"><?php the_author() ?></a></td> 1436 <?php 1437 break; 1438 1439 case 'control_view': 1440 ?> 1441 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td> 1442 <?php 1443 break; 1444 1445 case 'control_edit': 1446 ?> 1447 <td><?php if ( current_user_can($post_type_object->cap->edit_post, $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td> 1448 <?php 1449 break; 1450 1451 case 'control_delete': 1452 ?> 1453 <td><?php if ( current_user_can($post_type_object->cap->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> 1454 <?php 1455 break; 1456 1457 default: 1458 ?> 1459 <td <?php echo $attributes ?>><?php do_action('manage_posts_custom_column', $column_name, $post->ID); ?></td> 1460 <?php 1461 break; 1462 } 1463 } 1464 ?> 1465 </tr> 1466 <?php 1467 $post = $global_post; 1468 } 1469 1470 /* 1471 * display one row if the page doesn't have any children 1472 * otherwise, display the row and its children in subsequent rows 1473 */ 1474 /** 1475 * {@internal Missing Short Description}} 1476 * 1477 * @since unknown 1478 * 1479 * @param unknown_type $page 1480 * @param unknown_type $level 1481 */ 1482 function display_page_row( $page, $level = 0 ) { 1483 global $post, $current_screen; 1484 static $rowclass; 1485 1486 $post = $page; 1487 setup_postdata($page); 1488 1489 if ( 0 == $level && (int)$page->post_parent > 0 ) { 1490 //sent level 0 by accident, by default, or because we don't know the actual level 1491 $find_main_page = (int)$page->post_parent; 1492 while ( $find_main_page > 0 ) { 1493 $parent = get_page($find_main_page); 1494 1495 if ( is_null($parent) ) 1496 break; 1497 1498 $level++; 1499 $find_main_page = (int)$parent->post_parent; 1500 1501 if ( !isset($parent_name) ) 1502 $parent_name = $parent->post_title; 1503 } 1504 } 1505 1506 $page->post_title = esc_html( $page->post_title ); 1507 $pad = str_repeat( '— ', $level ); 1508 $id = (int) $page->ID; 1509 $rowclass = 'alternate' == $rowclass ? '' : 'alternate'; 1510 $posts_columns = get_column_headers( $current_screen ); 1511 $hidden = get_hidden_columns( $current_screen ); 1512 $title = _draft_or_post_title(); 1513 $post_type = $page->post_type; 1514 $post_type_object = get_post_type_object($post_type); 1515 ?> 1516 <tr id="page-<?php echo $id; ?>" class="<?php echo $rowclass; ?> iedit"> 1517 <?php 1518 1519 foreach ( $posts_columns as $column_name => $column_display_name ) { 1520 $class = "class=\"$column_name column-$column_name\""; 1521 1522 $style = ''; 1523 if ( in_array($column_name, $hidden) ) 1524 $style = ' style="display:none;"'; 1525 1526 $attributes = "$class$style"; 1527 1528 switch ($column_name) { 1529 1530 case 'cb': 1531 ?> 1532 <th scope="row" class="check-column"><?php if ( current_user_can( $post_type_object->cap->edit_post, $page->ID ) ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th> 1533 <?php 1534 break; 1535 case 'date': 1536 if ( '0000-00-00 00:00:00' == $page->post_date && 'date' == $column_name ) { 1537 $t_time = $h_time = __('Unpublished'); 1538 $time_diff = 0; 1539 } else { 1540 $t_time = get_the_time(__('Y/m/d g:i:s A')); 1541 $m_time = $page->post_date; 1542 $time = get_post_time('G', true); 1543 1544 $time_diff = time() - $time; 1545 1546 if ( $time_diff > 0 && $time_diff < 24*60*60 ) 1547 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); 1548 else 1549 $h_time = mysql2date(__('Y/m/d'), $m_time); 1550 } 1551 echo '<td ' . $attributes . '>'; 1552 echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $page, $column_name, '') . '</abbr>'; 1553 echo '<br />'; 1554 if ( 'publish' == $page->post_status ) { 1555 _e('Published'); 1556 } elseif ( 'future' == $page->post_status ) { 1557 if ( $time_diff > 0 ) 1558 echo '<strong class="attention">' . __('Missed schedule') . '</strong>'; 1559 else 1560 _e('Scheduled'); 1561 } else { 1562 _e('Last Modified'); 1563 } 1564 echo '</td>'; 1565 break; 1566 case 'title': 1567 $attributes = 'class="post-title page-title column-title"' . $style; 1568 $edit_link = get_edit_post_link( $page->ID ); 1569 ?> 1570 <td <?php echo $attributes ?>><strong><?php if ( current_user_can($post_type_object->cap->edit_post, $page->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states($page); echo isset($parent_name) ? ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html($parent_name) : ''; ?></strong> 1571 <?php 1572 $actions = array(); 1573 if ( current_user_can($post_type_object->cap->edit_post, $page->ID) && $post->post_status != 'trash' ) { 1574 $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr(__('Edit this page')) . '">' . __('Edit') . '</a>'; 1575 $actions['inline'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>'; 1576 } 1577 if ( current_user_can($post_type_object->cap->delete_post, $page->ID) ) { 1578 if ( $post->post_status == 'trash' ) 1579 $actions['untrash'] = "<a title='" . esc_attr(__('Remove this page from the Trash')) . "' href='" . wp_nonce_url("post.php?post_type=$post_type&action=untrash&post=$page->ID", 'untrash-' . $post->post_type . '_' . $page->ID) . "'>" . __('Restore') . "</a>"; 1580 elseif ( EMPTY_TRASH_DAYS ) 1581 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this page to the Trash')) . "' href='" . get_delete_post_link($page->ID) . "'>" . __('Trash') . "</a>"; 1582 if ( $post->post_status == 'trash' || !EMPTY_TRASH_DAYS ) 1583 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this page permanently')) . "' href='" . wp_nonce_url("post.php?post_type=$post_type&action=delete&post=$page->ID", 'delete-' . $post->post_type . '_' . $page->ID) . "'>" . __('Delete Permanently') . "</a>"; 1584 } 1585 if ( in_array($post->post_status, array('pending', 'draft')) ) { 1586 if ( current_user_can($post_type_object->cap->edit_post, $page->ID) ) 1587 $actions['view'] = '<a href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink($page->ID) ) ) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>'; 1588 } elseif ( $post->post_status != 'trash' ) { 1589 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 1590 } 1591 $actions = apply_filters('page_row_actions', $actions, $page); 1592 $action_count = count($actions); 1593 1594 $i = 0; 1595 echo '<div class="row-actions">'; 1596 foreach ( $actions as $action => $link ) { 1597 ++$i; 1598 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; 1599 echo "<span class='$action'>$link$sep</span>"; 1600 } 1601 echo '</div>'; 1602 1603 get_inline_data($post); 1604 echo '</td>'; 1605 break; 1606 1607 case 'comments': 1608 ?> 1609 <td <?php echo $attributes ?>><div class="post-com-count-wrapper"> 1610 <?php 1611 $left = get_pending_comments_num( $page->ID ); 1612 $pending_phrase = sprintf( __('%s pending'), number_format( $left ) ); 1613 if ( $left ) 1614 echo '<strong>'; 1615 comments_number("<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>'); 1616 if ( $left ) 1617 echo '</strong>'; 1618 ?> 1619 </div></td> 1620 <?php 1621 break; 1622 1623 case 'author': 1624 ?> 1625 <td <?php echo $attributes ?>><a href="edit.php?post_type=<?php echo $post_type; ?>&author=<?php the_author_meta('ID'); ?>"><?php the_author() ?></a></td> 1626 <?php 1627 break; 1628 1629 default: 1630 ?> 1631 <td <?php echo $attributes ?>><?php do_action('manage_pages_custom_column', $column_name, $id); ?></td> 1632 <?php 1633 break; 1634 } 1635 } 1636 ?> 1637 1638 </tr> 1639 1640 <?php 1641 } 1642 1643 /* 1644 * displays pages in hierarchical order with paging support 1645 */ 1646 /** 1647 * {@internal Missing Short Description}} 1648 * 1649 * @since unknown 1650 * 1651 * @param unknown_type $pages 1652 * @param unknown_type $pagenum 1653 * @param unknown_type $per_page 1654 * @return unknown 1655 */ 1656 function page_rows($pages, $pagenum = 1, $per_page = 20) { 1657 global $wpdb; 1658 1659 $level = 0; 1660 1661 if ( ! $pages ) { 1662 $pages = get_pages( array('sort_column' => 'menu_order') ); 1663 1664 if ( ! $pages ) 1665 return false; 1666 } 1667 1668 /* 1669 * arrange pages into two parts: top level pages and children_pages 1670 * children_pages is two dimensional array, eg. 1671 * children_pages[10][] contains all sub-pages whose parent is 10. 1672 * It only takes O(N) to arrange this and it takes O(1) for subsequent lookup operations 1673 * If searching, ignore hierarchy and treat everything as top level 1674 */ 1675 if ( empty($_GET['s']) ) { 1676 1677 $top_level_pages = array(); 1678 $children_pages = array(); 1679 1680 foreach ( $pages as $page ) { 1681 1682 // catch and repair bad pages 1683 if ( $page->post_parent == $page->ID ) { 1684 $page->post_parent = 0; 1685 $wpdb->update($wpdb->posts, array('post_parent' => 0), array('ID' => $page->ID)); 1686 clean_page_cache( $page->ID ); 1687 } 1688 1689 if ( 0 == $page->post_parent ) 1690 $top_level_pages[] = $page; 1691 else 1692 $children_pages[ $page->post_parent ][] = $page; 1693 } 1694 1695 $pages = &$top_level_pages; 1696 } 1697 1698 $count = 0; 1699 $start = ($pagenum - 1) * $per_page; 1700 $end = $start + $per_page; 1701 1702 foreach ( $pages as $page ) { 1703 if ( $count >= $end ) 1704 break; 1705 1706 if ( $count >= $start ) 1707 echo "\t" . display_page_row( $page, $level ); 1708 1709 $count++; 1710 1711 if ( isset($children_pages) ) 1712 _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page ); 1713 } 1714 1715 // if it is the last pagenum and there are orphaned pages, display them with paging as well 1716 if ( isset($children_pages) && $count < $end ){ 1717 foreach( $children_pages as $orphans ){ 1718 foreach ( $orphans as $op ) { 1719 if ( $count >= $end ) 1720 break; 1721 if ( $count >= $start ) 1722 echo "\t" . display_page_row( $op, 0 ); 1723 $count++; 1724 } 1725 } 1726 } 1727 } 1728 1729 /** 1730 * Given a top level page ID, display the nested hierarchy of sub-pages 1731 * together with paging support 1732 * 1733 * @since unknown 1734 * 1735 * @param unknown_type $children_pages 1736 * @param unknown_type $count 1737 * @param unknown_type $parent 1738 * @param unknown_type $level 1739 * @param unknown_type $pagenum 1740 * @param unknown_type $per_page 1741 */ 1742 function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) { 1743 1744 if ( ! isset( $children_pages[$parent] ) ) 1745 return; 1746 1747 $start = ($pagenum - 1) * $per_page; 1748 $end = $start + $per_page; 1749 1750 foreach ( $children_pages[$parent] as $page ) { 1751 1752 if ( $count >= $end ) 1753 break; 1754 1755 // If the page starts in a subtree, print the parents. 1756 if ( $count == $start && $page->post_parent > 0 ) { 1757 $my_parents = array(); 1758 $my_parent = $page->post_parent; 1759 while ( $my_parent) { 1760 $my_parent = get_post($my_parent); 1761 $my_parents[] = $my_parent; 1762 if ( !$my_parent->post_parent ) 1763 break; 1764 $my_parent = $my_parent->post_parent; 1765 } 1766 $num_parents = count($my_parents); 1767 while( $my_parent = array_pop($my_parents) ) { 1768 echo "\t" . display_page_row( $my_parent, $level - $num_parents ); 1769 $num_parents--; 1770 } 1771 } 1772 1773 if ( $count >= $start ) 1774 echo "\t" . display_page_row( $page, $level ); 1775 1776 $count++; 1777 1778 _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page ); 1779 } 1780 1781 unset( $children_pages[$parent] ); //required in order to keep track of orphans 1782 } 1783 1784 /** 1785 * Generate HTML for a single row on the users.php admin panel. 1786 * 1787 * @since 2.1.0 1788 * 1789 * @param object $user_object 1790 * @param string $style Optional. Attributes added to the TR element. Must be sanitized. 1791 * @param string $role Key for the $wp_roles array. 1792 * @param int $numposts Optional. Post count to display for this user. Defaults to zero, as in, a new user has made zero posts. 1793 * @return string 1794 */ 1795 function user_row( $user_object, $style = '', $role = '', $numposts = 0 ) { 1796 global $wp_roles; 1797 1798 if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) ) 1799 $user_object = new WP_User( (int) $user_object ); 1800 $user_object = sanitize_user_object($user_object, 'display'); 1801 $email = $user_object->user_email; 1802 $url = $user_object->user_url; 1803 $short_url = str_replace( 'http://', '', $url ); 1804 $short_url = str_replace( 'www.', '', $short_url ); 1805 if ('/' == substr( $short_url, -1 )) 1806 $short_url = substr( $short_url, 0, -1 ); 1807 if ( strlen( $short_url ) > 35 ) 1808 $short_url = substr( $short_url, 0, 32 ).'...'; 1809 $checkbox = ''; 1810 // Check if the user for this row is editable 1811 if ( current_user_can( 'list_users' ) ) { 1812 // Set up the user editing link 1813 // TODO: make profile/user-edit determination a separate function 1814 if ( get_current_user_id() == $user_object->ID) { 1815 $edit_link = 'profile.php'; 1816 } else { 1817 $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" ) ); 1818 } 1819 $edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />"; 1820 1821 // Set up the hover actions for this user 1822 $actions = array(); 1823 1824 if ( current_user_can('edit_user', $user_object->ID) ) { 1825 $edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />"; 1826 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; 1827 } else { 1828 $edit = "<strong>$user_object->user_login</strong><br />"; 1829 } 1830 1831 if ( !is_multisite() && get_current_user_id() != $user_object->ID && current_user_can('delete_user', $user_object->ID) ) 1832 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=delete&user=$user_object->ID", 'bulk-users') . "'>" . __('Delete') . "</a>"; 1833 if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can('remove_user', $user_object->ID) ) 1834 $actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=remove&user=$user_object->ID", 'bulk-users') . "'>" . __('Remove') . "</a>"; 1835 $actions = apply_filters('user_row_actions', $actions, $user_object); 1836 $action_count = count($actions); 1837 $i = 0; 1838 $edit .= '<div class="row-actions">'; 1839 foreach ( $actions as $action => $link ) { 1840 ++$i; 1841 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; 1842 $edit .= "<span class='$action'>$link$sep</span>"; 1843 } 1844 $edit .= '</div>'; 1845 1846 // Set up the checkbox (because the user is editable, otherwise its empty) 1847 $checkbox = "<input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' />"; 1848 1849 } else { 1850 $edit = '<strong>' . $user_object->user_login . '</strong>'; 1851 } 1852 $role_name = isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role] ) : __('None'); 1853 $r = "<tr id='user-$user_object->ID'$style>"; 1854 $columns = get_column_headers('users'); 1855 $hidden = get_hidden_columns('users'); 1856 $avatar = get_avatar( $user_object->ID, 32 ); 1857 foreach ( $columns as $column_name => $column_display_name ) { 1858 $class = "class=\"$column_name column-$column_name\""; 1859 1860 $style = ''; 1861 if ( in_array($column_name, $hidden) ) 1862 $style = ' style="display:none;"'; 1863 1864 $attributes = "$class$style"; 1865 1866 switch ($column_name) { 1867 case 'cb': 1868 $r .= "<th scope='row' class='check-column'>$checkbox</th>"; 1869 break; 1870 case 'username': 1871 $r .= "<td $attributes>$avatar $edit</td>"; 1872 break; 1873 case 'name': 1874 $r .= "<td $attributes>$user_object->first_name $user_object->last_name</td>"; 1875 break; 1876 case 'email': 1877 $r .= "<td $attributes><a href='mailto:$email' title='" . sprintf( __('E-mail: %s' ), $email ) . "'>$email</a></td>"; 1878 break; 1879 case 'role': 1880 $r .= "<td $attributes>$role_name</td>"; 1881 break; 1882 case 'posts': 1883 $attributes = 'class="posts column-posts num"' . $style; 1884 $r .= "<td $attributes>"; 1885 if ( $numposts > 0 ) { 1886 $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>"; 1887 $r .= $numposts; 1888 $r .= '</a>'; 1889 } else { 1890 $r .= 0; 1891 } 1892 $r .= "</td>"; 1893 break; 1894 default: 1895 $r .= "<td $attributes>"; 1896 $r .= apply_filters('manage_users_custom_column', '', $column_name, $user_object->ID); 1897 $r .= "</td>"; 1898 } 1899 } 1900 $r .= '</tr>'; 1901 1902 return $r; 1903 } 1904 1905 /** 1906 * {@internal Missing Short Description}} 1907 * 1908 * @since unknown 1909 * 1910 * @param string $status Comment status (approved, spam, trash, etc) 1911 * @param string $s Term to search for 1912 * @param int $start Offset to start at for pagination 1913 * @param int $num Maximum number of comments to return 1914 * @param int $post Post ID or 0 to return all comments 1915 * @param string $type Comment type (comment, trackback, pingback, etc) 1916 * @return array [0] contains the comments and [1] contains the total number of comments that match (ignoring $start and $num) 1917 */ 1918 function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0, $type = '' ) { 1919 global $wpdb; 1920 1921 $start = abs( (int) $start ); 1922 $num = (int) $num; 1923 $post = (int) $post; 1924 $count = wp_count_comments(); 1925 $index = ''; 1926 1927 if ( 'moderated' == $status ) { 1928 $approved = "c.comment_approved = '0'"; 1929 $total = $count->moderated; 1930 } elseif ( 'approved' == $status ) { 1931 $approved = "c.comment_approved = '1'"; 1932 $total = $count->approved; 1933 } elseif ( 'spam' == $status ) { 1934 $approved = "c.comment_approved = 'spam'"; 1935 $total = $count->spam; 1936 } elseif ( 'trash' == $status ) { 1937 $approved = "c.comment_approved = 'trash'"; 1938 $total = $count->trash; 1939 } else { 1940 $approved = "( c.comment_approved = '0' OR c.comment_approved = '1' )"; 1941 $total = $count->moderated + $count->approved; 1942 $index = 'USE INDEX (c.comment_date_gmt)'; 1943 } 1944 1945 if ( $post ) { 1946 $total = ''; 1947 $post = " AND c.comment_post_ID = '$post'"; 1948 } else { 1949 $post = ''; 1950 } 1951 1952 $orderby = "ORDER BY c.comment_date_gmt DESC LIMIT $start, $num"; 1953 1954 if ( 'comment' == $type ) 1955 $typesql = "AND c.comment_type = ''"; 1956 elseif ( 'pings' == $type ) 1957 $typesql = "AND ( c.comment_type = 'pingback' OR c.comment_type = 'trackback' )"; 1958 elseif ( 'all' == $type ) 1959 $typesql = ''; 1960 elseif ( !empty($type) ) 1961 $typesql = $wpdb->prepare("AND c.comment_type = %s", $type); 1962 else 1963 $typesql = ''; 1964 1965 if ( !empty($type) ) 1966 $total = ''; 1967 1968 $query = "FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' "; 1969 if ( $s ) { 1970 $total = ''; 1971 $s = $wpdb->escape($s); 1972 $query .= "AND 1973 (c.comment_author LIKE '%$s%' OR 1974 c.comment_author_email LIKE '%$s%' OR 1975 c.comment_author_url LIKE ('%$s%') OR 1976 c.comment_author_IP LIKE ('%$s%') OR 1977 c.comment_content LIKE ('%$s%') ) AND 1978 $approved 1979 $typesql"; 1980 } else { 1981 $query .= "AND $approved $post $typesql"; 1982 } 1983 1984 $comments = $wpdb->get_results("SELECT * $query $orderby"); 1985 if ( '' === $total ) 1986 $total = $wpdb->get_var("SELECT COUNT(c.comment_ID) $query"); 1987 1988 update_comment_cache($comments); 1989 1990 return array($comments, $total); 1991 } 1992 1993 /** 1994 * {@internal Missing Short Description}} 1995 * 1996 * @since unknown 1997 * 1998 * @param unknown_type $comment_id 1999 * @param unknown_type $mode 2000 * @param unknown_type $comment_status 2001 * @param unknown_type $checkbox 2002 */ 2003 function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) { 2004 global $comment, $post, $_comment_pending_count; 2005 $comment = get_comment( $comment_id ); 2006 $post = get_post($comment->comment_post_ID); 2007 $the_comment_status = wp_get_comment_status($comment->comment_ID); 2008 $post_type_object = get_post_type_object($post->post_type); 2009 $user_can = current_user_can($post_type_object->cap->edit_post, $post->ID); 2010 2011 $comment_url = esc_url(get_comment_link($comment->comment_ID)); 2012 $author_url = get_comment_author_url(); 2013 if ( 'http://' == $author_url ) 2014 $author_url = ''; 2015 $author_url_display = preg_replace('|http://(www\.)?|i', '', $author_url); 2016 if ( strlen($author_url_display) > 50 ) 2017 $author_url_display = substr($author_url_display, 0, 49) . '...'; 2018 2019 $ptime = date('G', strtotime( $comment->comment_date ) ); 2020 if ( ( abs(time() - $ptime) ) < 86400 ) 2021 $ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) ); 2022 else 2023 $ptime = mysql2date(__('Y/m/d \a\t g:i A'), $comment->comment_date ); 2024 2025 if ( $user_can ) { 2026 $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) ); 2027 $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) ); 2028 2029 $approve_url = esc_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" ); 2030 $unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" ); 2031 $spam_url = esc_url( "comment.php?action=spamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" ); 2032 $unspam_url = esc_url( "comment.php?action=unspamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" ); 2033 $trash_url = esc_url( "comment.php?action=trashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" ); 2034 $untrash_url = esc_url( "comment.php?action=untrashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" ); 2035 $delete_url = esc_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" ); 2036 } 2037 2038 echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>"; 2039 $columns = get_column_headers('edit-comments'); 2040 $hidden = get_hidden_columns('edit-comments'); 2041 foreach ( $columns as $column_name => $column_display_name ) { 2042 $class = "class=\"$column_name column-$column_name\""; 2043 2044 $style = ''; 2045 if ( in_array($column_name, $hidden) ) 2046 $style = ' style="display:none;"'; 2047 2048 $attributes = "$class$style"; 2049 2050 switch ($column_name) { 2051 case 'cb': 2052 if ( !$checkbox ) break; 2053 echo '<th scope="row" class="check-column">'; 2054 if ( $user_can ) echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />"; 2055 echo '</th>'; 2056 break; 2057 case 'comment': 2058 echo "<td $attributes>"; 2059 echo '<div id="submitted-on">'; 2060 /* translators: 2: comment date, 3: comment time */ 2061 printf( __( '<a href="%1$s">%2$s at %3$s</a>' ), $comment_url, 2062 /* translators: comment date format. See http://php.net/date */ get_comment_date( __('Y/m/d') ), 2063 /* translators: comment time format. See http://php.net/date */ get_comment_date( get_option( 'time_format' ) ) ); 2064 2065 if ( $comment->comment_parent ) { 2066 $parent = get_comment( $comment->comment_parent ); 2067 $parent_link = esc_url( get_comment_link( $comment->comment_parent ) ); 2068 $name = apply_filters( 'get_comment_author', $parent->comment_author ); // there's no API function for this 2069 printf( ' | '.__( 'In reply to <a href="%1$s">%2$s</a>.' ), $parent_link, $name ); 2070 } 2071 2072 echo '</div>'; 2073 comment_text(); 2074 if ( $user_can ) { ?> 2075 <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden"> 2076 <textarea class="comment" rows="1" cols="1"><?php echo htmlspecialchars( apply_filters('comment_edit_pre', $comment->comment_content), ENT_QUOTES ); ?></textarea> 2077 <div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div> 2078 <div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div> 2079 <div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div> 2080 <div class="comment_status"><?php echo $comment->comment_approved; ?></div> 2081 </div> 2082 <?php 2083 } 2084 2085 if ( $user_can ) { 2086 // preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash 2087 $actions = array( 2088 'approve' => '', 'unapprove' => '', 2089 'reply' => '', 2090 'quickedit' => '', 2091 'edit' => '', 2092 'spam' => '', 'unspam' => '', 2093 'trash' => '', 'untrash' => '', 'delete' => '' 2094 ); 2095 2096 if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments 2097 if ( 'approved' == $the_comment_status ) 2098 $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='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; 2099 else if ( 'unapproved' == $the_comment_status ) 2100 $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='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; 2101 } else { 2102 $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; 2103 $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; 2104 } 2105 2106 if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) { 2107 $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>'; 2108 } elseif ( 'spam' == $the_comment_status ) { 2109 $actions['unspam'] = "<a href='$unspam_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1 vim-z vim-destructive'>" . _x( 'Not Spam', 'comment' ) . '</a>'; 2110 } elseif ( 'trash' == $the_comment_status ) { 2111 $actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1 vim-z vim-destructive'>" . __( 'Restore' ) . '</a>'; 2112 } 2113 2114 if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) { 2115 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::delete=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>'; 2116 } else { 2117 $actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x('Trash', 'verb') . '</a>'; 2118 } 2119 2120 if ( 'trash' != $the_comment_status ) { 2121 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . esc_attr__('Edit comment') . "'>". __('Edit') . '</a>'; 2122 $actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\');return false;" class="vim-q" title="'.esc_attr__('Quick Edit').'" href="#">' . __('Quick Edit') . '</a>'; 2123 if ( 'spam' != $the_comment_status ) 2124 $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\');return false;" class="vim-r" title="'.esc_attr__('Reply to this comment').'" href="#">' . __('Reply') . '</a>'; 2125 } 2126 2127 $actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment ); 2128 2129 $i = 0; 2130 echo '<div class="row-actions">'; 2131 foreach ( $actions as $action => $link ) { 2132 ++$i; 2133 ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; 2134 2135 // Reply and quickedit need a hide-if-no-js span when not added with ajax 2136 if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax ) 2137 $action .= ' hide-if-no-js'; 2138 elseif ( ($action == 'untrash' && $the_comment_status == 'trash') || ($action == 'unspam' && $the_comment_status == 'spam') ) { 2139 if ('1' == get_comment_meta($comment_id, '_wp_trash_meta_status', true)) 2140 $action .= ' approve'; 2141 else 2142 $action .= ' unapprove'; 2143 } 2144 2145 echo "<span class='$action'>$sep$link</span>"; 2146 } 2147 echo '</div>'; 2148 } 2149 2150 echo '</td>'; 2151 break; 2152 case 'author': 2153 echo "<td $attributes><strong>"; comment_author(); echo '</strong><br />'; 2154 if ( !empty($author_url) ) 2155 echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />"; 2156 if ( $user_can ) { 2157 if ( !empty($comment->comment_author_email) ) { 2158 comment_author_email_link(); 2159 echo '<br />'; 2160 } 2161 echo '<a href="edit-comments.php?s='; 2162 comment_author_IP(); 2163 echo '&mode=detail'; 2164 if ( 'spam' == $comment_status ) 2165 echo '&comment_status=spam'; 2166 echo '">'; 2167 comment_author_IP(); 2168 echo '</a>'; 2169 } //current_user_can 2170 echo '</td>'; 2171 break; 2172 case 'date': 2173 echo "<td $attributes>" . get_comment_date(__('Y/m/d \a\t g:ia')) . '</td>'; 2174 break; 2175 case 'response': 2176 if ( 'single' !== $mode ) { 2177 if ( isset( $_comment_pending_count[$post->ID] ) ) { 2178 $pending_comments = $_comment_pending_count[$post->ID]; 2179 } else { 2180 $_comment_pending_count_temp = get_pending_comments_num( array( $post->ID ) ); 2181 $pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID]; 2182 } 2183 if ( $user_can ) { 2184 $post_link = "<a href='" . get_edit_post_link($post->ID) . "'>"; 2185 $post_link .= get_the_title($post->ID) . '</a>'; 2186 } else { 2187 $post_link = get_the_title($post->ID); 2188 } 2189 echo "<td $attributes>\n"; 2190 echo '<div class="response-links"><span class="post-com-count-wrapper">'; 2191 echo $post_link . '<br />'; 2192 $pending_phrase = esc_attr(sprintf( __('%s pending'), number_format( $pending_comments ) )); 2193 if ( $pending_comments ) 2194 echo '<strong>'; 2195 comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>'); 2196 if ( $pending_comments ) 2197 echo '</strong>'; 2198 echo '</span> '; 2199 echo "<a href='" . get_permalink( $post->ID ) . "'>#</a>"; 2200 echo '</div>'; 2201 if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) ) 2202 echo $thumb; 2203 echo '</td>'; 2204 } 2205 break; 2206 default: 2207 echo "<td $attributes>\n"; 2208 do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID ); 2209 echo "</td>\n"; 2210 break; 2211 } 2212 } 2213 echo "</tr>\n"; 2214 } 2215 2216 /** 2217 * {@internal Missing Short Description}} 2218 * 2219 * @since unknown 319 * @since 2.7.0 2220 320 * 2221 321 * @param unknown_type $position … … 2232 332 } 2233 333 2234 $columns = get_column_headers('edit-comments'); 2235 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns('edit-comments') ) ); 2236 $col_count = count($columns) - count($hidden); 334 if ( $mode == 'single' ) { 335 $wp_list_table = _get_list_table('WP_Post_Comments_List_Table'); 336 } else { 337 $wp_list_table = _get_list_table('WP_Comments_List_Table'); 338 } 2237 339 2238 340 ?> 2239 341 <form method="get" action=""> 2240 342 <?php if ( $table_row ) : ?> 2241 <table style="display:none;"><tbody id="com-reply"><tr id="replyrow" style="display:none;"><td colspan="<?php echo $ col_count; ?>">343 <table style="display:none;"><tbody id="com-reply"><tr id="replyrow" style="display:none;"><td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="colspanchange"> 2242 344 <?php else : ?> 2243 345 <div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;"> … … 2313 415 * {@internal Missing Short Description}} 2314 416 * 2315 * @since unknown417 * @since 1.2.0 2316 418 * 2317 419 * @param unknown_type $meta … … 2356 458 * {@internal Missing Short Description}} 2357 459 * 2358 * @since unknown460 * @since 2.5.0 2359 461 * 2360 462 * @param unknown_type $entry … … 2388 490 2389 491 $entry['meta_key'] = esc_attr($entry['meta_key']); 2390 $entry['meta_value'] = htmlspecialchars($entry['meta_value']); // using a <textarea />492 $entry['meta_value'] = esc_textarea( $entry['meta_value'] ); // using a <textarea /> 2391 493 $entry['meta_id'] = (int) $entry['meta_id']; 2392 494 … … 2396 498 $r .= "\n\t\t<td class='left'><label class='screen-reader-text' 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']}' />"; 2397 499 2398 $r .= "\n\t\t<div class='submit'><input name='deletemeta[{$entry['meta_id']}]' type='submit' "; 2399 $r .= "class='delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta' tabindex='6' value='". esc_attr__( 'Delete' ) ."' />"; 2400 $r .= "\n\t\t<input name='updatemeta' type='submit' tabindex='6' value='". esc_attr__( 'Update' ) ."' class='add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce updatemeta' /></div>"; 500 $r .= "\n\t\t<div class='submit'>"; 501 $r .= get_submit_button( __( 'Delete' ), "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta", "deletemeta[{$entry['meta_id']}]", false, array( 'tabindex' => '6' ) ); 502 $r .= "\n\t\t"; 503 $r .= get_submit_button( __( 'Update' ), "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce updatemeta" , 'updatemeta', false, array( 'tabindex' => '6' ) ); 504 $r .= "</div>"; 2401 505 $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false ); 2402 506 $r .= "</td>"; … … 2409 513 * {@internal Missing Short Description}} 2410 514 * 2411 * @since unknown515 * @since 1.2.0 2412 516 */ 2413 517 function meta_form() { … … 2458 562 2459 563 <tr><td colspan="2" class="submit"> 2460 < input type="submit" id="addmetasub" name="addmeta" class="add:the-list:newmeta" tabindex="9" value="<?php esc_attr_e( 'Add Custom Field' ) ?>" />564 <?php submit_button( __( 'Add Custom Field' ), 'add:the-list:newmeta', 'addmeta', false, array( 'id' => 'addmetasub', 'tabindex' => '9' ) ); ?> 2461 565 <?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?> 2462 566 </td></tr> … … 2470 574 * {@internal Missing Short Description}} 2471 575 * 2472 * @since unknown576 * @since 0.71 2473 577 * 2474 578 * @param unknown_type $edit … … 2544 648 * {@internal Missing Short Description}} 2545 649 * 2546 * @since unknown650 * @since 1.5.0 2547 651 * 2548 652 * @param unknown_type $default … … 2563 667 * {@internal Missing Short Description}} 2564 668 * 2565 * @since unknown669 * @since 1.5.0 2566 670 * 2567 671 * @param unknown_type $default … … 2599 703 * {@internal Missing Short Description}} 2600 704 * 2601 * @since unknown705 * @since 2.0.0 2602 706 * 2603 707 * @param unknown_type $id … … 2621 725 <tr> 2622 726 <th scope="row"><?php _e( 'URL' ) ?></th> 2623 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo wp_get_attachment_url(); ?></textarea></td>727 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo esc_textarea( wp_get_attachment_url() ); ?></textarea></td> 2624 728 </tr> 2625 729 <?php if ( $icon ) : ?> … … 2649 753 2650 754 /** 2651 * Print out <option> html elements for role selectors based on $wp_roles 2652 * 2653 * @package WordPress 2654 * @subpackage Administration 2655 * @since 2.1 2656 * 2657 * @uses $wp_roles 2658 * @param string $default slug for the role that should be already selected 755 * Print out <option> html elements for role selectors 756 * 757 * @since 2.1.0 758 * 759 * @param string $selected slug for the role that should be already selected 2659 760 */ 2660 761 function wp_dropdown_roles( $selected = false ) { … … 2666 767 foreach ( $editable_roles as $role => $details ) { 2667 768 $name = translate_user_role($details['name'] ); 2668 if ( $selected == $role ) // Make default first in list769 if ( $selected == $role ) // preselect specified role 2669 770 $p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>"; 2670 771 else … … 2677 778 * {@internal Missing Short Description}} 2678 779 * 2679 * @since unknown780 * @since 2.3.0 2680 781 * 2681 782 * @param unknown_type $size … … 2697 798 * {@internal Missing Short Description}} 2698 799 * 2699 * @since unknown800 * @since 2.3.0 2700 801 * 2701 802 * @param unknown_type $bytes … … 2713 814 * {@internal Missing Short Description}} 2714 815 * 2715 * @since unknown816 * @since 2.5.0 2716 817 * 2717 818 * @return unknown … … 2727 828 * Outputs the form used by the importers to accept the data to be imported 2728 829 * 2729 * @since 2.0 830 * @since 2.0.0 2730 831 * 2731 832 * @param string $action The action attribute for the form. … … 2747 848 <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" /> 2748 849 </p> 2749 <p class="submit"> 2750 <input type="submit" class="button" value="<?php esc_attr_e( 'Upload file and import' ); ?>" /> 2751 </p> 850 <?php submit_button( __('Upload file and import'), 'button' ); ?> 2752 851 </form> 2753 852 <?php … … 2778 877 2779 878 foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) { 2780 foreach ( array('high', 'core', 'default', 'low') as $a_priority ) { 2781 if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) ) 2782 continue; 2783 2784 // If a core box was previously added or removed by a plugin, don't add. 2785 if ( 'core' == $priority ) { 2786 // If core box previously deleted, don't add 2787 if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] ) 879 foreach ( array('high', 'core', 'default', 'low') as $a_priority ) { 880 if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) ) 881 continue; 882 883 // If a core box was previously added or removed by a plugin, don't add. 884 if ( 'core' == $priority ) { 885 // If core box previously deleted, don't add 886 if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] ) 887 return; 888 // If box was added with default priority, give it core priority to maintain sort order 889 if ( 'default' == $a_priority ) { 890 $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id]; 891 unset($wp_meta_boxes[$page][$a_context]['default'][$id]); 892 } 2788 893 return; 2789 // If box was added with default priority, give it core priority to maintain sort order2790 if ( 'default' == $a_priority ) {2791 $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];2792 unset($wp_meta_boxes[$page][$a_context]['default'][$id]);2793 894 } 2794 return; 895 // If no priority given and id already present, use existing priority 896 if ( empty($priority) ) { 897 $priority = $a_priority; 898 // 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. 899 } elseif ( 'sorted' == $priority ) { 900 $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title']; 901 $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback']; 902 $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args']; 903 } 904 // An id can be in only one priority and one context 905 if ( $priority != $a_priority || $context != $a_context ) 906 unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]); 2795 907 } 2796 // If no priority given and id already present, use existing priority2797 if ( empty($priority) ) {2798 $priority = $a_priority;2799 // 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.2800 } elseif ( 'sorted' == $priority ) {2801 $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];2802 $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];2803 $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];2804 }2805 // An id can be in only one priority and one context2806 if ( $priority != $a_priority || $context != $a_context )2807 unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);2808 }2809 908 } 2810 909 … … 2859 958 $hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : ''; 2860 959 echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . $hidden_class . '" ' . '>' . "\n"; 2861 echo '<div class="handlediv" title="' . __('Click to toggle') . '"><br /></div>';960 echo '<div class="handlediv" title="' . esc_attr__('Click to toggle') . '"><br /></div>'; 2862 961 echo "<h3 class='hndle'><span>{$box['title']}</span></h3>\n"; 2863 962 echo '<div class="inside">' . "\n"; … … 2902 1001 * {@internal Missing Short Description}} 2903 1002 * 2904 * @since unknown1003 * @since 2.7.0 2905 1004 * 2906 1005 * @param unknown_type $screen … … 2937 1036 * Get Hidden Meta Boxes 2938 1037 * 2939 * @since 2.7 1038 * @since 2.7.0 2940 1039 * 2941 1040 * @param string|object $screen Screen identifier … … 2949 1048 2950 1049 // Hide slug boxes by default 2951 if ( !is_array( $hidden ) ) 2952 $hidden = array('slugdiv'); 1050 if ( !is_array( $hidden ) ) { 1051 if ( 'post' == $screen->base || 'page' == $screen->base ) 1052 $hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv'); 1053 else 1054 $hidden = array( 'slugdiv' ); 1055 $hidden = apply_filters('default_hidden_meta_boxes', $hidden, $screen); 1056 } 2953 1057 2954 1058 return $hidden; … … 3042 1146 * @global $wp_settings_sections Storage array of all settings sections added to admin pages 3043 1147 * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections 3044 * @since unknown1148 * @since 2.7.0 3045 1149 * 3046 1150 * @param string $page The slug name of the page whos settings sections you want to output … … 3072 1176 * @global $wp_settings_fields Storage array of settings fields and their pages/sections 3073 1177 * 3074 * @since unknown1178 * @since 2.7.0 3075 1179 * 3076 1180 * @param string $page Slug title of the admin page who's settings fields you want to show. … … 3109 1213 * page is first accessed. 3110 1214 * 1215 * @since 3.0.0 1216 * 3111 1217 * @global array $wp_settings_errors Storage array of errors registered during this pageload 3112 1218 * … … 3137 1243 * pageload and returns them. 3138 1244 * 3139 * If changes were just submitted ($_GET[' updated']) and settings errors were saved1245 * If changes were just submitted ($_GET['settings-updated']) and settings errors were saved 3140 1246 * to the 'settings_errors' transient then those errors will be returned instead. This 3141 1247 * is used to pass errors back across pageloads. … … 3144 1250 * This is useful if you have errors or notices you want to show even when the user 3145 1251 * hasn't submitted data (i.e. when they first load an options page, or in admin_notices action hook) 1252 * 1253 * @since 3.0.0 3146 1254 * 3147 1255 * @global array $wp_settings_errors Storage array of errors registered during this pageload … … 3162 1270 // If settings were passed back from options.php then use them 3163 1271 // Ignore transients if $sanitize is true, we dont' want the old values anyway 3164 if ( isset($_GET[' updated']) && $_GET['updated'] && get_transient('settings_errors') ) {1272 if ( isset($_GET['settings-updated']) && $_GET['settings-updated'] && get_transient('settings_errors') ) { 3165 1273 $settings_errors = get_transient('settings_errors'); 3166 1274 delete_transient('settings_errors'); … … 3197 1305 * settings when the user arrives at the settings page. 3198 1306 * 1307 * @since 3.0.0 1308 * 3199 1309 * @param string $setting Optional slug title of a specific setting who's errors you want. 3200 1310 * @param boolean $sanitize Whether to re-sanitize the setting value before returning errors. 3201 1311 * @param boolean $hide_on_update If set to true errors will not be shown if the settings page has already been submitted. 3202 * @return <type> 3203 */ 3204 function settings_errors ( $setting = '', $sanitize = FALSE, $hide_on_update = FALSE ) { 3205 3206 if ($hide_on_update AND $_GET['updated']) return; 1312 */ 1313 function settings_errors( $setting = '', $sanitize = FALSE, $hide_on_update = FALSE ) { 1314 1315 if ($hide_on_update AND $_GET['settings-updated']) return; 3207 1316 3208 1317 $settings_errors = get_settings_errors( $setting, $sanitize ); … … 3224 1333 * {@internal Missing Short Description}} 3225 1334 * 3226 * @since unknown 3227 * 3228 * @param unknown_type $page 3229 */ 3230 function manage_columns_prefs( $page ) { 3231 $columns = get_column_headers( $page ); 3232 $hidden = get_hidden_columns( $page ); 3233 $special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username'); 3234 3235 foreach ( $columns as $column => $title ) { 3236 // Can't hide these or they are special 3237 if ( in_array( $column, $special ) ) 3238 continue; 3239 if ( empty( $title ) ) 3240 continue; 3241 3242 if ( 'comments' == $column ) 3243 $title = __( 'Comments' ); 3244 $id = "$column-hide"; 3245 echo '<label for="' . $id . '">'; 3246 echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . (! in_array($column, $hidden) ? ' checked="checked"' : '') . ' />'; 3247 echo "$title</label>\n"; 3248 } 3249 } 3250 3251 /** 3252 * {@internal Missing Short Description}} 3253 * 3254 * @since unknown 1335 * @since 2.7.0 3255 1336 * 3256 1337 * @param unknown_type $found_action … … 3270 1351 <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label> 3271 1352 <input type="text" id="find-posts-input" name="ps" value="" /> 3272 <input type="button" onclick="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br />1353 <input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br /> 3273 1354 3274 1355 <?php … … 3286 1367 </div> 3287 1368 <div class="find-box-buttons"> 3288 <input type="button" class="button alignleft" onclick="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" />3289 < input id="find-posts-submit" type="submit" class="button-primary alignright" value="<?php esc_attr_e('Select'); ?>" />1369 <input id="find-posts-close" type="button" class="button alignleft" value="<?php esc_attr_e('Close'); ?>" /> 1370 <?php submit_button( __( 'Select' ), 'button-primary alignright', 'find-posts-submit', false ); ?> 3290 1371 </div> 3291 1372 </div> … … 3310 1391 * {@internal Missing Short Description}} 3311 1392 * 3312 * @since unknown1393 * @since 2.7.0 3313 1394 */ 3314 1395 function favorite_actions( $screen = null ) { … … 3317 1398 if ( is_string($screen) ) 3318 1399 $screen = convert_to_screen($screen); 1400 1401 if ( $screen->is_user ) 1402 return; 3319 1403 3320 1404 if ( isset($screen->post_type) ) { … … 3327 1411 3328 1412 if ( !$default_action ) { 3329 switch ( $screen->id ) { 3330 case 'upload': 3331 $default_action = array('media-new.php' => array(__('New Media'), 'upload_files')); 3332 break; 3333 case 'media': 3334 $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files')); 3335 break; 3336 case 'link-manager': 3337 case 'link': 3338 if ( 'add' != $screen->action ) 3339 $default_action = array('link-add.php' => array(__('New Link'), 'manage_links')); 3340 else 3341 $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links')); 3342 break; 3343 case 'users': 3344 $default_action = array('user-new.php' => array(__('New User'), 'create_users')); 3345 break; 3346 case 'user': 3347 $default_action = array('users.php' => array(__('Edit Users'), 'edit_users')); 3348 break; 3349 case 'plugins': 3350 $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins')); 3351 break; 3352 case 'plugin-install': 3353 $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins')); 3354 break; 3355 case 'themes': 3356 $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes')); 3357 break; 3358 case 'theme-install': 3359 $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes')); 3360 break; 3361 default: 3362 $default_action = array('post-new.php' => array(__('New Post'), 'edit_posts')); 3363 break; 1413 if ( $screen->is_network ) { 1414 $default_action = array('sites.php' => array( __('Sites'), 'manage_sites')); 1415 } else { 1416 switch ( $screen->id ) { 1417 case 'upload': 1418 $default_action = array('media-new.php' => array(__('New Media'), 'upload_files')); 1419 break; 1420 case 'media': 1421 $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files')); 1422 break; 1423 case 'link-manager': 1424 case 'link': 1425 if ( 'add' != $screen->action ) 1426 $default_action = array('link-add.php' => array(__('New Link'), 'manage_links')); 1427 else 1428 $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links')); 1429 break; 1430 case 'users': 1431 $default_action = array('user-new.php' => array(__('New User'), 'create_users')); 1432 break; 1433 case 'user': 1434 $default_action = array('users.php' => array(__('Edit Users'), 'edit_users')); 1435 break; 1436 case 'plugins': 1437 $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins')); 1438 break; 1439 case 'plugin-install': 1440 $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins')); 1441 break; 1442 case 'themes': 1443 $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes')); 1444 break; 1445 case 'theme-install': 1446 $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes')); 1447 break; 1448 default: 1449 $default_action = array('post-new.php' => array(__('New Post'), 'edit_posts')); 1450 break; 1451 } 3364 1452 } 3365 1453 } 3366 1454 3367 $actions = array( 3368 'post-new.php' => array(__('New Post'), 'edit_posts'), 3369 'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'), 3370 'post-new.php?post_type=page' => array(__('New Page'), 'edit_pages'), 3371 'media-new.php' => array(__('Upload'), 'upload_files'), 3372 'edit-comments.php' => array(__('Comments'), 'moderate_comments') 1455 if ( !$screen->is_network ) { 1456 $actions = array( 1457 'post-new.php' => array(__('New Post'), 'edit_posts'), 1458 'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'), 1459 'post-new.php?post_type=page' => array(__('New Page'), 'edit_pages'), 1460 'media-new.php' => array(__('Upload'), 'upload_files'), 1461 'edit-comments.php' => array(__('Comments'), 'moderate_comments') 1462 ); 1463 } else { 1464 $actions = array( 1465 'sites.php' => array( __('Sites'), 'manage_sites'), 1466 'users.php' => array( __('Users'), 'manage_network_users') 3373 1467 ); 1468 } 3374 1469 3375 1470 $default_key = array_keys($default_action); … … 3378 1473 unset($actions[$default_key]); 3379 1474 $actions = array_merge($default_action, $actions); 3380 $actions = apply_filters( 'favorite_actions', $actions);1475 $actions = apply_filters( 'favorite_actions', $actions, $screen ); 3381 1476 3382 1477 $allowed_actions = array(); … … 3412 1507 * 3413 1508 * @since 2.7.0 3414 * @param int $ id The post id. If not supplied the global $post is used.3415 * 3416 */ 3417 function _draft_or_post_title( $post_id = 0) {1509 * @param int $post_id The post id. If not supplied the global $post is used. 1510 * @return string The post title if set 1511 */ 1512 function _draft_or_post_title( $post_id = 0 ) { 3418 1513 $title = get_the_title($post_id); 3419 1514 if ( empty($title) ) … … 3433 1528 */ 3434 1529 function _admin_search_query() { 3435 echo isset($_ GET['s']) ? esc_attr( stripslashes( $_GET['s'] ) ) : '';1530 echo isset($_REQUEST['s']) ? esc_attr( stripslashes( $_REQUEST['s'] ) ) : ''; 3436 1531 } 3437 1532 … … 3445 1540 */ 3446 1541 function iframe_header( $title = '', $limit_styles = false ) { 3447 global $hook_suffix; 1542 show_admin_bar( false ); 1543 global $hook_suffix, $current_screen, $current_user, $admin_body_class, $wp_locale; 1544 $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix); 1545 $admin_body_class .= ' iframe'; 1546 3448 1547 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3449 1548 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> … … 3461 1560 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}; 3462 1561 function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();} 1562 var userSettings = { 1563 'url': '<?php echo SITECOOKIEPATH; ?>', 1564 'uid': '<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>', 1565 'time':'<?php echo time() ?>' 1566 }, 1567 ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', 1568 pagenow = '<?php echo $current_screen->id; ?>', 1569 typenow = '<?php if ( isset($current_screen->post_type) ) echo $current_screen->post_type; ?>', 1570 adminpage = '<?php echo $admin_body_class; ?>', 1571 thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>', 1572 decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>', 1573 isRtl = <?php echo (int) is_rtl(); ?>; 3463 1574 //]]> 3464 1575 </script> 3465 1576 <?php 1577 do_action('admin_enqueue_scripts', $hook_suffix); 1578 do_action("admin_print_styles-$hook_suffix"); 3466 1579 do_action('admin_print_styles'); 1580 do_action("admin_print_scripts-$hook_suffix"); 3467 1581 do_action('admin_print_scripts'); 1582 do_action("admin_head-$hook_suffix"); 3468 1583 do_action('admin_head'); 3469 3470 $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);3471 1584 ?> 3472 1585 </head> … … 3534 1647 } 3535 1648 } 1649 1650 if ( get_post_format( $post->ID ) ) 1651 echo ' - <span class="post-state-format">' . get_post_format_string( get_post_format( $post->ID ) ) . '</span>'; 3536 1652 } 3537 1653 … … 3545 1661 */ 3546 1662 function convert_to_screen( $screen ) { 3547 $screen = str_replace( array('.php', '-new', '-add' ), '', $screen); 1663 $screen = str_replace( array('.php', '-new', '-add', '-network', '-user' ), '', $screen); 1664 1665 if ( is_network_admin() ) 1666 $screen .= '-network'; 1667 elseif ( is_user_admin() ) 1668 $screen .= '-user'; 1669 3548 1670 $screen = (string) apply_filters( 'screen_meta_screen', $screen ); 3549 1671 $screen = (object) array('id' => $screen, 'base' => $screen); … … 3552 1674 3553 1675 function screen_meta($screen) { 3554 global $wp_meta_boxes, $_wp_contextual_help, $ title;1676 global $wp_meta_boxes, $_wp_contextual_help, $wp_list_table, $wp_current_screen_options; 3555 1677 3556 1678 if ( is_string($screen) ) 3557 1679 $screen = convert_to_screen($screen); 3558 1680 3559 $column_screens = get_column_headers($screen); 1681 $columns = get_column_headers( $screen ); 1682 $hidden = get_hidden_columns( $screen ); 1683 3560 1684 $meta_screens = array('index' => 'dashboard'); 3561 1685 … … 3566 1690 3567 1691 $show_screen = false; 3568 if ( !empty($wp_meta_boxes[$screen->id]) || !empty($column _screens) )1692 if ( !empty($wp_meta_boxes[$screen->id]) || !empty($columns) ) 3569 1693 $show_screen = true; 3570 1694 … … 3584 1708 break; 3585 1709 } 3586 if ( ! empty( $settings ) )1710 if ( ! empty( $settings ) ) 3587 1711 $show_screen = true; 1712 1713 if ( !empty($wp_current_screen_options) ) 1714 $show_screen = true; 1715 3588 1716 ?> 3589 1717 <div id="screen-meta"> … … 3598 1726 </div> 3599 1727 <?php endif; 3600 if ( ! empty($column _screens) ) : ?>3601 <h5><?php echo ( isset( $column _screens['_title'] ) ? $column_screens['_title'] : _x('Show on screen', 'Columns') ) ?></h5>1728 if ( ! empty($columns) ) : ?> 1729 <h5><?php echo ( isset( $columns['_title'] ) ? $columns['_title'] : _x('Show on screen', 'Columns') ) ?></h5> 3602 1730 <div class="metabox-prefs"> 3603 <?php manage_columns_prefs($screen); ?> 1731 <?php 1732 $special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname'); 1733 1734 foreach ( $columns as $column => $title ) { 1735 // Can't hide these for they are special 1736 if ( in_array( $column, $special ) ) 1737 continue; 1738 if ( empty( $title ) ) 1739 continue; 1740 1741 if ( 'comments' == $column ) 1742 $title = __( 'Comments' ); 1743 $id = "$column-hide"; 1744 echo '<label for="' . $id . '">'; 1745 echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( !in_array($column, $hidden), true, false ) . ' />'; 1746 echo "$title</label>\n"; 1747 } 1748 ?> 3604 1749 <br class="clear" /> 3605 1750 </div> … … 3675 1820 } 3676 1821 3677 function drag_drop_help() {3678 return '3679 <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>3680 <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>3681 ';3682 }3683 3684 function plugins_search_help() {3685 return '3686 <p><strong>' . __('Search help') . '</strong></p>' .3687 '<p>' . __('You may search based on 3 criteria:') . '<br />' .3688 __('<strong>Term:</strong> Searches theme names and descriptions for the specified term.') . '<br />' .3689 __('<strong>Tag:</strong> Searches for themes tagged as such.') . '<br />' .3690 __('<strong>Author:</strong> Searches for themes created by the Author, or which the Author contributed to.') . '</p>3691 ';3692 }3693 3694 1822 function screen_layout($screen) { 3695 global $screen_layout_columns ;1823 global $screen_layout_columns, $wp_current_screen_options; 3696 1824 3697 1825 if ( is_string($screen) ) 3698 1826 $screen = convert_to_screen($screen); 3699 1827 3700 $columns = array('dashboard' => 4, 'link' => 2); 3701 3702 // Add custom post types 3703 foreach ( get_post_types( array('show_ui' => true) ) as $post_type ) 3704 $columns[$post_type] = 2; 3705 3706 $columns = apply_filters('screen_layout_columns', $columns, $screen->id, $screen); 3707 3708 if ( !isset($columns[$screen->id]) ) { 1828 // Back compat for plugins using the filter instead of add_screen_option() 1829 $columns = apply_filters('screen_layout_columns', array(), $screen->id, $screen); 1830 if ( !empty($columns) && isset($columns[$screen->id]) ) 1831 add_screen_option('layout_columns', array('max' => $columns[$screen->id]) ); 1832 1833 if ( !isset($wp_current_screen_options['layout_columns']) ) { 3709 1834 $screen_layout_columns = 0; 3710 1835 return ''; 3711 }1836 } 3712 1837 3713 1838 $screen_layout_columns = get_user_option("screen_layout_$screen->id"); 3714 $num = $columns[$screen->id]; 3715 3716 if ( ! $screen_layout_columns ) 1839 $num = $wp_current_screen_options['layout_columns']['max']; 1840 1841 if ( ! $screen_layout_columns ) { 1842 if ( isset($wp_current_screen_options['layout_columns']['default']) ) 1843 $screen_layout_columns = $wp_current_screen_options['layout_columns']['default']; 1844 else 3717 1845 $screen_layout_columns = 2; 1846 } 3718 1847 3719 1848 $i = 1; … … 3727 1856 } 3728 1857 1858 /** 1859 * Register and configure an admin screen option 1860 * 1861 * @since 3.1.0 1862 * 1863 * @param string $option An option name. 1864 * @param mixed $args Option dependent arguments 1865 * @return void 1866 */ 1867 function add_screen_option( $option, $args = array() ) { 1868 global $wp_current_screen_options; 1869 1870 if ( !isset($wp_current_screen_options) ) 1871 $wp_current_screen_options = array(); 1872 1873 $wp_current_screen_options[$option] = $args; 1874 } 1875 3729 1876 function screen_options($screen) { 1877 global $wp_current_screen_options; 1878 3730 1879 if ( is_string($screen) ) 3731 1880 $screen = convert_to_screen($screen); 3732 1881 3733 switch ( $screen->base ) { 3734 case 'edit': 3735 case 'edit-pages': 3736 $post_type = 'post'; 3737 if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array('public' => true ) ) ) ) 3738 $post_type = $_GET['post_type']; 3739 $post_type_object = get_post_type_object($post_type); 3740 $per_page_label = $post_type_object->labels->name; 3741 break; 3742 case 'ms-sites': 3743 $per_page_label = _x( 'Sites', 'sites per page (screen options)' ); 3744 break; 3745 case 'ms-users': 3746 $per_page_label = _x( 'Users', 'users per page (screen options)' ); 3747 break; 3748 case 'edit-comments': 3749 $per_page_label = _x( 'Comments', 'comments per page (screen options)' ); 3750 break; 3751 case 'upload': 3752 $per_page_label = _x( 'Media items', 'items per page (screen options)' ); 3753 break; 3754 case 'edit-tags': 3755 global $tax; 3756 $per_page_label = $tax->labels->name; 3757 break; 3758 case 'plugins': 3759 $per_page_label = _x( 'Plugins', 'plugins per page (screen options)' ); 3760 break; 3761 default: 3762 return ''; 3763 } 3764 3765 $option = str_replace( '-', '_', "{$screen->id}_per_page" ); 3766 if ( 'edit_tags_per_page' == $option ) { 3767 if ( 'category' == $tax->name ) 3768 $option = 'categories_per_page'; 3769 elseif ( 'post_tag' != $tax->name ) 3770 $option = 'edit_' . $tax->name . '_per_page'; 1882 if ( !isset($wp_current_screen_options['per_page']) ) 1883 return ''; 1884 1885 $per_page_label = $wp_current_screen_options['per_page']['label']; 1886 1887 if ( empty($wp_current_screen_options['per_page']['option']) ) { 1888 $option = str_replace( '-', '_', "{$screen->id}_per_page" ); 1889 } else { 1890 $option = $wp_current_screen_options['per_page']['option']; 3771 1891 } 3772 1892 3773 1893 $per_page = (int) get_user_option( $option ); 3774 1894 if ( empty( $per_page ) || $per_page < 1 ) { 3775 if ( 'plugins' == $screen->id)3776 $per_page = 999;1895 if ( isset($wp_current_screen_options['per_page']['default']) ) 1896 $per_page = $wp_current_screen_options['per_page']['default']; 3777 1897 else 3778 1898 $per_page = 20; … … 3786 1906 $per_page = apply_filters( $option, $per_page ); 3787 1907 1908 // Back compat 1909 if ( isset( $screen->post_type ) ) 1910 $per_page = apply_filters( 'edit_posts_per_page', $per_page, $screen->post_type ); 1911 3788 1912 $return = "<div class='screen-options'>\n"; 3789 1913 if ( !empty($per_page_label) ) 3790 1914 $return .= "<input type='text' class='screen-per-page' name='wp_screen_options[value]' id='$option' maxlength='3' value='$per_page' /> <label for='$option'>$per_page_label</label>\n"; 3791 $return .= "<input type='submit' class='button' value='" . esc_attr__('Apply') . "' />";1915 $return .= get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false ); 3792 1916 $return .= "<input type='hidden' name='wp_screen_options[option]' value='" . esc_attr($option) . "' />"; 3793 1917 $return .= "</div>\n"; … … 3796 1920 3797 1921 function screen_icon($screen = '') { 3798 global $current_screen ;1922 global $current_screen, $typenow; 3799 1923 3800 1924 if ( empty($screen) ) … … 3802 1926 elseif ( is_string($screen) ) 3803 1927 $name = $screen; 1928 1929 $class = 'icon32'; 3804 1930 3805 1931 if ( empty($name) ) { … … 3811 1937 if ( 'edit' == $name && isset($screen->post_type) && 'page' == $screen->post_type ) 3812 1938 $name = 'edit-pages'; 1939 1940 $post_type = ''; 1941 if ( isset( $screen->post_type ) ) 1942 $post_type = $screen->post_type; 1943 elseif ( $current_screen == $screen ) 1944 $post_type = $typenow; 1945 if ( $post_type ) 1946 $class .= ' ' . sanitize_html_class( 'icon32-posts-' . $post_type ); 3813 1947 } 3814 1948 3815 1949 ?> 3816 <div id="icon-<?php echo $name; ?>" class=" icon32"><br /></div>1950 <div id="icon-<?php echo $name; ?>" class="<?php echo $class; ?>"><br /></div> 3817 1951 <?php 3818 1952 } … … 3851 1985 } 3852 1986 3853 x.open('GET', 'admin-ajax.php?action=wp-compression-test&test='+test+'&'+(new Date()).getTime(), true);1987 x.open('GET', ajaxurl + '?action=wp-compression-test&test='+test+'&'+(new Date()).getTime(), true); 3854 1988 x.send(''); 3855 1989 } … … 3881 2015 </script> 3882 2016 <?php 2017 } 2018 2019 /** 2020 * Get the current screen object 2021 * 2022 * @since 3.1.0 2023 * 2024 * @return object Current screen object 2025 */ 2026 function get_current_screen() { 2027 global $current_screen; 2028 2029 if ( !isset($current_screen) ) 2030 return null; 2031 2032 return $current_screen; 3883 2033 } 3884 2034 … … 3945 2095 } 3946 2096 2097 $current_screen->is_network = is_network_admin(); 2098 $current_screen->is_user = is_user_admin(); 2099 2100 if ( $current_screen->is_network ) { 2101 $current_screen->base .= '-network'; 2102 $current_screen->id .= '-network'; 2103 } elseif ( $current_screen->is_user ) { 2104 $current_screen->base .= '-user'; 2105 $current_screen->id .= '-user'; 2106 } 2107 3947 2108 $current_screen = apply_filters('current_screen', $current_screen); 3948 2109 } 3949 2110 3950 ?> 2111 /** 2112 * Echos a submit button, with provided text and appropriate class 2113 * 2114 * @since 3.1.0 2115 * 2116 * @param string $text The text of the button (defaults to 'Save Changes') 2117 * @param string $type The type of button. One of: primary, secondary, delete 2118 * @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute 2119 * is given in $other_attributes below, $name will be used as the button's id. 2120 * @param bool $wrap True if the output button should be wrapped in a paragraph tag, 2121 * false otherwise. Defaults to true 2122 * @param array|string $other_attributes Other attributes that should be output with the button, 2123 * mapping attributes to their values, such as array( 'tabindex' => '1' ). 2124 * These attributes will be ouput as attribute="value", such as tabindex="1". 2125 * Defaults to no other attributes. Other attributes can also be provided as a 2126 * string such as 'tabindex="1"', though the array format is typically cleaner. 2127 */ 2128 function submit_button( $text = NULL, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = NULL ) { 2129 echo get_submit_button( $text, $type, $name, $wrap, $other_attributes ); 2130 } 2131 2132 /** 2133 * Returns a submit button, with provided text and appropriate class 2134 * 2135 * @since 3.1.0 2136 * 2137 * @param string $text The text of the button (defaults to 'Save Changes') 2138 * @param string $type The type of button. One of: primary, secondary, delete 2139 * @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute 2140 * is given in $other_attributes below, $name will be used as the button's id. 2141 * @param bool $wrap True if the output button should be wrapped in a paragraph tag, 2142 * false otherwise. Defaults to true 2143 * @param array|string $other_attributes Other attributes that should be output with the button, 2144 * mapping attributes to their values, such as array( 'tabindex' => '1' ). 2145 * These attributes will be ouput as attribute="value", such as tabindex="1". 2146 * Defaults to no other attributes. Other attributes can also be provided as a 2147 * string such as 'tabindex="1"', though the array format is typically cleaner. 2148 */ 2149 function get_submit_button( $text = NULL, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = NULL ) { 2150 switch ( $type ) : 2151 case 'primary' : 2152 case 'secondary' : 2153 $class = 'button-' . $type; 2154 break; 2155 case 'delete' : 2156 $class = 'button-secondary delete'; 2157 break; 2158 default : 2159 $class = $type; // Custom cases can just pass in the classes they want to be used 2160 endswitch; 2161 $text = ( NULL == $text ) ? __( 'Save Changes' ) : $text; 2162 2163 // Default the id attribute to $name unless an id was specifically provided in $other_attributes 2164 $id = $name; 2165 if ( is_array( $other_attributes ) && isset( $other_attributes['id'] ) ) { 2166 $id = $other_attributes['id']; 2167 unset( $other_attributes['id'] ); 2168 } 2169 2170 $attributes = ''; 2171 if ( is_array( $other_attributes ) ) { 2172 foreach ( $other_attributes as $attribute => $value ) { 2173 $attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important 2174 } 2175 } else if ( !empty( $other_attributes ) ) { // Attributes provided as a string 2176 $attributes = $other_attributes; 2177 } 2178 2179 $button = '<input type="submit" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" class="' . esc_attr( $class ); 2180 $button .= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />'; 2181 2182 if ( $wrap ) { 2183 $button = '<p class="submit">' . $button . '</p>'; 2184 } 2185 2186 return $button; 2187 } 2188
Note: See TracChangeset
for help on using the changeset viewer.