WordPress.org

Ready to get started?Download WordPress

Plugin Directory

Spanish Quote of the Day

Spanish Quote of the Day gives you a random notable quote in spanish from todopensamientos.com's database.

Spanish Quote of the Day automatically shows a random formatted notable quote in spanish inside your wordpress themes. The spanish quote is collectted by random from todopensamientos.com's database therefore it's not necessary that you have your own database of quotes; Spanish Quote of the Day gives them to you. Simple put the widget Spanish Quote of the Day in any of your theme sidebars; its operation is automatic.

This plugin has a triple functionality:

The Widget Spanish Quote of the Day creates a widget called "Spanish Quotes of the Day" -or the translated version of this name- that you can include in any of your theme sidebars. Automatically, your theme will show a notable random quote in spanish, plus the author name, the original author's archive page and a link to the source.

The Shortcode Spanish Quote of the Day creates the shortcode [spanish_quote] that allows you to add a notable random quote in spanish inside the content of your posts, pages or even custom post types.

Filters, quotes's length, output format control Spanish Quote of the Day works via filtered outputs so it's possible to decide one output format for the widget use, and another one for the shortcode use; even you can modify the output format depending on the post number, post content, categories, etc.

In addition, from version 1.2.2+, you can even decide the maximum length of the quotes you want to receive. In former versions of the plugin, the maximum length was permanently set to 275 characters but now, you can choose to receive longer o shorter quotes through the plugins's settings page.

The standard output format

After installation and activation, the quote standard output format to screen is this:

    <div id="cool-quote">
    <span class="quote-text"> quote </span>
    ' - '
    <span class="quote-author-link"> anchor to author's archive page ( with the author_name text ) </span>
    <span class="quote-credits"> anchor to quote's website source ( with the provider_name text ) </span>
    </div>

In a basic installation, as default, both of widget and shorcode outputs are formatted via the same function that convert the object response and adds a minimun styling via these four simple classes: .cool-quote, .quote-text, .quote-author-link, .quote-credits.

Styling

And this is the minimum styles to format the output

    /* Spanish Quotes mínimun styles */
    #cool-quote { display:block; margin: 1em 0; }
    .quote-author-link a {font-style:italic }
    .quote-credits { display:block; font-variant:small-caps; font-weight: bold; font-size: 0.9em }

It's a very simple styling, I know it, but it's to improve an ease integration of Spanish Quote of the Day with your theme styles without coding.

Of course, you are allow to modify the format of the output via CSS. Just, edit directly the spanish-quotes.css file in the plugin's directory to modify the standard styles.

Filtering

Spanish Quote of the Day has three filters, one for the widget outputs called widget_quotes, one for the shortcode outputs called post_outputs and finally, one third filter for the raw object oembed response output from the oembed call called raw_quotes.

All of three filters has the same structure:

    apply_filters( 'namefilter', $content, $post );

so they allow you to control completely the output format of the different uses -widget or shortcode- and, additionally, they also allow you to modify this output format according to the current post, his content, the post categories, etc.

For example, if you want to modify the output for the default posts template and always include a <blockquote></blockquote> structure you can add this code at the begining of your single.php file:

    <?php
    function add_blockquote ( $response, $post ) {

        $out      = '<blockquote>';
        $out     .= $response;
        $out     .= '</blockquote>';
        return $out;
    }
    add_filter ( 'post_quotes', 'add_blockquote', 10, 2 ); 
    ?>

Another example could be to change the format only for pages and leaving the standard output for the rest. This this case, you should include a code like this next example in your functions.php file:

    <?php
    function only_in_pages ( $response, $post ) {

        if ( $post->post_type != 'page' ) return $response;

        $out      = '<div style="display:block; float:right;">';
        $out     .= $response;
        $out     .= '</div>';
        return $out;

    }
    add_filter ( 'post_quotes', 'only_in_pages', 10, 2 ); 
    ?>

These are two basic example that simply work after the basic filters and add some html code however, if you need a more accurate control of the output, you can even disconnect the default filters, in that way,

    remove_filter ( 'post_quotes', array ('spn_quotes', 'cook_quotes'), 10 );

It's possible but then, remeber that the other two filters are directly receiving an oembed object response and you have to deal to his individual properties (see The Oembed Call section below for more information).

For example, if in the shortcode use you want to change a) the order of the elements of the output, b) add some text and c) change completely the styling classes, you could use a source like this:

    <?php
    // removing the default filter
    remove_filter ( 'post_quotes', array ('spn_quotes', 'cook_quotes'), 10 );

    function reorder_quote ( $response, $post ) {

        // after removing the default filter, now $response is not a string, is an object 
        // See The Oembed Call section below for more information of the oembed object $response

        // changing classes 
        $out     = '<div id="my-quote-style">';

        // first, the author
        $out    .= 'This quote belong to : ';
        $out    .= '<span class="my-quote-author-link"><a href="' . $response->author_url . '" title="' . __( 'Notable quotes of', 'spanish-quotes-of-the-day' ) . ' ' . $response->author_name . ' | ' . $response->provider_name . '" target="_blank" >' . $response->author_name . '</a></span>';

        // then, the quote
        $out    .= 'The quote: '; 
        $out    .= '<span class="my-quote-text">'. $response->html . '</span>';

        // and finally, the provider
        $out    .= 'The quote\'s source: ';
        $out    .= ' <span class="my-quote-credits"><a href="' . $response->provider_url . '" target="_blank" title="' . __( 'Theme classified notable quotes in spanish', 'spanish-quotes-of-the-day' ) . ' | ' . $response->provider_name . '">'. __('Notable Quotes in Spanish', 'spanish-quotes-of-the-day') . '</a></span>';

        $out    .= '</div><!-- end #my-quote-style -->';

        return $out;

    }
    add_filter ( 'post_quotes', 'reorder_quote', 10, 2 ); 
    ?>

The Oembed Call

Spanish Quote of the Day works via an unique oembed call (see http://http://www.oembed.com/ for further information) to the quotes database of http://todopensamientos.com so the plugin it's fast, secure, simple and... automatic.

The oembed call to http://todopensamientos.com/oembed/ address returns a HTTP response that the plugin transforms for extracting the standard oembed response object :

    (object) $response  {
        "version":"1.0",
        "type":"rich",
        "html": the quote contents,
        "url":  exact URL's quote, 
        "provider_name": "TodoPensamientos",
        "provider_url":  URL's provider,
        "author_name": Author name,
        "author_url": exact URL's author name archive of quotes,
    }

and creates the first output that's given to you via the first filter raw_quotes. If you need a sophisticated control of the oembed object $response, you cau use directly this last filter (it's possible, but not recommended in any case).

Then, the plugin processes the object response and gives you the processed output to screen converting the object into an HTML string. This output is served for widget use and shortcode use via the widget_quotes filter and post_quotes filter, respectively.

Translations

The english version of the shortcode [spanish_quote] is always available but depending on the language of your WP installation you have also a translated version of the shortcode. See the plugin's initial activation message for further information. For example, in a Spanish WP installation, the additional translated shorcode name is [frase_del_dia].

Quotes Lenght Control

From version 1.2.2+, we have added a new query var inside the oembed call that allows you to decide the maximun length for the quotes that you want to receive from http:://todopensamientos.com database. In former versions, the maximum length was a constant (275 characters), now this parameter is var so, you can modify it through the plugin's settings page. We usually suggest a maximum length below 300 characters but, now, you decide...

Asynchronous Mode

From version 1.2.0 and greater, we add the asynchronous fetching operation mode to connect and collect the quotes. To activate the Asynchronous mode simply go to the Settings > Spanish Quotes and check the field: Asynchronous Mode.

The asynchoroous fetching operation mode improves the load page time in the server side because it moves the process of fetching the quote to the client side. That's fantastic, but remember that this could be incompatible with some client systems and, in addition it's a much less stable process so, we advise do not activate the asynchronous mode unless your website truly has a high volumen of hits by day. By default, the asynchronous mode is disabled.

In the asynchronous mode the filter raw_quotes are not available.

Credits output

In each quote, by default I include a credit link to the todopensamientos.com's database, the true source of these quotes. It's my little contribution to this project. Of course, you are allow to modify the standard output and avoid the credits link... but I invite you to don't suppressed it. Every day, they are doing a fantastic work collecting, verifying, arranging, classifying and checking the correct source of all their quotes, so, let them to live; credit them.

Special Needs or Requests

If you have an special need, suggestion or request, for example, you'd prefer to choose a specific category of quotes, or the minimum or maximun length allowed for the quotes (nowadays, all quotes have a maximun length of 275 characters), or your preferred authors, etc., please, don't hesitate to contact with http://todopensamientos.com via the plugin's author email in the address jmviade@gmail.com.

Requires: 3.0 or higher
Compatible up to: 3.9.1
Last Updated: 2014-7-7
Downloads: 129

Ratings

5 stars
5 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1
100,1,1
100,1,1
100,2,2