| @@ -2,9 +2,9 @@ | ||
| 2 | 2 | namespace Elementor\App; |
| 3 | 3 | |
| 4 | 4 | use Elementor\App\AdminMenuItems\Theme_Builder_Menu_Item; |
| 5 | 5 | use Elementor\Core\Admin\Menu\Admin_Menu_Manager; |
| 6 | -use Elementor\Core\Experiments\Manager as ExperimentsManager; | |
| 6 | +use Elementor\Icons_Manager; | |
| 7 | 7 | use Elementor\Modules\WebCli\Module as WebCLIModule; |
| 8 | 8 | use Elementor\Core\Base\App as BaseApp; |
| 9 | 9 | use Elementor\Core\Settings\Manager as SettingsManager; |
| 10 | 10 | use Elementor\Plugin; |
| @@ -10,21 +10,9 @@ | ||
| 10 | 10 | use Elementor\Plugin; |
| 11 | 11 | use Elementor\TemplateLibrary\Source_Local; |
| 12 | 12 | use Elementor\User; |
| 13 | 13 | use Elementor\Utils; |
| 14 | -use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager; | |
| 15 | -use Elementor\Core\Utils\Assets_Config_Provider; | |
| 16 | -use Elementor\Core\Utils\Collection; | |
| 17 | -use Elementor\Core\Utils\Assets_Translation_Loader; | |
| 18 | -use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider; | |
| 19 | -use Elementor\App\AdminMenuItems\Editor_One_Theme_Builder_Menu; | |
| 20 | 14 | |
| 21 | -use Elementor\App\Modules\ImportExport\Module as ImportExportModule; | |
| 22 | -use Elementor\App\Modules\KitLibrary\Module as KitLibraryModule; | |
| 23 | -use Elementor\App\Modules\ImportExportCustomization\Module as ImportExportCustomizationModule; | |
| 24 | -use Elementor\App\Modules\SiteEditor\Module as SiteEditorModule; | |
| 25 | -use Elementor\App\Modules\Onboarding\Module as OnboardingModule; | |
| 26 | - | |
| 27 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 28 | 16 | exit; // Exit if accessed directly. |
| 29 | 17 | } |
| 30 | 18 | |
| @@ -49,10 +37,10 @@ | ||
| 49 | 37 | public function get_base_url() { |
| 50 | 38 | return admin_url( 'admin.php?page=' . self::PAGE_ID . '&ver=' . ELEMENTOR_VERSION ); |
| 51 | 39 | } |
| 52 | 40 | |
| 53 | - private function register_editor_one_menu( Menu_Data_Provider $menu_data_provider ) { | |
| 54 | - $menu_data_provider->register_menu( new Editor_One_Theme_Builder_Menu() ); | |
| 41 | + private function register_admin_menu( Admin_Menu_Manager $admin_menu ) { | |
| 42 | + $admin_menu->register( static::PAGE_ID, new Theme_Builder_Menu_Item() ); | |
| 55 | 43 | } |
| 56 | 44 | |
| 57 | 45 | public function fix_submenu( $menu ) { |
| 58 | 46 | global $submenu; |
| @@ -86,16 +74,12 @@ | ||
| 86 | 74 | |
| 87 | 75 | // Add the introduction and user settings only when it is needed (when loading the app and not in the editor or admin pages) |
| 88 | 76 | $this->set_settings( 'user', [ |
| 89 | 77 | 'introduction' => (object) User::get_introduction_meta(), |
| 90 | - 'is_administrator' => current_user_can( 'manage_options' ), | |
| 91 | - 'restrictions' => Plugin::$instance->role_manager->get_user_restrictions_array(), | |
| 92 | 78 | ] ); |
| 93 | 79 | |
| 94 | 80 | $this->enqueue_assets(); |
| 95 | 81 | |
| 96 | - remove_action( 'wp_print_styles', 'print_emoji_styles' ); | |
| 97 | - | |
| 98 | 82 | // Setup default heartbeat options |
| 99 | 83 | // TODO: Enable heartbeat. |
| 100 | 84 | add_filter( 'heartbeat_settings', function( $settings ) { |
| 101 | 85 | $settings['interval'] = 15; |
| @@ -117,14 +101,8 @@ | ||
| 117 | 101 | 'hasPro' => Utils::has_pro(), |
| 118 | 102 | 'admin_url' => admin_url(), |
| 119 | 103 | 'login_url' => wp_login_url(), |
| 120 | 104 | 'base_url' => $this->get_base_url(), |
| 121 | - 'home_url' => home_url(), | |
| 122 | - 'promotion' => Filtered_Promotions_Manager::get_filtered_promotion_data( | |
| 123 | - [ 'upgrade_url' => 'https://go.elementor.com/go-pro-theme-builder/' ], | |
| 124 | - 'elementor/site-editor/promotion', | |
| 125 | - 'upgrade_url' | |
| 126 | - ), | |
| 127 | 105 | ]; |
| 128 | 106 | } |
| 129 | 107 | |
| 130 | 108 | private function render() { |
| @@ -131,16 +109,16 @@ | ||
| 131 | 109 | require __DIR__ . '/view.php'; |
| 132 | 110 | } |
| 133 | 111 | |
| 134 | 112 | /** |
| 135 | - * Get Elementor editor theme color preference. | |
| 113 | + * Get Elementor UI theme preference. | |
| 136 | 114 | * |
| 137 | - * Retrieve the user theme color preference as defined by editor preferences manager. | |
| 115 | + * Retrieve the user UI theme preference as defined by editor preferences manager. | |
| 138 | 116 | * |
| 139 | 117 | * @since 3.0.0 |
| 140 | 118 | * @access private |
| 141 | 119 | * |
| 142 | - * @return string Preferred editor theme. | |
| 120 | + * @return string Preferred UI theme. | |
| 143 | 121 | */ |
| 144 | 122 | private function get_elementor_ui_theme_preference() { |
| 145 | 123 | $editor_preferences = SettingsManager::get_settings_managers( 'editorPreferences' ); |
| 146 | 124 | |
| @@ -162,38 +140,11 @@ | ||
| 162 | 140 | { document.body.classList.add( `eps-theme-dark` ); }' ); |
| 163 | 141 | } |
| 164 | 142 | } |
| 165 | 143 | |
| 166 | - private function register_packages() { | |
| 167 | - $assets_config_provider = ( new Assets_Config_Provider() ) | |
| 168 | - ->set_path_resolver( function ( $name ) { | |
| 169 | - return ELEMENTOR_ASSETS_PATH . "js/packages/{$name}/{$name}.asset.php"; | |
| 170 | - } ); | |
| 171 | - | |
| 172 | - Collection::make( [ 'ui', 'icons', 'store', 'query', 'utils', 'events', 'onboarding' ] ) | |
| 173 | - ->each( function( $package ) use ( $assets_config_provider ) { | |
| 174 | - $suffix = Utils::is_script_debug() ? '' : '.min'; | |
| 175 | - $config = $assets_config_provider->load( $package )->get( $package ); | |
| 176 | - | |
| 177 | - if ( ! $config ) { | |
| 178 | - return; | |
| 179 | - } | |
| 180 | - | |
| 181 | - wp_register_script( | |
| 182 | - $config['handle'], | |
| 183 | - ELEMENTOR_ASSETS_URL . "js/packages/{$package}/{$package}{$suffix}.js", | |
| 184 | - $config['deps'], | |
| 185 | - ELEMENTOR_VERSION, | |
| 186 | - true | |
| 187 | - ); | |
| 188 | - } ); | |
| 189 | - } | |
| 190 | - | |
| 191 | 144 | private function enqueue_assets() { |
| 192 | 145 | Plugin::$instance->init_common(); |
| 193 | 146 | |
| 194 | - $this->register_packages(); | |
| 195 | - | |
| 196 | 147 | /** @var WebCLIModule $web_cli */ |
| 197 | 148 | $web_cli = Plugin::$instance->modules_manager->get_modules( 'web-cli' ); |
| 198 | 149 | $web_cli->register_scripts(); |
| 199 | 150 | |
| @@ -253,11 +204,8 @@ | ||
| 253 | 204 | $this->get_js_assets_url( 'app' ), |
| 254 | 205 | [ |
| 255 | 206 | 'wp-url', |
| 256 | 207 | 'wp-i18n', |
| 257 | - 'elementor-v2-ui', | |
| 258 | - 'elementor-v2-icons', | |
| 259 | - 'elementor-v2-onboarding', | |
| 260 | 208 | 'react', |
| 261 | 209 | 'react-dom', |
| 262 | 210 | 'select2', |
| 263 | 211 | ], |
| @@ -266,9 +214,10 @@ | ||
| 266 | 214 | ); |
| 267 | 215 | |
| 268 | 216 | $this->enqueue_dark_theme_detection_script(); |
| 269 | 217 | |
| 270 | - Assets_Translation_Loader::for_handles( [ 'elementor-app-packages', 'elementor-app' ], 'elementor' ); | |
| 218 | + wp_set_script_translations( 'elementor-app-packages', 'elementor' ); | |
| 219 | + wp_set_script_translations( 'elementor-app', 'elementor' ); | |
| 271 | 220 | |
| 272 | 221 | $this->print_config(); |
| 273 | 222 | } |
| 274 | 223 | |
| @@ -285,41 +234,23 @@ | ||
| 285 | 234 | |
| 286 | 235 | $this->print_config( 'elementor-app-loader' ); |
| 287 | 236 | } |
| 288 | 237 | |
| 289 | - private function register_import_export_customization_experiment() { | |
| 290 | - Plugin::$instance->experiments->add_feature( [ | |
| 291 | - 'name' => 'import-export-customization', | |
| 292 | - 'title' => esc_html__( 'Import/Export Customization', 'elementor' ), | |
| 293 | - 'description' => esc_html__( 'Enhanced import/export for website templates. Selectively include site content, templates, and settings with advanced granular control.', 'elementor' ), | |
| 294 | - 'release_status' => ExperimentsManager::RELEASE_STATUS_BETA, | |
| 295 | - 'default' => ExperimentsManager::STATE_ACTIVE, | |
| 296 | - 'hidden' => true, | |
| 297 | - 'mutable' => false, | |
| 298 | - ] ); | |
| 299 | - } | |
| 300 | - | |
| 301 | 238 | public function __construct() { |
| 302 | - $this->register_import_export_customization_experiment(); | |
| 239 | + $this->add_component( 'site-editor', new Modules\SiteEditor\Module() ); | |
| 303 | 240 | |
| 304 | - $this->add_component( 'site-editor', new SiteEditorModule() ); | |
| 305 | - | |
| 306 | 241 | if ( current_user_can( 'manage_options' ) || Utils::is_wp_cli() ) { |
| 307 | - $this->add_component( 'import-export', new ImportExportModule() ); | |
| 242 | + $this->add_component( 'import-export', new Modules\ImportExport\Module() ); | |
| 308 | 243 | |
| 309 | - if ( Plugin::$instance->experiments->is_feature_active( 'import-export-customization' ) ) { | |
| 310 | - $this->add_component( 'import-export-customization', new ImportExportCustomizationModule() ); | |
| 311 | - } | |
| 312 | - | |
| 313 | 244 | // Kit library is depended on import-export |
| 314 | - $this->add_component( 'kit-library', new KitLibraryModule() ); | |
| 245 | + $this->add_component( 'kit-library', new Modules\KitLibrary\Module() ); | |
| 315 | 246 | } |
| 316 | 247 | |
| 317 | - $this->add_component( 'onboarding', new OnboardingModule() ); | |
| 248 | + $this->add_component( 'onboarding', new Modules\Onboarding\Module() ); | |
| 318 | 249 | |
| 319 | - add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) { | |
| 320 | - $this->register_editor_one_menu( $menu_data_provider ); | |
| 321 | - } ); | |
| 250 | + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) { | |
| 251 | + $this->register_admin_menu( $admin_menu ); | |
| 252 | + }, Source_Local::ADMIN_MENU_PRIORITY + 10 ); | |
| 322 | 253 | |
| 323 | 254 | // Happens after WP plugin page validation. |
| 324 | 255 | add_filter( 'add_menu_classes', [ $this, 'fix_submenu' ] ); |
| 325 | 256 | |