Esempio n. 1
0
 /**
  * Get the excerpt through the_content filter
  * Accepted values for length_unit: 'char', 'word'
  * @param array $args
  * @return string
  */
 public function getTheExcerpt($args = array())
 {
     $default_args = array('length' => 150, 'length_unit' => 'char', 'strip_shortcodes' => true, 'hellip' => '…');
     $args = Arr::iterable($args) ? array_merge($default_args, $args) : $default_args;
     extract($args);
     $excerpt = $this->get('post_excerpt');
     if (!strlen($excerpt)) {
         $excerpt = strip_tags($this->get('post_content'));
         if ($length_unit == 'char') {
             $excerpt = Str::shortenWordsByChar($excerpt, $length, $hellip);
         } elseif ($length_unit == 'word') {
             $excerpt = Str::shortenWords($excerpt, $length, $hellip);
         }
     }
     $excerpt = apply_filters('the_excerpt', $excerpt);
     return $strip_shortcodes ? strip_shortcodes($excerpt) : $excerpt;
 }