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


Generated : Sun Oct 25 08:20:35 2026 Cross-referenced by PHPXref