PluginProbe ʕ •ᴥ•ʔ
Appointment Booking Plugin – LatePoint | Calendar & Scheduling for WordPress / 5.2.9
Appointment Booking Plugin – LatePoint | Calendar & Scheduling for WordPress v5.2.9
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 9 months 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 9 months ago carts_helper.php 1 year ago connector_helper.php 9 months ago csv_helper.php 9 months ago customer_helper.php 9 months ago customer_import_helper.php 4 months ago database_helper.php 9 months ago debug_helper.php 1 year ago defaults_helper.php 1 year ago elementor_helper.php 1 year ago email_helper.php 9 months ago encrypt_helper.php 1 year ago events_helper.php 9 months ago form_helper.php 9 months ago icalendar_helper.php 1 year ago image_helper.php 1 year ago invoices_helper.php 9 months 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 9 months ago meta_helper.php 1 year ago migrations_helper.php 1 year ago money_helper.php 1 year ago notifications_helper.php 9 months ago order_intent_helper.php 9 months ago orders_helper.php 1 year ago otp_helper.php 9 months 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 7 months ago router_helper.php 1 year ago service_helper.php 1 year ago sessions_helper.php 1 year ago settings_helper.php 4 months ago short_links_systems_helper.php 9 months ago shortcodes_helper.php 9 months ago sms_helper.php 1 year ago steps_helper.php 5 months ago stripe_connect_helper.php 9 months ago styles_helper.php 9 months ago support_topics_helper.php 1 year ago time_helper.php 9 months ago timeline_helper.php 9 months ago transaction_helper.php 1 year ago transaction_intent_helper.php 1 year ago util_helper.php 7 months ago version_specific_updates_helper.php 9 months ago whatsapp_helper.php 1 year ago work_periods_helper.php 5 months ago wp_datetime.php 1 year ago wp_user_helper.php 1 year ago
router_helper.php
103 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 }
88 }else{
89 esc_html_e('Page Not Found', 'latepoint');
90 }
91 }
92
93 public static function get_request_param($name, $default = false){
94 if(isset($_GET[$name])){
95 $param = sanitize_text_field(wp_unslash($_GET[$name]));
96 }elseif(isset($_POST[$name])){
97 $param = sanitize_text_field(wp_unslash($_POST[$name]));
98 }else{
99 $param = $default;
100 }
101 return $param;
102 }
103 }