element_before(); if ( $this->config['type'] == 'menu' ) { $nonce = wp_create_nonce( 'exopite_sof_backup' ); $options = get_option( $this->unique ); $export = esc_url( add_query_arg( array( 'action' => 'exopite-sof-export-options', 'export' => $this->unique, 'wpnonce' => $nonce ), admin_url( 'admin-ajax.php' ) ) ); $encoded_options = ''; if ( $options ) { $encoded_options = $this->encode_string( $options ); } echo ''; echo '( ' . esc_attr__( 'copy-paste your backup string here', 'exopite-sof' ) . ' )'; echo '' . esc_attr__( 'Import a Backup', 'exopite-sof' ) . ''; echo '
'; echo ''; echo '' . esc_attr__( 'Download Backup', 'exopite-sof' ) . ''; echo '
'; echo '' . esc_attr__( 'Please be sure for reset all of framework options.', 'exopite-sof' ) . ''; echo '' . esc_attr__( 'Reset All Options', 'exopite-sof' ) . ''; echo '
'; } else { echo 'This item only available in menu!
'; } echo $this->element_after(); } /** * Encode string for backup options */ function encode_string( $option ) { return json_encode( $option ); // return rtrim( strtr( call_user_func( 'base' . '64' . '_encode', addslashes( gzcompress( serialize( $option ), 9 ) ) ), '+/', '-_' ), '=' ); } /** * Decode string for backup options */ function decode_string( $option ) { return json_decode( $_POST['value'], true ); // return unserialize( gzuncompress( stripslashes( call_user_func( 'base' . '64' . '_decode', rtrim( strtr( $option, '-_', '+/' ), '=' ) ) ) ) ); } public static function enqueue( $args ) { /* * https://sweetalert.js.org/guides/ */ // wp_enqueue_script( 'sweetalert', '//unpkg.com/sweetalert/dist/sweetalert.min.js', false, '2.1.0', true ); $resources = array( array( 'name' => 'sweetalert', 'fn' => 'sweetalert.min.js', 'type' => 'script', 'dependency' => false, 'version' => '2.1.0', 'attr' => true, ), ); parent::do_enqueue( $resources, $args ); } } }