Skip to content

Instantly share code, notes, and snippets.

View Pleiades's full-sized avatar

Nicholas R. Batik Pleiades

  • Pleiades Publishing Services, Co.
  • Austin, TX
View GitHub Profile
@Pleiades
Pleiades / orange-button.css
Created November 15, 2012 19:08
WordPress Shortcode to Add a Big Orange Button With a Link
.orange-button {
background: none repeat scroll 0 0 #FB661B;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
display: table;
margin: 10px auto;
padding: 3px 10px;
text-align: center;
}
@Pleiades
Pleiades / flickr-badge-sample.txt
Created November 15, 2012 20:14
Add a Flickr Badge
[flickrbadge count="4" layout="h" display="latest" size="t" source="all_tag" tag="fish"]Here’s the latest fish[/flickrbadge]  
@Pleiades
Pleiades / Donate.php
Created November 15, 2012 20:29
Add a PayPal Donation Link
function donate_shortcode( $atts ) {
extract(shortcode_atts(array(
'text' => 'Make a donation',
'account' => 'REPLACE ME',
'for' => '',
), $atts));
global $post;
if (!$for) $for = str_replace(" ","+",$post->post_title);
return '<a class="donateLink" href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business='.$account.'&item_name=Donation+for+'.$for.'">'.$text.'</a>';
}
@Pleiades
Pleiades / googlemap.php
Created November 15, 2012 21:54
Add Google Maps
function fn_googleMaps($atts, $content = null) {
extract(shortcode_atts(array(
"width" => '640',
"height" => '480',
"src" => ''
), $atts));
return '<iframe width="'.$width.'" height="'.$height.'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'.$src.'"></iframe>';
}
add_shortcode("googlemap", "fn_googleMaps");
@Pleiades
Pleiades / privatenotestoposts.php
Created November 15, 2012 22:01
Add Private Notes to Posts
function sc_note( $atts, $content = null ) {
if ( current_user_can( 'publish_posts' ) )
return '<div class="note">'.$content.'</div>';
return '';
}
add_shortcode( 'note', 'sc_note' );
@Pleiades
Pleiades / contenttorgistereduseronly.php
Created November 15, 2012 22:09
Display Content to Registered Users Only
add_shortcode( 'member', 'member_check_shortcode' );
function member_check_shortcode( $atts, $content = null ) {
if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )
return $content;
return '';
}
@Pleiades
Pleiades / disablewordpressformatting.php
Created November 15, 2012 22:17
Disable WordPress Formatting
function my_formatter($content) {
$new_content = '';
$pattern_full = '{(\[raw\].*?\[/raw\])}is';
$pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
$pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);
foreach ($pieces as $piece) {
if (preg_match($pattern_contents, $piece, $matches)) {
$new_content .= $matches[1];
} else {
$new_content .= wptexturize(wpautop($piece));
@Pleiades
Pleiades / displayrelatedposts.php
Created November 15, 2012 22:27
Display Related Posts
function related_posts_shortcode( $atts ) {
extract(shortcode_atts(array(
'limit' => '5', ccccca
), $atts));
global $wpdb, $post, $table_prefix;
if ($post->ID) {
$retval = '<ul>';
// Get tags
$tags = wp_get_post_tags($post->ID);
$tagsarray = array();
@Pleiades
Pleiades / embedgooglechart.php
Created November 15, 2012 22:35
Embed a Google Chart
function chart_shortcode( $atts ) {
extract(shortcode_atts(array(
'data' => '',
'colors' => '',
'size' => '400x200',
'bg' => 'ffffff',
'title' => '',
'labels' => '',
'advanced' => '',
'type' => 'pie'
@Pleiades
Pleiades / embedrssfeed.php
Created November 15, 2012 22:42
Embed an RSS Feed
include_once(ABSPATH.WPINC.'/rss.php');
function readRss($atts) {
extract(shortcode_atts(array(
"feed" => 'http://',
"num" => '1',
), $atts));
return wp_rss($feed, $num);
}
add_shortcode('rss', 'readRss');