Selective reCAPTCHA Loader for CF7
Selective reCAPTCHA Loader for CF7 is a performance optimization plugin that intelligently controls when and where Google reCAPTCHA assets are loaded for Contact Form 7 forms. Instead of loading reCAPTCHA on every page, this plugin provides two modes to optimize your site’s performance.
Key Features
🚀 Two Loading Modes: — Selective Mode (Default): Only loads reCAPTCHA on pages that contain Contact Form 7 forms — Global Mode: Always loads reCAPTCHA on all front-end pages (traditional behavior)
🎯 Smart Detection: — Detects CF7 shortcodes in post content — Identifies CF7 blocks in Gutenberg editor — Whitelist-based override for specific pages
⚙️ Advanced Configuration: — Whitelist specific pages by ID, slug, or regex patterns (pages matching the whitelist will always load reCAPTCHA) — Comprehensive filter system for developers
How It Works
The plugin hooks into WordPress’s script enqueuing system with a priority of 120, analyzing each page to determine if Contact Form 7 forms are present. Based on your selected mode and detection results, it either allows or prevents reCAPTCHA assets from loading.
Caching Considerations: — Per-page detection results are cached per request — Cache automatically clears when plugin settings change
Developer Features
Filters:
— selerelo_is_form_page — Modify form page detection
— selerelo_recaptcha_handles — Define which script handles to control
Template Functions:
— selerelo_should_load_recaptcha() — Check if reCAPTCHA will load
— selerelo_is_form_page() — Check if page has forms
— selerelo_get_option() — Get plugin options
Technical Details
Minimum Requirements: — WordPress 6.0 or higher — PHP 7.4 or higher — Contact Form 7 5.8 or higher
Performance Impact: — Minimal overhead: Detection logic is lightweight and cached — Reduces script loading on pages without forms — Can significantly improve page load times on form-free pages
Security: — All user inputs are sanitized and escaped — Uses WordPress nonces for form submissions — Follows WordPress coding standards — No external API calls or tracking
日本語版説明
Selective reCAPTCHA Loader for CF7 は、Contact Form 7 のパフォーマンスを最適化するプラグインです。全ページでreCAPTCHAを読み込む代わりに、フォームがあるページでのみ読み込みます。
主な特徴
2つの読み込みモード: — Selectiveモード(推奨): フォームがあるページのみ読み込み — Globalモード: 全ページでreCAPTCHA読み込み(従来方式)
スマート検出: — ショートコード、Gutenbergブロック内のフォームを検出 — ホワイトリスト機能(ページID、スラッグ、正規表現対応、ホワイトリストに一致したページは必ずreCAPTCHAを読み込みます)
インストール
- プラグインファイルを
/wp-content/plugins/selective-recaptcha-loader/にアップロード - 管理画面の「プラグイン」でプラグインを有効化
- 「設定」→「Selective reCAPTCHA」で設定
- Selectiveモードのまま使用を推奨(ほとんどのサイトに最適)
使い方
Globalモード: 全ページでreCAPTCHAを読み込みます。サイト全体にフォームがある場合に適しています。
Selectiveモード: フォーム検出したページのみreCAPTCHAを読み込みます。最大のパフォーマンス向上が期待できます。
注意事項
キャッシュプラグイン: ほとんどのキャッシュプラグインと互換性があります。検出ロジックはキャッシュ前に実行されます。
