functions.php
Table of Contents
- mphb_get_template_part() : mixed
- Get template part.
- mphb_load_template() : mixed
- mphb_current_time() : string
- mphb_get_status_label() : string
- Retrieve a post status label by name
- mphb_set_cookie() : mixed
- mphb_get_cookie() : mixed|null
- mphb_has_cookie() : bool
- mphb_unset_cookie() : mixed
- mphb_is_checkout_page() : mixed
- mphb_is_search_results_page() : mixed
- mphb_is_single_room_type_page() : mixed
- mphb_is_create_booking_page() : mixed
- mphb_get_thumbnail_width() : mixed
- mphb_format_price() : string
- mphb_format_percentage() : string
- mphb_trim_zeros() : string
- Trim trailing zeros off prices.
- mphb_trim_decimal_zeros() : mixed
- mphb_get_paged_query_var() : int
- Get WP Query paged var
- mphb_add_to_meta_query() : array<string|int, mixed>
- mphb_meta_query_is_first_order_clause() : bool
- mphb_clean() : string|array<string|int, mixed>
- Clean variables using sanitize_text_field. Arrays are cleaned recursively.
- mphb_hash_equals() : bool
- mphb_strlen() : string
- mphb_get_query_args() : array<string|int, mixed>
- TODO add support for arrays
- mphb_wp_dropdown_pages() : string
- Wrapper function for wp_dropdown_pages
- mphb_set_time_limit() : mixed
- Wrapper for set_time_limit to see if it is enabled.
- mphb_error_log() : mixed
- mphb_current_domain() : string
- mphb_generate_uuid4() : string
- For local usage only. For global IDs it's better to use function mphb_generate_uid().
- mphb_generate_uid() : mixed
- mphb_get_edit_post_link_for_everyone() : string
- Retrieves the edit post link for post regardless current user capabilities
- mphb_get_rooms_select_list() : array<string|int, mixed>
- mphb_show_multiple_instances_notice() : mixed
- mphb_upgrade_to_premium_message() : string
- mphb_normilize_season_price() : array<string|int, mixed>
- Season price format history: v2.6.0- - single number.
- mphb_is_reserved_term() : bool
- Check if term name is reserved.
- mphb_string_starts_with() : bool
- mphb_string_ends_with() : bool
- mphb_array_disjunction() : mixed
- mphb_readable_post_statuses() : array<string|int, mixed>
- mphb_db_version() : mixed
- mphb_db_version_at_least() : mixed
- mphb_version_at_least() : mixed
- mphb_wordpress_at_least() : bool
- mphb_fix_blocks_autop() : mixed
- mphb_escape_json_unicodes() : string
- mphb_strip_price_breakdown_json() : string
- mphb_uploads_dir() : string
- mphb_create_uploads_dir() : mixed
- mphb_verify_nonce() : mixed
- mphb_get_polyfill_for() : mixed
- mphb_current_year() : int
- mphb_days_in_month() : int
- mphb_get_customer_fields() : array<string|int, mixed>
- mphb_get_default_customer_fields() : array<string|int, mixed>
- mphb_is_default_customer_field() : bool
- mphb_get_custom_customer_fields() : array<string|int, mixed>
- mphb_get_admin_checkout_customer_fields() : array<string|int, mixed>
- mphb_get_editing_post_id() : int
- mphb_limit() : int|float
- mphb_array_insert_after() : array<string|int, mixed>
- Add an array after the specified position.
- mphb_array_insert_after_key() : array<string|int, mixed>
- Add an array after the specified key in the associative array.
- mphb_array_usearch() : mixed
- mphb_prefix() : string
- mphb_unprefix() : string
- mphb_get_booking() : Booking|null
- mphb_get_customer() : Customer|null
- mphb_get_room_type() : RoomType|null
- mphb_get_season() : Season|null
- mphb_is_base_request() : bool
- Determine if the current view is the "All" view.
- mphb_is_complete_booking() : bool
- mphb_is_pending_booking() : bool
- mphb_is_locking_booking() : bool
- mphb_is_failed_booking() : bool
- mphb_get_available_rooms() : array<string|int, mixed>
- mphb_posint() : int
- mphb_get_min_adults() : int
- mphb_get_min_children() : int
- mphb_get_max_adults() : int
- mphb_get_max_children() : int
- mphb_array_flip_duplicates() : array<string|int, mixed>
- mphb_get_room_type_base_price() : float
- mphb_get_room_type_period_price() : float
- mphb_get_room_type_ids() : array<string|int, int>
- mphb_today() : DateTime
- mphb_has_buffer_days() : bool
- mphb_get_buffer_days() : int
- mphb_modify_buffer_period() : array<string|int, DateTime>
- mphb_modify_booking_buffer_period() : array<string|int, DateTime>
- mphb_modify_booking_period_with_booking_buffer() : array<string|int, DateTime>
- mphb_is_rooms_free_query_atts_with_buffer() : array<string|int, mixed>
- mphb_filter_checkin_checkout_dates() : array<string|int, mixed>
- mphb_help_tip() : string
- Display a help tip.
- mphb_create_url() : string
- mphb_parse_queue_room_id() : int
Functions
mphb_get_template_part()
Get template part.
mphb_get_template_part(string $slug[, mixed $atts = array() ]) : mixed
Parameters
- $slug : string
- $atts : mixed = array()
mphb_load_template()
mphb_load_template(mixed $template[, mixed $templateArgs = array() ]) : mixed
Parameters
- $template : mixed
- $templateArgs : mixed = array()
mphb_current_time()
mphb_current_time(string $type, bool $gmt) : string
Parameters
- $type : string
- $gmt : bool
Tags
mphb_get_status_label()
Retrieve a post status label by name
mphb_get_status_label(string $status) : string
Parameters
- $status : string
mphb_set_cookie()
mphb_set_cookie(string $name, string $value, int $expire) : mixed
Parameters
- $name : string
- $value : string
- $expire : int
mphb_get_cookie()
mphb_get_cookie(string $name) : mixed|null
Parameters
- $name : string
mphb_has_cookie()
mphb_has_cookie(string $name) : bool
Parameters
- $name : string
mphb_unset_cookie()
mphb_unset_cookie(string $name) : mixed
Parameters
- $name : string
Tags
mphb_is_checkout_page()
mphb_is_checkout_page() : mixed
mphb_is_search_results_page()
mphb_is_search_results_page() : mixed
mphb_is_single_room_type_page()
mphb_is_single_room_type_page() : mixed
mphb_is_create_booking_page()
mphb_is_create_booking_page() : mixed
mphb_get_thumbnail_width()
mphb_get_thumbnail_width() : mixed
mphb_format_price()
mphb_format_price(float $price[, array<string|int, mixed> $atts = array() ]) : string
Parameters
- $price : float
- $atts : array<string|int, mixed> = array()
mphb_format_percentage()
mphb_format_percentage(float $price[, array<string|int, mixed> $atts = array() ]) : string
Parameters
- $price : float
- $atts : array<string|int, mixed> = array()
mphb_trim_zeros()
Trim trailing zeros off prices.
mphb_trim_zeros(mixed $price) : string
Parameters
- $price : mixed
mphb_trim_decimal_zeros()
mphb_trim_decimal_zeros(mixed $price) : mixed
Parameters
- $price : mixed
Tags
mphb_get_paged_query_var()
Get WP Query paged var
mphb_get_paged_query_var() : int
mphb_add_to_meta_query()
mphb_add_to_meta_query(array<string|int, mixed> $queryPart, array<string|int, mixed>|null $metaQuery) : array<string|int, mixed>
Parameters
- $queryPart : array<string|int, mixed>
- $metaQuery : array<string|int, mixed>|null
mphb_meta_query_is_first_order_clause()
mphb_meta_query_is_first_order_clause(array<string|int, mixed> $query) : bool
Parameters
- $query : array<string|int, mixed>
mphb_clean()
Clean variables using sanitize_text_field. Arrays are cleaned recursively.
mphb_clean(string|array<string|int, mixed> $var) : string|array<string|int, mixed>
Non-scalar values are ignored.
Parameters
- $var : string|array<string|int, mixed>
mphb_hash_equals()
mphb_hash_equals(string $knownString, string $userInput) : bool
Parameters
- $knownString : string
- $userInput : string
Tags
mphb_strlen()
mphb_strlen(string $s) : string
Parameters
- $s : string
mphb_get_query_args()
TODO add support for arrays
mphb_get_query_args(string $url) : array<string|int, mixed>
Parameters
- $url : string
mphb_wp_dropdown_pages()
Wrapper function for wp_dropdown_pages
mphb_wp_dropdown_pages([array<string|int, mixed> $atts = array() ]) : string
Parameters
- $atts : array<string|int, mixed> = array()
Tags
mphb_set_time_limit()
Wrapper for set_time_limit to see if it is enabled.
mphb_set_time_limit(int $limit) : mixed
Parameters
- $limit : int
-
The maximum execution time, in seconds. If set to zero, no time limit is imposed.
mphb_error_log()
mphb_error_log(mixed $message) : mixed
Parameters
- $message : mixed
mphb_current_domain()
mphb_current_domain() : string
mphb_generate_uuid4()
For local usage only. For global IDs it's better to use function mphb_generate_uid().
mphb_generate_uuid4() : string
mphb_generate_uid()
mphb_generate_uid() : mixed
mphb_get_edit_post_link_for_everyone()
Retrieves the edit post link for post regardless current user capabilities
mphb_get_edit_post_link_for_everyone(int|string $id[, mixed $context = 'display' ]) : string
Parameters
- $id : int|string
- $context : mixed = 'display'
mphb_get_rooms_select_list()
mphb_get_rooms_select_list(int $typeId) : array<string|int, mixed>
Parameters
- $typeId : int
-
Room type ID.
mphb_show_multiple_instances_notice()
mphb_show_multiple_instances_notice() : mixed
mphb_upgrade_to_premium_message()
mphb_upgrade_to_premium_message([string $wrapper = 'span' ][, string $wrapperClass = 'description' ]) : string
Parameters
- $wrapper : string = 'span'
-
Optional. Wrapper tag - "span" or "div". "span" by default. Pass the empty value to remove the wrapper
- $wrapperClass : string = 'description'
-
Optional. "description" by default.
Tags
mphb_normilize_season_price()
Season price format history: v2.6.0- - single number.
mphb_normilize_season_price(mixed $price) : array<string|int, mixed>
v2.7.1- - ["base", "enable_variations" => "0"|"1", "variations" => ""|[["adults", "children", "price"]]]. v2.7.2+ - ["periods", "prices", "enable_variations" => true/false, "variations" => [["adults", "children", "prices"]]].
Parameters
- $price : mixed
-
Price in any format.
mphb_is_reserved_term()
Check if term name is reserved.
mphb_is_reserved_term(string $termName) : bool
Parameters
- $termName : string
-
Term name.
Tags
mphb_string_starts_with()
mphb_string_starts_with(string $haystack, string $needle) : bool
Parameters
- $haystack : string
- $needle : string
Tags
mphb_string_ends_with()
mphb_string_ends_with(string $haystack, string $needle) : bool
Parameters
- $haystack : string
- $needle : string
mphb_array_disjunction()
mphb_array_disjunction(mixed $a, mixed $b) : mixed
Parameters
- $a : mixed
- $b : mixed
Tags
mphb_readable_post_statuses()
mphb_readable_post_statuses() : array<string|int, mixed>
Tags
mphb_db_version()
mphb_db_version() : mixed
Tags
mphb_db_version_at_least()
mphb_db_version_at_least(mixed $requiredVersion) : mixed
Parameters
- $requiredVersion : mixed
Tags
mphb_version_at_least()
mphb_version_at_least(mixed $requiredVersion) : mixed
Parameters
- $requiredVersion : mixed
Tags
mphb_wordpress_at_least()
mphb_wordpress_at_least(string $requiredVersion) : bool
Parameters
- $requiredVersion : string
Tags
mphb_fix_blocks_autop()
mphb_fix_blocks_autop() : mixed
Tags
mphb_escape_json_unicodes()
mphb_escape_json_unicodes(string $json) : string
Parameters
- $json : string
-
JSON string with possibly escaped Unicode symbols (\uXXXX).
Tags
mphb_strip_price_breakdown_json()
mphb_strip_price_breakdown_json(string $json) : string
Parameters
- $json : string
-
JSON string with possibly escaped symbol '.
Tags
mphb_uploads_dir()
mphb_uploads_dir() : string
Tags
mphb_create_uploads_dir()
mphb_create_uploads_dir() : mixed
Tags
mphb_verify_nonce()
mphb_verify_nonce(mixed $action[, mixed $nonceName = 'mphb_nonce' ]) : mixed
Parameters
- $action : mixed
- $nonceName : mixed = 'mphb_nonce'
Tags
mphb_get_polyfill_for()
mphb_get_polyfill_for(mixed $function) : mixed
Parameters
- $function : mixed
Tags
mphb_current_year()
mphb_current_year() : int
Tags
mphb_days_in_month()
mphb_days_in_month(int $month, int $year) : int
Parameters
- $month : int
- $year : int
Tags
mphb_get_customer_fields()
mphb_get_customer_fields() : array<string|int, mixed>
Tags
mphb_get_default_customer_fields()
mphb_get_default_customer_fields() : array<string|int, mixed>
Tags
mphb_is_default_customer_field()
mphb_is_default_customer_field(string $fieldName) : bool
Parameters
- $fieldName : string
Tags
mphb_get_custom_customer_fields()
mphb_get_custom_customer_fields() : array<string|int, mixed>
Tags
mphb_get_admin_checkout_customer_fields()
mphb_get_admin_checkout_customer_fields() : array<string|int, mixed>
Tags
mphb_get_editing_post_id()
mphb_get_editing_post_id() : int
Tags
mphb_limit()
mphb_limit(int|float $value, int|float $min, int|float $max) : int|float
Parameters
- $value : int|float
- $min : int|float
- $max : int|float
Tags
mphb_array_insert_after()
Add an array after the specified position.
mphb_array_insert_after(array<string|int, mixed> $array, int $position, array<string|int, mixed> $insert) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
-
Subject array.
- $position : int
- $insert : array<string|int, mixed>
-
Array to insert.
Tags
mphb_array_insert_after_key()
Add an array after the specified key in the associative array.
mphb_array_insert_after_key(array<string|int, mixed> $array, mixed $searchKey, array<string|int, mixed> $insert) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
-
Subject array.
- $searchKey : mixed
- $insert : array<string|int, mixed>
-
Array to insert.
Tags
mphb_array_usearch()
mphb_array_usearch(array<string|int, mixed> $haystack, callable $checkCallback) : mixed
Parameters
- $haystack : array<string|int, mixed>
- $checkCallback : callable
-
The callback check function. The function must return TRUE if the proper element was found or FALSE otherwise. Gets the value of the element as the first argument and the key as second.
Tags
mphb_prefix()
mphb_prefix(string $str[, string $separator = '_' ]) : string
Parameters
- $str : string
- $separator : string = '_'
-
Optional. "_" by default.
Tags
mphb_unprefix()
mphb_unprefix(string $str[, string $separator = '_' ]) : string
Parameters
- $str : string
- $separator : string = '_'
-
Optional. "_" by default.
Tags
mphb_get_booking()
mphb_get_booking(int $bookingId[, bool $force = false ]) : Booking|null
Parameters
- $bookingId : int
- $force : bool = false
-
Optional. FALSE by default.
Tags
mphb_get_customer()
mphb_get_customer(int $bookingId) : Customer|null
Parameters
- $bookingId : int
Tags
mphb_get_room_type()
mphb_get_room_type(int $roomTypeId[, bool $force = false ]) : RoomType|null
Parameters
- $roomTypeId : int
- $force : bool = false
-
Optional. FALSE by default.
Tags
mphb_get_season()
mphb_get_season(int $seasonId[, bool $force = false ]) : Season|null
Parameters
- $seasonId : int
- $force : bool = false
-
Optional. False by default.
Tags
mphb_is_base_request()
Determine if the current view is the "All" view.
mphb_is_base_request([string|null $postType = null ]) : bool
Parameters
- $postType : string|null = null
-
Optional. NULL by default.
Tags
mphb_is_complete_booking()
mphb_is_complete_booking(Booking $booking) : bool
Parameters
- $booking : Booking
Tags
mphb_is_pending_booking()
mphb_is_pending_booking(Booking $booking) : bool
Parameters
- $booking : Booking
Tags
mphb_is_locking_booking()
mphb_is_locking_booking(Booking $booking) : bool
Parameters
- $booking : Booking
Tags
mphb_is_failed_booking()
mphb_is_failed_booking(Booking $booking) : bool
Parameters
- $booking : Booking
Tags
mphb_get_available_rooms()
mphb_get_available_rooms(DateTime $from, DateTime $to[, array<string|int, mixed> $atts = array() ]) : array<string|int, mixed>
Parameters
- $from : DateTime
-
Start date, like check-in date.
- $to : DateTime
-
End date, like check-out date.
- $atts : array<string|int, mixed> = array()
-
Optional. @param int $atts['room_type_id'] Optional. 0 by default (any room type). @param int|int[] $atts['exclude_bookings'] Optional. One or more booking IDs.
Tags
mphb_posint()
mphb_posint(int|string $value) : int
Parameters
- $value : int|string
Tags
mphb_get_min_adults()
mphb_get_min_adults() : int
Tags
mphb_get_min_children()
mphb_get_min_children() : int
Tags
mphb_get_max_adults()
mphb_get_max_adults() : int
Tags
mphb_get_max_children()
mphb_get_max_children() : int
Tags
mphb_array_flip_duplicates()
mphb_array_flip_duplicates(array<string|int, mixed> $array[, bool $arraySingle = false ]) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
-
Array to flip.
- $arraySingle : bool = false
-
Optional. Convert single value into array. FALSE by default.
Tags
mphb_get_room_type_base_price()
mphb_get_room_type_base_price([mixed $roomType = null ][, mixed $startDate = null ][, mixed $endDate = null ]) : float
Parameters
- $roomType : mixed = null
- $startDate : mixed = null
- $endDate : mixed = null
Tags
mphb_get_room_type_period_price()
mphb_get_room_type_period_price(DateTime $startDate, DateTime $endDate[, mixed $roomType = null ][, array<string|int, mixed> $args = array() ]) : float
Parameters
- $startDate : DateTime
- $endDate : DateTime
- $roomType : mixed = null
- $args : array<string|int, mixed> = array()
-
Optional.
Tags
mphb_get_room_type_ids()
mphb_get_room_type_ids([string $language = 'any' ][, array<string|int, mixed> $atts = array() ]) : array<string|int, int>
Parameters
- $language : string = 'any'
-
'any'|'original' Optional. 'any' by default.
- $atts : array<string|int, mixed> = array()
-
Additional atts.
Tags
mphb_today()
mphb_today([string $modifier = '' ]) : DateTime
Parameters
- $modifier : string = ''
-
Optional. Modifier like '+1 day'. Empty by default.
Tags
mphb_has_buffer_days()
mphb_has_buffer_days() : bool
Tags
mphb_get_buffer_days()
mphb_get_buffer_days(DateTime $date, int $roomTypeId) : int
Parameters
- $date : DateTime
- $roomTypeId : int
Tags
mphb_modify_buffer_period()
mphb_modify_buffer_period(DateTime $startDate, DateTime $endDate, int $bufferDays) : array<string|int, DateTime>
Parameters
- $startDate : DateTime
- $endDate : DateTime
- $bufferDays : int
Tags
mphb_modify_booking_buffer_period()
mphb_modify_booking_buffer_period(Booking $booking, int $bufferDays[, bool $extendDates = false ]) : array<string|int, DateTime>
Parameters
- $booking : Booking
- $bufferDays : int
- $extendDates : bool = false
-
Optional. Extend the final result with check-in and next to the check-out dates. Useful for Booking Calendar, for example. False by default.
Tags
mphb_modify_booking_period_with_booking_buffer()
mphb_modify_booking_period_with_booking_buffer(array<string|int, mixed> $bookingPeriod, int $roomTypeId) : array<string|int, DateTime>
Parameters
- $bookingPeriod : array<string|int, mixed>
- $roomTypeId : int
Tags
mphb_is_rooms_free_query_atts_with_buffer()
mphb_is_rooms_free_query_atts_with_buffer(array<string|int, mixed> $atts) : array<string|int, mixed>
Parameters
- $atts : array<string|int, mixed>
Tags
mphb_filter_checkin_checkout_dates()
mphb_filter_checkin_checkout_dates(array<string|int, mixed> $datesArray, int $roomsTotal) : array<string|int, mixed>
Parameters
- $datesArray : array<string|int, mixed>
- $roomsTotal : int
Tags
mphb_help_tip()
Display a help tip.
mphb_help_tip(string $tip[, bool $allow_html = false ]) : string
Parameters
- $tip : string
-
Help tip text.
- $allow_html : bool = false
-
Allow sanitized HTML if true or escape.
Tags
mphb_create_url()
mphb_create_url(string $endpoint[, string $value = '' ][, string $permalink = '' ]) : string
Parameters
- $endpoint : string
-
Endpoint slug.
- $value : string = ''
-
Query param value.
- $permalink : string = ''
-
Permalink.
Tags
mphb_parse_queue_room_id()
mphb_parse_queue_room_id(string $queueItem) : int
Parameters
- $queueItem : string
-
Sync queue item, like "%Timestamp%_%Room ID%".