| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * List Table API: WP_Posts_List_Table class 4 * 5 * @package WordPress 6 * @subpackage Administration 7 * @since 3.1.0 8 */ 9 10 /** 11 * Core class used to implement displaying posts in a list table. 12 * 13 * @since 3.1.0 14 * 15 * @see WP_List_Table 16 */ 17 class WP_Posts_List_Table extends WP_List_Table { 18 19 /** 20 * Whether the items should be displayed hierarchically or linearly. 21 * 22 * @since 3.1.0 23 * @var bool 24 */ 25 protected $hierarchical_display; 26 27 /** 28 * Holds the number of pending comments for each post. 29 * 30 * @since 3.1.0 31 * @var array 32 */ 33 protected $comment_pending_count; 34 35 /** 36 * Holds the number of posts for this user. 37 * 38 * @since 3.1.0 39 * @var int 40 */ 41 private $user_posts_count; 42 43 /** 44 * Holds the number of posts which are sticky. 45 * 46 * @since 3.1.0 47 * @var int 48 */ 49 private $sticky_posts_count = 0; 50 51 private $is_trash; 52 53 /** 54 * Current level for output. 55 * 56 * @since 4.3.0 57 * @var int 58 */ 59 protected $current_level = 0; 60 61 /** 62 * Constructor. 63 * 64 * @since 3.1.0 65 * 66 * @see WP_List_Table::__construct() for more information on default arguments. 67 * 68 * @global WP_Post_Type $post_type_object Global post type object. 69 * @global wpdb $wpdb WordPress database abstraction object. 70 * 71 * @param array $args An associative array of arguments. 72 */ 73 public function __construct( $args = array() ) { 74 global $post_type_object, $wpdb; 75 76 parent::__construct( 77 array( 78 'plural' => 'posts', 79 'screen' => $args['screen'] ?? null, 80 ) 81 ); 82 83 $post_type = $this->screen->post_type; 84 $post_type_object = get_post_type_object( $post_type ); 85 86 $exclude_states = get_post_stati( 87 array( 88 'show_in_admin_all_list' => false, 89 ) 90 ); 91 92 $this->user_posts_count = (int) $wpdb->get_var( 93 $wpdb->prepare( 94 "SELECT COUNT( 1 ) 95 FROM $wpdb->posts 96 WHERE post_type = %s 97 AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' ) 98 AND post_author = %d", 99 $post_type, 100 get_current_user_id() 101 ) 102 ); 103 104 if ( $this->user_posts_count 105 && ! current_user_can( $post_type_object->cap->edit_others_posts ) 106 && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) 107 && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) 108 ) { 109 $_GET['author'] = get_current_user_id(); 110 } 111 112 $sticky_posts = get_option( 'sticky_posts' ); 113 114 if ( 'post' === $post_type && $sticky_posts ) { 115 $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) ); 116 117 $this->sticky_posts_count = (int) $wpdb->get_var( 118 $wpdb->prepare( 119 "SELECT COUNT( 1 ) 120 FROM $wpdb->posts 121 WHERE post_type = %s 122 AND post_status NOT IN ('trash', 'auto-draft') 123 AND ID IN ($sticky_posts)", 124 $post_type 125 ) 126 ); 127 } 128 } 129 130 /** 131 * Sets whether the table layout should be hierarchical or not. 132 * 133 * @since 4.2.0 134 * 135 * @param bool $display Whether the table layout should be hierarchical. 136 */ 137 public function set_hierarchical_display( $display ) { 138 $this->hierarchical_display = $display; 139 } 140 141 /** 142 * @return bool 143 */ 144 public function ajax_user_can() { 145 return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts ); 146 } 147 148 /** 149 * @global string $mode List table view mode. 150 * @global array $avail_post_stati 151 * @global WP_Query $wp_query WordPress Query object. 152 * @global int $per_page 153 */ 154 public function prepare_items() { 155 global $mode, $avail_post_stati, $wp_query, $per_page; 156 157 if ( ! empty( $_REQUEST['mode'] ) ) { 158 $mode = 'excerpt' === $_REQUEST['mode'] ? 'excerpt' : 'list'; 159 set_user_setting( 'posts_list_mode', $mode ); 160 } else { 161 $mode = get_user_setting( 'posts_list_mode', 'list' ); 162 } 163 164 // Is going to call wp(). 165 $avail_post_stati = wp_edit_posts_query(); 166 167 $this->set_hierarchical_display( 168 is_post_type_hierarchical( $this->screen->post_type ) 169 && 'menu_order title' === $wp_query->query['orderby'] 170 ); 171 172 $post_type = $this->screen->post_type; 173 $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' ); 174 175 /** This filter is documented in wp-admin/includes/post.php */ 176 $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type ); 177 178 if ( $this->hierarchical_display ) { 179 $total_items = $wp_query->post_count; 180 } elseif ( $wp_query->found_posts || $this->get_pagenum() === 1 ) { 181 $total_items = $wp_query->found_posts; 182 } else { 183 $post_counts = (array) wp_count_posts( $post_type, 'readable' ); 184 185 if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'], $avail_post_stati, true ) ) { 186 $total_items = $post_counts[ $_REQUEST['post_status'] ]; 187 } elseif ( isset( $_REQUEST['show_sticky'] ) && $_REQUEST['show_sticky'] ) { 188 $total_items = $this->sticky_posts_count; 189 } elseif ( isset( $_GET['author'] ) && get_current_user_id() === (int) $_GET['author'] ) { 190 $total_items = $this->user_posts_count; 191 } else { 192 $total_items = array_sum( $post_counts ); 193 194 // Subtract post types that are not included in the admin all list. 195 foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) { 196 $total_items -= $post_counts[ $state ]; 197 } 198 } 199 } 200 201 $this->is_trash = isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status']; 202 203 $this->set_pagination_args( 204 array( 205 'total_items' => $total_items, 206 'per_page' => $per_page, 207 ) 208 ); 209 } 210 211 /** 212 * @return bool 213 */ 214 public function has_items() { 215 return have_posts(); 216 } 217 218 /** 219 */ 220 public function no_items() { 221 if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) { 222 echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash; 223 } else { 224 echo get_post_type_object( $this->screen->post_type )->labels->not_found; 225 } 226 } 227 228 /** 229 * Determines if the current view is the "All" view. 230 * 231 * @since 4.2.0 232 * 233 * @return bool Whether the current view is the "All" view. 234 */ 235 protected function is_base_request() { 236 $vars = $_GET; 237 unset( $vars['paged'] ); 238 239 if ( empty( $vars ) ) { 240 return true; 241 } elseif ( 1 === count( $vars ) && ! empty( $vars['post_type'] ) ) { 242 return $this->screen->post_type === $vars['post_type']; 243 } 244 245 return 1 === count( $vars ) && ! empty( $vars['mode'] ); 246 } 247 248 /** 249 * Creates a link to edit.php with params. 250 * 251 * @since 4.4.0 252 * 253 * @param string[] $args Associative array of URL parameters for the link. 254 * @param string $link_text Link text. 255 * @param string $css_class Optional. Class attribute. Default empty string. 256 * @return string The formatted link string. 257 */ 258 protected function get_edit_link( $args, $link_text, $css_class = '' ) { 259 $url = add_query_arg( $args, 'edit.php' ); 260 261 $class_html = ''; 262 $aria_current = ''; 263 264 if ( ! empty( $css_class ) ) { 265 $class_html = sprintf( 266 ' class="%s"', 267 esc_attr( $css_class ) 268 ); 269 270 if ( 'current' === $css_class ) { 271 $aria_current = ' aria-current="page"'; 272 } 273 } 274 275 return sprintf( 276 '<a href="%s"%s%s>%s</a>', 277 esc_url( $url ), 278 $class_html, 279 $aria_current, 280 $link_text 281 ); 282 } 283 284 /** 285 * @global array $locked_post_status This seems to be deprecated. 286 * @global array $avail_post_stati 287 * @return array 288 */ 289 protected function get_views() { 290 global $locked_post_status, $avail_post_stati; 291 292 $post_type = $this->screen->post_type; 293 294 if ( ! empty( $locked_post_status ) ) { 295 return array(); 296 } 297 298 $status_links = array(); 299 $num_posts = wp_count_posts( $post_type, 'readable' ); 300 $total_posts = array_sum( (array) $num_posts ); 301 $class = ''; 302 303 $current_user_id = get_current_user_id(); 304 $all_args = array( 'post_type' => $post_type ); 305 $mine = ''; 306 307 // Subtract post types that are not included in the admin all list. 308 foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) { 309 $total_posts -= $num_posts->$state; 310 } 311 312 if ( $this->user_posts_count && $this->user_posts_count !== $total_posts ) { 313 if ( isset( $_GET['author'] ) && ( $current_user_id === (int) $_GET['author'] ) ) { 314 $class = 'current'; 315 } 316 317 $mine_args = array( 318 'post_type' => $post_type, 319 'author' => $current_user_id, 320 ); 321 322 $mine_inner_html = sprintf( 323 /* translators: %s: Number of posts. */ 324 _nx( 325 'Mine <span class="count">(%s)</span>', 326 'Mine <span class="count">(%s)</span>', 327 $this->user_posts_count, 328 'posts' 329 ), 330 number_format_i18n( $this->user_posts_count ) 331 ); 332 333 $mine = array( 334 'url' => esc_url( add_query_arg( $mine_args, 'edit.php' ) ), 335 'label' => $mine_inner_html, 336 'current' => isset( $_GET['author'] ) && ( $current_user_id === (int) $_GET['author'] ), 337 ); 338 339 $all_args['all_posts'] = 1; 340 $class = ''; 341 } 342 343 $all_inner_html = sprintf( 344 /* translators: %s: Number of posts. */ 345 _nx( 346 'All <span class="count">(%s)</span>', 347 'All <span class="count">(%s)</span>', 348 $total_posts, 349 'posts' 350 ), 351 number_format_i18n( $total_posts ) 352 ); 353 354 $status_links['all'] = array( 355 'url' => esc_url( add_query_arg( $all_args, 'edit.php' ) ), 356 'label' => $all_inner_html, 357 'current' => empty( $class ) && ( $this->is_base_request() || isset( $_REQUEST['all_posts'] ) ), 358 ); 359 360 if ( $mine ) { 361 $status_links['mine'] = $mine; 362 } 363 364 foreach ( get_post_stati( array( 'show_in_admin_status_list' => true ), 'objects' ) as $status ) { 365 $class = ''; 366 367 $status_name = $status->name; 368 369 if ( ! in_array( $status_name, $avail_post_stati, true ) || empty( $num_posts->$status_name ) ) { 370 continue; 371 } 372 373 if ( isset( $_REQUEST['post_status'] ) && $status_name === $_REQUEST['post_status'] ) { 374 $class = 'current'; 375 } 376 377 $status_args = array( 378 'post_status' => $status_name, 379 'post_type' => $post_type, 380 ); 381 382 $status_label = sprintf( 383 translate_nooped_plural( $status->label_count, $num_posts->$status_name ), 384 number_format_i18n( $num_posts->$status_name ) 385 ); 386 387 $status_links[ $status_name ] = array( 388 'url' => esc_url( add_query_arg( $status_args, 'edit.php' ) ), 389 'label' => $status_label, 390 'current' => isset( $_REQUEST['post_status'] ) && $status_name === $_REQUEST['post_status'], 391 ); 392 } 393 394 if ( ! empty( $this->sticky_posts_count ) ) { 395 $class = ! empty( $_REQUEST['show_sticky'] ) ? 'current' : ''; 396 397 $sticky_args = array( 398 'post_type' => $post_type, 399 'show_sticky' => 1, 400 ); 401 402 $sticky_inner_html = sprintf( 403 /* translators: %s: Number of posts. */ 404 _nx( 405 'Sticky <span class="count">(%s)</span>', 406 'Sticky <span class="count">(%s)</span>', 407 $this->sticky_posts_count, 408 'posts' 409 ), 410 number_format_i18n( $this->sticky_posts_count ) 411 ); 412 413 $sticky_link = array( 414 'sticky' => array( 415 'url' => esc_url( add_query_arg( $sticky_args, 'edit.php' ) ), 416 'label' => $sticky_inner_html, 417 'current' => ! empty( $_REQUEST['show_sticky'] ), 418 ), 419 ); 420 421 // Sticky comes after Publish, or if not listed, after All. 422 $split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ), true ); 423 $status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) ); 424 } 425 426 return $this->get_views_links( $status_links ); 427 } 428 429 /** 430 * @return array 431 */ 432 protected function get_bulk_actions() { 433 $actions = array(); 434 $post_type_obj = get_post_type_object( $this->screen->post_type ); 435 436 if ( current_user_can( $post_type_obj->cap->edit_posts ) ) { 437 if ( $this->is_trash ) { 438 $actions['untrash'] = __( 'Restore' ); 439 } else { 440 $actions['edit'] = _x( 'Bulk edit', 'verb' ); 441 } 442 } 443 444 if ( current_user_can( $post_type_obj->cap->delete_posts ) ) { 445 if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) { 446 $actions['delete'] = __( 'Delete permanently' ); 447 } else { 448 $actions['trash'] = __( 'Move to Trash' ); 449 } 450 } 451 452 return $actions; 453 } 454 455 /** 456 * Displays a categories drop-down for filtering on the Posts list table. 457 * 458 * @since 4.6.0 459 * 460 * @global int $cat Currently selected category. 461 * 462 * @param string $post_type Post type slug. 463 */ 464 protected function categories_dropdown( $post_type ) { 465 global $cat; 466 467 /** 468 * Filters whether to remove the 'Categories' drop-down from the post list table. 469 * 470 * @since 4.6.0 471 * 472 * @param bool $disable Whether to disable the categories drop-down. Default false. 473 * @param string $post_type Post type slug. 474 */ 475 if ( false !== apply_filters( 'disable_categories_dropdown', false, $post_type ) ) { 476 return; 477 } 478 479 if ( is_object_in_taxonomy( $post_type, 'category' ) ) { 480 $dropdown_options = array( 481 'show_option_all' => get_taxonomy( 'category' )->labels->all_items, 482 'hide_empty' => 0, 483 'hierarchical' => 1, 484 'show_count' => 0, 485 'orderby' => 'name', 486 'selected' => $cat, 487 ); 488 489 echo '<label class="screen-reader-text" for="cat">' . get_taxonomy( 'category' )->labels->filter_by_item . '</label>'; 490 491 wp_dropdown_categories( $dropdown_options ); 492 } 493 } 494 495 /** 496 * Displays a formats drop-down for filtering items. 497 * 498 * @since 5.2.0 499 * 500 * @param string $post_type Post type slug. 501 */ 502 protected function formats_dropdown( $post_type ) { 503 /** 504 * Filters whether to remove the 'Formats' drop-down from the post list table. 505 * 506 * @since 5.2.0 507 * @since 5.5.0 The `$post_type` parameter was added. 508 * 509 * @param bool $disable Whether to disable the drop-down. Default false. 510 * @param string $post_type Post type slug. 511 */ 512 if ( apply_filters( 'disable_formats_dropdown', false, $post_type ) ) { 513 return; 514 } 515 516 // Return if the post type doesn't have post formats or if we're in the Trash. 517 if ( ! is_object_in_taxonomy( $post_type, 'post_format' ) || $this->is_trash ) { 518 return; 519 } 520 521 // Make sure the dropdown shows only formats with a post count greater than 0. 522 $used_post_formats = get_terms( 523 array( 524 'taxonomy' => 'post_format', 525 'hide_empty' => true, 526 ) 527 ); 528 529 // Return if there are no posts using formats. 530 if ( ! $used_post_formats ) { 531 return; 532 } 533 534 $displayed_post_format = $_GET['post_format'] ?? ''; 535 ?> 536 <label for="filter-by-format" class="screen-reader-text"> 537 <?php 538 /* translators: Hidden accessibility text. */ 539 _e( 'Filter by post format' ); 540 ?> 541 </label> 542 <select name="post_format" id="filter-by-format"> 543 <option<?php selected( $displayed_post_format, '' ); ?> value=""><?php _e( 'All formats' ); ?></option> 544 <?php 545 foreach ( $used_post_formats as $used_post_format ) { 546 // Post format slug. 547 $slug = str_replace( 'post-format-', '', $used_post_format->slug ); 548 // Pretty, translated version of the post format slug. 549 $pretty_name = get_post_format_string( $slug ); 550 551 // Skip the standard post format. 552 if ( 'standard' === $slug ) { 553 continue; 554 } 555 ?> 556 <option<?php selected( $displayed_post_format, $slug ); ?> value="<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $pretty_name ); ?></option> 557 <?php 558 } 559 ?> 560 </select> 561 <?php 562 } 563 564 /** 565 * @param string $which 566 */ 567 protected function extra_tablenav( $which ) { 568 ?> 569 <div class="alignleft actions"> 570 <?php 571 if ( 'top' === $which ) { 572 ob_start(); 573 574 $this->months_dropdown( $this->screen->post_type ); 575 $this->categories_dropdown( $this->screen->post_type ); 576 $this->formats_dropdown( $this->screen->post_type ); 577 578 /** 579 * Fires before the Filter button on the Posts and Pages list tables. 580 * 581 * The Filter button allows sorting by date and/or category on the 582 * Posts list table, and sorting by date on the Pages list table. 583 * 584 * @since 2.1.0 585 * @since 4.4.0 The `$post_type` parameter was added. 586 * @since 4.6.0 The `$which` parameter was added. 587 * 588 * @param string $post_type The post type slug. 589 * @param string $which The location of the extra table nav markup: 590 * 'top' or 'bottom' for WP_Posts_List_Table, 591 * 'bar' for WP_Media_List_Table. 592 */ 593 do_action( 'restrict_manage_posts', $this->screen->post_type, $which ); 594 595 $output = ob_get_clean(); 596 597 if ( ! empty( $output ) ) { 598 echo $output; 599 submit_button( __( 'Filter' ), 'compact', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); 600 } 601 } 602 603 if ( $this->is_trash && $this->has_items() 604 && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) 605 ) { 606 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); 607 } 608 ?> 609 </div> 610 <?php 611 /** 612 * Fires immediately following the closing "actions" div in the tablenav for the posts 613 * list table. 614 * 615 * @since 4.4.0 616 * 617 * @param string $which The location of the extra table nav markup: 'top' or 'bottom'. 618 */ 619 do_action( 'manage_posts_extra_tablenav', $which ); 620 } 621 622 /** 623 * @return string 624 */ 625 public function current_action() { 626 if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) { 627 return 'delete_all'; 628 } 629 630 return parent::current_action(); 631 } 632 633 /** 634 * @global string $mode List table view mode. 635 * 636 * @return array 637 */ 638 protected function get_table_classes() { 639 global $mode; 640 641 $mode_class = esc_attr( 'table-view-' . $mode ); 642 643 return array( 644 'widefat', 645 'fixed', 646 'striped', 647 $mode_class, 648 is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts', 649 ); 650 } 651 652 /** 653 * @return string[] Array of column titles keyed by their column name. 654 */ 655 public function get_columns() { 656 $post_type = $this->screen->post_type; 657 658 $posts_columns = array(); 659 660 $posts_columns['cb'] = '<input type="checkbox" />'; 661 662 /* translators: Posts screen column name. */ 663 $posts_columns['title'] = _x( 'Title', 'column name' ); 664 665 if ( post_type_supports( $post_type, 'author' ) ) { 666 $posts_columns['author'] = __( 'Author' ); 667 } 668 669 $taxonomies = get_object_taxonomies( $post_type, 'objects' ); 670 $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' ); 671 672 /** 673 * Filters the taxonomy columns in the Posts list table. 674 * 675 * The dynamic portion of the hook name, `$post_type`, refers to the post 676 * type slug. 677 * 678 * Possible hook names include: 679 * 680 * - `manage_taxonomies_for_post_columns` 681 * - `manage_taxonomies_for_page_columns` 682 * 683 * @since 3.5.0 684 * 685 * @param string[] $taxonomies Array of taxonomy names to show columns for. 686 * @param string $post_type The post type. 687 */ 688 $taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type ); 689 $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' ); 690 691 foreach ( $taxonomies as $taxonomy ) { 692 if ( 'category' === $taxonomy ) { 693 $column_key = 'categories'; 694 } elseif ( 'post_tag' === $taxonomy ) { 695 $column_key = 'tags'; 696 } else { 697 $column_key = 'taxonomy-' . $taxonomy; 698 } 699 700 $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; 701 } 702 703 $post_status = ! empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all'; 704 705 if ( post_type_supports( $post_type, 'comments' ) 706 && ! in_array( $post_status, array( 'pending', 'draft', 'future' ), true ) 707 ) { 708 $posts_columns['comments'] = sprintf( 709 '<span class="vers comment-grey-bubble" title="%1$s" aria-hidden="true"></span><span class="screen-reader-text">%2$s</span>', 710 esc_attr__( 'Comments' ), 711 /* translators: Hidden accessibility text. */ 712 __( 'Comments' ) 713 ); 714 } 715 716 $posts_columns['date'] = __( 'Date' ); 717 718 if ( 'page' === $post_type ) { 719 720 /** 721 * Filters the columns displayed in the Pages list table. 722 * 723 * @since 2.5.0 724 * 725 * @param string[] $posts_columns An associative array of column headings. 726 */ 727 $posts_columns = apply_filters( 'manage_pages_columns', $posts_columns ); 728 } else { 729 730 /** 731 * Filters the columns displayed in the Posts list table. 732 * 733 * @since 1.5.0 734 * 735 * @param string[] $posts_columns An associative array of column headings. 736 * @param string $post_type The post type slug. 737 */ 738 $posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type ); 739 } 740 741 /** 742 * Filters the columns displayed in the Posts list table for a specific post type. 743 * 744 * The dynamic portion of the hook name, `$post_type`, refers to the post type slug. 745 * 746 * Possible hook names include: 747 * 748 * - `manage_post_posts_columns` 749 * - `manage_page_posts_columns` 750 * 751 * @since 3.0.0 752 * 753 * @param string[] $posts_columns An associative array of column headings. 754 */ 755 return apply_filters( "manage_{$post_type}_posts_columns", $posts_columns ); 756 } 757 758 /** 759 * @return array 760 */ 761 protected function get_sortable_columns() { 762 763 $post_type = $this->screen->post_type; 764 765 if ( 'page' === $post_type ) { 766 if ( isset( $_GET['orderby'] ) ) { 767 $title_orderby_text = __( 'Table ordered by Title.' ); 768 } else { 769 $title_orderby_text = __( 'Table ordered by Hierarchical Menu Order and Title.' ); 770 } 771 772 $sortables = array( 773 'title' => array( 'title', false, __( 'Title' ), $title_orderby_text, 'asc' ), 774 'parent' => array( 'parent', false ), 775 'comments' => array( 'comment_count', false, __( 'Comments' ), __( 'Table ordered by Comments.' ) ), 776 'date' => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ) ), 777 ); 778 } else { 779 $sortables = array( 780 'title' => array( 'title', false, __( 'Title' ), __( 'Table ordered by Title.' ) ), 781 'parent' => array( 'parent', false ), 782 'comments' => array( 'comment_count', false, __( 'Comments' ), __( 'Table ordered by Comments.' ) ), 783 'date' => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ), 'desc' ), 784 ); 785 } 786 // Custom Post Types: there's a filter for that, see get_column_info(). 787 788 return $sortables; 789 } 790 791 /** 792 * Generates the list table rows. 793 * 794 * @since 3.1.0 795 * 796 * @global WP_Query $wp_query WordPress Query object. 797 * @global int $per_page 798 * 799 * @param array $posts 800 * @param int $level 801 */ 802 public function display_rows( $posts = array(), $level = 0 ) { 803 global $wp_query, $per_page; 804 805 if ( empty( $posts ) ) { 806 $posts = $wp_query->posts; 807 } 808 809 add_filter( 'the_title', 'esc_html' ); 810 811 if ( $this->hierarchical_display ) { 812 $this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page ); 813 } else { 814 $this->_display_rows( $posts, $level ); 815 } 816 } 817 818 /** 819 * @param array $posts 820 * @param int $level 821 */ 822 private function _display_rows( $posts, $level = 0 ) { 823 $post_type = $this->screen->post_type; 824 825 // Create array of post IDs. 826 $post_ids = array(); 827 828 foreach ( $posts as $a_post ) { 829 $post_ids[] = $a_post->ID; 830 } 831 832 if ( post_type_supports( $post_type, 'comments' ) ) { 833 $this->comment_pending_count = get_pending_comments_num( $post_ids ); 834 } 835 update_post_author_caches( $posts ); 836 837 foreach ( $posts as $post ) { 838 $this->single_row( $post, $level ); 839 } 840 } 841 842 /** 843 * @global wpdb $wpdb WordPress database abstraction object. 844 * @global WP_Post $post Global post object. 845 * @param array $pages 846 * @param int $pagenum 847 * @param int $per_page 848 */ 849 private function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) { 850 global $wpdb; 851 852 $level = 0; 853 854 if ( ! $pages ) { 855 $pages = get_pages( array( 'sort_column' => 'menu_order' ) ); 856 857 if ( ! $pages ) { 858 return; 859 } 860 } 861 862 /* 863 * Arrange pages into two parts: top level pages and children_pages. 864 * children_pages is two dimensional array. Example: 865 * children_pages[10][] contains all sub-pages whose parent is 10. 866 * It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations 867 * If searching, ignore hierarchy and treat everything as top level 868 */ 869 if ( empty( $_REQUEST['s'] ) ) { 870 $top_level_pages = array(); 871 $children_pages = array(); 872 873 foreach ( $pages as $page ) { 874 // Catch and repair bad pages. 875 if ( $page->post_parent === $page->ID ) { 876 $page->post_parent = 0; 877 $wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) ); 878 clean_post_cache( $page ); 879 } 880 881 if ( $page->post_parent > 0 ) { 882 $children_pages[ $page->post_parent ][] = $page; 883 } else { 884 $top_level_pages[] = $page; 885 } 886 } 887 888 $pages = &$top_level_pages; 889 } 890 891 $count = 0; 892 $start = ( $pagenum - 1 ) * $per_page; 893 $end = $start + $per_page; 894 $to_display = array(); 895 896 foreach ( $pages as $page ) { 897 if ( $count >= $end ) { 898 break; 899 } 900 901 if ( $count >= $start ) { 902 $to_display[ $page->ID ] = $level; 903 } 904 905 ++$count; 906 907 if ( isset( $children_pages ) ) { 908 $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); 909 } 910 } 911 912 // If it is the last pagenum and there are orphaned pages, display them with paging as well. 913 if ( isset( $children_pages ) && $count < $end ) { 914 foreach ( $children_pages as $orphans ) { 915 foreach ( $orphans as $op ) { 916 if ( $count >= $end ) { 917 break; 918 } 919 920 if ( $count >= $start ) { 921 $to_display[ $op->ID ] = 0; 922 } 923 924 ++$count; 925 } 926 } 927 } 928 929 $ids = array_keys( $to_display ); 930 _prime_post_caches( $ids ); 931 $_posts = array_map( 'get_post', $ids ); 932 update_post_author_caches( $_posts ); 933 934 if ( ! isset( $GLOBALS['post'] ) ) { 935 $GLOBALS['post'] = reset( $ids ); 936 } 937 938 foreach ( $to_display as $page_id => $level ) { 939 echo "\t"; 940 $this->single_row( $page_id, $level ); 941 } 942 } 943 944 /** 945 * Displays the nested hierarchy of sub-pages together with paging 946 * support, based on a top level page ID. 947 * 948 * @since 3.1.0 (Standalone function exists since 2.6.0) 949 * @since 4.2.0 Added the `$to_display` parameter. 950 * 951 * @param array $children_pages 952 * @param int $count 953 * @param int $parent_page 954 * @param int $level 955 * @param int $pagenum 956 * @param int $per_page 957 * @param array $to_display List of pages to be displayed. Passed by reference. 958 */ 959 private function _page_rows( &$children_pages, &$count, $parent_page, $level, $pagenum, $per_page, &$to_display ) { 960 if ( ! isset( $children_pages[ $parent_page ] ) ) { 961 return; 962 } 963 964 $start = ( $pagenum - 1 ) * $per_page; 965 $end = $start + $per_page; 966 967 foreach ( $children_pages[ $parent_page ] as $page ) { 968 if ( $count >= $end ) { 969 break; 970 } 971 972 // If the page starts in a subtree, print the parents. 973 if ( $count === $start && $page->post_parent > 0 ) { 974 $my_parents = array(); 975 $my_parent = $page->post_parent; 976 977 while ( $my_parent ) { 978 // Get the ID from the list or the attribute if my_parent is an object. 979 $parent_id = $my_parent; 980 981 if ( is_object( $my_parent ) ) { 982 $parent_id = $my_parent->ID; 983 } 984 985 $my_parent = get_post( $parent_id ); 986 $my_parents[] = $my_parent; 987 988 if ( ! $my_parent->post_parent ) { 989 break; 990 } 991 992 $my_parent = $my_parent->post_parent; 993 } 994 995 $num_parents = count( $my_parents ); 996 997 while ( $my_parent = array_pop( $my_parents ) ) { 998 $to_display[ $my_parent->ID ] = $level - $num_parents; 999 --$num_parents; 1000 } 1001 } 1002 1003 if ( $count >= $start ) { 1004 $to_display[ $page->ID ] = $level; 1005 } 1006 1007 ++$count; 1008 1009 $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); 1010 } 1011 1012 unset( $children_pages[ $parent_page ] ); // Required in order to keep track of orphans. 1013 } 1014 1015 /** 1016 * Gets a trimmed excerpt to display in place of a missing post title. 1017 * 1018 * Only returns text in the Compact list view for posts that have no title, 1019 * do not require a password, and that the current user is allowed to read. 1020 * 1021 * @since 7.1.0 1022 * 1023 * @global string $mode List table view mode. 1024 * 1025 * @param WP_Post $post The current WP_Post object. 1026 * @return string The escaped, trimmed excerpt, or an empty string. 1027 */ 1028 protected function get_no_title_excerpt( $post ) { 1029 global $mode; 1030 1031 if ( 'excerpt' === $mode 1032 || '' !== get_the_title( $post ) 1033 || post_password_required( $post ) 1034 || ! current_user_can( 'read_post', $post->ID ) 1035 ) { 1036 return ''; 1037 } 1038 1039 $excerpt = get_the_excerpt( $post ); 1040 1041 if ( '' === $excerpt || ! is_string( $excerpt ) ) { 1042 return ''; 1043 } 1044 1045 return esc_html( wp_trim_words( $excerpt, 15 ) ); 1046 } 1047 1048 /** 1049 * Handles the checkbox column output. 1050 * 1051 * @since 4.3.0 1052 * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. 1053 * @since 7.1.0 Includes a trimmed excerpt for untitled posts in Compact view. 1054 * 1055 * @param WP_Post $item The current WP_Post object. 1056 */ 1057 public function column_cb( $item ) { 1058 // Restores the more descriptive, specific name for use within this method. 1059 $post = $item; 1060 1061 $show = current_user_can( 'edit_post', $post->ID ); 1062 1063 /** 1064 * Filters whether to show the bulk edit checkbox for a post in its list table. 1065 * 1066 * By default the checkbox is only shown if the current user can edit the post. 1067 * 1068 * @since 5.7.0 1069 * 1070 * @param bool $show Whether to show the checkbox. 1071 * @param WP_Post $post The current WP_Post object. 1072 */ 1073 if ( apply_filters( 'wp_list_table_show_post_checkbox', $show, $post ) ) : 1074 1075 $post_title = _draft_or_post_title(); 1076 1077 // If the post has no title, try adding part of the excerpt. 1078 $no_title_excerpt = $this->get_no_title_excerpt( $post ); 1079 if ( '' !== $no_title_excerpt ) { 1080 $post_title .= ' ' . $no_title_excerpt; 1081 } 1082 ?> 1083 <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" /> 1084 <label for="cb-select-<?php the_ID(); ?>"> 1085 <span class="screen-reader-text"> 1086 <?php 1087 /* translators: %s: Post title. */ 1088 printf( __( 'Select %s' ), $post_title ); 1089 ?> 1090 </span> 1091 </label> 1092 <div class="locked-indicator"> 1093 <span class="locked-indicator-icon" aria-hidden="true"></span> 1094 <span class="screen-reader-text"> 1095 <?php 1096 printf( 1097 /* translators: Hidden accessibility text. %s: Post title. */ 1098 __( '“%s” is locked' ), 1099 $post_title 1100 ); 1101 ?> 1102 </span> 1103 </div> 1104 <?php 1105 endif; 1106 } 1107 1108 /** 1109 * @since 4.3.0 1110 * 1111 * @param WP_Post $post 1112 * @param string $classes 1113 * @param string $data 1114 * @param string $primary 1115 */ 1116 protected function _column_title( $post, $classes, $data, $primary ) { 1117 echo '<td class="' . $classes . ' page-title" ', $data, '>'; 1118 echo $this->column_title( $post ); 1119 echo $this->handle_row_actions( $post, 'title', $primary ); 1120 echo '</td>'; 1121 } 1122 1123 /** 1124 * Handles the title column output. 1125 * 1126 * @since 4.3.0 1127 * @since 7.1.0 Includes a trimmed excerpt for untitled posts in Compact view. 1128 * 1129 * @global string $mode List table view mode. 1130 * 1131 * @param WP_Post $post The current WP_Post object. 1132 */ 1133 public function column_title( $post ) { 1134 global $mode; 1135 1136 if ( $this->hierarchical_display ) { 1137 if ( 0 === $this->current_level && (int) $post->post_parent > 0 ) { 1138 // Sent level 0 by accident, by default, or because we don't know the actual level. 1139 $find_main_page = (int) $post->post_parent; 1140 1141 while ( $find_main_page > 0 ) { 1142 $parent = get_post( $find_main_page ); 1143 1144 if ( is_null( $parent ) ) { 1145 break; 1146 } 1147 1148 ++$this->current_level; 1149 $find_main_page = (int) $parent->post_parent; 1150 1151 if ( ! isset( $parent_name ) ) { 1152 /** This filter is documented in wp-includes/post-template.php */ 1153 $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID ); 1154 } 1155 } 1156 } 1157 } 1158 1159 $can_edit_post = current_user_can( 'edit_post', $post->ID ); 1160 1161 if ( $can_edit_post && 'trash' !== $post->post_status ) { 1162 $lock_holder = wp_check_post_lock( $post->ID ); 1163 1164 if ( $lock_holder ) { 1165 $lock_holder = get_userdata( $lock_holder ); 1166 $locked_avatar = get_avatar( $lock_holder->ID, 18 ); 1167 /* translators: %s: User's display name. */ 1168 $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) ); 1169 } else { 1170 $locked_avatar = ''; 1171 $locked_text = ''; 1172 } 1173 1174 echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n"; 1175 } 1176 1177 $pad = str_repeat( '— ', $this->current_level ); 1178 echo '<strong>'; 1179 1180 $title = _draft_or_post_title(); 1181 1182 // If the post has no title, try adding part of the excerpt. 1183 $no_title_excerpt = $this->get_no_title_excerpt( $post ); 1184 if ( '' !== $no_title_excerpt ) { 1185 $title .= ' <span class="trimmed-post-excerpt">' . $no_title_excerpt . '</span>'; 1186 } 1187 1188 if ( $can_edit_post && 'trash' !== $post->post_status ) { 1189 printf( 1190 '<a class="row-title" href="%s">%s%s</a>', 1191 get_edit_post_link( $post->ID ), 1192 $pad, 1193 $title 1194 ); 1195 } else { 1196 printf( 1197 '<span>%s%s</span>', 1198 $pad, 1199 $title 1200 ); 1201 } 1202 _post_states( $post ); 1203 1204 if ( isset( $parent_name ) ) { 1205 $post_type_object = get_post_type_object( $post->post_type ); 1206 echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name ); 1207 } 1208 1209 echo "</strong>\n"; 1210 1211 if ( 'excerpt' === $mode 1212 && ! is_post_type_hierarchical( $this->screen->post_type ) 1213 && current_user_can( 'read_post', $post->ID ) 1214 ) { 1215 if ( post_password_required( $post ) ) { 1216 echo '<span class="protected-post-excerpt">' . esc_html( get_the_excerpt() ) . '</span>'; 1217 } else { 1218 echo esc_html( get_the_excerpt() ); 1219 } 1220 } 1221 1222 /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */ 1223 $quick_edit_enabled = apply_filters( 'quick_edit_enabled_for_post_type', true, $post->post_type ); 1224 1225 if ( $quick_edit_enabled ) { 1226 get_inline_data( $post ); 1227 } 1228 } 1229 1230 /** 1231 * Handles the post date column output. 1232 * 1233 * @since 4.3.0 1234 * 1235 * @global string $mode List table view mode. 1236 * 1237 * @param WP_Post $post The current WP_Post object. 1238 */ 1239 public function column_date( $post ) { 1240 global $mode; 1241 1242 if ( '0000-00-00 00:00:00' === $post->post_date ) { 1243 $t_time = __( 'Unpublished' ); 1244 $time_diff = 0; 1245 } else { 1246 $t_time = sprintf( 1247 /* translators: 1: Post date, 2: Post time. */ 1248 __( '%1$s at %2$s' ), 1249 /* translators: Post date format. See https://www.php.net/manual/datetime.format.php */ 1250 get_the_time( __( 'Y/m/d' ), $post ), 1251 /* translators: Post time format. See https://www.php.net/manual/datetime.format.php */ 1252 get_the_time( __( 'g:i a' ), $post ) 1253 ); 1254 1255 $time = get_post_timestamp( $post ); 1256 $time_diff = time() - $time; 1257 } 1258 1259 if ( 'publish' === $post->post_status ) { 1260 $status = __( 'Published' ); 1261 } elseif ( 'future' === $post->post_status ) { 1262 if ( $time_diff > 0 ) { 1263 $status = '<strong class="error-message">' . __( 'Missed schedule' ) . '</strong>'; 1264 } else { 1265 $status = __( 'Scheduled' ); 1266 } 1267 } else { 1268 $status = __( 'Last Modified' ); 1269 } 1270 1271 /** 1272 * Filters the status text of the post. 1273 * 1274 * @since 4.8.0 1275 * 1276 * @param string $status The status text. 1277 * @param WP_Post $post Post object. 1278 * @param string $column_name The column name. 1279 * @param string $mode The list display mode ('excerpt' or 'list'). 1280 */ 1281 $status = apply_filters( 'post_date_column_status', $status, $post, 'date', $mode ); 1282 1283 if ( $status ) { 1284 echo $status . '<br />'; 1285 } 1286 1287 /** 1288 * Filters the published, scheduled, or unpublished time of the post. 1289 * 1290 * @since 2.5.1 1291 * @since 5.5.0 Removed the difference between 'excerpt' and 'list' modes. 1292 * The published time and date are both displayed now, 1293 * which is equivalent to the previous 'excerpt' mode. 1294 * 1295 * @param string $t_time The published time. 1296 * @param WP_Post $post Post object. 1297 * @param string $column_name The column name. 1298 * @param string $mode The list display mode ('excerpt' or 'list'). 1299 */ 1300 echo apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode ); 1301 } 1302 1303 /** 1304 * Handles the comments column output. 1305 * 1306 * @since 4.3.0 1307 * 1308 * @param WP_Post $post The current WP_Post object. 1309 */ 1310 public function column_comments( $post ) { 1311 ?> 1312 <div class="post-com-count-wrapper"> 1313 <?php 1314 $pending_comments = $this->comment_pending_count[ $post->ID ] ?? 0; 1315 1316 $this->comments_bubble( $post->ID, $pending_comments ); 1317 ?> 1318 </div> 1319 <?php 1320 } 1321 1322 /** 1323 * Handles the post author column output. 1324 * 1325 * @since 4.3.0 1326 * @since 6.8.0 Added fallback text when author's name is unknown. 1327 * 1328 * @param WP_Post $post The current WP_Post object. 1329 */ 1330 public function column_author( $post ) { 1331 $author = get_the_author(); 1332 1333 if ( ! empty( $author ) ) { 1334 $args = array( 1335 'post_type' => $post->post_type, 1336 'author' => get_the_author_meta( 'ID' ), 1337 ); 1338 echo $this->get_edit_link( $args, esc_html( $author ) ); 1339 } else { 1340 echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . __( '(no author)' ) . '</span>'; 1341 } 1342 } 1343 1344 /** 1345 * Handles the default column output. 1346 * 1347 * @since 4.3.0 1348 * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. 1349 * 1350 * @param WP_Post $item The current WP_Post object. 1351 * @param string $column_name The current column name. 1352 */ 1353 public function column_default( $item, $column_name ) { 1354 // Restores the more descriptive, specific name for use within this method. 1355 $post = $item; 1356 1357 if ( 'categories' === $column_name ) { 1358 $taxonomy = 'category'; 1359 } elseif ( 'tags' === $column_name ) { 1360 $taxonomy = 'post_tag'; 1361 } elseif ( str_starts_with( $column_name, 'taxonomy-' ) ) { 1362 $taxonomy = substr( $column_name, 9 ); 1363 } else { 1364 $taxonomy = false; 1365 } 1366 1367 if ( $taxonomy ) { 1368 $taxonomy_object = get_taxonomy( $taxonomy ); 1369 $terms = get_the_terms( $post->ID, $taxonomy ); 1370 1371 if ( is_array( $terms ) ) { 1372 $term_links = array(); 1373 1374 foreach ( $terms as $t ) { 1375 $posts_in_term_qv = array(); 1376 1377 if ( 'post' !== $post->post_type ) { 1378 $posts_in_term_qv['post_type'] = $post->post_type; 1379 } 1380 1381 if ( $taxonomy_object->query_var ) { 1382 $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug; 1383 } else { 1384 $posts_in_term_qv['taxonomy'] = $taxonomy; 1385 $posts_in_term_qv['term'] = $t->slug; 1386 } 1387 1388 $label = esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ); 1389 1390 $term_links[] = $this->get_edit_link( $posts_in_term_qv, $label ); 1391 } 1392 1393 /** 1394 * Filters the links in `$taxonomy` column of edit.php. 1395 * 1396 * @since 5.2.0 1397 * 1398 * @param string[] $term_links Array of term editing links. 1399 * @param string $taxonomy Taxonomy name. 1400 * @param WP_Term[] $terms Array of term objects appearing in the post row. 1401 */ 1402 $term_links = apply_filters( 'post_column_taxonomy_links', $term_links, $taxonomy, $terms ); 1403 1404 echo implode( wp_get_list_item_separator(), $term_links ); 1405 } else { 1406 echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . $taxonomy_object->labels->no_terms . '</span>'; 1407 } 1408 return; 1409 } 1410 1411 if ( is_post_type_hierarchical( $post->post_type ) ) { 1412 1413 /** 1414 * Fires in each custom column on the Posts list table. 1415 * 1416 * This hook only fires if the current post type is hierarchical, 1417 * such as pages. 1418 * 1419 * @since 2.5.0 1420 * 1421 * @param string $column_name The name of the column to display. 1422 * @param int $post_id The current post ID. 1423 */ 1424 do_action( 'manage_pages_custom_column', $column_name, $post->ID ); 1425 } else { 1426 1427 /** 1428 * Fires in each custom column in the Posts list table. 1429 * 1430 * This hook only fires if the current post type is non-hierarchical, 1431 * such as posts. 1432 * 1433 * @since 1.5.0 1434 * 1435 * @param string $column_name The name of the column to display. 1436 * @param int $post_id The current post ID. 1437 */ 1438 do_action( 'manage_posts_custom_column', $column_name, $post->ID ); 1439 } 1440 1441 /** 1442 * Fires for each custom column of a specific post type in the Posts list table. 1443 * 1444 * The dynamic portion of the hook name, `$post->post_type`, refers to the post type. 1445 * 1446 * Possible hook names include: 1447 * 1448 * - `manage_post_posts_custom_column` 1449 * - `manage_page_posts_custom_column` 1450 * 1451 * @since 3.1.0 1452 * 1453 * @param string $column_name The name of the column to display. 1454 * @param int $post_id The current post ID. 1455 */ 1456 do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID ); 1457 } 1458 1459 /** 1460 * @global WP_Post $post Global post object. 1461 * 1462 * @param int|WP_Post $post 1463 * @param int $level 1464 */ 1465 public function single_row( $post, $level = 0 ) { 1466 $global_post = get_post(); 1467 1468 $post = get_post( $post ); 1469 $this->current_level = $level; 1470 1471 $GLOBALS['post'] = $post; 1472 setup_postdata( $post ); 1473 1474 $classes = 'iedit author-' . ( get_current_user_id() === (int) $post->post_author ? 'self' : 'other' ); 1475 1476 $lock_holder = wp_check_post_lock( $post->ID ); 1477 1478 if ( $lock_holder ) { 1479 $classes .= ' wp-locked'; 1480 } 1481 1482 if ( $post->post_parent ) { 1483 $count = count( get_post_ancestors( $post->ID ) ); 1484 $classes .= ' level-' . $count; 1485 } else { 1486 $classes .= ' level-0'; 1487 } 1488 ?> 1489 <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>"> 1490 <?php $this->single_row_columns( $post ); ?> 1491 </tr> 1492 <?php 1493 $GLOBALS['post'] = $global_post; 1494 } 1495 1496 /** 1497 * Gets the name of the default primary column. 1498 * 1499 * @since 4.3.0 1500 * 1501 * @return string Name of the default primary column, in this case, 'title'. 1502 */ 1503 protected function get_default_primary_column_name() { 1504 return 'title'; 1505 } 1506 1507 /** 1508 * Generates and displays row action links. 1509 * 1510 * @since 4.3.0 1511 * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. 1512 * 1513 * @param WP_Post $item Post being acted upon. 1514 * @param string $column_name Current column name. 1515 * @param string $primary Primary column name. 1516 * @return string Row actions output for posts, or an empty string 1517 * if the current column is not the primary column. 1518 */ 1519 protected function handle_row_actions( $item, $column_name, $primary ) { 1520 if ( $primary !== $column_name ) { 1521 return ''; 1522 } 1523 1524 // Restores the more descriptive, specific name for use within this method. 1525 $post = $item; 1526 1527 $post_type_object = get_post_type_object( $post->post_type ); 1528 $can_edit_post = current_user_can( 'edit_post', $post->ID ); 1529 $actions = array(); 1530 $title = _draft_or_post_title(); 1531 1532 if ( $can_edit_post && 'trash' !== $post->post_status ) { 1533 $actions['edit'] = sprintf( 1534 '<a href="%s" aria-label="%s">%s</a>', 1535 get_edit_post_link( $post->ID ), 1536 /* translators: %s: Post title. */ 1537 esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ), 1538 __( 'Edit' ) 1539 ); 1540 1541 /** 1542 * Filters whether Quick Edit should be enabled for the given post type. 1543 * 1544 * @since 6.4.0 1545 * 1546 * @param bool $enable Whether to enable the Quick Edit functionality. Default true. 1547 * @param string $post_type Post type name. 1548 */ 1549 $quick_edit_enabled = apply_filters( 'quick_edit_enabled_for_post_type', true, $post->post_type ); 1550 1551 if ( $quick_edit_enabled && 'wp_block' !== $post->post_type ) { 1552 $actions['inline hide-if-no-js'] = sprintf( 1553 '<button type="button" class="button-link editinline" aria-label="%s" aria-expanded="false">%s</button>', 1554 /* translators: %s: Post title. */ 1555 esc_attr( sprintf( __( 'Quick edit “%s” inline' ), $title ) ), 1556 __( 'Quick Edit' ) 1557 ); 1558 } 1559 } 1560 1561 if ( current_user_can( 'delete_post', $post->ID ) ) { 1562 if ( 'trash' === $post->post_status ) { 1563 $actions['untrash'] = sprintf( 1564 '<a href="%s" aria-label="%s">%s</a>', 1565 wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ), 1566 /* translators: %s: Post title. */ 1567 esc_attr( sprintf( __( 'Restore “%s” from the Trash' ), $title ) ), 1568 __( 'Restore' ) 1569 ); 1570 } elseif ( EMPTY_TRASH_DAYS ) { 1571 $actions['trash'] = sprintf( 1572 '<a href="%s" class="submitdelete" aria-label="%s">%s</a>', 1573 get_delete_post_link( $post->ID ), 1574 /* translators: %s: Post title. */ 1575 esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $title ) ), 1576 _x( 'Trash', 'verb' ) 1577 ); 1578 } 1579 1580 if ( 'trash' === $post->post_status || ! EMPTY_TRASH_DAYS ) { 1581 $actions['delete'] = sprintf( 1582 '<a href="%s" class="submitdelete" aria-label="%s">%s</a>', 1583 get_delete_post_link( $post->ID, '', true ), 1584 /* translators: %s: Post title. */ 1585 esc_attr( sprintf( __( 'Delete “%s” permanently' ), $title ) ), 1586 __( 'Delete Permanently' ) 1587 ); 1588 } 1589 } 1590 1591 if ( is_post_type_viewable( $post_type_object ) ) { 1592 if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ), true ) ) { 1593 if ( $can_edit_post ) { 1594 $preview_link = get_preview_post_link( $post ); 1595 $actions['view'] = sprintf( 1596 '<a href="%s" rel="bookmark" aria-label="%s">%s</a>', 1597 esc_url( $preview_link ), 1598 /* translators: %s: Post title. */ 1599 esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ), 1600 _x( 'Preview', 'verb' ) 1601 ); 1602 } 1603 } elseif ( 'trash' !== $post->post_status ) { 1604 $actions['view'] = sprintf( 1605 '<a href="%s" rel="bookmark" aria-label="%s">%s</a>', 1606 get_permalink( $post->ID ), 1607 /* translators: %s: Post title. */ 1608 esc_attr( sprintf( __( 'View “%s”' ), $title ) ), 1609 __( 'View' ) 1610 ); 1611 } 1612 } 1613 1614 if ( 'wp_block' === $post->post_type ) { 1615 $actions['export'] = sprintf( 1616 '<button type="button" class="wp-list-reusable-blocks__export button-link" data-id="%s" aria-label="%s">%s</button>', 1617 $post->ID, 1618 /* translators: %s: Post title. */ 1619 esc_attr( sprintf( __( 'Export “%s” as JSON' ), $title ) ), 1620 __( 'Export as JSON' ) 1621 ); 1622 } 1623 1624 if ( is_post_type_hierarchical( $post->post_type ) ) { 1625 1626 /** 1627 * Filters the array of row action links on the Pages list table. 1628 * 1629 * The filter is evaluated only for hierarchical post types. 1630 * 1631 * @since 2.8.0 1632 * 1633 * @param string[] $actions An array of row action links. Defaults are 1634 * 'Edit', 'Quick Edit', 'Restore', 'Trash', 1635 * 'Delete Permanently', 'Preview', and 'View'. 1636 * @param WP_Post $post The post object. 1637 */ 1638 $actions = apply_filters( 'page_row_actions', $actions, $post ); 1639 } else { 1640 1641 /** 1642 * Filters the array of row action links on the Posts list table. 1643 * 1644 * The filter is evaluated only for non-hierarchical post types. 1645 * 1646 * @since 2.8.0 1647 * 1648 * @param string[] $actions An array of row action links. Defaults are 1649 * 'Edit', 'Quick Edit', 'Restore', 'Trash', 1650 * 'Delete Permanently', 'Preview', and 'View'. 1651 * @param WP_Post $post The post object. 1652 */ 1653 $actions = apply_filters( 'post_row_actions', $actions, $post ); 1654 } 1655 1656 return $this->row_actions( $actions ); 1657 } 1658 1659 /** 1660 * Outputs the hidden row displayed when inline editing 1661 * 1662 * @since 3.1.0 1663 * 1664 * @global string $mode List table view mode. 1665 */ 1666 public function inline_edit() { 1667 global $mode; 1668 1669 $screen = $this->screen; 1670 1671 $post = get_default_post_to_edit( $screen->post_type ); 1672 $post_type_object = get_post_type_object( $screen->post_type ); 1673 1674 $taxonomy_names = get_object_taxonomies( $screen->post_type ); 1675 $hierarchical_taxonomies = array(); 1676 $flat_taxonomies = array(); 1677 1678 foreach ( $taxonomy_names as $taxonomy_name ) { 1679 $taxonomy = get_taxonomy( $taxonomy_name ); 1680 1681 $show_in_quick_edit = $taxonomy->show_in_quick_edit; 1682 1683 /** 1684 * Filters whether the current taxonomy should be shown in the Quick Edit panel. 1685 * 1686 * @since 4.2.0 1687 * 1688 * @param bool $show_in_quick_edit Whether to show the current taxonomy in Quick Edit. 1689 * @param string $taxonomy_name Taxonomy name. 1690 * @param string $post_type Post type of current Quick Edit post. 1691 */ 1692 if ( ! apply_filters( 'quick_edit_show_taxonomy', $show_in_quick_edit, $taxonomy_name, $screen->post_type ) ) { 1693 continue; 1694 } 1695 1696 if ( $taxonomy->hierarchical ) { 1697 $hierarchical_taxonomies[] = $taxonomy; 1698 } else { 1699 $flat_taxonomies[] = $taxonomy; 1700 } 1701 } 1702 1703 $m = ( isset( $mode ) && 'excerpt' === $mode ) ? 'excerpt' : 'list'; 1704 $can_publish = current_user_can( $post_type_object->cap->publish_posts ); 1705 $core_columns = array( 1706 'cb' => true, 1707 'date' => true, 1708 'title' => true, 1709 'categories' => true, 1710 'tags' => true, 1711 'comments' => true, 1712 'author' => true, 1713 ); 1714 ?> 1715 1716 <form method="get"> 1717 <table style="display: none"><tbody id="inlineedit"> 1718 <?php 1719 $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page'; 1720 $inline_edit_classes = "inline-edit-row inline-edit-row-$hclass"; 1721 $bulk_edit_classes = "bulk-edit-row bulk-edit-row-$hclass bulk-edit-{$screen->post_type}"; 1722 $quick_edit_classes = "quick-edit-row quick-edit-row-$hclass inline-edit-{$screen->post_type}"; 1723 1724 $bulk = 0; 1725 1726 while ( $bulk < 2 ) : 1727 $classes = $inline_edit_classes . ' '; 1728 $classes .= $bulk ? $bulk_edit_classes : $quick_edit_classes; 1729 ?> 1730 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="<?php echo $classes; ?>" style="display: none"> 1731 <td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> 1732 <div class="inline-edit-wrapper" role="region" aria-labelledby="<?php echo $bulk ? 'bulk' : 'quick'; ?>-edit-legend"> 1733 <fieldset class="inline-edit-col-left"> 1734 <legend class="inline-edit-legend" id="<?php echo $bulk ? 'bulk' : 'quick'; ?>-edit-legend"><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></legend> 1735 <div class="inline-edit-col"> 1736 1737 <?php if ( post_type_supports( $screen->post_type, 'title' ) ) : ?> 1738 1739 <?php if ( $bulk ) : ?> 1740 1741 <div id="bulk-title-div"> 1742 <div id="bulk-titles"></div> 1743 </div> 1744 1745 <?php else : // $bulk ?> 1746 1747 <label> 1748 <span class="title"><?php _e( 'Title' ); ?></span> 1749 <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span> 1750 </label> 1751 1752 <?php if ( is_post_type_viewable( $screen->post_type ) ) : ?> 1753 1754 <label> 1755 <span class="title"><?php _e( 'Slug' ); ?></span> 1756 <span class="input-text-wrap"><input type="text" name="post_name" value="" autocomplete="off" spellcheck="false" /></span> 1757 </label> 1758 1759 <?php endif; // is_post_type_viewable() ?> 1760 1761 <?php endif; // $bulk ?> 1762 1763 <?php endif; // post_type_supports( ... 'title' ) ?> 1764 1765 <?php if ( ! $bulk ) : ?> 1766 <fieldset class="inline-edit-date"> 1767 <legend><span class="title"><?php _e( 'Date' ); ?></span></legend> 1768 <?php touch_time( 1, 1, 0, 1 ); ?> 1769 </fieldset> 1770 <br class="clear" /> 1771 <?php endif; // $bulk ?> 1772 1773 <?php 1774 if ( post_type_supports( $screen->post_type, 'author' ) ) { 1775 $authors_dropdown = ''; 1776 1777 if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) { 1778 $dropdown_name = 'post_author'; 1779 $dropdown_class = 'authors'; 1780 if ( wp_is_large_user_count() ) { 1781 $authors_dropdown = sprintf( '<select name="%s" class="%s hidden"></select>', esc_attr( $dropdown_name ), esc_attr( $dropdown_class ) ); 1782 } else { 1783 $users_opt = array( 1784 'hide_if_only_one_author' => false, 1785 'capability' => array( $post_type_object->cap->edit_posts ), 1786 'name' => $dropdown_name, 1787 'class' => $dropdown_class, 1788 'multi' => 1, 1789 'echo' => 0, 1790 'show' => 'display_name_with_login', 1791 ); 1792 1793 if ( $bulk ) { 1794 $users_opt['show_option_none'] = __( '— No Change —' ); 1795 } 1796 1797 /** 1798 * Filters the arguments used to generate the Quick Edit authors drop-down. 1799 * 1800 * @since 5.6.0 1801 * 1802 * @see wp_dropdown_users() 1803 * 1804 * @param array $users_opt An array of arguments passed to wp_dropdown_users(). 1805 * @param bool $bulk A flag to denote if it's a bulk action. 1806 */ 1807 $users_opt = apply_filters( 'quick_edit_dropdown_authors_args', $users_opt, $bulk ); 1808 1809 $authors = wp_dropdown_users( $users_opt ); 1810 1811 if ( $authors ) { 1812 $authors_dropdown = '<label class="inline-edit-author">'; 1813 $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>'; 1814 $authors_dropdown .= $authors; 1815 $authors_dropdown .= '</label>'; 1816 } 1817 } 1818 } // current_user_can( 'edit_others_posts' ) 1819 1820 if ( ! $bulk ) { 1821 echo $authors_dropdown; 1822 } 1823 } // post_type_supports( ... 'author' ) 1824 ?> 1825 1826 <?php if ( ! $bulk && $can_publish ) : ?> 1827 1828 <div class="inline-edit-group wp-clearfix"> 1829 <label class="alignleft"> 1830 <span class="title"><?php _e( 'Password' ); ?></span> 1831 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input ltr" value="" /></span> 1832 </label> 1833 1834 <span class="alignleft inline-edit-or"> 1835 <?php 1836 /* translators: Between password field and private checkbox on post quick edit interface. */ 1837 _e( '–OR–' ); 1838 ?> 1839 </span> 1840 <label class="alignleft inline-edit-private"> 1841 <input type="checkbox" name="keep_private" value="private" /> 1842 <span class="checkbox-title"><?php _e( 'Private' ); ?></span> 1843 </label> 1844 </div> 1845 1846 <?php endif; ?> 1847 1848 </div> 1849 </fieldset> 1850 1851 <?php if ( count( $hierarchical_taxonomies ) && ! $bulk ) : ?> 1852 1853 <fieldset class="inline-edit-col-center inline-edit-categories"> 1854 <div class="inline-edit-col"> 1855 1856 <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?> 1857 1858 <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ); ?></span> 1859 <input type="hidden" name="<?php echo ( 'category' === $taxonomy->name ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" /> 1860 <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name ); ?>-checklist"> 1861 <?php wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy->name ) ); ?> 1862 </ul> 1863 1864 <?php endforeach; // $hierarchical_taxonomies as $taxonomy ?> 1865 1866 </div> 1867 </fieldset> 1868 1869 <?php endif; // count( $hierarchical_taxonomies ) && ! $bulk ?> 1870 1871 <fieldset class="inline-edit-col-right"> 1872 <div class="inline-edit-col"> 1873 1874 <?php 1875 if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) { 1876 echo $authors_dropdown; 1877 } 1878 ?> 1879 1880 <?php if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) : ?> 1881 1882 <?php if ( $post_type_object->hierarchical ) : ?> 1883 1884 <label> 1885 <span class="title"><?php _e( 'Parent' ); ?></span> 1886 <?php 1887 $dropdown_args = array( 1888 'post_type' => $post_type_object->name, 1889 'selected' => $post->post_parent, 1890 'name' => 'post_parent', 1891 'show_option_none' => __( 'Main Page (no parent)' ), 1892 'option_none_value' => 0, 1893 'sort_column' => 'menu_order, post_title', 1894 ); 1895 1896 if ( $bulk ) { 1897 $dropdown_args['show_option_no_change'] = __( '— No Change —' ); 1898 $dropdown_args['id'] = 'bulk_edit_post_parent'; 1899 } 1900 1901 /** 1902 * Filters the arguments used to generate the Quick Edit page-parent drop-down. 1903 * 1904 * @since 2.7.0 1905 * @since 5.6.0 The `$bulk` parameter was added. 1906 * 1907 * @see wp_dropdown_pages() 1908 * 1909 * @param array $dropdown_args An array of arguments passed to wp_dropdown_pages(). 1910 * @param bool $bulk A flag to denote if it's a bulk action. 1911 */ 1912 $dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args, $bulk ); 1913 1914 wp_dropdown_pages( $dropdown_args ); 1915 ?> 1916 </label> 1917 1918 <?php endif; // hierarchical ?> 1919 1920 <?php if ( ! $bulk ) : ?> 1921 1922 <label> 1923 <span class="title"><?php _e( 'Order' ); ?></span> 1924 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order; ?>" /></span> 1925 </label> 1926 1927 <?php endif; // ! $bulk ?> 1928 1929 <?php endif; // post_type_supports( ... 'page-attributes' ) ?> 1930 1931 <?php if ( 0 < count( get_page_templates( null, $screen->post_type ) ) ) : ?> 1932 1933 <label> 1934 <span class="title"><?php _e( 'Template' ); ?></span> 1935 <select name="page_template"> 1936 <?php if ( $bulk ) : ?> 1937 <option value="-1"><?php _e( '— No Change —' ); ?></option> 1938 <?php endif; // $bulk ?> 1939 <?php 1940 /** This filter is documented in wp-admin/includes/meta-boxes.php */ 1941 $default_title = apply_filters( 'default_page_template_title', __( 'Default template' ), 'quick-edit' ); 1942 ?> 1943 <option value="default"><?php echo esc_html( $default_title ); ?></option> 1944 <?php page_template_dropdown( '', $screen->post_type ); ?> 1945 </select> 1946 </label> 1947 1948 <?php endif; ?> 1949 1950 <?php if ( count( $flat_taxonomies ) && ! $bulk ) : ?> 1951 1952 <?php foreach ( $flat_taxonomies as $taxonomy ) : ?> 1953 1954 <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?> 1955 <?php $taxonomy_name = esc_attr( $taxonomy->name ); ?> 1956 <div class="inline-edit-tags-wrap"> 1957 <label class="inline-edit-tags"> 1958 <span class="title"><?php echo esc_html( $taxonomy->labels->name ); ?></span> 1959 <textarea data-wp-taxonomy="<?php echo $taxonomy_name; ?>" cols="22" rows="1" name="tax_input[<?php echo esc_attr( $taxonomy->name ); ?>]" class="tax_input_<?php echo esc_attr( $taxonomy->name ); ?>" aria-describedby="inline-edit-<?php echo esc_attr( $taxonomy->name ); ?>-desc"></textarea> 1960 </label> 1961 <p class="howto" id="inline-edit-<?php echo esc_attr( $taxonomy->name ); ?>-desc"><?php echo esc_html( $taxonomy->labels->separate_items_with_commas ); ?></p> 1962 </div> 1963 <?php endif; // current_user_can( 'assign_terms' ) ?> 1964 1965 <?php endforeach; // $flat_taxonomies as $taxonomy ?> 1966 1967 <?php endif; // count( $flat_taxonomies ) && ! $bulk ?> 1968 1969 <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> 1970 1971 <?php if ( $bulk ) : ?> 1972 1973 <div class="inline-edit-group wp-clearfix"> 1974 1975 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> 1976 1977 <label class="alignleft"> 1978 <span class="title"><?php _e( 'Comments' ); ?></span> 1979 <select name="comment_status"> 1980 <option value=""><?php _e( '— No Change —' ); ?></option> 1981 <option value="open"><?php _e( 'Allow' ); ?></option> 1982 <option value="closed"><?php _e( 'Do not allow' ); ?></option> 1983 </select> 1984 </label> 1985 1986 <?php endif; ?> 1987 1988 <?php if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> 1989 1990 <label class="alignright"> 1991 <span class="title"><?php _e( 'Pings' ); ?></span> 1992 <select name="ping_status"> 1993 <option value=""><?php _e( '— No Change —' ); ?></option> 1994 <option value="open"><?php _e( 'Allow' ); ?></option> 1995 <option value="closed"><?php _e( 'Do not allow' ); ?></option> 1996 </select> 1997 </label> 1998 1999 <?php endif; ?> 2000 2001 </div> 2002 2003 <?php else : // $bulk ?> 2004 2005 <div class="inline-edit-group wp-clearfix"> 2006 2007 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> 2008 2009 <label class="alignleft"> 2010 <input type="checkbox" name="comment_status" value="open" /> 2011 <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span> 2012 </label> 2013 2014 <?php endif; ?> 2015 2016 <?php if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> 2017 2018 <label class="alignleft"> 2019 <input type="checkbox" name="ping_status" value="open" /> 2020 <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span> 2021 </label> 2022 2023 <?php endif; ?> 2024 2025 </div> 2026 2027 <?php endif; // $bulk ?> 2028 2029 <?php endif; // post_type_supports( ... comments or pings ) ?> 2030 2031 <div class="inline-edit-group wp-clearfix"> 2032 2033 <label class="inline-edit-status alignleft"> 2034 <span class="title"><?php _e( 'Status' ); ?></span> 2035 <select name="_status"> 2036 <?php 2037 $inline_edit_statuses = array(); 2038 if ( $bulk ) { 2039 $inline_edit_statuses['-1'] = __( '— No Change —' ); 2040 } 2041 // Contributors only get "Unpublished" and "Pending Review". 2042 if ( $can_publish ) { 2043 $inline_edit_statuses['publish'] = __( 'Published' ); 2044 $inline_edit_statuses['future'] = __( 'Scheduled' ); 2045 // There is already a checkbox for Private in Single Post Quick Edit. See #63612. 2046 if ( $bulk ) { 2047 $inline_edit_statuses['private'] = __( 'Private' ); 2048 } 2049 } 2050 2051 $inline_edit_statuses['pending'] = __( 'Pending Review' ); 2052 $inline_edit_statuses['draft'] = __( 'Draft' ); 2053 2054 /** 2055 * Filters the statuses available in the Quick Edit and Bulk Edit UI. 2056 * 2057 * @since 6.9.0 2058 * 2059 * @param array<string,string> $inline_edit_statuses An array of statuses available in the Quick Edit UI. 2060 * @param string $post_type The post type slug. 2061 * @param bool $bulk A flag to denote if it's a bulk action. 2062 * @param bool $can_publish A flag to denote if the user can publish posts. 2063 */ 2064 $inline_edit_statuses = apply_filters( 'quick_edit_statuses', $inline_edit_statuses, $screen->post_type, $bulk, $can_publish ); 2065 2066 foreach ( $inline_edit_statuses as $inline_status_value => $inline_status_text ) : 2067 ?> 2068 <option value="<?php echo esc_attr( $inline_status_value ); ?>"><?php echo esc_attr( $inline_status_text ); ?></option> 2069 <?php 2070 endforeach; 2071 ?> 2072 </select> 2073 </label> 2074 2075 <?php if ( 'post' === $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?> 2076 2077 <?php if ( $bulk ) : ?> 2078 2079 <label class="alignright"> 2080 <span class="title"><?php _e( 'Sticky' ); ?></span> 2081 <select name="sticky"> 2082 <option value="-1"><?php _e( '— No Change —' ); ?></option> 2083 <option value="sticky"><?php _e( 'Sticky' ); ?></option> 2084 <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option> 2085 </select> 2086 </label> 2087 2088 <?php else : // $bulk ?> 2089 2090 <label class="alignleft"> 2091 <input type="checkbox" name="sticky" value="sticky" /> 2092 <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span> 2093 </label> 2094 2095 <?php endif; // $bulk ?> 2096 2097 <?php endif; // 'post' && $can_publish && current_user_can( 'edit_others_posts' ) ?> 2098 2099 </div> 2100 2101 <?php if ( $bulk && current_theme_supports( 'post-formats' ) && post_type_supports( $screen->post_type, 'post-formats' ) ) : ?> 2102 <?php $post_formats = get_theme_support( 'post-formats' ); ?> 2103 2104 <label class="alignleft"> 2105 <span class="title"><?php _ex( 'Format', 'post format' ); ?></span> 2106 <select name="post_format"> 2107 <option value="-1"><?php _e( '— No Change —' ); ?></option> 2108 <option value="0"><?php echo get_post_format_string( 'standard' ); ?></option> 2109 <?php if ( is_array( $post_formats[0] ) ) : ?> 2110 <?php foreach ( $post_formats[0] as $format ) : ?> 2111 <option value="<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></option> 2112 <?php endforeach; ?> 2113 <?php endif; ?> 2114 </select> 2115 </label> 2116 2117 <?php endif; ?> 2118 2119 </div> 2120 </fieldset> 2121 2122 <?php 2123 list( $columns ) = $this->get_column_info(); 2124 2125 foreach ( $columns as $column_name => $column_display_name ) { 2126 if ( isset( $core_columns[ $column_name ] ) ) { 2127 continue; 2128 } 2129 2130 if ( $bulk ) { 2131 2132 /** 2133 * Fires once for each column in Bulk Edit mode. 2134 * 2135 * @since 2.7.0 2136 * 2137 * @param string $column_name Name of the column to edit. 2138 * @param string $post_type The post type slug. 2139 */ 2140 do_action( 'bulk_edit_custom_box', $column_name, $screen->post_type ); 2141 } else { 2142 2143 /** 2144 * Fires once for each column in Quick Edit mode. 2145 * 2146 * @since 2.7.0 2147 * 2148 * @param string $column_name Name of the column to edit. 2149 * @param string $post_type The post type slug, or current screen name if this is a taxonomy list table. 2150 * @param string $taxonomy The taxonomy name, if any. 2151 */ 2152 do_action( 'quick_edit_custom_box', $column_name, $screen->post_type, '' ); 2153 } 2154 } 2155 ?> 2156 2157 <div class="submit inline-edit-save"> 2158 <?php if ( ! $bulk ) : ?> 2159 <?php wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); ?> 2160 <button type="button" class="button button-primary save"><?php _e( 'Update' ); ?></button> 2161 <?php else : ?> 2162 <?php submit_button( __( 'Update' ), 'primary', 'bulk_edit', false ); ?> 2163 <?php endif; ?> 2164 2165 <button type="button" class="button cancel"><?php _e( 'Cancel' ); ?></button> 2166 2167 <?php if ( ! $bulk ) : ?> 2168 <span class="spinner"></span> 2169 <?php endif; ?> 2170 2171 <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" /> 2172 <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" /> 2173 <?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) : ?> 2174 <input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" /> 2175 <?php endif; ?> 2176 2177 <?php 2178 wp_admin_notice( 2179 '<p class="error"></p>', 2180 array( 2181 'type' => 'error', 2182 'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ), 2183 'paragraph_wrap' => false, 2184 ) 2185 ); 2186 ?> 2187 </div> 2188 </div> <!-- end of .inline-edit-wrapper --> 2189 2190 </td></tr> 2191 2192 <?php 2193 ++$bulk; 2194 endwhile; 2195 ?> 2196 </tbody></table> 2197 </form> 2198 <?php 2199 } 2200 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Tue Jul 21 08:20:16 2026 | Cross-referenced by PHPXref |