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


Generated : Thu Apr 10 08:20:01 2025 Cross-referenced by PHPXref