The icon_dir_uri WordPress PHP Filter allows you to modify the icon directory URI.
Usage
add_filter('icon_dir_uri', 'your_custom_function'); function your_custom_function($uri) { // your custom code here return $uri; }
Parameters
$uri
(string) – Icon directory URI to be modified.
More information
See WordPress Developer Resources: icon_dir_uri
Examples
Change Icon Directory
Change the default icon directory to a custom one.
add_filter('icon_dir_uri', 'change_icon_directory'); function change_icon_directory($uri) { // Change icon directory to a custom one $uri = 'https://example.com/custom-icons/'; return $uri; }
Add CDN URL
Add a CDN URL for the icon directory.
add_filter('icon_dir_uri', 'add_cdn_icon_directory'); function add_cdn_icon_directory($uri) { // Add a CDN URL for the icon directory $uri = 'https://cdn.example.com/icons/'; return $uri; }
Append Version Number
Append a version number to the icon directory URI for cache busting.
add_filter('icon_dir_uri', 'append_version_number'); function append_version_number($uri) { // Append a version number to the icon directory URI $uri .= '?ver=1.0.0'; return $uri; }
Modify Subdirectory
Modify the subdirectory in the icon directory URI.
add_filter('icon_dir_uri', 'modify_subdirectory'); function modify_subdirectory($uri) { // Replace the default subdirectory with a custom one $uri = str_replace('/default-icons/', '/custom-icons/', $uri); return $uri; }
Add Language-specific Icon Directory
Add a language-specific icon directory based on the user’s language.
add_filter('icon_dir_uri', 'add_language_specific_directory'); function add_language_specific_directory($uri) { // Get the user's language $language = get_locale(); // Add a language-specific icon directory $uri = 'https://example.com/icons/' . $language . '/'; return $uri; }
END