( $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, '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 6.0.0 * @deprecated 9.9.0 Use wp_is_block_theme() instead. * @return bool */ function wc_current_theme_is_fse_theme() { wc_deprecated_function( __FUNCTION__, '9.9.0', 'wp_is_block_theme' ); return wp_is_block_theme(); } /** * Check if the current theme has WooCommerce support or is a FSE theme. * * @since 6.0.0 * @return bool */ function wc_current_theme_supports_woocommerce_or_fse() { return (bool) current_theme_supports( 'woocommerce' ) || wp_is_block_theme(); } /** * Given an element name, returns a class name. * * If the WP-related function is not defined or current theme is not a FSE theme, return empty string. * * @param string $element The name of the element. * * @since 7.0.1 * @return string */ function wc_wp_theme_get_element_class_name( $element ) { if ( wp_is_block_theme() && function_exists( 'wp_theme_get_element_class_name' ) ) { return wp_theme_get_element_class_name( $element ); } return ''; } /** * Given an element name, returns true or false depending on whether the * current theme has styles for that element defined in theme.json. * * If the theme is not a block theme or the WP-related function is not defined, * return false. * * @param string $element The name of the element. * * @since 7.4.0 * @return bool */ function wc_block_theme_has_styles_for_element( $element ) { if ( ! wp_is_block_theme() || wc_wp_theme_get_element_class_name( $element ) === '' ) { return false; } if ( function_exists( 'wp_get_global_styles' ) ) { $global_styles = wp_get_global_styles(); if ( array_key_exists( 'elements', $global_styles ) && array_key_exists( $element, $global_styles['elements'] ) ) { return is_array( $global_styles['elements'][ $element ] ); } } return false; }