[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-admin/includes/ -> class-wp-posts-list-table.php (source)

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


Generated : Fri May 8 08:20:02 2026 Cross-referenced by PHPXref