start_controls_section( 'content_section', [ 'label' => esc_html__( 'Social Settings', 'easy-elements' ), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'social_links', [ 'label' => esc_html__( 'Social Links', 'easy-elements' ), 'type' => Controls_Manager::REPEATER, 'fields' => [ // Link Title Field [ 'name' => 'link_title', 'label' => esc_html__( 'Link Title', 'easy-elements' ), 'type' => Controls_Manager::TEXT, 'default' => esc_html__( 'Social Link', 'easy-elements' ), ], // Link URL Field [ 'name' => 'link_url', 'label' => esc_html__( 'Link URL', 'easy-elements' ), 'type' => Controls_Manager::URL, 'default' => [ 'url' => '#', 'is_external' => false, 'nofollow' => false, ], ], // Icon Field [ 'name' => 'icon', 'label' => esc_html__( 'Icon', 'easy-elements' ), 'type' => Controls_Manager::ICONS, 'default' => [ 'value' => 'fab fa-facebook-f', 'library' => 'fa-brands', ], ], // Background Color Field [ 'name' => 'background_color', 'label' => esc_html__( 'Background Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'default' => '#1877F2', ], // Icon Color Field [ 'name' => 'icon_color', 'label' => esc_html__( 'Icon Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'default' => '#ffffff', ], // Hover Background Color Field [ 'name' => 'hover_background_color', 'label' => esc_html__( 'Hover Background Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'default' => '#166fe5', ], // Hover Icon Color Field [ 'name' => 'hover_icon_color', 'label' => esc_html__( 'Hover Icon Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'default' => '#ffffff', ], ], // Default social links 'default' => [ [ 'link_title' => esc_html__( 'Facebook', 'easy-elements' ), 'link_url' => [ 'url' => '#' ], 'icon' => [ 'value' => 'fab fa-facebook-f' ], 'background_color' => '#1877F2', 'icon_color' => '#ffffff', 'hover_background_color' => '#166fe5', 'hover_icon_color' => '#ffffff', ], [ 'link_title' => esc_html__( 'Twitter', 'easy-elements' ), 'link_url' => [ 'url' => '#' ], 'icon' => [ 'value' => 'fab fa-twitter' ], 'background_color' => '#1DA1F2', 'icon_color' => '#ffffff', 'hover_background_color' => '#1a91da', 'hover_icon_color' => '#ffffff', ], [ 'link_title' => esc_html__( 'Instagram', 'easy-elements' ), 'link_url' => [ 'url' => '#' ], 'icon' => [ 'value' => 'fab fa-instagram' ], 'background_color' => '#E4405F', 'icon_color' => '#ffffff', 'hover_background_color' => '#d63384', 'hover_icon_color' => '#ffffff', ], ], 'title_field' => '{{{ link_title }}}', ] ); // Color Mode Control $this->add_control( 'color_mode', [ 'label' => esc_html__( 'Color Mode', 'easy-elements' ), 'type' => Controls_Manager::SELECT, 'default' => 'custom', 'options' => [ 'custom' => esc_html__( 'Custom Colors (Per Item)', 'easy-elements' ), 'global' => esc_html__( 'Global Colors', 'easy-elements' ), ], 'separator' => 'before', ] ); $this->end_controls_section(); // ======================================== // STYLE SECTION - Buttons Style // ======================================== $this->start_controls_section( 'buttons_style_section', [ 'label' => esc_html__( 'Buttons Style', 'easy-elements' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); // Button Size Control $this->add_responsive_control( 'button_size', [ 'label' => esc_html__( 'Button Size', 'easy-elements' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', 'em' ], 'range' => [ 'px' => [ 'min' => 30, 'max' => 100, 'step' => 1, ], 'em' => [ 'min' => 2, 'max' => 6, 'step' => 0.1, ], ], 'default' => [ 'unit' => 'px', 'size' => 45, ], 'selectors' => [ '{{WRAPPER}} .eel-social-button' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}}; line-height: {{SIZE}}{{UNIT}};', ], ] ); // Button Spacing Control $this->add_responsive_control( 'button_spacing', [ 'label' => esc_html__( 'Button Spacing', 'easy-elements' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', 'em' ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 50, 'step' => 1, ], 'em' => [ 'min' => 0, 'max' => 3, 'step' => 0.1, ], ], 'default' => [ 'unit' => 'px', 'size' => 10, ], 'selectors' => [ '{{WRAPPER}} .eel-social-buttons' => 'gap: {{SIZE}}{{UNIT}};', ], ] ); // Border Radius Control $this->add_control( 'button_border_radius', [ 'label' => esc_html__( 'Border Radius', 'easy-elements' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%' ], 'default' => [ 'top' => '50', 'right' => '50', 'bottom' => '50', 'left' => '50', 'unit' => '%', 'isLinked' => true, ], 'selectors' => [ '{{WRAPPER}} .eel-social-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); // 1. Start the Tabs Wrapper $this->start_controls_tabs( 'tabs_button_border_style' ); // ---- NORMAL STATE TAB ---- $this->start_controls_tab( 'tab_button_border_normal', [ 'label' => esc_html__( 'Normal', 'easy-elements' ), ] ); $this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'button_border', 'selector' => '{{WRAPPER}} .eel-social-button', ] ); $this->end_controls_tab(); // ---- HOVER STATE TAB ---- $this->start_controls_tab( 'tab_button_border_hover', [ 'label' => esc_html__( 'Hover', 'easy-elements' ), ] ); $this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'button_border_hover', // Must be a unique name 'selector' => '{{WRAPPER}} .eel-social-button:hover', // Targeted with :hover ] ); $this->end_controls_tab(); $this->end_controls_tabs(); // Close the Tabs Wrapper // Box Shadow Control $this->add_group_control( Group_Control_Box_Shadow::get_type(), [ 'name' => 'button_box_shadow', 'selector' => '{{WRAPPER}} .eel-social-button', ] ); // Global Background Color Control (only when global mode is selected) $this->add_control( 'button_background_color', [ 'label' => esc_html__( 'Background Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'default' => '#1877F2', 'condition' => [ 'color_mode' => 'global', ], 'selectors' => [ '{{WRAPPER}} .eel-social-button' => 'background-color: {{VALUE}} !important;', ], ] ); // Global Hover Background Color Control $this->add_control( 'button_background_hover_color', [ 'label' => esc_html__( 'Hover Background Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'default' => '#166fe5', 'condition' => [ 'color_mode' => 'global', ], 'selectors' => [ '{{WRAPPER}} .eel-social-button:hover' => 'background-color: {{VALUE}} !important; border-color: {{VALUE}} !important;', ], ] ); // Global Icon Color Control $this->add_control( 'button_icon_color', [ 'label' => esc_html__( 'Icon Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'default' => '#ffffff', 'condition' => [ 'color_mode' => 'global', ], 'selectors' => [ '{{WRAPPER}} .eel-social-button i' => 'color: {{VALUE}};', '{{WRAPPER}} .eel-social-button svg' => 'fill: {{VALUE}};', ], ] ); // Global Hover Icon Color Control $this->add_control( 'button_icon_hover_color', [ 'label' => esc_html__( 'Hover Icon Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'default' => '#ffffff', 'condition' => [ 'color_mode' => 'global', ], 'selectors' => [ '{{WRAPPER}} .eel-social-button:hover i' => 'color: {{VALUE}} !important;', '{{WRAPPER}} .eel-social-button:hover svg' => 'fill: {{VALUE}} !important;', ], ] ); // Icon Size Control $this->add_responsive_control( 'icon_size', [ 'label' => esc_html__( 'Icon Size', 'easy-elements' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', 'em' ], 'range' => [ 'px' => [ 'min' => 10, 'max' => 50, 'step' => 1, ], 'em' => [ 'min' => 0.5, 'max' => 3, 'step' => 0.1, ], ], 'default' => [ 'unit' => 'px', 'size' => 18, ], 'selectors' => [ '{{WRAPPER}} .eel-social-button i' => 'font-size: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .eel-social-button svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};', ], ] ); $this->end_controls_section(); } /** * Render widget output on the frontend * * Generates the HTML markup for the social icons */ protected function render() { $settings = $this->get_settings_for_display(); if ( empty( $settings['social_links'] ) ) { return; } $color_mode = $settings['color_mode'] ?? 'custom'; echo '
'; if ( ! empty( $custom_css ) ) { $handle = 'easyel-social-share-inline'; wp_register_style( $handle, false, [], EASYELEMENTS_VER ); wp_enqueue_style( $handle ); wp_add_inline_style( $handle, $custom_css ); } } }