json', EditorAssetsAPI::ASSETS_DATA_TRANSIENT_KEY => '_elementor_v4_promotions', EditorAssetsAPI::ASSETS_DATA_KEY => 'promotions', ]; } private function is_atomic_widgets_active(): bool { return Plugin::$instance->experiments->is_feature_active( 'e_atomic_elements' ); } private function get_atomic_promotion_configs(): array { return [ [ 'key' => 'attributes', 'label' => __( 'Attributes', 'elementor' ), 'section' => 'settings', 'priority' => 40, ], [ 'key' => 'display-conditions', 'label' => __( 'Display Conditions', 'elementor' ), 'section' => 'settings', 'priority' => 50, ], ]; } private function should_register_core_atomic_panel_promotions(): bool { // Pro with an active license registers real atomic widgets (or its own panel // promotion layer). Core stubs caused duplicate panel entries after ED-25600. return ! Utils::has_pro() || ! Utils::is_license_active(); } private function register_atomic_promotions(): void { if ( ! $this->should_register_core_atomic_panel_promotions() ) { return; } add_action( 'elementor/init', function() { if ( ! $this->is_atomic_widgets_active() ) { return; } add_filter( 'elementor/atomic-widgets/props-schema', [ $this, 'inject_atomic_promotion_props' ] ); foreach ( $this->get_atomic_promotion_configs() as $config ) { add_filter( 'elementor/atomic-widgets/controls', fn( array $controls, $element ) => $this->inject_atomic_promotion_control( $controls, $element, $config ), $config['priority'], 2 ); } } ); ( new Atomic_Form_Widget_Promotion() )->register(); ( new Collection_Loop_Widget_Promotion() )->register(); } public function inject_atomic_promotion_props( array $schema ): array { foreach ( $this->get_atomic_promotion_configs() as $config ) { $key = $config['key']; if ( isset( $schema[ $key ] ) ) { continue; } $schema[ $key ] = Promotion_Prop_Type::make( $key ); } return $schema; } protected function inject_atomic_promotion_control( array $element_controls, $atomic_element, array $config ): array { $key = $config['key']; $schema = $atomic_element::get_props_schema(); if ( ! array_key_exists( $key, $schema ) ) { return $element_controls; } foreach ( $element_controls as $item ) { if ( ! ( $item instanceof \Elementor\Modules\AtomicWidgets\Controls\Section ) ) { continue; } if ( $item->get_id() !== $config['section'] ) { continue; } $control = Atomic_Promotion_Control::make( $key ) ->set_label( $config['label'] ) ->set_meta( [ 'topDivider' => true, ] ); $item->add_item( $control ); break; } return $element_controls; } }