/
home
/
rekodeb
/
webrennes
/
wp-content
/
plugins
/
windfall-core
/
elementor
/
widgets
/
Upload File
HOME
<?php /* * Elementor Windfall Client Widget * Author & Copyright: VictorTheme */ namespace Elementor; if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly class Windfall_Client extends Widget_Base{ /** * Retrieve the widget name. */ public function get_name(){ return 'vt-windfall_client'; } /** * Retrieve the widget title. */ public function get_title(){ return esc_html__( 'Client Carousel', 'windfall-core' ); } /** * Retrieve the widget icon. */ public function get_icon() { return 'fa fa-shield'; } /** * Retrieve the list of categories the widget belongs to. */ public function get_categories() { return ['victortheme-category']; } /** * Retrieve the list of scripts the Windfall Client widget depended on. * Used to set scripts dependencies required to run the widget. */ public function get_script_depends() { return ['vt-windfall_client']; } /** * Register Windfall Client 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_client', [ 'label' => esc_html__( 'Client Options', 'windfall-core' ), ] ); $this->add_control( 'client_section_title', [ 'label' => esc_html__( 'Client Carousel Title', 'windfall-core' ), 'type' => Controls_Manager::TEXT, 'label_block' => true, 'default' => esc_html__( 'Trusted Partners', 'windfall-core' ), 'placeholder' => esc_html__( 'Type your client carousel title here', 'windfall-core' ), ] ); $repeater = new Repeater(); $repeater->add_control( 'client_logo_title', [ 'label' => esc_html__( 'Logo title', 'windfall-core' ), 'type' => Controls_Manager::TEXT, 'label_block' => true, 'placeholder' => esc_html__( 'Type item title here', 'windfall-core' ), ] ); $repeater->add_control( 'client_logo', [ 'label' => esc_html__( 'Logo Image', 'windfall-core' ), 'type' => Controls_Manager::MEDIA, 'default' => [ 'url' => Utils::get_placeholder_image_src(), ], ] ); $repeater->add_control( 'client_link_type', [ 'label' => __( 'Link Type', 'windfall-core' ), 'type' => Controls_Manager::SELECT, 'options' => [ 'link' => esc_html__( 'Normal Link', 'windfall-core' ), 'popup' => esc_html__( 'Popup', 'windfall-core' ), ], 'default' => 'link', ] ); $repeater->add_control( 'client_link', [ 'label' => esc_html__( 'Link', 'windfall-core' ), 'type' => Controls_Manager::URL, 'placeholder' => __( 'https://your-link.com', 'windfall-core' ), 'label_block' => true, 'show_external' => true, 'default' => [ 'url' => '', 'is_external' => true, 'nofollow' => true, ], 'condition' => [ 'client_link_type' => 'link', ], ] ); $this->add_control( 'clientLogos_groups', [ 'label' => esc_html__( 'Client Logos', 'windfall-core' ), 'type' => Controls_Manager::REPEATER, 'default' => [ [ 'client_logo_title' => esc_html__( 'Item #1', 'windfall-core' ), ], ], 'fields' => $repeater->get_controls(), 'title_field' => '{{{ client_logo_title }}}', ] ); $this->add_control( 'retina_img', [ 'label' => esc_html__( 'Retina Image?', 'windfall-core' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Yes', 'windfall-core' ), 'label_off' => esc_html__( 'No', 'windfall-core' ), 'return_value' => 'true', 'description' => esc_html__( 'If you want to resize your retina image, enable it.', 'windfall-core' ), ] ); $this->end_controls_section();// end: Section $this->start_controls_section( 'section_carousel', [ 'label' => esc_html__( 'Carousel Options', 'windfall-core' ), ] ); $this->add_responsive_control( 'carousel_items', [ 'label' => esc_html__( 'How many items?', 'windfall-core' ), 'type' => Controls_Manager::NUMBER, 'min' => 1, 'max' => 100, 'step' => 1, 'default' => 5, 'description' => esc_html__( 'Enter the number of items to show.', 'windfall-core' ), ] ); $this->add_responsive_control( 'carousel_margin', [ 'label' => __( 'Space Between Items', 'windfall-core' ), 'type' => Controls_Manager::SLIDER, 'default' => [ 'size' =>30, ], 'label_block' => true, ] ); $this->add_control( 'carousel_autoplay_timeout', [ 'label' => __( 'Auto Play Timeout', 'windfall-core' ), 'type' => Controls_Manager::NUMBER, 'default' => 5000, ] ); $this->add_control( 'carousel_loop', [ 'label' => esc_html__( 'Disable Loop?', 'windfall-core' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Yes', 'windfall-core' ), 'label_off' => esc_html__( 'No', 'windfall-core' ), 'return_value' => 'true', 'description' => esc_html__( 'Continuously moving carousel, if enabled.', 'windfall-core' ), ] ); $this->add_control( 'carousel_dots', [ 'label' => esc_html__( 'Dots', 'windfall-core' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Yes', 'windfall-core' ), 'label_off' => esc_html__( 'No', 'windfall-core' ), 'return_value' => 'true', 'description' => esc_html__( 'If you want Carousel Dots, enable it.', 'windfall-core' ), ] ); $this->add_control( 'carousel_nav', [ 'label' => esc_html__( 'Navigation', 'windfall-core' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Yes', 'windfall-core' ), 'label_off' => esc_html__( 'No', 'windfall-core' ), 'return_value' => 'true', 'description' => esc_html__( 'If you want Carousel Navigation, enable it.', 'windfall-core' ), ] ); $this->add_control( 'carousel_autoplay', [ 'label' => esc_html__( 'Autoplay', 'windfall-core' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Yes', 'windfall-core' ), 'label_off' => esc_html__( 'No', 'windfall-core' ), 'return_value' => 'true', 'description' => esc_html__( 'If you want to start Carousel automatically, enable it.', 'windfall-core' ), ] ); $this->add_control( 'carousel_animate_out', [ 'label' => esc_html__( 'Animate Out', 'windfall-core' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Yes', 'windfall-core' ), 'label_off' => esc_html__( 'No', 'windfall-core' ), 'return_value' => 'true', 'description' => esc_html__( 'CSS3 animation out.', 'windfall-core' ), ] ); $this->add_control( 'carousel_mousedrag', [ 'label' => esc_html__( 'Disable Mouse Drag?', 'windfall-core' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Yes', 'windfall-core' ), 'label_off' => esc_html__( 'No', 'windfall-core' ), 'return_value' => 'true', 'description' => esc_html__( 'If you want to disable Mouse Drag, check it.', 'windfall-core' ), ] ); $this->add_control( 'carousel_autowidth', [ 'label' => esc_html__( 'Auto Width', 'windfall-core' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Yes', 'windfall-core' ), 'label_off' => esc_html__( 'No', 'windfall-core' ), 'return_value' => 'true', 'description' => esc_html__( 'Adjust Auto Width automatically for each carousel items.', 'windfall-core' ), ] ); $this->add_control( 'carousel_autoheight', [ 'label' => esc_html__( 'Auto Height', 'windfall-core' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => esc_html__( 'Yes', 'windfall-core' ), 'label_off' => esc_html__( 'No', 'windfall-core' ), 'return_value' => 'true', 'description' => esc_html__( 'Adjust Auto Height automatically for each carousel items.', 'windfall-core' ), ] ); $this->end_controls_section();// end: Section // Section Title $this->start_controls_section( 'section_titl_style', [ 'label' => esc_html__( 'Section Title', 'windfall-core' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'label' => esc_html__( 'Typography', 'windfall-core' ), 'name' => 'sec_title_typography', 'selector' => '{{WRAPPER}} .partners-title', ] ); $this->add_control( 'sec_title_color', [ 'label' => esc_html__( 'Color', 'windfall-core' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .partners-title' => 'color: {{VALUE}};', ], ] ); $this->end_controls_section();// end: Section // Navigation $this->start_controls_section( 'section_navigation_style', [ 'label' => esc_html__( 'Navigation', 'windfall-core' ), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => [ 'carousel_nav' => 'true', ], 'frontend_available' => true, ] ); $this->add_responsive_control( 'arrow_size', [ 'label' => esc_html__( 'Size', 'windfall-core' ), 'type' => Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 16, 'max' => 1000, 'step' => 1, ], ], 'size_units' => [ 'px' ], 'selectors' => [ '{{WRAPPER}} .owl-carousel .owl-nav .owl-prev:before, {{WRAPPER}} .owl-carousel .owl-nav .owl-next:before' => 'font-size: {{SIZE}}{{UNIT}} !important;', '{{WRAPPER}} .owl-carousel .owl-nav button.owl-prev, {{WRAPPER}} .owl-carousel .owl-nav button.owl-next' => 'width: calc({{SIZE}}{{UNIT}} + 24px);height: calc({{SIZE}}{{UNIT}} + 24px);', ], ] ); $this->start_controls_tabs( 'nav_arrow_style' ); $this->start_controls_tab( 'nav_arrow_normal', [ 'label' => esc_html__( 'Normal', 'windfall-core' ), ] ); $this->add_control( 'nav_arrow_color', [ 'label' => esc_html__( 'Color', 'windfall-core' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .owl-carousel .owl-nav .owl-prev:before, {{WRAPPER}} .owl-carousel .owl-nav .owl-next:before' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'nav_arrow_bg_color', [ 'label' => esc_html__( 'Background Color', 'windfall-core' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .owl-carousel .owl-nav .owl-prev, {{WRAPPER}} .owl-carousel .owl-nav .owl-next' => 'background: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'nav_border', 'label' => esc_html__( 'Border', 'windfall-core' ), 'selector' => '{{WRAPPER}} .owl-carousel .owl-nav .owl-prev, {{WRAPPER}} .owl-carousel .owl-nav .owl-next', ] ); $this->end_controls_tab(); // end:Normal tab $this->start_controls_tab( 'nav_arrow_hover', [ 'label' => esc_html__( 'Hover', 'windfall-core' ), ] ); $this->add_control( 'nav_arrow_hover_color', [ 'label' => esc_html__( 'Color', 'windfall-core' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .owl-carousel .owl-nav .owl-prev:hover:before, {{WRAPPER}} .owl-carousel .owl-nav .owl-next:hover:before' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'nav_arrow_bg_hover_color', [ 'label' => esc_html__( 'Background Color', 'windfall-core' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .owl-carousel .owl-nav .owl-prev:hover, {{WRAPPER}} .owl-carousel .owl-nav .owl-next:hover' => 'background: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'nav_active_border', 'label' => esc_html__( 'Border', 'windfall-core' ), 'selector' => '{{WRAPPER}} .owl-carousel .owl-nav .owl-prev:hover, {{WRAPPER}} .owl-carousel .owl-nav .owl-next:hover', ] ); $this->end_controls_tab(); // end:Hover tab $this->end_controls_tabs(); // end tabs $this->end_controls_section();// end: Section $this->start_controls_section( 'section_dots_style', [ 'label' => esc_html__( 'Dots', 'windfall-core' ), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => [ 'carousel_dots' => 'true', ], 'frontend_available' => true, ] ); $this->add_responsive_control( 'dots_size', [ 'label' => esc_html__( 'Size', 'windfall-core' ), 'type' => Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 0, 'max' => 70, 'step' => 1, ], ], 'size_units' => [ 'px' ], 'selectors' => [ '{{WRAPPER}} .owl-carousel .owl-dot' => 'width: {{SIZE}}{{UNIT}};height: {{SIZE}}{{UNIT}}', ], ] ); $this->add_responsive_control( 'dots_margin', [ 'label' => __( 'Margin', 'windfall-core' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .owl-carousel .owl-dot' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->start_controls_tabs( 'dots_style' ); $this->start_controls_tab( 'dots_normal', [ 'label' => esc_html__( 'Normal', 'windfall-core' ), ] ); $this->add_control( 'dots_color', [ 'label' => esc_html__( 'Color', 'windfall-core' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .owl-carousel .owl-dot' => 'background: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'dots_border', 'label' => esc_html__( 'Border', 'windfall-core' ), 'selector' => '{{WRAPPER}} .owl-carousel .owl-dot', ] ); $this->end_controls_tab(); // end:Normal tab $this->start_controls_tab( 'dots_active', [ 'label' => esc_html__( 'Active', 'windfall-core' ), ] ); $this->add_control( 'dots_active_color', [ 'label' => esc_html__( 'Color', 'windfall-core' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .owl-carousel .owl-dot.active' => 'background: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'dots_active_border', 'label' => esc_html__( 'Border', 'windfall-core' ), 'selector' => '{{WRAPPER}} .owl-carousel .owl-dot.active', ] ); $this->end_controls_tab(); // end:Active tab $this->end_controls_tabs(); // end tabs $this->end_controls_section();// end: Section } /** * Render Client widget output on the frontend. * Written in PHP and used to generate the final HTML. */ protected function render() { $settings = $this->get_settings_for_display(); $client_section_title = !empty( $settings['client_section_title'] ) ? $settings['client_section_title'] : ''; $retina_img = !empty( $settings['retina_img'] ) ? $settings['retina_img'] : ''; $clientLogos_groups = !empty( $settings['clientLogos_groups'] ) ? $settings['clientLogos_groups'] : []; $carousel_items = !empty( $settings['carousel_items'] ) ? $settings['carousel_items'] : ''; $carousel_items_tablet = !empty( $settings['carousel_items_tablet'] ) ? $settings['carousel_items_tablet'] : ''; $carousel_items_mobile = !empty( $settings['carousel_items_mobile'] ) ? $settings['carousel_items_mobile'] : ''; $carousel_margin = !empty( $settings['carousel_margin']['size'] ) ? $settings['carousel_margin']['size'] : ''; $carousel_autoplay_timeout = !empty( $settings['carousel_autoplay_timeout'] ) ? $settings['carousel_autoplay_timeout'] : ''; $carousel_loop = ( isset( $settings['carousel_loop'] ) && ( 'true' == $settings['carousel_loop'] ) ) ? $settings['carousel_loop'] : 'false'; $carousel_dots = ( isset( $settings['carousel_dots'] ) && ( 'true' == $settings['carousel_dots'] ) ) ? true : false; $carousel_nav = ( isset( $settings['carousel_nav'] ) && ( 'true' == $settings['carousel_nav'] ) ) ? true : false; $carousel_autoplay = ( isset( $settings['carousel_autoplay'] ) && ( 'true' == $settings['carousel_autoplay'] ) ) ? true : false; $carousel_animate_out = ( isset( $settings['carousel_animate_out'] ) && ( 'true' == $settings['carousel_animate_out'] ) ) ? true : false; $carousel_mousedrag = ( isset( $settings['carousel_mousedrag'] ) && ( 'true' == $settings['carousel_mousedrag'] ) ) ? $settings['carousel_mousedrag'] : 'false'; $carousel_autowidth = ( isset( $settings['carousel_autowidth'] ) && ( 'true' == $settings['carousel_autowidth'] ) ) ? true : false; $carousel_autoheight = ( isset( $settings['carousel_autoheight'] ) && ( 'true' == $settings['carousel_autoheight'] ) ) ? true : false; // Carousel Data's $carousel_loop = $carousel_loop !== 'true' ? ' data-loop="true"' : ' data-loop="false"'; $carousel_items = $carousel_items ? ' data-items="'. $carousel_items .'"' : ' data-items="5"'; $carousel_margin = $carousel_margin ? ' data-margin="'. $carousel_margin .'"' : ' data-margin="30"'; $carousel_dots = $carousel_dots ? ' data-dots="true"' : ' data-dots="false"'; $carousel_nav = $carousel_nav ? ' data-nav="true"' : ' data-nav="false"'; $carousel_autoplay_timeout = $carousel_autoplay_timeout ? ' data-autoplay-timeout="'. $carousel_autoplay_timeout .'"' : ''; $carousel_autoplay = $carousel_autoplay ? ' data-autoplay="true"' : ''; $carousel_animate_out = $carousel_animate_out ? ' data-animateout="true"' : ''; $carousel_mousedrag = $carousel_mousedrag !== 'true' ? ' data-mouse-drag="true"' : ' data-mouse-drag="false"'; $carousel_autowidth = $carousel_autowidth ? ' data-auto-width="true"' : ''; $carousel_autoheight = $carousel_autoheight ? ' data-auto-height="true"' : ''; $carousel_tablet = $carousel_items_tablet ? ' data-items-tablet="'. $carousel_items_tablet .'"' : ' data-items-tablet="3"'; $carousel_mobile = $carousel_items_mobile ? ' data-items-mobile-landscape="'. $carousel_items_mobile .'"' : ' data-items-mobile-landscape="2"'; $carousel_small_mobile = $carousel_items_mobile ? ' data-items-mobile-portrait="'. $carousel_items_mobile .'"' : ' data-items-mobile-portrait="1"'; // RTL if ( is_rtl() ) { $switch_rtl = ' data-rtl="true"'; } else { $switch_rtl = ' data-rtl="false"'; } // Title $title = $client_section_title ? '<h4 class="partners-title">'.$client_section_title.'</h4>' : ''; $output = '<div class="wndfal-partners"> <div class="container"> '.$title.' <div class="owl-carousel" '. $carousel_loop . $carousel_items . $carousel_margin . $carousel_dots . $carousel_nav . $carousel_autoplay_timeout . $carousel_autoplay . $carousel_animate_out . $carousel_mousedrag . $carousel_autowidth . $carousel_autoheight . $carousel_tablet . $carousel_mobile . $carousel_small_mobile .$switch_rtl.'>'; // Group Param Output if( is_array( $clientLogos_groups ) && !empty( $clientLogos_groups ) ){ foreach ( $clientLogos_groups as $each_logo ) { $client_logo_title = !empty( $each_logo['client_logo_title'] ) ? $each_logo['client_logo_title'] : ''; $image_url = wp_get_attachment_url( $each_logo['client_logo']['id'] ); $client_link_type = !empty($each_logo['client_link_type']) ? $each_logo['client_link_type'] : ''; $image_link = !empty( $each_logo['client_link']['url'] ) ? $each_logo['client_link']['url'] : ''; $image_link_external = !empty( $each_logo['client_link']['is_external'] ) ? 'target="_blank"' : ''; $image_link_nofollow = !empty( $each_logo['client_link']['nofollow'] ) ? 'rel="nofollow"' : ''; $image_link_attr = !empty( $image_link ) ? $image_link_external.' '.$image_link_nofollow : ''; if($image_url){ $att_id = intval( $each_logo['client_logo']['id'] ); $image_path = get_attached_file($att_id); $image_data = file_get_contents($image_path); list($width, $height, $type, $attr) = getimagesizefromstring($image_data); } else { $width = ''; $height = ''; } if($retina_img) { $logo_width = $width/2; $logo_height = $height/2; } else { $logo_width = ''; $logo_height = ''; } $logo_width = $logo_width ? 'width: '.windfall_core_check_px($logo_width).';' : ''; $logo_height = $logo_height ? 'height: '.windfall_core_check_px($logo_height).';' : ''; if($client_link_type === 'popup') { $output .= '<div class="item"><div class="partner-item"><div class="wndfal-image wndfal-popup"><a href="'.esc_url($image_url).'"><img src="'. $image_url .'" alt="'.esc_attr($client_logo_title).'" style="'.esc_attr($logo_width).' '.esc_attr($logo_height).'"></a></div></div></div>'; } else { if (!empty($each_logo['client_link']['url'])) { $output .= '<div class="item"><div class="partner-item"><div class="wndfal-image"><a href="'. $each_logo['client_link']['url'] .'" '. $image_link_attr .'><img src="'. $image_url .'" alt="'.esc_attr($client_logo_title).'" style="'.esc_attr($logo_width).' '.esc_attr($logo_height).'"></a></div></div></div>'; } else { $output .= '<div class="item"><div class="partner-item"><div class="wndfal-image"><span><img src="'. $image_url .'" alt="'.esc_attr($client_logo_title).'" style="'.esc_attr($logo_width).' '.esc_attr($logo_height).'"></span></div></div></div>'; } } } } $output .= '</div></div></div>'; echo $output; } /** * Render Client 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_Client() );