Changeset 50804
- Timestamp:
- 05/03/2021 01:55:08 PM (4 years ago)
- Location:
- trunk/src/wp-admin/includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-comments-list-table.php
r50768 r50804 414 414 } 415 415 416 if ( ( 'spam' === $comment_status || 'trash' === $comment_status ) && current_user_can( 'moderate_comments' ) && $has_items ) { 416 if ( ( 'spam' === $comment_status || 'trash' === $comment_status ) && $has_items 417 && current_user_can( 'moderate_comments' ) 418 ) { 417 419 wp_nonce_field( 'bulk-destroy', '_destroy_nonce' ); 418 420 $title = ( 'spam' === $comment_status ) ? esc_attr__( 'Empty Spam' ) : esc_attr__( 'Empty Trash' ); -
trunk/src/wp-admin/includes/class-wp-media-list-table.php
r50770 r50804 172 172 protected function get_bulk_actions() { 173 173 $actions = array(); 174 174 175 if ( MEDIA_TRASH ) { 175 176 if ( $this->is_trash ) { … … 209 210 submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); 210 211 211 if ( $this->is_trash && current_user_can( 'edit_others_posts' ) && $this->has_items() ) { 212 if ( $this->is_trash && $this->has_items() 213 && current_user_can( 'edit_others_posts' ) 214 ) { 212 215 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); 213 216 } … … 337 340 $column_key = 'taxonomy-' . $taxonomy; 338 341 } 342 339 343 $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; 340 344 } … … 347 351 } 348 352 } 353 349 354 /* translators: Column name. */ 350 355 $posts_columns['date'] = _x( 'Date', 'column name' ); 356 351 357 /** 352 358 * Filters the Media list table columns. … … 425 431 <?php 426 432 echo $link_start; 433 427 434 if ( $thumb ) : 428 435 ?> … … 430 437 <?php 431 438 endif; 439 432 440 echo $title . $link_end; 441 433 442 _media_states( $post ); 434 443 ?> … … 599 608 if ( $taxonomy ) { 600 609 $terms = get_the_terms( $post->ID, $taxonomy ); 610 601 611 if ( is_array( $terms ) ) { 602 612 $out = array(); -
trunk/src/wp-admin/includes/class-wp-posts-list-table.php
r50505 r50804 85 85 $post_type_object = get_post_type_object( $post_type ); 86 86 87 $exclude_states 87 $exclude_states = get_post_stati( 88 88 array( 89 89 'show_in_admin_all_list' => false, 90 90 ) 91 91 ); 92 92 93 $this->user_posts_count = (int) $wpdb->get_var( 93 94 $wpdb->prepare( 94 " 95 SELECT COUNT( 1 ) 96 FROM $wpdb->posts 97 WHERE post_type = %s 98 AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' ) 99 AND post_author = %d 100 ", 95 "SELECT COUNT( 1 ) 96 FROM $wpdb->posts 97 WHERE post_type = %s 98 AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' ) 99 AND post_author = %d", 101 100 $post_type, 102 101 get_current_user_id() … … 104 103 ); 105 104 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'] ) ) { 105 if ( $this->user_posts_count 106 && ! current_user_can( $post_type_object->cap->edit_others_posts ) 107 && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) 108 && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) 109 ) { 107 110 $_GET['author'] = get_current_user_id(); 108 111 } 109 112 110 113 $sticky_posts = get_option( 'sticky_posts' ); 114 111 115 if ( 'post' === $post_type && $sticky_posts ) { 112 $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) ); 113 $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 ) ); 116 $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) ); 117 118 $this->sticky_posts_count = (int) $wpdb->get_var( 119 $wpdb->prepare( 120 "SELECT COUNT( 1 ) 121 FROM $wpdb->posts 122 WHERE post_type = %s 123 AND post_status NOT IN ('trash', 'auto-draft') 124 AND ID IN ($sticky_posts)", 125 $post_type 126 ) 127 ); 114 128 } 115 129 } … … 152 166 $avail_post_stati = wp_edit_posts_query(); 153 167 154 $this->set_hierarchical_display( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' === $wp_query->query['orderby'] ); 168 $this->set_hierarchical_display( 169 is_post_type_hierarchical( $this->screen->post_type ) 170 && 'menu_order title' === $wp_query->query['orderby'] 171 ); 155 172 156 173 $post_type = $this->screen->post_type; … … 171 188 } elseif ( isset( $_REQUEST['show_sticky'] ) && $_REQUEST['show_sticky'] ) { 172 189 $total_items = $this->sticky_posts_count; 173 } elseif ( isset( $_GET['author'] ) && get_current_user_id() == $_GET['author'] ) {190 } elseif ( isset( $_GET['author'] ) && get_current_user_id() === (int) $_GET['author'] ) { 174 191 $total_items = $this->user_posts_count; 175 192 } else { … … 245 262 $class_html = ''; 246 263 $aria_current = ''; 264 247 265 if ( ! empty( $class ) ) { 248 266 $class_html = sprintf( … … 294 312 295 313 if ( $this->user_posts_count && $this->user_posts_count !== $total_posts ) { 296 if ( isset( $_GET['author'] ) && ( $ _GET['author'] == $current_user_id) ) {314 if ( isset( $_GET['author'] ) && ( $current_user_id === (int) $_GET['author'] ) ) { 297 315 $class = 'current'; 298 316 } … … 336 354 337 355 $status_links['all'] = $this->get_edit_link( $all_args, $all_inner_html, $class ); 356 338 357 if ( $mine ) { 339 358 $status_links['mine'] = $mine; … … 514 533 // Pretty, translated version of the post format slug. 515 534 $pretty_name = get_post_format_string( $slug ); 535 516 536 // Skip the standard post format. 517 537 if ( 'standard' === $slug ) { … … 566 586 } 567 587 568 if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) && $this->has_items() ) { 588 if ( $this->is_trash && $this->has_items() 589 && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) 590 ) { 569 591 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); 570 592 } … … 604 626 $mode_class = esc_attr( 'table-view-' . $mode ); 605 627 606 return array( 'widefat', 'fixed', 'striped', $mode_class, is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' ); 628 return array( 629 'widefat', 630 'fixed', 631 'striped', 632 $mode_class, 633 is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts', 634 ); 607 635 } 608 636 … … 659 687 660 688 $post_status = ! empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all'; 661 if ( post_type_supports( $post_type, 'comments' ) && ! in_array( $post_status, array( 'pending', 'draft', 'future' ), true ) ) { 662 $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>'; 689 690 if ( post_type_supports( $post_type, 'comments' ) 691 && ! in_array( $post_status, array( 'pending', 'draft', 'future' ), true ) 692 ) { 693 $posts_columns['comments'] = sprintf( 694 '<span class="vers comment-grey-bubble" title="%1$s"><span class="screen-reader-text">%2$s</span></span>', 695 esc_attr__( 'Comments' ), 696 __( 'Comments' ) 697 ); 663 698 } 664 699 … … 790 825 */ 791 826 if ( empty( $_REQUEST['s'] ) ) { 792 793 827 $top_level_pages = array(); 794 828 $children_pages = array(); 795 829 796 830 foreach ( $pages as $page ) { 797 798 831 // Catch and repair bad pages. 799 if ( $page->post_parent == $page->ID ) {832 if ( $page->post_parent === $page->ID ) { 800 833 $page->post_parent = 0; 801 834 $wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) ); … … 803 836 } 804 837 805 if ( 0 == $page->post_parent ) { 838 if ( $page->post_parent > 0 ) { 839 $children_pages[ $page->post_parent ][] = $page; 840 } else { 806 841 $top_level_pages[] = $page; 807 } else {808 $children_pages[ $page->post_parent ][] = $page;809 842 } 810 843 } … … 893 926 894 927 // If the page starts in a subtree, print the parents. 895 if ( $count == $start && $page->post_parent > 0 ) {928 if ( $count === $start && $page->post_parent > 0 ) { 896 929 $my_parents = array(); 897 930 $my_parent = $page->post_parent; 931 898 932 while ( $my_parent ) { 899 933 // Get the ID from the list or the attribute if my_parent is an object. 900 934 $parent_id = $my_parent; 935 901 936 if ( is_object( $my_parent ) ) { 902 937 $parent_id = $my_parent->ID; … … 905 940 $my_parent = get_post( $parent_id ); 906 941 $my_parents[] = $my_parent; 942 907 943 if ( ! $my_parent->post_parent ) { 908 944 break; 909 945 } 946 910 947 $my_parent = $my_parent->post_parent; 911 948 } 949 912 950 $num_parents = count( $my_parents ); 951 913 952 while ( $my_parent = array_pop( $my_parents ) ) { 914 953 $to_display[ $my_parent->ID ] = $level - $num_parents; … … 1005 1044 // Sent level 0 by accident, by default, or because we don't know the actual level. 1006 1045 $find_main_page = (int) $post->post_parent; 1046 1007 1047 while ( $find_main_page > 0 ) { 1008 1048 $parent = get_post( $find_main_page ); … … 1068 1108 echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name ); 1069 1109 } 1110 1070 1111 echo "</strong>\n"; 1071 1112 … … 1209 1250 $taxonomy = false; 1210 1251 } 1252 1211 1253 if ( $taxonomy ) { 1212 1254 $taxonomy_object = get_taxonomy( $taxonomy ); 1213 1255 $terms = get_the_terms( $post->ID, $taxonomy ); 1256 1214 1257 if ( is_array( $terms ) ) { 1215 1258 $term_links = array(); 1259 1216 1260 foreach ( $terms as $t ) { 1217 1261 $posts_in_term_qv = array(); 1262 1218 1263 if ( 'post' !== $post->post_type ) { 1219 1264 $posts_in_term_qv['post_type'] = $post->post_type; 1220 1265 } 1266 1221 1267 if ( $taxonomy_object->query_var ) { 1222 1268 $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug; … … 1313 1359 setup_postdata( $post ); 1314 1360 1315 $classes = 'iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );1361 $classes = 'iedit author-' . ( get_current_user_id() === (int) $post->post_author ? 'self' : 'other' ); 1316 1362 1317 1363 $lock_holder = wp_check_post_lock( $post->ID ); 1364 1318 1365 if ( $lock_holder ) { 1319 1366 $classes .= ' wp-locked'; … … 1403 1450 ); 1404 1451 } 1452 1405 1453 if ( 'trash' === $post->post_status || ! EMPTY_TRASH_DAYS ) { 1406 1454 $actions['delete'] = sprintf( … … 1502 1550 1503 1551 foreach ( $taxonomy_names as $taxonomy_name ) { 1504 1505 1552 $taxonomy = get_taxonomy( $taxonomy_name ); 1506 1553 … … 1538 1585 'author' => true, 1539 1586 ); 1540 1541 1587 ?> 1542 1588 … … 1550 1596 1551 1597 $bulk = 0; 1598 1552 1599 while ( $bulk < 2 ) : 1553 1600 $classes = $inline_edit_classes . ' '; … … 1598 1645 1599 1646 <?php 1600 if ( post_type_supports( $screen->post_type, 'author' ) ) :1647 if ( post_type_supports( $screen->post_type, 'author' ) ) { 1601 1648 $authors_dropdown = ''; 1602 1649 1603 if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) :1650 if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) { 1604 1651 $users_opt = array( 1605 1652 'hide_if_only_one_author' => false, … … 1629 1676 1630 1677 $authors = wp_dropdown_users( $users_opt ); 1631 if ( $authors ) : 1678 1679 if ( $authors ) { 1632 1680 $authors_dropdown = '<label class="inline-edit-author">'; 1633 1681 $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>'; 1634 1682 $authors_dropdown .= $authors; 1635 1683 $authors_dropdown .= '</label>'; 1636 endif; 1637 endif; // current_user_can( 'edit_others_posts' ) 1638 ?> 1639 1640 <?php 1684 } 1685 } // current_user_can( 'edit_others_posts' ) 1686 1641 1687 if ( ! $bulk ) { 1642 1688 echo $authors_dropdown; 1643 1689 } 1644 endif;// post_type_supports( ... 'author' )1690 } // post_type_supports( ... 'author' ) 1645 1691 ?> 1646 1692
Note: See TracChangeset
for help on using the changeset viewer.