Exemple #1
0
 /**
  * Request for plugin information
  *
  * @param $def
  * @param $action
  * @param $args
  * @return mixed
  */
 public function getPluginInformation($def, $action, $args)
 {
     // slug
     $pluginSlug = $this->_pm->getSlugFilenamePath();
     if (!isset($args->slug) || $args->slug != $this->_pm->getSlug()) {
         // IMPORTANT:
         // this plugin is not responsible for this request
         // return def to not break other plugins
         return $def;
     }
     $result = '';
     // Get the current version
     $plugin_info = get_site_transient('update_plugins');
     if (!empty($this->_pm->getConfig()->debug->update)) {
         $this->_pm->getLogger()->debug('Plugin info check:');
         $this->_pm->getLogger()->debug(var_export($plugin_info, true));
     }
     $current_version = $plugin_info->checked[$pluginSlug];
     if (apply_filters('ifw_woocommerce_is_slug_activated-' . $pluginSlug, false)) {
         $activationData = apply_filters('ifw_woocommerce_get_activation_data-' . $pluginSlug, array());
         $request = $this->_getRequest('upgrade-api');
         if ($request instanceof IfwPsn_Wp_Http_Request) {
             $request->addData('request', 'plugininformation')->addData('plugin_name', $pluginSlug)->addData('version', $current_version)->addData('software_version', $current_version)->addData('activation_email', $activationData['email'])->addData('api_key', $activationData['license'])->addData('domain', $this->_getPlatform())->addData('instance', $this->_getInstance($activationData['license'], $activationData['email']));
         }
         $response = $request->send();
         if ($response->isSuccess()) {
             $responseBody = $response->getBody();
             $result = unserialize($responseBody);
             if ($result === false) {
                 $result = new WP_Error('plugins_api_failed', __('An unknown error occurred'), $request['body']);
             }
         } else {
             $result = new WP_Error('plugins_api_failed', __('An Unexpected HTTP Error occurred during the API request.</p> <p><a href="javascript:void(0)" onclick="document.location.reload(); return false;">Try again</a>'), $response->getErrorMessage());
         }
         if (!empty($this->_pm->getConfig()->debug->update)) {
             $this->_pm->getLogger()->debug(' --- Plugin info check response --- ');
             $this->_pm->getLogger()->debug(var_export($response, true));
         }
     }
     return $result;
 }
Exemple #2
0
 /**
  * Fires at the end of the update message container in each row of the plugins list table.
  *
  * @param array $plugin_data An array of plugin data.
  * @param $meta_data
  */
 public function getUpdateInlineMessage($plugin_data, $meta_data)
 {
     $plugin_slug = $this->_pm->getSlug();
     $request = $this->_getRequest();
     $request->addData('action', 'plugin_update_message')->addData('slug', $plugin_slug)->addData('version', $plugin_data['Version'])->addData('lang', IfwPsn_Wp_Proxy_Blog::getLanguage());
     if ($this->_pm->isPremium()) {
         $license = $this->_getLicenseCode();
         $request->addData('license', $license);
     }
     $response = $request->send();
     if ($response->isSuccess()) {
         if ($this->_pm->isPremium() && empty($license)) {
             printf('<div style="padding: 5px 10px; border: 1px dashed red; margin-top: 10px;">%s</div>', sprintf(__('You have to enter your plugin <b>license code</b> in the <a href="%s">plugin options</a> to be able to download this update!', 'ifw'), $this->_pm->getConfig()->plugin->optionsPage));
         }
         echo $response->getBody();
     }
 }