Customizer Export/Import - Version 0.4

Version Description

Download this release

Release Info

Developer justinbusa
Plugin Icon 128x128 Customizer Export/Import
Version 0.4
Comparing to
See all releases

Code changes from version 0.3 to 0.4

classes/class-cei-core.php CHANGED
@@ -218,19 +218,45 @@ final class CEI_Core {
218
  */
219
  static private function _import( $wp_customize )
220
  {
 
221
  if ( ! wp_verify_nonce( $_REQUEST['cei-import'], 'cei-importing' ) ) {
222
  return;
223
  }
224
 
 
 
 
 
 
 
225
  require_once CEI_PLUGIN_DIR . 'classes/class-cei-option.php';
226
 
 
227
  global $wp_customize;
228
  global $cei_error;
229
 
 
230
  $cei_error = false;
231
  $template = get_template();
232
- $raw = file_get_contents( $_FILES['cei-import-file']['tmp_name'] );
233
- $data = @unserialize( $raw );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
 
235
  // Data checks.
236
  if ( 'array' != gettype( $data ) ) {
218
  */
219
  static private function _import( $wp_customize )
220
  {
221
+ // Make sure we have a valid nonce.
222
  if ( ! wp_verify_nonce( $_REQUEST['cei-import'], 'cei-importing' ) ) {
223
  return;
224
  }
225
 
226
+ // Make sure WordPress upload support is loaded.
227
+ if ( ! function_exists( 'wp_handle_upload' ) ) {
228
+ require_once( ABSPATH . 'wp-admin/includes/file.php' );
229
+ }
230
+
231
+ // Load the export/import option class.
232
  require_once CEI_PLUGIN_DIR . 'classes/class-cei-option.php';
233
 
234
+ // Setup global vars.
235
  global $wp_customize;
236
  global $cei_error;
237
 
238
+ // Setup internal vars.
239
  $cei_error = false;
240
  $template = get_template();
241
+ $overrides = array( 'test_form' => FALSE, 'mimes' => array('dat' => 'text/dat') );
242
+ $file = wp_handle_upload( $_FILES['cei-import-file'], $overrides );
243
+
244
+ // Make sure we have an uploaded file.
245
+ if ( isset( $file['error'] ) ) {
246
+ $cei_error = $file['error'];
247
+ return;
248
+ }
249
+ if ( ! file_exists( $file['file'] ) ) {
250
+ $cei_error = __( 'Error importing settings! Please try again.', 'customizer-export-import' );
251
+ return;
252
+ }
253
+
254
+ // Get the upload data.
255
+ $raw = file_get_contents( $file['file'] );
256
+ $data = @unserialize( $raw );
257
+
258
+ // Remove the uploaded file.
259
+ unlink( $file['file'] );
260
 
261
  // Data checks.
262
  if ( 'array' != gettype( $data ) ) {
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.3
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.1' );
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.4
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.4' );
14
  define( 'CEI_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
15
  define( 'CEI_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
16