function weaverx_fwrite_current_css()
{
    // write the current generated CSS to a file - called only from Weaver II Admin
    if (!weaverx_f_file_access_available() || !current_user_can('edit_theme_options')) {
        return '';
    }
    $save_dir = weaverx_f_uploads_base_dir() . 'weaverx-subthemes';
    $save_url = weaverx_f_uploads_base_url() . 'weaverx-subthemes';
    $usename = 'style-weaverxt.css';
    $theme_dir_exists = weaverx_f_mkdir($save_dir);
    if (!$theme_dir_exists) {
        weaverx_f_file_access_fail(__('Unable to create directory. Probably a file system permission problem. Directory', 'weaver-xtreme') . $save_dir);
    }
    $theme_dir_writable = $theme_dir_exists;
    if (!weaverx_f_is_writable($save_dir)) {
        weaverx_f_file_access_fail(__('Directory not writable. Probably a file system permission problem. Directory: ', 'weaver-xtreme') . $save_dir);
        $theme_dir_writable = false;
    }
    $filename = $save_dir . '/' . $usename;
    // we will add txt
    if (!$theme_dir_writable || !$theme_dir_exists || !($handle = weaverx_f_open($filename, 'w'))) {
        weaverx_f_file_access_fail(__('Unable to create file. Probably a file system permission problem. File: ', 'weaver-xtreme') . $filename);
        return '';
    }
    // This string goes in the generated CSS file
    weaverx_f_write($handle, sprintf("/* WARNING: Do not edit this file. It is dynamically generated. Any edits you make will be overwritten. */\n/* This file generated using %s %s subtheme: %s */\n", WEAVERX_THEMENAME, WEAVERX_VERSION, weaverx_getopt('wii_subtheme')));
    weaverx_output_style($handle);
    if (!weaverx_f_close($handle)) {
        weaverx_f_file_access_fail(__('Unable to create file. Probably a file system permission problem. File: ', 'weaver-xtreme') . $filename);
        return '';
    }
    return $save_url . '/' . $usename;
}
 public static function reset_options($contents)
 {
     if (substr($contents, 0, 10) == 'WXT-V01.00') {
         $type = 'theme';
     } else {
         if (substr($contents, 0, 10) == 'WXB-V01.00') {
             $type = 'backup';
         } else {
             $val = substr($contents, 0, 10);
             self::$wvrx_error = __("Wrong theme file format version", 'weaver-xtreme') . ':' . $val;
             return false;
             /* simple check for one of ours */
         }
     }
     $restore = array();
     $restore = unserialize(substr($contents, 10));
     if (!$restore) {
         self::$wvrx_error = __("Unserialize failed", 'weaver-xtreme');
         return false;
     }
     $version = weaverx_getopt('weaverx_version_id');
     // get something to force load
     $new_cache = array();
     global $weaverx_opts_cache;
     if ($type == 'theme') {
         // need to clear some settings
         // first, pickup the per-site settings that aren't theme related...
         foreach ($weaverx_opts_cache as $key => $val) {
             if (isset($key[0]) && $key[0] == '_') {
                 // these are non-theme specific settings
                 $new_cache[$key] = $val;
             }
             // keep
         }
         $opts = $restore['weaverx_base'];
         // fetch base opts
         foreach ($opts as $key => $val) {
             if (isset($key[0]) && $key[0] != '_') {
                 $new_cache[$key] = $val;
             }
             // and add rest from restore
         }
     } else {
         if ($type == 'backup') {
             $opts = $restore['weaverx_base'];
             // fetch base opts
             foreach ($opts as $key => $val) {
                 $new_cache[$key] = $val;
                 // overwrite with saved values
             }
         }
     }
     $new_cache['weaverx_version_id'] = $version;
     $new_cache['wvrx_css_saved'] = '';
     $new_cache['last_option'] = 'Weaver Xtreme';
     $new_cache['style_date'] = date('Y-m-d-H:i:s');
     delete_option('weaverx_settings');
     update_option('weaverx_settings', $new_cache);
     $save_dir = weaverx_f_uploads_base_dir() . 'weaverx-subthemes';
     $usename = 'style-weaverxt.css';
     $filename = $save_dir . '/' . $usename;
     @unlink($filename);
     $weaverx_opts_cache = $new_cache;
     if (weaverx_f_file_access_available()) {
         // and now is the time to update the style file
         require_once get_template_directory() . '/includes/generatecss.php';
         weaverx_fwrite_current_css();
     }
     return true;
 }
function weaverx_adv_site_opts()
{
    ?>
	<div class="atw-option-header"><span style="color:black; padding:.2em;" class="dashicons dashicons-admin-generic"></span>
	<?php 
    _e('Site Options', 'weaver-xtreme');
    ?>
	<?php 
    weaverx_help_link('help.html#AdvSiteOptions', __('Help on Advanced Site Options', 'weaver-xtreme'));
    ?>
</div><br />
<?php 
    _e('These options are available to fine tune various aspects of your site.
Technically, these features	are not part of the theme styling, but cover other aspects of site functionality.', 'weaver-xtreme');
    ?>
<br />
<hr />
   <!-- ======== -->
   <?php 
    if (weaverx_f_file_access_available()) {
        ?>
   <h3><?php 
        _e('Inline CSS - (Xtreme-Plus Option)', 'weaver-xtreme');
        ?>
</h3>

	<label><input type="checkbox" name="<?php 
        weaverx_sapi_main_name('_inline_style');
        ?>
" id="_inline_style" <?php 
        checked(weaverx_getopt_checked('_inline_style'));
        ?>
 />
<?php 
        _e('Generate inline CSS code rather than using style-weaverxt.css file.
By default, Weaver Xtreme Plus will use the style-weaverxt.css file. &diams;', 'weaver-xtreme');
        ?>
	</label><br /><br />
<?php 
    }
    ?>

<h3><?php 
    _e('Include Widget Areas in Print', 'weaver-xtreme');
    ?>
</h3>

	<label><input type="checkbox" name="<?php 
    weaverx_sapi_main_name('_print_show_widgets');
    ?>
" id="_inline_style" <?php 
    checked(weaverx_getopt_checked('_print_show_widgets'));
    ?>
 />
<?php 
    _e('Include all widget areas and full Footer content on browser Print page operation. &diams;', 'weaver-xtreme');
    ?>
	</label><br /><br />

	<br />
	<div class="atw-option-subheader"><span style="color:black; padding:.2em;" class="dashicons dashicons-format-image"></span><span style="color:blue;font-size:larger;">
	<b><?php 
    _e('FavIcon', 'weaver-xtreme');
    ?>
</b></span></div></br />
<p>
<?php 
    _e('You can add a FavIcon to your site with this option.
The preferred FavIcon is in the <code>.ico</code> format which has the most universal browser compatibility.
However, <code>.png, .gif, and .jpg</code> will	work for most modern browsers.
The standard sizes are 16x16, 32x32, or 48x48 px.
You can alternatively load a <code>favicon.ico</code> file to the root directory of your site. &diams;', 'weaver-xtreme');
    ?>
</p>
<p>
<?php 
    $icon = weaverx_getopt('_favicon_url');
    if ($icon != '') {
        echo '<img src="' . esc_url($icon) . '" alt="favicon" />&nbsp;';
    }
    ?>
	<strong><?php 
    _e('FavIcon URL:', 'weaver-xtreme');
    ?>
 </strong>
	<?php 
    weaverx_textarea(weaverx_getopt('_favicon_url'), '_favicon_url', 1, 'URL ', $style = 'width:350px;');
    ?>
	<?php 
    weaverx_media_lib_button('_favicon_url');
    ?>
&nbsp;&nbsp;<?php 
    _e('Full path to FavIcon', 'weaver-xtreme');
    ?>
</p><br />

	<div class="atw-option-subheader"><span style="color:black; padding:.2em;" class="dashicons dashicons-admin-page"></span><span style="color:blue;font-size:larger;">
	<b><?php 
    _e('Exclude Pages from SiteMap', 'weaver-xtreme');
    ?>
</b></span></div></br />
<p>
<?php 
    _e('You can specify a comma separated list of Page IDs to be excluded from the SiteMap Page list.
To exclude pages from Search results, use a plugin such as "Search Exclude".
You can hide different sections of the SiteMap by adding rules to the "Custom CSS Rules" box.
To hide authors, for example, add the rule <code>#sitemap-authors{display:none;}</code>.
The IDs for the SiteMap sections are: <code>#sitemap-pages, #sitemap-posts, #sitemap-categories, #sitemap-tags, #sitemap-authors</code>', 'weaver-xtreme');
    ?>
</p>
<p>
<?php 
    $exclude = weaverx_getopt('_sitemap_exclude_pages');
    ?>
	<strong><?php 
    _e('Exclude Pages from SiteMap', 'weaver-xtreme');
    ?>
: </strong>
	<?php 
    weaverx_textarea(weaverx_getopt('_sitemap_exclude_pages'), '_sitemap_exclude_pages', 1, '1,2,3', $style = 'width:350px;');
    ?>
</p><br />




	<div class="atw-option-subheader"><span style="color:black; padding:.2em;" class="dashicons dashicons-hammer"></span>
		<span style="color:blue;font-size:larger;">
		<b><?php 
    _e('SEO - Search Engine Optimization', 'weaver-xtreme');
    ?>
</b>
		</span></div><br />
<p>
<?php 
    _e('The Weaver Xtreme Theme has been designed to follow the latest SEO guidelines.
Each non-home page will use the recommended "Page Title | Site Title" format, and the site is formatted using the appropriate HTML5 tags for optimal SEO performance.
An SEO plugin may help you optimize your site for SEO, but is not required.
See the <em>Help</em> tab for recommended SEO plugins.', 'weaver-xtreme');
    ?>
</p><br />

	<div class="atw-option-subheader"><span style="color:black; padding:.2em;" class="dashicons dashicons-admin-home"></span>
		<span style="color:blue;font-size:larger;">
			<b><?php 
    _e('Home Page', 'weaver-xtreme');
    ?>
</b>
		</span></div>
<p>
<?php 
    _e('WordPress allows you to specify what page is used for your home page - either the standard WordPress blog, or a static page (which can be a Weaver Xtreme "Page with Posts" page).
Please see the Weaver Xtreme Help topic for a more complete explanation.', 'weaver-xtreme');
    ?>
</p>
<p>
<?php 
    _e('You can set the front page on the Dashboard <em>Settings&rarr;Reading panel</em>:', 'weaver-xtreme');
    ?>
<a href="<?php 
    echo esc_url(home_url('/') . 'wp-admin/options-reading.php');
    ?>
">
<strong><?php 
    _e('Set Front Page Displays', 'weaver-xtreme');
    ?>
</strong></a></p><br />

	<div class="atw-option-subheader"><span style="color:black; padding:.2em;" class="dashicons dashicons-admin-users"></span>
		<span style="color:blue;font-size:larger;">
			<b><?php 
    _e('Author Avatars', 'weaver-xtreme');
    ?>
</b>
		</span></div>
<p>
<?php 
    _e('For the best look, your site should support Avatars - a small image associated with a contributors e-mail address.
Gravatar.com is probably the most popular Avatar support, and is closely associated with WordPress.
You should set up a Gravatar for the main authors of your blog.
For contributors without any avatar, WordPress will automatically generate an avatar.
See the <strong>Settings &rarr; Discussion</strong> admin page for avatar settings.', 'weaver-xtreme');
    ?>
</p>
	<hr />
<?php 
    do_action('weaverxplus_admin', 'site_opts');
    do_action('weaverx_child_siteoptions');
}
function weaverx_use_inline_css($css_file)
{
    return weaverx_getopt_checked('_inline_style') || !weaverx_f_file_access_available() || !weaverx_f_exists($css_file) || isset($_REQUEST['wp_customize']);
    // also force inline from customizer
}