← All changes
|
admin/advanced-settings/includes/shortcodes/compare.php
+15
-10
3.9.9
→
4.0.3
View file →
| @@ -1,18 +1,23 @@ | ||
| 1 | 1 | <?php |
| 2 | +// Exit if accessed directly | |
| 3 | +if ( ! defined( 'ABSPATH' ) ) exit; | |
| 2 | 4 | |
| 3 | 5 | add_shortcode( 'compare', 'wppb_toolbox_compare_shortcode' ); |
| 4 | 6 | function wppb_toolbox_compare_shortcode( $atts, $content ){ |
| 5 | - extract( | |
| 6 | - $out = shortcode_atts( array( 'val1' => '', 'val2' => '', 'operator' => ''), $atts ) | |
| 7 | - ); | |
| 8 | 7 | |
| 9 | - foreach($out as $key => $value){ | |
| 10 | - $out[$key] = str_replace('”', '', $value ); | |
| 8 | + $atts = shortcode_atts( array( | |
| 9 | + 'val1' => '', | |
| 10 | + 'val2' => '', | |
| 11 | + 'operator' => '', | |
| 12 | + ), $atts, 'compare' ); | |
| 13 | + | |
| 14 | + foreach($atts as $key => $value){ | |
| 15 | + $atts[$key] = str_replace('”', '', $value ); | |
| 11 | 16 | } |
| 12 | 17 | |
| 13 | - $l = $out['val1']; | |
| 14 | - $r = $out['val2']; | |
| 18 | + $l = $atts['val1']; | |
| 19 | + $r = $atts['val2']; | |
| 15 | 20 | |
| 16 | 21 | $operators = array( |
| 17 | 22 | '==' => function($l, $r) { |
| 18 | 23 | return $l == $r; |
| @@ -39,12 +44,12 @@ | ||
| 39 | 44 | return $l == $r; |
| 40 | 45 | }, |
| 41 | 46 | ); |
| 42 | 47 | |
| 43 | - if ( !array_key_exists($out['operator'], $operators ) ) | |
| 44 | - return '<p>The compare operator <strong style="padding:0 10px;">' . $out["operator"] . '</strong> is not recognized. Please try: == , ===, !=, <, >, <=, >='; | |
| 48 | + if ( !array_key_exists($atts['operator'], $operators ) ) | |
| 49 | + return '<p>The compare operator <strong style="padding:0 10px;">' . esc_html( $atts["operator"] ) . '</strong> is not recognized. Please try: == , ===, !=, <, >, <=, >='; | |
| 45 | 50 | |
| 46 | - $bool = $operators[$out['operator']]($l, $r); | |
| 51 | + $bool = $operators[$atts['operator']]($l, $r); | |
| 47 | 52 | |
| 48 | 53 | if( $bool ) |
| 49 | 54 | return do_shortcode( $content ); |
| 50 | 55 | } |