get_contents( $import_file );
$settings = json_decode( $file_contants, 1 );
// Astra addons activation.
if ( class_exists( 'Astra_Admin_Helper' ) ) {
Astra_Admin_Helper::update_admin_settings_option( '_astra_ext_enabled_extensions', $settings['astra-addons'] );
}
// Delete existing dynamic CSS cache.
delete_option( 'astra-settings' );
update_option( 'astra-settings', $settings['customizer-settings'] );
wp_safe_redirect(
wp_nonce_url(
add_query_arg(
array(
'page' => 'astra',
'status' => 'imported',
),
admin_url( 'themes.php' )
),
'astra-import-complete'
)
);
exit;
}
/**
* Export our chosen options.
*
* @since 1.0.0
*/
public static function export() {
if ( ! isset( $_POST['astra_export_nonce'] ) || ! wp_verify_nonce( $_POST['astra_export_nonce'], 'astra_export_nonce' ) ) {
return;
}
if ( empty( $_POST['astra_ie_action'] ) || 'export_settings' !== $_POST['astra_ie_action'] ) {
return;
}
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
// Get options from the Customizer API.
$theme_options['customizer-settings'] = Astra_Theme_Options::get_options();
// Add Astra Addons to import.
if ( class_exists( 'Astra_Ext_Extension' ) ) {
$theme_options['astra-addons'] = Astra_Ext_Extension::get_enabled_addons();
}
$theme_options = apply_filters( 'astra_export_data', $theme_options );
nocache_headers();
header( 'Content-Type: application/json; charset=utf-8' );
header( 'Content-Disposition: attachment; filename=astra-settings-export-' . date( 'm-d-Y' ) . '.json' );
header( 'Expires: 0' );
echo wp_json_encode( $theme_options );
// Start the download.
die();
}
}
}
/**
* Kicking this off by calling 'get_instance()' method
*/
Astra_Import_Export_Loader::get_instance();