Skip to content

Instantly share code, notes, and snippets.

@spkellydev
Last active November 13, 2017 19:31
Show Gist options
  • Save spkellydev/db276f064d1fc79ee8d23056a168f006 to your computer and use it in GitHub Desktop.
Save spkellydev/db276f064d1fc79ee8d23056a168f006 to your computer and use it in GitHub Desktop.
<?php
//https://codex.wordpress.org/WPMU_Functions/switch_to_blog
interface iPartial
{
public function get_site_path($blog_id);
public function get_main_slug($slug);
}
class Partial implements iPartial
{
public function get_site_path($blog_id) {
$self = get_blog_details($blog_id)->path;
if ($self != '/') {
return false;
} else {
return true;
}
}
public function get_main_slug($slug) {
//if site url has no path added
//main site blog id would == 1
$blog_id = get_current_blog_id();
if (get_site_path($blog_id)) {
switch_to_blog( 1 );
//call private partial slug only after switching blogs
sl9_private_partial($slug);
//go back to main site
restore_current_blog();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment