/**
  * Hooked into transition_post_status. Will initiate search engine pings
  * if the post is being published, is a post type that a sitemap is built for
  * and is a post that is included in sitemaps.
  *
  * @param string   $new_status New post status.
  * @param string   $old_status Old post status.
  * @param \WP_Post $post       Post object.
  */
 function status_transition($new_status, $old_status, $post)
 {
     if ($new_status != 'publish') {
         return;
     }
     wp_cache_delete('lastpostmodified:gmt:' . $post->post_type, 'timeinfo');
     // #17455.
     $options = WPSEO_Options::get_options(array('wpseo_xml', 'wpseo_titles'));
     if (isset($options['post_types-' . $post->post_type . '-not_in_sitemap']) && $options['post_types-' . $post->post_type . '-not_in_sitemap'] === true || $post->post_type === 'nav_menu_item') {
         return;
     }
     if (WP_CACHE) {
         wp_schedule_single_event(time() + 300, 'wpseo_hit_sitemap_index');
     }
     /**
      * Filter: 'wpseo_allow_xml_sitemap_ping' - Check if pinging is not allowed (allowed by default)
      *
      * @api boolean $allow_ping The boolean that is set to true by default.
      */
     if (apply_filters('wpseo_allow_xml_sitemap_ping', true) === false) {
         return;
     }
     // Allow the pinging to happen slightly after the hit sitemap index so the sitemap is fully regenerated when the ping happens.
     $excluded_posts = explode(',', $options['excluded-posts']);
     if (!in_array($post->ID, $excluded_posts)) {
         if (defined('YOAST_SEO_PING_IMMEDIATELY') && YOAST_SEO_PING_IMMEDIATELY) {
             wpseo_ping_search_engines();
         } else {
             wp_schedule_single_event(time() + 300, 'wpseo_ping_search_engines');
         }
     }
 }
Example #2
0
function delete_metadata($meta_type, $object_id, $meta_key, $meta_value = '')
{
    if (!$meta_type || !$meta_key) {
        return false;
    }
    if (!($table = _get_meta_table($meta_type))) {
        return false;
    }
    global $wpdb;
    $column = esc_sql($meta_type . '_id');
    // expected_slashed ($meta_key)
    $meta_key = stripslashes($meta_key);
    $meta_value = maybe_serialize(stripslashes_deep($meta_value));
    $query = $wpdb->prepare("DELETE FROM {$table} WHERE meta_key = %s", $meta_key);
    if ($meta_value) {
        $query .= $wpdb->prepare("AND meta_value = %s", $meta_value);
    }
    $count = $wpdb->query($query);
    if (!$count) {
        return false;
    }
    wp_cache_delete($object_id, $meta_type . '_meta');
    do_action("deleted_{$meta_type}_meta", $object_id, $meta_key, $meta_value);
    return true;
}
function wpurp_shortcode_generator_user_menu_authors()
{
    $menu_authors = array();
    $menu_author_ids = array();
    // Get all menus one by one
    $limit = 100;
    $offset = 0;
    while (true) {
        $args = array('post_type' => 'menu', 'post_status' => array('publish', 'private'), 'posts_per_page' => $limit, 'offset' => $offset);
        $query = new WP_Query($args);
        if (!$query->have_posts()) {
            break;
        }
        $posts = $query->posts;
        foreach ($posts as $post) {
            $id = $post->ID;
            $author = $post->post_author;
            if (!in_array($author, $menu_author_ids)) {
                $menu_author_ids[] = $author;
                $user = get_userdata($author);
                $name = $user ? $user->display_name : __('n/a', 'wp-ultimate-recipe');
                $menu_authors[] = array('value' => $author, 'label' => $name);
            }
            wp_cache_delete($id, 'posts');
            wp_cache_delete($id, 'post_meta');
        }
        $offset += $limit;
        wp_cache_flush();
    }
    return $menu_authors;
}
 /**
  * Update the embed code on an Embed
  *
  * @param  int $id
  * @param  string $html
  * @return Embed
  */
 public static function update($id, $html = '')
 {
     global $wpdb;
     $update = $wpdb->update("{$wpdb->base_prefix}protected_embeds", array('html' => $html), array('embed_id' => $id));
     wp_cache_delete($id, 'protected-embeds');
     return static::get($id);
 }
Example #5
0
function xfac_user_deleteRecord($record)
{
    global $wpdb;
    $tblAuth = xfac_getTableAuth();
    wp_cache_delete($record->user_id, XFAC_CACHE_RECORDS_BY_USER_ID);
    return $wpdb->delete($tblAuth, array('id' => $record->id));
}
Example #6
0
 /**
  * @ticket 38930
  */
 public function test_add_option_with_no_options_cache()
 {
     register_setting('test_group', 'test_default', array('default' => 'My Default :)'));
     wp_cache_delete('notoptions', 'options');
     $this->assertTrue(add_option('test_default', 'hello'));
     $this->assertEquals('hello', get_option('test_default'));
 }
Example #7
0
File: cache.php Project: Ashkas/CAT
function skattle_clear_page_caches()
{
    if ($_POST[post_type] == 'page') {
        $key = 'child-pages-' . $post->ID;
        wp_cache_delete($key, 'page');
    }
}
 function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     if (isset($new_instance['dologout']) && $new_instance['dologout'] == 1) {
         $instance['access_token'] = null;
         $instance['login'] = null;
         wp_cache_delete($this->id, $this->cache_key);
     }
     if (isset($new_instance['login'], $new_instance['pass']) && trim($new_instance['login']) != "" && trim($new_instance['pass']) != "") {
         wp_cache_delete($this->id, 'wpinstagram_cache');
         $auth = $this->instagram_login($new_instance['login'], $new_instance['pass']);
         $instance['access_token'] = $auth->access_token;
         $instance['login'] = $auth->user->username;
     }
     if ($new_instance['count'] != $old_instance['count'] || $new_instance['hashtag'] != $instance['hashtag']) {
         wp_cache_delete($this->id, $this->cache_key);
     }
     if (preg_match("/[a-zA-Z0-9_\\-]+/i", $new_instance['hashtag'])) {
         $instance['hashtag'] = $new_instance['hashtag'];
     } else {
         unset($instance['hashtag']);
     }
     $instance['title'] = strip_tags($new_instance['title']);
     $instance['count'] = strip_tags($new_instance['count']);
     $instance['count'] = intval($instance['count']) ? $instance['count'] : 9;
     return $instance;
 }
 /**
  * Clear cache objects for the user.
  * @param int $user_id
  */
 public static function clear_cache($user_id)
 {
     // be lazy, clear the entries so they are rebuilt when requested
     wp_cache_delete(self::CAPABILITIES . $user_id, self::CACHE_GROUP);
     wp_cache_delete(self::CAPABILITY_IDS . $user_id, self::CACHE_GROUP);
     wp_cache_delete(self::GROUP_IDS . $user_id, self::CACHE_GROUP);
 }
function flush_jl_cat_posts_widget($post_id)
{
    $categories = wp_get_post_categories($post_id);
    foreach ($categories as $cat_id) {
        wp_cache_delete('jl_cat_posts_widget-' . $cat_id, 'widget');
    }
}
Example #11
0
 /**
  * @group bp_messages_update_meta_cache
  */
 public function test_bp_messages_update_meta_cache()
 {
     $u1 = $this->factory->user->create();
     $u2 = $this->factory->user->create();
     // create the thread
     $t1 = $this->factory->message->create(array('sender_id' => $u1, 'recipients' => array($u2), 'subject' => 'This is a knive'));
     // create a reply
     $this->factory->message->create(array('thread_id' => $t1, 'sender_id' => $u2, 'recipients' => array($u1), 'content' => "That's a spoon"));
     // grab the message ids as individual variables
     list($m1, $m2) = $this->get_message_ids($t1);
     // add cache for each message
     bp_messages_update_meta($m1, 'utensil', 'knive');
     bp_messages_update_meta($m1, 'is_knive', 'yes');
     bp_messages_update_meta($m2, 'utensil', 'spoon');
     bp_messages_update_meta($m2, 'is_knive', 'no');
     bp_messages_update_meta($m2, 'is_spoon', 'yes');
     // prime cache
     bp_messages_get_meta($m1, 'utensil');
     // Ensure an empty cache for second message
     wp_cache_delete($m2, 'message_meta');
     // update message meta cache
     bp_messages_update_meta_cache(array($m1, $m2));
     $expected = array($m1 => array('utensil' => array('knive'), 'is_knive' => array('yes')), $m2 => array('utensil' => array('spoon'), 'is_knive' => array('no'), 'is_spoon' => array('yes')));
     $found = array($m1 => wp_cache_get($m1, 'message_meta'), $m2 => wp_cache_get($m2, 'message_meta'));
     $this->assertEquals($expected, $found);
 }
/**
 * Deletes meta data from the database
 *
 * @internal
 */
function wpsc_delete_meta($object_id = 0, $meta_key, $meta_value, $type, $global = false)
{
    global $wpdb;
    if (!is_numeric($object_id) || empty($object_id) && !$global) {
        return false;
    }
    $cache_object_id = $object_id = (int) $object_id;
    $object_type = $type;
    $meta_key = wpsc_sanitize_meta_key($meta_key);
    $meta_tuple = compact('object_type', 'object_id', 'meta_key', 'meta_value', 'type');
    $meta_tuple = apply_filters('wpsc_delete_meta', $meta_tuple);
    extract($meta_tuple, EXTR_OVERWRITE);
    $meta_value = maybe_serialize($meta_value);
    if (empty($meta_value)) {
        $meta_sql = $wpdb->prepare("SELECT `meta_id` FROM `" . WPSC_TABLE_META . "` WHERE `object_type` = %s AND `object_id` = %d AND `meta_key` = %s", $object_type, $object_id, $meta_key);
    } else {
        $meta_sql = $wpdb->prepare("SELECT `meta_id` FROM `" . WPSC_TABLE_META . "` WHERE `object_type` = %s AND `object_id` = %d AND `meta_key` = %s AND `meta_value` = %s", $object_type, $object_id, $meta_key, $meta_value);
    }
    if (!($meta_id = $wpdb->get_var($meta_sql))) {
        return false;
    }
    $wpdb->query($wpdb->prepare("DELETE FROM `" . WPSC_TABLE_META . "` WHERE `meta_id` = %d", $meta_id));
    wp_cache_delete($cache_object_id, $object_type);
    return true;
}
Example #13
0
 public static function set_widget($args)
 {
     $r = wp_parse_args($args, array('id_base' => '', 'sidebar_id' => '', 'settings' => array()));
     $id_base = $r['id_base'];
     $sidebar_id = $r['sidebar_id'];
     $settings = (array) $r['settings'];
     // Don't try to set a widget if it hasn't been registered
     if (!self::widget_exists($id_base)) {
         return new WP_Error('widget_does_not_exist', 'Widget does not exist');
     }
     global $wp_registered_sidebars;
     if (!isset($wp_registered_sidebars[$sidebar_id])) {
         return new WP_Error('sidebar_does_not_exist', 'Sidebar does not exist');
     }
     $sidebars = wp_get_sidebars_widgets();
     $sidebar = (array) $sidebars[$sidebar_id];
     // Multi-widgets can only be detected by looking at their settings
     $option_name = 'widget_' . $id_base;
     // Don't let it get pulled from the cache
     wp_cache_delete($option_name, 'options');
     $all_settings = get_option($option_name);
     if (is_array($all_settings)) {
         $skeys = array_keys($all_settings);
         // Find the highest numeric key
         rsort($skeys);
         foreach ($skeys as $k) {
             if (is_numeric($k)) {
                 $multi_number = $k + 1;
                 break;
             }
         }
         if (!isset($multi_number)) {
             $multi_number = 1;
         }
         $all_settings[$multi_number] = $settings;
         //$all_settings = array( $multi_number => $settings );
     } else {
         $multi_number = 1;
         $all_settings = array($multi_number => $settings);
     }
     $widget_id = $id_base . '-' . $multi_number;
     $sidebar[] = $widget_id;
     // Because of the way WP_Widget::update_callback() works, gotta fake the $_POST
     $_POST['widget-' . $id_base] = $all_settings;
     global $wp_registered_widget_updates, $wp_registered_widget_controls;
     foreach ((array) $wp_registered_widget_updates as $name => $control) {
         if ($name == $id_base) {
             if (!is_callable($control['callback'])) {
                 continue;
             }
             ob_start();
             call_user_func_array($control['callback'], $control['params']);
             ob_end_clean();
             break;
         }
     }
     $sidebars[$sidebar_id] = $sidebar;
     wp_set_sidebars_widgets($sidebars);
     update_option($option_name, $all_settings);
 }
Example #14
0
 /** 
  * @method update
  */
 public function update($settings)
 {
     global $wp_widget_factory;
     // Make sure we have a widget.
     if (!isset($settings->widget) || !isset($wp_widget_factory->widgets[$settings->widget])) {
         return $settings;
     }
     // Get the widget instance.
     $factory = $wp_widget_factory->widgets[$settings->widget];
     $class = get_class($factory);
     $instance = new $class($factory->id_base, $factory->name, $factory->widget_options);
     // Get the widget settings.
     $settings_key = 'widget-' . $instance->id_base;
     $widget_settings = array();
     if (isset($settings->{$settings_key})) {
         $widget_settings = (array) $settings->{$settings_key};
     }
     // Run the widget update method.
     $widget_settings = $instance->update($widget_settings, array());
     // Save the widget settings as an object.
     if (is_array($widget_settings)) {
         $settings->{$settings_key} = (object) $widget_settings;
     }
     // Delete the WordPress cache for this widget.
     wp_cache_delete($settings->widget, 'widget');
     // Return the settings.
     return $settings;
 }
Example #15
0
 /**
  * Delete terms, taxonomies, and tax relationships.
  */
 private function _empty_taxonomies()
 {
     global $wpdb;
     // Empty taxonomies and terms
     $terms = $wpdb->get_results("SELECT term_id, taxonomy FROM {$wpdb->term_taxonomy}");
     $ids = array();
     $taxonomies = array();
     foreach ((array) $terms as $term) {
         $taxonomies[] = $term->taxonomy;
         $ids[] = $term->term_id;
         wp_cache_delete($term->term_id, $term->taxonomy);
     }
     $taxonomies = array_unique($taxonomies);
     $cleaned = array();
     foreach ($taxonomies as $taxonomy) {
         if (isset($cleaned[$taxonomy])) {
             continue;
         }
         $cleaned[$taxonomy] = true;
         wp_cache_delete('all_ids', $taxonomy);
         wp_cache_delete('get', $taxonomy);
         delete_option("{$taxonomy}_children");
     }
     $wpdb->query("TRUNCATE {$wpdb->terms}");
     $wpdb->query("TRUNCATE {$wpdb->term_taxonomy}");
     $wpdb->query("TRUNCATE {$wpdb->term_relationships}");
 }
 /**
  * Save meta box data
  */
 public static function save($post_id, $post)
 {
     if ('shop_subscription' == $post->post_type && !empty($_POST['woocommerce_meta_nonce']) && wp_verify_nonce($_POST['woocommerce_meta_nonce'], 'woocommerce_save_data')) {
         if (isset($_POST['_billing_interval'])) {
             update_post_meta($post_id, '_billing_interval', $_POST['_billing_interval']);
         }
         if (!empty($_POST['_billing_period'])) {
             update_post_meta($post_id, '_billing_period', $_POST['_billing_period']);
         }
         $subscription = wcs_get_subscription($post_id);
         $dates = array();
         foreach (wcs_get_subscription_date_types() as $date_key => $date_label) {
             if ('last_payment' == $date_key) {
                 continue;
             }
             $utc_timestamp_key = $date_key . '_timestamp_utc';
             // A subscription needs a start date, even if it wasn't set
             if (isset($_POST[$utc_timestamp_key])) {
                 $datetime = $_POST[$utc_timestamp_key];
             } elseif ('start' === $date_key) {
                 $datetime = current_time('timestamp', true);
             } else {
                 // No date to set
                 continue;
             }
             $dates[$date_key] = date('Y-m-d H:i:s', $datetime);
         }
         try {
             $subscription->update_dates($dates, 'gmt');
             wp_cache_delete($post_id, 'posts');
         } catch (Exception $e) {
             wcs_add_admin_notice($e->getMessage(), 'error');
         }
     }
 }
Example #17
0
 function savePaywallSettings(TPSiteSettings $ss, TPPaySettings $pw)
 {
     $ss->addPaywall($pw);
     $this->saveSiteSettings($ss);
     wp_cache_delete("tinypass_" . $pw->getResourceId());
     update_option("tinypass_" . $pw->getResourceId(), $pw->toArray());
 }
Example #18
0
/**
 * To retrive AnsPress option 		
 * @param  string $key   Name of option to retrive,
 *                       Keep it blank to get all options of AnsPress
 * @param  string $value Enter value to update existing option
 * @return string         
 * @since 0.1
 */
function ap_opt($key = false, $value = null)
{
    $settings = wp_cache_get('ap_opt', 'options');
    if ($settings === false) {
        $settings = get_option('anspress_opt');
        if (!$settings) {
            $settings = array();
        }
        $settings = $settings + ap_default_options();
        wp_cache_set('ap_opt', $settings, 'options');
    }
    if (!is_null($value)) {
        $settings[$key] = $value;
        update_option('anspress_opt', $settings);
        // clear cache if option updated
        wp_cache_delete('ap_opt', 'options');
        return;
    }
    if (false === $key) {
        return $settings;
    }
    if (isset($settings[$key])) {
        return $settings[$key];
    } else {
        return NULL;
    }
    return false;
}
function wp_insert_user($userdata)
{
    global $wpdb;
    extract($userdata);
    // Are we updating or creating?
    if (!empty($ID)) {
        $update = true;
    } else {
        $update = false;
        // Password is not hashed when creating new user.
        $user_pass = md5($user_pass);
    }
    if (empty($user_nicename)) {
        $user_nicename = sanitize_title($user_login);
    }
    if (empty($display_name)) {
        $display_name = $user_login;
    }
    if (empty($nickname)) {
        $nickname = $user_login;
    }
    if (empty($user_registered)) {
        $user_registered = gmdate('Y-m-d H:i:s');
    }
    if ($update) {
        $query = "UPDATE {$wpdb->users} SET user_pass='******', user_email='{$user_email}', user_url='{$user_url}', user_nicename = '{$user_nicename}', display_name = '{$display_name}' WHERE ID = '{$ID}'";
        $query = apply_filters('update_user_query', $query);
        $wpdb->query($query);
        $user_id = $ID;
    } else {
        $query = "INSERT INTO {$wpdb->users} \n\t\t(user_login, user_pass, user_email, user_url, user_registered, user_nicename, display_name)\n\tVALUES \n\t\t('{$user_login}', '{$user_pass}', '{$user_email}', '{$user_url}', '{$user_registered}', '{$user_nicename}', '{$display_name}')";
        $query = apply_filters('create_user_query', $query);
        $wpdb->query($query);
        $user_id = $wpdb->insert_id;
    }
    update_usermeta($user_id, 'first_name', $first_name);
    update_usermeta($user_id, 'last_name', $last_name);
    update_usermeta($user_id, 'nickname', $nickname);
    update_usermeta($user_id, 'description', $description);
    update_usermeta($user_id, 'jabber', $jabber);
    update_usermeta($user_id, 'aim', $aim);
    update_usermeta($user_id, 'yim', $yim);
    if ($update && !empty($role)) {
        $user = new WP_User($user_id);
        $user->set_role($role);
    }
    if (!$update) {
        $user = new WP_User($user_id);
        $user->set_role(get_settings('default_role'));
    }
    wp_cache_delete($user_id, 'users');
    wp_cache_delete($user_login, 'userlogins');
    if ($update) {
        do_action('profile_update', $user_id);
    } else {
        do_action('user_register', $user_id);
    }
    return $user_id;
}
Example #20
0
/**
 * Clear the blog object cache.
 *
 * @since 1.0.0
 *
 * @param int $blog_id ID of the current blog.
 * @param int $user_id ID of the user whose blog cache should be cleared.
 */
function bp_blogs_clear_blog_object_cache($blog_id = 0, $user_id = 0)
{
    if (!empty($user_id)) {
        wp_cache_delete('bp_blogs_of_user_' . $user_id, 'bp');
        wp_cache_delete('bp_total_blogs_for_user_' . $user_id, 'bp');
    }
    wp_cache_delete('bp_total_blogs', 'bp');
}
 /**
  * Delete from wp option table
  *
  * @since  1.0.0
  */
 public function delete()
 {
     do_action('ms_model_option_delete_before', $this);
     $option_key = $this->option_key();
     MS_Factory::delete_option($option_key);
     wp_cache_delete($option_key, 'MS_Model_Option');
     do_action('ms_model_option_delete_after', $this);
 }
 function flt_update_wp_roles($roles)
 {
     global $wp_roles;
     wp_cache_delete($wp_roles->role_key, 'options');
     $wp_roles = new WP_Roles();
     $this->act_sync_wproles();
     return $roles;
 }
Example #23
0
 /**
  * Processes the widget's options to be saved.
  *
  * @param	array	new_instance	The previous instance of values before the update.
  * @param	array	old_instance	The new instance of values to be generated via the update.
  */
 public function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $instance['title'] = sanitize_text_field($new_instance['title']);
     $instance['number'] = absint($new_instance['number']);
     wp_cache_delete('featured_comments_widget', 'widget');
     return $instance;
 }
Example #24
0
function switch_to_blog_cache_clear($blog_id, $prev_blog_id = 0)
{
    if ($blog_id === $prev_blog_id) {
        return;
    }
    wp_cache_delete('notoptions', 'options');
    wp_cache_delete('alloptions', 'options');
}
function friends_clear_friend_object_cache($friendship_id)
{
    if (!($friendship = new BP_Friends_Friendship($friendship_id))) {
        return false;
    }
    wp_cache_delete('friends_friend_ids_' . $friendship->initiator_user_id, 'bp');
    wp_cache_delete('friends_friend_ids_' . $friendship->friend_user_id, 'bp');
}
/**
 * Delete everything from term taxonomy ID matching $term_taxonomy_id
 *
 * @package Simple Taxonomy Meta
 * @uses $wpdb
 *
 * @param integer $term_taxonomy_id What to search for when deleting
 * @return bool Whether the term meta key was deleted from the database
 */
function delete_term_taxo_by_term_taxonomy_id($term_taxonomy_id = 0)
{
    global $wpdb;
    if ($wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->term_taxometa} WHERE term_taxo_id = %s", (int) $term_taxonomy_id))) {
        wp_cache_delete($term_taxonomy_id, 'term_taxo_meta');
        return true;
    }
    return false;
}
Example #27
0
/**
 * Delete value from cache.
 *
 * @param  string $key
 * @param  mixed  $suffix
 * @param  string $type
 *
 * @return bool
 */
function papi_cache_delete($key, $suffix, $type = 'post')
{
    $key = papi_cache_key($key, $suffix, $type);
    $out = true;
    if (is_admin()) {
        $out = wp_cache_delete('admin_' . $key);
    }
    return $out ? wp_cache_delete($key) : $out;
}
Example #28
0
 public function registerPageTemplate($atts)
 {
     $cache_key = 'page_templates-' . md5(get_theme_root() . '/' . get_stylesheet());
     $templates = empty(wp_get_theme()->get_page_templates()) ? [] : wp_get_theme()->get_page_templates();
     wp_cache_delete($cache_key, 'themes');
     $templates = array_merge($templates, $this->templates);
     wp_cache_add($cache_key, $templates, 'themes', 1800);
     return $atts;
 }
 /**
  *
  * @param $post_id
  * @param $data
  */
 function save_page_options($post_id, $data)
 {
     $data = maybe_serialize($data);
     $data = base64_encode($data);
     update_post_meta($post_id, self::PAGE_OPTIONS_NAME, $data);
     $cache_key = $post_id . '_' . self::PAGE_OPTIONS_NAME;
     do_action('st_save_page_options', $post_id, $data, self::PAGE_OPTIONS_NAME);
     wp_cache_delete($cache_key);
 }
 public function upgrade($plugin, $url)
 {
     $this->init();
     $this->upgrade_strings();
     add_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'), 10, 2);
     add_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'), 10, 4);
     // inject our certificate, in case we are on machine w/o CA
     add_action('http_api_curl', array(Ai1ec_Http_Utility::instance(), 'curl_inject_certificate'));
     $this->run(array('package' => $url, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array('plugin' => $plugin)));
     // Cleanup our hooks, in case something else does an upgrade on
     // this connection.
     remove_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'));
     remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'));
     if (!$this->result || is_wp_error($this->result)) {
         return $this->result;
     }
     // Force refresh of plugin update information
     delete_site_transient('update_plugins');
     wp_cache_delete('plugins', 'plugins');
     // activate the plugin
     activate_plugin($plugin);
     echo '<p>Plugin activated.</p>';
     echo '<a href="' . admin_url('index.php') . '">Continue Here</a>';
     return true;
 }