From 33fc21192107fd4a596dfabd84c954388bd8c6db Mon Sep 17 00:00:00 2001
From: cheh
- - + > +
> - -
- -- > - -
- -- > - +
> - + +
+ ++ > +
get_skin_options() ) ) ) ? $instance['skin'] : ''; - - $header = !empty( $instance['header'] ) ? 1 : 0; - $border = !empty( $instance['border'] ) ? 1 : 0; - $stream = !empty( $instance['stream'] ) ? 1 : 0; - $faces = !empty( $instance['faces'] ) ? 1 : 0; + $cover = !empty( $instance['cover'] ) ? 1 : 0; + $header = !empty( $instance['header'] ) ? 1 : 0; + $faces = !empty( $instance['faces'] ) ? 1 : 0; + $posts = !empty( $instance['posts'] ) ? 1 : 0; ob_start(); include( trailingslashit( CHERRY_SOCIAL_PUBLIC ) . 'views/facebook-like-box.php' ); @@ -156,11 +154,10 @@ public function update( $new_instance, $old_instance ) { $instance['title'] = strip_tags( $new_instance['title'] ); $instance['page_url'] = esc_url( $new_instance['page_url'] ); $instance['height'] = absint( $new_instance['height'] ); + $instance['cover'] = !empty( $new_instance['cover'] ) ? 1 : 0; $instance['header'] = !empty( $new_instance['header'] ) ? 1 : 0; - $instance['border'] = !empty( $new_instance['border'] ) ? 1 : 0; - $instance['stream'] = !empty( $new_instance['stream'] ) ? 1 : 0; $instance['faces'] = !empty( $new_instance['faces'] ) ? 1 : 0; - $instance['skin'] = esc_attr( $new_instance['skin'] ); + $instance['posts'] = !empty( $new_instance['posts'] ) ? 1 : 0; return $instance; } @@ -182,40 +179,25 @@ public function form( $instance ) { 'title' => '', 'page_url' => '', 'height' => 250, - 'skin' => 'light', - 'faces' => 1, - 'header' => 0, - 'stream' => 0, - 'border' => 0, + 'cover' => 0, + 'header' => 1, + 'faces' => 0, + 'posts' => 1, ) ); $instance = wp_parse_args( (array) $instance, $defaults ); $title = esc_attr( $instance['title'] ); $page_url = esc_url( $instance['page_url'] ); $height = intval( $instance['height'] ); - $skin = $this->get_skin_options(); + $cover = (bool) $instance['cover']; $faces = (bool) $instance['faces']; $header = (bool) $instance['header']; - $stream = (bool) $instance['stream']; - $border = (bool) $instance['border']; + $posts = (bool) $instance['posts']; // Display the admin form. include( trailingslashit( CHERRY_SOCIAL_ADMIN ) . 'views/facebook-like-box-admin.php' ); } - /** - * Get an array of the available orderby options. - * - * @since 1.0.0 - * @return array - */ - public function get_skin_options() { - return apply_filters( 'cherry_facebook_like_box_get_skin_options', array( - 'light' => __( 'Light', 'cherry-social' ), - 'dark' => __( 'Dark', 'cherry-social' ), - ) ); - } - } } diff --git a/public/views/facebook-like-box.php b/public/views/facebook-like-box.php index 3e513f1..ada3eb4 100644 --- a/public/views/facebook-like-box.php +++ b/public/views/facebook-like-box.php @@ -4,23 +4,20 @@ die; } ?> -+ + +
+ ++ + +
+ +
+
+
+
+
+
+
+
+
+
+
+ link", 'cherry-social' ), esc_url( 'https://instagram.com/developer/clients/manage/' ) ); ?>
+
+
+ + +
+ ++ + +
+ ++ > + +
+ ++ > + +
+ ++ > + +
+ ++ + +
+ \ No newline at end of file diff --git a/admin/views/social-follow.php b/admin/views/social-follow.php index 4598790..eebb16c 100644 --- a/admin/views/social-follow.php +++ b/admin/views/social-follow.php @@ -1,6 +1,6 @@ get_widget_slug(), + __( 'Cherry Instagram', 'cherry-social' ), + array( + 'classname' => $this->get_widget_slug() . '_widget', + 'description' => __( 'A widget for Instagram.', 'cherry-social' ) + ) + ); + + // Refreshing the widget's cached output with each new post. + add_action( 'save_post', array( $this, 'flush_widget_cache' ) ); + add_action( 'deleted_post', array( $this, 'flush_widget_cache' ) ); + add_action( 'switch_theme', array( $this, 'flush_widget_cache' ) ); + } + + /** + * Return the widget slug. + * + * @since 1.0.0 + * @return Plugin slug variable. + */ + public function get_widget_slug() { + return $this->widget_slug; + } + + /** + * Outputs the content of the widget. + * + * @since 1.0.0 + * @param array $args The array of form elements. + * @param array $instance The current instance of the widget. + */ + public function widget( $args, $instance ) { + + // Check if there is a cached output. + $cache = wp_cache_get( $this->get_widget_slug(), 'widget' ); + + if ( !is_array( $cache ) ) { + $cache = array(); + } + + if ( !isset( $args['widget_id'] ) ) { + $args['widget_id'] = $this->id; + } + + if ( isset( $cache[ $args['widget_id'] ] ) ) { + return print $cache[ $args['widget_id'] ]; + } + + extract( $args, EXTR_SKIP ); + + $client_id = esc_attr( $instance['client_id'] ); + $user_name = !empty( $instance['user_name'] ) ? strtolower( trim( $instance['user_name'] ) ) : ''; + $tag = !empty( $instance['tag'] ) ? esc_attr( $instance['tag'] ) : ''; + $image_counter = !empty( $instance['image_counter'] ) ? absint( $instance['image_counter'] ) : ''; + $button_text = !empty( $instance['button_text'] ) ? esc_attr( $instance['button_text'] ) : ''; + + $endpoints = ( !empty( $instance['endpoints'] ) && in_array( $instance['endpoints'], array_keys( $this->get_endpoints_options() ) ) ) ? $instance['endpoints'] : ''; + $image_size = ( !empty( $instance['image_size'] ) && in_array( $instance['image_size'], array_keys( $this->get_image_size_options() ) ) ) ? $instance['image_size'] : ''; + + if ( 'hashtag' == $endpoints ) { + if ( empty( $tag ) ) { + return print $before_widget . __( 'Please, enter #hashtag.', 'cherry-social' ) . $after_widget; + } + } + + if ( 'self' == $endpoints ) { + if ( empty( $user_name ) ) { + return print $before_widget . __( 'Please, enter your username.', 'cherry-social' ) . $after_widget; + } + } + + if ( empty( $client_id ) ) { + return print $before_widget . __( 'Please, enter your Instagram CLIENT ID.', 'cherry-social' ) . $after_widget; + } + + if ( $image_counter <= 0 ) { + return ''; + } + + $config = array(); + + if ( ! empty( $instance['link'] ) ) $config[] = 'link'; + if ( ! empty( $instance['display_time'] ) ) $config[] = 'time'; + if ( ! empty( $instance['display_description'] ) ) $config[] = 'description'; + if ( ! empty( $image_size ) ) $config['thumb'] = $image_size; + + if ( 'self' == $endpoints ) { + $user_id = $this->get_user_id( $user_name, $client_id ); + + if ( ! $user_id ) { + return print $before_widget . __( 'Please, enter a valid username and CLIENT ID.', 'cherry-social' ) . $after_widget; + } + + $data = $user_id; + + } else { + $data = $tag; + } + + $config['endpoints'] = $endpoints; + $photos = $this->get_photos( $data, $client_id, $image_counter, $config ); + + if ( ! $photos ) { + return print $before_widget . __( 'Please, enter a valid CLIENT ID.', 'cherry-social' ) . $after_widget; + } + + $output = $before_widget; + + /** + * Fires before a content widget. + * + * @since 1.0.0 + */ + do_action( $this->widget_slug . '_before', $args, $instance ); + + if ( !empty( $instance['title'] ) ) { + /** + * Filter the widget title. + * + * @since 1.0.0 + * @param string $title The widget title. + * @param array $instance An array of the widget's settings. + * @param mixed $widget_slug The widget ID. + */ + $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->widget_slug ); + + // Display the widget title if one was input. + if ( $title ) { + $output .= $before_title; + $output .= $title; + $output .= $after_title; + } + } + + $date_format = get_option( 'date_format' ); + + $output .= '