1 ) { $rem = $num % 10; $revnum = ( $revnum * 10 ) + $rem; $num = ( $num / 10 ); } return $revnum; } } if ( ! function_exists( 'addonify_wishlist_get_product_avaibility' ) ) { /** * Get product's avaibility. * * @since 2.0.2 * * @param object $product Product. * @return array $product_avaibility Array containing avaibility class and label. */ function addonify_wishlist_get_product_avaibility( $product ) { if ( ! $product ) { return false; } $product_status = $product->get_stock_status(); $product_avaibility = array(); switch ( $product_status ) { case 'instock': $product_avaibility['class'] = 'in-stock'; $product_avaibility['avaibility'] = apply_filters( 'addonify_wishlist_product_in_stock_label', addonify_wishlist_get_option( 'product_in_stock_label' ) ); break; case 'outofstock': $product_avaibility['class'] = 'out-of-stock'; $product_avaibility['avaibility'] = apply_filters( 'addonify_wishlist_product_out_of_stock_label', addonify_wishlist_get_option( 'product_out_of_stock_label' ) ); break; default: } return $product_avaibility; } } if ( ! function_exists( 'addonify_wishlist_get_wishlist_items' ) ) { /** * Get items in the wishlist. * * @since 2.0.6 * * @return array */ function addonify_wishlist_get_wishlist_items() { $wishlist_handler = new Addonify_Wishlist_Actions( [ // phpcs:ignore 'user_id' => get_current_user_id(), 'site_url' => get_site_url(), ] ); return $wishlist_handler->get_wishlist_items(); } } if ( ! function_exists( 'addonify_wishlist_get_wishlist_items_count' ) ) { /** * Get the count of items in the wishlist. * * @since 1.0.0 * * @return int Count of items. */ function addonify_wishlist_get_wishlist_items_count() { return count( addonify_wishlist_get_wishlist_items() ); } } if ( ! function_exists( 'addonify_wishlist_is_product_in_wishlist' ) ) { /** * Check if product is in wishlist. * * @since 1.0.0 * * @param int $product_id Product ID. * @return boolean True if product is in wishlist, false otherwise. */ function addonify_wishlist_is_product_in_wishlist( $product_id ) { $wishlist_items = addonify_wishlist_get_wishlist_items(); return in_array( $product_id, $wishlist_items, true ); } } if ( ! function_exists( 'addonify_wishlist_escape_svg' ) ) { /** * Sanitizes SVG when rendering in the frontend. * * @since 2.0.6 * * @param string $svg SVG code. * @return string $svg Sanitized SVG code. */ function addonify_wishlist_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, ), 'g' => array( 'fill' => true, ), 'title' => array( 'title' => true, ), 'path' => array( 'd' => true, 'fill' => true, ), ); return wp_kses( $svg, $allowed_html ); } } if ( ! function_exists( 'addonify_wishlist_get_wishlist_icons' ) ) { /** * Gets and returns wishlist icon. * * @since 2.0.6. * * @param array $key Icon key. */ function addonify_wishlist_get_wishlist_icons( $key ) { $icons = array( // Heart icons (6 icons). 'heart-1' => '', 'heart-2' => '', 'heart-3' => '', 'heart-4' => '', 'heart-5' => '', 'heart-6' => '', // Check icons (4 icons). 'check-1' => '', 'check-2' => '', 'check-3' => '', 'check-4' => '', // Close icons (3 icons). 'close-1' => '', 'close-2' => '', 'close-3' => '', // Warning icons (2 icons). 'warning-1' => '', 'warning-2' => '', // Error icons (2 icons). 'error-1' => '', 'error-2' => '', // Gear icon (3 icons). 'gear-1' => '', 'gear-2' => '', 'gear-3' => '', // Setting icon (2 icons). 'setting-1' => '', 'setting-2' => '', // Bell icon (4 icons). 'bell-1' => '', 'bell-2' => '', 'bell-3' => '', 'bell-4' => '', // Bell icon (4 icons). 'bin-1' => '', 'bin-2' => '', 'bin-3' => '', 'bin-4' => '', 'bin-5' => '', 'bin-6' => '', // Spinner icon (2 icons). 'spinner-1' => '', 'spinner-2' => '', // Edit icon (2 icons). 'edit-1' => '', 'edit-2' => '', // Eye icon (4 icons). 'eye-1' => '', 'eye-2' => '', 'eye-3' => '', 'eye-4' => '', // Bolt/Flash icon (2 icons). 'bolt-1' => '', 'bolt-2' => '', // Login icon (2 icons). 'login-1' => '', 'login-2' => '', ); return isset( $icons[ $key ] ) ? $icons[ $key ] : false; } }