Below, you’ll find a detailed guide on how to add the Booking Calendar 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 Calendar Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the Booking Calendar Plugin and the shortcodes it provides:
"Booking Calendar is a powerful WordPress plugin that simplifies the booking process for your visitors. It is user-friendly, customizable, and perfect for any booking systems."
- [booking]
- [bookingcalendar]
- [bookingform]
- [bookingedit]
- [bookingsearch]
- [bookingsearchresults]
- [bookingselect]
- [bookingresource]
- [bookingtimeline]
- [bookingcustomerlisting]
- [booking_test_speed]
- [bookingflextimeline]
Booking Calendar [booking] Shortcode
The Booking Calendar shortcode allows you to add a booking form to your site. It customizes the booking type, form type, number of months, and start month.
Shortcode: [booking]
Parameters
Here is a list of all possible booking shortcode parameters and attributes:
nummonths
– defines the number of months to display in the booking calendar.type
– specifies the booking resource type.form_type
– determines the type of booking form to display.agregate
– aggregates additional booking types to the main booking type.aggregate
– another way to aggregate additional booking types.startmonth
– sets the starting month of the calendar.options
– additional options for the booking form.
Examples and Usage
Basic example – A simple use of the shortcode to display a booking form with default settings.
[booking /]
Advanced examples
Display a booking form for a specific resource type, with a specific form type and display 3 months in the booking calendar.
[booking type=2 form_type='custom' nummonths=3 /]
Display a booking form with a specific start month. The format for the start month is ‘Year-Month’.
[booking startmonth='2022-12' /]
Aggregate multiple booking types into a single booking form. The booking types are separated by a semicolon.
[booking type=1 agregate='2;3;4' /]
Use specific booking options for the booking form. The options should be provided as a string.
[booking options='option1;option2;option3' /]
PHP Function Code
In case you have difficulties debugging what causing issues with [booking]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'booking', array( &$this, 'booking_shortcode' ) );
Shortcode PHP function:
function booking_shortcode($attr) {
//debuge($attr);
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
if ( isset( $_GET['booking_hash'] ) ) {
return
__( 'You need to use special shortcode [bookingedit] for booking editing.', 'booking' )
. ' '
. sprintf( __( 'Please check FAQ instruction how to configure it here %s', 'booking' )
, '<a href="https://wpbookingcalendar.com/faq/configure-editing-cancel-payment-bookings-for-visitors/">https://wpbookingcalendar.com/faq/configure-editing-cancel-payment-bookings-for-visitors/</a>'
);
}
//if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache
$my_boook_count = get_bk_option( 'booking_client_cal_count' );
$my_boook_type = 1;
$my_booking_form = 'standard';
$start_month_calendar = false;
$bk_otions = array();
if ( isset( $attr['nummonths'] ) ) { $my_boook_count = $attr['nummonths']; }
if ( isset( $attr['type'] ) ) { $my_boook_type = $attr['type']; }
// if (isset($_GET['resource_id'])) { // Get ID of booking resource from URL parameter ?resource_id=3
// $my_boook_type = intval( $_GET['resource_id'] );
// }
// $custom_field_in_post = intval( get_post_meta( get_the_ID() , 'resource_id' , true ) ); // Get ID of booking resource from custom field with name 'resource_id=4'
// if (! empty( $custom_field_in_post )){
// $my_boook_type = $custom_field_in_post;
// }
if ( isset( $attr['form_type'] ) ) { $my_booking_form = $attr['form_type']; }
if ( isset( $attr['agregate'] ) && (! empty( $attr['agregate'] )) ) {
$additional_bk_types = $attr['agregate'];
$my_boook_type .= ';'.$additional_bk_types;
}
if ( isset( $attr['aggregate'] ) && (! empty( $attr['aggregate'] )) ) {
$additional_bk_types = $attr['aggregate'];
$my_boook_type .= ';'.$additional_bk_types;
}
if ( isset( $attr['startmonth'] ) ) { // Set start month of calendar, fomrat: '2011-1'
$start_month_calendar = explode( '-', $attr['startmonth'] );
if ( (is_array($start_month_calendar)) && ( count($start_month_calendar) > 1) ) { }
else $start_month_calendar = false;
}
if ( isset( $attr['options'] ) ) { $bk_otions = $attr['options']; }
$res = $this->add_booking_form_action($my_boook_type,$my_boook_count, 0 , $my_booking_form , '', $start_month_calendar, $bk_otions );
return $res;
}
Code file location:
booking/booking/core/lib/wpdev-booking-class.php
Booking Calendar [bookingcalendar] Shortcode
The ‘Booking Calendar’ shortcode is a powerful tool that generates a booking calendar on your WordPress site. The shortcode fetches booking data, counts, and types, allowing customization through various attributes. It can aggregate multiple booking types, set the start month, and apply other options. The output is a fully interactive booking calendar, enhancing user experience.
Shortcode: [bookingcalendar]
Parameters
Here is a list of all possible bookingcalendar shortcode parameters and attributes:
nummonths
– defines the number of months to display in the booking calendartype
– sets the type of booking (represented by a number).agregate
– allows to combine multiple booking types together.aggregate
– another way to combine multiple booking types together.startmonth
– sets the starting month for the calendar (format: ‘YYYY-M’).options
– allows to add additional options to the booking calendar.
Examples and Usage
Basic example – Display a booking calendar with the default settings.
[bookingcalendar /]
Advanced examples
Display a booking calendar for a specific type of booking and specify the number of months to display.
[bookingcalendar type=2 nummonths=3 /]
Aggregate multiple types of bookings into one calendar and start the calendar from a specific month.
[bookingcalendar type=1 agregate="2;3" startmonth="2023-6" /]
Customize the booking calendar with specific options.
[bookingcalendar options="option1;option2" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [bookingcalendar]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'bookingcalendar', array( &$this, 'booking_calendar_only_shortcode' ) );
Shortcode PHP function:
function booking_calendar_only_shortcode($attr) {
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
//if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache
$my_boook_count = get_bk_option( 'booking_client_cal_count' );
$my_boook_type = 1;
$start_month_calendar = false;
$bk_otions = array();
if ( isset( $attr['nummonths'] ) ) { $my_boook_count = $attr['nummonths']; }
if ( isset( $attr['type'] ) ) { $my_boook_type = $attr['type']; }
if ( isset( $attr['agregate'] ) && (! empty( $attr['agregate'] )) ) {
$additional_bk_types = $attr['agregate'];
$my_boook_type .= ';'.$additional_bk_types;
}
if ( isset( $attr['aggregate'] ) && (! empty( $attr['aggregate'] )) ) { //FixIn: 8.3.3.8
$additional_bk_types = $attr['aggregate'];
$my_boook_type .= ';'.$additional_bk_types;
}
if ( isset( $attr['startmonth'] ) ) { // Set start month of calendar, fomrat: '2011-1'
$start_month_calendar = explode( '-', $attr['startmonth'] );
if ( (is_array($start_month_calendar)) && ( count($start_month_calendar) > 1) ) { }
else $start_month_calendar = false;
}
if ( isset( $attr['options'] ) ) { $bk_otions = $attr['options']; }
$res = $this->add_calendar_action($my_boook_type,$my_boook_count, 0, $start_month_calendar, $bk_otions );
$start_script_code = "<div id='calendar_booking_unselectable".$my_boook_type."'></div>";
return "<div class='wpbc_only_calendar'>" . $start_script_code . $res . '</div>'; //FixIn: 8.0.1.2
}
Code file location:
booking/booking/core/lib/wpdev-booking-class.php
Booking Calendar [bookingform] Shortcode
The ‘bookingform’ shortcode from the Booking Plugin is designed to generate a booking form on the front-end. It allows customization of booking types, form types, and selected dates. The shortcode uses WordPress functions to sanitize the attributes passed. It initializes variables for booking type, form type, booking count, and selected dates. These variables are then used to create the booking form via the ‘add_booking_form_action’ function. Additionally, the shortcode includes a JavaScript section that runs on page load. This script applies a filter ‘wpdev_booking_show_availability_at_calendar’ to display availability on the calendar. In conclusion, the ‘bookingform’ shortcode provides a flexible and secure way to add booking functionality to a WordPress site.
Shortcode: [bookingform]
Parameters
Here is a list of all possible bookingform shortcode parameters and attributes:
type
– Specifies the type of booking to be made.form_type
– Determines the format of the booking form.selected_dates
– Defines specific dates without using a calendar.
Examples and Usage
Basic example – The following usage of the shortcode will display the standard booking form for the booking resource type 1.
[bookingform type=1 form_type=standard]
Advanced examples
1. In this example, the shortcode is used to display a custom booking form for the booking resource type 2. The selected dates are also specified.
[bookingform type=2 form_type=custom selected_dates='20.08.2020, 29.08.2020']
2. This example shows how to use the shortcode to display a standard booking form for the booking resource type 3, with a specific set of selected dates.
[bookingform type=3 form_type=standard selected_dates='15.09.2020, 25.09.2020']
These examples demonstrate the flexibility of the ‘bookingform’ shortcode, which allows you to customize the booking form display according to your specific requirements.
PHP Function Code
In case you have difficulties debugging what causing issues with [bookingform]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'bookingform', array( &$this, 'bookingform_shortcode' ) );
Shortcode PHP function:
function bookingform_shortcode($attr) {
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
//if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache
$my_boook_type = 1;
$my_booking_form = 'standard';
$my_boook_count = 1;
$my_selected_dates_without_calendar = '';
if ( isset( $attr['type'] ) ) { $my_boook_type = $attr['type']; }
if ( isset( $attr['form_type'] ) ) { $my_booking_form = $attr['form_type']; }
if ( isset( $attr['selected_dates'] ) ) { $my_selected_dates_without_calendar = $attr['selected_dates']; } //$my_selected_dates_without_calendar = '20.08.2010, 29.08.2010';
$res = $this->add_booking_form_action($my_boook_type,$my_boook_count, 0 , $my_booking_form, $my_selected_dates_without_calendar, false );
$res .= "<script type='text/javascript'> "; //FixIn:6.1.1.16
$res .= "jQuery(document).ready( function(){";
$res .= apply_filters('wpdev_booking_show_availability_at_calendar', '', $my_boook_type);
$res .= "}); ";
$res .= "</script>";
return $res;
}
Code file location:
booking/booking/core/lib/wpdev-booking-class.php
Booking Calendar [bookingedit] Shortcode
The ‘bookingedit’ shortcode is a part of the Booking Calendar plugin. It allows users to edit their booking details. The shortcode checks for a valid booking hash, and if found, it fetches and displays the booking form.
Shortcode: [bookingedit]
Parameters
Here is a list of all possible bookingedit shortcode parameters and attributes:
nummonths
– Specifies the number of months to be displayed in the booking calendar.type
– Determines the type of booking. Typically, this is the booking resource ID.form_type
– Defines the type of booking form to be used.agregate
– Allows additional booking resources to be added to the booking process.aggregate
– Alternative spelling for ‘agregate’, performs the same function.options
– Allows for additional options to be passed to the booking form.
Examples and Usage
Basic example – Show the booking form with a default configuration.
[bookingedit /]
Advanced examples
Display the booking form with a specified number of months and a specific booking type.
[bookingedit nummonths=3 type=2 /]
Use the shortcode to display a booking form with a specific form type and aggregate other booking types.
[bookingedit form_type="deluxe" agregate="3,4" /]
Display a booking form with custom options.
[bookingedit options="color:blue; font-size:14px;" /]
In these examples, ‘nummonths’ is the number of months to be displayed in the booking form, ‘type’ is the booking type, ‘form_type’ is the type of form to be displayed, ‘agregate’ is used to aggregate other booking types with the main one and ‘options’ is used to customize the display of the booking form.
PHP Function Code
In case you have difficulties debugging what causing issues with [bookingedit]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'bookingedit', array( &$this, 'bookingedit_shortcode' ) );
Shortcode PHP function:
function bookingedit_shortcode($attr) {
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
//if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache
if ( isset( $_GET['wpbc_hash'] ) ) {
if ( function_exists( 'wpbc_parse_one_way_hash' ) ) {
$one_way_hash_response = wpbc_parse_one_way_hash( $_GET['wpbc_hash'] );
return $one_way_hash_response;
}
}
$my_boook_count = get_bk_option( 'booking_client_cal_count' );
$my_boook_type = 1;
$my_booking_form = 'standard';
$bk_otions = array();
if ( isset( $attr['nummonths'] ) ) { $my_boook_count = $attr['nummonths']; }
if ( isset( $attr['type'] ) ) { $my_boook_type = $attr['type']; }
if ( isset( $attr['form_type'] ) ) { $my_booking_form = $attr['form_type']; }
if ( isset( $attr['agregate'] ) && (! empty( $attr['agregate'] )) ) { //FixIn:7.0.1.26
$additional_bk_types = $attr['agregate'];
$my_boook_type .= ';'.$additional_bk_types;
}
if ( isset( $attr['aggregate'] ) && (! empty( $attr['aggregate'] )) ) {
$additional_bk_types = $attr['aggregate'];
$my_boook_type .= ';'.$additional_bk_types;
}
if ( isset( $attr['options'] ) ) { $bk_otions = $attr['options']; }
if (isset($_GET['booking_hash'])) {
$my_booking_id_type = wpbc_hash__get_booking_id__resource_id( $_GET['booking_hash'] );
if ($my_booking_id_type !== false) {
$my_edited_bk_id = $my_booking_id_type[0];
$my_boook_type = $my_booking_id_type[1];
if ($my_boook_type == '') return __('Wrong booking hash in URL. Probably hash is expired.' ,'booking');
} else {
return __('Wrong booking hash in URL. Probably hash is expired.' ,'booking');
}
} else {
return __('This page can only be accessed through links in emails related to your booking.' ,'booking')
. ' <br/><em>'
. sprintf( __('Please check more about configuration at %sthis page%s' ,'booking')
, '<a href="https://wpbookingcalendar.com/faq/configure-editing-cancel-payment-bookings-for-visitors/" target="_blank">' , '</a>.')
. '</em>';
}
$res = $this->add_booking_form_action($my_boook_type,$my_boook_count, 0 , $my_booking_form, '', false, $bk_otions );
if (isset($_GET['booking_pay'])) {
// Payment form
if ( 'On' == get_bk_option( 'booking_super_admin_receive_regular_user_payments' ) ){ //FixIn: 9.2.3.8
make_bk_action('make_force_using_this_user', -999 ); // '-999' - This ID "by default" is the ID of super booking admin user
}
$res .= apply_bk_filter('wpdev_get_payment_form',$my_edited_bk_id, $my_boook_type );
if ( 'On' == get_bk_option( 'booking_super_admin_receive_regular_user_payments' ) ){ //FixIn: 9.2.3.8
make_bk_action( 'finish_force_using_this_user' );
}
}
return $res;
}
Code file location:
booking/booking/core/lib/wpdev-booking-class.php
Booking Calendar [bookingsearch] Shortcode
The ‘BookingSearch’ shortcode is a powerful tool within the Booking Plugin. It generates a search form for bookings, allowing users to easily find their desired booking. The shortcode uses the ‘wpdev_get_booking_search_form’ filter to create the search form, ensuring it’s tailored to the specific attributes defined. It’s a simple yet effective way to enhance user experience.
Shortcode: [bookingsearch]
Examples and Usage
Basic example – A simple usage of the ‘bookingsearch’ shortcode without any additional parameters. This will display the default booking search form.
[bookingsearch /]
PHP Function Code
In case you have difficulties debugging what causing issues with [bookingsearch]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'bookingsearch', array( &$this, 'bookingsearch_shortcode' ) );
Shortcode PHP function:
function bookingsearch_shortcode($attr) {
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
//if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache
$search_form = apply_bk_filter('wpdev_get_booking_search_form','', $attr );
return $search_form ;
}
Code file location:
booking/booking/core/lib/wpdev-booking-class.php
Booking Calendar [bookingsearchresults] Shortcode
The Booking Search Results shortcode is a feature of the Booking plugin. It displays the results of a booking search on your WordPress site. The shortcode uses the function ‘bookingsearchresults_shortcode’ to retrieve and display search results. The function applies a filter ‘wpdev_get_booking_search_results’ to get the relevant booking data.
Shortcode: [bookingsearchresults]
Examples and Usage
Basic example – A simple use of the booking search results shortcode. This will display the search results without any specific parameters.
[bookingsearchresults /]
PHP Function Code
In case you have difficulties debugging what causing issues with [bookingsearchresults]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'bookingsearchresults', array( &$this, 'bookingsearchresults_shortcode' ) );
Shortcode PHP function:
function bookingsearchresults_shortcode($attr) {
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
//if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache
$search_results = apply_bk_filter('wpdev_get_booking_search_results','', $attr );
return $search_results ;
}
Code file location:
booking/booking/core/lib/wpdev-booking-class.php
Booking Calendar [bookingselect] Shortcode
The ‘bookingselect’ shortcode from the Booking Plugin is designed to generate a booking selection form on the website. This shortcode fetches the booking form by applying the ‘wpdev_get_booking_select_form’ filter. The attributes passed to the shortcode are sanitized using the ‘wpbc_escape_shortcode_params’ function. This ensures the security and integrity of the data.
Shortcode: [bookingselect]
Examples and Usage
Basic example – This shortcode displays a booking selection form without any specific parameters.
[bookingselect /]
PHP Function Code
In case you have difficulties debugging what causing issues with [bookingselect]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'bookingselect', array( &$this, 'bookingselect_shortcode' ) );
Shortcode PHP function:
function bookingselect_shortcode($attr) {
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
//if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache
$search_form = apply_bk_filter('wpdev_get_booking_select_form','', $attr );
return $search_form ;
}
Code file location:
booking/booking/core/lib/wpdev-booking-class.php
Booking Calendar [bookingresource] Shortcode
The ‘bookingresource’ shortcode from the Booking Calendar plugin is used to display booking resource information. It applies filters to the booking resource data based on the provided attributes.
Shortcode: [bookingresource]
Examples and Usage
Basic example – A shortcode to display the booking resource form without any additional parameters.
[bookingresource /]
PHP Function Code
In case you have difficulties debugging what causing issues with [bookingresource]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'bookingresource', array( &$this, 'bookingresource_shortcode' ) );
Shortcode PHP function:
function bookingresource_shortcode($attr) {
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
//if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache
$search_form = apply_bk_filter('wpbc_booking_resource_info','', $attr );
return $search_form ;
}
Code file location:
booking/booking/core/lib/wpdev-booking-class.php
Booking Calendar [bookingtimeline] Shortcode
The Booking Timeline shortcode is a part of the Booking plugin in WordPress. It retrieves and displays a timeline of booking activities. The shortcode initiates the ‘bookingtimeline_shortcode’ function, which takes ‘attr’ as a parameter. The ‘attr’ parameter is escaped for security using ‘wpbc_escape_shortcode_params’. The function then calls ‘bookingflextimeline_shortcode’ with ‘attr’ as the argument, returning a timeline of booking results.
Shortcode: [bookingtimeline]
Examples and Usage
Basic example – The basic usage of the ‘bookingtimeline’ shortcode doesn’t require any parameters. It will display a timeline of bookings with the default settings.
[bookingtimeline /]
PHP Function Code
In case you have difficulties debugging what causing issues with [bookingtimeline]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'bookingtimeline', array( &$this, 'bookingtimeline_shortcode' ) );
Shortcode PHP function:
function bookingtimeline_shortcode($attr) {
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
//FixIn: 8.6.1.13
$timeline_results = bookingflextimeline_shortcode($attr);
return $timeline_results;
}
Code file location:
booking/booking/core/lib/wpdev-booking-class.php
Booking Calendar [bookingcustomerlisting] Shortcode
The ‘bookingcustomerlisting’ shortcode is used to display a list of bookings for a specific customer. It fetches booking details using a unique booking_hash. The shortcode checks if a booking_hash is present, retrieves the booking and resource IDs, and generates a timeline of bookings. If no hash is found, it displays an error message.
Shortcode: [bookingcustomerlisting]
Parameters
Here is a list of all possible bookingcustomerlisting shortcode parameters and attributes:
booking_hash
– A unique code related to a specific bookingtype
– Identifies all the booking resourcesview_days_num
– Specifies the number of days to viewscroll_start_date
– Sets the start date for the scrollingscroll_day
– Defines the number of days to scroll from start datescroll_month
– Defines the number of months to scroll from start dateheader_title
– Sets the title for the booking header
Examples and Usage
Basic example – Display the booking customer listing by using the shortcode without any parameters. This will display the default values set in the plugin settings.
[bookingcustomerlisting /]
Advanced examples
Display the booking customer listing with a specific booking hash. This will show the booking details related to the specific hash.
[bookingcustomerlisting booking_hash="your_booking_hash" /]
Customize the view days number to 60 days and set a specific scroll start date. This will show the booking details for the next 60 days starting from the specified date.
[bookingcustomerlisting view_days_num="60" scroll_start_date="2022-01-01" /]
Override the header title and specify the scroll day and month. This will change the default header title and set the calendar to scroll to the specific day and month.
[bookingcustomerlisting header_title="Your Custom Title" scroll_day="15" scroll_month="2" /]
Note: Replace “your_booking_hash”, “2022-01-01”, “Your Custom Title”, “15”, and “2” with your desired booking hash, date, title, day, and month respectively.
PHP Function Code
In case you have difficulties debugging what causing issues with [bookingcustomerlisting]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'bookingcustomerlisting', array( &$this, 'bookingcustomerlisting_shortcode' ) ); //FixIn: 8.1.3.5
Shortcode PHP function:
function bookingcustomerlisting_shortcode( $attr ){
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
//FixIn: 8.4.5.11
if (! is_array($attr)) {
$attr = array();
}
if ( ( isset( $_GET['booking_hash'] ) ) || ( isset( $attr['booking_hash'] ) ) ) {
if ( isset( $_GET['booking_hash'] ) ) {
$my_booking_id_type = wpbc_hash__get_booking_id__resource_id( $_GET['booking_hash'] );
$attr['booking_hash'] = $_GET['booking_hash'];
} else {
$my_booking_id_type = wpbc_hash__get_booking_id__resource_id( $attr['booking_hash'] );
}
if ( $my_booking_id_type !== false ) {
if ( ! isset( $attr['type' ] ) ) { // 8.1.3.5.2
$br_list = wpbc_get_all_booking_resources_list();
$br_list = array_keys( $br_list );
$br_list = implode(',',$br_list);
$attr['type' ] = $br_list; //wpbc_get_default_resource();
}
if ( ! isset( $attr['view_days_num' ] ) ) {
$attr['view_days_num' ] = 30;
}
if ( ! isset( $attr['scroll_start_date' ] ) ) {
$attr['scroll_start_date' ] = '';
}
if ( ! isset( $attr['scroll_day' ] ) ) {
$attr['scroll_day' ] = 0;
}
if ( ! isset( $attr['scroll_month' ] ) ) {
$attr['scroll_month' ] = 0;
}
if ( ! isset( $attr['header_title' ] ) ) {
$attr['header_title' ] = __( 'My bookings' , 'booking');
}
$timeline_results = $this->bookingtimeline_shortcode( $attr );
return $timeline_results ;
} else {
return __( 'Wrong booking hash in URL. Probably hash is expired.', 'booking' );
}
} else {
return __( 'This page can only be accessed through links in emails related to your booking.', 'booking' )
. ' <br/><em>'
. sprintf( __( 'Please check more about configuration at %sthis page%s', 'booking' ), '<a href="https://wpbookingcalendar.com/faq/configure-editing-cancel-payment-bookings-for-visitors/" target="_blank">', '</a>.' )
. '</em>';
}
}
Code file location:
booking/booking/core/lib/wpdev-booking-class.php
Booking Calendar [booking_test_speed] Shortcode
The ‘booking_test_speed’ shortcode is a part of Booking Calendar plugin. It creates a testing environment for booking dates. This shortcode runs a test to check if specific dates are booked, using the ‘wpbc_api_is_dates_booked’ function. It tests dates from September 10 to September 18, 2021, for resource ID 13. The output is a simple text display, with headers and horizontal lines for clarity.
Shortcode: [booking_test_speed]
Examples and Usage
Basic example – Show the booking test speed for a specific resource.
[booking_test_speed resource_id=13 /]
PHP Function Code
In case you have difficulties debugging what causing issues with [booking_test_speed]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'booking_test_speed', array( &$this, 'booking_test_speed_shortcode' ) ); //FixIn: 8.7.11.13
Shortcode PHP function:
function booking_test_speed_shortcode( $attr ) {
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
echo '<h4>Booking Calendar Test</h4>';
$datesArray = Array(
'2021-09-10'
, '2021-09-11'
, '2021-09-12'
, '2021-09-13'
, '2021-09-14'
, '2021-09-15'
, '2021-09-16'
, '2021-09-17'
, '2021-09-18'
) ;
for( $i = 0; $i < 1 ; $i++) {
$result = wpbc_api_is_dates_booked( $datesArray, $resource_id = 13 );
//debuge((int) $result );
}
debuge_speed('(int)');
echo '<hr/>';
echo '<hr/>';
}
Code file location:
booking/booking/core/lib/wpdev-booking-class.php
Booking Calendar [bookingflextimeline] Shortcode
The Booking Calendar plugin shortcode ‘bookingflextimeline’ is designed to display a flexible timeline for booking resources. This shortcode fetches all booking resources, sets default values for attributes like ‘view_days_num’, ‘scroll_start_date’, ‘scroll_day’, ‘scroll_month’, and ‘header_title’. It then initializes a timeline and displays it. The timeline is interactive, allowing for navigation and booking status display.
Shortcode: [bookingflextimeline]
Parameters
Here is a list of all possible bookingflextimeline shortcode parameters and attributes:
type
– specifies the booking resources to be displayedview_days_num
– sets the number of days to be shown in the timelinescroll_start_date
– determines the start date for the timeline scrollscroll_day
– adjusts the timeline scroll by a certain number of daysscroll_month
– adjusts the timeline scroll by a certain number of monthsheader_title
– sets a custom title for the timeline header
Examples and Usage
Basic example – Displaying the default booking resource for a month
[bookingflextimeline /]
In this example, the shortcode will display the booking timeline for the default booking resource. The view will cover a period of 30 days (a month) starting from the current date.
Advanced examples
Displaying a specific booking resource for a custom number of days
[bookingflextimeline type="2" view_days_num="15" /]
In this example, the shortcode will display the booking timeline for the booking resource with ID 2. The view will cover a period of 15 days starting from the current date.
Displaying a specific booking resource with a custom start date and a custom header title
[bookingflextimeline type="3" scroll_start_date="2022-12-01" header_title="Booking Resource 3" /]
In this example, the shortcode will display the booking timeline for the booking resource with ID 3. The view will start from 1st December 2022 and will cover a period of 30 days. The header title will be “Booking Resource 3”.
PHP Function Code
In case you have difficulties debugging what causing issues with [bookingflextimeline]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'bookingflextimeline', 'bookingflextimeline_shortcode' );
Shortcode PHP function:
function bookingflextimeline_shortcode($attr) {
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1
//if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache
if ( empty( $attr['type'] ) ) { // 8.7.7.4
if ( class_exists( 'wpdev_bk_personal' ) ) {
$br_list = wpbc_get_all_booking_resources_list();
$br_list = array_keys( $br_list );
$br_list = implode( ',', $br_list );
$attr['type'] = $br_list;
} else {
$attr['type'] = wpbc_get_default_resource();
}
}
if ( ! isset( $attr['view_days_num' ] ) ) {
$attr['view_days_num' ] = 30;
}
if ( ! isset( $attr['scroll_start_date' ] ) ) {
$attr['scroll_start_date' ] = '';
}
if ( ! isset( $attr['scroll_day' ] ) ) {
$attr['scroll_day' ] = 0;
}
if ( ! isset( $attr['scroll_month' ] ) ) {
$attr['scroll_month' ] = 0;
}
if ( ! isset( $attr['header_title' ] ) ) {
$attr['header_title' ] = '';
}
ob_start();
$timeline = new WPBC_TimelineFlex();
$html_client_id = $timeline->client_init( $attr ); // Define arameters and get bookings
//wpbc_datepicker_js(); // JS Datepicker
//wpbc_datepicker_css(); // CSS DatePicker
echo '<div class="wpdevelop">';
echo '<div id="'.$html_client_id.'" class="wpbc_timeline_client_border">';
echo wp_nonce_field( 'WPBC_FLEXTIMELINE_NAV', 'wpbc_nonce_' . $html_client_id , true , false );
echo '<div id="ajax_respond_insert'.$html_client_id.'" class="ajax_respond_insert" style="display:none;"></div>';
echo '<div class="wpbc_timeline_ajax_replace">';
if ( ! WPBC()->booking_obj->popover_front_end_js_is_writed ) { //Write this JS only once at page
wpbc_bs_javascript_popover(); // JS Popover
WPBC()->booking_obj->popover_front_end_js_is_writed = true;
} //FixIn: 9.2.1.3
//Define Global JavaScript Object - array of objects. //FixIn: 9.2.1.3
?>
<script type="text/javascript">
var wpbc_timeline_obj;
if ( undefined === wpbc_timeline_obj ){
wpbc_timeline_obj = [];
}
</script>
<?php
$timeline->show_timeline();
echo '</div>';
echo '</div>';
echo '</div>';
// Fix for "Twenty Two" theme.
// Theme incorrectly closing HTML elements with attributes that contain HTML tags in content of the posts and pages.
// For example, if the HTML element have tags like this
// <div data-content="<div class='flex-popover-content-data'>Data</div>" data-original-title="<div class='popover-title-id' > ID: 19</div>" >My text</div>
// Theme show info like this
// <div data-content="<div class='flex-popover-content-data'>Data</div>” data-original-title=”<div class='popover-title-id' > ID: 19</div>” >My text</div>
/*
?><script type="text/javascript">
wpbc_flextimeline_nav( wpbc_timeline_obj['<?php echo $html_client_id; ?>'], 0 );
</script><?php
*/
$timeline_results = ob_get_contents();
ob_end_clean();
return $timeline_results ;
}
Code file location:
booking/booking/core/timeline/v2/wpbc-class-timeline_v2.php
Conclusion
Now that you’ve learned how to embed the Booking Calendar 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