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`中。

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
檢視更多 >