• I am using a form (plugin) I am developing to create and edit posts from the front end. I can use wp_editor to create the post but on the form to edit the created post is where I am having the issue. I can get the post content and echo it out correctly and see it works fine as a debug check but when I pass the content into wp_editor it messes up the image tag in the content string.

    What was < img src=”example300x300.jpg” width=”300″ / > becomes <img class="”example300×300.jpg”” aux=”””” width=””300”” />
    Note the added smart quotes and the different x in the URL.

    I tried removing all double quotes before passing the content to wp_editor which fixed the quotes around the URL but not the ‘x’ and it changed aux=”width=300″.

    I tried turning off all plugins except the ones critical to the page functionality with no effect.

    I tried to turn off wptexturize with no effect.

    The only thing I can find to fix the issue was to comment out line 284 in wp-includes/class-wp-editor.php
    //$content = apply_filters( ‘the_editor_content’, $content, $default_editor );
    But this will only work until the next upgrade because it is in the CORE!

    How do I fix this the right way???

    • This topic was modified 2 years, 6 months ago by dddienst. Reason: Had to escape the example img tag
    • This topic was modified 2 years, 6 months ago by dddienst. Reason: Had to escape the example img tag. 2nd try

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    Quotes within HTML tags need to be the straight kind, not the curly or smart kind. If you’re getting odd modifications of editor content with all plugins deactivated, then the cause is almost certainly due to your theme. It has added a content filter that’s causing your trouble. The correct way to disable unwanted filtering is to identify where the theme adds the problem filter callback function. Knowing how it was added, you can then remove it before you invoke the editor with remove_filter().

    Thread Starter dddienst

    (@dddienst)

    I did a search for add_filter in my theme files then one by one called remove_filter before the wp_editor call. The problem persisted after every try.

    I am not using smart quotes but whatever filter is the problem is adding them without removing the regular quotes and changing my x to multiply symbol. I was not able to disable every plug-in as my form requires a couple to run. However these plugins have tons of filters. PODS and Ultimate Member.

    Moderator bcworkz

    (@bcworkz)

    To successfully remove an added filter, you’d need to ensure the removal call occurs after the callback was added. Simply calling remove_filter() may not be enough. It needs to be called at the right time. Using a large $priority arg for the same hook used to add should do the trick.

    Set up an alternative editor instance that’s not dependent on plugins. You could simply place
    wp_editor('<img src="example300x300.jpg" width="300" />', 'editor_test');
    on a theme template somewhere. Presumably the problem will persist. Then you can disable plugins and swap themes to narrow down the cause.

    Search the source code of the problem module for all instances “the_editor_content” using a recursive full text search tool like grep. Any add_filter() calls in the search results will possibly be the problem callback.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WP_Editor messing up link in content’ is closed to new replies.