Created
May 26, 2016 22:17
-
-
Save pixelcoder/9319a4f7cfd712e130731a1d43dda74b to your computer and use it in GitHub Desktop.
Example WordPress shortcode creation
This file contains hidden or 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
<?php | |
# BUTTONS | |
function sc_btn_default($atts, $content = null){ | |
return '<a href="'.$atts['link'].'" class="button">'.do_shortcode($content).'</a>'; | |
} | |
add_shortcode('button', 'sc_btn_default'); | |
function sc_btn_primary($atts, $content = null){ | |
return '<a href="'.$atts['link'].'" class="button">'.do_shortcode($content).'</a>'; | |
} | |
add_shortcode('button_primary', 'sc_btn_default'); | |
function sc_btn_secondary($atts, $content = null){ | |
return '<a href="'.$atts['link'].'" class="button">'.do_shortcode($content).'</a>'; | |
} | |
add_shortcode('button_secondary', 'sc_btn_default'); | |
# ROWS | |
function sc_row_open($atts, $content = null){ | |
return '<div class="row">'; | |
} | |
add_shortcode('row_open', 'sc_row_open'); | |
function sc_row_close($atts, $content = null){ | |
return '</div>'; | |
} | |
add_shortcode('row_close', 'sc_row_close'); | |
# COLUMNS | |
function sc_column_full($atts, $content = null){ | |
return '<div class="column">'.do_shortcode($content).'</div>'; | |
} | |
add_shortcode('column', 'sc_column_full'); | |
function sc_column_quarter($atts, $content = null){ | |
return '<div class="column one-quarter">'.do_shortcode($content).'</div>'; | |
} | |
add_shortcode('column_quarter', 'sc_column_quarter'); | |
function sc_column_half($atts, $content = null){ | |
return '<div class="column one-half">'.do_shortcode($content).'</div>'; | |
} | |
add_shortcode('column_half', 'sc_column_half'); | |
function sc_column_third($atts, $content = null){ | |
return '<div class="column one-third">'.do_shortcode($content).'</div>'; | |
} | |
add_shortcode('column_third', 'sc_column_third'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment