SearchWP Documentation

インストールガイドを表示したり、ナレッジベースを参照したり、SearchWPの多くのフックについて確認したりできます。

searchwp\indexer\http_basic_auth_credentials

4.0.0以降

このフックは非推奨です
代わりに searchwp\background_process\http_basic_auth_credentials を使用してください。

インデクサーにHTTP基本認証の認証情報を教える。

注意: この認証情報はHTTP基本認証用であり、WordPressのログイン認証情報ではありません。

パラメータ

タイプ パラメータ デフォルト 提供開始
配列 $credentials
キー タイプ
ユーザー名 文字列 ユーザー名
パスワード 文字列 パスワード
4.0.0

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

HTTP基本認証の認証情報を提供する

<?php
// @deprecated
// @see https://searchwp.com/documentation/hooks/searchwp-background_process-http_basic_auth_credentials/
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\indexer\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 )
);
}, 999 );
}
}
new MySearchWPBasicAuthCreds();

このコードの使用方法