From 0a9148d9607a6d9cb40285d17a615b6293ffd384 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 18 Mar 2020 11:22:20 -0400 Subject: [PATCH 1/4] Add filter to allow adding single files (that aren't sprites) coming from theme --- fields/acf-base.php | 1 + 1 file changed, 1 insertion(+) diff --git a/fields/acf-base.php b/fields/acf-base.php index 6f36a46..46d33a0 100644 --- a/fields/acf-base.php +++ b/fields/acf-base.php @@ -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. From 3099916a26fc84fb2dc68ef466fa9b5d519eb046 Mon Sep 17 00:00:00 2001 From: davidwebca Date: Sat, 10 Apr 2021 12:39:56 -0400 Subject: [PATCH 2/4] Only enqueue if we actually find svgs This commit fixes crashes with wp_localize_script that was introduced in wordpress v 5.7 --- fields/acf-base.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/fields/acf-base.php b/fields/acf-base.php index 46d33a0..c196704 100644 --- a/fields/acf-base.php +++ b/fields/acf-base.php @@ -299,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' ); + } } /** From cc4abd90d8e388ba9b73b1235198c387d6c4b99e Mon Sep 17 00:00:00 2001 From: David Lapointe Date: Fri, 16 Jul 2021 14:25:50 -0400 Subject: [PATCH 3/4] Add sensible defaults for fill and stroke through CSS to avoid invisible icons while not removing existing colorized svgs --- assets/css/style.css | 3 +++ assets/css/style.min.css | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/assets/css/style.css b/assets/css/style.css index 34c5321..66e2767 100755 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -4,6 +4,9 @@ height:40px; margin-right: 10px; vertical-align: middle; + fill: currentColor; + stroke: currentColor; + color: black; } .select2-selection svg, diff --git a/assets/css/style.min.css b/assets/css/style.min.css index 5e55734..ab53b42 100755 --- a/assets/css/style.min.css +++ b/assets/css/style.min.css @@ -1 +1 @@ -.acf_svg__icon,.select2-results svg{width:40px;height:40px;margin-right:10px;vertical-align:middle}.acf_svg__icon.small,.select2-selection svg{width:25px;height:19px;margin-right:10px;margin-top:3px;float:left;size:2px}.acf_svg__span{font-size:1.2em} \ No newline at end of file +.acf_svg__icon,.select2-results svg{width:40px;height:40px;margin-right:10px;vertical-align:middle;fill:currentColor;stroke:currentColor;color:#000}.acf_svg__icon.small,.select2-selection svg{width:25px;height:19px;margin-right:10px;margin-top:3px;float:left;size:2px}.acf_svg__span{font-size:1.2em} \ No newline at end of file From b7afcf90cbba6ea3594f983cee207bae6f827b1b Mon Sep 17 00:00:00 2001 From: David Lapointe Date: Fri, 16 Jul 2021 14:39:25 -0400 Subject: [PATCH 4/4] Sensible defaults for fill and stroke missing from selected icon --- assets/css/style.css | 3 +++ assets/css/style.min.css | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/assets/css/style.css b/assets/css/style.css index 66e2767..df77e71 100755 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -17,6 +17,9 @@ margin-top: 3px; float: left; size: 2px; + fill: currentColor; + stroke: currentColor; + color: black; } .acf_svg__span { diff --git a/assets/css/style.min.css b/assets/css/style.min.css index ab53b42..42c85a5 100755 --- a/assets/css/style.min.css +++ b/assets/css/style.min.css @@ -1 +1 @@ -.acf_svg__icon,.select2-results svg{width:40px;height:40px;margin-right:10px;vertical-align:middle;fill:currentColor;stroke:currentColor;color:#000}.acf_svg__icon.small,.select2-selection svg{width:25px;height:19px;margin-right:10px;margin-top:3px;float:left;size:2px}.acf_svg__span{font-size:1.2em} \ No newline at end of file +.acf_svg__icon,.select2-results svg{width:40px;height:40px;margin-right:10px;vertical-align:middle;fill:currentColor;stroke:currentColor;color:#000}.acf_svg__icon.small,.select2-selection svg{width:25px;height:19px;margin-right:10px;margin-top:3px;float:left;size:2px;fill:currentColor;stroke:currentColor;color:#000}.acf_svg__span{font-size:1.2em} \ No newline at end of file