| @@ -3,11 +3,10 @@ | ||
| 3 | 3 | |
| 4 | 4 | use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager; |
| 5 | 5 | use Elementor\Core\Common\Modules\Ajax\Module; |
| 6 | 6 | use Elementor\Core\Debug\Loading_Inspection_Manager; |
| 7 | -use Elementor\Core\Editor\Loader\Editor_Loader; | |
| 8 | -use Elementor\Core\Utils\Assets_Config_Provider; | |
| 9 | -use Elementor\Core\Utils\Collection; | |
| 7 | +use Elementor\Core\Editor\Loader\Editor_Loader_Factory; | |
| 8 | +use Elementor\Core\Editor\Loader\Editor_Loader_Interface; | |
| 10 | 9 | use Elementor\Core\Settings\Manager as SettingsManager; |
| 11 | 10 | use Elementor\Plugin; |
| 12 | 11 | use Elementor\TemplateLibrary\Source_Local; |
| 13 | 12 | use Elementor\Utils; |
| @@ -66,9 +65,9 @@ | ||
| 66 | 65 | */ |
| 67 | 66 | public $promotion; |
| 68 | 67 | |
| 69 | 68 | /** |
| 70 | - * @var Editor_Loader | |
| 69 | + * @var Editor_Loader_Interface | |
| 71 | 70 | */ |
| 72 | 71 | private $loader; |
| 73 | 72 | |
| 74 | 73 | /** |
| @@ -212,67 +211,8 @@ | ||
| 212 | 211 | die; |
| 213 | 212 | } |
| 214 | 213 | |
| 215 | 214 | /** |
| 216 | - * Whether the current request targets the Elementor editor. | |
| 217 | - * | |
| 218 | - * Unlike `is_edit_mode()`, this is not affected by temporary `set_edit_mode()` overrides. | |
| 219 | - * | |
| 220 | - * @since 4.1.0 | |
| 221 | - * @access public | |
| 222 | - * | |
| 223 | - * @return bool Whether the current request targets the Elementor editor. | |
| 224 | - */ | |
| 225 | - public function is_editor_request() { | |
| 226 | - $common = Plugin::$instance->common; | |
| 227 | - | |
| 228 | - if ( $common ) { | |
| 229 | - /** @var Module ajax */ | |
| 230 | - $ajax_data = $common->get_component( 'ajax' )->get_current_action_data(); | |
| 231 | - | |
| 232 | - if ( ! empty( $ajax_data ) && 'get_document_config' === $ajax_data['action'] ) { | |
| 233 | - return true; | |
| 234 | - } | |
| 235 | - } | |
| 236 | - | |
| 237 | - if ( $this->is_editor_admin_screen() ) { | |
| 238 | - return true; | |
| 239 | - } | |
| 240 | - | |
| 241 | - return $this->is_editor_ajax_request(); | |
| 242 | - } | |
| 243 | - | |
| 244 | - private function is_editor_admin_screen(): bool { | |
| 245 | - if ( ! function_exists( 'get_current_screen' ) ) { | |
| 246 | - return false; | |
| 247 | - } | |
| 248 | - | |
| 249 | - $screen = get_current_screen(); | |
| 250 | - | |
| 251 | - if ( ! $screen ) { | |
| 252 | - return false; | |
| 253 | - } | |
| 254 | - | |
| 255 | - return isset( $_GET['action'] ) && 'elementor' === $_GET['action'] && in_array( $screen->base, [ 'post', 'toplevel_page_elementor' ], true ); | |
| 256 | - } | |
| 257 | - | |
| 258 | - private function is_editor_ajax_request(): bool { | |
| 259 | - $actions = apply_filters( 'elementor/editor/ajax_actions', [ | |
| 260 | - 'elementor', | |
| 261 | - | |
| 262 | - // Templates | |
| 263 | - 'elementor_get_templates', | |
| 264 | - 'elementor_save_template', | |
| 265 | - 'elementor_get_template', | |
| 266 | - 'elementor_delete_template', | |
| 267 | - 'elementor_import_template', | |
| 268 | - 'elementor_library_direct_actions', | |
| 269 | - ] ); | |
| 270 | - | |
| 271 | - return isset( $_REQUEST['action'] ) && in_array( $_REQUEST['action'], $actions, true ); | |
| 272 | - } | |
| 273 | - | |
| 274 | - /** | |
| 275 | 215 | * Whether the edit mode is active. |
| 276 | 216 | * |
| 277 | 217 | * Used to determine whether we are in the edit mode. |
| 278 | 218 | * |
| @@ -720,24 +660,13 @@ | ||
| 720 | 660 | |
| 721 | 661 | /** |
| 722 | 662 | * Get loader. |
| 723 | 663 | * |
| 724 | - * @return Editor_Loader | |
| 664 | + * @return Editor_Loader_Interface | |
| 725 | 665 | */ |
| 726 | 666 | private function get_loader() { |
| 727 | 667 | if ( ! $this->loader ) { |
| 728 | - $this->loader = new Editor_Loader( | |
| 729 | - new Collection( [ | |
| 730 | - 'assets_url' => ELEMENTOR_ASSETS_URL, | |
| 731 | - 'min_suffix' => ( Utils::is_script_debug() || Utils::is_elementor_tests() ) ? '' : '.min', | |
| 732 | - 'direction_suffix' => is_rtl() ? '-rtl' : '', | |
| 733 | - ] ), | |
| 734 | - ( new Assets_Config_Provider() )->set_path_resolver( | |
| 735 | - function ( $name ) { | |
| 736 | - return ELEMENTOR_ASSETS_PATH . "js/packages/{$name}/{$name}.asset.php"; | |
| 737 | - } | |
| 738 | - ) | |
| 739 | - ); | |
| 668 | + $this->loader = Editor_Loader_Factory::create(); | |
| 740 | 669 | |
| 741 | 670 | $this->loader->init(); |
| 742 | 671 | } |
| 743 | 672 | |