__( 'Center (Modal)', 'admore-widgets-suite' ), 'top_bar' => __( 'Top Bar', 'admore-widgets-suite' ), 'bottom_bar' => __( 'Bottom Bar', 'admore-widgets-suite' ), 'slide_right' => __( 'Slide-in Bottom Right', 'admore-widgets-suite' ), 'slide_left' => __( 'Slide-in Bottom Left', 'admore-widgets-suite' ), 'side_right' => __( 'Side Panel Right', 'admore-widgets-suite' ), 'side_left' => __( 'Side Panel Left', 'admore-widgets-suite' ), 'full_screen' => __( 'Full Screen', 'admore-widgets-suite' ), ]; } public static function animations(): array { return [ 'fade' => __( 'Fade', 'admore-widgets-suite' ), 'zoom' => __( 'Zoom In', 'admore-widgets-suite' ), 'slide_up' => __( 'Slide Up', 'admore-widgets-suite' ), 'slide_down' => __( 'Slide Down', 'admore-widgets-suite' ), 'slide_left' => __( 'Slide Left', 'admore-widgets-suite' ), 'slide_right' => __( 'Slide Right', 'admore-widgets-suite' ), 'bounce' => __( 'Bounce', 'admore-widgets-suite' ), 'flip' => __( 'Flip', 'admore-widgets-suite' ), 'newspaper' => __( 'Newspaper', 'admore-widgets-suite' ), 'none' => __( 'None', 'admore-widgets-suite' ), ]; } public static function close_positions(): array { return [ 'top_right' => __( 'Inside — Top Right', 'admore-widgets-suite' ), 'top_left' => __( 'Inside — Top Left', 'admore-widgets-suite' ), 'bottom_right' => __( 'Inside — Bottom Right', 'admore-widgets-suite' ), 'bottom_left' => __( 'Inside — Bottom Left', 'admore-widgets-suite' ), 'outside_top_right' => __( 'Outside — Top Right', 'admore-widgets-suite' ), 'outside_top_left' => __( 'Outside — Top Left', 'admore-widgets-suite' ), ]; } /** CSS for each close-button position (offset and size come from CSS variables). */ private static function close_position_css(): array { $o = 'var(--eppro-popup-close-offset, 12px)'; $out = 'calc((var(--eppro-popup-close-size, 32px) + var(--eppro-popup-close-offset, 12px)) * -1)'; return [ 'top_right' => "top: {$o}; right: {$o}; bottom: auto; left: auto;", 'top_left' => "top: {$o}; left: {$o}; bottom: auto; right: auto;", 'bottom_right' => "bottom: {$o}; right: {$o}; top: auto; left: auto;", 'bottom_left' => "bottom: {$o}; left: {$o}; top: auto; right: auto;", 'outside_top_right' => "top: {$out}; right: 0; bottom: auto; left: auto;", 'outside_top_left' => "top: {$out}; left: 0; bottom: auto; right: auto;", ]; } // ========================================================================= // Settings // ========================================================================= public static function is_popup_document( $document ): bool { if ( ! is_object( $document ) || ! method_exists( $document, 'get_main_post' ) ) { return false; } $post = $document->get_main_post(); return $post instanceof \WP_Post && EPPRO_Popup_CPT::POST_TYPE === $post->post_type; } private static function key( string $name ): string { return self::PREFIX . $name; } private static function pick( string $value, array $allowed, string $fallback ): string { $value = sanitize_key( str_replace( '-', '_', $value ) ); return array_key_exists( $value, $allowed ) ? $value : $fallback; } private static function dimensions( $value, string $unit = 'px' ): array { $value = (string) absint( $value ); return [ 'top' => $value, 'right' => $value, 'bottom' => $value, 'left' => $value, 'unit' => $unit, 'isLinked' => true ]; } private static function hex_to_rgba( string $hex, int $opacity ): string { $hex = ltrim( (string) sanitize_hex_color( $hex ), '#' ); if ( 3 === strlen( $hex ) ) { $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; } if ( 6 !== strlen( $hex ) ) { return 'rgba(0,0,0,0.55)'; } return sprintf( 'rgba(%d,%d,%d,%s)', hexdec( substr( $hex, 0, 2 ) ), hexdec( substr( $hex, 2, 2 ) ), hexdec( substr( $hex, 4, 2 ) ), round( min( 100, $opacity ) / 100, 2 ) ); } /** * Control defaults. Taken from the pre-1.0.5 "_eppro_popup" meta so popups * created before the Page Settings existed keep exactly the same look. */ public static function defaults( int $post_id ): array { $m = EPPRO_Popup_Settings::get( $post_id ); $width = absint( $m['popup_width'] ?? $m['max_width'] ?? 600 ) ?: 600; $width_unit = (string) ( $m['popup_width_unit'] ?? 'px' ); $width_unit = in_array( $width_unit, [ 'px', '%', 'vw' ], true ) ? $width_unit : 'px'; $height = ! empty( $m['popup_height'] ) ? absint( $m['popup_height'] ) : 0; $h_unit = (string) ( $m['popup_height_unit'] ?? 'px' ); $h_unit = in_array( $h_unit, [ 'px', 'vh' ], true ) ? $h_unit : 'px'; $position = self::pick( (string) ( $m['position'] ?? 'center' ), self::positions(), 'center' ); // Shadow: the old presets, as Box Shadow values (slide-ins had their own shadow). $presets = [ 'none' => null, 'sm' => [ 'horizontal' => 0, 'vertical' => 4, 'blur' => 12, 'spread' => 0, 'color' => 'rgba(0,0,0,0.1)' ], 'md' => [ 'horizontal' => 0, 'vertical' => 10, 'blur' => 30, 'spread' => 0, 'color' => 'rgba(0,0,0,0.18)' ], 'lg' => [ 'horizontal' => 0, 'vertical' => 20, 'blur' => 60, 'spread' => 0, 'color' => 'rgba(0,0,0,0.25)' ], 'xl' => [ 'horizontal' => 0, 'vertical' => 25, 'blur' => 80, 'spread' => 0, 'color' => 'rgba(0,0,0,0.35)' ], ]; $preset = (string) ( $m['shadow_preset'] ?? 'lg' ); $shadow = array_key_exists( $preset, $presets ) ? $presets[ $preset ] : $presets['lg']; if ( in_array( $position, [ 'slide_right', 'slide_left' ], true ) && 'none' !== $preset ) { $shadow = [ 'horizontal' => 0, 'vertical' => 8, 'blur' => 40, 'spread' => 0, 'color' => 'rgba(0,0,0,0.2)' ]; } $shape = (string) ( $m['close_btn_shape'] ?? 'circle' ); $close_radius = 'rounded' === $shape ? [ 'size' => 6, 'unit' => 'px' ] : ( 'square' === $shape ? [ 'size' => 0, 'unit' => 'px' ] : [ 'size' => 50, 'unit' => '%' ] ); return [ 'width' => [ 'size' => $width, 'unit' => $width_unit ], 'height_type' => $height ? 'custom' : 'auto', 'height' => [ 'size' => $height ?: 400, 'unit' => $h_unit ], 'position' => $position, 'padding' => self::dimensions( $m['content_padding'] ?? 0 ), 'animation' => self::pick( (string) ( $m['animation'] ?? 'fade' ), self::animations(), 'fade' ), 'anim_speed' => min( 2000, max( 100, absint( $m['anim_speed'] ?? 300 ) ) ), 'close_overlay' => ! empty( $m['close_overlay'] ) ? 'yes' : '', 'close_esc' => ( ! isset( $m['close_esc'] ) || $m['close_esc'] ) ? 'yes' : '', 'hide_close_for' => absint( $m['hide_close_for'] ?? 0 ), 'auto_close_after' => absint( $m['auto_close_after'] ?? 0 ), 'scroll_lock' => ( ! array_key_exists( 'body_scroll_lock', $m ) || $m['body_scroll_lock'] ) ? 'yes' : '', 'redirect_on_close' => esc_url_raw( (string) ( $m['redirect_on_close'] ?? '' ) ), 'z_index' => absint( $m['z_index'] ?? 999999 ) ?: 999999, 'bg_color' => sanitize_hex_color( (string) ( $m['container_bg'] ?? '' ) ) ?: '#ffffff', 'radius' => self::dimensions( $m['border_radius'] ?? 8 ), 'border_width' => min( 10, absint( $m['border_width'] ?? 0 ) ), 'border_color' => sanitize_hex_color( (string) ( $m['border_color'] ?? '' ) ) ?: '#e2e8f0', 'shadow' => $shadow, 'overlay_color' => self::hex_to_rgba( (string) ( $m['overlay_color'] ?? '#000000' ), absint( $m['overlay_opacity'] ?? 55 ) ), 'overlay_blur' => min( 20, absint( $m['overlay_blur'] ?? 0 ) ), 'close_button' => ( ! array_key_exists( 'show_close_btn', $m ) || $m['show_close_btn'] ) ? 'show' : 'hide', 'close_position' => self::pick( (string) ( $m['close_position'] ?? 'top_right' ), self::close_positions(), 'top_right' ), 'close_size' => min( 80, max( 20, absint( $m['close_btn_size'] ?? 32 ) ) ), 'close_color' => sanitize_hex_color( (string) ( $m['close_btn_color'] ?? '' ) ) ?: '#374151', 'close_bg' => sanitize_hex_color( (string) ( $m['close_btn_bg'] ?? '' ) ) ?: '#f3f4f6', 'close_radius' => $close_radius, ]; } /** * Effective settings the renderer needs (classes and script config): the * saved page settings, falling back to the defaults above. */ public static function get( int $post_id ): array { $d = self::defaults( $post_id ); $saved = get_post_meta( $post_id, '_elementor_page_settings', true ); $saved = is_array( $saved ) ? $saved : []; $value = static function ( string $name ) use ( $d, $saved ) { $key = self::PREFIX . $name; return array_key_exists( $key, $saved ) ? $saved[ $key ] : $d[ $name ]; }; return [ 'position' => self::pick( (string) $value( 'position' ), self::positions(), 'center' ), 'animation' => self::pick( (string) $value( 'animation' ), self::animations(), 'fade' ), 'anim_speed' => min( 2000, max( 100, absint( $value( 'anim_speed' ) ) ) ), 'close_overlay' => 'yes' === $value( 'close_overlay' ), 'close_esc' => 'yes' === $value( 'close_esc' ), 'hide_close_for' => absint( $value( 'hide_close_for' ) ), 'auto_close_after' => absint( $value( 'auto_close_after' ) ), 'scroll_lock' => 'yes' === $value( 'scroll_lock' ), 'redirect_on_close' => esc_url_raw( (string) $value( 'redirect_on_close' ) ), 'close_button' => 'hide' === $value( 'close_button' ) ? 'hide' : 'show', 'close_position' => self::pick( (string) $value( 'close_position' ), self::close_positions(), 'top_right' ), ]; } // ========================================================================= // Elementor page settings // ========================================================================= public static function register_controls( $document ): void { if ( ! self::is_popup_document( $document ) ) { return; } $id = (int) $document->get_main_id(); $d = self::defaults( $id ); $sel = '#eppro-popup-' . $id; $box = $sel . ' .eppro-popup-container'; $btn = $sel . ' .eppro-popup-close'; // Page-only options that mean nothing for a popup. foreach ( [ 'template', 'hide_title' ] as $control ) { if ( $document->get_controls( $control ) ) { $document->remove_control( $control ); } } // ── Settings tab: Layout ───────────────────────────────────────────── $document->start_controls_section( self::key( 'section_layout' ), [ 'label' => EPPRO_Elementor_Helper::panel_label( __( 'Popup Layout', 'admore-widgets-suite' ) ), 'tab' => \Elementor\Controls_Manager::TAB_SETTINGS, ] ); $document->add_control( self::key( 'notice' ), [ 'type' => \Elementor\Controls_Manager::RAW_HTML, 'raw' => sprintf( /* translators: %s: link to the Popup Builder admin page */ esc_html__( 'Triggers, display conditions and the Active switch are in %s.', 'admore-widgets-suite' ), '' . esc_html__( 'Popup Builder → Quick Settings', 'admore-widgets-suite' ) . '' ), 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info', ] ); $document->add_responsive_control( self::key( 'width' ), [ 'label' => __( 'Width', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => [ 'px', '%', 'vw' ], 'range' => [ 'px' => [ 'min' => 200, 'max' => 1600, 'step' => 10 ], '%' => [ 'min' => 10, 'max' => 100 ], 'vw' => [ 'min' => 10, 'max' => 100 ], ], 'default' => $d['width'], 'selectors' => [ $sel => '--eppro-popup-max-w: {{SIZE}}{{UNIT}}; --eppro-popup-side-w: {{SIZE}}{{UNIT}};' ], 'description' => __( 'Top Bar, Bottom Bar and Full Screen always use the full width.', 'admore-widgets-suite' ), ] ); $document->add_control( self::key( 'height_type' ), [ 'label' => __( 'Height', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => $d['height_type'], 'options' => [ 'auto' => __( 'Fit to Content', 'admore-widgets-suite' ), 'custom' => __( 'Custom', 'admore-widgets-suite' ), ], ] ); $document->add_responsive_control( self::key( 'height' ), [ 'label' => __( 'Custom Height', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => [ 'px', 'vh' ], 'range' => [ 'px' => [ 'min' => 100, 'max' => 1200, 'step' => 10 ], 'vh' => [ 'min' => 10, 'max' => 100 ], ], 'default' => $d['height'], 'selectors' => [ $sel => '--eppro-popup-height: {{SIZE}}{{UNIT}};' ], 'condition' => [ self::key( 'height_type' ) => 'custom' ], 'description' => __( 'Longer content scrolls inside the popup.', 'admore-widgets-suite' ), ] ); $document->add_control( self::key( 'position' ), [ 'label' => __( 'Position', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => $d['position'], 'options' => self::positions(), 'separator' => 'before', ] ); $document->add_responsive_control( self::key( 'padding' ), [ 'label' => __( 'Content Padding', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%' ], 'default' => $d['padding'], 'selectors' => [ $sel => '--eppro-popup-padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ], ] ); $document->end_controls_section(); // ── Settings tab: Behaviour ────────────────────────────────────────── $document->start_controls_section( self::key( 'section_behaviour' ), [ 'label' => EPPRO_Elementor_Helper::panel_label( __( 'Popup Behaviour', 'admore-widgets-suite' ) ), 'tab' => \Elementor\Controls_Manager::TAB_SETTINGS, ] ); $document->add_control( self::key( 'animation' ), [ 'label' => __( 'Entrance Animation', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => $d['animation'], 'options' => self::animations(), ] ); $document->add_control( self::key( 'anim_speed' ), [ 'label' => __( 'Animation Speed (ms)', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::NUMBER, 'min' => 100, 'max' => 2000, 'step' => 50, 'default' => $d['anim_speed'], 'selectors' => [ $sel => '--eppro-popup-anim-speed: {{VALUE}}ms; --eppro-popup-overlay-speed: {{VALUE}}ms;' ], ] ); $document->add_control( self::key( 'close_overlay' ), [ 'label' => __( 'Close on Overlay Click', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => $d['close_overlay'], 'separator' => 'before', ] ); $document->add_control( self::key( 'close_esc' ), [ 'label' => __( 'Close on ESC Key', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => $d['close_esc'], ] ); $document->add_control( self::key( 'hide_close_for' ), [ 'label' => __( 'Show Close Button After (seconds)', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::NUMBER, 'min' => 0, 'max' => 120, 'default' => $d['hide_close_for'], 'description' => __( '0 = right away. Counted from when the popup opens.', 'admore-widgets-suite' ), ] ); $document->add_control( self::key( 'auto_close_after' ), [ 'label' => __( 'Auto Close After (seconds)', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::NUMBER, 'min' => 0, 'max' => 600, 'default' => $d['auto_close_after'], 'description' => __( '0 = never.', 'admore-widgets-suite' ), ] ); $document->add_control( self::key( 'scroll_lock' ), [ 'label' => __( 'Prevent Page Scrolling', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => $d['scroll_lock'], ] ); $document->add_control( self::key( 'redirect_on_close' ), [ 'label' => __( 'Redirect on Close (URL)', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'input_type' => 'url', 'default' => $d['redirect_on_close'], 'placeholder' => 'https://', 'label_block' => true, ] ); $document->add_control( self::key( 'z_index' ), [ 'label' => __( 'Z-Index', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::NUMBER, 'min' => 1, 'default' => $d['z_index'], 'selectors' => [ $sel => '--eppro-popup-z: {{VALUE}};' ], ] ); $document->end_controls_section(); // ── Style tab: Popup box ───────────────────────────────────────────── $document->start_controls_section( self::key( 'section_box' ), [ 'label' => EPPRO_Elementor_Helper::panel_label( __( 'Popup Box', 'admore-widgets-suite' ) ), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $document->add_group_control( \Elementor\Group_Control_Background::get_type(), [ 'name' => self::key( 'bg' ), 'types' => [ 'classic', 'gradient' ], 'selector' => $box, 'fields_options' => [ 'background' => [ 'default' => 'classic' ], 'color' => [ 'default' => $d['bg_color'] ], ], ] ); $document->add_responsive_control( self::key( 'radius' ), [ 'label' => __( 'Border Radius', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%' ], 'default' => $d['radius'], 'selectors' => [ $sel => '--eppro-popup-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ], ] ); $border_defaults = []; if ( $d['border_width'] > 0 ) { $border_defaults = [ 'border' => [ 'default' => 'solid' ], 'width' => [ 'default' => self::dimensions( $d['border_width'] ) ], 'color' => [ 'default' => $d['border_color'] ], ]; } $document->add_group_control( \Elementor\Group_Control_Border::get_type(), [ 'name' => self::key( 'border' ), 'selector' => $box, 'fields_options' => $border_defaults, ] ); $document->add_group_control( \Elementor\Group_Control_Box_Shadow::get_type(), [ 'name' => self::key( 'shadow' ), 'selector' => $box, 'fields_options' => $d['shadow'] ? [ 'box_shadow_type' => [ 'default' => 'yes' ], 'box_shadow' => [ 'default' => $d['shadow'] ], ] : [], ] ); $document->end_controls_section(); // ── Style tab: Overlay ─────────────────────────────────────────────── $document->start_controls_section( self::key( 'section_overlay' ), [ 'label' => EPPRO_Elementor_Helper::panel_label( __( 'Overlay', 'admore-widgets-suite' ) ), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $document->add_control( self::key( 'overlay_color' ), [ 'label' => __( 'Overlay Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => $d['overlay_color'], 'selectors' => [ $sel => '--eppro-popup-overlay-bg: {{VALUE}};' ], 'description' => __( 'Slide-in positions have no overlay.', 'admore-widgets-suite' ), ] ); $document->add_control( self::key( 'overlay_blur' ), [ 'label' => __( 'Background Blur', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 20 ] ], 'default' => [ 'size' => $d['overlay_blur'], 'unit' => 'px' ], 'selectors' => [ $sel => '--eppro-popup-overlay-blur: {{SIZE}}{{UNIT}};' ], ] ); $document->end_controls_section(); // ── Style tab: Close button ────────────────────────────────────────── $document->start_controls_section( self::key( 'section_close' ), [ 'label' => EPPRO_Elementor_Helper::panel_label( __( 'Close Button', 'admore-widgets-suite' ) ), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $show_close = [ self::key( 'close_button' ) => 'show' ]; $document->add_control( self::key( 'close_button' ), [ 'label' => __( 'Close Button', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => $d['close_button'], 'options' => [ 'show' => __( 'Show', 'admore-widgets-suite' ), 'hide' => __( 'Hide', 'admore-widgets-suite' ), ], 'selectors_dictionary' => [ 'show' => 'flex', 'hide' => 'none' ], 'selectors' => [ $btn => 'display: {{VALUE}};' ], ] ); $document->add_control( self::key( 'close_position' ), [ 'label' => __( 'Position', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => $d['close_position'], 'options' => self::close_positions(), 'selectors_dictionary' => self::close_position_css(), 'selectors' => [ $btn => '{{VALUE}}' ], 'condition' => $show_close, ] ); $document->add_control( self::key( 'close_offset' ), [ 'label' => __( 'Distance from Edge', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 60 ] ], 'default' => [ 'size' => 12, 'unit' => 'px' ], 'selectors' => [ $sel => '--eppro-popup-close-offset: {{SIZE}}{{UNIT}};' ], 'condition' => $show_close, ] ); $document->add_control( self::key( 'close_size' ), [ 'label' => __( 'Button Size', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'range' => [ 'px' => [ 'min' => 20, 'max' => 80 ] ], 'default' => [ 'size' => $d['close_size'], 'unit' => 'px' ], 'selectors' => [ $sel => '--eppro-popup-close-size: {{SIZE}}{{UNIT}};' ], 'condition' => $show_close, ] ); $document->add_control( self::key( 'close_icon_size' ), [ 'label' => __( 'Icon Size', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'range' => [ 'px' => [ 'min' => 8, 'max' => 40 ] ], 'default' => [ 'size' => 16, 'unit' => 'px' ], 'selectors' => [ $sel => '--eppro-popup-close-icon: {{SIZE}}{{UNIT}};' ], 'condition' => $show_close, ] ); $document->add_control( self::key( 'close_radius' ), [ 'label' => __( 'Border Radius', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => [ 'px', '%' ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 40 ], '%' => [ 'min' => 0, 'max' => 50 ] ], 'default' => $d['close_radius'], 'selectors' => [ $sel => '--eppro-popup-close-radius: {{SIZE}}{{UNIT}};' ], 'condition' => $show_close, ] ); $document->start_controls_tabs( self::key( 'close_tabs' ), [ 'condition' => $show_close ] ); $document->start_controls_tab( self::key( 'close_tab_normal' ), [ 'label' => __( 'Normal', 'admore-widgets-suite' ) ] ); $document->add_control( self::key( 'close_color' ), [ 'label' => __( 'Icon Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => $d['close_color'], 'selectors' => [ $sel => '--eppro-popup-close-color: {{VALUE}};' ], ] ); $document->add_control( self::key( 'close_bg' ), [ 'label' => __( 'Background Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => $d['close_bg'], 'selectors' => [ $sel => '--eppro-popup-close-bg: {{VALUE}};' ], ] ); $document->end_controls_tab(); $document->start_controls_tab( self::key( 'close_tab_hover' ), [ 'label' => __( 'Hover', 'admore-widgets-suite' ) ] ); $document->add_control( self::key( 'close_color_hover' ), [ 'label' => __( 'Icon Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ $sel => '--eppro-popup-close-color-hover: {{VALUE}};' ], ] ); $document->add_control( self::key( 'close_bg_hover' ), [ 'label' => __( 'Background Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ $sel => '--eppro-popup-close-bg-hover: {{VALUE}};' ], ] ); $document->end_controls_tab(); $document->end_controls_tabs(); // Focus ring: the outline shown when the button has keyboard focus // (the popup focuses the close button when it opens). $document->add_control( self::key( 'close_focus_heading' ), [ 'label' => __( 'Focus Ring', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::HEADING, 'separator' => 'before', 'condition' => $show_close, ] ); $show_focus = array_merge( $show_close, [ self::key( 'close_focus' ) => 'show' ] ); $document->add_control( self::key( 'close_focus' ), [ 'label' => __( 'Focus Ring', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'show', 'options' => [ 'show' => __( 'Show', 'admore-widgets-suite' ), 'hide' => __( 'Hide', 'admore-widgets-suite' ), ], 'selectors_dictionary' => [ 'show' => 'solid', 'hide' => 'none' ], 'selectors' => [ $sel => '--eppro-popup-close-focus-style: {{VALUE}};' ], 'description' => __( 'Outline shown when the close button has keyboard focus. Keep it visible for keyboard users if you can.', 'admore-widgets-suite' ), 'condition' => $show_close, ] ); $document->add_control( self::key( 'close_focus_color' ), [ 'label' => __( 'Focus Ring Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ $sel => '--eppro-popup-close-focus-color: {{VALUE}};' ], 'condition' => $show_focus, ] ); $document->add_control( self::key( 'close_focus_width' ), [ 'label' => __( 'Focus Ring Width', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'range' => [ 'px' => [ 'min' => 1, 'max' => 6 ] ], 'default' => [ 'size' => 2, 'unit' => 'px' ], 'selectors' => [ $sel => '--eppro-popup-close-focus-width: {{SIZE}}{{UNIT}};' ], 'condition' => $show_focus, ] ); $document->end_controls_section(); } // ========================================================================= // Markup shared by the frontend renderer and the editor preview // ========================================================================= public static function print_frame_open( int $post_id, string $title, array $design, bool $preview = false ): void { $popup_id = 'eppro-popup-' . $post_id; $classes = [ 'eppro-popup-overlay', 'eppro-anim-' . $design['animation'], 'eppro-pos-' . $design['position'], ]; if ( $preview ) { $classes[] = 'eppro-open'; $classes[] = 'eppro-popup-is-preview'; } // The preview always prints the button so the Show / Hide setting can toggle it live. $print_close = $preview || 'show' === $design['close_button']; ?>