admin-menu-items
9 months ago
controls
1 year ago
pointers
1 year ago
widgets
9 months ago
module.php
1 year ago
promotion-data.php
1 year ago
promotion-data.php
127 lines
| 1 | <?php |
| 2 | namespace Elementor\Modules\Promotions; |
| 3 | |
| 4 | use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager; |
| 5 | use Elementor\Includes\EditorAssetsAPI; |
| 6 | use Elementor\Utils; |
| 7 | |
| 8 | class PromotionData { |
| 9 | protected EditorAssetsAPI $editor_assets_api; |
| 10 | |
| 11 | public function __construct( EditorAssetsAPI $editor_assets_api ) { |
| 12 | $this->editor_assets_api = $editor_assets_api; |
| 13 | } |
| 14 | |
| 15 | public function get_promotion_data( $force_request = false ): array { |
| 16 | $assets_data = $this->transform_assets_data( $force_request ); |
| 17 | |
| 18 | return [ |
| 19 | Utils::ANIMATED_HEADLINE => $this->get_animated_headline_data( $assets_data ), |
| 20 | Utils::VIDEO_PLAYLIST => $this->get_video_playlist_data( $assets_data ), |
| 21 | Utils::CTA => $this->get_cta_button_data( $assets_data ), |
| 22 | Utils::IMAGE_CAROUSEL => $this->get_image_carousel_data( $assets_data ), |
| 23 | Utils::TESTIMONIAL_WIDGET => $this->get_testimonial_widget_data( $assets_data ), |
| 24 | ]; |
| 25 | } |
| 26 | |
| 27 | private function transform_assets_data( $force_request = false ) { |
| 28 | $assets_data = $this->editor_assets_api->get_assets_data( $force_request ); |
| 29 | $transformed_data = []; |
| 30 | |
| 31 | foreach ( $assets_data as $asset ) { |
| 32 | $transformed_data[ $asset['id'] ] = $asset['imageSrc']; |
| 33 | } |
| 34 | |
| 35 | return $transformed_data; |
| 36 | } |
| 37 | |
| 38 | private function get_animated_headline_data( $assets_data ) { |
| 39 | $data = [ |
| 40 | 'image' => esc_url( $assets_data[ Utils::ANIMATED_HEADLINE ] ?? '' ), |
| 41 | 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), |
| 42 | 'title' => esc_html__( 'Bring Headlines to Life', 'elementor' ), |
| 43 | 'description' => [ |
| 44 | esc_html__( 'Highlight key messages dynamically.', 'elementor' ), |
| 45 | esc_html__( 'Apply rotating effects to text.', 'elementor' ), |
| 46 | esc_html__( 'Fully customize your headlines.', 'elementor' ), |
| 47 | ], |
| 48 | 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ), |
| 49 | 'upgrade_url' => 'https://go.elementor.com/go-pro-heading-widget-control/', |
| 50 | ]; |
| 51 | |
| 52 | return $this->filter_data( Utils::ANIMATED_HEADLINE, $data ); |
| 53 | } |
| 54 | |
| 55 | private function get_video_playlist_data( $assets_data ) { |
| 56 | $data = [ |
| 57 | 'image' => esc_url( $assets_data[ Utils::VIDEO_PLAYLIST ] ?? '' ), |
| 58 | 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), |
| 59 | 'title' => esc_html__( 'Showcase Video Playlists', 'elementor' ), |
| 60 | 'description' => [ |
| 61 | esc_html__( 'Embed videos with full control.', 'elementor' ), |
| 62 | esc_html__( 'Adjust layout and playback settings.', 'elementor' ), |
| 63 | esc_html__( 'Seamlessly customize video appearance.', 'elementor' ), |
| 64 | ], |
| 65 | 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ), |
| 66 | 'upgrade_url' => 'https://go.elementor.com/go-pro-video-widget-control/', |
| 67 | ]; |
| 68 | |
| 69 | return $this->filter_data( Utils::VIDEO_PLAYLIST, $data ); |
| 70 | } |
| 71 | |
| 72 | private function get_cta_button_data( $assets_data ) { |
| 73 | $data = [ |
| 74 | 'image' => esc_url( $assets_data[ Utils::CTA ] ?? '' ), |
| 75 | 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), |
| 76 | 'title' => esc_html__( 'Boost Conversions with CTAs', 'elementor' ), |
| 77 | 'description' => [ |
| 78 | esc_html__( 'Combine text, buttons, and images.', 'elementor' ), |
| 79 | esc_html__( 'Add hover animations and CSS effects.', 'elementor' ), |
| 80 | esc_html__( 'Create unique, interactive designs.', 'elementor' ), |
| 81 | ], |
| 82 | 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ), |
| 83 | 'upgrade_url' => 'https://go.elementor.com/go-pro-button-widget-control/', |
| 84 | ]; |
| 85 | |
| 86 | return $this->filter_data( Utils::CTA, $data ); |
| 87 | } |
| 88 | |
| 89 | private function get_image_carousel_data( $assets_data ) { |
| 90 | $data = [ |
| 91 | 'image' => esc_url( $assets_data[ Utils::IMAGE_CAROUSEL ] ?? '' ), |
| 92 | 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), |
| 93 | 'title' => esc_html__( 'Design Custom Carousels', 'elementor' ), |
| 94 | 'description' => [ |
| 95 | esc_html__( 'Create flexible custom carousels.', 'elementor' ), |
| 96 | esc_html__( 'Adjust transitions and animations.', 'elementor' ), |
| 97 | esc_html__( 'Showcase multiple items with style.', 'elementor' ), |
| 98 | ], |
| 99 | 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ), |
| 100 | 'upgrade_url' => 'https://go.elementor.com/go-pro-image-carousel-widget-control/', |
| 101 | ]; |
| 102 | |
| 103 | return $this->filter_data( Utils::IMAGE_CAROUSEL, $data ); |
| 104 | } |
| 105 | |
| 106 | private function get_testimonial_widget_data( $assets_data ) { |
| 107 | $data = [ |
| 108 | 'image' => esc_url( $assets_data[ Utils::TESTIMONIAL_WIDGET ] ?? '' ), |
| 109 | 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), |
| 110 | 'title' => esc_html__( 'Upgrade Your Testimonials', 'elementor' ), |
| 111 | 'description' => [ |
| 112 | esc_html__( 'Display reviews in a rotating carousel.', 'elementor' ), |
| 113 | esc_html__( 'Boost credibility with dynamic testimonials.', 'elementor' ), |
| 114 | esc_html__( 'Customize layouts for visual appeal.', 'elementor' ), |
| 115 | ], |
| 116 | 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ), |
| 117 | 'upgrade_url' => 'https://go.elementor.com/go-pro-testimonial-widget-control/', |
| 118 | ]; |
| 119 | |
| 120 | return $this->filter_data( Utils::TESTIMONIAL_WIDGET, $data ); |
| 121 | } |
| 122 | |
| 123 | private function filter_data( $widget_name, $asset_data ): array { |
| 124 | return Filtered_Promotions_Manager::get_filtered_promotion_data( $asset_data, "elementor/widgets/{$widget_name}/custom_promotion", 'upgrade_url' ); |
| 125 | } |
| 126 | } |
| 127 |