PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.2
Elementor Website Builder – more than just a page builder v4.3.2
4.3.2 4.3.1 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 All 455 releases
← All changes | modules/promotions/conversion-banner.php +115 -44 4.1.2 → 4.3.2 View file →
@@ -1,9 +1,9 @@
1 1 <?php
2 2
3 3 namespace Elementor\Modules\Promotions;
4 4
5 -use Elementor\Modules\Promotions\AdminMenuItems\Go_Pro_Promotion_Item;
5 +use Elementor\Core\Base\Document;
6 6 use Elementor\User;
7 7 use Elementor\Utils;
8 8
9 9 if ( ! defined( 'ABSPATH' ) ) {
@@ -19,11 +19,20 @@
19 19 const OBJECT_NAME = 'eConversionBanner';
20 20 const DISMISS_KEY = 'conversion_banner_go_pro';
21 21 const AJAX_ACTION = 'elementor_dismiss_conversion_banner';
22 22 const CONTAINER_ID = 'e-conversion-banner';
23 + const UPGRADE_URL = 'https://go.elementor.com/go-pro-wp-admin-upgrade-notice/';
23 24 const BIRTHDAY_PROMOTION_URL = 'https://go.elementor.com/go-pro-wp-admin-upgrad-notice/';
24 25
25 26 const HELLO_THEME_CONFIG_FILTER = 'hello-plus-theme/rest/admin-config';
27 + const THEME_SLUGS = [ 'hello-elementor', 'hello-biz', 'hello-commerce' ];
28 + const THEME_SETTINGS_PAGE_SUFFIX = '-settings';
29 + const GO_PRO_TITLE_PREFIX = 'Go Pro';
30 + const MIN_ELEMENTOR_PAGES_TO_TRIGGER = 2;
31 + const PENDING_TRANSIENT_KEY = 'elementor_conversion_banner_pages_pending';
32 + const PENDING_TTL = DAY_IN_SECONDS;
33 + const UNLOCK_OPTION_KEY = 'elementor_conversion_banner_unlocked';
34 + const UNLOCK_OPTION_VALUE = '1';
26 35
27 36 public function __construct() {
28 37 add_action( 'wp_ajax_' . self::AJAX_ACTION, [ $this, 'ajax_dismiss_banner' ] );
29 38
@@ -31,12 +40,37 @@
31 40
32 41 add_action( 'current_screen', [ $this, 'maybe_register_banner_hooks' ] );
33 42 }
34 43
44 + public static function register_cache_invalidation_hooks(): void {
45 + static $hooks_registered = false;
46 +
47 + if ( $hooks_registered ) {
48 + return;
49 + }
50 +
51 + $hooks_registered = true;
52 +
53 + add_action( 'added_post_meta', [ self::class, 'maybe_invalidate_pending_cache' ], 10, 4 );
54 + add_action( 'updated_post_meta', [ self::class, 'maybe_invalidate_pending_cache' ], 10, 4 );
55 + }
56 +
57 + public static function maybe_invalidate_pending_cache( $meta_id, $post_id, $meta_key, $meta_value ): void {
58 + if ( Document::BUILT_WITH_ELEMENTOR_META_KEY !== $meta_key ) {
59 + return;
60 + }
61 +
62 + if ( self::is_unlocked() ) {
63 + return;
64 + }
65 +
66 + delete_transient( self::PENDING_TRANSIENT_KEY );
67 + }
68 +
35 69 public function maybe_register_banner_hooks(): void {
36 70 $placement = $this->get_active_placement();
37 71
38 - if ( empty( $placement ) ) {
72 + if ( empty( $placement ) || ! self::has_min_elementor_pages() ) {
39 73 return;
40 74 }
41 75
42 76 add_action( 'in_admin_header', [ $this, 'render_banner_container' ], 11 );
@@ -53,19 +87,42 @@
53 87 <?php
54 88 }
55 89
56 90 public function suppress_hello_theme_banner( $config ) {
57 - if ( ! ( is_array( $config ) && isset( $config['welcome'] ) ) ) {
91 + if ( $this->is_request_from_theme_admin_page()
92 + || ! ( is_array( $config ) && isset( $config['welcome'] ) )
93 + || Utils::has_pro()
94 + ) {
58 95 return $config;
59 96 }
60 97
61 - if ( Utils::has_pro() ) {
62 - return $config;
98 + $title = $config['welcome']['title'] ?? '';
99 +
100 + if ( is_string( $title ) && substr( $title, 0, strlen( self::GO_PRO_TITLE_PREFIX ) ) === self::GO_PRO_TITLE_PREFIX ) {
101 + $config['welcome'] = [];
63 102 }
64 103
65 - $config['welcome'] = [];
104 + return $config;
105 + }
66 106
67 - return $config;
107 + private function is_request_from_theme_admin_page(): bool {
108 + $referer = wp_get_referer();
109 +
110 + if ( ! $referer ) {
111 + return false;
112 + }
113 +
114 + parse_str( (string) wp_parse_url( $referer, PHP_URL_QUERY ), $query_args );
115 +
116 + $page = $query_args['page'] ?? '';
117 +
118 + foreach ( self::THEME_SLUGS as $theme_slug ) {
119 + if ( $page === $theme_slug || $page === $theme_slug . self::THEME_SETTINGS_PAGE_SUFFIX ) {
120 + return true;
121 + }
122 + }
123 +
124 + return false;
68 125 }
69 126
70 127 public function ajax_dismiss_banner(): void {
71 128 try {
@@ -158,20 +215,20 @@
158 215 return $this->get_birthday_banner_config();
159 216 }
160 217
161 218 return [
162 - 'title' => esc_html__( 'Go Pro, Go Limitless', 'elementor' ),
163 - 'text' => esc_html__( 'Unlock the theme builder, popup builder, 100+ widgets and more advanced tools to take your website to the next level.', 'elementor' ),
219 + 'title' => __( 'Elevate your site with Elementor Pro', 'elementor' ),
220 + 'text' => __( 'Access Elementor\'s Theme Builder, Dynamic Content, WooCommerce Builder, Popup Builder, 85+ Pro widgets and more when you upgrade to Pro', 'elementor' ),
164 221 'buttons' => [
165 222 [
166 - 'text' => esc_html__( 'Upgrade Now', 'elementor' ),
167 - 'link' => Go_Pro_Promotion_Item::get_url(),
223 + 'text' => __( 'Upgrade now', 'elementor' ),
224 + 'link' => self::UPGRADE_URL,
168 225 'target' => '_blank',
169 226 ],
170 227 ],
171 228 'image' => [
172 229 'src' => '',
173 - 'alt' => esc_html__( 'Upgrade to Elementor Pro', 'elementor' ),
230 + 'alt' => __( 'Upgrade to Elementor Pro', 'elementor' ),
174 231 ],
175 232 ];
176 233 }
177 234
@@ -176,13 +233,13 @@
176 233 }
177 234
178 235 private function get_birthday_banner_config(): array {
179 236 return [
180 - 'title' => esc_html__( 'Celebrate 10 years of Elementor', 'elementor' ),
181 - 'text' => esc_html__( 'Upgrade your workflow with more capabilities for less. Offer ends June 17.', 'elementor' ),
237 + 'title' => __( 'Celebrate 10 years of Elementor', 'elementor' ),
238 + 'text' => __( 'Upgrade your workflow with more capabilities for less. Offer ends June 17.', 'elementor' ),
182 239 'buttons' => [
183 240 [
184 - 'text' => esc_html__( 'Get Discounts', 'elementor' ),
241 + 'text' => __( 'Get Discounts', 'elementor' ),
185 242 'link' => self::BIRTHDAY_PROMOTION_URL,
186 243 'target' => '_blank',
187 244 ],
188 245 ],
@@ -187,9 +244,9 @@
187 244 ],
188 245 ],
189 246 'image' => [
190 247 'src' => ELEMENTOR_ASSETS_URL . 'images/decade-birthday.png',
191 - 'alt' => esc_html__( 'Celebrate 10 years of Elementor', 'elementor' ),
248 + 'alt' => __( 'Celebrate 10 years of Elementor', 'elementor' ),
192 249 ],
193 250 ];
194 251 }
195 252
@@ -209,11 +266,48 @@
209 266 return $allowed_pages[ $current_screen->id ] ?? [];
210 267 }
211 268
212 269 private static function should_display(): bool {
213 - return ! Utils::has_pro() && ! self::is_dismissed();
270 + return ! Utils::has_pro() && ! self::is_dismissed() && self::has_min_elementor_pages();
214 271 }
215 272
273 + private static function is_unlocked(): bool {
274 + return self::UNLOCK_OPTION_VALUE === get_option( self::UNLOCK_OPTION_KEY );
275 + }
276 +
277 + private static function has_min_elementor_pages(): bool {
278 + if ( self::is_unlocked() ) {
279 + return true;
280 + }
281 +
282 + if ( get_transient( self::PENDING_TRANSIENT_KEY ) ) {
283 + return false;
284 + }
285 +
286 + $query = new \WP_Query( [
287 + 'fields' => 'ids',
288 + 'meta_key' => Document::BUILT_WITH_ELEMENTOR_META_KEY,
289 + 'meta_value' => 'builder',
290 + 'no_found_rows' => true,
291 + 'post_status' => 'any',
292 + 'post_type' => 'any',
293 + 'posts_per_page' => self::MIN_ELEMENTOR_PAGES_TO_TRIGGER,
294 + 'update_post_meta_cache' => false,
295 + 'update_post_term_cache' => false,
296 + ] );
297 +
298 + if ( count( $query->posts ) >= self::MIN_ELEMENTOR_PAGES_TO_TRIGGER ) {
299 + update_option( self::UNLOCK_OPTION_KEY, self::UNLOCK_OPTION_VALUE, true );
300 + delete_transient( self::PENDING_TRANSIENT_KEY );
301 +
302 + return true;
303 + }
304 +
305 + set_transient( self::PENDING_TRANSIENT_KEY, 1, self::PENDING_TTL );
306 +
307 + return false;
308 + }
309 +
216 310 private static function is_user_allowed(): bool {
217 311 return current_user_can( 'manage_options' );
218 312 }
219 313
@@ -222,8 +316,9 @@
222 316 }
223 317
224 318 private function get_allowed_admin_pages(): array {
225 319 $default = [ 'selector' => self::DEFAULT_SELECTOR ];
320 + $plugin_pages = [ 'selector' => '.wrap hr.wp-header-end' ];
226 321
227 322 return [
228 323 'dashboard' => [ 'selector' => '#wpbody #wpbody-content .wrap h1' ],
229 324 'toplevel_page_elementor' => [
@@ -229,15 +324,8 @@
229 324 'toplevel_page_elementor' => [
230 325 'selector' => '#e-home-screen',
231 326 'before' => true,
232 327 ],
233 - 'update-core' => $default,
234 - 'edit-post' => $default,
235 - 'edit-page' => $default,
236 - 'edit-category' => $default,
237 - 'edit-post_tag' => $default,
238 - 'upload' => $default,
239 - 'media' => $default,
240 328 'elementor_page_elementor-settings' => $default,
241 329 'elementor_page_elementor-tools' => $default,
242 330 'elementor_page_elementor-role-manager' => $default,
243 331 'elementor_page_elementor-element-manager' => [
@@ -259,27 +347,10 @@
259 347 'edit-elementor_library_category' => $default,
260 348 'themes' => $default,
261 349 'nav-menus' => $default,
262 350 'theme-editor' => $default,
263 - 'plugins' => $default,
264 - 'plugin-install' => $default,
265 - 'plugin-editor' => $default,
266 - 'users' => $default,
267 - 'user' => $default,
268 - 'profile' => $default,
269 - 'tools' => $default,
270 - 'import' => $default,
271 - 'export' => $default,
272 - 'site-health' => $default,
273 - 'export-personal-data' => $default,
274 - 'erase-personal-data' => $default,
275 - 'options-general' => $default,
276 - 'options-writing' => $default,
277 - 'options-reading' => $default,
278 - 'options-discussion' => $default,
279 - 'options-media' => $default,
280 - 'options-permalink' => $default,
281 - 'options-privacy' => $default,
282 - 'privacy-policy-guide' => $default,
351 + 'plugins' => $plugin_pages,
352 + 'plugin-install' => $plugin_pages,
353 + 'plugin-editor' => $plugin_pages,
283 354 ];
284 355 }
285 356 }