Skip to content

Instantly share code, notes, and snippets.

@marushu
Created December 4, 2021 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marushu/d16531a1d8ec579ab5bcfcf1583882fb to your computer and use it in GitHub Desktop.
Save marushu/d16531a1d8ec579ab5bcfcf1583882fb to your computer and use it in GitHub Desktop.
<?php
/**
* Embed ブログカードをカスタマイズ
* https://snow-monkey.2inc.org/manual/manual-advanced/customize-blog-card/
*/
add_filter(
'snow_monkey_oembed_blog_card_template',
function( $template, $cache ) {
$template = '';
$cache['cached_time'] = 0;
$target = false === strpos( $cache['domain'], $_SERVER['SERVER_NAME'] )
? 'target="_blank"'
: 'target="_self"';
$blog_link = $cache['permalink'];
$blog_thumb = $cache['thumbnail']
? '<img src="' . esc_url( $cache['thumbnail'] ) . '" alt="">'
: '';
$blog_title = $cache['title'];
$blog_excerpt = $cache['description']
? $cache['description']
: '';
$blog_domain = $cache['domain']
? $cache['domain']
: '';
$template .= '<a href="' . esc_html( $blog_link ) . '" ' . $target . '>' . PHP_EOL;
$template .= '<div class="wp-oembed-blog-card__figure">' . PHP_EOL;
$template .= $blog_thumb . PHP_EOL;
$template .= '</div>' . PHP_EOL;
$template .= '<div class="blog-content__wrap">' . PHP_EOL;
$template .= '<h4 class="blog-title">' . esc_html( $blog_title ) . '</h4>' . PHP_EOL;
$template .= '<div class="blog-content">' . esc_html( $blog_excerpt ) . '</div>' . PHP_EOL;
$template .= '<div class="blog-domain">' . esc_attr( $blog_domain ) . '</div>' . PHP_EOL;
$template .= '</div>' . PHP_EOL;
$template .= '</a>' . PHP_EOL;
return $template;
},
10,
2
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment