Esempio n. 1
0
/**
 * Recursively delete a directory
 *
 * @param string $dir Directory name
 * @param boolean $deleteRootToo Delete specified top-level directory as well
 */
function WPPortfolio_unlinkRecursive($dir, $deleteRootToo)
{
    if (!($dh = @opendir($dir))) {
        return;
    }
    while (false !== ($obj = readdir($dh))) {
        if ($obj == '.' || $obj == '..') {
            continue;
        }
        if (!@unlink($dir . '/' . $obj)) {
            WPPortfolio_unlinkRecursive($dir . '/' . $obj, true);
        }
    }
    closedir($dh);
    if ($deleteRootToo) {
        @rmdir($dir);
    }
    return;
}
Esempio n. 2
0
/**
 * Method called when we want to uninstall the portfolio plugin to remove the database tables.
 */
function WPPortfolio_uninstall()
{
    // Remove all options from the database
    delete_option('WPPortfolio_setting_stw_access_key');
    delete_option('WPPortfolio_setting_stw_secret_key');
    delete_option('WPPortfolio_setting_stw_thumb_size');
    delete_option('WPPortfolio_setting_cache_days');
    delete_option('WPPortfolio_setting_template_website');
    delete_option('WPPortfolio_setting_template_group');
    delete_option('WPPortfolio_setting_template_css');
    delete_option('WPPortfolio_setting_template_css_paging');
    delete_option('WPPortfolio_setting_template_css_widget');
    delete_option('WPPortfolio_version');
    // Remove all tables for the portfolio
    global $wpdb;
    $table_name = $wpdb->prefix . TABLE_WEBSITES;
    $uninstall_sql = "DROP TABLE IF EXISTS " . $table_name;
    $wpdb->query($uninstall_sql);
    $table_name = $wpdb->prefix . TABLE_WEBSITE_GROUPS;
    $uninstall_sql = "DROP TABLE IF EXISTS " . $table_name;
    $wpdb->query($uninstall_sql);
    $table_name = $wpdb->prefix . TABLE_WEBSITE_DEBUG;
    $uninstall_sql = "DROP TABLE IF EXISTS " . $table_name;
    $wpdb->query($uninstall_sql);
    // Remove cache
    $actualThumbPath = WPPortfolio_getThumbPathActualDir();
    WPPortfolio_unlinkRecursive($actualThumbPath);
    WPPortfolio_showMessage(__("Deleted WP Portfolio database entries.", 'wp-portfolio'));
}