PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.28
Booktics – Appointment Booking Calendar for Service Businesses v1.0.28
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.28, at core/service/templates/single-service-template.php

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