/*
	Theme Name: Hello Elementor
	Theme URI: https://elementor.com/hello-theme/?utm_source=wp-themes&utm_campaign=theme-uri&utm_medium=wp-dash
	Description: Hello Elementor is a lightweight and minimalist WordPress theme that was built specifically to work seamlessly with the Elementor site builder plugin. The theme is free, open-source, and designed for users who want a flexible, easy-to-use, and customizable website. The theme, which is optimized for performance, provides a solid foundation for users to build their own unique designs using the Elementor drag-and-drop site builder. Its simplicity and flexibility make it a great choice for both beginners and experienced Web Creators.
	Author: Elementor Team
	Author URI: https://elementor.com/?utm_source=wp-themes&utm_campaign=author-uri&utm_medium=wp-dash
	Version: 3.4.9
	Stable tag: 3.4.9
	Requires at least: 6.0
	Tested up to: 6.8
	Requires PHP: 7.4
	License: GNU General Public License v3 or later.
	License URI: https://www.gnu.org/licenses/gpl-3.0.html
	Text Domain: hello-elementor
	Tags: accessibility-ready, flexible-header, custom-colors, custom-menu, custom-logo, featured-images, rtl-language-support, threaded-comments, translation-ready,
*/



/* partner */


function partners_grid_shortcode() {

    $args = array(
        'post_type' => 'partner',
        'posts_per_page' => -1,
        'post_status' => 'publish'
    );

    $query = new WP_Query($args);

    ob_start();

    echo '<div class="partners-grid">';

    while ($query->have_posts()) {

        $query->the_post();

        $logo = get_field('partner_logo');
        $type = get_field('partner_type');
        $website = get_field('website_url');
        $expertise = get_field('expertise');
        $services = get_field('services');

        ?>

        <div class="partner-card">

            <div class="partner-header">

                <div class="partner-logo">

                    <?php if($logo): ?>
                        <img src="<?php echo esc_url($logo['url']); ?>" alt="">
                    <?php endif; ?>

                </div>

                <div class="partner-info">

                    <?php if($type): ?>
                        <small><?php echo esc_html($type); ?></small>
                    <?php endif; ?>

                    <h3><?php the_title(); ?></h3>

                </div>

            </div>

            <h5>Area of Expertise (Voices)</h5>

            <div class="partner-tags">

                <?php

                if($expertise){

                    $tags = explode("\n", $expertise);

                    foreach($tags as $tag){

                        echo '<span>'.esc_html(trim($tag)).'</span>';

                    }

                }

                ?>

            </div>

            <h5>Services</h5>

            <div class="partner-tags">

                <?php

                if($services){

                    $tags = explode("\n", $services);

                    foreach($tags as $tag){

                        echo '<span>'.esc_html(trim($tag)).'</span>';

                    }

                }

                ?>

            </div>

            <div class="partner-footer">

                <a class="details-btn" href="<?php the_permalink(); ?>">
                    View Details
                </a>

                <?php if($website): ?>

                    <a class="website-btn"
                       href="<?php echo esc_url($website); ?>"
                       target="_blank">
                        Go to Website ↗
                    </a>

                <?php endif; ?>

            </div>

        </div>

        <?php
    }

    wp_reset_postdata();

    echo '</div>';

    return ob_get_clean();
}

add_shortcode('partners_grid', 'partners_grid_shortcode');