-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Purge for AMP URL when a Post or Page is Published. #353
Changes from 2 commits
914dccf
c2a1416
6048861
b34d004
13973c5
e9424e3
3671fc9
4a9a801
cbfc429
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -90,8 +90,29 @@ public function purge_url( $url, $feed = true ) { | |||||
break; | ||||||
|
||||||
} | ||||||
|
||||||
if( ( is_page() || is_single() ) && $nginx_helper_admin->options['purge_amp_urls'] ) { | ||||||
$this->purge_amp_version( $url ); | ||||||
} | ||||||
|
||||||
} | ||||||
|
||||||
/** | ||||||
* Purge AMP version of a URL. | ||||||
* | ||||||
* @param string $url_base The base URL to purge. | ||||||
*/ | ||||||
private function purge_amp_version( $url_base ) { | ||||||
$amp_url = $url_base . '/amp/'; | ||||||
|
||||||
$this->log('- Purging AMP URL | ' . $amp_url); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix the PHPCS error here.
Suggested change
|
||||||
|
||||||
if ($this->nginx_helper_admin->options['purge_method'] === 'unlink_files') { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use Yoda condition and add spaces at start and end of the brackets |
||||||
$this->delete_cache_file_for($amp_url); | ||||||
} else { | ||||||
$this->do_remote_get($this->purge_base_url() . '/amp/'); | ||||||
} | ||||||
} | ||||||
|
||||||
/** | ||||||
* Function to custom purge urls. | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
'purge_page_on_deleted_comment', | ||
'purge_feeds', | ||
'smart_http_expire_form_nonce', | ||
'purge_amp_urls', | ||
); | ||
|
||
$all_inputs = array(); | ||
|
@@ -548,6 +549,38 @@ | |
</td> | ||
</tr> | ||
</table> | ||
<table class="form-table rtnginx-table"> | ||
<tr valign="top"> | ||
<th scope="row"> | ||
<h4> | ||
<?php esc_html_e( 'Purge AMP URL:', 'nginx-helper' ); ?> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix the indentation |
||
</h4> | ||
</th> | ||
<td> | ||
<fieldset> | ||
<legend class="screen-reader-text"> | ||
<span> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix the indentation |
||
| ||
<?php | ||
esc_html_e( 'purge amp urls', 'nginx-helper' ); | ||
?> | ||
</span> | ||
</legend> | ||
<label for="purge_amp_urls"> | ||
<input type="checkbox" value="1" id="purge_amp_urls" name="purge_amp_urls" <?php checked( $nginx_helper_settings['purge_amp_urls'], 1 ); ?> /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this option enabled by default? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SH4LIN I have enabled it in accordance with the default behaviour since, by default, all other options—aside from comments—are enabled when purge is enabled. |
||
| ||
<?php | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix the indentation in the HTML markup |
||
echo wp_kses( | ||
__( 'purge <strong>amp urls</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"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use sprintf()