'theme1', 'client_id' => '', 'client_secret' => '', 'access_token' => '', 'instagram_user_id' => '', 'before_wrapper' => '', 'before_image_listing' => '
  • ', 'after_image_listing' => '
  • ', 'before_title' => '

    ', 'after_title' => '

    ', 'before_caption' => '

    ', 'after_caption' => '

    ', 'image_count' => '20', 'image_size' => 'standard_resolution', 'buffer_hours' => '1', 'show_user_details' => '1', ); add_option('twaic_settings', $defaults); } } // Clean up on uninstall register_deactivation_hook(__FILE__, 'twaic_deactivate'); function twaic_deactivate(){ delete_option('twaic_settings'); } // Render the settings page class twaic_settings_page { // Holds the values to be used in the fields callbacks private $options; // Start up public function __construct() { add_action( 'admin_menu', array( $this, 'add_plugin_page' ) ); add_action( 'admin_init', array( $this, 'page_init' ) ); } // Add settings page public function add_plugin_page() { add_menu_page( 'Advanced Instagram Carousel', 'AI Carousel', 'administrator', 'twaic', array($this,'create_admin_page'), plugins_url('asset/images/icon20x20.png',__FILE__ ) ); } // Options page callback public function create_admin_page() { // Set class property $this->options = get_option( 'twaic_settings' ); if(!$this->options){ twaic_set_options (); $this->options = get_option( 'twaic_settings' ); } ?>

    Advanced Instagram Carousel Settings

    $var){ if($key == 'twbs' || $key == 'interval' || $key == 'background_images_height'){ $new_input[$key] = absint( $input[$key] ); } else if ($key == 'link_button_before' || $key == 'link_button_after' || $key == 'before_title' || $key == 'after_title' || $key == 'before_caption' || $key == 'after_caption' || $key == 'after_wrapper' || $key == 'before_wrapper'){ $new_input[$key] = $input[$key]; // Don't sanitise these, meant to be html! } else { $new_input[$key] = sanitize_text_field( $input[$key] ); } } return $new_input; } // Print the Section text public function twaic_instagram_settings_header() { echo '

    '.__('Basic setup of how each Carousel will function, what controls will show and which images will be displayed.', 'twaic-settings').'

    '; } public function twaic_settings_setup() { echo '

    '.__('Change the setup of the carousel - how it functions.', 'twaic-settings').'

    '; } public function twaic_settings_link_buttons_header() { echo '

    '.__('Options for using a link button instead of linking the image directly.', 'twaic-settings').'

    '; } public function twaic_settings_markup_header() { echo '

    '.__('Customise which CSS classes and HTML tags the Carousel uses.', 'twaic-settings').'

    '; } // Callback functions - print the form inputs // Carousel behaviour public function client_id_callback() { printf('', isset( $this->options['client_id'] ) ? esc_attr( $this->options['client_id']) : ''); echo '

    '.__('Follow our tutorial http://www.thelogicalcoder.com/how-to-register-your-app-in-instagram/').'

    '; } public function client_secret_callback() { printf('', isset( $this->options['client_secret'] ) ? esc_attr( $this->options['client_secret']) : ''); echo '

    '.__('Follow our tutorial http://www.thelogicalcoder.com/how-to-register-your-app-in-instagram/').'

    '; } public function access_token_callback() { printf('', isset( $this->options['access_token'] ) ? esc_attr( $this->options['access_token']) : ''); echo '

    '.__('Use this URL if using in Localhost as Redirect URI: http://www.thelogicalcoder.com/development/social/instagram/').'

    '; echo '

    '.__('Use this URL if using in Server as Redirect URI: '.plugins_url('instagram/',__FILE__ )).'

    '; echo '

    '.__('Generate Instagram Access Token if using in Localhost Generate').'

    '; echo '

    '.__('Generate Instagram Access Token if using in Server Generate').'

    '; echo ''; } public function instagram_user_id_callback() { printf('', isset( $this->options['instagram_user_id'] ) ? esc_attr( $this->options['instagram_user_id']) : ''); echo '

    '.__('Generate Instagram Access Token First').'

    '; } public function showcaption_callback() { if(isset( $this->options['showcaption'] ) && $this->options['showcaption'] == 'false'){ $twaic_showcaption_t = ''; $twaic_showcaption_f = ' selected="selected"'; } else { $twaic_showcaption_t = ' selected="selected"'; $twaic_showcaption_f = ''; } echo ''; } public function showcontrols_callback() { if(isset( $this->options['showcontrols'] ) && $this->options['showcontrols'] == 'false'){ $twaic_showcontrols_t = ''; $twaic_showcontrols_f = ' selected="selected"'; $twaic_showcontrols_c = ''; } else if(isset( $this->options['showcontrols'] ) && $this->options['showcontrols'] == 'true'){ $twaic_showcontrols_t = ' selected="selected"'; $twaic_showcontrols_f = ''; $twaic_showcontrols_c = ''; } else if(isset( $this->options['showcontrols'] ) && $this->options['showcontrols'] == 'custom'){ $twaic_showcontrols_t = ''; $twaic_showcontrols_f = ''; $twaic_showcontrols_c = ' selected="selected"'; } echo ''; } public function showindicator_callback() { if(isset( $this->options['showindicator'] ) && $this->options['showindicator'] == 'false'){ $twaic_showindicator_t = ''; $twaic_showindicator_f = ' selected="selected"'; $twaic_showindicator_c = ''; } else if(isset( $this->options['showindicator'] ) && $this->options['showindicator'] == 'true'){ $twaic_showindicator_t = ' selected="selected"'; $twaic_showindicator_f = ''; $twaic_showindicator_c = ''; } else if(isset( $this->options['showindicator'] ) && $this->options['showindicator'] == 'numbered'){ $twaic_showindicator_t = ''; $twaic_showindicator_f = ''; $twaic_showindicator_c = ' selected="selected"'; } echo ''; } public function orderby_callback() { $orderby_options = array ( 'menu_order' => __('Menu order, as set in Carousel overview page', 'twaic-settings'), 'date' => __('Date slide was published', 'twaic-settings'), 'rand' => __('Random ordering', 'twaic-settings'), 'title' => __('Slide title', 'twaic-settings') ); echo ''; } public function order_callback() { if(isset( $this->options['order'] ) && $this->options['order'] == 'DESC'){ $twaic_showcontrols_a = ''; $twaic_showcontrols_d = ' selected="selected"'; } else { $twaic_showcontrols_a = ' selected="selected"'; $twaic_showcontrols_d = ''; } echo ''; } public function category_callback() { $cats = get_terms('twaic_category'); echo ''; } // Setup Section public function image_size_callback() { $image_sizes = get_intermediate_image_sizes(); echo ''; echo '

    '.__("If your need small image, you can use a smaller image size to increase page speed.", 'twaic-settings').'

    '; } public function theme_callback() { echo ''; echo '

    '.__("Choose your desire design.", 'twaic-settings').'

    '; } public function show_user_details_callback(){ echo ''; echo '

    '.__("Want to show user info?", 'twaic-settings').'

    '; } // Markup Section public function before_wrapper_callback(){ printf('', isset( $this->options['before_wrapper'] ) ? esc_attr( $this->options['before_wrapper']) : ''); } public function before_title_callback() { printf('', isset( $this->options['before_title'] ) ? esc_attr( $this->options['before_title']) : '

    '); } public function after_title_callback() { printf('', isset( $this->options['after_title'] ) ? esc_attr( $this->options['after_title']) : '

    '); } public function before_caption_callback() { printf('', isset( $this->options['before_caption'] ) ? esc_attr( $this->options['before_caption']) : '

    '); } public function after_caption_callback() { printf('', isset( $this->options['after_caption'] ) ? esc_attr( $this->options['after_caption']) : '

    '); } } if( is_admin() ){ $twaic_settings_page = new twaic_settings_page(); } // Add settings link on plugin page function twaic_settings_link ($links) { $settings_link = ''.__('Settings', 'twaic-settings').''; array_unshift($links, $settings_link); return $links; } $twaic_plugin = TWAIC_PLUGIN_BASENAME; add_filter("plugin_action_links_$twaic_plugin", 'twaic_settings_link' ); function twaic_msg() { $option = get_option( 'twaic_settings' ); if(!isset($option['access_token']) || $option['access_token']==""){ echo '

    Advanced Instagram Carousel

    Configure Instagram Access Token first. Settings

    Follow our tutorial http://www.thelogicalcoder.com/how-to-register-your-app-in-instagram/

    '; } } // Now we set that function up to execute when the admin_notices action is called add_action( 'admin_notices', 'twaic_msg' );