The emoji_svg_url WordPress PHP filter allows you to modify the URL where emoji SVG images are hosted.
Usage
add_filter( 'emoji_svg_url', 'your_custom_function' ); function your_custom_function( $url ) { // your custom code here return $url; }
Parameters
$url
(string): The emoji base URL for SVG images.
More information
See WordPress Developer Resources: emoji_svg_url
Examples
Change the emoji SVG URL to use a custom CDN
Change the base URL for emoji SVG images to use a custom Content Delivery Network (CDN).
add_filter( 'emoji_svg_url', 'change_emoji_svg_url_to_custom_cdn' ); function change_emoji_svg_url_to_custom_cdn( $url ) { // Replace the default URL with your custom CDN URL $url = 'https://your-custom-cdn.com/emoji/'; return $url; }
Serve emoji SVG images from your own server
Serve emoji SVG images from a folder within your server.
add_filter( 'emoji_svg_url', 'serve_emoji_svg_from_own_server' ); function serve_emoji_svg_from_own_server( $url ) { // Set the URL to your own server's emoji folder $url = 'https://your-website.com/your-emoji-folder/'; return $url; }
Use a different emoji provider
Use a different emoji provider for SVG images.
add_filter( 'emoji_svg_url', 'use_different_emoji_provider' ); function use_different_emoji_provider( $url ) { // Set the URL to a different emoji provider $url = 'https://another-emoji-provider.com/svg/'; return $url; }
Add a version query to the emoji SVG URL
Add a version query parameter to the emoji SVG URL for cache busting.
add_filter( 'emoji_svg_url', 'add_version_query_to_emoji_svg_url' ); function add_version_query_to_emoji_svg_url( $url ) { // Add a version query parameter for cache busting $url = add_query_arg( 'v', '1.0.0', $url ); return $url; }
Conditionally change the emoji SVG URL
Change the emoji SVG URL based on the user’s role.
add_filter( 'emoji_svg_url', 'conditionally_change_emoji_svg_url' ); function conditionally_change_emoji_svg_url( $url ) { // Check if the current user is an administrator if ( current_user_can( 'manage_options' ) ) { // Set the URL to a custom emoji folder for administrators $url = 'https://your-website.com/admin-emoji-folder/'; } return $url; }