first commit

This commit is contained in:
2026-05-25 14:34:29 +02:00
commit 64f5e06629
4236 changed files with 1314148 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
<?php
namespace Elementor\Modules\Home\Transformations\Base;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
use Elementor\Core\Isolation\Elementor_Adapter;
use Elementor\Core\Isolation\Elementor_Adapter_Interface;
use Elementor\Core\Isolation\Plugin_Status_Adapter;
use Elementor\Core\Isolation\Plugin_Status_Adapter_Interface;
use Elementor\Core\Isolation\Wordpress_Adapter;
use Elementor\Core\Isolation\Wordpress_Adapter_Interface;
abstract class Transformations_Abstract {
protected const USER_TIER_FREE = 'free';
protected const USER_TIER_PRO = 'pro';
protected const USER_TIER_AGENCY = 'agency';
protected const USER_TIER_ONE = 'one';
protected Wordpress_Adapter_Interface $wordpress_adapter;
protected Plugin_Status_Adapter_Interface $plugin_status_adapter;
protected Elementor_Adapter_Interface $elementor_adapter;
/**
* @param $args ?array{
* wordpress_adapter: Wordpress_Adapter_Interface,
* plugin_status_adapter: Plugin_Status_Adapter_Interface,
* elementor_adapter: Elementor_Adapter_Interface,
* } the adapters to use in the transformations
*/
public function __construct( array $args = [] ) {
$this->wordpress_adapter = $args['wordpress_adapter'] ?? new Wordpress_Adapter();
$this->plugin_status_adapter = $args['plugin_status_adapter'] ?? new Plugin_Status_Adapter( $this->wordpress_adapter );
$this->elementor_adapter = $args['elementor_adapter'] ?? new Elementor_Adapter();
}
protected function get_tier() {
$tier = $this->elementor_adapter->get_tier();
$filtered_tier = apply_filters( 'elementor/admin/homescreen_promotion_tier', $tier ) ?? $tier;
return $this->normalize_tier( $filtered_tier );
}
private function normalize_tier( string $tier ): string {
return self::USER_TIER_AGENCY === $tier ? self::USER_TIER_ONE : $tier;
}
abstract public function transform( array $home_screen_data ): array;
}

View File

@@ -0,0 +1,18 @@
<?php
namespace Elementor\Modules\Home\Transformations;
use Elementor\Modules\Home\Transformations\Base\Transformations_Abstract;
use Elementor\Plugin;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class Create_Edit_Website_Url extends Transformations_Abstract {
public function transform( array $home_screen_data ): array {
$home_screen_data['edit_website_url'] = wp_nonce_url( admin_url( 'admin.php?action=elementor_edit_website_redirect' ), 'elementor_action_edit_website' );
return $home_screen_data;
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace Elementor\Modules\Home\Transformations;
use Elementor\Modules\Home\Transformations\Base\Transformations_Abstract;
use Elementor\Plugin;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class Create_New_Page_Url extends Transformations_Abstract {
public function transform( array $home_screen_data ): array {
$home_screen_data['button_cta_url'] = Plugin::$instance->documents->get_create_new_post_url( 'page' );
return $home_screen_data;
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace Elementor\Modules\Home\Transformations;
use Elementor\Core\DocumentTypes\Page;
use Elementor\Includes\EditorAssetsAPI;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class Create_Site_Settings_Url extends Base\Transformations_Abstract {
const SITE_SETTINGS_ITEMS = [ 'Site Settings', 'Site Logo', 'Global Colors', 'Global Fonts' ];
public function transform( array $home_screen_data ): array {
if ( ! EditorAssetsAPI::has_valid_nested_array( $home_screen_data, [ 'get_started', 'repeater' ] ) ) {
return $home_screen_data;
}
$site_settings_url_config = Page::get_site_settings_url_config();
$home_screen_data['get_started']['repeater'] = array_map( function( $repeater_item ) use ( $site_settings_url_config ) {
if ( ! in_array( $repeater_item['title'], static::SITE_SETTINGS_ITEMS, true ) ) {
return $repeater_item;
}
if ( ! empty( $repeater_item['tab_id'] ) ) {
$site_settings_url_config['url'] = add_query_arg( [ 'active-tab' => $repeater_item['tab_id'] ], $site_settings_url_config['url'] );
}
return array_merge( $repeater_item, $site_settings_url_config );
}, $home_screen_data['get_started']['repeater'] );
return $home_screen_data;
}
}

View File

@@ -0,0 +1,67 @@
<?php
namespace Elementor\Modules\Home\Transformations;
use Elementor\Includes\EditorAssetsAPI;
use Elementor\Modules\Home\Transformations\Base\Transformations_Abstract;
use Elementor\Utils;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class Filter_Get_Started_By_License extends Transformations_Abstract {
public bool $has_pro;
private array $supported_tiers;
public function __construct( $args ) {
parent::__construct( $args );
$this->has_pro = Utils::has_pro();
$this->supported_tiers = [
self::USER_TIER_FREE,
self::USER_TIER_PRO,
self::USER_TIER_ONE,
];
}
private function is_valid_item( $item ) {
$user_tier = $this->get_tier();
if ( ! $this->has_pro && self::USER_TIER_FREE === $item['license'][0] ) {
return true;
}
if ( $user_tier === $item['license'][0] ) {
return true;
}
return $this->is_fallback_for_unsupported_licenses( $item['license'][0], $user_tier );
}
private function is_fallback_for_unsupported_licenses( $item_tier, $user_tier ): bool {
$is_supported_user_tier = in_array( $user_tier, $this->supported_tiers, true );
return ! $is_supported_user_tier && self::USER_TIER_PRO === $item_tier;
}
public function transform( array $home_screen_data ): array {
if ( ! EditorAssetsAPI::has_valid_nested_array( $home_screen_data, [ 'get_started' ] ) ) {
return $home_screen_data;
}
$new_get_started = [];
foreach ( $home_screen_data['get_started'] as $index => $item ) {
if ( $this->is_valid_item( $item ) ) {
$new_get_started[] = $item;
}
}
$home_screen_data['get_started'] = reset( $new_get_started );
return $home_screen_data;
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace elementor\modules\home\transformations;
use Elementor\Includes\EditorAssetsAPI;
use Elementor\Modules\Home\Transformations\Base\Transformations_Abstract;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class Filter_Sidebar_Promotion_By_License extends Transformations_Abstract {
public function transform( array $home_screen_data ): array {
if ( ! EditorAssetsAPI::has_valid_nested_array( $home_screen_data, [ 'sidebar_promotion_variants' ] ) ) {
return $home_screen_data;
}
$user_tier = $this->get_tier();
$new_sidebar_promotion = array_filter( $home_screen_data['sidebar_promotion_variants'], function( $item ) use ( $user_tier ) {
return $this->is_enabled( $item ) && $this->is_tier_acceptable( $item, $user_tier );
});
if ( empty( $new_sidebar_promotion ) ) {
unset( $home_screen_data['sidebar_promotion_variants'] );
return $home_screen_data;
}
$home_screen_data['sidebar_promotion_variants'] = reset( $new_sidebar_promotion );
return $home_screen_data;
}
private function is_enabled( $item ) {
return ! empty( $item['is_enabled'] ) && 'true' === $item['is_enabled'];
}
private function is_tier_acceptable( $item, $user_tier ) {
return ! empty( $item['license'] ) && in_array( $user_tier, $item['license'] );
}
}

View File

@@ -0,0 +1,78 @@
<?php
namespace elementor\modules\home\transformations;
use Elementor\Core\Common\Modules\Connect\Module as ConnectModule;
use Elementor\Includes\EditorAssetsAPI;
use Elementor\Modules\Home\Transformations\Base\Transformations_Abstract;
use Elementor\Utils;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class Filter_Top_Section_By_License extends Transformations_Abstract {
public bool $has_pro;
private array $supported_tiers;
public function __construct( array $args = [] ) {
parent::__construct( $args );
$this->has_pro = Utils::has_pro();
$this->supported_tiers = [
ConnectModule::ACCESS_TIER_FREE,
ConnectModule::ACCESS_TIER_PRO_LEGACY,
self::USER_TIER_ONE,
];
}
private function is_valid_item( $item ) {
if ( isset( $item['license'] ) ) {
$item_tier = $item['license'][0];
$user_tier = $this->get_tier();
return $this->validate_tier( $item_tier, $user_tier );
}
return false;
}
private function validate_tier( $item_tier, $user_tier ): bool {
if ( $user_tier === $item_tier ) {
return true;
}
$is_user_tier_supported = in_array( $user_tier, $this->supported_tiers, true );
if ( $is_user_tier_supported ) {
return false;
}
$is_item_tier_free = ConnectModule::ACCESS_TIER_FREE === $item_tier;
$is_valid = $this->has_pro !== $is_item_tier_free;
$is_supported_item_tier = in_array( $item_tier, $this->supported_tiers, true );
return $is_valid && $is_supported_item_tier;
}
public function transform( array $home_screen_data ): array {
if ( ! EditorAssetsAPI::has_valid_nested_array( $home_screen_data, [ 'top_with_licences' ] ) ) {
return $home_screen_data;
}
$new_top = [];
foreach ( $home_screen_data['top_with_licences'] as $index => $item ) {
if ( $this->is_valid_item( $item ) ) {
$new_top = $item;
break;
}
}
$home_screen_data['top_with_licences'] = $new_top;
return $home_screen_data;
}
}