Astra_Ext_Adv_Search_Markup::search_icon( $echo = false )

Search icon markup


Description


Parameters

$style

(string) (Required) Search style.


Return

(void|string) Returns or echo search icon HTML markup.


Source

File: addons/advanced-search/classes/class-astra-ext-adv-search-markup.php

		public static function search_icon( $echo = false ) {
			$svg     = '';
			$classes = array(
				'ast-icon',
				'icon-search',
			);
			$icon    = astra_get_option( 'header-search-icon' );

			if ( isset( $icon['type'], $icon['value'] ) ) {
				$type  = $icon['type'];
				$value = $icon['value'];

				if ( $type === 'custom' ) {
					$svg       = do_shortcode( $value );
					$classes[] = 'icon-' . $type;
				} elseif ( is_callable( 'Astra_Builder_UI_Controller::fetch_svg_icon' ) ) {
					$svg       = Astra_Builder_UI_Controller::fetch_svg_icon( $value );
					$classes[] = 'icon-' . $value;
				}
			}

			$svg = $svg ?: Astra_Icons::get_icons( 'search' );
			$svg = sprintf(
				'<span class="%1$s">%2$s</span>',
				implode( ' ', $classes ),
				$svg
			);

			$allowed_svg_args = array(
				'span'  => array( 'class' => array() ),
				'svg'   => array(
					'xmlns:xlink'       => array(),
					'version'           => array(),
					'id'                => array(),
					'x'                 => array(),
					'y'                 => array(),
					'enable-background' => array(),
					'xml:space'         => array(),
					'class'             => array(),
					'aria-hidden'       => array(),
					'aria-labelledby'   => array(),
					'role'              => array(),
					'xmlns'             => array(),
					'width'             => array(),
					'height'            => array(),
					'viewbox'           => array(),
				),
				'g'     => array( 'fill' => array() ),
				'title' => array( 'title' => array() ),
				'path'  => array(
					'd'    => array(),
					'fill' => array(),
				),
			);

			if ( $echo !== true ) {
				return wp_kses( $svg, $allowed_svg_args );
			}
			
			echo wp_kses( $svg, $allowed_svg_args );
		}

Changelog

Changelog
Version Description
4.8.13 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.