get_post_embed_url

The timeline below displays how wordpress function get_post_embed_url has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Retrieves the URL to embed a specific post in an iframe.
 *
 * @since 4.4.0
 *
 * @param int|WP_Post $post Optional. Post ID or object. Defaults to the current post.
 * @return string|false The post embed URL on success, false if the post doesn't exist.
 */
function get_post_embed_url($post = null)
{
    $post = get_post($post);
    if (!$post) {
        return false;
    }
    $embed_url = trailingslashit(get_permalink($post)) . user_trailingslashit('embed');
    $path_conflict = get_page_by_path(str_replace(home_url(), '', $embed_url), OBJECT, get_post_types(array('public' => true)));
    if (!get_option('permalink_structure') || $path_conflict) {
        $embed_url = add_query_arg(array('embed' => 'true'), get_permalink($post));
    }
    /**
     * Filters the URL to embed a specific post.
     *
     * @since 4.4.0
     *
     * @param string  $embed_url The post embed URL.
     * @param WP_Post $post      The corresponding post object.
     */
    return sanitize_url(apply_filters('post_embed_url', $embed_url, $post));
}

WordPress Version: 4.6

/**
 * Retrieves the URL to embed a specific post in an iframe.
 *
 * @since 4.4.0
 *
 * @param int|WP_Post $post Optional. Post ID or object. Defaults to the current post.
 * @return string|false The post embed URL on success, false if the post doesn't exist.
 */
function get_post_embed_url($post = null)
{
    $post = get_post($post);
    if (!$post) {
        return false;
    }
    $embed_url = trailingslashit(get_permalink($post)) . user_trailingslashit('embed');
    $path_conflict = get_page_by_path(str_replace(home_url(), '', $embed_url), OBJECT, get_post_types(array('public' => true)));
    if (!get_option('permalink_structure') || $path_conflict) {
        $embed_url = add_query_arg(array('embed' => 'true'), get_permalink($post));
    }
    /**
     * Filters the URL to embed a specific post.
     *
     * @since 4.4.0
     *
     * @param string  $embed_url The post embed URL.
     * @param WP_Post $post      The corresponding post object.
     */
    return esc_url_raw(apply_filters('post_embed_url', $embed_url, $post));
}

WordPress Version: 4.5

/**
 * Retrieves the URL to embed a specific post in an iframe.
 *
 * @since 4.4.0
 *
 * @param int|WP_Post $post Optional. Post ID or object. Defaults to the current post.
 * @return string|false The post embed URL on success, false if the post doesn't exist.
 */
function get_post_embed_url($post = null)
{
    $post = get_post($post);
    if (!$post) {
        return false;
    }
    $embed_url = trailingslashit(get_permalink($post)) . user_trailingslashit('embed');
    $path_conflict = get_page_by_path(str_replace(home_url(), '', $embed_url), OBJECT, get_post_types(array('public' => true)));
    if (!get_option('permalink_structure') || $path_conflict) {
        $embed_url = add_query_arg(array('embed' => 'true'), get_permalink($post));
    }
    /**
     * Filter the URL to embed a specific post.
     *
     * @since 4.4.0
     *
     * @param string  $embed_url The post embed URL.
     * @param WP_Post $post      The corresponding post object.
     */
    return esc_url_raw(apply_filters('post_embed_url', $embed_url, $post));
}

WordPress Version: 4.4

/**
 * Retrieves the URL to embed a specific post in an iframe.
 *
 * @since 4.4.0
 *
 * @param int|WP_Post $post Optional. Post ID or object. Defaults to the current post.
 * @return string|false The post embed URL on success, false if the post doesn't exist.
 */
function get_post_embed_url($post = null)
{
    $post = get_post($post);
    if (!$post) {
        return false;
    }
    if (get_option('permalink_structure')) {
        $embed_url = trailingslashit(get_permalink($post)) . user_trailingslashit('embed');
    } else {
        $embed_url = add_query_arg(array('embed' => 'true'), get_permalink($post));
    }
    /**
     * Filter the URL to embed a specific post.
     *
     * @since 4.4.0
     *
     * @param string  $embed_url The post embed URL.
     * @param WP_Post $post      The corresponding post object.
     */
    return esc_url_raw(apply_filters('post_embed_url', $embed_url, $post));
}