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