Automattic\WooCommerce\Admin\RemoteInboxNotifications
RemoteInboxNotificationsDataSourcePoller::validate_action
Validate the action.
Метод класса: RemoteInboxNotificationsDataSourcePoller{}
Хуков нет.
Возвращает
true|false. The result of the validation.
Использование
// private - только в коде основоного (родительского) класса $result = $this->validate_action( $action, $url );
- $action(объект) (обязательный)
- The action to validate.
- $url(строка) (обязательный)
- The url of the feed containing the action (for error reporting).
Код RemoteInboxNotificationsDataSourcePoller::validate_action() RemoteInboxNotificationsDataSourcePoller::validate action WC 10.7.0
private function validate_action( $action, $url ) {
$logger = self::get_logger();
$logger_context = array( 'source' => $url );
if ( ! isset( $action->locales ) || ! is_array( $action->locales ) ) {
$logger->error(
'Action is invalid because it has empty or missing locales in feed',
$logger_context
);
// phpcs:ignore
$logger->error( print_r( $action, true ), $logger_context );
return false;
}
if ( null === SpecRunner::get_action_locale( $action->locales ) ) {
$logger->error(
'Action is invalid because the locale could not be retrieved in feed',
$logger_context
);
// phpcs:ignore
$logger->error( print_r( $action, true ), $logger_context );
return false;
}
if ( ! isset( $action->name ) ) {
$logger->error(
'Action is invalid because the name is missing in feed',
$logger_context
);
// phpcs:ignore
$logger->error( print_r( $action, true ), $logger_context );
return false;
}
if ( ! isset( $action->status ) ) {
$logger->error(
'Action is invalid because the status is missing in feed',
$logger_context
);
// phpcs:ignore
$logger->error( print_r( $action, true ), $logger_context );
return false;
}
return true;
}