Example #1
0
    function options_page()
    {
        $themename = get_option('colabs_themename');
        $custom_editor = new colabs_custom_editor();
        $files = array();
        ?>

		<div id="colabs_options" class="wrap<?php 
        if (is_rtl()) {
            echo ' rtl';
        }
        ?>
 colabs_container one_col">
		<h2 class="colabs_admin_page_title"></h2>
		<?php 
        if (file_exists(COLABS_CUSTOM)) {
            // Determine which file we're editing. Default to something harmless, like custom.css.
            if (isset($_GET['file'])) {
                $file = $_GET['file'];
            } else {
                $file = 'custom.css';
            }
            $files = $custom_editor->get_custom_files();
            $extension = substr($file, strrpos($file, '.'));
            // Determine if the custom file exists and is writable. Otherwise, this page is useless.
            $error = $custom_editor->is_custom_writable($file, $files);
            if (!$error) {
                // Get contents of custom.css
                if (filesize(COLABS_CUSTOM . '/' . $file) > 0) {
                    $wp_filesystem = WP_Filesystem($cred);
                    global $wp_filesystem;
                    $content = $wp_filesystem->get_contents(COLABS_CUSTOM . '/' . $file);
                    $content = htmlspecialchars($content);
                } else {
                    $content = '';
                }
            }
            ?>
					
			<div id="main">
					
				<div id="panel-header">
					<?php 
            colabsthemes_options_page_header('save_button=false');
            ?>
				</div><!-- #panel-header -->

				<div id="panel-content">
			
					<?php 
            if ($error) {
                echo $error;
            }
            ?>
			
					<?php 
            do_action('colabsthemes_editor_content');
            ?>
			
					<div class="section">
							<h3 class="heading"><?php 
            _e('Upload Custom CSS File', 'colabsthemes');
            ?>
</h3>
							<div class="option">
									<form method="post" enctype="multipart/form-data" id="colabsform" action="<?php 
            echo admin_url('admin-post.php?action=colabs_file_editor');
            ?>
">
											<input id="css_file" type="file" name="import"/>
											<?php 
            wp_nonce_field('colabs-custom-file', '_wpnonce-colabs-custom-file');
            ?>
											<input type="submit" class="button" value="Upload File" name="custom_file_import" />
									</form>
							</div><!-- .option -->
					</div><!-- .section -->    
			
					<div class="section">
						<h3 class="heading"><?php 
            _e('File Editor', 'colabsthemes');
            ?>
</h3>
						<div class="option">
								<form style="overflow:hidden" method="post" id="file-jump" name="file-jump" action="<?php 
            echo admin_url('admin-post.php?action=colabs_file_editor');
            ?>
">
									<h3><?php 
            printf(__('Currently editing: <code>%s</code>', 'colabsthemes'), "custom/{$file}");
            ?>
</h3>
									<p>
											<select id="custom_files" name="custom_files">
													<option value="<?php 
            echo $file;
            ?>
"><?php 
            echo $file;
            ?>
</option>
													<?php 
            foreach ($files as $f) {
                // An option for each available file
                if ($f != $file) {
                    echo "\t\t\t\t\t<option value=\"{$f}\">{$f}</option>\n";
                }
            }
            ?>
											</select>
											<?php 
            wp_nonce_field('colabs-custom-file-jump', '_wpnonce-colabs-custom-file-jump');
            ?>
											<input type="submit" id="custom_file_jump" class="button" name="custom_file_jump" value="<?php 
            _e('Edit selected file', 'colabsthemes');
            ?>
" />
									</p>
								
									<?php 
            if ('.php' == $extension) {
                echo "\t\t\t<p class=\"alert\">" . __('<strong>Note:</strong> If you make a mistake in your code while modifying a <acronym title="PHP: Hypertext Preprocessor">PHP</acronym> file, saving this page <em>may</em> result your site becoming temporarily unusable. Prior to editing such files, be sure to have access to the file via <acronym title="File Transfer Protocol">FTP</acronym> or other means so that you can correct the error.', 'colabsthemes') . "</p>\n";
            }
            ?>
								</form>
								
								<form class="file_editor" method="post" id="template" name="template" action="<?php 
            echo admin_url('admin-post.php?action=colabs_file_editor');
            ?>
">       
									<input type="hidden" id="file" name="file" value="<?php 
            echo $file;
            ?>
" />
									<textarea id="newcontent" name="newcontent" rows="25" cols="50" class="large-text"><?php 
            echo $content;
            ?>
</textarea>
									<span>
										<?php 
            wp_nonce_field('colabs-custom-file', '_wpnonce-colabs-custom-file');
            ?>
										<input type="submit" class="button submit-button button-primary save_button" id="custom_file_submit" value="Save All Changes" name="custom_file_submit" />
										<span id="colabs_editor_color_picker" class="colorSelector"></span>
										<input class="colabs-color input-text-small" name="colabs_editor_color" id="colabs_editor_color" type="text" value="#ffffff" />
										<label class="inline" for="colabs_editor_color" style="display: inline-block; margin-top: -18px;"><?php 
            _e('Color Reference', 'colabsthemes');
            ?>
</label>
									</span>
								</form>
						</div><!-- .option -->
					</div><!-- .section -->       
				</div><!--/#panel-content -->

				<div id="panel-footer">
					<ul>
						<li class="docs"><a title="Theme Documentation" href="http://colorlabsproject.com/documentation/<?php 
            echo strtolower(str_replace(" ", "", $themename));
            ?>
" target="_blank" ><?php 
            _e('View Documentation', 'colabsthemes');
            ?>
</a></li>
						<li class="forum"><a href="http://colorlabsproject.com/resolve/" target="_blank"><?php 
            _e('Submit a Support Ticket', 'colabsthemes');
            ?>
</a></li>
						<li class="idea"><a href="http://ideas.colorlabsproject.com/" target="_blank"><?php 
            _e('Suggest a Feature', 'colabsthemes');
            ?>
</a></li>
					</ul>
				</div><!--/#panel-footer -->
			
			</div><!--/#main -->   
			<?php 
        } else {
            echo "<div class=\"warning\">\n\t<p><strong>" . __('Attention!', 'colabsthemes') . '</strong> ' . __('In order to edit your custom files, you&#8217;ll need to change the name of your <code>custom-sample</code> folder to <code>custom</code>.', 'colabsthemes') . "</p>\n</div>\n";
        }
        ?>
		</div>
	<?php 
    }
function colabsthemes_readme_menu_admin()
{
    // Get Theme Name
    $themename = get_option('colabs_themename');
    // Assume we cannot find the file.
    $file = array();
    // Get the file contents
    $file = wp_remote_get(get_template_directory_uri() . '/README.txt');
    ?>
<div id="colabs_options" class="wrap<?php 
    if (is_rtl()) {
        echo ' rtl';
    }
    ?>
">

	<div class="one_col wrap colabs_container">
    
	<div id="main">
        
	<div id="panel-header">
        <?php 
    colabsthemes_options_page_header('save_button=false');
    ?>
	</div><!-- #panel-header -->

    <div id="panel-content">

    <div class="section">
    <h3 class="heading"><?php 
    echo $themename . __(' - README.txt Theme File', 'colabsthemes');
    ?>
</h3>
    <div class="option">

    	<div id="colabs-readme-file">
    		<?php 
    if (isset($file)) {
        echo wpautop($file['body']);
    } else {
        echo '<b>README.txt file not found.</b>';
    }
    ?>
    	</div>
		
	</div><!-- .option -->
    </div><!-- .section -->
    </div><!-- #panel-content -->

    <div id="panel-footer">
      <ul>
          <li class="docs"><a title="Theme Documentation" href="http://colorlabsproject.com/documentation/<?php 
    echo strtolower(str_replace(" ", "", $themename));
    ?>
" target="_blank" >View Documentation</a></li>
          <li class="forum"><a href="http://colorlabsproject.com/resolve/" target="_blank">Submit a Support Ticket</a></li>
          <li class="idea"><a href="http://ideas.colorlabsproject.com/" target="_blank">Suggest a Feature</a></li>
      </ul>
  	</div><!-- #panel-footer -->
	</div><!-- #main -->

	</div><!-- .colabs_container -->
    
</div><!-- #colabs_options -->

<?php 
}
    /**
     * admin_screen()
     *
     * Load the admin screen.
     *
     * @since 1.0.0
     */
    function admin_screen()
    {
        $themename = get_option('colabs_themename');
        $export_type = 'all';
        if (isset($_POST['export-type'])) {
            $export_type = esc_attr($_POST['export-type']);
        }
        ?>
<div class="wrap colabs_notice">
	<h2></h2>

<div id="colabs_options" class="wrap <?php 
        if (is_rtl()) {
            echo 'rtl';
        }
        ?>
 colabs_backup">

	<div class="one_col wrap colabs_container">
    
            <div class="clear"></div>
						<?php 
        colabs_theme_check();
        ?>
            <div id="colabs-popup-save" class="colabs-save-popup"><div class="colabs-save-save">Options Updated</div></div>
            <div id="colabs-popup-reset" class="colabs-save-popup"><div class="colabs-save-reset">Options Reset</div></div>
            <div style="width:100%;padding-top:15px;"></div>
            <div class="clear"></div>
        
	<div id="main">
        
	<div id="panel-header">
        <?php 
        colabsthemes_options_page_header('save_button=false');
        ?>
	</div><!-- #panel-header -->

    <div id="panel-content">

    <div class="section">
    
    	<h3 class="heading"><?php 
        _e('Import Settings', 'colabsthemes');
        ?>
</h3>
    	<div class="option">
    	<p><?php 
        _e('If you have settings in a backup file on your computer, the ColorLabs Framework can import those into this site. To get started, upload your backup file to import from below.', 'colabsthemes');
        ?>
</p>
    
    	<div class="form-wrap">
    		<form enctype="multipart/form-data" method="post" action="<?php 
        echo admin_url('admin.php?page=' . $this->token);
        ?>
">
    			<?php 
        wp_nonce_field('colabsthemes-backup-import');
        ?>
    			<label for="colabsthemes-import-file"><?php 
        printf(__('Upload File: (Maximum Size: %s)', 'colabsthemes'), ini_get('post_max_size'));
        ?>
</label>
    			<input type="file" id="colabsthemes-import-file" name="colabsthemes-import-file" size="25" />
    			<input type="hidden" name="colabsthemes-backup-import" value="1" />
    			<input type="submit" class="button" value="<?php 
        _e('Upload File and Import', 'colabsthemes');
        ?>
" />
    		</form>
    	</div><!--/.form-wrap-->
    	</div><!-- .option -->

    </div><!-- .section -->
    
    <div class="section">
            
    	<h3 class="heading"><?php 
        _e('Export Settings', 'colabsthemes');
        ?>
</h3>
    	<div class="option">
    	<p><?php 
        _e('When you click the button below, the ColorLabs Framework will create a text file for you to save to your computer.', 'colabsthemes');
        ?>
</p>
    	<p><?php 
        echo sprintf(__('This text file can be used to restore your settings here on "%s", or to easily setup another website with the same settings".', 'colabsthemes'), get_bloginfo('name'));
        ?>
</p>
    		
    	<form method="post" action="<?php 
        echo admin_url('admin.php?page=' . $this->token);
        ?>
">
    		<?php 
        wp_nonce_field('colabsthemes-backup-export');
        ?>
    		<p><label><input type="radio" name="export-type" value="all"<?php 
        checked('all', $export_type);
        ?>
> <?php 
        _e('All Settings', 'colabsthemes');
        ?>
</label>
            <span class="description"><?php 
        _e('This will contain all of the options listed below.', 'colabsthemes');
        ?>
</span></p>
    
    		<p><label for="content"><input type="radio" name="export-type" value="theme"<?php 
        checked('theme', $export_type);
        ?>
/> <?php 
        _e('Theme Options', 'colabsthemes');
        ?>
</label></p>
    		
    		<p><label for="content"><input type="radio" name="export-type" value="seo"<?php 
        checked('seo', $export_type);
        ?>
/> <?php 
        _e('SEO Settings', 'colabsthemes');
        ?>
</label></p>
    		
    		<?php 
        if (get_option('colabs_themename') == 'Backbone') {
            ?>
<p><label for="content"><input type="radio" name="export-type" value="sidebar"<?php 
            checked('sidebar', $export_type);
            ?>
/> <?php 
            _e('Sidebar Manager', 'colabsthemes');
            ?>
 <span class="description"><?php 
            _e('This will contain only the custom sidebars themselves and not the widgets within them', 'colabsthemes');
            ?>
</span></label></p><?php 
        }
        ?>
    		
    		<input type="hidden" name="colabsthemes-backup-export" value="1" />
    		<input type="submit" class="button" value="<?php 
        _e('Download Export File', 'colabsthemes');
        ?>
" />
    	</form>
    	</div><!-- .option -->
        
    </div><!-- .section -->
    
    </div><!-- #panel-content -->

    <div id="panel-footer">
      <ul>
          <li class="docs"><a title="Theme Documentation" href="http://colorlabsproject.com/documentation/<?php 
        echo strtolower(str_replace(" ", "", $themename));
        ?>
" target="_blank" >View Documentation</a></li>
          <li class="forum"><a href="http://colorlabsproject.com/resolve/" target="_blank">Submit a Support Ticket</a></li>
          <li class="idea"><a href="http://ideas.colorlabsproject.com/" target="_blank">Suggest a Feature</a></li>
      </ul>
  	</div><!-- #panel-footer -->
	</div><!-- #main -->

	</div><!-- .colabs_container -->
    
</div><!-- #colabs_options -->

</div><!-- .wrap -->
<?php 
    }
function colabsthemes_framework_update_page()
{
    $themename = get_option('colabs_themename');
    global $message;
    ?>
<div class="wrap colabs_notice">
<div id="colabs_options" class="wrap<?php 
    if (is_rtl()) {
        echo ' rtl';
    }
    ?>
">
	<div class="one_col wrap colabs_container">
	
	<?php 
    // Message update success
    if (isset($_REQUEST['update_success'])) {
        echo "<div id='framework-upgraded' class='updated fade'><p>" . __("New framework successfully downloaded, extracted and updated.", "colabsthemes") . "</p></div>";
    } else {
        echo $message;
    }
    ?>

	<div id="main">
	<div id="panel-header">
        <?php 
    colabsthemes_options_page_header('save_button=false');
    ?>
	</div><!-- #panel-header -->
    <div id="panel-content">
    <?php 
    if (isset($_POST['password'])) {
        $cred = $_POST;
        $filesystem = WP_Filesystem($cred);
    } elseif (isset($_POST['colabs_ftp_cred'])) {
        $cred = unserialize(stripcslashes($_POST['colabs_ftp_cred']));
        $filesystem = WP_Filesystem($cred);
    } else {
        $filesystem = WP_Filesystem();
    }
    $url = admin_url('admin.php?page=colabsthemes_framework_update');
    if ($filesystem == false) {
        request_filesystem_credentials($url);
    } else {
        ?>
		<?php 
        $theme_name = get_option('colabs_themename');
        $storefront_theme = colabs_get_fw_version('http://colorlabsproject.com/updates/' . strtolower($theme_name) . '/changelog.txt');
        $check_theme_update = version_compare($storefront_theme, COLABS_THEME_VER, '>');
        if ($check_theme_update != 1) {
            ?>
			<div class="section">
				<h3 class="heading"><?php 
            _e("Framework Update", "colabsthemes");
            ?>
</h3>
				<div class="option">
					<?php 
            colabsthemes_framework_update_page_set();
            ?>
				</div><!-- .option -->
			</div><!-- .section -->
		<?php 
        }
        ?>
		<div class="section">
			<h3 class="heading"><?php 
        _e("Themes Update", "colabsthemes");
        ?>
</h3>
			<div class="option">
        <?php 
        colabsthemes_themes_update_page_set();
        ?>
			</div><!-- .option -->
    </div><!-- .section -->
		<?php 
    }
    ?>
    </div><!-- #panel-content -->
    <div id="panel-footer">
      <ul>
          <li class="docs"><a title="Theme Documentation" href="http://colorlabsproject.com/documentation/<?php 
    echo strtolower(str_replace(" ", "", $themename));
    ?>
" target="_blank" ><?php 
    _e("View Documentation", "colabsthemes");
    ?>
</a></li>
          <li class="forum"><a href="http://colorlabsproject.com/resolve/" target="_blank"><?php 
    _e("Submit a Support Ticket", "colabsthemes");
    ?>
</a></li>
          <li class="idea"><a href="http://ideas.colorlabsproject.com/" target="_blank"><?php 
    _e("Suggest a Feature", "colabsthemes");
    ?>
</a></li>
      </ul>
  	</div><!-- #panel-footer -->
	</div><!-- #main -->
	</div><!-- .colabs_container -->
</div><!-- #colabs_options -->
</div><!-- .wrap -->
<?php 
}
Example #5
0
    function colabsthemes_options_page()
    {
        $options = get_option('colabs_template');
        $themename = get_option('colabs_themename');
        $shortname = get_option('colabs_shortname');
        $manualurl = get_option('colabs_manual');
        //Framework Version in Backend Header
        $colabs_framework_version = get_option('colabs_framework_version');
        $theme_data = wp_get_theme();
        //GET themes update RSS feed and do magic
        include_once ABSPATH . WPINC . '/feed.php';
        $pos = strpos($manualurl, 'documentation');
        $theme_slug = str_replace("/", "", substr($manualurl, $pos + 13));
        //13 for the word documentation
        ?>
<div class="wrap colabs_container">
  <h2 class="colabs_admin_page_title"></h2>
  <?php 
        $free_themes = array('lensa', 'photogram', 'leatherly', 'tumblepress', 'rpg.cod', 'wellblog');
        if (in_array(strtolower($themename), $free_themes)) {
            ?>
    <div class="colabs_twitter_stream updated">

        <div class="stream-label"><?php 
            _e('News On Twitter:', 'colabsthemes');
            ?>
</div>
        <?php 
            $instance = array('query' => 'from:colorlabs', 'number' => 5, 'show_follow' => 'false', 'show_avatar' => 'false', 'show_account' => 'false', 'consumer_key' => 'tZC2RgSO04T7ctQQDIFw', 'consumer_secret' => 'xB8YWcEYkzqnqGAgHia84YVWlGSZqRnZn0otis2Ho', 'list_before' => '<li>', 'list_after' => '</li>');
            ?>
        <ul>
          <?php 
            colabs_get_tweets($instance);
            ?>
        </ul>

    </div>
    <!-- .colabs_twitter-stream -->
  <?php 
        }
        ?>
  

    <form action="" enctype="multipart/form-data" id="colabsform">
    <?php 
        // Add nonce for added security.
        if (function_exists('wp_nonce_field')) {
            wp_nonce_field('colabsframework-theme-options-update');
        }
        // End IF Statement
        $colabs_nonce = '';
        if (function_exists('wp_create_nonce')) {
            $colabs_nonce = wp_create_nonce('colabsframework-theme-options-update');
        }
        // End IF Statement
        if ('' == $colabs_nonce) {
        } else {
            ?>
      <input type="hidden" name="_ajax_nonce" value="<?php 
            echo $colabs_nonce;
            ?>
" />
    <?php 
        }
        // End IF Statement
        ?>

    <?php 
        // Rev up the Options Machine
        $return = colabsthemes_machine($options);
        ?>

    <div id="main" class="menu-item-settings metabox-holder">
        
      <div id="panel-header">
        <?php 
        colabsthemes_options_page_header(array('theme_data' => $theme_data, 'themename' => $themename));
        ?>
      </div><!-- #panel-header -->

      <div id="sidebar-nav">
        <ul><?php 
        echo $return[1];
        ?>
</ul>   
      </div>

      <div id="panel-content">
        <div class="group help-block"> <p><?php 
        _e("Drag an icon on the left and drop it here to customize", "colabsthemes");
        ?>
</p> </div>
        <?php 
        echo $return[0];
        /* Settings */
        ?>
        <div class="clear"></div>
      </div>
            
      <div id="panel-footer">
        <ul>
          <li class="docs"><a title="Theme Documentation" href="http://colorlabsproject.com/documentation/<?php 
        echo strtolower(str_replace(" ", "", $themename));
        ?>
" target="_blank" ><?php 
        _e("View Documentation", "colabsthemes");
        ?>
</a></li>
          <li class="forum"><a href="http://colorlabsproject.com/resolve/" target="_blank"><?php 
        _e("Submit a Support Ticket", "colabsthemes");
        ?>
</a></li>
          <li class="idea"><a href="http://ideas.colorlabsproject.com/" target="_blank"><?php 
        _e("Suggest a Feature", "colabsthemes");
        ?>
</a></li>
        </ul>
        
        <div class="save-bar save_bar_top right">
          <img style="display:none" src="<?php 
        echo get_template_directory_uri();
        ?>
/functions/images/ajax-loading.gif" class="ajax-loading-img ajax-loading-img-top" alt="Working..." />
          <input type="submit" value="Save Changes" class="button submit-button button-primary" />
          <button class="button submit-button reset-button button-highlighted"><?php 
        _e('Reset Options', 'colabsthemes');
        ?>
</button>
        </div>
      </div><!-- #panel-footer -->

    </div><!--/#main-->
  </form>

  <form method="post" style="display:none" id="colabsform-reset">
    <?php 
        // Add nonce for added security.
        if (function_exists('wp_nonce_field')) {
            wp_nonce_field('colabsframework-theme-options-reset');
        }
        // End IF Statement
        $colabs_nonce = '';
        if (function_exists('wp_create_nonce')) {
            $colabs_nonce = wp_create_nonce('colabsframework-theme-options-reset');
        }
        // End IF Statement
        if ('' == $colabs_nonce) {
        } else {
            ?>
      <input type="hidden" name="_ajax_nonce" value="<?php 
            echo $colabs_nonce;
            ?>
" />
    <?php 
        }
        // End IF Statement
        ?>
    <input name="reset" type="submit" value="Reset Options" class="button submit-button reset-button button-highlighted" onclick="return confirm( '<?php 
        _e("Click OK to reset all options. All settings will be lost!", "colabsthemes");
        ?>
' );" />
    <input type="hidden" name="colabs_save" value="reset" /> 
  </form>

  <div class="theme-info"><br>
    <span class="theme"><?php 
        echo $themename;
        ?>
 <?php 
        echo COLABS_THEME_VER;
        ?>
</span>
    <span class="framework"><?php 
        _e('Framework', 'colabsthemes');
        ?>
 <?php 
        echo $colabs_framework_version;
        ?>
</span>
  </div><!--/.theme-info-->
  
  <div style="clear:both;"></div>    
</div><!--wrap-->
<?php 
    }
    function colabs_facebook_admin_page()
    {
        global $colabs_facebook_name;
        global $appapikey, $appsecret;
        global $option_fb_sess_key, $option_fb_sess_sec, $option_fb_sess_uid, $option_fb_sess_uname;
        ?>
			<div id="colabs_options" class="wrap <?php 
        if (get_bloginfo('text_direction') == 'rtl') {
            echo 'rtl';
        }
        ?>
 colabs_facebook">
			<div class="one_col wrap colabs_container">
			<div class="clear"></div>
			<?php 
        //Show a warning if they're using a naughty other plugin
        if (class_exists('Facebook')) {
            ?>
<div class="error"><p><strong>Warning:</strong> Another plugin has included the Facebook API throughout all of Wordpress.  I suggest you contact that plugin's author and ask them to include it only in pages where it's actually needed.<br /><br />Things may work fine as-is, but only if the API version included by the other plugin is at least as recent as the one required by Facebook Photo Fetcher.</p></div><?php 
        } else {
            if (version_compare('5', PHP_VERSION, "<=")) {
                require_once 'facebook-platform/facebook.php';
            } else {
                die("Sorry, but as of version 1.0.0, Facebook Photo Album requires PHP5.");
            }
        }
        //Connect to Facebook and create an auth token.
        //Note: We only care about $token when the user is creating/saving a session; otherwise it's irrelevant and we just ignore it.
        $facebook = new Facebook($appapikey, $appsecret, null, true);
        $facebook->api_client->secret = $appsecret;
        $token = $facebook->api_client->auth_createToken();
        if (!$token) {
            echo 'Failed to create Facebook authentication token!';
        }
        //Check $_POST for what we're doing, and update any necessary options
        if (isset($_POST['save-facebook-session'])) {
            //We're connecting the useraccount to facebook, and the user just did STEP 2
            //We need to use the connection token to create a new session and save it,
            //which we'll use from now on to reconnect as the authenticated user.
            $token = $_POST['save-facebook-session'];
            try {
                $new_session = $facebook->api_client->auth_getSession($token);
            } catch (Exception $e) {
                $new_session = 0;
                update_option($option_fb_sess_key, '');
                update_option($option_fb_sess_sec, '');
                update_option($option_fb_sess_uid, '');
                update_option($option_fb_sess_uname, '');
            }
            $errorMsg = 0;
            if (!$new_session) {
                $errorMsg = "Failed to get an authenticated session.";
            }
            if (!$new_session['secret']) {
                $errorMsg = "Failed to get a session secret.";
            }
            //Success!  Save the key, secret, userID, and username
            if (!$errorMsg) {
                $user = $facebook->api_client->users_getInfo($new_session['uid'], array('name'));
                update_option($option_fb_sess_key, $new_session['session_key']);
                update_option($option_fb_sess_sec, $new_session['secret']);
                update_option($option_fb_sess_uid, $new_session['uid']);
                update_option($option_fb_sess_uname, $user[0]['name']);
                ?>
<div class="updated"><p><strong><?php 
                echo 'Facebook Session Saved. (UID: ' . $new_session['uid'] . ')';
                ?>
</strong></p></div><?php 
            } else {
                update_option($option_fb_sess_key, '');
                update_option($option_fb_sess_sec, '');
                update_option($option_fb_sess_uid, '');
                update_option($option_fb_sess_uname, '');
                ?>
<div class="updated"><p><strong><?php 
                echo 'An error occurred while linking with Facebook: ' . $errorMsg;
                ?>
</strong></p></div><?php 
            }
        }
        if (isset($_POST['reset-facebook-session'])) {
            update_option($option_fb_sess_key, '');
            update_option($option_fb_sess_sec, '');
            update_option($option_fb_sess_uid, '');
            update_option($option_fb_sess_uname, '');
            ?>
<div class="updated"><p><strong><?php 
            echo 'Reset Facebook account successfully';
            ?>
</strong></p></div><?php 
        }
        //Get all the options from the database
        $session_key = get_option($option_fb_sess_key);
        $session_sec = get_option($option_fb_sess_sec);
        $my_uid = get_option($option_fb_sess_uid);
        $my_name = get_option($option_fb_sess_uname);
        //Finally, OUTPUT THE ADMIN PAGE.
        ?>
		
			<?php 
        //SECTION - Connect to Facebook.  See note at top of file.
        ?>
			<div style="width:100%;padding-top:15px;"></div>
      <div class="clear"></div>
			<div id="main">
        
			<div id="panel-header">
						<?php 
        colabsthemes_options_page_header('save_button=false');
        ?>
			</div><!-- #panel-header -->

				<div id="panel-content">
				<div class="section">
					<h3 class="heading"><?php 
        _e('Connect with Facebook', 'colabsthemes');
        ?>
</h3>
					<div class="option">
					<?php 
        if ($my_uid) {
            echo "<p><i>This plugin is successfully connected with <b>{$my_name}</b>'s Facebook account and is ready to create galleries.</i></p>";
        } else {
            echo "<p>Before this plugin can be used, you must connect it with your Facebook account.</p><p>Please click the following button and complete the pop-up login form. <b><i>When finished, close the pop-up and click the save button to save your session</i></b>. You will only have to do this once.</p><p>If you failed save the session please check in your <a href='http://www.facebook.com/settings?tab=applications' target='-Blank'>Facebook App Settings</a> and remove it, then try to connect again.</p>";
        }
        if ($my_uid) {
            ?>
					<div id="step1wrap">
					<form method="post" id="step1Frm" action="">
						<input type="submit" class="button-secondary" id="step1Btn" value="<?php 
            echo _e('Reset Account', 'colabsthemes');
            ?>
" />
						<input type="hidden" name="reset-facebook-session" value="true" />
					</form>
					</div>
					
					<?php 
        } else {
            ?>
					<div id="step1wrap">
					<form method="get" id="step1Frm" action="http://www.facebook.com/login.php" target="_blank">
						<input type="hidden" name="api_key" value="<?php 
            echo $appapikey;
            ?>
" />
						<input type="hidden" name="auth_token" value="<?php 
            echo $token;
            ?>
" />
						<input type="hidden" name="popup" value="1" />      <?php 
            //Style the window as a popup
            ?>
						<input type="hidden" name="skipcookie" value="1" /> <?php 
            //User must enter login info even if already logged in
            ?>
						<input type="hidden" name="req_perms" value="offline_access,user_photos,friends_photos" /> <?php 
            //Require an infinite session
            ?>
						<input type="hidden" name="v" value="1.0" />
						<input type="submit" class="button-secondary" id="step1Btn" value="<?php 
            echo $my_uid ? "Change Account" : "Connect to Facebook";
            ?>
" />
					</form>
					</div>
					
					<div id="step2wrap" style="display:none;">
					<form method="post" action="">
						<input type="hidden" name="save-facebook-session" value="<?php 
            echo $token;
            ?>
" />
						<input type="submit" class="button-primary" value="Save Facebook Session" />
					</form>
					</div>
								
					<script type="text/javascript">
					jQuery(document).ready(function() {
						jQuery('#step1Frm').submit(function(e) {
								e.preventDefault();
								jQuery('#step1wrap').toggle();
								jQuery('#step2wrap').toggle();
								
								var $form = jQuery(this),
										url = $form.attr('action'),
										param = $form.serialize();
										url = url + '?' + param + '&TB_iframe=true';
								
								window.open (url,"Facebook Login","menubar=1,resizable=0,width=500,height=350");
										
							});
					});
					</script>
					<?php 
        }
        ?>
					</div>
				</div>
				</div>	
				</div>
			</div>
			<?php 
    }
    function admin_screen()
    {
        $themename = get_option('colabs_themename');
        $options_gateways = $this->default_options_gateways;
        $gateways = Colabs_Gateway_Registry::get_gateways();
        foreach ($gateways as $gateway) {
            $options_gateways = array_merge($options_gateways, $gateway->form());
        }
        ?>
    <div class="wrap colabs_container">
      <h2></h2>
      <form action="" method="post">
      <input name="page" type="hidden" value="gateways" />
      <input name="submitted" type="hidden" value="true" />      
      <div class="clear"></div>
      <div id="colabs-popup-save" class="colabs-save-popup"><div class="colabs-save-save"><?php 
        _e("Options Updated", "colabsthemes");
        ?>
</div></div>
      <div id="colabs-popup-reset" class="colabs-save-popup"><div class="colabs-save-reset"><?php 
        _e("Options Reset", "colabsthemes");
        ?>
</div></div>
      <div class="clear"></div>
      <?php 
        $return = colabsthemes_machine($options_gateways);
        ?>
      <div id="main" class="menu-item-settings metabox-holder">
        <div id="panel-header">
          <?php 
        colabsthemes_options_page_header(array('save_button' => 'true'));
        ?>
        </div><!-- #panel-header -->
        <div id="sidebar-nav">
          <ul>
            <?php 
        echo $return[1];
        ?>
          </ul>
        </div>
        <div id="panel-content">
          <div class="group help-block"> <p><?php 
        _e("Drag icon on the left and Drop it here to customize", "colabsthemes");
        ?>
</p> </div>
          <?php 
        echo $return[0];
        ?>
          <div class="clear"></div>
        </div>
        <div id="panel-footer">
          <ul>
            <li class="docs"><a title="Theme Documentation" href="http://colorlabsproject.com/documentation/<?php 
        echo strtolower(str_replace(" ", "", $themename));
        ?>
" target="_blank" ><?php 
        _e('View Documentation', 'colabsthemes');
        ?>
</a></li>
            <li class="forum"><a href="http://colorlabsproject.com/resolve/" target="_blank"><?php 
        _e('Submit a Support Ticket', 'colabsthemes');
        ?>
</a></li>
            <li class="idea"><a href="http://ideas.colorlabsproject.com/" target="_blank"><?php 
        _e('Suggest a Feature', 'colabsthemes');
        ?>
</a></li>
          </ul>
        </div><!-- #panel-footer -->
      </div><!-- #main -->
      </form>
    </div><!--wrap-->
    <?php 
    }
?>
 colabs_instagram">

	<div class="one_col wrap colabs_container">
    
            <div class="clear"></div>
            <div id="colabs-popup-save" class="colabs-save-popup"><div class="colabs-save-save">Options Updated</div></div>
            <div id="colabs-popup-reset" class="colabs-save-popup"><div class="colabs-save-reset">Options Reset</div></div>
            <div style="width:100%;padding-top:15px;"></div>
            <div class="clear"></div>
        
	<div id="main">
        
	<div id="panel-header">
        <?php 
colabsthemes_options_page_header('save_button=false');
?>
	</div><!-- #panel-header -->

    <div id="panel-content">
	
	<?php 
$isPHP5 = version_compare(phpversion(), '5.0.0', '>=');
if (!$isPHP5) {
    $colabsErrors = array(sprintf(__('colabs requires at least PHP 5.0 to work properly, your version is: %s', 'colabsthemes'), phpversion()));
} else {
    // Fehlermeldungen ausgeben
    $colabsErrors = ColabsInstagram::getInstance()->getErrors();
}
if ($colabsErrors) {
    ?>
    /**
     * admin_screen()
     *
     * Load the admin screen.
     *
     * @since 1.0.0
     */
    function admin_screen()
    {
        $themename = get_option('colabs_themename');
        $export_type = 'all';
        if (isset($_POST['export-type'])) {
            $export_type = esc_attr($_POST['export-type']);
        }
        ?>

<div id="colabs_options" class="one_col wrap colabs_container <?php 
        if (is_rtl()) {
            echo 'rtl';
        }
        ?>
 colabs_customizer">
  <h2></h2>
	
	<div id="main">
        
		<div id="panel-header">
        <?php 
        colabsthemes_options_page_header('save_button=false');
        ?>
		</div><!-- #panel-header -->

    <div id="panel-content">

			<div class="section">
			
				<h3 class="heading"><?php 
        _e('Import Customizer Settings', 'colabsthemes');
        ?>
</h3>
				<div class="option">
				<p><?php 
        printf(__('If you have tried <a href="%s" target="_blank">Colorlabs Customizer Demo</a> and export the settings into your computer, then you can import the exported file (.json) containing customizer settings to your site here. ', 'colabsthemes'), 'http://demo.colorlabsproject.com');
        ?>
</p>
					<p><?php 
        printf(__('Or you can customize your theme by using <a href="%s">Wordpress Customizer</a>.', 'colabsthemes'), wp_customize_url());
        ?>
</p>
				<div class="form-wrap">
					<form enctype="multipart/form-data" method="post" action="<?php 
        echo admin_url('admin.php?page=' . $this->token);
        ?>
">
						<?php 
        wp_nonce_field('colabsthemes-customizer-import');
        ?>
						<label for="colabsthemes-import-file"><?php 
        printf(__('Upload File: (Maximum Size: %s)', 'colabsthemes'), ini_get('post_max_size'));
        ?>
</label>
						<input type="file" id="colabsthemes-import-file" name="colabsthemes-import-file" size="25" />
						<input type="hidden" name="colabsthemes-customizer-import" value="1" />
						<input type="submit" class="button" value="<?php 
        _e('Upload File and Import', 'colabsthemes');
        ?>
" />
					</form>
				</div><!--/.form-wrap-->
				</div><!-- .option -->

			</div><!-- .section -->

    </div><!-- #panel-content -->

    <div id="panel-footer">
      <ul>
          <li class="docs"><a title="Theme Documentation" href="http://colorlabsproject.com/documentation/<?php 
        echo strtolower(str_replace(" ", "", $themename));
        ?>
" target="_blank" ><?php 
        _e('View Documentation', 'colabsthemes');
        ?>
</a></li>
          <li class="forum"><a href="http://colorlabsproject.com/resolve/" target="_blank"><?php 
        _e('Submit a Support Ticket', 'colabsthemes');
        ?>
</a></li>
          <li class="idea"><a href="http://ideas.colorlabsproject.com/" target="_blank"><?php 
        _e('Suggest a Feature', 'colabsthemes');
        ?>
</a></li>
      </ul>
  	</div><!-- #panel-footer -->
	</div><!-- #main -->

</div><!-- .wrap -->
<?php 
    }
function colabsthemes_seo_page()
{
    $themename = get_option('colabs_themename');
    $manualurl = get_option('colabs_manual');
    $shortname = 'seo_colabs';
    //Framework Version in Backend Head
    $colabs_framework_version = get_option('colabs_framework_version');
    //GET themes update RSS feed and do magic
    include_once ABSPATH . WPINC . '/feed.php';
    $pos = strpos($manualurl, 'documentation');
    $theme_slug = str_replace("/", "", substr($manualurl, $pos + 13));
    //13 for the word documentation
    //add filter to make the rss read cache clear every 4 hours
    add_filter('wp_feed_cache_transient_lifetime', create_function('$a', 'return 14400;'));
    $inner_pages = array('b' => 'Page title;', 'a' => 'Page title; Blog title', 'd' => 'Page title; Blog description', 'f' => 'Page title; Blog title; Blog description', 'c' => 'Blog title; Page title;', 'e' => 'Blog title; Page title; Blog description');
    $seo_options = array();
    $seo_options[] = array("name" => __("Page Title", "colabsthemes"), "icon" => "misc", "type" => "heading");
    $seo_options[] = array("name" => __("Blog Title", "colabsthemes"), "desc" => __("NOTE: This value corresponds to that in the Settings > General tab in the WordPress Dashboard.", "colabsthemes"), "id" => "blogname", "std" => "", "type" => "text");
    $seo_options[] = array("name" => __("Blog Description", "colabsthemes"), "desc" => __("NOTE: This value corresponds to that in the Settings > General tab in the WordPress Dashboard.", "colabsthemes"), "id" => "blogdescription", "std" => "", "type" => "text");
    $seo_options[] = array("name" => __("Separator", "colabsthemes"), "desc" => __("Set a character that separates elements of your page titles ( eg. |, -, or &raquo; ).", "colabsthemes"), "id" => $shortname . "_separator", "std" => "|", "type" => "text");
    $seo_options[] = array("name" => __("Custom Page Titles", "colabsthemes"), "desc" => __("Check this box to gain control over the elements of the page titles (highly recommended).", "colabsthemes"), "id" => $shortname . "_wp_title", "std" => "true", "class" => "collapsed", "type" => "checkbox");
    $seo_options[] = array("name" => __("Homepage Title Layout", "colabsthemes"), "desc" => __("Define the order of the title elements.", "colabsthemes"), "id" => $shortname . "_home_layout", "std" => "a", "class" => "hidden", "options" => array('b' => 'Blog title', 'a' => 'Blog title; Blog description', 'c' => 'Blog description', 'd' => 'Blog description; Blog title'), "type" => "select2");
    $seo_options[] = array("name" => __("Single Title Layout", "colabsthemes"), "desc" => __("Define the order of the title elements.", "colabsthemes"), "id" => $shortname . "_single_layout", "std" => "f", "class" => "hidden", "options" => $inner_pages, "type" => "select2");
    $seo_options[] = array("name" => __("Page Title Layout", "colabsthemes"), "desc" => __("Define the order of the title elements.", "colabsthemes"), "id" => $shortname . "_page_layout", "std" => "f", "class" => "hidden", "options" => $inner_pages, "type" => "select2");
    $seo_options[] = array("name" => __("Archive Title Layout", "colabsthemes"), "desc" => __("Define the order of the title elements.", "colabsthemes"), "id" => $shortname . "_archive_layout", "std" => "f", "class" => "hidden", "options" => $inner_pages, "type" => "select2");
    $seo_options[] = array("name" => __("Page Number", "colabsthemes"), "desc" => __("Define a text string that precedes page number in page titles.", "colabsthemes"), "id" => $shortname . "_paged_var", "std" => "Page", "class" => "hidden", "type" => "text");
    $seo_options[] = array("name" => __("Page Number Position", "colabsthemes"), "desc" => __("Define the position of page number in page titles.", "colabsthemes"), "id" => $shortname . "_paged_var_pos", "std" => "before", "class" => "hidden", "options" => array('before' => 'Before Title', 'after' => 'After Title'), "type" => "select2");
    $seo_options[] = array("name" => __("Disable Custom Titles", "colabsthemes"), "desc" => __("If you prefer to have uniform titles across you theme. Alternatively they will be generated from custom fields and/or plugin data.", "colabsthemes"), "id" => $shortname . "_wp_custom_field_title", "std" => "false", "class" => "hidden hide", "type" => "checkbox");
    $seo_options[] = array("name" => __("Description Meta", "colabsthemes"), "icon" => "misc", "type" => "heading");
    $seo_options[] = array("name" => __("Homepage Description", "colabsthemes"), "desc" => __("Choose where to populate the homepage meta description from.", "colabsthemes"), "id" => $shortname . "_meta_home_desc", "std" => "b", "class" => "collapsed", "options" => array("a" => "Off", "b" => "From Site Description", "c" => "From Custom Homepage Description"), "type" => "radio");
    $seo_options[] = array("name" => __("Custom Homepage Description", "colabsthemes"), "desc" => __("Add a custom meta description to your homepage.", "colabsthemes"), "id" => $shortname . "_meta_home_desc_custom", "std" => "", "class" => "hidden last", "type" => "textarea");
    $seo_options[] = array("name" => __("Single Page/Post Description", "colabsthemes"), "desc" => __("Choose where to populate the single Page/Post meta description from.", "colabsthemes"), "id" => $shortname . "_meta_single_desc", "std" => "c", "options" => array("a" => "Off *", "b" => "From Custom Field and/or Plugin Data", "c" => "Automatically from Post/Page Content"), "type" => "radio");
    $seo_options[] = array("name" => __("Global Post/Page Description", "colabsthemes"), "desc" => __("Add a custom meta description to your posts and pages. This will only show if no other data is available from the selection above. This will still be added even if setting above is set to \"Off\".", "colabsthemes"), "id" => $shortname . "_meta_single_desc_sitewide", "std" => "", "class" => "collapsed", "type" => "checkbox");
    $seo_options[] = array("name" => __("Global Post/Page Description", "colabsthemes"), "desc" => __("Add a global post/page description.", "colabsthemes"), "id" => $shortname . "_meta_single_desc_custom", "std" => "", "class" => "hidden", "type" => "textarea");
    $seo_options[] = array("name" => __("Keyword Meta", "colabsthemes"), "icon" => "misc", "type" => "heading");
    $seo_options[] = array("name" => __("Homepage Keywords", "colabsthemes"), "desc" => __("Choose where to populate the homepage meta keywords from.", "colabsthemes"), "id" => $shortname . "_meta_home_key", "std" => "a", "class" => "collapsed", "options" => array("a" => "Off", "c" => "From Custom Homepage Keywords"), "type" => "radio");
    $seo_options[] = array("name" => __("Custom Homepage Keywords", "colabsthemes"), "desc" => __("Add a comma-separated list of keywords to your homepage.", "colabsthemes"), "id" => $shortname . "_meta_home_key_custom", "std" => "", "class" => "hidden last", "type" => "textarea");
    $seo_options[] = array("name" => __("Single Page/Post Keywords", "colabsthemes"), "desc" => __("Choose where to populate the single page/post meta keywords from.", "colabsthemes"), "id" => $shortname . "_meta_single_key", "std" => "c", "options" => array("a" => "Off *", "b" => "From Custom Fields and/or Plugins", "c" => "Automatically from Post Tags &amp; Categories"), "type" => "radio");
    $seo_options[] = array("name" => __("Global Post/Page Keywords", "colabsthemes"), "desc" => __("Add custom meta keywords to your posts and pages. These will only show if no other data is available from the selection above. These will still be added even if setting above is set to \"Off\".", "colabsthemes"), "id" => $shortname . "_meta_single_key_sitewide", "std" => "", "class" => "collapsed", "type" => "checkbox");
    $seo_options[] = array("name" => __("Global Post/Page Keywords", "colabsthemes"), "desc" => __("Add a comma-separated list of keywords to your posts and pages.", "colabsthemes"), "id" => $shortname . "_meta_single_key_custom", "std" => "", "class" => "hidden", "type" => "textarea");
    $seo_options[] = array("name" => __("Indexing Options", "colabsthemes"), "icon" => "misc", "type" => "heading");
    $seo_options[] = array("name" => __("Archive Pages to Index", "colabsthemes"), "desc" => __("Select which archive pages to be indexed. Indexing archive pages may result in duplicate entries in search engines and cause content dilution.", "colabsthemes"), "id" => $shortname . "_meta_indexing", "std" => "category", "type" => "multicheck", "options" => array('category' => 'Category Archives', 'tag' => 'Tag Archives', 'author' => 'Author Pages', 'search' => 'Search Results', 'date' => 'Date Archives'));
    $seo_options[] = array("name" => __("Add 'follow' Meta to Posts and Pages", "colabsthemes"), "desc" => __("Check this box to add 'follow' meta to all posts and pages. This means that all links on these pages will be crawled by search engines, including those leading away from your site.", "colabsthemes"), "id" => $shortname . "_meta_single_follow", "std" => "", "type" => "checkbox");
    $seo_options[] = array("name" => __("Advanced Settings", "colabsthemes"), "icon" => "general", "type" => "heading");
    $seo_options[] = array("name" => __("Please Read", "colabsthemes"), "type" => "info", "std" => "Data from 3rd party plugin such as All-in-One SEO Pack, Headspace 2 and WordPress SEO By Yoast can also be used where applicable. Use the checkbox below to use 3rd party plugin data.</span>");
    $seo_options[] = array("name" => __("Use 3rd Party Plugin Data", "colabsthemes"), "desc" => __("Meta data added to <strong>custom fields in posts and pages</strong> will be extracted and used where applicable. This typically does not include home page and archive pages and only single post/pages.", "colabsthemes"), "id" => $shortname . "_use_third_party_data", "std" => "false", "type" => "checkbox");
    $seo_options[] = array("name" => __("Hide ColorLabs SEO Settings", "colabsthemes"), "desc" => __("Check this box to hide the ColorLabs SEO Settings box in the post and page editing screens.", "colabsthemes"), "id" => $shortname . "_hide_fields", "std" => "false", "type" => "checkbox");
    update_option('colabs_seo_template', $seo_options);
    ?>
		<?php 
    if (class_exists('All_in_One_SEO_Pack') || class_exists('Headspace_Plugin') || class_exists('WPSEO_Admin') || class_exists('WPSEO_Frontend')) {
        echo "<div id='' class='update-nag'><strong>3rd Party SEO Plugin(s) Detected</strong> - Some " . $themename . " SEO functionality has been disabled.</div>";
    }
    ?>

		<?php 
    if (get_option('blog_public') == 0) {
        echo "<div id='' class='update-nag'><strong>This site is set to Private</strong> - SEO is disabled, change settings <a href='" . admin_url('options-privacy.php') . "'>here</a>.</div>";
    }
    ?>

		<div class="wrap colabs_container">

			<form action="" enctype="multipart/form-data" id="colabsform">
				<?php 
    // Add nonce for added security.
    if (function_exists('wp_nonce_field')) {
        wp_nonce_field('colabsframework-seo-options-update');
    }
    // End IF Statement
    $colabs_nonce = '';
    if (function_exists('wp_create_nonce')) {
        $colabs_nonce = wp_create_nonce('colabsframework-seo-options-update');
    }
    // End IF Statement
    if ('' == $colabs_nonce) {
    } else {
        ?>
					<input type="hidden" name="_ajax_nonce" value="<?php 
        echo $colabs_nonce;
        ?>
" />
				<?php 
    }
    // End IF Statement
    ?>
        
				<div class="clear"></div>

				<?php 
    colabs_theme_check();
    ?>
				<div id="colabs-popup-save" class="colabs-save-popup"><div class="colabs-save-save"><?php 
    _e("Options Updated", "colabsthemes");
    ?>
</div></div>
				<div id="colabs-popup-reset" class="colabs-save-popup"><div class="colabs-save-reset"><?php 
    _e("Options Reset", "colabsthemes");
    ?>
</div></div>
				<div style="width:100%;padding-top:15px;"></div>

				<div class="clear"></div>
				<?php 
    $return = colabsthemes_machine($seo_options);
    ?>
				<div id="main" class="menu-item-settings metabox-holder">
					<div id="panel-header">
						<?php 
    colabsthemes_options_page_header('reset_button=false');
    ?>
					</div><!-- #panel-header -->

					<div id="sidebar-nav">
						<ul><?php 
    echo $return[1];
    ?>
</ul>
					</div>

					<div id="panel-content">
						<div class="group help-block"> <p><?php 
    _e("Drag icon on the left and Drop it here to customize", "colabsthemes");
    ?>
</p> </div>
						<?php 
    echo $return[0];
    ?>
						<div class="clear"></div>
					</div>

					<div id="panel-footer">
						<ul>
							<li class="docs"><a title="Theme Documentation" href="http://colorlabsproject.com/documentation/<?php 
    echo strtolower(str_replace(" ", "", $themename));
    ?>
" target="_blank" ><?php 
    _e("View Documentation", "colabsthemes");
    ?>
</a></li>
							<li class="forum"><a href="http://colorlabsproject.com/resolve/" target="_blank"><?php 
    _e("Submit a Support Ticket", "colabsthemes");
    ?>
</a></li>
							<li class="idea"><a href="http://ideas.colorlabsproject.com/" target="_blank"><?php 
    _e("Suggest a Feature", "colabsthemes");
    ?>
</a></li>
						</ul>
							
						<div class="save-bar save_bar_top right">
							<img style="display:none" src="<?php 
    echo get_template_directory_uri();
    ?>
/functions/images/ajax-loading.gif" class="ajax-loading-img ajax-loading-img-top" alt="Working..." />
							<input type="submit" value="Save Changes" class="button submit-button button-primary" />
							<button class="button submit-button reset-button button-highlighted"><?php 
    _e('Reset Options', 'colabsthemes');
    ?>
</button>
						</div>
					</div><!-- #panel-footer -->

				</div><!-- #main -->
			</form>

			<form action="<?php 
    echo esc_attr($_SERVER['REQUEST_URI']);
    ?>
" method="post" id="colabsform-reset" style="display: none">
				<?php 
    // Add nonce for added security.
    if (function_exists('wp_nonce_field')) {
        wp_nonce_field('colabsframework-seo-options-reset');
    }
    // End IF Statement
    $colabs_nonce = '';
    if (function_exists('wp_create_nonce')) {
        $colabs_nonce = wp_create_nonce('colabsframework-seo-options-reset');
    }
    // End IF Statement
    if ('' == $colabs_nonce) {
    } else {
        ?>
					<input type="hidden" name="_ajax_nonce" value="<?php 
        echo $colabs_nonce;
        ?>
" />
				<?php 
    }
    // End IF Statement
    ?>
				
				<input name="reset" type="submit" value="Reset Options" class="button submit-button reset-button button-highlighted" onclick="return confirm( '<?php 
    _e("Click OK to reset all options. All settings will be lost", "colabsthemes");
    ?>
!' );" />
				<input type="hidden" name="colabs_save" value="reset" /> 
			</form>
		<div style="clear:both;"></div>
	</div><!--wrap-->

<?php 
}
function colabsthemes_sbm_page()
{
    global $wp_registered_sidebars;
    // If the user wants to reset the script, we reset the script.
    if (isset($_POST['colabs_save']) && 'sbm_reset' == $_POST['colabs_save']) {
        colabsthemes_sbm_reset();
    }
    // End IF Statement
    //Load SBM settings
    $init_array = array('sidebars' => array(), 'settings' => array('infobox' => 'show'));
    add_option('sbm_colabs_sbm_options', $init_array);
    $colabs_sbm_options = get_option('sbm_colabs_sbm_options');
    //Error checking
    if (!empty($colabs_sbm_options['sidebars'])) {
        foreach ($colabs_sbm_options['sidebars'] as $key => $options) {
            if (empty($key)) {
                unset($colabs_sbm_options['sidebars'][$key]);
            }
        }
    }
    //delete_option( 'sbm_colabs_sbm_options' );
    $themename = get_option('colabs_themename');
    $manualurl = get_option('colabs_manual');
    //Framework Version in Backend Head
    $colabs_framework_version = get_option('colabs_framework_version');
    //Outout for original sidebars, and new sidebars
    $init_sidebars = '';
    $init_sidebar = '';
    $new_sidebars = '';
    $counter = 0;
    foreach ($wp_registered_sidebars as $sidebar) {
        if (!strstr($sidebar['id'], 'colabs_sbm_')) {
            $counter++;
            if ($counter == 1) {
                $init_sidebar = $sidebar['name'];
            }
            $init_sidebars .= '<option value="' . $sidebar['id'] . '">' . $sidebar['name'] . '</option>';
        } else {
            $new_sidebars .= '<option value="' . $sidebar['id'] . '">' . $sidebar['name'] . '</option>';
        }
    }
    //Start script output
    ?>
	<script type="text/javascript">
	/* Below is the IE fix for .live( 'submit')  error */
	/**
	 * Patch (plugin) for jQuery bug 6359: "live( 'submit') does nothing in IE if
	 * live( 'click') was called before. same with delegate."
	 *
	 * The workaround is to ensure that live( 'click') calls happen *after*
	 * live( 'submit') calls. Fixing live() fixes delegate(), which calls live().
	 *
	 * This plugin uses setTimeout(..., 0) to effect the workaround. That is, it
	 * defers live( 'click') calls to a future execution context. It should work
	 * around the issue in most cases.
	 *
	 * @author Jonathan Aquino
	 * @see http://dev.jquery.com/ticket/6359
	 * @see TEZLA-538
	 */
	(function($) {
		    var originalLive = jQuery.fn.live;
		    jQuery.fn.live = function(types) {
		        var self = this;
		        var args = arguments;
		        if ('click' == types) {
		            setTimeout(function() {
		                originalLive.apply(self, args);
		            }, 0);
		        } else {
		            originalLive.apply(self, args);
		        }
		    };
	})(jQuery);

	//Accordian for the template selecting
	function initMenus() {

		jQuery( '.colabs-sbm-menu ul ul').hide();

		jQuery( '.colabs-sbm-menu ul ul:first').show();


		jQuery( '.colabs-sbm-menu ul#colabs-sbm-menu_ul li a').click(
			function() {
				var checkElement = jQuery(this).next();
				var parent = this.parentNode.parentNode.id;


				if((checkElement.is( 'ul')) && (!checkElement.is( ':visible'))) {
				jQuery( '#' + parent + ' > li a span').text( '[+]' );
					jQuery( '#' + parent + ' ul:visible').slideUp( 'normal' );
					checkElement.slideDown( 'normal' );
					checkElement.parent().find( 'a span').text( '[-]' );

				}
				return false;
			});
		}

	jQuery(document).ready(function() {
		initMenus();

		function colabs_sbm_title(sidebar,name,type){

			if ( 'custom_post_type' == type ) {

				type = 'Custom Post Type';

			} // End IF Statement

			var message = name+', '+type+' ( '+sidebar+')';
			return message;
		}

		function colabs_sbm_description(sidebar,name,type){
			if('post_tag' == type) type = 'tag template';
			if('page_template' == type) type = 'page template';
			if('hierarchy' == type) type = 'template hierarchy';
			if('custom_post_type' == type) type = 'custom post type';
			if('post_type_archive' == type) type = 'post type archive';

			var message = '<?php 
    _e("This sidebar will replace the", "colabsthemes");
    ?>
 '+sidebar+' <?php 
    _e("sidebar on the", "colabsthemes");
    ?>
 '+name+' '+type+'.';
			return message;
		}

		jQuery( '.item-edit').click(function(){
			jQuery(this).parent().parent().parent().next( '.menu-item-settings').slideToggle(function(){ colabsAdmin.equalHeight(); });
			return false;
		});

		jQuery( '#colabs-sbm-toggle-info').live( 'click',function(){
			var info = jQuery( '#colabs-sbm-builder-meta' );
			if('none' == info.css( 'display')){
				info.fadeIn();
			} else {
				info.fadeOut();
			}
			return false;
		});
		jQuery( '#colabs-sbm-builder-piggy').val(0);
		jQuery( '#colabs-sbm-tab-new').live( 'click',function(){

			jQuery( '.nav-tabs .nav-tab').removeClass( 'nav-tab-active' );
			jQuery(this).addClass( 'nav-tab-active' );
			jQuery( '#colabs-sbm-builder-part-assign').hide();
			jQuery( '#colabs-sbm-builder-part-create').show();
			jQuery( '#colabs-sbm-builder-piggy').val(0);
			jQuery( '#colabs-sbm-label-sb-name span').text( "Sidebar Name" );
			jQuery( '#colabs-sbm-label-sb-desc').show();
			return false;
		});

		jQuery( '#colabs-sbm-tab-existing').live( 'click',function(){

			jQuery( '.nav-tabs .nav-tab').removeClass( 'nav-tab-active' );
			jQuery(this).addClass( 'nav-tab-active' );
			jQuery( '#colabs-sbm-builder-part-create').hide();
			jQuery( '#colabs-sbm-builder-part-assign').show();
			jQuery( '#colabs-sbm-builder-piggy').val(1);
			jQuery( '#colabs-sbm-label-sb-name span').text( "Sidebar Alias" );
			jQuery( '#colabs-sbm-label-sb-desc').hide();
			return false;
		});

		jQuery( '.colabs-sbm-menu ul#colabs-sbm-menu_ul ul li').click(function(){

			var template_data = jQuery(this).children( 'span').text();
	    	var ajax_url = '<?php 
    echo admin_url("admin-ajax.php");
    ?>
';
	    	var data = {
	    		type: 'colabs_sbm_get_links',
	    		action: 'colabs_sbm_post_action',
	    		data:template_data
	    	};

	    	jQuery.post(ajax_url, data, function(response) {
				
				jQuery('.colabs-sbm-builder').hide("fast");
				jQuery('.colabs-sbm-builder').slideToggle("normal");
				colabsAdmin.equalHeight();

	    		//GET LINKS
				var response = response.split( '|' );
				var type	= response[0];
				var name	= response[1];
				var slug	= response[2];
				var id		= response[3];
				var other	= response[4];
				var cond	= response[5];

				//When user changes sidebar to replace
				jQuery( '#sidebar_to_replace').live( 'change',function(){
		 			var sidebar = "";
          			jQuery(this).children( "option:selected").each(function(){
                		sidebar = jQuery(this).text();
              		});
          			generatedTitle = colabs_sbm_title(sidebar,name,type);
					generatedMessage = colabs_sbm_description(sidebar,name,type);
					jQuery( '#sidebar-title').val(generatedTitle);
					jQuery( '#sidebar-description').val(generatedMessage);

				});

				var html = '';
				var class_name = '';

				generatedTitle = colabs_sbm_title( '<?php 
    echo $init_sidebar;
    ?>
',name,type);
				generatedMessage = colabs_sbm_description( '<?php 
    echo $init_sidebar;
    ?>
',name,type);

				jQuery( '#colabs-sbm-get-links').show();

				//Add Values to Template Info
				var name_input = jQuery( '#colabs-sbm-get-links-inner #template-info-name' );
				name_input.val(name);
				name_input.prev( 'label').html( '<span><?php 
    _e("Name", "colabsthemes");
    ?>
:</span> '+name);

				var type_input = jQuery( '#colabs-sbm-get-links-inner #template-info-type' );
				type_input.val(type);
				type_input.val(type).prev().html( '<span><?php 
    _e("Type", "colabsthemes");
    ?>
:</span> '+type);

				var slug_input = jQuery( '#colabs-sbm-get-links-inner #template-info-slug' );
				slug_input.val(slug);
				slug_input.prev().html( '<span><?php 
    _e("Slug", "colabsthemes");
    ?>
:</span> '+slug);

				var id_input = jQuery( '#colabs-sbm-get-links-inner #template-info-id' );
				id_input.val(id);
				id_input.prev().html( '<span><?php 
    _e("ID", "colabsthemes");
    ?>
:</span> '+id);

				if(other != ''){
					var other_input = jQuery( '#colabs-sbm-get-links-inner #template-info-other' );
					other_input.val(other);
					other_input.prev().html( '<span><?php 
    _e("URL", "colabsthemes");
    ?>
:</span> <small><a href="'+ other +'">'+ other +'</a></small>' );
				} else {
					var other_input = jQuery( '#colabs-sbm-get-links-inner #template-info-other' );
					other_input.val( 'n/a' );
					other_input.prev().html( '<span><?php 
    _e("URL", "colabsthemes");
    ?>
:</span> n/a' );

				}

				//Add Values to Sidebar Builder
				jQuery( '#colabs-sbm-get-links-inner #sidebar-title').val(generatedTitle);
				jQuery( '#colabs-sbm-get-links-inner #sidebar-description').val(generatedMessage);
				jQuery( '#colabs-sbm-get-links-inner #colabs-sbm-builder-conditional').val(cond);


				html += '<label id="colabs-sbm-label-sb-desc"><span>Sidebar description</span> <textarea id="sidebar-description" name="sidebar-description" style="width:230px">'+generatedMessage+'</textarea></label>';
			 	html += '<input id="colabs-sbm-builder-conditional" type="hidden" name="conditional" value="'+cond+'" />';

	    		var success = jQuery( '#colabs-popup-save' );
	    		var loading = jQuery( '.ajax-loading-img' );
	    		loading.fadeOut();
	    		//jQuery( '#colabs-sbm-tip-1').hide(); //Fade tip out

	    	});
	    	return false;
		});

		//Now to save your new sidebar

		jQuery( "#colabs-sbm-get-links .colabs-sbm-controls input[type=submit]").live( "click",function(){

	    	var sidebarTitle = jQuery( '#sidebar-title').val();
	    	if('' == sidebarTitle){ 
	    		alert( '<?php 
    _e("Please add a Sidebar Name!", "colabsthemes");
    ?>
' );
	    		return false;
	    	}

	    	function newValues() {
	    	  var serializedValues = jQuery( "#colabs-sbm-get-links").serialize();
	    	  return serializedValues;
	    	}
	    	jQuery( ":checkbox, :radio").click(newValues);
	    	jQuery( "select").change(newValues);
	    	jQuery( '.ajax-loading-img').fadeIn();
	    	var serializedReturn = newValues();

	    	var ajax_url = '<?php 
    echo admin_url("admin-ajax.php");
    ?>
';

	    	var data = {
	    		type: 'colabs_sbm_add_sidebar',
	    		action: 'colabs_sbm_post_action',
	    		data: serializedReturn
	    	};

	    	jQuery.post(ajax_url, data, function(response) {

	    		//Split response up
				var response = response.split( '|' );

				//Only stage is used in this case
				var type	= response[0];
				var slug	= response[1];
				var name	= response[2];
				var id		= response[3];
				var other	= response[4]; // URL's mostly
				var cond	= response[5];
				var stage	= response[6];
				var sbName	= response[7];
				var sbId	= response[8];
				var piggy	= response[9];

	    		var success = jQuery( '#colabs-popup-save' );
	    		var loading = jQuery( '.ajax-loading-img' );
	    		loading.fadeOut();
	    		if(stage == 2){
	    			location.reload();
	    		}
	    	});
	    	return false;
	    });

   	    //Delete a sidebar
	    jQuery( '#colabs-sbm-sidebars .menu-item .submitdelete').live( 'click',function(){

	    	var id = jQuery(this).parent().parent().parent().parent().attr( 'id' );
	    	var ajax_url = '<?php 
    echo admin_url("admin-ajax.php");
    ?>
';
	    	var data = {
	    		type: 'colabs_sbm_delete-sidebar',
	    		action: 'colabs_sbm_post_action',
	    		data: id
	    	};
	    	if('' == id){
	    		alert( '<?php 
    _e("And error has occured: No ID found.", "colabsthemes");
    ?>
' ); die();
	    	}

	    	jQuery.post(ajax_url, data, function(response) {
	    		//Split response up
				var response = response.split( '|' );

				//Only stage is used in this case
				var ids		= response[0];
				var pos		= response[1];

				jQuery(ids).fadeOut( 'slow',function(){ jQuery(this).remove();});
				if(jQuery(id).hasClass( 'menu-item-depth-0')){
					jQuery(this).next( '.menu-item-depth-1').fadeOut( 'slow',function(){ jQuery(this).remove();});
				}

				jQuery( '#sidebar_to_piggyback option').each(function(){
					if(jQuery(this).val() == pos){ jQuery(this).remove();}
				});
				if(jQuery( '#sidebar_to_piggyback option').length == 0){
					//alert( 'its done' );
					jQuery( '#colabs-sbm-tab-existing').remove();
					jQuery( '#colabs-sbm-tab-new').click();
				};
	    	});
	    	return false;
	    });

	    //Cancel a sidebar
	    jQuery( '#colabs-sbm-sidebars .menu-item .submitcancel').live( 'click',function(){
	    	jQuery(this).parent().parent().slideUp(function(){ colabsAdmin.equalHeight(); });
	    	return false;
	    })

   	    //Edit a sidebar
	    jQuery( '#colabs-sbm-sidebars .menu-item .submitsave').live( 'click',function(){

	    	var clicked = jQuery(this);
	    	var id = clicked.parent().parent().attr( 'id' );

	    		function newValues() {
	    	  		var serializedValues = clicked.parent().parent().parent().parent().find( 'form').serialize();
	    	  		return serializedValues;
	    		}
	    		jQuery( ":checkbox, :radio").click(newValues);
	    		jQuery( "select").change(newValues);
	    		jQuery( '.ajax-loading-img').fadeIn();
	    		var serializedReturn = newValues();

	    		var ajax_url = '<?php 
    echo admin_url("admin-ajax.php");
    ?>
';

	    		var data = {
	    			type: 'colabs_sbm_save-sidebar',
	    			action: 'colabs_sbm_post_action',
	    			data: serializedReturn
	    		};

	    		jQuery.post(ajax_url, data, function(response) {

	    			var response = response.split( '|' );
					var name	= response[0];
					var sidebar	= response[1];

	    			var loading = jQuery( '.ajax-loading-img' );
	    			loading.fadeOut();
	    			clicked.parent().parent().parent().parent().find( '.item-title').text(name);
	    			clicked.parent().parent().parent().parent().find( '.item-type').text(sidebar);
	    			clicked.parent().parent().slideUp();

	    		});

	    	return false;


	    });

	    //Delete a sidebar
	    jQuery( '.sbm-content .btn-close').live( 'click',function(){

	    	var ajax_url = '<?php 
    echo admin_url("admin-ajax.php");
    ?>
';
	    	var data = {
	    		type: 'colabs_sbm_dismiss_intro',
	    		action: 'colabs_sbm_post_action',
	    		data: ''
	    	};

	    	jQuery.post(ajax_url, data, function(response) {
				jQuery( '.sbm-content .info-box').slideUp( 'slow',function(){ jQuery(this).remove();});
	    	});
	    	return false;
	    });

});
</script>

<div class="wrap colabs_container">

    <div id="colabsform">
    <div id="main" class="sbm-content">
    
        <div id="panel-header">
            <?php 
    colabsthemes_options_page_header('reset_button=false&save_button=false');
    ?>
        </div><!-- #panel-header -->
    
    	<div id="sidebar-nav" class="colabs-sbm-menu">

			<ul id="colabs-sbm-menu_ul">
			<?php 
    $pages = get_pages(array('sort_order' => 'ASC'));
    ?>
			<?php 
    if (!empty($pages)) {
        ?>
			<li><a href="#">Pages <span>[-]</span></a>
				<ul>
					<?php 
        foreach ($pages as $page) {
            if (array_key_exists('colabs_sbm_page_' . $page->ID, $colabs_sbm_options['sidebars'])) {
                continue;
            }
            echo '<li>' . $page->post_title . '<span>type=page&name=' . urlencode($page->post_title) . '&slug=' . $page->post_name . '&id=' . $page->ID . '&other=null</span></li>';
        }
        ?>
				</ul>
			</li>
			<?php 
    }
    $page_templates = get_page_templates();
    if (!empty($page_templates)) {
        ?>
			<li><a href="#">Page Templates <span>[+]</span></a>
				<ul>
				<?php 
        foreach ($page_templates as $name => $template) {
            echo '<li>' . $name . '<span>type=page_template&name=' . urlencode($name) . '&slug=' . $template . '&id=null&other=null</span></li>';
        }
        ?>
				</ul>
			</li>
			<?php 
    }
    $taxonomies = get_taxonomies();
    if (!empty($taxonomies)) {
        foreach ($taxonomies as $taxonomy) {
            if ('nav_menu' == $taxonomy or 'link_category' == $taxonomy) {
                continue;
            }
            $terms = get_terms($taxonomy);
            if (!empty($terms)) {
                ?>
			<li><a href="#"><?php 
                echo ucwords(str_replace('_', ' ', $taxonomy));
                ?>
 <span>[+]</span></a>
				<ul><?php 
                foreach ($terms as $term) {
                    echo '<li>' . $term->name . '<span>type=' . $taxonomy . '&name=' . urlencode($term->name) . '&slug=' . $term->slug . '&id=' . $term->term_id . '&other=' . $taxonomy . '</span></li>';
                }
                ?>
				</ul>
			</li>
				<?php 
            }
        }
    }
    ?>

			<li><a href="#">Template Hierarchy <span>[+]</span></a>
				<ul>
					<?php 
    $heirarchy = array('Front Page' => 'front_page', 'Home' => 'home', 'Posts (single.php)' => 'single', 'Pages' => 'page', 'Singular (posts and pages)' => 'singular', 'All Archives' => 'archive', 'Category Archive' => 'category', 'Tag Archive' => 'tag', 'Taxonomy Archive' => 'tax', 'Author Archive' => 'author', 'Date Archive' => 'date', 'Search Results' => 'search', 'Paged' => 'paged', 'Attachment' => 'attach', '404' => '404');
    foreach ($heirarchy as $name => $item) {
        echo '<li>' . $name . '<span>type=hierarchy&name=' . $name . '&slug=' . $item . '&id=null&other=null&other=null</span></li>';
    }
    ?>
				</ul>
			</li>
			<?php 
    /*------------------------------------------------------------*/
    /* Support for custom post types, if using WordPress 3.0+.
    			/*------------------------------------------------------------*/
    global $wp_version;
    if ($wp_version >= '3.0') {
        $_args = array('show_ui' => true, 'public' => true, 'publicly_queryable' => true, '_builtin' => false);
        $_post_types = get_post_types($_args, 'object');
        // Set certain post types that aren't allowed to have custom sidebars.
        $_disallowed_types = array('slide');
        // Make the array pluggable.
        $_disallowed_types = apply_filters('colabsframework_sbm_disallowed_posttypes', $_disallowed_types);
        if (count($_post_types)) {
            foreach ($_post_types as $k => $v) {
                if (in_array($k, $_disallowed_types)) {
                    unset($_post_types[$k]);
                }
                // End IF Statement
            }
            // End FOREACH Loop
        }
        // End IF Statement
        if (count($_post_types)) {
            ?>
				<li>
					<a href="#">Custom Post Type <span>[+]</span></a>
					<?php 
            $_html = '';
            $_html .= '<ul>' . "\n";
            foreach ($_post_types as $k => $v) {
                $_html .= '<li>' . $v->labels->name . '<span>type=custom_post_type&name=' . urlencode($v->labels->name) . '&slug=' . urlencode($k) . '&id=' . urlencode($k) . '&other=' . urlencode($k) . '</span></li>' . "\n";
            }
            // End FOREACH Loop
            $_html .= '</ul>' . "\n";
            echo $_html;
            ?>
				</li>
			<?php 
        }
        // End IF Statement
    }
    // End IF Statement
    ?>
			<?php 
    /*------------------------------------------------------------*/
    /* Support for post type archives, if using WordPress 3.1+.
    			/*------------------------------------------------------------*/
    $_archives = array();
    if (count($_post_types)) {
        foreach ($_post_types as $k => $p) {
            if ($p->has_archive) {
                $_archives[$k] = $p;
            }
        }
    }
    if (count($_archives)) {
        ?>
				<li>
					<a href="#">Post Type Archives <span>[+]</span></a>
					<?php 
        $_html = '';
        $_html .= '<ul>' . "\n";
        foreach ($_archives as $k => $v) {
            $_html .= '<li>' . $v->labels->name . '<span>type=post_type_archive&name=' . urlencode($v->labels->name) . '&slug=' . urlencode($k) . '&id=' . urlencode($k) . '&other=' . urlencode($k) . '</span></li>' . "\n";
        }
        // End FOREACH Loop
        $_html .= '</ul>' . "\n";
        echo $_html;
        ?>
				</li>
			<?php 
    }
    // End IF Statement
    ?>
			</ul><!-- #colabs-sbm-menu_ul -->
    
    	</div><!-- /#sidebar-nav -->
    
    	<div id="panel-content">
    
    			<span class="colabs-sbm-tip" id="colabs-sbm-tip-1"><?php 
    _e("Start by selecting a template from the menu on the left for your new sidebar. The new sidebar will be available on the ", "colabsthemes");
    ?>
<a href="<?php 
    echo admin_url('widgets.php');
    ?>
"><?php 
    _e("Widgets", "colabsthemes");
    ?>
</a> <?php 
    _e("page", "colabsthemes");
    ?>
.</span>
    
    		<div class="colabs-sbm-builder" style="display:none">
    
    			<form action="" id="colabs-sbm-get-links">
    				<?php 
    // Add nonce for added security.
    if (function_exists('wp_nonce_field')) {
        wp_nonce_field('colabsframework-sbm-options-update');
    }
    // End IF Statement
    ?>
    				<div id="colabs-sbm-get-links-inner">
    				<?php 
    //Sidebar Options panel get created here...
    ?>
    				<div id="colabs-sbm-response-builder">
    				<?php 
    //Template Info
    ?>
    
    				<div id="colabs-sbm-builder-meta">
    				    <div id="colabs-sbm-builder-meta-top"><?php 
    _e("Template Info", "colabsthemes");
    ?>
</div>
    				    <div id="colabs-sbm-builder-meta-bottom">
    				    	<label><span><?php 
    _e("Name", "colabsthemes");
    ?>
:</span></label><input type="hidden" name="name" id="template-info-name" value="">
    				    	<label><span><?php 
    _e("Type", "colabsthemes");
    ?>
:</span></label><input type="hidden" name="type" id="template-info-type" value="">
    				    	<label><span><?php 
    _e("Slug", "colabsthemes");
    ?>
:</span></label><input type="hidden" name="name" id="template-info-slug" value="">
    				    	<label><span><?php 
    _e("ID", "colabsthemes");
    ?>
:</span></label><input type="hidden" name="id" id="template-info-id" value="">
    				    	<label class="last"><span><?php 
    _e("URL", "colabsthemes");
    ?>
:</span> <small><a href=""></a></small></label><input type="hidden" name="other" id="template-info-other" value="">
    				    </div>
    				</div>
    				<div class="nav-tabs-nav">
    					<div class="nav-tabs-wrapper">
    						<div class="nav-tabs">
    							<a id="colabs-sbm-tab-new" href="#" class="nav-tab nav-tab-active"><?php 
    _e("Create a new Sidebar", "colabsthemes");
    ?>
</a>
    							<?php 
    if (!empty($colabs_sbm_options['sidebars'])) {
        ?>
    							<a id="colabs-sbm-tab-existing" class="nav-tab" href="#"><?php 
        _e("Use Existing Sidebar", "colabsthemes");
        ?>
</a>
    							<?php 
    }
    ?>
    							<a id="colabs-sbm-toggle-info" class="fr" href="#"><?php 
    _e("Template Info", "colabsthemes");
    ?>
<img src="<?php 
    get_template_directory_uri();
    ?>
/functions/images/ico-info.png" /></a>
    						</div>
    					</div>
    				</div>
    				<div class="builder-header">
    					<label id="colabs-sbm-label-sb-name"><span><?php 
    _e("Sidebar Name", "colabsthemes");
    ?>
</span> <input value="" type="text" name="sidebar-title" id="sidebar-title"/></label>
    				</div>
    
    				<div id="colabs-sbm-builder-body">
    				    <div id="colabs-sbm-builder-part-assign" class="colabs-sbm-builder-part-inner">
    				    	<label><span><?php 
    _e("Sidebar to use", "colabsthemes");
    ?>
</span></label>
    				    	<select name="sidebar_to_piggyback" id="sidebar_to_piggyback">
    				    	<?php 
    echo $new_sidebars;
    ?>
    				    	</select>
    				    </div>
    				    <div id="colabs-sbm-builder-part-create" class="colabs-sbm-builder-part-inner">
    				    	<label><span><?php 
    _e("Sidebar to replace", "colabsthemes");
    ?>
</span>
    				    	<select name="sidebar_to_replace" id="sidebar_to_replace">
    				    	<?php 
    echo $init_sidebars;
    ?>
    				    	</select></label>
    				    </div>
    
    				    	<label id="colabs-sbm-label-sb-desc"><span><?php 
    _e("Sidebar description", "colabsthemes");
    ?>
</span> <textarea id="sidebar-description" name="sidebar-description" style="width:230px"></textarea></label>
    				    	<input id="colabs-sbm-builder-conditional" type="hidden" name="conditional" value="'" />
    				    	<input id="colabs-sbm-builder-stage" type="hidden" name="stage" value="2" />
    				    	<input id="colabs-sbm-builder-piggy" type="hidden" name="piggy" value="0" />
    					</div>
    					<div class="colabs-sbm-controls">
    						<input type="submit" value="Add Sidebar" class="button" />
    					</div>
    				</div>
    			</div>
    		</form>

    		<div class="clear"></div>
    	</div><!-- /.colabs-sbm-builder -->
    
    	<div id="colabs-sbm-sidebars" class="js">
    
    			<h3><?php 
    _e("Custom Sidebars", "colabsthemes");
    ?>
 <span><?php 
    _e("Newly created sidebars", "colabsthemes");
    ?>
</span></h3>
    			<?php 
    //$colabs_sbm_options = get_option( 'sbm_colabs_sbm_options' );
    $top_array = array();
    if (!empty($colabs_sbm_options['sidebars'])) {
        ?>
    				<ul class="menu ui-sortable" id="menu-to-edit">
    				<?php 
        foreach ($colabs_sbm_options['sidebars'] as $sidebar) {
            $sidebar_name = $sidebar['setup']['name'];
            $id = $sidebar['conditionals']['id'];
            $sidebar_id = $sidebar['conditionals']['sidebar_id'];
            $sidebar_to_replace = $sidebar['conditionals']['sidebar_to_replace'];
            $sidebar_piggy = $sidebar['conditionals']['piggy'];
            if (empty($sidebar_piggy)) {
                $top_array[$sidebar_id] = array();
            }
            if (!empty($sidebar_piggy)) {
                $top_array[$sidebar_piggy][] = $sidebar_id;
            }
        }
        //print_r($top_array);
        foreach ($top_array as $top_id => $top_sidebar) {
            $sidebar_id = $top_id;
            $sidebar_name = $colabs_sbm_options['sidebars'][$sidebar_id]['setup']['name'];
            $sidebar_id = $colabs_sbm_options['sidebars'][$sidebar_id]['conditionals']['sidebar_id'];
            $sidebar_desc = $colabs_sbm_options['sidebars'][$sidebar_id]['setup']['description'];
            $sidebar_to_replace = $colabs_sbm_options['sidebars'][$sidebar_id]['conditionals']['sidebar_to_replace'];
            $sidebar_to_replace_nice = $wp_registered_sidebars[$sidebar_to_replace]['name'];
            ?>
    						<li class="menu-item menu-item-depth-0 menu-item-edit-inactive" id="<?php 
            echo $sidebar_id;
            ?>
">
    							<form>
    							<dl class="menu-item-bar">
    								<dt class="menu-item-handle">
    									<span class="item-title"><?php 
            echo $sidebar_name;
            ?>
</span>
    									<span class="item-controls">
    										<span class="item-type"><?php 
            echo $sidebar_to_replace_nice;
            ?>
</span>
    										<a class="item-edit" title="Edit" href="#"><?php 
            _e("Edit", "colabsthemes");
            ?>
</a>
    									</span>
    								</dt>
    							</dl>
    							<div class="menu-item-settings" style="display: none;">
    
    							<p class="description description-thin">
    								<label><?php 
            _e("Sidebar Name", "colabsthemes");
            ?>
<br />
    									<input type="text" class="widefat edit-menu-item-title" name="sidebar_name" value="<?php 
            echo $sidebar_name;
            ?>
">
    								</label>
    							</p>
    
    							<p class="description description-thin">
    								<label><?php 
            _e("Sidebar to replace", "colabsthemes");
            ?>
<br />
    									<select class="widefat sidebar-to-replace" name="sidebar_to_replace">
    										<?php 
            echo $init_sidebars;
            ?>
    									</select>
    								</label>
    							</p>
    
    							<p class="field-description description description-wide">
    								<label><?php 
            _e("Description", "colabsthemes");
            ?>
<br />
    									<textarea class="widefat" rows="3" cols="20" name="sidebar_description"><?php 
            echo $sidebar_desc;
            ?>
</textarea>
    								</label>
    							</p>
    							<input type="hidden" name="sidebar_id" value="<?php 
            echo $sidebar_id;
            ?>
" />
    							<div class="menu-item-actions description-wide submitbox">
    								<a class="item-delete submitdelete deletion" onclick="return confirm( 'Are you sure you want to delete this sidebar?' );" href="#"><?php 
            _e("Remove This & All Dependents", "colabsthemes");
            ?>
</a> <span class="meta-sep"> | </span> <a class="item-cancel submitcancel" href="#"><?php 
            _e("Cancel", "colabsthemes");
            ?>
</a> <span class="meta-sep"> | </span> <a class="item-save submitsave" href="#"><?php 
            _e("Save", "colabsthemes");
            ?>
</a>
    							</div>
    						</div>
    						<ul class="menu-item-transport"></ul>
    						<script type="text/javascript">
    							jQuery(document).ready(function(){
    								jQuery( '#<?php 
            echo $sidebar_id;
            ?>
').find( '.sidebar-to-replace option').each(function(){
    									if(jQuery(this).val() == '<?php 
            echo $sidebar_to_replace;
            ?>
'){
    										jQuery(this).attr( 'selected','selected' );
    									}
    								})
    							})
    						</script>
    					</form>
    				</li>
    
    					<?php 
            if (!empty($top_sidebar)) {
                foreach ($top_sidebar as $piggies) {
                    $sidebar_id = $piggies;
                    $sidebar_name = $colabs_sbm_options['sidebars'][$sidebar_id]['setup']['name'];
                    $sidebar_id = $colabs_sbm_options['sidebars'][$sidebar_id]['conditionals']['sidebar_id'];
                    ?>
    	     					<li class="menu-item menu-item-depth-1" id="<?php 
                    echo $sidebar_id;
                    ?>
">
    	     						<form>
    									<dl class="menu-item-bar">
    										<dt class="menu-item-handle">
    											<span class="item-title"><?php 
                    echo $sidebar_name;
                    ?>
</span>
    											<span class="item-controls">
    												<span class="item-type"></span>
    												<a class="item-edit" title="Edit" href="#"><?php 
                    _e("Edit", "colabsthemes");
                    ?>
</a>
    											</span>
    										</dt>
    									</dl>
    
    									<div class="menu-item-settings" style="display: none;">

    										<input type="hidden" name="sidebar_id" value="<?php 
                    echo $sidebar_id;
                    ?>
" />
    										<div class="menu-item-actions description-wide submitbox">
    											<a class="item-delete submitdelete deletion" onclick="return confirm( '<?php 
                    _e("Are you sure you want to delete this sidebar", "colabsthemes");
                    ?>
?' );" href="#"><?php 
                    _e("Delete", "colabsthemes");
                    ?>
</a> <span class="meta-sep"> | </span> <a class="item-cancel submitcancel" href="#"><?php 
                    _e("Cancel", "colabsthemes");
                    ?>
</a> <span class="meta-sep">
    										</div>
    									</div><!-- .menu-item-settings-->
    									<ul class="menu-item-transport"></ul>
    								</form>
    							</li>
    	     					<?php 
                }
            }
        }
        ?>
    		</ul>
    		<?php 
    } else {
        ?>
    		<h5><em><?php 
        _e("No sidebars added yet.", "colabsthemes");
        ?>
</em></h5>
    		<?php 
    }
    ?>
    		</div><!-- /#colabs-sbm-sidebars -->
    
    	</div><!-- /#panel-content -->

        <div id="panel-footer">
            <ul>
                <li class="docs"><a title="Theme Documentation" href="http://colorlabsproject.com/documentation/<?php 
    echo strtolower(str_replace(" ", "", $themename));
    ?>
" target="_blank" ><?php 
    _e("View Documentation", "colabsthemes");
    ?>
</a></li>
                <li class="forum"><a href="http://colorlabsproject.com/resolve/" target="_blank"><?php 
    _e("Submit a Support Ticket", "colabsthemes");
    ?>
</a></li>
                <li class="idea"><a href="http://ideas.colorlabsproject.com/" target="_blank"><?php 
    _e("Suggest a Feature", "colabsthemes");
    ?>
</a></li>
            </ul>
            
            <div class="save-bar save_bar_top right">
                <img style="display:none" src="<?php 
    echo get_template_directory_uri();
    ?>
/functions/images/ajax-loading.gif" class="ajax-loading-img ajax-loading-img-top" alt="Working..." />

            	 <form action="" method="post" style="display:inline" id="colabsform-reset">
                    <span class="submit-footer-reset">
                    <input name="reset" type="submit" value="Reset Sidebar Settings" class="button submit-button reset-button" onclick="return confirm( '<?php 
    _e("Click OK to reset. Any Sidebar Settings settings will be lost!", "colabsthemes");
    ?>
' );" />
                    <input type="hidden" name="colabs_save" value="sbm_reset" />
                    </span>
                </form>
            </div><!-- /.save-bar -->
            
        </div><!-- #panel-footer -->

    </div><!-- /.sbm-content -->
    
    <div class="clear"></div>
    </div><!-- /#colabsform -->
         
<div style="clear:both;"></div>
<pre style="display:none">
<?php 
    // print_r($colabs_sbm_options);
    ?>
</pre>
</div><!--wrap-->

<?php 
}
Example #12
0
function colabsthemes_layout_settings_page()
{
    $layout_options = get_option('colabs_layout_template');
    $themename = get_option('colabs_themename');
    $manualurl = get_option('colabs_manual');
    $shortname = 'colabs_layout';
    //Framework Version in Backend Head
    $colabs_framework_version = get_option('colabs_framework_version');
    //GET themes update RSS feed and do magic
    include_once ABSPATH . WPINC . '/feed.php';
    $pos = strpos($manualurl, 'documentation');
    $theme_slug = str_replace("/", "", substr($manualurl, $pos + 13));
    //13 for the word documentation
    //add filter to make the rss read cache clear every 4 hours
    add_filter('wp_feed_cache_transient_lifetime', create_function('$a', 'return 14400;'));
    ?>

  <div class="wrap colabs_container">
		<h2 class="colabs_admin_page_title"></h2>
    <form action="" enctype="multipart/form-data" id="colabsform" method="post">
      <?php 
    // Add nonce for added security.
    if (function_exists('wp_nonce_field')) {
        wp_nonce_field('colabsframework-layout-options-update');
    }
    // End IF Statement
    $colabs_nonce = '';
    if (function_exists('wp_create_nonce')) {
        $colabs_nonce = wp_create_nonce('colabsframework-layout-options-update');
    }
    // End IF Statement
    if ('' != $colabs_nonce) {
        ?>
        <input type="hidden" name="_ajax_nonce" value="<?php 
        echo $colabs_nonce;
        ?>
" />
      <?php 
    }
    ?>
           
      <?php 
    $return = colabsthemes_machine($layout_options);
    ?>
      <div id="main">
        <div id="panel-header">
            <?php 
    colabsthemes_options_page_header('reset_button=false');
    ?>
        </div><!-- #panel-header -->
        
        <div id="sidebar-nav">
            <ul>
                <?php 
    echo $return[1];
    ?>
            </ul>
        </div>
        <div id="panel-content">
            <div class="group help-block"> <p><?php 
    _e("Drag icon on the left and Drop it here to customize", "colabsthemes");
    ?>
</p> </div>
            <?php 
    echo $return[0];
    ?>
            <div class="clear"></div>
        </div>
                
        <div id="panel-footer">
            <ul>
                <li class="docs"><a title="Theme Documentation" href="http://colorlabsproject.com/documentation/<?php 
    echo strtolower(str_replace(" ", "", $themename));
    ?>
" target="_blank" ><?php 
    _e("View Documentation", "colabsthemes");
    ?>
</a></li>
                <li class="forum"><a href="http://colorlabsproject.com/resolve/" target="_blank"><?php 
    _e("Submit a Support Ticket", "colabsthemes");
    ?>
</a></li>
                <li class="idea"><a href="http://ideas.colorlabsproject.com/" target="_blank"><?php 
    _e("Suggest a Feature", "colabsthemes");
    ?>
</a></li>
            </ul>
            
            <div class="save-bar save_bar_top right">
                <img style="display:none" src="<?php 
    echo get_template_directory_uri();
    ?>
/functions/images/ajax-loading.gif" class="ajax-loading-img ajax-loading-img-top" alt="Working..." />
                <input type="submit" value="Save Changes" class="button submit-button button-primary" />
                
    </form>
    <form action="<?php 
    echo esc_attr($_SERVER['REQUEST_URI']);
    ?>
" method="post" style="display:inline" id="colabsform-reset">
                <?php 
    // Add nonce for added security.
    if (function_exists('wp_nonce_field')) {
        wp_nonce_field('colabsframework-layout-options-reset');
    }
    // End IF Statement
    $colabs_nonce = '';
    if (function_exists('wp_create_nonce')) {
        $colabs_nonce = wp_create_nonce('colabsframework-layout-options-reset');
    }
    // End IF Statement
    if ('' == $colabs_nonce) {
    } else {
        ?>
                    <input type="hidden" name="_ajax_nonce" value="<?php 
        echo $colabs_nonce;
        ?>
" />
                <?php 
    }
    // End IF Statement
    ?>
                    <input name="reset" type="submit" value="Reset Options" class="button submit-button reset-button button-highlighted" onclick="return confirm( '<?php 
    _e("Click OK to reset all options. All settings will be lost!", "colabsthemes");
    ?>
' );" />
                    <input type="hidden" name="colabs_save" value="reset" /> 
    </form>
            </div>
        </div><!-- #panel-footer -->

			</div><!-- #main -->

    <div style="clear:both;"></div>
  </div><!--wrap-->
<?php 
}