Created
August 11, 2014 16:23
-
-
Save vienhoang/c6f18ccb1cb52f16154c to your computer and use it in GitHub Desktop.
WordPress: Custom shortcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Twitter Shower | |
Plugin URI: http://vienhoang.com | |
Description: Display message. | |
Version: 1.0 | |
Author: Vien Hoang | |
Author URI: http://vienhoang.com | |
License: GPL2 | |
*/ | |
// $content is between the shortcode | |
add_shortcode( 'twitter', function( $atts, $content ) { | |
$atts = shortcode_atts( | |
array( | |
'username' => 'vienhoang', | |
'content' => !empty($content) ? $conent : 'Follow me on Twitter!' | |
), $atts | |
); | |
// Extact the atts array and get variables from keys | |
extract($atts); | |
return "<a href=\"http://twitter.com/{$username}\">{$content}</a>"; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment