[ label, SVG inner markup ]. * * @return array */ function get_icons() { $icons = array( 'house' => array( 'label' => __( 'House', 'blockmason-core' ), 'svg' => '', ), 'building' => array( 'label' => __( 'Building', 'blockmason-core' ), 'svg' => '', ), 'factory' => array( 'label' => __( 'Industrial', 'blockmason-core' ), 'svg' => '', ), 'roof' => array( 'label' => __( 'Roof', 'blockmason-core' ), 'svg' => '', ), 'drop' => array( 'label' => __( 'Plumbing & bathrooms', 'blockmason-core' ), 'svg' => '', ), 'kitchen' => array( 'label' => __( 'Kitchens', 'blockmason-core' ), 'svg' => '', ), 'roller' => array( 'label' => __( 'Painting & facades', 'blockmason-core' ), 'svg' => '', ), 'bolt' => array( 'label' => __( 'Electrical', 'blockmason-core' ), 'svg' => '', ), 'hard-hat' => array( 'label' => __( 'Hard hat', 'blockmason-core' ), 'svg' => '', ), 'crane' => array( 'label' => __( 'Crane', 'blockmason-core' ), 'svg' => '', ), 'blueprint' => array( 'label' => __( 'Design & planning', 'blockmason-core' ), 'svg' => '', ), 'hammer' => array( 'label' => __( 'Renovation', 'blockmason-core' ), 'svg' => '', ), ); /** * Filters the service icons. * * @param array $icons slug => [ 'label' => string, 'svg' => inner SVG markup ]. */ return apply_filters( 'blockmason_core_icons', $icons ); } /** * Returns an icon as inline SVG, or an empty string. * * @param string $slug Icon slug. * @param int $size Size in pixels. * @return string */ function get_icon_svg( $slug, $size = 48 ) { $icons = get_icons(); if ( empty( $icons[ $slug ] ) ) { return ''; } return sprintf( '', absint( $size ), wp_kses( $icons[ $slug ]['svg'], allowed_svg_tags() ) ); } /** * Allowed SVG child elements for icons. * * @return array */ function allowed_svg_tags() { $common = array( 'd' => true, 'x' => true, 'y' => true, 'width' => true, 'height' => true, 'rx' => true, 'cx' => true, 'cy' => true, 'r' => true, 'points' => true, ); return array( 'path' => $common, 'rect' => $common, 'circle' => $common, 'polyline' => $common, 'line' => array( 'x1' => true, 'y1' => true, 'x2' => true, 'y2' => true, ), ); }