<?php
/**
 * Kopa Widget Contact Info
 *
 * @author 		Kopatheme
 * @category 	Widgets
 * @package 	KopaFramework/Widgets
 * @since    	1.0.0
 * @extends 	Kopa_Widget
 */

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

class Kopa_Widget_Contact_Info extends Kopa_Widget {
	/**
	 * Constructor
	 */
	public function __construct() {
		$this->widget_cssclass    = 'kopa-widget-contact-info';
		$this->widget_description = __( 'Display contact info.', 'newmoment' );
		$this->widget_id          = 'kopa-widget-contact-info';
		$this->widget_name        = __( 'Kopa Widget Contact Info', 'newmoment' );
		// $this->widget_width       = 400;
		$this->settings           = array(
			'title'  => array(
				'type'  => 'text',
				'std'   => __( 'Kopa Widget About', 'newmoment' ),
				'label' => __( 'Title:', 'newmoment' )
			)
		);
		parent::__construct();
	}

	/**
	 * widget function.
	 *
	 * @see WP_Widget
	 * @access public
	 * @param array $args
	 * @param array $instance
	 * @return void
	 */
	public function widget( $args, $instance ) {

		if ( $this->get_cached_widget( $args ) )
			return;

		ob_start();
		extract( $args );

		$title       = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );

        $address = get_theme_mod('kopa_address');
        $phone   = get_theme_mod('kopa_phone');
        $fax     = get_theme_mod('kopa_fax');
        $email   = get_theme_mod('kopa_email');
        ?>
            <div class="widget kopa-contact-info-widget">
                <?php if($address != '') : ?>
                <p class="contact-address clearfix"><i class="fa fa-map-marker"></i><strong><?php _e('Address:', 'newmoment');?></strong><span><?php echo $address; ?></span></p>
                <?php endif; ?>
                <?php if($phone != '') : ?>
                <p class="contact-phone clearfix"><i class="fa fa-phone"></i><strong><?php _e('Phone:', 'newmoment');?></strong><a href="calto:<?php echo $phone; ?>"><?php echo $phone; ?></a></p>
                <?php endif; ?>
                <?php if($fax != '') : ?>
                <p class="contact-fax clearfix"><i class="fa fa-fax"></i><strong><?php _e('Fax:', 'newmoment');?></strong><a href="calto:<?php echo $fax; ?>"><?php echo $fax; ?></a></p>
                <?php endif; ?>
                <?php if($email != '') : ?>
                <p class="contact-email clearfix"><i class="fa fa-envelope"></i><strong><?php _e('Email:', 'newmoment');?></strong><a href="mailto:<?php echo $email; ?>"><?php echo $email; ?></a></p>
                <?php endif; ?>
            </div>
            <!-- kopa-contact-info-widget -->
		<?php
		
		$content = ob_get_clean();

		echo $content;

		$this->cache_widget( $args, $content );
	}
}

register_widget( 'Kopa_Widget_Contact_Info' );