File: /var/www/ilya/data/www/notes.rudomilov.ru/wp-content/themes/gridfocus/header.php
<?php
/**
* @package WordPress
* @subpackage Grid_Focus
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<? if(!is_home() && !is_single() && !is_page()) { ?><meta name="robots" content="noindex,follow" /><? } ?>
<!-- social graph by Ilya -->
<meta property="og:site_name" content="<? bloginfo(); ?>" />
<?
$og_image_default = "https://notes.rudomilov.ru/wp-content/themes/gridfocus/images/default_og_image.jpg";
$og_image_filetypes = array('jpg','jpeg','gif','png');
function get_og_image($og_image_default,$og_image_filetypes) {
global $post, $posts;
$og_image = '';
$og_image_alternative = '';
$dom = new DOMDocument();
@$dom->loadHTML($post->post_content);
$dom->preserveWhiteSpace = false;
//$dom->saveHTML();
$images = $dom->getElementsByTagName('img');
foreach ($images as $image) {
if(empty($og_image_alternative)) {
list($og_image_width, $og_image_height, $og_image_type, $og_image_attr) = getimagesize($image->getAttribute('src'));
if($og_image_width>600)
$og_image_alternative = $image->getAttribute('src');
}
if($image->parentNode->nodeName=='a') {
$result = preg_match('/(' . implode('|', $og_image_filetypes) . ')/i', $image->parentNode->getAttribute('href'));
if($result) {
list($og_image_width, $og_image_height, $og_image_type, $og_image_attr) = getimagesize($image->parentNode->getAttribute('href'));
if($og_image_width>600) {
$og_image = $image->parentNode->getAttribute('href');
break;
}
}
}
}
if(empty($og_image))
if(!empty($og_image_alternative))
$og_image = $og_image_alternative;
else
$og_image = $og_image_default;
return $og_image;
}
if(is_singular()) {
global $post;
setup_postdata($post);
$og_image = get_og_image($og_image_default,$og_image_filetypes);
list($og_image_width, $og_image_height, $og_image_type, $og_image_attr) = getimagesize($og_image);
?>
<!-- social code -->
<meta property="og:url" content="<?php the_permalink(); ?>" />
<meta property="og:title" content="<?php echo strip_tags(the_title('','',FALSE)); ?> | <? bloginfo(); ?>" />
<meta property="og:type" content="article" />
<meta property="og:description" content="<? echo strip_tags(get_the_excerpt()); ?>" />
<meta property="og:image" content="<? echo $og_image; ?>" />
<meta property="og:image:width" content="<? echo $og_image_width; ?>" />
<meta property="og:image:height" content="<? echo $og_image_height; ?>" />
<meta name="Description" content="<? echo strip_tags(get_the_excerpt()); ?>" />
<? } elseif(is_home()) {
list($og_image_default_width, $og_image_default_height, $og_image_default_type, $og_image_default_attr) = getimagesize($og_image_default); ?>
<meta property="og:url" content="<? echo home_url(); ?>" />
<meta property="og:title" content="<? bloginfo(); ?>" />
<meta property="og:type" content="website" />
<meta property="og:description" content="<? bloginfo('description'); ?>" />
<meta property="og:image" content="<? echo $og_image_default; ?>" />
<meta property="og:image:width" content="<? echo $og_image_default_width; ?>" />
<meta property="og:image:height" content="<? echo $og_image_default_height; ?>" />
<? } else {
list($og_image_default_width, $og_image_default_height, $og_image_default_type, $og_image_default_attr) = getimagesize($og_image_default); ?>
<meta property="og:url" content="http://<? echo $_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]; ?>" />
<meta property="og:title" content="<? bloginfo(); ?>" />
<meta property="og:type" content="website" />
<meta property="og:description" content="<? bloginfo('description'); ?>" />
<meta property="og:image" content="<? echo $og_image_default; ?>" />
<meta property="og:image:width" content="<? echo $og_image_default_width; ?>" />
<meta property="og:image:height" content="<? echo $og_image_default_height; ?>" />
<? } ?><meta property="og:locale" content="ru_ru"/>
<!-- /social graph by Ilya -->
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<title><?php if (function_exists('is_tag') && is_tag()) { echo 'Posts tagged "'.$tag.'" - '; } elseif (is_archive()) { wp_title(''); echo ' Archive - '; } elseif (is_search()) { echo 'Search for "'.wp_specialchars($s).'" - '; } elseif (!(is_404()) && (is_single()) || (is_page())) { wp_title(''); echo ' - '; } elseif (is_404()) { echo 'Not Found - '; } bloginfo('name'); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" />
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
<?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
<?php wp_enqueue_script('jquery'); ?>
<?php wp_head(); ?>
<?php
if(is_single() || is_page()) { ?>
<link rel="author" href="https://plus.google.com/114712147124536013355" />
<? } ?>
</head>
<body>
<!-- begin of Top100 code --><script id="top100Counter" type="text/javascript" src="//counter.rambler.ru/top100.jcn?1492702"></script>
<noscript><img src="//counter.rambler.ru/top100.cnt?1492702" alt="" width="1" height="1" border="0"></noscript><!-- end of Top100 code --><!--LiveInternet counter--><script type="text/javascript">new Image().src = "//counter.yadro.ru/hit?r" + escape(document.referrer) + ((typeof(screen)=="undefined")?"" : ";s"+screen.width+"*"+screen.height+"*" + (screen.colorDepth?screen.colorDepth:screen.pixelDepth)) + ";u"+escape(document.URL) + ";" +Math.random();</script><!--/LiveInternet-->
<div id="wrapper">
<div id="masthead" class="fix">
<h1><a href="<?php echo get_settings('home'); ?>/"><?php bloginfo('name'); ?></a></h1>
<div id="blogLead">
<noindex><a href="http://www.rudomilov.ru" target="_blank"><?php echo get_avatar( get_the_author_meta("user_email",1), 42 ); ?></a></noindex>
<p id="authorIntro"><?php bloginfo('description'); ?></p>
</div>
</div>
<?php include (TEMPLATEPATH . '/navigation.strip.php'); ?>