Digital experiences for all disciplines
New Landing › How can we help? › Themeforest Theme Support › Uplift › Updating SVG Icons
New Landing › How can we help? › Themeforest Theme Support › Uplift › Updating SVG Icons
- This topic has 39 replies, 8 voices, and was last updated 7 years by Swift Ideas – Ed.
-
Posted in: Uplift
-
October 3, 2016 at 7:11 pm #294249
Great, will update there.
November 11, 2016 at 5:36 pm #301568Ed – I’m attempting to implement this code as a fallback for the other method (discussed here: http://www.swiftideas.com/forums/topic/additional-nucleo-icons/#post-301515) which isn’t yet working either. With your code as-is, I was able to get the icons to appear (as outlined down arrows) in the svg list. However, the icons did not appear on the front end. There is just an empty space.
Update: I noticed your code utilized spb_outline_svg_icons, but i’m adding colored icons, so I swapped that bit with spb_coloured_svg_icons – which isn’t adding anything to the icon list. Thoughts?
November 14, 2016 at 1:43 pm #301798Did you use the updated code?
/* ADD PAGE BUILDER SVG ICONS ================================================== */ if ( !function_exists( 'spb_child_theme_svg_icons' ) ) { function spb_child_theme_svg_icons( $svg_icons ) { if ( !$svg_icons ) { $svg_icons = array(); } // Check if we can access files if ( !function_exists('glob') ) { return $svg_icons; } // Path to directory to scan $folder = '/swift-builder-icons/svg/'; $directory = get_stylesheet_directory() . $folder; $uri = get_stylesheet_directory_uri() . $folder; // Get all svg files $svgs = glob($directory . "*.svg"); // If no files, return if ( empty($svgs) ) { return; } // Add each icon to array foreach($svgs as $svg) { $svg = basename($svg); $key = $uri . $svg; if ( !array_key_exists( $key, $svg_icons ) ) { $svg_icons[ $key ] = $svg; } } // Return array return $svg_icons; } add_filter( 'spb_svg_icons_list', 'spb_child_theme_svg_icons' ); }
November 14, 2016 at 5:55 pm #301854David – I just added the following line:
if ( !$svg_icons ) { $svg_icons = array(); }
Unfortunately I still get the word “Array” in the svg icon list.
Here’s my entire function:
/* ADD PAGE BUILDER SVG ICONS ================================================== */ if ( !function_exists( 'spb_child_theme_svg_icons' ) ) { function spb_child_theme_svg_icons( $svg_icons ) { if ( !$svg_icons ) { $svg_icons = array(); } // Check if we can access files if ( !function_exists('glob') ) { return $svg_icons; } // Path to directory to scan $folder = '/swift-builder-icons/svg/'; $directory = get_stylesheet_directory() . $folder; $uri = get_stylesheet_directory_uri() . $folder; // Get all svg files $svgs = glob($directory . "*.svg"); // If no files, return if ( empty($svgs) ) { return; } // Add each icon to array foreach($svgs as $svg) { $svg = basename($svg); $key = $uri . $svg; if ( !array_key_exists( $key, $svg_icons ) ) { $svg_icons[ $key ] = $svg; } } // Return array return $svg_icons; } add_filter( 'spb_svg_icons_list', 'spb_child_theme_svg_icons' ); }
Thoughts?
November 16, 2016 at 7:16 pm #302232@WEswift Can you add your FTP details and a WP login.
– David.
November 16, 2016 at 8:29 pm #302251This reply has been marked as private.November 21, 2016 at 12:08 pm #302698Thanks for your patience, I have been looking into this but will need to check with Ed also this am.
– David.
November 21, 2016 at 4:21 pm #302784David – thanks for keeping this going. It’s much appreciated. Keep us posted. -Paul
November 21, 2016 at 4:36 pm #302786No problem. Let’s wait for Ed reply.
-Rui
November 21, 2016 at 11:37 pm #302894Please try this code, it’s modified and tested on Uplift:
/* ADD PAGE BUILDER SVG ICONS ================================================== */ if ( !function_exists( 'spb_child_theme_svg_icons' ) ) { function spb_child_theme_svg_icons( $svg_icons ) { if ( !$svg_icons ) { $svg_icons = array(); } // Check if we can access files if ( !function_exists('glob') ) { return $svg_icons; } // Path to directory to scan $folder = '/swift-builder-icons/svg/'; $directory = get_stylesheet_directory() . $folder; $uri = get_stylesheet_directory_uri() . $folder; // Get all svg files $svgs = glob($directory . "*.svg"); // If no files, return if ( empty($svgs) ) { return; } // Add each icon to array foreach($svgs as $svg) { $svg = basename($svg); $key = $uri . $svg; if ( !array_key_exists( $key, $svg_icons ) ) { $svg_icons[ $key ] = $svg; } } // Output $svg_icon_output = ""; foreach ( $svg_icons as $icon => $name ) { $svg_icon_output .= '<li class="svg-icon" data-icon="'.$name.'" data-path="'.$icon.'"><i class="svg-icon-picker-item" style="background-image: url('.$icon.');"></i></li>'; } return $svg_icon_output; } add_filter( 'spb_svg_icons_list', 'spb_child_theme_svg_icons' ); }
– Ed
-
Posted in: Uplift
You must be logged in and have valid license to reply to this topic.