Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for using custom HTML or shortcode for lead capture form #272

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/simply-rets-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public static function register_admin_settings() {
register_setting('sr_admin_settings', 'sr_listing_gallery');
register_setting('sr_admin_settings', 'sr_show_leadcapture');
register_setting('sr_admin_settings', 'sr_leadcapture_recipient');
register_setting('sr_admin_settings', 'sr_leadcapture_custom_form');
register_setting('sr_admin_settings', 'sr_additional_rooms');
register_setting('sr_admin_settings', 'sr_listhub_analytics');
register_setting('sr_admin_settings', 'sr_listhub_analytics_id');
Expand Down Expand Up @@ -130,6 +131,15 @@ public static function sr_admin_page() {
update_option('sr_custom_disclaimer', htmlentities(stripslashes($_POST['sr_custom_disclaimer'])));
}

// Custom POST handler for updating the custom lead capture form
// so we can properly sanitize the input.
if (isset( $_POST['sr_leadcapture_custom_form'] )) {
update_option(
'sr_leadcapture_custom_form',
htmlentities(stripslashes($_POST['sr_leadcapture_custom_form']))
);
}

// Custom POST handler for updating the custom disclaimer
// so we can properly sanitize the input.
if (isset( $_POST['sr_custom_no_results_message'] )) {
Expand Down Expand Up @@ -232,6 +242,18 @@ public static function sr_admin_page() {
/>
</td>
</tr>
<tr>
<td>
<p>
<strong>Use custom Custom lead capture form HTML or shortcode
<small>
<i>(leave blank to use default form)</i>
</small>
</strong>
</p>
<textarea id="sr_leadcapture_custom_form" name="sr_leadcapture_custom_form" cols="35" rows="6"><?php echo esc_attr( get_option('sr_leadcapture_custom_form') ); ?></textarea>
</td>
</tr>
</tbody>
</table>
<h3>Map settings</h3>
Expand Down
8 changes: 8 additions & 0 deletions src/simply-rets-api-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1858,6 +1858,14 @@ public static function srWidgetListingGenerator( $response, $settings ) {


public static function srContactFormMarkup($listing) {
$custom_form = get_option('sr_leadcapture_custom_form', false);

// Use custom form if configured
if ($custom_form != false) {
return do_shortcode($custom_form);
}

// Default lead capture form
$markup = '';
$markup .= '<hr>';
$markup .= '<div id="sr-contact-form">';
Expand Down