get_option() filtering and getting out of recursion

Usually I remove the filter, then add it back on afterwards; function _my_custom_option( $option ) { remove_filter( ‘pre_option_name’, ‘_my_custom_option’ ); // do what you like with $option add_filter( ‘pre_option_name’, ‘_my_custom_option’ ); return $option; } add_filter( ‘pre_option_name’, ‘_my_custom_option’ );

Changing text within the Block Editor

Changing the “Post reverted to draft.” text In WordPress version 5.0, WordPress introduced a new post type label which has the key item_reverted_to_draft and it’s defined as: item_reverted_to_draft – Label used when an item is switched to a draft. Default is ‘Post reverted to draft.’ / ‘Page reverted to draft.’ Hence, as with any other … Read more

How do I use the ‘http_request_host_is_external’ filter

You can do this: add_filter( ‘http_request_host_is_external’, ‘__return_true’ ); However, note that this disables this security feature. If you know the host or url isn’t going to change and is always going to be that, you can be more secure by checking for that explicitly: add_filter( ‘http_request_host_is_external’, ‘allow_my_custom_host’, 10, 3 ); function allow_my_custom_host( $allow, $host, $url … Read more

Adding revision support to WooCommerce product content

As you pointed out already there is a filter. add_filter( ‘woocommerce_register_post_type_product’, ‘wpse_modify_product_post_type’ ); function wpse_modify_product_post_type( $args ) { $args[‘supports’][] = ‘revisions’; return $args; } Put that in your child theme’s functions.php file.

post_mime_types Filter not Working in List Mode

The problem lies in the attachment-filter= URL parameter. The slash between application/pdf (or else) is being escaped twice. When you replace the %252F with a slash or %2F the filter will work. The first escaping (/ becomes %2F) happens when WP is building the selectbox containing the mime types. The second one (%2F becomes %252F) … Read more

Custom Rewrite Rules Not Sticking

I am not completely sure why this happens but I have seen it too. In my plugin Opera Speed Dial Preview I had to add the rewrite rules on init too – that fixed it. Sometimes other plugins or later visits to the permalink page may reset your custom roles … reminds me to write … Read more