darrenjacoby / intervention

WordPress plugin to configure wp-admin and application state using a single config file.
MIT License
642 stars 51 forks source link

Remove activate and deactivate actions when defining plugin state in config #101

Closed claytoncollie closed 2 years ago

claytoncollie commented 2 years ago

I am finally using this plugin and I really love it. I feel like I am dialing in my WordPress config just how I like it with the application array. One thing I noticed is that when you define a set of plugins in the application.plugins array, the bulk_actions-plugins and plugin_action_links should probably be filtered to remove theActivate and Deactive options.

See https://developer.wordpress.org/reference/hooks/bulk_actions-this-screen-id/ and https://developer.wordpress.org/reference/hooks/plugin_action_links/ and https://developer.wordpress.org/reference/hooks/plugin_action_links_plugin_file/ for reference

Happy to make a PR if you think it's a good idea. Was looking at this file to add the functionality. Sound about right?

darrenjacoby commented 2 years ago

Hey @claytoncollie,

Thanks for the nice words!

That makes sense to me. I've added it to the next release. You were correct it should get added to that file, Theme.php does something similar, it uses an Admin class where you can set the Intervention key to be removed.

I've added the following to Plugins.php when an application config is present.

Admin::set('plugins.all.actions.activate', true);
Admin::set('plugins.all.actions.deactivate', true);
darrenjacoby commented 2 years ago

Should be on branch interface, still very much a work in progress branch though.

claytoncollie commented 2 years ago

I checked out the interface branch and ran composer install && composer run build and am getting a fatal error.


[13-Feb-2022 20:30:07 UTC] PHP Fatal error:  Uncaught Error: Class 'Jacoby\Intervention\Illuminate\Support\Collection' not found in /Users/claytoncollie/www/forklift/app/public/wp-content/plugins/intervention/src/Support/Arr.php:65
Stack trace:
#0 /Users/claytoncollie/www/forklift/app/public/wp-content/plugins/intervention/src/Support/Arr.php(32): Jacoby\Intervention\Support\Arr::collect(Array)
#1 /Users/claytoncollie/www/forklift/app/public/wp-content/plugins/intervention/src/Support/Arr.php(48): Jacoby\Intervention\Support\Arr::normalize(Array)
#2 /Users/claytoncollie/www/forklift/app/public/wp-content/plugins/intervention/src/Intervention.php(33): Jacoby\Intervention\Support\Arr::normalizeTrue(Array)
#3 /Users/claytoncollie/www/forklift/app/public/wp-content/plugins/intervention/intervention.php(85): Jacoby\Intervention\Intervention->__construct(Array, true)
#4 /Users/claytoncollie/www/forklift/app/public/wp-settings.php(418): include_once('/Users/claytonc...')
#5 /Users/claytoncollie/www/forklift/app/public/wp-config.php(83): require_once('/Users/cl in /Users/claytoncollie/www/forklift/app/public/wp-content/plugins/intervention/src/Support/Arr.php on line 65
[13-Feb-2022 20:30:07 UTC] PHP Notice:  is_embed was called <strong>incorrectly</strong>. Conditional query tags do not work before the query is run. Before then, they always return false. Please see <a href="https://wordpress.org/support/article/debugging-in-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 3.1.0.) in /Users/claytoncollie/www/forklift/app/public/wp-includes/functions.php on line 5768
[13-Feb-2022 20:30:07 UTC] PHP Stack trace:
[13-Feb-2022 20:30:07 UTC] PHP   1. WP_Fatal_Error_Handler->handle() /Users/claytoncollie/www/forklift/app/public/wp-includes/class-wp-fatal-error-handler.php:0
[13-Feb-2022 20:30:07 UTC] PHP   2. WP_Fatal_Error_Handler->display_error_template() /Users/claytoncollie/www/forklift/app/public/wp-includes/class-wp-fatal-error-handler.php:57
[13-Feb-2022 20:30:07 UTC] PHP   3. WP_Fatal_Error_Handler->display_default_error_template() /Users/claytoncollie/www/forklift/app/public/wp-includes/class-wp-fatal-error-handler.php:152
[13-Feb-2022 20:30:07 UTC] PHP   4. wp_die() /Users/claytoncollie/www/forklift/app/public/wp-includes/class-wp-fatal-error-handler.php:233
[13-Feb-2022 20:30:07 UTC] PHP   5. _default_wp_die_handler() /Users/claytoncollie/www/forklift/app/public/wp-includes/functions.php:3661
[13-Feb-2022 20:30:07 UTC] PHP   6. wp_robots() /Users/claytoncollie/www/forklift/app/public/wp-includes/functions.php:3737
[13-Feb-2022 20:30:07 UTC] PHP   7. apply_filters() /Users/claytoncollie/www/forklift/app/public/wp-includes/robots-template.php:32
[13-Feb-2022 20:30:07 UTC] PHP   8. WP_Hook->apply_filters() /Users/claytoncollie/www/forklift/app/public/wp-includes/plugin.php:189
[13-Feb-2022 20:30:07 UTC] PHP   9. wp_robots_noindex_embeds() /Users/claytoncollie/www/forklift/app/public/wp-includes/class-wp-hook.php:307
[13-Feb-2022 20:30:07 UTC] PHP  10. is_embed() /Users/claytoncollie/www/forklift/app/public/wp-includes/robots-template.php:93
[13-Feb-2022 20:30:07 UTC] PHP  11. _doing_it_wrong() /Users/claytoncollie/www/forklift/app/public/wp-includes/query.php:881
[13-Feb-2022 20:30:07 UTC] PHP  12. trigger_error() /Users/claytoncollie/www/forklift/app/public/wp-includes/functions.php:5768
[13-Feb-2022 20:30:07 UTC] PHP Notice:  is_search was called <strong>incorrectly</strong>. Conditional query tags do not work before the query is run. Before then, they always return false. Please see <a href="https://wordpress.org/support/article/debugging-in-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 3.1.0.) in /Users/claytoncollie/www/forklift/app/public/wp-includes/functions.php on line 5768
[13-Feb-2022 20:30:07 UTC] PHP Stack trace:
[13-Feb-2022 20:30:07 UTC] PHP   1. WP_Fatal_Error_Handler->handle() /Users/claytoncollie/www/forklift/app/public/wp-includes/class-wp-fatal-error-handler.php:0
[13-Feb-2022 20:30:07 UTC] PHP   2. WP_Fatal_Error_Handler->display_error_template() /Users/claytoncollie/www/forklift/app/public/wp-includes/class-wp-fatal-error-handler.php:57
[13-Feb-2022 20:30:07 UTC] PHP   3. WP_Fatal_Error_Handler->display_default_error_template() /Users/claytoncollie/www/forklift/app/public/wp-includes/class-wp-fatal-error-handler.php:152
[13-Feb-2022 20:30:07 UTC] PHP   4. wp_die() /Users/claytoncollie/www/forklift/app/public/wp-includes/class-wp-fatal-error-handler.php:233
[13-Feb-2022 20:30:07 UTC] PHP   5. _default_wp_die_handler() /Users/claytoncollie/www/forklift/app/public/wp-includes/functions.php:3661
[13-Feb-2022 20:30:07 UTC] PHP   6. wp_robots() /Users/claytoncollie/www/forklift/app/public/wp-includes/functions.php:3737
[13-Feb-2022 20:30:07 UTC] PHP   7. apply_filters() /Users/claytoncollie/www/forklift/app/public/wp-includes/robots-template.php:32
[13-Feb-2022 20:30:07 UTC] PHP   8. WP_Hook->apply_filters() /Users/claytoncollie/www/forklift/app/public/wp-includes/plugin.php:189
[13-Feb-2022 20:30:07 UTC] PHP   9. wp_robots_noindex_search() /Users/claytoncollie/www/forklift/app/public/wp-includes/class-wp-hook.php:307
[13-Feb-2022 20:30:07 UTC] PHP  10. is_search() /Users/claytoncollie/www/forklift/app/public/wp-includes/robots-template.php:119
[13-Feb-2022 20:30:07 UTC] PHP  11. _doing_it_wrong() /Users/claytoncollie/www/forklift/app/public/wp-includes/query.php:699
[13-Feb-2022 20:30:07 UTC] PHP  12. trigger_error() /Users/claytoncollie/www/forklift/app/public/wp-includes/functions.php:5768
darrenjacoby commented 2 years ago

@claytoncollie you may need to install php-scoper globally before running composer run build for the time-being;

composer global require humbug/php-scoper

Let me know if that works?

darrenjacoby commented 2 years ago

I have added this fix to main for the meanwhile. I will open separate issues for PHP scoper and interface should we need.