Code
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 | |
function add_qrcode_in_this_article($atts) { | |
extract(shortcode_atts(array( | |
'url' => 'http://example.com', | |
'size' => '80', | |
), $atts)); | |
return '<img src="https://chart.googleapis.com/chart?chs=' . $size . 'x' . $size . '&cht=qr&chl=' . $url . '&choe=UTF-8 " alt="QR Code"/>'; | |
} | |
add_shortcode('myqrcode', 'add_qrcode_in_this_article'); | |
?> | |
/*ショートコードは [myqrcode url="http://foo.net" size="150"] と書く。*/ |
Screen shot
Note
Description | ショートコードでサイズとURLを指定。Google APIを使う。 |
---|---|
WordPress Ver. | 3.3.1 |
Via | URLやサイズを指定出来るQRコードをショートコードで作れるようにする |