本文整理汇总了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);
}