| @@ -12,11 +12,11 @@ | ||
| 12 | 12 | * @return void |
| 13 | 13 | */ |
| 14 | 14 | public function __construct() { |
| 15 | 15 | add_shortcode( |
| 16 | - 'booktics-service-view', array( | |
| 17 | - $this, | |
| 18 | - 'render_service_view', | |
| 16 | + 'booktics_service_view', array( | |
| 17 | + $this, | |
| 18 | + 'render_service_view', | |
| 19 | 19 | ) |
| 20 | 20 | ); |
| 21 | 21 | } |
| 22 | 22 | |
| @@ -27,9 +27,27 @@ | ||
| 27 | 27 | * |
| 28 | 28 | * @return string |
| 29 | 29 | */ |
| 30 | 30 | public function render_service_view( $attributes ) { |
| 31 | - $id = isset( $attributes['id'] ) ? $attributes['id'] : ''; | |
| 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 | + } | |
| 32 | 50 | |
| 33 | 51 | return "<div class='booktics-shortcode-wrapper'> |
| 34 | 52 | <div class='booktics-single-service-wrapper' |
| 35 | 53 | data-id='" . esc_attr( $id ) . "'> |