function option_page_simply_instagram()
    {
        if (isset($_GET['tab'])) {
            $_GET['tab'];
        } else {
            //wp_redirect( 'options-general.php?page=' . $this->plugin_options_key . '&tab=' . $this->si_general_settings . '&noheader=true' );
            //exit;
        }
        /**
         * Save info to database
         * v1.2.5 uses wp options	 
         */
        if (isset($_GET['access_token']) && isset($_GET['id'])) {
            //$wpdb->insert( $wpdb->prefix . "instagram", array( 'access_token' => $_GET['access_token'], 'user_id' => $_GET['id'] ) );
            update_option('si_access_token', $_GET['access_token']);
            update_option('si_user_id', $_GET['id']);
        }
        /*
         * Info query to check if database
         * has record.
         */
        //$info = $wpdb->get_results("select * from " . $wpdb->prefix . "instagram");
        $info = array('si_access_token' => get_option('si_access_token'), 'si_user_id' => get_option('si_user_id'));
        if (isset($_POST['sIntLogout']) == "log_out") {
            /** 
             * v.1.2.6 Delete from wp options
             */
            //$wpdb->query("delete from " . $wpdb->prefix . "instagram");
            delete_option('si_access_token');
            delete_option('si_user_id');
            ?>
 <meta http-equiv="refresh" content="0;url=<?php 
            echo get_admin_url() . 'options-general.php?page=simply-instagram';
            ?>
"> <?php 
        }
        ?>
		<div class="wrap">
		 	<h2><?php 
        echo __('Simply Instagram Settings', 'simply-instagram');
        ?>
</h2>			 	
		 	
		 	<?php 
        if (!$info['si_access_token'] && !$info['si_user_id']) {
            ?>
 
				<?php 
            if ($_GET['access_token'] == "" && $_GET['id'] == "") {
                ?>
					<div class="error">
					 <p><?php 
                echo __('You did not authorize Simply Instagram. This plugin will not work without your authorization.', 'simply-instagram');
                ?>
 </p>
					</div>
				<?php 
            }
            ?>
				<a href=" <?php 
            echo sInstLogin('?return_uri=' . base64_encode(get_admin_url() . 'options-general.php?page=simply-instagram'));
            ?>
 "><img src="<?php 
            echo plugins_url() . '/simply-instagram/images/instagram-login.jpg';
            ?>
" alt="<?php 
            echo __('Login to Instagram and authorize Simply Instagram plugin', 'simply-instagram');
            ?>
" /></a>
			<?php 
        } else {
            ?>
				<?php 
            if (isset($_GET['access_token']) && $_GET['id']) {
                ?>
 <meta http-equiv="refresh" content="0;url=<?php 
                echo get_admin_url() . 'options-general.php?page=simply-instagram';
                ?>
"> <?php 
            }
            ?>
				
				<iframe src="https://instagram.com/accounts/logout/" width="0" height="0">Logout</iframe>
				<?php 
            $user_info = sInstGetInfo(user_id(), access_token());
            //print_r( $user_info );
            ?>
				<div id="sInts-welcome">
				<img src="<?php 
            echo $user_info['data']['profile_picture'];
            ?>
" id="si_profile_photo"/>
				<p id="si_username"><?php 
            echo __('Welcome', 'simply-instagram');
            ?>
 <?php 
            echo $user_info['data']['full_name'];
            ?>
!</p>
				
				
				<form name="itw_logout" method="post" action="<?php 
            echo str_replace('%7E', '~', htmlentities(get_admin_url() . 'options-general.php?page=simply-instagram'));
            ?>
">
				<input type="hidden" name="sIntLogout" value="log_out">
				<input type="submit" class="button" value="Log out" name="logout" onclick="" >
				</form>
				
				</div> 
			
			<?php 
        }
        ?>
	
			
			<?php 
        /**
         *
         * If not yet authorized, hide all tabs
         *
         */
        if (get_option('si_access_token') && get_option('si_user_id')) {
            ?>
			
			<?php 
            $tab = isset($_GET['tab']) ? $_GET['tab'] : $this->general_settings_key;
            ?>
		 	
			<?php 
            $this->plugin_options_tabs();
            ?>
	
						
			<form method="post" action="options.php?noheader=true">
				<?php 
            wp_nonce_field('update-options');
            ?>
				<?php 
            settings_fields($tab);
            ?>
				<?php 
            do_settings_sections($tab);
            ?>
				<?php 
            submit_button();
            ?>
			</form>
			
			<?php 
            if ($tab === $this->about_settings_key) {
                ?>
			
			<h3><?php 
                echo __('API RESPONSE', 'simply-instagram');
                ?>
</h3>
			<p><?php 
                echo __('The following will display API response from Instagram API Server. Please use cache module in order to work.', 'simply-instagram');
                ?>
</p>
			
			<p><strong><?php 
                echo __('Self Feed', 'simply-instagram');
                ?>
</strong>: <?php 
                echo sIntCheckResponse("selffeed.json");
                ?>
</p>
			<p><strong><?php 
                echo __('Recent Media', 'simply-instagram');
                ?>
</strong>: <?php 
                echo sIntCheckResponse("recentmedia.json");
                ?>
</p>
			<p><strong><?php 
                echo __('Likes', 'simply-instagram');
                ?>
</strong>: <?php 
                echo sIntCheckResponse("likes.json");
                ?>
</p>
			<p><strong><?php 
                echo __('Followers', 'simply-instagram');
                ?>
</strong>: <?php 
                echo sIntCheckResponse("followers.json");
                ?>
</p>
			<p><strong><?php 
                echo __('Following', 'simply-instagram');
                ?>
</strong>: <?php 
                echo sIntCheckResponse("following.json");
                ?>
</p>
			<p><strong><?php 
                echo __('Following Info', 'simply-instagram');
                ?>
</strong>: <?php 
                echo sIntCheckResponse("followinginfo.json");
                ?>
</p>
			<p><strong><?php 
                echo __('Currently Popular', 'simply-instagram');
                ?>
</strong>: <?php 
                echo sIntCheckResponse("popular.json");
                ?>
</p>
			<br/>
			
			<h3><?php 
                echo __('RATE THIS PLUGIN', 'simply-instagram');
                ?>
</h3>
			<p><a href="http://wordpress.org/support/view/plugin-reviews/simply-instagram" target="_blank" class="tooltip" title="Rate this plugin in Wordpress.org"> <img src="<?php 
                echo plugins_url();
                ?>
/simply-instagram/images/rate.png" ></a></p><br/>
			
			<h3><strong id="help"><?php 
                echo __('HELP THIS PLUGIN', 'simply-instagram');
                ?>
</strong></h3><p style="text-align: justify !important;"><strong><?php 
                echo __('You can help improve this plugin by donating any amount you want or rate this plugin in Wordpress.org.', 'simply-instagram');
                ?>
</strong></p>
			
			<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
				<input type="hidden" name="cmd" value="_s-xclick">
				<input type="hidden" name="hosted_button_id" value="BUDCX2S6SJ3ZG">
				<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
				<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
		 	</form>
		 
				<script>
				
				//remove save button if in about tab
				jQuery(document).ready( function(){
					jQuery("#submit").css( 'display', 'none' );
				});
				
				</script>
			<?php 
            }
            ?>
			
			<?php 
            if ($tab === $this->shortcode_settings_key) {
                ?>
				<script>
				
				//remove save button if in shortcode tab
				jQuery(document).ready( function(){
					jQuery("#submit").css( 'display', 'none' );
				});
				
				function displayVals() {
				      var endpoints = jQuery("select[name=endpoints]").val();// || [];
				      var type = jQuery("select[name=type]").val();// || [];
				      var size = jQuery("select[name=size]").val();
				      var display = jQuery("select[name=totalphoto]").val();
				      var presentation = jQuery("select[name=presentation]").val();
				      var displayoption = jQuery("select[name=displayoption]").val();
				      var showphotographer = jQuery("select[name=showphotographer]").val();
				      var photocomment = jQuery("select[name=photocomment]").val();
				      var stat = jQuery("select[name=stat]").val();
				      var photocaption = jQuery("select[name=photocaption]").val();
				      var displaycomment = jQuery("select[name=displaycomment]").val();
				      
				      if( endpoints == "media" ){
				        jQuery("p#generated-sc").html(  '[simply_instagram endpoints="' + endpoints + '" type="popular" size="' + size + '" presentation="' + presentation + '" display="' + display + '" displayoption="' + displayoption + '" showphotographer="' + showphotographer + '" photocomment="' + photocomment + '" stat="' + stat + '" photocaption="' + photocaption + '" displaycomment="' + displaycomment + '"]' );
				        jQuery("select[name=type]").attr( "disabled", true );
				      }else{
				      	jQuery("p#generated-sc").html( '[simply_instagram endpoints="' + endpoints + '" type="' + type + '" size="' + size + '" presentation="' + presentation + '" display="' + display + '" displayoption="' + displayoption + '" showphotographer="' + showphotographer + '" photocomment="' + photocomment + '" stat="' + stat + '" photocaption="' + photocaption + '" displaycomment="' + displaycomment + '"]' );
				      	jQuery("select[name=type]").attr( "disabled", false );
				      }
				    }		    
				
				    jQuery("select[name=endpoints]").change(displayVals);
				    jQuery("select[name=type]").change(displayVals);
				    jQuery("select[name=size]").change(displayVals);
				    jQuery("select[name=totalphoto]").change(displayVals);
				    jQuery("select[name=presentation]").change(displayVals);
				    jQuery("select[name=displayoption]").change(displayVals);
				    jQuery("select[name=showphotographer]").change(displayVals);
				    jQuery("select[name=photocomment]").change(displayVals);
				    jQuery("select[name=stat]").change(displayVals);
				    jQuery("select[name=photocaption]").change(displayVals);
				    jQuery("select[name=displaycomment]").change(displayVals);
				    displayVals();
				</script>
			<?php 
            }
            ?>
			
			<?php 
        }
        /* End of hiding tabs when not authorized */
        ?>
		</div>
		<?php 
    }
    /** @see WP_Widget::widget */
    function widget($args, $instance)
    {
        extract($args);
        $short_desc = '';
        echo $before_widget;
        echo $before_title . $instance['widget_title'] . $after_title;
        echo '<p>' . $short_desc . '</p>';
        $info = sInstGetInfo(user_id(), access_token());
        sInstShowInfo($info, array('name' => 'true', 'bio' => 'true', 'website' => 'true', 'media' => 'true', 'followers' => 'true', 'following' => 'true', 'profile_pic' => 'true'), $instance['profile_width']);
        if ($instance['followers'] == true) {
            if ($instance['followers_desc']) {
                echo "<p>" . $instance['followers_desc'] . "</p>";
            } else {
                echo '<div class="clear"></div>';
            }
            $fllwrsdata = sInstDiplayFollowData(sInstGetFollowers(user_id(), access_token(), array('name' => 'true', 'bio' => 'true', 'website' => 'true', 'media' => 'true', 'followers' => 'true', 'following' => 'true', 'profile_pic' => 'true')), "25", $instance['followers_profile_width'], false);
            ?>
				<script type="text/javascript" charset="utf-8">
				  //jQuery.noConflict();
				  jQuery(document).ready(function(){
				     jQuery('.si-tooltip').tooltipster();
				  });
				</script>
			<?php 
        }
        if ($instance['following'] == true) {
            if ($instance['following_desc']) {
                echo "<p>" . $instance['following_desc'] . "</p>";
            } else {
                echo '<div class="clear"></div>';
            }
            sInstDiplayFollowData(sInstGetFollowing(user_id(), access_token(), array('name' => 'true', 'bio' => 'true', 'website' => 'true', 'media' => 'true', 'followers' => 'true', 'following' => 'true', 'profile_pic' => 'true')), "25", $instance['followers_profile_width'], false);
            ?>
				<script type="text/javascript" charset="utf-8">
				  //jQuery.noConflict();
				  jQuery(document).ready(function(){
				     jQuery('.si-tooltip').tooltipster();
				  });
				</script>
			<?php 
        }
        if ($instance['latest_feed'] == true) {
            if ($instance['latest_feed_desc']) {
                echo "<p>" . $instance['latest_feed_desc'] . "</p>";
            } else {
                echo '<div class="clear"></div>';
            }
            $customRel = "latestfeed";
            sInstShowWidgetData(sInstGetSelfFeed(access_token()), "25", $instance['latest_photo_profile_width'], $customRel, $instance['display_caption'], $instance['open_instagram']);
            ?>
				<script type="text/javascript" charset="utf-8">
				  //jQuery.noConflict();
				  jQuery(document).ready(function(){
				    jQuery("a[rel^='<?php 
            echo $customRel;
            ?>
']").prettyPhoto({
				    	autoplay_slideshow: 'true',
				    	social_tools:false,
				    	theme: 'pp_default',
				    	});
				     jQuery('.si-tooltip').tooltipster();
				  });
				</script>
			<?php 
        }
        if ($instance['latest_photo'] == true) {
            if ($instance['latest_photo_desc']) {
                echo "<p>" . $instance['latest_photo_desc'] . "</p>";
            } else {
                echo '<div class="clear"></div>';
            }
            $customRel = "latestphoto";
            sInstShowWidgetData(sInstGetRecentMedia(user_id(), access_token()), "25", $instance['latest_photo_profile_width'], $customRel, $instance['display_caption'], $instance['open_instagram']);
            ?>
				<script type="text/javascript" charset="utf-8">
				  jQuery(document).ready(function(){
				    jQuery("a[rel^='<?php 
            echo $customRel;
            ?>
']").prettyPhoto({
				    	autoplay_slideshow: 'true',
				    	social_tools:false,
				    	theme: 'pp_default',
				    	});
				     jQuery('.si-tooltip').tooltipster();
				  });
				</script>
			<?php 
        }
        if ($instance['liked_photo'] == true) {
            if ($instance['liked_photo_desc']) {
                echo "<p>" . $instance['liked_photo_desc'] . "</p>";
            } else {
                echo '<div class="clear"></div>';
            }
            $customRel = "likedphoto";
            sInstShowWidgetData(sInstGetLikes(access_token()), "25", $instance['liked_photo_width'], $customRel, $instance['display_caption'], $instance['open_instagram']);
            ?>
				<script type="text/javascript" charset="utf-8">
				  jQuery(document).ready(function(){
				    jQuery("a[rel^='<?php 
            echo $customRel;
            ?>
']").prettyPhoto({
				    	autoplay_slideshow: 'true',
				    	social_tools:false,
				    	theme: 'pp_default',
				    	});
				     jQuery('.si-tooltip').tooltipster();
				  });
				</script>
			<?php 
        }
        echo $after_widget;
    }