PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.4.3
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.4.3
3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 All 111 releases
templately / includes / Builder / Conditions / Condition.php

Condition.php in Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! 3.4.3, at includes/Builder/Conditions/Condition.php

85 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Templately\Builder\Conditions;
4
5 use Templately\Builder\ThemeBuilder;
6
7 /**
8 * Code Inspiration from Elementor
9 */
10 abstract class Condition {
11 /**
12 * @var ThemeBuilder
13 */
14 protected $builder;
15
16 protected $controls = [];
17 protected $sub_conditions = [];
18
19 public function __construct( $args = [] ) {
20 $this->builder = templately()->theme_builder;
21
22 $this->register_sub_conditions();
23 $this->register_controls();
24 }
25
26 protected function register_sub_conditions() {
27 }
28
29 protected function register_controls() {
30 }
31
32 public function get_priority(): int {
33 return 100;
34 }
35
36 public function get_config(): array {
37 $config = [];
38
39 $config['label'] = $this->get_label();
40 $config['plural_label'] = $this->get_all_label();
41 $config['sub_conditions'] = $this->get_sub_conditions();
42 $config['type'] = $this->get_type();
43 $config['name'] = $this->get_name();
44
45 if ( ! empty( $this->get_controls() ) ) {
46 $config['controls'] = $this->get_controls();
47 }
48
49 return $config;
50 }
51
52 abstract public function get_label(): string;
53
54 public function get_all_label(): string {
55 return $this->get_label();
56 }
57
58 public function get_sub_conditions() {
59 return $this->sub_conditions;
60 }
61
62 abstract public function get_type(): string;
63
64 abstract public function get_name(): string;
65
66 private function get_controls() {
67 return $this->controls;
68 }
69
70 public function check( $args = [] ): bool {
71 return true;
72 }
73
74 public function add_control( $control_name, $control ) {
75 $this->controls[ $control_name ] = $control;
76 }
77
78 /**
79 * @param Condition $condition
80 */
81 public function register_sub_condition( Condition $condition ) {
82 $this->sub_conditions[] = $condition->get_name();
83 $this->builder::$conditions_manager->register_condition_instance( $condition );
84 }
85 }