Plugin Directory

Changeset 1856096


Ignore:
Timestamp:
04/11/2018 12:23:46 AM (8 years ago)
Author:
jfcby
Message:

Update to current version of WordPress

Location:
randomquotr/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • randomquotr/trunk/RandomQuotr.php

    r77590 r1856096  
    11<?php
    22/*
    3     Plugin Name: RandomQuotr
    4     Plugin URI: http://www.wallofscribbles.com/wordpress-plugins/randomquoter
    5     Description: Based on the Hello Dolly plugin concept. RandomQuotr allows the user to create their own list of quotes, and then use the hooks available to display either a random or a specific quote.
    6     Version: 1.0
    7     Author: Corey Dutson
    8     Author URI: http://www.wallofscribbles.com
     3Plugin Name: RandomQuotr
     4Plugin URI: https://wordpress.org/plugins/randomquotr/
     5Description: RandomQuotr allows the user to create their own list of quotes and then use the hooks or shortcodes available to display either a random or a specific quote.
     6Version: 1.0.2
     7Author: jfcby
     8Author URI: http://www.corematrixgrid.com
     9License: GPL2
     10License URI: https://www.gnu.org/licenses/gpl-2.0.html
     11Last Updated: 4/10/2018 - jfcby
     12Text Domain: randomquotr
    913*/
    1014
    11 /*  Copyright 2008  Corey Dutson  (email : cdutson@wallofscribbles.com)
    12 
    13     This program is free software; you can redistribute it and/or modify
    14     it under the terms of the GNU General Public License as published by
    15     the Free Software Foundation; either version 2 of the License, or
    16     (at your option) any later version.
    17 
    18     This program is distributed in the hope that it will be useful,
    19     but WITHOUT ANY WARRANTY; without even the implied warranty of
    20     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    21     GNU General Public License for more details.
    22 
    23     You should have received a copy of the GNU General Public License
    24     along with this program; if not, write to the Free Software
    25     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    26 */
    27 
    28 add_action('admin_menu', 'randomQuotr_menu');
    29 
    30 function randomQuotr_menu() {
    31   add_options_page('RandomQuotr Options', 'RandomQuotr', 8, __FILE__, 'randomQuotr_adminPage');
     15/** If this file is called directly, abort. */
     16if ( !defined( 'ABSPATH' ) ) {
     17    die;
    3218}
    3319
    34 function randomQuotr_adminPage() {
     20add_action('admin_menu', 'randomquotr_menu');
     21
     22function randomquotr_menu() {
     23  add_options_page('RandomQuotr Options', 'RandomQuotr', 8, __FILE__, 'randomquotr_adminPage');
     24}
     25
     26function randomquotr_adminPage() {
    3527?>
    3628  <div class='wrap'>
     
    4335                <td style="vertical-align:top">
    4436                    <h3>Quotes</h3>
    45                     <textarea rows="20" cols="60" name='randomQuotr_quotes' id='randomQuotr_quotes'><?php echo get_option('randomQuotr_quotes'); ?></textarea>
     37                    <textarea rows="20" cols="60" name='randomquotr_quotes' id='randomquotr_quotes'><?php echo get_option('randomquotr_quotes'); ?></textarea>
    4638                </td>
    4739                <td style="vertical-align:top">
    4840                    <h3>Explanation</h3>
    4941                    <p>Each line is a random quote. Don't worry if your line wraps onto the next one, it will still count as one line. Carriage returns (the Enter key) break up the quotes.</p>
    50                     <p><strong>To get a random quote use the following hook:</strong><p>
    51                     <p><em>&lt;?php random_quote() ?&gt;</em></p>
    52                     <p>You can also use <em>&lt;?php $quote = get_random_quote(); ?&gt;</em></p>
     42                    <h4>Hooks</h4>
     43                    <p><strong>To get a random quote use the following hook:</strong><p>
     44                    <p><em>&lt;?php rdqr_random_quote() ?&gt;</em></p>
     45                    <p>You can also use <em>&lt;?php $quote = rdqr_get_random_quote(); ?&gt;</em></p>
    5346                    <p><strong>To get a specific quote use the following hook:</strong><p>
    54                     <p><em>&lt;?php target_quote($quoteNumber) ?&gt;</em> where $quoteNumber is the quote line.</p>
    55                     <p>You can also use <em>&lt;?php $quote = get_target_quote($quoteNumber); ?&gt;</em></p>
    56                     <p><em>e.g. target_quote(3) will return the 3rd quote.</em></p>
    57                     <p><strong>Note: target_quote will return null when:</strong>
     47                    <p><em>&lt;?php rdqr_target_quote($quoteNumber) ?&gt;</em> where $quoteNumber is the quote line.</p>
     48                    <p>You can also use <em>&lt;?php $quote = rdqr_get_target_quote($quoteNumber); ?&gt;</em></p>
     49                    <p><em>e.g. rdqr_target_quote(3) will return the 3rd quote.</em></p>
     50                    <p><strong>Note: rdqr_target_quote will return null when:</strong>
    5851                    <ul>
    5952                    <li>There are no quotes available.</li>
     
    6255                        <li>A non-numeric value is passed: "twenty". Note that "33" <em><strong>WILL</strong></em> work.</li>
    6356                    </ul>
     57                    <h4>Shortcodes</h4>
     58                    <p>Use shortcode <em><strong>[rdqr_randomquote]</strong></em> to display a random quote in a page or post.</p>
     59                    <p>Use shortcode <em><strong>[rdqr_targetquote singlequote="3"]</strong></em> to display a specific quote in a post or page. Change the number 3 to the line number of the quote that you want to display.</p>                 
     60                    <p><strong>Use the following shortcode in your theme files to get a random quote:</strong><p>
     61                    <p><em>&lt;?php echo do_shortcode("[rdqr_randomquote]"); ?&gt;</em>.</p>
     62                    <p><strong>Use the following shortcode in your theme files to get a specific quote:</strong><p>
     63                    <p><em>&lt;?php echo do_shortcode('[rdqr_targetquote singlequote="3"]'); ?&gt;</em>. Change the number 3 to the quote that you want displayed.</p>
    6464                </td>
    6565            </tr>
     
    6767       
    6868        <input type='hidden' name='action' value='update' />
    69         <input type='hidden' name='page_options' value='randomQuotr_quotes' />
     69        <input type='hidden' name='page_options' value='randomquotr_quotes' />
    7070
    7171        <p class='submit'>
     
    7979
    8080/* Echos a texturized random quote */
    81 function random_quote() { echo get_random_quote(); }
     81function rdqr_random_quote() {
     82    echo rdqr_get_random_quote();
     83}
    8284
    8385/* Returns a texturized random quote */
    84 function get_random_quote() {
    85     $rQuote = explode("\n", get_option('randomQuotr_quotes'));
     86function rdqr_get_random_quote() {
     87    $rQuote = explode("\n", get_option('randomquotr_quotes'));
    8688    if($rQuote == null || count($rQuote) <= 0)
    8789        return null;
     
    8991}
    9092
     93/* Display Random Shortcode */
     94add_shortcode('rdqr_randomquote', 'rdqr_get_random_quote');
     95
     96
    9197/* Echos a specific texturized quote If it cannot select a quote (invalid selection, invalid input) it will echo null (nothing will display)*/
    92 function target_quote($lineNumber) { echo get_target_quote ($lineNumber); }
     98function rdqr_target_quote($lineNumber) {
     99    echo rdqr_get_target_quote ($lineNumber);
     100}
    93101
    94102/* returns a specific texturized quote. If it cannot select a quote (invalid selection, invalid input) it will return null */
    95 function get_target_quote($lineNumber) {
    96     $rQuote = explode("\n", get_option('randomQuotr_quotes'));
     103function rdqr_get_target_quote($lineNumber) {
     104    $rQuote = explode("\n", get_option('randomquotr_quotes'));
    97105    if($rQuote == null || count($rQuote) <= 0 || $lineNumber < 1 || !is_numeric($lineNumber) || intval($lineNumber) > count($rQuote))
    98106        return null;
    99107    return wptexturize($rQuote[ intval($lineNumber) - 1 ]);
    100108}
    101    
     109
     110/* Shortcode with parameter */
     111function rdqr_target_quote_shortcode($singlequote) {
     112 extract(shortcode_atts(array(
     113    'singlequote' => ''
     114    ), $singlequote));     
     115  return rdqr_get_target_quote($singlequote);
     116}
     117add_shortcode('rdqr_targetquote', 'rdqr_target_quote_shortcode');
     118
     119
     120/* Using Shortcodes in Widgets */
     121add_filter('widget_text', 'do_shortcode');
     122
    102123?>
  • randomquotr/trunk/readme.txt

    r80362 r1856096  
    11=== RandomQuotr ===
    2 Contributors: Corey Dutson
    3 Donate link: http://wallofscribbles.com/wordpress-plugins
    4 Tags: content, quotes, random, hello dolly
    5 Requires at least: 2.0.2
    6 Tested up to: 2.7
    7 Stable tag: trunk
     2Contributors: Corey Dutson, jfcby
     3Tags: content, quotes, random
     4Requires at least: 4.0
     5Tested up to: 4.9.4
     6Stable tag: 1.0.2
     7Requires PHP: 5.2.4
     8License: GPLv2 or later
     9License URI: http://www.gnu.org/licenses/gpl-2.0.html
    810
    9 Allows the user to create a list of quotes, and then pull either a random or specific quote from that list
     11Create a list of quotes and then display either a random or specific quote.
    1012
    1113== Description ==
    1214
    13 Allows the user to create a list of quotes, and then pull either a random or specific quote from that list using custom template tags.
     15Allows the user to create a list of quotes and then display either a random or specific quote from that list using custom template tags or shortcodes.
    1416
    1517== Installation ==
    1618
    17 1. Upload `RandomQuotr` to the `/wp-content/plugins/` directory
    18 1. Activate the plugin through the 'Plugins' menu in WordPress
    19 1. Under the settings section, navigate to the RandomQuotr section
    20 1. Add quotes to the textarea on the left-hand side. Quotes are split by carriage returns (line breaks)
     191. Upload the plugin files to the `/wp-content/plugins/randomquotr` directory, or install the plugin through the WordPress plugins screen directly.
     201. Activate the plugin through the 'Plugins' screen in WordPress
     211. Use the Settings->RandomQuotr screen add quotes in the textarea on the left-hand side. Quotes are split by carriage returns (line breaks)
     221. Use the following hooks to display the quotes:
    2123
    22 Once that's done, you can use the following hooks to display the content:
    23 
    24 **Getting a random quote**
    25 * `random_quote();` - this will display the text automatically.
    26 * `$quote = get_random_quote();` - this stores the text within a variable.
     24**Get a random quote**
     25* `rdqr_random_quote();` - this will display the text automatically.
     26* `$quote = rdqr_get_random_quote();` - this stores the text within a variable.
    2727
    2828**Getting a specific quote**
    29 * `target_quote(3);` - this will display the third quote in the list.
    30 * `$quote = get_target_quote();` - this stores the text within a variable.
     29* `rdqr_target_quote(3);` - this will display the third quote in the list.
     30* `$quote = rdqr_get_target_quote();` - this stores the text within a variable.
    3131
    3232
    3333== Frequently Asked Questions ==
    3434
    35 = I'm using target_quote(0) and nothing's coming up! I know I have a quote in there though =
     35= I'm using rdqr_target_quote(0) and nothing's coming up! I know I have added quotes =
    3636
    37 The list starts at 1, not 0.
     37The list starts at 1 not 0.
    3838
    39 = target_quote and get_target_quote are not doing anything! =
     39= rdqr_target_quote and rdqr_get_target_quote are not doing anything! =
    4040
    4141Make sure that you are passing in a valid value. If you are passing in an invalid number (below 1, above the number of quotes), a non-number ("forty"), or there are no quotes to get, all of the functions will return null.
    4242
     43= Can a shortcode be used to display a random quote? =
    4344
    44 == Current version ==
     45Yes, use [rdqr_randomquote] in a page or post.
    4546
    46 Current version: 1.0
     47= Can a shortcode be used to display a specific quote? =
    4748
    48 == Revision History ==
     49Yes, use [rdqr_targetquote singlequote="3"] to display the third quote. Change the number 3 to the quote that you want displayed.
    4950
    50 0.1 - made within the functions.php file of the theme
    51 1.0 - created plugin, cleaned things up
     51= Can shortcodes be used in theme files? =
     52Yes, to display a random quote place <?php echo do_shortcode("[rdqr_randomquote]"); ?> in your theme template. Display a specific quote by placing <?php echo do_shortcode('[rdqr_targetquote singlequote="3"]'); ?> in your theme template. Change the number 3 to the quote that you want displayed.
    5253
    53 == GPL ==
    54 Copyright 2008  Corey Dutson  (email : cdutson@wallofscribbles.com)
     54= Can shortcodes be used in widgets? =
    5555
    56 This program is free software; you can redistribute it and/or modify
    57 it under the terms of the GNU General Public License as published by
    58 the Free Software Foundation; either version 2 of the License, or
    59 (at your option) any later version.
     56Yes, the shortcodes can be used in widgets.
    6057
    61 This program is distributed in the hope that it will be useful,
    62 but WITHOUT ANY WARRANTY; without even the implied warranty of
    63 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    64 GNU General Public License for more details.
     58== Changelog ==
    6559
    66 You should have received a copy of the GNU General Public License
    67 along with this program; if not, write to the Free Software
    68 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     60= 1.0.2 =
     61* added shortcodes
     62
     63= 1.0.1 =
     64* made within the functions.php file of the theme
     65
     66= 1.0.0 =
     67* created plugin, cleaned things up
Note: See TracChangeset for help on using the changeset viewer.