<?php
/**
 * Elements Shortcode
 *
 * @package All In One Custom Post
 * @since All In One Custom Post 1.0.0 
 */
if ( !defined( 'ABSPATH' ) ) exit;

// Row Shortcode
function aio_shortcode_row( $atts, $content = null ) {
	
	extract( shortcode_atts( array(
		'column'	=> 'col-sm-6 col-md-6',
		'style'		=> ''
	), $atts ) );

	$html = '<div class="row row-equal">' . do_shortcode( $content ) . '</div>';

	return $html;
}
add_shortcode( 'shortcode_row', 'aio_shortcode_row' );

// Column Shortcode
function aio_shortcode_column( $atts, $content = null ) {

	extract( shortcode_atts( array(
		'column'	=> 'col-sm-6 col-md-6',
		'style'		=> '',
		'animation'	=> '',
		'ani'		=> ''
	), $atts ) );
	
	if ( $style != '' ) { $style = 'style="' . $style . '"'; }
	if ( $animation != '' ) { $animation = 'data-animation="' . esc_attr( $animation ) . '"'; $ani = 'fx-start'; }

	$html = '<div class="column column-equal ' . esc_attr( $column ) . ' ' . sanitize_html_class( $ani )  . '" ' . $animation  . ' ' . $style . '>' . do_shortcode( $content ) . '</div>';

	return $html;
}
add_shortcode( 'shortcode_column', 'aio_shortcode_column' );

// Text Shortcode
function aio_shortcode_text( $atts, $content = null ) {

	extract( shortcode_atts( array(
		'style'		=> '',
		'ani' 		=> '',
		'animation' => ''
	), $atts ) );
	
	if ( $style != '' ) { $style = 'style="' . $style . '"'; }
	if ( $animation != '' ) { $animation = 'data-animation="' . esc_attr( $animation ) . '"'; $ani = 'fx-start'; }

	$html = '<article class="text clearfix ' . sanitize_html_class( $ani ) . '" ' . $animation . ' ' . $style . '>' . do_shortcode( $content ) . '</article>';

	return $html;
}
add_shortcode( 'shortcode_text', 'aio_shortcode_text' );

// Text Image Shortcode
function aio_shortcode_list_picture( $atts ) {

	extract( shortcode_atts( array(
		'module'	=> '',
		'picture'	=> '',
		'title'		=> '',
		'content'	=> 'false'
	), $atts ));


	$html = '<div class="list-picture-left">
		<div class="list-picture">
			<img src="' . esc_url( $picture )  . '" width="86" height="86" />
		</div>
		<div class="list-picture-content">
			<h3>' . wp_strip_all_tags( $title )  . '</h3>
			<p>' . wp_strip_all_tags( $content )  . '</p>
		</div>
	</div>';
		
	return $html;
}
add_shortcode( 'shortcode_list_picture', 'aio_shortcode_list_picture' );


// Text Icon Shortcode
function aio_shortcode_text_icon( $atts ) {

	extract( shortcode_atts( array(
		'module'	=> '',
		'icon'		=> 'fa-plus',
		'title'		=> '',
		'content'	=> 'false'
	), $atts ));


	$html = '<div class="text-icon-left">
		<div class="text-icon">
			<i class="fa ' . esc_attr( $icon )  . '"></i>
		</div>
		<div class="text-icon-content">
			<h3>' . wp_strip_all_tags( $title )  . '</h3>
			<p>' . wp_strip_all_tags( $content )  . '</p>
		</div>
	</div>';
		
	return $html;
}
add_shortcode( 'shortcode_text_icon', 'aio_shortcode_text_icon' );

// Shortcode Picture
function aio_shortcode_picture( $atts ) {

	extract( shortcode_atts( array(
		'src'		=> '',
		'width'		=> '',
		'height'	=> '',
		'crop'		=> 'false',
		'alt'		=> 'picture',
		'ani' 		=> '',
		'animation' => ''
	), $atts ));

	if ( $animation != '' ) { $animation = 'data-animation="' . esc_attr( $animation ) . '"'; $ani = 'fx-start'; }

	if ($crop == 'true' ) {
		$html = '<img src="' . esc_url( aq_resize( esc_url( $src ), esc_attr( $width ), esc_attr( $height ), true, true, true ) ) . '" class="' . sanitize_html_class( $ani ) . '" "' . $animation . ' alt="' . esc_attr( $alt ) . '" />';
	} else {
		$html = '<img src="' . esc_url( $src ) . '" class="' . sanitize_html_class( $ani ) . '" ' . $animation . ' alt="' . esc_attr( $alt ) . '" />';
	}
		
	return $html;
}
add_shortcode( 'shortcode_picture', 'aio_shortcode_picture' );

// Banner Shortcode
function aio_shortcode_banner( $atts ) {

	extract( shortcode_atts( array(
		'caption'	=> '',
		'content'	=> '',
		'module'	=> '',
		'ani' 		=> '',
		'animation'	=> ''
	), $atts ) );

	if ( $animation != '' ) { $animation = 'data-animation="' . esc_attr( $animation ) . '"'; $ani = 'fx-start'; }
	ob_start(); ?>
	
	<?php if ( $module == 'left' ) : ?>

		<article class="banner-left clearfix <?php echo sanitize_html_class( $ani ); ?>" <?php echo $animation; ?>>
			<div class="banner-head">
				<h2><?php echo wp_filter_kses( $caption ); ?></h2>
				<?php if ( $content != '' ) : ?>
					<p><?php echo wp_filter_kses( $content ); ?></p>
				<?php endif; ?>
			</div>
			<div class="banner-foot">
				<?php echo do_shortcode( $button ); ?>
			</div>
		</article>
		
	<?php else : ?>
	
		<article class="banner-center clearfix <?php echo sanitize_html_class( $ani ); ?>" <?php echo $animation; ?>>
			<div class="banner-inner">
				<h2><?php echo wp_filter_kses( $caption ); ?></h2>
				<?php if ( $content != '' ) : ?>
					<p><?php echo wp_filter_kses( $content ); ?></p>
				<?php endif; ?>
				<?php echo do_shortcode( $button ); ?>
			</div>
		</article>

	<?php endif; ?>
	
	<?php
	$html = ob_get_clean();
	return $html;
}
add_shortcode( 'shortcode_banner', 'aio_shortcode_banner' );

// Shortcode Social Media
function aio_social_media( $atts ) {

	extract( shortcode_atts( array(
		'module'	=> '',
		'caption'	=> 'Connect with us on <strong>World Wide Web</strong>',
		'facebook' 	=> '',
		'twitter' 	=> '',
		'google' 	=> '',
		'linkedin' 	=> '',
		'youtube' 	=> '',
		'email' 	=> '',
		'ani' 		=> '',
		'animation'	=> ''
	), $atts ) );

	if ( $animation != '' ) { $animation = 'data-animation="' . esc_attr( $animation ) . '"'; $ani = 'fx-start'; }
	ob_start();
	?>

	<?php if ( $module == 'group' ) : ?>

		<div class="social-media-group clearfix <?php echo sanitize_html_class( $ani ); ?>" <?php echo $animation; ?>>
			<div class="social-media-head"><h3><?php echo wp_filter_kses( $caption ); ?></div>
			<div class="social-media-body">
				<div class="social-media-item column-equal col-xs-2 ">
					<a href="<?php echo esc_url( $facebook ); ?>">
					<i class="fa fa-facebook icon-facebook"></i>
					</a>
				</div>
				<div class="social-media-item column-equal col-xs-2 ">
					<a href="<?php echo esc_url( $twitter ); ?>">
						<i class="fa fa-twitter icon-twitter"></i>
					</a>
				</div>
				<div class="social-media-item column-equal col-xs-2 ">
					<a href="<?php echo esc_url( $google ); ?>">
						<i class="fa fa-google-plus icon-googleplus"></i>
					</a>
				</div>
				<div class="social-media-item column-equal col-xs-2 ">
					<a href="<?php echo esc_url( $linkedin ); ?>">
						<i class="fa fa-linkedin icon-linkedin"></i>
					</a>
				</div>
				<div class="social-media-item column-equal col-xs-2 ">
					<a href="<?php echo esc_url( $youtube ); ?>">
						<i class="fa fa-youtube icon-youtube"></i>
					</a>
				</div>
				<div class="social-media-item column-equal col-xs-2 ">
					<a href="mailto:<?php echo sanitize_email( $email ); ?>">
						<i class="fa fa-envelope icon-email"></i>
					</a>
				</div>
			</div>
		</div>

	<?php elseif ( $module == 'widget' ) : ?>

		<div class="social-media-widget row row-equal">
			<div class="social-media-item column-equal col-xs-4">
				<a href="<?php echo esc_url( $facebook ); ?>" class="icon-facebook">
					<i class="fa fa-facebook"></i>
					<span><?php _e( 'Facebook', PLUGIN_NAME ); ?></span>
				</a>
			</div>
			<div class="social-media-item column-equal col-xs-4">
				<a href="<?php echo esc_url( $twitter ); ?>" class="icon-twitter">
					<i class="fa fa-twitter"></i>
					<span><?php _e( 'Twitter', PLUGIN_NAME ); ?></span>
				</a>
			</div>
			<div class="social-media-item column-equal col-xs-4">
				<a href="<?php echo esc_url( $google ); ?>" class="icon-googleplus">
					<i class="fa fa-google-plus"></i>
					<span><?php _e( 'Google+', PLUGIN_NAME ); ?></span>
				</a>
			</div>
			<div class="social-media-item column-equal col-xs-4">
				<a href="<?php echo esc_url( $linkedin ); ?>" class=" icon-linkedin">
					<i class="fa fa-linkedin"></i>
					<span><?php _e( 'LinkedIn', PLUGIN_NAME ); ?></span>
				</a>
			</div>
			<div class="social-media-item column-equal col-xs-4">
				<a href="<?php echo esc_url( $youtube ); ?>" class="icon-youtube">
					<i class="fa fa-youtube"></i>
					<span><?php _e( 'YouTube', PLUGIN_NAME ); ?></span>
				</a>
			</div>
			<div class="social-media-item column-equal col-xs-4">
				<a href="mailto:<?php echo sanitize_email( $email ); ?>" class="icon-mail">
				<i class="fa fa-envelope"></i>
					<span><?php _e( 'EMail', PLUGIN_NAME ); ?></span>
				</a>
			</div>
		</div>

	<?php else : ?>

		<div class="social-media-widget row row-equal">
			<div class="social-media-item column-equal col-sm-2">
				<a href="<?php echo esc_url( $facebook ); ?>" class="icon-facebook">
					<i class="fa fa-facebook"></i>
					<span><?php _e( 'Facebook', PLUGIN_NAME ); ?></span>
				</a>
			</div>
			<div class="social-media-item column-equal col-sm-2">
				<a href="<?php echo esc_url( $twitter ); ?>" class="icon-twitter">
					<i class="fa fa-twitter"></i>
					<span><?php _e( 'Twitter', PLUGIN_NAME ); ?></span>
				</a>
			</div>
			<div class="social-media-item column-equal col-sm-2">
				<a href="<?php echo esc_url( $google ); ?>" class="icon-googleplus">
					<i class="fa fa-google-plus"></i>
					<span><?php _e( 'Google+', PLUGIN_NAME ); ?></span>
				</a>
			</div>
			<div class="social-media-item column-equal col-sm-2">
				<a href="<?php echo esc_url( $linkedin ); ?>" class=" icon-linkedin">
					<i class="fa fa-linkedin"></i>
					<span><?php _e( 'LinkedIn', PLUGIN_NAME ); ?></span>
				</a>
			</div>
			<div class="social-media-item column-equal col-sm-2">
				<a href="<?php echo esc_url( $youtube ); ?>" class="icon-youtube">
					<i class="fa fa-youtube"></i>
					<span><?php _e( 'YouTube', PLUGIN_NAME ); ?></span>
				</a>
			</div>
			<div class="social-media-item column-equal col-sm-2">
				<a href="mailto:<?php echo sanitize_email( $email ); ?>" class="icon-mail">
				<i class="fa fa-envelope"></i>
					<span><?php _e( 'EMail', PLUGIN_NAME ); ?></span>
				</a>
			</div>
		</div>
		
	<?php endif; ?>
		
	<?php
	$html = ob_get_clean();
	return $html;
}
add_shortcode( 'shortcode_social_media', 'aio_social_media' );

// Shortcode Button
function aio_shortcode_button( $atts ) {

	extract( shortcode_atts( array(
		'module'		=> 'main',
		'icon'			=> '',
		'title' 		=> 'Read More',
		'size' 		    => 'big',
		'target'		=> '',
		'url' 		    => '#'
	), $atts ) );

	if ( $icon != '') { $icon = '<i class="fa ' . esc_attr( $icon ) . '"></i>'; }
	if ( $target != '') { $target = 'target="' . esc_attr( $target ) . '"'; }

	$html = '<a href="' . esc_url( $url ) . '" ' . $target . ' class="button-' . sanitize_html_class( $size ) . ' button-' . sanitize_html_class( $module ) . '">' . $icon . '' . wp_strip_all_tags( $title ) . '</a>';
	return $html;
}
add_shortcode( 'shortcode_button', 'aio_shortcode_button' );

// Separator Shortcode
function aio_shortcode_separator( $atts ) {

	extract( shortcode_atts( array(
		'caption'		=> '',
		'module'	=> ''
	), $atts ) );

	if ($module == 'center') {
		$html = '<div class="separator-center row clearfix">
			<h2><span>' .  wp_strip_all_tags( $caption ) . '</span></h2>
		</div>';
	} else {
		$html = '<div class="separator-left row clearfix">
			<h2><span>' .  wp_strip_all_tags( $caption ) . '</span></h2>
		</div>';
	}
	return $html;
}
add_shortcode( 'shortcode_separator', 'aio_shortcode_separator' );

// Box Shortcode
function aio_shortcode_box( $atts, $content = null ) {

	extract( shortcode_atts( array(
		'module'	=> ''
	), $atts ) );

	if ($module == 'center') {
		$html = '<div class="box-center">' . do_shortcode( $content ) . '</div>';
	} else {
		$html = '<div class="box-left">' . do_shortcode( $content ) . '</div>';
	}
	return $html;
}
add_shortcode( 'shortcode_box', 'aio_shortcode_box' );

						
// Pie Shortcode
function aio_shortcode_pie( $atts ) {

	extract( shortcode_atts( array(
		'module'		=> 'center',
		'percent'		=> '75',
		'size'			=> '100',
		'color'			=> '#ffcc01',
		'background'	=> '#f5f5f5',
		'title' 		=> 'Pie Title Text',
		'content' 		=> 'Pie Content Text'
	), $atts ) );

	$html = '<div class="pie-center fx-pie">
		<span class="chart" data-percent="' . esc_attr( $percent ) . '" data-size="' . esc_attr( $size ) . '" data-color="' . esc_attr( $color ) . '" data-background="' . esc_attr( $background ) . '"><span class="percent">' . wp_strip_all_tags( $percent ) . '</span></span>
		<h3>' . wp_strip_all_tags( $title ) . '</h3>
		<p>' . wp_strip_all_tags( $content) . '</p>
	</div>';
	return $html;
}
add_shortcode( 'shortcode_pie', 'aio_shortcode_pie' );

// Accordion Shortcode
function aio_shortcode_accordion( $atts, $content = null ) {

	extract( shortcode_atts( array(
		'id'			=> '',
		'name'			=> '',
		'module'		=> '',
		'column'		=> ''
	), $atts ) );

	$html = '<article id="' . wp_strip_all_tags( $id ) . '" class="accordion-group panel-group ">' . do_shortcode( $content ) . '</article>';
	return $html;
}
add_shortcode( 'shortcode_accordion', 'aio_shortcode_accordion' );
function aio_shortcode_accordion_item( $atts) {

	extract( shortcode_atts( array(
		'id'			=> '',
		'id_parent'		=> '',
		'title'			=> '',
		'collapse'		=> 'true',
		'content'		=> '',
		'column'		=> ''
	), $atts ) );
	
	if ($collapse == 'false') { $collapse = 'in'; }

	$html = '<div class="panel panel-default">
		<div class="panel-heading">
			<h4 class="panel-title"><a data-toggle="collapse" data-parent="#' . wp_strip_all_tags( $id_parent ) . '" href="#' . wp_strip_all_tags( $id ) . '">' . wp_strip_all_tags( $title ) . '<i class="fa fa-plus"></i></a></h4>
		</div>
		<div id="' . wp_strip_all_tags( $id ) . '" class="panel-collapse collapse ' . wp_strip_all_tags( $collapse ) . '">
			<div class="panel-body">
				<p>' . wp_strip_all_tags( $content ) . '</p>
			</div>
		</div>
	</div>';
	return $html;
}
add_shortcode( 'shortcode_accordion_item', 'aio_shortcode_accordion_item' );

// Quote Shortcode
function aio_shortcode_quote( $atts ) {

	extract( shortcode_atts( array(
		'style'		=> '',
		'module'	=> '',
		'author'	=> '',
		'quote'		=> '',
		'company'	=> '',
		'ani' 		=> '',
		'animation' => ''
	), $atts ));

	if ( $style != '' ) { $style = 'style="' . $style . '"'; }
	if ( $animation != '' ) { $animation = 'data-animation="' . $animation . '"'; $ani = 'vr-scroll'; }
	
	if ($module == 'big') {

		$html = '<article class="quote-big clearfix">
			<blockquote>
				<p><i class="fa fa-quote-left"></i>' . wp_strip_all_tags( $quote ) . '<i class="fa fa-quote-right"></i></p>';
				if ( $author != '' ) {
					$html .= '<cite><strong>' . wp_strip_all_tags( $author ) . ',-</strong></cite>';
				}
			$html .= '</blockquote>
		</article>';
	
	} else {
		
		$html = '<article class="quote clearfix">
			<blockquote>
				<p><i class="fa fa-quote-left"></i>' . wp_strip_all_tags( $quote ) . '<i class="fa fa-quote-right"></i></p>';
				if ( $author != '' ) {
					$html .= '<cite><strong>' . wp_strip_all_tags( $author ) . ',-</strong></cite>';
				}
			$html .= '</blockquote>
		</article>';
		
	}
	
	return $html;
}
add_shortcode( 'shortcode_quote', 'aio_shortcode_quote' );

// Element Bar Shortcode
function aio_shortcode_bar( $atts  ) {

	$column = ''; $color = '';  $percent = ''; $title = '';
	
	extract( shortcode_atts( array(
		'column' 	=> '',
		'color' 	=> '',
		'percent'   => 75,
		'title'     => 'Bar Title Text',
		'ani' 		=> '',
		'animation'	=> ''
	), $atts ) );
	
	if ( $animation != '' ) { $animation = 'data-animation="' . $animation . '"'; $ani = 'fx-start'; }

	$html = '<article class="bar fx-bar ' . sanitize_html_class( $ani ) . '" ' . $animation . '>
		<span class="bar-graph" data-width="' . $percent . '" style="background-color:' . $color . '"></span>
		<div class="bar-head">' . wp_strip_all_tags( $title ) . ' <strong><b>' . $percent . '</b>%</strong></div>
	</article>';
	return $html;
}
add_shortcode( 'shortcode_bar', 'aio_shortcode_bar' );

// Counter Shortcode
function aio_shortcode_counter( $atts, $content = null ) {

	extract( shortcode_atts( array(
		'module'		=> '',
		'title'			=> 'Counter Title Text',
		'sign' 			=> '+',
		'column' 		=> '',
		'color' 		=> '#dedede',
		'number' 		=> '125',
		'icon'			=> 'fa-check',
		'title' 		=> 'Title text',
		'ani' 			=> '',
		'animation'		=> ''
	), $atts ) );

	if ( $animation != '' ) { $animation = 'data-animation="' . esc_attr( $animation ) . '"'; $ani = 'fx-start'; }

	$html = '<div class="counter fx-counter ' . sanitize_html_class( $ani ) . '" ' . $animation . '>
		<div class="counter-body" style="color:' . $color . '"><span class="counter-number" data-number="' . wp_strip_all_tags( $number ) . '">0</span><span>' . wp_strip_all_tags( $sign ) . '</span></div>
		<h3><i class="fa ' . $icon . '"></i>' . wp_strip_all_tags( $title ) . '</h3>
	</div>';
	return $html;
}
add_shortcode( 'shortcode_counter', 'aio_shortcode_counter' );

// Element Tab Shortcode
function aio_shortcode_tab( $atts ) {

	extract( shortcode_atts( array(
		'module'		=> '',
		'name'			=> '',
		'column'		=> '',
		'icon_1'		=> 'fa-check-square',
		'picture_1'		=> '',
		'title_1'		=> '',
		'content_1'		=> '',
		'icon_2'		=> 'fa-check-square',
		'picture_2'		=> '',
		'title_2'		=> '',
		'content_2'		=> '',
		'icon_3'		=> 'fa-check-square',
		'picture_3'		=> '',
		'title_3'		=> '',
		'content_3'		=> '',
		'icon_4'		=> 'fa-check-square',
		'picture_4'		=> '',
		'title_4'		=> '',
		'content_4'		=> '',
		'icon_5'		=> 'fa-check-square',
		'picture_5'		=> '',
		'title_5'		=> '',
		'content_5'		=> '',
		'ani' 		=> '',
		'animation'	=> ''
	), $atts ) );
	
	if ($picture_1 != '') { $picture_1 = '<img class="alignleft" src="' . esc_url($picture_1) . '" alt="' . $name .'" />'; }
	if ($picture_2 != '') { $picture_2 = '<img class="alignleft" src="' . esc_url($picture_2) . '" alt="' . $name .'" />'; }
	if ($picture_3 != '') { $picture_3 = '<img class="alignleft" src="' . esc_url($picture_3) . '" alt="' . $name .'" />'; }
	if ($picture_4 != '') { $picture_4 = '<img class="alignleft" src="' . esc_url($picture_4) . '" alt="' . $name .'" />'; }
	if ($picture_5 != '') { $picture_5 = '<img class="alignleft" src="' . esc_url($picture_5) . '" alt="' . $name .'" />'; }

	if ($module == 'mega') {
	
		$html = '
		<article class="tabs tab-mega">
			<ul class="nav nav-tabs">';
				if ($title_1 != '') { $html .= '<li class="active"><a href="#' . esc_attr( $name ) . 'tab1" data-toggle="tab"><i class="fa ' . $icon_1 . '"></i><h4>' . aio_kses( $title_1 ) . '</h4></a></li>'; }
				if ($title_2 != '') { $html .= '<li><a href="#' . esc_attr( $name ) . 'tab2" data-toggle="tab"><i class="fa ' . $icon_2 . '"></i><h4>' . aio_kses( $title_2 ) . '</h4></a></li>'; }
				if ($title_3 != '') { $html .= '<li><a href="#' . esc_attr( $name ) . 'tab3" data-toggle="tab"><i class="fa ' . $icon_3 . '"></i><h4>' . aio_kses( $title_3 ) . '</h4></a></li>'; }
				if ($title_4 != '') { $html .= '<li><a href="#' . esc_attr( $name ) . 'tab4" data-toggle="tab"><i class="fa ' . $icon_4 . '"></i><h4>' . aio_kses( $title_4 ) . '</h4></a></li>'; }
				if ($title_5 != '') { $html .= '<li><a href="#' . esc_attr( $name ) . 'tab5" data-toggle="tab"><i class="fa ' . $icon_5 . '"></i><h4>' . aio_kses( $title_5 ) . '</h4></a></li>'; }
			$html .= '</ul>
			<div class="tab-content">';
				if ($content_1 != '') { $html .= '<div class="tab-pane active" id="' . esc_attr( $name ) . 'tab1"><p>' . $picture_1 . '' . aio_kses( $content_1 ) . '</p></div>'; }
				if ($content_2 != '') { $html .= '<div class="tab-pane" id="' . esc_attr( $name ) . 'tab2"><p>' . $picture_2 . '' . aio_kses( $content_2 ) . '</p></div>'; }
				if ($content_3 != '') { $html .= '<div class="tab-pane" id="' . esc_attr( $name ) . 'tab3"><p>' . $picture_3 . '' . aio_kses( $content_3 ) . '</p></div>'; }
				if ($content_4 != '') { $html .= '<div class="tab-pane" id="' . esc_attr( $name ) . 'tab4"><p>' . $picture_4 . '' . aio_kses( $content_4 ) . '</p></div>'; }
				if ($content_5 != '') { $html .= '<div class="tab-pane" id="' . esc_attr( $name ) . 'tab5"><p>' . $picture_5 . '' . aio_kses( $content_5 ) . '</p></div>'; }
			$html .= '</div>
		</article>';
	
	} else {
	
		$html = '<article class="tabs">
			<ul class="nav nav-tabs">';
				if ($title_1 != '') { $html .= '<li class="active"><a href="#' . esc_attr( $name ) . 'tab1" data-toggle="tab"><h4>' . wp_strip_all_tags( $title_1 ) . '</h4></a></li>'; }
				if ($title_2 != '') { $html .= '<li><a href="#' . esc_attr( $name ) . 'tab2" data-toggle="tab"><h4>' . wp_strip_all_tags( $title_2 ) . '</h4></a></li>'; }
				if ($title_3 != '') { $html .= '<li><a href="#' . esc_attr( $name ) . 'tab3" data-toggle="tab"><h4>' . wp_strip_all_tags( $title_3 ) . '</h4></a></li>'; }
				if ($title_4 != '') { $html .= '<li><a href="#' . esc_attr( $name ) . 'tab4" data-toggle="tab"><h4>' . wp_strip_all_tags( $title_4 ) . '</h4></a></li>'; }
				if ($title_5 != '') { $html .= '<li><a href="#' . esc_attr( $name ) . 'tab5" data-toggle="tab"><h4>' . wp_strip_all_tags( $title_4 ) . '</h4></a></li>'; }
			$html .= '</ul>
			<div class="tab-content">';
				if ($content_1 != '') { $html .= '<div class="tab-pane active" id="' . esc_attr( $name ) . 'tab1"><p>' . wp_filter_kses( $content_1 ) . '</p></div>'; }
				if ($content_2 != '') { $html .= '<div class="tab-pane" id="' . esc_attr( $name ) . 'tab2"><p>' . wp_filter_kses( $content_2 ) . '</p></div>'; }
				if ($content_3 != '') { $html .= '<div class="tab-pane" id="' . esc_attr( $name ) . 'tab3"><p>' . wp_filter_kses( $content_3 ) . '</p></div>'; }
				if ($content_4 != '') { $html .= '<div class="tab-pane" id="' . esc_attr( $name ) . 'tab4"><p>' . wp_filter_kses( $content_4 ) . '</p></div>'; }
			$html .= '</div>
		</article>';
		
	}
	return $html;
}
add_shortcode( 'shortcode_tab', 'aio_shortcode_tab' );

// Element Slider
function aio_shortcode_slider( $atts ) {

	extract( shortcode_atts( array(
		'module'		=> 'main',
		'ani'			=> '',
		'animation'		=> ''
	), $atts ) );

	$html = ' <div class="vr-slider-gallery">
		<div class="vr-slider">' . do_shortcode( $content ) . '</div>
	</div>';
	return $html;
}
add_shortcode( 'shortcode_slider', 'aio_shortcode_slider' );

// Element Slider Item
function aio_shortcode_slider_item( $atts ) {

	extract( shortcode_atts( array(
		'module'	=> 'main',
		'picture'	=> '',
		'alt'		=> '',
		'caption' 	=> '',
		'ani'		=> '',
		'animation'	=> ''
	), $atts ) );

	$html = '<div class="slider-item vr-slider-item vr-blog-slider-thumb">
		<img width="800" height="420" src="' . esc_url( aq_resize( $picture, 800, 420, true, true, true ) ) . '" alt="' . esc_attr( $alt ) .'" />
	</div>';
	return $html;
}
add_shortcode( 'shortcode_slider_item', 'aio_shortcode_slider_item' );

// Shortcode Google Map
function aio_shortcode_map( $atts, $content = null ) {

	extract( shortcode_atts( array(
		'id'			=> '',
		'style'			=> '',
		'width'			=> '100%',
		'height'		=> '360',
		'latitude' 		=> '-8.581763',
		'longitude' 	=> '115.3755938',
		'zoom' 			=> '12'
	), $atts ) );
	
	if ( $id != '' ) { $id = 'id="' . $id . '"'; }
	if ( $style != '' ) { $style = 'style="' . $style . '"'; }

	$html = '<article class="embed-map" style="height:' . esc_attr( $height ) . 'px">
		<iframe width="' . esc_attr( $width ) . '" height="' . esc_attr( $height ) . '" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/?ie=UTF8&amp;ll='. esc_attr( $latitude ) . ', ' . esc_attr( $longitude ) . '&amp;spn=0.01134,0.026157&amp;t=m&amp;z=' . esc_attr( $zoom ) . '&amp;output=embed"></iframe>
	</article>';
	return $html;
}
add_shortcode( 'shortcode_map', 'aio_shortcode_map' );

// uneven 5 function
function aio_uneven_5( $num, $picture, $animation ) {
	$ani = '';
	if ( $animation != '' ) { $ani = 'fx-start'; }
	$result;
	if ( $num == 1) {
		$result = '<article class="gallery-uneven col-sm-12 col-md-3 ' . sanitize_html_class( $ani ) . '" ' . $animation . ' style="height:500px;background-image: url(' . esc_url( $picture ). ');">';
	} elseif ( $num == 2) {
		$result = '<article class="gallery-uneven col-sm-12 col-md-6 ' . sanitize_html_class( $ani ) . '" ' . $animation . ' style="height:250px;background-image: url(' . esc_url( $picture ) . ');">';
	} elseif ( $num == 3) {
		$result = '<article class="gallery-uneven col-sm-12 col-md-3 ' . sanitize_html_class( $ani ) . '" ' . $animation . ' style="height:250px;background-image: url(' . esc_url( $picture ) . ');">';
	} elseif ( $num == 4) {
		$result = '<article class="gallery-uneven col-sm-12 col-md-3 ' . sanitize_html_class( $ani ) . '" ' . $animation . ' style="height:250px;background-image: url(' . esc_url( $picture ) . ');">';
	} elseif ( $num == 5) {
		$result = '<article class="gallery-uneven col-sm-12 col-md-6 ' . sanitize_html_class( $ani ) . '" ' . $animation . ' style="height:250px;background-image: url(' . esc_url( $picture ) . ');">';
	}
	return $result;
}

// uneven 9 function
function aio_uneven_9( $num, $picture, $animation  ) {
	$ani = '';
	if ( $animation != '' ) { $ani = 'fx-start'; }
	$result;
	if ( $num == 1) {
		$result = '<article id="' . $num .'" class="gallery-uneven col-sm-12 col-md-6 ' . sanitize_html_class( $ani ) . '" ' . $animation . ' style="height:500px;background-image: url(' . esc_url( $picture ) . ');">';
	} elseif ( $num == 2) {
		$result = '<article id="' . $num .'" class="gallery-uneven col-sm-12 col-md-3 ' . sanitize_html_class( $ani ) . '" ' . $animation . ' style="height:250px;background-image: url(' . esc_url( $picture ) . ');">';
	} elseif ( $num == 3) {
		$result = '<article id="' . $num .'" class="gallery-uneven col-sm-12 col-md-3 ' . sanitize_html_class( $ani ) . '" ' . $animation . ' style="height:250px;background-image: url(' . esc_url( $picture ) . ');">';
	} elseif ( $num == 4) {
		$result = '<article id="' . $num .'" class="gallery-uneven col-sm-12 col-md-6 ' . sanitize_html_class( $ani ) . '" ' . $animation . ' style="height:250px;background-image: url(' . esc_url( $picture ) . ');">';
	} elseif ( $num == 5) {
		$result = '<article id="' . $num .'" class="gallery-uneven col-sm-12 col-md-3 ' . sanitize_html_class( $ani ) . '" ' . $animation . ' style="height:500px;background-image: url(' . esc_url( $picture ) . ');">';
	} elseif ( $num == 6) {
		$result = '<article id="' . $num .'" class="gallery-uneven col-sm-12 col-md-6 ' . sanitize_html_class( $ani ) . '" ' . $animation . ' style="height:250px;background-image: url(' . esc_url( $picture ) . ');">';
	} elseif ( $num == 7) {
		$result = '<article id="' . $num .'" class="gallery-uneven col-sm-12 col-md-3 ' . sanitize_html_class( $ani ) . '" ' . $animation . ' style="height:250px;background-image: url(' . esc_url( $picture ) . ');">';
	} elseif ( $num == 8) {
		$result = '<article id="' . $num .'" class="gallery-uneven col-sm-12 col-md-3 ' . sanitize_html_class( $ani ) . '" ' . $animation . ' style="height:250px;background-image: url(' . esc_url( $picture ) . ');">';
	} elseif ( $num == 9) {
		$result = '<article id="' . $num .'" class="gallery-uneven col-sm-12 col-md-6 ' . sanitize_html_class( $ani ) . '" ' . $animation . ' style="height:250px;background-image: url(' . esc_url( $picture ) . ');">';
	}
	return $result;
}
// Get element thumbnail
function aio_src( $post ) {
	if ( has_post_thumbnail( $post ) ) {
		$src = wp_get_attachment_image_src( get_post_thumbnail_id( $post ), 'full' );
		return $src[0];
	}
}

// Get element limited excerpt
function aio_excerpt( $limit ) {

	$excerpt = explode( ' ', get_the_excerpt(), $limit );
	if ( count( $excerpt ) >= $limit ) {
		array_pop( $excerpt );
		$excerpt = implode( ' ', $excerpt ) . ' ...';
	} else {
		$excerpt = implode( ' ', $excerpt );
	}

	$excerpt = preg_replace( '`\[[^\]]*\]`' , '', $excerpt );
	return $excerpt;
}

// Prints HTML with meta information for the current post-date/time and author.
function aio_posted_on() {

	$byline = sprintf(
		esc_html_x( 'by %s', 'post author', PLUGIN_NAME ),
		'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span> | '
	);
	
	echo '<span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK.

	if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
		echo '<span class="comments-link">';
			echo __( ' with ', PLUGIN_NAME);
			comments_popup_link( esc_html__( '0 Comment', PLUGIN_NAME ), esc_html__( '1 Comment', PLUGIN_NAME ), esc_html__( '% Comments', PLUGIN_NAME ) );
		echo '</span> | ';
	}
	
	/* translators: used between list items, there is a space after the comma */
	$categories_list = get_the_category_list( esc_html__( ', ', PLUGIN_NAME ) );
	if ( $categories_list ) {
		printf( '<span class="cat-links">' . esc_html__( 'in %1$s', PLUGIN_NAME ) . '</span>', $categories_list ); // WPCS: XSS OK.
	}
	
}

// get classic post date
function aio_posted_on_classic() {

	$byline = sprintf(
		esc_html_x( 'by %s', 'post author', PLUGIN_NAME ),
		'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>  '
	);
	
	echo '<span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK.

	if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
		echo '<span class="comments-link">';
			echo __( ' with ', PLUGIN_NAME);
			comments_popup_link( esc_html__( '0 Comment', PLUGIN_NAME ), esc_html__( '1 Comment', PLUGIN_NAME ), esc_html__( '% Comments', PLUGIN_NAME ) );
		echo '</span>  ';
	}
	
}

// Get post author
function aio_posted_by() {

	$byline = sprintf(
		esc_html_x( 'by %s', 'post author', PLUGIN_NAME ),
		'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>  '
	);
	
	echo '<span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK.
	
}


// Returns true if a blog has more than 1 category.
function aio_categorized_blog() {
	if ( false === ( $all_the_cool_cats = get_transient( 'theme_categories' ) ) ) {
		// Create an array of all the categories that are attached to posts.
		$all_the_cool_cats = get_categories( array(
			'fields'     => 'ids',
			'hide_empty' => 1,

			// We only need to know if there is more than one category.
			'number'     => 2,
		) );

		// Count the number of categories that are attached to the posts.
		$all_the_cool_cats = count( $all_the_cool_cats );

		set_transient( 'theme_categories', $all_the_cool_cats );
	}

	if ( $all_the_cool_cats > 1 ) {
		// This blog has more than 1 category so theme_categorized_blog should return true.
		return true;
	} else {
		// This blog has only 1 category so theme_categorized_blog should return false.
		return false;
	}
	//return true;
}

// Flush out the transients used in aio_categorized_blog.
function aio_category_transient_flusher() {
	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
		return;
	}
	// Like, beat it. Dig?
	delete_transient( 'aio_categories' );
}
add_action( 'edit_category', 'aio_category_transient_flusher' );
add_action( 'save_post',     'aio_category_transient_flusher' );


function aio_entry_footer() {
	
	edit_post_link( esc_html__( 'Edit', PLUGIN_NAME ), '<span class="edit-link">', '</span>' );

	// Hide category and tag text for pages.
	if ( 'post' == get_post_type() ) {

		/* translators: used between list items, there is a space after the comma */
		$tags_list = get_the_tag_list( '', ' ' );
		if ( $tags_list ) {
			printf( '<span class="tags-links">' . esc_html__( 'Tagged %1$s', PLUGIN_NAME ) . '</span>', $tags_list ); // WPCS: XSS OK.
		}
	}
}

function aio_kses( $html ) {
	$allow = array_merge( wp_kses_allowed_html( 'post' ), array(
		'h1' => array(),
		'h2' => array(),
		'h3' => array(),
		'h4' => array(),
		'h5' => array(),
		'h6' => array(),
		'p' => array(),
		'ul' => array(),
		'li' => array(),
		'span' => array(),
		'strong' => array(),
		'small' => array(),
		'i' => array(
			'class'		=> true,
		),
		'button'	=> array(
			'class'		=> true,
		),
		'section' => array(
			'id'		=> true,
			'class'		=> true,
			'style'		=> true,
		),
		'div' => array(
			'id'    => true,
			'class'    => true,
			'style'    => true,
		),
		'img' => array(
			'src'			=> true,
			'width'			=> true,
			'height'		=> true,
			'data-original'	=> true,
			'alt'			=> true,
		),
		'a' => array(
			'href'    => true,
			'class'   => true,
		),
	));
	return wp_kses( $html, $allow );
}

// armada bind animation
function aio_bind_animation() {
	$datas = array(
		array(
			'value' => '',
			'label' => '',
		),
		array(
			'value' => 'fadeIn',
			'label' => 'fadeIn',
		),
		array(
			'value' => 'fadeInUp',
			'label' => 'fadeInUp',
		),
		array(
			'value' => 'fadeInDown',
			'label' => 'fadeInDown',
		),
		array(
			'value' => 'fadeInLeft',
			'label' => 'fadeInLeft',
		),
		array(
			'value' => 'fadeInRight',
			'label' => 'fadeInRight',
		),
		array(
			'value' => 'rotateFromLeft',
			'label' => 'rotateFromLeft',
		),
		array(
			'value' => 'rotateFromRight',
			'label' => 'rotateFromRight',
		),
		array(
			'value' => 'flipInX',
			'label' => 'flipInX',
		),
		array(
			'value' => 'flipOutX',
			'label' => 'flipOutX',
		),
		array(
			'value' => 'flipInY',
			'label' => 'flipInY',
		),
		array(
			'value' => 'flipOutY',
			'label' => 'flipOutY',
		),
		array(
			'value' => 'bounceIn',
			'label' => 'bounceIn',
		),
		array(
			'value' => 'bounceInUp',
			'label' => 'bounceInUp',
		),
		array(
			'value' => 'bounceInDown',
			'label' => 'bounceInDown',
		),
		array(
			'value' => 'bounceInLeft',
			'label' => 'bounceInLeft',
		),
		array(
			'value' => 'bounceInRight',
			'label' => 'bounceInRight',
		),
	);

	$result = array();
	foreach ( $datas as $data ) {
		$result[] = array( 'value' => $data['value'], 'label' => $data['label'] );
	}
	return $result;
}
VP_Security::instance()->whitelist_function( 'theme_option_animation' );




// Bind Font Weight
function aio_bind_font_weight()
{
	$datas = array(
			array(
				'value' => '300',
				'label' => '300',
			),
			array(
				'value' => '400',
				'label' => '400',
			),
			array(
				'value' => '500',
				'label' => '500',
			),
			array(
				'value' => '600',
				'label' => '600',
			),
			array(
				'value' => '700',
				'label' => '700',
			),
			array(
				'value' => '800',
				'label' => '800',
			),
			array(
				'value' => '900',
				'label' => '900',
			),
	);

	$result = array();
	foreach ( $datas as $data ) {
		$result[] = array( 'value' => $data['value'], 'label' => $data['label']);
	}
	return $result;
}
VP_Security::instance()->whitelist_function( 'aio_bind_font_weight' );

// Bind Column
function aio_bind_column() {

	$datas = array(
		array(
			'value' => '1',
			'label' => '1',
		),
		array(
			'value' => '2',
			'label' => '2',
		),
		array(
			'value' => '2-6',
			'label' => '2-6',
		),
		array(
			'value' => '3',
			'label' => '3',
		),
		array(
			'value' => '3-6',
			'label' => '3-6',
		),
		array(
			'value' => '4',
			'label' => '4',
		),
		array(
			'value' => '4-6',
			'label' => '4-6',
		),
		array(
			'value' => '5',
			'label' => '5',
		),
		array(
			'value' => '6',
			'label' => '6',
		),
		array(
			'value' => '6-6',
			'label' => '6-6',
		),
		array(
			'value' => '7',
			'label' => '7',
		),
		array(
			'value' => '8',
			'label' => '8',
		),
		array(
			'value' => '9',
			'label' => '9',
		),
		array(
			'value' => '10',
			'label' => '10',
		),
		array(
			'value' => '11',
			'label' => '11',
		),
		array(
			'value' => '12',
			'label' => '12',
		),
		array(
			'value' => '20',
			'label' => '20',
		),
	);

	$result = array();
	foreach ( $datas as $data ) {
		$result[] = array( 'value' => $data['value'], 'label' => $data['label'] );
	}
	return $result;
}
VP_Security::instance()->whitelist_function( 'aio_bind_column' );

// Bind Number
function aio_bind_number() {

	$datas = array(
		array(
			'value' => '',
			'label' => '',
		),
		array(
			'value' => '1',
			'label' => '1',
		),
		array(
			'value' => '2',
			'label' => '2',
		),
		array(
			'value' => '3',
			'label' => '3',
		),
		array(
			'value' => '4',
			'label' => '4',
		),
		array(
			'value' => '5',
			'label' => '5',
		),
		array(
			'value' => '6',
			'label' => '6',
		),
		array(
			'value' => '7',
			'label' => '7',
		),
		array(
			'value' => '8',
			'label' => '8',
		),
		array(
			'value' => '9',
			'label' => '9',
		),
		array(
			'value' => '10',
			'label' => '10',
		),
		array(
			'value' => '11',
			'label' => '11',
		),
		array(
			'value' => '12',
			'label' => '12',
		),
	);

	$result = array();
	foreach ( $datas as $data ) {
		$result[] = array( 'value' => $data['value'], 'label' => $data['label'] );
	}
	return $result;
}
VP_Security::instance()->whitelist_function( 'aio_bind_number' );

