PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.3
Elementor Website Builder – more than just a page builder v4.0.3
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
← All changes | modules/widget-creation/module.php +8 -98 4.3.0-beta34.0.3 View file →
@@ -2,13 +2,9 @@
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;
7 -use Elementor\Core\Utils\Hints;
8 -use Elementor\Elements_Manager;
9 -use Elementor\Modules\AtomicWidgets\Module as Atomic_Widgets_Module;
10 -use Elementor\Plugin;
6 +use Elementor\Core\Experiments\Manager as ExperimentsManager;
11 7
12 8 if ( ! defined( 'ABSPATH' ) ) {
13 9 exit;
14 10 }
@@ -13,120 +9,34 @@
13 9 exit;
14 10 }
15 11
16 12 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 13 const MODULE_NAME = 'widget-creation';
14 + const EXPERIMENT_NAME = 'e_widget_creation';
20 15
21 16 const PACKAGES = [
22 17 'editor-widget-creation',
23 18 ];
24 19
25 - const ANGIE_CONSENT_OPTION = 'angie_external_scripts_consent';
26 -
27 20 public function get_name() {
28 21 return self::MODULE_NAME;
29 22 }
30 23
31 - public static function get_angie_in_panels_experimental_data(): array {
24 + public static function get_experimental_data(): array {
32 25 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' ),
26 + 'name' => self::EXPERIMENT_NAME,
27 + 'title' => esc_html__( 'Widget Creation', 'elementor' ),
28 + 'description' => esc_html__( 'Promote widget creation with Angie plugin.', 'elementor' ),
36 29 'hidden' => true,
37 - 'default' => Experiments_Manager::STATE_INACTIVE,
38 - 'release_status' => Experiments_Manager::RELEASE_STATUS_DEV,
30 + 'default' => ExperimentsManager::STATE_ACTIVE,
31 + 'release_status' => ExperimentsManager::RELEASE_STATUS_ALPHA,
39 32 ];
40 33 }
41 34
42 35 public function __construct() {
43 36 parent::__construct();
44 - $this->register_angie_in_panels_experiment();
45 - AngiePromotion::init();
46 37
47 38 add_filter( 'elementor/editor/v2/packages', fn( $packages ) => $this->add_packages( $packages ) );
48 - add_action( 'elementor/elements/categories_registered', [ $this, 'maybe_register_custom_widgets_category_fallback' ], 100 );
49 - add_action( 'rest_api_init', fn() => $this->register_consent_route() );
50 - }
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 -
56 - private function register_consent_route(): void {
57 - register_rest_route( 'elementor/v1', '/angie/consent', [
58 - 'methods' => 'POST',
59 - 'callback' => fn() => $this->handle_save_consent(),
60 - 'permission_callback' => fn() => current_user_can( 'manage_options' ),
61 - ] );
62 - }
63 -
64 - private function handle_save_consent(): \WP_REST_Response {
65 - update_option( self::ANGIE_CONSENT_OPTION, 'yes' );
66 -
67 - return new \WP_REST_Response( [ 'success' => true ], 200 );
68 - }
69 -
70 - public function maybe_register_custom_widgets_category_fallback( Elements_Manager $elements_manager ): void {
71 - if ( Hints::is_plugin_active( 'angie' ) ) {
72 - return;
73 - }
74 -
75 - $categories = $elements_manager->get_categories();
76 -
77 - if ( isset( $categories[ Elements_Manager::CATEGORY_CUSTOM_WIDGETS ] ) ) {
78 - return;
79 - }
80 -
81 - $elements_manager->add_category(
82 - Elements_Manager::CATEGORY_CUSTOM_WIDGETS,
83 - [
84 - 'title' => esc_html__( 'Custom Widget', 'elementor' ),
85 - 'icon' => 'eicon-ai',
86 - 'hideIfEmpty' => false,
87 - 'active' => true,
88 - ]
89 - );
90 -
91 - add_action( 'elementor/editor/templates/panel/category', [ $this, 'render_custom_widgets_category_heading_cta' ] );
92 - add_action( 'elementor/editor/templates/panel/category/content', [ $this, 'render_custom_widgets_category_empty_state' ] );
93 - }
94 -
95 - public function render_custom_widgets_category_heading_cta(): void {
96 - if ( ! current_user_can( 'manage_options' ) ) {
97 - return;
98 - }
99 -
100 - ?>
101 - <# if ( 'custom-widgets' === name ) { #>
102 - <button type="button" class="elementor-panel-custom-widgets__cta elementor-panel-custom-widgets__cta--heading"><?php echo esc_html__( 'Try for free', 'elementor' ); ?></button>
103 - <# } #>
104 - <?php
105 - }
106 -
107 - public function render_custom_widgets_category_empty_state(): void {
108 - if ( $this->custom_widgets_category_has_widgets() ) {
109 - return;
110 - }
111 -
112 - ?>
113 - <# if ( 'custom-widgets' === name ) { #>
114 - <div class="elementor-panel-category-custom-widgets-empty">
115 - <p class="elementor-panel-category-custom-widgets-empty__message"><?php echo esc_html__( 'Create custom widgets by describing what you need.', 'elementor' ); ?></p>
116 - </div>
117 - <# } #>
118 - <?php
119 - }
120 -
121 - private function custom_widgets_category_has_widgets(): bool {
122 - foreach ( Plugin::$instance->widgets_manager->get_widget_types() as $widget ) {
123 - if ( in_array( Elements_Manager::CATEGORY_CUSTOM_WIDGETS, $widget->get_categories(), true ) ) {
124 - return true;
125 - }
126 - }
127 -
128 - return false;
129 39 }
130 40
131 41 private function add_packages( array $packages ): array {
132 42 return array_merge( $packages, self::PACKAGES );