activities_helper.php
3 months ago
agent_helper.php
3 months ago
analytics_helper.php
4 months ago
auth_helper.php
3 months ago
blocks_helper.php
3 months ago
booking_helper.php
3 months ago
bricks_helper.php
3 months ago
bundles_helper.php
3 months ago
calendar_helper.php
3 months ago
carts_helper.php
3 months ago
connector_helper.php
3 months ago
csv_helper.php
3 months ago
customer_helper.php
3 months ago
customer_import_helper.php
3 months ago
database_helper.php
3 months ago
debug_helper.php
3 months ago
defaults_helper.php
3 months ago
elementor_helper.php
3 months ago
email_helper.php
3 months ago
encrypt_helper.php
3 months ago
events_helper.php
3 months ago
form_helper.php
3 months ago
icalendar_helper.php
3 months ago
image_helper.php
3 months ago
invoices_helper.php
3 months ago
license_helper.php
3 months ago
location_helper.php
3 months ago
marketing_systems_helper.php
3 months ago
meeting_systems_helper.php
3 months ago
menu_helper.php
3 months ago
meta_helper.php
3 months ago
migrations_helper.php
3 months ago
money_helper.php
3 months ago
notifications_helper.php
3 months ago
nps_survey_helper.php
3 months ago
order_intent_helper.php
3 months ago
orders_helper.php
3 months ago
otp_helper.php
3 months ago
pages_helper.php
3 months ago
params_helper.php
3 months ago
payments_helper.php
3 months ago
price_breakdown_helper.php
3 months ago
process_jobs_helper.php
3 months ago
processes_helper.php
3 months ago
replacer_helper.php
3 months ago
resource_helper.php
3 months ago
roles_helper.php
3 months ago
router_helper.php
3 months ago
service_helper.php
3 months ago
sessions_helper.php
3 months ago
settings_helper.php
3 months ago
short_links_systems_helper.php
3 months ago
shortcodes_helper.php
3 months ago
sms_helper.php
3 months ago
steps_helper.php
3 months ago
stripe_connect_helper.php
3 months ago
styles_helper.php
3 months ago
support_topics_helper.php
3 months ago
time_helper.php
3 months ago
timeline_helper.php
3 months ago
transaction_helper.php
3 months ago
transaction_intent_helper.php
3 months ago
util_helper.php
3 months ago
version_specific_updates_helper.php
3 months ago
whatsapp_helper.php
3 months ago
work_periods_helper.php
3 months ago
wp_datetime.php
3 months ago
wp_user_helper.php
3 months ago
bricks_helper.php
88 lines
| 1 | <?php |
| 2 | |
| 3 | class OsBricksHelper { |
| 4 | |
| 5 | private static ?OsBricksHelper $_instance = null; |
| 6 | private string $min_php_version = '7.4'; |
| 7 | private static array $data = []; |
| 8 | |
| 9 | private array $widgets = [ |
| 10 | 'book_button', |
| 11 | 'list_of_resources', |
| 12 | 'customer_login', |
| 13 | 'customer_dashboard', |
| 14 | 'calendar', |
| 15 | 'book_form', |
| 16 | ]; |
| 17 | |
| 18 | public static function init(): OsBricksHelper { |
| 19 | if ( is_null( self::$_instance ) ) { |
| 20 | self::$_instance = new self(); |
| 21 | } |
| 22 | |
| 23 | return self::$_instance; |
| 24 | } |
| 25 | |
| 26 | public function __construct() { |
| 27 | if ( $this->check_requirements() ) { |
| 28 | self::set_data(); |
| 29 | $this->register_widgets(); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | |
| 34 | private function check_requirements(): bool { |
| 35 | if ( ! class_exists( '\Bricks\Elements' ) ) { |
| 36 | return false; |
| 37 | } |
| 38 | if ( ! $this->check_php_version() ) { |
| 39 | add_action( 'admin_notices', [ $this, 'php_version_error' ] ); |
| 40 | return false; |
| 41 | } |
| 42 | return true; |
| 43 | } |
| 44 | |
| 45 | private function check_php_version(): bool { |
| 46 | return version_compare( PHP_VERSION, $this->min_php_version, '>=' ); |
| 47 | } |
| 48 | |
| 49 | private function php_version_error(): void { |
| 50 | $message = esc_html__( 'Theme requires PHP version', 'latepoint' ) . ' <strong>' . $this->min_php_version . '</strong> ' . esc_html__( 'or greater.', 'latepoint' ); |
| 51 | printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message ); |
| 52 | } |
| 53 | |
| 54 | private function register_widgets() { |
| 55 | foreach ( $this->widgets as $widget ) { |
| 56 | $path = LATEPOINT_ABSPATH . 'blocks/bricks/bricks_widget_' . $widget . '.php'; |
| 57 | if ( file_exists( $path ) ) { |
| 58 | \Bricks\Elements::register_element( $path ); |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | public static function get_data( $key = false ) { |
| 64 | if ( ! $key ) { |
| 65 | return self::$data; |
| 66 | } |
| 67 | if ( ! empty( self::$data[ $key ] ) ) { |
| 68 | return self::$data[ $key ]; |
| 69 | } |
| 70 | return []; |
| 71 | } |
| 72 | |
| 73 | private function set_data() { |
| 74 | $localized_vars = OsBlockHelper::localized_vars_for_blocks(); |
| 75 | self::$data['agents'] = array_column( $localized_vars['agents'], 'name', 'id' ); |
| 76 | self::$data['services'] = array_column( $localized_vars['services'], 'name', 'id' ); |
| 77 | self::$data['locations'] = array_column( $localized_vars['locations'], 'name', 'id' ); |
| 78 | self::$data['bundles'] = array_column( $localized_vars['bundles'], 'name', 'id' ); |
| 79 | self::$data['location_categories'] = OsLocationHelper::get_location_categories(); |
| 80 | self::$data['service_categories'] = array_column( $localized_vars['service_categories'], 'name', 'id' ); |
| 81 | self::$data['selected_agents'] = array_column( $localized_vars['selected_agents_options'], 'label', 'value' ); |
| 82 | self::$data['selected_services'] = array_column( $localized_vars['selected_services_options'], 'label', 'value' ); |
| 83 | self::$data['selected_service_categories'] = array_column( $localized_vars['selected_service_categories_options'], 'label', 'value' ); |
| 84 | self::$data['selected_locations'] = array_column( $localized_vars['selected_locations_options'], 'label', 'value' ); |
| 85 | self::$data['selected_bundles'] = array_column( $localized_vars['selected_bundles_options'], 'label', 'value' ); |
| 86 | } |
| 87 | } |
| 88 |