first commit
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Elementor\Modules\Promotions\AdminMenuItems;
|
||||
|
||||
use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager;
|
||||
use Elementor\Modules\Promotions\AdminMenuItems\Interfaces\Promotion_Menu_Item;
|
||||
use Elementor\Settings;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
abstract class Base_Promotion_Item implements Promotion_Menu_Item {
|
||||
|
||||
public function get_name() {
|
||||
return 'base_promotion';
|
||||
}
|
||||
|
||||
public function is_visible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function get_parent_slug() {
|
||||
return Settings::PAGE_ID;
|
||||
}
|
||||
|
||||
public function get_capability() {
|
||||
return 'manage_options';
|
||||
}
|
||||
|
||||
public function get_cta_text() {
|
||||
return esc_html__( 'Upgrade Now', 'elementor' );
|
||||
}
|
||||
|
||||
public function get_image_url() {
|
||||
return ELEMENTOR_ASSETS_URL . 'images/go-pro-wp-dashboard.svg';
|
||||
}
|
||||
|
||||
public function get_promotion_description() {
|
||||
return '';
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$config = [
|
||||
'title' => $this->get_promotion_title(),
|
||||
'description' => $this->get_promotion_description(),
|
||||
'image' => $this->get_image_url(),
|
||||
'upgrade_text' => $this->get_cta_text(),
|
||||
'upgrade_url' => $this->get_cta_url(),
|
||||
];
|
||||
|
||||
$config = Filtered_Promotions_Manager::get_filtered_promotion_data( $config, 'elementor/' . $this->get_name() . '/custom_promotion', 'upgrade_url' );
|
||||
|
||||
$description = $config['description'] ?? $this->get_promotion_description() ?? '';
|
||||
|
||||
?>
|
||||
<div class="wrap">
|
||||
<div class="elementor-blank_state">
|
||||
<img src="<?php echo esc_url( $config['image'] ?? $this->get_image_url() ); ?>" loading="lazy" />
|
||||
|
||||
<h3><?php echo esc_html( $config['title'] ?? $this->get_promotion_title() ); ?></h3>
|
||||
<?php if ( $description ) : ?>
|
||||
<p><?php echo esc_html( $description ); ?></p>
|
||||
<?php endif; ?>
|
||||
<a class="elementor-button go-pro" href="<?php echo esc_url( $config['upgrade_url'] ?? $this->get_cta_url() ); ?>">
|
||||
<?php echo esc_html( $config['upgrade_text'] ?? $this->get_cta_text() ); ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace Elementor\Modules\Promotions\AdminMenuItems;
|
||||
|
||||
use Elementor\Core\Admin\Menu\Interfaces\Admin_Menu_Item_With_Page;
|
||||
use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager;
|
||||
use Elementor\Settings;
|
||||
use Elementor\Utils;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
abstract class Base_Promotion_Template implements Admin_Menu_Item_With_Page {
|
||||
|
||||
abstract protected function get_promotion_title(): string;
|
||||
|
||||
abstract protected function get_cta_url(): string;
|
||||
|
||||
abstract protected function get_content_lines(): array;
|
||||
|
||||
abstract protected function get_video_url(): string;
|
||||
|
||||
public function is_visible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function get_parent_slug() {
|
||||
return Settings::PAGE_ID;
|
||||
}
|
||||
|
||||
public function get_capability() {
|
||||
return 'manage_options';
|
||||
}
|
||||
|
||||
protected function get_cta_text() {
|
||||
return esc_html__( 'Upgrade Now', 'elementor' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the promotion have a side note.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get_side_note(): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
private function get_lines() {
|
||||
ob_start();
|
||||
if ( ! empty( $this->get_content_lines() ) ) {
|
||||
?>
|
||||
<ul>
|
||||
<?php foreach ( $this->get_content_lines() as $item ) { ?>
|
||||
<li><?php Utils::print_unescaped_internal_string( $item ); ?></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$promotion_data = $this->get_promotion_data();
|
||||
?>
|
||||
<div class="e-feature-promotion">
|
||||
<div class="e-feature-promotion_data">
|
||||
<h3><?php Utils::print_unescaped_internal_string( $promotion_data['promotion_title'] ); ?></h3>
|
||||
|
||||
<?php Utils::print_unescaped_internal_string( $promotion_data['lines'] ); ?>
|
||||
|
||||
<a class="elementor-button go-pro" href="<?php echo esc_url( $promotion_data['cta_url'] ); ?>" target="_blank">
|
||||
<?php Utils::print_unescaped_internal_string( $promotion_data['cta_text'] ); ?>
|
||||
</a>
|
||||
|
||||
<?php if ( ! empty( $promotion_data['side_note'] ) ) { ?>
|
||||
<div class="side-note">
|
||||
<p><?php Utils::print_unescaped_internal_string( $promotion_data['side_note'] ); ?></p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
private function get_promotion_data(): ?array {
|
||||
return Filtered_Promotions_Manager::get_filtered_promotion_data( $this->build_promotion_data_array(), 'elementor/' . $this->get_name() . '/custom_promotion', 'cta_url' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function build_promotion_data_array(): array {
|
||||
return [
|
||||
'promotion_title' => $this->get_promotion_title(),
|
||||
'cta_url' => $this->get_cta_url(),
|
||||
'cta_text' => $this->get_cta_text(),
|
||||
'video_url' => $this->get_video_url(),
|
||||
'lines' => $this->get_lines(),
|
||||
'side_note' => $this->get_side_note(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Elementor\Modules\Promotions\AdminMenuItems;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Custom_Code_Promotion_Item extends Base_Promotion_Template {
|
||||
public function get_name() {
|
||||
return 'custom_code';
|
||||
}
|
||||
|
||||
public function get_label() {
|
||||
return esc_html__( 'Custom Code', 'elementor' );
|
||||
}
|
||||
|
||||
public function get_page_title() {
|
||||
return esc_html__( 'Custom Code', 'elementor' );
|
||||
}
|
||||
|
||||
protected function get_promotion_title(): string {
|
||||
return esc_html__( 'Enjoy Creative Freedom with Custom Code', 'elementor' );
|
||||
}
|
||||
|
||||
protected function get_content_lines(): array {
|
||||
return [
|
||||
esc_html__( 'Add Custom Code snippets anywhere on your website, including the header or footer to measure your page’s performance*', 'elementor' ),
|
||||
esc_html__( 'Use Custom Code to create sophisticated custom interactions to engage visitors', 'elementor' ),
|
||||
esc_html__( 'Leverage Elementor AI to instantly generate Custom Code for Elementor', 'elementor' ),
|
||||
];
|
||||
}
|
||||
|
||||
protected function get_side_note(): string {
|
||||
return esc_html__( '* Requires an Advanced subscription or higher', 'elementor' );
|
||||
}
|
||||
|
||||
protected function get_cta_url(): string {
|
||||
return 'https://go.elementor.com/go-pro-custom-code/';
|
||||
}
|
||||
|
||||
protected function get_video_url(): string {
|
||||
return 'https://www.youtube-nocookie.com/embed/IOovQd1hJUg?si=xeBJ_mRZxRH1l5O6';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Elementor\Modules\Promotions\AdminMenuItems;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Custom_Fonts_Promotion_Item extends Base_Promotion_Template {
|
||||
public function get_name() {
|
||||
return 'custom_fonts';
|
||||
}
|
||||
|
||||
public function get_label() {
|
||||
return esc_html__( 'Custom Fonts', 'elementor' );
|
||||
}
|
||||
|
||||
public function get_page_title() {
|
||||
return esc_html__( 'Custom Fonts', 'elementor' );
|
||||
}
|
||||
|
||||
protected function get_promotion_title(): string {
|
||||
return esc_html__( 'Stay on brand with a Custom Font', 'elementor' );
|
||||
}
|
||||
|
||||
protected function get_content_lines(): array {
|
||||
return [
|
||||
esc_html__( 'Upload any font to keep your website true to your brand', 'elementor' ),
|
||||
sprintf(
|
||||
/* translators: %s: br */
|
||||
esc_html__( 'Remain GDPR compliant with Custom Fonts that let you disable %s Google Fonts from your website', 'elementor' ),
|
||||
'<br />'
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
protected function get_cta_url(): string {
|
||||
return 'https://go.elementor.com/go-pro-custom-fonts/';
|
||||
}
|
||||
|
||||
protected function get_video_url(): string {
|
||||
return 'https://www.youtube-nocookie.com/embed/j_guJkm28eY?si=cdd2TInwuGDTtCGD';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Elementor\Modules\Promotions\AdminMenuItems;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Custom_Icons_Promotion_Item extends Base_Promotion_Template {
|
||||
public function get_name() {
|
||||
return 'custom_icons';
|
||||
}
|
||||
|
||||
public function get_label() {
|
||||
return esc_html__( 'Custom Icons', 'elementor' );
|
||||
}
|
||||
|
||||
public function get_page_title() {
|
||||
return esc_html__( 'Custom Icons', 'elementor' );
|
||||
}
|
||||
|
||||
protected function get_promotion_title(): string {
|
||||
return sprintf(
|
||||
/* translators: %s: `<br>` tag. */
|
||||
esc_html__( 'Enjoy creative freedom %s with Custom Icons', 'elementor' ),
|
||||
'<br />'
|
||||
);
|
||||
}
|
||||
|
||||
protected function get_content_lines(): array {
|
||||
return [
|
||||
sprintf(
|
||||
/* translators: %s: `<br>` tag. */
|
||||
esc_html__( 'Expand your icon library beyond FontAwesome and add icon %s libraries of your choice', 'elementor' ),
|
||||
'<br />'
|
||||
),
|
||||
esc_html__( 'Add any icon, anywhere on your website', 'elementor' ),
|
||||
];
|
||||
}
|
||||
|
||||
protected function get_cta_url(): string {
|
||||
return 'https://go.elementor.com/go-pro-custom-icons/';
|
||||
}
|
||||
|
||||
protected function get_video_url(): string {
|
||||
return 'https://www.youtube-nocookie.com/embed/PsowinxDWfM?si=SV9Z3TLz3_XEy5C6';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Elementor\Modules\Promotions\AdminMenuItems;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Form_Submissions_Promotion_Item extends Base_Promotion_Template {
|
||||
public function get_name() {
|
||||
return 'submissions';
|
||||
}
|
||||
|
||||
public function get_label() {
|
||||
return esc_html__( 'Submissions', 'elementor' );
|
||||
}
|
||||
|
||||
public function get_page_title() {
|
||||
return esc_html__( 'Submissions', 'elementor' );
|
||||
}
|
||||
|
||||
public function get_promotion_title(): string {
|
||||
return sprintf(
|
||||
/* translators: %s: `<br>` tag. */
|
||||
esc_html__( 'Create Forms and Collect Leads %s with Elementor Pro', 'elementor' ),
|
||||
'<br>'
|
||||
);
|
||||
}
|
||||
|
||||
protected function get_content_lines(): array {
|
||||
return [
|
||||
esc_html__( 'Create single or multi-step forms to engage and convert visitors', 'elementor' ),
|
||||
esc_html__( 'Use any field to collect the information you need', 'elementor' ),
|
||||
esc_html__( 'Integrate your favorite marketing software*', 'elementor' ),
|
||||
esc_html__( 'Collect lead submissions directly within your WordPress Admin to manage, analyze and perform bulk actions on the submitted lead*', 'elementor' ),
|
||||
];
|
||||
}
|
||||
|
||||
protected function get_cta_url(): string {
|
||||
return 'https://go.elementor.com/go-pro-submissions/';
|
||||
}
|
||||
|
||||
protected function get_video_url(): string {
|
||||
return 'https://www.youtube-nocookie.com/embed/LNfnwba9C-8?si=JLHk3UAexnvTfU1a';
|
||||
}
|
||||
|
||||
protected function get_side_note(): string {
|
||||
return esc_html__( '* Requires an Advanced subscription or higher', 'elementor' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Elementor\Modules\Promotions\AdminMenuItems;
|
||||
|
||||
use Elementor\Core\Admin\Menu\Interfaces\Admin_Menu_Item_With_Page;
|
||||
use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager;
|
||||
use Elementor\Settings;
|
||||
use Elementor\Utils;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Go_Pro_Promotion_Item implements Admin_Menu_Item_With_Page {
|
||||
const URL = 'https://go.elementor.com/pro-admin-menu/';
|
||||
|
||||
public function get_name() {
|
||||
return 'admin_menu_promo';
|
||||
}
|
||||
|
||||
public function is_visible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function get_parent_slug() {
|
||||
return Settings::PAGE_ID;
|
||||
}
|
||||
|
||||
public function get_label() {
|
||||
$upgrade_text = esc_html__( 'Upgrade', 'elementor' );
|
||||
|
||||
if ( Utils::is_sale_time() ) {
|
||||
$upgrade_text = esc_html__( 'Upgrade Sale Now', 'elementor' );
|
||||
}
|
||||
|
||||
return apply_filters( 'elementor/admin_menu/custom_promotion', [ 'upgrade_text' => $upgrade_text ] )['upgrade_text'] ?? $upgrade_text;
|
||||
}
|
||||
|
||||
public function get_page_title() {
|
||||
return '';
|
||||
}
|
||||
|
||||
public function get_capability() {
|
||||
return 'manage_options';
|
||||
}
|
||||
|
||||
public static function get_url() {
|
||||
$url = self::URL;
|
||||
$filtered_url = apply_filters( 'elementor/admin_menu/custom_promotion', [ 'upgrade_url' => $url ] )['upgrade_url'] ?? '';
|
||||
$promotion_data = Filtered_Promotions_Manager::get_filtered_promotion_data( [ 'upgrade_url' => $filtered_url ], 'elementor/admin_menu/custom_promotion', 'upgrade_url' );
|
||||
return $promotion_data ['upgrade_url'];
|
||||
}
|
||||
|
||||
public function render() {
|
||||
// Redirects from the module on `admin_init`.
|
||||
die;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Elementor\Modules\Promotions\AdminMenuItems\Interfaces;
|
||||
|
||||
use Elementor\Core\Admin\Menu\Interfaces\Admin_Menu_Item_With_Page;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
interface Promotion_Menu_Item extends Admin_Menu_Item_With_Page {
|
||||
public function get_image_url();
|
||||
|
||||
public function get_promotion_title();
|
||||
|
||||
public function get_promotion_description();
|
||||
|
||||
public function get_cta_text();
|
||||
|
||||
public function get_cta_url();
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Elementor\Modules\Promotions\AdminMenuItems;
|
||||
|
||||
use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager;
|
||||
use Elementor\TemplateLibrary\Source_Local;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Popups_Promotion_Item extends Base_Promotion_Item {
|
||||
|
||||
private array $promotion_data;
|
||||
|
||||
public function __construct() {
|
||||
$this->promotion_data = [
|
||||
'title' => esc_html__( 'Get Popup Builder', 'elementor' ),
|
||||
'content' => esc_html__(
|
||||
'The Popup Builder lets you take advantage of all the amazing features in Elementor, so you can build beautiful & highly converting popups. Get Elementor Pro and start designing your popups today.',
|
||||
'elementor'
|
||||
),
|
||||
'action_button' => [
|
||||
'text' => esc_html__( 'Upgrade Now', 'elementor' ),
|
||||
'url' => 'https://go.elementor.com/go-pro-popup-builder/',
|
||||
],
|
||||
];
|
||||
|
||||
$this->promotion_data = Filtered_Promotions_Manager::get_filtered_promotion_data( $this->promotion_data, 'elementor/templates/popup', 'action_button', 'url' );
|
||||
}
|
||||
|
||||
public function get_parent_slug() {
|
||||
return Source_Local::ADMIN_MENU_SLUG;
|
||||
}
|
||||
|
||||
public function get_name() {
|
||||
return 'popups';
|
||||
}
|
||||
|
||||
public function get_label() {
|
||||
return esc_html__( 'Popups', 'elementor' );
|
||||
}
|
||||
|
||||
public function get_page_title() {
|
||||
return esc_html__( 'Popups', 'elementor' );
|
||||
}
|
||||
|
||||
public function get_promotion_title() {
|
||||
return $this->promotion_data['title'];
|
||||
}
|
||||
|
||||
public function get_promotion_description() {
|
||||
return $this->promotion_data['content'];
|
||||
}
|
||||
|
||||
public function get_cta_url() {
|
||||
return $this->promotion_data['action_button']['url'];
|
||||
}
|
||||
|
||||
public function get_cta_text() {
|
||||
return $this->promotion_data['action_button']['text'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace Elementor\Modules\Promotions\Controls;
|
||||
|
||||
use Elementor\Base_Data_Control;
|
||||
|
||||
class Promotion_Control extends Base_Data_Control {
|
||||
|
||||
const TYPE = 'promotion_control';
|
||||
|
||||
public function get_type() {
|
||||
return static::TYPE;
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
?>
|
||||
<div data-promotion="{{{ data.name }}}" class="elementor-control-type-switcher elementor-label-inline e-control-promotion__wrapper">
|
||||
<div class="elementor-control-content">
|
||||
<div class="elementor-control-field">
|
||||
<# if ( data.label ) {#>
|
||||
<label for="<?php $this->print_control_uid(); ?>" class="elementor-control-title">{{{ data.label }}}</label>
|
||||
<# } #>
|
||||
<span class="e-control-promotion__lock-wrapper">
|
||||
<i class="eicon-lock"></i>
|
||||
</span>
|
||||
<div class="elementor-control-input-wrapper">
|
||||
<label class="elementor-switch elementor-control-unit-2 e-control-promotion-switch">
|
||||
<input type="checkbox" class="elementor-switch-input" disabled>
|
||||
<span class="elementor-switch-label" data-off="Off"></span>
|
||||
<span class="elementor-switch-handle"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="e-promotion-react-wrapper" data-promotion="{{{ data.name }}}"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
166
wp-content/plugins/elementor/modules/promotions/module.php
Normal file
166
wp-content/plugins/elementor/modules/promotions/module.php
Normal file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
namespace Elementor\Modules\Promotions;
|
||||
|
||||
use Elementor\Api;
|
||||
use Elementor\Controls_Manager;
|
||||
use Elementor\Core\Admin\Menu\Admin_Menu_Manager;
|
||||
use Elementor\Core\Base\Module as Base_Module;
|
||||
use Elementor\Modules\Promotions\AdminMenuItems\Custom_Code_Promotion_Item;
|
||||
use Elementor\Modules\Promotions\AdminMenuItems\Custom_Fonts_Promotion_Item;
|
||||
use Elementor\Modules\Promotions\AdminMenuItems\Custom_Icons_Promotion_Item;
|
||||
use Elementor\Modules\Promotions\AdminMenuItems\Form_Submissions_Promotion_Item;
|
||||
use Elementor\Modules\Promotions\AdminMenuItems\Go_Pro_Promotion_Item;
|
||||
use Elementor\Modules\Promotions\AdminMenuItems\Popups_Promotion_Item;
|
||||
use Elementor\Modules\Promotions\Pointers\Birthday;
|
||||
use Elementor\Widgets_Manager;
|
||||
use Elementor\Utils;
|
||||
use Elementor\Includes\EditorAssetsAPI;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Module extends Base_Module {
|
||||
|
||||
const ADMIN_MENU_PRIORITY = 100;
|
||||
|
||||
const ADMIN_MENU_PROMOTIONS_PRIORITY = 120;
|
||||
|
||||
public static function is_active() {
|
||||
return ! Utils::has_pro();
|
||||
}
|
||||
|
||||
public function get_name() {
|
||||
return 'promotions';
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
add_action( 'admin_init', function () {
|
||||
$this->handle_external_redirects();
|
||||
} );
|
||||
|
||||
add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) {
|
||||
$this->register_menu_items( $admin_menu );
|
||||
}, static::ADMIN_MENU_PRIORITY );
|
||||
|
||||
add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) {
|
||||
$this->register_promotion_menu_item( $admin_menu );
|
||||
}, static::ADMIN_MENU_PROMOTIONS_PRIORITY );
|
||||
|
||||
add_action( 'elementor/widgets/register', function( Widgets_Manager $manager ) {
|
||||
foreach ( Api::get_promotion_widgets() as $widget_data ) {
|
||||
$manager->register( new Widgets\Pro_Widget_Promotion( [], [
|
||||
'widget_name' => $widget_data['name'],
|
||||
'widget_title' => $widget_data['title'],
|
||||
] ) );
|
||||
}
|
||||
} );
|
||||
|
||||
if ( Birthday::should_display_notice() ) {
|
||||
new Birthday();
|
||||
}
|
||||
|
||||
if ( Utils::has_pro() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
add_action( 'elementor/controls/register', function ( Controls_Manager $controls_manager ) {
|
||||
$controls_manager->register( new Controls\Promotion_Control() );
|
||||
} );
|
||||
|
||||
add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_react_data' ] );
|
||||
add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_editor_v4_alphachip' ] );
|
||||
}
|
||||
|
||||
private function handle_external_redirects() {
|
||||
if ( empty( $_GET['page'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'go_elementor_pro' === $_GET['page'] ) {
|
||||
wp_redirect( Go_Pro_Promotion_Item::get_url() );
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
private function register_menu_items( Admin_Menu_Manager $admin_menu ) {
|
||||
$admin_menu->register( 'e-form-submissions', new Form_Submissions_Promotion_Item() );
|
||||
$admin_menu->register( 'elementor_custom_fonts', new Custom_Fonts_Promotion_Item() );
|
||||
$admin_menu->register( 'elementor_custom_icons', new Custom_Icons_Promotion_Item() );
|
||||
$admin_menu->register( 'elementor_custom_code', new Custom_Code_Promotion_Item() );
|
||||
$admin_menu->register( 'popup_templates', new Popups_Promotion_Item() );
|
||||
}
|
||||
|
||||
private function register_promotion_menu_item( Admin_Menu_Manager $admin_menu ) {
|
||||
$admin_menu->register( 'go_elementor_pro', new Go_Pro_Promotion_Item() );
|
||||
}
|
||||
|
||||
public function enqueue_react_data(): void {
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$min_suffix = Utils::is_script_debug() ? '' : '.min';
|
||||
|
||||
wp_enqueue_script(
|
||||
'e-react-promotions',
|
||||
ELEMENTOR_ASSETS_URL . 'js/e-react-promotions' . $min_suffix . '.js',
|
||||
[
|
||||
'react',
|
||||
'react-dom',
|
||||
'backbone-marionette',
|
||||
'elementor-editor-modules',
|
||||
'elementor-v2-ui',
|
||||
],
|
||||
ELEMENTOR_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
wp_set_script_translations( 'e-react-promotions', 'elementor' );
|
||||
|
||||
wp_localize_script(
|
||||
'e-react-promotions',
|
||||
'elementorPromotionsData',
|
||||
$this->get_app_js_config()
|
||||
);
|
||||
}
|
||||
|
||||
public function enqueue_editor_v4_alphachip(): void {
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$min_suffix = Utils::is_script_debug() ? '' : '.min';
|
||||
|
||||
wp_enqueue_script(
|
||||
'editor-v4-opt-in-alphachip',
|
||||
ELEMENTOR_ASSETS_URL . 'js/editor-v4-opt-in-alphachip' . $min_suffix . '.js',
|
||||
[
|
||||
'react',
|
||||
'react-dom',
|
||||
'elementor-common',
|
||||
'elementor-v2-ui',
|
||||
],
|
||||
ELEMENTOR_VERSION,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
private function get_app_js_config(): array {
|
||||
$editor_assets_api = new EditorAssetsAPI( $this->get_api_config() );
|
||||
$promotion_data = new PromotionData( $editor_assets_api );
|
||||
|
||||
return $promotion_data->get_promotion_data();
|
||||
}
|
||||
|
||||
private function get_api_config(): array {
|
||||
return [
|
||||
EditorAssetsAPI::ASSETS_DATA_URL => 'https://assets.elementor.com/free-to-pro-upsell/v1/free-to-pro-upsell.json',
|
||||
EditorAssetsAPI::ASSETS_DATA_TRANSIENT_KEY => '_elementor_free_to_pro_upsell',
|
||||
EditorAssetsAPI::ASSETS_DATA_KEY => 'free-to-pro-upsell',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace Elementor\Modules\Promotions\Pointers;
|
||||
|
||||
use Elementor\User;
|
||||
use Elementor\Utils;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Birthday {
|
||||
const PROMOTION_URL = 'https://go.elementor.com/go-pro-wordpress-notice-birthday/';
|
||||
const ELEMENTOR_POINTER_ID = 'toplevel_page_elementor';
|
||||
const SEEN_TODAY_KEY = '_elementor-2025-birthday';
|
||||
const DISMISS_ACTION_KEY = 'birthday_pointer_2025';
|
||||
|
||||
public function __construct() {
|
||||
add_action( 'admin_print_footer_scripts-index.php', [ $this, 'enqueue_notice' ] );
|
||||
}
|
||||
|
||||
public function enqueue_notice() {
|
||||
if ( ! $this->should_display_notice() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->set_seen_today();
|
||||
$this->enqueue_dependencies();
|
||||
|
||||
$pointer_content = '<h3>' . esc_html__( 'Elementor’s 9th Birthday sale!', 'elementor' ) . '</h3>';
|
||||
$pointer_content .= '<p>' . esc_html__( 'Celebrate Elementor’s birthday with us—exclusive deals are available now.', 'elementor' );
|
||||
$pointer_content .= sprintf(
|
||||
'<p><a class="button button-primary" href="%s" target="_blank">%s</a></p>',
|
||||
self::PROMOTION_URL,
|
||||
esc_html__( 'View Deals', 'elementor' )
|
||||
);
|
||||
|
||||
$allowed_tags = [
|
||||
'h3' => [],
|
||||
'p' => [],
|
||||
'a' => [
|
||||
'class' => [],
|
||||
'target' => [ '_blank' ],
|
||||
'href' => [],
|
||||
],
|
||||
];
|
||||
?>
|
||||
|
||||
<script>
|
||||
jQuery( document ).ready( function( $ ) {
|
||||
$( "#<?php echo esc_attr( self::ELEMENTOR_POINTER_ID ); ?>" ).pointer( {
|
||||
content: '<?php echo wp_kses( $pointer_content, $allowed_tags ); ?>',
|
||||
position: {
|
||||
edge: <?php echo is_rtl() ? "'right'" : "'left'"; ?>,
|
||||
align: "center"
|
||||
},
|
||||
close: function() {
|
||||
elementorCommon.ajax.addRequest( "introduction_viewed", {
|
||||
data: {
|
||||
introductionKey: '<?php echo esc_attr( static::DISMISS_ACTION_KEY ); ?>'
|
||||
}
|
||||
} );
|
||||
}
|
||||
} ).pointer( "open" );
|
||||
} );
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
public static function should_display_notice(): bool {
|
||||
return self::is_user_allowed() &&
|
||||
! self::is_dismissed() &&
|
||||
self::is_campaign_time() &&
|
||||
! self::is_already_seen_today() &&
|
||||
! Utils::has_pro();
|
||||
}
|
||||
|
||||
private static function is_user_allowed(): bool {
|
||||
return current_user_can( 'manage_options' ) || current_user_can( 'edit_pages' );
|
||||
}
|
||||
|
||||
private static function is_campaign_time() {
|
||||
$start = new \DateTime( '2025-06-10 12:00:00', new \DateTimeZone( 'UTC' ) );
|
||||
$end = new \DateTime( '2025-06-17 03:59:00', new \DateTimeZone( 'UTC' ) );
|
||||
$now = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) );
|
||||
|
||||
return $now >= $start && $now <= $end;
|
||||
}
|
||||
|
||||
private static function is_already_seen_today() {
|
||||
return get_transient( self::get_user_transient_id() );
|
||||
}
|
||||
|
||||
private function set_seen_today() {
|
||||
$now = time();
|
||||
$midnight = strtotime( 'tomorrow midnight' );
|
||||
$seconds_until_midnight = $midnight - $now;
|
||||
|
||||
set_transient( self::get_user_transient_id(), $now, $seconds_until_midnight );
|
||||
}
|
||||
|
||||
private static function get_user_transient_id(): string {
|
||||
return self::SEEN_TODAY_KEY . '_' . get_current_user_id();
|
||||
}
|
||||
|
||||
private function enqueue_dependencies() {
|
||||
wp_enqueue_script( 'wp-pointer' );
|
||||
wp_enqueue_style( 'wp-pointer' );
|
||||
}
|
||||
|
||||
private static function is_dismissed(): bool {
|
||||
return User::get_introduction_meta( static::DISMISS_ACTION_KEY );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
namespace Elementor\Modules\Promotions;
|
||||
|
||||
use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager;
|
||||
use Elementor\Includes\EditorAssetsAPI;
|
||||
use Elementor\Utils;
|
||||
|
||||
class PromotionData {
|
||||
protected EditorAssetsAPI $editor_assets_api;
|
||||
|
||||
public function __construct( EditorAssetsAPI $editor_assets_api ) {
|
||||
$this->editor_assets_api = $editor_assets_api;
|
||||
}
|
||||
|
||||
public function get_promotion_data( $force_request = false ): array {
|
||||
$assets_data = $this->transform_assets_data( $force_request );
|
||||
|
||||
return [
|
||||
Utils::ANIMATED_HEADLINE => $this->get_animated_headline_data( $assets_data ),
|
||||
Utils::VIDEO_PLAYLIST => $this->get_video_playlist_data( $assets_data ),
|
||||
Utils::CTA => $this->get_cta_button_data( $assets_data ),
|
||||
Utils::IMAGE_CAROUSEL => $this->get_image_carousel_data( $assets_data ),
|
||||
Utils::TESTIMONIAL_WIDGET => $this->get_testimonial_widget_data( $assets_data ),
|
||||
];
|
||||
}
|
||||
|
||||
private function transform_assets_data( $force_request = false ) {
|
||||
$assets_data = $this->editor_assets_api->get_assets_data( $force_request );
|
||||
$transformed_data = [];
|
||||
|
||||
foreach ( $assets_data as $asset ) {
|
||||
$transformed_data[ $asset['id'] ] = $asset['imageSrc'];
|
||||
}
|
||||
|
||||
return $transformed_data;
|
||||
}
|
||||
|
||||
private function get_animated_headline_data( $assets_data ) {
|
||||
$data = [
|
||||
'image' => esc_url( $assets_data[ Utils::ANIMATED_HEADLINE ] ?? '' ),
|
||||
'image_alt' => esc_attr__( 'Upgrade', 'elementor' ),
|
||||
'title' => esc_html__( 'Bring Headlines to Life', 'elementor' ),
|
||||
'description' => [
|
||||
esc_html__( 'Highlight key messages dynamically.', 'elementor' ),
|
||||
esc_html__( 'Apply rotating effects to text.', 'elementor' ),
|
||||
esc_html__( 'Fully customize your headlines.', 'elementor' ),
|
||||
],
|
||||
'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ),
|
||||
'upgrade_url' => 'https://go.elementor.com/go-pro-heading-widget-control/',
|
||||
];
|
||||
|
||||
return $this->filter_data( Utils::ANIMATED_HEADLINE, $data );
|
||||
}
|
||||
|
||||
private function get_video_playlist_data( $assets_data ) {
|
||||
$data = [
|
||||
'image' => esc_url( $assets_data[ Utils::VIDEO_PLAYLIST ] ?? '' ),
|
||||
'image_alt' => esc_attr__( 'Upgrade', 'elementor' ),
|
||||
'title' => esc_html__( 'Showcase Video Playlists', 'elementor' ),
|
||||
'description' => [
|
||||
esc_html__( 'Embed videos with full control.', 'elementor' ),
|
||||
esc_html__( 'Adjust layout and playback settings.', 'elementor' ),
|
||||
esc_html__( 'Seamlessly customize video appearance.', 'elementor' ),
|
||||
],
|
||||
'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ),
|
||||
'upgrade_url' => 'https://go.elementor.com/go-pro-video-widget-control/',
|
||||
];
|
||||
|
||||
return $this->filter_data( Utils::VIDEO_PLAYLIST, $data );
|
||||
}
|
||||
|
||||
private function get_cta_button_data( $assets_data ) {
|
||||
$data = [
|
||||
'image' => esc_url( $assets_data[ Utils::CTA ] ?? '' ),
|
||||
'image_alt' => esc_attr__( 'Upgrade', 'elementor' ),
|
||||
'title' => esc_html__( 'Boost Conversions with CTAs', 'elementor' ),
|
||||
'description' => [
|
||||
esc_html__( 'Combine text, buttons, and images.', 'elementor' ),
|
||||
esc_html__( 'Add hover animations and CSS effects.', 'elementor' ),
|
||||
esc_html__( 'Create unique, interactive designs.', 'elementor' ),
|
||||
],
|
||||
'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ),
|
||||
'upgrade_url' => 'https://go.elementor.com/go-pro-button-widget-control/',
|
||||
];
|
||||
|
||||
return $this->filter_data( Utils::CTA, $data );
|
||||
}
|
||||
|
||||
private function get_image_carousel_data( $assets_data ) {
|
||||
$data = [
|
||||
'image' => esc_url( $assets_data[ Utils::IMAGE_CAROUSEL ] ?? '' ),
|
||||
'image_alt' => esc_attr__( 'Upgrade', 'elementor' ),
|
||||
'title' => esc_html__( 'Design Custom Carousels', 'elementor' ),
|
||||
'description' => [
|
||||
esc_html__( 'Create flexible custom carousels.', 'elementor' ),
|
||||
esc_html__( 'Adjust transitions and animations.', 'elementor' ),
|
||||
esc_html__( 'Showcase multiple items with style.', 'elementor' ),
|
||||
],
|
||||
'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ),
|
||||
'upgrade_url' => 'https://go.elementor.com/go-pro-image-carousel-widget-control/',
|
||||
];
|
||||
|
||||
return $this->filter_data( Utils::IMAGE_CAROUSEL, $data );
|
||||
}
|
||||
|
||||
private function get_testimonial_widget_data( $assets_data ) {
|
||||
$data = [
|
||||
'image' => esc_url( $assets_data[ Utils::TESTIMONIAL_WIDGET ] ?? '' ),
|
||||
'image_alt' => esc_attr__( 'Upgrade', 'elementor' ),
|
||||
'title' => esc_html__( 'Upgrade Your Testimonials', 'elementor' ),
|
||||
'description' => [
|
||||
esc_html__( 'Display reviews in a rotating carousel.', 'elementor' ),
|
||||
esc_html__( 'Boost credibility with dynamic testimonials.', 'elementor' ),
|
||||
esc_html__( 'Customize layouts for visual appeal.', 'elementor' ),
|
||||
],
|
||||
'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ),
|
||||
'upgrade_url' => 'https://go.elementor.com/go-pro-testimonial-widget-control/',
|
||||
];
|
||||
|
||||
return $this->filter_data( Utils::TESTIMONIAL_WIDGET, $data );
|
||||
}
|
||||
|
||||
private function filter_data( $widget_name, $asset_data ): array {
|
||||
return Filtered_Promotions_Manager::get_filtered_promotion_data( $asset_data, "elementor/widgets/{$widget_name}/custom_promotion", 'upgrade_url' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
namespace Elementor\Modules\Promotions\Widgets;
|
||||
|
||||
use Elementor\Widget_Base;
|
||||
use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Pro_Widget_Promotion extends Widget_Base {
|
||||
|
||||
private $widget_data;
|
||||
|
||||
public function hide_on_search() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function show_in_panel() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get_name() {
|
||||
return $this->widget_data['widget_name'];
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return $this->widget_data['widget_title'];
|
||||
}
|
||||
|
||||
public function get_categories() {
|
||||
return [ 'general', 'pro-elements' ];
|
||||
}
|
||||
|
||||
public function on_import( $element ) {
|
||||
$element['settings']['__should_import'] = true;
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
protected function register_controls() {}
|
||||
|
||||
protected function render() {
|
||||
if ( $this->is_editor_render() ) {
|
||||
$this->render_promotion();
|
||||
} else {
|
||||
$this->render_empty_content();
|
||||
}
|
||||
}
|
||||
|
||||
private function is_editor_render(): bool {
|
||||
return \Elementor\Plugin::$instance->editor->is_edit_mode();
|
||||
}
|
||||
|
||||
private function render_promotion() {
|
||||
$promotion = Filtered_Promotions_Manager::get_filtered_promotion_data(
|
||||
[
|
||||
'image_url' => esc_url( $this->get_promotion_image_url() ),
|
||||
'text' => sprintf(
|
||||
/* translators: %s: Widget title. */
|
||||
esc_html__( 'This result includes the Elementor Pro %s widget. Upgrade now to unlock it and grow your web creation toolkit.', 'elementor' ),
|
||||
esc_html( $this->widget_data['widget_title'] )
|
||||
),
|
||||
'upgrade_url' => esc_url( 'https://go.elementor.com/go-pro-element-pro/' ),
|
||||
],
|
||||
'elementor/pro-widget/promotion',
|
||||
'upgrade_url'
|
||||
);
|
||||
?>
|
||||
<div class="e-container">
|
||||
<span class="e-badge"><i class="eicon-lock" aria-hidden="true"></i> <?php echo esc_html__( 'Pro', 'elementor' ); ?></span>
|
||||
<p>
|
||||
<img src="<?php echo esc_url( $promotion['image_url'] ); ?>" loading="lazy" alt="Go Pro">
|
||||
<?php
|
||||
echo esc_html( $promotion['text'] );
|
||||
?>
|
||||
</p>
|
||||
<div class="e-actions">
|
||||
<a href="#" class="e-btn e-btn-txt e-promotion-delete"><?php echo esc_html__( 'Remove', 'elementor' ); ?></a>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
private function get_promotion_image_url(): string {
|
||||
return ELEMENTOR_ASSETS_URL . 'images/go-pro.svg';
|
||||
}
|
||||
|
||||
private function render_empty_content() {
|
||||
echo ' ';
|
||||
}
|
||||
|
||||
protected function content_template() {}
|
||||
|
||||
public function __construct( $data = [], $args = null ) {
|
||||
$this->widget_data = [
|
||||
'widget_name' => $args['widget_name'],
|
||||
'widget_title' => $args['widget_title'],
|
||||
];
|
||||
|
||||
parent::__construct( $data, $args );
|
||||
}
|
||||
|
||||
public function render_plain_content( $instance = [] ) {}
|
||||
}
|
||||
Reference in New Issue
Block a user