PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.5
Elementor Website Builder – more than just a page builder v4.0.5
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 4.0.7 All 451 releases
← All changes | modules/widget-creation/module.php +0 -90 4.0.84.0.5 View file →
@@ -3,11 +3,8 @@
3 3 namespace Elementor\Modules\WidgetCreation;
4 4
5 5 use Elementor\Core\Base\Module as BaseModule;
6 6 use Elementor\Core\Experiments\Manager as ExperimentsManager;
7 -use Elementor\Core\Utils\Hints;
8 -use Elementor\Elements_Manager;
9 -use Elementor\Plugin;
10 7
11 8 if ( ! defined( 'ABSPATH' ) ) {
12 9 exit;
13 10 }
@@ -19,10 +16,8 @@
19 16 const PACKAGES = [
20 17 'editor-widget-creation',
21 18 ];
22 19
23 - const ANGIE_CONSENT_OPTION = 'angie_external_scripts_consent';
24 -
25 20 public function get_name() {
26 21 return self::MODULE_NAME;
27 22 }
28 23
@@ -40,93 +35,8 @@
40 35 public function __construct() {
41 36 parent::__construct();
42 37
43 38 add_filter( 'elementor/editor/v2/packages', fn( $packages ) => $this->add_packages( $packages ) );
44 - add_action( 'elementor/elements/categories_registered', [ $this, 'maybe_register_custom_widgets_category_fallback' ], 100 );
45 - add_action( 'rest_api_init', fn() => $this->register_consent_route() );
46 - }
47 -
48 - private function register_consent_route(): void {
49 - register_rest_route( 'elementor/v1', '/angie/consent', [
50 - 'methods' => 'POST',
51 - 'callback' => fn() => $this->handle_save_consent(),
52 - 'permission_callback' => fn() => current_user_can( 'manage_options' ),
53 - ] );
54 - }
55 -
56 - private function handle_save_consent(): \WP_REST_Response {
57 - update_option( self::ANGIE_CONSENT_OPTION, 'yes' );
58 -
59 - return new \WP_REST_Response( [ 'success' => true ], 200 );
60 - }
61 -
62 - public function maybe_register_custom_widgets_category_fallback( Elements_Manager $elements_manager ): void {
63 - if ( ! Plugin::$instance->experiments->is_feature_active( self::EXPERIMENT_NAME ) ) {
64 - return;
65 - }
66 -
67 - if ( Hints::is_plugin_active( 'angie' ) ) {
68 - return;
69 - }
70 -
71 - $categories = $elements_manager->get_categories();
72 -
73 - if ( isset( $categories[ Elements_Manager::CATEGORY_CUSTOM_WIDGETS ] ) ) {
74 - return;
75 - }
76 -
77 - $elements_manager->add_category(
78 - Elements_Manager::CATEGORY_CUSTOM_WIDGETS,
79 - [
80 - 'title' => esc_html__( 'Custom Widget', 'elementor' ),
81 - 'icon' => 'eicon-ai',
82 - 'hideIfEmpty' => false,
83 - 'active' => true,
84 - ]
85 - );
86 -
87 - add_action( 'elementor/editor/templates/panel/category', [ $this, 'render_custom_widgets_category_heading_cta' ] );
88 - add_action( 'elementor/editor/templates/panel/category/content', [ $this, 'render_custom_widgets_category_empty_state' ] );
89 - }
90 -
91 - public function render_custom_widgets_category_heading_cta(): void {
92 - if ( ! Plugin::$instance->experiments->is_feature_active( self::EXPERIMENT_NAME ) ) {
93 - return;
94 - }
95 -
96 - ?>
97 - <# if ( 'custom-widgets' === name ) { #>
98 - <button type="button" class="elementor-panel-custom-widgets__cta elementor-panel-custom-widgets__cta--heading"><?php echo esc_html__( 'Try for free', 'elementor' ); ?></button>
99 - <# } #>
100 - <?php
101 - }
102 -
103 - public function render_custom_widgets_category_empty_state(): void {
104 - if ( ! Plugin::$instance->experiments->is_feature_active( self::EXPERIMENT_NAME ) ) {
105 - return;
106 - }
107 -
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 );