WP_Posts_List_Table::get_views() –

You appear to be a bot. Output may be restricted

Description

Usage

$array = WP_Posts_List_Table::get_views();

Parameters

Returns

array

Source

File name: wordpress/wp-admin/includes/class-wp-posts-list-table.php
Lines:

1 to 100 of 139
  protected function get_views() {
    global $locked_post_status, $avail_post_stati;

    $post_type = $this->screen->post_type;

    if ( ! empty( $locked_post_status ) ) {
      return array();
    }

    $status_links = array();
    $num_posts    = wp_count_posts( $post_type, 'readable' );
    $total_posts  = array_sum( (array) $num_posts );
    $class        = '';

    $current_user_id = get_current_user_id();
    $all_args        = array( 'post_type' => $post_type );
    $mine            = '';

    // Subtract post types that are not included in the admin all list.
    foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) {
      $total_posts -= $num_posts->$state;
    }

    if ( $this->user_posts_count && $this->user_posts_count !== $total_posts ) {
      if ( isset( $_GET['author'] ) && ( $current_user_id === (int) $_GET['author'] ) ) {
        $class = 'current';
      }

      $mine_args = array(
        'post_type' => $post_type,
        'author'    => $current_user_id,
      );

      $mine_inner_html = sprintf(
        /* translators: %s: Number of posts. */
        _nx(
          'Mine <span class="count">(%s)</span>',
          'Mine <span class="count">(%s)</span>',
          $this->user_posts_count,
          'posts'
        ),
        number_format_i18n( $this->user_posts_count )
      );

      $mine = array(
        'url'     => esc_url( add_query_arg( $mine_args, 'edit.php' ) ),
        'label'   => $mine_inner_html,
        'current' => isset( $_GET['author'] ) && ( $current_user_id === (int) $_GET['author'] ),
      );

      $all_args['all_posts'] = 1;
      $class                 = '';
    }

    $all_inner_html = sprintf(
      /* translators: %s: Number of posts. */
      _nx(
        'All <span class="count">(%s)</span>',
        'All <span class="count">(%s)</span>',
        $total_posts,
        'posts'
      ),
      number_format_i18n( $total_posts )
    );

    $status_links['all'] = array(
      'url'     => esc_url( add_query_arg( $all_args, 'edit.php' ) ),
      'label'   => $all_inner_html,
      'current' => empty( $class ) && ( $this->WP_Posts_List_Table::is_base_request() || isset( $_REQUEST['all_posts'] ) ),
    );

    if ( $mine ) {
      $status_links['mine'] = $mine;
    }

    foreach ( get_post_stati( array( 'show_in_admin_status_list' => true ), 'objects' ) as $status ) {
      $class = '';

      $status_name = $status->name;

      if ( ! in_array( $status_name, $avail_post_stati, true ) || empty( $num_posts->$status_name ) ) {
        continue;
      }

      if ( isset( $_REQUEST['post_status'] ) && $status_name === $_REQUEST['post_status'] ) {
        $class = 'current';
      }

      $status_args = array(
        'post_status' => $status_name,
        'post_type'   => $post_type,
      );

      $status_label = sprintf(
        translate_nooped_plural( $status->label_count, $num_posts->$status_name ),
        number_format_i18n( $num_posts->$status_name )
      );

      $status_links[ $status_name ] = array(
        'url'     => esc_url( add_query_arg( $status_args, 'edit.php' ) ),
 

 View on GitHub View on Trac