PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.7
Elementor Website Builder – more than just a page builder v3.0.7
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 / files / frontend.php

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

144 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Core\Responsive\Files;
4
5 use Elementor\Core\Files\Base;
6 use Elementor\Core\Responsive\Responsive;
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly
10 }
11
12 class Frontend extends Base {
13
14 const META_KEY = 'elementor-custom-breakpoints-files';
15
16 private $template_file;
17
18 /**
19 * @since 2.1.0
20 * @access public
21 */
22 public function __construct( $file_name, $template_file = null ) {
23 $this->template_file = $template_file;
24
25 parent::__construct( $file_name );
26 }
27
28 /**
29 * @since 2.1.0
30 * @access public
31 */
32 public function parse_content() {
33 $breakpoints = Responsive::get_breakpoints();
34
35 $breakpoints_keys = array_keys( $breakpoints );
36
37 $file_content = file_get_contents( $this->template_file );
38
39 $file_content = preg_replace_callback( '/ELEMENTOR_SCREEN_([A-Z]+)_([A-Z]+)/', function ( $placeholder_data ) use ( $breakpoints_keys, $breakpoints ) {
40 $breakpoint_index = array_search( strtolower( $placeholder_data[1] ), $breakpoints_keys );
41
42 $is_max_point = 'MAX' === $placeholder_data[2];
43
44 if ( $is_max_point ) {
45 $breakpoint_index++;
46 }
47
48 $value = $breakpoints[ $breakpoints_keys[ $breakpoint_index ] ];
49
50 if ( $is_max_point ) {
51 $value--;
52 }
53
54 return $value . 'px';
55 }, $file_content );
56
57 return $file_content;
58 }
59
60 /**
61 * Load meta.
62 *
63 * Retrieve the file meta data.
64 *
65 * @since 2.1.0
66 * @access protected
67 */
68 protected function load_meta() {
69 $option = $this->load_meta_option();
70
71 $file_meta_key = $this->get_file_meta_key();
72
73 if ( empty( $option[ $file_meta_key ] ) ) {
74 return [];
75 }
76
77 return $option[ $file_meta_key ];
78 }
79
80 /**
81 * Update meta.
82 *
83 * Update the file meta data.
84 *
85 * @since 2.1.0
86 * @access protected
87 *
88 * @param array $meta New meta data.
89 */
90 protected function update_meta( $meta ) {
91 $option = $this->load_meta_option();
92
93 $option[ $this->get_file_meta_key() ] = $meta;
94
95 update_option( static::META_KEY, $option );
96 }
97
98 /**
99 * Delete meta.
100 *
101 * Delete the file meta data.
102 *
103 * @since 2.1.0
104 * @access protected
105 */
106 protected function delete_meta() {
107 $option = $this->load_meta_option();
108
109 $file_meta_key = $this->get_file_meta_key();
110
111 if ( isset( $option[ $file_meta_key ] ) ) {
112 unset( $option[ $file_meta_key ] );
113 }
114
115 if ( $option ) {
116 update_option( static::META_KEY, $option );
117 } else {
118 delete_option( static::META_KEY );
119 }
120 }
121
122 /**
123 * @since 2.1.0
124 * @access private
125 */
126 private function get_file_meta_key() {
127 return pathinfo( $this->get_file_name(), PATHINFO_FILENAME );
128 }
129
130 /**
131 * @since 2.1.0
132 * @access private
133 */
134 private function load_meta_option() {
135 $option = get_option( static::META_KEY );
136
137 if ( ! $option ) {
138 $option = [];
139 }
140
141 return $option;
142 }
143 }
144