PluginProbe
Elementor Website Builder – more than just a page builder / 3.34.2
Elementor Website Builder – more than just a page builder v3.34.2
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.34.2, at modules/promotions/admin-menu-items/base-promotion-template.php

111 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(): bool {
25 return true;
26 }
27
28 public function get_parent_slug(): string {
29 return Settings::PAGE_ID;
30 }
31
32 public function get_capability(): string {
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 *
43 * @return string
44 */
45 protected function get_side_note(): string {
46 return '';
47 }
48
49 private function get_lines() {
50 ob_start();
51 if ( ! empty( $this->get_content_lines() ) ) {
52 ?>
53 <ul>
54 <?php foreach ( $this->get_content_lines() as $item ) { ?>
55 <li><?php Utils::print_unescaped_internal_string( $item ); ?></li>
56 <?php } ?>
57 </ul>
58 <?php
59 }
60
61 return ob_get_clean();
62 }
63
64 public function render() {
65 $promotion_data = $this->get_promotion_data();
66 ?>
67 <div class="e-feature-promotion">
68 <div class="e-feature-promotion_data">
69 <h3><?php Utils::print_unescaped_internal_string( $promotion_data['promotion_title'] ); ?></h3>
70
71 <?php Utils::print_unescaped_internal_string( $promotion_data['lines'] ); ?>
72
73 <a class="elementor-button go-pro" href="<?php echo esc_url( $promotion_data['cta_url'] ); ?>" target="_blank">
74 <?php Utils::print_unescaped_internal_string( $promotion_data['cta_text'] ); ?>
75 </a>
76
77 <?php if ( ! empty( $promotion_data['side_note'] ) ) { ?>
78 <div class="side-note">
79 <p><?php Utils::print_unescaped_internal_string( $promotion_data['side_note'] ); ?></p>
80 </div>
81 <?php } ?>
82
83 </div>
84
85 <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>
86 </div>
87 <?php
88 }
89
90 /**
91 * @return array|null
92 */
93 private function get_promotion_data(): ?array {
94 return Filtered_Promotions_Manager::get_filtered_promotion_data( $this->build_promotion_data_array(), 'elementor/' . $this->get_name() . '/custom_promotion', 'cta_url' );
95 }
96
97 /**
98 * @return array
99 */
100 private function build_promotion_data_array(): array {
101 return [
102 'promotion_title' => $this->get_promotion_title(),
103 'cta_url' => $this->get_cta_url(),
104 'cta_text' => $this->get_cta_text(),
105 'video_url' => $this->get_video_url(),
106 'lines' => $this->get_lines(),
107 'side_note' => $this->get_side_note(),
108 ];
109 }
110 }
111