- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-posts-list-table.php
r42228 r42343 75 75 global $post_type_object, $wpdb; 76 76 77 parent::__construct( array( 78 'plural' => 'posts', 79 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 80 ) ); 77 parent::__construct( 78 array( 79 'plural' => 'posts', 80 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 81 ) 82 ); 81 83 82 84 $post_type = $this->screen->post_type; 83 85 $post_type_object = get_post_type_object( $post_type ); 84 86 85 $exclude_states = get_post_stati( array( 86 'show_in_admin_all_list' => false, 87 ) ); 88 $this->user_posts_count = intval( $wpdb->get_var( $wpdb->prepare( " 87 $exclude_states = get_post_stati( 88 array( 89 'show_in_admin_all_list' => false, 90 ) 91 ); 92 $this->user_posts_count = intval( 93 $wpdb->get_var( 94 $wpdb->prepare( 95 " 89 96 SELECT COUNT( 1 ) 90 97 FROM $wpdb->posts … … 92 99 AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' ) 93 100 AND post_author = %d 94 ", $post_type, get_current_user_id() ) ) ); 101 ", $post_type, get_current_user_id() 102 ) 103 ) 104 ); 95 105 96 106 if ( $this->user_posts_count && ! current_user_can( $post_type_object->cap->edit_others_posts ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) ) { … … 99 109 100 110 if ( 'post' === $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) { 101 $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) );111 $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) ); 102 112 $this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status NOT IN ('trash', 'auto-draft') AND ID IN ($sticky_posts)", $post_type ) ); 103 113 } … … 116 126 117 127 /** 118 *119 128 * @return bool 120 129 */ … … 124 133 125 134 /** 126 *127 135 * @global array $avail_post_stati 128 136 * @global WP_Query $wp_query … … 139 147 140 148 $post_type = $this->screen->post_type; 141 $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' );149 $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' ); 142 150 143 151 /** This filter is documented in wp-admin/includes/post.php */ 144 $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type );152 $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type ); 145 153 146 154 if ( $this->hierarchical_display ) { … … 151 159 $post_counts = (array) wp_count_posts( $post_type, 'readable' ); 152 160 153 if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'] , $avail_post_stati ) ) {161 if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'], $avail_post_stati ) ) { 154 162 $total_items = $post_counts[ $_REQUEST['post_status'] ]; 155 163 } elseif ( isset( $_REQUEST['show_sticky'] ) && $_REQUEST['show_sticky'] ) { … … 176 184 $this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] === 'trash'; 177 185 178 $this->set_pagination_args( array( 179 'total_items' => $total_items, 180 'per_page' => $per_page 181 ) ); 182 } 183 184 /** 185 * 186 $this->set_pagination_args( 187 array( 188 'total_items' => $total_items, 189 'per_page' => $per_page, 190 ) 191 ); 192 } 193 194 /** 186 195 * @return bool 187 196 */ … … 193 202 */ 194 203 public function no_items() { 195 if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) 204 if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) { 196 205 echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash; 197 else206 } else { 198 207 echo get_post_type_object( $this->screen->post_type )->labels->not_found; 208 } 199 209 } 200 210 … … 254 264 255 265 /** 256 *257 266 * @global array $locked_post_status This seems to be deprecated. 258 267 * @global array $avail_post_stati … … 264 273 $post_type = $this->screen->post_type; 265 274 266 if ( ! empty($locked_post_status) )275 if ( ! empty( $locked_post_status ) ) { 267 276 return array(); 277 } 268 278 269 279 $status_links = array(); 270 $num_posts = wp_count_posts( $post_type, 'readable' );271 $total_posts = array_sum( (array) $num_posts );272 $class = '';280 $num_posts = wp_count_posts( $post_type, 'readable' ); 281 $total_posts = array_sum( (array) $num_posts ); 282 $class = ''; 273 283 274 284 $current_user_id = get_current_user_id(); 275 $all_args = array( 'post_type' => $post_type );276 $mine = '';285 $all_args = array( 'post_type' => $post_type ); 286 $mine = ''; 277 287 278 288 // Subtract post types that are not included in the admin all list. … … 288 298 $mine_args = array( 289 299 'post_type' => $post_type, 290 'author' => $current_user_id300 'author' => $current_user_id, 291 301 ); 292 302 … … 304 314 305 315 $all_args['all_posts'] = 1; 306 $class = '';316 $class = ''; 307 317 } 308 318 … … 326 336 } 327 337 328 foreach ( get_post_stati( array('show_in_admin_status_list' => true), 'objects') as $status ) {338 foreach ( get_post_stati( array( 'show_in_admin_status_list' => true ), 'objects' ) as $status ) { 329 339 $class = ''; 330 340 … … 335 345 } 336 346 337 if ( isset( $_REQUEST['post_status']) && $status_name === $_REQUEST['post_status'] ) {347 if ( isset( $_REQUEST['post_status'] ) && $status_name === $_REQUEST['post_status'] ) { 338 348 $class = 'current'; 339 349 } … … 341 351 $status_args = array( 342 352 'post_status' => $status_name, 343 'post_type' => $post_type,353 'post_type' => $post_type, 344 354 ); 345 355 … … 356 366 357 367 $sticky_args = array( 358 'post_type' => $post_type,359 'show_sticky' => 1 368 'post_type' => $post_type, 369 'show_sticky' => 1, 360 370 ); 361 371 … … 371 381 372 382 $sticky_link = array( 373 'sticky' => $this->get_edit_link( $sticky_args, $sticky_inner_html, $class ) 383 'sticky' => $this->get_edit_link( $sticky_args, $sticky_inner_html, $class ), 374 384 ); 375 385 376 386 // Sticky comes after Publish, or if not listed, after All. 377 $split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) );387 $split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) ); 378 388 $status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) ); 379 389 } … … 383 393 384 394 /** 385 *386 395 * @return array 387 396 */ 388 397 protected function get_bulk_actions() { 389 $actions = array();398 $actions = array(); 390 399 $post_type_obj = get_post_type_object( $this->screen->post_type ); 391 400 … … 436 445 $dropdown_options = array( 437 446 'show_option_all' => get_taxonomy( 'category' )->labels->all_items, 438 'hide_empty' => 0,439 'hierarchical' => 1,440 'show_count' => 0,441 'orderby' => 'name',442 'selected' => $cat447 'hide_empty' => 0, 448 'hierarchical' => 1, 449 'show_count' => 0, 450 'orderby' => 'name', 451 'selected' => $cat, 443 452 ); 444 453 … … 455 464 <div class="alignleft actions"> 456 465 <?php 457 if ( 'top' === $which && !is_singular() ) {458 ob_start();459 460 $this->months_dropdown( $this->screen->post_type );461 $this->categories_dropdown( $this->screen->post_type );462 463 /**464 * Fires before the Filter button on the Posts and Pages list tables.465 *466 * The Filter button allows sorting by date and/or category on the467 * Posts list table, and sorting by date on the Pages list table.468 *469 * @since 2.1.0470 * @since 4.4.0 The `$post_type` parameter was added.471 * @since 4.6.0 The `$which` parameter was added.472 *473 * @param string $post_type The post type slug.474 * @param string $which The location of the extra table nav markup:475 * 'top' or 'bottom' for WP_Posts_List_Table,476 * 'bar' for WP_Media_List_Table.477 */478 do_action( 'restrict_manage_posts', $this->screen->post_type, $which );479 480 $output = ob_get_clean();481 482 if ( ! empty( $output ) ) {483 echo $output;484 submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );485 }486 }487 488 if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) && $this->has_items() ) {489 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );490 }466 if ( 'top' === $which && ! is_singular() ) { 467 ob_start(); 468 469 $this->months_dropdown( $this->screen->post_type ); 470 $this->categories_dropdown( $this->screen->post_type ); 471 472 /** 473 * Fires before the Filter button on the Posts and Pages list tables. 474 * 475 * The Filter button allows sorting by date and/or category on the 476 * Posts list table, and sorting by date on the Pages list table. 477 * 478 * @since 2.1.0 479 * @since 4.4.0 The `$post_type` parameter was added. 480 * @since 4.6.0 The `$which` parameter was added. 481 * 482 * @param string $post_type The post type slug. 483 * @param string $which The location of the extra table nav markup: 484 * 'top' or 'bottom' for WP_Posts_List_Table, 485 * 'bar' for WP_Media_List_Table. 486 */ 487 do_action( 'restrict_manage_posts', $this->screen->post_type, $which ); 488 489 $output = ob_get_clean(); 490 491 if ( ! empty( $output ) ) { 492 echo $output; 493 submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); 494 } 495 } 496 497 if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) && $this->has_items() ) { 498 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); 499 } 491 500 ?> 492 501 </div> … … 504 513 505 514 /** 506 *507 515 * @return string 508 516 */ 509 517 public function current_action() { 510 if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) 518 if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) { 511 519 return 'delete_all'; 520 } 512 521 513 522 return parent::current_action(); … … 515 524 516 525 /** 517 *518 526 * @return array 519 527 */ … … 523 531 524 532 /** 525 *526 533 * @return array 527 534 */ … … 558 565 559 566 foreach ( $taxonomies as $taxonomy ) { 560 if ( 'category' === $taxonomy ) 567 if ( 'category' === $taxonomy ) { 561 568 $column_key = 'categories'; 562 elseif ( 'post_tag' === $taxonomy )569 } elseif ( 'post_tag' === $taxonomy ) { 563 570 $column_key = 'tags'; 564 else571 } else { 565 572 $column_key = 'taxonomy-' . $taxonomy; 573 } 566 574 567 575 $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; 568 576 } 569 577 570 $post_status = ! empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';571 if ( post_type_supports( $post_type, 'comments' ) && ! in_array( $post_status, array( 'pending', 'draft', 'future' ) ) )578 $post_status = ! empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all'; 579 if ( post_type_supports( $post_type, 'comments' ) && ! in_array( $post_status, array( 'pending', 'draft', 'future' ) ) ) { 572 580 $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>'; 581 } 573 582 574 583 $posts_columns['date'] = __( 'Date' ); … … 610 619 611 620 /** 612 *613 621 * @return array 614 622 */ … … 618 626 'parent' => 'parent', 619 627 'comments' => 'comment_count', 620 'date' => array( 'date', true ) 628 'date' => array( 'date', true ), 621 629 ); 622 630 } … … 631 639 global $wp_query, $per_page; 632 640 633 if ( empty( $posts ) ) 641 if ( empty( $posts ) ) { 634 642 $posts = $wp_query->posts; 643 } 635 644 636 645 add_filter( 'the_title', 'esc_html' ); … … 651 660 $post_ids = array(); 652 661 653 foreach ( $posts as $a_post ) 662 foreach ( $posts as $a_post ) { 654 663 $post_ids[] = $a_post->ID; 664 } 655 665 656 666 $this->comment_pending_count = get_pending_comments_num( $post_ids ); 657 667 658 foreach ( $posts as $post ) 668 foreach ( $posts as $post ) { 659 669 $this->single_row( $post, $level ); 670 } 660 671 } 661 672 … … 675 686 $pages = get_pages( array( 'sort_column' => 'menu_order' ) ); 676 687 677 if ( ! $pages ) 688 if ( ! $pages ) { 678 689 return; 690 } 679 691 } 680 692 … … 689 701 690 702 $top_level_pages = array(); 691 $children_pages = array();703 $children_pages = array(); 692 704 693 705 foreach ( $pages as $page ) { … … 700 712 } 701 713 702 if ( 0 == $page->post_parent ) 714 if ( 0 == $page->post_parent ) { 703 715 $top_level_pages[] = $page; 704 else716 } else { 705 717 $children_pages[ $page->post_parent ][] = $page; 718 } 706 719 } 707 720 … … 709 722 } 710 723 711 $count = 0;712 $start = ( $pagenum - 1 ) * $per_page;713 $end = $start + $per_page;724 $count = 0; 725 $start = ( $pagenum - 1 ) * $per_page; 726 $end = $start + $per_page; 714 727 $to_display = array(); 715 728 716 729 foreach ( $pages as $page ) { 717 if ( $count >= $end ) 730 if ( $count >= $end ) { 718 731 break; 732 } 719 733 720 734 if ( $count >= $start ) { 721 $to_display[ $page->ID] = $level;735 $to_display[ $page->ID ] = $level; 722 736 } 723 737 724 738 $count++; 725 739 726 if ( isset( $children_pages ) ) 740 if ( isset( $children_pages ) ) { 727 741 $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); 742 } 728 743 } 729 744 730 745 // If it is the last pagenum and there are orphaned pages, display them with paging as well. 731 if ( isset( $children_pages ) && $count < $end ) {732 foreach ( $children_pages as $orphans ) {746 if ( isset( $children_pages ) && $count < $end ) { 747 foreach ( $children_pages as $orphans ) { 733 748 foreach ( $orphans as $op ) { 734 if ( $count >= $end ) 749 if ( $count >= $end ) { 735 750 break; 751 } 736 752 737 753 if ( $count >= $start ) { 738 $to_display[ $op->ID] = 0;754 $to_display[ $op->ID ] = 0; 739 755 } 740 756 … … 773 789 */ 774 790 private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display ) { 775 if ( ! isset( $children_pages[ $parent] ) )791 if ( ! isset( $children_pages[ $parent ] ) ) { 776 792 return; 793 } 777 794 778 795 $start = ( $pagenum - 1 ) * $per_page; 779 $end = $start + $per_page;780 781 foreach ( $children_pages[ $parent] as $page ) {782 if ( $count >= $end ) 796 $end = $start + $per_page; 797 798 foreach ( $children_pages[ $parent ] as $page ) { 799 if ( $count >= $end ) { 783 800 break; 801 } 784 802 785 803 // If the page starts in a subtree, print the parents. 786 804 if ( $count == $start && $page->post_parent > 0 ) { 787 805 $my_parents = array(); 788 $my_parent = $page->post_parent;806 $my_parent = $page->post_parent; 789 807 while ( $my_parent ) { 790 808 // Get the ID from the list or the attribute if my_parent is an object … … 794 812 } 795 813 796 $my_parent = get_post( $parent_id );814 $my_parent = get_post( $parent_id ); 797 815 $my_parents[] = $my_parent; 798 if ( ! $my_parent->post_parent )816 if ( ! $my_parent->post_parent ) { 799 817 break; 818 } 800 819 $my_parent = $my_parent->post_parent; 801 820 } 802 821 $num_parents = count( $my_parents ); 803 822 while ( $my_parent = array_pop( $my_parents ) ) { 804 $to_display[ $my_parent->ID] = $level - $num_parents;823 $to_display[ $my_parent->ID ] = $level - $num_parents; 805 824 $num_parents--; 806 825 } … … 808 827 809 828 if ( $count >= $start ) { 810 $to_display[ $page->ID] = $level;829 $to_display[ $page->ID ] = $level; 811 830 } 812 831 … … 816 835 } 817 836 818 unset( $children_pages[ $parent] ); //required in order to keep track of orphans837 unset( $children_pages[ $parent ] ); //required in order to keep track of orphans 819 838 } 820 839 … … 827 846 */ 828 847 public function column_cb( $post ) { 829 if ( current_user_can( 'edit_post', $post->ID ) ): ?> 830 <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php 831 printf( __( 'Select %s' ), _draft_or_post_title() ); 832 ?></label> 848 if ( current_user_can( 'edit_post', $post->ID ) ) : 849 ?> 850 <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"> 851 <?php 852 printf( __( 'Select %s' ), _draft_or_post_title() ); 853 ?> 854 </label> 833 855 <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" /> 834 856 <div class="locked-indicator"> 835 857 <span class="locked-indicator-icon" aria-hidden="true"></span> 836 <span class="screen-reader-text"><?php 858 <span class="screen-reader-text"> 859 <?php 837 860 printf( 838 861 /* translators: %s: post title */ … … 840 863 _draft_or_post_title() 841 864 ); 842 ?></span> 865 ?> 866 </span> 843 867 </div> 844 <?php endif; 868 <?php 869 endif; 845 870 } 846 871 … … 900 925 901 926 if ( $lock_holder ) { 902 $lock_holder = get_userdata( $lock_holder );927 $lock_holder = get_userdata( $lock_holder ); 903 928 $locked_avatar = get_avatar( $lock_holder->ID, 18 ); 904 $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );929 $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) ); 905 930 } else { 906 931 $locked_avatar = $locked_text = ''; … … 911 936 912 937 $pad = str_repeat( '— ', $this->current_level ); 913 echo "<strong>";938 echo '<strong>'; 914 939 915 940 $format = get_post_format( $post->ID ); … … 921 946 $format_args = array( 922 947 'post_format' => $format, 923 'post_type' => $post->post_type948 'post_type' => $post->post_type, 924 949 ); 925 950 … … 973 998 974 999 if ( '0000-00-00 00:00:00' === $post->post_date ) { 975 $t_time = $h_time = __( 'Unpublished' );1000 $t_time = $h_time = __( 'Unpublished' ); 976 1001 $time_diff = 0; 977 1002 } else { 978 1003 $t_time = get_the_time( __( 'Y/m/d g:i:s a' ) ); 979 1004 $m_time = $post->post_date; 980 $time = get_post_time( 'G', true, $post );1005 $time = get_post_time( 'G', true, $post ); 981 1006 982 1007 $time_diff = time() - $time; … … 1051 1076 <div class="post-com-count-wrapper"> 1052 1077 <?php 1053 $pending_comments = isset( $this->comment_pending_count[ $post->ID] ) ? $this->comment_pending_count[$post->ID] : 0;1078 $pending_comments = isset( $this->comment_pending_count[ $post->ID ] ) ? $this->comment_pending_count[ $post->ID ] : 0; 1054 1079 1055 1080 $this->comments_bubble( $post->ID, $pending_comments ); … … 1069 1094 $args = array( 1070 1095 'post_type' => $post->post_type, 1071 'author' => get_the_author_meta( 'ID' )1096 'author' => get_the_author_meta( 'ID' ), 1072 1097 ); 1073 1098 echo $this->get_edit_link( $args, get_the_author() ); … … 1094 1119 if ( $taxonomy ) { 1095 1120 $taxonomy_object = get_taxonomy( $taxonomy ); 1096 $terms = get_the_terms( $post->ID, $taxonomy );1121 $terms = get_the_terms( $post->ID, $taxonomy ); 1097 1122 if ( is_array( $terms ) ) { 1098 1123 $out = array(); … … 1106 1131 } else { 1107 1132 $posts_in_term_qv['taxonomy'] = $taxonomy; 1108 $posts_in_term_qv['term'] = $t->slug;1133 $posts_in_term_qv['term'] = $t->slug; 1109 1134 } 1110 1135 … … 1172 1197 $global_post = get_post(); 1173 1198 1174 $post = get_post( $post );1199 $post = get_post( $post ); 1175 1200 $this->current_level = $level; 1176 1201 … … 1186 1211 1187 1212 if ( $post->post_parent ) { 1188 $count= count( get_post_ancestors( $post->ID ) );1189 $classes .= ' level-'. $count;1213 $count = count( get_post_ancestors( $post->ID ) ); 1214 $classes .= ' level-' . $count; 1190 1215 } else { 1191 $classes .= ' level-0';1216 $classes .= ' level-0'; 1192 1217 } 1193 1218 ?> … … 1226 1251 1227 1252 $post_type_object = get_post_type_object( $post->post_type ); 1228 $can_edit_post = current_user_can( 'edit_post', $post->ID );1229 $actions = array();1230 $title = _draft_or_post_title();1253 $can_edit_post = current_user_can( 'edit_post', $post->ID ); 1254 $actions = array(); 1255 $title = _draft_or_post_title(); 1231 1256 1232 1257 if ( $can_edit_post && 'trash' != $post->post_status ) { … … 1278 1303 if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) { 1279 1304 if ( $can_edit_post ) { 1280 $preview_link = get_preview_post_link( $post );1305 $preview_link = get_preview_post_link( $post ); 1281 1306 $actions['view'] = sprintf( 1282 1307 '<a href="%s" rel="bookmark" aria-label="%s">%s</a>', … … 1345 1370 $screen = $this->screen; 1346 1371 1347 $post = get_default_post_to_edit( $screen->post_type );1372 $post = get_default_post_to_edit( $screen->post_type ); 1348 1373 $post_type_object = get_post_type_object( $screen->post_type ); 1349 1374 1350 $taxonomy_names = get_object_taxonomies( $screen->post_type );1375 $taxonomy_names = get_object_taxonomies( $screen->post_type ); 1351 1376 $hierarchical_taxonomies = array(); 1352 $flat_taxonomies = array();1377 $flat_taxonomies = array(); 1353 1378 foreach ( $taxonomy_names as $taxonomy_name ) { 1354 1379 … … 1370 1395 } 1371 1396 1372 if ( $taxonomy->hierarchical ) 1397 if ( $taxonomy->hierarchical ) { 1373 1398 $hierarchical_taxonomies[] = $taxonomy; 1374 else1399 } else { 1375 1400 $flat_taxonomies[] = $taxonomy; 1376 } 1377 1378 $m = ( isset( $mode ) && 'excerpt' === $mode ) ? 'excerpt' : 'list'; 1379 $can_publish = current_user_can( $post_type_object->cap->publish_posts ); 1380 $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true ); 1401 } 1402 } 1403 1404 $m = ( isset( $mode ) && 'excerpt' === $mode ) ? 'excerpt' : 'list'; 1405 $can_publish = current_user_can( $post_type_object->cap->publish_posts ); 1406 $core_columns = array( 1407 'cb' => true, 1408 'date' => true, 1409 'title' => true, 1410 'categories' => true, 1411 'tags' => true, 1412 'comments' => true, 1413 'author' => true, 1414 ); 1381 1415 1382 1416 ?> … … 1384 1418 <form method="get"><table style="display: none"><tbody id="inlineedit"> 1385 1419 <?php 1386 $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page';1420 $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page'; 1387 1421 $inline_edit_classes = "inline-edit-row inline-edit-row-$hclass"; 1388 1422 $bulk_edit_classes = "bulk-edit-row bulk-edit-row-$hclass bulk-edit-{$screen->post_type}"; … … 1390 1424 1391 1425 $bulk = 0; 1392 while ( $bulk < 2 ) { ?> 1393 1394 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="<?php echo $inline_edit_classes . ' '; 1395 echo $bulk ? $bulk_edit_classes : $quick_edit_classes; 1396 ?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> 1426 while ( $bulk < 2 ) { 1427 ?> 1428 1429 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class=" 1430 <?php 1431 echo $inline_edit_classes . ' '; 1432 echo $bulk ? $bulk_edit_classes : $quick_edit_classes; 1433 ?> 1434 " style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> 1397 1435 1398 1436 <fieldset class="inline-edit-col-left"> … … 1402 1440 1403 1441 if ( post_type_supports( $screen->post_type, 'title' ) ) : 1404 if ( $bulk ) : ?> 1442 if ( $bulk ) : 1443 ?> 1405 1444 <div id="bulk-title-div"> 1406 1445 <div id="bulk-titles"></div> … … 1419 1458 </label> 1420 1459 1421 <?php endif; // $bulk 1422 endif; // post_type_supports title ?> 1423 1424 <?php if ( !$bulk ) : ?> 1460 <?php 1461 endif; // $bulk 1462 endif; // post_type_supports title 1463 ?> 1464 1465 <?php if ( ! $bulk ) : ?> 1425 1466 <fieldset class="inline-edit-date"> 1426 1467 <legend><span class="title"><?php _e( 'Date' ); ?></span></legend> … … 1428 1469 </fieldset> 1429 1470 <br class="clear" /> 1430 <?php endif; // $bulk 1431 1432 if ( post_type_supports( $screen->post_type, 'author' ) ) : 1433 $authors_dropdown = ''; 1434 1435 if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) : 1436 $users_opt = array( 1437 'hide_if_only_one_author' => false, 1438 'who' => 'authors', 1439 'name' => 'post_author', 1440 'class'=> 'authors', 1441 'multi' => 1, 1442 'echo' => 0, 1443 'show' => 'display_name_with_login', 1444 ); 1445 if ( $bulk ) 1446 $users_opt['show_option_none'] = __( '— No Change —' ); 1447 1448 if ( $authors = wp_dropdown_users( $users_opt ) ) : 1449 $authors_dropdown = '<label class="inline-edit-author">'; 1450 $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>'; 1451 $authors_dropdown .= $authors; 1452 $authors_dropdown .= '</label>'; 1453 endif; 1454 endif; // authors 1471 <?php 1472 endif; // $bulk 1473 1474 if ( post_type_supports( $screen->post_type, 'author' ) ) : 1475 $authors_dropdown = ''; 1476 1477 if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) : 1478 $users_opt = array( 1479 'hide_if_only_one_author' => false, 1480 'who' => 'authors', 1481 'name' => 'post_author', 1482 'class' => 'authors', 1483 'multi' => 1, 1484 'echo' => 0, 1485 'show' => 'display_name_with_login', 1486 ); 1487 if ( $bulk ) { 1488 $users_opt['show_option_none'] = __( '— No Change —' ); 1489 } 1490 1491 if ( $authors = wp_dropdown_users( $users_opt ) ) : 1492 $authors_dropdown = '<label class="inline-edit-author">'; 1493 $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>'; 1494 $authors_dropdown .= $authors; 1495 $authors_dropdown .= '</label>'; 1496 endif; 1497 endif; // authors 1455 1498 ?> 1456 1499 1457 <?php if ( !$bulk ) echo $authors_dropdown; 1500 <?php 1501 if ( ! $bulk ) { 1502 echo $authors_dropdown;} 1458 1503 endif; // post_type_supports author 1459 1504 1460 if ( !$bulk && $can_publish ) :1505 if ( ! $bulk && $can_publish ) : 1461 1506 ?> 1462 1507 1463 <div class="inline-edit-group wp-clearfix">1464 <label class="alignleft">1465 <span class="title"><?php _e( 'Password' ); ?></span>1466 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>1467 </label>1468 1469 <em class="alignleft inline-edit-or">1470 <?php1471 /* translators: Between password field and private checkbox on post quick edit interface */1472 _e( '–OR–' );1473 ?>1508 <div class="inline-edit-group wp-clearfix"> 1509 <label class="alignleft"> 1510 <span class="title"><?php _e( 'Password' ); ?></span> 1511 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span> 1512 </label> 1513 1514 <em class="alignleft inline-edit-or"> 1515 <?php 1516 /* translators: Between password field and private checkbox on post quick edit interface */ 1517 _e( '–OR–' ); 1518 ?> 1474 1519 </em> 1475 1520 <label class="alignleft inline-edit-private"> 1476 <input type="checkbox" name="keep_private" value="private" />1477 <span class="checkbox-title"><?php _e( 'Private' ); ?></span>1521 <input type="checkbox" name="keep_private" value="private" /> 1522 <span class="checkbox-title"><?php _e( 'Private' ); ?></span> 1478 1523 </label> 1479 1524 </div> … … 1483 1528 </div></fieldset> 1484 1529 1485 <?php if ( count( $hierarchical_taxonomies ) && ! $bulk ) : ?>1530 <?php if ( count( $hierarchical_taxonomies ) && ! $bulk ) : ?> 1486 1531 1487 1532 <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col"> … … 1489 1534 <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?> 1490 1535 1491 <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?></span>1536 <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ); ?></span> 1492 1537 <input type="hidden" name="<?php echo ( $taxonomy->name === 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" /> 1493 <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name ) ?>-checklist">1494 <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?>1538 <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name ); ?>-checklist"> 1539 <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ); ?> 1495 1540 </ul> 1496 1541 … … 1504 1549 1505 1550 <?php 1506 if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) 1507 echo $authors_dropdown; 1508 1509 if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) : 1510 1511 if ( $post_type_object->hierarchical ) : 1551 if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) { 1552 echo $authors_dropdown; 1553 } 1554 1555 if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) : 1556 1557 if ( $post_type_object->hierarchical ) : 1512 1558 ?> 1513 <label>1514 <span class="title"><?php _e( 'Parent' ); ?></span>1559 <label> 1560 <span class="title"><?php _e( 'Parent' ); ?></span> 1515 1561 <?php 1516 $dropdown_args = array( 1517 'post_type' => $post_type_object->name, 1518 'selected' => $post->post_parent, 1519 'name' => 'post_parent', 1520 'show_option_none' => __( 'Main Page (no parent)' ), 1521 'option_none_value' => 0, 1522 'sort_column' => 'menu_order, post_title', 1523 ); 1524 1525 if ( $bulk ) 1526 $dropdown_args['show_option_no_change'] = __( '— No Change —' ); 1527 1528 /** 1529 * Filters the arguments used to generate the Quick Edit page-parent drop-down. 1530 * 1531 * @since 2.7.0 1532 * 1533 * @see wp_dropdown_pages() 1534 * 1535 * @param array $dropdown_args An array of arguments. 1536 */ 1537 $dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args ); 1538 1539 wp_dropdown_pages( $dropdown_args ); 1540 ?> 1541 </label> 1542 1543 <?php 1544 endif; // hierarchical 1545 1546 if ( !$bulk ) : ?> 1562 $dropdown_args = array( 1563 'post_type' => $post_type_object->name, 1564 'selected' => $post->post_parent, 1565 'name' => 'post_parent', 1566 'show_option_none' => __( 'Main Page (no parent)' ), 1567 'option_none_value' => 0, 1568 'sort_column' => 'menu_order, post_title', 1569 ); 1570 1571 if ( $bulk ) { 1572 $dropdown_args['show_option_no_change'] = __( '— No Change —' ); 1573 } 1574 1575 /** 1576 * Filters the arguments used to generate the Quick Edit page-parent drop-down. 1577 * 1578 * @since 2.7.0 1579 * 1580 * @see wp_dropdown_pages() 1581 * 1582 * @param array $dropdown_args An array of arguments. 1583 */ 1584 $dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args ); 1585 1586 wp_dropdown_pages( $dropdown_args ); 1587 ?> 1588 </label> 1589 1590 <?php 1591 endif; // hierarchical 1592 1593 if ( ! $bulk ) : 1594 ?> 1547 1595 1548 1596 <label> 1549 1597 <span class="title"><?php _e( 'Order' ); ?></span> 1550 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>1598 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order; ?>" /></span> 1551 1599 </label> 1552 1600 1553 1601 <?php 1554 endif; // !$bulk1602 endif; // !$bulk 1555 1603 endif; // page-attributes 1556 1604 ?> … … 1563 1611 <option value="-1"><?php _e( '— No Change —' ); ?></option> 1564 1612 <?php endif; // $bulk ?> 1565 <?php1613 <?php 1566 1614 /** This filter is documented in wp-admin/includes/meta-boxes.php */ 1567 $default_title = apply_filters( 'default_page_template_title', __( 'Default Template' ), 'quick-edit' );1568 ?>1615 $default_title = apply_filters( 'default_page_template_title', __( 'Default Template' ), 'quick-edit' ); 1616 ?> 1569 1617 <option value="default"><?php echo esc_html( $default_title ); ?></option> 1570 <?php page_template_dropdown( '', $screen->post_type ) ?>1618 <?php page_template_dropdown( '', $screen->post_type ); ?> 1571 1619 </select> 1572 1620 </label> 1573 1621 <?php endif; ?> 1574 1622 1575 <?php if ( count( $flat_taxonomies ) && ! $bulk ) : ?>1623 <?php if ( count( $flat_taxonomies ) && ! $bulk ) : ?> 1576 1624 1577 1625 <?php foreach ( $flat_taxonomies as $taxonomy ) : ?> 1578 <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : 1626 <?php 1627 if ( current_user_can( $taxonomy->cap->assign_terms ) ) : 1579 1628 $taxonomy_name = esc_attr( $taxonomy->name ); 1580 1629 1581 1630 ?> 1582 1631 <label class="inline-edit-tags"> 1583 <span class="title"><?php echo esc_html( $taxonomy->labels->name ) ?></span>1632 <span class="title"><?php echo esc_html( $taxonomy->labels->name ); ?></span> 1584 1633 <textarea data-wp-taxonomy="<?php echo $taxonomy_name; ?>" cols="22" rows="1" name="tax_input[<?php echo $taxonomy_name; ?>]" class="tax_input_<?php echo $taxonomy_name; ?>"></textarea> 1585 1634 </label> … … 1588 1637 <?php endforeach; //$flat_taxonomies as $taxonomy ?> 1589 1638 1590 <?php endif; // count( $flat_taxonomies ) && !$bulk ?> 1591 1592 <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) : 1593 if ( $bulk ) : ?> 1639 <?php endif; // count( $flat_taxonomies ) && !$bulk ?> 1640 1641 <?php 1642 if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) : 1643 if ( $bulk ) : 1644 ?> 1594 1645 1595 1646 <div class="inline-edit-group wp-clearfix"> … … 1631 1682 </div> 1632 1683 1633 <?php endif; // $bulk 1634 endif; // post_type_supports comments or pings ?> 1684 <?php 1685 endif; // $bulk 1686 endif; // post_type_supports comments or pings 1687 ?> 1635 1688 1636 1689 <div class="inline-edit-group wp-clearfix"> … … 1645 1698 <option value="future"><?php _e( 'Scheduled' ); ?></option> 1646 1699 <?php if ( $bulk ) : ?> 1647 <option value="private"><?php _e( 'Private' ) ?></option>1700 <option value="private"><?php _e( 'Private' ); ?></option> 1648 1701 <?php endif; // $bulk ?> 1649 1702 <?php endif; ?> … … 1711 1764 list( $columns ) = $this->get_column_info(); 1712 1765 1713 foreach ( $columns as $column_name => $column_display_name ) {1714 if ( isset( $core_columns[$column_name] ) )1715 continue;1716 1717 if ( $bulk ) { 1718 1719 /** 1720 * Fires once for each column in Bulk Edit mode.1721 *1722 * @since 2.7.01723 *1724 * @param string $column_name Name of the column to edit.1725 * @param WP_Post $post_type The post type slug.1726 */1727 do_action( 'bulk_edit_custom_box', $column_name, $screen->post_type );1728 } else {1729 1730 /** 1731 * Fires once for each column in Quick Edit mode.1732 *1733 * @since 2.7.01734 *1735 * @param string $column_name Name of the column to edit.1736 * @param string $post_type The post type slug, or current screen name if this is a taxonomy list table.1737 * @param string taxonomy The taxonomy name, if any.1738 */1739 do_action( 'quick_edit_custom_box', $column_name, $screen->post_type, '' );1740 }1741 1742 }1766 foreach ( $columns as $column_name => $column_display_name ) { 1767 if ( isset( $core_columns[ $column_name ] ) ) { 1768 continue; 1769 } 1770 1771 if ( $bulk ) { 1772 1773 /** 1774 * Fires once for each column in Bulk Edit mode. 1775 * 1776 * @since 2.7.0 1777 * 1778 * @param string $column_name Name of the column to edit. 1779 * @param WP_Post $post_type The post type slug. 1780 */ 1781 do_action( 'bulk_edit_custom_box', $column_name, $screen->post_type ); 1782 } else { 1783 1784 /** 1785 * Fires once for each column in Quick Edit mode. 1786 * 1787 * @since 2.7.0 1788 * 1789 * @param string $column_name Name of the column to edit. 1790 * @param string $post_type The post type slug, or current screen name if this is a taxonomy list table. 1791 * @param string taxonomy The taxonomy name, if any. 1792 */ 1793 do_action( 'quick_edit_custom_box', $column_name, $screen->post_type, '' ); 1794 } 1795 } 1743 1796 ?> 1744 1797 <div class="submit inline-edit-save"> 1745 1798 <button type="button" class="button cancel alignleft"><?php _e( 'Cancel' ); ?></button> 1746 <?php if ( ! $bulk ) { 1799 <?php 1800 if ( ! $bulk ) { 1747 1801 wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); 1748 1802 ?> 1749 1803 <button type="button" class="button button-primary save alignright"><?php _e( 'Update' ); ?></button> 1750 1804 <span class="spinner"></span> 1751 <?php } else { 1805 <?php 1806 } else { 1752 1807 submit_button( __( 'Update' ), 'primary alignright', 'bulk_edit', false ); 1753 } ?> 1808 } 1809 ?> 1754 1810 <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" /> 1755 1811 <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
Note: See TracChangeset
for help on using the changeset viewer.