function enqueue_bootstrap_for_elementor() {
    // Bootstrap CSS
    wp_enqueue_style('bootstrap-css', 'https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css');
    
    // Bootstrap JS (ensure jQuery is loaded as a dependency)
    wp_enqueue_script('bootstrap-js', 'https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js', array('jquery'), null, true);
}

// Use Elementor hook to enqueue files only when Elementor is used
add_action('elementor/frontend/after_enqueue_scripts', 'enqueue_bootstrap_for_elementor');



//Services Post Type
add_action('init', 'services_post_type_init');
function services_post_type_init()
{

    $labels = array(

        'name' => __('Services', 'post type general name', ''),
        'singular_name' => __('Services', 'post type singular name', ''),
        'add_new' => __('Add New', 'Services', ''),
        'add_new_item' => __('Add New Services', ''),
        'edit_item' => __('Edit Services', ''),
        'new_item' => __('New Services', ''),
        'view_item' => __('View Services', ''),
        'search_items' => __('Search Services', ''),
        'not_found' =>  __('No Services found', ''),
        'not_found_in_trash' => __('No Services found in Trash', ''),
        'parent_item_colon' => ''
    );
    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'rewrite' => true,
        'query_var' => true,
        'menu_icon' => get_stylesheet_directory_uri() . '/images/testimonials.png',
        'capability_type' => 'post',
        'hierarchical' => true,
        'public' => true,
        'has_archive' => true,
        'show_in_nav_menus' => true,
        'menu_position' => null,
        'rewrite' => array(
            'slug' => 'services',
            'with_front' => true
        ),
        'supports' => array(
            'title',
            'editor',
            'thumbnail'
        )
    );

    register_post_type('services', $args);
}


// Add Shortcode [our_services];
add_shortcode('our_services', 'codex_our_services');
function codex_our_services()
{
    ob_start();
    wp_reset_postdata();
?>

 
        <div class="row ser-content">
            <?php
            $arg = array(
                'post_type' => 'services',
                'posts_per_page' => -1,
            );
            $po = new WP_Query($arg);
            ?>
            <?php if ($po->have_posts()) : ?>

                <?php while ($po->have_posts()) : ?>
                    <?php $po->the_post(); ?>
                    <div class="col-md-4">
                        <div class="ser-body">
                                <div class="thumbnail-blog">
                                    <?php echo get_the_post_thumbnail(get_the_ID(), 'full'); ?>
                                </div>
                                <div class="content">
                                    <h3 class="title"><?php the_title(); ?></h3>
                                  <div><?php echo wp_trim_words(get_the_content(), 15, '...'); ?></div>
                                </div>
                              <div class="readmore">
                                <a href="<?php echo get_permalink() ?>">Read More</a>
                            </div>
                        </div>
                    </div>
                <?php endwhile; ?>

            <?php endif; ?>
        </div>


<?php
    wp_reset_postdata();
    return '' . ob_get_clean();
}