| 1 |
<?php |
| 2 |
namespace Elementor\Modules\Promotions\Widgets; |
| 3 |
|
| 4 |
use Elementor\Widget_Base; |
| 5 |
use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager; |
| 6 |
|
| 7 |
if ( ! defined( 'ABSPATH' ) ) { |
| 8 |
exit; // Exit if accessed directly. |
| 9 |
} |
| 10 |
|
| 11 |
class Pro_Widget_Promotion extends Widget_Base { |
| 12 |
|
| 13 |
private $widget_data; |
| 14 |
|
| 15 |
public function hide_on_search() { |
| 16 |
return true; |
| 17 |
} |
| 18 |
|
| 19 |
public function show_in_panel() { |
| 20 |
return false; |
| 21 |
} |
| 22 |
|
| 23 |
public function get_name() { |
| 24 |
return $this->widget_data['widget_name']; |
| 25 |
} |
| 26 |
|
| 27 |
public function get_title() { |
| 28 |
return $this->widget_data['widget_title']; |
| 29 |
} |
| 30 |
|
| 31 |
public function on_import( $element ) { |
| 32 |
$element['settings']['__should_import'] = true; |
| 33 |
|
| 34 |
return $element; |
| 35 |
} |
| 36 |
|
| 37 |
protected function register_controls() {} |
| 38 |
|
| 39 |
protected function render() { |
| 40 |
if ( $this->is_editor_render() ) { |
| 41 |
$this->render_promotion(); |
| 42 |
} else { |
| 43 |
$this->render_empty_content(); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
private function is_editor_render(): bool { |
| 48 |
return \Elementor\Plugin::$instance->editor->is_edit_mode(); |
| 49 |
} |
| 50 |
|
| 51 |
private function render_promotion() { |
| 52 |
$promotion = Filtered_Promotions_Manager::get_filtered_promotion_data( |
| 53 |
[ |
| 54 |
'image_url' => esc_url( $this->get_promotion_image_url() ), |
| 55 |
'text' => sprintf( |
| 56 |
/* translators: %s: Widget title. */ |
| 57 |
esc_html__( 'This result includes the Elementor Pro %s widget. Upgrade now to unlock it and grow your web creation toolkit.', 'elementor' ), |
| 58 |
esc_html( $this->widget_data['widget_title'] ) |
| 59 |
), |
| 60 |
'upgrade_url' => esc_url( 'https://go.elementor.com/go-pro-element-pro/' ), |
| 61 |
], |
| 62 |
'elementor/pro-widget/promotion', |
| 63 |
'upgrade_url' |
| 64 |
); |
| 65 |
?> |
| 66 |
<div class="e-container"> |
| 67 |
<span class="e-badge"><i class="eicon-lock" aria-hidden="true"></i> <?php echo esc_html__( 'Pro', 'elementor' ); ?></span> |
| 68 |
<p> |
| 69 |
<img src="<?php echo esc_url( $promotion['image_url'] ); ?>" loading="lazy" alt="Go Pro"> |
| 70 |
<?php |
| 71 |
echo esc_html( $promotion['text'] ); |
| 72 |
?> |
| 73 |
</p> |
| 74 |
<div class="e-actions"> |
| 75 |
<a href="#" class="e-btn e-btn-txt e-promotion-delete"><?php echo esc_html__( 'Remove', 'elementor' ); ?></a> |
| 76 |
<a href="<?php echo esc_url( $promotion['upgrade_url'] ); ?>" rel="noreferrer" target="_blank" class="e-btn go-pro elementor-clickable e-promotion-go-pro"><?php echo esc_html__( 'Go Pro', 'elementor' ); ?></a> |
| 77 |
</div> |
| 78 |
</div> |
| 79 |
<?php |
| 80 |
} |
| 81 |
|
| 82 |
private function get_promotion_image_url(): string { |
| 83 |
return ELEMENTOR_ASSETS_URL . 'images/go-pro.svg'; |
| 84 |
} |
| 85 |
|
| 86 |
private function render_empty_content() { |
| 87 |
echo ' '; |
| 88 |
} |
| 89 |
|
| 90 |
protected function content_template() {} |
| 91 |
|
| 92 |
public function __construct( $data = [], $args = null ) { |
| 93 |
$this->widget_data = [ |
| 94 |
'widget_name' => $args['widget_name'], |
| 95 |
'widget_title' => $args['widget_title'], |
| 96 |
]; |
| 97 |
|
| 98 |
parent::__construct( $data, $args ); |
| 99 |
} |
| 100 |
|
| 101 |
public function render_plain_content( $instance = [] ) {} |
| 102 |
} |
| 103 |
|