* with the rest of the page CSS, and no free-text CSS reaches the page. * * @package AdMoreWidgetsSuite * @since 1.0.0 */ if ( ! defined( 'ABSPATH' ) ) exit; class EPPRO_Extension_Custom_CSS { /** Allowed length units for spacing/sizing controls. */ private const LENGTH_UNITS = [ 'px', 'em', 'rem', '%', 'vh', 'vw' ]; public static function init(): void { // Inject controls into every element's Advanced tab. add_action( 'elementor/element/after_section_end', [ __CLASS__, 'add_controls' ], 10, 3 ); } // ========================================================================= // Register Controls // ========================================================================= public static function add_controls( \Elementor\Controls_Stack $element, string $section_id, array $args ): void { // Only add once — attach after the "_section_responsive" section in Advanced tab. if ( '_section_responsive' !== $section_id ) return; $element->start_controls_section( 'eppro_custom_css_section', [ 'label' => EPPRO_Elementor_Helper::panel_label( __( 'Custom Styles', 'admore-widgets-suite' ) ), 'tab' => \Elementor\Controls_Manager::TAB_ADVANCED, ] ); $element->add_control( 'eppro_cc_notice', [ 'type' => \Elementor\Controls_Manager::RAW_HTML, 'raw' => esc_html__( 'Apply common style overrides to this element. These are scoped to this element only.', 'admore-widgets-suite' ), 'content_classes' => 'elementor-descriptor', ] ); // --- Colors ----------------------------------------------------------- $element->add_control( 'eppro_cc_bg_color', [ 'label' => __( 'Background Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}}' => 'background-color: {{VALUE}};' ], ] ); $element->add_control( 'eppro_cc_text_color', [ 'label' => __( 'Text Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}}' => 'color: {{VALUE}};' ], ] ); // --- Spacing ---------------------------------------------------------- $element->add_control( 'eppro_cc_padding', [ 'label' => __( 'Padding', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => self::LENGTH_UNITS, 'selectors' => [ '{{WRAPPER}}' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ], ] ); $element->add_control( 'eppro_cc_margin', [ 'label' => __( 'Margin', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => self::LENGTH_UNITS, 'selectors' => [ '{{WRAPPER}}' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ], ] ); // --- Border ----------------------------------------------------------- $element->add_control( 'eppro_cc_border_width', [ 'label' => __( 'Border Width', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', 'rem' ], 'selectors' => [ '{{WRAPPER}}' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}; border-style: solid;' ], ] ); $element->add_control( 'eppro_cc_border_color', [ 'label' => __( 'Border Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}}' => 'border-color: {{VALUE}};' ], ] ); $element->add_control( 'eppro_cc_border_radius', [ 'label' => __( 'Border Radius', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', 'rem', '%' ], 'selectors' => [ '{{WRAPPER}}' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ], ] ); // --- Sizing / misc ---------------------------------------------------- $element->add_control( 'eppro_cc_min_height', [ 'label' => __( 'Min Height', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => [ 'px', 'vh', '%' ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 1000 ], 'vh' => [ 'min' => 0, 'max' => 100 ], '%' => [ 'min' => 0, 'max' => 100 ], ], 'selectors' => [ '{{WRAPPER}}' => 'min-height: {{SIZE}}{{UNIT}};' ], ] ); $element->add_control( 'eppro_cc_opacity', [ 'label' => __( 'Opacity', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 0, 'max' => 1, 'step' => 0.01 ], ], 'selectors' => [ '{{WRAPPER}}' => 'opacity: {{SIZE}};' ], ] ); $element->add_control( 'eppro_cc_z_index', [ 'label' => __( 'Z-Index', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::NUMBER, 'min' => -999, 'max' => 9999, 'step' => 1, 'selectors' => [ '{{WRAPPER}}' => 'z-index: {{VALUE}};' ], ] ); $element->end_controls_section(); } }