Created
July 4, 2019 01:39
-
-
Save patric-boehner/86eb9320888934b909c454508bbedf31 to your computer and use it in GitHub Desktop.
Include inline SVG files.
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 | |
function pb_load_inline_svg( $filename ) { | |
// Add the path to your SVG directory inside your theme. | |
$svg_path = '/assets/svg/'; | |
$file_end = '.svg'; | |
//Check the SVG file exists | |
if ( ! file_exists( CHILD_DIR . $svg_path . $filename . $file_end ) ) { | |
// Return a blank string if we can't find the file. | |
return ''; | |
} | |
// Load and return the contents of the file | |
return file_get_contents( CHILD_DIR . $svg_path . $filename . $file_end ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment