Automattic\WooCommerce\Internal\Admin\Settings
PaymentsRestController::register_routes │ public │ WC 1.0
Register the REST API endpoints handled by this controller.
Метод класса: PaymentsRestController{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$PaymentsRestController = new PaymentsRestController(); $PaymentsRestController->register_routes( $override );
- $override(true|false)
- Whether to override the existing routes. Useful for testing.
По умолчанию: false
Код PaymentsRestController::register_routes() PaymentsRestController::register routes WC 10.3.4
public function register_routes( bool $override = false ) {
register_rest_route(
$this->route_namespace,
'/' . $this->rest_base . '/country',
array(
array(
'methods' => \WP_REST_Server::EDITABLE,
'callback' => fn( $request ) => $this->run( $request, 'set_country' ),
'validation_callback' => 'rest_validate_request_arg',
'permission_callback' => fn( $request ) => $this->check_permissions( $request ),
'args' => array(
'location' => array(
'description' => esc_html__( 'The ISO3166 alpha-2 country code to save for the current user.', 'woocommerce' ),
'type' => 'string',
'pattern' => '[a-zA-Z]{2}', // Two alpha characters.
'required' => true,
'validate_callback' => fn( $value, $request ) => $this->check_location_arg( $value, $request ),
),
),
),
),
$override
);
register_rest_route(
$this->route_namespace,
'/' . $this->rest_base . '/providers',
array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => fn( $request ) => $this->run( $request, 'get_providers' ),
'validation_callback' => 'rest_validate_request_arg',
'permission_callback' => fn( $request ) => $this->check_permissions( $request ),
'args' => array(
'location' => array(
'description' => esc_html__( 'ISO3166 alpha-2 country code. Defaults to WooCommerce\'s base location country.', 'woocommerce' ),
'type' => 'string',
'pattern' => '[a-zA-Z]{2}', // Two alpha characters.
'required' => false,
'validate_callback' => fn( $value, $request ) => $this->check_location_arg( $value, $request ),
),
),
),
'schema' => fn() => $this->get_schema_for_get_payment_providers(),
),
$override
);
register_rest_route(
$this->route_namespace,
'/' . $this->rest_base . '/providers/order',
array(
array(
'methods' => \WP_REST_Server::EDITABLE,
'callback' => fn( $request ) => $this->run( $request, 'update_providers_order' ),
'permission_callback' => fn( $request ) => $this->check_permissions( $request ),
'args' => array(
'order_map' => array(
'description' => esc_html__( 'A map of provider ID to integer values representing the sort order.', 'woocommerce' ),
'type' => 'object',
'required' => true,
'validate_callback' => fn( $value ) => $this->check_providers_order_map_arg( $value ),
'sanitize_callback' => fn( $value ) => $this->sanitize_providers_order_arg( $value ),
),
),
),
),
$override
);
register_rest_route(
$this->route_namespace,
'/' . $this->rest_base . '/suggestion/(?P<id>[\w\d\-]+)/attach',
array(
array(
'methods' => \WP_REST_Server::EDITABLE,
'callback' => fn( $request ) => $this->run( $request, 'attach_payment_extension_suggestion' ),
'permission_callback' => fn( $request ) => $this->check_permissions( $request ),
),
),
$override
);
register_rest_route(
$this->route_namespace,
'/' . $this->rest_base . '/suggestion/(?P<id>[\w\d\-]+)/hide',
array(
array(
'methods' => \WP_REST_Server::EDITABLE,
'callback' => fn( $request ) => $this->run( $request, 'hide_payment_extension_suggestion' ),
'permission_callback' => fn( $request ) => $this->check_permissions( $request ),
),
),
$override
);
register_rest_route(
$this->route_namespace,
'/' . $this->rest_base . '/suggestion/(?P<suggestion_id>[\w\d\-]+)/incentive/(?P<incentive_id>[\w\d\-]+)/dismiss',
array(
array(
'methods' => \WP_REST_Server::EDITABLE,
'callback' => fn( $request ) => $this->run( $request, 'dismiss_payment_extension_suggestion_incentive' ),
'permission_callback' => fn( $request ) => $this->check_permissions( $request ),
'args' => array(
'context' => array(
'description' => esc_html__( 'The context ID for which to dismiss the incentive. If not provided, will dismiss the incentive for all contexts.', 'woocommerce' ),
'type' => 'string',
'required' => false,
'sanitize_callback' => 'sanitize_key',
),
'do_not_track' => array(
'description' => esc_html__( 'If true, the incentive dismissal will be ignored by tracking.', 'woocommerce' ),
'type' => 'boolean',
'required' => false,
'default' => false,
'sanitize_callback' => 'rest_sanitize_boolean',
),
),
),
),
$override
);
}