• Resolved pinkhare

    (@pinkhare)


    Users might lose settings while they are working with their options this framework. To prevent that situation from occuring, the framework needs to popup a new window and show the link on it when users click an external link. But there’s no ‘target’ attribute on any anchor tag in the browser-generated source code. It seems that the framework removes the ‘target’ attributes on anchor tags internally, so I wish it would be fixed quickly.

    https://www.ads-software.com/plugins/options-framework/

Viewing 3 replies - 1 through 3 (of 3 total)
  • I assume you are talking about a link that is entered in the “desc” field stripping tags from your HTML code.

    I’ve run in to this problem myself, and it is difficult to deal with as there is a lack of action/filters to fix the problem.

    The “desc” field is sanitized via wp_kses, allowing only tags in the global $allowedtags variable. Unfortunately this variable is very strict, and removes most attributes, including “target”.

    This plugin should not sanitize the field at all. Why would you sanitize code that is hard coded into the script? Sanitize user input, not source code…!

    Anyway, the code below should help. It temporarily replaces the $allowtags “whitelist” with a more lineant variant, $allowedposttags. Many more elements and attributes are trusted here, so you will have more freedom.

    Just drop this code in to your functions.php file, then you can use the “target” attribute on your links. This code only runs on the options framework page. It starts when the page options framework section starts, and stops when options framework is done. So other plugins should not be affected.

    function rad_of_add_better_kses() {
      add_action('optionsframework_after', 'rad_of_remove_better_kses'); // Will remove this hook when OF is done
    
      // Hold on to $allowedtags in another variable, temporarily replacing the original value while Options Framework is displaying the interface
      global $allowedtags, $allowedposttags, $rad_temp_allowedtags;
      $rad_temp_allowedtags = $allowedtags;
      $allowedtags = $allowedposttags;
    }
    function rad_of_remove_better_kses() {
      // Options framework is done displaying the interface, reset $allowedtags as to not interfere with other plugins.
      global $allowedtags, $rad_temp_allowedtags;
      $allowedtags = $rad_temp_allowedtags;
    }
    add_action('appearance_page_options-framework', 'rad_of_add_better_kses');
    Thread Starter pinkhare

    (@pinkhare)

    Thank you so much, radgh!
    Your code works and it does exactly what I want.
    Thanks again!!

    Plugin Author Devin Price

    (@downstairsdev)

    Sanitization for desc fields and info options has been removed:
    https://github.com/devinsays/options-framework-plugin/commit/03a1a94cc2e00f9064a5511744ef09195bed39e5

    Look for it in the next update!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘target="_blank" not working on hyperlink’ is closed to new replies.