/
home
/
rekodeb
/
webrennes
/
wp-content
/
plugins
/
windfall-core
/
elementor
/
widgets
/
Upload File
HOME
<?php /* * Elementor Windfall About Widget * Author & Copyright: VictorTheme */ namespace Elementor; if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly class Windfall_About extends Widget_Base{ /** * Retrieve the widget name. */ public function get_name(){ return 'vt-windfall_about'; } /** * Retrieve the widget title. */ public function get_title(){ return esc_html__( 'About', 'windfall-core' ); } /** * Retrieve the widget icon. */ public function get_icon() { return 'fa fa-plus-circle'; } /** * Retrieve the list of categories the widget belongs to. */ public function get_categories() { return ['victortheme-category']; } /** * Retrieve the list of scripts the Windfall Windfall About widget depended on. * Used to set scripts dependencies required to run the widget. */ /* public function get_script_depends() { return ['vt-windfall_about']; } */ /** * Register Windfall Windfall About widget controls. * Adds different input fields to allow the user to change and customize the widget settings. */ protected function register_controls(){ $this->start_controls_section( 'section_features', [ 'label' => esc_html__( 'About Options', 'windfall-core' ), ] ); $this->add_control( 'about_image', [ 'label' => esc_html__( 'Upload About Image', 'windfall-core' ), 'type' => Controls_Manager::MEDIA, 'frontend_available' => true, 'default' => [ 'url' => Utils::get_placeholder_image_src(), ], 'description' => esc_html__( 'Set your about image.', 'windfall-core'), ] ); $this->add_control( 'about_title', [ 'label' => esc_html__( 'About Title', 'windfall-core' ), 'type' => Controls_Manager::TEXT, 'default' => esc_html__( 'About Title', 'windfall-core' ), 'placeholder' => esc_html__( 'Type about title text here', 'windfall-core' ), 'label_block' => true, ] ); $this->add_control( 'about_content', [ 'label' => esc_html__( 'About Content', 'windfall-core' ), 'type' => Controls_Manager::TEXTAREA, 'placeholder' => esc_html__( 'Type about content here', 'windfall-core' ), 'label_block' => true, ] ); $repeater = new Repeater(); $repeater->add_control( 'list_text', [ 'label' => esc_html__( 'Text', 'windfall-core' ), 'type' => Controls_Manager::TEXTAREA, 'label_block' => true, ] ); $this->add_control( 'listItems_groups', [ 'label' => esc_html__( 'Lists', 'windfall-core' ), 'type' => Controls_Manager::REPEATER, 'default' => [ [ 'list_text' => esc_html__( 'Item #1', 'windfall-core' ), ], ], 'fields' => $repeater->get_controls(), 'title_field' => '{{{ list_text }}}', ] ); $this->add_control( 'btn_txt', [ 'label' => esc_html__( 'Button Text', 'windfall-core' ), 'type' => Controls_Manager::TEXT, 'label_block' => true, 'placeholder' => esc_html__( 'Type your button text here', 'windfall-core' ), ] ); $this->add_control( 'button_link', [ 'label' => esc_html__( 'Button Link', 'windfall-core' ), 'type' => Controls_Manager::URL, 'placeholder' => __( 'https://your-link.com', 'windfall-core' ), 'show_external' => true, 'default' => [ 'url' => '', 'is_external' => true, 'nofollow' => true, ], ] ); $this->end_controls_section();// end: Section $this->end_controls_section();// end: Section // Title Style $this->start_controls_section( 'section_title_style', [ 'label' => esc_html__( 'Title', 'windfall-core' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'sasfea_title_typography', 'selector' => '{{WRAPPER}} .about-title', ] ); $this->add_control( 'title_color', [ 'label' => esc_html__( 'Color', 'windfall-core' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .about-title' => 'color: {{VALUE}};', ], ] ); $this->end_controls_section();// end: Section // Content Style $this->start_controls_section( 'section_content_style', [ 'label' => esc_html__( 'Content', 'windfall-core' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'label' => esc_html__( 'Typography', 'windfall-core' ), 'name' => 'content_typography', 'selector' => '{{WRAPPER}} .about-info p, {{WRAPPER}} .about-info ul li', ] ); $this->add_control( 'content_color', [ 'label' => esc_html__( 'Color', 'windfall-core' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .about-info p, {{WRAPPER}} .about-info ul li' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'content_padding', [ 'label' => __( 'Padding', 'windfall-core' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em' ], 'selectors' => [ '{{WRAPPER}} .about-info' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_control( 'list_bullet_color', [ 'label' => esc_html__( 'Bullet Color', 'windfall-core' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .check-list li:before' => 'color: {{VALUE}};', ], ] ); $this->end_controls_section();// end: Section // Button Style $this->start_controls_section( 'section_button_style', [ 'label' => esc_html__( 'Button', 'windfall-core' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'button_typography', 'selector' => '{{WRAPPER}} .wndfal-btn', ] ); $this->add_responsive_control( 'button_min_width', [ 'label' => esc_html__( 'Width', 'windfall-core' ), 'type' => Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 10, 'max' => 500, 'step' => 1, ], ], 'size_units' => [ 'px' ], 'selectors' => [ '{{WRAPPER}} .wndfal-btn' => 'min-width: {{SIZE}}{{UNIT}};', ], ] ); $this->add_control( 'button_padding', [ 'label' => __( 'Padding', 'windfall-core' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em' ], 'selectors' => [ '{{WRAPPER}} .wndfal-btn .btn-text' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_control( 'button_border_radius', [ 'label' => __( 'Border Radius', 'windfall-core' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .wndfal-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->start_controls_tabs( 'button_style' ); $this->start_controls_tab( 'button_normal', [ 'label' => esc_html__( 'Normal', 'windfall-core' ), ] ); $this->add_control( 'button_color', [ 'label' => esc_html__( 'Color', 'windfall-core' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .wndfal-btn' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'button_bg_color', [ 'label' => esc_html__( 'Background Color', 'windfall-core' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .wndfal-btn .btn-text-wrap' => 'background-color: {{VALUE}};', ], ] ); $this->end_controls_tab(); // end:Normal tab $this->start_controls_tab( 'button_hover', [ 'label' => esc_html__( 'Hover', 'windfall-core' ), ] ); $this->add_control( 'button_hover_color', [ 'label' => esc_html__( 'Color', 'windfall-core' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .wndfal-btn:hover' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'button_bg_hover_color', [ 'label' => esc_html__( 'Background Color', 'windfall-core' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .wndfal-btn:hover .btn-text-wrap' => 'background-color: {{VALUE}};', ], ] ); $this->add_control( 'button_border_hover_color', [ 'label' => esc_html__( 'Border Color', 'windfall-core' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .wndfal-btn:before, {{WRAPPER}} .wndfal-btn:after, {{WRAPPER}} .wndfal-btn .btn-text-wrap:before, {{WRAPPER}} .wndfal-btn .btn-text-wrap:after' => 'background: {{VALUE}};', ], ] ); $this->end_controls_tab(); // end:Hover tab $this->end_controls_tabs(); // end tabs $this->end_controls_section();// end: Section } /** * Render About widget output on the frontend. * Written in PHP and used to generate the final HTML. */ protected function render() { $settings = $this->get_settings_for_display(); $about_title = !empty( $settings['about_title'] ) ? $settings['about_title'] : []; $about_content = !empty( $settings['about_content'] ) ? $settings['about_content'] : []; $listItems_groups = !empty( $settings['listItems_groups'] ) ? $settings['listItems_groups'] : []; $image_url = wp_get_attachment_url( $settings['about_image']['id'] ); $alt = get_post_meta($settings['about_image']['id'], '_wp_attachment_image_alt', true); $title = $about_title ? '<h2 class="about-title">'.$about_title.'</h2>' : ''; $content = $about_content ? '<p>'.$about_content.'</p>' : ''; // Button $btn_text = !empty( $settings['btn_txt'] ) ? $settings['btn_txt'] : ''; $btn_link = !empty( $settings['button_link']['url'] ) ? $settings['button_link']['url'] : ''; $btn_external = !empty( $settings['button_link']['is_external'] ) ? 'target="_blank"' : ''; $btn_nofollow = !empty( $settings['button_link']['nofollow'] ) ? 'rel="nofollow"' : ''; $btn_link_attr = !empty( $btn_link ) ? $btn_external.' '.$btn_nofollow : ''; // Button Styling $button_main = $btn_link ? '<a href="'.$btn_link.'" '.$btn_link_attr.' class="wndfal-btn"><span class="btn-text-wrap"><span class="btn-text">'.$btn_text.'</span></span></a>' : '<span class="wndfal-btn"><span class="btn-text-wrap"><span class="btn-text">'.$btn_text.'</span></span></span>'; $button_actual = $btn_text ? '<div class="wndfal-btns-group">'.$button_main.'</div>' : ''; $feature_image = $image_url ? '<div class="wndfal-image"><img src="'.$image_url.'" alt="'.$alt.'"></div>' : ''; $output = '<div class="wndfal-about"> <div class="container"> <div class="row"> <div class="col-lg-6 order-lg-2"> <div class="about-info"> '.$title.$content.'<ul class="check-list">'; // Group Param Output if( is_array( $listItems_groups ) && !empty( $listItems_groups ) ){ foreach ( $listItems_groups as $each_list ) { $list_text = $each_list['list_text'] ? $each_list['list_text'] : ''; $list_link_actual = $list_text ? '<li>'.$list_text.'</li>' : ''; $output .= $list_link_actual; } } $output .= '</ul>'.$button_actual.'</div></div><div class="col-lg-6 order-lg-1">'.$feature_image.'</div></div></div></div>'; echo $output; } /** * Render About widget output in the editor. * Written as a Backbone JavaScript template and used to generate the live preview. */ //protected function _content_template(){} } Plugin::instance()->widgets_manager->register_widget_type( new Windfall_About() );