Wordpress-如何禁用插件更新
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17897044/
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
Wordpress- how to disable plugin update
提问by pp_1
I've found great plugin for Wordpress under GPLv2 licence and made a lot of changes in source code, plugin does something else now. I modified author (with original plugin author's credits), url, version number (from xxx 1.5 to yyy 1.0).
我在 GPLv2 许可下找到了很棒的 Wordpress 插件,并对源代码进行了大量更改,插件现在可以做其他事情。我修改了作者(使用原始插件作者的学分)、网址、版本号(从 xxx 1.5 到 yyy 1.0)。
Everything works great, but when Wordpress checks for plugin updates it treats my plugin yyy 1.0 as xxx 1.0 and displays notification about availible update.
一切正常,但是当 Wordpress 检查插件更新时,它会将我的插件 yyy 1.0 视为 xxx 1.0 并显示有关可用更新的通知。
My changed plugin yyy 1.0 was installed by copying files from my computer, not from WP repository.
我更改的插件 yyy 1.0 是通过从我的计算机而不是从 WP 存储库复制文件来安装的。
What else do I have to change?
我还需要改变什么?
采纳答案by danyo
In the plugin file, there will be a function that will check for updates. The original author could have named this anything, so you will have to go through the code and check each function and what it does. I would imagine the function will be quite obvious as to what it does.
在插件文件中,会有一个检查更新的功能。原作者可以将其命名为任何名称,因此您必须仔细阅读代码并检查每个函数及其作用。我想这个功能对于它的作用会很明显。
Alternatively you can add this to your plugin file:
或者,您可以将其添加到您的插件文件中:
add_filter( 'http_request_args', 'dm_prevent_update_check', 10, 2 );
function dm_prevent_update_check( $r, $url ) {
if ( 0 === strpos( $url, 'http://api.wordpress.org/plugins/update-check/' ) ) {
$my_plugin = plugin_basename( __FILE__ );
$plugins = unserialize( $r['body']['plugins'] );
unset( $plugins->plugins[$my_plugin] );
unset( $plugins->active[array_search( $my_plugin, $plugins->active )] );
$r['body']['plugins'] = serialize( $plugins );
}
return $r;
}
Credits: http://developersmind.com/2010/06/12/preventing-wordpress-from-checking-for-updates-for-a-plugin/
学分:http: //developersmind.com/2010/06/12/preventing-wordpress-from-checking-for-updates-for-a-plugin/
回答by Kishan Chauhan
Disable plugin update
禁用插件更新
Add this code in your plugin root file.
将此代码添加到您的插件根文件中。
add_filter('site_transient_update_plugins', 'remove_update_notification');
function remove_update_notification($value) {
unset($value->response[ plugin_basename(__FILE__) ]);
return $value;
}
回答by Sumith Harshan
Put this code in the theme functions.php file. This is working for me and I'm using it. Also this is for specific plugin. Here you need to change plugin main file url to match to that of your plugin.
将此代码放在主题functions.php 文件中。这对我有用,我正在使用它。这也是针对特定插件的。在这里,您需要更改插件主文件 url 以匹配您的插件。
function my_filter_plugin_updates( $value ) {
if( isset( $value->response['facebook-comments-plugin/facebook-comments.php'] ) ) {
unset( $value->response['facebook-comments-plugin/facebook-comments.php'] );
}
return $value;
}
add_filter( 'site_transient_update_plugins', 'my_filter_plugin_updates' );
Here:
这里:
"facebook-comments-plugin" => facebook comments plugin folder name
“facebook-comments-plugin”=> facebook 评论插件文件夹名称
"facebook-comments.php" => plugin main file.this may be different like index.php
"facebook-comments.php" => 插件主文件。这可能与 index.php 不同
Hope this would be help.
希望这会有所帮助。
回答by Abhinav bhardwaj
The simplest and effective way is to change the version of the plugin which you don't want to get update. For an example if I don't want wptouch to get updated, I open it's defination file, which is like:
最简单有效的方法是更改您不想更新的插件版本。例如,如果我不希望 wptouch 更新,我会打开它的定义文件,如下所示:
/*
Plugin Name: WPtouch Mobile Plugin
Plugin URI: http://www.wptouch.com/
Version: 4.0.4
*/
Here in the Version change 4.0.4to 9999like:
在版本中将4.0.4更改为9999,例如:
/*
Plugin Name: WPtouch Mobile Plugin
Plugin URI: http://www.wptouch.com/
Version: 9999
*/
回答by victor
add_filter('site_transient_update_plugins', '__return_false');
in function.php add above code and disable all plugins updates
在function.php中添加上面的代码并禁用所有插件更新
回答by skibulk
Here's an updated version of Mark Jaquith's script:
这是 Mark Jaquith 脚本的更新版本:
- WP Updates have switched to HTTPS
- Unserialize was blocked on my shared hosting
- This uses json_decode and json_encode instead
- Credit: Block Plugin Update
- WP 更新已切换到 HTTPS
- 反序列化在我的共享主机上被阻止
- 这使用 json_decode 和 json_encode 代替
- 信用:块插件更新
.
.
add_filter( 'http_request_args', 'widget_disable_update', 10, 2 );
function widget_disable_update( $r, $url ) {
if ( 0 === strpos( $url, 'https://api.wordpress.org/plugins/update-check/' ) ) {
$my_plugin = plugin_basename( __FILE__ );
$plugins = json_decode( $r['body']['plugins'], true );
unset( $plugins['plugins'][$my_plugin] );
unset( $plugins['active'][array_search( $my_plugin, $plugins['active'] )] );
$r['body']['plugins'] = json_encode( $plugins );
}
return $r;
}
回答by Hemant Ramphul
Disable plugin updates manually:
手动禁用插件更新:
- Open functions.php file (go to your activated themes folder)
- Copy and paste the following code:
- 打开functions.php文件(转到您激活的主题文件夹)
- 复制并粘贴以下代码:
remove_action( 'load-update-core.php', 'wp_update_plugins' );
remove_action( 'load-update-core.php', 'wp_update_plugins' );
add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) );
add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) );
- Save changes, and you're done
- 保存更改,你就完成了
回答by Tanto Prihartanto
Add this line to wp-config.php to disable plugin updates:
将此行添加到 wp-config.php 以禁用插件更新:
define('DISALLOW_FILE_MODS',true);
回答by tanius
Just for completeness, here is one more plugin meant to block updates of selected other plugins:
为了完整起见,这里还有一个插件,用于阻止所选其他插件的更新:
https://github.com/daggerhart/lock-plugins
https://github.com/daggerhart/lock-plugins
Some information about its background and mode of function can be found here(in German).
可以在此处(德语)找到有关其背景和功能模式的一些信息。