Inventory_Presser_Plugin::single_sections_add_form( array $sections )

Adds a contact form to single vehicle pages if a form is saved in the setting.


Parameters Parameters

$sections

(array) (Required)


Top ↑

Return Return

(array)


Top ↑

Source Source

File: inventory-presser.php

		public function single_sections_add_form( $sections ) {
			// Does this setting have a value?
			$settings = INVP::settings();
			if ( ! empty( $settings['singles_contact_form'] ) ) {
				// Value is a form ID prefixed with the form builder. GF_8.
				$form = explode( '_', $settings['singles_contact_form'] );
				if ( ! is_array( $form ) || 2 !== count( $form ) ) {
					return $sections;
				}
				$form_html         = '';
				$shortcode_pattern = '';
				switch ( $form[0] ) {
					case 'CF7':
						$shortcode_pattern = '[contact-form-7 id="%s"]';
						break;

					case 'GF':
						$shortcode_pattern = '

Oops! We could not locate your form.

'; break; case 'WPF': $shortcode_pattern = '[wpforms id="%s"]'; break; case 'WSF': $shortcode_pattern = '[ws_form id="%s"]'; break; } $shortcode = sprintf( $shortcode_pattern, $form[1] ); if ( '' !== $shortcode ) { $form_html = apply_shortcodes( apply_filters( 'invp_single_sections_form_shortcode', $shortcode ) ); } if ( '' !== $form_html ) { // Add the form to the sections array. $sections['form'] = sprintf( '<h2 class="vehicle-content-wrap">%s</h2><div class="vehicle-content-wrap">%s</div>', esc_html( apply_filters( 'invp_single_sections_form_title', __( 'Check Availability', 'inventory-presser' ) ) ), $form_html ); } } return $sections; }