Last active
August 29, 2015 14:06
-
-
Save keirwhitaker/584dbaeb2c87885a98b1 to your computer and use it in GitHub Desktop.
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
/** | |
* Shortcode that outputs a figure in the WordPress content editor generated content | |
* @author Keir Whitaker ([email protected] | keirwhitaker.com) | |
* | |
* @param type $atts The src attribute | |
* @param type $content The caption for the figcaption | |
* @return string | |
* | |
* Usage [figure src="/wp-content/test.jpg"]This is not linked up but this is <a href="http://yahoo.com">This is the content</a>[/figure] | |
* | |
*/ | |
function figure_func( $atts, $content ) { | |
$a = shortcode_atts( array ( | |
'src' => '' | |
), $atts ); | |
$content = wp_kses( $content, array ( | |
'strong' => array(), | |
'a' => array( 'href', 'title' ), | |
'em' =>array() | |
) ); | |
$retval .= '<figure>'; | |
$retval .= '<img src="' . $a['src'] . '" />'; | |
$retval .= '<figcaption>' . html_entity_decode( $content ) . '</figcaption>'; | |
$retval .= '</figure>'; | |
return $retval; | |
} | |
add_shortcode( 'figure', 'figure_func' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment