10 events found.
function scan_form_plugins_usage() { if ( ! current_user_can( 'manage_options' ) ) return; if ( ! isset( $_GET['scan_forms'] ) ) return; $results = []; $posts = get_posts([ 'post_type' => 'any', 'post_status' => 'publish', 'posts_per_page' => -1, ]); foreach ( $posts as $post ) { $content = $post->post_content; $found = []; // --- Contact Form 7 --- // CF7 shortcode if ( preg_match_all( '/\[contact-form-7[^\]]*\]/', $content, $matches ) ) { $found['CF7_shortcode'] = $matches[0]; } // CF7 block (Gutenberg) if ( strpos( $content, 'wpcf7/contact-form' ) !== false ) { $found['CF7_block'] = ['block embed detected']; } // --- Gravity Forms --- // GF shortcode if ( preg_match_all( '/\[gravityform[s]?[^\]]*\]/', $content, $matches ) ) { $found['GravityForms_shortcode'] = $matches[0]; } // GF block (Gutenberg) if ( strpos( $content, 'gravityforms/form' ) !== false ) { $found['GravityForms_block'] = ['block embed detected']; } // --- Page Builders --- // Elementor (stored as JSON in postmeta) $elementor_data = get_post_meta( $post->ID, '_elementor_data', true ); if ( $elementor_data ) { if ( strpos( $elementor_data, 'contact-form-7' ) !== false ) { $found['CF7_elementor'] = ['Elementor widget detected']; } if ( strpos( $elementor_data, 'gravityforms' ) !== false ) { $found['GravityForms_elementor'] = ['Elementor widget detected']; } } // Divi (stored as shortcode-style in content) if ( strpos( $content, 'et_pb_contact_form' ) !== false ) { $found['CF7_divi'] = ['Divi module detected']; } if ( preg_match_all( '/\[et_pb_gravity_forms[^\]]*\]/', $content, $matches ) ) { $found['GravityForms_divi'] = $matches[0]; } // Beaver Builder (stored in postmeta) $bb_data = get_post_meta( $post->ID, '_fl_builder_data', true ); if ( $bb_data ) { $bb_serialized = maybe_serialize( $bb_data ); if ( strpos( $bb_serialized, 'contact-form-7' ) !== false ) { $found['CF7_beaver'] = ['Beaver Builder module detected']; } if ( strpos( $bb_serialized, 'gravityforms' ) !== false ) { $found['GravityForms_beaver'] = ['Beaver Builder module detected']; } } if ( ! empty( $found ) ) { $results[] = [ 'title' => $post->post_title, 'url' => get_permalink( $post->ID ), 'forms' => $found, ]; } } // --- Output to error log only --- error_log( '=== Form Plugin Usage Scan ===' ); if ( empty( $results ) ) { error_log( 'No form embeds found.' ); } else { foreach ( $results as $r ) { error_log( '--- ' . $r['title'] . ' | ' . $r['url'] . ' ---' ); foreach ( $r['forms'] as $plugin => $details ) { error_log( ' ' . $plugin . ': ' . implode( ', ', $details ) ); } } } error_log( '=== Scan Complete ===' ); wp_die( 'Scan complete. Check your error log for results.', 'Scan Complete', [ 'response' => 200 ] ); } add_action( 'init', 'scan_form_plugins_usage' );