*/ if ( ! function_exists( 'addonify_quick_view_get_button_icons' ) ) { /** * Return quick view button icons * * @since 1.2.8 * * @param string $key Icon key. * @return string|array Icon string if found, else returns the array of icons. */ function addonify_quick_view_get_button_icons( $key ) { $icons = array( 'icon_one' => '', 'icon_two' => '', 'icon_three' => '', 'icon_four' => '', 'icon_five' => '', 'icon_six' => '', ); if ( 'all' === $key ) { return $icons; } // Return specific icon or array. return array_key_exists( $key, $icons ) ? $icons[ $key ] : false; } } if ( ! function_exists( 'addonify_quick_view_get_spinner_icon' ) ) { /** * Return the spinner svg icon. * * @since 1.2.8 * * @param string $key Icon key. * @return string|array Icon string if found, else returns the array of icons. */ function addonify_quick_view_get_spinner_icon( $key ) { $icons = array( 'icon_one' => '', 'icon_two' => '', 'icon_three' => '', 'icon_four' => '', 'icon_five' => '', 'icon_six' => ' ', ); if ( 'all' === $key ) { return $icons; } // Return specific icon or array. return array_key_exists( $key, $icons ) ? $icons[ $key ] : false; } } 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 ); } } if ( ! function_exists( 'addonify_quick_view_get_border_styles' ) ) { /** * Get border styles. * * @since 1.2.16 */ function addonify_quick_view_get_border_styles() { return array( 'none' => esc_html__( 'None', 'addonify-quick-view' ), 'solid' => esc_html__( 'Solid', 'addonify-quick-view' ), 'dotted' => esc_html__( 'Dotted', 'addonify-quick-view' ), 'dashed' => esc_html__( 'Dashed', 'addonify-quick-view' ), 'double' => esc_html__( 'Double', 'addonify-quick-view' ), ); } } if ( ! function_exists( 'addonify_quick_view_get_font_weights' ) ) { /** * Get font weights. * * @since 1.2.16 */ function addonify_quick_view_get_font_weights() { return array( '400' => esc_html__( 'Normal', 'addonify-quick-view' ), '500' => esc_html__( 'Medium', 'addonify-quick-view' ), '600' => esc_html__( 'Semi bold', 'addonify-quick-view' ), '700' => esc_html__( 'Bold', 'addonify-quick-view' ), ); } } if ( ! function_exists( 'addonify_quick_view_get_text_transforms' ) ) { /** * Get text transforms. * * @since 1.2.16 */ function addonify_quick_view_get_text_transforms() { return array( 'inherit' => esc_html__( 'Deafult', 'addonify-quick-view' ), 'capitalize' => esc_html__( 'Capitalize', 'addonify-quick-view' ), 'lowercase' => esc_html__( 'Lowercase', 'addonify-quick-view' ), 'uppercase' => esc_html__( 'Uppercase', 'addonify-quick-view' ), ); } } if ( ! function_exists( 'addonify_quick_view_get_font_styles' ) ) { /** * Get font styles. * * @since 1.2.16 */ function addonify_quick_view_get_font_styles() { return array( 'inherit' => esc_html__( 'Default', 'addonify-quick-view' ), 'italic' => esc_html__( 'Italic', 'addonify-quick-view' ), ); } } if ( ! function_exists( 'addonify_quick_view_minify_css' ) ) { /** * Minifies CSS code. * * @since 1.0.0 * * @param string $css Unminified CSS. */ function addonify_quick_view_minify_css( $css ) { $css = preg_replace( '/\s+/', ' ', $css ); $css = preg_replace( '/\/\*[^\!](.*?)\*\//', '', $css ); $css = preg_replace( '/(,|:|;|\{|}) /', '$1', $css ); $css = preg_replace( '/ (,|;|\{|})/', '$1', $css ); $css = preg_replace( '/(:| )0\.([0-9]+)(%|em|ex|px|in|cm|mm|pt|pc)/i', '${1}.${2}${3}', $css ); $css = preg_replace( '/(:| )(\.?)0(%|em|ex|px|in|cm|mm|pt|pc)/i', '${1}0', $css ); return trim( $css ); } } if ( ! function_exists( 'addonify_quick_view_get_option' ) ) { /** * Retrieve the value of a settings field. * * @since 1.0.7 * * @param string $setting_id Setting ID. */ function addonify_quick_view_get_option( $setting_id ) { $defaults = addonify_quick_view_setting_defaults(); return get_option( ADDONIFY_QUICK_VIEW_DB_INITIALS . $setting_id, $defaults[ $setting_id ] ); } }