← All changes
|
modules/promotions/admin-menu-items/base-promotion-template.php
+19
-43
4.3.1
→
3.19.2
View file →
| @@ -2,35 +2,34 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace Elementor\Modules\Promotions\AdminMenuItems; |
| 4 | 4 | |
| 5 | 5 | use Elementor\Core\Admin\Menu\Interfaces\Admin_Menu_Item_With_Page; |
| 6 | -use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager; | |
| 7 | 6 | use Elementor\Settings; |
| 8 | 7 | use Elementor\Utils; |
| 9 | 8 | |
| 10 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | - exit; // Exit if accessed directly. | |
| 10 | + exit; // Exit if accessed directly | |
| 12 | 11 | } |
| 13 | 12 | |
| 14 | 13 | abstract class Base_Promotion_Template implements Admin_Menu_Item_With_Page { |
| 15 | 14 | |
| 16 | - abstract protected function get_promotion_title(): string; | |
| 15 | + abstract protected function get_promotion_title(); | |
| 17 | 16 | |
| 18 | - abstract protected function get_cta_url(): string; | |
| 17 | + abstract protected function get_cta_url(); | |
| 19 | 18 | |
| 20 | - abstract protected function get_content_lines(): array; | |
| 19 | + abstract protected function set_list(); | |
| 21 | 20 | |
| 22 | - abstract protected function get_video_url(): string; | |
| 21 | + abstract protected function get_video_url(); | |
| 23 | 22 | |
| 24 | - public function is_visible(): bool { | |
| 23 | + public function is_visible() { | |
| 25 | 24 | return true; |
| 26 | 25 | } |
| 27 | 26 | |
| 28 | - public function get_parent_slug(): string { | |
| 27 | + public function get_parent_slug() { | |
| 29 | 28 | return Settings::PAGE_ID; |
| 30 | 29 | } |
| 31 | 30 | |
| 32 | - public function get_capability(): string { | |
| 31 | + public function get_capability() { | |
| 33 | 32 | return 'manage_options'; |
| 34 | 33 | } |
| 35 | 34 | |
| 36 | 35 | protected function get_cta_text() { |
| @@ -38,21 +37,20 @@ | ||
| 38 | 37 | } |
| 39 | 38 | |
| 40 | 39 | /** |
| 41 | 40 | * Should the promotion have a side note. |
| 42 | - * | |
| 43 | 41 | * @return string |
| 44 | 42 | */ |
| 45 | - protected function get_side_note(): string { | |
| 43 | + protected function get_side_note() { | |
| 46 | 44 | return ''; |
| 47 | 45 | } |
| 48 | 46 | |
| 49 | - private function get_lines() { | |
| 47 | + protected function get_list() { | |
| 50 | 48 | ob_start(); |
| 51 | - if ( ! empty( $this->get_content_lines() ) ) { | |
| 49 | + if ( ! empty( $this->set_list() ) ) { | |
| 52 | 50 | ?> |
| 53 | 51 | <ul> |
| 54 | - <?php foreach ( $this->get_content_lines() as $item ) { ?> | |
| 52 | + <?php foreach ( $this->set_list() as $item ) { ?> | |
| 55 | 53 | <li><?php Utils::print_unescaped_internal_string( $item ); ?></li> |
| 56 | 54 | <?php } ?> |
| 57 | 55 | </ul> |
| 58 | 56 | <?php |
| @@ -61,50 +59,28 @@ | ||
| 61 | 59 | return ob_get_clean(); |
| 62 | 60 | } |
| 63 | 61 | |
| 64 | 62 | public function render() { |
| 65 | - $promotion_data = $this->get_promotion_data(); | |
| 66 | 63 | ?> |
| 67 | 64 | <div class="e-feature-promotion"> |
| 68 | 65 | <div class="e-feature-promotion_data"> |
| 69 | - <h3><?php Utils::print_unescaped_internal_string( $promotion_data['promotion_title'] ); ?></h3> | |
| 66 | + <h3><?php Utils::print_unescaped_internal_string( $this->get_promotion_title() ); ?></h3> | |
| 70 | 67 | |
| 71 | - <?php Utils::print_unescaped_internal_string( $promotion_data['lines'] ); ?> | |
| 68 | + <?php Utils::print_unescaped_internal_string( $this->get_list() ); ?> | |
| 72 | 69 | |
| 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'] ); ?> | |
| 70 | + <a class="elementor-button go-pro" href="<?php echo esc_url( $this->get_cta_url() ); ?>" target="_blank"> | |
| 71 | + <?php Utils::print_unescaped_internal_string( $this->get_cta_text() ); ?> | |
| 75 | 72 | </a> |
| 76 | 73 | |
| 77 | - <?php if ( ! empty( $promotion_data['side_note'] ) ) { ?> | |
| 74 | + <?php if ( ! empty( $this->get_side_note() ) ) { ?> | |
| 78 | 75 | <div class="side-note"> |
| 79 | - <p><?php Utils::print_unescaped_internal_string( $promotion_data['side_note'] ); ?></p> | |
| 76 | + <p><?php Utils::print_unescaped_internal_string( $this->get_side_note() ); ?></p> | |
| 80 | 77 | </div> |
| 81 | 78 | <?php } ?> |
| 82 | 79 | |
| 83 | 80 | </div> |
| 84 | 81 | |
| 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> | |
| 82 | + <iframe class="e-feature-promotion_iframe" src="<?php Utils::print_unescaped_internal_string( $this->get_video_url() ); ?>" title="Elementor" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe> | |
| 86 | 83 | </div> |
| 87 | 84 | <?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 | 85 | } |
| 110 | 86 | } |