Skip to content

Commit

Permalink
Merge pull request #9 from dwnload/develop
Browse files Browse the repository at this point in the history
Update WordPress plugin check filter with additional object check.
  • Loading branch information
thefrosty authored Feb 7, 2019
2 parents 5b90593 + 4cd0908 commit afe637f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELONG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## 1.3.1 2019-02-06
### Updated
- Added additional check for object on `site_transient_update_plugins` check.

## 1.3.0.1 2018-07-30
### Changed
- Move the Admin class into an action hook on `after_setup_theme` to avoid conditional notices.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dwnload/wp-rest-api-object-cache",
"description": "Enable object caching for WordPress' REST API. Aids in increased response times of your applications endpoints.",
"type": "wordpress-plugin",
"version": "1.3.0.1",
"version": "1.3.1",
"license": "MIT",
"authors": [
{
Expand Down
19 changes: 7 additions & 12 deletions wp-rest-api-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: Enable object caching for WordPress' REST API. Aids in increased response times of your applications endpoints.
* Author: Austin Passy
* Author URI: http://github.com/thefrosty
* Version: 1.3.0.1
* Version: 1.3.1
* Requires at least: 4.9
* Tested up to: 4.9
* Requires PHP: 7.0
Expand All @@ -25,15 +25,10 @@
}
});

call_user_func_array(
function ($filter) {
add_filter($filter, function ($value) use ($filter) {
if (! empty($value->response) && array_key_exists(plugin_basename(__FILE__), $value->response)) {
unset($value->response[plugin_basename(__FILE__)]);
}
add_filter('site_transient_update_plugins', function ($value) {
if (isset($value) && is_object($value) && (! empty($value->response) && is_array($value->response))) {
unset($value->response[@plugin_basename(__FILE__)]);
}

return $value;
});
},
['pre_site_transient_update_plugins', 'site_transient_update_plugins']
);
return $value;
});

0 comments on commit afe637f

Please sign in to comment.