Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/entry-vi...
File: entry-views.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Plugin Name: Entry Views
[2] Fix | Delete
* Plugin URI: http://themehybrid.com/plugins/entry-views
[3] Fix | Delete
* Description: A WordPress plugin for tracking the number of post views.
[4] Fix | Delete
* Version: 1.0.0
[5] Fix | Delete
* Author: Justin Tadlock
[6] Fix | Delete
* Author URI: http://justintadlock.com
[7] Fix | Delete
* Text Domain: entry-views
[8] Fix | Delete
* Domain Path: /languages
[9] Fix | Delete
*
[10] Fix | Delete
* Entry views is a script for calculating the number of views a post gets. It is meant to be basic and
[11] Fix | Delete
* not a full-featured solution. The idea is to allow theme/plugin authors to quickly load this file and
[12] Fix | Delete
* build functions on top of it to suit their project needs. This is an AJAX-based solution, so only visitors
[13] Fix | Delete
* to your site with JavaScript enabled in their browser will update the view count. It is possible to do this
[14] Fix | Delete
* without AJAX but not recommend (see notes below).
[15] Fix | Delete
*
[16] Fix | Delete
* Not using AJAX: You can call up ev_set_post_view_count() at any time and pass it a post ID to update the
[17] Fix | Delete
* count, but this has problems. Any links with rel="next" or rel="prefetch" will cause some browsers to prefetch
[18] Fix | Delete
* the data for that particular page. This can cause the view count to be skewed. To try and avoid this
[19] Fix | Delete
* issue, you need to disable/remove adjacent_posts_rel_link_wp_head(). However, this is not bullet-proof
[20] Fix | Delete
* as it cannot control links it doesn't know about.
[21] Fix | Delete
* @link http://core.trac.wordpress.org/ticket/14568
[22] Fix | Delete
*
[23] Fix | Delete
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
[24] Fix | Delete
* General Public License as published by the Free Software Foundation; either version 2 of the License,
[25] Fix | Delete
* or (at your option) any later version.
[26] Fix | Delete
*
[27] Fix | Delete
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
[28] Fix | Delete
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[29] Fix | Delete
*
[30] Fix | Delete
* @package EntryViews
[31] Fix | Delete
* @version 1.0.0
[32] Fix | Delete
* @author Justin Tadlock <justin@justintadlock.com>
[33] Fix | Delete
* @copyright Copyright (c) 2010 - 2014, Justin Tadlock
[34] Fix | Delete
* @link http://themehybrid.com/plugins/entry-views
[35] Fix | Delete
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
[36] Fix | Delete
*/
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* Plugin loader class.
[40] Fix | Delete
*
[41] Fix | Delete
* @since 1.0.0
[42] Fix | Delete
*/
[43] Fix | Delete
final class Entry_Views_Plugin {
[44] Fix | Delete
[45] Fix | Delete
/**
[46] Fix | Delete
* Holds the instances of this class.
[47] Fix | Delete
*
[48] Fix | Delete
* @since 1.0.0
[49] Fix | Delete
* @access private
[50] Fix | Delete
* @var object
[51] Fix | Delete
*/
[52] Fix | Delete
private static $instance;
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* The post ID to update the entry views for.
[56] Fix | Delete
*
[57] Fix | Delete
* @since 1.0.0
[58] Fix | Delete
* @access public
[59] Fix | Delete
* @var int
[60] Fix | Delete
*/
[61] Fix | Delete
public $post_id = 0;
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* Sets up needed actions/filters for the plugin to initialize.
[65] Fix | Delete
*
[66] Fix | Delete
* @since 1.0.0
[67] Fix | Delete
* @access public
[68] Fix | Delete
* @return void
[69] Fix | Delete
*/
[70] Fix | Delete
public function __construct() {
[71] Fix | Delete
[72] Fix | Delete
add_action( 'plugins_loaded', array( $this, 'i18n' ), 2 );
[73] Fix | Delete
add_action( 'plugins_loaded', array( $this, 'includes' ), 3 );
[74] Fix | Delete
add_action( 'init', array( $this, 'post_type_support' ), 10 );
[75] Fix | Delete
add_action( 'widgets_init', array( $this, 'register_widgets' ), 10 );
[76] Fix | Delete
add_action( 'template_redirect', array( $this, 'load' ), 99 );
[77] Fix | Delete
add_action( 'wp_ajax_entry_views', array( $this, 'update_ajax' ), 10 );
[78] Fix | Delete
add_action( 'wp_ajax_nopriv_entry_views', array( $this, 'update_ajax' ), 10 );
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
/**
[82] Fix | Delete
* Loads the translation files.
[83] Fix | Delete
*
[84] Fix | Delete
* @since 1.0.0
[85] Fix | Delete
* @access public
[86] Fix | Delete
* @return void
[87] Fix | Delete
*/
[88] Fix | Delete
function i18n() {
[89] Fix | Delete
load_plugin_textdomain( 'entry-views', false, 'entry-views/languages' );
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
/**
[93] Fix | Delete
* Loads the initial files needed by the plugin.
[94] Fix | Delete
*
[95] Fix | Delete
* @since 1.0.0
[96] Fix | Delete
* @access public
[97] Fix | Delete
* @return void
[98] Fix | Delete
*/
[99] Fix | Delete
function includes() {
[100] Fix | Delete
$path = trailingslashit( plugin_dir_path( __FILE__ ) );
[101] Fix | Delete
[102] Fix | Delete
require_once( "{$path}inc/functions.php" );
[103] Fix | Delete
require_once( "{$path}inc/template.php" );
[104] Fix | Delete
require_once( "{$path}inc/shortcodes.php" );
[105] Fix | Delete
require_once( "{$path}inc/widget-entry-views.php" );
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
/**
[109] Fix | Delete
* Adds support for 'entry-views' to the 'post', 'page', and 'attachment' post types (default WordPress
[110] Fix | Delete
* post types). For all other post types, the theme should explicitly register support for this feature.
[111] Fix | Delete
*
[112] Fix | Delete
* @since 1.0.0
[113] Fix | Delete
* @access public
[114] Fix | Delete
* @return void
[115] Fix | Delete
*/
[116] Fix | Delete
function post_type_support() {
[117] Fix | Delete
[118] Fix | Delete
/* Core post types. */
[119] Fix | Delete
add_post_type_support( 'post', array( 'entry-views' ) );
[120] Fix | Delete
add_post_type_support( 'page', array( 'entry-views' ) );
[121] Fix | Delete
add_post_type_support( 'attachment', array( 'entry-views' ) );
[122] Fix | Delete
[123] Fix | Delete
/* Plugin post types. */
[124] Fix | Delete
add_post_type_support( 'literature', array( 'entry-views' ) );
[125] Fix | Delete
add_post_type_support( 'portfolio_item', array( 'entry-views' ) );
[126] Fix | Delete
add_post_type_support( 'recipe', array( 'entry-views' ) );
[127] Fix | Delete
add_post_type_support( 'restaurant_item', array( 'entry-views' ) );
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
/**
[131] Fix | Delete
* Registers the plugin's widgets.
[132] Fix | Delete
*
[133] Fix | Delete
* @since 1.0.0
[134] Fix | Delete
* @access public
[135] Fix | Delete
* @return void
[136] Fix | Delete
*/
[137] Fix | Delete
public function register_widgets() {
[138] Fix | Delete
[139] Fix | Delete
register_widget( 'EV_Widget_Entry_Views' );
[140] Fix | Delete
}
[141] Fix | Delete
[142] Fix | Delete
/**
[143] Fix | Delete
* Checks if we're on a singular post view and if the current post type supports the 'entry-views'
[144] Fix | Delete
* extension. If so, set the $post_id variable and load the needed JavaScript.
[145] Fix | Delete
*
[146] Fix | Delete
* @since 1.0.0
[147] Fix | Delete
* @access public
[148] Fix | Delete
* @return void
[149] Fix | Delete
*/
[150] Fix | Delete
function load() {
[151] Fix | Delete
[152] Fix | Delete
/* Check if we're on a singular post view. */
[153] Fix | Delete
if ( is_singular() && !is_preview() ) {
[154] Fix | Delete
[155] Fix | Delete
/* Get the post object. */
[156] Fix | Delete
$post = get_queried_object();
[157] Fix | Delete
[158] Fix | Delete
/* Check if the post type supports the 'entry-views' feature. */
[159] Fix | Delete
if ( post_type_supports( $post->post_type, 'entry-views' ) ) {
[160] Fix | Delete
[161] Fix | Delete
/* Set the post ID for later use because we wouldn't want a custom query to change this. */
[162] Fix | Delete
$this->post_id = get_queried_object_id();
[163] Fix | Delete
[164] Fix | Delete
/* Enqueue the jQuery library. */
[165] Fix | Delete
wp_enqueue_script( 'jquery' );
[166] Fix | Delete
[167] Fix | Delete
/* Load the entry views JavaScript in the footer. */
[168] Fix | Delete
add_action( 'wp_footer', array( $this, 'load_scripts' ) );
[169] Fix | Delete
}
[170] Fix | Delete
}
[171] Fix | Delete
}
[172] Fix | Delete
[173] Fix | Delete
/**
[174] Fix | Delete
* Callback function hooked to 'wp_ajax_entry_views' and 'wp_ajax_nopriv_entry_views'. It checks the
[175] Fix | Delete
* AJAX nonce and passes the given $post_id to the entry views update function.
[176] Fix | Delete
*
[177] Fix | Delete
* @since 1.0.0
[178] Fix | Delete
* @access public
[179] Fix | Delete
* @return void
[180] Fix | Delete
*/
[181] Fix | Delete
function update_ajax() {
[182] Fix | Delete
[183] Fix | Delete
/* Check the AJAX nonce to make sure this is a valid request. */
[184] Fix | Delete
check_ajax_referer( 'entry_views_ajax' );
[185] Fix | Delete
[186] Fix | Delete
/* If the post ID is set, set it to the $post_id variable and make sure it's an integer. */
[187] Fix | Delete
if ( isset( $_POST['post_id'] ) )
[188] Fix | Delete
$post_id = absint( $_POST['post_id'] );
[189] Fix | Delete
[190] Fix | Delete
/* If $post_id isn't empty, pass it to the ev_set_post_view_count() function to update the view count. */
[191] Fix | Delete
if ( !empty( $post_id ) )
[192] Fix | Delete
ev_set_post_view_count( $post_id );
[193] Fix | Delete
}
[194] Fix | Delete
[195] Fix | Delete
/**
[196] Fix | Delete
* Displays a small script that sends an AJAX request for the page. It passes the $post_id to the AJAX
[197] Fix | Delete
* callback function for updating the meta.
[198] Fix | Delete
*
[199] Fix | Delete
* @since 1.0.0
[200] Fix | Delete
* @access public
[201] Fix | Delete
* @return void
[202] Fix | Delete
*/
[203] Fix | Delete
function load_scripts() {
[204] Fix | Delete
[205] Fix | Delete
/* Create a nonce for the AJAX request. */
[206] Fix | Delete
$nonce = wp_create_nonce( 'entry_views_ajax' );
[207] Fix | Delete
[208] Fix | Delete
/* Display the JavaScript needed. */
[209] Fix | Delete
echo '<script type="text/javascript">/* <![CDATA[ */ jQuery(document).ready( function() { jQuery.post( "' . admin_url( 'admin-ajax.php' ) . '", { action : "entry_views", _ajax_nonce : "' . $nonce . '", post_id : ' . absint( $this->post_id ) . ' } ); } ); /* ]]> */</script>' . "\n";
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
/**
[213] Fix | Delete
* Returns the instance.
[214] Fix | Delete
*
[215] Fix | Delete
* @since 1.0.0
[216] Fix | Delete
* @access public
[217] Fix | Delete
* @return object
[218] Fix | Delete
*/
[219] Fix | Delete
public static function get_instance() {
[220] Fix | Delete
[221] Fix | Delete
if ( !self::$instance )
[222] Fix | Delete
self::$instance = new self;
[223] Fix | Delete
[224] Fix | Delete
return self::$instance;
[225] Fix | Delete
}
[226] Fix | Delete
}
[227] Fix | Delete
[228] Fix | Delete
Entry_Views_Plugin::get_instance();
[229] Fix | Delete
[230] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function