Permalink
Browse files

upgrading to ver 1.61 (svn trunk is the 'stable')

  • Loading branch information...
Matt Richmond
Matt Richmond committed Jun 25, 2012
1 parent 37fefa3 commit 6a0917c9f758e27d99e746fe8e166bd19fe9cdc5
Showing with 373 additions and 28 deletions.
  1. +4 −4 postviews-options.php
  2. +4 −1 readme.txt
  3. +18 −23 wp-postviews.php
  4. +347 −0 wp-postviews.pot
View
@@ -2,8 +2,8 @@
/*
+----------------------------------------------------------------+
| |
-| WordPress 2.8 Plugin: WP-PostViews 1.60 |
-| Copyright (c) 2009 Lester "GaMerZ" Chan |
+| WordPress Plugin: WP-PostViews |
+| Copyright (c) 2012 Lester "GaMerZ" Chan |
| |
| File Written By: |
| - Lester "GaMerZ" Chan |
@@ -20,8 +20,8 @@
### Variables Variables Variables
$base_name = plugin_basename('wp-postviews/postviews-options.php');
$base_page = 'admin.php?page='.$base_name;
-$id = intval($_GET['id']);
-$mode = trim($_GET['mode']);
+$id = (isset($_GET['id']) ? intval($_GET['id']) : 0);
+$mode = (isset($_GET['mode']) ? trim($_GET['mode']) : '');
$views_settings = array('views_options', 'widget_views_most_viewed', 'widget_views');
$views_postmetas = array('views');
View
@@ -3,7 +3,7 @@ Contributors: GamerZ
Donate link: http://lesterchan.net/site/donation/
Tags: views, hits, counter, postviews
Requires at least: 2.8
-Tested up to: 3.0.4
+Tested up to: 3.3.2
Stable tag: trunk
Enables you to display how many times a post/page had been viewed.
@@ -35,6 +35,9 @@ Enables you to display how many times a post/page had been viewed.
* 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.
== Changelog ==
+= Version 1.61 (21-05-2012) =
+* Move AJAX Request to wp-admin/admin-ajax.php
+
= Version 1.60 (18-02-2011) =
* NEW: Added Views Count To Edit Posts Screen
* FIXED: Removed Global $post
View
@@ -3,14 +3,14 @@
Plugin Name: WP-PostViews
Plugin URI: http://lesterchan.net/portfolio/programming/php/
Description: Enables you to display how many times a post/page had been viewed. Modified by <a href="http://DPotter.net/Technical/" title="David's Technical Musings">David Potter</a> to include options for when and where to display view counts.
-Version: 1.60
+Version: 1.61
Author: Lester 'GaMerZ' Chan
Author URI: http://lesterchan.net
*/
/*
- Copyright 2009 Lester Chan (email : lesterchan@gmail.com)
+ Copyright 2012 Lester Chan (email : lesterchan@gmail.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -28,17 +28,6 @@
*/
-### Load WP-Config File If This File Is Called Directly
-if (!function_exists('add_action')) {
- $wp_root = '../../..';
- if (file_exists($wp_root.'/wp-load.php')) {
- require_once($wp_root.'/wp-load.php');
- } else {
- require_once($wp_root.'/wp-config.php');
- }
-}
-
-
### Create Text Domain For Translations
add_action('init', 'postviews_textdomain');
function postviews_textdomain() {
@@ -96,14 +85,14 @@ function process_postviews() {
}
if($should_count) {
if(defined('WP_CACHE') && WP_CACHE) {
- echo "\n".'<!-- Start Of Script Generated By WP-PostViews 1.60 -->'."\n";
+ echo "\n".'<!-- Start Of Script Generated By WP-PostViews -->'."\n";
wp_print_scripts('jquery');
echo '<script type="text/javascript">'."\n";
echo '/* <![CDATA[ */'."\n";
- echo "jQuery.ajax({type:'GET',url:'".plugins_url('wp-postviews/wp-postviews.php')."',data:'postviews_id=".$id."',cache:false});";
+ echo "jQuery.ajax({type:'GET',url:'".admin_url('admin-ajax.php', (is_ssl() ? 'https' : 'http'))."',data:'postviews_id=".$id."&action=postviews',cache:false});";
echo '/* ]]> */'."\n";
echo '</script>'."\n";
- echo '<!-- End Of Script Generated By WP-PostViews 1.60 -->'."\n";
+ echo '<!-- End Of Script Generated By WP-PostViews -->'."\n";
} else {
if(!update_post_meta($id, 'views', ($post_views+1))) {
add_post_meta($id, 'views', 1, true);
@@ -642,17 +631,23 @@ function postviews_page_most_stats($content) {
### Function: Increment Post Views
-increment_views();
+add_action('wp_ajax_postviews', 'increment_views');
+add_action('wp_ajax_nopriv_postviews', 'increment_views');
function increment_views() {
global $wpdb;
- $post_id = intval($_GET['postviews_id']);
- if($post_id > 0 && defined('WP_CACHE') && WP_CACHE) {
- $post_views = get_post_custom($post_id);
- $post_views = intval($post_views['views'][0]);
- if(!update_post_meta($post_id, 'views', ($post_views+1))) {
- add_post_meta($post_id, 'views', 1, true);
+ if(!empty($_GET['postviews_id']))
+ {
+ $post_id = intval($_GET['postviews_id']);
+ if($post_id > 0 && defined('WP_CACHE') && WP_CACHE) {
+ $post_views = get_post_custom($post_id);
+ $post_views = intval($post_views['views'][0]);
+ if(!update_post_meta($post_id, 'views', ($post_views + 1))) {
+ add_post_meta($post_id, 'views', 1, true);
+ }
+ echo ($post_views + 1);
}
}
+ exit();
}
### Function Show Post Views Column in WP-Admin
Oops, something went wrong.

0 comments on commit 6a0917c

Please sign in to comment.