php WordPress 通过数据库停用插件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2624551/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 07:08:44  来源:igfitidea点击:

WordPress deactivate a plugin via database?

phpwordpress

提问by Scott B

I have a wordpress script, wp-supercache, that I need to disable (as its cached on a nasty error), however, the error is causing the wp-admin redirect to fail, which means I can't get into the site to disable the plugin.

我有一个 wordpress 脚本 wp-supercache,我需要禁用它(因为它缓存在一个令人讨厌的错误上),但是,该错误导致 wp-admin 重定向失败,这意味着我无法进入该站点禁用插件。

Any advice? I can access the database via cpanel.

有什么建议吗?我可以通过 cpanel 访问数据库。

采纳答案by Sarfraz

Try re-naming the folder of the plugin and then see if error is gone (make backup first of course.). If that does not help, here is the solutionthen.

尝试重新命名插件的文件夹,然后查看错误是否消失(当然先备份。)。如果这没有帮助,那么这里是解决方案

回答by sameers

To disable a specific plugin, you have to remove it from the serialized string that stores the list of all plugins - that's set in the option_valuecolumn of the wp_optionstable as discussed by @TimDurden. The specific format change you have to make is, taken shamelessly from teh Internet:

要禁用特定插件,您必须将其从存储所有插件列表的序列化字符串中删除 -如@TimDurden所述option_value,该wp_options列表设置在表的列中。您必须进行的特定格式更改是从互联网上无耻地获取的

a:4:{
    i:0;s:19:"akismet/akismet.php";
    i:1;s:36:"google-sitemap-generator/sitemap.php";
    i:2;s:55:"google-syntax-highlighter/google_syntax_highlighter.php";
    i:3;s:29:"wp-swfobject/wp-swfobject.php";
}

That first set of characters - a:4- designates an array and its length. Note also that each line in the list of plugins has an index. So:

第一组字符 --a:4指定一个数组及其长度。另请注意,插件列表中的每一行都有一个索引。所以:

  1. Decrement the index (from 4 to 3 in this case)
  2. In each line, decrement the number after the i:
  3. Remove the specific plugin you want to disable.
  1. 减少索引(在这种情况下从 4 到 3)
  2. 在每一行中,减少后面的数字 i:
  3. 删除要禁用的特定插件。

Update the value in the db using the new string you constructed from these steps:

使用您通过以下步骤构建的新字符串更新数据库中的值:

update wp_options set option_value=<new value> where option_id=<id of this option>

Note that your table name might not be wp_options - you might have a prefix to add.

请注意,您的表名可能不是 wp_options - 您可能需要添加前缀。

回答by user183037

You only need to rename the folder in /wp-content/plugins/ and the plugin will be automatically de-activated. Once it is de-activated, you will be able to login.

您只需要重命名 /wp-content/plugins/ 中的文件夹,插件就会自动停用。取消激活后,您就可以登录了。

回答by michalzuber

  1. Backup database or just the wp_options table
  2. SELECT option_value FROM wp_options WHERE option_name = 'active_plugins';

  3. Copy selected string (serialized string) and paste in the left side at https://serializededitor.com/
  4. Remove the line which plugin you want to deactivate
  5. Copy the serialized result string from the right side and update active_plugins value with it.

    UPDATE wp_options SET option_value = 'THE_NEW_SERIALIZED_STRING' WHERE option_name = 'active_plugins' LIMIT 1;

  1. 备份数据库或只是 wp_options 表
  2. SELECT option_value FROM wp_options WHERE option_name = 'active_plugins';

  3. 复制选定的字符串(序列化字符串)并粘贴到https://serializededitor.com/的左侧
  4. 删除要停用的插件行
  5. 从右侧复制序列化的结果字符串并用它更新 active_plugins 值。

    更新 wp_options SET option_value = 'THE_NEW_SERIALIZED_STRING' WHERE option_name = 'active_plugins' LIMIT 1;

回答by Barkster

I wrote a little exe in .dot to repair/remove options string from database.

我在 .dot 中编写了一个小 exe 来修复/删除数据库中的选项字符串。

  1. Download exe here
  2. Run on MySQL server
  1. 在这里下载exe
  2. 在 MySQL 服务器上运行

SELECT * FROM wp_options WHERE option_name = 'active_plugins';

SELECT * FROM wp_options WHERE option_name = 'active_plugins';

  1. Paste Results in textbox, press parse.
  2. Remove the ones you don't want.
  3. Click output, it copies output to clipboard
  4. replace brackets inside the single quotes below with output and Run on MySQL server
  1. 将结果粘贴到文本框中,按解析。
  2. 删除你不想要的。
  3. 单击输出,它将输出复制到剪贴板
  4. 用输出替换下面单引号内的括号并在 MySQL 服务器上运行

UPDATE wp_options SET option_value = '[replace inside single quotes with your output' WHERE option_name = 'active_plugins';

UPDATE wp_options SET option_value = '[用您的输出替换单引号内' WHERE option_name = 'active_plugins';

  1. No warranties... I don't claim to be programmer
  1. 没有保证......我不声称自己是程序员

enter image description here

在此处输入图片说明

回答by tjdurden

To disable all Wordpress plugins on your site:

要禁用您网站上的所有 Wordpress 插件:

  1. Login to your database management tool (e.g. PHPMyAdmin)
  2. Execute the following query:
  1. 登录到您的数据库管理工具(例如 PHPMyAdmin)
  2. 执行以下查询:

UPDATE wp_options SET option_value = '' WHERE option_name = 'active_plugins';

UPDATE wp_options SET option_value = '' WHERE option_name = 'active_plugins';

回答by Bhargav Mehta

Another way to do this is you can backup the site and then just rename the folder of the plugin under /wp-content/plugins/ to some other name . So the plugin will be disabled. I wont prefer deleting the plugin folder as it may cause errors. After the step is done log in to your wordpress site and delete the plugin from there

另一种方法是您可以备份站点,然后将 /wp-content/plugins/ 下的插件文件夹重命名为其他名称。所以插件将被禁用。我不喜欢删除插件文件夹,因为它可能会导致错误。完成该步骤后,登录您的 wordpress 站点并从那里删除插件

回答by P Manoj MJ

You just need to change the values in the record "active_plugins" in the database. You can find the process Here

您只需要更改数据库中“active_plugins”记录中的值。你可以在这里找到这个过程

回答by Anil Jadhav

Using this code you can activate your plugin from the functions.php:

使用此代码,您可以从以下位置激活您的插件functions.php

function activate_plugin_via_php() {
    $active_plugins = get_option( 'active_plugins' );
    array_push($active_plugins, 'unyson/unyson.php'); /* Here just replace unyson plugin directory and plugin file*/
    update_option( 'active_plugins', $active_plugins );
}
add_action( 'init', 'activate_plugin_via_php' );

回答by Nimeshka Srimal

Late answer,but answering as it will be useful to someone in the future. All the plugins are stored in the wp_options table in a serialized manner. U can edit this field manually. Or if you unserialize it using a function like in php using unserialize(), you will get an array. just modify it to remove the plugin you want to remove from that array, and serialize it back. then update the table. Thats it. If you want to know more about it hereis a good article. It explains all about this.

迟到的答案,但回答,因为它将来会对某人有用。所有插件都以序列化的方式存储在 wp_options 表中。您可以手动编辑此字段。或者,如果您使用像在 php 中使用 unserialize() 的函数反序列化它,您将获得一个数组。只需修改它以删除要从该数组中删除的插件,然后将其序列化。然后更新表。就是这样。如果你想了解更多,这里是一篇很好的文章。它解释了这一切。