plugin updates

This commit is contained in:
Tony Volpe
2024-11-15 13:53:04 -05:00
parent 1293d604ca
commit 0238f0c4ca
2009 changed files with 163492 additions and 89543 deletions

View File

@@ -97,6 +97,8 @@ class WC_Admin_Marketplace_Promotions {
return array();
}
$promotions = self::merge_promos( $promotions );
return self::filter_out_inactive_promotions( $promotions );
}
@@ -144,6 +146,7 @@ class WC_Admin_Marketplace_Promotions {
}
$promotions = json_decode( wp_remote_retrieve_body( $raw_promotions ), true );
if ( ! is_array( $promotions ) ) {
$promotions = array();
@@ -277,6 +280,27 @@ class WC_Admin_Marketplace_Promotions {
return $active_promotions;
}
/**
* Promos arrive in the array of promotions as an array of arrays with the key 'promos'.
* We merge them into the main array.
*
* @param ?array $promotions Promotions data received from WCCOM.
* May have an element with the key 'promos', which contains an array.
*
* @return array
* */
private static function merge_promos( ?array $promotions = array() ): array {
if (
! empty( $promotions['promos'] )
&& is_array( $promotions['promos'] )
) {
$promotions = array_merge( $promotions, $promotions['promos'] );
unset( $promotions['promos'] );
}
return $promotions;
}
/**
* Callback for the `woocommerce_marketplace_menu_items` filter
* in `Automattic\WooCommerce\Internal\Admin\Marketplace::get_marketplace_pages`.