option_defaults(); $bytab = $this->admin_get_options_by_tab( $currenttab ); foreach( $bytab as $id){ $new = (isset($newoptions[$id])?$newoptions[$id]:''); $old = (isset($oldoptions[$id])?$oldoptions[$id]:''); $opt = (isset($options[$id])?$options[$id]:''); $oldoptions[$id] = $this->MenuOptionsValidate( $new, $old, $opt ); // Make changes to existing options array } update_option( $this->get_private('settings'), $oldoptions); return $oldoptions; } ////////////////////////////////////////////////////////////////////////////////////// ////////////////////// Admin Option Functions ////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// /** * Create array of option names for a given tab * * @ Since 1.2.0 */ function admin_get_options_by_tab( $tab = 'generator' ){ $default_options = $this->option_defaults(); $return = array(); foreach($default_options as $key => $val){ if( $val['tab'] == $tab ){ $return[$key] = $key; } } return $return; } /** * Create array of option names and current values for a given tab * * @ Since 1.2.0 */ function admin_get_settings_by_tab( $tab = 'generator' ){ $current = $this->get_all_options(); $default_options = $this->option_defaults(); $return = array(); foreach($default_options as $key => $val){ if( $val['tab'] == $tab ){ $return[$key] = $current[$key]; } } return $return; } /** * Create array of positions for a given tab along with a list of settings for each position * * @ Since 1.2.0 * @ Updated 1.2.3 */ function get_option_positions_by_tab( $tab = 'generator' ){ $positions = $this->admin_option_positions(); $return = array(); if( isset($positions[$tab]) ){ $options = $this->admin_get_options_by_tab( $tab ); $defaults = $this->option_defaults(); foreach($positions[$tab] as $pos => $info ){ $return[$pos]['title'] = (isset($info['title'])?$info['title']:''); $return[$pos]['description'] = (isset($info['description'])?$info['description']:''); $return[$pos]['options'] = array(); } foreach($options as $name){ $pos = (isset($defaults[$name]['position'])?$defaults[$name]['position']:'none'); $return[ $pos ]['options'][] = $name; } } return $return; } /** * Create array of positions for each widget along with a list of settings for each position * * @ Since 1.2.0 */ function admin_get_widget_options_by_position(){ $default_options = $this->option_defaults(); $positions = $this->admin_widget_positions(); $return = array(); foreach($positions as $key => $val ){ $return[$key]['title'] = $val; $return[$key]['options'] = array(); } foreach($default_options as $key => $val){ if(!empty($val['widget'])){ $return[ $val['position'] ]['options'][] = $key; } } return $return; } ////////////////////////////////////////////////////////////////////////////////////// /////////////////////// Admin Page Functions ////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// /** * Create shortcode based on given options * * @ Since 1.1.0 * @ Update 1.2.5 */ function admin_generate_shortcode( $options, $optiondetails ){ $short = '['.$this->get_private('short'); $trigger = ''; foreach( $options as $key=>$value ){ if($value && isset($optiondetails[$key]['short'])){ if( isset($optiondetails[$key]['child']) && isset($optiondetails[$key]['hidden']) ){ $hidden = @explode(' ',$optiondetails[$key]['hidden']); if( !in_array( $options[ $optiondetails[$key]['child'] ] ,$hidden) ){ $short .= ' '.$optiondetails[$key]['short'].'="'.$value.'"'; } }else{ $short .= ' '.$optiondetails[$key]['short'].'="'.$value.'"'; } } } $short .= ']'; return $short; } /** * Define Settings Page Tab Markup * * @since 1.1.0 * @link`http://www.onedesigns.com/tutorials/separate-multiple-theme-options-pages-using-tabs Daniel Tara * */ function admin_options_page_tabs( $current = 'general' ) { $tabs = $this->admin_settings_page_tabs(); $links = array(); foreach( $tabs as $tab ){ $tabname = $tab['name']; $tabtitle = $tab['title']; if( $tabname == $current ){ $links[] = ''.$tabtitle.''; }else{ $links[] = ''.$tabtitle.''; } } echo '

'.$this->get_private('name').'

'; echo '
'; } /** * Function for printing general settings page * * @ Since 1.2.0 * @ Updated 1.2.4 */ function admin_display_general(){ ?>

get_private('name'); _e(", a WordPress plugin by the Alpine Press.");?>

check_private('termsofservice') ) { echo '

'.$this->get_private('termsofservice').'

'; }?>

the Alpine Press.


check_private('plugins') && is_array( $this->get_private('plugins') ) ){ foreach($this->get_private('plugins') as $each){ ?>

Please support further development of this plugin with a small donation.

get_all_options(); $settings_section = $this->get_private('id'). '_' . $currenttab . '_tab'; $submitted = ( ( isset($_POST[ "hidden" ]) && ($_POST[ "hidden" ]=="Y") ) ? true : false ); if( $submitted ){ $options = $this->admin_simple_update( $currenttab, $_POST, $options ); } $buttom = (isset($_POST[$this->get_private('settings').'_'.$currenttab]['submit-'.$currenttab])?$_POST[$this->get_private('settings').'_'.$currenttab]['submit-'.$currenttab]:''); if( $buttom == 'Delete Current Cache' ){ $bot = new PhotoTileForInstagramBot(); $bot->clearAllCache(); echo '
'.__("Cache Cleared").'
'; } elseif( $buttom == 'Save Settings' ){ $bot = new PhotoTileForInstagramBot(); $bot->clearAllCache(); echo '
'.__("Settings Saved").'
'; } echo '
'; echo ''; $this->admin_display_opt_form($options,$currenttab); echo '
'; echo '
'; } /** * Second function for printing options page * * @ Since 1.1.0 * @ Updated 1.2.5 * */ function admin_display_opt_form($options,$currenttab){ $defaults = $this->option_defaults(); $positions = $this->get_option_positions_by_tab( $currenttab ); $submitted = ( ( isset($_POST[ "hidden" ]) && ($_POST[ "hidden" ]=="Y") ) ? true : false ); if( 'generator' == $currenttab ) { $preview = (isset($_POST[ $this->get_private('settings').'_preview']['submit-preview']) && $_POST[ $this->get_private('settings').'_preview']['submit-preview'] == 'Preview')?true:false; if( $submitted && isset($_POST['shortcode']) && $preview ){ $short = str_replace('\"','"',$_POST['shortcode']); }elseif( $submitted ){ $short = $this->admin_generate_shortcode( $_POST, $defaults ); } ?>

This tool allows you to create shortcodes for the Alpine PhotoTile plugin.

A shortcode is a line of text that tells WordPress how to load a plugin inside the content of a page or post. Rather than explaining how to put together a shortcode, this tool will create the shortcode for you.

Now, copy (Crtl+C) and paste (Crtl+V) the following shortcode into a page or post. Or preview using the button below.

'; echo do_shortcode($short); echo ''; } } echo '
'; } if( !empty($positions) && count($positions) ){ foreach( $positions as $position=>$positionsinfo){ echo '
'; if( !empty($positionsinfo['title']) ){ echo '

'. $positionsinfo['title'].'

'; } if( !empty($positionsinfo['description']) ){ echo '
'. $positionsinfo['description'].'
'; } echo ''; echo ''; if( !empty($positionsinfo['options']) && count($positionsinfo['options']) ){ foreach( $positionsinfo['options'] as $optionname ){ $option = $defaults[$optionname]; $fieldname = ( $option['name'] ); $fieldid = ( $option['name'] ); if( !empty($option['hidden-option']) && !empty($option['check']) ){ $show = $this->get_option( $option['check'] ); if( !$show ){ continue; } } if(isset($option['parent'])){ $class = $option['parent']; }elseif(isset($option['child'])){ $class =($option['child']); }else{ $class = ('unlinked'); } $trigger = (isset($option['trigger'])?('data-trigger="'.(($option['trigger'])).'"'):''); $hidden = (isset($option['hidden'])?' '.$option['hidden']:''); if( 'generator' == $currenttab ){ echo ''; }else{ echo ''; } } } echo ''; echo '
'; $this->MenuDisplayCallback($options,$option,$fieldname,$fieldid); echo '
'; $this->AdminDisplayCallback($options,$option,$fieldname,$fieldid); echo '
'; echo '
'; } } if( 'generator' == $currenttab ) { echo ''; }elseif( 'plugin-settings' == $currenttab ){ echo ''; echo ''; } } ////////////////////////////////////////////////////////////////////////////////////// ////////////////////// Menu Display Functions ///////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// /** * Function for displaying forms in the widget page * * @ Since 1.0.0 * @ Updated 1.2.5 */ function MenuDisplayCallback($options,$option,$fieldname,$fieldid){ $default = (isset($option['default'])?$option['default']:''); $optionname = (isset($option['name'])?$option['name']:''); $optiontitle = (isset($option['title'])?$option['title']:''); $optiondescription = (isset($option['description'])?$option['description']:''); $fieldtype = (isset($option['type'])?$option['type']:''); $value = ( isset($options[$optionname]) ? $options[$optionname] : $default ); // Output checkbox form field markup if ( 'checkbox' == $fieldtype ) { ?> /> value="" />

/>
value="" />

=$min && $newinput<=$max) ? $newinput : $valid_input ); } // Validate text input and textarea fields else if ( ( 'text' == $type || 'textarea' == $type || 'image-upload' == $type) ) { $valid_input = strip_tags( $newinput ); $sanatize = (isset($optiondetails['sanitize'])?$optiondetails['sanitize']:''); // Validate no-HTML content // nospaces option offers additional filters if ( 'nospaces' == $sanatize ) { // Pass input data through the wp_filter_nohtml_kses filter $valid_input = wp_filter_nohtml_kses( $newinput ); // Remove specified character(s) if( isset($optiondetails['remove']) ){ if( is_array($optiondetails['remove']) ){ foreach( $optiondetails['remove'] as $remove ){ $valid_input = str_replace($remove,'',$valid_input); } }else{ $valid_input = str_replace($optiondetails['remove'],'',$valid_input); } } // Switch or encode characters if( isset($optiondetails['encode']) && is_array( $optiondetails['encode'] ) ){ foreach( $optiondetails['encode'] as $find=>$replace ){ $valid_input = str_replace($find,$replace,$valid_input); } } // Replace spaces with provided character or just remove spaces if( isset($optiondetails['replace']) ){ $valid_input = str_replace(array(' ',' '),$optiondetails['replace'],$valid_input); }else{ $valid_input = str_replace(' ','',$valid_input); } } // Check if numeric elseif ( 'numeric' == $sanatize && is_numeric( wp_filter_nohtml_kses( $newinput ) ) ) { // Pass input data through the wp_filter_nohtml_kses filter $valid_input = wp_filter_nohtml_kses( $newinput ); if( isset($optiondetails['min']) && $valid_input<$optiondetails['min']){ $valid_input = $optiondetails['min']; } if( isset($optiondetails['max']) && $valid_input>$optiondetails['max']){ $valid_input = $optiondetails['max']; } } elseif ( 'int' == $sanatize && is_numeric( wp_filter_nohtml_kses( $newinput ) ) ) { // Pass input data through the wp_filter_nohtml_kses filter $valid_input = round( wp_filter_nohtml_kses( $newinput ) ); if( isset($optiondetails['min']) && $valid_input<$optiondetails['min']){ $valid_input = $optiondetails['min']; } if( isset($optiondetails['max']) && $valid_input>$optiondetails['max']){ $valid_input = $optiondetails['max']; } } elseif ( 'tag' == $sanatize ) { // Pass input data through the wp_filter_nohtml_kses filter $valid_input = wp_filter_nohtml_kses( $newinput ); $valid_input = str_replace(' ','-',$valid_input); } // Validate no-HTML content elseif ( 'nohtml' == $sanatize ) { // Pass input data through the wp_filter_nohtml_kses filter $valid_input = wp_filter_nohtml_kses( $newinput ); $valid_input = str_replace(' ','',$valid_input); } // Validate HTML content elseif ( 'html' == $sanatize ) { // Pass input data through the wp_filter_kses filter using allowed post tags $valid_input = wp_kses_post($newinput ); } // Validate URL address elseif( 'url' == $sanatize ){ $valid_input = esc_url( $newinput ); } // Validate CSS elseif( 'css' == $sanatize ){ $valid_input = wp_htmledit_pre( stripslashes( $newinput ) ); } // Just strip slashes elseif( 'stripslashes' == $sanatize ){ $valid_input = stripslashes( $newinput ); } }else if( 'wp-textarea' == $type ){ // Text area filter $valid_input = wp_kses_post( force_balance_tags($newinput) ); } elseif( 'color' == $type ){ $value = wp_filter_nohtml_kses( $newinput ); if( '#' == $value ){ $valid_input = ''; }else{ $valid_input = $value; } } return $valid_input; } } /** ############################################################################################################################################## * ############################################################################################################################################## * ############################################################################################################################################## * ############################################################################################################################################## * ############################################################################################################################################## * ############################################################################################################################################## * ############################################################################################################################################## * ############################################################################################################################################## * * AlpineBot * * ADMIN Functions * Contains ONLY UNIQUE ADMIN functions * * ########################################################################################## */ class PhotoTileForInstagramAdmin extends PhotoTileForInstagramAdminSecondary{ ////////////////////////////////////////////////////////////////////////////////////// //////////////////// Unique Admin Functions //////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// /** * Add User * * @ Since 1.2.0 * @ Updated 1.2.4 */ function AddUser( $post_content ){ /* $post_content = array( 'access_token' => $access_token, 'username' => $user->username, 'picture' => $user->profile_picture, 'fullname' => $user->full_name, 'client_id' => $client_id, 'client_secret' => $client_secret );*/ if( !empty($post_content['access_token']) && !empty($post_content['username']) && !empty($post_content['user_id']) ){ $user = $post_content['username']; $oldoptions = $this->get_all_options(); $currentUsers = $oldoptions['users']; //if( empty($currentUsers[ $user ]) || ($currentUsers[ $user ]['access_token'] != $post_content['access_token']) ){ $post_content['name'] = $user; $post_content['title'] = $user; $currentUsers[ $user ] = $post_content; $oldoptions['users'] = $currentUsers; update_option( $this->get_private('settings'), $oldoptions); //} } return true; } /** * Delete User * * @since 1.2.0 * */ function DeleteUser( $user ){ $oldoptions = $this->get_all_options(); $currentUsers = $oldoptions['users']; if( !empty($currentUsers[$user]) ){ unset($currentUsers[$user]); } $oldoptions['users'] = $currentUsers; update_option( $this->get_private('settings'), $oldoptions); } /** * Update User * * @since 1.2.0 * */ function UpdateUser( $data ){ $oldoptions = $this->get_all_options(); $currentUsers = $oldoptions['users']; if( !empty($data['username']) && !empty($oldoptions['users']) && !empty($oldoptions['users'][$data['username']]) ) { $current = $oldoptions['users'][$data['username']]; foreach( $data as $k=>$v ){ if( !empty($v) ){ $current[$k] = $v; } } $oldoptions['users'][$data['username']] = $current; update_option( $this->get_private('settings'), $oldoptions); } } /** * Alpine PhotoTile: Options Page * * @ Since 1.1.1 * @ Updated 1.2.4 */ function admin_build_settings_page(){ $currenttab = isset( $_GET['tab'] )?$_GET['tab']:'general'; echo '
'; $this->admin_options_page_tabs( $currenttab ); echo '
'; echo '
'; if( 'general' == $currenttab ){ $this->admin_display_general(); }elseif( 'add' == $currenttab ){ $this->admin_display_add(); }else{ $this->admin_setup_options_form($currenttab); } echo '
'; echo '
'; $this->admin_donate_button(); echo ''; echo '
'; echo '
'; // Close Container echo '
'; // Close wrap } /** * Show User Function * * @ Since 1.2.0 * @ Updated 1.2.5 */ function show_user($info){ $name = (isset($info['username'])?$info['username']:'user'); $picture = (isset($info['picture'])?$info['picture']:'user'); $output = '
'; $output .= '

'.$name.'

'; $output .= '
'; // Not currently needed $output .= '
'; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= '
'; $output .= '
'; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= '
'; $output .= '
'; return $output; } /** * Show User Javascript * * @ Since 1.2.0 * * // Not currently needed */ function show_user_js($info){ $redirect = admin_url( 'options-general.php?page='.$this->get_private('settings').'&tab=add' ); $output = 'jQuery(document).ready(function() {var url = "https://api.instagram.com/oauth/authorize/"+"?redirect_uri=" + encodeURIComponent("'.$redirect . '")+ "&response_type=code" + "&client_id='.$info['client_id'].'" + "&display=touch";jQuery("#'.$this->get_private('settings').'-user-'.$info['username'].'").ajaxForm({ success: function(responseText){ window.location.replace(url); } }); });'; return $output; } /** * Display Add User Page * * @ Since 1.2.0 * @ Updated 1.2.6 */ function admin_display_add(){ $currenttab = 'add'; $options = $this->get_all_options(); $settings_section = $this->get_private('id') . '_'.$currenttab.'_tab'; $submitted = ( ( isset($_POST[ "hidden" ]) && ($_POST[ "hidden" ]=="Y") ) ? true : false ); $redirect = admin_url( 'options-general.php?page='.$this->get_private('settings').'&tab='.$currenttab ); $success = false; $errormessage = null; $errortype = null; if( isset($_POST['add-user']) ){ if( !empty($_POST['client_id']) && !empty($_POST['client_secret']) ){ $options = $this->admin_simple_update( $currenttab, $_POST, $options ); // Don't display previously input info ?> DeleteUser( $user ); } elseif( isset($_POST['update-user']) && isset($_POST['user']) ){ $user = $_POST['user']; $users = $this->get_instagram_users(); if( !empty($users) && !empty($users[$user]) && !empty($users[$user]['access_token']) && !empty($users[$user]['user_id']) ){ $request = 'https://api.instagram.com/v1/users/'.$users[$user]['user_id'].'/?access_token='.$users[$user]['access_token']; $response = wp_remote_get($request, array( 'method' => 'GET', 'timeout' => 10, 'sslverify' => apply_filters('https_local_ssl_verify', false) ) ); if( is_wp_error( $response ) || !isset($response['body']) ) { // Try again if( method_exists( $this, 'manual_cURL' ) ){ $content = $this->manual_cURL($request); } if( !isset($content) ){ $errormessage = 'User not updated'; } }else{ $content = $response['body']; } if( isset( $content ) ){ if( function_exists('json_decode') ){ $_instagram_json = @json_decode( $content, true ); } if( empty($_instagram_json) && method_exists( $this, 'json_decoder' ) ){ $_instagram_json = $this->json_decoder($content); } if( empty($_instagram_json) || 200 != $_instagram_json['meta']['code'] ){ $errormessage = 'User not updated'; }elseif( !empty($_instagram_json['data']) ){ $data = $_instagram_json['data']; $post_content = array( 'access_token' => $users[$user]['access_token'], 'username' => $data['username'], 'picture' => $data['profile_picture'], 'fullname' => $data['full_name'], 'user_id' => $users[$user]['user_id'] ); $this->UpdateUser( $post_content ); $update = true; } } } } elseif( $submitted && isset($_POST['manual-user-form']) && !empty($_POST['access_token']) && !empty($_POST['user_id']) && !empty($_POST['client_id']) && !empty($_POST['username']) ){ $success = $this->AddUser($_POST); } elseif( isset($_GET['code']) ) { $code = $_GET['code']; $client_id = $this->get_option('client_id'); $client_secret = $this->get_option('client_secret'); $url = 'https://api.instagram.com/oauth/access_token'; $fields = array( 'code' => $code, 'response_type' => 'authorization_code', 'redirect_uri' => $redirect, 'client_id' => $client_id, 'client_secret' => $client_secret, 'grant_type' => 'authorization_code' ); $response = wp_remote_post($url, array( 'body' => $fields, 'sslverify' => apply_filters('https_local_ssl_verify', false) ) ); $access_token = null; $username = null; $image = null; if( is_wp_error( $response ) || !isset($response['body']) ) { // Try again if( method_exists( $this, 'manual_cURL' ) ){ $content = $this->manual_cURL($url,$fields); } if( !isset($content) ){ $errormessage = 'User not added'; } }else{ $content = $response['body']; } if( isset($content) ) { if( function_exists('json_decode') ){ $auth = @json_decode( $content, true ); } if( empty($auth) && method_exists( $this, 'json_decoder' ) ){ // Try alternative decode $auth = $this->json_decoder($content); } if( isset($auth['access_token']) ) { $access_token = $auth['access_token']; $user = $auth['user']; $post_content = array( 'access_token' => $access_token, 'username' => $user['username'], 'picture' => $user['profile_picture'], 'fullname' => $user['full_name'], 'user_id' => $user['id'], 'client_id' => $client_id, 'client_secret' => $client_secret ); $success = $this->AddUser($post_content); }else{ $errormessage = 'No access token found'; } }elseif( !is_wp_error($response) && $response['response']['code'] >= 400 ) { $error = json_decode($response['body']); $errormessage = $error->error_message; $errortype = $error->error_type; } } $defaults = $this->option_defaults(); $positions = $this->get_option_positions_by_tab( $currenttab ); echo '
'; if( !empty($success) ){ echo '
User successfully authorized.
'; }elseif( !empty($update) ){ echo '
User ('.$user.') updated.
'; }elseif( !empty($delete) ){ echo '
User ('.$user.') deleted.
'; }elseif( !empty($errormessage) ){ echo '
An error occured ('.$errormessage.').
'; } if( count($positions) ){ foreach( $positions as $position=>$positionsinfo){ if( $position == 'top'){ echo '
'; if( $positionsinfo['title'] ){ echo '

'. $positionsinfo['title'].'

'; } $users = $this->get_instagram_users(); if( empty($users) || ( is_array( $users ) && isset($users['none']) && is_array( $users['none'] ) ) ){ echo '

No users available. Add a user by following the instructions below.

'; }elseif( !empty($users) && is_array($users) ){ foreach($users as $name=>$info){ echo $this->show_user($info); //echo ''; // Not currently needed } } echo '
'; }else{ echo '
'; ?>
" action="" method="post"> '; if( $positionsinfo['title'] ){ echo '

'. $positionsinfo['title'].'

'; } echo ''; echo ''; if( count($positionsinfo['options']) ){ foreach( $positionsinfo['options'] as $optionname ){ $option = $defaults[$optionname]; $fieldname = ( $option['name'] ); $fieldid = ( $option['name'] ); echo ''; } } echo ''; echo '
'; $this->AdminDisplayCallback(array() ,$option,$fieldname,$fieldid); // Don't display previously input info echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; } } } echo ''; // close add div ?>

:

(!!!)

(Please let me know if these directions become outdated)");?>

  1. http://instagram.com/developer.
  2. get_private('name');?> WordPress plugin

          ****

If the above method does not seem to be working:

I have setup a troubleshooting tool at the Alpine Press that you can use to manually retrieve the information you need.

Once this is done, fill out and submit the form below.

'Username','user_id' =>'User ID','access_token' => 'Access Token','client_id' => 'Client ID','client_secret' => 'Client Secret','picture' => 'Picture'); foreach($the_content as $name=>$title){ ?>