PluginProbe
Elementor Website Builder – more than just a page builder / 3.21.5
Elementor Website Builder – more than just a page builder v3.21.5
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 / notices / elementor-dev-notice.php

elementor-dev-notice.php in Elementor Website Builder – more than just a page builder 3.21.5, at core/admin/notices/elementor-dev-notice.php

171 lines 3.7 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\Notices;
3
4 use Elementor\User;
5 use Elementor\Settings;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit; // Exit if accessed directly.
9 }
10
11 class Elementor_Dev_Notice extends Base_Notice {
12 /**
13 * Notice ID.
14 */
15 const ID = 'elementor_dev_promote';
16
17 /**
18 * Plugin slug to install.
19 */
20 const PLUGIN_SLUG = 'elementor-beta';
21
22 /**
23 * Plugin name.
24 */
25 const PLUGIN_NAME = 'elementor-beta/elementor-beta.php';
26
27 /**
28 * Holds the plugins names.
29 *
30 * @var array
31 */
32 private $plugins = [];
33
34 /**
35 * If one of those plugin is installed it will show the notice.
36 *
37 * @var string[]
38 */
39 private $promotion_plugins = [
40 'woocommerce-beta-tester/woocommerce-beta-tester.php',
41 'wp-jquery-update-test/wp-jquery-update-test.php',
42 'wordpress-beta-tester/wp-beta-tester.php',
43 'gutenberg/gutenberg.php',
44 ];
45
46 /**
47 * If one of those options is enabled it will show the notice.
48 *
49 * @var string[]
50 */
51 private $promotion_options = [
52 'elementor_beta',
53 ];
54
55 /**
56 * @inheritDoc
57 */
58 public function should_print() {
59 return current_user_can( 'install_plugins' ) &&
60 ! User::is_user_notice_viewed( static::ID ) &&
61 ! $this->is_elementor_dev_installed() &&
62 ! $this->is_install_screen() &&
63 (
64 $this->is_promotion_plugins_installed() ||
65 $this->is_promotion_options_enabled()
66 );
67 }
68
69 /**
70 * @inheritDoc
71 */
72 public function get_config() {
73 return [
74 'id' => static::ID,
75 'title' => esc_html__( 'Elementor Developer Edition', 'elementor' ),
76 'description' => __(
77 'Get a sneak peek at our in progress development versions, and help us improve Elementor to perfection. Developer Edition releases contain experimental functionality for testing purposes.',
78 'elementor'
79 ),
80 'button' => [
81 'text' => esc_html__( 'Install & Activate', 'elementor' ),
82 'url' => wp_nonce_url(
83 self_admin_url( 'update.php?action=install-plugin&plugin=' . static::PLUGIN_SLUG ),
84 'install-plugin_' . static::PLUGIN_SLUG
85 ),
86 'type' => 'cta',
87 ],
88 ];
89 }
90
91 /**
92 * Return all the plugins names.
93 *
94 * This method is protected so it can be mocked in tests.
95 *
96 * @return array
97 */
98 protected function get_plugins() {
99 if ( ! $this->plugins ) {
100 $this->plugins = array_keys( get_plugins() );
101 }
102
103 return $this->plugins;
104 }
105
106 /**
107 * Checks if elementor dev is installed
108 *
109 * @return bool
110 */
111 private function is_elementor_dev_installed() {
112 return in_array( static::PLUGIN_NAME, $this->get_plugins(), true );
113 }
114
115 /**
116 * Checks if the admin screen is install screen.
117 *
118 * @return bool
119 */
120 private function is_install_screen() {
121 $screen = get_current_screen();
122
123 if ( ! $screen ) {
124 return false;
125 }
126
127 return 'update' === $screen->id;
128 }
129
130 /**
131 * Checks if is one of the promotion plugins is installed
132 *
133 * @return bool
134 */
135 private function is_promotion_plugins_installed() {
136 return array_reduce( $this->promotion_plugins, function ( $should_show_notice, $plugin_name ) {
137 if ( $should_show_notice ) {
138 return true;
139 }
140
141 return in_array( $plugin_name, $this->get_plugins(), true );
142 }, false );
143 }
144
145 /**
146 * Checks if is one of the promotion options is enabled.
147 *
148 * @return bool
149 */
150 private function is_promotion_options_enabled() {
151 return array_reduce( $this->promotion_options, function ( $should_show_notice, $option ) {
152 if ( $should_show_notice ) {
153 return true;
154 }
155
156 return 'yes' === get_option( $option, 'no' );
157 }, false );
158 }
159
160 /**
161 * Checks if the current page is elementor settings page
162 *
163 * @return bool
164 */
165 private function is_elementor_setting_page() {
166 $current_screen = get_current_screen();
167
168 return $current_screen && 'toplevel_page_' . Settings::PAGE_ID === $current_screen->id;
169 }
170 }
171