settings );
// No need to initialize options since defaults are applied as needed
return ( NULL!==$options[$option_string] ? $options[$option_string] : $this->set_default_option( $options, $option_string ) );
}
/**
* Simple function to array of all option settings
*
* @ Since 1.2.0
*/
function get_all_options(){
$options = get_option( $this->settings );
$defaults = $this->option_defaults();
foreach( $defaults as $option_string => $details ){
if( NULL === $options[$option_string] && !empty($default_options[$option_string]['default']) ){
$options[$option_string] = $default_options[$option_string]['default'];
}
}
//update_option( $this->settings, $options ); Unnecessary since options will soon be updated if this fuction was called
return $options;
}
/**
* Correctly set and save the option's default setting
*
* @ Since 1.2.0
*/
function set_default_option( $options, $option_string ){
$default_options = $this->option_defaults();
if( NULL !== $default_options[$option_string] ){
$options[$option_string] = $default_options[$option_string]['default'];
update_option( $this->settings, $options );
return $options[$option_string];
}else{
return NULL;
}
}
/**
* Create array of option names for a given tab
*
* @ Since 1.2.0
*/
function 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 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->option_positions();
$return = array();
if( NULL !== $positions[$tab] ){
$options = $this->get_options_by_tab( $tab );
$defaults = $this->option_defaults();
foreach($positions[$tab] as $pos => $info ){
$return[$pos]['title'] = $info['title'];
$return[$pos]['description'] = $info['description'];
$return[$pos]['options'] = array();
}
foreach($options as $name){
$pos = $defaults[$name]['position'];
$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 get_widget_options_by_position(){
$default_options = $this->option_defaults();
$positions = $this->widget_positions();
$return = array();
foreach($positions as $key => $val ){
$return[$key]['title'] = $val;
$return[$key]['options'] = array();
}
foreach($default_options as $key => $val){
if($val['widget']){
$return[ $val['position'] ]['options'][] = $key;
}
}
return $return;
}
/**
* Register styles and scripts
*
* @ Since 1.2.3
*
*/
function register_style_and_script(){
wp_register_script($this->wjs,$this->url.'/js/'.$this->wjs.'.js','',$this->ver);
wp_register_style($this->wcss,$this->url.'/css/'.$this->wcss.'.css','',$this->ver);
$lightbox = $this->get_option('general_lightbox');
$prevent = $this->get_option('general_lightbox_no_load');
if( 'fancybox' == $lightbox && !$prevent ){
wp_register_script( 'fancybox', $this->url.'/js/fancybox/jquery.fancybox-1.3.4.pack.js', '', '1.3.4', true );
wp_register_style( 'fancybox-stylesheet', $this->url . '/js/fancybox/jquery.fancybox-1.3.4.css', false, '1.3.4', 'screen' );
}elseif( 'prettyphoto' == $lightbox && !$prevent ){
wp_register_script( 'prettyphoto', $this->url.'/js/prettyphoto/js/jquery.prettyPhoto.js', '', '3.1.4', true );
wp_register_style( 'prettyphoto-stylesheet', $this->url . '/js/prettyphoto/css/prettyPhoto.css', false, '3.1.4', 'screen' );
}elseif( 'colorbox' == $lightbox && !$prevent ){
wp_register_script( 'colorbox', $this->url.'/js/colorbox/jquery.colorbox-min.js', '', '1.3.21', true );
wp_register_style( 'colorbox-stylesheet', $this->url . '/js/colorbox/colorbox.css', false, '3.1.4', 'screen' );
}elseif( 'alpine-fancybox' == $lightbox ){
wp_register_script( 'fancybox-alpine', $this->url.'/js/fancybox-alpine-safemode/jquery.fancyboxForAlpine-1.3.4.pack.js', '', '1.3.4', true );
wp_register_style( 'fancybox-alpine-stylesheet', $this->url . '/js/fancybox-alpine-safemode/jquery.fancyboxForAlpine-1.3.4.css', false, '1.3.4', 'screen' );
}
// Enable loading the styles and scripts in the header
$headerload = $this->get_option('general_load_header');
if( $headerload ){
if( 'fancybox' == $lightbox && !$prevent ){
wp_enqueue_script( 'fancybox' );
wp_enqueue_style( 'fancybox-stylesheet');
}elseif( 'prettyphoto' == $lightbox && !$prevent ){
wp_enqueue_script( 'prettyphoto' );
wp_enqueue_style( 'prettyphoto-stylesheet');
}elseif( 'colorbox' == $lightbox && !$prevent ){
wp_enqueue_script( 'colorbox' );
wp_enqueue_style( 'colorbox-stylesheet' );
}elseif( 'alpine-fancybox' == $lightbox ){
wp_enqueue_script( 'fancybox-alpine' );
wp_enqueue_style( 'fancybox-alpine-stylesheet' );
}
wp_enqueue_style($this->wcss);
wp_enqueue_script($this->wjs);
}
}
/**
* Enqueue styles and scripts
*
* @ Since 1.2.3
*
*/
function enqueue_style_and_script(){
$headerload = $this->get_option('general_load_header');
if( !$headerload ){
// Change web source
if( $this->options['instagram_image_link_option'] == "fancybox" ){
$lightbox = $this->get_option('general_lightbox');
$prevent = $this->get_option('general_lightbox_no_load');
if( 'fancybox' == $lightbox && !$prevent ){
wp_enqueue_script( 'fancybox' );
wp_enqueue_style( 'fancybox-stylesheet');
}elseif( 'prettyphoto' == $lightbox && !$prevent ){
wp_enqueue_script( 'prettyphoto' );
wp_enqueue_style( 'prettyphoto-stylesheet');
}elseif( 'colorbox' == $lightbox && !$prevent ){
wp_enqueue_script( 'colorbox' );
wp_enqueue_style( 'colorbox-stylesheet' );
}elseif( 'alpine-fancybox' == $lightbox ){
wp_enqueue_script( 'fancybox-alpine' );
wp_enqueue_style( 'fancybox-alpine-stylesheet' );
}
}
wp_enqueue_style($this->wcss);
wp_enqueue_script($this->wjs);
}
}
/**
* Options Simple Update for Admin Page
*
* @since 1.2.0
*
*/
function SimpleUpdate( $currenttab, $newoptions, $oldoptions ){
$options = $this->option_defaults();
$bytab = $this->get_options_by_tab( $currenttab );
foreach( $bytab as $id){
$oldoptions[$id] = $this->MenuOptionsValidate( $newoptions[$id],$oldoptions[$id],$options[$id] );
}
update_option( $this->settings, $oldoptions);
return $oldoptions;
}
/**
* Function for displaying forms in the widget page
*
* @since 1.0.0
*
*/
function MenuDisplayCallback($options,$option,$fieldname,$fieldid){
$default = $option['default'];
$optionname = $option['name'];
$optiontitle = $option['title'];
$optiondescription = $option['description'];
$fieldtype = $option['type'];
$value = ( Null !== $options[$optionname] ? $options[$optionname] : $default );
// Output checkbox form field markup
if ( 'checkbox' == $fieldtype ) {
?>
/>
value="" />
/>
value="" />
=$optiondetails['min'] && $newinput<=$optiondetails['max']) ? $newinput : $valid_input );
}
// Validate text input and textarea fields
else if ( ( 'text' == $optiondetails['type'] || 'textarea' == $optiondetails['type'] || 'image-upload' == $optiondetails['type']) ) {
$valid_input = strip_tags( $newinput );
// Validate no-HTML content
// nospaces option offers additional filters
if ( 'nospaces' == $optiondetails['sanitize'] ) {
// Pass input data through the wp_filter_nohtml_kses filter
$valid_input = wp_filter_nohtml_kses( $newinput );
// Remove specified character(s)
if(Null !== $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( 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(Null !== $optiondetails['replace']){
$valid_input = str_replace(array(' ',' '),$optiondetails['replace'],$valid_input);
}else{
$valid_input = str_replace(' ','',$valid_input);
}
}
// Check if numeric
if ( 'numeric' == $optiondetails['sanitize'] && 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( NULL !== $optiondetails['min'] && $valid_input<$optiondetails['min']){
$valid_input = $optiondetails['min'];
}
if( NULL !== $optiondetails['max'] && $valid_input>$optiondetails['max']){
$valid_input = $optiondetails['max'];
}
}
if ( 'int' == $optiondetails['sanitize'] && 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( NULL !== $optiondetails['min'] && $valid_input<$optiondetails['min']){
$valid_input = $optiondetails['min'];
}
if( NULL !== $optiondetails['max'] && $valid_input>$optiondetails['max']){
$valid_input = $optiondetails['max'];
}
}
if ( 'tag' == $optiondetails['sanitize'] ) {
// 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
if ( 'nohtml' == $optiondetails['sanitize'] ) {
// 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
if ( 'html' == $optiondetails['sanitize'] ) {
// Pass input data through the wp_filter_kses filter using allowed post tags
$valid_input = wp_kses_post($newinput );
}
// Validate URL address
if( 'url' == $optiondetails['sanitize'] ){
$valid_input = esc_url( $newinput );
}
// Validate URL address
if( 'css' == $optiondetails['sanitize'] ){
$valid_input = wp_htmledit_pre( stripslashes( $newinput ) );
}
}else if( 'wp-textarea' == $optiondetails['type'] ){
// Text area filter
$valid_input = wp_kses_post( force_balance_tags($newinput) );
}
elseif( 'color' == $optiondetails['type'] ){
$value = wp_filter_nohtml_kses( $newinput );
if( '#' == $value ){
$valid_input = '';
}else{
$valid_input = $value;
}
}
return $valid_input;
}
/**
* Get current settings page tab
*
* @since 1.2.0
*
*/
function get_current_tab( $current = 'general' ) {
if ( isset ( $_GET['tab'] ) ) :
$current = $_GET['tab'];
else:
$current = 'general';
endif;
return $current;
}
/**
* Create shortcode based on given options
*
* @since 1.1.0
*
*/
function generate_shortcode( $options, $optiondetails ){
$short = '['.$this->short;
$trigger = '';
foreach( $options as $key=>$value ){
if($value && $optiondetails[$key]['short']){
if( $optiondetails[$key]['child'] && $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->settings_page_tabs();
$links = array();
foreach( $tabs as $tab ) :
$tabname = $tab['name'];
$tabtitle = $tab['title'];
if ( $tabname == $current ) :
$links[] = "$tabtitle";
else :
$links[] = "$tabtitle";
endif;
endforeach;
echo '';
echo '';
}
/**
* Function for printing general settings page
*
* @since 1.2.0
*
*/
function display_general(){
?>
option_defaults();
$positions = $this->get_option_positions_by_tab( $currenttab );
if( 'generator' == $currenttab ) {
echo '
';
if($short){
echo ' Now, copy (Crtl+C) and paste (Crtl+P) the following shortcode into a page or post.
';
echo '
';
}
}
if( count($positions) ){
foreach( $positions as $position=>$positionsinfo){
echo '';
if( $positionsinfo['title'] ){ echo '
'. $positionsinfo['title'].'
'; }
if( $positionsinfo['description'] ){ echo '
'. $positionsinfo['description'].'
'; }
echo '
';
echo '
';
}
}
echo ''. __('Need Help? Visit ') .'the Alpine Press'. __(" for more about this plugin.") .' ';
if( 'generator' == $currenttab ) {
echo '';
}elseif( 'plugin-settings' == $currenttab ){
echo '';
echo '';
}
}
/**
* Functions for caching results and clearing cache
*
* @since 1.1.0
*
*/
public function setCacheDir($val) { $this->cacheDir = $val; }
public function setExpiryInterval($val) { $this->expiryInterval = $val; }
public function getExpiryInterval($val) { return (int)$this->expiryInterval; }
public function cacheExists($key) {
$filename_cache = $this->cacheDir . '/' . $key . '.cache'; //Cache filename
$filename_info = $this->cacheDir . '/' . $key . '.info'; //Cache info
if (file_exists($filename_cache) && file_exists($filename_info)) {
$cache_time = file_get_contents ($filename_info) + (int)$this->expiryInterval; //Last update time of the cache file
$time = time(); //Current Time
$expiry_time = (int)$time; //Expiry time for the cache
if ((int)$cache_time >= (int)$expiry_time) {//Compare last updated and current time
return true;
}
}
return false;
}
public function getCache($key) {
$filename_cache = $this->cacheDir . '/' . $key . '.cache'; //Cache filename
$filename_info = $this->cacheDir . '/' . $key . '.info'; //Cache info
if (file_exists($filename_cache) && file_exists($filename_info)) {
$cache_time = file_get_contents ($filename_info) + (int)$this->expiryInterval; //Last update time of the cache file
$time = time(); //Current Time
$expiry_time = (int)$time; //Expiry time for the cache
if ((int)$cache_time >= (int)$expiry_time){ //Compare last updated and current time
return file_get_contents ($filename_cache); //Get contents from file
}
}
return null;
}
public function putCache($key, $content) {
$time = time(); //Current Time
if ( ! file_exists($this->cacheDir) ){
@mkdir($this->cacheDir);
$cleaning_info = $this->cacheDir . '/cleaning.info'; //Cache info
@file_put_contents ($cleaning_info , $time); // save the time of last cache update
}
if ( file_exists($this->cacheDir) && is_dir($this->cacheDir) ){
$dir = $this->cacheDir . '/';
$filename_cache = $dir . $key . '.cache'; //Cache filename
$filename_info = $dir . $key . '.info'; //Cache info
@file_put_contents($filename_cache , $content); // save the content
@file_put_contents($filename_info , $time); // save the time of last cache update
}
}
public function clearAllCache() {
$dir = $this->cacheDir . '/';
if(is_dir($dir)){
$opendir = @opendir($dir);
while(false !== ($file = readdir($opendir))) {
if($file != "." && $file != "..") {
if(file_exists($dir.$file)) {
$file_array = @explode('.',$file);
$file_type = @array_pop( $file_array );
// only remove cache or info files
if( 'cache' == $file_type || 'info' == $file_type){
@chmod($dir.$file, 0777);
@unlink($dir.$file);
}
}
/*elseif(is_dir($dir.$file)) {
@chmod($dir.$file, 0777);
@chdir('.');
@destroy($dir.$file.'/');
@rmdir($dir.$file);
}*/
}
}
@closedir($opendir);
}
}
public function cleanCache() {
$cleaning_info = $this->cacheDir . '/cleaning.info'; //Cache info
if (file_exists($cleaning_info)) {
$cache_time = file_get_contents ($cleaning_info) + (int)$this->cleaningInterval; //Last update time of the cache cleaning
$time = time(); //Current Time
$expiry_time = (int)$time; //Expiry time for the cache
if ((int)$cache_time < (int)$expiry_time){ //Compare last updated and current time
// Clean old files
$dir = $this->cacheDir . '/';
if(is_dir($dir)){
$opendir = @opendir($dir);
while(false !== ($file = readdir($opendir))) {
if($file != "." && $file != "..") {
if(is_dir($dir.$file)) {
//@chmod($dir.$file, 0777);
//@chdir('.');
//@destroy($dir.$file.'/');
//@rmdir($dir.$file);
}
elseif(file_exists($dir.$file)) {
$file_array = @explode('.',$file);
$file_type = @array_pop( $file_array );
$file_key = @implode( $file_array );
if( $file_type && $file_key && 'info' == $file_type){
$filename_cache = $dir . $file_key . '.cache'; //Cache filename
$filename_info = $dir . $file_key . '.info'; //Cache info
if (file_exists($filename_cache) && file_exists($filename_info)) {
$cache_time = file_get_contents ($filename_info) + (int)$this->cleaningInterval; //Last update time of the cache file
$expiry_time = (int)$time; //Expiry time for the cache
if ((int)$cache_time < (int)$expiry_time) {//Compare last updated and current time
@chmod($filename_cache, 0777);
@unlink($filename_cache);
@chmod($filename_info, 0777);
@unlink($filename_info);
}
}
}
}
}
}
@closedir($opendir);
}
@file_put_contents ($cleaning_info , $time); // save the time of last cache cleaning
}
}
}
/////////////////////////////////////////////////////////////
///////// Source-specific functions below this line /////////
/////////////////////////////////////////////////////////////
/**
* Add User
*
* @since 1.2.0
*
*/
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($post_content['access_token'] && $post_content['username'] && $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->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->settings, $oldoptions);
}
/**
* ReAuthorize User
*
* @since 1.2.0
*
*/
function ReAuthorize( $user ){
$oldoptions = $this->get_all_options();
$currentUsers = $oldoptions['users'];
$current = $currentUsers[ $user ];
if( $current['client_id'] && $current['client_secret'] ){
$oldoptions['client_id'] = $current['client_id'];
$oldoptions['client_secret'] = $current['client_secret'];
update_option( $this->settings, $oldoptions);
}
}
/**
* Alpine PhotoTile: Options Page
*
* @ Since 1.1.1
*
*/
function build_settings_page(){
$optiondetails = $this->option_defaults();
$currenttab = $this->get_current_tab();
echo '';
$this->admin_options_page_tabs( $currenttab );
echo '
';
if( 'general' == $currenttab ){
$this->display_general();
}elseif( 'add' == $currenttab ){
$this->display_add();
}elseif( 'preview' == $currenttab ){
$this->display_preview();
}else{
$options = $this->get_all_options();
$settings_section = $this->id . '_' . $currenttab . '_tab';
$submitted = ( ( isset($_POST[ "hidden" ]) && ($_POST[ "hidden" ]=="Y") ) ? true : false );
if( $submitted ){
$options = $this->SimpleUpdate( $currenttab, $_POST, $options );
if( 'generator' == $currenttab ) {
$short = $this->generate_shortcode( $options, $optiondetails );
}
}
echo '
';
if( $_POST[$this->settings.'_'.$currenttab]['submit-'.$currenttab] == 'Delete Current Cache' ){
$this->clearAllCache();
echo '
'.__("Cache Cleared").'
';
}
elseif( $_POST[$this->settings.'_'.$currenttab]['submit-'.$currenttab] == 'Save Settings' ){
$this->clearAllCache();
echo '
'.__("Settings Saved").'
';
}
echo '
';
echo '
';
}
echo '
'; // Close Container
echo '
'; // Close wrap
}
/**
* Show User Function
*
* @ Since 1.2.0
* @ Updated 1.2.3
*/
function show_user($info){
$output = '';
$output .= '
'.$info['username'].'
';
$output .= '
';
// Not currently needed
/* $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->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->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.3
*/
function display_add(){
wp_enqueue_script( 'jquery-form');
$currenttab = 'add';
$options = $this->get_all_options();
$settings_section = $this->id . '_'.$currenttab.'_tab';
$submitted = ( ( isset($_POST[ "hidden" ]) && ($_POST[ "hidden" ]=="Y") ) ? true : false );
$redirect = admin_url( 'options-general.php?page='.$this->settings.'&tab='.$currenttab );
$success = false;
$errormessage = null;
$errortype = null;
if (isset($_GET['code'])) {
$code = $_GET['code'];
$client_id = $this->get_option('client_id');
$client_secret = $this->get_option('client_secret');
$response = wp_remote_post("https://api.instagram.com/oauth/access_token",
array(
'body' => array(
'code' => $code,
'response_type' => 'authorization_code',
'redirect_uri' => $redirect,
'client_id' => $client_id,
'client_secret' => $client_secret,
'grant_type' => 'authorization_code'
),
'sslverify' => apply_filters('https_local_ssl_verify', false)
)
);
$access_token = null;
$username = null;
$image = null;
if(!is_wp_error($response) && $response['response']['code'] < 400 && $response['response']['code'] >= 200) {
$auth = json_decode($response['body']);
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);
$icon = $this->show_user($post_content);
$js = $this->show_user_js($post_content);
}
}elseif( !is_wp_error($response) && $response['response']['code'] >= 400 ) {
$error = json_decode($response['body']);
$errormessage = $error->error_message;
$errortype = $error->error_type;
}
}
if( $submitted && $_POST[ $this->settings.'_delete']['submit-delete'] == 'Delete User' ){
$delete = true;
$user = $_POST['user'];
$this->DeleteUser( $user );
}elseif( $submitted && $_POST[ $this->settings.'_reauthorize']['submit-reauthorize'] == 'Re-Authorize' ){
$user = $_POST['user'];
$this->ReAuthorize( $user );
}elseif( $submitted && $_POST[ $this->settings.'_add']['submit-add'] == 'Add and Authorize New User' ){
$options = $this->SimpleUpdate( $currenttab, $_POST, $options ); // Don't display previously input info
}elseif($submitted && $_POST['manual-user-form'] == 'Add New User' && $_POST['access_token'] && $_POST['user_id'] && $_POST['client_id'] && $_POST['username']){
$success = $this->AddUser($_POST);
}
$defaults = $this->option_defaults();
$positions = $this->get_option_positions_by_tab( $currenttab );
echo '';
if( $success ){
echo '
User successfully authorized.
';
}elseif( $delete ){
echo '
User ('.$user.') deleted.
';
}elseif( $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( $users['none']['name'] == 'none' ){
echo '
No users available. Add a user by following the instructions below.
';
}else{
foreach($users as $name=>$info){
echo $this->show_user($info);
//echo ''; // Not currently needed
}
}
echo '
';
}else{
echo '
';
echo '
';
echo '';
echo '
';
echo '
';
}
}
}
echo ''; // close add div
?>
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.