| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\Promotions\Widgets; |
| 4 |
|
| 5 |
use Elementor\Plugin; |
| 6 |
|
| 7 |
if ( ! defined( 'ABSPATH' ) ) { |
| 8 |
exit; |
| 9 |
} |
| 10 |
|
| 11 |
class Collection_Loop_Widget_Promotion { |
| 12 |
|
| 13 |
private const LOOP_PROMOTION_IMAGE_URL = 'https://assets.elementor.com/packages/v1/images/Loop_grid_promotion.png'; |
| 14 |
|
| 15 |
public function register(): void { |
| 16 |
add_filter( 'elementor/editor/localize_settings', [ $this, 'add_promotion_data' ] ); |
| 17 |
} |
| 18 |
|
| 19 |
private function is_active(): bool { |
| 20 |
return Plugin::$instance->experiments->is_feature_active( 'e_atomic_elements' ); |
| 21 |
} |
| 22 |
|
| 23 |
public function add_promotion_data( array $settings ): array { |
| 24 |
if ( ! current_user_can( 'manage_options' ) || ! $this->is_active() ) { |
| 25 |
return $settings; |
| 26 |
} |
| 27 |
|
| 28 |
if ( ! isset( $settings['atomicWidgetPromotions'] ) ) { |
| 29 |
$settings['atomicWidgetPromotions'] = []; |
| 30 |
} |
| 31 |
|
| 32 |
$settings['atomicWidgetPromotions'][] = [ |
| 33 |
'type' => 'collection-loop', |
| 34 |
'cardType' => 'atomic', |
| 35 |
'widgets' => $this->get_widgets(), |
| 36 |
'content' => $this->get_promotion_content(), |
| 37 |
]; |
| 38 |
|
| 39 |
return $settings; |
| 40 |
} |
| 41 |
|
| 42 |
private function get_widgets(): array { |
| 43 |
return [ |
| 44 |
[ |
| 45 |
'name' => 'e-collection-loop', |
| 46 |
'title' => __( 'Loop', 'elementor' ), |
| 47 |
'icon' => 'eicon-loop-widget', |
| 48 |
'categories' => '["v4-elements"]', |
| 49 |
], |
| 50 |
]; |
| 51 |
} |
| 52 |
|
| 53 |
private function get_promotion_content(): array { |
| 54 |
return [ |
| 55 |
'title' => __( 'Loop', 'elementor' ), |
| 56 |
'content' => __( 'Upgrade to connect custom layouts directly to your site database, seamlessly rendering dynamic content queries that engage your site visitors.', 'elementor' ), |
| 57 |
'ctaText' => __( 'Upgrade now', 'elementor' ), |
| 58 |
'image' => self::LOOP_PROMOTION_IMAGE_URL, |
| 59 |
'widgetCtaUrl' => 'https://go.elementor.com/go-pro-loop-modal/', |
| 60 |
'sectionCtaUrl' => 'https://go.elementor.com/go-pro-loop-section/', |
| 61 |
]; |
| 62 |
} |
| 63 |
} |
| 64 |
|