Skip to content

Commit 94dc176

Browse files
authored
Merge pull request #7 from dwnload/develop
Version 1.2.3
2 parents 9079bba + d360caf commit 94dc176

File tree

5 files changed

+28
-22
lines changed

5 files changed

+28
-22
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
language: php
22

33
php:
4-
- '7.1'
54
- '7.0'
5+
- '7.1'
6+
- '7.2'
67

78
install: composer install
89

CHANGELONG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## 1.2.3 - 2018-05-30
8+
### Updated
9+
- Added permission check (`delete_users`) before adding admin bar node.
10+
- Change permission check on settings page from `manage_options` to `delete_users`.
11+
- Removed nonce check after successful cache flush for admin notice.
12+
13+
### Added
14+
- PHP 7.2 to the Travis build.
15+
716
## 1.2.2 - 2018-04-30
817
### Fixed
918
- When endpoints have multiple posts, the request bubbles up and appends the results which leads to a body size X's the

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "dwnload/wp-rest-api-object-cache",
33
"description": "Enable object caching for WordPress' REST API. Aids in increased response times of your applications endpoints.",
44
"type": "wordpress-plugin",
5-
"version": "1.2.2",
5+
"version": "1.2.3",
66
"license": "MIT",
77
"authors": [
88
{

src/WpAdmin/Admin.php

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected function adminMenu()
7575
'options-general.php',
7676
\esc_html__('WP REST API Cache', 'wp-rest-api-cache'),
7777
\esc_html__('REST API Cache', 'wp-rest-api-cache'),
78-
'manage_options',
78+
'delete_users',
7979
self::MENU_SLUG,
8080
function () {
8181
$this->renderPage();
@@ -90,12 +90,14 @@ function () {
9090
*/
9191
protected function adminBarMenu(WP_Admin_Bar $wp_admin_bar)
9292
{
93-
$args = [
93+
if (! is_user_logged_in() || ! current_user_can('delete_users') || ! is_admin_bar_showing()) {
94+
return;
95+
}
96+
97+
$wp_admin_bar->add_node([
9498
'id' => WpRestApiCache::ID,
9599
'title' => \esc_html__('REST API Cache', 'wp-rest-api-cache'),
96-
];
97-
98-
$wp_admin_bar->add_node($args);
100+
]);
99101
$wp_admin_bar->add_menu([
100102
'parent' => WpRestApiCache::ID,
101103
'id' => self::MENU_ID,
@@ -111,16 +113,12 @@ protected function adminAction()
111113
{
112114
$this->requestCallback();
113115

114-
$url = \wp_nonce_url(
115-
\add_query_arg(
116-
[self::NOTICE => 1],
117-
\remove_query_arg(
118-
[RestDispatch::QUERY_CACHE_DELETE, RestDispatch::QUERY_CACHE_REFRESH],
119-
\wp_get_referer()
120-
)
121-
),
122-
self::NONCE_ACTION,
123-
self::NONCE_NAME
116+
$url = \add_query_arg(
117+
[self::NOTICE => 1],
118+
\remove_query_arg(
119+
[RestDispatch::QUERY_CACHE_DELETE, RestDispatch::QUERY_CACHE_REFRESH],
120+
\wp_get_referer()
121+
)
124122
);
125123
\wp_safe_redirect($url);
126124
exit;
@@ -131,9 +129,7 @@ protected function adminAction()
131129
*/
132130
protected function adminNotices()
133131
{
134-
if (! empty($_REQUEST[self::NONCE_NAME]) &&
135-
\wp_verify_nonce($_REQUEST[self::NONCE_NAME], self::NONCE_ACTION) &&
136-
! empty($_GET[self::NOTICE]) &&
132+
if (! empty($_GET[self::NOTICE]) &&
137133
filter_var_int($_GET[self::NOTICE]) === 1
138134
) {
139135
$message = \esc_html__('The cache has been successfully cleared.', 'wp-rest-api-cache');

wp-rest-api-cache.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Description: Enable object caching for WordPress' REST API. Aids in increased response times of your applications endpoints.
55
* Author: Austin Passy
66
* Author URI: http://github.com/thefrosty
7-
* Version: 1.2.2
7+
* Version: 1.2.3
88
* Requires at least: 4.9
99
* Tested up to: 4.9
1010
* Requires PHP: 7.0
@@ -19,7 +19,7 @@
1919

2020
PluginFactory::create('rest-api-object-cache')
2121
->addOnHook(RestDispatch::class)
22-
->addOnHook(Admin::class)
22+
->addOnHook(Admin::class)
2323
->initialize();
2424

2525
call_user_func_array(

0 commit comments

Comments
 (0)