
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
<?php
/**
 * Shortcode Facebook Page
 *
 * @link       https://codesupply.co
 * @since      1.0.0
 *
 * @package    Basic Facebook
 */

/**
 * Facebook Page Shortcode
 *
 * @param array  $atts      User defined attributes in shortcode tag.
 * @param string $content   Shorcode tag content.
 * @return string           Shortcode result HTML.
 */
function bfb_facebook_page_shortcode( $atts, $content = '' ) {

	$params = shortcode_atts( array(
		'href'                  => '',
		'hide_cover'            => false,
		'show_facepile'         => false,
		'show_posts'            => false,
		'small_header'          => false,
		'adapt_container_width' => true,
	), $atts );

	$params['hide_cover']            = filter_var( $params['hide_cover'], FILTER_VALIDATE_BOOLEAN );
	$params['show_facepile']         = filter_var( $params['show_facepile'], FILTER_VALIDATE_BOOLEAN );
	$params['show_posts']            = filter_var( $params['show_posts'], FILTER_VALIDATE_BOOLEAN );
	$params['small_header']          = filter_var( $params['small_header'], FILTER_VALIDATE_BOOLEAN );
	$params['adapt_container_width'] = filter_var( $params['adapt_container_width'], FILTER_VALIDATE_BOOLEAN );

	ob_start();

	if ( $params['href'] ) {
	?>
		<div class="fb-page-wrapper">
			<div class="fb-page"
				 data-href="<?php echo esc_attr( $params['href'] ); ?>"
				 data-hide-cover="<?php echo esc_attr( $params['hide_cover'] ); ?>"
				 data-show-facepile="<?php echo esc_attr( $params['show_facepile'] ); ?>"
				 data-show-posts="<?php echo esc_attr( $params['show_posts'] ); ?>"
				 data-small-header="<?php echo esc_attr( $params['small_header'] ); ?>"
				 data-adapt-container-width="<?php echo esc_attr( $params['adapt_container_width'] ); ?>">
			</div>
		</div>
	<?php
	} else {
		?>
		<p class="alert alert-warning">
			<?php esc_html_e( 'The "Facebook Page URL" field is required!', 'basic-facebook' ); ?>
		</p>
		<?php
	}

	return ob_get_clean();
}
add_shortcode( 'basic_facebook_page', 'bfb_facebook_page_shortcode' );

/**
 * Map Facebook Page Shortcode into the Basic Shortcodes Plugin
 */
if ( function_exists( 'bsc_register_shortcode' ) ) :

	bsc_register_shortcode( array(
		'name'			=> 'facebook_page',
		'title'			=> esc_html__( 'Facebook Page', 'basic-facebook' ),
		'priority'		=> 150,
		'base'			=> 'basic_facebook_page',
		'autoregister'	=> false,
		'fields'		=> array(
			array(
				'type'		=> 'input',
				'name'		=> 'href',
				'label'		=> esc_html__( 'Facebook Page URL', 'basic-facebook' ),
			),
			array(
				'type'		=> 'checkbox',
				'name'		=> 'hide_cover',
				'label'		=> esc_html__( 'Hide Cover', 'basic-facebook' ),
				'default'	=> false,
			),
			array(
				'type'		=> 'checkbox',
				'name'		=> 'show_facepile',
				'label'		=> esc_html__( 'Show Facepile', 'basic-facebook' ),
				'default'	=> false,
			),
			array(
				'type'		=> 'checkbox',
				'name'		=> 'show_posts',
				'label'		=> esc_html__( 'Show Posts', 'basic-facebook' ),
				'default'	=> false,
			),
			array(
				'type'		=> 'checkbox',
				'name'		=> 'small_header',
				'label'		=> esc_html__( 'Small Header', 'basic-facebook' ),
				'default'	=> false,
			),
		),
	) );

endif;
