PluginProbe
Pixel Gallery Addons for Elementor – Easy Grid, Creative Gallery, Drag and Drop Grid, Custom Grid Layout, Portfolio Gallery / trunk
Pixel Gallery Addons for Elementor – Easy Grid, Creative Gallery, Drag and Drop Grid, Custom Grid Layout, Portfolio Gallery vtrunk
2.1.14 2.1.13 2.1.12 2.1.11 2.1.10 2.1.9 2.1.8 2.1.7 trunk 1.2.2 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.4.0 1.4.1 1.4.10 1.4.11 1.4.2 1.4.3 1.4.5 1.4.6 All 74 releases
pixel-gallery / base / condition.php

condition.php in Pixel Gallery Addons for Elementor – Easy Grid, Creative Gallery, Drag and Drop Grid, Custom Grid Layout, Portfolio Gallery trunk, at base/condition.php

130 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace PixelGallery\Base;
3
4 // Elementor Classes
5 use Elementor\Controls_Manager;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit; // Exit if accessed directly
9 }
10
11 /**
12 * \Base\Condition
13 * @since 5.3.0
14 */
15 abstract class Condition {
16
17 /**
18 * @var Module_Base
19 */
20 protected static $_instances = [];
21
22 protected $element_id;
23
24 /**
25 * @return string of the current module class name
26 * @since 5.3.0
27 */
28 public static function class_name() {
29 return get_called_class();
30 }
31
32 /**
33 * @return static
34 */
35 public static function instance() {
36 if ( empty( static::$_instances[ static::class_name() ] ) ) {
37 static::$_instances[ static::class_name() ] = new static();
38 }
39
40 return static::$_instances[ static::class_name() ];
41 }
42
43 /**
44 * Defaults to true
45 * @return bool if current condition is supported
46 * @since 5.3.0
47 */
48 public static function is_supported() {
49 return true;
50 }
51
52 /**
53 * Get the name of condition
54 * @return string as per our condition control name
55 * @since 5.3.0
56 */
57 public function get_name() {}
58
59 /**
60 * Get the title of condition
61 * @return string as per condition control title
62 * @since 5.3.0
63 */
64 public function get_title() {}
65
66 /**
67 * Get the control name
68 * @return string as per condition control name
69 * @since 5.3.0
70 */
71 public function get_name_control() {
72 return false; }
73
74 /**
75 * Get the control value
76 * @return string as per condition control value
77 * @since 5.3.0
78 */
79 public function get_value_control() {}
80
81 /**
82 * Check the condition
83 * @param string $relation Comparison operator for compare function
84 * @param mixed $val will check the control value as per condition needs
85 * @since 5.3.0
86 */
87 public function check( $relation, $val ) {}
88
89 /**
90 * Compare conditions.
91 * Calls compare method
92 * @param mixed $left_val First value to compare.
93 * @param mixed $right_val Second value to compare.
94 * @param string $relation Comparison operator.
95 * @return bool
96 * @since 5.3.0
97 *
98 */
99 public function compare( $left_val, $right_val, $relation ) {
100 switch ( $relation ) {
101 case 'is':
102 return $left_val == $right_val;
103 case 'not':
104 return $left_val != $right_val;
105 default:
106 return $left_val === $right_val;
107 }
108 }
109
110 /**
111 * Set Condition Element ID
112 * Set the element ID for this condition
113 * @return string
114 * @since 5.3.0
115 */
116 public function set_element_id( $id ) {
117 $this->element_id = $id;
118 }
119
120 /**
121 * Get Condition Element ID
122 * Returns the previously set element id
123 * @return string
124 * @since 5.3.0
125 */
126 protected function get_element_id() {
127 return $this->element_id;
128 }
129 }
130