Plugin Deactivate Self on Activation Errors
You may need to have this line in your code require_once( ABSPATH . ‘wp-admin/includes/plugin.php’ ); The plugin.php file is not automatically included.
You may need to have this line in your code require_once( ABSPATH . ‘wp-admin/includes/plugin.php’ ); The plugin.php file is not automatically included.
Because WordPress already have class named Request https://developer.wordpress.org/reference/classes/requests/ When creating a plugin or using boilerplate to generate, you should add prefix for your plugin name/class name, or avoid using very basic name. Example: class Wpse309780_Request { function __construct(argument) { # code… } }
You first example looks corrent. There is however a typo, hence class ‘MyPluginAdmin’ not found. You include myplugin-admin.php, but then your question seems to suggest the page holding the class is in fact my-plugin-admin.php (with a hypen). If I correct the typo and run the code there are no warnings. Edit (this works correctly): my-plugin.php: … Read more
Per the WP Codex, you need to be sure you are passing the directory and file: <?php If (is_plugin_active(‘plugin-directory/plugin-file.php’)) { //plugin is activated } ?>
I believe the issue is that your function that sets up the settings initially isn’t getting run upon activation. Add a call to your mouldings_register_settings_initial() in the activation hook, like this: function mouldings_activate() { global $wpdb, $mouldings_options; mouldings_register_settings_initial(); if ($mouldings_options === false){ $mouldings_options = array( ‘idea_item_columns’ => ‘4’ ); update_option( ‘mouldings_settings’, $mouldings_options ); } } … Read more
Comments might have been closed once. If you change this option later globally it doesn’t affect existing posts when comments were turned off per post. To test if comments really work create a new post and enable the discussion meta box on that screen: If you can comment while all plugins are disabled and the … Read more
Plugins are activated in a sandbox and their output is captured to check for errors, and redirect if activation was successful. Adding something in an activation hook will cause it to run once in that “invisible” sandbox on activation, and that’s it. When you add an action, you’re only adding it for that request, if … Read more
Method 1 You can use activate_plugin() and deactivate_plugins() to activate/deactivate plugins programmatically. If you want to control the time at which those actions happen, then you can use wp_schedule_event() too. Method 2 I know you asked about PHP, but if you have WP-CLI installed on your server, you can also write a script that uses … Read more
There are few solutions. You can use activate_plugin and deactivate_plugin hooks for example. But… As far as I understand you right, you want to get notified whenever list of plugins get changed and not when a plugin is activated or deactivated. So the easiest way will be hooking onto update_option. add_action(‘updated_option’, function( $option_name, $old_value, $value … Read more
You can add those without a button: register_activation_hook( __FILE__, ‘my_plugin_install_function’); function my_plugin_install_function() { //post status and options $post = array( ‘comment_status’ => ‘closed’, ‘ping_status’ => ‘closed’ , ‘post_author’ => 1, ‘post_date’ => date(‘Y-m-d H:i:s’), ‘post_name’ => ‘Checklists’, ‘post_status’ => ‘publish’ , ‘post_title’ => ‘Checklists’, ‘post_type’ => ‘page’, ); //insert page and save the id $newvalue … Read more