wp_set_lang_dir

函数
wp_set_lang_dir ( No parameters )
Access
Private
定义位置
相关方法
wp_get_upload_dirwp_get_image_editorwp_kses_hairwp_upload_dirwp_reset_vars
引入
3.0.0
弃用
-

wp_set_lang_dir: 这个函数为一个给定的语言设置语言方向。该方向是’ltr’(从左到右)或’rtl’(从右到左)。

设置语言目录的位置。

要手动设置目录,在wp-config.php中定义`WP_LANG_DIR`常量。

如果语言目录存在于`WP_CONTENT_DIR`中,它将被使用。否则,语言目录将被假定为存在于`WPINC`中。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_set_lang_dir() {
if ( ! defined( 'WP_LANG_DIR' ) ) {
if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) || ! @is_dir( ABSPATH . WPINC . '/languages' ) ) {
/**
* Server path of the language directory.
*
* No leading slash, no trailing slash, full path, not relative to ABSPATH
*
* @since 2.1.0
*/
define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' );
if ( ! defined( 'LANGDIR' ) ) {
// Old static relative path maintained for limited backward compatibility - won't work in some cases.
define( 'LANGDIR', 'wp-content/languages' );
}
} else {
/**
* Server path of the language directory.
*
* No leading slash, no trailing slash, full path, not relative to `ABSPATH`.
*
* @since 2.1.0
*/
define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' );
if ( ! defined( 'LANGDIR' ) ) {
// Old relative path maintained for backward compatibility.
define( 'LANGDIR', WPINC . '/languages' );
}
}
}
}
function wp_set_lang_dir() { if ( ! defined( 'WP_LANG_DIR' ) ) { if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) || ! @is_dir( ABSPATH . WPINC . '/languages' ) ) { /** * Server path of the language directory. * * No leading slash, no trailing slash, full path, not relative to ABSPATH * * @since 2.1.0 */ define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' ); if ( ! defined( 'LANGDIR' ) ) { // Old static relative path maintained for limited backward compatibility - won't work in some cases. define( 'LANGDIR', 'wp-content/languages' ); } } else { /** * Server path of the language directory. * * No leading slash, no trailing slash, full path, not relative to `ABSPATH`. * * @since 2.1.0 */ define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' ); if ( ! defined( 'LANGDIR' ) ) { // Old relative path maintained for backward compatibility. define( 'LANGDIR', WPINC . '/languages' ); } } } }
function wp_set_lang_dir() {
	if ( ! defined( 'WP_LANG_DIR' ) ) {
		if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) || ! @is_dir( ABSPATH . WPINC . '/languages' ) ) {
			/**
			 * Server path of the language directory.
			 *
			 * No leading slash, no trailing slash, full path, not relative to ABSPATH
			 *
			 * @since 2.1.0
			 */
			define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' );
			if ( ! defined( 'LANGDIR' ) ) {
				// Old static relative path maintained for limited backward compatibility - won't work in some cases.
				define( 'LANGDIR', 'wp-content/languages' );
			}
		} else {
			/**
			 * Server path of the language directory.
			 *
			 * No leading slash, no trailing slash, full path, not relative to `ABSPATH`.
			 *
			 * @since 2.1.0
			 */
			define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' );
			if ( ! defined( 'LANGDIR' ) ) {
				// Old relative path maintained for backward compatibility.
				define( 'LANGDIR', WPINC . '/languages' );
			}
		}
	}
}

常见问题

FAQs
查看更多 >