| @@ -88,8 +88,36 @@ | ||
| 88 | 88 | <p style="font-size:12px;color:#666;margin:-4px 0 0;"> |
| 89 | 89 | <?php esc_html_e( 'Override the global cache expiry for this post (1–720 hours). Leave at 0 to inherit the site default.', 'xspeed' ); ?> |
| 90 | 90 | </p> |
| 91 | 91 | <?php |
| 92 | + self::render_purge_action( $post ); | |
| 93 | + } | |
| 94 | + | |
| 95 | + /** | |
| 96 | + * "Purge this post's cache" under the rules. | |
| 97 | + * | |
| 98 | + * Shown only for a published, publicly viewable post — a draft has no | |
| 99 | + * cached page to clear, so the button could only ever report that it | |
| 100 | + * removed nothing. It leaves the editor rather than submitting the post | |
| 101 | + * form, so an unsaved draft is never silently published by a purge. | |
| 102 | + */ | |
| 103 | + private static function render_purge_action( \WP_Post $post ): void { | |
| 104 | + if ( ! Purge_Ui::user_can_purge() ) { | |
| 105 | + return; | |
| 106 | + } | |
| 107 | + if ( '' === Purge_Ui::permalink_of( (int) $post->ID ) ) { | |
| 108 | + return; | |
| 109 | + } | |
| 110 | + ?> | |
| 111 | + <p style="margin:14px 0 0;padding-top:12px;border-top:1px solid #dcdcde;"> | |
| 112 | + <a href="<?php echo esc_url( Purge_Ui::post_purge_link( (int) $post->ID ) ); ?>" class="button button-secondary"> | |
| 113 | + <?php esc_html_e( 'Purge this post’s cache', 'xspeed' ); ?> | |
| 114 | + </a> | |
| 115 | + </p> | |
| 116 | + <p style="font-size:12px;color:#666;margin:6px 0 0;"> | |
| 117 | + <?php esc_html_e( 'Clears this post and the pages that list it — the homepage, its archive and the neighbouring posts. The rest of the site keeps its cache.', 'xspeed' ); ?> | |
| 118 | + </p> | |
| 119 | + <?php | |
| 92 | 120 | } |
| 93 | 121 | |
| 94 | 122 | /** |
| 95 | 123 | * @param int $post_id |