Skip to content

Commit 66c2f5b

Browse files
committed
Change Purge Cache button name and 'nginx-helper_urls' query argument value on front-end admin bar.
Conditionally display the purge cache button name as 'Purge Cache' for admin dashboard and 'Purge Current Page' on front-end admin bar. Conditionally set query argument 'nginx_helper_urls' value to 'all' for admin dashaboard purge cache button and 'current-url' for front-end admin bar button
1 parent 7bced91 commit 66c2f5b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

admin/class-nginx-helper-admin.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,18 @@ public function nginx_helper_toolbar_purge_link( $wp_admin_bar ) {
201201
return;
202202
}
203203

204+
if ( is_admin() ) {
205+
$nginx_helper_urls = 'all';
206+
$link_title = __( 'Purge Cache', 'nginx-helper' );
207+
} else {
208+
$nginx_helper_urls = 'current-url';
209+
$link_title = __( 'Purge Current Page', 'nginx-helper' );
210+
}
211+
204212
$purge_url = add_query_arg(
205213
array(
206214
'nginx_helper_action' => 'purge',
207-
'nginx_helper_urls' => 'all',
215+
'nginx_helper_urls' => $nginx_helper_urls,
208216
)
209217
);
210218

@@ -213,9 +221,9 @@ public function nginx_helper_toolbar_purge_link( $wp_admin_bar ) {
213221
$wp_admin_bar->add_menu(
214222
array(
215223
'id' => 'nginx-helper-purge-all',
216-
'title' => __( 'Purge Cache', 'nginx-helper' ),
224+
'title' => $link_title,
217225
'href' => $nonced_url,
218-
'meta' => array( 'title' => __( 'Purge Cache', 'nginx-helper' ) ),
226+
'meta' => array( 'title' => array( 'title' => $link_title ) ),
219227
)
220228
);
221229

0 commit comments

Comments
 (0)