PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / 1.0.56
Timetics – Appointment Booking Calendar & Scheduling v1.0.56
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.56, at core/appointments/hooks.php

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