
网络开发中的Git:了解一个项目的典型工作流程
get_locale ( No parameters )
get_locale函数用于检索WordPress站点的当前区域设置: 这个函数可以用来确定网站的语言和格式化设置。
检索当前的locale。
如果locale已经设置,那么它将在{@see ‘locale’}过滤钩中过滤locale,并返回该值。
如果locale还没有设置,那么如果定义了WPLANG常量,就会使用它。然后通过{@see ‘locale’}过滤钩子进行过滤,并且 locale全局设置的值并返回locale。
获取locale的过程应该只做一次,但locale将始终使用{@see ‘locale’}钩子进行过滤。
function get_locale() { global $locale, $wp_local_package; if ( isset( $locale ) ) { /** This filter is documented in wp-includes/l10n.php */ return apply_filters( 'locale', $locale ); } if ( isset( $wp_local_package ) ) { $locale = $wp_local_package; } // WPLANG was defined in wp-config. if ( defined( 'WPLANG' ) ) { $locale = WPLANG; } // If multisite, check options. if ( is_multisite() ) { // Don't check blog option when installing. if ( wp_installing() ) { $ms_locale = get_site_option( 'WPLANG' ); } else { $ms_locale = get_option( 'WPLANG' ); if ( false === $ms_locale ) { $ms_locale = get_site_option( 'WPLANG' ); } } if ( false !== $ms_locale ) { $locale = $ms_locale; } } else { $db_locale = get_option( 'WPLANG' ); if ( false !== $db_locale ) { $locale = $db_locale; } } if ( empty( $locale ) ) { $locale = 'en_US'; } /** * Filters the locale ID of the WordPress installation. * * @since 1.5.0 * * @param string $locale The locale ID. */ return apply_filters( 'locale', $locale ); }