Wordpress-如何禁用插件更新

问题描述 投票:36回答:8

我在GPLv2许可证下找到了很好的Wordpress插件,并在源代码中做了很多改动,插件现在做了别的事情。我修改了作者(原始插件作者的学分),网址,版本号(从xxx 1.5到yyy 1.0)。

一切都很好,但是当Wordpress检查插件更新时,它会将我的插件yyy 1.0视为xxx 1.0,并显示有关可用更新的通知。

我更改的插件yyy 1.0是通过从我的计算机复制文件而不是从WP存储库复制的。

我还需要改变什么?

wordpress plugins updating
8个回答
21
投票

在插件文件中,将有一个检查更新的函数。原作者可能已将此命名为任何内容,因此您必须完成代码并检查每个函数及其功能。我认为这个功能将非常明显。

或者,您可以将其添加到您的插件文件:

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

致谢:http://developersmind.com/2010/06/12/preventing-wordpress-from-checking-for-updates-for-a-plugin/


37
投票

禁用插件更新

在插件根文件中添加此代码。

add_filter('site_transient_update_plugins', 'remove_update_notification');
function remove_update_notification($value) {
     unset($value->response[ plugin_basename(__FILE__) ]);
     return $value;
} 

29
投票

将此代码放在theme.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' );

这里:

“facebook-comments-plugin”=> facebook评论插件文件夹名称

“facebook-comments.php”=>插件主文件。这可能与index.php不同

希望这会有所帮助。


13
投票

最简单有效的方法是更改​​您不想更新的插件版本。举个例子,如果我不想让wptouch更新,我打开它的defination文件,就像:

/*
    Plugin Name: WPtouch Mobile Plugin
    Plugin URI: http://www.wptouch.com/
    Version: 4.0.4

*/

这里的版本更改4.0.4到9999像:

/*
    Plugin Name: WPtouch Mobile Plugin
    Plugin URI: http://www.wptouch.com/
    Version: 9999

*/

12
投票
add_filter('site_transient_update_plugins', '__return_false');

在function.php中添加上面的代码并禁用所有插件更新


2
投票

这是Mark Jaquith脚本的更新版本:

  • WP更新已切换到HTTPS
  • 在我的共享主机上阻止了反序列化
  • 这使用json_decode和json_encode代替
  • 图片来源:Block Plugin Update

.

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

0
投票

手动禁用插件更新:

  1. 打开functions.php文件(转到激活的主题文件夹)
  2. 复制并粘贴以下代码:

remove_action( 'load-update-core.php', 'wp_update_plugins' );

add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) );

  1. 保存更改,您就完成了

0
投票

将此行添加到wp-config.php以禁用插件更新:

define('DISALLOW_FILE_MODS',true);
© www.soinside.com 2019 - 2024. All rights reserved.