AlkantarClanX12

Your IP : 216.73.217.24


Current Path : /www/capitalgmcbuickregina_830/public/wp-content/plugins/popup-maker/classes/Controllers/
Upload File :
Current File : /www/capitalgmcbuickregina_830/public/wp-content/plugins/popup-maker/classes/Controllers/Assets.php

<?php
/**
 * Plugin assets controller.
 *
 * @author    Code Atlantic
 * @package   PopupMaker
 * @copyright (c) 2024, Code Atlantic LLC.
 */

namespace PopupMaker\Controllers;

use PopupMaker\Plugin\Controller;

defined( 'ABSPATH' ) || exit;

/**
 * Assets controller.
 *
 * @since 1.21.0
 */
class Assets extends Controller {

	/**
	 * Whether global vars should be printed.
	 *
	 * @var bool
	 */
	private $should_print_global_vars = false;

	/**
	 * Initialize the assets controller.
	 */
	public function init() {
		add_action( 'init', [ $this, 'register_scripts' ], 1 );
		add_action( 'wp_enqueue_scripts', [ $this, 'register_scripts' ], 1 );
		add_action( 'admin_enqueue_scripts', [ $this, 'register_scripts' ], 1 );
		add_action( 'enqueue_block_editor_assets', [ $this, 'register_scripts' ], 1 );

		add_action( 'wp_print_scripts', [ $this, 'autoload_styles_for_scripts' ], 1 );
		add_action( 'admin_print_scripts', [ $this, 'autoload_styles_for_scripts' ], 1 );

		// Add a hook to fix old handles that might be enqueueed and not loaded, load their replacements.
		add_action( 'wp_enqueue_scripts', [ $this, 'fix_old_handles' ], 1 );
		add_action( 'wp_footer', [ $this, 'print_global_vars' ], 10 ); // wp_print_footer_scripts is at 20.
		add_action( 'admin_footer', [ $this, 'print_global_vars' ], 10 ); // admin_print_footer_scripts is at 20.
	}

	/**
	 * Get list of plugin packages.
	 *
	 * @return array
	 */
	public function get_packages() {
		static $packages;

		if ( $packages ) {
			return $packages;
		}

		$packages = [
			'admin-bar'           => [
				'bundled'  => false,
				'handle'   => 'popup-maker-admin-bar',
				'styles'   => true,
				'deps'     => [ 'popup-maker-site' ],
				'varsName' => 'popupMakerAdminBar',
				'vars'     => [
					'i18n' => [
						'instructions' => __( 'Click Start Selection, then click a page element (text, button, image, etc.) to get its CSS selector.', 'popup-maker' ),
						'results'      => _x( 'Selector', 'JS alert for CSS get selector tool', 'popup-maker' ),
						'close'        => _x( 'Close', 'JS alert for CSS get selector tool', 'popup-maker' ),
						'copy'         => _x( 'Copy', 'JS alert for CSS get selector tool', 'popup-maker' ),
						'copied'       => _x( 'Copied to clipboard', 'JS alert for CSS get selector tool', 'popup-maker' ),
					],
				],
			],
			'admin-marketing'     => [
				'bundled' => false,
				'handle'  => 'popup-maker-admin-marketing',
				'styles'  => true,
			],
			'admin-notifications' => [
				'bundled' => false,
				'handle'  => 'popup-maker-admin-notifications',
				'styles'  => true,
			],
			'block-editor'        => [
				'bundled'  => false,
				'handle'   => 'popup-maker-block-editor',
				'styles'   => true,
				'deps'     => [],
				'varsName' => 'popupMakerBlockEditor',
				'vars'     => [
					'cta_types'                  => $this->container->get( 'cta_types' )->get_as_array(),
					'popups'                     => pum_get_all_popups(),
					'homeUrl'                    => home_url(),
					'previewNonce'               => wp_create_nonce( 'popup-preview' ),
					'popupTriggerExcludedBlocks' => apply_filters(
						'pum_block_editor_popup_trigger_excluded_blocks',
						[
							'core/nextpage',
							'popup-maker/call-to-action',
							'popup-maker/call-to-actions',
						]
					),
				],
			],
			'block-library'       => [
				'bundled'      => false,
				'handle'       => 'popup-maker-block-library',
				'styles'       => true,
				'block_styles' => true,
				'varsName'     => 'popupMakerBlockLibrary',
				'vars'         => function () {
					return [
						'homeUrl' => home_url(),
					];
				},
			],
			'components'          => [
				'bundled'  => false,
				'handle'   => 'popup-maker-components',
				'styles'   => true,
				'varsName' => 'popupMakerComponents',
				'vars'     => function () {
					return [
						'popups' => \pum_get_all_popups(),
					];
				},
			],
			'core-data'           => [
				'bundled'  => false,
				'handle'   => 'popup-maker-core-data',
				'styles'   => false,
				'deps'     => [
					'wp-api',
				],
				'varsName' => 'popupMakerCoreData',
				'vars'     => function () {
					return [
						// TODO Migrate to use plugin('options')->get_all();
						'currentSettings' => \pum_get_options(),
					];
				},
			],
			'cta-admin'           => [
				'bundled'  => false,
				'handle'   => 'popup-maker-cta-admin',
				'styles'   => true,
				'varsName' => 'popupMakerCtaAdmin',
				'vars'     => function () {
					return [
						'cta_types' => $this->container->get( 'cta_types' )->get_as_array(),
					];
				},
			],
			'cta-editor'          => [
				'bundled'  => false,
				'handle'   => 'popup-maker-cta-editor',
				'styles'   => true,
				'varsName' => 'popupMakerCtaEditor',
				'vars'     => function () {
					return [
						'cta_types' => $this->container->get( 'cta_types' )->get_as_array(),
					];
				},
					// 'head'     => true,
			],
			'dashboard'           => [
				'bundled'  => false,
				'handle'   => 'popup-maker-dashboard',
				'styles'   => true,
				'varsName' => 'popupMakerDashboard',
				'vars'     => [],
			],
			'data'                => [
				'bundled' => false,
				'handle'  => 'popup-maker-data',
				'styles'  => false,
				// 'varsName' => 'popupMakerData',
				// 'vars'     => [],
			],
			'fields'              => [
				'bundled' => false,
				'handle'  => 'popup-maker-fields',
				'styles'  => false,
				// 'varsName' => 'popupMakerFields',
				// 'vars'     => [],
			],
			'i18n'                => [
				'bundled' => false,
				'handle'  => 'popup-maker-i18n',
				'styles'  => false,
				// 'varsName' => 'popupMakerI18n',
				// 'vars'     => [],
			],
			'icons'               => [
				'bundled' => false,
				'handle'  => 'popup-maker-icons',
				'styles'  => true,
				// 'varsName' => 'popupMakerIcons',
				// 'vars'     => [],
			],
			'layout'              => [
				'bundled' => false,
				'handle'  => 'popup-maker-layout',
				'styles'  => true,
				// 'varsName' => 'popupMakerLayout',
				// 'vars'     => [],
			],
			'popup-admin'         => [
				'bundled' => false,
				'handle'  => 'popup-maker-popup-admin',
				'styles'  => true,
			],
			'registry'            => [
				'bundled' => false,
				'handle'  => 'popup-maker-registry',
				'styles'  => false,
				// 'varsName' => 'popupMakerRegistry',
				// 'vars'     => [],
			],
			'use-query-params'    => [
				'bundled' => false,
				'handle'  => 'popup-maker-use-query-params',
				'styles'  => false,
				// 'varsName' => 'popupMakerUseQueryParams',
				// 'vars'     => [],
			],
			'utils'               => [
				'bundled' => false,
				'handle'  => 'popup-maker-utils',
				'styles'  => false,
				// 'varsName' => 'popupMakerUtils',
				// 'vars'     => [],
			],
		];

		return $packages;
	}

		/**
		 * Register all package scripts & styles.
		 */
	public function register_scripts() {
		static $registered;

		if ( $registered ) {
			return;
		}
		$registered = true;

		$path          = 'dist/packages';
		$packages_meta = pum_get_asset_group_meta( 'package', [
			'version' => $this->container->get( 'version' ),
		] );

		$packages = $this->get_packages();

		$screen = ( is_admin() && function_exists( 'get_current_screen' ) ) ? get_current_screen() : false;
		$rtl    = is_rtl() ? '-rtl' : '';

		foreach ( $packages as $package => $package_data ) {
			if (
			! isset( $package_data['handle'] ) ||
			! isset( $packages_meta[ "$package.js" ] )
			) {
				// Skip packages that don't have a handle or meta.
					continue;
			}

				$handle       = $package_data['handle'];
				$package_data = wp_parse_args( $package_data, [
					'bundled' => true,
				] );

				$bundled = (bool) $package_data['bundled'];

				$meta = $packages_meta[ "$package.js" ];

				$js_file = $this->container->get_url( "$path/$package.js" );
				$js_deps = array_merge(
					// Automated dependency registration.
					$meta['dependencies'],
					// Manual dependency registration.
					isset( $package_data['deps'] ) ? $package_data['deps'] : []
				);

			if ( 'block-editor' === $package ) {
				if ( is_admin() && ( ! $screen || 'widgets' !== $screen->id ) ) {
					$js_deps = array_merge( $js_deps, [ 'wp-edit-post' ] );
				}
			}

				$footer = $package_data['head'] ?? true;

			if ( $bundled ) {
				pum_register_script( $handle, $js_file, $js_deps, $meta['version'], $footer );
			} else {
				// Though pum_* asset functions pass through to wp_* automatically when disabled, admin packages should never be bundled.
				wp_register_script( $handle, $js_file, $js_deps, $meta['version'], $footer );
			}

				$css_path = $this->container->get_path( "$path/$package{$rtl}.css" );

			if ( isset( $package_data['styles'] ) && $package_data['styles'] && file_exists( $css_path ) ) {
				$css_file = $this->container->get_url( "$path/$package{$rtl}.css" );
				$css_deps = [ 'wp-components', 'wp-block-editor', 'dashicons' ];

				if ( $bundled ) {
					pum_register_style( $handle, $css_file, $css_deps, $meta['version'] );
				} else {
					// Though pum_* asset functions pass through to wp_* automatically when disabled, admin packages should never be bundled.
					wp_register_style( $handle, $css_file, $css_deps, $meta['version'] );
				}
			}

				$block_css_path = $this->container->get_path( "$path/$package-style{$rtl}.css" );

			if ( isset( $package_data['block_styles'] ) && $package_data['block_styles'] && file_exists( $block_css_path ) ) {
				$block_css_file = $this->container->get_url( "$path/$package-style{$rtl}.css" );
				$block_css_deps = [ 'wp-block-editor' ];

				if ( $bundled ) {
					pum_register_style( $handle . '-style', $block_css_file, $block_css_deps, $meta['version'] );
				} else {
					wp_register_style( $handle . '-style', $block_css_file, $block_css_deps, $meta['version'] );
				}
			}

				/**
				 * TODO Create pum_set_script_translations() function.
				 *
				 * May be extended to wp_set_script_translations( 'my-handle', 'my-domain',
				 * plugin_dir_path( MY_PLUGIN ) . 'languages' ) ). For details see
				 * https://make.wordpress.org/core/2018/11/09/new-javascript-i18n-support-in-wordpress/
				 */
				wp_set_script_translations( $handle, 'popup-maker' );
		}
	}

	/**
	 * Get global vars.
	 *
	 * @return array
	 */
	private function get_global_vars() {
		$additional_global_vars = is_admin() ?
		$this->get_admin_global_vars() :
		$this->get_frontend_global_vars();

		return apply_filters(
			'popup_maker/global_vars',
			array_merge(
				[
					'siteUrl'   => esc_url_raw( site_url() ),
					'version'   => $this->container->get( 'version' ),
					'pluginUrl' => $this->container->get_url( '' ),
					'assetsUrl' => $this->container->get_url( 'assets/' ),
					'nonce'     => wp_create_nonce( 'popup-maker' ),
				],
				$additional_global_vars
			)
		);
	}

	/**
	 * Get admin-onlyglobal vars.
	 *
	 * @return array
	 */
	private function get_admin_global_vars() {
		$wp_version = get_bloginfo( 'version' );
		// Strip last number from version as they won't be breaking changes.
		$wp_version = preg_replace( '/\.\d+$/', '', $wp_version );

		$permissions = $this->container->get_permissions();

		foreach ( $permissions as $permission => $cap ) {
			$permissions[ $permission ] = current_user_can( $cap );
		}

		return apply_filters(
			'popup_maker/admin_global_vars',
			[
				'adminUrl'    => admin_url(),
				'wpVersion'   => $wp_version,
				'permissions' => $permissions,
				'layoutVars'  => $this->get_layout_vars(),
			]
		);
	}

	/**
	 * Vars consumed by `@popup-maker/layout` admin pages.
	 *
	 * @return array<string,mixed>
	 */
	private function get_layout_vars() {
		$vars = apply_filters(
			'popup_maker/layout_vars',
			[
				'navTabs'            => [],
				'supportMenuItems'   => [],
				'showSupport'        => true,
			]
		);

		if ( ! is_array( $vars ) ) {
			$vars = [
				'navTabs'          => [],
				'supportMenuItems' => [],
				'showSupport'      => true,
			];
		}

		if ( isset( $vars['navTabs'] ) ) {
			$vars['navTabs'] = $this->sanitize_layout_nav_tabs( $vars['navTabs'] );
		}

		if ( isset( $vars['supportMenuItems'] ) ) {
			$vars['supportMenuItems'] = $this->sanitize_layout_support_menu_items( $vars['supportMenuItems'] );
		}

		if ( isset( $vars['showSupport'] ) ) {
			$vars['showSupport'] = (bool) $vars['showSupport'];
		}

		return $vars;
	}

	/**
	 * Sanitize nav tab definitions before localizing to JS.
	 *
	 * @param mixed $tabs Shell tab list.
	 * @return array<int,array<string,string>>
	 */
	private function sanitize_layout_nav_tabs( $tabs ) {
		$sanitized = [];

		foreach ( (array) $tabs as $tab ) {
			if ( ! is_array( $tab ) || empty( $tab['id'] ) || empty( $tab['href'] ) ) {
				continue;
			}

			$sanitized[] = [
				'id'    => sanitize_key( $tab['id'] ),
				'title' => sanitize_text_field( $tab['title'] ?? '' ),
				'href'  => esc_url_raw( $tab['href'] ),
			];
		}

		return $sanitized;
	}

	/**
	 * Sanitize support menu items before localizing to JS.
	 *
	 * @param mixed $items Support menu item list.
	 * @return array<int,array<string,string>>
	 */
	private function sanitize_layout_support_menu_items( $items ) {
		$sanitized = [];

		foreach ( (array) $items as $item ) {
			if ( ! is_array( $item ) || empty( $item['id'] ) || empty( $item['label'] ) ) {
				continue;
			}

			$sanitized_item = [
				'id'    => sanitize_key( $item['id'] ),
				'label' => sanitize_text_field( $item['label'] ),
				'group' => sanitize_key( $item['group'] ?? 'primary' ),
			];

			if ( ! empty( $item['href'] ) ) {
				$sanitized_item['href'] = esc_url_raw( $item['href'] );
			}

			if ( ! empty( $item['target'] ) ) {
				$sanitized_item['target'] = sanitize_text_field( $item['target'] );
			}

			if ( ! empty( $item['icon'] ) ) {
				$sanitized_item['icon'] = sanitize_key( $item['icon'] );
			}

			$sanitized[] = $sanitized_item;
		}

		return $sanitized;
	}

	/**
	 * Get frontend-only global vars.
	 *
	 * @return array
	 */
	private function get_frontend_global_vars() {
		return apply_filters( 'popup_maker/frontend_global_vars', [] );
	}

	/**
	 * Print global vars.
	 *
	 * @return void
	 */
	public function print_global_vars() {
		static $printed;

		if ( $printed || ! $this->should_print_global_vars ) {
			return;
		}

		$printed = true;

		$global_vars = $this->get_global_vars();

		?>
		<script id="popup-maker-global-vars">
		window.popupMaker = window.popupMaker || {};
		window.popupMaker.globalVars = <?php echo wp_json_encode( $global_vars ); ?>;
		</script>
			<?php
	}

	/**
	 * Auto load styles if scripts are enqueued.
	 */
	public function autoload_styles_for_scripts() {
		$packages = $this->get_packages();

		foreach ( $packages as $package => $package_data ) {
			if ( ! isset( $package_data['handle'] ) ) {
				// Skip packages that don't have a handle or meta.
				continue;
			}

			$handle       = $package_data['handle'];
			$package_data = wp_parse_args( $package_data, [
				'bundled' => true,
			] );

			$bundled = (bool) $package_data['bundled'];

			if ( pum_script_is( $handle, 'enqueued' ) || wp_script_is( $handle, 'enqueued' ) ) {
				$this->should_print_global_vars = true;

				if ( isset( $package_data['styles'] ) && $package_data['styles'] ) {
					if ( $bundled ) {
						pum_enqueue_style( $handle );
					} else {
						wp_enqueue_style( $handle );
					}
				}

				if ( isset( $package_data['block_styles'] ) && $package_data['block_styles'] ) {
					if ( $bundled ) {
						pum_enqueue_style( $handle . '-style' );
					} else {
						wp_enqueue_style( $handle . '-style' );
					}
				}

				if ( isset( $package_data['varsName'] ) && ! empty( $package_data['vars'] ) ) {
					$localized_vars = is_callable( $package_data['vars'] ) ?
					call_user_func( $package_data['vars'] ) :
					$package_data['vars'];

					$localized_vars = apply_filters( "popup_maker/{$package}_localized_vars", $localized_vars );

					if ( $bundled ) {
						pum_localize_script( $handle, $package_data['varsName'], $localized_vars );
					} else {
						// Though pum_* asset functions pass through to wp_* automatically when disabled, admin packages should never be bundled.
						wp_localize_script( $handle, $package_data['varsName'], $localized_vars );
					}
				}
			}
		}
	}

	/**
	 * Fix old handles that might be enqueueed and not loaded, load their replacements.
	 *
	 * @return void
	 */
	public function fix_old_handles() {
	}
}

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