Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

When I want to import the XML files with the aid of the WordPress Importer plugin, the blogs imported will lose all the slashes, i.e., "\", which are really contained in the XML files imported.

Since I have to use the LaTeX plug-in (Latex for WordPress plug-in), it becomes terrible.

In fact, maybe weeks ago, it worked well. There was no such problem at all. But from one day, I find that all changed. TT

Is there any one who know what's happening? Thank you very much!

share|improve this question
    
Are the slashes removed during import or are they imported and just not displayed? Does it happen if you use TwentyEleven and disable all other plugins? –  toscho Apr 28 '12 at 14:53
    
Yes, they all disappeared during import. I tried, i.e., disabled all plug-ins, but the problem is still there. –  shuiruge Apr 29 '12 at 5:03

1 Answer 1

The importer calls wp_insert_post() which runs stripslashes_deep() on the data. But the exporter doesn't run addslashes. Looks like a bug to me.

What you may try is to prepare the data during export.

Create a plugin with the following content and activate it before you run the export:

<?php
/**
 * Plugin Name: Slash my export
 * Description: Adds extra back slashes to exported data.
 */

add_filter( 'the_content_export', 'addslashes' );
add_filter( 'the_excerpt_export', 'addslashes' );

I have not tested this, it may be wrong, it may have side effects. stripslashes_deep() may eat the extra slashes too …

You should open a bug on Trac if this plugin fixes your problem.

share|improve this answer
    
So professional! It can add slashed when export, I guess. While, what I want to do is to add slashes when import. Is there any problem if I add slashes in this way when import, rather than when export? (I guess there is. Because if there is not, there will be no need to run stripslashes_deep() when import. I'm a new guy.) Thanks very much! –  shuiruge Apr 29 '12 at 11:03
    
I'm not sure. You would have to apply addslashes before the slashes are stripped … which happens very early. Because once they are removed there is no way to say where they should have been preserved. Changing the export is much easier. –  toscho Apr 29 '12 at 11:13
    
Thank you for your explanation. I will have a try. –  shuiruge Apr 30 '12 at 6:57
    
@shuiruge Any progress? Did it work? –  toscho Oct 6 '12 at 22:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.