Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/bdthemes-element-pack/base/condition.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 + namespace ElementPack\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 +