PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.3
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / admin / advanced-settings / includes / shortcodes / compare.php

compare.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 4.0.3, at admin/advanced-settings/includes/shortcodes/compare.php

56 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // Exit if accessed directly
3 if ( ! defined( 'ABSPATH' ) ) exit;
4
5 add_shortcode( 'compare', 'wppb_toolbox_compare_shortcode' );
6 function wppb_toolbox_compare_shortcode( $atts, $content ){
7
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('&#8221;', '', $value );
16 }
17
18 $l = $atts['val1'];
19 $r = $atts['val2'];
20
21 $operators = array(
22 '==' => function($l, $r) {
23 return $l == $r;
24 },
25 '===' => function($l, $r) {
26 return $l === $r;
27 },
28 '!=' => function($l, $r) {
29 return $l != $r;
30 },
31 '<' => function($l, $r) {
32 return $l < $r;
33 },
34 '>' => function($l, $r) {
35 return $l > $r;
36 },
37 '<=' => function($l, $r) {
38 return $l <= $r;
39 },
40 '>=' => function($l, $r) {
41 return $l >= $r;
42 },
43 '' => function($l, $r) {
44 return $l == $r;
45 },
46 );
47
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: == , ===, !=, <, >, <=, >=';
50
51 $bool = $operators[$atts['operator']]($l, $r);
52
53 if( $bool )
54 return do_shortcode( $content );
55 }
56