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 / admin / admin.php

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

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