Mais conteúdo relacionado
Add tag shortcode
- 1. add_tag_shortcode.php 2011-11-06
<?php
/*
Plugin Name: Add Tag Shortcode
Plugin URI: http://semperfiwebdesign.com/
Description: Adds shortcodes for use with basic wordpress template tags.
Version: 1.0
Author: Semper Fi Web Design
Author 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' );
?>
- 1/1 -