AlkantarClanX12

Your IP : 216.73.217.24


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

<?php
/**
 * Options Utility
 *
 * @package   PopupMaker
 * @copyright Copyright (c) 2024, Code Atlantic LLC
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class PUM_Utils_Options
 */
class PUM_Utils_Options {

	/**
	 * Unique Prefix per plugin.
	 *
	 * @var string
	 */
	public static $prefix = 'popmake_';

	/**
	 * Keeps static copy of the options during runtime.
	 *
	 * @var array<string, string|int|bool|array<string, mixed>|null>|null
	 */
	private static $data;

	/**
	 * Initialize Options on run.
	 *
	 * @param bool $force
	 * @return void
	 */
	public static function init( $force = false ) {
		global $popmake_options;

		if ( ! isset( self::$data ) || $force ) {
			self::$data = self::get_all();

			/** @deprecated 1.7.0 */
			$popmake_options = self::$data;
		}
	}

	/**
	 * Get Settings
	 *
	 * Retrieves all plugin settings
	 *
	 * @return array<string, string|int|bool|array<string, mixed>|null> settings
	 */
	public static function get_all() {
		$settings = get_option( self::$prefix . 'settings', [] );
		if ( ! is_array( $settings ) ) {
			$settings = [];
		}

		/* @deprecated filter. */
		$settings = apply_filters( 'popmake_get_settings', $settings );

		return apply_filters( self::$prefix . 'get_options', $settings );
	}

	/**
	 * Get an option
	 *
	 * Looks to see if the specified setting exists, returns default if not
	 *
	 * @template T
	 * @param string $key
	 * @param T      $default_value
	 *
	 * @return T
	 */
	public static function get( $key = '', $default_value = false ) {
		// Passive initialization.
		self::init();

		$value = isset( self::$data[ $key ] ) ? self::$data[ $key ] : $default_value;

		return apply_filters( self::$prefix . 'get_option', $value, $key, $default_value );
	}

	/**
	 * Update an option
	 *
	 * Updates an setting value in both the db and the global variable.
	 * Warning: Passing in an empty, false or null string value will remove
	 *          the key from the _options array.
	 *
	 * @param string                                    $key The Key to update
	 * @param string|int|bool|array<string, mixed>|null $value The value to set the key to
	 *
	 * @return bool True if updated, false if not.
	 */
	public static function update( $key = '', $value = false ) {
		// Passive initialization.
		self::init();

		// If no key, exit
		if ( empty( $key ) ) {
			return false;
		}

		if ( empty( $value ) ) {
			$remove_option = self::delete( $key );

			return $remove_option;
		}

		// First let's grab the current settings
		$options = get_option( self::$prefix . 'settings', [] );

		// Let's let devs alter that value coming in
		$value = apply_filters( self::$prefix . 'update_option', $value, $key );

		// Next let's try to update the value
		$options[ $key ] = $value;
		$did_update      = update_option( self::$prefix . 'settings', $options );

		// If it updated, let's update the global variable
		if ( $did_update ) {
			self::$data[ $key ] = $value;
		}

		return $did_update;
	}

	/**
	 * Update the entire settings array from a new array.
	 *
	 * @param array<string, string|int|bool|array<string, mixed>|null> $new_options
	 *
	 * @return bool
	 */
	public static function update_all( $new_options = [] ) {
		// First let's grab the current settings
		$options = get_option( self::$prefix . 'settings' );

		// Lets merge options that may exist previously that are not existing now.
		$new_options = wp_parse_args( $new_options, $options );

		$did_update = update_option( self::$prefix . 'settings', $new_options );

		// If it updated, let's update the global variable
		if ( $did_update ) {
			self::$data = $new_options;
		}

		return $did_update;
	}

	/**
	 * Merge the new options into the settings array.
	 *
	 * @param array<string, string|int|bool|array<string, mixed>|null> $new_options
	 *
	 * @return bool
	 */
	public static function merge( $new_options = [] ) {

		$options = self::get_all();

		// Merge new options.
		foreach ( $new_options as $key => $val ) {
			$options[ $key ] = ! empty( $val ) ? $val : false;
		}

		$did_update = update_option( self::$prefix . 'settings', $options );

		// If it updated, let's update the global variable
		if ( $did_update ) {
			self::$data = $options;
		}

		return $did_update;
	}

	/**
	 * Remove an option or multiple
	 *
	 * Removes a setting value in both the db and the global variable.
	 *
	 * @param string|array<int, string> $keys The Key/s to delete
	 *
	 * @return bool True if updated, false if not.
	 */
	public static function delete( $keys = '' ) {
		// Passive initialization.
		self::init();

		// If no key, exit
		if ( empty( $keys ) ) {
			return false;
		} elseif ( is_string( $keys ) ) {
			$keys = [ $keys ];
		}

		// First let's grab the current settings
		$options = get_option( self::$prefix . 'settings' );

		// Remove each key/value pair.
		foreach ( $keys as $key ) {
			if ( isset( $options[ $key ] ) ) {
				unset( $options[ $key ] );
			}
		}

		$did_update = update_option( self::$prefix . 'settings', $options );

		// If it updated, let's update the global variable
		if ( $did_update ) {
			self::$data = $options;
		}

		return $did_update;
	}

	/**
	 * Remaps option keys.
	 *
	 * @param array<string, string> $remap_array an array of $old_key => $new_key values.
	 *
	 * @return bool
	 */
	public static function remap_keys( $remap_array = [] ) {
		$options = self::get_all();

		foreach ( $remap_array as $key => $new_key ) {
			if ( isset( $options[ $key ] ) ) {
				$options[ $new_key ] = $options[ $key ];
			}
			unset( $options[ $key ] );
		}

		$did_update = update_option( self::$prefix . 'settings', $options );

		// If it updated, let's update the global variable
		if ( $did_update ) {
			self::$data = $options;
		}

		return $did_update;
	}
}

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