Pz-LinkCard - Version 2.3.1

Version Description

Download this release

Release Info

Developer poporon
Plugin Icon 128x128 Pz-LinkCard
Version 2.3.1
Comparing to
See all releases

Code changes from version 2.3.0 to 2.3.1

Files changed (5) hide show
  1. js/mce.js +103 -101
  2. lib/pz-linkcard-style.php +649 -647
  3. pz-linkcard.php +1833 -1833
  4. readme.txt +7 -1
  5. templete/pz-linkcard-templete.css +289 -283
js/mce.js CHANGED
@@ -1,101 +1,103 @@
1
- (function() {
2
- // 画面のどこかをクリックしたらモーダルを閉じる
3
- $("#pz-lkc-overlay,#pz-lkc-close").unbind().click(function(){
4
- $("#pz-lkc-overlay").css("display", "none");
5
- $("#pz-lkc-modal").css("display"," none");
6
- $("#pz-lkc-serif").val("");
7
- $("#pz-lkc-check").prop("checked", false);
8
- });
9
-
10
- // [ESC]キーが押されたらCLOSEをクリック
11
- $(document).keydown(function(e) {
12
- if (e.keyCode == 27) {
13
- $("#pz-lkc-close").click();
14
- }
15
- });
16
-
17
- $("#pz-lkc-url").bind('paste', function(e){
18
- if ($("#pz-lkc-url").val() == "") {
19
- var cb = undefined;
20
- if (window.clipboardData && window.clipboardData.getData) {
21
- cb = window.clipboardData.getData('Text');
22
- } else if (e.originalEvent.clipboardData && e.originalEvent.clipboardData.getData) {
23
- cb = e.originalEvent.clipboardData.getData('text/plain');
24
- }
25
- var ur = cut_url(cb);
26
- if (ur != null) {
27
- ur = ur[1];
28
- $("#pz-lkc-url").val(ur);
29
- $("#pz-lkc-url").select();
30
- return false;
31
- }
32
- }
33
- });
34
-
35
- // 挿入ボタン
36
- $("#pz-lkc-insert").unbind().click(function(){
37
- $("#pz-lkc-overlay").css("display","none");
38
- $("#pz-lkc-modal").css("display","none");
39
- if ($("#pz-lkc-url").val() != "") {
40
- var sc = "<p>[" + $("#pz-lkc-code").val() + " url=\"" + $("#pz-lkc-url").val() + "\"]</p>";
41
- tinymce.activeEditor.selection.setContent(sc);
42
- }
43
- tinymce.activeEditor.focus()
44
- $("#pz-lkc-serif").val("");
45
- $("#pz-lkc-check").prop("checked", false);
46
- });
47
-
48
- // ウィンドウのリサイズ
49
- $(window).resize(centermodal);
50
- function centermodal() {
51
- var w = $(window).width();
52
- var h = $(window).height();
53
- var mw = $("#pz-lkc-modal").outerWidth();
54
- var mh = $("#pz-lkc-modal").outerHeight();
55
- $("#pz-lkc-modal").css( {"left": ((w - mw)/2) + "px","top": ((h - mh)/2) + "px"} );
56
- }
57
-
58
- // 文字列からURLを切り出す
59
- function cut_url(s) {
60
- var ur = s.match(/((https?|ftp):\/\/[^<>{}|:;\\\*\^\"\'\[\]\s\t\n]*)/);
61
- return ur;
62
- }
63
-
64
- tinymce.create('tinymce.plugins.pzlinkcard', {
65
- init: function(ed, url){
66
- ed.addButton('pz_linkcard',{
67
- title: 'Insert Linkcard',
68
- image: url + '/button.png',
69
- cmd: 'insert_pz_linkcard'
70
- });
71
- ed.addCommand('insert_pz_linkcard', function() {
72
- $("#pz-lkc-overlay").css("display", "block");
73
- $("#pz-lkc-modal").css("display", "block");
74
- $("#pz-lkc-url").val("");
75
- var st = tinymce.activeEditor.selection.getContent();
76
- var ur = cut_url(st);
77
- if (ur != null) {
78
- ur = ur[1];
79
- } else {
80
- var cb = undefined;
81
- if (window.clipboardData && window.clipboardData.getData) {
82
- cb = window.clipboardData.getData('Text');
83
- ur = cut_url(cb);
84
- if (ur != null) {
85
- ur = ur[1];
86
- }
87
- }
88
- }
89
- $("#pz-lkc-url").val(ur);
90
- centermodal();
91
- $("#pz-lkc-url").focus();
92
- $("#pz-lkc-url").select();
93
- });
94
- },
95
- createControl: function(n, cm) {
96
- return null;
97
- }
98
- });
99
- tinymce.PluginManager.add('pz_linkcard',tinymce.plugins.pzlinkcard);
100
- tinymce.PluginManager.requireLangPack('pz_linkcard');
101
- })();
 
 
1
+ jQuery(function($){
2
+ $(function() {
3
+ // 画面のどこかをクリックしたらモーダルを閉じる
4
+ $("#pz-lkc-overlay,#pz-lkc-close").unbind().click(function(){
5
+ $("#pz-lkc-overlay").css("display", "none");
6
+ $("#pz-lkc-modal").css("display"," none");
7
+ $("#pz-lkc-serif").val("");
8
+ $("#pz-lkc-check").prop("checked", false);
9
+ });
10
+
11
+ // [ESC]キーが押されたらCLOSEをクリック
12
+ $(document).keydown(function(e) {
13
+ if (e.keyCode == 27) {
14
+ $("#pz-lkc-close").click();
15
+ }
16
+ });
17
+
18
+ $("#pz-lkc-url").bind('paste', function(e){
19
+ if ($("#pz-lkc-url").val() == "") {
20
+ var cb = undefined;
21
+ if (window.clipboardData && window.clipboardData.getData) {
22
+ cb = window.clipboardData.getData('Text');
23
+ } else if (e.originalEvent.clipboardData && e.originalEvent.clipboardData.getData) {
24
+ cb = e.originalEvent.clipboardData.getData('text/plain');
25
+ }
26
+ var ur = cut_url(cb);
27
+ if (ur != null) {
28
+ ur = ur[1];
29
+ $("#pz-lkc-url").val(ur);
30
+ $("#pz-lkc-url").select();
31
+ return false;
32
+ }
33
+ }
34
+ });
35
+
36
+ // 挿入ボタン
37
+ $("#pz-lkc-insert").unbind().click(function(){
38
+ $("#pz-lkc-overlay").css("display","none");
39
+ $("#pz-lkc-modal").css("display","none");
40
+ if ($("#pz-lkc-url").val() != "") {
41
+ var sc = "<p>[" + $("#pz-lkc-code").val() + " url=\"" + $("#pz-lkc-url").val() + "\"]</p>";
42
+ tinymce.activeEditor.selection.setContent(sc);
43
+ }
44
+ tinymce.activeEditor.focus()
45
+ $("#pz-lkc-serif").val("");
46
+ $("#pz-lkc-check").prop("checked", false);
47
+ });
48
+
49
+ // ウィンドウのリサイズ
50
+ $(window).resize(centermodal);
51
+ function centermodal() {
52
+ var w = $(window).width();
53
+ var h = $(window).height();
54
+ var mw = $("#pz-lkc-modal").outerWidth();
55
+ var mh = $("#pz-lkc-modal").outerHeight();
56
+ $("#pz-lkc-modal").css( {"left": ((w - mw)/2) + "px","top": ((h - mh)/2) + "px"} );
57
+ }
58
+
59
+ // 文字列からURLを切り出す
60
+ function cut_url(s) {
61
+ var ur = s.match(/((https?|ftp):\/\/[^<>{}|:;\\\*\^\"\'\[\]\s\t\n]*)/);
62
+ return ur;
63
+ }
64
+
65
+ tinymce.create('tinymce.plugins.pzlinkcard', {
66
+ init: function(ed, url){
67
+ ed.addButton('pz_linkcard',{
68
+ title: 'Insert Linkcard',
69
+ image: url + '/button.png',
70
+ cmd: 'insert_pz_linkcard'
71
+ });
72
+ ed.addCommand('insert_pz_linkcard', function() {
73
+ $("#pz-lkc-overlay").css("display", "block");
74
+ $("#pz-lkc-modal").css("display", "block");
75
+ $("#pz-lkc-url").val("");
76
+ var st = tinymce.activeEditor.selection.getContent();
77
+ var ur = cut_url(st);
78
+ if (ur != null) {
79
+ ur = ur[1];
80
+ } else {
81
+ var cb = undefined;
82
+ if (window.clipboardData && window.clipboardData.getData) {
83
+ cb = window.clipboardData.getData('Text');
84
+ ur = cut_url(cb);
85
+ if (ur != null) {
86
+ ur = ur[1];
87
+ }
88
+ }
89
+ }
90
+ $("#pz-lkc-url").val(ur);
91
+ centermodal();
92
+ $("#pz-lkc-url").focus();
93
+ $("#pz-lkc-url").select();
94
+ });
95
+ },
96
+ createControl: function(n, cm) {
97
+ return null;
98
+ }
99
+ });
100
+ tinymce.PluginManager.add('pz_linkcard',tinymce.plugins.pzlinkcard);
101
+ tinymce.PluginManager.requireLangPack('pz_linkcard');
102
+ });
103
+ });
lib/pz-linkcard-style.php CHANGED
@@ -1,648 +1,650 @@
1
- <?php if (!function_exists("get_option")) die; ?>
2
- <?php
3
- if (!isset($this->options['style']) || !$this->options['style']) {
4
- $css_dir = $this->upload_dir_path;
5
- $css_path = $this->upload_dir_path.'style.css';
6
- if (!is_dir($css_dir) && !wp_mkdir_p($css_dir)) {
7
- $css_path = $this->plugin_dir_path.'style.css';
8
- }
9
-
10
- $temp_name = $this->plugin_dir_path.'templete/pz-linkcard-templete.css'; // 元となるテンプレート
11
-
12
- $file_text = file_get_contents($temp_name);
13
- if ($file_text) {
14
- // バージョン
15
- $file_text = str_replace('/*VERSION*/', $this->options['plugin-version'], $file_text );
16
-
17
- // かんたん書式設定
18
- switch ($this->options['special-format']) {
19
- case 'LkC': // Pz-LkC Default
20
- $file_text = str_replace('/*EX-IMAGE*/', 'background-image: linear-gradient(#78f 0%, #78f 10%, #fff 30%);', $file_text );
21
- $file_text = str_replace('/*IN-IMAGE*/', 'background-image: linear-gradient(#ca4 0%, #ca4 10%, #fff 30%);', $file_text );
22
- $file_text = str_replace('/*TH-IMAGE*/', 'background-image: linear-gradient(#ca4 0%, #ca4 10%, #eee 30%);', $file_text );
23
- switch ($this->options['info-position']) {
24
- case '1':
25
- $file_text = str_replace('/*COLOR-INFO*/', 'color: #fff;', $file_text );
26
- $file_text = str_replace('/*COLOR-ADDED*/', 'color: #fff;', $file_text );
27
- }
28
- $file_text = str_replace('/*THUMBNAIL-POSITION*/', 'float: left;', $file_text );
29
- break;
30
- case 'smp': // Simple(サムネイルとタイトル)
31
- $file_text = str_replace('/*EX-BORDER*/', 'border: none;', $file_text );
32
- $file_text = str_replace('/*IN-BORDER*/', 'border: none;', $file_text );
33
- $file_text = str_replace('/*TH-BORDER*/', 'border: none;', $file_text );
34
- $file_text = str_replace('/*NONE-INFO*/', 'display: none !important;', $file_text );
35
- $file_text = str_replace('/*NONE-EXCERPT*/', 'display: none !important;', $file_text );
36
- break;
37
- case 'hbc': // ノーマル(はてなブログカード風)
38
- $file_text = str_replace('/*EX-BORDER*/', 'border: 1px solid rgba(0,0,0,0.1);', $file_text );
39
- $file_text = str_replace('/*IN-BORDER*/', 'border: 1px solid rgba(0,0,0,0.1);', $file_text );
40
- $file_text = str_replace('/*TH-BORDER*/', 'border: 1px solid rgba(0,0,0,0.1);', $file_text );
41
- $file_text = str_replace('/*RADIUS*/', 'border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px;', $file_text );
42
- $file_text = str_replace('/*SHADOW*/', 'box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);', $file_text );
43
- break;
44
- case 'JIN': // 見出し(テーマJIN風)
45
- $file_text = str_replace('/*MARGIN-TOP*/', 'margin-top: 24px;', $file_text );
46
- $file_text = str_replace('/*MARGIN-RIGHT*/', 'margin-right: auto;', $file_text );
47
- $file_text = str_replace('/*MARGIN-BOTTOM*/', 'margin-bottom: 30px;', $file_text );
48
- $file_text = str_replace('/*MARGIN-LEFT*/', 'margin-left: auto;', $file_text );
49
- $file_text = str_replace('/*CARD-TOP*/', 'margin-top: 24px;', $file_text );
50
- $file_text = str_replace('/*CARD-RIGHT*/', 'margin-right: 20px;', $file_text );
51
- $file_text = str_replace('/*CARD-BOTTOM*/', 'margin-bottom: 20px;', $file_text );
52
- $file_text = str_replace('/*CARD-LEFT*/', 'margin-left: 20px;', $file_text );
53
- $file_text = str_replace('/*WIDTH*/', 'max-width: 96%;', $file_text );
54
- $file_text = str_replace('/*RADIUS*/', 'border-radius: 4px; -webkit-border-radius: 4px; -moz-border-radius: 4px;', $file_text );
55
- $file_text = str_replace('/*WRAP-MARGIN*/', 'margin: 0 auto;', $file_text );
56
- $file_text = str_replace('/*THUMBNAIL-WIDTH*/', 'max-width: 150px;', $file_text );
57
- $file_text = str_replace('/*THUMBNAIL-HEIGHT*/', 'height: 108px; overflow: hidden;', $file_text );
58
- $file_text = str_replace('/*THUMBNAIL-IMG-WIDTH*/', 'width: 150px;', $file_text );
59
- $file_text = str_replace('/*HOVER*/', 'opacity: 0.8;', $file_text );
60
- $file_text = str_replace('/*OPTION*/', '.linkcard p { display: none; }', $file_text );
61
- $file_text = str_replace('/*COLOR-ADDED*/', 'color: #fff;', $file_text );
62
- $file_text = str_replace('/*SIZE-ADDED*/', 'font-size: 12px;', $file_text );
63
- $file_text = str_replace('/*HEIGHT-ADDED*/', 'line-height: 30px;', $file_text );
64
- $added_height = intval(preg_replace('/[^0-9]/', '', isset($this->options['height-added'] ) ? $this->options['height-added'] : $this->defaults['height-added'] ) );
65
- $heading_height = intval( $added_height / 2 );
66
- $heading_padding = intval( $added_height / 4 );
67
- $file_text = str_replace('/*EX-HEADING*/', 'position: absolute; top: -15px; left: 20px; padding: 0 10px; background-color: '.$this->options['ex-border-color'].'; border-radius: 2px;', $file_text );
68
- $file_text = str_replace('/*IN-HEADING*/', 'position: absolute; top: -15px; left: 20px; padding: 0 10px; background-color: '.$this->options['in-border-color'].'; border-radius: 2px;', $file_text );
69
- $file_text = str_replace('/*TH-HEADING*/', 'position: absolute; top: -15px; left: 20px; padding: 0 10px; background-color: '.$this->options['th-border-color'].'; border-radius: 2px;', $file_text );
70
- if (isset($this->options['thumbnail-resize']) && $this->options['thumbnail-resize'] == '1') {
71
- $size_title = intval(preg_replace('/[^0-9]/', '', isset($this->options['size-title']) ? $this->options['size-title'] : $this->defaults['size-title'] ) );
72
- $size_excerpt = intval(preg_replace('/[^0-9]/', '', isset($this->options['size-excerpt']) ? $this->options['size-excerpt'] : $this->defaults['size-excerpt'] ) );
73
- $height_title = intval(preg_replace('/[^0-9]/', '', isset($this->options['height-title']) ? $this->options['height-title'] : $this->defaults['height-title'] ) );
74
- $height_excerpt = intval(preg_replace('/[^0-9]/', '', isset($this->options['height-excerpt']) ? $this->options['height-excerpt'] : $this->defaults['height-excerpt'] ) );
75
- $thumbnail_width = 150;
76
- $file_text = str_replace('/*RESIZE*/',
77
- '@media screen and (max-width: 767px) {'.PHP_EOL.' .lkc-internal-wrap { max-width: 100% }'.PHP_EOL.' .lkc-external-wrap { max-width: 100% }'.PHP_EOL.' .lkc-this-wrap { max-width: 100% }'.PHP_EOL.' .lkc-title { font-size: '.intval($size_title * 0.9).'px; line-height: '.intval($height_title * 0.9).'px; }'.PHP_EOL.' .lkc-excerpt { font-size: '.intval($size_excerpt * 0.95).'px; }'.PHP_EOL.' .lkc-thumbnail { max-width: '.intval($thumbnail_width * 0.9).'px; }'.PHP_EOL.' .lkc-thumbnail-img { max-width: '.intval($thumbnail_width * 0.9).'px; }'.PHP_EOL.'}'.PHP_EOL.
78
- '@media screen and (max-width: 512px) {'.PHP_EOL.' .lkc-internal-wrap { max-width: 100% }'.PHP_EOL.' .lkc-external-wrap { max-width: 100% }'.PHP_EOL.' .lkc-this-wrap { max-width: 100% }'.PHP_EOL.' .lkc-title { font-size: '.intval($size_title * 0.8).'px; line-height: '.intval($height_title * 0.8).'px; }'.PHP_EOL.' .lkc-excerpt { font-size: '.intval($size_excerpt * 0.8).'px; }'.PHP_EOL.' .lkc-thumbnail { max-width: '.intval($thumbnail_width * 0.7).'px; }'.PHP_EOL.' .lkc-thumbnail-img { max-width: '.intval($thumbnail_width * 0.7).'px; }'.PHP_EOL.'}'.PHP_EOL.
79
- '@media screen and (max-width: 320px) {'.PHP_EOL.' .lkc-internal-wrap { max-width: 100% }'.PHP_EOL.' .lkc-external-wrap { max-width: 100% }'.PHP_EOL.' .lkc-this-wrap { max-width: 100% }'.PHP_EOL.' .lkc-title { font-size: '.intval($size_title * 0.7).'px; line-height: '.intval($height_title * 0.7).'px; }'.PHP_EOL.' .lkc-excerpt { font-size: '.intval($size_excerpt * 0.6).'px; }'.PHP_EOL.' .lkc-thumbnail { max-width: '.intval($thumbnail_width * 0.5).'px; }'.PHP_EOL.' .lkc-thumbnail-img { max-width: '.intval($thumbnail_width * 0.5).'px; }'.PHP_EOL.'}', $file_text );
80
- }
81
- break;
82
- case 'ecl': // 囲み
83
- $css = '.lkc-internal-wrap , .lkc-external-wrap , .lkc-this-wrap { transition: all 0.7s ease-in-out; border-width: 2px; }'.PHP_EOL;
84
- $css .= '.lkc-internal-wrap::before , .lkc-external-wrap::before , .lkc-this-wrap::before { content: ""; display: block; position: absolute; border: 2px solid #888888; box-sizing: border-box; width: 24px; height: 24px; transition: all 0.7s ease-in-out; top: -6px; left: -6px; border-width: 2px 0 0 2px; }'.PHP_EOL;
85
- $css .= '.lkc-internal-wrap::after , .lkc-external-wrap::after , .lkc-this-wrap::after { content: ""; display: block; position: absolute; border: 2px solid #888888; box-sizing: border-box; width: 24px; height: 24px; transition: all 0.7s ease-in-out; bottom: -6px; right: -6px; border-width: 0 2px 2px 0; }'.PHP_EOL;
86
- $css .= '.lkc-internal-wrap:hover { border-color: '.$this->options['in-bgcolor'].'; }'.PHP_EOL;
87
- $css .= '.lkc-external-wrap:hover { border-color: '.$this->options['ex-bgcolor'].'; }'.PHP_EOL;
88
- $css .= '.lkc-this-wrap:hover { border-color: '.$this->options['th-bgcolor'].'; }'.PHP_EOL;
89
- $css .= '.lkc-internal-wrap:hover::before { width: calc(100% + 12px); height: calc(100% + 12px); border-color: '.$this->options['in-bgcolor'].'; }'.PHP_EOL;
90
- $css .= '.lkc-external-wrap:hover::before { width: calc(100% + 12px); height: calc(100% + 12px); border-color: '.$this->options['ex-bgcolor'].'; }'.PHP_EOL;
91
- $css .= '.lkc-this-wrap:hover::before { width: calc(100% + 12px); height: calc(100% + 12px); border-color: '.$this->options['th-bgcolor'].'; }'.PHP_EOL;
92
- $css .= '.lkc-internal-wrap:hover::after { width: calc(100% + 12px); height: calc(100% + 12px); border-color: '.$this->options['in-bgcolor'].'; }'.PHP_EOL;
93
- $css .= '.lkc-external-wrap:hover::after { width: calc(100% + 12px); height: calc(100% + 12px); border-color: '.$this->options['ex-bgcolor'].'; }'.PHP_EOL;
94
- $css .= '.lkc-this-wrap:hover::after { width: calc(100% + 12px); height: calc(100% + 12px); border-color: '.$this->options['th-bgcolor'].'; }'.PHP_EOL;
95
- $file_text = str_replace('/*OPTION*/', $css, $file_text );
96
- break;
97
- case 'cmp': // コンパクト(Twitter風)
98
- $file_text = str_replace('/*EX-BORDER*/', 'border: 1px solid rgba(0,0,0,0.1);', $file_text );
99
- $file_text = str_replace('/*IN-BORDER*/', 'border: 1px solid rgba(0,0,0,0.1);', $file_text );
100
- $file_text = str_replace('/*TH-BORDER*/', 'border: 1px solid rgba(0,0,0,0.1);', $file_text );
101
- $file_text = str_replace('/*CONTENT-HEIGHT*/', 'height: 108px;', $file_text );
102
- $file_text = str_replace('/*WRAP-MARGIN*/', 'margin: 0;', $file_text );
103
- $file_text = str_replace('/*PADDING*/', 'padding: 0;', $file_text );
104
- $file_text = str_replace('/*RADIUS*/', 'border-radius: 16px; -webkit-border-radius: 16px; -moz-border-radius: 16px;', $file_text );
105
- $file_text = str_replace('/*CARD-TOP*/', 'margin: 0;', $file_text );
106
- $file_text = str_replace('/*CARD-RIGHT*/', '', $file_text );
107
- $file_text = str_replace('/*CARD-BOTTOM*/', '', $file_text );
108
- $file_text = str_replace('/*CARD-LEFT*/', '', $file_text );
109
- $file_text = str_replace('/*MARGIN-TITLE*/', 'margin: 30px 0 0 108px;', $file_text );
110
- $file_text = str_replace('/*MARGIN-URL*/', 'margin: 0 0 0 108px;', $file_text );
111
- $file_text = str_replace('/*MARGIN-EXCERPT*/', 'margin: 0 0 0 108px;', $file_text );
112
- $file_text = str_replace('/*CONTENT-PADDING*/', 'padding: 0;', $file_text );
113
- $file_text = str_replace('/*CONTENT-MARGIN*/', 'margin: 0;', $file_text );
114
- $content_height = intval(preg_replace('/[^0-9]/', '', isset($this->options['content-height'] ) ? $this->options['content-height'] : $this->defaults['content-height'] ) );
115
- $file_text = str_replace('/*THUMBNAIL-WIDTH*/', 'display: block; overflow: hidden;', $file_text );
116
- $file_text = str_replace('/*THUMBNAIL-HEIGHT*/', 'height: 108px;', $file_text );
117
- $file_text = str_replace('/*THUMBNAIL-IMG-WIDTH*/', 'width: 100px;', $file_text );
118
- $file_text = str_replace('/*THUMBNAIL-IMG-HEIGHT*/', 'height: 108px;', $file_text );
119
- $file_text = str_replace('/*THUMBNAIL-POSITION*/', 'float: left;', $file_text );
120
- $file_text = str_replace('/*THUMBNAIL-MARGIN*/', 'margin: 0 8px 0 0;', $file_text );
121
- $file_text = str_replace('/*THUMBNAIL-RADIUS*/', 'border-radius: 16px 0 0 16px;', $file_text );
122
- $file_text = str_replace('/*POSITION-INFO*/', 'position: absolute; top: 8px; left: 108px;', $file_text );
123
- break;
124
- case 'ref': // 反射
125
- $css = '.lkc-internal-wrap , .lkc-external-wrap , .lkc-this-wrap { overflow: hidden; }'.PHP_EOL;
126
- $css .= '.lkc-internal-wrap::before , .lkc-external-wrap::before , .lkc-this-wrap::before { content: ""; display: block; width: 500px; height: 120px; background: '.$this->options['border-color'].'; position: absolute; top: -10px; left: -500px; transform: rotate(-45deg); transition: all .3s ease-in-out; }'.PHP_EOL;
127
- $css .= '.lkc-internal-wrap:hover::before , .lkc-external-wrap:hover::before , .lkc-this-wrap:hover::before { margin-left: 300% ; }'.PHP_EOL;
128
- $file_text = str_replace('/*OPTION*/', $css, $file_text );
129
- break;
130
- case 'w95': // Windows 95
131
- $css = '.lkc-external-wrap a , .lkc-internal-wrap a , .lkc-this-wrap a { cursor: default; }'.PHP_EOL;
132
- $css .= '.lkc-card { margin: 16px; padding: 4px; border: 3px #c0c7c8 solid; background: #e0e0e0; border: 1px #87888f solid; }'.PHP_EOL;
133
- $css .= '.lkc-url { cursor: pointer; }'.PHP_EOL;
134
- $css .= '.lkc-info { margin: 0; padding: 4px; border: 1px #87888f solid; background: #0000a8; font-weight: bold; font-size: 11px; line-height: 16px; }'.PHP_EOL;
135
- $css .= '.lkc-domain { color: #fff; font-weight: normal; }'.PHP_EOL;
136
- $file_text = str_replace('/*OPTION*/', $css, $file_text );
137
- break;
138
- case 'wxp': // Windows XP
139
- $css = '.lkc-external-wrap a , .lkc-internal-wrap a , .lkc-this-wrap a { cursor: default; }'.PHP_EOL;
140
- $css .= '.lkc-card { margin: 16px; padding: 0; border: 3px #1f61e3 solid; border-radius: 5px; background: #eeecdf; }'.PHP_EOL;
141
- $css .= '.lkc-info { margin: 0; padding: 4px; background: linear-gradient(to bottom, #2790ff, #1f61e3); background: -webkit-linear-gradient(top, #2790ff, #1f61e3); font-weight: bold; font-size: 11px; line-height: 16px; }'.PHP_EOL;
142
- $css .= '.lkc-domain { color: #fff; }'.PHP_EOL;
143
- $css .= '.lkc-title-text { padding: 0 4px; }'.PHP_EOL;
144
- $css .= '.lkc-url { padding: 4px; cursor: pointer; }'.PHP_EOL;
145
- $css .= '.lkc-excerpt { padding: 4px; }'.PHP_EOL;
146
- $file_text = str_replace('/*OPTION*/', $css, $file_text );
147
- break;
148
- case 'sqr': // スクエア(WordPress標準風)
149
- $file_text = str_replace('/*HEIGHT*/', 'height: 337px;', $file_text );
150
- $file_text = str_replace('/*CONTENT-HEIGHT*/', 'height: 300px;', $file_text );
151
- $thumbnail_width = preg_replace('/[^0-9]/', '', isset($this->options['width']) ? $this->options['width'] : $this->defaults['thumbnail-width'] ) - 0;
152
- $file_text = str_replace('/*THUMBNAIL-WIDTH*/', 'display: block; overflow: hidden;', $file_text );
153
- $file_text = str_replace('/*THUMBNAIL-HEIGHT*/', 'max-height: 200px;', $file_text );
154
- $file_text = str_replace('/*THUMBNAIL-IMG-WIDTH*/', 'width: '.$thumbnail_width .'px;', $file_text );
155
- $file_text = str_replace('/*THUMBNAIL-IMG-HEIGHT*/', '', $file_text );
156
- $file_text = str_replace('/*OPTION*/', '.lkc-thumbnail { float: initial; }', $file_text );
157
- break;
158
- case 'ct1': // セロファンテープ(中央)
159
- $file_text = str_replace('/*WRAP-BEFORE*/', 'content: "";display: block;position: absolute;left: 40%;top: -16px;width: 95px;height: 25px;z-index: 2;background-color: rgba(243,245,228,0.5);border: 2px solid rgba(255,255,255,0.5);-webkit-box-shadow: 1px 1px 4px rgba(200,200,180,0.8);-moz-box-shadow: 1px 1px 4px rgba(200,200,180,0.8);box-shadow: 1px 1px 4px rgba(200,200,180,0.8);-webkit-transform: rotate(3deg);-moz-transform: rotate(3deg);-o-transform: rotate(3deg);', $file_text );
160
- $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.2);', $file_text );
161
- break;
162
- case 'ct2': // セロファンテープ(左右)
163
- $file_text = str_replace('/*MARGIN-LEFT*/', 'margin-left: 40px;', $file_text );
164
- $file_text = str_replace('/*WRAP-BEFORE*/', 'content: "";display: block;position: absolute;left: -40px;top: -4px;width: 75px;height: 25px;z-index: 2;background-color: rgba(243,245,228,0.5);border: 2px solid rgba(255,255,255,0.5);-webkit-box-shadow: 1px 1px 4px rgba(200,200,180,0.8);-moz-box-shadow: 1px 1px 4px rgba(200,200,180,0.8);box-shadow: 1px 1px 4px rgba(200,200,180,0.8);-webkit-transform: rotate(-45deg);-moz-transform: rotate(-45deg);-o-transform: rotate(-45deg);', $file_text );
165
- $file_text = str_replace('/*WRAP-AFTER*/', 'content: "";display: block;position: absolute;right: -20px;top: -2px;width: 75px;height: 25px;z-index: 2;background-color: rgba(243,245,228,0.5);border: 2px solid rgba(255,255,255,0.5);-webkit-box-shadow: 1px 1px 4px rgba(200,200,180,0.8);-moz-box-shadow: 1px 1px 4px rgba(200,200,180,0.8);box-shadow: 1px 1px 4px rgba(200,200,180,0.8);-webkit-transform: rotate(16deg);-moz-transform: rotate(16deg);-o-transform: rotate(16deg);transform: rotate(16deg);', $file_text );
166
- $file_text = str_replace('/*MARGIN-RIGHT*/', 'margin-right: 25px;', $file_text );
167
- $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.2);', $file_text );
168
- break;
169
- case 'ct3': // セロファンテープ(長め)
170
- $file_text = str_replace('/*WRAP-BEFORE*/', 'content: "";display: block;position: absolute;left: -5%;top: -12px;width: 110%;height: 25px;z-index: 2;background-color: rgba(243,245,228,0.5);border: 2px solid rgba(255,255,255,0.5);-webkit-box-shadow: 1px 1px 4px rgba(200,200,180,0.8);-moz-box-shadow: 1px 1px 4px rgba(200,200,180,0.8);box-shadow: 1px 1px 4px rgba(200,200,180,0.8);-webkit-transform: rotate(-3deg);-moz-transform: rotate(-3deg);-o-transform: rotate(-3deg);', $file_text );
171
- $file_text = str_replace('/*MARGIN-LEFT*/', 'margin-left: 32px;', $file_text );
172
- $file_text = str_replace('/*MARGIN-RIGHT*/', 'margin-right: 32px;', $file_text );
173
- $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.2);', $file_text );
174
- break;
175
- case 'ct4': // セロファンテープ(斜め)
176
- $file_text = str_replace('/*WRAP-BEFORE*/', 'content: ""; display: block; position: absolute; left: -24px; top: 0px; width: 200px; height: 25px; z-index: 2; background-color: rgba(243,245,228,0.5); border: 2px solid rgba(255,255,255,0.5); -webkit-box-shadow: 1px 1px 4px rgba(200,200,180,0.8); -moz-box-shadow: 1px 1px 4px rgba(200,200,180,0.8); box-shadow: 1px 1px 4px rgba(200,200,180,0.8); -webkit-transform: rotate(-8deg); -moz-transform: rotate(-8deg); -o-transform: rotate(-8deg);', $file_text );
177
- $file_text = str_replace('/*MARGIN-LEFT*/', 'margin-left: 24px;', $file_text );
178
- $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.2);', $file_text );
179
- break;
180
- case 'slt': // 斜め(ネタ)
181
- $file_text = str_replace('/*WRAP*/', 'transform:skew(-10deg) rotate(1deg);-webkit-transform: skew(-10deg) rotate(1deg);-moz-transform:skew(-10deg) rotate(1deg);', $file_text );
182
- $file_text = str_replace('/*MARGIN-LEFT*/', 'margin-left: 12px;', $file_text );
183
- $file_text = str_replace('/*MARGIN-RIGHT*/', 'margin-right: 30px;', $file_text );
184
- break;
185
- case '3Dr': // 立体(ネタ)
186
- $file_text = str_replace('/*WRAP*/', '-webkit-transform:perspective(150px) scale3d(0.84,0.9,1) rotate3d(1,0,0,12deg);', $file_text );
187
- $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0 20px 16px rgba(0, 0, 0, 0.6) , 0px 32px 32px rgba(0, 0, 0, 0.2) inset;', $file_text );
188
- break;
189
- case 'ppc': // 紙めくれ
190
- $file_text = str_replace('/*WRAP-AFTER*/', 'z-index: -1; content:""; height: 10px; width: 60%; position: absolute; right: 16px; bottom: 14px; left: auto; transform: skew(5deg) rotate(3deg); -webkit-transform: skew(5deg) rotate(3deg); -moz-transform: skew(5deg) rotate(3deg); box-shadow: 0 16px 16px rgba(0,0,0,1); -webkit-box-shadow: 0 16px 16px rgba(0,0,0,1); -moz-box-shadow: 0 16px 12px rgba(0,0,0,1);', $file_text );
191
- $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.8);', $file_text );
192
- $file_text = str_replace('/*OPTION*/', 'article { position: relative; z-index: 0; } article blockquote { position: relative; z-index: 0; }', $file_text );
193
- break;
194
- case 'tac': // テープと紙めくれ
195
- $file_text = str_replace('/*WRAP-BEFORE*/', 'content: ""; display: block; position: absolute; left: -24px; top: 0px; width: 200px; height: 25px; z-index: 2; background-color: rgba(243,245,228,0.5); border: 2px solid rgba(255,255,255,0.5); -webkit-box-shadow: 1px 1px 4px rgba(200,200,180,0.8); -moz-box-shadow: 1px 1px 4px rgba(200,200,180,0.8); box-shadow: 1px 1px 4px rgba(200,200,180,0.8); -webkit-transform: rotate(-8deg); -moz-transform: rotate(-8deg); -o-transform: rotate(-8deg);', $file_text );
196
- $file_text = str_replace('/*WRAP-AFTER*/', 'z-index: -1; content:""; height: 10px; width: 60%; position: absolute; right: 16px; bottom: 14px; left: auto; transform: skew(5deg) rotate(3deg); -webkit-transform: skew(5deg) rotate(3deg); -moz-transform: skew(5deg) rotate(3deg); box-shadow: 0 16px 16px rgba(0,0,0,1); -webkit-box-shadow: 0 16px 16px rgba(0,0,0,1); -moz-box-shadow: 0 16px 12px rgba(0,0,0,1);', $file_text );
197
- $file_text = str_replace('/*MARGIN-LEFT*/', 'margin-left: 24px;', $file_text );
198
- $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.8);', $file_text );
199
- $file_text = str_replace('/*OPTION*/', 'article { position: relative; z-index: 0; } article blockquote { position: relative; z-index: 0; }', $file_text );
200
- break;
201
- case 'pin': // 押しピン(綺麗な画像募集中)
202
- $file_text = str_replace('/*WRAP-AFTER*/', 'content: ""; display: block; position: absolute; background-image: url("'.$this->plugin_dir_url.'img/pin.png"); background-repeat: no-repeat; background-position: center; left: 47%; top: -16px; width: 40px; height: 40px; z-index: 1; pointer-events: none;', $file_text );
203
- break;
204
- case 'inN': // 中立青緑(イングレス風)
205
- $file_text = str_replace('/*EX-BORDER*/', 'border: 4px solid #59fbea;', $file_text );
206
- $file_text = str_replace('/*IN-BORDER*/', 'border: 4px solid #59fbea;', $file_text );
207
- $file_text = str_replace('/*TH-BORDER*/', 'border: 4px solid #59fbea;', $file_text );
208
- $file_text = str_replace('/*COLOR-TITLE*/', 'color: #59fbea;', $file_text );
209
- $file_text = str_replace('/*COLOR-URL*/', 'color: #59fbea;', $file_text );
210
- $file_text = str_replace('/*COLOR-EXCERPT*/', 'color: #59fbea;', $file_text );
211
- $file_text = str_replace('/*COLOR-INFO*/', 'color: #59fbea;', $file_text );
212
- $file_text = str_replace('/*COLOR-PLUGIN*/', 'color: #59fbea;', $file_text );
213
- $file_text = str_replace('/*EX-BGCOLOR*/', 'background-color: rgba( 35,100, 93,0.9);', $file_text );
214
- $file_text = str_replace('/*IN-BGCOLOR*/', 'background-color: rgba( 8, 25, 23,0.9);', $file_text );
215
- $file_text = str_replace('/*TH-BGCOLOR*/', 'background-color: rgba( 89,251,234,0.05);', $file_text );
216
- break;
217
- case 'inI': // 情報オレンジ(イングレス風)
218
- $file_text = str_replace('/*EX-BORDER*/', 'border: 4px solid #ebbc4a;', $file_text );
219
- $file_text = str_replace('/*IN-BORDER*/', 'border: 4px solid #ebbc4a;', $file_text );
220
- $file_text = str_replace('/*TH-BORDER*/', 'border: 4px solid #ebbc4a;', $file_text );
221
- $file_text = str_replace('/*COLOR-TITLE*/', 'color: #ebbc4a;', $file_text );
222
- $file_text = str_replace('/*COLOR-URL*/', 'color: #ebbc4a;', $file_text );
223
- $file_text = str_replace('/*COLOR-EXCERPT*/', 'color: #ebbc4a;', $file_text );
224
- $file_text = str_replace('/*COLOR-INFO*/', 'color: #ebbc4a;', $file_text );
225
- $file_text = str_replace('/*COLOR-PLUGIN*/', 'color: #ebbc4a;', $file_text );
226
- $file_text = str_replace('/*EX-BGCOLOR*/', 'background-color: rgba( 94, 75, 29,0.9);', $file_text );
227
- $file_text = str_replace('/*IN-BGCOLOR*/', 'background-color: rgba( 23, 18, 7,0.9);', $file_text );
228
- $file_text = str_replace('/*TH-BGCOLOR*/', 'background-color: rgba(235,188, 74,0.05);', $file_text );
229
- break;
230
- case 'inE': // エンライテッドカラー(イングレス風)
231
- $file_text = str_replace('/*EX-BORDER*/', 'border: 4px solid #28f428;', $file_text );
232
- $file_text = str_replace('/*IN-BORDER*/', 'border: 4px solid #28f428;', $file_text );
233
- $file_text = str_replace('/*TH-BORDER*/', 'border: 4px solid #28f428;', $file_text );
234
- $file_text = str_replace('/*COLOR-TITLE*/', 'color: #28f428;', $file_text );
235
- $file_text = str_replace('/*COLOR-URL*/', 'color: #28f428;', $file_text );
236
- $file_text = str_replace('/*COLOR-EXCERPT*/', 'color: #28f428;', $file_text );
237
- $file_text = str_replace('/*COLOR-INFO*/', 'color: #28f428;', $file_text );
238
- $file_text = str_replace('/*COLOR-PLUGIN*/', 'color: #28f428;', $file_text );
239
- $file_text = str_replace('/*EX-BGCOLOR*/', 'background-color: rgba( 16, 97, 16,0.9);', $file_text );
240
- $file_text = str_replace('/*IN-BGCOLOR*/', 'background-color: rgba( 4, 24, 4,0.9);', $file_text );
241
- $file_text = str_replace('/*TH-BGCOLOR*/', 'background-color: rgba( 40,244, 40,0.05);', $file_text );
242
- break;
243
- case 'inR': // レジスタンスカラー(イングレス風)
244
- $file_text = str_replace('/*EX-BORDER*/', 'border: 4px solid #00c2ff;', $file_text );
245
- $file_text = str_replace('/*IN-BORDER*/', 'border: 4px solid #00c2ff;', $file_text );
246
- $file_text = str_replace('/*TH-BORDER*/', 'border: 4px solid #00c2ff;', $file_text );
247
- $file_text = str_replace('/*COLOR-TITLE*/', 'color: #00c2ff;', $file_text );
248
- $file_text = str_replace('/*COLOR-URL*/', 'color: #00c2ff;', $file_text );
249
- $file_text = str_replace('/*COLOR-EXCERPT*/', 'color: #00c2ff;', $file_text );
250
- $file_text = str_replace('/*COLOR-INFO*/', 'color: #00c2ff;', $file_text );
251
- $file_text = str_replace('/*COLOR-PLUGIN*/', 'color: #00c2ff;', $file_text );
252
- $file_text = str_replace('/*EX-BGCOLOR*/', 'background-color: rgba( 0, 77,102,0.9);', $file_text );
253
- $file_text = str_replace('/*IN-BGCOLOR*/', 'background-color: rgba( 0, 19, 25,0.9);', $file_text );
254
- $file_text = str_replace('/*TH-BGCOLOR*/', 'background-color: rgba( 0,194,255,0.05);', $file_text );
255
- break;
256
- case 'sBR': // 縫い目(青&赤)
257
- $file_text = str_replace('/*EX-BORDER*/', 'border: 2px dashed rgba(255,255,255,0.5);', $file_text );
258
- $file_text = str_replace('/*IN-BORDER*/', 'border: 2px dashed rgba(255,255,255,0.5);', $file_text );
259
- $file_text = str_replace('/*TH-BORDER*/', 'border: 2px dashed rgba(255,255,255,0.5);', $file_text );
260
- $file_text = str_replace('/*EX-BGCOLOR*/', 'background: #bcddff; box-shadow: 0 0 0 5px #aabbee, 3px 3px 6px 4px rgba(0,0,0,0.6); -moz-box-shadow: 0 0 0 5px #aabbee, 3px 3px 6px 4px rgba(0,0,0,0.6); -webkit-box-shadow: 0 0 0 5px #aabbee, 3px 3px 6px 4px rgba(0,0,0,0.6);', $file_text );
261
- $file_text = str_replace('/*IN-BGCOLOR*/', 'background: #f8d0d0; box-shadow: 0 0 0 5px #e8a8a8, 3px 3px 6px 4px rgba(0,0,0,0.6); -moz-box-shadow: 0 0 0 5px #e8a8a8, 3px 3px 6px 4px rgba(0,0,0,0.6); -webkit-box-shadow: 0 0 0 5px #e8a8a8, 3px 3px 6px 4px rgba(0,0,0,0.6);', $file_text );
262
- $file_text = str_replace('/*TH-BGCOLOR*/', 'background: #f29db0; box-shadow: 0 0 0 5px #de8899, 3px 3px 6px 4px rgba(0,0,0,0.6); -moz-box-shadow: 0 0 0 5px #de8899, 3px 3px 6px 4px rgba(0,0,0,0.6); -webkit-box-shadow: 0 0 0 5px #de8899, 3px 3px 6px 4px rgba(0,0,0,0.6);', $file_text );
263
- break;
264
- case 'sGY': // 縫い目(緑&黄)
265
- $file_text = str_replace('/*EX-BORDER*/', 'border: 2px dashed rgba(255,255,255,0.5);', $file_text );
266
- $file_text = str_replace('/*IN-BORDER*/', 'border: 2px dashed rgba(255,255,255,0.5);', $file_text );
267
- $file_text = str_replace('/*TH-BORDER*/', 'border: 2px dashed rgba(255,255,255,0.5);', $file_text );
268
- $file_text = str_replace('/*EX-BGCOLOR*/', 'background: #acefdd; box-shadow: 0 0 0 5px #8abecb, 3px 3px 6px 4px rgba(0,0,0,0.6); -moz-box-shadow: 0 0 0 5px #8abecb, 3px 3px 6px 4px rgba(0,0,0,0.6); -webkit-box-shadow: 0 0 0 5px #8abecb, 3px 3px 6px 4px rgba(0,0,0,0.6);', $file_text );
269
- $file_text = str_replace('/*IN-BGCOLOR*/', 'background: #ffde51; box-shadow: 0 0 0 5px #fbca4d, 3px 3px 6px 4px rgba(0,0,0,0.6); -moz-box-shadow: 0 0 0 5px #fbca4d, 3px 3px 6px 4px rgba(0,0,0,0.6); -webkit-box-shadow: 0 0 0 5px #fbca4d, 3px 3px 6px 4px rgba(0,0,0,0.6);', $file_text );
270
- $file_text = str_replace('/*TH-BGCOLOR*/', 'background: #f0e0b0; box-shadow: 0 0 0 5px #decca0, 3px 3px 6px 4px rgba(0,0,0,0.6); -moz-box-shadow: 0 0 0 5px #decca0, 3px 3px 6px 4px rgba(0,0,0,0.6); -webkit-box-shadow: 0 0 0 5px #decca0, 3px 3px 6px 4px rgba(0,0,0,0.6);', $file_text );
271
- break;
272
- }
273
-
274
- // 文字色
275
- $file_text = str_replace('/*COLOR-TITLE*/', 'color: '.$this->options['color-title'].';', $file_text );
276
- $file_text = str_replace('/*COLOR-URL*/', 'color: '.$this->options['color-url'].';', $file_text );
277
- $file_text = str_replace('/*COLOR-EXCERPT*/', 'color: '.$this->options['color-excerpt'].';', $file_text );
278
- $file_text = str_replace('/*COLOR-INFO*/', 'color: '.$this->options['color-info'].';', $file_text );
279
- if (!$this->options['color-added']) {
280
- $this->options['color-added'] = $this->options['color-info'];
281
- $this->options['size-added'] = $this->options['size-info'];
282
- $this->options['height-added'] = $this->options['height-info'];
283
- $this->options['outline-added'] = $this->options['outline-info'];
284
- }
285
- $file_text = str_replace('/*COLOR-ADDED*/', 'color: '.$this->options['color-added'].';', $file_text );
286
- $file_text = str_replace('/*COLOR-MORE*/', 'color: '.$this->options['color-more'].';', $file_text );
287
- $file_text = str_replace('/*COLOR-PLUGIN*/', 'color: '.$this->options['color-plugin'].';', $file_text );
288
-
289
- // 文字の大きさ
290
- $file_text = str_replace('/*SIZE-TITLE*/', 'font-size: '.$this->options['size-title'].';', $file_text );
291
- $file_text = str_replace('/*SIZE-URL*/', 'font-size: '.$this->options['size-url'].';', $file_text );
292
- $file_text = str_replace('/*SIZE-EXCERPT*/', 'font-size: '.$this->options['size-excerpt'].';', $file_text );
293
- $file_text = str_replace('/*SIZE-INFO*/', 'font-size: '.$this->options['size-info'].';', $file_text );
294
- $file_text = str_replace('/*SIZE-ADDED*/', 'font-size: '.$this->options['size-added'].';', $file_text );
295
- $file_text = str_replace('/*SIZE-MORE*/', 'font-size: '.$this->options['size-more'].';', $file_text );
296
- $file_text = str_replace('/*SIZE-PLUGIN*/', 'font-size: '.$this->options['size-plugin'].';', $file_text );
297
-
298
- // 行の高さ
299
- $file_text = str_replace('/*HEIGHT-TITLE*/', 'line-height: '.$this->options['height-title'].';', $file_text );
300
- $file_text = str_replace('/*HEIGHT-URL*/', 'line-height: '.$this->options['height-url'].';', $file_text );
301
- $file_text = str_replace('/*HEIGHT-EXCERPT*/', 'line-height: '.$this->options['height-excerpt'].';', $file_text );
302
- $file_text = str_replace('/*HEIGHT-INFO*/', 'line-height: '.$this->options['height-info'].';', $file_text );
303
- $file_text = str_replace('/*HEIGHT-ADDED*/', 'line-height: '.$this->options['height-added'].';', $file_text );
304
- $file_text = str_replace('/*HEIGHT-MORE*/', 'line-height: '.$this->options['height-more'].';', $file_text );
305
- $file_text = str_replace('/*HEIGHT-PLUGIN*/', 'line-height: '.$this->options['height-plugin'].';', $file_text );
306
-
307
- // 文字の縁取り
308
- if (isset($this->options['outline-title']) && $this->options['outline-title'] == '1') {
309
- $file_text = str_replace('/*OUTCOLOR-TITLE*/', 'text-shadow: 0 -1px '.$this->options['outline-color-title'].', 1px -1px '.$this->options['outline-color-title'].', 1px 0 '.$this->options['outline-color-title'].', 1px 1px '.$this->options['outline-color-title'].', 0 1px '.$this->options['outline-color-title'].', -1px 1px '.$this->options['outline-color-title'].', -1px 0 '.$this->options['outline-color-title'].', -1px -1px '.$this->options['outline-color-title'].';', $file_text );
310
- }
311
- if (isset($this->options['outline-url']) && $this->options['outline-url'] == '1') {
312
- $file_text = str_replace('/*OUTCOLOR-URL*/', 'text-shadow: 0 -1px '.$this->options['outline-color-url'].', 1px -1px '.$this->options['outline-color-url'].', 1px 0 '.$this->options['outline-color-url'].', 1px 1px '.$this->options['outline-color-url'].', 0 1px '.$this->options['outline-color-url'].', -1px 1px '.$this->options['outline-color-url'].', -1px 0 '.$this->options['outline-color-url'].', -1px -1px '.$this->options['outline-color-url'].';', $file_text );
313
- }
314
- if (isset($this->options['outline-excerpt']) && $this->options['outline-excerpt'] == '1') {
315
- $file_text = str_replace('/*OUTCOLOR-EXCERPT*/','text-shadow: 0 -1px '.$this->options['outline-color-excerpt'].', 1px -1px '.$this->options['outline-color-excerpt'].', 1px 0 '.$this->options['outline-color-excerpt'].', 1px 1px '.$this->options['outline-color-excerpt'].', 0 1px '.$this->options['outline-color-excerpt'].', -1px 1px '.$this->options['outline-color-excerpt'].', -1px 0 '.$this->options['outline-color-excerpt'].', -1px -1px '.$this->options['outline-color-excerpt'].';', $file_text );
316
- }
317
- if (isset($this->options['outline-info']) && $this->options['outline-info'] == '1') {
318
- $file_text = str_replace('/*OUTCOLOR-INFO*/', 'text-shadow: 0 -1px '.$this->options['outline-color-info'].', 1px -1px '.$this->options['outline-color-info'].', 1px 0 '.$this->options['outline-color-info'].', 1px 1px '.$this->options['outline-color-info'].', 0 1px '.$this->options['outline-color-info'].', -1px 1px '.$this->options['outline-color-info'].', -1px 0 '.$this->options['outline-color-info'].', -1px -1px '.$this->options['outline-color-info'].';', $file_text );
319
- }
320
- if (isset($this->options['outline-added']) && $this->options['outline-added'] == '1') {
321
- $file_text = str_replace('/*OUTCOLOR-ADDED*/', 'text-shadow: 0 -1px '.$this->options['outline-color-added'].', 1px -1px '.$this->options['outline-color-added'].', 1px 0 '.$this->options['outline-color-added'].', 1px 1px '.$this->options['outline-color-added'].', 0 1px '.$this->options['outline-color-added'].', -1px 1px '.$this->options['outline-color-added'].', -1px 0 '.$this->options['outline-color-added'].', -1px -1px '.$this->options['outline-color-added'].';', $file_text );
322
- }
323
- if (isset($this->options['outline-more']) && $this->options['outline-more'] == '1') {
324
- $file_text = str_replace('/*OUTCOLOR-MORE*/', 'text-shadow: 0 -1px '.$this->options['outline-color-more'].', 1px -1px '.$this->options['outline-color-more'].', 1px 0 '.$this->options['outline-color-more'].', 1px 1px '.$this->options['outline-color-more'].', 0 1px '.$this->options['outline-color-more'].', -1px 1px '.$this->options['outline-color-more'].', -1px 0 '.$this->options['outline-color-more'].', -1px -1px '.$this->options['outline-color-more'].';', $file_text );
325
- }
326
- if (isset($this->options['outline-plugin']) && $this->options['outline-plugin'] == '1') {
327
- $file_text = str_replace('/*OUTCOLOR-PLUGIN*/', 'text-shadow: 0 -1px '.$this->options['outline-color-plugin'].', 1px -1px '.$this->options['outline-color-plugin'].', 1px 0 '.$this->options['outline-color-plugin'].', 1px 1px '.$this->options['outline-color-plugin'].', 0 1px '.$this->options['outline-color-plugin'].', -1px 1px '.$this->options['outline-color-plugin'].', -1px 0 '.$this->options['outline-color-plugin'].', -1px -1px '.$this->options['outline-color-plugin'].';', $file_text );
328
- }
329
-
330
- // カードの周りへの余白
331
- if ($this->options['margin-top']) {
332
- $file_text = str_replace('/*MARGIN-TOP*/', 'margin-top: '.$this->options['margin-top'].';', $file_text );
333
- }
334
- if ($this->options['margin-right']) {
335
- $file_text = str_replace('/*MARGIN-RIGHT*/', 'margin-right: '.$this->options['margin-right'].';', $file_text );
336
- }
337
- if ($this->options['margin-bottom']) {
338
- $file_text = str_replace('/*MARGIN-BOTTOM*/', 'margin-bottom: '.$this->options['margin-bottom'].';', $file_text );
339
- }
340
- if ($this->options['margin-left']) {
341
- $file_text = str_replace('/*MARGIN-LEFT*/', 'margin-left: '.$this->options['margin-left'].';', $file_text );
342
- }
343
-
344
- // カードの余白等調整
345
- $file_text = str_replace('/*PADDING*/', 'padding: 0;', $file_text );
346
-
347
- // カード内側の余白
348
- if ($this->options['card-top']) {
349
- $file_text = str_replace('/*CARD-TOP*/', 'margin-top: '.$this->options['card-top'].';', $file_text );
350
- } else {
351
- $file_text = str_replace('/*CARD-TOP*/', 'margin-top: 7px;', $file_text );
352
- }
353
- if ($this->options['card-right']) {
354
- $file_text = str_replace('/*CARD-RIGHT*/', 'margin-right: '.$this->options['card-right'].';', $file_text );
355
- } else {
356
- $file_text = str_replace('/*CARD-RIGHT*/', 'margin-right: 7px;', $file_text );
357
- }
358
- if ($this->options['card-bottom']) {
359
- $file_text = str_replace('/*CARD-BOTTOM*/', 'margin-bottom: '.$this->options['card-bottom'].';', $file_text );
360
- } else {
361
- $file_text = str_replace('/*CARD-BOTTOM*/', 'margin-bottom: 7px;', $file_text );
362
- }
363
- if ($this->options['card-left']) {
364
- $file_text = str_replace('/*CARD-LEFT*/', 'margin-left: '.$this->options['card-left'].';', $file_text );
365
- } else {
366
- $file_text = str_replace('/*CARD-LEFT*/', 'margin-left: 7px;', $file_text );
367
- }
368
-
369
- // img のスタイルを強制リセット
370
- if (isset($this->options['style-reset-img'])) {
371
- $file_text = str_replace('/*RESET-IMG*/', 'margin: 0 !important; padding: 0; border: none;', $file_text );
372
- $file_text = str_replace('/*STATIC*/', 'position: static !important;', $file_text );
373
- $file_text = str_replace('/*IMPORTANT*/', '!important', $file_text );
374
- } else {
375
- $file_text = str_replace('/*IMPORTANT*/', '', $file_text );
376
- }
377
-
378
- // 外部リンク背景
379
- if ($this->options['ex-bgcolor']) {
380
- $file_text = str_replace('/*EX-BGCOLOR*/', 'background-color: '.$this->options['ex-bgcolor'].';', $file_text );
381
- }
382
- if ($this->options['ex-image']) {
383
- if (preg_match('/https?(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/', $this->options['ex-image'])) {
384
- $file_text = str_replace('/*EX-IMAGE*/', 'background-image: url("'.$this->options['ex-image'].'");', $file_text );
385
- } else {
386
- $file_text = str_replace('/*EX-IMAGE*/', 'background-image: '.$this->options['ex-image'].';', $file_text );
387
- }
388
- }
389
-
390
- // 内部リンク背景
391
- if ($this->options['in-bgcolor']) {
392
- $file_text = str_replace('/*IN-BGCOLOR*/', 'background-color: '.$this->options['in-bgcolor'].';', $file_text );
393
- }
394
- if ($this->options['in-image']) {
395
- if (preg_match('/https?(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/', $this->options['in-image'])) {
396
- $file_text = str_replace('/*IN-IMAGE*/', 'background-image: url("'.$this->options['in-image'].'");', $file_text );
397
- } else {
398
- $file_text = str_replace('/*IN-IMAGE*/', 'background-image: '.$this->options['in-image'].';', $file_text );
399
- }
400
- }
401
-
402
- // 同ページリンク背景色
403
- if ($this->options['th-bgcolor']) {
404
- $file_text = str_replace('/*TH-BGCOLOR*/', 'background-color: '.$this->options['th-bgcolor'].';', $file_text );
405
- }
406
- if ($this->options['th-image']) {
407
- if (preg_match('/https?(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/', $this->options['th-image'])) {
408
- $file_text = str_replace('/*TH-IMAGE*/', 'background-image: url("'.$this->options['th-image'].'");', $file_text );
409
- } else {
410
- $file_text = str_replace('/*TH-IMAGE*/', 'background-image: '.$this->options['th-image'].';', $file_text );
411
- }
412
- }
413
-
414
- // センタリング指定あり
415
- if (isset($this->options['centering']) && $this->options['centering'] == '1') {
416
- $file_text = str_replace('/*WRAP-MARGIN*/', 'margin: 0 auto;', $file_text );
417
- $file_text = str_replace('/*HATENA-WRAP-MARGIN*/', 'margin: 0 auto;', $file_text );
418
- } else {
419
- $file_text = str_replace('/*WRAP-MARGIN*/', 'margin: 0;', $file_text );
420
- $file_text = str_replace('/*HATENA-WRAP-MARGIN*/', 'margin: 0;', $file_text );
421
- }
422
-
423
- // 角まる指定あり
424
- switch ($this->options['radius']) {
425
- case null:
426
- $file_text = str_replace('/*RADIUS*/', '', $file_text );
427
- $file_text = str_replace('/*THUMBNAIL-RADIUS*/', '', $file_text );
428
- break;
429
- case '2':
430
- $file_text = str_replace('/*RADIUS*/', 'border-radius: 4px; -webkit-border-radius: 4px; -moz-border-radius: 4px;', $file_text );
431
- $file_text = str_replace('/*THUMBNAIL-RADIUS*/', 'border-radius: 2px; -webkit-border-radius: 2px; -moz-border-radius: 2px;', $file_text );
432
- break;
433
- case '1':
434
- $file_text = str_replace('/*RADIUS*/', 'border-radius: 8px; -webkit-border-radius: 8px; -moz-border-radius: 8px;', $file_text );
435
- $file_text = str_replace('/*THUMBNAIL-RADIUS*/', 'border-radius: 6px; -webkit-border-radius: 6px; -moz-border-radius: 6px;', $file_text );
436
- break;
437
- case '3':
438
- $file_text = str_replace('/*RADIUS*/', 'border-radius: 16px; -webkit-border-radius: 16px; -moz-border-radius: 16px;', $file_text );
439
- $file_text = str_replace('/*THUMBNAIL-RADIUS*/', 'border-radius: 8px; -webkit-border-radius: 8px; -moz-border-radius: 8px;', $file_text );
440
- break;
441
- case '4':
442
- $file_text = str_replace('/*RADIUS*/', 'border-radius: 32px; -webkit-border-radius: 32px; -moz-border-radius: 32px;', $file_text );
443
- $file_text = str_replace('/*THUMBNAIL-RADIUS*/', 'border-radius: 12px; -webkit-border-radius: 12px; -moz-border-radius: 12px;', $file_text );
444
- break;
445
- case '5':
446
- $file_text = str_replace('/*RADIUS*/', 'border-radius: 64px; -webkit-border-radius: 64px; -moz-border-radius: 64px;', $file_text );
447
- $file_text = str_replace('/*THUMBNAIL-RADIUS*/', 'border-radius: 16px; -webkit-border-radius: 16px; -moz-border-radius: 16px;', $file_text );
448
- break;
449
- }
450
-
451
- // 影あり
452
- if (isset($this->options['shadow']) && $this->options['shadow'] == '1') {
453
- if (isset($this->options['shadow-inset']) && $this->options['shadow-inset'] == '1') {
454
- $file_text = str_replace('/*SHADOW*/', 'box-shadow: 8px 8px 8px rgba(0, 0, 0, 0.5) , 0 0 16px rgba(0, 0, 0, 0.3) inset;', $file_text );
455
- } else {
456
- $file_text = str_replace('/*SHADOW*/', 'box-shadow: 8px 8px 8px rgba(0, 0, 0, 0.5);', $file_text );
457
- }
458
- } else {
459
- if (isset($this->options['shadow-inset']) && $this->options['shadow-inset'] == '1') {
460
- $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0 0 16px rgba(0, 0, 0, 0.5) inset;', $file_text );
461
- }
462
- }
463
-
464
- // マウスを乗せたとき
465
- switch ($this->options['hover']) {
466
- case '1':
467
- $file_text = str_replace('/*HOVER*/', 'opacity: 0.8;', $file_text );
468
- break;
469
- case '2':
470
- $file_text = str_replace('/*WRAP*/', 'transition: all 0.3s ease 0s;', $file_text );
471
- $file_text = str_replace('/*HOVER*/', 'box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25); transform: translateY(-4px);', $file_text );
472
- break;
473
- case '3':
474
- $file_text = str_replace('/*WRAP*/', 'transition: all 0.3s ease 0s;', $file_text );
475
- $file_text = str_replace('/*HOVER*/', 'box-shadow: 16px 16px 16px rgba(0, 0, 0, 0.5); transform: translateY(-4px);', $file_text );
476
- break;
477
- case '7':
478
- $file_text = str_replace('/*WRAP*/', 'transition: all 0.3s ease 0s;', $file_text );
479
- $file_text = str_replace('/*HOVER*/', 'border-radius: 40px;', $file_text );
480
- break;
481
- }
482
-
483
- // サムネイルの位置とサイズ
484
- $thumbnail_width = intval(preg_replace('/[^0-9]/', '', isset($this->options['thumbnail-width']) ? $this->options['thumbnail-width'] : $this->defaults['thumbnail-width'] ) );
485
- $thumbnail_height = intval(preg_replace('/[^0-9]/', '', isset($this->options['thumbnail-height'] ) ? $this->options['thumbnail-height'] : $this->defaults['thumbnail-height'] ) );
486
- $content_width = intval(preg_replace('/[^0-9]/', '', isset($this->options['width']) ? $this->options['width'] : $this->defaults['thumbnail-width'] ) );
487
- $content_height = intval(preg_replace('/[^0-9]/', '', isset($this->options['content-height'] ) ? $this->options['content-height'] : $this->defaults['content-height'] ) );
488
- switch ($this->options['thumbnail-position']) {
489
- case '1':
490
- $file_text = str_replace('/*THUMBNAIL-POSITION*/', 'float: right;', $file_text );
491
- $file_text = str_replace('/*THUMBNAIL-MARGIN*/', 'margin: 0 6px 4px 4px;', $file_text );
492
- $file_text = str_replace('/*THUMBNAIL-WIDTH*/', 'max-width: '.$thumbnail_width .'px;', $file_text );
493
- $file_text = str_replace('/*THUMBNAIL-HEIGHT*/', 'max-height: '.$thumbnail_height.'px;', $file_text );
494
- $file_text = str_replace('/*THUMBNAIL-IMG-WIDTH*/', 'width: '.$thumbnail_width .'px;', $file_text );
495
- $file_text = str_replace('/*THUMBNAIL-IMG-HEIGHT*/','max-height: '.$thumbnail_height.'px;', $file_text );
496
- break;
497
- case '2':
498
- $file_text = str_replace('/*THUMBNAIL-POSITION*/', 'float: left;', $file_text );
499
- $file_text = str_replace('/*THUMBNAIL-MARGIN*/', 'margin: 0 6px 4px 4px;', $file_text );
500
- $file_text = str_replace('/*THUMBNAIL-WIDTH*/', 'max-width: '.$thumbnail_width .'px;', $file_text );
501
- $file_text = str_replace('/*THUMBNAIL-HEIGHT*/', 'max-height: '.$thumbnail_height.'px;', $file_text );
502
- $file_text = str_replace('/*THUMBNAIL-IMG-WIDTH*/', 'width: '.$thumbnail_width .'px;', $file_text );
503
- $file_text = str_replace('/*THUMBNAIL-IMG-HEIGHT*/','max-height: '.$thumbnail_height.'px;', $file_text );
504
- break;
505
- case '3':
506
- $file_text = str_replace('/*THUMBNAIL-POSITION*/', 'display: block;', $file_text );
507
- $file_text = str_replace('/*THUMBNAIL-MARGIN*/', 'margin: 0 6px 4px 4px;', $file_text );
508
- $file_text = str_replace('/*THUMBNAIL-WIDTH*/', '', $file_text );
509
- $file_text = str_replace('/*THUMBNAIL-HEIGHT*/', 'height: '.$thumbnail_height.'px; overflow: hidden;', $file_text );
510
- $file_text = str_replace('/*THUMBNAIL-IMG-WIDTH*/', 'width: '.$content_width .'px;', $file_text );
511
- $file_text = str_replace('/*THUMBNAIL-IMG-HEIGHT*/','', $file_text );
512
- break;
513
- }
514
-
515
- // サムネイル影あり
516
- if (isset($this->options['thumbnail-shadow']) && $this->options['thumbnail-shadow'] == '1') {
517
- $file_text = str_replace('/*THUMBNAIL-SHADOW*/', 'box-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);', $file_text );
518
- }
519
-
520
- // サムネイルのリサイズ
521
- if (isset($this->options['thumbnail-resize']) && $this->options['thumbnail-resize'] == '1') {
522
- $size_title = intval(preg_replace('/[^0-9]/', '', isset($this->options['size-title']) ? $this->options['size-title'] : $this->defaults['size-title'] ) );
523
- $size_excerpt = intval(preg_replace('/[^0-9]/', '', isset($this->options['size-excerpt']) ? $this->options['size-excerpt'] : $this->defaults['size-excerpt'] ) );
524
- $height_title = intval(preg_replace('/[^0-9]/', '', isset($this->options['height-title']) ? $this->options['height-title'] : $this->defaults['height-title'] ) );
525
- $height_excerpt = intval(preg_replace('/[^0-9]/', '', isset($this->options['height-excerpt']) ? $this->options['height-excerpt'] : $this->defaults['height-excerpt'] ) );
526
- $thumbnail_width = intval(preg_replace('/[^0-9]/', '', isset($this->options['thumbnail-width']) ? $this->options['thumbnail-width'] : $this->defaults['thumbnail-width'] ) );
527
- $file_text = str_replace('/*RESIZE*/',
528
- '@media screen and (max-width: 600px) {'.PHP_EOL.' .lkc-title { font-size: '.intval($size_title * 0.9).'px; line-height: '.intval($height_title * 0.9).'px; }'.PHP_EOL.' .lkc-excerpt { font-size: '.intval($size_excerpt * 0.95).'px; }'.PHP_EOL.' .lkc-thumbnail { max-width: '.intval($thumbnail_width * 0.9).'px; }'.PHP_EOL.' .lkc-thumbnail-img { max-width: '.intval($thumbnail_width * 0.9).'px; }'.PHP_EOL.'}'.PHP_EOL.
529
- '@media screen and (max-width: 480px) {'.PHP_EOL.' .lkc-title { font-size: '.intval($size_title * 0.8).'px; line-height: '.intval($height_title * 0.8).'px; }'.PHP_EOL.' .lkc-excerpt { font-size: '.intval($size_excerpt * 0.8).'px; }'.PHP_EOL.' .lkc-thumbnail { max-width: '.intval($thumbnail_width * 0.7).'px; }'.PHP_EOL.' .lkc-thumbnail-img { max-width: '.intval($thumbnail_width * 0.7).'px; }'.PHP_EOL.'}'.PHP_EOL.
530
- '@media screen and (max-width: 320px) {'.PHP_EOL.' .lkc-title { font-size: '.intval($size_title * 0.7).'px; line-height: '.intval($height_title * 0.7).'px; }'.PHP_EOL.' .lkc-excerpt { font-size: '.intval($size_excerpt * 0.6).'px; }'.PHP_EOL.' .lkc-thumbnail { max-width: '.intval($thumbnail_width * 0.5).'px; }'.PHP_EOL.' .lkc-thumbnail-img { max-width: '.intval($thumbnail_width * 0.5).'px; }'.PHP_EOL.'}', $file_text );
531
- }
532
-
533
- // 横幅
534
- if ($this->options['width']) {
535
- $file_text = str_replace('/*WIDTH*/', 'max-width: '.$this->options['width'].';', $file_text );
536
- } else {
537
- $file_text = str_replace('/*WIDTH*/', 'max-width: 100%;', $file_text );
538
- }
539
-
540
- // タイトルを折り返さない
541
- if ($this->options['nowrap-title']) {
542
- $file_text = str_replace('/*NOWRAP-TITLE*/', 'white-space: nowrap; text-overflow: ellipsis;', $file_text );
543
- }
544
-
545
- // URLを折り返さない
546
- if ($this->options['nowrap-url']) {
547
- $file_text = str_replace('/*NOWRAP-URL*/', 'white-space: nowrap; text-overflow: ellipsis;', $file_text );
548
- }
549
-
550
- // 記事情報の高さ
551
- if ($this->options['content-height']) {
552
- $file_text = str_replace('/*CONTENT-HEIGHT*/', 'height: '.$this->options['content-height'].';', $file_text );
553
- }
554
-
555
- // 枠線の太さ
556
- $border = (preg_replace('/[^0-9]/', '', $this->options['border-width']) - 0).'px ';
557
- $border .= (isset($this->options['border-style']) ? $this->options['border-style'] : $this->defaults['border-style']).' ';
558
- $ex_border = $border.(isset($this->options['ex-border-color']) ? $this->options['ex-border-color'] : $this->defaults['ex-border-color']).';';
559
- $in_border = $border.(isset($this->options['in-border-color']) ? $this->options['in-border-color'] : $this->defaults['in-border-color']).';';
560
- $th_border = $border.(isset($this->options['th-border-color']) ? $this->options['th-border-color'] : $this->defaults['th-border-color']).';';
561
- $file_text = str_replace('/*EX-BORDER*/', 'border: '.$ex_border, $file_text );
562
- $file_text = str_replace('/*IN-BORDER*/', 'border: '.$in_border, $file_text );
563
- $file_text = str_replace('/*TH-BORDER*/', 'border: '.$th_border, $file_text );
564
-
565
- // 抜粋文の部分を凹ませる
566
- if (isset($this->options['content-inset']) && $this->options['content-inset'] == '1') {
567
- $file_text = str_replace('/*CONTENT-PADDING*/', 'padding: 6px;', $file_text );
568
- $file_text = str_replace('/*CONTENT-INSET*/', 'box-shadow: 4px 4px 4px rgba(0, 0, 0, 0.5) inset;', $file_text );
569
- $file_text = str_replace('/*CONTENT-BGCOLOR*/', 'background-color: rgba(255, 255, 255, 0.8 );', $file_text );
570
- }
571
-
572
- // 記事情報のマージン
573
- $file_text = str_replace('/*CONTENT-MARGIN*/', 'margin: 6px 0 0 0;', $file_text );
574
-
575
- // 抜粋文のマージン
576
- $file_text = str_replace('/*MARGIN-EXCERPT*/', 'margin: 0;', $file_text );
577
-
578
- // サイト情報の区切り線
579
- if (isset($this->options['separator']) && $this->options['separator'] == '1') {
580
- switch ($this->options['info-position']) {
581
- case '1':
582
- $file_text = str_replace('/*SEPARATOR*/', 'border-top: 1px solid '.$this->options['color-info'].';', $file_text );
583
- break;
584
- case '2':
585
- $file_text = str_replace('/*SEPARATOR*/', 'border-bottom: 1px solid '.$this->options['color-info'].';', $file_text );
586
- break;
587
- }
588
- }
589
-
590
- // 付加情報
591
- if (isset($this->options['heading']) && $this->options['heading'] == '1') {
592
- $added_height = intval(preg_replace('/[^0-9]/', '', isset($this->options['height-added'] ) ? $this->options['height-added'] : $this->defaults['height-added'] ) );
593
- $heading_height = intval( $added_height / 2 );
594
- $heading_padding = intval( $added_height / 4 );
595
- $file_text = str_replace('/*EX-HEADING*/', 'position: absolute; top: -'.$heading_height.'px; left: 20px; padding: 0 '.$heading_padding.'px; background-color: '.$this->options['ex-border-color'].'; border-radius: 2px;', $file_text );
596
- $file_text = str_replace('/*IN-HEADING*/', 'position: absolute; top: -'.$heading_height.'px; left: 20px; padding: 0 '.$heading_padding.'px; background-color: '.$this->options['in-border-color'].'; border-radius: 2px;', $file_text );
597
- $file_text = str_replace('/*TH-HEADING*/', 'position: absolute; top: -'.$heading_height.'px; left: 20px; padding: 0 '.$heading_padding.'px; background-color: '.$this->options['th-border-color'].'; border-radius: 2px;', $file_text );
598
- }
599
-
600
- // 続きを読むボタン
601
- switch ($this->options['flg-more']) {
602
- case '1':
603
- $file_text = str_replace('/*STYLE-MORE*/', 'padding: 4px; margin: 4px 0;', $file_text );
604
- break;
605
- case '2':
606
- $file_text = str_replace('/*STYLE-MORE*/', 'border: 1px solid #888; text-align: center; padding: 4px; margin: 4px 0;', $file_text );
607
- break;
608
- case '3':
609
- $file_text = str_replace('/*STYLE-MORE*/', 'border: 1px solid #888; border-radius: 6px; text-align: center; padding: 4px; margin: 4px 0; background-color: #46f;', $file_text );
610
- break;
611
- case '4':
612
- $file_text = str_replace('/*STYLE-MORE*/', 'border: 1px solid #888; border-radius: 6px; text-align: center; padding: 4px; margin: 4px 0; background-color: #888;', $file_text );
613
- break;
614
- }
615
-
616
- // アンカーの文字装飾
617
- if (isset($this->options['flg-anker']) && $this->options['flg-anker'] == '1') {
618
- $file_text = str_replace('/*ANKER*/', 'text-decoration: none !important;', $file_text );
619
- }
620
-
621
- // 追加CSS
622
- if (isset($this->options['css-add'])) {
623
- $file_text = str_replace('/*CSS-ADD*/', $this->options['css-add'], $file_text );
624
- } else {
625
- $file_text = str_replace('/*CSS-ADD*/', '', $file_text );
626
- }
627
-
628
- // ぽぽづれ。へのリンクを表示する
629
- if (isset($this->options['plugin-link']) && $this->options['plugin-link'] == '1') {
630
- $file_text = str_replace('/*CREDIT*/', 'display: block;', $file_text );
631
- } else {
632
- $file_text = str_replace('/*CREDIT*/', 'display: none;', $file_text );
633
- }
634
-
635
- $result = file_put_contents($css_path, $file_text);
636
- global $pagenow;
637
- if (isset($pagenow) && $pagenow == 'options-general.php') {
638
- if ($result == true) {
639
- echo '<div class="updated fade"><p><strong>'.__('Style sheet saved.', $this->text_domain).'</strong></p></div>';
640
- } else {
641
- echo '<div class="error fade"><p><strong>'.__('Style sheet failed.', $this->text_domain).'</strong></p></div>';
642
- }
643
- }
644
- }
645
- unset($temp_name);
646
- unset($file_text);
647
- unset($result);
 
 
648
  }
1
+ <?php if (!function_exists("get_option")) die; ?>
2
+ <?php
3
+ if (!isset($this->options['style']) || !$this->options['style']) {
4
+ $css_dir = $this->upload_dir_path;
5
+ $css_path = $this->upload_dir_path.'style.css';
6
+ if (!is_dir($css_dir) && !wp_mkdir_p($css_dir)) {
7
+ $css_path = $this->plugin_dir_path.'style.css';
8
+ }
9
+
10
+ $temp_name = $this->plugin_dir_path.'templete/pz-linkcard-templete.css'; // 元となるテンプレート
11
+
12
+ $file_text = file_get_contents($temp_name);
13
+ if ($file_text) {
14
+ // バージョン
15
+ $file_text = str_replace('/*VERSION*/', $this->options['plugin-version'], $file_text );
16
+
17
+ // かんたん書式設定
18
+ switch ($this->options['special-format']) {
19
+ case 'LkC': // Pz-LkC Default
20
+ $file_text = str_replace('/*EX-IMAGE*/', 'background-image: linear-gradient(#78f 0%, #78f 10%, #fff 30%);', $file_text );
21
+ $file_text = str_replace('/*IN-IMAGE*/', 'background-image: linear-gradient(#ca4 0%, #ca4 10%, #fff 30%);', $file_text );
22
+ $file_text = str_replace('/*TH-IMAGE*/', 'background-image: linear-gradient(#ca4 0%, #ca4 10%, #eee 30%);', $file_text );
23
+ switch ($this->options['info-position']) {
24
+ case '1':
25
+ $file_text = str_replace('/*COLOR-INFO*/', 'color: #fff;', $file_text );
26
+ $file_text = str_replace('/*COLOR-ADDED*/', 'color: #fff;', $file_text );
27
+ }
28
+ $file_text = str_replace('/*THUMBNAIL-POSITION*/', 'float: left;', $file_text );
29
+ break;
30
+ case 'smp': // Simple(サムネイルとタイトル)
31
+ $file_text = str_replace('/*EX-BORDER*/', 'border: none;', $file_text );
32
+ $file_text = str_replace('/*IN-BORDER*/', 'border: none;', $file_text );
33
+ $file_text = str_replace('/*TH-BORDER*/', 'border: none;', $file_text );
34
+ $file_text = str_replace('/*NONE-INFO*/', 'display: none !important;', $file_text );
35
+ $file_text = str_replace('/*NONE-EXCERPT*/', 'display: none !important;', $file_text );
36
+ break;
37
+ case 'hbc': // ノーマル(はてなブログカード風)
38
+ $file_text = str_replace('/*EX-BORDER*/', 'border: 1px solid rgba(0,0,0,0.1);', $file_text );
39
+ $file_text = str_replace('/*IN-BORDER*/', 'border: 1px solid rgba(0,0,0,0.1);', $file_text );
40
+ $file_text = str_replace('/*TH-BORDER*/', 'border: 1px solid rgba(0,0,0,0.1);', $file_text );
41
+ $file_text = str_replace('/*RADIUS*/', 'border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px;', $file_text );
42
+ $file_text = str_replace('/*SHADOW*/', 'box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);', $file_text );
43
+ break;
44
+ case 'JIN': // 見出し(テーマJIN風)
45
+ $file_text = str_replace('/*MARGIN-TOP*/', 'margin-top: 24px;', $file_text );
46
+ $file_text = str_replace('/*MARGIN-RIGHT*/', 'margin-right: auto;', $file_text );
47
+ $file_text = str_replace('/*MARGIN-BOTTOM*/', 'margin-bottom: 30px;', $file_text );
48
+ $file_text = str_replace('/*MARGIN-LEFT*/', 'margin-left: auto;', $file_text );
49
+ $file_text = str_replace('/*CARD-TOP*/', 'margin-top: 24px;', $file_text );
50
+ $file_text = str_replace('/*CARD-RIGHT*/', 'margin-right: 20px;', $file_text );
51
+ $file_text = str_replace('/*CARD-BOTTOM*/', 'margin-bottom: 20px;', $file_text );
52
+ $file_text = str_replace('/*CARD-LEFT*/', 'margin-left: 20px;', $file_text );
53
+ $file_text = str_replace('/*WIDTH*/', 'max-width: 96%;', $file_text );
54
+ $file_text = str_replace('/*RADIUS*/', 'border-radius: 4px; -webkit-border-radius: 4px; -moz-border-radius: 4px;', $file_text );
55
+ $file_text = str_replace('/*WRAP-MARGIN*/', 'margin: 0 auto;', $file_text );
56
+ $file_text = str_replace('/*THUMBNAIL-WIDTH*/', 'max-width: 150px;', $file_text );
57
+ $file_text = str_replace('/*THUMBNAIL-HEIGHT*/', 'height: 108px; overflow: hidden;', $file_text );
58
+ $file_text = str_replace('/*THUMBNAIL-IMG-WIDTH*/', 'width: 150px;', $file_text );
59
+ $file_text = str_replace('/*HOVER*/', 'opacity: 0.8;', $file_text );
60
+ $file_text = str_replace('/*OPTION*/', '.linkcard p { display: none; }', $file_text );
61
+ $file_text = str_replace('/*COLOR-ADDED*/', 'color: #fff;', $file_text );
62
+ $file_text = str_replace('/*SIZE-ADDED*/', 'font-size: 12px;', $file_text );
63
+ $file_text = str_replace('/*HEIGHT-ADDED*/', 'line-height: 30px;', $file_text );
64
+ $added_height = intval(preg_replace('/[^0-9]/', '', isset($this->options['height-added'] ) ? $this->options['height-added'] : $this->defaults['height-added'] ) );
65
+ $heading_height = intval( $added_height / 2 );
66
+ $heading_padding = intval( $added_height / 4 );
67
+ $file_text = str_replace('/*EX-HEADING*/', 'position: absolute; top: -15px; left: 20px; padding: 0 10px; background-color: '.$this->options['ex-border-color'].'; border-radius: 2px;', $file_text );
68
+ $file_text = str_replace('/*IN-HEADING*/', 'position: absolute; top: -15px; left: 20px; padding: 0 10px; background-color: '.$this->options['in-border-color'].'; border-radius: 2px;', $file_text );
69
+ $file_text = str_replace('/*TH-HEADING*/', 'position: absolute; top: -15px; left: 20px; padding: 0 10px; background-color: '.$this->options['th-border-color'].'; border-radius: 2px;', $file_text );
70
+ if (isset($this->options['thumbnail-resize']) && $this->options['thumbnail-resize'] == '1') {
71
+ $size_title = intval(preg_replace('/[^0-9]/', '', isset($this->options['size-title']) ? $this->options['size-title'] : $this->defaults['size-title'] ) );
72
+ $size_excerpt = intval(preg_replace('/[^0-9]/', '', isset($this->options['size-excerpt']) ? $this->options['size-excerpt'] : $this->defaults['size-excerpt'] ) );
73
+ $height_title = intval(preg_replace('/[^0-9]/', '', isset($this->options['height-title']) ? $this->options['height-title'] : $this->defaults['height-title'] ) );
74
+ $height_excerpt = intval(preg_replace('/[^0-9]/', '', isset($this->options['height-excerpt']) ? $this->options['height-excerpt'] : $this->defaults['height-excerpt'] ) );
75
+ $thumbnail_width = 150;
76
+ $file_text = str_replace('/*RESIZE*/',
77
+ '@media screen and (max-width: 767px) {'.PHP_EOL.' .lkc-internal-wrap { max-width: 100% }'.PHP_EOL.' .lkc-external-wrap { max-width: 100% }'.PHP_EOL.' .lkc-this-wrap { max-width: 100% }'.PHP_EOL.' .lkc-title { font-size: '.intval($size_title * 0.9).'px; line-height: '.intval($height_title * 0.9).'px; }'.PHP_EOL.' .lkc-excerpt { font-size: '.intval($size_excerpt * 0.95).'px; }'.PHP_EOL.' .lkc-thumbnail { max-width: '.intval($thumbnail_width * 0.9).'px; }'.PHP_EOL.' .lkc-thumbnail-img { max-width: '.intval($thumbnail_width * 0.9).'px; }'.PHP_EOL.'}'.PHP_EOL.
78
+ '@media screen and (max-width: 512px) {'.PHP_EOL.' .lkc-internal-wrap { max-width: 100% }'.PHP_EOL.' .lkc-external-wrap { max-width: 100% }'.PHP_EOL.' .lkc-this-wrap { max-width: 100% }'.PHP_EOL.' .lkc-title { font-size: '.intval($size_title * 0.8).'px; line-height: '.intval($height_title * 0.8).'px; }'.PHP_EOL.' .lkc-excerpt { font-size: '.intval($size_excerpt * 0.8).'px; }'.PHP_EOL.' .lkc-thumbnail { max-width: '.intval($thumbnail_width * 0.7).'px; }'.PHP_EOL.' .lkc-thumbnail-img { max-width: '.intval($thumbnail_width * 0.7).'px; }'.PHP_EOL.'}'.PHP_EOL.
79
+ '@media screen and (max-width: 320px) {'.PHP_EOL.' .lkc-internal-wrap { max-width: 100% }'.PHP_EOL.' .lkc-external-wrap { max-width: 100% }'.PHP_EOL.' .lkc-this-wrap { max-width: 100% }'.PHP_EOL.' .lkc-title { font-size: '.intval($size_title * 0.7).'px; line-height: '.intval($height_title * 0.7).'px; }'.PHP_EOL.' .lkc-excerpt { font-size: '.intval($size_excerpt * 0.6).'px; }'.PHP_EOL.' .lkc-thumbnail { max-width: '.intval($thumbnail_width * 0.5).'px; }'.PHP_EOL.' .lkc-thumbnail-img { max-width: '.intval($thumbnail_width * 0.5).'px; }'.PHP_EOL.'}', $file_text );
80
+ }
81
+ $file_text = str_replace('/*SCALE*/', 'transform: scale(1.1);', $file_text );
82
+ $file_text = str_replace('/*TRANSFORM*/', '-webkit-transition: color 0.4s ease, background 0.4s ease, transform 0.4s ease, opacity 0.4s ease, border 0.4s ease, padding 0.4s ease, left 0.4s ease, box-shadow 0.4s ease; transition: color 0.4s ease, background 0.4s ease, transform 0.4s ease, opacity 0.4s ease, border 0.4s ease, padding 0.4s ease, left 0.4s ease, box-shadow 0.4s ease;', $file_text );
83
+ break;
84
+ case 'ecl': // 囲み
85
+ $css = '.lkc-internal-wrap , .lkc-external-wrap , .lkc-this-wrap { transition: all 0.7s ease-in-out; border-width: 2px; }'.PHP_EOL;
86
+ $css .= '.lkc-internal-wrap::before , .lkc-external-wrap::before , .lkc-this-wrap::before { content: ""; display: block; position: absolute; border: 2px solid #888888; box-sizing: border-box; width: 24px; height: 24px; transition: all 0.7s ease-in-out; top: -6px; left: -6px; border-width: 2px 0 0 2px; }'.PHP_EOL;
87
+ $css .= '.lkc-internal-wrap::after , .lkc-external-wrap::after , .lkc-this-wrap::after { content: ""; display: block; position: absolute; border: 2px solid #888888; box-sizing: border-box; width: 24px; height: 24px; transition: all 0.7s ease-in-out; bottom: -6px; right: -6px; border-width: 0 2px 2px 0; }'.PHP_EOL;
88
+ $css .= '.lkc-internal-wrap:hover { border-color: '.$this->options['in-bgcolor'].'; }'.PHP_EOL;
89
+ $css .= '.lkc-external-wrap:hover { border-color: '.$this->options['ex-bgcolor'].'; }'.PHP_EOL;
90
+ $css .= '.lkc-this-wrap:hover { border-color: '.$this->options['th-bgcolor'].'; }'.PHP_EOL;
91
+ $css .= '.lkc-internal-wrap:hover::before { width: calc(100% + 12px); height: calc(100% + 12px); border-color: '.$this->options['in-bgcolor'].'; }'.PHP_EOL;
92
+ $css .= '.lkc-external-wrap:hover::before { width: calc(100% + 12px); height: calc(100% + 12px); border-color: '.$this->options['ex-bgcolor'].'; }'.PHP_EOL;
93
+ $css .= '.lkc-this-wrap:hover::before { width: calc(100% + 12px); height: calc(100% + 12px); border-color: '.$this->options['th-bgcolor'].'; }'.PHP_EOL;
94
+ $css .= '.lkc-internal-wrap:hover::after { width: calc(100% + 12px); height: calc(100% + 12px); border-color: '.$this->options['in-bgcolor'].'; }'.PHP_EOL;
95
+ $css .= '.lkc-external-wrap:hover::after { width: calc(100% + 12px); height: calc(100% + 12px); border-color: '.$this->options['ex-bgcolor'].'; }'.PHP_EOL;
96
+ $css .= '.lkc-this-wrap:hover::after { width: calc(100% + 12px); height: calc(100% + 12px); border-color: '.$this->options['th-bgcolor'].'; }'.PHP_EOL;
97
+ $file_text = str_replace('/*OPTION*/', $css, $file_text );
98
+ break;
99
+ case 'cmp': // コンパクト(Twitter風)
100
+ $file_text = str_replace('/*EX-BORDER*/', 'border: 1px solid rgba(0,0,0,0.1);', $file_text );
101
+ $file_text = str_replace('/*IN-BORDER*/', 'border: 1px solid rgba(0,0,0,0.1);', $file_text );
102
+ $file_text = str_replace('/*TH-BORDER*/', 'border: 1px solid rgba(0,0,0,0.1);', $file_text );
103
+ $file_text = str_replace('/*CONTENT-HEIGHT*/', 'height: 108px;', $file_text );
104
+ $file_text = str_replace('/*WRAP-MARGIN*/', 'margin: 0;', $file_text );
105
+ $file_text = str_replace('/*PADDING*/', 'padding: 0;', $file_text );
106
+ $file_text = str_replace('/*RADIUS*/', 'border-radius: 16px; -webkit-border-radius: 16px; -moz-border-radius: 16px;', $file_text );
107
+ $file_text = str_replace('/*CARD-TOP*/', 'margin: 0;', $file_text );
108
+ $file_text = str_replace('/*CARD-RIGHT*/', '', $file_text );
109
+ $file_text = str_replace('/*CARD-BOTTOM*/', '', $file_text );
110
+ $file_text = str_replace('/*CARD-LEFT*/', '', $file_text );
111
+ $file_text = str_replace('/*MARGIN-TITLE*/', 'margin: 30px 0 0 108px;', $file_text );
112
+ $file_text = str_replace('/*MARGIN-URL*/', 'margin: 0 0 0 108px;', $file_text );
113
+ $file_text = str_replace('/*MARGIN-EXCERPT*/', 'margin: 0 0 0 108px;', $file_text );
114
+ $file_text = str_replace('/*CONTENT-PADDING*/', 'padding: 0;', $file_text );
115
+ $file_text = str_replace('/*CONTENT-MARGIN*/', 'margin: 0;', $file_text );
116
+ $content_height = intval(preg_replace('/[^0-9]/', '', isset($this->options['content-height'] ) ? $this->options['content-height'] : $this->defaults['content-height'] ) );
117
+ $file_text = str_replace('/*THUMBNAIL-WIDTH*/', 'display: block; overflow: hidden;', $file_text );
118
+ $file_text = str_replace('/*THUMBNAIL-HEIGHT*/', 'height: 108px;', $file_text );
119
+ $file_text = str_replace('/*THUMBNAIL-IMG-WIDTH*/', 'width: 100px;', $file_text );
120
+ $file_text = str_replace('/*THUMBNAIL-IMG-HEIGHT*/', 'height: 108px;', $file_text );
121
+ $file_text = str_replace('/*THUMBNAIL-POSITION*/', 'float: left;', $file_text );
122
+ $file_text = str_replace('/*THUMBNAIL-MARGIN*/', 'margin: 0 8px 0 0;', $file_text );
123
+ $file_text = str_replace('/*THUMBNAIL-RADIUS*/', 'border-radius: 16px 0 0 16px;', $file_text );
124
+ $file_text = str_replace('/*POSITION-INFO*/', 'position: absolute; top: 8px; left: 108px;', $file_text );
125
+ break;
126
+ case 'ref': // 反射
127
+ $css = '.lkc-internal-wrap , .lkc-external-wrap , .lkc-this-wrap { overflow: hidden; }'.PHP_EOL;
128
+ $css .= '.lkc-internal-wrap::before , .lkc-external-wrap::before , .lkc-this-wrap::before { content: ""; display: block; width: 500px; height: 120px; background: '.$this->options['border-color'].'; position: absolute; top: -10px; left: -500px; transform: rotate(-45deg); transition: all .3s ease-in-out; }'.PHP_EOL;
129
+ $css .= '.lkc-internal-wrap:hover::before , .lkc-external-wrap:hover::before , .lkc-this-wrap:hover::before { margin-left: 300% ; }'.PHP_EOL;
130
+ $file_text = str_replace('/*OPTION*/', $css, $file_text );
131
+ break;
132
+ case 'w95': // Windows 95
133
+ $css = '.lkc-external-wrap a , .lkc-internal-wrap a , .lkc-this-wrap a { cursor: default; }'.PHP_EOL;
134
+ $css .= '.lkc-card { margin: 16px; padding: 4px; border: 3px #c0c7c8 solid; background: #e0e0e0; border: 1px #87888f solid; }'.PHP_EOL;
135
+ $css .= '.lkc-url { cursor: pointer; }'.PHP_EOL;
136
+ $css .= '.lkc-info { margin: 0; padding: 4px; border: 1px #87888f solid; background: #0000a8; font-weight: bold; font-size: 11px; line-height: 16px; }'.PHP_EOL;
137
+ $css .= '.lkc-domain { color: #fff; font-weight: normal; }'.PHP_EOL;
138
+ $file_text = str_replace('/*OPTION*/', $css, $file_text );
139
+ break;
140
+ case 'wxp': // Windows XP
141
+ $css = '.lkc-external-wrap a , .lkc-internal-wrap a , .lkc-this-wrap a { cursor: default; }'.PHP_EOL;
142
+ $css .= '.lkc-card { margin: 16px; padding: 0; border: 3px #1f61e3 solid; border-radius: 5px; background: #eeecdf; }'.PHP_EOL;
143
+ $css .= '.lkc-info { margin: 0; padding: 4px; background: linear-gradient(to bottom, #2790ff, #1f61e3); background: -webkit-linear-gradient(top, #2790ff, #1f61e3); font-weight: bold; font-size: 11px; line-height: 16px; }'.PHP_EOL;
144
+ $css .= '.lkc-domain { color: #fff; }'.PHP_EOL;
145
+ $css .= '.lkc-title-text { padding: 0 4px; }'.PHP_EOL;
146
+ $css .= '.lkc-url { padding: 4px; cursor: pointer; }'.PHP_EOL;
147
+ $css .= '.lkc-excerpt { padding: 4px; }'.PHP_EOL;
148
+ $file_text = str_replace('/*OPTION*/', $css, $file_text );
149
+ break;
150
+ case 'sqr': // スクエア(WordPress標準風)
151
+ $file_text = str_replace('/*HEIGHT*/', 'height: 337px;', $file_text );
152
+ $file_text = str_replace('/*CONTENT-HEIGHT*/', 'height: 300px;', $file_text );
153
+ $thumbnail_width = preg_replace('/[^0-9]/', '', isset($this->options['width']) ? $this->options['width'] : $this->defaults['thumbnail-width'] ) - 0;
154
+ $file_text = str_replace('/*THUMBNAIL-WIDTH*/', 'display: block; overflow: hidden;', $file_text );
155
+ $file_text = str_replace('/*THUMBNAIL-HEIGHT*/', 'max-height: 200px;', $file_text );
156
+ $file_text = str_replace('/*THUMBNAIL-IMG-WIDTH*/', 'width: '.$thumbnail_width .'px;', $file_text );
157
+ $file_text = str_replace('/*THUMBNAIL-IMG-HEIGHT*/', '', $file_text );
158
+ $file_text = str_replace('/*OPTION*/', '.lkc-thumbnail { float: initial; }', $file_text );
159
+ break;
160
+ case 'ct1': // セロファンテープ(中央)
161
+ $file_text = str_replace('/*WRAP-BEFORE*/', 'content: "";display: block;position: absolute;left: 40%;top: -16px;width: 95px;height: 25px;z-index: 2;background-color: rgba(243,245,228,0.5);border: 2px solid rgba(255,255,255,0.5);-webkit-box-shadow: 1px 1px 4px rgba(200,200,180,0.8);-moz-box-shadow: 1px 1px 4px rgba(200,200,180,0.8);box-shadow: 1px 1px 4px rgba(200,200,180,0.8);-webkit-transform: rotate(3deg);-moz-transform: rotate(3deg);-o-transform: rotate(3deg);', $file_text );
162
+ $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.2);', $file_text );
163
+ break;
164
+ case 'ct2': // セロファンテープ(左右)
165
+ $file_text = str_replace('/*MARGIN-LEFT*/', 'margin-left: 40px;', $file_text );
166
+ $file_text = str_replace('/*WRAP-BEFORE*/', 'content: "";display: block;position: absolute;left: -40px;top: -4px;width: 75px;height: 25px;z-index: 2;background-color: rgba(243,245,228,0.5);border: 2px solid rgba(255,255,255,0.5);-webkit-box-shadow: 1px 1px 4px rgba(200,200,180,0.8);-moz-box-shadow: 1px 1px 4px rgba(200,200,180,0.8);box-shadow: 1px 1px 4px rgba(200,200,180,0.8);-webkit-transform: rotate(-45deg);-moz-transform: rotate(-45deg);-o-transform: rotate(-45deg);', $file_text );
167
+ $file_text = str_replace('/*WRAP-AFTER*/', 'content: "";display: block;position: absolute;right: -20px;top: -2px;width: 75px;height: 25px;z-index: 2;background-color: rgba(243,245,228,0.5);border: 2px solid rgba(255,255,255,0.5);-webkit-box-shadow: 1px 1px 4px rgba(200,200,180,0.8);-moz-box-shadow: 1px 1px 4px rgba(200,200,180,0.8);box-shadow: 1px 1px 4px rgba(200,200,180,0.8);-webkit-transform: rotate(16deg);-moz-transform: rotate(16deg);-o-transform: rotate(16deg);transform: rotate(16deg);', $file_text );
168
+ $file_text = str_replace('/*MARGIN-RIGHT*/', 'margin-right: 25px;', $file_text );
169
+ $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.2);', $file_text );
170
+ break;
171
+ case 'ct3': // セロファンテープ(長め)
172
+ $file_text = str_replace('/*WRAP-BEFORE*/', 'content: "";display: block;position: absolute;left: -5%;top: -12px;width: 110%;height: 25px;z-index: 2;background-color: rgba(243,245,228,0.5);border: 2px solid rgba(255,255,255,0.5);-webkit-box-shadow: 1px 1px 4px rgba(200,200,180,0.8);-moz-box-shadow: 1px 1px 4px rgba(200,200,180,0.8);box-shadow: 1px 1px 4px rgba(200,200,180,0.8);-webkit-transform: rotate(-3deg);-moz-transform: rotate(-3deg);-o-transform: rotate(-3deg);', $file_text );
173
+ $file_text = str_replace('/*MARGIN-LEFT*/', 'margin-left: 32px;', $file_text );
174
+ $file_text = str_replace('/*MARGIN-RIGHT*/', 'margin-right: 32px;', $file_text );
175
+ $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.2);', $file_text );
176
+ break;
177
+ case 'ct4': // セロファンテープ(斜め)
178
+ $file_text = str_replace('/*WRAP-BEFORE*/', 'content: ""; display: block; position: absolute; left: -24px; top: 0px; width: 200px; height: 25px; z-index: 2; background-color: rgba(243,245,228,0.5); border: 2px solid rgba(255,255,255,0.5); -webkit-box-shadow: 1px 1px 4px rgba(200,200,180,0.8); -moz-box-shadow: 1px 1px 4px rgba(200,200,180,0.8); box-shadow: 1px 1px 4px rgba(200,200,180,0.8); -webkit-transform: rotate(-8deg); -moz-transform: rotate(-8deg); -o-transform: rotate(-8deg);', $file_text );
179
+ $file_text = str_replace('/*MARGIN-LEFT*/', 'margin-left: 24px;', $file_text );
180
+ $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.2);', $file_text );
181
+ break;
182
+ case 'slt': // 斜め(ネタ)
183
+ $file_text = str_replace('/*WRAP*/', 'transform:skew(-10deg) rotate(1deg);-webkit-transform: skew(-10deg) rotate(1deg);-moz-transform:skew(-10deg) rotate(1deg);', $file_text );
184
+ $file_text = str_replace('/*MARGIN-LEFT*/', 'margin-left: 12px;', $file_text );
185
+ $file_text = str_replace('/*MARGIN-RIGHT*/', 'margin-right: 30px;', $file_text );
186
+ break;
187
+ case '3Dr': // 立体(ネタ)
188
+ $file_text = str_replace('/*WRAP*/', '-webkit-transform:perspective(150px) scale3d(0.84,0.9,1) rotate3d(1,0,0,12deg);', $file_text );
189
+ $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0 20px 16px rgba(0, 0, 0, 0.6) , 0px 32px 32px rgba(0, 0, 0, 0.2) inset;', $file_text );
190
+ break;
191
+ case 'ppc': // 紙めくれ
192
+ $file_text = str_replace('/*WRAP-AFTER*/', 'z-index: -1; content:""; height: 10px; width: 60%; position: absolute; right: 16px; bottom: 14px; left: auto; transform: skew(5deg) rotate(3deg); -webkit-transform: skew(5deg) rotate(3deg); -moz-transform: skew(5deg) rotate(3deg); box-shadow: 0 16px 16px rgba(0,0,0,1); -webkit-box-shadow: 0 16px 16px rgba(0,0,0,1); -moz-box-shadow: 0 16px 12px rgba(0,0,0,1);', $file_text );
193
+ $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.8);', $file_text );
194
+ $file_text = str_replace('/*OPTION*/', 'article { position: relative; z-index: 0; } article blockquote { position: relative; z-index: 0; }', $file_text );
195
+ break;
196
+ case 'tac': // テープと紙めくれ
197
+ $file_text = str_replace('/*WRAP-BEFORE*/', 'content: ""; display: block; position: absolute; left: -24px; top: 0px; width: 200px; height: 25px; z-index: 2; background-color: rgba(243,245,228,0.5); border: 2px solid rgba(255,255,255,0.5); -webkit-box-shadow: 1px 1px 4px rgba(200,200,180,0.8); -moz-box-shadow: 1px 1px 4px rgba(200,200,180,0.8); box-shadow: 1px 1px 4px rgba(200,200,180,0.8); -webkit-transform: rotate(-8deg); -moz-transform: rotate(-8deg); -o-transform: rotate(-8deg);', $file_text );
198
+ $file_text = str_replace('/*WRAP-AFTER*/', 'z-index: -1; content:""; height: 10px; width: 60%; position: absolute; right: 16px; bottom: 14px; left: auto; transform: skew(5deg) rotate(3deg); -webkit-transform: skew(5deg) rotate(3deg); -moz-transform: skew(5deg) rotate(3deg); box-shadow: 0 16px 16px rgba(0,0,0,1); -webkit-box-shadow: 0 16px 16px rgba(0,0,0,1); -moz-box-shadow: 0 16px 12px rgba(0,0,0,1);', $file_text );
199
+ $file_text = str_replace('/*MARGIN-LEFT*/', 'margin-left: 24px;', $file_text );
200
+ $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.8);', $file_text );
201
+ $file_text = str_replace('/*OPTION*/', 'article { position: relative; z-index: 0; } article blockquote { position: relative; z-index: 0; }', $file_text );
202
+ break;
203
+ case 'pin': // 押しピン(綺麗な画像募集中)
204
+ $file_text = str_replace('/*WRAP-AFTER*/', 'content: ""; display: block; position: absolute; background-image: url("'.$this->plugin_dir_url.'img/pin.png"); background-repeat: no-repeat; background-position: center; left: 47%; top: -16px; width: 40px; height: 40px; z-index: 1; pointer-events: none;', $file_text );
205
+ break;
206
+ case 'inN': // 中立青緑(イングレス風)
207
+ $file_text = str_replace('/*EX-BORDER*/', 'border: 4px solid #59fbea;', $file_text );
208
+ $file_text = str_replace('/*IN-BORDER*/', 'border: 4px solid #59fbea;', $file_text );
209
+ $file_text = str_replace('/*TH-BORDER*/', 'border: 4px solid #59fbea;', $file_text );
210
+ $file_text = str_replace('/*COLOR-TITLE*/', 'color: #59fbea;', $file_text );
211
+ $file_text = str_replace('/*COLOR-URL*/', 'color: #59fbea;', $file_text );
212
+ $file_text = str_replace('/*COLOR-EXCERPT*/', 'color: #59fbea;', $file_text );
213
+ $file_text = str_replace('/*COLOR-INFO*/', 'color: #59fbea;', $file_text );
214
+ $file_text = str_replace('/*COLOR-PLUGIN*/', 'color: #59fbea;', $file_text );
215
+ $file_text = str_replace('/*EX-BGCOLOR*/', 'background-color: rgba( 35,100, 93,0.9);', $file_text );
216
+ $file_text = str_replace('/*IN-BGCOLOR*/', 'background-color: rgba( 8, 25, 23,0.9);', $file_text );
217
+ $file_text = str_replace('/*TH-BGCOLOR*/', 'background-color: rgba( 89,251,234,0.05);', $file_text );
218
+ break;
219
+ case 'inI': // 情報オレンジ(イングレス風)
220
+ $file_text = str_replace('/*EX-BORDER*/', 'border: 4px solid #ebbc4a;', $file_text );
221
+ $file_text = str_replace('/*IN-BORDER*/', 'border: 4px solid #ebbc4a;', $file_text );
222
+ $file_text = str_replace('/*TH-BORDER*/', 'border: 4px solid #ebbc4a;', $file_text );
223
+ $file_text = str_replace('/*COLOR-TITLE*/', 'color: #ebbc4a;', $file_text );
224
+ $file_text = str_replace('/*COLOR-URL*/', 'color: #ebbc4a;', $file_text );
225
+ $file_text = str_replace('/*COLOR-EXCERPT*/', 'color: #ebbc4a;', $file_text );
226
+ $file_text = str_replace('/*COLOR-INFO*/', 'color: #ebbc4a;', $file_text );
227
+ $file_text = str_replace('/*COLOR-PLUGIN*/', 'color: #ebbc4a;', $file_text );
228
+ $file_text = str_replace('/*EX-BGCOLOR*/', 'background-color: rgba( 94, 75, 29,0.9);', $file_text );
229
+ $file_text = str_replace('/*IN-BGCOLOR*/', 'background-color: rgba( 23, 18, 7,0.9);', $file_text );
230
+ $file_text = str_replace('/*TH-BGCOLOR*/', 'background-color: rgba(235,188, 74,0.05);', $file_text );
231
+ break;
232
+ case 'inE': // エンライテッドカラー(イングレス風)
233
+ $file_text = str_replace('/*EX-BORDER*/', 'border: 4px solid #28f428;', $file_text );
234
+ $file_text = str_replace('/*IN-BORDER*/', 'border: 4px solid #28f428;', $file_text );
235
+ $file_text = str_replace('/*TH-BORDER*/', 'border: 4px solid #28f428;', $file_text );
236
+ $file_text = str_replace('/*COLOR-TITLE*/', 'color: #28f428;', $file_text );
237
+ $file_text = str_replace('/*COLOR-URL*/', 'color: #28f428;', $file_text );
238
+ $file_text = str_replace('/*COLOR-EXCERPT*/', 'color: #28f428;', $file_text );
239
+ $file_text = str_replace('/*COLOR-INFO*/', 'color: #28f428;', $file_text );
240
+ $file_text = str_replace('/*COLOR-PLUGIN*/', 'color: #28f428;', $file_text );
241
+ $file_text = str_replace('/*EX-BGCOLOR*/', 'background-color: rgba( 16, 97, 16,0.9);', $file_text );
242
+ $file_text = str_replace('/*IN-BGCOLOR*/', 'background-color: rgba( 4, 24, 4,0.9);', $file_text );
243
+ $file_text = str_replace('/*TH-BGCOLOR*/', 'background-color: rgba( 40,244, 40,0.05);', $file_text );
244
+ break;
245
+ case 'inR': // レジスタンスカラー(イングレス風)
246
+ $file_text = str_replace('/*EX-BORDER*/', 'border: 4px solid #00c2ff;', $file_text );
247
+ $file_text = str_replace('/*IN-BORDER*/', 'border: 4px solid #00c2ff;', $file_text );
248
+ $file_text = str_replace('/*TH-BORDER*/', 'border: 4px solid #00c2ff;', $file_text );
249
+ $file_text = str_replace('/*COLOR-TITLE*/', 'color: #00c2ff;', $file_text );
250
+ $file_text = str_replace('/*COLOR-URL*/', 'color: #00c2ff;', $file_text );
251
+ $file_text = str_replace('/*COLOR-EXCERPT*/', 'color: #00c2ff;', $file_text );
252
+ $file_text = str_replace('/*COLOR-INFO*/', 'color: #00c2ff;', $file_text );
253
+ $file_text = str_replace('/*COLOR-PLUGIN*/', 'color: #00c2ff;', $file_text );
254
+ $file_text = str_replace('/*EX-BGCOLOR*/', 'background-color: rgba( 0, 77,102,0.9);', $file_text );
255
+ $file_text = str_replace('/*IN-BGCOLOR*/', 'background-color: rgba( 0, 19, 25,0.9);', $file_text );
256
+ $file_text = str_replace('/*TH-BGCOLOR*/', 'background-color: rgba( 0,194,255,0.05);', $file_text );
257
+ break;
258
+ case 'sBR': // 縫い目(青&赤)
259
+ $file_text = str_replace('/*EX-BORDER*/', 'border: 2px dashed rgba(255,255,255,0.5);', $file_text );
260
+ $file_text = str_replace('/*IN-BORDER*/', 'border: 2px dashed rgba(255,255,255,0.5);', $file_text );
261
+ $file_text = str_replace('/*TH-BORDER*/', 'border: 2px dashed rgba(255,255,255,0.5);', $file_text );
262
+ $file_text = str_replace('/*EX-BGCOLOR*/', 'background: #bcddff; box-shadow: 0 0 0 5px #aabbee, 3px 3px 6px 4px rgba(0,0,0,0.6); -moz-box-shadow: 0 0 0 5px #aabbee, 3px 3px 6px 4px rgba(0,0,0,0.6); -webkit-box-shadow: 0 0 0 5px #aabbee, 3px 3px 6px 4px rgba(0,0,0,0.6);', $file_text );
263
+ $file_text = str_replace('/*IN-BGCOLOR*/', 'background: #f8d0d0; box-shadow: 0 0 0 5px #e8a8a8, 3px 3px 6px 4px rgba(0,0,0,0.6); -moz-box-shadow: 0 0 0 5px #e8a8a8, 3px 3px 6px 4px rgba(0,0,0,0.6); -webkit-box-shadow: 0 0 0 5px #e8a8a8, 3px 3px 6px 4px rgba(0,0,0,0.6);', $file_text );
264
+ $file_text = str_replace('/*TH-BGCOLOR*/', 'background: #f29db0; box-shadow: 0 0 0 5px #de8899, 3px 3px 6px 4px rgba(0,0,0,0.6); -moz-box-shadow: 0 0 0 5px #de8899, 3px 3px 6px 4px rgba(0,0,0,0.6); -webkit-box-shadow: 0 0 0 5px #de8899, 3px 3px 6px 4px rgba(0,0,0,0.6);', $file_text );
265
+ break;
266
+ case 'sGY': // 縫い目(緑&黄)
267
+ $file_text = str_replace('/*EX-BORDER*/', 'border: 2px dashed rgba(255,255,255,0.5);', $file_text );
268
+ $file_text = str_replace('/*IN-BORDER*/', 'border: 2px dashed rgba(255,255,255,0.5);', $file_text );
269
+ $file_text = str_replace('/*TH-BORDER*/', 'border: 2px dashed rgba(255,255,255,0.5);', $file_text );
270
+ $file_text = str_replace('/*EX-BGCOLOR*/', 'background: #acefdd; box-shadow: 0 0 0 5px #8abecb, 3px 3px 6px 4px rgba(0,0,0,0.6); -moz-box-shadow: 0 0 0 5px #8abecb, 3px 3px 6px 4px rgba(0,0,0,0.6); -webkit-box-shadow: 0 0 0 5px #8abecb, 3px 3px 6px 4px rgba(0,0,0,0.6);', $file_text );
271
+ $file_text = str_replace('/*IN-BGCOLOR*/', 'background: #ffde51; box-shadow: 0 0 0 5px #fbca4d, 3px 3px 6px 4px rgba(0,0,0,0.6); -moz-box-shadow: 0 0 0 5px #fbca4d, 3px 3px 6px 4px rgba(0,0,0,0.6); -webkit-box-shadow: 0 0 0 5px #fbca4d, 3px 3px 6px 4px rgba(0,0,0,0.6);', $file_text );
272
+ $file_text = str_replace('/*TH-BGCOLOR*/', 'background: #f0e0b0; box-shadow: 0 0 0 5px #decca0, 3px 3px 6px 4px rgba(0,0,0,0.6); -moz-box-shadow: 0 0 0 5px #decca0, 3px 3px 6px 4px rgba(0,0,0,0.6); -webkit-box-shadow: 0 0 0 5px #decca0, 3px 3px 6px 4px rgba(0,0,0,0.6);', $file_text );
273
+ break;
274
+ }
275
+
276
+ // 文字色
277
+ $file_text = str_replace('/*COLOR-TITLE*/', 'color: '.$this->options['color-title'].';', $file_text );
278
+ $file_text = str_replace('/*COLOR-URL*/', 'color: '.$this->options['color-url'].';', $file_text );
279
+ $file_text = str_replace('/*COLOR-EXCERPT*/', 'color: '.$this->options['color-excerpt'].';', $file_text );
280
+ $file_text = str_replace('/*COLOR-INFO*/', 'color: '.$this->options['color-info'].';', $file_text );
281
+ if (!$this->options['color-added']) {
282
+ $this->options['color-added'] = $this->options['color-info'];
283
+ $this->options['size-added'] = $this->options['size-info'];
284
+ $this->options['height-added'] = $this->options['height-info'];
285
+ $this->options['outline-added'] = $this->options['outline-info'];
286
+ }
287
+ $file_text = str_replace('/*COLOR-ADDED*/', 'color: '.$this->options['color-added'].';', $file_text );
288
+ $file_text = str_replace('/*COLOR-MORE*/', 'color: '.$this->options['color-more'].';', $file_text );
289
+ $file_text = str_replace('/*COLOR-PLUGIN*/', 'color: '.$this->options['color-plugin'].';', $file_text );
290
+
291
+ // 文字の大きさ
292
+ $file_text = str_replace('/*SIZE-TITLE*/', 'font-size: '.$this->options['size-title'].';', $file_text );
293
+ $file_text = str_replace('/*SIZE-URL*/', 'font-size: '.$this->options['size-url'].';', $file_text );
294
+ $file_text = str_replace('/*SIZE-EXCERPT*/', 'font-size: '.$this->options['size-excerpt'].';', $file_text );
295
+ $file_text = str_replace('/*SIZE-INFO*/', 'font-size: '.$this->options['size-info'].';', $file_text );
296
+ $file_text = str_replace('/*SIZE-ADDED*/', 'font-size: '.$this->options['size-added'].';', $file_text );
297
+ $file_text = str_replace('/*SIZE-MORE*/', 'font-size: '.$this->options['size-more'].';', $file_text );
298
+ $file_text = str_replace('/*SIZE-PLUGIN*/', 'font-size: '.$this->options['size-plugin'].';', $file_text );
299
+
300
+ // 行の高さ
301
+ $file_text = str_replace('/*HEIGHT-TITLE*/', 'line-height: '.$this->options['height-title'].';', $file_text );
302
+ $file_text = str_replace('/*HEIGHT-URL*/', 'line-height: '.$this->options['height-url'].';', $file_text );
303
+ $file_text = str_replace('/*HEIGHT-EXCERPT*/', 'line-height: '.$this->options['height-excerpt'].';', $file_text );
304
+ $file_text = str_replace('/*HEIGHT-INFO*/', 'line-height: '.$this->options['height-info'].';', $file_text );
305
+ $file_text = str_replace('/*HEIGHT-ADDED*/', 'line-height: '.$this->options['height-added'].';', $file_text );
306
+ $file_text = str_replace('/*HEIGHT-MORE*/', 'line-height: '.$this->options['height-more'].';', $file_text );
307
+ $file_text = str_replace('/*HEIGHT-PLUGIN*/', 'line-height: '.$this->options['height-plugin'].';', $file_text );
308
+
309
+ // 文字の縁取り
310
+ if (isset($this->options['outline-title']) && $this->options['outline-title'] == '1') {
311
+ $file_text = str_replace('/*OUTCOLOR-TITLE*/', 'text-shadow: 0 -1px '.$this->options['outline-color-title'].', 1px -1px '.$this->options['outline-color-title'].', 1px 0 '.$this->options['outline-color-title'].', 1px 1px '.$this->options['outline-color-title'].', 0 1px '.$this->options['outline-color-title'].', -1px 1px '.$this->options['outline-color-title'].', -1px 0 '.$this->options['outline-color-title'].', -1px -1px '.$this->options['outline-color-title'].';', $file_text );
312
+ }
313
+ if (isset($this->options['outline-url']) && $this->options['outline-url'] == '1') {
314
+ $file_text = str_replace('/*OUTCOLOR-URL*/', 'text-shadow: 0 -1px '.$this->options['outline-color-url'].', 1px -1px '.$this->options['outline-color-url'].', 1px 0 '.$this->options['outline-color-url'].', 1px 1px '.$this->options['outline-color-url'].', 0 1px '.$this->options['outline-color-url'].', -1px 1px '.$this->options['outline-color-url'].', -1px 0 '.$this->options['outline-color-url'].', -1px -1px '.$this->options['outline-color-url'].';', $file_text );
315
+ }
316
+ if (isset($this->options['outline-excerpt']) && $this->options['outline-excerpt'] == '1') {
317
+ $file_text = str_replace('/*OUTCOLOR-EXCERPT*/','text-shadow: 0 -1px '.$this->options['outline-color-excerpt'].', 1px -1px '.$this->options['outline-color-excerpt'].', 1px 0 '.$this->options['outline-color-excerpt'].', 1px 1px '.$this->options['outline-color-excerpt'].', 0 1px '.$this->options['outline-color-excerpt'].', -1px 1px '.$this->options['outline-color-excerpt'].', -1px 0 '.$this->options['outline-color-excerpt'].', -1px -1px '.$this->options['outline-color-excerpt'].';', $file_text );
318
+ }
319
+ if (isset($this->options['outline-info']) && $this->options['outline-info'] == '1') {
320
+ $file_text = str_replace('/*OUTCOLOR-INFO*/', 'text-shadow: 0 -1px '.$this->options['outline-color-info'].', 1px -1px '.$this->options['outline-color-info'].', 1px 0 '.$this->options['outline-color-info'].', 1px 1px '.$this->options['outline-color-info'].', 0 1px '.$this->options['outline-color-info'].', -1px 1px '.$this->options['outline-color-info'].', -1px 0 '.$this->options['outline-color-info'].', -1px -1px '.$this->options['outline-color-info'].';', $file_text );
321
+ }
322
+ if (isset($this->options['outline-added']) && $this->options['outline-added'] == '1') {
323
+ $file_text = str_replace('/*OUTCOLOR-ADDED*/', 'text-shadow: 0 -1px '.$this->options['outline-color-added'].', 1px -1px '.$this->options['outline-color-added'].', 1px 0 '.$this->options['outline-color-added'].', 1px 1px '.$this->options['outline-color-added'].', 0 1px '.$this->options['outline-color-added'].', -1px 1px '.$this->options['outline-color-added'].', -1px 0 '.$this->options['outline-color-added'].', -1px -1px '.$this->options['outline-color-added'].';', $file_text );
324
+ }
325
+ if (isset($this->options['outline-more']) && $this->options['outline-more'] == '1') {
326
+ $file_text = str_replace('/*OUTCOLOR-MORE*/', 'text-shadow: 0 -1px '.$this->options['outline-color-more'].', 1px -1px '.$this->options['outline-color-more'].', 1px 0 '.$this->options['outline-color-more'].', 1px 1px '.$this->options['outline-color-more'].', 0 1px '.$this->options['outline-color-more'].', -1px 1px '.$this->options['outline-color-more'].', -1px 0 '.$this->options['outline-color-more'].', -1px -1px '.$this->options['outline-color-more'].';', $file_text );
327
+ }
328
+ if (isset($this->options['outline-plugin']) && $this->options['outline-plugin'] == '1') {
329
+ $file_text = str_replace('/*OUTCOLOR-PLUGIN*/', 'text-shadow: 0 -1px '.$this->options['outline-color-plugin'].', 1px -1px '.$this->options['outline-color-plugin'].', 1px 0 '.$this->options['outline-color-plugin'].', 1px 1px '.$this->options['outline-color-plugin'].', 0 1px '.$this->options['outline-color-plugin'].', -1px 1px '.$this->options['outline-color-plugin'].', -1px 0 '.$this->options['outline-color-plugin'].', -1px -1px '.$this->options['outline-color-plugin'].';', $file_text );
330
+ }
331
+
332
+ // カードの周りへの余白
333
+ if ($this->options['margin-top']) {
334
+ $file_text = str_replace('/*MARGIN-TOP*/', 'margin-top: '.$this->options['margin-top'].';', $file_text );
335
+ }
336
+ if ($this->options['margin-right']) {
337
+ $file_text = str_replace('/*MARGIN-RIGHT*/', 'margin-right: '.$this->options['margin-right'].';', $file_text );
338
+ }
339
+ if ($this->options['margin-bottom']) {
340
+ $file_text = str_replace('/*MARGIN-BOTTOM*/', 'margin-bottom: '.$this->options['margin-bottom'].';', $file_text );
341
+ }
342
+ if ($this->options['margin-left']) {
343
+ $file_text = str_replace('/*MARGIN-LEFT*/', 'margin-left: '.$this->options['margin-left'].';', $file_text );
344
+ }
345
+
346
+ // カードの余白等調整
347
+ $file_text = str_replace('/*PADDING*/', 'padding: 0;', $file_text );
348
+
349
+ // カード内側の余白
350
+ if ($this->options['card-top']) {
351
+ $file_text = str_replace('/*CARD-TOP*/', 'margin-top: '.$this->options['card-top'].';', $file_text );
352
+ } else {
353
+ $file_text = str_replace('/*CARD-TOP*/', 'margin-top: 7px;', $file_text );
354
+ }
355
+ if ($this->options['card-right']) {
356
+ $file_text = str_replace('/*CARD-RIGHT*/', 'margin-right: '.$this->options['card-right'].';', $file_text );
357
+ } else {
358
+ $file_text = str_replace('/*CARD-RIGHT*/', 'margin-right: 7px;', $file_text );
359
+ }
360
+ if ($this->options['card-bottom']) {
361
+ $file_text = str_replace('/*CARD-BOTTOM*/', 'margin-bottom: '.$this->options['card-bottom'].';', $file_text );
362
+ } else {
363
+ $file_text = str_replace('/*CARD-BOTTOM*/', 'margin-bottom: 7px;', $file_text );
364
+ }
365
+ if ($this->options['card-left']) {
366
+ $file_text = str_replace('/*CARD-LEFT*/', 'margin-left: '.$this->options['card-left'].';', $file_text );
367
+ } else {
368
+ $file_text = str_replace('/*CARD-LEFT*/', 'margin-left: 7px;', $file_text );
369
+ }
370
+
371
+ // img のスタイルを強制リセット
372
+ if (isset($this->options['style-reset-img'])) {
373
+ $file_text = str_replace('/*RESET-IMG*/', 'margin: 0 !important; padding: 0; border: none;', $file_text );
374
+ $file_text = str_replace('/*STATIC*/', 'position: static !important;', $file_text );
375
+ $file_text = str_replace('/*IMPORTANT*/', '!important', $file_text );
376
+ } else {
377
+ $file_text = str_replace('/*IMPORTANT*/', '', $file_text );
378
+ }
379
+
380
+ // 外部リンク背景
381
+ if ($this->options['ex-bgcolor']) {
382
+ $file_text = str_replace('/*EX-BGCOLOR*/', 'background-color: '.$this->options['ex-bgcolor'].';', $file_text );
383
+ }
384
+ if ($this->options['ex-image']) {
385
+ if (preg_match('/https?(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/', $this->options['ex-image'])) {
386
+ $file_text = str_replace('/*EX-IMAGE*/', 'background-image: url("'.$this->options['ex-image'].'");', $file_text );
387
+ } else {
388
+ $file_text = str_replace('/*EX-IMAGE*/', 'background-image: '.$this->options['ex-image'].';', $file_text );
389
+ }
390
+ }
391
+
392
+ // 内部リンク背景
393
+ if ($this->options['in-bgcolor']) {
394
+ $file_text = str_replace('/*IN-BGCOLOR*/', 'background-color: '.$this->options['in-bgcolor'].';', $file_text );
395
+ }
396
+ if ($this->options['in-image']) {
397
+ if (preg_match('/https?(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/', $this->options['in-image'])) {
398
+ $file_text = str_replace('/*IN-IMAGE*/', 'background-image: url("'.$this->options['in-image'].'");', $file_text );
399
+ } else {
400
+ $file_text = str_replace('/*IN-IMAGE*/', 'background-image: '.$this->options['in-image'].';', $file_text );
401
+ }
402
+ }
403
+
404
+ // 同ページリンク背景色
405
+ if ($this->options['th-bgcolor']) {
406
+ $file_text = str_replace('/*TH-BGCOLOR*/', 'background-color: '.$this->options['th-bgcolor'].';', $file_text );
407
+ }
408
+ if ($this->options['th-image']) {
409
+ if (preg_match('/https?(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/', $this->options['th-image'])) {
410
+ $file_text = str_replace('/*TH-IMAGE*/', 'background-image: url("'.$this->options['th-image'].'");', $file_text );
411
+ } else {
412
+ $file_text = str_replace('/*TH-IMAGE*/', 'background-image: '.$this->options['th-image'].';', $file_text );
413
+ }
414
+ }
415
+
416
+ // センタリング指定あり
417
+ if (isset($this->options['centering']) && $this->options['centering'] == '1') {
418
+ $file_text = str_replace('/*WRAP-MARGIN*/', 'margin: 0 auto;', $file_text );
419
+ $file_text = str_replace('/*HATENA-WRAP-MARGIN*/', 'margin: 0 auto;', $file_text );
420
+ } else {
421
+ $file_text = str_replace('/*WRAP-MARGIN*/', 'margin: 0;', $file_text );
422
+ $file_text = str_replace('/*HATENA-WRAP-MARGIN*/', 'margin: 0;', $file_text );
423
+ }
424
+
425
+ // 角まる指定あり
426
+ switch ($this->options['radius']) {
427
+ case null:
428
+ $file_text = str_replace('/*RADIUS*/', '', $file_text );
429
+ $file_text = str_replace('/*THUMBNAIL-RADIUS*/', '', $file_text );
430
+ break;
431
+ case '2':
432
+ $file_text = str_replace('/*RADIUS*/', 'border-radius: 4px; -webkit-border-radius: 4px; -moz-border-radius: 4px;', $file_text );
433
+ $file_text = str_replace('/*THUMBNAIL-RADIUS*/', 'border-radius: 2px; -webkit-border-radius: 2px; -moz-border-radius: 2px;', $file_text );
434
+ break;
435
+ case '1':
436
+ $file_text = str_replace('/*RADIUS*/', 'border-radius: 8px; -webkit-border-radius: 8px; -moz-border-radius: 8px;', $file_text );
437
+ $file_text = str_replace('/*THUMBNAIL-RADIUS*/', 'border-radius: 6px; -webkit-border-radius: 6px; -moz-border-radius: 6px;', $file_text );
438
+ break;
439
+ case '3':
440
+ $file_text = str_replace('/*RADIUS*/', 'border-radius: 16px; -webkit-border-radius: 16px; -moz-border-radius: 16px;', $file_text );
441
+ $file_text = str_replace('/*THUMBNAIL-RADIUS*/', 'border-radius: 8px; -webkit-border-radius: 8px; -moz-border-radius: 8px;', $file_text );
442
+ break;
443
+ case '4':
444
+ $file_text = str_replace('/*RADIUS*/', 'border-radius: 32px; -webkit-border-radius: 32px; -moz-border-radius: 32px;', $file_text );
445
+ $file_text = str_replace('/*THUMBNAIL-RADIUS*/', 'border-radius: 12px; -webkit-border-radius: 12px; -moz-border-radius: 12px;', $file_text );
446
+ break;
447
+ case '5':
448
+ $file_text = str_replace('/*RADIUS*/', 'border-radius: 64px; -webkit-border-radius: 64px; -moz-border-radius: 64px;', $file_text );
449
+ $file_text = str_replace('/*THUMBNAIL-RADIUS*/', 'border-radius: 16px; -webkit-border-radius: 16px; -moz-border-radius: 16px;', $file_text );
450
+ break;
451
+ }
452
+
453
+ // 影あり
454
+ if (isset($this->options['shadow']) && $this->options['shadow'] == '1') {
455
+ if (isset($this->options['shadow-inset']) && $this->options['shadow-inset'] == '1') {
456
+ $file_text = str_replace('/*SHADOW*/', 'box-shadow: 8px 8px 8px rgba(0, 0, 0, 0.5) , 0 0 16px rgba(0, 0, 0, 0.3) inset;', $file_text );
457
+ } else {
458
+ $file_text = str_replace('/*SHADOW*/', 'box-shadow: 8px 8px 8px rgba(0, 0, 0, 0.5);', $file_text );
459
+ }
460
+ } else {
461
+ if (isset($this->options['shadow-inset']) && $this->options['shadow-inset'] == '1') {
462
+ $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0 0 16px rgba(0, 0, 0, 0.5) inset;', $file_text );
463
+ }
464
+ }
465
+
466
+ // マウスを乗せたとき
467
+ switch ($this->options['hover']) {
468
+ case '1':
469
+ $file_text = str_replace('/*HOVER*/', 'opacity: 0.8;', $file_text );
470
+ break;
471
+ case '2':
472
+ $file_text = str_replace('/*WRAP*/', 'transition: all 0.3s ease 0s;', $file_text );
473
+ $file_text = str_replace('/*HOVER*/', 'box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25); transform: translateY(-4px);', $file_text );
474
+ break;
475
+ case '3':
476
+ $file_text = str_replace('/*WRAP*/', 'transition: all 0.3s ease 0s;', $file_text );
477
+ $file_text = str_replace('/*HOVER*/', 'box-shadow: 16px 16px 16px rgba(0, 0, 0, 0.5); transform: translateY(-4px);', $file_text );
478
+ break;
479
+ case '7':
480
+ $file_text = str_replace('/*WRAP*/', 'transition: all 0.3s ease 0s;', $file_text );
481
+ $file_text = str_replace('/*HOVER*/', 'border-radius: 40px;', $file_text );
482
+ break;
483
+ }
484
+
485
+ // サムネイルの位置とサイズ
486
+ $thumbnail_width = intval(preg_replace('/[^0-9]/', '', isset($this->options['thumbnail-width']) ? $this->options['thumbnail-width'] : $this->defaults['thumbnail-width'] ) );
487
+ $thumbnail_height = intval(preg_replace('/[^0-9]/', '', isset($this->options['thumbnail-height'] ) ? $this->options['thumbnail-height'] : $this->defaults['thumbnail-height'] ) );
488
+ $content_width = intval(preg_replace('/[^0-9]/', '', isset($this->options['width']) ? $this->options['width'] : $this->defaults['thumbnail-width'] ) );
489
+ $content_height = intval(preg_replace('/[^0-9]/', '', isset($this->options['content-height'] ) ? $this->options['content-height'] : $this->defaults['content-height'] ) );
490
+ switch ($this->options['thumbnail-position']) {
491
+ case '1':
492
+ $file_text = str_replace('/*THUMBNAIL-POSITION*/', 'float: right;', $file_text );
493
+ $file_text = str_replace('/*THUMBNAIL-MARGIN*/', 'margin: 0 6px 4px 4px;', $file_text );
494
+ $file_text = str_replace('/*THUMBNAIL-WIDTH*/', 'max-width: '.$thumbnail_width .'px;', $file_text );
495
+ $file_text = str_replace('/*THUMBNAIL-HEIGHT*/', 'max-height: '.$thumbnail_height.'px;', $file_text );
496
+ $file_text = str_replace('/*THUMBNAIL-IMG-WIDTH*/', 'width: '.$thumbnail_width .'px;', $file_text );
497
+ $file_text = str_replace('/*THUMBNAIL-IMG-HEIGHT*/','max-height: '.$thumbnail_height.'px;', $file_text );
498
+ break;
499
+ case '2':
500
+ $file_text = str_replace('/*THUMBNAIL-POSITION*/', 'float: left;', $file_text );
501
+ $file_text = str_replace('/*THUMBNAIL-MARGIN*/', 'margin: 0 6px 4px 4px;', $file_text );
502
+ $file_text = str_replace('/*THUMBNAIL-WIDTH*/', 'max-width: '.$thumbnail_width .'px;', $file_text );
503
+ $file_text = str_replace('/*THUMBNAIL-HEIGHT*/', 'max-height: '.$thumbnail_height.'px;', $file_text );
504
+ $file_text = str_replace('/*THUMBNAIL-IMG-WIDTH*/', 'width: '.$thumbnail_width .'px;', $file_text );
505
+ $file_text = str_replace('/*THUMBNAIL-IMG-HEIGHT*/','max-height: '.$thumbnail_height.'px;', $file_text );
506
+ break;
507
+ case '3':
508
+ $file_text = str_replace('/*THUMBNAIL-POSITION*/', 'display: block;', $file_text );
509
+ $file_text = str_replace('/*THUMBNAIL-MARGIN*/', 'margin: 0 6px 4px 4px;', $file_text );
510
+ $file_text = str_replace('/*THUMBNAIL-WIDTH*/', '', $file_text );
511
+ $file_text = str_replace('/*THUMBNAIL-HEIGHT*/', 'height: '.$thumbnail_height.'px; overflow: hidden;', $file_text );
512
+ $file_text = str_replace('/*THUMBNAIL-IMG-WIDTH*/', 'width: '.$content_width .'px;', $file_text );
513
+ $file_text = str_replace('/*THUMBNAIL-IMG-HEIGHT*/','', $file_text );
514
+ break;
515
+ }
516
+
517
+ // サムネイル影あり
518
+ if (isset($this->options['thumbnail-shadow']) && $this->options['thumbnail-shadow'] == '1') {
519
+ $file_text = str_replace('/*THUMBNAIL-SHADOW*/', 'box-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);', $file_text );
520
+ }
521
+
522
+ // サムネイルのリサイズ
523
+ if (isset($this->options['thumbnail-resize']) && $this->options['thumbnail-resize'] == '1') {
524
+ $size_title = intval(preg_replace('/[^0-9]/', '', isset($this->options['size-title']) ? $this->options['size-title'] : $this->defaults['size-title'] ) );
525
+ $size_excerpt = intval(preg_replace('/[^0-9]/', '', isset($this->options['size-excerpt']) ? $this->options['size-excerpt'] : $this->defaults['size-excerpt'] ) );
526
+ $height_title = intval(preg_replace('/[^0-9]/', '', isset($this->options['height-title']) ? $this->options['height-title'] : $this->defaults['height-title'] ) );
527
+ $height_excerpt = intval(preg_replace('/[^0-9]/', '', isset($this->options['height-excerpt']) ? $this->options['height-excerpt'] : $this->defaults['height-excerpt'] ) );
528
+ $thumbnail_width = intval(preg_replace('/[^0-9]/', '', isset($this->options['thumbnail-width']) ? $this->options['thumbnail-width'] : $this->defaults['thumbnail-width'] ) );
529
+ $file_text = str_replace('/*RESIZE*/',
530
+ '@media screen and (max-width: 600px) {'.PHP_EOL.' .lkc-title { font-size: '.intval($size_title * 0.9).'px; line-height: '.intval($height_title * 0.9).'px; }'.PHP_EOL.' .lkc-excerpt { font-size: '.intval($size_excerpt * 0.95).'px; }'.PHP_EOL.' .lkc-thumbnail { max-width: '.intval($thumbnail_width * 0.9).'px; }'.PHP_EOL.' .lkc-thumbnail-img { max-width: '.intval($thumbnail_width * 0.9).'px; }'.PHP_EOL.'}'.PHP_EOL.
531
+ '@media screen and (max-width: 480px) {'.PHP_EOL.' .lkc-title { font-size: '.intval($size_title * 0.8).'px; line-height: '.intval($height_title * 0.8).'px; }'.PHP_EOL.' .lkc-excerpt { font-size: '.intval($size_excerpt * 0.8).'px; }'.PHP_EOL.' .lkc-thumbnail { max-width: '.intval($thumbnail_width * 0.7).'px; }'.PHP_EOL.' .lkc-thumbnail-img { max-width: '.intval($thumbnail_width * 0.7).'px; }'.PHP_EOL.'}'.PHP_EOL.
532
+ '@media screen and (max-width: 320px) {'.PHP_EOL.' .lkc-title { font-size: '.intval($size_title * 0.7).'px; line-height: '.intval($height_title * 0.7).'px; }'.PHP_EOL.' .lkc-excerpt { font-size: '.intval($size_excerpt * 0.6).'px; }'.PHP_EOL.' .lkc-thumbnail { max-width: '.intval($thumbnail_width * 0.5).'px; }'.PHP_EOL.' .lkc-thumbnail-img { max-width: '.intval($thumbnail_width * 0.5).'px; }'.PHP_EOL.'}', $file_text );
533
+ }
534
+
535
+ // 横幅
536
+ if ($this->options['width']) {
537
+ $file_text = str_replace('/*WIDTH*/', 'max-width: '.$this->options['width'].';', $file_text );
538
+ } else {
539
+ $file_text = str_replace('/*WIDTH*/', 'max-width: 100%;', $file_text );
540
+ }
541
+
542
+ // タイトルを折り返さない
543
+ if ($this->options['nowrap-title']) {
544
+ $file_text = str_replace('/*NOWRAP-TITLE*/', 'white-space: nowrap; text-overflow: ellipsis;', $file_text );
545
+ }
546
+
547
+ // URLを折り返さない
548
+ if ($this->options['nowrap-url']) {
549
+ $file_text = str_replace('/*NOWRAP-URL*/', 'white-space: nowrap; text-overflow: ellipsis;', $file_text );
550
+ }
551
+
552
+ // 記事情報の高さ
553
+ if ($this->options['content-height']) {
554
+ $file_text = str_replace('/*CONTENT-HEIGHT*/', 'height: '.$this->options['content-height'].';', $file_text );
555
+ }
556
+
557
+ // 枠線の太さ
558
+ $border = (preg_replace('/[^0-9]/', '', $this->options['border-width']) - 0).'px ';
559
+ $border .= (isset($this->options['border-style']) ? $this->options['border-style'] : $this->defaults['border-style']).' ';
560
+ $ex_border = $border.(isset($this->options['ex-border-color']) ? $this->options['ex-border-color'] : $this->defaults['ex-border-color']).';';
561
+ $in_border = $border.(isset($this->options['in-border-color']) ? $this->options['in-border-color'] : $this->defaults['in-border-color']).';';
562
+ $th_border = $border.(isset($this->options['th-border-color']) ? $this->options['th-border-color'] : $this->defaults['th-border-color']).';';
563
+ $file_text = str_replace('/*EX-BORDER*/', 'border: '.$ex_border, $file_text );
564
+ $file_text = str_replace('/*IN-BORDER*/', 'border: '.$in_border, $file_text );
565
+ $file_text = str_replace('/*TH-BORDER*/', 'border: '.$th_border, $file_text );
566
+
567
+ // 抜粋文の部分を凹ませる
568
+ if (isset($this->options['content-inset']) && $this->options['content-inset'] == '1') {
569
+ $file_text = str_replace('/*CONTENT-PADDING*/', 'padding: 6px;', $file_text );
570
+ $file_text = str_replace('/*CONTENT-INSET*/', 'box-shadow: 4px 4px 4px rgba(0, 0, 0, 0.5) inset;', $file_text );
571
+ $file_text = str_replace('/*CONTENT-BGCOLOR*/', 'background-color: rgba(255, 255, 255, 0.8 );', $file_text );
572
+ }
573
+
574
+ // 記事情報のマージン
575
+ $file_text = str_replace('/*CONTENT-MARGIN*/', 'margin: 6px 0 0 0;', $file_text );
576
+
577
+ // 抜粋文のマージン
578
+ $file_text = str_replace('/*MARGIN-EXCERPT*/', 'margin: 0;', $file_text );
579
+
580
+ // サイト情報の区切り線
581
+ if (isset($this->options['separator']) && $this->options['separator'] == '1') {
582
+ switch ($this->options['info-position']) {
583
+ case '1':
584
+ $file_text = str_replace('/*SEPARATOR*/', 'border-top: 1px solid '.$this->options['color-info'].';', $file_text );
585
+ break;
586
+ case '2':
587
+ $file_text = str_replace('/*SEPARATOR*/', 'border-bottom: 1px solid '.$this->options['color-info'].';', $file_text );
588
+ break;
589
+ }
590
+ }
591
+
592
+ // 付加情報
593
+ if (isset($this->options['heading']) && $this->options['heading'] == '1') {
594
+ $added_height = intval(preg_replace('/[^0-9]/', '', isset($this->options['height-added'] ) ? $this->options['height-added'] : $this->defaults['height-added'] ) );
595
+ $heading_height = intval( $added_height / 2 );
596
+ $heading_padding = intval( $added_height / 4 );
597
+ $file_text = str_replace('/*EX-HEADING*/', 'position: absolute; top: -'.$heading_height.'px; left: 20px; padding: 0 '.$heading_padding.'px; background-color: '.$this->options['ex-border-color'].'; border-radius: 2px;', $file_text );
598
+ $file_text = str_replace('/*IN-HEADING*/', 'position: absolute; top: -'.$heading_height.'px; left: 20px; padding: 0 '.$heading_padding.'px; background-color: '.$this->options['in-border-color'].'; border-radius: 2px;', $file_text );
599
+ $file_text = str_replace('/*TH-HEADING*/', 'position: absolute; top: -'.$heading_height.'px; left: 20px; padding: 0 '.$heading_padding.'px; background-color: '.$this->options['th-border-color'].'; border-radius: 2px;', $file_text );
600
+ }
601
+
602
+ // 続きを読むボタン
603
+ switch ($this->options['flg-more']) {
604
+ case '1':
605
+ $file_text = str_replace('/*STYLE-MORE*/', 'padding: 4px; margin: 4px 0;', $file_text );
606
+ break;
607
+ case '2':
608
+ $file_text = str_replace('/*STYLE-MORE*/', 'border: 1px solid #888; text-align: center; padding: 4px; margin: 4px 0;', $file_text );
609
+ break;
610
+ case '3':
611
+ $file_text = str_replace('/*STYLE-MORE*/', 'border: 1px solid #888; border-radius: 6px; text-align: center; padding: 4px; margin: 4px 0; background-color: #46f;', $file_text );
612
+ break;
613
+ case '4':
614
+ $file_text = str_replace('/*STYLE-MORE*/', 'border: 1px solid #888; border-radius: 6px; text-align: center; padding: 4px; margin: 4px 0; background-color: #888;', $file_text );
615
+ break;
616
+ }
617
+
618
+ // アンカーの文字装飾
619
+ if (isset($this->options['flg-anker']) && $this->options['flg-anker'] == '1') {
620
+ $file_text = str_replace('/*ANKER*/', 'text-decoration: none !important;', $file_text );
621
+ }
622
+
623
+ // 追加CSS
624
+ if (isset($this->options['css-add'])) {
625
+ $file_text = str_replace('/*CSS-ADD*/', $this->options['css-add'], $file_text );
626
+ } else {
627
+ $file_text = str_replace('/*CSS-ADD*/', '', $file_text );
628
+ }
629
+
630
+ // ぽぽづれ。へのリンクを表示する
631
+ if (isset($this->options['plugin-link']) && $this->options['plugin-link'] == '1') {
632
+ $file_text = str_replace('/*CREDIT*/', 'display: block;', $file_text );
633
+ } else {
634
+ $file_text = str_replace('/*CREDIT*/', 'display: none;', $file_text );
635
+ }
636
+
637
+ $result = file_put_contents($css_path, $file_text);
638
+ global $pagenow;
639
+ if (isset($pagenow) && $pagenow == 'options-general.php') {
640
+ if ($result == true) {
641
+ echo '<div class="updated fade"><p><strong>'.__('Style sheet saved.', $this->text_domain).'</strong></p></div>';
642
+ } else {
643
+ echo '<div class="error fade"><p><strong>'.__('Style sheet failed.', $this->text_domain).'</strong></p></div>';
644
+ }
645
+ }
646
+ }
647
+ unset($temp_name);
648
+ unset($file_text);
649
+ unset($result);
650
  }
pz-linkcard.php CHANGED
@@ -1,1833 +1,1833 @@
1
- <?php
2
- /*
3
- Plugin Name: Pz-LinkCard
4
- Plugin URI: http://poporon.poponet.jp/pz-linkcard
5
- Description: リンクをカード形式で表示します。
6
- Version: 2.3.0
7
- Author: poporon
8
- Author URI: http://poporon.poponet.jp
9
- License: GPLv2 or later
10
- */
11
-
12
- defined('ABSPATH') || die;
13
-
14
- class Pz_LinkCard {
15
- public $slug; // スラッグ
16
- public $text_domain; // テキスト ドメイン(スラッグと同じ内容)
17
-
18
- public $charset; // 文字セット
19
-
20
- public $amp; // Google AMP
21
-
22
- public $now; // 現在日時(ローカル時間)
23
- public $now_mysql; // 現在日時(SQL形式)
24
-
25
- public $plugin_basename; // プラグイン ディレクトリの名前
26
- public $plugin_dir_path; // プラグイン ディレクトリのパス
27
- public $plugin_dir_url; // プラグイン ディレクトリのURL
28
- public $plugin_link; // プラグインページのURL
29
-
30
- public $upload_dir_path; // アップロード ディレクトリのパス
31
- public $upload_dir_url; // アップロード ディレクトリのURL
32
-
33
- private $db_name; // DB名
34
-
35
- public $options;
36
- protected $defaults = array(
37
- 'code1' => 'blogcard',
38
- 'code2' => null,
39
- 'code3' => null,
40
- 'code4' => null,
41
- 'auto-atag' => null,
42
- 'auto-url' => null,
43
- 'auto-external' => null,
44
- 'trail-slash' => '1',
45
- 'border-width' => '1px',
46
- 'border-style' => 'solid',
47
- 'border-color' => '#888888',
48
- 'width' => '500px',
49
- 'content-height' => '108px',
50
- 'margin-top' => '4px',
51
- 'margin-right' => '16px',
52
- 'margin-bottom' => '16px',
53
- 'margin-left' => '4px',
54
- 'card-top' => null,
55
- 'card-right' => null,
56
- 'card-bottom' => null,
57
- 'card-left' => null,
58
- 'centering' => null,
59
- 'radius' => null,
60
- 'shadow' => null,
61
- 'shadow-inset' => null,
62
- 'opacity' => null,
63
- 'hover' => null,
64
- 'special-format' => null,
65
- 'use-inline' => null,
66
- 'use-sitename' => '1',
67
- 'use-hatena' => null,
68
- 'display-url' => '1',
69
- 'display-excerpt' => '1',
70
- 'display-date' => '1',
71
- 'trim-title' => 80,
72
- 'trim-url' => 250,
73
- 'trim-count' => 250,
74
- 'trim-sitename' => 45,
75
- 'info-position' => '1',
76
- 'separator' => null,
77
- 'size-title' => '16px',
78
- 'size-url' => '10px',
79
- 'size-excerpt' => '11px',
80
- 'size-info' => '12px',
81
- 'size-added' => '12px',
82
- 'size-more' => '12px',
83
- 'size-plugin' => '10px',
84
- 'height-title' => '24px',
85
- 'height-url' => '10px',
86
- 'height-excerpt' => '17px',
87
- 'height-info' => '12px',
88
- 'height-added' => '12px',
89
- 'height-more' => '40px',
90
- 'height-plugin' => '10px',
91
- 'color-title' => '#111111',
92
- 'color-url' => '#4466ff',
93
- 'color-excerpt' => '#333333',
94
- 'color-info' => '#222222',
95
- 'color-added' => '#222222',
96
- 'color-more' => '#444444',
97
- 'color-plugin' => '#888888',
98
- 'outline-color-title' => '#ffffff',
99
- 'outline-color-url' => '#ffffff',
100
- 'outline-color-excerpt' => '#ffffff',
101
- 'outline-color-info' => '#ffffff',
102
- 'outline-color-added' => '#ffffff',
103
- 'outline-color-more' => '#ffffff',
104
- 'outline-color-plugin' => '#ffffff',
105
- 'nowrap-title' => null,
106
- 'nowrap-url' => '1',
107
- 'ex-bgcolor' => '#ffffff',
108
- 'in-bgcolor' => '#f8f8f8',
109
- 'th-bgcolor' => '#eeeeee',
110
- 'ex-border-color' => '#888888',
111
- 'in-border-color' => '#888888',
112
- 'th-border-color' => '#888888',
113
- 'in-get' => null,
114
- 'ex-image' => null,
115
- 'in-image' => null,
116
- 'th-image' => null,
117
- 'ex-info' => null,
118
- 'in-more-text' => null,
119
- 'th-more-text' => null,
120
- 'ex-more-text' => null,
121
- 'in-info' => null,
122
- 'th-info' => null,
123
- 'in-target' => null,
124
- 'ex-target' => '2',
125
- 'ex-thumbnail' => '13',
126
- 'in-thumbnail' => '1',
127
- 'ex-favicon' => '3',
128
- 'in-favicon' => '3',
129
- 'favicon-api' => 'https://www.google.com/s2/favicons?domain=%DOMAIN%',
130
- 'thumbnail-api' => 'https://s.wordpress.com/mshots/v1/%URL%?w=100',
131
- 'thumbnail-position'=> '2',
132
- 'thumbnail-width' => '100px',
133
- 'thumbnail-height' => '108px',
134
- 'thumbnail-shadow' => null,
135
- 'thumbnail-resize' => '1',
136
- 'cache-time' => 31536000,
137
- 'user-agent' => null,
138
- 'flg-more' => null,
139
- 'flg-referer' => '1',
140
- 'flg-agent' => '1',
141
- 'flg-redir' => '1',
142
- 'flg-alive' => '1',
143
- 'flg-alive-count' => null,
144
- 'flg-ssl' => '1',
145
- 'flg-amp-url' => null,
146
- 'flg-relative-url' => null,
147
- 'flg-idn' => '1',
148
- 'flg-anker' => '1',
149
- 'flg-unlink' => '1',
150
- 'flg-get-pid' => null,
151
- 'flg-subdir' => '1',
152
- 'flg-invalid' => null,
153
- 'flg-edit-insert' => '1',
154
- 'flg-edit-qtag' => '1',
155
- 'flg-do-shortcode' => null,
156
- 'style-reset-img' => '1',
157
- 'style' => null,
158
- 'css-add' => null,
159
- 'css-sp' => null,
160
- 'css-file' => null,
161
- 'css-path' => null,
162
- 'css-url' => null,
163
- 'class-pc' => null,
164
- 'class-mobile' => null,
165
- 'sns-position' => '2',
166
- 'sns-tw' => '1',
167
- 'sns-fb' => '1',
168
- 'sns-hb' => '1',
169
- 'sns-po' => '1',
170
- 'link-all' => '1',
171
- 'blockquote' => null,
172
- 'nofollow' => null,
173
- 'presence' => null,
174
- 'thumbnail-dir' => null,
175
- 'thumbnail-url' => null,
176
- 'invalid-url' => null,
177
- 'invalid-time' => null,
178
- 'plugin-link' => null,
179
- 'plugin-name' => 'Pz-LinkCard',
180
- 'plugin-version' => '2.3.0',
181
- 'plugin-url' => 'https://popozure.info/pz-linkcard',
182
- 'pz-hbc-options' => null,
183
- 'debug-time' => null
184
- );
185
-
186
- public function __construct() {
187
- $this->slug = basename(dirname(__FILE__));
188
- $this->text_domain = $this->slug;
189
-
190
- $this->charset = get_bloginfo('charset');
191
-
192
- $this->amp = '1';
193
-
194
- $this->now = current_time('timestamp', false);
195
- $this->now_mysql = current_time('mysql');
196
-
197
- $this->plugin_basename = plugin_basename(__FILE__);
198
- $this->plugin_dir_path = plugin_dir_path(__FILE__);
199
- $this->plugin_dir_url = plugin_dir_url (__FILE__);
200
-
201
- $wp_upload_dir = wp_upload_dir();
202
- $this->upload_dir_path = $wp_upload_dir['basedir'].'/'.$this->slug.'/';
203
- $this->upload_dir_url = $wp_upload_dir['baseurl'].'/'.$this->slug.'/';
204
-
205
- $this->options = get_option('Pz_LinkCard_options', $this->defaults );
206
- foreach ($this->defaults as $key => $value) {
207
- if (!isset($this->options[$key])) {
208
- $this->options[$key] = null;
209
- }
210
- }
211
-
212
- // DB
213
- global $wpdb;
214
- $this->db_name = $wpdb->prefix.'pz_linkcard';
215
-
216
- // バージョンが違っていたら、DBとオプションを更新する
217
- if ($this->options['plugin-version'] <> $this->defaults['plugin-version']) {
218
- $this->activate();
219
- }
220
-
221
- // ショートコードの設定
222
- if ($this->options['auto-atag'] || $this->options['auto-url']) {
223
- add_filter ('the_content', array($this, 'auto_replace') ); // 自動置き換え
224
- add_shortcode ('pz-linkcard-auto-replace', array($this, 'shortcode') ); // 自動置き換え専用ショートコード
225
- }
226
- if ($this->options['code1']) {
227
- add_shortcode($this->options['code1'], array($this, 'shortcode'));
228
- }
229
- if ($this->options['code2']) {
230
- add_shortcode($this->options['code2'], array($this, 'shortcode'));
231
- }
232
- if ($this->options['code3']) {
233
- add_shortcode($this->options['code3'], array($this, 'shortcode'));
234
- }
235
- if ($this->options['code4']) {
236
- add_shortcode($this->options['code4'], array($this, 'shortcode'));
237
- }
238
-
239
- // 日本語化
240
- load_plugin_textdomain ($this->text_domain, false, $this->slug.'/languages');
241
-
242
- // 管理画面のとき
243
- if (is_admin()) {
244
- register_activation_hook (__FILE__, array($this, 'activate') ); // 有効化したときの処理
245
- register_deactivation_hook (__FILE__, array($this, 'deactivate') ); // 無効化したときの処理
246
- add_action ('admin_menu', array($this, 'add_menu') ); // 設定メニュー
247
- add_action ('admin_enqueue_scripts', array($this, 'enqueue_admin') ); // 設定メニュー用スクリプト
248
- add_action ('admin_print_footer_scripts', array($this, 'add_footer') ); // テキストエディタ用クイックタグ
249
- add_action ('admin_notices', array($this, 'add_notices')); // 注意書き
250
- add_filter ('mce_buttons', array($this, 'add_mce_button') ); // ビジュアルエディタ用ボタン
251
- add_filter ('mce_external_plugins', array($this, 'add_mce_plugin') ); // ビジュアルエディタ用ボタン
252
- add_filter ('plugin_action_links_'.$this->plugin_basename, array($this, 'action_links') ); // プラグイン画面
253
- } else {
254
- add_action('wp_enqueue_scripts', array($this, 'enqueue'));
255
- }
256
-
257
- add_action( 'pz_linkcard_check', array( $this, 'schedule_hook_check' ) );
258
- add_action( 'pz_linkcard_alive', array( $this, 'schedule_hook_alive' ) );
259
-
260
- if (!wp_next_scheduled('pz_linkcard_check')) {
261
- wp_schedule_event ( time() + 10 , 'hourly', 'pz_linkcard_check');
262
- }
263
- if (!wp_next_scheduled('pz_linkcard_alive')) {
264
- wp_schedule_event ( time() + 1800 , 'daily', 'pz_linkcard_alive');
265
- }
266
- }
267
-
268
- // テキストリンクの行とURLのみの行をリンクカードへ置き換える処理(直接HTMLタグにするのでは無くショートコードに変換する。)
269
- public function auto_replace($content) {
270
- if (!$this->options['auto-external']) {
271
- if ($this->options['auto-atag']) {
272
- $content = preg_replace( '/(^|<br ?\/?>)(<p.*>)?<a .*href=[\'"](https?:\/\/[-_\.!~*()a-zA-Z0-9;\/?:\@&=+\$,%#]+)[\'"]((?!<IMG).)*<\/a>(<\/p>)?$/im', '[pz-linkcard-auto-replace url="$3"]', $content);
273
- }
274
- if ($this->options['auto-url']) {
275
- $content = preg_replace( '/(^|<br ?\/?>)(<p.*>)?(https?:\/\/[-_\.!~*()a-zA-Z0-9;\/?:\@&=+\$,%#]+)(<\/p>|<br ?\/?>)?$/im', '[pz-linkcard-auto-replace url="$3"]', $content);
276
- }
277
- if ($this->options['flg-do-shortcode']) {
278
- $content = do_shortcode($content);
279
- }
280
- return $content;
281
- } else {
282
- if ($this->options['auto-atag']) {
283
- preg_match_all('/(^|<br ?\/?>)(<p.*>)?(<a .*href=[\'"](https?:\/\/[-_\.!~*()a-zA-Z0-9;\/?:\@&=+\$,%#]+)[\'"]((?!<IMG).)*<\/a>)(<\/p>)?$/im', $content, $m );
284
- for ($i=0; $i<count($m[0]); $i++) {
285
- $url = $m[4][$i];
286
- if ($this->Pz_LinkType($url ) == 0) {
287
- $tag = '[pz-linkcard-auto-replace url="'.$url.'"]';
288
- $content = preg_replace('{'.$m[0][$i].'}', $tag, $content, 1);
289
- }
290
- }
291
- }
292
- if ($this->options['auto-url']) {
293
- preg_match_all('/(^|<br ?\/?>)(<p.*>)?(https?:\/\/[-_\.!~*()a-zA-Z0-9;\/?:\@&=+\$,%#]+)(<\/p>|<br ?\/?>)?$/im', $content, $m );
294
- for ($i=0; $i<count($m[0]); $i++) {
295
- $url = $m[3][$i];
296
- if ($this->Pz_LinkType($url ) == 0) {
297
- $tag = '[pz-linkcard-auto-replace url="'.$url.'"]';
298
- $content = preg_replace('{'.$m[0][$i].'}', $tag, $content, 1);
299
- }
300
- }
301
- }
302
- if ($this->options['flg-do-shortcode']) {
303
- $content = do_shortcode($content);
304
- }
305
- return $content;
306
- }
307
- }
308
-
309
- // ショートコード処理
310
- public function shortcode($atts, $content = null, $shortcode) {
311
- // 実行時間
312
- if ($this->options['debug-time']) {
313
- $start_time = microtime(true);
314
- echo PHP_EOL.'<!-- Pz-LkC [Debug mode: On] /-->'.PHP_EOL;
315
- echo '<!-- Pz-LkC [Shortcode] /-->'.PHP_EOL;
316
- }
317
-
318
- // URL
319
- $url = '';
320
- if (isset( $atts['url'] ) ) {
321
- $url = $atts['url'];
322
- } elseif (isset( $atts['href'] ) ) { // Aタグのようにhrefパラメータも有効にする
323
- $url = $atts['href'];
324
- } elseif (isset( $atts['uri'] ) ) { // 密かに記述ミス対応(uriやurIでもurlとして判定する)
325
- $url = $atts['uri'];
326
- } elseif (isset( $atts['ur1'] ) ) { // 密かに記述ミス対応(ur1でもurlとして判定する)
327
- $url = $atts['ur1'];
328
- } elseif (isset( $atts[0] ) ) { // 謎の記述ミスに対応
329
- if (preg_match('/url=[\s \'\"‘’“”″]*(.*?)[\s \'\"‘’“”″]*$/u', $atts[0], $m)) {
330
- $url = $m[1];
331
- } elseif (isset( $atts[1] ) ) { // 謎の記述ミスに対応
332
- if (preg_match('/url=[\s \'\"‘’“”″]*(.*?)[\s \'\"‘’“”″]*$/u', $atts[1], $m)) {
333
- $url = $m[1];
334
- }
335
- }
336
- }
337
- $url_org = $url; // 指定されたurlパラメータ
338
- if ($this->options['flg-relative-url']) {
339
- if (substr($url, 0, 1) == '/') {
340
- $url = home_url() . $url;
341
- }
342
- }
343
- $url = $this->pz_TrimURL( $url ); // URLエンティティ化など(無害化?)
344
- if ( !$url ) {
345
- if ($this->options['debug-time']) {
346
- echo '<!-- Pz-LkC ['.html_entity_decode(print_r($atts, true)).'] /-->'.PHP_EOL;
347
- }
348
- if (!$this->options['flg-invalid']) {
349
- if (!preg_match('/\/wp-admin\/admin-ajax.php/i', $_SERVER["REQUEST_URI"])) {
350
- $this->options['flg-invalid'] = '1';
351
- $this->options['invalid-url'] = (!$_SERVER["HTTPS"] ? "http://" : "https://").$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];
352
- $this->options['invalid-time'] = $this->now;
353
- $result = update_option('Pz_LinkCard_options', $this->options);
354
- }
355
- }
356
- return '<a name="pz-lkc-error"></a><div class="lkc-error"><div class="lkc-card"><div class="lkc-this-wrap"><div class="lkc-excerpt">'.$this->slug.': '.__('Incorrect URL specification.', $this->text_domain).'(url='.html_entity_decode($url_org).')'.PHP_EOL.'<!-- '.html_entity_decode(print_r($atts, true)).' /-->'.PHP_EOL.'</div></div></div></div>';
357
- }
358
- $atts['url'] = $url;
359
-
360
- // titleパラメータ
361
- $s_title = isset($atts['title'] ) ? $atts['title'] : null;
362
-
363
- // contentパラメータ
364
- if (isset($atts['content'] ) ) {
365
- $s_excerpt = $atts['content'];
366
- } elseif (isset($atts['contents'] ) ) {
367
- $s_excerpt = $atts['contents'];
368
- } elseif (isset($atts['description'] ) ) {
369
- $s_excerpt = $atts['description'];
370
- } else {
371
- $s_excerpt = null;
372
- }
373
-
374
- // 囲まれ文字(ショートコード1のみ有効)
375
- if ($shortcode == $this->options['code1']) {
376
- switch (isset($this->options['use-inline']) ? $this->options['use-inline'] : null) {
377
- case '1':
378
- $s_excerpt = isset($content) ? $content : '';
379
- break;
380
- case '2':
381
- $s_title = isset($content) ? $content : '';
382
- break;
383
- }
384
- }
385
-
386
- // 記事内容取得
387
- $data = $this->pz_GetHTML ( $atts );
388
-
389
- // 実行時間
390
- if ($this->options['debug-time']) {
391
- $end_time = microtime(true);
392
- $elasped_time = number_format($end_time - $start_time, 8, '.', ',');
393
- echo '<!-- Pz-LkC [ElaspedTime='.$elasped_time.'sec] /-->'.PHP_EOL;
394
- }
395
-
396
- return $data;
397
- }
398
-
399
- // キャッシュやリンク先からリンクカードのHTMLを生成
400
- function pz_GetHTML( $atts, $content = null ) {
401
- if ($this->options['debug-time']) {
402
- echo '<!-- Pz-LkC [GetHTML] /-->'.PHP_EOL;
403
- }
404
-
405
- // モバイルチェック
406
- if (function_exists('wp_is_mobile') && wp_is_mobile()) {
407
- $is_mobile = true;
408
- } else {
409
- $is_mobile = false;
410
- }
411
- if ($this->options['debug-time']) {
412
- echo '<!-- Pz-LkC [MOBILE='.$is_mobile.'] /-->'.PHP_EOL;
413
- }
414
-
415
- $url = $atts['url'];
416
- if (!isset($url) || $url == '' ) {
417
- return null;
418
- }
419
- if ($this->options['debug-time']) {
420
- echo '<!-- Pz-LkC [URL='.$url.'] /-->'.PHP_EOL;
421
- }
422
-
423
- // URLパース(ドメイン名などを抽出)
424
- $url_m = parse_url( $url );
425
- $scheme = $url_m['scheme']; // スキーム
426
- $domain = $url_m['host']; // ドメイン名
427
- $domain_url = $scheme.'://'.$url_m['host']; // ドメインURL
428
- $location = substr($url, mb_strlen($domain_url)); // ドメイン名以降
429
-
430
- // 自サイトチェック
431
- $link_type = $this->Pz_LinkType($url);
432
-
433
- // モバイルかPCかのクラス名を追加
434
- $class_id = 'linkcard';
435
- if ($is_mobile && $this->options['class-mobile']) {
436
- $class_id .= ' '.$this->options['class-mobile'];
437
- } elseif ($this->options['class-pc']) {
438
- $class_id .= ' '.$this->options['class-pc'];
439
- }
440
-
441
- // キャッシュから取得
442
- $data_id = null;
443
- $data = array();
444
- $data['url'] = $url;
445
- $result = $this->pz_GetCache( $data );
446
- if (isset($result) && is_array($result) && isset($result['url'])) {
447
- $data = $result;
448
- $data_id = $data['id'];
449
- $url = $data['url'];
450
- }
451
- if ($this->options['debug-time']) {
452
- echo '<!-- Pz-LkC [CACHE='.$data_id.'] /-->'.PHP_EOL;
453
- }
454
-
455
- // 内部リンクの処理
456
- if ( $link_type ) {
457
- // リンクターゲットの設定
458
- $target = ''; // 同ページに開く
459
- if (isset($this->options['in-target'])) {
460
- if ($this->options['in-target'] == '1' || ($this->options['in-target'] == '2' && !$is_mobile)) {
461
- $target = ' target="_blank"'; // 新しいページで開く
462
- }
463
- }
464
-
465
- // followパラメータ
466
- if ( (isset($atts['follow'] ) && mb_strtolower($atts['follow']) == 'no') || (isset($atts['nofollow'] ) && mb_strtolower($atts['nofollow']) == 'true') ) {
467
- $nofollow = ' rel="nofollow"'; // nofollow指定。趣味の問題?
468
- } else {
469
- $nofollow = '';
470
- }
471
-
472
- // キャッシュが無い、もしくは強制取得
473
- if ( is_null($data_id) || ( isset($atts['force']) && $atts['force'] == true ) ) {
474
- if ($this->options['debug-time']) {
475
- echo '<!-- Pz-LkC [IN-POST] /-->'.PHP_EOL;
476
- }
477
- $data = $this->pz_GetPost( $data ); // 最新記事内容を取得
478
- $data['link_type'] = 1;
479
- if ($this->options['debug-time']) {
480
- echo '<!-- Pz-LkC [IN-SET] /-->'.PHP_EOL;
481
- }
482
- $result = $this->pz_SetCache( $data ); // 保存
483
- } elseif ($this->options['in-get'] <> 2) {
484
- if ($this->options['debug-time']) {
485
- echo '<!-- Pz-LkC [IN-POST] /-->'.PHP_EOL;
486
- }
487
- $data = $this->pz_GetPost( $data ); // 最新記事内容を取得
488
- $data['link_type'] = 1;
489
- }
490
- }
491
-
492
- // 外部リンクの処理
493
- if ( !$link_type ) {
494
- // リンクターゲットの設定
495
- $target = ''; // 同ページに開く
496
- if (isset($this->options['ex-target'] ) ) {
497
- if ($this->options['ex-target'] == '1' || ($this->options['ex-target'] == '2' && !$is_mobile ) ) {
498
- $target = ' target="_blank"'; // 新しいページで開く
499
- }
500
- }
501
-
502
- // followパラメータ
503
- if (isset($this->options['nofollow'] ) || (isset($atts['follow'] ) && mb_strtolower($atts['follow']) == 'no') || (isset($atts['nofollow'] ) && mb_strtolower($atts['nofollow']) == 'true') ) {
504
- $nofollow = ' rel="nofollow"'; // nofollow指定。趣味の問題?
505
- } else {
506
- $nofollow = '';
507
- }
508
-
509
- // キャッシュが無い、もしくは強制取得
510
- if ( is_null($data_id) || ( isset($atts['force']) && $atts['force'] == true ) ) {
511
- if ($this->options['debug-time']) {
512
- echo '<!-- Pz-LkC [OUT-CURL] /-->'.PHP_EOL;
513
- }
514
- $result = $this->pz_GetCURL( $data ); // cURLで記事内容を取得
515
- if ( isset($result) && is_array($result) && isset($result['url']) ) {
516
- $data = $result;
517
- $data['link_type'] = 0;
518
- $result = $this->pz_SetCache( $data );
519
- }
520
- }
521
- }
522
-
523
- // 念のため初期化
524
- $data_id = (isset($data['id']) ? $data['id'] : null);
525
- $site_name = (isset($data['site_name']) ? $data['site_name'] : null);
526
- $title = (isset($data['title']) ? $data['title'] : null);
527
- $excerpt = (isset($data['excerpt']) ? $data['excerpt'] : null);
528
- $post_date = (isset($data['post_date']) ? $data['post_date'] : null);
529
- $thumbnail_url = (isset($data['thumbnail']) ? $data['thumbnail'] : null);
530
- $favicon_url = (isset($data['favicon']) ? $data['favicon'] : null);
531
- $result_code = (isset($data['result_code']) ? $data['result_code'] : null);
532
- $sns_tw = (isset($data['sns_twitter']) ? $data['sns_twitter'] : null);
533
- $sns_fb = (isset($data['sns_facebook']) ? $data['sns_facebook'] : null);
534
- $sns_hb = (isset($data['sns_hatena']) ? $data['sns_hatena'] : null);
535
- $sns_po = (isset($data['sns_pocket']) ? $data['sns_pocket'] : null);
536
- $alive_result = (isset($data['alive_result']) ? $data['alive_result'] : null);
537
-
538
- $thumbnail = null;
539
- $favicon = null;
540
-
541
- // ラッピング
542
- switch ($link_type) {
543
- case '1':
544
- $wrap_op = '<div class="lkc-this-wrap">';
545
- $wrap_cl = '</div>';
546
- $added_op = '<div class="lkc-this-added">';
547
- $added_cl = '</div>';
548
- $more = null;
549
- $more_text = null;
550
- $info = isset($this->options['th-info']) ? $this->options['th-info'] : null ;
551
- $sw_thumbnail = isset($this->options['in-thumbnail']) ? $this->options['in-thumbnail'] : '0' ;
552
- $sw_favicon = isset($this->options['in-favicon']) ? $this->options['in-favicon'] : '0' ;
553
- break;
554
- case '2':
555
- $wrap_op = '<div class="lkc-internal-wrap">';
556
- $wrap_cl = '</div>';
557
- $added_op = '<div class="lkc-internal-added">';
558
- $added_cl = '</div>';
559
- $more = isset($this->options['flg-more']) ? $this->options['flg-more'] : null ;
560
- $more_text = isset($this->options['in-more-text']) ? $this->options['in-more-text'] : null ;
561
- $info = isset($this->options['in-info']) ? $this->options['in-info'] : null ;
562
- $sw_thumbnail = isset($this->options['in-thumbnail']) ? $this->options['in-thumbnail'] : '0' ;
563
- $sw_favicon = isset($this->options['in-favicon']) ? $this->options['in-favicon'] : '0' ;
564
- break;
565
- default:
566
- $wrap_op = '<div class="lkc-external-wrap">';
567
- $wrap_cl = '</div>';
568
- $added_op = '<div class="lkc-external-added">';
569
- $added_cl = '</div>';
570
- $more = isset($this->options['flg-more']) ? $this->options['flg-more'] : null ;
571
- $more_text = isset($this->options['ex-more-text']) ? $this->options['ex-more-text'] : null ;
572
- $info = isset($this->options['ex-info']) ? $this->options['ex-info'] : '' ;
573
- $sw_thumbnail = isset($this->options['ex-thumbnail']) ? $this->options['ex-thumbnail'] : '0' ;
574
- $sw_favicon = isset($this->options['ex-favicon']) ? $this->options['ex-favicon'] : '0' ;
575
- break;
576
- }
577
-
578
- // 外部リンクの処理
579
- if ( !$link_type && isset($this->options['use-hatena']) && !is_null($this->options['use-hatena'] ) ) {
580
- // 「はてなブログカード」をそのまま利用する
581
- $tag = '<div class="lkc-iframe-wrap"><iframe src="https://hatenablog-parts.com/embed?url=' .$url.'" class="lkc-iframe" scrolling="no" frameborder="0"></iframe></div>';
582
- if (isset($this->options['blockquote']) ? $this->options['blockquote'] : null == '1') {
583
- $tag = '<div class="'.$class_id.'"><blockquote class="lkc-quote">'.$tag.'</blockquote></div>';
584
- } else {
585
- $tag = '<div class="'.$class_id.'">'.$tag.'</div>';
586
- }
587
- return $tag; // タグを出力してさっさと終了
588
- }
589
-
590
- // サムネイル取得
591
- if ( !$this->options['thumbnail-position'] || ( $result_code <> 0 && $result_code <> 200 ) ) {
592
- $thumbnail = null;
593
- } else {
594
- if ($sw_thumbnail == '1' || $sw_thumbnail == '13') { // 直接取得
595
- if ( !$link_type ) {
596
- $thumbnail_url = $this->pz_GetThumbnail($thumbnail_url); // 外部サイトのサムネイルをキャッシュ
597
- }
598
- if ( isset($thumbnail_url) && $thumbnail_url <> '' ) {
599
- $thumbnail = '<img class="lkc-thumbnail-img" src="'.$thumbnail_url.'" alt="" />';
600
- } elseif ($sw_thumbnail == '13') { // 直接取得に失敗
601
- $sw_thumbnail = '3';
602
- }
603
- }
604
- if ($sw_thumbnail == '3') { // WebAPIを利用
605
- // 画像取得(WebAPI)
606
- if (isset($this->options['thumbnail-api'])) {
607
- $thumbnail = preg_replace('/%DOMAIN_URL%/', $domain_url, $this->options['thumbnail-api'] );
608
- $thumbnail = preg_replace('/%DOMAIN%/', $domain, $thumbnail);
609
- $thumbnail = preg_replace('/%URL%/', rawurlencode($url), $thumbnail);
610
- $thumbnail = '<img class="lkc-thumbnail-img" src="'.$thumbnail.'" alt="" />';
611
- }
612
- }
613
- }
614
-
615
- // ファビコン取得
616
- if (!isset($this->options['info-position'])) {
617
- $favicon = null;
618
- } else{
619
- if ($sw_favicon == '1' || $sw_favicon == '13') { // 直接取得
620
- if ( !is_null($favicon_url ) ) {
621
- $favicon = '<img class="lkc-favicon" src="'.$favicon_url.'" alt="" width=16 height=16 />';
622
- } elseif ($sw_favicon == '13') { // 直接取得に失敗
623
- $sw_favicon == '3';
624
- }
625
- }
626
- if ($sw_favicon == '3') { // WebAPIを利用
627
- // サイトアイコン取得(WebAPI)
628
- if (isset($this->options['favicon-api'])) {
629
- $favicon = preg_replace('/%DOMAIN_URL%/', $domain_url, $this->options['favicon-api'] );
630
- $favicon = preg_replace('/%DOMAIN%/', $domain, $favicon);
631
- $favicon = preg_replace('/%URL%/', rawurlencode($url), $favicon);
632
- $favicon = '<img class="lkc-favicon" src="'.$favicon.'" alt="" width=16 height=16 />';
633
- }
634
- }
635
- }
636
-
637
- // タイトル
638
- if (!isset($title) || $title == '') {
639
- $title = esc_html($url); // タイトル取得できていなかったらURLをセットする
640
- }
641
-
642
- // パラメータ取得(タイトル・抜粋文)
643
- if (isset($atts['title'])) { // titleパラメータ
644
- $title = $atts['title'];
645
- $excerpt = '';
646
- }
647
- if ($excerpt == '') {
648
- if (isset($atts['content'])) { // contrentパラメータ
649
- $excerpt = $atts['content'];
650
- } elseif (isset($atts['contents'])) { // contentsパラメータ
651
- $excerpt = $atts['contents'];
652
- } elseif (isset($atts['description'])) { // descriptionパラメータ
653
- $excerpt = $atts['description'];
654
- }
655
- }
656
-
657
- // タイトル整形
658
- if (isset($title)) {
659
- $str = $title;
660
- $str = strip_tags($str); // タグの除去
661
- $str = str_replace(array("\r", "\n"), '', $str); // 改行削除
662
- $str = esc_html($str); // 念のためエスケープ
663
- $str = mb_strimwidth($str, 0, (isset($this->options['trim-title']) ? $this->options['trim-title'] : $this->defaults['trim-title'] ) , '...');
664
- $title = $str;
665
- }
666
-
667
- // 抜粋文整形(抜粋文非表示の場合、空欄にする)
668
- if (!isset($this->options['display-excerpt']) || is_null($this->options['display-excerpt'])) {
669
- $excerpt = '';
670
- } else {
671
- if (isset($excerpt)) {
672
- $str = $excerpt;
673
- $str = strip_tags($str); // タグの除去
674
- $str = preg_replace('/<!--more-->.+/is', '', $str); // moreタグ以降削除
675
- $str = preg_replace('/\[[^]]*\]/', '', $str); // ショートコードすべて除去
676
- $str = str_replace(array("\r", "\n"), '', $str); // 改行削除
677
- $str = esc_html($str); // 念のためエスケープ
678
- $str = mb_strimwidth($str, 0, (isset($this->options['trim-count']) ? $this->options['trim-count'] : $this->defaults['trim-count'] ) , '...');
679
- $excerpt = $str;
680
- }
681
- }
682
-
683
- // サイト名称を使わない場合、ドメイン名で上書き
684
- $site_title = '';
685
- if ((isset($this->options['use-sitename']) ? $this->options['use-sitename'] : null) && $site_name) {
686
- $c_site_name = $site_name;
687
- $site_name = mb_strimwidth($site_name, 0, (isset($this->options['trim-sitename']) ? $this->options['trim-sitename'] : $this->defaults['trim-sitename'] ) , '...');
688
- if ($site_name <> $c_site_name) {
689
- $site_title = ' title="'.$c_site_name.'"';
690
- }
691
- } else {
692
- $site_name = $domain;
693
- // 日本語ドメイン対応
694
- if (isset($this->options['flg-idn']) ? true : false) {
695
- if (function_exists('idn_to_utf8')) {
696
- if (substr( $domain, 0, 4 ) == 'xn--') {
697
- $site_name = idn_to_utf8( $domain );
698
- }
699
- }
700
- }
701
- }
702
-
703
- // リンク先URL
704
- if ( (isset($this->options['flg-unlink']) ? true : false) && (array_search($alive_result, array('403','404','410'))) ) {
705
- // Not found の時は見え消ししてリンクしない
706
- $a_op_all = '<div style="cursor: not-allowed;" title="">';
707
- $a_cl_all = '</div>';
708
- $a_op = '';
709
- $a_cl = '';
710
- $st_op = '<strike>';
711
- $st_cl = '</strike>';
712
- } elseif ((isset($this->options['link-all']) ? $this->options['link-all'] : null) == '1') {
713
- // カード全体をリンク(どこをクリックしても良いのが分かり易い)
714
- $a_op_all = '<a class="lkc-link no_icon" href="'.$url.'"'.$target.$nofollow.'>';
715
- $a_cl_all = '</a>';
716
- $a_op = '';
717
- $a_cl = '';
718
- $st_op = '';
719
- $st_cl = '';
720
- } else {
721
- // タイトルとかURLとかを個別でリンク(タイトルや抜粋文などの文字を範囲指定をしてコピー等がし易い)
722
- $a_op_all = '';
723
- $a_cl_all = '';
724
- $a_op = '<a class="lkc-link no_icon" href="'.$url.'"'.$target.$nofollow.'>';
725
- $a_cl = '</a>';
726
- $st_op = '';
727
- $st_cl = '';
728
- }
729
-
730
- // ソーシャルカウントの表示
731
- $sns = null;
732
- $sns_info = null;
733
- $sns_title = null;
734
- if ( isset($this->options['sns-position']) ? $this->options['sns-position'] : null ) {
735
- $sns = '';
736
- // カード全体をリンクにするときは表示のみ
737
- if ((isset($this->options['link-all']) ? $this->options['link-all'] : null) == '1') {
738
- if (isset($this->options['sns-tw']) && !is_null($this->options['sns-tw']) && $sns_tw > 0) {
739
- $sns .= ' <div class="lkc-sns-tw">'.$sns_tw.'&nbsp;tweet'.(($sns_tw > 1) ? 's' : '').'</div>';
740
- }
741
- if (isset($this->options['sns-fb']) && !is_null($this->options['sns-fb']) && $sns_fb > 0) {
742
- $sns .= ' <div class="lkc-sns-fb">'.$sns_fb.'&nbsp;share'.(($sns_fb > 1) ? 's' : '').'</div>';
743
- }
744
- if (isset($this->options['sns-hb']) && !is_null($this->options['sns-hb']) && $sns_hb > 0) {
745
- $sns .= ' <div class="lkc-sns-hb">'.$sns_hb.'&nbsp;user'.(($sns_hb > 1) ? 's' : '').'</div>';
746
- }
747
- if (isset($this->options['sns-po']) && !is_null($this->options['sns-po']) && $sns_po > 0) {
748
- $sns .= ' <div class="lkc-sns-po">'.$sns_po.'&nbsp;pocket'.(($sns_po > 1) ? 's' : '').'</div>';
749
- }
750
- } else {
751
- // 外部リンクアイコンを表示させるプラグイン対応のため no_icon を付与
752
- if (isset($this->options['sns-tw']) && !is_null($this->options['sns-tw']) && $sns_tw > 0) {
753
- $sns .= ' <a class="lkc-sns-tw no_icon" href="https://twitter.com/search?q=' .preg_replace('/.*\/\/(.*)/', '$1', $url).'&text='.esc_html($title).'" target="_blank">'.$sns_tw.'&nbsp;tweet'.(($sns_tw > 1) ? 's' : '').'</a>';
754
- }
755
- if (isset($this->options['sns-fb']) && !is_null($this->options['sns-fb']) && $sns_fb > 0) {
756
- $sns .= ' <a class="lkc-sns-fb no_icon" href="https://www.facebook.com/" target="_blank">'.$sns_fb.'&nbsp;share'.(($sns_fb > 1) ? 's' : '').'</a>';
757
- }
758
- if (isset($this->options['sns-hb']) && !is_null($this->options['sns-hb']) && $sns_hb > 0) {
759
- $sns .= ' <a class="lkc-sns-hb no_icon" href="https://b.hatena.ne.jp/entry/s/' .preg_replace('/.*\/\/(.*)/', '$1', $url).'" target="_blank">'.$sns_hb.'&nbsp;user'.(($sns_hb > 1) ? 's' : '').'</a>';
760
- }
761
- if (isset($this->options['sns-po']) && !is_null($this->options['sns-po']) && $sns_po > 0) {
762
- $sns .= ' <a class="lkc-sns-po no_icon" href="https://getpocket.com/" target="_blank">'.$sns_po.'&nbsp;pocket'.(($sns_po > 1) ? 's' : '').'</a>';
763
- }
764
- }
765
- if ($sns) {
766
- if ($this->options['sns-position'] == '1') {
767
- $sns_title = '<div class="lkc-share">'.$sns.'</div>';
768
- } else {
769
- $sns_info = '&nbsp;'.'<div class="lkc-share">'.$sns.'</div>';
770
- }
771
- }
772
- }
773
-
774
- // サムネイル
775
- if ($thumbnail) {
776
- $thumbnail = '<figure class="lkc-thumbnail">'.$thumbnail.'</figure>';
777
- }
778
-
779
- // 日本語ドメイン対応
780
- if (isset($this->options['flg-idn']) ? true : false) {
781
- if (function_exists('idn_to_utf8')) {
782
- if (substr( $domain, 0, 4 ) == 'xn--') {
783
- $url = $scheme.'://'.idn_to_utf8( $domain ).$location;
784
- }
785
- }
786
- }
787
-
788
- // 続きを読むボタン
789
- if ( $more && $more_text ) {
790
- $moretag = '<div class="lkc-more">'.$a_op.'<div class="lkc-more-text">'.$more_text.'</div>'.$a_cl.'</div>';
791
- } else {
792
- $moretag = '';
793
- }
794
-
795
- // リンク先URL
796
- $url1 = '';
797
- $url2 = '';
798
- if ($this->options['display-url']) {
799
- if ($this->options['display-url'] == '2') {
800
- $url2 = '&nbsp;<div class="lkc-url-info"><cite>'.$st_op.$a_op.$url.$st_cl.$a_cl.'</cite></div>';
801
- } else {
802
- $url1 = '<div class="lkc-url"><cite>'.$st_op.$a_op.$url.$st_cl.$a_cl.'</cite></div>';
803
- }
804
- }
805
-
806
- // サイト情報
807
- if ($info) {
808
- $added_info = $added_op.$info.$added_cl;
809
- } else {
810
- $added_info = '';
811
- }
812
- if ($this->options['display-date'] && $link_type) {
813
- $post_date = '<div class="lkc-date">'.date('Y.m.d', strtotime($post_date)).'</div>';
814
- } else {
815
- $post_date = '';
816
- }
817
- $domain_info = '<div class="lkc-info">'.$a_op.$favicon.'<div class="lkc-domain"'.$site_title.'>'.$site_name.'</div>'.$added_info.$a_cl.$sns_info.$url2.$post_date.'</div>';
818
-
819
- // 記事内容
820
- //$content = '<div class="lkc-content">'.$a_op.$thumbnail.'<div class="lkc-title"><div class="lkc-title-text">'.$title.'</div>'.$a_cl.$sns_title.'</div>'.$url1.'<div class="lkc-excerpt">'.$excerpt.'</div>'.$moretag.'</div>';
821
-
822
- // Google AMPに対応
823
- if ( (function_exists('is_amp_endpoint') && is_amp_endpoint()) || isset($this->amp) || ( isset($this->options['flg-amp-url']) && ( preg_match('/\/amp\/?$/i', $_SERVER["REQUEST_URI"]) || preg_match('/\?amp=1$/i', $_SERVER["REQUEST_URI"]) ) ) ) {
824
- // 簡易タグ作成
825
- $tag = '<table border="1" cellspacing="0" cellpadding="4"><tbody></tr><tr><td>'.$excerpt.'<br>'.$a_op_all.$a_op.$title.$a_cl.$a_cl_all.' - '.$site_name.'</td></tr></tbody></table>';
826
- } else {
827
- // HTMLタグ作成
828
- switch (isset($this->options['info-position']) ? $this->options['info-position'] : null) {
829
- case '1':
830
- $tag = $wrap_op.$a_op_all.'<div class="lkc-card">'.$domain_info.'<div class="lkc-content">'.$a_op.$thumbnail.'<div class="lkc-title"><div class="lkc-title-text">'.$title.'</div>'.$a_cl.$sns_title.'</div>'.$url1.'<div class="lkc-excerpt">'.$excerpt.'</div>'.$moretag.'</div><div class="clear"></div></div>'.$a_cl_all.$wrap_cl;
831
- break;
832
- case '2':
833
- $tag = $wrap_op.$a_op_all.'<div class="lkc-card"><div class="lkc-content">'.$a_op.$thumbnail.'<div class="lkc-title"><div class="lkc-title-text">'.$title.'</div>'.$a_cl.$sns_title.'</div>'.$url1.'<div class="lkc-excerpt">'.$excerpt.'</div>'.$moretag.'</div>'.$domain_info.'<div class="clear"></div></div>'.$a_cl_all.$wrap_cl;
834
- break;
835
- case '3':
836
- $tag = $wrap_op.$a_op_all.'<div class="lkc-card"><div class="lkc-content">'.$a_op.$thumbnail.$domain_info.'<div class="lkc-title"><div class="lkc-title-text">'.$title.'</div>'.$a_cl.$sns_title.$url1.'</div><div class="lkc-excerpt">'.$excerpt.'</div>'.$moretag.'</div><div class="clear"></div></div>'.$a_cl_all.$wrap_cl;
837
- break;
838
- default:
839
- $tag = $wrap_op.$a_op_all.'<div class="lkc-card"><div class="lkc-content">'.$a_op.$thumbnail.'<div class="lkc-title"><div class="lkc-title-text">'.$title.'</div>'.$a_cl.$sns_title.'</div>'.$url1.'<div class="lkc-excerpt">'.$excerpt.'</div>'.$moretag.'</div><div class="clear"></div></div>'.$a_cl_all.$wrap_cl;
840
- }
841
- }
842
-
843
- // 引用文扱い
844
- if (isset($this->options['blockquote']) ? $this->options['blockquote'] : null == '1') {
845
- $tag = '<div class="'.$class_id.'"><blockquote class="lkc-quote">'.$tag.'</blockquote></div>';
846
- } else {
847
- $tag = '<div class="'.$class_id.'">'.$tag.'</div>';
848
- }
849
-
850
- return $tag;
851
- }
852
-
853
- // URLのエンティティ化など(無害化?)
854
- function pz_TrimURL($url = null) {
855
- if (!isset($url) || $url == '') {
856
- $url = null;
857
- return $url;
858
- }
859
-
860
- $url = html_entity_decode($url);
861
- if ($this->options['debug-time']) {
862
- echo '<!-- Pz-LkC [URL1='.$url.'] /-->'.PHP_EOL;
863
- }
864
- $url = preg_replace('/^[\s \'\"‘’“”″]*(.*?)[\s \'\"‘’“”″]*$/u', '\1', $url); // 色んな打ち間違え対応
865
- if ($this->options['debug-time']) {
866
- echo '<!-- Pz-LkC [URL2='.$url.'] /-->'.PHP_EOL;
867
- }
868
- $url = esc_url($url); // プロトコル除外など
869
- if ($this->options['debug-time']) {
870
- echo '<!-- Pz-LkC [URL3='.$url.'] /-->'.PHP_EOL;
871
- }
872
- switch (isset($this->options['trail-slash']) ? $this->options['trail-slash'] : null) {
873
- case '1': // URLがドメイン名だけの場合、最後のスラッシュを除外する
874
- $array_url = parse_url($url);
875
- if (!isset($array_url['path']) || $array_url['path'] == '/') {
876
- $url = rtrim($url, '/');
877
- }
878
- break;
879
- case '2': // 常に最後のスラッシュを除外する
880
- $url = rtrim($url, '/');
881
- break;
882
- }
883
- if ($this->options['debug-time']) {
884
- echo '<!-- Pz-LkC [URL4='.$url.'] /-->'.PHP_EOL;
885
- }
886
-
887
- return $url;
888
- }
889
-
890
- // 内部サイト・外部サイトの判断
891
- function pz_LinkType($url = null) {
892
- if (substr($url, 0, mb_strlen(home_url() ) ) == home_url() ) {
893
- if (get_permalink() == $url) {
894
- $link_type = 1; // 自ページ
895
- } else {
896
- $link_type = 2; // 自サイト内
897
- }
898
- } else {
899
- $link_type = 0; // 外部サイト
900
- }
901
- // サブディレクトリ型マルチサイト対応
902
- if ($this->options['flg-subdir'] && is_multisite() && !is_subdomain_install() && is_main_site) {
903
- $this_blog_id = get_current_blog_id();
904
- $blog_id = 0;
905
- do {
906
- $blog_id++;
907
- $blog_url = get_site_url($blog_id);
908
- if ($blog_url && $blog_id <> $this_blog_id && substr($url, 0, mb_strlen($blog_url) ) == $blog_url ) {
909
- // ドメイン名
910
- if (preg_match('/https?:\/\/(.*)\//i', $blog_url.'/',$m)) {
911
- $domain_url = $m[0];
912
- $domain = $m[1];
913
- } else {
914
- $domain_url = null;
915
- $domain = null;
916
- }
917
- $link_type = 0; // 外部サイト
918
- }
919
- } while ($blog_url);
920
- }
921
- if ($this->options['debug-time']) {
922
- echo '<!-- Pz-LkC [TYPE='.$link_type.'] /-->'.PHP_EOL;
923
- }
924
- return $link_type;
925
- }
926
-
927
- // 相対パスをURLにする
928
- public function pz_RelToURL( $base_url = '', $rel_path = '' ) {
929
- if (preg_match('/^https?\:\/\//', $rel_path ) ) { // 絶対パスだった場合
930
- return $rel_path;
931
- } elseif (substr($rel_path, 0, 2) == '//' ) { // 絶対パスだった場合(スキーム省略)
932
- return $rel_path;
933
- }
934
- $parse = parse_url($base_url );
935
- if (substr($rel_path, 0, 1) == '/' ) { // ドキュメントルート指定
936
- return $parse['scheme'].'://'.$parse ['host'].$rel_path;
937
- }
938
- return $parse['scheme'].'://'.$parse['host'].dirname($parse['path'] ).'/'.$rel_path;
939
- }
940
-
941
- // ソーシャルカウント取得
942
- public function pz_RenewSNSCount( $data ) {
943
- if (!isset($this->options['sns-position']) || $this->options['sns-position'] == '') {
944
- return null;
945
- }
946
- if (!isset($data) || !is_array($data)) {
947
- return null;
948
- }
949
-
950
- $data = $this->pz_GetCache($data);
951
- if (!isset($data) || !is_array($data)) {
952
- return null;
953
- }
954
-
955
- // ソーシャルカウント
956
- $sns_renew = false;
957
- $update_cnt = false;
958
-
959
- // タイムオーバー
960
- $opt = array( 'timeout' => 30 );
961
-
962
- // 保存期間満了でソーシャルカウントをリセット
963
- if ($this->now > $data['sns_nexttime'] && $data['result_code'] <= 200 ) {
964
- $sns_renew = true;
965
- }
966
-
967
- // Twitter count.json 2015/11/21 非公式サービス終了に伴い停止→代替APIへ変更
968
- if (isset($this->options['sns-tw']) && !is_null($this->options['sns-tw'])) {
969
- $count_before = isset($data['sns_twitter']) ? $data['sns_twitter'] : -1;
970
- if ($sns_renew || $count_before < 0) {
971
- // $result = wp_remote_get( 'http://urls.api.twitter.com/1/urls/count.json?url=' .rawurlencode($data['url']), $opt );
972
- $result = wp_remote_get( 'https://jsoon.digitiminimi.com/twitter/count.json?url=' .rawurlencode($data['url']), $opt );
973
- if (isset($result) && !is_wp_error($result) && $result['response']['code'] == 200) {
974
- $count = intval(json_decode($result['body'])->count);
975
- if ($count > $count_before) {
976
- $data['sns_twitter'] = $count;
977
- $update_cnt = true;
978
- }
979
- }
980
- }
981
- }
982
-
983
- if (isset($this->options['sns-fb']) && !is_null($this->options['sns-fb'])) {
984
- $count_before = intval(isset($data['sns_facebook']) ? $data['sns_facebook'] : -1);
985
- if ($sns_renew || $count_before < 0) {
986
- $result = wp_remote_get( 'https://graph.facebook.com/?id=' .rawurlencode($data['url']), $opt );
987
- if (isset($result) && !is_wp_error($result) && $result['response']['code'] == 200) {
988
- $json = json_decode($result['body']);
989
- $count = intval(isset($json->share->share_count) ? $json->share->share_count : 0);
990
- if ($count > $count_before) {
991
- $data['sns_facebook'] = $count;
992
- $update_cnt = true;
993
- }
994
- }
995
- }
996
- }
997
-
998
- if (isset($this->options['sns-hb']) && !is_null($this->options['sns-hb'])) {
999
- $count_before = isset($data['sns_hatena']) ? $data['sns_hatena'] : -1;
1000
- if ($sns_renew || $count_before < 0) {
1001
- $result = wp_remote_get( 'http://api.b.st-hatena.com/entry.count?url=' .rawurlencode($data['url']), $opt );
1002
- if (isset($result) && !is_wp_error($result) && $result['response']['code'] == 200) {
1003
- $count = intval($result['body']);
1004
- if ($count > $count_before) {
1005
- $data['sns_hatena'] = $count;
1006
- $update_cnt = true;
1007
- }
1008
- }
1009
- }
1010
- }
1011
-
1012
- if (isset($this->options['sns-po']) && !is_null($this->options['sns-po'])) {
1013
- $count_before = isset($data['sns_pocket']) ? $data['sns_pocket'] : -1;
1014
- if ($sns_renew || $count_before < 0) {
1015
- $result = wp_remote_get( 'https://widgets.getpocket.com/v1/button?label=pocket&count=vertical&align=left&v=1&src=https&url=' .rawurlencode($data['url']), $opt );
1016
- if (isset($result) && !is_wp_error($result) && $result['response']['code'] == 200) {
1017
- preg_match('/<em id="cnt">([0-9]*)<\/em>/', $result['body'], $m);
1018
- $count = intval($m[1] ? $m[1] : 0);
1019
- if ($count > $count_before) {
1020
- $data['sns_pocket'] = $count;
1021
- $update_cnt = true;
1022
- }
1023
- }
1024
- }
1025
- }
1026
-
1027
- // 登録してから一週間までは毎日、それ以降は週一回更新(取得が固まらないようにランダム時間付与)
1028
- if ($update_cnt || ($this->now - strtotime($data['regist']) < WEEK_IN_SECONDS)) {
1029
- $sns_nexttime = $this->now + DAY_IN_SECONDS + rand(0, DAY_IN_SECONDS); // 1day + 0-24h
1030
- } else {
1031
- $sns_nexttime = $this->now + WEEK_IN_SECONDS + rand(0, DAY_IN_SECONDS); // 7days + 0-24h
1032
- }
1033
- // MINUTE_IN_SECONDS = 60
1034
- // HOUR_IN_SECONDS = 60 * MINUTE_IN_SECONDS = 3600
1035
- // DAY_IN_SECONDS = 24 * HOUR_IN_SECONDS = 86400
1036
- // WEEK_IN_SECONDS = 7 * DAY_IN_SECONDS = 604800
1037
- // YEAR_IN_SECONDS = 365 * DAY_IN_SECONDS
1038
-
1039
- global $wpdb;
1040
- $wpdb->update(
1041
- $this->db_name,
1042
- array(
1043
- 'sns_twitter' => $data['sns_twitter'],
1044
- 'sns_facebook' => $data['sns_facebook'],
1045
- 'sns_hatena' => $data['sns_hatena'],
1046
- 'sns_pocket' => $data['sns_pocket'],
1047
- 'sns_time' => $this->now,
1048
- 'sns_nexttime' => $sns_nexttime,
1049
- 'uptime' => $this->now
1050
- ),
1051
- array(
1052
- 'id' => $data['id']
1053
- )
1054
- );
1055
- return $data;
1056
- }
1057
-
1058
- // キャッシュデータを取得
1059
- public function pz_GetCache( $data ) {
1060
- if (!isset($data) || !is_array($data)) {
1061
- return null;
1062
- }
1063
- global $wpdb;
1064
- if (!empty($data['url'])) {
1065
- $url = $data['url'];
1066
- $data = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->db_name WHERE url=%s", $url));
1067
- } elseif (isset($data['id']) && !is_null($data['id'])) {
1068
- $data_id = intval($data['id']);
1069
- $data = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->db_name WHERE id=%d", $data_id));
1070
- } else {
1071
- return null;
1072
- }
1073
- if ($wpdb->last_error <> '') { // DBエラーのとき、初期化する
1074
- $this->activate();
1075
- }
1076
- if (is_wp_error($data)) {
1077
- return null;
1078
- }
1079
- return (array) $data; // Arrayに直して返す
1080
- }
1081
-
1082
- // キャッシュデータを保存
1083
- public function pz_SetCache($data) {
1084
- global $wpdb;
1085
- if (!isset($data) || !is_array($data)) {
1086
- return null;
1087
- }
1088
- if (!isset($data['url']) || is_null($data['url']) || $data['result_code'] < 100) {
1089
- return null;
1090
- }
1091
- $url = $this->pz_TrimURL($data['url']);
1092
- $data['url'] = $url;
1093
- if (!isset($data['url_key']) || is_null($data['url_key']) || $data['url_key'] == '' ) {
1094
- $data['url_key'] = hash( 'sha256', esc_url( $url ), true);
1095
- }
1096
-
1097
- if (!isset($data['regist_result']) || !$data['regist_result']) { // 最初登録時情報
1098
- $data['regist_title'] = $data['title'];
1099
- $data['regist_excerpt'] = $data['excerpt'];
1100
- $data['regist_charset'] = $data['charset'];
1101
- $data['regist_result'] = $data['result_code'];
1102
- $data['regist_time'] = $this->now;
1103
- }
1104
- $data['uptime'] = $this->now; // 最終更新日時
1105
-
1106
- // 更新してみる
1107
- if ( isset($data['id']) ) {
1108
- $result = $wpdb->update(
1109
- $this->db_name,
1110
- $data,
1111
- array(
1112
- 'id' => $data['id']
1113
- )
1114
- );
1115
- } else {
1116
- $result = $wpdb->update(
1117
- $this->db_name,
1118
- $data,
1119
- array(
1120
- 'url_key' => $data['url_key']
1121
- )
1122
- );
1123
- }
1124
- if (!$result) {
1125
- $data['regist'] = $this->now_mysql; // 登録日
1126
- // 更新できなかったら挿入
1127
- unset($data['id']);
1128
- $result = $wpdb->insert(
1129
- $this->db_name,
1130
- $data
1131
- );
1132
- if (!$result) {
1133
- // 挿入できなかったら日本語項目を落としてなるべく登録する
1134
- unset($data['site_name']);
1135
- $result = $wpdb->insert(
1136
- $this->db_name,
1137
- $data
1138
- );
1139
- if (!$result) {
1140
- unset($data['excerpt']);
1141
- $result = $wpdb->insert(
1142
- $this->db_name,
1143
- $data
1144
- );
1145
- if (!$result) {
1146
- unset($data['title']);
1147
- $result = $wpdb->insert(
1148
- $this->db_name,
1149
- $data
1150
- );
1151
- if (!$result) {
1152
- return $data;
1153
- }
1154
- }
1155
- }
1156
- }
1157
- }
1158
- return $this->pz_GetCache($data);
1159
- }
1160
-
1161
- // キャッシュデータを削除
1162
- public function pz_DelCache($data) {
1163
- global $wpdb;
1164
- if (!isset($data) || !is_array($data)) {
1165
- return null;
1166
- }
1167
- if (isset($data['id']) && !is_null($data['id'])) {
1168
- $data_id = intval($data['id']);
1169
- $result = $wpdb->delete($this->db_name, array('id' => $data_id), array('%d') );
1170
- return $result;
1171
- } elseif (isset($data['url']) && !is_null($data['url'])) {
1172
- $url = $this->pz_TrimURL($data['url']);
1173
- $result = $wpdb->delete($this->db_name, array('url' => $url), array('%s') );
1174
- return $result;
1175
- }
1176
- return null;
1177
- }
1178
-
1179
- // サイト内取得
1180
- public function pz_GetPost( $data ) {
1181
- // サイト名取得
1182
- $site_name = get_bloginfo('name');
1183
-
1184
- // ドメイン名
1185
- if (preg_match('/https?:\/\/(.*)\//i', home_url().'/',$m)) {
1186
- $domain_url = $m[0];
1187
- $domain = $m[1];
1188
- } else {
1189
- $domain_url = null;
1190
- $domain = null;
1191
- }
1192
-
1193
- // サイトアイコン
1194
- if (function_exists('has_site_icon') && has_site_icon()) {
1195
- $favicon = get_site_icon_url(16, '', 0);
1196
- } else {
1197
- $favicon = null;
1198
- }
1199
-
1200
- $title = null;
1201
- $excerpt = null;
1202
- $thumbnail = null;
1203
-
1204
- // 記事内容
1205
- $url = $data['url'];
1206
- $post_id = url_to_postid($url ); // 記事IDを取得
1207
- if ($this->options['debug-time']) {
1208
- echo '<!-- Pz-LkC [PID='.$post_id.'] /-->'.PHP_EOL;
1209
- }
1210
-
1211
- if ( !$post_id && isset($this->options['flg-get-pid']) ? true : false) {
1212
- $url = $this->Pz_GetRedirURL( $data ); // 本当の記事URLを取得
1213
- $post_id = url_to_postid($url ); // 記事IDを取得
1214
- if ($this->options['debug-time']) {
1215
- echo '<!-- Pz-LkC [PID='.$post_id.'(REDIR)] /-->'.PHP_EOL;
1216
- }
1217
- }
1218
-
1219
- if ( $post_id ) {
1220
- $result_code = 200; // 外部取得と同じコードをセット
1221
- $post = get_post($post_id); // 記事情報
1222
- if ( $this->options['in-get'] == '1') {
1223
- $title = $post->post_title; // 記事タイトル
1224
- $excerpt = $post->post_excerpt; // 抜粋文優先
1225
- if ($excerpt == '') {
1226
- $excerpt = $post->post_content; // 抜粋文が無かったら記事
1227
- }
1228
- } else {
1229
- $title = $post->post_title; // 記事タイトル
1230
- $excerpt = $post->post_content; // 記事内容から抜粋
1231
- }
1232
- $post_date = $post->post_date;
1233
- $thumbnail_id = get_post_thumbnail_id( $post_id ); // サムネイル
1234
- if ($this->options['debug-time']) {
1235
- echo '<!-- Pz-LkC [TID='.$thumbnail_id.'] /-->'.PHP_EOL;
1236
- }
1237
- $attach = wp_get_attachment_image_src( $thumbnail_id, 'thumbnail', true );
1238
- if (isset($attach) && count($attach) > 3 && isset($attach[0])) {
1239
- $thumbnail = $attach[0];
1240
- if (preg_match('/.*(\/\/.*)/', $thumbnail, $m)) { // スキームを外す
1241
- $thumbnail = $m[1];
1242
- }
1243
- }
1244
- } else {
1245
- $title = get_bloginfo('name');
1246
- $excerpt = get_bloginfo('description');
1247
- $site_name = get_bloginfo('name');
1248
- $thumbnail = '';
1249
- $result_code = '404';
1250
-
1251
- // カテゴリ ページの処理
1252
- $cat_dir = get_option('category_base');
1253
- $cat_url = home_url().'/'.($cat_dir ? $cat_dir : 'category').'/';
1254
- $cat_len = mb_strlen($cat_url );
1255
- if (substr($url, 0, $cat_len ) == $cat_url ) {
1256
- $cat_slug = substr($url, $cat_len );
1257
- $cat_data = get_category_by_slug($cat_slug );
1258
- $cat_count = ($cat_data->count - 0);
1259
- $title = __('Category', $this->text_domain ).' '.__('‘', $this->text_domain ).$cat_data->name.__('’', $this->text_domain );
1260
- $excerpt = __('(', $this->text_domain ).__('Count', $this->text_domain ).':'.($cat_data->count - 0).__(')', $this->text_domain ).' '.$cat_data->description;
1261
- if (isset($cat_data->slug)) {
1262
- $result_code = '200';
1263
- }
1264
- } else {
1265
- // タグ ページの処理
1266
- $cat_dir = get_option('tag_base');
1267
- $cat_url = home_url().'/'.($cat_dir ? $cat_dir : 'tag').'/';
1268
- $cat_len = mb_strlen($cat_url );
1269
- if (substr($url, 0, $cat_len ) == $cat_url ) {
1270
- $cat_slug = substr($url, $cat_len );
1271
- $cat_data = get_tags( array( 'slug' => $cat_slug ) );
1272
- $title = __('Tag', $this->text_domain ).' '.__('‘', $this->text_domain ).$cat_data[0]->name.__('’', $this->text_domain );
1273
- $excerpt = __('(', $this->text_domain ).__('Count', $this->text_domain ).':'.($cat_data[0]->count - 0).__(')', $this->text_domain ).' '.$cat_data[0]->description;
1274
- if (isset($cat_data[0]->slug)) {
1275
- $result_code = '200';
1276
- }
1277
- } else {
1278
- if ( !$post_id && isset($this->options['flg-get-pid']) ? true : false) {
1279
- $data = $this->Pz_GetCURL($data ); // 外部サイトとして読み込み
1280
- return $data;
1281
- }
1282
- }
1283
- }
1284
- }
1285
-
1286
- // タイトル整形
1287
- if (isset($title)) {
1288
- $str = $title;
1289
- $str = strip_tags($str); // タグの除去
1290
- $str = str_replace(array("\r", "\n"), '', $str); // 改行削除
1291
- $str = esc_html($str); // 念のためエスケープ
1292
- $str = mb_strimwidth($str, 0, 200, '...'); // 保管用のタイトルは200文字で切る
1293
- $title = $str;
1294
- }
1295
-
1296
- // 抜粋文整形
1297
- if (isset($excerpt)) {
1298
- $str = $excerpt;
1299
- $str = strip_tags($str); // タグの除去
1300
- $str = preg_replace('/<!--more-->.+/is', '', $str); // moreタグ以降削除
1301
- $str = preg_replace('/\[[^]]*\]/', '', $str); // ショートコードすべて除去
1302
- $str = str_replace(array("\r", "\n"), '', $str); // 改行削除
1303
- $str = esc_html($str); // 念のためエスケープ
1304
- $str = mb_strimwidth($str, 0, 500, '...'); // 保管用の記事内容は500文字で切る
1305
- $excerpt = $str;
1306
- }
1307
-
1308
- // URLパース(ドメイン名などを抽出)
1309
- $url_m = parse_url( $url );
1310
- $scheme = $url_m['scheme']; // スキーム
1311
- //$domain = $url_m['host']; // ドメイン名
1312
- //$domain_url = $scheme.'://'.$url_m['host']; // ドメインURL
1313
- $location = substr($url, mb_strlen($domain_url)); // ドメイン名以降
1314
-
1315
- // データセット
1316
- if (isset($data['title']) && $data['title'] == $title ) {
1317
- $before['mod_title'] = 0;
1318
- } else {
1319
- $before['mod_title'] = 1;
1320
- }
1321
- if (isset($data['excerpt']) && $data['excerpt'] == $excerpt ) {
1322
- $before['mod_excerpt'] = 0;
1323
- } else {
1324
- $before['mod_excerpt'] = 1;
1325
- }
1326
- if (!isset($data['use_post_id1'])) {
1327
- $data['use_post_id1'] = get_the_ID();
1328
- }
1329
- $data['scheme'] = $scheme;
1330
- $data['domain'] = $domain;
1331
- $data['location'] = $location;
1332
- $data['site_name'] = $site_name;
1333
- $data['title'] = $title;
1334
- $data['excerpt'] = $excerpt;
1335
- $data['post_date'] = $post_date;
1336
- $data['thumbnail'] = $thumbnail;
1337
- $data['favicon'] = $favicon;
1338
- $data['charset'] = 'UTF-8';
1339
- $data['result_code'] = $result_code;
1340
- $data['alive_result'] = $result_code;
1341
- $data['favicon'] = $favicon;
1342
-
1343
- return $data;
1344
- }
1345
-
1346
- // リダイレクト先URL取得
1347
- public function pz_GetRedirURL( $data ) {
1348
- $url = $data['url'];
1349
- if ( function_exists( 'curl_init' ) ) { // cURLを使用する
1350
- $result_code = 0;
1351
- $ch = curl_init($url);
1352
- curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); // データで取得
1353
- curl_setopt( $ch, CURLOPT_NOBODY, true ); // ヘッダのみ取得
1354
- curl_setopt( $ch, CURLOPT_TIMEOUT, 120 ); // タイムアウト
1355
- curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true ); // リダイレクトを処理する
1356
- curl_setopt( $ch, CURLOPT_MAXREDIRS, 5 ); // リダイレクトを処理する階層
1357
- $html = curl_exec($ch);
1358
- $errno = intval( curl_errno( $ch ) ); // cURL実行
1359
- if ( $errno ) {
1360
- $result_code = $errno;
1361
- $error = true;
1362
- } else {
1363
- $header = curl_getinfo($ch);
1364
- $result_code = $header['http_code']; // HTTPステータス
1365
- $error = false;
1366
- $url = $header['url'];
1367
- }
1368
- curl_close($ch);
1369
- }
1370
- return $url;
1371
- }
1372
-
1373
- // 外部サイト取得
1374
- public function pz_GetCURL( $data ) {
1375
- $url = $this->pz_TrimURL( $data['url'] );
1376
- if (!isset( $url ) || $url == '') {
1377
- return null;
1378
- }
1379
-
1380
- // リンク先サイト取得
1381
- $html = null;
1382
- $error = true;
1383
-
1384
- $domain = null;
1385
- $site_name = null;
1386
- $title = null;
1387
- $excerpt = null;
1388
- $charset = null;
1389
- $result_code = null;
1390
-
1391
- // URLパース(ドメイン名などを抽出)
1392
- $url_m = parse_url( $url );
1393
- $scheme = $url_m['scheme']; // スキーム
1394
- $domain = $url_m['host']; // ドメイン名
1395
- $domain_url = $scheme.'://'.$url_m['host']; // ドメインURL
1396
- $location = substr($url, mb_strlen($domain_url)); // ドメイン名以降
1397
-
1398
- if ( function_exists( 'curl_init' ) ) { // cURLを使用する
1399
- $result_code = 0;
1400
- $ch = curl_init($url);
1401
- curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); // データで取得
1402
- curl_setopt( $ch, CURLOPT_TIMEOUT, 8 ); // タイムアウト
1403
- if (isset($this->options['flg-referer']) ? true : false) {
1404
- curl_setopt( $ch, CURLOPT_REFERER, get_permalink() ); // リファラ
1405
- }
1406
- if (isset($this->options['flg-agent']) ? true : false) {
1407
- curl_setopt( $ch, CURLOPT_USERAGENT, $this->options['user-agent'] ); // ユーザーエージェントにPz-LinkCard-Crawlerを使う
1408
- } else {
1409
- curl_setopt( $ch, CURLOPT_USERAGENT, esc_html( $_SERVER['HTTP_USER_AGENT'] ) ); // アクセス者のユーザーエージェントを使う
1410
- }
1411
- if (isset($this->options['flg-redir']) ? true : false) {
1412
- curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true ); // リダイレクトを処理する
1413
- curl_setopt( $ch, CURLOPT_MAXREDIRS, 8 ); // リダイレクトを処理する階層
1414
- curl_setopt( $ch, CURLOPT_AUTOREFERER, true ); // リダイレクト用リファラを自動セット
1415
- } else {
1416
- curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, false ); // リダイレクトを処理しない
1417
- }
1418
- curl_setopt( $ch, CURLOPT_COOKIESESSION, true ); // セッションCOOKIEを使用する
1419
- curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, (isset($this->options['flg-ssl']) ? false : true) ); // SSL検証
1420
- $html = curl_exec($ch);
1421
- $errno = intval( curl_errno( $ch ) ); // cURL実行
1422
- if ( $errno ) {
1423
- $html = ''; // cURLエラー
1424
- $result_code = $errno;
1425
- $error = true;
1426
- } else {
1427
- $header = curl_getinfo($ch);
1428
- $result_code = $header['http_code']; // HTTPステータス
1429
- $error = false;
1430
- }
1431
- curl_close($ch);
1432
- } else { // cURLが使用できない場合
1433
- $result = wp_remote_get( $url ); //wp_remote_get実行
1434
- if ( is_wp_error( $result ) ) {
1435
- $html = '';
1436
- $result_code = -1; // wp_remote_getエラー
1437
- $error = true;
1438
- } else {
1439
- $html = $result['body'];
1440
- $result_code = $result['response']['code']; // HTTPステータス
1441
- $error = false;
1442
- }
1443
- }
1444
-
1445
- // 文字コード判定
1446
- $charset = null;
1447
- if ($html <> '') {
1448
- if (preg_match('/charset\s*=\s*"*([^>\/\s"]*).*<\/head/si', $html, $m)) {
1449
- $m[1] = trim(trim($m[1]), '\'\"');
1450
- $charset = $m[1];
1451
- } else {
1452
- foreach(array('UTF-8','SJIS','EUC-JP','eucJP-win','ASCII','JIS','SJIS-win') as $c_charset) {
1453
- // 文字コード変換してみて内容が変わらないものを文字セットと判断する
1454
- if (mb_convert_encoding($html, $this->charset, $c_charset) == $html) {
1455
- $charset = $c_charset;
1456
- break;
1457
- }
1458
- }
1459
- }
1460
- if (is_null($charset)) {
1461
- $charset = mb_detect_encoding($html, 'ASCII,JIS,UTF-7,EUC-JP,SJIS,UTF-8');
1462
- $html = mb_convert_encoding($html, $this->charset, 'ASCII,JIS,UTF-7,EUC-JP,SJIS,UTF-8');
1463
- } elseif ($this->charset <> $charset) {
1464
- $html = mb_convert_encoding($html, $this->charset, $charset);
1465
- }
1466
-
1467
- // HEADタグ(METAタグ解析)
1468
- $head = null;
1469
- $tags = null;
1470
- if (preg_match('/<\s*head[^>]*>(.*)<\s*\/head\s*>/si', $html, $m)) {
1471
- $head = $m[1];
1472
- $tags = $this->pz_GetMeta($head);
1473
- }
1474
-
1475
- // タイトル
1476
- if (isset( $tags['og:title'] ) && $tags['og:title'] ) {
1477
- $title = $tags['og:title'] ;
1478
- } elseif (isset( $tags['twitter:title'] ) && $tags['twitter:title'] ) {
1479
- $title = $tags['twitter:title'] ;
1480
- } elseif (isset( $tags['title'] ) && $tags['title'] ) {
1481
- $title = $tags['title'] ;
1482
- }
1483
-
1484
- // 抜粋文・概要文
1485
- if (isset( $tags['og:description'] ) && $tags['og:description'] ) {
1486
- $excerpt = $tags['og:description'] ;
1487
- } elseif (isset( $tags['twitter:description'] ) && $tags['twitter:description'] ) {
1488
- $excerpt = $tags['twitter:description'] ;
1489
- } elseif (isset( $tags['description'] ) && $tags['description'] ) {
1490
- $excerpt = $tags['description'] ;
1491
- }
1492
-
1493
- // OGPから画像URL取得
1494
- if (isset( $tags['og:image'] ) && $tags['og:image'] ) {
1495
- $thumbnail_url = $tags['og:image'] ;
1496
- } elseif (isset( $tags['twitter:image'] ) && $tags['twitter:image'] ) {
1497
- $thumbnail_url = $tags['twitter:image'] ;
1498
- } else {
1499
- $thumbnail_url = '';
1500
- }
1501
- if ($thumbnail_url && !preg_match('/^https*:\/\//', $thumbnail_url, $m) ) {
1502
- $thumbnail_url = $this->pz_RelToURL($url, $thumbnail_url);
1503
- }
1504
-
1505
- // OGPからサイトアイコンURL取得
1506
- if (isset( $tags['icon'] ) && $tags['icon'] ) {
1507
- $favicon_url = $tags['icon'] ;
1508
- } elseif (isset( $tags['shortcut icon'] ) && $tags['shortcut icon'] ) {
1509
- $favicon_url = $tags['shortcut icon'] ;
1510
- } elseif (isset( $tags['apple-touch-icon'] ) && $tags['apple-touch-icon']) {
1511
- $favicon_url = $tags['apple-touch-icon'] ;
1512
- } else {
1513
- $favicon_url = '';
1514
- }
1515
- if ($favicon_url && !preg_match('/^https*:\/\//', $favicon_url, $m) ) {
1516
- $favicon_url = $this->pz_RelToURL($url, $favicon_url);
1517
- }
1518
-
1519
- // サイト名
1520
- if (isset( $tags['og:site_name'] ) && $tags['og:site_name'] ) {
1521
- $site_name = $tags['og:site_name'] ;
1522
- }
1523
-
1524
- // タイトル整形
1525
- if (isset($title)) {
1526
- $str = $title;
1527
- $str = strip_tags($str); // タグの除去
1528
- $str = str_replace(array("\r", "\n"), '', $str); // 改行削除
1529
- $str = esc_html($str); // 念のためエスケープ
1530
- $str = mb_strimwidth($str, 0, 200, '...'); // 保管用のタイトルは200文字で切る
1531
- $title = $str;
1532
- }
1533
-
1534
- // 抜粋文整形
1535
- if (isset($excerpt)) {
1536
- $str = $excerpt;
1537
- $str = strip_tags($str); // タグの除去
1538
- $str = str_replace(array("\r", "\n"), '', $str); // 改行削除
1539
- $str = esc_html($str); // 念のためエスケープ
1540
- $str = mb_strimwidth($str, 0, 500, '...'); // 保管用の記事内容は500文字で切る
1541
- $excerpt = $str;
1542
- }
1543
-
1544
- // データセット
1545
- if (isset($data_id) && !is_null($data_id)) {
1546
- $data['id'] = $data_id;
1547
- }
1548
- if (isset($url_key) && !is_null($url_key)) {
1549
- $data['url_key'] = $url_key;
1550
- }
1551
- $data['site_name'] = $site_name;
1552
- $data['title'] = $title;
1553
- $data['excerpt'] = $excerpt;
1554
- $data['mod_title'] = 0;
1555
- $data['mod_excerpt'] = 0;
1556
- $data['charset'] = $charset;
1557
- // if (isset($atts['force']) && $atts['force'] == true) {
1558
- // $data['regist'] = $this->now_mysql; // 登録日
1559
- // }
1560
- }
1561
- $data['url'] = $url;
1562
- $data['thumbnail'] = ( isset($thumbnail_url) ? $thumbnail_url : null );
1563
- $data['result_code'] = $result_code;
1564
- $data['alive_result'] = $result_code;
1565
- $data['scheme'] = $scheme;
1566
- $data['domain'] = $domain;
1567
- $data['location'] = $location;
1568
- $data['favicon'] = ( isset($favicon_url) ? $favicon_url : null );
1569
- if (!isset($data['use_post_id1']) || !$data['use_post_id1']) {
1570
- $data['use_post_id1'] = get_the_ID();
1571
- }
1572
- $data['sns_twitter'] = (isset( $data['sns_twitter'] ) ? $data['sns_twitter'] : -1 );
1573
- $data['sns_facebook'] = (isset( $data['sns_facebook'] ) ? $data['sns_facebook'] : -1 );
1574
- $data['sns_hatena'] = (isset( $data['sns_hatena'] ) ? $data['sns_hatena'] : -1 );
1575
- $data['sns_nexttime'] = (isset( $data['sns_nexttime'] ) ? $data['sns_nexttime'] : 0 );
1576
- $data['uptime'] = $this->now;
1577
- $data['alive_time'] = $this->now;
1578
- $data['alive_result'] = $result_code;
1579
- return $data;
1580
- }
1581
-
1582
- // TITLEとMETAタグを分解
1583
- function pz_GetMeta( $html, $tags = null, $clear = false ) {
1584
- if ($clear == true || !isset($tags)) {
1585
- $tags = null;
1586
- $tags = array('none' => 'none');
1587
- }
1588
-
1589
- // TITLEタグ
1590
- if (preg_match('/<\s*title\s*[^>]*>\s*([^<]*)\s*<\s*\/title\s*[^>]*>/si', $html, $m)) {
1591
- $tags['title'] = esc_html($m[1]);
1592
- }
1593
-
1594
- // metaタグ パース
1595
- $match = null;
1596
- preg_match_all('/<\s*meta\s(?=[^>]*?\b(?:name|property)\s*=\s*(?|"\s*([^"]*?)\s*"|\'\s*([^\']*?)\s*\'|([^"\'>]*?)(?=\s*\/?\s*>|\s\w+\s*=)))[^>]*?\bcontent\s*=\s*(?|"\s*([^"]*?)\s*"|\'\s*([^\']*?)\s*\'|([^"\'>]*?)(?=\s*\/?\s*>|\s\w+\s*=))[^>]*>/is', $html, $match);
1597
- if (isset($match) && is_array($match) && count($match) == 3 && count($match[1]) > 0) {
1598
- foreach ($match[1] as &$m) {
1599
- $m = strtolower($m);
1600
- }
1601
- unset($m);
1602
- $tags += array_combine($match[1], $match[2]);
1603
- }
1604
-
1605
- // linkタグ パース
1606
- $match = null;
1607
- preg_match_all('/<\s*link\s(?=[^>]*?\brel\s*=\s*(?|"\s*([^"]*?)\s*"|\'\s*([^\']*?)\s*\'|([^"\'>]*?)(?=\s*\/?\s*>|\s\w+\s*=)))[^>]*?\bhref\s*=\s*(?|"\s*([^"]*?)\s*"|\'\s*([^\']*?)\s*\'|([^"\'>]*?)(?=\s*\/?\s*>|\s\w+\s*=))[^>]*>/is', $html, $match);
1608
- if (isset($match) && is_array($match) && count($match) == 3 && count($match[1]) > 0) {
1609
- foreach ($match[1] as &$m) {
1610
- $m = strtolower($m);
1611
- }
1612
- unset($m);
1613
- $tags += array_combine($match[1], $match[2]);
1614
- }
1615
-
1616
- return $tags;
1617
- }
1618
-
1619
- // サムネイル取得(外部リンクOGP画像取得)
1620
- public function pz_GetThumbnail( $url, $force = false ) {
1621
- if (!isset($url) || $url == '' || $url == 'https://s0.wp.com/i/blank.jpg') {
1622
- return null;
1623
- }
1624
-
1625
- $file_dir = $this->options['thumbnail-dir']; // サムネイルのディレクトリ
1626
- if (!is_dir($file_dir)) {
1627
- return null;
1628
- }
1629
-
1630
- $file_name = bin2hex(hash('sha256', esc_url( $url ), true)); // URLをハッシュしてファイル名を生成する
1631
- $file_path = $file_dir.$file_name; // ファイルのフルパス
1632
- $file_url = $this->options['thumbnail-url'].$file_name; // 画像URL
1633
-
1634
- if (!$force && file_exists($file_path )) { // 既にあれば画像URLを返す
1635
- return $file_url;
1636
- }
1637
-
1638
- list($width, $height) = @getimagesize($url); // サイズを取得
1639
- if (!isset($width) || !isset($height) || $width < 8 || $height < 8) { // 8x8未満は画像ではないと見なす
1640
- return null;
1641
- }
1642
- $image = imagecreatefromstring( file_get_contents($url) ); // 画像読み込み
1643
-
1644
- $new_width = 200; // 幅200px
1645
- $new_height = 200; // 高さ200px
1646
- if ($width <> $height) { // 正方形でない
1647
- if ($width > $height) { // 幅の方が大きい
1648
- $new_height = $height * ( $new_width / $width ); // 幅に合わせる
1649
- } else { // 高さの方が大きい
1650
- $new_width = $width * ( $new_height / $height ); // 高さに合わせる
1651
- }
1652
- }
1653
- $image_p = imagecreatetruecolor($new_width, $new_height); // パレットを用意
1654
- imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); // サイズ変更してコピー
1655
- imagejpeg($image_p, $file_path); // JPEGで保存
1656
- return $file_url; // 画像URLを返す
1657
- }
1658
-
1659
- // 管理画面時のスタイルシート、スクリプト設定
1660
- public function enqueue_admin($hook) {
1661
- wp_enqueue_script ('pz-lkc-admin', plugins_url('js/admin.js', __FILE__), array('jquery'), false, true);
1662
- wp_enqueue_style ('wp-color-picker');
1663
- wp_enqueue_script ('colorpicker-script', plugins_url('js/color-picker.js', __FILE__), array('wp-color-picker'), false, true);
1664
- // wp_enqueue_media();
1665
- // wp_enqueue_script ('media-uploader', plugins_url("media-uploader.js", __FILE__), array('jquery'), false, false);
1666
- wp_enqueue_style('pz-lkc-admin', plugin_dir_url (__FILE__).'css/admin.css');
1667
- }
1668
-
1669
- // 管理画面時のスタイルシート、スクリプト設定
1670
- public function add_footer() {
1671
- if ($this->options['flg-edit-qtag']) {
1672
- if (wp_script_is('quicktags') ) {
1673
- echo '<script>QTags.addButton(\'pz-lkc\',\''.__('Linkcard', $this->text_domain ).'\',\'['.$this->options['code1'].' url="\',\'"]\',\'\',\''.__('Make Linkcard', $this->text_domain ).'\');</script>';
1674
- }
1675
- }
1676
- require_once ('lib/pz-linkcard-modal.php');
1677
- }
1678
-
1679
- // 管理画面時の注意書き設定
1680
- public function add_notices() {
1681
- if ($this->options['flg-invalid']) {
1682
- echo '<div class="error fade is-dismissible"><p><strong>'.$this->slug.': '.__('Invalid URL parameter in ', $this->text_domain).'<a href="'.$this->options['invalid-url'].'" target="_blank">'.$this->options['invalid-url'].'</a></strong><br>'.__('*', $this->text_domain).' '.__('You can cancel this message from <a href="./options-general.php?page=pz-linkcard-settings">the setting screen</a>.', $this->text_domain).'</p></div>';
1683
- }
1684
- }
1685
-
1686
- // 管理画面時のスタイルシート、スクリプト設定
1687
- public function add_mce_button($buttons) {
1688
- if ($this->options['flg-edit-insert']) {
1689
- $buttons[] = 'pz_linkcard';
1690
- }
1691
- return $buttons;
1692
- }
1693
- public function add_mce_plugin($plugins) {
1694
- if ($this->options['flg-edit-insert']) {
1695
- $plugins['pz_linkcard'] = $this->plugin_dir_url.'js/mce.js';
1696
- }
1697
- return $plugins;
1698
- }
1699
-
1700
- // 通常時のスタイルシート
1701
- public function enqueue($hook) {
1702
- $this->amp = null;
1703
-
1704
- $css_path = $this->upload_dir_path.'style.css';
1705
- $css_url = $this->upload_dir_url .'style.css';
1706
- if (!file_exists($css_path )) {
1707
- $css_url = $this->plugin_dir_url .'style.css';
1708
- }
1709
- if (preg_match('/.*(\/\/.*)/', $css_url, $m)) { // スキームを外す
1710
- $css_url = $m[1];
1711
- }
1712
- wp_enqueue_style ('pz-linkcard', $css_url);
1713
- //if (!isset($this->options['style'])) {
1714
- // wp_enqueue_style ('pz-linkcard', $this->options['css-url']);
1715
- //} else {
1716
- // if (isset($this->options['css-file'])) {
1717
- // wp_enqueue_style('pz-linkcard', $this->options['css-file']);
1718
- // }
1719
- //}
1720
- }
1721
-
1722
- // 管理画面のサブメニュー追加
1723
- public function add_menu() {
1724
- $menu_manager = __('Pz LkC Cache', $this->text_domain);
1725
- $menu_settings = __('Pz LinkCard', $this->text_domain);
1726
- if ($this->options['flg-alive'] && $this->options['flg-alive-count']) {
1727
- global $wpdb;
1728
- $result = $wpdb->get_row("SELECT COUNT(*) AS count FROM $this->db_name WHERE alive_result = '404'");
1729
- if (isset($result) && isset($result->count)) {
1730
- $menu_manager .= '&nbsp;<span class="update-plugins"><span class="update-count lkc-menu-count">'.$result->count.'</span></span>';
1731
- }
1732
- }
1733
- add_management_page (__('LinkCard cache manager', $this->text_domain), $menu_manager, 'manage_options', 'pz-linkcard-cache', array($this, 'page_cacheman') );
1734
- add_options_page (__('LinkCard Settings', $this->text_domain), $menu_settings, 'manage_options', 'pz-linkcard-settings', array($this, 'page_settings') );
1735
- }
1736
-
1737
- // WP-CRONスケジュール(SNSカウント取得)
1738
- public function schedule_hook_check() {
1739
- if (!isset($this->options['sns-position']) || $this->options['sns-position'] == '') {
1740
- return null;
1741
- }
1742
-
1743
- global $wpdb;
1744
- $result = (array) $wpdb->get_results($wpdb->prepare("SELECT url,sns_nexttime FROM $this->db_name WHERE sns_nexttime<%d ORDER BY sns_nexttime ASC", $this->now));
1745
- $i = 0;
1746
- if (isset($result) && is_array($result) && count($result) > 0) {
1747
- foreach($result as $data) {
1748
- $i++;
1749
- if ($i > 10) {
1750
- wp_schedule_single_event(time() + 30, 'pz_linkcard_check');
1751
- break;
1752
- }
1753
- if (isset($data) && isset($data->url)) {
1754
- $data = $this->pz_RenewSNSCount(array('url' => $data->url) );
1755
- }
1756
- }
1757
- }
1758
- }
1759
-
1760
- // WP-CRONスケジュール(存在チェック)
1761
- public function schedule_hook_alive() {
1762
- if (!isset($this->options['flg-alive']) || $this->options['flg-alive'] == '') {
1763
- return null;
1764
- }
1765
-
1766
- global $wpdb;
1767
- $result = (array) $wpdb->get_results($wpdb->prepare("SELECT url,alive_time FROM $this->db_name WHERE alive_nexttime<%d ORDER BY alive_time ASC, id ASC", $this->now - WEEK_IN_SECONDS ));
1768
- $i = 0;
1769
- if (isset($result) && is_array($result) && count($result) > 0) {
1770
- foreach($result as $data) {
1771
- $i++;
1772
- if ($i > 5) {
1773
- wp_schedule_single_event(time() + 3600, 'pz_linkcard_alive');
1774
- break;
1775
- }
1776
- if (isset($data) && isset($data->url)) {
1777
- $before = $this->pz_GetCache( array( 'url' => $data->url ) );
1778
- $after = $this->pz_GetCURL( $before );
1779
- if ($before['title'] == $after['title'] ) {
1780
- $before['mod_title'] = 0;
1781
- } else {
1782
- $before['mod_title'] = 1;
1783
- }
1784
- if ($before['excerpt'] == $after['excerpt'] ) {
1785
- $before['mod_excerpt'] = 0;
1786
- } else {
1787
- $before['mod_excerpt'] = 1;
1788
- }
1789
- $before['alive_result'] = $after['result_code'];
1790
- $before['alive_time'] = $this->now;
1791
- $before['alive_nexttime'] = $this->now + WEEK_IN_SECONDS * 4 + rand(0, DAY_IN_SECONDS);
1792
- $before['thumbnail'] = $after['thumbnail'];
1793
- $before['favicon'] = $after['favicon'];
1794
- $before = $this->pz_SetCache( $before );
1795
- }
1796
- }
1797
- }
1798
- }
1799
-
1800
- // スタイルシート生成
1801
- public function pz_SetStyle() {
1802
- require_once ('lib/pz-linkcard-style.php');
1803
- }
1804
-
1805
- // Pz カード管理 キャッシュ・マネージャ
1806
- public function page_cacheman() {
1807
- require_once ('lib/pz-linkcard-cacheman.php');
1808
- }
1809
-
1810
- // Pz カード 設定画面
1811
- public function page_settings() {
1812
- require_once ('lib/pz-linkcard-settings.php');
1813
- }
1814
-
1815
- // プラグイン一覧のクイックメニュー
1816
- public function action_links($links) {
1817
- $links = array('<a href="options-general.php?page=pz-linkcard-settings">'.__('Settings', $this->text_domain).'</a>' , '<a href="tools.php?page=pz-linkcard-cache">'.__('Manage', $this->text_domain).'</a>' ) + $links;
1818
- return $links;
1819
- }
1820
-
1821
- // プラグイン有効化
1822
- public function activate() {
1823
- require_once ('lib/pz-linkcard-init.php');
1824
- }
1825
-
1826
- // プラグイン停止
1827
- public function deactivate() {
1828
- wp_clear_scheduled_hook('pz_linkcard_check');
1829
- wp_clear_scheduled_hook('pz_linkcard_alive');
1830
- }
1831
-
1832
- }
1833
- $Class_Pz_LinkCard = new Pz_LinkCard;
1
+ <?php
2
+ /*
3
+ Plugin Name: Pz-LinkCard
4
+ Plugin URI: http://poporon.poponet.jp/pz-linkcard
5
+ Description: リンクをカード形式で表示します。
6
+ Version: 2.3.1
7
+ Author: poporon
8
+ Author URI: http://poporon.poponet.jp
9
+ License: GPLv2 or later
10
+ */
11
+
12
+ defined('ABSPATH') || die;
13
+
14
+ class Pz_LinkCard {
15
+ public $slug; // スラッグ
16
+ public $text_domain; // テキスト ドメイン(スラッグと同じ内容)
17
+
18
+ public $charset; // 文字セット
19
+
20
+ public $amp; // Google AMP
21
+
22
+ public $now; // 現在日時(ローカル時間)
23
+ public $now_mysql; // 現在日時(SQL形式)
24
+
25
+ public $plugin_basename; // プラグイン ディレクトリの名前
26
+ public $plugin_dir_path; // プラグイン ディレクトリのパス
27
+ public $plugin_dir_url; // プラグイン ディレクトリのURL
28
+ public $plugin_link; // プラグインページのURL
29
+
30
+ public $upload_dir_path; // アップロード ディレクトリのパス
31
+ public $upload_dir_url; // アップロード ディレクトリのURL
32
+
33
+ private $db_name; // DB名
34
+
35
+ public $options;
36
+ protected $defaults = array(
37
+ 'code1' => 'blogcard',
38
+ 'code2' => null,
39
+ 'code3' => null,
40
+ 'code4' => null,
41
+ 'auto-atag' => null,
42
+ 'auto-url' => null,
43
+ 'auto-external' => null,
44
+ 'trail-slash' => '1',
45
+ 'border-width' => '1px',
46
+ 'border-style' => 'solid',
47
+ 'border-color' => '#888888',
48
+ 'width' => '500px',
49
+ 'content-height' => '108px',
50
+ 'margin-top' => '4px',
51
+ 'margin-right' => '16px',
52
+ 'margin-bottom' => '16px',
53
+ 'margin-left' => '4px',
54
+ 'card-top' => null,
55
+ 'card-right' => null,
56
+ 'card-bottom' => null,
57
+ 'card-left' => null,
58
+ 'centering' => null,
59
+ 'radius' => null,
60
+ 'shadow' => null,
61
+ 'shadow-inset' => null,
62
+ 'opacity' => null,
63
+ 'hover' => null,
64
+ 'special-format' => null,
65
+ 'use-inline' => null,
66
+ 'use-sitename' => '1',
67
+ 'use-hatena' => null,
68
+ 'display-url' => '1',
69
+ 'display-excerpt' => '1',
70
+ 'display-date' => '1',
71
+ 'trim-title' => 80,
72
+ 'trim-url' => 250,
73
+ 'trim-count' => 250,
74
+ 'trim-sitename' => 45,
75
+ 'info-position' => '1',
76
+ 'separator' => null,
77
+ 'size-title' => '16px',
78
+ 'size-url' => '10px',
79
+ 'size-excerpt' => '11px',
80
+ 'size-info' => '12px',
81
+ 'size-added' => '12px',
82
+ 'size-more' => '12px',
83
+ 'size-plugin' => '10px',
84
+ 'height-title' => '24px',
85
+ 'height-url' => '10px',
86
+ 'height-excerpt' => '17px',
87
+ 'height-info' => '12px',
88
+ 'height-added' => '12px',
89
+ 'height-more' => '40px',
90
+ 'height-plugin' => '10px',
91
+ 'color-title' => '#111111',
92
+ 'color-url' => '#4466ff',
93
+ 'color-excerpt' => '#333333',
94
+ 'color-info' => '#222222',
95
+ 'color-added' => '#222222',
96
+ 'color-more' => '#444444',
97
+ 'color-plugin' => '#888888',
98
+ 'outline-color-title' => '#ffffff',
99
+ 'outline-color-url' => '#ffffff',
100
+ 'outline-color-excerpt' => '#ffffff',
101
+ 'outline-color-info' => '#ffffff',
102
+ 'outline-color-added' => '#ffffff',
103
+ 'outline-color-more' => '#ffffff',
104
+ 'outline-color-plugin' => '#ffffff',
105
+ 'nowrap-title' => null,
106
+ 'nowrap-url' => '1',
107
+ 'ex-bgcolor' => '#ffffff',
108
+ 'in-bgcolor' => '#f8f8f8',
109
+ 'th-bgcolor' => '#eeeeee',
110
+ 'ex-border-color' => '#888888',
111
+ 'in-border-color' => '#888888',
112
+ 'th-border-color' => '#888888',
113
+ 'in-get' => null,
114
+ 'ex-image' => null,
115
+ 'in-image' => null,
116
+ 'th-image' => null,
117
+ 'ex-info' => null,
118
+ 'in-more-text' => null,
119
+ 'th-more-text' => null,
120
+ 'ex-more-text' => null,
121
+ 'in-info' => null,
122
+ 'th-info' => null,
123
+ 'in-target' => null,
124
+ 'ex-target' => '2',
125
+ 'ex-thumbnail' => '13',
126
+ 'in-thumbnail' => '1',
127
+ 'ex-favicon' => '3',
128
+ 'in-favicon' => '3',
129
+ 'favicon-api' => 'https://www.google.com/s2/favicons?domain=%DOMAIN%',
130
+ 'thumbnail-api' => 'https://s.wordpress.com/mshots/v1/%URL%?w=100',
131
+ 'thumbnail-position'=> '2',
132
+ 'thumbnail-width' => '100px',
133
+ 'thumbnail-height' => '108px',
134
+ 'thumbnail-shadow' => null,
135
+ 'thumbnail-resize' => '1',
136
+ 'cache-time' => 31536000,
137
+ 'user-agent' => null,
138
+ 'flg-more' => null,
139
+ 'flg-referer' => '1',
140
+ 'flg-agent' => '1',
141
+ 'flg-redir' => '1',
142
+ 'flg-alive' => '1',
143
+ 'flg-alive-count' => null,
144
+ 'flg-ssl' => '1',
145
+ 'flg-amp-url' => null,
146
+ 'flg-relative-url' => null,
147
+ 'flg-idn' => '1',
148
+ 'flg-anker' => '1',
149
+ 'flg-unlink' => '1',
150
+ 'flg-get-pid' => null,
151
+ 'flg-subdir' => '1',
152
+ 'flg-invalid' => null,
153
+ 'flg-edit-insert' => '1',
154
+ 'flg-edit-qtag' => '1',
155
+ 'flg-do-shortcode' => null,
156
+ 'style-reset-img' => '1',
157
+ 'style' => null,
158
+ 'css-add' => null,
159
+ 'css-sp' => null,
160
+ 'css-file' => null,
161
+ 'css-path' => null,
162
+ 'css-url' => null,
163
+ 'class-pc' => null,
164
+ 'class-mobile' => null,
165
+ 'sns-position' => '2',
166
+ 'sns-tw' => '1',
167
+ 'sns-fb' => '1',
168
+ 'sns-hb' => '1',
169
+ 'sns-po' => '1',
170
+ 'link-all' => '1',
171
+ 'blockquote' => null,
172
+ 'nofollow' => null,
173
+ 'presence' => null,
174
+ 'thumbnail-dir' => null,
175
+ 'thumbnail-url' => null,
176
+ 'invalid-url' => null,
177
+ 'invalid-time' => null,
178
+ 'plugin-link' => null,
179
+ 'plugin-name' => 'Pz-LinkCard',
180
+ 'plugin-version' => '2.3.1',
181
+ 'plugin-url' => 'https://popozure.info/pz-linkcard',
182
+ 'pz-hbc-options' => null,
183
+ 'debug-time' => null
184
+ );
185
+
186
+ public function __construct() {
187
+ $this->slug = basename(dirname(__FILE__));
188
+ $this->text_domain = $this->slug;
189
+
190
+ $this->charset = get_bloginfo('charset');
191
+
192
+ $this->amp = '1';
193
+
194
+ $this->now = current_time('timestamp', false);
195
+ $this->now_mysql = current_time('mysql');
196
+
197
+ $this->plugin_basename = plugin_basename(__FILE__);
198
+ $this->plugin_dir_path = plugin_dir_path(__FILE__);
199
+ $this->plugin_dir_url = plugin_dir_url (__FILE__);
200
+
201
+ $wp_upload_dir = wp_upload_dir();
202
+ $this->upload_dir_path = $wp_upload_dir['basedir'].'/'.$this->slug.'/';
203
+ $this->upload_dir_url = $wp_upload_dir['baseurl'].'/'.$this->slug.'/';
204
+
205
+ $this->options = get_option('Pz_LinkCard_options', $this->defaults );
206
+ foreach ($this->defaults as $key => $value) {
207
+ if (!isset($this->options[$key])) {
208
+ $this->options[$key] = null;
209
+ }
210
+ }
211
+
212
+ // DB
213
+ global $wpdb;
214
+ $this->db_name = $wpdb->prefix.'pz_linkcard';
215
+
216
+ // バージョンが違っていたら、DBとオプションを更新する
217
+ if ($this->options['plugin-version'] <> $this->defaults['plugin-version']) {
218
+ $this->activate();
219
+ }
220
+
221
+ // ショートコードの設定
222
+ if ($this->options['auto-atag'] || $this->options['auto-url']) {
223
+ add_filter ('the_content', array($this, 'auto_replace') ); // 自動置き換え
224
+ add_shortcode ('pz-linkcard-auto-replace', array($this, 'shortcode') ); // 自動置き換え専用ショートコード
225
+ }
226
+ if ($this->options['code1']) {
227
+ add_shortcode($this->options['code1'], array($this, 'shortcode'));
228
+ }
229
+ if ($this->options['code2']) {
230
+ add_shortcode($this->options['code2'], array($this, 'shortcode'));
231
+ }
232
+ if ($this->options['code3']) {
233
+ add_shortcode($this->options['code3'], array($this, 'shortcode'));
234
+ }
235
+ if ($this->options['code4']) {
236
+ add_shortcode($this->options['code4'], array($this, 'shortcode'));
237
+ }
238
+
239
+ // 日本語化
240
+ load_plugin_textdomain ($this->text_domain, false, $this->slug.'/languages');
241
+
242
+ // 管理画面のとき
243
+ if (is_admin()) {
244
+ register_activation_hook (__FILE__, array($this, 'activate') ); // 有効化したときの処理
245
+ register_deactivation_hook (__FILE__, array($this, 'deactivate') ); // 無効化したときの処理
246
+ add_action ('admin_menu', array($this, 'add_menu') ); // 設定メニュー
247
+ add_action ('admin_enqueue_scripts', array($this, 'enqueue_admin') ); // 設定メニュー用スクリプト
248
+ add_action ('admin_print_footer_scripts', array($this, 'add_footer') ); // テキストエディタ用クイックタグ
249
+ add_action ('admin_notices', array($this, 'add_notices')); // 注意書き
250
+ add_filter ('mce_buttons', array($this, 'add_mce_button') ); // ビジュアルエディタ用ボタン
251
+ add_filter ('mce_external_plugins', array($this, 'add_mce_plugin') ); // ビジュアルエディタ用ボタン
252
+ add_filter ('plugin_action_links_'.$this->plugin_basename, array($this, 'action_links') ); // プラグイン画面
253
+ } else {
254
+ add_action('wp_enqueue_scripts', array($this, 'enqueue'));
255
+ }
256
+
257
+ add_action( 'pz_linkcard_check', array( $this, 'schedule_hook_check' ) );
258
+ add_action( 'pz_linkcard_alive', array( $this, 'schedule_hook_alive' ) );
259
+
260
+ if (!wp_next_scheduled('pz_linkcard_check')) {
261
+ wp_schedule_event ( time() + 10 , 'hourly', 'pz_linkcard_check');
262
+ }
263
+ if (!wp_next_scheduled('pz_linkcard_alive')) {
264
+ wp_schedule_event ( time() + 1800 , 'daily', 'pz_linkcard_alive');
265
+ }
266
+ }
267
+
268
+ // テキストリンクの行とURLのみの行をリンクカードへ置き換える処理(直接HTMLタグにするのでは無くショートコードに変換する。)
269
+ public function auto_replace($content) {
270
+ if (!$this->options['auto-external']) {
271
+ if ($this->options['auto-atag']) {
272
+ $content = preg_replace( '/(^|<br ?\/?>)(<p.*>)?<a .*href=[\'"](https?:\/\/[-_\.!~*()a-zA-Z0-9;\/?:\@&=+\$,%#]+)[\'"]((?!<IMG).)*<\/a>(<\/p>)?$/im', '[pz-linkcard-auto-replace url="$3"]', $content);
273
+ }
274
+ if ($this->options['auto-url']) {
275
+ $content = preg_replace( '/(^|<br ?\/?>)(<p.*>)?(https?:\/\/[-_\.!~*()a-zA-Z0-9;\/?:\@&=+\$,%#]+)(<\/p>|<br ?\/?>)?$/im', '[pz-linkcard-auto-replace url="$3"]', $content);
276
+ }
277
+ if ($this->options['flg-do-shortcode']) {
278
+ $content = do_shortcode($content);
279
+ }
280
+ return $content;
281
+ } else {
282
+ if ($this->options['auto-atag']) {
283
+ preg_match_all('/(^|<br ?\/?>)(<p.*>)?(<a .*href=[\'"](https?:\/\/[-_\.!~*()a-zA-Z0-9;\/?:\@&=+\$,%#]+)[\'"]((?!<IMG).)*<\/a>)(<\/p>)?$/im', $content, $m );
284
+ for ($i=0; $i<count($m[0]); $i++) {
285
+ $url = $m[4][$i];
286
+ if ($this->Pz_LinkType($url ) == 0) {
287
+ $tag = '[pz-linkcard-auto-replace url="'.$url.'"]';
288
+ $content = preg_replace('{'.$m[0][$i].'}', $tag, $content, 1);
289
+ }
290
+ }
291
+ }
292
+ if ($this->options['auto-url']) {
293
+ preg_match_all('/(^|<br ?\/?>)(<p.*>)?(https?:\/\/[-_\.!~*()a-zA-Z0-9;\/?:\@&=+\$,%#]+)(<\/p>|<br ?\/?>)?$/im', $content, $m );
294
+ for ($i=0; $i<count($m[0]); $i++) {
295
+ $url = $m[3][$i];
296
+ if ($this->Pz_LinkType($url ) == 0) {
297
+ $tag = '[pz-linkcard-auto-replace url="'.$url.'"]';
298
+ $content = preg_replace('{'.$m[0][$i].'}', $tag, $content, 1);
299
+ }
300
+ }
301
+ }
302
+ if ($this->options['flg-do-shortcode']) {
303
+ $content = do_shortcode($content);
304
+ }
305
+ return $content;
306
+ }
307
+ }
308
+
309
+ // ショートコード処理
310
+ public function shortcode($atts, $content = null, $shortcode) {
311
+ // 実行時間
312
+ if ($this->options['debug-time']) {
313
+ $start_time = microtime(true);
314
+ echo PHP_EOL.'<!-- Pz-LkC [Debug mode: On] /-->'.PHP_EOL;
315
+ echo '<!-- Pz-LkC [Shortcode] /-->'.PHP_EOL;
316
+ }
317
+
318
+ // URL
319
+ $url = '';
320
+ if (isset( $atts['url'] ) ) {
321
+ $url = $atts['url'];
322
+ } elseif (isset( $atts['href'] ) ) { // Aタグのようにhrefパラメータも有効にする
323
+ $url = $atts['href'];
324
+ } elseif (isset( $atts['uri'] ) ) { // 密かに記述ミス対応(uriやurIでもurlとして判定する)
325
+ $url = $atts['uri'];
326
+ } elseif (isset( $atts['ur1'] ) ) { // 密かに記述ミス対応(ur1でもurlとして判定する)
327
+ $url = $atts['ur1'];
328
+ } elseif (isset( $atts[0] ) ) { // 謎の記述ミスに対応
329
+ if (preg_match('/url=[\s \'\"‘’“”″]*(.*?)[\s \'\"‘’“”″]*$/u', $atts[0], $m)) {
330
+ $url = $m[1];
331
+ } elseif (isset( $atts[1] ) ) { // 謎の記述ミスに対応
332
+ if (preg_match('/url=[\s \'\"‘’“”″]*(.*?)[\s \'\"‘’“”″]*$/u', $atts[1], $m)) {
333
+ $url = $m[1];
334
+ }
335
+ }
336
+ }
337
+ $url_org = $url; // 指定されたurlパラメータ
338
+ if ($this->options['flg-relative-url']) {
339
+ if (substr($url, 0, 1) == '/') {
340
+ $url = home_url() . $url;
341
+ }
342
+ }
343
+ $url = $this->pz_TrimURL( $url ); // URLエンティティ化など(無害化?)
344
+ if ( !$url ) {
345
+ if ($this->options['debug-time']) {
346
+ echo '<!-- Pz-LkC ['.html_entity_decode(print_r($atts, true)).'] /-->'.PHP_EOL;
347
+ }
348
+ if (!$this->options['flg-invalid']) {
349
+ if (!preg_match('/\/wp-admin\/admin-ajax.php/i', $_SERVER["REQUEST_URI"])) {
350
+ $this->options['flg-invalid'] = '1';
351
+ $this->options['invalid-url'] = (!$_SERVER["HTTPS"] ? "http://" : "https://").$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];
352
+ $this->options['invalid-time'] = $this->now;
353
+ $result = update_option('Pz_LinkCard_options', $this->options);
354
+ }
355
+ }
356
+ return '<a name="pz-lkc-error"></a><div class="lkc-error"><div class="lkc-card"><div class="lkc-this-wrap"><div class="lkc-excerpt">'.$this->slug.': '.__('Incorrect URL specification.', $this->text_domain).'(url='.html_entity_decode($url_org).')'.PHP_EOL.'<!-- '.html_entity_decode(print_r($atts, true)).' /-->'.PHP_EOL.'</div></div></div></div>';
357
+ }
358
+ $atts['url'] = $url;
359
+
360
+ // titleパラメータ
361
+ $s_title = isset($atts['title'] ) ? $atts['title'] : null;
362
+
363
+ // contentパラメータ
364
+ if (isset($atts['content'] ) ) {
365
+ $s_excerpt = $atts['content'];
366
+ } elseif (isset($atts['contents'] ) ) {
367
+ $s_excerpt = $atts['contents'];
368
+ } elseif (isset($atts['description'] ) ) {
369
+ $s_excerpt = $atts['description'];
370
+ } else {
371
+ $s_excerpt = null;
372
+ }
373
+
374
+ // 囲まれ文字(ショートコード1のみ有効)
375
+ if ($shortcode == $this->options['code1']) {
376
+ switch (isset($this->options['use-inline']) ? $this->options['use-inline'] : null) {
377
+ case '1':
378
+ $s_excerpt = isset($content) ? $content : '';
379
+ break;
380
+ case '2':
381
+ $s_title = isset($content) ? $content : '';
382
+ break;
383
+ }
384
+ }
385
+
386
+ // 記事内容取得
387
+ $data = $this->pz_GetHTML ( $atts );
388
+
389
+ // 実行時間
390
+ if ($this->options['debug-time']) {
391
+ $end_time = microtime(true);
392
+ $elasped_time = number_format($end_time - $start_time, 8, '.', ',');
393
+ echo '<!-- Pz-LkC [ElaspedTime='.$elasped_time.'sec] /-->'.PHP_EOL;
394
+ }
395
+
396
+ return $data;
397
+ }
398
+
399
+ // キャッシュやリンク先からリンクカードのHTMLを生成
400
+ function pz_GetHTML( $atts, $content = null ) {
401
+ if ($this->options['debug-time']) {
402
+ echo '<!-- Pz-LkC [GetHTML] /-->'.PHP_EOL;
403
+ }
404
+
405
+ // モバイルチェック
406
+ if (function_exists('wp_is_mobile') && wp_is_mobile()) {
407
+ $is_mobile = true;
408
+ } else {
409
+ $is_mobile = false;
410
+ }
411
+ if ($this->options['debug-time']) {
412
+ echo '<!-- Pz-LkC [MOBILE='.$is_mobile.'] /-->'.PHP_EOL;
413
+ }
414
+
415
+ $url = $atts['url'];
416
+ if (!isset($url) || $url == '' ) {
417
+ return null;
418
+ }
419
+ if ($this->options['debug-time']) {
420
+ echo '<!-- Pz-LkC [URL='.$url.'] /-->'.PHP_EOL;
421
+ }
422
+
423
+ // URLパース(ドメイン名などを抽出)
424
+ $url_m = parse_url( $url );
425
+ $scheme = $url_m['scheme']; // スキーム
426
+ $domain = $url_m['host']; // ドメイン名
427
+ $domain_url = $scheme.'://'.$url_m['host']; // ドメインURL
428
+ $location = substr($url, mb_strlen($domain_url)); // ドメイン名以降
429
+
430
+ // 自サイトチェック
431
+ $link_type = $this->Pz_LinkType($url);
432
+
433
+ // モバイルかPCかのクラス名を追加
434
+ $class_id = 'linkcard';
435
+ if ($is_mobile && $this->options['class-mobile']) {
436
+ $class_id .= ' '.$this->options['class-mobile'];
437
+ } elseif ($this->options['class-pc']) {
438
+ $class_id .= ' '.$this->options['class-pc'];
439
+ }
440
+
441
+ // キャッシュから取得
442
+ $data_id = null;
443
+ $data = array();
444
+ $data['url'] = $url;
445
+ $result = $this->pz_GetCache( $data );
446
+ if (isset($result) && is_array($result) && isset($result['url'])) {
447
+ $data = $result;
448
+ $data_id = $data['id'];
449
+ $url = $data['url'];
450
+ }
451
+ if ($this->options['debug-time']) {
452
+ echo '<!-- Pz-LkC [CACHE='.$data_id.'] /-->'.PHP_EOL;
453
+ }
454
+
455
+ // 内部リンクの処理
456
+ if ( $link_type ) {
457
+ // リンクターゲットの設定
458
+ $target = ''; // 同ページに開く
459
+ if (isset($this->options['in-target'])) {
460
+ if ($this->options['in-target'] == '1' || ($this->options['in-target'] == '2' && !$is_mobile)) {
461
+ $target = ' target="_blank"'; // 新しいページで開く
462
+ }
463
+ }
464
+
465
+ // followパラメータ
466
+ if ( (isset($atts['follow'] ) && mb_strtolower($atts['follow']) == 'no') || (isset($atts['nofollow'] ) && mb_strtolower($atts['nofollow']) == 'true') ) {
467
+ $nofollow = ' rel="nofollow"'; // nofollow指定。趣味の問題?
468
+ } else {
469
+ $nofollow = '';
470
+ }
471
+
472
+ // キャッシュが無い、もしくは強制取得
473
+ if ( is_null($data_id) || ( isset($atts['force']) && $atts['force'] == true ) ) {
474
+ if ($this->options['debug-time']) {
475
+ echo '<!-- Pz-LkC [IN-POST] /-->'.PHP_EOL;
476
+ }
477
+ $data = $this->pz_GetPost( $data ); // 最新記事内容を取得
478
+ $data['link_type'] = 1;
479
+ if ($this->options['debug-time']) {
480
+ echo '<!-- Pz-LkC [IN-SET] /-->'.PHP_EOL;
481
+ }
482
+ $result = $this->pz_SetCache( $data ); // 保存
483
+ } elseif ($this->options['in-get'] <> 2) {
484
+ if ($this->options['debug-time']) {
485
+ echo '<!-- Pz-LkC [IN-POST] /-->'.PHP_EOL;
486
+ }
487
+ $data = $this->pz_GetPost( $data ); // 最新記事内容を取得
488
+ $data['link_type'] = 1;
489
+ }
490
+ }
491
+
492
+ // 外部リンクの処理
493
+ if ( !$link_type ) {
494
+ // リンクターゲットの設定
495
+ $target = ''; // 同ページに開く
496
+ if (isset($this->options['ex-target'] ) ) {
497
+ if ($this->options['ex-target'] == '1' || ($this->options['ex-target'] == '2' && !$is_mobile ) ) {
498
+ $target = ' target="_blank"'; // 新しいページで開く
499
+ }
500
+ }
501
+
502
+ // followパラメータ
503
+ if (isset($this->options['nofollow'] ) || (isset($atts['follow'] ) && mb_strtolower($atts['follow']) == 'no') || (isset($atts['nofollow'] ) && mb_strtolower($atts['nofollow']) == 'true') ) {
504
+ $nofollow = ' rel="nofollow"'; // nofollow指定。趣味の問題?
505
+ } else {
506
+ $nofollow = '';
507
+ }
508
+
509
+ // キャッシュが無い、もしくは強制取得
510
+ if ( is_null($data_id) || ( isset($atts['force']) && $atts['force'] == true ) ) {
511
+ if ($this->options['debug-time']) {
512
+ echo '<!-- Pz-LkC [OUT-CURL] /-->'.PHP_EOL;
513
+ }
514
+ $result = $this->pz_GetCURL( $data ); // cURLで記事内容を取得
515
+ if ( isset($result) && is_array($result) && isset($result['url']) ) {
516
+ $data = $result;
517
+ $data['link_type'] = 0;
518
+ $result = $this->pz_SetCache( $data );
519
+ }
520
+ }
521
+ }
522
+
523
+ // 念のため初期化
524
+ $data_id = (isset($data['id']) ? $data['id'] : null);
525
+ $site_name = (isset($data['site_name']) ? $data['site_name'] : null);
526
+ $title = (isset($data['title']) ? $data['title'] : null);
527
+ $excerpt = (isset($data['excerpt']) ? $data['excerpt'] : null);
528
+ $post_date = (isset($data['post_date']) ? $data['post_date'] : null);
529
+ $thumbnail_url = (isset($data['thumbnail']) ? $data['thumbnail'] : null);
530
+ $favicon_url = (isset($data['favicon']) ? $data['favicon'] : null);
531
+ $result_code = (isset($data['result_code']) ? $data['result_code'] : null);
532
+ $sns_tw = (isset($data['sns_twitter']) ? $data['sns_twitter'] : null);
533
+ $sns_fb = (isset($data['sns_facebook']) ? $data['sns_facebook'] : null);
534
+ $sns_hb = (isset($data['sns_hatena']) ? $data['sns_hatena'] : null);
535
+ $sns_po = (isset($data['sns_pocket']) ? $data['sns_pocket'] : null);
536
+ $alive_result = (isset($data['alive_result']) ? $data['alive_result'] : null);
537
+
538
+ $thumbnail = null;
539
+ $favicon = null;
540
+
541
+ // ラッピング
542
+ switch ($link_type) {
543
+ case '1':
544
+ $wrap_op = '<div class="lkc-this-wrap">';
545
+ $wrap_cl = '</div>';
546
+ $added_op = '<div class="lkc-this-added">';
547
+ $added_cl = '</div>';
548
+ $more = null;
549
+ $more_text = null;
550
+ $info = isset($this->options['th-info']) ? $this->options['th-info'] : null ;
551
+ $sw_thumbnail = isset($this->options['in-thumbnail']) ? $this->options['in-thumbnail'] : '0' ;
552
+ $sw_favicon = isset($this->options['in-favicon']) ? $this->options['in-favicon'] : '0' ;
553
+ break;
554
+ case '2':
555
+ $wrap_op = '<div class="lkc-internal-wrap">';
556
+ $wrap_cl = '</div>';
557
+ $added_op = '<div class="lkc-internal-added">';
558
+ $added_cl = '</div>';
559
+ $more = isset($this->options['flg-more']) ? $this->options['flg-more'] : null ;
560
+ $more_text = isset($this->options['in-more-text']) ? $this->options['in-more-text'] : null ;
561
+ $info = isset($this->options['in-info']) ? $this->options['in-info'] : null ;
562
+ $sw_thumbnail = isset($this->options['in-thumbnail']) ? $this->options['in-thumbnail'] : '0' ;
563
+ $sw_favicon = isset($this->options['in-favicon']) ? $this->options['in-favicon'] : '0' ;
564
+ break;
565
+ default:
566
+ $wrap_op = '<div class="lkc-external-wrap">';
567
+ $wrap_cl = '</div>';
568
+ $added_op = '<div class="lkc-external-added">';
569
+ $added_cl = '</div>';
570
+ $more = isset($this->options['flg-more']) ? $this->options['flg-more'] : null ;
571
+ $more_text = isset($this->options['ex-more-text']) ? $this->options['ex-more-text'] : null ;
572
+ $info = isset($this->options['ex-info']) ? $this->options['ex-info'] : '' ;
573
+ $sw_thumbnail = isset($this->options['ex-thumbnail']) ? $this->options['ex-thumbnail'] : '0' ;
574
+ $sw_favicon = isset($this->options['ex-favicon']) ? $this->options['ex-favicon'] : '0' ;
575
+ break;
576
+ }
577
+
578
+ // 外部リンクの処理
579
+ if ( !$link_type && isset($this->options['use-hatena']) && !is_null($this->options['use-hatena'] ) ) {
580
+ // 「はてなブログカード」をそのまま利用する
581
+ $tag = '<div class="lkc-iframe-wrap"><iframe src="https://hatenablog-parts.com/embed?url=' .$url.'" class="lkc-iframe" scrolling="no" frameborder="0"></iframe></div>';
582
+ if (isset($this->options['blockquote']) ? $this->options['blockquote'] : null == '1') {
583
+ $tag = '<div class="'.$class_id.'"><blockquote class="lkc-quote">'.$tag.'</blockquote></div>';
584
+ } else {
585
+ $tag = '<div class="'.$class_id.'">'.$tag.'</div>';
586
+ }
587
+ return $tag; // タグを出力してさっさと終了
588
+ }
589
+
590
+ // サムネイル取得
591
+ if ( !$this->options['thumbnail-position'] || ( $result_code <> 0 && $result_code <> 200 ) ) {
592
+ $thumbnail = null;
593
+ } else {
594
+ if ($sw_thumbnail == '1' || $sw_thumbnail == '13') { // 直接取得
595
+ if ( !$link_type ) {
596
+ $thumbnail_url = $this->pz_GetThumbnail($thumbnail_url); // 外部サイトのサムネイルをキャッシュ
597
+ }
598
+ if ( isset($thumbnail_url) && $thumbnail_url <> '' ) {
599
+ $thumbnail = '<img class="lkc-thumbnail-img" src="'.$thumbnail_url.'" alt="" />';
600
+ } elseif ($sw_thumbnail == '13') { // 直接取得に失敗
601
+ $sw_thumbnail = '3';
602
+ }
603
+ }
604
+ if ($sw_thumbnail == '3') { // WebAPIを利用
605
+ // 画像取得(WebAPI)
606
+ if (isset($this->options['thumbnail-api'])) {
607
+ $thumbnail = preg_replace('/%DOMAIN_URL%/', $domain_url, $this->options['thumbnail-api'] );
608
+ $thumbnail = preg_replace('/%DOMAIN%/', $domain, $thumbnail);
609
+ $thumbnail = preg_replace('/%URL%/', rawurlencode($url), $thumbnail);
610
+ $thumbnail = '<img class="lkc-thumbnail-img" src="'.$thumbnail.'" alt="" />';
611
+ }
612
+ }
613
+ }
614
+
615
+ // ファビコン取得
616
+ if (!isset($this->options['info-position'])) {
617
+ $favicon = null;
618
+ } else{
619
+ if ($sw_favicon == '1' || $sw_favicon == '13') { // 直接取得
620
+ if ( !is_null($favicon_url ) ) {
621
+ $favicon = '<img class="lkc-favicon" src="'.$favicon_url.'" alt="" width=16 height=16 />';
622
+ } elseif ($sw_favicon == '13') { // 直接取得に失敗
623
+ $sw_favicon == '3';
624
+ }
625
+ }
626
+ if ($sw_favicon == '3') { // WebAPIを利用
627
+ // サイトアイコン取得(WebAPI)
628
+ if (isset($this->options['favicon-api'])) {
629
+ $favicon = preg_replace('/%DOMAIN_URL%/', $domain_url, $this->options['favicon-api'] );
630
+ $favicon = preg_replace('/%DOMAIN%/', $domain, $favicon);
631
+ $favicon = preg_replace('/%URL%/', rawurlencode($url), $favicon);
632
+ $favicon = '<img class="lkc-favicon" src="'.$favicon.'" alt="" width=16 height=16 />';
633
+ }
634
+ }
635
+ }
636
+
637
+ // タイトル
638
+ if (!isset($title) || $title == '') {
639
+ $title = esc_html($url); // タイトル取得できていなかったらURLをセットする
640
+ }
641
+
642
+ // パラメータ取得(タイトル・抜粋文)
643
+ if (isset($atts['title'])) { // titleパラメータ
644
+ $title = $atts['title'];
645
+ $excerpt = '';
646
+ }
647
+ if ($excerpt == '') {
648
+ if (isset($atts['content'])) { // contrentパラメータ
649
+ $excerpt = $atts['content'];
650
+ } elseif (isset($atts['contents'])) { // contentsパラメータ
651
+ $excerpt = $atts['contents'];
652
+ } elseif (isset($atts['description'])) { // descriptionパラメータ
653
+ $excerpt = $atts['description'];
654
+ }
655
+ }
656
+
657
+ // タイトル整形
658
+ if (isset($title)) {
659
+ $str = $title;
660
+ $str = strip_tags($str); // タグの除去
661
+ $str = str_replace(array("\r", "\n"), '', $str); // 改行削除
662
+ $str = esc_html($str); // 念のためエスケープ
663
+ $str = mb_strimwidth($str, 0, (isset($this->options['trim-title']) ? $this->options['trim-title'] : $this->defaults['trim-title'] ) , '...');
664
+ $title = $str;
665
+ }
666
+
667
+ // 抜粋文整形(抜粋文非表示の場合、空欄にする)
668
+ if (!isset($this->options['display-excerpt']) || is_null($this->options['display-excerpt'])) {
669
+ $excerpt = '';
670
+ } else {
671
+ if (isset($excerpt)) {
672
+ $str = $excerpt;
673
+ $str = strip_tags($str); // タグの除去
674
+ $str = preg_replace('/<!--more-->.+/is', '', $str); // moreタグ以降削除
675
+ $str = preg_replace('/\[[^]]*\]/', '', $str); // ショートコードすべて除去
676
+ $str = str_replace(array("\r", "\n"), '', $str); // 改行削除
677
+ $str = esc_html($str); // 念のためエスケープ
678
+ $str = mb_strimwidth($str, 0, (isset($this->options['trim-count']) ? $this->options['trim-count'] : $this->defaults['trim-count'] ) , '...');
679
+ $excerpt = $str;
680
+ }
681
+ }
682
+
683
+ // サイト名称を使わない場合、ドメイン名で上書き
684
+ $site_title = '';
685
+ if ((isset($this->options['use-sitename']) ? $this->options['use-sitename'] : null) && $site_name) {
686
+ $c_site_name = $site_name;
687
+ $site_name = mb_strimwidth($site_name, 0, (isset($this->options['trim-sitename']) ? $this->options['trim-sitename'] : $this->defaults['trim-sitename'] ) , '...');
688
+ if ($site_name <> $c_site_name) {
689
+ $site_title = ' title="'.$c_site_name.'"';
690
+ }
691
+ } else {
692
+ $site_name = $domain;
693
+ // 日本語ドメイン対応
694
+ if (isset($this->options['flg-idn']) ? true : false) {
695
+ if (function_exists('idn_to_utf8')) {
696
+ if (substr( $domain, 0, 4 ) == 'xn--') {
697
+ $site_name = idn_to_utf8( $domain );
698
+ }
699
+ }
700
+ }
701
+ }
702
+
703
+ // リンク先URL
704
+ if ( (isset($this->options['flg-unlink']) ? true : false) && (array_search($alive_result, array('403','404','410'))) ) {
705
+ // Not found の時は見え消ししてリンクしない
706
+ $a_op_all = '<div style="cursor: not-allowed;" title="">';
707
+ $a_cl_all = '</div>';
708
+ $a_op = '';
709
+ $a_cl = '';
710
+ $st_op = '<strike>';
711
+ $st_cl = '</strike>';
712
+ } elseif ((isset($this->options['link-all']) ? $this->options['link-all'] : null) == '1') {
713
+ // カード全体をリンク(どこをクリックしても良いのが分かり易い)
714
+ $a_op_all = '<a class="lkc-link no_icon" href="'.$url.'"'.$target.$nofollow.'>';
715
+ $a_cl_all = '</a>';
716
+ $a_op = '';
717
+ $a_cl = '';
718
+ $st_op = '';
719
+ $st_cl = '';
720
+ } else {
721
+ // タイトルとかURLとかを個別でリンク(タイトルや抜粋文などの文字を範囲指定をしてコピー等がし易い)
722
+ $a_op_all = '';
723
+ $a_cl_all = '';
724
+ $a_op = '<a class="lkc-link no_icon" href="'.$url.'"'.$target.$nofollow.'>';
725
+ $a_cl = '</a>';
726
+ $st_op = '';
727
+ $st_cl = '';
728
+ }
729
+
730
+ // ソーシャルカウントの表示
731
+ $sns = null;
732
+ $sns_info = null;
733
+ $sns_title = null;
734
+ if ( isset($this->options['sns-position']) ? $this->options['sns-position'] : null ) {
735
+ $sns = '';
736
+ // カード全体をリンクにするときは表示のみ
737
+ if ((isset($this->options['link-all']) ? $this->options['link-all'] : null) == '1') {
738
+ if (isset($this->options['sns-tw']) && !is_null($this->options['sns-tw']) && $sns_tw > 0) {
739
+ $sns .= ' <div class="lkc-sns-tw">'.$sns_tw.'&nbsp;tweet'.(($sns_tw > 1) ? 's' : '').'</div>';
740
+ }
741
+ if (isset($this->options['sns-fb']) && !is_null($this->options['sns-fb']) && $sns_fb > 0) {
742
+ $sns .= ' <div class="lkc-sns-fb">'.$sns_fb.'&nbsp;share'.(($sns_fb > 1) ? 's' : '').'</div>';
743
+ }
744
+ if (isset($this->options['sns-hb']) && !is_null($this->options['sns-hb']) && $sns_hb > 0) {
745
+ $sns .= ' <div class="lkc-sns-hb">'.$sns_hb.'&nbsp;user'.(($sns_hb > 1) ? 's' : '').'</div>';
746
+ }
747
+ if (isset($this->options['sns-po']) && !is_null($this->options['sns-po']) && $sns_po > 0) {
748
+ $sns .= ' <div class="lkc-sns-po">'.$sns_po.'&nbsp;pocket'.(($sns_po > 1) ? 's' : '').'</div>';
749
+ }
750
+ } else {
751
+ // 外部リンクアイコンを表示させるプラグイン対応のため no_icon を付与
752
+ if (isset($this->options['sns-tw']) && !is_null($this->options['sns-tw']) && $sns_tw > 0) {
753
+ $sns .= ' <a class="lkc-sns-tw no_icon" href="https://twitter.com/search?q=' .preg_replace('/.*\/\/(.*)/', '$1', $url).'&text='.esc_html($title).'" target="_blank">'.$sns_tw.'&nbsp;tweet'.(($sns_tw > 1) ? 's' : '').'</a>';
754
+ }
755
+ if (isset($this->options['sns-fb']) && !is_null($this->options['sns-fb']) && $sns_fb > 0) {
756
+ $sns .= ' <a class="lkc-sns-fb no_icon" href="https://www.facebook.com/" target="_blank">'.$sns_fb.'&nbsp;share'.(($sns_fb > 1) ? 's' : '').'</a>';
757
+ }
758
+ if (isset($this->options['sns-hb']) && !is_null($this->options['sns-hb']) && $sns_hb > 0) {
759
+ $sns .= ' <a class="lkc-sns-hb no_icon" href="https://b.hatena.ne.jp/entry/s/' .preg_replace('/.*\/\/(.*)/', '$1', $url).'" target="_blank">'.$sns_hb.'&nbsp;user'.(($sns_hb > 1) ? 's' : '').'</a>';
760
+ }
761
+ if (isset($this->options['sns-po']) && !is_null($this->options['sns-po']) && $sns_po > 0) {
762
+ $sns .= ' <a class="lkc-sns-po no_icon" href="https://getpocket.com/" target="_blank">'.$sns_po.'&nbsp;pocket'.(($sns_po > 1) ? 's' : '').'</a>';
763
+ }
764
+ }
765
+ if ($sns) {
766
+ if ($this->options['sns-position'] == '1') {
767
+ $sns_title = '<div class="lkc-share">'.$sns.'</div>';
768
+ } else {
769
+ $sns_info = '&nbsp;'.'<div class="lkc-share">'.$sns.'</div>';
770
+ }
771
+ }
772
+ }
773
+
774
+ // サムネイル
775
+ if ($thumbnail) {
776
+ $thumbnail = '<figure class="lkc-thumbnail">'.$thumbnail.'</figure>';
777
+ }
778
+
779
+ // 日本語ドメイン対応
780
+ if (isset($this->options['flg-idn']) ? true : false) {
781
+ if (function_exists('idn_to_utf8')) {
782
+ if (substr( $domain, 0, 4 ) == 'xn--') {
783
+ $url = $scheme.'://'.idn_to_utf8( $domain ).$location;
784
+ }
785
+ }
786
+ }
787
+
788
+ // 続きを読むボタン
789
+ if ( $more && $more_text ) {
790
+ $moretag = '<div class="lkc-more">'.$a_op.'<div class="lkc-more-text">'.$more_text.'</div>'.$a_cl.'</div>';
791
+ } else {
792
+ $moretag = '';
793
+ }
794
+
795
+ // リンク先URL
796
+ $url1 = '';
797
+ $url2 = '';
798
+ if ($this->options['display-url']) {
799
+ if ($this->options['display-url'] == '2') {
800
+ $url2 = '&nbsp;<div class="lkc-url-info"><cite>'.$st_op.$a_op.$url.$st_cl.$a_cl.'</cite></div>';
801
+ } else {
802
+ $url1 = '<div class="lkc-url"><cite>'.$st_op.$a_op.$url.$st_cl.$a_cl.'</cite></div>';
803
+ }
804
+ }
805
+
806
+ // サイト情報
807
+ if ($info) {
808
+ $added_info = $added_op.$info.$added_cl;
809
+ } else {
810
+ $added_info = '';
811
+ }
812
+ if ($this->options['display-date'] && $link_type) {
813
+ $post_date = '<div class="lkc-date">'.date('Y.m.d', strtotime($post_date)).'</div>';
814
+ } else {
815
+ $post_date = '';
816
+ }
817
+ $domain_info = '<div class="lkc-info">'.$a_op.$favicon.'<div class="lkc-domain"'.$site_title.'>'.$site_name.'</div>'.$added_info.$a_cl.$sns_info.$url2.$post_date.'</div>';
818
+
819
+ // 記事内容
820
+ //$content = '<div class="lkc-content">'.$a_op.$thumbnail.'<div class="lkc-title"><div class="lkc-title-text">'.$title.'</div>'.$a_cl.$sns_title.'</div>'.$url1.'<div class="lkc-excerpt">'.$excerpt.'</div>'.$moretag.'</div>';
821
+
822
+ // Google AMPに対応
823
+ if ( (function_exists('is_amp_endpoint') && is_amp_endpoint()) || isset($this->amp) || ( isset($this->options['flg-amp-url']) && ( preg_match('/\/amp\/?$/i', $_SERVER["REQUEST_URI"]) || preg_match('/\?amp=1$/i', $_SERVER["REQUEST_URI"]) ) ) ) {
824
+ // 簡易タグ作成
825
+ $tag = '<table border="1" cellspacing="0" cellpadding="4"><tbody></tr><tr><td>'.$excerpt.'<br>'.$a_op_all.$a_op.$title.$a_cl.$a_cl_all.' - '.$site_name.'</td></tr></tbody></table>';
826
+ } else {
827
+ // HTMLタグ作成
828
+ switch (isset($this->options['info-position']) ? $this->options['info-position'] : null) {
829
+ case '1':
830
+ $tag = $wrap_op.$a_op_all.'<div class="lkc-card">'.$domain_info.'<div class="lkc-content">'.$a_op.$thumbnail.'<div class="lkc-title"><div class="lkc-title-text">'.$title.'</div>'.$a_cl.$sns_title.'</div>'.$url1.'<div class="lkc-excerpt">'.$excerpt.'</div>'.$moretag.'</div><div class="clear"></div></div>'.$a_cl_all.$wrap_cl;
831
+ break;
832
+ case '2':
833
+ $tag = $wrap_op.$a_op_all.'<div class="lkc-card"><div class="lkc-content">'.$a_op.$thumbnail.'<div class="lkc-title"><div class="lkc-title-text">'.$title.'</div>'.$a_cl.$sns_title.'</div>'.$url1.'<div class="lkc-excerpt">'.$excerpt.'</div>'.$moretag.'</div>'.$domain_info.'<div class="clear"></div></div>'.$a_cl_all.$wrap_cl;
834
+ break;
835
+ case '3':
836
+ $tag = $wrap_op.$a_op_all.'<div class="lkc-card"><div class="lkc-content">'.$a_op.$thumbnail.$domain_info.'<div class="lkc-title"><div class="lkc-title-text">'.$title.'</div>'.$a_cl.$sns_title.$url1.'</div><div class="lkc-excerpt">'.$excerpt.'</div>'.$moretag.'</div><div class="clear"></div></div>'.$a_cl_all.$wrap_cl;
837
+ break;
838
+ default:
839
+ $tag = $wrap_op.$a_op_all.'<div class="lkc-card"><div class="lkc-content">'.$a_op.$thumbnail.'<div class="lkc-title"><div class="lkc-title-text">'.$title.'</div>'.$a_cl.$sns_title.'</div>'.$url1.'<div class="lkc-excerpt">'.$excerpt.'</div>'.$moretag.'</div><div class="clear"></div></div>'.$a_cl_all.$wrap_cl;
840
+ }
841
+ }
842
+
843
+ // 引用文扱い
844
+ if (isset($this->options['blockquote']) ? $this->options['blockquote'] : null == '1') {
845
+ $tag = '<div class="'.$class_id.'"><blockquote class="lkc-quote">'.$tag.'</blockquote></div>';
846
+ } else {
847
+ $tag = '<div class="'.$class_id.'">'.$tag.'</div>';
848
+ }
849
+
850
+ return $tag;
851
+ }
852
+
853
+ // URLのエンティティ化など(無害化?)
854
+ function pz_TrimURL($url = null) {
855
+ if (!isset($url) || $url == '') {
856
+ $url = null;
857
+ return $url;
858
+ }
859
+
860
+ $url = html_entity_decode($url);
861
+ if ($this->options['debug-time']) {
862
+ echo '<!-- Pz-LkC [URL1='.$url.'] /-->'.PHP_EOL;
863
+ }
864
+ $url = preg_replace('/^[\s \'\"‘’“”″]*(.*?)[\s \'\"‘’“”″]*$/u', '\1', $url); // 色んな打ち間違え対応
865
+ if ($this->options['debug-time']) {
866
+ echo '<!-- Pz-LkC [URL2='.$url.'] /-->'.PHP_EOL;
867
+ }
868
+ $url = esc_url($url); // プロトコル除外など
869
+ if ($this->options['debug-time']) {
870
+ echo '<!-- Pz-LkC [URL3='.$url.'] /-->'.PHP_EOL;
871
+ }
872
+ switch (isset($this->options['trail-slash']) ? $this->options['trail-slash'] : null) {
873
+ case '1': // URLがドメイン名だけの場合、最後のスラッシュを除外する
874
+ $array_url = parse_url($url);
875
+ if (!isset($array_url['path']) || $array_url['path'] == '/') {
876
+ $url = rtrim($url, '/');
877
+ }
878
+ break;
879
+ case '2': // 常に最後のスラッシュを除外する
880
+ $url = rtrim($url, '/');
881
+ break;
882
+ }
883
+ if ($this->options['debug-time']) {
884
+ echo '<!-- Pz-LkC [URL4='.$url.'] /-->'.PHP_EOL;
885
+ }
886
+
887
+ return $url;
888
+ }
889
+
890
+ // 内部サイト・外部サイトの判断
891
+ function pz_LinkType($url = null) {
892
+ if (substr($url, 0, mb_strlen(home_url() ) ) == home_url() ) {
893
+ if (get_permalink() == $url) {
894
+ $link_type = 1; // 自ページ
895
+ } else {
896
+ $link_type = 2; // 自サイト内
897
+ }
898
+ } else {
899
+ $link_type = 0; // 外部サイト
900
+ }
901
+ // サブディレクトリ型マルチサイト対応
902
+ if ($this->options['flg-subdir'] && is_multisite() && !is_subdomain_install() && is_main_site) {
903
+ $this_blog_id = get_current_blog_id();
904
+ $blog_id = 0;
905
+ do {
906
+ $blog_id++;
907
+ $blog_url = get_site_url($blog_id);
908
+ if ($blog_url && $blog_id <> $this_blog_id && substr($url, 0, mb_strlen($blog_url) ) == $blog_url ) {
909
+ // ドメイン名
910
+ if (preg_match('/https?:\/\/(.*)\//i', $blog_url.'/',$m)) {
911
+ $domain_url = $m[0];
912
+ $domain = $m[1];
913
+ } else {
914
+ $domain_url = null;
915
+ $domain = null;
916
+ }
917
+ $link_type = 0; // 外部サイト
918
+ }
919
+ } while ($blog_url);
920
+ }
921
+ if ($this->options['debug-time']) {
922
+ echo '<!-- Pz-LkC [TYPE='.$link_type.'] /-->'.PHP_EOL;
923
+ }
924
+ return $link_type;
925
+ }
926
+
927
+ // 相対パスをURLにする
928
+ public function pz_RelToURL( $base_url = '', $rel_path = '' ) {
929
+ if (preg_match('/^https?\:\/\//', $rel_path ) ) { // 絶対パスだった場合
930
+ return $rel_path;
931
+ } elseif (substr($rel_path, 0, 2) == '//' ) { // 絶対パスだった場合(スキーム省略)
932
+ return $rel_path;
933
+ }
934
+ $parse = parse_url($base_url );
935
+ if (substr($rel_path, 0, 1) == '/' ) { // ドキュメントルート指定
936
+ return $parse['scheme'].'://'.$parse ['host'].$rel_path;
937
+ }
938
+ return $parse['scheme'].'://'.$parse['host'].dirname($parse['path'] ).'/'.$rel_path;
939
+ }
940
+
941
+ // ソーシャルカウント取得
942
+ public function pz_RenewSNSCount( $data ) {
943
+ if (!isset($this->options['sns-position']) || $this->options['sns-position'] == '') {
944
+ return null;
945
+ }
946
+ if (!isset($data) || !is_array($data)) {
947
+ return null;
948
+ }
949
+
950
+ $data = $this->pz_GetCache($data);
951
+ if (!isset($data) || !is_array($data)) {
952
+ return null;
953
+ }
954
+
955
+ // ソーシャルカウント
956
+ $sns_renew = false;
957
+ $update_cnt = false;
958
+
959
+ // タイムオーバー
960
+ $opt = array( 'timeout' => 30 );
961
+
962
+ // 保存期間満了でソーシャルカウントをリセット
963
+ if ($this->now > $data['sns_nexttime'] && $data['result_code'] <= 200 ) {
964
+ $sns_renew = true;
965
+ }
966
+
967
+ // Twitter count.json 2015/11/21 非公式サービス終了に伴い停止→代替APIへ変更
968
+ if (isset($this->options['sns-tw']) && !is_null($this->options['sns-tw'])) {
969
+ $count_before = isset($data['sns_twitter']) ? $data['sns_twitter'] : -1;
970
+ if ($sns_renew || $count_before < 0) {
971
+ // $result = wp_remote_get( 'http://urls.api.twitter.com/1/urls/count.json?url=' .rawurlencode($data['url']), $opt );
972
+ $result = wp_remote_get( 'https://jsoon.digitiminimi.com/twitter/count.json?url=' .rawurlencode($data['url']), $opt );
973
+ if (isset($result) && !is_wp_error($result) && $result['response']['code'] == 200) {
974
+ $count = intval(json_decode($result['body'])->count);
975
+ if ($count > $count_before) {
976
+ $data['sns_twitter'] = $count;
977
+ $update_cnt = true;
978
+ }
979
+ }
980
+ }
981
+ }
982
+
983
+ if (isset($this->options['sns-fb']) && !is_null($this->options['sns-fb'])) {
984
+ $count_before = intval(isset($data['sns_facebook']) ? $data['sns_facebook'] : -1);
985
+ if ($sns_renew || $count_before < 0) {
986
+ $result = wp_remote_get( 'https://graph.facebook.com/?id=' .rawurlencode($data['url']), $opt );
987
+ if (isset($result) && !is_wp_error($result) && $result['response']['code'] == 200) {
988
+ $json = json_decode($result['body']);
989
+ $count = intval(isset($json->share->share_count) ? $json->share->share_count : 0);
990
+ if ($count > $count_before) {
991
+ $data['sns_facebook'] = $count;
992
+ $update_cnt = true;
993
+ }
994
+ }
995
+ }
996
+ }
997
+
998
+ if (isset($this->options['sns-hb']) && !is_null($this->options['sns-hb'])) {
999
+ $count_before = isset($data['sns_hatena']) ? $data['sns_hatena'] : -1;
1000
+ if ($sns_renew || $count_before < 0) {
1001
+ $result = wp_remote_get( 'http://api.b.st-hatena.com/entry.count?url=' .rawurlencode($data['url']), $opt );
1002
+ if (isset($result) && !is_wp_error($result) && $result['response']['code'] == 200) {
1003
+ $count = intval($result['body']);
1004
+ if ($count > $count_before) {
1005
+ $data['sns_hatena'] = $count;
1006
+ $update_cnt = true;
1007
+ }
1008
+ }
1009
+ }
1010
+ }
1011
+
1012
+ if (isset($this->options['sns-po']) && !is_null($this->options['sns-po'])) {
1013
+ $count_before = isset($data['sns_pocket']) ? $data['sns_pocket'] : -1;
1014
+ if ($sns_renew || $count_before < 0) {
1015
+ $result = wp_remote_get( 'https://widgets.getpocket.com/v1/button?label=pocket&count=vertical&align=left&v=1&src=https&url=' .rawurlencode($data['url']), $opt );
1016
+ if (isset($result) && !is_wp_error($result) && $result['response']['code'] == 200) {
1017
+ preg_match('/<em id="cnt">([0-9]*)<\/em>/', $result['body'], $m);
1018
+ $count = intval($m[1] ? $m[1] : 0);
1019
+ if ($count > $count_before) {
1020
+ $data['sns_pocket'] = $count;
1021
+ $update_cnt = true;
1022
+ }
1023
+ }
1024
+ }
1025
+ }
1026
+
1027
+ // 登録してから一週間までは毎日、それ以降は週一回更新(取得が固まらないようにランダム時間付与)
1028
+ if ($update_cnt || ($this->now - strtotime($data['regist']) < WEEK_IN_SECONDS)) {
1029
+ $sns_nexttime = $this->now + DAY_IN_SECONDS + rand(0, DAY_IN_SECONDS); // 1day + 0-24h
1030
+ } else {
1031
+ $sns_nexttime = $this->now + WEEK_IN_SECONDS + rand(0, DAY_IN_SECONDS); // 7days + 0-24h
1032
+ }
1033
+ // MINUTE_IN_SECONDS = 60
1034
+ // HOUR_IN_SECONDS = 60 * MINUTE_IN_SECONDS = 3600
1035
+ // DAY_IN_SECONDS = 24 * HOUR_IN_SECONDS = 86400
1036
+ // WEEK_IN_SECONDS = 7 * DAY_IN_SECONDS = 604800
1037
+ // YEAR_IN_SECONDS = 365 * DAY_IN_SECONDS
1038
+
1039
+ global $wpdb;
1040
+ $wpdb->update(
1041
+ $this->db_name,
1042
+ array(
1043
+ 'sns_twitter' => $data['sns_twitter'],
1044
+ 'sns_facebook' => $data['sns_facebook'],
1045
+ 'sns_hatena' => $data['sns_hatena'],
1046
+ 'sns_pocket' => $data['sns_pocket'],
1047
+ 'sns_time' => $this->now,
1048
+ 'sns_nexttime' => $sns_nexttime,
1049
+ 'uptime' => $this->now
1050
+ ),
1051
+ array(
1052
+ 'id' => $data['id']
1053
+ )
1054
+ );
1055
+ return $data;
1056
+ }
1057
+
1058
+ // キャッシュデータを取得
1059
+ public function pz_GetCache( $data ) {
1060
+ if (!isset($data) || !is_array($data)) {
1061
+ return null;
1062
+ }
1063
+ global $wpdb;
1064
+ if (!empty($data['url'])) {
1065
+ $url = $data['url'];
1066
+ $data = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->db_name WHERE url=%s", $url));
1067
+ } elseif (isset($data['id']) && !is_null($data['id'])) {
1068
+ $data_id = intval($data['id']);
1069
+ $data = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->db_name WHERE id=%d", $data_id));
1070
+ } else {
1071
+ return null;
1072
+ }
1073
+ if ($wpdb->last_error <> '') { // DBエラーのとき、初期化する
1074
+ $this->activate();
1075
+ }
1076
+ if (is_wp_error($data)) {
1077
+ return null;
1078
+ }
1079
+ return (array) $data; // Arrayに直して返す
1080
+ }
1081
+
1082
+ // キャッシュデータを保存
1083
+ public function pz_SetCache($data) {
1084
+ global $wpdb;
1085
+ if (!isset($data) || !is_array($data)) {
1086
+ return null;
1087
+ }
1088
+ if (!isset($data['url']) || is_null($data['url']) || $data['result_code'] < 100) {
1089
+ return null;
1090
+ }
1091
+ $url = $this->pz_TrimURL($data['url']);
1092
+ $data['url'] = $url;
1093
+ if (!isset($data['url_key']) || is_null($data['url_key']) || $data['url_key'] == '' ) {
1094
+ $data['url_key'] = hash( 'sha256', esc_url( $url ), true);
1095
+ }
1096
+
1097
+ if (!isset($data['regist_result']) || !$data['regist_result']) { // 最初登録時情報
1098
+ $data['regist_title'] = $data['title'];
1099
+ $data['regist_excerpt'] = $data['excerpt'];
1100
+ $data['regist_charset'] = $data['charset'];
1101
+ $data['regist_result'] = $data['result_code'];
1102
+ $data['regist_time'] = $this->now;
1103
+ }
1104
+ $data['uptime'] = $this->now; // 最終更新日時
1105
+
1106
+ // 更新してみる
1107
+ if ( isset($data['id']) ) {
1108
+ $result = $wpdb->update(
1109
+ $this->db_name,
1110
+ $data,
1111
+ array(
1112
+ 'id' => $data['id']
1113
+ )
1114
+ );
1115
+ } else {
1116
+ $result = $wpdb->update(
1117
+ $this->db_name,
1118
+ $data,
1119
+ array(
1120
+ 'url_key' => $data['url_key']
1121
+ )
1122
+ );
1123
+ }
1124
+ if (!$result) {
1125
+ $data['regist'] = $this->now_mysql; // 登録日
1126
+ // 更新できなかったら挿入
1127
+ unset($data['id']);
1128
+ $result = $wpdb->insert(
1129
+ $this->db_name,
1130
+ $data
1131
+ );
1132
+ if (!$result) {
1133
+ // 挿入できなかったら日本語項目を落としてなるべく登録する
1134
+ unset($data['site_name']);
1135
+ $result = $wpdb->insert(
1136
+ $this->db_name,
1137
+ $data
1138
+ );
1139
+ if (!$result) {
1140
+ unset($data['excerpt']);
1141
+ $result = $wpdb->insert(
1142
+ $this->db_name,
1143
+ $data
1144
+ );
1145
+ if (!$result) {
1146
+ unset($data['title']);
1147
+ $result = $wpdb->insert(
1148
+ $this->db_name,
1149
+ $data
1150
+ );
1151
+ if (!$result) {
1152
+ return $data;
1153
+ }
1154
+ }
1155
+ }
1156
+ }
1157
+ }
1158
+ return $this->pz_GetCache($data);
1159
+ }
1160
+
1161
+ // キャッシュデータを削除
1162
+ public function pz_DelCache($data) {
1163
+ global $wpdb;
1164
+ if (!isset($data) || !is_array($data)) {
1165
+ return null;
1166
+ }
1167
+ if (isset($data['id']) && !is_null($data['id'])) {
1168
+ $data_id = intval($data['id']);
1169
+ $result = $wpdb->delete($this->db_name, array('id' => $data_id), array('%d') );
1170
+ return $result;
1171
+ } elseif (isset($data['url']) && !is_null($data['url'])) {
1172
+ $url = $this->pz_TrimURL($data['url']);
1173
+ $result = $wpdb->delete($this->db_name, array('url' => $url), array('%s') );
1174
+ return $result;
1175
+ }
1176
+ return null;
1177
+ }
1178
+
1179
+ // サイト内取得
1180
+ public function pz_GetPost( $data ) {
1181
+ // サイト名取得
1182
+ $site_name = get_bloginfo('name');
1183
+
1184
+ // ドメイン名
1185
+ if (preg_match('/https?:\/\/(.*)\//i', home_url().'/',$m)) {
1186
+ $domain_url = $m[0];
1187
+ $domain = $m[1];
1188
+ } else {
1189
+ $domain_url = null;
1190
+ $domain = null;
1191
+ }
1192
+
1193
+ // サイトアイコン
1194
+ if (function_exists('has_site_icon') && has_site_icon()) {
1195
+ $favicon = get_site_icon_url(16, '', 0);
1196
+ } else {
1197
+ $favicon = null;
1198
+ }
1199
+
1200
+ $title = null;
1201
+ $excerpt = null;
1202
+ $thumbnail = null;
1203
+
1204
+ // 記事内容
1205
+ $url = $data['url'];
1206
+ $post_id = url_to_postid($url ); // 記事IDを取得
1207
+ if ($this->options['debug-time']) {
1208
+ echo '<!-- Pz-LkC [PID='.$post_id.'] /-->'.PHP_EOL;
1209
+ }
1210
+
1211
+ if ( !$post_id && isset($this->options['flg-get-pid']) ? true : false) {
1212
+ $url = $this->Pz_GetRedirURL( $data ); // 本当の記事URLを取得
1213
+ $post_id = url_to_postid($url ); // 記事IDを取得
1214
+ if ($this->options['debug-time']) {
1215
+ echo '<!-- Pz-LkC [PID='.$post_id.'(REDIR)] /-->'.PHP_EOL;
1216
+ }
1217
+ }
1218
+
1219
+ if ( $post_id ) {
1220
+ $result_code = 200; // 外部取得と同じコードをセット
1221
+ $post = get_post($post_id); // 記事情報
1222
+ if ( $this->options['in-get'] == '1') {
1223
+ $title = $post->post_title; // 記事タイトル
1224
+ $excerpt = $post->post_excerpt; // 抜粋文優先
1225
+ if ($excerpt == '') {
1226
+ $excerpt = $post->post_content; // 抜粋文が無かったら記事
1227
+ }
1228
+ } else {
1229
+ $title = $post->post_title; // 記事タイトル
1230
+ $excerpt = $post->post_content; // 記事内容から抜粋
1231
+ }
1232
+ $post_date = $post->post_date;
1233
+ $thumbnail_id = get_post_thumbnail_id( $post_id ); // サムネイル
1234
+ if ($this->options['debug-time']) {
1235
+ echo '<!-- Pz-LkC [TID='.$thumbnail_id.'] /-->'.PHP_EOL;
1236
+ }
1237
+ $attach = wp_get_attachment_image_src( $thumbnail_id, 'thumbnail', true );
1238
+ if (isset($attach) && count($attach) > 3 && isset($attach[0])) {
1239
+ $thumbnail = $attach[0];
1240
+ if (preg_match('/.*(\/\/.*)/', $thumbnail, $m)) { // スキームを外す
1241
+ $thumbnail = $m[1];
1242
+ }
1243
+ }
1244
+ } else {
1245
+ $title = get_bloginfo('name');
1246
+ $excerpt = get_bloginfo('description');
1247
+ $site_name = get_bloginfo('name');
1248
+ $thumbnail = '';
1249
+ $result_code = '404';
1250
+
1251
+ // カテゴリ ページの処理
1252
+ $cat_dir = get_option('category_base');
1253
+ $cat_url = home_url().'/'.($cat_dir ? $cat_dir : 'category').'/';
1254
+ $cat_len = mb_strlen($cat_url );
1255
+ if (substr($url, 0, $cat_len ) == $cat_url ) {
1256
+ $cat_slug = substr($url, $cat_len );
1257
+ $cat_data = get_category_by_slug($cat_slug );
1258
+ $cat_count = ($cat_data->count - 0);
1259
+ $title = __('Category', $this->text_domain ).' '.__('‘', $this->text_domain ).$cat_data->name.__('’', $this->text_domain );
1260
+ $excerpt = __('(', $this->text_domain ).__('Count', $this->text_domain ).':'.($cat_data->count - 0).__(')', $this->text_domain ).' '.$cat_data->description;
1261
+ if (isset($cat_data->slug)) {
1262
+ $result_code = '200';
1263
+ }
1264
+ } else {
1265
+ // タグ ページの処理
1266
+ $cat_dir = get_option('tag_base');
1267
+ $cat_url = home_url().'/'.($cat_dir ? $cat_dir : 'tag').'/';
1268
+ $cat_len = mb_strlen($cat_url );
1269
+ if (substr($url, 0, $cat_len ) == $cat_url ) {
1270
+ $cat_slug = substr($url, $cat_len );
1271
+ $cat_data = get_tags( array( 'slug' => $cat_slug ) );
1272
+ $title = __('Tag', $this->text_domain ).' '.__('‘', $this->text_domain ).$cat_data[0]->name.__('’', $this->text_domain );
1273
+ $excerpt = __('(', $this->text_domain ).__('Count', $this->text_domain ).':'.($cat_data[0]->count - 0).__(')', $this->text_domain ).' '.$cat_data[0]->description;
1274
+ if (isset($cat_data[0]->slug)) {
1275
+ $result_code = '200';
1276
+ }
1277
+ } else {
1278
+ if ( !$post_id && isset($this->options['flg-get-pid']) ? true : false) {
1279
+ $data = $this->Pz_GetCURL($data ); // 外部サイトとして読み込み
1280
+ return $data;
1281
+ }
1282
+ }
1283
+ }
1284
+ }
1285
+
1286
+ // タイトル整形
1287
+ if (isset($title)) {
1288
+ $str = $title;
1289
+ $str = strip_tags($str); // タグの除去
1290
+ $str = str_replace(array("\r", "\n"), '', $str); // 改行削除
1291
+ $str = esc_html($str); // 念のためエスケープ
1292
+ $str = mb_strimwidth($str, 0, 200, '...'); // 保管用のタイトルは200文字で切る
1293
+ $title = $str;
1294
+ }
1295
+
1296
+ // 抜粋文整形
1297
+ if (isset($excerpt)) {
1298
+ $str = $excerpt;
1299
+ $str = strip_tags($str); // タグの除去
1300
+ $str = preg_replace('/<!--more-->.+/is', '', $str); // moreタグ以降削除
1301
+ $str = preg_replace('/\[[^]]*\]/', '', $str); // ショートコードすべて除去
1302
+ $str = str_replace(array("\r", "\n"), '', $str); // 改行削除
1303
+ $str = esc_html($str); // 念のためエスケープ
1304
+ $str = mb_strimwidth($str, 0, 500, '...'); // 保管用の記事内容は500文字で切る
1305
+ $excerpt = $str;
1306
+ }
1307
+
1308
+ // URLパース(ドメイン名などを抽出)
1309
+ $url_m = parse_url( $url );
1310
+ $scheme = $url_m['scheme']; // スキーム
1311
+ //$domain = $url_m['host']; // ドメイン名
1312
+ //$domain_url = $scheme.'://'.$url_m['host']; // ドメインURL
1313
+ $location = substr($url, mb_strlen($domain_url)); // ドメイン名以降
1314
+
1315
+ // データセット
1316
+ if (isset($data['title']) && $data['title'] == $title ) {
1317
+ $before['mod_title'] = 0;
1318
+ } else {
1319
+ $before['mod_title'] = 1;
1320
+ }
1321
+ if (isset($data['excerpt']) && $data['excerpt'] == $excerpt ) {
1322
+ $before['mod_excerpt'] = 0;
1323
+ } else {
1324
+ $before['mod_excerpt'] = 1;
1325
+ }
1326
+ if (!isset($data['use_post_id1'])) {
1327
+ $data['use_post_id1'] = get_the_ID();
1328
+ }
1329
+ $data['scheme'] = $scheme;
1330
+ $data['domain'] = $domain;
1331
+ $data['location'] = $location;
1332
+ $data['site_name'] = $site_name;
1333
+ $data['title'] = $title;
1334
+ $data['excerpt'] = $excerpt;
1335
+ $data['post_date'] = $post_date;
1336
+ $data['thumbnail'] = $thumbnail;
1337
+ $data['favicon'] = $favicon;
1338
+ $data['charset'] = 'UTF-8';
1339
+ $data['result_code'] = $result_code;
1340
+ $data['alive_result'] = $result_code;
1341
+ $data['favicon'] = $favicon;
1342
+
1343
+ return $data;
1344
+ }
1345
+
1346
+ // リダイレクト先URL取得
1347
+ public function pz_GetRedirURL( $data ) {
1348
+ $url = $data['url'];
1349
+ if ( function_exists( 'curl_init' ) ) { // cURLを使用する
1350
+ $result_code = 0;
1351
+ $ch = curl_init($url);
1352
+ curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); // データで取得
1353
+ curl_setopt( $ch, CURLOPT_NOBODY, true ); // ヘッダのみ取得
1354
+ curl_setopt( $ch, CURLOPT_TIMEOUT, 120 ); // タイムアウト
1355
+ curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true ); // リダイレクトを処理する
1356
+ curl_setopt( $ch, CURLOPT_MAXREDIRS, 5 ); // リダイレクトを処理する階層
1357
+ $html = curl_exec($ch);
1358
+ $errno = intval( curl_errno( $ch ) ); // cURL実行
1359
+ if ( $errno ) {
1360
+ $result_code = $errno;
1361
+ $error = true;
1362
+ } else {
1363
+ $header = curl_getinfo($ch);
1364
+ $result_code = $header['http_code']; // HTTPステータス
1365
+ $error = false;
1366
+ $url = $header['url'];
1367
+ }
1368
+ curl_close($ch);
1369
+ }
1370
+ return $url;
1371
+ }
1372
+
1373
+ // 外部サイト取得
1374
+ public function pz_GetCURL( $data ) {
1375
+ $url = $this->pz_TrimURL( $data['url'] );
1376
+ if (!isset( $url ) || $url == '') {
1377
+ return null;
1378
+ }
1379
+
1380
+ // リンク先サイト取得
1381
+ $html = null;
1382
+ $error = true;
1383
+
1384
+ $domain = null;
1385
+ $site_name = null;
1386
+ $title = null;
1387
+ $excerpt = null;
1388
+ $charset = null;
1389
+ $result_code = null;
1390
+
1391
+ // URLパース(ドメイン名などを抽出)
1392
+ $url_m = parse_url( $url );
1393
+ $scheme = $url_m['scheme']; // スキーム
1394
+ $domain = $url_m['host']; // ドメイン名
1395
+ $domain_url = $scheme.'://'.$url_m['host']; // ドメインURL
1396
+ $location = substr($url, mb_strlen($domain_url)); // ドメイン名以降
1397
+
1398
+ if ( function_exists( 'curl_init' ) ) { // cURLを使用する
1399
+ $result_code = 0;
1400
+ $ch = curl_init($url);
1401
+ curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); // データで取得
1402
+ curl_setopt( $ch, CURLOPT_TIMEOUT, 8 ); // タイムアウト
1403
+ if (isset($this->options['flg-referer']) ? true : false) {
1404
+ curl_setopt( $ch, CURLOPT_REFERER, get_permalink() ); // リファラ
1405
+ }
1406
+ if (isset($this->options['flg-agent']) ? true : false) {
1407
+ curl_setopt( $ch, CURLOPT_USERAGENT, $this->options['user-agent'] ); // ユーザーエージェントにPz-LinkCard-Crawlerを使う
1408
+ } else {
1409
+ curl_setopt( $ch, CURLOPT_USERAGENT, esc_html( $_SERVER['HTTP_USER_AGENT'] ) ); // アクセス者のユーザーエージェントを使う
1410
+ }
1411
+ if (isset($this->options['flg-redir']) ? true : false) {
1412
+ curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true ); // リダイレクトを処理する
1413
+ curl_setopt( $ch, CURLOPT_MAXREDIRS, 8 ); // リダイレクトを処理する階層
1414
+ curl_setopt( $ch, CURLOPT_AUTOREFERER, true ); // リダイレクト用リファラを自動セット
1415
+ } else {
1416
+ curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, false ); // リダイレクトを処理しない
1417
+ }
1418
+ curl_setopt( $ch, CURLOPT_COOKIESESSION, true ); // セッションCOOKIEを使用する
1419
+ curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, (isset($this->options['flg-ssl']) ? false : true) ); // SSL検証
1420
+ $html = curl_exec($ch);
1421
+ $errno = intval( curl_errno( $ch ) ); // cURL実行
1422
+ if ( $errno ) {
1423
+ $html = ''; // cURLエラー
1424
+ $result_code = $errno;
1425
+ $error = true;
1426
+ } else {
1427
+ $header = curl_getinfo($ch);
1428
+ $result_code = $header['http_code']; // HTTPステータス
1429
+ $error = false;
1430
+ }
1431
+ curl_close($ch);
1432
+ } else { // cURLが使用できない場合
1433
+ $result = wp_remote_get( $url ); //wp_remote_get実行
1434
+ if ( is_wp_error( $result ) ) {
1435
+ $html = '';
1436
+ $result_code = -1; // wp_remote_getエラー
1437
+ $error = true;
1438
+ } else {
1439
+ $html = $result['body'];
1440
+ $result_code = $result['response']['code']; // HTTPステータス
1441
+ $error = false;
1442
+ }
1443
+ }
1444
+
1445
+ // 文字コード判定
1446
+ $charset = null;
1447
+ if ($html <> '') {
1448
+ if (preg_match('/charset\s*=\s*"*([^>\/\s"]*).*<\/head/si', $html, $m)) {
1449
+ $m[1] = trim(trim($m[1]), '\'\"');
1450
+ $charset = $m[1];
1451
+ } else {
1452
+ foreach(array('UTF-8','SJIS','EUC-JP','eucJP-win','ASCII','JIS','SJIS-win') as $c_charset) {
1453
+ // 文字コード変換してみて内容が変わらないものを文字セットと判断する
1454
+ if (mb_convert_encoding($html, $this->charset, $c_charset) == $html) {
1455
+ $charset = $c_charset;
1456
+ break;
1457
+ }
1458
+ }
1459
+ }
1460
+ if (is_null($charset)) {
1461
+ $charset = mb_detect_encoding($html, 'ASCII,JIS,UTF-7,EUC-JP,SJIS,UTF-8');
1462
+ $html = mb_convert_encoding($html, $this->charset, 'ASCII,JIS,UTF-7,EUC-JP,SJIS,UTF-8');
1463
+ } elseif ($this->charset <> $charset) {
1464
+ $html = mb_convert_encoding($html, $this->charset, $charset);
1465
+ }
1466
+
1467
+ // HEADタグ(METAタグ解析)
1468
+ $head = null;
1469
+ $tags = null;
1470
+ if (preg_match('/<\s*head[^>]*>(.*)<\s*\/head\s*>/si', $html, $m)) {
1471
+ $head = $m[1];
1472
+ $tags = $this->pz_GetMeta($head);
1473
+ }
1474
+
1475
+ // タイトル
1476
+ if (isset( $tags['og:title'] ) && $tags['og:title'] ) {
1477
+ $title = $tags['og:title'] ;
1478
+ } elseif (isset( $tags['twitter:title'] ) && $tags['twitter:title'] ) {
1479
+ $title = $tags['twitter:title'] ;
1480
+ } elseif (isset( $tags['title'] ) && $tags['title'] ) {
1481
+ $title = $tags['title'] ;
1482
+ }
1483
+
1484
+ // 抜粋文・概要文
1485
+ if (isset( $tags['og:description'] ) && $tags['og:description'] ) {
1486
+ $excerpt = $tags['og:description'] ;
1487
+ } elseif (isset( $tags['twitter:description'] ) && $tags['twitter:description'] ) {
1488
+ $excerpt = $tags['twitter:description'] ;
1489
+ } elseif (isset( $tags['description'] ) && $tags['description'] ) {
1490
+ $excerpt = $tags['description'] ;
1491
+ }
1492
+
1493
+ // OGPから画像URL取得
1494
+ if (isset( $tags['og:image'] ) && $tags['og:image'] ) {
1495
+ $thumbnail_url = $tags['og:image'] ;
1496
+ } elseif (isset( $tags['twitter:image'] ) && $tags['twitter:image'] ) {
1497
+ $thumbnail_url = $tags['twitter:image'] ;
1498
+ } else {
1499
+ $thumbnail_url = '';
1500
+ }
1501
+ if ($thumbnail_url && !preg_match('/^https*:\/\//', $thumbnail_url, $m) ) {
1502
+ $thumbnail_url = $this->pz_RelToURL($url, $thumbnail_url);
1503
+ }
1504
+
1505
+ // OGPからサイトアイコンURL取得
1506
+ if (isset( $tags['icon'] ) && $tags['icon'] ) {
1507
+ $favicon_url = $tags['icon'] ;
1508
+ } elseif (isset( $tags['shortcut icon'] ) && $tags['shortcut icon'] ) {
1509
+ $favicon_url = $tags['shortcut icon'] ;
1510
+ } elseif (isset( $tags['apple-touch-icon'] ) && $tags['apple-touch-icon']) {
1511
+ $favicon_url = $tags['apple-touch-icon'] ;
1512
+ } else {
1513
+ $favicon_url = '';
1514
+ }
1515
+ if ($favicon_url && !preg_match('/^https*:\/\//', $favicon_url, $m) ) {
1516
+ $favicon_url = $this->pz_RelToURL($url, $favicon_url);
1517
+ }
1518
+
1519
+ // サイト名
1520
+ if (isset( $tags['og:site_name'] ) && $tags['og:site_name'] ) {
1521
+ $site_name = $tags['og:site_name'] ;
1522
+ }
1523
+
1524
+ // タイトル整形
1525
+ if (isset($title)) {
1526
+ $str = $title;
1527
+ $str = strip_tags($str); // タグの除去
1528
+ $str = str_replace(array("\r", "\n"), '', $str); // 改行削除
1529
+ $str = esc_html($str); // 念のためエスケープ
1530
+ $str = mb_strimwidth($str, 0, 200, '...'); // 保管用のタイトルは200文字で切る
1531
+ $title = $str;
1532
+ }
1533
+
1534
+ // 抜粋文整形
1535
+ if (isset($excerpt)) {
1536
+ $str = $excerpt;
1537
+ $str = strip_tags($str); // タグの除去
1538
+ $str = str_replace(array("\r", "\n"), '', $str); // 改行削除
1539
+ $str = esc_html($str); // 念のためエスケープ
1540
+ $str = mb_strimwidth($str, 0, 500, '...'); // 保管用の記事内容は500文字で切る
1541
+ $excerpt = $str;
1542
+ }
1543
+
1544
+ // データセット
1545
+ if (isset($data_id) && !is_null($data_id)) {
1546
+ $data['id'] = $data_id;
1547
+ }
1548
+ if (isset($url_key) && !is_null($url_key)) {
1549
+ $data['url_key'] = $url_key;
1550
+ }
1551
+ $data['site_name'] = $site_name;
1552
+ $data['title'] = $title;
1553
+ $data['excerpt'] = $excerpt;
1554
+ $data['mod_title'] = 0;
1555
+ $data['mod_excerpt'] = 0;
1556
+ $data['charset'] = $charset;
1557
+ // if (isset($atts['force']) && $atts['force'] == true) {
1558
+ // $data['regist'] = $this->now_mysql; // 登録日
1559
+ // }
1560
+ }
1561
+ $data['url'] = $url;
1562
+ $data['thumbnail'] = ( isset($thumbnail_url) ? $thumbnail_url : null );
1563
+ $data['result_code'] = $result_code;
1564
+ $data['alive_result'] = $result_code;
1565
+ $data['scheme'] = $scheme;
1566
+ $data['domain'] = $domain;
1567
+ $data['location'] = $location;
1568
+ $data['favicon'] = ( isset($favicon_url) ? $favicon_url : null );
1569
+ if (!isset($data['use_post_id1']) || !$data['use_post_id1']) {
1570
+ $data['use_post_id1'] = get_the_ID();
1571
+ }
1572
+ $data['sns_twitter'] = (isset( $data['sns_twitter'] ) ? $data['sns_twitter'] : -1 );
1573
+ $data['sns_facebook'] = (isset( $data['sns_facebook'] ) ? $data['sns_facebook'] : -1 );
1574
+ $data['sns_hatena'] = (isset( $data['sns_hatena'] ) ? $data['sns_hatena'] : -1 );
1575
+ $data['sns_nexttime'] = (isset( $data['sns_nexttime'] ) ? $data['sns_nexttime'] : 0 );
1576
+ $data['uptime'] = $this->now;
1577
+ $data['alive_time'] = $this->now;
1578
+ $data['alive_result'] = $result_code;
1579
+ return $data;
1580
+ }
1581
+
1582
+ // TITLEとMETAタグを分解
1583
+ function pz_GetMeta( $html, $tags = null, $clear = false ) {
1584
+ if ($clear == true || !isset($tags)) {
1585
+ $tags = null;
1586
+ $tags = array('none' => 'none');
1587
+ }
1588
+
1589
+ // TITLEタグ
1590
+ if (preg_match('/<\s*title\s*[^>]*>\s*([^<]*)\s*<\s*\/title\s*[^>]*>/si', $html, $m)) {
1591
+ $tags['title'] = esc_html($m[1]);
1592
+ }
1593
+
1594
+ // metaタグ パース
1595
+ $match = null;
1596
+ preg_match_all('/<\s*meta\s(?=[^>]*?\b(?:name|property)\s*=\s*(?|"\s*([^"]*?)\s*"|\'\s*([^\']*?)\s*\'|([^"\'>]*?)(?=\s*\/?\s*>|\s\w+\s*=)))[^>]*?\bcontent\s*=\s*(?|"\s*([^"]*?)\s*"|\'\s*([^\']*?)\s*\'|([^"\'>]*?)(?=\s*\/?\s*>|\s\w+\s*=))[^>]*>/is', $html, $match);
1597
+ if (isset($match) && is_array($match) && count($match) == 3 && count($match[1]) > 0) {
1598
+ foreach ($match[1] as &$m) {
1599
+ $m = strtolower($m);
1600
+ }
1601
+ unset($m);
1602
+ $tags += array_combine($match[1], $match[2]);
1603
+ }
1604
+
1605
+ // linkタグ パース
1606
+ $match = null;
1607
+ preg_match_all('/<\s*link\s(?=[^>]*?\brel\s*=\s*(?|"\s*([^"]*?)\s*"|\'\s*([^\']*?)\s*\'|([^"\'>]*?)(?=\s*\/?\s*>|\s\w+\s*=)))[^>]*?\bhref\s*=\s*(?|"\s*([^"]*?)\s*"|\'\s*([^\']*?)\s*\'|([^"\'>]*?)(?=\s*\/?\s*>|\s\w+\s*=))[^>]*>/is', $html, $match);
1608
+ if (isset($match) && is_array($match) && count($match) == 3 && count($match[1]) > 0) {
1609
+ foreach ($match[1] as &$m) {
1610
+ $m = strtolower($m);
1611
+ }
1612
+ unset($m);
1613
+ $tags += array_combine($match[1], $match[2]);
1614
+ }
1615
+
1616
+ return $tags;
1617
+ }
1618
+
1619
+ // サムネイル取得(外部リンクOGP画像取得)
1620
+ public function pz_GetThumbnail( $url, $force = false ) {
1621
+ if (!isset($url) || $url == '' || $url == 'https://s0.wp.com/i/blank.jpg') {
1622
+ return null;
1623
+ }
1624
+
1625
+ $file_dir = $this->options['thumbnail-dir']; // サムネイルのディレクトリ
1626
+ if (!is_dir($file_dir)) {
1627
+ return null;
1628
+ }
1629
+
1630
+ $file_name = bin2hex(hash('sha256', esc_url( $url ), true)); // URLをハッシュしてファイル名を生成する
1631
+ $file_path = $file_dir.$file_name; // ファイルのフルパス
1632
+ $file_url = $this->options['thumbnail-url'].$file_name; // 画像URL
1633
+
1634
+ if (!$force && file_exists($file_path )) { // 既にあれば画像URLを返す
1635
+ return $file_url;
1636
+ }
1637
+
1638
+ list($width, $height) = @getimagesize($url); // サイズを取得
1639
+ if (!isset($width) || !isset($height) || $width < 8 || $height < 8) { // 8x8未満は画像ではないと見なす
1640
+ return null;
1641
+ }
1642
+ $image = imagecreatefromstring( file_get_contents($url) ); // 画像読み込み
1643
+
1644
+ $new_width = 200; // 幅200px
1645
+ $new_height = 200; // 高さ200px
1646
+ if ($width <> $height) { // 正方形でない
1647
+ if ($width > $height) { // 幅の方が大きい
1648
+ $new_height = $height * ( $new_width / $width ); // 幅に合わせる
1649
+ } else { // 高さの方が大きい
1650
+ $new_width = $width * ( $new_height / $height ); // 高さに合わせる
1651
+ }
1652
+ }
1653
+ $image_p = imagecreatetruecolor($new_width, $new_height); // パレットを用意
1654
+ imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); // サイズ変更してコピー
1655
+ imagejpeg($image_p, $file_path); // JPEGで保存
1656
+ return $file_url; // 画像URLを返す
1657
+ }
1658
+
1659
+ // 管理画面時のスタイルシート、スクリプト設定
1660
+ public function enqueue_admin($hook) {
1661
+ wp_enqueue_script ('pz-lkc-admin', plugins_url('js/admin.js', __FILE__), array('jquery'), false, true);
1662
+ wp_enqueue_style ('wp-color-picker');
1663
+ wp_enqueue_script ('colorpicker-script', plugins_url('js/color-picker.js', __FILE__), array('wp-color-picker'), false, true);
1664
+ // wp_enqueue_media();
1665
+ // wp_enqueue_script ('media-uploader', plugins_url("media-uploader.js", __FILE__), array('jquery'), false, false);
1666
+ wp_enqueue_style('pz-lkc-admin', plugin_dir_url (__FILE__).'css/admin.css');
1667
+ }
1668
+
1669
+ // 管理画面時のスタイルシート、スクリプト設定
1670
+ public function add_footer() {
1671
+ if ($this->options['flg-edit-qtag']) {
1672
+ if (wp_script_is('quicktags') ) {
1673
+ echo '<script>QTags.addButton(\'pz-lkc\',\''.__('Linkcard', $this->text_domain ).'\',\'['.$this->options['code1'].' url="\',\'"]\',\'\',\''.__('Make Linkcard', $this->text_domain ).'\');</script>';
1674
+ }
1675
+ }
1676
+ require_once ('lib/pz-linkcard-modal.php');
1677
+ }
1678
+
1679
+ // 管理画面時の注意書き設定
1680
+ public function add_notices() {
1681
+ if ($this->options['flg-invalid']) {
1682
+ echo '<div class="error fade is-dismissible"><p><strong>'.$this->slug.': '.__('Invalid URL parameter in ', $this->text_domain).'<a href="'.$this->options['invalid-url'].'" target="_blank">'.$this->options['invalid-url'].'</a></strong><br>'.__('*', $this->text_domain).' '.__('You can cancel this message from <a href="./options-general.php?page=pz-linkcard-settings">the setting screen</a>.', $this->text_domain).'</p></div>';
1683
+ }
1684
+ }
1685
+
1686
+ // 管理画面時のスタイルシート、スクリプト設定
1687
+ public function add_mce_button($buttons) {
1688
+ if ($this->options['flg-edit-insert']) {
1689
+ $buttons[] = 'pz_linkcard';
1690
+ }
1691
+ return $buttons;
1692
+ }
1693
+ public function add_mce_plugin($plugins) {
1694
+ if ($this->options['flg-edit-insert']) {
1695
+ $plugins['pz_linkcard'] = $this->plugin_dir_url.'js/mce.js';
1696
+ }
1697
+ return $plugins;
1698
+ }
1699
+
1700
+ // 通常時のスタイルシート
1701
+ public function enqueue($hook) {
1702
+ $this->amp = null;
1703
+
1704
+ $css_path = $this->upload_dir_path.'style.css';
1705
+ $css_url = $this->upload_dir_url .'style.css';
1706
+ if (!file_exists($css_path )) {
1707
+ $css_url = $this->plugin_dir_url .'style.css';
1708
+ }
1709
+ if (preg_match('/.*(\/\/.*)/', $css_url, $m)) { // スキームを外す
1710
+ $css_url = $m[1];
1711
+ }
1712
+ wp_enqueue_style ('pz-linkcard', $css_url);
1713
+ //if (!isset($this->options['style'])) {
1714
+ // wp_enqueue_style ('pz-linkcard', $this->options['css-url']);
1715
+ //} else {
1716
+ // if (isset($this->options['css-file'])) {
1717
+ // wp_enqueue_style('pz-linkcard', $this->options['css-file']);
1718
+ // }
1719
+ //}
1720
+ }
1721
+
1722
+ // 管理画面のサブメニュー追加
1723
+ public function add_menu() {
1724
+ $menu_manager = __('Pz LkC Cache', $this->text_domain);
1725
+ $menu_settings = __('Pz LinkCard', $this->text_domain);
1726
+ if ($this->options['flg-alive'] && $this->options['flg-alive-count']) {
1727
+ global $wpdb;
1728
+ $result = $wpdb->get_row("SELECT COUNT(*) AS count FROM $this->db_name WHERE alive_result = '404'");
1729
+ if (isset($result) && isset($result->count)) {
1730
+ $menu_manager .= '&nbsp;<span class="update-plugins"><span class="update-count lkc-menu-count">'.$result->count.'</span></span>';
1731
+ }
1732
+ }
1733
+ add_management_page (__('LinkCard cache manager', $this->text_domain), $menu_manager, 'manage_options', 'pz-linkcard-cache', array($this, 'page_cacheman') );
1734
+ add_options_page (__('LinkCard Settings', $this->text_domain), $menu_settings, 'manage_options', 'pz-linkcard-settings', array($this, 'page_settings') );
1735
+ }
1736
+
1737
+ // WP-CRONスケジュール(SNSカウント取得)
1738
+ public function schedule_hook_check() {
1739
+ if (!isset($this->options['sns-position']) || $this->options['sns-position'] == '') {
1740
+ return null;
1741
+ }
1742
+
1743
+ global $wpdb;
1744
+ $result = (array) $wpdb->get_results($wpdb->prepare("SELECT url,sns_nexttime FROM $this->db_name WHERE sns_nexttime<%d ORDER BY sns_nexttime ASC", $this->now));
1745
+ $i = 0;
1746
+ if (isset($result) && is_array($result) && count($result) > 0) {
1747
+ foreach($result as $data) {
1748
+ $i++;
1749
+ if ($i > 10) {
1750
+ wp_schedule_single_event(time() + 30, 'pz_linkcard_check');
1751
+ break;
1752
+ }
1753
+ if (isset($data) && isset($data->url)) {
1754
+ $data = $this->pz_RenewSNSCount(array('url' => $data->url) );
1755
+ }
1756
+ }
1757
+ }
1758
+ }
1759
+
1760
+ // WP-CRONスケジュール(存在チェック)
1761
+ public function schedule_hook_alive() {
1762
+ if (!isset($this->options['flg-alive']) || $this->options['flg-alive'] == '') {
1763
+ return null;
1764
+ }
1765
+
1766
+ global $wpdb;
1767
+ $result = (array) $wpdb->get_results($wpdb->prepare("SELECT url,alive_time FROM $this->db_name WHERE alive_nexttime<%d ORDER BY alive_time ASC, id ASC", $this->now - WEEK_IN_SECONDS ));
1768
+ $i = 0;
1769
+ if (isset($result) && is_array($result) && count($result) > 0) {
1770
+ foreach($result as $data) {
1771
+ $i++;
1772
+ if ($i > 5) {
1773
+ wp_schedule_single_event(time() + 3600, 'pz_linkcard_alive');
1774
+ break;
1775
+ }
1776
+ if (isset($data) && isset($data->url)) {
1777
+ $before = $this->pz_GetCache( array( 'url' => $data->url ) );
1778
+ $after = $this->pz_GetCURL( $before );
1779
+ if ($before['title'] == $after['title'] ) {
1780
+ $before['mod_title'] = 0;
1781
+ } else {
1782
+ $before['mod_title'] = 1;
1783
+ }
1784
+ if ($before['excerpt'] == $after['excerpt'] ) {
1785
+ $before['mod_excerpt'] = 0;
1786
+ } else {
1787
+ $before['mod_excerpt'] = 1;
1788
+ }
1789
+ $before['alive_result'] = $after['result_code'];
1790
+ $before['alive_time'] = $this->now;
1791
+ $before['alive_nexttime'] = $this->now + WEEK_IN_SECONDS * 4 + rand(0, DAY_IN_SECONDS);
1792
+ $before['thumbnail'] = $after['thumbnail'];
1793
+ $before['favicon'] = $after['favicon'];
1794
+ $before = $this->pz_SetCache( $before );
1795
+ }
1796
+ }
1797
+ }
1798
+ }
1799
+
1800
+ // スタイルシート生成
1801
+ public function pz_SetStyle() {
1802
+ require_once ('lib/pz-linkcard-style.php');
1803
+ }
1804
+
1805
+ // Pz カード管理 キャッシュ・マネージャ
1806
+ public function page_cacheman() {
1807
+ require_once ('lib/pz-linkcard-cacheman.php');
1808
+ }
1809
+
1810
+ // Pz カード 設定画面
1811
+ public function page_settings() {
1812
+ require_once ('lib/pz-linkcard-settings.php');
1813
+ }
1814
+
1815
+ // プラグイン一覧のクイックメニュー
1816
+ public function action_links($links) {
1817
+ $links = array('<a href="options-general.php?page=pz-linkcard-settings">'.__('Settings', $this->text_domain).'</a>' , '<a href="tools.php?page=pz-linkcard-cache">'.__('Manage', $this->text_domain).'</a>' ) + $links;
1818
+ return $links;
1819
+ }
1820
+
1821
+ // プラグイン有効化
1822
+ public function activate() {
1823
+ require_once ('lib/pz-linkcard-init.php');
1824
+ }
1825
+
1826
+ // プラグイン停止
1827
+ public function deactivate() {
1828
+ wp_clear_scheduled_hook('pz_linkcard_check');
1829
+ wp_clear_scheduled_hook('pz_linkcard_alive');
1830
+ }
1831
+
1832
+ }
1833
+ $Class_Pz_LinkCard = new Pz_LinkCard;
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: poporon
3
  Tags: post, internal link, external link, blogcard, linkcard
4
  Requires at least: 4.3
5
- Tested up to: 5.2.2
6
  Stable tag: trunk
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -163,6 +163,12 @@ A7.
163
  5. "Write shortcode and url"
164
 
165
  == Changelog ==
 
 
 
 
 
 
166
  Ver2.3.0
167
  * プラグインなどのインストール状況によって設定画面のタブが動作しない不具合の修正をしました。
168
  Fixed: Fixed a bug that the tab of the setting screen does not respond.
2
  Contributors: poporon
3
  Tags: post, internal link, external link, blogcard, linkcard
4
  Requires at least: 4.3
5
+ Tested up to: 5.3
6
  Stable tag: trunk
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
163
  5. "Write shortcode and url"
164
 
165
  == Changelog ==
166
+ Ver2.3.1
167
+ * WordPress 5.3 での動作確認。
168
+ Compatible with WordPress 5.3.
169
+ * ビジュアル エディタのボタンが表示されない不具合の修正をしました。
170
+ Fixed a bug that the button of the visual editor is not displayed.
171
+
172
  Ver2.3.0
173
  * プラグインなどのインストール状況によって設定画面のタブが動作しない不具合の修正をしました。
174
  Fixed: Fixed a bug that the tab of the setting screen does not respond.
templete/pz-linkcard-templete.css CHANGED
@@ -1,284 +1,290 @@
1
- /* [Pz-LkC][/*VERSION*/] CSS */
2
- .linkcard {
3
- /*MARGIN-TOP*/
4
- /*MARGIN-BOTTOM*/
5
- /*MARGIN-LEFT*/
6
- /*MARGIN-RIGHT*/
7
- }
8
- .linkcard img {
9
- /*RESET-IMG*/
10
- }
11
- .linkcard span.external-icon {
12
- display: none;
13
- }
14
- .linkcard p {
15
- display: none;
16
- }
17
- .lkc-link {
18
- /*ANKER*/
19
- }
20
- .lkc-external-wrap {
21
- /*EX-BORDER*/
22
- /*EX-BGCOLOR*/
23
- /*EX-IMAGE*/
24
- }
25
- .lkc-internal-wrap {
26
- /*IN-BORDER*/
27
- /*IN-BGCOLOR*/
28
- /*IN-IMAGE*/
29
- }
30
- .lkc-this-wrap {
31
- /*TH-BORDER*/
32
- /*TH-BGCOLOR*/
33
- /*TH-IMAGE*/
34
- }
35
- .lkc-external-wrap , .lkc-internal-wrap , .lkc-this-wrap {
36
- position: relative;
37
- /*WRAP-MARGIN*/
38
- /*PADDING*/
39
- /*RADIUS*/
40
- /*SHADOW*/
41
- /*HEIGHT*/
42
- /*WIDTH*/
43
- /*WRAP*/
44
- /*NOHOVER*/
45
- }
46
- .lkc-external-wrap::before , .lkc-internal-wrap::before , .lkc-this-wrap::before {
47
- /*WRAP-BEFORE*/
48
- }
49
- .lkc-external-wrap::after , .lkc-internal-wrap::after , .lkc-this-wrap::after {
50
- /*WRAP-AFTER*/
51
- }
52
- .lkc-external-wrap:hover , .lkc-internal-wrap:hover , .lkc-this-wrap:hover {
53
- /*HOVER*/
54
- }
55
- .lkc-external-wrap:hover::before , .lkc-internal-wrap:hover::before , .lkc-this-wrap:hover::before {
56
- /*HOVER-BEFORE*/
57
- }
58
- .lkc-external-wrap:hover::after , .lkc-internal-wrap:hover::after , .lkc-this-wrap:hover::after {
59
- /*HOVER-AFTER*/
60
- }
61
- .lkc-card {
62
- /*CARD-TOP*/
63
- /*CARD-RIGHT*/
64
- /*CARD-BOTTOM*/
65
- /*CARD-LEFT*/
66
- }
67
- .lkc-content {
68
- /*CONTENT-PADDING*/
69
- /*CONTENT-INSET*/
70
- /*CONTENT-BGCOLOR*/
71
- /*CONTENT-HEIGHT*/
72
- /*CONTENT-MARGIN*/
73
- word-break: break-all;
74
- white-space: normal;
75
- overflow: hidden;
76
- /*SEPARATOR*/
77
- }
78
- .lkc-title-text {
79
- /*MARGIN-TITLE*/
80
- /*COLOR-TITLE*/
81
- /*OUTCOLOR-TITLE*/
82
- /*SIZE-TITLE*/
83
- /*HEIGHT-TITLE*/
84
- font-weight: bold;
85
- overflow: hidden;
86
- word-break: break-all;
87
- /*ELLIPSIS-TITLE*/
88
- }
89
- .lkc-title-text:hover {
90
- text-decoration: underline;
91
- }
92
- .lkc-url {
93
- /*MARGIN-URL*/
94
- /*COLOR-URL*/
95
- /*OUTCOLOR-URL*/
96
- /*SIZE-URL*/
97
- /*HEIGHT-URL*/
98
- font-weight: normal;
99
- text-decoration: underline;
100
- overflow: hidden;
101
- display: block;
102
- /*NOWRAP-URL*/
103
- }
104
- .lkc-url-info {
105
- /*COLOR-URL*/
106
- /*OUTCOLOR-URL*/
107
- /*SIZE-URL*/
108
- /*HEIGHT-URL*/
109
- font-weight: normal;
110
- text-decoration: underline;
111
- white-space: nowrap;
112
- overflow: hidden;
113
- text-overflow: ellipsis;
114
- display: inline;
115
- }
116
- .lkc-excerpt {
117
- /*MARGIN-EXCERPT*/
118
- /*COLOR-EXCERPT*/
119
- /*OUTCOLOR-EXCERPT*/
120
- /*SIZE-EXCERPT*/
121
- /*HEIGHT-EXCERPT*/
122
- padding: 0;
123
- overflow: hidden;
124
- /*NONE-EXCERPT*/
125
- }
126
- .lkc-more-text {
127
- display: inline;
128
- /*COLOR-MORE*/
129
- /*OUTCOLOR-MORE*/
130
- /*SIZE-MORE*/
131
- /*HEIGHT-MORE*/
132
- /*STYLE-MORE*/
133
- }
134
- .lkc-thumbnail {
135
- /*THUMBNAIL-WIDTH*/
136
- /*THUMBNAIL-HEIGHT*/
137
- padding: 0;
138
- /*THUMBNAIL-MARGIN*/
139
- /*THUMBNAIL-POSITION*/
140
- }
141
- .lkc-thumbnail-img {
142
- /*THUMBNAIL-IMG-WIDTH*/
143
- /*THUMBNAIL-IMG-HEIGHT*/
144
- border: 1px solid #222;
145
- /*THUMBNAIL-RADIUS*/
146
- /*THUMBNAIL-SHADOW*/
147
- }
148
- .lkc-info {
149
- /*POSITION-INFO*/
150
- padding: 0;
151
- /*COLOR-INFO*/
152
- /*OUTCOLOR-INFO*/
153
- /*SIZE-INFO*/
154
- /*HEIGHT-INFO*/
155
- white-space: nowrap;
156
- overflow: hidden;
157
- display: block /*IMPORTANT*/;
158
- /*NONE-INFO*/
159
- }
160
- .lkc-favicon {
161
- height: 16px;
162
- width: 16px;
163
- margin: 0 4px /*IMPORTANT*/;
164
- border: none;
165
- vertical-align: bottom;
166
- display: inline /*IMPORTANT*/;
167
- }
168
- .lkc-domain {
169
- margin: 0 0 0 6px;
170
- /*COLOR-INFO*/
171
- /*OUTCOLOR-INFO*/
172
- /*SIZE-INFO*/
173
- /*HEIGHT-INFO*/
174
- text-decoration: none;
175
- display: inline /*IMPORTANT*/;
176
- }
177
- .lkc-external-added {
178
- /*EX-HEADING*/
179
- }
180
- .lkc-internal-added {
181
- /*IN-HEADING*/
182
- }
183
- .lkc-this-added {
184
- /*TH-HEADING*/
185
- }
186
- .lkc-external-added , .lkc-internal-added , .lkc-this-added {
187
- /*COLOR-ADDED*/
188
- /*OUTCOLOR-ADDED*/
189
- /*SIZE-ADDED*/
190
- /*HEIGHT-ADDED*/
191
- display: inline /*IMPORTANT*/;
192
- }
193
- .lkc-date {
194
- /*COLOR-INFO*/
195
- /*OUTCOLOR-INFO*/
196
- /*SIZE-INFO*/
197
- /*HEIGHT-INFO*/
198
- text-decoration: none;
199
- display: inline /*IMPORTANT*/;
200
- float: right;
201
- }
202
- .lkc-share {
203
- display: inline;
204
- text-shadow: none;
205
- }
206
- .lkc-sns-tw {
207
- display: inline;
208
- margin: 0;
209
- padding: 0 1px;
210
- color: #5ea9dd /*IMPORTANT*/;
211
- background-color: #f5f8fa /*IMPORTANT*/;
212
- font-size: 9px;
213
- text-decoration: underline /*IMPORTANT*/;
214
- font-weight: bold /*IMPORTANT*/;
215
- white-space: nowrap;
216
- }
217
- .lkc-sns-fb {
218
- display: inline;
219
- margin: 0;
220
- padding: 0 1px;
221
- color: #ffffff /*IMPORTANT*/;
222
- background-color: #3864a3 /*IMPORTANT*/;
223
- font-size: 9px;
224
- text-decoration: underline /*IMPORTANT*/;
225
- font-weight: bold /*IMPORTANT*/;
226
- white-space: nowrap;
227
- }
228
- .lkc-sns-hb {
229
- display: inline;
230
- margin: 0;
231
- padding: 0 1px;
232
- color: #ff6464 /*IMPORTANT*/;
233
- background-color: #ffefef /*IMPORTANT*/;
234
- font-size: 9px;
235
- text-decoration: underline /*IMPORTANT*/;
236
- font-weight: bold /*IMPORTANT*/;
237
- white-space: nowrap;
238
- }
239
- .lkc-sns-gp {
240
- display: inline;
241
- margin: 0;
242
- padding: 0 1px;
243
- color: #dd4e42 /*IMPORTANT*/;
244
- background-color: #ffffff /*IMPORTANT*/;
245
- font-size: 9px;
246
- text-decoration: underline /*IMPORTANT*/;
247
- font-weight: bold /*IMPORTANT*/;
248
- white-space: nowrap;
249
- }
250
- .lkc-sns-po {
251
- display: inline;
252
- margin: 0;
253
- padding: 0 1px;
254
- color: #eeeeee /*IMPORTANT*/;
255
- background-color: #ee4055 /*IMPORTANT*/;
256
- font-size: 9px;
257
- text-decoration: underline /*IMPORTANT*/;
258
- font-weight: bold /*IMPORTANT*/;
259
- white-space: nowrap;
260
- }
261
- .clear {
262
- clear: both;
263
- }
264
-
265
- blockquote.lkc-quote {
266
- background-color: transparent;
267
- background-image: none;
268
- padding: 0;
269
- margin: 0;
270
- border: none;
271
- }
272
-
273
- .lkc-iframe-wrap {
274
- /*HATENA-WRAP-MARGIN*/
275
- /*WIDTH*/
276
- }
277
- .lkc-iframe {
278
- padding: 0;
279
- margin: 0;
280
- width: 100%;
281
- }
282
- /*OPTION*/
283
- /*CSS-ADD*/
 
 
 
 
 
 
284
  /*RESIZE*/
1
+ /* [Pz-LkC][/*VERSION*/] CSS */
2
+ .linkcard {
3
+ /*MARGIN-TOP*/
4
+ /*MARGIN-BOTTOM*/
5
+ /*MARGIN-LEFT*/
6
+ /*MARGIN-RIGHT*/
7
+ }
8
+ .linkcard img {
9
+ /*RESET-IMG*/
10
+ }
11
+ .linkcard span.external-icon {
12
+ display: none;
13
+ }
14
+ .linkcard p {
15
+ display: none;
16
+ }
17
+ .linkcard:hover .lkc-thumbnail img {
18
+ /*SCALE*/
19
+ }
20
+ .lkc-link {
21
+ /*ANKER*/
22
+ }
23
+ .lkc-external-wrap {
24
+ /*EX-BORDER*/
25
+ /*EX-BGCOLOR*/
26
+ /*EX-IMAGE*/
27
+ }
28
+ .lkc-internal-wrap {
29
+ /*IN-BORDER*/
30
+ /*IN-BGCOLOR*/
31
+ /*IN-IMAGE*/
32
+ }
33
+ .lkc-this-wrap {
34
+ /*TH-BORDER*/
35
+ /*TH-BGCOLOR*/
36
+ /*TH-IMAGE*/
37
+ }
38
+ .lkc-external-wrap , .lkc-internal-wrap , .lkc-this-wrap {
39
+ position: relative;
40
+ /*WRAP-MARGIN*/
41
+ /*PADDING*/
42
+ /*RADIUS*/
43
+ /*SHADOW*/
44
+ /*HEIGHT*/
45
+ /*WIDTH*/
46
+ /*WRAP*/
47
+ /*NOHOVER*/
48
+ }
49
+ .lkc-external-wrap::before , .lkc-internal-wrap::before , .lkc-this-wrap::before {
50
+ /*WRAP-BEFORE*/
51
+ }
52
+ .lkc-external-wrap::after , .lkc-internal-wrap::after , .lkc-this-wrap::after {
53
+ /*WRAP-AFTER*/
54
+ }
55
+ .lkc-external-wrap:hover , .lkc-internal-wrap:hover , .lkc-this-wrap:hover {
56
+ /*HOVER*/
57
+ }
58
+ .lkc-external-wrap:hover::before , .lkc-internal-wrap:hover::before , .lkc-this-wrap:hover::before {
59
+ /*HOVER-BEFORE*/
60
+ }
61
+ .lkc-external-wrap:hover::after , .lkc-internal-wrap:hover::after , .lkc-this-wrap:hover::after {
62
+ /*HOVER-AFTER*/
63
+ }
64
+ .lkc-card {
65
+ /*CARD-TOP*/
66
+ /*CARD-RIGHT*/
67
+ /*CARD-BOTTOM*/
68
+ /*CARD-LEFT*/
69
+ }
70
+ .lkc-content {
71
+ /*CONTENT-PADDING*/
72
+ /*CONTENT-INSET*/
73
+ /*CONTENT-BGCOLOR*/
74
+ /*CONTENT-HEIGHT*/
75
+ /*CONTENT-MARGIN*/
76
+ word-break: break-all;
77
+ white-space: normal;
78
+ overflow: hidden;
79
+ /*SEPARATOR*/
80
+ }
81
+ .lkc-title-text {
82
+ /*MARGIN-TITLE*/
83
+ /*COLOR-TITLE*/
84
+ /*OUTCOLOR-TITLE*/
85
+ /*SIZE-TITLE*/
86
+ /*HEIGHT-TITLE*/
87
+ font-weight: bold;
88
+ overflow: hidden;
89
+ word-break: break-all;
90
+ /*ELLIPSIS-TITLE*/
91
+ }
92
+ .lkc-title-text:hover {
93
+ text-decoration: underline;
94
+ }
95
+ .lkc-url {
96
+ /*MARGIN-URL*/
97
+ /*COLOR-URL*/
98
+ /*OUTCOLOR-URL*/
99
+ /*SIZE-URL*/
100
+ /*HEIGHT-URL*/
101
+ font-weight: normal;
102
+ text-decoration: underline;
103
+ overflow: hidden;
104
+ display: block;
105
+ /*NOWRAP-URL*/
106
+ }
107
+ .lkc-url-info {
108
+ /*COLOR-URL*/
109
+ /*OUTCOLOR-URL*/
110
+ /*SIZE-URL*/
111
+ /*HEIGHT-URL*/
112
+ font-weight: normal;
113
+ text-decoration: underline;
114
+ white-space: nowrap;
115
+ overflow: hidden;
116
+ text-overflow: ellipsis;
117
+ display: inline;
118
+ }
119
+ .lkc-excerpt {
120
+ /*MARGIN-EXCERPT*/
121
+ /*COLOR-EXCERPT*/
122
+ /*OUTCOLOR-EXCERPT*/
123
+ /*SIZE-EXCERPT*/
124
+ /*HEIGHT-EXCERPT*/
125
+ padding: 0;
126
+ overflow: hidden;
127
+ /*NONE-EXCERPT*/
128
+ }
129
+ .lkc-more-text {
130
+ display: inline;
131
+ /*COLOR-MORE*/
132
+ /*OUTCOLOR-MORE*/
133
+ /*SIZE-MORE*/
134
+ /*HEIGHT-MORE*/
135
+ /*STYLE-MORE*/
136
+ }
137
+ .lkc-thumbnail {
138
+ /*THUMBNAIL-WIDTH*/
139
+ /*THUMBNAIL-HEIGHT*/
140
+ padding: 0;
141
+ /*THUMBNAIL-MARGIN*/
142
+ /*THUMBNAIL-POSITION*/
143
+ }
144
+ .lkc-thumbnail img {
145
+ /*TRANSFORM*/
146
+ }
147
+ .lkc-thumbnail-img {
148
+ /*THUMBNAIL-IMG-WIDTH*/
149
+ /*THUMBNAIL-IMG-HEIGHT*/
150
+ border: 1px solid #222;
151
+ /*THUMBNAIL-RADIUS*/
152
+ /*THUMBNAIL-SHADOW*/
153
+ }
154
+ .lkc-info {
155
+ /*POSITION-INFO*/
156
+ padding: 0;
157
+ /*COLOR-INFO*/
158
+ /*OUTCOLOR-INFO*/
159
+ /*SIZE-INFO*/
160
+ /*HEIGHT-INFO*/
161
+ white-space: nowrap;
162
+ overflow: hidden;
163
+ display: block /*IMPORTANT*/;
164
+ /*NONE-INFO*/
165
+ }
166
+ .lkc-favicon {
167
+ height: 16px;
168
+ width: 16px;
169
+ margin: 0 4px /*IMPORTANT*/;
170
+ border: none;
171
+ vertical-align: bottom;
172
+ display: inline /*IMPORTANT*/;
173
+ }
174
+ .lkc-domain {
175
+ margin: 0 0 0 6px;
176
+ /*COLOR-INFO*/
177
+ /*OUTCOLOR-INFO*/
178
+ /*SIZE-INFO*/
179
+ /*HEIGHT-INFO*/
180
+ text-decoration: none;
181
+ display: inline /*IMPORTANT*/;
182
+ }
183
+ .lkc-external-added {
184
+ /*EX-HEADING*/
185
+ }
186
+ .lkc-internal-added {
187
+ /*IN-HEADING*/
188
+ }
189
+ .lkc-this-added {
190
+ /*TH-HEADING*/
191
+ }
192
+ .lkc-external-added , .lkc-internal-added , .lkc-this-added {
193
+ /*COLOR-ADDED*/
194
+ /*OUTCOLOR-ADDED*/
195
+ /*SIZE-ADDED*/
196
+ /*HEIGHT-ADDED*/
197
+ display: inline /*IMPORTANT*/;
198
+ }
199
+ .lkc-date {
200
+ /*COLOR-INFO*/
201
+ /*OUTCOLOR-INFO*/
202
+ /*SIZE-INFO*/
203
+ /*HEIGHT-INFO*/
204
+ text-decoration: none;
205
+ display: inline /*IMPORTANT*/;
206
+ float: right;
207
+ }
208
+ .lkc-share {
209
+ display: inline;
210
+ text-shadow: none;
211
+ }
212
+ .lkc-sns-tw {
213
+ display: inline;
214
+ margin: 0;
215
+ padding: 0 1px;
216
+ color: #5ea9dd /*IMPORTANT*/;
217
+ background-color: #f5f8fa /*IMPORTANT*/;
218
+ font-size: 9px;
219
+ text-decoration: underline /*IMPORTANT*/;
220
+ font-weight: bold /*IMPORTANT*/;
221
+ white-space: nowrap;
222
+ }
223
+ .lkc-sns-fb {
224
+ display: inline;
225
+ margin: 0;
226
+ padding: 0 1px;
227
+ color: #ffffff /*IMPORTANT*/;
228
+ background-color: #3864a3 /*IMPORTANT*/;
229
+ font-size: 9px;
230
+ text-decoration: underline /*IMPORTANT*/;
231
+ font-weight: bold /*IMPORTANT*/;
232
+ white-space: nowrap;
233
+ }
234
+ .lkc-sns-hb {
235
+ display: inline;
236
+ margin: 0;
237
+ padding: 0 1px;
238
+ color: #ff6464 /*IMPORTANT*/;
239
+ background-color: #ffefef /*IMPORTANT*/;
240
+ font-size: 9px;
241
+ text-decoration: underline /*IMPORTANT*/;
242
+ font-weight: bold /*IMPORTANT*/;
243
+ white-space: nowrap;
244
+ }
245
+ .lkc-sns-gp {
246
+ display: inline;
247
+ margin: 0;
248
+ padding: 0 1px;
249
+ color: #dd4e42 /*IMPORTANT*/;
250
+ background-color: #ffffff /*IMPORTANT*/;
251
+ font-size: 9px;
252
+ text-decoration: underline /*IMPORTANT*/;
253
+ font-weight: bold /*IMPORTANT*/;
254
+ white-space: nowrap;
255
+ }
256
+ .lkc-sns-po {
257
+ display: inline;
258
+ margin: 0;
259
+ padding: 0 1px;
260
+ color: #eeeeee /*IMPORTANT*/;
261
+ background-color: #ee4055 /*IMPORTANT*/;
262
+ font-size: 9px;
263
+ text-decoration: underline /*IMPORTANT*/;
264
+ font-weight: bold /*IMPORTANT*/;
265
+ white-space: nowrap;
266
+ }
267
+ .clear {
268
+ clear: both;
269
+ }
270
+
271
+ blockquote.lkc-quote {
272
+ background-color: transparent;
273
+ background-image: none;
274
+ padding: 0;
275
+ margin: 0;
276
+ border: none;
277
+ }
278
+
279
+ .lkc-iframe-wrap {
280
+ /*HATENA-WRAP-MARGIN*/
281
+ /*WIDTH*/
282
+ }
283
+ .lkc-iframe {
284
+ padding: 0;
285
+ margin: 0;
286
+ width: 100%;
287
+ }
288
+ /*OPTION*/
289
+ /*CSS-ADD*/
290
  /*RESIZE*/