From 3aaca9b31e3315a66a2ddefd102fc0b20776cac3 Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer <reinhold@kainhofer.com> Date: Tue, 12 Jul 2016 01:28:03 +0200 Subject: [PATCH] Fix entering update credentials when multiple OpenTools plugins are enabled --- assets/js/opentools-updatecheck.js | 4 ++-- opentools-update-checker.php | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/assets/js/opentools-updatecheck.js b/assets/js/opentools-updatecheck.js index 74773fc..3f8f407 100644 --- a/assets/js/opentools-updatecheck.js +++ b/assets/js/opentools-updatecheck.js @@ -9,7 +9,7 @@ var showUpdateCredentialsRow = function (btn) { type: "POST", url: ajaxurl, data: { - action: 'getUpdateCredentialsRow', + action: 'getUpdateCredentialsRow_'+slug, slug: slug, _ajax_nonce: nonce }, @@ -32,7 +32,7 @@ var submitUpdateCredentials = function(btn) { var tr = jQuery(btn).closest('tr'); var data = { - action: 'submitUpdateCredentials', + action: 'submitUpdateCredentials_'+slug, slug: slug, _ajax_nonce: nonce, }; diff --git a/opentools-update-checker.php b/opentools-update-checker.php index 18adb95..b01fa1d 100644 --- a/opentools-update-checker.php +++ b/opentools-update-checker.php @@ -42,8 +42,8 @@ class OpenToolsPluginUpdateChecker extends PluginUpdateChecker_2_1 { // add_filter('plugin_row_meta', array($this, 'displayUpdateCredentialsLink'), 9, 2); add_filter('plugin_action_links_'.$this->pluginFile, array($this, 'displayUpdateCredentialsLink'), 9, 2); - add_action( 'wp_ajax_getUpdateCredentialsRow', array( &$this, 'getUpdateCredentialsRow') ); - add_action( 'wp_ajax_submitUpdateCredentials', array( &$this, 'submitUpdateCredentials') ); + add_action( 'wp_ajax_getUpdateCredentialsRow_'.$this->slug, array( &$this, 'getUpdateCredentialsRow') ); + add_action( 'wp_ajax_submitUpdateCredentials_'.$this->slug, array( &$this, 'submitUpdateCredentials') ); } protected function getCredentials($slug) @@ -128,11 +128,20 @@ class OpenToolsPluginUpdateChecker extends PluginUpdateChecker_2_1 { return; } + $json['showCredentials'] = $showCredentials; + $json['issetSLUG'] = isset($_REQUEST['slug']); + $json['SLUGmatches'] = $_REQUEST['slug'] == $this->slug; + $json['userCanUpdatePlugins'] = current_user_can('update_plugins'); + $json['checkAjax'] = check_ajax_referer('otup_enter_update_credentials'); + $json['NotEmptyCredVars'] = !empty($this->credvars); + + $json['IsNetworkAdmin'] = is_network_admin(); + $json['isMultisite'] = is_multisite(); $showCredentials = isset($_REQUEST['slug']) && $_REQUEST['slug'] == $this->slug && current_user_can('update_plugins') - && check_ajax_referer('otup_enter_update_credentials'); - $showCredentials = $showCredentials && !empty($this->credvars); + && check_ajax_referer('otup_enter_update_credentials') + && !empty($this->credvars); if ( $showCredentials && (is_network_admin() || !is_multisite() )) { $slug = $this->slug; -- GitLab