Skip to content

Commit

Permalink
Merge pull request #295 from rtCamp/feature/skip-feeds-option
Browse files Browse the repository at this point in the history
GH-281: New filter for $feed [Master]
  • Loading branch information
Pathan-Amaankhan authored Apr 15, 2024
2 parents d894f3e + 5d779c4 commit 5ffd1ab
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
4 changes: 2 additions & 2 deletions admin/class-fastcgi-purger.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function purge_url( $url, $feed = true ) {

$this->delete_cache_file_for( $_url_purge );

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

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

$this->do_remote_get( $_url_purge );

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

$feed_url = rtrim( $_url_purge_base, '/' ) . '/feed/';
$this->do_remote_get( $feed_url );
Expand Down
1 change: 1 addition & 0 deletions admin/class-nginx-helper-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ public function nginx_helper_default_settings() {
'purge_page_on_mod' => 1,
'purge_page_on_new_comment' => 1,
'purge_page_on_deleted_comment' => 1,
'purge_feeds' => 1,
'redis_hostname' => '127.0.0.1',
'redis_port' => '6379',
'redis_prefix' => 'nginx-cache:',
Expand Down
45 changes: 45 additions & 0 deletions admin/partials/nginx-helper-general-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
'purge_page_on_mod',
'purge_page_on_new_comment',
'purge_page_on_deleted_comment',
'purge_feeds',
'smart_http_expire_form_nonce',
);

Expand All @@ -58,6 +59,18 @@
$nginx_helper_admin->nginx_helper_default_settings()
);

$site_options = get_site_option( 'rt_wp_nginx_helper_options', array() );

// Uncheck checkbox fields whose default value is `1` but user has unchecked.
foreach ( $nginx_helper_admin->nginx_helper_default_settings() as $default_setting_field => $default_setting_value ) {

if ( 1 === $default_setting_value && isset( $site_options[ $default_setting_field ] ) && empty( $all_inputs[ $default_setting_field ] ) ) {

$nginx_settings[ $default_setting_field ] = 0;

}
}

if ( ( ! is_numeric( $nginx_settings['log_filesize'] ) ) || ( empty( $nginx_settings['log_filesize'] ) ) ) {
$error_log_filesize = __( 'Log file size must be a number.', 'nginx-helper' );
unset( $nginx_settings['log_filesize'] );
Expand Down Expand Up @@ -496,6 +509,38 @@
</td>
</tr>
</table>
<table class="form-table rtnginx-table">
<tr valign="top">
<th scope="row">
<h4>
<?php esc_html_e( 'Purge Feeds:', 'nginx-helper' ); ?>
</h4>
</th>
<td>
<fieldset>
<legend class="screen-reader-text">
<span>
&nbsp;
<?php
esc_html_e( 'purge feeds', 'nginx-helper' );
?>
</span>
</legend>
<label for="purge_feeds">
<input type="checkbox" value="1" id="purge_feeds" name="purge_feeds" <?php checked( $nginx_helper_settings['purge_feeds'], 1 ); ?> />
&nbsp;
<?php
echo wp_kses(
__( 'purge <strong>feeds</strong> along with <strong>posts</strong> & <strong>pages</strong>.', 'nginx-helper' ),
array( 'strong' => array() )
);
?>
</label>
<br />
</fieldset>
</td>
</tr>
</table>
<table class="form-table rtnginx-table">
<tr valign="top">
<th scope="row">
Expand Down

0 comments on commit 5ffd1ab

Please sign in to comment.