$name ) { $forms[ (string) $id ] = $name; } $this->start_controls_section( 'abientot_booking_form', array( 'label' => __( 'Booking form', 'abientot' ) ) ); $this->add_control( 'form', array( 'label' => __( 'Form', 'abientot' ), 'type' => \Elementor\Controls_Manager::SELECT, 'options' => $forms, 'default' => '0', ) ); $this->add_control( 'mode', array( 'label' => __( 'Display', 'abientot' ), 'type' => \Elementor\Controls_Manager::SELECT, 'options' => array( '' => __( 'Use the form setting', 'abientot' ), 'embedded' => __( 'Embedded', 'abientot' ), 'popup' => __( 'Popup', 'abientot' ), ), 'default' => '', ) ); $this->end_controls_section(); } /** The shortcode for the chosen form and display; built from a resolved form id and a fixed list of modes. */ private function shortcode(): string { $settings = $this->get_settings_for_display(); $mode = sanitize_key( (string) ( $settings['mode'] ?? '' ) ); return BookingForms::shortcode( BookingForms::resolve( $settings['form'] ?? 0 ), in_array( $mode, array( 'embedded', 'popup' ), true ) ? $mode : '' ); } protected function render() { echo do_shortcode( $this->shortcode() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- The booking form escapes its own markup. } /** Elementor copies this into the post content: the shortcode keeps the form working without Elementor and lets Abientot find the booking page. */ public function render_plain_content() { echo $this->shortcode(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Fixed shortcode text: an integer id and a whitelisted mode. } /** A form is not page text: nothing for Elementor's Markdown export (and no form rendered for it). */ public function render_markdown(): string { return ''; } }