Updated Update Server related code.
authorChuck Scott <cscott@gaslightmedia.com>
Fri, 14 Apr 2017 15:18:33 +0000 (11:18 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Fri, 14 Apr 2017 15:18:33 +0000 (11:18 -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/languages/plugin-update-checker-fr_FR.po
lib/plugin-update-checker/languages/plugin-update-checker-hu_HU.po
lib/plugin-update-checker/languages/plugin-update-checker.pot
lib/plugin-update-checker/plugin-update-checker.php

index 29d59bf..edee637 100644 (file)
@@ -36,7 +36,7 @@ define('GLM_SERVERSTATS_PLUGIN_DEBUG_SMARTY', false);
  *  global instances from clashing with instances in other plugins.
  */
 $vprefix = str_replace('-', '_', GLM_SERVERSTATS_PLUGIN_SLUG);
-define('GLM_SERVERSTATS_PREFIX', $vprefix.'_');
+define('GLM_SERVERSTATS_PLUGIN_PREFIX', $vprefix.'_');
 
 // URLs
 define('GLM_SERVERSTATS_SITE_BASE_URL', home_url('/') );
@@ -60,3 +60,5 @@ define('GLM_SERVERSTATS_PLUGIN_CONFIG_PATH', GLM_SERVERSTATS_PLUGIN_PATH.'/confi
 define('GLM_SERVERSTATS_PLUGIN_MODEL_PATH', GLM_SERVERSTATS_PLUGIN_PATH.'/models');
 define('GLM_SERVERSTATS_PLUGIN_VIEW_PATH', GLM_SERVERSTATS_PLUGIN_PATH.'/views');
 
+// Update Server
+define('GLM_SERVERSTATS_PLUGIN_UPDATE_SERVER', 'http://www.gaslightmedia.com/update_server');
\ No newline at end of file
index 3431ce7..6b668e2 100644 (file)
--- a/index.php
+++ b/index.php
@@ -180,23 +180,19 @@ function serverStatsController($model)
 
 }
 
-
 /*
  * Plugin Update Support - uses Gaslight Media update server
  */
-require GLM_SERVERSTATS_PLUGIN_LIB_PATH.'/opentools-update-checker/opentools-update-checker.php';
-${GLM_SERVERSTATS_PREFIX."updateChecker"} = new OpenToolsPluginUpdateChecker(
-     'http://www.gaslightmedia.com/update_server/?action=get_metadata&slug='.GLM_SERVERSTATS_PLUGIN_SLUG,
+require_once GLM_SERVERSTATS_PLUGIN_LIB_PATH.'/opentools-update-checker/opentools-update-checker.php';
+${GLM_SERVERSTATS_PLUGIN_PREFIX."updateChecker"} = new OpenToolsPluginUpdateChecker(
+    GLM_SERVERSTATS_PLUGIN_UPDATE_SERVER.'/?action=get_metadata&slug='.GLM_SERVERSTATS_PLUGIN_SLUG,
     __FILE__,
     GLM_SERVERSTATS_PLUGIN_SLUG
 );
-
-${GLM_SERVERSTATS_PREFIX."updateChecker"}->declareCredentials(array(
-  'license_key' => __('License Key:')
+${GLM_SERVERSTATS_PLUGIN_PREFIX."updateChecker"}->declareCredentials(array(
+    'license_key' => __('License Key:')
 ));
 
-
-
 /*
 *
 * Activate and Deactivate hooks
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 bcbcd15..b5df93a 100644 (file)
@@ -25,7 +25,7 @@ msgid "Check for updates"
 msgstr "Vérifier les mises à jour"
 
 #: plugin-update-checker.php:681
-msgid "This plugin is up to date."
+msgid "No plugin update available."
 msgstr "Ce plugin est à jour."
 
 #: plugin-update-checker.php:683
index df22657..13c71f5 100644 (file)
@@ -25,7 +25,7 @@ msgid "Check for updates"
 msgstr "Frissítés ellenőrzése"
 
 #: plugin-update-checker.php:896
-msgid "This plugin is up to date."
+msgid "No plugin update available."
 msgstr "Ez a plugin naprakész."
 
 #: plugin-update-checker.php:898
index bcbbd84..6923604 100644 (file)
@@ -26,7 +26,7 @@ msgid "Check for updates"
 msgstr ""
 
 #: plugin-update-checker.php:896
-msgid "This plugin is up to date."
+msgid "No plugin update available."
 msgstr ""
 
 #: plugin-update-checker.php:898
index 4855629..38760f4 100644 (file)
@@ -196,18 +196,22 @@ class PluginUpdateChecker_3_1 {
         //Try to parse the response\r
         $status = $this->validateApiResponse($result);\r
         $pluginInfo = null;\r
-        if ( !is_wp_error($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
             $this->triggerError(\r
                 sprintf('The URL %s does not point to a valid plugin metadata file. ', $url)\r
                     . $status->get_error_message(),\r
                 E_USER_WARNING\r
             );\r
+            */\r
         }\r
 \r
         $pluginInfo = apply_filters('puc_request_info_result-'.$this->slug, $pluginInfo, $result);\r
@@ -805,7 +809,7 @@ class PluginUpdateChecker_3_1 {
         if ( isset($_GET['puc_update_check_result'], $_GET['puc_slug']) && ($_GET['puc_slug'] == $this->slug) ) {\r
             $status = strval($_GET['puc_update_check_result']);\r
             if ( $status == 'no_update' ) {\r
-                $message = __('This plugin is up to date.', 'plugin-update-checker');\r
+                $message = __('No plugin update available.', 'plugin-update-checker');\r
             } else if ( $status == 'update_available' ) {\r
                 $message = __('A new version of this plugin is available.', 'plugin-update-checker');\r
             } else {\r