Disable XML-RPC via snippet

From the xmlrpc_enabled filter docs: Contrary to the way it’s named, this filter does not control whether XML-RPC is fully enabled, rather, it only controls whether XML-RPC methods requiring authentication – such as for publishing purposes – are enabled. To fully disable XMLRPC, you might be able to use the xmlrpc_methods filter and return an … Read more

Embed dynamic media query in a Gutenberg block

If we stick to your exact example, I would define the value as a custom property in an inline style: <div class=”item” style=”–my-gap: <?php echo esc_attr( $attributes[‘gap’] ); ?>;”> Then in CSS use a media query to use the property as the appropriate margin: .item { margin-bottom: var(–my-gap); } @media ( min-width: 768px ) { … 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.

Wrong mime types served

OK, so with the help of the comments to my question and some more digging around I have found (what I think is) the correct answer: The apache config needs to have the headers module enabled (“a2enmod headers”) and the mime module (“a2enmod mime”) and the .htaccess file needs to have sections as follows: <IfModule … Read more

wp_get_attachment_image with custom size not rendering possible 2x srcset image

It appears the problem was that image size variants were being capped by the max_srcset_image_width property that can be raised with the following: add_filter( ‘max_srcset_image_width’, ‘setSrcsetMaximumWidth’, 10, 2 ); function setSrcsetMaximumWidth( $max_srcset_image_width, $sizes_array ) { return 3200; } I was never aware of this before and have no idea why I never ran into this.

How to secure custom endpoint for rest api in WordPress

Add permission_callback parameter and set it to whatever authentication you want to apply. So, if you want to make it accessible to a user having manage_options capability, your code should be something like this- add_action(‘rest_api_init’, function(){ register_rest_route(‘fs/v1’, ‘posts’, [ ‘methods’ => ‘GET’, ‘callback’ => ‘fs_posts’, ‘permission_callback’ => function( $request ) { return current_user_can( ‘manage_options’ ); … Read more

Restricting page by user role

I’ll try to answer the question from beginning to end so for example, when user with customer role wants to login to example.com/about page, they will be redirected to another page. I want to do this in software, not with a plugin Note that you can turn the snippet into a plugin by adding this … Read more