$value ){ if ( $graphene_defaults[$key] === $value || $value === '' ) { unset( $data[$key] ); } } */ $data = json_encode( $data ); $size = strlen( $data ); header( 'Content-Type: text/plain' ); header( 'Content-Disposition: attachment; filename="'.$name.'"' ); header( "Content-Transfer-Encoding: binary" ); header( 'Accept-Ranges: bytes' ); /* The three lines below basically make the download non-cacheable */ header( "Cache-control: private" ); header( 'Pragma: private' ); header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); header( "Content-Length: " . $size); print( $data ); } else { wp_die( __( 'ERROR: You are not authorised to perform that operation', 'graphene' ) ); } die(); } if ( isset( $_POST['graphene_export'] ) ){ add_action( 'init', 'graphene_export_options' ); } /** * This file manages the theme settings uploading and import operations. * Uses WP_Filesystem */ function graphene_import_form(){ $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); $size = size_format( $bytes, 2 ); $upload_dir = wp_upload_dir(); if ( ! empty( $upload_dir['error'] ) ) : ?>


()



()



move( $_FILES['import']['tmp_name'], $filename, true) ) { echo 'Error saving file!'; return; } $file = $_FILES['import']; if ( $file['type'] == 'text/plain' ) { $data = $wp_filesystem->get_contents( $filename ); // try to read the file if ( $data !== FALSE ){ $settings = json_decode( $data, true ); // try to read the settings array if ( ! $is_colours ) { if ( isset( $settings['db_version'] ) ) { $settings = array_merge( $graphene_settings, $settings ); update_option( 'graphene_settings', $settings ); echo '

' . __( 'Options import completed.', 'graphene' ) . '

'; echo '

' . __( '« Return to Graphene Options', 'graphene' ) . '

'; } else { // else: try to read the settings array echo '

'.__( 'Sorry, there has been an error.', 'graphene' ).'
'; echo __( 'The uploaded file does not contain valid Graphene options.', 'graphene' ).'

'; } } else { if ( isset( $settings['colour_presets'] ) ) { $graphene_settings['colour_presets'] = array_merge( $graphene_settings['colour_presets'], $settings['colour_presets'] ); update_option( 'graphene_settings', $graphene_settings ); echo '

' . __( 'Colour presets import completed.', 'graphene' ) . '

'; echo '

' . __( '« Return to Graphene Options', 'graphene' ) . '

'; } else { // else: try to read the settings array echo '

'.__( 'Sorry, there has been an error.', 'graphene' ).'
'; echo __( 'The uploaded file does not contain valid Graphene colour presets.', 'graphene' ).'

'; } } } else { // else: try to read the file echo '

'.__( 'Sorry, there has been an error.', 'graphene' ).'
'; echo __( 'The uploaded file could not be read.', 'graphene' ).'

'; } } else { // else: make sure the file uploaded was a plain text file echo '

'.__( 'Sorry, there has been an error.', 'graphene' ).'
'; echo __( 'The uploaded file is not supported.', 'graphene' ).'

'; } // Delete the file after we're done $wp_filesystem->delete( $filename); } else { // else: make sure there is an import file uploaded echo '

'.__( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.', 'graphene' ).'

'; } echo '
'; } else { wp_die( __( 'ERROR: You are not authorised to perform that operation', 'graphene' ) ); } } // Closes the graphene_import_file() function definition