Below, you’ll find a detailed guide on how to add the CleverReach® WP Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the CleverReach® WP Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the CleverReach® WP Plugin and the shortcodes it provides:
"CleverReach® WP is a powerful WordPress plugin that seamlessly integrates with CleverReach® to automate your email marketing, improve communication, and grow your business."
- [cleverreach]
CleverReach® WP [cleverreach] Shortcode
The CleverReach shortcode is a powerful tool used to handle forms in WordPress. It uses the ‘cleverreach_form_handler’ function to register and validate form entries. If no form is specified or found, it returns an empty string. However, if a form is identified, it retrieves the form’s HTML code, providing a flexible way to manage forms.
Shortcode: [cleverreach]
Parameters
Here is a list of all possible cleverreach shortcode parameters and attributes:
form
– Specifies the ID of the CleverReach form to display
Examples and Usage
Basic example – A simple usage of the shortcode to display a form based on its ID.
[cleverreach form=1 /]
Advanced examples – Showcasing more complex usage of the shortcode. Here, we’re using the shortcode to display a form by referencing both ID and title. The form will first try to load by ID, but if not found, it will try to load by title.
[cleverreach form=1 title="Sign Up Form" /]
Please note that the ‘title’ attribute in the advanced example is not supported in the given PHP code. This is just an illustrative example of how additional parameters can be used in shortcodes. The actual implementation may require additional coding to support such features.
PHP Function Code
In case you have difficulties debugging what causing issues with [cleverreach]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'cleverreach', array( $this, 'cleverreach_form_handler' ) );
Shortcode PHP function:
function cleverreach_form_handler( $attributes ) {
Initializer::register();
if ( empty( $attributes[ 'form' ] ) ) {
return '';
}
$form_repository = RepositoryRegistry::getRepository( Form::getClassName() );
$filter = new QueryFilter();
$filter->where( 'formId', Operators::EQUALS, $attributes[ 'form' ] );
/** @var Form $form */
$form = $form_repository->selectOne( $filter );
if ( ! $form ) {
return '';
}
return Forms_Formatter::get_form_code( $form->getHtml() );
}
Code file location:
cleverreach-wp/cleverreach-wp/Components/class-shortcode-handler.php
Conclusion
Now that you’ve learned how to embed the CleverReach® WP Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply