I created a plugin and want to add a function to delete my tables from the database when a user deletes my plugin. I created a function that deletes tables from the DB when a user deactivates my plugin, but I don't want that. Here is the code: // Delete table when deactivate function my_plugin_remove_database() { global $wpdb; $table_name = "NestoNovo"; $sql = "DROP TABLE IF EXISTS $table_name;"; $wpdb->query($sql); delete_option("my_plugin_db_version"); } register_deactivation_hook( __FILE__, 'my_plugin_remove_database' ); As you can see, this …
I received the following error after attempting to update my WordPress to the latest version Fatal error: Call to undefined function wp_cache_get() in /home/fairmftt/public_html/wp-includes/option.php on line 1117 After going through the support forum I deactivated my plugins but this made the problem worse - I now get that error if I go directly to that website. Also, when I log into WordPress (not the dashboard) I can't do anything to the page including updating the error. All the plugins have …
I´m writing an addon. I would like in the install function to stop the activation if the main plugin is inactive. class MyAddon { public function __construct(){ register_activation_hook( __FILE__, array( $this, 'install' ) ); } public function install(){ if ( is_plugin_inactive( 'MainPlugin.php' ) ){ //The addon has to be inactive // Notice for admin to prevent to active the main plugin before. } } } How can I do this ?
I have these plugin files: my-plugin/my-plugin.php my-plugin/my-plugin-class.php In my-plugin.php I have the following line: register_activation_hook( __FILE__, array( $my_plugin_object, 'on_activate_my_plugin' ) ); In my-plugin-class.php I have the following methods: public function on_activate_my_plugin() { if ( // Some validation failed ) { wp_mail( '[email protected]' , 'test', 'test' ); deactivate_plugins( 'my-plugin/my-plugin.php' ); add_action( 'admin_notices', array( $this, 'my_plugin_activation_failed' ) ); } } public function my_plugin_activation_failed() { ?><div class="notice notice-error"><p>The <strong>My Plugin</strong> could not be activated because of something.</p><p>Do the thing and activate the plugin.</p></div><?php …
Hi I'm wondering if someone can point me in the right direction here. I'm having trouble figuring out how deactivate_plugins() works. I've been using variations of the below for awhile now and it's always seemed to work until recently. register_activation_hook(__FILE__, 'my_plugin_activate_deactivate'); add_action('after_switch_theme', 'my_plugin_activate_deactivate'); function my_plugin_activate_deactivate() { if ( !function_exists ('mythemename') { deactivate_plugins( plugin_basename(__FILE__) ); } } The first problem is that the register_activation_hook part doesn't do anything at all... the plugin activates regardless of whether or not mythemename function exists. …
Does deactivating a plugin help with any performance on your website? I mean is it worth deactivating plugins that you don't use constantly? Does uninstalling a plugin make any difference from deactivating a plugin?
So this is what I've read: Many plugins might get WordPress slow if they are activated Many plugins might get WordPress slow even if they are not activated!? An example Let's say I build a large plugin and activate it in WordPress. Later on I figured it would be better to split the plugin into a few plugins instead, just to change the parts individually. The code is still the same. Will my plugins slow down my WordPress because there …
I have a php script that sits outside of wordpress, but loads WP core with wp-load.php. Here is my basic page: <?php define('WP_USE_THEMES', false); global $wp, $wp_query, $wp_the_query, $wp_did_header; require_once('wp-load.php'); switch_to_blog(1); //make sure we're on the top level site $author_id = 77; //admin ?> However, this also loads plugins - one of which (FacetWP) is throwing an error. As I don't need it, I thought I'd deactivate it with: function deactivate_plugin_conditional() { deactivate_plugins('facetwp/index.php'); } add_action( 'admin_init', 'deactivate_plugin_conditional' ); However, this …
I have an AWS server running four WordPress sites. All plugins have been deactivated on one of the sites and I cannot enable them. When I try enabling them in bulk, or individually, there is no error and it even says "Plugin activated.", but they are not. I have tried changing the ACLs temporarily, so that the webserver has full access. I have tried moving directories of plugins that have been recently updated, but nothing works. I have found that …
I'm working on my first plugin and am trying to use register_activation_hook() and register_deactivation_hook() ... I know I'm not doing this right: /*====================================================*/ // 1.0 Actions to perform upon plugin activation /*====================================================*/ register_activation_hook( __FILE__, 'construct_uploader_page' ); register_activation_hook( __FILE__, 'construct_terms_page' ); register_activation_hook( __FILE__, 'create_custom_user_role' ); // Construct Event Photo Uploader template page function construct_uploader_page() { $post_id = -1; // Setup custom vars $author_id = 1; $slug = 'event-photo-uploader'; $title = 'Event Photo Uploader'; // Check if page exists... if not, create …
I kinda did something stupid. To test something I created a couple of plugins and during testing I think I renamed the plugin. Now I deleted the plugins but I'm still getting an error message saying the plugin couldn't be found: The plugin something else has been deactivated due to an error: Plugin file does not exist. I searched the database and there's an activate_plugins entry in wp_options. It contains the following: a:4:{i:0;s:23:"bandpress/bootstrap.php";i:3;s:56:"posts-from-single-category-widget/post_from_category.php";i:4;s:15:"something else ";i:5;s:68:"syntax-highlighter-with-add-button-in-editor/syntaxhighlighterpp.php";} So, I think I need …
I've successfully added admin notices to display on register_activation_hook, and when the plugin updates, but I'm not seeing any way to display admin_notices after the uninstall or deactivation hooks. Is this at all possible? Alternatively can use javascript at this stage? (yes sort of). EDIT: To answer @G. M. I've already read the docs and @kaiser I've already seen your great writeup on these hooks, but unless I've been sloppy and missed something these two hooks seem to operate differently …
I've got two environments in my project: dev & production. I just want to be able to deactivate or disable W3TC in my dev environment but the plugin has no native support for this . I also can't find a deactivate hook that works with the plugin and setting define('WP_CACHE', false); based on HTTP_HOST seems to be bypassed in wp-config.php. So surely this has come up before for people - what is the solution?
We recently deactivated the bbPress plugin because we don't use it anymore. Immediately following that, no admin users can get into the dashboard without hitting the infamous: "You do not have sufficient permissions to access this page?" We tried removing ALL plugins to rule out a dependance from one of those, but it didn't work.
I want to display a message when the user try to activate my plugin. This message will ask if him really wants to activate the plugin or, if him change his mind, cancel the activation. How can I accomplish that? This is the code for the warning message just for reference. --- UPDATED CODE --- register_activation_hook( __FILE__, 'on_activation' ); function on_activation() { // Add the admin notice: add_action( 'admin_notices', 'on_activation_note' ); // Then you should check the DB option: $plugins …
I would like that every time any plugin previously activated, a function from my plugin be called, returning (at least) the name of the plugin, or something that allows to identify it (file name?). I figured i could use the action hook "deactivated_plugin" but i'm wondering what information from the desactivated plugin is actually available?