コード例 #1
0
 /**
  * Sync plugin's add-on license.
  *
  * @author Vova Feldman (@svovaf)
  * @since  1.0.6
  * @uses   FS_Api
  *
  * @param number $addon_id
  * @param bool   $background
  */
 private function _sync_addon_license($addon_id, $background)
 {
     $this->_logger->entrance();
     if ($this->is_addon_activated($addon_id)) {
         // If already installed, use add-on sync.
         $fs_addon = self::get_instance_by_id($addon_id);
         $fs_addon->_sync_license($background);
         return;
     }
     // Validate add-on exists.
     $addon = $this->get_addon($addon_id);
     if (!is_object($addon)) {
         return;
     }
     // Add add-on into account add-ons.
     $account_addons = $this->get_account_addons();
     if (!is_array($account_addons)) {
         $account_addons = array();
     }
     $account_addons[] = $addon->id;
     $account_addons = array_unique($account_addons);
     $this->_store_account_addons($account_addons);
     // Load add-on licenses.
     $licenses = $this->_fetch_licenses($addon->id);
     // Sync add-on licenses.
     if (!isset($licenses->error)) {
         $this->_update_licenses($licenses, $addon->slug);
         if (!$this->is_addon_installed($addon->slug) && FS_License_Manager::has_premium_license($licenses)) {
             $plans_result = $this->get_api_site_or_plugin_scope()->get("/addons/{$addon_id}/plans.json");
             if (!isset($plans_result->error)) {
                 $plans = array();
                 foreach ($plans_result->plans as $plan) {
                     $plans[] = new FS_Plugin_Plan($plan);
                 }
                 $this->_admin_notices->add_sticky(FS_Plan_Manager::instance()->has_free_plan($plans) ? sprintf(__fs('addon-successfully-upgraded-message', $this->_slug), $addon->title) . ' ' . $this->_get_latest_download_link(__fs('download-latest-version', $this->_slug), $addon_id) : sprintf(__fs('addon-successfully-purchased-message', $this->_slug), $addon->title) . ' ' . $this->_get_latest_download_link(__fs('download-latest-version', $this->_slug), $addon_id), 'addon_plan_upgraded_' . $addon->slug, __fs('yee-haw', $this->_slug) . '!');
             }
         }
     }
 }
コード例 #2
0
ファイル: class-freemius.php プロジェクト: kitchenseeker/www
 /**
  * Sync plugin's add-on license.
  *
  * @author Vova Feldman (@svovaf)
  * @since  1.0.6
  * @uses   FS_Api
  *
  * @param number $addon_id
  * @param bool   $background
  */
 private function _sync_addon_license($addon_id, $background)
 {
     $this->_logger->entrance();
     if ($this->is_addon_activated($addon_id)) {
         // If already installed, use add-on sync.
         $fs_addon = self::get_instance_by_id($addon_id);
         $fs_addon->_sync_license($background);
         return;
     }
     // Validate add-on exists.
     $addon = $this->get_addon($addon_id);
     if (!is_object($addon)) {
         return;
     }
     // Add add-on into account add-ons.
     $account_addons = $this->get_account_addons();
     if (!is_array($account_addons)) {
         $account_addons = array();
     }
     $account_addons[] = $addon->id;
     $account_addons = array_unique($account_addons);
     $this->_store_account_addons($account_addons);
     // Load add-on licenses.
     $licenses = $this->_fetch_licenses($addon->id);
     // Sync add-on licenses.
     if (!isset($licenses->error)) {
         $this->_update_licenses($licenses, $addon->slug);
         if (!$this->is_addon_installed($addon->slug) && FS_License_Manager::has_premium_license($licenses)) {
             $plans_result = $this->get_api_site_or_plugin_scope()->get("/addons/{$addon_id}/plans.json");
             if (!isset($plans_result->error)) {
                 $plans = $plans_result->plans;
                 $this->_admin_notices->add_sticky(FS_Plan_Manager::instance()->has_free_plan($plans) ? sprintf(__('Your %s Add-on plan was successfully upgraded.', WP_FS__SLUG), $addon->title) . ' ' . $this->_get_latest_download_link(__('Download the latest version now', WP_FS__SLUG), $addon_id) : sprintf(__('%s Add-on was successfully purchased.', WP_FS__SLUG), $addon->title) . ' ' . $this->_get_latest_download_link(__('Download the latest version now', WP_FS__SLUG), $addon_id), 'addon_plan_upgraded', __('Ye-ha!', WP_FS__SLUG));
             }
         }
     }
 }