Yoast\WP\SEO\Schema_Aggregator\User_Interface
Site_Schema_Aggregator_Route::register_routes
Registers routes with WordPress.
Метод класса: Site_Schema_Aggregator_Route{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$Site_Schema_Aggregator_Route = new Site_Schema_Aggregator_Route(); $Site_Schema_Aggregator_Route->register_routes();
Код Site_Schema_Aggregator_Route::register_routes() Site Schema Aggregator Route::register routes Yoast 28.3
public function register_routes() {
$base_route_config = [
'methods' => 'GET',
'callback' => [ $this, 'aggregate_site_schema' ],
'permission_callback' => [ $this, 'get_permission_callback' ],
'args' => [
'post_type' => [
'required' => true,
'validate_callback' => static function ( $param ) {
return \is_string( $param ) && \preg_match( '/^[a-z0-9_-]+$/', $param ) && \post_type_exists( $param );
},
'sanitize_callback' => 'sanitize_key',
],
],
];
$schema_aggregator_route_page = $base_route_config;
$schema_aggregator_route_page['args']['page'] = [
'default' => 1,
'validate_callback' => [ $this, 'validate_page' ],
'sanitize_callback' => 'absint',
];
\register_rest_route( Main::API_V1_NAMESPACE, self::GET_SCHEMA_ROUTE . '/(?P<post_type>[a-z0-9_-]+)', $base_route_config );
\register_rest_route( Main::API_V1_NAMESPACE, self::GET_SCHEMA_ROUTE . '/(?P<post_type>[a-z0-9_-]+)/(?P<page>\d+)', $schema_aggregator_route_page );
}