Skip to content
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

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

Vedant-Gandhi
Copy link
Contributor

Description

The aim of this PR is to add support for purging AMP URL's.

Type

  • New Feature

Reference Issue

Testing

The code has been tested locally and is working as expected.

@Vedant-Gandhi Vedant-Gandhi marked this pull request as ready for review September 6, 2024 09:44
@Vedant-Gandhi Vedant-Gandhi requested a review from SH4LIN October 10, 2024 06:15
</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 ); ?> />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this option enabled by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

* @param string $url_base The base URL to purge.
*/
private function purge_amp_version( $url_base ) {
$amp_url = $url_base . '/amp/';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use sprintf()


$this->log('- Purging AMP URL | ' . $amp_url);

if ($this->nginx_helper_admin->options['purge_method'] === 'unlink_files') {
Copy link

Choose a reason for hiding this comment

The 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

@Vedant-Gandhi Vedant-Gandhi requested a review from SH4LIN October 22, 2024 06:13
private function purge_amp_version( $url_base ) {
$amp_url = sprintf( '%s/amp/', rtrim( $url_base, '/' ) );

$this->log('- Purging AMP URL | ' . $amp_url);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the PHPCS error here.

Suggested change
$this->log('- Purging AMP URL | ' . $amp_url);
$this->log( '- Purging AMP URL | ' . $amp_url );

<tr valign="top">
<th scope="row">
<h4>
<?php esc_html_e( 'Purge AMP URL:', 'nginx-helper' ); ?>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the indentation

<td>
<fieldset>
<legend class="screen-reader-text">
<span>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the indentation

<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 ); ?> />
&nbsp;
<?php
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the indentation in the HTML markup

@Vedant-Gandhi Vedant-Gandhi requested a review from SH4LIN December 12, 2024 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants