PluginProbe
Elementor Website Builder – more than just a page builder / 3.1.0-dev2
Elementor Website Builder – more than just a page builder v3.1.0-dev2
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 4.1.0-beta1 All 453 releases
elementor / core / admin / notices / elementor-dev-notice.php

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

152 lines 3.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\Notices;
3
4 use Elementor\User;
5 use Elementor\Plugin;
6 use Elementor\Core\Experiments\Manager as Experiments_Manager;
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 class Elementor_Dev_Notice extends Base_Notice {
13 /**
14 * Notice ID
15 */
16 const ID = 'elementor_dev_promote';
17
18 /**
19 * Holds the plugins names.
20 *
21 * @var array
22 */
23 private $plugins = [];
24
25 /**
26 * If one of those plugin is installed it will show the notice.
27 *
28 * @var string[]
29 */
30 private $promotion_plugins = [
31 'woocommerce-beta-tester/woocommerce-beta-tester.php',
32 'wp-jquery-update-test/wp-jquery-update-test.php',
33 'wordpress-beta-tester/wp-beta-tester.php',
34 'gutenberg/gutenberg.php',
35 ];
36
37 /**
38 * If one of those options is enabled it will show the notice.
39 *
40 * @var string[]
41 */
42 private $promotion_options = [
43 'elementor_beta',
44 ];
45
46 /**
47 * @inheritDoc
48 */
49 public function should_print() {
50 return current_user_can( 'install_plugins' ) &&
51 ! User::is_user_notice_viewed( static::ID ) &&
52 ! $this->is_elementor_dev_installed() &&
53 (
54 $this->has_at_least_one_active_experiment() ||
55 $this->is_promotion_plugins_installed() ||
56 $this->is_promotion_options_enabled()
57 );
58 }
59
60 /**
61 * @inheritDoc
62 */
63 public function get_config() {
64 return [
65 'dismissible' => true,
66 'id' => static::ID,
67 'title' => __( 'Elementor Developer Edition', 'elementor' ),
68 'description' => __(
69 '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.',
70 'elementor'
71 ),
72 'button' => [
73 'text' => __( 'Install & Activate', 'elementor' ),
74 'url' => wp_nonce_url(
75 self_admin_url( 'update.php?action=install-plugin&plugin=elementor-dev' ),
76 'install-plugin_elementor-dev'
77 ),
78 'class' => 'button',
79 ],
80 ];
81 }
82
83 /**
84 * Return all the plugins names.
85 *
86 * This method is protected so it can be mocked in tests.
87 *
88 * @return array
89 */
90 protected function get_plugins() {
91 if ( ! $this->plugins ) {
92 $this->plugins = array_keys( get_plugins() );
93 }
94
95 return $this->plugins;
96 }
97
98 /**
99 * Checks if elementor dev is installed
100 *
101 * @return bool
102 */
103 private function is_elementor_dev_installed() {
104 return in_array( 'elementor-dev/elementor-dev.php', $this->get_plugins(), true );
105 }
106
107 /**
108 * Checks if is one of the promotion plugins is installed
109 *
110 * @return bool
111 */
112 private function is_promotion_plugins_installed() {
113 return array_reduce( $this->promotion_plugins, function ( $should_show_notice, $plugin_name ) {
114 if ( $should_show_notice ) {
115 return true;
116 }
117
118 return in_array( $plugin_name, $this->get_plugins(), true );
119 }, false );
120 }
121
122 /**
123 * Checks if is one of the promotion options is enable.
124 *
125 * @return bool
126 */
127 private function is_promotion_options_enabled() {
128 return array_reduce( $this->promotion_options, function ( $should_show_notice, $option ) {
129 if ( $should_show_notice ) {
130 return true;
131 }
132
133 return 'yes' === get_option( $option, 'no' );
134 }, false );
135 }
136
137 /**
138 * Checks if as at least one active experiment (The state must be "active" and not default-active).
139 *
140 * @return bool
141 */
142 private function has_at_least_one_active_experiment() {
143 foreach ( Plugin::$instance->experiments->get_features() as $feature_name => $feature ) {
144 if ( Experiments_Manager::STATE_ACTIVE === $feature['state'] ) {
145 return true;
146 }
147 }
148
149 return false;
150 }
151 }
152