Difference between `is_serialized_string` and `is_serialized`

If you check the source code of is_serialized() and is_serialized_string(), the difference will become clear. is_serialized() checks if the data is serialized, whereas is_serialized_string() checks, if the serialized data is of type string. var_dump( is_serialized( serialize(NULL) ) ); // true var_dump( is_serialized_string( serialize(NULL) ) ); // false var_dump( is_serialized( serialize(array(1,2,3)) ) ); // true var_dump( … Read more

WordPress Codex has different number of arguments for get_previous_post and get_next_post functions. Why?

The Codex does not document the $taxonomy argument. Without digging into it, my assumption would be that maybe it originally was not one of the arguments and no one ever bothered to change the Codex. The Codex, while still a tremendous resource of information, is (1) user generated/curated content and can be prone to mistakes, … Read more

*Just curious* I erroneously used hook add_action() instead of add_filter() and there was no error and the result was correct. Why is that?

add_action() uses add_filter() behind the hood. function add_action( $hook_name, $callback, $priority = 10, $accepted_args = 1 ) { return add_filter( $hook_name, $callback, $priority, $accepted_args ); } Source: https://developer.wordpress.org/reference/functions/add_action/ So basically it doesn’t matter if you use add_filter or add_action. But it doesn’t mean you should, using the appropriate function for a event will make your … Read more

What does the raw value for the get_bloginfo’s filter argument exactly do?

We have the following filters added by default (source) add_filter( ‘bloginfo’, ‘wptexturize’ ); add_filter( ‘bloginfo’, ‘convert_chars’ ); add_filter( ‘bloginfo’, ‘esc_html’ ); The bloginfo filter (source) is applied on the get_bloginfo() output, in the display mode, except for the url that has it’s own bloginfo_url filter. The core isn’t using that url filter currently and there’s … Read more

Add Option if Not Exists

The logic on the IF THEN ELSE does seem a bit wonky. If I’m reading it correctly… The call to get_option( $option_name ) will return FALSE if the option does not exist or if it has no value. So the IF would be executed: when the option doesn’t exist and $new_value != FALSE the option … Read more