| @@ -6,8 +6,10 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace Timetics\Core\Appointments; |
| 9 | 9 | |
| 10 | +defined( 'ABSPATH' ) || exit; | |
| 11 | + | |
| 10 | 12 | use Timetics\Utils\Singleton; |
| 11 | 13 | |
| 12 | 14 | class Hooks { |
| 13 | 15 | use Singleton; |
| @@ -22,9 +24,9 @@ | ||
| 22 | 24 | add_action( 'init', [ $this, 'register_appointment' ] ); |
| 23 | 25 | add_action( 'init', [ $this, 'register_appointment_taxonomy' ] ); |
| 24 | 26 | // add_filter( 'get_term', [ $this, 'prepare_term' ], 10, 2 ); |
| 25 | 27 | |
| 26 | - } | |
| 28 | + } | |
| 27 | 29 | |
| 28 | 30 | /** |
| 29 | 31 | * Include custom template for single appointment |
| 30 | 32 | * |
| @@ -32,17 +34,18 @@ | ||
| 32 | 34 | * |
| 33 | 35 | * @return string |
| 34 | 36 | */ |
| 35 | 37 | public function custom_single_post_template( $template ) { |
| 38 | + | |
| 39 | + | |
| 36 | 40 | // Check if it's a single post |
| 37 | - if ( is_single() ) { | |
| 38 | - | |
| 39 | - global $post; | |
| 40 | - | |
| 41 | - if ( 'timetics-appointment' !== $post->post_type ) { | |
| 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) { | |
| 42 | 46 | return $template; |
| 43 | 47 | } |
| 44 | - | |
| 45 | 48 | // Load a custom template file |
| 46 | 49 | $custom_template = TIMETICS_PLUGIN_DIR . '/templates/meeting/custom-single-post-template.php'; |
| 47 | 50 | |
| 48 | 51 | if ( file_exists( $custom_template ) ) { |
| @@ -48,8 +51,22 @@ | ||
| 48 | 51 | if ( file_exists( $custom_template ) ) { |
| 49 | 52 | return $custom_template; |
| 50 | 53 | } |
| 51 | 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 | + | |
| 52 | 69 | } |
| 53 | 70 | |
| 54 | 71 | // Return the original template if no custom template is found |
| 55 | 72 | return $template; |