How can I conditionally add the filter option_home?

Assuming that if wp_sitemaps_enabled has a filter and it has that because we wanted to set it to false, otherwise it defaults to true for public sites. So I would just use and check whether it is filtered or not: add_filter( ‘wp_sitemaps_enabled’, ‘__return_false’ ); if (has_filter( ‘wp_sitemaps_enabled’) === true) { add_filter(‘option_home’, ‘any_callback_function’); } else { … Read more

Using the REST API filter, including two meta_queries breaks the response for one custom post type

Oddly, the cause of the problem seems to be the quotation marks around the comparison parameter. For example filter[meta_query][0][compare]=%27=%27 now needs to be filter[meta_query][0][compare]==. When only matching one meta value, this is not necessary, when matching two, this is, now, necessary. :/ Update: I realised that my hosting provider changed the version of Linux on … Read more

How to use filter in this situation, can not modify the structure using filter

So you’re trying to call the hide_empty_fields() and maybe_add_disclaimer_and_courtesy() methods in the Register_Impress_Shortcodes class, from within a global function, and it’s not impossible to call class methods from within such global functions, but you cannot use $this in your function because $this is only available from within a class method which is called from within … Read more

Is there a way to check if the ‘wp_sitemaps_enabled’ is true or false?

The wp_sitemaps_enabled filter is filtering the value returned by WP_Sitemaps::sitemaps_enabled(). You can get the global instance of WP_Sitemaps with wp_sitemaps_get_server, which means you can get the value of sitemaps_enabled() like this: $sitemaps = wp_sitemaps_get_server(); $enabled = $sitemaps->sitemaps_enabled(); if ( $enabled ) { }