Version Description
N/A
Download this release
Release Info
Developer | GamerZ |
Plugin | WP-PostViews |
Version | 1.68 |
Comparing to | |
See all releases |
Code changes from version 1.67 to 1.68
- postviews-options.php +14 -12
- readme.txt +14 -9
- screenshot-1.png +0 -0
- wp-postviews.php +23 -12
postviews-options.php
CHANGED
@@ -10,17 +10,17 @@ $text = '';
|
|
10 |
if(!empty($_POST['Submit'] )) {
|
11 |
check_admin_referer( 'wp-postviews_options' );
|
12 |
$views_options = array(
|
13 |
-
'count' => intval(
|
14 |
-
, 'exclude_bots' => intval(
|
15 |
-
, 'display_home' => intval(
|
16 |
-
, 'display_single' => intval(
|
17 |
-
, 'display_page' => intval(
|
18 |
-
, 'display_archive' => intval(
|
19 |
-
, 'display_search' => intval(
|
20 |
-
, 'display_other' => intval(
|
21 |
-
, 'use_ajax' => intval(
|
22 |
-
, 'template' => trim(
|
23 |
-
, 'most_viewed_template' => trim(
|
24 |
);
|
25 |
$update_views_queries = array();
|
26 |
$update_views_text = array();
|
@@ -100,6 +100,8 @@ if( !isset ( $views_options['use_ajax'] ) ) {
|
|
100 |
</p>
|
101 |
</td>
|
102 |
</tr>
|
|
|
|
|
103 |
<?php endif; ?>
|
104 |
<tr>
|
105 |
<td valign="top">
|
@@ -144,7 +146,7 @@ if( !isset ( $views_options['use_ajax'] ) ) {
|
|
144 |
</td>
|
145 |
</tr>
|
146 |
<tr>
|
147 |
-
<td valign="top"><strong><?php _e( '
|
148 |
<td>
|
149 |
<select name="views_display_single" size="1">
|
150 |
<option value="0"<?php selected( '0', $views_options['display_single'] ); ?>><?php _e( 'Display to everyone', 'wp-postviews' ); ?></option>
|
10 |
if(!empty($_POST['Submit'] )) {
|
11 |
check_admin_referer( 'wp-postviews_options' );
|
12 |
$views_options = array(
|
13 |
+
'count' => intval( views_options_parse('views_count') )
|
14 |
+
, 'exclude_bots' => intval( views_options_parse('views_exclude_bots') )
|
15 |
+
, 'display_home' => intval( views_options_parse('views_display_home') )
|
16 |
+
, 'display_single' => intval( views_options_parse('views_display_single') )
|
17 |
+
, 'display_page' => intval( views_options_parse('views_display_page') )
|
18 |
+
, 'display_archive' => intval( views_options_parse('views_display_archive') )
|
19 |
+
, 'display_search' => intval( views_options_parse('views_display_search') )
|
20 |
+
, 'display_other' => intval( views_options_parse('views_display_other') )
|
21 |
+
, 'use_ajax' => intval( views_options_parse('views_use_ajax') )
|
22 |
+
, 'template' => trim( views_options_parse('views_template_template') )
|
23 |
+
, 'most_viewed_template' => trim( views_options_parse('views_template_most_viewed') )
|
24 |
);
|
25 |
$update_views_queries = array();
|
26 |
$update_views_text = array();
|
100 |
</p>
|
101 |
</td>
|
102 |
</tr>
|
103 |
+
<?php else: ?>
|
104 |
+
<input type="hidden" name="views_use_ajax" value="0" />
|
105 |
<?php endif; ?>
|
106 |
<tr>
|
107 |
<td valign="top">
|
146 |
</td>
|
147 |
</tr>
|
148 |
<tr>
|
149 |
+
<td valign="top"><strong><?php _e( 'Single Posts:', 'wp-postviews' ); ?></strong></td>
|
150 |
<td>
|
151 |
<select name="views_display_single" size="1">
|
152 |
<option value="0"<?php selected( '0', $views_options['display_single'] ); ?>><?php _e( 'Display to everyone', 'wp-postviews' ); ?></option>
|
readme.txt
CHANGED
@@ -3,29 +3,33 @@ Contributors: GamerZ
|
|
3 |
Donate link: http://lesterchan.net/site/donation/
|
4 |
Tags: views, hits, counter, postviews
|
5 |
Requires at least: 3.0
|
6 |
-
Tested up to:
|
7 |
-
Stable tag: 1.
|
8 |
|
9 |
Enables you to display how many times a post/page had been viewed.
|
10 |
|
11 |
== Description ==
|
12 |
|
|
|
|
|
|
|
13 |
= Development =
|
14 |
-
|
15 |
|
16 |
= Translations =
|
17 |
-
|
18 |
|
19 |
= Credits =
|
20 |
-
*
|
21 |
-
* __ngetext() by [Anna Ozeritskaya](http://hweia.ru/ "Anna Ozeritskaya")
|
22 |
-
* Right To Left Language Support by [Kambiz R. Khojasteh](http://persian-programming.com/ "Kambiz R. Khojasteh")
|
23 |
-
* Options To Display Views On Certain Places by [David Potter](http://dpotter.net/Technical/ "David Potter")
|
24 |
|
25 |
= Donations =
|
26 |
-
|
27 |
|
28 |
== Changelog ==
|
|
|
|
|
|
|
|
|
29 |
= Version 1.67 =
|
30 |
* NEW: Allow user to not use AJAX to update the views even though WP_CACHE is true
|
31 |
|
@@ -149,6 +153,7 @@ N/A
|
|
149 |
== Screenshots ==
|
150 |
|
151 |
1. PostViews
|
|
|
152 |
|
153 |
== Frequently Asked Questions ==
|
154 |
|
3 |
Donate link: http://lesterchan.net/site/donation/
|
4 |
Tags: views, hits, counter, postviews
|
5 |
Requires at least: 3.0
|
6 |
+
Tested up to: 4.0
|
7 |
+
Stable tag: 1.68
|
8 |
|
9 |
Enables you to display how many times a post/page had been viewed.
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
+
= Build Status =
|
14 |
+
[![Build Status](https://travis-ci.org/lesterchan/wp-postviews.svg?branch=master)](https://travis-ci.org/lesterchan/wp-postviews)
|
15 |
+
|
16 |
= Development =
|
17 |
+
[https://github.com/lesterchan/wp-postviews/](https://github.com/lesterchan/wp-postviews/ "https://github.com/lesterchan/wp-postviews/")
|
18 |
|
19 |
= Translations =
|
20 |
+
[http://dev.wp-plugins.org/browser/wp-postviews/i18n/](http://dev.wp-plugins.org/browser/wp-postviews/i18n/ "http://dev.wp-plugins.org/browser/wp-postviews/i18n/")
|
21 |
|
22 |
= Credits =
|
23 |
+
* Plugin icon by [Iconmoon](http://www.icomoon.io) from [Flaticon](http://www.flaticon.com)
|
|
|
|
|
|
|
24 |
|
25 |
= Donations =
|
26 |
+
I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks, I will really appericiate it. If not feel free to use it without any obligations.
|
27 |
|
28 |
== Changelog ==
|
29 |
+
= Version 1.68 =
|
30 |
+
* NEW: Added action hook 'postviews_increment_views' and 'postviews_increment_views_ajax'
|
31 |
+
* NEW: Allow custom post type to be chosen under the widget
|
32 |
+
|
33 |
= Version 1.67 =
|
34 |
* NEW: Allow user to not use AJAX to update the views even though WP_CACHE is true
|
35 |
|
153 |
== Screenshots ==
|
154 |
|
155 |
1. PostViews
|
156 |
+
2. Admin - PostViews Options
|
157 |
|
158 |
== Frequently Asked Questions ==
|
159 |
|
screenshot-1.png
DELETED
Binary file
|
wp-postviews.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: WP-PostViews
|
4 |
Plugin URI: http://lesterchan.net/portfolio/programming/php/
|
5 |
Description: Enables you to display how many times a post/page had been viewed.
|
6 |
-
Version: 1.
|
7 |
Author: Lester 'GaMerZ' Chan
|
8 |
Author URI: http://lesterchan.net
|
9 |
Text Domain: wp-postviews
|
@@ -118,6 +118,7 @@ function process_postviews() {
|
|
118 |
}
|
119 |
if( $should_count && ( ( isset( $views_options['use_ajax'] ) && intval( $views_options['use_ajax'] ) === 0 ) || ( !defined( 'WP_CACHE' ) || !WP_CACHE ) ) ) {
|
120 |
update_post_meta( $id, 'views', ( $post_views + 1 ) );
|
|
|
121 |
}
|
122 |
}
|
123 |
}
|
@@ -155,8 +156,8 @@ function wp_postview_cache_count_enqueue() {
|
|
155 |
break;
|
156 |
}
|
157 |
if ( $should_count ) {
|
158 |
-
wp_enqueue_script( 'wp-postviews-cache', plugins_url( 'postviews-cache.js', __FILE__ ), array( 'jquery' ), '1.
|
159 |
-
wp_localize_script( 'wp-postviews-cache', 'viewsCacheL10n', array( 'admin_ajax_url' => admin_url( 'admin-ajax.php'
|
160 |
}
|
161 |
}
|
162 |
}
|
@@ -750,6 +751,7 @@ function increment_views() {
|
|
750 |
$post_views = get_post_custom( $post_id );
|
751 |
$post_views = intval( $post_views['views'][0] );
|
752 |
update_post_meta( $post_id, 'views', ( $post_views + 1 ) );
|
|
|
753 |
echo ( $post_views + 1 );
|
754 |
exit();
|
755 |
}
|
@@ -804,14 +806,13 @@ function sort_postviews($query) {
|
|
804 |
|
805 |
// Display Widget
|
806 |
function widget($args, $instance) {
|
807 |
-
extract($args);
|
808 |
$title = apply_filters('widget_title', esc_attr($instance['title']));
|
809 |
$type = esc_attr($instance['type']);
|
810 |
$mode = esc_attr($instance['mode']);
|
811 |
$limit = intval($instance['limit']);
|
812 |
$chars = intval($instance['chars']);
|
813 |
$cat_ids = explode(',', esc_attr($instance['cat_ids']));
|
814 |
-
echo $before_widget
|
815 |
echo '<ul>'."\n";
|
816 |
switch($type) {
|
817 |
case 'least_viewed':
|
@@ -828,7 +829,7 @@ function sort_postviews($query) {
|
|
828 |
break;
|
829 |
}
|
830 |
echo '</ul>'."\n";
|
831 |
-
echo
|
832 |
}
|
833 |
|
834 |
// When Widget Control Form Is Posted
|
@@ -848,13 +849,16 @@ function sort_postviews($query) {
|
|
848 |
|
849 |
// DIsplay Widget Control Form
|
850 |
function form($instance) {
|
851 |
-
$instance = wp_parse_args((array) $instance, array('title' => __('Views', 'wp-postviews'), 'type' => 'most_viewed', 'mode' => '
|
852 |
$title = esc_attr($instance['title']);
|
853 |
$type = esc_attr($instance['type']);
|
854 |
-
$mode = esc_attr($instance['mode']);
|
855 |
$limit = intval($instance['limit']);
|
856 |
$chars = intval($instance['chars']);
|
857 |
$cat_ids = esc_attr($instance['cat_ids']);
|
|
|
|
|
|
|
858 |
?>
|
859 |
<p>
|
860 |
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'wp-postviews'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label>
|
@@ -873,9 +877,12 @@ function sort_postviews($query) {
|
|
873 |
<p>
|
874 |
<label for="<?php echo $this->get_field_id('mode'); ?>"><?php _e('Include Views From:', 'wp-postviews'); ?>
|
875 |
<select name="<?php echo $this->get_field_name('mode'); ?>" id="<?php echo $this->get_field_id('mode'); ?>" class="widefat">
|
876 |
-
<option value="
|
877 |
-
|
878 |
-
|
|
|
|
|
|
|
879 |
</select>
|
880 |
</label>
|
881 |
</p>
|
@@ -945,4 +952,8 @@ function views_activation( $network_wide ) {
|
|
945 |
add_option( $option_name, $option );
|
946 |
}
|
947 |
}
|
948 |
-
|
|
|
|
|
|
|
|
3 |
Plugin Name: WP-PostViews
|
4 |
Plugin URI: http://lesterchan.net/portfolio/programming/php/
|
5 |
Description: Enables you to display how many times a post/page had been viewed.
|
6 |
+
Version: 1.68
|
7 |
Author: Lester 'GaMerZ' Chan
|
8 |
Author URI: http://lesterchan.net
|
9 |
Text Domain: wp-postviews
|
118 |
}
|
119 |
if( $should_count && ( ( isset( $views_options['use_ajax'] ) && intval( $views_options['use_ajax'] ) === 0 ) || ( !defined( 'WP_CACHE' ) || !WP_CACHE ) ) ) {
|
120 |
update_post_meta( $id, 'views', ( $post_views + 1 ) );
|
121 |
+
do_action( 'postviews_increment_views', ( $post_views + 1 ) );
|
122 |
}
|
123 |
}
|
124 |
}
|
156 |
break;
|
157 |
}
|
158 |
if ( $should_count ) {
|
159 |
+
wp_enqueue_script( 'wp-postviews-cache', plugins_url( 'postviews-cache.js', __FILE__ ), array( 'jquery' ), '1.68', true );
|
160 |
+
wp_localize_script( 'wp-postviews-cache', 'viewsCacheL10n', array( 'admin_ajax_url' => admin_url( 'admin-ajax.php' ), 'post_id' => intval( $post->ID ) ) );
|
161 |
}
|
162 |
}
|
163 |
}
|
751 |
$post_views = get_post_custom( $post_id );
|
752 |
$post_views = intval( $post_views['views'][0] );
|
753 |
update_post_meta( $post_id, 'views', ( $post_views + 1 ) );
|
754 |
+
do_action( 'postviews_increment_views_ajax', ( $post_views + 1 ) );
|
755 |
echo ( $post_views + 1 );
|
756 |
exit();
|
757 |
}
|
806 |
|
807 |
// Display Widget
|
808 |
function widget($args, $instance) {
|
|
|
809 |
$title = apply_filters('widget_title', esc_attr($instance['title']));
|
810 |
$type = esc_attr($instance['type']);
|
811 |
$mode = esc_attr($instance['mode']);
|
812 |
$limit = intval($instance['limit']);
|
813 |
$chars = intval($instance['chars']);
|
814 |
$cat_ids = explode(',', esc_attr($instance['cat_ids']));
|
815 |
+
echo $args['before_widget'] . $args['before_title'] . $title . $args['after_title'];
|
816 |
echo '<ul>'."\n";
|
817 |
switch($type) {
|
818 |
case 'least_viewed':
|
829 |
break;
|
830 |
}
|
831 |
echo '</ul>'."\n";
|
832 |
+
echo $args['after_widget'];
|
833 |
}
|
834 |
|
835 |
// When Widget Control Form Is Posted
|
849 |
|
850 |
// DIsplay Widget Control Form
|
851 |
function form($instance) {
|
852 |
+
$instance = wp_parse_args((array) $instance, array('title' => __('Views', 'wp-postviews'), 'type' => 'most_viewed', 'mode' => '', 'limit' => 10, 'chars' => 200, 'cat_ids' => '0'));
|
853 |
$title = esc_attr($instance['title']);
|
854 |
$type = esc_attr($instance['type']);
|
855 |
+
$mode = trim(esc_attr($instance['mode']));
|
856 |
$limit = intval($instance['limit']);
|
857 |
$chars = intval($instance['chars']);
|
858 |
$cat_ids = esc_attr($instance['cat_ids']);
|
859 |
+
$post_types = get_post_types(array(
|
860 |
+
'public' => true
|
861 |
+
));
|
862 |
?>
|
863 |
<p>
|
864 |
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'wp-postviews'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label>
|
877 |
<p>
|
878 |
<label for="<?php echo $this->get_field_id('mode'); ?>"><?php _e('Include Views From:', 'wp-postviews'); ?>
|
879 |
<select name="<?php echo $this->get_field_name('mode'); ?>" id="<?php echo $this->get_field_id('mode'); ?>" class="widefat">
|
880 |
+
<option value=""<?php selected('', $mode); ?>><?php _e('All', 'wp-postviews'); ?></option>
|
881 |
+
<?php if($post_types > 0): ?>
|
882 |
+
<?php foreach($post_types as $post_type): ?>
|
883 |
+
<option value="<?php echo $post_type; ?>"<?php selected($post_type, $mode); ?>><?php printf(__('%s Only', 'wp-postviews'), ucfirst($post_type)); ?></option>
|
884 |
+
<?php endforeach; ?>
|
885 |
+
<?php endif; ?>
|
886 |
</select>
|
887 |
</label>
|
888 |
</p>
|
952 |
add_option( $option_name, $option );
|
953 |
}
|
954 |
}
|
955 |
+
|
956 |
+
### Function: Parse View Options
|
957 |
+
function views_options_parse($key) {
|
958 |
+
return !empty($_POST[$key]) ? $_POST[$key] : null;
|
959 |
+
}
|