-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathclass-gf-business-hours.php
102 lines (88 loc) · 2.49 KB
/
class-gf-business-hours.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
class GFBusinessHours extends GFAddOn {
protected $_version = "2.1";
protected $_min_gravityforms_version = "2.0";
protected $_slug = 'gravity-forms-business-hours';
protected $_path = 'gravity-forms-business-hours/gravity-forms-business-hours.php';
protected $_full_path = __FILE__;
protected $_title = 'Gravity Forms Business Hours by GravityView';
protected $_short_title = 'Business Hours';
/**
* Enqueue scripts
* @return [type] [description]
*/
public function scripts() {
$script_debug = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
$scripts = array(
array(
"handle" => "business_hours_app",
"src" => $this->get_base_url() . "/assets/js/public{$script_debug}.js",
"version" => $this->_version,
"deps" => array("jquery"),
'callback' => array($this, 'localize_scripts'),
"enqueue" => array(
array(
"field_types" => array("business_hours"),
),
array(
"admin_page" => array(
"entry_edit",
"entry_detail"
),
),
),
)
);
return array_merge(parent::scripts(), $scripts);
}
/**
* Provide translation for the scripts
* @return void
*/
public function localize_scripts() {
$days = gf_business_hours_get_days();
$strings = array(
'already_exists' => __('This combination already exists', 'gravity-forms-business-hours'),
);
wp_localize_script('business_hours_app', 'GFBusinessHours', $strings);
wp_localize_script('business_hours_app_admin', 'GFBusinessHours', $strings);
}
/**
* Enqueue styles using the Gravity Forms Addons framework
*
* @see GFAddOn::styles()
* @return void
*/
public function styles() {
$styles = array(
array("handle" => "business_hours_admin_style",
"src" => $this->get_base_url() . "/assets/css/admin.css",
"version" => $this->_version,
"enqueue" => array(
array(
"admin_page" => array(
"entry_view",
"entry_detail",
"form_editor",
)
),
),
),
array("handle" => "business_hours_frontend_style",
"src" => $this->get_base_url() . "/assets/css/public.css",
"version" => $this->_version,
"deps" => array("dashicons"),
"enqueue" => array(
array("field_types" => array("business_hours")),
array(
"admin_page" => array(
"entry_edit",
"entry_detail"
),
),
),
),
);
return array_merge(parent::styles(), $styles);
}
}