本文整理匯總了PHP中TextHelper::trim_words方法的典型用法代碼示例。如果您正苦於以下問題:PHP TextHelper::trim_words方法的具體用法?PHP TextHelper::trim_words怎麽用?PHP TextHelper::trim_words使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TextHelper
的用法示例。
在下文中一共展示了TextHelper::trim_words方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
protected function run()
{
$force = $this->force;
$len = $this->length;
$chars = $this->char_length;
$strip = $this->strip;
$readmore_matches = array();
$text = '';
$trimmed = false;
if (isset($this->post->post_excerpt) && strlen($this->post->post_excerpt)) {
if ($this->force) {
$text = TextHelper::trim_words($this->post->post_excerpt, $len, false);
if ($chars !== false) {
$text = TextHelper::trim_characters($this->post->post_excerpt, $chars, false);
}
$trimmed = true;
} else {
$text = $this->post->post_excerpt;
}
}
if (!strlen($text) && preg_match('/<!--\\s?more(.*?)?-->/', $this->post->post_content, $readmore_matches)) {
$pieces = explode($readmore_matches[0], $this->post->post_content);
$text = $pieces[0];
if ($force) {
$text = TextHelper::trim_words($text, $len, false);
if ($chars !== false) {
$text = TextHelper::trim_characters($text, $chars, false);
}
$trimmed = true;
}
$text = do_shortcode($text);
}
if (!strlen($text)) {
$text = TextHelper::trim_words($this->post->content(), $len, false);
if ($chars !== false) {
$text = TextHelper::trim_characters($text, $chars, false);
}
$trimmed = true;
}
if (!strlen(trim($text))) {
return trim($text);
}
if ($strip) {
$allowable_tags = is_string($strip) ? $strip : null;
$text = trim(strip_tags($text, $allowable_tags));
}
if (strlen($text)) {
return $this->assemble($text, $readmore_matches, $trimmed);
}
return trim($text);
}