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/meks-sim.../inc
File: class-flickr-widget.php
<?php
[0] Fix | Delete
/*-----------------------------------------------------------------------------------*/
[1] Fix | Delete
/* Flicker Widget Class
[2] Fix | Delete
/*-----------------------------------------------------------------------------------*/
[3] Fix | Delete
[4] Fix | Delete
class MKS_Flickr_Widget extends WP_Widget {
[5] Fix | Delete
[6] Fix | Delete
var $defaults;
[7] Fix | Delete
[8] Fix | Delete
function __construct() {
[9] Fix | Delete
$widget_ops = array( 'classname' => 'mks_flickr_widget', 'description' => __( 'Display your Flickr photostream', 'meks-simple-flickr-widget' ) );
[10] Fix | Delete
$control_ops = array( 'id_base' => 'mks_flickr_widget' );
[11] Fix | Delete
parent::__construct( 'mks_flickr_widget', __( 'Meks Flickr Widget', 'meks-simple-flickr-widget' ), $widget_ops, $control_ops );
[12] Fix | Delete
[13] Fix | Delete
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
[14] Fix | Delete
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
[15] Fix | Delete
[16] Fix | Delete
$this->defaults = array(
[17] Fix | Delete
'title' => 'Flickr',
[18] Fix | Delete
'id' => '',
[19] Fix | Delete
'count' => 9,
[20] Fix | Delete
't_width' => 85,
[21] Fix | Delete
't_height' => 85,
[22] Fix | Delete
'randomize' => 0,
[23] Fix | Delete
);
[24] Fix | Delete
[25] Fix | Delete
//Allow themes or plugins to modify default parameters
[26] Fix | Delete
$this->defaults = apply_filters( 'mks_flickr_widget_modify_defaults', $this->defaults );
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
function enqueue_styles() {
[30] Fix | Delete
wp_register_style( 'meks-flickr-widget', MKS_FLICKR_WIDGET_URL.'css/style.css', false, MKS_FLICKR_WIDGET_VER );
[31] Fix | Delete
wp_enqueue_style( 'meks-flickr-widget' );
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
[35] Fix | Delete
function widget( $args, $instance ) {
[36] Fix | Delete
[37] Fix | Delete
$instance = wp_parse_args( (array) $instance, $this->defaults );
[38] Fix | Delete
[39] Fix | Delete
extract( $args );
[40] Fix | Delete
[41] Fix | Delete
$title = apply_filters( 'widget_title', $instance['title'] );
[42] Fix | Delete
[43] Fix | Delete
echo $before_widget;
[44] Fix | Delete
if ( ! empty( $title ) ) {
[45] Fix | Delete
echo $before_title . $title . $after_title;
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
$photos = $this->get_photos( $instance['id'], $instance['count'] );
[49] Fix | Delete
[50] Fix | Delete
if ( !empty( $photos ) ) {
[51] Fix | Delete
[52] Fix | Delete
if($instance['randomize']){
[53] Fix | Delete
shuffle($photos);
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
$height = $instance['t_height'] ? $instance['t_height'].'px' : 'auto';
[57] Fix | Delete
$style = 'style="width: '.esc_attr( $instance['t_width'] ).'px; height: '.esc_attr( $height ).';"';
[58] Fix | Delete
[59] Fix | Delete
echo '<ul class="flickr">';
[60] Fix | Delete
foreach ( $photos as $photo ) {
[61] Fix | Delete
echo '<li><a href="'.esc_url( $photo['img_url'] ).'" title="'.esc_attr( $photo['title'] ).'" target="_blank" rel="noopener"><img src="'.esc_attr( $photo['img_src'] ).'" alt="'.esc_attr( $photo['title'] ).'" '.$style.'/></a></li>';
[62] Fix | Delete
}
[63] Fix | Delete
echo '</ul>';
[64] Fix | Delete
echo '<div class="clear"></div>';
[65] Fix | Delete
}
[66] Fix | Delete
echo $after_widget;
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
[70] Fix | Delete
function get_photos( $id, $count = 8 ) {
[71] Fix | Delete
if ( empty( $id ) )
[72] Fix | Delete
return false;
[73] Fix | Delete
[74] Fix | Delete
$transient_key = md5( 'mks_flickr_cache_' . $id . $count );
[75] Fix | Delete
$cached = get_transient( $transient_key );
[76] Fix | Delete
if ( !empty( $cached ) ) {
[77] Fix | Delete
return $cached;
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
$protocol = is_ssl() ? 'https' : 'http';
[81] Fix | Delete
$output = array();
[82] Fix | Delete
$rss = $protocol.'://api.flickr.com/services/feeds/photos_public.gne?id='.$id.'&lang=en-us&format=rss_200';
[83] Fix | Delete
$rss = fetch_feed( $rss );
[84] Fix | Delete
[85] Fix | Delete
if ( is_wp_error( $rss ) ) {
[86] Fix | Delete
//check for group feed
[87] Fix | Delete
$rss = $protocol.'://api.flickr.com/services/feeds/groups_pool.gne?id='.$id.'&lang=en-us&format=rss_200';
[88] Fix | Delete
$rss = fetch_feed( $rss );
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
if ( !is_wp_error( $rss ) ) {
[92] Fix | Delete
$maxitems = $rss->get_item_quantity( $count );
[93] Fix | Delete
$rss_items = $rss->get_items( 0, $maxitems );
[94] Fix | Delete
foreach ( $rss_items as $item ) {
[95] Fix | Delete
$temp = array();
[96] Fix | Delete
$temp['img_url'] = esc_url( $item->get_permalink() );
[97] Fix | Delete
$temp['title'] = esc_html( $item->get_title() );
[98] Fix | Delete
$content = $item->get_content();
[99] Fix | Delete
preg_match_all( "/<IMG.+?SRC=[\"']([^\"']+)/si", $content, $sub, PREG_SET_ORDER );
[100] Fix | Delete
$photo_url = str_replace( "_m.jpg", "_t.jpg", $sub[0][1] );
[101] Fix | Delete
$temp['img_src'] = esc_url( $photo_url );
[102] Fix | Delete
$output[] = $temp;
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
set_transient( $transient_key, $output, 60 * 60 * 24 );
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
//print_r( $output );
[109] Fix | Delete
[110] Fix | Delete
return $output;
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
function update( $new_instance, $old_instance ) {
[114] Fix | Delete
$instance = array();
[115] Fix | Delete
$instance['title'] = strip_tags( $new_instance['title'] );
[116] Fix | Delete
$instance['id'] = strip_tags( $new_instance['id'] );
[117] Fix | Delete
$instance['count'] = absint( $new_instance['count'] );
[118] Fix | Delete
$instance['t_width'] = absint( $new_instance['t_width'] );
[119] Fix | Delete
$instance['t_height'] = absint( $new_instance['t_height'] );
[120] Fix | Delete
$instance['randomize'] = isset( $new_instance['randomize'] ) ? 1 : 0;
[121] Fix | Delete
return $new_instance;
[122] Fix | Delete
}
[123] Fix | Delete
[124] Fix | Delete
[125] Fix | Delete
function form( $instance ) {
[126] Fix | Delete
[127] Fix | Delete
$instance = wp_parse_args( (array) $instance, $this->defaults ); ?>
[128] Fix | Delete
[129] Fix | Delete
<p>
[130] Fix | Delete
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title', 'meks-simple-flickr-widget' ); ?>:</label>
[131] Fix | Delete
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
[132] Fix | Delete
</p>
[133] Fix | Delete
<p>
[134] Fix | Delete
<label for="<?php echo $this->get_field_id( 'id' ); ?>"><?php _e( 'Flickr ID', 'meks-simple-flickr-widget' ); ?>:</label> <small><a href="http://idgettr.com/" target="_blank"><?php _e( 'What\'s my Flickr ID?', 'meks-simple-flickr-widget' ); ?></a></small>
[135] Fix | Delete
<input class="widefat" id="<?php echo $this->get_field_id( 'id' ); ?>" name="<?php echo $this->get_field_name( 'id' ); ?>" type="text" value="<?php echo esc_attr( $instance['id'] ); ?>" />
[136] Fix | Delete
<small class="howto"><?php _e( 'Example ID: 23100287@N07', 'meks-simple-flickr-widget' ); ?></small>
[137] Fix | Delete
</p>
[138] Fix | Delete
<p>
[139] Fix | Delete
<label for="<?php echo $this->get_field_id( 'count' ); ?>"><?php _e( 'Number of photos', 'meks-simple-flickr-widget' ); ?>:</label>
[140] Fix | Delete
<input class="small-text" type="text" value="<?php echo absint( $instance['count'] ); ?>" id="<?php echo $this->get_field_id( 'count' ); ?>" name="<?php echo $this->get_field_name( 'count' ); ?>" />
[141] Fix | Delete
</p>
[142] Fix | Delete
[143] Fix | Delete
<p>
[144] Fix | Delete
<label for="<?php echo $this->get_field_id( 't_width' ); ?>"><?php _e( 'Thumbnail width', 'meks-simple-flickr-widget' ); ?>:</label>
[145] Fix | Delete
<input class="small-text" type="text" value="<?php echo absint( $instance['t_width'] ); ?>" id="<?php echo $this->get_field_id( 't_width' ); ?>" name="<?php echo $this->get_field_name( 't_width' ); ?>" /> px
[146] Fix | Delete
</p>
[147] Fix | Delete
[148] Fix | Delete
<p>
[149] Fix | Delete
<label for="<?php echo $this->get_field_id( 't_height' ); ?>"><?php _e( 'Thumbnail height', 'meks-simple-flickr-widget' ); ?>:</label>
[150] Fix | Delete
<input class="small-text" type="text" value="<?php echo absint( $instance['t_height'] ); ?>" id="<?php echo $this->get_field_id( 't_height' ); ?>" name="<?php echo $this->get_field_name( 't_height' ); ?>" /> px
[151] Fix | Delete
<small class="howto"><?php _e( 'Note: You can use "0" value for auto height', 'meks-simple-flickr-widget' ); ?></small>
[152] Fix | Delete
</p>
[153] Fix | Delete
[154] Fix | Delete
<p>
[155] Fix | Delete
<label for="<?php echo $this->get_field_id( 'randomize' ); ?>">
[156] Fix | Delete
<input type="checkbox" value="1" id="<?php echo $this->get_field_id( 'randomize' ); ?>" name="<?php echo $this->get_field_name( 'randomize' ); ?>" <?php checked( $instance['randomize'], 1 ); ?>/> <?php _e( 'Randomize photos?', 'meks-simple-flickr-widget' ); ?>
[157] Fix | Delete
</label>
[158] Fix | Delete
</p>
[159] Fix | Delete
[160] Fix | Delete
<?php
[161] Fix | Delete
}
[162] Fix | Delete
}
[163] Fix | Delete
?>
[164] Fix | Delete
[165] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function