首先,我们要在plugins_loaded之前建立一个钩子(也可以新建一个插件,文件夹名字设置为aaaaaaaa,文件名也设置这个,目的是让插件靠前加载)。
代码如下:
add_action("plugins_loaded","plugins_loaded_yinjiangbi");
function plugins_loaded_yinjiangbi(){
add_filter(
'site_transient_update_plugins',
function($transient) {
$start = microtime( true );
// echo '<pre>';
//需要更新 $transient->translations;
//无需更新 $transient->no_update
//var_dump($transient->no_update["accelerated-mobile-pages/accelerated-moblie-pages.php"]);
// var_dump($transient->no_update);
// exit;
$default_headers = array(
'Name' => 'Plugin Name',
'PluginURI' => 'Plugin URI',
'Version' => 'Version',
'Description' => 'Description',
'Author' => 'Author',
'AuthorURI' => 'Author URI',
'TextDomain' => 'Text Domain',
'DomainPath' => 'Domain Path',
'Network' => 'Network',
'RequiresWP' => 'Requires at least',
'RequiresPHP' => 'Requires PHP',
'UpdateURI' => 'Update URI',
// Site Wide Only is deprecated in favor of Network.
'_sitewide' => 'Site Wide Only',
);
foreach ($transient->no_update as $key=>$value) {
// echo $plugin_data['Name']."<br>";
// var_dump($value->package);
$can_update_plugins[] = $key;
}
// var_dump($can_update_plugins);
$active_plugins = get_option("active_plugins");
foreach ($active_plugins as $active_plugin){
// var_dump($active_plugin);
if(is_array($can_update_plugins)){
if(!in_array($active_plugin,$can_update_plugins)){
$dont_can_update_plugins[] = $active_plugin;
}
}
}
$aaa = file_get_contents(ABSPATH."wp-content/plugins/1.txt");
if($aaa == ""){
foreach ($dont_can_update_plugins as $dont_can_update_plugin){
// echo $dont_can_update_plugin."<br>";
$plugin_data = get_file_data( ABSPATH."wp-content/plugins/".$dont_can_update_plugin, $default_headers, 'plugin' );
file_put_contents(ABSPATH."wp-content/plugins/1.txt",$dont_can_update_plugin.'----'.$plugin_data['UpdateURI'].PHP_EOL, FILE_APPEND);
}
}
// exit;
}
);
}
© 版权声明
THE END
暂无评论内容