From 0cef2ae07c4081cc6e1e06019adb30b164c3801b Mon Sep 17 00:00:00 2001 From: jaswsinc Date: Sun, 4 Jan 2015 01:33:00 -0900 Subject: [PATCH] FTP/SFTP upgrade compat. See: websharks/quick-cache#389 --- quick-cache-pro/quick-cache-pro.inc.php | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/quick-cache-pro/quick-cache-pro.inc.php b/quick-cache-pro/quick-cache-pro.inc.php index 311d5ae1..235b8082 100644 --- a/quick-cache-pro/quick-cache-pro.inc.php +++ b/quick-cache-pro/quick-cache-pro.inc.php @@ -407,6 +407,7 @@ public function setup() add_filter('enable_live_network_counts', array($this, 'update_blog_paths')); + add_filter('fs_ftp_connection_types', array($this, 'fs_ftp_connection_types')); add_filter('pre_site_transient_update_plugins', array($this, 'pre_site_transient_update_plugins')); add_filter('plugin_action_links_'.plugin_basename($this->file), array($this, 'add_settings_link')); @@ -894,6 +895,44 @@ public function check_update_sync_version() $update_sync_page, $update_sync_response['version']), 'persistent-update-sync-version'); } + /** + * Appends hidden inputs for pro updater when FTP credentials are requested by WP. + * + * @since 14xxxx See: + * + * @attaches-to `fs_ftp_connection_types` filter. + * + * @param array $types Types of connections. + * + * @return array $types Types of connections. + */ + public function fs_ftp_connection_types($types) + { + if(!is_admin() || $GLOBALS['pagenow'] !== 'update.php') + return $types; // Nothing to do here. + + $_r = array_map('trim', stripslashes_deep($_REQUEST)); + + if(empty($_r['action']) || $_r['action'] !== 'upgrade-plugin') + return $types; // Nothing to do here. + + if(empty($_r[__NAMESPACE__.'__update_version']) || !($update_version = (string)$_r[__NAMESPACE__.'__update_version'])) + return $types; // Nothing to do here. + + if(empty($_r[__NAMESPACE__.'__update_zip']) || !($update_zip = (string)$_r[__NAMESPACE__.'__update_zip'])) + return $types; // Nothing to do here. + + echo ''; + + return $types; // Filter through. + } + /** * Modifies transient data associated with this plugin. *