Created
April 17, 2023 13:00
-
-
Save patrickposner/ebafa8d8012ac792ecc844abcd965973 to your computer and use it in GitHub Desktop.
Freemius Basic Auth License Activation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* FREEMIUS API BASIC AUTH WORKAROUND */ | |
add_filter( 'http_request_args', 'my_http_request_args_filter', 1, 2 ); | |
add_filter( 'http_request_args', 'my_http_request_args_filter', 9999, 2 ); | |
function my_http_request_args_filter( $parsed_args, $url ) { | |
if ( false === strpos( $url, '://api.freemius.com' ) ) { | |
return $parsed_args; | |
} | |
if ( empty( $parsed_args['headers'] ) ) { | |
return $parsed_args; | |
} | |
foreach ( $parsed_args['headers'] as $key => $value ) { | |
if ( 'Authorization' === $key ) { | |
$parsed_args['headers']['Authorization2'] = $value; | |
} else if ( 'Authorization2' === $key ) { | |
$parsed_args['headers']['Authorization'] = $value; | |
unset($parsed_args['headers'][$key]); | |
} | |
} | |
return $parsed_args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment