Automattic\WooCommerce\Internal\Admin\Logging

Settings::get_filesystem_settings_definitions()privateWC 1.0

The definitions used by WC_Admin_Settings to render settings related to filesystem log handlers.

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

Хуков нет.

Возвращает

Массив.

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

// private - только в коде основоного (родительского) класса
$result = $this->get_filesystem_settings_definitions(): array;

Код Settings::get_filesystem_settings_definitions() WC 9.7.1

private function get_filesystem_settings_definitions(): array {
	$location_info = array();
	$directory     = self::get_log_directory();

	$status_info = array();
	try {
		$filesystem = FilesystemUtil::get_wp_filesystem();
		if ( $filesystem instanceof WP_Filesystem_Direct ) {
			$status_info[] = __( '✅ Ready', 'woocommerce' );
		} else {
			$status_info[] = __( '⚠️ The file system is not configured for direct writes. This could cause problems for the logger.', 'woocommerce' );
			$status_info[] = __( 'You may want to switch to the database for log storage.', 'woocommerce' );
		}
	} catch ( Exception $exception ) {
		$status_info[] = __( '⚠️ The file system connection could not be initialized.', 'woocommerce' );
		$status_info[] = __( 'You may want to switch to the database for log storage.', 'woocommerce' );
	}

	$location_info[] = sprintf(
		// translators: %s is a location in the filesystem.
		__( 'Log files are stored in this directory: %s', 'woocommerce' ),
		sprintf(
			'<code>%s</code>',
			esc_html( $directory )
		)
	);

	if ( ! wp_is_writable( $directory ) ) {
		$location_info[] = __( '⚠️ This directory does not appear to be writable.', 'woocommerce' );
	}

	$location_info[] = sprintf(
		// translators: %s is an amount of computer disk space, e.g. 5 KB.
		__( 'Directory size: %s', 'woocommerce' ),
		size_format( wc_get_container()->get( FileController::class )->get_log_directory_size() )
	);

	return array(
		'file_start'    => array(
			'title' => __( 'File system settings', 'woocommerce' ),
			'id'    => self::PREFIX . 'settings',
			'type'  => 'title',
		),
		'file_status'   => array(
			'title' => __( 'Status', 'woocommerce' ),
			'type'  => 'info',
			'text'  => implode( "\n\n", $status_info ),
		),
		'log_directory' => array(
			'title' => __( 'Location', 'woocommerce' ),
			'type'  => 'info',
			'text'  => implode( "\n\n", $location_info ),
		),
		'entry_format'  => array(),
		'file_end'      => array(
			'id'   => self::PREFIX . 'settings',
			'type' => 'sectionend',
		),
	);
}