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.../inc
File: widget-entry-views.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* @package EntryViews
[2] Fix | Delete
* @version 1.0.0
[3] Fix | Delete
* @author Justin Tadlock <justin@justintadlock.com>
[4] Fix | Delete
* @copyright Copyright (c) 2010 - 2014, Justin Tadlock
[5] Fix | Delete
* @link http://themehybrid.com/plugins/entry-views
[6] Fix | Delete
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* Entry Views widget.
[11] Fix | Delete
*
[12] Fix | Delete
* @since 1.0.0
[13] Fix | Delete
*/
[14] Fix | Delete
class EV_Widget_Entry_Views extends WP_Widget {
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* Default arguments for the widget settings.
[18] Fix | Delete
*
[19] Fix | Delete
* @since 1.0.0
[20] Fix | Delete
* @access public
[21] Fix | Delete
* @var array
[22] Fix | Delete
*/
[23] Fix | Delete
public $defaults = array();
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* Set up the widget's unique name, ID, class, description, and other options.
[27] Fix | Delete
*
[28] Fix | Delete
* @since 1.0.0
[29] Fix | Delete
* @access public
[30] Fix | Delete
* @return void
[31] Fix | Delete
*/
[32] Fix | Delete
function __construct() {
[33] Fix | Delete
[34] Fix | Delete
/* Set up the widget options. */
[35] Fix | Delete
$widget_options = array(
[36] Fix | Delete
'classname' => 'widget-entry-views',
[37] Fix | Delete
'description' => esc_html__( 'Display posts based on their view count.', 'entry-views' )
[38] Fix | Delete
);
[39] Fix | Delete
[40] Fix | Delete
/* Set up the widget control options. */
[41] Fix | Delete
$control_options = array(
[42] Fix | Delete
'width' => 200,
[43] Fix | Delete
'height' => 350
[44] Fix | Delete
);
[45] Fix | Delete
[46] Fix | Delete
/* Create the widget. */
[47] Fix | Delete
$this->WP_Widget(
[48] Fix | Delete
'ev-entry-views',
[49] Fix | Delete
__( 'Entry Views', 'entry-views' ),
[50] Fix | Delete
$widget_options,
[51] Fix | Delete
$control_options
[52] Fix | Delete
);
[53] Fix | Delete
[54] Fix | Delete
/* Set up defaults. */
[55] Fix | Delete
$this->defaults = array(
[56] Fix | Delete
'title' => esc_attr__( 'Views', 'entry-views' ),
[57] Fix | Delete
'posts_per_page' => 10,
[58] Fix | Delete
'post_type' => 'post',
[59] Fix | Delete
'order' => 'DESC',
[60] Fix | Delete
'show_view_count' => true
[61] Fix | Delete
);
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
/**
[65] Fix | Delete
* Outputs the widget based on the arguments input through the widget controls.
[66] Fix | Delete
*
[67] Fix | Delete
* @since 1.0.0
[68] Fix | Delete
* @access public
[69] Fix | Delete
* @param array $sidebar
[70] Fix | Delete
* @param array $instance
[71] Fix | Delete
* @return void
[72] Fix | Delete
*/
[73] Fix | Delete
function widget( $sidebar, $instance ) {
[74] Fix | Delete
[75] Fix | Delete
/* Set the $args for wp_get_archives() to the $instance array. */
[76] Fix | Delete
$args = wp_parse_args( $instance, $this->defaults );
[77] Fix | Delete
[78] Fix | Delete
/* Output the sidebar's $before_widget wrapper. */
[79] Fix | Delete
echo $sidebar['before_widget'];
[80] Fix | Delete
[81] Fix | Delete
/* If a title was input by the user, display it. */
[82] Fix | Delete
if ( !empty( $args['title'] ) )
[83] Fix | Delete
echo $sidebar['before_title'] . apply_filters( 'widget_title', $args['title'], $instance, $this->id_base ) . $sidebar['after_title'];
[84] Fix | Delete
[85] Fix | Delete
/* Query the most/least viewed posts. */
[86] Fix | Delete
$loop = new WP_Query(
[87] Fix | Delete
array(
[88] Fix | Delete
'post_type' => $args['post_type'],
[89] Fix | Delete
'posts_per_page' => $args['posts_per_page'],
[90] Fix | Delete
'order' => $args['order'],
[91] Fix | Delete
'orderby' => 'meta_value_num',
[92] Fix | Delete
'ignore_sticky_posts' => true,
[93] Fix | Delete
'meta_key' => ev_get_meta_key()
[94] Fix | Delete
)
[95] Fix | Delete
);
[96] Fix | Delete
[97] Fix | Delete
if ( $loop->have_posts() ) : ?>
[98] Fix | Delete
[99] Fix | Delete
<ul class="ev-entry-views-list">
[100] Fix | Delete
[101] Fix | Delete
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
[102] Fix | Delete
[103] Fix | Delete
<li>
[104] Fix | Delete
<?php the_title( '<a href="' . get_permalink() . '">', '</a>' ); ?>
[105] Fix | Delete
<?php if ( true == $args['show_view_count'] ) : ?>
[106] Fix | Delete
<?php ev_post_views( array( 'text' => '(%s)', 'wrap' => '<span class="entry-view-count">%2$s</span>' ) ); ?>
[107] Fix | Delete
<?php endif; ?>
[108] Fix | Delete
</li>
[109] Fix | Delete
[110] Fix | Delete
<?php endwhile; ?>
[111] Fix | Delete
[112] Fix | Delete
</ul><!-- .ev-entry-views-list -->
[113] Fix | Delete
[114] Fix | Delete
<?php endif;
[115] Fix | Delete
[116] Fix | Delete
/* Close the sidebar's widget wrapper. */
[117] Fix | Delete
echo $sidebar['after_widget'];
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
/**
[121] Fix | Delete
* The update callback for the widget control options. This method is used to sanitize and/or
[122] Fix | Delete
* validate the options before saving them into the database.
[123] Fix | Delete
*
[124] Fix | Delete
* @since 1.0.0
[125] Fix | Delete
* @access public
[126] Fix | Delete
* @param array $new_instance
[127] Fix | Delete
* @param array $old_instance
[128] Fix | Delete
* @return array
[129] Fix | Delete
*/
[130] Fix | Delete
function update( $new_instance, $old_instance ) {
[131] Fix | Delete
[132] Fix | Delete
/* Strip tags. */
[133] Fix | Delete
$instance['title'] = strip_tags( $new_instance['title'] );
[134] Fix | Delete
[135] Fix | Delete
/* Array map sanitize key. */
[136] Fix | Delete
$instance['post_type'] = array_map( 'sanitize_key', $new_instance['post_type'] );
[137] Fix | Delete
[138] Fix | Delete
/* Whitelist options. */
[139] Fix | Delete
$order = array( 'ASC', 'DESC' );
[140] Fix | Delete
[141] Fix | Delete
$instance['order'] = in_array( $new_instance['order'], $order ) ? $new_instance['order'] : 'DESC';
[142] Fix | Delete
[143] Fix | Delete
/* Integers. */
[144] Fix | Delete
$instance['posts_per_page'] = absint( $new_instance['posts_per_page'] );
[145] Fix | Delete
[146] Fix | Delete
/* Checkboxes. */
[147] Fix | Delete
$instance['show_view_count'] = isset( $new_instance['show_view_count'] ) ? 1 : 0;
[148] Fix | Delete
[149] Fix | Delete
/* Return sanitized options. */
[150] Fix | Delete
return $instance;
[151] Fix | Delete
}
[152] Fix | Delete
[153] Fix | Delete
/**
[154] Fix | Delete
* Displays the widget control options in the Widgets admin screen.
[155] Fix | Delete
*
[156] Fix | Delete
* @since 1.0.0
[157] Fix | Delete
* @access public
[158] Fix | Delete
* @param array $instance
[159] Fix | Delete
* @param void
[160] Fix | Delete
*/
[161] Fix | Delete
function form( $instance ) {
[162] Fix | Delete
[163] Fix | Delete
/* Merge the user-selected arguments with the defaults. */
[164] Fix | Delete
$instance = wp_parse_args( (array) $instance, $this->defaults );
[165] Fix | Delete
[166] Fix | Delete
$post_types = array();
[167] Fix | Delete
$_post_types = get_post_types( array( 'public' => true ), 'objects' );
[168] Fix | Delete
[169] Fix | Delete
foreach ( $_post_types as $_post_type ) {
[170] Fix | Delete
if ( post_type_supports( $_post_type->name, 'entry-views' ) )
[171] Fix | Delete
$post_types[] = $_post_type;
[172] Fix | Delete
}
[173] Fix | Delete
[174] Fix | Delete
/* Create an array of order options. */
[175] Fix | Delete
$order = array(
[176] Fix | Delete
'ASC' => esc_attr__( 'Ascending', 'entry-views' ),
[177] Fix | Delete
'DESC' => esc_attr__( 'Descending', 'entry-views' )
[178] Fix | Delete
);
[179] Fix | Delete
[180] Fix | Delete
?>
[181] Fix | Delete
<p>
[182] Fix | Delete
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'entry-views' ); ?></label>
[183] Fix | Delete
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" placeholder="<?php echo esc_attr( $this->defaults['title'] ); ?>" />
[184] Fix | Delete
</p>
[185] Fix | Delete
<p>
[186] Fix | Delete
<label for="<?php echo $this->get_field_id( 'post_type' ); ?>"><?php _e( 'Post Type:', 'entry-views' ); ?></label>
[187] Fix | Delete
<select class="widefat" id="<?php echo $this->get_field_id( 'post_type' ); ?>" name="<?php echo $this->get_field_name( 'post_type' ); ?>[]" size="4" multiple="multiple">
[188] Fix | Delete
<?php foreach ( $post_types as $post_type ) { ?>
[189] Fix | Delete
<option value="<?php echo esc_attr( $post_type->name ); ?>" <?php selected( in_array( $post_type->name, (array)$instance['post_type'] ) ); ?>><?php echo esc_html( $post_type->labels->singular_name ); ?></option>
[190] Fix | Delete
<?php } ?>
[191] Fix | Delete
</select>
[192] Fix | Delete
</p>
[193] Fix | Delete
<p>
[194] Fix | Delete
<label for="<?php echo $this->get_field_id( 'posts_per_page' ); ?>"><?php _e( 'Limit:', 'entry-views' ); ?></label>
[195] Fix | Delete
<input type="number" class="widefat code" size="5" min="1" id="<?php echo $this->get_field_id( 'posts_per_page' ); ?>" name="<?php echo $this->get_field_name( 'posts_per_page' ); ?>" value="<?php echo esc_attr( $instance['posts_per_page'] ); ?>" placeholder="10" />
[196] Fix | Delete
</p>
[197] Fix | Delete
<p>
[198] Fix | Delete
<label for="<?php echo $this->get_field_id( 'order' ); ?>"><?php _e( 'Order:', 'entry-views' ); ?></label>
[199] Fix | Delete
<select class="widefat" id="<?php echo $this->get_field_id( 'order' ); ?>" name="<?php echo $this->get_field_name( 'order' ); ?>">
[200] Fix | Delete
<?php foreach ( $order as $option_value => $option_label ) { ?>
[201] Fix | Delete
<option value="<?php echo esc_attr( $option_value ); ?>" <?php selected( $instance['order'], $option_value ); ?>><?php echo esc_html( $option_label ); ?></option>
[202] Fix | Delete
<?php } ?>
[203] Fix | Delete
</select>
[204] Fix | Delete
</p>
[205] Fix | Delete
<p>
[206] Fix | Delete
<label for="<?php echo $this->get_field_id( 'show_view_count' ); ?>">
[207] Fix | Delete
<input class="checkbox" type="checkbox" <?php checked( $instance['show_view_count'], true ); ?> id="<?php echo $this->get_field_id( 'show_view_count' ); ?>" name="<?php echo $this->get_field_name( 'show_view_count' ); ?>" /> <?php _e( 'Show view count?', 'entry-views' ); ?></label>
[208] Fix | Delete
</p>
[209] Fix | Delete
<?php
[210] Fix | Delete
}
[211] Fix | Delete
}
[212] Fix | Delete
[213] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function