| @@ -2,11 +2,12 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace Elementor\Modules\WidgetCreation; |
| 4 | 4 | |
| 5 | 5 | use Elementor\Core\Base\Module as BaseModule; |
| 6 | -use Elementor\Core\Experiments\Manager as ExperimentsManager; | |
| 6 | +use Elementor\Core\Experiments\Manager as Experiments_Manager; | |
| 7 | 7 | use Elementor\Core\Utils\Hints; |
| 8 | 8 | use Elementor\Elements_Manager; |
| 9 | +use Elementor\Modules\AtomicWidgets\Module as Atomic_Widgets_Module; | |
| 9 | 10 | use Elementor\Plugin; |
| 10 | 11 | |
| 11 | 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 12 | 13 | exit; |
| @@ -12,10 +13,11 @@ | ||
| 12 | 13 | exit; |
| 13 | 14 | } |
| 14 | 15 | |
| 15 | 16 | class Module extends BaseModule { |
| 17 | + const EXPERIMENT_NAME = Atomic_Widgets_Module::EXPERIMENT_NAME; | |
| 18 | + const ANGIE_IN_PANELS_EXPERIMENT_NAME = 'e_angie_in_panels'; | |
| 16 | 19 | const MODULE_NAME = 'widget-creation'; |
| 17 | - const EXPERIMENT_NAME = 'e_widget_creation'; | |
| 18 | 20 | |
| 19 | 21 | const PACKAGES = [ |
| 20 | 22 | 'editor-widget-creation', |
| 21 | 23 | ]; |
| @@ -25,21 +27,22 @@ | ||
| 25 | 27 | public function get_name() { |
| 26 | 28 | return self::MODULE_NAME; |
| 27 | 29 | } |
| 28 | 30 | |
| 29 | - public static function get_experimental_data(): array { | |
| 31 | + public static function get_angie_in_panels_experimental_data(): array { | |
| 30 | 32 | return [ |
| 31 | - 'name' => self::EXPERIMENT_NAME, | |
| 32 | - 'title' => esc_html__( 'Widget Creation', 'elementor' ), | |
| 33 | - 'description' => esc_html__( 'Promote widget creation with Angie plugin.', 'elementor' ), | |
| 33 | + 'name' => self::ANGIE_IN_PANELS_EXPERIMENT_NAME, | |
| 34 | + 'title' => esc_html__( 'Angie in editor panels', 'elementor' ), | |
| 35 | + 'description' => esc_html__( 'Load Angie inside the native Elementor editor panel instead of the legacy push sidebar.', 'elementor' ), | |
| 34 | 36 | 'hidden' => true, |
| 35 | - 'default' => ExperimentsManager::STATE_ACTIVE, | |
| 36 | - 'release_status' => ExperimentsManager::RELEASE_STATUS_ALPHA, | |
| 37 | + 'default' => Experiments_Manager::STATE_INACTIVE, | |
| 38 | + 'release_status' => Experiments_Manager::RELEASE_STATUS_DEV, | |
| 37 | 39 | ]; |
| 38 | 40 | } |
| 39 | 41 | |
| 40 | 42 | public function __construct() { |
| 41 | 43 | parent::__construct(); |
| 44 | + $this->register_angie_in_panels_experiment(); | |
| 42 | 45 | AngiePromotion::init(); |
| 43 | 46 | |
| 44 | 47 | add_filter( 'elementor/editor/v2/packages', fn( $packages ) => $this->add_packages( $packages ) ); |
| 45 | 48 | add_action( 'elementor/elements/categories_registered', [ $this, 'maybe_register_custom_widgets_category_fallback' ], 100 ); |
| @@ -45,8 +48,12 @@ | ||
| 45 | 48 | add_action( 'elementor/elements/categories_registered', [ $this, 'maybe_register_custom_widgets_category_fallback' ], 100 ); |
| 46 | 49 | add_action( 'rest_api_init', fn() => $this->register_consent_route() ); |
| 47 | 50 | } |
| 48 | 51 | |
| 52 | + private function register_angie_in_panels_experiment(): void { | |
| 53 | + Plugin::$instance->experiments->add_feature( self::get_angie_in_panels_experimental_data() ); | |
| 54 | + } | |
| 55 | + | |
| 49 | 56 | private function register_consent_route(): void { |
| 50 | 57 | register_rest_route( 'elementor/v1', '/angie/consent', [ |
| 51 | 58 | 'methods' => 'POST', |
| 52 | 59 | 'callback' => fn() => $this->handle_save_consent(), |
| @@ -60,12 +67,8 @@ | ||
| 60 | 67 | return new \WP_REST_Response( [ 'success' => true ], 200 ); |
| 61 | 68 | } |
| 62 | 69 | |
| 63 | 70 | public function maybe_register_custom_widgets_category_fallback( Elements_Manager $elements_manager ): void { |
| 64 | - if ( ! Plugin::$instance->experiments->is_feature_active( self::EXPERIMENT_NAME ) ) { | |
| 65 | - return; | |
| 66 | - } | |
| 67 | - | |
| 68 | 71 | if ( Hints::is_plugin_active( 'angie' ) ) { |
| 69 | 72 | return; |
| 70 | 73 | } |
| 71 | 74 | |
| @@ -89,12 +92,8 @@ | ||
| 89 | 92 | add_action( 'elementor/editor/templates/panel/category/content', [ $this, 'render_custom_widgets_category_empty_state' ] ); |
| 90 | 93 | } |
| 91 | 94 | |
| 92 | 95 | public function render_custom_widgets_category_heading_cta(): void { |
| 93 | - if ( ! Plugin::$instance->experiments->is_feature_active( self::EXPERIMENT_NAME ) ) { | |
| 94 | - return; | |
| 95 | - } | |
| 96 | - | |
| 97 | 96 | if ( ! current_user_can( 'manage_options' ) ) { |
| 98 | 97 | return; |
| 99 | 98 | } |
| 100 | 99 | |
| @@ -105,12 +104,8 @@ | ||
| 105 | 104 | <?php |
| 106 | 105 | } |
| 107 | 106 | |
| 108 | 107 | public function render_custom_widgets_category_empty_state(): void { |
| 109 | - if ( ! Plugin::$instance->experiments->is_feature_active( self::EXPERIMENT_NAME ) ) { | |
| 110 | - return; | |
| 111 | - } | |
| 112 | - | |
| 113 | 108 | if ( $this->custom_widgets_category_has_widgets() ) { |
| 114 | 109 | return; |
| 115 | 110 | } |
| 116 | 111 | |