<?php
namespace EcafeAddons\Widgets;

use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Utils;
use Elementor\Group_Control_Typography;
use Elementor\Core\Schemes\Typography;
use Elementor\Scheme_Color;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Background;
use Elementor\Group_Control_Box_Shadow;
use EcafeAddons\EcafeElementLoad;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

class Ecafe_Facebook_Embed extends Widget_Base {

	public function get_name() {
		return 'ecafe-facebook-embed';
	}

	public function get_title() {
		return esc_html__( 'Facebook Embed', 'essential-classy-addons-for-elementor' );
	}

	public function get_icon() {
		return 'ecafe-ele-back-icon ecafe-facebook-embed-icon';
	}

	public function get_categories() {
		return array( 'ecembed' );
	}

	public function get_keywords() {
		return array( 'facebook embed', 'embed', 'fb', 'facebook' );
	}
	public function get_custom_help_url() {
		return 'https://store.kapasias.com/helpdesk/';
	}
	public function has_widget_inner_wrapper(): bool {
		return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
	}
	protected function register_controls() {

		$this->start_controls_section(
			'contentSection',
			array(
				'label' => esc_html__( 'Facebook Embed', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);
		$this->add_control(
			'type',
			array(
				'label'   => esc_html__( 'Type', 'essential-classy-addons-for-elementor' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'posts',
				'options' => array(
					'posts'  => esc_html__( 'Posts', 'essential-classy-addons-for-elementor' ),
					'page'   => esc_html__( 'Page', 'essential-classy-addons-for-elementor' ),
					'videos' => esc_html__( 'Videos', 'essential-classy-addons-for-elementor' ),
					'like'   => esc_html__( 'Like', 'essential-classy-addons-for-elementor' ),
					'save'   => esc_html__( 'Save', 'essential-classy-addons-for-elementor' ),
					'share'  => esc_html__( 'Share', 'essential-classy-addons-for-elementor' ),
				),
			)
		);
		$this->add_control(
			'postUrl',
			array(
				'label'         => __( 'Post URL', 'essential-classy-addons-for-elementor' ),
				'type'          => Controls_Manager::URL,
				'placeholder'   => __( 'Enter Post URL', 'essential-classy-addons-for-elementor' ),
				'show_external' => true,
				'dynamic'       => array( 'active' => true ),
				'default'       => array(
					'url'         => 'https://www.facebook.com/elemntor/posts/pfbid042FUTN7GPrjqgzrRopTLiZGfnr8xhWyhsnuyBhRG1SPAfaEghTZjGTBtXNS9yNKYl',
					'is_external' => true,
					'nofollow'    => true,
				),
				'condition'     => array(
					'type' => 'posts',
				),
			)
		);
		$this->add_control(
			'videoUrl',
			array(
				'label'         => __( 'Video URL', 'essential-classy-addons-for-elementor' ),
				'type'          => Controls_Manager::URL,
				'placeholder'   => __( 'Enter Video URL', 'essential-classy-addons-for-elementor' ),
				'show_external' => true,
				'dynamic'       => array( 'active' => true ),
				'default'       => array(
					'url'         => 'https://www.facebook.com/elemntor/videos/967372490905433',
					'is_external' => true,
					'nofollow'    => true,
				),
				'condition'     => array(
					'type' => 'videos',
				),
			)
		);
		$this->add_control(
			'pageUrl',
			array(
				'label'         => __( 'Page URL', 'essential-classy-addons-for-elementor' ),
				'type'          => Controls_Manager::URL,
				'placeholder'   => __( 'Enter Page URL', 'essential-classy-addons-for-elementor' ),
				'show_external' => true,
				'dynamic'       => array( 'active' => true ),
				'default'       => array(
					'url'         => 'https://www.facebook.com/elemntor/',
					'is_external' => true,
					'nofollow'    => true,
				),
				'condition'     => array(
					'type' => 'page',
				),
			)
		);
		$this->add_control(
			'targetUrl',
			array(
				'label'     => esc_html__( 'Target URL', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'custom',
				'options'   => array(
					'currentpage' => esc_html__( 'Current Page', 'essential-classy-addons-for-elementor' ),
					'custom'      => esc_html__( 'Custom Page', 'essential-classy-addons-for-elementor' ),
				),
				'condition' => array(
					'type' => 'like',
				),
				'separator' => 'before',
			)
		);
		$this->add_control(
			'permalinkFormate',
			array(
				'label'     => esc_html__( 'Permalink Format', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'plain',
				'options'   => array(
					'plain'  => esc_html__( 'Plain', 'essential-classy-addons-for-elementor' ),
					'pretty' => esc_html__( 'Pretty', 'essential-classy-addons-for-elementor' ),
				),
				'condition' => array(
					'type'      => 'like',
					'targetUrl' => 'currentpage',
				),
			)
		);
		$this->add_control(
			'likeUrl',
			array(
				'label'         => __( 'Like Button URL', 'essential-classy-addons-for-elementor' ),
				'type'          => Controls_Manager::URL,
				'placeholder'   => __( 'Enter Like Button Url', 'essential-classy-addons-for-elementor' ),
				'show_external' => true,
				'dynamic'       => array( 'active' => true ),
				'default'       => array(
					'url'         => 'https://www.facebook.com/elemntor/',
					'is_external' => true,
					'nofollow'    => true,
				),
				'condition'     => array(
					'type'      => 'like',
					'targetUrl' => 'custom',
				),
			)
		);
		$this->add_control(
			'saveUrl',
			array(
				'label'         => __( 'Save URL', 'essential-classy-addons-for-elementor' ),
				'type'          => Controls_Manager::URL,
				'placeholder'   => __( 'Enter Save Url', 'essential-classy-addons-for-elementor' ),
				'show_external' => true,
				'dynamic'       => array( 'active' => true ),
				'default'       => array(
					'url'         => 'https://www.facebook.com/',
					'is_external' => true,
					'nofollow'    => true,
				),
				'condition'     => array(
					'type' => 'save',
				),
			)
		);
		$this->add_control(
			'shareUrl',
			array(
				'label'         => __( 'Share URL', 'essential-classy-addons-for-elementor' ),
				'type'          => Controls_Manager::URL,
				'placeholder'   => __( 'Enter Share Url', 'essential-classy-addons-for-elementor' ),
				'show_external' => true,
				'dynamic'       => array( 'active' => true ),
				'default'       => array(
					'url'         => 'https://www.facebook.com/',
					'is_external' => true,
					'nofollow'    => true,
				),
				'condition'     => array(
					'type' => 'share',
				),
			)
		);
		$this->add_control(
			'facebookDeveloperOpt',
			array(
				'type'            => Controls_Manager::RAW_HTML,
				'raw'             => 'Note : <a href="https://developers.facebook.com/docs/plugins"  target="_blank" rel="noopener noreferrer">Facebook Developer Options</a>',
				'content_classes' => 'ec-description-note',
			)
		);
		$this->add_responsive_control(
			'ecfeWidth',
			array(
				'type'        => Controls_Manager::SLIDER,
				'label'       => esc_html__( 'Width', 'essential-classy-addons-for-elementor' ),
				'size_units'  => array( 'px' ),
				'range'       => array(
					'px' => array(
						'min'  => 0,
						'max'  => 1000,
						'step' => 1,
					),
				),
				'render_type' => 'ui',
				'condition'   => array(
					'type' => 'posts',
				),
				'selectors'   => array(
					'{{WRAPPER}} .ec-social-embed iframe.ec-social-embed-fb-iframe' => 'width: {{SIZE}}{{UNIT}}',
				),
				'separator'   => 'before',
			)
		);
		$this->add_responsive_control(
			'ecfeHeight',
			array(
				'type'        => Controls_Manager::SLIDER,
				'label'       => esc_html__( 'Height', 'essential-classy-addons-for-elementor' ),
				'size_units'  => array( 'px' ),
				'range'       => array(
					'px' => array(
						'min'  => 0,
						'max'  => 1000,
						'step' => 1,
					),
				),
				'render_type' => 'ui',
				'condition'   => array(
					'type' => 'posts',
				),
				'selectors'   => array(
					'{{WRAPPER}} .ec-social-embed iframe.ec-social-embed-fb-iframe' => 'height: {{SIZE}}{{UNIT}}',
				),
			)
		);
		$this->add_responsive_control(
			'videoWidth',
			array(
				'type'        => Controls_Manager::SLIDER,
				'label'       => esc_html__( 'Width', 'essential-classy-addons-for-elementor' ),
				'size_units'  => array( 'px' ),
				'range'       => array(
					'px' => array(
						'min'  => 0,
						'max'  => 1000,
						'step' => 1,
					),
				),
				'render_type' => 'ui',
				'condition'   => array(
					'type' => 'videos',
				),
				'selectors'   => array(
					'{{WRAPPER}} .ec-social-embed iframe.ec-social-embed-fb-iframe' => 'width: {{SIZE}}{{UNIT}}',
				),
				'separator'   => 'before',
			)
		);
		$this->add_responsive_control(
			'videoHeight',
			array(
				'type'        => Controls_Manager::SLIDER,
				'label'       => esc_html__( 'Height', 'essential-classy-addons-for-elementor' ),
				'size_units'  => array( 'px' ),
				'range'       => array(
					'px' => array(
						'min'  => 0,
						'max'  => 1000,
						'step' => 1,
					),
				),
				'render_type' => 'ui',
				'condition'   => array(
					'type' => 'videos',
				),
				'selectors'   => array(
					'{{WRAPPER}} .ec-social-embed iframe.ec-social-embed-fb-iframe' => 'height: {{SIZE}}{{UNIT}}',
				),
			)
		);
		$this->add_control(
			'pageTabs',
			array(
				'label'     => esc_html__( 'Tabs', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'timeline',
				'options'   => array(
					'timeline' => esc_html__( 'Timeline', 'essential-classy-addons-for-elementor' ),
					'events'   => esc_html__( 'Events', 'essential-classy-addons-for-elementor' ),
					'messages' => esc_html__( 'Messages', 'essential-classy-addons-for-elementor' ),
				),
				'condition' => array(
					'type' => 'page',
				),
			)
		);
		$this->add_control(
			'coverPhoto',
			array(
				'label'     => esc_html__( 'Hide Cover Photo', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'default'   => 'yes',
				'condition' => array(
					'type' => 'page',
				),
			)
		);
		$this->add_responsive_control(
			'pageWidth',
			array(
				'type'        => Controls_Manager::SLIDER,
				'label'       => esc_html__( 'Width', 'essential-classy-addons-for-elementor' ),
				'size_units'  => array( 'px' ),
				'range'       => array(
					'px' => array(
						'min'  => 0,
						'max'  => 1000,
						'step' => 1,
					),
				),
				'render_type' => 'ui',
				'condition'   => array(
					'type' => 'page',
				),
				'selectors'   => array(
					'{{WRAPPER}} .ec-social-embed iframe.ec-social-embed-fb-iframe' => 'width: {{SIZE}}{{UNIT}}',
				),
				'separator'   => 'before',
			)
		);
		$this->add_responsive_control(
			'pageHeight',
			array(
				'type'        => Controls_Manager::SLIDER,
				'label'       => esc_html__( 'Height', 'essential-classy-addons-for-elementor' ),
				'size_units'  => array( 'px' ),
				'range'       => array(
					'px' => array(
						'min'  => 0,
						'max'  => 1000,
						'step' => 1,
					),
				),
				'render_type' => 'ui',
				'condition'   => array(
					'type' => 'page',
				),
				'selectors'   => array(
					'{{WRAPPER}} .ec-social-embed iframe.ec-social-embed-fb-iframe' => 'height: {{SIZE}}{{UNIT}}',
				),
			)
		);
		$this->add_control(
			'sizeButton',
			array(
				'label'     => esc_html__( 'Button Size', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'small',
				'options'   => array(
					'small' => esc_html__( 'Small', 'essential-classy-addons-for-elementor' ),
					'large' => esc_html__( 'Large', 'essential-classy-addons-for-elementor' ),
				),
				'condition' => array(
					'type' => array( 'like', 'save', 'share' ),
				),
			)
		);
		$this->add_control(
			'actionType',
			array(
				'label'     => esc_html__( 'Action Type', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'like',
				'options'   => array(
					'like'      => esc_html__( 'Like', 'essential-classy-addons-for-elementor' ),
					'recommend' => esc_html__( 'Recommend', 'essential-classy-addons-for-elementor' ),
				),
				'condition' => array(
					'type' => 'like',
				),
			)
		);
		$this->add_control(
			'buttonLayout',
			array(
				'label'     => esc_html__( 'Like Button', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'button',
				'options'   => array(
					'standard'     => esc_html__( 'Standard', 'essential-classy-addons-for-elementor' ),
					'button'       => esc_html__( 'Button', 'essential-classy-addons-for-elementor' ),
					'button_count' => esc_html__( 'Button Count', 'essential-classy-addons-for-elementor' ),
					'box_count'    => esc_html__( 'Box Count', 'essential-classy-addons-for-elementor' ),
				),
				'condition' => array(
					'type' => 'like',
				),
			)
		);
		$this->add_control(
			'colorScheme',
			array(
				'label'     => esc_html__( 'Color Scheme', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'light',
				'options'   => array(
					'light' => esc_html__( 'Light', 'essential-classy-addons-for-elementor' ),
					'dark'  => esc_html__( 'Dark', 'essential-classy-addons-for-elementor' ),
				),
				'condition' => array(
					'type'         => 'like',
					'buttonLayout' => 'standard',
				),
			)
		);
		$this->add_control(
			'shareButton',
			array(
				'label'     => esc_html__( 'Share Button', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'default'   => 'no',
				'condition' => array(
					'type' => 'like',
				),
			)
		);
		$this->add_responsive_control(
			'likeWidth',
			array(
				'type'        => Controls_Manager::SLIDER,
				'label'       => esc_html__( 'Width', 'essential-classy-addons-for-elementor' ),
				'size_units'  => array( 'px' ),
				'range'       => array(
					'px' => array(
						'min'  => 0,
						'max'  => 1000,
						'step' => 1,
					),
				),
				'render_type' => 'ui',
				'condition'   => array(
					'type' => 'like',
				),
				'selectors'   => array(
					'{{WRAPPER}} .ec-social-embed iframe.ec-social-embed-fb-iframe' => 'width: {{SIZE}}{{UNIT}}',
				),
				'separator'   => 'before',
			)
		);
		$this->add_responsive_control(
			'likeHeight',
			array(
				'type'        => Controls_Manager::SLIDER,
				'label'       => esc_html__( 'Height', 'essential-classy-addons-for-elementor' ),
				'size_units'  => array( 'px' ),
				'range'       => array(
					'px' => array(
						'min'  => 0,
						'max'  => 200,
						'step' => 1,
					),
				),
				'render_type' => 'ui',
				'condition'   => array(
					'type' => 'like',
				),
				'selectors'   => array(
					'{{WRAPPER}} .ec-social-embed iframe.ec-social-embed-fb-iframe' => 'height: {{SIZE}}{{UNIT}}',
				),
			)
		);
		$this->add_control(
			'shareButtonLayout',
			array(
				'label'     => esc_html__( 'Layout', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'button',
				'options'   => array(
					'button'       => esc_html__( 'Button', 'essential-classy-addons-for-elementor' ),
					'button_count' => esc_html__( 'Button Count', 'essential-classy-addons-for-elementor' ),
					'box_count'    => esc_html__( 'Box Count', 'essential-classy-addons-for-elementor' ),
				),
				'condition' => array(
					'type' => 'share',
				),
			)
		);
		$this->add_responsive_control(
			'shareButtonWidth',
			array(
				'type'        => Controls_Manager::SLIDER,
				'label'       => esc_html__( 'Width', 'essential-classy-addons-for-elementor' ),
				'size_units'  => array( 'px' ),
				'range'       => array(
					'px' => array(
						'min'  => 0,
						'max'  => 1000,
						'step' => 1,
					),
				),
				'render_type' => 'ui',
				'condition'   => array(
					'type' => 'share',
				),
				'selectors'   => array(
					'{{WRAPPER}} .ec-social-embed iframe.ec-social-embed-fb-iframe' => 'width: {{SIZE}}{{UNIT}}',
				),
				'separator'   => 'before',
			)
		);
		$this->add_responsive_control(
			'shareButtonHeight',
			array(
				'type'        => Controls_Manager::SLIDER,
				'label'       => esc_html__( 'Height', 'essential-classy-addons-for-elementor' ),
				'size_units'  => array( 'px' ),
				'range'       => array(
					'px' => array(
						'min'  => 0,
						'max'  => 100,
						'step' => 1,
					),
				),
				'render_type' => 'ui',
				'condition'   => array(
					'type' => 'share',
				),
				'selectors'   => array(
					'{{WRAPPER}} .ec-social-embed iframe.ec-social-embed-fb-iframe' => 'height: {{SIZE}}{{UNIT}}',
				),
			)
		);
		$this->end_controls_section();

		/*Notice panel*/
		$ecwidgetdemolink = esc_url( 'https://ecaddons.com/elements/facebook-embed/' );
		$ecwidgetdoclink  = esc_url( 'https://ecaddons.com/docs/facebook-embed-widget-tutorial/' );
		include ECAFE_PATH . 'element/widgets/ecafe-widgetpanel-help.php';

		/*Embed Options Style Start*/
		$this->start_controls_section(
			'sectionStyling',
			array(
				'label' => esc_html__( 'Facebook Embed', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);
		$this->add_responsive_control(
			'alignment',
			array(
				'label'     => esc_html__( 'Content Alignment', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::CHOOSE,
				'default'   => 'center',
				'options'   => array(
					'left'   => array(
						'title' => esc_html__( 'Left', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-left',
					),
					'center' => array(
						'title' => esc_html__( 'Center', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-center',
					),
					'right'  => array(
						'title' => esc_html__( 'Right', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-right',
					),
				),
				'selectors' => array(
					'{{WRAPPER}} .ec-social-embed' => 'text-align: {{VALUE}}',
				),
			)
		);
		$this->start_controls_tabs( 'tabsFb' );
		$this->start_controls_tab(
			'tabFbNormal',
			array(
				'label'     => esc_html__( 'Normal', 'essential-classy-addons-for-elementor' ),
				'condition' => array(
					'type' => array( 'posts', 'videos', 'page' ),
				),
			)
		);
		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'      => 'fbBorder',
				'label'     => esc_html__( 'Border', 'essential-classy-addons-for-elementor' ),
				'selector'  => '{{WRAPPER}} .ec-social-embed-fb-iframe,{{WRAPPER}} .tw-button',
				'condition' => array(
					'type' => array( 'posts', 'videos', 'page' ),
				),
			)
		);
		$this->add_responsive_control(
			'fbBorderR',
			array(
				'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-social-embed-fb-iframe,{{WRAPPER}} .tw-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
				'condition'  => array(
					'type' => array( 'posts', 'videos', 'page' ),
				),
			)
		);
		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'      => 'fbBoxshadow',
				'selector'  => '{{WRAPPER}} .ec-social-embed-fb-iframe,{{WRAPPER}} .tw-button',
				'condition' => array(
					'type' => array( 'posts', 'videos', 'page' ),
				),
			)
		);
		$this->end_controls_tab();
		$this->start_controls_tab(
			'tabFbHover',
			array(
				'label'     => esc_html__( 'Hover', 'essential-classy-addons-for-elementor' ),
				'condition' => array(
					'type' => array( 'posts', 'videos', 'page' ),
				),
			)
		);
		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'      => 'fbBorderH',
				'label'     => esc_html__( 'Border', 'essential-classy-addons-for-elementor' ),
				'selector'  => '{{WRAPPER}} .ec-social-embed-fb-iframe:hover,{{WRAPPER}} .tw-button:hover',
				'condition' => array(
					'type' => array( 'posts', 'videos', 'page' ),
				),
			)
		);
		$this->add_responsive_control(
			'fbBorderRH',
			array(
				'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-social-embed-fb-iframe:hover,{{WRAPPER}} .tw-button:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
				'condition'  => array(
					'type' => array( 'posts', 'videos', 'page' ),
				),
			)
		);
		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'      => 'fbBoxshadowH',
				'selector'  => '{{WRAPPER}} .ec-social-embed-fb-iframe:hover,{{WRAPPER}} .tw-button:hover',
				'condition' => array(
					'type' => array( 'posts', 'videos', 'page' ),
				),
			)
		);
		$this->end_controls_tab();
		$this->end_controls_tabs();

		$this->add_control(
			'outerBg',
			array(
				'label'     => esc_html__( 'Background', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
			)
		);
		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'     => 'fbBg',
				'types'    => array( 'classic', 'gradient' ),
				'selector' => '{{WRAPPER}} .ec-social-embed',
			)
		);
		$this->end_controls_section();
		/*Embed Options Style End*/
	}

	protected function render() {

		$settings       = $this->get_settings_for_display();
			$type       = ! empty( $settings['type'] ) ? $settings['type'] : '';
			$sizeButton = ! empty( $settings['sizeButton'] ) ? $settings['sizeButton'] : '';

		if ( ! empty( $type ) ) {
			$output                = '<div class="ec-social-embed">';
				$scrolling         = ' scrolling="no"';
				$frameborder       = ' frameborder="0"';
				$allowTransparency = ' allowTransparency="true"';
				$allow             = ' allow="encrypted-media"';
			if ( $type == 'posts' ) {
				$postUrl    = ! empty( $settings['postUrl'] ) && ! empty( $settings['postUrl']['url'] ) ? $settings['postUrl']['url'] : '';
				$ecfeWidth  = ! empty( $settings['ecfeWidth']['size'] ) ? $settings['ecfeWidth']['size'] : 450;
				$ecfeHeight = ! empty( $settings['ecfeHeight']['size'] ) ? $settings['ecfeHeight']['size'] : 550;
				$output    .= '<iframe class="ec-social-embed-fb-iframe" src="https://www.facebook.com/plugins/post.php?href=' . esc_url( $postUrl ) . '&width=' . esc_attr( $ecfeWidth ) . '&height=' . esc_attr( $ecfeHeight ) . '" width="' . esc_attr( $ecfeWidth ) . '" height="' . esc_attr( $ecfeHeight ) . '" ' . esc_attr( $scrolling ) . ' ' . esc_attr( $frameborder ) . ' ' . esc_attr( $allowTransparency ) . ' ' . esc_attr( $allow ) . ' ></iframe>';
			} elseif ( $type == 'page' ) {
						$pageUrl    = ! empty( $settings['pageUrl'] ) && ! empty( $settings['pageUrl']['url'] ) ? $settings['pageUrl']['url'] : '';
						$pageWidth  = ! empty( $settings['pageWidth']['size'] ) ? $settings['pageWidth']['size'] : 300;
						$pageHeight = ! empty( $settings['pageHeight']['size'] ) ? $settings['pageHeight']['size'] : 500;

						$coverPhoto = false;
				if ( isset( $settings['coverPhoto'] ) && $settings['coverPhoto'] == 'yes' ) {
					$coverPhoto = true;
				}
						$output .= '<iframe class="ec-social-embed-fb-iframe" src="https://www.facebook.com/plugins/page.php?href=' . esc_url( $pageUrl ) . '&tabs=' . esc_attr( $settings['pageTabs'] ) . '&width=' . esc_attr( $pageWidth ) . '&height=' . esc_attr( $pageHeight ) . '&hide_cover=' . esc_attr( $coverPhoto ) . '&lazy=true&adapt_container_width=true" width="' . esc_attr( $pageWidth ) . '" height="' . esc_attr( $pageHeight ) . '" ' . esc_attr( $scrolling ) . ' ' . esc_attr( $frameborder ) . ' ' . esc_attr( $allowTransparency ) . ' ' . esc_attr( $allow ) . ' ></iframe>';
			} elseif ( $type == 'videos' ) {
				$videoUrl    = ! empty( $settings['videoUrl'] ) && ! empty( $settings['videoUrl']['url'] ) ? $settings['videoUrl']['url'] : '';
				$videoWidth  = ! empty( $settings['videoWidth']['size'] ) ? $settings['videoWidth']['size'] : 400;
				$videoHeight = ! empty( $settings['videoHeight']['size'] ) ? $settings['videoHeight']['size'] : 550;

				$output .= '<iframe class="ec-social-embed-fb-iframe" src="https://www.facebook.com/plugins/video.php?href=' . esc_url( $videoUrl ) . '&width=' . esc_attr( $videoWidth ) . '&height=' . esc_attr( $videoHeight ) . '" width="' . esc_attr( $videoWidth ) . '" height="' . esc_attr( $videoHeight ) . '" ' . esc_attr( $scrolling ) . ' ' . esc_attr( $frameborder ) . ' ' . esc_attr( $allowTransparency ) . ' ' . esc_attr( $allow ) . '></iframe>';
			} elseif ( $type == 'like' ) {
				$likeUrl = ! empty( $settings['likeUrl'] ) && ! empty( $settings['likeUrl']['url'] ) ? $settings['likeUrl']['url'] : '';

				$likeHeight  = ! empty( $settings['likeHeight']['size'] ) ? $settings['likeHeight']['size'] : 100;
				$likeWidth   = ! empty( $settings['likeWidth']['size'] ) ? $settings['likeWidth']['size'] : 250;
				$shareButton = false;
				if ( isset( $settings['shareButton'] ) && $settings['shareButton'] == 'yes' ) {
					$shareButton = true;
				}
				if ( $settings['targetUrl'] == 'currentpage' ) {
					$permalinkFormate = ! empty( $settings['permalinkFormate'] ) ? $settings['permalinkFormate'] : 'plain';
					$post_id          = get_the_ID();
					if ( $permalinkFormate == 'plain' ) {
						$plain   = get_permalink( $post_id );
						$output .= '<iframe class="ec-social-embed-fb-iframe" src="https://www.facebook.com/plugins/like.php?href=' . esc_url( $plain ) . '&layout=' . esc_attr( $settings['buttonLayout'] ) . '&action=' . esc_attr( $settings['actionType'] ) . '&size=' . esc_attr( $sizeButton ) . '&share=' . esc_attr( $shareButton ) . '&height=' . esc_attr( $likeHeight ) . '&colorscheme=' . esc_attr( $settings['colorScheme'] ) . '&width=' . esc_attr( $likeWidth ) . '" width="' . esc_attr( $likeWidth ) . '" height="' . esc_attr( $likeHeight ) . '" ' . esc_attr( $scrolling ) . ' ' . esc_attr( $frameborder ) . ' ' . esc_attr( $allowTransparency ) . ' ' . esc_attr( $allow ) . '></iframe>';
					} elseif ( $permalinkFormate == 'pretty' ) {
						$pretty  = add_query_arg( 'p', $post_id, home_url() );
						$output .= '<iframe class="ec-social-embed-fb-iframe" src="https://www.facebook.com/plugins/like.php?href=' . esc_url( $pretty ) . '&layout=' . esc_attr( $settings['buttonLayout'] ) . '&action=' . esc_attr( $settings['actionType'] ) . '&size=' . esc_attr( $sizeButton ) . '&share=' . esc_attr( $shareButton ) . '&height=' . esc_attr( $likeHeight ) . '&colorscheme=' . esc_attr( $settings['colorScheme'] ) . '&width=' . esc_attr( $likeWidth ) . '" width="' . esc_attr( $likeWidth ) . '" height="' . esc_attr( $likeHeight ) . '" ' . esc_attr( $scrolling ) . ' ' . esc_attr( $frameborder ) . ' ' . esc_attr( $allowTransparency ) . ' ' . esc_attr( $allow ) . '></iframe>';
					}
				} else {
					$output .= '<iframe class="ec-social-embed-fb-iframe" src="https://www.facebook.com/plugins/like.php?href=' . esc_url( $likeUrl ) . '&layout=' . esc_attr( $settings['buttonLayout'] ) . '&action=' . esc_attr( $settings['actionType'] ) . '&size=' . esc_attr( $sizeButton ) . '&share=' . esc_attr( $shareButton ) . '&height=' . esc_attr( $likeHeight ) . '&colorscheme=' . esc_attr( $settings['colorScheme'] ) . '&width=' . esc_attr( $likeWidth ) . '" width="' . esc_attr( $likeWidth ) . '" height="' . esc_attr( $likeHeight ) . '" ' . esc_attr( $scrolling ) . ' ' . esc_attr( $frameborder ) . ' ' . esc_attr( $allowTransparency ) . ' ' . esc_attr( $allow ) . '></iframe>';
				}
			} elseif ( $type == 'save' ) {
				$saveUrl = ! empty( $settings['saveUrl'] ) && ! empty( $settings['saveUrl']['url'] ) ? $settings['saveUrl']['url'] : '';
				$output .= '<div class="fb-save" data-uri="' . esc_url( $saveUrl ) . '" data-size="' . esc_attr( $sizeButton ) . '"></div>';
				$output .= '<script async defer src="https://connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v15.0"></script>';
			} elseif ( $type == 'share' ) {
				$shareUrl          = ! empty( $settings['shareUrl'] ) && ! empty( $settings['shareUrl']['url'] ) ? $settings['shareUrl']['url'] : '';
				$shareButtonHeight = ! empty( $settings['shareButtonHeight']['size'] ) ? $settings['shareButtonHeight']['size'] : 50;
				$shareButtonWidth  = ! empty( $settings['shareButtonWidth']['size'] ) ? $settings['shareButtonWidth']['size'] : 100;
				$output           .= '<iframe class="ec-social-embed-fb-iframe" src="https://www.facebook.com/plugins/share_button.php?href=' . esc_url( $shareUrl ) . '&layout=' . esc_attr( $settings['shareButtonLayout'] ) . '&size=' . esc_attr( $sizeButton ) . '&width=' . esc_attr( $shareButtonWidth ) . '&height=' . esc_attr( $shareButtonHeight ) . '" width="' . esc_attr( $shareButtonWidth ) . '" height="' . esc_attr( $shareButtonHeight ) . '" ' . esc_attr( $scrolling ) . ' ' . esc_attr( $frameborder ) . ' ' . esc_attr( $allowTransparency ) . ' ' . esc_attr( $allow ) . '></iframe>';
			}
					$output .= '</div>';
		}

		echo $output;
	}
}
