Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter to allow adding single files (that aren't sprites) #18

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
height:40px;
margin-right: 10px;
vertical-align: middle;
fill: currentColor;
stroke: currentColor;
color: black;
}

.select2-selection svg,
Expand All @@ -14,6 +17,9 @@
margin-top: 3px;
float: left;
size: 2px;
fill: currentColor;
stroke: currentColor;
color: black;
}

.acf_svg__span {
Expand Down
2 changes: 1 addition & 1 deletion assets/css/style.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions fields/acf-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public function get_all_svg_files() {
* @since 2.0.0
*/
$media_svg_files = $this->get_medias_svg();
$media_svg_files = apply_filters( 'acf_svg_icon_wp_media_svgs' , $media_svg_files);

/**
* The path to the svg file.
Expand Down Expand Up @@ -298,11 +299,14 @@ public function input_admin_enqueue_scripts() {
// Min version ?
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG === true ? '' : '.min';

wp_localize_script( 'acf-input-svg-icon', 'svg_icon_format_data', $this->parse_svg() );
wp_register_style( 'acf-input-svg-icon', ACF_SVG_ICON_URL . 'assets/css/style' . $suffix . '.css', array( 'select2' ), ACF_SVG_ICON_VER );

wp_enqueue_script( 'acf-input-svg-icon' );
wp_enqueue_style( 'acf-input-svg-icon' );
// Only enqueue if we find svgs
if($files = $this->parse_svg()) {
wp_localize_script( 'acf-input-svg-icon', 'svg_icon_format_data', $this->parse_svg() );
wp_register_style( 'acf-input-svg-icon', ACF_SVG_ICON_URL . 'assets/css/style' . $suffix . '.css', array( 'select2' ), ACF_SVG_ICON_VER );

wp_enqueue_script( 'acf-input-svg-icon' );
wp_enqueue_style( 'acf-input-svg-icon' );
}
}

/**
Expand Down