I am looking to override a function in functions.php through a theme or plugin. Specifically, is_ssl(), which does not have any filter or action hooks. Obviously, the easy why would be to update functions.php itself, but this will leave issues with upgrade and compatibility. How could this be done.

Edit:
The goal is to overwrite is_ssl() function to return true when specific flag is set in the request header.

Is it possible with the override-function?

4 Answers
4

If you look at the source of the is_ssl() function you’ll see it checks various $_SERVER variables. Therefore, you could try adding this to a plugin:

if ( isset( $_SERVER['HTTP_MY_CUSTOM_HEADER'] ) )
  $_SERVER['HTTPS'] = 'on';

You’d need to call that code as early as possible, ie. directly in the plugin body rather than on a hook.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *