Automattic\WooCommerce\Internal\Admin\Suggestions\Incentives
Incentive::is_dismissed
Check if an incentive has been manually dismissed.
Метод класса: Incentive{}
Хуков нет.
Возвращает
true|false. Whether the incentive has been manually dismissed.
Использование
$Incentive = new Incentive(); $Incentive->is_dismissed( $id, $context ): bool;
- $id(строка) (обязательный)
- The incentive ID to check for dismissal.
- $context(строка)
- The context ID in which to check for dismissal. If no context ID is provided, we check for dismissal in all contexts.
По умолчанию:''
Код Incentive::is_dismissed() Incentive::is dismissed WC 10.5.2
public function is_dismissed( string $id, string $context = '' ): bool {
if ( empty( $id ) ) {
return false;
}
$all_dismissed_incentives = $this->get_all_dismissed_incentives();
// If there are no dismissed incentives for the suggestion, return early.
$dismissed_incentives = $all_dismissed_incentives[ $this->suggestion_id ] ?? array();
if ( empty( $dismissed_incentives ) ) {
return false;
}
// Check if the incentive is dismissed in the given context.
if ( in_array(
$id,
array_column(
array_filter(
$dismissed_incentives,
// All context dismissals are always included.
fn( $dismissed_incentive ) => 'all' === $dismissed_incentive['context'] || $context === $dismissed_incentive['context']
),
'id'
),
true
) ) {
return true;
}
return false;
}