Plugin won’t activate – cannot declare class (already in use)

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… } }

How to properly setup an activation hook

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

Default Plugin Settings Not Writing to Database

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 deactivated

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

How to automate wordpress plugin activate and deactivate by php logic?

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

Detect when any plugin is activated or deactivated

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)