예제 #1
0
 /**
  * Tries to activate add-on account based on parent plugin info.
  *
  * @author Vova Feldman (@svovaf)
  * @since  1.0.6
  *
  * @param Freemius $parent_fs
  */
 private function _activate_addon_account(Freemius $parent_fs)
 {
     if ($this->is_registered()) {
         // Already activated.
         return;
     }
     // Activate add-on with parent plugin credentials.
     $addon_install = $parent_fs->get_api_site_scope()->call("/addons/{$this->_plugin->id}/installs.json", 'post', $this->get_install_data_for_api(array('uid' => $this->get_anonymous_id()), false, false));
     if (isset($addon_install->error)) {
         $this->_admin_notices->add(sprintf(__fs('could-not-activate-x', $this->_slug), $this->get_plugin_name()) . ' ' . __fs('contact-us-with-error-message', $this->_slug) . ' ' . '<b>' . $addon_install->error->message . '</b>', __fs('oops', $this->_slug) . '...', 'error');
         return;
     }
     // First of all, set site info - otherwise we won't
     // be able to invoke API calls.
     $this->_site = new FS_Site($addon_install);
     // Sync add-on plans.
     $this->_sync_plans();
     // Get site's current plan.
     $this->_site->plan = $this->_get_plan_by_id($this->_site->plan->id);
     // Get user information based on parent's plugin.
     $user = $parent_fs->get_user();
     $this->_set_account($user, $this->_site);
     // Sync licenses.
     $this->_sync_licenses();
     // Try to activate premium license.
     $this->_activate_license(true);
 }
예제 #2
0
 /**
  * Tries to activate add-on account based on parent plugin info.
  *
  * @author Vova Feldman (@svovaf)
  * @since  1.0.6
  *
  * @param Freemius $parent_fs
  */
 private function _activate_addon_account(Freemius $parent_fs)
 {
     if ($this->is_registered()) {
         // Already activated.
         return;
     }
     // Activate add-on with parent plugin credentials.
     $addon_install = $parent_fs->get_api_site_scope()->call("/addons/{$this->_plugin->id}/installs.json", 'post', array('title' => get_bloginfo('name'), 'version' => $this->get_plugin_version(), 'language' => get_bloginfo('language'), 'charset' => get_bloginfo('charset'), 'platform_version' => get_bloginfo('version')));
     if (isset($addon_install->error)) {
         $this->_admin_notices->add(sprintf(__('Couldn\'t activate %s. Please contact us with the following message: %s', WP_FS__SLUG), $this->get_plugin_name(), '<b>' . $addon_install->error->message . '</b>'), 'Oops...', 'error');
         return;
     }
     // First of all, set site info - otherwise we won't
     // be able to invoke API calls.
     $this->_site = new FS_Site($addon_install);
     // Sync add-on plans.
     $this->_sync_plans();
     // Get site's current plan.
     $this->_site->plan = $this->_get_plan_by_id($this->_site->plan->id);
     // Get user information based on parent's plugin.
     $user = $parent_fs->get_user();
     $this->_set_account($user, $this->_site);
     // Sync licenses.
     $this->_sync_licenses();
     // Try to activate premium license.
     $this->_activate_license(true);
 }