Skip to content

Commit

Permalink
#8 : strip useless tags when parsing library's svg
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximeCulea committed Nov 19, 2018
1 parent eef91ab commit dd53284
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion fields/acf-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,18 @@ public function parse_svg() {
return false;
}

/**
* Get the allowed tags to parse icon's ids
*
* @param string $allowed_tags : Passed directly to strip_tags
*
* @author david-treblig
* @since 2.0.1
*
* @return string
*/
$allowed_tags = apply_filters( 'acf_svg_icon_svg_parse_tags', '<symbol><g>' );

$out = array();
foreach ( $files as $file ) {
if ( ! is_file( $file['file'] ) ) {
Expand All @@ -149,7 +161,7 @@ public function parse_svg() {
} else {
// If not extract them from the CSS file.
$contents = file_get_contents( $file['file'] );
preg_match_all( '/id="(\S+)"/m', $contents, $svg );
preg_match_all( '/id="(\S+)"/m', strip_tags( $contents, $allowed_tags ), $svg );

foreach ( $svg[1] as $id ) {
$id = sanitize_title( $id );
Expand Down

0 comments on commit dd53284

Please sign in to comment.