2013-07-27 54 views
26

我發現在GPLv2許可下的Wordpress插件很棒,並在源代碼中做了很多更改,現在插件做了其他事情。 我修改了作者(原始插件作者的信用),網址,版本號(從xxx 1.5到yyy 1.0)。Wordpress-如何禁用插件更新

一切都很好,但是當Wordpress檢查插件更新時,它會將我的插件yyy 1.0視爲xxx 1.0,並顯示有關可用更新的通知。

我更改的插件yyy 1.0是通過從我的計算機複製文件而不是從WP存儲庫安裝的。

我還有什麼需要改變的?

+1

FWIW,重命名該文件夾。有時奇蹟與更新跟蹤有關。 – vaxquis

回答

16

在插件文件中,會有一個函數來檢查更新。原作者可能已經爲此命名,所以您必須仔細閱讀代碼並檢查每個函數以及它的功能。我想這個功能對於它的功能會非常明顯。

另外,您可以添加到您的插件文件:

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/

+1

平庸,但我懷疑皮特原來的代碼來自馬克: http://markjaquith.wordpress.com/2009/12/14/excluding-your-plugin-or-theme-from-update-checks/ – jb510

21

將這個代碼在主題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'); 

這裏:

「臉譜-評論-插件」=>評論Facebook的插件文件夾名稱

「臉譜-的comments.php」=>插件主文件。這個可不同像index.php

希望這會有所幫助。

的更多細節my blog.

30

禁用插件更新

在插件的根文件添加該代碼。

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

這種方法只有在插件被激活時纔會刪除通知。仍然顯示更新通知是插件被停用。 –

+1

@ aniskhan001在function.php中添加上面的代碼並禁用特定的插件,如'unset($ value-> response [「akismet/akismet.php」]);' –

+0

這是自使用平臺鉤子以來的最佳解決方案。 – loretoparisi

7

最簡單有效的方法是更改​​不想更新的插件版本。 舉一個例子,如果 我不想wptouch得到更新,我打開它的認定中的文件,該文件是這樣的:

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

*/ 

在這裏的版本變化4.0.4到 這樣的:

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

*/ 
+1

有時它可以工作,但不幸的是這並不總是奏效。 – Gray

7
add_filter('site_transient_update_plugins', '__return_false'); 
在功能

。PHP添加上面的代碼,並禁用所有插件更新

+0

太棒了!非常感謝你。 – adamj

1

這裏是馬克·賈基斯的腳本的更新版本:

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