Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
What is wrong with using filter? Developers can modify default value. –  Mamaduka Mar 5 '12 at 16:39

1 Answer 1

up vote 4 down vote accepted

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.

share|improve this answer
    
Thanks for the clear explanation :) –  Omar Abid Mar 5 '12 at 20:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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