/**
  * Install plugin with current logged WP user info.
  *
  * @author Vova Feldman (@svovaf)
  * @since  1.0.7
  */
 function _install_with_current_user()
 {
     $this->_logger->entrance();
     if ($this->is_registered()) {
         return;
     }
     if (fs_request_is_action($this->_slug . '_activate_existing') && fs_request_is_post()) {
         //				check_admin_referer( 'activate_existing_' . $this->_plugin->public_key );
         $this->_admin_notices->remove_sticky('connect_account');
         // Get current logged WP user.
         $current_user = wp_get_current_user();
         // Find the relevant FS user by the email.
         $user = self::_get_user_by_email($current_user->user_email);
         // We have to set the user before getting user scope API handler.
         $this->_user = $user;
         // Install the plugin.
         $install = $this->get_api_user_scope()->call("/plugins/{$this->get_id()}/installs.json", 'post', $this->get_install_data_for_api(array('uid' => $this->get_anonymous_id())));
         if (isset($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>' . $install->error->message . '</b>', __fs('oops', $this->_slug) . '...', 'error');
             return;
         }
         $site = new FS_Site($install);
         $this->_site = $site;
         //				$this->_enrich_site_plan( false );
         //				$this->_set_account( $user, $site );
         //				$this->_sync_plans();
         $this->setup_account($this->_user, $this->_site);
     }
 }
Пример #2
0
 /**
  * Install plugin with current logged WP user info.
  *
  * @author Vova Feldman (@svovaf)
  * @since  1.0.7
  */
 function _install_with_current_user()
 {
     $this->_logger->entrance();
     if ($this->is_registered()) {
         return;
     }
     if (fs_request_is_action($this->_slug . '_activate_existing') && fs_request_is_post()) {
         //				check_admin_referer( 'activate_existing_' . $this->_plugin->public_key );
         $this->install_with_current_user();
     }
 }
Пример #3
0
 /**
  * Install plugin with current logged WP user info.
  *
  * @author Vova Feldman (@svovaf)
  * @since  1.0.7
  */
 function _install_with_current_user()
 {
     if ($this->is_registered()) {
         return;
     }
     if (fs_request_is_action($this->_slug . '_activate_existing') && fs_request_is_post()) {
         //				check_admin_referer( 'activate_existing_' . $this->_plugin->public_key );
         // Get current logged WP user.
         $current_user = wp_get_current_user();
         // Find the relevant FS user by the email.
         $user = self::_get_user_by_email($current_user->user_email);
         // We have to set the user before getting user scope API handler.
         $this->_user = $user;
         // Install the plugin.
         $install = $this->get_api_user_scope()->call("/plugins/{$this->get_id()}/installs.json", 'post', array('url' => get_site_url(), 'title' => get_bloginfo('name'), 'version' => $this->get_plugin_version(), 'language' => get_bloginfo('language'), 'charset' => get_bloginfo('charset'), 'platform_version' => get_bloginfo('version')));
         if (isset($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>' . $install->error->message . '</b>'), 'Oops...', 'error');
             return;
         }
         $site = new FS_Site($install);
         $this->_site = $site;
         $this->_enrich_site_plan(false);
         $this->_set_account($user, $site);
         $this->_sync_plans();
         // Reload the page with the keys.
         if (fs_redirect($this->_get_admin_page_url())) {
             exit;
         }
     }
 }