# booking/11.4.2/includes/elementor-booking-form/elementor-widget-booking.php

Booking Calendar, version 11.4.2. 517 lines.

- Page: https://pluginprobe.com/plugins/booking/11.4.2/code/includes/elementor-booking-form/elementor-widget-booking.php
- Raw: https://pluginprobe.com/plugins/booking/11.4.2/raw/includes/elementor-booking-form/elementor-widget-booking.php
- Modified: 2026-07-13T07:52:42+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/booking/11.4.2/code/includes/elementor-booking-form/elementor-widget-booking.php#L10-L20`.

```php
<?php
/**
 * includes/elementor-booking-form/elementor-widget-booking.php
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * Elementor Booking Calendar Widget.
 *
 * Elementor widget for Booking Calendar plugin.
 *
 * @since 1.0.0
 */
class WPBC_Elementor_WPBC_Booking_Form_1 extends \Elementor\Widget_Base {

	/**
	 * Get widget name.
	 *
	 * Retrieve list widget name.
	 *
	 * @since 1.0.0
	 * @access public
	 * @return string Widget name.
	 */
	public function get_name(): string {
		return 'wpbc_widget_booking_form_1';
	}

	/**
	 * Get widget title.
	 *
	 * Retrieve list widget title.
	 *
	 * @since 1.0.0
	 * @access public
	 * @return string Widget title.
	 */
	public function get_title(): string {
		return 'Booking Calendar'; // . ' - ' . esc_html__( 'Booking Form', 'booking' ); //.
	}

	/**
	 * Get widget icon.
	 *
	 * Retrieve list widget icon.
	 *
	 * @since 1.0.0
	 * @access public
	 * @return string Widget icon.
	 */
	public function get_icon(): string {
		return 'wpbc_logo_in_elementor';
	}

	/**
	 * Get widget categories.
	 *
	 * Retrieve the list of categories the list widget belongs to.
	 *
	 * @since 1.0.0
	 * @access public
	 * @return array Widget categories.
	 */
	public function get_categories(): array {
		return [ 'basic', 'wpbc' ];
	}

	/**
	 * Get widget keywords.
	 *
	 * Retrieve the list of keywords the list widget belongs to.
	 *
	 * @since 1.0.0
	 * @access public
	 * @return array Widget keywords.
	 */
	public function get_keywords(): array {
		return [ 'Booking Calendar', 'booking', 'calendar', 'bookings', 'events', 'appointments', 'booking plugin', 'wpbc' ];
	}

	/**
	 * Get custom help URL.
	 *
	 * Retrieve a URL where the user can get more information about the widget.
	 *
	 * @since 1.0.0
	 * @access public
	 * @return string Widget help URL.
	 */
	public function get_custom_help_url(): string {
		return 'https://wpbookingcalendar.com/contact/';
	}

	/**
	 * Get widget promotion data.
	 *
	 * Retrieve the widget promotion data.
	 *
	 * @since 1.0.0
	 * @access protected
	 * @return array Widget promotion data.
	 */
	protected function get_upsale_data(): array {
		return array(
			'image'        => 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' => '<strong>' . esc_html__('Optional', 'booking') . '!</strong> '  . 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' => '<strong>' . esc_html__('Optional', 'booking') . '!</strong> ' . 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' => '<strong>' . esc_html__('Optional', 'booking') . '!</strong> ' . 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'  => '<button type="button" class="elementor-button wpbc-reset-dates-button" style="margin-top:10px;">'.esc_html__('Reset Dates','booking').'</button>',
				'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' );
	}

}

```
