Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR solves a number of issues: 1. The js was only enqueued if the current user had the `activate_plugins` ability (=(super)-admin) rendering the plugin largely useless for multi-author websites where most authors are non-admins. 2. The requirements were checked using `is_plugin_active()` which is unreliable. Changed this to a check based on code rather than on the `is_plugin_active()` function. This is more reliable as: a) it will also take into account plugins loaded through the must-use plugins directory b) it will still work even if the user has renamed the folder for the plugin within `wp-content/plugins/` (which happens more often than you'd expect). 3. Allow for *this* plugin to be installed as a must-use plugin, i.e. the admin notice and the deactivation should only happen if the plugin is installed as a normal plugin. So re-arranged the code to deal with that. 4. Get rid of the use of `get_plugin_data()` which is an expensive function if all you really want to do is get the version number of the plugin. Also the original function call was wrong causing a number of errors and failing to retrieve the version number as `dirname( __FILE__ )` was passed, while the function expects `__FILE__`. Replaced with a class constant. Fixes #6 (point 2) This PR additionally fixes the following PHP errors which were caused by the bug outlined in point 3: `PHP Warning: fopen(/path/to/plugins/yoast-seo-acf-analysis): failed to open stream: Permission denied` `PHP Warning: fread() expects parameter 1 to be resource, boolean given in /path/to/wp-includes/functions.php on line 4466` `PHP Warning: fclose() expects parameter 1 to be resource, boolean given in /path/to/wp-includes/functions.php on line 4469`
- Loading branch information