Skip to content

Commit 1f3ecdd

Browse files
committed
Add s3CacheControl option to the S3 Options page.
1 parent 42215ca commit 1f3ecdd

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

src/Controller.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,16 @@ public static function seedOptions() : void {
175175
);
176176

177177
$wpdb->query( $query );
178+
179+
$query = $wpdb->prepare(
180+
$query_string,
181+
's3CacheControl',
182+
'public, max-age=900',
183+
'Cache-Control header value',
184+
''
185+
);
186+
187+
$wpdb->query( $query );
178188
}
179189

180190
/**
@@ -394,6 +404,12 @@ public static function saveOptionsFromUI() : void {
394404
[ 'name' => 's3RemotePath' ]
395405
);
396406

407+
$wpdb->update(
408+
$table_name,
409+
[ 'value' => sanitize_text_field( $_POST['s3CacheControl'] ) ],
410+
[ 'name' => 's3CacheControl' ]
411+
);
412+
397413
wp_safe_redirect( admin_url( 'admin.php?page=wp2static-s3' ) );
398414
exit;
399415
}

views/s3-page.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,22 @@
111111
</td>
112112
</tr>
113113

114+
<tr>
115+
<td style="width:50%;">
116+
<label
117+
for="<?php echo $view['options']['s3CacheControl']->name; ?>"
118+
><?php echo $view['options']['s3CacheControl']->label; ?></label>
119+
</td>
120+
<td>
121+
<input
122+
id="<?php echo $view['options']['s3CacheControl']->name; ?>"
123+
name="<?php echo $view['options']['s3CacheControl']->name; ?>"
124+
type="text"
125+
value="<?php echo $view['options']['s3CacheControl']->value !== '' ? $view['options']['s3CacheControl']->value : ''; ?>"
126+
/>
127+
</td>
128+
</tr>
129+
114130
</tbody>
115131
</table>
116132

0 commit comments

Comments
 (0)