Updated update server support code.
authorChuck Scott <cscott@gaslightmedia.com>
Thu, 13 Apr 2017 21:29:07 +0000 (17:29 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Thu, 13 Apr 2017 21:29:07 +0000 (17:29 -0400)
defines.php
index.php
lib/opentools-update-checker/js/opentools-updatecheck.js
lib/opentools-update-checker/opentools-update-checker.php
lib/plugin-update-checker/plugin-update-checker.php

index 93e27b3..755902b 100644 (file)
@@ -89,8 +89,4 @@ define('GLM_MEMBERS_PLUGIN_CURRENT_THEME', $glmCurrentTheme->get_template());
 define('GLM_MEMBERS_PLUGIN_CURRENT_THEME_DIR', $glmCurrentTheme->get_template_directory());
 
 // Update Server
-if (GLM_MEMBER_PLUGIN_HOST == 'CHUCK') {
- define('GLM_MEMBERS_PLUGIN_UPDATE_SERVER', 'http://192.168.44.54/update_server');
-} else {
- define('GLM_MEMBERS_PLUGIN_UPDATE_SERVER', 'http://www.gaslightmedia.com/update_server');
-}
+define('GLM_MEMBERS_PLUGIN_UPDATE_SERVER', 'http://www.gaslightmedia.com/update_server');
index 4d31ce1..1b3343b 100644 (file)
--- a/index.php
+++ b/index.php
@@ -711,7 +711,7 @@ function glmCheckDatabase ()
  * Plugin Update Support - uses Gaslight Media update server
  */
 // Do not include this require statement in add-ons to this plugin. The update checker code should only be loaded here.
-require GLM_MEMBERS_PLUGIN_LIB_PATH.'/opentools-update-checker/opentools-update-checker.php';
+require_once GLM_MEMBERS_PLUGIN_LIB_PATH.'/opentools-update-checker/opentools-update-checker.php';
 ${GLM_MEMBERS_PLUGIN_PREFIX."updateChecker"} = new OpenToolsPluginUpdateChecker(
     GLM_MEMBERS_PLUGIN_UPDATE_SERVER.'/?action=get_metadata&slug='.GLM_MEMBERS_PLUGIN_SLUG,
     __FILE__,
index 662a5cf..c064289 100644 (file)
@@ -1,33 +1,36 @@
 /**
  * OpenTools Update Check Admin JS
  */
+var credentialsRowDisplayed = [];
 var showUpdateCredentialsRow = function (btn) {
-    if (showUpdateCredentialsRow.credentialsRowDisplayed) {
-        return;
-    }
-    showUpdateCredentialsRow.credentialsRowDisplayed = true;
     var ajaxurl = jQuery(btn).data('ajaxurl');
     var slug = jQuery(btn).data("slug");
     var nonce = jQuery(btn).data("nonce");
+
+    if (credentialsRowDisplayed[slug]) {
+        return false;
+    }
+    credentialsRowDisplayed[slug] = true;
     var ajaxargs = {
         type: "POST",
         url: ajaxurl,
         data: {
-            action: 'getUpdateCredentialsRow',
+            action: 'getUpdateCredentialsRow_' + slug,
             slug: slug,
             _ajax_nonce: nonce
         },
         success: function ( json ) {
             jQuery(btn).closest('tr').after(json['row']);
         },
-        error: function() {  },
-        complete: function() {  },
+        error: function() { },
+        complete: function() { },
     };
     jQuery.ajax(ajaxargs);
     return false;
 };
 
 var submitUpdateCredentials = function(btn) {
+    
     var ajaxurl = jQuery(btn).data('ajaxurl');
     var slug = jQuery(btn).data("slug");
     var nonce = jQuery(btn).data("nonce");
@@ -36,7 +39,7 @@ var submitUpdateCredentials = function(btn) {
     
     var tr = jQuery(btn).closest('tr');
     var data = { 
-            action: 'submitUpdateCredentials',
+            action: 'submitUpdateCredentials_' + slug,
             slug: slug,
             _ajax_nonce: nonce,
         };
index 853ef8f..6f0b4bb 100644 (file)
@@ -42,8 +42,8 @@ class OpenToolsPluginUpdateChecker extends PluginUpdateChecker_3_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)
@@ -124,14 +124,13 @@ class OpenToolsPluginUpdateChecker extends PluginUpdateChecker_3_1 {
     */
     public function getUpdateCredentialsRow() {
         $json = array('row' => '', 'message'=>'Unsuccessful');
-
         $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);
-
         if ( $showCredentials && (is_network_admin() || !is_multisite() )) {
+
             $slug = $this->slug;
             if ( is_network_admin() ) {
                 $active_class = is_plugin_active_for_network( $this->pluginFile ) ? 'active': '';
@@ -152,7 +151,8 @@ class OpenToolsPluginUpdateChecker extends PluginUpdateChecker_3_1 {
                 $tr .= $credname    . " <input type=\"text\" name=\"otup_update_credentials[$slug][$credkey]\" value=\"" . esc_attr($current_credentials[$credkey]) . "\">&nbsp;&nbsp;&nbsp;";
             }
 
-            $tr .= sprintf('<input type="submit" class="button otup_update_credentials_submit" onclick="return submitUpdateCredentials(this);" data-slug="%s" data-nonce="%s" data-ajaxurl="%s" data-credentialvars=\'%s\'>',
+//            $tr .= sprintf('<input type="submit" class="button otup_update_credentials_submit" onclick="return submitUpdateCredentials(this);" data-slug="%s" data-nonce="%s" data-ajaxurl="%s" data-credentialvars=\'%s\'>',
+            $tr .= sprintf('<div class="button otup_update_credentials_submit" style="line-height: 1.2em; height: 1.5em;" onclick="return submitUpdateCredentials(this);" data-slug="%s" data-nonce="%s" data-ajaxurl="%s" data-credentialvars=\'%s\'>Update License Key</div>',
                 esc_attr($this->slug),
                 esc_attr(wp_create_nonce( 'otup_enter_update_credentials_'.$slug )),
                 esc_attr($this->ajaxurl),
index a056945..38760f4 100644 (file)
@@ -196,13 +196,13 @@ class PluginUpdateChecker_3_1 {
         //Try to parse the response\r
         $status = $this->validateApiResponse($result);\r
         $pluginInfo = null;\r
-// *** CPS ***        if ( !is_wp_error($status) && is_array($status)){\r
-        if ( !is_wp_error($status) && is_array($status)){\r
+        if ( !is_wp_error($status)){\r
             $pluginInfo = PluginInfo_3_1::fromJson($result['body']);\r
             if ( $pluginInfo !== null ) {\r
                 $pluginInfo->filename = $this->pluginFile;\r
                 $pluginInfo->slug = $this->slug;\r
             }\r
+\r
         } else {\r
             return false;\r
             /* Not generating error at this time as this could simply be a bad or missing key submitted\r