| [ 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 $aria_label = $this->get_primary_column_aria_label( $post ); 1118 $aria_attr = ( '' !== $aria_label ) ? ' aria-label="' . esc_attr( $aria_label ) . '"' : ''; 1119 echo '<th scope="row" class="' . $classes . ' page-title" ', $data, $aria_attr, '>'; 1120 echo $this->column_title( $post ); 1121 echo $this->handle_row_actions( $post, 'title', $primary ); 1122 echo '</th>'; 1123 } 1124 1125 /** 1126 * Returns a clean label for the primary (title) column's row header `aria-label`. 1127 * 1128 * Provides screen readers with just the post title as the row header name, 1129 * preventing them from computing the name from the full cell content 1130 * (which includes row action links, post states, and possibly an excerpt). 1131 * 1132 * @since 6.9.0 1133 * 1134 * @param WP_Post $item The current post object. 1135 * @return string The post title, or 'no title' if no title. 1136 */ 1137 protected function get_primary_column_aria_label( $item ) { 1138 return isset( $item->post_title ) && ! empty( $item->post_title ) ? $item->post_title : __( 'no title' ); 1139 } 1140 1141 /** 1142 * Handles the title column output. 1143 * 1144 * @since 4.3.0 1145 * @since 7.1.0 Includes a trimmed excerpt for untitled posts in Compact view. 1146 * 1147 * @global string $mode List table view mode. 1148 * 1149 * @param WP_Post $post The current WP_Post object. 1150 */ 1151 public function column_title( $post ) { 1152 global $mode; 1153 1154 if ( $this->hierarchical_display ) { 1155 if ( 0 === $this->current_level && (int) $post->post_parent > 0 ) { 1156 // Sent level 0 by accident, by default, or because we don't know the actual level. 1157 $find_main_page = (int) $post->post_parent; 1158 1159 while ( $find_main_page > 0 ) { 1160 $parent = get_post( $find_main_page ); 1161 1162 if ( is_null( $parent ) ) { 1163 break; 1164 } 1165 1166 ++$this->current_level; 1167 $find_main_page = (int) $parent->post_parent; 1168 1169 if ( ! isset( $parent_name ) ) { 1170 /** This filter is documented in wp-includes/post-template.php */ 1171 $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID ); 1172 } 1173 } 1174 } 1175 } 1176 1177 $can_edit_post = current_user_can( 'edit_post', $post->ID ); 1178 1179 if ( $can_edit_post && 'trash' !== $post->post_status ) { 1180 $lock_holder = wp_check_post_lock( $post->ID ); 1181 1182 if ( $lock_holder ) { 1183 $lock_holder = get_userdata( $lock_holder ); 1184 $locked_avatar = get_avatar( $lock_holder->ID, 18 ); 1185 /* translators: %s: User's display name. */ 1186 $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) ); 1187 } else { 1188 $locked_avatar = ''; 1189 $locked_text = ''; 1190 } 1191 1192 echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n"; 1193 } 1194 1195 $pad = str_repeat( 1196 '<span aria-hidden="true">—</span> ', 1197 $this->current_level 1198 ); 1199 $described_by_attr = ''; 1200 $hierarchy_linked = ''; 1201 $hierarchy_nolink = ''; 1202 1203 if ( $post->post_parent ) { 1204 $parent = get_post( $post->post_parent ); 1205 1206 if ( $parent ) { 1207 /** This filter is documented in wp-includes/post-template.php */ 1208 $parent_title = apply_filters( 'the_title', $parent->post_title, $parent->ID ); 1209 1210 $hierarchy_id = 'post-hierarchy-' . $post->ID; 1211 $described_by_attr = sprintf( ' aria-describedby="%s"', esc_attr( $hierarchy_id ) ); 1212 $hierarchy_linked = sprintf( 1213 '<span id="%1$s" class="hidden">%2$s</span>', 1214 esc_attr( $hierarchy_id ), 1215 /* translators: %s: Parent post title. */ 1216 esc_html( sprintf( __( 'Child of %s' ), wp_strip_all_tags( $parent_title ) ) ) 1217 ); 1218 $hierarchy_nolink = sprintf( 1219 '<span id="%1$s" class="screen-reader-text"> (%2$s)</span>', 1220 esc_attr( $hierarchy_id ), 1221 /* translators: %s: Parent post title. */ 1222 esc_html( sprintf( __( 'Child of %s' ), wp_strip_all_tags( $parent_title ) ) ) 1223 ); 1224 } 1225 } 1226 1227 echo '<strong>'; 1228 1229 $title = _draft_or_post_title(); 1230 1231 // If the post has no title, try adding part of the excerpt. 1232 $no_title_excerpt = $this->get_no_title_excerpt( $post ); 1233 if ( '' !== $no_title_excerpt ) { 1234 $title .= ' <span class="trimmed-post-excerpt">' . $no_title_excerpt . '</span>'; 1235 } 1236 1237 if ( $can_edit_post && 'trash' !== $post->post_status ) { 1238 printf( 1239 '%1$s<a class="row-title" href="%2$s"%3$s>%4$s</a>%5$s', 1240 $pad, 1241 get_edit_post_link( $post->ID ), 1242 $described_by_attr, 1243 $title, 1244 $hierarchy_linked 1245 ); 1246 } else { 1247 printf( 1248 '%1$s<span>%2$s%3$s</span>', 1249 $pad, 1250 $title, 1251 $hierarchy_nolink 1252 ); 1253 } 1254 _post_states( $post ); 1255 1256 if ( isset( $parent_name ) ) { 1257 $post_type_object = get_post_type_object( $post->post_type ); 1258 echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name ); 1259 } 1260 1261 echo "</strong>\n"; 1262 1263 if ( 'excerpt' === $mode 1264 && ! is_post_type_hierarchical( $this->screen->post_type ) 1265 && current_user_can( 'read_post', $post->ID ) 1266 ) { 1267 if ( post_password_required( $post ) ) { 1268 echo '<span class="protected-post-excerpt">' . esc_html( get_the_excerpt() ) . '</span>'; 1269 } else { 1270 echo esc_html( get_the_excerpt() ); 1271 } 1272 } 1273 1274 /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */ 1275 $quick_edit_enabled = apply_filters( 'quick_edit_enabled_for_post_type', true, $post->post_type ); 1276 1277 if ( $quick_edit_enabled ) { 1278 get_inline_data( $post ); 1279 } 1280 } 1281 1282 /** 1283 * Handles the post date column output. 1284 * 1285 * @since 4.3.0 1286 * 1287 * @global string $mode List table view mode. 1288 * 1289 * @param WP_Post $post The current WP_Post object. 1290 */ 1291 public function column_date( $post ) { 1292 global $mode; 1293 1294 if ( '0000-00-00 00:00:00' === $post->post_date ) { 1295 $t_time = __( 'Unpublished' ); 1296 $time_diff = 0; 1297 } else { 1298 $t_time = sprintf( 1299 /* translators: 1: Post date, 2: Post time. */ 1300 __( '%1$s at %2$s' ), 1301 /* translators: Post date format. See https://www.php.net/manual/datetime.format.php */ 1302 get_the_time( __( 'Y/m/d' ), $post ), 1303 /* translators: Post time format. See https://www.php.net/manual/datetime.format.php */ 1304 get_the_time( __( 'g:i a' ), $post ) 1305 ); 1306 1307 $time = get_post_timestamp( $post ); 1308 $time_diff = time() - $time; 1309 } 1310 1311 if ( 'publish' === $post->post_status ) { 1312 $status = __( 'Published' ); 1313 } elseif ( 'future' === $post->post_status ) { 1314 if ( $time_diff > 0 ) { 1315 $status = '<strong class="error-message">' . __( 'Missed schedule' ) . '</strong>'; 1316 } else { 1317 $status = __( 'Scheduled' ); 1318 } 1319 } else { 1320 $status = __( 'Last Modified' ); 1321 } 1322 1323 /** 1324 * Filters the status text of the post. 1325 * 1326 * @since 4.8.0 1327 * 1328 * @param string $status The status text. 1329 * @param WP_Post $post Post object. 1330 * @param string $column_name The column name. 1331 * @param string $mode The list display mode ('excerpt' or 'list'). 1332 */ 1333 $status = apply_filters( 'post_date_column_status', $status, $post, 'date', $mode ); 1334 1335 if ( $status ) { 1336 echo $status . '<br />'; 1337 } 1338 1339 /** 1340 * Filters the published, scheduled, or unpublished time of the post. 1341 * 1342 * @since 2.5.1 1343 * @since 5.5.0 Removed the difference between 'excerpt' and 'list' modes. 1344 * The published time and date are both displayed now, 1345 * which is equivalent to the previous 'excerpt' mode. 1346 * 1347 * @param string $t_time The published time. 1348 * @param WP_Post $post Post object. 1349 * @param string $column_name The column name. 1350 * @param string $mode The list display mode ('excerpt' or 'list'). 1351 */ 1352 echo apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode ); 1353 } 1354 1355 /** 1356 * Handles the comments column output. 1357 * 1358 * @since 4.3.0 1359 * 1360 * @param WP_Post $post The current WP_Post object. 1361 */ 1362 public function column_comments( $post ) { 1363 ?> 1364 <div class="post-com-count-wrapper"> 1365 <?php 1366 $pending_comments = $this->comment_pending_count[ $post->ID ] ?? 0; 1367 1368 $this->comments_bubble( $post->ID, $pending_comments ); 1369 ?> 1370 </div> 1371 <?php 1372 } 1373 1374 /** 1375 * Handles the post author column output. 1376 * 1377 * @since 4.3.0 1378 * @since 6.8.0 Added fallback text when author's name is unknown. 1379 * 1380 * @param WP_Post $post The current WP_Post object. 1381 */ 1382 public function column_author( $post ) { 1383 $author = get_the_author(); 1384 1385 if ( ! empty( $author ) ) { 1386 $args = array( 1387 'post_type' => $post->post_type, 1388 'author' => get_the_author_meta( 'ID' ), 1389 ); 1390 echo $this->get_edit_link( $args, esc_html( $author ) ); 1391 } else { 1392 echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . __( '(no author)' ) . '</span>'; 1393 } 1394 } 1395 1396 /** 1397 * Handles the default column output. 1398 * 1399 * @since 4.3.0 1400 * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. 1401 * 1402 * @param WP_Post $item The current WP_Post object. 1403 * @param string $column_name The current column name. 1404 */ 1405 public function column_default( $item, $column_name ) { 1406 // Restores the more descriptive, specific name for use within this method. 1407 $post = $item; 1408 1409 if ( 'categories' === $column_name ) { 1410 $taxonomy = 'category'; 1411 } elseif ( 'tags' === $column_name ) { 1412 $taxonomy = 'post_tag'; 1413 } elseif ( str_starts_with( $column_name, 'taxonomy-' ) ) { 1414 $taxonomy = substr( $column_name, 9 ); 1415 } else { 1416 $taxonomy = false; 1417 } 1418 1419 if ( $taxonomy ) { 1420 $taxonomy_object = get_taxonomy( $taxonomy ); 1421 $terms = get_the_terms( $post->ID, $taxonomy ); 1422 1423 if ( is_array( $terms ) ) { 1424 $term_links = array(); 1425 1426 foreach ( $terms as $t ) { 1427 $posts_in_term_qv = array(); 1428 1429 if ( 'post' !== $post->post_type ) { 1430 $posts_in_term_qv['post_type'] = $post->post_type; 1431 } 1432 1433 if ( $taxonomy_object->query_var ) { 1434 $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug; 1435 } else { 1436 $posts_in_term_qv['taxonomy'] = $taxonomy; 1437 $posts_in_term_qv['term'] = $t->slug; 1438 } 1439 1440 $label = esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ); 1441 1442 $term_links[] = $this->get_edit_link( $posts_in_term_qv, $label ); 1443 } 1444 1445 /** 1446 * Filters the links in `$taxonomy` column of edit.php. 1447 * 1448 * @since 5.2.0 1449 * 1450 * @param string[] $term_links Array of term editing links. 1451 * @param string $taxonomy Taxonomy name. 1452 * @param WP_Term[] $terms Array of term objects appearing in the post row. 1453 */ 1454 $term_links = apply_filters( 'post_column_taxonomy_links', $term_links, $taxonomy, $terms ); 1455 1456 echo implode( wp_get_list_item_separator(), $term_links ); 1457 } else { 1458 echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . $taxonomy_object->labels->no_terms . '</span>'; 1459 } 1460 return; 1461 } 1462 1463 if ( is_post_type_hierarchical( $post->post_type ) ) { 1464 1465 /** 1466 * Fires in each custom column on the Posts list table. 1467 * 1468 * This hook only fires if the current post type is hierarchical, 1469 * such as pages. 1470 * 1471 * @since 2.5.0 1472 * 1473 * @param string $column_name The name of the column to display. 1474 * @param int $post_id The current post ID. 1475 */ 1476 do_action( 'manage_pages_custom_column', $column_name, $post->ID ); 1477 } else { 1478 1479 /** 1480 * Fires in each custom column in the Posts list table. 1481 * 1482 * This hook only fires if the current post type is non-hierarchical, 1483 * such as posts. 1484 * 1485 * @since 1.5.0 1486 * 1487 * @param string $column_name The name of the column to display. 1488 * @param int $post_id The current post ID. 1489 */ 1490 do_action( 'manage_posts_custom_column', $column_name, $post->ID ); 1491 } 1492 1493 /** 1494 * Fires for each custom column of a specific post type in the Posts list table. 1495 * 1496 * The dynamic portion of the hook name, `$post->post_type`, refers to the post type. 1497 * 1498 * Possible hook names include: 1499 * 1500 * - `manage_post_posts_custom_column` 1501 * - `manage_page_posts_custom_column` 1502 * 1503 * @since 3.1.0 1504 * 1505 * @param string $column_name The name of the column to display. 1506 * @param int $post_id The current post ID. 1507 */ 1508 do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID ); 1509 } 1510 1511 /** 1512 * @global WP_Post $post Global post object. 1513 * 1514 * @param int|WP_Post $post 1515 * @param int $level 1516 */ 1517 public function single_row( $post, $level = 0 ) { 1518 $global_post = get_post(); 1519 1520 $post = get_post( $post ); 1521 $this->current_level = $level; 1522 1523 $GLOBALS['post'] = $post; 1524 setup_postdata( $post ); 1525 1526 $classes = 'iedit author-' . ( get_current_user_id() === (int) $post->post_author ? 'self' : 'other' ); 1527 1528 $lock_holder = wp_check_post_lock( $post->ID ); 1529 1530 if ( $lock_holder ) { 1531 $classes .= ' wp-locked'; 1532 } 1533 1534 if ( $post->post_parent ) { 1535 $count = count( get_post_ancestors( $post->ID ) ); 1536 $classes .= ' level-' . $count; 1537 } else { 1538 $classes .= ' level-0'; 1539 } 1540 ?> 1541 <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>"> 1542 <?php $this->single_row_columns( $post ); ?> 1543 </tr> 1544 <?php 1545 $GLOBALS['post'] = $global_post; 1546 } 1547 1548 /** 1549 * Gets the name of the default primary column. 1550 * 1551 * @since 4.3.0 1552 * 1553 * @return string Name of the default primary column, in this case, 'title'. 1554 */ 1555 protected function get_default_primary_column_name() { 1556 return 'title'; 1557 } 1558 1559 /** 1560 * Generates and displays row action links. 1561 * 1562 * @since 4.3.0 1563 * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. 1564 * 1565 * @param WP_Post $item Post being acted upon. 1566 * @param string $column_name Current column name. 1567 * @param string $primary Primary column name. 1568 * @return string Row actions output for posts, or an empty string 1569 * if the current column is not the primary column. 1570 */ 1571 protected function handle_row_actions( $item, $column_name, $primary ) { 1572 if ( $primary !== $column_name ) { 1573 return ''; 1574 } 1575 1576 // Restores the more descriptive, specific name for use within this method. 1577 $post = $item; 1578 1579 $post_type_object = get_post_type_object( $post->post_type ); 1580 $can_edit_post = current_user_can( 'edit_post', $post->ID ); 1581 $actions = array(); 1582 $title = _draft_or_post_title(); 1583 1584 if ( $can_edit_post && 'trash' !== $post->post_status ) { 1585 $actions['edit'] = sprintf( 1586 '<a href="%s" aria-label="%s">%s</a>', 1587 get_edit_post_link( $post->ID ), 1588 /* translators: %s: Post title. */ 1589 esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ), 1590 __( 'Edit' ) 1591 ); 1592 1593 /** 1594 * Filters whether Quick Edit should be enabled for the given post type. 1595 * 1596 * @since 6.4.0 1597 * 1598 * @param bool $enable Whether to enable the Quick Edit functionality. Default true. 1599 * @param string $post_type Post type name. 1600 */ 1601 $quick_edit_enabled = apply_filters( 'quick_edit_enabled_for_post_type', true, $post->post_type ); 1602 1603 if ( $quick_edit_enabled && 'wp_block' !== $post->post_type ) { 1604 $actions['inline hide-if-no-js'] = sprintf( 1605 '<button type="button" class="button-link editinline" aria-label="%s" aria-expanded="false">%s</button>', 1606 /* translators: %s: Post title. */ 1607 esc_attr( sprintf( __( 'Quick edit “%s” inline' ), $title ) ), 1608 __( 'Quick Edit' ) 1609 ); 1610 } 1611 } 1612 1613 if ( current_user_can( 'delete_post', $post->ID ) ) { 1614 if ( 'trash' === $post->post_status ) { 1615 $actions['untrash'] = sprintf( 1616 '<a href="%s" aria-label="%s">%s</a>', 1617 wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ), 1618 /* translators: %s: Post title. */ 1619 esc_attr( sprintf( __( 'Restore “%s” from the Trash' ), $title ) ), 1620 __( 'Restore' ) 1621 ); 1622 } elseif ( EMPTY_TRASH_DAYS ) { 1623 $actions['trash'] = sprintf( 1624 '<a href="%s" class="submitdelete" aria-label="%s">%s</a>', 1625 get_delete_post_link( $post->ID ), 1626 /* translators: %s: Post title. */ 1627 esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $title ) ), 1628 _x( 'Trash', 'verb' ) 1629 ); 1630 } 1631 1632 if ( 'trash' === $post->post_status || ! EMPTY_TRASH_DAYS ) { 1633 $actions['delete'] = sprintf( 1634 '<a href="%s" class="submitdelete" aria-label="%s">%s</a>', 1635 get_delete_post_link( $post->ID, '', true ), 1636 /* translators: %s: Post title. */ 1637 esc_attr( sprintf( __( 'Delete “%s” permanently' ), $title ) ), 1638 __( 'Delete Permanently' ) 1639 ); 1640 } 1641 } 1642 1643 if ( is_post_type_viewable( $post_type_object ) ) { 1644 if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ), true ) ) { 1645 if ( $can_edit_post ) { 1646 $preview_link = get_preview_post_link( $post ); 1647 $actions['view'] = sprintf( 1648 '<a href="%s" rel="bookmark" aria-label="%s">%s</a>', 1649 esc_url( $preview_link ), 1650 /* translators: %s: Post title. */ 1651 esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ), 1652 _x( 'Preview', 'verb' ) 1653 ); 1654 } 1655 } elseif ( 'trash' !== $post->post_status ) { 1656 $actions['view'] = sprintf( 1657 '<a href="%s" rel="bookmark" aria-label="%s">%s</a>', 1658 get_permalink( $post->ID ), 1659 /* translators: %s: Post title. */ 1660 esc_attr( sprintf( __( 'View “%s”' ), $title ) ), 1661 __( 'View' ) 1662 ); 1663 } 1664 } 1665 1666 if ( 'wp_block' === $post->post_type ) { 1667 $actions['export'] = sprintf( 1668 '<button type="button" class="wp-list-reusable-blocks__export button-link" data-id="%s" aria-label="%s">%s</button>', 1669 $post->ID, 1670 /* translators: %s: Post title. */ 1671 esc_attr( sprintf( __( 'Export “%s” as JSON' ), $title ) ), 1672 __( 'Export as JSON' ) 1673 ); 1674 } 1675 1676 if ( is_post_type_hierarchical( $post->post_type ) ) { 1677 1678 /** 1679 * Filters the array of row action links on the Pages list table. 1680 * 1681 * The filter is evaluated only for hierarchical post types. 1682 * 1683 * @since 2.8.0 1684 * 1685 * @param string[] $actions An array of row action links. Defaults are 1686 * 'Edit', 'Quick Edit', 'Restore', 'Trash', 1687 * 'Delete Permanently', 'Preview', and 'View'. 1688 * @param WP_Post $post The post object. 1689 */ 1690 $actions = apply_filters( 'page_row_actions', $actions, $post ); 1691 } else { 1692 1693 /** 1694 * Filters the array of row action links on the Posts list table. 1695 * 1696 * The filter is evaluated only for non-hierarchical post types. 1697 * 1698 * @since 2.8.0 1699 * 1700 * @param string[] $actions An array of row action links. Defaults are 1701 * 'Edit', 'Quick Edit', 'Restore', 'Trash', 1702 * 'Delete Permanently', 'Preview', and 'View'. 1703 * @param WP_Post $post The post object. 1704 */ 1705 $actions = apply_filters( 'post_row_actions', $actions, $post ); 1706 } 1707 1708 return $this->row_actions( $actions ); 1709 } 1710 1711 /** 1712 * Outputs the hidden row displayed when inline editing 1713 * 1714 * @since 3.1.0 1715 * 1716 * @global string $mode List table view mode. 1717 */ 1718 public function inline_edit() { 1719 global $mode; 1720 1721 $screen = $this->screen; 1722 1723 $post = get_default_post_to_edit( $screen->post_type ); 1724 $post_type_object = get_post_type_object( $screen->post_type ); 1725 1726 $taxonomy_names = get_object_taxonomies( $screen->post_type ); 1727 $hierarchical_taxonomies = array(); 1728 $flat_taxonomies = array(); 1729 1730 foreach ( $taxonomy_names as $taxonomy_name ) { 1731 $taxonomy = get_taxonomy( $taxonomy_name ); 1732 1733 $show_in_quick_edit = $taxonomy->show_in_quick_edit; 1734 1735 /** 1736 * Filters whether the current taxonomy should be shown in the Quick Edit panel. 1737 * 1738 * @since 4.2.0 1739 * 1740 * @param bool $show_in_quick_edit Whether to show the current taxonomy in Quick Edit. 1741 * @param string $taxonomy_name Taxonomy name. 1742 * @param string $post_type Post type of current Quick Edit post. 1743 */ 1744 if ( ! apply_filters( 'quick_edit_show_taxonomy', $show_in_quick_edit, $taxonomy_name, $screen->post_type ) ) { 1745 continue; 1746 } 1747 1748 if ( $taxonomy->hierarchical ) { 1749 $hierarchical_taxonomies[] = $taxonomy; 1750 } else { 1751 $flat_taxonomies[] = $taxonomy; 1752 } 1753 } 1754 1755 $m = ( isset( $mode ) && 'excerpt' === $mode ) ? 'excerpt' : 'list'; 1756 $can_publish = current_user_can( $post_type_object->cap->publish_posts ); 1757 $core_columns = array( 1758 'cb' => true, 1759 'date' => true, 1760 'title' => true, 1761 'categories' => true, 1762 'tags' => true, 1763 'comments' => true, 1764 'author' => true, 1765 ); 1766 ?> 1767 1768 <form method="get"> 1769 <table style="display: none"><tbody id="inlineedit"> 1770 <?php 1771 $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page'; 1772 $inline_edit_classes = "inline-edit-row inline-edit-row-$hclass"; 1773 $bulk_edit_classes = "bulk-edit-row bulk-edit-row-$hclass bulk-edit-{$screen->post_type}"; 1774 $quick_edit_classes = "quick-edit-row quick-edit-row-$hclass inline-edit-{$screen->post_type}"; 1775 1776 $bulk = 0; 1777 1778 while ( $bulk < 2 ) : 1779 $classes = $inline_edit_classes . ' '; 1780 $classes .= $bulk ? $bulk_edit_classes : $quick_edit_classes; 1781 ?> 1782 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="<?php echo $classes; ?>" style="display: none"> 1783 <td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> 1784 <div class="inline-edit-wrapper" role="region" aria-labelledby="<?php echo $bulk ? 'bulk' : 'quick'; ?>-edit-legend"> 1785 <fieldset class="inline-edit-col-left"> 1786 <legend class="inline-edit-legend" id="<?php echo $bulk ? 'bulk' : 'quick'; ?>-edit-legend"><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></legend> 1787 <div class="inline-edit-col"> 1788 1789 <?php if ( post_type_supports( $screen->post_type, 'title' ) ) : ?> 1790 1791 <?php if ( $bulk ) : ?> 1792 1793 <div id="bulk-title-div"> 1794 <div id="bulk-titles"></div> 1795 </div> 1796 1797 <?php else : // $bulk ?> 1798 1799 <label> 1800 <span class="title"><?php _e( 'Title' ); ?></span> 1801 <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span> 1802 </label> 1803 1804 <?php if ( is_post_type_viewable( $screen->post_type ) ) : ?> 1805 1806 <label> 1807 <span class="title"><?php _e( 'Slug' ); ?></span> 1808 <span class="input-text-wrap"><input type="text" name="post_name" value="" autocomplete="off" spellcheck="false" /></span> 1809 </label> 1810 1811 <?php endif; // is_post_type_viewable() ?> 1812 1813 <?php endif; // $bulk ?> 1814 1815 <?php endif; // post_type_supports( ... 'title' ) ?> 1816 1817 <?php if ( ! $bulk ) : ?> 1818 <fieldset class="inline-edit-date"> 1819 <legend><span class="title"><?php _e( 'Date' ); ?></span></legend> 1820 <?php touch_time( 1, 1, 0, 1 ); ?> 1821 </fieldset> 1822 <br class="clear" /> 1823 <?php endif; // $bulk ?> 1824 1825 <?php 1826 if ( post_type_supports( $screen->post_type, 'author' ) ) { 1827 $authors_dropdown = ''; 1828 1829 if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) { 1830 $dropdown_name = 'post_author'; 1831 $dropdown_class = 'authors'; 1832 if ( wp_is_large_user_count() ) { 1833 $authors_dropdown = sprintf( '<select name="%s" class="%s hidden"></select>', esc_attr( $dropdown_name ), esc_attr( $dropdown_class ) ); 1834 } else { 1835 $users_opt = array( 1836 'hide_if_only_one_author' => false, 1837 'capability' => array( $post_type_object->cap->edit_posts ), 1838 'name' => $dropdown_name, 1839 'class' => $dropdown_class, 1840 'multi' => 1, 1841 'echo' => 0, 1842 'show' => 'display_name_with_login', 1843 ); 1844 1845 if ( $bulk ) { 1846 $users_opt['show_option_none'] = __( '— No Change —' ); 1847 } 1848 1849 /** 1850 * Filters the arguments used to generate the Quick Edit authors drop-down. 1851 * 1852 * @since 5.6.0 1853 * 1854 * @see wp_dropdown_users() 1855 * 1856 * @param array $users_opt An array of arguments passed to wp_dropdown_users(). 1857 * @param bool $bulk A flag to denote if it's a bulk action. 1858 */ 1859 $users_opt = apply_filters( 'quick_edit_dropdown_authors_args', $users_opt, $bulk ); 1860 1861 $authors = wp_dropdown_users( $users_opt ); 1862 1863 if ( $authors ) { 1864 $authors_dropdown = '<label class="inline-edit-author">'; 1865 $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>'; 1866 $authors_dropdown .= $authors; 1867 $authors_dropdown .= '</label>'; 1868 } 1869 } 1870 } // current_user_can( 'edit_others_posts' ) 1871 1872 if ( ! $bulk ) { 1873 echo $authors_dropdown; 1874 } 1875 } // post_type_supports( ... 'author' ) 1876 ?> 1877 1878 <?php if ( ! $bulk && $can_publish ) : ?> 1879 1880 <div class="inline-edit-group wp-clearfix"> 1881 <label class="alignleft"> 1882 <span class="title"><?php _e( 'Password' ); ?></span> 1883 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input ltr" value="" /></span> 1884 </label> 1885 1886 <span class="alignleft inline-edit-or"> 1887 <?php 1888 /* translators: Between password field and private checkbox on post quick edit interface. */ 1889 _e( '–OR–' ); 1890 ?> 1891 </span> 1892 <label class="alignleft inline-edit-private"> 1893 <input type="checkbox" name="keep_private" value="private" /> 1894 <span class="checkbox-title"><?php _e( 'Private' ); ?></span> 1895 </label> 1896 </div> 1897 1898 <?php endif; ?> 1899 1900 </div> 1901 </fieldset> 1902 1903 <?php if ( count( $hierarchical_taxonomies ) && ! $bulk ) : ?> 1904 1905 <fieldset class="inline-edit-col-center inline-edit-categories"> 1906 <div class="inline-edit-col"> 1907 1908 <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?> 1909 1910 <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ); ?></span> 1911 <input type="hidden" name="<?php echo ( 'category' === $taxonomy->name ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" /> 1912 <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name ); ?>-checklist"> 1913 <?php wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy->name ) ); ?> 1914 </ul> 1915 1916 <?php endforeach; // $hierarchical_taxonomies as $taxonomy ?> 1917 1918 </div> 1919 </fieldset> 1920 1921 <?php endif; // count( $hierarchical_taxonomies ) && ! $bulk ?> 1922 1923 <fieldset class="inline-edit-col-right"> 1924 <div class="inline-edit-col"> 1925 1926 <?php 1927 if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) { 1928 echo $authors_dropdown; 1929 } 1930 ?> 1931 1932 <?php if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) : ?> 1933 1934 <?php if ( $post_type_object->hierarchical ) : ?> 1935 1936 <label> 1937 <span class="title"><?php _e( 'Parent' ); ?></span> 1938 <?php 1939 $dropdown_args = array( 1940 'post_type' => $post_type_object->name, 1941 'selected' => $post->post_parent, 1942 'name' => 'post_parent', 1943 'show_option_none' => __( 'Main Page (no parent)' ), 1944 'option_none_value' => 0, 1945 'sort_column' => 'menu_order, post_title', 1946 ); 1947 1948 if ( $bulk ) { 1949 $dropdown_args['show_option_no_change'] = __( '— No Change —' ); 1950 $dropdown_args['id'] = 'bulk_edit_post_parent'; 1951 } 1952 1953 /** 1954 * Filters the arguments used to generate the Quick Edit page-parent drop-down. 1955 * 1956 * @since 2.7.0 1957 * @since 5.6.0 The `$bulk` parameter was added. 1958 * 1959 * @see wp_dropdown_pages() 1960 * 1961 * @param array $dropdown_args An array of arguments passed to wp_dropdown_pages(). 1962 * @param bool $bulk A flag to denote if it's a bulk action. 1963 */ 1964 $dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args, $bulk ); 1965 1966 wp_dropdown_pages( $dropdown_args ); 1967 ?> 1968 </label> 1969 1970 <?php endif; // hierarchical ?> 1971 1972 <?php if ( ! $bulk ) : ?> 1973 1974 <label> 1975 <span class="title"><?php _e( 'Order' ); ?></span> 1976 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order; ?>" /></span> 1977 </label> 1978 1979 <?php endif; // ! $bulk ?> 1980 1981 <?php endif; // post_type_supports( ... 'page-attributes' ) ?> 1982 1983 <?php if ( 0 < count( get_page_templates( null, $screen->post_type ) ) ) : ?> 1984 1985 <label> 1986 <span class="title"><?php _e( 'Template' ); ?></span> 1987 <select name="page_template"> 1988 <?php if ( $bulk ) : ?> 1989 <option value="-1"><?php _e( '— No Change —' ); ?></option> 1990 <?php endif; // $bulk ?> 1991 <?php 1992 /** This filter is documented in wp-admin/includes/meta-boxes.php */ 1993 $default_title = apply_filters( 'default_page_template_title', __( 'Default template' ), 'quick-edit' ); 1994 ?> 1995 <option value="default"><?php echo esc_html( $default_title ); ?></option> 1996 <?php page_template_dropdown( '', $screen->post_type ); ?> 1997 </select> 1998 </label> 1999 2000 <?php endif; ?> 2001 2002 <?php if ( count( $flat_taxonomies ) && ! $bulk ) : ?> 2003 2004 <?php foreach ( $flat_taxonomies as $taxonomy ) : ?> 2005 2006 <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?> 2007 <?php $taxonomy_name = esc_attr( $taxonomy->name ); ?> 2008 <div class="inline-edit-tags-wrap"> 2009 <label class="inline-edit-tags"> 2010 <span class="title"><?php echo esc_html( $taxonomy->labels->name ); ?></span> 2011 <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> 2012 </label> 2013 <p class="howto" id="inline-edit-<?php echo esc_attr( $taxonomy->name ); ?>-desc"><?php echo esc_html( $taxonomy->labels->separate_items_with_commas ); ?></p> 2014 </div> 2015 <?php endif; // current_user_can( 'assign_terms' ) ?> 2016 2017 <?php endforeach; // $flat_taxonomies as $taxonomy ?> 2018 2019 <?php endif; // count( $flat_taxonomies ) && ! $bulk ?> 2020 2021 <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> 2022 2023 <?php if ( $bulk ) : ?> 2024 2025 <div class="inline-edit-group wp-clearfix"> 2026 2027 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> 2028 2029 <label class="alignleft"> 2030 <span class="title"><?php _e( 'Comments' ); ?></span> 2031 <select name="comment_status"> 2032 <option value=""><?php _e( '— No Change —' ); ?></option> 2033 <option value="open"><?php _e( 'Allow' ); ?></option> 2034 <option value="closed"><?php _e( 'Do not allow' ); ?></option> 2035 </select> 2036 </label> 2037 2038 <?php endif; ?> 2039 2040 <?php if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> 2041 2042 <label class="alignright"> 2043 <span class="title"><?php _e( 'Pings' ); ?></span> 2044 <select name="ping_status"> 2045 <option value=""><?php _e( '— No Change —' ); ?></option> 2046 <option value="open"><?php _e( 'Allow' ); ?></option> 2047 <option value="closed"><?php _e( 'Do not allow' ); ?></option> 2048 </select> 2049 </label> 2050 2051 <?php endif; ?> 2052 2053 </div> 2054 2055 <?php else : // $bulk ?> 2056 2057 <div class="inline-edit-group wp-clearfix"> 2058 2059 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> 2060 2061 <label class="alignleft"> 2062 <input type="checkbox" name="comment_status" value="open" /> 2063 <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span> 2064 </label> 2065 2066 <?php endif; ?> 2067 2068 <?php if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> 2069 2070 <label class="alignleft"> 2071 <input type="checkbox" name="ping_status" value="open" /> 2072 <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span> 2073 </label> 2074 2075 <?php endif; ?> 2076 2077 </div> 2078 2079 <?php endif; // $bulk ?> 2080 2081 <?php endif; // post_type_supports( ... comments or pings ) ?> 2082 2083 <div class="inline-edit-group wp-clearfix"> 2084 2085 <label class="inline-edit-status alignleft"> 2086 <span class="title"><?php _e( 'Status' ); ?></span> 2087 <select name="_status"> 2088 <?php 2089 $inline_edit_statuses = array(); 2090 if ( $bulk ) { 2091 $inline_edit_statuses['-1'] = __( '— No Change —' ); 2092 } 2093 // Contributors only get "Unpublished" and "Pending Review". 2094 if ( $can_publish ) { 2095 $inline_edit_statuses['publish'] = __( 'Published' ); 2096 $inline_edit_statuses['future'] = __( 'Scheduled' ); 2097 // There is already a checkbox for Private in Single Post Quick Edit. See #63612. 2098 if ( $bulk ) { 2099 $inline_edit_statuses['private'] = __( 'Private' ); 2100 } 2101 } 2102 2103 $inline_edit_statuses['pending'] = __( 'Pending Review' ); 2104 $inline_edit_statuses['draft'] = __( 'Draft' ); 2105 2106 /** 2107 * Filters the statuses available in the Quick Edit and Bulk Edit UI. 2108 * 2109 * @since 6.9.0 2110 * 2111 * @param array<string,string> $inline_edit_statuses An array of statuses available in the Quick Edit UI. 2112 * @param string $post_type The post type slug. 2113 * @param bool $bulk A flag to denote if it's a bulk action. 2114 * @param bool $can_publish A flag to denote if the user can publish posts. 2115 */ 2116 $inline_edit_statuses = apply_filters( 'quick_edit_statuses', $inline_edit_statuses, $screen->post_type, $bulk, $can_publish ); 2117 2118 foreach ( $inline_edit_statuses as $inline_status_value => $inline_status_text ) : 2119 ?> 2120 <option value="<?php echo esc_attr( $inline_status_value ); ?>"><?php echo esc_attr( $inline_status_text ); ?></option> 2121 <?php 2122 endforeach; 2123 ?> 2124 </select> 2125 </label> 2126 2127 <?php if ( 'post' === $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?> 2128 2129 <?php if ( $bulk ) : ?> 2130 2131 <label class="alignright"> 2132 <span class="title"><?php _e( 'Sticky' ); ?></span> 2133 <select name="sticky"> 2134 <option value="-1"><?php _e( '— No Change —' ); ?></option> 2135 <option value="sticky"><?php _e( 'Sticky' ); ?></option> 2136 <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option> 2137 </select> 2138 </label> 2139 2140 <?php else : // $bulk ?> 2141 2142 <label class="alignleft"> 2143 <input type="checkbox" name="sticky" value="sticky" /> 2144 <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span> 2145 </label> 2146 2147 <?php endif; // $bulk ?> 2148 2149 <?php endif; // 'post' && $can_publish && current_user_can( 'edit_others_posts' ) ?> 2150 2151 </div> 2152 2153 <?php if ( $bulk && current_theme_supports( 'post-formats' ) && post_type_supports( $screen->post_type, 'post-formats' ) ) : ?> 2154 <?php $post_formats = get_theme_support( 'post-formats' ); ?> 2155 2156 <label class="alignleft"> 2157 <span class="title"><?php _ex( 'Format', 'post format' ); ?></span> 2158 <select name="post_format"> 2159 <option value="-1"><?php _e( '— No Change —' ); ?></option> 2160 <option value="0"><?php echo get_post_format_string( 'standard' ); ?></option> 2161 <?php if ( is_array( $post_formats[0] ) ) : ?> 2162 <?php foreach ( $post_formats[0] as $format ) : ?> 2163 <option value="<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></option> 2164 <?php endforeach; ?> 2165 <?php endif; ?> 2166 </select> 2167 </label> 2168 2169 <?php endif; ?> 2170 2171 </div> 2172 </fieldset> 2173 2174 <?php 2175 list( $columns ) = $this->get_column_info(); 2176 2177 foreach ( $columns as $column_name => $column_display_name ) { 2178 if ( isset( $core_columns[ $column_name ] ) ) { 2179 continue; 2180 } 2181 2182 if ( $bulk ) { 2183 2184 /** 2185 * Fires once for each column in Bulk Edit mode. 2186 * 2187 * @since 2.7.0 2188 * 2189 * @param string $column_name Name of the column to edit. 2190 * @param string $post_type The post type slug. 2191 */ 2192 do_action( 'bulk_edit_custom_box', $column_name, $screen->post_type ); 2193 } else { 2194 2195 /** 2196 * Fires once for each column in Quick Edit mode. 2197 * 2198 * @since 2.7.0 2199 * 2200 * @param string $column_name Name of the column to edit. 2201 * @param string $post_type The post type slug, or current screen name if this is a taxonomy list table. 2202 * @param string $taxonomy The taxonomy name, if any. 2203 */ 2204 do_action( 'quick_edit_custom_box', $column_name, $screen->post_type, '' ); 2205 } 2206 } 2207 ?> 2208 2209 <div class="submit inline-edit-save"> 2210 <?php if ( ! $bulk ) : ?> 2211 <?php wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); ?> 2212 <button type="button" class="button button-primary save"><?php _e( 'Update' ); ?></button> 2213 <?php else : ?> 2214 <?php submit_button( __( 'Update' ), 'primary', 'bulk_edit', false ); ?> 2215 <?php endif; ?> 2216 2217 <button type="button" class="button cancel"><?php _e( 'Cancel' ); ?></button> 2218 2219 <?php if ( ! $bulk ) : ?> 2220 <span class="spinner"></span> 2221 <?php endif; ?> 2222 2223 <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" /> 2224 <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" /> 2225 <?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) : ?> 2226 <input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" /> 2227 <?php endif; ?> 2228 2229 <?php 2230 wp_admin_notice( 2231 '<p class="error"></p>', 2232 array( 2233 'type' => 'error', 2234 'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ), 2235 'paragraph_wrap' => false, 2236 ) 2237 ); 2238 ?> 2239 </div> 2240 </div> <!-- end of .inline-edit-wrapper --> 2241 2242 </td></tr> 2243 2244 <?php 2245 ++$bulk; 2246 endwhile; 2247 ?> 2248 </tbody></table> 2249 </form> 2250 <?php 2251 } 2252 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Mon Jul 27 08:20:18 2026 | Cross-referenced by PHPXref |