Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. diff --git a/wp-content/plugins/widget-context/widget-context.php b/wp-content/plugins/widget-context/widget-context.php
  2. index 477574a..dd88576 100755
  3. --- a/wp-content/plugins/widget-context/widget-context.php
  4. +++ b/wp-content/plugins/widget-context/widget-context.php
  5. @@ -415,15 +415,47 @@ class widget_context {
  6.  
  7. function context_check_url( $check, $settings ) {
  8.  
  9. + global $wp;
  10. + $current_path = trim( $wp->request );
  11. +
  12. $settings = wp_parse_args(
  13. $settings,
  14. array(
  15. - 'urls' => null
  16. + 'urls' => null,
  17. )
  18. );
  19.  
  20. $urls = trim( $settings['urls'] );
  21.  
  22. + /**
  23. + * Targeted URLs, including URLs negated with "!".
  24. + */
  25. + $urls_all = explode( "\n", $urls );
  26. +
  27. + /**
  28. + * Holds urls negated with not (!).
  29. + */
  30. + $urls_excluded = array();
  31. +
  32. + /**
  33. + * Remove leading "!"" before adding to excluded URL list.
  34. + */
  35. + $charmask = " \t\n\r\0\x0B!";
  36. + foreach ( $urls_all as $url ) {
  37. + if ( 0 === strpos( $url, '!' ) ) {
  38. + $urls_excluded[] = trim( $url, $charmask );
  39. + }
  40. + }
  41. +
  42. + /**
  43. + * Deny widget if current path matches an excluded URL.
  44. + */
  45. + foreach ( $urls_excluded as $not_url ) {
  46. + if ( $current_path === $not_url ) {
  47. + return $check;
  48. + }
  49. + }
  50. +
  51. if ( empty( $urls ) )
  52. return $check;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement