Guest User

sb_root_relative_urls-blacklist-1.diff

a guest
May 2nd, 2014
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. --- sb_root_relative_urls.php
  2. +++ sb_root_relative_urls.php
  3. @@ -116,6 +116,9 @@
  4. //This method is used for urls that can be acceptably reformatted into root-relative urls without causing issues
  5. //related to other deficiencies in the wp core.
  6.  
  7. + if (MP_WP_Root_Relative_URLS::check_blacklist($url, 'http'))
  8. + return $url;
  9. +
  10. if (self::$massage) {
  11. //massage back to absolute because we're rendering a feed and the platform mixes url procurment methods between the delivery methods
  12. //despite offering _rss specific filters
  13. @@ -180,6 +183,22 @@
  14. return $o;
  15. }
  16.  
  17. + static function check_blacklist($url, $str_prefix = false) {
  18. + $emc2_blacklist_urls = get_option('emc2_blacklist_urls');
  19. + if ($emc2_blacklist_urls != '') {
  20. + $emc2_blacklist_urls = explode("\n", $emc2_blacklist_urls);
  21. +
  22. + foreach ($emc2_blacklist_urls as &$blacklist_url) {
  23. + if ($str_prefix && substr($blacklist_url, 0, strlen($str_prefix)) !== $str_prefix)
  24. + continue;
  25. +
  26. + if (stripos($url, trim($blacklist_url)) !== false)
  27. + return true;
  28. + }
  29. + }
  30. + return false;
  31. + }
  32. +
  33. static function init() {
  34.  
  35. add_action('admin_init', array( 'MP_WP_Root_Relative_URLS', 'admin_settings_init' ));
  36. @@ -187,7 +206,7 @@
  37. //Here we check the url blacklist to disable proper root relative urls, this helps with certain 3rd party
  38. //plugins / certain clients for rss feeds
  39. $cur_url = MP_WP_Root_Relative_URLS::dynamic_absolute_url(@$_SERVER['REQUEST_URI']);
  40. - if (stripos(get_option('emc2_blacklist_urls'), $cur_url) !== false) {
  41. + if (MP_WP_Root_Relative_URLS::check_blacklist($cur_url, '/')) {
  42. //for blacklists, create a dynamic but full absolute url instead
  43. self::$massage = true;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment