set_activation_hooks(); //Language Setup load_plugin_textdomain('wp-paginate', false, "$name/I18n/"); //"Constants" setup $this->pluginurl = plugins_url($name) . "/"; $this->pluginpath = WP_PLUGIN_DIR . "/$name/"; //Initialize the options $this->get_options(); //Actions add_action( 'init', array(&$this, 'init_pagination')); add_action('admin_menu', array(&$this, 'admin_menu_link')); add_action('admin_enqueue_scripts', array($this, 'wpp_admin_head')); add_action('wp_enqueue_scripts', array($this, 'wpp_enqueue_custom_css'), 20); add_action('admin_notices', array($this, 'show_wpp_admin_notice')); add_action('wp_ajax_nopriv_wpp_dismiss_notice', array($this, 'wpp_dismiss_notice')); add_action('wp_ajax_wpp_dismiss_notice', array($this, 'wpp_dismiss_notice')); add_action('wp_ajax_nopriv_wpp_set_review_later', array($this, 'wpp_set_review_later')); add_action('wp_ajax_wpp_set_review_later', array($this, 'wpp_set_review_later')); $this->positions = array( 'none' => __('Function only', 'wp-paginate'), 'below' => __('Below the Content', 'wp-paginate'), 'above' => __('Above the Content', 'wp-paginate'), 'both' => __('Above and Below the Content', 'wp-paginate') ); $this->fonts = array( 'font-inherit' => __('inherit', 'wp-paginate'), 'font-initial' => __('initial', 'wp-paginate'), 'font-arial' => __('Arial', 'wp-paginate'), 'font-georgia' => __('Georgia', 'wp-paginate'), 'font-tahoma' => __('Tahoma', 'wp-paginate'), 'font-times' => __('Times New Roman', 'wp-paginate'), 'font-trebuchet' => __('Trebuchet MS', 'wp-paginate'), 'font-verdana' => __('Verdana', 'wp-paginate') ); $this->presets = array( array('default', __('Grey Buttons', 'wp-paginate'), 'default.jpg'), array('wpp-blue-cta', __('Blue Buttons', 'wp-paginate'), 'blue-cta-buttons.jpg'), array('wpp-modern-grey', __('Modern Grey Buttons', 'wp-paginate'), 'modern-grey-buttons.jpg'), array('wpp-neon-pink', __('Neon Pink Buttons', 'wp-paginate'), 'neon-pink-buttons.png'), ); if ($this->options['css']) add_action('wp_print_styles', array(&$this, 'wp_paginate_css')); } public function set_activation_hooks() { register_activation_hook(__FILE__, array($this, 'do_activation')); register_deactivation_hook(__FILE__, array($this, 'do_deactivation')); } public function do_activation() { $this->activate(); } public function do_deactivation() { $this->deactivate(); } public function activate() { $current_user_id = get_current_user_id(); if(get_user_meta( $current_user_id, WPP_REVIEW_NOTICE, true ) !== "off" ) { $review_date = date('Y-m-d', strtotime("+2 days")); update_user_meta( $current_user_id, WPP_REVIEW_NOTICE, $review_date ); } } public function deactivate() { } public function init_pagination() { if(isset($this->options['everywhere']) && isset($this->options['position'])) { if ($this->options['position'] === 'above' || $this->options['position'] === 'both') add_filter( 'loop_start', array($this, 'add_pagination_to_page_top')); if ($this->options['position'] === 'below' || $this->options['position'] === 'both') add_filter( 'loop_end', array($this, 'add_pagination_to_page_bottom')); if ($this->options['everywhere'] && ($this->options['position'] === 'below' || $this->options['position'] === 'both')) add_filter( 'wp_link_pages', array($this, 'add_pagination_to_page_bottom'), 10, 2 ); if ($this->options['everywhere'] && ($this->options['position'] === 'above' || $this->options['position'] === 'both')) add_filter( 'wp_link_pages', array($this, 'add_pagination_to_page_top'), 10, 2 ); } } function add_pagination_to_page_bottom($content) { $this->get_options(); if(defined('WPP-DEBUG')) { $output = print_r($this->options, true); error_log($output); } if( ($this->options['home-page'] && is_front_page()) || ($this->options['blog-page'] && is_home()) || ($this->options['search-page'] && is_search()) || ($this->options['category-page'] && is_category()) || ($this->options['archive-page'] && is_archive()) || ($this->options['everywhere']) ) { if ( is_feed() ) return $content; global $wp_query, $wp_paginate_display_bottom; if ( is_main_query() && $content === $wp_query && ! $wp_paginate_display_bottom ) { $wp_paginate_display_bottom = true; wp_paginate(); } } } function add_pagination_to_page_top($content) { $this->get_options(); if(defined('WPP-DEBUG')) { $output = print_r($this->options, true); error_log($output); } if( ($this->options['home-page'] && is_front_page()) || ($this->options['blog-page'] && is_home()) || ($this->options['search-page'] && is_search()) || ($this->options['category-page'] && is_category()) || ($this->options['archive-page'] && is_archive()) || ($this->options['everywhere']) ) { if ( is_feed() ) return $content; global $wp_query, $wp_paginate_display_top; if ( is_main_query() && $content === $wp_query && ! $wp_paginate_display_top ) { $wp_paginate_display_top = true; wp_paginate(); } } } function wpp_admin_head($hook) { if ( isset( $_REQUEST['page'] ) && 'wp-paginate.php' == $_REQUEST['page'] ) { //wp_enqueue_style( 'bootstrap', plugins_url( '/css/bootstrap/bootstrap.min.css', __FILE__ )); if ( isset( $_GET['action'] ) && 'custom_css' == $_GET['action'] ) $this->wpp_include_codemirror(); } wp_enqueue_style( 'wp-paginate-admin', plugins_url( '/css/wp-paginate-admin.css', __FILE__ )); wp_enqueue_script('jquery'); wp_register_script( 'wpp-script', $this->pluginurl .'js/wp-paginate.js', array( 'jquery' ), '', true ); wp_localize_script( 'wpp-script', 'wpp_ajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'nonce'=> wp_create_nonce(WP_PAGINATE_NONCE)) ); wp_enqueue_script('wpp-script'); } function wpp_enqueue_custom_css() { $wpp_custom_css_active = get_option('wpp_custom_css_active', 'off'); if($wpp_custom_css_active === 'on') { $upload_dir = wp_upload_dir(); $wpp_css_file = $upload_dir['baseurl'] . '/wpp-custom-code/wpp-custom-code.css'; wp_enqueue_style( 'wpp-custom-style', $wpp_css_file, array('wp-paginate') ); } } /** * Pagination based on options/args */ function paginate($args = false) { if ($this->type === 'comments' && !get_option('page_comments')) return; $r = wp_parse_args($args, $this->options); extract($r, EXTR_SKIP); //error_log("r " . print_r($r, true)); if(isset($this->options['preset'])) $preset = $this->options['preset']; else $preset = 'default'; if(isset($this->options['font'])) $font = $this->options['font']; else $font = 'font-inherit'; if(isset($before)) $before_option = $before; else if(isset($this->options['before'])) $before_option = $this->options['before']; else $before_option = ''; if(isset($this->options['slash'])) $slash_option = $this->options['slash']; else $slash_option = false; $before = stripslashes(html_entity_decode($before_option)); $after = stripslashes(html_entity_decode($after_option)); if (!isset($page) && !isset($pages)) { global $wp_query; if ($this->type === 'posts') { $page = get_query_var('paged'); $posts_per_page = intval(get_query_var('posts_per_page')); $pages = intval(ceil($wp_query->found_posts / $posts_per_page)); } else { $page = get_query_var('cpage'); $comments_per_page = get_option('comments_per_page'); $pages = get_comment_pages_count(); } $page = !empty($page) ? intval($page) : 1; } $prevlink = ($this->type === 'posts') ? rtrim(esc_url(get_pagenum_link($page - 1)), '/') : get_comments_pagenum_link($page - 1); $nextlink = ($this->type === 'posts') ? rtrim(esc_url(get_pagenum_link($page + 1)), '/') : get_comments_pagenum_link($page + 1); //if($slash_option == true) { // $prevlink . '/'; // $nextlink . '/'; //} $output = stripslashes(wp_kses_decode_entities($before)); if ($pages > 1) { if($preset === 'default') $output .= sprintf('
    ', ($this->type === 'posts') ? '' : ' wp-paginate-comments'); else $output .= sprintf('
      ', ($this->type === 'posts') ? '' : ' wp-paginate-comments'); if (strlen(stripslashes($title)) > 0) { $output .= sprintf('
    1. %s
    2. ', stripslashes($title)); } $ellipsis = "
    3. ...
    4. "; if ($page > 1 && !empty($previouspage)) { $prevlink = rtrim($prevlink, '/'); $contains_param = (strpos($prevlink, '?') !== false) ? true : false; if($slash_option && !$contains_param) $output .= sprintf('
    5. ', $prevlink, stripslashes($previouspage)); else $output .= sprintf('
    6. ', $prevlink, stripslashes($previouspage)); } $min_links = $range * 2 + 1; $block_min = min($page - $range, $pages - $min_links); $block_high = max($page + $range, $min_links); $left_gap = (($block_min - $anchor - $gap) > 0) ? true : false; $right_gap = (($block_high + $anchor + $gap) < $pages) ? true : false; if ($left_gap && !$right_gap) { $output .= sprintf('%s%s%s', $this->paginate_loop(1, $anchor, 0, $slash_option), $ellipsis, $this->paginate_loop($block_min, $pages, $page, $slash_option) ); } else if ($left_gap && $right_gap) { $output .= sprintf('%s%s%s%s%s', $this->paginate_loop(1, $anchor, 0, $slash_option), $ellipsis, $this->paginate_loop($block_min, $block_high, $page, $slash_option), $ellipsis, $this->paginate_loop(($pages - $anchor + 1), $pages, 0, $slash_option) ); } else if ($right_gap && !$left_gap) { $output .= sprintf('%s%s%s', $this->paginate_loop(1, $block_high, $page, $slash_option), $ellipsis, $this->paginate_loop(($pages - $anchor + 1), $pages, 0, $slash_option) ); } else { $output .= $this->paginate_loop(1, $pages, $page, $slash_option); } if ($page < $pages && !empty($nextpage)) { $nextlink = rtrim($nextlink, '/'); $contains_param = (strpos($nextlink, '?') !== false) ? true : false; if($slash_option && !$contains_param) $output .= sprintf('
    7. ', $nextlink, stripslashes($nextpage)); else $output .= sprintf('
    8. ', $nextlink, stripslashes($nextpage)); } $output .= "
    "; } $output .= stripslashes(wp_kses_decode_entities($after)); if ($pages > 1 || $empty) { echo $output; } } /** * Helper function for pagination which builds the page links. */ function paginate_loop($start, $max, $page = 0, $slash = false) { $output = ""; for ($i = $start; $i <= $max; $i++) { if($slash) $p = ($this->type === 'posts') ? esc_url(get_pagenum_link($i)) : get_comments_pagenum_link($i); else $p = ($this->type === 'posts') ? rtrim(esc_url(get_pagenum_link($i)), '/') : get_comments_pagenum_link($i); $output .= ($page == intval($i)) ? "
  1. $i
  2. " : "
  3. $i
  4. "; } return $output; } function wp_paginate_css() { $name = "css/wp-paginate.css"; if (false !== @file_exists(STYLESHEETPATH . "/$name")) { $css = get_stylesheet_directory_uri() . "/$name"; } else { $css = $this->pluginurl . $name; } wp_enqueue_style('wp-paginate', $css, false, $this->version, 'screen'); if (function_exists('is_rtl') && is_rtl()) { $name = "css/wp-paginate-rtl.css"; if (false !== @file_exists(STYLESHEETPATH . "/$name")) { $css = get_stylesheet_directory_uri() . "/$name"; } else { $css = $this->pluginurl . $name; } wp_enqueue_style('wp-paginate-rtl', $css, false, $this->version, 'screen'); } wp_enqueue_style( 'wpp-advanced-styles', $this->wpp_print_style() ); } /** * Retrieves the plugin options from the database. * @return array */ function get_options() { if (!$options = get_option($this->optionsName)) { $options = array( 'title' => 'Pages:', 'nextpage' => '»', 'previouspage' => '«', 'css' => true, 'slash' => false, 'before' => '', 'empty' => true, 'range' => 3, 'anchor' => 1, 'gap' => 3, 'everywhere' => false, 'home-page' => false, 'blog-page' => false, 'search-page' => false, 'category-page' => false, 'archive-page' => false, 'position' => 'none', 'hide-standard-pagination' => false, 'font' => 'font-inherit', 'preset' => 'default' ); update_option($this->optionsName, $options); } $this->options = $options; } /** * Saves the admin options to the database. */ function save_admin_options(){ if(defined('WPP-DEBUG')) { $output = print_r($this->options, true); error_log($output); } return update_option($this->optionsName, $this->options); } /** * @desc Adds the options subpanel */ function admin_menu_link() { add_options_page('WP-Paginate', 'WP-Paginate', 'manage_options', basename(__FILE__), array(&$this, 'admin_options_page')); add_filter('plugin_action_links_' . plugin_basename(__FILE__), array(&$this, 'filter_plugin_actions'), 10, 2 ); } /** * @desc Adds the Settings link to the plugin activate/deactivate page */ function filter_plugin_actions($links, $file) { $settings_link = '' . __('Settings', 'wp-paginate') . ''; array_unshift($links, $settings_link); // before other links return $links; } /** * Adds settings/options page */ function admin_options_page() { if (isset($_POST['wp_paginate_save'])) { if (wp_verify_nonce($_POST['_wpnonce'], 'wp-paginate-update-options')) { if(defined('WPP-DEBUG')) { error_log("wp_paginate_save"); } $this->options['title'] = trim(stripslashes(strip_tags($_POST['title']))); $this->options['previouspage'] = trim(stripslashes(strip_tags($_POST['previouspage']))); $this->options['nextpage'] = trim(stripslashes(strip_tags($_POST['nextpage']))); $this->options['before'] = esc_attr($_POST['before']); $this->options['after'] = esc_attr($_POST['after']); $this->options['empty'] = (isset($_POST['empty']) && $_POST['empty'] === 'on') ? true : false; $this->options['css'] = (isset($_POST['css']) && $_POST['css'] === 'on') ? true : false; $this->options['slash'] = (isset($_POST['slash']) && $_POST['slash'] === 'on') ? true : false; $this->options['range'] = intval($_POST['range']); $this->options['anchor'] = intval($_POST['anchor']); $this->options['gap'] = intval($_POST['gap']); $this->options['everywhere'] = (isset($_POST['everywhere']) && $_POST['everywhere'] === 'on') ? true : false; $this->options['home-page'] = (isset($_POST['home-page']) && $_POST['home-page'] === 'on') ? true : false; $this->options['blog-page'] = (isset($_POST['blog-page']) && $_POST['blog-page'] === 'on') ? true : false; $this->options['search-page'] = (isset($_POST['search-page']) && $_POST['search-page'] === 'on') ? true : false; $this->options['category-page'] = (isset($_POST['category-page']) && $_POST['category-page'] === 'on') ? true : false; $this->options['archive-page'] = (isset($_POST['archive-page']) && $_POST['archive-page'] === 'on') ? true : false; if(isset($_POST['position'])) $this->options['position'] = $_POST['position']; $this->options['hide-standard-pagination'] = (isset($_POST['hide-standard-pagination']) && $_POST['hide-standard-pagination'] === 'on') ? true : false; if(isset($_POST['font'])) $this->options['font'] = $_POST['font']; if(isset($_POST['preset'])) $this->options['preset'] = $_POST['preset']; $this->save_admin_options(); echo '

    ' . __('Success! Your changes were successfully saved!', 'wp-paginate') . '

    '; } else { echo '

    ' . __('Whoops! There was a problem with the data you posted. Please try again.', 'wp-paginate') . '

    '; } } ?>

    WP-Paginate

     

    options['position'])) $position = $this->options['position']; else $position = 'none'; ?>

     

    ' name='preset' id='preset'>
    options['font'])) $font = $this->options['font']; else $font = 'font-inherit'; ?>

    Choose a preset style from the list below.

    options['preset'])) { $preset_option = $this->options['preset']; } else { $preset_option = 'default'; } ?> presets as $preset ) { ?>
    > <?php echo $preset[1]; ?> image" width="326" height="70">

     

    options['slash'])) $this->options['slash'] = false; ?>

     


    wpp_upgrade_to_pro_tab(); ?>

     


    Custom CSS

    wpp_custom_code_tab(); ?>

     


    WordPress Forum'); ?>

     

    WP Paginate is Maintained and Upgraded by Max Foundry
    Developed Originally by Eric Martin
    Max Foundry Produces These Other Fine Plugins
    ' . $css_file . '' ) . ' '; } else { $error .= __( 'Not enough permissions to create or update the file', 'wp-paginate' ) . ' ' . $real_css_file . '. '; } if(isset($_REQUEST['wpp_custom_css_active'])) $wpp_custom_css_active = 'on'; else $wpp_custom_css_active = 'off'; update_option('wpp_custom_css_active', $wpp_custom_css_active, true ); if ( ! empty( $error ) ) $error .= ' ' . __( 'Learn more', 'wp-paginate' ) . ''; } if ( file_exists( $real_css_file ) ) { update_recently_edited( $real_css_file ); $content_css = esc_textarea( file_get_contents( $real_css_file ) ); //$is_css_active = true; } else $content_css = ""; if ( ! empty( $message ) ) { ?>

    ' . $css_file . ''; } else { echo __( 'Browsing', 'wp-paginate' ) . ' ' . $css_file . ''; } ?>

    ', '' ); ?>

    get_options(); //global $pgntn_options; ?> wpp_show_review_notice(); } else { $now = date("Y-m-d"); $review_time = strtotime($review); $now_time = strtotime($now); if($now_time > $review_time) { $this->wpp_show_review_notice(); } } } } public function wpp_show_review_notice() { if( current_user_can( 'manage_options' ) ) { ?>

    Preset Layouts and Multi Site support!', 'wp-paginate'); ?>
    <?php _e('WP Pagination Pro buttons styles', 'wp-paginate'); ?>
    Exact Look and Feel You Want', 'wp-paginate'); ?>
    <?php _e('WP Pagination Por button Style customizer', 'wp-paginate'); ?>
    <?php _e('buy now button', 'wp-paginate'); ?>" width="205" height="68">
    type = 'posts'; return $wp_paginate->paginate($args); } } /** * Pagination function to use for post comments */ function wp_paginate_comments($args = false) { global $wp_paginate; $wp_paginate->type = 'comments'; return $wp_paginate->paginate($args); } /* * The format of this plugin is based on the following plugin template: * http://pressography.com/plugins/wordpress-plugin-template/ */