WordPress.org

Make WordPress Core

Changeset 28347


Ignore:
Timestamp:
05/08/14 08:15:48 (3 years ago)
Author:
DrewAPicture
Message:

Use an interpolated hook name for edit_{$post_type}_per_page instead of $per_page and adjust docs accordingly.

Also references the correct variable for the $posts_per_page parameter in the edit_posts_per_page hook doc.

Props Otto42 for the initial patch.
See #26869.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/post.php

    r28302 r28347  
    950950        $order = 'ASC'; 
    951951 
    952     $per_page = 'edit_' . $post_type . '_per_page'; 
     952    $per_page = "edit_{$post_type}_per_page"; 
    953953    $posts_per_page = (int) get_user_option( $per_page ); 
    954954    if ( empty( $posts_per_page ) || $posts_per_page < 1 ) 
     
    958958     * Filter the number of items per page to show for a specific 'per_page' type. 
    959959     * 
    960      * The dynamic hook name, $per_page, refers to a hook name comprised of the post type, 
    961      * preceded by 'edit_', and succeeded by '_per_page', e.g. 'edit_$post_type_per_page'. 
     960     * The dynamic portion of the hook name, $post_type, refers to the post type. 
    962961     * 
    963962     * Some examples of filter hooks generated here include: 'edit_attachment_per_page', 
     
    966965     * @since 3.0.0 
    967966     * 
    968      * @param int $posts_per_page Number of posts to display per page for the given 'per_page' 
     967     * @param int $posts_per_page Number of posts to display per page for the given post 
    969968     *                            type. Default 20. 
    970969     */ 
    971     $posts_per_page = apply_filters( $per_page, $posts_per_page ); 
     970    $posts_per_page = apply_filters( "edit_{$post_type}_per_page", $posts_per_page ); 
    972971 
    973972    /** 
     
    976975     * @since 2.8.0 
    977976     * 
    978      * @param int    $per_page Number of posts to be displayed. Default 20. 
    979      * @param string $post_type The post type. 
     977     * @param int    $posts_per_page Number of posts to be displayed. Default 20. 
     978     * @param string $post_type      The post type. 
    980979     */ 
    981980    $posts_per_page = apply_filters( 'edit_posts_per_page', $posts_per_page, $post_type ); 
Note: See TracChangeset for help on using the changeset viewer.