WordPress.org

Plugin Directory

Changeset 976238


Ignore:
Timestamp:
09/01/14 03:57:45 (3 years ago)
Author:
peterricci
Message:

release 0.1.7

Location:
yakadanda-instagram/trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • yakadanda-instagram/trunk/admin/functions.php

    r961572 r976238  
    109109  /* authentication */ 
    110110  if (isset($_GET['code'])) { 
    111     $data = yinstagram_get_options('settings'); 
    112      
    113     $response = (array) wp_remote_post("https://api.instagram.com/oauth/access_token", array( 
    114           'method' => 'POST', 
    115           'timeout' => 45, 
    116           'redirection' => 5, 
    117           'httpversion' => '1.0', 
    118           'blocking' => true, 
    119           'headers' => array(), 
    120           'body' => array( 
    121             'client_id' => $data['client_id'], 
    122             'client_secret' => $data['client_secret'], 
    123             'grant_type' => 'authorization_code', 
    124             'redirect_uri' => admin_url('admin.php?page=yinstagram/settings.php'), 
    125             'code' => $_GET['code'], 
    126             'response_type' => 'authorization_code' 
    127           ), 
    128           'cookies' => array(), 
    129           'sslverify' => apply_filters('https_local_ssl_verify', false) 
    130         ) 
    131       ); 
    132      
    133     if (!is_wp_error($response) && isset($response['headers'])) { 
    134       if ($response['response']['code'] == '200') { 
    135         $value = (array) json_decode($response['body']); 
    136         update_option('yinstagram_access_token', $value); 
    137          
    138         $message = maybe_serialize(array('cookie' => 1, 'class' => 'error', 'msg' => 'Connection to Instagram failed.')); 
    139         if (get_option('yinstagram_access_token')) { 
    140           $message = maybe_serialize(array('cookie' => 1, 'class' => 'updated', 'msg' => 'Connection to Instagram succeeded.')); 
    141         } 
    142       } else { 
    143         $body = json_decode($response['body']); 
    144         $message = maybe_serialize(array('cookie' => 1, 'class' => 'error', 'msg' => $body->error_message)); 
    145       } 
    146     } else { 
    147       $message = maybe_serialize(array('cookie' => 1, 'class' => 'error', 'msg' => $response['errors']['http_request_failed'][0])); 
     111    $message = maybe_serialize(array('cookie' => 1, 'class' => 'error', 'msg' => 'Connection to Instagram failed.')); 
     112     
     113    $response = json_decode( yinstagram_access_token($_GET['code']) ); 
     114     
     115    if ( isset($response->access_token) ) { 
     116      update_option('yinstagram_access_token', $response); 
     117      $message = maybe_serialize(array('cookie' => 1, 'class' => 'updated', 'msg' => 'Connection to Instagram succeeded.')); 
    148118    } 
    149119     
     
    193163       
    194164      $encodeURIComponent = yinstagram_encodeURIComponent(admin_url('admin.php?page=yinstagram/settings.php')); 
    195       $url = 'https://api.instagram.com/oauth/authorize/?response_type=code&client_id=' . $_POST['client_id'] . '&redirect_uri=' . $encodeURIComponent; 
     165      $url = 'https://api.instagram.com/oauth/authorize/?client_id=' . $_POST['client_id'] . '&redirect_uri=' . $encodeURIComponent . '&response_type=code'; 
    196166       
    197167      wp_redirect($url); exit; 
     
    376346  die(); 
    377347} 
     348 
     349function yinstagram_access_token($code) { 
     350  $data = yinstagram_get_options('settings'); 
     351   
     352  // Get cURL resource 
     353  $curl = curl_init(); 
     354  // Set some options - we are passing in a useragent too here 
     355  curl_setopt_array($curl, array( 
     356    CURLOPT_RETURNTRANSFER => 1, 
     357    CURLOPT_URL => 'https://api.instagram.com/oauth/access_token', 
     358    CURLOPT_USERAGENT => 'Yakadanda Instagram Access Token Request', 
     359    CURLOPT_POST => 1, 
     360    CURLOPT_POSTFIELDS => array( 
     361      'client_id' => $data['client_id'], 
     362      'client_secret' => $data['client_secret'], 
     363      'grant_type' => 'authorization_code', 
     364      'redirect_uri' => admin_url('admin.php?page=yinstagram/settings.php'), 
     365      'code' => $code 
     366    ) 
     367  )); 
     368  // Send the request & save response to $resp 
     369  $resp = curl_exec($curl); 
     370  // Close request to clear up some resources 
     371  curl_close($curl); 
     372   
     373  return $resp; 
     374} 
     375 
     376function yinstagram_fetch_data($url) { 
     377  $ch = curl_init(); 
     378  curl_setopt($ch, CURLOPT_URL, $url); 
     379  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
     380  curl_setopt($ch, CURLOPT_TIMEOUT, 20); 
     381  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
     382  $result = curl_exec($ch); 
     383  curl_close($ch); 
     384  return $result; 
     385} 
  • yakadanda-instagram/trunk/admin/page-settings.php

    r952645 r976238  
    22  <div id="icon-edit" class="icon32 icon32-posts-quote"><br></div> 
    33  <h2>Settings</h2> 
     4  <?php if (!function_exists('curl_version')): ?> 
     5    <div class="error"> 
     6      <p>Please enable cURL.</p> 
     7    </div>   
     8  <?php endif; ?> 
    49  <?php if ($message): ?> 
    510    <div class="<?php echo $message['class']; ?>"> 
  • yakadanda-instagram/trunk/admin/shortcode.php

    r961572 r976238  
    33function yinstagram_shortcode($atts) { 
    44  global $wp, $yinstagram_options; 
    5    
     5 
    66  $a = shortcode_atts( array( 
    77      'display_images' => null, //display_your_images - recent, feed, liked, hashtag 
     
    99      'hashtags' => null //display_the_following_hashtags 
    1010    ), $atts); 
    11    
     11 
     12  // Enqueue scripts 
     13  yinstagram_wp_enqueue_scripts($yinstagram_options); 
     14 
    1215  $display_your_images = empty($a['display_images']) ? $yinstagram_options['display_your_images'] : $a['display_images']; 
    1316   
     
    182185   
    183186  return $output; 
    184 } 
    185  
    186 function yinstagram_fetch_data($url) { 
    187   $ch = curl_init(); 
    188   curl_setopt($ch, CURLOPT_URL, $url); 
    189   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    190   curl_setopt($ch, CURLOPT_TIMEOUT, 20); 
    191   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
    192   $result = curl_exec($ch); 
    193   curl_close($ch); 
    194   return $result; 
    195187} 
    196188 
  • yakadanda-instagram/trunk/admin/widget.php

    r961572 r976238  
    1010  public function widget($args, $instance) { 
    1111    global $yinstagram_options; 
     12 
     13    // Enqueue scripts 
     14    yinstagram_wp_enqueue_scripts($yinstagram_options); 
    1215     
    1316    extract($args); 
     
    162165 
    163166  public function form($instance) { 
    164     $auth = get_option('yinstagram_access_token'); 
     167    $auth = yinstagram_get_options('token'); 
    165168    $title = isset($instance['title']) ? $instance['title'] : __(null, 'text_domain'); 
    166169    $type = isset($instance['type']) ? $instance['type'] : 'images'; 
     
    218221      <input class="widefat" id="<?php echo $this->get_field_id('limit'); ?>" name="<?php echo $this->get_field_name('limit'); ?>" type="text" value="<?php echo esc_attr($limit); ?>" /> 
    219222    </p> 
    220       <p> 
     223    <p> 
    221224      <label for="<?php echo $this->get_field_id('order'); ?>"><?php _e('Order:'); ?></label><br> 
    222225      <select id="<?php echo $this->get_field_id('order'); ?>" name="<?php echo $this->get_field_name('order'); ?>"> 
  • yakadanda-instagram/trunk/js/script.js

    r961572 r976238  
    114114            } 
    115115 
    116             $( '<img class="img_w-' + yinstagram_widget_images[i].id + '" title="' + yinstagram_widget_images[i].title +'" src="' + yinstagram_widget_images[i].src + '" style="display: none; width: ' + yinstagram_widget_settings['dimensions'] + 'px; height: ' + yinstagram_widget_settings['dimensions'] + 'px;">' ).load(function() { 
     116            $( '<img class="img_w-' + yinstagram_widget_images[i].id + '" src="' + yinstagram_widget_images[i].src + '" style="display: none; width: ' + yinstagram_widget_settings['dimensions'] + 'px; height: ' + yinstagram_widget_settings['dimensions'] + 'px;">' ).load(function() { 
    117117              $( '.load_w-'+yinstagram_widget_images[i].id ).replaceWith(this); 
    118118              $('.img_w-'+yinstagram_widget_images[i].id).fadeIn(); 
     
    159159    e.preventDefault(); 
    160160  }); 
    161    
     161 
    162162  /* 
    163163   * backend 
  • yakadanda-instagram/trunk/readme.txt

    r972240 r976238  
    55Requires at least: 3.8 
    66Tested up to: 3.9.2 
    7 Stable tag: 0.1.6 
     7Stable tag: 0.1.7 
    88License: GPLv2 or later 
    99 
     
    6767== Changelog == 
    6868 
     69= 0.1.7 = 
     70* Change request the access_token method 
     71* Improve equeue stylesheets and javascripts 
     72 
    6973= 0.1.6 = 
    7074* Update setup documentation 
     
    160164== Upgrade Notice == 
    161165 
     166= 0.1.7 = 
     167* Fix auth on widget 
     168 
    162169= 0.1.6 = 
    163170* Add failed message on failure connection 
  • yakadanda-instagram/trunk/yakadanda-instagram.php

    r972172 r976238  
    44  Plugin URI: http://www.yakadanda.com/plugins/yakadanda-instagram/ 
    55  Description: A Wordpress plugin that pulls in Instagram images of user or hashtags. 
    6   Version: 0.1.6 
     6  Version: 0.1.7 
    77  Author: Peter Ricci 
    88  Author URI: http://www.yakadanda.com/ 
     
    1313register_activation_hook(__FILE__, 'yinstagram_activate'); 
    1414function yinstagram_activate() { 
    15   if (!get_option('yinstagram_settings')) 
    16     add_option('yinstagram_settings', null, false, false); 
    17   if (!get_option('yinstagram_display_options')) 
    18     add_option('yinstagram_display_options', null, false, false); 
    19   if (!get_option('yinstagram_access_token')) 
    20     add_option('yinstagram_access_token', null, false, false); 
     15  if (!get_option('yinstagram_settings')) { add_option('yinstagram_settings', null, false, false); } 
     16  if (!get_option('yinstagram_display_options')) { add_option('yinstagram_display_options', null, false, false); } 
     17  if (!get_option('yinstagram_access_token')) { add_option('yinstagram_access_token', null, false, false); } 
    2118} 
    2219 
     
    2825} 
    2926 
    30 if (!defined('YINSTAGRAM_VER')) define('YINSTAGRAM_VER', '0.1.6'); 
     27if (!defined('YINSTAGRAM_VER')) define('YINSTAGRAM_VER', '0.1.7'); 
    3128if (!defined('YINSTAGRAM_PLUGIN_DIR')) define('YINSTAGRAM_PLUGIN_DIR', plugin_dir_path(__FILE__)); 
    3229if (!defined('YINSTAGRAM_PLUGIN_URL')) define('YINSTAGRAM_PLUGIN_URL', plugins_url(null, __FILE__)); 
     
    4845} 
    4946 
    50 // Register scripts & styles 
     47// Register scripts 
    5148add_action('init', 'yinstagram_register'); 
    5249function yinstagram_register() { 
     
    7067  wp_register_script('yinstagram-script', YINSTAGRAM_PLUGIN_URL . '/js/script.js', array('jquery'), YINSTAGRAM_VER, true); 
    7168   
     69  // ajax 
    7270  wp_localize_script('yinstagram-script', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) )); 
    73 } 
    74  
    75 // Enqueue styles for admin 
    76 add_action('admin_enqueue_scripts', 'yinstagram_admin_enqueue_styles'); 
    77 function yinstagram_admin_enqueue_styles() { 
    78   if (yinstagram_is_plugin_page(yinstagram_get_page())) { 
    79     wp_enqueue_style('yinstagram-admin'); 
    80   } 
    81 } 
    82 // Enqueue then call styles in frontend 
    83 add_action('wp_enqueue_scripts', 'yinstagram_wp_enqueue_styles'); 
    84 function yinstagram_wp_enqueue_styles() { 
    85   global $yinstagram_options; 
    86    
    87   if ($yinstagram_options['lightbox'] == 'colorbox') { wp_enqueue_style('yinstagram-colorbox'); } 
    88    
    89   wp_enqueue_style('yinstagram-style'); 
    9071} 
    9172 
     
    9475function yinstagram_admin_enqueue_scripts() { 
    9576  if (yinstagram_is_plugin_page(yinstagram_get_page())) { 
     77    wp_enqueue_style('yinstagram-admin'); 
     78     
    9679    wp_enqueue_script('jquery-ui-dialog'); 
    9780    wp_enqueue_script('yinstagram-script'); 
    9881  } 
    9982} 
    100 // Enqueue then call scripts in frontend 
    101 add_action('wp_enqueue_scripts', 'yinstagram_wp_enqueue_scripts'); 
    102 function yinstagram_wp_enqueue_scripts() { 
    103   global $yinstagram_options; 
    10483 
    105   wp_enqueue_script('jquery'); 
    106   wp_enqueue_script('yinstagram-simplyScroll'); 
     84// Enqueue scripts for frontend 
     85function yinstagram_wp_enqueue_scripts($yinstagram_options) { 
     86  if ($yinstagram_options['lightbox'] == 'colorbox') { wp_enqueue_style('yinstagram-colorbox'); } 
     87  wp_enqueue_style('yinstagram-style'); 
    10788 
     89  if ($yinstagram_options['scroll'] == 'auto') { wp_enqueue_script('yinstagram-simplyScroll'); } 
    10890  if ($yinstagram_options['lightbox'] == 'colorbox') { wp_enqueue_script('yinstagram-colorbox'); } 
    109  
    11091  wp_enqueue_script('yinstagram-script'); 
    11192} 
Note: See TracChangeset for help on using the changeset viewer.