plugin updates
This commit is contained in:
@@ -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`.
|
||||
|
||||
Reference in New Issue
Block a user