*/
if ( ! function_exists( 'addonify_quick_view_get_button_icons' ) ) {
/**
* Return quick view button icons
*
* @since 1.2.8
*
* @param string $action Icon key.
* @return string|array Icon string if found, else returns the array of icons.
*/
function addonify_quick_view_get_button_icons( $action ) {
$icons = array(
'icon_one' => '',
'icon_two' => '',
'icon_three' => '',
'icon_four' => '',
'icon_five' => '',
'icon_six' => '',
);
// Return specific icon or array.
return array_key_exists( $action, $icons ) ? $icons[ $action ] : $icons;
}
}
if ( ! function_exists( 'addonify_quick_view_get_spinner_icon' ) ) {
/**
* Return the spinner svg icon.
*
* @since 1.2.8
*
* @param string $action Icon key.
* @return string|array Icon string if found, else returns the array of icons.
*/
function addonify_quick_view_get_spinner_icon( $action ) {
$icons = array(
'icon_one' => '',
'icon_two' => '',
'icon_three' => '',
'icon_four' => '',
'icon_five' => '',
'icon_six' => '',
);
// Return specific icon or array.
return array_key_exists( $action, $icons ) ? $icons[ $action ] : $icons;
}
}
if ( ! function_exists( 'addonify_quick_view_sanitize_multi_choices' ) ) {
/**
* Sanitize multiple choices values.
*
* @since 1.0.7
*
* @param array $args Raw values.
* @return array $sanitized_values
*/
function addonify_quick_view_sanitize_multi_choices( $args ) {
if (
is_array( $args['choices'] ) &&
count( $args['choices'] ) &&
is_array( $args['values'] ) &&
count( $args['values'] )
) {
$sanitized_values = array();
foreach ( $args['values'] as $value ) {
if ( array_key_exists( $value, $args['choices'] ) ) {
$sanitized_values[] = $value;
}
}
return $sanitized_values;
}
return array();
}
}
if ( ! function_exists( 'addonify_quick_view_is_mobile' ) ) {
/**
* Check if the device is mobile.
*
* @since 1.1.1
*
* @return boolean
*/
function addonify_quick_view_is_mobile() {
if ( class_exists( '\Detection\MobileDetect' ) ) {
$device_detect = new \Detection\MobileDetect; // phpcs:ignore
return $device_detect->isMobile();
}
}
}
if ( ! function_exists( 'addonify_quick_view_is_tablet' ) ) {
/**
* Check if the device is tablet.
*
* @since 1.1.1
*
* @return boolean
*/
function addonify_quick_view_is_tablet() {
if ( class_exists( '\Detection\MobileDetect' ) ) {
$device_detect = new \Detection\MobileDetect; // phpcs:ignore
return $device_detect->isTablet();
}
}
}
/**
* Sanitizes SVG
*
* @since 1.2.8
* @package Addonify_Quick_View
* @subpackage Addonify_Quick_View/includes/functions
*/
if ( ! function_exists( 'addonify_quick_view_escape_svg' ) ) {
/**
* Sanitizes SVG
*
* @param string $svg SVG code.
* @return string $svg Sanitized SVG code.
*/
function addonify_quick_view_escape_svg( $svg ) {
$allowed_html = 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 wp_kses( $svg, $allowed_html );
}
}