element keywords.
*/
public function get_keywords() {
return [
'sureforms',
'contact form',
'form',
'bricks form',
];
}
/**
* Set element controls.
*
* @since 0.0.5
* @return void
*/
public function set_controls() {
// Select Form.
$this->controls['form-id'] = [
'tab' => 'content',
'label' => __( 'Form', 'sureforms' ),
'type' => 'select',
'options' => Helper::get_sureforms_title_with_ids(),
'placeholder' => __( 'Select Form', 'sureforms' ),
];
// Show Form Title Toggle.
$this->controls['form-title'] = [
'tab' => 'content',
'label' => __( 'Show Form Title', 'sureforms' ),
'type' => 'checkbox',
'info' => __( 'Enable this to show form title.', 'sureforms' ),
'required' => [ 'form-id', '!=', '' ],
];
$this->controls['srfm_form_submission_info'] = [
'tab' => 'content',
'content' => __( 'Form submission will be possible on the frontend.', 'sureforms' ),
'type' => 'info',
'required' => [ 'form-id', '!=', '' ],
];
}
/**
* Enqueue scripts for phone and dropdown field in the Bricks editor.
*
* @since 0.0.10
* @return void
*/
public function enqueue_scripts() {
// enqueue common fields assets for the dropdown and phone fields.
Page_Builders::enqueue_common_fields_assets();
}
/**
* Render element.
*
* @since 0.0.5
* @return void
*/
public function render() {
$settings = $this->settings;
$form_id = $settings['form-id'] ?? '';
$form_title = isset( $settings['form-title'] );
// get spectra blocks and add css and js.
$blocks = parse_blocks( get_post_field( 'post_content', $form_id ) );
$styles = Spec_Gb_Helper::get_instance()->get_assets( $blocks );
if ( $form_id > 0 ) {
// phpcs:ignore -- WordPress.Security.EscapeOutput.OutputNotEscaped - Escaping not required.
echo 'render_attributes( '_root' ) . '>' . do_shortcode( sprintf( '[sureforms id="%s" show_title="%s"]', $form_id, ! $form_title ) );
// phpcs:ignore -- WordPress.Security.EscapeOutput.OutputNotEscaped - Escaping not required.
echo '';
// phpcs:ignore -- WordPress.Security.EscapeOutput.OutputNotEscaped - Escaping not required.
echo '
';
} else {
// Show placeholder when no form is selected.
// phpcs:ignore -- WordPress.Security.EscapeOutput.OutputNotEscaped - Escaping not required.
echo $this->render_element_placeholder(
[
'icon-class' => $this->icon,
'description' => esc_html__( 'Select the form that you wish to add here.', 'sureforms' ),
]
);
// phpcs:ignoreEnd
}
}
}