| @@ -5,8 +5,9 @@ | ||
| 5 | 5 | use Elementor\Core\Common\Modules\Ajax\Module; |
| 6 | 6 | use Elementor\Core\Debug\Loading_Inspection_Manager; |
| 7 | 7 | use Elementor\Core\Editor\Loader\Editor_Loader_Factory; |
| 8 | 8 | use Elementor\Core\Editor\Loader\Editor_Loader_Interface; |
| 9 | +use Elementor\Core\Experiments\Manager as Experiments_Manager; | |
| 9 | 10 | use Elementor\Core\Settings\Manager as SettingsManager; |
| 10 | 11 | use Elementor\Plugin; |
| 11 | 12 | use Elementor\TemplateLibrary\Source_Local; |
| 12 | 13 | use Elementor\Utils; |
| @@ -30,8 +31,10 @@ | ||
| 30 | 31 | * User capability required to access Elementor editor. |
| 31 | 32 | */ |
| 32 | 33 | const EDITING_CAPABILITY = 'edit_posts'; |
| 33 | 34 | |
| 35 | + const EDITOR_V2_EXPERIMENT_NAME = 'editor_v2'; | |
| 36 | + | |
| 34 | 37 | /** |
| 35 | 38 | * Post ID. |
| 36 | 39 | * |
| 37 | 40 | * Holds the ID of the current post being edited. |
| @@ -80,11 +83,11 @@ | ||
| 80 | 83 | * |
| 81 | 84 | * @since 1.0.0 |
| 82 | 85 | * @access public |
| 83 | 86 | * |
| 84 | - * @param bool $to_die Optional. Whether to die at the end. Default is `true`. | |
| 87 | + * @param bool $die Optional. Whether to die at the end. Default is `true`. | |
| 85 | 88 | */ |
| 86 | - public function init( $to_die = true ) { | |
| 89 | + public function init( $die = true ) { | |
| 87 | 90 | if ( empty( $_REQUEST['post'] ) ) { |
| 88 | 91 | return; |
| 89 | 92 | } |
| 90 | 93 | |
| @@ -159,9 +162,9 @@ | ||
| 159 | 162 | |
| 160 | 163 | $this->get_loader()->print_root_template(); |
| 161 | 164 | |
| 162 | 165 | // From the action it's an empty string, from tests its `false` |
| 163 | - if ( false !== $to_die ) { | |
| 166 | + if ( false !== $die ) { | |
| 164 | 167 | die; |
| 165 | 168 | } |
| 166 | 169 | } |
| 167 | 170 | |
| @@ -534,34 +537,16 @@ | ||
| 534 | 537 | |
| 535 | 538 | add_action( 'admin_action_elementor', [ $this, 'init' ] ); |
| 536 | 539 | add_action( 'template_redirect', [ $this, 'redirect_to_new_url' ] ); |
| 537 | 540 | |
| 541 | + $this->register_editor_v2_experiment(); | |
| 542 | + | |
| 538 | 543 | // Handle autocomplete feature for URL control. |
| 539 | 544 | add_filter( 'wp_link_query_args', [ $this, 'filter_wp_link_query_args' ] ); |
| 540 | 545 | add_filter( 'wp_link_query', [ $this, 'filter_wp_link_query' ] ); |
| 541 | - | |
| 542 | - add_filter( 'replace_editor', [ $this, 'filter_replace_editor' ], 10, 2 ); | |
| 543 | 546 | } |
| 544 | 547 | |
| 545 | 548 | /** |
| 546 | - * Signals to WordPress that Elementor is replacing the block editor on its own editor page, | |
| 547 | - * so that block-editor-specific behaviour (e.g. WP 7.0 COOP/COEP isolation headers) is not | |
| 548 | - * applied when the Elementor editor is active. | |
| 549 | - * | |
| 550 | - * @param bool $replace Whether the editor is being replaced. | |
| 551 | - * @param \WP_Post $post The post being edited. | |
| 552 | - * | |
| 553 | - * @return bool | |
| 554 | - */ | |
| 555 | - public function filter_replace_editor( $replace, $post ) { | |
| 556 | - if ( isset( $_REQUEST['action'] ) && 'elementor' === $_REQUEST['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 557 | - return true; | |
| 558 | - } | |
| 559 | - | |
| 560 | - return $replace; | |
| 561 | - } | |
| 562 | - | |
| 563 | - /** | |
| 564 | 549 | * @since 2.2.0 |
| 565 | 550 | * @access public |
| 566 | 551 | */ |
| 567 | 552 | public function filter_wp_link_query_args( $query ) { |
| @@ -610,8 +595,30 @@ | ||
| 610 | 595 | $this->loader->init(); |
| 611 | 596 | } |
| 612 | 597 | |
| 613 | 598 | return $this->loader; |
| 599 | + } | |
| 600 | + | |
| 601 | + /** | |
| 602 | + * Adding Editor V2 experiment. | |
| 603 | + * | |
| 604 | + * @return void | |
| 605 | + * @throws \Exception | |
| 606 | + */ | |
| 607 | + private function register_editor_v2_experiment() { | |
| 608 | + Plugin::$instance->experiments->add_feature( [ | |
| 609 | + 'name' => static::EDITOR_V2_EXPERIMENT_NAME, | |
| 610 | + 'title' => esc_html__( 'Editor Top Bar', 'elementor' ), | |
| 611 | + 'description' => sprintf( | |
| 612 | + esc_html__( | |
| 613 | + 'Get a sneak peek of the new Editor powered by React. The beautiful design and experimental layout of the Top bar are just some of the exciting tools on their way. %s', | |
| 614 | + 'elementor' | |
| 615 | + ), | |
| 616 | + '<a href="https://go.elementor.com/wp-dash-elementor-top-bar/" target="_blank">' . esc_html__( 'Learn more', 'elementor' ) . '</a>' | |
| 617 | + ), | |
| 618 | + 'default' => Experiments_Manager::STATE_INACTIVE, | |
| 619 | + 'status' => Experiments_Manager::RELEASE_STATUS_ALPHA, | |
| 620 | + ] ); | |
| 614 | 621 | } |
| 615 | 622 | |
| 616 | 623 | /** |
| 617 | 624 | * Get elements presets. |