wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_load_secrets_dropin is private and should not be used in themes or plugins directly.
wp_load_secrets_dropin › WordPress Function
Since7.2.0
Deprecatedn/a
› wp_load_secrets_dropin ( No parameters )
| Access: |
|
| Defined at: |
|
| Codex: |
Loads the secrets.php drop-in, if one exists, and records whether it left the Secrets API's provider, store, and keyring overrides in a usable state.
Runs once, before must-use plugins load, so that every class a drop-in's classes extend already exists and every plugin sees the drop-in's provider. The drop-in sets its overrides in the$wp_secrets_provider, $wp_secrets_store
and $wp_secrets_keyring globals. They are declared global before the require, so
a plain assignment such as $wp_secrets_keyring = new My_Keyring(); works.
Sets $GLOBALS['wp_secrets_dropin_loaded'] as soon as the file is found, whether
or not it then loads cleanly: wp_using_secrets_dropin() reports presence, not
health.
Sets $GLOBALS['wp_secrets_dropin_broken'] when the require throws, or when any of
$GLOBALS['wp_secrets_provider'], $GLOBALS['wp_secrets_store'], or
$GLOBALS['wp_secrets_keyring'] is set to something that does not extend its
class. A global left unset is fine: a drop-in that overrides only the keyring
leaves the other two alone. Once the flag is set, every Secrets API operation
returns WP_Error for the rest of the request rather than falling back to the
default provider, so a broken drop-in reads as unreachable, never as absent.
PHP treats a class that extends an abstract class but omits one of its abstract
methods as an uncatchable fatal error, even inside the try/catch around the require. That case
cannot be intercepted from PHP code.Related Functions: wp_using_secrets_dropin, wp_load_core_site_options, _wp_secrets_retire, wp_list_secrets, wp_load_press_this
Source
function wp_load_secrets_dropin(): void {
static $loaded = false;
if ( $loaded ) {
return;
}
$loaded = true;
$dropin_path = WP_CONTENT_DIR . '/secrets.php';
if ( ! file_exists( $dropin_path ) ) {
return;
}
$GLOBALS['wp_secrets_dropin_loaded'] = true;
/*
* The drop-in is required inside this function. Declaring the overrides global
* lets it set them as plain variables, as db.php does with $wpdb.
*/
global $wp_secrets_provider, $wp_secrets_store, $wp_secrets_keyring;
try {
require $dropin_path;
} catch ( Throwable $e ) {
$GLOBALS['wp_secrets_dropin_broken'] = true;
return;
}
if ( isset( $GLOBALS['wp_secrets_store'] ) && ! ( $GLOBALS['wp_secrets_store'] instanceof WP_Secrets_Store ) ) {
$GLOBALS['wp_secrets_dropin_broken'] = true;
}
if ( isset( $GLOBALS['wp_secrets_keyring'] ) && ! ( $GLOBALS['wp_secrets_keyring'] instanceof WP_Secrets_Keyring ) ) {
$GLOBALS['wp_secrets_dropin_broken'] = true;
}
if ( isset( $GLOBALS['wp_secrets_provider'] ) && ! ( $GLOBALS['wp_secrets_provider'] instanceof WP_Secrets_Provider ) ) {
$GLOBALS['wp_secrets_dropin_broken'] = true;
}
}