PluginProbe
Elementor Website Builder – more than just a page builder / 3.10.0-dev1
Elementor Website Builder – more than just a page builder v3.10.0-dev1
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
← All changes | modules/gutenberg/module.php +9 -106 4.3.0-beta23.10.0-dev1 View file →
@@ -1,9 +1,8 @@
1 1 <?php
2 2 namespace Elementor\Modules\Gutenberg;
3 3
4 4 use Elementor\Core\Base\Module as BaseModule;
5 -use Elementor\Core\Experiments\Manager as Experiments_Manager;
6 5 use Elementor\Plugin;
7 6 use Elementor\User;
8 7 use Elementor\Utils;
9 8
@@ -38,14 +37,14 @@
38 37 */
39 38 public function register_elementor_rest_field() {
40 39 register_rest_field( get_post_types( '', 'names' ),
41 40 'gutenberg_elementor_mode', [
42 - 'update_callback' => function( $request_value, $obj ) {
43 - if ( ! User::is_current_user_can_edit( $obj->ID ) ) {
41 + 'update_callback' => function( $request_value, $object ) {
42 + if ( ! User::is_current_user_can_edit( $object->ID ) ) {
44 43 return false;
45 44 }
46 45
47 - $document = Plugin::$instance->documents->get( $obj->ID );
46 + $document = Plugin::$instance->documents->get( $object->ID );
48 47
49 48 if ( ! $document ) {
50 49 return false;
51 50 }
@@ -70,9 +69,9 @@
70 69 }
71 70
72 71 $this->is_gutenberg_editor_active = true;
73 72
74 - $suffix = Utils::is_script_debug() ? '' : '.min';
73 + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
75 74
76 75 wp_enqueue_script( 'elementor-gutenberg', ELEMENTOR_ASSETS_URL . 'js/gutenberg' . $suffix . '.js', [ 'jquery' ], ELEMENTOR_VERSION, true );
77 76
78 77 $elementor_settings = [
@@ -94,12 +93,9 @@
94 93 ?>
95 94 <script id="elementor-gutenberg-button-switch-mode" type="text/html">
96 95 <div id="elementor-switch-mode">
97 96 <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>
97 + <span class="elementor-switch-mode-on"><?php echo esc_html__( '&#8592; Back to WordPress Editor', 'elementor' ); ?></span>
102 98 <span class="elementor-switch-mode-off">
103 99 <i class="eicon-elementor-square" aria-hidden="true"></i>
104 100 <?php echo esc_html__( 'Edit with Elementor', 'elementor' ); ?>
105 101 </span>
@@ -107,14 +103,13 @@
107 103 </div>
108 104 </script>
109 105
110 106 <script id="elementor-gutenberg-panel" type="text/html">
111 - <div id="elementor-editor">
112 - <div id="elementor-go-to-edit-page-link">
113 - <button id="elementor-editor-button" class="button button-primary button-hero">
107 + <div id="elementor-editor"><a id="elementor-go-to-edit-page-link" href="#">
108 + <div id="elementor-editor-button" class="button button-primary button-hero">
114 109 <i class="eicon-elementor-square" aria-hidden="true"></i>
115 110 <?php echo esc_html__( 'Edit with Elementor', 'elementor' ); ?>
116 - </button>
111 + </div>
117 112 <div class="elementor-loader-wrapper">
118 113 <div class="elementor-loader">
119 114 <div class="elementor-loader-boxes">
120 115 <div class="elementor-loader-box"></div>
@@ -124,22 +119,10 @@
124 119 </div>
125 120 </div>
126 121 <div class="elementor-loading-title"><?php echo esc_html__( 'Loading', 'elementor' ); ?></div>
127 122 </div>
128 - </div>
129 - </div>
123 + </a></div>
130 124 </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 125 <?php
143 126 }
144 127
145 128 /**
@@ -149,86 +132,6 @@
149 132 public function __construct() {
150 133 add_action( 'rest_api_init', [ $this, 'register_elementor_rest_field' ] );
151 134 add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_assets' ] );
152 135 add_action( 'admin_footer', [ $this, 'print_admin_js_template' ] );
153 - add_action( 'wp_enqueue_scripts', [ $this, 'dequeue_assets' ], 999 );
154 - }
155 -
156 - public function dequeue_assets() {
157 - if ( ! static::is_optimized_gutenberg_loading_enabled() ) {
158 - return;
159 - }
160 -
161 - if ( ! static::should_dequeue_gutenberg_assets() ) {
162 - return;
163 - }
164 -
165 - wp_dequeue_style( 'wp-block-library' );
166 - wp_dequeue_style( 'wp-block-library-theme' );
167 - wp_dequeue_style( 'wc-block-style' );
168 - wp_dequeue_style( 'wc-blocks-style' );
169 - }
170 -
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 {
185 - $post = get_post();
186 -
187 - if ( empty( $post->ID ) ) {
188 - return false;
189 - }
190 -
191 - if ( ! static::is_built_with_elementor( $post ) ) {
192 - return false;
193 - }
194 -
195 - if ( static::is_gutenberg_in_post( $post ) ) {
196 - return false;
197 - }
198 -
199 - return true;
200 - }
201 -
202 - private static function is_built_with_elementor( $post ): bool {
203 - $document = Plugin::$instance->documents->get( $post->ID );
204 -
205 - if ( ! $document || ! $document->is_built_with_elementor() ) {
206 - return false;
207 - }
208 -
209 - return true;
210 - }
211 -
212 - private static function is_gutenberg_in_post( $post ): bool {
213 - if ( has_blocks( $post ) ) {
214 - return true;
215 - }
216 -
217 - if ( static::current_theme_is_fse_theme() ) {
218 - return true;
219 - }
220 -
221 - return false;
222 - }
223 -
224 - private static function current_theme_is_fse_theme(): bool {
225 - if ( function_exists( 'wp_is_block_theme' ) ) {
226 - return (bool) wp_is_block_theme();
227 - }
228 - if ( function_exists( 'gutenberg_is_fse_theme' ) ) {
229 - return (bool) gutenberg_is_fse_theme();
230 - }
231 -
232 - return false;
233 136 }
234 137 }