Plugin Directory

Changeset 565719


Ignore:
Timestamp:
06/30/2012 10:04:55 AM (14 years ago)
Author:
paddelboot
Message:

Version 1.3b;

Location:
3pagination
Files:
10 added
2 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • 3pagination/trunk/3pagination.php

    r565111 r565719  
    44 * Plugin Name: 3pagination
    55 * Description: Reach any page with no more than 3 clicks
    6  * Version: 1.2b
     6 * Version: 1.3b
    77 * Author: Michael Schröder <ms@ts-webdesign.net>
    88 * TextDomain: 3pagination
    9  * DomainPath: /l10n
     9 * DomainPath: /languages
    1010 */
    11 
    1211if ( !class_exists( 'threepagination' ) ) {
    1312
     13    if ( function_exists( 'add_filter' ) )
     14        add_filter( 'plugins_loaded', array( 'threepagination', 'get_object' ) );
     15
    1416    class threepagination {
    1517
     
    2224
    2325        /**
     26         * Class object
     27         *
     28         * @var object
     29         */
     30        static $_object;
     31
     32        /**
     33         * Create class object
     34         *
     35         * @access public
     36         * @return object $_object
     37         * @since 0.1a
     38         */
     39        public static function get_object() {
     40
     41            if ( NULL == self::$_object ) {
     42                self::$_object = new self;
     43            }
     44            return self::$_object;
     45        }
     46
     47        /**
    2448         * Class init
    2549         *
     
    2751         */
    2852        public function __construct() {
    29            
     53
    3054            // Get files
    3155            $this->include_files();
    3256
    3357            // Set textdomain string
    34             add_filter( 'admin_init', array( $this, 'set_textdomain' ), 1 );
    35            
     58            add_filter( 'init', array( $this, 'set_textdomain' ), 1 );
     59            add_filter( 'init', array( $this, 'load_textdomain' ), 2 );
     60
    3661            add_filter( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ) );
    3762            add_filter( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
    3863        }
    39        
     64
    4065        /**
    4166         * Include files
     
    4368         * @since 1.2b
    4469         */
    45         private function include_files() {
    46            
    47             require_once( plugin_dir_path( __FILE__) . 'class.settings.php' );
     70        public function include_files() {
     71
     72            require_once( plugin_dir_path( __FILE__ ) . 'class.settings.php' );
    4873        }
    4974
     
    5782            $this->textdomain = '3pagination';
    5883        }
    59        
     84
     85        public function load_textdomain() {
     86
     87            load_plugin_textdomain( $this->textdomain, FALSE, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
     88        }
     89
    6090        /**
    6191         * Load admin scripts
     
    6494         */
    6595        public function admin_scripts() {
    66            
     96
    6797            wp_enqueue_style( 'threepagination-css', plugins_url( 'examples/style.css', __FILE__ ) );
    6898        }
    69        
     99
    70100        /**
    71101         * Load frontend scripts
     
    74104         */
    75105        public function frontend_scripts() {
    76            
     106
    77107            wp_enqueue_style( 'threepagination-css', plugins_url( 'examples/style.css', __FILE__ ) );
    78            
     108
    79109            wp_enqueue_script( '3pagination-js', plugins_url( '/js/3pagination.js', __FILE__ ), array( 'jquery', 'json2' ) );
    80             wp_localize_script( '3pagination-js', 'threepag_vars', $this->frontend_vars() );               
    81         }
    82        
     110            wp_localize_script( '3pagination-js', 'threepag_vars', $this->frontend_vars() );
     111        }
     112
    83113        /**
    84114         * Set frontend vars
     
    88118         */
    89119        private function frontend_vars() {
    90            
    91             $vars = array();
    92            
     120
     121            $vars = array( );
     122
    93123            $settings = get_option( '3pagination_settings' );
    94            
     124
    95125            // Check placement
    96126            if ( 'on' == $this->init_var( $settings, 'placement_header_index' ) && is_home() ||
     
    98128                    'on' == $this->init_var( $settings, 'placement_header_category' ) && is_category() ||
    99129                    'on' == $this->init_var( $settings, 'placement_header_search' ) && is_search() )
    100                     $vars[ 'placement_header' ] = TRUE;
    101            
     130                $vars[ 'placement_header' ] = TRUE;
     131
    102132            if ( 'on' == $this->init_var( $settings, 'placement_footer_index' ) && is_home() ||
    103133                    'on' == $this->init_var( $settings, 'placement_footer_archive' ) && is_archive() ||
    104134                    'on' == $this->init_var( $settings, 'placement_footer_category' ) && is_category() ||
    105135                    'on' == $this->init_var( $settings, 'placement_footer_search' ) && is_search() )
    106                     $vars[ 'placement_footer' ] = TRUE;
    107            
     136                $vars[ 'placement_footer' ] = TRUE;
     137
    108138            if ( 'on' == $this->init_var( $settings, 'placement_prepend_index' ) && is_home() ||
    109139                    'on' == $this->init_var( $settings, 'placement_prepend_archive' ) && is_archive() ||
    110140                    'on' == $this->init_var( $settings, 'placement_prepend_category' ) && is_category() ||
    111141                    'on' == $this->init_var( $settings, 'placement_prepend_search' ) && is_search() ) {
    112                     $vars[ 'placement_prepend' ] = TRUE;
    113                     $vars[ 'placement_prepend_id' ] = $settings[ 'placement_prepend_id' ];
    114                     }
    115            
     142                $vars[ 'placement_prepend' ] = TRUE;
     143                $vars[ 'placement_prepend_id' ] = $settings[ 'placement_prepend_id' ];
     144            }
     145
    116146            if ( 'on' == $this->init_var( $settings, 'placement_append_index' ) && is_home() ||
    117147                    'on' == $this->init_var( $settings, 'placement_append_archive' ) && is_archive() ||
    118148                    'on' == $this->init_var( $settings, 'placement_append_category' ) && is_category() ||
    119149                    'on' == $this->init_var( $settings, 'placement_append_search' ) && is_search() ) {
    120                     $vars[ 'placement_append' ] = TRUE;
    121                     $vars[ 'placement_append_id' ] = $settings[ 'placement_append_id' ];
    122                     }
    123            
     150                $vars[ 'placement_append' ] = TRUE;
     151                $vars[ 'placement_append_id' ] = $settings[ 'placement_append_id' ];
     152            }
     153
    124154            // HTML output
    125155            $vars[ 'html' ] = json_encode( self::get() );
    126            
     156
    127157            return $vars;
    128158        }
     
    143173
    144174            global $wp_query, $wp;
    145            
    146             // Get the page count
     175
     176            // Get global settings
     177            $settings = get_option( '3pagination_settings' );
     178
     179            // Permalink structure
     180            $pretty = ( 'on' == $settings[ 'other_pretty' ] ) ? TRUE : FALSE;
     181
     182            // Get the page count.
    147183            $total_pages = ( FALSE == $max_num_pages ) ? $wp_query->max_num_pages : $max_num_pages;
    148184
     
    150186            if ( 1 == $total_pages )
    151187                return;
    152            
     188
    153189            // For now, 3pagination supports up to 999 pages only
    154             if ( 999 < $total_pages )
    155                 $total_pages = 999;
     190            if ( intval( $settings[ 'other_maxnumpages' ] ) < $total_pages )
     191                $total_pages = intval( $settings[ 'other_maxnumpages' ] );
    156192
    157193            // Get currently visited page
     
    222258                    break;
    223259            }
    224            
    225             $settings = get_option( '3pagination_settings' );
    226            
    227             $css = isset( $settings[ 'css_class' ] ) ? $settings[ 'css_class' ] : $css;
     260
     261            $css = isset( $settings[ 'css_class' ] ) ? $settings[ 'css_class' ] : $css;
    228262
    229263            // Navigation labels
    230264            if ( FALSE !== $labels && 'on' == $settings[ 'labels_show' ] ) {
    231                            
     265
    232266                if ( $on_page > 1 ) {
    233267                    $i = $on_page - 1;
     
    272306         * Create link href
    273307         *
     308         * @TODO: _always_ append possibly existing URL parameters
     309         *
    274310         * @param object $wp | WP object
    275311         * @param int $i | current element
     
    279315        private static function url( $wp, $i, $pretty ) {
    280316
    281             // Pretty permalinks
     317            // Pretty URLs
    282318            if ( TRUE == $pretty ) {
    283319                if ( get_query_var( 'paged' ) )
     
    286322                    $url = home_url( $wp->request ) . '/page/' . $i;
    287323            }
    288             // GET parameters
    289             else
     324            // Default URLs
     325            else 
    290326                $url = home_url( $wp->request ) . '?paged=' . $i;
    291            
    292             //This might be a search query, where WP uses GET parameters (who knows why):
    293             $params = parse_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" );
    294             if ( isset( $params[ 'query' ] ) )
    295                 $url.= '?' . $params[ 'query' ];
     327
     328            // Does the current URL have any parameters? If so,
     329            // we will always append them to the new link url, even
     330            // if pretty URLs = on
     331            $base_url = 'http://' . $_SERVER[ 'HTTP_HOST' ] . $_SERVER[ 'REQUEST_URI' ];
     332            if ( strpos( $base_url, '=' ) ) {
     333                // has at least one param
     334                $params = parse_url( $base_url );
     335                $url.= ( TRUE == $pretty ) ? '?' . $params[ 'query' ] : '&' . $params[ 'query' ];
     336            }           
    296337
    297338            return $url;
     
    314355         * @since   0.1a
    315356         */
    316         public function init_var ( $var, $index, $default = FALSE, $override_set_empty = FALSE ) {
     357        public function init_var( $var, $index, $default = FALSE, $override_set_empty = FALSE ) {
    317358
    318359            // is the $index of $var not yet set or (optional) set but empty?
     
    322363            return $var[ $index ];
    323364        }
     365
    324366    }
    325367
    326     // Instantiate class
    327     new threepagination();
    328368}
    329 
    330369?>
  • 3pagination/trunk/class.settings.php

    r565111 r565719  
    11<?php
     2/**
     3 * @TODO:
     4 * - Set placement template globally, not for each option
     5 * - Pretty URLs or not
     6 * - Max no. of pages
     7 *
     8 * 
     9 */
    210if ( !class_exists( 'threepagination_settings' ) ) {
    311
     
    1725         */
    1826        public function __construct() {
    19 
     27           
    2028            // Management page submenu
    2129            add_filter( 'admin_menu', array( $this, 'add_submenu' ) );
     
    3240        public function add_submenu() {
    3341
    34             add_management_page( __( '3pagination Configuration', $this->textdomain ), '3pagination', 'activate_plugins', '3pagination', array( $this, 'draw_settings_page' ) );
     42            add_options_page( __( '3pagination Configuration', parent::$_object->textdomain ), '3pagination', 'activate_plugins', '3pagination', array( $this, 'draw_settings_page' ) );
    3543        }
    3644
     
    3947            <div class="wrap">
    4048                <?php screen_icon( 'options-general' ); ?>
    41                 <h2><?php _e( '3pagination Settings', $this->textdomain ); ?></h2>
     49                <h2><?php _e( '3pagination Settings', parent::$_object->textdomain ); ?></h2>
    4250
    4351                <form action="options.php" method="post">
     
    4553                    settings_fields( '3pagination_settings' );
    4654                    do_settings_sections( '3pagination' );
    47                     submit_button( __( 'Save Changes', $this->textdomain ), 'button-primary', 'submit', TRUE );
     55                    submit_button( __( 'Save Changes', parent::$_object->textdomain ), 'button-primary', 'submit', TRUE );
    4856                    ?>
    4957                </form>
     
    5563         * Init the settings API
    5664         *
     65         * @TODO checkbox "I am using pretty URLS"
     66         *
    5767         * @since 0.1
    5868         */
     
    6575            // Add the section to reading settings so we can add our
    6676            // fields to it         
    67             add_settings_section( '3pagination_preview', __( 'Preview', $this->textdomain ), array( $this, 'section_preview' ), '3pagination' );
    68             add_settings_section( '3pagination_labels', __( 'Labels', $this->textdomain ), array( $this, 'section_labels' ), '3pagination' );
    69             add_settings_section( '3pagination_placement', __( 'Placement', $this->textdomain ), array( $this, 'section_placement' ), '3pagination' );
    70             add_settings_section( '3pagination_css', __( 'DOM & CSS', $this->textdomain ), array( $this, 'section_css' ), '3pagination' );
     77            add_settings_section( '3pagination_preview', __( 'Preview', parent::$_object->textdomain ), array( $this, 'section_preview' ), '3pagination' );
     78            add_settings_section( '3pagination_labels', __( 'Labels', parent::$_object->textdomain ), array( $this, 'section_labels' ), '3pagination' );
     79            add_settings_section( '3pagination_placement', __( 'Placement', parent::$_object->textdomain ), array( $this, 'section_placement' ), '3pagination' );
     80            add_settings_section( '3pagination_css', __( 'DOM & CSS', parent::$_object->textdomain ), array( $this, 'section_css' ), '3pagination' );
     81            add_settings_section( '3pagination_other', __( 'Other options', parent::$_object->textdomain ), array( $this, 'section_other' ), '3pagination' );
    7182
    7283            // Add the field with the names and function to use for our new
    7384            // settings, put it in our new section
    74             add_settings_field( 'threepagination_preview', __( 'Preview of pagination', $this->textdomain ), array( $this, 'preview' ), '3pagination', '3pagination_preview' );
    75 
    76             add_settings_field( 'threepagination_labels_show', __( 'Show labels', $this->textdomain ), array( $this, 'labels_show' ), '3pagination', '3pagination_labels' );
    77             add_settings_field( 'threepagination_labels_previous', __( 'Previous page', $this->textdomain ), array( $this, 'labels_previous' ), '3pagination', '3pagination_labels' );
    78             add_settings_field( 'threepagination_labels_next', __( 'Next page', $this->textdomain ), array( $this, 'labels_next' ), '3pagination', '3pagination_labels' );
    79             add_settings_field( 'threepagination_labels_first', __( 'First page', $this->textdomain ), array( $this, 'labels_first' ), '3pagination', '3pagination_labels' );
    80             add_settings_field( 'threepagination_labels_last', __( 'Last page', $this->textdomain ), array( $this, 'labels_last' ), '3pagination', '3pagination_labels' );
    81        
    82             add_settings_field( 'threepagination_css_class', __( 'Set CSS class', $this->textdomain ), array( $this, 'css_class' ), '3pagination', '3pagination_css' );         
    83            
    84             add_settings_field( 'threepagination_placement_header', __( 'Inject below header', $this->textdomain ), array( $this, 'placement_header' ), '3pagination', '3pagination_placement' );
    85             add_settings_field( 'threepagination_placement_footer', __( 'Inject above footer', $this->textdomain ), array( $this, 'placement_footer' ), '3pagination', '3pagination_placement' );       
    86            
    87             add_settings_field( 'threepagination_placement_prepend', __( 'Prepend to', $this->textdomain ), array( $this, 'placement_prepend' ), '3pagination', '3pagination_placement' );     
    88             add_settings_field( 'threepagination_placement_append', __( 'Append to', $this->textdomain ), array( $this, 'placement_append' ), '3pagination', '3pagination_placement' );     
    89 
     85            add_settings_field( 'threepagination_preview', __( 'Preview of pagination', parent::$_object->textdomain ), array( $this, 'preview' ), '3pagination', '3pagination_preview' );
     86
     87            add_settings_field( 'threepagination_labels_show', __( 'Show labels', parent::$_object->textdomain ), array( $this, 'labels_show' ), '3pagination', '3pagination_labels' );
     88            add_settings_field( 'threepagination_labels_previous', __( 'Previous page', parent::$_object->textdomain ), array( $this, 'labels_previous' ), '3pagination', '3pagination_labels' );
     89            add_settings_field( 'threepagination_labels_next', __( 'Next page', parent::$_object->textdomain ), array( $this, 'labels_next' ), '3pagination', '3pagination_labels' );
     90            add_settings_field( 'threepagination_labels_first', __( 'First page', parent::$_object->textdomain ), array( $this, 'labels_first' ), '3pagination', '3pagination_labels' );
     91            add_settings_field( 'threepagination_labels_last', __( 'Last page', parent::$_object->textdomain ), array( $this, 'labels_last' ), '3pagination', '3pagination_labels' );
     92       
     93            add_settings_field( 'threepagination_css_class', __( 'Set CSS class', parent::$_object->textdomain ), array( $this, 'css_class' ), '3pagination', '3pagination_css' );         
     94           
     95            add_settings_field( 'threepagination_placement_header', __( 'Inject below header', parent::$_object->textdomain ), array( $this, 'placement_header' ), '3pagination', '3pagination_placement' );
     96            add_settings_field( 'threepagination_placement_footer', __( 'Inject above footer', parent::$_object->textdomain ), array( $this, 'placement_footer' ), '3pagination', '3pagination_placement' );       
     97           
     98            add_settings_field( 'threepagination_placement_prepend', __( 'Prepend to', parent::$_object->textdomain ), array( $this, 'placement_prepend' ), '3pagination', '3pagination_placement' );       
     99            add_settings_field( 'threepagination_placement_append', __( 'Append to', parent::$_object->textdomain ), array( $this, 'placement_append' ), '3pagination', '3pagination_placement' );     
     100
     101            add_settings_field( 'threepagination_other_maxnumpages', __( 'Max no. of pages', parent::$_object->textdomain ), array( $this, 'other_maxnumpages' ), '3pagination', '3pagination_other' );     
     102            add_settings_field( 'threepagination_other_pretty', __( 'Pretty URLs enabled?', parent::$_object->textdomain ), array( $this, 'other_pretty' ), '3pagination', '3pagination_other' );
     103           
    90104        }
    91105       
     
    97111        public function section_preview() {
    98112            ?>
    99             <!--<span class="description"><?php _e( 'Preview of pagination' ); ?></span>-->
     113            <!--<span class="description"><?php _e( 'Preview of pagination', parent::$_object->textdomain ); ?></span>-->
    100114            <?php           
    101115        }
     
    108122        public function section_labels() {
    109123            ?>
    110             <span class="description"><?php _e( 'Define the navigation labels characters' ); ?></span>
     124            <span class="description"><?php _e( 'Define the navigation labels characters', parent::$_object->textdomain ); ?></span>
    111125            <?php
    112126        }
     
    119133        public function section_css() {
    120134            ?>
    121             <span class="description"><?php _e( 'Set your stylesheet for the pagination' ); ?></span>
    122             <?php
    123         }
     135            <span class="description"><?php _e( 'Set your stylesheet for the pagination', parent::$_object->textdomain ); ?></span>
     136            <?php
     137        }
     138       
     139        /**
     140         * Head of "Other options" section
     141         *
     142         * @since 0.1
     143         */
     144        public function section_other() {
     145            ?>
     146            <span class="description"><?php _e( '', parent::$_object->textdomain ); ?></span>
     147            <?php
     148        }       
    124149       
    125150        /**
     
    131156            ?>
    132157            <p>
    133             <span class="description"><?php _e( '<b>Inject:</b> You can "inject" the navigation bar below the header or above the footer div. Your theme needs to have an according HTML structure (which most WordPress themes do).' ); ?></span>
     158            <span class="description"><?php _e( '<b>Inject:</b> You can "inject" the navigation bar below the header or above the footer div. Your theme needs to have an according HTML structure (which most WordPress themes do).', parent::$_object->textdomain ); ?></span>
    134159            <br />
    135             <span class="description"><?php _e( '<b>Append/Prepend:</b> You can specifiy a container into which the pagination will be prepended/appended. Write it CSS-style, i.e. #mycontainer' ); ?></span>
     160            <span class="description"><?php _e( '<b>Append/Prepend:</b> You can specifiy a container into which the pagination will be prepended/appended. Write it CSS-style, i.e. #mycontainer', parent::$_object->textdomain ); ?></span>
    136161            <br />
    137             <span class="description"><?php _e( '<b>Note:</b> If you want your site to degrade gracefully, you should additionaly hardcode the pagination function into your theme files: <input style="background-color:lightgrey" size="45" type="text" value="<noscript><?php threepagination::draw(); ?></noscript>"' ); ?></span>
     162            <span class="description"><?php _e( '<b>Note:</b> If you want your site to degrade gracefully, you should additionaly hardcode the pagination function into your theme files: <input style="background-color:lightgrey" size="45" type="text" value="<noscript><?php threepagination::draw(); ?></noscript>"', parent::$_object->textdomain ); ?></span>
    138163            </p>
    139164            <?php
     
    215240        }
    216241       
     242        /**
     243         * Inject below header
     244         *
     245         * @since 0.1
     246         */
     247        public function placement_header() {
     248
     249            $settings = get_option( '3pagination_settings', TRUE );
     250            ?>
     251            <input type="checkbox" name="3pagination_settings[placement_header_index]" <?php checked( $this->init_var( $settings, 'placement_header_index', FALSE ), 'on' ); ?> />
     252            <label for="3pagination_settings[placement_header_index]"><?php _e( 'Index pages', parent::$_object->textdomain ); ?></label>
     253            <input type="checkbox" name="3pagination_settings[placement_header_archive]" <?php checked( $this->init_var( $settings, 'placement_header_archive', FALSE ), 'on' ); ?> />
     254            <label for="3pagination_settings[placement_header_archive]"><?php _e( 'Archive pages', parent::$_object->textdomain ); ?></label>
     255            <input type="checkbox" name="3pagination_settings[placement_header_category]" <?php checked( $this->init_var( $settings, 'placement_header_category', FALSE ), 'on' ); ?> />
     256            <label for="3pagination_settings[placement_header_category]"><?php _e( 'Category pages', parent::$_object->textdomain ); ?></label>         
     257            <input type="checkbox" name="3pagination_settings[placement_header_search]" <?php checked( $this->init_var( $settings, 'placement_header_search', FALSE ), 'on' ); ?> />
     258            <label for="3pagination_settings[placement_header_search]"><?php _e( 'Search pages', parent::$_object->textdomain ); ?></label>
     259            <?php
     260        }
     261       
     262        /**
     263         * Inject above footer
     264         *
     265         * @since 0.1
     266         */
     267        public function placement_footer() {
     268
     269            $settings = get_option( '3pagination_settings', TRUE );
     270            ?>
     271            <input type="checkbox" name="3pagination_settings[placement_footer_index]" <?php checked( $this->init_var( $settings, 'placement_footer_index', FALSE ), 'on' ); ?> />
     272            <label for="3pagination_settings[placement_footer_index]"><?php _e( 'Index pages', parent::$_object->textdomain ); ?></label>
     273            <input type="checkbox" name="3pagination_settings[placement_footer_archive]" <?php checked( $this->init_var( $settings, 'placement_footer_archive', FALSE ), 'on' ); ?> />
     274            <label for="3pagination_settings[placement_footer_archive]"><?php _e( 'Archive pages', parent::$_object->textdomain ); ?></label>
     275            <input type="checkbox" name="3pagination_settings[placement_footer_category]" <?php checked( $this->init_var( $settings, 'placement_footer_category', FALSE ), 'on' ); ?> />
     276            <label for="3pagination_settings[placement_footer_category]"><?php _e( 'Category pages', parent::$_object->textdomain ); ?></label>         
     277            <input type="checkbox" name="3pagination_settings[placement_footer_search]" <?php checked( $this->init_var( $settings, 'placement_footer_search', FALSE ), 'on' ); ?> />
     278            <label for="3pagination_settings[placement_footer_search]"><?php _e( 'Search pages', parent::$_object->textdomain ); ?></label>         
     279            <?php
     280        }
     281       
     282        /**
     283         * Prepend to custom container
     284         *
     285         * @since 0.1
     286         */
     287        public function placement_prepend() {
     288
     289            $settings = get_option( '3pagination_settings', TRUE );
     290            ?>
     291            <input type="text" name="3pagination_settings[placement_prepend_id]" value="<?php echo $this->init_var( $settings, 'placement_prepend_id', FALSE ); ?>" />         
     292            <label for="3pagination_settings[placement_prepend_id]"><?php _e( 'in', parent::$_object->textdomain ); ?></label>         
     293            <input type="checkbox" name="3pagination_settings[placement_prepend_index]" <?php checked( $this->init_var( $settings, 'placement_prepend_index', FALSE ), 'on' ); ?> />
     294            <label for="3pagination_settings[placement_prepend_index]"><?php _e( 'Index pages', parent::$_object->textdomain ); ?></label>
     295            <input type="checkbox" name="3pagination_settings[placement_prepend_archive]" <?php checked( $this->init_var( $settings, 'placement_prepend_archive', FALSE ), 'on' ); ?> />
     296            <label for="3pagination_settings[placement_prepend_archive]"><?php _e( 'Archive pages', parent::$_object->textdomain ); ?></label>
     297            <input type="checkbox" name="3pagination_settings[placement_prepend_category]" <?php checked( $this->init_var( $settings, 'placement_prepend_category', FALSE ), 'on' ); ?> />
     298            <label for="3pagination_settings[placement_prepend_category]"><?php _e( 'Category pages', parent::$_object->textdomain ); ?></label>   
     299            <input type="checkbox" name="3pagination_settings[placement_prepend_search]" <?php checked( $this->init_var( $settings, 'placement_prepend_search', FALSE ), 'on' ); ?> />
     300            <label for="3pagination_settings[placement_prepend_search]"><?php _e( 'Search pages', parent::$_object->textdomain ); ?></label>           
     301            <?php
     302        }
     303       
     304        /**
     305         * Append to custom container
     306         *
     307         * @since 0.1
     308         */
     309        public function placement_append() {
     310
     311            $settings = get_option( '3pagination_settings', TRUE );
     312            ?>
     313            <input type="text" name="3pagination_settings[placement_append_id]" value="<?php echo $this->init_var( $settings, 'placement_append_id', FALSE ); ?>" />           
     314            <label for="3pagination_settings[placement_append_id]"><?php echo _x( 'in', 'Zeige Pagination "in" diesen Seiten an', parent::$_object->textdomain ); ?></label>                       
     315            <input type="checkbox" name="3pagination_settings[placement_append_index]" <?php checked( $this->init_var( $settings, 'placement_append_index', FALSE ), 'on' ); ?> />
     316            <label for="3pagination_settings[placement_append_index]"><?php _e( 'Index pages', parent::$_object->textdomain ); ?></label>
     317            <input type="checkbox" name="3pagination_settings[placement_append_archive]" <?php checked( $this->init_var( $settings, 'placement_append_archive', FALSE ), 'on' ); ?> />
     318            <label for="3pagination_settings[placement_append_archive]"><?php _e( 'Archive pages', parent::$_object->textdomain ); ?></label>
     319            <input type="checkbox" name="3pagination_settings[placement_append_category]" <?php checked( $this->init_var( $settings, 'placement_append_category', FALSE ), 'on' ); ?> />
     320            <label for="3pagination_settings[placement_append_category]"><?php _e( 'Category pages', parent::$_object->textdomain ); ?></label>
     321            <input type="checkbox" name="3pagination_settings[placement_append_search]" <?php checked( $this->init_var( $settings, 'placement_append_search', FALSE ), 'on' ); ?> />
     322            <label for="3pagination_settings[placement_append_search]"><?php _e( 'Search pages', parent::$_object->textdomain ); ?></label>
     323            <?php
     324        }
     325
    217326        /**
    218327         * Set CSS class
     
    230339        }
    231340       
    232         /**
    233          * Inject below header
    234          *
    235          * @since 0.1
    236          */
    237         public function placement_header() {
    238 
    239             $settings = get_option( '3pagination_settings', TRUE );
    240             ?>
    241             <input type="checkbox" name="3pagination_settings[placement_header_index]" <?php checked( $this->init_var( $settings, 'placement_header_index', FALSE ), 'on' ); ?> />
    242             <label for="3pagination_settings[placement_header_index]"><?php _e( 'Index pages' ); ?></label>
    243             <input type="checkbox" name="3pagination_settings[placement_header_archive]" <?php checked( $this->init_var( $settings, 'placement_header_archive', FALSE ), 'on' ); ?> />
    244             <label for="3pagination_settings[placement_header_archive]"><?php _e( 'Archive pages' ); ?></label>
    245             <input type="checkbox" name="3pagination_settings[placement_header_category]" <?php checked( $this->init_var( $settings, 'placement_header_category', FALSE ), 'on' ); ?> />
    246             <label for="3pagination_settings[placement_header_category]"><?php _e( 'Category pages' ); ?></label>           
    247             <input type="checkbox" name="3pagination_settings[placement_header_search]" <?php checked( $this->init_var( $settings, 'placement_header_search', FALSE ), 'on' ); ?> />
    248             <label for="3pagination_settings[placement_header_search]"><?php _e( 'Search pages' ); ?></label>
    249             <?php
    250         }
    251        
    252         /**
    253          * Inject above footer
    254          *
    255          * @since 0.1
    256          */
    257         public function placement_footer() {
    258 
    259             $settings = get_option( '3pagination_settings', TRUE );
    260             ?>
    261             <input type="checkbox" name="3pagination_settings[placement_footer_index]" <?php checked( $this->init_var( $settings, 'placement_footer_index', FALSE ), 'on' ); ?> />
    262             <label for="3pagination_settings[placement_footer_index]"><?php _e( 'Index pages' ); ?></label>
    263             <input type="checkbox" name="3pagination_settings[placement_footer_archive]" <?php checked( $this->init_var( $settings, 'placement_footer_archive', FALSE ), 'on' ); ?> />
    264             <label for="3pagination_settings[placement_footer_archive]"><?php _e( 'Archive pages' ); ?></label>
    265             <input type="checkbox" name="3pagination_settings[placement_footer_category]" <?php checked( $this->init_var( $settings, 'placement_footer_category', FALSE ), 'on' ); ?> />
    266             <label for="3pagination_settings[placement_footer_category]"><?php _e( 'Category pages' ); ?></label>           
    267             <input type="checkbox" name="3pagination_settings[placement_footer_search]" <?php checked( $this->init_var( $settings, 'placement_footer_search', FALSE ), 'on' ); ?> />
    268             <label for="3pagination_settings[placement_footer_search]"><?php _e( 'Search pages' ); ?></label>           
    269             <?php
    270         }
    271        
    272         /**
    273          * Prepend to custom container
    274          *
    275          * @since 0.1
    276          */
    277         public function placement_prepend() {
    278 
    279             $settings = get_option( '3pagination_settings', TRUE );
    280             ?>
    281             <input type="text" name="3pagination_settings[placement_prepend_id]" value="<?php echo $this->init_var( $settings, 'placement_prepend_id', FALSE ); ?>" />         
    282             <label for="3pagination_settings[placement_prepend_id]"><?php _e( 'in' ); ?></label>           
    283             <input type="checkbox" name="3pagination_settings[placement_prepend_index]" <?php checked( $this->init_var( $settings, 'placement_prepend_index', FALSE ), 'on' ); ?> />
    284             <label for="3pagination_settings[placement_prepend_index]"><?php _e( 'Index pages' ); ?></label>
    285             <input type="checkbox" name="3pagination_settings[placement_prepend_archive]" <?php checked( $this->init_var( $settings, 'placement_prepend_archive', FALSE ), 'on' ); ?> />
    286             <label for="3pagination_settings[placement_prepend_archive]"><?php _e( 'Archive pages' ); ?></label>
    287             <input type="checkbox" name="3pagination_settings[placement_prepend_category]" <?php checked( $this->init_var( $settings, 'placement_prepend_category', FALSE ), 'on' ); ?> />
    288             <label for="3pagination_settings[placement_prepend_category]"><?php _e( 'Category pages' ); ?></label> 
    289             <input type="checkbox" name="3pagination_settings[placement_prepend_search]" <?php checked( $this->init_var( $settings, 'placement_prepend_search', FALSE ), 'on' ); ?> />
    290             <label for="3pagination_settings[placement_prepend_search]"><?php _e( 'Search pages' ); ?></label>         
    291             <?php
    292         }
    293        
    294         /**
    295          * Append to custom container
    296          *
    297          * @since 0.1
    298          */
    299         public function placement_append() {
    300 
    301             $settings = get_option( '3pagination_settings', TRUE );
    302             ?>
    303             <input type="text" name="3pagination_settings[placement_append_id]" value="<?php echo $this->init_var( $settings, 'placement_append_id', FALSE ); ?>" />           
    304             <label for="3pagination_settings[placement_append_id]"><?php _e( 'in' ); ?></label>                     
    305             <input type="checkbox" name="3pagination_settings[placement_append_index]" <?php checked( $this->init_var( $settings, 'placement_append_index', FALSE ), 'on' ); ?> />
    306             <label for="3pagination_settings[placement_append_index]"><?php _e( 'Index pages' ); ?></label>
    307             <input type="checkbox" name="3pagination_settings[placement_append_archive]" <?php checked( $this->init_var( $settings, 'placement_append_archive', FALSE ), 'on' ); ?> />
    308             <label for="3pagination_settings[placement_append_archive]"><?php _e( 'Archive pages' ); ?></label>
    309             <input type="checkbox" name="3pagination_settings[placement_append_category]" <?php checked( $this->init_var( $settings, 'placement_append_category', FALSE ), 'on' ); ?> />
    310             <label for="3pagination_settings[placement_append_category]"><?php _e( 'Category pages' ); ?></label>   
    311             <input type="checkbox" name="3pagination_settings[placement_append_search]" <?php checked( $this->init_var( $settings, 'placement_append_search', FALSE ), 'on' ); ?> />
    312             <label for="3pagination_settings[placement_append_search]"><?php _e( 'Search pages' ); ?></label>
    313             <?php
    314         }
    315 
    316 
     341        public function other_maxnumpages() {
     342           
     343            $settings = get_option( '3pagination_settings', TRUE );
     344            ?>
     345            <input type="text" name="3pagination_settings[other_maxnumpages]" value="<?php echo $this->init_var( $settings, 'other_maxnumpages', '999', TRUE ); ?>" />
     346            <br />
     347            <span class="description">Limit to a maximum number of pagelinks</span>
     348                <?php   
     349        }
     350       
     351        public function other_pretty() {
     352           
     353            $settings = get_option( '3pagination_settings', TRUE );
     354                   
     355            ?>
     356            <input type="checkbox" name="3pagination_settings[other_pretty]" <?php checked( $this->init_var( $settings, 'other_pretty', 'on' ), 'on' ); ?> />
     357            <?php   
     358        }
     359       
    317360        /**
    318361         * Validate user input
     
    325368         */
    326369        public function threepagination_validate( $data ) {
    327 
     370           
    328371            $settings = get_option( '3pagination_settings' );
    329372
     
    358401            $settings[ 'placement_append_category' ] = esc_attr( $data[ 'placement_append_category' ] );
    359402           
    360            
    361             // Set this option to determine whether to display serverside fallback pagination
    362             foreach( $settings AS $key => $value ) {
    363                 if ( 0 === strpos( $key, 'placement_' ) && ! empty( $value ) ) {
    364                         $settings[ 'hide_serverside' ] = TRUE;
    365                         break; 
    366                 }
    367             }
     403            $settings[ 'other_maxnumpages' ] = intval( $data[ 'other_maxnumpages' ] );
     404            $settings[ 'other_pretty' ] = esc_attr( $data[ 'other_pretty' ] );
    368405
    369406            return $settings;
  • 3pagination/trunk/readme.txt

    r565375 r565719  
    44Requires at least: 3.3.2
    55Tested up to: 3.4.1
    6 Stable tag: 1.2b
     6Stable tag: 1.3b
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    28281. Upload `3pagination.php` to the `/wp-content/plugins/` directory OR choose `Plugins->Add New` and type "3pagination".
    29292. Activate the plugin through the `Plugins` menu in WordPress
    30 3. Go to `Tools->3pagination` to set labels, placement and CSS.
     303. Go to `Settings->3pagination` to set labels, placement and CSS.
    31314. Done!
    3232
    33 <h4>Implementation</h4>
     33<h4>How to use</h4>
    3434All options can be set in an options page, the pagination container can be injected or appended to the existing DOM.
    3535If you are unsure about the HTML structure of your Website, you can do the following (in Firefox):
     
    3737<li>Right click the spot where you wish the pagination to appear and choose `Inspect Element (Q)` from the menu list</li>
    3838<li>Copy the id of the container, i.e. #wrapper.someclass</li>
    39 <li>To append or prepend the pagination to this container, paste it's id into the appropriate field of the Placement section under `Tools->3pagination`</li>
     39<li>To append or prepend the pagination to this container, paste it's id into the appropriate field of the Placement section under `Settings->3pagination`</li>
    4040<li>Choose on which pages (archives, search etc.) the pagination should appear. Done!</li>
    4141</ol>
    4242
    4343
    44 <h4>Implementation - old school</h4>
     44<h4>How to use - old school</h4>
    4545You can, if you want (or to have your website degrade gracefully), call the class methods in your theme files.
    4646
     
    6666== Screenshots ==
    6767
    68 1. Option page: preview, label, placement and CSS
    69 2. Example of a pagination display, 'classic' style
    70 3. 'classic-glow' style
    71 4. 'classic-small' style
     681. Settings page: preview, label, placement, CSS and other settings
     692. Injected below header
    7270
    7371== Changelog ==
     
    9088- Support for search templates
    9189
     90= 1.3b =
     91- Added checkbox for pretty URLs;
     92- Added option for max no. of pages
     93- Fixed link URL building;
     94- German localization;
     95- Plugin loading enqueued;
     96- Fixed bug with pagination link;
     97
    9298== A brief Markdown Example ==
    9399
Note: See TracChangeset for help on using the changeset viewer.