How do I get reusable blocks via frontend REST API?

How do I get reusable blocks via frontend REST API? We need to be logged in as a user and additionally add the wp_rest nonce to the block rest endpoint request, either via the _wpnonce POST/GET parameter or via the X-WP-Nonce header. See e.g. the docs for more information on the authentication. EDIT: As pointed … Read more

wrapping ‘rest_api_init’ in ‘is_admin()’ function

Essentially, you shouldn’t wrap your REST route declarations inside is_admin() since WordPress will not load them (see @DarkNueron comment). What you can do is pass a ‘permission_callback’ function to the register_rest_route function. If the function returns true, the request is allowed to continue; if false, an error is returned. So you could do: register_rest_route(‘your-namespace/v1’, ‘/options/’, … Read more

Does it still make sense using json endpoint ep_mask now that there’s the new rest api? [closed]

I think you should stop using rewrite endpoints to handle JSON responses. Instead you can and you should use the REST API. So, instead of this: function makeplugins_add_json_endpoint() { add_rewrite_endpoint( ‘json’, EP_PERMALINK | EP_PAGES ); } add_action( ‘init’, ‘makeplugins_add_json_endpoint’ ); And then handle the JSON response at your own, you can and you should do … Read more

Confused about AngularJS and WordPress

Unfortunately I don’t know Angular to give you a hand with that, but I’m seeing this question is related to another about consuming an endpoint with a filter by meta_key (by the way, I’ve updated my previous response with a very simple jQuery-only code to show posts retrieved in a list). However, if you don’t … Read more

WP-RestAPI and xml sitemap

Let’s assume your plugin is writing to the /usr/share/wordpress/sitemap_index.xml filesystem location, but you want it can be accessed through http://www.website.com/sitemap_index.xml as if the xml file were stored in /var/www/html/sitemap_index.xml. You can use the alias directive then, available in mainstream webservers Apache and NginX: For an alias in NginX, you put this inside the server of … Read more