PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.1
Elementor Website Builder – more than just a page builder v3.0.1
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / core / responsive / responsive.php

responsive.php in Elementor Website Builder – more than just a page builder 3.0.1, at core/responsive/responsive.php

168 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Core\Responsive;
3
4 use Elementor\Core\Responsive\Files\Frontend;
5
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit; // Exit if accessed directly.
8 }
9
10 /**
11 * Elementor responsive.
12 *
13 * Elementor responsive handler class is responsible for setting up Elementor
14 * responsive breakpoints.
15 *
16 * @since 1.0.0
17 */
18 class Responsive {
19
20 /**
21 * The Elementor breakpoint prefix.
22 */
23 const BREAKPOINT_OPTION_PREFIX = 'elementor_viewport_';
24
25 /**
26 * Default breakpoints.
27 *
28 * Holds the default responsive breakpoints.
29 *
30 * @since 1.0.0
31 * @access private
32 * @static
33 *
34 * @var array Default breakpoints.
35 */
36 private static $default_breakpoints = [
37 'xs' => 0,
38 'sm' => 480,
39 'md' => 768,
40 'lg' => 1025,
41 'xl' => 1440,
42 'xxl' => 1600,
43 ];
44
45 /**
46 * Editable breakpoint keys.
47 *
48 * Holds the editable breakpoint keys.
49 *
50 * @since 1.0.0
51 * @access private
52 * @static
53 *
54 * @var array Editable breakpoint keys.
55 */
56 private static $editable_breakpoints_keys = [
57 'md',
58 'lg',
59 ];
60
61 /**
62 * Get default breakpoints.
63 *
64 * Retrieve the default responsive breakpoints.
65 *
66 * @since 1.0.0
67 * @access public
68 * @static
69 *
70 * @return array Default breakpoints.
71 */
72 public static function get_default_breakpoints() {
73 return self::$default_breakpoints;
74 }
75
76 /**
77 * Get editable breakpoints.
78 *
79 * Retrieve the editable breakpoints.
80 *
81 * @since 1.0.0
82 * @access public
83 * @static
84 *
85 * @return array Editable breakpoints.
86 */
87 public static function get_editable_breakpoints() {
88 return array_intersect_key( self::get_breakpoints(), array_flip( self::$editable_breakpoints_keys ) );
89 }
90
91 /**
92 * Get breakpoints.
93 *
94 * Retrieve the responsive breakpoints.
95 *
96 * @since 1.0.0
97 * @access public
98 * @static
99 *
100 * @return array Responsive breakpoints.
101 */
102 public static function get_breakpoints() {
103 return array_reduce(
104 array_keys( self::$default_breakpoints ), function( $new_array, $breakpoint_key ) {
105 if ( ! in_array( $breakpoint_key, self::$editable_breakpoints_keys ) ) {
106 $new_array[ $breakpoint_key ] = self::$default_breakpoints[ $breakpoint_key ];
107 } else {
108 $saved_option = get_option( self::BREAKPOINT_OPTION_PREFIX . $breakpoint_key );
109
110 $new_array[ $breakpoint_key ] = $saved_option ? (int) $saved_option : self::$default_breakpoints[ $breakpoint_key ];
111 }
112
113 return $new_array;
114 }, []
115 );
116 }
117
118 /**
119 * @since 2.1.0
120 * @access public
121 * @static
122 */
123 public static function has_custom_breakpoints() {
124 return ! ! array_diff( self::$default_breakpoints, self::get_breakpoints() );
125 }
126
127 /**
128 * @since 2.1.0
129 * @access public
130 * @static
131 */
132 public static function get_stylesheet_templates_path() {
133 return ELEMENTOR_ASSETS_PATH . 'css/templates/';
134 }
135
136 /**
137 * @since 2.1.0
138 * @access public
139 * @static
140 */
141 public static function compile_stylesheet_templates() {
142 foreach ( self::get_stylesheet_templates() as $file_name => $template_path ) {
143 $file = new Frontend( $file_name, $template_path );
144
145 $file->update();
146 }
147 }
148
149 /**
150 * @since 2.1.0
151 * @access private
152 * @static
153 */
154 private static function get_stylesheet_templates() {
155 $templates_paths = glob( self::get_stylesheet_templates_path() . '*.css' );
156
157 $templates = [];
158
159 foreach ( $templates_paths as $template_path ) {
160 $file_name = 'custom-' . basename( $template_path );
161
162 $templates[ $file_name ] = $template_path;
163 }
164
165 return apply_filters( 'elementor/core/responsive/get_stylesheet_templates', $templates );
166 }
167 }
168