PluginProbe
Elementor Website Builder – more than just a page builder / 3.23.0-dev2
Elementor Website Builder – more than just a page builder v3.23.0-dev2
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 / admin-menu-items / base-promotion-template.php

base-promotion-template.php in Elementor Website Builder – more than just a page builder 3.23.0-dev2, at modules/promotions/admin-menu-items/base-promotion-template.php

110 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\Promotions\AdminMenuItems;
4
5 use Elementor\Core\Admin\Menu\Interfaces\Admin_Menu_Item_With_Page;
6 use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager;
7 use Elementor\Settings;
8 use Elementor\Utils;
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit; // Exit if accessed directly
12 }
13
14 abstract class Base_Promotion_Template implements Admin_Menu_Item_With_Page {
15
16 abstract protected function get_promotion_title():string;
17
18 abstract protected function get_cta_url():string;
19
20 abstract protected function get_content_lines():array;
21
22 abstract protected function get_video_url():string;
23
24 public function is_visible() {
25 return true;
26 }
27
28 public function get_parent_slug() {
29 return Settings::PAGE_ID;
30 }
31
32 public function get_capability() {
33 return 'manage_options';
34 }
35
36 protected function get_cta_text() {
37 return esc_html__( 'Upgrade Now', 'elementor' );
38 }
39
40 /**
41 * Should the promotion have a side note.
42 * @return string
43 */
44 protected function get_side_note():string {
45 return '';
46 }
47
48 private function get_lines() {
49 ob_start();
50 if ( ! empty( $this->get_content_lines() ) ) {
51 ?>
52 <ul>
53 <?php foreach ( $this->get_content_lines() as $item ) { ?>
54 <li><?php Utils::print_unescaped_internal_string( $item ); ?></li>
55 <?php } ?>
56 </ul>
57 <?php
58 }
59
60 return ob_get_clean();
61 }
62
63 public function render() {
64 $promotion_data = $this->get_promotion_data();
65 ?>
66 <div class="e-feature-promotion">
67 <div class="e-feature-promotion_data">
68 <h3><?php Utils::print_unescaped_internal_string( $promotion_data['promotion_title'] ); ?></h3>
69
70 <?php Utils::print_unescaped_internal_string( $promotion_data['lines'] ); ?>
71
72 <a class="elementor-button go-pro" href="<?php echo esc_url( $promotion_data['cta_url'] ); ?>" target="_blank">
73 <?php Utils::print_unescaped_internal_string( $promotion_data['cta_text'] ); ?>
74 </a>
75
76 <?php if ( ! empty( $promotion_data['side_note'] ) ) { ?>
77 <div class="side-note">
78 <p><?php Utils::print_unescaped_internal_string( $promotion_data['side_note'] ); ?></p>
79 </div>
80 <?php } ?>
81
82 </div>
83
84 <iframe class="e-feature-promotion_iframe" src="<?php Utils::print_unescaped_internal_string( $promotion_data['video_url'] ); ?>&rel=0" title="Elementor" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
85 </div>
86 <?php
87 }
88
89 /**
90 * @return array|null
91 */
92 private function get_promotion_data(): ?array {
93 return Filtered_Promotions_Manager::get_filtered_promotion_data( $this->build_promotion_data_array(), 'elementor/' . $this->get_name() . '/custom_promotion', 'cta_url' );
94 }
95
96 /**
97 * @return array
98 */
99 private function build_promotion_data_array(): array {
100 return [
101 'promotion_title' => $this->get_promotion_title(),
102 'cta_url' => $this->get_cta_url(),
103 'cta_text' => $this->get_cta_text(),
104 'video_url' => $this->get_video_url(),
105 'lines' => $this->get_lines(),
106 'side_note' => $this->get_side_note(),
107 ];
108 }
109 }
110