Changeset 3632355
- Timestamp:
- 08/03/2026 05:59:43 AM (3 months ago)
- Location:
- magic-export-import
- Files:
-
- 66 added
- 8 edited
-
tags/2.0.4 (added)
-
tags/2.0.4/.DS_Store (added)
-
tags/2.0.4/LICENSE (added)
-
tags/2.0.4/assets (added)
-
tags/2.0.4/assets/.DS_Store (added)
-
tags/2.0.4/assets/loader.svg (added)
-
tags/2.0.4/assets/magic-export-import.js (added)
-
tags/2.0.4/assets/magic-export-import.min.css (added)
-
tags/2.0.4/assets/magic-export-import.min.css.map (added)
-
tags/2.0.4/assets/magic-export-import.min.js (added)
-
tags/2.0.4/assets/magic-export-import.scss (added)
-
tags/2.0.4/assets/select2 (added)
-
tags/2.0.4/assets/select2/select2.min.css (added)
-
tags/2.0.4/assets/select2/select2.min.js (added)
-
tags/2.0.4/assets/vis (added)
-
tags/2.0.4/assets/vis/vis-network.min.css (added)
-
tags/2.0.4/assets/vis/vis-network.min.js (added)
-
tags/2.0.4/cache (added)
-
tags/2.0.4/cache/.DS_Store (added)
-
tags/2.0.4/cache/.htaccess (added)
-
tags/2.0.4/cache/index.php (added)
-
tags/2.0.4/class-magic-ex-im-setup.php (added)
-
tags/2.0.4/includes (added)
-
tags/2.0.4/includes/.DS_Store (added)
-
tags/2.0.4/includes/class-magic-ex-im-cache.php (added)
-
tags/2.0.4/includes/class-magic-ex-im-data.php (added)
-
tags/2.0.4/includes/class-magic-ex-im-type.php (added)
-
tags/2.0.4/includes/magic-ex-im-fallback-functions.php (added)
-
tags/2.0.4/includes/magic-ex-im-functions.php (added)
-
tags/2.0.4/includes/magic-types (added)
-
tags/2.0.4/includes/magic-types/class-magic-ex-im-type-acf-options-pages.php (added)
-
tags/2.0.4/includes/magic-types/class-magic-ex-im-type-comments.php (added)
-
tags/2.0.4/includes/magic-types/class-magic-ex-im-type-menus.php (added)
-
tags/2.0.4/includes/magic-types/class-magic-ex-im-type-posts.php (added)
-
tags/2.0.4/includes/magic-types/class-magic-ex-im-type-shop-orders.php (added)
-
tags/2.0.4/includes/magic-types/class-magic-ex-im-type-terms.php (added)
-
tags/2.0.4/includes/magic-types/class-magic-ex-im-type-users.php (added)
-
tags/2.0.4/includes/plugin-adapters (added)
-
tags/2.0.4/includes/plugin-adapters/.DS_Store (added)
-
tags/2.0.4/includes/plugin-adapters/class-magic-ex-im-adapter-acf.php (added)
-
tags/2.0.4/includes/plugin-adapters/class-magic-ex-im-adapter-cf7.php (added)
-
tags/2.0.4/includes/plugin-adapters/class-magic-ex-im-adapter-polylang.php (added)
-
tags/2.0.4/includes/plugin-adapters/class-magic-ex-im-adapter-wc-bexio-automator.php (added)
-
tags/2.0.4/includes/plugin-adapters/class-magic-ex-im-adapter-woocommerce.php (added)
-
tags/2.0.4/includes/plugin-adapters/class-magic-ex-im-adapter-yoast-seo.php (added)
-
tags/2.0.4/includes/trait-magic-ex-im-singleton.php (added)
-
tags/2.0.4/languages (added)
-
tags/2.0.4/languages/magic-export-import.pot (added)
-
tags/2.0.4/readme.txt (added)
-
tags/2.0.4/template-parts (added)
-
tags/2.0.4/template-parts/.DS_Store (added)
-
tags/2.0.4/template-parts/advanced-filters (added)
-
tags/2.0.4/template-parts/advanced-filters/advanced-filters-comments.php (added)
-
tags/2.0.4/template-parts/advanced-filters/advanced-filters-posts.php (added)
-
tags/2.0.4/template-parts/advanced-filters/advanced-filters-shop-orders.php (added)
-
tags/2.0.4/template-parts/advanced-filters/advanced-filters-terms-polylang.php (added)
-
tags/2.0.4/template-parts/advanced-filters/advanced-filters-terms.php (added)
-
tags/2.0.4/template-parts/advanced-filters/advanced-filters-toggler.php (added)
-
tags/2.0.4/template-parts/advanced-filters/advanced-filters-users.php (added)
-
tags/2.0.4/template-parts/export-progress.php (added)
-
tags/2.0.4/template-parts/import-progress.php (added)
-
tags/2.0.4/template-parts/page-content.php (added)
-
tags/2.0.4/template-parts/select-export-keys.php (added)
-
tags/2.0.4/template-parts/select-export-media-keys.php (added)
-
tags/2.0.4/template-parts/select-export-related-keys.php (added)
-
tags/2.0.4/template-parts/select.php (added)
-
trunk/class-magic-ex-im-setup.php (modified) (1 diff)
-
trunk/includes/magic-types/class-magic-ex-im-type-comments.php (modified) (3 diffs)
-
trunk/includes/magic-types/class-magic-ex-im-type-menus.php (modified) (3 diffs)
-
trunk/includes/magic-types/class-magic-ex-im-type-posts.php (modified) (3 diffs)
-
trunk/includes/magic-types/class-magic-ex-im-type-terms.php (modified) (3 diffs)
-
trunk/includes/magic-types/class-magic-ex-im-type-users.php (modified) (3 diffs)
-
trunk/includes/plugin-adapters/class-magic-ex-im-adapter-acf.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
magic-export-import/trunk/class-magic-ex-im-setup.php
r3610286 r3632355 3 3 * Plugin Name: Magic Export & Import 4 4 * Description: The ultimate tool to migrate any content including posts, terms, users, comments, WooCommerce shop orders, menus and ACF Options pages. 5 * Version: 2.0. 35 * Version: 2.0.4 6 6 * Requires at least: 6.2 7 7 * Requires PHP: 7.4 -
magic-export-import/trunk/includes/magic-types/class-magic-ex-im-type-comments.php
r3599178 r3632355 502 502 $item_data['comment']['comment_ID'] = $item_id; 503 503 504 $updated = wp_update_comment( $item_data['comment'] ); 504 // Slash the data since wp_update_comment() unslashes it. 505 $updated = wp_update_comment( wp_slash( $item_data['comment'] ) ); 505 506 return is_numeric( $updated ) ? $item_id : $updated; 506 507 } … … 513 514 protected function create_new_item( $item_data ) { 514 515 515 $comment_id = wp_insert_comment( $item_data['comment'] ); 516 // Slash the data since wp_insert_comment() unslashes it. 517 $comment_id = wp_insert_comment( wp_slash( $item_data['comment'] ) ); 516 518 517 519 return $comment_id; … … 531 533 // Skip meta if value is empty and meta doesn't exist (don't create new empty meta). 532 534 if ( $value || is_numeric( $value ) || metadata_exists( 'comment', $item_id, $meta_key ) ) { 533 update_comment_meta( $item_id, $meta_key, $value ); 535 // Slash the value since update_comment_meta() unslashes it. 536 update_comment_meta( $item_id, $meta_key, wp_slash( $value ) ); 534 537 } 535 538 } -
magic-export-import/trunk/includes/magic-types/class-magic-ex-im-type-menus.php
r3607033 r3632355 584 584 } 585 585 586 $menu_item['ID'] = wp_update_nav_menu_item( $item_id, 0, $menu_item_data ); 586 // Slash the data since wp_update_nav_menu_item() passes it to wp_insert_post(), which unslashes it. 587 $menu_item['ID'] = wp_update_nav_menu_item( $item_id, 0, wp_slash( $menu_item_data ) ); 587 588 588 589 if ( is_wp_error( $menu_item['ID'] ) ) { … … 603 604 // Skip meta if value is empty and meta doesn't exist (don't create new empty meta). 604 605 if ( $meta_value || is_numeric( $meta_value ) || metadata_exists( 'post', $menu_item['ID'], $meta_key ) ) { 605 update_post_meta( $menu_item['ID'], $meta_key, $meta_value ); 606 // Slash the value since update_post_meta() unslashes it. 607 update_post_meta( $menu_item['ID'], $meta_key, wp_slash( $meta_value ) ); 606 608 } 607 609 } … … 655 657 // Skip meta if value is empty and meta doesn't exist (don't create new empty meta). 656 658 if ( $value || is_numeric( $value ) || metadata_exists( 'term', $item_id, $meta_key ) ) { 657 update_term_meta( $item_id, $meta_key, $value ); 659 // Slash the value since update_term_meta() unslashes it. 660 update_term_meta( $item_id, $meta_key, wp_slash( $value ) ); 658 661 } 659 662 } -
magic-export-import/trunk/includes/magic-types/class-magic-ex-im-type-posts.php
r3608651 r3632355 858 858 $item_data['post']['ID'] = $item_id; 859 859 860 return wp_update_post( $item_data['post'] ); 860 // Slash the data since wp_update_post() unslashes it (e.g. backslashes 861 // within the Gutenberg block attributes JSON are eaten otherwise). 862 return wp_update_post( wp_slash( $item_data['post'] ) ); 861 863 } 862 864 … … 874 876 } 875 877 876 return wp_insert_post( $item_data['post'] ); 878 // Slash the data since wp_insert_post() unslashes it (e.g. backslashes 879 // within the Gutenberg block attributes JSON are eaten otherwise). 880 return wp_insert_post( wp_slash( $item_data['post'] ) ); 877 881 } 878 882 … … 890 894 // Skip meta if value is empty and meta doesn't exist (don't create new empty meta). 891 895 if ( $value || is_numeric( $value ) || metadata_exists( 'post', $item_id, $meta_key ) ) { 892 update_post_meta( $item_id, $meta_key, $value ); 896 // Slash the value since update_post_meta() unslashes it. 897 update_post_meta( $item_id, $meta_key, wp_slash( $value ) ); 893 898 } 894 899 } -
magic-export-import/trunk/includes/magic-types/class-magic-ex-im-type-terms.php
r3599178 r3632355 357 357 protected function update_existing_item( $item_data, $item_id ) { 358 358 359 $updated_term = wp_update_term( $item_id, $this->magic_item, $item_data['term'] ); 359 // Slash the data since wp_update_term() unslashes it. 360 $updated_term = wp_update_term( $item_id, $this->magic_item, wp_slash( $item_data['term'] ) ); 360 361 361 362 return is_wp_error( $updated_term ) ? $updated_term : $updated_term['term_id']; … … 369 370 protected function create_new_item( $item_data ) { 370 371 371 $created_term = wp_insert_term( $item_data['term']['name'], $this->magic_item, $item_data['term'] ); 372 // Slash the data since wp_insert_term() unslashes it. 373 $created_term = wp_insert_term( wp_slash( $item_data['term']['name'] ), $this->magic_item, wp_slash( $item_data['term'] ) ); 372 374 373 375 return is_wp_error( $created_term ) ? $created_term : $created_term['term_id']; … … 387 389 // Skip meta if value is empty and meta doesn't exist (don't create new empty meta). 388 390 if ( $value || is_numeric( $value ) || metadata_exists( 'term', $item_id, $meta_key ) ) { 389 update_term_meta( $item_id, $meta_key, $value ); 391 // Slash the value since update_term_meta() unslashes it. 392 update_term_meta( $item_id, $meta_key, wp_slash( $value ) ); 390 393 } 391 394 } -
magic-export-import/trunk/includes/magic-types/class-magic-ex-im-type-users.php
r3599178 r3632355 347 347 $item_data['user']['ID'] = $item_id; 348 348 349 $user_id = wp_update_user( $item_data['user'] ); 349 // Slash the data since wp_update_user() unslashes it. 350 $user_id = wp_update_user( wp_slash( $item_data['user'] ) ); 350 351 $this->update_user_password( $user_id, $item_data['user'] ); 351 352 … … 365 366 } 366 367 367 $user_id = wp_insert_user( $item_data['user'] ); 368 // Slash the data since wp_insert_user() unslashes it. 369 $user_id = wp_insert_user( wp_slash( $item_data['user'] ) ); 368 370 $this->update_user_password( $user_id, $item_data['user'] ); 369 371 … … 384 386 // Skip meta if value is empty and meta doesn't exist (don't create new empty meta). 385 387 if ( $value || is_numeric( $value ) || metadata_exists( 'user', $item_id, $meta_key ) ) { 386 update_user_meta( $item_id, $meta_key, $value ); 388 // Slash the value since update_user_meta() unslashes it. 389 update_user_meta( $item_id, $meta_key, wp_slash( $value ) ); 387 390 } 388 391 } -
magic-export-import/trunk/includes/plugin-adapters/class-magic-ex-im-adapter-acf.php
r3599178 r3632355 175 175 176 176 // Encode modified JSON back to string (refer to @see tag). 177 // No slashing compensation is needed here anymore: the import write 178 // paths (wp_insert_post(), update_post_meta(), update_field()) receive 179 // wp_slash()-ed data now, covering the whole content uniformly. 177 180 $modified_json_str = serialize_block_attributes( $json_data ); 178 179 // Prepare content for the wp_unslash() using under wp_insert_post().180 if ( magic_ex_im_is_import() ) {181 $modified_json_str = str_replace( '\\', '\\\\', $modified_json_str );182 }183 181 184 182 // Reconstruct the full block with modified JSON. … … 1426 1424 1427 1425 if ( $item_acf_id ) { 1428 update_field( $field_name, $value, $item_acf_id ); 1426 // Slash the value since acf_update_metadata() unslashes it for both 1427 // the meta and the options page storage. 1428 update_field( $field_name, wp_slash( $value ), $item_acf_id ); 1429 1429 } 1430 1430 } -
magic-export-import/trunk/readme.txt
r3610286 r3632355 6 6 Tested up to: 7.0 7 7 Requires PHP: 7.4 8 Stable tag: 2.0. 38 Stable tag: 2.0.4 9 9 License: GPL v3 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-3.0.txt … … 84 84 85 85 == Changelog == 86 87 = 2.0.4 = 88 * Fix: backslashes in imported content are no longer stripped (e.g. the \n escapes within Gutenberg block attributes JSON, which broke the block custom CSS). All import write calls (posts, meta, comments, users, terms, menu items and ACF fields) now pass properly slashed data to the WordPress functions that unslash it internally; the previous partial workaround for ACF blocks is superseded by this uniform handling. 86 89 87 90 = 2.0.3 =
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)