start_controls_section( 'content_section', array( 'label' => __( 'Content', 'a1-tools' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ) ); $this->add_control( 'franchise_id', array( 'label' => __( 'Franchise ID', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => '', 'description' => __( 'Leave empty to show all franchises. Enter a specific ID to show only that franchise.', 'a1-tools' ), ) ); $this->add_control( 'columns', array( 'label' => __( 'Columns', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::NUMBER, 'min' => 1, 'max' => 3, 'default' => 1, 'description' => __( 'Number of grid columns (1-3). Stacks to 1 on mobile.', 'a1-tools' ), ) ); $this->add_control( 'show_title', array( 'label' => __( 'Show Title', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => __( 'Yes', 'a1-tools' ), 'label_off' => __( 'No', 'a1-tools' ), 'return_value' => 'yes', 'default' => 'yes', ) ); $this->add_control( 'show_phone', array( 'label' => __( 'Show Phone', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => __( 'Yes', 'a1-tools' ), 'label_off' => __( 'No', 'a1-tools' ), 'return_value' => 'yes', 'default' => 'yes', ) ); $this->add_control( 'show_address', array( 'label' => __( 'Show Address', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => __( 'Yes', 'a1-tools' ), 'label_off' => __( 'No', 'a1-tools' ), 'return_value' => 'yes', 'default' => 'yes', ) ); $this->add_control( 'show_map', array( 'label' => __( 'Show Map', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => __( 'Yes', 'a1-tools' ), 'label_off' => __( 'No', 'a1-tools' ), 'return_value' => 'yes', 'default' => 'yes', ) ); $this->add_control( 'show_directions', array( 'label' => __( 'Show Directions Link', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => __( 'Yes', 'a1-tools' ), 'label_off' => __( 'No', 'a1-tools' ), 'return_value' => 'yes', 'default' => 'yes', ) ); $this->add_control( 'map_height', array( 'label' => __( 'Map Height', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'range' => array( 'px' => array( 'min' => 150, 'max' => 600, ), ), 'default' => array( 'size' => 300, 'unit' => 'px', ), 'condition' => array( 'show_map' => 'yes', ), ) ); $this->add_control( 'map_zoom', array( 'label' => __( 'Map Zoom Level', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::NUMBER, 'min' => 1, 'max' => 20, 'default' => 15, 'condition' => array( 'show_map' => 'yes', ), ) ); $this->end_controls_section(); // ── Style: Card ───────────────────────────────────────────── $this->start_controls_section( 'style_card_section', array( 'label' => __( 'Card', 'a1-tools' ), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ) ); $this->add_control( 'card_background', array( 'label' => __( 'Background Color', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#ffffff', 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-card' => 'background-color: {{VALUE}};', ), ) ); $this->add_group_control( \Elementor\Group_Control_Border::get_type(), array( 'name' => 'card_border', 'selector' => '{{WRAPPER}} .a1tools-franchise-card', ) ); $this->add_control( 'card_border_hover_color', array( 'label' => __( 'Border Hover Color', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-card:hover' => 'border-color: {{VALUE}};', ), 'condition' => array( 'card_border_border!' => '' ), ) ); $this->add_control( 'card_border_radius', array( 'label' => __( 'Border Radius', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', '%' ), 'default' => array( 'top' => '8', 'right' => '8', 'bottom' => '8', 'left' => '8', 'unit' => 'px', ), 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-card' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->add_responsive_control( 'card_padding', array( 'label' => __( 'Padding', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', 'em' ), 'default' => array( 'top' => '20', 'right' => '20', 'bottom' => '20', 'left' => '20', 'unit' => 'px', ), 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-card' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->add_group_control( \Elementor\Group_Control_Box_Shadow::get_type(), array( 'name' => 'card_shadow', 'selector' => '{{WRAPPER}} .a1tools-franchise-card', ) ); $this->add_control( 'card_hover_shadow_heading', array( 'label' => __( 'Hover Shadow', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::HEADING, 'separator' => 'before', ) ); $this->add_group_control( \Elementor\Group_Control_Box_Shadow::get_type(), array( 'name' => 'card_hover_shadow', 'selector' => '{{WRAPPER}} .a1tools-franchise-card:hover', ) ); $this->end_controls_section(); // ── Style: Spacing ────────────────────────────────────────── $this->start_controls_section( 'style_spacing_section', array( 'label' => __( 'Spacing', 'a1-tools' ), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ) ); $this->add_responsive_control( 'grid_gap', array( 'label' => __( 'Grid Gap', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'range' => array( 'px' => array( 'min' => 0, 'max' => 60, ), ), 'default' => array( 'size' => 20, 'unit' => 'px', ), 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-grid' => 'gap: {{SIZE}}{{UNIT}};', ), ) ); $this->add_responsive_control( 'content_spacing', array( 'label' => __( 'Content Spacing', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'range' => array( 'px' => array( 'min' => 0, 'max' => 30, ), ), 'default' => array( 'size' => 10, 'unit' => 'px', ), 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-title' => 'margin-bottom: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .a1tools-franchise-address' => 'margin-bottom: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .a1tools-franchise-phone' => 'margin-bottom: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .a1tools-franchise-map' => 'margin-bottom: {{SIZE}}{{UNIT}};', ), ) ); $this->end_controls_section(); // ── Style: Typography ─────────────────────────────────────── $this->start_controls_section( 'style_typography_section', array( 'label' => __( 'Typography', 'a1-tools' ), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ) ); $this->add_control( 'title_heading', array( 'label' => __( 'Title', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::HEADING, ) ); $this->add_control( 'title_color', array( 'label' => __( 'Color', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#333333', 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-title' => 'color: {{VALUE}};', ), ) ); $this->add_group_control( \Elementor\Group_Control_Typography::get_type(), array( 'name' => 'title_typography', 'selector' => '{{WRAPPER}} .a1tools-franchise-title', ) ); $this->add_responsive_control( 'title_alignment', array( 'label' => __( 'Alignment', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::CHOOSE, 'options' => array( 'left' => array( 'title' => __( 'Left', 'a1-tools' ), 'icon' => 'eicon-text-align-left', ), 'center' => array( 'title' => __( 'Center', 'a1-tools' ), 'icon' => 'eicon-text-align-center', ), 'right' => array( 'title' => __( 'Right', 'a1-tools' ), 'icon' => 'eicon-text-align-right', ), ), 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-title' => 'text-align: {{VALUE}};', ), ) ); $this->add_control( 'address_heading', array( 'label' => __( 'Address', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::HEADING, 'separator' => 'before', ) ); $this->add_control( 'address_color', array( 'label' => __( 'Color', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#555555', 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-address' => 'color: {{VALUE}};', ), ) ); $this->add_group_control( \Elementor\Group_Control_Typography::get_type(), array( 'name' => 'address_typography', 'selector' => '{{WRAPPER}} .a1tools-franchise-address', ) ); $this->add_responsive_control( 'address_alignment', array( 'label' => __( 'Alignment', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::CHOOSE, 'options' => array( 'left' => array( 'title' => __( 'Left', 'a1-tools' ), 'icon' => 'eicon-text-align-left', ), 'center' => array( 'title' => __( 'Center', 'a1-tools' ), 'icon' => 'eicon-text-align-center', ), 'right' => array( 'title' => __( 'Right', 'a1-tools' ), 'icon' => 'eicon-text-align-right', ), ), 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-address' => 'text-align: {{VALUE}};', ), ) ); $this->add_control( 'phone_heading', array( 'label' => __( 'Phone', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::HEADING, 'separator' => 'before', ) ); $this->add_control( 'phone_color', array( 'label' => __( 'Color', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#0066cc', 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-phone a' => 'color: {{VALUE}};', ), ) ); $this->add_control( 'phone_hover_color', array( 'label' => __( 'Hover Color', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-phone a:hover' => 'color: {{VALUE}};', ), ) ); $this->add_group_control( \Elementor\Group_Control_Typography::get_type(), array( 'name' => 'phone_typography', 'selector' => '{{WRAPPER}} .a1tools-franchise-phone a', ) ); $this->add_responsive_control( 'phone_alignment', array( 'label' => __( 'Alignment', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::CHOOSE, 'options' => array( 'left' => array( 'title' => __( 'Left', 'a1-tools' ), 'icon' => 'eicon-text-align-left', ), 'center' => array( 'title' => __( 'Center', 'a1-tools' ), 'icon' => 'eicon-text-align-center', ), 'right' => array( 'title' => __( 'Right', 'a1-tools' ), 'icon' => 'eicon-text-align-right', ), ), 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-phone' => 'text-align: {{VALUE}};', ), ) ); $this->end_controls_section(); // ── Style: Directions Button ──────────────────────────────── $this->start_controls_section( 'style_button_section', array( 'label' => __( 'Directions Button', 'a1-tools' ), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, 'condition' => array( 'show_directions' => 'yes', ), ) ); $this->add_group_control( \Elementor\Group_Control_Typography::get_type(), array( 'name' => 'button_typography', 'selector' => '{{WRAPPER}} .a1tools-franchise-directions-link', ) ); $this->start_controls_tabs( 'button_style_tabs' ); // ── Normal ── $this->start_controls_tab( 'button_normal_tab', array( 'label' => __( 'Normal', 'a1-tools' ) ) ); $this->add_control( 'button_text_color', array( 'label' => __( 'Text Color', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#ffffff', 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-directions-link' => 'color: {{VALUE}};', ), ) ); $this->add_control( 'button_bg_color', array( 'label' => __( 'Background Color', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#333333', 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-directions-link' => 'background-color: {{VALUE}};', ), ) ); $this->add_group_control( \Elementor\Group_Control_Border::get_type(), array( 'name' => 'button_border', 'selector' => '{{WRAPPER}} .a1tools-franchise-directions-link', ) ); $this->end_controls_tab(); // ── Hover ── $this->start_controls_tab( 'button_hover_tab', array( 'label' => __( 'Hover', 'a1-tools' ) ) ); $this->add_control( 'button_hover_text_color', array( 'label' => __( 'Text Color', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-directions-link:hover' => 'color: {{VALUE}};', ), ) ); $this->add_control( 'button_hover_bg_color', array( 'label' => __( 'Background Color', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#555555', 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-directions-link:hover' => 'background-color: {{VALUE}};', ), ) ); $this->add_control( 'button_hover_border_color', array( 'label' => __( 'Border Color', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-directions-link:hover' => 'border-color: {{VALUE}};', ), 'condition' => array( 'button_border_border!' => '' ), ) ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->add_control( 'button_border_radius', array( 'label' => __( 'Border Radius', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', '%' ), 'separator' => 'before', 'default' => array( 'top' => '4', 'right' => '4', 'bottom' => '4', 'left' => '4', 'unit' => 'px', ), 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-directions-link' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->add_responsive_control( 'button_padding', array( 'label' => __( 'Padding', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', 'em' ), 'default' => array( 'top' => '8', 'right' => '16', 'bottom' => '8', 'left' => '16', 'unit' => 'px', ), 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-directions-link' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->add_responsive_control( 'button_alignment', array( 'label' => __( 'Alignment', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::CHOOSE, 'options' => array( 'left' => array( 'title' => __( 'Left', 'a1-tools' ), 'icon' => 'eicon-text-align-left', ), 'center' => array( 'title' => __( 'Center', 'a1-tools' ), 'icon' => 'eicon-text-align-center', ), 'right' => array( 'title' => __( 'Right', 'a1-tools' ), 'icon' => 'eicon-text-align-right', ), ), 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-directions' => 'text-align: {{VALUE}};', ), ) ); $this->end_controls_section(); } // ──────────────────────────────────────────────────────────────── // Render // ──────────────────────────────────────────────────────────────── protected function render() { $settings = $this->get_settings_for_display(); echo a1tools_shortcode_franchise( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- shortcode handles its own escaping. 'show_title' => $settings['show_title'] ?? 'yes', 'show_phone' => $settings['show_phone'] ?? 'yes', 'show_address' => $settings['show_address'] ?? 'yes', 'show_map' => $settings['show_map'] ?? 'yes', 'show_directions' => $settings['show_directions'] ?? 'yes', 'map_height' => $settings['map_height']['size'] ?? '300', 'map_zoom' => $settings['map_zoom'] ?? '15', 'columns' => $settings['columns'] ?? '1', 'id' => $settings['franchise_id'] ?? '', ) ); } protected function content_template() { ?>
<# if ( settings.show_title !== '' ) { #>

<# } #> <# if ( settings.show_address === 'yes' ) { #>
123 Main Street
City, State 12345
<# } #> <# if ( settings.show_phone === 'yes' ) { #> <# } #> <# if ( settings.show_map === 'yes' ) { #>
Map loads on frontend
<# } #> <# if ( settings.show_directions === 'yes' ) { #> <# } #>
<# if ( ( settings.columns || 1 ) > 1 ) { #>
<# if ( settings.show_title !== '' ) { #>

<# } #> <# if ( settings.show_address === 'yes' ) { #>
456 Oak Avenue
Town, State 67890
<# } #> <# if ( settings.show_phone === 'yes' ) { #> <# } #> <# if ( settings.show_map === 'yes' ) { #>
Map loads on frontend
<# } #> <# if ( settings.show_directions === 'yes' ) { #> <# } #>
<# } #>
Note: Actual franchise data loads on the frontend from the A1 Tools API.