PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.21
Booktics – Appointment Booking Calendar for Service Businesses v1.0.21
1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 All 27 releases
booktics / core / assets / localize.php

localize.php in Booktics – Appointment Booking Calendar for Service Businesses 1.0.21, at core/assets/localize.php

62 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Booktics\Assets;
3
4 if ( ! defined( 'ABSPATH' ) ) exit;
5
6 /**
7 * Manage all localize data
8 */
9 class Localize {
10
11 /**
12 * Get admin localize data
13 *
14 * @return array Collection localize data
15 */
16 public static function get_admin() {
17 $current_user = wp_get_current_user();
18 $user_roles = [];
19 if ( isset( $current_user->roles ) && is_array( $current_user->roles) ) {
20 foreach( $current_user->roles as $role) {
21 $user_roles[] = $role;
22 }
23 }
24
25 $data = [
26 'site_url' => site_url(),
27 'admin_url' => admin_url(),
28 'nonce' => wp_create_nonce( 'wp_rest' ),
29 'date_format' => get_option( 'date_format' ),
30 'date_format_string' => date_i18n( get_option( 'date_format' ) ),
31 'time_format' => get_option( 'time_format' ),
32 'time_format_string' => date_i18n( get_option( 'time_format' ) ),
33 'start_of_week' => get_option( 'start_of_week', 0 ),
34 'current_user_id' => get_current_user_id(),
35 'currency_list' => booktics_get_currencies(),
36 'bookticsPro' => class_exists('BookticsPro'),
37 'user_role' => (array) $user_roles,
38 ];
39
40 return apply_filters( 'booktics_admin_localize', $data );
41 }
42
43 /**
44 * Get frontend localize data
45 *
46 * @return array Collection localize data
47 */
48 public static function get_frontend() {
49 $data = [
50 'site_url' => site_url(),
51 'nonce' => wp_create_nonce( 'wp_rest' ),
52 'date_format' => get_option( 'date_format' ),
53 'time_format' => get_option( 'time_format' ),
54 'current_user_id' => get_current_user_id(),
55 'start_of_week' => get_option( 'start_of_week', 0 ),
56 'locale_name' => strtolower( str_replace( '_', '-', get_locale() ) ),
57 'currency_list' => booktics_get_currencies(),
58 ];
59
60 return apply_filters( 'booktics_frontend_localize', $data );
61 }
62 }