Core concepts

Blocks

The plugins add seven custom blocks to the site, each of them are listed below.

Contact Form

One of the most essential blocks in the plugin, this block adds a contact form on the landing pages. By default, the form sends an email with the lead information to the email added in the settings box; however, this block has a filter where you can intercept the request and add your own logic.

The logic to send the email is defined in a custom end-point, see the register hook and the logic implementation

dslp_handle_form_submit

As I said before, the function to send the email has a filter where you can intercept the request and add your own logic. The filter is called dslp_handle_form_submit and here is a sample of how you can implement your own logic:

add_filter( 'dslp_handle_form_submit', function ( WP_REST_Request $request ) {
	$data    = $request->get_json_params();
	$name    = $data['name'];
	$email   = $data['email'];
	$phone   = $data['phone'];
	$zip     = $data['zipcode'];
	$message = $data['message'];
	$to      = $data['email-to'];
	$referer = $request->get_header( 'referer' );

	$body = 'A new inquiry has been submitted<br><br>';
	$body .= sprintf( 'Name: %s', $name . '<br><br>' );
	$body .= sprintf( 'Email: %s', $email . '<br><br>' );
	$body .= sprintf( 'Phone: %s', $phone . '<br><br>' );
	$body .= sprintf( 'Zip: %s', $zip . '<br><br>' );
	$body .= sprintf( 'Referrer: %s', $referer . '<br><br>' );
	$body .= sprintf( 'Message: %s', $message . '<br><br>' );
	$subject = apply_filters( 'dslp_email_subject', '[URGENT] New Inquiry Submitted' );
	$mail = wp_mail( $to, $subject, $body );
	// Airtable Integration.
	$airtableData = [
		'email'               => $email,
		'full_name'           => $name,
		'phone'               => $phone,
		'project_description' => $message,
		'project_type'        => "Other",
		'request_appointment' => true,
		'zip'                 => $zip,
		'referrer'            => $referer,
		'landing_page'        => true,
	];

	$apiUrl = get_rest_url( null, 'booking/v1/sync-lead' );

	$apiRequest = wp_remote_post( $apiUrl, [
		'headers'     => [ 'Content-Type' => 'application/json; charset=utf-8' ],
		'body'        => json_encode( $airtableData ),
		'data_format' => 'body',
	] );

	if ( is_wp_error( $apiRequest ) ) {
		return new WP_REST_Response( [ 'success' => false ], 500 );
	}

	return new WP_REST_Response( [ 'success' => true, 'status' => 'ok', 'message' => 'Thank you for your submission. We will be in touch shortly.' ], 200 );
} );

In the previous example, we intercepted the request, sent a custom email, and also we stored the lead information on AirTable, and finally, we returned a WP_REST_Response indicating that the response was taken and proceeded successfully.

dslp_email_subject

There is another filter to change the email subject if needed. The filter is called dslp_email_subject and here is an example of how to use it:

add_filter('dslp_email_subject', function ($subject) {
	// Verify if the cookie source is set if yes then use add a switch case to set the subject
	$cookie = $_COOKIE['lead-source'];
	if (isset($cookie)) {
		switch ($cookie) {
			case 'google-ads':
				$subject = '[Google Ads] New Inquiry Submitted';
				break;
            default:
        }
	}

	return $subject;
});

In the previous example, we changed the subject if a cookie is present.

The main files for this block are:

admin/partials/blocks/contact-form.php
common/css/contact-form.scss
common/js/contact-form.js

The settings configuration is located in:

admin/acf.php

Text Keywords

Another important block, this block allows the user to add several texts and show them based on a URL keyword, this is what make dymanic the landing pages.

The main files for this block are:

admin/partials/blocks/text-by-keywors.php

The settings configuration is located in:

admin/acf.php

Image Grid

This block allows the user to add several images and is used for to show logos or brands.

The main files for this block are:

admin/partials/blocks/images-grid.php
common/css/images-grid.scss

The settings configuration is located in:

admin/acf.php

Offers Slider

This block allows the user to add images in a carousel view and is used to show deals in the hero section.

The main files for this block are:

admin/partials/blocks/offers-slider.php
common/css/offers.scss
common/js/offers.js

The settings configuration is located in:

admin/acf.php

Post Carrousel

This block allows the user to show blog posts in a carrousel way.

The main files for this block are:

admin/partials/blocks/post-carrousel.php
common/css/post-carrousel.scss
common/js/post-carrousel.js

The settings configuration is located in:

admin/acf.php

Reviews Slider

This block allows the user to show clients reviews in a carrousel way.

The main files for this block are:

admin/partials/blocks/reviews-slider.php
common/css/reviews.scss
common/js/reviews.js

The settings configuration is located in:

admin/acf.php

Toggle Content

This block allows the user to show content in a toggle way, this can be used for a FAQs section for example.

The main files for this block are:

admin/partials/blocks/toggle.php
common/css/toogle.scss
common/js/toggle.js

The settings configuration is located in:

admin/acf.php
Previous
Plugin Structure