WordPress.org

Plugin Directory

Changeset 528367


Ignore:
Timestamp:
04/07/12 05:46:40 (2 years ago)
Author:
jeremyfelt
Message:

Finally move Custom Posts Per Page into a class of it's own.

Now it can be happy with its existence and not have to worry as much about conflicting in the global namespace.

Also, cleanup a bunch of code to meet standards, comment a lot of stuff, and handle default options *just* that much smarter.

Location:
custom-posts-per-page/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • custom-posts-per-page/trunk/custom-posts-per-page.php

    r496612 r528367  
    44Plugin URI: http://www.jeremyfelt.com/wordpress/plugins/custom-posts-per-page/ 
    55Description: Shows a custom set number of posts depending on the type of page being viewed. 
    6 Version: 1.4 
     6Version: 1.5 
    77Author: Jeremy Felt 
    88Author URI: http://www.jeremyfelt.com 
     
    2828*/ 
    2929 
    30 $jf_cpppc_page_count_offset = 0; 
    31  
    32 register_activation_hook( __FILE__, 'cpppc_check_and_upgrade' ); 
    33  
    34 if ( is_admin() ) { 
    35     /*  If we're on the admin screen, we'll want to make sure that 
    36             the appropriate settings are showing up. */ 
    37     add_action( 'admin_init', 'cpppc_check_and_upgrade' ); 
    38     add_action( 'admin_menu', 'cpppc_add_settings' ); 
    39     add_action( 'admin_init', 'cpppc_register_settings' ); 
    40     add_action( 'admin_init', 'cpppc_add_languages' ); 
    41  
    42     /*  Provide a good looking 'settings' link when the plugin is activated. */ 
    43     add_filter( 'plugin_action_links', 'cpppc_plugin_action_links', 10, 2 ); 
    44 } else { 
    45     /* If we're on any page other than the admin screen, we'll add our 
    46          * request modification. If this filter is used on the admin screen, 
    47          * the number of posts shown is changed there as well. Not ideal unless 
    48          * we're planning on it. :) 
    49          */ 
    50     add_action( 'pre_get_posts', 'jf_cpppc_modify_query' ); 
    51 } 
    52  
    53 function cpppc_add_languages() { 
    54     $plugin_dir = basename( dirname(__FILE__) ) . '/lang'; 
    55     load_plugin_textdomain( 'custom-posts-per-page', false, $plugin_dir ); 
    56 } 
    57  
    58 function cpppc_check_and_upgrade() { 
    59     if ( ! get_option( 'cpppc_upgrade' ) || '1.3' == get_option( 'cpppc_upgrade' ) ) { 
    60         cpppc_activate(); 
    61  
    62         $cpppc_options = get_option( 'cpppc_options' ); 
    63  
    64         if ( isset( $cpppc_options[ 'front_page_count' ] ) ) { 
    65             $cpppc_options[ 'front_count' ] = $cpppc_options[ 'front_page_count' ]; 
    66             unset( $cpppc_options[ 'front_page_count' ] ); 
    67         } 
    68  
    69         if ( isset( $cpppc_options[ 'index_count' ] ) ) { 
    70             $cpppc_options[ 'front_count_paged' ] = $cpppc_options[ 'index_count' ]; 
    71             unset( $cpppc_options[ 'index_count' ] ); 
    72         } 
    73  
    74         update_option( 'cpppc_options', $cpppc_options ); 
    75         update_option( 'cpppc_upgrade', '1.4' ); 
    76     } 
    77 } 
    78  
    79 function cpppc_activate() { 
    80     /*  When the plugin is first activated, we'll set some default values in an options array. We'll 
    81      *  pull the default value from the current Reading setting for 'posts_per_page' so that nothing 
    82      *  changes unexpectedly. */ 
    83     $default_count   = get_option( 'posts_per_page' ); 
    84     $current_options = get_option( 'cpppc_options' ); 
    85     $default_options = array(); 
    86  
    87     $option_type_array = array( 'front', 'category', 'tag', 'author', 'archive', 'search', 'default' ); 
    88  
    89     foreach ( $option_type_array as $option_type ) { 
    90         $default_options[ $option_type . '_count' ] = $default_count; 
    91         /*  If the user has already set an option for one of the existing views, we don't want the 
    92          *  paged views to act differently all of a sudden. We'll match those existing values before 
    93          *  going with the default. */ 
    94         $default_options[ $option_type . '_count_paged' ] = isset( $current_options[ $option_type . '_count' ] ) ? $current_options[ $option_type . '_count' ] : $default_count; 
    95     } 
    96  
    97     /*  We'll also get all of the currently registered custom post types and give them a default value 
    98      *  of 0 if one has not previously been set. Custom post types are a special breed and we don't 
    99      *  necessarily want them to match the default posts_per_page value without a conscious decision 
    100      *  by the user. */ 
    101     $all_post_types = get_post_types( array( '_builtin' => false ) ); 
    102     foreach ( $all_post_types as $p => $k ) { 
    103         $default_options[ $p . '_count' ]       = isset( $current_options[ $p . '_count' ] ) ? $current_options[ $p . '_count' ] : 0; 
    104         $default_options[ $p . '_count_paged' ] = isset( $current_options[ $p . '_count' ] ) ? $current_options[ $p . '_count' ] : 0; 
    105     } 
    106  
    107     /*  Compare existing options with default options and assign accordingly. */ 
    108     $cpppc_options = wp_parse_args( $current_options, $default_options ); 
    109  
    110     update_option( 'cpppc_options', $cpppc_options ); 
    111 } 
    112  
    113 function cpppc_plugin_action_links( $links, $file ) { 
    114     /*  Function gratefully taken (and barely modified) from Pippin Williamson's 
    115      *  WPMods article: http://www.wpmods.com/adding-plugin-action-links/ */ 
    116     static $this_plugin; 
    117  
    118     if ( !$this_plugin ) 
    119         $this_plugin = plugin_basename( __FILE__ ); 
    120  
    121     /*  Make sure we are on the correct plugin */ 
    122     if ( $file == $this_plugin ) { 
    123         $settings_path = '/wp-admin/options-general.php?page=post-count-settings'; 
    124         $settings_link = '<a href="' . get_bloginfo( 'wpurl' ) . $settings_path . '">' . __('Settings', 'custom-posts-per-page') . '</a>'; 
    125         array_unshift( $links, $settings_link ); // add the link to the list 
    126     } 
    127     return $links; 
    128 } 
    129  
    130 function cpppc_add_settings() { 
    131     /*  Add the sub-menu item under the Settings top-level menu. */ 
    132     add_options_page( __('Posts Per Page', 'custom-posts-per-page'), __('Posts Per Page', 'custom-posts-per-page'), 'manage_options', 'post-count-settings', 'cpppc_view_settings' ); 
    133 } 
    134  
    135 function cpppc_view_settings() { 
    136     /*  Display the main settings view for Custom Posts Per Page. */ 
    137     echo '<div class="wrap"> 
    138         <div class="icon32" id="icon-options-general"></div> 
    139             <h2>' . __('Custom Posts Per Page', 'custom-posts-per-page') . '</h2> 
    140             <h3>' . __('Overview', 'custom-posts-per-page') . ':</h3> 
    141             <p style="margin-left:12px;max-width:640px;">' . __('The settings below allow you to specify how many posts per 
    142             page are displayed to readers depending on the which type of page is being viewed.</p> 
    143             <p style="margin-left:12px;max-width:640px;">Different values can 
    144             be set for your your main view, category views, tag views, author views, archive views, search views, and views 
    145             for custom post types. For each of these views, a different setting is available for the first page and subsequent pages. 
    146             In addition to these, a default value is available that can be set for any 
    147             other pages not covered by this.', 'custom-posts-per-page') . '</p>'; 
    148     echo '<p style="margin-left:12px;max-width:640px;">' . __('The initial value used on activation was pulled from the setting', 'custom-posts-per-page'); 
    149     echo ' <em>' . __('Blog Pages show at most', 'custom-posts-per-page') . '</em> '; 
    150     echo __('found in the', 'custom-posts-per-page') . ' <a href="' . get_bloginfo('wpurl') . 'wp-admin/options-reading.php' . '" title="Reading Settings">'; 
    151     echo __('Reading', 'custom-posts-per-page') . '</a> ' . __('options', 'custom-posts-per-page') . '.</p>'; 
    152     echo '<form method="post" action="options.php">'; 
    153  
    154     settings_fields( 'cpppc_options' ); 
    155     do_settings_sections( 'cpppc' ); // Display the main section of settings. 
    156     do_settings_sections( 'cpppc_custom' ); // Display the section of settings that handles custom post types. 
    157  
    158     echo '<p class="submit"><input type="submit" class="button-primary" value="'; 
    159     _e('Save Changes', 'custom-posts-per-page'); 
    160     echo '" /> 
    161             </p> 
    162             </form> 
    163         </div>'; 
    164 } 
    165  
    166 function cpppc_register_settings() { 
    167     /*  Add the settings that we're going to be using for the plugin. */ 
    168     register_setting( 'cpppc_options', 'cpppc_options', 'cpppc_options_validate' ); 
    169     add_settings_section( 'cpppc_section_main', '', 'cpppc_section_text', 'cpppc' ); 
    170     add_settings_section( 'cpppc_section_custom', '', 'cpppc_section_custom_text', 'cpppc_custom' ); 
    171     add_settings_field( 'cpppc_index_count', __('Main Index posts per page:', 'custom-posts-per-page'), 'cpppc_index_count_text', 'cpppc', 'cpppc_section_main' ); 
    172     add_settings_field( 'cpppc_category_count', __('Category posts per page:', 'custom-posts-per-page'), 'cpppc_category_count_text', 'cpppc', 'cpppc_section_main' ); 
    173     add_settings_field( 'cpppc_archive_count', __('Archive posts per page:', 'custom-posts-per-page'), 'cpppc_archive_count_text', 'cpppc', 'cpppc_section_main' ); 
    174     add_settings_field( 'cpppc_tag_count', __('Tag posts per page:', 'custom-posts-per-page'), 'cpppc_tag_count_text', 'cpppc', 'cpppc_section_main' ); 
    175     add_settings_field( 'cpppc_author_count', __('Author posts per page:', 'custom-posts-per-page'), 'cpppc_author_count_text', 'cpppc', 'cpppc_section_main' ); 
    176     add_settings_field( 'cpppc_search_count', __('Search posts per page:', 'custom-posts-per-page'), 'cpppc_search_count_text', 'cpppc', 'cpppc_section_main' ); 
    177     add_settings_field( 'cpppc_default_count', __('Default posts per page:', 'custom-posts-per-page'), 'cpppc_default_count_text', 'cpppc', 'cpppc_section_main' ); 
    178     add_settings_field( 'cpppc_post_type_count', '', 'cpppc_post_type_count_text', 'cpppc_custom', 'cpppc_section_custom' ); 
    179 } 
    180  
    181 function cpppc_options_validate($input) { 
    182     /*  We aren't doing heavy validation yet, more like a passive aggressive failure. 
    183      *  If you enter anything other than an integer, the value will be set to 0 by 
    184      *  default and if a negative value is inputted, it will be corrected to positive. */ 
    185     $input = array_map( 'absint', $input ); 
    186     return $input; 
    187 } 
    188  
    189 function cpppc_section_text() { 
    190     echo '<h3>' . __('Main Settings', 'custom-posts-per-page') . ':</h3> 
    191         <p style="max-width:640px;margin-left:12px;">' . __('This section allows you to modify page view types that are 
     30class Custom_Posts_Per_Page_Foghlaim { 
     31 
     32    private $page_count_offset = 0; 
     33 
     34    /** 
     35     * Start up the plugin by adding appropriate actions and filters. 
     36     * 
     37     * Our pre_get_posts action should only happen on non admin screens 
     38     * otherwise things get weird. 
     39     */ 
     40    public function __construct() { 
     41        register_activation_hook( __FILE__, array( $this, 'upgrade_check' ) ); 
     42 
     43        add_action( 'admin_init', array( $this, 'upgrade_check' ) ); 
     44        add_action( 'admin_menu', array( $this, 'add_settings' ) ); 
     45        add_action( 'admin_init', array( $this, 'register_settings' ) ); 
     46        add_action( 'admin_init', array( $this, 'add_languages' ) ); 
     47        add_filter( 'plugin_action_links', array( $this, 'add_plugin_action_links' ), 10, 2 ); 
     48 
     49        if ( ! is_admin() ) 
     50            add_action( 'pre_get_posts', array( $this, 'modify_query' ) ); 
     51    } 
     52 
     53    /** 
     54     * Load our language information 
     55     */ 
     56    public function add_languages() { 
     57        load_plugin_textdomain( 'custom-posts-per-page', false, basename( dirname( __FILE__ ) ) . '/lang' ); 
     58    } 
     59 
     60    /** 
     61     * Our database 'upgrade' check. 
     62     * 
     63     * In version 1.3, we refactored the option names a bit, so a little 
     64     * cleanup is needed if we detect and old version. 
     65     */ 
     66    public function upgrade_check() { 
     67        if ( '1.3' == get_option( 'cpppc_upgrade', '1.3' ) ) { 
     68            $this->activate(); 
     69 
     70            $cpppc_options = get_option( 'cpppc_options' ); 
     71 
     72            if ( isset( $cpppc_options[ 'front_page_count' ] ) ) { 
     73                $cpppc_options[ 'front_count' ] = $cpppc_options[ 'front_page_count' ]; 
     74                unset( $cpppc_options[ 'front_page_count' ] ); 
     75            } 
     76 
     77            if ( isset( $cpppc_options[ 'index_count' ] ) ) { 
     78                $cpppc_options[ 'front_count_paged' ] = $cpppc_options[ 'index_count' ]; 
     79                unset( $cpppc_options[ 'index_count' ] ); 
     80            } 
     81 
     82            update_option( 'cpppc_options', $cpppc_options ); 
     83            update_option( 'cpppc_upgrade', '1.4' ); 
     84        } 
     85    } 
     86 
     87    /** 
     88     * Activate the plugin when it is activated through the admin screen, or if it is upgraded 
     89     * and we find that things are out of date in upgrade_check. 
     90     * 
     91     * When first activated, we set some default values in an options array. The default value 
     92     * is pulled from the current 'posts_per_page' option so that nothing changes unexpectedly. 
     93     */ 
     94    public function activate() { 
     95        $default_count     = get_option( 'posts_per_page' ); 
     96        $current_options   = get_option( 'cpppc_options' ); 
     97        $default_options   = array(); 
     98        $option_type_array = array( 'front', 'category', 'tag', 'author', 'archive', 'search', 'default' ); 
     99 
     100        foreach ( $option_type_array as $option_type ) { 
     101            $default_options[ $option_type . '_count' ] = $default_count; 
     102 
     103            /* For some users that are upgrading from a past version, we want to make sure the paged count 
     104             * is filled in with something appropriate. This looks for each option in order. */ 
     105            if ( ! empty( $cppc_options[ $option_type . '_count_paged' ] ) ) 
     106                $default_options[ $option_type . '_count_paged' ] = $current_options[ $option_type . '_count_paged' ]; 
     107            elseif ( ! empty( $cpppc_options[ $option_type . '_count' ] ) ) 
     108                $default_options[ $option_type . '_count_paged' ] = $current_options[ $option_type . '_count' ]; 
     109            else 
     110                $default_options[ $option_type . '_count_paged' ] = $default_count; 
     111        } 
     112 
     113        /*  We'll also get all of the currently registered custom post types and give them a default value 
     114         *  of 0 if one has not previously been set. Custom post types are a special breed and we don't 
     115         *  necessarily want them to match the default posts_per_page value without a conscious decision 
     116         *  by the user. */ 
     117        $all_post_types = get_post_types( array( '_builtin' => false ) ); 
     118        foreach ( $all_post_types as $p => $k ) { 
     119            if ( isset( $current_options[ $p . '_count' ] ) ) 
     120                $default_options[ $p . '_count' ] = $current_options[ $p . '_count' ]; 
     121            else 
     122                $default_options[ $p . '_count' ] = 0; 
     123 
     124            if ( isset( $current_options[ $p . '_count_paged' ] ) ) 
     125                $default_options[ $p . '_count_paged' ] = $current_options[ $p . '_count_paged' ]; 
     126            else 
     127                $default_options[ $p . '_count_paged' ] = 0; 
     128        } 
     129        update_option( 'cpppc_options', $default_options ); 
     130    } 
     131 
     132    /** 
     133     * Adds a pretty 'settings' link under the plugin upon activation. 
     134     * 
     135     * This function gratefully taken (and barely modified) from Pippin Williamson's 
     136     * WPMods article: http://www.wpmods.com/adding-plugin-action-links/ 
     137     * 
     138     * @param $links array of links provided by core that will be displayed under the plugin 
     139     * @param $file string representing the plugin's filename 
     140     * @return array the new array of links to be displayed 
     141     */ 
     142    public function add_plugin_action_links( $links, $file ) { 
     143        static $this_plugin; 
     144 
     145        if ( ! $this_plugin ) 
     146            $this_plugin = plugin_basename( __FILE__ ); 
     147 
     148        if ( $file == $this_plugin ) { 
     149            $settings_link = '<a href="' . site_url( '/wp-admin/options-general.php?page=post-count-settings' ) . '">' . __('Settings', 'custom-posts-per-page') . '</a>'; 
     150            array_unshift( $links, $settings_link ); 
     151        } 
     152        return $links; 
     153    } 
     154 
     155    /** 
     156     * Add the settings page for Custom Posts Per Page under the settings menu. 
     157     */ 
     158    public function add_settings() { 
     159        add_options_page( __( 'Posts Per Page', 'custom-posts-per-page' ), __( 'Posts Per Page', 'custom-posts-per-page' ), 'manage_options', 'post-count-settings', array( $this, 'view_settings' ) ); 
     160    } 
     161 
     162    /** 
     163     * Display the main settings view for the plugin. 
     164     */ 
     165    public function view_settings() { 
     166        ?> 
     167        <div class="wrap"> 
     168            <div class="icon32" id="icon-options-general"></div> 
     169            <h2><?php _e( 'Custom Posts Per Page', 'custom-posts-per-page' ); ?></h2> 
     170            <h3><?php _e( 'Overview', 'custom-posts-per-page' ); ?></h3> 
     171            <p style="margin-left:12px;max-width:640px;"><?php _e( 'The settings below allow you to specify how many posts per page are displayed to readers depending on the which type of page is being viewed.' ); ?></p> 
     172            <p style="margin-left:12px;max-width:640px;"><?php _e( 'Different values can be set for your your main view, category views, tag views, author views, archive views, search views, and 
     173            views for custom post types. For each of these views, a different setting is available for the first page and subsequent pages. In addition to these, a default value is available that 
     174            can be set for any other pages not covered by this.', 'custom-posts-per-page' ); ?></p> 
     175            <p style="margin-left:12px;max-width:640px;"><?php _e( 'The initial value used on activation was pulled from the setting <em>Blog Pages show at most</em> found in the', 'custom-posts-per-page' ); ?> <a href="<?php echo site_url( '/wp-admin/options-reading.php' ); ?>" title="Reading Settings"><?php _e( 'Reading Settings', 'custom-posts-per-page' ); ?></a></p> 
     176            <form method="post" action="options.php"> 
     177    <?php 
     178        settings_fields( 'cpppc_options' ); 
     179        do_settings_sections( 'cpppc' ); 
     180        do_settings_sections( 'cpppc_custom' ); 
     181    ?> 
     182        <p class="submit"><input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'custom-posts-per-page' ); ?>" /></p></form> 
     183        </div> 
     184    <?php 
     185    } 
     186 
     187    /** 
     188     * Register all of the settings we'll be using. 
     189     */ 
     190    public function register_settings() { 
     191        register_setting( 'cpppc_options', 'cpppc_options', array( $this, 'validate_options' ) ); 
     192        add_settings_section( 'cpppc_section_main', '', array( $this, 'output_main_section_text' ), 'cpppc' ); 
     193        add_settings_section( 'cpppc_section_custom', '', array( $this, 'output_custom_section_text' ), 'cpppc_custom' ); 
     194        add_settings_field( 'cpppc_index_count', __( 'Main Index posts per page:', 'custom-posts-per-page' ), array( $this, 'output_index_count_text' ), 'cpppc', 'cpppc_section_main' ); 
     195        add_settings_field( 'cpppc_category_count', __( 'Category posts per page:', 'custom-posts-per-page' ), array( $this, 'output_category_count_text' ), 'cpppc', 'cpppc_section_main' ); 
     196        add_settings_field( 'cpppc_archive_count', __( 'Archive posts per page:', 'custom-posts-per-page' ), array( $this, 'output_archive_count_text' ), 'cpppc', 'cpppc_section_main' ); 
     197        add_settings_field( 'cpppc_tag_count', __( 'Tag posts per page:', 'custom-posts-per-page' ), array( $this, 'output_tag_count_text' ), 'cpppc', 'cpppc_section_main' ); 
     198        add_settings_field( 'cpppc_author_count', __( 'Author posts per page:', 'custom-posts-per-page' ), array( $this, 'output_author_count_text' ), 'cpppc', 'cpppc_section_main' ); 
     199        add_settings_field( 'cpppc_search_count', __( 'Search posts per page:', 'custom-posts-per-page' ), array( $this, 'output_search_count_text' ), 'cpppc', 'cpppc_section_main' ); 
     200        add_settings_field( 'cpppc_default_count', __( 'Default posts per page:', 'custom-posts-per-page' ), array( $this, 'output_default_count_text' ), 'cpppc', 'cpppc_section_main' ); 
     201        add_settings_field( 'cpppc_post_type_count', '', array( $this, 'output_post_type_count_text' ), 'cpppc_custom', 'cpppc_section_custom' ); 
     202    } 
     203 
     204    /** 
     205     * Validate the values entered by the user. 
     206     * 
     207     * We aren't doing heavy validation yet, more like a passive aggressive failure. 
     208     * If you enter anything other than an integer, the value will be set to 0 by 
     209     * default and if a negative value is inputted, it will be corrected to positive. 
     210     * 
     211     * @param $input array of counts destined to be used as posts_per_page options 
     212     * @return array the same array with absint run on each 
     213     */ 
     214    public function validate_options( $input ) { 
     215        return array_map( 'absint', $input ); 
     216    } 
     217 
     218    /** 
     219     * Output the main section of text. 
     220     */ 
     221    public function output_main_section_text() { 
     222    ?> 
     223        <h3><?php _e( 'Main Settings', 'custom-posts-per-page' ); ?></h3> 
     224        <p style="max-width:640px;margin-left:12px;"><?php _e( 'This section allows you to modify page view types that are 
    192225        associated with WordPress by default. When an option is set to 0, it will not modify any page requests for 
    193         that view and will instead allow default values to pass through.', 'custom-posts-per-page') . '</p>'; 
    194     echo '<p style="max-width:460px;margin-left:12px;"><strong>Please Note:</strong> <em>For each setting, the box on the <strong>LEFT</strong> controls the the number of posts displayed on 
    195     the first page of that view while the box on the <strong>RIGHT</strong> controls the number of posts seen on pages 2, 3, 4, etc... of that view.</em></p>'; 
    196 } 
    197  
    198 function cpppc_section_custom_text() { 
    199     echo '<h3>' . __('Custom Post Type Specific Settings', 'custom-posts-per-page') . ':</h3> 
    200     <p style="max-width:640px;margin-left:12px;">' . __('This section contains a list of all of your registered custom post 
     226        that view and will instead allow default values to pass through.', 'custom-posts-per-page' ); ?></p> 
     227        <p style="max-width:460px;margin-left:12px;"><strong><?php _e( 'Please Note', 'custom-posts-per-page' ); ?>:</strong> 
     228        <em><?php _e( 'For each setting, the box on the <strong>LEFT</strong> controls the the number of posts displayed on the first page of that view while 
     229        the box on the <strong>RIGHT</strong> controls the number of posts seen on pages 2, 3, 4, etc... of that view.', 'custom-posts-per-page' ); ?></em></p> 
     230    <?php 
     231    } 
     232 
     233    /** 
     234     * Output the custom post type section of text. 
     235     */ 
     236    public function output_custom_section_text() { 
     237    ?> 
     238    <h3><?php _e( 'Custom Post Type Specific Settings', 'custom-posts-per-page' ); ?></h3> 
     239    <p style="max-width:640px;margin-left:12px;"><?php _e( 'This section contains a list of all of your registered custom post 
    201240    types. In order to not conflict with other plugins or themes, these are set to 0 by default. When an option is 
    202241    set to 0, it will not modify any page requests for that custom post type archive. For Custom Posts Per Page to 
    203     control the number of posts to display, these will need to be changed.', 'custom-post-per-page') . '</p>'; 
     242    control the number of posts to display, these will need to be changed.', 'custom-post-per-page' ); ?></p> 
     243    <?php 
     244    } 
     245 
     246    /** 
     247     * Output the individual options for each custom post type registered in WordPress 
     248     */ 
     249    public function output_post_type_count_text() { 
     250        $cpppc_options  = get_option( 'cpppc_options' ); 
     251        $all_post_types = get_post_types( array( '_builtin' => false ) ); 
     252 
     253        /* Quirky little workaround for displaying the settings in our table */ 
     254        echo '</td><td></td></tr>'; 
     255 
     256        foreach ( $all_post_types as $p => $k ) { 
     257            /*  Default values are assigned for custom post types that are available 
     258             *  to us when our plugin is registered. If a custom post type becomes 
     259             *  available after our plugin is installed, we'll want to catch it and 
     260             *  assign a good value. */ 
     261            if ( empty( $cpppc_options[ $p . '_count' ] ) ) 
     262                $cpppc_options[ $p . '_count' ] = 0; 
     263 
     264            if ( empty( $cpppc_options[ $p . '_count_paged' ] ) ) 
     265                $cpppc_options[ $p . '_count_paged' ] = 0; 
     266 
     267            $this_post_data = get_post_type_object( $p ); 
     268 
     269        ?> 
     270            <tr> 
     271                <td><?php echo $this_post_data->labels->name; ?></td> 
     272                <td><input id="cpppc_post_type_count[<?php echo $p; ?>]" name="cpppc_options[<?php echo $p; ?>_count]" size="10" type="text" value="<?php echo esc_attr( $cpppc_options[ $p . '_count' ] ); ?>" /> 
     273                    &nbsp;<input id="cpppc_post_type_count[<?php echo $p; ?>]" name="cpppc_options[<?php echo $p; ?>_count_paged]" size="10" type="text" value="<?php echo esc_attr( $cpppc_options[ $p . '_count_paged' ] ); ?>" /> 
     274                </td> 
     275            </tr> 
     276        <?php 
     277        } 
     278    } 
     279 
     280    /** 
     281     * Display the input field for the index page post count option. 
     282     */ 
     283    public function output_index_count_text() { 
     284        $cpppc_options = get_option( 'cpppc_options', array( 'front_count' => 0, 'front_count_paged' => 0 ) ); 
     285    ?> 
     286        <input id="cpppc_index_count[0]" name="cpppc_options[front_count]" size="10" type="text" value="<?php echo esc_attr( $cpppc_options[ 'front_count' ] ); ?>" /> 
     287        &nbsp;<input id="cpppc_index_count[1]" name="cpppc_options[front_count_paged]" size="10" type="text" value="<?php echo esc_attr( $cpppc_options[ 'front_count_paged' ] ); ?>" /> 
     288    <?php 
     289    } 
     290 
     291    /** 
     292     * Display the input field for the category page post count option. 
     293     */ 
     294    public function output_category_count_text() { 
     295        $cpppc_options = get_option( 'cpppc_options', array( 'category_count' => 0, 'category_count_paged' => 0 ) ); 
     296    ?> 
     297        <input id="cppppc_category_count[0]" name="cpppc_options[category_count]" size="10" type="text" value="<?php echo esc_attr( $cpppc_options[ 'category_count' ] ); ?>" /> 
     298        &nbsp;<input id="cppppc_category_count[1]" name="cpppc_options[category_count_paged]" size="10" type="text" value="<?php echo esc_attr( $cpppc_options[ 'category_count_paged' ] ); ?>" /> 
     299    <?php 
     300    } 
     301 
     302    /** 
     303     * Display the input field for the archive page post count option. 
     304     */ 
     305    public function output_archive_count_text() { 
     306        $cpppc_options = get_option( 'cpppc_options', array( 'archive_count' => 0, 'archive_count_paged' => 0 ) ); 
     307    ?> 
     308        <input id="cppppc_archive_count[0]" name="cpppc_options[archive_count]" size="10" type="text" value="<?php echo esc_attr( $cpppc_options[ 'archive_count' ] ); ?>" /> 
     309        &nbsp;<input id="cppppc_archive_count[1]" name="cpppc_options[archive_count_paged]" size="10" type="text" value="<?php echo esc_attr( $cpppc_options[ 'archive_count_paged' ] ); ?>" /> 
     310    <?php 
     311    } 
     312 
     313    /** 
     314     * Display the input field for the tag page post count option. 
     315     */ 
     316    public function output_tag_count_text() { 
     317        $cpppc_options = get_option( 'cpppc_options', array( 'tag_count' => 0, 'tag_count_paged' => 0 ) ); 
     318    ?> 
     319        <input id="cpppc_tag_count[0]" name="cpppc_options[tag_count]" size="10" type="text" value="<?php echo esc_attr( $cpppc_options[ 'tag_count' ] ); ?>" /> 
     320        &nbsp;<input id="cpppc_tag_count[1]" name="cpppc_options[tag_count_paged]" size="10" type="text" value="<?php echo esc_attr( $cpppc_options[ 'tag_count_paged' ] ); ?>" /> 
     321    <?php 
     322    } 
     323 
     324    /** 
     325     * Display the input field for the author page post count option. 
     326     */ 
     327    public function output_author_count_text() { 
     328        $cpppc_options = get_option( 'cpppc_options', array( 'author_count' => 0, 'author_count_paged' => 0 ) ); 
     329    ?> 
     330        <input id="cpppc_author_count[0]" name="cpppc_options[author_count]" size="10" type="text" value="<?php echo esc_attr( $cpppc_options[ 'author_count' ] ); ?>" /> 
     331        &nbsp;<input id="cpppc_author_count[1]" name="cpppc_options[author_count_paged]" size="10" type="text" value="<?php echo esc_attr( $cpppc_options[ 'author_count_paged' ] ); ?>" /> 
     332    <?php 
     333    } 
     334 
     335    /** 
     336     * Display the input field for the search page post count option. 
     337     */ 
     338    public function output_search_count_text() { 
     339        $cpppc_options = get_option( 'cpppc_options', array( 'search_count' => 0, 'search_count_paged' => 0 ) ); 
     340    ?> 
     341        <input id="cppppc_search_count[0]" name="cpppc_options[search_count]" size="10" type="text" value="<?php echo esc_attr( $cpppc_options[ 'search_count' ] ); ?>" /> 
     342        &nbsp;<input id="cppppc_search_count[1]" name="cpppc_options[search_count_paged]" size="10" type="text" value="<?php echo esc_attr( $cpppc_options[ 'search_count_paged' ] ); ?>" /> 
     343    <?php 
     344    } 
     345 
     346    /** 
     347     * Display the input field for the default page post count option. 
     348     */ 
     349    public function output_default_count_text() { 
     350        $cpppc_options = get_option( 'cpppc_options', array( 'default_count' => 0, 'default_count_paged' => 0 ) ); 
     351    ?> 
     352        <input id="cppppc_default_count[0]" name="cpppc_options[default_count]" size="10" type="text" value="<?php echo esc_attr( $cpppc_options[ 'default_count' ] ); ?>" /> 
     353        &nbsp;<input id="cppppc_default_count[1]" name="cpppc_options[default_count_paged]" size="10" type="text" value="<?php echo esc_attr( $cpppc_options[ 'default_count_paged' ] ); ?>" /> 
     354    <?php 
     355    } 
     356 
     357    /** 
     358     * Backwards compatible (3.2.1) function to check for main query. In an ideal world, we'd 
     359     * tell you to buzz off and upgrade to at least 3.3.1, let alone the 3.4 that's just around 
     360     * the corner... but I'll be nice for one more release. Then I get to remove 15 lines. :) 
     361     * 
     362     * @param $query object WP Query object 
     363     * @return bool Whether or not this is the main query 
     364     */ 
     365    public function check_main_query( $query ) { 
     366        if ( method_exists( $query, 'is_main_query' ) ) { 
     367            return $query->is_main_query(); 
     368        } else { 
     369            global $wp_the_query; 
     370            return $query === $wp_the_query; 
     371        } 
     372    } 
     373 
     374    /** 
     375     * This is the important part of the plugin that actually modifies the query before anything 
     376     * is displayed. 
     377     * 
     378     * @param $query WP Query object 
     379     * @return mixed 
     380     */ 
     381    public function modify_query( $query ) { 
     382 
     383        /*  If this isn't the main query, we'll avoid altering the results. */ 
     384        if ( ! $this->check_main_query( $query ) ) 
     385            return; 
     386 
     387        $cpppc_options   = get_option( 'cpppc_options' ); 
     388        $all_post_types  = get_post_types( array( '_builtin' => false ) ); 
     389        $post_type_array = array(); 
     390        foreach ( $all_post_types as $p=> $k ) { 
     391            $post_type_array[] = $p; 
     392        } 
     393 
     394        /*  Set our own page flag for our own sanity. */ 
     395        $cpppc_paged = ( $query->get( 'paged' ) && 2 <= $query->get( 'paged' ) ) ? true : false; 
     396        $page_number = $query->get( 'paged' ); 
     397 
     398        if ( $query->is_home() ) { 
     399            $final_options = $this->process_options( 'front', $cpppc_paged, $cpppc_options, $page_number ); 
     400        } elseif ( $query->is_post_type_archive( $post_type_array ) ) { 
     401            /*  We've just established that the visitor is loading an archive page of a custom post type by matching 
     402             *  it to a general array. Now we'll loop back through until we find exactly what post type is matching 
     403             *  so we can modify the request accordingly. */ 
     404            foreach ( $post_type_array as $my_post_type ) { 
     405                if ( $query->is_post_type_archive( $my_post_type ) ) { 
     406                    /*  Now we know for sure what custom post type we're on. */ 
     407                    $my_post_type_option = $my_post_type; 
     408                } 
     409            } 
     410            /*  Now check to see if we've assigned a value to this yet. When our plugin is registered, only the custom 
     411             *  post types available to us at the time are assigned options. If a new custom post type has been 
     412             *  installed, it's possible it does not yet have an option. For now we'll skip the request modification 
     413             *  and let it slide by if there is no match. */ 
     414            $final_options = $this->process_options( $my_post_type_option, $cpppc_paged, $cpppc_options, $page_number ); 
     415        } elseif ( $query->is_category() ) { 
     416            $final_options = $this->process_options( 'category', $cpppc_paged, $cpppc_options, $page_number ); 
     417        } elseif ( $query->is_tag() ) { 
     418            $final_options = $this->process_options( 'tag', $cpppc_paged, $cpppc_options, $page_number ); 
     419        } elseif ( $query->is_author() ) { 
     420            $final_options = $this->process_options( 'author', $cpppc_paged, $cpppc_options, $page_number ); 
     421        } elseif ( $query->is_search() ) { 
     422            $final_options = $this->process_options( 'search', $cpppc_paged, $cpppc_options, $page_number ); 
     423        } elseif ( $query->is_archive() ) { 
     424            /*  Note that the check for is_archive needs to be below anything else that WordPress may consider an 
     425             *  archive. This includes is_tag, is_category, is_author and probably some others. */ 
     426            $final_options = $this->process_options( 'archive', $cpppc_paged, $cpppc_options, $page_number ); 
     427        } else { 
     428            $final_options = $this->process_options( 'default', $cpppc_paged, $cpppc_options, $page_number ); 
     429        } 
     430 
     431        if ( isset( $final_options[ 'posts' ] ) ) { 
     432            $query->set( 'posts_per_page', $final_options[ 'posts' ] ); 
     433            $query->set( 'offset', $final_options[ 'offset' ] ); 
     434        } 
     435 
     436        if ( 0 <> $this->page_count_offset ) 
     437            add_filter( 'found_posts', array( $this, 'correct_found_posts' ) ); 
     438    } 
     439 
     440    /** 
     441     * The offset and post count deal gets a bit confused when the first page and subsequent pages stop matching. 
     442     * This function helps realign things once we've screwed with them. 
     443     * 
     444     * @param $found_posts int The number of found posts 
     445     * @return mixed The number of posts to report as found for real 
     446     */ 
     447    public function correct_found_posts( $found_posts ) { 
     448        return ( $found_posts + $this->page_count_offset ); 
     449    } 
     450 
     451    /** 
     452     * @param $option_prefix string The prefix of the count and count_paged options in the database 
     453     * @param $cpppc_paged bool True if this is paged, false if it isn't. 
     454     * @param $cpppc_options array of options from the database for custom posts per page 
     455     * @param null $page_number int Which page is it? 
     456     * @return array Contains the final values for posts_per_page and offset to be passed to the query 
     457     */ 
     458    public function process_options( $option_prefix, $cpppc_paged, $cpppc_options, $page_number = NULL ) { 
     459        $final_options = array(); 
     460 
     461        if ( ! $cpppc_paged && ! empty( $cpppc_options[ $option_prefix . '_count' ] ) ) { 
     462            $final_options[ 'posts' ]  = $cpppc_options[ $option_prefix . '_count' ]; 
     463            $final_options[ 'offset' ] = 0; 
     464        } elseif ( $cpppc_paged & ! empty( $cpppc_options[ $option_prefix . '_count_paged' ] ) ) { 
     465            $this->page_count_offset = ( $cpppc_options[ $option_prefix . '_count_paged' ] - $cpppc_options[ $option_prefix . '_count' ] ); 
     466            $final_options[ 'offset' ]  = ( ( $page_number - 2 ) * $cpppc_options[ $option_prefix . '_count_paged' ] + $cpppc_options[ $option_prefix . '_count' ] ); 
     467            $final_options[ 'posts' ]   = $cpppc_options[ $option_prefix . '_count_paged' ]; 
     468        } 
     469        return $final_options; 
     470    } 
    204471} 
    205  
    206 function cpppc_post_type_count_text() { 
    207     $cpppc_options  = get_option( 'cpppc_options' ); 
    208     $all_post_types = get_post_types( array( '_builtin' => false ) ); 
    209  
    210     echo '</td><td></td></tr>'; 
    211  
    212     foreach ( $all_post_types as $p=> $k ) { 
    213         /*  Default values are assigned for custom post types that are available 
    214          *  to us when our plugin is registered. If a custom post type becomes 
    215          *  available after our plugin is installed, we'll want to catch it and 
    216          *  assign a good value. */ 
    217         if ( ! isset($cpppc_options[ $p . '_count' ]) ) { 
    218             $cpppc_options[ $p . '_count' ] = 0; 
    219         } 
    220  
    221         $this_post_data = get_post_type_object( $p ); 
    222  
    223         echo '<tr><td>'; 
    224         echo $this_post_data->labels->name . '</td><td> <input id="cpppc_post_type_count[' . $p . ']" name="cpppc_options[' . $p . '_count]" size="10" type="text" value="'; 
    225         echo $cpppc_options[ $p . '_count' ]; 
    226         echo '">'; 
    227         echo '&nbsp;<input id="cpppc_post_type_count[' . $p . ']" name="cpppc_options[' . $p . '_count_paged]" size="10" type="text" value="'; 
    228         echo $cpppc_options[ $p . '_count_paged' ]; 
    229         echo '"></td></tr>'; 
    230     } 
    231 } 
    232  
    233 function cpppc_index_count_text() { 
    234     /*  Display the input field for the index page post count option. */ 
    235     $cpppc_options = get_option( 'cpppc_options' ); 
    236  
    237     echo '<input id="cpppc_index_count[0]" name="cpppc_options[front_count]" size="10" type="text" value="'; 
    238     echo $cpppc_options[ 'front_count' ]; 
    239     echo '" />'; 
    240     echo '&nbsp;<input id="cpppc_index_count[1]" name="cpppc_options[front_count_paged]" size="10" type="text" value="'; 
    241     echo $cpppc_options[ 'front_count_paged' ]; 
    242     echo '" />'; 
    243 } 
    244  
    245 function cpppc_category_count_text() { 
    246     /*  Display the input field for the category page post count option. */ 
    247     $cpppc_options = get_option( 'cpppc_options' ); 
    248  
    249     echo '<input id="cppppc_category_count[0]" name="cpppc_options[category_count]" size="10" type="text" value="'; 
    250     echo $cpppc_options[ 'category_count' ]; 
    251     echo '" />'; 
    252     echo '&nbsp;<input id="cppppc_category_count[1]" name="cpppc_options[category_count_paged]" size="10" type="text" value="'; 
    253     echo $cpppc_options[ 'category_count_paged' ]; 
    254     echo '" />'; 
    255 } 
    256  
    257 function cpppc_archive_count_text() { 
    258     /*  Display the input field for the archive page post count option. */ 
    259     $cpppc_options = get_option( 'cpppc_options' ); 
    260  
    261     echo '<input id="cppppc_archive_count[0]" name="cpppc_options[archive_count]" size="10" type="text" value="'; 
    262     echo $cpppc_options[ 'archive_count' ]; 
    263     echo '" />'; 
    264     echo '&nbsp;<input id="cppppc_archive_count[1]" name="cpppc_options[archive_count_paged]" size="10" type="text" value="'; 
    265     echo $cpppc_options[ 'archive_count_paged' ]; 
    266     echo '" />'; 
    267 } 
    268  
    269 function cpppc_tag_count_text() { 
    270     /*  Display the input field for the tag page post count option. */ 
    271     $cpppc_options = get_option( 'cpppc_options' ); 
    272  
    273     echo '<input id="cpppc_tag_count[0]" name="cpppc_options[tag_count]" size="10" type="text" value="'; 
    274     echo $cpppc_options[ 'tag_count' ]; 
    275     echo '" />'; 
    276     echo '&nbsp;<input id="cpppc_tag_count[1]" name="cpppc_options[tag_count_paged]" size="10" type="text" value="'; 
    277     echo $cpppc_options[ 'tag_count_paged' ]; 
    278     echo '" />'; 
    279 } 
    280  
    281 function cpppc_author_count_text() { 
    282     /*  Display the input field for the author page post count option. */ 
    283     $cpppc_options = get_option( 'cpppc_options' ); 
    284  
    285     echo '<input id="cpppc_author_count[0]" name="cpppc_options[author_count]" size="10" type="text" value="'; 
    286     echo $cpppc_options[ 'author_count' ]; 
    287     echo '" />'; 
    288     echo '&nbsp;<input id="cpppc_author_count[1]" name="cpppc_options[author_count_paged]" size="10" type="text" value="'; 
    289     echo $cpppc_options[ 'author_count_paged' ]; 
    290     echo '" />'; 
    291 } 
    292  
    293 function cpppc_search_count_text() { 
    294     /*  Display the input field for the search page post count option. */ 
    295     $cpppc_options = get_option( 'cpppc_options' ); 
    296  
    297     echo '<input id="cppppc_search_count[0]" name="cpppc_options[search_count]" size="10" type="text" value="'; 
    298     echo $cpppc_options[ 'search_count' ]; 
    299     echo '" />'; 
    300     echo '&nbsp;<input id="cppppc_search_count[1]" name="cpppc_options[search_count_paged]" size="10" type="text" value="'; 
    301     echo $cpppc_options[ 'search_count_paged' ]; 
    302     echo '" />'; 
    303 } 
    304  
    305 function cpppc_default_count_text() { 
    306     /*  Display the input field for the default page post count option. */ 
    307     $cpppc_options = get_option( 'cpppc_options' ); 
    308  
    309     echo '<input id="cppppc_default_count[0]" name="cpppc_options[default_count]" size="10" type="text" value="'; 
    310     echo $cpppc_options[ 'default_count' ]; 
    311     echo '" />'; 
    312     echo '&nbsp;<input id="cppppc_default_count[1]" name="cpppc_options[default_count_paged]" size="10" type="text" value="'; 
    313     echo $cpppc_options[ 'default_count_paged' ]; 
    314     echo '" />'; 
    315 } 
    316  
    317 function jf_cpppc_correct_found_posts( $found_posts ) { 
    318     global $jf_cpppc_page_count_offset; 
    319     return ( $found_posts + $jf_cpppc_page_count_offset ); 
    320 } 
    321  
    322 function jf_cpppc_check_main_query( $query ) { 
    323     if ( method_exists( $query, 'is_main_query' ) ) { 
    324         return $query->is_main_query(); 
    325     } else { 
    326         global $wp_the_query; 
    327         return $query === $wp_the_query; 
    328     } 
    329 } 
    330  
    331 function jf_cpppc_process_options( $option_prefix, $cpppc_paged, $cpppc_options, $page_number = NULL ) { 
    332     global $jf_cpppc_page_count_offset; 
    333  
    334     $final_options = array(); 
    335  
    336     if ( !$cpppc_paged && 0 != $cpppc_options[ $option_prefix . '_count' ] ) { 
    337         $final_options[ 'posts' ]  = $cpppc_options[ $option_prefix . '_count' ]; 
    338         $final_options[ 'offset' ] = 0; 
    339     } elseif ( $cpppc_paged & 0 != $cpppc_options[ $option_prefix . '_count_paged' ] ) { 
    340         $jf_cpppc_page_count_offset = ( $cpppc_options[ $option_prefix . '_count_paged' ] - $cpppc_options[ $option_prefix . '_count' ] ); 
    341         $final_options[ 'offset' ]  = ( ( $page_number - 2 ) * $cpppc_options[ $option_prefix . '_count_paged' ] + $cpppc_options[ $option_prefix . '_count' ] ); 
    342         $final_options[ 'posts' ]   = $cpppc_options[ $option_prefix . '_count_paged' ]; 
    343     } 
    344  
    345     return $final_options; 
    346 } 
    347  
    348 function jf_cpppc_modify_query( $query ) { 
    349     global $jf_cpppc_page_count_offset; 
    350  
    351     /*  If this isn't the main query, we'll avoid altering the results. */ 
    352     if ( ! jf_cpppc_check_main_query( $query ) ) 
    353         return; 
    354  
    355     /*  This is the important part of the plugin that actually modifies the query 
    356              at the beginning of the page before anything is displayed. */ 
    357     $cpppc_options   = get_option( 'cpppc_options' ); 
    358     $all_post_types  = get_post_types( array( '_builtin' => false ) ); 
    359     $post_type_array = array(); 
    360     foreach ( $all_post_types as $p=> $k ) { 
    361         $post_type_array[] = $p; 
    362     } 
    363  
    364     /*  Set our own page flag for our own sanity. */ 
    365     $cpppc_paged = ( $query->get( 'paged' ) && 2 <= $query->get( 'paged' ) ) ? 1 : NULL; 
    366     $page_number = $query->get( 'paged' ); 
    367  
    368     if ( $query->is_home() ) { 
    369         $final_options = jf_cpppc_process_options( 'front', $cpppc_paged, $cpppc_options, $page_number ); 
    370     } elseif ( $query->is_post_type_archive( $post_type_array ) ) { 
    371         /*  We've just established that the visitor is loading an archive page of a custom post type by matching 
    372          *  it to a general array. Now we'll loop back through until we find exactly what post type is matching 
    373          *  so we can modify the request accordingly. */ 
    374         foreach ( $post_type_array as $my_post_type ) { 
    375             if ( $query->is_post_type_archive( $my_post_type ) ) { 
    376                 /*  Now we know for sure what custom post type we're on. */ 
    377                 $my_post_type_option = $my_post_type; 
    378             } 
    379         } 
    380         /*  Now check to see if we've assigned a value to this yet. When our plugin is registered, only the custom 
    381          *  post types available to us at the time are assigned options. If a new custom post type has been 
    382          *  installed, it's possible it does not yet have an option. For now we'll skip the request modification 
    383          *  and let it slide by if there is no match. */ 
    384         $final_options = jf_cpppc_process_options( $my_post_type_option, $cpppc_paged, $cpppc_options, $page_number ); 
    385     } elseif ( $query->is_category() ) { 
    386         $final_options = jf_cpppc_process_options( 'category', $cpppc_paged, $cpppc_options, $page_number ); 
    387     } elseif ( $query->is_tag() ) { 
    388         $final_options = jf_cpppc_process_options( 'tag', $cpppc_paged, $cpppc_options, $page_number ); 
    389     } elseif ( $query->is_author() ) { 
    390         $final_options = jf_cpppc_process_options( 'author', $cpppc_paged, $cpppc_options, $page_number ); 
    391     } elseif ( $query->is_search() ) { 
    392         $final_options = jf_cpppc_process_options( 'search', $cpppc_paged, $cpppc_options, $page_number ); 
    393     } elseif ( $query->is_archive() ) { 
    394         /*  Note that the check for is_archive needs to be below anything else that WordPress may consider an 
    395          *  archive. This includes is_tag, is_category, is_author and probably some others. */ 
    396         $final_options = jf_cpppc_process_options( 'archive', $cpppc_paged, $cpppc_options, $page_number ); 
    397     } else { 
    398         $final_options = jf_cpppc_process_options( 'default', $cpppc_paged, $cpppc_options, $page_number ); 
    399     } 
    400  
    401     if ( isset( $final_options[ 'posts' ] ) ) { 
    402         $query->set( 'posts_per_page', $final_options[ 'posts' ] ); 
    403         $query->set( 'offset', $final_options[ 'offset' ] ); 
    404     } 
    405  
    406     if ( 0 <> $jf_cpppc_page_count_offset ) 
    407         add_filter( 'found_posts', 'jf_cpppc_correct_found_posts' ); 
    408  
    409 } 
     472new Custom_Posts_Per_Page_Foghlaim(); 
  • custom-posts-per-page/trunk/readme.txt

    r496612 r528367  
    66Requires at least: 3.2.1 
    77Tested up to: 3.3.1 
    8 Stable tag: 1.4 
     8Stable tag: 1.5 
    99 
    1010Custom Posts Per Page provides a settings page in your WordPress admin that allows you to specify how many posts are displayed for different views. 
     
    4040 
    4141== Frequently Asked Questions == 
     42= Should I keep using WordPress 3.2.1? = 
     43 
     44* No. I'm being nice for now, but when 3.5 comes out, I'm totally removing the last piece of code that ties this plugin to 3.2.1. Sorry. :) 
    4245 
    4346= Why aren't there any FAQs? = 
     
    5053 
    5154== Changelog == 
     55= 1.5 = 
     56* A bunch of code cleanup. Move everything to a class. 
     57* Cleanup text domain stuff in preparation for a new translation (sweet!) 
     58* Document more, handle default settings a bit better. 
     59 
    5260= 1.4 = 
    5361* **New** - Proper handling with is_main_query. Will no longer affect queries for side bars and such. 
Note: See TracChangeset for help on using the changeset viewer.