private function redirectToDeactivationPage()
 {
     $url = $_SERVER['HTTP_REFERER'];
     if (isset($_POST['bulk_deactivate']) && $_POST['bulk_deactivate'] == '1') {
         header("location: {$url}");
     } else {
         WPRC_Loader::includeUrlAnalyzer();
         $params = WPRC_UrlAnalyzer::getExtensionFromUrl($url);
         if (array_key_exists('action', $params) && array_key_exists('type', $params)) {
             if (($params['action'] == 'deactivate' || $params['action'] == 'activate' && $params['type'] == 'theme') && $params['type'] != '') {
                 header("location: {$url}&reported=true");
             }
         }
     }
 }
if (array_key_exists('checked', $_POST)) {
    // bulk deactivation
    // bulk deactivation accessible for plugins only
    $extension_type = 'plugin';
    $extension_keys = $_POST['checked'];
    $bulk_deactivate = 1;
    $bulk_data['_wpnonce'] = $_POST['_wpnonce'];
    $bulk_data['_wp_http_referer'] = $_POST['_wp_http_referer'];
    $bulk_data['checked'] = $_POST['checked'];
    $bulk_data['action'] = $_POST['action'];
    $bulk_data['action2'] = $_POST['action2'];
    $url = admin_url('plugins.php');
} else {
    // single extension deactivation
    $url = $_SERVER['REQUEST_URI'];
    $extension = WPRC_UrlAnalyzer::getExtensionFromUrl($url);
    $extension_type = $extension['type'];
    $extension_path = $extension['name'];
    $all_plugins = get_plugins();
    $extension_name = isset($all_plugins[$extension_path]['Name']) ? $all_plugins[$extension_path]['Name'] : '';
    switch ($extension_type) {
        case 'plugin':
            if (array_key_exists('name', $extension)) {
                // it is not a name, it's a extension_path (placed in $extension['name'])
                $extension_keys[] = $extension['name'];
            }
            break;
        case 'theme':
            // send uninstall report for previous theme not current theme
            //$extension_keys[] = $em->getCurrentThemeName();
            $extension_keys[] = $em->getSwitchedThemeName();
Ejemplo n.º 3
0
 /**
  * Update extenion_path for the plugins
  * 
  * (on 'install_plugin_complete_actions' hook)
  * 
  * @param array install actions array
  */
 public static function updatePluginExtensionPath($install_actions)
 {
     if (array_key_exists('activate_plugin', $install_actions)) {
         // get parameters from the GET
         $repository_id = $_GET['repository_id'];
         $plugin_slug = $_GET['plugin'];
         // get activation link from the html
         preg_match('/href="(?<activation_link>[^"]*)"/', $install_actions['activate_plugin'], $matches);
         $activation_link = $matches['activation_link'];
         // parse activation link
         WPRC_Loader::includeUrlAnalyzer();
         $url_params = WPRC_UrlAnalyzer::getUrlParams($activation_link);
         $plugin_path = $url_params['plugin'];
         // update extension
         $et_model = WPRC_Loader::getModel('extensions');
         $et_model->updateExtensionPath($plugin_path, $plugin_slug, $repository_id);
     }
     return $install_actions;
 }