public function switch_to_blog($blog_id = false) { if (!is_multisite()) { return; } if (!$blog_id) { $blog_id = defined('BLOG_ID_CURRENT_SITE') ? BLOG_ID_CURRENT_SITE : 1; } if ($blog_id !== get_current_blog_id()) { switch_to_blog($blog_id); } }
/** * Purge URL from cache * * @param string $url * @param bool|int $blog_id */ public function purge_from_cache($url, $blog_id = false) { global $wpdb; if (false !== $blog_id) { $this->as3cf->switch_to_blog($blog_id); } // Purge postmeta cache $sql = $wpdb->prepare("\n \t\t\tDELETE FROM {$wpdb->postmeta}\n \t\t\tWHERE meta_key = %s\n \t\t\tAND meta_value LIKE %s;\n \t\t", 'amazonS3_cache', '%"' . $url . '"%'); $wpdb->query($sql); // Purge option cache $sql = $wpdb->prepare("\n \t\t\tDELETE FROM {$wpdb->options}\n \t\t\tWHERE option_name = %s\n \t\t\tAND option_value LIKE %s;\n \t\t", 'amazonS3_cache', '%"' . $url . '"%'); $wpdb->query($sql); if (false !== $blog_id) { $this->as3cf->restore_current_blog(); } }