Repository navigation
Expand file tree
/
Copy pathBookingInit.php
More file actions
executable file
·150 lines (112 loc) · 4.1 KB
/
Copy pathBookingInit.php
File metadata and controls
executable file
·150 lines (112 loc) · 4.1 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
require_once 'Views.php';
require_once 'Apis.php';
require_once 'omiHooks.php';
/**
* @author omibeaver
* @name BookingInit WP init hooks
*
*/
class BookingInit
{
function __construct()
{
//create booking post type.
add_action('init', function () {
omiHooks::booking_record_fun();
});
//init routes.
add_action('rest_api_init', function () {
self::register_api();
});
//custom admin booking pane btn column.
add_action('admin_init', function () {
omiHooks::booking_view_ext();
});
//custom admin booking pane save post.
add_action('save_post', function ($post_id, $view) {
omiHooks::booking_cus_save($post_id, $view);
}, 10, 2);
//custom admin booking pane column.
add_action('manage_macro_booking_record_posts_custom_column', function ($column, $post_id) {
omiHooks::booking_admin_column($column, $post_id);
}, 10, 2);
//custom admin booking pane columns.
add_filter('manage_macro_booking_record_posts_columns', function ($columns) {
return omiHooks::booking_admin_columns($columns);
});
//load custom JS.
add_action( 'admin_enqueue_scripts', function (){
omiHooks::loadJs();
} );
//hook admin pane booking statue change.
add_action('wp_ajax_change_booking_status', function () {
omiHooks::change_booking_status();
});
//hook admin pane booking statue change.
add_action('wp_ajax_nopriv_change_booking_status',function (){
omiHooks::change_booking_status();
});
//custom admin booking pane row
add_action( 'post_row_actions',function ($actions,$post ){
return omiHooks::removeRowBtn($actions,$post );
} ,10,2);
//custom woocommerce product
add_filter( 'woocommerce_rest_prepare_shop_order_object', function ($data, $post, $context){
return omiHooks::customOrderQuery($data, $post, $context);
}, 12, 3 );
//close auto-update tips.
omiHooks::closeUpdate();
}
//start register all hooks.
private static function register_api()
{
//rest loginIn
register_rest_route('macro', '/booking_signIn', array(
'methods' => 'GET',
'callback' => function ($request) {
return (new Apis($request))->bookingSignIn();
},
'permission_callback' => '__return_true'
));
//rest query booking list by user
register_rest_route('macro', '/booking_list', array(
'methods' => 'GET',
'callback' => function ($request) {
return (new Apis($request))->bookingListQuery();
},
'permission_callback' => '__return_true'
));
//rest signUp
register_rest_route('macro', '/booking_signUp', array(
'methods' => 'POST',
'callback' => function ($request) {
return (new Apis($request))->bookingSignUp();
},
'permission_callback' => '__return_true'
));
//rest create new booking
register_rest_route('macro', '/booking_create', array(
'methods' => 'POST',
'callback' => function ($request) {
return (new Apis($request))->bookingCreate();
},
'permission_callback' => '__return_true'
));
//rest change booking status
register_rest_route('macro', '/booking_update', array(
'methods' => 'PUT',
'callback' => function ($request) {
return (new Apis($request))->bookingStatusUpdate();
},
'permission_callback' => '__return_true'
));
register_rest_route('macro', '/create_order', array(
'methods' => 'POST',
'callback' => function ($request) {
return (new Apis($request))->createOrder();
},
'permission_callback' => '__return_true'
));
}
}