<?php
/*
 * This file belongs to the YIT Framework.
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-3.0.txt
 */


$access_key = ( get_option( 'YITH_WC_amazon_s3_storage_connection_access_key_text' ) ? get_option( 'YITH_WC_amazon_s3_storage_connection_access_key_text' ) : null );
$secret_access_key = ( get_option( 'YITH_WC_amazon_s3_storage_connection_secret_access_key_text' ) ? get_option( 'YITH_WC_amazon_s3_storage_connection_secret_access_key_text' ) : null );

if ( empty( $access_key ) || empty( $secret_access_key ) ) {
	update_option( 'YITH_WC_amazon_s3_storage_connection_success', 0 );
}else{
	require_once( constant( 'YITH_WC_AMAZON_S3_STORAGE_PATH' ) . 'includes/class.yith-wc-amazon-s3-storage-aws-s3-client.php' );
	$aws_s3_client = new YITH_WC_Amazon_S3_Storage_Aws_S3_Client( $access_key, $secret_access_key );

	$buckets = $aws_s3_client->Show_Buckets();
}


$settings = array(
	'generalsettings' => array(
		'general-options' => array(
			'type'  => 'title',
			'desc'  => '',
		),
		'yith-amazon-s3-storage-bucket-name'      => array(
			'id'        => 'YITH_WC_amazon_s3_storage_connection_bucket_selected_select',
			'name'      => __( 'Set a bucket name', 'yith-test-plugin' ),
			'type'      => 'yith-field',
			'yith-type' => 'custom',
			'action'    => 'YITH_WC_amazon_s3_storage_bucket_options',
			'desc'      => __( 'Select the S3 bucket name where to upload all the files. If you don\'t know how to create a bucket, <a href="https://aws.amazon.com/blogs/security/wheres-my-secret-access-key/" target="_blank">
                    you can click here
                </a>', 'yith-amazon-s3-storage' )
		),

		'yith-amazon-s3-storage-copy-file-to-s3'        => array(
			'id'        => 'YITH_WC_amazon_s3_storage_copy_file_s3_checkbox',
			'name'      => __( 'Copy file to S3', 'yith-amazon-s3-storage' ),
			'type'      => 'yith-field',
			'yith-type' => 'checkbox',
			'desc'      => __( 'Copy files also to S3 The files uploaded to the media library will be added automatically to S3. The files that are already in the media library will NOT be uploaded to S3', 'yith-amazon-s3-storage' ),
		),
		'yith-amazon-s3-storage-replace-url'        => array(
			'id'        => 'YITH_WC_amazon_s3_storage_replace_url_checkbox',
			'name'      => __( 'Replace URL', 'yith-amazon-s3-storage' ),
			'type'      => 'yith-field',
			'yith-type' => 'checkbox',
			'desc'      => __( 'Files will be served by S3 The URLs of the files will be automatically replaced to be downloaded from S3 and not from your WordPress installation', 'yith-amazon-s3-storage' ),
		),
		'yith-amazon-s3-storage-remove-from-server'        => array(
			'id'        => 'YITH_WC_amazon_s3_storage_remove_from_server_checkbox',
			'name'      => __( 'Remove from server', 'yith-amazon-s3-storage' ),
			'type'      => 'yith-field',
			'yith-type' => 'checkbox',
			'desc'      => __( 'Remove from the server The files uploaded to S3 amazon will be deleted from your server', 'yith-amazon-s3-storage' ),
		),
		'general-options-end'          => array(
			'type' => 'sectionend',
			'id'   => 'yith-wcbk-general-options'
		),
	)
);

return apply_filters( 'yith_wc_amazon_s3_storage_general_settings_options', $settings );