ms_cookie_constants()定义多站点的cookie

目录

描述

Defines Multisite cookie constants.

ms_cookie_constants() 描述

用法

<?php ms_cookie_constants() ?>

ms_cookie_constants() 用法

参数

This function does not accept any parameters

ms_cookie_constants() 参数

示例

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */

ms_cookie_constants() 示例

注意

Constants set: COOKIEPATH, SITECOOKIEPATH, ADMIN_COOKIE_PATH, COOKIE_DOMAIN

ms_cookie_constants() 注意

历史

添加于 版本: 3.0.0

ms_cookie_constants() 历史

源文件

ms_cookie_constants() 函数的代码位于 wp-includes/ms-default-constants.php

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Defines Multisite cookie constants.
 *
 * @since 3.0.0
 */
function ms_cookie_constants(  ) {
	$current_site = get_current_site();

	/**
	 * @since 1.2.0
	 */
	if ( !defined( 'COOKIEPATH' ) )
		define( 'COOKIEPATH', $current_site->path );

	/**
	 * @since 1.5.0
	 */
	if ( !defined( 'SITECOOKIEPATH' ) )
		define( 'SITECOOKIEPATH', $current_site->path );

	/**
	 * @since 2.6.0
	 */
	if ( !defined( 'ADMIN_COOKIE_PATH' ) ) {
		if ( ! is_subdomain_install() || trim( parse_url( get_option( 'siteurl' ), PHP_URL_PATH ), '/' ) ) {
			define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH );
		} else {
			define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
		}
	}

	/**
	 * @since 2.0.0
	 */
	if ( !defined('COOKIE_DOMAIN') && is_subdomain_install() ) {
		if ( !empty( $current_site->cookie_domain ) )
			define('COOKIE_DOMAIN', '.' . $current_site->cookie_domain);
		else
			define('COOKIE_DOMAIN', '.' . $current_site->domain);
	}
}

ms_cookie_constants() 源文件

相关