Last active
December 16, 2015 14:22
-
-
Save sectsect/8fc1a7cf0d1b89a201cb to your computer and use it in GitHub Desktop.
Detect the_content for Japanese multibyte Characters on wordpress
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 | |
function mb_trim($str) { | |
static $chars = "[\\x0-\x20\x7f\xc2\xa0\xe3\x80\x80]"; | |
return preg_replace("/\A{$chars}++|{$chars}++\z/u", '', strip_tags($str)); | |
} | |
$content = mb_trim(get_the_content()); | |
if($content === ""){ | |
echo '<p>Empty Content</p>'; | |
}else{ | |
echo '<p>NOT Empty Content</p>'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment