Created
April 2, 2022 20:37
-
-
Save jswebschmiede/7ce9f6de4b3d882be6a4b8a871753abf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Load an inline SVG. | |
* | |
* @param string $filename The filename of the SVG you want to load. | |
* | |
* @return string The content of the SVG you want to load. | |
*/ | |
function load_inline_svg( $filename ) { | |
// Add the path to your SVG directory inside your theme. | |
$svg_path = '/images/svgs/'; | |
// Check the SVG file exists | |
if ( file_exists( get_stylesheet_directory() . $svg_path . $filename ) ) { | |
// Load and return the contents of the file | |
return file_get_contents( get_stylesheet_directory_uri() . $svg_path . $filename ); | |
} | |
// Return a blank string if we can't find the file. | |
return ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment