Skip to content

Instantly share code, notes, and snippets.

@outsideris
Created August 27, 2017 16:59
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 outsideris/13ee75d7f359acdf8e55659179da04ad to your computer and use it in GitHub Desktop.
Save outsideris/13ee75d7f359acdf8e55659179da04ad to your computer and use it in GitHub Desktop.
textcube meta tags 플러그인
<?php
function print_meta_tags($target) {
global $pageTitle, $blog, $entry, $defaultURL, $blogid, $service, $serviceURL, $pathURL;
$beginning_length = 200;
$beginning = UTF8::lessenAsEm(removeAllTags(stripHTML($entry['content'])), $beginning_length);
if (preg_match_all('/\[##_(1R|1L|1C|2C|3C|iMazing|Gallery)\|[^|]*\.(gif|jpg|jpeg|png|bmp|GIF|JPG|JPEG|PNG|BMP)\|.*_##\]/si', $entry['content'], $matches)) {
$split = explode("|", $matches[0][0]);
$filename = $split[1];
$imagefile = $defaultURL."/attach/".$entry['blogid']."/".$filename;
} else if(preg_match_all('/<img[^>]+?src=("|\')?([^\'">]*?)("|\')/si', $entry['content'], $matches)) {
if (preg_match_all('/\[##_ATTACH_PATH_##\]/si', $matches[2][0], $secondmatches)) {
$imagefile = "http://blog.outsider.ne.kr/attach/1".$matches[2][0];
} else {
$imagefile = $matches[2][0];
}
} else {
$imagefile = "http://blog.outsider.ne.kr/skin/blog/anti_verbose/images/title-image.jpg";
}
if ($pageTitle) {
$pageTitleStr = $pageTitle.' :: ';
}
$header = CRLF;
// facebook
$header .= '<meta property="fb:app_id" content="226652787347023">'.CRLF;
$header .= '<meta property="og:site_name" content="'.$blog['title'].'"/>'.CRLF;
$header .= '<meta property="og:type" content="blog"/>'.CRLF;
$header .= '<meta property="og:title" content="'.str_replace("\"", "'", $pageTitleStr).$blog['title'].'" />'.CRLF;
$header .= '<meta property="og:image" content="'.$imagefile.'" />'.CRLF;
$header .= '<meta property="og:url" content="'.$defaultURL.'/'.$entry['id'].'"/>'.CRLF;
$header .= '<meta property="og:description" content="'.$beginning.'"/>'.CRLF;
// twitter
$header .= '<meta name="twitter:card" content="summary">'.CRLF;
$header .= '<meta name="twitter:url" content="'.$defaultURL.'/'.$entry['id'].'">'.CRLF;
$header .= '<meta name="twitter:title" content="'.str_replace("\"", "'", $pageTitleStr).$blog['title'].'">'.CRLF;
$header .= '<meta name="twitter:description" content="'.$beginning.'">'.CRLF;
$header .= '<meta name="twitter:image" content="'.$imagefile.'">'.CRLF;
$header .= '<meta name="twitter:site" content="@outsideris">'.CRLF;
$header .= '<meta name="twitter:domain" content="blog.outsider.ne.kr">'.CRLF;
return $target.$header;
}
?>
<?xml version="1.0" encoding="utf-8"?>
<plugin version="1.0">
<title xml:lang="en">Meta Tags Plug-in</title>
<title xml:lang="ko">메타태그 출력</title>
<link>http://blog.outsider.ne.kr/</link>
<version>1.0</version>
<description xml:lang="en">Print meta tags in head tag.</description>
<description xml:lang="ko">헤드에 meta 테그를 출력합니다.</description>
<license>GPL</license>
<author xml:lang="en" link="http://blog.outsider.ne.kr/">JeongHoon Byun (Outsider)</author>
<author xml:lang="ko" link="http://blog.outsider.ne.kr/"><![CDATA[변정훈 (Outsider)]]></author>
<safety changeData="no" exposeData="no" accessLocal="no" accessRemote="no" accessRaw="no" />
<requirements>
<textcube>1.7</textcube>
</requirements>
<binding>
<tag name="OUTSIDER_META_TAGS" handler="print_meta_tags" />
</binding>
</plugin>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment