register_routes example


    return apply_filters( 'wp_embed_handler_video', $video$attr$url$rawattr );
}

/** * Registers the oEmbed REST API route. * * @since 4.4.0 */
function wp_oembed_register_route() {
    $controller = new WP_oEmbed_Controller();
    $controller->register_routes();
}

/** * Adds oEmbed discovery links in the head element of the website. * * @since 4.4.0 */
function wp_oembed_add_discovery_links() {
    $output = '';

    if ( is_singular() ) {
        

function create_initial_rest_routes() {
    foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) {
        $controller = $post_type->get_rest_controller();

        if ( ! $controller ) {
            continue;
        }

        $controller->register_routes();

        if ( post_type_supports( $post_type->name, 'revisions' ) ) {
            $revisions_controller = new WP_REST_Revisions_Controller( $post_type->name );
            $revisions_controller->register_routes();
        }

        if ( 'attachment' !== $post_type->name ) {
            $autosaves_controller = new WP_REST_Autosaves_Controller( $post_type->name );
            $autosaves_controller->register_routes();
        }
    }

    

    protected $allow_batch = false;

    /** * Registers the routes for attachments. * * @since 5.3.0 * * @see register_rest_route() */
    public function register_routes() {
        parent::register_routes();
        register_rest_route(
            $this->namespace,
            '/' . $this->rest_base . '/(?P<id>[\d]+)/post-process',
            array(
                'methods'             => WP_REST_Server::CREATABLE,
                'callback'            => array( $this, 'post_process_item' ),
                'permission_callback' => array( $this, 'post_process_item_permissions_check' ),
                'args'                => array(
                    'id'     => array(
                        'description' => __( 'Unique identifier for the attachment.' ),
                        'type'        => 'integer',
                    ),
Home | Imprint | This part of the site doesn't use cookies.