PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.3
Booktics – Appointment Booking Calendar for Service Businesses v1.0.3
1.0.29 1.0.28 1.0.27 1.0.26 1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 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.2 1.0.3 All 31 releases
booktics / core / service / templates / single-service-template.php

single-service-template.php in Booktics – Appointment Booking Calendar for Service Businesses 1.0.3, at core/service/templates/single-service-template.php

68 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Booktics\Service\Templates;
4
5 use Booktics\Contracts\Hookable_Service_Contract;
6
7 /**
8 * Single_Service_Template class handles custom template loading for single service pages
9 *
10 * @package Booktics\Service\Templates
11 */
12 class Single_Service_Template implements Hookable_Service_Contract {
13
14 /**
15 * Register template filter hook
16 *
17 * @return void
18 */
19 public function register() {
20 add_filter(
21 'template_include', array(
22 $this,
23 'custom_single_service_template',
24 )
25 );
26 }
27
28 /**
29 * Loads custom template for single service pages
30 *
31 * @param string $template Current template path
32 *
33 * @return string Modified template path
34 */
35 public function custom_single_service_template( $template ) {
36 if ( is_single() ) {
37 global $post; // Add this line to access the global $post variable
38
39 // Check if the post type is 'booktics-service'
40 if ( 'booktics-service' !== $post->post_type ) {
41 return $template;
42 }
43 if ( $post->post_status === 'deactive' ) {
44 wp_head();
45 ?>
46 <div
47 class="booktics-shortcode-wrapper booktics-shortcode-notice-wrapper">
48 <div>
49 <h3><?php echo esc_html__( 'Service Unavailable', 'booktics' ); ?></h3>
50 </div>
51 </div>
52 <?php
53 wp_footer();
54 exit;
55 }
56 // Load a custom template file
57 $custom_template = BOOKTICS_DIR . '/templates/service/custom-single-service-template.php';
58
59 if ( file_exists( $custom_template ) ) {
60 return $custom_template;
61 }
62 }
63
64 // Return the original template if no custom template is found
65 return $template;
66 }
67 }
68