Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post meta does not imported due to slashes. Added wp_slash to the post and post meta. #161

Conversation

maheshwaghmare
Copy link

@maheshwaghmare maheshwaghmare commented Jul 4, 2018

How to reproduce the issue?

  1. I have create the page with Elementor.
  2. Added the markup in widget like - <h3 class="elementor-heading-title elementor-size-default elementor-inline-editingpen " contenteditable="true "data-elementor-setting-key=.
  3. I have exported the XML from - Tools > Export.
  4. Trying to import it with the WordPress Importer v2.

It skip the page. Because the post meta is not unserialize. Line 1167

Sample page post meta while I have debugging.

{
    "id": "4b41ce4",
    "elType": "widget",
    "settings":
    {
    	"editor": "<h3 class="elementor-heading-title elementor-size-default elementor-inline-editingpen " contenteditable="true "data-elementor-setting-key="..

Quick Fix

I have used below filters to quick fix the issue and created this PR.

add_filter('wp_import_post_data_processed', function( $postdata, $data ) {
	return wp_slash( $postdata );
}, 99, 2 );

add_filter('wxr_importer.pre_process.post_meta', function( $meta_item, $post_id ) {
	return wp_slash( $meta_item );
}, 99, 2 );

Why this PR?

Because, If I imported the XML with the OLD WordPoress Importer it import the XML which DOES NOT imported with the NEW WordPoress Importer 2.

After debugging I found that the $postdata have not added wp_slash() which is added in old importer $postdata. It is missing from the $meta_item too. I have added both in this patch.

@rmccue
Copy link
Member

rmccue commented Mar 4, 2023

Thanks! Closing in favour of #174 for a best practice approach.

@rmccue rmccue closed this Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants