プラグイン for WP


function the_qrcode( $data = "" , $width_height = 150 , $chld = "L" ) {
	if ( "" == $data ) {
		$data = get_bloginfo('url');
	}
	return '<img src="http://chart.apis.google.com/chart?chs=' . $width_height . 'x' . $width_height . '&cht=qr&chld=' . $chld . '&chl=' . rawurlencode($data) . '">';
}

function qrcode_output_func( $atts , $content = null ) {
	extract( shortcode_atts( array(
					'size' => '150',
					'errorlv' => 'L',
					), $atts ));

	if ( "" == $content ) {
		$content = get_permalink();
	}
	return the_qrcode( $content , $size , $errorlv );
}

add_shortcode( 'qrcode' , 'qrcode_output_func' );


http://plugin.php-web.net/wp/qrcode からダウンロード可能。

get_bloginfo('url'), get_permalink() はワードプレスの関数。

コメントは受け付けていません。