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

Purge home page by akamai #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion admin/class-akamai-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ public function validate( $input ) {
'purge_tags' => 1,
'purge_categories' => 1,
'purge_archives' => 1,
'purge_home' => 1,
);

$akamai = new Akamai();
Expand All @@ -230,7 +231,7 @@ public function validate( $input ) {
$valid['section'] = $input['section'];
}

foreach ( array( 'purge_comments', 'purge_tags', 'purge_categories', 'purge_archives' ) as $checkbox ) {
foreach ( array( 'purge_comments', 'purge_tags', 'purge_categories', 'purge_archives', 'purge_home' ) as $checkbox ) {
$valid[ $checkbox ] = 0;
if ( isset( $input[ $checkbox ] ) && ! empty( $input[ $checkbox ] ) ) {
$valid[ $checkbox ] = 1;
Expand Down
16 changes: 16 additions & 0 deletions admin/partials/akamai-admin-display.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,22 @@ class="description">Purge archive pages for categories associated with the post<
</label>
</td>
</tr>
<tr>
<th scope="row">
<label for="<?php echo esc_attr( $this->plugin_name ); ?>-purge-home">
<?php esc_html_e( 'Purge home', $this->plugin_name ); ?>
</label>
</th>
<td>
<input type="checkbox" id="<?php echo esc_attr( $this->plugin_name ); ?>-purge-home"
name="<?php echo esc_attr( $this->plugin_name ); ?>[purge_home]"
value="1" <?php checked( $options['purge_home'] ); ?>"/>

<label for="<?php echo esc_attr( $this->plugin_name ); ?>-purge-home">
<span class="description">Purge home page</span>
</label>
</td>
</tr>
</tbody>
</table>
<button id="verify" type="button" class="button" name="verify">Verify Credentials</button>
Expand Down
4 changes: 4 additions & 0 deletions includes/class-akamai.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ protected function get_purge_body( $options, $post ) {
$objects[] = $this->get_item_url( $archive );
}
}

if ( $options['purge_home'] ) {
$objects[] = home_url( '/' );
}

$data = array(
'hostname' => $host,
Expand Down