Changeset 2519583
- Timestamp:
- 04/22/2021 07:20:04 AM (5 years ago)
- Location:
- advanced-export
- Files:
-
- 50 added
- 9 edited
-
tags/1.0.3 (added)
-
tags/1.0.3/LICENSE.txt (added)
-
tags/1.0.3/admin (added)
-
tags/1.0.3/admin/class-advanced-export-admin.php (added)
-
tags/1.0.3/admin/function-create-zip.php (added)
-
tags/1.0.3/admin/function-form-load.php (added)
-
tags/1.0.3/admin/index.php (added)
-
tags/1.0.3/advanced-export.php (added)
-
tags/1.0.3/assets (added)
-
tags/1.0.3/assets/css (added)
-
tags/1.0.3/assets/css/advanced-export-admin.css (added)
-
tags/1.0.3/assets/js (added)
-
tags/1.0.3/assets/js/advanced-export-admin.js (added)
-
tags/1.0.3/includes (added)
-
tags/1.0.3/includes/class-advanced-export-activator.php (added)
-
tags/1.0.3/includes/class-advanced-export-deactivator.php (added)
-
tags/1.0.3/includes/class-advanced-export-i18n.php (added)
-
tags/1.0.3/includes/class-advanced-export-loader.php (added)
-
tags/1.0.3/includes/class-advanced-export.php (added)
-
tags/1.0.3/includes/index.php (added)
-
tags/1.0.3/index.php (added)
-
tags/1.0.3/languages (added)
-
tags/1.0.3/languages/advanced-export.pot (added)
-
tags/1.0.3/readme.txt (added)
-
tags/1.0.3/uninstall.php (added)
-
tags/1.0.4 (added)
-
tags/1.0.4/LICENSE.txt (added)
-
tags/1.0.4/admin (added)
-
tags/1.0.4/admin/class-advanced-export-admin.php (added)
-
tags/1.0.4/admin/function-create-zip.php (added)
-
tags/1.0.4/admin/function-form-load.php (added)
-
tags/1.0.4/admin/index.php (added)
-
tags/1.0.4/advanced-export.php (added)
-
tags/1.0.4/assets (added)
-
tags/1.0.4/assets/css (added)
-
tags/1.0.4/assets/css/advanced-export-admin.css (added)
-
tags/1.0.4/assets/js (added)
-
tags/1.0.4/assets/js/advanced-export-admin.js (added)
-
tags/1.0.4/includes (added)
-
tags/1.0.4/includes/class-advanced-export-activator.php (added)
-
tags/1.0.4/includes/class-advanced-export-deactivator.php (added)
-
tags/1.0.4/includes/class-advanced-export-i18n.php (added)
-
tags/1.0.4/includes/class-advanced-export-loader.php (added)
-
tags/1.0.4/includes/class-advanced-export.php (added)
-
tags/1.0.4/includes/index.php (added)
-
tags/1.0.4/index.php (added)
-
tags/1.0.4/languages (added)
-
tags/1.0.4/languages/advanced-export.pot (added)
-
tags/1.0.4/readme.txt (added)
-
tags/1.0.4/uninstall.php (added)
-
trunk/admin/class-advanced-export-admin.php (modified) (5 diffs)
-
trunk/admin/function-create-zip.php (modified) (20 diffs)
-
trunk/admin/function-form-load.php (modified) (6 diffs)
-
trunk/advanced-export.php (modified) (2 diffs)
-
trunk/includes/class-advanced-export-activator.php (modified) (1 diff)
-
trunk/includes/class-advanced-export-deactivator.php (modified) (1 diff)
-
trunk/includes/class-advanced-export-i18n.php (modified) (1 diff)
-
trunk/includes/class-advanced-export.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
advanced-export/trunk/admin/class-advanced-export-admin.php
r2159845 r2519583 68 68 public function __construct( $plugin_name, $version ) { 69 69 70 $this->plugin_name = $plugin_name;71 $this->version = $version;72 $this->page_slug = apply_filters( 'advanced_export_page_slug','advanced-export' );73 $this->export_capability = apply_filters( 'advanced_export_capability', 'export' );70 $this->plugin_name = $plugin_name; 71 $this->version = $version; 72 $this->page_slug = apply_filters( 'advanced_export_page_slug', 'advanced-export' ); 73 $this->export_capability = apply_filters( 'advanced_export_capability', 'export' ); 74 74 } 75 75 … … 81 81 public function enqueue_styles( $hook_suffix ) { 82 82 83 if ( 'tools_page_' .$this->page_slug == $hook_suffix ){83 if ( 'tools_page_' . $this->page_slug == $hook_suffix ) { 84 84 wp_enqueue_style( $this->plugin_name, ADVANCED_EXPORT_URL . 'assets/css/advanced-export-admin.css', array(), $this->version, 'all' ); 85 85 } … … 93 93 public function enqueue_scripts( $hook_suffix ) { 94 94 95 if ( 'tools_page_' .$this->page_slug == $hook_suffix ){95 if ( 'tools_page_' . $this->page_slug == $hook_suffix ) { 96 96 wp_enqueue_script( $this->plugin_name, ADVANCED_EXPORT_URL . 'assets/js/advanced-export-admin.js', array( 'jquery' ), $this->version, false ); 97 wp_localize_script( $this->plugin_name, 'advanced_export_js_object', array( 98 'ajaxurl' => admin_url( 'admin-ajax.php' ) 99 ) ); 97 wp_localize_script( 98 $this->plugin_name, 99 'advanced_export_js_object', 100 array( 101 'ajaxurl' => admin_url( 'admin-ajax.php' ), 102 ) 103 ); 100 104 } 101 105 } … … 144 148 // If the 'download' URL parameter is set, a Theme Data ZIP export file returned. 145 149 if ( isset( $_POST['advanced-export-download'] ) ) { 146 if ( ! current_user_can( $this->export_capability ) ){147 wp_die( esc_html__( 'Sorry, you are not allowed to export the content of this site.', 'advanced-export' ) );150 if ( ! current_user_can( $this->export_capability ) ) { 151 wp_die( esc_html__( 'Sorry, you are not allowed to export the content of this site.', 'advanced-export' ) ); 148 152 } 149 153 … … 155 159 if ( ! isset( $_POST['content'] ) || 'all' == $_POST['content'] ) { 156 160 $args['content'] = 'all'; 157 } 158 elseif ( 'posts' == $_POST['content'] ) { 161 } elseif ( 'posts' == $_POST['content'] ) { 159 162 $args['content'] = 'post'; 160 163 161 if ( $_POST['cat'] ) {162 $args['category'] = absint( $_POST['cat'] ) ;163 }164 165 if ( $_POST['post_author'] ) {164 if ( $_POST['cat'] ) { 165 $args['category'] = absint( $_POST['cat'] ); 166 } 167 168 if ( $_POST['post_author'] ) { 166 169 $args['author'] = absint( $_POST['post_author'] ); 167 }170 } 168 171 169 172 if ( $_POST['post_start_date'] || $_POST['post_end_date'] ) { 170 173 $args['start_date'] = sanitize_text_field( $_POST['post_start_date'] ); 171 $args['end_date'] = sanitize_text_field( $_POST['post_end_date'] ); 172 } 173 174 if ( $_POST['post_status'] ){ 175 $args['status'] = sanitize_text_field ( $_POST['post_status'] ); 176 } 177 } 178 elseif ( 'pages' == $_POST['content'] ) { 174 $args['end_date'] = sanitize_text_field( $_POST['post_end_date'] ); 175 } 176 177 if ( $_POST['post_status'] ) { 178 $args['status'] = sanitize_text_field( $_POST['post_status'] ); 179 } 180 } elseif ( 'pages' == $_POST['content'] ) { 179 181 $args['content'] = 'page'; 180 182 181 if ( $_POST['page_author'] ) {183 if ( $_POST['page_author'] ) { 182 184 $args['author'] = absint( $_POST['page_author'] ); 183 }185 } 184 186 185 187 if ( $_POST['page_start_date'] || $_POST['page_end_date'] ) { 186 188 $args['start_date'] = sanitize_text_field( $_POST['page_start_date'] ); 187 $args['end_date'] = sanitize_text_field( $_POST['page_end_date'] );188 } 189 190 if ( $_POST['page_status'] ) {189 $args['end_date'] = sanitize_text_field( $_POST['page_end_date'] ); 190 } 191 192 if ( $_POST['page_status'] ) { 191 193 $args['status'] = sanitize_text_field( $_POST['page_status'] ); 192 } 193 } 194 elseif ( 'attachment' == $_POST['content'] ) { 194 } 195 } elseif ( 'attachment' == $_POST['content'] ) { 195 196 $args['content'] = 'attachment'; 196 197 197 198 if ( $_POST['attachment_start_date'] || $_POST['attachment_end_date'] ) { 198 199 $args['start_date'] = sanitize_text_field( $_POST['attachment_start_date'] ); 199 $args['end_date'] = sanitize_text_field( $_POST['attachment_end_date'] ); 200 } 201 } 202 else { 203 $args['content'] = sanitize_text_field ( $_POST['content'] ); 204 } 205 if( isset( $_POST['include_media'] ) && $_POST['include_media'] == 1 ){ 200 $args['end_date'] = sanitize_text_field( $_POST['attachment_end_date'] ); 201 } 202 } else { 203 $args['content'] = sanitize_text_field( $_POST['content'] ); 204 } 205 if ( isset( $_POST['include_media'] ) && $_POST['include_media'] == 1 ) { 206 206 $args['include_media'] = 1; 207 207 } 208 if ( isset( $_POST['widgets_data'] ) && $_POST['widgets_data'] == 1 ){208 if ( isset( $_POST['widgets_data'] ) && $_POST['widgets_data'] == 1 ) { 209 209 $args['widgets_data'] = 1; 210 210 } 211 if ( isset( $_POST['options_data'] ) && $_POST['options_data'] == 1 ){211 if ( isset( $_POST['options_data'] ) && $_POST['options_data'] == 1 ) { 212 212 $args['options_data'] = 1; 213 213 } -
advanced-export/trunk/admin/function-create-zip.php
r2328319 r2519583 5 5 * @since 1.0.0 6 6 */ 7 if ( !function_exists( 'advanced_export_create_zip') ){7 if ( ! function_exists( 'advanced_export_create_zip' ) ) { 8 8 function advanced_export_create_zip( $source, $wp_filesystem ) { 9 9 10 10 /*Check if Zip Extension Installed*/ 11 if ( !class_exists( 'ZipArchive')){12 die( esc_html__( 'ZIP extension is not installed, please install ZIP extension on your host or contact to your hosting provider and try again!', 'advanced-export') );13 } 14 15 $zip = new ZipArchive;16 $zip_filename = esc_attr( get_option( 'template') ).'-data';11 if ( ! class_exists( 'ZipArchive' ) ) { 12 die( esc_html__( 'ZIP extension is not installed, please install ZIP extension on your host or contact to your hosting provider and try again!', 'advanced-export' ) ); 13 } 14 15 $zip = new ZipArchive; 16 $zip_filename = esc_attr( get_option( 'template' ) ) . '-data'; 17 17 $zip->open( $zip_filename, ZipArchive::CREATE && ZipArchive::OVERWRITE ); 18 18 … … 20 20 https://stackoverflow.com/questions/4914750/how-to-zip-a-whole-folder-using-php */ 21 21 $files = new RecursiveIteratorIterator( 22 new RecursiveDirectoryIterator( $source),22 new RecursiveDirectoryIterator( $source ), 23 23 RecursiveIteratorIterator::LEAVES_ONLY 24 24 ); 25 25 foreach ( $files as $name => $file ) { 26 26 /*Skip directories (they would be added automatically)*/ 27 if ( ! $file->isDir() ) {27 if ( ! $file->isDir() ) { 28 28 /*Get real and relative path for current file*/ 29 $filePath = $file->getRealPath();30 $relativePath = substr( $filePath, strlen($source));29 $filePath = $file->getRealPath(); 30 $relativePath = substr( $filePath, strlen( $source ) ); 31 31 32 32 /*Add current file/directory to archive*/ 33 $zip->addFile( $filePath, $relativePath );33 $zip->addFile( $filePath, $relativePath ); 34 34 } 35 35 } … … 41 41 42 42 /*delete temp zip files*/ 43 $wp_filesystem->rmdir( $zip_filename, true );44 $wp_filesystem->rmdir( $source, true );43 $wp_filesystem->rmdir( $zip_filename, true ); 44 $wp_filesystem->rmdir( $source, true ); 45 45 die(); 46 46 } … … 52 52 * @since 1.0.0 53 53 */ 54 if ( !function_exists( 'advanced_export_create_data_files') ){55 function advanced_export_create_data_files( $form_args ) {56 57 $defaults = array(54 if ( ! function_exists( 'advanced_export_create_data_files' ) ) { 55 function advanced_export_create_data_files( $form_args ) { 56 57 $defaults = array( 58 58 'content' => 'all', 59 59 'author' => false, … … 64 64 'include_media' => false, 65 65 'widgets_data' => false, 66 'options_data' => false 66 'options_data' => false, 67 67 ); 68 68 $form_args = wp_parse_args( $form_args, $defaults ); … … 76 76 WP_Filesystem(); 77 77 global $wp_filesystem; 78 if ( ! file_exists( ADVANCED_EXPORT_TEMP ) ) {79 $wp_filesystem->mkdir(ADVANCED_EXPORT_TEMP);80 }81 if( 1 == $form_args['include_media'] ){82 if ( !file_exists( ADVANCED_EXPORT_TEMP_UPLOADS ) ) {83 $wp_filesystem->mkdir(ADVANCED_EXPORT_TEMP_UPLOADS);84 }85 }78 if ( ! file_exists( ADVANCED_EXPORT_TEMP ) ) { 79 $wp_filesystem->mkdir( ADVANCED_EXPORT_TEMP ); 80 } 81 if ( 1 == $form_args['include_media'] ) { 82 if ( ! file_exists( ADVANCED_EXPORT_TEMP_UPLOADS ) ) { 83 $wp_filesystem->mkdir( ADVANCED_EXPORT_TEMP_UPLOADS ); 84 } 85 } 86 86 87 87 /*default post types*/ … … 90 90 if ( 'all' != $form_args['content'] && post_type_exists( $form_args['content'] ) ) { 91 91 $post_type_object = get_post_type_object( $form_args['content'] ); 92 if ( $post_type_object->can_export ) {92 if ( $post_type_object->can_export ) { 93 93 $post_types = array( $form_args['content'] ); 94 94 } 95 } 96 else { 95 } else { 97 96 $post_types = get_post_types( array( 'can_export' => true ) ); 98 97 } … … 101 100 102 101 /*ignore post type*/ 103 $ignore_post_types = apply_filters( 'advanced_export_ignore_post_types',array( 'revision') );102 $ignore_post_types = apply_filters( 'advanced_export_ignore_post_types', array( 'revision' ) ); 104 103 foreach ( $post_types as $post_type ) { 105 104 … … 109 108 } 110 109 /*default args*/ 111 $args = array( 'post_type' => $post_type, 'posts_per_page' => - 1 ); 110 $args = array( 111 'post_type' => $post_type, 112 'posts_per_page' => - 1, 113 ); 112 114 113 115 /*setting post status*/ 114 if ( $form_args['status'] && ( 'post' == $post_type || 'page' == $post_type ) ) {116 if ( $form_args['status'] && ( 'post' == $post_type || 'page' == $post_type ) ) { 115 117 $args['post_status'] = $form_args['status']; 116 } 117 else{ 118 } else { 118 119 $args['post_status'] = 'any'; 119 120 } … … 128 129 /*setting date and author*/ 129 130 if ( 'post' == $post_type || 'page' == $post_type || 'attachment' == $post_type ) { 130 if ( $form_args['author'] ) {131 if ( $form_args['author'] ) { 131 132 $args['author'] = $form_args['post_author']; 132 133 } 133 if ( $form_args['start_date'] && $form_args['end_date'] ) {134 if ( $form_args['start_date'] && $form_args['end_date'] ) { 134 135 $args['date_query'] = array( 135 136 'after' => $form_args['start_date'], … … 150 151 if ( $object && isset( $object->labels->name ) && ! empty( $object->labels->name ) ) { 151 152 $type_title = $object->labels->name; 152 } 153 else { 153 } else { 154 154 $type_title = ucwords( $post_type ); 155 155 } … … 165 165 166 166 /*copy save images in exported folder if include media*/ 167 if ( 1 == $form_args['include_media'] && $post_type == 'attachment' ){167 if ( 1 == $form_args['include_media'] && $post_type == 'attachment' ) { 168 168 $file = get_attached_file( $single_post_data->ID ); 169 169 if ( is_file( $file ) ) { 170 170 if ( is_dir( ADVANCED_EXPORT_TEMP_UPLOADS ) ) { 171 copy( $file, ADVANCED_EXPORT_TEMP_UPLOADS . basename( $file ) );171 copy( $file, ADVANCED_EXPORT_TEMP_UPLOADS . basename( $file ) ); 172 172 } 173 173 } … … 178 178 foreach ( $taxonomies as $taxonomy ) { 179 179 $terms_data[ $taxonomy ] = wp_get_post_terms( $single_post_data->ID, $taxonomy, array( 'fields' => 'all' ) ); 180 if ( $terms_data[$taxonomy] ){181 foreach ( $terms_data[$taxonomy] as $tax_id => $single_term ){182 if ( !empty( $single_term->term_id ) ) {183 $terms_data[ $taxonomy ][ $tax_id ] ->meta = get_term_meta( $single_term->term_id );184 if ( !empty( $terms_data[ $taxonomy ][ $tax_id ] -> meta ) ){185 foreach ( $terms_data[ $taxonomy ][ $tax_id ] -> meta as $key=>$val ){186 if ( is_array( $val ) && count( $val ) == 1 && isset($val[0] ) ){187 $terms_data[ $taxonomy ][ $tax_id ] -> meta[$key] = $val[0];180 if ( $terms_data[ $taxonomy ] ) { 181 foreach ( $terms_data[ $taxonomy ] as $tax_id => $single_term ) { 182 if ( ! empty( $single_term->term_id ) ) { 183 $terms_data[ $taxonomy ][ $tax_id ]->meta = get_term_meta( $single_term->term_id ); 184 if ( ! empty( $terms_data[ $taxonomy ][ $tax_id ]->meta ) ) { 185 foreach ( $terms_data[ $taxonomy ][ $tax_id ]->meta as $key => $val ) { 186 if ( is_array( $val ) && count( $val ) == 1 && isset( $val[0] ) ) { 187 $terms_data[ $taxonomy ][ $tax_id ]->meta[ $key ] = $val[0]; 188 188 } 189 189 } … … 209 209 'post_mime_type' => $single_post_data->post_mime_type, 210 210 'meta' => $post_meta_data, 211 'terms' => $terms_data 211 'terms' => $terms_data, 212 212 ); 213 213 } … … 218 218 if ( $attachment ) { 219 219 unset( $content_data['attachment'] ); 220 $content_data = array('attachment' => $attachment ) + $content_data;221 } 222 /*Put post 3nd last*/223 $post = isset( $content_data['post'] ) ? $content_data['post'] : array();224 if ( $post ) {225 unset( $content_data['post'] );226 $content_data['post'] =$post;227 }228 /*Put page 2nd last*/229 $page = isset( $content_data['page'] ) ? $content_data['page'] : array();230 if ( $page ) {231 unset( $content_data['page'] );232 $content_data['page'] =$page;233 }234 /*Put nav last*/220 $content_data = array( 'attachment' => $attachment ) + $content_data; 221 } 222 /*Put post 3nd last*/ 223 $post = isset( $content_data['post'] ) ? $content_data['post'] : array(); 224 if ( $post ) { 225 unset( $content_data['post'] ); 226 $content_data['post'] = $post; 227 } 228 /*Put page 2nd last*/ 229 $page = isset( $content_data['page'] ) ? $content_data['page'] : array(); 230 if ( $page ) { 231 unset( $content_data['page'] ); 232 $content_data['page'] = $page; 233 } 234 /*Put nav last*/ 235 235 $nav = isset( $content_data['nav_menu_item'] ) ? $content_data['nav_menu_item'] : array(); 236 236 if ( $nav ) { … … 240 240 241 241 /*export widget settings.*/ 242 if ( 1 == $form_args['widgets_data'] ){242 if ( 1 == $form_args['widgets_data'] ) { 243 243 $sidebars_widgets = get_option( 'sidebars_widgets' ); 244 $widget_data = array();244 $widget_data = array(); 245 245 foreach ( $sidebars_widgets as $sidebar_name => $widgets ) { 246 246 if ( is_array( $widgets ) ) { 247 247 foreach ( $widgets as $widget_name ) { 248 $widget_name_strip = preg_replace( '#-\d+$#', '', $widget_name );248 $widget_name_strip = preg_replace( '#-\d+$#', '', $widget_name ); 249 249 $widget_data[ $widget_name_strip ] = get_option( 'widget_' . $widget_name_strip ); 250 250 } … … 254 254 255 255 /*export options and nav*/ 256 if ( 1 == $form_args['options_data'] ){256 if ( 1 == $form_args['options_data'] ) { 257 257 /*nav menu data*/ 258 $menus = get_terms( 'nav_menu' );258 $menus = get_terms( 'nav_menu' ); 259 259 $theme_locations = get_nav_menu_locations(); 260 $menu_data = array();260 $menu_data = array(); 261 261 foreach ( $menus as $menu ) { 262 foreach ( $theme_locations as $key => $theme_location ) {263 if ( $menu->term_id == $theme_location ){264 $menu_data[ $key] = $menu->term_id;262 foreach ( $theme_locations as $key => $theme_location ) { 263 if ( $menu->term_id == $theme_location ) { 264 $menu_data[ $key ] = $menu->term_id; 265 265 } 266 266 } … … 268 268 269 269 /*get all options*/ 270 $all_options = wp_load_alloptions();271 $theme_mode = 'theme_mods_'.get_option('template');272 $options_data = array();270 $all_options = wp_load_alloptions(); 271 $theme_mode = 'theme_mods_' . get_option( 'template' ); 272 $options_data = array(); 273 273 $needed_options = array( 274 274 'blogname', … … 297 297 'show_on_front', 298 298 'page_for_posts', 299 $theme_mode 299 $theme_mode, 300 300 ); 301 $needed_options = apply_filters('advanced_export_include_options',$needed_options ); 302 303 foreach ( $all_options as $name => $value ) { 304 if( apply_filters('advanced_export_all_options',false ) ){ 305 $options_data[ $name ] = maybe_unserialize( $value ); 306 $options_data[ $name . '-child' ] = maybe_unserialize( $value ); 307 } 308 else if ( in_array( $name, $needed_options )) { 309 $options_data[ $name ] = maybe_unserialize( $value ); 301 if ( is_child_theme() ) { 302 $needed_options[] = 'theme_mods_' . get_option( 'stylesheet' ); 303 } 304 305 /*For Gutentor.*/ 306 if ( function_exists( 'run_gutentor' ) ) { 307 $args = array( 308 'orderby' => 'id', 309 'hide_empty' => 0, 310 ); 311 $categories = get_categories( $args ); 312 if ( $categories ) { 313 foreach ( $categories as $category_list ) { 314 $needed_options[] = 'gutentor-cat-' . $category_list->term_id; 315 } 316 } 317 } 318 319 $needed_options = apply_filters( 'advanced_export_include_options', $needed_options ); 320 321 foreach ( $all_options as $name => $value ) { 322 if ( apply_filters( 'advanced_export_all_options', false ) ) { 323 $options_data[ $name ] = maybe_unserialize( $value ); 310 324 $options_data[ $name . '-child' ] = maybe_unserialize( $value ); 311 } 312 if( $name == $theme_mode ){ 325 } elseif ( in_array( $name, $needed_options ) ) { 326 $options_data[ $name ] = maybe_unserialize( $value ); 327 $options_data[ $name . '-child' ] = maybe_unserialize( $value ); 328 } 329 if ( $name == $theme_mode ) { 313 330 unset( $options_data[ $name ]['nav_menu_locations'] ); 314 331 } … … 320 337 321 338 /*content*/ 322 $wp_filesystem->put_contents( ADVANCED_EXPORT_TEMP . 'content.json' , json_encode( $content_data ) );339 $wp_filesystem->put_contents( ADVANCED_EXPORT_TEMP . 'content.json', json_encode( $content_data ) ); 323 340 324 341 /*widgets*/ 325 if ( 1 == $form_args['widgets_data'] ){342 if ( 1 == $form_args['widgets_data'] ) { 326 343 $combine_widgets_data = array(); 327 if ( !empty( $sidebars_widgets) ){344 if ( ! empty( $sidebars_widgets ) ) { 328 345 $combine_widgets_data['widget_positions'] = $sidebars_widgets; 329 346 } 330 if ( !empty( $widget_data ) ){347 if ( ! empty( $widget_data ) ) { 331 348 $combine_widgets_data['widget_options'] = $widget_data; 332 349 } 333 $wp_filesystem->put_contents( ADVANCED_EXPORT_TEMP . 'widgets.json' , json_encode( $combine_widgets_data ) );350 $wp_filesystem->put_contents( ADVANCED_EXPORT_TEMP . 'widgets.json', json_encode( $combine_widgets_data ) ); 334 351 } 335 352 336 353 /*options/customizer*/ 337 if ( 1 == $form_args['options_data'] ){354 if ( 1 == $form_args['options_data'] ) { 338 355 $combine_options_data = array(); 339 if ( !empty( $menu_data ) ){356 if ( ! empty( $menu_data ) ) { 340 357 $combine_options_data['menu'] = $menu_data; 341 358 } 342 if ( !empty( $options_data ) ){359 if ( ! empty( $options_data ) ) { 343 360 $combine_options_data['options'] = $options_data; 344 361 } 345 $wp_filesystem->put_contents( ADVANCED_EXPORT_TEMP . 'options.json' , json_encode( $combine_options_data ) );346 } 347 } 348 advanced_export_create_zip( ADVANCED_EXPORT_TEMP, $wp_filesystem );362 $wp_filesystem->put_contents( ADVANCED_EXPORT_TEMP . 'options.json', json_encode( $combine_options_data ) ); 363 } 364 } 365 advanced_export_create_zip( ADVANCED_EXPORT_TEMP, $wp_filesystem ); 349 366 } 350 367 } 351 if ( !function_exists( 'advanced_export_ziparchive') ){352 function advanced_export_ziparchive( $form_args ) {368 if ( ! function_exists( 'advanced_export_ziparchive' ) ) { 369 function advanced_export_ziparchive( $form_args ) { 353 370 advanced_export_create_data_files( $form_args ); 354 371 } -
advanced-export/trunk/admin/function-form-load.php
r2159845 r2519583 6 6 */ 7 7 global $wpdb, $wp_locale; 8 if ( !function_exists( 'advanced_export_date_options') ){8 if ( ! function_exists( 'advanced_export_date_options' ) ) { 9 9 function advanced_export_date_options( $post_type = 'post' ) { 10 10 global $wpdb, $wp_locale; 11 11 12 $months = $wpdb->get_results( $wpdb->prepare( " 12 $months = $wpdb->get_results( 13 $wpdb->prepare( 14 " 13 15 SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month 14 16 FROM $wpdb->posts 15 17 WHERE post_type = %s AND post_status != 'auto-draft' 16 18 ORDER BY post_date DESC 17 ", $post_type ) ); 19 ", 20 $post_type 21 ) 22 ); 18 23 19 24 $month_count = count( $months ); 20 if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) )25 if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) { 21 26 return; 27 } 22 28 23 29 foreach ( $months as $date ) { 24 if ( 0 == $date->year ) 30 if ( 0 == $date->year ) { 25 31 continue; 32 } 26 33 27 34 $month = zeroise( $date->month, 2 ); 28 echo '<option value="' . esc_attr( $date->year ) . '-' . esc_attr( $month ) . '">' . esc_attr( $wp_locale->get_month( $month ) ) . ' ' . esc_attr( $date->year ). '</option>';35 echo '<option value="' . esc_attr( $date->year ) . '-' . esc_attr( $month ) . '">' . esc_attr( $wp_locale->get_month( $month ) ) . ' ' . esc_attr( $date->year ) . '</option>'; 29 36 } 30 37 } 31 38 } 32 39 33 function advanced_export_form() {40 function advanced_export_form() { 34 41 global $wpdb, $wp_locale; 35 42 ?> 36 43 <div class="wrap"> 37 <h1><?php esc_html_e( 'Export Zip','advanced-export'); ?></h1>38 39 <p><?php esc_html_e( 'When you click the button below Plugin will create a Zip file to save to your computer.','advanced-export'); ?></p>40 <p><?php esc_html_e( 'Once you’ve saved the download zip file, you can use the Import function in another WordPress installation to import the content from this site.','advanced-export'); ?></p>41 42 <h2><?php esc_html_e( 'Choose what to export','advanced-export'); ?></h2>44 <h1><?php esc_html_e( 'Export Zip', 'advanced-export' ); ?></h1> 45 46 <p><?php esc_html_e( 'When you click the button below Plugin will create a Zip file to save to your computer.', 'advanced-export' ); ?></p> 47 <p><?php esc_html_e( 'Once you’ve saved the download zip file, you can use the Import function in another WordPress installation to import the content from this site.', 'advanced-export' ); ?></p> 48 49 <h2><?php esc_html_e( 'Choose what to export', 'advanced-export' ); ?></h2> 43 50 <form method="post" id="advanced-export-filters" action=""> 44 51 <?php 45 52 wp_nonce_field( 'advanced-export' ); 46 53 ?> 47 <legend class="screen-reader-text"><?php esc_html_e( 'Content to export','advanced-export'); ?></legend>54 <legend class="screen-reader-text"><?php esc_html_e( 'Content to export', 'advanced-export' ); ?></legend> 48 55 <fieldset class="single-item"> 49 56 <input type="hidden" name="advanced-export-download" value="true" /> 50 <p><label><input type="radio" name="content" value="all" checked="checked" aria-describedby="all-content-desc" /><?php esc_html_e( 'All content','advanced-export'); ?></label></p>57 <p><label><input type="radio" name="content" value="all" checked="checked" aria-describedby="all-content-desc" /><?php esc_html_e( 'All content', 'advanced-export' ); ?></label></p> 51 58 <p class="description" id="all-content-desc"> 52 <?php esc_html_e( 'This will contain all of your posts, pages, comments, custom fields, terms, navigation menus, and custom posts.','advanced-export'); ?>59 <?php esc_html_e( 'This will contain all of your posts, pages, comments, custom fields, terms, navigation menus, and custom posts.', 'advanced-export' ); ?> 53 60 </p> 54 61 55 <p><label><input type="radio" name="content" value="posts" /> <?php esc_html_e( 'Posts','advanced-export'); ?></label></p>62 <p><label><input type="radio" name="content" value="posts" /> <?php esc_html_e( 'Posts', 'advanced-export' ); ?></label></p> 56 63 <ul id="post-filters" class="advanced-export-filters"> 57 64 <li> 58 65 <label><span class="label-responsive"><?php _e( 'Categories:' ); ?></span> 59 <?php wp_dropdown_categories( array( 'show_option_all' => esc_html__( 'All','advanced-export') ) ); ?>66 <?php wp_dropdown_categories( array( 'show_option_all' => esc_html__( 'All', 'advanced-export' ) ) ); ?> 60 67 </label> 61 68 </li> 62 69 <li> 63 <label><span class="label-responsive"><?php esc_html_e( 'Authors:' ,'advanced-export'); ?></span>70 <label><span class="label-responsive"><?php esc_html_e( 'Authors:', 'advanced-export' ); ?></span> 64 71 <?php 65 72 $authors = $wpdb->get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'post'" ); 66 wp_dropdown_users( array( 67 'include' => $authors, 68 'name' => 'post_author', 69 'multi' => true, 70 'show_option_all' => esc_html__( 'All' ,'advanced-export'), 71 'show' => 'display_name_with_login', 72 ) ); ?> 73 wp_dropdown_users( 74 array( 75 'include' => $authors, 76 'name' => 'post_author', 77 'multi' => true, 78 'show_option_all' => esc_html__( 'All', 'advanced-export' ), 79 'show' => 'display_name_with_login', 80 ) 81 ); 82 ?> 73 83 </label> 74 84 </li> 75 85 <li> 76 86 <fieldset> 77 <legend class="screen-reader-text"><?php esc_html_e( 'Date range:', 'advanced-export' ); ?></legend>78 <label for="post-start-date" class="label-responsive"><?php esc_html_e( 'Start date:', 'advanced-export' ); ?></label>87 <legend class="screen-reader-text"><?php esc_html_e( 'Date range:', 'advanced-export' ); ?></legend> 88 <label for="post-start-date" class="label-responsive"><?php esc_html_e( 'Start date:', 'advanced-export' ); ?></label> 79 89 <select name="post_start_date" id="post-start-date"> 80 <option value="0"><?php esc_html_e( '— Select —', 'advanced-export' ); ?></option>90 <option value="0"><?php esc_html_e( '— Select —', 'advanced-export' ); ?></option> 81 91 <?php advanced_export_date_options(); ?> 82 92 </select> 83 <label for="post-end-date" class="label-responsive"><?php esc_html_e( 'End date:', 'advanced-export' ); ?></label>93 <label for="post-end-date" class="label-responsive"><?php esc_html_e( 'End date:', 'advanced-export' ); ?></label> 84 94 <select name="post_end_date" id="post-end-date"> 85 <option value="0"><?php esc_html_e( '— Select —', 'advanced-export' ); ?></option>95 <option value="0"><?php esc_html_e( '— Select —', 'advanced-export' ); ?></option> 86 96 <?php advanced_export_date_options(); ?> 87 97 </select> … … 89 99 </li> 90 100 <li> 91 <label for="post-status" class="label-responsive"><?php esc_html_e( 'Status:', 'advanced-export'); ?></label>101 <label for="post-status" class="label-responsive"><?php esc_html_e( 'Status:', 'advanced-export' ); ?></label> 92 102 <select name="post_status" id="post-status"> 93 <option value="0"><?php esc_html_e( 'All','advanced-export' ); ?></option> 94 <?php $post_stati = get_post_stati( array( 'internal' => false ), 'objects' ); 95 foreach ( $post_stati as $status ) : ?> 103 <option value="0"><?php esc_html_e( 'All', 'advanced-export' ); ?></option> 104 <?php 105 $post_stati = get_post_stati( array( 'internal' => false ), 'objects' ); 106 foreach ( $post_stati as $status ) : 107 ?> 96 108 <option value="<?php echo esc_attr( $status->name ); ?>"><?php echo esc_html( $status->label ); ?></option> 97 109 <?php endforeach; ?> … … 100 112 </ul> 101 113 102 <p><label><input type="radio" name="content" value="pages" /> <?php esc_html_e( 'Pages', 'advanced-export' ); ?></label></p>114 <p><label><input type="radio" name="content" value="pages" /> <?php esc_html_e( 'Pages', 'advanced-export' ); ?></label></p> 103 115 <ul id="page-filters" class="advanced-export-filters"> 104 116 <li> 105 <label><span class="label-responsive"><?php esc_html_e( 'Authors:', 'advanced-export' ); ?></span>117 <label><span class="label-responsive"><?php esc_html_e( 'Authors:', 'advanced-export' ); ?></span> 106 118 <?php 107 119 $authors = $wpdb->get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'page'" ); 108 wp_dropdown_users( array( 109 'include' => $authors, 110 'name' => 'page_author', 111 'multi' => true, 112 'show_option_all' =>esc_html__( 'All' ,'advanced-export'), 113 'show' => 'display_name_with_login', 114 ) ); ?> 120 wp_dropdown_users( 121 array( 122 'include' => $authors, 123 'name' => 'page_author', 124 'multi' => true, 125 'show_option_all' => esc_html__( 'All', 'advanced-export' ), 126 'show' => 'display_name_with_login', 127 ) 128 ); 129 ?> 115 130 </label> 116 131 </li> 117 132 <li> 118 133 <fieldset> 119 <legend class="screen-reader-text"><?php esc_html_e( 'Date range:', 'advanced-export' ); ?></legend>120 <label for="page-start-date" class="label-responsive"><?php esc_html_e( 'Start date:' ,'advanced-export'); ?></label>134 <legend class="screen-reader-text"><?php esc_html_e( 'Date range:', 'advanced-export' ); ?></legend> 135 <label for="page-start-date" class="label-responsive"><?php esc_html_e( 'Start date:', 'advanced-export' ); ?></label> 121 136 <select name="page_start_date" id="page-start-date"> 122 <option value="0"><?php esc_html_e( '— Select —', 'advanced-export' ); ?></option>137 <option value="0"><?php esc_html_e( '— Select —', 'advanced-export' ); ?></option> 123 138 <?php advanced_export_date_options( 'page' ); ?> 124 139 </select> 125 <label for="page-end-date" class="label-responsive"><?php esc_html_e( 'End date:', 'advanced-export' ); ?></label>140 <label for="page-end-date" class="label-responsive"><?php esc_html_e( 'End date:', 'advanced-export' ); ?></label> 126 141 <select name="page_end_date" id="page-end-date"> 127 <option value="0"><?php esc_html_e( '— Select —', 'advanced-export' ); ?></option>142 <option value="0"><?php esc_html_e( '— Select —', 'advanced-export' ); ?></option> 128 143 <?php advanced_export_date_options( 'page' ); ?> 129 144 </select> … … 131 146 </li> 132 147 <li> 133 <label for="page-status" class="label-responsive"><?php esc_html_e( 'Status:', 'advanced-export' ); ?></label>148 <label for="page-status" class="label-responsive"><?php esc_html_e( 'Status:', 'advanced-export' ); ?></label> 134 149 <select name="page_status" id="page-status"> 135 <option value="0"><?php esc_html_e( 'All' ,'advanced-export'); ?></option>150 <option value="0"><?php esc_html_e( 'All', 'advanced-export' ); ?></option> 136 151 <?php foreach ( $post_stati as $status ) : ?> 137 152 <option value="<?php echo esc_attr( $status->name ); ?>"><?php echo esc_html( $status->label ); ?></option> … … 141 156 </ul> 142 157 143 <?php foreach ( get_post_types( array( '_builtin' => false, 'can_export' => true ), 'objects' ) as $post_type ) : ?> 158 <?php 159 foreach ( get_post_types( 160 array( 161 '_builtin' => false, 162 'can_export' => true, 163 ), 164 'objects' 165 ) as $post_type ) : 166 ?> 144 167 <p><label><input type="radio" name="content" value="<?php echo esc_attr( $post_type->name ); ?>" /> <?php echo esc_html( $post_type->label ); ?></label></p> 145 168 <?php endforeach; ?> 146 169 147 <p><label><input type="radio" name="content" value="attachment" /> <?php esc_html_e( 'Media', 'advanced-export' ); ?></label></p>170 <p><label><input type="radio" name="content" value="attachment" /> <?php esc_html_e( 'Media', 'advanced-export' ); ?></label></p> 148 171 <ul id="attachment-filters" class="advanced-export-filters"> 149 172 <li> 150 173 <fieldset> 151 <legend class="screen-reader-text"><?php esc_html_e( 'Date range:', 'advanced-export' ); ?></legend>152 <label for="attachment-start-date" class="label-responsive"><?php esc_html_e( 'Start date:', 'advanced-export' ); ?></label>174 <legend class="screen-reader-text"><?php esc_html_e( 'Date range:', 'advanced-export' ); ?></legend> 175 <label for="attachment-start-date" class="label-responsive"><?php esc_html_e( 'Start date:', 'advanced-export' ); ?></label> 153 176 <select name="attachment_start_date" id="attachment-start-date"> 154 <option value="0"><?php esc_html_e( '— Select —', 'advanced-export' ); ?></option>177 <option value="0"><?php esc_html_e( '— Select —', 'advanced-export' ); ?></option> 155 178 <?php advanced_export_date_options( 'attachment' ); ?> 156 179 </select> 157 <label for="attachment-end-date" class="label-responsive"><?php esc_html_e( 'End date:', 'advanced-export' ); ?></label>180 <label for="attachment-end-date" class="label-responsive"><?php esc_html_e( 'End date:', 'advanced-export' ); ?></label> 158 181 <select name="attachment_end_date" id="attachment-end-date"> 159 <option value="0"><?php esc_html_e( '— Select —', 'advanced-export' ); ?></option>182 <option value="0"><?php esc_html_e( '— Select —', 'advanced-export' ); ?></option> 160 183 <?php advanced_export_date_options( 'attachment' ); ?> 161 184 </select> … … 167 190 <fieldset class="single-item"> 168 191 <input type="checkbox" name="widgets_data" id="widgets_data" value="1" checked> 169 <label for="widgets_data" class="label-responsive"><?php esc_html_e( 'Widget Data', 'advanced-export' ); ?></label>192 <label for="widgets_data" class="label-responsive"><?php esc_html_e( 'Widget Data', 'advanced-export' ); ?></label> 170 193 </fieldset> 171 194 <fieldset class="single-item"> 172 195 <input type="checkbox" id="options_data" name="options_data" value="1" checked> 173 <label for="options_data" class="label-responsive"><?php esc_html_e( 'Customizer/Options Data', 'advanced-export' ); ?></label>174 </fieldset> 175 <fieldset class="single-item">176 <input type="checkbox" name="include_media" id="include_media" value="1">177 <label for="include_media" class="label-responsive"><?php esc_html_e( 'Include Media' ,'advanced-export'); ?></label>178 </fieldset>196 <label for="options_data" class="label-responsive"><?php esc_html_e( 'Customizer/Options Data', 'advanced-export' ); ?></label> 197 </fieldset> 198 <fieldset class="single-item"> 199 <input type="checkbox" name="include_media" id="include_media" value="1"> 200 <label for="include_media" class="label-responsive"><?php esc_html_e( 'Include Media', 'advanced-export' ); ?></label> 201 </fieldset> 179 202 <?php 180 203 do_action( 'advanced_export_form' ); 181 submit_button( esc_html__( 'Download Export File','advanced-export') );204 submit_button( esc_html__( 'Download Export File', 'advanced-export' ) ); 182 205 ?> 183 206 </form> -
advanced-export/trunk/advanced-export.php
r2328319 r2519583 15 15 * Plugin URI: https://addonspress.com/item/advanced-export 16 16 * Description: Advanced Export with Options to Export Widget, Customizer and Media Files 17 * Version: 1.0. 317 * Version: 1.0.4 18 18 * Author: AddonsPress 19 19 * Author URI: https://addonspress.com/ … … 25 25 26 26 /*Define Constants for this plugin*/ 27 define( 'ADVANCED_EXPORT_VERSION', '1.0. 3' );27 define( 'ADVANCED_EXPORT_VERSION', '1.0.4' ); 28 28 define( 'ADVANCED_EXPORT_PATH', plugin_dir_path( __FILE__ ) ); 29 29 define( 'ADVANCED_EXPORT_URL', plugin_dir_url( __FILE__ ) ); 30 30 31 $upload_dir = wp_upload_dir();32 $advanced_export_temp =$upload_dir['basedir'] . '/advanced-export-temp/';33 $advanced_export_temp_uploads = $advanced_export_temp . '/uploads/';31 $upload_dir = wp_upload_dir(); 32 $advanced_export_temp = $upload_dir['basedir'] . '/advanced-export-temp/'; 33 $advanced_export_temp_uploads = $advanced_export_temp . '/uploads/'; 34 34 35 35 define( 'ADVANCED_EXPORT_TEMP', $advanced_export_temp ); -
advanced-export/trunk/includes/class-advanced-export-activator.php
r2159845 r2519583 33 33 34 34 } 35 36 35 } -
advanced-export/trunk/includes/class-advanced-export-deactivator.php
r2159845 r2519583 33 33 34 34 } 35 36 35 } -
advanced-export/trunk/includes/class-advanced-export-i18n.php
r2159845 r2519583 40 40 dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' 41 41 ); 42 43 42 } 44 43 } -
advanced-export/trunk/includes/class-advanced-export.php
r2159845 r2519583 130 130 private function setup_globals() { 131 131 132 $this->version = defined('ADVANCED_EXPORT_VERSION')?ADVANCED_EXPORT_VERSION:'1.0.0';132 $this->version = defined( 'ADVANCED_EXPORT_VERSION' ) ? ADVANCED_EXPORT_VERSION : '1.0.0'; 133 133 $this->plugin_name = 'advanced-export'; 134 134 135 135 //The array of actions and filters registered with this plugins. 136 136 $this->actions = array(); … … 138 138 139 139 // Misc 140 $this->domain = 'advanced-export'; // Unique identifier for retrieving translated strings141 $this->errors = new WP_Error(); // errors140 $this->domain = 'advanced-export'; // Unique identifier for retrieving translated strings 141 $this->errors = new WP_Error(); // errors 142 142 } 143 143 … … 216 216 $this->loader->add_action( 'admin_enqueue_scripts', $this->admin, 'enqueue_scripts' ); 217 217 $this->loader->add_action( 'admin_menu', $this->admin, 'export_menu' ); 218 $this->loader->add_action( 'admin_init', $this->admin, 'export_content', 1 );218 $this->loader->add_action( 'admin_init', $this->admin, 'export_content', 1 ); 219 219 $this->loader->add_action( 'wp_ajax_advanced_export_ajax_form_load', $this->admin, 'form_load' ); 220 220 } -
advanced-export/trunk/readme.txt
r2328319 r2519583 5 5 Tags: export, advanced export, demo export, theme export, widget export, customizer export 6 6 Requires at least: 4.5 7 Tested up to: 5. 4.27 Tested up to: 5.7.1 8 8 Requires PHP: 5.6.20 9 Stable tag: 1.0. 39 Stable tag: 1.0.4 10 10 License: GPLv2 or later 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 118 118 == Changelog == 119 119 120 = 1.0.4 - 2021-04-22 = 121 * Updated : PHPCS 122 120 123 = 1.0.3 - 2020-06-22 = 121 124 * Updated : Export post types order
Note: See TracChangeset
for help on using the changeset viewer.