PluginProbe
Elementor Website Builder – more than just a page builder / 3.7.4
Elementor Website Builder – more than just a page builder v3.7.4
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 / admin / admin.php

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

786 lines 23.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Core\Admin;
3
4 use Elementor\Api;
5 use Elementor\Beta_Testers;
6 use Elementor\Core\Admin\Menu\Main as MainMenu;
7 use Elementor\Core\App\Modules\Onboarding\Module as Onboarding_Module;
8 use Elementor\Core\Base\App;
9 use Elementor\Core\Upgrade\Manager as Upgrade_Manager;
10 use Elementor\Plugin;
11 use Elementor\Settings;
12 use Elementor\User;
13 use Elementor\Utils;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit; // Exit if accessed directly.
17 }
18
19 class Admin extends App {
20
21 private $menus = [];
22
23 /**
24 * Get module name.
25 *
26 * Retrieve the module name.
27 *
28 * @since 2.3.0
29 * @access public
30 *
31 * @return string Module name.
32 */
33 public function get_name() {
34 return 'admin';
35 }
36
37 /**
38 * @since 2.2.0
39 * @access public
40 */
41 public function maybe_redirect_to_getting_started() {
42 if ( ! get_transient( 'elementor_activation_redirect' ) ) {
43 return;
44 }
45
46 if ( wp_doing_ajax() ) {
47 return;
48 }
49
50 delete_transient( 'elementor_activation_redirect' );
51
52 if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
53 return;
54 }
55
56 $already_had_onboarding = get_option( Onboarding_Module::ONBOARDING_OPTION );
57
58 // Get the latest installation from Elementor's Install log in the DB.
59 $latest_install = key( Upgrade_Manager::get_installs_history() );
60
61 if ( ! empty( $latest_install ) ) {
62 $is_new_install = version_compare( $latest_install, '3.6.0-beta', '>=' );
63 } else {
64 // If `$latest_install` is not set, Elementor was never installed on this site.
65 $is_new_install = true;
66 }
67
68 if ( $already_had_onboarding || ! $is_new_install ) {
69 return;
70 }
71
72 wp_safe_redirect( admin_url( 'admin.php?page=elementor-app#onboarding' ) );
73
74 exit;
75 }
76
77 /**
78 * Enqueue admin scripts.
79 *
80 * Registers all the admin scripts and enqueues them.
81 *
82 * Fired by `admin_enqueue_scripts` action.
83 *
84 * @since 1.0.0
85 * @access public
86 */
87 public function enqueue_scripts() {
88 wp_register_script(
89 'elementor-admin-modules',
90 $this->get_js_assets_url( 'admin-modules' ),
91 [],
92 ELEMENTOR_VERSION,
93 true
94 );
95
96 wp_register_script(
97 'elementor-admin',
98 $this->get_js_assets_url( 'admin' ),
99 [
100 'elementor-common',
101 'elementor-admin-modules',
102 ],
103 ELEMENTOR_VERSION,
104 true
105 );
106
107 wp_enqueue_script( 'elementor-admin' );
108
109 $this->print_config();
110 }
111
112 /**
113 * Enqueue admin styles.
114 *
115 * Registers all the admin styles and enqueues them.
116 *
117 * Fired by `admin_enqueue_scripts` action.
118 *
119 * @since 1.0.0
120 * @access public
121 */
122 public function enqueue_styles() {
123 $direction_suffix = is_rtl() ? '-rtl' : '';
124
125 wp_register_style(
126 'elementor-admin',
127 $this->get_css_assets_url( 'admin' . $direction_suffix ),
128 [
129 'elementor-common',
130 ],
131 ELEMENTOR_VERSION
132 );
133
134 wp_enqueue_style( 'elementor-admin' );
135
136 // It's for upgrade notice.
137 // TODO: enqueue this just if needed.
138 add_thickbox();
139 }
140
141 /**
142 * Print switch mode button.
143 *
144 * Adds a switch button in post edit screen (which has cpt support). To allow
145 * the user to switch from the native WordPress editor to Elementor builder.
146 *
147 * Fired by `edit_form_after_title` action.
148 *
149 * @since 1.0.0
150 * @access public
151 *
152 * @param \WP_Post $post The current post object.
153 */
154 public function print_switch_mode_button( $post ) {
155 // Exit if Gutenberg are active.
156 if ( did_action( 'enqueue_block_editor_assets' ) ) {
157 return;
158 }
159
160 $document = Plugin::$instance->documents->get( $post->ID );
161
162 if ( ! $document || ! $document->is_editable_by_current_user() ) {
163 return;
164 }
165
166 wp_nonce_field( basename( __FILE__ ), '_elementor_edit_mode_nonce' );
167 ?>
168 <div id="elementor-switch-mode">
169 <input id="elementor-switch-mode-input" type="hidden" name="_elementor_post_mode" value="<?php echo esc_attr( $document->is_built_with_elementor() ); ?>" />
170 <button id="elementor-switch-mode-button" type="button" class="button button-primary button-hero">
171 <span class="elementor-switch-mode-on">
172 <i class="eicon-arrow-<?php echo ( is_rtl() ) ? 'right' : 'left'; ?>" aria-hidden="true"></i>
173 <?php echo esc_html__( 'Back to WordPress Editor', 'elementor' ); ?>
174 </span>
175 <span class="elementor-switch-mode-off">
176 <i class="eicon-elementor-square" aria-hidden="true"></i>
177 <?php echo esc_html__( 'Edit with Elementor', 'elementor' ); ?>
178 </span>
179 </button>
180 </div>
181 <div id="elementor-editor">
182 <a id="elementor-go-to-edit-page-link" href="<?php echo esc_url( $document->get_edit_url() ); ?>">
183 <div id="elementor-editor-button" class="button button-primary button-hero">
184 <i class="eicon-elementor-square" aria-hidden="true"></i>
185 <?php echo esc_html__( 'Edit with Elementor', 'elementor' ); ?>
186 </div>
187 <div class="elementor-loader-wrapper">
188 <div class="elementor-loader">
189 <div class="elementor-loader-boxes">
190 <div class="elementor-loader-box"></div>
191 <div class="elementor-loader-box"></div>
192 <div class="elementor-loader-box"></div>
193 <div class="elementor-loader-box"></div>
194 </div>
195 </div>
196 <div class="elementor-loading-title"><?php echo esc_html__( 'Loading', 'elementor' ); ?></div>
197 </div>
198 </a>
199 </div>
200 <?php
201 }
202
203 /**
204 * Save post.
205 *
206 * Flag the post mode when the post is saved.
207 *
208 * Fired by `save_post` action.
209 *
210 * @since 1.0.0
211 * @access public
212 *
213 * @param int $post_id Post ID.
214 */
215 public function save_post( $post_id ) {
216 if ( ! isset( $_POST['_elementor_edit_mode_nonce'] ) || ! wp_verify_nonce( $_POST['_elementor_edit_mode_nonce'], basename( __FILE__ ) ) ) {
217 return;
218 }
219
220 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
221 return;
222 }
223
224 Plugin::$instance->documents->get( $post_id )->set_is_built_with_elementor( ! empty( $_POST['_elementor_post_mode'] ) );
225 }
226
227 /**
228 * Add Elementor post state.
229 *
230 * Adds a new "Elementor" post state to the post table.
231 *
232 * Fired by `display_post_states` filter.
233 *
234 * @since 1.8.0
235 * @access public
236 *
237 * @param array $post_states An array of post display states.
238 * @param \WP_Post $post The current post object.
239 *
240 * @return array A filtered array of post display states.
241 */
242 public function add_elementor_post_state( $post_states, $post ) {
243 $document = Plugin::$instance->documents->get( $post->ID );
244
245 if ( $document && $document->is_built_with_elementor() && $document->is_editable_by_current_user() ) {
246 $post_states['elementor'] = esc_html__( 'Elementor', 'elementor' );
247 }
248
249 return $post_states;
250 }
251
252 /**
253 * Body status classes.
254 *
255 * Adds CSS classes to the admin body tag.
256 *
257 * Fired by `admin_body_class` filter.
258 *
259 * @since 1.0.0
260 * @access public
261 *
262 * @param string $classes Space-separated list of CSS classes.
263 *
264 * @return string Space-separated list of CSS classes.
265 */
266 public function body_status_classes( $classes ) {
267 global $pagenow;
268
269 if ( in_array( $pagenow, [ 'post.php', 'post-new.php' ], true ) && Utils::is_post_support() ) {
270 $post = get_post();
271
272 $document = Plugin::$instance->documents->get( $post->ID );
273
274 $mode_class = $document && $document->is_built_with_elementor() ? 'elementor-editor-active' : 'elementor-editor-inactive';
275
276 $classes .= ' ' . $mode_class;
277 }
278
279 return $classes;
280 }
281
282 /**
283 * Plugin action links.
284 *
285 * Adds action links to the plugin list table
286 *
287 * Fired by `plugin_action_links` filter.
288 *
289 * @since 1.0.0
290 * @access public
291 *
292 * @param array $links An array of plugin action links.
293 *
294 * @return array An array of plugin action links.
295 */
296 public function plugin_action_links( $links ) {
297 $settings_link = sprintf( '<a href="%1$s">%2$s</a>', admin_url( 'admin.php?page=' . Settings::PAGE_ID ), esc_html__( 'Settings', 'elementor' ) );
298
299 array_unshift( $links, $settings_link );
300
301 $links['go_pro'] = sprintf( '<a href="%1$s" target="_blank" class="elementor-plugins-gopro">%2$s</a>', 'https://go.elementor.com/go-pro-wp-plugins/', esc_html__( 'Go Pro', 'elementor' ) );
302
303 return $links;
304 }
305
306 /**
307 * Plugin row meta.
308 *
309 * Adds row meta links to the plugin list table
310 *
311 * Fired by `plugin_row_meta` filter.
312 *
313 * @since 1.1.4
314 * @access public
315 *
316 * @param array $plugin_meta An array of the plugin's metadata, including
317 * the version, author, author URI, and plugin URI.
318 * @param string $plugin_file Path to the plugin file, relative to the plugins
319 * directory.
320 *
321 * @return array An array of plugin row meta links.
322 */
323 public function plugin_row_meta( $plugin_meta, $plugin_file ) {
324 if ( ELEMENTOR_PLUGIN_BASE === $plugin_file ) {
325 $row_meta = [
326 'docs' => '<a href="https://go.elementor.com/docs-admin-plugins/" aria-label="' . esc_attr( esc_html__( 'View Elementor Documentation', 'elementor' ) ) . '" target="_blank">' . esc_html__( 'Docs & FAQs', 'elementor' ) . '</a>',
327 'ideo' => '<a href="https://go.elementor.com/yt-admin-plugins/" aria-label="' . esc_attr( esc_html__( 'View Elementor Video Tutorials', 'elementor' ) ) . '" target="_blank">' . esc_html__( 'Video Tutorials', 'elementor' ) . '</a>',
328 ];
329
330 $plugin_meta = array_merge( $plugin_meta, $row_meta );
331 }
332
333 return $plugin_meta;
334 }
335
336 /**
337 * Admin footer text.
338 *
339 * Modifies the "Thank you" text displayed in the admin footer.
340 *
341 * Fired by `admin_footer_text` filter.
342 *
343 * @since 1.0.0
344 * @access public
345 *
346 * @param string $footer_text The content that will be printed.
347 *
348 * @return string The content that will be printed.
349 */
350 public function admin_footer_text( $footer_text ) {
351 $current_screen = get_current_screen();
352 $is_elementor_screen = ( $current_screen && false !== strpos( $current_screen->id, 'elementor' ) );
353
354 if ( $is_elementor_screen ) {
355 $footer_text = sprintf(
356 /* translators: 1: Elementor, 2: Link to plugin review */
357 __( 'Enjoyed %1$s? Please leave us a %2$s rating. We really appreciate your support!', 'elementor' ),
358 '<strong>' . esc_html__( 'Elementor', 'elementor' ) . '</strong>',
359 '<a href="https://go.elementor.com/admin-review/" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
360 );
361 }
362
363 return $footer_text;
364 }
365
366 /**
367 * Register dashboard widgets.
368 *
369 * Adds a new Elementor widgets to WordPress dashboard.
370 *
371 * Fired by `wp_dashboard_setup` action.
372 *
373 * @since 1.9.0
374 * @access public
375 */
376 public function register_dashboard_widgets() {
377 wp_add_dashboard_widget( 'e-dashboard-overview', esc_html__( 'Elementor Overview', 'elementor' ), [ $this, 'elementor_dashboard_overview_widget' ] );
378
379 // Move our widget to top.
380 global $wp_meta_boxes;
381
382 $dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
383 $ours = [
384 'e-dashboard-overview' => $dashboard['e-dashboard-overview'],
385 ];
386
387 $wp_meta_boxes['dashboard']['normal']['core'] = array_merge( $ours, $dashboard ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
388 }
389
390 /**
391 * Elementor dashboard widget.
392 *
393 * Displays the Elementor dashboard widget.
394 *
395 * Fired by `wp_add_dashboard_widget` function.
396 *
397 * @since 1.9.0
398 * @access public
399 */
400 public function elementor_dashboard_overview_widget() {
401 $elementor_feed = Api::get_feed_data();
402 $recently_edited_query = Utils::get_recently_edited_posts_query();
403
404 if ( User::is_current_user_can_edit_post_type( 'page' ) ) {
405 $create_new_label = esc_html__( 'Create New Page', 'elementor' );
406 $create_new_post_type = 'page';
407 } elseif ( User::is_current_user_can_edit_post_type( 'post' ) ) {
408 $create_new_label = esc_html__( 'Create New Post', 'elementor' );
409 $create_new_post_type = 'post';
410 }
411 ?>
412 <div class="e-dashboard-widget">
413 <div class="e-overview__header">
414 <div class="e-overview__logo"><div class="e-logo-wrapper"><i class="eicon-elementor"></i></div></div>
415 <div class="e-overview__versions">
416 <span class="e-overview__version"><?php echo esc_html__( 'Elementor', 'elementor' ); ?> v<?php echo ELEMENTOR_VERSION; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span>
417 <?php
418 /**
419 * Elementor dashboard widget after the version.
420 *
421 * Fires after Elementor version display in the dashboard widget.
422 *
423 * @since 1.9.0
424 */
425 do_action( 'elementor/admin/dashboard_overview_widget/after_version' );
426 ?>
427 </div>
428 <?php if ( ! empty( $create_new_post_type ) ) : ?>
429 <div class="e-overview__create">
430 <a href="<?php echo esc_url( Plugin::$instance->documents->get_create_new_post_url( $create_new_post_type ) ); ?>" class="button"><span aria-hidden="true" class="dashicons dashicons-plus"></span> <?php echo esc_html( $create_new_label ); ?></a>
431 </div>
432 <?php endif; ?>
433 </div>
434 <?php if ( $recently_edited_query->have_posts() ) : ?>
435 <div class="e-overview__recently-edited">
436 <h3 class="e-heading e-divider_bottom"><?php echo esc_html__( 'Recently Edited', 'elementor' ); ?></h3>
437 <ul class="e-overview__posts">
438 <?php
439 while ( $recently_edited_query->have_posts() ) :
440 $recently_edited_query->the_post();
441 $document = Plugin::$instance->documents->get( get_the_ID() );
442
443 $date = date_i18n( _x( 'M jS', 'Dashboard Overview Widget Recently Date', 'elementor' ), get_the_modified_time( 'U' ) );
444 ?>
445 <li class="e-overview__post">
446 <a href="<?php echo esc_attr( $document->get_edit_url() ); ?>" class="e-overview__post-link"><?php echo esc_html( get_the_title() ); ?> <span class="dashicons dashicons-edit"></span></a> <span><?php echo $date; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>, <?php the_time(); ?></span>
447 </li>
448 <?php endwhile; ?>
449 </ul>
450 </div>
451 <?php endif; ?>
452 <?php if ( ! empty( $elementor_feed ) ) : ?>
453 <div class="e-overview__feed">
454 <h3 class="e-heading e-divider_bottom"><?php echo esc_html__( 'News & Updates', 'elementor' ); ?></h3>
455 <ul class="e-overview__posts">
456 <?php foreach ( $elementor_feed as $feed_item ) : ?>
457 <li class="e-overview__post">
458 <a href="<?php echo esc_url( $feed_item['url'] ); ?>" class="e-overview__post-link" target="_blank">
459 <?php if ( ! empty( $feed_item['badge'] ) ) : ?>
460 <span class="e-overview__badge"><?php echo esc_html( $feed_item['badge'] ); ?></span>
461 <?php endif; ?>
462 <?php echo esc_html( $feed_item['title'] ); ?>
463 </a>
464 <p class="e-overview__post-description"><?php echo esc_html( $feed_item['excerpt'] ); ?></p>
465 </li>
466 <?php endforeach; ?>
467 </ul>
468 </div>
469 <?php endif; ?>
470 <div class="e-overview__footer e-divider_top">
471 <ul>
472 <?php foreach ( $this->get_dashboard_overview_widget_footer_actions() as $action_id => $action ) : ?>
473 <li class="e-overview__<?php echo esc_attr( $action_id ); ?>"><a href="<?php echo esc_attr( $action['link'] ); ?>" target="_blank"><?php echo esc_html( $action['title'] ); ?> <span class="screen-reader-text"><?php echo esc_html__( '(opens in a new window)', 'elementor' ); ?></span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></li>
474 <?php endforeach; ?>
475 </ul>
476 </div>
477 </div>
478 <?php
479 }
480
481 /**
482 * Get elementor dashboard overview widget footer actions.
483 *
484 * Retrieves the footer action links displayed in elementor dashboard widget.
485 *
486 * @since 1.9.0
487 * @access private
488 */
489 private function get_dashboard_overview_widget_footer_actions() {
490 $base_actions = [
491 'blog' => [
492 'title' => esc_html__( 'Blog', 'elementor' ),
493 'link' => 'https://go.elementor.com/overview-widget-blog/',
494 ],
495 'help' => [
496 'title' => esc_html__( 'Help', 'elementor' ),
497 'link' => 'https://go.elementor.com/overview-widget-docs/',
498 ],
499 ];
500
501 $additions_actions = [
502 'go-pro' => [
503 'title' => esc_html__( 'Upgrade', 'elementor' ),
504 'link' => 'https://go.elementor.com/go-pro-wp-overview-widget/',
505 ],
506 ];
507
508 // Visible to all core users when Elementor Pro is not installed.
509 $additions_actions['find_an_expert'] = [
510 'title' => esc_html__( 'Find an Expert', 'elementor' ),
511 'link' => 'https://go.elementor.com/go-pro-find-an-expert/',
512 ];
513
514 /**
515 * Dashboard widget footer actions.
516 *
517 * Filters the additions actions displayed in Elementor dashboard widget.
518 *
519 * Developers can add new action links to Elementor dashboard widget
520 * footer using this filter.
521 *
522 * @since 1.9.0
523 *
524 * @param array $additions_actions Elementor dashboard widget footer actions.
525 */
526 $additions_actions = apply_filters( 'elementor/admin/dashboard_overview_widget/footer_actions', $additions_actions );
527
528 $actions = $base_actions + $additions_actions;
529
530 return $actions;
531 }
532
533 /**
534 * Admin action new post.
535 *
536 * When a new post action is fired the title is set to 'Elementor' and the post ID.
537 *
538 * Fired by `admin_action_elementor_new_post` action.
539 *
540 * @since 1.9.0
541 * @access public
542 */
543 public function admin_action_new_post() {
544 check_admin_referer( 'elementor_action_new_post' );
545
546 if ( empty( $_GET['post_type'] ) ) {
547 $post_type = 'post';
548 } else {
549 $post_type = $_GET['post_type'];
550 }
551
552 if ( ! User::is_current_user_can_edit_post_type( $post_type ) ) {
553 return;
554 }
555
556 if ( empty( $_GET['template_type'] ) ) {
557 $type = 'post';
558 } else {
559 $type = sanitize_text_field( $_GET['template_type'] );
560 }
561
562 $post_data = isset( $_GET['post_data'] ) ? $_GET['post_data'] : [];
563
564 $meta = [];
565
566 /**
567 * Create new post meta data.
568 *
569 * Filters the meta data of any new post created.
570 *
571 * @since 2.0.0
572 *
573 * @param array $meta Post meta data.
574 */
575 $meta = apply_filters( 'elementor/admin/create_new_post/meta', $meta );
576
577 $post_data['post_type'] = $post_type;
578
579 $document = Plugin::$instance->documents->create( $type, $post_data, $meta );
580
581 if ( is_wp_error( $document ) ) {
582 wp_die( $document ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
583 }
584
585 wp_redirect( $document->get_edit_url() );
586
587 die;
588 }
589
590 /**
591 * @since 2.3.0
592 * @access public
593 */
594 public function add_new_template_template() {
595 Plugin::$instance->common->add_template( ELEMENTOR_PATH . 'includes/admin-templates/new-template.php' );
596 }
597
598 /**
599 * @access public
600 */
601 public function enqueue_new_template_scripts() {
602 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
603
604 wp_enqueue_script(
605 'elementor-new-template',
606 ELEMENTOR_ASSETS_URL . 'js/new-template' . $suffix . '.js',
607 [],
608 ELEMENTOR_VERSION,
609 true
610 );
611 }
612
613 /**
614 * @since 2.6.0
615 * @access public
616 */
617 public function add_beta_tester_template() {
618 Plugin::$instance->common->add_template( ELEMENTOR_PATH . 'includes/admin-templates/beta-tester.php' );
619 }
620
621 /**
622 * @access public
623 */
624 public function enqueue_beta_tester_scripts() {
625 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
626
627 wp_enqueue_script(
628 'elementor-beta-tester',
629 ELEMENTOR_ASSETS_URL . 'js/beta-tester' . $suffix . '.js',
630 [],
631 ELEMENTOR_VERSION,
632 true
633 );
634 }
635
636 /**
637 * @access public
638 */
639 public function init_new_template() {
640 if ( 'edit-elementor_library' !== get_current_screen()->id ) {
641 return;
642 }
643
644 // Allow plugins to add their templates on admin_head.
645 add_action( 'admin_head', [ $this, 'add_new_template_template' ] );
646 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_new_template_scripts' ] );
647 }
648
649 public function version_update_warning( $current_version, $new_version ) {
650 $current_version_minor_part = explode( '.', $current_version )[1];
651 $new_version_minor_part = explode( '.', $new_version )[1];
652
653 if ( $current_version_minor_part === $new_version_minor_part ) {
654 return;
655 }
656 ?>
657 <hr class="e-major-update-warning__separator" />
658 <div class="e-major-update-warning">
659 <div class="e-major-update-warning__icon">
660 <i class="eicon-info-circle"></i>
661 </div>
662 <div>
663 <div class="e-major-update-warning__title">
664 <?php echo esc_html__( 'Heads up, Please backup before upgrade!', 'elementor' ); ?>
665 </div>
666 <div class="e-major-update-warning__message">
667 <?php
668 printf(
669 /* translators: %1$s Link open tag, %2$s: Link close tag. */
670 esc_html__( 'The latest update includes some substantial changes across different areas of the plugin. We highly recommend you %1$sbackup your site before upgrading%2$s, and make sure you first update in a staging environment', 'elementor' ),
671 '<a href="https://go.elementor.com/wp-dash-update-backup/">',
672 '</a>'
673 );
674 ?>
675 </div>
676 </div>
677 </div>
678 <?php
679 }
680
681 /**
682 * @access public
683 */
684 public function init_beta_tester( $current_screen ) {
685 if ( ( 'toplevel_page_elementor' === $current_screen->base ) || 'elementor_page_elementor-tools' === $current_screen->id ) {
686 add_action( 'admin_head', [ $this, 'add_beta_tester_template' ] );
687 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_beta_tester_scripts' ] );
688 }
689 }
690
691 /**
692 * Admin constructor.
693 *
694 * Initializing Elementor in WordPress admin.
695 *
696 * @since 1.0.0
697 * @access public
698 */
699 public function __construct() {
700 Plugin::$instance->init_common();
701
702 $this->add_component( 'feedback', new Feedback() );
703 $this->add_component( 'admin-notices', new Admin_Notices() );
704
705 if ( Plugin::$instance->experiments->is_feature_active( 'admin_menu_rearrangement' ) ) {
706 $this->register_menu();
707 }
708
709 add_action( 'admin_init', [ $this, 'maybe_redirect_to_getting_started' ] );
710
711 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
712 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_styles' ] );
713
714 add_action( 'edit_form_after_title', [ $this, 'print_switch_mode_button' ] );
715 add_action( 'save_post', [ $this, 'save_post' ] );
716
717 add_filter( 'display_post_states', [ $this, 'add_elementor_post_state' ], 10, 2 );
718
719 add_filter( 'plugin_action_links_' . ELEMENTOR_PLUGIN_BASE, [ $this, 'plugin_action_links' ] );
720 add_filter( 'plugin_row_meta', [ $this, 'plugin_row_meta' ], 10, 2 );
721
722 add_filter( 'admin_body_class', [ $this, 'body_status_classes' ] );
723 add_filter( 'admin_footer_text', [ $this, 'admin_footer_text' ] );
724
725 // Register Dashboard Widgets.
726 add_action( 'wp_dashboard_setup', [ $this, 'register_dashboard_widgets' ] );
727
728 // Admin Actions
729 add_action( 'admin_action_elementor_new_post', [ $this, 'admin_action_new_post' ] );
730
731 add_action( 'current_screen', [ $this, 'init_new_template' ] );
732 add_action( 'current_screen', [ $this, 'init_beta_tester' ] );
733
734 add_action( 'in_plugin_update_message-' . ELEMENTOR_PLUGIN_BASE, function( $plugin_data ) {
735 $this->version_update_warning( ELEMENTOR_VERSION, $plugin_data['new_version'] );
736 } );
737 }
738
739 /**
740 * @since 2.3.0
741 * @access protected
742 */
743 protected function get_init_settings() {
744 $beta_tester_email = get_user_meta( get_current_user_id(), User::BETA_TESTER_META_KEY, true );
745 $elementor_beta = get_option( 'elementor_beta', 'no' );
746 $all_introductions = User::get_introduction_meta();
747 $beta_tester_signup_dismissed = array_key_exists( Beta_Testers::BETA_TESTER_SIGNUP, $all_introductions );
748
749 $settings = [
750 'home_url' => home_url(),
751 'settings_url' => Settings::get_url(),
752 'user' => [
753 'introduction' => User::get_introduction_meta(),
754 ],
755 'beta_tester' => [
756 'beta_tester_signup' => Beta_Testers::BETA_TESTER_SIGNUP,
757 'has_email' => $beta_tester_email,
758 'option_enabled' => 'no' !== $elementor_beta,
759 'signup_dismissed' => $beta_tester_signup_dismissed,
760 ],
761 ];
762
763 /**
764 * Localize settings.
765 *
766 * Filters the initial localize settings in the admin.
767 *
768 * WordPress has it's own way to pass localized data from PHP (backend) to
769 * JS (frontend). Elementor uses this method to pass localize data in the
770 * admin. This hook can be used to add more localized settings in addition
771 * to the initial Elementor settings.
772 *
773 * @since 2.3.0
774 *
775 * @param array $settings Initial localize settings.
776 */
777 $settings = apply_filters( 'elementor/admin/localize_settings', $settings );
778
779 return $settings;
780 }
781
782 private function register_menu() {
783 $this->menus['main'] = new MainMenu();
784 }
785 }
786