Plugin customization
In order to facilitate customization different filters and actions have been created. We recommend that you insert your customization code in the functions.php of your child theme to make sure it is not erase on plugin or theme update.
Filters for the accommodation type post
hb_accommodation_cpt
hb_accommodation_public
Filters for the search form
Filters for the accommodation selection
hb_available_accommodation_markup
hb_first_available_accom_num
Filters for the extra-services selection
Filters for the details form
These filters can be useful if you wish to add content before or after a specific field:
hb_details_form_markup_before_field
hb_details_form_markup_after_field
This filter can be useful if you wish to modify a specific field output:
This filter can be useful if you wish to modify the output of the details form:
Filters for the payment section
Filters for the summary and book now area
hb_resa_summary_markup
hb_resa_summary_no_external_payment_markup
hb_resa_summary_external_payment_markup
hb_confirm_area_markup
Filters for the invoice table
hb_invoice_table_markup
Filters for the actions associated to the reservation and customer
Filters for the shorcodes [hb_accommodation_list], [hb_rates], [hb_availability]
hb_rates_markup
hb_availability_on_click_refresh
Filters for HBook additional roles (reservation reader, reservation manager, pricing manager, HBook manager)
hb_resa_reader_capabilities
hb_pricing_manager_capabilities
hb_hbook_manager_capabilities
Filters for automatic emails
hb_email_actions : to add actions upon which an email is sent automatically
hb_scheduled_min_hour : to change the sending window minimum hour of the day
hb_scheduled_max_hour : to change the sending window maximum hour of the day. Default is 11pm
Filters for the iCal sync
hb_ical_agenda_check_in_time : to change the shared check-in time when using the “agenda” query parameter. Default is 3pm.
hb_ical_agenda_check_out_time : to change the shared check-out time when using the “agenda” query parameter. Default is 11am.
hb_ical_additional_info : to add information to filter the “DESCRIPTION” field when importing a iCal calendar event. The filtered information will be displayed in the “Comments” column for the reservation.
hb_ical_additional_non_standard_properties : to add information to filter any non standard property (“X-PROPERTY-NAME”) field when importing a iCal calendar event. The filtered information will be displayed in the “Comments” column for the reservation.
hb_ical_nb_years_history : to customize the number of years in the past that are included in the export when passing the query parameter “future_only” to “no”. Default is 2 years.
Various
hb_strings : to add external strings for translation in HBook > Text
Js functions
HBook plugin also try to call these two global JavaScript functions:
hb_accommodation_taxonomies
This filter is applied to the taxonomies parameter which is passed to the register_post_type function used for creating the Accommodation custom post type.
Parameter:
$taxonomies: (array) list of taxonomies.
Example:
Adding categories to the Accommodation posts.
function categories_for_accommodation( $taxonomies ) {
$taxonomies[] = 'category';
return $taxonomies;
}
add_filter( 'hb_accommodation_taxonomies', 'categories_for_accommodation' );
Please note that by default posts using a custom post types are not included in archive pages. To add them (if you wish to have a page for a category for example), you will need to add the following code:
function hbook_add_custom_types( $query ) {
if( (is_category() || is_tag()) && $query->is_archive() && empty( $query->query_vars['suppress_filters'] ) ) {
$query->set( 'post_type', array(
'post', 'hb_accommodation'
));
}
return $query;
}
add_filter( 'pre_get_posts', 'hbook_add_custom_types' );
hb_accommodation_has_archive
This filter is applied to the has_archive parameter which is passed to the register_post_type function used for creating the Accommodation custom post type.
Parameter: none
Example:
To disable the archive for the accommodation post types:
function hb_disable_archive() {
return false;
}
add_filter( 'hb_accommodation_has_archive', 'hb_disable_archive' );
hb_accommodation_supports
This filter is applied to the supports parameter which is passed to the register_post_type function used for creating the Accommodation custom post type.
Parameter:
$supports: (array) list of supported items.
Example:
Adding support for excerpts to the Accommodation posts.
function support_for_excerpts( $supports ) {
$supports[] = 'excerpt';
return $supports;
}
add_filter( 'hb_accommodation_supports', 'support_for_excerpts' );
hb_search_form_markup
This filter is applied to the HTML mark up of the form which is used for searching available accommodation.
Parameters:
$output: (string) the HTML code of the form.
$form_id: (string) the id of the form as passed to the [hb_booking_form] shortcode via the form_id attribute.
hb_search_form_title
This filter is applied to the title of the search form.
Parameter:
$title: (string) the HTML code of the title of the search form.
Example:
function change_title_tag( $title ) {
return str_replace( 'h3', 'h2', $title );
}
add_filter( 'hb_search_form_title', 'change_title_tag' );
hb_extra_name
This filter is applied to the name of each extra service (extra services are displayed as a list after the accommodation selection).
Parameter:
$display_name, $option, $price
$display_name: (string) name of the extra as it will be displayed
$extra: (array) information about the extra
$price: (array) price of the extra
hb_extras_form_markup
This filter is applied to the HTML mark up of the form which displays extra services.
Parameter:
$output: (string) the HTML code of the form.
hb_resa_extra_formatting
This filter is applied to the name of each chosen extra service (in emails sent by HBook).
Parameter:
$formatted_extra_name: (string) the formatted name of the extra service
$extra_name: (string) the name of the extra service
$extra_value: (string) value of the chosen option
$option_choice_name: (string) name of the chosen option
hb_details_form_markup_field
This filter is applied to the HTML mark up of a field of details fields.
Parameter:
$output: (string) the HTML code of for the specific field.
$field: (array) the attributes of the field.
Example:
Set a default input field value. In this example, it is a default arrival time, for a field that is for admin use only.
add_filter( 'hb_details_form_markup_field', 'myfunction_set_default_arrival_time', 10, 2 );
function myfunction_set_default_arrival_time( $markup, $field ) {
if ( $field['id'] == 'arrival_time' ) {
$markup = str_replace( 'value=""', 'value="15:00"', $markup );
}
return $markup;
}
hb_details_form_markup
This filter is applied to the HTML mark up of the form which is used for getting the details fields.
Parameter:
$output: (string) the HTML code of the form.
hb_payment_types
This filter is applied to the set an order for the payment types listed when a choice is offered to the customer.
Parameter:
$types: (array) list of accepted payment types. Default order is : array( 'offline', 'store_credit_card', 'deposit', 'full' ).
Example:
Changing the default order to have the offline option as last one.
function custom_payment_type_order( $types ) {
$types = array( 'deposit', 'full', 'store_credit_card', 'offline' );
return $types;
}
add_filter( 'hb_payment_types', 'custom_payment_type_order' );
hb_active_payment_gateways
This filter is applied to the list of payment gateways that have been activated.
Parameter:
$gateways: (array) list of active payment types.
Example:
Reverse the order of the payment gateways options, in the payment form, when various are enabled.
function custom_payment_gateway_order( $gateways ) {
$gateways = array_reverse( $gateways );
return $gateways;
}
add_filter( 'hb_active_payment_gateways', 'custom_payment_gateway_order' );
hb_stripe_credit_cards_icons
This filter is applied to the set which credit card icons you wish to display in the Stripe payment form.
Parameter:
$icons: (array) list of credit card icons. Default value is : array( 'mastercard', 'visa', 'americanexpress' ). Possible values are : 'amazon', 'americanexpress', 'delta', ''diners', discover', 'ebay', ''jcb', maestro', 'mastercard', 'solo', 'visa', 'visaelectron', 'switch'
Example:
Display only visa and mastercard icons.
function custom_stripe_payment_icons( $types ) {
$icons = array( 'visa', 'mastercard' );
return $icons;
}
add_filter( 'hb_stripe_credit_cards_icons', 'custom_stripe_payment_icons' );
hb_policies_area_markup
This filter is applied to the part of the booking form where customers aknowledge Privacy policy, Terms and conditions.
Parameter:
$output: (string) the HTML code of the form.
Example:
Add a checkbox to signup to a MailChimp newsletter. This requires MC4WP plugin and custom integration. Please check this article of our knowledgebase.
function add_mailchimp_to_details_form( $output ) {
$output .= '<h3 class="hb-title hb-title-terms">Our newsletter</h3>';
$output .= '<p>';
$output .= '<label>';
$output .= '<input type="checkbox" name="mc4wp-subscribe" value="1" />';
$output .= 'Yes! Subscribe me to the your monthly newsletter.</label>';
$output .= '</p>';
return $output;
}
add_filter( 'hb_policies_area_markup', 'add_mailchimp_to_details_form' );
hb_invoice_table_style
This filter is applied to the invoice table styles. You can find these styles in wp-content/plugins/hbook/utils/utils.php. Look for the function "get_invoice_table".
Parameters
$style: (string) all the CSS applied.
$resa: (array) the reservation information
hb_create_reservation
This action fires when a new reservation is added to the reservation database table.
Parameter:
$resa_info: (array) all of the new reservation information.
hb_create_customer
This action fires when a new customer is added to the customer database table.
Parameter:
$customer_info: (array) all of the customer information.
hb_reservations_updated
This action fires whenever the reservations database table is updated.
Parameter: None.
hb_blocked_accom_updated
This action fires whenever the blocked accommodation database table is updated.
Parameter: None.
hb_accommodation_list_markup
This hook can be used to modify the display of the accommodation list.
Parameter:
$output: (string) that contains the output of the accommodation list markup.
Example:
For the accommodation list thumbnail to open the accommodation type post in the same tab.
In the functions.php of your child theme add:
function change_target_self( $output ) {
return str_replace( '_blank', '_self', $output );
}
add_filter( 'hb_accommodation_list_markup', 'change_target_self' );
hb_resa_manager_capabilities
This filter is applied to the list of capabilities of the reservation manager.
Parameter:
$capabilities: (array) that contains a list of the different capabilities.
Example:
If your theme redirect automatically the user with "read" capability to the front-end, you shoudl add capabilities that are for Contributor or Author, depending on your theme. To view a full list of WordPress roles and capabilities, please refer to https://codex.wordpress.org/Roles_and_Capabilities
function hb_add_capabiliites_to_manager( $capabilities ) {
$added_capabilities = array( 'edit_posts', 'delete_pots' );
$capabilities = array_merge( $added_capabilities, $capabilities );
return $capabilities;
}
add_filter( 'hb_resa_manager_capabilities', 'hb_add_capabiliites_to_manager' );
hb_email_actions
This filter is applied to the list of actions that are shown in the column "Send on" of the email templates in HBook > Emails.
Parameter:
$actions: (array) that contains information about the different actions : a key (string) => value (string). Required keys are 'action_value' and 'action_text'.
hb_scheduled_min_hour
Automatics emails are triggered, by default, between 7am and 11pm (timezone set in WordPress Settings), as soon there is a visit on your website (admin or front-end).
Default is 7 (7am). Expect a number between 0 and 23.
Parameter: None.
Example:
function change_minimum_scheduled_hour() {
return 9;
}
add_filter( 'hb_scheduled_min_hour', 'change_minimum_scheduled_hour' );
hb_scheduled_max_hour
Automatics emails are triggered, by default, between 7am and 11pm (timezone set in WordPress Settings), as soon there is a visit on your website (admin or front-end).
Default is 23 (11pm). Expect a number between 0 and 23.
Parameter: None.
Example:
function change_maximum_scheduled_hour() {
return 20;
}
add_filter( 'hb_scheduled_max_hour', 'change_maximum_scheduled_hour' );
hb_ical_agenda_check_in_time
If you are using the query parameter “agenda” to include times in the format of the shared information for DTSTART and DTEND iCal property, you may wish to modify the time passed to DTSTART (check-in time). By default, we pass “15” (3pm).
Parameter: None.
Default is 15 (3pm). Expect a number between 0 and 23.
function change_agenda_check_in_time() {
return 16;
}
add_filter( 'hb_ical_agenda_check_in_time', 'change_agenda_check_in_time' );
hb_ical_agenda_check_out_time
If you are using the query parameter “agenda” to include times in the format of the shared information for DTSTART and DTEND iCal property, you may wish to modify the time passed to DTEND (check-out time). By default, we pass “11” (11am).
Parameter: None.
Default is 11 (11am). Expect a number between 0 and 23.
function change_agenda_check_out_time() {
return 10;
}
add_filter( 'hb_ical_agenda_check_out_time', 'change_agenda_check_out_time' );
hb_ical_additional_info
Parameter:
$default_comment_data: (array) an array of values that will be looked for in the DESCRIPTION field of the ical content of an external calendar. When found, HBook will show the value of this field in the column "Comments" for the reservation.
Example with dummy data “Vehicle-Registration” and “Special-Request”.
function my_platforms_comment_data ( $default_comment_data ) {
$additional_data = array(
'Vehicle-Registration',
'Special-Request'
);
$updated_comment_data = array_merge( $default_comment_data, $additional_data );
return $updated_comment_data;
}
add_filter( 'hb_ical_additional_info', 'my_platforms_comment_data' );
hb_ical_additional_non_standard_properties
Parameter:
$other_ical_non_standard_properties: (array) an array of properties that will be looked for in the ical content of an external calendar. When found, HBook will show the value of this field in the column "Comments" for the reservation.
Example with dummy data “X-EXTRAS” and “X-TOTAL-AMOUNT”.
function my_platforms_non_standard_properties ( $other_ical_non_standard_properties ) {
$additional_properties = array(
'X-EXTRAS',
'X-TOTAL-AMOUNT'
);
$updated_other_non_standard_properties = array_merge( $other_ical_non_standard_properties, $additional_properties );
return $updated_other_non_standard_properties;
}
add_filter( 'hb_ical_additional_non_standard_properties', 'my_platforms_non_standard_properties' );
hb_ical_nb_years_history
If you are using the query parameter “future_only” to include past reservations/blocked dates in the iCal export, you may wish to modify the number of years included in the export. By default, HBook includes 2 years of history, when the parameter “future_only” is passed with “no” as value (to override default value of including only future reservations and blocked dates).
function custom_ical_nb_years_history ( $default_delay ) {
return '6';
}
add_filter( 'hb_ical_nb_years_history', 'custom_ical_nb_years_history' );
hb_language_list
This filter is applied to the list of languages managed by HBook in a multi-language website.
Parameter:
$langs: (array) a key (string) => value (string) array that contains information about the different languages (key is the language locale, value is the language name).
Example:
If you are using a multi-language plugin that is not Polylang or WPML and for which the languages are not detected automatically by HBook:
function new_language_list( $langs ) {
$added_languages = array(
'fr_FR' => 'French',
'it_IT' => 'Italian',
'es_ES' => 'Spanish',
'de_DE' => 'German'
);
$langs = array_merge( $added_languages, $langs );
return $langs;
}
add_filter( 'hb_language_list', 'new_language_list' );
hb_uncompleted_resa_deletion_delay
Expect a returned value as: (integer + "MINUTE" or "HOUR") the delay before HBook delete a reservation that was not completed and is shown as "Processing" status (the customer closed the tab, left the payment process, etc.). By default, HBook delete these uncompleted resrevation after 1 hour.
Example:
Deleting uncompleted reservations after 30 MINUTE.
function custom_uncompleted_resa_deletion_delay( $default_delay ) {
return '30 MINUTE';
}
add_filter( 'hb_uncompleted_resa_deletion_delay', 'custom_uncompleted_resa_deletion_delay' );
hb_old_resa_logs_deletion_delay
Expect a returned value as: (integer + "DAY" or "MONTH") the delay of log retention for HBook reservation status changes. These logs are used by ourselves or webdevelopers for debug purposes. By default, HBook delete these logs after 14 days.
Example:
Retaining logs for 28 DAY.
function custom_resa_logs_deletion_delay( $default_delay ) {
return '28 DAY';
}
add_filter( 'hb_old_resa_logs_deletion_delay', 'custom_resa_logs_deletion_delay' );
hb_retina_scale_factor
Parameter:
$retina_scale_factor: (integer) the scale factor applied to images displayed by HBook (by default the scale factor is 1).
Example:
Displaying images ready for 3x retina devices.
function custom_retina_scale_factor( $retina_scale_factor ) {
return 3;
}
add_filter( 'hb_retina_scale_factor', 'custom_retina_scale_factor' );
hb_image_sizes
Parameter:
$sizes: (multidimensional array) an array of sizes, each size containing "width" and "height" keys. This filter can be useful if you set that HBook uses "static" images resizing in HBook > Misc > Misc. When settings to "Static", HBook don't use AquaResizer.
JavaScript functions
hbook_show_accom_list
HBook plugin tries to call this function whenever the list of available accommodation is shown.
Example:
Launching a JavaScript function after the list of available accommodation has been shown.
In the functions.php of your child theme add:
add_action( 'wp_enqueue_scripts', 'enqueue_my_js_scripts' );
function enqueue_my_js_scripts() {
wp_enqueue_script( 'my-script', get_stylesheet_directory_uri() . '/my-script.js', array(), null, true );
}
and in the child theme directory create a my-script.js file that contains:
function hbook_show_accom_list() {
my_js_function();
}
hbook_reservation_done
HBook plugin tries to call this function whenever a reservation is successfully completed by a customer.
Example:
Launching a JavaScript function after a reservation has been made. This can be used if you have conversion or tracking code for example.
In the functions.php of your child theme add:
add_action( 'wp_enqueue_scripts', 'enqueue_my_js_scripts' );
function enqueue_my_js_scripts() {
wp_enqueue_script( 'my-script', get_stylesheet_directory_uri() . '/my-script.js', array(), null, true );
}
and in the child theme directory create a my-script.js file that contains:
function hbook_reservation_done() {
my_js_function();
}