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

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

131 lines 3.6 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\Validate_Promotion;
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 $promotion_data = $this->build_promotion_data_array();
94
95 $new_promotion_data = apply_filters( 'elementor/' . $this->get_name() . '/custom_promotion', $promotion_data );
96
97 return count( $new_promotion_data ) <= count( $promotion_data )
98 ? $this->replace_values( $promotion_data, $new_promotion_data )
99 : $promotion_data;
100 }
101
102 /**
103 * @return array
104 */
105 private function build_promotion_data_array(): array {
106 return [
107 'promotion_title' => $this->get_promotion_title(),
108 'cta_url' => $this->get_cta_url(),
109 'cta_text' => $this->get_cta_text(),
110 'video_url' => $this->get_video_url(),
111 'lines' => $this->get_lines(),
112 'side_note' => $this->get_side_note(),
113 ];
114 }
115
116 /**
117 * @param array $promotion_data
118 * @param array $new_promotion_data
119 * @return array
120 */
121 private function replace_values( array $promotion_data, array $new_promotion_data ): array {
122 $new_promotion_data = array_replace( $promotion_data, $new_promotion_data );
123
124 if ( ! Validate_Promotion::domain_is_on_elementor_dot_com( $new_promotion_data['cta_url'] ) ) {
125 $new_promotion_data['cta_url'] = $promotion_data['cta_url'];
126 }
127
128 return $new_promotion_data;
129 }
130 }
131