source on its own array key, without adding the * both `width` and `height` attributes, since these are added dynamically, * before rendering the SVG code. * * All icons are assumed to have equal width and height, hence the option * to only specify a `$size` parameter in the svg methods. * * @since 1.2.0 */ class Azeria_SVG_Icons { /** * Gets the SVG code for a given icon. * * @since 1.2.0 * @param string $type Icon type. * @param string $icon Icon name. * @param array|string $classes Additional CSS classes * @return null|string */ public static function get_svg( $type = 'ui', $icon = '', $classes = array() ) { switch ( $type ) { case 'ui': $arr = apply_filters( 'azeria_svg_ui_icons', self::$ui_icons ); break; case 'social': $arr = apply_filters( 'azeria_svg_social_icons', self::$social_icons ); break; default: $arr = array(); } $classes = (array) $classes; $classes[] = 'svg-icon'; if ( array_key_exists( $icon, $arr ) ) { $repl = '\s*<', $svg ); // Remove white space between SVG tags. return sprintf( '%2$s', join( ' ', $classes ), $svg ); } return null; } /** * User Interface icons – svg sources. * * @since 1.2.0 * @var array */ static $ui_icons = array( 'arrow-up' => '', 'arrow-left' => '', 'arrow-right' => '', 'arrow-double-left' => '', 'arrow-double-right' => '', 'author' => '', 'time' => '', 'comments' => '', 'categories' => '', 'tags' => '', 'post-sticky' => '', 'post-standard' => '', 'post-image' => '', 'post-gallery' => '', 'post-video' => '', 'post-quote' => '', 'bars' => '', 'close' => '', 'reply' => '', ); /** * Social icons – svg sources. * * @since 1.2.0 * @var array */ static $social_icons = array( 'facebook' => '', 'twitter' => '', 'google-plus' => '', 'instagram' => '', 'pinterest' => '', 'dribbble' => '', ); } /** * Gets the SVG code for a given icon. * * @since 1.2.0 * @param string $icon Icon name. * @param array|string $classes Additional CSS classes * @return null|string */ function azeria_get_icon_svg( $icon = '', $classes = array() ) { return Azeria_SVG_Icons::get_svg( 'ui', $icon, $classes ); } /** * Gets the SVG code for a given icon. * * @since 1.2.0 * @param string $icon Icon name. * @param array|string $classes Additional CSS classes * @return null|string */ function azeria_get_social_icon_svg( $icon = '', $classes = array() ) { return Azeria_SVG_Icons::get_svg( 'social', $icon, $classes ); }