function url_to_blog_card_tag($url) { if (!$url) { return; } $url = strip_tags($url); //URL $id = url_to_postid($url); //IDを取得(URLから投稿ID変換) if (!$id) { return; } //IDを取得できない場合はループを飛ばす global $post; $post_id = get_post($id); setup_postdata($post_id); $exce = $post_id->post_excerpt; $title = $post_id->post_title; //タイトルの取得 $date = mysql2date('Y-m-d H:i', $post_id->post_date); //投稿日の取得 $excerpt = get_content_excerpt($post_id->post_content, get_excerpt_length()); //抜粋の取得 if (is_wordpress_excerpt() && $exce) { //Wordpress固有の抜粋のとき $excerpt = $exce; } //新しいタブで開く場合 $target = is_blog_card_target_blank() ? ' target="_blank"' : ''; //$hatebu_url = preg_replace('/^https?:\/\//i', '', $url); //はてブを表示する場合 $hatebu_tag = is_blog_card_hatena_visible() ? '<div class="blog-card-hatebu"><a href="//b.hatena.ne.jp/entry/' . $url . '"' . $target . '><img src="//b.hatena.ne.jp/entry/image/' . $url . '" alt="はてブ数" /></a></div>' : ''; //サイトロゴを表示する場合 $favicon_tag = ''; if (is_favicon_enable() && get_the_favicon_url()) { //ファビコンが有効か確認 //ファビコンをイメージたいのでそのまま表示する //$favicon_tag = '<span class="blog-card-favicon"><img src="'.get_the_favicon_url().'" class="blog-card-favicon-img" alt="ファビコン" /></span>'; //はてなファビコンAPIを利用する //$favicon_tag = '<span class="blog-card-favicon"><img src="http://favicon.st-hatena.com/?url='.site_url().'" class="blog-card-favicon-img" alt="ファビコン" /></span>'; //GoogleファビコンAPIを利用する //http://www.google.com/s2/favicons?domain=nelog.jp $favicon_tag = '<span class="blog-card-favicon"><img src="http://www.google.com/s2/favicons?domain=' . get_this_site_domain() . '" class="blog-card-favicon-img" alt="ファビコン" /></span>'; } $site_logo_tag = is_blog_card_site_logo_visible() ? '<div class="blog-card-site">' . $favicon_tag . '<a href="' . home_url() . '"' . $target . '>' . get_this_site_domain() . '</a></div>' : ''; $date_tag = ''; if (is_blog_card_date_visible()) { $date_tag = '<div class="blog-card-date">' . $date . '</div>'; } //サムネイルの取得(要100×100のサムネイル設定) $thumbnail = get_the_post_thumbnail($id, 'thumb100', array('class' => 'blog-card-thumb-image', 'alt' => $title)); if (!$thumbnail) { //サムネイルが存在しない場合 $thumbnail = '<img src="' . get_template_directory_uri() . '/images/no-image.png" alt="' . $title . '" class="blog-card-thumb-image" />'; } //取得した情報からブログカードのHTMLタグを作成 $tag = '<div class="blog-card internal-blog-card"><div class="blog-card-thumbnail"><a href="' . $url . '" class="blog-card-thumbnail-link"' . $target . '>' . $thumbnail . '</a></div><div class="blog-card-content"><div class="blog-card-title"><a href="' . $url . '" class="blog-card-title-link"' . $target . '>' . $title . '</a></div><div class="blog-card-excerpt">' . $excerpt . '</div></div><div class="blog-card-footer">' . $site_logo_tag . $hatebu_tag . $date_tag . '</div></div>'; return $tag; }
function get_the_favicon_url() { if (is_favicon_enable()) { if (get_favicon_url()) { return get_favicon_url(); } else { return get_stylesheet_directory_uri() . '/images/favicon.ico'; } } }
function the_favicon_tag() { if (is_favicon_enable()) { echo '<link rel="shortcut icon" type="image/x-icon" href="' . get_the_favicon_url() . '" />' . "\n"; } }
function admin_favicon() { if (is_favicon_enable()) { echo '<link rel="shortcut icon" type="image/x-icon" href="' . get_stylesheet_directory_uri() . '/images/favicon.ico" />' . "\n"; } }