WC_Install::create_files() private WC 1.0
Create files/directories.
{} Это метод класса: WC_Install{}
Хуки из метода
Возвращает
Null. Ничего.
Использование
$result = WC_Install::create_files();
Код WC_Install::create_files() WC Install::create files WC 5.0.0
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();
}