| @@ -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 | /** |
| @@ -27,8 +29,14 @@ | ||
| 27 | 29 | |
| 28 | 30 | // [timetics-meeting-list limit=''] |
| 29 | 31 | add_shortcode( 'timetics-meeting-list', [ $this, 'meeting_list' ] ); |
| 30 | 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 | + | |
| 31 | 39 | if ( class_exists( 'Wpeventin' ) ) { |
| 32 | 40 | add_action( 'init', [ $this, 'eventin_seat_plan' ] ); |
| 33 | 41 | } |
| 34 | 42 | } |
| @@ -40,18 +48,25 @@ | ||
| 40 | 48 | */ |
| 41 | 49 | public function booking_form( $attribute ) { |
| 42 | 50 | wp_enqueue_style( 'timetics-vendor' ); |
| 43 | 51 | wp_enqueue_style( 'timetics-frontend' ); |
| 44 | - wp_enqueue_script( 'timetics-antd-scripts' ); | |
| 45 | 52 | wp_enqueue_script( 'timetics-flatpickr-scripts' ); |
| 46 | 53 | wp_enqueue_script( 'timetics-frontend-scripts' ); |
| 54 | + wp_enqueue_script( 'calendar-locale' ); | |
| 47 | 55 | |
| 48 | 56 | $id = isset( $attribute['id'] ) ? $attribute['id'] : ''; |
| 49 | 57 | $data_controls = [ |
| 50 | 58 | 'id' => $id, |
| 51 | 59 | ]; |
| 52 | - $controls = json_encode( $data_controls ); | |
| 60 | + $controls = wp_json_encode( $data_controls ); | |
| 53 | 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 | + | |
| 54 | 69 | ob_start(); |
| 55 | 70 | ?> |
| 56 | 71 | <div class="timetics-shortcode-wrapper"> |
| 57 | 72 | <div class="timetics-single-booking-wrapper" |
| @@ -59,13 +74,49 @@ | ||
| 59 | 74 | </div> |
| 60 | 75 | <?php |
| 61 | 76 | return ob_get_clean(); |
| 62 | 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' ); | |
| 63 | 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 | + ?> | |
| 98 | + <div class="timetics-shortcode-wrapper"> | |
| 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> | |
| 109 | + </div> | |
| 110 | + <?php | |
| 111 | + } | |
| 112 | + return ob_get_clean(); | |
| 113 | + | |
| 114 | + } | |
| 115 | + | |
| 64 | 116 | public function eventin_seat_plan() { |
| 65 | 117 | wp_enqueue_style( 'timetics-vendor' ); |
| 66 | 118 | wp_enqueue_style( 'timetics-frontend' ); |
| 67 | - wp_enqueue_script( 'timetics-antd-scripts' ); | |
| 68 | 119 | wp_enqueue_script( 'timetics-flatpickr-scripts' ); |
| 69 | 120 | wp_enqueue_script( 'timetics-frontend-scripts' ); |
| 70 | 121 | } |
| 71 | 122 | |
| @@ -76,14 +127,18 @@ | ||
| 76 | 127 | */ |
| 77 | 128 | public function meeting_list( $attribute ) { |
| 78 | 129 | wp_enqueue_style( 'timetics-vendor' ); |
| 79 | 130 | wp_enqueue_style( 'timetics-frontend' ); |
| 80 | - wp_enqueue_script( 'timetics-antd-scripts' ); | |
| 81 | 131 | wp_enqueue_script( 'timetics-flatpickr-scripts' ); |
| 82 | 132 | wp_enqueue_script( 'timetics-frontend-scripts' ); |
| 133 | + wp_enqueue_script( 'calendar-locale' ); | |
| 134 | + wp_enqueue_script( 'jquery' ); | |
| 83 | 135 | |
| 84 | - $limit = isset( $attribute['limit'] ) ? $attribute['limit'] : ''; | |
| 136 | + wp_enqueue_script( 'timetics-meeting-filtering', TIMETICS_ASSETS_URL . 'js/meeting-filter.js', ['jquery'], time(), true ); | |
| 85 | 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 | + | |
| 86 | 141 | ob_start(); |
| 87 | 142 | ?> |
| 88 | 143 | <div class="timetics-shortcode-wrapper"> |
| 89 | 144 | <div class="timetics-meeting-list-wrapper"> |
| @@ -92,8 +147,36 @@ | ||
| 92 | 147 | require_once TIMETICS_PLUGIN_DIR . 'core/frontend/templates/meeting-list.php'; |
| 93 | 148 | } |
| 94 | 149 | ?> |
| 95 | 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> | |
| 96 | 179 | </div> |
| 97 | 180 | <?php |
| 98 | 181 | return ob_get_clean(); |
| 99 | 182 | } |