<?php
/**
 *	PLS Widget: Social Links
 */
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}


if ( ! class_exists( 'PLS_Widget_Base' ) ) {
	return;
}

class PLS_Social_Links extends PLS_Widget_Base {

	/**
	 * Constructor.
	 */
	public function __construct() {

		$this->widget_cssclass 		= 'pls-social-link';
        $this->widget_description 	= esc_html__( 'Display social links.', 'modave-core' );
        $this->widget_id 			= 'pls-social-links';
        $this->widget_name 			= esc_html__( 'PLS: Social Links', 'modave-core' );
		$this->settings = array(
            'title' => array(
                'type' 	=> 'text',
                'label' => esc_html__( 'Title:', 'modave-core' ),
				'std' => esc_html__( 'Social', 'modave-core' ),
            ),
			'hide_title' => array(
                'type' 	=> 'checkbox',
                'label' => esc_html__( 'Hide Widget Title?', 'modave-core' ),
                'std' 	=> true,
            ),
			'social_Style' => array(
                'type' => 'select',
                'label' => esc_html__( 'Icons Style:', 'modave-core' ),
                'options' => array(
					'icons-default' 		=> esc_html__( 'Default', 'modave-core' ),	
                    'icons-bordered' 		=> esc_html__( 'Bordered', 'modave-core' ),			
                    'icons-fill-colour' 	=> esc_html__( 'Fill Colour', 'modave-core' ),
                ),
                'std' => 'icons-bordered',
            ),
			'social_icon_size' => array(
                'type' => 'select',
                'label' => esc_html__( 'Icons Size:', 'modave-core' ),
                'options' => array(
                    'icons-size-default'=> esc_html__( 'Default', 'modave-core' ),
					'icons-size-small' 	=> esc_html__( 'Small', 'modave-core' ),
					'icons-size-large' 	=> esc_html__( 'Large', 'modave-core' ),
                ),
                'std' => 'icons-size-default',
            ),
			'social_color' => array(
                'type' => 'select',
                'label' => esc_html__( 'Icons Color (This option works only with the Bordered style).', 'modave-core' ),
                'options' => array(
					'' 	=> esc_html__( 'Default', 'modave-core' ),	
					'icons-color-dark' 		=> esc_html__( 'Dark', 'modave-core' ),	
                    'icons-color-light' 	=> esc_html__( 'Light', 'modave-core' ),
                ),
                'std' => '',
            ),
		);
		parent::__construct();
	}
	
	/**
     * Output widget.
     *
     * @see WP_Widget
     *
     * @param array $args
     * @param array $instance
     */
    public function widget( $args, $instance ){

        ob_start();
		
		$hide_title = ( !empty( $instance['hide_title'] ) ) ? (bool) $instance['hide_title'] : false;
		if( $hide_title ) unset( $instance['title'] );
		
		$this->widget_start( $args, $instance );
		
		do_action( 'pls_core_before_social_links' );
		
		$social_Style 		= ( !empty($instance['social_Style'] ) ) ?  $instance['social_Style'] : 'icons-fill-colour';
		$social_icon_size 	= ( !empty($instance['social_icon_size'] ) ) ?  $instance['social_icon_size'] : 'icons-size-default';
		$social_color 		= ( !empty($instance['social_color'] ) ) ?  $instance['social_color'] : ''; 
		$social_color 		= apply_filters( 'pls_widget_social_icons_color', $social_color );?>
		
		<div class="pls-social-links-widget">
			<?php //Get Social link
			if ( function_exists( 'pls_social_share' ) ){
				pls_social_share( array(
					'type'	=> 'profile',
					'style' => $social_Style,
					'size' 	=> $social_icon_size,
					'color' => $social_color
				) );
			}?>
		</div>
		
		<?php
		do_action( 'pls_core_after_social_links' );

		$this->widget_end($args);

        echo ob_get_clean();
    }
}