检查WordPress是否可以访问文件系统而无需请求凭据。

原型

wp_can_install_language_pack()

返回值

(bool)  成功时返回true,失败时返回false。

源文件

路径:wp-admin/includes/translation-install.php

<?php
...
function wp_can_install_language_pack() {
	if ( ! wp_is_file_mod_allowed( 'can_install_language_pack' ) ) {
		return false;
	}
	require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
	$skin = new Automatic_Upgrader_Skin;
	$upgrader = new Language_Pack_Upgrader( $skin );
	$upgrader->init();
	$check = $upgrader->fs_connect( array( WP_CONTENT_DIR, WP_LANG_DIR ) );
	if ( ! $check || is_wp_error( $check ) ) {
		return false;
	}
	return true;
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/wp_can_install_language_pack/