PluginProbe ʕ •ᴥ•ʔ
Appointment Booking Plugin – LatePoint | Calendar & Scheduling for WordPress / 5.1.4
Appointment Booking Plugin – LatePoint | Calendar & Scheduling for WordPress v5.1.4
5.6.8 5.6.7 5.6.6 5.6.5 5.6.4 5.6.3 5.6.2 5.6.1 5.6.0 5.5.2 5.5.1 5.5.0 5.4.2 trunk 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.1.8 5.1.9 5.1.91 5.1.92 5.1.93 5.1.94 5.2.0 5.2.1 5.2.10 5.2.11 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.0 5.3.1 5.3.2 5.4.0 5.4.1
latepoint / lib / helpers / router_helper.php
latepoint / lib / helpers Last commit date
activities_helper.php 1 year ago agent_helper.php 1 year ago auth_helper.php 1 year ago blocks_helper.php 1 year ago booking_helper.php 1 year ago bricks_helper.php 1 year ago bundles_helper.php 1 year ago calendar_helper.php 1 year ago carts_helper.php 1 year ago connector_helper.php 1 year ago csv_helper.php 1 year ago customer_helper.php 1 year ago database_helper.php 1 year ago debug_helper.php 1 year ago defaults_helper.php 1 year ago elementor_helper.php 1 year ago email_helper.php 1 year ago encrypt_helper.php 1 year ago events_helper.php 1 year ago form_helper.php 1 year ago icalendar_helper.php 1 year ago image_helper.php 1 year ago invoices_helper.php 1 year ago license_helper.php 1 year ago location_helper.php 1 year ago marketing_systems_helper.php 1 year ago meeting_systems_helper.php 1 year ago menu_helper.php 1 year ago meta_helper.php 1 year ago migrations_helper.php 1 year ago money_helper.php 1 year ago notifications_helper.php 1 year ago order_intent_helper.php 1 year ago orders_helper.php 1 year ago pages_helper.php 1 year ago params_helper.php 1 year ago payments_helper.php 1 year ago price_breakdown_helper.php 1 year ago process_jobs_helper.php 1 year ago processes_helper.php 1 year ago replacer_helper.php 1 year ago resource_helper.php 1 year ago roles_helper.php 1 year ago router_helper.php 1 year ago service_helper.php 1 year ago sessions_helper.php 1 year ago settings_helper.php 1 year ago shortcodes_helper.php 1 year ago sms_helper.php 1 year ago steps_helper.php 1 year ago stripe_connect_helper.php 1 year ago styles_helper.php 1 year ago support_topics_helper.php 1 year ago time_helper.php 1 year ago timeline_helper.php 1 year ago transaction_intent_helper.php 1 year ago util_helper.php 1 year ago version_specific_updates_helper.php 1 year ago whatsapp_helper.php 1 year ago work_periods_helper.php 1 year ago wp_datetime.php 1 year ago wp_user_helper.php 1 year ago
router_helper.php
104 lines
1 <?php
2
3 class OsRouterHelper {
4
5 public static function build_pre_route_link($route, $params = array()){
6 return self::build_link($route, array_merge(array('pre_route'=> 1), $params));
7 }
8
9 public static function add_extension($string = '', $extension = '.php'){
10 if(substr($string, -strlen($extension))===$extension) return $string;
11 else return $string.$extension;
12 }
13
14 public static function build_link($route, $params = array()){
15 $params_query = '';
16 if($params){
17 $params_query = '&'.http_build_query($params);
18 }
19 if(is_array($route) && (count($route) == 2)) $route = OsRouterHelper::build_route_name($route[0], $route[1]);
20 return admin_url('admin.php?page=latepoint&route_name='.$route.$params_query);
21 }
22
23 public static function build_admin_post_link($route, $params = array()){
24 $params_query = '';
25 if($params){
26 $params_query = '&'.http_build_query($params);
27 }
28 if(is_array($route) && (count($route) == 2)) $route = OsRouterHelper::build_route_name($route[0], $route[1]);
29 return admin_url('admin-post.php?action=latepoint_route_call&route_name='.$route.$params_query);
30 }
31
32 public static function link_has_route($route_name, $link){
33 $link_params = wp_parse_url($link);
34 if(empty($link_params['query'])) return false;
35 parse_str($link_params['query'], $link_query_params);
36 return ($link_query_params && isset($link_query_params['route_name']) && ($link_query_params['route_name'] == $route_name));
37 }
38
39 public static function build_front_link($route, $params = array()){
40 $params_query = '';
41 if($params){
42 $params_query = '&'.http_build_query($params);
43 }
44 if(is_array($route) && (count($route) == 2)) $route = OsRouterHelper::build_route_name($route[0], $route[1]);
45 return site_url('index.php?latepoint_is_custom_route=true&route_name='.$route.$params_query);
46 }
47
48 public static function build_route_name($controller, $action){
49 return $controller.'__'.$action;
50 }
51
52 public static function convert_route_name_to_controller_and_action($route_name): array{
53 list($controller_name, $action) = explode('__', $route_name);
54 if(empty($controller_name) || empty($action)) return [];
55 $controller_name = str_replace('_', '', ucwords($controller_name, '_'));
56 $controller_class_name = 'Os'.$controller_name.'Controller';
57 if(class_exists($controller_class_name)) {
58 $controller_obj = new $controller_class_name();
59 if(method_exists($controller_obj, $action)) {
60 // check if action is valid
61 return ['controller' => $controller_obj, 'action' => $action];
62 }else{
63 return [];
64 }
65 }else{
66 return [];
67 }
68 }
69
70 public static function call_by_route_name($route_name, $return_format = 'html'){
71 OsDebugHelper::log_route($route_name, $return_format);
72 $route_data = self::convert_route_name_to_controller_and_action($route_name);
73 if(!empty($route_data)){
74 $controller_obj = $route_data['controller'];
75 $action = $route_data['action'];
76 if($return_format) $controller_obj->set_return_format($return_format);
77 // check if user is allowed to access this route
78 if($controller_obj->can_current_user_access_action($action)){
79 $controller_obj->route_name = $route_name;
80 $controller_obj->$action();
81 }else{
82 if($controller_obj->get_return_format() == 'json'){
83 $controller_obj->send_json( ['status' => LATEPOINT_STATUS_ERROR, 'message' => __('Not Authorized', 'latepoint')] );
84 }else{
85 echo '<div class="latepoint-not-authorized"><div class="not-authorized-message">'.esc_html__('Not Authorized', 'latepoint').'</div></div>';
86 }
87 exit();
88 }
89 }else{
90 esc_html_e('Page Not Found', 'latepoint');
91 }
92 }
93
94 public static function get_request_param($name, $default = false){
95 if(isset($_GET[$name])){
96 $param = sanitize_text_field(wp_unslash($_GET[$name]));
97 }elseif(isset($_POST[$name])){
98 $param = sanitize_text_field(wp_unslash($_POST[$name]));
99 }else{
100 $param = $default;
101 }
102 return $param;
103 }
104 }