esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ),
'image_alt' => esc_attr__( 'Upgrade', 'booking' ),
'title' => esc_html__( 'Booking Calendar Pro', 'booking' ),
'description' => esc_html__( 'Get the premium version of the plugin with additional features.', 'booking' ),
'upgrade_url' => esc_url( 'https://wpbookingcalendar.com/prices/' ),
'upgrade_text' => esc_html__( 'Upgrade Now', 'booking' ),
'condition' => ! class_exists('wpdev_bk_personal'),
);
}
/**
* Whether the widget requires inner wrapper.
*
* Determine whether to optimize the DOM size.
*
* @since 1.0.0
* @access public
* @return bool Whether to optimize the DOM size.
*/
public function has_widget_inner_wrapper(): bool {
return true;
}
/**
* Whether the element returns dynamic content.
*
* Determine whether to cache the element output or not.
*
* @since 1.0.0
* @access protected
* @return bool Whether to cache the element output.
*/
protected function is_dynamic_content(): bool {
return true;
}
/**
* Register list widget controls.
*
* Add input fields to allow the user to customize the widget settings.
*
* @since 1.0.0
* @access protected
*/
protected function register_controls(): void {
$this->start_controls_section(
'wpbc_booking_interface_section',
[
'label' => esc_html__( 'Booking Interface', 'booking' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'wpbc_booking_shortcode',
[
'type' => \Elementor\Controls_Manager::SELECT,
'label' => esc_html__( 'Display Mode', 'booking' ),
'options' => [
'booking' => esc_html__( 'Booking Form', 'booking' ) . ' + ' . esc_html__( 'Calendar', 'booking' ),
'bookingcalendar' => esc_html__( 'Availability Calendar Only', 'booking' ),
],
'default' => 'booking',
'label_block' => true,
]
);
if ( class_exists( 'wpdev_bk_personal' ) ) {
$this->add_control(
'wpbc_booking_resource_id',
[
'label' => esc_html__( 'Select Booking Resource', 'booking' ),
'type' => 'wpbc_resource_selection',
]
);
}
$this->add_control(
'wpbc_booking_months_number',
[
'type' => \Elementor\Controls_Manager::SELECT,
'label' => esc_html__( 'Number of Visible Months', 'booking' ),
'options' => [
'1' => '1 ' . esc_html__( 'month', 'booking' ),
'2' => '2 ' . esc_html__( 'months', 'booking' ),
'3' => '3 ' . esc_html__( 'months', 'booking' ),
'4' => '4 ' . esc_html__( 'months', 'booking' ),
'5' => '5 ' . esc_html__( 'months', 'booking' ),
'6' => '6 ' . esc_html__( 'months', 'booking' ),
'7' => '7 ' . esc_html__( 'months', 'booking' ),
'8' => '8 ' . esc_html__( 'months', 'booking' ),
'9' => '9 ' . esc_html__( 'months', 'booking' ),
'10' => '10 ' . esc_html__( 'months', 'booking' ),
'11' => '11 ' . esc_html__( 'months', 'booking' ),
'12' => '12 ' . esc_html__( 'months', 'booking' ),
],
'default' => '1',
]
);
if ( wpbc_is_custom_forms_enabled() ) {
$this->add_control(
'wpbc_custom_form_id',
[
'label' => esc_html__( 'Use Custom Form', 'booking' ),
'type' => 'wpbc_custom_form_selection',
'condition' => [
'wpbc_booking_shortcode' => 'booking',
],
]
);
}
$this->add_control(
'wpbc_go_button__form_fields',
[
'type' => 'wpbc_go_button',
'text' => esc_html__( 'Go to Form Fields Configuration', 'booking' ),
'icon' => 'eicon-share-arrow',
'css_class' => 'e-btn-txt e-btn-txt-border',
'url' => esc_url( wpbc_get_settings_url() . '&tab=builder_booking_form' ),
'condition' => [
'wpbc_booking_shortcode' => 'booking',
],
]
);
$this->add_control(
'wpbc_booking_popup_enabled',
[
'type' => \Elementor\Controls_Manager::SWITCHER,
'label' => esc_html__( 'Open in Popup', 'booking' ),
'description' => esc_html__( 'Show a button that opens the booking form in a popup window.', 'booking' ),
'label_on' => esc_html__( 'Yes', 'booking' ),
'label_off' => esc_html__( 'No', 'booking' ),
'return_value' => 'yes',
'default' => '',
'condition' => [
'wpbc_booking_shortcode' => 'booking',
],
]
);
$this->add_control(
'wpbc_booking_popup_button_title',
[
'type' => \Elementor\Controls_Manager::TEXT,
'label' => esc_html__( 'Popup Button Title', 'booking' ),
'default' => esc_html__( 'Book now', 'booking' ),
'placeholder' => esc_html__( 'Book now', 'booking' ),
'label_block' => true,
'condition' => [
'wpbc_booking_shortcode' => 'booking',
'wpbc_booking_popup_enabled' => 'yes',
],
]
);
$this->add_control(
'wpbc_booking_popup_title',
[
'type' => \Elementor\Controls_Manager::TEXT,
'label' => esc_html__( 'Popup Title', 'booking' ),
'default' => esc_html__( 'Booking Form', 'booking' ),
'placeholder' => esc_html__( 'Booking Form', 'booking' ),
'label_block' => true,
'condition' => [
'wpbc_booking_shortcode' => 'booking',
'wpbc_booking_popup_enabled' => 'yes',
],
]
);
$this->add_control(
'wpbc_booking_popup_button_class',
[
'type' => \Elementor\Controls_Manager::TEXT,
'label' => esc_html__( 'Popup Button CSS Class', 'booking' ),
'default' => 'wp-element-button',
'placeholder' => 'wp-element-button',
'label_block' => true,
'condition' => [
'wpbc_booking_shortcode' => 'booking',
'wpbc_booking_popup_enabled' => 'yes',
],
]
);
$this->add_control(
'wpbc_booking_popup_modal_class',
[
'type' => \Elementor\Controls_Manager::TEXT,
'label' => esc_html__( 'Popup CSS Class', 'booking' ),
'default' => '',
'placeholder' => '',
'label_block' => true,
'condition' => [
'wpbc_booking_shortcode' => 'booking',
'wpbc_booking_popup_enabled' => 'yes',
],
]
);
$this->add_control(
'wpbc_booking_popup_size',
[
'type' => \Elementor\Controls_Manager::SELECT,
'label' => esc_html__( 'Popup Size', 'booking' ),
'options' => [
'lg' => esc_html__( 'Large', 'booking' ),
'default' => esc_html__( 'Default', 'booking' ),
'sm' => esc_html__( 'Small', 'booking' ),
],
'default' => 'lg',
'condition' => [
'wpbc_booking_shortcode' => 'booking',
'wpbc_booking_popup_enabled' => 'yes',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'wpbc_booking_advanced_section',
[
'label' => esc_html__( 'Advanced', 'booking' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'wpbc_booking_calendar_dates_start',
[
'type' => \Elementor\Controls_Manager::DATE_TIME,
'label' => esc_html__( 'Earliest date visible/selectable in the calendar.', 'booking' ),
'default' => '',
'label_block' => true,
'description' => '' . esc_html__('Optional', 'booking') . '! ' . esc_html__( 'Format: YYYY-MM-DD (e.g. 2025-07-26)', 'booking' ),
'picker_options' => [
'enableTime' => false,
'dateFormat' => 'Y-m-d', // '2025-07-26' format
],
]
);
$this->add_control(
'wpbc_booking_calendar_dates_end',
[
'type' => \Elementor\Controls_Manager::DATE_TIME,
'label' => esc_html__( 'Latest date visible/selectable in the calendar.', 'booking' ),
'default' => '',
'label_block' => true,
'description' => '' . esc_html__('Optional', 'booking') . '! ' . esc_html__( 'Format: YYYY-MM-DD (e.g. 2025-12-31)', 'booking' ),
'picker_options' => [
'enableTime' => false,
'dateFormat' => 'Y-m-d', // '2025-07-26' format
],
]
);
$this->add_control(
'wpbc_booking_calendar_startmonth',
[
'type' => \Elementor\Controls_Manager::DATE_TIME,
'label' => esc_html__( 'Select start month of calendar after loading.', 'booking' ),
'default' => '',
'label_block' => true,
'description' => '' . esc_html__('Optional', 'booking') . '! ' . esc_html__( 'Format: YYYY-MM (e.g. 2025-3)', 'booking' ),
'picker_options' => [
'enableTime' => false,
'dateFormat' => 'Y-m', // '2025-07-26' format
],
]
);
$this->add_control(
'wpbc_booking_calendar_dates_reset_button',
[
'type' => \Elementor\Controls_Manager::RAW_HTML,
'raw' => '',
'content_classes' => 'wpbc-calendar-dates-reset-wrapper',
]
);
$this->end_controls_section();
$this->start_controls_section(
'wpbc_theme_section',
[
'label' => esc_html__( 'Appearance & Color Themes', 'booking' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'wpbc_calendar_skin_control',
[
'label' => esc_html__( 'Calendar Theme (Skin)', 'booking' ),
'type' => 'wpbc_calendar_skin_selection',
'frontend_available' => false,
'render_type' => 'none',
'label_block' => true,
]
);
$this->end_controls_section();
}
/**
* Render list widget output on the frontend.
*
* Written in PHP and used to generate the final HTML.
*
* @since 1.0.0
* @access protected
*/
protected function render(): void {
$shortcode_params = array();
$settings = $this->get_settings_for_display();
// Shortcode type.
$allowed_shortcodes = array( 'booking', 'bookingcalendar' );
$shortcode_type = in_array( $settings['wpbc_booking_shortcode'], $allowed_shortcodes, true ) ? $settings['wpbc_booking_shortcode'] : 'booking';
// Number of months.
$months_number = isset( $settings['wpbc_booking_months_number'] ) ? intval( $settings['wpbc_booking_months_number'] ) : 1;
if ( $months_number > 1 ) {
$shortcode_params[] = "nummonths={$months_number}";
}
// Booking resource (if personal version is active).
if ( class_exists( 'wpdev_bk_personal' ) && ! empty( $settings['wpbc_booking_resource_id'] ) && intval( $settings['wpbc_booking_resource_id'] ) > 1 ) {
$resource_id = intval( $settings['wpbc_booking_resource_id'] );
$shortcode_params[] = "resource_id={$resource_id}";
}
// Is custom use form ?
if ( ( class_exists( 'wpdev_bk_biz_m' ) ) && ! empty( $settings['wpbc_custom_form_id'] ) ) {
$wpbc_custom_form_id = sanitize_text_field( $settings['wpbc_custom_form_id'] );
if ( 'standard' !== $wpbc_custom_form_id ) {
$shortcode_params[] = "form_type='{$wpbc_custom_form_id}'";
}
}
// wpbc_booking_calendar_dates_start / calendar_dates_end / startmonth .
if ( ! empty( $settings['wpbc_booking_calendar_dates_start'] ) ) {
$shortcode_params[] = "calendar_dates_start='" . $settings['wpbc_booking_calendar_dates_start'] . "'";
}
if ( ! empty( $settings['wpbc_booking_calendar_dates_end'] ) ) {
$shortcode_params[] = "calendar_dates_end='" . $settings['wpbc_booking_calendar_dates_end'] . "'";
}
if ( ! empty( $settings['wpbc_booking_calendar_startmonth'] ) ) {
$shortcode_params[] = "startmonth='" . $settings['wpbc_booking_calendar_startmonth'] . "'";
}
if ( 'booking' === $shortcode_type && ! empty( $settings['wpbc_booking_popup_enabled'] ) && 'yes' === $settings['wpbc_booking_popup_enabled'] ) {
$shortcode_params[] = 'popup=1';
$popup_button_title = isset( $settings['wpbc_booking_popup_button_title'] ) ? sanitize_text_field( $settings['wpbc_booking_popup_button_title'] ) : '';
if ( '' !== $popup_button_title && esc_html__( 'Book now', 'booking' ) !== $popup_button_title ) {
$shortcode_params[] = "popup_button_title='" . str_replace( "'", '', $popup_button_title ) . "'";
}
$popup_title = isset( $settings['wpbc_booking_popup_title'] ) ? sanitize_text_field( $settings['wpbc_booking_popup_title'] ) : '';
if ( '' !== $popup_title && esc_html__( 'Booking Form', 'booking' ) !== $popup_title ) {
$shortcode_params[] = "popup_title='" . str_replace( "'", '', $popup_title ) . "'";
}
$popup_button_class = isset( $settings['wpbc_booking_popup_button_class'] ) ? sanitize_text_field( $settings['wpbc_booking_popup_button_class'] ) : '';
if ( '' !== $popup_button_class && 'wp-element-button' !== $popup_button_class ) {
$shortcode_params[] = "popup_button_class='" . str_replace( "'", '', $popup_button_class ) . "'";
}
$popup_modal_class = isset( $settings['wpbc_booking_popup_modal_class'] ) ? sanitize_text_field( $settings['wpbc_booking_popup_modal_class'] ) : '';
if ( '' !== $popup_modal_class ) {
$shortcode_params[] = "popup_modal_class='" . str_replace( "'", '', $popup_modal_class ) . "'";
}
$popup_size = isset( $settings['wpbc_booking_popup_size'] ) ? sanitize_key( $settings['wpbc_booking_popup_size'] ) : 'lg';
if ( ! in_array( $popup_size, array( 'lg', 'sm', 'default' ), true ) ) {
$popup_size = 'lg';
}
if ( 'lg' !== $popup_size ) {
$shortcode_params[] = "popup_size='{$popup_size}'";
}
}
// Final parameters string.
$shortcode_params_str = implode( ' ', $shortcode_params );
echo do_shortcode( '[' . $shortcode_type . ' ' . $shortcode_params_str . ']' );
}
public function get_script_depends(): array {
return array( 'wpbc-modal', 'wpbc-elementor-frontend-bridge' );
}
public function get_style_depends(): array {
return array( 'wpdevelop-bts', 'wpdevelop-bts-theme', 'wpbc-admin-modal-popups', 'wpbc-elementor-frontend-bridge' );
}
}