Quotation Plugin

I have written a plugin for Wordpress that allows you to display a random quote-of-the-day on your site. There does already appear to be a few quote-like plugins available but they all required you to manually create or add the quotations yourself. My plugin has a clear advantage in that it is self-contained. It pulls quotes from an RSS feed supplied by quotationspage.com.

In my opinion, the standards of quotes you get from this site are of a very high quality. Sometimes funny, sometimes political, sometimes philosophical but always witty! The plugin, once installed will select quotes at random from a possible twelve, which are updated once every twenty-four hours.

You can see the plugin in action at the top of this page on the sidebar on the homepage. It is my first ever Wordpress plugin and is still in a beta stage. The source code is heavily commented, but I am happy to answer any questions on it.

The latest version is version 0.7.3
Download now.

Installation

  1. Put the qqotd.php file into your wp-content/plugins directory.
  2. Activate the plugin on the plugin screen.
  3. Insert <?php do_qquotes(); ?> in your templates (header.php is recommended).

Known Bugs

  1. The URL to the RSS feed could at some point change and unless the old URL points to the new, quotes will not be found
  2. Adverts ending in anything other than a full stop, are not eliminated. Fixed!(01/09/05 20:23:54)
  3. The advert remove function is also removing the initial " surrounding the quote itself.Fixed (06/02/06)
  4. Versions of php where allow_call_time_pass_reference was set to false cause warnings. Fixed (27/12/06)

21 Responses to “Quotation Plugin”


  1. as you can se on the “randomness” page (sidebar at at the bottom) on http://notsokosher.net

    fwrite() and fclose() don’t seem to be working. any ideas?

  2. Official
  3. Are you referring to the error:

    CG-Feedread failed to save feed to disk — couldn't write to the cache_feedread directory.

    The fwrite and fclose must be working to some extend as you seem to have some sort of qquotes on your page. But I am not sure where the qquotes plugin is? Is it the one under “Not So Kosherific” (on the randomness page)?

    Can you have a look on your web server and see if a directory called qquotes has been created in wp-content/plugins/. Did you modify the script at all?

  4. sorry about that, i took it off because it was creating a lot of garble-d-gook on the randomness page. the CG-feedread is from the rss feed, gotta figure that one out as well.

    I’ll make a new page called quotes with just that command in it, and you can see waht im talking about. i think it might have something to do with the writing privilages of that directory, but since i don’t own the server, it might be fairly difficult for me to configure it.

  5. ok - now im just getting “qquote failed to write” 12 times then “qquote failed to read”

    quite certain it is the privilages thing.

    oh, and the other quotes use either sql or a pre formatted text db to store the quotes, or just dynamicaly post them from and rss feed. neither of them actually need to write something. hence why i didn’t get this error before.

  6. Official
  7. If you have ftp/ssh access to your server could you have a look and see if a directory called qquotes has been created in wp-content/plugins/. If it has are there any files in it/are they empty?

  8. nay, it is empty. i created it for the program - the only reason why it is there. i am quite certain it has something to do with read/write privilages.

  9. well, ’tis been quite a while, I know, but I did finally fix the problem. It did have to do with writing privs. I thought I had set qquotes to 777, but apparently doing things through FTP isn’t quite enough, I had to do it through SSH. Silly linux and their rules.

    Now that it finally works, Cheers! Some wonderfuly hilarious sayings you got there.

  10. Hi,

    trying your plugin I get
    failed to open stream: No route to host in /usr/local/data/php/bb-blog/wp-content/plugins/qqotd.php on line 186

    is it possible to tell your plugin about a proxy ?
    I guess it is because of the firewall ?

  11. found your quotation pluginn after much searching for something like this, and it is perfect, works just like it should.
    thanks so much.

  12. Official
  13. Nowotny, Im not convinced it is a proxy problem. Can you get onto your webserver and try the following:
    cd /usr/local/data/php/bb-blog/wp-content/plugins/
    ls -l qquotes

    And tell me what happens?

  14. i am using the plugin, it’s great, but i just noticed that there are only quotation marks (”) being written at the end of the quote.
    Is this the source (quotationspage.com) or is this controlled by your plugin script?
    I would either have q-marks start and finish, or none at all.
    is there an easy fix…?
    thanks

  15. Official
  16. Hi eric, I’ve just been on your site and I see what you mean. It confuses me though as this should not be the case. You sure you have the latest version? You will see that my qquotes have ” at the start and finish. Maybe you got a bad batch of quotes. My advice, wait for the next set to be loaded and see if the problem goes. Keep me posted!

  17. i’ve downloaded and am using the version labelled 0.7.1, the php file is labelled 0.7
    I had saved a batch of 12 qquotd text files from an earlier time and they are set up with “-marks at each end, so it might be just a “bad batch”, as you say, this time.
    I will watch and see how the next ones work.
    By the way, thanks for turning me onto the “simpleviewer” image gallery app as well, (after poking around on your site a bit), it’s a nice setup.

  18. Official
  19. Sorry eric, I checked things a bit more thoroughly and it appears I was myself using a different version than the one available for download. Please download the new zip file and replace the PHP file to fix this problem. You will need to wait for the next time the quotes are updated to see the change take effect.

  20. using the new version and clearing up some other problems that might have been related seems to have solved the problem.
    very good & thanks

  21. i have used the new version and fixed up some other stuff that may have been related and all is good now.
    many thanks

  22. michellemb says:

    I’ve been trying to use your plugin… but this keeps coming up every time I activate it:

    Warning: fopen(): URL file-access is disabled in the server configuration in /home/.data/user/website/wp-content/plugins/qqotd.php on line 186

    Any idea what I need to do? Thanks

  23. Official
  24. Hi michellemb! This could be quite a tricky one. Your hosting company has disabled scripts on your site from accessing external URLs, in this case the quotationpage.com. Who is your web hosting company? Could you ask them why they have PHP setup in this way as it’s quite unusual for them to have done this.

  25. Thanks for the plugin - much bet than get-a-quote that I have used in the past.

    Try widgtize-anything, I have widgetified the theme I chose and this plugin works really well with yours.

    Cheers!

  26. Got this fun error upon activating plugin…

    Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of xml_set_object(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in /home/.bauzeur/salesmotiv8/salesmotivation.net/wp-content/plugins/qqotd.php on line 182

  27. Official
  28. My web host had
    allow_call_time_pass_reference
    set to true already so I never noticed this. I have changed the call to xml_set_object() to now be pass by value and tested it under php 4.4.4.

    If you re-download the zip file (0.7.3), you should find this error to now be resolved.