File: /var/www/html/wp-content/themes/ganryujima_new_1602/_header.php
<!DOCTYPE html>
<html class="" lang="ja" style="" ng-app="ganryuApp">
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# article: http://ogp.me/ns/article#">
<meta charset="utf-8">
<link rel="shortcut icon" href="<?= home_url() ?>/assets/img/favicon.png">
<?php
if ( is_home() ) {
$meta_excerpt = get_bloginfo( 'description' );
} elseif ( is_category() ) {
$meta_excerpt = category_description();
} elseif ( is_single() ) {
if ($post->post_excerpt) {
$meta_excerpt = $post->post_excerpt;
} else {
$meta_excerpt = strip_tags($post->post_content);
$meta_excerpt = str_replace("\n", "", $meta_excerpt);
$meta_excerpt = str_replace("\r", "", $meta_excerpt);
$meta_excerpt = mb_substr($meta_excerpt, 0, 100) . "...";
}
}
?>
<?php
$str = $post->post_content;
$searchPattern = '/<img.*?src=(["\'])(.+?)\1.*?>/i';
if (has_post_thumbnail() && ! is_archive() && ! is_front_page() && ! is_home()) {
$image_id = get_post_thumbnail_id();
$image = wp_get_attachment_image_src( $image_id, 'full');
$ogimage=$image[0];
} else if (is_singular('post') || is_singular('grjm_budo')) {
$img = get_field('news_list_thumbnail');
$imgurl = wp_get_attachment_image_src($img, '3-2');
$ogimage=$imgurl[0];
} else if (is_singular('grjm_discussion')) {
$img = get_field('discussion_index_image');
$imgurl = wp_get_attachment_image_src($img, '3-2');
$ogimage=$imgurl[0];
} else if (is_singular('grjm_tv')) {
$img = get_field('main_img');
$imgurl = wp_get_attachment_image_src($img, '3-2');
$ogimage=$imgurl[0];
} else if (is_singular('grjm_events') || is_singular('grjm_event_results')) {
$img = get_field('cover');
$imgurl = wp_get_attachment_image_src($img, '3-2');
$ogimage=$imgurl[0];
} else if (is_singular('grjm_fighter')) {
$img = get_field('fighter_img1');
$imgurl = wp_get_attachment_image_src($img, '3-2');
$ogimage=$imgurl[0];
} else if ( preg_match( $searchPattern, $str, $imgurl ) &&is_single()) {
$ogimage=$imgurl[2];
} else {
$ogimage=get_bloginfo('url')."/assets/images/dummy3-2.jpg";
}
?>
<meta name="description" content="<?php echo $meta_excerpt; ?>">
<meta name="keywords" content="格闘技,イベント,格闘家,格闘技ルール,議論,巌流島,GANRYUJIMA,スポーツ,武道,武術">
<meta name="viewport" content="width=device-width">
<title><?php wp_title( '|', true, 'right' ); bloginfo('name'); ?></title>
<meta property="fb:app_id" content="302184056577324">
<meta property="og:type" content="article">
<meta property="og:url" content="<?php the_permalink() ?>">
<meta property="og:title" content="<?php wp_title( '|', true, 'right' ); bloginfo('name'); ?>">
<meta property="og:image" content="<?php echo $ogimage; ?>">
<meta property="og:description" content="<?php echo $meta_excerpt; ?>">
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/style.css">
<?php if(wp_is_mobile() && !is_Kindle() && !is_ipad()){ ?>
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/stylesheets/import_sp.css">
<?php } else { ?>
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/stylesheets/import.css">
<?php } ?>
<link href="<?php bloginfo('template_url'); ?>/stylesheets/print.css" media="print" rel="stylesheet" type="text/css" />
<script id="twitter-wjs" src="//platform.twitter.com/widgets.js"></script>
<?php wp_head(); ?>
</head>
<?php $body_id ="";
if ( is_front_page() ) {
$body_id = 'id="index"';
} else if ( is_page() ) {
$body_id = 'id="'.$post->post_name.'"';
} else if ( is_search() ) {
$body_id = 'id="search_results"';
} else if ( is_category() ) {
$category = get_the_category();
$body_id = 'id="category_'.$category[0]->category_nicename.'"';
}
?>
<body ng-cloak class="ng-cloak" <?php echo $body_id; ?> <?php body_class(); ?> data-twttr-rendered="true" ng-controller="RootCtrl" ng-init="init()">
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/ja_JP/sdk.js#xfbml=1&version=v2.4&appId=111646695639504";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>