| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Elementor\Modules\Promotions; |
| 4 | 4 | |
| 5 | -use Elementor\Core\Base\Document; | |
| 5 | +use Elementor\Modules\Promotions\AdminMenuItems\Go_Pro_Promotion_Item; | |
| 6 | 6 | use Elementor\User; |
| 7 | 7 | use Elementor\Utils; |
| 8 | 8 | |
| 9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
| @@ -19,20 +19,13 @@ | ||
| 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/'; | |
| 24 | 23 | const BIRTHDAY_PROMOTION_URL = 'https://go.elementor.com/go-pro-wp-admin-upgrad-notice/'; |
| 25 | 24 | |
| 26 | 25 | const HELLO_THEME_CONFIG_FILTER = 'hello-plus-theme/rest/admin-config'; |
| 27 | 26 | const THEME_SLUGS = [ 'hello-elementor', 'hello-biz', 'hello-commerce' ]; |
| 28 | - const THEME_SETTINGS_PAGE_SUFFIX = '-settings'; | |
| 29 | 27 | 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'; | |
| 35 | 28 | |
| 36 | 29 | public function __construct() { |
| 37 | 30 | add_action( 'wp_ajax_' . self::AJAX_ACTION, [ $this, 'ajax_dismiss_banner' ] ); |
| 38 | 31 | |
| @@ -40,37 +33,12 @@ | ||
| 40 | 33 | |
| 41 | 34 | add_action( 'current_screen', [ $this, 'maybe_register_banner_hooks' ] ); |
| 42 | 35 | } |
| 43 | 36 | |
| 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 | - | |
| 69 | 37 | public function maybe_register_banner_hooks(): void { |
| 70 | 38 | $placement = $this->get_active_placement(); |
| 71 | 39 | |
| 72 | - if ( empty( $placement ) || ! self::has_min_elementor_pages() ) { | |
| 40 | + if ( empty( $placement ) ) { | |
| 73 | 41 | return; |
| 74 | 42 | } |
| 75 | 43 | |
| 76 | 44 | add_action( 'in_admin_header', [ $this, 'render_banner_container' ], 11 ); |
| @@ -112,17 +80,9 @@ | ||
| 112 | 80 | } |
| 113 | 81 | |
| 114 | 82 | parse_str( (string) wp_parse_url( $referer, PHP_URL_QUERY ), $query_args ); |
| 115 | 83 | |
| 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; | |
| 84 | + return in_array( $query_args['page'] ?? '', self::THEME_SLUGS ); | |
| 125 | 85 | } |
| 126 | 86 | |
| 127 | 87 | public function ajax_dismiss_banner(): void { |
| 128 | 88 | try { |
| @@ -215,14 +175,14 @@ | ||
| 215 | 175 | return $this->get_birthday_banner_config(); |
| 216 | 176 | } |
| 217 | 177 | |
| 218 | 178 | return [ |
| 219 | - 'title' => esc_html__( 'Build more with Elementor Pro', 'elementor' ), | |
| 220 | - 'text' => esc_html__( 'Add the theme builder, popup builder, and 85+ advanced widgets to your Elementor Editor.', 'elementor' ), | |
| 179 | + 'title' => esc_html__( 'Go Pro, Go Limitless', 'elementor' ), | |
| 180 | + 'text' => esc_html__( 'Unlock the theme builder, popup builder, 100+ widgets and more advanced tools to take your website to the next level.', 'elementor' ), | |
| 221 | 181 | 'buttons' => [ |
| 222 | 182 | [ |
| 223 | - 'text' => esc_html__( 'Upgrade now', 'elementor' ), | |
| 224 | - 'link' => self::UPGRADE_URL, | |
| 183 | + 'text' => esc_html__( 'Upgrade Now', 'elementor' ), | |
| 184 | + 'link' => Go_Pro_Promotion_Item::get_url(), | |
| 225 | 185 | 'target' => '_blank', |
| 226 | 186 | ], |
| 227 | 187 | ], |
| 228 | 188 | 'image' => [ |
| @@ -266,48 +226,11 @@ | ||
| 266 | 226 | return $allowed_pages[ $current_screen->id ] ?? []; |
| 267 | 227 | } |
| 268 | 228 | |
| 269 | 229 | private static function should_display(): bool { |
| 270 | - return ! Utils::has_pro() && ! self::is_dismissed() && self::has_min_elementor_pages(); | |
| 230 | + return ! Utils::has_pro() && ! self::is_dismissed(); | |
| 271 | 231 | } |
| 272 | 232 | |
| 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 | - | |
| 310 | 233 | private static function is_user_allowed(): bool { |
| 311 | 234 | return current_user_can( 'manage_options' ); |
| 312 | 235 | } |
| 313 | 236 | |
| @@ -316,9 +239,8 @@ | ||
| 316 | 239 | } |
| 317 | 240 | |
| 318 | 241 | private function get_allowed_admin_pages(): array { |
| 319 | 242 | $default = [ 'selector' => self::DEFAULT_SELECTOR ]; |
| 320 | - $plugin_pages = [ 'selector' => '.wrap hr.wp-header-end' ]; | |
| 321 | 243 | |
| 322 | 244 | return [ |
| 323 | 245 | 'dashboard' => [ 'selector' => '#wpbody #wpbody-content .wrap h1' ], |
| 324 | 246 | 'toplevel_page_elementor' => [ |
| @@ -347,10 +269,10 @@ | ||
| 347 | 269 | 'edit-elementor_library_category' => $default, |
| 348 | 270 | 'themes' => $default, |
| 349 | 271 | 'nav-menus' => $default, |
| 350 | 272 | 'theme-editor' => $default, |
| 351 | - 'plugins' => $plugin_pages, | |
| 352 | - 'plugin-install' => $plugin_pages, | |
| 353 | - 'plugin-editor' => $plugin_pages, | |
| 273 | + 'plugins' => $default, | |
| 274 | + 'plugin-install' => $default, | |
| 275 | + 'plugin-editor' => $default, | |
| 354 | 276 | ]; |
| 355 | 277 | } |
| 356 | 278 | } |