| @@ -6,8 +6,10 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace Timetics\Core\Frontend; |
| 9 | 9 | |
| 10 | +defined( 'ABSPATH' ) || exit; | |
| 11 | + | |
| 10 | 12 | use Timetics\Utils\Singleton; |
| 11 | 13 | use Timetics; |
| 12 | 14 | |
| 13 | 15 | /** |
| @@ -26,8 +28,18 @@ | ||
| 26 | 28 | add_shortcode( 'timetics-booking-form', [ $this, 'booking_form' ] ); |
| 27 | 29 | |
| 28 | 30 | // [timetics-meeting-list limit=''] |
| 29 | 31 | add_shortcode( 'timetics-meeting-list', [ $this, 'meeting_list' ] ); |
| 32 | + | |
| 33 | + // [timetics-user-dashboard] | |
| 34 | + add_shortcode( 'timetics-user-dashboard', [ $this, 'user_dashboard' ] ); | |
| 35 | + | |
| 36 | + // [timetics-category id=''] | |
| 37 | + add_shortcode( 'timetics-category', [ $this, 'category_meetings' ] ); | |
| 38 | + | |
| 39 | + if ( class_exists( 'Wpeventin' ) ) { | |
| 40 | + add_action( 'init', [ $this, 'eventin_seat_plan' ] ); | |
| 41 | + } | |
| 30 | 42 | } |
| 31 | 43 | |
| 32 | 44 | /** |
| 33 | 45 | * booking form for frontend |
| @@ -33,52 +45,139 @@ | ||
| 33 | 45 | * booking form for frontend |
| 34 | 46 | * |
| 35 | 47 | * @return void |
| 36 | 48 | */ |
| 37 | - public function booking_form($attribute) { | |
| 38 | - wp_enqueue_style('timetics-vendor'); | |
| 39 | - wp_enqueue_style('timetics-frontend'); | |
| 40 | - wp_enqueue_script('timetics-antd-scripts'); | |
| 41 | - wp_enqueue_script('timetics-flatpickr-scripts'); | |
| 42 | - wp_enqueue_script('timetics-frontend-scripts'); | |
| 49 | + public function booking_form( $attribute ) { | |
| 50 | + wp_enqueue_style( 'timetics-vendor' ); | |
| 51 | + wp_enqueue_style( 'timetics-frontend' ); | |
| 52 | + wp_enqueue_script( 'timetics-flatpickr-scripts' ); | |
| 53 | + wp_enqueue_script( 'timetics-frontend-scripts' ); | |
| 54 | + wp_enqueue_script( 'calendar-locale' ); | |
| 43 | 55 | |
| 44 | - $id = isset($attribute['id']) ? $attribute['id'] : ''; | |
| 56 | + $id = isset( $attribute['id'] ) ? $attribute['id'] : ''; | |
| 45 | 57 | $data_controls = [ |
| 46 | - 'id'=>$id, | |
| 58 | + 'id' => $id, | |
| 47 | 59 | ]; |
| 48 | - $controls = json_encode( $data_controls ); | |
| 60 | + $controls = wp_json_encode( $data_controls ); | |
| 49 | 61 | |
| 62 | + $visibility = get_post_meta( $id, '_tt_apointment_visibility', true ); | |
| 63 | + $is_visible = 'enabled' === $visibility; | |
| 64 | + | |
| 65 | + if ( ! $is_visible && ! current_user_can( 'manage_options' ) ) { | |
| 66 | + return '<div class="timetics-shortcode-wrapper"><p>' . esc_html__( 'This booking form is not available.', 'timetics' ) . '</p></div>'; | |
| 67 | + } | |
| 68 | + | |
| 50 | 69 | ob_start(); |
| 51 | 70 | ?> |
| 71 | + <div class="timetics-shortcode-wrapper"> | |
| 72 | + <div class="timetics-single-booking-wrapper" | |
| 73 | + data-controls="<?php echo esc_attr( $controls ); ?>"></div> | |
| 74 | + </div> | |
| 75 | + <?php | |
| 76 | + return ob_get_clean(); | |
| 77 | + } | |
| 78 | + /** | |
| 79 | + * user dashboard for frontend | |
| 80 | + * | |
| 81 | + * @return void | |
| 82 | + */ | |
| 83 | + public function user_dashboard( $attribute ) { | |
| 84 | + wp_enqueue_style( 'timetics-vendor' ); | |
| 85 | + wp_enqueue_style( 'timetics-frontend' ); | |
| 86 | + wp_enqueue_script( 'timetics-frontend-scripts' ); | |
| 87 | + | |
| 88 | + $id = get_current_user_id(); | |
| 89 | + $data_controls = [ | |
| 90 | + 'id' => $id, | |
| 91 | + ]; | |
| 92 | + $controls = wp_json_encode( $data_controls ); | |
| 93 | + | |
| 94 | + ob_start(); | |
| 95 | + if (is_user_logged_in()) { | |
| 96 | + | |
| 97 | + ?> | |
| 52 | 98 | <div class="timetics-shortcode-wrapper"> |
| 53 | - <div class="timetics-single-booking-wrapper" data-controls="<?php echo esc_attr( $controls ); ?>" > </div> | |
| 99 | + <div class="timetics-user-dashboard-wrapper" | |
| 100 | + data-controls="<?php echo esc_attr( $controls ); ?>"> | |
| 101 | + </div> | |
| 102 | + </div> | |
| 103 | + <?php | |
| 104 | + | |
| 105 | + }else{ | |
| 106 | + ?> | |
| 107 | + <div class="timetics-userdashbaord-wrapper"> | |
| 108 | + <h3> <?php esc_html_e( 'You are not logged in', 'timetics' ); ?> <a href="<?php echo esc_url( wp_login_url( get_permalink() ) ); ?>"><?php esc_html_e( 'Login', 'timetics' ); ?></a></h3> | |
| 54 | 109 | </div> |
| 55 | - <?php | |
| 110 | + <?php | |
| 111 | + } | |
| 56 | 112 | return ob_get_clean(); |
| 113 | + | |
| 57 | 114 | } |
| 58 | 115 | |
| 116 | + public function eventin_seat_plan() { | |
| 117 | + wp_enqueue_style( 'timetics-vendor' ); | |
| 118 | + wp_enqueue_style( 'timetics-frontend' ); | |
| 119 | + wp_enqueue_script( 'timetics-flatpickr-scripts' ); | |
| 120 | + wp_enqueue_script( 'timetics-frontend-scripts' ); | |
| 121 | + } | |
| 122 | + | |
| 59 | 123 | /** |
| 60 | 124 | * booking form for frontend |
| 61 | 125 | * |
| 62 | 126 | * @return void |
| 63 | 127 | */ |
| 64 | - public function meeting_list($attribute) { | |
| 65 | - wp_enqueue_style('timetics-vendor'); | |
| 66 | - wp_enqueue_style('timetics-frontend'); | |
| 128 | + public function meeting_list( $attribute ) { | |
| 129 | + wp_enqueue_style( 'timetics-vendor' ); | |
| 130 | + wp_enqueue_style( 'timetics-frontend' ); | |
| 131 | + wp_enqueue_script( 'timetics-flatpickr-scripts' ); | |
| 132 | + wp_enqueue_script( 'timetics-frontend-scripts' ); | |
| 133 | + wp_enqueue_script( 'calendar-locale' ); | |
| 134 | + wp_enqueue_script( 'jquery' ); | |
| 67 | 135 | |
| 68 | - $limit = isset($attribute['limit']) ? $attribute['limit'] : ''; | |
| 136 | + wp_enqueue_script( 'timetics-meeting-filtering', TIMETICS_ASSETS_URL . 'js/meeting-filter.js', ['jquery'], time(), true ); | |
| 69 | 137 | |
| 138 | + $timetics_limit = isset( $attribute['limit'] ) ? $attribute['limit'] : ''; | |
| 139 | + $timetics_show_filter = isset( $attribute['show_filter'] ) && 'true' == $attribute['show_filter'] ? $attribute['show_filter'] : false; | |
| 140 | + | |
| 70 | 141 | ob_start(); |
| 71 | 142 | ?> |
| 72 | - <div class="timetics-shortcode-wrapper"> | |
| 73 | - <div class="timetics-meeting-list-wrapper"> | |
| 74 | - <?php | |
| 75 | - if (file_exists(TIMETICS_PLUGIN_DIR . 'core/frontend/templates/meeting-list.php')){ | |
| 76 | - require_once TIMETICS_PLUGIN_DIR . 'core/frontend/templates/meeting-list.php'; | |
| 77 | - } | |
| 78 | - ?> | |
| 79 | - </div> | |
| 143 | + <div class="timetics-shortcode-wrapper"> | |
| 144 | + <div class="timetics-meeting-list-wrapper"> | |
| 145 | + <?php | |
| 146 | + if ( file_exists( TIMETICS_PLUGIN_DIR . 'core/frontend/templates/meeting-list.php' ) ) { | |
| 147 | + require_once TIMETICS_PLUGIN_DIR . 'core/frontend/templates/meeting-list.php'; | |
| 148 | + } | |
| 149 | + ?> | |
| 80 | 150 | </div> |
| 151 | + </div> | |
| 152 | + <?php | |
| 153 | + return ob_get_clean(); | |
| 154 | + } | |
| 155 | + | |
| 156 | + /** | |
| 157 | + * category wise meeting for frontend | |
| 158 | + * | |
| 159 | + * @return void | |
| 160 | + */ | |
| 161 | + public function category_meetings( $attribute ) { | |
| 162 | + wp_enqueue_style( 'timetics-vendor' ); | |
| 163 | + wp_enqueue_style( 'timetics-frontend' ); | |
| 164 | + wp_enqueue_script( 'timetics-flatpickr-scripts' ); | |
| 165 | + wp_enqueue_script( 'timetics-frontend-scripts' ); | |
| 166 | + wp_enqueue_script( 'calendar-locale' ); | |
| 167 | + | |
| 168 | + $id = isset( $attribute['id'] ) ? $attribute['id'] : ''; | |
| 169 | + $data_controls = [ | |
| 170 | + 'id' => $id, | |
| 171 | + ]; | |
| 172 | + $controls = wp_json_encode( $data_controls ); | |
| 173 | + | |
| 174 | + ob_start(); | |
| 175 | + ?> | |
| 176 | + <div class="timetics-shortcode-wrapper"> | |
| 177 | + <div class="timetics-category-wrapper" | |
| 178 | + data-controls="<?php echo esc_attr( $controls ); ?>"></div> | |
| 179 | + </div> | |
| 81 | 180 | <?php |
| 82 | 181 | return ob_get_clean(); |
| 83 | 182 | } |
| 84 | 183 | } |