1

Click here to load reader

Add tag shortcode

Embed Size (px)

Citation preview

Page 1: Add tag shortcode

add_tag_shortcode.php 2011-11-06

- 1/1 -

<?php/*Plugin Name: Add Tag ShortcodePlugin URI: http://semperfiwebdesign.com/Description: Adds shortcodes for use with basic wordpress template tags.Version: 1.0Author: Semper Fi Web DesignAuthor URI: http://semperfiwebdesign.com/*/

if ( ! function_exists( 'sfwd_add_tag_shortcode' ) ) { function sfwd_add_tag_shortcode($atts, $content='', $code) { extract(shortcode_atts(array( 'has_func' => "has_$code", 'get_func' => "get_the_$code", ), $atts)); if ( $has_func && function_exists( $has_func ) ) { if ( !( call_user_func ( $has_func ) ) ) { return; } } if ( $get_func && function_exists( $get_func ) ) { return "<span class='add_$code'>".do_shortcode(call_user_func($get_func )).'</span>'; } }}

add_shortcode( 'title', 'sfwd_add_tag_shortcode' );add_shortcode( 'content', 'sfwd_add_tag_shortcode' );add_shortcode( 'excerpt', 'sfwd_add_tag_shortcode' );?>