function weaverx_sapi_form_bottom($form_name = 'end of form') { // customizer only, keep values, preserve values, save values, not legacy (search terms for these kinds of settings) $non_sapi = array('weaverx_version_id', 'style_version', 'theme_filename', 'addon_name', '_hide_theme_thumbs', 'last_option', 'font_set_vietnamese', 'font_set_cryllic', 'font_set_greek', 'font_set_hebrew', 'font_word_spacing_global_dec', 'font_letter_spacing_global_dec'); /* The following code allows the SAPI to save the non-sapi values. If you don't do this here, then the values will be set to false, and be lost! SAPI is not tolerant of submitting a form that doesn't include EVERY setting for the form group. */ foreach ($non_sapi as $name) { ?> <input name="<?php weaverx_sapi_main_name($name); ?> " id="<?php echo $name; ?> " type="hidden" value="<?php echo weaverx_getopt($name); ?> " /> <?php } weaverx_setopt('last_option', 'Weaver Xtreme'); // Safety check for limited PHP $_POST variables echo "</form> <!-- {$form_name} -->\n"; }
public static function reset_options($contents, $ext) { if ($ext == 'wxall') { $version = weaverx_getopt('weaverx_version_id'); // get something to force load opts_cache weaverx_delete_all_options(); $restore = array(); $restore = unserialize($contents); $opts = $restore['weaverx']; // fetch base opts //if (isset($opts['fonts_added']) ) { // $opts['fonts_added'] = serialize($opts['fonts_added']); //} foreach ($opts as $key => $val) { weaverx_setopt($key, $val, false); // overwrite with saved values } weaverx_setopt('weaverx_version_id', $version); // keep version, force save of db weaverx_setopt('wvrx_css_saved', ''); weaverx_setopt('last_option', 'Weaver Xtreme'); weaverxplus_clear_opts(); $opts = $restore['weaverxplus']; // fetch plus opts foreach ($opts as $key => $val) { weaverxplus_setopt($key, $val, false); // overwrite with saved values } weaverxplus_update_opts(); weaverx_save_opts('xplus', true); } else { 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_ex_set_current_to_serialized_values($contents) { global $weaverx_opts_cache; // need to mess with the cache 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); return weaverx_f_fail(__("Wrong theme file format version", 'weaver-xtreme') . ':' . $val); /* simple check for one of ours */ } } $restore = array(); $restore = unserialize(substr($contents, 10)); if (!$restore) { return weaverx_f_fail(__("Unserialize failed", 'weaver-xtreme')); } $version = weaverx_getopt('weaverx_version_id'); // get something to force load if ($type == 'theme') { // need to clear some settings // first, pickup the per-site settings that aren't theme related... $new_cache = array(); 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 weaverx_delete_all_options(); foreach ($opts as $key => $val) { if (isset($key[0]) && $key[0] != '_') { weaverx_setopt($key, $val, false); } // overwrite with saved theme values } foreach ($new_cache as $key => $val) { // set the values we need to keep weaverx_setopt($key, $val, false); } } else { if ($type == 'backup') { weaverx_delete_all_options(); $opts = $restore['weaverx_base']; // fetch base opts foreach ($opts as $key => $val) { weaverx_setopt($key, $val, false); // overwrite with saved values } } } weaverx_setopt('weaverx_version_id', $version); // keep version, force save of db weaverx_setopt('wvrx_css_saved', ''); weaverx_setopt('last_option', 'Weaver Xtreme'); weaverx_save_opts('loading theme'); // OK, now we've saved the options, update them in the DB return true; }
function weaverx_admin_page_process_options() { /* Process all options - called upon entry to options forms */ // Most options are handled by the SAPI filter. settings_errors('weaverx_settings'); // display results from SAPI save settings $processed = false; if (function_exists('wvrx_ts_installed')) { $processed = weaverx_process_options_themes(); // >>>> Weaver Xtreme Themes Tab } do_action('weaverx_child_process_options'); // let the child theme do something do_action('weaverxplus_admin', 'process_options'); do_action('weaverx_process_license_options'); /* this tab has the most individual forms and submit commands */ /* ====================================================== */ if (!$processed && isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true') { add_settings_error('weaverx_settings', 'settings_updated', __('Saved', 'weaver-xtreme'), 'updated'); $vers = weaverx_getopt('style_version'); weaverx_setopt('style_version', $vers + 1); } weaverx_save_opts('Weaver Xtreme Admin'); /* FINALLY - SAVE ALL OPTIONS AND UPDATE CURRENT CSS FILE */ }
function weaverx_save_opts($who = '', $bump = true) { // Save options // Here's the strategy. Using weaverx_getopt always loads the cache if it hasn't been. // Using weaverx_setopt will save the cache to the database by default // So we take advantage of this by bumping the style version, and using weaverx_setopt, // which saves to the database //$vers = weaverx_getopt('style_version'); if ($who == 'customizer') { // really need to refresh the cache weaverx_clear_opt_cache($who); $old = weaverx_getopt('style_date'); // and reload the cache } if ($bump) { //$vers = $vers ? $vers + 1 : 1; // bump or init // put the CSS into the DB require_once get_template_directory() . '/includes/generatecss.php'; unset($GLOBALS['wvrx_css_saved']); $GLOBALS['wvrx_css_saved'] = ''; weaverx_f_write('wvrx_css_saved', '/* -wvrx_css- */'); weaverx_output_style('wvrx_css_saved'); weaverx_setopt('wvrx_css_saved', $GLOBALS['wvrx_css_saved']); unset($GLOBALS['wvrx_css_saved']); } weaverx_setopt('style_date', date('Y-m-d-H:i:s'), $bump); //weaverx_setopt('style_version',$vers, $bump); // update options, style version 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(); } }