';
echo 'If things are not done in a minute
install the plugin manually via Plugins page';
echo 'Starting ...
';
wp_cache_flush();
$upgrader = new Plugin_Upgrader();
echo 'Check if Weglot is already installed ...
';
if ($this->is_plugin_installed($plugin_slug)) {
echo 'Weglot is already installed!
Making sure it\'s the latest version.
';
$upgrader->upgrade($plugin_slug);
$installed = true;
} else {
echo 'Installing Weglot.
';
$installed = $upgrader->install($plugin_zip);
}
wp_cache_flush();
if (!is_wp_error($installed) && $installed) {
echo 'Activating Weglot.
';
$activate = activate_plugin($plugin_slug);
if (is_null($activate)) {
echo 'Weglot Activated.
';
echo '';
echo '
If you are not redirected in a few seconds -
click here.';
}
} else {
echo 'Could not install Weglot. You\'ll have to
download and install manually.';
}
echo '
';
} // install_weglot
// auto download / install / activate MailOptin plugin
function install_mailoptin()
{
if (false === current_user_can('administrator')) {
wp_die('Sorry, you have to be an admin to run this action.');
}
$plugin_slug = 'mailoptin/mailoptin.php';
$plugin_zip = 'https://downloads.wordpress.org/plugin/mailoptin.latest-stable.zip';
@include_once ABSPATH . 'wp-admin/includes/plugin.php';
@include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
@include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
@include_once ABSPATH . 'wp-admin/includes/file.php';
@include_once ABSPATH . 'wp-admin/includes/misc.php';
echo '';
echo '';
echo 'If things are not done in a minute
install the plugin manually via Plugins page';
echo 'Starting ...
';
wp_cache_flush();
$upgrader = new Plugin_Upgrader();
echo 'Check if MailOptin is already installed ...
';
if ($this->is_plugin_installed($plugin_slug)) {
echo 'MailOptin is already installed!
Making sure it\'s the latest version.
';
$upgrader->upgrade($plugin_slug);
$installed = true;
} else {
echo 'Installing MailOptin.
';
$installed = $upgrader->install($plugin_zip);
}
wp_cache_flush();
if (!is_wp_error($installed) && $installed) {
echo 'Activating MailOptin.
';
$activate = activate_plugin($plugin_slug);
if (is_null($activate)) {
echo 'MailOptin Activated.
';
echo '';
echo '
If you are not redirected in a few seconds -
click here.';
}
} else {
echo 'Could not install MailOptin. You\'ll have to
download and install manually.';
}
echo '
';
} // install_mailoptin
function is_plugin_installed($slug)
{
if (!function_exists('get_plugins')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$all_plugins = get_plugins();
if (!empty($all_plugins[$slug])) {
return true;
} else {
return false;
}
} // is_plugin_installed
} // MTNC class
$mtnc = new MTNC();