PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / 1.0.10
Timetics – Appointment Booking Calendar & Scheduling v1.0.10
1.0.61 1.0.60 1.0.59 1.0.58 1.0.57 1.0.56 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.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 All 62 releases
timetics / core / appointments / hooks.php

hooks.php in Timetics – Appointment Booking Calendar & Scheduling 1.0.10, at core/appointments/hooks.php

145 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Booking related hooks
4 *
5 * @package Timetics
6 */
7
8 namespace Timetics\Core\Appointments;
9
10 use Timetics\Utils\Singleton;
11
12 class Hooks {
13 use Singleton;
14
15 /**
16 * Initialize
17 *
18 * @return void
19 */
20 public function init() {
21 add_filter( 'template_include', [ $this, 'custom_single_post_template' ] );
22 add_action( 'init', [ $this, 'register_appointment' ] );
23 add_action( 'init', [ $this, 'register_appointment_taxonomy' ] );
24 // add_filter( 'get_term', [ $this, 'prepare_term' ], 10, 2 );
25
26 }
27
28 /**
29 * Include custom template for single appointment
30 *
31 * @param string $template
32 *
33 * @return string
34 */
35 public function custom_single_post_template( $template ) {
36 // Check if it's a single post
37 if ( is_single() ) {
38
39 global $post;
40
41 if ( 'timetics-appointment' !== $post->post_type ) {
42 return $template;
43 }
44
45 // Load a custom template file
46 $custom_template = TIMETICS_PLUGIN_DIR . '/templates/meeting/custom-single-post-template.php';
47
48 if ( file_exists( $custom_template ) ) {
49 return $custom_template;
50 }
51
52 }
53
54 // Return the original template if no custom template is found
55 return $template;
56 }
57
58 /**
59 * Register custom post type for appointment
60 *
61 * @return void
62 */
63 public function register_appointment() {
64 $labels = array(
65 'name' => __( 'Timetics Appointments', 'timetics' ),
66 'singular_name' => __( 'Timetics Appointment', 'timetics' ),
67 'menu_name' => __( 'Timetics Appointments', 'timetics' ),
68 'add_new' => __( 'Add New', 'timetics' ),
69 'add_new_item' => __( 'Add New Timetics Appointment', 'timetics'),
70 'edit' => __( 'Edit', 'timetics' ),
71 'edit_item' => __( 'Edit Timetics Appointment', 'timetics' ),
72 'new_item' => __( 'New Timetics Appointment', 'timetics' ),
73 'view' => __( 'View', 'timetics' ),
74 'view_item' => __( 'View Timetics Appointment', 'timetics' ),
75 'search_items' => __( 'Search Timetics Appointments', 'timetics' ),
76 'not_found' => __( 'No timetics appointments found', 'timetics' ),
77 'not_found_in_trash' => __( 'No timetics appointments found in trash', 'timetics' ),
78 'parent' => __( 'Parent Timetics Appointment', 'timetics' ),
79 );
80
81 $args = array(
82 'labels' => $labels,
83 'public' => true,
84 'publicly_queryable' => true,
85 'show_ui' => true,
86 'show_in_menu' => false,
87 'query_var' => true,
88 'rewrite' => array( 'slug' => 'timetics-appointment' ),
89 'capability_type' => 'post',
90 'has_archive' => true,
91 'hierarchical' => false,
92 'menu_position' => null,
93 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
94 );
95
96 register_post_type( 'timetics-appointment', $args );
97 }
98
99 public function register_appointment_taxonomy() {
100 $labels = array(
101 'name' => __( 'Appointment categories', 'timetics' ),
102 'singular_name' => __( 'Appointment category', 'timetics' ),
103 'menu_name' => __( 'Appointment category', 'timetics' ),
104 'all_items' => __( 'Appointment categories', 'timetics' ),
105 'parent_item' => __( 'Parent Genre', 'timetics' ),
106 'parent_item_colon' => __( 'Parent Genre:', 'timetics' ),
107 'new_item_name' => __( 'New Genre Name', 'timetics' ),
108 'add_new_item' => __( 'Add New Genre', 'timetics' ),
109 'edit_item' => __( 'Edit Genre', 'timetics' ),
110 'update_item' => __( 'Update Genre', 'timetics' ),
111 'view_item' => __( 'View Genre', 'timetics' ),
112 'separate_items_with_commas' => __( 'Separate genres with commas', 'timetics' ),
113 'add_or_remove_items' => __( 'Add or remove genres', 'timetics' ),
114 'choose_from_most_used' => __( 'Choose from the most used genres', 'timetics' ),
115 'popular_items' => __( 'Popular Genres', 'timetics' ),
116 'search_items' => __( 'Search Genres', 'timetics' ),
117 'not_found' => __( 'Genre Not Found', 'timetics' ),
118 'no_terms' => __( 'No genres', 'timetics' ),
119 'items_list' => __( 'Genres list', 'timetics' ),
120 'items_list_navigation' => __( 'Genres list navigation', 'timetics' ),
121 );
122
123 $args = array(
124 'labels' => $labels,
125 'hierarchical' => true,
126 'public' => true,
127 'show_ui' => false,
128 'show_admin_column' => true,
129 'show_in_nav_menus' => true,
130 'show_tagcloud' => true,
131 );
132
133 register_taxonomy( 'timetics-meeting-category', array( 'book' ), $args ); //
134 }
135
136 public function prepare_term( $term, $taxonomy ) {
137 if ( 'timetics-meeting-category' !== $taxonomy ) {
138 return $term;
139 }
140
141
142 return $term;
143 }
144 }
145