=== Highlight Search Terms === Contributors: RavanH Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravanhagen%40gmail%2ecom&item_name=Highlight%20Search%20Terms&item_number=0%2e6&no_shipping=0&tax=0&bn=PP%2dDonationsBF&charset=UTF%2d8 Tags: mark, highlight, hilite, search, term, terms, jquery Requires at least: 2.3 Tested up to: 3.4.2 Stable tag: 1.2.2 Very lightweight jQuery script that wraps search terms in an HTML5 mark tag when referer is a search engine or within wp search results. == Description == Highlights search terms using jQuery when referer is a search engine _or_ within WordPress generated search results. This plugin is a light weight, low resource demanding and very simple fusion between How to Highlight Search Terms with jQuery - theme hack by Thaya Kareeson and Search Hilite by Ryan Boren, with some optimisations and adapted to support HTML5. **New since version 1.2** - Caching (WP Super Cache) compatibility - Highlights not only on WP search results page but also one click deeper inside any of the found pages - Search terms wrapped in double qoutes now considered as single term - Support for many more search engines: Google, Bing, Yahoo, Lycos, Ask, AOL, Baidu, Youdao, Dogpile, Search.com, Goodsearch.com, Mywebsearch.com, Webcrawler.com, Info.com **NOTE:** to make the highlights visible in browsers that do not support HTML5 like Internet Explorer 8 or older you will have to define at least one CSS hilite styling! Read on below **So what do I need to do?** and [Installation](http://wordpress.org/extend/plugins/highlight-search-terms/installation/) for more detailed instructions. You can find CSS examples in [Other Notes](http://wordpress.org/extend/plugins/highlight-search-terms/other_notes/). = What does it do? = This low impact plugin uses only two action hooks, **wp_header** where it needs to define some variables and **wp_footer** to insert the jQuery library (included in your WordPress package; only if not already loaded) and to add the hilite jQuery extension to your page source code. The jQuery extension that runs after the page has loaded, finds all search terms on that page inside each div with class `hentry` (or ID `content`, `main` or `wrapper`) and wraps them in ` ... ` tags. Note that N is a number starting with 0 for the first term used in the search phrase increasing 1 for each additional term used. Any part of a search phrase wrapped in quotes is considered as a single term. = What does it NOT do? = There are no CSS style rules set for highlighting. You are free to use any styling you wish but to make the highlights visible in browsers that do not support HTML5 like Internet Explorer 8 or older you absolutely *need to define at least one rule*. = So what do I need to do? = In most cases, it should just work. But you can do two things to ensure backward browser and theme compatibility: **1. Define CSS rules:** There are _no_ configuration options and there is _no_ predefined highlight styling. You are completely free to define any CSS styling rules in your themes **main stylesheet (style.css)** or use any **Custom CSS plugin** like [Custom CSS](http://wordpress.org/extend/plugins/safecss/) to get a result that fits your theme best. You can find basic instructions and CSS examples under the [Other Notes](http://wordpress.org/extend/plugins/highlight-search-terms/other_notes/) tab. **2. Check your theme:** In most up to date themes (including WP's own default theme) post and page content is shown inside a div with class `hentry`. This means search terms found in post and page content will be highlighted but not similar terms that accidentaly show in the page header, sidebar or footer. If your current theme does not use the `hentry` class (yet), this plugin will look for IDs `content`, `main` and finally `wrapper` but if none of those are found, it will not work for you out of the box. See the last of the [FAQ's](http://wordpress.org/extend/plugins/highlight-search-terms/faq/) for ways to make it work. == Installation == To make it work, you will need to take up to three steps, depending on your wishes and WordPress theme. (I) A normal installation and activation procedure; (II) adding CSS styling rules to get highlighting for older browsers that do not support HTML5 like Internet Explorer 8 and below; _and_ (III) Make sure your theme uses any of the recognized classes or ID's for the post content div so that the script knows where and where not to look for search terms. **I.** [Install now](http://coveredwebservices.com/wp-plugin-install/?plugin=highlight-search-terms) _or_ use the slick search and install feature (Plugins > Add New and search for "highlight search terms") in your WP2.7+ admin section _or_ follow these basic steps. 1. Download archive and unpack. 2. Upload (and overwrite) the /highlight-search-terms/ folder and its content to the /plugins/ folder. 3. Activate plugin on the Plug-ins page **II.** Add at least _one_ new rule to your themes styleheet (style.css or a custom stylsheet or a custom css plugin) to style highlightable text. For example use `.hilite { background:#D3E18A; }` to get a moss green background on search terms found in the content section (not header, sidebar or footer; assuming your Theme uses a div with class "hentry"). Please find more examples under the [Other Notes](http://wordpress.org/extend/plugins/highlight-search-terms/other_notes/) tab. **III.** In most up to date themes (including WP's own Default theme) post and page content is shown inside a div with class `hentry`. This class is recognized by the hilite script, which means search terms found in post and page content will be highlighted but *not* similar terms that coincidentaly reside in the page header, sidebar or footer. If your current theme does not use the `hentry` class (yet), this plugin will look for IDs `content`, `main` and finally `wrapper` (which might include the header, sidebar and footer areas) but if *none* of those are found, it will not work for you out of the box. See the last of the [FAQ's](http://wordpress.org/extend/plugins/highlight-search-terms/faq/) for ways to make it work. == Frequently Asked Questions == = I do not see any highlighting! = This plugin has _no_ configuration options page and there is _no_ predefined highlight styling. For any highliting to become visible in browsers that do not support HTML5 like Internet Explorer 8 or older, you have to complete step II of the installation process. Edit your themes Stylesheet (style.css) to contain a rule that will give you exactly the styling that fits your theme. Don't want to edit your themes stylesheet? I can highly recommend Automattics own [Custom CSS](http://wordpress.org/extend/plugins/safecss/) plugin! = I want to customise the highlighting but have no idea what to put in my stylesheet. Can you give me some examples? = Sure! See tab [Other Notes](http://wordpress.org/extend/plugins/highlight-search-terms/other_notes/) for instructions and some examples to get you started. = I still do not see any highlighting! = Due to a problem with jQuery's `$('body')` call in combination with many other scripts (like Google Ads, Analytics, Skype Check and other javascript) in the ever increasingly popular Firefox browser, I have had to limit the script search term wrapping to a particular div instead of the whole document body. I chose div with class "hentry" since that is the most commonly used content layer class in WordPress themes. If that is not available, the script will look for divs #content then #main then #wrapper. However, in your particular theme, none of these divs might be available... Let's suppose your theme's index.php or single.php has no `