Skip to content

Instantly share code, notes, and snippets.

@sectsect
Last active December 16, 2015 14:22
Show Gist options
  • Save sectsect/8fc1a7cf0d1b89a201cb to your computer and use it in GitHub Desktop.
Save sectsect/8fc1a7cf0d1b89a201cb to your computer and use it in GitHub Desktop.
Detect the_content for Japanese multibyte Characters on wordpress
<?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