I have run into some WordPress code which does POST requests to API sites and in the POST parameters for the SSL property it has

$params = array( 'body' => $_POST, 'sslverify' => apply_filters('https_local_ssl_verify', false));

So why not simply put false or true?

  • What is wrong with using filter? Developers can modify default value. – Mamaduka Mar 5 '12 at 16:39

The apply_filters() function lets plugins and themes override the value. So yes, you could manually set sslverify to false. The code snippet you included will set it to false in the absence of any filter.

Let's say I have a plugin that wants to force it to true. I would add this:

add_filter( 'https_local_ssl_verify', '__return_true' );

The __return_true() function is a special function in WordPress that automatically returns true. So if I add this code to a plugin or my theme's funtions.php file, it will force your code above to set 'sslverify' => true.

It all depends on your local setup and what you're trying to do with the site. The use of apply_filters() merely makes things as flexible as possible.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.