Created
May 11, 2013 17:51
-
-
Save torounit/5560793 to your computer and use it in GitHub Desktop.
WordPressマルチサイトで、body_classに"site-hoge"を出力するクラス。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Ms_Body_Class { | |
public function __construct() { | |
add_filter( "body_class", array( $this, "body_class" )); | |
} | |
public function get_blog_path() { | |
$blog_details = get_blog_details($GLOBALS['blog_id']); | |
$blog_path = trim( $blog_details->path, "/" ); | |
return $blog_path; | |
} | |
public function body_class( $classes ) { | |
$blog_path = $this->get_blog_path(); | |
if(!$blog_path) { | |
$blog_path = "main"; | |
} | |
$classes[] = "site-".$blog_path; | |
return $classes; | |
} | |
} | |
new Ms_Body_Class(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment