Nice Quotes Rotator

Description

This plugin provides the ability to have randomly selected quotes displayed on the admin page, by using a shortcode or by using a sidebar widget. The quotes include user-entered quotes, and can optionally include excerpts from a user-chosen category and can also optionally include links from a user-chosen links category There also is an option for including the lyrics from "Hello Dolly". The plugin can be used for random quotes, rotating testimonials, rotating random affiliate links, or random featured posts. It was inspired by the Hello Dolly plugin (hello.php) that comes bundled with WordPress.

Installation

Installation is simple and straight-forward:

  1. Unzip nice-quotes.zip into to the /wp-content/plugins/ directory.
  2. Activate the plugin through the 'Plugins' menu in WordPress.
  3. Configure the plugin options under the 'Plugins->Nice Quotes Options' menu in WordPress. Don't forget to Save Changes!

Frequently Asked Questions

I have set the category on the option page but no posts are ever quoted.

Make sure at least one of those posts in that category has an excerpt defined.

What is the ratio of quotes, links and excerpts?

The ratio is split evenly between the types of quotes enabled to be displayed. To determine the probability of a quote type (links, excerpts, and custom quotes) being displayed count the number of types enabled. The probability is one in however many types are being displayed.

For example, if you have links, excerpts and quotes all enabled then the chances of getting an excerpt is 1 in 3, the chance of getting a quote is 1 in 3 and the chance of getting a quote is 1 in 3.

Can the plugin be used to list only a random excerpt from a category?

Yes it can, just don't set any custom quotes or check the option to include Hello Dolly lyrics.

Can the plugin be used to list only a random link from a link-category (like Blogroll for example)

Yes it can, just don't set any custom quotes or check the option to include Hello Dolly lyrics.

Can HTML be used in custom quotes?

Yes, it can. Using a break tag (<br />) is recommended for multi-line quotes.

Can smilies or shortcodes be used in custom quotes?

Yes they can. Smilies are only included if they are enabled under Settings->Writing.

How can the quotes be styled?

Quotes have a class of 'niceQuote' set on them. To style them add to your stylesheet:

.niceQuote {
// css properties here;
}

How can the quotes be used on a post or page?

Just use [nicequote] as a shortcode and a randomly chosen quote will be displayed on the page. The quote is randomly chosen each time the post or page is loaded.

Are the quotes random?

Yes they are. Each time the quote is loaded (whether on the admin page, a sidebar widget or via shortcode) the quote will be random with the ratios listed above.

Can other plugins add quotes to be be displayed? I'd like to create a package of quotes.

Yes! See pluggable_example.php for sample code to get started. In order for these quotes to be displayed, it is necessary to check the option to allow plugins to add quotes.

Why is there an option to include Hello Dolly lyrics?

The inspiration for this plugin comes from the Hello Dolly plugin (hello.php) bundled with Wordpress. I wanted to have the option to have user-defined custom quotes and to have those quotes appear on the Wordpress front-end. I also wanted to optionally highlight a featured post or be able to show an affiliated link.

Screenshots

Nice Quotes Rotator Screenshot 1
This is the options screen showing the settings available with Nice Quotes Rotator.

Nice Quotes Rotator Screenshot 2
This is the Nice Quotes settings added to the Widgets menu.

Changelog

0.1

  • Initial public release.

0.2

  • fixed the shortcode to match the documentation (now [nicequote] works).

0.3

  • Added two attributes to the shortcode. tagoverride which overrides whichever option is set in the options page for which HTML tag to use. This is useful for changing the tag when something should be inline or block. additionalclasses is used for adding additional CSS classes to the nicequote. See This page for a listing of built-in WordPress classes, for reference.

0.4

  • Fixed an error caused in the last update.

0.5

  • Fixed an error caused in the last update of a missing argument to one of the functions.

1.0

  • Removed any quotes that consist solely of whitespace. Fixed an error when rotating Hello Dolly quotes with no custom quotes, causing a black quote to appear. Added support for plugin developers to inject their own quotes.

Demo

Here is a demo of quotes in an unordered list. Refreshing the page will randomize the quotes.

  • That’s right, you’re in scary regent prison where you belong. – Myka (Warehouse 13)
  • Demons run but count the cost
    the battle’s won
    but the child is lost.
  • Dolly’ll never go away
  • Steel is my body and fire is my blood
  • The high pressure holds the grab bag and looks a lot like milk. I think of apples!
  • I don’t find your sarcasm believable.
    Lance – (Voltron Force)

Licensing

The Nice Quotes Rotator free WordPress plugin is licensed under the GNU Public License v2.0 (GPL2). You are free to use and modify the plugin as you see fit.

Donate

Coders love caffeine — and I’m no exception ;)

If you like my free plugins, feel free to donate. Doing so allows me to continue work on this and other great WordPress plugins, themes, etc.



36 thoughts on “Nice Quotes Rotator

  1. The documentation tells us that the shortcode to use is “[nicequote]” but it seems that it actually needs to be “[nice-quote]“

    Thanks for the plugin!

    • Eric,

      I appreciate the comment and have updated the code to a newer version that can use [nicequote] as noted in the documentation.

      I also replied to your Thread on the WordPress forum.

      Thanks again for the bug report, and comment.

    • Can the shortcode [nicequote] work in a text widget? Anyplace you can use a shortcode you can use the [nicequote] shortcode. Are you trying to use it in the default text widget that comes with WordPress or something else?

      The default text widget (found in wp-includes/default-widgets.php) that comes with WordPress is run through the ‘widget_text’ filter.

    • PS. I was looking again through the docs for the do_shortcode function and it suggests:

      // Use shortcodes in text widgets. add_filter('widget_text', 'do_shortcode');

      You can use the code from the docs if it is a time-sensitive thing; I have started working on a new plugin to enable shortcode parsing in text widgets along with converting smilies. It will be available as soon as I have the documents (readme files etc) written up and get the svn directory from WordPress.org.

    • Javi, I created a plugin to allow shortcodes and smilies in the Default text widget called ‘Allow Shortcodes in Text Widgets’. You can either download it from this website or download it from the WordPress.org plugin repository.

    • Björn, I don’t have any plans currently to add a template function, but you can call use either the convert_shortcode function or use the return_nice_quotes function.

      There are several ways you can include the quote-rotator in php.

      Firstly, WordPress has a function that converts all shortcodes to the output from the shortcode’s handler(s):

      echo do_shortcode('[nicequote]');

      You can also pass the attributes in the shortcode:

      echo do_shortcode("[nicequote tagoverride='q']");

      Second, you can call the function return_nice_quotes used to create the shortcode in php. You may want to use to call it in a if function_exists( ) condition so that if you ever decide to disable the plugin, it won’t bring down your site by attempting to call a non-existent function.

      if (function_exists('return_nice_quotes')) { echo return_nice_quotes(); }

      Thirdly, you can do the same as above but pass in the same arguments that you could with the nicequote shortcode:

      if (function_exists('return_nice_quotes')) { echo return_nice_quotes(array( 'tagoverride' => 'q', 'additionalclasses' => 'headerQuote', ) ); }
    • I just re-read you question, if you are trying to get a quote to appear and are not trying to have a HTML object you can call the nice_quotes_get_quote function.

      if (function_exists(‘nice_quotes_get_quote’)) { echo nice_quotes_get_quote(); }
  2. About php code in the theme fiels. I put echo do_shortcode(‘[nicequote]‘); or if (function_exists(‘return_nice_quotes’)) { echo return_nice_quotes(); } into the theme. they just show these words, not the nice quotes.

    • Hunter, You need to pass the code through the PHP interpreter, by wrapping the code in <?php and ?>.

      If what you are trying to do is the same as what Björn is trying to do by putting it in a <title> tag:

      <?php if (function_exists(‘nice_quotes_get_quote’)) { echo nice_quotes_get_quote(); } ?>
  3. Great plugin! Although even having quite a lot of quotes to display, some times it doesn’t display anything, just an empty ‘widget’ box.

    Any ideas or suggestions?

    Thanks!

    • Modcorrupt, the most obvious thing that comes to mind is to check and make sure that you don’t have an empty line in your custom quotes.

      Also, if you have the option for for post excerpts to be included from a category, make sure none of the excerpts have a non-breakable space in them. When you view the source of the page what do you get?

      It is possible that it may be a SQL problem or that I missed something.

      • No empty lines, but this is how I have it in the options:

        “Experience hath shewn, that even under the best forms of government those entrusted with power have, in time, and by slow operations, perverted it into tyranny.” – Thomas Jefferson

        “For a people who are free, and who mean to remain so, a well-organized and armed militia is their best security.” – Thomas Jefferson

        Etc. Shall I take out the breaks and just have an empty line between quotes? Or is this okay?

        Thanks!

        • Sorry, the break tag didn’t show up between the quotes on this page. So I have between them. Hopefully this one shows up.

          Anyhow, I have the break tag in between all the quotes.

          • Ok, never mind. My bad. I took out all the breaks and it’s working perfectly now. Had a ‘brainfart’ moment there and didn’t quite get it. It was pretty late at night when I installed it and started adding quotes. Heh.

            Cheers & Thanks again. Great plugin!

          • Modcorrupt, I am glad you got it working.

            For reference, the plugin calls the explode function in PHP to populate the array on the newline (/n) character. Each carriage return should be a new quote.

  4. It appears that the .niceQuote functionality does not work style the results of the Widget? Is there anyway to style the output of the widget?

    Thanks

    • Which functionality isn’t working?

      The niceQuote has a style attribute of niceQuote; To style all niceQuotes, you could use:

      .niceQuote { // css stuff here. }

      To do only the stuff in the sidebar use, most blogs would use:

      #sidebar .niceQuote { // css stuff here. }

      Keep in mind that inline level elements and block level elements behave differently.

      Changing the way quotes are nested in the widgets is now on my list of things to do. The widget will probably take a space-delineated list of tags, instead of the ordered-lists.

  5. Hi.

    I am trying to get this working on my site. I have it in the sidebar, and I can get it to display the quotes directly added to the settings page. But I cant get it to show the quotes from a posts category even though I have “A random post excerpt” selected in the what to show, and my category selected in the “Excerpts from the following category…”

    Any idea what I have missed or why its not working?

    I am using WordPress 3.0.1.

  6. I have a random quote show up, but sometimes, it doesn’t show anything. I refresh and eventually it will show a quote. And there is no rotation at all. What do I need to do to get the rotation?

  7. Okay, I figured out why I was getting the blank quotes, but still can’t get it to rotate. Help would be appreciated.

  8. Hi, just wondering if you have an update regarding Matt’s comment about styles when used in a widget on sidebar? I can’t seem to get my css working. I now see that the quotes take on the order list style. So my issue is that I want my ordered lists to be indented 20px, however I do not want my quotes to be indented at all.

    Can you assist? I’m getting frustrated with figuring out the CSS.

    THANKS!

    • The widget should have a class of widget_nqwidget. If you want to only change the lists in the nice-quote widgets you would have a rule similar to:

      .widget_nqwidget ul { margin:0px; }

      If you are using Firefox, Firebug and Web Developer toolbar work wonders and are very useful. I’m sure other browsers have other tools that may be similar.

    • Do you mean the time-zone or time-format?

      The Nice Quotes Rotator doesn’t do anything when you update that page.

      Does the time update when the plugin is disabled? I suspect that it is some other plugin or some other problem.

    • You can use the nice_quotes_get_quote function to return a random quote as a string. You should probably check to see if the function exists in the off chance that your code still exists but the plugin is deactivated.

    • Not too sure what you mean by ‘dissolves’.

      This plugin doesn’t do anything but output a quote in the shortcode. It does not do anything to cause them to fade out.

  9. I installed the plugin and activated it. I added content to the quotes box and added the shortcode to my page.

    I would like an unordered list like you have in your demo above, but mine is only showing one item at a time.

    Can you please let me how to get it to list all of the “quotes” in an unordered list like your demo above?

    Thank you Cindy

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>