The enqueue_embed_scripts WordPress PHP action fires when scripts and styles are enqueued for the embed iframe.
Usage
add_action('enqueue_embed_scripts', 'your_function_name'); function your_function_name() { // your custom code here }
Parameters
This action does not have any parameters.
More information
See WordPress Developer Resources: enqueue_embed_scripts
Examples
Add a Custom CSS File for Embedded Content
This example enqueues a custom CSS file to style embedded content.
add_action('enqueue_embed_scripts', 'enqueue_custom_embed_css'); function enqueue_custom_embed_css() { wp_enqueue_style('custom-embed-css', get_stylesheet_directory_uri() . '/css/custom-embed.css'); }
Add a Custom JavaScript File for Embedded Content
This example enqueues a custom JavaScript file for embedded content.
add_action('enqueue_embed_scripts', 'enqueue_custom_embed_js'); function enqueue_custom_embed_js() { wp_enqueue_script('custom-embed-js', get_template_directory_uri() . '/js/custom-embed.js', array(), '1.0.0', true); }
Deregister Default WordPress Embed Script
This example removes the default WordPress embed script.
add_action('enqueue_embed_scripts', 'remove_wp_embed_script'); function remove_wp_embed_script() { wp_deregister_script('wp-embed'); }
Add Google Fonts to Embedded Content
This example enqueues Google Fonts for embedded content.
add_action('enqueue_embed_scripts', 'enqueue_google_fonts_embed'); function enqueue_google_fonts_embed() { wp_enqueue_style('google-fonts', 'https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap', false); }
Add Custom Inline CSS for Embedded Content
This example adds custom inline CSS to style embedded content.
add_action('enqueue_embed_scripts', 'add_custom_embed_inline_css'); function add_custom_embed_inline_css() { $custom_css = " .wp-embed { font-family: 'Roboto', sans-serif; background-color: #f8f8f8; }"; wp_add_inline_style('wp-embed', $custom_css); }