Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
WC_Install::create_files()
Create files/directories.
Description Description
Source Source
File: includes/class-wc-install.php
private static function create_files() { // Bypass if filesystem is read-only and/or non-standard upload system is used. if ( apply_filters( 'woocommerce_install_skip_create_files', false ) ) { return; } // Install files and folders for uploading files and prevent hotlinking. $upload_dir = wp_get_upload_dir(); $download_method = get_option( 'woocommerce_file_download_method', 'force' ); $files = array( array( 'base' => $upload_dir['basedir'] . '/woocommerce_uploads', 'file' => 'index.html', 'content' => '', ), array( 'base' => WC_LOG_DIR, 'file' => '.htaccess', 'content' => 'deny from all', ), array( 'base' => WC_LOG_DIR, 'file' => 'index.html', 'content' => '', ), array( 'base' => $upload_dir['basedir'] . '/woocommerce_uploads', 'file' => '.htaccess', 'content' => 'redirect' === $download_method ? 'Options -Indexes' : 'deny from all', ), ); foreach ( $files as $file ) { if ( wp_mkdir_p( $file['base'] ) && ! 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 } } } // Create attachment for placeholders. self::create_placeholder_image(); }