Update a server-side render Block when woocommerce cart block changed

Something like this should work: const {select, subscribe} = window.wp.data; const cartStoreKey = window.wc.wcBlocksData.CART_STORE_KEY; const unsub = subscribe( onCartChange, cartStoreKey ); function onCartChange() { const cart = select( cartStoreKey ).getCartData(); console.log( ‘¡ cart change !’, cart ); } The block’s frontend script should have the woocommerce script’s handle as a dependency so the window.wc.wcBlocksData will … Read more

Get list of outdated plugins in the rest api?

Get list of outdated plugins in the rest api? It looks like you would need to create your own custom REST API endpoints using get_plugin_updates() and get_theme_updates() to list available updates. Note that these display cached data and don’t trigger a request to wp.org api.

How to get a page’s featured image through REST API?

Maybe because the custom REST field (fimg_url) was only being added to posts of the post type and yet your request was for Pages, i.e. posts of the page type.. so try changing the register_rest_field( array(‘post’) to register_rest_field( array(‘post’, ‘page’). See https://developer.wordpress.org/reference/functions/register_rest_field/#parameters. But actually, you can use the _embed parameter to have the full media … Read more

Using backbone, can I prevent the nonce from being set?

Yes, the nonce is by default always being sent via the X-WP-Nonce header – see the source here and here on GitHub. wp.api.WPApiBaseModel.prototype.sync and wp.api.WPApiBaseCollection.prototype.sync can technically be extended or modified, but I would instead disable the nonce header like so, i.e. using <Collection or Model object>.endpointModel: Collection example: const Posts = new wp.api.collections.Posts(); // … Read more

Get the email of the author of the currently being edited post in Gutenberg frontend

Here’s how can you get the ID and email address of the author of the currently being edited post: // Get the post author’s ID. let postAuthorId = wp.data.select( ‘core/editor’ ).getCurrentPostAttribute( ‘author’ ); /* or you can also use this: let postAuthorId = wp.data.select( ‘core/editor’ ).getEditedPostAttribute( ‘author’ ); */ // Get the post author’s email. … Read more