SearchWP Documentation

Sehen Sie sich die Installationsanleitung an, durchsuchen Sie die Wissensdatenbank und erfahren Sie mehr über die vielen Hooks von SearchWP

searchwp\background_process\http_basic_auth_credentials

Seit: 4.1.0

Inhaltsverzeichnis

HTTP Basic Authentication-Anmeldeinformationen für den Indexer.

Hinweis: Diese Anmeldeinformationen sind für die HTTP Basic Authentication, nicht für Ihre WordPress-Anmeldedaten.

Parameter

Typ Parameter Standard Seit
Array $credentials
Schlüssel Typ Wert
Benutzername Zeichenkette Benutzername
Passwort Zeichenkette Passwort
4.1.0

Beispiele

All hooks should be added to your custom SearchWP Customizations Plugin.

HTTP Basic Authentication-Anmeldeinformationen angeben

<?php
// Provide HTTP Basic Authentication credentials to SearchWP (and WP Cron).
class MySearchWPBasicAuthCreds {
private $username = 'username'; // HTTP Basic Auth username.
private $password = 'password'; // HTTP Basic Auth password.
function __construct() {
// Provide HTTP Basic Authentication credentials to SearchWP.
add_filter(
'searchwp\background_process\http_basic_auth_credentials',
function( $credentials ) {
return [
'username' => $this->username,
'password' => $this->password,
];
}
);
// Also provide HTTP Basic Authentication credentials to WP Cron.
// This can be removed if handled elsewhere, otherwise *REQUIRED*
add_filter( 'cron_request', function( $cron_request ) {
if ( ! isset( $cron_request['args']['headers'] ) ) {
$cron_request['args']['headers'] = [];
}
if ( isset( $cron_request['args']['headers']['Authorization'] ) ) {
return $cron_request;
}
$cron_request['args']['headers']['Authorization'] = sprintf(
'Basic %s',
base64_encode( $this->username . ':' . $this->password )
);
return $cron_request;
}, 999 );
}
}
new MySearchWPBasicAuthCreds();

Anwendung dieses Codes