includes/class-freemius.php
function _deactivate_plugin_hook() {
            $this->_logger->entrance( 'slug = ' . $this->_slug );

            if ( ! $this->is_user_admin() ) {
                return;
            }

            $is_network_deactivation  = fs_is_network_admin();
            $storage_keys_for_removal = array();

            $this->_admin_notices->clear_all_sticky();

            $storage_keys_for_removal[] = 'sticky_optin_added';
            if ( isset( $this->_storage->sticky_optin_added ) ) {
                unset( $this->_storage->sticky_optin_added );
            }

            if ( ! isset( $this->_storage->is_plugin_new_install ) ) {
                // Remember that plugin was already installed.
                $this->_storage->is_plugin_new_install = false;
            }

            // Hook to plugin uninstall.
            register_uninstall_hook( $this->_plugin_main_file_path, array( 'Freemius', '_uninstall_plugin_hook' ) );

            $this->clear_module_main_file_cache();
            $this->clear_sync_cron( $this->_is_network_active );
            $this->clear_install_sync_cron();

            if ( $this->is_registered() ) {
                if ( $this->is_premium() && ! $this->has_active_valid_license() ) {
                    FS_Plugin_Updater::instance( $this )->delete_update_data();
                }

                if ( $is_network_deactivation ) {
                    // Send deactivation event.
                    $this->sync_installs( array(
                        'is_active' => false,
                    ) );
                } else {
                    // Send deactivation event.
                    $this->sync_install( array(
                        'is_active' => false,
                    ) );
                }
            } else {
                if ( ! $this->has_api_connectivity() ) {
                    // Reset connectivity test cache.
                    unset( $this->_storage->connectivity_test );

                    $storage_keys_for_removal[] = 'connectivity_test';
                }
            }

            if ( $is_network_deactivation ) {
                if ( isset( $this->_storage->sticky_optin_added_ms ) ) {
                    unset( $this->_storage->sticky_optin_added_ms );
                }

                if ( ! empty( $storage_keys_for_removal ) ) {
                    $sites = self::get_sites();

                    foreach ( $sites as $site ) {
                        $blog_id = self::get_site_blog_id( $site );

                        foreach ( $storage_keys_for_removal as $key ) {
                            $this->_storage->remove( $key, false, $blog_id );
                        }

                        $this->_storage->save( $blog_id );
                    }
                }
            }

            // Clear API cache on deactivation.
            FS_Api::clear_cache();

            $this->remove_sdk_reference();
        }
function _deactivate_plugin_hook() {
            $this->_logger->entrance( 'slug = ' . $this->_slug );

            if ( ! $this->is_user_admin() ) {
                return;
            }

            $is_network_deactivation  = fs_is_network_admin();
            $storage_keys_for_removal = array();

            $this->_admin_notices->clear_all_sticky();

            $storage_keys_for_removal[] = 'sticky_optin_added';
            if ( isset( $this->_storage->sticky_optin_added ) ) {
                unset( $this->_storage->sticky_optin_added );
            }

            if ( ! isset( $this->_storage->is_plugin_new_install ) ) {
                // Remember that plugin was already installed.
                $this->_storage->is_plugin_new_install = false;
            }

            // Hook to plugin uninstall.
            register_uninstall_hook( $this->_plugin_main_file_path, array( 'Freemius', '_uninstall_plugin_hook' ) );

            $this->clear_module_main_file_cache();
            $this->clear_sync_cron( $this->_is_network_active );
            $this->clear_install_sync_cron();

            if ( $this->is_registered() ) {
                if ( $this->is_premium() && ! $this->has_active_valid_license() ) {
                    FS_Plugin_Updater::instance( $this )->delete_update_data();
                }

                if ( $is_network_deactivation ) {
                    // Send deactivation event.
                    $this->sync_installs( array(
                        'is_active' => false,
                    ) );
                } else {
                    // Send deactivation event.
                    $this->sync_install( array(
                        'is_active' => false,
                    ) );
                }
            } else {
                if ( ! $this->has_api_connectivity() ) {
                    // Reset connectivity test cache.
                    unset( $this->_storage->connectivity_test );

                    $storage_keys_for_removal[] = 'connectivity_test';
                }
            }

            if ( $is_network_deactivation ) {
                if ( isset( $this->_storage->sticky_optin_added_ms ) ) {
                    unset( $this->_storage->sticky_optin_added_ms );
                }

                if ( ! empty( $storage_keys_for_removal ) ) {
                    $sites = self::get_sites();

                    foreach ( $sites as $site ) {
                        $blog_id = self::get_site_blog_id( $site );

                        foreach ( $storage_keys_for_removal as $key ) {
                            $this->_storage->remove( $key, false, $blog_id );
                        }

                        $this->_storage->save( $blog_id );
                    }
                }
            }

            // Clear API cache on deactivation.
            FS_Api::clear_cache();

            $this->remove_sdk_reference();
        }
function _deactivate_plugin_hook ( ) { $ this -> _logger -> entrance ( 'slug = ' . $ this -> _slug ) ; if ( ! $ this -> is_user_admin ( ) ) { return ; } $ is_network_deactivation = fs_is_network_admin ( ) ; $ storage_keys_for_removal = array ( ) ; $ this -> _admin_notices -> clear_all_sticky ( ) ; $ storage_keys_for_removal [ ] = 'sticky_optin_added' ; if ( isset ( $ this -> _storage -> sticky_optin_added ) ) { unset ( $ this -> _storage -> sticky_optin_added ) ; } if ( ! isset ( $ this -> _storage -> is_plugin_new_install ) ) { // Remember that plugin was already installed.
 $ this -> _storage -> is_plugin_new_install = false ; } // Hook to plugin uninstall.
 register_uninstall_hook ( $ this -> _plugin_main_file_path , array ( 'Freemius' , '_uninstall_plugin_hook' ) ) ; $ this -> clear_module_main_file_cache ( ) ; $ this -> clear_sync_cron ( $ this -> _is_network_active ) ; $ this -> clear_install_sync_cron ( ) ; if ( $ this -> is_registered ( ) ) { if ( $ this -> is_premium ( ) && ! $ this -> has_active_valid_license ( ) ) { FS_Plugin_Updater :: instance ( $ this ) -> delete_update_data ( ) ; } if ( $ is_network_deactivation ) { // Send deactivation event.
 $ this -> sync_installs ( array ( 'is_active' => false , ) ) ; } else { // Send deactivation event.
 $ this -> sync_install ( array ( 'is_active' => false , ) ) ; } } else { if ( ! $ this -> has_api_connectivity ( ) ) { // Reset connectivity test cache.
 unset ( $ this -> _storage -> connectivity_test ) ; $ storage_keys_for_removal [ ] = 'connectivity_test' ; } } if ( $ is_network_deactivation ) { if ( isset ( $ this -> _storage -> sticky_optin_added_ms ) ) { unset ( $ this -> _storage -> sticky_optin_added_ms ) ; } if ( ! empty ( $ storage_keys_for_removal ) ) { $ sites = self :: get_sites ( ) ; foreach ( $ sites as $ site ) { $ blog_id = self :: get_site_blog_id ( $ site ) ; foreach ( $ storage_keys_for_removal as $ key ) { $ this -> _storage -> remove ( $ key , false , $ blog_id ) ; } $ this -> _storage -> save ( $ blog_id ) ; } } } // Clear API cache on deactivation.
 FS_Api :: clear_cache ( ) ; $ this -> remove_sdk_reference ( ) ; }
Plugin deactivation hook.

@author Vova Feldman (@svovaf)
@since  1.0.1
Plugin deactivation hook .