From 11d2315076dbc2f6d07f44872aee8cb99b408204 Mon Sep 17 00:00:00 2001 From: elchugreeva Date: Mon, 21 Oct 2024 11:12:46 +0200 Subject: [PATCH 1/5] Internal: Replace Free to Pro Upsell Promotion - Video & button Widgets [ED-15843] --- includes/widgets/button.php | 24 ++---------------- includes/widgets/video.php | 24 ++---------------- modules/promotions/promotion-data.php | 36 +++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 44 deletions(-) diff --git a/includes/widgets/button.php b/includes/widgets/button.php index c12c76300398..93175d863c15 100644 --- a/includes/widgets/button.php +++ b/includes/widgets/button.php @@ -85,28 +85,6 @@ public function has_widget_inner_wrapper(): bool { return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); } - /** - * Get widget upsale data. - * - * Retrieve the widget promotion data. - * - * @since 3.19.0 - * @access protected - * - * @return array Widget promotion data. - */ - protected function get_upsale_data() { - return [ - 'condition' => ! Utils::has_pro(), - 'image' => esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ), - 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), - 'title' => esc_html__( 'Convert visitors into customers', 'elementor' ), - 'description' => esc_html__( 'Get the Call to Action widget and grow your toolbox with Elementor Pro.', 'elementor' ), - 'upgrade_url' => esc_url( 'https://go.elementor.com/go-pro-button-widget/' ), - 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ), - ]; - } - protected function register_controls() { $this->start_controls_section( 'section_button', @@ -117,6 +95,8 @@ protected function register_controls() { $this->register_button_content_controls(); + Plugin::$instance->controls_manager->add_free_to_pro_upsale_promotion_control( $this, esc_html__( 'Call to Action widget', 'elementor' ), Utils::CTA ); + $this->end_controls_section(); $this->start_controls_section( diff --git a/includes/widgets/video.php b/includes/widgets/video.php index 5653d8ab12ba..4d0a713eeff1 100644 --- a/includes/widgets/video.php +++ b/includes/widgets/video.php @@ -110,28 +110,6 @@ public function has_widget_inner_wrapper(): bool { return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); } - /** - * Register video widget controls. - * - * Adds different input fields to allow the user to change and customize the widget settings. - * - * @since 3.19.0 - * @access protected - * - * @return array Widget promotion data. - */ - protected function get_upsale_data() { - return [ - 'condition' => ! Utils::has_pro(), - 'image' => esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ), - 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), - 'title' => esc_html__( "Grab your visitors' attention", 'elementor' ), - 'description' => esc_html__( 'Get the Video Playlist widget and grow your toolbox with Elementor Pro.', 'elementor' ), - 'upgrade_url' => esc_url( 'https://go.elementor.com/go-pro-video-widget/' ), - 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ), - ]; - } - /** * Register video widget controls. * @@ -626,6 +604,8 @@ protected function register_controls() { ] ); + Plugin::$instance->controls_manager->add_free_to_pro_upsale_promotion_control( $this, esc_html__( 'Video Playlist widget', 'elementor' ), Utils::VIDEO_PLAYLIST ); + $this->end_controls_section(); $this->start_controls_section( diff --git a/modules/promotions/promotion-data.php b/modules/promotions/promotion-data.php index 8bb0a9969b01..dfb0eb30ff5a 100644 --- a/modules/promotions/promotion-data.php +++ b/modules/promotions/promotion-data.php @@ -21,6 +21,8 @@ public static function get_promotion_data( $force_request = false ): array { return [ Utils::ANIMATED_HEADLINE => self::get_animated_headline_data( $assets_data ), + Utils::VIDEO_PLAYLIST => self::get_video_playlist_data( $assets_data ), + Utils::CTA => self::get_cta_button_data( $assets_data ), ]; } @@ -52,6 +54,40 @@ private static function get_animated_headline_data( $assets_data ) { return self::filter_data( Utils::ANIMATED_HEADLINE, $data ); } + private static function get_video_playlist_data( $assets_data ) { + $data = [ + 'image' => esc_url( $assets_data[ Utils::VIDEO_PLAYLIST ] ) ?? '', + 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), + 'title' => esc_html__( 'Showcase Video Playlists', 'elementor' ), + 'description' => [ + esc_html__( 'Embed videos with full control.', 'elementor' ), + esc_html__( 'Adjust layout and playback settings.', 'elementor' ), + esc_html__( 'Seamlessly customize video appearance.', 'elementor' ), + ], + 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ), + 'upgrade_url' => 'https://go.elementor.com/go-pro-video-widget/', + ]; + + return self::filter_data( Utils::VIDEO_PLAYLIST, $data ); + } + + private static function get_cta_button_data( $assets_data ) { + $data = [ + 'image' => esc_url( $assets_data[ Utils::CTA ] ) ?? '', + 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), + 'title' => esc_html__( 'Boost Conversions with CTAs', 'elementor' ), + 'description' => [ + esc_html__( 'Combine text, buttons, and images.', 'elementor' ), + esc_html__( 'Add hover animations and CSS effects.', 'elementor' ), + esc_html__( 'Create unique, interactive designs.', 'elementor' ), + ], + 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ), + 'upgrade_url' => 'https://go.elementor.com/go-pro-button-widget/', + ]; + + return self::filter_data( Utils::CTA, $data ); + } + private static function filter_data( $widget_name, $asset_data ) { return Filtered_Promotions_Manager::get_filtered_promotion_data( $asset_data, "elementor/widgets/{$widget_name}/custom_promotion", 'upgrade_url' ); } From 2be992b525165836614ef9331fc351d0d601cbe0 Mon Sep 17 00:00:00 2001 From: elchugreeva Date: Mon, 21 Oct 2024 11:25:22 +0200 Subject: [PATCH 2/5] tests --- .../modules/promotions/promotions.test.ts | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/playwright/sanity/modules/promotions/promotions.test.ts b/tests/playwright/sanity/modules/promotions/promotions.test.ts index c4d9e739deb9..c4e4012e7211 100644 --- a/tests/playwright/sanity/modules/promotions/promotions.test.ts +++ b/tests/playwright/sanity/modules/promotions/promotions.test.ts @@ -62,15 +62,22 @@ test.describe( 'Promotion tests @promotions', () => { promotionsHelper = new PromotionsHelper( page, testInfo ), container = await editor.addElement( { elType: 'container' }, 'document' ); - await editor.addWidget( 'heading', container ); + await test.step( 'Free to Pro - react animated headline modal visible', async () => { + await editor.addWidget( 'heading', container ); + await editor.openPanelTab( 'content' ); + await promotionsHelper.modalPromotionModalVisibilityTest( 'animated_headline_promotion' ); + } ); - await editor.openPanelTab( 'content' ); + await test.step( 'Free to Pro - react video playlist modal visible', async () => { + await editor.addWidget( 'video', container ); + await editor.openPanelTab( 'content' ); + await promotionsHelper.modalPromotionModalVisibilityTest( 'video_playlist_promotion' ); + } ); - await test.step( 'Free to Pro - react modals screenshot tests', async () => { - const promotionControls = [ 'animated_headline_promotion' ]; - for ( const effect of promotionControls ) { - await promotionsHelper.modalPromotionModalVisibilityTest( effect ); - } + await test.step( 'Free to Pro - react cta button modal visible', async () => { + await editor.addWidget( 'button', container ); + await editor.openPanelTab( 'content' ); + await promotionsHelper.modalPromotionModalVisibilityTest( 'cta_promotion' ); } ); } ); From efcadfe8cbe3bd7e3e0f19d7b3f7ac564723113c Mon Sep 17 00:00:00 2001 From: elchugreeva Date: Mon, 21 Oct 2024 12:00:15 +0200 Subject: [PATCH 3/5] testimonial & image carousel --- includes/widgets/image-carousel.php | 23 ++---------- includes/widgets/testimonial.php | 23 ++---------- modules/promotions/promotion-data.php | 36 +++++++++++++++++++ .../modules/promotions/promotions.test.ts | 13 +++++++ 4 files changed, 53 insertions(+), 42 deletions(-) diff --git a/includes/widgets/image-carousel.php b/includes/widgets/image-carousel.php index fd7628e3211f..95fd6e456875 100644 --- a/includes/widgets/image-carousel.php +++ b/includes/widgets/image-carousel.php @@ -91,27 +91,6 @@ public function get_style_depends(): array { return [ 'e-swiper', 'widget-image-carousel' ]; } - /** - * Get widget upsale data. - * - * Retrieve the widget promotion data. - * - * @since 3.18.0 - * @access protected - * - * @return array Widget promotion data. - */ - protected function get_upsale_data() { - return [ - 'condition' => ! Utils::has_pro(), - 'image' => esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ), - 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), - 'description' => esc_html__( 'Gain complete freedom to design every slide with Elementor"s Pro Carousel.', 'elementor' ), - 'upgrade_url' => esc_url( 'https://go.elementor.com/go-pro-image-carousel-widget/' ), - 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ), - ]; - } - public function has_widget_inner_wrapper(): bool { return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); } @@ -395,6 +374,8 @@ protected function register_controls() { ] ); + Plugin::$instance->controls_manager->add_free_to_pro_upsale_promotion_control( $this, esc_html__( 'Carousel PRO widget', 'elementor' ), Utils::IMAGE_CAROUSEL ); + $this->end_controls_section(); $this->start_controls_section( diff --git a/includes/widgets/testimonial.php b/includes/widgets/testimonial.php index 23a7445e67e7..7b5c9cec931b 100644 --- a/includes/widgets/testimonial.php +++ b/includes/widgets/testimonial.php @@ -95,27 +95,6 @@ public function has_widget_inner_wrapper(): bool { return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); } - /** - * Get widget upsale data. - * - * Retrieve the widget promotion data. - * - * @since 3.18.0 - * @access protected - * - * @return array Widget promotion data. - */ - protected function get_upsale_data() { - return [ - 'condition' => ! Utils::has_pro(), - 'image' => esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ), - 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), - 'description' => esc_html__( 'Use interesting masonry layouts and other overlay features with Elementor\'s Pro Gallery widget.', 'elementor' ), - 'upgrade_url' => esc_url( 'https://go.elementor.com/go-pro-testimonial-widget/' ), - 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ), - ]; - } - /** * Register testimonial widget controls. * @@ -262,6 +241,8 @@ protected function register_controls() { ] ); + Plugin::$instance->controls_manager->add_free_to_pro_upsale_promotion_control( $this, esc_html__( 'Loop Carousel widget', 'elementor' ), Utils::TESTIMONIAL_WIDGET ); + $this->end_controls_section(); // Content. diff --git a/modules/promotions/promotion-data.php b/modules/promotions/promotion-data.php index dfb0eb30ff5a..68dd15b4c698 100644 --- a/modules/promotions/promotion-data.php +++ b/modules/promotions/promotion-data.php @@ -23,6 +23,8 @@ public static function get_promotion_data( $force_request = false ): array { Utils::ANIMATED_HEADLINE => self::get_animated_headline_data( $assets_data ), Utils::VIDEO_PLAYLIST => self::get_video_playlist_data( $assets_data ), Utils::CTA => self::get_cta_button_data( $assets_data ), + Utils::IMAGE_CAROUSEL => self::get_image_carousel_data( $assets_data ), + Utils:: TESTIMONIAL_WIDGET => self::get_testimonial_widget_data( $assets_data ), ]; } @@ -88,6 +90,40 @@ private static function get_cta_button_data( $assets_data ) { return self::filter_data( Utils::CTA, $data ); } + private static function get_image_carousel_data( $assets_data ) { + $data = [ + 'image' => esc_url( $assets_data[ Utils::IMAGE_CAROUSEL ] ) ?? '', + 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), + 'title' => esc_html__( 'Design Custom Carousels', 'elementor' ), + 'description' => [ + esc_html__( 'Create flexible custom carousels.', 'elementor' ), + esc_html__( 'Adjust transitions and animations easily.', 'elementor' ), + esc_html__( 'Showcase multiple items with style.', 'elementor' ), + ], + 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ), + 'upgrade_url' => 'https://go.elementor.com/go-pro-image-carousel-widget/', + ]; + + return self::filter_data( Utils::IMAGE_CAROUSEL, $data ); + } + + private static function get_testimonial_widget_data( $assets_data ) { + $data = [ + 'image' => esc_url( $assets_data[ Utils::TESTIMONIAL_WIDGET ] ) ?? '', + 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), + 'title' => esc_html__( 'Upgrade Your Testimonials', 'elementor' ), + 'description' => [ + esc_html__( 'Display reviews in a rotating carousel.', 'elementor' ), + esc_html__( 'Boost credibility with dynamic testimonials.', 'elementor' ), + esc_html__( 'Customize layouts for visual appeal.', 'elementor' ), + ], + 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ), + 'upgrade_url' => 'https://go.elementor.com/go-pro-testimonial-widget/', + ]; + + return self::filter_data( Utils::TESTIMONIAL_WIDGET, $data ); + } + private static function filter_data( $widget_name, $asset_data ) { return Filtered_Promotions_Manager::get_filtered_promotion_data( $asset_data, "elementor/widgets/{$widget_name}/custom_promotion", 'upgrade_url' ); } diff --git a/tests/playwright/sanity/modules/promotions/promotions.test.ts b/tests/playwright/sanity/modules/promotions/promotions.test.ts index c4e4012e7211..2cd4dcd6c758 100644 --- a/tests/playwright/sanity/modules/promotions/promotions.test.ts +++ b/tests/playwright/sanity/modules/promotions/promotions.test.ts @@ -79,6 +79,19 @@ test.describe( 'Promotion tests @promotions', () => { await editor.openPanelTab( 'content' ); await promotionsHelper.modalPromotionModalVisibilityTest( 'cta_promotion' ); } ); + + await test.step( 'Free to Pro - react image carousel modal visible', async () => { + await editor.addWidget( 'image-carousel', container ); + await editor.openPanelTab( 'content' ); + await promotionsHelper.modalPromotionModalVisibilityTest( 'image_carousel_promotion' ); + } ); + + await test.step( 'Free to Pro - react testimonial modal visible', async () => { + await editor.addWidget( 'testimonial', container ); + await editor.openPanelTab( 'content' ); + await promotionsHelper.modalPromotionModalVisibilityTest( 'testimonial_widget_promotion' ); + } ); + } ); test( 'Context Menu Promotions - Free to Pro', async ( { page, apiRequests }, testInfo ) => { From a87d712d63c1e2e3f5d57b9a8e5bc7dcc6d30dd6 Mon Sep 17 00:00:00 2001 From: elchugreeva Date: Mon, 21 Oct 2024 14:27:33 +0200 Subject: [PATCH 4/5] comment fix --- modules/promotions/promotion-data.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/promotions/promotion-data.php b/modules/promotions/promotion-data.php index 68dd15b4c698..71779869bb6e 100644 --- a/modules/promotions/promotion-data.php +++ b/modules/promotions/promotion-data.php @@ -41,7 +41,7 @@ private static function transform_assets_data( $force_request = false ) { private static function get_animated_headline_data( $assets_data ) { $data = [ - 'image' => esc_url( $assets_data[ Utils::ANIMATED_HEADLINE ] ) ?? '', + 'image' => esc_url( $assets_data[ Utils::ANIMATED_HEADLINE ] ?? '' ), 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), 'title' => esc_html__( 'Bring Headlines to Life', 'elementor' ), 'description' => [ @@ -58,7 +58,7 @@ private static function get_animated_headline_data( $assets_data ) { private static function get_video_playlist_data( $assets_data ) { $data = [ - 'image' => esc_url( $assets_data[ Utils::VIDEO_PLAYLIST ] ) ?? '', + 'image' => esc_url( $assets_data[ Utils::VIDEO_PLAYLIST ] ?? '' ), 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), 'title' => esc_html__( 'Showcase Video Playlists', 'elementor' ), 'description' => [ @@ -75,7 +75,7 @@ private static function get_video_playlist_data( $assets_data ) { private static function get_cta_button_data( $assets_data ) { $data = [ - 'image' => esc_url( $assets_data[ Utils::CTA ] ) ?? '', + 'image' => esc_url( $assets_data[ Utils::CTA ] ?? '' ), 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), 'title' => esc_html__( 'Boost Conversions with CTAs', 'elementor' ), 'description' => [ @@ -92,7 +92,7 @@ private static function get_cta_button_data( $assets_data ) { private static function get_image_carousel_data( $assets_data ) { $data = [ - 'image' => esc_url( $assets_data[ Utils::IMAGE_CAROUSEL ] ) ?? '', + 'image' => esc_url( $assets_data[ Utils::IMAGE_CAROUSEL ] ?? '' ), 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), 'title' => esc_html__( 'Design Custom Carousels', 'elementor' ), 'description' => [ @@ -109,7 +109,7 @@ private static function get_image_carousel_data( $assets_data ) { private static function get_testimonial_widget_data( $assets_data ) { $data = [ - 'image' => esc_url( $assets_data[ Utils::TESTIMONIAL_WIDGET ] ) ?? '', + 'image' => esc_url( $assets_data[ Utils::TESTIMONIAL_WIDGET ] ?? '' ), 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), 'title' => esc_html__( 'Upgrade Your Testimonials', 'elementor' ), 'description' => [ From a80ac294a371b75365e4a41b5d8720186939762b Mon Sep 17 00:00:00 2001 From: elchugreeva Date: Mon, 21 Oct 2024 17:12:00 +0200 Subject: [PATCH 5/5] comment fix --- modules/promotions/promotion-data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/promotions/promotion-data.php b/modules/promotions/promotion-data.php index 16485bd44e47..b2ab813c1c3c 100644 --- a/modules/promotions/promotion-data.php +++ b/modules/promotions/promotion-data.php @@ -121,6 +121,6 @@ private function get_testimonial_widget_data( $assets_data ) { } private function filter_data( $widget_name, $asset_data ): array { - return Filtered_Promotions_Manager::get_filtered_promotion_data( $asset_data, "elementor/widgets/{$widget_name}/custom_promotion", 'upgrade_url'); + return Filtered_Promotions_Manager::get_filtered_promotion_data( $asset_data, "elementor/widgets/{$widget_name}/custom_promotion", 'upgrade_url' ); } }