Apply suggestions from code review
Mostly adding "since 4.4.0" annotations and updating db update functions from 4.2 to 4.4. Co-authored-by: Claudio Sanches <contato@claudiosanches.com>
This commit is contained in:
parent
29843b9396
commit
e9d692f455
|
@ -149,9 +149,9 @@ class WC_Install {
|
|||
'wc_update_400_reset_action_scheduler_migration_status',
|
||||
'wc_update_400_db_version',
|
||||
),
|
||||
'4.2.0' => array(
|
||||
'wc_update_420_insert_attribute_terms_for_variable_products',
|
||||
'wc_update_420_db_version',
|
||||
'4.4.0' => array(
|
||||
'wc_update_440_insert_attribute_terms_for_variable_products',
|
||||
'wc_update_440_db_version',
|
||||
),
|
||||
);
|
||||
|
||||
|
|
|
@ -587,7 +587,7 @@ class WC_Product_Variation extends WC_Product_Simple {
|
|||
/**
|
||||
* Delete variation, set the ID to 0, and return result.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @since 4.4.0
|
||||
* @param bool $force_delete Should the variation be deleted permanently.
|
||||
* @return bool result
|
||||
*/
|
||||
|
|
|
@ -374,6 +374,7 @@ class WC_Query {
|
|||
*
|
||||
* We also cache the post visibility so that it isn't checked again when displaying the posts list.
|
||||
*
|
||||
* @since 4.4.0
|
||||
* @param int $count Original posts count, as supplied by the found_posts filter.
|
||||
*
|
||||
* @return int Adjusted posts count.
|
||||
|
@ -728,11 +729,11 @@ class WC_Query {
|
|||
$product_visibility_not_in[] = $product_visibility_terms['outofstock'];
|
||||
}
|
||||
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Recommended
|
||||
// Filter by rating.
|
||||
if ( isset( $_GET['rating_filter'] ) ) {
|
||||
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||
$rating_filter = array_filter( array_map( 'absint', explode( ',', $_GET['rating_filter'] ) ) );
|
||||
$rating_filter = array_filter( array_map( 'absint', explode( ',', wp_unslash( $_GET['rating_filter'] ) ) ) );
|
||||
$rating_terms = array();
|
||||
for ( $i = 1; $i <= 5; $i ++ ) {
|
||||
if ( in_array( $i, $rating_filter, true ) && isset( $product_visibility_terms[ 'rated-' . $i ] ) ) {
|
||||
|
@ -749,7 +750,7 @@ class WC_Query {
|
|||
);
|
||||
}
|
||||
}
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Recommended
|
||||
|
||||
if ( ! empty( $product_visibility_not_in ) ) {
|
||||
$tax_query[] = array(
|
||||
|
|
|
@ -200,7 +200,7 @@ class WC_Product_Variable_Data_Store_CPT extends WC_Product_Data_Store_CPT imple
|
|||
$values = array();
|
||||
}
|
||||
|
||||
// Empty value inicates that all options for given attribute are available.
|
||||
// Empty value indicates that all options for given attribute are available.
|
||||
if ( in_array( null, $values, true ) || in_array( '', $values, true ) || empty( $values ) ) {
|
||||
$values = $attribute['is_taxonomy'] ? wc_get_object_terms( $product->get_id(), $attribute['name'], 'slug' ) : wc_get_text_attributes( $attribute['value'] );
|
||||
// Get custom attributes (non taxonomy) as defined.
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
* @version 2.5.0
|
||||
*/
|
||||
|
||||
// phpcs:disable Generic.Commenting.Todo.TaskFound
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
@ -241,6 +239,7 @@ function wc_set_loop_prop( $prop, $value = '' ) {
|
|||
/**
|
||||
* Set the current visbility for a product in the woocommerce_loop global.
|
||||
*
|
||||
* @since 4.4.0
|
||||
* @param int $product_id Product it to cache visbiility for.
|
||||
* @param bool $value The poduct visibility value to cache.
|
||||
*/
|
||||
|
@ -251,6 +250,7 @@ function wc_set_loop_product_visibility( $product_id, $value ) {
|
|||
/**
|
||||
* Gets the cached current visibility for a product from the woocommerce_loop global.
|
||||
*
|
||||
* @since 4.4.0
|
||||
* @param int $product_id Product id to get the cached visibility for.
|
||||
*
|
||||
* @return bool|null The cached product visibility, or null if on visibility has been cached for that product.
|
||||
|
@ -731,9 +731,8 @@ function wc_product_class( $class = '', $product_id = null ) {
|
|||
*/
|
||||
function wc_query_string_form_fields( $values = null, $exclude = array(), $current_key = '', $return = false ) {
|
||||
if ( is_null( $values ) ) {
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Recommended
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$values = $_GET;
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Recommended
|
||||
} elseif ( is_string( $values ) ) {
|
||||
$url_parts = wp_parse_url( $values );
|
||||
$values = array();
|
||||
|
|
|
@ -2136,7 +2136,7 @@ function wc_update_400_db_version() {
|
|||
*
|
||||
* @return bool true if there are more products to process.
|
||||
*/
|
||||
function wc_update_420_insert_attribute_terms_for_variable_products() {
|
||||
function wc_update_440_insert_attribute_terms_for_variable_products() {
|
||||
$state_option_name = 'woocommerce_' . __FUNCTION__ . '_state';
|
||||
|
||||
$page = intval( get_option( $state_option_name, 1 ) );
|
||||
|
@ -2172,6 +2172,6 @@ function wc_update_420_insert_attribute_terms_for_variable_products() {
|
|||
/**
|
||||
* Update DB version.
|
||||
*/
|
||||
function wc_update_420_db_version() {
|
||||
WC_Install::update_db_version( '4.2.0' );
|
||||
function wc_update_440_db_version() {
|
||||
WC_Install::update_db_version( '4.4.0' );
|
||||
}
|
||||
|
|
|
@ -485,6 +485,7 @@ class WC_Widget_Layered_Nav extends WC_Widget {
|
|||
/**
|
||||
* Wrapper for WC_Query::get_main_tax_query() to ease unit testing.
|
||||
*
|
||||
* @since 4.4.0
|
||||
* @return array
|
||||
*/
|
||||
protected function get_main_tax_query() {
|
||||
|
@ -494,6 +495,7 @@ class WC_Widget_Layered_Nav extends WC_Widget {
|
|||
/**
|
||||
* Wrapper for WC_Query::get_main_search_query_sql() to ease unit testing.
|
||||
*
|
||||
* @since 4.4.0
|
||||
* @return string
|
||||
*/
|
||||
protected function get_main_search_query_sql() {
|
||||
|
@ -503,6 +505,7 @@ class WC_Widget_Layered_Nav extends WC_Widget {
|
|||
/**
|
||||
* Wrapper for WC_Query::get_main_search_queryget_main_meta_query to ease unit testing.
|
||||
*
|
||||
* @since 4.4.0
|
||||
* @return array
|
||||
*/
|
||||
protected function get_main_meta_query() {
|
||||
|
@ -513,6 +516,7 @@ class WC_Widget_Layered_Nav extends WC_Widget {
|
|||
* Get a tax query SQL for a given set of taxonomy, terms and operator.
|
||||
* Uses an intermediate WP_Tax_Query object.
|
||||
*
|
||||
* @since 4.4.0
|
||||
* @param string $taxonomy Taxonomy name.
|
||||
* @param array $terms Terms to include in the query.
|
||||
* @param string $operator Query operator, as supported by WP_Tax_Query; e.g. "NOT IN".
|
||||
|
@ -536,6 +540,7 @@ class WC_Widget_Layered_Nav extends WC_Widget {
|
|||
/**
|
||||
* Convert a tax query array to SQL using an intermediate WP_Tax_Query object.
|
||||
*
|
||||
* @since 4.4.0
|
||||
* @param array $query Query array in the same format accepted by WP_Tax_Query constructor.
|
||||
*
|
||||
* @return array Query SQL as returned by WP_Tax_Query->get_sql.
|
||||
|
|
Loading…
Reference in New Issue