Changeset 1418872
- Timestamp:
- 05/17/2016 03:19:13 PM (10 years ago)
- Location:
- speak-pirate/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
speak-pirate.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
speak-pirate/trunk/readme.txt
r1234394 r1418872 3 3 Tags: pirate, language, shortcode, translate, translation 4 4 Requires at least: 3.0 5 Tested up to: 4. 36 Stable tag: trunk5 Tested up to: 4.5.2 6 Stable tag: master 7 7 License: GPLv2 or later 8 8 … … 22 22 23 23 == Changelog == 24 = 1.1 = 25 * Updated to filter all site content on Speak like a Pirate Day (September 19)...kudos to joemcgill 26 * Updated code to better adhere to WordPress coding standards 27 24 28 = 1.0 = 25 29 * Initial release -
speak-pirate/trunk/speak-pirate.php
r654703 r1418872 2 2 /** 3 3 * Plugin Name: Speak Pirate 4 * Plugin URI: 5 * Description: Translates text in a shortcode into the equivalent text spoken as a pirate4 * Plugin URI: 5 * Description: translates text in a shortcode into the equivalent text spoken as a pirate 6 6 * Author: ericjuden 7 7 * Author URI: http://ericjuden.com 8 * Version: 1. 08 * Version: 1.1 9 9 */ 10 10 11 11 class Speak_Pirate { 12 12 function __construct(){ 13 13 // Constructor...actions and filters go here 14 add_shortcode('speak_pirate', array($this, 'speak_pirate'), 10, 2); 14 add_shortcode( 'speak_pirate' , array( $this , 'speak_pirate_shortcode' ), 10 , 2 ); 15 16 /** 17 * Add filter to all content on Speak like a Pirate Day (Sept. 19) 18 */ 19 if ( 'Sep 19' === date( 'M j' ) ) { 20 add_filter( 'the_content' , array( $this , 'speak_pirate') ); 21 } 15 22 } 16 17 function speak_pirate( $args, $content = null){23 24 function speak_pirate( $content = null ){ 18 25 // Check if there is any content 19 if( $content == null){26 if( $content == null ) { 20 27 return; 21 28 } 22 29 23 30 // URL encode our "pirate" text 24 $text = urlencode( $content);25 31 $text = urlencode( $content ); 32 26 33 // Set the url for our web service. Found API from apihub.com 27 $url = sprintf( 'http://isithackday.com/arrpi.php?text=%s', $text);28 34 $url = sprintf( 'http://isithackday.com/arrpi.php?text=%s' , $text ); 35 29 36 // Retrieve response from web service 30 $response = wp_remote_get( $url);31 37 $response = wp_remote_get( $url ); 38 32 39 // Return translated string. If nothing found, returns empty string 33 return wp_remote_retrieve_body($response); 40 return wp_remote_retrieve_body( $response ); 41 } 42 43 function speak_pirate_shortcode( $args, $content = null ) { 44 return $this->speak_pirate( $content ); 34 45 } 35 46 } 36 47 37 48 // Create an instance of the class so it will run 38 49 $speak_pirate = new Speak_Pirate();
Note: See TracChangeset
for help on using the changeset viewer.