PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.1
Elementor Website Builder – more than just a page builder v4.3.1
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 +78 -10 4.3.0-beta2 → 4.3.1 View file →
@@ -1,8 +1,9 @@
1 1 <?php
2 2
3 3 namespace Elementor\Modules\Promotions;
4 4
5 +use Elementor\Core\Base\Document;
5 6 use Elementor\User;
6 7 use Elementor\Utils;
7 8
8 9 if ( ! defined( 'ABSPATH' ) ) {
@@ -25,8 +26,13 @@
25 26 const HELLO_THEME_CONFIG_FILTER = 'hello-plus-theme/rest/admin-config';
26 27 const THEME_SLUGS = [ 'hello-elementor', 'hello-biz', 'hello-commerce' ];
27 28 const THEME_SETTINGS_PAGE_SUFFIX = '-settings';
28 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';
29 35
30 36 public function __construct() {
31 37 add_action( 'wp_ajax_' . self::AJAX_ACTION, [ $this, 'ajax_dismiss_banner' ] );
32 38
@@ -34,12 +40,37 @@
34 40
35 41 add_action( 'current_screen', [ $this, 'maybe_register_banner_hooks' ] );
36 42 }
37 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 +
38 69 public function maybe_register_banner_hooks(): void {
39 70 $placement = $this->get_active_placement();
40 71
41 - if ( empty( $placement ) ) {
72 + if ( empty( $placement ) || ! self::has_min_elementor_pages() ) {
42 73 return;
43 74 }
44 75
45 76 add_action( 'in_admin_header', [ $this, 'render_banner_container' ], 11 );
@@ -184,13 +215,13 @@
184 215 return $this->get_birthday_banner_config();
185 216 }
186 217
187 218 return [
188 - 'title' => esc_html__( 'Build more with Elementor Pro', 'elementor' ),
189 - 'text' => esc_html__( 'Add the theme builder, popup builder, and 85+ advanced widgets to your Elementor Editor.', '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' ),
190 221 'buttons' => [
191 222 [
192 - 'text' => esc_html__( 'Upgrade now', 'elementor' ),
223 + 'text' => __( 'Upgrade now', 'elementor' ),
193 224 'link' => self::UPGRADE_URL,
194 225 'target' => '_blank',
195 226 ],
196 227 ],
@@ -195,9 +226,9 @@
195 226 ],
196 227 ],
197 228 'image' => [
198 229 'src' => '',
199 - 'alt' => esc_html__( 'Upgrade to Elementor Pro', 'elementor' ),
230 + 'alt' => __( 'Upgrade to Elementor Pro', 'elementor' ),
200 231 ],
201 232 ];
202 233 }
203 234
@@ -202,13 +233,13 @@
202 233 }
203 234
204 235 private function get_birthday_banner_config(): array {
205 236 return [
206 - 'title' => esc_html__( 'Celebrate 10 years of Elementor', 'elementor' ),
207 - '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' ),
208 239 'buttons' => [
209 240 [
210 - 'text' => esc_html__( 'Get Discounts', 'elementor' ),
241 + 'text' => __( 'Get Discounts', 'elementor' ),
211 242 'link' => self::BIRTHDAY_PROMOTION_URL,
212 243 'target' => '_blank',
213 244 ],
214 245 ],
@@ -213,9 +244,9 @@
213 244 ],
214 245 ],
215 246 'image' => [
216 247 'src' => ELEMENTOR_ASSETS_URL . 'images/decade-birthday.png',
217 - 'alt' => esc_html__( 'Celebrate 10 years of Elementor', 'elementor' ),
248 + 'alt' => __( 'Celebrate 10 years of Elementor', 'elementor' ),
218 249 ],
219 250 ];
220 251 }
221 252
@@ -235,9 +266,46 @@
235 266 return $allowed_pages[ $current_screen->id ] ?? [];
236 267 }
237 268
238 269 private static function should_display(): bool {
239 - return ! Utils::has_pro() && ! self::is_dismissed();
270 + return ! Utils::has_pro() && ! self::is_dismissed() && self::has_min_elementor_pages();
271 + }
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;
240 308 }
241 309
242 310 private static function is_user_allowed(): bool {
243 311 return current_user_can( 'manage_options' );