Automattic\WooCommerce\Admin\API

OnboardingTasks::register_routes()publicWC 1.0

Register routes.

{} Это метод класса: OnboardingTasks{}

Хуков нет.

Возвращает

null. Ничего.

Использование

$OnboardingTasks = new OnboardingTasks();
$OnboardingTasks->register_routes();

Код OnboardingTasks::register_routes() WC 6.9.4

public function register_routes() {
	register_rest_route(
		$this->namespace,
		'/' . $this->rest_base . '/import_sample_products',
		array(
			array(
				'methods'             => \WP_REST_Server::CREATABLE,
				'callback'            => array( $this, 'import_sample_products' ),
				'permission_callback' => array( $this, 'create_products_permission_check' ),
			),
			'schema' => array( $this, 'get_public_item_schema' ),
		)
	);

	register_rest_route(
		$this->namespace,
		'/' . $this->rest_base . '/create_homepage',
		array(
			array(
				'methods'             => \WP_REST_Server::CREATABLE,
				'callback'            => array( $this, 'create_homepage' ),
				'permission_callback' => array( $this, 'create_pages_permission_check' ),
			),
			'schema' => array( $this, 'get_public_item_schema' ),
		)
	);

	register_rest_route(
		$this->namespace,
		'/' . $this->rest_base . '/create_product_from_template',
		array(
			array(
				'methods'             => \WP_REST_Server::CREATABLE,
				'callback'            => array( $this, 'create_product_from_template' ),
				'permission_callback' => array( $this, 'create_products_permission_check' ),
				'args'                => array_merge(
					$this->get_endpoint_args_for_item_schema( \WP_REST_Server::CREATABLE ),
					array(
						'template_name' => array(
							'required'    => true,
							'type'        => 'string',
							'description' => __( 'Product template name.', 'woocommerce' ),
						),
					)
				),
			),
			'schema' => array( $this, 'get_public_item_schema' ),
		)
	);

	register_rest_route(
		$this->namespace,
		'/' . $this->rest_base,
		array(
			array(
				'methods'             => \WP_REST_Server::READABLE,
				'callback'            => array( $this, 'get_tasks' ),
				'permission_callback' => array( $this, 'get_tasks_permission_check' ),
				'args'                => array(
					'ids' => array(
						'description'       => __( 'Optional parameter to get only specific task lists by id.', 'woocommerce' ),
						'type'              => 'array',
						'sanitize_callback' => 'wp_parse_slug_list',
						'validate_callback' => 'rest_validate_request_arg',
						'items'             => array(
							'enum' => TaskLists::get_list_ids(),
							'type' => 'string',
						),
					),
				),
			),
			array(
				'methods'             => \WP_REST_Server::CREATABLE,
				'callback'            => array( $this, 'get_tasks' ),
				'permission_callback' => array( $this, 'get_tasks_permission_check' ),
				'args'                => $this->get_task_list_params(),
			),
			'schema' => array( $this, 'get_public_item_schema' ),
		)
	);

	register_rest_route(
		$this->namespace,
		'/' . $this->rest_base . '/(?P<id>[a-z0-9_\-]+)/hide',
		array(
			array(
				'methods'             => \WP_REST_Server::EDITABLE,
				'callback'            => array( $this, 'hide_task_list' ),
				'permission_callback' => array( $this, 'hide_task_list_permission_check' ),
			),
			'schema' => array( $this, 'get_public_item_schema' ),
		)
	);

	register_rest_route(
		$this->namespace,
		'/' . $this->rest_base . '/(?P<id>[a-z0-9_\-]+)/unhide',
		array(
			array(
				'methods'             => \WP_REST_Server::EDITABLE,
				'callback'            => array( $this, 'unhide_task_list' ),
				'permission_callback' => array( $this, 'hide_task_list_permission_check' ),
			),
			'schema' => array( $this, 'get_public_item_schema' ),
		)
	);

	register_rest_route(
		$this->namespace,
		'/' . $this->rest_base . '/(?P<id>[a-z0-9_\-]+)/dismiss',
		array(
			array(
				'methods'             => \WP_REST_Server::EDITABLE,
				'callback'            => array( $this, 'dismiss_task' ),
				'permission_callback' => array( $this, 'get_tasks_permission_check' ),
			),
			'schema' => array( $this, 'get_public_item_schema' ),
		)
	);

	register_rest_route(
		$this->namespace,
		'/' . $this->rest_base . '/(?P<id>[a-z0-9_\-]+)/undo_dismiss',
		array(
			array(
				'methods'             => \WP_REST_Server::EDITABLE,
				'callback'            => array( $this, 'undo_dismiss_task' ),
				'permission_callback' => array( $this, 'get_tasks_permission_check' ),
			),
			'schema' => array( $this, 'get_public_item_schema' ),
		)
	);

	register_rest_route(
		$this->namespace,
		'/' . $this->rest_base . '/(?P<id>[a-z0-9_-]+)/snooze',
		array(
			'args'   => array(
				'duration'     => array(
					'description'       => __( 'Time period to snooze the task.', 'woocommerce' ),
					'type'              => 'string',
					'validate_callback' => function( $param, $request, $key ) {
						return in_array( $param, array_keys( $this->duration_to_ms ), true );
					},
				),
				'task_list_id' => array(
					'description' => __( 'Optional parameter to query specific task list.', 'woocommerce' ),
					'type'        => 'string',
				),
			),
			array(
				'methods'             => \WP_REST_Server::CREATABLE,
				'callback'            => array( $this, 'snooze_task' ),
				'permission_callback' => array( $this, 'snooze_task_permissions_check' ),
			),
			'schema' => array( $this, 'get_public_item_schema' ),
		)
	);

	register_rest_route(
		$this->namespace,
		'/' . $this->rest_base . '/(?P<id>[a-z0-9_\-]+)/action',
		array(
			array(
				'methods'             => \WP_REST_Server::EDITABLE,
				'callback'            => array( $this, 'action_task' ),
				'permission_callback' => array( $this, 'get_tasks_permission_check' ),
			),
			'schema' => array( $this, 'get_public_item_schema' ),
		)
	);

	register_rest_route(
		$this->namespace,
		'/' . $this->rest_base . '/(?P<id>[a-z0-9_\-]+)/undo_snooze',
		array(
			array(
				'methods'             => \WP_REST_Server::EDITABLE,
				'callback'            => array( $this, 'undo_snooze_task' ),
				'permission_callback' => array( $this, 'snooze_task_permissions_check' ),
			),
			'schema' => array( $this, 'get_public_item_schema' ),
		)
	);
}