function sp_delete_sp_theme($theme)
{
    $mobileTheme = sp_get_option('sp_mobile_theme');
    $tabletTheme = sp_get_option('sp_tablet_theme');
    $curTheme = sp_get_option('sp_current_theme');
    if ($curTheme['theme'] == $theme) {
        $mess = spa_text('Sorry, cannot delete the active theme');
    } else {
        if ($mobileTheme['theme'] == $theme) {
            $mess = spa_text('Sorry, cannot delete the active mobile theme');
        } else {
            if ($tabletTheme['theme'] == $theme) {
                $mess = spa_text('Sorry, cannot delete the active tablet theme');
            } else {
                sp_remove_dir(SPTHEMEBASEDIR . $theme);
                do_action('sph_delete_' . trim($theme));
                do_action('sph_deleted_sp_theme', trim($theme));
                $mess = spa_text('Theme deleted');
            }
        }
    }
    return $mess;
}
function spa_deactivate_plugin()
{
    $uninstall = sp_get_option('sfuninstall');
    if ($uninstall) {
        # uninstall - remove all data
        # remove any admin capabilities
        $admins = spdb_table(SFMEMBERS, 'admin=1');
        foreach ($admins as $admin) {
            $user = new WP_User($admin->user_id);
            $user->remove_cap('SPF Manage Options');
            $user->remove_cap('SPF Manage Forums');
            $user->remove_cap('SPF Manage User Groups');
            $user->remove_cap('SPF Manage Permissions');
            $user->remove_cap('SPF Manage Tags');
            $user->remove_cap('SPF Manage Components');
            $user->remove_cap('SPF Manage Admins');
            $user->remove_cap('SPF Manage Profiles');
            $user->remove_cap('SPF Manage Users');
            $user->remove_cap('SPF Manage Toolbox');
            $user->remove_cap('SPF Manage Plugins');
            $user->remove_cap('SPF Manage Themes');
            $user->remove_cap('SPF Manage Integration');
            $user->remove_cap('SPF Manage Configuration');
            # no longer used but some may still have it
        }
        # remove any installed tables
        $tables = sp_get_option('installed_tables');
        if ($tables) {
            foreach ($tables as $table) {
                spdb_query("DROP TABLE IF EXISTS {$table}");
            }
        }
        # since we have removed our tables, need to turn off error logging to prevent onslaught of errors
        global $spGlobals;
        $spGlobals['record-errors'] = false;
        # Remove the Page record
        $sfpage = sp_get_option('sfpage');
        if (!empty($sfpage)) {
            spdb_query('DELETE FROM ' . SFWPPOSTS . ' WHERE ID=' . sp_get_option('sfpage'));
        }
        # remove widget data
        delete_option('widget_spf');
        delete_option('widget_sforum');
        # remove any wp options we might have set
        delete_option('sfInstallID');
        delete_option('sp_storage1');
        delete_option('sp_storage2');
        # Now remove user meta data
        $optionlist = array('sfadmin', 'location', 'msn', 'skype', 'icq', 'facebook', 'myspace', 'twitter', 'linkedin', 'youtube', 'googleplus', 'sfuse_quicktags', 'signature', 'sigimage');
        foreach ($optionlist as $option) {
            spdb_query('DELETE FROM ' . SFUSERMETA . " WHERE meta_key='{$option}';");
        }
        # send our uninstall action
        do_action('sph_uninstalled', $admins);
        # remove storage locations if so directed
        if (sp_get_option('removestorage')) {
            # let's remove our directories and storage
            global $spPaths;
            if (!empty($spPaths)) {
                foreach ($spPaths as $storage => $path) {
                    # lets not remove plugins and themes
                    if ($storage != 'plugins' && $storage != 'themes') {
                        sp_remove_dir(SF_STORE_DIR . '/' . $path);
                    }
                }
            }
            # remove the languages folder if it exists
            # note the sp-resources dire may not exist - but its our default. if user creates other parent dir for languages, we wont know about  it
            sp_remove_dir(SF_STORE_DIR . '/sp-resources/forum-language');
        }
    }
    # remove the combined css and js cache files
    sp_clear_combined_css('all');
    sp_clear_combined_css('mobile');
    sp_clear_combined_css('tablet');
    # remove cron jobs for deactivaton or uninstall
    wp_clear_scheduled_hook('spf_cron_pm');
    # left here for 5.0 who doesnt upgrade
    wp_clear_scheduled_hook('spf_cron_sitemap');
    # left here for 5.0 who doesnt upgrade
    wp_clear_scheduled_hook('sph_cron_user');
    wp_clear_scheduled_hook('sph_transient_cleanup_cron');
    wp_clear_scheduled_hook('sph_stats_cron');
    wp_clear_scheduled_hook('sph_news_cron');
    # send deactivated action
    if (!$uninstall) {
        do_action('sph_deactivated');
    }
}
Example #3
0
function sp_delete_sp_plugin($plugin)
{
    $mess = '';
    if (!sp_is_plugin_active($plugin)) {
        $parts = explode('/', $plugin);
        sp_remove_dir(SFPLUGINDIR . $parts[0]);
        do_action('sph_delete_' . trim($plugin));
        do_action('sph_deleted_sp_plugin', trim($plugin));
        $mess = sp_text('Plugin successfully deleted');
    } else {
        $mess = sp_text('Plugin is active and cannot be deleted');
    }
    return $mess;
}
Example #4
0
function sp_remove_dir($dir)
{
    if (is_dir($dir)) {
        foreach (glob($dir . '/*') as $file) {
            if (is_dir($file)) {
                sp_remove_dir($file);
            } else {
                @unlink($file);
            }
        }
        @rmdir($dir);
    }
}