wpseek.com
WordPress开发者和主题制作者的搜索引擎



_wp_secrets_get › WordPress Function

Since7.2.0
已弃用n/a
› _wp_secrets_get ( $name, $version, $network )
访问:
  • private
参数: (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
返回:
  • (WP_Secret|null|WP_Error)
定义在:
文档:

Shared implementation behind wp_get_secret() and wp_get_network_secret().



源码

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 );
}