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', 'mainwp'), $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', 'mainwp'), $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 = MainWP_Right_Now::getPluginThemeSlugs($websiteId, $_POST['type']);
         }
     }
     if (empty($slugs)) {
         die(json_encode(array('message' => __('Not found items slugs to update.'))));
     }
     $website = MainWP_DB::Instance()->getWebsiteById($websiteId);
     try {
         $info = array('result' => MainWP_Right_Now::upgradePluginTheme($websiteId, $_POST['type'], $slugs));
         if (!empty($website)) {
             $info['site_url'] = esc_url($website->url);
         }
         die(json_encode($info));
     } catch (MainWP_Exception $e) {
         die(json_encode(array('error' => array('message' => $e->getMessage(), 'extra' => $e->getMessageExtra()))));
     }
 }