/var/www/html_us/wp-content/plugins/elementor/core/breakpoints/breakpoint.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
namespace Elementor\Core\Breakpoints;

use 
Elementor\Core\Base\Base_Object;
use 
Elementor\Plugin;
use 
Elementor\Core\Breakpoints\Manager as Breakpoints_Manager;

if ( ! 
defined'ABSPATH' ) ) {
    exit; 
// Exit if accessed directly.
}

class 
Breakpoint extends Base_Object {

    private 
$name;
    private 
$label;
    private 
$default_value;
    private 
$db_key;
    private 
$value;
    private 
$is_custom;
    private 
$direction 'max';
    private 
$is_enabled false;
    private 
$config;

    
/**
     * Get Name
     *
     * @since 3.2.0
     *
     * @return string
     */
    
public function get_name() {
        return 
$this->name;
    }

    
/**
     * Is Enabled
     *
     * Check if the breakpoint is enabled or not. The breakpoint instance receives this data from
     * the Breakpoints Manager.
     *
     * @return bool $is_enabled class variable
     */
    
public function is_enabled() {
        return 
$this->is_enabled;
    }

    
/**
     * Get Label
     *
     * Retrieve the breakpoint label.
     *
     * @since 3.2.0
     *
     * @return string $label class variable
     */
    
public function get_label() {
        return 
$this->label;
    }

    
/**
     * Get Value
     *
     * Retrieve the saved breakpoint value.
     *
     * @since 3.2.0
     *
     * @return int $value class variable
     */
    
public function get_value() {
        if ( ! 
$this->value ) {
            
$this->init_value();
        }

        return 
$this->value;
    }

    
/**
     * Is Custom
     *
     * Check if the breakpoint's value is a custom or default value.
     *
     * @since 3.2.0
     *
     * @return bool $is_custom class variable
     */
    
public function is_custom() {
        if ( ! 
$this->is_custom ) {
            
$this->get_value();
        }

        return 
$this->is_custom;
    }

    
/**
     * Get Default Value
     *
     * Returns the Breakpoint's default value.
     *
     * @since 3.2.0
     *
     * @return int $default_value class variable
     */
    
public function get_default_value() {
        return 
$this->default_value;
    }

    
/**
     * Get Direction
     *
     * Returns the Breakpoint's direction ('min'/'max').
     *
     * @since 3.2.0
     *
     * @return string $direction class variable
     */
    
public function get_direction() {
        return 
$this->direction;
    }

    
/**
     * Set Value
     *
     * Set the `$value` class variable and the `$is_custom` class variable.
     *
     * @since 3.2.0
     *
     * @return int $value class variable
     */
    
private function init_value() {
        
$cached_value Plugin::$instance->kits_manager->get_current_settings$this->db_key );

        if ( 
$cached_value ) {
            
$this->value = (int) $cached_value;

            
$this->is_custom $this->value !== $this->default_value;
        } else {
            
$this->value $this->default_value;

            
$this->is_custom false;
        }

        return 
$this->value;
    }

    public function 
__construct$args ) {
        
$this->name $args['name'];
        
$this->label $args['label'];
        
// Used for CSS generation
        
$this->db_key Breakpoints_Manager::BREAKPOINT_SETTING_PREFIX $args['name'];
        
$this->direction $args['direction'];
        
$this->is_enabled $args['is_enabled'];
        
$this->default_value $args['default_value'];
    }
}