includes/class-freemius.php
private function _cancel_trial() {
            $this->_logger->entrance();

            if ( ! $this->is_trial() ) {
                return (object) array(
                    'error' => (object) array(
                        'message' => $this->get_text_inline( 'It looks like you are not in trial mode anymore so there\'s nothing to cancel :)', 'trial-cancel-no-trial-message' )
                    )
                );
            }

            $trial_plan = $this->get_trial_plan();

            $api  = $this->get_api_site_scope();
            $site = $api->call( 'trials.json', 'delete' );

            $trial_cancelled = false;

            if ( $this->is_api_result_entity( $site ) ) {
                $prev_trial_ends = $this->_site->trial_ends;

                if ( $this->is_paid_trial() ) {
                    $this->_license->expiration   = $site->trial_ends;
                    $this->_license->is_cancelled = true;
                    $this->_update_site_license( $this->_license );
                    $this->_store_licenses();

                    // Clear subscription reference.
                    $this->_sync_site_subscription( null );
                }

                // Update site info.
                $this->_site = new FS_Site( $site );

                $trial_cancelled = ( $prev_trial_ends != $site->trial_ends );
            } else {
                // @todo handle different error cases.
            }

            if ( ! $trial_cancelled ) {
                return (object) array(
                    'error' => (object) array(
                        'message' => $this->get_text_inline( 'Seems like we are having some temporary issue with your trial cancellation. Please try again in few minutes.', 'trial-cancel-failure-message' )
                    )
                );
            }

            // Remove previous sticky messages about upgrade or trial (if exist).
            $this->_admin_notices->remove_sticky( array(
                'trial_started',
                'trial_promotion',
                'plan_upgraded',
            ) );

            // Store site updates.
            $this->_store_site();

            if ( ! $this->is_addon() ||
                 ! $this->deactivate_premium_only_addon_without_license( true )
            ) {
                $this->_admin_notices->add(
                    sprintf( $this->get_text_inline( 'Your %s free trial was successfully cancelled.', 'trial-cancel-message' ), $trial_plan->title )
                );
            }

            return $site;
        }
private function _cancel_trial() {
            $this->_logger->entrance();

            if ( ! $this->is_trial() ) {
                return (object) array(
                    'error' => (object) array(
                        'message' => $this->get_text_inline( 'It looks like you are not in trial mode anymore so there\'s nothing to cancel :)', 'trial-cancel-no-trial-message' )
                    )
                );
            }

            $trial_plan = $this->get_trial_plan();

            $api  = $this->get_api_site_scope();
            $site = $api->call( 'trials.json', 'delete' );

            $trial_cancelled = false;

            if ( $this->is_api_result_entity( $site ) ) {
                $prev_trial_ends = $this->_site->trial_ends;

                if ( $this->is_paid_trial() ) {
                    $this->_license->expiration   = $site->trial_ends;
                    $this->_license->is_cancelled = true;
                    $this->_update_site_license( $this->_license );
                    $this->_store_licenses();

                    // Clear subscription reference.
                    $this->_sync_site_subscription( null );
                }

                // Update site info.
                $this->_site = new FS_Site( $site );

                $trial_cancelled = ( $prev_trial_ends != $site->trial_ends );
            } else {
                // @todo handle different error cases.
            }

            if ( ! $trial_cancelled ) {
                return (object) array(
                    'error' => (object) array(
                        'message' => $this->get_text_inline( 'Seems like we are having some temporary issue with your trial cancellation. Please try again in few minutes.', 'trial-cancel-failure-message' )
                    )
                );
            }

            // Remove previous sticky messages about upgrade or trial (if exist).
            $this->_admin_notices->remove_sticky( array(
                'trial_started',
                'trial_promotion',
                'plan_upgraded',
            ) );

            // Store site updates.
            $this->_store_site();

            if ( ! $this->is_addon() ||
                 ! $this->deactivate_premium_only_addon_without_license( true )
            ) {
                $this->_admin_notices->add(
                    sprintf( $this->get_text_inline( 'Your %s free trial was successfully cancelled.', 'trial-cancel-message' ), $trial_plan->title )
                );
            }

            return $site;
        }
private function _cancel_trial ( ) { $ this -> _logger -> entrance ( ) ; if ( ! $ this -> is_trial ( ) ) { return ( object ) array ( 'error' => ( object ) array ( 'message' => $ this -> get_text_inline ( 'It looks like you are not in trial mode anymore so there\'s nothing to cancel :)' , 'trial-cancel-no-trial-message' ) ) ) ; } $ trial_plan = $ this -> get_trial_plan ( ) ; $ api = $ this -> get_api_site_scope ( ) ; $ site = $ api -> call ( 'trials.json' , 'delete' ) ; $ trial_cancelled = false ; if ( $ this -> is_api_result_entity ( $ site ) ) { $ prev_trial_ends = $ this -> _site -> trial_ends ; if ( $ this -> is_paid_trial ( ) ) { $ this -> _license -> expiration = $ site -> trial_ends ; $ this -> _license -> is_cancelled = true ; $ this -> _update_site_license ( $ this -> _license ) ; $ this -> _store_licenses ( ) ; // Clear subscription reference.
 $ this -> _sync_site_subscription ( null ) ; } // Update site info.
 $ this -> _site = new FS_Site ( $ site ) ; $ trial_cancelled = ( $ prev_trial_ends != $ site -> trial_ends ) ; } else { // @todo handle different error cases.
 } if ( ! $ trial_cancelled ) { return ( object ) array ( 'error' => ( object ) array ( 'message' => $ this -> get_text_inline ( 'Seems like we are having some temporary issue with your trial cancellation. Please try again in few minutes.' , 'trial-cancel-failure-message' ) ) ) ; } // Remove previous sticky messages about upgrade or trial (if exist).
 $ this -> _admin_notices -> remove_sticky ( array ( 'trial_started' , 'trial_promotion' , 'plan_upgraded' , ) ) ; // Store site updates.
 $ this -> _store_site ( ) ; if ( ! $ this -> is_addon ( ) || ! $ this -> deactivate_premium_only_addon_without_license ( true ) ) { $ this -> _admin_notices -> add ( sprintf ( $ this -> get_text_inline ( 'Your %s free trial was successfully cancelled.' , 'trial-cancel-message' ) , $ trial_plan -> title ) ) ; } return $ site ; }
Cancel site trial.

@author Vova Feldman (@svovaf)
@since  1.0.9

@return object

@uses   FS_Api
Cancel site trial .