<?php
/**
 * Force a placeholder display for interactive maps when in the editor
 */
function bw_filter_interactive_map_in_editor($content) {
    // Only affect REST API requests, which include Gutenberg editor operations
    if (!defined('REST_REQUEST') || !REST_REQUEST) {
        return $content;
    }
    
    // Replace the interactive map shortcode with a placeholder
    if (has_shortcode($content, 'interactive_map')) {
        $pattern = '/\\[interactive_map.*?\\](.*?)\\[\\/interactive_map\\]/s';
        $replacement = '[interactive_map] Showing placeholder for map in editor - will display correctly on the published page.';
        $content = preg_replace($pattern, $replacement, $content);
    }
    
    return $content;
}
add_filter('the_content', 'bw_filter_interactive_map_in_editor', 999);
