Skip to content

Commit 5ffd1ab

Browse files
Merge pull request #295 from rtCamp/feature/skip-feeds-option
GH-281: New filter for $feed [Master]
2 parents d894f3e + 5d779c4 commit 5ffd1ab

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

admin/class-fastcgi-purger.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function purge_url( $url, $feed = true ) {
5757

5858
$this->delete_cache_file_for( $_url_purge );
5959

60-
if ( $feed ) {
60+
if ( $feed && ! empty( $nginx_helper_admin->options['purge_feeds'] ) ) {
6161

6262
$feed_url = rtrim( $_url_purge_base, '/' ) . '/feed/';
6363
$this->delete_cache_file_for( $feed_url );
@@ -79,7 +79,7 @@ public function purge_url( $url, $feed = true ) {
7979

8080
$this->do_remote_get( $_url_purge );
8181

82-
if ( $feed ) {
82+
if ( $feed && ! empty( $nginx_helper_admin->options['purge_feeds'] ) ) {
8383

8484
$feed_url = rtrim( $_url_purge_base, '/' ) . '/feed/';
8585
$this->do_remote_get( $feed_url );

admin/class-nginx-helper-admin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ public function nginx_helper_default_settings() {
272272
'purge_page_on_mod' => 1,
273273
'purge_page_on_new_comment' => 1,
274274
'purge_page_on_deleted_comment' => 1,
275+
'purge_feeds' => 1,
275276
'redis_hostname' => '127.0.0.1',
276277
'redis_port' => '6379',
277278
'redis_prefix' => 'nginx-cache:',

admin/partials/nginx-helper-general-options.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
'purge_page_on_mod',
3939
'purge_page_on_new_comment',
4040
'purge_page_on_deleted_comment',
41+
'purge_feeds',
4142
'smart_http_expire_form_nonce',
4243
);
4344

@@ -58,6 +59,18 @@
5859
$nginx_helper_admin->nginx_helper_default_settings()
5960
);
6061

62+
$site_options = get_site_option( 'rt_wp_nginx_helper_options', array() );
63+
64+
// Uncheck checkbox fields whose default value is `1` but user has unchecked.
65+
foreach ( $nginx_helper_admin->nginx_helper_default_settings() as $default_setting_field => $default_setting_value ) {
66+
67+
if ( 1 === $default_setting_value && isset( $site_options[ $default_setting_field ] ) && empty( $all_inputs[ $default_setting_field ] ) ) {
68+
69+
$nginx_settings[ $default_setting_field ] = 0;
70+
71+
}
72+
}
73+
6174
if ( ( ! is_numeric( $nginx_settings['log_filesize'] ) ) || ( empty( $nginx_settings['log_filesize'] ) ) ) {
6275
$error_log_filesize = __( 'Log file size must be a number.', 'nginx-helper' );
6376
unset( $nginx_settings['log_filesize'] );
@@ -496,6 +509,38 @@
496509
</td>
497510
</tr>
498511
</table>
512+
<table class="form-table rtnginx-table">
513+
<tr valign="top">
514+
<th scope="row">
515+
<h4>
516+
<?php esc_html_e( 'Purge Feeds:', 'nginx-helper' ); ?>
517+
</h4>
518+
</th>
519+
<td>
520+
<fieldset>
521+
<legend class="screen-reader-text">
522+
<span>
523+
&nbsp;
524+
<?php
525+
esc_html_e( 'purge feeds', 'nginx-helper' );
526+
?>
527+
</span>
528+
</legend>
529+
<label for="purge_feeds">
530+
<input type="checkbox" value="1" id="purge_feeds" name="purge_feeds" <?php checked( $nginx_helper_settings['purge_feeds'], 1 ); ?> />
531+
&nbsp;
532+
<?php
533+
echo wp_kses(
534+
__( 'purge <strong>feeds</strong> along with <strong>posts</strong> & <strong>pages</strong>.', 'nginx-helper' ),
535+
array( 'strong' => array() )
536+
);
537+
?>
538+
</label>
539+
<br />
540+
</fieldset>
541+
</td>
542+
</tr>
543+
</table>
499544
<table class="form-table rtnginx-table">
500545
<tr valign="top">
501546
<th scope="row">

0 commit comments

Comments
 (0)