Created
June 29, 2012 06:57
-
-
Save s-hiroshi/3016372 to your computer and use it in GitHub Desktop.
WordPress > shortcode > br
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
<?php | |
/** | |
* 属性numに指定した数の改行をマークアップ。 | |
* @attribute num 改行の数 | |
* 使い方[bar num="3"] 3回改行 | |
*/ | |
function br_func($atts) { | |
extract(shortcode_atts(array( | |
'num' => '1' | |
), $atts)); | |
$num = intval($num); | |
$html = ''; | |
if ($num == 1) { | |
$html = "<br />"; | |
} else if ($num > 1) { | |
for ($i=0; $i<$num; $i++) { | |
$html .= "<br />"; | |
} | |
} | |
return $html; | |
} | |
add_shortcode('br', 'br_func'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment