Lead Conversion
WordPress Gutenberg block for smart lead generation.
by The WordPress Contributors · github.com/alexphex/lead-conversion-block
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/alexphex/lead-conversion-block/archive/refs/heads/main.zipLead Conversion Block for WordPress
A lightweight Gutenberg block designed for lead generation. It allows creators to build opt-in forms or call-to-action buttons with advanced display logic, storing all submissions as Custom Post Types (CPT) within WordPress via a secure REST API.
🚀 Key Features Custom Gutenberg Block: Built using the modern React-based WordPress Block API.
Smart Display Logic: * Delay: Show the block after a specified number of seconds.
UTM Tracking: Option to display the block only if utm_source is present in the URL.
Referrer Check: Hide the block for internal navigation to reduce intrusiveness.
Frequency Control: Uses localStorage to limit displays (e.g., show once every 30 days per user).
Lead Management (CPT): Submissions are stored in a custom "Leads" menu in the WordPress dashboard, not just sent via email.
REST API Integration: Handles form submissions asynchronously for a seamless user experience.
Responsive Design: Mobile-ready styles built with SCSS.
🛠 Tech Stack Frontend: React (Gutenberg Block Editor), Vanilla JS (Frontend Logic), SCSS.
Backend: PHP, WordPress REST API, Custom Post Types (CPT).
Data Persistence: WordPress Database (Post Meta), Browser LocalStorage.
📂 Project Structure /src: React components and block logic for the editor.
view.js: Lightweight vanilla JS for frontend interactions and display conditions.
render.php: Server-side rendering for the block (SEO friendly).
lead-conversion.php: Core plugin file, REST API registration, and CPT setup.
style.scss: Modular styles for both inline forms and modal popups.
🔧 Installation & Setup Clone this repository into your /wp-content/plugins/ directory.
Run npm install to install dependencies.
Run npm run build to compile the block assets.
Activate the plugin through the WordPress 'Plugins' menu.
Find the "Lead Conversion" block in the Gutenberg editor.
🔒 Security Measures Data Sanitization: All inputs are cleaned using sanitize_email, sanitize_title, and esc_url_raw before database entry.
Output Escaping: Secure data rendering using esc_html, esc_attr, and wp_kses_post.
REST API Validation: Strict argument validation and permission callbacks for API endpoints.