Changeset 1870288
- Timestamp:
- 05/07/2018 07:49:10 PM (8 years ago)
- File:
-
- 1 edited
-
proverbs/trunk/proverbs.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
proverbs/trunk/proverbs.php
r1800674 r1870288 1 1 <?php 2 2 3 /** 3 * @package Proverbs 4 * @version 1.0 4 * The plugin bootstrap file 5 * 6 * This file is read by WordPress to generate the plugin information in the plugin 7 * admin area. This file also includes all of the dependencies used by the plugin, 8 * registers the activation and deactivation functions, and defines a function 9 * that starts the plugin. 10 * 11 * @link Proverbs 12 * @package Proverbs 13 * 14 * @wordpress-plugin 15 * Plugin Name: Proverbs 16 * Description: This plugin displays different proverbs. After activating plugin, user can insert shortcode [proverb] where he or she wants proverb to be displayed. Table of proverbs can be inserted too, shortcode for that is [category-search]. Table of proverbs has search capability, where user can find proverbs by categories. Also page titled Proverbs is created with shortcode [category-search] as its content. Menu link Proverbs gets created in admin side. From there user can manage proverbs and their categories. 17 * Version: 2.0.0 18 * Author: castellar120 19 * License: GPL-2.0+ 20 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt 21 * Text Domain: proverbs 22 * Domain Path: /languages 5 23 */ 6 /*7 Plugin Name: Proverbs8 Version: 1.09 Description: This plugin displays different proverbs. After activating plugin, user has to insert shortcode [proverb] where he or she wants proverb to be displayed.10 Author: castellar12011 License: GPL212 License URI: https://www.gnu.org/licenses/gpl-2.0.html13 */14 24 15 class Proverbs { 16 17 public function __construct() { 18 $this->createShortcode(); 19 } 20 21 private $selectedProverb = ""; 22 23 private $Proverbs = array("Two wrongs don't make a right.", "proverbs", "The pen is mightier than the sword.", "When in Rome, do as the Romans.", "The squeaky wheel gets the grease.", "When the going gets tough, the tough get going.", "No man is an island.", "Fortune favors the bold.", "People who live in glass houses should not throw stones.", "Hope for the best, but prepare for the worst.", "Better late than never.", "Birds of a feather flock together.", "Keep your friends close and your enemies closer.", "A picture is worth a thousand words.", "There's no such thing as a free lunch.", "There's no place like home.", "Discretion is the greater part of valor.", "The early bird catches the worm.", "Never look a gift horse in the mouth.", "You can't make an omelet without breaking a few eggs.", "God helps those who help themselves.", "You can't always get what you want.", "Cleanliness is next to godliness.", "A watched pot never boils.", "Beggars can't be choosers.", "Actions speak louder than words.", "If it ain't broke, don't fix it.", "Practice makes perfect.", "Too many cooks spoil the broth.", "Easy come, easy go.", "Don't bite the hand that feeds you.", "All good things must come to an end.", "If you can't beat 'em, join 'em.", "One man's trash is another man's treasure.", "There's no time like the present.", "Beauty is in the eye of the beholder.", "Even walls have ears.", "They catch up with a liar sooner than with a limping dog.", "The apple falls close to its tree.", "There is no rose without thorns."); 24 25 private function getProverb() { 26 $randomNumber = rand(0, count($this->Proverbs)-1); 27 $this->selectedProverb = $this->Proverbs[$randomNumber]; 28 } 29 30 public function shortcodeTemplate( $atts ) { 31 $this->getProverb(); 32 ob_start(); ?> 33 <blockquote> 34 <?php echo $this->selectedProverb; ?> 35 </blockquote> 36 <?php 37 return ob_get_clean(); 38 } 39 40 private function createShortcode() { 41 add_shortcode( 'proverb', array($this, 'shortcodeTemplate') ); 42 } 25 // If this file is called directly, abort. 26 if ( ! defined( 'WPINC' ) ) { 27 die; 43 28 } 44 29 45 $Proverbs = new Proverbs(); 30 /** 31 * Currently plugin version. 32 * Start at version 1.0.0 and use SemVer - https://semver.org 33 * Rename this for your plugin and update it as you release new versions. 34 */ 35 define( 'PLUGIN_NAME_VERSION', '2.0.0' ); 36 37 /** 38 * The code that runs during plugin activation. 39 * This action is documented in includes/class-proverbs-activator.php 40 */ 41 function activate_proverbs() { 42 require_once plugin_dir_path( __FILE__ ) . 'includes/class-proverbs-activator.php'; 43 Proverbs_Activator::activate(); 44 } 45 46 /** 47 * The code that runs during plugin deactivation. 48 * This action is documented in includes/class-proverbs-deactivator.php 49 */ 50 function deactivate_proverbs() { 51 require_once plugin_dir_path( __FILE__ ) . 'includes/class-proverbs-deactivator.php'; 52 Proverbs_Deactivator::deactivate(); 53 } 54 55 register_activation_hook( __FILE__, 'activate_proverbs' ); 56 register_deactivation_hook( __FILE__, 'deactivate_proverbs' ); 57 58 /** 59 * The core plugin class that is used to define internationalization, 60 * admin-specific hooks, and public-facing site hooks. 61 */ 62 require plugin_dir_path( __FILE__ ) . 'includes/class-proverbs.php'; 63 64 /** 65 * Begins execution of the plugin. 66 * 67 * Since everything within the plugin is registered via hooks, 68 * then kicking off the plugin from this point in the file does 69 * not affect the page life cycle. 70 * 71 * @since 2.0.0 72 */ 73 function run_proverbs() { 74 75 $plugin = new Proverbs(); 76 $plugin->run(); 77 78 } 79 run_proverbs();
Note: See TracChangeset
for help on using the changeset viewer.