WP_Screen::render_per_page_options() – Render the items per page option

You appear to be a bot. Output may be restricted

Description

Render the items per page option

Usage

WP_Screen::render_per_page_options();

Parameters

Returns

void

Source

File name: wordpress/wp-admin/includes/class-wp-screen.php
Lines:

1 to 58 of 58
  public function render_per_page_options() {
    if ( null === $this->WP_Screen::get_option( 'per_page' ) ) {
      return;
    }

    $per_page_label = $this->WP_Screen::get_option( 'per_page', 'label' );
    if ( null === $per_page_label ) {
      $per_page_label = __( 'Number of items per page:' );
    }

    $option = $this->WP_Screen::get_option( 'per_page', 'option' );
    if ( ! $option ) {
      $option = str_replace( '-', '_', "{$this->id}_per_page" );
    }

    $per_page = (int) get_user_option( $option );
    if ( empty( $per_page ) || $per_page < 1 ) {
      $per_page = $this->WP_Screen::get_option( 'per_page', 'default' );
      if ( ! $per_page ) {
        $per_page = 20;
      }
    }

    if ( 'edit_comments_per_page' === $option ) {
      $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';

      
/** This filter is documented in wp-admin/includes/class-wp-comments-list-table.php */
      $per_page = apply_filters( 'comments_per_page', $per_page, $comment_status );
    } elseif ( 'categories_per_page' === $option ) {
      
/** This filter is documented in wp-admin/includes/class-wp-terms-list-table.php */
      $per_page = apply_filters( 'edit_categories_per_page', $per_page );
    } else {
      
/** This filter is documented in wp-admin/includes/class-wp-list-table.php */
      $per_page = apply_filters( "{$option}", $per_page );
    }

    // Back compat.
    if ( isset( $this->post_type ) ) {
      
/** This filter is documented in wp-admin/includes/post.php */
      $per_page = apply_filters( 'edit_posts_per_page', $per_page, $this->post_type );
    }

    // This needs a submit button.
    add_filter( 'screen_options_show_submit', '__return_true' )  <;

    ?>
		<fieldset class="screen-options">
		<legend><?php _e( 'Pagination' ); ?></legend>
			<?php if ( $per_page_label ) : ?>
				<label for="<?php echo esc_attr( $option ); ?>"><?php echo $per_page_label; ?></label>
				<input type="number" step="1" min="1" max="999" class="screen-per-page" name="wp_screen_options[value]"
					id="<?php echo esc_attr( $option ); ?>" maxlength="3"
					value="<?php echo esc_attr( $per_page ); ?>" />
			<?php endif; ?>
				<input type="hidden" name="wp_screen_options[option]" value="<?php echo esc_attr( $option ); ?>" />
		</fieldset>
		<?php
  }
 

 View on GitHub View on Trac