WordPress.org

Plugin Directory


Ignore:
Timestamp:
09/22/17 09:21:47 (3 months ago)
Author:
mnmlthms
Message:

New version 1.1.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-my-instagram/trunk/inc/public/widget.php

    r1690431 r1734163  
    3131            $title = empty( $instance['title'] ) ? '' : apply_filters( 'widget_title', $instance['title'] ); 
    3232            $username = empty( $instance['username'] ) ? '' : $instance['username']; 
     33            $hashtag = empty( $instance['hashtag'] ) ? '' : $instance['hashtag']; 
    3334            $limit = empty( $instance['number'] ) ? 9 : $instance['number']; 
    3435            $size = empty( $instance['size'] ) ? 'large' : $instance['size']; 
     
    4546            do_action( 'wpmiw_before_widget', $instance ); 
    4647 
    47             if( !empty( $username ) ){ 
    48                  
     48            if( empty( $username ) && empty( $hashtag ) ){ 
     49                if( current_user_can( 'edit_theme_options' ) ){ 
     50                    esc_html_e( 'You need to input your username or hashtag!', 'wp-my-instagram' ); 
     51                } 
     52            }else{ 
    4953                WP_My_Instagram_Main::display_feed( $instance ); 
    50             }else{ 
    51                 if( current_user_can( 'edit_theme_options' ) ){ 
    52                     esc_html_e( 'You need to input your username!', 'wp-my-instagram' ); 
    53                 } 
    5454            } 
    5555 
     
    6868                    'title'     => esc_html__( 'Instagram', 'wp-my-instagram' ),  
    6969                    'username'  => '',  
     70                    'hashtag'   => '',  
    7071                    'size'      => 'large',  
    7172                    'layout'    => 'default',  
     
    7879            $title = $instance['title']; 
    7980            $username = $instance['username']; 
     81            $hashtag = $instance['hashtag']; 
    8082            $limit = absint( $instance['limit'] ); 
    8183            $size = $instance['size']; 
     
    8789            <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title', 'wp-my-instagram' ); ?>: <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></label></p> 
    8890            <p><label for="<?php echo esc_attr( $this->get_field_id( 'username' ) ); ?>"><?php esc_html_e( 'Username', 'wp-my-instagram' ); ?>: <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'username' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'username' ) ); ?>" type="text" value="<?php echo esc_attr( $username ); ?>" /></label></p> 
     91            <p> 
     92                <label for="<?php echo esc_attr( $this->get_field_id( 'hashtag' ) ); ?>"><?php esc_html_e( 'Hashtag', 'wp-my-instagram' ); ?>: <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'hashtag' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'hashtag' ) ); ?>" type="text" value="<?php echo esc_attr( $hashtag ); ?>" /></label> 
     93                <p><?php esc_html_e( 'If hashtag is entered, use hashtag instead.', 'wp-my-instagram'); ?></p> 
     94            </p> 
    8995            <p><label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>"><?php esc_html_e( 'Number of photos', 'wp-my-instagram' ); ?>: <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'limit' ) ); ?>" type="text" value="<?php echo esc_attr( $limit ); ?>" /></label></p> 
    9096            <p><label for="<?php echo esc_attr( $this->get_field_id( 'size' ) ); ?>"><?php esc_html_e( 'Photo size', 'wp-my-instagram' ); ?>:</label> 
     
    129135            $instance['title'] = strip_tags( $new_instance['title'] ); 
    130136            $instance['username'] = trim( strip_tags( $new_instance['username'] ) ); 
    131             $instance['limit'] = ! absint( $new_instance['limit'] ) ? 9 : $new_instance['limit']; 
     137            $instance['hashtag'] = trim( strip_tags( $new_instance['hashtag'] ) ); 
     138            $instance['limit'] = ! absint( $new_instance['limit'] ) ? 9 : sanitize_text_field( $new_instance['limit'] );; 
    132139            $instance['size'] = ( ( $new_instance['size'] == 'thumbnail' || $new_instance['size'] == 'large' || $new_instance['size'] == 'small' || $new_instance['size'] == 'original' ) ? $new_instance['size'] : 'large' ); 
    133140            $instance['layout'] = in_array( $new_instance['layout'], array( 'default', '2', '3', '4', '5', '6', '8', '10' ) ) ? $new_instance['layout'] : 'default'; 
     
    137144            if( $new_instance['preload'] ){ 
    138145                $username = $instance['username']; 
     146                $hashtag = $instance['hashtag']; 
     147                $key = $hashtag ? $hashtag : $username; 
    139148                $limit = $instance['limit']; 
    140                 WP_My_Instagram_Main::delete_cache( $username, $limit ); 
    141                 WP_My_Instagram_Main::scrape_instagram( $username, $limit ); 
     149                $use_hashtag = $hashtag ? true : false; 
     150                WP_My_Instagram_Main::delete_cache( $key, $limit, $use_hashtag ); 
     151                WP_My_Instagram_Main::scrape_instagram( $key, $limit, $use_hashtag ); 
    142152            } 
    143153 
Note: See TracChangeset for help on using the changeset viewer.