<?php

defined( 'ABSPATH' ) or die;

use Tech360\Slider as Slider;

add_shortcode( 'slider', 'slider' );

function slider( $atts ) {

	$atts = shortcode_atts( array(
		'id' => false
	), $atts );

	$atts[ 'id' ] = intval( $atts[ 'id' ] );

	if( $atts[ 'id' ] && 'slider' == get_post_type( $atts[ 'id' ] ) && 'publish' == get_post_status( $atts[ 'id' ] ) ) {
		ob_start();
		Slider::render( $atts[ 'id' ] );
		return ob_get_clean();
	} else {
		return null;
	}

}
