includes/class-freemius.php
private function deactivate_premium_only_addon_without_license( $is_after_trial_cancel = false ) {
            if ( ! $this->has_free_plan() &&
                 ! $this->has_features_enabled_license() &&
                 ! $this->_has_premium_license()
            ) {
                if ( $this->is_registered() ) {
                    // IF wrapper is turned off because activation_timestamp is currently only stored for plugins (not addons).
                    //                if (empty($this->_storage->activation_timestamp) ||
                    //                    (WP_FS__SCRIPT_START_TIME - $this->_storage->activation_timestamp) > 30
                    //                ) {
                    /**
                     * @todo When it's first fail, there's no reason to try and re-sync because the licenses were just synced after initial activation.
                     *
                     * Retry syncing the user add-on licenses.
                     */
                    // Sync licenses.
                    $this->_sync_licenses();
                    //                }

                    // Try to activate premium license.
                    $this->_activate_license( true );
                }

                if ( ! $this->has_free_plan() &&
                     ! $this->has_features_enabled_license() &&
                     ! $this->_has_premium_license()
                ) {
                    // @todo Check if deactivate plugins also call the deactivation hook.

                    $this->_parent->_admin_notices->add_sticky(
                        sprintf(
                            ( $is_after_trial_cancel ?
                                $this->_parent->get_text_inline(
                                    '%s free trial was successfully cancelled. Since the add-on is premium only it was automatically deactivated. If you like to use it in the future, you\'ll have to purchase a license.',
                                    'addon-trial-cancelled-message'
                                ) :
                                $this->_parent->get_text_inline(
                                    '%s is a premium only add-on. You have to purchase a license first before activating the plugin.',
                                    'addon-no-license-message'
                                )
                            ),
                            '<b>' . $this->_plugin->title . '</b>'
                        ) . ' ' . sprintf(
                            '<a href="%s" aria-label="%s" class="button button-primary" style="margin-left: 10px; vertical-align: middle;">%s &nbsp;&#10140;</a>',
                            $this->_parent->addon_url( $this->_slug ),
                            esc_attr( sprintf( $this->_parent->get_text_inline( 'More information about %s', 'more-information-about-x' ), $this->_plugin->title ) ),
                            $this->_parent->get_text_inline( 'Purchase License', 'purchase-license' )
                        ),
                        'no_addon_license_' . $this->_slug,
                        ( $is_after_trial_cancel ? '' : $this->_parent->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...' ),
                        ( $is_after_trial_cancel ? 'success' : 'error' )
                    );

                    deactivate_plugins( array( $this->_plugin_basename ), true );

                    return true;
                }
            }

            return false;
        }
private function deactivate_premium_only_addon_without_license( $is_after_trial_cancel = false ) {
            if ( ! $this->has_free_plan() &&
                 ! $this->has_features_enabled_license() &&
                 ! $this->_has_premium_license()
            ) {
                if ( $this->is_registered() ) {
                    // IF wrapper is turned off because activation_timestamp is currently only stored for plugins (not addons).
                    //                if (empty($this->_storage->activation_timestamp) ||
                    //                    (WP_FS__SCRIPT_START_TIME - $this->_storage->activation_timestamp) > 30
                    //                ) {
                    /**
                     * @todo When it's first fail, there's no reason to try and re-sync because the licenses were just synced after initial activation.
                     *
                     * Retry syncing the user add-on licenses.
                     */
                    // Sync licenses.
                    $this->_sync_licenses();
                    //                }

                    // Try to activate premium license.
                    $this->_activate_license( true );
                }

                if ( ! $this->has_free_plan() &&
                     ! $this->has_features_enabled_license() &&
                     ! $this->_has_premium_license()
                ) {
                    // @todo Check if deactivate plugins also call the deactivation hook.

                    $this->_parent->_admin_notices->add_sticky(
                        sprintf(
                            ( $is_after_trial_cancel ?
                                $this->_parent->get_text_inline(
                                    '%s free trial was successfully cancelled. Since the add-on is premium only it was automatically deactivated. If you like to use it in the future, you\'ll have to purchase a license.',
                                    'addon-trial-cancelled-message'
                                ) :
                                $this->_parent->get_text_inline(
                                    '%s is a premium only add-on. You have to purchase a license first before activating the plugin.',
                                    'addon-no-license-message'
                                )
                            ),
                            '<b>' . $this->_plugin->title . '</b>'
                        ) . ' ' . sprintf(
                            '<a href="%s" aria-label="%s" class="button button-primary" style="margin-left: 10px; vertical-align: middle;">%s &nbsp;&#10140;</a>',
                            $this->_parent->addon_url( $this->_slug ),
                            esc_attr( sprintf( $this->_parent->get_text_inline( 'More information about %s', 'more-information-about-x' ), $this->_plugin->title ) ),
                            $this->_parent->get_text_inline( 'Purchase License', 'purchase-license' )
                        ),
                        'no_addon_license_' . $this->_slug,
                        ( $is_after_trial_cancel ? '' : $this->_parent->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...' ),
                        ( $is_after_trial_cancel ? 'success' : 'error' )
                    );

                    deactivate_plugins( array( $this->_plugin_basename ), true );

                    return true;
                }
            }

            return false;
        }
private function deactivate_premium_only_addon_without_license ( $ is_after_trial_cancel = false ) { if ( ! $ this -> has_free_plan ( ) && ! $ this -> has_features_enabled_license ( ) && ! $ this -> _has_premium_license ( ) ) { if ( $ this -> is_registered ( ) ) { // IF wrapper is turned off because activation_timestamp is currently only stored for plugins (not addons).
 //                if (empty($this->_storage->activation_timestamp) ||
 //                    (WP_FS__SCRIPT_START_TIME - $this->_storage->activation_timestamp) > 30
 //                ) {
 /**
                     * @todo When it's first fail, there's no reason to try and re-sync because the licenses were just synced after initial activation.
                     *
                     * Retry syncing the user add-on licenses.
                     */ // Sync licenses.
 $ this -> _sync_licenses ( ) ; //                }
 // Try to activate premium license.
 $ this -> _activate_license ( true ) ; } if ( ! $ this -> has_free_plan ( ) && ! $ this -> has_features_enabled_license ( ) && ! $ this -> _has_premium_license ( ) ) { // @todo Check if deactivate plugins also call the deactivation hook.
 $ this -> _parent -> _admin_notices -> add_sticky ( sprintf ( ( $ is_after_trial_cancel ? $ this -> _parent -> get_text_inline ( '%s free trial was successfully cancelled. Since the add-on is premium only it was automatically deactivated. If you like to use it in the future, you\'ll have to purchase a license.' , 'addon-trial-cancelled-message' ) : $ this -> _parent -> get_text_inline ( '%s is a premium only add-on. You have to purchase a license first before activating the plugin.' , 'addon-no-license-message' ) ) , '<b>' . $ this -> _plugin -> title . '</b>' ) . ' ' . sprintf ( '<a href="%s" aria-label="%s" class="button button-primary" style="margin-left: 10px; vertical-align: middle;">%s &nbsp;&#10140;</a>' , $ this -> _parent -> addon_url ( $ this -> _slug ) , esc_attr ( sprintf ( $ this -> _parent -> get_text_inline ( 'More information about %s' , 'more-information-about-x' ) , $ this -> _plugin -> title ) ) , $ this -> _parent -> get_text_inline ( 'Purchase License' , 'purchase-license' ) ) , 'no_addon_license_' . $ this -> _slug , ( $ is_after_trial_cancel ? '' : $ this -> _parent -> get_text_x_inline ( 'Oops' , 'exclamation' , 'oops' ) . '...' ) , ( $ is_after_trial_cancel ? 'success' : 'error' ) ) ; deactivate_plugins ( array ( $ this -> _plugin_basename ) , true ) ; return true ; } } return false ; }
Deactivate add-on if it's premium only and the user does't have a valid license.

@param bool $is_after_trial_cancel

@return bool If add-on was deactivated.
Deactivate add - on if it s premium only and the user does t have a valid license .