includes/class-freemius.php
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( $this->get_text_inline( 'Couldn\'t activate %s.', 'could-not-activate-x' ), $this->get_plugin_name() ) . ' ' .
                    $this->get_text_inline( 'Please contact us with the following message:', 'contact-us-with-error-message' ) . ' ' . '<b>' . $addon_install->error->message . '</b>',
                    $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
                    'error'
                );

                return;
            }

            // Get user information based on parent's plugin.
            $user = $parent_fs->get_user();

            // First of all, set site and user info - otherwise we won't
            // be able to invoke API calls.
            $this->_site = new FS_Site( $addon_install );
            $this->_user = $user;

            // Sync add-on plans.
            $this->_sync_plans();

            // Get site's current plan.
            //$this->_site->plan = $this->_get_plan_by_id( $this->_site->plan->id );

            $this->_set_account( $user, $this->_site );

            // Sync licenses.
            $this->_sync_licenses();

            // Try to activate premium license.
            $this->_activate_license( true );
        }
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( $this->get_text_inline( 'Couldn\'t activate %s.', 'could-not-activate-x' ), $this->get_plugin_name() ) . ' ' .
                    $this->get_text_inline( 'Please contact us with the following message:', 'contact-us-with-error-message' ) . ' ' . '<b>' . $addon_install->error->message . '</b>',
                    $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
                    'error'
                );

                return;
            }

            // Get user information based on parent's plugin.
            $user = $parent_fs->get_user();

            // First of all, set site and user info - otherwise we won't
            // be able to invoke API calls.
            $this->_site = new FS_Site( $addon_install );
            $this->_user = $user;

            // Sync add-on plans.
            $this->_sync_plans();

            // Get site's current plan.
            //$this->_site->plan = $this->_get_plan_by_id( $this->_site->plan->id );

            $this->_set_account( $user, $this->_site );

            // Sync licenses.
            $this->_sync_licenses();

            // Try to activate premium license.
            $this->_activate_license( true );
        }
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 ( $ this -> get_text_inline ( 'Couldn\'t activate %s.' , 'could-not-activate-x' ) , $ this -> get_plugin_name ( ) ) . ' ' . $ this -> get_text_inline ( 'Please contact us with the following message:' , 'contact-us-with-error-message' ) . ' ' . '<b>' . $ addon_install -> error -> message . '</b>' , $ this -> get_text_x_inline ( 'Oops' , 'exclamation' , 'oops' ) . '...' , 'error' ) ; return ; } // Get user information based on parent's plugin.
 $ user = $ parent_fs -> get_user ( ) ; // First of all, set site and user info - otherwise we won't
 // be able to invoke API calls.
 $ this -> _site = new FS_Site ( $ addon_install ) ; $ this -> _user = $ user ; // Sync add-on plans.
 $ this -> _sync_plans ( ) ; // Get site's current plan.
 //$this->_site->plan = $this->_get_plan_by_id( $this->_site->plan->id );
 $ this -> _set_account ( $ user , $ this -> _site ) ; // Sync licenses.
 $ this -> _sync_licenses ( ) ; // Try to activate premium license.
 $ this -> _activate_license ( true ) ; }
Tries to activate add-on account based on parent plugin info.

@author Vova Feldman (@svovaf)
@since  1.0.6

@param Freemius $parent_fs
Tries to activate add - on account based on parent plugin info .