Commit 8b39d395 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer

Clean up the update checker for the advanced plugin

parent df90aafa
......@@ -27,15 +27,15 @@ class OpenToolsPluginUpdateChecker extends PluginUpdateChecker_2_1 {
}
public function declareCredentials($credential_def) {
$this->credvars = $credential_def;
// Append the update credentials to the update server link
$this->addQueryArgFilter(array($this, 'appendQueryArgsCredentials'));
}
protected function installOTHooks()
{
$this->ajaxurl = is_network_admin()?network_admin_url( 'admin-ajax.php' ): admin_url( 'admin-ajax.php' );
// Append the update credentials to the update server link
$this->addQueryArgFilter(array($this, 'appendQueryArgsCredentials'));
add_action('admin_print_scripts-plugins.php', array($this, 'addCredentialCheckScripts'));
add_action('admin_print_styles-plugins.php', array($this, 'addCredentialCheckStyles'));
......@@ -99,6 +99,7 @@ class OpenToolsPluginUpdateChecker extends PluginUpdateChecker_2_1 {
public function displayUpdateCredentialsLink($links, $pluginFile) {
$isRelevant = ($pluginFile == $this->pluginFile)
|| (!empty($this->muPluginFile) && $pluginFile == $this->muPluginFile);
$isRelevant = $isRelevant && !empty($this->credvars);
if ( $isRelevant && current_user_can('update_plugins') ) {
$credentials = $this->getCredentials($this->slug);
......@@ -127,6 +128,7 @@ class OpenToolsPluginUpdateChecker extends PluginUpdateChecker_2_1 {
&& $_REQUEST['slug'] == $this->slug
&& current_user_can('update_plugins')
&& check_ajax_referer('otup_enter_update_credentials');
$showCredentials = $showCredentials && !empty($this->credvars);
if ( $showCredentials && (is_network_admin() || !is_multisite() )) {
$slug = $this->slug;
......@@ -179,7 +181,7 @@ class OpenToolsPluginUpdateChecker extends PluginUpdateChecker_2_1 {
$submitCredentials = $slug == $this->slug
&& current_user_can('update_plugins')
&& check_ajax_referer('otup_enter_update_credentials_'.$slug);
$submitCredentials = $submitCredentials && !empty($this->credvars);
if ( $submitCredentials ) {
$credentials = array();
......@@ -219,7 +221,7 @@ class OpenToolsPluginUpdateChecker extends PluginUpdateChecker_2_1 {
$updateinfo = $this->requestInfo(array());
if ($updateinfo && isset($updateinfo->download_url)) {
$downloadurl = $updateinfo->download_url;
$downloadurl .= (parse_url($downloadurl, PHP_URL_QUERY) ? '&' : '?') . 'check_access=1';
$downloadurl = apply_filters('puc_check_download_query_args-'.$this->slug, $downloadurl);
$headers = get_headers($downloadurl);
list($version, $status_code, $msg) = explode(' ',$headers[0], 3);
......@@ -232,6 +234,10 @@ class OpenToolsPluginUpdateChecker extends PluginUpdateChecker_2_1 {
}
return $success;
}
public function addAccessCheckQueryArgFilter($callback){
add_filter('puc_check_download_query_args-'.$this->slug, $callback);
}
};
......
......@@ -35,6 +35,11 @@ $myUpdateChecker->declareCredentials(array(
'order_number' => __('Order Number:'),
'order_pass' => __('Order Password:'),
));
$myUpdateChecker->addAccessCheckQueryArgFilter('oton_addAccessCheckArg');
function oton_addAccessCheckArg($downloadurl) {
return $downloadurl . (parse_url($downloadurl, PHP_URL_QUERY) ? '&' : '?') . 'check_access=1';
}
// $myUpdateChecker->checkForUpdates();
// *****************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment