Server : LiteSpeed
System : Linux premium92.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User : rbnsfqys ( 805)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /home/rbnsfqys/public_html/wp-content/plugins/latepoint/lib/helpers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : /home/rbnsfqys/public_html/wp-content/plugins/latepoint/lib/helpers/bricks_helper.php
<?php

class OsBricksHelper {

	private static ?OsBricksHelper $_instance = null;
	private string $min_php_version = '7.4';
	private static array $data = [];

	private array $widgets = [
		'book_button',
		'list_of_resources',
		'customer_login',
		'customer_dashboard',
		'calendar',
		'book_form',
	];

	public static function init(): OsBricksHelper {
		if ( is_null(self::$_instance)) {
			self::$_instance = new self();
		}

		return self::$_instance;
	}

	public function __construct() {
		if ($this->check_requirements()) {
			self::set_data();
			$this->register_widgets();
		}
	}


	private function check_requirements(): bool {
		if(!class_exists( '\Bricks\Elements' )){
			return false;
		}
		if ( ! $this->check_php_version() ) {
			add_action( 'admin_notices', [ $this, 'php_version_error' ] );
			return false;
		}
		return true;
	}

	private function check_php_version(): bool {
		return version_compare( PHP_VERSION, $this->min_php_version, '>=' );
	}

	private function php_version_error(): void {
		$message = esc_html__( 'Theme requires PHP version', 'latepoint' ) . ' <strong>' . $this->min_php_version . '</strong> ' . esc_html__( 'or greater.', 'latepoint' );
		printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
	}

	private function register_widgets() {
		foreach ( $this->widgets as $widget ) {
			$path = LATEPOINT_ABSPATH . 'blocks/bricks/bricks_widget_' . $widget . '.php';
			if ( file_exists( $path ) ) {
				\Bricks\Elements::register_element( $path );
			}
		}
	}

	public static function get_data( $key = false) {
		if (!$key) {
			return self::$data;
		}
		if (!empty(self::$data[$key])) {
			return self::$data[$key];
		}
		return  [];
	}

	private function set_data() {
		$localized_vars = OsBlockHelper::localized_vars_for_blocks();
		self::$data['agents'] = array_column($localized_vars['agents'], 'name', 'id');
		self::$data['services'] = array_column($localized_vars['services'], 'name', 'id');;
		self::$data['locations'] = array_column($localized_vars['locations'], 'name', 'id');
		self::$data['bundles'] = array_column($localized_vars['bundles'], 'name', 'id');
		self::$data['location_categories'] = OsLocationHelper::get_location_categories();
		self::$data['service_categories'] = array_column($localized_vars['service_categories'], 'name', 'id');
		self::$data['selected_agents'] = array_column($localized_vars['selected_agents_options'], 'label', 'value');
		self::$data['selected_services'] = array_column($localized_vars['selected_services_options'], 'label', 'value');
		self::$data['selected_service_categories'] = array_column($localized_vars['selected_service_categories_options'], 'label', 'value');
		self::$data['selected_locations'] = array_column($localized_vars['selected_locations_options'], 'label', 'value');
		self::$data['selected_bundles'] = array_column($localized_vars['selected_bundles_options'], 'label', 'value');
	}

}

F1le Man4ger