PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.0-dev3
Elementor Website Builder – more than just a page builder v4.0.0-dev3
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / modules / promotions / widgets / pro-widget-promotion.php

pro-widget-promotion.php in Elementor Website Builder – more than just a page builder 4.0.0-dev3, at modules/promotions/widgets/pro-widget-promotion.php

107 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 get_categories() {
32 return [ 'general', 'pro-elements' ];
33 }
34
35 public function on_import( $element ) {
36 $element['settings']['__should_import'] = true;
37
38 return $element;
39 }
40
41 protected function register_controls() {}
42
43 protected function render() {
44 if ( $this->is_editor_render() ) {
45 $this->render_promotion();
46 } else {
47 $this->render_empty_content();
48 }
49 }
50
51 private function is_editor_render(): bool {
52 return \Elementor\Plugin::$instance->editor->is_edit_mode();
53 }
54
55 private function render_promotion() {
56 $promotion = Filtered_Promotions_Manager::get_filtered_promotion_data(
57 [
58 'image_url' => esc_url( $this->get_promotion_image_url() ),
59 'text' => sprintf(
60 /* translators: %s: Widget title. */
61 esc_html__( 'This result includes the Elementor Pro %s widget. Upgrade now to unlock it and grow your web creation toolkit.', 'elementor' ),
62 esc_html( $this->widget_data['widget_title'] )
63 ),
64 'upgrade_url' => esc_url( 'https://go.elementor.com/go-pro-element-pro/' ),
65 ],
66 'elementor/pro-widget/promotion',
67 'upgrade_url'
68 );
69 ?>
70 <div class="e-container">
71 <span class="e-badge"><i class="eicon-lock" aria-hidden="true"></i> <?php echo esc_html__( 'Pro', 'elementor' ); ?></span>
72 <p>
73 <img src="<?php echo esc_url( $promotion['image_url'] ); ?>" loading="lazy" alt="Go Pro">
74 <?php
75 echo esc_html( $promotion['text'] );
76 ?>
77 </p>
78 <div class="e-actions">
79 <a href="#" class="e-btn e-btn-txt e-promotion-delete"><?php echo esc_html__( 'Remove', 'elementor' ); ?></a>
80 <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>
81 </div>
82 </div>
83 <?php
84 }
85
86 private function get_promotion_image_url(): string {
87 return ELEMENTOR_ASSETS_URL . 'images/go-pro.svg';
88 }
89
90 private function render_empty_content() {
91 echo ' ';
92 }
93
94 protected function content_template() {}
95
96 public function __construct( $data = [], $args = null ) {
97 $this->widget_data = [
98 'widget_name' => $args['widget_name'],
99 'widget_title' => $args['widget_title'],
100 ];
101
102 parent::__construct( $data, $args );
103 }
104
105 public function render_plain_content( $instance = [] ) {}
106 }
107