| 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 |
|
| 32 |
/** |
| 33 |
* booking form for frontend |
| 34 |
* |
| 35 |
* @return void |
| 36 |
*/ |
| 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'); |
| 43 |
|
| 44 |
$id = isset($attribute['id']) ? $attribute['id'] : ''; |
| 45 |
$data_controls = [ |
| 46 |
'id'=>$id, |
| 47 |
]; |
| 48 |
$controls = json_encode( $data_controls ); |
| 49 |
|
| 50 |
ob_start(); |
| 51 |
?> |
| 52 |
<div class="timetics-shortcode-wrapper"> |
| 53 |
<div class="timetics-single-booking-wrapper" data-controls="<?php echo esc_attr( $controls ); ?>" > </div> |
| 54 |
</div> |
| 55 |
<?php |
| 56 |
return ob_get_clean(); |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* booking form for frontend |
| 61 |
* |
| 62 |
* @return void |
| 63 |
*/ |
| 64 |
public function meeting_list($attribute) { |
| 65 |
wp_enqueue_style('timetics-vendor'); |
| 66 |
wp_enqueue_style('timetics-frontend'); |
| 67 |
|
| 68 |
$limit = isset($attribute['limit']) ? $attribute['limit'] : ''; |
| 69 |
|
| 70 |
ob_start(); |
| 71 |
?> |
| 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> |
| 80 |
</div> |
| 81 |
<?php |
| 82 |
return ob_get_clean(); |
| 83 |
} |
| 84 |
} |
| 85 |
|