rest_get_url_prefix example

/** * Adds REST rewrite rules. * * @since 4.4.0 * * @see add_rewrite_rule() * @global WP_Rewrite $wp_rewrite WordPress rewrite component. */
function rest_api_register_rewrites() {
    global $wp_rewrite;

    add_rewrite_rule( '^' . rest_get_url_prefix() . '/?$', 'index.php?rest_route=/', 'top' );
    add_rewrite_rule( '^' . rest_get_url_prefix() . '/(.*)?', 'index.php?rest_route=/$matches[1]', 'top' );
    add_rewrite_rule( '^' . $wp_rewrite->index . '/' . rest_get_url_prefix() . '/?$', 'index.php?rest_route=/', 'top' );
    add_rewrite_rule( '^' . $wp_rewrite->index . '/' . rest_get_url_prefix() . '/(.*)?', 'index.php?rest_route=/$matches[1]', 'top' );
}

/** * Registers the default REST API filters. * * Attached to the {@see 'rest_api_init'} action * to make testing and disabling these filters easier. * * @since 4.4.0 */
Home | Imprint | This part of the site doesn't use cookies.