=== Plugin Name ===
Contributors: rfgoetz
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YQQURY7VW2B2J
Tags: topbar, header bar,beforesite, heads up, fixed bar, link, heads up bar,attention, quick notice, bar, notification bar, popup, self promotion, toolbar, top of the page, plugin, important, message, php
Requires at least: 3.2.1
Tested up to: 3.6
Stable tag: 5.04

Create MULTIPLE TopBars that will be shown at the top of your website.  TopBars are selected by a variety of options - includes schedules! 

== Description ==

Create **MULTIPLE** TopBars that will be shown at the top (or bottom) of your website.  The Cacheable TopBars are randomly selected based on the criteria you select, including start time, stop time and more.  You can provide a weighting to skew selected TopBars to show up more often.  It is super-duper customizable, even add your own PHP. You can easily lose track of time getting your TopBars perfect!

Version 5.0 now allows the user to re-open a TopBar, adds more Social buttons (and you can place them before or after the TopBar.)  You can also see some Sample ToolBars that shows how you can use the plugin. It also gives you a way to supress live preview (see FAQ for &nopreview option) to help find broken, custom PHP.  Also, there a several more warning messages as the TopBar tries to tell you if you may have an incompatible setting.

Version 4.17 adds the ability to display the TopBar only when the user scrolls the page. 

New with Verison 4.15+ is the ability to add custom PHP to be executed when the TopBars are created.  Of course, that can be super dangerous if you enter PHP code that is invalid -- you could break your website.  That option should only be used by **Advanced Swimmers** only.

Version 4.10+ now statically creates the TopBar to allow you to take advantage of caching plugins.

There was a **Superduper major re-write with Version 4.0.**  Refactored all the functions to use its own database table instead of WordPress options.  This allows you to create an unlimited number of TopBars.  This version is leaner, faster, smarter.   Quick links are added throughout to make editing your TopBars a breeze.

Want to see how this TopBar looks?   You can test how your TopBars show up to allow you to adjusting the selection factors on the fly.  You can even get a sampling of how 10 pageviews would render the TopBar -- *great for A/B testing*.

Want to create a lot of TopBars -- you can copy the existing ones with just a few clicks.   Know SQL?  You can even export the TopBars in three different formats (JSON, CSV or SQL).    Sorry, **no support** is given if you import directly to the database.

With so many option pages, I only included a few screen images.  More images can be found on [Zwebify.com](http://zwebify.com/WordPress-plugins/)

Here is a crazy-long list of options you have for each TopBar -- and this is not even complete!

<ol>
	<li>Enable/disable the TopBar without disabling the plugin.</li>
	<li>Place the TopBar Above the Header or Below the Footer</li>
	<li>Amount of time (in milliseconds) for the TopBar to appear. Enter 0 for no delay.</li>
	<li>Amount of time (in milliseconds) for the TopBar to take to slide down on the page. Enter 0 for no delay.</li>
	<li>Amount of time (in milliseconds) for the TopBar to stay on the page.  Enter 0 for the TopBar to not disappear.</li>
	<li>Pick the date/time for the TopBar to start showing.</li>
	<li>Pick the date/time for the TopBar to stop showing. Of course, it must be after the start time. Select 0 for the TopBar to never disappear.</li>
	<li>Whether to show the TopBar for logged in users, not logged in users or all users.
	<li>A lot of CSS options -- and even a way to enter your own CSS in</li>
	<li>Retrict the Topbar to show on only certain pages (or to not show on those pages)</li>
	<li>Retrict the Topbar to show on only certain categories (or to not show on those categories)</li>
	<li>Add social buttons to the TopBar</li>
	<li>Add a Close Button</li>
	<li>Option to execute your own PHP code before (or after) the TopBar is created</li>
	<li>Has explicit support for qTranslate -- translates the top bar text fields and link field.</li>
	<li>You can have unlimited number of TopBars -- the plugin randomly selects one (based on individual weightings) to show </li>
	<li>The TopBars are generated in such a way to support cacheing (e.g. W3 Total Cache, WP Super Cache)</li>
</ol>



== Installation ==

This section describes how to install the plugin and get it working.

1. Upload all files in `wp-topbar.zip` to the `/wp-content/plugins/wp-topbar` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Configure the options
4. Make sure to set "Enable" to yes to see the plugin on your website.

I've included a sample image for you to try on your website:  wp-topbar_sample_image.jpg.

== Frequently Asked Questions ==

= My TopBar is not working. What should I do? =
Are you upgrading from an old version?   I do my best to allow for clean upgrades.  Just in case, try creating a default TopBar.  If that works, you may have CSS or other incompatabilities on the older TopBar that does not work with the latest version.  

Also, check for any messages under the Live Preview heading on the Admin Page. It will tell you if you have cookies or time settings that will prevent the TopBar from loading.  

You may have CSS settings that prevent the TopBar from loading. If you entered any setting that are not valid, the TopBar will not load. Try deleting the settings and then re-entering your CSS until you find the one that is causing the issue.

You can also use the Debug page to see if you can see an error.

= HELP! I am using custom PHP and now my website is broken =
Don't Panic! 
You have two options to fix this:
1. Append &nopreview to the url when you are trying to edit a TopBar. E.g. https://www.dummy.org/wp/wp-admin/?page=wp-topbar.php&action=phptexttab&barid=422116&nopreview.    Hit ENTER to reload the page. You should now be able to edit the custom php.
2. Go into your database tool (usually using phpMyAdmin), find the wp-topbar table and delete the offending row. 

= My TopBar does not support my local language = 

The problem is with your table collation. You need to change the collation to utf8_general_ci.

Run this query from your phpMyAdmin to change the collation.

ALTER TABLE 'DATABASEPREFIX'_topbar_data CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci

Of course, make a backup of your table first!

(Thanks to samhat for help on this one!)

= How do the new Include/Exclude login (in version 3.10) work behind the scenes? = 

You have four choices to handle include (or exclude) the TopBar from showing:
 Page ID - this only checks the current page's ID against the list you entered.
 Category ID - this only checks the current category IDs against the list you entered.  The criteria is satisfied if any of the page's category IDs match what you entered.  We only check the default "category" taxonomy.
 Both - both the Page ID and Category criteria must match for the TopBar to show
 Either - either the Page ID or Category criteria need to match for the TopBar to show
 
The default is to check by PageId.


= How do the new cookies (in version 3.04) work behind the scenes? = 

If you allow the user to close the TopBar, then the plugin checks to see if you have enabled cookies.   If they are not enabled, it deletes any existing cookies.   If they are enabled, it looks to see if a cookie has been created.  A cookie is only created if the TopBar has been previously closed by the user.  If it finds a cookie, it prevents the TopBar from showing.

If you change the Cookie Value to something new, the TopBar will show up again.  This is useful if you want to force the TopBar to show on new content.  Make sure to select something you haven't used before.  A good idea is to increment the value by one every time you want to force the TopBar to show.

With Version 4.00+, all TopBars must share the same cookie settings for this to work. You can set the TopBars to be the same by using the new Close Button tab on the main page

= How does the Priority field (in version 4.00+) work? =

The Plugin randomly selects a valid TopBar to show using this field to skew how they are selected. The TopBar multiplies a random number (between 0 and 1) with the TopBar's Priority value (which is a number between 1 to 100). A higher number means this TopBar will be selected more frequently; a lower number means less frequently. 

= How so I delete a TopBar? =

On the All Tables view, select the TopBars via the Check Box and selete the "Delete" function from the Bulk Actions drop down list.

= How are TopBars selected to show? =

See the Priority question above to see how they are selected. The TopBar will select only those TopBars that are valid per the date/time criteria. Once a TopBar is selected to show, it then goes through the Control Options. That checks to see if the TopBar should be shown on the Home Page (or not) and which Page IDs or Category IDs the TopBar should show (or not).

The Final check is to see if the TopBar has cookie controls (see above). If the user is allowed to close the TopBar and cookies are enabled, then we look for a cookie. If one is found, and it matches the cookie value, then the TopBar is not shown.

= What CSS ID's are available? =

Use "#topbar"

= What if I fix the TopBar to the top or bottom of the page? = 

Use this CSS to fix the TopBar to the bottom of the page: 
	position:fixed; bottom: 0; padding: 0; margin: 0; width: 100%; z-index: 99999;

Or this to fix the TopBar to the top of the page (adjust the top value to be the height of your TopBar):
	position:fixed; top: 40; padding:0; margin:0; width: 100%; z-index: 99999;

Note that by putting your TopBar in a Fixed Position, you will overlay the content of your website by the TopBar.

= How to Find the Page ID = 

You can find the Page ID in the Edit Post or Edit Page URL. For example, the page ID for the following example is “1234.”

http://example.WordPress.com/wp-admin/page.php?action=edit&post=1234

= How do I test the TopBar? = 

To test the TopBar on your site, you can set the Page IDs (in Main Options) to a single page (and not your home page) and select Include/Exclude Logic to be "Page IDs". Then go to that Page to see how the TopBar is working.

= Why does my TopBar look odd on Internet Explorer? = 

IE does not (yet) implement gradients like other browsers.  So, make sure you test your TopBar on all the major browswers.

= How dow I uninstall? = 

Go to the Uninstall tab and then click the Uninstall button at the bottom of the page.
You'll be sent to the WordPress Plugins page. Now deactivate and uninstall the Plugin

== Upgrade Notice ==


= 5.04 = 

Added option to only show the TopBar on the Home Page.  Fixes a few defects.

= 5.03 = 

Version 5.03 adds option to start the TopBar in the closed position and fixed minor bugs

= 5.02 = 

Version 5.02 adds Sample ToolBars tab, adds Scoll Amount field and fixes minor bugs

= 5.01 = 

Version 5.01 supports WordPress 3.5.2 and fixes minor bugs

= 5.0 = 

Version 5.0 adds ability to reopen a TopBar, fixes a couple of defects and enhances how custom PHP is supported.  Changed TopBar to use a DIV container instead of a P container. Double check how your TopBars now render after upgrading.  Added six more Social Buttons.  See Changelog for all updates.

= 4.17 = 

Version 4.17 adds a new Scrolling option, has some defect fixes and JavaScript updates

= 4.16 = 

Minor fix to SQL/CSV Export function

= 4.15 = 

Now can add custom PHP to the TopBar.  Also now has the ability to select TopBars based on whether the user is logged in

= 4.14 = 

Fixed issue where sometimes the html link would sometimes not display correctly

= 4.13 = 

Changed to use WordPress' embedded jQuery UI & new Color Picker (on WP 3.5+), cleaned up CSS Options Page and other fixes

= 4.12 = 

Fixed issues that sometimes causes the plugin to not activate correctly

= 4.11 = 

Version 4.11 supports WordPress 3.5.1, updates jQuery UI to latest version, and fixes minor bugs

= 4.10 = 

Version 4.10 supports WordPress 3.5, fixes several defects, and now supports caching

= 4.03 = 

Version 4.03 supports WordPress 3.4.2, adds security features, and fixes a few bugs.

= 4.02 = 

Version 4.02 adds warning to update settings after upgrade and fixes a defect

= 4.01 = 

Version 4.01 add explicit support for the qtranslate plugin and a tab to bulk change all Close Button settings

= 4.00 = 

Version 4.00 Converted to using database to store MULTIPLE (yahoo!) TopBars.  Refactored to be leaner, faster, and smarter.  Your old TopBar will be imported into the new database.

= 3.10 = 

Version 3.10 supports WordPress 3.4 and adds the capability to restrict the TopBar from showing by category.   You can also explicitly manage how it shows up on the Home Page.   Moved Control logic to its own options page.

= 3.09 = 

Version 3.09 fixed for use with multisite (network) and added submenus to the Admin bar.

= 3.08 = 

Version 3.08 changes how special characters are handles in the user defined CSS/text fields.

= 3.07 = 

Version 3.07 changes how the way jQuery is called to better support more installations.

= 3.06 = 

Version 3.06 adds the ability to add Social Icons to the TopBar.  

= 3.05 = 

Version 3.05 has a new admin page and fixes a few errors.  

= 3.04 = 

Version 3.04 fixes corrupts SVN files

= 3.03 = 

Version 3.03 allows users to close the TopBar

= 3.02 = 

Version 3.02 changed date/time picker to a GPL version to conform to WordPress licensing

= 3.01 = 

Fixes bug in posting pages.

= 3.00 = 

Version 3.0 adds the ability to set a start/end time for the TopBar to show.  It was re-worked to be smaller and faster.

= 2.1 = 

Version 2.1 is a minor bug fix for when the TopBar is in the footer and you are trying to exclude pages.

= 2.0 = 

More options added -- should not change how your TopBar works since the new defaults are set to be how the TopBar previously operated.

= 1.5 = 

This version provides even more control over how the TopBar is placed. Test, Test Test it carefully on your beta site before upgrading.



== Screenshots ==

1. This is how it will look on your website
2. All TopBars Screen
3. Test Priority Screen
4. Export Options Screen
5. Main Options Screen for a single TopBar


== Changelog ==


= 5.04 - 08/30/2013 =

1. ADDED:     Added option to only show the TopBar on the Home Page.  Thanks to Liltiger for the idea.
2. UPDATED:   timepicker.js and CSS updated to version 1.4 - http://trentrichardson.com/examples/timepicker/
3. FIXED:     Fixed a Social Button target defect - thanks to leslie.
3. CHANGED:   On social tab, do not display image size if PHP is not setup to allow remote URL fopens.  Thanks to ericd for discovering this.

= 5.03 - 08/01/2013 =

1. VALIDATED: Version 5.03 supports WordPress 3.6
2. ADDED:     Added code to set default values for existing TopBars (useful when adding new user defined fields)
3. ADDED:     Added Reopen Position field.  Thanks to Lisa L. for the idea.
4. FIXED:	  Fixed Custom CSS for the link defect. Thanks to carolemagouirk for finding it!

= 5.02 - 07/21/2013 =

1. FIXED:     Defect related to checking CSS of social buttons
2. FIXED:     Defects related bulk duplication of rows
3. FIXED:     CSS issue that caused the browser to jump to the top of the screen when a button was selected
4. ADDED:     New Sample TopBars
5. ADDED:     Added Scroll Amount field to fine tune the Scoll Action option.  Thanks to ellefrost for the idea.

= 5.01 - 06/22/2013 =

1. VALIDATED: Version 5.01 supports WordPress 3.5.2
2. FIXED:     Defects related to re-open button options, added more warning messages for using re-open options
3. UPDATED:   Updated FAQ to describe how to create your own menus.

= 5.0 - 06/19/2013 =

1. ADDED:     Added ability to reopen a TopBar.
2. CHANGED:   Now the TopBar uses the Bar Color even if you have an image set.  Double check how TopBars now render if you use an image!!
3. FIXED:     Change the TopBar to use a real container (div instead of p) to fix custom PHP issues. Please double check how TopBars now render.
4. CHANGED:   Updated jQuery Theme to make buttons/sliders easier to see
5. UPDATED:   Finished adding slider bars to the Main Options tab to select numbers
6. ADDED:     Added a way to suppress live preview (see FAQ for "&nopreview" option) to help find broken custom PHP
7. UPDATED:   Default TopBar uses a new sample image and "positon fixed"
8. CHANGED:   Changed CSS Option A to add "background-repeat: no-repeat;"
9. ADDED:     Added more warning messages for possible incompatible options selected by the user
10. ADDED:    Added six more Social Buttons - and the ability to place them before/after the TopBar
11. ADDED:    Added Uninstall Option
12. FIXED:    Fixed how the plugin handled conversion from pre-database versions
13. UPDATED:  Updated the FAQ with more current information
14. CHANGED:  Moved Font & Text Alignment options to the TextBar Tab
15. FIXED:    How the Close Button works to be more reliable

= 4.17 - 06/01/2013 = 

1. UPDATED:   timepicker.js updated to version 1.3 - http://trentrichardson.com/examples/timepicker/
2. FIXED:     More fixes to the SQL/CSV Export functions
3. UPDATED:	  Jazzed up the UI a bit
4. CHANGED:   Updated to JQueryUI to 1.10.3
5. ADDED:     Option to display only when user scrolls the page
6. ADDED:     Included WordPress Pointers to highlight new functionality, which can be permanently dismissed once read
7. CHANGED:   Changed the DEFAULT TopBar to not be "fixed" to the top of the page.  This will push the page down instead of overlaying it.
8. CHANGED:   Cleaned up the plugin's folder structure


= 4.16 - 05/16/2013 = 

1. FIXED:  SQL/CSV Export Function adjusted to account for new fields.


= 4.15 - 05/03/2013 = 

1. ADDED:   Added PHP options that can be added to the TopBar.  USE AT OWN RISK
2. ADDED:   Added ability to select TopBars based on whether the user is logged in
3. CHANGED: Now loads own version of JQueryUI (1.10.2) since the DatePicker was not consistently being loaded correctly


= 4.14 - 03/08/2013 = 

1. FIXED:    Fixed issue where sometimes the html link would sometimes not display correctly
2. CHANGED:  Added display of database charset/collation to help debug multi-lingual issues
3. CHANGED:  To use embedded version of jQuery DatePicker

= 4.13 - 02/9/2013 =

1. CHANGED: Changed to use WordPress' embedded jQueryUI
2. CHANGED: Updated Color Picker from farbtastic to the new WordPress 3.5 Color Picker if using WordPress 3.5+
3. UPDATED: timepicker.js updated to version 1.2 (future proof for jQueryUI 1.10 compatability) - http://trentrichardson.com/examples/timepicker/
4. CHANGED: CSS Options page changed to try to make it clearer how the various CSS options work
5. CHANGED: Removed URL check on the TopBar link so that qtranslate will process the link correctly
6. FIXED:   Minor display of error messages that check the div_css field

= 4.12 - 01/28/2013 =

1. FIXED:   Issue that sometimes causes the plugin to not activate correctly.  Finally found it by using the Bitnami WordPress Stack - http://bitnami.org/stack/WordPress
2. FIXED:   Plugin deletion messages
3. CHANGED: Removed the option to delete a TopBar from Options pages. Use the All Tables view and Delete using the Bulk Actions drop down list

= 4.11 - 01/26/2013 =

1. VALIDATED: Version 4.11 supports WordPress 3.5.1
2. UPDATED:   jQuery UI to version 1.9.2
3. FIXED:     Streamlined JavaScript when only one TopBar is selected
4. FIXED:     Logic when no TopBars are selected

= 4.10 - 12/10/2012 =

1. VALIDATED: Version 4.10 supports WordPress 3.5
2. FIXED:     Several defects found in 3.5 testing
3. NEW:       Now supports caching plugins by generating HTML for all possible TopBars and using JavaScript to randomly select a TopBar

= 4.03 - 9/10/2012 =

1. VALIDATED: Version 4.04 supports WordPress 3.4.2
2. NEW:       Adds security features (nonces) to the admin pages (Thanks to Blake Entrekin)
3. FIXED:     How the CSS for the link is rendered
4. FIXED:     Enable/disable social buttons work again

= 4.02 - 8/31/2012 =

1. NEW: Adds warning to update settings after upgrade
2. FIXED:  missing php closing tags

= 4.01 - 7/04/2012 =

1. NEW:    Adds explicit support for the qtranslate plugin
2. FIX:    No longer calls exception when the user has not set a default topbar
3. ADDED:  Tab on main page to allow you to bulk set the Close Button settings
4. FIX:    WordPress Export Functions -- workaround for core defect?

= 4.00 - 7/01/2012 = 

1. NEW: Version 4.0 Converted to using database to store MULTIPLE (yahoo!) TopBars.  Refactored to be leaner, faster, and smarter.  Your old TopBar will be imported into the new database.

= 3.10 - 6/05/2012 = 

1. VALIDATED: Version 3.10 supports WordPress 3.4
2. FIXED:     Removed PSD icons files to make plugin smaller to install
3. NEW:       Adds the capability to restrict the TopBar from showing by category
4. NEW:       You can also excplicity manage how it shows up on the Home Page
5. NEW:       Moved Page ID and new Category ID/Home Page control logic to its own options page
6. CHANGED:   The labels and descriptions on the options page for selecting the Page ID include/exclude logic. 
 
= 3.09 - 4/26/2012 = 

1. NEW:   Added submenus to the Admin bar.
2. FIXED: Code to support multisite (network) installs.

= 3.08 - 4/18/2012 = 

1. FIXED: Added more discrete handling of special characters if Magic Quotes is turned on in PHP.  So now can handle quote marks.

= 3.07 - 4/05/2012 = 

1. FIXED: Version 3.07 changes how jQuery is enqueued to better support more themes.

= 3.06 - 4/04/2012 = 

1. NEW: Version 3.06 adds the ability to add Social Icons to the TopBar.  
2. NEW: Added Debug page

= 3.05 - 3/31/2012 = 

1. FIXED: javascript error if "footer" is chosen as placement of TopBar
2. NEW:   Redesigned admin page

= 3.04 - 3/30/2012 = 

1. FIXED: Corrupt SVN files.

= 3.03 - 3/29/2012 = 

1. NEW:   Allow users to close the TopBar
2. FIXED: Moved HTML out of HEAD tags and into the BODY tags

= 3.02 - 3/22/2012 = 

1. FIXED: Changed date/time picker to a GPL version to conform to WordPress licensing

= 3.01 - 3/18/2012 = 

1. FIXED: Bug that caused WordPress post/pages not to load correctly

= 3.0 - 3/17/2012 = 

1. NEW:   Added start/end times to limit when the TopBar shows.
2. FIXED: Updated deprecated functions
3. FIXED: Tightened code and made the code smaller 
4. FIXED: Enqueues javascript, if necessary

= 2.1 - 12/30/2011 = 

1. FIXED: TopBar excludes PageIDs now work when TopBar is on footer pages.

= 2.0 - 12/26/2011 = 

1. NEW:   Added option to make the TopBar disappear after a set amount of time.
2. NEW:   Added copy buttons to copy code samples.
3. NEW:   Added option to invert the Include Pages list to make it actually exclude pages.
4. FIXED: Cleaned up code to make it tighter.

= 1.5 - 12/23/2011 = 

1. FIXED: Moved TopBar to the Body instead of the Header and fixed missing close DIV.  That MAY break your site -- test carefully.
2. NEW:   Adds additional Link option (target) which allows you to change how the link opens.
3. NEW:   Added option to put TopBar at the footer. (Thanks, candace88, for the idea!)
4. NEW:   Added and new DIV-level CSS. 

= 1.4 - 12/10/2011 = 

1. NEW:       Added options to change the margin of the TopBar.
2. FIXED:     Cleaned up the code.
3. VALIDATED: Version 1.4 supports WordPress 3.3

= 1.3 - 12/05/2011 = 

1. NEW: Added easier navigation buttons.  Added more space to the CSS section.
2. NEW: Added code to allow you to use quotes in your text.
3. NEW: Added id="topbar" to the output.

= 1.2.1 - 10/08/2011 =

1. FIXED: Minor fix to allow settings page to display correctly.

= 1.2 - 10/08/2011 =

1. NEW: Add image background, custom css, and text alignment.

= 1.1 - 10/07/2011 =

1. FIXED: Cleaned up the code to make the TopBar be invisible upon first load.

= 1.0 - 9/25/2011 =

Initial version

