PluginProbe
Elementor Website Builder – more than just a page builder / 3.19.2
Elementor Website Builder – more than just a page builder v3.19.2
4.3.1 4.3.0 4.3.0-beta3 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 All 454 releases
← All changes | modules/gutenberg/module.php +25 -37 4.3.03.19.2 View file →
@@ -38,14 +38,14 @@
38 38 */
39 39 public function register_elementor_rest_field() {
40 40 register_rest_field( get_post_types( '', 'names' ),
41 41 'gutenberg_elementor_mode', [
42 - 'update_callback' => function( $request_value, $obj ) {
43 - if ( ! User::is_current_user_can_edit( $obj->ID ) ) {
42 + 'update_callback' => function( $request_value, $object ) {
43 + if ( ! User::is_current_user_can_edit( $object->ID ) ) {
44 44 return false;
45 45 }
46 46
47 - $document = Plugin::$instance->documents->get( $obj->ID );
47 + $document = Plugin::$instance->documents->get( $object->ID );
48 48
49 49 if ( ! $document ) {
50 50 return false;
51 51 }
@@ -70,9 +70,9 @@
70 70 }
71 71
72 72 $this->is_gutenberg_editor_active = true;
73 73
74 - $suffix = Utils::is_script_debug() ? '' : '.min';
74 + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
75 75
76 76 wp_enqueue_script( 'elementor-gutenberg', ELEMENTOR_ASSETS_URL . 'js/gutenberg' . $suffix . '.js', [ 'jquery' ], ELEMENTOR_VERSION, true );
77 77
78 78 $elementor_settings = [
@@ -94,12 +94,9 @@
94 94 ?>
95 95 <script id="elementor-gutenberg-button-switch-mode" type="text/html">
96 96 <div id="elementor-switch-mode">
97 97 <button id="elementor-switch-mode-button" type="button" class="button button-primary button-large">
98 - <span class="elementor-switch-mode-on">
99 - <i class="eicon-wordpress" aria-hidden="true"></i>
100 - <?php echo esc_html__( 'Edit with WordPress', 'elementor' ); ?>
101 - </span>
98 + <span class="elementor-switch-mode-on"><?php echo esc_html__( '&#8592; Back to WordPress Editor', 'elementor' ); ?></span>
102 99 <span class="elementor-switch-mode-off">
103 100 <i class="eicon-elementor-square" aria-hidden="true"></i>
104 101 <?php echo esc_html__( 'Edit with Elementor', 'elementor' ); ?>
105 102 </span>
@@ -127,19 +124,8 @@
127 124 </div>
128 125 </div>
129 126 </div>
130 127 </script>
131 -
132 - <script id="elementor-gutenberg-button-tmpl" type="text/html">
133 - <div id="elementor-edit-button-gutenberg">
134 - <button id="elementor-edit-mode-button" type="button" class="button button-primary button-large">
135 - <span class="elementor-edit-mode-gutenberg">
136 - <i class="eicon-elementor-square" aria-hidden="true"></i>
137 - <?php echo esc_html__( 'Edit with Elementor', 'elementor' ); ?>
138 - </span>
139 - </button>
140 - </div>
141 - </script>
142 128 <?php
143 129 }
144 130
145 131 /**
@@ -146,16 +132,31 @@
146 132 * @since 2.1.0
147 133 * @access public
148 134 */
149 135 public function __construct() {
136 + $this->register_experiments();
137 +
150 138 add_action( 'rest_api_init', [ $this, 'register_elementor_rest_field' ] );
151 139 add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_assets' ] );
152 140 add_action( 'admin_footer', [ $this, 'print_admin_js_template' ] );
141 +
153 142 add_action( 'wp_enqueue_scripts', [ $this, 'dequeue_assets' ], 999 );
154 143 }
155 144
145 + public function register_experiments() {
146 + Plugin::$instance->experiments->add_feature( [
147 + 'name' => 'block_editor_assets_optimize',
148 + 'title' => esc_html__( 'Optimized Gutenberg Loading', 'elementor' ),
149 + 'description' => esc_html__( 'Use this experiment to reduce unnecessary render-blocking loads, enhancing site performance by dequeuing unused Gutenberg block editor files (styles and scripts).', 'elementor' ),
150 + 'release_status' => Experiments_Manager::RELEASE_STATUS_STABLE,
151 + 'default' => Experiments_Manager::STATE_ACTIVE,
152 + 'tag' => esc_html__( 'Performance', 'elementor' ),
153 + 'generator_tag' => true,
154 + ] );
155 + }
156 +
156 157 public function dequeue_assets() {
157 - if ( ! static::is_optimized_gutenberg_loading_enabled() ) {
158 + if ( ! Plugin::$instance->experiments->is_feature_active( 'block_editor_assets_optimize' ) ) {
158 159 return;
159 160 }
160 161
161 162 if ( ! static::should_dequeue_gutenberg_assets() ) {
@@ -167,22 +168,9 @@
167 168 wp_dequeue_style( 'wc-block-style' );
168 169 wp_dequeue_style( 'wc-blocks-style' );
169 170 }
170 171
171 - /**
172 - * Check whether the "Optimized Gutenberg Loading" settings is enabled.
173 - *
174 - * The 'elementor_optimized_gutenberg_loading' option can be enabled/disabled from the Elementor settings.
175 - * For BC, when the option has not been saved in the database, the default '1' value is returned.
176 - *
177 - * @since 3.21.0
178 - * @access private
179 - */
180 - private static function is_optimized_gutenberg_loading_enabled(): bool {
181 - return (bool) get_option( 'elementor_optimized_gutenberg_loading', '1' );
182 - }
183 -
184 - private static function should_dequeue_gutenberg_assets(): bool {
172 + private static function should_dequeue_gutenberg_assets() : bool {
185 173 $post = get_post();
186 174
187 175 if ( empty( $post->ID ) ) {
188 176 return false;
@@ -198,9 +186,9 @@
198 186
199 187 return true;
200 188 }
201 189
202 - private static function is_built_with_elementor( $post ): bool {
190 + private static function is_built_with_elementor( $post ) : bool {
203 191 $document = Plugin::$instance->documents->get( $post->ID );
204 192
205 193 if ( ! $document || ! $document->is_built_with_elementor() ) {
206 194 return false;
@@ -208,9 +196,9 @@
208 196
209 197 return true;
210 198 }
211 199
212 - private static function is_gutenberg_in_post( $post ): bool {
200 + private static function is_gutenberg_in_post( $post ) : bool {
213 201 if ( has_blocks( $post ) ) {
214 202 return true;
215 203 }
216 204
@@ -220,9 +208,9 @@
220 208
221 209 return false;
222 210 }
223 211
224 - private static function current_theme_is_fse_theme(): bool {
212 + private static function current_theme_is_fse_theme() : bool {
225 213 if ( function_exists( 'wp_is_block_theme' ) ) {
226 214 return (bool) wp_is_block_theme();
227 215 }
228 216 if ( function_exists( 'gutenberg_is_fse_theme' ) ) {