| @@ -1,47 +1,57 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace Booktics\Shortcode; | |
| 4 | - | |
| 5 | -/** | |
| 6 | - * Service View shortcode class | |
| 7 | - */ | |
| 8 | -class Service_Shortcode { | |
| 9 | - /** | |
| 10 | - * Constructor for service view shortcode | |
| 11 | - * | |
| 12 | - * @return void | |
| 13 | - */ | |
| 14 | - public function __construct() { | |
| 15 | - add_shortcode( | |
| 16 | - 'booktics-service-view', array( | |
| 17 | - $this, | |
| 18 | - 'render_service_view', | |
| 19 | - ) | |
| 20 | - ); | |
| 21 | - } | |
| 22 | - | |
| 23 | - /** | |
| 24 | - * Render service view | |
| 25 | - * | |
| 26 | - * @param array $attributes | |
| 27 | - * | |
| 28 | - * @return string | |
| 29 | - */ | |
| 30 | - public function render_service_view( $attributes ) { | |
| 31 | - $id = isset( $attributes['id'] ) ? $attributes['id'] : ''; | |
| 32 | - $post = get_post( $id ); | |
| 33 | - if ( ! $post || ( isset( $post->post_status ) && $post->post_status === 'deactive' ) ) { | |
| 34 | - return '<div class="booktics-shortcode-notice-wrapper"> | |
| 35 | - <div> | |
| 36 | - <h3>' . esc_html__( 'Service Unavailable', 'booktics' ) . '</h3> | |
| 37 | - </div> | |
| 38 | - </div>'; | |
| 39 | - } | |
| 40 | - | |
| 41 | - return "<div class='booktics-shortcode-wrapper'> | |
| 42 | - <div class='booktics-single-service-wrapper' | |
| 43 | - data-id='" . esc_attr( $id ) . "'> | |
| 44 | - </div> | |
| 45 | - </div>"; | |
| 46 | - } | |
| 47 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace Booktics\Shortcode; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Service View shortcode class | |
| 7 | + */ | |
| 8 | +class Service_Shortcode { | |
| 9 | + /** | |
| 10 | + * Constructor for service view shortcode | |
| 11 | + * | |
| 12 | + * @return void | |
| 13 | + */ | |
| 14 | + public function __construct() { | |
| 15 | + add_shortcode( | |
| 16 | + 'booktics_service_view', array( | |
| 17 | + $this, | |
| 18 | + 'render_service_view', | |
| 19 | + ) | |
| 20 | + ); | |
| 21 | + } | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * Render service view | |
| 25 | + * | |
| 26 | + * @param array $attributes | |
| 27 | + * | |
| 28 | + * @return string | |
| 29 | + */ | |
| 30 | + public function render_service_view( $attributes ) { | |
| 31 | + $id = isset( $attributes['id'] ) ? absint( $attributes['id'] ) : 0; | |
| 32 | + | |
| 33 | + wp_enqueue_style( 'booktics-vendor' ); | |
| 34 | + wp_enqueue_style( 'booktics-frontend' ); | |
| 35 | + | |
| 36 | + wp_enqueue_script( 'booktics-packages' ); | |
| 37 | + wp_enqueue_script( 'booktics-frontend-scripts' ); | |
| 38 | + wp_enqueue_script( 'booktics-flatpickr-scripts' ); | |
| 39 | + | |
| 40 | + do_action( 'booktics_before_rendering_service_view_shortcode' ); | |
| 41 | + | |
| 42 | + $post = get_post( $id ); | |
| 43 | + if ( ! $post || ( isset( $post->post_status ) && $post->post_status === 'deactive' ) ) { | |
| 44 | + return '<div class="booktics-shortcode-notice-wrapper"> | |
| 45 | + <div> | |
| 46 | + <h3>' . esc_html__( 'Service Unavailable', 'booktics' ) . '</h3> | |
| 47 | + </div> | |
| 48 | + </div>'; | |
| 49 | + } | |
| 50 | + | |
| 51 | + return "<div class='booktics-shortcode-wrapper'> | |
| 52 | + <div class='booktics-single-service-wrapper' | |
| 53 | + data-id='" . esc_attr( $id ) . "'> | |
| 54 | + </div> | |
| 55 | + </div>"; | |
| 56 | + } | |
| 57 | +} | |