Handles the form shortcode.
Description
See also
Parameters
- $atts
-
(array) (Required) Array of shortcode attributes.
- 'id'
(int) Form ID. This must always be present. - 'show'
(string) How to display the form. Either 'direct' or 'iframe'. Default 'direct'. - 'iframe_width'
(string) If $show is set to 'iframe', this indicates the iframe width. Default '100%'. - 'iframe_height'
(string) If $show is set to 'iframe', this indicates the iframe height. Default '100%'.
- 'id'
Source
File: src/db-objects/forms/form-frontend-output-handler.php
public function get_shortcode_content( $atts ) { $atts = shortcode_atts( array( 'id' => '', 'show' => 'direct', 'iframe_width' => '100%', 'iframe_height' => '100%', ), $atts ); $atts['id'] = absint( $atts['id'] ); if ( empty( $atts['id'] ) ) { return __( 'Shortcode is missing a form ID!', 'torro-forms' ); } $form = $this->form_manager->get( $atts['id'] ); if ( ! $form ) { return __( 'Shortcode is using an invalid form ID!', 'torro-forms' ); } if ( 'iframe' === $atts['show'] ) { $url = get_permalink( $form->id ); if ( isset( $_GET['torro_submission_id'] ) ) { $url = add_query_arg( 'torro_submission_id', absint( $_GET['torro_submission_id'] ), $url ); } return '<iframe src="' . $url . '" style="width:' . esc_attr( $atts['iframe_width'] ) . ';height:' . esc_attr( $atts['iframe_height'] ) . ';"></iframe>'; } $submission = null; if ( isset( $_GET['torro_submission_id'] ) ) { $submission = $this->form_manager->get_child_manager( 'submissions' )->get( absint( $_GET['torro_submission_id'] ) ); if ( $submission->form_id !== $form->id ) { $submission = null; } } ob_start(); $this->render_form_content( $form, $submission ); return ob_get_clean(); }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |