Adding a social icon via custom function?
-
So, I was trying to see whether or not I could use this solution in another theme’s support forum to add a “site” icon to Seedlet’s social icons stuff, via a custom function using the Code Snippets plugin.
I gather there’s not an exact 1:1 correlation here in approaches (child theme function.php vs. Code Snippets), but I’m stuck on figuring out if there’s a way to make this work.
I’ve been using
add_action('after_setup_theme', 'extend_icons_array');
to avoid an error where the Seedlet_SVG_Icons isn’t found, but then even if I require that class file in the function, it then errors out saying the class is already in use and can’t be declared.What am I (possibly very obviously to actual coders) missing here?
Thanks. For reference, below is the current version that’s barfing.
function extend_icons_array ($arr_parent, $arr_added) { require(get_template_directory( __FILE__ ).'/classes/class-seedlet-svg-icons.php'); foreach ($arr_added as $key => $value) { $arr_parent[$key] = $value; } return ($arr_parent); } $more_ui_icons = array(); $more_social_icons_map = array( 'site' => array( 'slow.dog', ), ); $more_social_icons = array( 'site' => '<svg viewBox="0 0 24 24" version="1.1" xmlns="https://www.w3.org/2000/svg"><path fill="currentColor" d="M9 0a9 9 0 1 0 0 18A9 9 0 0 0 9 0Zm3.46 11.95c0 1.47-.8 3.3-4.06 4.7c.3-4.17-2.52-3.69-3.2-5A3.25 3.25 0 0 1 7 9.1a8.49 8.49 0 0 1-4.18-2c.05.47.279.904.64 1.21a4.18 4.18 0 0 1-1.94-1.5a7.94 7.94 0 0 1 7.25-5.63c-.84 1.38-1.5 4.13 0 5.57C7.23 7 6.26 5 5.41 5.79c-1.13 1.06.33 2.51 3.42 3.08c3.29.59 3.66 1.58 3.63 3.08Zm1.34-4c-.32-1.11.62-2.23 1.69-3.14a7.27 7.27 0 0 1 .84 6.68c-.77-1.89-2.17-2.32-2.53-3.57v.03Z"/></svg>' ); Seedlet_SVG_Icons::$ui_icons = extend_icons_array(Seedlet_SVG_Icons::$ui_icons, $more_ui_icons); Seedlet_SVG_Icons::$social_icons_map= extend_icons_array(Seedlet_SVG_Icons::$social_icons_map, $more_social_icons_map); Seedlet_SVG_Icons::$social_icons = extend_icons_array(Seedlet_SVG_Icons::$social_icons, $more_social_icons); add_action('after_setup_theme', 'extend_icons_array');
- The topic ‘Adding a social icon via custom function?’ is closed to new replies.