AlkantarClanX12

Your IP : 216.73.217.24


Current Path : /www/capitalgmcbuickregina_830/public/wp-content/plugins/leadbox-staff/plugin/Shortcodes/
Upload File :
Current File : /www/capitalgmcbuickregina_830/public/wp-content/plugins/leadbox-staff/plugin/Shortcodes/Staff.php

<?php

namespace Leadbox\Staff\Shortcodes;

use WP_Query;

use function Roots\view;

class Staff
{
    public $app;

    public $plugin;

    function __construct($app, $plugin)
    {
        $this->app = $app;
        $this->plugin = $plugin;
    }

    public function __invoke($atts): string
    {
        $this->loadAssets();
        $staffQuery = new WP_Query( $this->parseArgs($atts) );
        $shortcode = $this->renderShortCode($staffQuery);
        wp_reset_postdata();

        return $shortcode;
    }

    public function loadAssets()
    {
        wp_enqueue_style('leadbox_staff_style', plugins_url() . '/leadbox-staff/resources/styles/staff.css');

        $asset_file = dirname(__DIR__, 2) . '/dist/scripts/staff-modal.asset.php';
        $asset = file_exists($asset_file) ? require($asset_file) : ['dependencies' => [], 'version' => '0.1.0'];
        wp_enqueue_script('leadbox_staff_modal', plugins_url() . '/leadbox-staff/dist/scripts/staff-modal.js', $asset['dependencies'], $asset['version'], true);
    }

    /**
     * Parse shortcode arguments
     * 
     * @param array  $args  query args for wp query
     * 
     * @return array query args for wp query
     */
    public function parseArgs($args): array
    {
        $args = wp_parse_args($args, [
            'type'             => 'all',
            'posts_per_page'   => -1,
            'category'         => 0,
            'orderby'          => 'menu_order title',
            'order'            => 'ASC',
            'suppress_filters' => true,
        ]);

        $args = array_merge([
            'post_type' => 'staff_member',
            ], $args
        );

        $args = $this->appendVisibilityQuery($args);

        return $args['type'] !== 'all'
            ? $this->appendTaxonomyQuery($args)
            : $args;
    }

    /**
     * Append visibility meta query.
     *
     * Staff saved before the "show" field existed have no meta row,
     * so missing meta counts as visible.
     *
     * @param array  $args  query args for wp query
     *
     * @return array  query args for wp query
     */
    public function appendVisibilityQuery(array $args): array
    {
        $args['meta_query'] = [
            'relation' => 'OR',
            [
                'key' => 'show',
                'compare' => 'NOT EXISTS',
            ],
            [
                'key' => 'show',
                'value' => '0',
                'compare' => '!=',
            ],
        ];

        return $args;
    }

    /**
     * Append taxonomy query
     * 
     * @param array  $args  query args for wp query
     * 
     * @return array  query args for wp query
     */
    public function appendTaxonomyQuery(array $args): array
    {
        $args['tax_query'] = [[
            'taxonomy' => 'departments',
            'field' => 'slug',
            'terms' => $args['type'],
        ]];

        return $args;
    }

    /**
     * Render Shortcode Blade View
     * 
     * @param WP_Query $query  the staff query
     * 
     * @return string rendered html
     */
    public function renderShortCode($query): string
    {
        return view('staff.shortcode', ['staff' => $query])->render();
    }
}

Home - Capital GMC Buick Regina

No data

Welcome to Capital GMC BUICK – REGINA

Thank you for choosing Capital GMC Buick | Regina, your premier certified Buick and GMC dealership proudly serving drivers in Regina and the surrounding communities. Whether you’re searching for a brand-new Buick or GMC vehicle or a meticulously inspected pre-owned model, we have a diverse selection to match your needs and lifestyle.

Beyond our impressive inventory, we offer a seamless and stress-free financing experience through our well-connected finance centre, where our team of experts is dedicated to securing the best loan or lease options for you, quickly, transparently, and hassle-free.

But our commitment to you doesn’t stop at the sale. Our state-of-the-art service centre is staffed with skilled Buick and GMC technicians who use the latest equipment and genuine OEM parts to keep your vehicle running at its best. From routine maintenance to complex repairs, we’ve got you covered.

Experience top-tier customer service, quality vehicles, and expert care, all in one place. Visit Capital GMC Buick | Regina today or call us at 306-205-8072 with any questions. We’re here to help!

Ask a Question