wp_maybe_load_embeds

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

WordPress Version: 5.6

/**
 * Determines if default embed handlers should be loaded.
 *
 * Checks to make sure that the embeds library hasn't already been loaded. If
 * it hasn't, then it will load the embeds library.
 *
 * @since 2.9.0
 *
 * @see wp_embed_register_handler()
 */
function wp_maybe_load_embeds()
{
    /**
     * Filters whether to load the default embed handlers.
     *
     * Returning a falsey value will prevent loading the default embed handlers.
     *
     * @since 2.9.0
     *
     * @param bool $maybe_load_embeds Whether to load the embeds library. Default true.
     */
    if (!apply_filters('load_default_embeds', true)) {
        return;
    }
    wp_embed_register_handler('youtube_embed_url', '#https?://(www.)?youtube\.com/(?:v|embed)/([^/]+)#i', 'wp_embed_handler_youtube');
    /**
     * Filters the audio embed handler callback.
     *
     * @since 3.6.0
     *
     * @param callable $handler Audio embed handler callback function.
     */
    wp_embed_register_handler('audio', '#^https?://.+?\.(' . implode('|', wp_get_audio_extensions()) . ')$#i', apply_filters('wp_audio_embed_handler', 'wp_embed_handler_audio'), 9999);
    /**
     * Filters the video embed handler callback.
     *
     * @since 3.6.0
     *
     * @param callable $handler Video embed handler callback function.
     */
    wp_embed_register_handler('video', '#^https?://.+?\.(' . implode('|', wp_get_video_extensions()) . ')$#i', apply_filters('wp_video_embed_handler', 'wp_embed_handler_video'), 9999);
}

WordPress Version: 4.6

/**
 * Determines if default embed handlers should be loaded.
 *
 * Checks to make sure that the embeds library hasn't already been loaded. If
 * it hasn't, then it will load the embeds library.
 *
 * @since 2.9.0
 *
 * @see wp_embed_register_handler()
 */
function wp_maybe_load_embeds()
{
    /**
     * Filters whether to load the default embed handlers.
     *
     * Returning a falsey value will prevent loading the default embed handlers.
     *
     * @since 2.9.0
     *
     * @param bool $maybe_load_embeds Whether to load the embeds library. Default true.
     */
    if (!apply_filters('load_default_embeds', true)) {
        return;
    }
    wp_embed_register_handler('youtube_embed_url', '#https?://(www.)?youtube\.com/(?:v|embed)/([^/]+)#i', 'wp_embed_handler_youtube');
    /**
     * Filters the audio embed handler callback.
     *
     * @since 3.6.0
     *
     * @param callable $handler Audio embed handler callback function.
     */
    wp_embed_register_handler('audio', '#^https?://.+?\.(' . join('|', wp_get_audio_extensions()) . ')$#i', apply_filters('wp_audio_embed_handler', 'wp_embed_handler_audio'), 9999);
    /**
     * Filters the video embed handler callback.
     *
     * @since 3.6.0
     *
     * @param callable $handler Video embed handler callback function.
     */
    wp_embed_register_handler('video', '#^https?://.+?\.(' . join('|', wp_get_video_extensions()) . ')$#i', apply_filters('wp_video_embed_handler', 'wp_embed_handler_video'), 9999);
}

WordPress Version: 4.4

/**
 * Determines if default embed handlers should be loaded.
 *
 * Checks to make sure that the embeds library hasn't already been loaded. If
 * it hasn't, then it will load the embeds library.
 *
 * @since 2.9.0
 *
 * @see wp_embed_register_handler()
 */
function wp_maybe_load_embeds()
{
    /**
     * Filter whether to load the default embed handlers.
     *
     * Returning a falsey value will prevent loading the default embed handlers.
     *
     * @since 2.9.0
     *
     * @param bool $maybe_load_embeds Whether to load the embeds library. Default true.
     */
    if (!apply_filters('load_default_embeds', true)) {
        return;
    }
    wp_embed_register_handler('youtube_embed_url', '#https?://(www.)?youtube\.com/(?:v|embed)/([^/]+)#i', 'wp_embed_handler_youtube');
    wp_embed_register_handler('googlevideo', '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo');
    /**
     * Filter the audio embed handler callback.
     *
     * @since 3.6.0
     *
     * @param callable $handler Audio embed handler callback function.
     */
    wp_embed_register_handler('audio', '#^https?://.+?\.(' . join('|', wp_get_audio_extensions()) . ')$#i', apply_filters('wp_audio_embed_handler', 'wp_embed_handler_audio'), 9999);
    /**
     * Filter the video embed handler callback.
     *
     * @since 3.6.0
     *
     * @param callable $handler Video embed handler callback function.
     */
    wp_embed_register_handler('video', '#^https?://.+?\.(' . join('|', wp_get_video_extensions()) . ')$#i', apply_filters('wp_video_embed_handler', 'wp_embed_handler_video'), 9999);
}

WordPress Version: 4.3

/**
 * Determines if default embed handlers should be loaded.
 *
 * Checks to make sure that the embeds library hasn't already been loaded. If
 * it hasn't, then it will load the embeds library.
 *
 * @since 2.9.0
 *
 * @see wp_embed_register_handler()
 */
function wp_maybe_load_embeds()
{
    /**
     * Filter whether to load the default embed handlers.
     *
     * Returning a falsey value will prevent loading the default embed handlers.
     *
     * @since 2.9.0
     *
     * @param bool $maybe_load_embeds Whether to load the embeds library. Default true.
     */
    if (!apply_filters('load_default_embeds', true)) {
        return;
    }
    wp_embed_register_handler('youtube_embed_url', '#https?://(www.)?youtube\.com/(?:v|embed)/([^/]+)#i', 'wp_embed_handler_youtube');
    wp_embed_register_handler('googlevideo', '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo');
    /**
     * Filter the audio embed handler callback.
     *
     * @since 3.6.0
     *
     * @param callback $handler Audio embed handler callback function.
     */
    wp_embed_register_handler('audio', '#^https?://.+?\.(' . join('|', wp_get_audio_extensions()) . ')$#i', apply_filters('wp_audio_embed_handler', 'wp_embed_handler_audio'), 9999);
    /**
     * Filter the video embed handler callback.
     *
     * @since 3.6.0
     *
     * @param callback $handler Video embed handler callback function.
     */
    wp_embed_register_handler('video', '#^https?://.+?\.(' . join('|', wp_get_video_extensions()) . ')$#i', apply_filters('wp_video_embed_handler', 'wp_embed_handler_video'), 9999);
}

WordPress Version: 4.2

/**
 * Determines if default embed handlers should be loaded.
 *
 * Checks to make sure that the embeds library hasn't already been loaded. If
 * it hasn't, then it will load the embeds library.
 *
 * @since 2.9.0
 *
 * @see wp_embed_register_handler()
 */
function wp_maybe_load_embeds()
{
    /**
     * Filter whether to load the default embed handlers.
     *
     * Returning a falsey value will prevent loading the default embed handlers.
     *
     * @since 2.9.0
     *
     * @param bool $maybe_load_embeds Whether to load the embeds library. Default true.
     */
    if (!apply_filters('load_default_embeds', true)) {
        return;
    }
    wp_embed_register_handler('youtube_embed_url', '#https?://(www.)?youtube\.com/embed/([^/]+)#i', 'wp_embed_handler_youtube');
    wp_embed_register_handler('googlevideo', '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo');
    /**
     * Filter the audio embed handler callback.
     *
     * @since 3.6.0
     *
     * @param callback $handler Audio embed handler callback function.
     */
    wp_embed_register_handler('audio', '#^https?://.+?\.(' . join('|', wp_get_audio_extensions()) . ')$#i', apply_filters('wp_audio_embed_handler', 'wp_embed_handler_audio'), 9999);
    /**
     * Filter the video embed handler callback.
     *
     * @since 3.6.0
     *
     * @param callback $handler Video embed handler callback function.
     */
    wp_embed_register_handler('video', '#^https?://.+?\.(' . join('|', wp_get_video_extensions()) . ')$#i', apply_filters('wp_video_embed_handler', 'wp_embed_handler_video'), 9999);
}

WordPress Version: 4.0

/**
 * Determines if default embed handlers should be loaded.
 *
 * Checks to make sure that the embeds library hasn't already been loaded. If
 * it hasn't, then it will load the embeds library.
 *
 * @since 2.9.0
 */
function wp_maybe_load_embeds()
{
    /**
     * Filter whether to load the default embed handlers.
     *
     * Returning a falsey value will prevent loading the default embed handlers.
     *
     * @since 2.9.0
     *
     * @param bool $maybe_load_embeds Whether to load the embeds library. Default true.
     */
    if (!apply_filters('load_default_embeds', true)) {
        return;
    }
    wp_embed_register_handler('youtube_embed_url', '#https?://(www.)?youtube\.com/embed/([^/]+)#i', 'wp_embed_handler_youtube');
    wp_embed_register_handler('googlevideo', '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo');
    /**
     * Filter the audio embed handler callback.
     *
     * @since 3.6.0
     *
     * @param callback $handler Audio embed handler callback function.
     */
    wp_embed_register_handler('audio', '#^https?://.+?\.(' . join('|', wp_get_audio_extensions()) . ')$#i', apply_filters('wp_audio_embed_handler', 'wp_embed_handler_audio'), 9999);
    /**
     * Filter the video embed handler callback.
     *
     * @since 3.6.0
     *
     * @param callback $handler Video embed handler callback function.
     */
    wp_embed_register_handler('video', '#^https?://.+?\.(' . join('|', wp_get_video_extensions()) . ')$#i', apply_filters('wp_video_embed_handler', 'wp_embed_handler_video'), 9999);
}

WordPress Version: 3.9

/**
 * Determines if default embed handlers should be loaded.
 *
 * Checks to make sure that the embeds library hasn't already been loaded. If
 * it hasn't, then it will load the embeds library.
 *
 * @since 2.9.0
 */
function wp_maybe_load_embeds()
{
    /**
     * Filter whether to load the default embed handlers.
     *
     * Returning a falsey value will prevent loading the default embed handlers.
     *
     * @since 2.9.0
     *
     * @param bool $maybe_load_embeds Whether to load the embeds library. Default true.
     */
    if (!apply_filters('load_default_embeds', true)) {
        return;
    }
    wp_embed_register_handler('googlevideo', '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo');
    /**
     * Filter the audio embed handler callback.
     *
     * @since 3.6.0
     *
     * @param callback $handler Audio embed handler callback function.
     */
    wp_embed_register_handler('audio', '#^https?://.+?\.(' . join('|', wp_get_audio_extensions()) . ')$#i', apply_filters('wp_audio_embed_handler', 'wp_embed_handler_audio'), 9999);
    /**
     * Filter the video embed handler callback.
     *
     * @since 3.6.0
     *
     * @param callback $handler Video embed handler callback function.
     */
    wp_embed_register_handler('video', '#^https?://.+?\.(' . join('|', wp_get_video_extensions()) . ')$#i', apply_filters('wp_video_embed_handler', 'wp_embed_handler_video'), 9999);
}

WordPress Version: 3.7

/**
 * Determines if default embed handlers should be loaded.
 *
 * Checks to make sure that the embeds library hasn't already been loaded. If
 * it hasn't, then it will load the embeds library.
 *
 * @since 2.9.0
 */
function wp_maybe_load_embeds()
{
    if (!apply_filters('load_default_embeds', true)) {
        return;
    }
    wp_embed_register_handler('googlevideo', '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo');
    wp_embed_register_handler('audio', '#^https?://.+?\.(' . join('|', wp_get_audio_extensions()) . ')$#i', apply_filters('wp_audio_embed_handler', 'wp_embed_handler_audio'), 9999);
    wp_embed_register_handler('video', '#^https?://.+?\.(' . join('|', wp_get_video_extensions()) . ')$#i', apply_filters('wp_video_embed_handler', 'wp_embed_handler_video'), 9999);
}