Timber\PostPreview::run PHP Метод

run() защищенный Метод

protected 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);
    }