Skip to content

Instantly share code, notes, and snippets.

@AndrewSepic
Last active August 29, 2015 14:27
Show Gist options
  • Save AndrewSepic/fb3bc345d6af9d588d75 to your computer and use it in GitHub Desktop.
Save AndrewSepic/fb3bc345d6af9d588d75 to your computer and use it in GitHub Desktop.
A simple bit of Wordpress code to add Shortcodes for Foundation's Grid and buttons
<?php
/********************************/
/* SHORTCODES */
/********************************/
/* COLUMNS */
// [row]
function row_shortcode( $atts, $content = null ){
return '<div class="row">' . do_shortcode($content) .'</div>';
}
add_shortcode( 'row', 'row_shortcode' );
// [one_half]
function one_half_col( $atts, $content = null ){
return '<div class="small-6 large-8 columns">' . do_shortcode($content) . '</div>';
}
add_shortcode( 'one_half', 'one_half_col' );
// [one_third]
function one_third_col( $atts, $content = null ){
return '<div class="small-2 large-4 columns">' . do_shortcode($content) . '</div>';
}
add_shortcode( 'one_third', 'one_third_col' );
// [two_third]
function two_third_col( $atts, $content = null ){
return '<div class="small-6 large-8 columns">' . do_shortcode($content) . '</div>';
}
add_shortcode( 'two_third', 'two_third_col' );
// [one_quarter]
function one_quarter_col( $atts, $content = null ){
return '<div class="small-6 large-8 columns">' . do_shortcode($content) . '</div>';
}
add_shortcode( 'one_quarter', 'one_quarter_col' );
// Button
// [button link="http://" size="large" color="blue" radius="round"]
function button_shortcode( $atts, $content = null ) {
$a = shortcode_atts( array(
'link' => 'nolink',
'size' => '',
'color' => '',
'radius' => '',
), $atts );
return '<a class="button ' . esc_attr($a['size']) . ' ' . esc_attr($a['color']) . ' ' . esc_attr($a['radius']) . '" href="' . esc_attr($a['link']) . '">' . $content . '</a>';
}
add_shortcode( 'button', 'button_shortcode' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment