Save all current core Absolute Weaver Theme settings to file on your computer. ( Full settings backup, including those marked with ♦. Does NOT include Absolute Weaver Plus settings. ) File:', 'absolute-weaver' ),
__( 'Save ALL Absolute Weaver Settings', 'absolute-weaver' ),
__( 'Save only theme related current settings to file on your computer. File: ', 'absolute-weaver' ),
)
*
*/
class AWeaver_Save_WV_Settings extends WP_Customize_Control {
public $description = '';
public $code;
public function render_content() {
$a_pro = ( aweaver_cz_is_plus() ) ? '-plus' : '';
echo '' . esc_html( $this->label ) . '';
if ( '' !== $this->description ) {
echo '' . aweaver_sanitize_markup( $this->description ) . '';
}
echo '';
echo '
';
echo aweaver_sanitize_markup( __( 'Save all current core Absolute Weaver Theme settings to file on your computer. ( Full settings backup, including those marked with ♦. Does NOT include Absolute Weaver Plus settings. ) File:', 'absolute-weaver' ) ); ?>
aweaver-backup-settings.wxb
Save only theme related current settings to file on your computer. File: ', 'absolute-weaver' ) ); ?>
weaverx-theme-settings.wxt
';
echo aweaver_sanitize_markup( __( 'Note: The previous download settings will include Absolute Weaver Plus settings values ( if Absolute Weaver Plus is installed ) along with the free version settings.
The previous Save buttons do not include advanced Absolute Weaver Plus options like shortcodes or SmartMenu settings.', 'absolute-weaver' ) )
. '
';
echo '
';
echo aweaver_sanitize_markup( __( 'Save ALL Settings - Basic Absolute Weaver, including ♦, ☆, and ★.', 'absolute-weaver' ) ); ?>
File: aweaver-settings-( timestamp ).wxall
";
esc_html_e( 'Save Settings to Site Host Filesystem', 'absolute-weaver' );
echo '
';
echo aweaver_sanitize_markup( __( "You can also save and restore your settings to the Site's Host filesystem. Open the Appearance:Absolute Weaver Admin:Save/Restore tab to see the options to Save/Restore settings to the host filesystem. ( requires free Weaver Theme Support Plugin )", 'absolute-weaver' ) );
}
*/
echo '
';
}
static public function process_save( $wp_customize ) {
if ( current_user_can( 'edit_theme_options' ) ) {
if ( isset( $_REQUEST['wvrx_save'] ) ) {
if ( wp_verify_nonce( $_REQUEST['wvrx_save'], 'wvrx-settings-saving' ) ) // use the wp_verify_nonce to validate the $_REQUEST value
{
self::_save_settings( $wp_customize, 'wxt' );
}
} elseif ( isset( $_REQUEST['wvrx_save_all'] ) ) {
if ( wp_verify_nonce( $_REQUEST['wvrx_save_all'], 'wvrx-settings-saving' ) ) // use the wp_verify_nonce to validate the $_REQUEST value
{
self::_save_settings( $wp_customize, 'wxb' );
}
} elseif ( isset( $_REQUEST['wvrx_save_xplus'] ) ) {
if ( wp_verify_nonce( $_REQUEST['wvrx_save_xplus'], 'wvrx-settings-saving' ) ) // use the wp_verify_nonce to validate the $_REQUEST value
{
self::_save_settings( $wp_customize, 'wxall' );
}
}
}
}
static private function _aweaver_filter_strip_default( $var ) {
if ( ! is_string( $var ) ) {
return true;
}
return strlen( $var ) && $var != 'default';
}
static private function _save_settings( $wp_customize, $ext ) {
// Note: a $_REQUEST based nonce has been verified before this function called
if ( headers_sent() ) {
header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
wp_die( esc_html__( 'Headers Sent: The headers have been sent by another plugin - there may be a plugin conflict.', 'absolute-weaver' ) );
}
if ( $ext == 'wxall' ) {
$time = date( 'Y-m-d-Hi' );
$fn = 'weaverx-settings-' . $time . '.wxall';
$opt_func = AWEAVER_GET_OPTION;
$aweaver_opts = $opt_func( apply_filters( 'aweaver_options', AWEAVER_SETTINGS_NAME ), array() );
$aweaverplus_opts = $opt_func( 'aweaverplus_settings', array() );
$aweaver_opts = array_filter( $aweaver_opts, 'self::_aweaver_filter_strip_default' );
$aweaverplus_opts = array_filter( $aweaverplus_opts, 'self::_aweaver_filter_strip_default' );
$save = array();
$save['header'] = 'WVRX-PLUS1'; // format
$save['ext'] = $ext; // the extension
$save['aweaver'] = $aweaver_opts;
$save['aweaverplus'] = $aweaverplus_opts;
$aweaver_settings = $save;
} else { // free version save
$base = 'aweaver-settings';
$a_pro = ( function_exists( 'aweaverplus_plugin_installed' ) ) ? '-plus' : '';
$opt_func = AWEAVER_GET_OPTION;
$aweaver_opts = $opt_func( apply_filters( 'aweaver_options', AWEAVER_SETTINGS_NAME ), array() );
$aweaver_header = '';
$aweaver_save = array();
$aweaver_opts = array_filter( $aweaver_opts, 'self::_aweaver_filter_strip_default' );
unset( $aweaver_opts['wvrx_css_saved'] );
$aweaver_save['weaverx_base'] = $aweaver_opts;
$a_pro = ( function_exists( 'aweaverplus_plugin_installed' ) ) ? '-plus' : '';
if ( $ext == 'wxt' ) {
$aweaver_header .= 'WVA-V01.00';
$fn = 'aweaver-theme-settings' . $a_pro . '.wxt';
foreach ( $aweaver_opts as $opt => $val ) {
if ( $opt[0] == '_' ) {
$aweaver_save['weaverx_base'][ $opt ] = false;
}
}
} else {
$aweaver_header .= 'WVB-V01.00'; /* Save all settings: 10 byte header */
$fn = 'aweaver-backup-settings' . $a_pro . '.wxb';
}
$aweaver_settings = $aweaver_header . serialize( $aweaver_save ); /* serialize full set of options right now */
}
// Set the download headers.
header( 'Content-disposition: attachment; filename=' . $fn );
header( 'Content-Type: application/octet-stream; charset=utf-8' );
// echo the export data.
echo $aweaver_settings;
// Start the download.
die();
}
static public function enqueue_scripts() {
// scripts loaded by AWeaver_Load_WA_Subtheme
}
}
}
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'AWeaver_Restore_WV_Settings' ) ) {
class AWeaver_Restore_WV_Settings extends WP_Customize_Control {
public $description = '';
public $code;
static private $wvrx_error = '';
/**
*/
public function render_content() {
echo '' . esc_html( $this->label ) . '';
if ( '' !== $this->description ) {
echo '' . aweaver_sanitize_markup( $this->description ) . '';
}
?>
';
return;
}
if ( ! aweaver_f_exists( $openname ) ) {
self::$wvrx_error = esc_html__( 'Sorry, there was a problem uploading your file. You may need to check your folder permissions or other server settings.', 'absolute-weaver' ) . esc_html__( 'Trying to use file', 'absolute-weaver' ) . $openname;
aweaver_alert( self::$wvrx_error );
return;
}
// Get the upload data.
$contents = aweaver_f_get_contents( $openname );
// Remove the uploaded file.
unlink( $openname );
unset( $FILES );
if ( ! self::reset_options( $contents, $ext_check ) ) {
return;
}
// we will now redirect to the customizer so all settings are reloaded
wp_redirect( home_url( '/wp-admin/customize.php?return=%2Fwp-admin%2Fthemes.php%3Fpage%3DWeaverX' ) );
}
static public function reset_options( $contents, $ext ) {
if ( $ext == 'wxall' ) {
$version = aweaver_getopt( 'aweaver_version_id' ); // get something to force load opts_cache
aweaver_delete_all_options();
$restore = array();
$restore = unserialize( $contents );
$opts = $restore['aweaver']; // fetch base opts
//if ( isset( $opts['fonts_added'] ) ) {
// $opts['fonts_added'] = serialize( $opts['fonts_added'] );
//}
foreach ( $opts as $key => $val ) {
aweaver_setopt( $key, $val, false ); // overwrite with saved values
}
aweaver_setopt( 'aweaver_version_id', $version ); // keep version, force save of db
aweaver_setopt( 'wvrx_css_saved', '' );
aweaver_setopt( 'last_option', AWEAVER_THEMENAME );
aweaverplus_clear_opts();
$opts = $restore['aweaverplus']; // fetch plus opts
foreach ( $opts as $key => $val ) {
aweaverplus_setopt( $key, $val, false ); // overwrite with saved values
}
aweaverplus_update_opts();
aweaver_save_opts( 'xplus', true );
} else {
if ( substr( $contents, 0, 10 ) == 'WXT-V01.00' || substr( $contents, 0, 10 ) != 'WVA-V01.00' ) {
$type = 'theme';
} elseif ( substr( $contents, 0, 10 ) == 'WXB-V01.00' || substr( $contents, 0, 10 ) != 'WVB-V01.00' ) {
$type = 'backup';
} else {
$val = substr( $contents, 0, 10 );
self::$wvrx_error = esc_html__( "Wrong theme file format version", 'absolute-weaver' ) . ':' . $val;
aweaver_alert( self::$wvrx_error );
return false; /* simple check for one of ours */
}
$restore = array();
$restore = unserialize( substr( $contents, 10 ) );
if ( ! $restore ) {
print_r( $contents );
self::$wvrx_error = esc_html__( "Unserialize failed", 'absolute-weaver' );
aweaver_alert( self::$wvrx_error );
return false;
}
$version = aweaver_getopt( 'aweaver_version_id' ); // get something to force load
$new_cache = array();
global $aweaver_opts_cache;
if ( $type == 'theme' ) {
// need to clear some settings
// first, pickup the per-site settings that aren't theme related...
foreach ( $aweaver_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
}
} elseif ( $type == 'backup' ) {
$opts = $restore['weaverx_base']; // fetch base opts
foreach ( $opts as $key => $val ) {
$new_cache[ $key ] = $val; // overwrite with saved values
}
}
$new_cache['aweaver_version_id'] = $version;
$new_cache['wvrx_css_saved'] = '';
$new_cache['last_option'] = AWEAVER_THEMENAME;
$new_cache['style_date'] = date( 'Y-m-d-H:i:s' );
$opt_func = AWEAVER_DELETE_OPTION;
$opt_func( AWEAVER_SETTINGS_NAME );
$opt_func = AWEAVER_UPDATE_OPTION;
$opt_func( AWEAVER_SETTINGS_NAME, $new_cache );
$aweaver_opts_cache = $new_cache;
aweaver_fwrite_current_css( true );
do_action( 'aweaver_save_mcecss' ); // theme support plugin saved editor css in file
do_action( 'aweaver_save_gutenberg_css' );
}
return true;
}
static public function enqueue_scripts() {
// scripts loaded by AWeaver_Load_WA_Subtheme
return;
}
static public function controls_print_scripts() {
if ( self::$wvrx_error ) {
echo '';
}
}
}
}