wpseek.com
A WordPress-centric search engine for devs and theme authors



_wp_secrets_get › WordPress Function

Since7.2.0
Deprecatedn/a
› _wp_secrets_get ( $name, $version, $network )
Parameters: (3)
  • (string) $name The secret's name.
    Required: Yes
  • (string) $version A WP_Secret_Version constant.
    Required: Yes
  • (bool) $network Whether this is a network-scope secret.
    Required: Yes
Returns:
  • (WP_Secret|null|WP_Error)
Defined at:
Codex:

Shared implementation behind wp_get_secret() and wp_get_network_secret().



Source

function _wp_secrets_get( string $name, string $version, bool $network ) {
	/*
	 * Checked here rather than inside the provider: this is a contract between
	 * the API and its caller, and asking every provider to re-validate a core
	 * constant would be duplicated work that a third-party provider could
	 * silently skip.
	 */
	if ( ! in_array( $version, array( WP_Secret_Version::CURRENT, WP_Secret_Version::PREVIOUS ), true ) ) {
		_doing_it_wrong(
			__FUNCTION__,
			__( 'The version must be WP_Secret_Version::CURRENT or WP_Secret_Version::PREVIOUS.' ),
			'7.2.0'
		);

		return new WP_Error(
			WP_SECRETS_ERROR_INVALID_ARGUMENT,
			__( 'The version must be WP_Secret_Version::CURRENT or WP_Secret_Version::PREVIOUS.' )
		);
	}

	return _wp_secrets_get_provider()->get( $name, $version, $network );
}