Comparing sensitive data, confidential files or internal emails?

Most legal and privacy policies prohibit uploading sensitive data online. Diffchecker Desktop ensures your confidential information never leaves your computer. Work offline and compare documents securely.

Untitled diff

Created Diff never expires
18 removals
701 lines
25 additions
708 lines
<?php
<?php
/*
/*
* Plugin Name: Jetpack Post Views
* Plugin Name: Jetpack Post Views
* Plugin URI: http://blog.sklambert.com/jetpack-post-views/
* Plugin URI: http://blog.sklambert.com/jetpack-post-views/
* Description: Adds a widget that displays your most popular posts using Jetpack stats. <strong>NOTE:</strong> If the plugin does not work, visit the <a href="options-general.php?page=jetpack_post_views">Settings</a> page to enter a WordPress API Key.
* Description: Adds a widget that displays your most popular posts using Jetpack stats. <strong>NOTE:</strong> If the plugin does not work, visit the <a href="options-general.php?page=jetpack_post_views">Settings</a> page to enter a WordPress API Key.
* Author: Steven Lambert
* Author: Steven Lambert
* Version: 1.0.8
* Version: 1.0.8
* Author URI: http://sklambert.com
* Author URI: http://sklambert.com
* License: GPL2+
* License: GPL2+
*/
*/
// Define plugin version
// Define plugin version
if ( !defined( 'JETPACK_POST_VIEWS_VERSION_NUM' ) ) {
if ( !defined( 'JETPACK_POST_VIEWS_VERSION_NUM' ) ) {
define( 'JETPACK_POST_VIEWS_VERSION_NUM', '1.0.8' );
define( 'JETPACK_POST_VIEWS_VERSION_NUM', '1.0.8' );
}
}
/**
/**
* Jetpack Post Views
* Jetpack Post Views
*
*
* Queries the Jetpack API and adds a custom post_meta 'jetpack-post-views' that holds the total views of a
* Queries the Jetpack API and adds a custom post_meta 'jetpack-post-views' that holds the total views of a
* post as listed on Jetpack. Adds a widget to display the top posts for a site.
* post as listed on Jetpack. Adds a widget to display the top posts for a site.
* NOTE: Plugin must have a correct Wordpress API Key before the post_meta data is added.
* NOTE: Plugin must have a correct Wordpress API Key before the post_meta data is added.
*/
*/
class Jetpack_Post_Views extends WP_Widget {
class Jetpack_Post_Views extends WP_Widget {
// Private variables
// Private variables
var $apiUrlBefore = 'http://stats.wordpress.com/csv.php';
var $apiUrlBefore = 'http://stats.wordpress.com/csv.php';
var $apiUrlAfter = '&table=postviews&days=-1&limit=-1&summarize&format=json';
var $apiArgs = array(
'table' => 'postviews',
'days' => '-1',
'limit' => '-1',
'summarize' => 1,
'format' => 'json',
);
// Update test data
// Update test data
var $updateMessages = array();
var $updateMessages = array();
var $DEBUG = false;
var $DEBUG = false;
/* CONSTRUCTOR */
/* CONSTRUCTOR */
function __construct() {
function __construct() {
// Admin hooks
// Admin hooks
add_action( 'admin_init', array( &$this, 'register_setting' ) );
add_action( 'admin_init', array( &$this, 'register_setting' ) );
add_action( 'admin_menu', array( &$this, 'register_settings_page' ) );
add_action( 'admin_menu', array( &$this, 'register_settings_page' ) );
add_action( 'manage_posts_custom_column', array( &$this, 'add_post_views_column_content' ), 10, 2);
add_action( 'manage_posts_custom_column', array( &$this, 'add_post_views_column_content' ), 10, 2);
add_filter( 'plugin_action_links', array( &$this, 'settings_link' ), 10, 2 );
add_filter( 'plugin_action_links', array( &$this, 'settings_link' ), 10, 2 );
add_filter( 'manage_posts_columns', array( &$this, 'add_post_views_column' ) );
add_filter( 'manage_posts_columns', array( &$this, 'add_post_views_column' ) );
add_filter( 'manage_edit-post_sortable_columns', array( &$this, 'post_views_column_sort') );
add_filter( 'manage_edit-post_sortable_columns', array( &$this, 'post_views_column_sort') );
add_filter( 'request', array( &$this, 'post_views_column_orderby' ) );
add_filter( 'request', array( &$this, 'post_views_column_orderby' ) );
// Scheduled hooks
// Scheduled hooks
add_action( 'jetpack_post_views_scheduled_update', array( &$this, 'get_post_views' ) );
add_action( 'jetpack_post_views_scheduled_update', array( &$this, 'get_post_views' ) );
// Post hooks
// Post hooks
add_action( 'publish_post', array( &$this, 'add_jetpack_meta' ) );
add_action( 'publish_post', array( &$this, 'add_jetpack_meta' ) );
// Query the database for the blog_id
// Query the database for the blog_id
global $wpdb;
global $wpdb;
$options_table = $wpdb->base_prefix."options";
$options_table = $wpdb->base_prefix."options";
$stats_options = $wpdb->get_var( "SELECT option_value
$stats_options = $wpdb->get_var( "SELECT option_value
FROM $options_table
FROM $options_table
WHERE option_name = 'stats_options'" );
WHERE option_name = 'stats_options'" );
$stats = unserialize($stats_options);
$stats = unserialize($stats_options);
// Set blog_id
// Set blog_id
if ( $stats ) {
if ( $stats ) {
$this->blog_id = $stats['blog_id'];
$this->blog_id = $stats['blog_id'];
}
}
else { // Jetpack stats unavailable
else { // Jetpack stats unavailable
// Try another possiblility to get the blog_id
// Try another possiblility to get the blog_id
$jetpack_options = $wpdb->get_var( "SELECT option_value
$jetpack_options = $wpdb->get_var( "SELECT option_value
FROM $options_table
FROM $options_table
WHERE option_name = 'jetpack_options'" );
WHERE option_name = 'jetpack_options'" );
$jetpack = unserialize($jetpack_options);
$jetpack = unserialize($jetpack_options);
if ( $jetpack ) {
if ( $jetpack ) {
$this->blog_id = $jetpack['id'];
$this->blog_id = $jetpack['id'];
}
}
else { // Jetpack stats really unavailable
else { // Jetpack stats really unavailable
$this->blog_id = -1;
$this->blog_id = -1;
}
}
}
}
// Grab the api key if it already exists
// Grab the api key if it already exists
$api_key = get_option( 'jetpack_post_views_wp_api_key' ) != "" ? get_option( 'jetpack_post_views_wp_api_key' ) : "";
$api_key = get_option( 'jetpack_post_views_wp_api_key' ) != "" ? get_option( 'jetpack_post_views_wp_api_key' ) : "";
// Default settings
// Default settings
$this->defaultsettings = (array) apply_filters( 'jetpack_post_views_defaultsettings', array(
$this->defaultsettings = (array) apply_filters( 'jetpack_post_views_defaultsettings', array(
'version' => JETPACK_POST_VIEWS_VERSION_NUM,
'version' => JETPACK_POST_VIEWS_VERSION_NUM,
'api_key' => $api_key,
'api_key' => $api_key,
'blog_id' => $this->blog_id,
'blog_id' => $this->blog_id,
'blog_uri' => get_bloginfo( 'wpurl' ),
'blog_uri' => get_bloginfo( 'wpurl' ),
'changed' => 0,
'changed' => 0,
'connect_blog_id' => 0,
'connect_blog_id' => 0,
'connect_blog_uri' => 0
'connect_blog_uri' => 0
) );
) );
// Create the settings array by merging the user's settings and the defaults
// Create the settings array by merging the user's settings and the defaults
$usersettings = (array) get_option('jetpack_post_views_settings');
$usersettings = (array) get_option('jetpack_post_views_settings');
$this->settings = wp_parse_args( $usersettings, $this->defaultsettings );
$this->settings = wp_parse_args( $usersettings, $this->defaultsettings );
// Controls and options
// Controls and options
$widget_ops = array(
$widget_ops = array(
'classname' => 'jetpack-post-views',
'classname' => 'jetpack-post-views',
'description' => __( 'Your site\'s most popular posts using Jetpack stats', 'jetpack-post-views')
'description' => __( 'Your site\'s most popular posts using Jetpack stats', 'jetpack-post-views')
);
);
$control_ops = array(
$control_ops = array(
'id_base' => 'jetpack-post-views-widget'
'id_base' => 'jetpack-post-views-widget'
);
);
// Set widget information
// Set widget information
$this->WP_Widget( 'jetpack-post-views-widget', __( 'Jetpack Post Views Widget', 'jetpack-post-views'), $widget_ops, $control_ops );
$this->WP_Widget( 'jetpack-post-views-widget', __( 'Jetpack Post Views Widget', 'jetpack-post-views'), $widget_ops, $control_ops );
}
}
/* REGISTER SETTINGS PAGE */
/* REGISTER SETTINGS PAGE */
function register_settings_page() {
function register_settings_page() {
add_options_page( __( 'Jetpack Post Views Settings', 'jetpack-post-views' ), __( 'Jetpack Post Views', 'jetpack-post-views' ), 'manage_options', 'jetpack_post_views', array( &$this, 'settings_page' ) );
add_options_page( __( 'Jetpack Post Views Settings', 'jetpack-post-views' ), __( 'Jetpack Post Views', 'jetpack-post-views' ), 'manage_options', 'jetpack_post_views', array( &$this, 'settings_page' ) );
}
}
/* REGISTER PLUGIN SETTINGS */
/* REGISTER PLUGIN SETTINGS */
function register_setting() {
function register_setting() {
register_setting( 'jetpack_post_views_settings', 'jetpack_post_views_settings', array( &$this, 'validate_settings' ) );
register_setting( 'jetpack_post_views_settings', 'jetpack_post_views_settings', array( &$this, 'validate_settings' ) );
}
}
/* ADD JETPACK POST META ON POST PUBLISH */
/* ADD JETPACK POST META ON POST PUBLISH */
function add_jetpack_meta() {
function add_jetpack_meta() {
global $post;
global $post;
add_post_meta( $post->ID, 'jetpack-post-views', 0, true );
add_post_meta( $post->ID, 'jetpack-post-views', 0, true );
}
}
/* ADD POST VIEWS TO POST ADMIN PAGE */
/* ADD POST VIEWS TO POST ADMIN PAGE */
function add_post_views_column( $defaults ) {
function add_post_views_column( $defaults ) {
$defaults['post_views'] = __( 'Total Views', 'jetpack-post-views' );
$defaults['post_views'] = __( 'Total Views', 'jetpack-post-views' );
return $defaults;
return $defaults;
}
}
/* SHOW THE TOTAL NUMBER OF VIEWS FOR A POST */
/* SHOW THE TOTAL NUMBER OF VIEWS FOR A POST */
function add_post_views_column_content( $column_name, $post_ID ) {
function add_post_views_column_content( $column_name, $post_ID ) {
if ($column_name == 'post_views') {
if ($column_name == 'post_views') {
echo number_format_i18n( get_post_meta( $post_ID, "jetpack-post-views", true ) ).__( ' views', 'jetpack-post-views' );
echo number_format_i18n( get_post_meta( $post_ID, "jetpack-post-views", true ) ).__( ' views', 'jetpack-post-views' );
}
}
}
}
/* ALLOW SORTING OF POST VIEW COLUMN */
/* ALLOW SORTING OF POST VIEW COLUMN */
function post_views_column_sort( $columns ) {
function post_views_column_sort( $columns ) {
$columns['post_views'] = 'post_views';
$columns['post_views'] = 'post_views';
return $columns;
return $columns;
}
}
/* SORT POST VIEW COLUMN BY VIEWS */
/* SORT POST VIEW COLUMN BY VIEWS */
function post_views_column_orderby( $vars ) {
function post_views_column_orderby( $vars ) {
if ( isset( $vars['orderby'] ) && 'post_views' == $vars['orderby'] ) {
if ( isset( $vars['orderby'] ) && 'post_views' == $vars['orderby'] ) {
$vars = array_merge( $vars, array(
$vars = array_merge( $vars, array(
'meta_key' => 'jetpack-post-views',
'meta_key' => 'jetpack-post-views',
'orderby' => 'meta_value_num'
'orderby' => 'meta_value_num'
) );
) );
}
}
return $vars;
return $vars;
}
}
/* ADD A "SETTINGS" LINK TO PLUGINS PAGE */
/* ADD A "SETTINGS" LINK TO PLUGINS PAGE */
function settings_link( $links, $file ) {
function settings_link( $links, $file ) {
static $this_plugin;
static $this_plugin;
if( empty($this_plugin) )
if( empty($this_plugin) )
$this_plugin = plugin_basename(__FILE__);
$this_plugin = plugin_basename(__FILE__);
if ( $file == $this_plugin )
if ( $file == $this_plugin )
$links[] = '<a href="' . admin_url( 'options-general.php?page=jetpack_post_views' ) . '">' . __( 'Settings', 'jetpack-post-views' ) . '</a>';
$links[] = '<a href="' . admin_url( 'options-general.php?page=jetpack_post_views' ) . '">' . __( 'Settings', 'jetpack-post-views' ) . '</a>';
return $links;
return $links;
}
}
/* SETTINGS PAGE */
/* SETTINGS PAGE */
function settings_page() { ?>
function settings_page() { ?>
<style>
<style>
.light {
.light {
height: 14px;
height: 14px;
width: 14px;
width: 14px;
border-radius: 14px;
border-radius: 14px;
-webkit-border-radius: 14px;
-webkit-border-radius: 14px;
-moz-border-radius: 14px;
-moz-border-radius: 14px;
-ms-border-radius: 14px;
-ms-border-radius: 14px;
-o-border-radius: 14px;
-o-border-radius: 14px;
position: relative;
position: relative;
top: 3px;
top: 3px;
box-shadow:
box-shadow:
0 1px 2px #fff,
0 1px 2px #fff,
0 -1px 1px #666,
0 -1px 1px #666,
inset 1px -2px 6px rgba(0,0,0,0.5),
inset 1px -2px 6px rgba(0,0,0,0.5),
inset -1px 1px 6px rgba(255,255,255,0.8);
inset -1px 1px 6px rgba(255,255,255,0.8);
}
}
.green {
.green {
background-color: #00b028;
background-color: #00b028;
}
}
.red {
.red {
background-color: #d20406;
background-color: #d20406;
}
}
.inner-light {
.inner-light {
position: absolute;
position: absolute;
top: -1px;
top: -1px;
left: 5px;
left: 5px;
}
}
.green .inner-light {
.green .inner-light {
background-color: rgba(123,252,149,0.7);
background-color: rgba(123,252,149,0.7);
border: 3px solid rgba(47,205,82,0.7);
border: 3px solid rgba(47,205,82,0.7);
width: 1px;
width: 1px;
height: 1px;
height: 1px;
border-radius: 1px;
border-radius: 1px;
-webkit-border-radius: 1px;
-webkit-border-radius: 1px;
-moz-border-radius: 1px;
-moz-border-radius: 1px;
-ms-border-radius: 1px;
-ms-border-radius: 1px;
-o-border-radius: 1px;
-o-border-radius: 1px;
filter: blur(1.5px);
filter: blur(1.5px);
-webkit-filter: blur(1.5px);
-webkit-filter: blur(1.5px);
-moz-filter: blur(1.5px);
-moz-filter: blur(1.5px);
-ms-filter: blur(1.5px);
-ms-filter: blur(1.5px);
-o-filter: blur(1.5px);
-o-filter: blur(1.5px);
}
}
.red .inner-light {
.red .inner-light {
background-color: rgba(225,162,157,0.7);
background-color: rgba(225,162,157,0.7);
border: 1px solid rgba(222,222,222,0.7);
border: 1px solid rgba(222,222,222,0.7);
width: 7px;
width: 7px;
height: 7px;
height: 7px;
border-radius: 7px;
border-radius: 7px;
-webkit-border-radius: 7px;
-webkit-border-radius: 7px;
-moz-border-radius: 7px;
-moz-border-radius: 7px;
-ms-border-radius: 7px;
-ms-border-radius: 7px;
-o-border-radius: 7px;
-o-border-radius: 7px;
filter: blur(2px);
filter: blur(2px);
-webkit-filter: blur(2px);
-webkit-filter: blur(2px);
-moz-filter: blur(2px);
-moz-filter: blur(2px);
-ms-filter: blur(2px);
-ms-filter: blur(2px);
-o-filter: blur(2px);
-o-filter: blur(2px);
}
}
</style>
</style>
<div class="wrap">
<div class="wrap">
<?php if ( function_exists('screen_icon') ) screen_icon(); ?>
<?php if ( function_exists('screen_icon') ) screen_icon(); ?>
<h2><?php _e( 'Jetpack Post Views Settings', 'jetpack-post-views' ); ?></h2>
<h2><?php _e( 'Jetpack Post Views Settings', 'jetpack-post-views' ); ?></h2>
<p><?php _e( 'Use the settings below if the plugin is unable to connect to Jetpack using the function <code>stats_get_csv()</code>.', 'jetpack-post-views' ); ?></p>
<p><?php _e( 'Use the settings below if the plugin is unable to connect to Jetpack using the function <code>stats_get_csv()</code>.', 'jetpack-post-views' ); ?></p>
<form method="post" action="options.php">
<form method="post" action="options.php">
<?php settings_fields('jetpack_post_views_settings'); ?>
<?php settings_fields('jetpack_post_views_settings'); ?>
<table class="form-table">
<table class="form-table">
<tr valign="top">
<tr valign="top">
<th scope="row"><label for="jetpack-post-views-api-key"><?php _e( 'WordPress API Key', 'jetpack-post-views' ); ?></label></th>
<th scope="row"><label for="jetpack-post-views-api-key"><?php _e( 'WordPress API Key', 'jetpack-post-views' ); ?></label></th>
<td><input name="jetpack_post_views_settings[api_key]" type="text" id="jetpack-post-views-api-key" value="<?php echo esc_attr( $this->settings['api_key'] ); ?>" class="regular-text" placeholder="<?php _e("https://apikey.wordpress.com/", 'jetpack-post-views'); ?>" /></td>
<td><input name="jetpack_post_views_settings[api_key]" type="text" id="jetpack-post-views-api-key" value="<?php echo esc_attr( $this->settings['api_key'] ); ?>" class="regular-text" placeholder="<?php _e("https://apikey.wordpress.com/", 'jetpack-post-views'); ?>" /></td>
</tr>
</tr>
<tr valign="top">
<tr valign="top">
<th scope="row"><label for="jetpack-post-views-blog_uri"><?php _e( 'Blog URI', 'jetpack-post-views' ); ?></label></th>
<th scope="row"><label for="jetpack-post-views-blog_uri"><?php _e( 'Blog URI', 'jetpack-post-views' ); ?></label></th>
<td><input name="jetpack_post_views_settings[blog_uri]" type="text" id="jetpack-post-views-blog-uri" value="<?php echo esc_attr( $this->settings['blog_uri'] ); ?>" class="regular-text" /></td>
<td><input name="jetpack_post_views_settings[blog_uri]" type="text" id="jetpack-post-views-blog-uri" value="<?php echo esc_attr( $this->settings['blog_uri'] ); ?>" class="regular-text" /></td>
</tr>
</tr>
</table>
</table>
<h3><?php _e( 'Connections', 'jetpack-post-views' ); ?></h3>
<h3><?php _e( 'Connections', 'jetpack-post-views' ); ?></h3>
<p><?php _e( 'Shows the status of connections to the Jetpack API. If at least one of the below connections shows green, the plugin should work properly.<br>Stats updated using the first connection available in the order that they are listed.', 'jetpack-post-views' ); ?></p>
<p><?php _e( 'Shows the status of connections to the Jetpack API. If at least one of the below connections shows green, the plugin should work properly.<br>Stats updated using the first connection available in the order that they are listed.', 'jetpack-post-views' ); ?></p>
<?php
<?php
if ( $this->settings['changed'] ) {
if ( $this->settings['changed'] ) {
// Test the URI connection
// Test the URI connection
$middle = '?api_key='.$this->settings['api_key'].'&blog_uri='.$this->settings['blog_uri'];
$args = array();
$url = $this->apiUrlBefore.$middle.$this->apiUrlAfter;
$args['api_key'] = $this->settings['api_key'];
$json = file_get_contents( $url );
$args['blog_uri'] = $this->settings['blog_uri'];
$data = json_decode( $json, true );
$args = $args + $this->apiArgs;
$url = add_query_arg( $args, $this->apiUrlBefore );
$json = wp_remote_get( $url );
$data = json_decode( $json['body'], true );
if ( $data[0]['postviews'] ) { // We got data back
if ( $data[0]['postviews'] ) { // We got data back
$this->settings['connect_blog_uri'] = 1;
$this->settings['connect_blog_uri'] = 1;
}
}
else {
else {
$this->settings['connect_blog_uri'] = 0;
$this->settings['connect_blog_uri'] = 0;
}
}
// Test the Blog ID connection
// Test the Blog ID connection
$middle = '?api_key='.$this->settings['api_key'].'&blog_id='.$this->settings['blog_id'];
$args = array();
$url = $this->apiUrlBefore.$middle.$this->apiUrlAfter;
$args['api_key'] = $this->settings['api_key'];
$json = file_get_contents( $url );
$args['blog_id'] = $this->settings['blog_id'];
$data = json_decode( $json, true );
$args = $args + $this->apiArgs;
$url = add_query_arg( $args, $this->apiUrlBefore );
$json = wp_remote_get( $url );
$data = json_decode( $json['body'], true );
if ( $data[0]['postviews'] ) { // We got data back
if ( $data[0]['postviews'] ) { // We got data back
$this->settings['connect_blog_id'] = 1;
$this->settings['connect_blog_id'] = 1;
}
}
else {
else {
$this->settings['connect_blog_id'] = 0;
$this->settings['connect_blog_id'] = 0;
}
}
$this->get_post_views();
$this->get_post_views();
}
}
?>
?>
<input type="hidden" name="jetpack_post_views_settings[connect_blog_uri]" id="jetpack-post-views-connect-blog-id" value="<?php echo esc_attr( $this->settings['connect_blog_uri'] ); ?>" />
<input type="hidden" name="jetpack_post_views_settings[connect_blog_uri]" id="jetpack-post-views-connect-blog-id" value="<?php echo esc_attr( $this->settings['connect_blog_uri'] ); ?>" />
<input type="hidden" name="jetpack_post_views_settings[connect_blog_id]" id="jetpack-post-views-connect-blog-id" value="<?php echo esc_attr( $this->settings['connect_blog_id'] ); ?>" />
<input type="hidden" name="jetpack_post_views_settings[connect_blog_id]" id="jetpack-post-views-connect-blog-id" value="<?php echo esc_attr( $this->settings['connect_blog_id'] ); ?>" />
<table class="form-table">
<table class="form-table">
<fieldset>
<fieldset>
<tr valign="top">
<tr valign="top">
<th scope="row"><?php _e( 'Function <code>stats_get_csv()</code> exists', 'jetpack-post-views' ); ?></th>
<th scope="row"><?php _e( 'Function <code>stats_get_csv()</code> exists', 'jetpack-post-views' ); ?></th>
<td>
<td>
<?php if ( function_exists('stats_get_csv') ) { ?>
<?php if ( function_exists('stats_get_csv') ) { ?>
<div class="light green"><div class="inner-light"></div></div>
<div class="light green"><div class="inner-light"></div></div>
<?php } else { ?>
<?php } else { ?>
<div class="light red"><div class="inner-light"></div></div>
<div class="light red"><div class="inner-light"></div></div>
<?php } ?>
<?php } ?>
</td>
</td>
</tr>
</tr>
<tr valign="top">
<tr valign="top">
<th scope="row"><?php _e( 'Can connect using Blog URI', 'jetpack-post-views' ); ?></th>
<th scope="row"><?php _e( 'Can connect using Blog URI', 'jetpack-post-views' ); ?></th>
<td>
<td>
<?php if ( $this->settings['connect_blog_uri'] ) { ?>
<?php if ( $this->settings['connect_blog_uri'] ) { ?>
<div class="light green"><div class="inner-light"></div></div>
<div class="light green"><div class="inner-light"></div></div>
<?php } else { ?>
<?php } else { ?>
<div class="light red"><div class="inner-light"></div></div>
<div class="light red"><div class="inner-light"></div></div>
<?php } ?>
<?php } ?>
</td>
</td>
</tr>
</tr>
<tr valign="top">
<tr valign="top">
<th scope="row"><?php _e( 'Can connect using Blog ID', 'jetpack-post-views' ); ?></th>
<th scope="row"><?php _e( 'Can connect using Blog ID', 'jetpack-post-views' ); ?></th>
<td>
<td>
<?php if ( $this->settings['connect_blog_id'] ) { ?>
<?php if ( $this->settings['connect_blog_id'] ) { ?>
<div class="light green"><div class="inner-light"></div></div>
<div class="light green"><div class="inner-light"></div></div>
<?php } else { ?>
<?php } else { ?>
<div class="light red"><div class="inner-light"></div></div>
<div class="light red"><div class="inner-light"></div></div>
<?php } ?>
<?php } ?>
</td>
</td>
</tr>
</tr>
</fieldset>
</fieldset>
</table>
</table>
<p class="submit">
<p class="submit">
<?php
<?php
if ( function_exists( 'submit_button' ) ) {
if ( function_exists( 'submit_button' ) ) {
submit_button( null, 'primary', 'jetpack-post-views-submit', false );
submit_button( null, 'primary', 'jetpack-post-views-submit', false );
} else {
} else {
echo '<input type="submit" name="jetpack-post-views-submit" class="button-primary" value="' . __( 'Save Changes', 'jetpack-post-views' ) . '" />' . "\n";
echo '<input type="submit" name="jetpack-post-views-submit" class="button-primary" value="' . __( 'Save Changes', 'jetpack-post-views' ) . '" />' . "\n";
}
}
?>
?>
</p>
</p>
<p>
<p>
<h3>Donate to Help Support this Plugin</h3>
<h3>Donate to Help Support this Plugin</h3>
<p>Jetpack Post Views remains a free plugin thanks to donations from supporters like you. Donations like yours help me to continue supporting this plugin with regular updates and bug fixes. Thanks for being a supporter!</p>
<p>Jetpack Post Views remains a free plugin thanks to donations from supporters like you. Donations like yours help me to continue supporting this plugin with regular updates and bug fixes. Thanks for being a supporter!</p>
<p> - Steven Lambert</p>
<p> - Steven Lambert</p>
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CPUDV9EYETJYJ" title="Donate to this plugin!">
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CPUDV9EYETJYJ" title="Donate to this plugin!">
<img src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" alt="" />
<img src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" alt="" />
</a>
</a>
</p>
</p>
<?php
<?php
if ($this->DEBUG) {
if ($this->DEBUG) {
echo "<div class='widefat'><h3>Plugin options</h3><pre>";
echo "<div class='widefat'><h3>Plugin options</h3><pre>";
foreach ($this->settings as $key => $value) {
foreach ($this->settings as $key => $value) {
echo "[$key]: $value\n";
echo "[$key]: $value\n";
}
}
echo "</pre></div>";
echo "</pre></div>";
if (function_exists('stats_get_csv')) {
if (function_exists('stats_get_csv')) {
echo "<br>stats_get_csv function exists<br>";
echo "<br>stats_get_csv function exists<br>";
}
}
else {
else {
echo "<br>stats_get_csv function does not exist<br>";
echo "<br>stats_get_csv function does not exist<br>";
}
}
$this->get_post_views();
$this->get_post_views();
ksort($this->updateMessages);
ksort($this->updateMessages);
echo "<br><div class='widefat'><h3>Update Messages by Post ID</h3><pre>";
echo "<br><div class='widefat'><h3>Update Messages by Post ID</h3><pre>";
foreach ($this->updateMessages as $key => $value) {
foreach ($this->updateMessages as $key => $value) {
if ( gettype($value) == "array") {
if ( gettype($value) == "array") {
echo "[$key]: ";
echo "[$key]: ";
print_r($value);
print_r($value);
}
}
else {
else {
echo "[$key]: $value\n";
echo "[$key]: $value\n";
}
}
}
}
echo "</pre></div>";
echo "</pre></div>";
}
}
?>
?>
</form>
</form>
</div>
</div>
<?php
<?php
}
}
/* WIDGET OUTPUT */
/* WIDGET OUTPUT */
function widget( $args, $instance ) {
function widget( $args, $instance ) {
global $post;
global $post;
extract ( $args );
extract ( $args );
$title = apply_filters('widget_title', $instance['title'] );
$title = apply_filters('widget_title', $instance['title'] );
$results = "";
$results = "";
$exclude_posts = explode( ',', $instance['exclude_posts'] );
$exclude_posts = explode( ',', $instance['exclude_posts'] );
echo $before_widget;
echo $before_widget;
// Print the title
// Print the title
if ( $title )
if ( $title )
echo $before_title . $title . $after_title;
echo $before_title . $title . $after_title;
?>
?>
<style>
<style>
.JPV_list {
.JPV_list {
overflow: hidden;
overflow: hidden;
}
}
.JPV_thumbnail {
.JPV_thumbnail {
width: 45%;
width: 45%;
}
}
.JPV_thumbnail > .JPV_thumbnail_img {
.JPV_thumbnail > .JPV_thumbnail_img {
max-width: 125px;
max-width: 125px;
height: auto;
height: auto;
}
}
.JPV_thumbnail + .JPV_text {
.JPV_thumbnail + .JPV_text {
width: 45%;
width: 45%;
padding-bottom: 10px;
padding-bottom: 10px;
text-align: center;
text-align: center;
margin-top: -5px;
margin-top: -5px;
}
}
.JPV_thumbnail_title {
.JPV_thumbnail_title {
float: left;
float: left;
width: 21.276596%;
width: 21.276596%;
}
}
.JPV_thumbnail_title > .JPV_thumbnail_img {
.JPV_thumbnail_title > .JPV_thumbnail_img {
max-width: 40px;
max-width: 40px;
height: auto;
height: auto;
}
}
.JPV_thumbnail_title + .JPV_text {
.JPV_thumbnail_title + .JPV_text {
float: right;
float: right;
width: 73.404255%;
width: 73.404255%;
padding-bottom: 10px;
padding-bottom: 10px;
}
}
</style>
</style>
<?php
<?php
// Get all categories
// Get all categories
$categories = get_categories();
$categories = get_categories();
// Get all post types
// Get all post types
$all_post_types = array();
$all_post_types = array();
$all_post_types = get_post_types( array( '_builtin' => false ), 'names' );
$all_post_types = get_post_types( array( '_builtin' => false ), 'names' );
$all_post_types['post'] = 'post';
$all_post_types['post'] = 'post';
// Filter which post types are displayed
// Filter which post types are displayed
$post_types = array();
$post_types = array();
foreach ( $all_post_types as $key => $value ) {
foreach ( $all_post_types as $key => $value ) {
if ( $instance['type_'.$key] ) {
if ( $instance['type_'.$key] ) {
array_push($post_types, $key);
array_push($post_types, $key);
}
}
}
}
// Grab the top posts and display them using the stats_get_csv function
// Grab the top posts and display them using the stats_get_csv function
if ( $instance['days'] != '-1' && function_exists('stats_get_csv') ) {
if ( $instance['days'] != '-1' && function_exists('stats_get_csv') ) {
$posts = stats_get_csv('postviews', 'days='.$instance['days'].'&limit=-1' );
$posts = stats_get_csv('postviews', 'days='.$instance['days'].'&limit=-1' );
$exclude_posts = explode( ',', $instance['exclude_posts'] );
$exclude_posts = explode( ',', $instance['exclude_posts'] );
$count = 0;
$count = 0;
// Print top posts in order
// Print top posts in order
$results = "<ul>";
$results = "<ul>";
foreach( $posts as $post ) {
foreach( $posts as $post ) {
// Stop printing posts if we reach the limit
// Stop printing posts if we reach the limit
if ( $count >= intval( $instance['num_posts'] ) ) {
if ( $count >= intval( $instance['num_posts'] ) ) {
break;
break;
}
}
// // Get all categories
// // Get all categories
// $cat_list = array();
// $cat_list = array();
// foreach ( $categories as $key => $value ) {
// foreach ( $categories as $key => $value ) {
// if ( $instance['category_'.$value->slug] ) {
// if ( $instance['category_'.$value->slug] ) {
// array_push($cat_list, $value->cat_ID);
// array_push($cat_list, $value->cat_ID);
// }
// }
// }
// }
// // Get the post's categories
// // Get the post's categories
// $cat_ids = array();
// $cat_ids = array();
// $category = get_the_category( $post['post_id'] );
// $category = get_the_category( $post['post_id'] );
// foreach ($category as $cat) {
// foreach ($category as $cat) {
// array_push($cat_ids, $cat->cat_ID);
// array_push($cat_ids, $cat->cat_ID);
// }
// }
// $inCat = false;
// $inCat = false;
// if ( array_intersect($cat_list, $cat_ids) ) {
// if ( array_intersect($cat_list, $cat_ids) ) {
// $inCat = true;
// $inCat = true;
// }
// }
// Only display posts and from the selected categories
// Only display posts and from the selected categories
if ( $post['post_id'] && get_post( $post['post_id'] ) && in_array( get_post_type( $post['post_id'] ), $post_types ) && !in_array( $post['post_id'], $exclude_posts) ) {
if ( $post['post_id'] && get_post( $post['post_id'] ) && in_array( get_post_type( $post['post_id'] ), $post_types ) && !in_array( $post['post_id'], $exclude_posts) ) {
$title = get_the_title( $post['post_id'] );
$title = get_the_title( $post['post_id'] );
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post['post_id'] ), 'post-thumbnail' );
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post['post_id'] ), 'post-thumbnail' );
$views = number_format_i18n( $post['views'] ? $post['views'] : 0 ).__( ' views', 'jetpack-post-views' );
$views = number_format_i18n( $post['views'] ? $post['views'] : 0 ).__( ' views', 'jetpack-post-views' );
$results .= '<li class="JPV_list"><a href="'.get_permalink( $post['post_id'] ).'" title="'.$title.'" class="JPV_'.$instance["display_type"].'">';
$results .= '<li class="JPV_list"><a href="'.get_permalink( $post['post_id'] ).'" title="'.$title.'" class="JPV_'.$instance["display_type"].'">';
switch ( $instance["display_type"] ) {
switch ( $instance["display_type"] ) {
case "thumbnail":
case "thumbnail":
$results .= '<img src="'.$thumbnail[0].'" class="JPV_thumbnail_img"/></a>';
$results .= '<img src="'.$thumbnail[0].'" class="JPV_thumbnail_img"/></a>';
if ( $instance["show_views"] )
if ( $instance["show_views"] )
$results .= '<div class="JPV_text">'.$views.'</div>';
$results .= '<div class="JPV_text">'.$views.'</div>';
break;
break;
case "thumbnail_title":
case "thumbnail_title":
$results .= '<img src="'.$thumbnail[0].'" class="JPV_thumbnail_img"/></a><div class="JPV_text"><a href="'.get_permalink( $post['post_id'] ).'" title="'.$title.'">'.$title.'</a>';
$results .= '<img src="'.$thumbnail[0].'" class="JPV_thumbnail_img"/></a><div class="JPV_text"><a href="'.get_permalink( $post['post_id'] ).'" title="'.$title.'">'.$title.'</a>';
if ( $instance["show_views"] )
if ( $instance["show_views"] )
$results .= " - ".$views.'</div>';
$results .= " - ".$views.'</div>';
break;
break;
default:
default:
$results .= $title.'</a>';
$results .= $title.'</a>';
if ( $instance["show_views"] )
if ( $instance["show_views"] )
$results .= " - ".$views;
$results .= " - ".$views;
}
}
$results .= '</li>';
$results .= '</li>';
$count++;
$count++;
}
}
}
}
$results .= "</ul>";
$results .= "</ul>";
}
}
// Else grab the top posts using the post meta
// Else grab the top posts using the post meta
else {
else {
// Filter results by category
// Filter results by category
$cat_list = array();
$cat_list = array();
foreach ( $categories as $key => $value ) {
foreach ( $categories as $key => $value ) {
if ( $instance['category_'.$value->slug] ) {
if ( $instance['category_'.$value->slug] ) {
array_push($cat_list, $value->cat_ID);
array_push($cat_list, $value->cat_ID);
}
}
}
}
$category = implode(',', $cat_list);
$category = implode(',', $cat_list);
$args = array(
$args = array(
'numberposts' => $instance['num_posts'],
'numberposts' => $instance['num_posts'],
'orderby' => 'meta_value_num',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'order' => 'DESC',
'exclude' => $instance['exclude_posts'],
'exclude' => $instance['exclude_posts'],
'meta_key' => 'jetpack-post-views',
'meta_key' => 'jetpack-post-views',
'post_type' => $post_types,
'post_type' => $post_types,
'category' => $category
'category' => $category
);
);
$posts = get_posts( $args );
$posts = get_posts( $args );
// Print top posts in order
// Print top posts in order
$results = "<ul>";
$results = "<ul>";
foreach( $posts as $post ) {
foreach( $posts as $post ) {
$title = get_the_title( $post->ID );
$title = get_the_title( $post->ID );
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' );
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' );
$views = number_format_i18n( get_post_meta( $post->ID, "jetpack-post-views", true ) ).__( ' views', 'jetpack-post-views' );
$views = number_format_i18n( get_post_meta( $post->ID, "jetpack-post-views", true ) ).__( ' views', 'jetpack-post-views' );
$results .= '<li class="JPV_list"><a href="'.get_permalink( $post->ID ).'" title="'.$title.'" class="JPV_'.$instance["display_type"].'">';
$results .= '<li class="JPV_list"><a href="'.get_permalink( $post->ID ).'" title="'.$title.'" class="JPV_'.$instance["display_type"].'">';
switch ( $instance["display_type"] ) {
switch ( $instance["display_type"] ) {
case "thumbnail":
case "thumbnail":
$results .= '<img src="'.$thumbnail[0].'" class="JPV_thumbnail_img"/></a>';
$results .= '<img src="'.$thumbnail[0].'" class="JPV_thumbnail_img"/></a>';
if ( $instance["show_views"] )
if ( $instance["show_views"] )
$results .= '<div class="JPV_text">'.$views.'</div>';
$results .= '<div class="JPV_text">'.$views.'</div>';
break;
break;
case "thumbnail_title":
case "thumbnail_title":
$results .= '<img src="'.$thumbnail[0].'" class="JPV_thumbnail_img"/></a><div class="JPV_text"><a href="'.get_permalink( $post->ID ).'" title="'.$title.'">'.$title.'</a>';
$results .= '<img src="'.$thumbnail[0].'" class="JPV_thumbnail_img"/></a><div class="JPV_text"><a href="'.get_permalink( $post->ID ).'" title="'.$title.'">'.$title.'</a>';
if ( $instance["show_views"] )
if ( $instance["show_views"] )
$results .= " - ".$views.'</div>';
$results .= " - ".$views.'</div>';
break;
break;
default:
default:
$results .= $title.'</a>';
$results .= $title.'</a>';
if ( $instance["show_views"] )
if ( $instance["show_views"] )
$results .= " - ".$views;
$results .= " - ".$views;
}
}
$results .= '</li>';
$results .= '</li>';
}
}
$results .= "</ul>";
$results .= "</ul>";
}
}
echo $results;
echo $results;
echo $after_widget;
echo $after_widget;
}
}
/* UPDATE WIDGET OPTIONS */
/* UPDATE WIDGET OPTIONS */
function update( $new_instance, $old_instance ) {
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance = $old_instance;
// Check nonce
// Check nonce
check_admin_referer('jetpack-post-views-widget-form-submission');
check_admin_referer('jetpack-post-views-widget-form-submission');
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['show_views'] = strip_tags( $new_instance['show_views'] );
$instance['show_views'] = strip_tags( $new_instance['show_views'] );
$instance['days'] = strip_tags( $new_instance['days'] );
$instance['days'] = strip_tags( $new_instance['days'] );
$instance['exclude_custom_types'] = strip_tags( $new_instance['exclude_custom_types'] );
$instance['exclude_custom_types'] = strip_tags( $new_instance['exclude_custom_types'] );
$instance['exclude_posts'] = strip_tags( $new_instance['exclude_posts'] );
$instance['exclude_posts'] = strip_tags( $new_instance['exclude_posts'] );
$instance['display_type'] = strip_tags( $new_instance['display_type'] );
$instance['display_type'] = strip_tags( $new_instance['display_type'] );
$instance['display_post_types'] = strip_tags( $new_instance['display_post_types'] );
$instance['display_post_types'] = strip_tags( $new_instance['display_post_types'] );
// Get all post types
// Get all post types
$post_types = get_post_types( array( '_builtin' => false ), 'names' );
$post_types = get_post_types( array( '_builtin' => false ), 'names' );
$post_types['post'] = 'post';
$post_types['post'] = 'post';
foreach ( $post_types as $key => $value ) {
foreach ( $post_types as $key => $value ) {
if ( $value != 'safecss' ) {
if ( $value != 'safecss' ) {
$instance['type_'.$key] = strip_tags( $new_instance['type_'.$key] );
$instance['type_'.$key] = strip_tags( $new_instance['type_'.$key] );
}
}
}
}
// Get all categories
// Get all categories
$categories = get_categories();
$categories = get_categories();
foreach ( $categories as $key => $value ) {
foreach ( $categories as $key => $value ) {
$instance['category_'.$value->slug] = strip_tags( $new_instance['category_'.$value->slug] );
$instance['category_'.$value->slug] = strip_tags( $new_instance['category_'.$value->slug] );
}
}
// Set default number of posts to display if invalid option
// Set default number of posts to display if invalid option
$num_posts = intval( strip_tags( $new_instance['num_posts'] ) );
$num_posts = intval( strip_tags( $new_instance['num_posts'] ) );
$instance['num_posts'] = ($num_posts > 0 ? $num_posts : 5);
$instance['num_posts'] = ($num_posts > 0 ? $num_posts : 5);
return $instance;
return $instance;
}
}
/* DISPLAY WIDGET OPTIONS */
/* DISPLAY WIDGET OPTIONS */
function form( $instance ) {
function form( $instance ) {
// Default widget settings
// Default widget settings
$defaults = array(
$defaults = array(
'title' => __( 'Most Popular Posts', 'jetpack-post-views' ),
'title' => __( 'Most Popular Posts', 'jetpack-post-views' ),
'error' => '',
'error' => '',
'num_posts' => 5,
'num_posts' => 5,
'days' => '-1',
'days' => '-1',
'show_views' => false,
'show_views' => false,
'display_type' => 'title',
'display_type' => 'title',
'exclude_posts' => '',
'exclude_posts' => '',
'display_post_types' => ''
'display_post_types' => ''
);
);
// Get all post types
// Get all post types
$post_types = get_post_types( array( '_builtin' => false ), 'names' );
$post_types = get_post_types( array( '_builtin' => false ), 'names' );
$post_types['post'] = 'post';
$post_types['post'] = 'post';
foreach ( $post_types as $key => $value ) {
foreach ( $post_types as $key => $value ) {
if ( $value != 'safecss' ) { // I have no idea what this is but it's not a valid post type
if ( $value != 'safecss' ) { // I have no idea what this is but it's not a valid post type
$defaults['type_'.$key] = 'on';
$defaults['type_'.$key] = 'on';
}
}
}
}
// Get all categories
// Get all categories
$categories = get_categories();
$categories = get_categories();
foreach ( $categories as $key => $value ) {
foreach ( $categories as $key => $value ) {
$defaults['category_'.$value->slug] = 'on';
$defaults['category_'.$value->slug] = 'on';
}
}
$instance = wp_parse_args( (array) $instance, $defaults );
$instance = wp_parse_args( (array) $instance, $defaults );
// echo "<pre>";
// echo "<pre>";
// print_r($instance);
// print_r($instance);
// echo "</pre>";
// echo "</pre>";
// Set nonce
// Set nonce
if ( function_exists('wp_nonce_field') ) {
if ( function_exists('wp_nonce_field') ) {
wp_nonce_field( 'jetpack-post-views-widget-form-submission' );
wp_nonce_field( 'jetpack-post-views-widget-form-submission' );
echo "\n<!-- end of wp_nonce_field -->\n";
echo "\n<!-- end of wp_nonce_field -->\n";
}
}
?>
?>
<style>
<style>
#JPV-display-content h3 {
#JPV-display-content h3 {
margin-top: 0;
margin-top: 0;
}
}
</style>
</style>
<div id="JPV-display-content" class="JPV-tab-content active">
<div id="JPV-display-content" class="JPV-tab-content active">
<h3>Display</h3>
<h3>Display</h3>
<p>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'jetpack-post-views'); ?></label>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'jetpack-post-views'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" type="text" />
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" type="text" />
</p>
</p>
<p>
<p>
<label for="<?php echo $this->get_field_id( 'num_posts' ); ?>"><?php _e('Number of posts to show:', 'jetpack-post-views'); ?></label>
<label for="<?php echo $this->get_field_id( 'num_posts' ); ?>"><?php _e('Number of posts to show:', 'jetpack-post-views'); ?></label>
<input id="<?php echo $this->get_field_id( 'num_posts' ); ?>" name="<?php echo $this->get_field_name( 'num_posts' ); ?>" value="<?php echo $instance['num_posts']; ?>" type="text" size="3" />
<input id="<?php echo $this->get_field_id( 'num_posts' ); ?>" name="<?php echo $this->get_field_name( 'num_posts' ); ?>" value="<?php echo $instance['num_posts']; ?>" type="text" size="3" />
</p>
</p>
<p>
<p>
<label for="<?php echo $this->get_field_id( 'days' ); ?>"><?php _e('<span class="error">*</span>Time interval:', 'jetpack-post-views'); ?></label>
<label for="<?php echo $this->get_field_id( 'days' ); ?>"><?php _e('<span class="error">*</span>Time interval:', 'jetpack-post-views'); ?></label>
<select id="<?php echo $this->get_field_id( 'days' ); ?>" name="<?php echo $this->get_field_name( 'days' ); ?>">
<select id="<?php echo $this->get_field_id( 'days' ); ?>" name="<?php echo $this->get_field_name( 'days' ); ?>">
<option value="-1" <?php echo ($instance['days'] == '-1' ? 'selected' : '') ?> ><?php _e('Unlimited', 'jetpack-post-views'); ?></option>
<option value="-1" <?php echo ($instance['days'] == '-1' ? 'selected' : '') ?> ><?php _e('Unlimited', 'jetpack-post-views'); ?></option>
<option value="1" <?php echo ($instance['days'] == '1' ? 'selected' : '') ?> ><?php _e('Day', 'jetpack-post-views'); ?></option>
<option value="1" <?php echo ($instance['days'] == '1' ? 'selected' : '') ?> ><?php _e('Day', 'jetpack-post-views'); ?></option>
<option value="7" <?php echo ($instance['days'] == '7' ? 'selected' : '') ?> ><?php _e('Week', 'jetpack-post-views'); ?></option>
<option value="7" <?php echo ($instance['days'] == '7' ? 'selected' : '') ?> ><?php _e('Week', 'jetpack-post-views'); ?></option>
<option value="30" <?php echo ($instance['days'] == '30' ? 'selected' : '') ?> ><?php _e('Month', 'jetpack-post-views'); ?></option>
<option value="30" <?php echo ($instance['days'] == '30' ? 'selected' : '') ?> ><?php _e('Month', 'jetpack-post-views'); ?></option>
<option value="366" <?php echo ($instance['days'] == '366' ? 'selected' : '') ?> ><?php _e('Year', 'jetpack-post-views'); ?></option>
<option value="366" <?php echo ($instance['days'] == '366' ? 'selected' : '') ?> ><?php _e('Year', 'jetpack-post-views'); ?></option>
</select>
</select>
</p>
</p>
<p>
<p>
<input class="checkbox" type="checkbox" <?php checked( $instance['show_views'], 'on' ); ?> id="<?php echo $this->get_field_id( 'show_views' ); ?>" name="<?php echo $this->get_field_name( 'show_views' ); ?>" />
<input class="checkbox" type="checkbox" <?php checked( $instance['show_views'], 'on' ); ?> id="<?php echo $this->get_field_id( 'show_views' ); ?>" name="<?php echo $this->get_field_name( '
<label for="<?php echo $this->get_field_id( 'show_views' ); ?>"><?php _e('Display number of views?', 'jetpack-post-views'); ?></label>
</p>
<p>
<label for="<?php