← All changes
|
includes/elementor-booking-form/elementor-widget-booking.php
+130
-4
11.1
→
11.9
View file →
| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * includes/elementor-booking-form/elementor-widget-booking.php |
| 4 | 4 | */ |
| @@ -226,9 +226,9 @@ | ||
| 226 | 226 | 'type' => 'wpbc_go_button', |
| 227 | 227 | 'text' => esc_html__( 'Go to Form Fields Configuration', 'booking' ), |
| 228 | 228 | 'icon' => 'eicon-share-arrow', |
| 229 | 229 | 'css_class' => 'e-btn-txt e-btn-txt-border', |
| 230 | - 'url' => esc_url( wpbc_get_settings_url() . '&tab=form' ), | |
| 230 | + 'url' => esc_url( wpbc_get_settings_url() . '&tab=builder_booking_form' ), | |
| 231 | 231 | 'condition' => [ |
| 232 | 232 | 'wpbc_booking_shortcode' => 'booking', |
| 233 | 233 | ], |
| 234 | 234 | ] |
| @@ -233,8 +233,102 @@ | ||
| 233 | 233 | ], |
| 234 | 234 | ] |
| 235 | 235 | ); |
| 236 | 236 | |
| 237 | + $this->add_control( | |
| 238 | + 'wpbc_booking_popup_enabled', | |
| 239 | + [ | |
| 240 | + 'type' => \Elementor\Controls_Manager::SWITCHER, | |
| 241 | + 'label' => esc_html__( 'Open in Popup', 'booking' ), | |
| 242 | + 'description' => esc_html__( 'Show a button that opens the booking form in a popup window.', 'booking' ), | |
| 243 | + 'label_on' => esc_html__( 'Yes', 'booking' ), | |
| 244 | + 'label_off' => esc_html__( 'No', 'booking' ), | |
| 245 | + 'return_value' => 'yes', | |
| 246 | + 'default' => '', | |
| 247 | + 'condition' => [ | |
| 248 | + 'wpbc_booking_shortcode' => 'booking', | |
| 249 | + ], | |
| 250 | + ] | |
| 251 | + ); | |
| 252 | + | |
| 253 | + $this->add_control( | |
| 254 | + 'wpbc_booking_popup_button_title', | |
| 255 | + [ | |
| 256 | + 'type' => \Elementor\Controls_Manager::TEXT, | |
| 257 | + 'label' => esc_html__( 'Popup Button Title', 'booking' ), | |
| 258 | + 'default' => esc_html__( 'Book now', 'booking' ), | |
| 259 | + 'placeholder' => esc_html__( 'Book now', 'booking' ), | |
| 260 | + 'label_block' => true, | |
| 261 | + 'condition' => [ | |
| 262 | + 'wpbc_booking_shortcode' => 'booking', | |
| 263 | + 'wpbc_booking_popup_enabled' => 'yes', | |
| 264 | + ], | |
| 265 | + ] | |
| 266 | + ); | |
| 267 | + | |
| 268 | + $this->add_control( | |
| 269 | + 'wpbc_booking_popup_title', | |
| 270 | + [ | |
| 271 | + 'type' => \Elementor\Controls_Manager::TEXT, | |
| 272 | + 'label' => esc_html__( 'Popup Title', 'booking' ), | |
| 273 | + 'default' => esc_html__( 'Booking Form', 'booking' ), | |
| 274 | + 'placeholder' => esc_html__( 'Booking Form', 'booking' ), | |
| 275 | + 'label_block' => true, | |
| 276 | + 'condition' => [ | |
| 277 | + 'wpbc_booking_shortcode' => 'booking', | |
| 278 | + 'wpbc_booking_popup_enabled' => 'yes', | |
| 279 | + ], | |
| 280 | + ] | |
| 281 | + ); | |
| 282 | + | |
| 283 | + $this->add_control( | |
| 284 | + 'wpbc_booking_popup_button_class', | |
| 285 | + [ | |
| 286 | + 'type' => \Elementor\Controls_Manager::TEXT, | |
| 287 | + 'label' => esc_html__( 'Popup Button CSS Class', 'booking' ), | |
| 288 | + 'default' => 'wp-element-button', | |
| 289 | + 'placeholder' => 'wp-element-button', | |
| 290 | + 'label_block' => true, | |
| 291 | + 'condition' => [ | |
| 292 | + 'wpbc_booking_shortcode' => 'booking', | |
| 293 | + 'wpbc_booking_popup_enabled' => 'yes', | |
| 294 | + ], | |
| 295 | + ] | |
| 296 | + ); | |
| 297 | + | |
| 298 | + $this->add_control( | |
| 299 | + 'wpbc_booking_popup_modal_class', | |
| 300 | + [ | |
| 301 | + 'type' => \Elementor\Controls_Manager::TEXT, | |
| 302 | + 'label' => esc_html__( 'Popup CSS Class', 'booking' ), | |
| 303 | + 'default' => '', | |
| 304 | + 'placeholder' => '', | |
| 305 | + 'label_block' => true, | |
| 306 | + 'condition' => [ | |
| 307 | + 'wpbc_booking_shortcode' => 'booking', | |
| 308 | + 'wpbc_booking_popup_enabled' => 'yes', | |
| 309 | + ], | |
| 310 | + ] | |
| 311 | + ); | |
| 312 | + | |
| 313 | + $this->add_control( | |
| 314 | + 'wpbc_booking_popup_size', | |
| 315 | + [ | |
| 316 | + 'type' => \Elementor\Controls_Manager::SELECT, | |
| 317 | + 'label' => esc_html__( 'Popup Size', 'booking' ), | |
| 318 | + 'options' => [ | |
| 319 | + 'lg' => esc_html__( 'Large', 'booking' ), | |
| 320 | + 'default' => esc_html__( 'Default', 'booking' ), | |
| 321 | + 'sm' => esc_html__( 'Small', 'booking' ), | |
| 322 | + ], | |
| 323 | + 'default' => 'lg', | |
| 324 | + 'condition' => [ | |
| 325 | + 'wpbc_booking_shortcode' => 'booking', | |
| 326 | + 'wpbc_booking_popup_enabled' => 'yes', | |
| 327 | + ], | |
| 328 | + ] | |
| 329 | + ); | |
| 330 | + | |
| 237 | 331 | $this->end_controls_section(); |
| 238 | 332 | |
| 239 | 333 | $this->start_controls_section( |
| 240 | 334 | 'wpbc_booking_advanced_section', |
| @@ -370,10 +464,42 @@ | ||
| 370 | 464 | if ( ! empty( $settings['wpbc_booking_calendar_startmonth'] ) ) { |
| 371 | 465 | $shortcode_params[] = "startmonth='" . $settings['wpbc_booking_calendar_startmonth'] . "'"; |
| 372 | 466 | } |
| 373 | 467 | |
| 468 | + if ( 'booking' === $shortcode_type && ! empty( $settings['wpbc_booking_popup_enabled'] ) && 'yes' === $settings['wpbc_booking_popup_enabled'] ) { | |
| 469 | + $shortcode_params[] = 'popup=1'; | |
| 374 | 470 | |
| 471 | + $popup_button_title = isset( $settings['wpbc_booking_popup_button_title'] ) ? sanitize_text_field( $settings['wpbc_booking_popup_button_title'] ) : ''; | |
| 472 | + if ( '' !== $popup_button_title && esc_html__( 'Book now', 'booking' ) !== $popup_button_title ) { | |
| 473 | + $shortcode_params[] = "popup_button_title='" . str_replace( "'", '', $popup_button_title ) . "'"; | |
| 474 | + } | |
| 375 | 475 | |
| 476 | + $popup_title = isset( $settings['wpbc_booking_popup_title'] ) ? sanitize_text_field( $settings['wpbc_booking_popup_title'] ) : ''; | |
| 477 | + if ( '' !== $popup_title && esc_html__( 'Booking Form', 'booking' ) !== $popup_title ) { | |
| 478 | + $shortcode_params[] = "popup_title='" . str_replace( "'", '', $popup_title ) . "'"; | |
| 479 | + } | |
| 480 | + | |
| 481 | + $popup_button_class = isset( $settings['wpbc_booking_popup_button_class'] ) ? sanitize_text_field( $settings['wpbc_booking_popup_button_class'] ) : ''; | |
| 482 | + if ( '' !== $popup_button_class && 'wp-element-button' !== $popup_button_class ) { | |
| 483 | + $shortcode_params[] = "popup_button_class='" . str_replace( "'", '', $popup_button_class ) . "'"; | |
| 484 | + } | |
| 485 | + | |
| 486 | + $popup_modal_class = isset( $settings['wpbc_booking_popup_modal_class'] ) ? sanitize_text_field( $settings['wpbc_booking_popup_modal_class'] ) : ''; | |
| 487 | + if ( '' !== $popup_modal_class ) { | |
| 488 | + $shortcode_params[] = "popup_modal_class='" . str_replace( "'", '', $popup_modal_class ) . "'"; | |
| 489 | + } | |
| 490 | + | |
| 491 | + $popup_size = isset( $settings['wpbc_booking_popup_size'] ) ? sanitize_key( $settings['wpbc_booking_popup_size'] ) : 'lg'; | |
| 492 | + if ( ! in_array( $popup_size, array( 'lg', 'sm', 'default' ), true ) ) { | |
| 493 | + $popup_size = 'lg'; | |
| 494 | + } | |
| 495 | + if ( 'lg' !== $popup_size ) { | |
| 496 | + $shortcode_params[] = "popup_size='{$popup_size}'"; | |
| 497 | + } | |
| 498 | + } | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 376 | 502 | // Final parameters string. |
| 377 | 503 | $shortcode_params_str = implode( ' ', $shortcode_params ); |
| 378 | 504 | |
| 379 | 505 | echo do_shortcode( '[' . $shortcode_type . ' ' . $shortcode_params_str . ']' ); |
| @@ -379,12 +505,12 @@ | ||
| 379 | 505 | echo do_shortcode( '[' . $shortcode_type . ' ' . $shortcode_params_str . ']' ); |
| 380 | 506 | } |
| 381 | 507 | |
| 382 | 508 | public function get_script_depends(): array { |
| 383 | - return array( 'wpbc-elementor-frontend-bridge' ); | |
| 509 | + return array( 'wpbc-modal', 'wpbc-elementor-frontend-bridge' ); | |
| 384 | 510 | } |
| 385 | 511 | |
| 386 | 512 | public function get_style_depends(): array { |
| 387 | - return array( 'wpbc-elementor-frontend-bridge' ); | |
| 513 | + return array( 'wpdevelop-bts', 'wpdevelop-bts-theme', 'wpbc-admin-modal-popups', 'wpbc-elementor-frontend-bridge' ); | |
| 388 | 514 | } |
| 389 | 515 | |
| 390 | -} | |
| 516 | +} | |