wordpresscustom-wordpress-pageswp-editor

Wordpress Editor drop hyperlinks when editing post


This is not a default post or page, it's a custom page using wp_editor as the WYSIWYG along with standard html formfields (start date, end date, start time, end time, etc). The custom form posts to a custom table (this table is shared with a 3rd part resource so it was coded outside of the standard wordpress tables). The form inserts a "notice" into the custom table and those notices are displayed on the client's web site as well as the 3rd party resource. The initial insert and display work just fine however, if you go back and edit one you Notice, the linked text does not work anymore. For example, (verbatim from the client) "say I created a notice and then I realized oh I forgot something and go back to edit it and then update it. Once it is updated and I click on the public notices page, if I click on the "click here to view ____" the link no longer works. Of course just have to go back in and re link it but feels like this shouldn’t be happening :/ especially when the changes we made had nothing to do with the link."

I'm not sure where to start troubleshooting this. My knee jerk reaction is the wp_editor config options but I'm not sure. Below is what the code looks like in the wp_editor when editing:

This is a <a href=\"https://www.google.com\">test</a>.

UPDATED
Requested INIT code:
wp_editor( $content, 'completesubject', $settings = array('textarea_rows'=> '10') );

UPDATED 2
Looks like this is already being done but not sure of the strip_tag tag, I wasn't expecting to see that. $notice = strip_tags( stripslashes( $_POST['notice'] ) );


Solution

  • Try this:

    $content = htmlspecialchars_decode( stripslashes( $content ) );
    wp_editor( $content, 'completesubject', $settings = array('textarea_rows'=> '10') );