Pz-LinkCard - Version 1.0.2

Version Description

  • *
Download this release

Release Info

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

Code changes from version 1.0.0 to 1.0.2

languages/pz-linkcard-ja.mo CHANGED
Binary file
languages/pz-linkcard-ja.po CHANGED
@@ -5,7 +5,7 @@ msgstr ""
5
  "Project-Id-Version: Pz-LinkCard\n"
6
  "Report-Msgid-Bugs-To: http://wppolyglots.wordpress.com\n"
7
  "POT-Creation-Date: 2015-10-10 22:58+0900\n"
8
- "PO-Revision-Date: 2015-10-11 00:17+0900\n"
9
  "Last-Translator: \n"
10
  "Language-Team: poporon\n"
11
  "Language: ja_JP\n"
@@ -312,19 +312,19 @@ msgstr "紙がめくれた効果(ほとんどのテーマで正しく表示さ
312
 
313
  #: ../pz-linkcard-settings.php:119
314
  msgid "Neutral"
315
- msgstr "ブルーグリーン"
316
 
317
  #: ../pz-linkcard-settings.php:120
318
  msgid "Orange"
319
- msgstr "オレンジ"
320
 
321
  #: ../pz-linkcard-settings.php:121
322
  msgid "Green"
323
- msgstr "グリーン"
324
 
325
  #: ../pz-linkcard-settings.php:122
326
  msgid "Blue"
327
- msgstr "ブルー"
328
 
329
  #: ../pz-linkcard-settings.php:124
330
  msgid "Will some of the parameters are forcibly changed"
5
  "Project-Id-Version: Pz-LinkCard\n"
6
  "Report-Msgid-Bugs-To: http://wppolyglots.wordpress.com\n"
7
  "POT-Creation-Date: 2015-10-10 22:58+0900\n"
8
+ "PO-Revision-Date: 2015-10-11 23:15+0900\n"
9
  "Last-Translator: \n"
10
  "Language-Team: poporon\n"
11
  "Language: ja_JP\n"
312
 
313
  #: ../pz-linkcard-settings.php:119
314
  msgid "Neutral"
315
+ msgstr "ブルーグリーン(黒背景推奨)"
316
 
317
  #: ../pz-linkcard-settings.php:120
318
  msgid "Orange"
319
+ msgstr "オレンジ(黒背景推奨)"
320
 
321
  #: ../pz-linkcard-settings.php:121
322
  msgid "Green"
323
+ msgstr "グリーン(黒背景推奨)"
324
 
325
  #: ../pz-linkcard-settings.php:122
326
  msgid "Blue"
327
+ msgstr "ブルー(黒背景推奨)"
328
 
329
  #: ../pz-linkcard-settings.php:124
330
  msgid "Will some of the parameters are forcibly changed"
pz-linkcard-cacheman.php CHANGED
@@ -11,9 +11,13 @@ echo '<h1>'.__('LinkCard cache manager', $this->text_domain).'</h1>';
11
 
12
  $update = isset($_REQUEST['update'] ) ? $_REQUEST['update'] : null;
13
  $cancel = isset($_REQUEST['cancel'] ) ? $_REQUEST['cancel'] : null;
 
14
  if ($update || $cancel) {
15
  if ($update) {
16
  $action = 'update';
 
 
 
17
  } else {
18
  $action = null;
19
  }
@@ -34,6 +38,7 @@ $confirm = isset($_REQUEST['confirm'] ) ? $_REQUEST['confirm'] : null;
34
  $result_code = isset($_REQUEST['result_code'] ) ? $_REQUEST['result_code'] : null;
35
  $paged = (isset($_REQUEST['paged'] ) ? $_REQUEST['paged'] : 1) - 0;
36
 
 
37
  global $wpdb;
38
 
39
  if (isset($action)) {
@@ -42,8 +47,8 @@ if (isset($action)) {
42
  switch ($action) {
43
  case 'edit':
44
  if (isset($bulk_id) && is_array($bulk_id)) {
45
- $data = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->db WHERE id=%d", $bulk_id[0]));
46
- // Pz_LinkCard::pz_getHTML(array('url' => $result->url, 'force' => true));
47
  ?>
48
  <form action="" method="post">
49
  <?php wp_nonce_field('pz_cacheman'); ?>
@@ -51,67 +56,71 @@ if (isset($action)) {
51
  <table name="cachelist" class="wp-list-table widefat fixed">
52
  <tr>
53
  <th style="width: 12em;"><?php _e('ID', $this->text_domain) ?></th>
54
- <td><input name="data[id]" type="text" id="inputtext" value="<?php echo $data->id; ?>" size="5" readonly="readonly" /></td>
 
 
 
 
55
  </tr>
56
  <tr>
57
  <th><?php _e('URL', $this->text_domain) ?></th>
58
- <td><input name="data[url]" type="text" id="inputtext" value="<?php echo $data->url; ?>" size="64" readonly="readonly" /></td>
59
  </tr>
60
  <tr>
61
  <th><?php _e('Site name', $this->text_domain) ?></th>
62
- <td><input name="data[site_name]" type="text" id="inputtext" value="<?php echo $data->site_name; ?>" size="64" /></td>
63
  </tr>
64
  <tr>
65
  <th><?php _e('Domain', $this->text_domain) ?></th>
66
- <td><input name="data[domain]" type="text" id="inputtext" value="<?php echo $data->domain; ?>" size="64" readonly="readonly" /></td>
67
  </tr>
68
  <tr>
69
  <th><?php _e('Title', $this->text_domain) ?></th>
70
- <td><input name="data[title]" type="text" id="inputtext" value="<?php echo $data->title; ?>" size="64" /></td>
71
  </tr>
72
  <tr>
73
  <th><?php _e('Excerpt', $this->text_domain) ?></th>
74
- <td><input name="data[excerpt]" type="text" id="inputtext" value="<?php echo $data->excerpt; ?>" size="64" /></td>
75
  </tr>
76
  <tr>
77
  <th><?php _e('Charset', $this->text_domain) ?></th>
78
- <td><input name="data[charset]" type="text" id="inputtext" value="<?php echo $data->charset; ?>" size="8" readonly="readonly" /></td>
79
  </tr>
80
  <tr>
81
  <th><?php _e('Thumbnail URL', $this->text_domain) ?></th>
82
- <td><input name="data[thumbnail]" type="text" id="inputtext" value="<?php echo $data->thumbnail; ?>" size="64" readonly="readonly" /></td>
83
  </tr>
84
  <tr>
85
  <th><?php _e('Favicon URL', $this->text_domain) ?></th>
86
- <td><input name="data[favicon]" type="text" id="inputtext" value="<?php echo $data->favicon; ?>" size="64" readonly="readonly" /></td>
87
  </tr>
88
  <tr>
89
  <th><?php _e('Result code', $this->text_domain) ?></th>
90
- <td><input name="data[result_code]" type="text" id="inputtext" value="<?php echo $data->result_code; ?>" size="5" readonly="readonly" /></td>
91
  </tr>
92
  <tr>
93
  <th><?php _e('Post ID', $this->text_domain) ?></th>
94
- <td><input name="data[post_id]" type="text" id="inputtext" value="<?php echo $data->post_id; ?>" size="5" readonly="readonly" /></td>
95
  </tr>
96
  <tr>
97
  <th><?php _e('SNS', $this->text_domain) ?></th>
98
  <td>
99
- <?php _e('Tw', $this->text_domain) ?>:<input name="data[sns_twitter]" type="text" id="inputtext" value="<?php echo $data->sns_twitter; ?>" size="5" readonly="readonly" />
100
- <?php _e('fb', $this->text_domain) ?>:<input name="data[sns_facebook]" type="text" id="inputtext" value="<?php echo $data->sns_facebook; ?>" size="5" readonly="readonly" />
101
- <?php _e('B!', $this->text_domain) ?>:<input name="data[sns_hatena]" type="text" id="inputtext" value="<?php echo $data->sns_hatena; ?>" size="5" readonly="readonly" />
102
  </td>
103
  </tr>
104
  <tr>
105
  <th><?php _e('Uptime', $this->text_domain) ?></th>
106
- <td><input name="data[uptime]" type="text" id="inputtext" value="<?php echo $data->uptime; ?>" size="10" readonly="readonly" /><?php echo date('Y/m/d H:i:s', $data->uptime); ?></td>
107
  </tr>
108
  <tr>
109
  <th><?php _e('Next update', $this->text_domain) ?></th>
110
- <td><input name="data[nexttime]" type="text" id="inputtext" value="<?php echo $data->nexttime; ?>" size="10" readonly="readonly" /><?php echo date('Y/m/d H:i:s', $data->nexttime); ?></td>
111
  </tr>
112
  <tr>
113
  <th><?php _e('Regist', $this->text_domain) ?></th>
114
- <td><input name="data[regist]" type="text" id="inputtext" value="<?php echo current_time('mysql'); ?>" size="20" readonly="readonly" /><?php echo $data->regist; ?></td>
115
  </tr>
116
  <tr>
117
  <th></th>
@@ -121,19 +130,16 @@ if (isset($action)) {
121
  </div>
122
  </form>
123
  <?php
 
124
  }
125
  break;
126
  case 'update':
127
- $data = isset($_REQUEST['data']) ? $_REQUEST['data'] : null ;
128
- if (isset($data) && is_array($data)) {
129
- $result = $wpdb->update(
130
- $this->db,
131
- $data,
132
- array(
133
- 'id' => $data['id']
134
- )
135
- );
136
- if ($result) {
137
  echo '<div class="updated fade"><p><strong>'.__('Updated cache', $this->text_domain).'</strong></p></div>';
138
  } else {
139
  echo '<div class="error fade"><p><strong>'.__('Update failed', $this->text_domain).'</strong></p></div>';
@@ -144,18 +150,28 @@ if (isset($action)) {
144
  break;
145
  case 'renew_sns':
146
  if (isset($bulk_id) && is_array($bulk_id)) {
147
- foreach ($bulk_id as $value) {
148
- $wpdb->update($this->db, array('nexttime' => 0), array('id' => $value), null, array('%d') );
 
 
 
 
 
 
 
 
149
  }
150
- echo '<div class="updated fade"><p><strong>'.__('Instructed to get the number again', $this->text_domain).'</strong></p></div>';
151
  }
152
  break;
153
  case 'renew':
154
  if (isset($bulk_id) && is_array($bulk_id)) {
155
  echo '<div class="updated fade"><p><strong>'.__('Cache renew', $this->text_domain).'...';
156
- foreach ($bulk_id as $value) {
157
- $result = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->db WHERE id=%d", $value));
158
- Pz_LinkCard::pz_getHTML(array('url' => $result->url, 'force' => true));
 
 
159
  echo '..';
160
  }
161
  echo __('completed', $this->text_domain).'</strong></p></div>';
@@ -163,8 +179,8 @@ if (isset($action)) {
163
  break;
164
  case 'delete':
165
  if (isset($bulk_id) && is_array($bulk_id)) {
166
- foreach ($bulk_id as $value) {
167
- $wpdb->delete($this->db, array('id' => $value), array('%d') );
168
  }
169
  echo '<div class="updated fade"><p><strong>'.__('Cache deleted', $this->text_domain).'</strong></p></div>';
170
  }
@@ -331,12 +347,14 @@ echo '</div>';
331
  <table name="cachelist" class="wp-list-table widefat fixed striped posts">
332
  <thead>
333
  <tr>
334
- <td id='cb' class='manage-column column-cb check-column'><label class="screen-reader-text" for="cb-select-all-1">'.__('Select all', $this->text_domain).'</label><input id="cb-select-all-1" type="checkbox" /></td>
335
- <th class="url style="min-width: 10em;"><?php echo_THC('url', __('URL', $this->text_domain) ); ?></th>
 
 
336
  <th class="title" style="min-width: 10em;"><?php echo_THC('title', __('Title', $this->text_domain) ); ?></th>
337
  <th class="excerpt" style="min-width: 20em;"><?php echo_THC('excerpt', __('Excerpt', $this->text_domain) ); ?></th>
338
- <th class="charset" style="min-width: 5em;"><?php echo_THC('charset', __('Charset', $this->text_domain) ); ?></th>
339
- <th class="domain" style="min-width: 8em;"><?php echo_THC('domain', __('Domain', $this->text_domain) ); ?></th>
340
  <th class="tw" style="width: 2em;"><?php echo_THC('sns_twitter', __('Tw', $this->text_domain) ); ?></th>
341
  <th class="fb" style="width: 2em;"><?php echo_THC('sns_facebook', __('fb', $this->text_domain) ); ?></th>
342
  <th class="hb" style="width: 2em;"><?php echo_THC('sns_hatena', __('B!', $this->text_domain) ); ?></th>
@@ -351,13 +369,16 @@ foreach ($data_all as $data) {
351
  echo '<tr>';
352
  // echo '<td colspan=12">'.Pz_LinkCard::pz_getHTML(array('url' => $data->url)).'</td>';
353
 
354
- $id = $data->id;
355
  echo ' <th scope="row" class="check-column">';
356
- echo ' <label class="screen-reader-text" for="cb-select-'.$id.'">'.__('Select', $this->text_domain).'</label>';
357
- echo ' <input id="cb-select-'.$id.'" type="checkbox" name="id[]" value="'.$id.'" />';
358
  echo ' <div class="locked-indicator"></div>';
359
  echo ' </th>';
360
 
 
 
 
361
  $url = esc_url($data->url);
362
  $title = htmlentities($data->title);
363
  echo ' <td colspan="2">';
@@ -368,10 +389,10 @@ foreach ($data_all as $data) {
368
  echo $url;
369
  }
370
  echo '</div><div>'.$title.'</div>';
371
- echo ' <div id="inline_'.$id.'"style="font-size: 90%;">';
372
- echo '<a href="'.wp_nonce_url('?page=pz-linkcard-cache&link_type='.$link_type.'&orderby='.$orderby.'&order='.$order.'&paged='.$page_now.'&action=edit&id[0]='.$id, 'pz_cacheman').'">'.__('edit',$this->text_domain).'</a> | ';
373
- echo '<a href="'.wp_nonce_url('?page=pz-linkcard-cache&link_type='.$link_type.'&orderby='.$orderby.'&order='.$order.'&paged='.$page_now.'&action=renew&id[0]='.$id, 'pz_cacheman').'" onclick="return confirm(\''.__('Are you sure?', $this->text_domain).'\');">'.__('renew',$this->text_domain).'</a> | ';
374
- echo '<a href="'.wp_nonce_url('?page=pz-linkcard-cache&link_type='.$link_type.'&orderby='.$orderby.'&order='.$order.'&paged='.$page_now.'&action=delete&id[0]='.$id, 'pz_cacheman').'" onclick="return confirm(\''.__('Are you sure?', $this->text_domain).'\');">'.__('delete',$this->text_domain).'</a>';
375
  echo '</div>';
376
  echo ' </td>';
377
 
11
 
12
  $update = isset($_REQUEST['update'] ) ? $_REQUEST['update'] : null;
13
  $cancel = isset($_REQUEST['cancel'] ) ? $_REQUEST['cancel'] : null;
14
+ $data = null;
15
  if ($update || $cancel) {
16
  if ($update) {
17
  $action = 'update';
18
+ if (isset($_REQUEST['data']) && is_array($_REQUEST['data'])) {
19
+ $data = $_REQUEST['data'];
20
+ }
21
  } else {
22
  $action = null;
23
  }
38
  $result_code = isset($_REQUEST['result_code'] ) ? $_REQUEST['result_code'] : null;
39
  $paged = (isset($_REQUEST['paged'] ) ? $_REQUEST['paged'] : 1) - 0;
40
 
41
+
42
  global $wpdb;
43
 
44
  if (isset($action)) {
47
  switch ($action) {
48
  case 'edit':
49
  if (isset($bulk_id) && is_array($bulk_id)) {
50
+ $data = $this->pz_GetCache(array('id' => $bulk_id[0]));
51
+ if (isset($data) && is_array($data)) {
52
  ?>
53
  <form action="" method="post">
54
  <?php wp_nonce_field('pz_cacheman'); ?>
56
  <table name="cachelist" class="wp-list-table widefat fixed">
57
  <tr>
58
  <th style="width: 12em;"><?php _e('ID', $this->text_domain) ?></th>
59
+ <td><input name="data[id]" type="text" id="inputtext" value="<?php echo $data['id']; ?>" size="5" readonly="readonly" /></td>
60
+ </tr>
61
+ <tr style="display: none;">
62
+ <th><?php _e('URL key', $this->text_domain) ?></th>
63
+ <td><input name="key_text" type="text" id="inputtext" value="<?php echo bin2hex($data['url_key']); ?>" size="71" readonly="readonly" /></td>
64
  </tr>
65
  <tr>
66
  <th><?php _e('URL', $this->text_domain) ?></th>
67
+ <td><input name="data[url]" type="text" id="inputtext" value="<?php echo $data['url']; ?>" size="71" readonly="readonly" /></td>
68
  </tr>
69
  <tr>
70
  <th><?php _e('Site name', $this->text_domain) ?></th>
71
+ <td><input name="data[site_name]" type="text" id="inputtext" value="<?php echo esc_attr($data['site_name']); ?>" size="71" /></td>
72
  </tr>
73
  <tr>
74
  <th><?php _e('Domain', $this->text_domain) ?></th>
75
+ <td><input name="data[domain]" type="text" id="inputtext" value="<?php echo $data['domain']; ?>" size="71" readonly="readonly" /></td>
76
  </tr>
77
  <tr>
78
  <th><?php _e('Title', $this->text_domain) ?></th>
79
+ <td><input name="data[title]" type="text" id="inputtext" value="<?php echo esc_attr($data['title']); ?>" size="71" /></td>
80
  </tr>
81
  <tr>
82
  <th><?php _e('Excerpt', $this->text_domain) ?></th>
83
+ <td><input name="data[excerpt]" type="text" id="inputtext" value="<?php echo esc_attr($data['excerpt']); ?>" size="71" /></td>
84
  </tr>
85
  <tr>
86
  <th><?php _e('Charset', $this->text_domain) ?></th>
87
+ <td><?php echo $data['charset']; ?>→<input name="data[charset]" type="text" id="inputtext" value="edit" size="8" readonly="readonly" /></td>
88
  </tr>
89
  <tr>
90
  <th><?php _e('Thumbnail URL', $this->text_domain) ?></th>
91
+ <td><input name="data[thumbnail]" type="text" id="inputtext" value="<?php echo $data['thumbnail']; ?>" size="71" readonly="readonly" /></td>
92
  </tr>
93
  <tr>
94
  <th><?php _e('Favicon URL', $this->text_domain) ?></th>
95
+ <td><input name="data[favicon]" type="text" id="inputtext" value="<?php echo $data['favicon']; ?>" size="71" readonly="readonly" /></td>
96
  </tr>
97
  <tr>
98
  <th><?php _e('Result code', $this->text_domain) ?></th>
99
+ <td><input name="data[result_code]" type="text" id="inputtext" value="<?php echo $data['result_code']; ?>" size="5" readonly="readonly" /></td>
100
  </tr>
101
  <tr>
102
  <th><?php _e('Post ID', $this->text_domain) ?></th>
103
+ <td><input name="data[post_id]" type="text" id="inputtext" value="<?php echo $data['post_id']; ?>" size="5" readonly="readonly" /></td>
104
  </tr>
105
  <tr>
106
  <th><?php _e('SNS', $this->text_domain) ?></th>
107
  <td>
108
+ <?php _e('Tw', $this->text_domain) ?>:<input name="data[sns_twitter]" type="text" id="inputtext" value="<?php echo $data['sns_twitter']; ?>" size="5" readonly="readonly" />
109
+ <?php _e('fb', $this->text_domain) ?>:<input name="data[sns_facebook]" type="text" id="inputtext" value="<?php echo $data['sns_facebook']; ?>" size="5" readonly="readonly" />
110
+ <?php _e('B!', $this->text_domain) ?>:<input name="data[sns_hatena]" type="text" id="inputtext" value="<?php echo $data['sns_hatena']; ?>" size="5" readonly="readonly" />
111
  </td>
112
  </tr>
113
  <tr>
114
  <th><?php _e('Uptime', $this->text_domain) ?></th>
115
+ <td><input name="data[uptime]" type="text" id="inputtext" value="<?php echo $data['uptime']; ?>" size="10" readonly="readonly" /><?php echo date('Y-m-d H:i:s', $data['uptime']); ?></td>
116
  </tr>
117
  <tr>
118
  <th><?php _e('Next update', $this->text_domain) ?></th>
119
+ <td><input name="data[nexttime]" type="text" id="inputtext" value="<?php echo $data['nexttime']; ?>" size="10" readonly="readonly" /><?php echo date('Y-m-d H:i:s', $data['nexttime']); ?></td>
120
  </tr>
121
  <tr>
122
  <th><?php _e('Regist', $this->text_domain) ?></th>
123
+ <td><input name="data[regist]" type="text" id="inputtext" value="<?php echo current_time('mysql'); ?>" size="17" readonly="readonly" /><?php echo $data['regist']; ?></td>
124
  </tr>
125
  <tr>
126
  <th></th>
130
  </div>
131
  </form>
132
  <?php
133
+ }
134
  }
135
  break;
136
  case 'update':
137
+ if (isset($data) && is_array($data) && isset($data['id'])) {
138
+ $data['title'] = stripslashes($data['title']);
139
+ $data['excerpt'] = stripslashes($data['excerpt']);
140
+ $data['site_name'] = stripslashes($data['site_name']);
141
+ $data = $this->pz_SetCache($data);
142
+ if (isset($data) && is_array($data) && isset($data['id'])) {
 
 
 
 
143
  echo '<div class="updated fade"><p><strong>'.__('Updated cache', $this->text_domain).'</strong></p></div>';
144
  } else {
145
  echo '<div class="error fade"><p><strong>'.__('Update failed', $this->text_domain).'</strong></p></div>';
150
  break;
151
  case 'renew_sns':
152
  if (isset($bulk_id) && is_array($bulk_id)) {
153
+ echo '<div class="updated fade"><p><strong>'.__('Social count renew', $this->text_domain).'...';
154
+ foreach ($bulk_id as $data_id) {
155
+ echo $data_id;
156
+ $data = $this->pz_GetCache(array('id' => $data_id));
157
+ if (isset($data) && is_array($data)) {
158
+ $data['nexttime'] = 0;
159
+ $data = $this->pz_SetCache($data);
160
+ $this->pz_getHTML(array('url' => $data['url']));
161
+ }
162
+ echo '..';
163
  }
164
+ echo __('completed', $this->text_domain).'</strong></p></div>';
165
  }
166
  break;
167
  case 'renew':
168
  if (isset($bulk_id) && is_array($bulk_id)) {
169
  echo '<div class="updated fade"><p><strong>'.__('Cache renew', $this->text_domain).'...';
170
+ foreach ($bulk_id as $data_id) {
171
+ $data = $this->pz_GetCache(array('id' => $data_id));
172
+ if (isset($data) && is_array($data)) {
173
+ $this->pz_getHTML(array('url' => $data['url'], 'force' => true));
174
+ }
175
  echo '..';
176
  }
177
  echo __('completed', $this->text_domain).'</strong></p></div>';
179
  break;
180
  case 'delete':
181
  if (isset($bulk_id) && is_array($bulk_id)) {
182
+ foreach ($bulk_id as $data_id) {
183
+ $this->pz_DelCache(array('id' => $data_id) );
184
  }
185
  echo '<div class="updated fade"><p><strong>'.__('Cache deleted', $this->text_domain).'</strong></p></div>';
186
  }
347
  <table name="cachelist" class="wp-list-table widefat fixed striped posts">
348
  <thead>
349
  <tr>
350
+ <td id="cb" class="manage-column column-cb check-column"><label class="screen-reader-text" for="cb-select-all-1"><?php _e('Select all', $this->text_domain); ?></label><input id="cb-select-all-1" type="checkbox" /></td>
351
+ <th class="id" style="width: 3em; display: none;"><?php echo_THC('id', __('ID', $this->text_domain) ); ?></th>
352
+ <th class="url_key" style="width: 9em; display: none;"><?php echo_THC('url_key', __('URL key', $this->text_domain) ); ?></th>
353
+ <th class="url" style="min-width: 10em;"><?php echo_THC('url', __('URL', $this->text_domain) ); ?></th>
354
  <th class="title" style="min-width: 10em;"><?php echo_THC('title', __('Title', $this->text_domain) ); ?></th>
355
  <th class="excerpt" style="min-width: 20em;"><?php echo_THC('excerpt', __('Excerpt', $this->text_domain) ); ?></th>
356
+ <th class="charset" style="width: 4em;"><?php echo_THC('charset', __('Charset', $this->text_domain) ); ?></th>
357
+ <th class="domain" style="min-width: 6em;"><?php echo_THC('domain', __('Domain', $this->text_domain) ); ?></th>
358
  <th class="tw" style="width: 2em;"><?php echo_THC('sns_twitter', __('Tw', $this->text_domain) ); ?></th>
359
  <th class="fb" style="width: 2em;"><?php echo_THC('sns_facebook', __('fb', $this->text_domain) ); ?></th>
360
  <th class="hb" style="width: 2em;"><?php echo_THC('sns_hatena', __('B!', $this->text_domain) ); ?></th>
369
  echo '<tr>';
370
  // echo '<td colspan=12">'.Pz_LinkCard::pz_getHTML(array('url' => $data->url)).'</td>';
371
 
372
+ $data_id = $data->id;
373
  echo ' <th scope="row" class="check-column">';
374
+ echo ' <label class="screen-reader-text" for="cb-select-'.$data_id.'">'.__('Select', $this->text_domain).'</label>';
375
+ echo ' <input id="cb-select-'.$data_id.'" type="checkbox" name="id[]" value="'.$data_id.'" />';
376
  echo ' <div class="locked-indicator"></div>';
377
  echo ' </th>';
378
 
379
+ echo ' <td style="display: none;">'.$data_id.'</td>';
380
+ echo ' <td style="display: none;">'.bin2hex($data->url_key).'</td>';
381
+
382
  $url = esc_url($data->url);
383
  $title = htmlentities($data->title);
384
  echo ' <td colspan="2">';
389
  echo $url;
390
  }
391
  echo '</div><div>'.$title.'</div>';
392
+ echo ' <div id="inline_'.$data_id.'"style="font-size: 90%;">';
393
+ echo '<a href="'.wp_nonce_url('?page=pz-linkcard-cache&link_type='.$link_type.'&orderby='.$orderby.'&order='.$order.'&paged='.$page_now.'&action=edit&id[0]='.$data_id, 'pz_cacheman').'">'.__('edit',$this->text_domain).'</a> | ';
394
+ echo '<a href="'.wp_nonce_url('?page=pz-linkcard-cache&link_type='.$link_type.'&orderby='.$orderby.'&order='.$order.'&paged='.$page_now.'&action=renew&id[0]='.$data_id, 'pz_cacheman').'" onclick="return confirm(\''.__('Are you sure?', $this->text_domain).'\');">'.__('renew',$this->text_domain).'</a> | ';
395
+ echo '<a href="'.wp_nonce_url('?page=pz-linkcard-cache&link_type='.$link_type.'&orderby='.$orderby.'&order='.$order.'&paged='.$page_now.'&action=delete&id[0]='.$data_id, 'pz_cacheman').'" onclick="return confirm(\''.__('Are you sure?', $this->text_domain).'\');">'.__('delete',$this->text_domain).'</a>';
396
  echo '</div>';
397
  echo ' </td>';
398
 
pz-linkcard-settings.php CHANGED
@@ -306,9 +306,9 @@
306
  <option value="1" <?php if($this->options['sns-position'] == '1') echo 'selected="selected"'; ?>><?php _e('After Title', $this->text_domain); ?></option>
307
  <option value="2" <?php if($this->options['sns-position'] == '2') echo 'selected="selected"'; ?>><?php _e('After site-name', $this->text_domain); ?></option>
308
  </select>
309
- <input name="properties[sns-twitter]" type="checkbox" id="check" value="1" <?php checked(isset($this->options['sns-twitter']) ? $this->options['sns-twitter'] : null, 1); ?> /><?php _e('Twitter', $this->text_domain); ?>
310
- <input name="properties[sns-facebook]" type="checkbox" id="check" value="1" <?php checked(isset($this->options['sns-facebook']) ? $this->options['sns-facebook'] : null, 1); ?> /><?php _e('Facebook', $this->text_domain); ?>
311
- <input name="properties[sns-hatena]" type="checkbox" id="check" value="1" <?php checked(isset($this->options['sns-hatena']) ? $this->options['sns-hatena'] : null, 1); ?> /><?php _e('Hatena', $this->text_domain); ?>
312
  <br /><?php _e('There is a possibility that the screen display is slow If you enable this setting.', $this->text_domain); ?>
313
  </td>
314
  </tr>
306
  <option value="1" <?php if($this->options['sns-position'] == '1') echo 'selected="selected"'; ?>><?php _e('After Title', $this->text_domain); ?></option>
307
  <option value="2" <?php if($this->options['sns-position'] == '2') echo 'selected="selected"'; ?>><?php _e('After site-name', $this->text_domain); ?></option>
308
  </select>
309
+ <input name="properties[sns-tw]" type="checkbox" id="check" value="1" <?php checked(isset($this->options['sns-tw']) ? $this->options['sns-tw'] : null, 1); ?> /><?php _e('Twitter', $this->text_domain); ?>
310
+ <input name="properties[sns-fb]" type="checkbox" id="check" value="1" <?php checked(isset($this->options['sns-fb']) ? $this->options['sns-fb'] : null, 1); ?> /><?php _e('Facebook', $this->text_domain); ?>
311
+ <input name="properties[sns-hb]" type="checkbox" id="check" value="1" <?php checked(isset($this->options['sns-hb']) ? $this->options['sns-hb'] : null, 1); ?> /><?php _e('Hatena', $this->text_domain); ?>
312
  <br /><?php _e('There is a possibility that the screen display is slow If you enable this setting.', $this->text_domain); ?>
313
  </td>
314
  </tr>
pz-linkcard-style.php CHANGED
@@ -40,7 +40,7 @@
40
  case 'ct1': // Cellophane tape center
41
  $file_text = str_replace('/*WRAP*/', 'position: relative;',$file_text );
42
  $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 );
43
- $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.2) , 0px 0px 16px rgba(0, 0, 0, 0.2) inset;', $file_text );
44
  break;
45
  case 'ct2': // Cellophane tape left right
46
  $file_text = str_replace('/*WRAP*/', 'position: relative;',$file_text );
@@ -48,14 +48,14 @@
48
  $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 );
49
  $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 );
50
  $file_text = str_replace('/*MARGIN-RIGHT*/', 'margin-right: 25px;',$file_text );
51
- $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.2) , 0px 0px 16px rgba(0, 0, 0, 0.2) inset;', $file_text );
52
  break;
53
  case 'ct3': // Cellophane long
54
  $file_text = str_replace('/*WRAP*/', 'position: relative;',$file_text );
55
  $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 );
56
  $file_text = str_replace('/*MARGIN-LEFT*/', 'margin-left: 32px;',$file_text );
57
  $file_text = str_replace('/*MARGIN-RIGHT*/', 'margin-right: 32px;',$file_text );
58
- $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.2) , 0px 0px 16px rgba(0, 0, 0, 0.2) inset;', $file_text );
59
  break;
60
  case 'slt': // Slanting
61
  $file_text = str_replace('/*WRAP*/', 'transform:skew(-10deg) rotate(1deg);-webkit-transform: skew(-10deg) rotate(1deg);-moz-transform:skew(-10deg) rotate(1deg);', $file_text );
40
  case 'ct1': // Cellophane tape center
41
  $file_text = str_replace('/*WRAP*/', 'position: relative;',$file_text );
42
  $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 );
43
+ $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.2) , 0px 0px 8px rgba(0, 0, 0, 0.2) inset;', $file_text );
44
  break;
45
  case 'ct2': // Cellophane tape left right
46
  $file_text = str_replace('/*WRAP*/', 'position: relative;',$file_text );
48
  $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 );
49
  $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 );
50
  $file_text = str_replace('/*MARGIN-RIGHT*/', 'margin-right: 25px;',$file_text );
51
+ $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.2) , 0px 0px 8px rgba(0, 0, 0, 0.2) inset;', $file_text );
52
  break;
53
  case 'ct3': // Cellophane long
54
  $file_text = str_replace('/*WRAP*/', 'position: relative;',$file_text );
55
  $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 );
56
  $file_text = str_replace('/*MARGIN-LEFT*/', 'margin-left: 32px;',$file_text );
57
  $file_text = str_replace('/*MARGIN-RIGHT*/', 'margin-right: 32px;',$file_text );
58
+ $file_text = str_replace('/*SHADOW*/', 'box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.2) , 0px 0px 8px rgba(0, 0, 0, 0.2) inset;', $file_text );
59
  break;
60
  case 'slt': // Slanting
61
  $file_text = str_replace('/*WRAP*/', 'transform:skew(-10deg) rotate(1deg);-webkit-transform: skew(-10deg) rotate(1deg);-moz-transform:skew(-10deg) rotate(1deg);', $file_text );
pz-linkcard.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Pz-LinkCard
4
  Plugin URI: http://poporon.poponet.jp/pz-linkcard
5
  Description: リンクをカード形式で表示します。
6
- Version: 1.0.0
7
  Author: poporon
8
  Author URI: http://poporon.poponet.jp
9
  License: GPLv2 or later
@@ -101,21 +101,19 @@ class Pz_LinkCard {
101
  'css-file' => null,
102
  'css-path' => null,
103
  'css-url' => null,
104
- 'use-snscache' => '1',
105
  'sns-position' => '2',
106
- 'sns-twitter' => '1',
107
- 'sns-facebook' => '1',
108
- 'sns-hatena' => '1',
109
  'link-all' => '1',
110
  'blockquote' => null,
111
  'nofollow' => null,
112
  'plugin-link' => null,
113
  'plugin-name' => 'Pz-LinkCard',
114
- 'plugin-version' => '1.0.0',
115
  'plugin-url' => 'http://poporon.poponet.jp/pz-linkcard',
116
  'pz-hbc-options' => null,
117
- 'debug-time' => null,
118
- 'saved-time' => time()
119
  );
120
  $this->options = get_option('Pz_LinkCard_options', $this->defaults );
121
 
@@ -209,6 +207,7 @@ class Pz_LinkCard {
209
  $url = html_entity_decode($url);
210
  $url = preg_replace('/^[\s \'\"‘’“”″]*(.*?)[\s \'\"‘’“”″]*$/u', '\1', $url);
211
  $url = htmlentities($url);
 
212
  }
213
  return $url;
214
  }
@@ -222,10 +221,7 @@ class Pz_LinkCard {
222
  $data = null;
223
 
224
  // リンク先URL
225
- $url = isset($atts['url']) ? $atts['url'] : null;
226
- $url = html_entity_decode($url);
227
- $url = preg_replace('/^[\s \'\"‘’“”″]*(.*?)[\s \'\"‘’“”″]*$/u', '\1', $url);
228
- $url = htmlentities($url);
229
 
230
  // 時間計測
231
  if (is_user_logged_in()) {
@@ -269,41 +265,44 @@ class Pz_LinkCard {
269
  }
270
 
271
  // URLをキーにしてDBからキャッシュ取得
272
- if (isset($url)) {
273
- $data = $this->pz_GetCache($url);
274
- if (is_wp_error($data) || !isset($data['id'])) {
275
- $data['id'] = null;
276
- $data['url_key'] = null;
277
- $data['site_name'] = null;
278
- $data['title'] = null;
279
- $data['excerpt'] = null;
280
- $data['charset'] = null;
281
- $data['thumbnail'] = null;
282
- $data['favicon'] = null;
283
- $data['result_code'] = null;
284
- $data['post_id'] = get_the_ID();
285
- $data['sns_twitter'] = -1;
286
- $data['sns_facebook'] = -1;
287
- $data['sns_hatena'] = -1;
288
- $data['uptime'] = null;
289
- $data['nexttime'] = 0;
290
- }
291
- $data_id = $data['id'];
292
- $url_key = $data['url_key'];
293
- $site_name = $data['site_name'];
294
- $title = $data['title'];
295
- $excerpt = $data['excerpt'];
296
- $charset = $data['charset'];
297
- $thumbnail_url = $data['thumbnail'];
298
- $favicon_url = $data['favicon'];
299
- $result_code = $data['result_code'];
300
- $post_id = $data['post_id'];
301
- $sns_twitter = $data['sns_twitter'];
302
- $sns_facebook = $data['sns_facebook'];
303
- $sns_hatena = $data['sns_hatena'];
304
- $uptime = $data['uptime'];
305
- $nexttime = $data['nexttime'];
306
- }
 
 
 
307
  $thumbnail = null;
308
  $favicon = null;
309
 
@@ -473,10 +472,10 @@ class Pz_LinkCard {
473
 
474
  // 取得エラーなし・取得または更新あり
475
  if (!$error && $update && $url) {
476
- if (isset($data_id)) {
477
  $data['id'] = $data_id;
478
  }
479
- if (isset($url_key)) {
480
  $data['url_key'] = $url_key;
481
  }
482
  $data['url'] = $url;
@@ -489,9 +488,9 @@ class Pz_LinkCard {
489
  $data['thumbnail'] = $thumbnail_url;
490
  $data['favicon'] = $favicon_url;
491
  $data['result_code'] = $result_code;
492
- $data['sns_twitter'] = $sns_twitter;
493
- $data['sns_facebook'] = $sns_facebook;
494
- $data['sns_hatena'] = $sns_hatena;
495
  $data['uptime'] = $uptime;
496
  $data['nexttime'] = $nexttime;
497
  if (isset($atts['force']) && $atts['force'] == true) {
@@ -505,25 +504,22 @@ class Pz_LinkCard {
505
  }
506
  }
507
 
508
- // 保存期間満了でソーシャルカウントをリセット
509
- // if (current_time('U') - $uptime > $this->options['cache-time']) {
510
- // if (current_time('U') - $uptime > 10) {
511
- if (current_time('U') > $nexttime && $result_code <= 200) {
512
- $sns_renew = true;
513
- $update_cnt = true;
514
- } else {
515
- $sns_renew = false;
516
- }
517
-
518
  // ソーシャルカウント
519
  $sns = null;
520
  $sns_info = null;
521
  $sns_title = null;
 
522
  if (!$error && (isset($this->options['sns-position']) ? $this->options['sns-position'] : null)) {
523
  $opt = array( 'timeout' => 5 );
524
 
525
- if (isset($this->options['sns-twitter'])) {
526
- $count = $sns_twitter;
 
 
 
 
 
 
527
  $count_before = $count;
528
  if ($sns_renew || $count < 0) {
529
  $result = wp_remote_get( 'http://urls.api.twitter.com/1/urls/count.json?url=' .rawurlencode($url), $opt );
@@ -535,13 +531,13 @@ class Pz_LinkCard {
535
  $count = json_decode($result['body'])->count - 0;
536
  }
537
  if ($count <> $count_before) {
538
- $sns_twitter = $count;
539
  $update_cnt = true;
540
  }
541
  }
542
  }
543
- if (isset($this->options['sns-facebook'])) {
544
- $count = $sns_facebook;
545
  $count_before = $count;
546
  if ($sns_renew || $count < 0) {
547
  $result = wp_remote_get( 'http://graph.facebook.com/?id=' .rawurlencode($url), $opt );
@@ -554,13 +550,13 @@ class Pz_LinkCard {
554
  $count = (isset($json->shares) ? isset($json->shares) : 0) - 0;
555
  }
556
  if ($count <> $count_before) {
557
- $sns_facebook = $count;
558
  $update_cnt = true;
559
  }
560
  }
561
  }
562
- if (isset($this->options['sns-hatena'])) {
563
- $count = $sns_hatena;
564
  $count_before = $count;
565
  if ($sns_renew || $count < 0) {
566
  $result = wp_remote_get( 'http://api.b.st-hatena.com/entry.count?url=' .rawurlencode($url), $opt );
@@ -572,7 +568,7 @@ class Pz_LinkCard {
572
  $count = $result['body'] - 0;
573
  }
574
  if ($count <> $count_before) {
575
- $sns_hatena = $count;
576
  $update_cnt = true;
577
  }
578
  }
@@ -580,13 +576,25 @@ class Pz_LinkCard {
580
 
581
  $sns = '<span class="linkcard-share">';
582
  if ((isset($this->options['link-all']) ? $this->options['link-all'] : null) == '1') {
583
- if ($sns_twitter > 0) $sns .= ' <span class="linkcard-sns-twitter no_icon">' .$sns_twitter .'&nbsp;tweet' .(($sns_twitter > 1) ? 's' : '').'</span>';
584
- if ($sns_facebook > 0) $sns .= ' <span class="linkcard-sns-facebook no_icon">' .$sns_facebook .'&nbsp;share' .(($sns_facebook > 1) ? 's' : '').'</span>';
585
- if ($sns_hatena > 0) $sns .= ' <span class="linkcard-sns-hatena no_icon">' .$sns_hatena .'&nbsp;user' .(($sns_hatena > 1) ? 's' : '').'</span>';
 
 
 
 
 
 
586
  } else {
587
- if ($sns_twitter > 0) $sns .= ' <a class="linkcard-sns-twitter no_icon" href="https://twitter.com/intent/tweet?url=' .rawurlencode($url).'&text='.esc_html($title).'" target="_blank">' .$sns_twitter .'&nbsp;tweet' .(($count > 1) ? 's' : '').'</a>';
588
- if ($sns_facebook > 0) $sns .= ' <a class="linkcard-sns-facebook no_icon" href="https://www.facebook.com/sharer/sharer.php?u="' .rawurlencode($url).' target="_blank">' .$sns_facebook .'&nbsp;share' .(($count > 1) ? 's' : '').'</a>';
589
- if ($sns_hatena > 0) $sns .= ' <a class="linkcard-sns-hatena no_icon" href="http://b.hatena.ne.jp/entry/' .rawurlencode($url).'" target="_blank">' .$sns_hatena .'&nbsp;user' .(($count > 1) ? 's' : '').'</a>';
 
 
 
 
 
 
590
  }
591
  $sns .= '</span>';
592
 
@@ -631,9 +639,9 @@ class Pz_LinkCard {
631
  $wpdb->update(
632
  $this->db,
633
  array(
634
- 'sns_twitter' => $sns_twitter,
635
- 'sns_facebook' => $sns_facebook,
636
- 'sns_hatena' => $sns_hatena,
637
  'uptime' => current_time('U'),
638
  'nexttime' => current_time('U') + 43200 + rand(0, 21600),
639
  ),
@@ -749,22 +757,42 @@ class Pz_LinkCard {
749
  return $tag;
750
  }
751
 
752
- public function pz_GetCache($url) {
753
  global $wpdb;
754
- return (array) $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->db WHERE url=%s", $url));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
755
  }
756
 
757
  public function pz_SetCache($data) {
758
  global $wpdb;
759
- $url = isset($data['url']) ? $data['url'] : null;
760
- if (is_null($url)) {
761
  return null;
762
  }
 
 
 
 
 
 
763
  if (!isset($data['url_key']) || is_null(isset($data['url_key'])) ) {
764
  $data['url_key'] = hash('sha256', esc_url($url), true);
765
  }
 
766
  $data['uptime'] = current_time('U');
767
- $data['nexttime'] = $data['uptime'] + 43200 + rand(0, 21600);
768
  // 更新してみる
769
  $result = $wpdb->update(
770
  $this->db,
@@ -776,6 +804,7 @@ class Pz_LinkCard {
776
  if (!$result) {
777
  $data['regist'] = current_time('mysql'); // 登録日
778
  // 更新できなかったら挿入
 
779
  $result = $wpdb->insert(
780
  $this->db,
781
  $data
@@ -785,7 +814,24 @@ class Pz_LinkCard {
785
  return null;
786
  }
787
  }
788
- return $this->pz_GetCache($url);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
789
  }
790
 
791
  function pz_GetMeta($html, $tags = null) {
@@ -865,7 +911,13 @@ class Pz_LinkCard {
865
 
866
  public function activation() {
867
  $this->options = get_option('Pz_LinkCard_options', $this->defaults);
868
- $this->options += $this->defaults;
 
 
 
 
 
 
869
  $this->options['plugin-version'] = $this->defaults['plugin-version'];
870
  update_option('Pz_LinkCard_options', $this->options);
871
 
3
  Plugin Name: Pz-LinkCard
4
  Plugin URI: http://poporon.poponet.jp/pz-linkcard
5
  Description: リンクをカード形式で表示します。
6
+ Version: 1.0.2
7
  Author: poporon
8
  Author URI: http://poporon.poponet.jp
9
  License: GPLv2 or later
101
  'css-file' => null,
102
  'css-path' => null,
103
  'css-url' => null,
 
104
  'sns-position' => '2',
105
+ 'sns-tw' => '1',
106
+ 'sns-fb' => '1',
107
+ 'sns-hb' => '1',
108
  'link-all' => '1',
109
  'blockquote' => null,
110
  'nofollow' => null,
111
  'plugin-link' => null,
112
  'plugin-name' => 'Pz-LinkCard',
113
+ 'plugin-version' => '1.0.2',
114
  'plugin-url' => 'http://poporon.poponet.jp/pz-linkcard',
115
  'pz-hbc-options' => null,
116
+ 'debug-time' => null
 
117
  );
118
  $this->options = get_option('Pz_LinkCard_options', $this->defaults );
119
 
207
  $url = html_entity_decode($url);
208
  $url = preg_replace('/^[\s \'\"‘’“”″]*(.*?)[\s \'\"‘’“”″]*$/u', '\1', $url);
209
  $url = htmlentities($url);
210
+ $url = esc_url($url); // プロトコル除外など
211
  }
212
  return $url;
213
  }
221
  $data = null;
222
 
223
  // リンク先URL
224
+ $url = isset($atts['url']) ? $this->pz_TrimURL($atts['url']) : null;
 
 
 
225
 
226
  // 時間計測
227
  if (is_user_logged_in()) {
265
  }
266
 
267
  // URLをキーにしてDBからキャッシュ取得
268
+ $data['id'] = null;
269
+ $data['url_key'] = null;
270
+ $data['site_name'] = null;
271
+ $data['title'] = null;
272
+ $data['excerpt'] = null;
273
+ $data['charset'] = null;
274
+ $data['thumbnail'] = null;
275
+ $data['favicon'] = null;
276
+ $data['result_code'] = null;
277
+ $data['post_id'] = get_the_ID();
278
+ $data['sns_twitter'] = -1;
279
+ $data['sns_facebook'] = -1;
280
+ $data['sns_hatena'] = -1;
281
+ $data['uptime'] = null;
282
+ $data['nexttime'] = 0;
283
+ if (isset($url) && $url) {
284
+ $data['url'] = $url;
285
+ $result = $this->pz_GetCache($data);
286
+ if (isset($result) && is_array($result) && isset($result['url'])) {
287
+ $data = $result;
288
+ }
289
+ }
290
+ $data_id = $data['id'];
291
+ $url_key = $data['url_key'];
292
+ $site_name = $data['site_name'];
293
+ $title = $data['title'];
294
+ $excerpt = $data['excerpt'];
295
+ $charset = $data['charset'];
296
+ $thumbnail_url = $data['thumbnail'];
297
+ $favicon_url = $data['favicon'];
298
+ $result_code = $data['result_code'];
299
+ $post_id = $data['post_id'];
300
+ $sns_tw = $data['sns_twitter'];
301
+ $sns_fb = $data['sns_facebook'];
302
+ $sns_hb = $data['sns_hatena'];
303
+ $uptime = $data['uptime'];
304
+ $nexttime = $data['nexttime'];
305
+
306
  $thumbnail = null;
307
  $favicon = null;
308
 
472
 
473
  // 取得エラーなし・取得または更新あり
474
  if (!$error && $update && $url) {
475
+ if (isset($data_id) && !is_null($data_id)) {
476
  $data['id'] = $data_id;
477
  }
478
+ if (isset($url_key) && !is_null($url_key)) {
479
  $data['url_key'] = $url_key;
480
  }
481
  $data['url'] = $url;
488
  $data['thumbnail'] = $thumbnail_url;
489
  $data['favicon'] = $favicon_url;
490
  $data['result_code'] = $result_code;
491
+ $data['sns_twitter'] = $sns_tw;
492
+ $data['sns_facebook'] = $sns_fb;
493
+ $data['sns_hatena'] = $sns_hb;
494
  $data['uptime'] = $uptime;
495
  $data['nexttime'] = $nexttime;
496
  if (isset($atts['force']) && $atts['force'] == true) {
504
  }
505
  }
506
 
 
 
 
 
 
 
 
 
 
 
507
  // ソーシャルカウント
508
  $sns = null;
509
  $sns_info = null;
510
  $sns_title = null;
511
+ $sns_renew = false;
512
  if (!$error && (isset($this->options['sns-position']) ? $this->options['sns-position'] : null)) {
513
  $opt = array( 'timeout' => 5 );
514
 
515
+ // 保存期間満了でソーシャルカウントをリセット
516
+ if (current_time('U') > $nexttime && $result_code <= 200) {
517
+ $sns_renew = true;
518
+ $update_cnt = true;
519
+ }
520
+
521
+ if (isset($this->options['sns-tw']) && !is_null($this->options['sns-tw'])) {
522
+ $count = $sns_tw;
523
  $count_before = $count;
524
  if ($sns_renew || $count < 0) {
525
  $result = wp_remote_get( 'http://urls.api.twitter.com/1/urls/count.json?url=' .rawurlencode($url), $opt );
531
  $count = json_decode($result['body'])->count - 0;
532
  }
533
  if ($count <> $count_before) {
534
+ $sns_tw = $count;
535
  $update_cnt = true;
536
  }
537
  }
538
  }
539
+ if (isset($this->options['sns-fb']) && !is_null($this->options['sns-fb'])) {
540
+ $count = $sns_fb;
541
  $count_before = $count;
542
  if ($sns_renew || $count < 0) {
543
  $result = wp_remote_get( 'http://graph.facebook.com/?id=' .rawurlencode($url), $opt );
550
  $count = (isset($json->shares) ? isset($json->shares) : 0) - 0;
551
  }
552
  if ($count <> $count_before) {
553
+ $sns_fb = $count;
554
  $update_cnt = true;
555
  }
556
  }
557
  }
558
+ if (isset($this->options['sns-hb']) && !is_null($this->options['sns-hb'])) {
559
+ $count = $sns_hb;
560
  $count_before = $count;
561
  if ($sns_renew || $count < 0) {
562
  $result = wp_remote_get( 'http://api.b.st-hatena.com/entry.count?url=' .rawurlencode($url), $opt );
568
  $count = $result['body'] - 0;
569
  }
570
  if ($count <> $count_before) {
571
+ $sns_hb = $count;
572
  $update_cnt = true;
573
  }
574
  }
576
 
577
  $sns = '<span class="linkcard-share">';
578
  if ((isset($this->options['link-all']) ? $this->options['link-all'] : null) == '1') {
579
+ if (isset($this->options['sns-tw']) && !is_null($this->options['sns-tw']) && $sns_tw > 0) {
580
+ $sns .= ' <span class="linkcard-sns-twitter no_icon">' .$sns_tw .'&nbsp;tweet' .(($sns_tw > 1) ? 's' : '').'</span>';
581
+ }
582
+ if (isset($this->options['sns-fb']) && !is_null($this->options['sns-fb']) && $sns_fb > 0) {
583
+ $sns .= ' <span class="linkcard-sns-facebook no_icon">' .$sns_fb .'&nbsp;share' .(($sns_fb > 1) ? 's' : '').'</span>';
584
+ }
585
+ if (isset($this->options['sns-hb']) && !is_null($this->options['sns-hb']) && $sns_hb > 0) {
586
+ $sns .= ' <span class="linkcard-sns-hatena no_icon">' .$sns_hb .'&nbsp;user' .(($sns_hb > 1) ? 's' : '').'</span>';
587
+ }
588
  } else {
589
+ if (isset($this->options['sns-tw']) && !is_null($this->options['sns-tw']) && $sns_tw > 0) {
590
+ $sns .= ' <a class="linkcard-sns-twitter no_icon" href="https://twitter.com/intent/tweet?url=' .rawurlencode($url).'&text='.esc_html($title).'" target="_blank">' .$sns_tw .'&nbsp;tweet' .(($count > 1) ? 's' : '').'</a>';
591
+ }
592
+ if (isset($this->options['sns-fb']) && !is_null($this->options['sns-fb']) && $sns_fb > 0) {
593
+ $sns .= ' <a class="linkcard-sns-facebook no_icon" href="https://www.facebook.com/sharer/sharer.php?u="' .rawurlencode($url).' target="_blank">' .$sns_fb .'&nbsp;share' .(($count > 1) ? 's' : '').'</a>';
594
+ }
595
+ if (isset($this->options['sns-hb']) && !is_null($this->options['sns-hb']) && $sns_hb > 0) {
596
+ $sns .= ' <a class="linkcard-sns-hatena no_icon" href="http://b.hatena.ne.jp/entry/' .rawurlencode($url).'" target="_blank">' .$sns_hb .'&nbsp;user' .(($count > 1) ? 's' : '').'</a>';
597
+ }
598
  }
599
  $sns .= '</span>';
600
 
639
  $wpdb->update(
640
  $this->db,
641
  array(
642
+ 'sns_twitter' => $sns_tw,
643
+ 'sns_facebook' => $sns_fb,
644
+ 'sns_hatena' => $sns_hb,
645
  'uptime' => current_time('U'),
646
  'nexttime' => current_time('U') + 43200 + rand(0, 21600),
647
  ),
757
  return $tag;
758
  }
759
 
760
+ public function pz_GetCache($data) {
761
  global $wpdb;
762
+ if (!isset($data) || !is_array($data)) {
763
+ return null;
764
+ }
765
+ if (isset($data['url']) && !is_null($data['url'])) {
766
+ $url = $this->pz_TrimURL($data['url']);
767
+ $data = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->db WHERE url=%s", $url));
768
+ } elseif (isset($data['id']) && !is_null($data['id'])) {
769
+ $id = intval($data['id']);
770
+ $data = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->db WHERE id=%d", $id));
771
+ } else {
772
+ return null;
773
+ }
774
+ if (is_wp_error($data)) {
775
+ return null;
776
+ }
777
+ return (array) $data; // Arrayに直して戻す
778
  }
779
 
780
  public function pz_SetCache($data) {
781
  global $wpdb;
782
+ if (!isset($data) || !is_array($data)) {
 
783
  return null;
784
  }
785
+ if (!isset($data['url']) || is_null($data['url'])) {
786
+ return null;
787
+ }
788
+ $url = $this->pz_TrimURL($data['url']);
789
+ $data['url'] = $url;
790
+
791
  if (!isset($data['url_key']) || is_null(isset($data['url_key'])) ) {
792
  $data['url_key'] = hash('sha256', esc_url($url), true);
793
  }
794
+
795
  $data['uptime'] = current_time('U');
 
796
  // 更新してみる
797
  $result = $wpdb->update(
798
  $this->db,
804
  if (!$result) {
805
  $data['regist'] = current_time('mysql'); // 登録日
806
  // 更新できなかったら挿入
807
+ unset($data['id']);
808
  $result = $wpdb->insert(
809
  $this->db,
810
  $data
814
  return null;
815
  }
816
  }
817
+ return $this->pz_GetCache($data);
818
+ }
819
+
820
+ public function pz_DelCache($data) {
821
+ global $wpdb;
822
+ if (!isset($data) || !is_array($data)) {
823
+ return null;
824
+ }
825
+ if (isset($data['url']) && !is_null($data['url'])) {
826
+ $url = $this->pz_TrimURL($data['url']);
827
+ $result = $wpdb->delete($this->db, array('url' => $url), array('%s') );
828
+ return $result;
829
+ } elseif (isset($data['id']) && !is_null($data['id'])) {
830
+ $data_id = intval($data['id']);
831
+ $result = $wpdb->delete($this->db, array('id' => $data_id), array('%d') );
832
+ return $result;
833
+ }
834
+ return null;
835
  }
836
 
837
  function pz_GetMeta($html, $tags = null) {
911
 
912
  public function activation() {
913
  $this->options = get_option('Pz_LinkCard_options', $this->defaults);
914
+ if ($this->options['plugin-version'] < '1.0.2') {
915
+ $this->options['sns-tw'] =$this->options['sns-twitter'];
916
+ $this->options['sns-fb'] =$this->options['sns-facebook'];
917
+ $this->options['sns-hb'] =$this->options['sns-hatena'];
918
+ }
919
+ // $this->options += $this->defaults;
920
+
921
  $this->options['plugin-version'] = $this->defaults['plugin-version'];
922
  update_option('Pz_LinkCard_options', $this->options);
923
 
readme.txt CHANGED
@@ -35,9 +35,7 @@ The goodbye to the text-only link.
35
  (ショートコード内にURLを記述した場合、ピンバックは飛びません。ピンバックを使用したい方は記事中にテキストリンクを張るなどで対応してください。)
36
 
37
 
38
- まだ成熟したプラグインでは無いので、ご意見やご要望があればありがたくいただきたいと思います。
39
-
40
- しかしながら、趣味で行っているプログラムであるため、対応能力にも限界があることを了承いただけると幸いです。
41
 
42
 
43
  == Installation ==
@@ -46,6 +44,7 @@ WordPressダッシュボードからのインストール
46
 
47
  (From your WordPress dashboard)
48
 
 
49
  1. 「プラグイン」→「新規追加」を選びます
50
 
51
  (Plugins menu > Add New)
@@ -58,7 +57,6 @@ WordPressダッシュボードからのインストール
58
 
59
  (Install)
60
 
61
-
62
  4. 「有効化する」を選び、有効化します
63
 
64
  (Activate)
@@ -156,6 +154,14 @@ WordPressピンバックは記事中にリンクを直接記述しないと飛
156
 
157
  == Changelog ==
158
 
 
 
 
 
 
 
 
 
159
  = 1.0.0 =
160
  * 全体的なプログラムの見直し。
161
  * URLが空欄などの場合の対応。
35
  (ショートコード内にURLを記述した場合、ピンバックは飛びません。ピンバックを使用したい方は記事中にテキストリンクを張るなどで対応してください。)
36
 
37
 
38
+ まだ成熟したプラグインでは無いので、ご意見やご要望があればなるべくお応えしていきたいと思います。
 
 
39
 
40
 
41
  == Installation ==
44
 
45
  (From your WordPress dashboard)
46
 
47
+
48
  1. 「プラグイン」→「新規追加」を選びます
49
 
50
  (Plugins menu > Add New)
57
 
58
  (Install)
59
 
 
60
  4. 「有効化する」を選び、有効化します
61
 
62
  (Activate)
154
 
155
  == Changelog ==
156
 
157
+ = 1.0.2 =
158
+ * 「カード管理」でキャッシュを編集したとき、一部の文字をエスケープしていなかったのを修正。
159
+ * バージョンアップの度に一部のパラメータがデフォルトに戻らないように修正。
160
+ * プログラム内でのキャッシュの読み書き方法の改善。
161
+
162
+ = 1.0.1 =
163
+ * 「カード管理」でキャッシュを編集したとき、内部IDがクリアされてしまう不具合を修正。
164
+
165
  = 1.0.0 =
166
  * 全体的なプログラムの見直し。
167
  * URLが空欄などの場合の対応。