| 1 |
<?php |
| 2 |
/** |
| 3 |
* @version 1.0 |
| 4 |
* @description Booking Manager - Shortcodes |
| 5 |
* |
| 6 |
* @author wpdevelop |
| 7 |
* @link http://oplugins.com/ |
| 8 |
* @email info@oplugins.com |
| 9 |
* |
| 10 |
* @modified 2017-07-16 |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 14 |
|
| 15 |
|
| 16 |
//////////////////////////////////////////////////////////////////////////////////////////// |
| 17 |
// I M P O R T |
| 18 |
//////////////////////////////////////////////////////////////////////////////////////////// |
| 19 |
|
| 20 |
/** Shortcode [] - Import ICS feed and create bookings from this feed. |
| 21 |
* |
| 22 |
* @param array $attr |
| 23 |
* @return string |
| 24 |
*/ |
| 25 |
function wpbm_ics_import_shortcode( $attr ) { |
| 26 |
|
| 27 |
ob_start(); |
| 28 |
|
| 29 |
$import_status = wpbm_ics_import_start( $attr ); |
| 30 |
|
| 31 |
$echo_results = ob_get_contents(); |
| 32 |
|
| 33 |
ob_end_clean(); |
| 34 |
|
| 35 |
$import_status_echo = sprintf( __( 'Imported %s bookings', 'booking-manager' ), '<strong>' . ( (int) $import_status ) . '</strong>' ); |
| 36 |
|
| 37 |
return $import_status_echo . $echo_results; |
| 38 |
} |
| 39 |
add_shortcode('booking-manager-import', 'wpbm_ics_import_shortcode' ); |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
//////////////////////////////////////////////////////////////////////////////////////////// |
| 45 |
// L I S T I N G |
| 46 |
//////////////////////////////////////////////////////////////////////////////////////////// |
| 47 |
// [booking-manager-listing url='https://server.com/feed.ics' from='2017-08-06' until='week' until_offset='4h' max=500] |
| 48 |
// [booking-manager-listing url='https://server.com/feed.ics' from='today' from_offset='5d' until='year-end' until_offset='4h' max=500] |
| 49 |
// 'now' => __( 'Now', 'booking-manager' ) |
| 50 |
// , 'today' => __( '00:00 Today', 'booking-manager' ) |
| 51 |
// , 'week' => __( 'Start of current week', 'booking-manager' ) |
| 52 |
// , 'month-start' => __( 'Start of current month', 'booking-manager' ) |
| 53 |
// , 'month-end' => __( 'End of current month', 'booking-manager' ) |
| 54 |
// , 'year-start' => __( 'Start of current year', 'booking-manager' ) |
| 55 |
// , 'any' => __( 'The start of time', 'booking-manager' ) |
| 56 |
// , 'date' => __( 'Specific date / time', 'booking-manager' ) |
| 57 |
|
| 58 |
/** Shortcode [booking-manager-listing ...] for showing listing from .ics feed |
| 59 |
* |
| 60 |
* @param array $attr |
| 61 |
*/ |
| 62 |
function wpbm_ics_listing_shortcode( $attr ) { |
| 63 |
|
| 64 |
$listing = wpbm_ics_get_listing( $attr ); |
| 65 |
|
| 66 |
return $listing; |
| 67 |
|
| 68 |
} |
| 69 |
add_shortcode('booking-manager-listing', 'wpbm_ics_listing_shortcode' ); //[booking-manager-listing url='https://calendar.google.com/calendar/ical/pkqi3dnhq1l4j2qu0id3as984k%40group.calendar.google.com/public/basic.ics' from='2016-08-01' until='2018-08-30'] |
| 70 |
|