我有一个古玩问题,我无法解决。
在我定义的插件主文件上:
add_filter(\'pre_set_site_transient_update_plugins\', array(\'moreads_update\',\'check_4_updates\'));
add_filter(\'plugins_api\', array(\'moreads_update\',\'plugin_api_info\'),10,3);
该类功能:
static public function check_4_updates($checkdata) {
global $wp_version;
//var_dump($checkdata);return $checkdata;
$options = get_option(MABASENAME);
$options = is_serialized($options) ? unserialize($options) : $options;
if (empty($checkdata->checked)) {return $checkdata;}
$args = array(
\'slug\' => MASLUG,
\'version\' => @$checkdata->checked[MASLUG]
);
$request_post = array(
\'body\' => array(
\'action\' => \'plugin_update_check\',
\'token\' => !empty($options[\'token\']) ? trim($options[\'token\']) : \'\',
\'domain\' => !empty($options[\'domain\']) ? trim($options[\'domain\']) : \'\',
\'request\' => serialize($args)
),
\'user-agent\' => \'WordPress/\'.$wp_version.\'; \'.get_bloginfo(\'url\')
);
$raw_response = wp_remote_post(\'http://api.domain.tld/\',$request_post);
$response = false;
if (!is_wp_error($raw_response) && ($raw_response[\'response\'][\'code\'] == 200)) {
$response = is_serialized($raw_response[\'body\']) ? unserialize($raw_response[\'body\']) : $raw_response[\'body\'];
}
if (!empty($response)) {
if(strpos(@$response->package, self::$_apiurl) !== false) { // Only API Domain for Update Server allowed
@$checkdata->response[MASLUG] = $response;
}
}
return $checkdata;
}
static public function plugin_api_info($def, $action, $args) {
global $wp_version;
if (!isset($args->slug) || ($args->slug != MASLUG)) {
return false;
}
$options = get_option(MABASENAME);
$options = is_serialized($options) ? unserialize($options) : $options;
$plugin_info = get_site_transient(\'update_plugins\');
$current_version = @$plugin_info->checked[MASLUG];
$args->version = $current_version;
$request_post = array(
\'body\' => array(
\'action\' => $action,
\'token\' => !empty($options[\'token\']) ? trim($options[\'token\']) : \'\',
\'domain\' => !empty($options[\'domain\']) ? trim($options[\'domain\']) : \'\',
\'request\' => serialize($args)
),
\'user-agent\' => \'WordPress/\'.$wp_version.\'; \'.get_bloginfo(\'url\')
);
$response = wp_remote_post(\'http://api.domain.tld/\',$request_post);
if (is_wp_error($response)) {
$res = new WP_Error(\'plugins_api_failed\', __(\'An unknown error occured while connecting the plugin-API.\').\'</p><p><a href="?" onclick="document.location.reload();return false;">\'.__(\'Try again?\').\'</a>\', $response->get_error_message());
} else {
$res = unserialize($response[\'body\']);
if ($res === false) {
$res = new WP_Error(\'plugins_api_failed\', __(\'Unknown error.\'), $response[\'body\']);
}
}
return $res;
}
API返回了以下对象:
Update:
$erg->slug,
$erg->package,
$erg->new_version,
Plugin-Info:
$erg->slug=array(
\'homepage\',
\'name\',
\'version\',
\'author\',
\'last_updated\',
\'external\',
\'requires\',
\'tested\',
\'downloaded\',
\'package\',
\'download_link\',
\'sections\' => array(
\'description\',
\'change_log\',
\'other_notes\'
)
);
在一个博客上,一切都很好。如果我设置了新版本,更新将显示在Wordpress更新页面上。
但在一个多站点的博客上,我什么都看不到。我只在多站点、网络范围内的一个博客上尝试过,还激活了第一个博客,没有可用的更新。
如果我能和
set_site_transient(\'update_plugins\', null);
add_filter(\'plugins_api_result\',function($res,$action,$args){print_r(array($res,$action,$args));return $res;});
我的更新例程“check\\u 4\\u updates()”不会在多站点上调用!
这里发生了什么事,怎么了?
谢谢Stefan