I may be late to this party, but to stop plugin activation and have WordPress show an error message where the admin notices go, I simply output an error message and terminate execution. This has the added advantage of playing nice with wp-cli:
Example:
class testPlugin() {
...
static function activate() {
//[do some stuff here]
if ($error) {
die('Plugin NOT activated: ' . $error);
}
}
register_activation_hook( __FILE__, array( 'testPlugin', 'activate' ));
Related Posts:
- How to Add a Third Level Sub Menu to the WordPress Admin Menu
- How to Add an Index to Plugin Database table
- How to safely sanitize a textarea which takes full HTML input
- How to Remove Certain Screen Options and Meta Boxes from add/edit post type?
- Why activate_plugin is not working in register_activation_hook
- Creating two database tables via plugin
- Is it a good idea to edit an already existing plugin to add more functionality?
- Custom Filter in WordPress to modify footer information via plugin?
- WP WC CLI – WooCommerce setup store with wp-cli [closed]
- Editor access to plugin settings
- How to use a Must-Use plugin to hide a regular one and to hide itself?
- Shortcode display outside the div
- Custom Post Type Statuses
- How does wordpress distinguish a plugin’s main php file from other php files? [duplicate]
- Insert code after tag without using functions.php?
- Plugin: How should I handle deleting comments?
- wordpress plugin that show my reputation (points) in any stackexchange project in my wordpress blogs
- Why load_textdomain work but not load_plugin_textdomain?
- Extend the Admin Post/Edit page
- Unable to load stylesheets and scripts to plugin settings page
- Passing select control value to block
- Can wp_script_is used in pluginA check if a script is being enqueued/registered from pluginB?
- Licensing of freemium plugin
- send_headers don’t work on wordpress multisite
- Why was my plugin rejected from the WordPress.org repository?
- $wpdb working with ajax but showing ajax error instead of success
- Adding content before the loop in category pages
- admin_notices hook show message all admin pages after plugin activate
- Default Plugin Settings Not Writing to Database
- How to define WordPress plugin shortcode globally for multisite?
- how to Include json manifest file in wp plugin
- Create a custom page template inside my wordpress plugin
- White page on custom plugin option submit
- Input with spaces in Shortcode attributes overwritten by defaults
- Unable to override pluggable function wp_mail
- Avoid class name collision when using third party libraries in plugins?
- How to find the origin of a file upload from within wp_handle_upload?
- How to add Internationalization in WordPress using Javascript/React?
- creating html reusable blocks via shortcodes
- I want to auto populate data in three fields if one drop down is selected
- How to set taxonomy in custom plugin?
- Plugin development: Buggy plugin preview
- how to use in custom single.php template using php?
- How can I change the meta_key for a particular piece of information?
- Howto check version of another plugin and then add a submenu page to it
- Which file of wordpress manage plugins functionalities?
- How can i create page through plugin
- I should enable automatic updates?
- Check if variable is set in filter
- How to add custom table style for table block in gutenberg editor
- How to write “alt” tag in image for wordpress code?
- Issues with a WP plugin menu system
- Different custom templates for product category [closed]
- Add a “View all” button on WooCommerce product archives pages
- How do I add an options page at the bottom of the list?
- is it possible to hook every page style?
- Redirect logged in user to somepage on every page view?
- Unable to give correct path in wordpress
- Disable variations on woo commerce if out of stock
- How to add img into a plugin?
- A question of etiquette when forking a plugin? [closed]
- how to request a script more than once in wordpress
- How to log custom plugin error to debug.log file
- Adding a jQuery modal dialog to the admin area
- How to make a Product page without ordering and database
- wp_options not returning value for logged out users?
- Gutenberg default attributes are empty when accessing in edit
- How to create admin setting for this small plugin
- Cannot run script properly with my custom plugin
- Cookie value changes back to previous value after changing
- Hide all Admin Notices and move on a separate page
- How to fix caching issue in PHP data from database
- Highlight admin menu items that are parent of existing core items
- Adding shortcodes to multiple pages with function
- SASS not showing in customized preloader plugin
- How to securely controlling data without keeping it in postmeta?
- Getting all woocommerce products from REST API call in plugin
- Get a list of Product Categories inside a loop
- Can you develop themes and plugins while using the hosting services BlueHost? [closed]
- WordPress plugin changes not updating
- wordpress ajax pagination object value does not change
- Google analytic issue in wordpress
- Custom pages with plugin
- How to insert category name above post title in a featured pages plugin?
- Displaying friend’s posts only
- What’s the preferred method of writing AJAX-enabled plugins?
- How to add submenu to WordPress plugin in the same Directory of main Plugin?
- Shortcode registered from a plugin not recognized
- How to change a specific page to custom page?
- wp_update_post call really slow when official Facebook plugin is installed
- How to set-up multiple cron task with wp_schedule_event so that they do not overlap?
- How use Dynamic hyperlink on each wordpress post?
- _e in wordpress +
- WordPress Code Access to Restricted Content without Registration
- Plugin version number after code rewrite [closed]
- wp_handle_upload – specified file failed upload test
- how to make wordpress remember my choice
- Running a function using Crown WordPress on one day a week, for example, Mondays of every week
- How to make a Template page to show the information of different things Shop and Product page?
- wordpress admin-ajax bad request 400