Customizer Export/Import - Version 0.7

Version Description

Download this release

Release Info

Developer pross
Plugin Icon 128x128 Customizer Export/Import
Version 0.7
Comparing to
See all releases

Code changes from version 0.6 to 0.7

classes/class-cei-core.php CHANGED
@@ -156,56 +156,60 @@ final class CEI_Core {
156
  'mods' => $mods ? $mods : array(),
157
  'options' => array()
158
  );
159
-
160
  // Get options from the Customizer API.
161
  $settings = $wp_customize->settings();
162
-
163
  foreach ( $settings as $key => $setting ) {
164
-
165
  if ( 'option' == $setting->type ) {
166
-
167
  // Don't save widget data.
168
  if ( stristr( $key, 'widget_' ) ) {
169
  continue;
170
  }
171
-
172
  // Don't save sidebar data.
173
  if ( stristr( $key, 'sidebars_' ) ) {
174
  continue;
175
  }
176
-
177
  // Don't save core options.
178
  if ( in_array( $key, self::$core_options ) ) {
179
  continue;
180
  }
181
-
182
  $data['options'][ $key ] = $setting->value();
183
  }
184
  }
185
-
186
  // Plugin developers can specify additional option keys to export.
187
  $option_keys = apply_filters( 'cei_export_option_keys', array() );
188
-
189
  foreach ( $option_keys as $option_key ) {
190
-
191
  $option_value = get_option( $option_key );
192
-
193
  if ( $option_value ) {
194
  $data['options'][ $option_key ] = $option_value;
195
  }
196
  }
197
-
 
 
 
 
198
  // Set the download headers.
199
  header( 'Content-disposition: attachment; filename=' . $theme . '-export.dat' );
200
  header( 'Content-Type: application/octet-stream; charset=' . $charset );
201
-
202
  // Serialize the export data.
203
  echo serialize( $data );
204
-
205
  // Start the download.
206
  die();
207
  }
208
-
209
  /**
210
  * Imports uploaded mods and calls WordPress core customize_save actions so
211
  * themes that hook into them can act before mods are saved to the database.
@@ -287,28 +291,33 @@ final class CEI_Core {
287
  'type' => 'option',
288
  'capability' => 'edit_theme_options'
289
  ) );
290
-
291
  $option->import( $option_value );
292
  }
293
  }
294
-
 
 
 
 
 
295
  // Call the customize_save action.
296
  do_action( 'customize_save', $wp_customize );
297
-
298
  // Loop through the mods.
299
  foreach ( $data['mods'] as $key => $val ) {
300
-
301
  // Call the customize_save_ dynamic action.
302
  do_action( 'customize_save_' . $key, $wp_customize );
303
-
304
  // Save the mod.
305
  set_theme_mod( $key, $val );
306
  }
307
-
308
  // Call the customize_save_after action.
309
  do_action( 'customize_save_after', $wp_customize );
310
  }
311
-
312
  /**
313
  * Imports images for settings saved as mods.
314
  *
156
  'mods' => $mods ? $mods : array(),
157
  'options' => array()
158
  );
159
+
160
  // Get options from the Customizer API.
161
  $settings = $wp_customize->settings();
162
+
163
  foreach ( $settings as $key => $setting ) {
164
+
165
  if ( 'option' == $setting->type ) {
166
+
167
  // Don't save widget data.
168
  if ( stristr( $key, 'widget_' ) ) {
169
  continue;
170
  }
171
+
172
  // Don't save sidebar data.
173
  if ( stristr( $key, 'sidebars_' ) ) {
174
  continue;
175
  }
176
+
177
  // Don't save core options.
178
  if ( in_array( $key, self::$core_options ) ) {
179
  continue;
180
  }
181
+
182
  $data['options'][ $key ] = $setting->value();
183
  }
184
  }
185
+
186
  // Plugin developers can specify additional option keys to export.
187
  $option_keys = apply_filters( 'cei_export_option_keys', array() );
188
+
189
  foreach ( $option_keys as $option_key ) {
190
+
191
  $option_value = get_option( $option_key );
192
+
193
  if ( $option_value ) {
194
  $data['options'][ $option_key ] = $option_value;
195
  }
196
  }
197
+
198
+ if( function_exists( 'wp_get_custom_css_post' ) ) {
199
+ $data['wp_css'] = wp_get_custom_css();
200
+ }
201
+
202
  // Set the download headers.
203
  header( 'Content-disposition: attachment; filename=' . $theme . '-export.dat' );
204
  header( 'Content-Type: application/octet-stream; charset=' . $charset );
205
+
206
  // Serialize the export data.
207
  echo serialize( $data );
208
+
209
  // Start the download.
210
  die();
211
  }
212
+
213
  /**
214
  * Imports uploaded mods and calls WordPress core customize_save actions so
215
  * themes that hook into them can act before mods are saved to the database.
291
  'type' => 'option',
292
  'capability' => 'edit_theme_options'
293
  ) );
294
+
295
  $option->import( $option_value );
296
  }
297
  }
298
+
299
+ // If wp_css is set then import it.
300
+ if( function_exists( 'wp_update_custom_css_post' ) && isset( $data['wp_css'] ) && '' !== $data['wp_css'] ) {
301
+ wp_update_custom_css_post( $data['wp_css'] );
302
+ }
303
+
304
  // Call the customize_save action.
305
  do_action( 'customize_save', $wp_customize );
306
+
307
  // Loop through the mods.
308
  foreach ( $data['mods'] as $key => $val ) {
309
+
310
  // Call the customize_save_ dynamic action.
311
  do_action( 'customize_save_' . $key, $wp_customize );
312
+
313
  // Save the mod.
314
  set_theme_mod( $key, $val );
315
  }
316
+
317
  // Call the customize_save_after action.
318
  do_action( 'customize_save_after', $wp_customize );
319
  }
320
+
321
  /**
322
  * Imports images for settings saved as mods.
323
  *
customizer-export-import.php CHANGED
@@ -3,14 +3,14 @@
3
  * Plugin Name: Customizer Export/Import
4
  * Plugin URI: http://www.wpbeaverbuilder.com/wordpress-customizer-export-import-plugin/?utm_source=external&utm_medium=customizer-export&utm_campaign=plugins-page
5
  * Description: Adds settings export and import functionality to the WordPress customizer.
6
- * Version: 0.6
7
  * Author: The Beaver Builder Team
8
  * Author URI: http://www.wpbeaverbuilder.com/?utm_source=external&utm_medium=customizer-export&utm_campaign=plugins-page
9
  * License: GNU General Public License v2.0
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  * Text Domain: customizer-export-import
12
  */
13
- define( 'CEI_VERSION', '0.6' );
14
  define( 'CEI_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
15
  define( 'CEI_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
16
 
3
  * Plugin Name: Customizer Export/Import
4
  * Plugin URI: http://www.wpbeaverbuilder.com/wordpress-customizer-export-import-plugin/?utm_source=external&utm_medium=customizer-export&utm_campaign=plugins-page
5
  * Description: Adds settings export and import functionality to the WordPress customizer.
6
+ * Version: 0.7
7
  * Author: The Beaver Builder Team
8
  * Author URI: http://www.wpbeaverbuilder.com/?utm_source=external&utm_medium=customizer-export&utm_campaign=plugins-page
9
  * License: GNU General Public License v2.0
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  * Text Domain: customizer-export-import
12
  */
13
+ define( 'CEI_VERSION', '0.7' );
14
  define( 'CEI_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
15
  define( 'CEI_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
16
 
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: justinbusa
3
  Tags: customizer, customizer export, customizer import, export, import, settings, customizer settings, theme settings, theme options
4
  Requires at least: 3.6
5
- Tested up to: 4.7.1
6
  Stable tag: trunk
7
  License: GPL2+
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -84,3 +84,7 @@ Please visit our blog for more info on the [Customizer Export/Import plugin](htt
84
  = Version 0.6 =
85
 
86
  - Trying another fix for the issue with uploads in WordPress 4.7.1.
 
 
 
 
2
  Contributors: justinbusa
3
  Tags: customizer, customizer export, customizer import, export, import, settings, customizer settings, theme settings, theme options
4
  Requires at least: 3.6
5
+ Tested up to: 4.9
6
  Stable tag: trunk
7
  License: GPL2+
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
84
  = Version 0.6 =
85
 
86
  - Trying another fix for the issue with uploads in WordPress 4.7.1.
87
+
88
+ = Version 0.7 =
89
+
90
+ - Added support for exporting and importing custom CSS.