/** * Help Yoast SEO analyze Flatsome UX Builder shortcode content * Flatsome stores page content as [shortcodes] in post_content. * strip_shortcodes() removes the content between registered shortcode tags, * so we use regex to just remove the [tag] markers, keeping the text. */ add_filter('wpseo_pre_analysis_post_content', function($content, $post) { if ($post instanceof WP_Post) { $raw_content = $post->post_content; // Also check UX Builder meta $ux_content = get_post_meta($post->ID, '_ux_builder_content', true); if (!empty($ux_content)) { $raw_content = $ux_content; } // Remove shortcode tags and HTML tags, keep text content $text = preg_replace('/\[[^\]]*\]/', '', $raw_content); $text = preg_replace('//', '', $text); $text = wp_strip_all_tags($text, true); $text = html_entity_decode($text, ENT_QUOTES | ENT_HTML5, 'UTF-8'); $text = trim(preg_replace('/\s+/', ' ', $text)); if (!empty($text)) { $content = $text . "\n\n" . $content; } } return $content; }, 10, 2); return $content; }, 10, 2);