function mainwp_upgradeplugintheme() { if ($_POST['type'] == "plugin" && !mainwp_current_user_can("dashboard", "update_plugins")) { die(json_encode(array('error' => mainwp_do_not_have_permissions("update plugins", $echo = false)))); } if ($_POST['type'] == "theme" && !mainwp_current_user_can("dashboard", "update_themes")) { die(json_encode(array('error' => mainwp_do_not_have_permissions("update themes", $echo = false)))); } $this->secure_request('mainwp_upgradeplugintheme'); $websiteId = null; $slugs = ""; if (isset($_POST['websiteId'])) { $websiteId = $_POST['websiteId']; if (isset($_POST['slug'])) { $slugs = $_POST['slug']; } else { $slugs = MainWPRightNow::getPluginThemeSlugs($websiteId, $_POST['type']); } } if (empty($slugs)) { die(json_encode(array('message' => __("Not found items slugs to update.")))); } try { die(json_encode(array('result' => MainWPRightNow::upgradePluginTheme($websiteId, $_POST['type'], $slugs)))); } catch (MainWPException $e) { die(json_encode(array('error' => array('message' => $e->getMessage(), 'extra' => $e->getMessageExtra())))); } }