WC_Admin_Marketplace_Promotions::maybe_show_bubble_promotions
If there's an active promotion of the format menu_bubble, add a filter to show a bubble on the Extensions item in the WooCommerce menu.
Use woocommerce_marketplace_suppress_promotions to suppress the bubble.
Метод класса: WC_Admin_Marketplace_Promotions{}
Хуки из метода
Возвращает
null. Ничего (null).
Использование
$result = WC_Admin_Marketplace_Promotions::maybe_show_bubble_promotions();
Код WC_Admin_Marketplace_Promotions::maybe_show_bubble_promotions() WC Admin Marketplace Promotions::maybe show bubble promotions WC 10.5.0
private static function maybe_show_bubble_promotions() {
/**
* Filter to suppress the requests for and showing of marketplace promotions.
*
* @since 8.8
*/
if ( apply_filters( 'woocommerce_marketplace_suppress_promotions', false ) ) {
return;
}
$promotions = get_transient( self::TRANSIENT_NAME );
if ( ! $promotions ) {
return;
}
$bubble_promotions = self::get_promotions_of_format( $promotions, 'menu_bubble' );
if ( empty( $bubble_promotions ) ) {
return;
}
$now_date_time = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
// Let's make absolutely sure the promotion is still active.
foreach ( $bubble_promotions as $promotion ) {
if ( ! isset( $promotion['date_to_gmt'] ) ) {
continue;
}
try {
$date_to_gmt = new DateTime( $promotion['date_to_gmt'], new DateTimeZone( 'UTC' ) );
} catch ( \Exception $ex ) {
continue;
}
if ( $now_date_time < $date_to_gmt ) {
add_filter(
'woocommerce_marketplace_menu_items',
function ( $marketplace_pages ) use ( $promotion ) {
return self::filter_marketplace_menu_items( $marketplace_pages, $promotion );
}
);
break;
}
}
}