forked from kish2011/DigitalOcean-Spaces-Sync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dos-settings-page.php
executable file
·184 lines (162 loc) · 9.58 KB
/
dos-settings-page.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<div class="dos__loader">
</div>
<div class="wrap">
<h1><?= __('DigitalOcean Spaces Sync Settings', 'dos'); ?></h1>
<div class="dos__message"></div>
<p><?= __('Type in your DigitalOcean Spaces container access information.', 'dos'); ?><br/>
<?= __('Don\'t have an account? <a href="https://goo.gl/SX2UwH">Create it</a>', 'dos'); ?></p>
<form method="POST" action="options.php">
<?php settings_fields('dos_settings'); ?>
<h2><?= __('Connection settings', 'dos'); ?></h2>
<table class="form-table">
<tbody>
<tr>
<th scope="row"><label for="dos_key"><?= __('DO Spaces Key', 'dos'); ?>:</label></th>
<td><input id="dos_key" name="dos_key" type="text" class="regular-text code" value="<?= esc_attr( defined( 'DOS_KEY' ) ? DOS_KEY : get_option('dos_key') ); ?>" <?= ( defined( 'DOS_KEY' ) ? 'disabled' : '' ); ?>/></td>
</tr>
<tr>
<th scope="row"><label for="dos_secret"><?= __('DO Spaces Secret', 'dos'); ?>:</label></th>
<td><input id="dos_secret" name="dos_secret" type="password" class="regular-text code" value="<?= esc_attr( defined( 'DOS_SECRET' ) ? DOS_SECRET : get_option('dos_secret') ); ?>" <?= ( defined( 'DOS_SECRET' ) ? 'disabled' : '' ); ?>/></td>
</tr>
<tr>
<th scope="row"><label for="dos_container"><?= __('DO Spaces Container', 'dos'); ?>:</label></th>
<td><input id="dos_container" name="dos_container" type="text" class="regular-text code" value="<?= esc_attr( defined( 'DOS_CONTAINER' ) ? DOS_CONTAINER : get_option('dos_container') ); ?>" <?= ( defined( 'DOS_CONTAINER' ) ? 'disabled' : '' ); ?>/></td>
</tr>
<tr>
<th scope="row"><label for="dos_endpoint"><?= __('Endpoint (with scheme)', 'dos'); ?>:</label></th>
<td>
<input id="dos_endpoint" name="dos_endpoint" type="text" class="regular-text code" value="<?= esc_attr( defined( 'DOS_ENDPOINT' ) ? DOS_ENDPOINT : get_option('dos_endpoint') ); ?>" <?= ( defined( 'DOS_ENDPOINT' ) ? 'disabled' : '' ); ?>/>
<p class="description">
<?= __('By default', 'dos'); ?>: <code>https://ams3.digitaloceanspaces.com</code>
</p>
</td>
</tr>
</tbody>
</table>
<button type="button" name="dos_test" class="button "><?= __('Check the connection', 'dos'); ?></button>
<p class="description"><?= __('Save settings before test', 'dos'); ?></p>
<br/>
<button type="submit" class="button button-primary"><?= __('Save settings','dos'); ?></button>
<h2><?= __('File & Path settings', 'dos'); ?></h2>
<table class="form-table">
<tbody>
<tr>
<th>
<label for="upload_url_path">
<?= __('Full URL-path to files', 'dos'); ?>:
</label>
</th>
<td>
<input id="upload_url_path" name="upload_url_path" type="text" class="regular-text code"
value="<?= esc_attr( defined( 'UPLOAD_URL_PATH' ) ? UPLOAD_URL_PATH : get_option('upload_url_path') ); ?>"
<?= ( defined( 'UPLOAD_URL_PATH' ) ? 'disabled' : '' ); ?>/>
<p class="description">
<?= __('Enter storage public domain or subdomain if the files are stored only in the cloud storage', 'dos'); ?>
<code>(http://uploads.example.com)</code>,
<?= __('or full URL path, if are kept both in cloud and on the server.','dos'); ?>
<code>(http://example.com/wp-content/uploads)</code>.
<?= __('In that case duplicates are created. If you change one, you change and the other,','dos'); ?>
</p>
</td>
</tr>
<tr>
<th>
<label for="upload_path">
<?= __('Local path', 'dos'); ?>:
</label>
</th>
<td>
<?php
$uploadPath = wp_upload_dir();
?>
<input id="upload_path" name="upload_path" type="text" class="regular-text code"
value="<?= esc_attr( $uploadPath['basedir'] ?$uploadPath['basedir'] : get_option('upload_path') ); ?>"
<?= ( defined( 'UPLOAD_PATH' ) ? 'disabled' : '' ); ?>/>
<p class="description">
<?= __('Local path to the uploaded files. By default', 'dos'); ?>: <code>wp-content/uploads</code><br/>
<?= __('Current installation path is', 'dos'); ?>: <code><?= $uploadPath['basedir']; ?></code><br/>
<?= __('Setting duplicates of the same name from the mediafiles settings. Changing one, you change and other', 'dos'); ?>.
</p>
</td>
</tr>
<tr>
<th>
<label for="dos_storage_path">
<?= __('Storage prefix', 'dos'); ?>:
</label>
</th>
<td>
<input id="dos_storage_path" name="dos_storage_path" type="text" class="regular-text code"
value="<?= esc_attr( defined( 'DOS_STORAGE_PATH' ) ? DOS_STORAGE_PATH : get_option('dos_storage_path') ); ?>"
<?= ( defined( 'DOS_STORAGE_PATH' ) ? 'disabled' : '' ); ?>/>
<p class="description">
<?= __( 'The path to the file in the storage will appear as a prefix / path.', 'dos' ); ?><br/>
<?php if(!empty(get_option('dos_storage_path'))): ?>
<?= __( 'For example in your case:', 'dos' ); ?>
<code><?= get_option('dos_storage_path'); ?></code>
<?php endif; ?>
</p>
</td>
</tr>
<tr>
<th>
<label for="dos_filter">
<?= __('Filemask/Regex for ignored files', 'dos'); ?>:
</label>
</th>
<td>
<input id="dos_filter" name="dos_filter" type="text" class="regular-text code"
value="<?= esc_attr( defined( 'DOS_FILTER' ) ? DOS_FILTER : get_option('dos_filter') ); ?>"
<?= ( defined( 'DOS_FILTER' ) ? 'disabled' : '' ); ?>/>
<p class="description">
<?= __('By default empty or', 'dos'); ?><code>*</code>
<?= __('Will upload all the files by default, you are free to use any Regular Expression to match and ignore the selection you need, for example:', 'dos'); ?>
<code>/^.*\.(zip|rar|docx)$/i</code>
</p>
</td>
</tr>
</tbody>
</table>
<h2><?= __('Sync settings', 'dos'); ?></h2>
<table class="form-table">
<tbody>
<tr>
<td>
<label>
<input type="checkbox" name="dos_storage_file_only" value="1" <?= checked( defined( 'DOS_STORAGE_FILE_ONLY' ) ? DOS_STORAGE_FILE_ONLY : get_option('dos_storage_file_only'), 1 ); ?>" <?= ( defined( 'DOS_STORAGE_FILE_ONLY' ) ? 'disabled' : '' ); ?> />
<?= __('Store files only in the cloud and delete after successful upload.', 'dos'); ?>
<?= __('In that case file will be removed from your server after being uploaded to cloud storage, that saves you space.', 'dos'); ?>
</label>
</td>
</tr>
<tr>
<td>
<label>
<input type="checkbox" name="dos_storage_file_delete" value="1" <?= checked( defined( 'DOS_STORAGE_FILE_DELETE' ) ? DOS_STORAGE_FILE_DELETE : get_option('dos_storage_file_delete'), 1 ); ?>"
<?= ( defined( 'DOS_STORAGE_FILE_DELETE' ) ? 'disabled' : '' ); ?> />
<?= __( 'Delete file from cloud storage as soon as it was removed from your library.', 'dos' ); ?>
</label>
</td>
</tr>
</tbody>
</table>
<input type="hidden" name="action" value="update"/>
<button type="submit" class="button button-primary"><?= __('Save settings','dos'); ?></button>
<h2><?= __('Optimization settings', 'dos'); ?></h2>
<table class="form-table">
<tbody>
<tr>
<td>
<label>
<input type="checkbox" name="dos_optimize_images" value="1" <?= checked( defined( 'DOS_OPTIMIZE_IMAGES' ) ? DOS_OPTIMIZE_IMAGES : get_option('DOS_OPTIMIZE_IMAGES'), 1 ); ?>" <?= ( defined( 'DOS_OPTIMIZE_IMAGES' ) ? 'disabled' : '' ); ?> />
<?= __('Optimize images before upload.', 'dos'); ?>
<?= __('The images are optimized with <a href="https://github.com/spatie/image-optimizer" target="_blank">https://github.com/spatie/image-optimizer</a> library', 'dos'); ?>
</label>
</td>
</tr>
</tbody>
</table>
<input type="hidden" name="action" value="update"/>
<button type="submit" class="button button-primary"><?= __('Save settings','dos'); ?></button>
</form>
</div>