Automattic\WooCommerce\Internal\PushNotifications\Controllers
PushTokenRestController::get_args
Get the accepted arguments for the POST request.
Метод класса: PushTokenRestController{}
Хуков нет.
Возвращает
array.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_args( ?string $context ): array;
- ?string $context
- .
По умолчанию:null
Список изменений
| С версии 10.6.0 | Введена. |
Код PushTokenRestController::get_args() PushTokenRestController::get args WC 11.3.0
private function get_args( ?string $context = null ): array {
$args = array(
'id' => array(
'description' => __( 'Push Token ID', 'woocommerce' ),
'type' => 'integer',
'required' => true,
'context' => array( 'delete' ),
'minimum' => 1,
'sanitize_callback' => 'absint',
'validate_callback' => array( $this, 'validate_argument' ),
),
'origin' => array(
'description' => __( 'Origin', 'woocommerce' ),
'type' => 'string',
'required' => true,
'context' => array( 'create' ),
'enum' => PushToken::ORIGINS,
'validate_callback' => array( $this, 'validate_argument' ),
),
'device_uuid' => array(
'description' => __( 'Device UUID', 'woocommerce' ),
'default' => '',
'type' => 'string',
'context' => array( 'create' ),
'validate_callback' => array( $this, 'validate_argument' ),
'sanitize_callback' => 'sanitize_text_field',
),
'device_locale' => array(
'description' => __( 'Device Locale', 'woocommerce' ),
'type' => 'string',
'required' => true,
'context' => array( 'create' ),
'validate_callback' => array( $this, 'validate_argument' ),
'sanitize_callback' => 'sanitize_text_field',
),
'platform' => array(
'description' => __( 'Platform', 'woocommerce' ),
'type' => 'string',
'required' => true,
'context' => array( 'create' ),
'enum' => PushToken::PLATFORMS,
'validate_callback' => array( $this, 'validate_argument' ),
),
'token' => array(
'description' => __( 'Push Token', 'woocommerce' ),
'type' => 'string',
'required' => true,
'context' => array( 'create' ),
'validate_callback' => array( $this, 'validate_argument' ),
'sanitize_callback' => 'wp_unslash',
),
'metadata' => array(
'description' => __( 'Metadata', 'woocommerce' ),
'type' => 'object',
'context' => array( 'create' ),
'validate_callback' => array( $this, 'validate_argument' ),
'sanitize_callback' => 'wp_unslash',
),
);
if ( $context ) {
$args = array_filter(
$args,
fn ( $arg ) => in_array( $context, $arg['context'], true )
);
}
return $args;
}