WordPress ソーシャルブックマーク系プラグイン(ボタン設置+管理画面での一覧統計)

本サイトでも使っている、WordPressのソーシャルブックマーク系のプラグインを2つ紹介します。

WP Social Bookmarking Light – ボタンの設置

プラグイン: WP Social Bookmarking Light

インストールして有効化すればすぐに使えます。
設定も簡単なので触ればすぐに分かると思います。

設定画面


設置画面

Social Matrics – 管理画面で一覧統計

プラグイン: Social Matrics

こちらも、インストールして有効化すればすぐに使えます。

これで完璧!

と、いきたいところですが、このプラグインの作者さんが外国人だからでしょう。日本特有のはてなブックマークとか mixi とかに対応していません。。
逆に、日本語の記事に StumbleUpon とか Digg にブックマークが付くことはまずないでしょうね。

ということで、はてなブックマークを表示させたいなら、プラグインに少し手を加えなければなりません。

まず、はてなブックマークの公式サイトからボタンのコードを取得します。→はてなブックマークボタンの作成・設置について

記事ごとのブックマークを管理画面上で一覧表示したいので、URLに記事のパーマリンクを仕込みます。

http://b.hatena.ne.jp/entry/<?php the_permalink() ?>
<a href="http://b.hatena.ne.jp/entry/<?php the_permalink() ?>" class="hatena-bookmark-button" data-hatena-bookmark-layout="standard" title="このエントリーをはてなブックマークに追加"><img src="http://b.st-hatena.com/images/entry-button/button-only.gif" alt="このエントリーをはてなブックマークに追加" width="20" height="20" style="border: none;" /></a><script type="text/javascript" src="http://b.st-hatena.com/js/bookmark_button.js" charset="utf-8" async="async"></script>

これをプラグインに組み込めばOK!
(はてなブックマークを追加して、StumbleUpon と Digg は非表示にしています)

> wp-content/plugins/social-metrics/socialmetrics.php(266行目〜)

<table class="widefat post fixed smtable" cellspacing="0">
	<thead> 
		<tr>
			<th scope="col" id="title0" class="manage-column column-title" >Title</th>
			<th scope="col" id="title1" class="manage-column column-title" >Twitter</th>
			<th scope="col" id="title2" class="manage-column column-title" >Facebook</th>
			<th scope="col" id="title3" class="manage-column column-title" >Google +1</th>
			<th scope="col" id="title4" class="manage-column column-title" >hatena</th>
			<!--
			<th scope="col" id="title5" class="manage-column column-title" >StumbleUpon</th>
			<th scope="col" id="title6" class="manage-column column-title" >Digg</th>
			-->
			<th scope="col" id="title7" class="manage-column column-title" >LinkedIn</th>
		</tr>
	</thead>
	<tbody>
		<?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
		<tr>
			<td ><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></td>
			<td ><a href="http://twitter.com/share" class="twitter-share-button" data-text="<?php the_title(); ?>" data-count="horizontal" data-url="<?php the_permalink() ?>">Tweet</a></td>
			<td ><iframe src="http://www.facebook.com/plugins/like.php?href=<?php the_permalink(); ?>&send=false&layout=button_count&width=100&show_faces=false&action=like&colorscheme=light" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe></td>
			<td ><g:plusone size="medium" href="<?php the_permalink(); ?>"></g:plusone></td>
			<td ><a href="http://b.hatena.ne.jp/entry/<?php the_permalink() ?>" class="hatena-bookmark-button" data-hatena-bookmark-layout="standard" title="このエントリーをはてなブックマークに追加"><img src="http://b.st-hatena.com/images/entry-button/button-only.gif" alt="このエントリーをはてなブックマークに追加" width="20" height="20" style="border: none;" /></a><script type="text/javascript" src="http://b.st-hatena.com/js/bookmark_button.js" charset="utf-8" async="async"></script></td>
			<!--
			<td ><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&r=<?php the_permalink(); ?>"></script></td>
			<td ><a class="DiggThisButton DiggCompact" href="http://digg.com/submit?url=<?php the_permalink(); ?>&amp;title=<?php the_title(); ?>"></a></td>
			-->
			<td ><script type="in/share" data-url="<?php the_permalink(); ?>" data-counter="right"></script></td>
			
		</tr>
		<?php endwhile; ?>
	</tbody>
	<tfoot>
		<tr> 
			<th scope="col"  class="manage-column column-title" >Title</th>
			<th scope="col"  class="manage-column column-title" >Twitter</th>
			<th scope="col"  class="manage-column column-title" >Facebook</th>
			<th scope="col"  class="manage-column column-title" >Google +1</th>
			<th scope="col"  class="manage-column column-title" >hatena</th>
			<!--
			<th scope="col"  class="manage-column column-title" >StumbleUpon</th>
			<th scope="col"  class="manage-column column-title" >Digg</th>
			-->
			<th scope="col"  class="manage-column column-title" >LinkedIn</th>
		</tr>
	</tfoot>
</table>

同様の手順で mixi ボタンとかも設置できます。(mixiボタンにはチェックキーが必要です)

注)プラグインのコアファイルに手を加えることはあまりいいことではありません。アップデートが走ったら修正箇所は上書きされてしまうからです。本来であれば日本語サイト向けのプラグインの出現を待つか、もしくは自分で作るか、と言いたいところですが、今回は取り急ぎということで。

追記

このプラグインを日本語サイト向けに改良している方がいらっしゃいました。→ ブログ記事のTweet数やブクマ、いいね!の数を管理画面に一覧表示するWordPressプラグイン・Social Metricsを日本向けにした
こちらもどうぞ。

コメントを残す