$file_name ) { unlink( $file_name ); } } } function wptouch_backup_settings() { global $wptouch_pro; $backup_domains = $wptouch_pro->get_active_setting_domains(); if ( is_array( $backup_domains ) && count( $backup_domains ) ) { $settings_to_save = array(); foreach( $backup_domains as $domain ) { $settings_notused = wptouch_get_settings( $domain ); $settings = $wptouch_pro->settings_objects[ $domain ]; if ( isset( $settings->domain) ) { unset( $settings->domain ); } $settings_to_save[ $domain ] = apply_filters( 'wptouch_backup_settings', $settings, $domain ); } ksort( $settings_to_save ); $backup_string = base64_encode( gzcompress( serialize( $settings_to_save ), 9 ) ); $backup_base_name = 'wptouch-backup-' . date( 'Ymd-His') . '.txt'; $backup_file_name = WPTOUCH_BACKUP_DIRECTORY . '/' . $backup_base_name; $backup_file = fopen( $backup_file_name, 'w+t' ); if ( $backup_file ) { fwrite( $backup_file, $backup_string ); fclose( $backup_file ); } } wptouch_prune_backup_files(); return $backup_base_name; } function wptouch_restore_settings( $encoded_string ) { global $wptouch_pro; $encoded_settings = base64_decode( $encoded_string ); $settings = unserialize( gzuncompress( $encoded_settings ) ); $wptouch_pro->erase_all_settings(); if ( is_array( $settings ) ) { foreach( $settings as $domain => $settings_object ) { $settings_object->domain = $domain; $settings_object->save(); } } }