• Resolved no2s13

    (@no2s13)


    Hi there

    When I try to add the target="_blank" attribute in a “Consent” field, it disappears immediately after updating the form.

    For example, if I add the following code to a “Consent” field: “<p>By checking this box, I acknowledge that I have read and accepted the <a href=”terms_link” target=”_blank” rel=”noopener nofollow”>Terms and Conditions</a></p>”, and then update the form, the link to the Terms and Conditions will not have the target="_blank" attribute; it automatically gets removed after the update.

    Can you please help me with this?

    Thank you very much.

    • This topic was modified 1 year, 5 months ago by no2s13.
    • This topic was modified 1 year, 5 months ago by no2s13.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @no2s13

    I hope you’re well today!

    There is a bug related to data sanitization there that causes stripping out this attribute when edited. Our Forminator Team is already aware of the issue but I don’t have ETA on the fix yet.

    A patch for now would be to add this code to the site as MU plugin:

    <?php 
    
    add_filter( 'forminator_field_consent_markup', 'forminator_field_consent_markup_target_blank', 11, 1 );
    function forminator_field_consent_markup_target_blank( $html ) {
    	
    	$html = str_replace( '<a', '<a target="_blank" ', $html );
    	
    	return $html;	
    	
    }

    – create an empty file with a .php extension (e.g. “forminator-consent-target-blank.php”)
    – copy and paste code into it
    – upload the file to the “/wp-content/mu-plugins” folder of your site’s WordPress installation.

    Once the code is there, every link that you put into the “consent” field will have target="_blank" automatically added to it on front-end (even despite being saved without it) so they’ll open in new tabs.

    Best regards,
    Adam

    Thread Starter no2s13

    (@no2s13)

    Thanks for your reply.

    I already fixed it by adding into Consent.php file (line 114) : $description = str_replace(‘<a ‘, ‘<a target=”_blank” ‘, $description);

    Regards,
    Julien

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @no2s13

    That would work of course but it’s never recommended to edit plugin core files directly and we never suggest such solutions.

    If you’re fine with it, that’s okay but just remember that an update to the plugin will wipe out your changes right away and if the fix is not included in such update (unfortunately, I don’t know in which version it will be yet), you’ll have to re-apply it.

    The Must-Use plugin solution, on the other hand, will “survive” update.

    Best regards,
    Adam

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @no2s13 ,

    We haven’t heard from you for several days now, so it looks like you don’t have more questions for us.

    Feel free to re-open this topic if needed.

    Kind regards
    Kasia

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Target=”_blank” removed automaticly’ is closed to new replies.