wpsc_get_auth_cookies()WPSCache 1.0

Хуков нет.

Возвращает

null. Ничего (null).

Использование

wpsc_get_auth_cookies();

Код wpsc_get_auth_cookies() WPSCache 1.12.4

function wpsc_get_auth_cookies() {
	static $cached_cookies;

	if ( isset( $cached_cookies ) && is_array( $cached_cookies ) ) {
		return $cached_cookies;
	}

	$cookies = array_keys( $_COOKIE );
	if ( empty( $cookies ) ) {
		return array();
	}

	$auth_cookies      = array();
	$duplicate_cookies = array();

	$wp_cookies = array(
		'AUTH_COOKIE'        => 'wordpress_',
		'SECURE_AUTH_COOKIE' => 'wordpress_sec_',
		'LOGGED_IN_COOKIE'   => 'wordpress_logged_in_',
	);

	foreach ( $wp_cookies as $cookie_const => $cookie_prefix ) {
		$cookie_key = strtolower( $cookie_const );

		if ( defined( $cookie_const ) ) {
			if ( in_array( constant( $cookie_const ), $cookies, true ) ) {
				$auth_cookies[ $cookie_key ] = constant( $cookie_const );
			}

			continue;
		}

		$found_cookies = preg_grep( '`^' . preg_quote( $cookie_prefix, '`' ) . '([0-9a-f]+)$`', $cookies );

		if ( count( $found_cookies ) === 1 ) {
			$auth_cookies[ $cookie_key ] = reset( $found_cookies );
		} elseif ( count( $found_cookies ) > 1 ) {
			$duplicate_cookies           = array_merge( $duplicate_cookies, $found_cookies );
			$auth_cookies[ $cookie_key ] = $found_cookies;
		}
	}

	$cookie_hash   = defined( 'COOKIEHASH' ) ? COOKIEHASH : '';
	$other_cookies = array(
		'comment_cookie'  => 'comment_author_',
		'postpass_cookie' => 'wp-postpass_',
	);

	foreach ( $other_cookies as $cookie_key => $cookie_prefix ) {

		if ( $cookie_hash ) {
			if ( in_array( $cookie_prefix . $cookie_hash, $cookies, true ) ) {
				$auth_cookies[ $cookie_key ] = $cookie_prefix . $cookie_hash;
			}

			continue;
		}

		$found_cookies = preg_grep( '`^' . preg_quote( $cookie_prefix, '`' ) . '([0-9a-f]+)$`', $cookies );

		if ( count( $found_cookies ) === 1 ) {
			$auth_cookies[ $cookie_key ] = reset( $found_cookies );
		} elseif ( count( $found_cookies ) > 1 ) {
			$duplicate_cookies           = array_merge( $duplicate_cookies, $found_cookies );
			$auth_cookies[ $cookie_key ] = $found_cookies;
		}
	}

	if ( ! $duplicate_cookies ) {
		$cached_cookies = $auth_cookies;
	}

	if ( empty( $auth_cookies ) ) {
		wp_cache_debug( 'wpsc_get_auth_cookies: no auth cookies detected', 5 );
	} elseif ( $duplicate_cookies ) {
		wp_cache_debug( 'wpsc_get_auth_cookies: duplicate cookies detected( ' . implode( ', ', $duplicate_cookies ) . ' )', 5 );
	} else {
		wp_cache_debug( 'wpsc_get_auth_cookies: cookies detected: ' . implode( ', ', $auth_cookies ), 5 );
	}

	return $auth_cookies;
}