PluginProbe
WP-Paginate / trunk
WP-Paginate vtrunk
trunk 1.0 1.0.1 1.1 1.1.1 1.1.2 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3 1.3.1 1.3.2 1.3.3 1.3.4 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 All 43 releases
wp-paginate / wp-paginate.php

wp-paginate.php in WP-Paginate trunk, at wp-paginate.php

1,294 lines 56.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: WP-Paginate
4 Plugin URI: https://wordpress.org/plugins/wp-paginate/
5 Description: A simple and flexible pagination plugin for WordPress posts and comments.
6 Version: 2.2.6
7 Author: Max Foundry
8 Author URI: http://maxfoundry.com
9 Text Domain: 'wp-paginate'
10 */
11
12 /* Copyright 2016 Max Foundry (http://www.maxfoundry.com)
13
14 Plugin originally created by Eric Martin (http://www.ericmmartin.com) and
15 and improved upon by Studio Fuels.
16
17 This program is free software; you can redistribute it and/or modify
18 it under the terms of the GNU General Public License as published by
19 the Free Software Foundation; either version 2 of the License, or
20 (at your option) any later version.
21
22 This program is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 GNU General Public License for more details.
26
27 You should have received a copy of the GNU General Public License
28 along with this program; if not, write to the Free Software
29 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 */
31
32 // plugin links
33 if(!defined('WPP_MAXBUTTONS_LINK'))
34 define('WPP_MAXBUTTONS_LINK', 'https://maxbuttons.com/?utm_source=wpp-descv2&utm_medium=wpp-plugin&utm_content=wpp-footer&utm_campaign=wpp-descv2');
35 if(!defined('WPP_MAXGALLERIA_LINK'))
36 define('WPP_MAXGALLERIA_LINK', 'https://maxgalleria.com/?utm_source=wpp-descv2&utm_medium=wpp-plugin&utm_content=wpp-footer&utm_campaign=wpp-descv2');
37 if(!defined('WPP_MEDIA_LIBRARY_PLUS_PRO_LINK'))
38 define('WPP_MEDIA_LIBRARY_PLUS_PRO_LINK', 'https://maxgalleria.com/downloads/media-library-plus-pro/?utm_source=wpp-descv2&utm_medium=wpp-plugin&utm_content=wpp-footer&utm_campaign=wpp-descv2');
39 if(!defined('WPP_WP_PAGINATE_PRO_LINK'))
40 define("WPP_WP_PAGINATE_PRO_LINK", "https://maxgalleria.com/downloads/wp-paginate-pro/");
41
42 define("WPP_REVIEW_NOTICE", "wpp_review_notice");
43 if(!defined("WP_PAGINATE_NONCE"))
44 define("WP_PAGINATE_NONCE", "wpp_js_nonce");
45
46 /**
47 * Set the wp-content and plugin urls/paths
48 */
49 if (!defined('WP_CONTENT_URL'))
50 define('WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
51 if (!defined('WP_CONTENT_DIR'))
52 define('WP_CONTENT_DIR', ABSPATH . 'wp-content');
53 if (!defined('WP_PLUGIN_URL') )
54 define('WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins');
55 if (!defined('WP_PLUGIN_DIR') )
56 define('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins');
57
58 if (!class_exists('WPPaginate')) {
59 class WPPaginate {
60 /**
61 * @var string The plugin version
62 */
63 public $version = '2.2.6';
64
65 /**
66 * @var string The options string name for this plugin
67 */
68 public $optionsName = 'wp_paginate_options';
69
70 /**
71 * @var string $localizationDomain Domain used for localization
72 */
73 public $localizationDomain = 'wp-paginate';
74
75 /**
76 * @var string $pluginurl The url to this plugin
77 */
78 public $pluginurl = '';
79 /**
80 * @var string $pluginpath The path to this plugin
81 */
82 public $pluginpath = '';
83
84 /**
85 * @var array $options Stores the options for this plugin
86 */
87 public $options = array();
88
89 public $type = 'posts';
90
91 public $positions = array();
92
93 public $fonts = array();
94
95 public $presets = array();
96
97 /**
98 * Constructor
99 */
100 function __construct() {
101 $name = dirname(plugin_basename(__FILE__));
102 $this->set_activation_hooks();
103
104 //"Constants" setup
105 $this->pluginurl = plugins_url($name) . "/";
106 $this->pluginpath = WP_PLUGIN_DIR . "/$name/";
107
108 //Initialize the options
109 $this->get_options();
110
111 //Actions
112 add_action( 'init', array(&$this, 'init_pagination'));
113 add_action('admin_menu', array(&$this, 'admin_menu_link'));
114 add_action('admin_enqueue_scripts', array($this, 'wpp_admin_head'));
115 add_action('wp_enqueue_scripts', array($this, 'wpp_enqueue_custom_css'), 20);
116
117 //Language Setup
118 //load_plugin_textdomain('wp-paginate', false, "$name/I18n/");
119 add_action('plugins_loaded', array($this, 'pagination_load_textdomain'));
120
121 add_action('admin_notices', array($this, 'show_wpp_admin_notice'));
122
123 add_action('wp_ajax_nopriv_wpp_dismiss_notice', array($this, 'wpp_dismiss_notice'));
124 add_action('wp_ajax_wpp_dismiss_notice', array($this, 'wpp_dismiss_notice'));
125
126 add_action('wp_ajax_nopriv_wpp_set_review_later', array($this, 'wpp_set_review_later'));
127 add_action('wp_ajax_wpp_set_review_later', array($this, 'wpp_set_review_later'));
128
129 $this->positions = array(
130 'none' => esc_html__('Function only', 'wp-paginate'),
131 'below' => esc_html__('Below the Content', 'wp-paginate'),
132 'above' => esc_html__('Above the Content', 'wp-paginate'),
133 'both' => esc_html__('Above and Below the Content', 'wp-paginate')
134 );
135
136 $this->fonts = array(
137 'font-inherit' => esc_html__('inherit', 'wp-paginate'),
138 'font-initial' => esc_html__('initial', 'wp-paginate'),
139 'font-arial' => esc_html__('Arial', 'wp-paginate'),
140 'font-georgia' => esc_html__('Georgia', 'wp-paginate'),
141 'font-tahoma' => esc_html__('Tahoma', 'wp-paginate'),
142 'font-times' => esc_html__('Times New Roman', 'wp-paginate'),
143 'font-trebuchet' => esc_html__('Trebuchet MS', 'wp-paginate'),
144 'font-verdana' => esc_html__('Verdana', 'wp-paginate')
145 );
146
147 $this->presets = array(
148 array('default', esc_html__('Grey Buttons', 'wp-paginate'), 'default.jpg'),
149 array('wpp-blue-cta', esc_html__('Blue Buttons', 'wp-paginate'), 'blue-cta-buttons.jpg'),
150 array('wpp-modern-grey', esc_html__('Modern Grey Buttons', 'wp-paginate'), 'modern-grey-buttons.jpg'),
151 array('wpp-neon-pink', esc_html__('Neon Pink Buttons', 'wp-paginate'), 'neon-pink-buttons.png'),
152 );
153
154 if ($this->options['css'])
155 add_action('wp_print_styles', array(&$this, 'wp_paginate_css'));
156 }
157
158 function pagination_load_textdomain() {
159 $name = dirname(plugin_basename(__FILE__));
160 load_plugin_textdomain('wp-paginate', false, "$name/I18n/");
161 }
162
163 public function set_activation_hooks() {
164 register_activation_hook(__FILE__, array($this, 'do_activation'));
165 register_deactivation_hook(__FILE__, array($this, 'do_deactivation'));
166 }
167
168 public function do_activation() {
169 $this->activate();
170 }
171
172 public function do_deactivation() {
173 $this->deactivate();
174 }
175
176 public function activate() {
177 $current_user_id = get_current_user_id();
178
179 if(get_user_meta( $current_user_id, WPP_REVIEW_NOTICE, true ) !== "off" ) {
180 $review_date = date('Y-m-d', strtotime("+2 days"));
181 update_user_meta( $current_user_id, WPP_REVIEW_NOTICE, $review_date );
182 }
183 }
184
185 public function deactivate() {
186 }
187
188 public function init_pagination() {
189
190 if(isset($this->options['everywhere']) && isset($this->options['position'])) {
191
192 if ($this->options['position'] === 'above' || $this->options['position'] === 'both')
193 add_filter( 'loop_start', array($this, 'add_pagination_to_page_top'));
194
195 if ($this->options['position'] === 'below' || $this->options['position'] === 'both')
196 add_filter( 'loop_end', array($this, 'add_pagination_to_page_bottom'));
197
198 if ($this->options['everywhere'] && ($this->options['position'] === 'below' || $this->options['position'] === 'both'))
199 add_filter( 'wp_link_pages', array($this, 'add_pagination_to_page_bottom'), 10, 2 );
200
201 if ($this->options['everywhere'] && ($this->options['position'] === 'above' || $this->options['position'] === 'both'))
202 add_filter( 'wp_link_pages', array($this, 'add_pagination_to_page_top'), 10, 2 );
203
204 }
205
206 }
207
208 function add_pagination_to_page_bottom($content) {
209
210 $this->get_options();
211 if(defined('WPP-DEBUG')) {
212 $output = print_r($this->options, true);
213 error_log($output);
214 }
215 if( ($this->options['home-page'] && is_front_page()) ||
216 ($this->options['blog-page'] && is_home()) ||
217 ($this->options['search-page'] && is_search()) ||
218 ($this->options['category-page'] && is_category()) ||
219 ($this->options['archive-page'] && is_archive()) ||
220 ($this->options['everywhere'])
221 ) {
222
223 if ( is_feed() )
224 return $content;
225 global $wp_query, $wp_paginate_display_bottom;
226 if ( is_main_query() && $content === $wp_query && ! $wp_paginate_display_bottom ) {
227 $wp_paginate_display_bottom = true;
228 wp_paginate();
229 }
230 }
231 }
232
233 function add_pagination_to_page_top($content) {
234
235 $this->get_options();
236 if(defined('WPP-DEBUG')) {
237 $output = print_r($this->options, true);
238 error_log($output);
239 }
240 if( ($this->options['home-page'] && is_front_page()) ||
241 ($this->options['blog-page'] && is_home()) ||
242 ($this->options['search-page'] && is_search()) ||
243 ($this->options['category-page'] && is_category()) ||
244 ($this->options['archive-page'] && is_archive()) ||
245 ($this->options['everywhere'])
246 ) {
247
248 if ( is_feed() )
249 return $content;
250 global $wp_query, $wp_paginate_display_top;
251 if ( is_main_query() && $content === $wp_query && ! $wp_paginate_display_top ) {
252 $wp_paginate_display_top = true;
253 wp_paginate();
254 }
255 }
256 }
257
258 function wpp_admin_head($hook) {
259 if ( isset( $_REQUEST['page'] ) && 'wp-paginate.php' == $_REQUEST['page'] ) {
260 //wp_enqueue_style( 'bootstrap', plugins_url( '/css/bootstrap/bootstrap.min.css', __FILE__ ));
261 if ( isset( $_GET['action'] ) && 'custom_css' == $_GET['action'] )
262 $this->wpp_include_codemirror();
263 }
264 wp_enqueue_style( 'wp-paginate-admin', plugins_url( '/css/wp-paginate-admin.css', __FILE__ ));
265
266 wp_enqueue_script('jquery');
267 wp_enqueue_script('jquery-migrate', ABSPATH . WPINC . '/js/jquery/jquery-migrate.min.js', array('jquery'));
268 wp_register_script( 'wpp-script', $this->pluginurl .'js/wp-paginate.js', array( 'jquery' ), '', true );
269
270 wp_localize_script( 'wpp-script', 'wpp_ajax',
271 array( 'ajaxurl' => admin_url( 'admin-ajax.php' ),
272 'nonce'=> wp_create_nonce(WP_PAGINATE_NONCE))
273 );
274
275 wp_enqueue_script('wpp-script');
276
277 }
278
279 function wpp_enqueue_custom_css() {
280 $wpp_custom_css_active = get_option('wpp_custom_css_active', 'off');
281 if($wpp_custom_css_active === 'on') {
282 $upload_dir = wp_upload_dir();
283 $wpp_css_file = $upload_dir['baseurl'] . '/wpp-custom-code/wpp-custom-code.css';
284 wp_enqueue_style( 'wpp-custom-style', $wpp_css_file, array('wp-paginate') );
285 }
286 }
287
288 /**
289 * Pagination based on options/args
290 */
291 function paginate($args = false) {
292
293
294 if ($this->type === 'comments' && !get_option('page_comments'))
295 return;
296
297 $r = wp_parse_args($args, $this->options);
298 extract($r, EXTR_SKIP);
299 //error_log("r " . print_r($r, true));
300
301 if(isset($this->options['preset']))
302 $preset = $this->options['preset'];
303 else
304 $preset = 'default';
305
306 if(isset($this->options['font']))
307 $font = $this->options['font'];
308 else
309 $font = 'font-inherit';
310
311 if(isset($before))
312 $before_option = $before;
313 else if(isset($this->options['before']))
314 $before_option = $this->options['before'];
315 else
316 $before_option = '<div class="navigation">';
317
318 if(isset($after))
319 $after_option = $after;
320 else if(isset($this->options['after']))
321 $after_option = $this->options['after'];
322 else
323 $after_option = '</div>';
324
325 if(isset($this->options['slash']))
326 $slash_option = $this->options['slash'];
327 else
328 $slash_option = false;
329
330 $before = stripslashes(html_entity_decode($before_option));
331 $after = stripslashes(html_entity_decode($after_option));
332
333 if (!isset($page) && !isset($pages)) {
334 global $wp_query;
335
336 if ($this->type === 'posts') {
337 $page = get_query_var('paged');
338 $posts_per_page = intval(get_query_var('posts_per_page'));
339 $pages = intval(ceil($wp_query->found_posts / $posts_per_page));
340 }
341 else {
342 $page = get_query_var('cpage');
343 $comments_per_page = get_option('comments_per_page');
344 $pages = get_comment_pages_count();
345 }
346 $page = !empty($page) ? intval($page) : 1;
347 }
348
349 $prevlink = ($this->type === 'posts')
350 ? rtrim(esc_url(get_pagenum_link($page - 1)), '/')
351 : get_comments_pagenum_link($page - 1);
352 $nextlink = ($this->type === 'posts')
353 ? rtrim(esc_url(get_pagenum_link($page + 1)), '/')
354 : get_comments_pagenum_link($page + 1);
355
356 //if($slash_option == true) {
357 // $prevlink . '/';
358 // $nextlink . '/';
359 //}
360
361 $output = stripslashes(wp_kses_decode_entities($before));
362 if ($pages > 1) {
363
364 if($preset === 'default')
365 $output .= sprintf('<ol class="wp-paginate ' . $font . '%s">', ($this->type === 'posts') ? '' : ' wp-paginate-comments');
366 else
367 $output .= sprintf('<ol class="wp-paginate ' . $preset . ' ' . $font . '%s">', ($this->type === 'posts') ? '' : ' wp-paginate-comments');
368
369 if (strlen(stripslashes($title)) > 0) {
370 $output .= sprintf('<li><span class="title">%s</span></li>', stripslashes($title));
371 }
372
373 if(isset($this->options['hide-ellipses']) && $this->options['hide-ellipses'] == true )
374 $ellipsis = "<li class='ellipse-gap'></li>";
375 else
376 $ellipsis = "<li class='ellipse-gap'><span class='gap'>...</span></li>";
377
378 if ($page > 1 && !empty($previouspage)) {
379 $prevlink = rtrim($prevlink, '/');
380 $contains_param = (strpos($prevlink, '?') !== false) ? true : false;
381 if($slash_option && !$contains_param)
382 $output .= sprintf('<li><a href="%s/" class="prev" aria-label="' . esc_html__('Go to previous page', 'wp-paginate') . '">%s</a></li>', $prevlink, stripslashes($previouspage));
383 else
384 $output .= sprintf('<li><a href="%s" class="prev" aria-label="' . esc_html__('Go to previous page', 'wp-paginate') . '">%s</a></li>', $prevlink, stripslashes($previouspage));
385 }
386
387 $min_links = $range * 2 + 1;
388 $block_min = min($page - $range, $pages - $min_links);
389 $block_high = max($page + $range, $min_links);
390 $left_gap = (($block_min - $anchor - $gap) > 0) ? true : false;
391 $right_gap = (($block_high + $anchor + $gap) < $pages) ? true : false;
392
393 if ($left_gap && !$right_gap) {
394 $output .= sprintf('%s%s%s',
395 $this->paginate_loop(1, $anchor, 0, 0, $slash_option),
396 $ellipsis,
397 $this->paginate_loop($block_min, $pages, $page, $page, $slash_option)
398 );
399 }
400 else if ($left_gap && $right_gap) {
401 $output .= sprintf('%s%s%s%s%s',
402 $this->paginate_loop(1, $anchor, 0, 0, $slash_option),
403 $ellipsis,
404 $this->paginate_loop($block_min, $block_high, $page, $page, $slash_option),
405 $ellipsis,
406 $this->paginate_loop(($pages - $anchor + 1), $pages, 0, 0, $slash_option)
407 );
408 }
409 else if ($right_gap && !$left_gap) {
410 $output .= sprintf('%s%s%s',
411 $this->paginate_loop(1, $block_high, $page, $page, $slash_option),
412 $ellipsis,
413 $this->paginate_loop(($pages - $anchor + 1), $pages, 0, 0, $slash_option)
414 );
415 }
416 else {
417 $output .= $this->paginate_loop(1, $pages, $page, $page, $slash_option);
418 }
419
420 if ($page < $pages && !empty($nextpage)) {
421 $nextlink = rtrim($nextlink, '/');
422 $contains_param = (strpos($nextlink, '?') !== false) ? true : false;
423 if($slash_option && !$contains_param)
424 $output .= sprintf('<li><a href="%s/" class="next" aria-label="' . esc_html__('Go to next page', 'wp-paginate') . '">%s</a></li>', $nextlink, stripslashes($nextpage));
425 else
426 $output .= sprintf('<li><a href="%s" class="next" aria-label="' . esc_html__('Go to next page', 'wp-paginate') . '">%s</a></li>', $nextlink, stripslashes($nextpage));
427 }
428 $output .= "</ol>";
429 }
430
431 $output .= stripslashes(wp_kses_decode_entities($after));
432
433 if ($pages > 1 || $empty) {
434 echo $output;
435 }
436 }
437
438 /**
439 * Helper function for pagination which builds the page links.
440 */
441 function paginate_loop($start, $max, $page = 0, $slash = false) {
442 $output = "";
443 for ($i = $start; $i <= $max; $i++) {
444 if($slash)
445 $p = ($this->type === 'posts') ? esc_url(get_pagenum_link($i)) : get_comments_pagenum_link($i);
446 else
447 $p = ($this->type === 'posts') ? rtrim(esc_url(get_pagenum_link($i)), '/') : get_comments_pagenum_link($i);
448 $output .= ($page == intval($i))
449 ? "<li><span class='page current'>$i</span></li>"
450 : "<li><a href='$p' title='$i' aria-label='" . esc_html__('Go to page', 'wp-paginate') . " $i' class='page'>$i</a></li>";
451 //: "<li><a href='$p' title='$i' aria-label='Go to page $i' class='page'>$i</a></li>";
452 }
453 return $output;
454 }
455
456 function wp_paginate_css() {
457 $name = "css/wp-paginate.css";
458
459 if (false !== @file_exists(STYLESHEETPATH . "/$name")) {
460 $css = get_stylesheet_directory_uri() . "/$name";
461 }
462 else {
463 $css = $this->pluginurl . $name;
464 }
465 wp_enqueue_style('wp-paginate', $css, false, $this->version, 'screen');
466
467 if (function_exists('is_rtl') && is_rtl()) {
468 $name = "css/wp-paginate-rtl.css";
469 if (false !== @file_exists(STYLESHEETPATH . "/$name")) {
470 $css = get_stylesheet_directory_uri() . "/$name";
471 }
472 else {
473 $css = $this->pluginurl . $name;
474 }
475 wp_enqueue_style('wp-paginate-rtl', $css, false, $this->version, 'screen');
476 }
477
478 wp_enqueue_style( 'wpp-advanced-styles', $this->wpp_print_style() );
479
480 }
481
482 /**
483 * Retrieves the plugin options from the database.
484 * @return array
485 */
486 function get_options() {
487 if (!$options = get_option($this->optionsName)) {
488 $options = array(
489 'title' => 'Pages:',
490 'nextpage' => '&raquo;',
491 'previouspage' => '&laquo;',
492 'css' => true,
493 'slash' => false,
494 'before' => '<div class="navigation">',
495 'after' => '</div>',
496 'empty' => true,
497 'range' => 3,
498 'anchor' => 1,
499 'gap' => 3,
500 'everywhere' => false,
501 'home-page' => false,
502 'blog-page' => false,
503 'search-page' => false,
504 'category-page' => false,
505 'archive-page' => false,
506 'position' => 'none',
507 'hide-standard-pagination' => false,
508 'hide-ellipses' => false,
509 'font' => 'font-inherit',
510 'preset' => 'default'
511 );
512 update_option($this->optionsName, $options);
513 }
514 $this->options = $options;
515 }
516 /**
517 * Saves the admin options to the database.
518 */
519 function save_admin_options(){
520
521 if(defined('WPP-DEBUG')) {
522 $output = print_r($this->options, true);
523 error_log($output);
524 }
525
526 return update_option($this->optionsName, $this->options);
527 }
528
529 /**
530 * @desc Adds the options subpanel
531 */
532 function admin_menu_link() {
533 add_options_page('WP-Paginate', 'WP-Paginate', 'manage_options', basename(__FILE__), array(&$this, 'admin_options_page'));
534 add_filter('plugin_action_links_' . plugin_basename(__FILE__), array(&$this, 'filter_plugin_actions'), 10, 2 );
535 }
536
537 /**
538 * @desc Adds the Settings link to the plugin activate/deactivate page
539 */
540 function filter_plugin_actions($links, $file) {
541 $settings_link = '<a href="options-general.php?page=' . basename(__FILE__) . '">' . esc_html__('Settings', 'wp-paginate') . '</a>';
542 array_unshift($links, $settings_link); // before other links
543
544 return $links;
545 }
546
547 /**
548 * Adds settings/options page
549 */
550 function admin_options_page() {
551
552 $allowed_html = array(
553 'div' => array(
554 'class' => array(),
555 'id' => array()
556 ),
557 'nav' => array(
558 'class' => array(),
559 'id' => array()
560 ),
561 'em' => array(),
562 'strong' => array()
563 );
564
565 $allowed_presets = array('default', 'wpp-blue-cta', 'wpp-modern-grey', 'wpp-neon-pink');
566
567 if (isset($_POST['wp_paginate_save'])) {
568 if (wp_verify_nonce($_POST['_wpnonce'], 'wp-paginate-update-options')) {
569
570 if(defined('WPP-DEBUG')) {
571 error_log("wp_paginate_save");
572 }
573
574 $this->options['title'] = trim(sanitize_text_field($_POST['title']));
575 $this->options['previouspage'] = trim(sanitize_text_field($_POST['previouspage']));
576 $this->options['nextpage'] = trim(sanitize_text_field($_POST['nextpage']));
577 $this->options['before'] = wp_kses($_POST['before'], $allowed_html);
578 $this->options['after'] = wp_kses($_POST['after'], $allowed_html);
579 $this->options['empty'] = (isset($_POST['empty']) && $_POST['empty'] === 'on') ? true : false;
580 $this->options['css'] = (isset($_POST['css']) && $_POST['css'] === 'on') ? true : false;
581 $this->options['slash'] = (isset($_POST['slash']) && $_POST['slash'] === 'on') ? true : false;
582 $this->options['range'] = intval($_POST['range']);
583 $this->options['anchor'] = intval($_POST['anchor']);
584 $this->options['gap'] = intval($_POST['gap']);
585 $this->options['everywhere'] = (isset($_POST['everywhere']) && $_POST['everywhere'] === 'on') ? true : false;
586 $this->options['home-page'] = (isset($_POST['home-page']) && $_POST['home-page'] === 'on') ? true : false;
587 $this->options['blog-page'] = (isset($_POST['blog-page']) && $_POST['blog-page'] === 'on') ? true : false;
588 $this->options['search-page'] = (isset($_POST['search-page']) && $_POST['search-page'] === 'on') ? true : false;
589 $this->options['category-page'] = (isset($_POST['category-page']) && $_POST['category-page'] === 'on') ? true : false;
590 $this->options['archive-page'] = (isset($_POST['archive-page']) && $_POST['archive-page'] === 'on') ? true : false;
591 if(isset($_POST['position']))
592 $this->options['position'] = sanitize_text_field($_POST['position']);
593 $this->options['hide-standard-pagination'] = (isset($_POST['hide-standard-pagination']) && $_POST['hide-standard-pagination'] === 'on') ? true : false;
594 $this->options['hide-ellipses'] = (isset($_POST['hide-ellipses']) && $_POST['hide-ellipses'] === 'on') ? true : false;
595 if(isset($_POST['font']))
596 $this->options['font'] = sanitize_text_field($_POST['font']);
597 if(isset($_POST['preset'])) {
598 $preset_value = trim(sanitize_text_field($_POST['preset']));
599 // only allow predefined values
600 if(in_array($preset_value, $allowed_presets))
601 $this->options['preset'] = $preset_value;
602 else
603 $this->options['preset'] = 'default';
604 }
605
606 $this->save_admin_options();
607
608 echo '<div class="updated"><p>' . esc_html__('Success! Your changes were successfully saved!', 'wp-paginate') . '</p></div>';
609 }
610 else {
611 echo '<div class="error"><p>' . esc_html__('Whoops! There was a problem with the data you posted. Please try again.', 'wp-paginate') . '</p></div>';
612 }
613 }
614
615 ?>
616
617 <div class="wrap">
618 <div class="icon32" id="icon-options-general"><br/></div>
619 <h1>WP-Paginate</h1>
620 <h2 class="nav-tab-wrapper">
621 <a class="nav-tab<?php if ( ! isset( $_GET['action'] ) ) echo ' nav-tab-active'; ?>" href="options-general.php?page=wp-paginate.php"><?php esc_html_e( 'Settings', 'wp-paginate' ); ?></a>
622 <a class="nav-tab <?php if ( isset( $_GET['action'] ) && 'custom_css' == $_GET['action'] ) echo ' nav-tab-active'; ?>" href="options-general.php?page=wp-paginate.php&amp;action=custom_css"><?php esc_html_e( 'Custom CSS', 'wp-paginate' ); ?></a>
623 <a class="nav-tab <?php if ( isset( $_GET['action'] ) && 'upgrade_to_pro' == $_GET['action'] ) echo ' nav-tab-active'; ?>" href="options-general.php?page=wp-paginate.php&amp;action=upgrade_to_pro"><?php esc_html_e( 'Upgrade to Pro', 'wp-paginate' ); ?></a>
624 </h2>
625
626 <?php if ( ! isset( $_GET['action'] ) || $_GET['action'] == 'appearance' ) { ?>
627
628 <form method="post" id="wp_paginate_options">
629 <?php wp_nonce_field('wp-paginate-update-options'); ?>
630
631 <h3><?php esc_html_e('General', 'wp-paginate'); ?></h3>
632 <table class="form-table">
633 <tr valign="top">
634 <th scope="row"><?php esc_html_e('Pagination Label:', 'wp-paginate'); ?></th>
635 <td><input name="title" type="text" id="title" size="40" value="<?php echo esc_attr(stripslashes(htmlspecialchars($this->options['title']))) ?>"/>
636 <span class="description"><?php esc_html_e('The optional text/HTML to display before the list of pages.', 'wp-paginate'); ?></span></td>
637 </tr>
638 <tr valign="top">
639 <th scope="row"><?php esc_html_e('Previous Page:', 'wp-paginate'); ?></th>
640 <td><input name="previouspage" type="text" id="previouspage" size="40" value="<?php echo esc_attr(stripslashes(htmlspecialchars($this->options['previouspage']))) ?>"/>
641 <span class="description"><?php esc_html_e('The text/HTML to display for the previous page link.', 'wp-paginate'); ?></span></td>
642 </tr>
643 <tr valign="top">
644 <th scope="row"><?php esc_html_e('Next Page:', 'wp-paginate'); ?></th>
645 <td><input name="nextpage" type="text" id="nextpage" size="40" value="<?php echo esc_attr(stripslashes(htmlspecialchars($this->options['nextpage']))) ?>"/>
646 <span class="description"><?php esc_html_e('The text/HTML to display for the next page link.', 'wp-paginate'); ?></span></td>
647 </tr>
648 </table>
649 <p>&nbsp;</p>
650 <h3><?php esc_html_e('Location &amp; Position', 'wp-paginate'); ?></h3>
651 <table class="form-table">
652 <tr valign="top">
653 <th scope="row"><?php esc_html_e('Everywhere:', 'wp-paginate'); ?></th>
654 <td><label for="everywhere">
655 <?php
656 if(isset($this->options['everywhere']))
657 $everywhere = $this->options['everywhere'];
658 else
659 $everywhere = false;
660 ?>
661 <input class="everywhere-cb" type="checkbox" id="everywhere" name="everywhere" <?php echo esc_attr(($everywhere === true) ? "checked='checked'" : ""); ?>/> <?php esc_html_e('Display pagination everywhere. (Comments pagination not included.)', 'wp-paginate') ?></label></td>
662 </tr>
663 <tr valign="top">
664 <th scope="row"><?php esc_html_e('Home Page:', 'wp-paginate'); ?></th>
665 <td><label for="home-page">
666 <?php
667 if(isset($this->options['home-page']))
668 $home_page = $this->options['home-page'];
669 else
670 $home_page = false;
671 ?>
672 <input class="not-everywhere-cb" type="checkbox" id="home-page" name="home-page" <?php echo esc_attr(($home_page === true) ? "checked='checked'" : "") ?>/> <?php esc_html_e('Display pagination on the home page.', 'wp-paginate') ?></label></td>
673 </tr>
674 <tr valign="top">
675 <th scope="row"><?php esc_html_e('Blog Page:', 'wp-paginate'); ?></th>
676 <td><label for="blog-page">
677 <?php
678 if(isset($this->options['blog-page']))
679 $blog_page = $this->options['blog-page'];
680 else
681 $blog_page = false;
682 ?>
683 <input class="not-everywhere-cb" type="checkbox" id="blog-page" name="blog-page" <?php echo esc_attr(($blog_page === true)) ? "checked='checked'" : ""; ?>/> <?php esc_html_e('Display pagination on the blog page.', 'wp-paginate') ?></label></td>
684 </tr>
685 <tr valign="top">
686 <th scope="row"><?php esc_html_e('Search Page:', 'wp-paginate'); ?></th>
687 <td><label for="search-page">
688 <?php
689 if(isset($this->options['search-page']))
690 $search_page = $this->options['search-page'];
691 else
692 $search_page = false;
693 ?>
694 <input class="not-everywhere-cb" type="checkbox" id="search-page" name="search-page" <?php echo esc_attr(($search_page === true) ? "checked='checked'" : "") ?>/> <?php esc_html_e('Display pagination on the search page.', 'wp-paginate') ?></label></td>
695 </tr>
696 <tr valign="top">
697 <th scope="row"><?php esc_html_e('Category Pages:', 'wp-paginate'); ?></th>
698 <td><label for="category-page">
699 <?php
700 if(isset($this->options['category-page']))
701 $category_page = $this->options['category-page'];
702 else
703 $category_page = false;
704 ?>
705 <input class="not-everywhere-cb" type="checkbox" id="search-page" name="category-page" <?php echo esc_attr(($category_page === true) ? "checked='checked'" : "") ?>/> <?php esc_html_e('Display pagination on category pages.', 'wp-paginate') ?></label></td>
706 </tr>
707 <tr valign="top">
708 <th scope="row"><?php esc_html_e('Archive Pages:', 'wp-paginate'); ?></th>
709 <td><label for="archive-page">
710 <?php
711 if(isset($this->options['archive-page']))
712 $archive_page = $this->options['archive-page'];
713 else
714 $archive_page = false;
715 ?>
716 <input class="not-everywhere-cb" type="checkbox" id="archive-page" name="archive-page" <?php echo esc_attr(($archive_page === true) ? "checked='checked'" : "") ?>/> <?php esc_html_e('Display pagination on archive pages.', 'wp-paginate') ?></label></td>
717 </tr>
718
719 <script>
720 jQuery(document).ready(function(){
721
722 jQuery(".everywhere-cb").change(function() {
723 if(jQuery(".everywhere-cb").is(':checked')) {
724 jQuery(".not-everywhere-cb").prop('disabled', true);
725 jQuery(".not-everywhere-cb").prop("checked", false);
726 } else {
727 jQuery(".not-everywhere-cb").prop('disabled', false);
728 }
729 });
730
731 if(jQuery(".everywhere-cb").is(':checked')) {
732 jQuery(".not-everywhere-cb").prop('disabled', true);
733 } else {
734 jQuery(".not-everywhere-cb").prop('disabled', false);
735 }
736
737 });
738 </script>
739
740 <tr valign="top">
741 <th scope="row"><?php esc_html_e('Position:', 'wp-paginate'); ?></th>
742 <td>
743 <?php
744 if(isset($this->options['position']))
745 $position = $this->options['position'];
746 else
747 $position = 'none';
748 ?>
749 <select name="position" id="range">
750 <?php foreach ($this->positions as $key => $name) { ?>
751 <?php $selected = ($position == $key) ? 'selected="selected"' : ''; ?>
752 <option value="<?php echo esc_attr($key) ?>" <?php echo esc_attr($selected) ?>><?php echo esc_html($name) ?></option>
753 <?php } ?>
754 </select>
755 <span class="description"><?php esc_html_e('Where to display the pagination on the page.', 'wp-paginate'); ?></span></td>
756 </tr>
757 <tr valign="top">
758 <th scope="row"><?php esc_html_e('Hide Standard Pagination:', 'wp-paginate'); ?></th>
759 <td><label for="hide-standard-pagination">
760 <?php
761 if(isset($this->options['hide-standard-pagination']))
762 $hide_standard_pagination = $this->options['hide-standard-pagination'];
763 else
764 $hide_standard_pagination = 'none';
765 ?>
766 <input type="checkbox" id="hide-standard-pagination" name="hide-standard-pagination" <?php echo esc_attr(($hide_standard_pagination === true) ? "checked='checked'" : "") ?>/> <?php esc_html_e('Hide the standard theme default pagination.', 'wp-paginate'); ?></label></td>
767 </tr>
768 </table>
769 <p>&nbsp;</p>
770 <h3><?php esc_html_e('Appearance', 'wp-paginate'); ?></h3>
771 <table class="form-table">
772 <tr valign="top">
773 <th scope="row"><?php esc_html_e('Pagination Font:', 'wp-paginate'); ?></th>
774 <td>
775 <?php
776 if(isset($this->options['font']))
777 $font = $this->options['font'];
778 else
779 $font = 'font-inherit';
780 ?>
781 <select name="font" id="font">
782 <?php foreach ($this->fonts as $key => $name) { ?>
783 <?php $selected = ($font == $key) ? 'selected="selected"' : ''; ?>
784 <option value="<?php echo esc_attr($key) ?>" <?php echo esc_attr($selected) ?>><?php echo esc_html($name) ?></option>
785 <?php } ?>
786 </select>
787 <span class="description"><?php esc_html_e('Select the font to use with the pagination.', 'wp-paginate'); ?></span></td>
788 </tr>
789 <tr valign="top">
790 <th scope="row"><?php esc_html_e('Hide Ellipses:', 'wp-paginate'); ?></th>
791 <td><label for="hide-ellipses">
792 <?php
793 if(isset($this->options['hide-ellipses']))
794 $hide_ellipses = $this->options['hide-ellipses'];
795 else
796 $hide_ellipses = 'none';
797 ?>
798 <input type="checkbox" id="hide-ellipses" name="hide-ellipses" <?php echo esc_attr(($hide_ellipses === true) ? "checked='checked'" : "") ?>/> <?php esc_html_e('Remove ellipses from the pagination links.', 'wp-paginate'); ?></label></td>
799 </tr>
800 <tr valign="top">
801 <th scope="row"><?php esc_html_e('Button Style:', 'wp-paginate'); ?></th>
802 <?php
803 if(isset($this->options['preset'])) {
804 $preset_option = $this->options['preset'];
805 } else {
806 $preset_option = 'default';
807 }
808 ?>
809 <input type='hidden' value='<?php echo esc_attr($preset_option) ?>' name='preset' id='preset'>
810 <td>
811 <p><?php esc_html_e('Choose a preset style from the list below.', 'wp-paginate'); ?></p>
812 <table class="button-styles">
813 <?php foreach($this->presets as $preset ) { ?>
814 <tr>
815 <td>
816 <?php echo esc_html($preset[1]) ?>
817 </td>
818 <td>
819 <input type="radio" name="preset" id="preset" value="<?php echo esc_attr($preset[0]) ?>" <?php echo esc_attr(($preset_option === $preset[0]) ? 'checked' : '') ?>>
820 </td>
821 <td>
822 <img alt="<?php echo esc_attr($preset[1]) ?> image" src="<?php echo esc_url($this->pluginurl . "images/" . $preset[2]) ?>" width="326" height="70">
823 </td>
824 </tr>
825 <?php } ?>
826 </table>
827 </td>
828 </tr>
829 </table>
830 <p>&nbsp;</p>
831 <h3><?php esc_html_e('Advanced Settings', 'wp-paginate'); ?></h3>
832 <table class="form-table">
833 <tr valign="top">
834 <th scope="row"><?php esc_html_e('Before Markup:', 'wp-paginate'); ?></th>
835 <td><input name="before" type="text" id="before" size="40" value="<?php echo esc_attr(stripslashes(wp_kses_decode_entities($this->options['before']))); ?>"/>
836 <span class="description"><?php esc_html_e('The HTML markup to display before the pagination code.', 'wp-paginate'); ?></span></td>
837 </tr>
838 <tr valign="top">
839 <th scope="row"><?php esc_html_e('After Markup:', 'wp-paginate'); ?></th>
840 <td><input name="after" type="text" id="after" size="40" value="<?php echo esc_attr(stripslashes(wp_kses_decode_entities($this->options['after']))); ?>"/>
841 <span class="description"><?php esc_html_e('The HTML markup to display after the pagination code.', 'wp-paginate'); ?></span></td>
842 </tr>
843 <tr valign="top">
844 <th scope="row"><?php esc_html_e('Markup Display:', 'wp-paginate'); ?></th>
845 <td><label for="empty">
846 <input type="checkbox" id="empty" name="empty" <?php echo esc_attr(($this->options['empty'] === true) ? "checked='checked'" : "") ?>/> <?php esc_html_e('Show Before Markup and After Markup, even if the page list is empty?', 'wp-paginate'); ?></label></td>
847 </tr>
848 <tr valign="top">
849 <th scope="row"><?php esc_html_e('WP-Paginate CSS File:', 'wp-paginate'); ?></th>
850 <td><label for="css">
851 <input type="checkbox" id="css" name="css" <?php echo esc_attr(($this->options['css'] === true) ? "checked='checked'" : "") ?>/> <?php printf(esc_html__('Include the default stylesheet wp-paginate.css? WP-Paginate will first look for <code>wp-paginate.css</code> in your theme directory (<code>themes/%s</code>).', 'wp-paginate'), get_template()); ?></label></td>
852 </tr>
853 <?php
854 if(!isset($this->options['slash']))
855 $this->options['slash'] = false;
856 ?>
857 <tr valign="top">
858 <th scope="row"><?php esc_html_e('Add trailing slash:', 'wp-paginate'); ?></th>
859 <td><label for="slash">
860 <input type="checkbox" id="css" name="slash" <?php echo esc_attr(($this->options['slash'] === true) ? "checked='checked'" : "") ?>/> <?php printf(esc_html__('Adds a trailing slash to the end of pagination links.', 'wp-paginate'), get_template()); ?></label></td>
861 </tr>
862
863 <tr valign="top">
864 <th scope="row"><?php esc_html_e('Page Range:', 'wp-paginate'); ?></th>
865 <td>
866 <select name="range" id="range">
867 <?php for ($i=1; $i<=10; $i++) : ?>
868 <option value="<?php echo esc_attr($i) ?>" <?php echo esc_attr(($i == $this->options['range']) ? "selected='selected'" : "") ?>><?php echo esc_html($i) ?></option>
869 <?php endfor; ?>
870 </select>
871 <span class="description"><?php esc_html_e('The number of page links to show before and after the current page. Recommended value: 3', 'wp-paginate'); ?></span></td>
872 </tr>
873 <tr valign="top">
874 <th scope="row"><?php esc_html_e('Page Anchors:', 'wp-paginate'); ?></th>
875 <td>
876 <select name="anchor" id="anchor">
877 <?php for ($i=0; $i<=10; $i++) : ?>
878 <option value="<?php echo esc_attr($i) ?>" <?php echo esc_attr(($i == $this->options['anchor']) ? "selected='selected'" : "") ?>><?php echo esc_html($i) ?></option>
879 <?php endfor; ?>
880 </select>
881 <span class="description"><?php esc_html_e('The number of links to always show at beginning and end of pagination. Recommended value: 1', 'wp-paginate'); ?></span></td>
882 </tr>
883 <tr valign="top">
884 <th scope="row"><?php esc_html_e('Page Gap:', 'wp-paginate'); ?></th>
885 <td>
886 <select name="gap" id="gap">
887 <?php for ($i=1; $i<=10; $i++) : ?>
888 <option value="<?php echo esc_attr($i) ?>" <?php echo esc_attr(($i == $this->options['gap']) ? "selected='selected'" : "") ?>><?php echo esc_html($i) ?></option>
889 <?php endfor; ?>
890 </select>
891 <span class="description"><?php esc_html_e('The minimum number of pages in a gap before an ellipsis (...) is added. Recommended value: 3', 'wp-paginate'); ?></span></td>
892 </tr>
893 </table>
894 <p class="submit">
895 <input type="submit" id="wpp-save-changes" value="<?php esc_html_e('Save Changes', 'wp-paginate'); ?>" name="wp_paginate_save" class="button-primary" />
896 </p>
897 </form>
898 <p>&nbsp;</p>
899 <hr>
900 <script>
901 jQuery(document).ready(function(){
902
903 jQuery("#wpp-save-changes").click(function(){
904 unsaved = false;
905 });
906
907 var unsaved = false;
908
909 jQuery(":input").change(function(){ //trigers change in all input fields including text type
910 unsaved = true;
911 });
912
913 function unloadPage(){
914 if(unsaved){
915 return "Do you want to leave this page and discard your changes or stay on this page?";
916 }
917 }
918
919 window.onbeforeunload = unloadPage;
920
921 });
922
923
924 </script>
925 <?php } elseif ( 'upgrade_to_pro' == $_GET['action'] ) { ?>
926 <?php $this->wpp_upgrade_to_pro_tab(); ?>
927 <p>&nbsp;</p>
928 <hr>
929 <?php } elseif ( 'custom_css' == $_GET['action'] ) { ?>
930 <h2>Custom CSS</h2>
931 <?php $this->wpp_custom_code_tab(); ?>
932 <p>&nbsp;</p>
933 <hr>
934 <?php } ?>
935
936 <h2><?php esc_html_e('Need Support?', 'wp-paginate'); ?></h2>
937 <p><?php printf(esc_html__('For questions, issues or feature requests, please post them in the %s and make sure to tag the post with wp-paginate.', 'wp-paginate'), '<a href="https://wordpress.org/support/plugin/wp-paginate">WordPress Forum</a>'); ?></p>
938 <p>&nbsp;</p>
939 <div id="wpp-plugins">
940
941 <div class="paginate-info"><?php esc_html_e( 'WP Paginate is Maintained and Upgraded by Max Foundry', 'wp-paginate' ); ?></div>
942 <div class="paginate-info"><?php esc_html_e( 'Developed Originally by Eric Martin', 'wp-paginate' ); ?></div>
943 <div class="mf-plugins"><?php esc_html_e( 'Max Foundry Produces These Other Fine Plugins', 'wp-paginate' ); ?></div>
944
945 <div class="column-left">
946 <a href="<?php echo esc_url_raw(WPP_MAXBUTTONS_LINK) ?>" target="_blank">
947 <img alt="maxbuttons logo" src="<?php echo $this->pluginurl ?>images/MBP.png" width="283" height="142">
948 </a>
949 <a href="<?php echo esc_url_raw(WPP_MAXBUTTONS_LINK) ?>" target="_blank">
950 <div class="wpp-plugin-title"><?php esc_html_e( 'WordPress Button Plugin', 'wp-paginate' ); ?></div>
951 </a>
952 </div>
953 <div class="column-center">
954 <a href="<?php echo esc_url_raw(WPP_MAXGALLERIA_LINK) ?>" target="_blank">
955 <img alt="maxgalleria logo" src="<?php echo esc_url($this->pluginurl . "images/MG_logo.png") ?>" width="283" height="142">
956 </a>
957 <a href="<?php echo esc_url_raw(WPP_MAXGALLERIA_LINK) ?>" target="_blank">
958 <div class="wpp-plugin-title"><?php esc_html_e( 'WordPress Gallery Plugin', 'wp-paginate' ); ?></div>
959 </a>
960 </div>
961 <div class="column-right">
962 <a href="<?php echo esc_url_raw(WPP_MEDIA_LIBRARY_PLUS_PRO_LINK) ?>" target="_blank">
963 <img alt="media library plus pro logo" src="<?php echo esc_url($this->pluginurl . "images/MLPP-card-red.png") ?>" width="283" height="142">
964 </a>
965 <a href="<?php echo esc_url_raw(WPP_MEDIA_LIBRARY_PLUS_PRO_LINK) ?>" target="_blank">
966 <div class="wpp-plugin-title"><?php esc_html_e( 'WordPress Media Library Folders', 'wp-paginate' ); ?></div>
967 </a>
968 </div>
969 </div>
970
971 </div>
972
973 <?php
974 }
975
976 function wpp_include_codemirror() {
977 wp_enqueue_style( 'codemirror.css', plugins_url( 'lib/codemirror.css', __FILE__ ) );
978 wp_enqueue_script( 'codemirror.js', plugins_url( 'lib/codemirror.js', __FILE__ ), array( 'jquery' ) );
979 }
980
981 function wpp_custom_code_tab() {
982 if ( ! current_user_can( 'edit_plugins' ) )
983 wp_die( esc_html__( 'You do not have sufficient permissions to edit plugins for this site.', 'wp-paginate' ) );
984
985 $message = $content = '';
986 $extension = 'css';
987 $wpp_custom_css_active = get_option('wpp_custom_css_active', 'off');
988
989 $upload_dir = wp_upload_dir();
990 $folder = $upload_dir['basedir'] . '/wpp-custom-code';
991 if ( ! $upload_dir["error"] ) {
992 if ( ! is_dir( $folder ) )
993 wp_mkdir_p( $folder, 0755 );
994
995 $index_file = $upload_dir['basedir'] . '/wpp-custom-code/index.php';
996 if ( ! file_exists( $index_file ) ) {
997 if ( $f = fopen( $index_file, 'w+' ) )
998 fclose( $f );
999 }
1000 }
1001
1002 $css_file = 'wpp-custom-code.css';
1003 $real_css_file = $folder . '/' . $css_file;
1004
1005 if ( isset( $_REQUEST['wpp_update_custom_code'] ) && check_admin_referer( 'wpp_update_nonce' . $css_file ) ) {
1006
1007 /* CSS */
1008 $newcontent_css = wp_kses_post(wp_unslash( $_POST['wpp_newcontent_css'] ));
1009 if ( $f = fopen( $real_css_file, 'w+' ) ) {
1010 fwrite( $f, $newcontent_css );
1011 fclose( $f );
1012 $message .= sprintf( esc_html__( 'File %s edited successfully.', 'wp-paginate' ), '<i>' . $css_file . '</i>' ) . ' ';
1013 } else {
1014 $error .= esc_html__( 'Not enough permissions to create or update the file', 'wp-paginate' ) . ' ' . $real_css_file . '. ';
1015 }
1016
1017 if(isset($_REQUEST['wpp_custom_css_active']))
1018 $wpp_custom_css_active = 'on';
1019 else
1020 $wpp_custom_css_active = 'off';
1021
1022 update_option('wpp_custom_css_active', $wpp_custom_css_active, true );
1023
1024 if ( ! empty( $error ) )
1025 $error .= ' <a href="https://codex.wordpress.org/Changing_File_Permissions" target="_blank">' . esc_html__( 'Learn more', 'wp-paginate' ) . '</a>';
1026 }
1027
1028 if ( file_exists( $real_css_file ) ) {
1029 update_recently_edited( $real_css_file );
1030 $content_css = esc_textarea( file_get_contents( $real_css_file ) );
1031 //$is_css_active = true;
1032 }
1033 else
1034 $content_css = "";
1035
1036 if ( ! empty( $message ) ) { ?>
1037 <div id="message" class="below-h2 updated notice is-dismissible"><p><?php echo esc_html($message) ?></p></div>
1038 <?php } ?>
1039 <form action="" method="post">
1040 <p>
1041 <?php esc_html_e( 'These styles will be added to the header on all pages of your site.', 'wp-paginate' ); ?>
1042 </p>
1043 <p><big>
1044 <?php if ( ! file_exists( $real_css_file ) || ( is_writeable( $real_css_file ) ) ) {
1045 echo esc_html__( 'Editing', 'wp-paginate' ) . ' <strong>' . $css_file . '</strong>';
1046 } else {
1047 echo esc_html__( 'Browsing', 'wp-paginate' ) . ' <strong>' . $css_file . '</strong>';
1048 } ?>
1049 </big></p>
1050 <p><label><input type="checkbox" name="wpp_custom_css_active" value="1" <?php checked( $wpp_custom_css_active, 'on'); ?> /> <?php _e( 'Activate', 'wp-paginate' ); ?></label></p>
1051 <textarea cols="70" rows="25" name="wpp_newcontent_css" id="wpp_newcontent_css"><?php if ( isset( $content_css ) ) echo $content_css; ?></textarea>
1052 <?php if ( ! file_exists( $real_css_file ) || is_writeable( $real_css_file )) { ?>
1053 <p class="submit">
1054 <input type="hidden" name="wpp_update_custom_code" value="submit" />
1055 <?php submit_button( esc_html__( 'Save Changes', 'wp-paginate' ), 'primary', 'submit', false );
1056 wp_nonce_field( 'wpp_update_nonce' . $css_file ); ?>
1057 </p>
1058 <?php } else { ?>
1059 <p><em><?php printf( esc_html__( 'You need to make this files writable before you can save your changes. See %s the Codex %s for more information.', 'wp-paginate' ),
1060 '<a href="https://codex.wordpress.org/Changing_File_Permissions" target="_blank">',
1061 '</a>' ); ?></em></p>
1062 <?php } ?>
1063 </form>
1064 <script>
1065 jQuery(document).ready(function(){
1066
1067 if ( typeof CodeMirror == 'function' ) {
1068 if ( jQuery( '#wpp_newcontent_css' ).length > 0 ) {
1069 var editor = CodeMirror.fromTextArea( document.getElementById( 'wpp_newcontent_css' ), {
1070 mode: "css",
1071 theme: "default",
1072 styleActiveLine: true,
1073 matchBrackets: true,
1074 lineNumbers: true,
1075 });
1076 }
1077 }
1078
1079 jQuery("#submit").click(function(){
1080 unsaved = false;
1081 });
1082
1083 var unsaved = false;
1084
1085 jQuery(":input").change(function(){ //trigers change in all input fields including text type
1086 unsaved = true;
1087 });
1088
1089 function unloadPage(){
1090 if(unsaved){
1091 return "Do you want to leave this page and discard your changes or stay on this page?";
1092 }
1093 }
1094
1095 window.onbeforeunload = unloadPage;
1096
1097 });
1098
1099
1100 </script>
1101 <?php }
1102
1103 function wpp_print_style() {
1104 $this->get_options();
1105 $classes = '';
1106 if(isset($this->options['hide-standard-pagination']) && $this->options['hide-standard-pagination']) {
1107 //$hide_comments
1108 $classes .=
1109 '.archive #nav-above,
1110 .archive #nav-below,
1111 .search #nav-above,
1112 .search #nav-below,
1113 .blog #nav-below,
1114 .blog #nav-above,
1115 .navigation.paging-navigation,
1116 .navigation.pagination,
1117 .pagination.paging-pagination,
1118 .pagination.pagination,
1119 .pagination.loop-pagination,
1120 .bicubic-nav-link,
1121 #page-nav,
1122 .camp-paging,
1123 #reposter_nav-pages,
1124 .unity-post-pagination,
1125 .wordpost_content .nav_post_link';
1126 }
1127 if ( ( ! empty( $pgntn_options['additional_pagination_style'] ) ) && '1' == $pgntn_options['display_custom_pagination'] ) {
1128 $classes .= ! empty( $classes ) ? ',' : '';
1129 $classes .= $pgntn_options['additional_pagination_style'];
1130 }
1131 if ( ! empty( $classes ) ) {
1132 echo '<style type="text/css">' . PHP_EOL;
1133 echo $classes . ' {
1134 display: none !important;
1135 }
1136 .single-gallery .pagination.gllrpr_pagination {
1137 display: block !important;
1138 }';
1139 echo '</style>' . PHP_EOL;
1140 } ?>
1141 <?php }
1142
1143 public function show_wpp_admin_notice() {
1144 $current_user_id = get_current_user_id();
1145
1146 $review = get_user_meta( $current_user_id, WPP_REVIEW_NOTICE, true );
1147 if( $review !== 'off') {
1148 if($review === false) {
1149 $this->wpp_show_review_notice();
1150 } else {
1151 $now = date("Y-m-d");
1152 $review_time = strtotime($review);
1153 $now_time = strtotime($now);
1154 if($now_time > $review_time) {
1155 $this->wpp_show_review_notice();
1156 }
1157 }
1158 }
1159 }
1160
1161 public function wpp_show_review_notice() {
1162 if( current_user_can( 'manage_options' ) ) { ?>
1163 <div class="updated notice wpp-notice">
1164 <div id='wp-paginate-logo'></div>
1165 <div id='wpp-notice-1'><p id='wpp-notice-title'><?php esc_html_e( 'Love WP-Paginate?', 'wp-paginate' ); ?></p>
1166 <p><?php esc_html_e( 'Your rating is a big help! We really appreciate it!', 'wp-paginate' ); ?></p>
1167
1168 <ul id="wpp-review-notice-links">
1169 <li> <span class="dashicons dashicons-smiley"></span><a id="wpp-review-already"><?php esc_html_e( "I've already left a review", 'wp-paginate' ); ?></a></li>
1170 <li><span class="dashicons dashicons-calendar-alt"></span><a id="wpp-review-later"><?php esc_html_e( "Maybe Later", 'wp-paginate' ); ?></a></li>
1171 <li><span class="dashicons dashicons-external"></span><a id="wpp-write-review" target="_blank" href="https://wordpress.org/support/plugin/wp-paginate/reviews/?filter=5"><?php esc_html_e( "Sure! I'd love to!", 'wp-paginate' ); ?></a></li>
1172 </ul>
1173 </div>
1174 <a class="dashicons dashicons-dismiss close-wpp-notice" id="wpp-dismiss"></a>
1175 </div>
1176 <?php
1177 }
1178 }
1179
1180 public function wpp_dismiss_notice() {
1181
1182 if ( !wp_verify_nonce( $_POST['nonce'], WP_PAGINATE_NONCE)) {
1183 exit(esc_html__('missing nonce! Please refresh the page.', 'wp-paginate'));
1184 }
1185
1186 $current_user_id = get_current_user_id();
1187
1188 update_user_meta( $current_user_id, WPP_REVIEW_NOTICE, "off" );
1189
1190 exit();
1191
1192 }
1193
1194 public function wpp_set_review_later() {
1195
1196 if ( !wp_verify_nonce( $_POST['nonce'], WP_PAGINATE_NONCE)) {
1197 exit(esc_html__('missing nonce! Please refresh the page.', 'wp-paginate'));
1198 }
1199
1200 $current_user_id = get_current_user_id();
1201
1202 $review_date = date('Y-m-d', strtotime("+7 days"));
1203
1204
1205 update_user_meta( $current_user_id, WPP_REVIEW_NOTICE, $review_date );
1206
1207 exit();
1208
1209 }
1210
1211 function wpp_upgrade_to_pro_tab() {
1212 ?>
1213 <div id="utp-content">
1214 <div id="mf-logo">
1215 <img alt="<?php esc_html_e('maxfoundry logo', 'wp-paginate'); ?>" src="<?php echo esc_url($this->pluginurl . '/images/max-foundry.png') ?>" width="172" height="32">
1216 </div>
1217 <div style="clear:both"></div>
1218 <div id="utp-banner">
1219 <div id="utp-title-wrap">
1220 <div id="utp-title"><?php esc_html_e('WP PAGINATE PRO', 'wp-paginate'); ?></div>
1221 </div>
1222 <a href="<?php echo esc_url_raw(WPP_WP_PAGINATE_PRO_LINK) ?>" target="_blank">
1223 <img class="buy-now-button" alt="<?php esc_html_e('buy now button', 'wp-paginate'); ?>" src="<?php echo esc_url($this->pluginurl . "/images/buy-now-btn.png") ?>" width="205" height="68">
1224 </a>
1225 </div>
1226 <img id='wppp-logo' alt="<?php esc_html_e('wp-pagination pro logo', 'wp-paginate'); ?>" src="<?php echo esc_url($this->pluginurl . '/images/wpp-pro-logo-2.png') ?>" width="169" height="61">
1227
1228 <div class="utp-text">
1229 <?php esc_html_e('WP-Paginate Pro come with 11 Beautiful<br>Preset Layouts and Multi Site support!', 'wp-paginate'); ?>
1230 </div>
1231
1232 <div id="wppp-buttons">
1233 <img alt="<?php esc_html_e('WP Pagination Pro buttons styles', 'wp-paginate'); ?>" src="<?php echo esc_url($this->pluginurl . '/images/wppp-buttons.png') ?>" width="646" height="713">
1234 </div>
1235
1236 <div class="utp-text">
1237 <?php esc_html_e('Use These Customizer Settings to Get the<br>Exact Look and Feel You Want', 'wp-paginate'); ?>
1238 </div>
1239
1240 <div id="wppp-customizer">
1241 <img alt="<?php esc_html_e('WP Pagination Por button Style customizer', 'wp-paginate'); ?>" src="<?php echo esc_url($this->pluginurl . '/images/wppp-customizer.png') ?>" width="650" height="380">
1242 </div>
1243
1244 <a href="<?php echo esc_url_raw(WPP_WP_PAGINATE_PRO_LINK) ?>" target="_blank">
1245 <img class="buy-now-button" alt="<?php esc_html_e('buy now button', 'wp-paginate'); ?>" src="<?php echo esc_url($this->pluginurl . "/images/buy-now-btn.png") ?>" width="205" height="68">
1246 </a>
1247
1248 </div>
1249
1250
1251 <div>
1252
1253 </div>
1254
1255
1256 <?php
1257 }
1258
1259
1260 }
1261 }
1262
1263 //instantiate the class
1264 if (class_exists('WPPaginate')) {
1265 $wp_paginate = new WPPaginate();
1266 }
1267
1268 /**
1269 * Pagination function to use for posts
1270 */
1271 function wp_paginate($args = false) {
1272
1273 if(!is_active_widget()) {
1274 global $wp_paginate;
1275 $wp_paginate->type = 'posts';
1276 return $wp_paginate->paginate($args);
1277 }
1278 }
1279
1280 /**
1281 * Pagination function to use for post comments
1282 */
1283 function wp_paginate_comments($args = false) {
1284 global $wp_paginate;
1285 $wp_paginate->type = 'comments';
1286 return $wp_paginate->paginate($args);
1287 }
1288
1289
1290 /*
1291 * The format of this plugin is based on the following plugin template:
1292 * http://pressography.com/plugins/wordpress-plugin-template/
1293 */
1294