Skip to content

Commit

Permalink
Define constants as env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
iazema committed Jul 26, 2024
1 parent fe54d31 commit 5a3c1cd
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions default-searchwp.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
return;
}

const HTTP_USER = 'XXXXXXXX';
const HTTP_PWD = 'ZZZZZZZZ';
// Constants to be defined as env vars
if ( ! defined( SEARCHWP_AUTH_USER ) || ! defined( SEARCHWP_AUTH_PWD ) ) {
return;
}

add_filter( 'searchwp\indexer\alternate', '__return_true' );

Expand All @@ -45,8 +47,8 @@
function () {
return [
// Customize with basic auth credentials
'username' => HTTP_USER,
'password' => HTTP_PWD,
'username' => SEARCHWP_AUTH_USER,
'password' => SEARCHWP_AUTH_PWD,
];
}
);
Expand All @@ -65,7 +67,7 @@ function ( $cron_request ) {
$cron_request['args']['headers']['Authorization'] = sprintf(
'Basic %s',
// Customize with basic auth credentials
base64_encode( HTTP_USER . ':' . HTTP_PWD ) //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
base64_encode( SEARCHWP_AUTH_USER . ':' . SEARCHWP_AUTH_PWD ) //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
);

return $cron_request;
Expand Down

0 comments on commit 5a3c1cd

Please sign in to comment.