Version Description
- New: Option to hide admin bar chart
- Fix: Small security bug with views label
- Tweak: Remove unnecessary CSS on every page
Download this release
Release Info
Developer | dfactory |
Plugin | Post Views Counter |
Version | 1.3.5 |
Comparing to | |
See all releases |
Code changes from version 1.3.4 to 1.3.5
- includes/columns.php +69 -57
- includes/counter.php +16 -17
- includes/functions.php +2 -2
- includes/settings.php +838 -815
- languages/post-views-counter.pot +77 -63
- post-views-counter.php +27 -26
- readme.txt +11 -7
includes/columns.php
CHANGED
@@ -470,54 +470,57 @@ class Post_Views_Counter_Columns {
|
|
470 |
* Add admin bar stats to a post.
|
471 |
*/
|
472 |
public function admin_bar_menu( $admin_bar ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
473 |
$post = null;
|
474 |
-
|
475 |
if ( is_admin() && ! wp_doing_ajax() ) {
|
476 |
global $pagenow;
|
477 |
-
|
478 |
$post = $pagenow == 'post.php' && ! empty( $_GET['post'] ) ? get_post( (int) $_GET['post'] ) : $post;
|
479 |
-
} elseif ( is_singular() )
|
480 |
global $post;
|
481 |
-
|
482 |
-
|
483 |
// get countable post types
|
484 |
$post_types = Post_Views_Counter()->options['general']['post_types_count'];
|
485 |
|
486 |
// whether to count this post type or not
|
487 |
if ( empty( $post_types ) || empty( $post ) || ! in_array( $post->post_type, $post_types, true ) )
|
488 |
return;
|
489 |
-
|
490 |
$dt = new DateTime();
|
491 |
-
|
492 |
-
|
493 |
-
$month = date_i18n( 'm', $date );
|
494 |
-
$week = date_i18n( 'W', $date );
|
495 |
-
$day = date_i18n( 'd', $date );
|
496 |
-
|
497 |
$views = pvc_get_views( array(
|
498 |
'post_id' => $post->ID,
|
499 |
'post_type' => $post->post_type,
|
500 |
'fields' => 'date=>views',
|
501 |
'views_query' => array(
|
502 |
-
'year' => $
|
503 |
-
|
504 |
-
'month' => $month,
|
505 |
-
// 'day' => $day
|
506 |
)
|
507 |
) );
|
508 |
-
|
509 |
$graph = '';
|
510 |
-
|
511 |
// get highest value
|
512 |
$views_copy = $views;
|
|
|
513 |
arsort( $views_copy, SORT_NUMERIC );
|
|
|
514 |
$highest = reset( $views_copy );
|
|
|
515 |
// find the multiplier
|
516 |
$multiplier = $highest * 0.05;
|
517 |
-
|
518 |
// generate ranges
|
519 |
$ranges = array();
|
520 |
-
|
521 |
for ( $i = 1; $i <= 20; $i ++ ) {
|
522 |
$ranges[$i] = round( $multiplier * $i );
|
523 |
}
|
@@ -525,7 +528,7 @@ class Post_Views_Counter_Columns {
|
|
525 |
// create graph
|
526 |
foreach ( $views as $date => $count ) {
|
527 |
$count_class = 0;
|
528 |
-
|
529 |
if ( $count > 0 ) {
|
530 |
foreach ( $ranges as $index => $range ) {
|
531 |
if ( $count <= $range ) {
|
@@ -534,36 +537,44 @@ class Post_Views_Counter_Columns {
|
|
534 |
}
|
535 |
}
|
536 |
}
|
537 |
-
|
538 |
$graph .= '<span class="pvc-line-graph pvc-line-graph-' . $count_class . '" title="' . sprintf( _n( '%s post view', '%s post views', $count, 'post-views-counter' ), number_format_i18n( $count ) ) . '"></span>';
|
539 |
}
|
540 |
-
|
541 |
-
$admin_bar->add_menu(
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
'
|
547 |
-
|
548 |
-
|
|
|
|
|
549 |
}
|
550 |
-
|
551 |
/**
|
552 |
* Maybe add admin CSS.
|
553 |
*/
|
554 |
public function admin_bar_maybe_add_style() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
555 |
$post = null;
|
556 |
-
|
557 |
if ( is_admin() && ! wp_doing_ajax() ) {
|
558 |
global $pagenow;
|
559 |
-
|
560 |
-
$post = $pagenow
|
561 |
-
} elseif ( is_singular() )
|
562 |
global $post;
|
563 |
-
|
564 |
-
|
565 |
// get countable post types
|
566 |
-
$post_types =
|
567 |
|
568 |
// whether to count this post type or not
|
569 |
if ( empty( $post_types ) || empty( $post ) || ! in_array( $post->post_type, $post_types, true ) )
|
@@ -571,35 +582,36 @@ class Post_Views_Counter_Columns {
|
|
571 |
|
572 |
// on backend area
|
573 |
add_action( 'admin_head', array( $this, 'admin_bar_css' ) );
|
|
|
574 |
// on frontend area
|
575 |
add_action( 'wp_head', array( $this, 'admin_bar_css' ) );
|
576 |
}
|
577 |
-
|
578 |
/**
|
579 |
* Add admin CSS.
|
580 |
*/
|
581 |
public function admin_bar_css() {
|
582 |
$html = '
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
for ( $i = 1; $i <= 20; $i ++ ) {
|
596 |
$html .= '
|
597 |
-
|
598 |
}
|
599 |
-
|
600 |
$html .= '
|
601 |
-
|
602 |
-
|
603 |
echo $html;
|
604 |
}
|
605 |
-
}
|
470 |
* Add admin bar stats to a post.
|
471 |
*/
|
472 |
public function admin_bar_menu( $admin_bar ) {
|
473 |
+
// get main instance
|
474 |
+
$pvc = Post_Views_Counter();
|
475 |
+
|
476 |
+
// statistics enabled?
|
477 |
+
if ( ! apply_filters( 'pvc_display_toolbar_statistics', $pvc->options['display']['toolbar_statistics'] ) )
|
478 |
+
return;
|
479 |
+
|
480 |
$post = null;
|
481 |
+
|
482 |
if ( is_admin() && ! wp_doing_ajax() ) {
|
483 |
global $pagenow;
|
484 |
+
|
485 |
$post = $pagenow == 'post.php' && ! empty( $_GET['post'] ) ? get_post( (int) $_GET['post'] ) : $post;
|
486 |
+
} elseif ( is_singular() )
|
487 |
global $post;
|
488 |
+
|
|
|
489 |
// get countable post types
|
490 |
$post_types = Post_Views_Counter()->options['general']['post_types_count'];
|
491 |
|
492 |
// whether to count this post type or not
|
493 |
if ( empty( $post_types ) || empty( $post ) || ! in_array( $post->post_type, $post_types, true ) )
|
494 |
return;
|
495 |
+
|
496 |
$dt = new DateTime();
|
497 |
+
|
498 |
+
// get post views
|
|
|
|
|
|
|
|
|
499 |
$views = pvc_get_views( array(
|
500 |
'post_id' => $post->ID,
|
501 |
'post_type' => $post->post_type,
|
502 |
'fields' => 'date=>views',
|
503 |
'views_query' => array(
|
504 |
+
'year' => $dt->format( 'Y' ),
|
505 |
+
'month' => $dt->format( 'm' )
|
|
|
|
|
506 |
)
|
507 |
) );
|
508 |
+
|
509 |
$graph = '';
|
510 |
+
|
511 |
// get highest value
|
512 |
$views_copy = $views;
|
513 |
+
|
514 |
arsort( $views_copy, SORT_NUMERIC );
|
515 |
+
|
516 |
$highest = reset( $views_copy );
|
517 |
+
|
518 |
// find the multiplier
|
519 |
$multiplier = $highest * 0.05;
|
520 |
+
|
521 |
// generate ranges
|
522 |
$ranges = array();
|
523 |
+
|
524 |
for ( $i = 1; $i <= 20; $i ++ ) {
|
525 |
$ranges[$i] = round( $multiplier * $i );
|
526 |
}
|
528 |
// create graph
|
529 |
foreach ( $views as $date => $count ) {
|
530 |
$count_class = 0;
|
531 |
+
|
532 |
if ( $count > 0 ) {
|
533 |
foreach ( $ranges as $index => $range ) {
|
534 |
if ( $count <= $range ) {
|
537 |
}
|
538 |
}
|
539 |
}
|
540 |
+
|
541 |
$graph .= '<span class="pvc-line-graph pvc-line-graph-' . $count_class . '" title="' . sprintf( _n( '%s post view', '%s post views', $count, 'post-views-counter' ), number_format_i18n( $count ) ) . '"></span>';
|
542 |
}
|
543 |
+
|
544 |
+
$admin_bar->add_menu(
|
545 |
+
[
|
546 |
+
'id' => 'pvc-post-views',
|
547 |
+
'title' => '<span class="pvc-graph-container">' . $graph . '</span>',
|
548 |
+
'href' => false,
|
549 |
+
'meta' => [
|
550 |
+
'title' => false
|
551 |
+
]
|
552 |
+
]
|
553 |
+
);
|
554 |
}
|
555 |
+
|
556 |
/**
|
557 |
* Maybe add admin CSS.
|
558 |
*/
|
559 |
public function admin_bar_maybe_add_style() {
|
560 |
+
// get main instance
|
561 |
+
$pvc = Post_Views_Counter();
|
562 |
+
|
563 |
+
// statistics enabled?
|
564 |
+
if ( ! $pvc->options['display']['toolbar_statistics'] )
|
565 |
+
return;
|
566 |
+
|
567 |
$post = null;
|
568 |
+
|
569 |
if ( is_admin() && ! wp_doing_ajax() ) {
|
570 |
global $pagenow;
|
571 |
+
|
572 |
+
$post = ( $pagenow === 'post.php' && ! empty( $_GET['post'] ) ) ? get_post( (int) $_GET['post'] ) : $post;
|
573 |
+
} elseif ( is_singular() )
|
574 |
global $post;
|
575 |
+
|
|
|
576 |
// get countable post types
|
577 |
+
$post_types = $pvc->options['general']['post_types_count'];
|
578 |
|
579 |
// whether to count this post type or not
|
580 |
if ( empty( $post_types ) || empty( $post ) || ! in_array( $post->post_type, $post_types, true ) )
|
582 |
|
583 |
// on backend area
|
584 |
add_action( 'admin_head', array( $this, 'admin_bar_css' ) );
|
585 |
+
|
586 |
// on frontend area
|
587 |
add_action( 'wp_head', array( $this, 'admin_bar_css' ) );
|
588 |
}
|
589 |
+
|
590 |
/**
|
591 |
* Add admin CSS.
|
592 |
*/
|
593 |
public function admin_bar_css() {
|
594 |
$html = '
|
595 |
+
<style type="text/css">
|
596 |
+
#wp-admin-bar-pvc-post-views .pvc-graph-container { padding-top: 6px; padding-bottom: 6px; position: relative; display: block; height: 100%; box-sizing: border-box; }
|
597 |
+
#wp-admin-bar-pvc-post-views .pvc-line-graph {
|
598 |
+
display: inline-block;
|
599 |
+
width: 1px;
|
600 |
+
margin-right: 1px;
|
601 |
+
background-color: #ccc;
|
602 |
+
vertical-align: baseline;
|
603 |
+
}
|
604 |
+
#wp-admin-bar-pvc-post-views .pvc-line-graph:hover { background-color: #eee; }
|
605 |
+
#wp-admin-bar-pvc-post-views .pvc-line-graph-0 { height: 1% }';
|
606 |
+
|
607 |
for ( $i = 1; $i <= 20; $i ++ ) {
|
608 |
$html .= '
|
609 |
+
#wp-admin-bar-pvc-post-views .pvc-line-graph-' . $i . ' { height: ' . $i * 5 . '% }';
|
610 |
}
|
611 |
+
|
612 |
$html .= '
|
613 |
+
</style>';
|
614 |
+
|
615 |
echo $html;
|
616 |
}
|
617 |
+
}
|
includes/counter.php
CHANGED
@@ -674,15 +674,15 @@ class Post_Views_Counter_Counter {
|
|
674 |
|
675 |
global $wpdb;
|
676 |
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
|
683 |
$this->db_insert_values = '';
|
684 |
|
685 |
-
|
686 |
}
|
687 |
|
688 |
/**
|
@@ -760,9 +760,9 @@ class Post_Views_Counter_Counter {
|
|
760 |
|
761 |
return true;
|
762 |
}
|
763 |
-
|
764 |
/**
|
765 |
-
* Encrypt user IP
|
766 |
*
|
767 |
* @param int $ip
|
768 |
* @return string $encrypted_ip
|
@@ -772,7 +772,7 @@ class Post_Views_Counter_Counter {
|
|
772 |
$auth_iv = defined( 'NONCE_KEY' ) ? NONCE_KEY : '';
|
773 |
|
774 |
// mcrypt strong encryption
|
775 |
-
if ( function_exists( 'mcrypt_encrypt' ) && defined( 'MCRYPT_BLOWFISH' ) ) {
|
776 |
// get max key size of the mcrypt mode
|
777 |
$max_key_size = mcrypt_get_key_size( MCRYPT_BLOWFISH, MCRYPT_MODE_CBC );
|
778 |
$max_iv_size = mcrypt_get_iv_size( MCRYPT_BLOWFISH, MCRYPT_MODE_CBC );
|
@@ -781,7 +781,7 @@ class Post_Views_Counter_Counter {
|
|
781 |
$encrypt_iv = mb_strimwidth( $auth_iv, 0, $max_iv_size );
|
782 |
|
783 |
$encrypted_ip = strtr( base64_encode( mcrypt_encrypt( MCRYPT_BLOWFISH, $encrypt_key, $ip, MCRYPT_MODE_CBC, $encrypt_iv ) ), '+/=', '-_,' );
|
784 |
-
|
785 |
} elseif ( function_exists( 'gzdeflate' ) )
|
786 |
$encrypted_ip = base64_encode( convert_uuencode( gzdeflate( $ip ) ) );
|
787 |
// no encryption
|
@@ -792,7 +792,7 @@ class Post_Views_Counter_Counter {
|
|
792 |
}
|
793 |
|
794 |
/**
|
795 |
-
* Decrypt user IP
|
796 |
*
|
797 |
* @param int $encrypted_ip
|
798 |
* @return string $ip
|
@@ -802,7 +802,7 @@ class Post_Views_Counter_Counter {
|
|
802 |
$auth_iv = defined( 'NONCE_KEY' ) ? NONCE_KEY : '';
|
803 |
|
804 |
// mcrypt strong encryption
|
805 |
-
if ( function_exists( 'mcrypt_decrypt' ) && defined( 'MCRYPT_BLOWFISH' ) ) {
|
806 |
// get max key size of the mcrypt mode
|
807 |
$max_key_size = mcrypt_get_key_size( MCRYPT_BLOWFISH, MCRYPT_MODE_CBC );
|
808 |
$max_iv_size = mcrypt_get_iv_size( MCRYPT_BLOWFISH, MCRYPT_MODE_CBC );
|
@@ -811,13 +811,12 @@ class Post_Views_Counter_Counter {
|
|
811 |
$encrypt_iv = mb_strimwidth( $auth_iv, 0, $max_iv_size );
|
812 |
|
813 |
$ip = mcrypt_decrypt( MCRYPT_BLOWFISH, $encrypt_key, base64_decode( strtr( $encrypted_ip, '-_,', '+/=' ) ), MCRYPT_MODE_CBC, $encrypt_iv );
|
814 |
-
|
815 |
-
} elseif ( function_exists( 'gzinflate' ) )
|
816 |
$ip = gzinflate( convert_uudecode( base64_decode( $encrypted_ip ) ) );
|
817 |
-
|
818 |
-
|
819 |
$ip = convert_uudecode( base64_decode( strtr( $encrypted_ip, '-_,', '+/=' ) ) );
|
820 |
-
}
|
821 |
|
822 |
return $ip;
|
823 |
}
|
674 |
|
675 |
global $wpdb;
|
676 |
|
677 |
+
$result = $wpdb->query( "
|
678 |
+
INSERT INTO " . $wpdb->prefix . "post_views (id, type, period, count)
|
679 |
+
VALUES " . $this->db_insert_values . "
|
680 |
+
ON DUPLICATE KEY UPDATE count = count + VALUES(count)"
|
681 |
+
);
|
682 |
|
683 |
$this->db_insert_values = '';
|
684 |
|
685 |
+
return $result;
|
686 |
}
|
687 |
|
688 |
/**
|
760 |
|
761 |
return true;
|
762 |
}
|
763 |
+
|
764 |
/**
|
765 |
+
* Encrypt user IP.
|
766 |
*
|
767 |
* @param int $ip
|
768 |
* @return string $encrypted_ip
|
772 |
$auth_iv = defined( 'NONCE_KEY' ) ? NONCE_KEY : '';
|
773 |
|
774 |
// mcrypt strong encryption
|
775 |
+
if ( function_exists( 'mcrypt_encrypt' ) && function_exists( 'mcrypt_get_key_size' ) && function_exists( 'mcrypt_get_iv_size' ) && defined( 'MCRYPT_BLOWFISH' ) ) {
|
776 |
// get max key size of the mcrypt mode
|
777 |
$max_key_size = mcrypt_get_key_size( MCRYPT_BLOWFISH, MCRYPT_MODE_CBC );
|
778 |
$max_iv_size = mcrypt_get_iv_size( MCRYPT_BLOWFISH, MCRYPT_MODE_CBC );
|
781 |
$encrypt_iv = mb_strimwidth( $auth_iv, 0, $max_iv_size );
|
782 |
|
783 |
$encrypted_ip = strtr( base64_encode( mcrypt_encrypt( MCRYPT_BLOWFISH, $encrypt_key, $ip, MCRYPT_MODE_CBC, $encrypt_iv ) ), '+/=', '-_,' );
|
784 |
+
// simple encryption
|
785 |
} elseif ( function_exists( 'gzdeflate' ) )
|
786 |
$encrypted_ip = base64_encode( convert_uuencode( gzdeflate( $ip ) ) );
|
787 |
// no encryption
|
792 |
}
|
793 |
|
794 |
/**
|
795 |
+
* Decrypt user IP.
|
796 |
*
|
797 |
* @param int $encrypted_ip
|
798 |
* @return string $ip
|
802 |
$auth_iv = defined( 'NONCE_KEY' ) ? NONCE_KEY : '';
|
803 |
|
804 |
// mcrypt strong encryption
|
805 |
+
if ( function_exists( 'mcrypt_decrypt' ) && function_exists( 'mcrypt_get_key_size' ) && function_exists( 'mcrypt_get_iv_size' ) && defined( 'MCRYPT_BLOWFISH' ) ) {
|
806 |
// get max key size of the mcrypt mode
|
807 |
$max_key_size = mcrypt_get_key_size( MCRYPT_BLOWFISH, MCRYPT_MODE_CBC );
|
808 |
$max_iv_size = mcrypt_get_iv_size( MCRYPT_BLOWFISH, MCRYPT_MODE_CBC );
|
811 |
$encrypt_iv = mb_strimwidth( $auth_iv, 0, $max_iv_size );
|
812 |
|
813 |
$ip = mcrypt_decrypt( MCRYPT_BLOWFISH, $encrypt_key, base64_decode( strtr( $encrypted_ip, '-_,', '+/=' ) ), MCRYPT_MODE_CBC, $encrypt_iv );
|
814 |
+
// simple encryption
|
815 |
+
} elseif ( function_exists( 'gzinflate' ) )
|
816 |
$ip = gzinflate( convert_uudecode( base64_decode( $encrypted_ip ) ) );
|
817 |
+
// no encryption
|
818 |
+
else
|
819 |
$ip = convert_uudecode( base64_decode( strtr( $encrypted_ip, '-_,', '+/=' ) ) );
|
|
|
820 |
|
821 |
return $ip;
|
822 |
}
|
includes/functions.php
CHANGED
@@ -394,7 +394,7 @@ if ( ! function_exists( 'pvc_post_views' ) ) {
|
|
394 |
$icon_class = ( $options['icon_class'] !== '' ? esc_attr( $options['icon_class'] ) : '' );
|
395 |
|
396 |
// add dashicons class if needed
|
397 |
-
$icon_class = strpos( $icon_class, 'dashicons' ) === 0 ? 'dashicons ' . $icon_class
|
398 |
|
399 |
// prepare icon output
|
400 |
$icon = apply_filters( 'pvc_post_views_icon', '<span class="post-views-icon ' . $icon_class . '"></span>', $post_id );
|
@@ -403,7 +403,7 @@ if ( ! function_exists( 'pvc_post_views' ) ) {
|
|
403 |
'pvc_post_views_html',
|
404 |
'<div class="post-views post-' . $post_id . ' entry-meta">
|
405 |
' . ( $options['display_style']['icon'] && $icon_class !== '' ? $icon : '' ) . '
|
406 |
-
' . ( $options['display_style']['text'] && $label !== '' ? '<span class="post-views-label">' . $label . '
|
407 |
<span class="post-views-count">' . number_format_i18n( $views ) . '</span>
|
408 |
</div>',
|
409 |
$post_id,
|
394 |
$icon_class = ( $options['icon_class'] !== '' ? esc_attr( $options['icon_class'] ) : '' );
|
395 |
|
396 |
// add dashicons class if needed
|
397 |
+
$icon_class = strpos( $icon_class, 'dashicons ' ) === 0 ? $icon_class : 'dashicons ' . $icon_class;
|
398 |
|
399 |
// prepare icon output
|
400 |
$icon = apply_filters( 'pvc_post_views_icon', '<span class="post-views-icon ' . $icon_class . '"></span>', $post_id );
|
403 |
'pvc_post_views_html',
|
404 |
'<div class="post-views post-' . $post_id . ' entry-meta">
|
405 |
' . ( $options['display_style']['icon'] && $icon_class !== '' ? $icon : '' ) . '
|
406 |
+
' . ( $options['display_style']['text'] && $label !== '' ? '<span class="post-views-label">' . esc_html( $label ) . '</span>' : '' ) . '
|
407 |
<span class="post-views-count">' . number_format_i18n( $views ) . '</span>
|
408 |
</div>',
|
409 |
$post_id,
|
includes/settings.php
CHANGED
@@ -1,816 +1,839 @@
|
|
1 |
-
<?php
|
2 |
-
// exit if accessed directly
|
3 |
-
if ( ! defined( 'ABSPATH' ) )
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Post_Views_Counter_Settings class.
|
8 |
-
*
|
9 |
-
* @class Post_Views_Counter_Settings
|
10 |
-
*/
|
11 |
-
class Post_Views_Counter_Settings {
|
12 |
-
|
13 |
-
private $tabs;
|
14 |
-
private $choices;
|
15 |
-
private $modes;
|
16 |
-
private $time_types;
|
17 |
-
private $groups;
|
18 |
-
private $user_roles;
|
19 |
-
private $positions;
|
20 |
-
private $display_styles;
|
21 |
-
public $post_types;
|
22 |
-
public $page_types;
|
23 |
-
|
24 |
-
public function __construct() {
|
25 |
-
// actions
|
26 |
-
add_action( 'admin_init', array( $this, 'register_settings' ) );
|
27 |
-
add_action( 'admin_menu', array( $this, 'admin_menu_options' ) );
|
28 |
-
add_action( 'after_setup_theme', array( $this, 'load_defaults' ) );
|
29 |
-
add_action( 'wp_loaded', array( $this, 'load_post_types' ) );
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Load default settings.
|
34 |
-
*/
|
35 |
-
public function load_defaults() {
|
36 |
-
if ( ! is_admin() )
|
37 |
-
return;
|
38 |
-
|
39 |
-
$this->modes = array(
|
40 |
-
'php' => __( 'PHP', 'post-views-counter' ),
|
41 |
-
'js' => __( 'JavaScript', 'post-views-counter' ),
|
42 |
-
'ajax' => __( 'Fast AJAX', 'post-views-counter' )
|
43 |
-
);
|
44 |
-
|
45 |
-
if ( function_exists( 'register_rest_route' ) )
|
46 |
-
$this->modes['rest_api'] = __( 'REST API', 'post-views-counter' );
|
47 |
-
|
48 |
-
$this->time_types = array(
|
49 |
-
'minutes' => __( 'minutes', 'post-views-counter' ),
|
50 |
-
'hours' => __( 'hours', 'post-views-counter' ),
|
51 |
-
'days' => __( 'days', 'post-views-counter' ),
|
52 |
-
'weeks' => __( 'weeks', 'post-views-counter' ),
|
53 |
-
'months' => __( 'months', 'post-views-counter' ),
|
54 |
-
'years' => __( 'years', 'post-views-counter' )
|
55 |
-
);
|
56 |
-
|
57 |
-
$this->groups = array(
|
58 |
-
'robots' => __( 'robots', 'post-views-counter' ),
|
59 |
-
'users' => __( 'logged in users', 'post-views-counter' ),
|
60 |
-
'guests' => __( 'guests', 'post-views-counter' ),
|
61 |
-
'roles' => __( 'selected user roles', 'post-views-counter' )
|
62 |
-
);
|
63 |
-
|
64 |
-
$this->positions = array(
|
65 |
-
'before' => __( 'before the content', 'post-views-counter' ),
|
66 |
-
'after' => __( 'after the content', 'post-views-counter' ),
|
67 |
-
'manual' => __( 'manual', 'post-views-counter' )
|
68 |
-
);
|
69 |
-
|
70 |
-
$this->display_styles = array(
|
71 |
-
'icon' => __( 'icon', 'post-views-counter' ),
|
72 |
-
'text' => __( 'label', 'post-views-counter' )
|
73 |
-
);
|
74 |
-
|
75 |
-
$this->tabs = array(
|
76 |
-
'general' => array(
|
77 |
-
'name' => __( 'General', 'post-views-counter' ),
|
78 |
-
'key' => 'post_views_counter_settings_general',
|
79 |
-
'submit' => 'save_pvc_general',
|
80 |
-
'reset' => 'reset_pvc_general'
|
81 |
-
),
|
82 |
-
'display' => array(
|
83 |
-
'name' => __( 'Display', 'post-views-counter' ),
|
84 |
-
'key' => 'post_views_counter_settings_display',
|
85 |
-
'submit' => 'save_pvc_display',
|
86 |
-
'reset' => 'reset_pvc_display'
|
87 |
-
)
|
88 |
-
);
|
89 |
-
|
90 |
-
$this->user_roles = $this->get_user_roles();
|
91 |
-
|
92 |
-
$this->page_types = apply_filters(
|
93 |
-
'pvc_page_types_display_options',
|
94 |
-
array(
|
95 |
-
'home' => __( 'Home', 'post-views-counter' ),
|
96 |
-
'archive' => __( 'Archives', 'post-views-counter' ),
|
97 |
-
'singular' => __( 'Single pages', 'post-views-counter' ),
|
98 |
-
'search' => __( 'Search results', 'post-views-counter' ),
|
99 |
-
)
|
100 |
-
);
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Get post types avaiable for counting.
|
105 |
-
*/
|
106 |
-
public function load_post_types() {
|
107 |
-
if ( ! is_admin() )
|
108 |
-
return;
|
109 |
-
|
110 |
-
$post_types = array();
|
111 |
-
|
112 |
-
// built in public post types
|
113 |
-
foreach ( get_post_types( array( '_builtin' => true, 'public' => true ), 'objects', 'and' ) as $key => $post_type ) {
|
114 |
-
$post_types[$key] = $post_type->labels->name;
|
115 |
-
}
|
116 |
-
|
117 |
-
// public custom post types
|
118 |
-
foreach ( get_post_types( array( '_builtin' => false, 'public' => true ), 'objects', 'and' ) as $key => $post_type ) {
|
119 |
-
$post_types[$key] = $post_type->labels->name;
|
120 |
-
}
|
121 |
-
|
122 |
-
// remove bbPress replies
|
123 |
-
if ( class_exists( 'bbPress' ) && isset( $post_types['reply'] ) )
|
124 |
-
unset( $post_types['reply'] );
|
125 |
-
|
126 |
-
$post_types = apply_filters( 'pvc_available_post_types', $post_types );
|
127 |
-
|
128 |
-
// sort post types alphabetically with their keys
|
129 |
-
asort( $post_types, SORT_STRING );
|
130 |
-
|
131 |
-
$this->post_types = $post_types;
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Get all user roles.
|
136 |
-
*
|
137 |
-
* @global object $wp_roles
|
138 |
-
* @return array
|
139 |
-
*/
|
140 |
-
public function get_user_roles() {
|
141 |
-
global $wp_roles;
|
142 |
-
|
143 |
-
$roles = array();
|
144 |
-
|
145 |
-
foreach ( apply_filters( 'editable_roles', $wp_roles->roles ) as $role => $details ) {
|
146 |
-
$roles[$role] = translate_user_role( $details['name'] );
|
147 |
-
}
|
148 |
-
|
149 |
-
asort( $roles, SORT_STRING );
|
150 |
-
|
151 |
-
return $roles;
|
152 |
-
}
|
153 |
-
|
154 |
-
/**
|
155 |
-
* Add options page.
|
156 |
-
*
|
157 |
-
* @return void
|
158 |
-
*/
|
159 |
-
public function admin_menu_options() {
|
160 |
-
add_options_page( __( 'Post Views Counter', 'post-views-counter' ), __( 'Post Views Counter', 'post-views-counter' ), 'manage_options', 'post-views-counter', array( $this, 'options_page' ) );
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* Options page callback.
|
165 |
-
*
|
166 |
-
* @return void
|
167 |
-
*/
|
168 |
-
public function options_page() {
|
169 |
-
$tab_key = (isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'general');
|
170 |
-
|
171 |
-
echo '
|
172 |
-
<div class="wrap">
|
173 |
-
<h2>' . __( 'Post Views Counter', 'post-views-counter' ) . '</h2>
|
174 |
-
<h2 class="nav-tab-wrapper">';
|
175 |
-
|
176 |
-
foreach ( $this->tabs as $key => $name ) {
|
177 |
-
echo '
|
178 |
-
<a class="nav-tab ' . ($tab_key == $key ? 'nav-tab-active' : '') . '" href="' . esc_url( admin_url( 'options-general.php?page=post-views-counter&tab=' . $key ) ) . '">' . $name['name'] . '</a>';
|
179 |
-
}
|
180 |
-
|
181 |
-
echo '
|
182 |
-
</h2>
|
183 |
-
<div class="post-views-counter-settings">
|
184 |
-
<div class="df-credits">
|
185 |
-
<h3 class="hndle">' . __( 'Post Views Counter', 'post-views-counter' ) . ' ' . Post_Views_Counter()->defaults['version'] . '</h3>
|
186 |
-
<div class="inside">
|
187 |
-
<h4 class="inner">' . __( 'Need support?', 'post-views-counter' ) . '</h4>
|
188 |
-
<p class="inner">' . sprintf( __( 'If you are having problems with this plugin, please browse it\'s <a href="%s" target="_blank">Documentation</a> or talk about them in the <a href="%s" target="_blank">Support forum</a>', 'post-views-counter' ), 'https://www.dfactory.eu/docs/post-views-counter/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=docs', 'https://www.dfactory.eu/support/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=support' ) . '</p>
|
189 |
-
<hr />
|
190 |
-
<h4 class="inner">' . __( 'Do you like this plugin?', 'post-views-counter' ) . '</h4>
|
191 |
-
<p class="inner">' . sprintf( __( '<a href="%s" target="_blank">Rate it 5</a> on WordPress.org', 'post-views-counter' ), 'https://wordpress.org/support/plugin/post-views-counter/reviews/?filter=5' ) . '<br />' .
|
192 |
-
sprintf( __( 'Blog about it & link to the <a href="%s" target="_blank">plugin page</a>.', 'post-views-counter' ), 'https://dfactory.eu/plugins/post-views-counter/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=blog-about' ) . '<br />' .
|
193 |
-
sprintf( __( 'Check out our other <a href="%s" target="_blank">WordPress plugins</a>.', 'post-views-counter' ), 'https://dfactory.eu/plugins/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=other-plugins' ) . '
|
194 |
-
</p>
|
195 |
-
<hr />
|
196 |
-
<p class="df-link inner"><a href="http://www.dfactory.eu/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=created-by" target="_blank" title="Digital Factory"><img src="//pvc-53eb.kxcdn.com/df-black-sm.png' . '" alt="Digital Factory" /></a></p>
|
197 |
-
</div>
|
198 |
-
</div>
|
199 |
-
<form action="options.php" method="post">';
|
200 |
-
|
201 |
-
wp_nonce_field( 'update-options' );
|
202 |
-
settings_fields( $this->tabs[$tab_key]['key'] );
|
203 |
-
do_settings_sections( $this->tabs[$tab_key]['key'] );
|
204 |
-
|
205 |
-
echo '
|
206 |
-
<p class="submit">';
|
207 |
-
|
208 |
-
submit_button( '', 'primary', $this->tabs[$tab_key]['submit'], false );
|
209 |
-
|
210 |
-
echo ' ';
|
211 |
-
|
212 |
-
submit_button( __( 'Reset to defaults', 'post-views-counter' ), 'secondary reset_pvc_settings', $this->tabs[$tab_key]['reset'], false );
|
213 |
-
|
214 |
-
echo '
|
215 |
-
</p>
|
216 |
-
</form>
|
217 |
-
</div>
|
218 |
-
<div class="clear"></div>
|
219 |
-
</div>';
|
220 |
-
}
|
221 |
-
|
222 |
-
/**
|
223 |
-
* Register settings callback.
|
224 |
-
*/
|
225 |
-
public function register_settings() {
|
226 |
-
// general options
|
227 |
-
register_setting( 'post_views_counter_settings_general', 'post_views_counter_settings_general', array( $this, 'validate_settings' ) );
|
228 |
-
add_settings_section( 'post_views_counter_settings_general', __( 'General settings', 'post-views-counter' ), '', 'post_views_counter_settings_general' );
|
229 |
-
add_settings_field( 'pvc_post_types_count', __( 'Post Types Count', 'post-views-counter' ), array( $this, 'post_types_count' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
230 |
-
add_settings_field( 'pvc_counter_mode', __( 'Counter Mode', 'post-views-counter' ), array( $this, 'counter_mode' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
231 |
-
add_settings_field( 'pvc_post_views_column', __( 'Post Views Column', 'post-views-counter' ), array( $this, 'post_views_column' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
232 |
-
add_settings_field( 'pvc_restrict_edit_views', __( 'Restrict Edit', 'post-views-counter' ), array( $this, 'restrict_edit_views' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
233 |
-
add_settings_field( 'pvc_time_between_counts', __( 'Count Interval', 'post-views-counter' ), array( $this, 'time_between_counts' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
234 |
-
add_settings_field( 'pvc_reset_counts', __( 'Reset Data Interval', 'post-views-counter' ), array( $this, 'reset_counts' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
235 |
-
add_settings_field( 'pvc_flush_interval', __( 'Flush Object Cache Interval', 'post-views-counter' ), array( $this, 'flush_interval' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
236 |
-
add_settings_field( 'pvc_exclude', __( 'Exclude Visitors', 'post-views-counter' ), array( $this, 'exclude' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
237 |
-
add_settings_field( 'pvc_exclude_ips', __( 'Exclude IPs', 'post-views-counter' ), array( $this, 'exclude_ips' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
238 |
-
add_settings_field( 'pvc_strict_counts', __( 'Strict counts', 'post-views-counter' ), array( $this, 'strict_counts' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
239 |
-
add_settings_field( 'pvc_wp_postviews', __( 'Tools', 'post-views-counter' ), array( $this, 'wp_postviews' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
240 |
-
add_settings_field( 'pvc_deactivation_delete', __( 'Deactivation', 'post-views-counter' ), array( $this, 'deactivation_delete' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
241 |
-
|
242 |
-
// display options
|
243 |
-
register_setting( 'post_views_counter_settings_display', 'post_views_counter_settings_display', array( $this, 'validate_settings' ) );
|
244 |
-
add_settings_section( 'post_views_counter_settings_display', __( 'Display settings', 'post-views-counter' ), '', 'post_views_counter_settings_display' );
|
245 |
-
add_settings_field( 'pvc_post_views_label', __( 'Post Views Label', 'post-views-counter' ), array( $this, 'post_views_label' ), 'post_views_counter_settings_display', 'post_views_counter_settings_display' );
|
246 |
-
add_settings_field( 'pvc_post_types_display', __( 'Post Type', 'post-views-counter' ), array( $this, 'post_types_display' ), 'post_views_counter_settings_display', 'post_views_counter_settings_display' );
|
247 |
-
add_settings_field( 'pvc_page_types_display', __( 'Page Type', 'post-views-counter' ), array( $this, 'page_types_display' ), 'post_views_counter_settings_display', 'post_views_counter_settings_display' );
|
248 |
-
add_settings_field( 'pvc_restrict_display', __( 'User Type', 'post-views-counter' ), array( $this, 'restrict_display' ), 'post_views_counter_settings_display', 'post_views_counter_settings_display' );
|
249 |
-
add_settings_field( 'pvc_position', __( 'Position', 'post-views-counter' ), array( $this, 'position' ), 'post_views_counter_settings_display', 'post_views_counter_settings_display' );
|
250 |
-
add_settings_field( 'pvc_display_style', __( 'Display Style', 'post-views-counter' ), array( $this, 'display_style' ), 'post_views_counter_settings_display', 'post_views_counter_settings_display' );
|
251 |
-
add_settings_field( 'pvc_icon_class', __( 'Icon Class', 'post-views-counter' ), array( $this, 'icon_class' ), 'post_views_counter_settings_display', 'post_views_counter_settings_display' );
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
<
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
echo '
|
577 |
-
<
|
578 |
-
|
579 |
-
|
580 |
-
foreach ( $this->
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
//
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
//
|
669 |
-
$input['
|
670 |
-
$input['
|
671 |
-
|
672 |
-
//
|
673 |
-
$input['
|
674 |
-
$input['
|
675 |
-
|
676 |
-
//
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
$input['exclude']['
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
$
|
714 |
-
}
|
715 |
-
|
716 |
-
$input['
|
717 |
-
}
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
$input['
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
// post
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
//
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
$input['
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
$
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
816 |
}
|
1 |
+
<?php
|
2 |
+
// exit if accessed directly
|
3 |
+
if ( ! defined( 'ABSPATH' ) )
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Post_Views_Counter_Settings class.
|
8 |
+
*
|
9 |
+
* @class Post_Views_Counter_Settings
|
10 |
+
*/
|
11 |
+
class Post_Views_Counter_Settings {
|
12 |
+
|
13 |
+
private $tabs;
|
14 |
+
private $choices;
|
15 |
+
private $modes;
|
16 |
+
private $time_types;
|
17 |
+
private $groups;
|
18 |
+
private $user_roles;
|
19 |
+
private $positions;
|
20 |
+
private $display_styles;
|
21 |
+
public $post_types;
|
22 |
+
public $page_types;
|
23 |
+
|
24 |
+
public function __construct() {
|
25 |
+
// actions
|
26 |
+
add_action( 'admin_init', array( $this, 'register_settings' ) );
|
27 |
+
add_action( 'admin_menu', array( $this, 'admin_menu_options' ) );
|
28 |
+
add_action( 'after_setup_theme', array( $this, 'load_defaults' ) );
|
29 |
+
add_action( 'wp_loaded', array( $this, 'load_post_types' ) );
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Load default settings.
|
34 |
+
*/
|
35 |
+
public function load_defaults() {
|
36 |
+
if ( ! is_admin() )
|
37 |
+
return;
|
38 |
+
|
39 |
+
$this->modes = array(
|
40 |
+
'php' => __( 'PHP', 'post-views-counter' ),
|
41 |
+
'js' => __( 'JavaScript', 'post-views-counter' ),
|
42 |
+
'ajax' => __( 'Fast AJAX', 'post-views-counter' )
|
43 |
+
);
|
44 |
+
|
45 |
+
if ( function_exists( 'register_rest_route' ) )
|
46 |
+
$this->modes['rest_api'] = __( 'REST API', 'post-views-counter' );
|
47 |
+
|
48 |
+
$this->time_types = array(
|
49 |
+
'minutes' => __( 'minutes', 'post-views-counter' ),
|
50 |
+
'hours' => __( 'hours', 'post-views-counter' ),
|
51 |
+
'days' => __( 'days', 'post-views-counter' ),
|
52 |
+
'weeks' => __( 'weeks', 'post-views-counter' ),
|
53 |
+
'months' => __( 'months', 'post-views-counter' ),
|
54 |
+
'years' => __( 'years', 'post-views-counter' )
|
55 |
+
);
|
56 |
+
|
57 |
+
$this->groups = array(
|
58 |
+
'robots' => __( 'robots', 'post-views-counter' ),
|
59 |
+
'users' => __( 'logged in users', 'post-views-counter' ),
|
60 |
+
'guests' => __( 'guests', 'post-views-counter' ),
|
61 |
+
'roles' => __( 'selected user roles', 'post-views-counter' )
|
62 |
+
);
|
63 |
+
|
64 |
+
$this->positions = array(
|
65 |
+
'before' => __( 'before the content', 'post-views-counter' ),
|
66 |
+
'after' => __( 'after the content', 'post-views-counter' ),
|
67 |
+
'manual' => __( 'manual', 'post-views-counter' )
|
68 |
+
);
|
69 |
+
|
70 |
+
$this->display_styles = array(
|
71 |
+
'icon' => __( 'icon', 'post-views-counter' ),
|
72 |
+
'text' => __( 'label', 'post-views-counter' )
|
73 |
+
);
|
74 |
+
|
75 |
+
$this->tabs = array(
|
76 |
+
'general' => array(
|
77 |
+
'name' => __( 'General', 'post-views-counter' ),
|
78 |
+
'key' => 'post_views_counter_settings_general',
|
79 |
+
'submit' => 'save_pvc_general',
|
80 |
+
'reset' => 'reset_pvc_general'
|
81 |
+
),
|
82 |
+
'display' => array(
|
83 |
+
'name' => __( 'Display', 'post-views-counter' ),
|
84 |
+
'key' => 'post_views_counter_settings_display',
|
85 |
+
'submit' => 'save_pvc_display',
|
86 |
+
'reset' => 'reset_pvc_display'
|
87 |
+
)
|
88 |
+
);
|
89 |
+
|
90 |
+
$this->user_roles = $this->get_user_roles();
|
91 |
+
|
92 |
+
$this->page_types = apply_filters(
|
93 |
+
'pvc_page_types_display_options',
|
94 |
+
array(
|
95 |
+
'home' => __( 'Home', 'post-views-counter' ),
|
96 |
+
'archive' => __( 'Archives', 'post-views-counter' ),
|
97 |
+
'singular' => __( 'Single pages', 'post-views-counter' ),
|
98 |
+
'search' => __( 'Search results', 'post-views-counter' ),
|
99 |
+
)
|
100 |
+
);
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Get post types avaiable for counting.
|
105 |
+
*/
|
106 |
+
public function load_post_types() {
|
107 |
+
if ( ! is_admin() )
|
108 |
+
return;
|
109 |
+
|
110 |
+
$post_types = array();
|
111 |
+
|
112 |
+
// built in public post types
|
113 |
+
foreach ( get_post_types( array( '_builtin' => true, 'public' => true ), 'objects', 'and' ) as $key => $post_type ) {
|
114 |
+
$post_types[$key] = $post_type->labels->name;
|
115 |
+
}
|
116 |
+
|
117 |
+
// public custom post types
|
118 |
+
foreach ( get_post_types( array( '_builtin' => false, 'public' => true ), 'objects', 'and' ) as $key => $post_type ) {
|
119 |
+
$post_types[$key] = $post_type->labels->name;
|
120 |
+
}
|
121 |
+
|
122 |
+
// remove bbPress replies
|
123 |
+
if ( class_exists( 'bbPress' ) && isset( $post_types['reply'] ) )
|
124 |
+
unset( $post_types['reply'] );
|
125 |
+
|
126 |
+
$post_types = apply_filters( 'pvc_available_post_types', $post_types );
|
127 |
+
|
128 |
+
// sort post types alphabetically with their keys
|
129 |
+
asort( $post_types, SORT_STRING );
|
130 |
+
|
131 |
+
$this->post_types = $post_types;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Get all user roles.
|
136 |
+
*
|
137 |
+
* @global object $wp_roles
|
138 |
+
* @return array
|
139 |
+
*/
|
140 |
+
public function get_user_roles() {
|
141 |
+
global $wp_roles;
|
142 |
+
|
143 |
+
$roles = array();
|
144 |
+
|
145 |
+
foreach ( apply_filters( 'editable_roles', $wp_roles->roles ) as $role => $details ) {
|
146 |
+
$roles[$role] = translate_user_role( $details['name'] );
|
147 |
+
}
|
148 |
+
|
149 |
+
asort( $roles, SORT_STRING );
|
150 |
+
|
151 |
+
return $roles;
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Add options page.
|
156 |
+
*
|
157 |
+
* @return void
|
158 |
+
*/
|
159 |
+
public function admin_menu_options() {
|
160 |
+
add_options_page( __( 'Post Views Counter', 'post-views-counter' ), __( 'Post Views Counter', 'post-views-counter' ), 'manage_options', 'post-views-counter', array( $this, 'options_page' ) );
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Options page callback.
|
165 |
+
*
|
166 |
+
* @return void
|
167 |
+
*/
|
168 |
+
public function options_page() {
|
169 |
+
$tab_key = (isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'general');
|
170 |
+
|
171 |
+
echo '
|
172 |
+
<div class="wrap">
|
173 |
+
<h2>' . __( 'Post Views Counter', 'post-views-counter' ) . '</h2>
|
174 |
+
<h2 class="nav-tab-wrapper">';
|
175 |
+
|
176 |
+
foreach ( $this->tabs as $key => $name ) {
|
177 |
+
echo '
|
178 |
+
<a class="nav-tab ' . ($tab_key == $key ? 'nav-tab-active' : '') . '" href="' . esc_url( admin_url( 'options-general.php?page=post-views-counter&tab=' . $key ) ) . '">' . $name['name'] . '</a>';
|
179 |
+
}
|
180 |
+
|
181 |
+
echo '
|
182 |
+
</h2>
|
183 |
+
<div class="post-views-counter-settings">
|
184 |
+
<div class="df-credits">
|
185 |
+
<h3 class="hndle">' . __( 'Post Views Counter', 'post-views-counter' ) . ' ' . Post_Views_Counter()->defaults['version'] . '</h3>
|
186 |
+
<div class="inside">
|
187 |
+
<h4 class="inner">' . __( 'Need support?', 'post-views-counter' ) . '</h4>
|
188 |
+
<p class="inner">' . sprintf( __( 'If you are having problems with this plugin, please browse it\'s <a href="%s" target="_blank">Documentation</a> or talk about them in the <a href="%s" target="_blank">Support forum</a>', 'post-views-counter' ), 'https://www.dfactory.eu/docs/post-views-counter/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=docs', 'https://www.dfactory.eu/support/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=support' ) . '</p>
|
189 |
+
<hr />
|
190 |
+
<h4 class="inner">' . __( 'Do you like this plugin?', 'post-views-counter' ) . '</h4>
|
191 |
+
<p class="inner">' . sprintf( __( '<a href="%s" target="_blank">Rate it 5</a> on WordPress.org', 'post-views-counter' ), 'https://wordpress.org/support/plugin/post-views-counter/reviews/?filter=5' ) . '<br />' .
|
192 |
+
sprintf( __( 'Blog about it & link to the <a href="%s" target="_blank">plugin page</a>.', 'post-views-counter' ), 'https://dfactory.eu/plugins/post-views-counter/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=blog-about' ) . '<br />' .
|
193 |
+
sprintf( __( 'Check out our other <a href="%s" target="_blank">WordPress plugins</a>.', 'post-views-counter' ), 'https://dfactory.eu/plugins/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=other-plugins' ) . '
|
194 |
+
</p>
|
195 |
+
<hr />
|
196 |
+
<p class="df-link inner"><a href="http://www.dfactory.eu/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=created-by" target="_blank" title="Digital Factory"><img src="//pvc-53eb.kxcdn.com/df-black-sm.png' . '" alt="Digital Factory" /></a></p>
|
197 |
+
</div>
|
198 |
+
</div>
|
199 |
+
<form action="options.php" method="post">';
|
200 |
+
|
201 |
+
wp_nonce_field( 'update-options' );
|
202 |
+
settings_fields( $this->tabs[$tab_key]['key'] );
|
203 |
+
do_settings_sections( $this->tabs[$tab_key]['key'] );
|
204 |
+
|
205 |
+
echo '
|
206 |
+
<p class="submit">';
|
207 |
+
|
208 |
+
submit_button( '', 'primary', $this->tabs[$tab_key]['submit'], false );
|
209 |
+
|
210 |
+
echo ' ';
|
211 |
+
|
212 |
+
submit_button( __( 'Reset to defaults', 'post-views-counter' ), 'secondary reset_pvc_settings', $this->tabs[$tab_key]['reset'], false );
|
213 |
+
|
214 |
+
echo '
|
215 |
+
</p>
|
216 |
+
</form>
|
217 |
+
</div>
|
218 |
+
<div class="clear"></div>
|
219 |
+
</div>';
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Register settings callback.
|
224 |
+
*/
|
225 |
+
public function register_settings() {
|
226 |
+
// general options
|
227 |
+
register_setting( 'post_views_counter_settings_general', 'post_views_counter_settings_general', array( $this, 'validate_settings' ) );
|
228 |
+
add_settings_section( 'post_views_counter_settings_general', __( 'General settings', 'post-views-counter' ), '', 'post_views_counter_settings_general' );
|
229 |
+
add_settings_field( 'pvc_post_types_count', __( 'Post Types Count', 'post-views-counter' ), array( $this, 'post_types_count' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
230 |
+
add_settings_field( 'pvc_counter_mode', __( 'Counter Mode', 'post-views-counter' ), array( $this, 'counter_mode' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
231 |
+
add_settings_field( 'pvc_post_views_column', __( 'Post Views Column', 'post-views-counter' ), array( $this, 'post_views_column' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
232 |
+
add_settings_field( 'pvc_restrict_edit_views', __( 'Restrict Edit', 'post-views-counter' ), array( $this, 'restrict_edit_views' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
233 |
+
add_settings_field( 'pvc_time_between_counts', __( 'Count Interval', 'post-views-counter' ), array( $this, 'time_between_counts' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
234 |
+
add_settings_field( 'pvc_reset_counts', __( 'Reset Data Interval', 'post-views-counter' ), array( $this, 'reset_counts' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
235 |
+
add_settings_field( 'pvc_flush_interval', __( 'Flush Object Cache Interval', 'post-views-counter' ), array( $this, 'flush_interval' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
236 |
+
add_settings_field( 'pvc_exclude', __( 'Exclude Visitors', 'post-views-counter' ), array( $this, 'exclude' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
237 |
+
add_settings_field( 'pvc_exclude_ips', __( 'Exclude IPs', 'post-views-counter' ), array( $this, 'exclude_ips' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
238 |
+
add_settings_field( 'pvc_strict_counts', __( 'Strict counts', 'post-views-counter' ), array( $this, 'strict_counts' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
239 |
+
add_settings_field( 'pvc_wp_postviews', __( 'Tools', 'post-views-counter' ), array( $this, 'wp_postviews' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
240 |
+
add_settings_field( 'pvc_deactivation_delete', __( 'Deactivation', 'post-views-counter' ), array( $this, 'deactivation_delete' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
|
241 |
+
|
242 |
+
// display options
|
243 |
+
register_setting( 'post_views_counter_settings_display', 'post_views_counter_settings_display', array( $this, 'validate_settings' ) );
|
244 |
+
add_settings_section( 'post_views_counter_settings_display', __( 'Display settings', 'post-views-counter' ), '', 'post_views_counter_settings_display' );
|
245 |
+
add_settings_field( 'pvc_post_views_label', __( 'Post Views Label', 'post-views-counter' ), array( $this, 'post_views_label' ), 'post_views_counter_settings_display', 'post_views_counter_settings_display' );
|
246 |
+
add_settings_field( 'pvc_post_types_display', __( 'Post Type', 'post-views-counter' ), array( $this, 'post_types_display' ), 'post_views_counter_settings_display', 'post_views_counter_settings_display' );
|
247 |
+
add_settings_field( 'pvc_page_types_display', __( 'Page Type', 'post-views-counter' ), array( $this, 'page_types_display' ), 'post_views_counter_settings_display', 'post_views_counter_settings_display' );
|
248 |
+
add_settings_field( 'pvc_restrict_display', __( 'User Type', 'post-views-counter' ), array( $this, 'restrict_display' ), 'post_views_counter_settings_display', 'post_views_counter_settings_display' );
|
249 |
+
add_settings_field( 'pvc_position', __( 'Position', 'post-views-counter' ), array( $this, 'position' ), 'post_views_counter_settings_display', 'post_views_counter_settings_display' );
|
250 |
+
add_settings_field( 'pvc_display_style', __( 'Display Style', 'post-views-counter' ), array( $this, 'display_style' ), 'post_views_counter_settings_display', 'post_views_counter_settings_display' );
|
251 |
+
add_settings_field( 'pvc_icon_class', __( 'Icon Class', 'post-views-counter' ), array( $this, 'icon_class' ), 'post_views_counter_settings_display', 'post_views_counter_settings_display' );
|
252 |
+
add_settings_field( 'pvc_toolbar_statistics', __( 'Toolbar Chart', 'post-views-counter' ), array( $this, 'toolbar_statistics' ), 'post_views_counter_settings_display', 'post_views_counter_settings_display' );
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Post views label option.
|
257 |
+
*/
|
258 |
+
public function post_views_label() {
|
259 |
+
echo '
|
260 |
+
<div id="pvc_post_views_label">
|
261 |
+
<fieldset>
|
262 |
+
<input type="text" class="large-text" name="post_views_counter_settings_display[label]" value="' . esc_attr( Post_Views_Counter()->options['display']['label'] ) . '" />
|
263 |
+
<p class="description">' . __( 'Enter the label for the post views counter field.', 'post-views-counter' ) . '</p>
|
264 |
+
</fieldset>
|
265 |
+
</div>';
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Post types to count option.
|
270 |
+
*/
|
271 |
+
public function post_types_count() {
|
272 |
+
echo '
|
273 |
+
<div id="pvc_post_types_count">';
|
274 |
+
|
275 |
+
foreach ( $this->post_types as $post_type => $post_type_name ) {
|
276 |
+
echo '
|
277 |
+
<label><input id="pvc_post_types_count-' . esc_attr( $post_type ) . '" type="checkbox" name="post_views_counter_settings_general[post_types_count][' . esc_attr( $post_type ) . ']" value="1" ' . checked( in_array( $post_type, Post_Views_Counter()->options['general']['post_types_count'], true ), true, false ) . ' />' . esc_html( $post_type_name ) . ' </label>';
|
278 |
+
}
|
279 |
+
|
280 |
+
echo '
|
281 |
+
<p class="description">' . __( 'Select post types for which post views will be counted.', 'post-views-counter' ) . '</p>
|
282 |
+
</div>';
|
283 |
+
}
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Post types to display option.
|
287 |
+
*/
|
288 |
+
public function post_types_display() {
|
289 |
+
echo '
|
290 |
+
<div id="pvc_post_types_display">';
|
291 |
+
|
292 |
+
foreach ( $this->post_types as $post_type => $post_type_name ) {
|
293 |
+
echo '
|
294 |
+
<label><input id="pvc_post_types_display-' . esc_attr( $post_type ) . '" type="checkbox" name="post_views_counter_settings_display[post_types_display][' . esc_attr( $post_type ) . ']" value="1" ' . checked( in_array( $post_type, Post_Views_Counter()->options['display']['post_types_display'], true ), true, false ) . ' />' . esc_html( $post_type_name ) . '</label>';
|
295 |
+
}
|
296 |
+
|
297 |
+
echo '
|
298 |
+
<p class="description">' . __( 'Select post types for which the views count will be displayed.', 'post-views-counter' ) . '</p>
|
299 |
+
</div>';
|
300 |
+
}
|
301 |
+
|
302 |
+
/**
|
303 |
+
* Counter mode option.
|
304 |
+
*/
|
305 |
+
public function counter_mode() {
|
306 |
+
echo '
|
307 |
+
<div id="pvc_counter_mode">';
|
308 |
+
|
309 |
+
foreach ( $this->modes as $key => $value ) {
|
310 |
+
$key = esc_attr( $key );
|
311 |
+
|
312 |
+
echo '
|
313 |
+
<label><input type="radio" name="post_views_counter_settings_general[counter_mode]" value="' . $key . '" ' . checked( $key, Post_Views_Counter()->options['general']['counter_mode'], false ) . ' />' . esc_html( $value ) . '</label>';
|
314 |
+
}
|
315 |
+
|
316 |
+
echo '
|
317 |
+
<p class="description">' . __( 'Select the method of collecting post views data. If you are using any of the caching plugins select Javascript or REST API (if available).', 'post-views-counter' ) . '<br />' . __( 'Optionally try the Fast AJAX experimental method, usually 10+ times faster than Javascript or REST API.', 'post-views-counter' ) . '</p>
|
318 |
+
</div>';
|
319 |
+
}
|
320 |
+
|
321 |
+
/**
|
322 |
+
* Post views column option.
|
323 |
+
*/
|
324 |
+
public function post_views_column() {
|
325 |
+
echo '
|
326 |
+
<div id="pvc_post_views_column">
|
327 |
+
<label><input id="pvc-post-views-column-enable" type="checkbox" name="post_views_counter_settings_general[post_views_column]" value="1" ' . checked( true, Post_Views_Counter()->options['general']['post_views_column'], false ) . ' />' . __( 'Enable to display post views count column for each of the selected post types.', 'post-views-counter' ) . '</label>
|
328 |
+
</div>';
|
329 |
+
}
|
330 |
+
|
331 |
+
/**
|
332 |
+
* Time between counts option.
|
333 |
+
*/
|
334 |
+
public function time_between_counts() {
|
335 |
+
echo '
|
336 |
+
<div id="pvc_time_between_counts">
|
337 |
+
<input size="4" type="text" name="post_views_counter_settings_general[time_between_counts][number]" value="' . esc_attr( Post_Views_Counter()->options['general']['time_between_counts']['number'] ) . '" />
|
338 |
+
<select class="pvc-chosen-short" name="post_views_counter_settings_general[time_between_counts][type]">';
|
339 |
+
|
340 |
+
foreach ( $this->time_types as $type => $type_name ) {
|
341 |
+
echo '
|
342 |
+
<option value="' . esc_attr( $type ) . '" ' . selected( $type, Post_Views_Counter()->options['general']['time_between_counts']['type'], false ) . '>' . esc_html( $type_name ) . '</option>';
|
343 |
+
}
|
344 |
+
|
345 |
+
echo '
|
346 |
+
</select>
|
347 |
+
<p class="description">' . __( 'Enter the time between single user visit count.', 'post-views-counter' ) . '</p>
|
348 |
+
</div>';
|
349 |
+
}
|
350 |
+
|
351 |
+
/**
|
352 |
+
* Reset counts option.
|
353 |
+
*/
|
354 |
+
public function reset_counts() {
|
355 |
+
echo '
|
356 |
+
<div id="pvc_reset_counts">
|
357 |
+
<input size="4" type="text" name="post_views_counter_settings_general[reset_counts][number]" value="' . esc_attr( Post_Views_Counter()->options['general']['reset_counts']['number'] ) . '" />
|
358 |
+
<select class="pvc-chosen-short" name="post_views_counter_settings_general[reset_counts][type]">';
|
359 |
+
|
360 |
+
foreach ( array_slice( $this->time_types, 2, null, true ) as $type => $type_name ) {
|
361 |
+
echo '
|
362 |
+
<option value="' . esc_attr( $type ) . '" ' . selected( $type, Post_Views_Counter()->options['general']['reset_counts']['type'], false ) . '>' . esc_html( $type_name ) . '</option>';
|
363 |
+
}
|
364 |
+
|
365 |
+
echo '
|
366 |
+
</select>
|
367 |
+
<p class="description">' . __( 'Delete single day post views data older than specified above. Enter 0 (number zero) if you want to preserve your data regardless of its age.', 'post-views-counter' ) . '</p>
|
368 |
+
</div>';
|
369 |
+
}
|
370 |
+
|
371 |
+
/**
|
372 |
+
* Flush interval option.
|
373 |
+
*/
|
374 |
+
public function flush_interval() {
|
375 |
+
echo '
|
376 |
+
<div id="pvc_flush_interval">
|
377 |
+
<input size="4" type="text" name="post_views_counter_settings_general[flush_interval][number]" value="' . esc_attr( Post_Views_Counter()->options['general']['flush_interval']['number'] ) . '" />
|
378 |
+
<select class="pvc-chosen-short" name="post_views_counter_settings_general[flush_interval][type]">';
|
379 |
+
|
380 |
+
foreach ( $this->time_types as $type => $type_name ) {
|
381 |
+
echo '
|
382 |
+
<option value="' . esc_attr( $type ) . '" ' . selected( $type, Post_Views_Counter()->options['general']['flush_interval']['type'], false ) . '>' . esc_html( $type_name ) . '</option>';
|
383 |
+
}
|
384 |
+
|
385 |
+
echo '
|
386 |
+
</select>
|
387 |
+
<p class="description">' . __( 'How often to flush cached view counts from the object cache into the database. This feature is used only if a persistent object cache is detected and the interval is greater than 0 (number zero). When used, view counts will be collected and stored in the object cache instead of the database and will then be asynchronously flushed to the database according to the specified interval.<br /><strong>Notice:</strong> Potential data loss may occur if the object cache is cleared/unavailable for the duration of the interval.', 'post-views-counter' ) . '</p>
|
388 |
+
</div>';
|
389 |
+
}
|
390 |
+
|
391 |
+
/**
|
392 |
+
* Exlude user groups option.
|
393 |
+
*/
|
394 |
+
public function exclude() {
|
395 |
+
echo '
|
396 |
+
<div id="pvc_exclude">
|
397 |
+
<fieldset>';
|
398 |
+
|
399 |
+
foreach ( $this->groups as $type => $type_name ) {
|
400 |
+
echo '
|
401 |
+
<label><input id="pvc_exclude-' . $type . '" type="checkbox" name="post_views_counter_settings_general[exclude][groups][' . $type . ']" value="1" ' . checked( in_array( $type, Post_Views_Counter()->options['general']['exclude']['groups'], true ), true, false ) . ' />' . esc_html( $type_name ) . '</label>';
|
402 |
+
}
|
403 |
+
|
404 |
+
echo '
|
405 |
+
<p class="description">' . __( 'Use it to hide the post views counter from selected type of visitors.', 'post-views-counter' ) . '</p>
|
406 |
+
<div class="pvc_user_roles"' . (in_array( 'roles', Post_Views_Counter()->options['general']['exclude']['groups'], true ) ? '' : ' style="display: none;"') . '>';
|
407 |
+
|
408 |
+
foreach ( $this->user_roles as $role => $role_name ) {
|
409 |
+
echo '
|
410 |
+
<label><input type="checkbox" name="post_views_counter_settings_general[exclude][roles][' . $role . ']" value="1" ' . checked( in_array( $role, Post_Views_Counter()->options['general']['exclude']['roles'], true ), true, false ) . '>' . esc_html( $role_name ) . '</label>';
|
411 |
+
}
|
412 |
+
|
413 |
+
echo '
|
414 |
+
<p class="description">' . __( 'Use it to hide the post views counter from selected user roles.', 'post-views-counter' ) . '</p>
|
415 |
+
</div>
|
416 |
+
</fieldset>
|
417 |
+
</div>';
|
418 |
+
}
|
419 |
+
|
420 |
+
/**
|
421 |
+
* Exclude IPs option.
|
422 |
+
*/
|
423 |
+
public function exclude_ips() {
|
424 |
+
// lovely php 5.2 limitations
|
425 |
+
$ips = Post_Views_Counter()->options['general']['exclude_ips'];
|
426 |
+
|
427 |
+
echo '
|
428 |
+
<div id="pvc_exclude_ips">';
|
429 |
+
|
430 |
+
if ( ! empty( $ips ) ) {
|
431 |
+
foreach ( $ips as $key => $ip ) {
|
432 |
+
echo '
|
433 |
+
<div class="ip-box">
|
434 |
+
<input type="text" name="post_views_counter_settings_general[exclude_ips][]" value="' . esc_attr( $ip ) . '" /> <a href="#" class="remove-exclude-ip" title="' . esc_attr__( 'Remove', 'post-views-counter' ) . '">' . esc_attr__( 'Remove', 'post-views-counter' ) . '</a>
|
435 |
+
</div>';
|
436 |
+
}
|
437 |
+
} else {
|
438 |
+
echo '
|
439 |
+
<div class="ip-box">
|
440 |
+
<input type="text" name="post_views_counter_settings_general[exclude_ips][]" value="" /> <a href="#" class="remove-exclude-ip" title="' . esc_attr__( 'Remove', 'post-views-counter' ) . '">' . esc_attr__( 'Remove', 'post-views-counter' ) . '</a>
|
441 |
+
</div>';
|
442 |
+
}
|
443 |
+
|
444 |
+
echo '
|
445 |
+
<p><input type="button" class="button button-secondary add-exclude-ip" value="' . esc_attr__( 'Add new', 'post-views-counter' ) . '" /> <input type="button" class="button button-secondary add-current-ip" value="' . esc_attr__( 'Add my current IP', 'post-views-counter' ) . '" data-rel="' . esc_attr( $_SERVER['REMOTE_ADDR'] ) . '" /></p>
|
446 |
+
<p class="description">' . __( 'Enter the IP addresses to be excluded from post views count.', 'post-views-counter' ) . '</p>
|
447 |
+
</div>';
|
448 |
+
}
|
449 |
+
|
450 |
+
/**
|
451 |
+
* Strict counts option.
|
452 |
+
*/
|
453 |
+
public function strict_counts() {
|
454 |
+
echo '
|
455 |
+
<div id="pvc_strict_counts">
|
456 |
+
<label><input id="pvc-strict-counts" type="checkbox" name="post_views_counter_settings_general[strict_counts]" value="1" ' . checked( true, Post_Views_Counter()->options['general']['strict_counts'], false ) . ' />' . __( 'Enable to prevent bypassing the counts interval (for e.g. using incognito browser window or by clearing cookies).', 'post-views-counter' ) . '</label>
|
457 |
+
</div>';
|
458 |
+
}
|
459 |
+
|
460 |
+
/**
|
461 |
+
* WP-PostViews import option.
|
462 |
+
*/
|
463 |
+
public function wp_postviews() {
|
464 |
+
echo '
|
465 |
+
<div id="pvc_wp_postviews">
|
466 |
+
<fieldset>
|
467 |
+
<input type="submit" class="button button-secondary" name="post_views_counter_import_wp_postviews" value="' . __( 'Import views', 'post-views-counter' ) . '"/> <label><input id="pvc-wp-postviews" type="checkbox" name="post_views_counter_import_wp_postviews_override" value="1" />' . __( 'Override existing views data.', 'post-views-counter' ) . '</label>
|
468 |
+
<p class="description">' . __( 'Import post views data from WP-PostViews plugin.', 'post-views-counter' ) . '</p>
|
469 |
+
<br /><input type="submit" class="button button-secondary" name="post_views_counter_reset_views" value="' . __( 'Delete views', 'post-views-counter' ) . '"/>
|
470 |
+
<p class="description">' . __( 'Delete ALL the existing post views data.', 'post-views-counter' ) . '</p>
|
471 |
+
</fieldset>
|
472 |
+
</div>';
|
473 |
+
}
|
474 |
+
|
475 |
+
/**
|
476 |
+
* Limit views edit to admins.
|
477 |
+
*/
|
478 |
+
public function restrict_edit_views() {
|
479 |
+
echo '
|
480 |
+
<div id="pvc_restrict_edit_views">
|
481 |
+
<label><input type="checkbox" name="post_views_counter_settings_general[restrict_edit_views]" value="1" ' . checked( true, Post_Views_Counter()->options['general']['restrict_edit_views'], false ) . ' />' . __( 'Enable to restrict post views editing to admins only.', 'post-views-counter' ) . '</label>
|
482 |
+
</div>';
|
483 |
+
}
|
484 |
+
|
485 |
+
/**
|
486 |
+
* Plugin deactivation option.
|
487 |
+
*/
|
488 |
+
public function deactivation_delete() {
|
489 |
+
echo '
|
490 |
+
<div id="pvc_deactivation_delete">
|
491 |
+
<label><input type="checkbox" name="post_views_counter_settings_general[deactivation_delete]" value="1" ' . checked( true, Post_Views_Counter()->options['general']['deactivation_delete'], false ) . ' />' . __( 'Enable to delete all plugin data on deactivation.', 'post-views-counter' ) . '</label>
|
492 |
+
</div>';
|
493 |
+
}
|
494 |
+
|
495 |
+
/**
|
496 |
+
* Visibility option.
|
497 |
+
*/
|
498 |
+
public function page_types_display() {
|
499 |
+
echo '
|
500 |
+
<div id="pvc_post_types_display">';
|
501 |
+
|
502 |
+
foreach ( $this->page_types as $key => $label ) {
|
503 |
+
echo '
|
504 |
+
<label><input id="pvc_page_types_display-' . esc_attr( $key ) . '" type="checkbox" name="post_views_counter_settings_display[page_types_display][' . esc_attr( $key ) . ']" value="1" ' . checked( in_array( $key, Post_Views_Counter()->options['display']['page_types_display'], true ), true, false ) . ' />' . esc_html( $label ) . '</label>';
|
505 |
+
}
|
506 |
+
|
507 |
+
echo '
|
508 |
+
<p class="description">' . __( 'Select page types where the views count will be displayed.', 'post-views-counter' ) . '</p>
|
509 |
+
</div>';
|
510 |
+
}
|
511 |
+
|
512 |
+
/**
|
513 |
+
* Counter position option.
|
514 |
+
*/
|
515 |
+
public function position() {
|
516 |
+
echo '
|
517 |
+
<div id="pvc_position">
|
518 |
+
<select class="pvc-chosen-short" name="post_views_counter_settings_display[position]">';
|
519 |
+
|
520 |
+
foreach ( $this->positions as $position => $position_name ) {
|
521 |
+
echo '
|
522 |
+
<option value="' . esc_attr( $position ) . '" ' . selected( $position, Post_Views_Counter()->options['display']['position'], false ) . '>' . esc_html( $position_name ) . '</option>';
|
523 |
+
}
|
524 |
+
|
525 |
+
echo '
|
526 |
+
</select>
|
527 |
+
<p class="description">' . __( 'Select where would you like to display the post views counter. Use [post-views] shortcode for manual display.', 'post-views-counter' ) . '</p>
|
528 |
+
</div>';
|
529 |
+
}
|
530 |
+
|
531 |
+
/**
|
532 |
+
* Counter style option.
|
533 |
+
*/
|
534 |
+
public function display_style() {
|
535 |
+
echo '
|
536 |
+
<div id="pvc_display_style">';
|
537 |
+
|
538 |
+
foreach ( $this->display_styles as $display => $style ) {
|
539 |
+
$display = esc_attr( $display );
|
540 |
+
|
541 |
+
echo '
|
542 |
+
<label><input type="checkbox" name="post_views_counter_settings_display[display_style][' . $display . ']" value="1" ' . checked( true, Post_Views_Counter()->options['display']['display_style'][$display], false ) . ' />' . esc_html( $style ) . '</label>';
|
543 |
+
}
|
544 |
+
|
545 |
+
echo '
|
546 |
+
<p class="description">' . __( 'Choose how to display the post views counter.', 'post-views-counter' ) . '</p>
|
547 |
+
</div>';
|
548 |
+
}
|
549 |
+
|
550 |
+
/**
|
551 |
+
* Counter icon class option.
|
552 |
+
*/
|
553 |
+
public function icon_class() {
|
554 |
+
echo '
|
555 |
+
<div id="pvc_icon_class">
|
556 |
+
<input type="text" name="post_views_counter_settings_display[icon_class]" class="large-text" value="' . esc_attr( Post_Views_Counter()->options['display']['icon_class'] ) . '" />
|
557 |
+
<p class="description">' . sprintf( __( 'Enter the post views icon class. Any of the <a href="%s" target="_blank">Dashicons</a> classes are available.', 'post-views-counter' ), 'https://developer.wordpress.org/resource/dashicons/' ) . '</p>
|
558 |
+
</div>';
|
559 |
+
}
|
560 |
+
|
561 |
+
/**
|
562 |
+
* Toolbar statistics.
|
563 |
+
*/
|
564 |
+
public function toolbar_statistics() {
|
565 |
+
echo '
|
566 |
+
<div id="pvc_toolbar_statistics">
|
567 |
+
<label><input type="checkbox" name="post_views_counter_settings_display[toolbar_statistics]" value="1" ' . checked( true, Post_Views_Counter()->options['display']['toolbar_statistics'], false ) . ' />' . __( 'Enable to display the post views chart at the toolbar.', 'post-views-counter' ) . '</label>
|
568 |
+
<p class="description">' . __( 'The post views chart will be displayed for the post types that are being counted.', 'post-views-counter' ) . '</p>
|
569 |
+
</div>';
|
570 |
+
}
|
571 |
+
|
572 |
+
/**
|
573 |
+
* Restrict display option.
|
574 |
+
*/
|
575 |
+
public function restrict_display() {
|
576 |
+
echo '
|
577 |
+
<div id="pvc_restrict_display">
|
578 |
+
<fieldset>';
|
579 |
+
|
580 |
+
foreach ( $this->groups as $type => $type_name ) {
|
581 |
+
|
582 |
+
if ( $type === 'robots' )
|
583 |
+
continue;
|
584 |
+
|
585 |
+
echo '
|
586 |
+
<label><input id="pvc_restrict_display-' . $type . '" type="checkbox" name="post_views_counter_settings_display[restrict_display][groups][' . esc_html( $type ) . ']" value="1" ' . checked( in_array( $type, Post_Views_Counter()->options['display']['restrict_display']['groups'], true ), true, false ) . ' />' . esc_html( $type_name ) . '</label>';
|
587 |
+
}
|
588 |
+
|
589 |
+
echo '
|
590 |
+
<p class="description">' . __( 'Use it to hide the post views counter from selected type of visitors.', 'post-views-counter' ) . '</p>
|
591 |
+
<div class="pvc_user_roles"' . (in_array( 'roles', Post_Views_Counter()->options['display']['restrict_display']['groups'], true ) ? '' : ' style="display: none;"') . '>';
|
592 |
+
|
593 |
+
foreach ( $this->user_roles as $role => $role_name ) {
|
594 |
+
echo '
|
595 |
+
<label><input type="checkbox" name="post_views_counter_settings_display[restrict_display][roles][' . $role . ']" value="1" ' . checked( in_array( $role, Post_Views_Counter()->options['display']['restrict_display']['roles'], true ), true, false ) . ' />' . esc_html( $role_name ) . '</label>';
|
596 |
+
}
|
597 |
+
|
598 |
+
echo '
|
599 |
+
<p class="description">' . __( 'Use it to hide the post views counter from selected user roles.', 'post-views-counter' ) . '</p>
|
600 |
+
</div>
|
601 |
+
</fieldset>
|
602 |
+
</div>';
|
603 |
+
}
|
604 |
+
|
605 |
+
/**
|
606 |
+
* Validate general settings.
|
607 |
+
*/
|
608 |
+
public function validate_settings( $input ) {
|
609 |
+
// get main instance
|
610 |
+
$pvc = Post_Views_Counter();
|
611 |
+
|
612 |
+
// import post views data from another plugin
|
613 |
+
if ( isset( $_POST['post_views_counter_import_wp_postviews'] ) ) {
|
614 |
+
// make sure we do not change anything in the settings
|
615 |
+
$input = $pvc->options['general'];
|
616 |
+
|
617 |
+
global $wpdb;
|
618 |
+
|
619 |
+
$meta_key = esc_attr( apply_filters( 'pvc_import_meta_key', 'views' ) );
|
620 |
+
|
621 |
+
$views = $wpdb->get_results( "SELECT post_id, meta_value FROM " . $wpdb->postmeta . " WHERE meta_key = '" . $meta_key . "'", ARRAY_A, 0 );
|
622 |
+
|
623 |
+
if ( ! empty( $views ) ) {
|
624 |
+
$sql = array();
|
625 |
+
|
626 |
+
foreach ( $views as $view ) {
|
627 |
+
$sql[] = "(" . $view['post_id'] . ", 4, 'total', " . $view['meta_value'] . ")";
|
628 |
+
}
|
629 |
+
|
630 |
+
$wpdb->query( "INSERT INTO " . $wpdb->prefix . "post_views(id, type, period, count) VALUES " . implode( ',', $sql ) . " ON DUPLICATE KEY UPDATE count = " . ( isset( $_POST['post_views_counter_import_wp_postviews_override'] ) ? '' : 'count + ' ) . "VALUES(count)" );
|
631 |
+
|
632 |
+
add_settings_error( 'wp_postviews_import', 'wp_postviews_import', __( 'Post views data imported succesfully.', 'post-views-counter' ), 'updated' );
|
633 |
+
} else {
|
634 |
+
add_settings_error( 'wp_postviews_import', 'wp_postviews_import', __( 'There was no post views data to import.', 'post-views-counter' ), 'updated' );
|
635 |
+
}
|
636 |
+
// delete all post views data
|
637 |
+
} elseif ( isset( $_POST['post_views_counter_reset_views'] ) ) {
|
638 |
+
// make sure we do not change anything in the settings
|
639 |
+
$input = $pvc->options['general'];
|
640 |
+
|
641 |
+
global $wpdb;
|
642 |
+
|
643 |
+
if ( $wpdb->query( 'TRUNCATE TABLE ' . $wpdb->prefix . 'post_views' ) )
|
644 |
+
add_settings_error( 'reset_post_views', 'reset_post_views', __( 'All existing data deleted succesfully.', 'post-views-counter' ), 'updated' );
|
645 |
+
else
|
646 |
+
add_settings_error( 'reset_post_views', 'reset_post_views', __( 'Error occurred. All existing data were not deleted.', 'post-views-counter' ), 'error' );
|
647 |
+
// save general settings
|
648 |
+
} elseif ( isset( $_POST['save_pvc_general'] ) ) {
|
649 |
+
// post types count
|
650 |
+
if ( isset( $input['post_types_count'] ) ) {
|
651 |
+
$post_types = array();
|
652 |
+
|
653 |
+
foreach ( $input['post_types_count'] as $post_type => $set ) {
|
654 |
+
if ( isset( $this->post_types[$post_type] ) )
|
655 |
+
$post_types[] = $post_type;
|
656 |
+
}
|
657 |
+
|
658 |
+
$input['post_types_count'] = array_unique( $post_types );
|
659 |
+
} else
|
660 |
+
$input['post_types_count'] = array();
|
661 |
+
|
662 |
+
// counter mode
|
663 |
+
$input['counter_mode'] = isset( $input['counter_mode'], $this->modes[$input['counter_mode']] ) ? $input['counter_mode'] : $pvc->defaults['general']['counter_mode'];
|
664 |
+
|
665 |
+
// post views column
|
666 |
+
$input['post_views_column'] = isset( $input['post_views_column'] );
|
667 |
+
|
668 |
+
// time between counts
|
669 |
+
$input['time_between_counts']['number'] = (int) ( isset( $input['time_between_counts']['number'] ) ? $input['time_between_counts']['number'] : $pvc->defaults['general']['time_between_counts']['number'] );
|
670 |
+
$input['time_between_counts']['type'] = isset( $input['time_between_counts']['type'], $this->time_types[$input['time_between_counts']['type']] ) ? $input['time_between_counts']['type'] : $pvc->defaults['general']['time_between_counts']['type'];
|
671 |
+
|
672 |
+
// flush interval
|
673 |
+
$input['flush_interval']['number'] = (int) ( isset( $input['flush_interval']['number'] ) ? $input['flush_interval']['number'] : $pvc->defaults['general']['flush_interval']['number'] );
|
674 |
+
$input['flush_interval']['type'] = isset( $input['flush_interval']['type'], $this->time_types[$input['flush_interval']['type']] ) ? $input['flush_interval']['type'] : $pvc->defaults['general']['flush_interval']['type'];
|
675 |
+
|
676 |
+
// Since the settings are about to be saved and cache flush interval could've changed,
|
677 |
+
// we want to make sure that any changes done on the settings page are in effect immediately
|
678 |
+
// (instead of having to wait for the previous schedule to occur).
|
679 |
+
// We achieve that by making sure to clear any previous cache flush schedules and
|
680 |
+
// schedule the new one if the specified interval is > 0
|
681 |
+
$pvc->remove_cache_flush();
|
682 |
+
|
683 |
+
if ( $input['flush_interval']['number'] > 0 )
|
684 |
+
$pvc->schedule_cache_flush();
|
685 |
+
|
686 |
+
// reset counts
|
687 |
+
$input['reset_counts']['number'] = (int) ( isset( $input['reset_counts']['number'] ) ? $input['reset_counts']['number'] : $pvc->defaults['general']['reset_counts']['number'] );
|
688 |
+
$input['reset_counts']['type'] = isset( $input['reset_counts']['type'], $this->time_types[$input['reset_counts']['type']] ) ? $input['reset_counts']['type'] : $pvc->defaults['general']['reset_counts']['type'];
|
689 |
+
|
690 |
+
// run cron on next visit?
|
691 |
+
$input['cron_run'] = ( $input['reset_counts']['number'] > 0 );
|
692 |
+
$input['cron_update'] = ( $input['cron_run'] && ( $pvc->options['general']['reset_counts']['number'] !== $input['reset_counts']['number'] || $pvc->options['general']['reset_counts']['type'] !== $input['reset_counts']['type'] ) );
|
693 |
+
|
694 |
+
// exclude
|
695 |
+
if ( isset( $input['exclude']['groups'] ) ) {
|
696 |
+
$groups = array();
|
697 |
+
|
698 |
+
foreach ( $input['exclude']['groups'] as $group => $set ) {
|
699 |
+
if ( isset( $this->groups[$group] ) )
|
700 |
+
$groups[] = $group;
|
701 |
+
}
|
702 |
+
|
703 |
+
$input['exclude']['groups'] = array_unique( $groups );
|
704 |
+
} else {
|
705 |
+
$input['exclude']['groups'] = array();
|
706 |
+
}
|
707 |
+
|
708 |
+
if ( in_array( 'roles', $input['exclude']['groups'], true ) && isset( $input['exclude']['roles'] ) ) {
|
709 |
+
$roles = array();
|
710 |
+
|
711 |
+
foreach ( $input['exclude']['roles'] as $role => $set ) {
|
712 |
+
if ( isset( $this->user_roles[$role] ) )
|
713 |
+
$roles[] = $role;
|
714 |
+
}
|
715 |
+
|
716 |
+
$input['exclude']['roles'] = array_unique( $roles );
|
717 |
+
} else
|
718 |
+
$input['exclude']['roles'] = array();
|
719 |
+
|
720 |
+
// exclude ips
|
721 |
+
if ( isset( $input['exclude_ips'] ) ) {
|
722 |
+
$ips = array();
|
723 |
+
|
724 |
+
foreach ( $input['exclude_ips'] as $ip ) {
|
725 |
+
if ( strpos( $ip, '*' ) !== false ) {
|
726 |
+
$new_ip = str_replace( '*', '0', $ip );
|
727 |
+
|
728 |
+
if ( filter_var( $new_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) )
|
729 |
+
$ips[] = $ip;
|
730 |
+
} elseif ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) )
|
731 |
+
$ips[] = $ip;
|
732 |
+
}
|
733 |
+
|
734 |
+
$input['exclude_ips'] = array_unique( $ips );
|
735 |
+
}
|
736 |
+
|
737 |
+
// restrict edit views
|
738 |
+
$input['restrict_edit_views'] = isset( $input['restrict_edit_views'] );
|
739 |
+
|
740 |
+
// strict counts
|
741 |
+
$input['strict_counts'] = isset( $input['strict_counts'] );
|
742 |
+
|
743 |
+
// deactivation delete
|
744 |
+
$input['deactivation_delete'] = isset( $input['deactivation_delete'] );
|
745 |
+
|
746 |
+
$input['update_version'] = $pvc->options['general']['update_version'];
|
747 |
+
$input['update_notice'] = $pvc->options['general']['update_notice'];
|
748 |
+
// save display settings
|
749 |
+
} elseif ( isset( $_POST['save_pvc_display'] ) ) {
|
750 |
+
|
751 |
+
// post views label
|
752 |
+
$input['label'] = isset( $input['label'] ) ? $input['label'] : $pvc->defaults['display']['label'];
|
753 |
+
|
754 |
+
if ( function_exists( 'icl_register_string' ) )
|
755 |
+
icl_register_string( 'Post Views Counter', 'Post Views Label', $input['label'] );
|
756 |
+
|
757 |
+
// position
|
758 |
+
$input['position'] = isset( $input['position'], $this->positions[$input['position']] ) ? $input['position'] : $pvc->defaults['display']['position'];
|
759 |
+
|
760 |
+
// display style
|
761 |
+
$input['display_style']['icon'] = isset( $input['display_style']['icon'] );
|
762 |
+
$input['display_style']['text'] = isset( $input['display_style']['text'] );
|
763 |
+
|
764 |
+
// link to post
|
765 |
+
$input['link_to_post'] = isset( $input['link_to_post'] ) ? $input['link_to_post'] : $pvc->defaults['display']['link_to_post'];
|
766 |
+
|
767 |
+
// icon class
|
768 |
+
$input['icon_class'] = isset( $input['icon_class'] ) ? trim( $input['icon_class'] ) : $pvc->defaults['display']['icon_class'];
|
769 |
+
|
770 |
+
$input['toolbar_statistics'] = isset( $input['toolbar_statistics'] ) ? trim( $input['toolbar_statistics'] ) : $pvc->defaults['display']['toolbar_statistics'];
|
771 |
+
|
772 |
+
// post types display
|
773 |
+
if ( isset( $input['post_types_display'] ) ) {
|
774 |
+
$post_types = array();
|
775 |
+
|
776 |
+
foreach ( $input['post_types_display'] as $post_type => $set ) {
|
777 |
+
if ( isset( $this->post_types[$post_type] ) )
|
778 |
+
$post_types[] = $post_type;
|
779 |
+
}
|
780 |
+
|
781 |
+
$input['post_types_display'] = array_unique( $post_types );
|
782 |
+
} else
|
783 |
+
$input['post_types_display'] = array();
|
784 |
+
|
785 |
+
// page types display
|
786 |
+
if ( isset( $input['page_types_display'] ) ) {
|
787 |
+
$page_types = array();
|
788 |
+
|
789 |
+
foreach ( $input['page_types_display'] as $page_type => $set ) {
|
790 |
+
if ( isset( $this->page_types[$page_type] ) )
|
791 |
+
$page_types[] = $page_type;
|
792 |
+
}
|
793 |
+
|
794 |
+
$input['page_types_display'] = array_unique( $page_types );
|
795 |
+
} else
|
796 |
+
$input['page_types_display'] = array();
|
797 |
+
|
798 |
+
// restrict display
|
799 |
+
if ( isset( $input['restrict_display']['groups'] ) ) {
|
800 |
+
$groups = array();
|
801 |
+
|
802 |
+
foreach ( $input['restrict_display']['groups'] as $group => $set ) {
|
803 |
+
if ( $group === 'robots' )
|
804 |
+
continue;
|
805 |
+
|
806 |
+
if ( isset( $this->groups[$group] ) )
|
807 |
+
$groups[] = $group;
|
808 |
+
}
|
809 |
+
|
810 |
+
$input['restrict_display']['groups'] = array_unique( $groups );
|
811 |
+
} else
|
812 |
+
$input['restrict_display']['groups'] = array();
|
813 |
+
|
814 |
+
if ( in_array( 'roles', $input['restrict_display']['groups'], true ) && isset( $input['restrict_display']['roles'] ) ) {
|
815 |
+
$roles = array();
|
816 |
+
|
817 |
+
foreach ( $input['restrict_display']['roles'] as $role => $set ) {
|
818 |
+
if ( isset( $this->user_roles[$role] ) )
|
819 |
+
$roles[] = $role;
|
820 |
+
}
|
821 |
+
|
822 |
+
$input['restrict_display']['roles'] = array_unique( $roles );
|
823 |
+
} else
|
824 |
+
$input['restrict_display']['roles'] = array();
|
825 |
+
// reset general settings
|
826 |
+
} elseif ( isset( $_POST['reset_pvc_general'] ) ) {
|
827 |
+
$input = $pvc->defaults['general'];
|
828 |
+
|
829 |
+
add_settings_error( 'reset_general_settings', 'settings_reset', __( 'General settings restored to defaults.', 'post-views-counter' ), 'updated' );
|
830 |
+
// reset display settings
|
831 |
+
} elseif ( isset( $_POST['reset_pvc_display'] ) ) {
|
832 |
+
$input = $pvc->defaults['display'];
|
833 |
+
|
834 |
+
add_settings_error( 'reset_general_settings', 'settings_reset', __( 'Display settings restored to defaults.', 'post-views-counter' ), 'updated' );
|
835 |
+
}
|
836 |
+
|
837 |
+
return $input;
|
838 |
+
}
|
839 |
}
|
languages/post-views-counter.pot
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
msgid ""
|
3 |
msgstr ""
|
4 |
"Project-Id-Version: Post Views Counter\n"
|
5 |
-
"POT-Creation-Date: 2021-
|
6 |
"PO-Revision-Date: 2015-04-08 18:59+0100\n"
|
7 |
"Last-Translator: Bartosz Arendt <info@dfactory.eu>\n"
|
8 |
"Language-Team: dFactory <info@dfactory.eu>\n"
|
@@ -21,9 +21,9 @@ msgstr ""
|
|
21 |
#: ../includes/columns.php:51 ../includes/columns.php:154
|
22 |
#: ../includes/columns.php:197 ../includes/columns.php:348
|
23 |
#: ../includes/columns.php:354 ../includes/columns.php:404
|
24 |
-
#: ../includes/dashboard.php:
|
25 |
-
#: ../includes/dashboard.php:
|
26 |
-
#: ../includes/dashboard.php:
|
27 |
msgid "Post Views"
|
28 |
msgstr ""
|
29 |
|
@@ -32,7 +32,7 @@ msgstr ""
|
|
32 |
msgid "You are not allowed to edit this item."
|
33 |
msgstr ""
|
34 |
|
35 |
-
#: ../includes/columns.php:114 ../includes/counter.php:
|
36 |
msgid "Invalid post ID."
|
37 |
msgstr ""
|
38 |
|
@@ -52,11 +52,11 @@ msgstr ""
|
|
52 |
msgid "OK"
|
53 |
msgstr ""
|
54 |
|
55 |
-
#: ../includes/counter.php:
|
56 |
msgid "REST API method is disabled."
|
57 |
msgstr ""
|
58 |
|
59 |
-
#: ../includes/counter.php:
|
60 |
msgid "Post type excluded."
|
61 |
msgstr ""
|
62 |
|
@@ -73,39 +73,39 @@ msgstr ""
|
|
73 |
msgid "Post Views Counter"
|
74 |
msgstr ""
|
75 |
|
76 |
-
#: ../includes/dashboard.php:
|
77 |
msgid ""
|
78 |
"Displays the chart of most viewed post types for a selected time period."
|
79 |
msgstr ""
|
80 |
|
81 |
-
#: ../includes/dashboard.php:
|
82 |
msgid "Top Posts"
|
83 |
msgstr ""
|
84 |
|
85 |
-
#: ../includes/dashboard.php:
|
86 |
msgid "Displays the list of most viewed posts and pages on your website."
|
87 |
msgstr ""
|
88 |
|
89 |
-
#: ../includes/dashboard.php:
|
90 |
-
#: ../includes/dashboard.php:
|
91 |
-
#: ../includes/dashboard.php:
|
92 |
msgid "You do not have permission to access this page."
|
93 |
msgstr ""
|
94 |
|
95 |
-
#: ../includes/dashboard.php:
|
96 |
-
msgid "
|
97 |
msgstr ""
|
98 |
|
99 |
-
#: ../includes/dashboard.php:
|
100 |
-
msgid "
|
101 |
msgstr ""
|
102 |
|
103 |
-
#: ../includes/dashboard.php:
|
104 |
-
msgid "
|
105 |
msgstr ""
|
106 |
|
107 |
-
#: ../includes/dashboard.php:
|
108 |
-
msgid "
|
109 |
msgstr ""
|
110 |
|
111 |
#: ../includes/functions.php:476
|
@@ -333,47 +333,51 @@ msgstr ""
|
|
333 |
msgid "Icon Class"
|
334 |
msgstr ""
|
335 |
|
336 |
-
#: ../includes/settings.php:
|
|
|
|
|
|
|
|
|
337 |
msgid "Enter the label for the post views counter field."
|
338 |
msgstr ""
|
339 |
|
340 |
-
#: ../includes/settings.php:
|
341 |
msgid "Select post types for which post views will be counted."
|
342 |
msgstr ""
|
343 |
|
344 |
-
#: ../includes/settings.php:
|
345 |
msgid "Select post types for which the views count will be displayed."
|
346 |
msgstr ""
|
347 |
|
348 |
-
#: ../includes/settings.php:
|
349 |
msgid ""
|
350 |
"Select the method of collecting post views data. If you are using any of the "
|
351 |
"caching plugins select Javascript or REST API (if available)."
|
352 |
msgstr ""
|
353 |
|
354 |
-
#: ../includes/settings.php:
|
355 |
msgid ""
|
356 |
"Optionally try the Fast AJAX experimental method, usually 10+ times faster "
|
357 |
"than Javascript or REST API."
|
358 |
msgstr ""
|
359 |
|
360 |
-
#: ../includes/settings.php:
|
361 |
msgid ""
|
362 |
"Enable to display post views count column for each of the selected post "
|
363 |
"types."
|
364 |
msgstr ""
|
365 |
|
366 |
-
#: ../includes/settings.php:
|
367 |
msgid "Enter the time between single user visit count."
|
368 |
msgstr ""
|
369 |
|
370 |
-
#: ../includes/settings.php:
|
371 |
msgid ""
|
372 |
"Delete single day post views data older than specified above. Enter 0 "
|
373 |
"(number zero) if you want to preserve your data regardless of its age."
|
374 |
msgstr ""
|
375 |
|
376 |
-
#: ../includes/settings.php:
|
377 |
msgid ""
|
378 |
"How often to flush cached view counts from the object cache into the "
|
379 |
"database. This feature is used only if a persistent object cache is detected "
|
@@ -385,106 +389,116 @@ msgid ""
|
|
385 |
"interval."
|
386 |
msgstr ""
|
387 |
|
388 |
-
#: ../includes/settings.php:
|
389 |
msgid "Use it to hide the post views counter from selected type of visitors."
|
390 |
msgstr ""
|
391 |
|
392 |
-
#: ../includes/settings.php:
|
393 |
msgid "Use it to hide the post views counter from selected user roles."
|
394 |
msgstr ""
|
395 |
|
396 |
-
#: ../includes/settings.php:
|
397 |
msgid "Remove"
|
398 |
msgstr ""
|
399 |
|
400 |
-
#: ../includes/settings.php:
|
401 |
msgid "Add new"
|
402 |
msgstr ""
|
403 |
|
404 |
-
#: ../includes/settings.php:
|
405 |
msgid "Add my current IP"
|
406 |
msgstr ""
|
407 |
|
408 |
-
#: ../includes/settings.php:
|
409 |
msgid "Enter the IP addresses to be excluded from post views count."
|
410 |
msgstr ""
|
411 |
|
412 |
-
#: ../includes/settings.php:
|
413 |
msgid ""
|
414 |
"Enable to prevent bypassing the counts interval (for e.g. using incognito "
|
415 |
"browser window or by clearing cookies)."
|
416 |
msgstr ""
|
417 |
|
418 |
-
#: ../includes/settings.php:
|
419 |
msgid "Import views"
|
420 |
msgstr ""
|
421 |
|
422 |
-
#: ../includes/settings.php:
|
423 |
msgid "Override existing views data."
|
424 |
msgstr ""
|
425 |
|
426 |
-
#: ../includes/settings.php:
|
427 |
msgid "Import post views data from WP-PostViews plugin."
|
428 |
msgstr ""
|
429 |
|
430 |
-
#: ../includes/settings.php:
|
431 |
msgid "Delete views"
|
432 |
msgstr ""
|
433 |
|
434 |
-
#: ../includes/settings.php:
|
435 |
msgid "Delete ALL the existing post views data."
|
436 |
msgstr ""
|
437 |
|
438 |
-
#: ../includes/settings.php:
|
439 |
msgid "Enable to restrict post views editing to admins only."
|
440 |
msgstr ""
|
441 |
|
442 |
-
#: ../includes/settings.php:
|
443 |
msgid "Enable to delete all plugin data on deactivation."
|
444 |
msgstr ""
|
445 |
|
446 |
-
#: ../includes/settings.php:
|
447 |
msgid "Select page types where the views count will be displayed."
|
448 |
msgstr ""
|
449 |
|
450 |
-
#: ../includes/settings.php:
|
451 |
msgid ""
|
452 |
"Select where would you like to display the post views counter. Use [post-"
|
453 |
"views] shortcode for manual display."
|
454 |
msgstr ""
|
455 |
|
456 |
-
#: ../includes/settings.php:
|
457 |
msgid "Choose how to display the post views counter."
|
458 |
msgstr ""
|
459 |
|
460 |
-
#: ../includes/settings.php:
|
461 |
#, php-format
|
462 |
msgid ""
|
463 |
"Enter the post views icon class. Any of the <a href=\"%s\" target=\"_blank"
|
464 |
"\">Dashicons</a> classes are available."
|
465 |
msgstr ""
|
466 |
|
467 |
-
#: ../includes/settings.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
468 |
msgid "Post views data imported succesfully."
|
469 |
msgstr ""
|
470 |
|
471 |
-
#: ../includes/settings.php:
|
472 |
msgid "There was no post views data to import."
|
473 |
msgstr ""
|
474 |
|
475 |
-
#: ../includes/settings.php:
|
476 |
msgid "All existing data deleted succesfully."
|
477 |
msgstr ""
|
478 |
|
479 |
-
#: ../includes/settings.php:
|
480 |
msgid "Error occurred. All existing data were not deleted."
|
481 |
msgstr ""
|
482 |
|
483 |
-
#: ../includes/settings.php:
|
484 |
msgid "General settings restored to defaults."
|
485 |
msgstr ""
|
486 |
|
487 |
-
#: ../includes/settings.php:
|
488 |
msgid "Display settings restored to defaults."
|
489 |
msgstr ""
|
490 |
|
@@ -566,28 +580,28 @@ msgstr ""
|
|
566 |
msgid "Thumbnail size"
|
567 |
msgstr ""
|
568 |
|
569 |
-
#: ../post-views-counter.php:
|
570 |
#, php-format
|
571 |
msgid ""
|
572 |
"Hey, you've been using <strong>Post Views Counter</strong> for more than %s."
|
573 |
msgstr ""
|
574 |
|
575 |
-
#: ../post-views-counter.php:
|
576 |
msgid ""
|
577 |
"Could you please do me a BIG favor and give it a 5-star rating on WordPress "
|
578 |
"to help us spread the word and boost our motivation."
|
579 |
msgstr ""
|
580 |
|
581 |
-
#: ../post-views-counter.php:
|
582 |
msgid "Your help is much appreciated. Thank you very much"
|
583 |
msgstr ""
|
584 |
|
585 |
-
#: ../post-views-counter.php:
|
586 |
#, php-format
|
587 |
msgid "founder of <a href=\"%s\" target=\"_blank\">dFactory</a> plugins."
|
588 |
msgstr ""
|
589 |
|
590 |
-
#: ../post-views-counter.php:
|
591 |
#, php-format
|
592 |
msgid ""
|
593 |
"<a href=\"%s\" class=\"pvc-dismissible-notice\" target=\"_blank\" rel="
|
@@ -597,18 +611,18 @@ msgid ""
|
|
597 |
"notice\" rel=\"noopener\">I already did</a>"
|
598 |
msgstr ""
|
599 |
|
600 |
-
#: ../post-views-counter.php:
|
601 |
msgid "Are you sure you want to reset these settings to defaults?"
|
602 |
msgstr ""
|
603 |
|
604 |
-
#: ../post-views-counter.php:
|
605 |
msgid "Are you sure you want to delete all existing data?"
|
606 |
msgstr ""
|
607 |
|
608 |
-
#: ../post-views-counter.php:
|
609 |
msgid "Support"
|
610 |
msgstr ""
|
611 |
|
612 |
-
#: ../post-views-counter.php:
|
613 |
msgid "Settings"
|
614 |
msgstr ""
|
2 |
msgid ""
|
3 |
msgstr ""
|
4 |
"Project-Id-Version: Post Views Counter\n"
|
5 |
+
"POT-Creation-Date: 2021-08-18 09:35+0200\n"
|
6 |
"PO-Revision-Date: 2015-04-08 18:59+0100\n"
|
7 |
"Last-Translator: Bartosz Arendt <info@dfactory.eu>\n"
|
8 |
"Language-Team: dFactory <info@dfactory.eu>\n"
|
21 |
#: ../includes/columns.php:51 ../includes/columns.php:154
|
22 |
#: ../includes/columns.php:197 ../includes/columns.php:348
|
23 |
#: ../includes/columns.php:354 ../includes/columns.php:404
|
24 |
+
#: ../includes/dashboard.php:94 ../includes/dashboard.php:198
|
25 |
+
#: ../includes/dashboard.php:207 ../includes/dashboard.php:216
|
26 |
+
#: ../includes/dashboard.php:302 ../includes/dashboard.php:432
|
27 |
msgid "Post Views"
|
28 |
msgstr ""
|
29 |
|
32 |
msgid "You are not allowed to edit this item."
|
33 |
msgstr ""
|
34 |
|
35 |
+
#: ../includes/columns.php:114 ../includes/counter.php:241
|
36 |
msgid "Invalid post ID."
|
37 |
msgstr ""
|
38 |
|
52 |
msgid "OK"
|
53 |
msgstr ""
|
54 |
|
55 |
+
#: ../includes/counter.php:233
|
56 |
msgid "REST API method is disabled."
|
57 |
msgstr ""
|
58 |
|
59 |
+
#: ../includes/counter.php:247
|
60 |
msgid "Post type excluded."
|
61 |
msgstr ""
|
62 |
|
73 |
msgid "Post Views Counter"
|
74 |
msgstr ""
|
75 |
|
76 |
+
#: ../includes/dashboard.php:94
|
77 |
msgid ""
|
78 |
"Displays the chart of most viewed post types for a selected time period."
|
79 |
msgstr ""
|
80 |
|
81 |
+
#: ../includes/dashboard.php:118
|
82 |
msgid "Top Posts"
|
83 |
msgstr ""
|
84 |
|
85 |
+
#: ../includes/dashboard.php:118
|
86 |
msgid "Displays the list of most viewed posts and pages on your website."
|
87 |
msgstr ""
|
88 |
|
89 |
+
#: ../includes/dashboard.php:147 ../includes/dashboard.php:150
|
90 |
+
#: ../includes/dashboard.php:387 ../includes/dashboard.php:390
|
91 |
+
#: ../includes/dashboard.php:504
|
92 |
msgid "You do not have permission to access this page."
|
93 |
msgstr ""
|
94 |
|
95 |
+
#: ../includes/dashboard.php:215
|
96 |
+
msgid "Year"
|
97 |
msgstr ""
|
98 |
|
99 |
+
#: ../includes/dashboard.php:230 ../includes/dashboard.php:316
|
100 |
+
msgid "Total Views"
|
101 |
msgstr ""
|
102 |
|
103 |
+
#: ../includes/dashboard.php:431
|
104 |
+
msgid "Post"
|
105 |
msgstr ""
|
106 |
|
107 |
+
#: ../includes/dashboard.php:455 ../includes/widgets.php:58
|
108 |
+
msgid "No most viewed posts found"
|
109 |
msgstr ""
|
110 |
|
111 |
#: ../includes/functions.php:476
|
333 |
msgid "Icon Class"
|
334 |
msgstr ""
|
335 |
|
336 |
+
#: ../includes/settings.php:252
|
337 |
+
msgid "Toolbar Chart"
|
338 |
+
msgstr ""
|
339 |
+
|
340 |
+
#: ../includes/settings.php:263
|
341 |
msgid "Enter the label for the post views counter field."
|
342 |
msgstr ""
|
343 |
|
344 |
+
#: ../includes/settings.php:281
|
345 |
msgid "Select post types for which post views will be counted."
|
346 |
msgstr ""
|
347 |
|
348 |
+
#: ../includes/settings.php:298
|
349 |
msgid "Select post types for which the views count will be displayed."
|
350 |
msgstr ""
|
351 |
|
352 |
+
#: ../includes/settings.php:317
|
353 |
msgid ""
|
354 |
"Select the method of collecting post views data. If you are using any of the "
|
355 |
"caching plugins select Javascript or REST API (if available)."
|
356 |
msgstr ""
|
357 |
|
358 |
+
#: ../includes/settings.php:317
|
359 |
msgid ""
|
360 |
"Optionally try the Fast AJAX experimental method, usually 10+ times faster "
|
361 |
"than Javascript or REST API."
|
362 |
msgstr ""
|
363 |
|
364 |
+
#: ../includes/settings.php:327
|
365 |
msgid ""
|
366 |
"Enable to display post views count column for each of the selected post "
|
367 |
"types."
|
368 |
msgstr ""
|
369 |
|
370 |
+
#: ../includes/settings.php:347
|
371 |
msgid "Enter the time between single user visit count."
|
372 |
msgstr ""
|
373 |
|
374 |
+
#: ../includes/settings.php:367
|
375 |
msgid ""
|
376 |
"Delete single day post views data older than specified above. Enter 0 "
|
377 |
"(number zero) if you want to preserve your data regardless of its age."
|
378 |
msgstr ""
|
379 |
|
380 |
+
#: ../includes/settings.php:387
|
381 |
msgid ""
|
382 |
"How often to flush cached view counts from the object cache into the "
|
383 |
"database. This feature is used only if a persistent object cache is detected "
|
389 |
"interval."
|
390 |
msgstr ""
|
391 |
|
392 |
+
#: ../includes/settings.php:405 ../includes/settings.php:590
|
393 |
msgid "Use it to hide the post views counter from selected type of visitors."
|
394 |
msgstr ""
|
395 |
|
396 |
+
#: ../includes/settings.php:414 ../includes/settings.php:599
|
397 |
msgid "Use it to hide the post views counter from selected user roles."
|
398 |
msgstr ""
|
399 |
|
400 |
+
#: ../includes/settings.php:434 ../includes/settings.php:440
|
401 |
msgid "Remove"
|
402 |
msgstr ""
|
403 |
|
404 |
+
#: ../includes/settings.php:445
|
405 |
msgid "Add new"
|
406 |
msgstr ""
|
407 |
|
408 |
+
#: ../includes/settings.php:445
|
409 |
msgid "Add my current IP"
|
410 |
msgstr ""
|
411 |
|
412 |
+
#: ../includes/settings.php:446
|
413 |
msgid "Enter the IP addresses to be excluded from post views count."
|
414 |
msgstr ""
|
415 |
|
416 |
+
#: ../includes/settings.php:456
|
417 |
msgid ""
|
418 |
"Enable to prevent bypassing the counts interval (for e.g. using incognito "
|
419 |
"browser window or by clearing cookies)."
|
420 |
msgstr ""
|
421 |
|
422 |
+
#: ../includes/settings.php:467
|
423 |
msgid "Import views"
|
424 |
msgstr ""
|
425 |
|
426 |
+
#: ../includes/settings.php:467
|
427 |
msgid "Override existing views data."
|
428 |
msgstr ""
|
429 |
|
430 |
+
#: ../includes/settings.php:468
|
431 |
msgid "Import post views data from WP-PostViews plugin."
|
432 |
msgstr ""
|
433 |
|
434 |
+
#: ../includes/settings.php:469
|
435 |
msgid "Delete views"
|
436 |
msgstr ""
|
437 |
|
438 |
+
#: ../includes/settings.php:470
|
439 |
msgid "Delete ALL the existing post views data."
|
440 |
msgstr ""
|
441 |
|
442 |
+
#: ../includes/settings.php:481
|
443 |
msgid "Enable to restrict post views editing to admins only."
|
444 |
msgstr ""
|
445 |
|
446 |
+
#: ../includes/settings.php:491
|
447 |
msgid "Enable to delete all plugin data on deactivation."
|
448 |
msgstr ""
|
449 |
|
450 |
+
#: ../includes/settings.php:508
|
451 |
msgid "Select page types where the views count will be displayed."
|
452 |
msgstr ""
|
453 |
|
454 |
+
#: ../includes/settings.php:527
|
455 |
msgid ""
|
456 |
"Select where would you like to display the post views counter. Use [post-"
|
457 |
"views] shortcode for manual display."
|
458 |
msgstr ""
|
459 |
|
460 |
+
#: ../includes/settings.php:546
|
461 |
msgid "Choose how to display the post views counter."
|
462 |
msgstr ""
|
463 |
|
464 |
+
#: ../includes/settings.php:557
|
465 |
#, php-format
|
466 |
msgid ""
|
467 |
"Enter the post views icon class. Any of the <a href=\"%s\" target=\"_blank"
|
468 |
"\">Dashicons</a> classes are available."
|
469 |
msgstr ""
|
470 |
|
471 |
+
#: ../includes/settings.php:567
|
472 |
+
msgid "Enable to display the post views chart at the toolbar."
|
473 |
+
msgstr ""
|
474 |
+
|
475 |
+
#: ../includes/settings.php:568
|
476 |
+
msgid ""
|
477 |
+
"The post views chart will be displayed for the post types that are being "
|
478 |
+
"counted."
|
479 |
+
msgstr ""
|
480 |
+
|
481 |
+
#: ../includes/settings.php:632
|
482 |
msgid "Post views data imported succesfully."
|
483 |
msgstr ""
|
484 |
|
485 |
+
#: ../includes/settings.php:634
|
486 |
msgid "There was no post views data to import."
|
487 |
msgstr ""
|
488 |
|
489 |
+
#: ../includes/settings.php:644
|
490 |
msgid "All existing data deleted succesfully."
|
491 |
msgstr ""
|
492 |
|
493 |
+
#: ../includes/settings.php:646
|
494 |
msgid "Error occurred. All existing data were not deleted."
|
495 |
msgstr ""
|
496 |
|
497 |
+
#: ../includes/settings.php:829
|
498 |
msgid "General settings restored to defaults."
|
499 |
msgstr ""
|
500 |
|
501 |
+
#: ../includes/settings.php:834
|
502 |
msgid "Display settings restored to defaults."
|
503 |
msgstr ""
|
504 |
|
580 |
msgid "Thumbnail size"
|
581 |
msgstr ""
|
582 |
|
583 |
+
#: ../post-views-counter.php:253
|
584 |
#, php-format
|
585 |
msgid ""
|
586 |
"Hey, you've been using <strong>Post Views Counter</strong> for more than %s."
|
587 |
msgstr ""
|
588 |
|
589 |
+
#: ../post-views-counter.php:253
|
590 |
msgid ""
|
591 |
"Could you please do me a BIG favor and give it a 5-star rating on WordPress "
|
592 |
"to help us spread the word and boost our motivation."
|
593 |
msgstr ""
|
594 |
|
595 |
+
#: ../post-views-counter.php:253
|
596 |
msgid "Your help is much appreciated. Thank you very much"
|
597 |
msgstr ""
|
598 |
|
599 |
+
#: ../post-views-counter.php:253
|
600 |
#, php-format
|
601 |
msgid "founder of <a href=\"%s\" target=\"_blank\">dFactory</a> plugins."
|
602 |
msgstr ""
|
603 |
|
604 |
+
#: ../post-views-counter.php:253
|
605 |
#, php-format
|
606 |
msgid ""
|
607 |
"<a href=\"%s\" class=\"pvc-dismissible-notice\" target=\"_blank\" rel="
|
611 |
"notice\" rel=\"noopener\">I already did</a>"
|
612 |
msgstr ""
|
613 |
|
614 |
+
#: ../post-views-counter.php:535
|
615 |
msgid "Are you sure you want to reset these settings to defaults?"
|
616 |
msgstr ""
|
617 |
|
618 |
+
#: ../post-views-counter.php:536
|
619 |
msgid "Are you sure you want to delete all existing data?"
|
620 |
msgstr ""
|
621 |
|
622 |
+
#: ../post-views-counter.php:590
|
623 |
msgid "Support"
|
624 |
msgstr ""
|
625 |
|
626 |
+
#: ../post-views-counter.php:614
|
627 |
msgid "Settings"
|
628 |
msgstr ""
|
post-views-counter.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: Post Views Counter
|
4 |
Description: Post Views Counter allows you to display how many times a post, page or custom post type had been viewed in a simple, fast and reliable way.
|
5 |
-
Version: 1.3.
|
6 |
Author: Digital Factory
|
7 |
Author URI: http://www.dfactory.eu/
|
8 |
Plugin URI: http://www.dfactory.eu/plugins/post-views-counter/
|
@@ -31,60 +31,61 @@ if ( ! class_exists( 'Post_Views_Counter' ) ) :
|
|
31 |
* Post Views Counter final class.
|
32 |
*
|
33 |
* @class Post_Views_Counter
|
34 |
-
* @version 1.3.
|
35 |
*/
|
36 |
final class Post_Views_Counter {
|
37 |
|
38 |
private static $instance;
|
39 |
public $options;
|
40 |
public $defaults = array(
|
41 |
-
'general'
|
42 |
-
'post_types_count'
|
43 |
-
'counter_mode'
|
44 |
-
'post_views_column'
|
45 |
-
'time_between_counts'
|
46 |
'number' => 24,
|
47 |
'type' => 'hours'
|
48 |
),
|
49 |
-
'reset_counts'
|
50 |
'number' => 30,
|
51 |
'type' => 'days'
|
52 |
),
|
53 |
-
'flush_interval'
|
54 |
'number' => 0,
|
55 |
'type' => 'minutes'
|
56 |
),
|
57 |
-
'exclude'
|
58 |
'groups' => array(),
|
59 |
'roles' => array()
|
60 |
),
|
61 |
-
'exclude_ips'
|
62 |
-
'strict_counts'
|
63 |
-
'restrict_edit_views'
|
64 |
-
'deactivation_delete'
|
65 |
-
'cron_run'
|
66 |
-
'cron_update'
|
67 |
'update_version' => 1,
|
68 |
'update_notice' => true,
|
69 |
'update_delay_date' => 0
|
70 |
),
|
71 |
-
'display'
|
72 |
-
'label'
|
73 |
-
'post_types_display'
|
74 |
-
'page_types_display'
|
75 |
-
'restrict_display'
|
76 |
'groups' => array(),
|
77 |
'roles' => array()
|
78 |
),
|
79 |
-
'position'
|
80 |
-
'display_style'
|
81 |
'icon' => true,
|
82 |
'text' => true
|
83 |
),
|
84 |
-
'link_to_post'
|
85 |
-
'icon_class'
|
|
|
86 |
),
|
87 |
-
'version'
|
88 |
);
|
89 |
|
90 |
/**
|
2 |
/*
|
3 |
Plugin Name: Post Views Counter
|
4 |
Description: Post Views Counter allows you to display how many times a post, page or custom post type had been viewed in a simple, fast and reliable way.
|
5 |
+
Version: 1.3.5
|
6 |
Author: Digital Factory
|
7 |
Author URI: http://www.dfactory.eu/
|
8 |
Plugin URI: http://www.dfactory.eu/plugins/post-views-counter/
|
31 |
* Post Views Counter final class.
|
32 |
*
|
33 |
* @class Post_Views_Counter
|
34 |
+
* @version 1.3.5
|
35 |
*/
|
36 |
final class Post_Views_Counter {
|
37 |
|
38 |
private static $instance;
|
39 |
public $options;
|
40 |
public $defaults = array(
|
41 |
+
'general' => array(
|
42 |
+
'post_types_count' => array( 'post' ),
|
43 |
+
'counter_mode' => 'php',
|
44 |
+
'post_views_column' => true,
|
45 |
+
'time_between_counts' => array(
|
46 |
'number' => 24,
|
47 |
'type' => 'hours'
|
48 |
),
|
49 |
+
'reset_counts' => array(
|
50 |
'number' => 30,
|
51 |
'type' => 'days'
|
52 |
),
|
53 |
+
'flush_interval' => array(
|
54 |
'number' => 0,
|
55 |
'type' => 'minutes'
|
56 |
),
|
57 |
+
'exclude' => array(
|
58 |
'groups' => array(),
|
59 |
'roles' => array()
|
60 |
),
|
61 |
+
'exclude_ips' => array(),
|
62 |
+
'strict_counts' => false,
|
63 |
+
'restrict_edit_views' => false,
|
64 |
+
'deactivation_delete' => false,
|
65 |
+
'cron_run' => true,
|
66 |
+
'cron_update' => true,
|
67 |
'update_version' => 1,
|
68 |
'update_notice' => true,
|
69 |
'update_delay_date' => 0
|
70 |
),
|
71 |
+
'display' => array(
|
72 |
+
'label' => 'Post Views:',
|
73 |
+
'post_types_display' => array( 'post' ),
|
74 |
+
'page_types_display' => array( 'singular' ),
|
75 |
+
'restrict_display' => array(
|
76 |
'groups' => array(),
|
77 |
'roles' => array()
|
78 |
),
|
79 |
+
'position' => 'after',
|
80 |
+
'display_style' => array(
|
81 |
'icon' => true,
|
82 |
'text' => true
|
83 |
),
|
84 |
+
'link_to_post' => true,
|
85 |
+
'icon_class' => 'dashicons-chart-bar',
|
86 |
+
'toolbar_statistics' => true
|
87 |
),
|
88 |
+
'version' => '1.3.5'
|
89 |
);
|
90 |
|
91 |
/**
|
readme.txt
CHANGED
@@ -4,8 +4,8 @@ Donate link: http://dfactory.eu/
|
|
4 |
Tags: counter, hits, posts, postviews, post views, views, count, statistics, stats, analytics, pageviews, tracking
|
5 |
Requires at least: 5.0
|
6 |
Requires PHP: 5.2.4
|
7 |
-
Tested up to: 5.
|
8 |
-
Stable tag: 1.3.
|
9 |
License: MIT License
|
10 |
License URI: http://opensource.org/licenses/MIT
|
11 |
|
@@ -62,6 +62,11 @@ No questions yet.
|
|
62 |
|
63 |
== Changelog ==
|
64 |
|
|
|
|
|
|
|
|
|
|
|
65 |
= 1.3.4 =
|
66 |
* New: Post Views stats preview in the admin bar
|
67 |
* New: Top Posts data available in the dashboard widget
|
@@ -211,8 +216,7 @@ Initial release
|
|
211 |
|
212 |
== Upgrade Notice ==
|
213 |
|
214 |
-
= 1.3.
|
215 |
-
* New:
|
216 |
-
*
|
217 |
-
* Tweak:
|
218 |
-
* Tweak: PHP 8.x compatibility
|
4 |
Tags: counter, hits, posts, postviews, post views, views, count, statistics, stats, analytics, pageviews, tracking
|
5 |
Requires at least: 5.0
|
6 |
Requires PHP: 5.2.4
|
7 |
+
Tested up to: 5.8
|
8 |
+
Stable tag: 1.3.5
|
9 |
License: MIT License
|
10 |
License URI: http://opensource.org/licenses/MIT
|
11 |
|
62 |
|
63 |
== Changelog ==
|
64 |
|
65 |
+
= 1.3.5 =
|
66 |
+
* New: Option to hide admin bar chart
|
67 |
+
* Fix: Small security bug with views label
|
68 |
+
* Tweak: Remove unnecessary CSS on every page
|
69 |
+
|
70 |
= 1.3.4 =
|
71 |
* New: Post Views stats preview in the admin bar
|
72 |
* New: Top Posts data available in the dashboard widget
|
216 |
|
217 |
== Upgrade Notice ==
|
218 |
|
219 |
+
= 1.3.5 =
|
220 |
+
* New: Option to hide admin bar chart
|
221 |
+
* Fix: Small security bug with views label
|
222 |
+
* Tweak: Remove unnecessary CSS on every page
|
|