Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Tymotey committed Jul 8, 2024
1 parent db7a3b4 commit aa0b640
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions cli/purge.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,25 +169,29 @@ public function url($args)
$current_blog = get_current_blog_id();
// If subfolder install test if current url has a blog link. If subdomain install: $path needs to remain '/'.
$path = '/';
$switch_blog = null;
if(!SUBDOMAIN_INSTALL){
// Get subfolder blog link. Try to match to a blog id.
$temp_path = explode('/', $deconstructed['path']);
if(!empty($temp_path[1])){
$path = '/'.$temp_path[1].'/'; // need / at beginning and end.
}
}

// Test if need to switch. Condition is if blog has been found.
$switch_blog = get_blog_id_from_url($deconstructed['host'], $path);
if(!$switch_blog){
// If no blog found, is main blog
$path = '/';
}
else{
if($current_blog != $switch_blog){
// If blog found switch to that blog.
switch_to_blog($switch_blog);
}
}
// Get blog id from URL.
$url_blog = get_blog_id_from_url($deconstructed['host'], $path);
if(!$url_blog){
// If no blog found, is main blog
$path = '/';
}
else{
// If blog found will switch to it.
$switch_blog = $url_blog;
}

// Switch to blog if needed.
if($switch_blog && $switch_blog!==$current_blog){
switch_to_blog($switch_blog);
}

// Test if link is ok.
Expand Down

0 comments on commit aa0b640

Please sign in to comment.