* Created on: 17/10/2018
*
* @package utilities.php
*/
/**
* Check if we're delivering AMP
*
* @return bool
*/
function neve_is_amp() {
return function_exists( 'is_amp_endpoint' ) && is_amp_endpoint();
}
/**
* Get hooks by location
*
* @return array $hooks - hooks locations and name
*/
function neve_hooks() {
$hooks = array(
'header' => array(
'neve_before_header_hook',
'neve_before_navbar_toggle_hook',
'neve_after_navbar_toggle_hook',
'neve_after_header_hook',
),
'footer' => array(
'neve_before_footer_hook',
'neve_after_footer_hook',
),
);
return apply_filters( 'neve_hooks_list', $hooks );
}
/**
* Cart icon markup.
*
* The changes here might not be visible on front end due to woocommerce cart-fragments.js
* In that case deactivate and reactivate WooCommerce.
*
* @param bool $echo should be echoed.
*
* @return string|null
*/
function neve_cart_icon( $echo = false ) {
$svg = '';
if ( $echo === false ) {
return $svg;
}
echo neve_kses_svg( $svg ); // WPCS: XSS OK.
}
/**
* Search Icon
*
* @param bool $echo should be echoed.
*
* @return string
*/
function neve_search_icon( $echo = false ) {
$svg = '';
if ( $echo === false ) {
return $svg;
}
echo neve_kses_svg( $svg ); // WPCS: XSS OK.
}
/**
* Escape HTML strings containing SVG.
*
* @param string $input the input string.
* @param array $additional_args additional allowed.
*
* @return string
*/
function neve_custom_kses_escape( $input, $additional_args ) {
$kses_defaults = wp_kses_allowed_html( 'post' );
$allowed_tags = array_merge( $kses_defaults, $additional_args );
return wp_kses( $input, $allowed_tags );
}
/**
* Kses svg.
*
* @param string $input input string to escape.
*
* @return string
*/
function neve_kses_svg( $input ) {
$svg_args = array(
'svg' => array(
'class' => true,
'aria-hidden' => true,
'aria-labelledby' => true,
'role' => true,
'xmlns' => true,
'width' => true,
'height' => true,
'viewbox' => true, // <= Must be lower case!
),
'g' => array( 'fill' => true ),
'title' => array( 'title' => true ),
'path' => array(
'd' => true,
'fill' => true,
),
);
return neve_custom_kses_escape( $input, $svg_args );
}