Yoast\WP\SEO\Actions
Alert_Dismissal_Action::reset()
Resets an alert.
Метод класса: Alert_Dismissal_Action{}
Хуков нет.
Возвращает
true|false
. Whether the reset was successful or not.
Использование
$Alert_Dismissal_Action = new Alert_Dismissal_Action(); $Alert_Dismissal_Action->reset( $alert_identifier );
- $alert_identifier(строка) (обязательный)
- Alert identifier.
Код Alert_Dismissal_Action::reset() Alert Dismissal Action::reset Yoast 24.4
public function reset( $alert_identifier ) { $user_id = $this->user->get_current_user_id(); if ( $user_id === 0 ) { return false; } if ( $this->is_allowed( $alert_identifier ) === false ) { return false; } $dismissed_alerts = $this->get_dismissed_alerts( $user_id ); if ( $dismissed_alerts === false ) { return false; } $amount_of_dismissed_alerts = \count( $dismissed_alerts ); if ( $amount_of_dismissed_alerts === 0 ) { // No alerts: nothing to reset. return true; } if ( \array_key_exists( $alert_identifier, $dismissed_alerts ) === false ) { // Alert not found: nothing to reset. return true; } if ( $amount_of_dismissed_alerts === 1 ) { // The 1 remaining dismissed alert is the alert to reset: delete the alerts user meta row. return $this->user->delete_meta( $user_id, static::USER_META_KEY, $dismissed_alerts ); } // Remove this alert from the dismissed alerts. unset( $dismissed_alerts[ $alert_identifier ] ); // Save. return $this->user->update_meta( $user_id, static::USER_META_KEY, $dismissed_alerts ) !== false; }