Created
May 19, 2014 13:54
-
-
Save RPSource/f1303ddd3775ef6fb267 to your computer and use it in GitHub Desktop.
Arrow shortcode WP
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
#-----------------------------------------------------------------# | |
# Add Shortcode to add arrows to divs | |
#-----------------------------------------------------------------# | |
function divider_arrow_function($atts, $content = null) { | |
extract(shortcode_atts(array( | |
'direction' => 'down', | |
'class' => '', | |
'width' => '100', | |
'height' => '60', | |
'color' => '#000' | |
), $atts)); | |
switch ($atts['direction']) { | |
case 'up': | |
return '<div class="arrow-' . $atts['direction'] . ' ' . $atts['class'] . '" style="width: 0; height: 0; border-left: ' . $atts['width'] . 'px solid transparent; border-right: ' . $atts['width'] . 'px solid transparent; border-bottom: ' . $atts['width'] . 'px solid ' . $atts['color'] . ';"></div>'; | |
break; | |
case 'down': | |
return '<div class="arrow-' . $atts['direction'] . ' ' . $atts['class'] . '" style="width: 0; height: 0; border-left: ' . $atts['width'] . 'px solid transparent; border-right: ' . $atts['width'] . 'px solid transparent; border-top: ' . $atts['width'] . 'px solid ' . $atts['color'] . ';"></div>'; | |
break; | |
case 'left': | |
return '<div class="arrow-' . $atts['direction'] . ' ' . $atts['class'] . '" style="width: 0; height: 0; border-top: ' . $atts['width'] . 'px solid transparent; border-bottom: ' . $atts['width'] . 'px solid transparent; border-right: ' . $atts['width'] . 'px solid ' . $atts['color'] . ';"></div>'; | |
break; | |
case 'right': | |
return '<div class="arrow-' . $atts['direction'] . ' ' . $atts['class'] . '" style="width: 0; height: 0; border-top: ' . $atts['width'] . 'px solid transparent; border-bottom: ' . $atts['width'] . 'px solid transparent; border-left: ' . $atts['width'] . 'px solid ' . $atts['color'] . ';"></div>'; | |
break; | |
} | |
} | |
add_shortcode('arrow', 'divider_arrow_function'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use?
There are a couple of default parameters that take certain values
Example usage: