/**
     * 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_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_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">
  
  <?php 
        $free_themes = array('lensa', 'photogram', 'leatherly', 'tumblepress', 'rpg.cod', 'wellblog');
        if (in_array(strtolower($themename), $free_themes)) {
            ?>
    <div class="colabs_twitter_stream">

        <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
        ?>

    <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 
        // 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-->

  <?php 
        if (!empty($update_message)) {
            echo $update_message;
        }
        ?>
    
  <div style="clear:both;"></div>    
</div><!--wrap-->
<?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="<?php 
        if (is_rtl()) {
            echo 'rtl';
        }
        ?>
 colabs_customizer">

	<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 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" >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_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">
        <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) {
    } 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($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 
}
    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';
        }
        ?>
">
<?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 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"><?php 
            _e('File Updated', 'colabsthemes');
            ?>
</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 
            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" 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');
            ?>
">
            <div class="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 left" alt="Working..." />
                <?php 
            wp_nonce_field('colabs-custom-file', '_wpnonce-colabs-custom-file');
            ?>
                <input type="submit" value="Save All Changes" class="button submit-button button-primary" name="custom_file_submit"/>
            </div>        
            <input type="hidden" id="file" name="file" value="<?php 
            echo $file;
            ?>
" />
            <p><textarea id="newcontent" name="newcontent" rows="25" cols="50" class="large-text"><?php 
            echo $content;
            ?>
</textarea></p>
            <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 -->

    </div><!--/.colabs_container -->
    
<?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 
    }