#! /bin/bash

DB=$(grep DB_NAME wp-config.php | cut -d \' -f 4)
DBuser=$(grep DB_USER wp-config.php | cut -d \' -f 4)
DBpass=$(grep DB_PASSWORD wp-config.php | cut -d \' -f 4)
DBhost=$(grep DB_HOST wp-config.php | cut -d \' -f 4)

function WPinstallCheck {
        if  [[ ! -f ./wp-config.php ]]; then
                echo "No WordPress installtion found in this DIR, script must be executed from user's WP directory." 1>&2
                exit 1 2> /dev/null
        fi
}

function tPrefix {
grep -i table_prefix wp-config.php | cut -d \' -f 2
}

function disablePlugins {
	mysql -u $DBuser -p$DBpass <<PLI
	USE $DB;
	UPDATE $(tPrefix)options SET option_value = 'a:0:{}' WHERE option_name = 'active_plugins';
PLI
}

WPinstallCheck
disablePlugins
