2008年09月14日 日
書誌挿入のテスト(その1)

自分でプラグインを書いて、本の情報を表示されるようにするテストです。
[bk1 bib_id=”03028111″]↑[bk1 bib_id=”03028111″]
↑[wp_bk1 bib_id=”03028111″]
[bk1 bib_id=”02684959″ style=”2″]↑[bk1 bib_id=”02684959″ style=”2″]
↑[wp_bk1 bib_id=”02684959″ style=”2″]
// [bk1_bib_shortcode bib_id= ]
function bk1_bib_shortcode($atts) {
extract(shortcode_atts(array(
'bib_id' => '',
'style' => ''
), $atts));
// [bk1_bib_shortcode bib_id= ]
function bk1_bib_shortcode($atts) {
extract(shortcode_atts(array(
'bib_id' => '',
'style' => ''
), $atts));
if($bib_id == "" ){
return '';
} else {
return <<<_EOT_
<script src="http://guro.style.coocan.jp/data/t$bib_id$style" type="text/javascript"></script>
_EOT_;
}
}
add_shortcode('bk1', 'bk1_bib_shortcode');
add_shortcode('wp_bk1', 'bk1_bib_shortcode');
まずは、自サイトにアップしている書誌ファイル(javascriptファイル:別プログラムから生成してアップしています…)を表示するだけの簡単プラグイン。
今後は、この部分を、bk1から自動取得するなどの目論見。
しっかし、wordpressの shortcode はお手軽でうれしいね。
追記:[bk1]の形でも発動させようとしたところが、タイトルにつけている[bk1]といっしょになっちゃったので、とりあえずshortcodeのタグは[wp_bk1]でいこうと思う。(名前の重複を避けるのは難しい)
