Below, you’ll find a detailed guide on how to add the Booking Manager Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Booking Manager Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the Booking Manager Plugin and the shortcodes it provides:
"Booking Manager is a highly efficient WordPress plugin that simplifies your reservation process. It enables seamless management of appointments, schedules, and bookings right from your website."
- [booking-manager-import]
- [booking-manager-listing]
- [booking-manager-delete]
Booking Manager [booking-manager-import] Shortcode
The Booking Manager shortcode is a crucial tool for importing booking data. It initiates the ‘wpbm_ics_import_start’ function which starts the import process.
The function uses output buffering to capture the import status. If the ‘silence’ attribute is set, no import message is shown. Otherwise, it displays the number of imported bookings.
Shortcode: [booking-manager-import]
Parameters
Here is a list of all possible booking-manager-import shortcode parameters and attributes:
silence
– hides the ‘Import XX bookings’ message if set to 1
Examples and Usage
Basic example – Utilize the shortcode to import bookings into the Booking Manager system.
[booking-manager-import]
PHP Function Code
In case you have difficulties debugging what causing issues with [booking-manager-import]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('booking-manager-import', 'wpbm_ics_import_shortcode' );
Shortcode PHP function:
function wpbm_ics_import_shortcode( $attr ) { ob_start(); $import_status = wpbm_ics_import_start( $attr ); $echo_results = ob_get_contents(); ob_end_clean(); if ( ! empty( $attr['silence'] ) ) { //FixIn: m.2.0.1.2 - do not show 'Import XX bookings' message, if paremeter silence=1 in shortcode $import_status_echo = ''; } else { $import_status_echo = sprintf( __( 'Imported %s bookings', 'booking-manager' ), '<strong>' . ( (int) $import_status ) . '</strong>' ); } return $import_status_echo . $echo_results; }
Code file location:
booking-manager/booking-manager/core/wpbm-shortcodes.php
Booking Manager [booking-manager-listing] Shortcode
The Booking Manager shortcode allows users to display a list of bookings from an external iCalendar URL. The details of the bookings from the specified date range will be listed.
Shortcode: [booking-manager-listing]
Parameters
Here is a list of all possible booking-manager-listing shortcode parameters and attributes:
url
– The web address of the iCalendar (.ics) filefrom
– The start date for the booking perioduntil
– The end date for the booking period
Examples and Usage
Basic example – A straightforward usage of the shortcode to display a booking manager listing from a specific Google Calendar.
[booking-manager-listing url='https://calendar.google.com/calendar/ical/example%40group.calendar.google.com/public/basic.ics' from='2022-01-01' until='2022-12-31']
PHP Function Code
In case you have difficulties debugging what causing issues with [booking-manager-listing]
shortcode, check below the related PHP functions code.
Shortcode line:
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']
Shortcode PHP function:
function wpbm_ics_listing_shortcode( $attr ) { $listing = wpbm_ics_get_listing( $attr ); return $listing; }
Code file location:
booking-manager/booking-manager/core/wpbm-shortcodes.php
Booking Manager [booking-manager-delete] Shortcode
The Booking Manager shortcode is designed to manage booking deletions efficiently. It checks if a ‘resource_id’ is set, if not, it defaults to 1.
Shortcode: [booking-manager-delete]
Parameters
Here is a list of all possible booking-manager-delete shortcode parameters and attributes:
resource_id
– Identifier of the booking type to be deleted.
Examples and Usage
Basic example – Utilizing the ‘booking-manager-delete’ shortcode with the default ‘resource_id’ attribute set to 1.
[booking-manager-delete]
PHP Function Code
In case you have difficulties debugging what causing issues with [booking-manager-delete]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'booking-manager-delete', 'wpbm_ics_delete_shortcode' );
Shortcode PHP function:
function wpbm_ics_delete_shortcode( $attr ) { ob_start(); if ( ! isset( $attr['resource_id'] ) ) { $attr['resource_id'] = 1; } global $wpdb; $is_trash = 1; $resource_id = $attr['resource_id']; $my_sql = "UPDATE {$wpdb->prefix}booking AS bk SET bk.trash = {$is_trash} WHERE sync_gid != '' AND trash != 1 AND booking_type = {$resource_id}"; if ( false === $wpdb->query( $my_sql ) ){ ?> <script type="text/javascript"> var my_message = '<?php echo html_entity_decode( esc_js( get_debuge_error('Error during trash booking in DB' ,__FILE__,__LINE__) ),ENT_QUOTES) ; ?>'; wpbc_admin_show_message( my_message, 'error', 30000 ); </script> <?php } $echo_results = ob_get_contents(); ob_end_clean(); return ''; }
Code file location:
booking-manager/booking-manager/core/wpbm-shortcodes.php
Conclusion
Now that you’ve learned how to embed the Booking Manager Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply