/**
 * Conditionally replace 'the_content'.
 *
 * Replaces the_content() if the post_type being displayed is one that would
 * normally be handled by BuddyPress, but proper single page templates do not
 * exist in the currently active theme.
 *
 * @since BuddyPress (1.7.0)
 *
 * @param string $content Original post content.
 * @return string $content Post content, potentially modified.
 */
function bp_replace_the_content($content = '')
{
    // Bail if not the main loop where theme compat is happening
    if (!bp_do_theme_compat()) {
        return $content;
    }
    // Set theme compat to false early, to avoid recursion from nested calls to
    // the_content() that execute before theme compat has unhooked itself.
    bp_set_theme_compat_active(false);
    // Do we have new content to replace the old content?
    $new_content = apply_filters('bp_replace_the_content', $content);
    // Juggle the content around and try to prevent unsightly comments
    if (!empty($new_content) && $new_content !== $content) {
        // Set the content to be the new content
        $content = $new_content;
        // Clean up after ourselves
        unset($new_content);
        // Reset the $post global
        wp_reset_postdata();
    }
    // Return possibly hi-jacked content
    return $content;
}
/**
 * Conditionally replace 'the_content'.
 *
 * Replaces the_content() if the post_type being displayed is one that would
 * normally be handled by BuddyPress, but proper single page templates do not
 * exist in the currently active theme.
 *
 * @since 1.7.0
 *
 * @param string $content Original post content.
 * @return string $content Post content, potentially modified.
 */
function bp_replace_the_content($content = '')
{
    // Bail if not the main loop where theme compat is happening.
    if (!bp_do_theme_compat()) {
        return $content;
    }
    // Set theme compat to false early, to avoid recursion from nested calls to
    // the_content() that execute before theme compat has unhooked itself.
    bp_set_theme_compat_active(false);
    /**
     * Filters the content to replace in the post.
     *
     * @since 1.7.0
     *
     * @param string $content Original post content.
     */
    $new_content = apply_filters('bp_replace_the_content', $content);
    // Juggle the content around and try to prevent unsightly comments.
    if (!empty($new_content) && $new_content !== $content) {
        // Set the content to be the new content.
        $content = $new_content;
        // Clean up after ourselves.
        unset($new_content);
        // Reset the $post global.
        wp_reset_postdata();
    }
    // Return possibly hi-jacked content.
    return $content;
}