Plugin Directory

Changeset 3632355


Ignore:
Timestamp:
08/03/2026 05:59:43 AM (3 months ago)
Author:
kovalchik8
Message:

Version 2.0.4

Location:
magic-export-import
Files:
66 added
8 edited

Legend:

Unmodified
Added
Removed
  • magic-export-import/trunk/class-magic-ex-im-setup.php

    r3610286 r3632355  
    33 * Plugin Name: Magic Export & Import
    44 * 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.3
     5 * Version: 2.0.4
    66 * Requires at least: 6.2
    77 * Requires PHP: 7.4
  • magic-export-import/trunk/includes/magic-types/class-magic-ex-im-type-comments.php

    r3599178 r3632355  
    502502                $item_data['comment']['comment_ID'] = $item_id;
    503503
    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'] ) );
    505506                return is_numeric( $updated ) ? $item_id : $updated;
    506507        }
    … …  
    513514        protected function create_new_item( $item_data ) {
    514515
    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'] ) );
    516518
    517519                return $comment_id;
    … …  
    531533                        // Skip meta if value is empty and meta doesn't exist (don't create new empty meta).
    532534                        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 ) );
    534537                        }
    535538                }
  • magic-export-import/trunk/includes/magic-types/class-magic-ex-im-type-menus.php

    r3607033 r3632355  
    584584                        }
    585585
    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 ) );
    587588
    588589                        if ( is_wp_error( $menu_item['ID'] ) ) {
    … …  
    603604                                        // Skip meta if value is empty and meta doesn't exist (don't create new empty meta).
    604605                                        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 ) );
    606608                                        }
    607609                                }
    … …  
    655657                        // Skip meta if value is empty and meta doesn't exist (don't create new empty meta).
    656658                        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 ) );
    658661                        }
    659662                }
  • magic-export-import/trunk/includes/magic-types/class-magic-ex-im-type-posts.php

    r3608651 r3632355  
    858858                $item_data['post']['ID'] = $item_id;
    859859
    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'] ) );
    861863        }
    862864
    … …  
    874876                }
    875877
    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'] ) );
    877881        }
    878882
    … …  
    890894                        // Skip meta if value is empty and meta doesn't exist (don't create new empty meta).
    891895                        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 ) );
    893898                        }
    894899                }
  • magic-export-import/trunk/includes/magic-types/class-magic-ex-im-type-terms.php

    r3599178 r3632355  
    357357        protected function update_existing_item( $item_data, $item_id ) {
    358358
    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'] ) );
    360361
    361362                return is_wp_error( $updated_term ) ? $updated_term : $updated_term['term_id'];
    … …  
    369370        protected function create_new_item( $item_data ) {
    370371
    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'] ) );
    372374
    373375                return is_wp_error( $created_term ) ? $created_term : $created_term['term_id'];
    … …  
    387389                        // Skip meta if value is empty and meta doesn't exist (don't create new empty meta).
    388390                        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 ) );
    390393                        }
    391394                }
  • magic-export-import/trunk/includes/magic-types/class-magic-ex-im-type-users.php

    r3599178 r3632355  
    347347                $item_data['user']['ID'] = $item_id;
    348348
    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'] ) );
    350351                $this->update_user_password( $user_id, $item_data['user'] );
    351352
    … …  
    365366                }
    366367
    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'] ) );
    368370                $this->update_user_password( $user_id, $item_data['user'] );
    369371
    … …  
    384386                        // Skip meta if value is empty and meta doesn't exist (don't create new empty meta).
    385387                        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 ) );
    387390                        }
    388391                }
  • magic-export-import/trunk/includes/plugin-adapters/class-magic-ex-im-adapter-acf.php

    r3599178 r3632355  
    175175
    176176                        // 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.
    177180                        $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                         }
    183181
    184182                        // Reconstruct the full block with modified JSON.
    … …  
    14261424
    14271425                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 );
    14291429                }
    14301430        }
  • magic-export-import/trunk/readme.txt

    r3610286 r3632355  
    66Tested up to: 7.0
    77Requires PHP: 7.4
    8 Stable tag: 2.0.3
     8Stable tag: 2.0.4
    99License: GPL v3 or later
    1010License URI: https://www.gnu.org/licenses/gpl-3.0.txt
    … …  
    8484
    8585== 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.
    8689
    8790= 2.0.3 =
Note: See TracChangeset for help on using the changeset viewer.