rray( $name, array_keys( $attributes ), true ) && in_array( $value, $variation_attributes[ $attributes[ $name ]['name'] ], true ) ); } else { return false; } } } if ( ! function_exists( 'wc_tax_enabled' ) ) { /** * Are store-wide taxes enabled? * * @return bool */ function wc_tax_enabled() { return apply_filters( 'wc_tax_enabled', get_option( 'woocommerce_calc_taxes' ) === 'yes' ); } } if ( ! function_exists( 'wc_shipping_enabled' ) ) { /** * Is shipping enabled? * * @return bool */ function wc_shipping_enabled() { return apply_filters( 'wc_shipping_enabled', get_option( 'woocommerce_ship_to_countries' ) !== 'disabled' ); } } if ( ! function_exists( 'wc_prices_include_tax' ) ) { /** * Are prices inclusive of tax? * * @return bool */ function wc_prices_include_tax() { return wc_tax_enabled() && apply_filters( 'woocommerce_prices_include_tax', get_option( 'woocommerce_prices_include_tax' ) === 'yes' ); } } /** * Simple check for validating a URL, it must start with http:// or https://. * and pass FILTER_VALIDATE_URL validation. * * @param string $url to check. * @return bool */ function wc_is_valid_url( $url ) { // Must start with http:// or https://. if ( 0 !== strpos( $url, 'http://' ) && 0 !== strpos( $url, 'https://' ) ) { return false; } // Must pass validation. if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) { return false; } return true; } /** * Check if the home URL is https. If it is, we don't need to do things such as 'force ssl'. * * @since 2.4.13 * @return bool */ function wc_site_is_https() { return false !== strstr( get_option( 'home' ), 'https:' ); } /** * Check if the checkout is configured for https. Look at options, WP HTTPS plugin, or the permalink itself. * * @since 2.5.0 * @return bool */ function wc_checkout_is_https() { return wc_site_is_https() || 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) || class_exists( 'WordPressHTTPS' ) || strstr( wc_get_page_permalink( 'checkout' ), 'https:' ); } /** * Checks whether the content passed contains a specific short code. * * @param string $tag Shortcode tag to check. * @return bool */ function wc_post_content_has_shortcode( $tag = '' ) { global $post; return is_singular() && is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, $tag ); } /** * Check if reviews are enabled. * * @since 3.6.0 * @return bool */ function wc_reviews_enabled() { return 'yes' === get_option( 'woocommerce_enable_reviews' ); } /** * Check if reviews ratings are enabled. * * @since 3.6.0 * @return bool */ function wc_review_ratings_enabled() { return wc_reviews_enabled() && 'yes' === get_option( 'woocommerce_enable_review_rating' ); } /** * Check if review ratings are required. * * @since 3.6.0 * @return bool */ function wc_review_ratings_required() { return 'yes' === get_option( 'woocommerce_review_rating_required' ); } /** * Check if a CSV file is valid. * * @since 3.6.5 * @param string $file File name. * @param bool $check_path If should check for the path. * @return bool */ function wc_is_file_valid_csv( $file, $check_path = true ) { /** * Filter check for CSV file path. * * @since 3.6.4 * @param bool $check_import_file_path If requires file path check. Defaults to true. * @param string $file Path of the file to be checked. */ $check_import_file_path = apply_filters( 'woocommerce_csv_importer_check_import_file_path', true, $file ); if ( $check_path && $check_import_file_path && false !== stripos( $file, '://' ) ) { return false; } /** * Filter CSV valid file types. * * @since 3.6.5 * @param array $valid_filetypes List of valid file types. */ $valid_filetypes = apply_filters( 'woocommerce_csv_import_valid_filetypes', array( 'csv' => 'text/csv', 'txt' => 'text/plain', ) ); $filetype = wp_check_filetype( $file, $valid_filetypes ); if ( in_array( $filetype['type'], $valid_filetypes, true ) ) { return true; } return false; } /** * Check if the current theme is a block theme. * * @since x.x.x * @return bool */ function wc_current_theme_is_fse_theme() { if ( function_exists( 'wp_is_block_theme' ) ) { return (bool) wp_is_block_theme(); } if ( function_exists( 'gutenberg_is_fse_theme' ) ) { return (bool) gutenberg_is_fse_theme(); } return false; } /** * Check if the current theme has WooCommerce support or is a FSE theme. * * @since x.x.x * @return bool */ function wc_current_theme_supports_woocommerce_or_fse() { return (bool) current_theme_supports( 'woocommerce' ) || wc_current_theme_is_fse_theme(); }