他サイトの紹介作業を単純化

ブックマークレットとショートコードを使ってURL取得からWPでの掲載までとっても楽ちん。

ショートコードサンプル
[[bm url="***" description="ページの概要・説明(任意)"]ページのタイトル[/bm]]

このショートコードを1クリックで取得するのが下記ブックマークレット。
お気に入りに登録しておいて、ショートコードを取得したいページでブックマークから起動するだけです。

ブックマークレット GetLinkCode

function.phpに追加した内容ですが、はてぶの表示はいらないかなと思ったので少しソースを変更しました。

/*外部リンクサムネ付き紹介用のショートコードの登録*/
function shortcode_custom_bookmark($opt, $content = null) {
    /* デフォルトの設定 */
    $width = 150; // サムネイルの横幅
    $class = 'bookmark cf'; // 全体を覆うclass
    $text = 'リンク'; // アンカーテキストがなかった時のテキスト
    /* デフォルトの設定ここまで */
    if(!empty($opt['url']) && preg_match('/^(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/', $opt['url'])) {
        if(!empty($opt['width']) && preg_match('/^[0-9]+$/', $opt['width'])) $width = $opt['width'];
        $height = round($width * 0.75);
        if(!empty($content)) $text = esc_attr($content);
        if(!empty($opt['class']) && preg_match('/^[a-zA-Z0-9 -_]+$/', $opt['class'])) $class .= ' '.$opt['class'];

        $str = '<article class="'.$class.'"><div class="bookmark_container"><figure><a href="'.$opt['url'].'" target="_blank"><img class="bookmark_thumb" align="left" border="0" src="http://s.wordpress.com/mshots/v1/'.rawurlencode($opt['url']).'?w='.$width.'" alt="'.$text.'" width="'.$width.'" height="'.$height.'" /></a></figure><header><h3><a href="'.$opt['url'].'" target="_blank">'.$text.'</a></h3></header>';
        if(!empty($opt['description'])) $str .= '<blockquote>'.mb_strimwidth(esc_attr($opt['description']), 0, 140, "...","UTF-8").'</blockquote>';

        $str .= '</div></article>';
        return $str;
    }
}
add_shortcode('bm', 'shortcode_custom_bookmark');

そうするとこんな感じに↓なります。

[bm url="http://increment-log.com/link-thumbnail-bookmarklet/" description="外部リンクをサムネイル付きで表示する「ShareHtmlメーカー」がありますが、僕はコレを使っていません。 ShareHtmlメーカーを知る前にこちらのショートコードを発見して以来ずっと使ってます。(以下の外部リンクもこのショートコードで表示してます)"]【WordPress】外部リンクをサムネイル付きで表示するショートコード用のブックマークレットを作成したよ[/bm]

※CSSは調整してね

こちらの記事を参考に組み込みました

http://increment-log.com/link-thumbnail-bookmarklet/
http://unguis.cre8or.jp/web/1385

※9/14 Getlink部分ほか少し記事修正しました