Changeset 1856096
- Timestamp:
- 04/11/2018 12:23:46 AM (8 years ago)
- Location:
- randomquotr/trunk
- Files:
-
- 2 edited
-
RandomQuotr.php (modified) (6 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
randomquotr/trunk/RandomQuotr.php
r77590 r1856096 1 1 <?php 2 2 /* 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 3 Plugin Name: RandomQuotr 4 Plugin URI: https://wordpress.org/plugins/randomquotr/ 5 Description: 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. 6 Version: 1.0.2 7 Author: jfcby 8 Author URI: http://www.corematrixgrid.com 9 License: GPL2 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html 11 Last Updated: 4/10/2018 - jfcby 12 Text Domain: randomquotr 9 13 */ 10 14 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. */ 16 if ( !defined( 'ABSPATH' ) ) { 17 die; 32 18 } 33 19 34 function randomQuotr_adminPage() { 20 add_action('admin_menu', 'randomquotr_menu'); 21 22 function randomquotr_menu() { 23 add_options_page('RandomQuotr Options', 'RandomQuotr', 8, __FILE__, 'randomquotr_adminPage'); 24 } 25 26 function randomquotr_adminPage() { 35 27 ?> 36 28 <div class='wrap'> … … 43 35 <td style="vertical-align:top"> 44 36 <h3>Quotes</h3> 45 <textarea rows="20" cols="60" name='random Quotr_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> 46 38 </td> 47 39 <td style="vertical-align:top"> 48 40 <h3>Explanation</h3> 49 41 <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><?php random_quote() ?></em></p> 52 <p>You can also use <em><?php $quote = get_random_quote(); ?></em></p> 42 <h4>Hooks</h4> 43 <p><strong>To get a random quote use the following hook:</strong><p> 44 <p><em><?php rdqr_random_quote() ?></em></p> 45 <p>You can also use <em><?php $quote = rdqr_get_random_quote(); ?></em></p> 53 46 <p><strong>To get a specific quote use the following hook:</strong><p> 54 <p><em><?php target_quote($quoteNumber) ?></em> where $quoteNumber is the quote line.</p>55 <p>You can also use <em><?php $quote = get_target_quote($quoteNumber); ?></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><?php rdqr_target_quote($quoteNumber) ?></em> where $quoteNumber is the quote line.</p> 48 <p>You can also use <em><?php $quote = rdqr_get_target_quote($quoteNumber); ?></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> 58 51 <ul> 59 52 <li>There are no quotes available.</li> … … 62 55 <li>A non-numeric value is passed: "twenty". Note that "33" <em><strong>WILL</strong></em> work.</li> 63 56 </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><?php echo do_shortcode("[rdqr_randomquote]"); ?></em>.</p> 62 <p><strong>Use the following shortcode in your theme files to get a specific quote:</strong><p> 63 <p><em><?php echo do_shortcode('[rdqr_targetquote singlequote="3"]'); ?></em>. Change the number 3 to the quote that you want displayed.</p> 64 64 </td> 65 65 </tr> … … 67 67 68 68 <input type='hidden' name='action' value='update' /> 69 <input type='hidden' name='page_options' value='random Quotr_quotes' />69 <input type='hidden' name='page_options' value='randomquotr_quotes' /> 70 70 71 71 <p class='submit'> … … 79 79 80 80 /* Echos a texturized random quote */ 81 function random_quote() { echo get_random_quote(); } 81 function rdqr_random_quote() { 82 echo rdqr_get_random_quote(); 83 } 82 84 83 85 /* Returns a texturized random quote */ 84 function get_random_quote() {85 $rQuote = explode("\n", get_option('random Quotr_quotes'));86 function rdqr_get_random_quote() { 87 $rQuote = explode("\n", get_option('randomquotr_quotes')); 86 88 if($rQuote == null || count($rQuote) <= 0) 87 89 return null; … … 89 91 } 90 92 93 /* Display Random Shortcode */ 94 add_shortcode('rdqr_randomquote', 'rdqr_get_random_quote'); 95 96 91 97 /* 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); } 98 function rdqr_target_quote($lineNumber) { 99 echo rdqr_get_target_quote ($lineNumber); 100 } 93 101 94 102 /* 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('random Quotr_quotes'));103 function rdqr_get_target_quote($lineNumber) { 104 $rQuote = explode("\n", get_option('randomquotr_quotes')); 97 105 if($rQuote == null || count($rQuote) <= 0 || $lineNumber < 1 || !is_numeric($lineNumber) || intval($lineNumber) > count($rQuote)) 98 106 return null; 99 107 return wptexturize($rQuote[ intval($lineNumber) - 1 ]); 100 108 } 101 109 110 /* Shortcode with parameter */ 111 function rdqr_target_quote_shortcode($singlequote) { 112 extract(shortcode_atts(array( 113 'singlequote' => '' 114 ), $singlequote)); 115 return rdqr_get_target_quote($singlequote); 116 } 117 add_shortcode('rdqr_targetquote', 'rdqr_target_quote_shortcode'); 118 119 120 /* Using Shortcodes in Widgets */ 121 add_filter('widget_text', 'do_shortcode'); 122 102 123 ?> -
randomquotr/trunk/readme.txt
r80362 r1856096 1 1 === 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 2 Contributors: Corey Dutson, jfcby 3 Tags: content, quotes, random 4 Requires at least: 4.0 5 Tested up to: 4.9.4 6 Stable tag: 1.0.2 7 Requires PHP: 5.2.4 8 License: GPLv2 or later 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 8 10 9 Allows the user to create a list of quotes, and then pull either a random or specific quote from that list 11 Create a list of quotes and then display either a random or specific quote. 10 12 11 13 == Description == 12 14 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.15 Allows 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. 14 16 15 17 == Installation == 16 18 17 1. Upload `RandomQuotr` to the `/wp-content/plugins/` directory18 1. Activate the plugin through the 'Plugins' menuin WordPress19 1. U nder the settings section, navigate to the RandomQuotr section20 1. Add quotes to the textarea on the left-hand side. Quotes are split by carriage returns (line breaks)19 1. Upload the plugin files to the `/wp-content/plugins/randomquotr` directory, or install the plugin through the WordPress plugins screen directly. 20 1. Activate the plugin through the 'Plugins' screen in WordPress 21 1. Use the Settings->RandomQuotr screen add quotes in the textarea on the left-hand side. Quotes are split by carriage returns (line breaks) 22 1. Use the following hooks to display the quotes: 21 23 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. 27 27 28 28 **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. 31 31 32 32 33 33 == Frequently Asked Questions == 34 34 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 = 36 36 37 The list starts at 1 ,not 0.37 The list starts at 1 not 0. 38 38 39 = target_quote andget_target_quote are not doing anything! =39 = rdqr_target_quote and rdqr_get_target_quote are not doing anything! = 40 40 41 41 Make 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. 42 42 43 = Can a shortcode be used to display a random quote? = 43 44 44 == Current version == 45 Yes, use [rdqr_randomquote] in a page or post. 45 46 46 Current version: 1.0 47 = Can a shortcode be used to display a specific quote? = 47 48 48 == Revision History == 49 Yes, use [rdqr_targetquote singlequote="3"] to display the third quote. Change the number 3 to the quote that you want displayed. 49 50 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? = 52 Yes, 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. 52 53 53 == GPL == 54 Copyright 2008 Corey Dutson (email : cdutson@wallofscribbles.com) 54 = Can shortcodes be used in widgets? = 55 55 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. 56 Yes, the shortcodes can be used in widgets. 60 57 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 == 65 59 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.