Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions fields/acf-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ function render_field_settings( $field ) {
private function get_svg_file_path() {
return apply_filters( 'acf_svg_icon_filepath', false );
}

/**
* Get the allowed tags to parse icon's ids
* Passed directly to strip_tags
* @link http://php.net/manual/en/function.strip-tags.php
*
* @return string
* @author david-treblig
*/
private function get_allowed_svg_tags() {
return apply_filters( 'acf_svg_icon_svg_parse_tags', '<symbol><g>' );
}


/**
Expand Down Expand Up @@ -106,7 +118,8 @@ public function parse_svg() {

// If not extract them from the CSS file.
$contents = file_get_contents( $file_path );
preg_match_all( '#id="(\S+)"#', $contents, $svg );
$tags = $this->get_allowed_svg_tags();
preg_match_all( '#id="(\S+)"#', strip_tags($contents, $tags), $svg );
array_shift( $svg );

foreach ( $svg[0] as $id ) {
Expand Down Expand Up @@ -197,4 +210,4 @@ function input_admin_enqueue_scripts() {
public function input_admin_footer() {
$this->display_svg();
}
}
}