WP_REST_Plugins_Controller::is_filesystem_available()protectedWP 5.5.0

Determine if the endpoints are available.

Only the 'Direct' filesystem transport, and SSH/FTP when credentials are stored are supported at present.

Метод класса: WP_REST_Plugins_Controller{}

Хуков нет.

Возвращает

true|WP_Error. True if filesystem is available, WP_Error otherwise.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->is_filesystem_available();

Список изменений

С версии 5.5.0 Введена.

Код WP_REST_Plugins_Controller::is_filesystem_available() WP 6.5.2

protected function is_filesystem_available() {
	$filesystem_method = get_filesystem_method();

	if ( 'direct' === $filesystem_method ) {
		return true;
	}

	ob_start();
	$filesystem_credentials_are_stored = request_filesystem_credentials( self_admin_url() );
	ob_end_clean();

	if ( $filesystem_credentials_are_stored ) {
		return true;
	}

	return new WP_Error( 'fs_unavailable', __( 'The filesystem is currently unavailable for managing plugins.' ), array( 'status' => 500 ) );
}