Created
July 4, 2012 04:03
-
-
Save s-hiroshi/3045199 to your computer and use it in GitHub Desktop.
WordPress > shortcode > pagetop
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 | |
/** | |
* 「このページの上へ」をマークアップするショートコード。 | |
* @attribute classname div要素のクラス名 省略 pagetop | |
* @attribute target アンカー名 省略 wrapper | |
* @attribute text リンクの文字列 このページの上へ。 | |
* 属性がない場合は下記のHTMLコードを返す。 | |
* <div class="pagetop"><a href="#wrapper">このページの上へ</a></div> | |
* 使い方[pagetop] | |
*/ | |
function pagetop_func($atts) { | |
extract(shortcode_atts(array( | |
'classname' => 'pagetop', | |
'target' => 'wrapper', | |
'text' => 'このページの上へ' | |
), $atts)); | |
$markup = '<div class="' . $classname . '"><a href="#' . $target . '">' . $text . '</a></div>'; | |
return $markup; | |
} | |
add_shortcode('pagetop', 'pagetop_func'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment