Automattic\WooCommerce\Admin
ReportCSVExporter::maybe_create_directory()
Create the directory for reports if it does not yet exist.
Method of the class: ReportCSVExporter{}
No Hooks.
Return
null
. Nothing (null).
Usage
$result = ReportCSVExporter::maybe_create_directory();
ReportCSVExporter::maybe_create_directory() ReportCSVExporter::maybe create directory code WC 9.7.1
public static function maybe_create_directory() { $reports_dir = self::get_reports_directory(); $files = array( array( 'base' => $reports_dir, 'file' => '.htaccess', 'content' => 'DirectoryIndex index.php index.html' . PHP_EOL . 'deny from all', ), array( 'base' => $reports_dir, 'file' => 'index.html', 'content' => '', ), ); foreach ( $files as $file ) { if ( ! file_exists( trailingslashit( $file['base'] ) ) ) { wp_mkdir_p( $file['base'] ); } if ( ! file_exists( trailingslashit( $file['base'] ) . $file['file'] ) ) { $file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'wb' ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_read_fopen if ( $file_handle ) { fwrite( $file_handle, $file['content'] ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fwrite fclose( $file_handle ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose } } } }