Automattic\WooCommerce\Internal\Admin\Logging\FileV2

FileController::get_file_sourcespublicWC 1.0

Get a list of sources for existing log files.

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

Хуков нет.

Возвращает

Массив|WP_Error.

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

$FileController = new FileController();
$FileController->get_file_sources();

Код FileController::get_file_sources() WC 10.5.2

public function get_file_sources() {
	$paths = glob( Settings::get_log_directory() . '*.log' );
	if ( false === $paths ) {
		return new WP_Error(
			'wc_log_directory_error',
			__( 'Could not access the log file directory.', 'woocommerce' )
		);
	}

	$all_sources = array_map(
		function( $path ) {
			$file = new File( $path );
			return $file->is_readable() ? $file->get_source() : null;
		},
		$paths
	);

	return array_unique( array_filter( $all_sources ) );
}