| 1 |
<?php |
| 2 |
/** |
| 3 |
* Shortcode class |
| 4 |
* |
| 5 |
* @package Timetics |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace Timetics\Core\Frontend; |
| 9 |
|
| 10 |
use Timetics\Utils\Singleton; |
| 11 |
use Timetics; |
| 12 |
|
| 13 |
/** |
| 14 |
* Class Shortcode |
| 15 |
*/ |
| 16 |
class Shortcode { |
| 17 |
use Singleton; |
| 18 |
|
| 19 |
/** |
| 20 |
* Initialize the shortcode class |
| 21 |
* |
| 22 |
* @return void |
| 23 |
*/ |
| 24 |
public function init() { |
| 25 |
// [timetics-booking-form id=''] |
| 26 |
add_shortcode( 'timetics-booking-form', [ $this, 'booking_form' ] ); |
| 27 |
|
| 28 |
// [timetics-meeting-list limit=''] |
| 29 |
add_shortcode( 'timetics-meeting-list', [ $this, 'meeting_list' ] ); |
| 30 |
|
| 31 |
if ( class_exists( 'Wpeventin' ) ) { |
| 32 |
add_action( 'init', [ $this, 'eventin_seat_plan' ] ); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* booking form for frontend |
| 38 |
* |
| 39 |
* @return void |
| 40 |
*/ |
| 41 |
public function booking_form( $attribute ) { |
| 42 |
wp_enqueue_style( 'timetics-vendor' ); |
| 43 |
wp_enqueue_style( 'timetics-frontend' ); |
| 44 |
wp_enqueue_script( 'timetics-antd-scripts' ); |
| 45 |
wp_enqueue_script( 'timetics-flatpickr-scripts' ); |
| 46 |
wp_enqueue_script( 'timetics-frontend-scripts' ); |
| 47 |
|
| 48 |
$id = isset( $attribute['id'] ) ? $attribute['id'] : ''; |
| 49 |
$data_controls = [ |
| 50 |
'id' => $id, |
| 51 |
]; |
| 52 |
$controls = json_encode( $data_controls ); |
| 53 |
|
| 54 |
ob_start(); |
| 55 |
?> |
| 56 |
<div class="timetics-shortcode-wrapper"> |
| 57 |
<div class="timetics-single-booking-wrapper" |
| 58 |
data-controls="<?php echo esc_attr( $controls ); ?>"></div> |
| 59 |
</div> |
| 60 |
<?php |
| 61 |
return ob_get_clean(); |
| 62 |
} |
| 63 |
|
| 64 |
public function eventin_seat_plan() { |
| 65 |
wp_enqueue_style( 'timetics-vendor' ); |
| 66 |
wp_enqueue_style( 'timetics-frontend' ); |
| 67 |
wp_enqueue_script( 'timetics-antd-scripts' ); |
| 68 |
wp_enqueue_script( 'timetics-flatpickr-scripts' ); |
| 69 |
wp_enqueue_script( 'timetics-frontend-scripts' ); |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* booking form for frontend |
| 74 |
* |
| 75 |
* @return void |
| 76 |
*/ |
| 77 |
public function meeting_list( $attribute ) { |
| 78 |
wp_enqueue_style( 'timetics-vendor' ); |
| 79 |
wp_enqueue_style( 'timetics-frontend' ); |
| 80 |
wp_enqueue_script( 'timetics-antd-scripts' ); |
| 81 |
wp_enqueue_script( 'timetics-flatpickr-scripts' ); |
| 82 |
wp_enqueue_script( 'timetics-frontend-scripts' ); |
| 83 |
|
| 84 |
$limit = isset( $attribute['limit'] ) ? $attribute['limit'] : ''; |
| 85 |
|
| 86 |
ob_start(); |
| 87 |
?> |
| 88 |
<div class="timetics-shortcode-wrapper"> |
| 89 |
<div class="timetics-meeting-list-wrapper"> |
| 90 |
<?php |
| 91 |
if ( file_exists( TIMETICS_PLUGIN_DIR . 'core/frontend/templates/meeting-list.php' ) ) { |
| 92 |
require_once TIMETICS_PLUGIN_DIR . 'core/frontend/templates/meeting-list.php'; |
| 93 |
} |
| 94 |
?> |
| 95 |
</div> |
| 96 |
</div> |
| 97 |
<?php |
| 98 |
return ob_get_clean(); |
| 99 |
} |
| 100 |
} |
| 101 |
|