A lightweight WordPress plugin that enhances JetFormBuilder's submit buttons by allowing users to add icons via custom CSS classes. This plugin dynamically injects icons into the submit buttons in the frontend based on the specified class.
- Allows form creators to specify an icon for each form's submit button using the "Additional CSS Class" field in Gutenberg.
- Supports Font Awesome icons.
- Automatically aligns icons with button text for a clean and professional appearance.
- No external CSS dependencies – all styles are handled inline.
-
In Gutenberg, add a
Submit
block to your JetFormBuilder form. -
In the block's settings (sidebar), find the "Additional CSS Class" field.
-
Add a class in the format
icon-fa-{icon-name}
. For example: -
Save the form and view it on the frontend. The icon will appear before the button text.
-
Open your WordPress theme's
functions.php
file. -
Copy and paste the following snippet:
add_filter('the_content', 'my_custom_icon_in_jetform_button', 20); function my_custom_icon_in_jetform_button($content) { if (preg_match_all('/<button[^>]*class="[^"]*icon-fa-([a-z0-9-]+)/i', $content, $matches)) { foreach ($matches[1] as $icon_name) { $icon_class = 'fa-' . $icon_name; $regex = '/(<button\b[^>]*icon-fa-' . preg_quote($icon_name, '/') . '[^>]*>)(.*?)(<\/button>)/is'; $replacement = '$1<i class="fa ' . $icon_class . '" style="margin-right:5px; vertical-align:middle;"></i>$2$3'; $content = preg_replace($regex, $replacement, $content); } } return $content; }
Install and activate the free plugin Code Snippets from the WordPress plugin repository.
-
In the WordPress admin panel, navigate to Snippets > Add New.
-
Give your snippet a name like "JetFormBuilder Submit Icon Enhancer."
-
Paste the following code into the snippet editor:
add_filter('the_content', 'my_custom_icon_in_jetform_button', 20); function my_custom_icon_in_jetform_button($content) { if (preg_match_all('/<button[^>]*class="[^"]*icon-fa-([a-z0-9-]+)/i', $content, $matches)) { foreach ($matches[1] as $icon_name) { $icon_class = 'fa-' . $icon_name; $regex = '/(<button\b[^>]*icon-fa-' . preg_quote($icon_name, '/') . '[^>]*>)(.*?)(<\/button>)/is'; $replacement = '$1<i class="fa ' . $icon_class . '" style="margin-right:5px; vertical-align:middle;"></i>$2$3'; $content = preg_replace($regex, $replacement, $content); } } return $content; }
-
Set the snippet to "Run Everywhere" and save it.
-
The functionality will now be active on your website.
- Add a
Submit
block to your form in JetFormBuilder. - Specify an icon using the "Additional CSS Class" field in the block settings.
- Save and preview your form on the frontend to see the icon in action.
For a button with the text "Submit" and a paper plane icon:
-
Add the class
icon-fa-paper-plane
in the block settings. -
The resulting button will display the paper plane icon aligned to the left of the "Submit" text.
<button class="jet-form-builder__action-button icon-fa-paper-plane"> <i class="fa fa-paper-plane" style="margin-right:5px; vertical-align:middle;"></i> Submit </button>
Here is a list of 18 popular icons for submit buttons that you can use with this plugin. Simply add the corresponding class icon-fa-{icon-name}
in the "Additional CSS Class" field of the Submit block.
Icon Preview | Icon Name | Font Awesome Class |
---|---|---|
📨 | Paper Plane | fa-paper-plane |
📩 | Envelope | fa-envelope |
✔️ | Check | fa-check |
❌ | Times | fa-times |
➕ | Plus | fa-plus |
➖ | Minus | fa-minus |
⭐ | Star | fa-star |
❤️ | Heart | fa-heart |
🔔 | Bell | fa-bell |
🔗 | Link | fa-link |
📤 | Upload | fa-upload |
🛒 | Cart | fa-shopping-cart |
🔒 | Lock | fa-lock |
🔓 | Unlock | fa-unlock |
📁 | Folder | fa-folder |
📂 | Open Folder | fa-folder-open |
➡️ | Arrow Right | fa-arrow-right |
⬅️ | Arrow Left | fa-arrow-left |
To use the Paper Plane icon for a Submit button:
- Add the class
icon-fa-paper-plane
in the "Additional CSS Class" field. - The resulting button will display the icon 📨 aligned to the left of the button label.
Important Note:
Make sure the Font Awesome library is loaded on your site. If your theme or another plugin doesn't already enqueue it, you can add it by placing the following code in your functions.php
or Code Snippets plugin:
```php
function ensure_font_awesome_loaded() {
if ( ! wp_style_is( 'font-awesome', 'enqueued' ) ) {
wp_enqueue_style(
'font-awesome',
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css',
array(),
'5.15.4'
);
}
}
add_action( 'wp_enqueue_scripts', 'ensure_font_awesome_loaded' );
WordPress: Version 5.8 or higher. JetFormBuilder: Version 2.0 or higher. PHP: Version 7.4 or higher. License This snippet is open-source and licensed under the MIT License. See the LICENSE file for details.
JetFormBuilder – For providing a robust form-building solution. Font Awesome – For the icons.