wp_remote_get() not retrieving pages properly

The HTTP request sent by wp_remote_get() is different from the one that a browser sends. E.g the user-agent is different (see documentation). Some websites respond differently based on this. The second argument of wp_remote_get() allows one to alter the request. Websites might also respond differently depending on the IP or the number of requests received … Read more

When does remove_filter not work?

Well this is somehow a very specific topic that is bound to a WordPress development issue. I strongly suggest you to keep track of the trac ticket if you liked my article. That is the best thing you can do I assume for finding out when the problems come into play as well how to … Read more

How to fix ob_end_flush() error?

I also had this issue with wordpress and couldn’t properly resolve it. Ended up with this filthy hack to prevent the error from showing: // Get the current error reporting level $e_level = error_reporting(); // Turn off error reporting error_reporting(0); ob_start(); echo ‘This is a horrible hack’; $buffer_contents = ob_get_clean(); ob_end_flush(); // Reset error reporting … Read more

Showing error “Function create_function() is deprecated”

Problem lies in your theme. It’s not compatible with PHP 7.2. In this version the create_function is deprecated and you should use Anonymous Functions instead. So for example instead of something like this: $callback = create_function(”, ‘echo “‘.str_replace(‘”‘, ‘\”‘, $section[‘desc’]).'”;’); You should use this: $callback = function() { echo str_replace(‘”‘, ‘\”‘, $section[‘desc’]); };

Why on Earth am I getting “undefined_index” errors?

It’s a common PHP error, usually when you try to access an array member with a non-existent key; $array = array( ‘hello’ => ‘world’ ); echo $array[‘foobar’]; // undefined index You should check for the key first with isset( $array[‘foobar’] ); UPDATE: In this case, I would chuck in a loop that sets-up the variables … Read more

Is it possible to disable caching of an option when using w3 total cache?

okay, here we go. try this: in your functions.php modify the behaviour of ai1ec_options: $ai1ec_options = get_option(‘ai1ec_options’); delete_option(‘ai1ec_options’); add_option(‘ai1ec_options’, $ai1ec_options, ”, ‘no’); // thanks for your suggestion 🙂 be careful though, as you might lose your set options, so be sure to get them from the database first. or create a backup option. afterwards, clear … Read more

How to use WP_Error $data argument?

$this->error_data[$code] … the WP_Error object holds $data in an array and $code is the key. The add_data method clearly states: The error code can only contain one error data. But the $data (mixed) can be an array or an object and carry as many keys/properties as you need. It’s up to your handlers how they … Read more

Debug mode shows Strict Standards

Just don’t set WP_DEBUG to TRUE. The error level is set in wp_debug_mode(), which is called in wp-settings.php before any plugins are loaded. If you leave the default values WordPress will set it to: error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR ); But you … Read more