Ejemplo n.º 1
0
 function highlight($post, $words, $content)
 {
     $highlight = new Highlighter(get_the_category_list(',', '', $post->ID), $words, true);
     if ($highlight->has_matches()) {
         $highlight->mark_words();
         return '<p><strong>' . __('Category', 'search-unleashed') . ':</strong> ' . $highlight->get() . '</p>';
     }
     return '';
 }
Ejemplo n.º 2
0
 function highlight($post, $words, $content)
 {
     $highlight = new Highlighter($this->get_permalink($post->ID), $words, true);
     if ($highlight->has_matches()) {
         $highlight->mark_words();
         return '<p><strong>' . __('Permalink', 'search-unleashed') . ':</strong> ' . $highlight->get() . '</p>';
     }
     return '';
 }
Ejemplo n.º 3
0
 function highlight($post, $words, $content)
 {
     $highlight = new Highlighter(get_the_author_meta('display_name', $post->post_author), $words, true);
     if ($highlight->has_matches()) {
         $highlight->mark_words();
         return '<p><strong>' . __('Author', 'search-unleashed') . ':</strong> ' . $this->get_author($highlight->get(), $post) . '</p>';
     }
     return '';
 }
Ejemplo n.º 4
0
 function highlight($post, $words, $content)
 {
     if ($this->show) {
         $highlight = new Highlighter($this->gather($post), $words, true);
         if ($highlight->has_matches()) {
             $highlight->mark_words();
             return '<p><strong>' . __('Tags', 'search-unleashed') . ':</strong> ' . $highlight->get() . '</p>';
         }
     }
     return '';
 }
Ejemplo n.º 5
0
 function highlight($post, $words, $content)
 {
     if (isset($post->comment_id)) {
         $comment = get_comment($post->comment_id);
         $highlight = new Highlighter($this->gather($comment), $words, true);
         if ($highlight->has_matches()) {
             $highlight->mark_words();
             return '<p><strong>' . __('Comment author', 'search-unleashed') . ':</strong> ' . $highlight->get() . '</p>';
         }
     }
     return '';
 }
Ejemplo n.º 6
0
 function highlight($post, $words, $content)
 {
     global $search_spider;
     // First check if the excerpt is not the same as the content
     $highlight = new Highlighter($content, $words, true);
     if ($highlight->has_matches() && $search_spider->has_highlighted_content == false) {
         $highlight->zoom($this->before, $this->after);
         $highlight->mark_words();
         return '<p><strong>' . __('Excerpt', 'search-unleashed') . ':</strong> ' . $highlight->get() . '</p>';
     }
     return '';
 }
Ejemplo n.º 7
0
 function highlight($post, $words, $content)
 {
     $meta = $this->the_post_custom($post->ID);
     if (!empty($meta)) {
         $highlight = new Highlighter($meta, $words, true);
         if ($highlight->has_matches()) {
             $highlight->zoom(40, 80);
             $highlight->mark_words();
             return '<p><strong>' . __('Meta-data', 'search-unleashed') . ':</strong> ' . $highlight->get() . '</p>';
         }
     }
     return '';
 }
Ejemplo n.º 8
0
 function highlight($post, $words, $content)
 {
     $high = new Highlighter($content, $words, true);
     if ($this->noindex === false) {
         global $search_spider;
         $search_spider->has_highlighted_content = true;
         $content = apply_filters('search_unleashed_content', $content, $post);
         $high->zoom($this->before, $this->after);
         $high->mark_words();
     } else {
         $high->zoom($this->before, $this->after);
     }
     return $high->reformat($high->get());
 }
Ejemplo n.º 9
0
	function highlight( $post, $words, $content ) {
		if ( isset( $post->comment_id ) ) {
			$comment   = get_comment( $post->comment_id );
			$highlight = new Highlighter( $this->gather( $comment ), $words, true );

			if ( $highlight->has_matches() ) {
				$highlight->zoom( $this->before, $this->after );
				$highlight->mark_words();
			
				if ( $this->include == 'content' )
					return sprintf( __( '<p><strong>Comment:</strong> %s</p>', 'search-unleashed' ), $highlight->get() );
				else if ($this->include == 'link')
					return sprintf( __( '<p><strong>Comment by %s:</strong> %s</p>', 'search-unleashed' ), $this->get_comment_author_link( $comment ), $highlight->get() );
				else if ($this->include == 'name')
					return sprintf( __( '<p><strong>Comment by %s:</strong> %s</p>', 'search-unleashed' ), apply_filters( 'comment_author', apply_filters( 'get_comment_author', $comment->comment_author ) ), $highlight->get() );
			}
		}
		
		return '';
	}
Ejemplo n.º 10
0
 /**
  * Highlighting for post titles.
  * Note that the_title may be called several times in a theme to display a single post. For this reason we have a 'theme_title_position' so that we only
  * highlight the title on the nth call to this function, per post display
  *
  * @param string $text
  * @return string Title
  */
 function the_title($text)
 {
     // Only if loop_start has been sent
     if (in_the_loop()) {
         global $post;
         // Reset our variables if this is the first time on this post
         if ($this->last_post_id != $post->ID) {
             $this->last_post_id = $post->ID;
             $this->last_post_count = 0;
         }
         $options = $this->get_options();
         // Compare position
         $this->last_post_count++;
         if ($this->last_post_count - 1 == $options['theme_title_position']) {
             $high = new Highlighter($text, $this->engine->get_terms());
             $high->mark_words();
             return $high->get();
         }
     }
     return $text;
 }