<?php
// This is funcion to all the custom control Layout for style in shortcode section
if ( ! function_exists( 'wpsection_set' ) ) {

    function wpsection_set( $var, $key, $def = '' ) {
        /*if (!$var)
        return false;*/

        if ( is_object( $var ) && isset( $var->$key ) ) {
            return $var->$key;
        } elseif ( is_array( $var ) && isset( $var[ $key ] ) ) {
            return $var[ $key ];
        } elseif ( $def ) {
            return $def;
        } else {
            return false;
        }
    }

}


//This code is for make the Elemntor Template in the repeater options on Slider Shortcode/Widgets

 
if (!function_exists('wpsection_elementor_template_')) {
    function wpsection_elementor_template_($type = null) {
        $args = [
            'post_type' => 'slider_templates',
            'posts_per_page' => -1,
        ];
        if ($type) {
            $args['tax_query'] = [
                [
                    'taxonomy' => 'elementor_library_type',
                    'field' => 'slug',
                    'terms' => $type,
                ],
            ];
        }
        $template = get_posts($args);
        $tpl = array();
        if (!empty($template) && !is_wp_error($template)) {
            foreach ($template as $post) {
                $tpl[$post->post_name] = $post->post_title;
            }
        }
        return $tpl;
    }
}



if (!function_exists('wpsection_elemntor_content')) {
    function wpsection_elemntor_content( $slug ) {

        $content_post = get_posts(array(
            'name' => $slug,
            'posts_per_page' => 1,
            'post_type' => 'slider_templates',
            'post_status' => 'publish'
        ));

        if (array_key_exists(0, $content_post) == true) {
            $id = $content_post[0]->ID;
            return $id;
        }
    }
}


