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_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_control( 'card_border_radius', array( 'label' => __( 'Border Radius', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'range' => array( 'px' => array( 'min' => 0, 'max' => 30, ), ), 'default' => array( 'size' => 8, 'unit' => 'px', ), 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-card' => 'border-radius: {{SIZE}}{{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->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_color', array( 'label' => __( 'Title Color', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#333333', 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-title' => 'color: {{VALUE}};', ), ) ); $this->add_control( 'address_color', array( 'label' => __( 'Address Color', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#555555', 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-address' => 'color: {{VALUE}};', ), ) ); $this->add_control( 'phone_color', array( 'label' => __( 'Phone Color', 'a1-tools' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#0066cc', 'selectors' => array( '{{WRAPPER}} .a1tools-franchise-phone a' => 'color: {{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_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_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_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.