SNS Count Cache - Version 1.0.0

Version Description

  • Added: function to retrieve follower count of OneSignal.
  • Fixed: Facebook share count is not retrieved and cached.
  • Removed: Function to retrieve Google+ share count because the count is no longer provided.
  • Fixed: Facebook access token can not be obtained in the setting page.

=

Download this release

Release Info

Developer marubon
Plugin Icon SNS Count Cache
Version 1.0.0
Comparing to
See all releases

Code changes from version 0.11.1 to 1.0.0

Files changed (90) hide show
  1. css/sns-count-cache.css +4 -0
  2. includes/admin-cache-status.php +228 -214
  3. includes/admin-dashboard-widget.php +204 -199
  4. includes/admin-dashboard.php +221 -216
  5. includes/admin-help.php +129 -129
  6. includes/admin-hot-content.php +251 -248
  7. includes/admin-notice.php +17 -13
  8. includes/admin-setting.php +2284 -2201
  9. includes/admin-share-count.php +344 -321
  10. includes/class-crypt-blowfish.php +0 -272
  11. includes/class-default-key.php +0 -319
  12. includes/class-scc-analytical-engline.php +30 -15
  13. includes/class-scc-cache-engine.php +38 -20
  14. includes/class-scc-cache.php +59 -0
  15. includes/class-scc-common-data-export-engine.php +124 -81
  16. includes/class-scc-common-job-reset-engine.php +63 -27
  17. includes/class-scc-common-util.php +0 -663
  18. includes/class-scc-crawl-strategy.php +121 -81
  19. includes/class-scc-crawler.php +78 -50
  20. includes/class-scc-crypt.php +104 -0
  21. includes/class-scc-engine.php +45 -29
  22. includes/class-scc-export-engine.php +12 -5
  23. includes/class-scc-file.php +72 -0
  24. includes/class-scc-follow-analytical-engine.php +125 -75
  25. includes/class-scc-follow-base-cache-engine.php +102 -50
  26. includes/class-scc-follow-cache-engine.php +71 -49
  27. includes/class-scc-follow-crawl-strategy-factory.php +22 -20
  28. includes/class-scc-follow-crawler.php +238 -98
  29. includes/class-scc-follow-facebook-crawl-strategy.php +191 -0
  30. includes/class-scc-follow-facebook-strategy.php +0 -138
  31. includes/class-scc-follow-feedly-crawl-strategy.php +178 -0
  32. includes/class-scc-follow-feedly-strategy.php +0 -130
  33. includes/class-scc-follow-instagram-crawl-strategy.php +183 -0
  34. includes/class-scc-follow-instagram-strategy.php +0 -132
  35. includes/class-scc-follow-lazy-cache-engine.php +85 -41
  36. includes/class-scc-follow-onesignal-crawl-strategy.php +189 -0
  37. includes/class-scc-follow-push7-crawl-strategy.php +180 -0
  38. includes/class-scc-follow-push7-strategy.php +0 -128
  39. includes/class-scc-follow-restore-cache-engine.php +70 -42
  40. includes/class-scc-follow-second-cache-engine.php +83 -41
  41. includes/{class-scc-follow-twitter-strategy.php → class-scc-follow-twitter-crawl-strategy.php} +95 -45
  42. includes/class-scc-format.php +157 -0
  43. includes/class-scc-hash.php +56 -0
  44. includes/class-scc-http.php +300 -0
  45. includes/class-scc-logger.php +58 -0
  46. includes/class-scc-oauth.php +340 -0
  47. includes/class-scc-share-analytical-engine.php +183 -118
  48. includes/class-scc-share-app-status-engine.php +250 -0
  49. includes/class-scc-share-base-cache-engine.php +191 -93
  50. includes/class-scc-share-cache-engine.php +123 -87
  51. includes/class-scc-share-crawl-strategy-factory.php +23 -26
  52. includes/class-scc-share-crawler.php +257 -103
  53. includes/class-scc-share-facebook-crawl-strategy.php +233 -0
  54. includes/class-scc-share-facebook-strategy.php +0 -136
  55. includes/class-scc-share-google-crawl-strategy.php +188 -0
  56. includes/class-scc-share-google-strategy.php +0 -130
  57. includes/class-scc-share-hatebu-crawl-strategy.php +176 -0
  58. includes/class-scc-share-hatebu-strategy.php +0 -126
  59. includes/class-scc-share-lazy-cache-engine.php +119 -58
  60. includes/class-scc-share-linkedin-crawl-strategy.php +180 -0
  61. includes/class-scc-share-linkedin-strategy.php +0 -140
  62. includes/class-scc-share-pinterest-crawl-strategy.php +182 -0
  63. includes/class-scc-share-pinterest-strategy.php +0 -134
  64. includes/class-scc-share-pocket-crawl-strategy.php +184 -0
  65. includes/class-scc-share-pocket-strategy.php +0 -138
  66. includes/class-scc-share-restore-cache-engine.php +101 -61
  67. includes/class-scc-share-rush-cache-engine.php +146 -72
  68. includes/class-scc-share-second-cache-engine.php +125 -60
  69. includes/class-scc-share-twitter-crawl-strategy.php +233 -0
  70. includes/class-scc-share-twitter-strategy.php +0 -194
  71. includes/class-scc-sleep-throttle.php +45 -18
  72. includes/{class-scc-wp-cron-util.php → class-scc-wp-cron.php} +49 -42
  73. includes/download.php +10 -8
  74. includes/interface-scc-order.php +28 -3
  75. index.php +5 -5
  76. js/jquery.floatThead.min.js +2 -0
  77. js/jquery.scc-cache-info.js +10 -0
  78. js/jquery.scc-cache-info.min.js +2 -1
  79. js/jquery.scc-table.js +11 -0
  80. js/jquery.scc-table.min.js +1 -0
  81. languages/sns-count-cache-ja.mo +0 -0
  82. languages/sns-count-cache-ja.po +643 -576
  83. readme.txt +20 -7
  84. screenshot-1.png +0 -0
  85. screenshot-2.png +0 -0
  86. screenshot-3.png +0 -0
  87. screenshot-4.png +0 -0
  88. screenshot-5.png +0 -0
  89. screenshot-6.png +0 -0
  90. sns-count-cache.php +1586 -672
css/sns-count-cache.css CHANGED
@@ -27,6 +27,10 @@
27
  font-size: 13px;
28
  }
29
 
 
 
 
 
30
  .sns-cnt-cache .view-table tr:nth-child(odd) {
31
  background-color: #ffffff;
32
  }
27
  font-size: 13px;
28
  }
29
 
30
+ .sns-cnt-cache .view-table tbody {
31
+ border-bottom: 1px solid #000;
32
+ }
33
+
34
  .sns-cnt-cache .view-table tr:nth-child(odd) {
35
  background-color: #ffffff;
36
  }
includes/admin-cache-status.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  admin-cache-status.php
4
 
5
  Description: Option page implementation
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,225 +27,207 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
- if ( ! defined( 'ABSPATH' ) ) exit(); // Exit if accessed directly
 
 
 
 
31
 
32
- $posts_per_page = 50;
33
 
 
 
 
34
  $paged = (int) 1;
 
35
 
36
- if ( isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) && $_GET['paged'] > 0 ) {
37
- $paged = (int) $_GET['paged'];
38
- } else {
39
- $paged = (int) 1;
40
- }
41
 
42
- if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], __FILE__ ) ) {
43
- if ( current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
44
- if ( isset( $_GET["action"] ) && $_GET["action"] === 'cache' ) {
45
- if ( isset( $_GET["post_id"] ) ) {
46
- $post_id = $_GET["post_id"];
47
- $this->cache_engines[self::REF_SHARE_BASE]->direct_cache( $post_id, true );
48
- //wp_safe_redirect( menu_page_url( 'scc-cache-status', false ) );
49
  }
50
  }
51
  }
52
  }
53
-
54
- $query_args = array(
55
- 'post_type' => $this->share_base_cache_post_types,
56
- 'post_status' => 'publish',
57
- 'posts_per_page' => $posts_per_page,
58
- 'paged' => $paged,
59
- 'update_post_term_cache' => false
60
- );
61
-
62
- $posts_query = new WP_Query( $query_args );
63
- ?>
64
- <div class="wrap">
65
- <h2><a href="admin.php?page=scc-cache-status"><?php _e( 'SNS Count Cache', self::DOMAIN ); ?></a></h2>
66
- <div class="sns-cnt-cache">
67
- <h3 class="nav-tab-wrapper">
68
- <a class="nav-tab" href="admin.php?page=scc-dashboard"><?php _e( 'Dashboard', self::DOMAIN ); ?></a>
69
- <a class="nav-tab nav-tab-active" href="admin.php?page=scc-cache-status"><?php _e( 'Cache Status', self::DOMAIN ); ?></a>
70
- <a class="nav-tab" href="admin.php?page=scc-share-count"><?php _e( 'Share Count', self::DOMAIN ); ?></a>
71
- <?php if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) { ?>
72
- <a class="nav-tab" href="admin.php?page=scc-hot-content"><?php _e( 'Hot Content', self::DOMAIN ); ?></a>
73
- <?php } ?>
74
- <a class="nav-tab" href="admin.php?page=scc-setting"><?php _e( 'Setting', self::DOMAIN ); ?></a>
75
- <a class="nav-tab" href="admin.php?page=scc-help"><?php _e( 'Help', self::DOMAIN ); ?></a>
76
- </h3>
77
- <div class="metabox-holder">
78
- <div id="share-site-summary" class="postbox">
79
- <div class="handlediv" title="Click to toggle"><br></div>
80
- <h3 class="hndle"><span><?php _e( 'Cache Status', self::DOMAIN ); ?></span></h3>
81
- <div class="inside">
82
- <table class="view-table">
83
- <thead>
84
- <tr>
85
- <th>No.</th>
86
- <th><?php _e( 'Content', self::DOMAIN ); ?></th>
87
- <th><?php _e( 'Primary Cache', self::DOMAIN ); ?></th>
88
- <th><?php _e( 'Secondary Cache', self::DOMAIN ); ?></th>
89
- <th><?php _e( 'Crawl Date', self::DOMAIN ); ?></th>
90
- <th></th>
91
- </tr>
92
- </thead>
93
- <tbody>
94
- <?php
95
- $count = ( $paged - 1 ) * $posts_per_page + 1;
96
-
97
- $share_base_cache_target = $this->share_base_cache_target ;
98
- unset( $share_base_cache_target[self::REF_CRAWL_DATE] );
99
-
100
- if ( $paged === 1 ) {
101
- ?>
102
- <tr class="home">
103
- <td><?php echo '-'; ?></td>
104
- <td><a href="<?php echo esc_url( home_url( '/' ) ); ?>" target="_blank"><?php echo esc_html( home_url( '/' ) ); ?></a></td>
 
 
 
 
105
  <?php
106
- $share_base_cache_target = $this->share_base_cache_target ;
107
-
108
- unset( $share_base_cache_target[self::REF_CRAWL_DATE] );
109
 
110
- $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( 'home' );
111
 
112
- if ( false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
113
- $full_cache_flag = true;
114
- $partial_cache_flag = false;
115
 
116
- foreach ( $share_base_cache_target as $sns => $active ) {
117
- if ( $active ) {
118
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
119
- $partial_cache_flag = true;
120
- } else {
121
- $full_cache_flag = false;
122
- }
123
- }
124
- }
125
-
126
- if ( $partial_cache_flag && $full_cache_flag ) {
127
- echo '<td class="full-cache">';
128
- _e( 'full cache', self::DOMAIN );
129
- echo '</td>';
130
- } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
131
- echo '<td class="partial-cache">';
132
- _e( 'partial cache', self::DOMAIN );
133
- echo '</td>';
134
- } else {
135
- echo '<td class="no-cache">';
136
- _e( 'no cache', self::DOMAIN );
137
- echo '</td>';
138
- }
139
- } else {
140
- SCC_Common_Util::log( '[' . __METHOD__ . '] : no transient' );
141
- echo '<td class="no-cache">';
142
- _e( 'no cache', self::DOMAIN );
143
- echo '</td>';
144
- }
145
 
 
146
  $full_cache_flag = true;
147
  $partial_cache_flag = false;
148
 
149
- $option_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( 'home' );
150
-
151
- if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
152
- foreach ( $share_base_cache_target as $sns => $active ) {
153
- if ( $active ) {
154
- if ( $sns_counts[$sns] >= 0 ){
155
- $partial_cache_flag = true;
156
- } else {
157
- $full_cache_flag = false;
158
- }
159
  }
160
  }
161
- } else {
162
- $full_cache_flag = false;
163
  }
164
 
165
  if ( $partial_cache_flag && $full_cache_flag ) {
166
  echo '<td class="full-cache">';
167
- _e( 'full cache', self::DOMAIN );
168
  echo '</td>';
169
  } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
170
  echo '<td class="partial-cache">';
171
- _e( 'partial cache', self::DOMAIN );
172
  echo '</td>';
173
  } else {
174
  echo '<td class="no-cache">';
175
- _e( 'no cache', self::DOMAIN );
176
- echo '</td>';
177
- }
178
- if ( isset( $sns_counts[self::REF_CRAWL_DATE] ) && $sns_counts[self::REF_CRAWL_DATE] && $sns_counts[self::REF_CRAWL_DATE] !== -1 ) {
179
- echo '<td class="full-cache">';
180
- echo esc_html( $sns_counts[self::REF_CRAWL_DATE] );
181
- echo '</td>';
182
- } else {
183
- echo '<td class="no-cache">';
184
- _e( 'no data', self::DOMAIN );
185
  echo '</td>';
186
  }
 
 
 
 
 
 
187
 
188
- $nonce = wp_create_nonce( __FILE__ );
189
- $cache_url = esc_url( 'admin.php?page=scc-cache-status&action=cache&post_id=' . 'home' . '&_wpnonce=' . $nonce . '&paged=' . $paged );
190
- ?>
191
- <td><a class="button button-small" href="<?php echo $cache_url ?>"><?php _e( 'Cache', self::DOMAIN ); ?></a></td>
192
- </tr>
193
- <?php
194
- }
195
- if ( $posts_query->have_posts() ) {
196
- while ( $posts_query->have_posts() ) {
197
- $posts_query->the_post();
198
- ?>
199
- <tr>
200
- <td><?php echo $count; ?></td>
201
- <td><a href="<?php echo esc_url( get_permalink( get_the_ID() ) ); ?>" target="_blank"><?php echo esc_html( get_permalink( get_the_ID() ) ); ?></a></td>
202
- <?php
203
- $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( get_the_ID() );
204
 
205
- if ( false === ( $sns_counts = get_transient( $transient_id ) ) ) {
206
- echo '<td class="no-cache">';
207
- _e( 'no cache', self::DOMAIN );
208
- echo '</td>';
209
- } else {
210
- $full_cache_flag = true;
211
- $partial_cache_flag = false;
212
-
213
- foreach ( $share_base_cache_target as $sns => $active ) {
214
- if ( $active ) {
215
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
216
- $partial_cache_flag = true;
217
- } else {
218
- $full_cache_flag = false;
219
- }
220
- }
221
- }
222
 
223
- if ( $partial_cache_flag && $full_cache_flag ) {
224
- echo '<td class="full-cache">';
225
- _e( 'full cache', self::DOMAIN );
226
- echo '</td>';
227
- } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
228
- echo '<td class="partial-cache">';
229
- _e( 'partial cache', self::DOMAIN );
230
- echo '</td>';
231
- } else {
232
- echo '<td class="no-cache">';
233
- _e( 'no cache', self::DOMAIN );
234
- echo '</td>';
235
  }
236
  }
 
 
 
237
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  $full_cache_flag = true;
239
  $partial_cache_flag = false;
240
 
241
- foreach ( $share_base_cache_target as $sns => $active ) {
242
  if ( $active ) {
243
- $meta_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( $sns );
244
-
245
- $sns_count = get_post_meta( get_the_ID(), $meta_key, true );
246
-
247
- if ( isset( $sns_count ) && $sns_count !== '' && $sns_count >= 0 ) {
248
- $partial_cache_flag = true;
249
  } else {
250
  $full_cache_flag = false;
251
  }
@@ -254,57 +236,89 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
254
 
255
  if ( $partial_cache_flag && $full_cache_flag ) {
256
  echo '<td class="full-cache">';
257
- _e( 'full cache', self::DOMAIN );
258
  echo '</td>';
259
  } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
260
  echo '<td class="partial-cache">';
261
- _e( 'partial cache', self::DOMAIN );
262
  echo '</td>';
263
  } else {
264
  echo '<td class="no-cache">';
265
- _e( 'no cache', self::DOMAIN );
266
  echo '</td>';
267
  }
 
268
 
269
- if ( isset( $sns_counts[self::REF_CRAWL_DATE] ) ) {
270
- echo '<td class="full-cache">';
271
- echo esc_html( $sns_counts[self::REF_CRAWL_DATE] );
272
- echo '</td>';
273
- } else {
274
- $meta_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( self::REF_CRAWL_DATE );
275
 
276
- $crawl_date = get_post_meta( get_the_ID(), $meta_key, true );
277
 
278
- if ( isset( $crawl_date ) && $crawl_date !== '' && $crawl_date !== '-1' ) {
279
- echo '<td class="full-cache">';
280
- echo esc_html( $crawl_date );
281
- echo '</td>';
282
  } else {
283
- echo '<td class="no-cache">';
284
- _e( 'no data', self::DOMAIN );
285
- echo '</td>';
286
  }
287
  }
 
288
 
289
- $nonce = wp_create_nonce( __FILE__ );
290
- $cache_url = esc_url( 'admin.php?page=scc-cache-status&action=cache&post_id=' . get_the_ID() . '&_wpnonce=' . $nonce . '&paged=' . $paged );
291
- ?>
292
- <td><a class="button button-small" href="<?php echo $cache_url ?>"><?php _e( 'Cache', self::DOMAIN ); ?></a></td>
293
- </tr>
294
- <?php
295
- ++$count;
 
 
 
 
 
296
  }
297
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
  ?>
299
- </tbody>
300
- </table>
301
- <?php
302
- $this->pagination( $posts_query->max_num_pages, '', $paged, false );
303
-
304
- wp_reset_postdata();
305
- ?>
306
- </div>
307
  </div>
308
  </div>
309
  </div>
310
  </div>
 
1
  <?php
2
+ /**
3
  admin-cache-status.php
4
 
5
  Description: Option page implementation
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ if ( ! defined( 'ABSPATH' ) ) {
31
+ exit(); // Exit if accessed directly
32
+ }
33
+
34
+ $posts_per_page = 50;
35
 
36
+ $paged = (int) 1;
37
 
38
+ if ( isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) && 0 < $_GET['paged'] ) {
39
+ $paged = (int) wp_unslash( $_GET['paged'] );
40
+ } else {
41
  $paged = (int) 1;
42
+ }
43
 
44
+ if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( wp_unslash( $_GET['_wpnonce'] ), __FILE__ ) ) {
45
+ if ( current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
46
+ if ( isset( $_GET['action'] ) && 'cache' === wp_unslash( $_GET['action'] ) ) {
47
+ if ( isset( $_GET['post_id'] ) ) {
48
+ $post_id = wp_unslash( $_GET['post_id'] );
49
 
50
+ if ( 'home' === $post_id || is_numeric( $post_id ) ) {
51
+ $this->cache_engines[ self::REF_SHARE_BASE ]->direct_cache( $post_id, true );
 
 
 
 
 
52
  }
53
  }
54
  }
55
  }
56
+ }
57
+
58
+ $query_args = array(
59
+ 'post_type' => $this->share_base_cache_post_types,
60
+ 'post_status' => 'publish',
61
+ 'posts_per_page' => $posts_per_page,
62
+ 'paged' => $paged,
63
+ 'update_post_term_cache' => false,
64
+ );
65
+
66
+ $posts_query = new WP_Query( $query_args );
67
+ ?>
68
+ <div class="wrap">
69
+ <h2><a href="admin.php?page=scc-cache-status"><?php esc_html_e( 'SNS Count Cache', self::DOMAIN ); ?></a></h2>
70
+ <div class="sns-cnt-cache">
71
+ <h3 class="nav-tab-wrapper">
72
+ <a class="nav-tab" href="admin.php?page=scc-dashboard"><?php esc_html_e( 'Dashboard', self::DOMAIN ); ?></a>
73
+ <a class="nav-tab nav-tab-active" href="admin.php?page=scc-cache-status"><?php esc_html_e( 'Cache Status', self::DOMAIN ); ?></a>
74
+ <a class="nav-tab" href="admin.php?page=scc-share-count"><?php esc_html_e( 'Share Count', self::DOMAIN ); ?></a>
75
+ <?php if ( self::OPT_SHARE_VARIATION_ANALYSIS_NONE !== $this->share_variation_analysis_mode ) { ?>
76
+ <a class="nav-tab" href="admin.php?page=scc-hot-content"><?php esc_html_e( 'Hot Content', self::DOMAIN ); ?></a>
77
+ <?php } ?>
78
+ <a class="nav-tab" href="admin.php?page=scc-setting"><?php esc_html_e( 'Setting', self::DOMAIN ); ?></a>
79
+ <a class="nav-tab" href="admin.php?page=scc-help"><?php esc_html_e( 'Help', self::DOMAIN ); ?></a>
80
+ </h3>
81
+ <div class="metabox-holder">
82
+ <div id="share-site-summary" class="postbox">
83
+ <div class="handlediv" title="Click to toggle"><br></div>
84
+ <h3 class="hndle"><span><?php esc_html_e( 'Cache Status', self::DOMAIN ); ?></span></h3>
85
+ <div class="inside">
86
+ <?php
87
+ $this->pagination( $posts_query->max_num_pages, '', $paged, false );
88
+ ?>
89
+ <table class="tfloat view-table">
90
+ <thead>
91
+ <tr>
92
+ <th>No.</th>
93
+ <th><?php esc_html_e( 'Content', self::DOMAIN ); ?></th>
94
+ <th><?php esc_html_e( 'Primary Cache', self::DOMAIN ); ?></th>
95
+ <th><?php esc_html_e( 'Secondary Cache', self::DOMAIN ); ?></th>
96
+ <th><?php esc_html_e( 'Crawl Date', self::DOMAIN ); ?></th>
97
+ <th></th>
98
+ </tr>
99
+ </thead>
100
+ <tbody>
101
+ <?php
102
+ $count = ( $paged - 1 ) * $posts_per_page + 1;
103
+
104
+ $share_base_cache_target = $this->share_base_cache_target ;
105
+ unset( $share_base_cache_target[ self::REF_CRAWL_DATE ] );
106
+
107
+ if ( 1 === $paged ) {
108
+ ?>
109
+ <tr class="home">
110
+ <td><?php echo '-'; ?></td>
111
+ <td><a href="<?php echo esc_url( home_url( '/' ) ); ?>" target="_blank"><?php echo esc_html( home_url( '/' ) ); ?></a></td>
112
  <?php
113
+ $share_base_cache_target = $this->share_base_cache_target ;
 
 
114
 
115
+ unset( $share_base_cache_target[ self::REF_CRAWL_DATE ] );
116
 
117
+ $transient_id = $this->cache_engines[ self::REF_SHARE_BASE ]->get_cache_key( 'home' );
 
 
118
 
119
+ $sns_counts = get_transient( $transient_id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
 
121
+ if ( false !== $sns_counts ) {
122
  $full_cache_flag = true;
123
  $partial_cache_flag = false;
124
 
125
+ foreach ( $share_base_cache_target as $sns => $active ) {
126
+ if ( $active ) {
127
+ if ( SCC_Cache::has_value( $sns_counts[ $sns ] ) && 0 <= $sns_counts[ $sns ] ) {
128
+ $partial_cache_flag = true;
129
+ } else {
130
+ $full_cache_flag = false;
 
 
 
 
131
  }
132
  }
 
 
133
  }
134
 
135
  if ( $partial_cache_flag && $full_cache_flag ) {
136
  echo '<td class="full-cache">';
137
+ esc_html_e( 'full cache', self::DOMAIN );
138
  echo '</td>';
139
  } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
140
  echo '<td class="partial-cache">';
141
+ esc_html_e( 'partial cache', self::DOMAIN );
142
  echo '</td>';
143
  } else {
144
  echo '<td class="no-cache">';
145
+ esc_html_e( 'no cache', self::DOMAIN );
 
 
 
 
 
 
 
 
 
146
  echo '</td>';
147
  }
148
+ } else {
149
+ SCC_Logger::log( '[' . __METHOD__ . '] : no transient' );
150
+ echo '<td class="no-cache">';
151
+ esc_html_e( 'no cache', self::DOMAIN );
152
+ echo '</td>';
153
+ }
154
 
155
+ $full_cache_flag = true;
156
+ $partial_cache_flag = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
+ $option_key = $this->cache_engines[ self::REF_SHARE_2ND ]->get_cache_key( 'home' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
 
160
+ $sns_counts = get_option( $option_key );
161
+
162
+ if ( false !== $sns_counts ) {
163
+ foreach ( $share_base_cache_target as $sns => $active ) {
164
+ if ( $active ) {
165
+ if ( SCC_Cache::has_value( $sns_counts[ $sns ] ) && 0 <= $sns_counts[ $sns ] ) {
166
+ $partial_cache_flag = true;
167
+ } else {
168
+ $full_cache_flag = false;
169
+ }
 
 
170
  }
171
  }
172
+ } else {
173
+ $full_cache_flag = false;
174
+ }
175
 
176
+ if ( $partial_cache_flag && $full_cache_flag ) {
177
+ echo '<td class="full-cache">';
178
+ esc_html_e( 'full cache', self::DOMAIN );
179
+ echo '</td>';
180
+ } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
181
+ echo '<td class="partial-cache">';
182
+ esc_html_e( 'partial cache', self::DOMAIN );
183
+ echo '</td>';
184
+ } else {
185
+ echo '<td class="no-cache">';
186
+ esc_html_e( 'no cache', self::DOMAIN );
187
+ echo '</td>';
188
+ }
189
+
190
+ if ( SCC_Cache::has_value( $sns_counts[ self::REF_CRAWL_DATE ] ) && -1 != $sns_counts[ self::REF_CRAWL_DATE ] ) {
191
+ echo '<td class="full-cache">';
192
+ echo esc_html( $sns_counts[ self::REF_CRAWL_DATE ] );
193
+ echo '</td>';
194
+ } else {
195
+ echo '<td class="no-cache">';
196
+ esc_html_e( 'no data', self::DOMAIN );
197
+ echo '</td>';
198
+ }
199
+
200
+ $nonce = wp_create_nonce( __FILE__ );
201
+ $cache_url = 'admin.php?page=scc-cache-status&action=cache&post_id=home&_wpnonce=' . $nonce . '&paged=' . $paged;
202
+ ?>
203
+ <td><a class="button button-small" href="<?php echo esc_url( $cache_url ); ?>"><?php esc_html_e( 'Cache', self::DOMAIN ); ?></a></td>
204
+ </tr>
205
+ <?php
206
+ } // End if().
207
+ if ( $posts_query->have_posts() ) {
208
+ while ( $posts_query->have_posts() ) {
209
+ $posts_query->the_post();
210
+ ?>
211
+ <tr>
212
+ <td><?php echo esc_html( $count ); ?></td>
213
+ <td><a href="<?php echo esc_url( get_permalink( get_the_ID() ) ); ?>" target="_blank"><?php echo esc_html( get_permalink( get_the_ID() ) ); ?></a></td>
214
+ <?php
215
+ $transient_id = $this->cache_engines[ self::REF_SHARE_BASE ]->get_cache_key( get_the_ID() );
216
+
217
+ $sns_counts = get_transient( $transient_id );
218
+
219
+ if ( false === $sns_counts ) {
220
+ echo '<td class="no-cache">';
221
+ esc_html_e( 'no cache', self::DOMAIN );
222
+ echo '</td>';
223
+ } else {
224
  $full_cache_flag = true;
225
  $partial_cache_flag = false;
226
 
227
+ foreach ( $share_base_cache_target as $sns => $active ) {
228
  if ( $active ) {
229
+ if ( SCC_Cache::has_value( $sns_counts[ $sns ] ) && 0 <= $sns_counts[ $sns ] ) {
230
+ $partial_cache_flag = true;
 
 
 
 
231
  } else {
232
  $full_cache_flag = false;
233
  }
236
 
237
  if ( $partial_cache_flag && $full_cache_flag ) {
238
  echo '<td class="full-cache">';
239
+ esc_html_e( 'full cache', self::DOMAIN );
240
  echo '</td>';
241
  } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
242
  echo '<td class="partial-cache">';
243
+ esc_html_e( 'partial cache', self::DOMAIN );
244
  echo '</td>';
245
  } else {
246
  echo '<td class="no-cache">';
247
+ esc_html_e( 'no cache', self::DOMAIN );
248
  echo '</td>';
249
  }
250
+ }
251
 
252
+ $full_cache_flag = true;
253
+ $partial_cache_flag = false;
254
+
255
+ foreach ( $share_base_cache_target as $sns => $active ) {
256
+ if ( $active ) {
257
+ $meta_key = $this->cache_engines[ self::REF_SHARE_2ND ]->get_cache_key( $sns );
258
 
259
+ $sns_count = get_post_meta( get_the_ID(), $meta_key, true );
260
 
261
+ if ( SCC_Cache::has_value( $sns_count ) && 0 <= $sns_count ) {
262
+ $partial_cache_flag = true;
 
 
263
  } else {
264
+ $full_cache_flag = false;
 
 
265
  }
266
  }
267
+ }
268
 
269
+ if ( $partial_cache_flag && $full_cache_flag ) {
270
+ echo '<td class="full-cache">';
271
+ esc_html_e( 'full cache', self::DOMAIN );
272
+ echo '</td>';
273
+ } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
274
+ echo '<td class="partial-cache">';
275
+ esc_html_e( 'partial cache', self::DOMAIN );
276
+ echo '</td>';
277
+ } else {
278
+ echo '<td class="no-cache">';
279
+ esc_html_e( 'no cache', self::DOMAIN );
280
+ echo '</td>';
281
  }
282
+
283
+ if ( SCC_Cache::has_value( $sns_counts[ self::REF_CRAWL_DATE ] ) && -1 != $sns_counts[ self::REF_CRAWL_DATE ] ) {
284
+ echo '<td class="full-cache">';
285
+ echo esc_html( $sns_counts[ self::REF_CRAWL_DATE ] );
286
+ echo '</td>';
287
+ } else {
288
+ $meta_key = $this->cache_engines[ self::REF_SHARE_2ND ]->get_cache_key( self::REF_CRAWL_DATE );
289
+
290
+ $crawl_date = get_post_meta( get_the_ID(), $meta_key, true );
291
+
292
+ if ( SCC_Cache::has_value( $crawl_date ) && -1 != $crawl_date ) {
293
+ echo '<td class="full-cache">';
294
+ echo esc_html( $crawl_date );
295
+ echo '</td>';
296
+ } else {
297
+ echo '<td class="no-cache">';
298
+ esc_html_e( 'no data', self::DOMAIN );
299
+ echo '</td>';
300
+ }
301
+ }
302
+
303
+ $nonce = wp_create_nonce( __FILE__ );
304
+ $cache_url = 'admin.php?page=scc-cache-status&action=cache&post_id=' . get_the_ID() . '&_wpnonce=' . $nonce . '&paged=' . $paged;
305
+ ?>
306
+ <td><a class="button button-small" href="<?php echo esc_url( $cache_url ); ?>"><?php esc_html_e( 'Cache', self::DOMAIN ); ?></a></td>
307
+ </tr>
308
+ <?php
309
+ ++$count;
310
+ } // End while().
311
+ } // End if().
312
+ ?>
313
+ </tbody>
314
+ </table>
315
+ <?php
316
+ $this->pagination( $posts_query->max_num_pages, '', $paged, false );
317
+
318
+ wp_reset_postdata();
319
  ?>
 
 
 
 
 
 
 
 
320
  </div>
321
  </div>
322
  </div>
323
  </div>
324
+ </div>
includes/admin-dashboard-widget.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  admin-dashboard-widget.php
4
 
5
  Description: Option page implementation
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,211 +27,216 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
- if ( ! defined( 'ABSPATH' ) ) exit(); // Exit if accessed directly
 
 
31
 
32
- $query_args = array(
33
- 'post_type' => $this->share_base_cache_post_types,
34
- 'post_status' => 'publish',
35
- 'nopaging' => true,
36
- 'update_post_term_cache' => false,
37
- 'update_post_meta_cache' => false
38
- );
39
 
40
- $site_query = new WP_Query( $query_args );
41
 
42
- ?>
43
- <div class="sns-cnt-cache">
44
- <div id="scc-dashboard-widget">
45
- <div id="site-summary-share-cache" class="site-summary activity-block">
46
- <h3><?php _e( 'Share', self::DOMAIN ); ?></h3>
47
- <h4><a href="admin.php?page=scc-cache-status"><?php _e( 'Cache Status', self::DOMAIN ); ?></a></h4>
48
- <table class="view-table">
49
- <thead>
50
- <tr>
51
- <th><?php _e( 'Cache Type', self::DOMAIN ); ?></th>
52
- <th><?php _e( 'Cache Progress', self::DOMAIN ); ?></th>
53
- <th><?php _e( 'Total Content', self::DOMAIN ); ?></th>
54
- <th><?php _e( 'State - Full Cache', self::DOMAIN ); ?></th>
55
- <th><?php _e( 'State - Partial Cache', self::DOMAIN ); ?></th>
56
- <th><?php _e( 'State - No Cache', self::DOMAIN ); ?></th>
57
- </tr>
58
- </thead>
59
- <tbody>
60
- <tr>
61
- <td><?php _e( 'Primary Cache', self::DOMAIN ); ?></td>
62
- <td>
63
- <img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc="spcs"></span>
64
- </td>
65
- <td class="share-count"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='spc'></span></td>
66
- <td class="share-count full-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='spfcc'></span></td>
67
- <td class="share-count partial-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='sppcc'></span></td>
68
- <td class="share-count no-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='spncc'></span></td>
69
- </tr>
70
- <tr>
71
- <td><?php _e( 'Secondary Cache', self::DOMAIN ); ?></td>
72
- <td>
73
- <img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc="sscs"></span>
74
- </td>
75
- <td class="share-count"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='spc'></span></td>
76
- <td class="share-count full-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='ssfcc'></span></td>
77
- <td class="share-count partial-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='sspcc'></span></td>
78
- <td class="share-count no-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='ssncc'></span></td>
79
- </tr>
80
- </tbody>
81
- </table>
82
- <h4><a href="admin.php?page=scc-share-count"><?php _e( 'Share Count', self::DOMAIN ); ?></a></h4>
83
- <table class="view-table">
84
- <thead>
85
- <tr>
86
- <?php
87
- $share_base_cache_target = $this->share_base_cache_target ;
88
- unset( $share_base_cache_target[self::REF_CRAWL_DATE] );
89
 
90
- foreach ( $share_base_cache_target as $sns => $active ){
91
- if ( $active ) {
92
- $sns_name = '';
93
 
94
- switch ( $sns ) {
95
- case self::REF_SHARE_TWITTER:
96
- $sns_name = __( 'Twitter', self::DOMAIN );
97
- break;
98
- case self::REF_SHARE_FACEBOOK:
99
- $sns_name = __( 'Facebook', self::DOMAIN );
100
- break;
101
- case self::REF_SHARE_GPLUS:
102
- $sns_name = __( 'Google+', self::DOMAIN );
103
- break;
104
- case self::REF_SHARE_POCKET:
105
- $sns_name = __( 'Pocket', self::DOMAIN );
106
- break;
107
- case self::REF_SHARE_HATEBU:
108
- $sns_name = __( 'Hatebu', self::DOMAIN );
109
- break;
110
- case self::REF_SHARE_PINTEREST:
111
- $sns_name = __( 'Pinterest', self::DOMAIN );
112
- break;
113
- case self::REF_SHARE_LINKEDIN:
114
- $sns_name = __( 'Linkedin', self::DOMAIN );
115
- break;
116
- case self::REF_SHARE_TOTAL:
117
- $sns_name = __( 'Total', self::DOMAIN );
118
- break;
119
- }
120
-
121
- echo '<th>' . esc_html( $sns_name ) . '</th>';
122
- }
123
- }
124
- ?>
125
- </tr>
126
- </thead>
127
- <tbody>
128
- <tr>
129
- <?php
130
- foreach ( $share_base_cache_target as $sns => $active ) {
131
- if ( $active ) {
132
- if ( $sns === self::REF_SHARE_GPLUS ){
133
- echo '<td class="share-count">';
134
- echo '<img class="loading" src="' . $this->loading_img_url . '" /><span data-scc="sgplus"></span>';
135
- echo '</td>';
136
- } else {
137
- echo '<td class="share-count">';
138
- echo '<img class="loading" src="' . $this->loading_img_url . '" /><span data-scc="s' . strtolower( $sns ) . '"></span>';
139
- echo '</td>';
140
- }
141
- }
142
  }
143
- ?>
144
- </tr>
145
- </tbody>
146
- </table>
147
- </div>
148
- <div id="site-summary-follow-cache" class="site-summary activity-block">
149
- <h3><?php _e( 'Follow', self::DOMAIN ); ?></h3>
150
- <h4><?php _e( 'Cache Status', self::DOMAIN ); ?></h4>
151
- <table class="view-table">
152
- <thead>
153
- <tr>
154
- <th><?php _e( 'Cache Type', self::DOMAIN ); ?></th>
155
- <th><?php _e( 'Cache Progress', self::DOMAIN ); ?></th>
156
- <th><?php _e( 'Total Content', self::DOMAIN ); ?></th>
157
- <th><?php _e( 'State - Full Cache', self::DOMAIN ); ?></th>
158
- <th><?php _e( 'State - Partial Cache', self::DOMAIN ); ?></th>
159
- <th><?php _e( 'State - No Cache', self::DOMAIN ); ?></th>
160
- </tr>
161
- </thead>
162
- <tbody>
163
- <tr>
164
- <td><?php _e( 'Primary Cache', self::DOMAIN ); ?></td>
165
- <td>
166
- <img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc="fpcs"></span>
167
- </td>
168
- <td class="share-count"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fpc'></span></td>
169
- <td class="share-count full-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fpfcc'></span></td>
170
- <td class="share-count partial-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fppcc'></span></td>
171
- <td class="share-count no-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fpncc'></span></td>
172
- </tr>
173
- <tr>
174
- <td><?php _e( 'Secondary Cache', self::DOMAIN ); ?></td>
175
- <td>
176
- <img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc="fscs"></span>
177
- </td>
178
- <td class="share-count"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fpc'></span></td>
179
- <td class="share-count full-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fsfcc'></span></td>
180
- <td class="share-count partial-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fspcc'></span></td>
181
- <td class="share-count no-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fsncc'></span></td>
182
- </tr>
183
- </tbody>
184
- </table>
185
- <h4><?php _e( 'Follower Count', self::DOMAIN ); ?></h4>
186
- <table class="view-table">
187
- <thead>
188
- <tr>
189
- <?php
190
- $follow_base_cache_target = $this->follow_base_cache_target ;
191
- unset( $follow_base_cache_target[self::REF_CRAWL_DATE] );
192
 
193
- foreach ( $follow_base_cache_target as $sns => $active ){
194
- if ( $active ) {
195
- $sns_name = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
 
197
- switch ( $sns ) {
198
- case self::REF_FOLLOW_TWITTER:
199
- $sns_name = __( 'Twitter', self::DOMAIN );
200
- break;
201
- case self::REF_FOLLOW_FACEBOOK:
202
- $sns_name = __( 'Facebook', self::DOMAIN );
203
- break;
204
- case self::REF_FOLLOW_FEEDLY:
205
- $sns_name = __( 'Feedly', self::DOMAIN );
206
- break;
207
- case self::REF_FOLLOW_INSTAGRAM:
208
- $sns_name = __( 'Instagram', self::DOMAIN );
209
- break;
210
- case self::REF_FOLLOW_PUSH7:
211
- $sns_name = __( 'Push7', self::DOMAIN );
212
- break;
213
- }
214
 
215
- echo '<th>' . esc_html( $sns_name ) . '</th>';
216
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  }
218
- ?>
219
- </tr>
220
- </thead>
221
- <tbody>
222
- <tr>
223
- <?php
224
- foreach ( $follow_base_cache_target as $sns => $active ) {
225
- if ( $active ) {
226
- echo '<td class="share-count">';
227
- echo '<img class="loading" src="' . $this->loading_img_url . '" /><span data-scc="f' . strtolower( $sns ) . '"></span>';
228
- echo '</td>';
229
- }
230
- }
231
- ?>
232
- </tr>
233
- </tbody>
234
- </table>
235
- </div>
 
 
 
236
  </div>
237
  </div>
 
1
  <?php
2
+ /**
3
  admin-dashboard-widget.php
4
 
5
  Description: Option page implementation
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ if ( ! defined( 'ABSPATH' ) ) {
31
+ exit(); // Exit if accessed directly
32
+ }
33
 
34
+ $query_args = array(
35
+ 'post_type' => $this->share_base_cache_post_types,
36
+ 'post_status' => 'publish',
37
+ 'nopaging' => true,
38
+ 'update_post_term_cache' => false,
39
+ 'update_post_meta_cache' => false,
40
+ );
41
 
42
+ $site_query = new WP_Query( $query_args );
43
 
44
+ ?>
45
+ <div class="sns-cnt-cache">
46
+ <div id="scc-dashboard-widget">
47
+ <div id="site-summary-share-cache" class="site-summary activity-block">
48
+ <h3><?php esc_html_e( 'Share', self::DOMAIN ); ?></h3>
49
+ <h4><a href="admin.php?page=scc-cache-status"><?php esc_html_e( 'Cache Status', self::DOMAIN ); ?></a></h4>
50
+ <table class="view-table">
51
+ <thead>
52
+ <tr>
53
+ <th><?php esc_html_e( 'Cache Type', self::DOMAIN ); ?></th>
54
+ <th><?php esc_html_e( 'Cache Progress', self::DOMAIN ); ?></th>
55
+ <th><?php esc_html_e( 'Total Content', self::DOMAIN ); ?></th>
56
+ <th><?php esc_html_e( 'State - Full Cache', self::DOMAIN ); ?></th>
57
+ <th><?php esc_html_e( 'State - Partial Cache', self::DOMAIN ); ?></th>
58
+ <th><?php esc_html_e( 'State - No Cache', self::DOMAIN ); ?></th>
59
+ </tr>
60
+ </thead>
61
+ <tbody>
62
+ <tr>
63
+ <td><?php esc_html_e( 'Primary Cache', self::DOMAIN ); ?></td>
64
+ <td>
65
+ <img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc="spcs"></span>
66
+ </td>
67
+ <td class="share-count"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='spc'></span></td>
68
+ <td class="share-count full-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='spfcc'></span></td>
69
+ <td class="share-count partial-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='sppcc'></span></td>
70
+ <td class="share-count no-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='spncc'></span></td>
71
+ </tr>
72
+ <tr>
73
+ <td><?php esc_html_e( 'Secondary Cache', self::DOMAIN ); ?></td>
74
+ <td>
75
+ <img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc="sscs"></span>
76
+ </td>
77
+ <td class="share-count"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='spc'></span></td>
78
+ <td class="share-count full-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='ssfcc'></span></td>
79
+ <td class="share-count partial-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='sspcc'></span></td>
80
+ <td class="share-count no-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='ssncc'></span></td>
81
+ </tr>
82
+ </tbody>
83
+ </table>
84
+ <h4><a href="admin.php?page=scc-share-count"><?php esc_html_e( 'Share Count', self::DOMAIN ); ?></a></h4>
85
+ <table class="view-table">
86
+ <thead>
87
+ <tr>
88
+ <?php
89
+ $share_base_cache_target = $this->share_base_cache_target ;
90
+ unset( $share_base_cache_target[ self::REF_CRAWL_DATE ] );
91
 
92
+ foreach ( $share_base_cache_target as $sns => $active ) {
93
+ if ( $active ) {
94
+ $sns_name = '';
95
 
96
+ switch ( $sns ) {
97
+ case self::REF_SHARE_TWITTER:
98
+ $sns_name = __( 'Twitter', self::DOMAIN );
99
+ break;
100
+ case self::REF_SHARE_FACEBOOK:
101
+ $sns_name = __( 'Facebook', self::DOMAIN );
102
+ break;
103
+ case self::REF_SHARE_GPLUS:
104
+ $sns_name = __( 'Google+', self::DOMAIN );
105
+ break;
106
+ case self::REF_SHARE_POCKET:
107
+ $sns_name = __( 'Pocket', self::DOMAIN );
108
+ break;
109
+ case self::REF_SHARE_HATEBU:
110
+ $sns_name = __( 'Hatebu', self::DOMAIN );
111
+ break;
112
+ case self::REF_SHARE_PINTEREST:
113
+ $sns_name = __( 'Pinterest', self::DOMAIN );
114
+ break;
115
+ case self::REF_SHARE_LINKEDIN:
116
+ $sns_name = __( 'Linkedin', self::DOMAIN );
117
+ break;
118
+ case self::REF_SHARE_TOTAL:
119
+ $sns_name = __( 'Total', self::DOMAIN );
120
+ break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
 
123
+ echo '<th>' . esc_html( $sns_name ) . '</th>';
124
+ }
125
+ }
126
+ ?>
127
+ </tr>
128
+ </thead>
129
+ <tbody>
130
+ <tr>
131
+ <?php
132
+ foreach ( $share_base_cache_target as $sns => $active ) {
133
+ if ( $active ) {
134
+ if ( self::REF_SHARE_GPLUS === $sns ) {
135
+ echo '<td class="share-count">';
136
+ echo '<img class="loading" src="' . esc_url( $this->loading_img_url ) . '" /><span data-scc="sgplus"></span>';
137
+ echo '</td>';
138
+ } else {
139
+ echo '<td class="share-count">';
140
+ echo '<img class="loading" src="' . esc_url( $this->loading_img_url ) . '" /><span data-scc="s' . esc_attr( strtolower( $sns ) ) . '"></span>';
141
+ echo '</td>';
142
+ }
143
+ }
144
+ }
145
+ ?>
146
+ </tr>
147
+ </tbody>
148
+ </table>
149
+ </div>
150
+ <div id="site-summary-follow-cache" class="site-summary activity-block">
151
+ <h3><?php esc_html_e( 'Follow', self::DOMAIN ); ?></h3>
152
+ <h4><?php esc_html_e( 'Cache Status', self::DOMAIN ); ?></h4>
153
+ <table class="view-table">
154
+ <thead>
155
+ <tr>
156
+ <th><?php esc_html_e( 'Cache Type', self::DOMAIN ); ?></th>
157
+ <th><?php esc_html_e( 'Cache Progress', self::DOMAIN ); ?></th>
158
+ <th><?php esc_html_e( 'Total Content', self::DOMAIN ); ?></th>
159
+ <th><?php esc_html_e( 'State - Full Cache', self::DOMAIN ); ?></th>
160
+ <th><?php esc_html_e( 'State - Partial Cache', self::DOMAIN ); ?></th>
161
+ <th><?php esc_html_e( 'State - No Cache', self::DOMAIN ); ?></th>
162
+ </tr>
163
+ </thead>
164
+ <tbody>
165
+ <tr>
166
+ <td><?php esc_html_e( 'Primary Cache', self::DOMAIN ); ?></td>
167
+ <td>
168
+ <img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc="fpcs"></span>
169
+ </td>
170
+ <td class="share-count"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='fpc'></span></td>
171
+ <td class="share-count full-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='fpfcc'></span></td>
172
+ <td class="share-count partial-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='fppcc'></span></td>
173
+ <td class="share-count no-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='fpncc'></span></td>
174
+ </tr>
175
+ <tr>
176
+ <td><?php esc_html_e( 'Secondary Cache', self::DOMAIN ); ?></td>
177
+ <td>
178
+ <img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc="fscs"></span>
179
+ </td>
180
+ <td class="share-count"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='fpc'></span></td>
181
+ <td class="share-count full-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='fsfcc'></span></td>
182
+ <td class="share-count partial-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='fspcc'></span></td>
183
+ <td class="share-count no-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='fsncc'></span></td>
184
+ </tr>
185
+ </tbody>
186
+ </table>
187
+ <h4><?php esc_html_e( 'Follower Count', self::DOMAIN ); ?></h4>
188
+ <table class="view-table">
189
+ <thead>
190
+ <tr>
191
+ <?php
192
+ $follow_base_cache_target = $this->follow_base_cache_target ;
193
+ unset( $follow_base_cache_target[ self::REF_CRAWL_DATE ] );
194
 
195
+ foreach ( $follow_base_cache_target as $sns => $active ) {
196
+ if ( $active ) {
197
+ $sns_name = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
 
199
+ switch ( $sns ) {
200
+ case self::REF_FOLLOW_TWITTER:
201
+ $sns_name = __( 'Twitter', self::DOMAIN );
202
+ break;
203
+ case self::REF_FOLLOW_FACEBOOK:
204
+ $sns_name = __( 'Facebook', self::DOMAIN );
205
+ break;
206
+ case self::REF_FOLLOW_FEEDLY:
207
+ $sns_name = __( 'Feedly', self::DOMAIN );
208
+ break;
209
+ case self::REF_FOLLOW_INSTAGRAM:
210
+ $sns_name = __( 'Instagram', self::DOMAIN );
211
+ break;
212
+ case self::REF_FOLLOW_PUSH7:
213
+ $sns_name = __( 'Push7', self::DOMAIN );
214
+ break;
215
+ case self::REF_FOLLOW_ONESIGNAL:
216
+ $sns_name = __( 'OneSignal', self::DOMAIN );
217
+ break;
218
  }
219
+
220
+ echo '<th>' . esc_html( $sns_name ) . '</th>';
221
+ }
222
+ }
223
+ ?>
224
+ </tr>
225
+ </thead>
226
+ <tbody>
227
+ <tr>
228
+ <?php
229
+ foreach ( $follow_base_cache_target as $sns => $active ) {
230
+ if ( $active ) {
231
+ echo '<td class="share-count">';
232
+ echo '<img class="loading" src="' . esc_url( $this->loading_img_url ) . '" /><span data-scc="f' . esc_attr( strtolower( $sns ) ) . '"></span>';
233
+ echo '</td>';
234
+ }
235
+ }
236
+ ?>
237
+ </tr>
238
+ </tbody>
239
+ </table>
240
  </div>
241
  </div>
242
+ </div>
includes/admin-dashboard.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  admin-dashboard.php
4
 
5
  Description: Option page implementation
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,233 +27,238 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
- if ( ! defined( 'ABSPATH' ) ) exit(); // Exit if accessed directly
31
-
32
- $query_args = array(
33
- 'post_type' => $this->share_base_cache_post_types,
34
- 'post_status' => 'publish',
35
- 'nopaging' => true,
36
- 'update_post_term_cache' => false,
37
- 'update_post_meta_cache' => false
38
- );
39
 
40
- $site_query = new WP_Query( $query_args );
41
- ?>
42
- <div class="wrap">
43
- <h2><a href="admin.php?page=scc-dashboard"><?php _e( 'SNS Count Cache', self::DOMAIN ); ?></a></h2>
44
- <div class="sns-cnt-cache">
45
- <div id="scc-dashboard">
46
- <h3 class="nav-tab-wrapper">
47
- <a class="nav-tab nav-tab-active" href="admin.php?page=scc-dashboard"><?php _e( 'Dashboard', self::DOMAIN ); ?></a>
48
- <a class="nav-tab" href="admin.php?page=scc-cache-status"><?php _e( 'Cache Status', self::DOMAIN ); ?></a>
49
- <a class="nav-tab" href="admin.php?page=scc-share-count"><?php _e( 'Share Count', self::DOMAIN ); ?></a>
50
- <?php if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) { ?>
51
- <a class="nav-tab" href="admin.php?page=scc-hot-content"><?php _e( 'Hot Content', self::DOMAIN ); ?></a>
52
- <?php } ?>
53
- <a class="nav-tab" href="admin.php?page=scc-setting"><?php _e( 'Setting', self::DOMAIN ); ?></a>
54
- <a class="nav-tab" href="admin.php?page=scc-help"><?php _e( 'Help', self::DOMAIN ); ?></a>
55
- </h3>
56
- <div class="metabox-holder">
57
- <div id="site-summary-share-cache" class="site-summary postbox">
58
- <div class="handlediv" title="Click to toggle"><br></div>
59
- <h3 class="hndle"><span><?php _e( 'Share', self::DOMAIN ); ?></span></h3>
60
- <div class="inside">
61
- <h4><a href="admin.php?page=scc-cache-status"><?php _e( 'Cache Status', self::DOMAIN ); ?></a></h4>
62
- <table class="view-table">
63
- <thead>
64
- <tr>
65
- <th><?php _e( 'Cache Type', self::DOMAIN ); ?></th>
66
- <th><?php _e( 'Cache Progress', self::DOMAIN ); ?></th>
67
- <th><?php _e( 'Total Content', self::DOMAIN ); ?></th>
68
- <th><?php _e( 'State - Full Cache', self::DOMAIN ); ?></th>
69
- <th><?php _e( 'State - Partial Cache', self::DOMAIN ); ?></th>
70
- <th><?php _e( 'State - No Cache', self::DOMAIN ); ?></th>
71
- </tr>
72
- </thead>
73
- <tbody>
74
- <tr>
75
- <td><?php _e( 'Primary Cache', self::DOMAIN ); ?></td>
76
- <td>
77
- <img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc="spcs"></span>
78
- </td>
79
- <td class="share-count"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='spc'></span></td>
80
- <td class="share-count full-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='spfcc'></span></td>
81
- <td class="share-count partial-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='sppcc'></span></td>
82
- <td class="share-count no-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='spncc'></span></td>
83
- </tr>
84
- <tr>
85
- <td><?php _e( 'Secondary Cache', self::DOMAIN ); ?></td>
86
- <td>
87
- <img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc="sscs"></span>
88
- </td>
89
- <td class="share-count"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='spc'></span></td>
90
- <td class="share-count full-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='ssfcc'></span></td>
91
- <td class="share-count partial-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='sspcc'></span></td>
92
- <td class="share-count no-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='ssncc'></span></td>
93
- </tr>
94
- </tbody>
95
- </table>
96
- <h4><a href="admin.php?page=scc-share-count"><?php _e( 'Share Count', self::DOMAIN ); ?></a></h4>
97
- <table class="view-table">
98
- <thead>
99
- <tr>
100
- <?php
101
- $share_base_cache_target = $this->share_base_cache_target ;
102
- unset( $share_base_cache_target[self::REF_CRAWL_DATE] );
103
 
104
- foreach ( $share_base_cache_target as $sns => $active ){
105
- if ( $active ) {
106
- $sns_name = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
 
108
- switch ( $sns ) {
109
- case self::REF_SHARE_TWITTER:
110
- $sns_name = __( 'Twitter', self::DOMAIN );
111
- break;
112
- case self::REF_SHARE_FACEBOOK:
113
- $sns_name = __( 'Facebook', self::DOMAIN );
114
- break;
115
- case self::REF_SHARE_GPLUS:
116
- $sns_name = __( 'Google+', self::DOMAIN );
117
- break;
118
- case self::REF_SHARE_POCKET:
119
- $sns_name = __( 'Pocket', self::DOMAIN );
120
- break;
121
- case self::REF_SHARE_HATEBU:
122
- $sns_name = __( 'Hatebu', self::DOMAIN );
123
- break;
124
- case self::REF_SHARE_PINTEREST:
125
- $sns_name = __( 'Pinterest', self::DOMAIN );
126
- break;
127
- case self::REF_SHARE_LINKEDIN:
128
- $sns_name = __( 'Linkedin', self::DOMAIN );
129
- break;
130
- case self::REF_SHARE_TOTAL:
131
- $sns_name = __( 'Total', self::DOMAIN );
132
- break;
133
- }
134
 
135
- echo '<th>' . esc_html( $sns_name ) . '</th>';
136
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  }
138
- ?>
139
- </tr>
140
- </thead>
141
- <tbody>
142
- <tr>
143
- <?php
144
- foreach ( $share_base_cache_target as $sns => $active ) {
145
- if ( $active ) {
146
- if ( $sns === self::REF_SHARE_GPLUS ){
147
- echo '<td class="share-count">';
148
- echo '<img class="loading" src="' . $this->loading_img_url . '" /><span data-scc="sgplus"></span>';
149
- echo '</td>';
150
- } else {
151
- echo '<td class="share-count">';
152
- echo '<img class="loading" src="' . $this->loading_img_url . '" /><span data-scc="s' . strtolower( $sns ) . '"></span>';
153
- echo '</td>';
154
- }
155
- }
 
 
156
  }
157
- ?>
158
- </tr>
159
- </tbody>
160
- </table>
161
- </div>
 
162
  </div>
163
  </div>
164
- <div class="metabox-holder">
165
- <div id="site-summary-follow-cache" class="site-summary postbox">
166
- <div class="handlediv" title="Click to toggle"><br></div>
167
- <h3 class="hndle"><span><?php _e( 'Follow', self::DOMAIN ); ?></span></h3>
168
- <div class="inside">
169
- <h4><?php _e( 'Cache Status', self::DOMAIN ); ?></h4>
170
- <table class="view-table">
171
- <thead>
172
- <tr>
173
- <th><?php _e( 'Cache Type', self::DOMAIN ); ?></th>
174
- <th><?php _e( 'Cache Progress', self::DOMAIN ); ?></th>
175
- <th><?php _e( 'Total Content', self::DOMAIN ); ?></th>
176
- <th><?php _e( 'State - Full Cache', self::DOMAIN ); ?></th>
177
- <th><?php _e( 'State - Partial Cache', self::DOMAIN ); ?></th>
178
- <th><?php _e( 'State - No Cache', self::DOMAIN ); ?></th>
179
- </tr>
180
- </thead>
181
- <tbody>
182
- <tr>
183
- <td><?php _e( 'Primary Cache', self::DOMAIN ); ?></td>
184
- <td>
185
- <img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc="fpcs"></span>
186
- </td>
187
- <td class="share-count"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fpc'></span></td>
188
- <td class="share-count full-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fpfcc'></span></td>
189
- <td class="share-count partial-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fppcc'></span></td>
190
- <td class="share-count no-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fpncc'></span></td>
191
- </tr>
192
- <tr>
193
- <td><?php _e( 'Secondary Cache', self::DOMAIN ); ?></td>
194
- <td>
195
- <img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc="fscs"></span>
196
- </td>
197
- <td class="share-count"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fpc'></span></td>
198
- <td class="share-count full-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fsfcc'></span></td>
199
- <td class="share-count partial-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fspcc'></span></td>
200
- <td class="share-count no-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fsncc'></span></td>
201
- </tr>
202
- </tbody>
203
- </table>
204
- <h4><?php _e( 'Follower Count', self::DOMAIN ); ?></h4>
205
  <table class="view-table">
206
- <thead>
207
- <tr>
208
- <?php
209
- $follow_base_cache_target = $this->follow_base_cache_target ;
210
- unset( $follow_base_cache_target[self::REF_CRAWL_DATE] );
211
-
212
- foreach ( $follow_base_cache_target as $sns => $active ){
213
- if ( $active ) {
214
- $sns_name = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
 
216
- switch ( $sns ) {
217
- case self::REF_FOLLOW_TWITTER:
218
- $sns_name = __( 'Twitter', self::DOMAIN );
219
- break;
220
- case self::REF_FOLLOW_FACEBOOK:
221
- $sns_name = __( 'Facebook', self::DOMAIN );
222
- break;
223
- case self::REF_FOLLOW_FEEDLY:
224
- $sns_name = __( 'Feedly', self::DOMAIN );
225
- break;
226
- case self::REF_FOLLOW_INSTAGRAM:
227
- $sns_name = __( 'Instagram', self::DOMAIN );
228
- break;
229
- case self::REF_FOLLOW_PUSH7:
230
- $sns_name = __( 'Push7', self::DOMAIN );
231
- break;
232
- }
233
 
234
- echo '<th>' . esc_html( $sns_name ) . '</th>';
235
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  }
237
- ?>
238
- </tr>
239
- </thead>
240
- <tbody>
241
- <tr>
242
- <?php
243
- foreach ( $follow_base_cache_target as $sns => $active ) {
244
- if ( $active ) {
245
- echo '<td class="share-count">';
246
- echo '<img class="loading" src="' . $this->loading_img_url . '" /><span data-scc="f' . strtolower( $sns ) . '"></span>';
247
- echo '</td>';
248
- }
249
- }
250
- ?>
251
- </tr>
252
- </tbody>
253
- </table>
254
- </div>
 
 
 
255
  </div>
256
  </div>
257
  </div>
258
  </div>
259
  </div>
 
1
  <?php
2
+ /**
3
  admin-dashboard.php
4
 
5
  Description: Option page implementation
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ if ( ! defined( 'ABSPATH' ) ) {
31
+ exit(); // Exit if accessed directly
32
+ }
 
 
 
 
 
 
33
 
34
+ $query_args = array(
35
+ 'post_type' => $this->share_base_cache_post_types,
36
+ 'post_status' => 'publish',
37
+ 'nopaging' => true,
38
+ 'update_post_term_cache' => false,
39
+ 'update_post_meta_cache' => false,
40
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
+ $site_query = new WP_Query( $query_args );
43
+ ?>
44
+ <div class="wrap">
45
+ <h2><a href="admin.php?page=scc-dashboard"><?php esc_html_e( 'SNS Count Cache', self::DOMAIN ); ?></a></h2>
46
+ <div class="sns-cnt-cache">
47
+ <div id="scc-dashboard">
48
+ <h3 class="nav-tab-wrapper">
49
+ <a class="nav-tab nav-tab-active" href="admin.php?page=scc-dashboard"><?php esc_html_e( 'Dashboard', self::DOMAIN ); ?></a>
50
+ <a class="nav-tab" href="admin.php?page=scc-cache-status"><?php esc_html_e( 'Cache Status', self::DOMAIN ); ?></a>
51
+ <a class="nav-tab" href="admin.php?page=scc-share-count"><?php esc_html_e( 'Share Count', self::DOMAIN ); ?></a>
52
+ <?php if ( self::OPT_SHARE_VARIATION_ANALYSIS_NONE !== $this->share_variation_analysis_mode ) { ?>
53
+ <a class="nav-tab" href="admin.php?page=scc-hot-content"><?php esc_html_e( 'Hot Content', self::DOMAIN ); ?></a>
54
+ <?php } ?>
55
+ <a class="nav-tab" href="admin.php?page=scc-setting"><?php esc_html_e( 'Setting', self::DOMAIN ); ?></a>
56
+ <a class="nav-tab" href="admin.php?page=scc-help"><?php esc_html_e( 'Help', self::DOMAIN ); ?></a>
57
+ </h3>
58
+ <div class="metabox-holder">
59
+ <div id="site-summary-share-cache" class="site-summary postbox">
60
+ <div class="handlediv" title="Click to toggle"><br></div>
61
+ <h3 class="hndle"><span><?php esc_html_e( 'Share', self::DOMAIN ); ?></span></h3>
62
+ <div class="inside">
63
+ <h4><a href="admin.php?page=scc-cache-status"><?php esc_html_e( 'Cache Status', self::DOMAIN ); ?></a></h4>
64
+ <table class="view-table">
65
+ <thead>
66
+ <tr>
67
+ <th><?php esc_html_e( 'Cache Type', self::DOMAIN ); ?></th>
68
+ <th><?php esc_html_e( 'Cache Progress', self::DOMAIN ); ?></th>
69
+ <th><?php esc_html_e( 'Total Content', self::DOMAIN ); ?></th>
70
+ <th><?php esc_html_e( 'State - Full Cache', self::DOMAIN ); ?></th>
71
+ <th><?php esc_html_e( 'State - Partial Cache', self::DOMAIN ); ?></th>
72
+ <th><?php esc_html_e( 'State - No Cache', self::DOMAIN ); ?></th>
73
+ </tr>
74
+ </thead>
75
+ <tbody>
76
+ <tr>
77
+ <td><?php esc_html_e( 'Primary Cache', self::DOMAIN ); ?></td>
78
+ <td>
79
+ <img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc="spcs"></span>
80
+ </td>
81
+ <td class="share-count"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='spc'></span></td>
82
+ <td class="share-count full-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='spfcc'></span></td>
83
+ <td class="share-count partial-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='sppcc'></span></td>
84
+ <td class="share-count no-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='spncc'></span></td>
85
+ </tr>
86
+ <tr>
87
+ <td><?php esc_html_e( 'Secondary Cache', self::DOMAIN ); ?></td>
88
+ <td>
89
+ <img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc="sscs"></span>
90
+ </td>
91
+ <td class="share-count"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='spc'></span></td>
92
+ <td class="share-count full-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='ssfcc'></span></td>
93
+ <td class="share-count partial-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='sspcc'></span></td>
94
+ <td class="share-count no-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='ssncc'></span></td>
95
+ </tr>
96
+ </tbody>
97
+ </table>
98
+ <h4><a href="admin.php?page=scc-share-count"><?php esc_html_e( 'Share Count', self::DOMAIN ); ?></a></h4>
99
+ <table class="view-table">
100
+ <thead>
101
+ <tr>
102
+ <?php
103
+ $share_base_cache_target = $this->share_base_cache_target ;
104
+ unset( $share_base_cache_target[ self::REF_CRAWL_DATE ] );
105
 
106
+ foreach ( $share_base_cache_target as $sns => $active ) {
107
+ if ( $active ) {
108
+ $sns_name = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
 
110
+ switch ( $sns ) {
111
+ case self::REF_SHARE_TWITTER:
112
+ $sns_name = __( 'Twitter', self::DOMAIN );
113
+ break;
114
+ case self::REF_SHARE_FACEBOOK:
115
+ $sns_name = __( 'Facebook', self::DOMAIN );
116
+ break;
117
+ case self::REF_SHARE_GPLUS:
118
+ $sns_name = __( 'Google+', self::DOMAIN );
119
+ break;
120
+ case self::REF_SHARE_POCKET:
121
+ $sns_name = __( 'Pocket', self::DOMAIN );
122
+ break;
123
+ case self::REF_SHARE_HATEBU:
124
+ $sns_name = __( 'Hatebu', self::DOMAIN );
125
+ break;
126
+ case self::REF_SHARE_PINTEREST:
127
+ $sns_name = __( 'Pinterest', self::DOMAIN );
128
+ break;
129
+ case self::REF_SHARE_LINKEDIN:
130
+ $sns_name = __( 'Linkedin', self::DOMAIN );
131
+ break;
132
+ case self::REF_SHARE_TOTAL:
133
+ $sns_name = __( 'Total', self::DOMAIN );
134
+ break;
135
  }
136
+
137
+ echo '<th>' . esc_html( $sns_name ) . '</th>';
138
+ }
139
+ }
140
+ ?>
141
+ </tr>
142
+ </thead>
143
+ <tbody>
144
+ <tr>
145
+ <?php
146
+ foreach ( $share_base_cache_target as $sns => $active ) {
147
+ if ( $active ) {
148
+ if ( self::REF_SHARE_GPLUS === $sns ) {
149
+ echo '<td class="share-count">';
150
+ echo '<img class="loading" src="' . esc_url( $this->loading_img_url ) . '" /><span data-scc="sgplus"></span>';
151
+ echo '</td>';
152
+ } else {
153
+ echo '<td class="share-count">';
154
+ echo '<img class="loading" src="' . esc_url( $this->loading_img_url ) . '" /><span data-scc="s' . esc_attr( strtolower( $sns ) ) . '"></span>';
155
+ echo '</td>';
156
  }
157
+ }
158
+ }
159
+ ?>
160
+ </tr>
161
+ </tbody>
162
+ </table>
163
  </div>
164
  </div>
165
+ </div>
166
+ <div class="metabox-holder">
167
+ <div id="site-summary-follow-cache" class="site-summary postbox">
168
+ <div class="handlediv" title="Click to toggle"><br></div>
169
+ <h3 class="hndle"><span><?php esc_html_e( 'Follow', self::DOMAIN ); ?></span></h3>
170
+ <div class="inside">
171
+ <h4><?php esc_html_e( 'Cache Status', self::DOMAIN ); ?></h4>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  <table class="view-table">
173
+ <thead>
174
+ <tr>
175
+ <th><?php esc_html_e( 'Cache Type', self::DOMAIN ); ?></th>
176
+ <th><?php esc_html_e( 'Cache Progress', self::DOMAIN ); ?></th>
177
+ <th><?php esc_html_e( 'Total Content', self::DOMAIN ); ?></th>
178
+ <th><?php esc_html_e( 'State - Full Cache', self::DOMAIN ); ?></th>
179
+ <th><?php esc_html_e( 'State - Partial Cache', self::DOMAIN ); ?></th>
180
+ <th><?php esc_html_e( 'State - No Cache', self::DOMAIN ); ?></th>
181
+ </tr>
182
+ </thead>
183
+ <tbody>
184
+ <tr>
185
+ <td><?php esc_html_e( 'Primary Cache', self::DOMAIN ); ?></td>
186
+ <td>
187
+ <img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc="fpcs"></span>
188
+ </td>
189
+ <td class="share-count"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='fpc'></span></td>
190
+ <td class="share-count full-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='fpfcc'></span></td>
191
+ <td class="share-count partial-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='fppcc'></span></td>
192
+ <td class="share-count no-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='fpncc'></span></td>
193
+ </tr>
194
+ <tr>
195
+ <td><?php esc_html_e( 'Secondary Cache', self::DOMAIN ); ?></td>
196
+ <td>
197
+ <img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc="fscs"></span>
198
+ </td>
199
+ <td class="share-count"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='fpc'></span></td>
200
+ <td class="share-count full-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='fsfcc'></span></td>
201
+ <td class="share-count partial-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='fspcc'></span></td>
202
+ <td class="share-count no-cache"><img class="loading" src="<?php echo esc_url( $this->loading_img_url ); ?>" /><span data-scc='fsncc'></span></td>
203
+ </tr>
204
+ </tbody>
205
+ </table>
206
+ <h4><?php esc_html_e( 'Follower Count', self::DOMAIN ); ?></h4>
207
+ <table class="view-table">
208
+ <thead>
209
+ <tr>
210
+ <?php
211
+ $follow_base_cache_target = $this->follow_base_cache_target ;
212
+ unset( $follow_base_cache_target[ self::REF_CRAWL_DATE ] );
213
 
214
+ foreach ( $follow_base_cache_target as $sns => $active ) {
215
+ if ( $active ) {
216
+ $sns_name = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
 
218
+ switch ( $sns ) {
219
+ case self::REF_FOLLOW_TWITTER:
220
+ $sns_name = __( 'Twitter', self::DOMAIN );
221
+ break;
222
+ case self::REF_FOLLOW_FACEBOOK:
223
+ $sns_name = __( 'Facebook', self::DOMAIN );
224
+ break;
225
+ case self::REF_FOLLOW_FEEDLY:
226
+ $sns_name = __( 'Feedly', self::DOMAIN );
227
+ break;
228
+ case self::REF_FOLLOW_INSTAGRAM:
229
+ $sns_name = __( 'Instagram', self::DOMAIN );
230
+ break;
231
+ case self::REF_FOLLOW_ONESIGNAL;
232
+ $sns_name = __( 'OneSignal', self::DOMAIN );
233
+ break;
234
+ case self::REF_FOLLOW_PUSH7:
235
+ $sns_name = __( 'Push7', self::DOMAIN );
236
+ break;
237
  }
238
+
239
+ echo '<th>' . esc_html( $sns_name ) . '</th>';
240
+ }
241
+ }
242
+ ?>
243
+ </tr>
244
+ </thead>
245
+ <tbody>
246
+ <tr>
247
+ <?php
248
+ foreach ( $follow_base_cache_target as $sns => $active ) {
249
+ if ( $active ) {
250
+ echo '<td class="share-count">';
251
+ echo '<img class="loading" src="' . esc_url( $this->loading_img_url ) . '" /><span data-scc="f' . esc_attr( strtolower( $sns ) ) . '"></span>';
252
+ echo '</td>';
253
+ }
254
+ }
255
+ ?>
256
+ </tr>
257
+ </tbody>
258
+ </table>
259
  </div>
260
  </div>
261
  </div>
262
  </div>
263
  </div>
264
+ </div>
includes/admin-help.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  admin-help.php
4
 
5
  Description: Option page implementation
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,89 +27,91 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
- if ( ! defined( 'ABSPATH' ) ) exit(); // Exit if accessed directly
 
 
31
  ?>
32
 
33
- <div class="wrap">
34
- <h2><a href="admin.php?page=scc-help"><?php _e( 'SNS Count Cache', self::DOMAIN ); ?></a></h2>
35
- <div class="sns-cnt-cache">
36
- <h3 class="nav-tab-wrapper">
37
- <a class="nav-tab" href="admin.php?page=scc-dashboard"><?php _e( 'Dashboard', self::DOMAIN ); ?></a>
38
- <a class="nav-tab" href="admin.php?page=scc-cache-status"><?php _e( 'Cache Status', self::DOMAIN ); ?></a>
39
- <a class="nav-tab" href="admin.php?page=scc-share-count"><?php _e( 'Share Count', self::DOMAIN ); ?></a>
40
- <?php if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) { ?>
41
- <a class="nav-tab" href="admin.php?page=scc-hot-content"><?php _e( 'Hot Content', self::DOMAIN ); ?></a>
42
- <?php } ?>
43
- <a class="nav-tab" href="admin.php?page=scc-setting"><?php _e( 'Setting', self::DOMAIN ) ?></a>
44
- <a class="nav-tab nav-tab-active" href="admin.php?page=scc-help"><?php _e( 'Help', self::DOMAIN ); ?></a>
45
- </h3>
46
- <div class="metabox-holder">
47
- <div id="share-site-summary" class="postbox">
48
- <div class="handlediv" title="Click to toggle"><br></div>
49
- <h3 class="hndle"><span><?php _e( 'Help', self::DOMAIN ); ?></span></h3>
50
- <div class="inside">
51
- <h4><?php _e( 'What is WordPress plugin SNS Cout Cache?', self::DOMAIN ); ?></h4>
52
- <p><?php _e( 'WordPress plugin SNS Count Cache is a plugin which helps you to shorten page loading time when your site displays share and follower counts. This plugin gets share counts such as Twitter and Facebook, Google+, Pocket, Pinterest, Linkedin and caches these counts in the background. This plugin alse caches follower counts such as Twitter and Facebook, Feedly, Instagram, Push7 in the same way. The share and follower counts can be retrieved quickly not through network but through the cache using given functions.', self::DOMAIN ); ?></p>
53
- <h4><?php _e( 'How often does this plugin get and cache share counts?', self::DOMAIN ); ?></h4>
54
- <p><?php _e( 'Although this plugin gets share count of 20 posts at a time every 10 minutes by default, you can modify the setting in the "Setting" tab in the administration page.', self::DOMAIN ); ?></p>
55
- <h4><?php _e( 'How can I know whether share count of each post is cached or not?', self::DOMAIN ); ?></h4>
56
- <p><?php _e( 'Cache status is described in the "Cache Status" tab in the administration page.', self::DOMAIN ); ?></p>
57
- <h4><?php _e( 'How often does this plugin get and cache follower counts?', self::DOMAIN ); ?></h4>
58
- <p><?php _e( 'Although this plugin gets follower count once a day by default, you can modify the setting in the "Setting" tab in the administration page.', self::DOMAIN ); ?></p>
59
- <h4><?php _e( 'What is cache status such as "full cache", "partial cache" and "no cache"?', self::DOMAIN ); ?></h4>
60
- <p><?php _e( 'The following is the explanation of the cache status.', self::DOMAIN ); ?></p>
61
- <table class="view-table">
62
- <thead>
63
- <tr>
64
- <th><?php _e( 'Cache Status', self::DOMAIN ); ?></th>
65
- <th><?php _e( 'Description', self::DOMAIN ); ?></th>
66
- </tr>
67
- </thead>
68
- <tbody>
69
- <tr><td><?php _e( 'full cache', self::DOMAIN ); ?></td><td><?php _e( 'Counts for selected all SNS are cached.', self::DOMAIN ); ?></td></tr>
70
- <tr><td><?php _e( 'partial cache', self::DOMAIN ); ?></td><td><?php _e( 'A subset of counts for selected SNS are cached.', self::DOMAIN ); ?></td></tr>
71
- <tr><td><?php _e( 'no cache', self::DOMAIN ); ?></td><td><?php _e( 'Count for selected SNS are not cached at all.', self::DOMAIN ); ?></td></tr>
72
- </tbody>
73
- </table>
74
- <h4><?php _e( 'How can I get share count from the cache?', self::DOMAIN ); ?></h4>
75
- <p><?php _e( 'The share count is retrieved from the cache using the following functions in the WordPress loop such as query_posts(), get_posts() and WP_Query().', self::DOMAIN ); ?></p>
76
- <table class="view-table">
77
- <thead>
78
- <tr>
79
- <th><?php _e( 'Function', self::DOMAIN ); ?></th>
80
- <th><?php _e( 'Description', self::DOMAIN ); ?></th>
81
- </tr>
82
- </thead>
83
- <tbody>
84
- <tr><td>scc_get_share_twitter()</td><td><?php _e( 'Twitter share count is returned from cache.', self::DOMAIN ); ?></td></tr>
85
- <tr><td>scc_get_share_facebook()</td><td><?php _e( 'Facebook share count is returned from cache.', self::DOMAIN ); ?></td></tr>
86
- <tr><td>scc_get_share_gplus()</td><td><?php _e( 'Google Plus share count is returned from cache.', self::DOMAIN ); ?></td></tr>
87
- <tr><td>scc_get_share_hatebu()</td><td><?php _e( 'Hatena Bookmark share count is returned from cache.', self::DOMAIN ); ?></td></tr>
88
- <tr><td>scc_get_share_pocket()</td><td><?php _e( 'Pocket share count is returned from cache.', self::DOMAIN ); ?></td></tr>
89
- <tr><td>scc_get_share_pinterest()</td><td><?php _e( 'Pinterest share count is returned from cache.', self::DOMAIN ); ?></td></tr>
90
- <tr><td>scc_get_share_linkedin()</td><td><?php _e( 'Linkedin share count is returned from cache.', self::DOMAIN ); ?></td></tr>
91
- <tr><td>scc_get_share_total()</td><td><?php _e( 'Total share count of selected SNS is returned from cache.', self::DOMAIN ); ?></td></tr>
92
- </tbody>
93
- </table>
94
- <h4><?php _e( 'How can I get follower count from the cache?', self::DOMAIN ); ?></h4>
95
- <p><?php _e( 'The follower count is retrieved from the cache using the following functions.', self::DOMAIN ); ?></p>
96
- <table class="view-table">
97
- <thead>
98
- <tr>
99
- <th><?php _e( 'Function', self::DOMAIN ); ?></th>
100
- <th><?php _e( 'Description', self::DOMAIN ); ?></th>
101
- </tr>
102
- </thead>
103
- <tbody>
104
- <tr><td>scc_get_follow_feedly()</td><td><?php _e( 'Feedly follower count is returned from cache.', self::DOMAIN ); ?></td></tr>
105
- <tr><td>scc_get_follow_twitter()</td><td><?php _e( 'Twitter follower count is returned from cache.', self::DOMAIN ); ?></td></tr>
106
- <tr><td>scc_get_follow_facebook()</td><td><?php _e( 'Facebook follower count is returned from cache.', self::DOMAIN ); ?></td></tr>
107
- <tr><td>scc_get_follow_instagram()</td><td><?php _e( 'Instagram follower count is returned from cache.', self::DOMAIN ); ?></td></tr>
108
- <tr><td>scc_get_follow_push7()</td><td><?php _e( 'Push7 follower count is returned from cache.', self::DOMAIN ); ?></td></tr>
109
- </tbody>
110
- </table>
111
- <h4><?php _e( 'Example Code', self::DOMAIN ); ?></h4>
112
- <?php _e( 'The code below describes a simple example which displays share count and follower count using the above functions.', self::DOMAIN ); ?>
113
  <pre><code class="php">
114
  &lt;?php
115
  $query_args = array(
@@ -128,7 +130,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
128
 
129
  if ( function_exists( &#039;scc_get_share_twitter&#039; ) &amp;&amp;
130
  function_exists( &#039;scc_get_share_facebook&#039; ) &amp;&amp;
131
- function_exists( &#039;scc_get_share_gplus&#039; ) &amp;&amp;
132
  function_exists( &#039;scc_get_share_pocket&#039; ) &amp;&amp;
133
  function_exists( &#039;scc_get_share_pinterest&#039; ) &amp;&amp;
134
  function_exists( &#039;scc_get_share_linkedin&#039; ) &amp;&amp;
@@ -138,7 +139,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
138
  // in order to get share count for current post and follower count.
139
  echo &#039;&lt;div&gt;Twitter share count: &#039; . scc_get_share_twitter() . &#039;&lt;/div&gt;&#039;;
140
  echo &#039;&lt;div&gt;Facebook share count: &#039; . scc_get_share_facebook() . &#039;&lt;/div&gt;&#039;;
141
- echo &#039;&lt;div&gt;Google+ share count: &#039; . scc_get_share_gplus() . &#039;&lt;/div&gt;&#039;;
142
  echo &#039;&lt;div&gt;Pocket share count: &#039; . scc_get_share_pocket() . &#039;&lt;/div&gt;&#039;;
143
  echo &#039;&lt;div&gt;Pinterest share count: &#039; . scc_get_share_pinterest() . &#039;&lt;/div&gt;&#039;;
144
  echo &#039;&lt;div&gt;Linkedin share count: &#039; . scc_get_share_linkedin() . &#039;&lt;/div&gt;&#039;;
@@ -152,7 +152,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
152
  function_exists( &#039;scc_get_follow_twitter&#039; ) &amp;&amp;
153
  function_exists( &#039;scc_get_follow_facebook&#039; ) &amp;&amp;
154
  function_exists( &#039;scc_get_follow_instagram&#039; ) &amp;&amp;
155
- function_exists( &#039;scc_get_follow_push7&#039; )
 
156
  ) {
157
  // You can use the given function in order to get follower count.
158
  echo &#039;&lt;div&gt;Feedly follower count: &#039; . scc_get_follow_feedly() . &#039;&lt;/div&gt;&#039;;
@@ -160,52 +161,51 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
160
  echo &#039;&lt;div&gt;Facebook follower count: &#039; . scc_get_follow_facebook() . &#039;&lt;/div&gt;&#039;;
161
  echo &#039;&lt;div&gt;Instagram follower count: &#039; . scc_get_follow_instagram() . &#039;&lt;/div&gt;&#039;;
162
  echo &#039;&lt;div&gt;Push7 follower count: &#039; . scc_get_follow_push7() . &#039;&lt;/div&gt;&#039;;
 
163
  }
164
  ?&gt;
165
  </code></pre>
166
- <script>hljs.initHighlightingOnLoad();</script>
167
- <h4><?php _e( 'How can I access specific custom field containing each share count?', self::DOMAIN ); ?></h4>
168
- <p><?php _e( 'Custom fields including share count are accessed using the following meta keys.', self::DOMAIN ); ?></p>
169
- <table class="view-table">
170
- <thead>
171
- <tr>
172
- <th><?php _e( 'Meta Key', self::DOMAIN ); ?></th>
173
- <th><?php _e( 'Description', self::DOMAIN ); ?></th>
174
- </tr>
175
- </thead>
176
- <tbody>
177
- <tr><td>scc_share_count_twitter</td><td><?php _e( 'A meta key to access Twitter share count', self::DOMAIN ); ?></td></tr>
178
- <tr><td>scc_share_count_facebook</td><td><?php _e( 'A meta key to access Facebook share count', self::DOMAIN ); ?></td></tr>
179
- <tr><td>scc_share_count_google+</td><td><?php _e( 'A meta key to access Google+ share count', self::DOMAIN ); ?></td></tr>
180
- <tr><td>scc_share_count_hatebu</td><td><?php _e( 'A meta key to access Hatena Bookmark share count', self::DOMAIN ); ?></td></tr>
181
- <tr><td>scc_share_count_pocket</td><td><?php _e( 'A meta key to access Pocket share count', self::DOMAIN ); ?></td></tr>
182
- <tr><td>scc_share_count_pinterest</td><td><?php _e( 'A meta key to access Pinterest share count', self::DOMAIN ); ?></td></tr>
183
- <tr><td>scc_share_count_linkedin</td><td><?php _e( 'A meta key to access Linkedin share count', self::DOMAIN ); ?></td></tr>
184
- <tr><td>scc_share_count_total</td><td><?php _e( 'A meta key to access total share count', self::DOMAIN ); ?></td></tr>
185
- </tbody>
186
- </table>
187
- <h4><?php _e( 'How can I access specific custom field containing each variation of share count?', self::DOMAIN ); ?></h4>
188
- <p><?php _e( 'Custom fields including variation of share count are accessed using the following meta keys.', self::DOMAIN ); ?></p>
189
- <table class="view-table">
190
- <thead>
191
- <tr>
192
- <th><?php _e( 'Meta Key', self::DOMAIN ); ?></th>
193
- <th><?php _e( 'Description', self::DOMAIN ); ?></th>
194
- </tr>
195
- </thead>
196
- <tbody>
197
- <tr><td>scc_share_delta_twitter</td><td><?php _e( 'A meta key to access variation of Twitter share count', self::DOMAIN ); ?></td></tr>
198
- <tr><td>scc_share_delta_facebook</td><td><?php _e( 'A meta key to access variation of Facebook share count', self::DOMAIN ); ?></td></tr>
199
- <tr><td>scc_share_delta_google+</td><td><?php _e( 'A meta key to access variation of Google+ share count', self::DOMAIN ); ?></td></tr>
200
- <tr><td>scc_share_delta_hatebu</td><td><?php _e( 'A meta key to access variation of Hatena Bookmark share count', self::DOMAIN ); ?></td></tr>
201
- <tr><td>scc_share_delta_pocket</td><td><?php _e( 'A meta key to access variation of Pocket share count', self::DOMAIN ); ?></td></tr>
202
- <tr><td>scc_share_delta_pinterest</td><td><?php _e( 'A meta key to access variation of Pinterest share count', self::DOMAIN ); ?></td></tr>
203
- <tr><td>scc_share_delta_linkedin</td><td><?php _e( 'A meta key to access variation of Linkedin share count', self::DOMAIN ); ?></td></tr>
204
- <tr><td>scc_share_delta_total</td><td><?php _e( 'A meta key to access variation of total share count', self::DOMAIN ); ?></td></tr>
205
- </tbody>
206
- </table>
207
- </div>
208
  </div>
209
  </div>
210
  </div>
211
  </div>
 
1
  <?php
2
+ /**
3
  admin-help.php
4
 
5
  Description: Option page implementation
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ if ( ! defined( 'ABSPATH' ) ) {
31
+ exit(); // Exit if accessed directly
32
+ }
33
  ?>
34
 
35
+ <div class="wrap">
36
+ <h2><a href="admin.php?page=scc-help"><?php esc_html_e( 'SNS Count Cache', self::DOMAIN ); ?></a></h2>
37
+ <div class="sns-cnt-cache">
38
+ <h3 class="nav-tab-wrapper">
39
+ <a class="nav-tab" href="admin.php?page=scc-dashboard"><?php esc_html_e( 'Dashboard', self::DOMAIN ); ?></a>
40
+ <a class="nav-tab" href="admin.php?page=scc-cache-status"><?php esc_html_e( 'Cache Status', self::DOMAIN ); ?></a>
41
+ <a class="nav-tab" href="admin.php?page=scc-share-count"><?php esc_html_e( 'Share Count', self::DOMAIN ); ?></a>
42
+ <?php if ( self::OPT_SHARE_VARIATION_ANALYSIS_NONE !== $this->share_variation_analysis_mode ) { ?>
43
+ <a class="nav-tab" href="admin.php?page=scc-hot-content"><?php esc_html_e( 'Hot Content', self::DOMAIN ); ?></a>
44
+ <?php } ?>
45
+ <a class="nav-tab" href="admin.php?page=scc-setting"><?php esc_html_e( 'Setting', self::DOMAIN ) ?></a>
46
+ <a class="nav-tab nav-tab-active" href="admin.php?page=scc-help"><?php esc_html_e( 'Help', self::DOMAIN ); ?></a>
47
+ </h3>
48
+ <div class="metabox-holder">
49
+ <div id="share-site-summary" class="postbox">
50
+ <div class="handlediv" title="Click to toggle"><br></div>
51
+ <h3 class="hndle"><span><?php esc_html_e( 'Help', self::DOMAIN ); ?></span></h3>
52
+ <div class="inside">
53
+ <h4><?php esc_html_e( 'What is WordPress plugin SNS Cout Cache?', self::DOMAIN ); ?></h4>
54
+ <p><?php esc_html_e( 'WordPress plugin SNS Count Cache is a plugin which helps you to shorten page loading time when your site displays share and follower counts. This plugin gets share counts such as Twitter and Facebook, Pocket, Pinterest, Linkedin and caches these counts in the background. This plugin alse caches follower counts such as Twitter and Facebook, Feedly, Instagram, OneSignal, Push7 in the same way. The share and follower counts can be retrieved quickly not through network but through the cache using given functions.', self::DOMAIN ); ?></p>
55
+ <h4><?php esc_html_e( 'How often does this plugin get and cache share counts?', self::DOMAIN ); ?></h4>
56
+ <p><?php esc_html_e( 'Although this plugin gets share count of 20 posts at a time every 10 minutes by default, you can modify the setting in the "Setting" tab in the administration page.', self::DOMAIN ); ?></p>
57
+ <h4><?php esc_html_e( 'How can I know whether share count of each post is cached or not?', self::DOMAIN ); ?></h4>
58
+ <p><?php esc_html_e( 'Cache status is described in the "Cache Status" tab in the administration page.', self::DOMAIN ); ?></p>
59
+ <h4><?php esc_html_e( 'How often does this plugin get and cache follower counts?', self::DOMAIN ); ?></h4>
60
+ <p><?php esc_html_e( 'Although this plugin gets follower count once a day by default, you can modify the setting in the "Setting" tab in the administration page.', self::DOMAIN ); ?></p>
61
+ <h4><?php esc_html_e( 'What is cache status such as "full cache", "partial cache" and "no cache"?', self::DOMAIN ); ?></h4>
62
+ <p><?php esc_html_e( 'The following is the explanation of the cache status.', self::DOMAIN ); ?></p>
63
+ <table class="view-table">
64
+ <thead>
65
+ <tr>
66
+ <th><?php esc_html_e( 'Cache Status', self::DOMAIN ); ?></th>
67
+ <th><?php esc_html_e( 'Description', self::DOMAIN ); ?></th>
68
+ </tr>
69
+ </thead>
70
+ <tbody>
71
+ <tr><td><?php esc_html_e( 'full cache', self::DOMAIN ); ?></td><td><?php esc_html_e( 'Counts for configured all SNS are cached.', self::DOMAIN ); ?></td></tr>
72
+ <tr><td><?php esc_html_e( 'partial cache', self::DOMAIN ); ?></td><td><?php esc_html_e( 'A subset of counts for configured SNS are cached.', self::DOMAIN ); ?></td></tr>
73
+ <tr><td><?php esc_html_e( 'no cache', self::DOMAIN ); ?></td><td><?php esc_html_e( 'Count for configured SNS are not cached at all.', self::DOMAIN ); ?></td></tr>
74
+ </tbody>
75
+ </table>
76
+ <h4><?php esc_html_e( 'How can I get share count from the cache?', self::DOMAIN ); ?></h4>
77
+ <p><?php esc_html_e( 'The share count is retrieved from the cache using the following functions in the WordPress loop such as query_posts(), get_posts() and WP_Query().', self::DOMAIN ); ?></p>
78
+ <table class="view-table">
79
+ <thead>
80
+ <tr>
81
+ <th><?php esc_html_e( 'Function', self::DOMAIN ); ?></th>
82
+ <th><?php esc_html_e( 'Description', self::DOMAIN ); ?></th>
83
+ </tr>
84
+ </thead>
85
+ <tbody>
86
+ <tr><td>scc_get_share_twitter()</td><td><?php esc_html_e( 'Twitter share count is returned from cache.', self::DOMAIN ); ?></td></tr>
87
+ <tr><td>scc_get_share_facebook()</td><td><?php esc_html_e( 'Facebook share count is returned from cache.', self::DOMAIN ); ?></td></tr>
88
+ <tr><td>scc_get_share_hatebu()</td><td><?php esc_html_e( 'Hatena Bookmark share count is returned from cache.', self::DOMAIN ); ?></td></tr>
89
+ <tr><td>scc_get_share_pocket()</td><td><?php esc_html_e( 'Pocket share count is returned from cache.', self::DOMAIN ); ?></td></tr>
90
+ <tr><td>scc_get_share_pinterest()</td><td><?php esc_html_e( 'Pinterest share count is returned from cache.', self::DOMAIN ); ?></td></tr>
91
+ <tr><td>scc_get_share_linkedin()</td><td><?php esc_html_e( 'Linkedin share count is returned from cache.', self::DOMAIN ); ?></td></tr>
92
+ <tr><td>scc_get_share_total()</td><td><?php esc_html_e( 'Total share count of selected SNS is returned from cache.', self::DOMAIN ); ?></td></tr>
93
+ </tbody>
94
+ </table>
95
+ <h4><?php esc_html_e( 'How can I get follower count from the cache?', self::DOMAIN ); ?></h4>
96
+ <p><?php esc_html_e( 'The follower count is retrieved from the cache using the following functions.', self::DOMAIN ); ?></p>
97
+ <table class="view-table">
98
+ <thead>
99
+ <tr>
100
+ <th><?php esc_html_e( 'Function', self::DOMAIN ); ?></th>
101
+ <th><?php esc_html_e( 'Description', self::DOMAIN ); ?></th>
102
+ </tr>
103
+ </thead>
104
+ <tbody>
105
+ <tr><td>scc_get_follow_feedly()</td><td><?php esc_html_e( 'Feedly follower count is returned from cache.', self::DOMAIN ); ?></td></tr>
106
+ <tr><td>scc_get_follow_twitter()</td><td><?php esc_html_e( 'Twitter follower count is returned from cache.', self::DOMAIN ); ?></td></tr>
107
+ <tr><td>scc_get_follow_facebook()</td><td><?php esc_html_e( 'Facebook follower count is returned from cache.', self::DOMAIN ); ?></td></tr>
108
+ <tr><td>scc_get_follow_instagram()</td><td><?php esc_html_e( 'Instagram follower count is returned from cache.', self::DOMAIN ); ?></td></tr>
109
+ <tr><td>scc_get_follow_push7()</td><td><?php esc_html_e( 'Push7 follower count is returned from cache.', self::DOMAIN ); ?></td></tr>
110
+ <tr><td>scc_get_follow_onesignal()</td><td><?php esc_html_e( 'OneSignal follower count is returned from cache.', self::DOMAIN ); ?></td></tr>
111
+ </tbody>
112
+ </table>
113
+ <h4><?php esc_html_e( 'Example Code', self::DOMAIN ); ?></h4>
114
+ <?php esc_html_e( 'The code below describes a simple example which displays share count and follower count using the above functions.', self::DOMAIN ); ?>
115
  <pre><code class="php">
116
  &lt;?php
117
  $query_args = array(
130
 
131
  if ( function_exists( &#039;scc_get_share_twitter&#039; ) &amp;&amp;
132
  function_exists( &#039;scc_get_share_facebook&#039; ) &amp;&amp;
 
133
  function_exists( &#039;scc_get_share_pocket&#039; ) &amp;&amp;
134
  function_exists( &#039;scc_get_share_pinterest&#039; ) &amp;&amp;
135
  function_exists( &#039;scc_get_share_linkedin&#039; ) &amp;&amp;
139
  // in order to get share count for current post and follower count.
140
  echo &#039;&lt;div&gt;Twitter share count: &#039; . scc_get_share_twitter() . &#039;&lt;/div&gt;&#039;;
141
  echo &#039;&lt;div&gt;Facebook share count: &#039; . scc_get_share_facebook() . &#039;&lt;/div&gt;&#039;;
 
142
  echo &#039;&lt;div&gt;Pocket share count: &#039; . scc_get_share_pocket() . &#039;&lt;/div&gt;&#039;;
143
  echo &#039;&lt;div&gt;Pinterest share count: &#039; . scc_get_share_pinterest() . &#039;&lt;/div&gt;&#039;;
144
  echo &#039;&lt;div&gt;Linkedin share count: &#039; . scc_get_share_linkedin() . &#039;&lt;/div&gt;&#039;;
152
  function_exists( &#039;scc_get_follow_twitter&#039; ) &amp;&amp;
153
  function_exists( &#039;scc_get_follow_facebook&#039; ) &amp;&amp;
154
  function_exists( &#039;scc_get_follow_instagram&#039; ) &amp;&amp;
155
+ function_exists( &#039;scc_get_follow_push7&#039; ) &amp;&amp;
156
+ function_exists( &#039;scc_get_follow_onesignal&#039; )
157
  ) {
158
  // You can use the given function in order to get follower count.
159
  echo &#039;&lt;div&gt;Feedly follower count: &#039; . scc_get_follow_feedly() . &#039;&lt;/div&gt;&#039;;
161
  echo &#039;&lt;div&gt;Facebook follower count: &#039; . scc_get_follow_facebook() . &#039;&lt;/div&gt;&#039;;
162
  echo &#039;&lt;div&gt;Instagram follower count: &#039; . scc_get_follow_instagram() . &#039;&lt;/div&gt;&#039;;
163
  echo &#039;&lt;div&gt;Push7 follower count: &#039; . scc_get_follow_push7() . &#039;&lt;/div&gt;&#039;;
164
+ echo &#039;&lt;div&gt;OneSignal follower count: &#039; . scc_get_follow_onesignal() . &#039;&lt;/div&gt;&#039;;
165
  }
166
  ?&gt;
167
  </code></pre>
168
+ <script>hljs.initHighlightingOnLoad();</script>
169
+ <h4><?php esc_html_e( 'How can I access specific custom field containing each share count?', self::DOMAIN ); ?></h4>
170
+ <p><?php esc_html_e( 'Custom fields including share count are accessed using the following meta keys.', self::DOMAIN ); ?></p>
171
+ <table class="view-table">
172
+ <thead>
173
+ <tr>
174
+ <th><?php esc_html_e( 'Meta Key', self::DOMAIN ); ?></th>
175
+ <th><?php esc_html_e( 'Description', self::DOMAIN ); ?></th>
176
+ </tr>
177
+ </thead>
178
+ <tbody>
179
+ <tr><td>scc_share_count_twitter</td><td><?php esc_html_e( 'A meta key to access Twitter share count', self::DOMAIN ); ?></td></tr>
180
+ <tr><td>scc_share_count_facebook</td><td><?php esc_html_e( 'A meta key to access Facebook share count', self::DOMAIN ); ?></td></tr>
181
+ <tr><td>scc_share_count_hatebu</td><td><?php esc_html_e( 'A meta key to access Hatena Bookmark share count', self::DOMAIN ); ?></td></tr>
182
+ <tr><td>scc_share_count_pocket</td><td><?php esc_html_e( 'A meta key to access Pocket share count', self::DOMAIN ); ?></td></tr>
183
+ <tr><td>scc_share_count_pinterest</td><td><?php esc_html_e( 'A meta key to access Pinterest share count', self::DOMAIN ); ?></td></tr>
184
+ <tr><td>scc_share_count_linkedin</td><td><?php esc_html_e( 'A meta key to access Linkedin share count', self::DOMAIN ); ?></td></tr>
185
+ <tr><td>scc_share_count_total</td><td><?php esc_html_e( 'A meta key to access total share count', self::DOMAIN ); ?></td></tr>
186
+ </tbody>
187
+ </table>
188
+ <h4><?php esc_html_e( 'How can I access specific custom field containing each variation of share count?', self::DOMAIN ); ?></h4>
189
+ <p><?php esc_html_e( 'Custom fields including variation of share count are accessed using the following meta keys.', self::DOMAIN ); ?></p>
190
+ <table class="view-table">
191
+ <thead>
192
+ <tr>
193
+ <th><?php esc_html_e( 'Meta Key', self::DOMAIN ); ?></th>
194
+ <th><?php esc_html_e( 'Description', self::DOMAIN ); ?></th>
195
+ </tr>
196
+ </thead>
197
+ <tbody>
198
+ <tr><td>scc_share_delta_twitter</td><td><?php esc_html_e( 'A meta key to access variation of Twitter share count', self::DOMAIN ); ?></td></tr>
199
+ <tr><td>scc_share_delta_facebook</td><td><?php esc_html_e( 'A meta key to access variation of Facebook share count', self::DOMAIN ); ?></td></tr>
200
+ <tr><td>scc_share_delta_hatebu</td><td><?php esc_html_e( 'A meta key to access variation of Hatena Bookmark share count', self::DOMAIN ); ?></td></tr>
201
+ <tr><td>scc_share_delta_pocket</td><td><?php esc_html_e( 'A meta key to access variation of Pocket share count', self::DOMAIN ); ?></td></tr>
202
+ <tr><td>scc_share_delta_pinterest</td><td><?php esc_html_e( 'A meta key to access variation of Pinterest share count', self::DOMAIN ); ?></td></tr>
203
+ <tr><td>scc_share_delta_linkedin</td><td><?php esc_html_e( 'A meta key to access variation of Linkedin share count', self::DOMAIN ); ?></td></tr>
204
+ <tr><td>scc_share_delta_total</td><td><?php esc_html_e( 'A meta key to access variation of total share count', self::DOMAIN ); ?></td></tr>
205
+ </tbody>
206
+ </table>
 
 
 
207
  </div>
208
  </div>
209
  </div>
210
  </div>
211
+ </div>
includes/admin-hot-content.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  admin-hot-content.php
4
 
5
  Description: Option page implementation
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,197 +27,172 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
- if ( ! defined( 'ABSPATH' ) ) exit(); // Exit if accessed directly
 
 
31
 
32
- $posts_per_page = 50;
33
 
34
- $sort_mode = false;
35
- $sort_exec_key = '';
36
 
37
- if ( isset( $_GET["action"] ) && $_GET["action"] === 'sort' ) {
38
- if ( current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
39
- if ( isset( $_GET["key"] ) ) {
40
- $sort_mode = true;
41
- $sns = $_GET["key"];
42
 
43
- if ( $sns === 'Google' ) {
44
- $sns = $sns . '+';
45
- }
46
 
47
- $sort_exec_key = $sns;
48
 
49
- $meta_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( $sns );
50
- $meta_key2 = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( $sns );
51
- }
52
  }
53
-
54
  }
 
55
 
56
- $paged = 1;
57
 
58
- if ( isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) && $_GET['paged'] > 0 ) {
59
- $paged = $_GET['paged'];
60
- } else {
61
- $paged = 1;
62
- }
63
-
64
- $share_base_cache_target = $this->share_base_cache_target ;
65
- unset( $share_base_cache_target[self::REF_CRAWL_DATE] );
66
-
67
- ?>
68
- <div class="wrap">
69
- <h2><a href="admin.php?page=scc-hot-content"><?php _e( 'SNS Count Cache', self::DOMAIN ); ?></a></h2>
70
- <div class="sns-cnt-cache">
71
- <h3 class="nav-tab-wrapper">
72
- <a class="nav-tab" href="admin.php?page=scc-dashboard"><?php _e( 'Dashboard', self::DOMAIN ); ?></a>
73
- <a class="nav-tab" href="admin.php?page=scc-cache-status"><?php _e( 'Cache Status', self::DOMAIN ); ?></a>
74
- <a class="nav-tab" href="admin.php?page=scc-share-count"><?php _e( 'Share Count', self::DOMAIN ); ?></a>
75
- <a class="nav-tab nav-tab-active" href="admin.php?page=scc-hot-content"><?php _e( 'Hot Content', self::DOMAIN ); ?></a>
76
- <a class="nav-tab" href="admin.php?page=scc-setting"><?php _e( 'Setting', self::DOMAIN ); ?></a>
77
- <a class="nav-tab" href="admin.php?page=scc-help"><?php _e( 'Help', self::DOMAIN ); ?></a>
78
- </h3>
79
- <div class="metabox-holder">
80
- <div id="share-each-content" class="postbox">
81
- <div class="handlediv" title="Click to toggle"><br></div>
82
- <h3 class="hndle"><span><?php _e( 'Hot Content', self::DOMAIN ); ?></span></h3>
83
- <div class="inside">
84
- <table class="view-table">
85
- <thead>
86
- <tr>
87
- <th>No.</th>
88
- <th><?php _e( 'Content', self::DOMAIN ); ?></th>
89
- <?php
90
- foreach ( $share_base_cache_target as $sns => $active ) {
91
- if ( $active ) {
92
- $sort_key = $sns;
93
 
94
- if ( $sort_key === self::REF_SHARE_GPLUS ) {
95
- $sort_key = str_replace( '+', '', $sort_key );
96
- }
97
 
98
- $sort_url = esc_url( 'admin.php?page=scc-hot-content&action=sort&key=' . $sort_key );
99
-
100
- $sns_name = '';
101
-
102
- switch ( $sns ) {
103
- case self::REF_SHARE_TWITTER:
104
- $sns_name = __( 'Twitter', self::DOMAIN );
105
- break;
106
- case self::REF_SHARE_FACEBOOK:
107
- $sns_name = __( 'Facebook', self::DOMAIN );
108
- break;
109
- case self::REF_SHARE_GPLUS:
110
- $sns_name = __( 'Google+', self::DOMAIN );
111
- break;
112
- case self::REF_SHARE_POCKET:
113
- $sns_name = __( 'Pocket', self::DOMAIN );
114
- break;
115
- case self::REF_SHARE_HATEBU:
116
- $sns_name = __( 'Hatebu', self::DOMAIN );
117
- break;
118
- case self::REF_SHARE_PINTEREST:
119
- $sns_name = __( 'Pinterest', self::DOMAIN );
120
- break;
121
- case self::REF_SHARE_LINKEDIN:
122
- $sns_name = __( 'Linkedin', self::DOMAIN );
123
- break;
124
- case self::REF_SHARE_TOTAL:
125
- $sns_name = __( 'Total', self::DOMAIN );
126
- break;
127
- }
128
 
129
- if ( $sns === $sort_exec_key ){
130
- echo '<th><a class="sort-exec-key" href="' . $sort_url . '">' . esc_html( $sns_name ) . '</th>';
131
- } else {
132
- echo '<th><a href="' . $sort_url . '">' . esc_html( $sns_name ) . '</th>';
133
- }
134
- }
135
  }
136
- ?>
137
- </tr>
138
- </thead>
139
- <tbody>
 
 
140
  <?php
141
- $meta_query = array();
142
 
143
- if ( $sort_mode ) {
144
- if ( version_compare( get_bloginfo('version'), '4.2', '>=') ) {
145
- $meta_query['relation'] = 'AND';
146
 
147
- $meta_query[0]['relation'] = 'OR';
148
 
149
- foreach ( $share_base_cache_target as $sns => $active ) {
150
- if ( $active ) {
151
- $meta_query[0][] = array(
152
- 'key' => 'scc_share_delta_' . strtolower( $sns ),
153
- 'value' => 0,
154
- 'compare'=>'>',
155
- 'type'=>'NUMERIC'
156
- );
157
- }
158
  }
 
159
 
160
- $meta_query['meta_primary'] = array(
161
- 'key' => $meta_key,
162
- 'type'=>'NUMERIC'
163
- );
164
 
165
- $meta_query['meta_secondary'] = array(
166
- 'key' => $meta_key2,
167
- 'type'=>'NUMERIC'
168
- );
169
 
170
- SCC_Common_Util::log( $meta_query );
171
-
172
- SCC_Common_Util::log( 'version: ' . get_bloginfo( 'version') );
173
-
174
- $query_args = array(
175
- 'post_type' => $this->share_base_cache_post_types,
176
- 'post_status' => 'publish',
177
- 'posts_per_page' => $posts_per_page,
178
- 'paged' => $paged,
179
- 'update_post_term_cache' => false,
180
- 'meta_query' => $meta_query,
181
- 'orderby' => array(
182
- 'meta_primary' => 'DESC',
183
- 'meta_secondary' => 'DESC'
184
- )
185
- );
186
- } else {
187
- foreach ( $share_base_cache_target as $sns => $active ) {
188
- if ( $active ) {
189
- $meta_query[] = array(
190
- 'key' => 'scc_share_delta_' . strtolower( $sns ),
191
- 'value' => 0,
192
- 'compare'=>'>',
193
- 'type'=>'NUMERIC'
194
- );
195
- }
196
- }
197
 
198
- $meta_query['relation'] = 'OR';
199
-
200
- $query_args = array(
201
- 'post_type' => $this->share_base_cache_post_types,
202
- 'post_status' => 'publish',
203
- 'posts_per_page' => $posts_per_page,
204
- 'paged' => $paged,
205
- 'meta_key' => $meta_key,
206
- 'orderby' => 'meta_value_num',
207
- 'update_post_term_cache' => false,
208
- 'order' => 'DESC',
209
- 'meta_query' => $meta_query
210
- );
211
- }
212
  } else {
213
  foreach ( $share_base_cache_target as $sns => $active ) {
214
  if ( $active ) {
215
  $meta_query[] = array(
216
  'key' => 'scc_share_delta_' . strtolower( $sns ),
217
  'value' => 0,
218
- 'compare'=>'>',
219
- 'type'=>'NUMERIC'
220
- );
221
  }
222
  }
223
 
@@ -228,107 +203,135 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
228
  'post_status' => 'publish',
229
  'posts_per_page' => $posts_per_page,
230
  'paged' => $paged,
 
 
 
 
231
  'meta_query' => $meta_query,
232
- 'update_post_term_cache' => false
 
 
 
 
 
 
 
 
 
233
  );
 
234
  }
235
 
236
- $posts_query = new WP_Query( $query_args );
237
 
238
- $count = ( $paged - 1 ) * $posts_per_page + 1;
 
 
 
 
 
 
 
 
239
 
240
- if ( $posts_query->have_posts() ) {
241
- while ( $posts_query->have_posts() ) {
242
- $posts_query->the_post();
243
- ?>
244
- <tr>
245
- <td><?php echo $count; ?></td>
246
- <td><a href="<?php echo esc_url( get_permalink( get_the_ID() ) ); ?>" target="_blank"><?php echo esc_html( get_the_title( get_the_ID() ) ); ?></a></td>
 
 
 
 
247
  <?php
248
- $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( get_the_ID() );
249
-
250
- if ( ! $sort_mode && false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
251
- foreach ( $share_base_cache_target as $sns => $active ) {
252
- if ( $active ) {
253
- //delta
254
- $meta_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( $sns );
255
- $sns_deltas[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
256
-
257
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
258
- echo '<td class="share-count">';
259
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
260
-
261
- if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
262
- echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
263
- } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
264
- echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
265
- }
266
-
267
- echo '</td>';
268
- } else {
269
- echo '<td class="not-cached share-count">';
270
- _e( 'N/A', self::DOMAIN );
271
- echo '</td>';
272
  }
 
 
 
 
 
 
273
  }
274
  }
275
- } else {
276
- foreach ( $share_base_cache_target as $sns => $active ) {
277
- if ( $active ){
278
- $meta_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( $sns );
279
-
280
- $sns_counts[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
281
-
282
- //delta
283
- $meta_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( $sns );
284
- $sns_deltas[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
285
-
286
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] !== '' && $sns_counts[$sns] >= 0 ) {
287
- echo '<td class="share-count">';
288
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
289
-
290
- if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
291
- echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
292
- } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
293
- echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
294
- }
295
-
296
- echo '</td>';
297
- } else {
298
- echo '<td class="not-cached share-count">';
299
- _e( 'N/A', self::DOMAIN );
300
- echo '</td>';
301
  }
 
 
 
 
 
 
302
  }
303
  }
304
  }
305
- ?>
306
- </tr>
307
- <?php
308
- ++$count;
309
- }
310
- } else {
311
- echo '<tr>';
312
- echo '<td>' . $count . '</td>';
313
- echo '<td>' . __( 'No hot content.', self::DOMAIN ) . '</td>';
314
- foreach ( $share_base_cache_target as $sns => $active ) {
315
- if ( $active ) {
316
- echo '<td class="not-cached share-count">';
317
- _e( 'N/A', self::DOMAIN );
318
- echo '</td>';
319
- }
320
  }
321
- echo '</tr>';
322
  }
323
- ?>
324
- </tbody>
325
- </table>
326
- <?php
327
- $this->pagination( $posts_query->max_num_pages, '', $paged, true );
328
- wp_reset_postdata();
329
  ?>
330
- </div>
 
 
 
 
 
331
  </div>
332
  </div>
333
  </div>
334
  </div>
 
1
  <?php
2
+ /**
3
  admin-hot-content.php
4
 
5
  Description: Option page implementation
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ if ( ! defined( 'ABSPATH' ) ) {
31
+ exit(); // Exit if accessed directly
32
+ }
33
 
34
+ $posts_per_page = 50;
35
 
36
+ $sort_mode = false;
37
+ $sort_exec_key = '';
38
 
39
+ if ( isset( $_GET['action'] ) && 'sort' === wp_unslash( $_GET['action'] ) ) {
40
+ if ( current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
41
+ if ( isset( $_GET['key'] ) ) {
42
+ $sort_mode = true;
43
+ $sns = wp_unslash( $_GET['key'] );
44
 
45
+ if ( 'Google' === $sns ) {
46
+ $sns = $sns . '+';
47
+ }
48
 
49
+ $sort_exec_key = $sns;
50
 
51
+ $meta_key = $this->analytical_engines[ self::REF_SHARE_ANALYSIS ]->get_delta_key( $sns );
52
+ $meta_key2 = $this->cache_engines[ self::REF_SHARE_2ND ]->get_cache_key( $sns );
 
53
  }
 
54
  }
55
+ }
56
 
57
+ $paged = 1;
58
 
59
+ if ( isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) && 0 < $_GET['paged'] ) {
60
+ $paged = (int) wp_unslash( $_GET['paged'] );
61
+ } else {
62
+ $paged = 1;
63
+ }
64
+
65
+ $share_base_cache_target = $this->share_base_cache_target ;
66
+ unset( $share_base_cache_target[ self::REF_CRAWL_DATE ] );
67
+
68
+ ?>
69
+ <div class="wrap">
70
+ <h2><a href="admin.php?page=scc-hot-content"><?php esc_html_e( 'SNS Count Cache', self::DOMAIN ); ?></a></h2>
71
+ <div class="sns-cnt-cache">
72
+ <h3 class="nav-tab-wrapper">
73
+ <a class="nav-tab" href="admin.php?page=scc-dashboard"><?php esc_html_e( 'Dashboard', self::DOMAIN ); ?></a>
74
+ <a class="nav-tab" href="admin.php?page=scc-cache-status"><?php esc_html_e( 'Cache Status', self::DOMAIN ); ?></a>
75
+ <a class="nav-tab" href="admin.php?page=scc-share-count"><?php esc_html_e( 'Share Count', self::DOMAIN ); ?></a>
76
+ <a class="nav-tab nav-tab-active" href="admin.php?page=scc-hot-content"><?php esc_html_e( 'Hot Content', self::DOMAIN ); ?></a>
77
+ <a class="nav-tab" href="admin.php?page=scc-setting"><?php esc_html_e( 'Setting', self::DOMAIN ); ?></a>
78
+ <a class="nav-tab" href="admin.php?page=scc-help"><?php esc_html_e( 'Help', self::DOMAIN ); ?></a>
79
+ </h3>
80
+ <div class="metabox-holder">
81
+ <div id="share-each-content" class="postbox">
82
+ <div class="handlediv" title="Click to toggle"><br></div>
83
+ <h3 class="hndle"><span><?php esc_html_e( 'Hot Content', self::DOMAIN ); ?></span></h3>
84
+ <div class="inside">
85
+ <table class="tfloat view-table">
86
+ <thead>
87
+ <tr>
88
+ <th>No.</th>
89
+ <th><?php esc_html_e( 'Content', self::DOMAIN ); ?></th>
90
+ <?php
91
+ foreach ( $share_base_cache_target as $sns => $active ) {
92
+ if ( $active ) {
93
+ $sort_key = $sns;
94
 
95
+ if ( self::REF_SHARE_GPLUS === $sort_key ) {
96
+ $sort_key = str_replace( '+', '', $sort_key );
97
+ }
98
 
99
+ $sort_url = esc_url( 'admin.php?page=scc-hot-content&action=sort&key=' . $sort_key );
100
+
101
+ $sns_name = '';
102
+
103
+ switch ( $sns ) {
104
+ case self::REF_SHARE_TWITTER:
105
+ $sns_name = __( 'Twitter', self::DOMAIN );
106
+ break;
107
+ case self::REF_SHARE_FACEBOOK:
108
+ $sns_name = __( 'Facebook', self::DOMAIN );
109
+ break;
110
+ case self::REF_SHARE_GPLUS:
111
+ $sns_name = __( 'Google+', self::DOMAIN );
112
+ break;
113
+ case self::REF_SHARE_POCKET:
114
+ $sns_name = __( 'Pocket', self::DOMAIN );
115
+ break;
116
+ case self::REF_SHARE_HATEBU:
117
+ $sns_name = __( 'Hatebu', self::DOMAIN );
118
+ break;
119
+ case self::REF_SHARE_PINTEREST:
120
+ $sns_name = __( 'Pinterest', self::DOMAIN );
121
+ break;
122
+ case self::REF_SHARE_LINKEDIN:
123
+ $sns_name = __( 'Linkedin', self::DOMAIN );
124
+ break;
125
+ case self::REF_SHARE_TOTAL:
126
+ $sns_name = __( 'Total', self::DOMAIN );
127
+ break;
128
+ }
129
 
130
+ if ( $sns === $sort_exec_key ){
131
+ echo '<th><a class="sort-exec-key" href="' . $sort_url . '">' . esc_html( $sns_name ) . '</th>';
132
+ } else {
133
+ echo '<th><a href="' . $sort_url . '">' . esc_html( $sns_name ) . '</th>';
 
 
134
  }
135
+ }
136
+ }
137
+ ?>
138
+ </tr>
139
+ </thead>
140
+ <tbody>
141
  <?php
142
+ $meta_query = array();
143
 
144
+ if ( $sort_mode ) {
145
+ if ( version_compare( get_bloginfo( 'version' ), '4.2', '>=' ) ) {
146
+ $meta_query['relation'] = 'AND';
147
 
148
+ $meta_query[0]['relation'] = 'OR';
149
 
150
+ foreach ( $share_base_cache_target as $sns => $active ) {
151
+ if ( $active ) {
152
+ $meta_query[0][] = array(
153
+ 'key' => 'scc_share_delta_' . strtolower( $sns ),
154
+ 'value' => 0,
155
+ 'compare' => '>',
156
+ 'type' => 'NUMERIC',
157
+ );
 
158
  }
159
+ }
160
 
161
+ $meta_query['meta_primary'] = array(
162
+ 'key' => $meta_key,
163
+ 'type' => 'NUMERIC',
164
+ );
165
 
166
+ $meta_query['meta_secondary'] = array(
167
+ 'key' => $meta_key2,
168
+ 'type' => 'NUMERIC',
169
+ );
170
 
171
+ SCC_Logger::log( $meta_query );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
 
173
+ SCC_Logger::log( 'version: ' . get_bloginfo( 'version' ) );
174
+
175
+ $query_args = array(
176
+ 'post_type' => $this->share_base_cache_post_types,
177
+ 'post_status' => 'publish',
178
+ 'posts_per_page' => $posts_per_page,
179
+ 'paged' => $paged,
180
+ 'update_post_term_cache' => false,
181
+ 'meta_query' => $meta_query,
182
+ 'orderby' => array(
183
+ 'meta_primary' => 'DESC',
184
+ 'meta_secondary' => 'DESC',
185
+ ),
186
+ );
187
  } else {
188
  foreach ( $share_base_cache_target as $sns => $active ) {
189
  if ( $active ) {
190
  $meta_query[] = array(
191
  'key' => 'scc_share_delta_' . strtolower( $sns ),
192
  'value' => 0,
193
+ 'compare' => '>',
194
+ 'type' => 'NUMERIC',
195
+ );
196
  }
197
  }
198
 
203
  'post_status' => 'publish',
204
  'posts_per_page' => $posts_per_page,
205
  'paged' => $paged,
206
+ 'meta_key' => $meta_key,
207
+ 'orderby' => 'meta_value_num',
208
+ 'update_post_term_cache' => false,
209
+ 'order' => 'DESC',
210
  'meta_query' => $meta_query,
211
+ );
212
+ } // End if().
213
+ } else {
214
+ foreach ( $share_base_cache_target as $sns => $active ) {
215
+ if ( $active ) {
216
+ $meta_query[] = array(
217
+ 'key' => 'scc_share_delta_' . strtolower( $sns ),
218
+ 'value' => 0,
219
+ 'compare' => '>',
220
+ 'type' => 'NUMERIC',
221
  );
222
+ }
223
  }
224
 
225
+ $meta_query['relation'] = 'OR';
226
 
227
+ $query_args = array(
228
+ 'post_type' => $this->share_base_cache_post_types,
229
+ 'post_status' => 'publish',
230
+ 'posts_per_page' => $posts_per_page,
231
+ 'paged' => $paged,
232
+ 'meta_query' => $meta_query,
233
+ 'update_post_term_cache' => false,
234
+ );
235
+ } // End if().
236
 
237
+ $posts_query = new WP_Query( $query_args );
238
+
239
+ $count = ( $paged - 1 ) * $posts_per_page + 1;
240
+
241
+ if ( $posts_query->have_posts() ) {
242
+ while ( $posts_query->have_posts() ) {
243
+ $posts_query->the_post();
244
+ ?>
245
+ <tr>
246
+ <td><?php echo esc_html( $count ); ?></td>
247
+ <td><a href="<?php echo esc_url( get_permalink( get_the_ID() ) ); ?>" target="_blank"><?php echo esc_html( get_the_title( get_the_ID() ) ); ?></a></td>
248
  <?php
249
+ $transient_id = $this->cache_engines[ self::REF_SHARE_BASE ]->get_cache_key( get_the_ID() );
250
+
251
+ $sns_counts = get_transient( $transient_id );
252
+
253
+ if ( ! $sort_mode && false !== $sns_counts ) {
254
+ foreach ( $share_base_cache_target as $sns => $active ) {
255
+ if ( $active ) {
256
+ //delta
257
+ $meta_key = $this->analytical_engines[ self::REF_SHARE_ANALYSIS ]->get_delta_key( $sns );
258
+ $sns_deltas[ $sns ] = get_post_meta( get_the_ID(), $meta_key, true );
259
+
260
+ if ( SCC_Cache::has_value( $sns_counts[ $sns ] ) && 0 <= $sns_counts[ $sns ] ) {
261
+ echo '<td class="share-count">';
262
+ echo esc_html( number_format( (int) $sns_counts[ $sns ] ) );
263
+
264
+ if ( SCC_Cache::has_value( $sns_deltas[ $sns ] ) && 0 < $sns_deltas[ $sns ] ) {
265
+ echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[ $sns ] ) ) . '</span>)';
266
+ } elseif ( SCC_Cache::has_value( $sns_deltas[ $sns ] ) && 0 > $sns_deltas[ $sns ] ) {
267
+ echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[ $sns ] ) ) . '</span>)';
 
 
 
 
 
268
  }
269
+
270
+ echo '</td>';
271
+ } else {
272
+ echo '<td class="not-cached share-count">';
273
+ esc_html_e( 'N/A', self::DOMAIN );
274
+ echo '</td>';
275
  }
276
  }
277
+ }
278
+ } else {
279
+ foreach ( $share_base_cache_target as $sns => $active ) {
280
+ if ( $active ) {
281
+ $meta_key = $this->cache_engines[ self::REF_SHARE_2ND ]->get_cache_key( $sns );
282
+
283
+ $sns_counts[ $sns ] = get_post_meta( get_the_ID(), $meta_key, true );
284
+
285
+ //delta
286
+ $meta_key = $this->analytical_engines[ self::REF_SHARE_ANALYSIS ]->get_delta_key( $sns );
287
+ $sns_deltas[ $sns ] = get_post_meta( get_the_ID(), $meta_key, true );
288
+
289
+ if ( SCC_Cache::has_value( $sns_counts[ $sns ] ) && 0 <= $sns_counts[ $sns ] ) {
290
+ echo '<td class="share-count">';
291
+ echo esc_html( number_format( (int) $sns_counts[ $sns ] ) );
292
+
293
+ if ( SCC_Cache::has_value( $sns_deltas[ $sns ] ) && 0 < $sns_deltas[ $sns ] ) {
294
+ echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[ $sns ] ) ) . '</span>)';
295
+ } elseif ( SCC_Cache::has_value( $sns_deltas[ $sns ] ) && 0 > $sns_deltas[ $sns ] ) {
296
+ echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[ $sns ] ) ) . '</span>)';
 
 
 
 
 
 
297
  }
298
+
299
+ echo '</td>';
300
+ } else {
301
+ echo '<td class="not-cached share-count">';
302
+ esc_html_e( 'N/A', self::DOMAIN );
303
+ echo '</td>';
304
  }
305
  }
306
  }
307
+ } // End if().
308
+ ?>
309
+ </tr>
310
+ <?php
311
+ ++$count;
312
+ } // End while().
313
+ } else {
314
+ echo '<tr>';
315
+ echo '<td>' . $count . '</td>';
316
+ echo '<td>' . __( 'No hot content.', self::DOMAIN ) . '</td>';
317
+ foreach ( $share_base_cache_target as $sns => $active ) {
318
+ if ( $active ) {
319
+ echo '<td class="not-cached share-count">';
320
+ esc_html_e( 'N/A', self::DOMAIN );
321
+ echo '</td>';
322
  }
 
323
  }
324
+ echo '</tr>';
325
+ } // End if().
 
 
 
 
326
  ?>
327
+ </tbody>
328
+ </table>
329
+ <?php
330
+ $this->pagination( $posts_query->max_num_pages, '', $paged, true );
331
+ wp_reset_postdata();
332
+ ?>
333
  </div>
334
  </div>
335
  </div>
336
  </div>
337
+ </div>
includes/admin-notice.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  admin-notice.php
4
 
5
  Description:
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,22 +27,26 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
- if ( ! defined( 'ABSPATH' ) ) exit(); // Exit if accessed directly
 
 
 
 
31
 
32
- if ( $messages = get_option( self::OPT_COMMON_ERROR_MESSAGE ) ) {
33
  ?>
34
  <div class="error">
35
  <ul>
36
- <?php
37
- foreach( $messages as $message ) {
38
- ?>
39
  <li><?php echo esc_html( $message ); ?></li>
40
- <?php
41
- }
42
- ?>
43
  </ul>
44
  </div>
45
  <?php
46
- delete_option( self::OPT_COMMON_ERROR_MESSAGE );
47
- }
48
  ?>
1
  <?php
2
+ /**
3
  admin-notice.php
4
 
5
  Description:
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ if ( ! defined( 'ABSPATH' ) ) {
31
+ exit(); // Exit if accessed directly
32
+ }
33
+
34
+ $messages = get_option( self::OPT_COMMON_ERROR_MESSAGE );
35
 
36
+ if ( $messages ) {
37
  ?>
38
  <div class="error">
39
  <ul>
40
+ <?php
41
+ foreach ( $messages as $message ) {
42
+ ?>
43
  <li><?php echo esc_html( $message ); ?></li>
44
+ <?php
45
+ }
46
+ ?>
47
  </ul>
48
  </div>
49
  <?php
50
+ delete_option( self::OPT_COMMON_ERROR_MESSAGE );
51
+ }
52
  ?>
includes/admin-setting.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  admin-setting.php
4
 
5
  Description: Option page implementation
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,354 +27,394 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
- if ( ! defined( 'ABSPATH' ) ) exit(); // Exit if accessed directly
 
 
31
 
32
- $tmp_instagram_access_token = '';
33
- $tmp_facebook_access_token = '';
34
- $tmp_twitter_bearer_token = '';
35
 
36
- if ( isset( $_POST['_wpnonce'] ) && $_POST['_wpnonce'] && check_admin_referer( __FILE__, '_wpnonce' ) ) {
37
- if ( isset( $_POST["update_all_options"] ) && $_POST["update_all_options"] === __( 'Update All Options', self::DOMAIN ) ) {
 
38
 
39
  $wp_error = new WP_Error();
40
 
41
- //$settings = array();
42
  $settings = get_option( self::DB_SETTINGS );
43
 
44
  $share_base_cache_target = array();
45
  $follow_base_cache_target = array();
46
 
47
- if ( isset( $_POST["share_base_custom_post_types"] ) && $_POST["share_base_custom_post_types"] ) {
48
- $settings[self::DB_SHARE_CUSTOM_POST_TYPES] = explode( ',', sanitize_text_field( $_POST["share_base_custom_post_types"] ) );
49
  } else {
50
- $settings[self::DB_SHARE_CUSTOM_POST_TYPES] = array();
51
  }
52
 
53
- if ( isset( $_POST["share_base_check_interval"] ) && $_POST["share_base_check_interval"] ) {
54
- $tmp_share_base_check_interval = sanitize_text_field( $_POST["share_base_check_interval"] );
55
  if ( is_numeric( $tmp_share_base_check_interval ) ) {
56
- $settings[self::DB_SHARE_BASE_CHECK_INTERVAL] = $tmp_share_base_check_interval;
57
  }
58
  }
59
 
60
- if ( isset( $_POST["share_base_posts_per_check"] ) && $_POST["share_base_posts_per_check"] ) {
61
- $tmp_share_base_posts_per_check = sanitize_text_field( $_POST["share_base_posts_per_check"] );
62
  if ( is_numeric( $tmp_share_base_posts_per_check ) ) {
63
- $settings[self::DB_SHARE_BASE_POSTS_PER_CHECK] = $tmp_share_base_posts_per_check;
64
  }
65
  }
66
 
67
- if ( isset( $_POST["dynamic_cache_mode"] ) && $_POST["dynamic_cache_mode"] ) {
68
- $settings[self::DB_COMMON_DYNAMIC_CACHE_MODE] = sanitize_text_field( $_POST["dynamic_cache_mode"] );
69
  }
70
 
71
- if ( isset( $_POST["fault_tolerance_mode"] ) && $_POST["fault_tolerance_mode"] ) {
72
- $settings[self::DB_COMMON_FAULT_TOLERANCE_MODE] = sanitize_text_field( $_POST["fault_tolerance_mode"] );
73
  }
74
 
75
- if ( isset( $_POST["share_variation_analysis_mode"] ) && $_POST["share_variation_analysis_mode"] ) {
76
- $settings[self::DB_SHARE_VARIATION_ANALYSIS_MODE] = sanitize_text_field( $_POST["share_variation_analysis_mode"] );
77
  }
78
 
79
- if ( isset( $_POST["follow_variation_analysis_mode"] ) && $_POST["follow_variation_analysis_mode"] ) {
80
- $settings[self::DB_FOLLOW_VARIATION_ANALYSIS_MODE] = sanitize_text_field( $_POST["follow_variation_analysis_mode"] );
81
  }
82
 
83
- if ( isset( $_POST["share_rush_new_content_term"] ) && $_POST["share_rush_new_content_term"] ) {
84
- $tmp_share_rush_new_content_term = sanitize_text_field( $_POST["share_rush_new_content_term"] );
85
  if ( is_numeric( $tmp_share_rush_new_content_term ) ) {
86
- $settings[self::DB_SHARE_RUSH_NEW_CONTENT_TERM] = $tmp_share_rush_new_content_term;
87
  }
88
  }
89
 
90
- if ( isset( $_POST["share_rush_check_interval"] ) && $_POST["share_rush_check_interval"] ) {
91
- $tmp_share_rush_check_interval = sanitize_text_field( $_POST["share_rush_check_interval"] );
92
  if ( is_numeric( $tmp_share_rush_check_interval ) ) {
93
- $settings[self::DB_SHARE_RUSH_CHECK_INTERVAL] = $tmp_share_rush_check_interval;
94
  }
95
  }
96
 
97
- if ( isset( $_POST["share_rush_posts_per_check"] ) && $_POST["share_rush_posts_per_check"] ) {
98
- $tmp_share_rush_posts_per_check = sanitize_text_field( $_POST["share_rush_posts_per_check"] );
99
  if ( is_numeric( $tmp_share_rush_posts_per_check ) ) {
100
- $settings[self::DB_SHARE_RUSH_POSTS_PER_CHECK] = $tmp_share_rush_posts_per_check;
101
  }
102
  }
103
 
104
- if ( isset( $_POST["data_export_mode"] ) && $_POST["data_export_mode"] ) {
105
- $settings[self::DB_COMMON_DATA_EXPORT_MODE] = sanitize_text_field( $_POST["data_export_mode"] );
106
  }
107
 
108
- if ( isset( $_POST["data_export_interval"] ) && $_POST["data_export_interval"] ) {
109
- $tmp_data_export_interval = sanitize_text_field( $_POST["data_export_interval"] );
110
  if ( is_numeric( $tmp_data_export_interval ) ) {
111
- $settings[self::DB_COMMON_DATA_EXPORT_INTERVAL] = $tmp_data_export_interval;
112
  }
113
  }
114
 
115
- if ( isset( $_POST["common_data_crawler_retry_limit"] ) && $_POST["common_data_crawler_retry_limit"] ) {
116
- $tmp_common_data_crawler_retry_limit = sanitize_text_field( $_POST["common_data_crawler_retry_limit"] );
117
  if ( is_numeric( $tmp_common_data_crawler_retry_limit ) ) {
118
- $settings[self::DB_COMMON_CRAWLER_RETRY_LIMIT] = $tmp_common_data_crawler_retry_limit;
119
  }
120
  }
121
 
122
- if ( isset( $_POST["share_base_cache_target_twitter"] ) && $_POST["share_base_cache_target_twitter"] ) {
123
- $share_base_cache_target[self::REF_SHARE_TWITTER] = true;
124
  } else {
125
- $share_base_cache_target[self::REF_SHARE_TWITTER] = false;
126
  }
127
 
128
- if ( isset( $_POST["share_alternative_twitter_api"] ) && $_POST["share_alternative_twitter_api"] ) {
129
- $settings[self::DB_SHARE_BASE_TWITTER_API] = sanitize_text_field( $_POST["share_alternative_twitter_api"] );
130
  }
131
 
132
- if ( isset( $_POST["share_base_cache_target_facebook"] ) && $_POST["share_base_cache_target_facebook"] ) {
133
- $share_base_cache_target[self::REF_SHARE_FACEBOOK] = true;
134
  } else {
135
- $share_base_cache_target[self::REF_SHARE_FACEBOOK] = false;
136
  }
137
 
138
- if ( isset( $_POST["share_base_cache_target_gplus"] ) && $_POST["share_base_cache_target_gplus"] ) {
139
- $share_base_cache_target[self::REF_SHARE_GPLUS] = true;
140
  } else {
141
- $share_base_cache_target[self::REF_SHARE_GPLUS] = false;
142
  }
143
 
144
- if ( isset( $_POST["share_base_cache_target_pocket"] ) && $_POST["share_base_cache_target_pocket"] ) {
145
- $share_base_cache_target[self::REF_SHARE_POCKET] = true;
146
  } else {
147
- $share_base_cache_target[self::REF_SHARE_POCKET] = false;
148
  }
149
 
150
- if ( isset( $_POST["share_base_cache_target_hatebu"] ) && $_POST["share_base_cache_target_hatebu"] ) {
151
- $share_base_cache_target[self::REF_SHARE_HATEBU] = true;
152
  } else {
153
- $share_base_cache_target[self::REF_SHARE_HATEBU] = false;
154
  }
155
 
156
- if ( isset( $_POST["share_base_cache_target_pinterest"] ) && $_POST["share_base_cache_target_pinterest"] ) {
157
- $share_base_cache_target[self::REF_SHARE_PINTEREST] = true;
158
  } else {
159
- $share_base_cache_target[self::REF_SHARE_PINTEREST] = false;
160
  }
161
 
162
- if ( isset( $_POST["share_base_cache_target_linkedin"] ) && $_POST["share_base_cache_target_linkedin"] ) {
163
- $share_base_cache_target[self::REF_SHARE_LINKEDIN] = true;
164
  } else {
165
- $share_base_cache_target[self::REF_SHARE_LINKEDIN] = false;
166
  }
167
 
168
  if ( ! empty( $share_base_cache_target ) ) {
169
- $settings[self::DB_SHARE_CACHE_TARGET] = $share_base_cache_target;
170
  }
171
 
172
- if ( isset( $_POST["follow_base_check_interval"] ) && $_POST["follow_base_check_interval"] ) {
173
- $tmp_follow_base_check_interval = sanitize_text_field( $_POST["follow_base_check_interval"] );
174
  if ( is_numeric( $tmp_follow_base_check_interval ) ) {
175
  if ( $tmp_follow_base_check_interval >= self::OPT_FOLLOW_BASE_CHECK_INTERVAL_MIN ) {
176
- $settings[self::DB_FOLLOW_CHECK_INTERVAL] = $tmp_follow_base_check_interval;
177
  } else {
178
- $settings[self::DB_FOLLOW_CHECK_INTERVAL] = self::OPT_FOLLOW_BASE_CHECK_INTERVAL_MIN;
179
  }
180
  }
181
  }
182
 
183
- if ( isset( $_POST["follow_base_cache_target_feedly"] ) && $_POST["follow_base_cache_target_feedly"] ) {
184
- $follow_base_cache_target[self::REF_FOLLOW_FEEDLY] = true;
 
 
 
 
 
 
185
  } else {
186
- $follow_base_cache_target[self::REF_FOLLOW_FEEDLY] = false;
187
  }
188
 
189
- if ( isset( $_POST["follow_base_cache_target_twitter"] ) && $_POST["follow_base_cache_target_twitter"] ) {
190
- $follow_base_cache_target[self::REF_FOLLOW_TWITTER] = true;
191
  } else {
192
- $follow_base_cache_target[self::REF_FOLLOW_TWITTER] = false;
193
  }
194
 
195
- if ( isset( $_POST["follow_base_cache_target_facebook"] ) && $_POST["follow_base_cache_target_facebook"] ) {
196
- $follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] = true;
197
  } else {
198
- $follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] = false;
199
  }
200
 
201
- if ( isset( $_POST["follow_base_cache_target_push7"] ) && $_POST["follow_base_cache_target_push7"] ) {
202
- $follow_base_cache_target[self::REF_FOLLOW_PUSH7] = true;
203
  } else {
204
- $follow_base_cache_target[self::REF_FOLLOW_PUSH7] = false;
205
  }
206
 
207
- if ( isset( $_POST["follow_base_cache_target_instagram"] ) && $_POST["follow_base_cache_target_instagram"] ) {
208
- $follow_base_cache_target[self::REF_FOLLOW_INSTAGRAM] = true;
209
  } else {
210
- $follow_base_cache_target[self::REF_FOLLOW_INSTAGRAM] = false;
211
  }
212
 
213
  if ( ! empty( $follow_base_cache_target ) ) {
214
- $settings[self::DB_FOLLOW_CACHE_TARGET] = $follow_base_cache_target;
215
  }
216
 
217
  $follow_twitter_preparation_flag = true;
218
 
219
- if ( isset( $_POST["share_facebook_app_id"] ) && $_POST["share_facebook_app_id"] ) {
220
- $settings[self::DB_SHARE_FACEBOOK_APP_ID] = SCC_Common_Util::encrypt_data( SCC_Common_Util::sanitize( $_POST["share_facebook_app_id"] ), AUTH_KEY );
221
  }
222
 
223
- if ( isset( $_POST["share_facebook_app_secret"] ) && $_POST["share_facebook_app_secret"] ) {
224
- $settings[self::DB_SHARE_FACEBOOK_APP_SECRET] = SCC_Common_Util::encrypt_data( SCC_Common_Util::sanitize( $_POST["share_facebook_app_secret"] ), AUTH_KEY );
225
  }
226
 
227
- if ( isset( $_POST["follow_twitter_screen_name"] ) && $_POST["follow_twitter_screen_name"] ) {
228
- $settings[self::DB_FOLLOW_TWITTER_SCREEN_NAME] = sanitize_text_field( $_POST["follow_twitter_screen_name"] );
229
  }
230
 
231
- if ( isset( $_POST["follow_twitter_consumer_key"] ) && $_POST["follow_twitter_consumer_key"] ) {
232
- $settings[self::DB_FOLLOW_TWITTER_CONSUMER_KEY] = SCC_Common_Util::encrypt_data( SCC_Common_Util::sanitize( $_POST["follow_twitter_consumer_key"] ), AUTH_KEY );
233
  } else {
234
  $follow_twitter_preparation_flag = false;
235
  }
236
 
237
- if ( isset( $_POST["follow_twitter_consumer_secret"] ) && $_POST["follow_twitter_consumer_secret"] ) {
238
- $settings[self::DB_FOLLOW_TWITTER_CONSUMER_SECRET] = SCC_Common_Util::encrypt_data( SCC_Common_Util::sanitize( $_POST["follow_twitter_consumer_secret"] ), AUTH_KEY );
239
  } else {
240
  $follow_twitter_preparation_flag = false;
241
  }
242
 
243
- if ( isset( $_POST["follow_twitter_bearer_token"] ) && $_POST["follow_twitter_bearer_token"] ) {
244
- $settings[self::DB_FOLLOW_TWITTER_BEARER_TOKEN] = SCC_Common_Util::encrypt_data( SCC_Common_Util::sanitize( $_POST["follow_twitter_bearer_token"] ), AUTH_KEY );
245
  }
246
 
247
  /*
248
- if ( isset( $_POST["follow_twitter_access_token"] ) && $_POST["follow_twitter_access_token"] ) {
249
- $settings[self::DB_FOLLOW_TWITTER_ACCESS_TOKEN] = SCC_Common_Util::encrypt_data( $_POST["follow_twitter_access_token"], AUTH_KEY );
250
  }
251
 
252
- if ( isset( $_POST["follow_twitter_access_token_secret"] ) && $_POST["follow_twitter_access_token_secret"] ) {
253
- $settings[self::DB_FOLLOW_TWITTER_ACCESS_TOKEN_SECRET] = SCC_Common_Util::encrypt_data( $_POST["follow_twitter_access_token_secret"], AUTH_KEY );
254
  }
255
  */
256
 
257
- if ( isset( $_POST["follow_facebook_page_id"] ) && $_POST["follow_facebook_page_id"] ) {
258
- $settings[self::DB_FOLLOW_FACEBOOK_PAGE_ID] = sanitize_text_field( $_POST["follow_facebook_page_id"] );
 
 
 
 
 
 
 
 
259
  }
260
 
261
- if ( isset( $_POST["follow_facebook_app_id"] ) && $_POST["follow_facebook_app_id"] ) {
262
- $settings[self::DB_FOLLOW_FACEBOOK_APP_ID] = SCC_Common_Util::encrypt_data( SCC_Common_Util::sanitize( $_POST["follow_facebook_app_id"] ), AUTH_KEY );
263
  }
264
 
265
- if ( isset( $_POST["follow_facebook_app_secret"] ) && $_POST["follow_facebook_app_secret"] ) {
266
- $settings[self::DB_FOLLOW_FACEBOOK_APP_SECRET] = SCC_Common_Util::encrypt_data( SCC_Common_Util::sanitize( $_POST["follow_facebook_app_secret"] ), AUTH_KEY );
267
  }
268
 
269
- if ( isset( $_POST["follow_facebook_access_token"] ) && $_POST["follow_facebook_access_token"] ) {
270
- $settings[self::DB_FOLLOW_FACEBOOK_ACCESS_TOKEN] = SCC_Common_Util::encrypt_data( SCC_Common_Util::sanitize( $_POST["follow_facebook_access_token"] ), AUTH_KEY );
271
  }
272
 
273
- if ( isset( $_POST["follow_push7_appno"] ) && $_POST["follow_push7_appno"] ) {
274
- $settings[self::DB_FOLLOW_PUSH7_APPNO] = SCC_Common_Util::encrypt_data( sanitize_text_field( $_POST["follow_push7_appno"] ), AUTH_KEY );
275
  }
276
 
277
- if ( isset( $_POST["follow_instagram_access_token"] ) && $_POST["follow_instagram_access_token"] ) {
278
- $settings[self::DB_FOLLOW_INSTAGRAM_ACCESS_TOKEN] = SCC_Common_Util::encrypt_data( SCC_Common_Util::sanitize( $_POST["follow_instagram_access_token"] ), AUTH_KEY );
279
  }
280
 
281
- if ( isset( $_POST["follow_instagram_client_id"] ) && $_POST["follow_instagram_client_id"] ) {
282
- $settings[self::DB_FOLLOW_INSTAGRAM_CLIENT_ID] = SCC_Common_Util::encrypt_data( SCC_Common_Util::sanitize( $_POST["follow_instagram_client_id"] ), AUTH_KEY );
283
  }
284
 
285
- if ( isset( $_POST["follow_instagram_client_secret"] ) && $_POST["follow_instagram_client_secret"] ) {
286
- $settings[self::DB_FOLLOW_INSTAGRAM_CLIENT_SECRET] = SCC_Common_Util::encrypt_data( SCC_Common_Util::sanitize( $_POST["follow_instagram_client_secret"] ), AUTH_KEY );
287
  }
288
 
289
- if ( isset( $_POST["follow_feed_type"] ) && $_POST["follow_feed_type"] ) {
290
- switch ( $_POST["follow_feed_type"] ) {
291
  case 'default':
292
- $settings[self::DB_FOLLOW_FEED_TYPE] = self::OPT_FEED_TYPE_DEFAULT;
293
  break;
294
  case 'rss2':
295
- $settings[self::DB_FOLLOW_FEED_TYPE] = self::OPT_FEED_TYPE_RSS2;
296
  break;
297
  case 'rss':
298
- $settings[self::DB_FOLLOW_FEED_TYPE] = self::OPT_FEED_TYPE_RSS;
299
  break;
300
  case 'rdf':
301
- $settings[self::DB_FOLLOW_FEED_TYPE] = self::OPT_FEED_TYPE_RDF;
302
  break;
303
  case 'atom':
304
- $settings[self::DB_FOLLOW_FEED_TYPE] = self::OPT_FEED_TYPE_ATOM;
305
  break;
306
  default:
307
- $settings[self::DB_FOLLOW_FEED_TYPE] = self::OPT_FEED_TYPE_DEFAULT;
308
  }
309
  } else {
310
- $settings[self::DB_FOLLOW_FEED_TYPE] = self::OPT_FEED_TYPE_DEFAULT;
311
  }
312
 
313
- if ( isset( $_POST["scheme_migration_mode"] ) && $_POST["scheme_migration_mode"] ) {
314
- $settings[self::DB_COMMON_SCHEME_MIGRATION_MODE] = self::OPT_COMMON_SCHEME_MIGRATION_MODE_ON;
315
  } else {
316
- $settings[self::DB_COMMON_SCHEME_MIGRATION_MODE] = self::OPT_COMMON_SCHEME_MIGRATION_MODE_OFF;
317
  }
318
 
319
- if ( isset( $_POST["scheme_migration_date"] ) && $_POST["scheme_migration_date"] ) {
320
- $tmp_scheme_migration_date = sanitize_text_field( $_POST["scheme_migration_date"] );
321
  if ( strptime( $tmp_scheme_migration_date, '%Y/%m/%d' ) ) {
322
- $settings[self::DB_COMMON_SCHEME_MIGRATION_DATE] = $tmp_scheme_migration_date;
323
  }
324
  }
325
 
326
- if ( isset( $_POST["crawler_ssl_verification"] ) && $_POST["crawler_ssl_verification"] ) {
327
- $settings[self::DB_COMMON_CRAWLER_SSL_VERIFICATION] = self::OPT_COMMON_CRAWLER_SSL_VERIFY_ON;
328
  } else {
329
- $settings[self::DB_COMMON_CRAWLER_SSL_VERIFICATION] = self::OPT_COMMON_CRAWLER_SSL_VERIFY_OFF;
330
  }
331
 
332
- if ( isset( $_POST['a_cronbtype'] ) && $_POST['a_cronbtype'] === 'mon' ) {
333
- $settings[self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE] = $_POST['a_moncronminutes'] . ' ' . $_POST['a_moncronhours'] . ' ' . $_POST['a_moncronmday'] . ' * *';
 
 
334
  }
335
 
336
- if ( isset( $_POST['a_cronbtype'] ) && $_POST['a_cronbtype'] === 'week' ) {
337
- $settings[self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE] = $_POST['a_weekcronminutes'] . ' ' . $_POST['a_weekcronhours'] . ' * * ' . $_POST['a_weekcronwday'];
 
 
338
  }
339
 
340
- if ( isset( $_POST['a_cronbtype'] ) && $_POST['a_cronbtype'] === 'day' ) {
341
- $settings[self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE] = $_POST['a_daycronminutes'] . ' ' . $_POST['a_daycronhours'] . ' * * *';
 
 
342
  }
343
 
344
- if ( isset( $_POST['a_cronbtype'] ) && $_POST['a_cronbtype'] === 'hour' ) {
345
- $settings[self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE] = $_POST['a_hourcronminutes'] . ' * * * *';
 
 
346
  }
347
 
348
- if ( isset( $_POST['b_cronbtype'] ) && $_POST['b_cronbtype'] === 'mon' ) {
349
- $settings[self::DB_FOLLOW_VARIATION_ANALYSIS_SCHEDULE] = $_POST['b_moncronminutes'] . ' ' . $_POST['b_moncronhours'] . ' ' . $_POST['b_moncronmday'] . ' * *';
 
 
350
  }
351
 
352
- if ( isset( $_POST['b_cronbtype'] ) && $_POST['b_cronbtype'] === 'week' ) {
353
- $settings[self::DB_FOLLOW_VARIATION_ANALYSIS_SCHEDULE] = $_POST['b_weekcronminutes'] . ' ' . $_POST['b_weekcronhours'] . ' * * ' . $_POST['b_weekcronwday'];
 
 
354
  }
355
 
356
- if ( isset( $_POST['b_cronbtype'] ) && $_POST['b_cronbtype'] === 'day' ) {
357
- $settings[self::DB_FOLLOW_VARIATION_ANALYSIS_SCHEDULE] = $_POST['b_daycronminutes'] . ' ' . $_POST['b_daycronhours'] . ' * * *';
 
 
358
  }
359
 
360
- if ( isset( $_POST['b_cronbtype'] ) && $_POST['b_cronbtype'] === 'hour' ) {
361
- $settings[self::DB_FOLLOW_VARIATION_ANALYSIS_SCHEDULE] = $_POST['b_hourcronminutes'] . ' * * * *';
 
 
362
  }
363
 
364
- if ( isset( $_POST['e_cronbtype'] ) && $_POST['e_cronbtype'] === 'mon' ) {
365
- $settings[self::DB_COMMON_DATA_EXPORT_SCHEDULE] = $_POST['e_moncronminutes'] . ' ' . $_POST['e_moncronhours'] . ' ' . $_POST['e_moncronmday'] . ' * *';
 
 
366
  }
367
 
368
- if ( isset( $_POST['e_cronbtype'] ) && $_POST['e_cronbtype'] === 'week' ) {
369
- $settings[self::DB_COMMON_DATA_EXPORT_SCHEDULE] = $_POST['e_weekcronminutes'] . ' ' . $_POST['e_weekcronhours'] . ' * * ' . $_POST['e_weekcronwday'];
 
 
370
  }
371
 
372
- if ( isset( $_POST['e_cronbtype'] ) && $_POST['e_cronbtype'] === 'day' ) {
373
- $settings[self::DB_COMMON_DATA_EXPORT_SCHEDULE] = $_POST['e_daycronminutes'] . ' ' . $_POST['e_daycronhours'] . ' * * *';
 
 
374
  }
375
 
376
- if ( isset( $_POST['e_cronbtype'] ) && $_POST['e_cronbtype'] === 'hour' ) {
377
- $settings[self::DB_COMMON_DATA_EXPORT_SCHEDULE] = $_POST['e_hourcronminutes'] . ' * * * *';
 
 
378
  }
379
 
380
  update_option( self::DB_SETTINGS, $settings );
@@ -382,2186 +422,2229 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
382
  $this->reactivate_plugin();
383
 
384
  set_transient( self::OPT_COMMON_ERROR_MESSAGE, $wp_error->get_error_messages(), 10 );
 
385
 
386
- //wp_safe_redirect( menu_page_url( 'scc-setting', false ) );
387
- }
388
-
389
- if ( isset( $_POST["reset_data"] ) && $_POST["reset_data"] === __( 'Reset', self::DOMAIN ) ) {
390
- SCC_Common_Util::log( '[' . __METHOD__ . '] reset' );
391
-
392
- $this->export_engines[self::REF_COMMON_EXPORT]->reset_export();
393
 
394
- //wp_safe_redirect( menu_page_url( 'scc-setting', false ) );
395
  }
396
 
397
- if ( isset( $_POST["export_data"] ) && $_POST["export_data"] === __( 'Export', self::DOMAIN ) ) {
398
- SCC_Common_Util::log( '[' . __METHOD__ . '] export' );
399
 
400
  set_time_limit( $this->extended_max_execution_time );
401
 
402
- $this->export_engines[self::REF_COMMON_EXPORT]->execute_export( NULL );
403
 
404
  set_time_limit( $this->original_max_execution_time );
405
-
406
- //wp_safe_redirect( menu_page_url('scc-setting', false ) );
407
  }
408
 
409
- if ( isset( $_POST["update_share_comparison_base"] ) && $_POST["update_share_comparison_base"] === __( 'Update Basis of Comparison', self::DOMAIN ) ) {
410
- SCC_Common_Util::log( '[' . __METHOD__ . '] base' );
411
 
412
  set_time_limit( $this->extended_max_execution_time );
413
 
414
- $this->analytical_engines[self::REF_SHARE_ANALYSIS]->execute_base( NULL );
415
 
416
  set_time_limit( $this->original_max_execution_time );
417
-
418
- //wp_safe_redirect( menu_page_url( 'scc-setting', false ) );
419
  }
420
 
421
- if ( isset( $_POST["update_follow_comparison_base"] ) && $_POST["update_follow_comparison_base"] === __( 'Update Basis of Comparison', self::DOMAIN ) ) {
422
- SCC_Common_Util::log( '[' . __METHOD__ . '] base' );
423
 
424
  set_time_limit( $this->extended_max_execution_time );
425
 
426
- $this->analytical_engines[self::REF_FOLLOW_ANALYSIS]->execute_base( NULL );
427
 
428
  set_time_limit( $this->original_max_execution_time );
429
-
430
- //wp_safe_redirect( menu_page_url( 'scc-setting', false ) );
431
  }
432
 
433
- if ( isset( $_POST["clear_share_base_cache"] ) && $_POST["clear_share_base_cache"] === __( 'Clear Cache', self::DOMAIN ) ) {
434
- SCC_Common_Util::log( '[' . __METHOD__ . '] clear cache' );
435
 
436
  set_time_limit( $this->extended_max_execution_time );
437
 
438
- $this->cache_engines[self::REF_SHARE_BASE]->clear_cache();
439
  //$this->cache_engines[self::REF_SHARE_2ND]->clear_cache();
440
- $this->cache_engines[self::REF_SHARE_2ND]->initialize_cache();
441
- $this->analytical_engines[self::REF_SHARE_ANALYSIS]->clear_base();
442
 
443
  set_time_limit( $this->original_max_execution_time );
444
-
445
- //wp_safe_redirect( menu_page_url('scc-setting', false ) );
446
  }
447
 
448
- if ( isset( $_POST["clear_follow_base_cache"] ) && $_POST["clear_follow_base_cache"] === __( 'Clear Cache', self::DOMAIN ) ) {
449
- SCC_Common_Util::log( '[' . __METHOD__ . '] clear cache' );
450
 
451
  set_time_limit( $this->extended_max_execution_time );
452
 
453
- $this->cache_engines[self::REF_FOLLOW_BASE]->clear_cache();
454
- //$this->cache_engines[self::REF_FOLLOW_2ND]->clear_cache();
455
- $this->cache_engines[self::REF_FOLLOW_2ND]->initialize_cache();
456
 
457
  set_time_limit( $this->original_max_execution_time );
458
-
459
- //wp_safe_redirect( menu_page_url('scc-setting', false ) );
460
  }
461
 
462
- if ( isset( $_POST["direct_follow_base_cache"] ) && $_POST["direct_follow_base_cache"] === __( 'Cache', self::DOMAIN ) ) {
463
- SCC_Common_Util::log( '[' . __METHOD__ . '] cache' );
464
 
465
  set_time_limit( $this->extended_max_execution_time );
466
 
467
- $this->cache_engines[self::REF_FOLLOW_BASE]->direct_cache( true );
468
 
469
  set_time_limit( $this->original_max_execution_time );
470
-
471
- //wp_safe_redirect( menu_page_url('scc-setting', false ) );
472
  }
473
 
474
- if ( isset( $_POST["get_tiwtter_bearer_token"] ) && $_POST["get_tiwtter_bearer_token"] === __( 'Get Bearer Token', self::DOMAIN ) ) {
475
- $tmp_twitter_bearer_token = SCC_Common_Util::get_twitter_bearer_token( $this->follow_twitter_consumer_key, $this->follow_twitter_consumer_secret );
476
  }
477
-
478
- } elseif( isset( $_GET['_wpnonce'] ) && $_GET['_wpnonce'] && isset( $_GET['action'] ) && $_GET['action'] && isset( $_GET['code'] ) && $_GET['code'] ) {
479
- if ( $_GET['action'] === 'instagram-auth' ) {
480
- if ( check_admin_referer( 'instagram-auth', '_wpnonce' ) ) {
481
- if ( current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
482
- $redirect_uri = plugins_url() . '/sns-count-cache/?action=instagram-auth';
483
- $tmp_instagram_access_token = SCC_Common_Util::get_instagram_access_token( $this->follow_instagram_client_id, $this->follow_instagram_client_secret, $redirect_uri, $_GET['code'] );
484
- }
485
- }
486
- } elseif ( $_GET['action'] === 'facebook-auth' ) {
487
- if ( check_admin_referer( 'facebook-auth', '_wpnonce' ) ) {
488
- if ( current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
489
- $redirect_uri = plugins_url() . '/sns-count-cache/?action=facebook-auth';
490
- $tmp_facebook_access_token = SCC_Common_Util::get_facebook_access_token( $this->follow_facebook_app_id, $this->follow_facebook_app_secret, $redirect_uri, $_GET['code'], $this->follow_facebook_page_id );
491
- }
 
 
 
 
492
  }
 
 
493
  }
494
- }
 
495
  ?>
496
- <div class="wrap">
497
- <h2><a href="admin.php?page=scc-setting"><?php _e( 'SNS Count Cache', self::DOMAIN ); ?></a></h2>
 
 
 
 
 
 
 
498
  <?php
499
- if ( $messages = get_transient( self::OPT_COMMON_ERROR_MESSAGE ) ) {
500
  ?>
501
- <div class="error">
502
- <ul>
503
- <?php
504
- foreach( $messages as $message ) {
505
- ?>
506
- <li><?php echo esc_html( $message ); ?></li>
507
- <?php
508
- }
509
- ?>
510
- </ul>
511
- </div>
512
  <?php
513
- delete_transient( self::OPT_COMMON_ERROR_MESSAGE );
514
- }
515
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
516
 
517
- <?php
518
- $status = SCC_WP_Cron_Util::test_cron_spawn();
519
 
520
- if ( is_wp_error( $status ) ) {
521
- echo '<div class="notice notice-error"><p>';
522
- _e( 'There was a problem spawning a call to the WP-Cron system on your site. This means WP-Cron jobs on your site may not work. The problem was: ', self::DOMAIN );
523
- echo '<br><strong>' . esc_html( $status->get_error_message() ) . '</strong>';
524
  echo '.</p></div>';
525
  }
 
526
 
527
- if ( isset( $this->share_base_cache_target[self::REF_SHARE_FACEBOOK] ) && $this->share_base_cache_target[self::REF_SHARE_FACEBOOK] ) {
528
- $configuration_check = $this->crawlers[self::REF_SHARE]->check_crawl_strategy_configurations( self::REF_SHARE_FACEBOOK );
529
 
530
- if ( ! $configuration_check ) {
531
- echo '<div class="notice notice-warning"><p>';
532
- _e( 'Configuratin is not enough to get share count. Please set required parameters at ', self::DOMAIN );
533
- echo '<a href="#share-base-cache-facebook">' . __( 'Share Base Cache - Facebook', self::DOMAIN ) . '</a>';
534
- echo '.</p></div>';
535
- }
536
  }
 
537
 
538
- if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_INSTAGRAM] ) && $this->follow_base_cache_target[self::REF_FOLLOW_INSTAGRAM] ) {
539
- $configuration_check = $this->crawlers[self::REF_FOLLOW]->check_crawl_strategy_configurations( self::REF_FOLLOW_INSTAGRAM);
540
 
541
- if ( ! $configuration_check ) {
542
- echo '<div class="notice notice-warning"><p>';
543
- _e( 'Configuratin is not enough to get follower count. Please set required parameters at ', self::DOMAIN );
544
- echo '<a href="#follow-base-cache-instagram">' . __( 'Follow Base Cache - Instagram', self::DOMAIN ) . '</a>';
545
- echo '.</p></div>';
546
- }
547
  }
 
548
 
549
- if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] ) && $this->follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] ) {
550
- $configuration_check = $this->crawlers[self::REF_FOLLOW]->check_crawl_strategy_configurations( self::REF_FOLLOW_FACEBOOK );
551
 
552
- if ( ! $configuration_check ) {
553
- echo '<div class="notice notice-warning"><p>';
554
- _e( 'Configuratin is not enough to get follower count. Please set required parameters at ', self::DOMAIN );
555
- echo '<a href="#follow-base-cache-facebook">' . __( 'Follow Base Cache - Facebook', self::DOMAIN ) . '</a>';
556
- echo '.</p></div>';
557
- }
558
  }
 
559
 
560
- if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_PUSH7] ) && $this->follow_base_cache_target[self::REF_FOLLOW_PUSH7] ) {
561
- $configuration_check = $this->crawlers[self::REF_FOLLOW]->check_crawl_strategy_configurations( self::REF_FOLLOW_PUSH7 );
562
 
563
- if ( ! $configuration_check ) {
564
- echo '<div class="notice notice-warning"><p>';
565
- _e( 'Configuratin is not enough to get follower count. Please set required parameters at ', self::DOMAIN );
566
- echo '<a href="#follow-base-cache-push7">' . __( 'Follow Base Cache - Push7', self::DOMAIN ) . '</a>';
567
- echo '.</p></div>';
568
- }
569
  }
 
570
 
571
- if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_TWITTER] ) && $this->follow_base_cache_target[self::REF_FOLLOW_TWITTER] ) {
572
- $configuration_check = $this->crawlers[self::REF_FOLLOW]->check_crawl_strategy_configurations( self::REF_FOLLOW_TWITTER );
573
 
574
- if ( ! $configuration_check ) {
575
- echo '<div class="notice notice-warning"><p>';
576
- _e( 'Configuratin is not enough to get follower count. Please set required parameters at ', self::DOMAIN );
577
- echo '<a href="#follow-base-cache-twitter">' . __( 'Follow Base Cache - Twitter', self::DOMAIN ) . '</a>';
578
- echo '.</p></div>';
579
- }
580
  }
 
581
 
582
- ?>
583
-
584
- <div class="sns-cnt-cache">
585
- <h3 class="nav-tab-wrapper">
586
- <a class="nav-tab" href="admin.php?page=scc-dashboard"><?php _e( 'Dashboard', self::DOMAIN ); ?></a>
587
- <a class="nav-tab" href="admin.php?page=scc-cache-status"><?php _e( 'Cache Status', self::DOMAIN ); ?></a>
588
- <a class="nav-tab" href="admin.php?page=scc-share-count"><?php _e( 'Share Count', self::DOMAIN ); ?></a>
589
- <?php if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) { ?>
590
- <a class="nav-tab" href="admin.php?page=scc-hot-content"><?php _e( 'Hot Content', self::DOMAIN ); ?></a>
591
- <?php } ?>
592
- <a class="nav-tab nav-tab-active" href="admin.php?page=scc-setting"><?php _e( 'Setting', self::DOMAIN ); ?></a>
593
- <a class="nav-tab" href="admin.php?page=scc-help"><?php _e( 'Help', self::DOMAIN ); ?></a>
594
- </h3>
595
- <p id="options-menu">
596
- <a href="#current-parameter"><?php _e( 'Current Setting', self::DOMAIN ); ?></a> | <a href="#share-base-cache"><?php _e( 'Share Base Cache', self::DOMAIN ); ?></a> | <a href="#share-rush-cache"><?php _e( 'Share Rush Cache', self::DOMAIN ); ?></a> | <a href="#share-variation-analysis"><?php _e( 'Share Variation Analysis', self::DOMAIN ); ?></a> | <a href="#follow-base-cache"><?php _e( 'Follow Base Cache', self::DOMAIN ); ?></a> | <a href="#follow-variation-analysis"><?php _e( 'Follow Variation Analysis', self::DOMAIN ); ?></a> | <a href="#common-dynamic-cache"><?php _e( 'Dynamic Cache', self::DOMAIN ); ?></a> | <a href="#common-fault-tolerance"><?php _e( 'Fault Tolerance', self::DOMAIN ); ?></a> | <a href="#common-data-crawler"><?php _e( 'Data Crawler', self::DOMAIN ); ?></a> | <a href="#common-data-export"><?php _e( 'Data Export', self::DOMAIN ); ?></a> | <a href="#common-exported-file"><?php _e( 'Exported File', self::DOMAIN ); ?></a>
597
- </p>
598
- <div class="metabox-holder">
599
- <div id="current-parameter" class="postbox">
600
- <div class="handlediv" title="Click to toggle"><br></div>
601
- <h3 class="hndle"><span><?php _e( 'Current Setting', self::DOMAIN ); ?></span></h3>
602
- <div class="inside">
603
- <table class="view-table">
604
- <thead>
605
- <tr>
606
- <th><?php _e( 'Capability', self::DOMAIN ); ?></th>
607
- <th><?php _e( 'Parameter', self::DOMAIN ); ?></th>
608
- <th><?php _e( 'Value', self::DOMAIN ); ?></th>
609
- </tr>
610
- </thead>
611
- <tbody>
612
- <tr>
613
- <td><?php _e( 'Share Base Cache', self::DOMAIN); ?></td>
614
- <td><?php _e( 'Target SNS', self::DOMAIN ); ?></td>
615
- <td>
616
- <?php
617
- $target_sns = array();
618
-
619
- if ( isset( $this->share_base_cache_target[self::REF_SHARE_FACEBOOK] ) && $this->share_base_cache_target[self::REF_SHARE_FACEBOOK] ) {
620
- $target_sns[] = __( 'Facebook', self::DOMAIN );
621
- }
622
- if ( isset( $this->share_base_cache_target[self::REF_SHARE_GPLUS] ) && $this->share_base_cache_target[self::REF_SHARE_GPLUS] ) {
623
- $target_sns[] = __( 'Google+', self::DOMAIN );
624
- }
625
- if ( isset( $this->share_base_cache_target[self::REF_SHARE_HATEBU] ) && $this->share_base_cache_target[self::REF_SHARE_HATEBU] ) {
626
- $target_sns[] = __( 'Hatena Bookmark', self::DOMAIN );
627
- }
628
- if ( isset( $this->share_base_cache_target[self::REF_SHARE_LINKEDIN] ) && $this->share_base_cache_target[self::REF_SHARE_LINKEDIN] ) {
629
- $target_sns[] = __( 'Linkedin', self::DOMAIN );
630
- }
631
- if ( isset( $this->share_base_cache_target[self::REF_SHARE_PINTEREST] ) && $this->share_base_cache_target[self::REF_SHARE_PINTEREST] ) {
632
- $target_sns[] = __( 'Pinterest', self::DOMAIN );
633
- }
634
- if ( isset( $this->share_base_cache_target[self::REF_SHARE_POCKET] ) && $this->share_base_cache_target[self::REF_SHARE_POCKET] ) {
635
- $target_sns[] = __( 'Pocket', self::DOMAIN );
636
- }
637
- if ( isset( $this->share_base_cache_target[self::REF_SHARE_TWITTER] ) && $this->share_base_cache_target[self::REF_SHARE_TWITTER] ) {
638
- $target_sns[] = __( 'Twitter', self::DOMAIN );
639
- }
640
- echo esc_html( implode( ", ", $target_sns ) );
641
- ?>
642
- </td>
643
- </tr>
644
- <tr>
645
- <td><?php _e( 'Share Base Cache', self::DOMAIN ); ?></td>
646
- <td><?php _e( 'Custom post types', self::DOMAIN ); ?></td>
647
- <td>
648
- <?php
649
- if ( ! empty( $this->share_base_custom_post_types ) && $this->share_base_custom_post_types ) {
650
- echo esc_html( implode( ',', $this->share_base_custom_post_types ) );
651
- } else {
652
- _e( 'N/A', self::DOMAIN );
653
- }
654
- ?>
655
- </td>
656
- </tr>
657
- <tr>
658
- <td><?php _e( 'Share Base Cache', self::DOMAIN ); ?></td>
659
- <td><?php _e( 'Interval cheking share count (sec)', self::DOMAIN ); ?></td>
660
- <td><?php echo esc_html( $this->share_base_check_interval ) . ' ' . __( 'seconds', self::DOMAIN ); ?></td>
661
- </tr>
662
- <tr>
663
- <td><?php _e( 'Share Base Cache', self::DOMAIN ); ?></td>
664
- <td><?php _e( 'Number of contents to check at a time', self::DOMAIN ) ?></td>
665
- <td><?php echo esc_html( $this->share_base_posts_per_check ) . ' ' . __( 'contents', self::DOMAIN ); ?></td>
666
- </tr>
667
- <tr>
668
- <td><?php _e( 'Share Base Cache', self::DOMAIN ); ?></td>
669
- <td><?php _e( 'Scheme migration mode from http to https', self::DOMAIN ); ?></td>
670
- <td>
671
- <?php
672
- if ( $this->scheme_migration_mode ) {
673
- _e( 'On', self::DOMAIN );
674
- } else {
675
- _e( 'Off', self::DOMAIN );
676
- }
677
- ?>
678
- </td>
679
- </tr>
680
- <?php if ( $this->scheme_migration_mode ) { ?>
681
- <tr>
682
- <td><?php _e( 'Share Base Cache', self::DOMAIN ); ?></td>
683
- <td><?php _e( 'Scheme migration date from http to https', self::DOMAIN ); ?></td>
684
- <td>
685
- <?php
686
- if ( isset( $this->scheme_migration_date ) ) {
687
- echo esc_html( $this->scheme_migration_date );
688
- } else {
689
- _e( 'N/A', self::DOMAIN );
690
- }
691
- ?>
692
- </td>
693
- </tr>
694
- <?php } ?>
695
 
696
- <?php if ( isset( $this->share_base_cache_target[self::REF_SHARE_TWITTER] ) && $this->share_base_cache_target[self::REF_SHARE_TWITTER] ) { ?>
697
- <tr>
698
- <td><?php _e( 'Share Base Cache - Twitter', self::DOMAIN ); ?></td>
699
- <td><?php _e( 'Alternative Twitter API', self::DOMAIN ); ?></td>
700
- <td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
701
  <?php
702
- if ( $this->share_base_twitter_api === self::OPT_SHARE_TWITTER_API_JSOON ) {
703
- echo '<a href="' . esc_url( 'https://jsoon.digitiminimi.com/' ) . '" target="_blank">' . esc_html( 'widgetoon.js & count.jsoon' ) . '</a>';
704
- } elseif ( $this->share_base_twitter_api === self::OPT_SHARE_TWITTER_API_OPENSHARECOUNT ) {
705
- echo '<a href="' . esc_url( 'https://opensharecount.com/' ) . '" target="_blank">' . esc_html( 'OpenShareCount' ) . '</a>';
706
- } elseif ( $this->share_base_twitter_api === self::OPT_SHARE_TWITTER_API_TWITCOUNT ) {
707
- echo '<a href="' . esc_url( 'http://twitcount.com/' ) . '" target="_blank">' . esc_html( 'TwitCount' ) . '</a>';
708
- } elseif( $this->share_base_twitter_api === self::OPT_SHARE_TWITTER_API_NEWSHARECOUNTS ) {
709
- echo '<a href="' . esc_url( 'http://newsharecounts.com/' ) . '" target="_blank">' . esc_html( 'NewShareCounts' ) . '</a>';
 
 
 
 
 
 
 
 
 
 
710
  }
 
711
  ?>
712
- </td>
713
- </tr>
714
- <?php } ?>
715
- <tr>
716
- <td><?php _e( 'Share Rush Cache', self::DOMAIN ); ?></td>
717
- <td><?php _e( 'Term considering posted content as new content', self::DOMAIN ); ?></td>
718
- <td>
719
- <?php
720
- if ( $this->share_rush_new_content_term == 1 ) {
721
- echo esc_html( $this->share_rush_new_content_term ) . ' ' . __( 'day', self::DOMAIN );
722
- } elseif ( $this->share_rush_new_content_term > 1 ) {
723
- echo esc_html( $this->share_rush_new_content_term ) . ' ' . __( 'days', self::DOMAIN );
724
- }
725
- ?>
726
- </td>
727
- </tr>
728
- <tr>
729
- <td><?php _e( 'Share Rush Cache', self::DOMAIN ); ?></td>
730
- <td><?php _e( 'Interval cheking share count (sec)', self::DOMAIN ); ?></td>
731
- <td>
732
- <?php
733
- echo esc_html( $this->share_rush_check_interval ) . ' ' . __( 'seconds', self::DOMAIN );
734
- ?>
735
- </td>
736
- <tr>
737
- <td><?php _e( 'Share Rush Cache', self::DOMAIN ); ?></td>
738
- <td><?php _e( 'Number of contents to check at a time', self::DOMAIN ) ?></td>
739
- <td><?php echo esc_html( $this->share_rush_posts_per_check ) . ' ' . __( 'contents', self::DOMAIN ); ?></td>
740
- </tr>
741
- </tr>
742
- <tr>
743
- <td><?php _e( 'Share Variation Analysis', self::DOMAIN ); ?></td>
744
- <td><?php _e( 'Method to update basis of comparison', self::DOMAIN ); ?></td><td>
745
- <?php
746
- switch ( $this->share_variation_analysis_mode ) {
747
- case self::OPT_SHARE_VARIATION_ANALYSIS_NONE:
748
- _e( 'Disabled (None)', self::DOMAIN );
749
- break;
750
- case self::OPT_SHARE_VARIATION_ANALYSIS_MANUAL:
751
- _e( 'Enabled (Manual)', self::DOMAIN );
752
- break;
753
- case self::OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER:
754
- _e( 'Enabled (Scheduler)', self::DOMAIN );
755
- break;
756
- default:
757
- _e( 'Disabled (None)', self::DOMAIN );
758
- }
759
- ?>
760
- </td>
761
- </tr>
762
- <?php
763
- if ( $this->share_variation_analysis_mode === self::OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER ) {
764
- ?>
765
- <tr>
766
- <td><?php _e( 'Share Variation Analysis', self::DOMAIN ); ?></td>
767
- <td><?php _e( 'Schedule', self::DOMAIN ); ?></td>
768
- <td><?php echo esc_html( $this->share_variation_analysis_schedule ); ?></td>
769
- </tr>
770
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
771
  }
772
- ?>
773
- <tr>
774
- <td><?php _e( 'Follow Base Cache', self::DOMAIN); ?></td>
775
- <td><?php _e( 'Target SNS', self::DOMAIN ); ?></td>
776
- <td>
777
- <?php
778
- $target_sns = array();
779
- if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] ) && $this->follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] ) {
780
- $target_sns[] = 'Facebook';
781
- }
782
- if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_FEEDLY] ) && $this->follow_base_cache_target[self::REF_FOLLOW_FEEDLY] ) {
783
- $target_sns[] = 'Feedly';
784
- }
785
- if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_INSTAGRAM] ) && $this->follow_base_cache_target[self::REF_FOLLOW_INSTAGRAM] ) {
786
- $target_sns[] = 'Instagram';
787
- }
788
- if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_PUSH7] ) && $this->follow_base_cache_target[self::REF_FOLLOW_PUSH7] ) {
789
- $target_sns[] = 'Push7';
790
- }
791
- if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_TWITTER] ) && $this->follow_base_cache_target[self::REF_FOLLOW_TWITTER] ) {
792
- $target_sns[] = 'Twitter';
793
- }
794
- echo esc_html( implode( ', ', $target_sns ) );
795
- ?>
796
- </td>
797
- </tr>
798
- <tr>
799
- <td><?php _e( 'Follow Base Cache', self::DOMAIN ); ?></td>
800
- <td><?php _e( 'Interval cheking follower count (sec)', self::DOMAIN ); ?></td>
801
- <td><?php echo esc_html( $this->follow_base_check_interval ) . ' ' . __( 'seconds', self::DOMAIN ); ?></td>
802
- </tr>
803
- <?php if ( $this->follow_base_cache_target[self::REF_FOLLOW_FEEDLY] ) { ?>
804
- <tr>
805
- <td><?php _e( 'Follow Base Cache - Feedly', self::DOMAIN ); ?></td>
806
- <td><?php _e( 'Target feed type', self::DOMAIN ); ?></td>
807
- <td>
808
- <?php
809
- switch ( $this->follow_feed_type ) {
810
- case self::OPT_FEED_TYPE_DEFAULT:
811
- _e( 'Default', self::DOMAIN );
812
- break;
813
- case self::OPT_FEED_TYPE_RSS:
814
- _e( 'RSS', self::DOMAIN );
815
- break;
816
- case self::OPT_FEED_TYPE_RSS2:
817
- _e( 'RSS2', self::DOMAIN );
818
- break;
819
- case self::OPT_FEED_TYPE_RDF:
820
- _e( 'RDF', self::DOMAIN );
821
- break;
822
- case self::OPT_FEED_TYPE_ATOM:
823
- _e( 'ATOM', self::DOMAIN );
824
- break;
825
- default:
826
- _e( 'Default', self::DOMAIN );
827
- }
828
- ?>
829
- </td>
830
- </tr>
831
- <tr>
832
- <td><?php _e( 'Follow Base Cache - Feedly', self::DOMAIN ); ?></td>
833
- <td><?php _e( 'Target feed', self::DOMAIN ); ?></td>
834
- <td><a href="<?php echo esc_url( get_feed_link( $this->follow_feed_type ) ); ?>" target="_blank"><?php echo esc_html( get_feed_link( $this->follow_feed_type ) ); ?></a></td>
835
- </tr>
836
- <?php } ?>
837
- <?php if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_TWITTER] ) && $this->follow_base_cache_target[self::REF_FOLLOW_TWITTER] ) { ?>
838
- <tr>
839
- <td><?php _e( 'Follow Base Cache - Twitter', self::DOMAIN ); ?></td>
840
- <td><?php _e( 'Target screen name', self::DOMAIN ); ?></td>
841
- <td>
842
- <?php
843
- if ( isset( $this->follow_twitter_screen_name ) && $this->follow_twitter_screen_name ) {
844
- echo '@' . esc_html( $this->follow_twitter_screen_name );
845
- } else {
846
- _e( 'N/A', self::DOMAIN );
847
- }
848
- ?>
849
- </td>
850
- </tr>
851
- <?php } ?>
852
- <?php if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] ) && $this->follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] ) { ?>
853
- <tr>
854
- <td><?php _e( 'Follow Base Cache - Facebook', self::DOMAIN ); ?></td>
855
- <td><?php _e( 'Page ID', self::DOMAIN ); ?></td>
856
- <td>
857
- <?php
858
- if ( isset( $this->follow_facebook_page_id ) ) {
859
- echo esc_html( $this->follow_facebook_page_id );
860
- } else {
861
- _e( 'N/A', self::DOMAIN );
862
- }
863
- ?>
864
- </td>
865
- </tr>
866
- <?php } ?>
867
- <tr>
868
- <td><?php _e( 'Follow Variation Analysis', self::DOMAIN ); ?></td>
869
- <td><?php _e( 'Method to update basis of comparison', self::DOMAIN ); ?></td><td>
870
- <?php
871
- switch ( $this->follow_variation_analysis_mode ) {
872
- case self::OPT_FOLLOW_VARIATION_ANALYSIS_NONE:
873
- _e( 'Disabled (None)', self::DOMAIN );
874
- break;
875
- case self::OPT_FOLLOW_VARIATION_ANALYSIS_MANUAL:
876
- _e( 'Enabled (Manual)', self::DOMAIN );
877
- break;
878
- case self::OPT_FOLLOW_VARIATION_ANALYSIS_SCHEDULER:
879
- _e( 'Enabled (Scheduler)', self::DOMAIN );
880
- break;
881
- default:
882
- _e( 'Disabled (None)', self::DOMAIN );
883
- }
884
- ?>
885
- </td>
886
- </tr>
887
- <?php
888
- if ( $this->follow_variation_analysis_mode === self::OPT_FOLLOW_VARIATION_ANALYSIS_SCHEDULER ) {
889
- ?>
890
- <tr>
891
- <td><?php _e( 'Follow Variation Analysis', self::DOMAIN ); ?></td>
892
- <td><?php _e( 'Schedule', self::DOMAIN ); ?></td>
893
- <td><?php echo esc_html( $this->follow_variation_analysis_schedule ); ?></td>
894
- </tr>
895
- <?php
896
  }
897
- ?>
898
- <tr>
899
- <td><?php _e( 'Dynamic Cache', self::DOMAIN); ?></td>
900
- <td><?php _e( 'Dynamic caching based on user access', self::DOMAIN ); ?></td><td>
901
- <?php
902
- switch ( $this->dynamic_cache_mode ) {
903
- case self::OPT_COMMON_ACCESS_BASED_CACHE_OFF:
904
- _e( 'Disabled', self::DOMAIN );
905
- break;
906
- case self::OPT_COMMON_ACCESS_BASED_CACHE_ON:
907
- _e( 'Enabled', self::DOMAIN );
908
- break;
909
- default:
910
- _e( 'Disabled', self::DOMAIN );
911
- }
912
- ?>
913
- </td>
914
- </tr>
915
- <tr>
916
- <td><?php _e( 'Fault Tolerance', self::DOMAIN); ?></td>
917
- <td><?php _e( 'Fault tolerance of count retrieval', self::DOMAIN ); ?></td><td>
918
- <?php
919
- switch ( $this->fault_tolerance_mode ) {
920
- case self::OPT_COMMON_FAULT_TOLERANCE_OFF:
921
- _e( 'Disabled', self::DOMAIN );
922
- break;
923
- case self::OPT_COMMON_FAULT_TOLERANCE_ON:
924
- _e( 'Enabled', self::DOMAIN );
925
- break;
926
- default:
927
- _e( 'Disabled', self::DOMAIN );
928
- }
929
- ?>
930
- </td>
931
- </tr>
932
- <tr>
933
- <td><?php _e( 'Data Crawler', self::DOMAIN ); ?></td>
934
- <td><?php _e( 'Crawl method', self::DOMAIN ); ?></td>
935
- <td>
936
- <?php
937
- switch ( $this->crawler_method ) {
938
- case self::OPT_COMMON_CRAWLER_METHOD_NORMAL:
939
- _e( 'Normal (Sequential Retrieval)', self::DOMAIN );
940
- break;
941
- case self::OPT_COMMON_CRAWLER_METHOD_CURL:
942
- _e( 'Extended (Parallel Retrieval)', self::DOMAIN );
943
- break;
944
- }
945
- ?>
946
- </td>
947
- </tr>
948
- <tr>
949
- <td><?php _e( 'Data Crawler', self::DOMAIN ); ?></td>
950
- <td><?php _e( 'Crawl retry limit', self::DOMAIN ); ?></td>
951
- <td>
952
- <?php
953
- switch ( $this->crawler_retry_limit ) {
954
- case -1:
955
- _e( 'no retry', self::DOMAIN );
956
- break;
957
- case 1:
958
- _e( '1 time', self::DOMAIN );
959
- break;
960
- case 2:
961
- _e( '2 times', self::DOMAIN );
962
- break;
963
- case 3:
964
- _e( '3 times', self::DOMAIN );
965
- break;
966
- case 4:
967
- _e( '2 times', self::DOMAIN );
968
- break;
969
- case 5:
970
- _e( '5 times', self::DOMAIN );
971
- break;
972
- }
973
- ?>
974
- </td>
975
- </tr>
976
- <tr>
977
- <td><?php _e( 'Data Crawler', self::DOMAIN ); ?></td>
978
- <td><?php _e( 'SSL verification', self::DOMAIN ); ?></td>
979
- <td>
980
- <?php
981
- if ( $this->crawler_ssl_verification ) {
982
- _e( 'On', self::DOMAIN );
983
- } else {
984
- _e( 'Off', self::DOMAIN );
985
- }
986
- ?>
987
- </td>
988
- </tr>
989
- <tr>
990
- <td><?php _e( 'Data Export', self::DOMAIN ); ?></td>
991
- <td><?php _e( 'Method of data export', self::DOMAIN ); ?></td><td>
992
- <?php
993
- switch ( $this->data_export_mode ) {
994
- case self::OPT_COMMON_DATA_EXPORT_MANUAL:
995
- _e( 'Manual', self::DOMAIN );
996
- break;
997
- case self::OPT_COMMON_DATA_EXPORT_SCHEDULER:
998
- _e( 'Scheduler', self::DOMAIN );
999
- break;
1000
- }
1001
- ?>
1002
- </td>
1003
- </tr>
1004
  <?php
1005
- if ( $this->data_export_mode === self::OPT_COMMON_DATA_EXPORT_SCHEDULER ) {
1006
  ?>
1007
- <tr>
1008
- <td><?php _e( 'Data Export', self::DOMAIN ); ?></td>
1009
- <td><?php _e( 'Interval exporting share count to a csv file', self::DOMAIN ); ?></td>
1010
- <td><?php echo esc_html( $this->data_export_interval / 3600 ) . ' ' . __( 'hours', self::DOMAIN ); ?></td>
1011
- </tr>
1012
  <?php
1013
- }
1014
  ?>
1015
- </tbody>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1016
  </table>
 
 
 
 
1017
  </div>
1018
  </div>
1019
- </div>
1020
- <div class="metabox-holder">
1021
- <form action="admin.php?page=scc-setting" method="post">
1022
- <?php wp_nonce_field( __FILE__, '_wpnonce' ); ?>
1023
- <div id="share-base-cache" class="postbox">
1024
- <div class="handlediv" title="Click to toggle"><br></div>
1025
- <h3 class="hndle"><span><?php _e('Share Base Cache', self::DOMAIN); ?></span></h3>
1026
- <div class="inside">
1027
- <table class="form-table">
1028
- <tr>
1029
- <th><label><?php _e( 'Target SNS', self::DOMAIN ); ?></label></th>
1030
- <td>
1031
- <div class="sns-check">
1032
- <input type="checkbox" value="1" id="share_base_cache_target_facebook" name="share_base_cache_target_facebook"<?php if ( isset( $this->share_base_cache_target[self::REF_SHARE_FACEBOOK] ) && $this->share_base_cache_target[self::REF_SHARE_FACEBOOK] ) echo ' checked="checked"'; ?> />
1033
- <label for="share_base_cache_target_facebook"><?php _e( 'Facebook', self::DOMAIN ); ?></label>
1034
- </div>
1035
- <div class="sns-check">
1036
- <input type="checkbox" value="1" id="share_base_cache_target_gplus" name="share_base_cache_target_gplus"<?php if ( isset( $this->share_base_cache_target[self::REF_SHARE_GPLUS] ) && $this->share_base_cache_target[self::REF_SHARE_GPLUS] ) echo ' checked="checked"'; ?> />
1037
- <label for="share_base_cache_target_gplus"><?php _e( 'Google+', self::DOMAIN ); ?></label>
1038
- </div>
1039
- <div class="sns-check">
1040
- <input type="checkbox" value="1" id="share_base_cache_target_hatebu" name="share_base_cache_target_hatebu"<?php if ( isset( $this->share_base_cache_target[self::REF_SHARE_HATEBU] ) && $this->share_base_cache_target[self::REF_SHARE_HATEBU] ) echo ' checked="checked"'; ?> />
1041
- <label for="share_base_cache_target_hatebu"><?php _e( 'Hatena Bookmark', self::DOMAIN ); ?></label>
1042
- </div>
1043
- <div class="sns-check">
1044
- <input type="checkbox" value="1" id="share_base_cache_target_linkedin" name="share_base_cache_target_linkedin"<?php if ( isset( $this->share_base_cache_target[self::REF_SHARE_LINKEDIN] ) && $this->share_base_cache_target[self::REF_SHARE_LINKEDIN] ) echo ' checked="checked"'; ?> />
1045
- <label for="share_base_cache_target_linkedin"><?php _e( 'Linkedin', self::DOMAIN ); ?></label>
1046
- </div>
1047
- <div class="sns-check">
1048
- <input type="checkbox" value="1" id="share_base_cache_target_pinterest" name="share_base_cache_target_pinterest"<?php if ( isset( $this->share_base_cache_target[self::REF_SHARE_PINTEREST] ) && $this->share_base_cache_target[self::REF_SHARE_PINTEREST] ) echo ' checked="checked"'; ?> />
1049
- <label for="share_base_cache_target_pinterest"><?php _e( 'Pinterest', self::DOMAIN ); ?></label>
1050
- </div>
1051
- <div class="sns-check">
1052
- <input type="checkbox" value="1" id="share_base_cache_target_pocket" name="share_base_cache_target_pocket"<?php if ( isset( $this->share_base_cache_target[self::REF_SHARE_POCKET] ) && $this->share_base_cache_target[self::REF_SHARE_POCKET] ) echo ' checked="checked"'; ?> />
1053
- <label for="share_base_cache_target_pocket"><?php _e( 'Pocket', self::DOMAIN ); ?></label>
1054
- </div>
1055
- <div class="sns-check">
1056
- <input type="checkbox" value="1" id="share_base_cache_target_twitter" name="share_base_cache_target_twitter"<?php if ( isset( $this->share_base_cache_target[self::REF_SHARE_TWITTER] ) && $this->share_base_cache_target[self::REF_SHARE_TWITTER] ) echo ' checked="checked"'; ?> />
1057
- <label for="share_base_cache_target_twitter"><?php _e( 'Twitter', self::DOMAIN ); ?></label>
1058
- </div>
1059
- </td>
1060
- </tr>
1061
- <tr>
1062
- <th><label for="share_base_custom_post_types"><?php _e( 'Custom post types', self::DOMAIN ); ?></label></th>
1063
- <td>
1064
- <input type="text" class="text" id="share_base_custom_post_types" name="share_base_custom_post_types" size="60" value="<?php echo esc_attr( implode( ',', $this->share_base_custom_post_types ) ); ?>" />
1065
  <br>
1066
- <span class="description"><?php _e( 'e.g. aaa, bbb, ccc (comma-delimited)', self::DOMAIN ); ?></span>
1067
- </td>
1068
- </tr>
1069
- <tr>
1070
- <th><label for="share_base_check_interval"><?php _e( 'Interval cheking share count (sec)', self::DOMAIN ); ?></label></th>
1071
- <td>
1072
- <input type="text" class="text" id="share_base_check_interval" name="share_base_check_interval" size="20" value="<?php echo esc_attr( $this->share_base_check_interval ); ?>" />
1073
- <span class="description"><?php _e( 'Default: 600', self::DOMAIN ); ?></span>
1074
- </td>
1075
- </tr>
1076
- <tr>
1077
- <th><label for="share_base_posts_per_check"><?php _e( 'Number of contents to check at a time', self::DOMAIN ); ?></label></th>
1078
- <td>
1079
- <input type="text" class="text" id="share_base_posts_per_check" name="share_base_posts_per_check" size="20" value="<?php echo esc_attr( $this->share_base_posts_per_check ); ?>" />
1080
- <span class="description"><?php _e( 'Default: 20', self::DOMAIN ); ?></span>
1081
- </td>
1082
- </tr>
1083
- <tr>
1084
- <th><label for="scheme_migration_mode"><?php _e( 'Scheme migration mode from http to https', self::DOMAIN ); ?></label></th>
1085
- <td>
1086
- <select id="scheme_migration_mode" name="scheme_migration_mode">
1087
- <option value="0"<?php if ( $this->scheme_migration_mode === self::OPT_COMMON_SCHEME_MIGRATION_MODE_OFF ) echo ' selected="selected"'; ?>><?php _e( 'Off', self::DOMAIN ); ?></option>
1088
- <option value="1"<?php if ( $this->scheme_migration_mode === self::OPT_COMMON_SCHEME_MIGRATION_MODE_ON ) echo ' selected="selected"'; ?>><?php _e( 'On', self::DOMAIN ); ?></option>
1089
- </select>
1090
- <span class="description"><?php _e('Default: Off', self::DOMAIN ); ?></span>
1091
- </td>
1092
- </tr>
1093
- <?php if ( $this->scheme_migration_mode ) { ?>
1094
- <tr>
1095
- <th><label for="scheme-migration-date"><?php _e( 'Scheme migration date from http to https', self::DOMAIN ); ?></label></th>
1096
- <td>
1097
- <input id="scheme-migration-date" type="text" class="text" name="scheme_migration_date" size="20" value="<?php echo esc_attr( $this->scheme_migration_date ); ?>" />
1098
- <span class="description"><?php _e( 'Default: N/A', self::DOMAIN ); ?></span>
1099
- <script>
1100
- jQuery(document).ready(function() {
1101
- jQuery('#scheme-migration-date').datepicker({
1102
- dateFormat : 'yy/mm/dd'
1103
- });
1104
- });
1105
- </script>
1106
  </td>
1107
  </tr>
1108
  <?php } ?>
1109
- </table>
1110
- <div class="submit-button">
1111
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1112
- <input type="submit" class="button button-secondary" name="clear_share_base_cache" value="<?php _e( 'Clear Cache', self::DOMAIN ); ?>">
1113
- </div>
1114
  </div>
1115
  </div>
1116
- <?php if ( isset( $this->share_base_cache_target[self::REF_SHARE_FACEBOOK] ) && $this->share_base_cache_target[self::REF_SHARE_FACEBOOK] ) { ?>
1117
- <div id="share-base-cache-facebook" class="postbox">
1118
- <div class="handlediv" title="Click to toggle"><br></div>
1119
- <h3 class="hndle"><span><?php _e( 'Share Base Cache - Facebook', self::DOMAIN ); ?></span></h3>
1120
- <div class="inside">
1121
- <table class="form-table">
1122
- <tr>
1123
- <th><label><?php _e( 'Developer page', self::DOMAIN ); ?></label></th>
1124
- <td>
1125
- <a href="https://developers.facebook.com/" target="_blank">https://developers.facebook.com/</a>
1126
- <br>
1127
- <span class="description"><?php _e( 'Register a application in Facebook developer page to get the following App ID and App Secret.', self::DOMAIN ); ?></span>
1128
- </td>
1129
- </tr>
1130
- <tr>
1131
- <th><label for="share_facebook_app_id"><?php _e( 'App ID (Client ID)', self::DOMAIN ); ?></label></th>
1132
- <td>
1133
- <input type="password" id="share_facebook_app_id" class="text" name="share_facebook_app_id" size="60" value="<?php echo esc_attr( $this->share_facebook_app_id ); ?>" />
1134
- <br>
1135
- <span class="description"><?php _e( 'App ID for Facebook API', self::DOMAIN ); ?></span>
1136
- </td>
1137
- </tr>
1138
- <tr>
1139
- <th><label for="share_facebook_app_secret"><?php _e( 'App Secret (Client Secret)', self::DOMAIN ); ?></label></th>
1140
- <td>
1141
- <input type="password" id="share_facebook_app_secret" class="text" name="share_facebook_app_secret" size="60" value="<?php echo esc_attr( $this->share_facebook_app_secret ); ?>" />
1142
- <br>
1143
- <span class="description"><?php _e( 'App Secret for Facebook API', self::DOMAIN ); ?></span>
1144
- </td>
1145
- </tr>
1146
- <?php if ( isset( $this->share_facebook_app_id ) && $this->share_facebook_app_id && isset( $this->share_facebook_app_secret ) && $this->share_facebook_app_secret ) { ?>
1147
- <tr>
1148
- <th><label for="tmp_share_facebook_access_token"><?php _e( 'Access Token', self::DOMAIN ); ?></label></th>
1149
- <td>
1150
- <input type="password" id="tmp_share_facebook_access_token" class="text" name="tmp_share_facebook_access_token" size="60" value="<?php echo esc_attr( $this->share_facebook_access_token ); ?>" readonly />
1151
- <br>
1152
- <span class="description"><?php _e( 'Access Token for Facebook API', self::DOMAIN ); ?></span>
1153
- </td>
1154
- </tr>
1155
- <?php } ?>
1156
- </table>
1157
- <div class="submit-button">
1158
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1159
- </div>
1160
- </div>
1161
- </div>
1162
- <?php } ?>
1163
- <?php if ( isset( $this->share_base_cache_target[self::REF_SHARE_TWITTER] ) && $this->share_base_cache_target[self::REF_SHARE_TWITTER] ) { ?>
1164
- <div id="share-base-cache-twitter" class="postbox">
1165
- <div class="handlediv" title="Click to toggle"><br></div>
1166
- <h3 class="hndle"><span><?php _e( 'Share Base Cache - Twitter', self::DOMAIN ); ?></span></h3>
1167
- <div class="inside">
1168
- <table class="form-table">
1169
- <tr>
1170
- <th><label for="share_alternative_twitter_api"><?php _e( 'Alternative Twitter API', self::DOMAIN ); ?></label></th>
1171
- <td>
1172
- <select id="share_alternative_twitter_api" name="share_alternative_twitter_api">
1173
- <option value="1"<?php if ( $this->share_base_twitter_api === self::OPT_SHARE_TWITTER_API_JSOON ) echo ' selected="selected"'; ?>><?php echo esc_html( 'widgetoon.js & count.jsoon' ); ?></option>
1174
- <option value="2"<?php if ( $this->share_base_twitter_api === self::OPT_SHARE_TWITTER_API_OPENSHARECOUNT ) echo ' selected="selected"'; ?>><?php echo esc_html( 'OpenShareCount' ); ?></option>
1175
- <option value="3"<?php if ( $this->share_base_twitter_api === self::OPT_SHARE_TWITTER_API_TWITCOUNT ) echo ' selected="selected"'; ?>><?php echo esc_html( 'TwitCount' ); ?></option>
1176
- <option value="4"<?php if ( $this->share_base_twitter_api === self::OPT_SHARE_TWITTER_API_NEWSHARECOUNTS ) echo ' selected="selected"'; ?>><?php echo esc_html( 'NewShareCounts' ); ?></option>
1177
- </select>
1178
- <span class="description"><?php _e( 'Default: ', self::DOMAIN ); echo esc_html( 'widgetoon.js & count.jsoon' ); ?></span>
1179
- </td>
1180
- </tr>
1181
- <tr>
1182
- <th><label><?php _e( 'Registration destination', self::DOMAIN ); ?></label></th>
1183
- <td>
1184
- <?php
1185
- if ( $this->share_base_twitter_api === self::OPT_SHARE_TWITTER_API_JSOON ) {
1186
- echo '<a href="' . esc_url( 'https://jsoon.digitiminimi.com/' ) . '" target="_blank">' . esc_html( 'https://jsoon.digitiminimi.com/' ) . '</a>';
1187
- } elseif ( $this->share_base_twitter_api === self::OPT_SHARE_TWITTER_API_OPENSHARECOUNT ) {
1188
- echo '<a href="' . esc_url( 'https://opensharecount.com/' ) . '" target="_blank">' . esc_html( 'https://opensharecount.com/' ) . '</a>';
1189
- } elseif ( $this->share_base_twitter_api === self::OPT_SHARE_TWITTER_API_TWITCOUNT ) {
1190
- echo '<a href="' . esc_url( 'http://twitcount.com/' ) . '" target="_blank">' . esc_html( 'http://twitcount.com/' ) . '</a>';
1191
- } elseif( $this->share_base_twitter_api === self::OPT_SHARE_TWITTER_API_NEWSHARECOUNTS ) {
1192
- echo '<a href="' . esc_url( 'http://newsharecounts.com/' ) . '" target="_blank">' . esc_html( 'http://newsharecounts.com/' ) . '</a>';
1193
- }
1194
- ?>
1195
- <br />
1196
- <span class="description"><?php _e( 'You need to register information such as your domain with the above site in order to start counting.', self::DOMAIN ); ?></span>
1197
- </td>
1198
- </tr>
1199
- </table>
1200
- <div class="submit-button">
1201
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1202
- </div>
1203
  </div>
1204
  </div>
1205
- <?php } ?>
1206
- <div id="share-rush-cache" class="postbox">
1207
- <div class="handlediv" title="Click to toggle"><br></div>
1208
- <h3 class="hndle"><span><?php _e( 'Share Rush Cache', self::DOMAIN); ?></span></h3>
1209
- <div class="inside">
1210
- <table class="form-table">
1211
- <tr>
1212
- <th><label for="share_rush_new_content_term"><?php _e( 'Term considering posted content as new content', self::DOMAIN ); ?></label></th>
1213
- <td>
1214
- <select id="share_rush_new_content_term" name="share_rush_new_content_term">
1215
- <option value="1"<?php if ( $this->share_rush_new_content_term === 1 ) echo ' selected="selected"'; ?>><?php _e( '1 day', self::DOMAIN ); ?></option>
1216
- <option value="2"<?php if ( $this->share_rush_new_content_term === 2 ) echo ' selected="selected"'; ?>><?php _e( '2 days', self::DOMAIN ); ?></option>
1217
- <option value="3"<?php if ( $this->share_rush_new_content_term === 3 ) echo ' selected="selected"'; ?>><?php _e( '3 days', self::DOMAIN ); ?></option>
1218
- <option value="4"<?php if ( $this->share_rush_new_content_term === 4 ) echo ' selected="selected"'; ?>><?php _e( '4 days', self::DOMAIN ); ?></option>
1219
- <option value="5"<?php if ( $this->share_rush_new_content_term === 5 ) echo ' selected="selected"'; ?>><?php _e( '5 days', self::DOMAIN ); ?></option>
1220
- <option value="6"<?php if ( $this->share_rush_new_content_term === 6 ) echo ' selected="selected"'; ?>><?php _e( '6 days', self::DOMAIN ); ?></option>
1221
- <option value="7"<?php if ( $this->share_rush_new_content_term === 7 ) echo ' selected="selected"'; ?>><?php _e( '7 days', self::DOMAIN ); ?></option>
1222
- <option value="8"<?php if ( $this->share_rush_new_content_term === 8 ) echo ' selected="selected"'; ?>><?php _e( '8 days', self::DOMAIN ); ?></option>
1223
- <option value="9"<?php if ( $this->share_rush_new_content_term === 9 ) echo ' selected="selected"'; ?>><?php _e( '9 days', self::DOMAIN ); ?></option>
1224
- <option value="10"<?php if ( $this->share_rush_new_content_term === 10 ) echo ' selected="selected"'; ?>><?php _e( '10 days', self::DOMAIN ); ?></option>
1225
- <option value="11"<?php if ( $this->share_rush_new_content_term === 11 ) echo ' selected="selected"'; ?>><?php _e( '11 days', self::DOMAIN ); ?></option>
1226
- <option value="12"<?php if ( $this->share_rush_new_content_term === 12 ) echo ' selected="selected"'; ?>><?php _e( '12 days', self::DOMAIN ); ?></option>
1227
- <option value="13"<?php if ( $this->share_rush_new_content_term === 13 ) echo ' selected="selected"'; ?>><?php _e( '13 days', self::DOMAIN ); ?></option>
1228
- <option value="14"<?php if ( $this->share_rush_new_content_term === 14 ) echo ' selected="selected"'; ?>><?php _e( '14 days', self::DOMAIN ); ?></option>
1229
- </select>
1230
- <span class="description"><?php _e( 'Default: 3 days', self::DOMAIN ); ?></span>
1231
- </td>
1232
- </tr>
1233
- <tr>
1234
- <th><label for="share_rush_check_interval"><?php _e( 'Interval cheking share count (sec)', self::DOMAIN ); ?></label></th>
1235
- <td>
1236
- <input type="text" id="share_rush_check_interval" class="text" name="share_rush_check_interval" size="20" value="<?php echo esc_attr( $this->share_rush_check_interval ); ?>" />
1237
- <span class="description"><?php _e( 'Default: 600', self::DOMAIN ); ?></span>
1238
- </td>
1239
- </tr>
1240
- <tr>
1241
- <th><label for="share_rush_posts_per_check"><?php _e( 'Number of contents to check at a time', self::DOMAIN ); ?></label></th>
1242
- <td>
1243
- <input type="text" id="share_rush_posts_per_check" class="text" name="share_rush_posts_per_check" size="20" value="<?php echo esc_attr( $this->share_rush_posts_per_check ); ?>" />
1244
- <span class="description"><?php _e( 'Default: 20', self::DOMAIN ); ?></span>
1245
- </td>
1246
- </tr>
1247
- </table>
1248
- <div class="submit-button">
1249
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1250
- </div>
1251
  </div>
1252
  </div>
1253
- <div id="share-variation-analysis" class="postbox">
1254
- <div class="handlediv" title="Click to toggle"><br></div>
1255
- <h3 class="hndle"><span><?php _e( 'Share Variation Analysis', self::DOMAIN ); ?></span></h3>
1256
- <div class="inside">
1257
- <table class="form-table">
1258
- <tr>
1259
- <th><label for="share_variation_analysis_mode"><?php _e( 'Method to update basis of comparison', self::DOMAIN ); ?></label></th>
1260
- <td>
1261
- <select id="share_variation_analysis_mode" name="share_variation_analysis_mode">
1262
- <option value="1"<?php if ( $this->share_variation_analysis_mode === self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) echo ' selected="selected"'; ?>><?php _e( 'Disabled (None)', self::DOMAIN ); ?></option>
1263
- <option value="2"<?php if ( $this->share_variation_analysis_mode === self::OPT_SHARE_VARIATION_ANALYSIS_MANUAL ) echo ' selected="selected"'; ?>><?php _e( 'Enabled (Manual)', self::DOMAIN ); ?></option>
1264
- <option value="3"<?php if ( $this->share_variation_analysis_mode === self::OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER ) echo ' selected="selected"'; ?>><?php _e( 'Enabled (Scheduler)', self::DOMAIN ); ?></option>
1265
- </select>
1266
- <span class="description"><?php _e( 'Disabled (None)', self::DOMAIN ); ?></span>
1267
- </td>
1268
- </tr>
1269
- <?php
1270
- if ( $this->share_variation_analysis_mode === self::OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER ) {
1271
- list( $cronstr['minutes'], $cronstr['hours'], $cronstr['mday'], $cronstr['mon'], $cronstr['wday'] ) = explode( ' ', $this->share_variation_analysis_schedule, 5 );
1272
- if ( strstr( $cronstr['minutes'], '*/' ) ) {
1273
- $minutes = explode( '/', $cronstr['minutes'] );
1274
- } else {
1275
- $minutes = explode( ',', $cronstr['minutes'] );
1276
- }
1277
- if ( strstr( $cronstr['hours'], '*/' ) ) {
1278
- $hours = explode( '/', $cronstr['hours'] );
1279
- } else {
1280
- $hours = explode( ',', $cronstr['hours'] );
1281
- }
1282
- if ( strstr( $cronstr['mday'], '*/' ) ) {
1283
- $mday = explode( '/', $cronstr['mday'] );
1284
- } else {
1285
- $mday = explode( ',', $cronstr['mday'] );
1286
- }
1287
- if ( strstr( $cronstr['mon'], '*/' ) ) {
1288
- $mon = explode( '/', $cronstr['mon'] );
1289
- } else {
1290
- $mon = explode( ',', $cronstr['mon'] );
1291
- }
1292
- if ( strstr( $cronstr['wday'], '*/' ) ) {
1293
- $wday = explode( '/', $cronstr['wday'] );
1294
- } else {
1295
- $wday = explode( ',', $cronstr['wday'] );
1296
- }
1297
- ?>
1298
- <tr class="a_wpcron">
1299
- <th scope="row"><?php _e( 'Scheduler', self::DOMAIN ); ?></th>
1300
- <td>
1301
- <table class="wpcron">
1302
- <tr>
1303
- <th>
1304
- <?php _e( 'Type', self::DOMAIN ); ?>
1305
- </th>
1306
- <th>
1307
- </th>
1308
- <th>
1309
- <?php _e( 'Hour', self::DOMAIN ); ?>
1310
- </th>
1311
- <th>
1312
- <?php _e( 'Minute', self::DOMAIN ); ?>
1313
- </th>
1314
- </tr>
1315
- <tr>
1316
- <td>
1317
- <label for="idcronbtype-mon">
1318
- <?php echo '<input class="radio" type="radio"' . checked( TRUE, is_numeric( $mday[0] ), FALSE ) . ' name="a_cronbtype" value="mon" /> ' . __( 'monthly', self::DOMAIN ); ?>
1319
- </label>
1320
- </td>
1321
- <td>
1322
- <select name="a_moncronmday">
1323
- <?php
1324
- for ( $i = 1; $i <= 31; $i ++ ) {
1325
- $on_day = '';
1326
-
1327
- switch ( $i ) {
1328
- case 1:
1329
- $on_day = __( 'on 1.', self::DOMAIN );
1330
- break;
1331
- case 2:
1332
- $on_day = __( 'on 2.', self::DOMAIN );
1333
- break;
1334
- case 3:
1335
- $on_day = __( 'on 3.', self::DOMAIN );
1336
- break;
1337
- case 4:
1338
- $on_day = __( 'on 4.', self::DOMAIN );
1339
- break;
1340
- case 5:
1341
- $on_day = __( 'on 5.', self::DOMAIN );
1342
- break;
1343
- case 6:
1344
- $on_day = __( 'on 6.', self::DOMAIN );
1345
- break;
1346
- case 7:
1347
- $on_day = __( 'on 7.', self::DOMAIN );
1348
- break;
1349
- case 8:
1350
- $on_day = __( 'on 8.', self::DOMAIN );
1351
- break;
1352
- case 9:
1353
- $on_day = __( 'on 9.', self::DOMAIN );
1354
- break;
1355
- case 10:
1356
- $on_day = __( 'on 10.', self::DOMAIN );
1357
- break;
1358
- case 11:
1359
- $on_day = __( 'on 11.', self::DOMAIN );
1360
- break;
1361
- case 12:
1362
- $on_day = __( 'on 12.', self::DOMAIN );
1363
- break;
1364
- case 13:
1365
- $on_day = __( 'on 13.', self::DOMAIN );
1366
- break;
1367
- case 14:
1368
- $on_day = __( 'on 14.', self::DOMAIN );
1369
- break;
1370
- case 15:
1371
- $on_day = __( 'on 15.', self::DOMAIN );
1372
- break;
1373
- case 16:
1374
- $on_day = __( 'on 16.', self::DOMAIN );
1375
- break;
1376
- case 17:
1377
- $on_day = __( 'on 17.', self::DOMAIN );
1378
- break;
1379
- case 18:
1380
- $on_day = __( 'on 18.', self::DOMAIN );
1381
- break;
1382
- case 19:
1383
- $on_day = __( 'on 19.', self::DOMAIN );
1384
- break;
1385
- case 20:
1386
- $on_day = __( 'on 20.', self::DOMAIN );
1387
- break;
1388
- case 21:
1389
- $on_day = __( 'on 21.', self::DOMAIN );
1390
- break;
1391
- case 22:
1392
- $on_day = __( 'on 22.', self::DOMAIN );
1393
- break;
1394
- case 23:
1395
- $on_day = __( 'on 23.', self::DOMAIN );
1396
- break;
1397
- case 24:
1398
- $on_day = __( 'on 24.', self::DOMAIN );
1399
- break;
1400
- case 25:
1401
- $on_day = __( 'on 25.', self::DOMAIN );
1402
- break;
1403
- case 26:
1404
- $on_day = __( 'on 26.', self::DOMAIN );
1405
- break;
1406
- case 27:
1407
- $on_day = __( 'on 27.', self::DOMAIN );
1408
- break;
1409
- case 28:
1410
- $on_day = __( 'on 28.', self::DOMAIN );
1411
- break;
1412
- case 29:
1413
- $on_day = __( 'on 29.', self::DOMAIN );
1414
- break;
1415
- case 30:
1416
- $on_day = __( 'on 30.', self::DOMAIN );
1417
- break;
1418
- case 31:
1419
- $on_day = __( 'on 31.', self::DOMAIN );
1420
- break;
1421
- }
1422
-
1423
- echo '<option ' . selected( in_array( "$i", $mday, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $on_day . '</option>';
1424
- }
1425
- ?>
1426
- </select>
1427
- </td>
1428
- <td>
1429
- <select name="a_moncronhours">
1430
- <?php for ( $i = 0; $i < 24; $i ++ ) {
1431
- echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1432
- } ?>
1433
- </select>
1434
- </td>
1435
- <td>
1436
- <select name="a_moncronminutes">
1437
- <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
1438
- echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1439
- } ?>
1440
- </select>
1441
- </td>
1442
- </tr>
1443
- <tr>
1444
- <td>
1445
- <label for="idcronbtype-week">
1446
- <?php echo '<input class="radio" type="radio"' . checked( TRUE, is_numeric( $wday[0] ), FALSE ) . ' name="a_cronbtype" value="week" /> ' . __( 'weekly', self::DOMAIN ); ?>
1447
- </label>
1448
- </td>
1449
- <td>
1450
- <select name="a_weekcronwday">
1451
- <?php
1452
- echo '<option ' . selected( in_array( '0', $wday, TRUE ), TRUE, FALSE ) . ' value="0" />' . __( 'Sunday', self::DOMAIN ) . '</option>';
1453
- echo '<option ' . selected( in_array( '1', $wday, TRUE ), TRUE, FALSE ) . ' value="1" />' . __( 'Monday', self::DOMAIN ) . '</option>';
1454
- echo '<option ' . selected( in_array( '2', $wday, TRUE ), TRUE, FALSE ) . ' value="2" />' . __( 'Tuesday', self::DOMAIN ) . '</option>';
1455
- echo '<option ' . selected( in_array( '3', $wday, TRUE ), TRUE, FALSE ) . ' value="3" />' . __( 'Wednesday', self::DOMAIN ) . '</option>';
1456
- echo '<option ' . selected( in_array( '4', $wday, TRUE ), TRUE, FALSE ) . ' value="4" />' . __( 'Thursday', self::DOMAIN ) . '</option>';
1457
- echo '<option ' . selected( in_array( '5', $wday, TRUE ), TRUE, FALSE ) . ' value="5" />' . __( 'Friday', self::DOMAIN ) . '</option>';
1458
- echo '<option ' . selected( in_array( '6', $wday, TRUE ), TRUE, FALSE ) . ' value="6" />' . __( 'Saturday', self::DOMAIN ) . '</option>';
1459
- ?>
1460
- </select>
1461
- </td>
1462
- <td>
1463
- <select name="a_weekcronhours">
1464
- <?php for ( $i = 0; $i < 24; $i ++ ) {
1465
- echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1466
- } ?>
1467
- </select>
1468
- </td>
1469
- <td>
1470
- <select name="a_weekcronminutes">
1471
- <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
1472
- echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1473
- } ?>
1474
- </select>
1475
- </td>
1476
- </tr>
1477
- <tr>
1478
- <td>
1479
- <label for="idcronbtype-day">
1480
- <?php echo '<input class="radio" type="radio"' . checked( "**", $mday[0] . $wday[0], FALSE ) . ' name="a_cronbtype" value="day" /> ' . __( 'daily', self::DOMAIN ); ?>
1481
- </label>
1482
- </td>
1483
- <td>
1484
- </td>
1485
- <td>
1486
- <select name="a_daycronhours">
1487
- <?php
1488
- for ( $i = 0; $i < 24; $i ++ ) {
1489
- echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1490
- }
1491
- ?>
1492
- </select>
1493
- </td>
1494
- <td>
1495
- <select name="a_daycronminutes">
1496
- <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
1497
- echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1498
- } ?>
1499
- </select>
1500
- </td>
1501
- </tr>
1502
- </table>
1503
- </td>
1504
- </tr>
1505
- <?php
1506
  }
1507
- ?>
1508
- </table>
1509
- <div class="submit-button">
1510
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1511
- <input type="submit" class="button button-secondary" name="update_share_comparison_base" value="<?php _e( 'Update Basis of Comparison', self::DOMAIN ); ?>" />
1512
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1513
  </div>
1514
  </div>
1515
- <div id="follow-base-cache" class="postbox">
1516
- <div class="handlediv" title="Click to toggle"><br></div>
1517
- <h3 class="hndle"><span><?php _e( 'Follow Base Cache', self::DOMAIN ); ?></span></h3>
1518
- <div class="inside">
1519
- <table class="form-table">
1520
- <tr>
1521
- <th><label><?php _e( 'Target SNS', self::DOMAIN ); ?></label></th>
1522
- <td>
1523
- <div class="sns-check">
1524
- <input type="checkbox" value="1" id="follow_base_cache_target_facebook" name="follow_base_cache_target_facebook"<?php if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] ) && $this->follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] ) echo ' checked="checked"'; ?> />
1525
- <label for="follow_base_cache_target_facebook"><?php _e( 'Facebook', self::DOMAIN ); ?></label>
1526
- </div>
1527
- <div class="sns-check">
1528
- <input type="checkbox" value="1" id="follow_base_cache_target_feedly" name="follow_base_cache_target_feedly"<?php if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_FEEDLY] ) && $this->follow_base_cache_target[self::REF_FOLLOW_FEEDLY] ) echo ' checked="checked"'; ?> />
1529
- <label for="follow_base_cache_target_feedly"><?php _e( 'Feedly', self::DOMAIN ); ?></label>
1530
- </div>
1531
- <div class="sns-check">
1532
- <input type="checkbox" value="1" id="follow_base_cache_target_instagram" name="follow_base_cache_target_instagram"<?php if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_INSTAGRAM] ) && $this->follow_base_cache_target[self::REF_FOLLOW_INSTAGRAM] ) echo ' checked="checked"'; ?> />
1533
- <label for="follow_base_cache_target_instagram"><?php _e( 'Instagram', self::DOMAIN ); ?></label>
1534
- </div>
1535
- <div class="sns-check">
1536
- <input type="checkbox" value="1" id="follow_base_cache_target_push7" name="follow_base_cache_target_push7"<?php if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_PUSH7] ) && $this->follow_base_cache_target[self::REF_FOLLOW_PUSH7] ) echo ' checked="checked"'; ?> />
1537
- <label for="follow_base_cache_target_push7"><?php _e( 'Push7', self::DOMAIN ); ?></label>
1538
- </div>
1539
- <div class="sns-check">
1540
- <input type="checkbox" value="1" id="follow_base_cache_target_twitter" name="follow_base_cache_target_twitter"<?php if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_TWITTER] ) && $this->follow_base_cache_target[self::REF_FOLLOW_TWITTER] ) echo ' checked="checked"'; ?> />
1541
- <label for="follow_base_cache_target_twitter"><?php _e( 'Twitter', self::DOMAIN ); ?></label>
1542
- </div>
1543
- </td>
1544
- </tr>
1545
- <tr>
1546
- <th><label for="follow_base_check_interval"><?php _e( 'Interval cheking follower count (sec)', self::DOMAIN ); ?></label></th>
1547
- <td>
1548
- <input type="text" class="text" id="follow_base_check_interval" name="follow_base_check_interval" size="20" value="<?php echo esc_attr( $this->follow_base_check_interval); ?>" />
1549
- <span class="description"><?php _e( 'Default: 86400 Minimum: 3600', self::DOMAIN ); ?></span>
1550
- </td>
1551
- </tr>
1552
- </table>
1553
- <div class="submit-button">
1554
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1555
- <input type="submit" class="button button-secondary" name="direct_follow_base_cache" value="<?php _e( 'Cache', self::DOMAIN ); ?>">
1556
- <input type="submit" class="button button-secondary" name="clear_follow_base_cache" value="<?php _e( 'Clear Cache', self::DOMAIN ); ?>">
1557
- </div>
 
 
 
 
1558
  </div>
1559
  </div>
1560
- <?php if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] ) && $this->follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] ) { ?>
1561
- <div id="follow-base-cache-facebook" class="postbox">
1562
- <div class="handlediv" title="Click to toggle"><br></div>
1563
- <h3 class="hndle"><span><?php _e( 'Follow Base Cache - Facebook', self::DOMAIN ); ?></span></h3>
1564
- <div class="inside">
1565
- <table class="form-table">
1566
- <tr>
1567
- <th><label for="follow_facebook_page_id"><?php _e( 'Page ID', self::DOMAIN ); ?></label></th>
1568
- <td>
1569
- <input type="text" class="text" id="follow_facebook_page_id" name="follow_facebook_page_id" size="30" value="<?php echo esc_attr( $this->follow_facebook_page_id ); ?>" />
1570
- <br>
1571
- <span class="description"><?php _e( 'Facebook page ID that you want to get follower count', self::DOMAIN ); ?></span>
1572
- </td>
1573
- </tr>
1574
- <tr>
1575
- <th><label><?php _e( 'Developer page', self::DOMAIN ); ?></label></th>
1576
- <td>
1577
- <a href="https://developers.facebook.com/" target="_blank">https://developers.facebook.com/</a>
1578
- <br>
1579
- <span class="description"><?php _e( 'Register a application in Facebook developer page to get the following App ID and App Secret.', self::DOMAIN ); ?></span>
1580
- </td>
1581
- </tr>
1582
- <tr>
1583
- <th><label for="follow_facebook_app_id"><?php _e( 'App ID (Client ID)', self::DOMAIN ); ?></label></th>
1584
- <td>
1585
- <input type="password" id="follow_facebook_app_id" class="text" name="follow_facebook_app_id" size="60" value="<?php echo esc_attr( $this->follow_facebook_app_id ); ?>" />
1586
- <br>
1587
- <span class="description"><?php _e( 'App ID for Facebook API', self::DOMAIN ); ?></span>
1588
- </td>
1589
- </tr>
1590
- <tr>
1591
- <th><label for="follow_facebook_app_secret"><?php _e( 'App Secret (Client Secret)', self::DOMAIN ); ?></label></th>
1592
- <td>
1593
- <input type="password" id="follow_facebook_app_secret" class="text" name="follow_facebook_app_secret" size="60" value="<?php echo esc_attr( $this->follow_facebook_app_secret ); ?>" />
1594
- <br>
1595
- <span class="description"><?php _e( 'App Secret for Facebook API', self::DOMAIN ); ?></span>
1596
- </td>
1597
- </tr>
1598
- <tr>
1599
- <th><label for="tmp_follow_facebook_redirect_uri"><?php _e( 'Redirect URI', self::DOMAIN ); ?></label></th>
1600
- <td>
1601
- <input type="text" id="tmp_follow_facebook_redirect_uri" class="text" name="tmp_follow_facebook_redirect_uri" size="60" value="<?php echo esc_url( plugins_url() . '/sns-count-cache/' ); ?>" onclick="this.focus();this.select()" title="<?php _e( 'To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac).', self::DOMAIN ); ?>" readonly />
1602
- <br>
1603
- <span class="description"><?php _e( 'Copy and set this to the field of "Valid OAuth redirect URIs" in application management page of Facebook developer page.', self::DOMAIN ); ?></span>
1604
- </td>
1605
- </tr>
1606
- <?php if ( isset( $_GET['action'] ) && $_GET['action'] && $_GET['action'] === 'facebook-auth' ) { ?>
1607
- <tr>
1608
- <th><label for="tmp_follow_facebook_access_token"><?php _e( 'Access Token', self::DOMAIN ); ?></label></th>
1609
- <td>
1610
- <?php if ( ! is_wp_error( $tmp_facebook_access_token ) ) { ?>
1611
- <input type="text" id="tmp_follow_facebook_access_token" class="text" name="tmp_follow_facebook_access_token" size="60" value="<?php echo esc_attr( $tmp_facebook_access_token ); ?>" onclick="this.focus();this.select()" title="<?php _e( 'To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac).', self::DOMAIN ); ?>" readonly />
1612
- <br>
1613
- <span class="description"><?php _e( 'Copy and pase this into the fields below.', self::DOMAIN ); ?></span>
1614
- <?php } else { ?>
1615
- <span class="update-message notice-error"><p><?php echo esc_html( $tmp_facebook_access_token->get_error_message() ); ?></p></span>
1616
- <?php } ?>
1617
- </td>
1618
- </tr>
1619
- <?php } ?>
1620
- <?php if ( isset( $this->follow_facebook_page_id ) && $this->follow_facebook_page_id && isset( $this->follow_facebook_app_id ) && $this->follow_facebook_app_id && isset( $this->follow_facebook_app_secret ) && $this->follow_facebook_app_secret ) { ?>
1621
- <tr>
1622
- <th><label for="follow_facebook_access_token"><?php _e( 'Access Token', self::DOMAIN ); ?></label></th>
1623
- <td>
1624
- <input type="password" id="follow_facebook_access_token" class="text" name="follow_facebook_access_token" size="60" value="<?php echo esc_attr( $this->follow_facebook_access_token ); ?>" />
1625
  <br>
1626
- <span class="description"><?php _e( 'Access Token for Facebook API', self::DOMAIN ); ?></span>
1627
- </td>
1628
- </tr>
1629
- <?php } ?>
1630
- </table>
1631
- <div class="submit-button">
1632
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1633
- <?php if ( isset( $this->follow_facebook_page_id ) && $this->follow_facebook_page_id && isset( $this->follow_facebook_app_id ) && $this->follow_facebook_app_id && isset( $this->follow_facebook_app_secret ) && $this->follow_facebook_app_secret ) { ?>
1634
- <a href="https://www.facebook.com/dialog/oauth?client_id=<?php echo esc_attr( $this->follow_facebook_app_id ); ?>&scope=manage_pages,read_insights&state=<?php echo wp_create_nonce( 'facebook-auth' ); ?>&redirect_uri=<?php echo plugins_url() . '/sns-count-cache/'; ?>?action=facebook-auth" class="button button-secondary"><?php _e( 'Get Access Token', self::DOMAIN ); ?></a>
1635
- <?php } ?>
1636
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
1637
  </div>
1638
  </div>
1639
- <?php } ?>
1640
- <?php if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_FEEDLY] ) && $this->follow_base_cache_target[self::REF_FOLLOW_FEEDLY] ) { ?>
1641
- <div id="follow-base-cache-feedly" class="postbox">
1642
- <div class="handlediv" title="Click to toggle"><br></div>
1643
- <h3 class="hndle"><span><?php _e( 'Follow Base Cache - Feedly', self::DOMAIN ); ?></span></h3>
1644
- <div class="inside">
1645
- <table class="form-table">
1646
- <tr>
1647
- <th><label for="follow_feed_type"><?php _e( 'Target feed type', self::DOMAIN ); ?></label></th>
1648
- <td>
1649
- <select id="follow_feed_type" name="follow_feed_type">
1650
- <option value="default"<?php if ( $this->follow_feed_type === self::OPT_FEED_TYPE_DEFAULT ) echo ' selected="selected"'; ?>><?php _e( 'Default', self::DOMAIN ) ?></option>
1651
- <option value="rss"<?php if ( $this->follow_feed_type === self::OPT_FEED_TYPE_RSS ) echo ' selected="selected"'; ?>><?php _e( 'RSS', self::DOMAIN ); ?></option>
1652
- <option value="rss2"<?php if ( $this->follow_feed_type === self::OPT_FEED_TYPE_RSS2 ) echo ' selected="selected"'; ?>><?php _e( 'RSS2', self::DOMAIN ); ?></option>
1653
- <option value="rdf"<?php if ( $this->follow_feed_type === self::OPT_FEED_TYPE_RDF ) echo ' selected="selected"'; ?>><?php _e( 'RDF', self::DOMAIN ); ?></option>
1654
- <option value="atom"<?php if ( $this->follow_feed_type === self::OPT_FEED_TYPE_ATOM ) echo ' selected="selected"'; ?>><?php _e( 'ATOM', self::DOMAIN ); ?></option>
1655
- </select>
1656
- <span class="description"><?php _e( 'Default: Default', self::DOMAIN ); ?></span>
1657
- </td>
1658
- </tr>
1659
- <tr>
1660
- <th><label><?php _e( 'Target feed', self::DOMAIN ); ?></label></th>
1661
- <td><a href="<?php echo esc_url( get_feed_link( $this->follow_feed_type ) ); ?>" target="_blank"><?php echo esc_html( get_feed_link( $this->follow_feed_type ) ); ?></a></td>
1662
- </tr>
1663
- </table>
1664
- <div class="submit-button">
1665
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1666
- </div>
1667
  </div>
1668
  </div>
1669
- <?php } ?>
1670
- <?php if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_INSTAGRAM] ) && $this->follow_base_cache_target[self::REF_FOLLOW_INSTAGRAM] ) { ?>
1671
- <div id="follow-base-cache-instagram" class="postbox">
1672
- <div class="handlediv" title="Click to toggle"><br></div>
1673
- <h3 class="hndle"><span><?php _e( 'Follow Base Cache - Instagram', self::DOMAIN ); ?></span></h3>
1674
- <div class="inside">
1675
- <table class="form-table">
1676
- <tr>
1677
- <th><label><?php _e( 'Developer page', self::DOMAIN ); ?></label></th>
1678
- <td>
1679
- <a href="https://www.instagram.com/developer/" target="_blank">https://www.instagram.com/developer/</a>
1680
- <br>
1681
- <span class="description"><?php _e( 'Register a client in Instagram developer page to get the following Client ID and Client Secret.', self::DOMAIN ); ?></span>
1682
- </td>
1683
- </tr>
1684
- <tr>
1685
- <th><label for="follow_instagram_client_id"><?php _e( 'Client ID', self::DOMAIN ); ?></label></th>
1686
- <td>
1687
- <input type="password" id="follow_instagram_client_id" class="text" name="follow_instagram_client_id" size="60" value="<?php echo esc_attr( $this->follow_instagram_client_id ); ?>" />
1688
- <br>
1689
- <span class="description"><?php _e( 'Client ID for Instagram API', self::DOMAIN ); ?></span>
1690
- </td>
1691
- </tr>
1692
- <tr>
1693
- <th><label for="follow_instagram_client_secret"><?php _e( 'Client Secret', self::DOMAIN ); ?></label></th>
1694
- <td>
1695
- <input type="password" id="follow_instagram_client_secret" class="text" name="follow_instagram_client_secret" size="60" value="<?php echo esc_attr( $this->follow_instagram_client_secret ); ?>" />
1696
- <br>
1697
- <span class="description"><?php _e( 'Client Secret for Instagram API', self::DOMAIN ); ?></span>
1698
- </td>
1699
- </tr>
1700
- <tr>
1701
- <th><label for="tmp_follow_instagram_redirect_uri"><?php _e( 'Redirect URI', self::DOMAIN ); ?></label></th>
1702
- <td>
1703
- <input type="text" id="tmp_follow_instagram_redirect_uri" class="text" name="tmp_follow_instagram_redirect_uri" size="60" value="<?php echo esc_url( plugins_url() . '/sns-count-cache/' ); ?>" onclick="this.focus();this.select()" title="<?php _e( 'To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac).', self::DOMAIN ); ?>" readonly />
1704
- <br>
1705
- <span class="description"><?php _e( 'Copy and set this to the field of "Valid redirect URIs" in the client management page of Instagram developer page.', self::DOMAIN ); ?></span>
1706
- </td>
1707
- </tr>
1708
- <?php if ( isset( $_GET['action'] ) && $_GET['action'] && $_GET['action'] === 'instagram-auth' ) { ?>
1709
- <tr>
1710
- <th><label for="tmp_follow_instagram_access_token"><?php _e( 'Access Token', self::DOMAIN ); ?></label></th>
1711
- <td>
1712
- <?php if ( ! is_wp_error( $tmp_instagram_access_token ) ) { ?>
1713
- <input type="text" id="tmp_follow_instagram_access_token" class="text" name="tmp_follow_instagram_access_token" size="60" value="<?php echo esc_attr( $tmp_instagram_access_token ); ?>" onclick="this.focus();this.select()" title="<?php _e( 'To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac).', self::DOMAIN ); ?>" readonly />
1714
- <br>
1715
- <span class="description"><?php _e( 'Copy and pase this into the fields below.', self::DOMAIN ); ?></span>
1716
- <?php } else { ?>
1717
- <span class="update-message notice-error"><p><?php echo esc_html( $tmp_instagram_access_token->get_error_message() ); ?></p></span>
1718
- <?php } ?>
1719
- </td>
1720
- </tr>
1721
- <?php } ?>
1722
- <?php if ( isset( $this->follow_instagram_client_id ) && $this->follow_instagram_client_id && isset( $this->follow_instagram_client_secret ) && $this->follow_instagram_client_secret ) { ?>
1723
- <tr>
1724
- <th><label for="follow_instagram_access_token"><?php _e( 'Access Token', self::DOMAIN ); ?></label></th>
1725
- <td>
1726
- <input type="password" id="follow_instagram_access_token" class="text" name="follow_instagram_access_token" size="60" value="<?php echo esc_attr( $this->follow_instagram_access_token ); ?>" />
1727
  <br>
1728
- <span class="description"><?php _e( 'Access Token for Instagram API', self::DOMAIN ); ?></span>
1729
- </td>
1730
- </tr>
1731
- <?php } ?>
1732
- </table>
1733
- <div class="submit-button">
1734
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1735
- <?php if ( isset( $this->follow_instagram_client_id ) && $this->follow_instagram_client_id && isset( $this->follow_instagram_client_secret ) && $this->follow_instagram_client_secret ) { ?>
1736
- <a href="https://api.instagram.com/oauth/authorize/?client_id=<?php echo esc_attr( $this->follow_instagram_client_id ); ?>&response_type=code&state=<?php echo wp_create_nonce( 'instagram-auth' ); ?>&redirect_uri=<?php echo plugins_url() . '/sns-count-cache/'; ?>?action=instagram-auth" class="button button-secondary"><?php _e( 'Get Access Token', self::DOMAIN ); ?></a>
1737
- <?php } ?>
1738
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
1739
  </div>
1740
  </div>
1741
- <?php } ?>
1742
- <?php if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_PUSH7] ) && $this->follow_base_cache_target[self::REF_FOLLOW_PUSH7] ) { ?>
1743
- <div id="follow-base-cache-push7" class="postbox">
1744
- <div class="handlediv" title="Click to toggle"><br></div>
1745
- <h3 class="hndle"><span><?php _e( 'Follow Base Cache - Push7', self::DOMAIN ); ?></span></h3>
1746
- <div class="inside">
1747
- <table class="form-table">
1748
- <tr>
1749
- <th><label><?php _e( 'Push7 page', self::DOMAIN ); ?></label></th>
1750
- <td>
1751
- <a href="https://push7.jp/" target="_blank">https://push7.jp/</a>
1752
- <br>
1753
- <span class="description"><?php _e( 'Register a application in Push7 page to get the following AppNo.', self::DOMAIN ); ?></span>
1754
- </td>
1755
- </tr>
1756
- <tr>
1757
- <th><label for="follow_push7_appno"><?php _e( 'AppNo', self::DOMAIN ); ?></label></th>
1758
- <td>
1759
- <input type="password" id="follow_push7_appno" class="text" name="follow_push7_appno" size="60" value="<?php echo esc_attr( $this->follow_push7_appno ); ?>" />
1760
- <br>
1761
- <span class="description"><?php _e( 'AppNo for Push7 API', self::DOMAIN ); ?></span>
1762
- </td>
1763
- </tr>
1764
- </table>
1765
- <div class="submit-button">
1766
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1767
- </div>
 
 
 
 
 
 
 
 
1768
  </div>
1769
  </div>
1770
- <?php } ?>
1771
- <?php if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_TWITTER] ) && $this->follow_base_cache_target[self::REF_FOLLOW_TWITTER] ) { ?>
1772
- <div id="follow-base-cache-twitter" class="postbox">
1773
- <div class="handlediv" title="Click to toggle"><br></div>
1774
- <h3 class="hndle"><span><?php _e( 'Follow Base Cache - Twitter', self::DOMAIN ); ?></span></h3>
1775
- <div class="inside">
1776
- <table class="form-table">
1777
- <tr>
1778
- <th><label for="follow_twitter_screen_name"><?php _e( 'Screen Name', self::DOMAIN ); ?></label></th>
1779
- <td>
1780
- <span class="at-mark">@</span>
1781
- <input type="text" id="follow_twitter_screen_name" class="text" name="follow_twitter_screen_name" size="30" value="<?php echo esc_attr( $this->follow_twitter_screen_name ); ?>" />
1782
- <br>
1783
- <span class="description"><?php _e( 'Twitter screen name that you want to get follower count', self::DOMAIN ); ?></span>
1784
- </td>
1785
- </tr>
1786
- <tr>
1787
- <th><label><?php _e( 'Developer page', self::DOMAIN ); ?></label></th>
1788
- <td>
1789
- <a href="https://dev.twitter.com/" target="_blank">https://dev.twitter.com/</a>
1790
- <br>
1791
- <span class="description"><?php _e( 'Register a application in Twitter developer page to get the following Consumer Key and Consumer Secret.', self::DOMAIN ); ?></span>
1792
- </td>
1793
- </tr>
1794
- <tr>
1795
- <th><label for="follow_twitter_consumer_key"><?php _e( 'Consumer Key (API Key)', self::DOMAIN ); ?></label></th>
1796
- <td>
1797
- <input type="password" id="follow_twitter_consumer_key" class="text" name="follow_twitter_consumer_key" size="60" value="<?php echo esc_attr( $this->follow_twitter_consumer_key ); ?>" />
1798
- <br>
1799
- <span class="description"><?php _e( 'Cconsumer Key for Twitter API', self::DOMAIN ); ?></span>
1800
- </td>
1801
- </tr>
1802
- <tr>
1803
- <th><label for="follow_twitter_consumer_secret"><?php _e( 'Consumer Secret (API Secret)', self::DOMAIN ); ?></label></th>
1804
- <td>
1805
- <input type="password" id="follow_twitter_consumer_secret" class="text" name="follow_twitter_consumer_secret" size="60" value="<?php echo esc_attr( $this->follow_twitter_consumer_secret ); ?>" />
1806
- <br>
1807
- <span class="description"><?php _e( 'Consumer Secret for Twitter API', self::DOMAIN ); ?></span>
1808
- </td>
1809
- </tr>
1810
- <?php if ( isset( $_POST["get_tiwtter_bearer_token"] ) && $_POST["get_tiwtter_bearer_token"] === __( 'Get Bearer Token', self::DOMAIN ) ) { ?>
1811
- <tr>
1812
- <th><label for="tmp_follow_twitter_bearer_token"><?php _e( 'Bearer Token', self::DOMAIN ); ?></label></th>
1813
- <td>
1814
- <?php if ( ! is_wp_error( $tmp_twitter_bearer_token ) ) { ?>
1815
- <input type="text" id="tmp_follow_twitter_bearer_token" class="text" name="tmp_follow_twitter_bearer_token" size="60" value="<?php echo esc_attr( $tmp_twitter_bearer_token ); ?>" onclick="this.focus();this.select()" title="<?php _e( 'To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac).', self::DOMAIN ); ?>" readonly />
1816
- <br>
1817
- <span class="description"><?php _e( 'Copy and pase this into the fields below.', self::DOMAIN ); ?></span>
1818
- <?php } else { ?>
1819
- <span class="update-message notice-error"><p><?php echo esc_html( $tmp_twitter_bearer_token->get_error_message() ); ?></p></span>
1820
- <?php } ?>
1821
- </td>
1822
- </tr>
1823
- <?php } ?>
1824
- <?php if ( isset( $this->follow_twitter_consumer_key ) && $this->follow_twitter_consumer_key && isset( $this->follow_twitter_consumer_secret ) && $this->follow_twitter_consumer_secret ) { ?>
1825
- <tr>
1826
- <th><label for="follow_twitter_bearer_token"><?php _e( 'Bearer Token', self::DOMAIN ); ?></label></th>
1827
- <td>
1828
- <input type="password" id="follow_twitter_bearer_token" class="text" name="follow_twitter_bearer_token" size="60" value="<?php echo esc_attr( $this->follow_twitter_bearer_token ); ?>" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1829
  <br>
1830
- <span class="description"><?php _e( 'Bearer Token for Twitter API', self::DOMAIN ); ?></span>
1831
- </td>
1832
- </tr>
1833
- <?php } ?>
1834
- </table>
1835
- <div class="submit-button">
1836
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1837
- <?php if ( isset( $this->follow_twitter_consumer_key ) && $this->follow_twitter_consumer_key && isset( $this->follow_twitter_consumer_secret ) && $this->follow_twitter_consumer_secret ) { ?>
1838
- <input type="submit" class="button button-secondary" name="get_tiwtter_bearer_token" value="<?php _e( 'Get Bearer Token', self::DOMAIN ); ?>" />
1839
- <?php } ?>
1840
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
1841
  </div>
1842
  </div>
1843
- <?php } ?>
1844
- <div id="follow-variation-analysis" class="postbox">
1845
- <div class="handlediv" title="Click to toggle"><br></div>
1846
- <h3 class="hndle"><span><?php _e( 'Follow Variation Analysis', self::DOMAIN ); ?></span></h3>
1847
- <div class="inside">
1848
- <table class="form-table">
1849
- <tr>
1850
- <th><label for="follow_variation_analysis_mode"><?php _e( 'Method to update basis of comparison', self::DOMAIN ); ?></label></th>
1851
- <td>
1852
- <select id="follow_variation_analysis_mode" name="follow_variation_analysis_mode">
1853
- <option value="1"<?php if ( $this->follow_variation_analysis_mode === self::OPT_FOLLOW_VARIATION_ANALYSIS_NONE ) echo ' selected="selected"'; ?>><?php _e( 'Disabled (None)', self::DOMAIN ); ?></option>
1854
- <option value="2"<?php if ( $this->follow_variation_analysis_mode === self::OPT_FOLLOW_VARIATION_ANALYSIS_MANUAL ) echo ' selected="selected"'; ?>><?php _e( 'Enabled (Manual)', self::DOMAIN ); ?></option>
1855
- <option value="3"<?php if ( $this->follow_variation_analysis_mode === self::OPT_FOLLOW_VARIATION_ANALYSIS_SCHEDULER ) echo ' selected="selected"'; ?>><?php _e( 'Enabled (Scheduler)', self::DOMAIN ); ?></option>
1856
- </select>
1857
- <span class="description"><?php _e( 'Disabled (None)', self::DOMAIN ); ?></span>
1858
- </td>
1859
- </tr>
1860
- <?php
1861
- if ( $this->follow_variation_analysis_mode === self::OPT_FOLLOW_VARIATION_ANALYSIS_SCHEDULER ) {
1862
- list( $cronstr['minutes'], $cronstr['hours'], $cronstr['mday'], $cronstr['mon'], $cronstr['wday'] ) = explode( ' ', $this->follow_variation_analysis_schedule, 5 );
1863
- if ( strstr( $cronstr['minutes'], '*/' ) ) {
1864
- $minutes = explode( '/', $cronstr['minutes'] );
1865
- } else {
1866
- $minutes = explode( ',', $cronstr['minutes'] );
1867
- }
1868
- if ( strstr( $cronstr['hours'], '*/' ) ) {
1869
- $hours = explode( '/', $cronstr['hours'] );
1870
- } else {
1871
- $hours = explode( ',', $cronstr['hours'] );
1872
- }
1873
- if ( strstr( $cronstr['mday'], '*/' ) ) {
1874
- $mday = explode( '/', $cronstr['mday'] );
1875
- } else {
1876
- $mday = explode( ',', $cronstr['mday'] );
1877
- }
1878
- if ( strstr( $cronstr['mon'], '*/' ) ) {
1879
- $mon = explode( '/', $cronstr['mon'] );
1880
- } else {
1881
- $mon = explode( ',', $cronstr['mon'] );
1882
- }
1883
- if ( strstr( $cronstr['wday'], '*/' ) ) {
1884
- $wday = explode( '/', $cronstr['wday'] );
1885
- } else {
1886
- $wday = explode( ',', $cronstr['wday'] );
1887
- }
1888
- ?>
1889
- <tr class="a_wpcron">
1890
- <th scope="row"><?php _e( 'Scheduler', self::DOMAIN ); ?></th>
1891
- <td>
1892
- <table class="wpcron">
1893
- <tr>
1894
- <th>
1895
- <?php _e( 'Type', self::DOMAIN ); ?>
1896
- </th>
1897
- <th>
1898
- </th>
1899
- <th>
1900
- <?php _e( 'Hour', self::DOMAIN ); ?>
1901
- </th>
1902
- <th>
1903
- <?php _e( 'Minute', self::DOMAIN ); ?>
1904
- </th>
1905
- </tr>
1906
- <tr>
1907
- <td>
1908
- <label for="idcronbtype-mon">
1909
- <?php echo '<input class="radio" type="radio"' . checked( TRUE, is_numeric( $mday[0] ), FALSE ) . ' name="b_cronbtype" value="mon" /> ' . __( 'monthly', self::DOMAIN ); ?>
1910
- </label>
1911
- </td>
1912
- <td>
1913
- <select name="b_moncronmday">
1914
- <?php
1915
- for ( $i = 1; $i <= 31; $i ++ ) {
1916
- $on_day = '';
1917
-
1918
- switch ( $i ) {
1919
- case 1:
1920
- $on_day = __( 'on 1.', self::DOMAIN );
1921
- break;
1922
- case 2:
1923
- $on_day = __( 'on 2.', self::DOMAIN );
1924
- break;
1925
- case 3:
1926
- $on_day = __( 'on 3.', self::DOMAIN );
1927
- break;
1928
- case 4:
1929
- $on_day = __( 'on 4.', self::DOMAIN );
1930
- break;
1931
- case 5:
1932
- $on_day = __( 'on 5.', self::DOMAIN );
1933
- break;
1934
- case 6:
1935
- $on_day = __( 'on 6.', self::DOMAIN );
1936
- break;
1937
- case 7:
1938
- $on_day = __( 'on 7.', self::DOMAIN );
1939
- break;
1940
- case 8:
1941
- $on_day = __( 'on 8.', self::DOMAIN );
1942
- break;
1943
- case 9:
1944
- $on_day = __( 'on 9.', self::DOMAIN );
1945
- break;
1946
- case 10:
1947
- $on_day = __( 'on 10.', self::DOMAIN );
1948
- break;
1949
- case 11:
1950
- $on_day = __( 'on 11.', self::DOMAIN );
1951
- break;
1952
- case 12:
1953
- $on_day = __( 'on 12.', self::DOMAIN );
1954
- break;
1955
- case 13:
1956
- $on_day = __( 'on 13.', self::DOMAIN );
1957
- break;
1958
- case 14:
1959
- $on_day = __( 'on 14.', self::DOMAIN );
1960
- break;
1961
- case 15:
1962
- $on_day = __( 'on 15.', self::DOMAIN );
1963
- break;
1964
- case 16:
1965
- $on_day = __( 'on 16.', self::DOMAIN );
1966
- break;
1967
- case 17:
1968
- $on_day = __( 'on 17.', self::DOMAIN );
1969
- break;
1970
- case 18:
1971
- $on_day = __( 'on 18.', self::DOMAIN );
1972
- break;
1973
- case 19:
1974
- $on_day = __( 'on 19.', self::DOMAIN );
1975
- break;
1976
- case 20:
1977
- $on_day = __( 'on 20.', self::DOMAIN );
1978
- break;
1979
- case 21:
1980
- $on_day = __( 'on 21.', self::DOMAIN );
1981
- break;
1982
- case 22:
1983
- $on_day = __( 'on 22.', self::DOMAIN );
1984
- break;
1985
- case 23:
1986
- $on_day = __( 'on 23.', self::DOMAIN );
1987
- break;
1988
- case 24:
1989
- $on_day = __( 'on 24.', self::DOMAIN );
1990
- break;
1991
- case 25:
1992
- $on_day = __( 'on 25.', self::DOMAIN );
1993
- break;
1994
- case 26:
1995
- $on_day = __( 'on 26.', self::DOMAIN );
1996
- break;
1997
- case 27:
1998
- $on_day = __( 'on 27.', self::DOMAIN );
1999
- break;
2000
- case 28:
2001
- $on_day = __( 'on 28.', self::DOMAIN );
2002
- break;
2003
- case 29:
2004
- $on_day = __( 'on 29.', self::DOMAIN );
2005
- break;
2006
- case 30:
2007
- $on_day = __( 'on 30.', self::DOMAIN );
2008
- break;
2009
- case 31:
2010
- $on_day = __( 'on 31.', self::DOMAIN );
2011
- break;
2012
- }
2013
-
2014
- echo '<option ' . selected( in_array( "$i", $mday, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $on_day . '</option>';
2015
- }
2016
- ?>
2017
- </select>
2018
- </td>
2019
- <td>
2020
- <select name="b_moncronhours">
2021
- <?php for ( $i = 0; $i < 24; $i ++ ) {
2022
- echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
2023
- } ?>
2024
- </select>
2025
- </td>
2026
- <td>
2027
- <select name="b_moncronminutes">
2028
- <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
2029
- echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
2030
- } ?>
2031
- </select>
2032
- </td>
2033
- </tr>
2034
- <tr>
2035
- <td>
2036
- <label for="idcronbtype-week">
2037
- <?php echo '<input class="radio" type="radio"' . checked( TRUE, is_numeric( $wday[0] ), FALSE ) . ' name="a_cronbtype" value="week" /> ' . __( 'weekly', self::DOMAIN ); ?>
2038
- </label>
2039
- </td>
2040
- <td>
2041
- <select name="b_weekcronwday">
2042
- <?php
2043
- echo '<option ' . selected( in_array( '0', $wday, TRUE ), TRUE, FALSE ) . ' value="0" />' . __( 'Sunday', self::DOMAIN ) . '</option>';
2044
- echo '<option ' . selected( in_array( '1', $wday, TRUE ), TRUE, FALSE ) . ' value="1" />' . __( 'Monday', self::DOMAIN ) . '</option>';
2045
- echo '<option ' . selected( in_array( '2', $wday, TRUE ), TRUE, FALSE ) . ' value="2" />' . __( 'Tuesday', self::DOMAIN ) . '</option>';
2046
- echo '<option ' . selected( in_array( '3', $wday, TRUE ), TRUE, FALSE ) . ' value="3" />' . __( 'Wednesday', self::DOMAIN ) . '</option>';
2047
- echo '<option ' . selected( in_array( '4', $wday, TRUE ), TRUE, FALSE ) . ' value="4" />' . __( 'Thursday', self::DOMAIN ) . '</option>';
2048
- echo '<option ' . selected( in_array( '5', $wday, TRUE ), TRUE, FALSE ) . ' value="5" />' . __( 'Friday', self::DOMAIN ) . '</option>';
2049
- echo '<option ' . selected( in_array( '6', $wday, TRUE ), TRUE, FALSE ) . ' value="6" />' . __( 'Saturday', self::DOMAIN ) . '</option>';
2050
- ?>
2051
- </select>
2052
- </td>
2053
- <td>
2054
- <select name="b_weekcronhours">
2055
- <?php for ( $i = 0; $i < 24; $i ++ ) {
2056
- echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
2057
- } ?>
2058
- </select>
2059
- </td>
2060
- <td>
2061
- <select name="b_weekcronminutes">
2062
- <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
2063
- echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
2064
- } ?>
2065
- </select>
2066
- </td>
2067
- </tr>
2068
- <tr>
2069
- <td>
2070
- <label for="idcronbtype-day">
2071
- <?php echo '<input class="radio" type="radio"' . checked( "**", $mday[0] . $wday[0], FALSE ) . ' name="b_cronbtype" value="day" /> ' . __( 'daily', self::DOMAIN ); ?>
2072
- </label>
2073
- </td>
2074
- <td>
2075
- </td>
2076
- <td>
2077
- <select name="b_daycronhours">
2078
- <?php
2079
- for ( $i = 0; $i < 24; $i ++ ) {
2080
- echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
2081
- }
2082
- ?>
2083
- </select>
2084
- </td>
2085
- <td>
2086
- <select name="b_daycronminutes">
2087
- <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
2088
- echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
2089
- } ?>
2090
- </select>
2091
- </td>
2092
- </tr>
2093
- </table>
2094
- </td>
2095
- </tr>
2096
- <?php
2097
  }
2098
- ?>
2099
- </table>
2100
- <div class="submit-button">
2101
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
2102
- <input type="submit" class="button button-secondary" name="update_follow_comparison_base" value="<?php _e( 'Update Basis of Comparison', self::DOMAIN ); ?>" />
2103
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2104
  </div>
2105
  </div>
2106
- <div id="common-dynamic-cache" class="postbox">
2107
- <div class="handlediv" title="Click to toggle"><br></div>
2108
- <h3 class="hndle"><span><?php _e( 'Dynamic Cache', self::DOMAIN ); ?></span></h3>
2109
- <div class="inside">
2110
- <table class="form-table">
2111
- <tr>
2112
- <th><label for="dynamic_cache_mode"><?php _e( 'Dynamic caching based on user access', self::DOMAIN ); ?></label></th>
2113
- <td>
2114
- <select id="dynamic_cache_mode" name="dynamic_cache_mode">
2115
- <option value="1"<?php if ( $this->dynamic_cache_mode === self::OPT_COMMON_ACCESS_BASED_CACHE_OFF ) echo ' selected="selected"'; ?>><?php _e( 'Disabled', self::DOMAIN ); ?></option>
2116
- <option value="5"<?php if ( $this->dynamic_cache_mode === self::OPT_COMMON_ACCESS_BASED_CACHE_ON ) echo ' selected="selected"'; ?>><?php _e( 'Enabled', self::DOMAIN ); ?></option>
2117
- </select>
2118
- <span class="description"><?php _e( 'Default: Disabled', self::DOMAIN ); ?></span>
2119
- </td>
2120
- </tr>
2121
- </table>
2122
- <div class="submit-button">
2123
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
2124
- </div>
2125
  </div>
2126
  </div>
2127
- <div id="common-fault-tolerance" class="postbox">
2128
- <div class="handlediv" title="Click to toggle"><br></div>
2129
- <h3 class="hndle"><span><?php _e( 'Fault Tolerance', self::DOMAIN ); ?></span></h3>
2130
- <div class="inside">
2131
- <table class="form-table">
2132
- <tr>
2133
- <th><label for="fault_tolerance_mode"><?php _e( 'Fault tolerant mode of count retrieval', self::DOMAIN ); ?></label></th>
2134
- <td>
2135
- <select id="fault_tolerance_mode" name="fault_tolerance_mode">
2136
- <option value="1"<?php if ( $this->fault_tolerance_mode === self::OPT_COMMON_FAULT_TOLERANCE_OFF ) echo ' selected="selected"'; ?>><?php _e( 'Disabled', self::DOMAIN ); ?></option>
2137
- <option value="2"<?php if ( $this->fault_tolerance_mode === self::OPT_COMMON_FAULT_TOLERANCE_ON ) echo ' selected="selected"'; ?>><?php _e( 'Enabled', self::DOMAIN ); ?></option>
2138
- </select>
2139
- <span class="description"><?php _e( 'Default: Disabled', self::DOMAIN ); ?></span>
2140
- </td>
2141
- </tr>
2142
- </table>
2143
- <div class="submit-button">
2144
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
2145
- </div>
2146
  </div>
2147
  </div>
2148
- <div id="common-data-crawler" class="postbox">
2149
- <div class="handlediv" title="Click to toggle"><br></div>
2150
- <h3 class="hndle"><span><?php _e( 'Data Crawler', self::DOMAIN ); ?></span></h3>
2151
- <div class="inside">
2152
- <table class="form-table">
2153
- <tr>
2154
- <th><label><?php _e( 'Crawl method', self::DOMAIN ); ?></label></th>
2155
- <td>
2156
- <?php
2157
- switch ( $this->crawler_method ) {
2158
- case self::OPT_COMMON_CRAWLER_METHOD_NORMAL:
2159
- _e( 'Normal (Sequential Retrieval)', self::DOMAIN );
2160
- break;
2161
- case self::OPT_COMMON_CRAWLER_METHOD_CURL:
2162
- _e( 'Extended (Parallel Retrieval)', self::DOMAIN );
2163
- break;
2164
- }
2165
- ?>
2166
- </td>
2167
- </tr>
2168
- <tr>
2169
- <th><label for="common_data_crawler_retry_limit"><?php _e( 'Crawl retry limit', self::DOMAIN ); ?></label></th>
2170
- <td>
2171
- <select id="common_data_crawler_retry_limit" name="common_data_crawler_retry_limit">
2172
- <option value="-1"<?php if ( $this->crawler_retry_limit === -1 ) echo ' selected="selected"'; ?>><?php _e( 'no retry', self::DOMAIN ); ?></option>
2173
- <option value="1"<?php if ( $this->crawler_retry_limit === 1 ) echo ' selected="selected"'; ?>><?php _e( '1 time', self::DOMAIN ); ?></option>
2174
- <option value="2"<?php if ( $this->crawler_retry_limit === 2 ) echo ' selected="selected"'; ?>><?php _e( '2 times', self::DOMAIN ); ?></option>
2175
- <option value="3"<?php if ( $this->crawler_retry_limit === 3 ) echo ' selected="selected"'; ?>><?php _e( '3 times', self::DOMAIN ); ?></option>
2176
- <option value="4"<?php if ( $this->crawler_retry_limit === 4 ) echo ' selected="selected"'; ?>><?php _e( '4 times', self::DOMAIN ); ?></option>
2177
- <option value="5"<?php if ( $this->crawler_retry_limit === 5 ) echo ' selected="selected"'; ?>><?php _e( '5 times', self::DOMAIN ); ?></option>
2178
- </select>
2179
- <span class="description"><?php _e( 'Default: 1 time', self::DOMAIN ); ?></span>
2180
- </td>
2181
- </tr>
2182
- <tr>
2183
- <th><label for="crawler_ssl_verification"><?php _e( 'SSL verification', self::DOMAIN ); ?></label></th>
2184
- <td>
2185
- <select id="crawler_ssl_verification" name="crawler_ssl_verification">
2186
- <option value="0"<?php if ( $this->crawler_ssl_verification === self::OPT_COMMON_CRAWLER_SSL_VERIFY_OFF ) echo ' selected="selected"'; ?>><?php _e( 'Off', self::DOMAIN ); ?></option>
2187
- <option value="1"<?php if ( $this->crawler_ssl_verification === self::OPT_COMMON_CRAWLER_SSL_VERIFY_ON ) echo ' selected="selected"'; ?>><?php _e( 'On', self::DOMAIN ); ?></option>
2188
- </select>
2189
- <span class="description"><?php _e( 'Default: On', self::DOMAIN ); ?></span>
2190
- </td>
2191
- </tr>
2192
- </table>
2193
- <div class="submit-button">
2194
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
2195
- </div>
2196
  </div>
2197
  </div>
2198
- <div id="common-data-export" class="postbox">
2199
- <div class="handlediv" title="Click to toggle"><br></div>
2200
- <h3 class="hndle"><span><?php _e( 'Data Export', self::DOMAIN ); ?></span></h3>
2201
- <div class="inside">
2202
- <table class="form-table">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2203
  <tr>
2204
- <th><label for="data_export_mode"><?php _e( 'Method of data export', self::DOMAIN ); ?></label></th>
2205
  <td>
2206
- <select id="data_export_mode" name="data_export_mode">
2207
- <option value="1"<?php if ( $this->data_export_mode === self::OPT_COMMON_DATA_EXPORT_MANUAL ) echo ' selected="selected"'; ?>><?php _e( 'Manual', self::DOMAIN ); ?></option>
2208
- <option value="2"<?php if ( $this->data_export_mode === self::OPT_COMMON_DATA_EXPORT_SCHEDULER ) echo ' selected="selected"'; ?> disabled="disabled"><?php _e( 'Scheduler', self::DOMAIN ); ?></option>
2209
- </select>
2210
- <span class="description"><?php _e( 'Default: Manual', self::DOMAIN ); ?></span>
2211
  </td>
2212
  </tr>
2213
- <?php
2214
- if ( $this->data_export_mode === self::OPT_COMMON_DATA_EXPORT_SCHEDULER ) {
2215
- list( $cronstr[ 'minutes' ], $cronstr[ 'hours' ], $cronstr[ 'mday' ], $cronstr[ 'mon' ], $cronstr[ 'wday' ] ) = explode( ' ', $this->data_export_schedule, 5 );
2216
- if ( strstr( $cronstr[ 'minutes' ], '*/' ) ) {
2217
- $minutes = explode( '/', $cronstr[ 'minutes' ] );
2218
- } else {
2219
- $minutes = explode( ',', $cronstr[ 'minutes' ] );
2220
- }
2221
- if ( strstr( $cronstr[ 'hours' ], '*/' ) ) {
2222
- $hours = explode( '/', $cronstr[ 'hours' ] );
2223
- } else {
2224
- $hours = explode( ',', $cronstr[ 'hours' ] );
2225
- }
2226
- if ( strstr( $cronstr[ 'mday' ], '*/' ) ) {
2227
- $mday = explode( '/', $cronstr[ 'mday' ] );
2228
- } else {
2229
- $mday = explode( ',', $cronstr[ 'mday' ] );
2230
- }
2231
- if ( strstr( $cronstr[ 'mon' ], '*/' ) ) {
2232
- $mon = explode( '/', $cronstr[ 'mon' ] );
2233
- } else {
2234
- $mon = explode( ',', $cronstr[ 'mon' ] );
2235
- }
2236
- if ( strstr( $cronstr[ 'wday' ], '*/' ) ) {
2237
- $wday = explode( '/', $cronstr[ 'wday' ] );
2238
- } else {
2239
- $wday = explode( ',', $cronstr[ 'wday' ] );
2240
- }
2241
- ?>
2242
- <tr class="e_wpcron">
2243
- <th scope="row"><?php _e( 'Scheduler', self::DOMAIN ); ?></th>
2244
  <td>
2245
- <table class="wpcron">
2246
- <tr>
2247
- <th>
2248
- <?php _e( 'Type', self::DOMAIN ); ?>
2249
- </th>
2250
- <th>
2251
- </th>
2252
- <th>
2253
- <?php _e( 'Hour', self::DOMAIN ); ?>
2254
- </th>
2255
- <th>
2256
- <?php _e( 'Minute', self::DOMAIN ); ?>
2257
- </th>
2258
- </tr>
2259
- <tr>
2260
- <td>
2261
- <label for="idcronbtype-mon">
2262
- <?php echo '<input class="radio" type="radio"' . checked( TRUE, is_numeric( $mday[0] ), FALSE ) . ' name="e_cronbtype" value="mon" /> ' . __( 'monthly', self::DOMAIN ); ?>
2263
- </label>
2264
- </td>
2265
- <td>
2266
- <select name="e_moncronmday">
2267
- <?php
2268
- for ( $i = 1; $i <= 31; $i ++ ) {
2269
- $on_day = '';
2270
-
2271
- switch ( $i ) {
2272
- case 1:
2273
- $on_day = __( 'on 1.', self::DOMAIN );
2274
- break;
2275
- case 2:
2276
- $on_day = __( 'on 2.', self::DOMAIN );
2277
- break;
2278
- case 3:
2279
- $on_day = __( 'on 3.', self::DOMAIN );
2280
- break;
2281
- case 4:
2282
- $on_day = __( 'on 4.', self::DOMAIN );
2283
- break;
2284
- case 5:
2285
- $on_day = __( 'on 5.', self::DOMAIN );
2286
- break;
2287
- case 6:
2288
- $on_day = __( 'on 6.', self::DOMAIN );
2289
- break;
2290
- case 7:
2291
- $on_day = __( 'on 7.', self::DOMAIN );
2292
- break;
2293
- case 8:
2294
- $on_day = __( 'on 8.', self::DOMAIN );
2295
- break;
2296
- case 9:
2297
- $on_day = __( 'on 9.', self::DOMAIN );
2298
- break;
2299
- case 10:
2300
- $on_day = __( 'on 10.', self::DOMAIN );
2301
- break;
2302
- case 11:
2303
- $on_day = __( 'on 11.', self::DOMAIN );
2304
- break;
2305
- case 12:
2306
- $on_day = __( 'on 12.', self::DOMAIN );
2307
- break;
2308
- case 13:
2309
- $on_day = __( 'on 13.', self::DOMAIN );
2310
- break;
2311
- case 14:
2312
- $on_day = __( 'on 14.', self::DOMAIN );
2313
- break;
2314
- case 15:
2315
- $on_day = __( 'on 15.', self::DOMAIN );
2316
- break;
2317
- case 16:
2318
- $on_day = __( 'on 16.', self::DOMAIN );
2319
- break;
2320
- case 17:
2321
- $on_day = __( 'on 17.', self::DOMAIN );
2322
- break;
2323
- case 18:
2324
- $on_day = __( 'on 18.', self::DOMAIN );
2325
- break;
2326
- case 19:
2327
- $on_day = __( 'on 19.', self::DOMAIN );
2328
- break;
2329
- case 20:
2330
- $on_day = __( 'on 20.', self::DOMAIN );
2331
- break;
2332
- case 21:
2333
- $on_day = __( 'on 21.', self::DOMAIN );
2334
- break;
2335
- case 22:
2336
- $on_day = __( 'on 22.', self::DOMAIN );
2337
- break;
2338
- case 23:
2339
- $on_day = __( 'on 23.', self::DOMAIN );
2340
- break;
2341
- case 24:
2342
- $on_day = __( 'on 24.', self::DOMAIN );
2343
- break;
2344
- case 25:
2345
- $on_day = __( 'on 25.', self::DOMAIN );
2346
- break;
2347
- case 26:
2348
- $on_day = __( 'on 26.', self::DOMAIN );
2349
- break;
2350
- case 27:
2351
- $on_day = __( 'on 27.', self::DOMAIN );
2352
- break;
2353
- case 28:
2354
- $on_day = __( 'on 28.', self::DOMAIN );
2355
- break;
2356
- case 29:
2357
- $on_day = __( 'on 29.', self::DOMAIN );
2358
- break;
2359
- case 30:
2360
- $on_day = __( 'on 30.', self::DOMAIN );
2361
- break;
2362
- case 31:
2363
- $on_day = __( 'on 31.', self::DOMAIN );
2364
- break;
2365
- }
2366
-
2367
- echo '<option ' . selected( in_array( "$i", $mday, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $on_day . '</option>';
2368
- }
2369
- ?>
2370
- </select>
2371
- </td>
2372
- <td>
2373
- <select name="e_moncronhours">
2374
- <?php
2375
- for ( $i = 0; $i < 24; $i ++ ) {
2376
- echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
2377
- }
2378
- ?>
2379
- </select>
2380
- </td>
2381
- <td>
2382
- <select name="e_moncronminutes">
2383
- <?php
2384
- for ( $i = 0; $i < 60; $i = $i + 5 ) {
2385
- echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
2386
- }
2387
- ?>
2388
- </select>
2389
- </td>
2390
- </tr>
2391
- <tr>
2392
- <td>
2393
- <label for="idcronbtype-week">
2394
- <?php echo '<input class="radio" type="radio"' . checked( TRUE, is_numeric( $wday[0] ), FALSE ) . ' name="e_cronbtype" value="week" /> ' . __( 'weekly', self::DOMAIN ); ?>
2395
- </label>
2396
- </td>
2397
- <td>
2398
- <select name="e_weekcronwday">
2399
- <?php
2400
- echo '<option ' . selected( in_array( '0', $wday, TRUE ), TRUE, FALSE ) . ' value="0" />' . __( 'Sunday', self::DOMAIN ) . '</option>';
2401
- echo '<option ' . selected( in_array( '1', $wday, TRUE ), TRUE, FALSE ) . ' value="1" />' . __( 'Monday', self::DOMAIN ) . '</option>';
2402
- echo '<option ' . selected( in_array( '2', $wday, TRUE ), TRUE, FALSE ) . ' value="2" />' . __( 'Tuesday', self::DOMAIN ) . '</option>';
2403
- echo '<option ' . selected( in_array( '3', $wday, TRUE ), TRUE, FALSE ) . ' value="3" />' . __( 'Wednesday', self::DOMAIN ) . '</option>';
2404
- echo '<option ' . selected( in_array( '4', $wday, TRUE ), TRUE, FALSE ) . ' value="4" />' . __( 'Thursday', self::DOMAIN ) . '</option>';
2405
- echo '<option ' . selected( in_array( '5', $wday, TRUE ), TRUE, FALSE ) . ' value="5" />' . __( 'Friday', self::DOMAIN ) . '</option>';
2406
- echo '<option ' . selected( in_array( '6', $wday, TRUE ), TRUE, FALSE ) . ' value="6" />' . __( 'Saturday', self::DOMAIN ) . '</option>';
2407
- ?>
2408
- </select>
2409
- </td>
2410
- <td>
2411
- <select name="e_weekcronhours">
2412
- <?php
2413
- for ( $i = 0; $i < 24; $i ++ ) {
2414
- echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
2415
- }
2416
- ?>
2417
- </select>
2418
- </td>
2419
- <td>
2420
- <select name="e_weekcronminutes">
2421
- <?php
2422
- for ( $i = 0; $i < 60; $i = $i + 5 ) {
2423
- echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
2424
- }
2425
- ?>
2426
- </select>
2427
- </td>
2428
- </tr>
2429
- <tr>
2430
- <td>
2431
- <label for="idcronbtype-day">
2432
- <?php echo '<input class="radio" type="radio"' . checked( "**", $mday[0] . $wday[0], FALSE ) . ' name="e_cronbtype" value="day" /> ' . __( 'daily', self::DOMAIN ); ?>
2433
- </label>
2434
- </td>
2435
- <td>
2436
- </td>
2437
- <td>
2438
- <select name="e_daycronhours">
2439
- <?php
2440
- for ( $i = 0; $i < 24; $i ++ ) {
2441
- echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
2442
- }
2443
- ?>
2444
- </select>
2445
- </td>
2446
- <td>
2447
- <select name="e_daycronminutes">
2448
- <?php
2449
- for ( $i = 0; $i < 60; $i = $i + 5 ) {
2450
- echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
2451
- }
2452
- ?>
2453
- </select>
2454
- </td>
2455
- </tr>
2456
- <tr>
2457
- <td>
2458
- <label for="idcronbtype-hour">
2459
- <?php echo '<input class="radio" type="radio"' . checked( "*", $hours[0], FALSE, FALSE ) . ' name="e_cronbtype" value="hour" /> ' . __( 'hourly', self::DOMAIN ); ?>
2460
- </label>
2461
- </td>
2462
- <td></td>
2463
- <td></td>
2464
- <td>
2465
- <select name="e_hourcronminutes">
2466
- <?php
2467
- for ( $i = 0; $i < 60; $i = $i + 5 ) {
2468
- echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
2469
- }
2470
- ?>
2471
- </select>
2472
- </td>
2473
- </tr>
2474
- </table>
2475
  </td>
2476
  </tr>
2477
- <?php
2478
- }
2479
- ?>
2480
- </table>
2481
- <div class="submit-button">
2482
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
2483
- </div>
2484
- </div>
2485
- </div>
2486
- </form>
2487
- </div>
2488
- <div class="metabox-holder">
2489
- <div id="common-exported-file" class="postbox">
2490
- <div class="handlediv" title="Click to toggle"><br></div>
2491
- <h3 class="hndle"><span><?php _e( 'Exported File', self::DOMAIN ); ?></span></h3>
2492
- <div class="inside">
2493
  <table class="form-table">
2494
  <tbody>
2495
  <tr>
2496
- <th><?php _e( 'Disk usage of exported file', self::DOMAIN ); ?></th>
2497
  <td>
2498
- <?php
2499
- $abs_path = WP_PLUGIN_DIR . '/sns-count-cache/data/sns-count-cache-data.csv';
2500
- $file_size = SCC_Common_Util::get_file_size( $abs_path );
2501
-
2502
- if ( isset( $file_size ) ) {
2503
- echo $file_size;
2504
- } else {
2505
- _e( 'No exported file', self::DOMAIN );
2506
- }
2507
- ?>
2508
  </td>
2509
  </tr>
2510
  </tbody>
2511
  </table>
2512
- <form action="admin.php?page=scc-setting" method="post">
2513
- <?php wp_nonce_field( __FILE__, '_wpnonce' ); ?>
2514
- <table class="form-table">
2515
- <tbody>
2516
- <tr>
2517
- <th><?php _e( 'Manual export', self::DOMAIN ); ?></th>
2518
- <td>
2519
- <input type="submit" class="button button-secondary" name="export_data" value="<?php _e( 'Export', self::DOMAIN ); ?>" />
2520
- <br>
2521
- <span class="description"><?php _e( 'Export share count to a csv file.', self::DOMAIN ); ?></span>
2522
- </td>
2523
- </tr>
2524
- </tbody>
2525
- </table>
2526
- </form>
2527
- <?php
2528
- if ( file_exists( $abs_path ) ) {
2529
- ?>
2530
- <form action="admin.php?page=scc-setting" method="post">
2531
- <?php wp_nonce_field( __FILE__, '_wpnonce' ); ?>
2532
- <table class="form-table">
2533
- <tbody>
2534
- <tr>
2535
- <th><?php _e( 'Reset of exported file', self::DOMAIN ); ?></th>
2536
- <td>
2537
- <input type="submit" class="button button-secondary" name="reset_data" value="<?php _e( 'Reset', self::DOMAIN ); ?>" />
2538
- <br>
2539
- <span class="description"><?php _e( 'Clear exported csv file.', self::DOMAIN ); ?></span>
2540
- </td>
2541
- </tr>
2542
- </tbody>
2543
- </table>
2544
- </form>
2545
- <form action="<?php echo plugins_url(); ?>/sns-count-cache/includes/download.php" method="post">
2546
- <?php wp_nonce_field( 'download', '_wpnonce' ); ?>
2547
- <table class="form-table">
2548
- <tbody>
2549
- <tr>
2550
- <th><?php _e( 'Download of exported file', self::DOMAIN ); ?></th>
2551
- <td>
2552
- <input type="submit" class="button button-secondary" name="download_data" value="<?php _e( 'Download', self::DOMAIN ); ?>" />
2553
- <br>
2554
- <span class="description"><?php _e( 'Download the exported csv file.', self::DOMAIN ); ?></span>
2555
- </td>
2556
- </tr>
2557
- </tbody>
2558
- </table>
2559
- </form>
2560
- <?php
2561
- }
2562
- ?>
2563
- </div>
2564
  </div>
2565
  </div>
2566
  </div>
2567
  </div>
 
1
  <?php
2
+ /**
3
  admin-setting.php
4
 
5
  Description: Option page implementation
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ if ( ! defined( 'ABSPATH' ) ) {
31
+ exit(); // Exit if accessed directly
32
+ }
33
 
34
+ $tmp_instagram_access_token = '';
35
+ $tmp_facebook_access_token = '';
36
+ $tmp_twitter_bearer_token = '';
37
 
38
+ if ( ! empty( $_POST['_wpnonce'] ) && check_admin_referer( __FILE__, '_wpnonce' ) ) {
39
+ if ( current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
40
+ if ( isset( $_POST['update_all_options'] ) && __( 'Update All Options', self::DOMAIN ) === wp_unslash( $_POST['update_all_options'] ) ) {
41
 
42
  $wp_error = new WP_Error();
43
 
 
44
  $settings = get_option( self::DB_SETTINGS );
45
 
46
  $share_base_cache_target = array();
47
  $follow_base_cache_target = array();
48
 
49
+ if ( ! empty( $_POST['share_base_custom_post_types'] ) ) {
50
+ $settings[ self::DB_SHARE_CUSTOM_POST_TYPES ] = explode( ',', sanitize_text_field( wp_unslash( $_POST['share_base_custom_post_types'] ) ) );
51
  } else {
52
+ $settings[ self::DB_SHARE_CUSTOM_POST_TYPES ] = array();
53
  }
54
 
55
+ if ( ! empty( $_POST['share_base_check_interval'] ) ) {
56
+ $tmp_share_base_check_interval = sanitize_text_field( wp_unslash( $_POST['share_base_check_interval'] ) );
57
  if ( is_numeric( $tmp_share_base_check_interval ) ) {
58
+ $settings[ self::DB_SHARE_BASE_CHECK_INTERVAL ] = $tmp_share_base_check_interval;
59
  }
60
  }
61
 
62
+ if ( ! empty( $_POST['share_base_posts_per_check'] ) ) {
63
+ $tmp_share_base_posts_per_check = sanitize_text_field( wp_unslash( $_POST['share_base_posts_per_check'] ) );
64
  if ( is_numeric( $tmp_share_base_posts_per_check ) ) {
65
+ $settings[ self::DB_SHARE_BASE_POSTS_PER_CHECK ] = $tmp_share_base_posts_per_check;
66
  }
67
  }
68
 
69
+ if ( ! empty( $_POST['dynamic_cache_mode'] ) ) {
70
+ $settings[ self::DB_COMMON_DYNAMIC_CACHE_MODE ] = sanitize_text_field( wp_unslash( $_POST['dynamic_cache_mode'] ) );
71
  }
72
 
73
+ if ( ! empty( $_POST['fault_tolerance_mode'] ) ) {
74
+ $settings[ self::DB_COMMON_FAULT_TOLERANCE_MODE ] = sanitize_text_field( wp_unslash( $_POST['fault_tolerance_mode'] ) );
75
  }
76
 
77
+ if ( ! empty( $_POST['share_variation_analysis_mode'] ) ) {
78
+ $settings[ self::DB_SHARE_VARIATION_ANALYSIS_MODE ] = sanitize_text_field( wp_unslash( $_POST['share_variation_analysis_mode'] ) );
79
  }
80
 
81
+ if ( ! empty( $_POST['follow_variation_analysis_mode'] ) ) {
82
+ $settings[ self::DB_FOLLOW_VARIATION_ANALYSIS_MODE ] = sanitize_text_field( wp_unslash( $_POST['follow_variation_analysis_mode'] ) );
83
  }
84
 
85
+ if ( ! empty( $_POST['share_rush_new_content_term'] ) ) {
86
+ $tmp_share_rush_new_content_term = sanitize_text_field( wp_unslash( $_POST['share_rush_new_content_term'] ) );
87
  if ( is_numeric( $tmp_share_rush_new_content_term ) ) {
88
+ $settings[ self::DB_SHARE_RUSH_NEW_CONTENT_TERM ] = $tmp_share_rush_new_content_term;
89
  }
90
  }
91
 
92
+ if ( ! empty( $_POST['share_rush_check_interval'] ) ) {
93
+ $tmp_share_rush_check_interval = sanitize_text_field( wp_unslash( $_POST['share_rush_check_interval'] ) );
94
  if ( is_numeric( $tmp_share_rush_check_interval ) ) {
95
+ $settings[ self::DB_SHARE_RUSH_CHECK_INTERVAL ] = $tmp_share_rush_check_interval;
96
  }
97
  }
98
 
99
+ if ( ! empty( $_POST['share_rush_posts_per_check'] ) ) {
100
+ $tmp_share_rush_posts_per_check = sanitize_text_field( wp_unslash( $_POST['share_rush_posts_per_check'] ) );
101
  if ( is_numeric( $tmp_share_rush_posts_per_check ) ) {
102
+ $settings[ self::DB_SHARE_RUSH_POSTS_PER_CHECK ] = $tmp_share_rush_posts_per_check;
103
  }
104
  }
105
 
106
+ if ( ! empty( $_POST['data_export_mode'] ) ) {
107
+ $settings[ self::DB_COMMON_DATA_EXPORT_MODE ] = sanitize_text_field( wp_unslash( $_POST['data_export_mode'] ) );
108
  }
109
 
110
+ if ( ! empty( $_POST['data_export_interval'] ) ) {
111
+ $tmp_data_export_interval = sanitize_text_field( wp_unslash( $_POST['data_export_interval'] ) );
112
  if ( is_numeric( $tmp_data_export_interval ) ) {
113
+ $settings[ self::DB_COMMON_DATA_EXPORT_INTERVAL ] = $tmp_data_export_interval;
114
  }
115
  }
116
 
117
+ if ( ! empty( $_POST['common_data_crawler_retry_limit'] ) ) {
118
+ $tmp_common_data_crawler_retry_limit = sanitize_text_field( wp_unslash( $_POST['common_data_crawler_retry_limit'] ) );
119
  if ( is_numeric( $tmp_common_data_crawler_retry_limit ) ) {
120
+ $settings[ self::DB_COMMON_CRAWLER_RETRY_LIMIT ] = $tmp_common_data_crawler_retry_limit;
121
  }
122
  }
123
 
124
+ if ( ! empty( $_POST['share_base_cache_target_twitter'] ) ) {
125
+ $share_base_cache_target[ self::REF_SHARE_TWITTER ] = true;
126
  } else {
127
+ $share_base_cache_target[ self::REF_SHARE_TWITTER ] = false;
128
  }
129
 
130
+ if ( ! empty( $_POST['share_alternative_twitter_api'] ) ) {
131
+ $settings[ self::DB_SHARE_BASE_TWITTER_API ] = sanitize_text_field( wp_unslash( $_POST['share_alternative_twitter_api'] ) );
132
  }
133
 
134
+ if ( ! empty( $_POST['share_base_cache_target_facebook'] ) ) {
135
+ $share_base_cache_target[ self::REF_SHARE_FACEBOOK ] = true;
136
  } else {
137
+ $share_base_cache_target[ self::REF_SHARE_FACEBOOK ] = false;
138
  }
139
 
140
+ if ( ! empty( $_POST['share_base_cache_target_gplus'] ) ) {
141
+ $share_base_cache_target[ self::REF_SHARE_GPLUS ] = true;
142
  } else {
143
+ $share_base_cache_target[ self::REF_SHARE_GPLUS ] = false;
144
  }
145
 
146
+ if ( ! empty( $_POST['share_base_cache_target_pocket'] ) ) {
147
+ $share_base_cache_target[ self::REF_SHARE_POCKET ] = true;
148
  } else {
149
+ $share_base_cache_target[ self::REF_SHARE_POCKET ] = false;
150
  }
151
 
152
+ if ( ! empty( $_POST['share_base_cache_target_hatebu'] ) ) {
153
+ $share_base_cache_target[ self::REF_SHARE_HATEBU ] = true;
154
  } else {
155
+ $share_base_cache_target[ self::REF_SHARE_HATEBU ] = false;
156
  }
157
 
158
+ if ( ! empty( $_POST['share_base_cache_target_pinterest'] ) ) {
159
+ $share_base_cache_target[ self::REF_SHARE_PINTEREST ] = true;
160
  } else {
161
+ $share_base_cache_target[ self::REF_SHARE_PINTEREST ] = false;
162
  }
163
 
164
+ if ( ! empty( $_POST['share_base_cache_target_linkedin'] ) ) {
165
+ $share_base_cache_target[ self::REF_SHARE_LINKEDIN ] = true;
166
  } else {
167
+ $share_base_cache_target[ self::REF_SHARE_LINKEDIN ] = false;
168
  }
169
 
170
  if ( ! empty( $share_base_cache_target ) ) {
171
+ $settings[ self::DB_SHARE_CACHE_TARGET ] = $share_base_cache_target;
172
  }
173
 
174
+ if ( ! empty( $_POST['follow_base_check_interval'] ) ) {
175
+ $tmp_follow_base_check_interval = sanitize_text_field( wp_unslash( $_POST['follow_base_check_interval'] ) );
176
  if ( is_numeric( $tmp_follow_base_check_interval ) ) {
177
  if ( $tmp_follow_base_check_interval >= self::OPT_FOLLOW_BASE_CHECK_INTERVAL_MIN ) {
178
+ $settings[ self::DB_FOLLOW_CHECK_INTERVAL ] = $tmp_follow_base_check_interval;
179
  } else {
180
+ $settings[ self::DB_FOLLOW_CHECK_INTERVAL ] = self::OPT_FOLLOW_BASE_CHECK_INTERVAL_MIN;
181
  }
182
  }
183
  }
184
 
185
+ if ( ! empty( $_POST['follow_base_cache_target_feedly'] ) ) {
186
+ $follow_base_cache_target[ self::REF_FOLLOW_FEEDLY ] = true;
187
+ } else {
188
+ $follow_base_cache_target[ self::REF_FOLLOW_FEEDLY ] = false;
189
+ }
190
+
191
+ if ( ! empty( $_POST['follow_base_cache_target_twitter'] ) ) {
192
+ $follow_base_cache_target[ self::REF_FOLLOW_TWITTER ] = true;
193
  } else {
194
+ $follow_base_cache_target[ self::REF_FOLLOW_TWITTER ] = false;
195
  }
196
 
197
+ if ( ! empty( $_POST['follow_base_cache_target_facebook'] ) ) {
198
+ $follow_base_cache_target[ self::REF_FOLLOW_FACEBOOK ] = true;
199
  } else {
200
+ $follow_base_cache_target[ self::REF_FOLLOW_FACEBOOK ] = false;
201
  }
202
 
203
+ if ( ! empty( $_POST['follow_base_cache_target_push7'] ) ) {
204
+ $follow_base_cache_target[ self::REF_FOLLOW_PUSH7 ] = true;
205
  } else {
206
+ $follow_base_cache_target[ self::REF_FOLLOW_PUSH7 ] = false;
207
  }
208
 
209
+ if ( ! empty( $_POST['follow_base_cache_target_instagram'] ) ) {
210
+ $follow_base_cache_target[ self::REF_FOLLOW_INSTAGRAM ] = true;
211
  } else {
212
+ $follow_base_cache_target[ self::REF_FOLLOW_INSTAGRAM ] = false;
213
  }
214
 
215
+ if ( ! empty( $_POST['follow_base_cache_target_onesignal'] ) ) {
216
+ $follow_base_cache_target[ self::REF_FOLLOW_ONESIGNAL ] = true;
217
  } else {
218
+ $follow_base_cache_target[ self::REF_FOLLOW_ONESIGNAL ] = false;
219
  }
220
 
221
  if ( ! empty( $follow_base_cache_target ) ) {
222
+ $settings[ self::DB_FOLLOW_CACHE_TARGET ] = $follow_base_cache_target;
223
  }
224
 
225
  $follow_twitter_preparation_flag = true;
226
 
227
+ if ( ! empty( $_POST['share_facebook_app_id'] ) ) {
228
+ $settings[ self::DB_SHARE_FACEBOOK_APP_ID ] = SCC_Crypt::encrypt( SCC_Format::sanitize( wp_unslash( $_POST['share_facebook_app_id'] ) ), AUTH_KEY );
229
  }
230
 
231
+ if ( ! empty( $_POST['share_facebook_app_secret'] ) ) {
232
+ $settings[ self::DB_SHARE_FACEBOOK_APP_SECRET ] = SCC_Crypt::encrypt( SCC_Format::sanitize( wp_unslash( $_POST['share_facebook_app_secret'] ) ), AUTH_KEY );
233
  }
234
 
235
+ if ( ! empty( $_POST['follow_twitter_screen_name'] ) ) {
236
+ $settings[ self::DB_FOLLOW_TWITTER_SCREEN_NAME ] = sanitize_text_field( wp_unslash( $_POST['follow_twitter_screen_name'] ) );
237
  }
238
 
239
+ if ( ! empty( $_POST['follow_twitter_api_key'] ) ) {
240
+ $settings[ self::DB_FOLLOW_TWITTER_API_KEY ] = SCC_Crypt::encrypt( SCC_Format::sanitize( wp_unslash( $_POST['follow_twitter_api_key'] ) ), AUTH_KEY );
241
  } else {
242
  $follow_twitter_preparation_flag = false;
243
  }
244
 
245
+ if ( ! empty( $_POST['follow_twitter_api_secret_key'] ) ) {
246
+ $settings[ self::DB_FOLLOW_TWITTER_API_SECRET_KEY ] = SCC_Crypt::encrypt( SCC_Format::sanitize( wp_unslash( $_POST['follow_twitter_api_secret_key'] ) ), AUTH_KEY );
247
  } else {
248
  $follow_twitter_preparation_flag = false;
249
  }
250
 
251
+ if ( ! empty( $_POST['follow_twitter_bearer_token'] ) ) {
252
+ $settings[ self::DB_FOLLOW_TWITTER_BEARER_TOKEN ] = SCC_Crypt::encrypt( SCC_Format::sanitize( wp_unslash( $_POST['follow_twitter_bearer_token'] ) ), AUTH_KEY );
253
  }
254
 
255
  /*
256
+ if ( isset( $_POST['follow_twitter_access_token'] ) && $_POST['follow_twitter_access_token'] ) {
257
+ $settings[self::DB_FOLLOW_TWITTER_ACCESS_TOKEN] = SCC_Crypt::encrypt( $_POST['follow_twitter_access_token'], AUTH_KEY );
258
  }
259
 
260
+ if ( isset( $_POST['follow_twitter_access_token_secret'] ) && $_POST['follow_twitter_access_token_secret'] ) {
261
+ $settings[self::DB_FOLLOW_TWITTER_ACCESS_TOKEN_SECRET] = SCC_Crypt::encrypt( $_POST['follow_twitter_access_token_secret'], AUTH_KEY );
262
  }
263
  */
264
 
265
+ if ( ! empty( $_POST['follow_facebook_page_id'] ) ) {
266
+ $settings[ self::DB_FOLLOW_FACEBOOK_PAGE_ID ] = sanitize_text_field( wp_unslash( $_POST['follow_facebook_page_id'] ) );
267
+ }
268
+
269
+ if ( ! empty( $_POST['follow_facebook_app_id'] ) ) {
270
+ $settings[ self::DB_FOLLOW_FACEBOOK_APP_ID ] = SCC_Crypt::encrypt( SCC_Format::sanitize( wp_unslash( $_POST['follow_facebook_app_id'] ) ), AUTH_KEY );
271
+ }
272
+
273
+ if ( ! empty( $_POST['follow_facebook_app_secret'] ) ) {
274
+ $settings[ self::DB_FOLLOW_FACEBOOK_APP_SECRET ] = SCC_Crypt::encrypt( SCC_Format::sanitize( wp_unslash( $_POST['follow_facebook_app_secret'] ) ), AUTH_KEY );
275
  }
276
 
277
+ if ( ! empty( $_POST['follow_facebook_access_token'] ) ) {
278
+ $settings[ self::DB_FOLLOW_FACEBOOK_ACCESS_TOKEN ] = SCC_Crypt::encrypt( SCC_Format::sanitize( wp_unslash( $_POST['follow_facebook_access_token'] ) ), AUTH_KEY );
279
  }
280
 
281
+ if ( ! empty( $_POST['follow_push7_app_number'] ) ) {
282
+ $settings[ self::DB_FOLLOW_PUSH7_APP_NUMBER ] = SCC_Crypt::encrypt( sanitize_text_field( wp_unslash( $_POST['follow_push7_app_number'] ) ), AUTH_KEY );
283
  }
284
 
285
+ if ( ! empty( $_POST['follow_instagram_access_token'] ) ) {
286
+ $settings[ self::DB_FOLLOW_INSTAGRAM_ACCESS_TOKEN ] = SCC_Crypt::encrypt( SCC_Format::sanitize( wp_unslash( $_POST['follow_instagram_access_token'] ) ), AUTH_KEY );
287
  }
288
 
289
+ if ( ! empty( $_POST['follow_instagram_client_id'] ) ) {
290
+ $settings[ self::DB_FOLLOW_INSTAGRAM_CLIENT_ID ] = SCC_Crypt::encrypt( SCC_Format::sanitize( wp_unslash( $_POST['follow_instagram_client_id'] ) ), AUTH_KEY );
291
  }
292
 
293
+ if ( ! empty( $_POST['follow_instagram_client_secret'] ) ) {
294
+ $settings[ self::DB_FOLLOW_INSTAGRAM_CLIENT_SECRET ] = SCC_Crypt::encrypt( SCC_Format::sanitize( wp_unslash( $_POST['follow_instagram_client_secret'] ) ), AUTH_KEY );
295
  }
296
 
297
+ if ( ! empty( $_POST['follow_onesignal_app_id'] ) ) {
298
+ $settings[ self::DB_FOLLOW_ONESIGNAL_APP_ID ] = SCC_Crypt::encrypt( SCC_Format::sanitize( wp_unslash( $_POST['follow_onesignal_app_id'] ) ), AUTH_KEY );
299
  }
300
 
301
+ if ( ! empty( $_POST['follow_onesignal_rest_api_key'] ) ) {
302
+ $settings[ self::DB_FOLLOW_ONESIGNAL_REST_API_KEY ] = SCC_Crypt::encrypt( SCC_Format::sanitize( wp_unslash( $_POST['follow_onesignal_rest_api_key'] ) ), AUTH_KEY );
303
  }
304
 
305
+ if ( ! empty( $_POST['follow_feed_type'] ) ) {
306
+ switch ( $_POST['follow_feed_type'] ) {
307
  case 'default':
308
+ $settings[ self::DB_FOLLOW_FEED_TYPE ] = self::OPT_FEED_TYPE_DEFAULT;
309
  break;
310
  case 'rss2':
311
+ $settings[ self::DB_FOLLOW_FEED_TYPE ] = self::OPT_FEED_TYPE_RSS2;
312
  break;
313
  case 'rss':
314
+ $settings[ self::DB_FOLLOW_FEED_TYPE ] = self::OPT_FEED_TYPE_RSS;
315
  break;
316
  case 'rdf':
317
+ $settings[ self::DB_FOLLOW_FEED_TYPE ] = self::OPT_FEED_TYPE_RDF;
318
  break;
319
  case 'atom':
320
+ $settings[ self::DB_FOLLOW_FEED_TYPE ] = self::OPT_FEED_TYPE_ATOM;
321
  break;
322
  default:
323
+ $settings[ self::DB_FOLLOW_FEED_TYPE ] = self::OPT_FEED_TYPE_DEFAULT;
324
  }
325
  } else {
326
+ $settings[ self::DB_FOLLOW_FEED_TYPE ] = self::OPT_FEED_TYPE_DEFAULT;
327
  }
328
 
329
+ if ( ! empty( $_POST['scheme_migration_mode'] ) ) {
330
+ $settings[ self::DB_COMMON_SCHEME_MIGRATION_MODE ] = self::OPT_COMMON_SCHEME_MIGRATION_MODE_ON;
331
  } else {
332
+ $settings[ self::DB_COMMON_SCHEME_MIGRATION_MODE ] = self::OPT_COMMON_SCHEME_MIGRATION_MODE_OFF;
333
  }
334
 
335
+ if ( ! empty( $_POST['scheme_migration_date'] ) ) {
336
+ $tmp_scheme_migration_date = sanitize_text_field( wp_unslash( $_POST['scheme_migration_date'] ) );
337
  if ( strptime( $tmp_scheme_migration_date, '%Y/%m/%d' ) ) {
338
+ $settings[ self::DB_COMMON_SCHEME_MIGRATION_DATE ] = $tmp_scheme_migration_date;
339
  }
340
  }
341
 
342
+ if ( ! empty( $_POST['crawler_ssl_verification'] ) ) {
343
+ $settings[ self::DB_COMMON_CRAWLER_SSL_VERIFICATION ] = self::OPT_COMMON_CRAWLER_SSL_VERIFY_ON;
344
  } else {
345
+ $settings[ self::DB_COMMON_CRAWLER_SSL_VERIFICATION ] = self::OPT_COMMON_CRAWLER_SSL_VERIFY_OFF;
346
  }
347
 
348
+ if ( isset( $_POST['a_cronbtype'] ) && 'mon' === wp_unslash( $_POST['a_cronbtype'] ) ) {
349
+ if ( isset( $_POST['a_moncronminutes'] ) && isset( $_POST['a_moncronhours'] ) && isset( $_POST['a_moncronmday'] ) ) {
350
+ $settings[ self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE ] = sanitize_text_field( wp_unslash( $_POST['a_moncronminutes'] ) ) . ' ' . sanitize_text_field( wp_unslash( $_POST['a_moncronhours'] ) ) . ' ' . sanitize_text_field( wp_unslash( $_POST['a_moncronmday'] ) ) . ' * *';
351
+ }
352
  }
353
 
354
+ if ( isset( $_POST['a_cronbtype'] ) && 'week' === wp_unslash( $_POST['a_cronbtype'] ) ) {
355
+ if ( isset( $_POST['a_weekcronminutes'] ) && isset( $_POST['a_weekcronhours'] ) && isset( $_POST['a_weekcronwday'] ) ) {
356
+ $settings[ self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE ] = sanitize_text_field( wp_unslash( $_POST['a_weekcronminutes'] ) ) . ' ' . sanitize_text_field( wp_unslash( $_POST['a_weekcronhours'] ) ) . ' * * ' . sanitize_text_field( wp_unslash( $_POST['a_weekcronwday'] ) );
357
+ }
358
  }
359
 
360
+ if ( isset( $_POST['a_cronbtype'] ) && 'day' === wp_unslash( $_POST['a_cronbtype'] ) ) {
361
+ if ( isset( $_POST['a_daycronminutes'] ) && isset( $_POST['a_daycronhours'] ) ) {
362
+ $settings[ self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE ] = sanitize_text_field( wp_unslash( $_POST['a_daycronminutes'] ) ) . ' ' . sanitize_text_field( wp_unslash( $_POST['a_daycronhours'] ) ) . ' * * *';
363
+ }
364
  }
365
 
366
+ if ( isset( $_POST['a_cronbtype'] ) && 'hour' === wp_unslash( $_POST['a_cronbtype'] ) ) {
367
+ if ( isset( $_POST['a_hourcronminutes'] ) ) {
368
+ $settings[ self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE ] = sanitize_text_field( wp_unslash( $_POST['a_hourcronminutes'] ) ) . ' * * * *';
369
+ }
370
  }
371
 
372
+ if ( isset( $_POST['b_cronbtype'] ) && 'mon' === wp_unslash( $_POST['b_cronbtype'] ) ) {
373
+ if ( isset( $_POST['b_moncronminutes'] ) && isset( $_POST['b_moncronhours'] ) && isset( $_POST['b_moncronmday'] ) ) {
374
+ $settings[ self::DB_FOLLOW_VARIATION_ANALYSIS_SCHEDULE ] = sanitize_text_field( wp_unslash( $_POST['b_moncronminutes'] ) ) . ' ' . sanitize_text_field( wp_unslash( $_POST['b_moncronhours'] ) ) . ' ' . sanitize_text_field( wp_unslash( $_POST['b_moncronmday'] ) ) . ' * *';
375
+ }
376
  }
377
 
378
+ if ( isset( $_POST['b_cronbtype'] ) && 'week' === wp_unslash( $_POST['b_cronbtype'] ) ) {
379
+ if ( isset( $_POST['b_weekcronminutes'] ) && isset( $_POST['b_weekcronhours'] ) && isset( $_POST['b_weekcronwday'] ) ) {
380
+ $settings[ self::DB_FOLLOW_VARIATION_ANALYSIS_SCHEDULE ] = sanitize_text_field( wp_unslash( $_POST['b_weekcronminutes'] ) ) . ' ' . sanitize_text_field( wp_unslash( $_POST['b_weekcronhours'] ) ) . ' * * ' . sanitize_text_field( wp_unslash( $_POST['b_weekcronwday'] ) );
381
+ }
382
  }
383
 
384
+ if ( isset( $_POST['b_cronbtype'] ) && 'day' === wp_unslash( $_POST['b_cronbtype'] ) ) {
385
+ if ( isset( $_POST['b_daycronminutes'] ) && isset( $_POST['b_daycronhours'] ) ) {
386
+ $settings[ self::DB_FOLLOW_VARIATION_ANALYSIS_SCHEDULE ] = sanitize_text_field( wp_unslash( $_POST['b_daycronminutes'] ) ) . ' ' . sanitize_text_field( wp_unslash( $_POST['b_daycronhours'] ) ) . ' * * *';
387
+ }
388
  }
389
 
390
+ if ( isset( $_POST['b_cronbtype'] ) && 'hour' === wp_unslash( $_POST['b_cronbtype'] ) ) {
391
+ if ( isset( $_POST['b_hourcronminutes'] ) ) {
392
+ $settings[ self::DB_FOLLOW_VARIATION_ANALYSIS_SCHEDULE ] = sanitize_text_field( wp_unslash( $_POST['b_hourcronminutes'] ) ) . ' * * * *';
393
+ }
394
  }
395
 
396
+ if ( isset( $_POST['e_cronbtype'] ) && 'mon' === wp_unslash( $_POST['e_cronbtype'] ) ) {
397
+ if ( isset( $_POST['e_moncronminutes'] ) && isset( $_POST['e_moncronhours'] ) && isset( $_POST['e_moncronmday'] ) ) {
398
+ $settings[ self::DB_COMMON_DATA_EXPORT_SCHEDULE ] = sanitize_text_field( wp_unslash( $_POST['e_moncronminutes'] ) ) . ' ' . sanitize_text_field( wp_unslash( $_POST['e_moncronhours'] ) ) . ' ' . sanitize_text_field( wp_unslash( $_POST['e_moncronmday'] ) ) . ' * *';
399
+ }
400
  }
401
 
402
+ if ( isset( $_POST['e_cronbtype'] ) && 'week' === wp_unslash( $_POST['e_cronbtype'] ) ) {
403
+ if ( isset( $_POST['e_weekcronminutes'] ) && isset( $_POST['e_weekcronhours'] ) && isset( $_POST['e_weekcronwday'] ) ) {
404
+ $settings[ self::DB_COMMON_DATA_EXPORT_SCHEDULE ] = sanitize_text_field( wp_unslash( $_POST['e_weekcronminutes'] ) ) . ' ' . sanitize_text_field( wp_unslash( $_POST['e_weekcronhours'] ) ) . ' * * ' . sanitize_text_field( wp_unslash( $_POST['e_weekcronwday'] ) );
405
+ }
406
  }
407
 
408
+ if ( isset( $_POST['e_cronbtype'] ) && 'day' === wp_unslash( $_POST['e_cronbtype'] ) ) {
409
+ if ( isset( $_POST['e_daycronminutes'] ) && isset( $_POST['e_daycronhours'] ) ) {
410
+ $settings[ self::DB_COMMON_DATA_EXPORT_SCHEDULE ] = sanitize_text_field( wp_unslash( $_POST['e_daycronminutes'] ) ) . ' ' . sanitize_text_field( wp_unslash( $_POST['e_daycronhours'] ) ) . ' * * *';
411
+ }
412
  }
413
 
414
+ if ( isset( $_POST['e_cronbtype'] ) && 'hour' === wp_unslash( $_POST['e_cronbtype'] ) ) {
415
+ if ( isset( $_POST['e_hourcronminutes'] ) ) {
416
+ $settings[ self::DB_COMMON_DATA_EXPORT_SCHEDULE ] = sanitize_text_field( wp_unslash( $_POST['e_hourcronminutes'] ) ) . ' * * * *';
417
+ }
418
  }
419
 
420
  update_option( self::DB_SETTINGS, $settings );
422
  $this->reactivate_plugin();
423
 
424
  set_transient( self::OPT_COMMON_ERROR_MESSAGE, $wp_error->get_error_messages(), 10 );
425
+ } // End if().
426
 
427
+ if ( isset( $_POST['reset_data'] ) && __( 'Reset', self::DOMAIN ) === wp_unslash( $_POST['reset_data'] ) ) {
428
+ SCC_Logger::log( '[' . __METHOD__ . '] reset' );
 
 
 
 
 
429
 
430
+ $this->export_engines[ self::REF_COMMON_EXPORT ]->reset_export();
431
  }
432
 
433
+ if ( isset( $_POST['export_data'] ) && __( 'Export', self::DOMAIN ) === wp_unslash( $_POST['export_data'] ) ) {
434
+ SCC_Logger::log( '[' . __METHOD__ . '] export' );
435
 
436
  set_time_limit( $this->extended_max_execution_time );
437
 
438
+ $this->export_engines[ self::REF_COMMON_EXPORT ]->execute_export( null );
439
 
440
  set_time_limit( $this->original_max_execution_time );
 
 
441
  }
442
 
443
+ if ( isset( $_POST['update_share_comparison_base'] ) && __( 'Update Basis of Comparison', self::DOMAIN ) === wp_unslash( $_POST['update_share_comparison_base'] ) ) {
444
+ SCC_Logger::log( '[' . __METHOD__ . '] base' );
445
 
446
  set_time_limit( $this->extended_max_execution_time );
447
 
448
+ $this->analytical_engines[ self::REF_SHARE_ANALYSIS ]->execute_base( null );
449
 
450
  set_time_limit( $this->original_max_execution_time );
 
 
451
  }
452
 
453
+ if ( isset( $_POST['update_follow_comparison_base'] ) && __( 'Update Basis of Comparison', self::DOMAIN ) === wp_unslash( $_POST['update_follow_comparison_base'] ) ) {
454
+ SCC_Logger::log( '[' . __METHOD__ . '] base' );
455
 
456
  set_time_limit( $this->extended_max_execution_time );
457
 
458
+ $this->analytical_engines[ self::REF_FOLLOW_ANALYSIS ]->execute_base( null );
459
 
460
  set_time_limit( $this->original_max_execution_time );
 
 
461
  }
462
 
463
+ if ( isset( $_POST['clear_share_base_cache'] ) && __( 'Clear Cache', self::DOMAIN ) === wp_unslash( $_POST['clear_share_base_cache'] ) ) {
464
+ SCC_Logger::log( '[' . __METHOD__ . '] clear cache' );
465
 
466
  set_time_limit( $this->extended_max_execution_time );
467
 
468
+ $this->cache_engines[ self::REF_SHARE_BASE ]->clear_cache();
469
  //$this->cache_engines[self::REF_SHARE_2ND]->clear_cache();
470
+ $this->cache_engines[ self::REF_SHARE_2ND ]->initialize_cache();
471
+ $this->analytical_engines[ self::REF_SHARE_ANALYSIS ]->clear_base();
472
 
473
  set_time_limit( $this->original_max_execution_time );
 
 
474
  }
475
 
476
+ if ( isset( $_POST['clear_follow_base_cache'] ) && __( 'Clear Cache', self::DOMAIN ) === wp_unslash( $_POST['clear_follow_base_cache'] ) ) {
477
+ SCC_Logger::log( '[' . __METHOD__ . '] clear cache' );
478
 
479
  set_time_limit( $this->extended_max_execution_time );
480
 
481
+ $this->cache_engines[ self::REF_FOLLOW_BASE ]->clear_cache();
482
+ //$this->cache_engines[ self::REF_FOLLOW_2ND ]->clear_cache();
483
+ $this->cache_engines[ self::REF_FOLLOW_2ND ]->initialize_cache();
484
 
485
  set_time_limit( $this->original_max_execution_time );
 
 
486
  }
487
 
488
+ if ( isset( $_POST['direct_follow_base_cache'] ) && __( 'Cache', self::DOMAIN ) === wp_unslash( $_POST['direct_follow_base_cache'] ) ) {
489
+ SCC_Logger::log( '[' . __METHOD__ . '] cache' );
490
 
491
  set_time_limit( $this->extended_max_execution_time );
492
 
493
+ $this->cache_engines[ self::REF_FOLLOW_BASE ]->direct_cache( true );
494
 
495
  set_time_limit( $this->original_max_execution_time );
 
 
496
  }
497
 
498
+ if ( isset( $_POST['get_tiwtter_bearer_token'] ) && __( 'Get Bearer Token', self::DOMAIN ) === wp_unslash( $_POST['get_tiwtter_bearer_token'] ) ) {
499
+ $tmp_twitter_bearer_token = SCC_Oauth::get_twitter_bearer_token( $this->follow_twitter_api_key, $this->follow_twitter_api_secret_key );
500
  }
501
+ } // End if().
502
+
503
+ } elseif ( ! empty( $_GET['_wpnonce'] ) && ! empty( $_GET['action'] ) && ! empty( $_GET['code'] ) ) {
504
+ if ( 'instagram-auth' === $_GET['action'] ) {
505
+ if ( check_admin_referer( 'instagram-auth', '_wpnonce' ) ) {
506
+ if ( current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
507
+ $redirect_uri = plugins_url() . '/sns-count-cache/?action=instagram-auth';
508
+ $code = sanitize_text_field( wp_unslash( $_GET['code'] ) );
509
+ $tmp_instagram_access_token = SCC_Oauth::get_instagram_access_token( $this->follow_instagram_client_id, $this->follow_instagram_client_secret, $redirect_uri, $code );
510
+ }
511
+ } // End if().
512
+ } elseif ( 'facebook-auth' === $_GET['action'] ) {
513
+ if ( check_admin_referer( 'facebook-auth', '_wpnonce' ) ) {
514
+ if ( current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
515
+ $redirect_uri = plugins_url() . '/sns-count-cache/?action=facebook-auth';
516
+ $code = sanitize_text_field( wp_unslash( $_GET['code'] ) );
517
+ $tmp_facebook_access_token = SCC_Oauth::get_facebook_access_token( $this->follow_facebook_app_id, $this->follow_facebook_app_secret, $redirect_uri, $code, $this->follow_facebook_page_id );
518
+ } else {
519
+ SCC_Logger::log( 'Invalid capability' );
520
  }
521
+ } else {
522
+ SCC_Logger::log( 'Invalid nonce' );
523
  }
524
+ } // End if().
525
+ } // End if().
526
  ?>
527
+ <div class="wrap">
528
+ <h2><a href="admin.php?page=scc-setting"><?php esc_html_e( 'SNS Count Cache', self::DOMAIN ); ?></a></h2>
529
+ <?php
530
+ $messages = get_transient( self::OPT_COMMON_ERROR_MESSAGE );
531
+
532
+ if ( $messages ) {
533
+ ?>
534
+ <div class="error">
535
+ <ul>
536
  <?php
537
+ foreach ( $messages as $message ) {
538
  ?>
539
+ <li><?php echo esc_html( $message ); ?></li>
 
 
 
 
 
 
 
 
 
 
540
  <?php
541
+ }
 
542
  ?>
543
+ </ul>
544
+ </div>
545
+ <?php
546
+ delete_transient( self::OPT_COMMON_ERROR_MESSAGE );
547
+ }
548
+ ?>
549
+ <?php
550
+ $status = SCC_WP_Cron::test_cron_spawn();
551
+
552
+ if ( is_wp_error( $status ) ) {
553
+ echo '<div class="notice notice-error"><p>';
554
+ esc_html_e( 'There was a problem spawning a call to the WP-Cron system on your site. This means WP-Cron jobs on your site may not work. The problem was: ', self::DOMAIN );
555
+ echo '<br><strong>' . esc_html( $status->get_error_message() ) . '</strong>';
556
+ echo '.</p></div>';
557
+ }
558
 
559
+ if ( ! empty( $this->share_base_cache_target[ self::REF_SHARE_FACEBOOK ] ) ) {
560
+ $configuration_check = $this->crawlers[ self::REF_SHARE ]->check_crawl_strategy_configurations( self::REF_SHARE_FACEBOOK );
561
 
562
+ if ( ! $configuration_check ) {
563
+ echo '<div class="notice notice-warning"><p>';
564
+ esc_html_e( 'Configuratin is not enough to get share count. Please set required parameters at ', self::DOMAIN );
565
+ echo '<a href="#share-base-cache-facebook">' . esc_html( __( 'Share Base Cache - Facebook', self::DOMAIN ) ) . '</a>';
566
  echo '.</p></div>';
567
  }
568
+ }
569
 
570
+ if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_INSTAGRAM ] ) ) {
571
+ $configuration_check = $this->crawlers[ self::REF_FOLLOW ]->check_crawl_strategy_configurations( self::REF_FOLLOW_INSTAGRAM );
572
 
573
+ if ( ! $configuration_check ) {
574
+ echo '<div class="notice notice-warning"><p>';
575
+ esc_html_e( 'Configuratin is not enough to get follower count. Please set required parameters at ', self::DOMAIN );
576
+ echo '<a href="#follow-base-cache-instagram">' . esc_html( __( 'Follow Base Cache - Instagram', self::DOMAIN ) ) . '</a>';
577
+ echo '.</p></div>';
 
578
  }
579
+ }
580
 
581
+ if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_FACEBOOK ] ) ) {
582
+ $configuration_check = $this->crawlers[ self::REF_FOLLOW ]->check_crawl_strategy_configurations( self::REF_FOLLOW_FACEBOOK );
583
 
584
+ if ( ! $configuration_check ) {
585
+ echo '<div class="notice notice-warning"><p>';
586
+ esc_html_e( 'Configuratin is not enough to get follower count. Please set required parameters at ', self::DOMAIN );
587
+ echo '<a href="#follow-base-cache-facebook">' . esc_html( __( 'Follow Base Cache - Facebook', self::DOMAIN ) ) . '</a>';
588
+ echo '.</p></div>';
 
589
  }
590
+ }
591
 
592
+ if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_PUSH7 ] ) ) {
593
+ $configuration_check = $this->crawlers[ self::REF_FOLLOW ]->check_crawl_strategy_configurations( self::REF_FOLLOW_PUSH7 );
594
 
595
+ if ( ! $configuration_check ) {
596
+ echo '<div class="notice notice-warning"><p>';
597
+ esc_html_e( 'Configuratin is not enough to get follower count. Please set required parameters at ', self::DOMAIN );
598
+ echo '<a href="#follow-base-cache-push7">' . esc_html( __( 'Follow Base Cache - Push7', self::DOMAIN ) ) . '</a>';
599
+ echo '.</p></div>';
 
600
  }
601
+ }
602
 
603
+ if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_TWITTER ] ) ) {
604
+ $configuration_check = $this->crawlers[ self::REF_FOLLOW ]->check_crawl_strategy_configurations( self::REF_FOLLOW_TWITTER );
605
 
606
+ if ( ! $configuration_check ) {
607
+ echo '<div class="notice notice-warning"><p>';
608
+ esc_html_e( 'Configuratin is not enough to get follower count. Please set required parameters at ', self::DOMAIN );
609
+ echo '<a href="#follow-base-cache-twitter">' . esc_html( __( 'Follow Base Cache - Twitter', self::DOMAIN ) ) . '</a>';
610
+ echo '.</p></div>';
 
611
  }
612
+ }
613
 
614
+ if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_ONESIGNAL ] ) ) {
615
+ $configuration_check = $this->crawlers[ self::REF_FOLLOW ]->check_crawl_strategy_configurations( self::REF_FOLLOW_ONESIGNAL );
616
 
617
+ if ( ! $configuration_check ) {
618
+ echo '<div class="notice notice-warning"><p>';
619
+ esc_html_e( 'Configuratin is not enough to get follower count. Please set required parameters at ', self::DOMAIN );
620
+ echo '<a href="#follow-base-cache-onesignal">' . esc_html( __( 'Follow Base Cache - OneSignal', self::DOMAIN ) ) . '</a>';
621
+ echo '.</p></div>';
 
622
  }
623
+ }
624
 
625
+ ?>
626
+
627
+ <div class="sns-cnt-cache">
628
+ <h3 class="nav-tab-wrapper">
629
+ <a class="nav-tab" href="admin.php?page=scc-dashboard"><?php esc_html_e( 'Dashboard', self::DOMAIN ); ?></a>
630
+ <a class="nav-tab" href="admin.php?page=scc-cache-status"><?php esc_html_e( 'Cache Status', self::DOMAIN ); ?></a>
631
+ <a class="nav-tab" href="admin.php?page=scc-share-count"><?php esc_html_e( 'Share Count', self::DOMAIN ); ?></a>
632
+ <?php if ( self::OPT_SHARE_VARIATION_ANALYSIS_NONE !== $this->share_variation_analysis_mode ) { ?>
633
+ <a class="nav-tab" href="admin.php?page=scc-hot-content"><?php esc_html_e( 'Hot Content', self::DOMAIN ); ?></a>
634
+ <?php } ?>
635
+ <a class="nav-tab nav-tab-active" href="admin.php?page=scc-setting"><?php esc_html_e( 'Setting', self::DOMAIN ); ?></a>
636
+ <a class="nav-tab" href="admin.php?page=scc-help"><?php esc_html_e( 'Help', self::DOMAIN ); ?></a>
637
+ </h3>
638
+ <p id="options-menu">
639
+ <a href="#current-parameter"><?php esc_html_e( 'Current Setting', self::DOMAIN ); ?></a> | <a href="#share-base-cache"><?php esc_html_e( 'Share Base Cache', self::DOMAIN ); ?></a> | <a href="#share-rush-cache"><?php esc_html_e( 'Share Rush Cache', self::DOMAIN ); ?></a> | <a href="#share-variation-analysis"><?php esc_html_e( 'Share Variation Analysis', self::DOMAIN ); ?></a> | <a href="#follow-base-cache"><?php esc_html_e( 'Follow Base Cache', self::DOMAIN ); ?></a> | <a href="#follow-variation-analysis"><?php esc_html_e( 'Follow Variation Analysis', self::DOMAIN ); ?></a> | <a href="#common-dynamic-cache"><?php esc_html_e( 'Dynamic Cache', self::DOMAIN ); ?></a> | <a href="#common-fault-tolerance"><?php esc_html_e( 'Fault Tolerance', self::DOMAIN ); ?></a> | <a href="#common-data-crawler"><?php esc_html_e( 'Data Crawler', self::DOMAIN ); ?></a> | <a href="#common-data-export"><?php esc_html_e( 'Data Export', self::DOMAIN ); ?></a> | <a href="#common-exported-file"><?php esc_html_e( 'Exported File', self::DOMAIN ); ?></a>
640
+ </p>
641
+ <div class="metabox-holder">
642
+ <div id="current-parameter" class="postbox">
643
+ <div class="handlediv" title="Click to toggle"><br></div>
644
+ <h3 class="hndle"><span><?php esc_html_e( 'Current Setting', self::DOMAIN ); ?></span></h3>
645
+ <div class="inside">
646
+ <table class="tfloat view-table">
647
+ <thead>
648
+ <tr>
649
+ <th><?php esc_html_e( 'Capability', self::DOMAIN ); ?></th>
650
+ <th><?php esc_html_e( 'Parameter', self::DOMAIN ); ?></th>
651
+ <th><?php esc_html_e( 'Value', self::DOMAIN ); ?></th>
652
+ </tr>
653
+ </thead>
654
+ <tbody>
655
+ <tr>
656
+ <td><?php esc_html_e( 'Share Base Cache', self::DOMAIN ); ?></td>
657
+ <td><?php esc_html_e( 'Target SNS', self::DOMAIN ); ?></td>
658
+ <td>
659
+ <?php
660
+ $target_sns = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
661
 
662
+ if ( ! empty( $this->share_base_cache_target[ self::REF_SHARE_FACEBOOK ] ) ) {
663
+ $target_sns[] = __( 'Facebook', self::DOMAIN );
664
+ }
665
+ if ( ! empty( $this->share_base_cache_target[ self::REF_SHARE_GPLUS ] ) ) {
666
+ $target_sns[] = __( 'Google+', self::DOMAIN );
667
+ }
668
+ if ( ! empty( $this->share_base_cache_target[ self::REF_SHARE_HATEBU ] ) ) {
669
+ $target_sns[] = __( 'Hatena Bookmark', self::DOMAIN );
670
+ }
671
+ if ( ! empty( $this->share_base_cache_target[ self::REF_SHARE_LINKEDIN ] ) ) {
672
+ $target_sns[] = __( 'Linkedin', self::DOMAIN );
673
+ }
674
+ if ( ! empty( $this->share_base_cache_target[ self::REF_SHARE_PINTEREST ] ) ) {
675
+ $target_sns[] = __( 'Pinterest', self::DOMAIN );
676
+ }
677
+ if ( ! empty( $this->share_base_cache_target[ self::REF_SHARE_POCKET ] ) ) {
678
+ $target_sns[] = __( 'Pocket', self::DOMAIN );
679
+ }
680
+ if ( ! empty( $this->share_base_cache_target[ self::REF_SHARE_TWITTER ] ) ) {
681
+ $target_sns[] = __( 'Twitter', self::DOMAIN );
682
+ }
683
+ echo esc_html( implode( ', ', $target_sns ) );
684
+ ?>
685
+ </td>
686
+ </tr>
687
+ <tr>
688
+ <td><?php esc_html_e( 'Share Base Cache', self::DOMAIN ); ?></td>
689
+ <td><?php esc_html_e( 'Custom post types', self::DOMAIN ); ?></td>
690
+ <td>
691
+ <?php
692
+ if ( ! empty( $this->share_base_custom_post_types ) ) {
693
+ echo esc_html( implode( ',', $this->share_base_custom_post_types ) );
694
+ } else {
695
+ esc_html_e( 'N/A', self::DOMAIN );
696
+ }
697
+ ?>
698
+ </td>
699
+ </tr>
700
+ <tr>
701
+ <td><?php esc_html_e( 'Share Base Cache', self::DOMAIN ); ?></td>
702
+ <td><?php esc_html_e( 'Interval cheking share count (sec)', self::DOMAIN ); ?></td>
703
+ <td><?php echo esc_html( $this->share_base_check_interval ) . ' ' . esc_html( __( 'seconds', self::DOMAIN ) ); ?></td>
704
+ </tr>
705
+ <tr>
706
+ <td><?php esc_html_e( 'Share Base Cache', self::DOMAIN ); ?></td>
707
+ <td><?php esc_html_e( 'Number of contents to check at a time', self::DOMAIN ) ?></td>
708
+ <td><?php echo esc_html( $this->share_base_posts_per_check ) . ' ' . esc_html( __( 'contents', self::DOMAIN ) ); ?></td>
709
+ </tr>
710
+ <tr>
711
+ <td><?php esc_html_e( 'Share Base Cache', self::DOMAIN ); ?></td>
712
+ <td><?php esc_html_e( 'Scheme migration mode from http to https', self::DOMAIN ); ?></td>
713
+ <td>
714
+ <?php
715
+ if ( $this->scheme_migration_mode ) {
716
+ esc_html_e( 'On', self::DOMAIN );
717
+ } else {
718
+ esc_html_e( 'Off', self::DOMAIN );
719
+ }
720
+ ?>
721
+ </td>
722
+ </tr>
723
+ <?php if ( $this->scheme_migration_mode ) { ?>
724
+ <tr>
725
+ <td><?php esc_html_e( 'Share Base Cache', self::DOMAIN ); ?></td>
726
+ <td><?php esc_html_e( 'Scheme migration date from http to https', self::DOMAIN ); ?></td>
727
+ <td>
728
+ <?php
729
+ if ( isset( $this->scheme_migration_date ) ) {
730
+ echo esc_html( $this->scheme_migration_date );
731
+ } else {
732
+ esc_html_e( 'N/A', self::DOMAIN );
733
+ }
734
+ ?>
735
+ </td>
736
+ </tr>
737
+ <?php } ?>
738
+ <?php if ( isset( $this->share_base_cache_target[ self::REF_SHARE_TWITTER ] ) && $this->share_base_cache_target[ self::REF_SHARE_TWITTER ] ) { ?>
739
+ <tr>
740
+ <td><?php esc_html_e( 'Share Base Cache - Twitter', self::DOMAIN ); ?></td>
741
+ <td><?php esc_html_e( 'Alternative Twitter API', self::DOMAIN ); ?></td>
742
+ <td>
743
+ <?php
744
+ if ( self::OPT_SHARE_TWITTER_API_JSOON === $this->share_base_twitter_api ) {
745
+ echo '<a href="' . esc_url( 'https://jsoon.digitiminimi.com/' ) . '" target="_blank">' . esc_html( 'widgetoon.js & count.jsoon' ) . '</a>';
746
+ } elseif ( self::OPT_SHARE_TWITTER_API_OPENSHARECOUNT === $this->share_base_twitter_api ) {
747
+ echo '<a href="' . esc_url( 'https://opensharecount.com/' ) . '" target="_blank">' . esc_html( 'OpenShareCount' ) . '</a>';
748
+ } elseif ( self::OPT_SHARE_TWITTER_API_TWITCOUNT === $this->share_base_twitter_api ) {
749
+ echo '<a href="' . esc_url( 'http://twitcount.com/' ) . '" target="_blank">' . esc_html( 'TwitCount' ) . '</a>';
750
+ } elseif ( self::OPT_SHARE_TWITTER_API_NEWSHARECOUNTS === $this->share_base_twitter_api ) {
751
+ echo '<a href="' . esc_url( 'http://newsharecounts.com/' ) . '" target="_blank">' . esc_html( 'NewShareCounts' ) . '</a>';
752
+ }
753
+ ?>
754
+ </td>
755
+ </tr>
756
+ <?php } ?>
757
+ <tr>
758
+ <td><?php esc_html_e( 'Share Rush Cache', self::DOMAIN ); ?></td>
759
+ <td><?php esc_html_e( 'Term considering posted content as new content', self::DOMAIN ); ?></td>
760
+ <td>
761
+ <?php
762
+ if ( 1 == $this->share_rush_new_content_term ) {
763
+ echo esc_html( $this->share_rush_new_content_term ) . ' ' . esc_html( __( 'day', self::DOMAIN ) );
764
+ } elseif ( 1 < $this->share_rush_new_content_term ) {
765
+ echo esc_html( $this->share_rush_new_content_term ) . ' ' . esc_html( __( 'days', self::DOMAIN ) );
766
+ }
767
+ ?>
768
+ </td>
769
+ </tr>
770
+ <tr>
771
+ <td><?php esc_html_e( 'Share Rush Cache', self::DOMAIN ); ?></td>
772
+ <td><?php esc_html_e( 'Interval cheking share count (sec)', self::DOMAIN ); ?></td>
773
+ <td>
774
+ <?php
775
+ echo esc_html( $this->share_rush_check_interval ) . ' ' . esc_html( __( 'seconds', self::DOMAIN ) );
776
+ ?>
777
+ </td>
778
+ <tr>
779
+ <td><?php esc_html_e( 'Share Rush Cache', self::DOMAIN ); ?></td>
780
+ <td><?php esc_html_e( 'Number of contents to check at a time', self::DOMAIN ) ?></td>
781
+ <td><?php echo esc_html( $this->share_rush_posts_per_check ) . ' ' . esc_html( __( 'contents', self::DOMAIN ) ); ?></td>
782
+ </tr>
783
+ </tr>
784
+ <tr>
785
+ <td><?php esc_html_e( 'Share Variation Analysis', self::DOMAIN ); ?></td>
786
+ <td><?php esc_html_e( 'Method to update basis of comparison', self::DOMAIN ); ?></td><td>
787
+ <?php
788
+ switch ( $this->share_variation_analysis_mode ) {
789
+ case self::OPT_SHARE_VARIATION_ANALYSIS_NONE:
790
+ esc_html_e( 'Disabled (None)', self::DOMAIN );
791
+ break;
792
+ case self::OPT_SHARE_VARIATION_ANALYSIS_MANUAL:
793
+ esc_html_e( 'Enabled (Manual)', self::DOMAIN );
794
+ break;
795
+ case self::OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER:
796
+ esc_html_e( 'Enabled (Scheduler)', self::DOMAIN );
797
+ break;
798
+ default:
799
+ esc_html_e( 'Disabled (None)', self::DOMAIN );
800
+ }
801
+ ?>
802
+ </td>
803
+ </tr>
804
+ <?php
805
+ if ( self::OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER === $this->share_variation_analysis_mode ) {
806
+ ?>
807
+ <tr>
808
+ <td><?php esc_html_e( 'Share Variation Analysis', self::DOMAIN ); ?></td>
809
+ <td><?php esc_html_e( 'Schedule', self::DOMAIN ); ?></td>
810
+ <td><?php echo esc_html( $this->share_variation_analysis_schedule ); ?></td>
811
+ </tr>
812
+ <?php
813
+ }
814
+ ?>
815
+ <tr>
816
+ <td><?php esc_html_e( 'Follow Base Cache', self::DOMAIN ); ?></td>
817
+ <td><?php esc_html_e( 'Target SNS', self::DOMAIN ); ?></td>
818
+ <td>
819
  <?php
820
+ $target_sns = array();
821
+ if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_FACEBOOK ] ) ) {
822
+ $target_sns[] = 'Facebook';
823
+ }
824
+ if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_FEEDLY ] ) ) {
825
+ $target_sns[] = 'Feedly';
826
+ }
827
+ if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_INSTAGRAM ] ) ) {
828
+ $target_sns[] = 'Instagram';
829
+ }
830
+ if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_ONESIGNAL ] ) ) {
831
+ $target_sns[] = 'OneSignal';
832
+ }
833
+ if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_PUSH7 ] ) ) {
834
+ $target_sns[] = 'Push7';
835
+ }
836
+ if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_TWITTER ] ) ) {
837
+ $target_sns[] = 'Twitter';
838
  }
839
+ echo esc_html( implode( ', ', $target_sns ) );
840
  ?>
841
+ </td>
842
+ </tr>
843
+ <tr>
844
+ <td><?php esc_html_e( 'Follow Base Cache', self::DOMAIN ); ?></td>
845
+ <td><?php esc_html_e( 'Interval cheking follower count (sec)', self::DOMAIN ); ?></td>
846
+ <td><?php echo esc_html( $this->follow_base_check_interval ) . ' ' . esc_html( __( 'seconds', self::DOMAIN ) ); ?></td>
847
+ </tr>
848
+ <?php if ( $this->follow_base_cache_target[ self::REF_FOLLOW_FEEDLY ] ) { ?>
849
+ <tr>
850
+ <td><?php esc_html_e( 'Follow Base Cache - Feedly', self::DOMAIN ); ?></td>
851
+ <td><?php esc_html_e( 'Target feed type', self::DOMAIN ); ?></td>
852
+ <td>
853
+ <?php
854
+ switch ( $this->follow_feed_type ) {
855
+ case self::OPT_FEED_TYPE_DEFAULT:
856
+ esc_html_e( 'Default', self::DOMAIN );
857
+ break;
858
+ case self::OPT_FEED_TYPE_RSS:
859
+ esc_html_e( 'RSS', self::DOMAIN );
860
+ break;
861
+ case self::OPT_FEED_TYPE_RSS2:
862
+ esc_html_e( 'RSS2', self::DOMAIN );
863
+ break;
864
+ case self::OPT_FEED_TYPE_RDF:
865
+ esc_html_e( 'RDF', self::DOMAIN );
866
+ break;
867
+ case self::OPT_FEED_TYPE_ATOM:
868
+ esc_html_e( 'ATOM', self::DOMAIN );
869
+ break;
870
+ default:
871
+ esc_html_e( 'Default', self::DOMAIN );
872
+ }
873
+ ?>
874
+ </td>
875
+ </tr>
876
+ <tr>
877
+ <td><?php esc_html_e( 'Follow Base Cache - Feedly', self::DOMAIN ); ?></td>
878
+ <td><?php esc_html_e( 'Target feed', self::DOMAIN ); ?></td>
879
+ <td><a href="<?php echo esc_url( get_feed_link( $this->follow_feed_type ) ); ?>" target="_blank"><?php echo esc_html( get_feed_link( $this->follow_feed_type ) ); ?></a></td>
880
+ </tr>
881
+ <?php } ?>
882
+ <?php if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_TWITTER ] ) ) { ?>
883
+ <tr>
884
+ <td><?php esc_html_e( 'Follow Base Cache - Twitter', self::DOMAIN ); ?></td>
885
+ <td><?php esc_html_e( 'Target screen name', self::DOMAIN ); ?></td>
886
+ <td>
887
+ <?php
888
+ if ( ! empty( $this->follow_twitter_screen_name ) ) {
889
+ echo '@' . esc_html( $this->follow_twitter_screen_name );
890
+ } else {
891
+ esc_html_e( 'N/A', self::DOMAIN );
892
+ }
893
+ ?>
894
+ </td>
895
+ </tr>
896
+ <?php } ?>
897
+ <?php if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_FACEBOOK ] ) ) { ?>
898
+ <tr>
899
+ <td><?php esc_html_e( 'Follow Base Cache - Facebook', self::DOMAIN ); ?></td>
900
+ <td><?php esc_html_e( 'Page ID', self::DOMAIN ); ?></td>
901
+ <td>
902
+ <?php
903
+ if ( isset( $this->follow_facebook_page_id ) ) {
904
+ echo esc_html( $this->follow_facebook_page_id );
905
+ } else {
906
+ esc_html_e( 'N/A', self::DOMAIN );
907
+ }
908
+ ?>
909
+ </td>
910
+ </tr>
911
+ <?php } ?>
912
+ <tr>
913
+ <td><?php esc_html_e( 'Follow Variation Analysis', self::DOMAIN ); ?></td>
914
+ <td><?php esc_html_e( 'Method to update basis of comparison', self::DOMAIN ); ?></td><td>
915
+ <?php
916
+ switch ( $this->follow_variation_analysis_mode ) {
917
+ case self::OPT_FOLLOW_VARIATION_ANALYSIS_NONE:
918
+ esc_html_e( 'Disabled (None)', self::DOMAIN );
919
+ break;
920
+ case self::OPT_FOLLOW_VARIATION_ANALYSIS_MANUAL:
921
+ esc_html_e( 'Enabled (Manual)', self::DOMAIN );
922
+ break;
923
+ case self::OPT_FOLLOW_VARIATION_ANALYSIS_SCHEDULER:
924
+ esc_html_e( 'Enabled (Scheduler)', self::DOMAIN );
925
+ break;
926
+ default:
927
+ esc_html_e( 'Disabled (None)', self::DOMAIN );
928
+ break;
929
  }
930
+ ?>
931
+ </td>
932
+ </tr>
933
+ <?php
934
+ if ( self::OPT_FOLLOW_VARIATION_ANALYSIS_SCHEDULER === $this->follow_variation_analysis_mode ) {
935
+ ?>
936
+ <tr>
937
+ <td><?php esc_html_e( 'Follow Variation Analysis', self::DOMAIN ); ?></td>
938
+ <td><?php esc_html_e( 'Schedule', self::DOMAIN ); ?></td>
939
+ <td><?php echo esc_html( $this->follow_variation_analysis_schedule ); ?></td>
940
+ </tr>
941
+ <?php
942
+ }
943
+ ?>
944
+ <tr>
945
+ <td><?php esc_html_e( 'Dynamic Cache', self::DOMAIN); ?></td>
946
+ <td><?php esc_html_e( 'Dynamic caching based on user access', self::DOMAIN ); ?></td><td>
947
+ <?php
948
+ switch ( $this->dynamic_cache_mode ) {
949
+ case self::OPT_COMMON_ACCESS_BASED_CACHE_OFF:
950
+ esc_html_e( 'Disabled', self::DOMAIN );
951
+ break;
952
+ case self::OPT_COMMON_ACCESS_BASED_CACHE_ON:
953
+ esc_html_e( 'Enabled', self::DOMAIN );
954
+ break;
955
+ default:
956
+ esc_html_e( 'Disabled', self::DOMAIN );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
957
  }
958
+ ?>
959
+ </td>
960
+ </tr>
961
+ <tr>
962
+ <td><?php esc_html_e( 'Fault Tolerance', self::DOMAIN ); ?></td>
963
+ <td><?php esc_html_e( 'Fault tolerance of count retrieval', self::DOMAIN ); ?></td><td>
964
+ <?php
965
+ switch ( $this->fault_tolerance_mode ) {
966
+ case self::OPT_COMMON_FAULT_TOLERANCE_OFF:
967
+ esc_html_e( 'Disabled', self::DOMAIN );
968
+ break;
969
+ case self::OPT_COMMON_FAULT_TOLERANCE_ON:
970
+ esc_html_e( 'Enabled', self::DOMAIN );
971
+ break;
972
+ default:
973
+ esc_html_e( 'Disabled', self::DOMAIN );
974
+ }
975
+ ?>
976
+ </td>
977
+ </tr>
978
+ <tr>
979
+ <td><?php esc_html_e( 'Data Crawler', self::DOMAIN ); ?></td>
980
+ <td><?php esc_html_e( 'Crawl method', self::DOMAIN ); ?></td>
981
+ <td>
982
+ <?php
983
+ switch ( $this->crawler_method ) {
984
+ case self::OPT_COMMON_CRAWLER_METHOD_NORMAL:
985
+ esc_html_e( 'Normal (Sequential Retrieval)', self::DOMAIN );
986
+ break;
987
+ case self::OPT_COMMON_CRAWLER_METHOD_CURL:
988
+ esc_html_e( 'Extended (Parallel Retrieval)', self::DOMAIN );
989
+ break;
990
+ }
991
+ ?>
992
+ </td>
993
+ </tr>
994
+ <tr>
995
+ <td><?php esc_html_e( 'Data Crawler', self::DOMAIN ); ?></td>
996
+ <td><?php esc_html_e( 'Crawl retry limit', self::DOMAIN ); ?></td>
997
+ <td>
998
+ <?php
999
+ switch ( $this->crawler_retry_limit ) {
1000
+ case -1:
1001
+ esc_html_e( 'no retry', self::DOMAIN );
1002
+ break;
1003
+ case 1:
1004
+ esc_html_e( '1 time', self::DOMAIN );
1005
+ break;
1006
+ case 2:
1007
+ esc_html_e( '2 times', self::DOMAIN );
1008
+ break;
1009
+ case 3:
1010
+ esc_html_e( '3 times', self::DOMAIN );
1011
+ break;
1012
+ case 4:
1013
+ esc_html_e( '2 times', self::DOMAIN );
1014
+ break;
1015
+ case 5:
1016
+ esc_html_e( '5 times', self::DOMAIN );
1017
+ break;
1018
+ }
1019
+ ?>
1020
+ </td>
1021
+ </tr>
1022
+ <tr>
1023
+ <td><?php esc_html_e( 'Data Crawler', self::DOMAIN ); ?></td>
1024
+ <td><?php esc_html_e( 'SSL verification', self::DOMAIN ); ?></td>
1025
+ <td>
1026
+ <?php
1027
+ if ( $this->crawler_ssl_verification ) {
1028
+ esc_html_e( 'On', self::DOMAIN );
1029
+ } else {
1030
+ esc_html_e( 'Off', self::DOMAIN );
1031
+ }
1032
+ ?>
1033
+ </td>
1034
+ </tr>
1035
+ <tr>
1036
+ <td><?php esc_html_e( 'Data Export', self::DOMAIN ); ?></td>
1037
+ <td><?php esc_html_e( 'Method of data export', self::DOMAIN ); ?></td><td>
1038
+ <?php
1039
+ switch ( $this->data_export_mode ) {
1040
+ case self::OPT_COMMON_DATA_EXPORT_MANUAL:
1041
+ esc_html_e( 'Manual', self::DOMAIN );
1042
+ break;
1043
+ case self::OPT_COMMON_DATA_EXPORT_SCHEDULER:
1044
+ esc_html_e( 'Scheduler', self::DOMAIN );
1045
+ break;
1046
+ }
1047
+ ?>
1048
+ </td>
1049
+ </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1050
  <?php
1051
+ if ( self::OPT_COMMON_DATA_EXPORT_SCHEDULER === $this->data_export_mode ) {
1052
  ?>
1053
+ <tr>
1054
+ <td><?php esc_html_e( 'Data Export', self::DOMAIN ); ?></td>
1055
+ <td><?php esc_html_e( 'Interval exporting share count to a csv file', self::DOMAIN ); ?></td>
1056
+ <td><?php echo esc_html( $this->data_export_interval / 3600 ) . ' ' . esc_html( __( 'hours', self::DOMAIN ) ); ?></td>
1057
+ </tr>
1058
  <?php
1059
+ }
1060
  ?>
1061
+ </tbody>
1062
+ </table>
1063
+ </div>
1064
+ </div>
1065
+ </div>
1066
+ <div class="metabox-holder">
1067
+ <form action="admin.php?page=scc-setting" method="post">
1068
+ <?php wp_nonce_field( __FILE__, '_wpnonce' ); ?>
1069
+ <div id="share-base-cache" class="postbox">
1070
+ <div class="handlediv" title="Click to toggle"><br></div>
1071
+ <h3 class="hndle"><span><?php esc_html_e('Share Base Cache', self::DOMAIN ); ?></span></h3>
1072
+ <div class="inside">
1073
+ <table class="form-table">
1074
+ <tr>
1075
+ <th><label><?php esc_html_e( 'Target SNS', self::DOMAIN ); ?></label></th>
1076
+ <td>
1077
+ <div class="sns-check">
1078
+ <input type="checkbox" value="1" id="share_base_cache_target_facebook" name="share_base_cache_target_facebook"<?php if ( ! empty( $this->share_base_cache_target[ self::REF_SHARE_FACEBOOK ] ) ) echo ' checked="checked"'; ?> />
1079
+ <label for="share_base_cache_target_facebook"><?php esc_html_e( 'Facebook', self::DOMAIN ); ?></label>
1080
+ </div>
1081
+ <div class="sns-check">
1082
+ <input type="checkbox" value="1" id="share_base_cache_target_hatebu" name="share_base_cache_target_hatebu"<?php if ( ! empty( $this->share_base_cache_target[ self::REF_SHARE_HATEBU ] ) ) echo ' checked="checked"'; ?> />
1083
+ <label for="share_base_cache_target_hatebu"><?php esc_html_e( 'Hatena Bookmark', self::DOMAIN ); ?></label>
1084
+ </div>
1085
+ <div class="sns-check">
1086
+ <input type="checkbox" value="1" id="share_base_cache_target_linkedin" name="share_base_cache_target_linkedin"<?php if ( ! empty( $this->share_base_cache_target[ self::REF_SHARE_LINKEDIN ] ) ) echo ' checked="checked"'; ?> />
1087
+ <label for="share_base_cache_target_linkedin"><?php esc_html_e( 'Linkedin', self::DOMAIN ); ?></label>
1088
+ </div>
1089
+ <div class="sns-check">
1090
+ <input type="checkbox" value="1" id="share_base_cache_target_pinterest" name="share_base_cache_target_pinterest"<?php if ( ! empty( $this->share_base_cache_target[ self::REF_SHARE_PINTEREST ] ) ) echo ' checked="checked"'; ?> />
1091
+ <label for="share_base_cache_target_pinterest"><?php esc_html_e( 'Pinterest', self::DOMAIN ); ?></label>
1092
+ </div>
1093
+ <div class="sns-check">
1094
+ <input type="checkbox" value="1" id="share_base_cache_target_pocket" name="share_base_cache_target_pocket"<?php if ( ! empty( $this->share_base_cache_target[ self::REF_SHARE_POCKET ] ) ) echo ' checked="checked"'; ?> />
1095
+ <label for="share_base_cache_target_pocket"><?php esc_html_e( 'Pocket', self::DOMAIN ); ?></label>
1096
+ </div>
1097
+ <div class="sns-check">
1098
+ <input type="checkbox" value="1" id="share_base_cache_target_twitter" name="share_base_cache_target_twitter"<?php if ( ! empty( $this->share_base_cache_target[ self::REF_SHARE_TWITTER ] ) ) echo ' checked="checked"'; ?> />
1099
+ <label for="share_base_cache_target_twitter"><?php esc_html_e( 'Twitter', self::DOMAIN ); ?></label>
1100
+ </div>
1101
+ </td>
1102
+ </tr>
1103
+ <tr>
1104
+ <th><label for="share_base_custom_post_types"><?php esc_html_e( 'Custom post types', self::DOMAIN ); ?></label></th>
1105
+ <td>
1106
+ <input type="text" class="text" id="share_base_custom_post_types" name="share_base_custom_post_types" size="60" value="<?php echo esc_attr( implode( ',', $this->share_base_custom_post_types ) ); ?>" />
1107
+ <br>
1108
+ <span class="description"><?php esc_html_e( 'e.g. aaa, bbb, ccc (comma-delimited)', self::DOMAIN ); ?></span>
1109
+ </td>
1110
+ </tr>
1111
+ <tr>
1112
+ <th><label for="share_base_check_interval"><?php esc_html_e( 'Interval cheking share count (sec)', self::DOMAIN ); ?></label></th>
1113
+ <td>
1114
+ <input type="text" class="text" id="share_base_check_interval" name="share_base_check_interval" size="20" value="<?php echo esc_attr( $this->share_base_check_interval ); ?>" />
1115
+ <span class="description"><?php esc_html_e( 'Default: 900', self::DOMAIN ); ?></span>
1116
+ </td>
1117
+ </tr>
1118
+ <tr>
1119
+ <th><label for="share_base_posts_per_check"><?php esc_html_e( 'Number of contents to check at a time', self::DOMAIN ); ?></label></th>
1120
+ <td>
1121
+ <input type="text" class="text" id="share_base_posts_per_check" name="share_base_posts_per_check" size="20" value="<?php echo esc_attr( $this->share_base_posts_per_check ); ?>" />
1122
+ <span class="description"><?php esc_html_e( 'Default: 15', self::DOMAIN ); ?></span>
1123
+ </td>
1124
+ </tr>
1125
+ <tr>
1126
+ <th><label for="scheme_migration_mode"><?php esc_html_e( 'Scheme migration mode from http to https', self::DOMAIN ); ?></label></th>
1127
+ <td>
1128
+ <select id="scheme_migration_mode" name="scheme_migration_mode">
1129
+ <option value="0"<?php if ( self::OPT_COMMON_SCHEME_MIGRATION_MODE_OFF === $this->scheme_migration_mode ) echo ' selected="selected"'; ?>><?php esc_html_e( 'Off', self::DOMAIN ); ?></option>
1130
+ <option value="1"<?php if ( self::OPT_COMMON_SCHEME_MIGRATION_MODE_ON === $this->scheme_migration_mode ) echo ' selected="selected"'; ?>><?php esc_html_e( 'On', self::DOMAIN ); ?></option>
1131
+ </select>
1132
+ <span class="description"><?php esc_html_e( 'Default: Off', self::DOMAIN ); ?></span>
1133
+ </td>
1134
+ </tr>
1135
+ <?php if ( $this->scheme_migration_mode ) { ?>
1136
+ <tr>
1137
+ <th><label for="scheme-migration-date"><?php esc_html_e( 'Scheme migration date from http to https', self::DOMAIN ); ?></label></th>
1138
+ <td>
1139
+ <input id="scheme-migration-date" type="text" class="text" name="scheme_migration_date" size="20" value="<?php echo esc_attr( $this->scheme_migration_date ); ?>" />
1140
+ <span class="description"><?php esc_html_e( 'Default: N/A', self::DOMAIN ); ?></span>
1141
+ <script>
1142
+ jQuery(document).ready(function() {
1143
+ jQuery('#scheme-migration-date').datepicker({
1144
+ dateFormat : 'yy/mm/dd'
1145
+ });
1146
+ });
1147
+ </script>
1148
+ </td>
1149
+ </tr>
1150
+ <?php } ?>
1151
  </table>
1152
+ <div class="submit-button">
1153
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php esc_html_e( 'Update All Options', self::DOMAIN ); ?>" />
1154
+ <input type="submit" class="button button-secondary" name="clear_share_base_cache" value="<?php esc_html_e( 'Clear Cache', self::DOMAIN ); ?>">
1155
+ </div>
1156
  </div>
1157
  </div>
1158
+ <?php if ( ! empty( $this->share_base_cache_target[ self::REF_SHARE_FACEBOOK ] ) ) { ?>
1159
+ <div id="share-base-cache-facebook" class="postbox">
1160
+ <div class="handlediv" title="Click to toggle"><br></div>
1161
+ <h3 class="hndle"><span><?php esc_html_e( 'Share Base Cache - Facebook', self::DOMAIN ); ?></span></h3>
1162
+ <div class="inside">
1163
+ <table class="form-table">
1164
+ <tr>
1165
+ <th><label><?php esc_html_e( 'Developer page', self::DOMAIN ); ?></label></th>
1166
+ <td>
1167
+ <a href="https://developers.facebook.com/apps/" target="_blank">https://developers.facebook.com/apps/</a>
1168
+ <br>
1169
+ <span class="description"><?php esc_html_e( 'Register a application in Facebook developer page to get the following App ID and App Secret.', self::DOMAIN ); ?></span>
1170
+ </td>
1171
+ </tr>
1172
+ <tr>
1173
+ <th><label for="share_facebook_app_id"><?php esc_html_e( 'App ID', self::DOMAIN ); ?></label></th>
1174
+ <td>
1175
+ <input type="password" id="share_facebook_app_id" class="text" name="share_facebook_app_id" size="60" value="<?php echo esc_attr( $this->share_facebook_app_id ); ?>" />
1176
+ <br>
1177
+ <span class="description"><?php esc_html_e( 'App ID for Facebook API', self::DOMAIN ); ?></span>
1178
+ </td>
1179
+ </tr>
1180
+ <tr>
1181
+ <th><label for="share_facebook_app_secret"><?php esc_html_e( 'App Secret', self::DOMAIN ); ?></label></th>
1182
+ <td>
1183
+ <input type="password" id="share_facebook_app_secret" class="text" name="share_facebook_app_secret" size="60" value="<?php echo esc_attr( $this->share_facebook_app_secret ); ?>" />
1184
+ <br>
1185
+ <span class="description"><?php esc_html_e( 'App Secret for Facebook API', self::DOMAIN ); ?></span>
1186
+ </td>
1187
+ </tr>
1188
+ <?php if ( ! empty( $this->share_facebook_app_id ) && ! empty( $this->share_facebook_app_secret ) ) { ?>
1189
+ <tr>
1190
+ <th><label for="tmp_share_facebook_access_token"><?php esc_html_e( 'Access Token', self::DOMAIN ); ?></label></th>
1191
+ <td>
1192
+ <input type="password" id="tmp_share_facebook_access_token" class="text" name="tmp_share_facebook_access_token" size="60" value="<?php echo esc_attr( $this->share_facebook_access_token ); ?>" readonly />
 
 
 
 
 
 
 
 
 
 
 
1193
  <br>
1194
+ <span class="description"><?php esc_html_e( 'Access Token for Facebook API', self::DOMAIN ); ?></span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1195
  </td>
1196
  </tr>
1197
  <?php } ?>
1198
+ </table>
1199
+ <div class="submit-button">
1200
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php esc_html_e( 'Update All Options', self::DOMAIN ); ?>" />
 
 
1201
  </div>
1202
  </div>
1203
+ </div>
1204
+ <?php } // End if(). ?>
1205
+ <?php if ( ! empty( $this->share_base_cache_target[ self::REF_SHARE_TWITTER ] ) ) { ?>
1206
+ <div id="share-base-cache-twitter" class="postbox">
1207
+ <div class="handlediv" title="Click to toggle"><br></div>
1208
+ <h3 class="hndle"><span><?php esc_html_e( 'Share Base Cache - Twitter', self::DOMAIN ); ?></span></h3>
1209
+ <div class="inside">
1210
+ <table class="form-table">
1211
+ <tr>
1212
+ <th><label for="share_alternative_twitter_api"><?php esc_html_e( 'Alternative Twitter API', self::DOMAIN ); ?></label></th>
1213
+ <td>
1214
+ <select id="share_alternative_twitter_api" name="share_alternative_twitter_api">
1215
+ <option value="1"<?php if ( self::OPT_SHARE_TWITTER_API_JSOON === $this->share_base_twitter_api ) echo ' selected="selected"'; ?>><?php echo esc_html( 'widgetoon.js & count.jsoon' ); ?></option>
1216
+ <option value="2"<?php if ( self::OPT_SHARE_TWITTER_API_OPENSHARECOUNT === $this->share_base_twitter_api ) echo ' selected="selected"'; ?>><?php echo esc_html( 'OpenShareCount' ); ?></option>
1217
+ <option value="3"<?php if ( self::OPT_SHARE_TWITTER_API_TWITCOUNT === $this->share_base_twitter_api ) echo ' selected="selected"'; ?>><?php echo esc_html( 'TwitCount' ); ?></option>
1218
+ <option value="4"<?php if ( self::OPT_SHARE_TWITTER_API_NEWSHARECOUNTS === $this->share_base_twitter_api ) echo ' selected="selected"'; ?>><?php echo esc_html( 'NewShareCounts' ); ?></option>
1219
+ </select>
1220
+ <span class="description"><?php esc_html_e( 'Default: widgetoon.js & count.jsoon' ); ?></span>
1221
+ </td>
1222
+ </tr>
1223
+ <tr>
1224
+ <th><label><?php esc_html_e( 'Registration destination', self::DOMAIN ); ?></label></th>
1225
+ <td>
1226
+ <?php
1227
+ if ( self::OPT_SHARE_TWITTER_API_JSOON === $this->share_base_twitter_api ) {
1228
+ echo '<a href="' . esc_url( 'https://jsoon.digitiminimi.com/' ) . '" target="_blank">' . esc_html( 'https://jsoon.digitiminimi.com/' ) . '</a>';
1229
+ } elseif ( self::OPT_SHARE_TWITTER_API_OPENSHARECOUNT === $this->share_base_twitter_api ) {
1230
+ echo '<a href="' . esc_url( 'https://opensharecount.com/' ) . '" target="_blank">' . esc_html( 'https://opensharecount.com/' ) . '</a>';
1231
+ } elseif ( self::OPT_SHARE_TWITTER_API_TWITCOUNT === $this->share_base_twitter_api ) {
1232
+ echo '<a href="' . esc_url( 'http://twitcount.com/' ) . '" target="_blank">' . esc_html( 'http://twitcount.com/' ) . '</a>';
1233
+ } elseif ( self::OPT_SHARE_TWITTER_API_NEWSHARECOUNTS === $this->share_base_twitter_api ) {
1234
+ echo '<a href="' . esc_url( 'http://newsharecounts.com/' ) . '" target="_blank">' . esc_html( 'http://newsharecounts.com/' ) . '</a>';
1235
+ }
1236
+ ?>
1237
+ <br />
1238
+ <span class="description"><?php esc_html_e( 'You need to register information such as your domain with the above site in order to start counting.', self::DOMAIN ); ?></span>
1239
+ </td>
1240
+ </tr>
1241
+ </table>
1242
+ <div class="submit-button">
1243
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php esc_html_e( 'Update All Options', self::DOMAIN ); ?>" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1244
  </div>
1245
  </div>
1246
+ </div>
1247
+ <?php } // End if(). ?>
1248
+ <div id="share-rush-cache" class="postbox">
1249
+ <div class="handlediv" title="Click to toggle"><br></div>
1250
+ <h3 class="hndle"><span><?php esc_html_e( 'Share Rush Cache', self::DOMAIN ); ?></span></h3>
1251
+ <div class="inside">
1252
+ <table class="form-table">
1253
+ <tr>
1254
+ <th><label for="share_rush_new_content_term"><?php esc_html_e( 'Term considering posted content as new content', self::DOMAIN ); ?></label></th>
1255
+ <td>
1256
+ <select id="share_rush_new_content_term" name="share_rush_new_content_term">
1257
+ <option value="1"<?php if ( 1 === $this->share_rush_new_content_term ) echo ' selected="selected"'; ?>><?php esc_html_e( '1 day', self::DOMAIN ); ?></option>
1258
+ <option value="2"<?php if ( 2 === $this->share_rush_new_content_term ) echo ' selected="selected"'; ?>><?php esc_html_e( '2 days', self::DOMAIN ); ?></option>
1259
+ <option value="3"<?php if ( 3 === $this->share_rush_new_content_term ) echo ' selected="selected"'; ?>><?php esc_html_e( '3 days', self::DOMAIN ); ?></option>
1260
+ <option value="4"<?php if ( 4 === $this->share_rush_new_content_term ) echo ' selected="selected"'; ?>><?php esc_html_e( '4 days', self::DOMAIN ); ?></option>
1261
+ <option value="5"<?php if ( 5 === $this->share_rush_new_content_term ) echo ' selected="selected"'; ?>><?php esc_html_e( '5 days', self::DOMAIN ); ?></option>
1262
+ <option value="6"<?php if ( 6 === $this->share_rush_new_content_term ) echo ' selected="selected"'; ?>><?php esc_html_e( '6 days', self::DOMAIN ); ?></option>
1263
+ <option value="7"<?php if ( 7 === $this->share_rush_new_content_term ) echo ' selected="selected"'; ?>><?php esc_html_e( '7 days', self::DOMAIN ); ?></option>
1264
+ <option value="8"<?php if ( 8 === $this->share_rush_new_content_term ) echo ' selected="selected"'; ?>><?php esc_html_e( '8 days', self::DOMAIN ); ?></option>
1265
+ <option value="9"<?php if ( 9 === $this->share_rush_new_content_term ) echo ' selected="selected"'; ?>><?php esc_html_e( '9 days', self::DOMAIN ); ?></option>
1266
+ <option value="10"<?php if ( 10 === $this->share_rush_new_content_term ) echo ' selected="selected"'; ?>><?php esc_html_e( '10 days', self::DOMAIN ); ?></option>
1267
+ <option value="11"<?php if ( 11 === $this->share_rush_new_content_term ) echo ' selected="selected"'; ?>><?php esc_html_e( '11 days', self::DOMAIN ); ?></option>
1268
+ <option value="12"<?php if ( 12 === $this->share_rush_new_content_term ) echo ' selected="selected"'; ?>><?php esc_html_e( '12 days', self::DOMAIN ); ?></option>
1269
+ <option value="13"<?php if ( 13 === $this->share_rush_new_content_term ) echo ' selected="selected"'; ?>><?php esc_html_e( '13 days', self::DOMAIN ); ?></option>
1270
+ <option value="14"<?php if ( 14 === $this->share_rush_new_content_term ) echo ' selected="selected"'; ?>><?php esc_html_e( '14 days', self::DOMAIN ); ?></option>
1271
+ </select>
1272
+ <span class="description"><?php esc_html_e( 'Default: 3 days', self::DOMAIN ); ?></span>
1273
+ </td>
1274
+ </tr>
1275
+ <tr>
1276
+ <th><label for="share_rush_check_interval"><?php esc_html_e( 'Interval cheking share count (sec)', self::DOMAIN ); ?></label></th>
1277
+ <td>
1278
+ <input type="text" id="share_rush_check_interval" class="text" name="share_rush_check_interval" size="20" value="<?php echo esc_attr( $this->share_rush_check_interval ); ?>" />
1279
+ <span class="description"><?php esc_html_e( 'Default: 900', self::DOMAIN ); ?></span>
1280
+ </td>
1281
+ </tr>
1282
+ <tr>
1283
+ <th><label for="share_rush_posts_per_check"><?php esc_html_e( 'Number of contents to check at a time', self::DOMAIN ); ?></label></th>
1284
+ <td>
1285
+ <input type="text" id="share_rush_posts_per_check" class="text" name="share_rush_posts_per_check" size="20" value="<?php echo esc_attr( $this->share_rush_posts_per_check ); ?>" />
1286
+ <span class="description"><?php esc_html_e( 'Default: 10', self::DOMAIN ); ?></span>
1287
+ </td>
1288
+ </tr>
1289
+ </table>
1290
+ <div class="submit-button">
1291
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php esc_html_e( 'Update All Options', self::DOMAIN ); ?>" />
1292
  </div>
1293
  </div>
1294
+ </div>
1295
+ <div id="share-variation-analysis" class="postbox">
1296
+ <div class="handlediv" title="Click to toggle"><br></div>
1297
+ <h3 class="hndle"><span><?php esc_html_e( 'Share Variation Analysis', self::DOMAIN ); ?></span></h3>
1298
+ <div class="inside">
1299
+ <table class="form-table">
1300
+ <tr>
1301
+ <th><label for="share_variation_analysis_mode"><?php esc_html_e( 'Method to update basis of comparison', self::DOMAIN ); ?></label></th>
1302
+ <td>
1303
+ <select id="share_variation_analysis_mode" name="share_variation_analysis_mode">
1304
+ <option value="1"<?php if ( self::OPT_SHARE_VARIATION_ANALYSIS_NONE === $this->share_variation_analysis_mode ) echo ' selected="selected"'; ?>><?php esc_html_e( 'Disabled (None)', self::DOMAIN ); ?></option>
1305
+ <option value="2"<?php if ( self::OPT_SHARE_VARIATION_ANALYSIS_MANUAL === $this->share_variation_analysis_mode ) echo ' selected="selected"'; ?>><?php esc_html_e( 'Enabled (Manual)', self::DOMAIN ); ?></option>
1306
+ <option value="3"<?php if ( self::OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER === $this->share_variation_analysis_mode ) echo ' selected="selected"'; ?>><?php esc_html_e( 'Enabled (Scheduler)', self::DOMAIN ); ?></option>
1307
+ </select>
1308
+ <span class="description"><?php esc_html_e( 'Default: Disabled (None)', self::DOMAIN ); ?></span>
1309
+ </td>
1310
+ </tr>
1311
+ <?php
1312
+ if ( self::OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER === $this->share_variation_analysis_mode ) {
1313
+ list( $cronstr['minutes'], $cronstr['hours'], $cronstr['mday'], $cronstr['mon'], $cronstr['wday'] ) = explode( ' ', $this->share_variation_analysis_schedule, 5 );
1314
+ if ( strstr( $cronstr['minutes'], '*/' ) ) {
1315
+ $minutes = explode( '/', $cronstr['minutes'] );
1316
+ } else {
1317
+ $minutes = explode( ',', $cronstr['minutes'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1318
  }
1319
+ if ( strstr( $cronstr['hours'], '*/' ) ) {
1320
+ $hours = explode( '/', $cronstr['hours'] );
1321
+ } else {
1322
+ $hours = explode( ',', $cronstr['hours'] );
1323
+ }
1324
+ if ( strstr( $cronstr['mday'], '*/' ) ) {
1325
+ $mday = explode( '/', $cronstr['mday'] );
1326
+ } else {
1327
+ $mday = explode( ',', $cronstr['mday'] );
1328
+ }
1329
+ if ( strstr( $cronstr['mon'], '*/' ) ) {
1330
+ $mon = explode( '/', $cronstr['mon'] );
1331
+ } else {
1332
+ $mon = explode( ',', $cronstr['mon'] );
1333
+ }
1334
+ if ( strstr( $cronstr['wday'], '*/' ) ) {
1335
+ $wday = explode( '/', $cronstr['wday'] );
1336
+ } else {
1337
+ $wday = explode( ',', $cronstr['wday'] );
1338
+ }
1339
+ ?>
1340
+ <tr class="a_wpcron">
1341
+ <th scope="row"><?php esc_html_e( 'Scheduler', self::DOMAIN ); ?></th>
1342
+ <td>
1343
+ <table class="wpcron">
1344
+ <tr>
1345
+ <th>
1346
+ <?php esc_html_e( 'Type', self::DOMAIN ); ?>
1347
+ </th>
1348
+ <th>
1349
+ </th>
1350
+ <th>
1351
+ <?php esc_html_e( 'Hour', self::DOMAIN ); ?>
1352
+ </th>
1353
+ <th>
1354
+ <?php esc_html_e( 'Minute', self::DOMAIN ); ?>
1355
+ </th>
1356
+ </tr>
1357
+ <tr>
1358
+ <td>
1359
+ <label for="idcronbtype-mon">
1360
+ <?php echo '<input class="radio" type="radio"' . checked( true, is_numeric( $mday[0] ), false ) . ' name="a_cronbtype" value="mon" /> ' . esc_html( __( 'monthly', self::DOMAIN ) ); ?>
1361
+ </label>
1362
+ </td>
1363
+ <td>
1364
+ <select name="a_moncronmday">
1365
+ <?php
1366
+ for ( $i = 1; $i <= 31; $i ++ ) {
1367
+ $on_day = '';
1368
+
1369
+ switch ( $i ) {
1370
+ case 1:
1371
+ $on_day = __( 'on 1.', self::DOMAIN );
1372
+ break;
1373
+ case 2:
1374
+ $on_day = __( 'on 2.', self::DOMAIN );
1375
+ break;
1376
+ case 3:
1377
+ $on_day = __( 'on 3.', self::DOMAIN );
1378
+ break;
1379
+ case 4:
1380
+ $on_day = __( 'on 4.', self::DOMAIN );
1381
+ break;
1382
+ case 5:
1383
+ $on_day = __( 'on 5.', self::DOMAIN );
1384
+ break;
1385
+ case 6:
1386
+ $on_day = __( 'on 6.', self::DOMAIN );
1387
+ break;
1388
+ case 7:
1389
+ $on_day = __( 'on 7.', self::DOMAIN );
1390
+ break;
1391
+ case 8:
1392
+ $on_day = __( 'on 8.', self::DOMAIN );
1393
+ break;
1394
+ case 9:
1395
+ $on_day = __( 'on 9.', self::DOMAIN );
1396
+ break;
1397
+ case 10:
1398
+ $on_day = __( 'on 10.', self::DOMAIN );
1399
+ break;
1400
+ case 11:
1401
+ $on_day = __( 'on 11.', self::DOMAIN );
1402
+ break;
1403
+ case 12:
1404
+ $on_day = __( 'on 12.', self::DOMAIN );
1405
+ break;
1406
+ case 13:
1407
+ $on_day = __( 'on 13.', self::DOMAIN );
1408
+ break;
1409
+ case 14:
1410
+ $on_day = __( 'on 14.', self::DOMAIN );
1411
+ break;
1412
+ case 15:
1413
+ $on_day = __( 'on 15.', self::DOMAIN );
1414
+ break;
1415
+ case 16:
1416
+ $on_day = __( 'on 16.', self::DOMAIN );
1417
+ break;
1418
+ case 17:
1419
+ $on_day = __( 'on 17.', self::DOMAIN );
1420
+ break;
1421
+ case 18:
1422
+ $on_day = __( 'on 18.', self::DOMAIN );
1423
+ break;
1424
+ case 19:
1425
+ $on_day = __( 'on 19.', self::DOMAIN );
1426
+ break;
1427
+ case 20:
1428
+ $on_day = __( 'on 20.', self::DOMAIN );
1429
+ break;
1430
+ case 21:
1431
+ $on_day = __( 'on 21.', self::DOMAIN );
1432
+ break;
1433
+ case 22:
1434
+ $on_day = __( 'on 22.', self::DOMAIN );
1435
+ break;
1436
+ case 23:
1437
+ $on_day = __( 'on 23.', self::DOMAIN );
1438
+ break;
1439
+ case 24:
1440
+ $on_day = __( 'on 24.', self::DOMAIN );
1441
+ break;
1442
+ case 25:
1443
+ $on_day = __( 'on 25.', self::DOMAIN );
1444
+ break;
1445
+ case 26:
1446
+ $on_day = __( 'on 26.', self::DOMAIN );
1447
+ break;
1448
+ case 27:
1449
+ $on_day = __( 'on 27.', self::DOMAIN );
1450
+ break;
1451
+ case 28:
1452
+ $on_day = __( 'on 28.', self::DOMAIN );
1453
+ break;
1454
+ case 29:
1455
+ $on_day = __( 'on 29.', self::DOMAIN );
1456
+ break;
1457
+ case 30:
1458
+ $on_day = __( 'on 30.', self::DOMAIN );
1459
+ break;
1460
+ case 31:
1461
+ $on_day = __( 'on 31.', self::DOMAIN );
1462
+ break;
1463
+ }
1464
+
1465
+ echo '<option ' . selected( in_array( "$i", $mday, true ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $on_day ) . '</option>';
1466
+ } // End if().
1467
+ ?>
1468
+ </select>
1469
+ </td>
1470
+ <td>
1471
+ <select name="a_moncronhours">
1472
+ <?php for ( $i = 0; $i < 24; $i ++ ) {
1473
+ echo '<option ' . selected( in_array( "$i", $hours, true ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $i ) . '</option>';
1474
+ } ?>
1475
+ </select>
1476
+ </td>
1477
+ <td>
1478
+ <select name="a_moncronminutes">
1479
+ <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
1480
+ echo '<option ' . selected( in_array( "$i", $minutes, true ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $i ) . '</option>';
1481
+ } ?>
1482
+ </select>
1483
+ </td>
1484
+ </tr>
1485
+ <tr>
1486
+ <td>
1487
+ <label for="idcronbtype-week">
1488
+ <?php echo '<input class="radio" type="radio"' . checked( true, is_numeric( $wday[0] ), false ) . ' name="a_cronbtype" value="week" /> ' . esc_html( __( 'weekly', self::DOMAIN ) ); ?>
1489
+ </label>
1490
+ </td>
1491
+ <td>
1492
+ <select name="a_weekcronwday">
1493
+ <?php
1494
+ echo '<option ' . selected( in_array( '0', $wday, true ), true, false ) . ' value="0" />' . esc_html( __( 'Sunday', self::DOMAIN ) ) . '</option>';
1495
+ echo '<option ' . selected( in_array( '1', $wday, true ), true, false ) . ' value="1" />' . esc_html( __( 'Monday', self::DOMAIN ) ) . '</option>';
1496
+ echo '<option ' . selected( in_array( '2', $wday, true ), true, false ) . ' value="2" />' . esc_html( __( 'Tuesday', self::DOMAIN ) ) . '</option>';
1497
+ echo '<option ' . selected( in_array( '3', $wday, true ), true, false ) . ' value="3" />' . esc_html( __( 'Wednesday', self::DOMAIN ) ) . '</option>';
1498
+ echo '<option ' . selected( in_array( '4', $wday, true ), true, false ) . ' value="4" />' . esc_html( __( 'Thursday', self::DOMAIN ) ) . '</option>';
1499
+ echo '<option ' . selected( in_array( '5', $wday, true ), true, false ) . ' value="5" />' . esc_html( __( 'Friday', self::DOMAIN ) ) . '</option>';
1500
+ echo '<option ' . selected( in_array( '6', $wday, true ), true, false ) . ' value="6" />' . esc_html( __( 'Saturday', self::DOMAIN ) ) . '</option>';
1501
+ ?>
1502
+ </select>
1503
+ </td>
1504
+ <td>
1505
+ <select name="a_weekcronhours">
1506
+ <?php for ( $i = 0; $i < 24; $i ++ ) {
1507
+ echo '<option ' . selected( in_array( "$i", $hours, true ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $i ) . '</option>';
1508
+ } ?>
1509
+ </select>
1510
+ </td>
1511
+ <td>
1512
+ <select name="a_weekcronminutes">
1513
+ <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
1514
+ echo '<option ' . selected( in_array( "$i", $minutes, true ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $i ) . '</option>';
1515
+ } ?>
1516
+ </select>
1517
+ </td>
1518
+ </tr>
1519
+ <tr>
1520
+ <td>
1521
+ <label for="idcronbtype-day">
1522
+ <?php echo '<input class="radio" type="radio"' . checked( "**", $mday[0] . $wday[0], false ) . ' name="a_cronbtype" value="day" /> ' . esc_html( __( 'daily', self::DOMAIN ) ); ?>
1523
+ </label>
1524
+ </td>
1525
+ <td>
1526
+ </td>
1527
+ <td>
1528
+ <select name="a_daycronhours">
1529
+ <?php
1530
+ for ( $i = 0; $i < 24; $i ++ ) {
1531
+ echo '<option ' . selected( in_array( "$i", $hours, true ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $i ) . '</option>';
1532
+ }
1533
+ ?>
1534
+ </select>
1535
+ </td>
1536
+ <td>
1537
+ <select name="a_daycronminutes">
1538
+ <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
1539
+ echo '<option ' . selected( in_array( "$i", $minutes, true ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $i ) . '</option>';
1540
+ } ?>
1541
+ </select>
1542
+ </td>
1543
+ </tr>
1544
+ </table>
1545
+ </td>
1546
+ </tr>
1547
+ <?php
1548
+ }
1549
+ ?>
1550
+ </table>
1551
+ <div class="submit-button">
1552
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php esc_html_e( 'Update All Options', self::DOMAIN ); ?>" />
1553
+ <input type="submit" class="button button-secondary" name="update_share_comparison_base" value="<?php esc_html_e( 'Update Basis of Comparison', self::DOMAIN ); ?>" />
1554
  </div>
1555
  </div>
1556
+ </div>
1557
+ <div id="follow-base-cache" class="postbox">
1558
+ <div class="handlediv" title="Click to toggle"><br></div>
1559
+ <h3 class="hndle"><span><?php esc_html_e( 'Follow Base Cache', self::DOMAIN ); ?></span></h3>
1560
+ <div class="inside">
1561
+ <table class="form-table">
1562
+ <tr>
1563
+ <th><label><?php esc_html_e( 'Target SNS', self::DOMAIN ); ?></label></th>
1564
+ <td>
1565
+ <div class="sns-check">
1566
+ <input type="checkbox" value="1" id="follow_base_cache_target_facebook" name="follow_base_cache_target_facebook"<?php if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_FACEBOOK ] ) ) echo ' checked="checked"'; ?> />
1567
+ <label for="follow_base_cache_target_facebook"><?php esc_html_e( 'Facebook', self::DOMAIN ); ?></label>
1568
+ </div>
1569
+ <div class="sns-check">
1570
+ <input type="checkbox" value="1" id="follow_base_cache_target_feedly" name="follow_base_cache_target_feedly"<?php if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_FEEDLY ] ) ) echo ' checked="checked"'; ?> />
1571
+ <label for="follow_base_cache_target_feedly"><?php esc_html_e( 'Feedly', self::DOMAIN ); ?></label>
1572
+ </div>
1573
+ <div class="sns-check">
1574
+ <input type="checkbox" value="1" id="follow_base_cache_target_instagram" name="follow_base_cache_target_instagram"<?php if ( ! empty( $this->follow_base_cache_target[self::REF_FOLLOW_INSTAGRAM] ) ) echo ' checked="checked"'; ?> />
1575
+ <label for="follow_base_cache_target_instagram"><?php esc_html_e( 'Instagram', self::DOMAIN ); ?></label>
1576
+ </div>
1577
+ <div class="sns-check">
1578
+ <input type="checkbox" value="1" id="follow_base_cache_target_onesignal" name="follow_base_cache_target_onesignal"<?php if ( ! empty( $this->follow_base_cache_target[self::REF_FOLLOW_ONESIGNAL] ) ) echo ' checked="checked"'; ?> />
1579
+ <label for="follow_base_cache_target_onesignal"><?php esc_html_e( 'OneSignal', self::DOMAIN ); ?></label>
1580
+ </div>
1581
+ <div class="sns-check">
1582
+ <input type="checkbox" value="1" id="follow_base_cache_target_push7" name="follow_base_cache_target_push7"<?php if ( ! empty( $this->follow_base_cache_target[self::REF_FOLLOW_PUSH7] ) ) echo ' checked="checked"'; ?> />
1583
+ <label for="follow_base_cache_target_push7"><?php esc_html_e( 'Push7', self::DOMAIN ); ?></label>
1584
+ </div>
1585
+ <div class="sns-check">
1586
+ <input type="checkbox" value="1" id="follow_base_cache_target_twitter" name="follow_base_cache_target_twitter"<?php if ( ! empty( $this->follow_base_cache_target[self::REF_FOLLOW_TWITTER] ) ) echo ' checked="checked"'; ?> />
1587
+ <label for="follow_base_cache_target_twitter"><?php esc_html_e( 'Twitter', self::DOMAIN ); ?></label>
1588
+ </div>
1589
+ </td>
1590
+ </tr>
1591
+ <tr>
1592
+ <th><label for="follow_base_check_interval"><?php esc_html_e( 'Interval cheking follower count (sec)', self::DOMAIN ); ?></label></th>
1593
+ <td>
1594
+ <input type="text" class="text" id="follow_base_check_interval" name="follow_base_check_interval" size="20" value="<?php echo esc_attr( $this->follow_base_check_interval ); ?>" />
1595
+ <span class="description"><?php esc_html_e( 'Default: 86400 Minimum: 3600', self::DOMAIN ); ?></span>
1596
+ </td>
1597
+ </tr>
1598
+ </table>
1599
+ <div class="submit-button">
1600
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php esc_html_e( 'Update All Options', self::DOMAIN ); ?>" />
1601
+ <input type="submit" class="button button-secondary" name="direct_follow_base_cache" value="<?php esc_html_e( 'Cache', self::DOMAIN ); ?>">
1602
+ <input type="submit" class="button button-secondary" name="clear_follow_base_cache" value="<?php esc_html_e( 'Clear Cache', self::DOMAIN ); ?>">
1603
  </div>
1604
  </div>
1605
+ </div>
1606
+ <?php if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_FACEBOOK ] ) ) { ?>
1607
+ <div id="follow-base-cache-facebook" class="postbox">
1608
+ <div class="handlediv" title="Click to toggle"><br></div>
1609
+ <h3 class="hndle"><span><?php esc_html_e( 'Follow Base Cache - Facebook', self::DOMAIN ); ?></span></h3>
1610
+ <div class="inside">
1611
+ <table class="form-table">
1612
+ <tr>
1613
+ <th><label for="follow_facebook_page_id"><?php esc_html_e( 'Page ID', self::DOMAIN ); ?></label></th>
1614
+ <td>
1615
+ <input type="text" class="text" id="follow_facebook_page_id" name="follow_facebook_page_id" size="30" value="<?php echo esc_attr( $this->follow_facebook_page_id ); ?>" />
1616
+ <br>
1617
+ <span class="description"><?php esc_html_e( 'Facebook page ID that you want to get follower count', self::DOMAIN ); ?></span>
1618
+ </td>
1619
+ </tr>
1620
+ <tr>
1621
+ <th><label><?php esc_html_e( 'Developer page', self::DOMAIN ); ?></label></th>
1622
+ <td>
1623
+ <a href="https://developers.facebook.com/apps/" target="_blank">https://developers.facebook.com/apps/</a>
1624
+ <br>
1625
+ <span class="description"><?php esc_html_e( 'Register a application in Facebook developer page to get the following App ID and App Secret.', self::DOMAIN ); ?></span>
1626
+ </td>
1627
+ </tr>
1628
+ <tr>
1629
+ <th><label for="follow_facebook_app_id"><?php esc_html_e( 'App ID', self::DOMAIN ); ?></label></th>
1630
+ <td>
1631
+ <input type="password" id="follow_facebook_app_id" class="text" name="follow_facebook_app_id" size="60" value="<?php echo esc_attr( $this->follow_facebook_app_id ); ?>" />
1632
+ <br>
1633
+ <span class="description"><?php esc_html_e( 'App ID for Facebook API', self::DOMAIN ); ?></span>
1634
+ </td>
1635
+ </tr>
1636
+ <tr>
1637
+ <th><label for="follow_facebook_app_secret"><?php esc_html_e( 'App Secret', self::DOMAIN ); ?></label></th>
1638
+ <td>
1639
+ <input type="password" id="follow_facebook_app_secret" class="text" name="follow_facebook_app_secret" size="60" value="<?php echo esc_attr( $this->follow_facebook_app_secret ); ?>" />
1640
+ <br>
1641
+ <span class="description"><?php esc_html_e( 'App Secret for Facebook API', self::DOMAIN ); ?></span>
1642
+ </td>
1643
+ </tr>
1644
+ <tr>
1645
+ <th><label for="tmp_follow_facebook_redirect_uri"><?php esc_html_e( 'Redirect URI', self::DOMAIN ); ?></label></th>
1646
+ <td>
1647
+ <input type="text" id="tmp_follow_facebook_redirect_uri" class="text" name="tmp_follow_facebook_redirect_uri" size="80" value="<?php echo esc_url( plugins_url() . '/sns-count-cache/?action=facebook-auth' ); ?>" onclick="this.focus();this.select()" title="<?php esc_html_e( 'To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac).', self::DOMAIN ); ?>" readonly />
1648
+ <br>
1649
+ <span class="description"><?php esc_html_e( 'Copy and set this to the field of "Valid OAuth redirect URIs" in application management page of Facebook developer page.', self::DOMAIN ); ?></span>
1650
+ </td>
1651
+ </tr>
1652
+ <?php if ( ! empty( $_GET['action'] ) && wp_unslash( $_GET['action'] ) === 'facebook-auth' ) { ?>
1653
+ <tr>
1654
+ <th><label for="tmp_follow_facebook_access_token"><?php esc_html_e( 'Access Token', self::DOMAIN ); ?></label></th>
1655
+ <td>
1656
+ <?php if ( ! is_wp_error( $tmp_facebook_access_token ) ) { ?>
1657
+ <input type="text" id="tmp_follow_facebook_access_token" class="text" name="tmp_follow_facebook_access_token" size="80" value="<?php echo esc_attr( $tmp_facebook_access_token ); ?>" onclick="this.focus();this.select()" title="<?php esc_html_e( 'To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac).', self::DOMAIN ); ?>" readonly />
 
 
 
 
 
 
 
 
 
 
 
 
1658
  <br>
1659
+ <span class="description"><?php esc_html_e( 'Copy and pase this into the fields below.', self::DOMAIN ); ?></span>
1660
+ <?php } else { ?>
1661
+ <span class="update-message notice-error"><p><?php echo esc_html( $tmp_facebook_access_token->get_error_message() ); ?></p></span>
1662
+ <?php } ?>
1663
+ </td>
1664
+ </tr>
1665
+ <?php } ?>
1666
+ <?php if ( ! empty( $this->follow_facebook_page_id ) && ! empty( $this->follow_facebook_app_id ) && ! empty( $this->follow_facebook_app_secret ) ) { ?>
1667
+ <tr>
1668
+ <th><label for="follow_facebook_access_token"><?php esc_html_e( 'Access Token', self::DOMAIN ); ?></label></th>
1669
+ <td>
1670
+ <input type="password" id="follow_facebook_access_token" class="text" name="follow_facebook_access_token" size="80" value="<?php echo esc_attr( $this->follow_facebook_access_token ); ?>" />
1671
+ <br>
1672
+ <span class="description"><?php esc_html_e( 'Access Token for Facebook API', self::DOMAIN ); ?></span>
1673
+ </td>
1674
+ </tr>
1675
+ <?php } ?>
1676
+ </table>
1677
+ <div class="submit-button">
1678
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php esc_html_e( 'Update All Options', self::DOMAIN ); ?>" />
1679
+ <?php if ( ! empty( $this->follow_facebook_page_id ) && ! empty( $this->follow_facebook_app_id ) && ! empty( $this->follow_facebook_app_secret ) ) { ?>
1680
+ <a href="https://www.facebook.com/dialog/oauth?client_id=<?php echo esc_attr( $this->follow_facebook_app_id ); ?>&scope=manage_pages,read_insights&state=<?php echo wp_create_nonce( 'facebook-auth' ); ?>&redirect_uri=<?php echo esc_url( plugins_url() ) . '/sns-count-cache/'; ?>?action=facebook-auth" class="button button-secondary"><?php esc_html_e( 'Get Access Token', self::DOMAIN ); ?></a>
1681
+ <?php } ?>
1682
  </div>
1683
  </div>
1684
+ </div>
1685
+ <?php } // End if(). ?>
1686
+ <?php if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_FEEDLY ] ) ) { ?>
1687
+ <div id="follow-base-cache-feedly" class="postbox">
1688
+ <div class="handlediv" title="Click to toggle"><br></div>
1689
+ <h3 class="hndle"><span><?php esc_html_e( 'Follow Base Cache - Feedly', self::DOMAIN ); ?></span></h3>
1690
+ <div class="inside">
1691
+ <table class="form-table">
1692
+ <tr>
1693
+ <th><label for="follow_feed_type"><?php esc_html_e( 'Target feed type', self::DOMAIN ); ?></label></th>
1694
+ <td>
1695
+ <select id="follow_feed_type" name="follow_feed_type">
1696
+ <option value="default"<?php if ( self::OPT_FEED_TYPE_DEFAULT === $this->follow_feed_type ) echo ' selected="selected"'; ?>><?php esc_html_e( 'Default', self::DOMAIN ) ?></option>
1697
+ <option value="rss"<?php if ( self::OPT_FEED_TYPE_RSS === $this->follow_feed_type ) echo ' selected="selected"'; ?>><?php esc_html_e( 'RSS', self::DOMAIN ); ?></option>
1698
+ <option value="rss2"<?php if ( self::OPT_FEED_TYPE_RSS2 === $this->follow_feed_type ) echo ' selected="selected"'; ?>><?php esc_html_e( 'RSS2', self::DOMAIN ); ?></option>
1699
+ <option value="rdf"<?php if ( self::OPT_FEED_TYPE_RDF === $this->follow_feed_type ) echo ' selected="selected"'; ?>><?php esc_html_e( 'RDF', self::DOMAIN ); ?></option>
1700
+ <option value="atom"<?php if ( self::OPT_FEED_TYPE_ATOM === $this->follow_feed_type ) echo ' selected="selected"'; ?>><?php esc_html_e( 'ATOM', self::DOMAIN ); ?></option>
1701
+ </select>
1702
+ <span class="description"><?php esc_html_e( 'Default: Default', self::DOMAIN ); ?></span>
1703
+ </td>
1704
+ </tr>
1705
+ <tr>
1706
+ <th><label><?php esc_html_e( 'Target feed', self::DOMAIN ); ?></label></th>
1707
+ <td><a href="<?php echo esc_url( get_feed_link( $this->follow_feed_type ) ); ?>" target="_blank"><?php echo esc_html( get_feed_link( $this->follow_feed_type ) ); ?></a></td>
1708
+ </tr>
1709
+ </table>
1710
+ <div class="submit-button">
1711
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php esc_html_e( 'Update All Options', self::DOMAIN ); ?>" />
1712
  </div>
1713
  </div>
1714
+ </div>
1715
+ <?php } ?>
1716
+ <?php if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_INSTAGRAM ] ) ) { ?>
1717
+ <div id="follow-base-cache-instagram" class="postbox">
1718
+ <div class="handlediv" title="Click to toggle"><br></div>
1719
+ <h3 class="hndle"><span><?php esc_html_e( 'Follow Base Cache - Instagram', self::DOMAIN ); ?></span></h3>
1720
+ <div class="inside">
1721
+ <table class="form-table">
1722
+ <tr>
1723
+ <th><label><?php esc_html_e( 'Developer page', self::DOMAIN ); ?></label></th>
1724
+ <td>
1725
+ <a href="https://www.instagram.com/developer/clients/manage/" target="_blank">https://www.instagram.com/developer/clients/manage/</a>
1726
+ <br>
1727
+ <span class="description"><?php esc_html_e( 'Register a client in Instagram developer page to get the following Client ID and Client Secret.', self::DOMAIN ); ?></span>
1728
+ </td>
1729
+ </tr>
1730
+ <tr>
1731
+ <th><label for="follow_instagram_client_id"><?php esc_html_e( 'Client ID', self::DOMAIN ); ?></label></th>
1732
+ <td>
1733
+ <input type="password" id="follow_instagram_client_id" class="text" name="follow_instagram_client_id" size="60" value="<?php echo esc_attr( $this->follow_instagram_client_id ); ?>" />
1734
+ <br>
1735
+ <span class="description"><?php esc_html_e( 'Client ID for Instagram API', self::DOMAIN ); ?></span>
1736
+ </td>
1737
+ </tr>
1738
+ <tr>
1739
+ <th><label for="follow_instagram_client_secret"><?php esc_html_e( 'Client Secret', self::DOMAIN ); ?></label></th>
1740
+ <td>
1741
+ <input type="password" id="follow_instagram_client_secret" class="text" name="follow_instagram_client_secret" size="60" value="<?php echo esc_attr( $this->follow_instagram_client_secret ); ?>" />
1742
+ <br>
1743
+ <span class="description"><?php esc_html_e( 'Client Secret for Instagram API', self::DOMAIN ); ?></span>
1744
+ </td>
1745
+ </tr>
1746
+ <tr>
1747
+ <th><label for="tmp_follow_instagram_redirect_uri"><?php esc_html_e( 'Redirect URI', self::DOMAIN ); ?></label></th>
1748
+ <td>
1749
+ <input type="text" id="tmp_follow_instagram_redirect_uri" class="text" name="tmp_follow_instagram_redirect_uri" size="80" value="<?php echo esc_url( plugins_url() . '/sns-count-cache/?action=instagram-auth' ); ?>" onclick="this.focus();this.select()" title="<?php esc_html_e( 'To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac).', self::DOMAIN ); ?>" readonly />
1750
+ <br>
1751
+ <span class="description"><?php esc_html_e( 'Copy and set this to the field of "Valid redirect URIs" in the client management page of Instagram developer page.', self::DOMAIN ); ?></span>
1752
+ </td>
1753
+ </tr>
1754
+ <?php if ( ! empty( $_GET['action'] ) && wp_unslash( $_GET['action'] ) === 'instagram-auth' ) { ?>
1755
+ <tr>
1756
+ <th><label for="tmp_follow_instagram_access_token"><?php esc_html_e( 'Access Token', self::DOMAIN ); ?></label></th>
1757
+ <td>
1758
+ <?php if ( ! is_wp_error( $tmp_instagram_access_token ) ) { ?>
1759
+ <input type="text" id="tmp_follow_instagram_access_token" class="text" name="tmp_follow_instagram_access_token" size="80" value="<?php echo esc_attr( $tmp_instagram_access_token ); ?>" onclick="this.focus();this.select()" title="<?php esc_html_e( 'To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac).', self::DOMAIN ); ?>" readonly />
 
 
 
 
 
 
 
 
 
 
 
 
1760
  <br>
1761
+ <span class="description"><?php esc_html_e( 'Copy and pase this into the fields below.', self::DOMAIN ); ?></span>
1762
+ <?php } else { ?>
1763
+ <span class="update-message notice-error"><p><?php echo esc_html( $tmp_instagram_access_token->get_error_message() ); ?></p></span>
1764
+ <?php } ?>
1765
+ </td>
1766
+ </tr>
1767
+ <?php } ?>
1768
+ <?php if ( ! empty( $this->follow_instagram_client_id ) && ! empty( $this->follow_instagram_client_secret ) ) { ?>
1769
+ <tr>
1770
+ <th><label for="follow_instagram_access_token"><?php esc_html_e( 'Access Token', self::DOMAIN ); ?></label></th>
1771
+ <td>
1772
+ <input type="password" id="follow_instagram_access_token" class="text" name="follow_instagram_access_token" size="80" value="<?php echo esc_attr( $this->follow_instagram_access_token ); ?>" />
1773
+ <br>
1774
+ <span class="description"><?php esc_html_e( 'Access Token for Instagram API', self::DOMAIN ); ?></span>
1775
+ </td>
1776
+ </tr>
1777
+ <?php } ?>
1778
+ </table>
1779
+ <div class="submit-button">
1780
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php esc_html_e( 'Update All Options', self::DOMAIN ); ?>" />
1781
+ <?php if ( ! empty( $this->follow_instagram_client_id ) && ! empty( $this->follow_instagram_client_secret ) ) { ?>
1782
+ <a href="https://api.instagram.com/oauth/authorize/?client_id=<?php echo esc_attr( $this->follow_instagram_client_id ); ?>&response_type=code&state=<?php echo wp_create_nonce( 'instagram-auth' ); ?>&redirect_uri=<?php echo esc_url( plugins_url() ) . '/sns-count-cache/'; ?>?action=instagram-auth" class="button button-secondary"><?php esc_html_e( 'Get Access Token', self::DOMAIN ); ?></a>
1783
+ <?php } ?>
1784
  </div>
1785
  </div>
1786
+ </div>
1787
+ <?php } // End if(). ?>
1788
+ <?php if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_ONESIGNAL ] ) ) { ?>
1789
+ <div id="follow-base-cache-onesignal" class="postbox">
1790
+ <div class="handlediv" title="Click to toggle"><br></div>
1791
+ <h3 class="hndle"><span><?php esc_html_e( 'Follow Base Cache - OneSignal', self::DOMAIN ); ?></span></h3>
1792
+ <div class="inside">
1793
+ <table class="form-table">
1794
+ <tr>
1795
+ <th><label><?php esc_html_e( 'Home page', self::DOMAIN ); ?></label></th>
1796
+ <td>
1797
+ <a href="https://onesignal.com/" target="_blank">https://onesignal.com/</a>
1798
+ <br>
1799
+ <span class="description"><?php esc_html_e( 'Register a application in OneSignal page to get the following App ID and User Auth Key.', self::DOMAIN ); ?></span>
1800
+ </td>
1801
+ </tr>
1802
+ <tr>
1803
+ <th><label for="follow_onesignal_app_id"><?php esc_html_e( 'OneSignal App ID', self::DOMAIN ); ?></label></th>
1804
+ <td>
1805
+ <input type="password" class="text" id="follow_onesignal_app_id" name="follow_onesignal_app_id" size="60" value="<?php echo esc_attr( $this->follow_onesignal_app_id ); ?>" />
1806
+ <br>
1807
+ <span class="description"><?php esc_html_e( 'OneSignal app ID that you want to get follower count', self::DOMAIN ); ?></span>
1808
+ </td>
1809
+ </tr>
1810
+ <tr>
1811
+ <th><label for="follow_onesignal_rest_api_key"><?php esc_html_e( 'REST API Key', self::DOMAIN ); ?></label></th>
1812
+ <td>
1813
+ <input type="password" id="follow_onesignal_rest_api_key" class="text" name="follow_onesignal_rest_api_key" size="60" value="<?php echo esc_attr( $this->follow_onesignal_rest_api_key ); ?>" />
1814
+ <br>
1815
+ <span class="description"><?php esc_html_e( 'REST API Key for OneSignal API', self::DOMAIN ); ?></span>
1816
+ </td>
1817
+ </tr>
1818
+ </table>
1819
+ <div class="submit-button">
1820
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php esc_html_e( 'Update All Options', self::DOMAIN ); ?>" />
1821
  </div>
1822
  </div>
1823
+ </div>
1824
+ <?php } // End if(). ?>
1825
+ <?php if ( ! empty( $this->follow_base_cache_target[self::REF_FOLLOW_PUSH7] ) ) { ?>
1826
+ <div id="follow-base-cache-push7" class="postbox">
1827
+ <div class="handlediv" title="Click to toggle"><br></div>
1828
+ <h3 class="hndle"><span><?php esc_html_e( 'Follow Base Cache - Push7', self::DOMAIN ); ?></span></h3>
1829
+ <div class="inside">
1830
+ <table class="form-table">
1831
+ <tr>
1832
+ <th><label><?php esc_html_e( 'Push7 page', self::DOMAIN ); ?></label></th>
1833
+ <td>
1834
+ <a href="https://push7.jp/" target="_blank">https://push7.jp/</a>
1835
+ <br>
1836
+ <span class="description"><?php esc_html_e( 'Register a application in Push7 page to get the following App Number.', self::DOMAIN ); ?></span>
1837
+ </td>
1838
+ </tr>
1839
+ <tr>
1840
+ <th><label for="follow_push7_app_number"><?php esc_html_e( 'App Number', self::DOMAIN ); ?></label></th>
1841
+ <td>
1842
+ <input type="password" id="follow_push7_app_number" class="text" name="follow_push7_app_number" size="60" value="<?php echo esc_attr( $this->follow_push7_app_number ); ?>" />
1843
+ <br>
1844
+ <span class="description"><?php esc_html_e( 'App Number for Push7 API', self::DOMAIN ); ?></span>
1845
+ </td>
1846
+ </tr>
1847
+ </table>
1848
+ <div class="submit-button">
1849
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php esc_html_e( 'Update All Options', self::DOMAIN ); ?>" />
1850
+ </div>
1851
+ </div>
1852
+ </div>
1853
+ <?php } ?>
1854
+ <?php if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_TWITTER ] ) ) { ?>
1855
+ <div id="follow-base-cache-twitter" class="postbox">
1856
+ <div class="handlediv" title="Click to toggle"><br></div>
1857
+ <h3 class="hndle"><span><?php esc_html_e( 'Follow Base Cache - Twitter', self::DOMAIN ); ?></span></h3>
1858
+ <div class="inside">
1859
+ <table class="form-table">
1860
+ <tr>
1861
+ <th><label for="follow_twitter_screen_name"><?php esc_html_e( 'Screen Name', self::DOMAIN ); ?></label></th>
1862
+ <td>
1863
+ <span class="at-mark">@</span>
1864
+ <input type="text" id="follow_twitter_screen_name" class="text" name="follow_twitter_screen_name" size="30" value="<?php echo esc_attr( $this->follow_twitter_screen_name ); ?>" />
1865
+ <br>
1866
+ <span class="description"><?php esc_html_e( 'Twitter screen name that you want to get follower count', self::DOMAIN ); ?></span>
1867
+ </td>
1868
+ </tr>
1869
+ <tr>
1870
+ <th><label><?php esc_html_e( 'Developer page', self::DOMAIN ); ?></label></th>
1871
+ <td>
1872
+ <a href="https://apps.twitter.com" target="_blank">https://apps.twitter.com</a>
1873
+ <br>
1874
+ <span class="description"><?php esc_html_e( 'Register a application in Twitter developer page to get the following Consumer Key and Consumer Secret.', self::DOMAIN ); ?></span>
1875
+ </td>
1876
+ </tr>
1877
+ <tr>
1878
+ <th><label for="follow_twitter_api_key"><?php esc_html_e( 'API Key', self::DOMAIN ); ?></label></th>
1879
+ <td>
1880
+ <input type="password" id="follow_twitter_api_key" class="text" name="follow_twitter_api_key" size="60" value="<?php echo esc_attr( $this->follow_twitter_api_key ); ?>" />
1881
+ <br>
1882
+ <span class="description"><?php esc_html_e( 'API key for Twitter API', self::DOMAIN ); ?></span>
1883
+ </td>
1884
+ </tr>
1885
+ <tr>
1886
+ <th><label for="follow_twitter_api_secret_key"><?php esc_html_e( 'API Secret Key', self::DOMAIN ); ?></label></th>
1887
+ <td>
1888
+ <input type="password" id="follow_twitter_api_secret_key" class="text" name="follow_twitter_api_secret_key" size="60" value="<?php echo esc_attr( $this->follow_twitter_api_secret_key ); ?>" />
1889
+ <br>
1890
+ <span class="description"><?php esc_html_e( 'API Secret Key for Twitter API', self::DOMAIN ); ?></span>
1891
+ </td>
1892
+ </tr>
1893
+ <?php if ( isset( $_POST['get_tiwtter_bearer_token'] ) && wp_unslash( $_POST['get_tiwtter_bearer_token'] ) === __( 'Get Bearer Token', self::DOMAIN ) ) { ?>
1894
+ <tr>
1895
+ <th><label for="tmp_follow_twitter_bearer_token"><?php esc_html_e( 'Bearer Token', self::DOMAIN ); ?></label></th>
1896
+ <td>
1897
+ <?php if ( ! is_wp_error( $tmp_twitter_bearer_token ) ) { ?>
1898
+ <input type="text" id="tmp_follow_twitter_bearer_token" class="text" name="tmp_follow_twitter_bearer_token" size="80" value="<?php echo esc_attr( $tmp_twitter_bearer_token ); ?>" onclick="this.focus();this.select()" title="<?php esc_html_e( 'To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac).', self::DOMAIN ); ?>" readonly />
1899
  <br>
1900
+ <span class="description"><?php esc_html_e( 'Copy and pase this into the fields below.', self::DOMAIN ); ?></span>
1901
+ <?php } else { ?>
1902
+ <span class="update-message notice-error"><p><?php echo esc_html( $tmp_twitter_bearer_token->get_error_message() ); ?></p></span>
1903
+ <?php } ?>
1904
+ </td>
1905
+ </tr>
1906
+ <?php } ?>
1907
+ <?php if ( ! empty( $this->follow_twitter_api_key ) && ! empty( $this->follow_twitter_api_secret_key ) ) { ?>
1908
+ <tr>
1909
+ <th><label for="follow_twitter_bearer_token"><?php esc_html_e( 'Bearer Token', self::DOMAIN ); ?></label></th>
1910
+ <td>
1911
+ <input type="password" id="follow_twitter_bearer_token" class="text" name="follow_twitter_bearer_token" size="80" value="<?php echo esc_attr( $this->follow_twitter_bearer_token ); ?>" />
1912
+ <br>
1913
+ <span class="description"><?php esc_html_e( 'Bearer Token for Twitter API', self::DOMAIN ); ?></span>
1914
+ </td>
1915
+ </tr>
1916
+ <?php } ?>
1917
+ </table>
1918
+ <div class="submit-button">
1919
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php esc_html_e( 'Update All Options', self::DOMAIN ); ?>" />
1920
+ <?php if ( ! empty( $this->follow_twitter_api_key ) && ! empty( $this->follow_twitter_api_secret_key ) ) { ?>
1921
+ <input type="submit" class="button button-secondary" name="get_tiwtter_bearer_token" value="<?php esc_html_e( 'Get Bearer Token', self::DOMAIN ); ?>" />
1922
+ <?php } ?>
1923
  </div>
1924
  </div>
1925
+ </div>
1926
+ <?php } // End if(). ?>
1927
+ <div id="follow-variation-analysis" class="postbox">
1928
+ <div class="handlediv" title="Click to toggle"><br></div>
1929
+ <h3 class="hndle"><span><?php esc_html_e( 'Follow Variation Analysis', self::DOMAIN ); ?></span></h3>
1930
+ <div class="inside">
1931
+ <table class="form-table">
1932
+ <tr>
1933
+ <th><label for="follow_variation_analysis_mode"><?php esc_html_e( 'Method to update basis of comparison', self::DOMAIN ); ?></label></th>
1934
+ <td>
1935
+ <select id="follow_variation_analysis_mode" name="follow_variation_analysis_mode">
1936
+ <option value="1"<?php if ( self::OPT_FOLLOW_VARIATION_ANALYSIS_NONE === $this->follow_variation_analysis_mode ) echo ' selected="selected"'; ?>><?php esc_html_e( 'Disabled (None)', self::DOMAIN ); ?></option>
1937
+ <option value="2"<?php if ( self::OPT_FOLLOW_VARIATION_ANALYSIS_MANUAL === $this->follow_variation_analysis_mode ) echo ' selected="selected"'; ?>><?php esc_html_e( 'Enabled (Manual)', self::DOMAIN ); ?></option>
1938
+ <option value="3"<?php if ( self::OPT_FOLLOW_VARIATION_ANALYSIS_SCHEDULER === $this->follow_variation_analysis_mode ) echo ' selected="selected"'; ?>><?php esc_html_e( 'Enabled (Scheduler)', self::DOMAIN ); ?></option>
1939
+ </select>
1940
+ <span class="description"><?php esc_html_e( 'Default: Disabled (None)', self::DOMAIN ); ?></span>
1941
+ </td>
1942
+ </tr>
1943
+ <?php
1944
+ if ( self::OPT_FOLLOW_VARIATION_ANALYSIS_SCHEDULER === $this->follow_variation_analysis_mode ) {
1945
+ list( $cronstr['minutes'], $cronstr['hours'], $cronstr['mday'], $cronstr['mon'], $cronstr['wday'] ) = explode( ' ', $this->follow_variation_analysis_schedule, 5 );
1946
+ if ( strstr( $cronstr['minutes'], '*/' ) ) {
1947
+ $minutes = explode( '/', $cronstr['minutes'] );
1948
+ } else {
1949
+ $minutes = explode( ',', $cronstr['minutes'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1950
  }
1951
+ if ( strstr( $cronstr['hours'], '*/' ) ) {
1952
+ $hours = explode( '/', $cronstr['hours'] );
1953
+ } else {
1954
+ $hours = explode( ',', $cronstr['hours'] );
1955
+ }
1956
+ if ( strstr( $cronstr['mday'], '*/' ) ) {
1957
+ $mday = explode( '/', $cronstr['mday'] );
1958
+ } else {
1959
+ $mday = explode( ',', $cronstr['mday'] );
1960
+ }
1961
+ if ( strstr( $cronstr['mon'], '*/' ) ) {
1962
+ $mon = explode( '/', $cronstr['mon'] );
1963
+ } else {
1964
+ $mon = explode( ',', $cronstr['mon'] );
1965
+ }
1966
+ if ( strstr( $cronstr['wday'], '*/' ) ) {
1967
+ $wday = explode( '/', $cronstr['wday'] );
1968
+ } else {
1969
+ $wday = explode( ',', $cronstr['wday'] );
1970
+ }
1971
+ ?>
1972
+ <tr class="a_wpcron">
1973
+ <th scope="row"><?php esc_html_e( 'Scheduler', self::DOMAIN ); ?></th>
1974
+ <td>
1975
+ <table class="wpcron">
1976
+ <tr>
1977
+ <th>
1978
+ <?php esc_html_e( 'Type', self::DOMAIN ); ?>
1979
+ </th>
1980
+ <th>
1981
+ </th>
1982
+ <th>
1983
+ <?php esc_html_e( 'Hour', self::DOMAIN ); ?>
1984
+ </th>
1985
+ <th>
1986
+ <?php esc_html_e( 'Minute', self::DOMAIN ); ?>
1987
+ </th>
1988
+ </tr>
1989
+ <tr>
1990
+ <td>
1991
+ <label for="idcronbtype-mon">
1992
+ <?php echo '<input class="radio" type="radio"' . checked( true, is_numeric( $mday[0] ), false ) . ' name="b_cronbtype" value="mon" /> ' . esc_html( __( 'monthly', self::DOMAIN ) ); ?>
1993
+ </label>
1994
+ </td>
1995
+ <td>
1996
+ <select name="b_moncronmday">
1997
+ <?php
1998
+ for ( $i = 1; $i <= 31; $i ++ ) {
1999
+ $on_day = '';
2000
+
2001
+ switch ( $i ) {
2002
+ case 1:
2003
+ $on_day = __( 'on 1.', self::DOMAIN );
2004
+ break;
2005
+ case 2:
2006
+ $on_day = __( 'on 2.', self::DOMAIN );
2007
+ break;
2008
+ case 3:
2009
+ $on_day = __( 'on 3.', self::DOMAIN );
2010
+ break;
2011
+ case 4:
2012
+ $on_day = __( 'on 4.', self::DOMAIN );
2013
+ break;
2014
+ case 5:
2015
+ $on_day = __( 'on 5.', self::DOMAIN );
2016
+ break;
2017
+ case 6:
2018
+ $on_day = __( 'on 6.', self::DOMAIN );
2019
+ break;
2020
+ case 7:
2021
+ $on_day = __( 'on 7.', self::DOMAIN );
2022
+ break;
2023
+ case 8:
2024
+ $on_day = __( 'on 8.', self::DOMAIN );
2025
+ break;
2026
+ case 9:
2027
+ $on_day = __( 'on 9.', self::DOMAIN );
2028
+ break;
2029
+ case 10:
2030
+ $on_day = __( 'on 10.', self::DOMAIN );
2031
+ break;
2032
+ case 11:
2033
+ $on_day = __( 'on 11.', self::DOMAIN );
2034
+ break;
2035
+ case 12:
2036
+ $on_day = __( 'on 12.', self::DOMAIN );
2037
+ break;
2038
+ case 13:
2039
+ $on_day = __( 'on 13.', self::DOMAIN );
2040
+ break;
2041
+ case 14:
2042
+ $on_day = __( 'on 14.', self::DOMAIN );
2043
+ break;
2044
+ case 15:
2045
+ $on_day = __( 'on 15.', self::DOMAIN );
2046
+ break;
2047
+ case 16:
2048
+ $on_day = __( 'on 16.', self::DOMAIN );
2049
+ break;
2050
+ case 17:
2051
+ $on_day = __( 'on 17.', self::DOMAIN );
2052
+ break;
2053
+ case 18:
2054
+ $on_day = __( 'on 18.', self::DOMAIN );
2055
+ break;
2056
+ case 19:
2057
+ $on_day = __( 'on 19.', self::DOMAIN );
2058
+ break;
2059
+ case 20:
2060
+ $on_day = __( 'on 20.', self::DOMAIN );
2061
+ break;
2062
+ case 21:
2063
+ $on_day = __( 'on 21.', self::DOMAIN );
2064
+ break;
2065
+ case 22:
2066
+ $on_day = __( 'on 22.', self::DOMAIN );
2067
+ break;
2068
+ case 23:
2069
+ $on_day = __( 'on 23.', self::DOMAIN );
2070
+ break;
2071
+ case 24:
2072
+ $on_day = __( 'on 24.', self::DOMAIN );
2073
+ break;
2074
+ case 25:
2075
+ $on_day = __( 'on 25.', self::DOMAIN );
2076
+ break;
2077
+ case 26:
2078
+ $on_day = __( 'on 26.', self::DOMAIN );
2079
+ break;
2080
+ case 27:
2081
+ $on_day = __( 'on 27.', self::DOMAIN );
2082
+ break;
2083
+ case 28:
2084
+ $on_day = __( 'on 28.', self::DOMAIN );
2085
+ break;
2086
+ case 29:
2087
+ $on_day = __( 'on 29.', self::DOMAIN );
2088
+ break;
2089
+ case 30:
2090
+ $on_day = __( 'on 30.', self::DOMAIN );
2091
+ break;
2092
+ case 31:
2093
+ $on_day = __( 'on 31.', self::DOMAIN );
2094
+ break;
2095
+ } // End switch().
2096
+
2097
+ echo '<option ' . selected( in_array( "$i", $mday, true ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $on_day ) . '</option>';
2098
+ } // End for().
2099
+ ?>
2100
+ </select>
2101
+ </td>
2102
+ <td>
2103
+ <select name="b_moncronhours">
2104
+ <?php for ( $i = 0; $i < 24; $i ++ ) {
2105
+ echo '<option ' . selected( in_array( "$i", $hours, true ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $i ) . '</option>';
2106
+ } ?>
2107
+ </select>
2108
+ </td>
2109
+ <td>
2110
+ <select name="b_moncronminutes">
2111
+ <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
2112
+ echo '<option ' . selected( in_array( "$i", $minutes, true ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $i ) . '</option>';
2113
+ } ?>
2114
+ </select>
2115
+ </td>
2116
+ </tr>
2117
+ <tr>
2118
+ <td>
2119
+ <label for="idcronbtype-week">
2120
+ <?php echo '<input class="radio" type="radio"' . checked( true, is_numeric( $wday[0] ), false ) . ' name="a_cronbtype" value="week" /> ' . esc_html( __( 'weekly', self::DOMAIN ) ); ?>
2121
+ </label>
2122
+ </td>
2123
+ <td>
2124
+ <select name="b_weekcronwday">
2125
+ <?php
2126
+ echo '<option ' . selected( in_array( '0', $wday, true ), true, false ) . ' value="0" />' . esc_html( __( 'Sunday', self::DOMAIN ) ) . '</option>';
2127
+ echo '<option ' . selected( in_array( '1', $wday, true ), true, false ) . ' value="1" />' . esc_html( __( 'Monday', self::DOMAIN ) ) . '</option>';
2128
+ echo '<option ' . selected( in_array( '2', $wday, true ), true, false ) . ' value="2" />' . esc_html( __( 'Tuesday', self::DOMAIN ) ) . '</option>';
2129
+ echo '<option ' . selected( in_array( '3', $wday, true ), true, false ) . ' value="3" />' . esc_html( __( 'Wednesday', self::DOMAIN ) ) . '</option>';
2130
+ echo '<option ' . selected( in_array( '4', $wday, true ), true, false ) . ' value="4" />' . esc_html( __( 'Thursday', self::DOMAIN ) ) . '</option>';
2131
+ echo '<option ' . selected( in_array( '5', $wday, true ), true, false ) . ' value="5" />' . esc_html( __( 'Friday', self::DOMAIN ) ) . '</option>';
2132
+ echo '<option ' . selected( in_array( '6', $wday, true ), true, false ) . ' value="6" />' . esc_html( __( 'Saturday', self::DOMAIN ) ) . '</option>';
2133
+ ?>
2134
+ </select>
2135
+ </td>
2136
+ <td>
2137
+ <select name="b_weekcronhours">
2138
+ <?php for ( $i = 0; $i < 24; $i ++ ) {
2139
+ echo '<option ' . selected( in_array( "$i", $hours, true ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $i ) . '</option>';
2140
+ } ?>
2141
+ </select>
2142
+ </td>
2143
+ <td>
2144
+ <select name="b_weekcronminutes">
2145
+ <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
2146
+ echo '<option ' . selected( in_array( "$i", $minutes, true ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $i ) . '</option>';
2147
+ } ?>
2148
+ </select>
2149
+ </td>
2150
+ </tr>
2151
+ <tr>
2152
+ <td>
2153
+ <label for="idcronbtype-day">
2154
+ <?php echo '<input class="radio" type="radio"' . checked( "**", $mday[0] . $wday[0], false ) . ' name="b_cronbtype" value="day" /> ' . esc_html( __( 'daily', self::DOMAIN ) ); ?>
2155
+ </label>
2156
+ </td>
2157
+ <td>
2158
+ </td>
2159
+ <td>
2160
+ <select name="b_daycronhours">
2161
+ <?php
2162
+ for ( $i = 0; $i < 24; $i ++ ) {
2163
+ echo '<option ' . selected( in_array( "$i", $hours, true ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $i ) . '</option>';
2164
+ }
2165
+ ?>
2166
+ </select>
2167
+ </td>
2168
+ <td>
2169
+ <select name="b_daycronminutes">
2170
+ <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
2171
+ echo '<option ' . selected( in_array( "$i", $minutes, ture ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $i ) . '</option>';
2172
+ } ?>
2173
+ </select>
2174
+ </td>
2175
+ </tr>
2176
+ </table>
2177
+ </td>
2178
+ </tr>
2179
+ <?php
2180
+ }
2181
+ ?>
2182
+ </table>
2183
+ <div class="submit-button">
2184
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php esc_html_e( 'Update All Options', self::DOMAIN ); ?>" />
2185
+ <input type="submit" class="button button-secondary" name="update_follow_comparison_base" value="<?php esc_html_e( 'Update Basis of Comparison', self::DOMAIN ); ?>" />
2186
  </div>
2187
  </div>
2188
+ </div>
2189
+ <div id="common-dynamic-cache" class="postbox">
2190
+ <div class="handlediv" title="Click to toggle"><br></div>
2191
+ <h3 class="hndle"><span><?php esc_html_e( 'Dynamic Cache', self::DOMAIN ); ?></span></h3>
2192
+ <div class="inside">
2193
+ <table class="form-table">
2194
+ <tr>
2195
+ <th><label for="dynamic_cache_mode"><?php esc_html_e( 'Dynamic caching based on user access', self::DOMAIN ); ?></label></th>
2196
+ <td>
2197
+ <select id="dynamic_cache_mode" name="dynamic_cache_mode">
2198
+ <option value="1"<?php if ( self::OPT_COMMON_ACCESS_BASED_CACHE_OFF === $this->dynamic_cache_mode ) echo ' selected="selected"'; ?>><?php esc_html_e( 'Disabled', self::DOMAIN ); ?></option>
2199
+ <option value="5"<?php if ( self::OPT_COMMON_ACCESS_BASED_CACHE_ON === $this->dynamic_cache_mode ) echo ' selected="selected"'; ?>><?php esc_html_e( 'Enabled', self::DOMAIN ); ?></option>
2200
+ </select>
2201
+ <span class="description"><?php esc_html_e( 'Default: Disabled', self::DOMAIN ); ?></span>
2202
+ </td>
2203
+ </tr>
2204
+ </table>
2205
+ <div class="submit-button">
2206
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php esc_html_e( 'Update All Options', self::DOMAIN ); ?>" />
2207
  </div>
2208
  </div>
2209
+ </div>
2210
+ <div id="common-fault-tolerance" class="postbox">
2211
+ <div class="handlediv" title="Click to toggle"><br></div>
2212
+ <h3 class="hndle"><span><?php esc_html_e( 'Fault Tolerance', self::DOMAIN ); ?></span></h3>
2213
+ <div class="inside">
2214
+ <table class="form-table">
2215
+ <tr>
2216
+ <th><label for="fault_tolerance_mode"><?php esc_html_e( 'Fault tolerant mode of count retrieval', self::DOMAIN ); ?></label></th>
2217
+ <td>
2218
+ <select id="fault_tolerance_mode" name="fault_tolerance_mode">
2219
+ <option value="1"<?php if ( self::OPT_COMMON_FAULT_TOLERANCE_OFF === $this->fault_tolerance_mode ) echo ' selected="selected"'; ?>><?php esc_html_e( 'Disabled', self::DOMAIN ); ?></option>
2220
+ <option value="2"<?php if ( self::OPT_COMMON_FAULT_TOLERANCE_ON === $this->fault_tolerance_mode ) echo ' selected="selected"'; ?>><?php esc_html_e( 'Enabled', self::DOMAIN ); ?></option>
2221
+ </select>
2222
+ <span class="description"><?php esc_html_e( 'Default: Disabled', self::DOMAIN ); ?></span>
2223
+ </td>
2224
+ </tr>
2225
+ </table>
2226
+ <div class="submit-button">
2227
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php esc_html_e( 'Update All Options', self::DOMAIN ); ?>" />
2228
  </div>
2229
  </div>
2230
+ </div>
2231
+ <div id="common-data-crawler" class="postbox">
2232
+ <div class="handlediv" title="Click to toggle"><br></div>
2233
+ <h3 class="hndle"><span><?php esc_html_e( 'Data Crawler', self::DOMAIN ); ?></span></h3>
2234
+ <div class="inside">
2235
+ <table class="form-table">
2236
+ <tr>
2237
+ <th><label><?php esc_html_e( 'Crawl method', self::DOMAIN ); ?></label></th>
2238
+ <td>
2239
+ <?php
2240
+ switch ( $this->crawler_method ) {
2241
+ case self::OPT_COMMON_CRAWLER_METHOD_NORMAL:
2242
+ esc_html_e( 'Normal (Sequential Retrieval)', self::DOMAIN );
2243
+ break;
2244
+ case self::OPT_COMMON_CRAWLER_METHOD_CURL:
2245
+ esc_html_e( 'Extended (Parallel Retrieval)', self::DOMAIN );
2246
+ break;
2247
+ }
2248
+ ?>
2249
+ </td>
2250
+ </tr>
2251
+ <tr>
2252
+ <th><label for="common_data_crawler_retry_limit"><?php esc_html_e( 'Crawl retry limit', self::DOMAIN ); ?></label></th>
2253
+ <td>
2254
+ <select id="common_data_crawler_retry_limit" name="common_data_crawler_retry_limit">
2255
+ <option value="-1"<?php if ( -1 === $this->crawler_retry_limit ) echo ' selected="selected"'; ?>><?php esc_html_e( 'no retry', self::DOMAIN ); ?></option>
2256
+ <option value="1"<?php if ( 1 === $this->crawler_retry_limit ) echo ' selected="selected"'; ?>><?php esc_html_e( '1 time', self::DOMAIN ); ?></option>
2257
+ <option value="2"<?php if ( 2 === $this->crawler_retry_limit ) echo ' selected="selected"'; ?>><?php esc_html_e( '2 times', self::DOMAIN ); ?></option>
2258
+ <option value="3"<?php if ( 3 === $this->crawler_retry_limit ) echo ' selected="selected"'; ?>><?php esc_html_e( '3 times', self::DOMAIN ); ?></option>
2259
+ <option value="4"<?php if ( 4 === $this->crawler_retry_limit ) echo ' selected="selected"'; ?>><?php esc_html_e( '4 times', self::DOMAIN ); ?></option>
2260
+ <option value="5"<?php if ( 5 === $this->crawler_retry_limit ) echo ' selected="selected"'; ?>><?php esc_html_e( '5 times', self::DOMAIN ); ?></option>
2261
+ </select>
2262
+ <span class="description"><?php esc_html_e( 'Default: no retry', self::DOMAIN ); ?></span>
2263
+ </td>
2264
+ </tr>
2265
+ <tr>
2266
+ <th><label for="crawler_ssl_verification"><?php esc_html_e( 'SSL verification', self::DOMAIN ); ?></label></th>
2267
+ <td>
2268
+ <select id="crawler_ssl_verification" name="crawler_ssl_verification">
2269
+ <option value="0"<?php if ( self::OPT_COMMON_CRAWLER_SSL_VERIFY_OFF === $this->crawler_ssl_verification ) echo ' selected="selected"'; ?>><?php esc_html_e( 'Off', self::DOMAIN ); ?></option>
2270
+ <option value="1"<?php if ( self::OPT_COMMON_CRAWLER_SSL_VERIFY_ON === $this->crawler_ssl_verification ) echo ' selected="selected"'; ?>><?php esc_html_e( 'On', self::DOMAIN ); ?></option>
2271
+ </select>
2272
+ <span class="description"><?php esc_html_e( 'Default: On', self::DOMAIN ); ?></span>
2273
+ </td>
2274
+ </tr>
2275
+ </table>
2276
+ <div class="submit-button">
2277
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php esc_html_e( 'Update All Options', self::DOMAIN ); ?>" />
2278
  </div>
2279
  </div>
2280
+ </div>
2281
+ <div id="common-data-export" class="postbox">
2282
+ <div class="handlediv" title="Click to toggle"><br></div>
2283
+ <h3 class="hndle"><span><?php esc_html_e( 'Data Export', self::DOMAIN ); ?></span></h3>
2284
+ <div class="inside">
2285
+ <table class="form-table">
2286
+ <tr>
2287
+ <th><label for="data_export_mode"><?php esc_html_e( 'Method of data export', self::DOMAIN ); ?></label></th>
2288
+ <td>
2289
+ <select id="data_export_mode" name="data_export_mode">
2290
+ <option value="1"<?php if ( self::OPT_COMMON_DATA_EXPORT_MANUAL === $this->data_export_mode ) echo ' selected="selected"'; ?>><?php esc_html_e( 'Manual', self::DOMAIN ); ?></option>
2291
+ <option value="2"<?php if ( self::OPT_COMMON_DATA_EXPORT_SCHEDULER === $this->data_export_mode ) echo ' selected="selected"'; ?> disabled="disabled"><?php esc_html_e( 'Scheduler', self::DOMAIN ); ?></option>
2292
+ </select>
2293
+ <span class="description"><?php esc_html_e( 'Default: Manual', self::DOMAIN ); ?></span>
2294
+ </td>
2295
+ </tr>
2296
+ <?php
2297
+ if ( self::OPT_COMMON_DATA_EXPORT_SCHEDULER === $this->data_export_mode ) {
2298
+ list( $cronstr[ 'minutes' ], $cronstr[ 'hours' ], $cronstr[ 'mday' ], $cronstr[ 'mon' ], $cronstr[ 'wday' ] ) = explode( ' ', $this->data_export_schedule, 5 );
2299
+ if ( strstr( $cronstr[ 'minutes' ], '*/' ) ) {
2300
+ $minutes = explode( '/', $cronstr[ 'minutes' ] );
2301
+ } else {
2302
+ $minutes = explode( ',', $cronstr[ 'minutes' ] );
2303
+ }
2304
+ if ( strstr( $cronstr[ 'hours' ], '*/' ) ) {
2305
+ $hours = explode( '/', $cronstr[ 'hours' ] );
2306
+ } else {
2307
+ $hours = explode( ',', $cronstr[ 'hours' ] );
2308
+ }
2309
+ if ( strstr( $cronstr[ 'mday' ], '*/' ) ) {
2310
+ $mday = explode( '/', $cronstr[ 'mday' ] );
2311
+ } else {
2312
+ $mday = explode( ',', $cronstr[ 'mday' ] );
2313
+ }
2314
+ if ( strstr( $cronstr[ 'mon' ], '*/' ) ) {
2315
+ $mon = explode( '/', $cronstr[ 'mon' ] );
2316
+ } else {
2317
+ $mon = explode( ',', $cronstr[ 'mon' ] );
2318
+ }
2319
+ if ( strstr( $cronstr[ 'wday' ], '*/' ) ) {
2320
+ $wday = explode( '/', $cronstr[ 'wday' ] );
2321
+ } else {
2322
+ $wday = explode( ',', $cronstr[ 'wday' ] );
2323
+ }
2324
+ ?>
2325
+ <tr class="e_wpcron">
2326
+ <th scope="row"><?php esc_html_e( 'Scheduler', self::DOMAIN ); ?></th>
2327
+ <td>
2328
+ <table class="wpcron">
2329
+ <tr>
2330
+ <th>
2331
+ <?php esc_html_e( 'Type', self::DOMAIN ); ?>
2332
+ </th>
2333
+ <th>
2334
+ </th>
2335
+ <th>
2336
+ <?php esc_html_e( 'Hour', self::DOMAIN ); ?>
2337
+ </th>
2338
+ <th>
2339
+ <?php esc_html_e( 'Minute', self::DOMAIN ); ?>
2340
+ </th>
2341
+ </tr>
2342
+ <tr>
2343
+ <td>
2344
+ <label for="idcronbtype-mon">
2345
+ <?php echo '<input class="radio" type="radio"' . checked( true, is_numeric( $mday[0] ), false ) . ' name="e_cronbtype" value="mon" /> ' . esc_html( __( 'monthly', self::DOMAIN ) ); ?>
2346
+ </label>
2347
+ </td>
2348
+ <td>
2349
+ <select name="e_moncronmday">
2350
+ <?php
2351
+ for ( $i = 1; $i <= 31; $i ++ ) {
2352
+ $on_day = '';
2353
+
2354
+ switch ( $i ) {
2355
+ case 1:
2356
+ $on_day = __( 'on 1.', self::DOMAIN );
2357
+ break;
2358
+ case 2:
2359
+ $on_day = __( 'on 2.', self::DOMAIN );
2360
+ break;
2361
+ case 3:
2362
+ $on_day = __( 'on 3.', self::DOMAIN );
2363
+ break;
2364
+ case 4:
2365
+ $on_day = __( 'on 4.', self::DOMAIN );
2366
+ break;
2367
+ case 5:
2368
+ $on_day = __( 'on 5.', self::DOMAIN );
2369
+ break;
2370
+ case 6:
2371
+ $on_day = __( 'on 6.', self::DOMAIN );
2372
+ break;
2373
+ case 7:
2374
+ $on_day = __( 'on 7.', self::DOMAIN );
2375
+ break;
2376
+ case 8:
2377
+ $on_day = __( 'on 8.', self::DOMAIN );
2378
+ break;
2379
+ case 9:
2380
+ $on_day = __( 'on 9.', self::DOMAIN );
2381
+ break;
2382
+ case 10:
2383
+ $on_day = __( 'on 10.', self::DOMAIN );
2384
+ break;
2385
+ case 11:
2386
+ $on_day = __( 'on 11.', self::DOMAIN );
2387
+ break;
2388
+ case 12:
2389
+ $on_day = __( 'on 12.', self::DOMAIN );
2390
+ break;
2391
+ case 13:
2392
+ $on_day = __( 'on 13.', self::DOMAIN );
2393
+ break;
2394
+ case 14:
2395
+ $on_day = __( 'on 14.', self::DOMAIN );
2396
+ break;
2397
+ case 15:
2398
+ $on_day = __( 'on 15.', self::DOMAIN );
2399
+ break;
2400
+ case 16:
2401
+ $on_day = __( 'on 16.', self::DOMAIN );
2402
+ break;
2403
+ case 17:
2404
+ $on_day = __( 'on 17.', self::DOMAIN );
2405
+ break;
2406
+ case 18:
2407
+ $on_day = __( 'on 18.', self::DOMAIN );
2408
+ break;
2409
+ case 19:
2410
+ $on_day = __( 'on 19.', self::DOMAIN );
2411
+ break;
2412
+ case 20:
2413
+ $on_day = __( 'on 20.', self::DOMAIN );
2414
+ break;
2415
+ case 21:
2416
+ $on_day = __( 'on 21.', self::DOMAIN );
2417
+ break;
2418
+ case 22:
2419
+ $on_day = __( 'on 22.', self::DOMAIN );
2420
+ break;
2421
+ case 23:
2422
+ $on_day = __( 'on 23.', self::DOMAIN );
2423
+ break;
2424
+ case 24:
2425
+ $on_day = __( 'on 24.', self::DOMAIN );
2426
+ break;
2427
+ case 25:
2428
+ $on_day = __( 'on 25.', self::DOMAIN );
2429
+ break;
2430
+ case 26:
2431
+ $on_day = __( 'on 26.', self::DOMAIN );
2432
+ break;
2433
+ case 27:
2434
+ $on_day = __( 'on 27.', self::DOMAIN );
2435
+ break;
2436
+ case 28:
2437
+ $on_day = __( 'on 28.', self::DOMAIN );
2438
+ break;
2439
+ case 29:
2440
+ $on_day = __( 'on 29.', self::DOMAIN );
2441
+ break;
2442
+ case 30:
2443
+ $on_day = __( 'on 30.', self::DOMAIN );
2444
+ break;
2445
+ case 31:
2446
+ $on_day = __( 'on 31.', self::DOMAIN );
2447
+ break;
2448
+ }
2449
+
2450
+ echo '<option ' . selected( in_array( "$i", $mday, true ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $on_day ) . '</option>';
2451
+ }
2452
+ ?>
2453
+ </select>
2454
+ </td>
2455
+ <td>
2456
+ <select name="e_moncronhours">
2457
+ <?php
2458
+ for ( $i = 0; $i < 24; $i ++ ) {
2459
+ echo '<option ' . selected( in_array( "$i", $hours, true ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $i ) . '</option>';
2460
+ }
2461
+ ?>
2462
+ </select>
2463
+ </td>
2464
+ <td>
2465
+ <select name="e_moncronminutes">
2466
+ <?php
2467
+ for ( $i = 0; $i < 60; $i = $i + 5 ) {
2468
+ echo '<option ' . selected( in_array( "$i", $minutes, true ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $i ) . '</option>';
2469
+ }
2470
+ ?>
2471
+ </select>
2472
+ </td>
2473
+ </tr>
2474
+ <tr>
2475
+ <td>
2476
+ <label for="idcronbtype-week">
2477
+ <?php echo '<input class="radio" type="radio"' . checked( true, is_numeric( $wday[0] ), false ) . ' name="e_cronbtype" value="week" /> ' . esc_html( __( 'weekly', self::DOMAIN ) ); ?>
2478
+ </label>
2479
+ </td>
2480
+ <td>
2481
+ <select name="e_weekcronwday">
2482
+ <?php
2483
+ echo '<option ' . selected( in_array( '0', $wday, true ), true, false ) . ' value="0" />' . esc_html( __( 'Sunday', self::DOMAIN ) ) . '</option>';
2484
+ echo '<option ' . selected( in_array( '1', $wday, true ), true, false ) . ' value="1" />' . esc_html( __( 'Monday', self::DOMAIN ) ) . '</option>';
2485
+ echo '<option ' . selected( in_array( '2', $wday, true ), true, false ) . ' value="2" />' . esc_html( __( 'Tuesday', self::DOMAIN ) ) . '</option>';
2486
+ echo '<option ' . selected( in_array( '3', $wday, true ), true, false ) . ' value="3" />' . esc_html( __( 'Wednesday', self::DOMAIN ) ) . '</option>';
2487
+ echo '<option ' . selected( in_array( '4', $wday, true ), true, false ) . ' value="4" />' . esc_html( __( 'Thursday', self::DOMAIN ) ) . '</option>';
2488
+ echo '<option ' . selected( in_array( '5', $wday, true ), true, false ) . ' value="5" />' . esc_html( __( 'Friday', self::DOMAIN ) ) . '</option>';
2489
+ echo '<option ' . selected( in_array( '6', $wday, true ), true, false ) . ' value="6" />' . esc_html( __( 'Saturday', self::DOMAIN ) ) . '</option>';
2490
+ ?>
2491
+ </select>
2492
+ </td>
2493
+ <td>
2494
+ <select name="e_weekcronhours">
2495
+ <?php
2496
+ for ( $i = 0; $i < 24; $i ++ ) {
2497
+ echo '<option ' . selected( in_array( "$i", $hours, true ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $i ) . '</option>';
2498
+ }
2499
+ ?>
2500
+ </select>
2501
+ </td>
2502
+ <td>
2503
+ <select name="e_weekcronminutes">
2504
+ <?php
2505
+ for ( $i = 0; $i < 60; $i = $i + 5 ) {
2506
+ echo '<option ' . selected( in_array( "$i", $minutes, true ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $i ) . '</option>';
2507
+ }
2508
+ ?>
2509
+ </select>
2510
+ </td>
2511
+ </tr>
2512
+ <tr>
2513
+ <td>
2514
+ <label for="idcronbtype-day">
2515
+ <?php echo '<input class="radio" type="radio"' . checked( "**", $mday[0] . $wday[0], FALSE ) . ' name="e_cronbtype" value="day" /> ' . esc_html( __( 'daily', self::DOMAIN ) ); ?>
2516
+ </label>
2517
+ </td>
2518
+ <td>
2519
+ </td>
2520
+ <td>
2521
+ <select name="e_daycronhours">
2522
+ <?php
2523
+ for ( $i = 0; $i < 24; $i ++ ) {
2524
+ echo '<option ' . selected( in_array( "$i", $hours, true ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $i ) . '</option>';
2525
+ }
2526
+ ?>
2527
+ </select>
2528
+ </td>
2529
+ <td>
2530
+ <select name="e_daycronminutes">
2531
+ <?php
2532
+ for ( $i = 0; $i < 60; $i = $i + 5 ) {
2533
+ echo '<option ' . selected( in_array( "$i", $minutes, true ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $i ) . '</option>';
2534
+ }
2535
+ ?>
2536
+ </select>
2537
+ </td>
2538
+ </tr>
2539
+ <tr>
2540
+ <td>
2541
+ <label for="idcronbtype-hour">
2542
+ <?php echo '<input class="radio" type="radio"' . checked( "*", $hours[0], false, false ) . ' name="e_cronbtype" value="hour" /> ' . __( 'hourly', self::DOMAIN ); ?>
2543
+ </label>
2544
+ </td>
2545
+ <td></td>
2546
+ <td></td>
2547
+ <td>
2548
+ <select name="e_hourcronminutes">
2549
+ <?php
2550
+ for ( $i = 0; $i < 60; $i = $i + 5 ) {
2551
+ echo '<option ' . selected( in_array( "$i", $minutes, true ), true, false ) . ' value="' . esc_attr( $i ) . '" />' . esc_html( $i ) . '</option>';
2552
+ }
2553
+ ?>
2554
+ </select>
2555
+ </td>
2556
+ </tr>
2557
+ </table>
2558
+ </td>
2559
+ </tr>
2560
+ <?php
2561
+ }
2562
+ ?>
2563
+ </table>
2564
+ <div class="submit-button">
2565
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php esc_html_e( 'Update All Options', self::DOMAIN ); ?>" />
2566
+ </div>
2567
+ </div>
2568
+ </div>
2569
+ </form>
2570
+ </div>
2571
+ <div class="metabox-holder">
2572
+ <div id="common-exported-file" class="postbox">
2573
+ <div class="handlediv" title="Click to toggle"><br></div>
2574
+ <h3 class="hndle"><span><?php esc_html_e( 'Exported File', self::DOMAIN ); ?></span></h3>
2575
+ <div class="inside">
2576
+ <table class="form-table">
2577
+ <tbody>
2578
+ <tr>
2579
+ <th><?php esc_html_e( 'Disk usage of exported file', self::DOMAIN ); ?></th>
2580
+ <td>
2581
+ <?php
2582
+ $abs_path = WP_PLUGIN_DIR . '/sns-count-cache/data/sns-count-cache-data.csv';
2583
+ $file_size = SCC_File::get_file_size( $abs_path );
2584
+
2585
+ if ( isset( $file_size ) ) {
2586
+ echo esc_html( $file_size );
2587
+ } else {
2588
+ esc_html_e( 'No exported file', self::DOMAIN );
2589
+ }
2590
+ ?>
2591
+ </td>
2592
+ </tr>
2593
+ </tbody>
2594
+ </table>
2595
+ <form action="admin.php?page=scc-setting" method="post">
2596
+ <?php wp_nonce_field( __FILE__, '_wpnonce' ); ?>
2597
+ <table class="form-table">
2598
+ <tbody>
2599
  <tr>
2600
+ <th><?php esc_html_e( 'Manual export', self::DOMAIN ); ?></th>
2601
  <td>
2602
+ <input type="submit" class="button button-secondary" name="export_data" value="<?php esc_html_e( 'Export', self::DOMAIN ); ?>" />
2603
+ <br>
2604
+ <span class="description"><?php esc_html_e( 'Export share count to a csv file.', self::DOMAIN ); ?></span>
 
 
2605
  </td>
2606
  </tr>
2607
+ </tbody>
2608
+ </table>
2609
+ </form>
2610
+ <?php
2611
+ if ( file_exists( $abs_path ) ) {
2612
+ ?>
2613
+ <form action="admin.php?page=scc-setting" method="post">
2614
+ <?php wp_nonce_field( __FILE__, '_wpnonce' ); ?>
2615
+ <table class="form-table">
2616
+ <tbody>
2617
+ <tr>
2618
+ <th><?php esc_html_e( 'Reset of exported file', self::DOMAIN ); ?></th>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2619
  <td>
2620
+ <input type="submit" class="button button-secondary" name="reset_data" value="<?php esc_html_e( 'Reset', self::DOMAIN ); ?>" />
2621
+ <br>
2622
+ <span class="description"><?php esc_html_e( 'Clear exported csv file.', self::DOMAIN ); ?></span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2623
  </td>
2624
  </tr>
2625
+ </tbody>
2626
+ </table>
2627
+ </form>
2628
+ <form action="<?php echo plugins_url(); ?>/sns-count-cache/includes/download.php" method="post">
2629
+ <?php wp_nonce_field( 'download', '_wpnonce' ); ?>
 
 
 
 
 
 
 
 
 
 
 
2630
  <table class="form-table">
2631
  <tbody>
2632
  <tr>
2633
+ <th><?php esc_html_e( 'Download of exported file', self::DOMAIN ); ?></th>
2634
  <td>
2635
+ <input type="submit" class="button button-secondary" name="download_data" value="<?php esc_html_e( 'Download', self::DOMAIN ); ?>" />
2636
+ <br>
2637
+ <span class="description"><?php esc_html_e( 'Download the exported csv file.', self::DOMAIN ); ?></span>
 
 
 
 
 
 
 
2638
  </td>
2639
  </tr>
2640
  </tbody>
2641
  </table>
2642
+ </form>
2643
+ <?php
2644
+ }
2645
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2646
  </div>
2647
  </div>
2648
  </div>
2649
  </div>
2650
+ </div>
includes/admin-share-count.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  admin-share-count.php
4
 
5
  Description: Option page implementation
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,171 +27,226 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
- if ( ! defined( 'ABSPATH' ) ) exit(); // Exit if accessed directly
 
 
31
 
32
- $posts_per_page = 50;
33
 
34
- $sort_mode = false;
35
- $sort_exec_key = '';
36
 
37
- if ( isset( $_GET["action"] ) && $_GET["action"] === 'sort' ) {
38
- if ( current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
39
- if( isset( $_GET["key"] ) ) {
40
- $sort_mode = true;
41
- $sns = $_GET["key"];
42
 
43
- if ( $sns === 'Google' ) {
44
- $sns = $sns . '+';
45
- }
46
 
47
- $sort_exec_key = $sns;
48
 
49
- $meta_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( $sns );
50
- }
51
  }
52
  }
 
53
 
54
- $paged = 1;
55
-
56
- if ( isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) && $_GET['paged'] > 0 ) {
57
- $paged = $_GET['paged'];
58
- } else {
59
- $paged = 1;
60
- }
61
 
62
- $share_base_cache_target = $this->share_base_cache_target ;
63
- unset( $share_base_cache_target[self::REF_CRAWL_DATE] );
64
-
65
- ?>
66
- <div class="wrap">
67
- <h2><a href="admin.php?page=scc-share-count"><?php _e( 'SNS Count Cache', self::DOMAIN ); ?></a></h2>
68
- <div class="sns-cnt-cache">
69
- <h3 class="nav-tab-wrapper">
70
- <a class="nav-tab" href="admin.php?page=scc-dashboard"><?php _e( 'Dashboard', self::DOMAIN ); ?></a>
71
- <a class="nav-tab" href="admin.php?page=scc-cache-status"><?php _e( 'Cache Status', self::DOMAIN ); ?></a>
72
- <a class="nav-tab nav-tab-active" href="admin.php?page=scc-share-count"><?php _e( 'Share Count', self::DOMAIN ); ?></a>
73
- <?php if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) { ?>
74
- <a class="nav-tab" href="admin.php?page=scc-hot-content"><?php _e( 'Hot Content', self::DOMAIN ); ?></a>
75
- <?php } ?>
76
- <a class="nav-tab" href="admin.php?page=scc-setting"><?php _e( 'Setting', self::DOMAIN ); ?></a>
77
- <a class="nav-tab" href="admin.php?page=scc-help"><?php _e( 'Help', self::DOMAIN ); ?></a>
78
- </h3>
79
- <div class="metabox-holder">
80
- <div id="share-each-content" class="postbox">
81
- <div class="handlediv" title="Click to toggle"><br></div>
82
- <h3 class="hndle"><span><?php _e( 'Share Count', self::DOMAIN ); ?></span></h3>
83
- <div class="inside">
84
- <table class="view-table">
85
- <thead>
86
- <tr>
87
- <th>No.</th>
88
- <th><?php _e( 'Content', self::DOMAIN ); ?></th>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  <?php
90
- foreach ( $share_base_cache_target as $sns => $active ) {
91
- if ( $active ) {
92
- $sort_key = $sns;
93
 
94
- if ( $sort_key === self::REF_SHARE_GPLUS ) {
95
- $sort_key = str_replace( '+', '', $sort_key );
96
- }
97
 
98
- $sort_url = esc_url( 'admin.php?page=scc-share-count&action=sort&key=' . $sort_key );
99
-
100
- $sns_name = '';
101
-
102
- switch ( $sns ) {
103
- case self::REF_SHARE_TWITTER:
104
- $sns_name = __( 'Twitter', self::DOMAIN );
105
- break;
106
- case self::REF_SHARE_FACEBOOK:
107
- $sns_name = __( 'Facebook', self::DOMAIN );
108
- break;
109
- case self::REF_SHARE_GPLUS:
110
- $sns_name = __( 'Google+', self::DOMAIN );
111
- break;
112
- case self::REF_SHARE_POCKET:
113
- $sns_name = __( 'Pocket', self::DOMAIN );
114
- break;
115
- case self::REF_SHARE_HATEBU:
116
- $sns_name = __( 'Hatebu', self::DOMAIN );
117
- break;
118
- case self::REF_SHARE_PINTEREST:
119
- $sns_name = __( 'Pinterest', self::DOMAIN );
120
- break;
121
- case self::REF_SHARE_LINKEDIN:
122
- $sns_name = __( 'Linkedin', self::DOMAIN );
123
- break;
124
- case self::REF_SHARE_TOTAL:
125
- $sns_name = __( 'Total', self::DOMAIN );
126
- break;
127
- }
128
 
129
- if ( $sns === $sort_exec_key ) {
130
- echo '<th><a class="sort-exec-key" href="' . $sort_url . '">' . esc_html( $sns_name ) . '</th>';
131
- } else {
132
- echo '<th><a href="' . $sort_url . '">' . esc_html( $sns_name ) . '</th>';
133
- }
134
  }
135
- }
 
136
  ?>
137
- </tr>
138
- </thead>
139
- <tbody>
140
  <?php
141
- if ( $sort_mode ) {
142
- $query_args = array(
143
- 'post_type' => $this->share_base_cache_post_types,
144
- 'post_status' => 'publish',
145
- 'posts_per_page' => $posts_per_page,
146
- 'paged' => $paged,
147
- 'meta_key' => $meta_key,
148
- 'orderby' => 'meta_value_num',
149
- 'update_post_term_cache' => false,
150
- 'order' => 'DESC'
151
- );
152
- } else {
153
- $query_args = array(
154
- 'post_type' => $this->share_base_cache_post_types,
155
- 'post_status' => 'publish',
156
- 'posts_per_page' => $posts_per_page,
157
- 'paged' => $paged,
158
- 'update_post_term_cache' => false
159
- );
160
- }
161
-
162
- $posts_query = new WP_Query( $query_args );
163
-
164
- $count = ( $paged - 1 ) * $posts_per_page + 1;
165
-
166
- if ( $paged === 1 ) {
167
  ?>
168
- <tr class="home">
169
- <td><?php echo '-'; ?></td>
170
- <td><a href="<?php echo esc_url( home_url( '/' ) ); ?>" target="_blank"><?php echo esc_html( bloginfo('name') ); ?></a></td>
171
  <?php
172
- if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) {
173
- $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( 'home' );
174
 
175
- if ( false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
176
- $option_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( 'home' );
177
 
178
- if ( false !== ( $sns_deltas = get_option( $option_key ) ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  foreach ( $share_base_cache_target as $sns => $active ) {
180
  if ( $active ) {
181
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
182
  echo '<td class="share-count">';
183
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
184
 
185
- if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
186
- echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
187
- } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
188
- echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
189
  }
190
 
191
  echo '</td>';
192
  } else {
193
  echo '<td class="not-cached share-count">';
194
- _e( 'N/A', self::DOMAIN );
195
  echo '</td>';
196
  }
197
  }
@@ -199,93 +254,101 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
199
  } else {
200
  foreach ( $share_base_cache_target as $sns => $active ) {
201
  if ( $active ) {
202
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
203
  echo '<td class="share-count">';
204
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
205
  echo '</td>';
206
  } else {
207
  echo '<td class="not-cached share-count">';
208
- _e( 'N/A', self::DOMAIN );
209
  echo '</td>';
210
  }
211
  }
212
  }
213
- }
214
  } else {
215
- $option_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( 'home' );
216
-
217
- if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
218
- $option_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( 'home' );
219
-
220
- if ( false !== ( $sns_deltas = get_option( $option_key ) ) ) {
221
- foreach ( $share_base_cache_target as $sns => $active ) {
222
- if ( $active ) {
223
- if ( $sns_counts[$sns] >= 0 ) {
224
- echo '<td class="share-count">';
225
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
226
-
227
- if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
228
- echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
229
- } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
230
- echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
231
- }
232
-
233
- echo '</td>';
234
- } else {
235
- echo '<td class="not-cached share-count">';
236
- _e( 'N/A', self::DOMAIN );
237
- echo '</td>';
238
- }
239
- }
240
- }
241
- } else {
242
- foreach ( $share_base_cache_target as $sns => $active ) {
243
- if ( $active ) {
244
- if ( $sns_counts[$sns] >= 0 ) {
245
- echo '<td class="share-count">';
246
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
247
- echo '</td>';
248
- } else {
249
- echo '<td class="not-cached share-count">';
250
- _e( 'N/A', self::DOMAIN );
251
- echo '</td>';
252
- }
253
  }
 
 
 
 
 
 
254
  }
255
  }
256
- } else {
257
- foreach ( $share_base_cache_target as $sns => $active ) {
258
- if ( $active ) {
 
 
 
 
 
 
259
  echo '<td class="not-cached share-count">';
260
- _e( 'N/A', self::DOMAIN );
261
  echo '</td>';
262
  }
263
  }
264
  }
265
- }
266
  } else {
267
- $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( 'home' );
268
 
269
- if ( false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
270
- $option_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( 'home' );
271
 
272
- if ( false !== ( $sns_deltas = get_option( $option_key ) ) ) {
 
 
 
 
 
273
  foreach ( $share_base_cache_target as $sns => $active ) {
274
  if ( $active ) {
275
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
276
  echo '<td class="share-count">';
277
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
278
 
279
- if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
280
- echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
281
- } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
282
- echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
283
  }
284
 
285
  echo '</td>';
286
  } else {
287
  echo '<td class="not-cached share-count">';
288
- _e( 'N/A', self::DOMAIN );
289
  echo '</td>';
290
  }
291
  }
@@ -293,160 +356,120 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
293
  } else {
294
  foreach ( $share_base_cache_target as $sns => $active ) {
295
  if ( $active ) {
296
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
297
  echo '<td class="share-count">';
298
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
299
  echo '</td>';
300
  } else {
301
  echo '<td class="not-cached share-count">';
302
- _e( 'N/A', self::DOMAIN );
303
  echo '</td>';
304
  }
305
  }
306
  }
307
- }
308
  } else {
309
- $option_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( 'home' );
310
-
311
- if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
312
- $option_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( 'home' );
313
-
314
- if ( false !== ( $sns_deltas = get_option( $option_key ) ) ) {
315
- foreach ( $share_base_cache_target as $sns => $active ) {
316
- if ( $active ){
317
- if ( $sns_counts[$sns] >= 0 ) {
318
- echo '<td class="share-count">';
319
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
320
-
321
- if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
322
- echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
323
- } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
324
- echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
325
- }
326
-
327
- echo '</td>';
328
- } else {
329
- echo '<td class="not-cached share-count">';
330
- _e( 'N/A', self::DOMAIN );
331
- echo '</td>';
332
- }
333
- }
334
- }
335
- } else {
336
- foreach ( $share_base_cache_target as $sns => $active ) {
337
- if ( $active ){
338
- if ( $sns_counts[$sns] >= 0 ) {
339
- echo '<td class="share-count">';
340
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
341
- echo '</td>';
342
- } else {
343
- echo '<td class="not-cached share-count">';
344
- _e( 'N/A', self::DOMAIN );
345
- echo '</td>';
346
- }
347
- }
348
- }
349
- }
350
- } else {
351
- foreach ( $share_base_cache_target as $sns => $active ) {
352
- if ( $active ) {
353
- echo '<td class="not-cached share-count">';
354
- _e( 'N/A', self::DOMAIN );
355
- echo '</td>';
356
- }
357
  }
358
  }
359
- }
360
- }
 
361
  ?>
362
- </tr>
363
- <?php
364
- }
365
- if ( $posts_query->have_posts() ) {
366
- while ( $posts_query->have_posts() ) {
367
- $posts_query->the_post();
368
- ?>
369
- <tr>
370
- <td><?php echo $count; ?></td>
371
- <td><a href="<?php echo esc_url( get_permalink( get_the_ID() ) ); ?>" target="_blank"><?php echo esc_html( get_the_title( get_the_ID() ) ); ?></a></td>
372
  <?php
373
- $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( get_the_ID() );
374
-
375
- if ( ! $sort_mode && false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
376
- foreach ( $share_base_cache_target as $sns => $active ) {
377
- if ( $active ) {
378
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
379
- echo '<td class="share-count">';
380
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
381
-
382
- if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) {
383
- //delta
384
- $meta_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( $sns );
385
- $sns_deltas[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
386
-
387
- if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
388
- echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
389
- } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
390
- echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
391
- }
392
- }
393
 
394
- echo '</td>';
395
- } else {
396
- echo '<td class="not-cached share-count">';
397
- _e( 'N/A', self::DOMAIN );
398
- echo '</td>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
399
  }
 
 
 
 
 
 
400
  }
401
  }
402
- } else {
403
- foreach ( $share_base_cache_target as $sns => $active ) {
404
- if( $active ){
405
- $meta_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( $sns );
 
406
 
407
- $sns_counts[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
408
 
409
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] !== '' && $sns_counts[$sns] >= 0 ) {
410
- echo '<td class="share-count">';
411
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
412
 
413
- if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) {
414
- //delta
415
- $meta_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( $sns );
416
- $sns_deltas[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
417
 
418
- if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
419
- echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
420
- } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
421
- echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
422
- }
423
  }
424
-
425
- echo '</td>';
426
- } else {
427
- echo '<td class="not-cached share-count">';
428
- _e( 'N/A', self::DOMAIN );
429
- echo '</td>';
430
  }
 
 
 
 
 
 
431
  }
432
  }
433
  }
434
- ?>
435
- </tr>
436
- <?php
437
- ++$count;
 
438
 
439
- }
440
- }
441
- ?>
442
- </tbody>
443
- </table>
444
- <?php
445
- $this->pagination( $posts_query->max_num_pages, '', $paged, true );
446
- wp_reset_postdata();
447
  ?>
448
- </div>
 
 
 
 
 
449
  </div>
450
  </div>
451
  </div>
452
  </div>
 
1
  <?php
2
+ /**
3
  admin-share-count.php
4
 
5
  Description: Option page implementation
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ if ( ! defined( 'ABSPATH' ) ) {
31
+ exit(); // Exit if accessed directly
32
+ }
33
 
34
+ $posts_per_page = 50;
35
 
36
+ $sort_mode = false;
37
+ $sort_exec_key = '';
38
 
39
+ if ( isset( $_GET['action'] ) && 'sort' === wp_unslash( $_GET['action'] ) ) {
40
+ if ( current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
41
+ if ( isset( $_GET['key'] ) ) {
42
+ $sort_mode = true;
43
+ $sns = wp_unslash( $_GET['key'] );
44
 
45
+ if ( 'Google' === $sns ) {
46
+ $sns = $sns . '+';
47
+ }
48
 
49
+ $sort_exec_key = $sns;
50
 
51
+ $meta_key = $this->cache_engines[ self::REF_SHARE_2ND ]->get_cache_key( $sns );
 
52
  }
53
  }
54
+ }
55
 
56
+ $paged = 1;
 
 
 
 
 
 
57
 
58
+ if ( isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) && 0 < wp_unslash( $_GET['paged'] ) ) {
59
+ $paged = (int) wp_unslash( $_GET['paged'] );
60
+ } else {
61
+ $paged = 1;
62
+ }
63
+
64
+ $share_base_cache_target = $this->share_base_cache_target ;
65
+ unset( $share_base_cache_target[ self::REF_CRAWL_DATE ] );
66
+
67
+ ?>
68
+ <div class="wrap">
69
+ <h2><a href="admin.php?page=scc-share-count"><?php esc_html_e( 'SNS Count Cache', self::DOMAIN ); ?></a></h2>
70
+ <div class="sns-cnt-cache">
71
+ <h3 class="nav-tab-wrapper">
72
+ <a class="nav-tab" href="admin.php?page=scc-dashboard"><?php esc_html_e( 'Dashboard', self::DOMAIN ); ?></a>
73
+ <a class="nav-tab" href="admin.php?page=scc-cache-status"><?php esc_html_e( 'Cache Status', self::DOMAIN ); ?></a>
74
+ <a class="nav-tab nav-tab-active" href="admin.php?page=scc-share-count"><?php esc_html_e( 'Share Count', self::DOMAIN ); ?></a>
75
+ <?php if ( self::OPT_SHARE_VARIATION_ANALYSIS_NONE !== $this->share_variation_analysis_mode ) { ?>
76
+ <a class="nav-tab" href="admin.php?page=scc-hot-content"><?php esc_html_e( 'Hot Content', self::DOMAIN ); ?></a>
77
+ <?php } ?>
78
+ <a class="nav-tab" href="admin.php?page=scc-setting"><?php esc_html_e( 'Setting', self::DOMAIN ); ?></a>
79
+ <a class="nav-tab" href="admin.php?page=scc-help"><?php esc_html_e( 'Help', self::DOMAIN ); ?></a>
80
+ </h3>
81
+ <div class="metabox-holder">
82
+ <div id="share-each-content" class="postbox">
83
+ <div class="handlediv" title="Click to toggle"><br></div>
84
+ <h3 class="hndle"><span><?php esc_html_e( 'Share Count', self::DOMAIN ); ?></span></h3>
85
+ <div class="inside">
86
+ <?php
87
+ if ( $sort_mode ) {
88
+ $query_args = array(
89
+ 'post_type' => $this->share_base_cache_post_types,
90
+ 'post_status' => 'publish',
91
+ 'posts_per_page' => $posts_per_page,
92
+ 'paged' => $paged,
93
+ 'meta_key' => $meta_key,
94
+ 'orderby' => 'meta_value_num',
95
+ 'update_post_term_cache' => false,
96
+ 'order' => 'DESC',
97
+ );
98
+ } else {
99
+ $query_args = array(
100
+ 'post_type' => $this->share_base_cache_post_types,
101
+ 'post_status' => 'publish',
102
+ 'posts_per_page' => $posts_per_page,
103
+ 'paged' => $paged,
104
+ 'update_post_term_cache' => false,
105
+ );
106
+ }
107
+
108
+ $posts_query = new WP_Query( $query_args );
109
+
110
+ $this->pagination( $posts_query->max_num_pages, '', $paged, true );
111
+ ?>
112
+ <table class="tfloat view-table">
113
+ <thead>
114
+ <tr>
115
+ <th>No.</th>
116
+ <th><?php esc_html_e( 'Content', self::DOMAIN ); ?></th>
117
  <?php
118
+ foreach ( $share_base_cache_target as $sns => $active ) {
119
+ if ( $active ) {
120
+ $sort_key = $sns;
121
 
122
+ if ( self::REF_SHARE_GPLUS === $sort_key ) {
123
+ $sort_key = str_replace( '+', '', $sort_key );
124
+ }
125
 
126
+ $sort_url = 'admin.php?page=scc-share-count&action=sort&key=' . $sort_key;
127
+
128
+ $sns_name = '';
129
+
130
+ switch ( $sns ) {
131
+ case self::REF_SHARE_TWITTER:
132
+ $sns_name = __( 'Twitter', self::DOMAIN );
133
+ break;
134
+ case self::REF_SHARE_FACEBOOK:
135
+ $sns_name = __( 'Facebook', self::DOMAIN );
136
+ break;
137
+ case self::REF_SHARE_GPLUS:
138
+ $sns_name = __( 'Google+', self::DOMAIN );
139
+ break;
140
+ case self::REF_SHARE_POCKET:
141
+ $sns_name = __( 'Pocket', self::DOMAIN );
142
+ break;
143
+ case self::REF_SHARE_HATEBU:
144
+ $sns_name = __( 'Hatebu', self::DOMAIN );
145
+ break;
146
+ case self::REF_SHARE_PINTEREST:
147
+ $sns_name = __( 'Pinterest', self::DOMAIN );
148
+ break;
149
+ case self::REF_SHARE_LINKEDIN:
150
+ $sns_name = __( 'Linkedin', self::DOMAIN );
151
+ break;
152
+ case self::REF_SHARE_TOTAL:
153
+ $sns_name = __( 'Total', self::DOMAIN );
154
+ break;
155
+ }
156
 
157
+ if ( $sns === $sort_exec_key ) {
158
+ echo '<th><a class="sort-exec-key" href="' . esc_url( $sort_url ) . '">' . esc_html( $sns_name ) . '</th>';
159
+ } else {
160
+ echo '<th><a href="' . esc_url( $sort_url ) . '">' . esc_html( $sns_name ) . '</th>';
 
161
  }
162
+ } // End if().
163
+ } // End foreach().
164
  ?>
165
+ </tr>
166
+ </thead>
167
+ <tbody>
168
  <?php
169
+ $count = ( $paged - 1 ) * $posts_per_page + 1;
170
+
171
+ if ( 1 === $paged ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  ?>
173
+ <tr class="home">
174
+ <td><?php echo '-'; ?></td>
175
+ <td><a href="<?php echo esc_url( home_url( '/' ) ); ?>" target="_blank"><?php echo esc_html( bloginfo( 'name' ) ); ?></a></td>
176
  <?php
177
+ if ( self::OPT_SHARE_VARIATION_ANALYSIS_NONE !== $this->share_variation_analysis_mode ) {
178
+ $transient_id = $this->cache_engines[ self::REF_SHARE_BASE ]->get_cache_key( 'home' );
179
 
180
+ $sns_counts = get_transient( $transient_id );
 
181
 
182
+ if ( false !== $sns_counts ) {
183
+ $option_key = $this->analytical_engines[ self::REF_SHARE_ANALYSIS ]->get_delta_key( 'home' );
184
+
185
+ $sns_deltas = get_option( $option_key );
186
+
187
+ if ( false !== $sns_deltas ) {
188
+ foreach ( $share_base_cache_target as $sns => $active ) {
189
+ if ( $active ) {
190
+ if ( SCC_Cache::has_value( $sns_counts[ $sns ] ) && 0 <= $sns_counts[ $sns ] ) {
191
+ echo '<td class="share-count">';
192
+ echo esc_html( number_format( (int) $sns_counts[ $sns ] ) );
193
+
194
+ if ( SCC_Cache::has_value( $sns_deltas[ $sns ] ) && 0 < $sns_deltas[ $sns ] ) {
195
+ echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[ $sns ] ) ) . '</span>)';
196
+ } elseif ( SCC_Cache::has_value( $sns_deltas[ $sns ] ) && 0 > $sns_deltas[ $sns ] ) {
197
+ echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[ $sns ] ) ) . '</span>)';
198
+ }
199
+
200
+ echo '</td>';
201
+ } else {
202
+ echo '<td class="not-cached share-count">';
203
+ esc_html_e( 'N/A', self::DOMAIN );
204
+ echo '</td>';
205
+ }
206
+ }
207
+ }
208
+ } else {
209
+ foreach ( $share_base_cache_target as $sns => $active ) {
210
+ if ( $active ) {
211
+ if ( SCC_Cache::has_value( $sns_counts[ $sns ] ) && 0 <= $sns_counts[ $sns ] ) {
212
+ echo '<td class="share-count">';
213
+ echo esc_html( number_format( (int) $sns_counts[ $sns ] ) );
214
+ echo '</td>';
215
+ } else {
216
+ echo '<td class="not-cached share-count">';
217
+ esc_html_e( 'N/A', self::DOMAIN );
218
+ echo '</td>';
219
+ }
220
+ }
221
+ }
222
+ } // End if().
223
+ } else {
224
+ $option_key = $this->cache_engines[ self::REF_SHARE_2ND ]->get_cache_key( 'home' );
225
+
226
+ $sns_counts = get_option( $option_key );
227
+
228
+ if ( false !== $sns_counts ) {
229
+ $option_key = $this->analytical_engines[ self::REF_SHARE_ANALYSIS ]->get_delta_key( 'home' );
230
+
231
+ $sns_deltas = get_option( $option_key );
232
+
233
+ if ( false !== $sns_deltas ) {
234
  foreach ( $share_base_cache_target as $sns => $active ) {
235
  if ( $active ) {
236
+ if ( SCC_Cache::has_value( $sns_counts[ $sns ] ) && 0 <= $sns_counts[ $sns ] ) {
237
  echo '<td class="share-count">';
238
+ echo esc_html( number_format( (int) $sns_counts[ $sns ] ) );
239
 
240
+ if ( SCC_Cache::has_value( $sns_deltas[ $sns ] ) && 0 < $sns_deltas[ $sns ] ) {
241
+ echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[ $sns ] ) ) . '</span>)';
242
+ } elseif ( SCC_Cache::has_value( $sns_deltas[ $sns ] ) && 0 < $sns_deltas[ $sns ] ) {
243
+ echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[ $sns ] ) ) . '</span>)';
244
  }
245
 
246
  echo '</td>';
247
  } else {
248
  echo '<td class="not-cached share-count">';
249
+ esc_html_e( 'N/A', self::DOMAIN );
250
  echo '</td>';
251
  }
252
  }
254
  } else {
255
  foreach ( $share_base_cache_target as $sns => $active ) {
256
  if ( $active ) {
257
+ if ( SCC_Cache::has_value( $sns_counts[ $sns ] ) && 0 <= $sns_counts[ $sns ] ) {
258
  echo '<td class="share-count">';
259
+ echo esc_html( number_format( (int) $sns_counts[ $sns ] ) );
260
  echo '</td>';
261
  } else {
262
  echo '<td class="not-cached share-count">';
263
+ esc_html_e( 'N/A', self::DOMAIN );
264
  echo '</td>';
265
  }
266
  }
267
  }
268
+ } // End if().
269
  } else {
270
+ foreach ( $share_base_cache_target as $sns => $active ) {
271
+ if ( $active ) {
272
+ echo '<td class="not-cached share-count">';
273
+ esc_html_e( 'N/A', self::DOMAIN );
274
+ echo '</td>';
275
+ }
276
+ }
277
+ } // End if().
278
+ } // End if().
279
+ } else {
280
+ $transient_id = $this->cache_engines[ self::REF_SHARE_BASE ]->get_cache_key( 'home' );
281
+
282
+ $sns_counts = get_transient( $transient_id );
283
+
284
+ if ( false !== $sns_counts ) {
285
+ $option_key = $this->analytical_engines[ self::REF_SHARE_ANALYSIS ]->get_delta_key( 'home' );
286
+
287
+ $sns_deltas = get_option( $option_key );
288
+
289
+ if ( false !== $sns_deltas ) {
290
+ foreach ( $share_base_cache_target as $sns => $active ) {
291
+ if ( $active ) {
292
+ if ( SCC_Cache::has_value( $sns_counts[ $sns ] ) && 0 <= $sns_counts[ $sns ] ) {
293
+ echo '<td class="share-count">';
294
+ echo esc_html( number_format( (int) $sns_counts[ $sns ] ) );
295
+
296
+ if ( SCC_Cache::has_value( $sns_deltas[ $sns ] ) && 0 < $sns_deltas[ $sns ] ) {
297
+ echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[ $sns ] ) ) . '</span>)';
298
+ } elseif ( SCC_Cache::has_value( $sns_deltas[ $sns ] ) && 0 > $sns_deltas[ $sns ] ) {
299
+ echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[ $sns ] ) ) . '</span>)';
 
 
 
 
 
 
 
 
300
  }
301
+
302
+ echo '</td>';
303
+ } else {
304
+ echo '<td class="not-cached share-count">';
305
+ esc_html_e( 'N/A', self::DOMAIN );
306
+ echo '</td>';
307
  }
308
  }
309
+ }
310
+ } else {
311
+ foreach ( $share_base_cache_target as $sns => $active ) {
312
+ if ( $active ) {
313
+ if ( SCC_Cache::has_value( $sns_counts[ $sns ] ) && 0 <= $sns_counts[ $sns ] ) {
314
+ echo '<td class="share-count">';
315
+ echo esc_html( number_format( (int) $sns_counts[ $sns ] ) );
316
+ echo '</td>';
317
+ } else {
318
  echo '<td class="not-cached share-count">';
319
+ esc_html_e( 'N/A', self::DOMAIN );
320
  echo '</td>';
321
  }
322
  }
323
  }
324
+ } // End if().
325
  } else {
326
+ $option_key = $this->cache_engines[ self::REF_SHARE_2ND ]->get_cache_key( 'home' );
327
 
328
+ $sns_counts = get_option( $option_key );
 
329
 
330
+ if ( false !== $sns_counts ) {
331
+ $option_key = $this->analytical_engines[ self::REF_SHARE_ANALYSIS ]->get_delta_key( 'home' );
332
+
333
+ $sns_deltas = get_option( $option_key );
334
+
335
+ if ( false !== $sns_deltas ) {
336
  foreach ( $share_base_cache_target as $sns => $active ) {
337
  if ( $active ) {
338
+ if ( SCC_Cache::has_value( $sns_counts[ $sns ] ) && 0 <= $sns_counts[ $sns ] ) {
339
  echo '<td class="share-count">';
340
+ echo esc_html( number_format( (int) $sns_counts[ $sns ] ) );
341
 
342
+ if ( SCC_Cache::has_value( $sns_deltas[ $sns ] ) && 0 < $sns_deltas[ $sns ] ) {
343
+ echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[ $sns ] ) ) . '</span>)';
344
+ } elseif ( SCC_Cache::has_value( $sns_deltas[ $sns ] ) && 0 > $sns_deltas[ $sns ] ) {
345
+ echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[ $sns ] ) ) . '</span>)';
346
  }
347
 
348
  echo '</td>';
349
  } else {
350
  echo '<td class="not-cached share-count">';
351
+ esc_html_e( 'N/A', self::DOMAIN );
352
  echo '</td>';
353
  }
354
  }
356
  } else {
357
  foreach ( $share_base_cache_target as $sns => $active ) {
358
  if ( $active ) {
359
+ if ( SCC_Cache::has_value( $sns_counts[ $sns ] ) && 0 <= $sns_counts[ $sns ] ) {
360
  echo '<td class="share-count">';
361
+ echo esc_html( number_format( (int) $sns_counts[ $sns ] ) );
362
  echo '</td>';
363
  } else {
364
  echo '<td class="not-cached share-count">';
365
+ esc_html_e( 'N/A', self::DOMAIN );
366
  echo '</td>';
367
  }
368
  }
369
  }
370
+ } // End if().
371
  } else {
372
+ foreach ( $share_base_cache_target as $sns => $active ) {
373
+ if ( $active ) {
374
+ echo '<td class="not-cached share-count">';
375
+ esc_html_e( 'N/A', self::DOMAIN );
376
+ echo '</td>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
377
  }
378
  }
379
+ } // End if().
380
+ } // End if().
381
+ } // End if().
382
  ?>
383
+ </tr>
384
+ <?php
385
+ } // End if().
386
+ if ( $posts_query->have_posts() ) {
387
+ while ( $posts_query->have_posts() ) {
388
+ $posts_query->the_post();
389
+ ?>
390
+ <tr>
391
+ <td><?php echo esc_html( $count ); ?></td>
392
+ <td><a href="<?php echo esc_url( get_permalink( get_the_ID() ) ); ?>" target="_blank"><?php echo esc_html( get_the_title( get_the_ID() ) ); ?></a></td>
393
  <?php
394
+ $transient_id = $this->cache_engines[ self::REF_SHARE_BASE ]->get_cache_key( get_the_ID() );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
395
 
396
+ $sns_counts = get_transient( $transient_id );
397
+
398
+ if ( ! $sort_mode && false !== $sns_counts ) {
399
+ foreach ( $share_base_cache_target as $sns => $active ) {
400
+ if ( $active ) {
401
+ if ( SCC_Cache::has_value( $sns_counts[ $sns ] ) && 0 <= $sns_counts[ $sns ] ) {
402
+ echo '<td class="share-count">';
403
+ echo esc_html( number_format( (int) $sns_counts[ $sns ] ) );
404
+
405
+ if ( self::OPT_SHARE_VARIATION_ANALYSIS_NONE !== $this->share_variation_analysis_mode ) {
406
+ // delta
407
+ $meta_key = $this->analytical_engines[ self::REF_SHARE_ANALYSIS ]->get_delta_key( $sns );
408
+ $sns_deltas[ $sns ] = get_post_meta( get_the_ID(), $meta_key, true );
409
+
410
+ if ( SCC_Cache::has_value( $sns_deltas[ $sns ] ) && 0 < $sns_deltas[ $sns ] ) {
411
+ echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[ $sns ] ) ) . '</span>)';
412
+ } elseif ( SCC_Cache::has_value( $sns_deltas[ $sns ] ) && 0 > $sns_deltas[ $sns ] ) {
413
+ echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[ $sns ] ) ) . '</span>)';
414
+ }
415
  }
416
+
417
+ echo '</td>';
418
+ } else {
419
+ echo '<td class="not-cached share-count">';
420
+ esc_html_e( 'N/A', self::DOMAIN );
421
+ echo '</td>';
422
  }
423
  }
424
+ }
425
+ } else {
426
+ foreach ( $share_base_cache_target as $sns => $active ) {
427
+ if ( $active ) {
428
+ $meta_key = $this->cache_engines[ self::REF_SHARE_2ND ]->get_cache_key( $sns );
429
 
430
+ $sns_counts[ $sns ] = get_post_meta( get_the_ID(), $meta_key, true );
431
 
432
+ if ( SCC_Cache::has_value( $sns_counts[ $sns ] ) && 0 <= $sns_counts[ $sns ] ) {
433
+ echo '<td class="share-count">';
434
+ echo esc_html( number_format( (int) $sns_counts[ $sns ] ) );
435
 
436
+ if ( self::OPT_SHARE_VARIATION_ANALYSIS_NONE !== $this->share_variation_analysis_mode ) {
437
+ //delta
438
+ $meta_key = $this->analytical_engines[ self::REF_SHARE_ANALYSIS ]->get_delta_key( $sns );
439
+ $sns_deltas[ $sns ] = get_post_meta( get_the_ID(), $meta_key, true );
440
 
441
+ if ( SCC_Cache::has_value( $sns_deltas[ $sns ] ) && 0 < $sns_deltas[ $sns ] ) {
442
+ echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[ $sns ] ) ) . '</span>)';
443
+ } elseif ( SCC_Cache::has_value( $sns_deltas[ $sns ] ) && 0 > $sns_deltas[ $sns ] ) {
444
+ echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[ $sns ] ) ) . '</span>)';
 
445
  }
 
 
 
 
 
 
446
  }
447
+
448
+ echo '</td>';
449
+ } else {
450
+ echo '<td class="not-cached share-count">';
451
+ esc_html_e( 'N/A', self::DOMAIN );
452
+ echo '</td>';
453
  }
454
  }
455
  }
456
+ } // End if().
457
+ ?>
458
+ </tr>
459
+ <?php
460
+ ++$count;
461
 
462
+ } // End while().
463
+ } // End if().
 
 
 
 
 
 
464
  ?>
465
+ </tbody>
466
+ </table>
467
+ <?php
468
+ $this->pagination( $posts_query->max_num_pages, '', $paged, true );
469
+ wp_reset_postdata();
470
+ ?>
471
  </div>
472
  </div>
473
  </div>
474
  </div>
475
+ </div>
includes/class-crypt-blowfish.php DELETED
@@ -1,272 +0,0 @@
1
- <?php
2
- /**
3
- * Crypt_Blowfish allows for encryption and decryption on the fly using
4
- * the Blowfish algorithm. Crypt_Blowfish does not require the mcrypt
5
- * PHP extension, it uses only PHP.
6
- * Crypt_Blowfish support encryption/decryption with or without a secret key.
7
- *
8
- * PHP versions 4 and 5
9
- *
10
- * @category Encryption
11
- * @package Crypt_Blowfish
12
- * @author Matthew Fonda <mfonda@php.net>
13
- * @copyright 2005 Matthew Fonda
14
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
15
- * @version CVS: $Id: Blowfish.php,v 1.81 2005/05/30 18:40:36 mfonda Exp $
16
- * @link http://pear.php.net/package/Crypt_Blowfish
17
- */
18
-
19
- /**
20
- *
21
- * Example usage:
22
- * $bf = new Crypt_Blowfish('some secret key!');
23
- * $encrypted = $bf->encrypt('this is some example plain text');
24
- * $plaintext = $bf->decrypt($encrypted);
25
- * echo "plain text: $plaintext";
26
- *
27
- *
28
- * @category Encryption
29
- * @package Crypt_Blowfish
30
- * @author Matthew Fonda <mfonda@php.net>
31
- * @copyright 2005 Matthew Fonda
32
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
33
- * @link http://pear.php.net/package/Crypt_Blowfish
34
- * @version @package_version@
35
- * @access public
36
- */
37
-
38
- class Crypt_Blowfish {
39
-
40
- /**
41
- * P-Array contains 18 32-bit subkeys
42
- *
43
- * @var array
44
- * @access private
45
- */
46
- private $_P = array();
47
-
48
- /**
49
- * Array of four S-Blocks each containing 256 32-bit entries
50
- *
51
- * @var array
52
- * @access private
53
- */
54
- private $_S = array();
55
-
56
- /**
57
- * Crypt_Blowfish Constructor
58
- * Initializes the Crypt_Blowfish object, and gives a sets
59
- * the secret key
60
- *
61
- * @param string $key
62
- * @access public
63
- */
64
- public function __construct( $key ) {
65
- $this->setKey( $key );
66
- }
67
-
68
- /**
69
- * Deprecated isReady method
70
- *
71
- * @return bool
72
- * @access public
73
- * @deprecated
74
- */
75
- public function isReady() {
76
- return true;
77
- }
78
-
79
- /**
80
- * Deprecated init method - init is now a private
81
- * method and has been replaced with _init
82
- *
83
- * @return bool
84
- * @access public
85
- * @deprecated
86
- * @see Crypt_Blowfish::_init()
87
- */
88
- public function init() {
89
- $this->_init();
90
- }
91
-
92
- /**
93
- * Initializes the Crypt_Blowfish object
94
- *
95
- * @access private
96
- */
97
- private function _init() {
98
- $defaults = new Crypt_Blowfish_DefaultKey();
99
- $this->_P = $defaults->P;
100
- $this->_S = $defaults->S;
101
- }
102
-
103
- /**
104
- * Enciphers a single 64 bit block
105
- *
106
- * @param int &$Xl
107
- * @param int &$Xr
108
- * @access private
109
- */
110
- private function _encipher( &$Xl, &$Xr ) {
111
- for ( $i = 0; $i < 16; $i++ ) {
112
- $temp = $Xl ^ $this->_P[$i];
113
- $Xl = ((($this->_S[0][($temp>>24) & 255] +
114
- $this->_S[1][($temp>>16) & 255]) ^
115
- $this->_S[2][($temp>>8) & 255]) +
116
- $this->_S[3][$temp & 255]) ^ $Xr;
117
- $Xr = $temp;
118
- }
119
- $Xr = $Xl ^ $this->_P[16];
120
- $Xl = $temp ^ $this->_P[17];
121
- }
122
-
123
- /**
124
- * Deciphers a single 64 bit block
125
- *
126
- * @param int &$Xl
127
- * @param int &$Xr
128
- * @access private
129
- */
130
- private function _decipher( &$Xl, &$Xr ) {
131
- for ( $i = 17; $i > 1; $i-- ) {
132
- $temp = $Xl ^ $this->_P[$i];
133
- $Xl = ((($this->_S[0][($temp>>24) & 255] +
134
- $this->_S[1][($temp>>16) & 255]) ^
135
- $this->_S[2][($temp>>8) & 255]) +
136
- $this->_S[3][$temp & 255]) ^ $Xr;
137
- $Xr = $temp;
138
- }
139
- $Xr = $Xl ^ $this->_P[1];
140
- $Xl = $temp ^ $this->_P[0];
141
- }
142
-
143
-
144
- /**
145
- * Encrypts a string
146
- *
147
- * @param string $plainText
148
- * @return string Returns cipher text on success, PEAR_Error on failure
149
- * @access public
150
- */
151
- public function encrypt( $plainText ) {
152
- if ( ! is_string( $plainText ) ) {
153
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ') : Plain text must be a string' );
154
- //PEAR::raiseError('Plain text must be a string', 0, PEAR_ERROR_DIE);
155
- die();
156
- }
157
-
158
- $cipherText = '';
159
- $len = strlen( $plainText );
160
- $plainText .= str_repeat(chr(0),(8 - ($len%8))%8);
161
- for ( $i = 0; $i < $len; $i += 8 ) {
162
- list( , $Xl, $Xr ) = unpack( "N2",substr( $plainText,$i, 8 ) );
163
- $this->_encipher( $Xl, $Xr );
164
- $cipherText .= pack( "N2", $Xl, $Xr );
165
- }
166
- return base64_encode( $cipherText) ;
167
- }
168
-
169
-
170
- /**
171
- * Decrypts an encrypted string
172
- *
173
- * @param string $cipherText
174
- * @return string Returns plain text on success, PEAR_Error on failure
175
- * @access public
176
- */
177
- public function decrypt( $cipherText ) {
178
- if ( ! is_string( $cipherText ) ) {
179
- //PEAR::raiseError('Chiper text must be a string', 1, PEAR_ERROR_DIE);
180
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ') : Chiper text must be a string' );
181
- die();
182
- }
183
-
184
- $cipherText = base64_decode( $cipherText );
185
-
186
- $plainText = '';
187
- $len = strlen( $cipherText );
188
- $cipherText .= str_repeat( chr(0), (8 - ($len%8))%8 );
189
- for ( $i = 0; $i < $len; $i += 8 ) {
190
- list( , $Xl, $Xr ) = unpack( "N2", substr( $cipherText, $i, 8 ) );
191
- $this->_decipher( $Xl, $Xr );
192
- $plainText .= pack( "N2", $Xl, $Xr );
193
- }
194
- return $plainText;
195
- }
196
-
197
-
198
- /**
199
- * Sets the secret key
200
- * The key must be non-zero, and less than or equal to
201
- * 56 characters in length.
202
- *
203
- * @param string $key
204
- * @return bool Returns true on success, PEAR_Error on failure
205
- * @access public
206
- */
207
- public function setKey( $key ) {
208
- if ( ! is_string( $key ) ) {
209
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ') : Key must be a string' );
210
- //PEAR::raiseError('Key must be a string', 2, PEAR_ERROR_DIE);
211
- die();
212
- }
213
-
214
- $key = substr( md5( $key ), 0, 55 );
215
-
216
- $len = strlen( $key );
217
-
218
- if ( $len > 56 || $len == 0 ) {
219
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ') : Key must be less than 56 characters and non-zero' );
220
- //PEAR::raiseError('Key must be less than 56 characters and non-zero. Supplied key length: ' . $len, 3, PEAR_ERROR_DIE);
221
- die();
222
- }
223
-
224
- require_once 'class-default-key.php';
225
- $this->_init();
226
-
227
- $k = 0;
228
- $data = 0;
229
- $datal = 0;
230
- $datar = 0;
231
-
232
- for ( $i = 0; $i < 18; $i++ ) {
233
- $data = 0;
234
- for ( $j = 4; $j > 0; $j-- ) {
235
- $data = $data << 8 | ord($key{$k});
236
- $k = ($k+1) % $len;
237
- }
238
- $this->_P[$i] ^= $data;
239
- }
240
-
241
- for ( $i = 0; $i <= 16; $i += 2 ) {
242
- $this->_encipher($datal, $datar);
243
- $this->_P[$i] = $datal;
244
- $this->_P[$i+1] = $datar;
245
- }
246
- for ( $i = 0; $i < 256; $i += 2 ) {
247
- $this->_encipher($datal, $datar);
248
- $this->_S[0][$i] = $datal;
249
- $this->_S[0][$i+1] = $datar;
250
- }
251
- for ( $i = 0; $i < 256; $i += 2 ) {
252
- $this->_encipher($datal, $datar);
253
- $this->_S[1][$i] = $datal;
254
- $this->_S[1][$i+1] = $datar;
255
- }
256
- for ($i = 0; $i < 256; $i += 2) {
257
- $this->_encipher($datal, $datar);
258
- $this->_S[2][$i] = $datal;
259
- $this->_S[2][$i+1] = $datar;
260
- }
261
- for ( $i = 0; $i < 256; $i += 2 ) {
262
- $this->_encipher($datal, $datar);
263
- $this->_S[3][$i] = $datal;
264
- $this->_S[3][$i+1] = $datar;
265
- }
266
-
267
- return true;
268
- }
269
-
270
- }
271
-
272
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-default-key.php DELETED
@@ -1,319 +0,0 @@
1
- <?php
2
- /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
-
4
- /**
5
- * Crypt_Blowfish allows for encryption and decryption on the fly using
6
- * the Blowfish algorithm. Crypt_Blowfish does not require the mcrypt
7
- * PHP extension, it uses only PHP.
8
- * Crypt_Blowfish support encryption/decryption with or without a secret key.
9
- *
10
- *
11
- * PHP versions 4 and 5
12
- *
13
- *
14
- * @category Encryption
15
- * @package Crypt_Blowfish
16
- * @author Matthew Fonda <mfonda@php.net>
17
- * @copyright 2005 Matthew Fonda
18
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
19
- * @version CVS: $Id: DefaultKey.php,v 1.81 2005/05/30 18:40:37 mfonda Exp $
20
- * @link http://pear.php.net/package/Crypt_Blowfish
21
- */
22
-
23
- /**
24
- * Class containing default key
25
- *
26
- * @category Encryption
27
- * @package Crypt_Blowfish
28
- * @author Matthew Fonda <mfonda@php.net>
29
- * @copyright 2005 Matthew Fonda
30
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
31
- * @link http://pear.php.net/package/Crypt_Blowfish
32
- * @version @package_version@
33
- * @access public
34
- */
35
- class Crypt_Blowfish_DefaultKey {
36
- public $P = array();
37
-
38
- public $S = array();
39
-
40
- public function __construct() {
41
- $this->P = array(
42
- 0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344,
43
- 0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89,
44
- 0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C,
45
- 0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917,
46
- 0x9216D5D9, 0x8979FB1B
47
- );
48
-
49
- $this->S = array(
50
- array(
51
- 0xD1310BA6, 0x98DFB5AC, 0x2FFD72DB, 0xD01ADFB7,
52
- 0xB8E1AFED, 0x6A267E96, 0xBA7C9045, 0xF12C7F99,
53
- 0x24A19947, 0xB3916CF7, 0x0801F2E2, 0x858EFC16,
54
- 0x636920D8, 0x71574E69, 0xA458FEA3, 0xF4933D7E,
55
- 0x0D95748F, 0x728EB658, 0x718BCD58, 0x82154AEE,
56
- 0x7B54A41D, 0xC25A59B5, 0x9C30D539, 0x2AF26013,
57
- 0xC5D1B023, 0x286085F0, 0xCA417918, 0xB8DB38EF,
58
- 0x8E79DCB0, 0x603A180E, 0x6C9E0E8B, 0xB01E8A3E,
59
- 0xD71577C1, 0xBD314B27, 0x78AF2FDA, 0x55605C60,
60
- 0xE65525F3, 0xAA55AB94, 0x57489862, 0x63E81440,
61
- 0x55CA396A, 0x2AAB10B6, 0xB4CC5C34, 0x1141E8CE,
62
- 0xA15486AF, 0x7C72E993, 0xB3EE1411, 0x636FBC2A,
63
- 0x2BA9C55D, 0x741831F6, 0xCE5C3E16, 0x9B87931E,
64
- 0xAFD6BA33, 0x6C24CF5C, 0x7A325381, 0x28958677,
65
- 0x3B8F4898, 0x6B4BB9AF, 0xC4BFE81B, 0x66282193,
66
- 0x61D809CC, 0xFB21A991, 0x487CAC60, 0x5DEC8032,
67
- 0xEF845D5D, 0xE98575B1, 0xDC262302, 0xEB651B88,
68
- 0x23893E81, 0xD396ACC5, 0x0F6D6FF3, 0x83F44239,
69
- 0x2E0B4482, 0xA4842004, 0x69C8F04A, 0x9E1F9B5E,
70
- 0x21C66842, 0xF6E96C9A, 0x670C9C61, 0xABD388F0,
71
- 0x6A51A0D2, 0xD8542F68, 0x960FA728, 0xAB5133A3,
72
- 0x6EEF0B6C, 0x137A3BE4, 0xBA3BF050, 0x7EFB2A98,
73
- 0xA1F1651D, 0x39AF0176, 0x66CA593E, 0x82430E88,
74
- 0x8CEE8619, 0x456F9FB4, 0x7D84A5C3, 0x3B8B5EBE,
75
- 0xE06F75D8, 0x85C12073, 0x401A449F, 0x56C16AA6,
76
- 0x4ED3AA62, 0x363F7706, 0x1BFEDF72, 0x429B023D,
77
- 0x37D0D724, 0xD00A1248, 0xDB0FEAD3, 0x49F1C09B,
78
- 0x075372C9, 0x80991B7B, 0x25D479D8, 0xF6E8DEF7,
79
- 0xE3FE501A, 0xB6794C3B, 0x976CE0BD, 0x04C006BA,
80
- 0xC1A94FB6, 0x409F60C4, 0x5E5C9EC2, 0x196A2463,
81
- 0x68FB6FAF, 0x3E6C53B5, 0x1339B2EB, 0x3B52EC6F,
82
- 0x6DFC511F, 0x9B30952C, 0xCC814544, 0xAF5EBD09,
83
- 0xBEE3D004, 0xDE334AFD, 0x660F2807, 0x192E4BB3,
84
- 0xC0CBA857, 0x45C8740F, 0xD20B5F39, 0xB9D3FBDB,
85
- 0x5579C0BD, 0x1A60320A, 0xD6A100C6, 0x402C7279,
86
- 0x679F25FE, 0xFB1FA3CC, 0x8EA5E9F8, 0xDB3222F8,
87
- 0x3C7516DF, 0xFD616B15, 0x2F501EC8, 0xAD0552AB,
88
- 0x323DB5FA, 0xFD238760, 0x53317B48, 0x3E00DF82,
89
- 0x9E5C57BB, 0xCA6F8CA0, 0x1A87562E, 0xDF1769DB,
90
- 0xD542A8F6, 0x287EFFC3, 0xAC6732C6, 0x8C4F5573,
91
- 0x695B27B0, 0xBBCA58C8, 0xE1FFA35D, 0xB8F011A0,
92
- 0x10FA3D98, 0xFD2183B8, 0x4AFCB56C, 0x2DD1D35B,
93
- 0x9A53E479, 0xB6F84565, 0xD28E49BC, 0x4BFB9790,
94
- 0xE1DDF2DA, 0xA4CB7E33, 0x62FB1341, 0xCEE4C6E8,
95
- 0xEF20CADA, 0x36774C01, 0xD07E9EFE, 0x2BF11FB4,
96
- 0x95DBDA4D, 0xAE909198, 0xEAAD8E71, 0x6B93D5A0,
97
- 0xD08ED1D0, 0xAFC725E0, 0x8E3C5B2F, 0x8E7594B7,
98
- 0x8FF6E2FB, 0xF2122B64, 0x8888B812, 0x900DF01C,
99
- 0x4FAD5EA0, 0x688FC31C, 0xD1CFF191, 0xB3A8C1AD,
100
- 0x2F2F2218, 0xBE0E1777, 0xEA752DFE, 0x8B021FA1,
101
- 0xE5A0CC0F, 0xB56F74E8, 0x18ACF3D6, 0xCE89E299,
102
- 0xB4A84FE0, 0xFD13E0B7, 0x7CC43B81, 0xD2ADA8D9,
103
- 0x165FA266, 0x80957705, 0x93CC7314, 0x211A1477,
104
- 0xE6AD2065, 0x77B5FA86, 0xC75442F5, 0xFB9D35CF,
105
- 0xEBCDAF0C, 0x7B3E89A0, 0xD6411BD3, 0xAE1E7E49,
106
- 0x00250E2D, 0x2071B35E, 0x226800BB, 0x57B8E0AF,
107
- 0x2464369B, 0xF009B91E, 0x5563911D, 0x59DFA6AA,
108
- 0x78C14389, 0xD95A537F, 0x207D5BA2, 0x02E5B9C5,
109
- 0x83260376, 0x6295CFA9, 0x11C81968, 0x4E734A41,
110
- 0xB3472DCA, 0x7B14A94A, 0x1B510052, 0x9A532915,
111
- 0xD60F573F, 0xBC9BC6E4, 0x2B60A476, 0x81E67400,
112
- 0x08BA6FB5, 0x571BE91F, 0xF296EC6B, 0x2A0DD915,
113
- 0xB6636521, 0xE7B9F9B6, 0xFF34052E, 0xC5855664,
114
- 0x53B02D5D, 0xA99F8FA1, 0x08BA4799, 0x6E85076A
115
- ),
116
- array(
117
- 0x4B7A70E9, 0xB5B32944, 0xDB75092E, 0xC4192623,
118
- 0xAD6EA6B0, 0x49A7DF7D, 0x9CEE60B8, 0x8FEDB266,
119
- 0xECAA8C71, 0x699A17FF, 0x5664526C, 0xC2B19EE1,
120
- 0x193602A5, 0x75094C29, 0xA0591340, 0xE4183A3E,
121
- 0x3F54989A, 0x5B429D65, 0x6B8FE4D6, 0x99F73FD6,
122
- 0xA1D29C07, 0xEFE830F5, 0x4D2D38E6, 0xF0255DC1,
123
- 0x4CDD2086, 0x8470EB26, 0x6382E9C6, 0x021ECC5E,
124
- 0x09686B3F, 0x3EBAEFC9, 0x3C971814, 0x6B6A70A1,
125
- 0x687F3584, 0x52A0E286, 0xB79C5305, 0xAA500737,
126
- 0x3E07841C, 0x7FDEAE5C, 0x8E7D44EC, 0x5716F2B8,
127
- 0xB03ADA37, 0xF0500C0D, 0xF01C1F04, 0x0200B3FF,
128
- 0xAE0CF51A, 0x3CB574B2, 0x25837A58, 0xDC0921BD,
129
- 0xD19113F9, 0x7CA92FF6, 0x94324773, 0x22F54701,
130
- 0x3AE5E581, 0x37C2DADC, 0xC8B57634, 0x9AF3DDA7,
131
- 0xA9446146, 0x0FD0030E, 0xECC8C73E, 0xA4751E41,
132
- 0xE238CD99, 0x3BEA0E2F, 0x3280BBA1, 0x183EB331,
133
- 0x4E548B38, 0x4F6DB908, 0x6F420D03, 0xF60A04BF,
134
- 0x2CB81290, 0x24977C79, 0x5679B072, 0xBCAF89AF,
135
- 0xDE9A771F, 0xD9930810, 0xB38BAE12, 0xDCCF3F2E,
136
- 0x5512721F, 0x2E6B7124, 0x501ADDE6, 0x9F84CD87,
137
- 0x7A584718, 0x7408DA17, 0xBC9F9ABC, 0xE94B7D8C,
138
- 0xEC7AEC3A, 0xDB851DFA, 0x63094366, 0xC464C3D2,
139
- 0xEF1C1847, 0x3215D908, 0xDD433B37, 0x24C2BA16,
140
- 0x12A14D43, 0x2A65C451, 0x50940002, 0x133AE4DD,
141
- 0x71DFF89E, 0x10314E55, 0x81AC77D6, 0x5F11199B,
142
- 0x043556F1, 0xD7A3C76B, 0x3C11183B, 0x5924A509,
143
- 0xF28FE6ED, 0x97F1FBFA, 0x9EBABF2C, 0x1E153C6E,
144
- 0x86E34570, 0xEAE96FB1, 0x860E5E0A, 0x5A3E2AB3,
145
- 0x771FE71C, 0x4E3D06FA, 0x2965DCB9, 0x99E71D0F,
146
- 0x803E89D6, 0x5266C825, 0x2E4CC978, 0x9C10B36A,
147
- 0xC6150EBA, 0x94E2EA78, 0xA5FC3C53, 0x1E0A2DF4,
148
- 0xF2F74EA7, 0x361D2B3D, 0x1939260F, 0x19C27960,
149
- 0x5223A708, 0xF71312B6, 0xEBADFE6E, 0xEAC31F66,
150
- 0xE3BC4595, 0xA67BC883, 0xB17F37D1, 0x018CFF28,
151
- 0xC332DDEF, 0xBE6C5AA5, 0x65582185, 0x68AB9802,
152
- 0xEECEA50F, 0xDB2F953B, 0x2AEF7DAD, 0x5B6E2F84,
153
- 0x1521B628, 0x29076170, 0xECDD4775, 0x619F1510,
154
- 0x13CCA830, 0xEB61BD96, 0x0334FE1E, 0xAA0363CF,
155
- 0xB5735C90, 0x4C70A239, 0xD59E9E0B, 0xCBAADE14,
156
- 0xEECC86BC, 0x60622CA7, 0x9CAB5CAB, 0xB2F3846E,
157
- 0x648B1EAF, 0x19BDF0CA, 0xA02369B9, 0x655ABB50,
158
- 0x40685A32, 0x3C2AB4B3, 0x319EE9D5, 0xC021B8F7,
159
- 0x9B540B19, 0x875FA099, 0x95F7997E, 0x623D7DA8,
160
- 0xF837889A, 0x97E32D77, 0x11ED935F, 0x16681281,
161
- 0x0E358829, 0xC7E61FD6, 0x96DEDFA1, 0x7858BA99,
162
- 0x57F584A5, 0x1B227263, 0x9B83C3FF, 0x1AC24696,
163
- 0xCDB30AEB, 0x532E3054, 0x8FD948E4, 0x6DBC3128,
164
- 0x58EBF2EF, 0x34C6FFEA, 0xFE28ED61, 0xEE7C3C73,
165
- 0x5D4A14D9, 0xE864B7E3, 0x42105D14, 0x203E13E0,
166
- 0x45EEE2B6, 0xA3AAABEA, 0xDB6C4F15, 0xFACB4FD0,
167
- 0xC742F442, 0xEF6ABBB5, 0x654F3B1D, 0x41CD2105,
168
- 0xD81E799E, 0x86854DC7, 0xE44B476A, 0x3D816250,
169
- 0xCF62A1F2, 0x5B8D2646, 0xFC8883A0, 0xC1C7B6A3,
170
- 0x7F1524C3, 0x69CB7492, 0x47848A0B, 0x5692B285,
171
- 0x095BBF00, 0xAD19489D, 0x1462B174, 0x23820E00,
172
- 0x58428D2A, 0x0C55F5EA, 0x1DADF43E, 0x233F7061,
173
- 0x3372F092, 0x8D937E41, 0xD65FECF1, 0x6C223BDB,
174
- 0x7CDE3759, 0xCBEE7460, 0x4085F2A7, 0xCE77326E,
175
- 0xA6078084, 0x19F8509E, 0xE8EFD855, 0x61D99735,
176
- 0xA969A7AA, 0xC50C06C2, 0x5A04ABFC, 0x800BCADC,
177
- 0x9E447A2E, 0xC3453484, 0xFDD56705, 0x0E1E9EC9,
178
- 0xDB73DBD3, 0x105588CD, 0x675FDA79, 0xE3674340,
179
- 0xC5C43465, 0x713E38D8, 0x3D28F89E, 0xF16DFF20,
180
- 0x153E21E7, 0x8FB03D4A, 0xE6E39F2B, 0xDB83ADF7
181
- ),
182
- array(
183
- 0xE93D5A68, 0x948140F7, 0xF64C261C, 0x94692934,
184
- 0x411520F7, 0x7602D4F7, 0xBCF46B2E, 0xD4A20068,
185
- 0xD4082471, 0x3320F46A, 0x43B7D4B7, 0x500061AF,
186
- 0x1E39F62E, 0x97244546, 0x14214F74, 0xBF8B8840,
187
- 0x4D95FC1D, 0x96B591AF, 0x70F4DDD3, 0x66A02F45,
188
- 0xBFBC09EC, 0x03BD9785, 0x7FAC6DD0, 0x31CB8504,
189
- 0x96EB27B3, 0x55FD3941, 0xDA2547E6, 0xABCA0A9A,
190
- 0x28507825, 0x530429F4, 0x0A2C86DA, 0xE9B66DFB,
191
- 0x68DC1462, 0xD7486900, 0x680EC0A4, 0x27A18DEE,
192
- 0x4F3FFEA2, 0xE887AD8C, 0xB58CE006, 0x7AF4D6B6,
193
- 0xAACE1E7C, 0xD3375FEC, 0xCE78A399, 0x406B2A42,
194
- 0x20FE9E35, 0xD9F385B9, 0xEE39D7AB, 0x3B124E8B,
195
- 0x1DC9FAF7, 0x4B6D1856, 0x26A36631, 0xEAE397B2,
196
- 0x3A6EFA74, 0xDD5B4332, 0x6841E7F7, 0xCA7820FB,
197
- 0xFB0AF54E, 0xD8FEB397, 0x454056AC, 0xBA489527,
198
- 0x55533A3A, 0x20838D87, 0xFE6BA9B7, 0xD096954B,
199
- 0x55A867BC, 0xA1159A58, 0xCCA92963, 0x99E1DB33,
200
- 0xA62A4A56, 0x3F3125F9, 0x5EF47E1C, 0x9029317C,
201
- 0xFDF8E802, 0x04272F70, 0x80BB155C, 0x05282CE3,
202
- 0x95C11548, 0xE4C66D22, 0x48C1133F, 0xC70F86DC,
203
- 0x07F9C9EE, 0x41041F0F, 0x404779A4, 0x5D886E17,
204
- 0x325F51EB, 0xD59BC0D1, 0xF2BCC18F, 0x41113564,
205
- 0x257B7834, 0x602A9C60, 0xDFF8E8A3, 0x1F636C1B,
206
- 0x0E12B4C2, 0x02E1329E, 0xAF664FD1, 0xCAD18115,
207
- 0x6B2395E0, 0x333E92E1, 0x3B240B62, 0xEEBEB922,
208
- 0x85B2A20E, 0xE6BA0D99, 0xDE720C8C, 0x2DA2F728,
209
- 0xD0127845, 0x95B794FD, 0x647D0862, 0xE7CCF5F0,
210
- 0x5449A36F, 0x877D48FA, 0xC39DFD27, 0xF33E8D1E,
211
- 0x0A476341, 0x992EFF74, 0x3A6F6EAB, 0xF4F8FD37,
212
- 0xA812DC60, 0xA1EBDDF8, 0x991BE14C, 0xDB6E6B0D,
213
- 0xC67B5510, 0x6D672C37, 0x2765D43B, 0xDCD0E804,
214
- 0xF1290DC7, 0xCC00FFA3, 0xB5390F92, 0x690FED0B,
215
- 0x667B9FFB, 0xCEDB7D9C, 0xA091CF0B, 0xD9155EA3,
216
- 0xBB132F88, 0x515BAD24, 0x7B9479BF, 0x763BD6EB,
217
- 0x37392EB3, 0xCC115979, 0x8026E297, 0xF42E312D,
218
- 0x6842ADA7, 0xC66A2B3B, 0x12754CCC, 0x782EF11C,
219
- 0x6A124237, 0xB79251E7, 0x06A1BBE6, 0x4BFB6350,
220
- 0x1A6B1018, 0x11CAEDFA, 0x3D25BDD8, 0xE2E1C3C9,
221
- 0x44421659, 0x0A121386, 0xD90CEC6E, 0xD5ABEA2A,
222
- 0x64AF674E, 0xDA86A85F, 0xBEBFE988, 0x64E4C3FE,
223
- 0x9DBC8057, 0xF0F7C086, 0x60787BF8, 0x6003604D,
224
- 0xD1FD8346, 0xF6381FB0, 0x7745AE04, 0xD736FCCC,
225
- 0x83426B33, 0xF01EAB71, 0xB0804187, 0x3C005E5F,
226
- 0x77A057BE, 0xBDE8AE24, 0x55464299, 0xBF582E61,
227
- 0x4E58F48F, 0xF2DDFDA2, 0xF474EF38, 0x8789BDC2,
228
- 0x5366F9C3, 0xC8B38E74, 0xB475F255, 0x46FCD9B9,
229
- 0x7AEB2661, 0x8B1DDF84, 0x846A0E79, 0x915F95E2,
230
- 0x466E598E, 0x20B45770, 0x8CD55591, 0xC902DE4C,
231
- 0xB90BACE1, 0xBB8205D0, 0x11A86248, 0x7574A99E,
232
- 0xB77F19B6, 0xE0A9DC09, 0x662D09A1, 0xC4324633,
233
- 0xE85A1F02, 0x09F0BE8C, 0x4A99A025, 0x1D6EFE10,
234
- 0x1AB93D1D, 0x0BA5A4DF, 0xA186F20F, 0x2868F169,
235
- 0xDCB7DA83, 0x573906FE, 0xA1E2CE9B, 0x4FCD7F52,
236
- 0x50115E01, 0xA70683FA, 0xA002B5C4, 0x0DE6D027,
237
- 0x9AF88C27, 0x773F8641, 0xC3604C06, 0x61A806B5,
238
- 0xF0177A28, 0xC0F586E0, 0x006058AA, 0x30DC7D62,
239
- 0x11E69ED7, 0x2338EA63, 0x53C2DD94, 0xC2C21634,
240
- 0xBBCBEE56, 0x90BCB6DE, 0xEBFC7DA1, 0xCE591D76,
241
- 0x6F05E409, 0x4B7C0188, 0x39720A3D, 0x7C927C24,
242
- 0x86E3725F, 0x724D9DB9, 0x1AC15BB4, 0xD39EB8FC,
243
- 0xED545578, 0x08FCA5B5, 0xD83D7CD3, 0x4DAD0FC4,
244
- 0x1E50EF5E, 0xB161E6F8, 0xA28514D9, 0x6C51133C,
245
- 0x6FD5C7E7, 0x56E14EC4, 0x362ABFCE, 0xDDC6C837,
246
- 0xD79A3234, 0x92638212, 0x670EFA8E, 0x406000E0
247
- ),
248
- array(
249
- 0x3A39CE37, 0xD3FAF5CF, 0xABC27737, 0x5AC52D1B,
250
- 0x5CB0679E, 0x4FA33742, 0xD3822740, 0x99BC9BBE,
251
- 0xD5118E9D, 0xBF0F7315, 0xD62D1C7E, 0xC700C47B,
252
- 0xB78C1B6B, 0x21A19045, 0xB26EB1BE, 0x6A366EB4,
253
- 0x5748AB2F, 0xBC946E79, 0xC6A376D2, 0x6549C2C8,
254
- 0x530FF8EE, 0x468DDE7D, 0xD5730A1D, 0x4CD04DC6,
255
- 0x2939BBDB, 0xA9BA4650, 0xAC9526E8, 0xBE5EE304,
256
- 0xA1FAD5F0, 0x6A2D519A, 0x63EF8CE2, 0x9A86EE22,
257
- 0xC089C2B8, 0x43242EF6, 0xA51E03AA, 0x9CF2D0A4,
258
- 0x83C061BA, 0x9BE96A4D, 0x8FE51550, 0xBA645BD6,
259
- 0x2826A2F9, 0xA73A3AE1, 0x4BA99586, 0xEF5562E9,
260
- 0xC72FEFD3, 0xF752F7DA, 0x3F046F69, 0x77FA0A59,
261
- 0x80E4A915, 0x87B08601, 0x9B09E6AD, 0x3B3EE593,
262
- 0xE990FD5A, 0x9E34D797, 0x2CF0B7D9, 0x022B8B51,
263
- 0x96D5AC3A, 0x017DA67D, 0xD1CF3ED6, 0x7C7D2D28,
264
- 0x1F9F25CF, 0xADF2B89B, 0x5AD6B472, 0x5A88F54C,
265
- 0xE029AC71, 0xE019A5E6, 0x47B0ACFD, 0xED93FA9B,
266
- 0xE8D3C48D, 0x283B57CC, 0xF8D56629, 0x79132E28,
267
- 0x785F0191, 0xED756055, 0xF7960E44, 0xE3D35E8C,
268
- 0x15056DD4, 0x88F46DBA, 0x03A16125, 0x0564F0BD,
269
- 0xC3EB9E15, 0x3C9057A2, 0x97271AEC, 0xA93A072A,
270
- 0x1B3F6D9B, 0x1E6321F5, 0xF59C66FB, 0x26DCF319,
271
- 0x7533D928, 0xB155FDF5, 0x03563482, 0x8ABA3CBB,
272
- 0x28517711, 0xC20AD9F8, 0xABCC5167, 0xCCAD925F,
273
- 0x4DE81751, 0x3830DC8E, 0x379D5862, 0x9320F991,
274
- 0xEA7A90C2, 0xFB3E7BCE, 0x5121CE64, 0x774FBE32,
275
- 0xA8B6E37E, 0xC3293D46, 0x48DE5369, 0x6413E680,
276
- 0xA2AE0810, 0xDD6DB224, 0x69852DFD, 0x09072166,
277
- 0xB39A460A, 0x6445C0DD, 0x586CDECF, 0x1C20C8AE,
278
- 0x5BBEF7DD, 0x1B588D40, 0xCCD2017F, 0x6BB4E3BB,
279
- 0xDDA26A7E, 0x3A59FF45, 0x3E350A44, 0xBCB4CDD5,
280
- 0x72EACEA8, 0xFA6484BB, 0x8D6612AE, 0xBF3C6F47,
281
- 0xD29BE463, 0x542F5D9E, 0xAEC2771B, 0xF64E6370,
282
- 0x740E0D8D, 0xE75B1357, 0xF8721671, 0xAF537D5D,
283
- 0x4040CB08, 0x4EB4E2CC, 0x34D2466A, 0x0115AF84,
284
- 0xE1B00428, 0x95983A1D, 0x06B89FB4, 0xCE6EA048,
285
- 0x6F3F3B82, 0x3520AB82, 0x011A1D4B, 0x277227F8,
286
- 0x611560B1, 0xE7933FDC, 0xBB3A792B, 0x344525BD,
287
- 0xA08839E1, 0x51CE794B, 0x2F32C9B7, 0xA01FBAC9,
288
- 0xE01CC87E, 0xBCC7D1F6, 0xCF0111C3, 0xA1E8AAC7,
289
- 0x1A908749, 0xD44FBD9A, 0xD0DADECB, 0xD50ADA38,
290
- 0x0339C32A, 0xC6913667, 0x8DF9317C, 0xE0B12B4F,
291
- 0xF79E59B7, 0x43F5BB3A, 0xF2D519FF, 0x27D9459C,
292
- 0xBF97222C, 0x15E6FC2A, 0x0F91FC71, 0x9B941525,
293
- 0xFAE59361, 0xCEB69CEB, 0xC2A86459, 0x12BAA8D1,
294
- 0xB6C1075E, 0xE3056A0C, 0x10D25065, 0xCB03A442,
295
- 0xE0EC6E0E, 0x1698DB3B, 0x4C98A0BE, 0x3278E964,
296
- 0x9F1F9532, 0xE0D392DF, 0xD3A0342B, 0x8971F21E,
297
- 0x1B0A7441, 0x4BA3348C, 0xC5BE7120, 0xC37632D8,
298
- 0xDF359F8D, 0x9B992F2E, 0xE60B6F47, 0x0FE3F11D,
299
- 0xE54CDA54, 0x1EDAD891, 0xCE6279CF, 0xCD3E7E6F,
300
- 0x1618B166, 0xFD2C1D05, 0x848FD2C5, 0xF6FB2299,
301
- 0xF523F357, 0xA6327623, 0x93A83531, 0x56CCCD02,
302
- 0xACF08162, 0x5A75EBB5, 0x6E163697, 0x88D273CC,
303
- 0xDE966292, 0x81B949D0, 0x4C50901B, 0x71C65614,
304
- 0xE6C6C7BD, 0x327A140A, 0x45E1D006, 0xC3F27B9A,
305
- 0xC9AA53FD, 0x62A80F00, 0xBB25BFE2, 0x35BDD2F6,
306
- 0x71126905, 0xB2040222, 0xB6CBCF7C, 0xCD769C2B,
307
- 0x53113EC0, 0x1640E3D3, 0x38ABBD60, 0x2547ADF0,
308
- 0xBA38209C, 0xF746CE76, 0x77AFA1C5, 0x20756060,
309
- 0x85CBFE4E, 0x8AE88DD8, 0x7AAAF9B0, 0x4CF9AA7E,
310
- 0x1948C25C, 0x02FB8A8C, 0x01C36AE4, 0xD6EBE1F9,
311
- 0x90D4F869, 0xA65CDEA0, 0x3F09252D, 0xC208E69F,
312
- 0xB74E6132, 0xCE77E25B, 0x578FDFE3, 0x3AC372E6
313
- )
314
- );
315
- }
316
-
317
- }
318
-
319
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-scc-analytical-engline.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-analytical-engline.php
4
 
5
  Description: This class is a data analytical engine.
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,53 +27,66 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  abstract class SCC_Analytical_Engine extends SCC_Engine {
31
 
32
  /**
33
  * Prefix of cache ID
 
 
34
  */
35
- protected $cache_prefix = NULL;
36
 
37
  /**
38
  * Prefix of base ID
 
 
39
  */
40
- protected $base_prefix = NULL;
41
 
42
  /**
43
- * Prefix of base ID
 
 
44
  */
45
- protected $delta_prefix = NULL;
46
 
47
  /**
48
- * instance for delegation
 
 
49
  */
50
- protected $delegate = NULL;
51
 
52
  /**
53
  * Get and cache data for a given post
54
  *
55
- * @since 0.1.1
 
56
  */
57
  abstract public function analyze( $options = array() );
58
 
59
  /**
60
  * Initialize cache
61
  *
62
- * @since 0.3.0
63
  */
64
  abstract public function initialize_base();
65
 
66
  /**
67
  * Clear cache
68
  *
69
- * @since 0.3.0
70
  */
71
  abstract public function clear_base();
72
 
73
  /**
74
  * Get cache key
75
  *
76
- * @since 0.6.0
 
77
  */
78
  public function get_cache_key( $suffix ) {
79
  return $this->cache_prefix . strtolower( $suffix );
@@ -82,7 +95,8 @@ abstract class SCC_Analytical_Engine extends SCC_Engine {
82
  /**
83
  * Get base key
84
  *
85
- * @since 0.6.1
 
86
  */
87
  public function get_base_key( $suffix ) {
88
  return $this->base_prefix . strtolower( $suffix );
@@ -91,7 +105,8 @@ abstract class SCC_Analytical_Engine extends SCC_Engine {
91
  /**
92
  * Get delta key
93
  *
94
- * @since 0.6.1
 
95
  */
96
  public function get_delta_key( $suffix ) {
97
  return $this->delta_prefix . strtolower( $suffix );
1
  <?php
2
+ /**
3
  class-scc-analytical-engline.php
4
 
5
  Description: This class is a data analytical engine.
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Analytical_Engine
32
+ */
33
  abstract class SCC_Analytical_Engine extends SCC_Engine {
34
 
35
  /**
36
  * Prefix of cache ID
37
+ *
38
+ * @var string
39
  */
40
+ protected $cache_prefix = null;
41
 
42
  /**
43
  * Prefix of base ID
44
+ *
45
+ * @var string
46
  */
47
+ protected $base_prefix = null;
48
 
49
  /**
50
+ * Prefix of delta ID
51
+ *
52
+ * @var [type]
53
  */
54
+ protected $delta_prefix = null;
55
 
56
  /**
57
+ * Instance for delegation
58
+ *
59
+ * @var SNS_Count_Cache
60
  */
61
+ protected $delegate = null;
62
 
63
  /**
64
  * Get and cache data for a given post
65
  *
66
+ * @param array $options Option.
67
+ * @return void
68
  */
69
  abstract public function analyze( $options = array() );
70
 
71
  /**
72
  * Initialize cache
73
  *
74
+ * @return void
75
  */
76
  abstract public function initialize_base();
77
 
78
  /**
79
  * Clear cache
80
  *
81
+ * @return void
82
  */
83
  abstract public function clear_base();
84
 
85
  /**
86
  * Get cache key
87
  *
88
+ * @param string $suffix Suffix of cache key.
89
+ * @return string
90
  */
91
  public function get_cache_key( $suffix ) {
92
  return $this->cache_prefix . strtolower( $suffix );
95
  /**
96
  * Get base key
97
  *
98
+ * @param string $suffix Suffix of base key.
99
+ * @return string
100
  */
101
  public function get_base_key( $suffix ) {
102
  return $this->base_prefix . strtolower( $suffix );
105
  /**
106
  * Get delta key
107
  *
108
+ * @param string $suffix Suffix of delta key.
109
+ * @return string
110
  */
111
  public function get_delta_key( $suffix ) {
112
  return $this->delta_prefix . strtolower( $suffix );
includes/class-scc-cache-engine.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,85 +27,103 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  abstract class SCC_Cache_Engine extends SCC_Engine {
31
 
32
  /**
33
  * Prefix of cache ID
 
 
34
  */
35
- protected $cache_prefix = NULL;
36
 
37
  /**
38
- * instance for delegation
 
 
39
  */
40
- protected $delegate = NULL;
41
 
42
  /**
43
- * retry of cache processing
 
 
44
  */
45
  protected $cache_retry = false;
46
 
47
  /**
48
- * limit of cache retry
 
 
49
  */
50
  protected $retry_limit = 3;
51
 
52
  /**
53
- * fault tolerance mode
 
 
54
  */
55
  protected $fault_tolerance = 1;
56
 
57
  /**
58
  * Get cache expiration based on current number of total post and page
59
  *
60
- * @since 0.1.1
61
  */
62
  abstract protected function get_cache_expiration();
63
 
64
  /**
65
  * Get and cache data for a given post
66
  *
67
- * @since 0.1.1
 
68
  */
69
  abstract public function cache( $options = array() );
70
 
71
  /**
72
  * Initialize cache
73
  *
74
- * @since 0.3.0
75
  */
76
  abstract public function initialize_cache();
77
 
78
  /**
79
  * Clear cache
80
  *
81
- * @since 0.3.0
82
  */
83
  abstract public function clear_cache();
84
 
85
  /**
86
  * Get cache
87
  *
88
- * @since 0.10.1
 
89
  */
90
  abstract public function get_cache( $options = array() );
91
 
92
  /**
93
  * Get cache key
94
  *
95
- * @since 0.6.0
 
96
  */
97
  public function get_cache_key( $suffix ) {
98
  return $this->cache_prefix . strtolower( $suffix );
99
  }
100
 
101
  /**
102
- * Order
103
  *
104
- * @since 0.6.1
 
 
105
  */
106
- protected function delegate_order( $order, $options = array() ) {
107
- if ( ! is_null( $this->delegate ) && ( $this->delegate instanceof SCC_Order ) && method_exists( $this->delegate, 'order' ) ) {
108
- $this->delegate->order( $this, $order, $options );
109
  }
110
  }
111
 
1
  <?php
2
+ /**
3
  class-scc-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Cache Engine
32
+ */
33
  abstract class SCC_Cache_Engine extends SCC_Engine {
34
 
35
  /**
36
  * Prefix of cache ID
37
+ *
38
+ * @var string
39
  */
40
+ protected $cache_prefix = null;
41
 
42
  /**
43
+ * Instance for delegation
44
+ *
45
+ * @var SNS_Count_Cache
46
  */
47
+ protected $delegate = null;
48
 
49
  /**
50
+ * Retry of cache processing
51
+ *
52
+ * @var boolean
53
  */
54
  protected $cache_retry = false;
55
 
56
  /**
57
+ * Limit of cache retry
58
+ *
59
+ * @var integer
60
  */
61
  protected $retry_limit = 3;
62
 
63
  /**
64
+ * Fault tolerance mode
65
+ *
66
+ * @var integer
67
  */
68
  protected $fault_tolerance = 1;
69
 
70
  /**
71
  * Get cache expiration based on current number of total post and page
72
  *
73
+ * @return void
74
  */
75
  abstract protected function get_cache_expiration();
76
 
77
  /**
78
  * Get and cache data for a given post
79
  *
80
+ * @param array $options option for cache processing.
81
+ * @return void
82
  */
83
  abstract public function cache( $options = array() );
84
 
85
  /**
86
  * Initialize cache
87
  *
88
+ * @return void
89
  */
90
  abstract public function initialize_cache();
91
 
92
  /**
93
  * Clear cache
94
  *
95
+ * @return void
96
  */
97
  abstract public function clear_cache();
98
 
99
  /**
100
  * Get cache
101
  *
102
+ * @param array $options Option.
103
+ * @return void
104
  */
105
  abstract public function get_cache( $options = array() );
106
 
107
  /**
108
  * Get cache key
109
  *
110
+ * @param string $suffix Suffix of cache key.
111
+ * @return string Cache key.
112
  */
113
  public function get_cache_key( $suffix ) {
114
  return $this->cache_prefix . strtolower( $suffix );
115
  }
116
 
117
  /**
118
+ * Delegate order
119
  *
120
+ * @param string $order Order.
121
+ * @param array $options Option.
122
+ * @return mixed Result of delegation
123
  */
124
+ protected function delegate_order( $order, $options = array() ) {
125
+ if ( ! is_null( $this->delegate ) && ( $this->delegate instanceof SCC_Order ) && method_exists( $this->delegate, 'order' ) ) {
126
+ return $this->delegate->order( $this, $order, $options );
127
  }
128
  }
129
 
includes/class-scc-cache.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ class-scc-cache.php
4
+
5
+ Description: This class is a common utility
6
+ Author: Daisuke Maruyama
7
+ Author URI: http://marubon.info/
8
+ License: GPL2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2014 - 2018 Daisuke Maruyama
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; either version 2
18
+ of the License, or (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ */
29
+
30
+ /**
31
+ * SCC_Cache
32
+ */
33
+ class SCC_Cache {
34
+
35
+ /**
36
+ * Class constarctor
37
+ * Hook onto all of the actions and filters needed by the plugin.
38
+ */
39
+ protected function __construct() {
40
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
41
+ }
42
+
43
+ /**
44
+ * Check if a given value has data or not.
45
+ *
46
+ * @param array $value Value to check.
47
+ * @return boolean
48
+ */
49
+ public static function has_value( $value ) {
50
+ if ( isset( $value ) && '' !== $value ) {
51
+ return true;
52
+ } else {
53
+ return false;
54
+ }
55
+ }
56
+
57
+ }
58
+
59
+ ?>
includes/class-scc-common-data-export-engine.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-common-data-export.php
4
 
5
  Description: This class is a data export engine whitch exports cached data using wp-cron at regular intervals
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,6 +27,9 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  class SCC_Common_Data_Export_Engine extends SCC_Export_Engine {
31
 
32
  /**
@@ -61,51 +64,68 @@ class SCC_Common_Data_Export_Engine extends SCC_Export_Engine {
61
 
62
  /**
63
  * Option flag of data export
 
 
64
  */
65
  private $export_activation = 0;
66
 
67
  /**
68
  * Interval for data export
 
 
69
  */
70
  private $export_interval = 43200;
71
 
72
  /**
73
  * Schedule for data export
 
 
74
  */
75
  private $export_schedule = '0 0 * * *';
76
 
77
  /**
78
  * Excluded keys of data export
 
 
79
  */
80
  private $export_exclude_keys = array();
81
 
82
  /**
83
  * File name of data export
 
 
84
  */
85
  private $export_file_name = 'sns-count-cache-data.csv';
86
 
87
  /**
88
  * Cache post types
 
 
89
  */
90
  private $post_types = array( 'post', 'page' );
91
 
92
  /**
93
  * Cache target of share count
 
 
94
  */
95
  private $share_target_sns = array();
96
 
97
  /**
98
  * Cache target of follow count
 
 
99
  */
100
  private $follow_target_sns = array();
101
 
102
  /**
103
  * Initialization
104
  *
105
- * @since 0.1.1
 
106
  */
107
  public function initialize( $options = array() ) {
108
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
109
 
110
  $this->share_cache_key_prefix = self::DEF_SHARE_META_KEY_PREFIX;
111
  $this->follow_cache_key_prefix = self::DEF_FOLLOW_META_KEY_PREFIX;
@@ -114,20 +134,61 @@ class SCC_Common_Data_Export_Engine extends SCC_Export_Engine {
114
  $this->event_schedule = self::DEF_EVENT_SCHEDULE;
115
  $this->event_description = self::DEF_EVENT_DESCRIPTION;
116
 
117
- if ( isset( $options['export_activation'] ) ) $this->export_activation = $options['export_activation'];
118
- if ( isset( $options['export_interval'] ) ) $this->export_interval = $options['export_interval'];
119
- if ( isset( $options['export_schedule'] ) ) $this->export_schedule = $options['export_schedule'];
120
- if ( isset( $options['prime_cron'] ) ) $this->prime_cron = $options['prime_cron'];
121
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
122
- if ( isset( $options['event_schedule'] ) ) $this->event_schedule = $options['event_schedule'];
123
- if ( isset( $options['event_description'] ) ) $this->event_description = $options['event_description'];
124
- if ( isset( $options['export_exclude_keys'] ) ) $this->export_exclude_keys = $options['export_exclude_keys'];
125
- if ( isset( $options['export_file_name'] ) ) $this->export_file_name = $options['export_file_name'];
126
- if ( isset( $options['post_types'] ) ) $this->post_types = $options['post_types'];
127
- if ( isset( $options['share_cache_key_prefix'] ) ) $this->share_cache_key_prefix = $options['share_cache_key_prefix'];
128
- if ( isset( $options['follow_cache_key_prefix'] ) ) $this->follow_cache_key_prefix = $options['follow_cache_key_prefix'];
129
- if ( isset( $options['share_target_sns'] ) ) $this->share_target_sns = $options['share_target_sns'];
130
- if ( isset( $options['follow_target_sns'] ) ) $this->follow_target_sns = $options['follow_target_sns'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
 
132
  add_filter( 'cron_schedules', array( $this, 'schedule_export_interval' ) );
133
  add_action( $this->prime_cron, array( $this, 'prime_export' ) );
@@ -137,100 +198,103 @@ class SCC_Common_Data_Export_Engine extends SCC_Export_Engine {
137
  /**
138
  * Register event schedule for this engine
139
  *
140
- * @since 0.1.0
 
141
  */
142
  public function schedule_export_interval( $schedules ) {
143
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
144
 
145
- $schedules[$this->event_schedule] = array(
146
  'interval' => $this->export_interval,
147
- 'display' => $this->event_description
148
- );
149
 
150
- return $schedules;
151
  }
152
 
153
  /**
154
  * Prime data export
155
  *
156
- * @since 0.4.0
157
  */
158
  public function prime_export() {
159
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
160
 
161
  //$next_exec_time = time() + $this->export_interval;
162
 
163
  //$next_exec_time = time() + 5;
164
 
165
- $next_exec_time = SCC_WP_Cron_Util::next_exec_time( $this->export_schedule );
166
 
167
- SCC_Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->export_interval );
168
 
169
- SCC_Common_Util::log( '[' . __METHOD__ . '] next_exec_time (timesatamp): ' . $next_exec_time );
170
- SCC_Common_Util::log( '[' . __METHOD__ . '] next_exec_time (date): ' . date_i18n( 'Y/m/d H:i:s', $next_exec_time ) );
171
 
172
- if ( ! SCC_WP_Cron_Util::is_scheduled_hook( $this->execute_cron ) ) {
173
- wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( SCC_Common_Util::short_hash( $next_exec_time ) ) );
174
  }
175
 
176
- //wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( SCC_Common_Util::short_hash( $next_exec_time ) ) );
177
  }
178
 
179
-
180
  /**
181
  * Execute data export
182
  *
183
- * @since 0.4.0
 
184
  */
185
  public function execute_export( $hash ) {
186
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
187
 
188
  $base_dir = WP_PLUGIN_DIR . '/sns-count-cache/data/';
189
 
190
  $current_date = date_i18n( 'Y/m/d H:i:s' );
191
 
192
  if ( file_exists( $base_dir ) ) {
193
- $abs_path = $base_dir . $this->export_file_name;
194
 
195
  if ( ! file_exists( $abs_path ) ) {
196
  if ( touch( $abs_path ) ) {
197
- SCC_Common_Util::log( '[' . __METHOD__ . '] export file creation succeeded: ' . $abs_path );
198
  } else {
199
- SCC_Common_Util::log( '[' . __METHOD__ . '] export file creation failed: ' . $abs_path );
200
  }
201
  if ( file_exists( $abs_path ) ) {
202
- SCC_Common_Util::log( '[' . __METHOD__ . '] file exists: ' . $abs_path );
203
  $fp = fopen( $abs_path, 'a' );
204
 
205
  $header = '"Retrieval Date","Post ID","Post Type","Post Title","Permalink","Post Date","SNS","Data Type","Data Value",' . "\r\n";
206
 
207
  if ( fwrite( $fp, mb_convert_encoding( $header, "SJIS", "UTF-8" ) ) ) {
208
- SCC_Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ' . $header );
209
  } else {
210
- SCC_Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ' . $header );
211
  }
212
  if ( fclose( $fp ) ) {
213
- SCC_Common_Util::log( '[' . __METHOD__ . '] file close succeeded: ' . $abs_path );
214
  } else {
215
- SCC_Common_Util::log( '[' . __METHOD__ . '] file close failed: ' . $abs_path );
216
  }
217
  }
218
  }
219
 
220
  if ( file_exists( $abs_path ) ) {
221
- SCC_Common_Util::log( '[' . __METHOD__ . '] file exists: ' . $abs_path );
222
 
223
  $fp = fopen( $abs_path, 'a' );
224
 
225
- $content = '"' . $current_date . '","' . 'home' . '","' . '-' . '","' . get_bloginfo('name') . '","' . home_url( '/' ) . '","' . '-';
226
 
227
  $option_key = $this->share_cache_key_prefix . strtolower( 'home' );
228
 
229
- if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
 
 
230
 
231
  foreach ( $this->share_target_sns as $sns => $active ) {
232
  if ( ! in_array( $sns, $this->export_exclude_keys ) ) {
233
- if ( $active ){
234
  if ( $sns_counts[$sns] >= 0 ) {
235
  $data_value = $sns_counts[$sns];
236
  } else {
@@ -239,9 +303,9 @@ class SCC_Common_Data_Export_Engine extends SCC_Export_Engine {
239
  $data = $content . '","' . $sns . '","' . 'Share' . '","' . $data_value . '",' . "\r\n";
240
 
241
  if ( fwrite( $fp, mb_convert_encoding( $data, "SJIS", "UTF-8" ) ) ) {
242
- SCC_Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ' . $data );
243
  } else {
244
- SCC_Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ' . $data );
245
  }
246
  }
247
  }
@@ -253,7 +317,7 @@ class SCC_Common_Data_Export_Engine extends SCC_Export_Engine {
253
  'post_status' => 'publish',
254
  'nopaging' => true,
255
  'update_post_term_cache' => false,
256
- 'update_post_meta_cache' => false
257
  );
258
 
259
  $posts_query = new WP_Query( $query_args );
@@ -273,49 +337,28 @@ class SCC_Common_Data_Export_Engine extends SCC_Export_Engine {
273
  if ( $active ) {
274
  $data_value = get_post_meta( $post_ID, $meta_key, true );
275
 
276
- if ( $data_value < 0 ){
277
  $data_value = '';
278
  }
279
 
280
  $data = $content . '","' . $sns . '","' . 'Share' . '","' . $data_value . '",' . "\r\n";
281
 
282
  if ( fwrite( $fp, mb_convert_encoding( $data, "SJIS", "UTF-8" ) ) ) {
283
- SCC_Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ' . $data );
284
  } else {
285
- SCC_Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ' . $data );
286
  }
287
  }
288
  }
289
  }
290
-
291
- /*
292
- foreach ( $this->follow_target_sns as $key => $value ) {
293
- $meta_key = $this->follow_cache_key_prefix . strtolower( $key );
294
- if ( $value ) {
295
- $data_value = get_post_meta( $post_ID, $meta_key, true );
296
-
297
- if ( $data_value == -1 ){
298
- $data_value = '';
299
- }
300
-
301
- $data = $content . '","' . $key . '","' . 'Follow' . '","' . $data_value . '",' . "\r\n";
302
- }
303
- if ( fwrite( $fp, mb_convert_encoding( $data, "SJIS", "UTF-8" ) ) ) {
304
- SCC_Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ' . $data );
305
- } else {
306
- SCC_Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ' . $data );
307
- }
308
- }
309
- */
310
-
311
  }
312
  }
313
  wp_reset_postdata();
314
 
315
  if ( fclose( $fp ) ) {
316
- SCC_Common_Util::log( '[' . __METHOD__ . '] file close succeeded: ' . $abs_path );
317
  } else {
318
- SCC_Common_Util::log( '[' . __METHOD__ . '] file close failed: ' . $abs_path );
319
  }
320
  }
321
  }
@@ -324,13 +367,13 @@ class SCC_Common_Data_Export_Engine extends SCC_Export_Engine {
324
  /**
325
  * Reset exported file
326
  *
327
- * @since 0.4.0
328
  */
329
  public function reset_export() {
330
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
331
 
332
  $base_dir = WP_PLUGIN_DIR . '/sns-count-cache/data/';
333
- $abs_path = $base_dir . $this->export_file_name;
334
 
335
  if ( file_exists( $abs_path ) ) {
336
  unlink( $abs_path );
1
  <?php
2
+ /**
3
  class-scc-common-data-export.php
4
 
5
  Description: This class is a data export engine whitch exports cached data using wp-cron at regular intervals
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Common_Data_Export_Engine
32
+ */
33
  class SCC_Common_Data_Export_Engine extends SCC_Export_Engine {
34
 
35
  /**
64
 
65
  /**
66
  * Option flag of data export
67
+ *
68
+ * @var integer
69
  */
70
  private $export_activation = 0;
71
 
72
  /**
73
  * Interval for data export
74
+ *
75
+ * @var integer
76
  */
77
  private $export_interval = 43200;
78
 
79
  /**
80
  * Schedule for data export
81
+ *
82
+ * @var string
83
  */
84
  private $export_schedule = '0 0 * * *';
85
 
86
  /**
87
  * Excluded keys of data export
88
+ *
89
+ * @var array
90
  */
91
  private $export_exclude_keys = array();
92
 
93
  /**
94
  * File name of data export
95
+ *
96
+ * @var string
97
  */
98
  private $export_file_name = 'sns-count-cache-data.csv';
99
 
100
  /**
101
  * Cache post types
102
+ *
103
+ * @var array
104
  */
105
  private $post_types = array( 'post', 'page' );
106
 
107
  /**
108
  * Cache target of share count
109
+ *
110
+ * @var array
111
  */
112
  private $share_target_sns = array();
113
 
114
  /**
115
  * Cache target of follow count
116
+ *
117
+ * @var array
118
  */
119
  private $follow_target_sns = array();
120
 
121
  /**
122
  * Initialization
123
  *
124
+ * @param array $options Option.
125
+ * @return void
126
  */
127
  public function initialize( $options = array() ) {
128
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
129
 
130
  $this->share_cache_key_prefix = self::DEF_SHARE_META_KEY_PREFIX;
131
  $this->follow_cache_key_prefix = self::DEF_FOLLOW_META_KEY_PREFIX;
134
  $this->event_schedule = self::DEF_EVENT_SCHEDULE;
135
  $this->event_description = self::DEF_EVENT_DESCRIPTION;
136
 
137
+ if ( isset( $options['export_activation'] ) ) {
138
+ $this->export_activation = $options['export_activation'];
139
+ }
140
+
141
+ if ( isset( $options['export_interval'] ) ) {
142
+ $this->export_interval = $options['export_interval'];
143
+ }
144
+
145
+ if ( isset( $options['export_schedule'] ) ) {
146
+ $this->export_schedule = $options['export_schedule'];
147
+ }
148
+
149
+ if ( isset( $options['prime_cron'] ) ) {
150
+ $this->prime_cron = $options['prime_cron'];
151
+ }
152
+
153
+ if ( isset( $options['execute_cron'] ) ) {
154
+ $this->execute_cron = $options['execute_cron'];
155
+ }
156
+
157
+ if ( isset( $options['event_schedule'] ) ) {
158
+ $this->event_schedule = $options['event_schedule'];
159
+ }
160
+
161
+ if ( isset( $options['event_description'] ) ) {
162
+ $this->event_description = $options['event_description'];
163
+ }
164
+
165
+ if ( isset( $options['export_exclude_keys'] ) ) {
166
+ $this->export_exclude_keys = $options['export_exclude_keys'];
167
+ }
168
+
169
+ if ( isset( $options['export_file_name'] ) ) {
170
+ $this->export_file_name = $options['export_file_name'];
171
+ }
172
+
173
+ if ( isset( $options['post_types'] ) ) {
174
+ $this->post_types = $options['post_types'];
175
+ }
176
+
177
+ if ( isset( $options['share_cache_key_prefix'] ) ) {
178
+ $this->share_cache_key_prefix = $options['share_cache_key_prefix'];
179
+ }
180
+
181
+ if ( isset( $options['follow_cache_key_prefix'] ) ) {
182
+ $this->follow_cache_key_prefix = $options['follow_cache_key_prefix'];
183
+ }
184
+
185
+ if ( isset( $options['share_target_sns'] ) ) {
186
+ $this->share_target_sns = $options['share_target_sns'];
187
+ }
188
+
189
+ if ( isset( $options['follow_target_sns'] ) ) {
190
+ $this->follow_target_sns = $options['follow_target_sns'];
191
+ }
192
 
193
  add_filter( 'cron_schedules', array( $this, 'schedule_export_interval' ) );
194
  add_action( $this->prime_cron, array( $this, 'prime_export' ) );
198
  /**
199
  * Register event schedule for this engine
200
  *
201
+ * @param array $schedules Schedule.
202
+ * @return array
203
  */
204
  public function schedule_export_interval( $schedules ) {
205
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
206
 
207
+ $schedules[ $this->event_schedule ] = array(
208
  'interval' => $this->export_interval,
209
+ 'display' => $this->event_description,
210
+ );
211
 
212
+ return $schedules;
213
  }
214
 
215
  /**
216
  * Prime data export
217
  *
218
+ * @return void
219
  */
220
  public function prime_export() {
221
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
222
 
223
  //$next_exec_time = time() + $this->export_interval;
224
 
225
  //$next_exec_time = time() + 5;
226
 
227
+ $next_exec_time = SCC_WP_Cron::next_exec_time( $this->export_schedule );
228
 
229
+ SCC_Logger::log( '[' . __METHOD__ . '] check_interval: ' . $this->export_interval );
230
 
231
+ SCC_Logger::log( '[' . __METHOD__ . '] next_exec_time (timesatamp): ' . $next_exec_time );
232
+ SCC_Logger::log( '[' . __METHOD__ . '] next_exec_time (date): ' . date_i18n( 'Y/m/d H:i:s', $next_exec_time ) );
233
 
234
+ if ( ! SCC_WP_Cron::is_scheduled_hook( $this->execute_cron ) ) {
235
+ wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( SCC_Hash::short_hash( $next_exec_time ) ) );
236
  }
237
 
238
+ //wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( SCC_Hash::short_hash( $next_exec_time ) ) );
239
  }
240
 
 
241
  /**
242
  * Execute data export
243
  *
244
+ * @param string $hash Hash.
245
+ * @return void
246
  */
247
  public function execute_export( $hash ) {
248
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
249
 
250
  $base_dir = WP_PLUGIN_DIR . '/sns-count-cache/data/';
251
 
252
  $current_date = date_i18n( 'Y/m/d H:i:s' );
253
 
254
  if ( file_exists( $base_dir ) ) {
255
+ $abs_path = $base_dir . sanitize_file_name( $this->export_file_name );
256
 
257
  if ( ! file_exists( $abs_path ) ) {
258
  if ( touch( $abs_path ) ) {
259
+ SCC_Logger::log( '[' . __METHOD__ . '] export file creation succeeded: ' . $abs_path );
260
  } else {
261
+ SCC_Logger::log( '[' . __METHOD__ . '] export file creation failed: ' . $abs_path );
262
  }
263
  if ( file_exists( $abs_path ) ) {
264
+ SCC_Logger::log( '[' . __METHOD__ . '] file exists: ' . $abs_path );
265
  $fp = fopen( $abs_path, 'a' );
266
 
267
  $header = '"Retrieval Date","Post ID","Post Type","Post Title","Permalink","Post Date","SNS","Data Type","Data Value",' . "\r\n";
268
 
269
  if ( fwrite( $fp, mb_convert_encoding( $header, "SJIS", "UTF-8" ) ) ) {
270
+ SCC_Logger::log( '[' . __METHOD__ . '] file write succeeded: ' . $header );
271
  } else {
272
+ SCC_Logger::log( '[' . __METHOD__ . '] file wrote failed: ' . $header );
273
  }
274
  if ( fclose( $fp ) ) {
275
+ SCC_Logger::log( '[' . __METHOD__ . '] file close succeeded: ' . $abs_path );
276
  } else {
277
+ SCC_Logger::log( '[' . __METHOD__ . '] file close failed: ' . $abs_path );
278
  }
279
  }
280
  }
281
 
282
  if ( file_exists( $abs_path ) ) {
283
+ SCC_Logger::log( '[' . __METHOD__ . '] file exists: ' . $abs_path );
284
 
285
  $fp = fopen( $abs_path, 'a' );
286
 
287
+ $content = '"' . $current_date . '","' . 'home' . '","' . '-' . '","' . get_bloginfo( 'name' ) . '","' . home_url( '/' ) . '","' . '-';
288
 
289
  $option_key = $this->share_cache_key_prefix . strtolower( 'home' );
290
 
291
+ $sns_counts = get_option( $option_key );
292
+
293
+ if ( false !== $sns_counts ) {
294
 
295
  foreach ( $this->share_target_sns as $sns => $active ) {
296
  if ( ! in_array( $sns, $this->export_exclude_keys ) ) {
297
+ if ( $active ) {
298
  if ( $sns_counts[$sns] >= 0 ) {
299
  $data_value = $sns_counts[$sns];
300
  } else {
303
  $data = $content . '","' . $sns . '","' . 'Share' . '","' . $data_value . '",' . "\r\n";
304
 
305
  if ( fwrite( $fp, mb_convert_encoding( $data, "SJIS", "UTF-8" ) ) ) {
306
+ SCC_Logger::log( '[' . __METHOD__ . '] file write succeeded: ' . $data );
307
  } else {
308
+ SCC_Logger::log( '[' . __METHOD__ . '] file wrote failed: ' . $data );
309
  }
310
  }
311
  }
317
  'post_status' => 'publish',
318
  'nopaging' => true,
319
  'update_post_term_cache' => false,
320
+ 'update_post_meta_cache' => false,
321
  );
322
 
323
  $posts_query = new WP_Query( $query_args );
337
  if ( $active ) {
338
  $data_value = get_post_meta( $post_ID, $meta_key, true );
339
 
340
+ if ( SCC_Cache::has_value( $data_value ) && $data_value < 0 ){
341
  $data_value = '';
342
  }
343
 
344
  $data = $content . '","' . $sns . '","' . 'Share' . '","' . $data_value . '",' . "\r\n";
345
 
346
  if ( fwrite( $fp, mb_convert_encoding( $data, "SJIS", "UTF-8" ) ) ) {
347
+ SCC_Logger::log( '[' . __METHOD__ . '] file write succeeded: ' . $data );
348
  } else {
349
+ SCC_Logger::log( '[' . __METHOD__ . '] file wrote failed: ' . $data );
350
  }
351
  }
352
  }
353
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
354
  }
355
  }
356
  wp_reset_postdata();
357
 
358
  if ( fclose( $fp ) ) {
359
+ SCC_Logger::log( '[' . __METHOD__ . '] file close succeeded: ' . $abs_path );
360
  } else {
361
+ SCC_Logger::log( '[' . __METHOD__ . '] file close failed: ' . $abs_path );
362
  }
363
  }
364
  }
367
  /**
368
  * Reset exported file
369
  *
370
+ * @return void
371
  */
372
  public function reset_export() {
373
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
374
 
375
  $base_dir = WP_PLUGIN_DIR . '/sns-count-cache/data/';
376
+ $abs_path = $base_dir . sanitize_file_name( $this->export_file_name );
377
 
378
  if ( file_exists( $abs_path ) ) {
379
  unlink( $abs_path );
includes/class-scc-common-job-reset-engine.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-common-job-reset-engine.php
4
 
5
  Description: This class is a job reset engine whitch reset expired jobs
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,6 +27,9 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  class SCC_Common_Job_Reset_Engine extends SCC_Engine {
31
 
32
  /**
@@ -51,45 +54,77 @@ class SCC_Common_Job_Reset_Engine extends SCC_Engine {
51
 
52
  /**
53
  * Interval cheking and caching target data
 
 
54
  */
55
  private $check_interval = 600;
56
 
57
  /**
58
  * Time expired
 
 
59
  */
60
  private $expiration_time = 1800;
61
 
62
  /**
63
  * Cache target
 
 
64
  */
65
  private $target_cron = array();
66
 
67
  /**
68
- * instance for delegation
 
 
69
  */
70
- private $delegate = NULL;
71
 
72
  /**
73
  * Initialization
74
  *
75
- * @since 0.1.1
 
76
  */
77
  public function initialize( $options = array() ) {
78
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
79
 
80
  $this->prime_cron = self::DEF_PRIME_CRON;
81
  $this->execute_cron = self::DEF_EXECUTE_CRON;
82
  $this->event_schedule = self::DEF_EVENT_SCHEDULE;
83
  $this->event_description = self::DEF_EVENT_DESCRIPTION;
84
 
85
- if ( isset( $options['delegate'] ) ) $this->delegate = $options['delegate'];
86
- if ( isset( $options['target_cron'] ) ) $this->target_cron = $options['target_cron'];
87
- if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
88
- if ( isset( $options['prime_cron'] ) ) $this->prime_cron = $options['prime_cron'];
89
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
90
- if ( isset( $options['event_schedule'] ) ) $this->event_schedule = $options['event_schedule'];
91
- if ( isset( $options['event_description'] ) ) $this->event_description = $options['event_description'];
92
- if ( isset( $options['expiration_time'] ) ) $this->expiration_time = $options['expiration_time'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
 
94
  add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
95
  add_action( $this->prime_cron, array( $this, 'prime_reset' ) );
@@ -99,14 +134,15 @@ class SCC_Common_Job_Reset_Engine extends SCC_Engine {
99
  /**
100
  * Register event schedule for this engine
101
  *
102
- * @since 0.1.0
 
103
  */
104
  public function schedule_check_interval( $schedules ) {
105
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
106
 
107
- $schedules[$this->event_schedule] = array(
108
  'interval' => $this->check_interval,
109
- 'display' => $this->event_description
110
  );
111
 
112
  return $schedules;
@@ -115,15 +151,15 @@ class SCC_Common_Job_Reset_Engine extends SCC_Engine {
115
  /**
116
  * Schedule job reset processing
117
  *
118
- * @since 0.2.0
119
  */
120
  public function prime_reset() {
121
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
122
 
123
  $next_exec_time = (int) current_time( 'timestamp', 1 ) + $this->check_interval;
124
 
125
- SCC_Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
126
- SCC_Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
127
 
128
  wp_schedule_single_event( $next_exec_time, $this->execute_cron, array() );
129
  }
@@ -131,14 +167,14 @@ class SCC_Common_Job_Reset_Engine extends SCC_Engine {
131
  /**
132
  * Reset expired jobs
133
  *
134
- * @since 0.2.0
135
  */
136
  public function execute_reset() {
137
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
138
 
139
  foreach ( $this->target_cron as $key => $hook ) {
140
- SCC_Common_Util::log( '[' . __METHOD__ . '] hook: ' . $hook );
141
- SCC_WP_Cron_Util::clear_expired_scheduled_hook( $hook, $this->expiration_time );
142
  }
143
  }
144
 
1
  <?php
2
+ /**
3
  class-scc-common-job-reset-engine.php
4
 
5
  Description: This class is a job reset engine whitch reset expired jobs
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Common_Job_Reset_Engine
32
+ */
33
  class SCC_Common_Job_Reset_Engine extends SCC_Engine {
34
 
35
  /**
54
 
55
  /**
56
  * Interval cheking and caching target data
57
+ *
58
+ * @var integer
59
  */
60
  private $check_interval = 600;
61
 
62
  /**
63
  * Time expired
64
+ *
65
+ * @var integer
66
  */
67
  private $expiration_time = 1800;
68
 
69
  /**
70
  * Cache target
71
+ *
72
+ * @var array
73
  */
74
  private $target_cron = array();
75
 
76
  /**
77
+ * Instance for delegation
78
+ *
79
+ * @var SNS_Count_Cache
80
  */
81
+ private $delegate = null;
82
 
83
  /**
84
  * Initialization
85
  *
86
+ * @param array $options Option.
87
+ * @return void
88
  */
89
  public function initialize( $options = array() ) {
90
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
91
 
92
  $this->prime_cron = self::DEF_PRIME_CRON;
93
  $this->execute_cron = self::DEF_EXECUTE_CRON;
94
  $this->event_schedule = self::DEF_EVENT_SCHEDULE;
95
  $this->event_description = self::DEF_EVENT_DESCRIPTION;
96
 
97
+ if ( isset( $options['delegate'] ) ) {
98
+ $this->delegate = $options['delegate'];
99
+ }
100
+
101
+ if ( isset( $options['target_cron'] ) ) {
102
+ $this->target_cron = $options['target_cron'];
103
+ }
104
+
105
+ if ( isset( $options['check_interval'] ) ) {
106
+ $this->check_interval = $options['check_interval'];
107
+ }
108
+
109
+ if ( isset( $options['prime_cron'] ) ) {
110
+ $this->prime_cron = $options['prime_cron'];
111
+ }
112
+
113
+ if ( isset( $options['execute_cron'] ) ) {
114
+ $this->execute_cron = $options['execute_cron'];
115
+ }
116
+
117
+ if ( isset( $options['event_schedule'] ) ) {
118
+ $this->event_schedule = $options['event_schedule'];
119
+ }
120
+
121
+ if ( isset( $options['event_description'] ) ) {
122
+ $this->event_description = $options['event_description'];
123
+ }
124
+
125
+ if ( isset( $options['expiration_time'] ) ) {
126
+ $this->expiration_time = $options['expiration_time'];
127
+ }
128
 
129
  add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
130
  add_action( $this->prime_cron, array( $this, 'prime_reset' ) );
134
  /**
135
  * Register event schedule for this engine
136
  *
137
+ * @param array $schedules Schedule.
138
+ * @return array
139
  */
140
  public function schedule_check_interval( $schedules ) {
141
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
142
 
143
+ $schedules[ $this->event_schedule ] = array(
144
  'interval' => $this->check_interval,
145
+ 'display' => $this->event_description,
146
  );
147
 
148
  return $schedules;
151
  /**
152
  * Schedule job reset processing
153
  *
154
+ * @return void
155
  */
156
  public function prime_reset() {
157
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
158
 
159
  $next_exec_time = (int) current_time( 'timestamp', 1 ) + $this->check_interval;
160
 
161
+ SCC_Logger::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
162
+ SCC_Logger::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
163
 
164
  wp_schedule_single_event( $next_exec_time, $this->execute_cron, array() );
165
  }
167
  /**
168
  * Reset expired jobs
169
  *
170
+ * @return void
171
  */
172
  public function execute_reset() {
173
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
174
 
175
  foreach ( $this->target_cron as $key => $hook ) {
176
+ SCC_Logger::log( '[' . __METHOD__ . '] hook: ' . $hook );
177
+ SCC_WP_Cron::clear_expired_scheduled_hook( $hook, $this->expiration_time );
178
  }
179
  }
180
 
includes/class-scc-common-util.php DELETED
@@ -1,663 +0,0 @@
1
- <?php
2
- /*
3
- class-scc-common-util.php
4
-
5
- Description: This class is a common utility
6
- Author: Daisuke Maruyama
7
- Author URI: http://marubon.info/
8
- License: GPL2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
-
12
- /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
-
15
- This program is free software; you can redistribute it and/or
16
- modify it under the terms of the GNU General Public License
17
- as published by the Free Software Foundation; either version 2
18
- of the License, or (at your option) any later version.
19
-
20
- This program is distributed in the hope that it will be useful,
21
- but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- GNU General Public License for more details.
24
-
25
- You should have received a copy of the GNU General Public License
26
- along with this program; if not, write to the Free Software
27
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
- */
29
-
30
- class SCC_Common_Util {
31
-
32
- /**
33
- * Class constarctor
34
- * Hook onto all of the actions and filters needed by the plugin.
35
- *
36
- */
37
- protected function __construct() {
38
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
39
- }
40
-
41
- /**
42
- * Output log message according to WP_DEBUG setting
43
- *
44
- * @since 0.1.0
45
- */
46
- public static function log( $message ) {
47
- if ( WP_DEBUG === true ) {
48
- if ( is_array( $message ) || is_object( $message ) ) {
49
- error_log( print_r( $message, true ) );
50
- } else {
51
- error_log( $message );
52
- }
53
- }
54
- }
55
-
56
- /**
57
- * Get short hash code
58
- *
59
- * @since 0.2.0
60
- */
61
- public static function short_hash( $data, $algo = 'CRC32' ) {
62
- return strtr( rtrim( base64_encode( pack( 'H*', sprintf( '%u', $algo( $data ) ) ) ), '=' ), '+/', '-_' );
63
- }
64
-
65
- /**
66
- * Get file size of given file
67
- *
68
- * @since 0.4.0
69
- */
70
- public static function get_file_size( $file ) {
71
-
72
- if ( file_exists( $file ) && is_file( $file ) ) {
73
- $filesize = filesize( $file );
74
- $s = array( 'B', 'KB', 'MB', 'GB', 'TB', 'PB' );
75
- $e = floor( log( $filesize ) / log( 1024 ) );
76
-
77
- if( $e == 0 || $e == 1 ) {
78
- $format = '%d ';
79
- } else {
80
- $format = '%.1f ';
81
- }
82
-
83
- $filesize = sprintf( $format . $s[$e], ( $filesize / pow( 1024, floor( $e ) ) ) );
84
-
85
- return $filesize;
86
- } else {
87
- return null;
88
- }
89
- }
90
-
91
- /**
92
- * Get custom post types
93
- *
94
- * @since 0.4.0
95
- */
96
- public static function get_custom_post_types() {
97
-
98
- global $wpdb;
99
-
100
- $custom_post_types = array();
101
-
102
- $builtin_post_types = get_post_types( array( '_builtin' => true ) );
103
-
104
- $exclude_post_types = "'";
105
- $exclude_post_types .= implode( "','", $builtin_post_types );
106
- $exclude_post_types .= "'";
107
-
108
- $sql = 'SELECT DISTINCT post_type FROM ' . $wpdb->posts . ' WHERE post_type NOT IN ( ' . $exclude_post_types . ' )';
109
-
110
- $results = $wpdb->get_results( $sql );
111
-
112
- foreach ( $results as $value ) {
113
- $custom_post_types[] = $value->post_type;
114
- }
115
-
116
- return $custom_post_types;
117
- }
118
-
119
- /**
120
- * check if php-xml module is loaded or not
121
- *
122
- * @since 0.4.0
123
- */
124
- public static function extension_loaded_php_xml() {
125
- if ( extension_loaded( 'xml' ) && extension_loaded( 'xmlreader' ) && extension_loaded( 'xmlwriter' ) ) {
126
- return true;
127
- } else {
128
- return false;
129
- }
130
- }
131
-
132
- /**
133
- * convert url based on http into url based on https
134
- *
135
- * @since 0.4.0
136
- */
137
- public static function get_secure_url( $url ){
138
- $url = str_replace( 'http://', 'https://', $url );
139
- return $url;
140
- }
141
-
142
- /**
143
- * convert url based on https into url based on http
144
- *
145
- * @since 0.4.0
146
- */
147
- public static function get_normal_url( $url ){
148
- $url = str_replace( 'https://', 'http://', $url );
149
- return $url;
150
- }
151
-
152
- /**
153
- * check if a given url is based on https or not.
154
- *
155
- * @since 0.4.0
156
- */
157
- public static function is_secure_url( $url ){
158
- if ( preg_match( '/^(https)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/', $url ) ) {
159
- return true;
160
- } else {
161
- return false;
162
- }
163
- }
164
-
165
- /**
166
- * check if a given url is based on http or not.
167
- *
168
- * @since 0.4.0
169
- */
170
- public static function is_normal_url( $url ){
171
- if ( preg_match( '/^(http)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/', $url ) ) {
172
- return true;
173
- } else {
174
- return false;
175
- }
176
- }
177
-
178
- /**
179
- * get cout data from SNS
180
- *
181
- * @since 0.5.1
182
- */
183
- public static function multi_remote_get( $urls, $headers, $timeout = 0, $sslverify = true, $curl = false ) {
184
- global $wp_version;
185
-
186
- $responses = array();
187
-
188
- if ( empty( $urls ) ) {
189
- return $responses;
190
- }
191
-
192
- if ( $curl ) {
193
- SCC_Common_Util::log( '[' . __METHOD__ . '] cURL: On' );
194
-
195
- $mh = curl_multi_init();
196
- $ch = array();
197
-
198
- foreach ( $urls as $sns => $url ) {
199
- $ch[$sns] = curl_init();
200
-
201
- curl_setopt( $ch[$sns], CURLOPT_URL, $url );
202
- curl_setopt( $ch[$sns], CURLOPT_USERAGENT, 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) );
203
- curl_setopt( $ch[$sns], CURLOPT_FOLLOWLOCATION, true );
204
- curl_setopt( $ch[$sns], CURLOPT_RETURNTRANSFER, true );
205
- curl_setopt( $ch[$sns], CURLOPT_ENCODING, 'gzip' );
206
-
207
- if ( ! empty( $headers[$sns] ) ) {
208
- //curl_setopt( $ch[$sns], CURLOPT_HEADER, true );
209
-
210
- $http_headers = array();
211
-
212
- foreach ( $headers[$sns] as $key => $value ) {
213
- $http_headers[] = $key . ': ' . $value;
214
- }
215
-
216
- curl_setopt( $ch[$sns], CURLOPT_HTTPHEADER, $http_headers );
217
- }
218
-
219
- if ( $sslverify ) {
220
- curl_setopt( $ch[$sns], CURLOPT_SSL_VERIFYPEER, true );
221
- curl_setopt( $ch[$sns], CURLOPT_SSL_VERIFYHOST, 2 );
222
- } else {
223
- curl_setopt( $ch[$sns], CURLOPT_SSL_VERIFYPEER, false );
224
- curl_setopt( $ch[$sns], CURLOPT_SSL_VERIFYHOST, 0 );
225
- }
226
-
227
- if ( $timeout > 0 ) {
228
- curl_setopt( $ch[$sns], CURLOPT_CONNECTTIMEOUT, $timeout );
229
- curl_setopt( $ch[$sns], CURLOPT_TIMEOUT, $timeout );
230
- }
231
-
232
- curl_multi_add_handle( $mh, $ch[$sns] );
233
- }
234
-
235
- $active = null;
236
-
237
- do {
238
- curl_multi_exec( $mh, $active );
239
- curl_multi_select( $mh );
240
- } while ( $active > 0 );
241
-
242
- foreach ( $urls as $sns => $url ) {
243
- $responses[$sns]['error'] = curl_error( $ch[$sns] );
244
-
245
- if ( ! empty( $responses[$sns]['error'] ) ) {
246
- $responses[$sns]['data'] = '';
247
- } else {
248
- $responses[$sns]['data'] = curl_multi_getcontent( $ch[$sns] );
249
- }
250
-
251
- curl_multi_remove_handle( $mh, $ch[$sns] );
252
- curl_close( $ch[$sns] );
253
- }
254
-
255
- curl_multi_close( $mh );
256
-
257
- return $responses;
258
- } else {
259
-
260
- SCC_Common_Util::log( '[' . __METHOD__ . '] cURL: Off' );
261
-
262
- foreach ( $urls as $sns => $url ) {
263
-
264
- $options = array(
265
- 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
266
- );
267
-
268
- if ( $sslverify ) {
269
- $options['sslverify'] = true;
270
- } else {
271
- $options['sslverify'] = false;
272
- }
273
-
274
- if ( $timeout > 0 ) {
275
- $options['timeout'] = $timeout;
276
- }
277
-
278
- if ( ! empty( $headers[$sns] ) ) {
279
- $options['headers'] = $headers[$sns];
280
- }
281
-
282
- $response = wp_remote_get( $url, $options );
283
-
284
- if ( ! is_wp_error( $response ) ) {
285
- if ( $response['response']['code'] === 200 ) {
286
- $responses[$sns]['data'] = $response['body'];
287
- } else {
288
- $responses[$sns]['data'] = '';
289
- $responses[$sns]['error'] = $response['response']['code'] . ': ' . $response['response']['message'];
290
- }
291
- } else {
292
- $responses[$sns]['data'] = '';
293
- $responses[$sns]['error'] = $response->get_error_message();
294
- }
295
- }
296
-
297
- return $responses;
298
- }
299
- }
300
-
301
- public static function serialize_base64_encode( $array ) {
302
- $data = serialize( $array );
303
- $data = base64_encode( $data );
304
-
305
- return $data;
306
- }
307
-
308
- public static function unserialize_base64_decode( $data ) {
309
- $data = base64_decode( $data );
310
- $array = unserialize( $data );
311
-
312
- return $array;
313
- }
314
-
315
- /**
316
- * encrypt given data
317
- *
318
- * @since 0.9.0
319
- */
320
- public static function encrypt_data( $input, $key = 'KEY_DEFAULT' ) {
321
-
322
- if ( extension_loaded( 'mcrypt' ) ) {
323
- self::log( 'mcrypt loaded' );
324
-
325
- $key = md5( $key );
326
-
327
- $td = mcrypt_module_open( 'blowfish', '', 'ecb', '');
328
- $key = substr( $key, 0, mcrypt_enc_get_key_size( $td ) );
329
- $iv = mcrypt_create_iv( mcrypt_enc_get_iv_size( $td ), MCRYPT_RAND );
330
-
331
- if ( mcrypt_generic_init( $td, $key, $iv ) < 0 ) {
332
- exit( 'error.' );
333
- }
334
-
335
- $encrypted_data = base64_encode( mcrypt_generic( $td, $input ) );
336
-
337
- mcrypt_generic_deinit( $td );
338
- mcrypt_module_close( $td );
339
-
340
- return $encrypted_data;
341
- } else {
342
- self::log( 'mcrypt not loaded' );
343
- $crypt = new Crypt_Blowfish( $key );
344
- return $crypt->encrypt( $input );
345
- }
346
- }
347
-
348
- /**
349
- * decrypt given data
350
- *
351
- * @since 0.9.0
352
- */
353
- public static function decrypt_data( $input, $key = 'KEY_DEFAULT' ) {
354
-
355
- if ( extension_loaded( 'mcrypt' ) ) {
356
- self::log( 'mcrypt loaded' );
357
-
358
- $key = md5( $key );
359
-
360
- $td = mcrypt_module_open( 'blowfish', '', 'ecb', '' );
361
- $key = substr( $key, 0, mcrypt_enc_get_key_size( $td ) );
362
- $iv = mcrypt_create_iv( mcrypt_enc_get_iv_size( $td ), MCRYPT_RAND );
363
-
364
- if ( mcrypt_generic_init( $td, $key, $iv ) < 0 ) {
365
- exit( 'error.' );
366
- }
367
-
368
- $data = mdecrypt_generic( $td, base64_decode( $input ) );
369
-
370
- mcrypt_generic_deinit( $td );
371
- mcrypt_module_close( $td );
372
-
373
- return $data;
374
- } else {
375
- self::log( 'mcrypt not loaded' );
376
- $crypt = new Crypt_Blowfish( $key );
377
- return $crypt->decrypt( $input );
378
- }
379
- }
380
-
381
- /**
382
- * Get bearer token for Twitter
383
- *
384
- * @since 0.9.0
385
- */
386
- public static function get_twitter_bearer_token( $cosumer_key, $consumer_secret, $sslverify = true, $timeout = 10 ) {
387
- global $wp_version;
388
-
389
- $bearer_token = '';
390
- $url = 'https://api.twitter.com/oauth2/token';
391
-
392
- $credential = base64_encode( $cosumer_key . ':' . $consumer_secret );
393
-
394
- $options = array(
395
- 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
396
- );
397
-
398
- if ( $sslverify ) {
399
- $options['sslverify'] = true;
400
- } else {
401
- $options['sslverify'] = false;
402
- }
403
-
404
- if ( $timeout > 0 ) {
405
- $options['timeout'] = $timeout;
406
- }
407
-
408
- $headers = array(
409
- 'Authorization' => 'Basic ' . $credential,
410
- 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'
411
- );
412
-
413
- if ( ! empty( $headers ) ) {
414
- $options['headers'] = $headers;
415
- }
416
-
417
- $body = array(
418
- 'grant_type' => 'client_credentials'
419
- );
420
-
421
- if ( ! empty( $body ) ) {
422
- $options['body'] = $body;
423
- }
424
-
425
- $response = wp_remote_post( $url, $options );
426
-
427
- //self::log( $response );
428
-
429
- if ( ! is_wp_error( $response ) ) {
430
- if ( $response['response']['code'] === 200 ) {
431
- $json = $response['body'];
432
- $content = json_decode( $json, true ) ;
433
- if ( isset( $content['token_type'] ) && $content['token_type'] && $content['token_type'] === 'bearer' ) {
434
- if ( isset( $content['access_token'] ) && $content['access_token'] ) {
435
- $bearer_token = $content['access_token'];
436
- }
437
- }
438
- } else {
439
- return new WP_Error( 'invalid_response_code', '[ERROR] Invalid response code: ' . $response['response']['code'] . ' ' . $response['response']['message'] );
440
- }
441
- } else {
442
- return $response;
443
- }
444
-
445
- return $bearer_token;
446
- }
447
-
448
- /**
449
- * Get acess token for Instagram
450
- *
451
- * @since 0.9.0
452
- */
453
- public static function get_instagram_access_token( $client_id, $client_secret, $redirect_uri, $code, $sslverify = true, $timeout = 10 ) {
454
- global $wp_version;
455
-
456
- $access_token = '';
457
- $url = 'https://api.instagram.com/oauth/access_token';
458
-
459
- $options = array(
460
- 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
461
- );
462
-
463
- if ( $sslverify ) {
464
- $options['sslverify'] = true;
465
- } else {
466
- $options['sslverify'] = false;
467
- }
468
-
469
- if ( $timeout > 0 ) {
470
- $options['timeout'] = $timeout;
471
- }
472
-
473
- $body = array(
474
- 'client_id' => $client_id,
475
- 'client_secret' => $client_secret,
476
- 'grant_type' => 'authorization_code',
477
- 'redirect_uri' => $redirect_uri,
478
- 'code' => $code
479
- );
480
-
481
- if ( ! empty( $body ) ) {
482
- $options['body'] = $body;
483
- }
484
-
485
- $response = wp_remote_post( $url, $options );
486
-
487
- //self::log( $response );
488
-
489
- if ( ! is_wp_error( $response ) ) {
490
- if ( $response['response']['code'] === 200 ) {
491
- $json = $response['body'];
492
- $content = json_decode( $json, true ) ;
493
- if ( isset( $content['access_token'] ) && $content['access_token'] ) {
494
- $access_token = $content['access_token'];
495
- }
496
- } else {
497
- return new WP_Error( 'invalid_response_code', '[ERROR] Invalid response code: ' . $response['response']['code'] . ' ' . $response['response']['message'] );
498
- }
499
- } else {
500
- return $response;
501
- }
502
-
503
- return $access_token;
504
- }
505
-
506
- /**
507
- * Get acess token for Facebook
508
- *
509
- * @since 0.9.0
510
- */
511
- public static function get_facebook_access_token( $app_id, $app_secret, $redirect_uri, $code, $page_id, $sslverify = true, $timeout = 10 ) {
512
- global $wp_version;
513
-
514
- $original_access_token = '';
515
- $extended_access_token = '';
516
- $access_token = '';
517
-
518
- $url = 'https://graph.facebook.com/oauth/access_token';
519
-
520
- $options = array(
521
- 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
522
- );
523
-
524
- if ( $sslverify ) {
525
- $options['sslverify'] = true;
526
- } else {
527
- $options['sslverify'] = false;
528
- }
529
-
530
- if ( $timeout > 0 ) {
531
- $options['timeout'] = $timeout;
532
- }
533
-
534
- $query_parameters = array(
535
- 'client_id' => $app_id,
536
- 'client_secret' => $app_secret,
537
- 'redirect_uri' => $redirect_uri,
538
- 'code' => $code
539
- );
540
-
541
- $request_url = $url . '?' . http_build_query( $query_parameters , '' , '&' );
542
-
543
- $response = wp_remote_get( $request_url, $options );
544
-
545
- //self::log( $response );
546
-
547
- if ( ! is_wp_error( $response ) ) {
548
- if ( $response['response']['code'] === 200 ) {
549
- $json = $response['body'];
550
-
551
- parse_str( $response['body'], $data );
552
- if ( isset( $data['access_token'] ) && $data['access_token'] ) {
553
- $original_access_token = $data['access_token'];
554
- }
555
- } else {
556
- return new WP_Error( 'invalid_response_code', '[ERROR] Invalid response code: ' . $response['response']['code'] . ' ' . $response['response']['message'] );
557
- }
558
- } else {
559
- return $response;
560
- }
561
-
562
- if ( isset( $original_access_token ) && $original_access_token ) {
563
- $url = 'https://graph.facebook.com/oauth/access_token';
564
-
565
- $query_parameters = array(
566
- 'client_id' => $app_id,
567
- 'client_secret' => $app_secret,
568
- 'grant_type' => 'fb_exchange_token',
569
- 'fb_exchange_token' => $original_access_token
570
- );
571
-
572
- $request_url = $url . '?' . http_build_query( $query_parameters , '' , '&' );
573
-
574
- $response = wp_remote_get( $request_url, $options );
575
-
576
- //self::log( $response );
577
-
578
- $data = array();
579
-
580
- if ( ! is_wp_error( $response ) ) {
581
- if ( $response['response']['code'] === 200 ) {
582
- parse_str( $response['body'], $data );
583
- if ( isset( $data['access_token'] ) && $data['access_token'] ) {
584
- $extended_access_token = $data['access_token'];
585
- }
586
- } else {
587
- return new WP_Error( 'invalid_response_code', '[ERROR] Invalid response code: ' . $response['response']['code'] . ' ' . $response['response']['message'] );
588
- }
589
- } else {
590
- return $response;
591
- }
592
- }
593
-
594
- if ( isset( $extended_access_token ) && $extended_access_token ) {
595
- $url = 'https://graph.facebook.com/me/accounts';
596
-
597
- $query_parameters = array(
598
- 'access_token' => $extended_access_token
599
- );
600
-
601
- $request_url = $url . '?' . http_build_query( $query_parameters , '' , '&' );
602
-
603
- $response = wp_remote_get( $request_url, $options );
604
-
605
- //self::log( $response );
606
-
607
- if ( ! is_wp_error( $response ) ) {
608
- if ( $response['response']['code'] === 200 ) {
609
- $json = $response['body'];
610
- $content = json_decode( $json, true ) ;
611
-
612
- $i = 0;
613
-
614
- while( true ) {
615
- if ( ! isset( $content['data'][$i] ) ) {
616
- break;
617
- }
618
-
619
- if ( isset( $content['data'][$i]['id'] ) && $content['data'][$i]['id'] === $page_id ) {
620
- if ( isset( $content['data'][$i]['access_token'] ) && $content['data'][$i]['access_token'] ) {
621
- $access_token = $content['data'][$i]['access_token'];
622
- }
623
- break;
624
- }
625
-
626
- ++$i;
627
- }
628
- } else {
629
- return new WP_Error( 'invalid_response_code', '[ERROR] Invalid response code: ' . $response['response']['code'] . ' ' . $response['response']['message'] );
630
- }
631
- } else {
632
- return $response;
633
- }
634
- }
635
-
636
- return $access_token;
637
- }
638
-
639
- public static function sanitize( $str ) {
640
- $filtered = wp_check_invalid_utf8( $str );
641
-
642
- if ( strpos( $filtered, '<' ) !== false ) {
643
- $filtered = wp_pre_kses_less_than( $filtered );
644
- // This will strip extra whitespace for us.
645
- $filtered = wp_strip_all_tags( $filtered, true );
646
- } else {
647
- $filtered = trim( preg_replace( '/[\r\n\t ]+/', ' ', $filtered ) );
648
- }
649
-
650
- $filtered = trim( preg_replace('/ +/', ' ', $filtered) );
651
-
652
- return $filtered;
653
- }
654
-
655
- public static function sanitize_cache_key( $cache_key ) {
656
- $cache_key = strtolower( $cache_key );
657
- $cache_key = preg_replace( '/[^a-z0-9_\-\+]/', '', $cache_key );
658
- return $cache_key;
659
- }
660
-
661
- }
662
-
663
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-scc-crawl-strategy.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-crawl-strategy.php
4
 
5
  Description: This class is abstract class of a data crawler
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,69 +27,81 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  abstract class SCC_Crawl_Strategy {
31
 
32
  /**
33
- * TODO Auto-generated comment.
 
 
34
  */
35
- protected $url;
36
 
37
  /**
38
- * TODO Auto-generated comment.
 
 
39
  */
40
- protected $method;
41
 
42
  /**
43
- * TODO Auto-generated comment.
 
 
44
  */
45
- protected $query_parameters = array();
46
 
47
  /**
48
- * TODO Auto-generated comment.
 
 
49
  */
50
- protected $parameters = array();
51
 
52
  /**
53
  * Instance
 
 
54
  */
55
  private static $instance = array();
56
 
57
  /**
58
  * Class constarctor
59
  * Hook onto all of the actions and filters needed by the plugin.
60
- *
61
  */
62
  protected function __construct() {
63
- SCC_Common_Util::log('[' . __METHOD__ . '] (line='. __LINE__ . ')');
64
- //$this->get_object_id();
65
  }
66
 
67
  /**
68
  * Get instance
69
  *
70
- * @since 0.1.1
71
  */
72
  public static function get_instance() {
73
  $class_name = get_called_class();
74
 
75
- if ( ! isset( self::$instance[$class_name] ) ) {
76
- self::$instance[$class_name] = new $class_name();
77
  }
78
 
79
- return self::$instance[$class_name];
80
  }
81
 
82
  /**
83
  * Return object ID
84
  *
85
- * @since 0.6.0
86
  */
87
  public function get_object_id() {
88
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
89
 
90
  $object_id = spl_object_hash( $this );
91
 
92
- SCC_Common_Util::log( '[' . __METHOD__ . '] object ID: ' . $object_id );
93
 
94
  return $object_id;
95
  }
@@ -97,133 +109,161 @@ abstract class SCC_Crawl_Strategy {
97
  /**
98
  * Inhibit clone
99
  *
100
- * @since 0.6.0
 
101
  */
102
- final public function __clone() {
103
- throw new Exception('Clone is not allowed against' . get_class( $this ) );
104
- }
105
 
106
  /**
107
- * Initialization
108
  *
109
- * @since 0.6.0
 
110
  */
111
  abstract public function initialize( $options = array() );
112
 
113
  /**
114
- * TODO Auto-generated comment.
 
 
115
  */
116
  public function get_url() {
117
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
118
  return $url;
119
  }
120
 
121
  /**
122
- * TODO Auto-generated comment.
 
 
 
123
  */
124
- public function set_url( $url) {
125
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
126
  $this->url = $url;
127
  }
128
 
129
  /**
130
- * TODO Auto-generated comment.
 
 
131
  */
132
  public function get_parameters() {
133
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
134
  return $this->parameters;
135
  }
136
 
 
 
 
 
 
 
137
  public function get_parameter( $key ) {
138
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
139
- return $this->parameters[$key];
140
  }
141
 
142
  /**
143
- * TODO Auto-generated comment.
 
 
 
144
  */
145
  public function set_parameters( $parameters = array() ) {
146
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
147
- //$this->parameters = array_merge( $this->parameters, $parameters );
148
  foreach ( $parameters as $key => $value ) {
149
  $this->set_parameter( $key, $value );
150
  }
151
  }
152
 
153
  /**
154
- * TODO Auto-generated comment.
 
 
 
 
155
  */
156
  public function set_parameter( $key, $value ) {
157
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
158
- $this->parameters[$key] = $value;
159
  }
160
 
161
  /**
162
- * TODO Auto-generated comment.
 
 
163
  */
164
- public function get_query_parameters() {
165
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
166
- return $this->query_parameters;
167
- }
168
-
169
- public function get_query_parameter( $key ) {
170
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
171
- return $this->query_parameters[$key];
172
  }
173
 
174
  /**
175
- * TODO Auto-generated comment.
 
 
 
176
  */
177
- public function set_query_parameters( $query_parameters = array() ) {
178
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
179
- //$this->query_parameters = array_merge( $this->query_parameters, $query_parameters );
180
- foreach( $query_parameters as $key => $value ) {
181
- $this->set_query_parameter( $key, $value );
182
- }
183
  }
184
 
185
  /**
186
- * TODO Auto-generated comment.
 
 
187
  */
188
- public function set_query_parameter( $key, $value ) {
189
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
190
- $this->query_parameters[$key] = $value;
191
- }
192
 
193
  /**
194
- * TODO Auto-generated comment.
 
 
 
195
  */
196
- public function get_method() {
197
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
198
- return $method;
199
- }
200
 
201
  /**
202
- * TODO Auto-generated comment.
 
 
 
203
  */
204
- public function set_method( $method) {
205
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
206
- $this->method = $method;
207
- }
208
 
209
  /**
210
- * TODO Auto-generated comment.
 
 
211
  */
212
- abstract public function build_query_url();
213
 
214
  /**
215
- * TODO Auto-generated comment.
 
 
216
  */
217
- abstract public function extract_count( $content );
218
 
219
  /**
220
- * TODO Auto-generated comment.
 
 
221
  */
222
- abstract public function build_header();
223
 
224
  /**
225
- * TODO Auto-generated comment.
 
 
 
226
  */
227
- abstract public function check_configuration();
228
 
229
  }
1
  <?php
2
+ /**
3
  class-scc-crawl-strategy.php
4
 
5
  Description: This class is abstract class of a data crawler
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Crawl_Strategy
32
+ */
33
  abstract class SCC_Crawl_Strategy {
34
 
35
  /**
36
+ * URL for request
37
+ *
38
+ * @var string
39
  */
40
+ protected $url = '';
41
 
42
  /**
43
+ * HTTP method for request
44
+ *
45
+ * @var string
46
  */
47
+ protected $http_method = null;
48
 
49
  /**
50
+ * Parameters for request
51
+ *
52
+ * @var array
53
  */
54
+ protected $parameters = array();
55
 
56
  /**
57
+ * Query parameters for request
58
+ *
59
+ * @var array
60
  */
61
+ protected $query_parameters = array();
62
 
63
  /**
64
  * Instance
65
+ *
66
+ * @var array
67
  */
68
  private static $instance = array();
69
 
70
  /**
71
  * Class constarctor
72
  * Hook onto all of the actions and filters needed by the plugin.
 
73
  */
74
  protected function __construct() {
75
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
76
+ // $this->get_object_id();
77
  }
78
 
79
  /**
80
  * Get instance
81
  *
82
+ * @return SCC_Crawl_Strategy
83
  */
84
  public static function get_instance() {
85
  $class_name = get_called_class();
86
 
87
+ if ( ! isset( self::$instance[ $class_name ] ) ) {
88
+ self::$instance[ $class_name ] = new $class_name();
89
  }
90
 
91
+ return self::$instance[ $class_name ];
92
  }
93
 
94
  /**
95
  * Return object ID
96
  *
97
+ * @return string
98
  */
99
  public function get_object_id() {
100
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
101
 
102
  $object_id = spl_object_hash( $this );
103
 
104
+ SCC_Logger::log( '[' . __METHOD__ . '] object ID: ' . $object_id );
105
 
106
  return $object_id;
107
  }
109
  /**
110
  * Inhibit clone
111
  *
112
+ * @return void
113
+ * @throws Exception Clone is not allowed against.
114
  */
115
+ final public function __clone() {
116
+ throw new Exception( 'Clone is not allowed against' . get_class( $this ) );
117
+ }
118
 
119
  /**
120
+ * Initialize
121
  *
122
+ * @param array $options Option.
123
+ * @return void
124
  */
125
  abstract public function initialize( $options = array() );
126
 
127
  /**
128
+ * Get URL
129
+ *
130
+ * @return string
131
  */
132
  public function get_url() {
133
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
134
  return $url;
135
  }
136
 
137
  /**
138
+ * Set URL
139
+ *
140
+ * @param string $url URL.
141
+ * @return void
142
  */
143
+ public function set_url( $url ) {
144
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
145
  $this->url = $url;
146
  }
147
 
148
  /**
149
+ * Get parameters
150
+ *
151
+ * @return array
152
  */
153
  public function get_parameters() {
154
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
155
  return $this->parameters;
156
  }
157
 
158
+ /**
159
+ * Get parameter
160
+ *
161
+ * @param string $key Key of parameters.
162
+ * @return string
163
+ */
164
  public function get_parameter( $key ) {
165
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
166
+ return $this->parameters[ $key ];
167
  }
168
 
169
  /**
170
+ * Set parameters
171
+ *
172
+ * @param array $parameters Parameters.
173
+ * @return void
174
  */
175
  public function set_parameters( $parameters = array() ) {
176
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
177
+
178
  foreach ( $parameters as $key => $value ) {
179
  $this->set_parameter( $key, $value );
180
  }
181
  }
182
 
183
  /**
184
+ * Set parameter
185
+ *
186
+ * @param string $key Key.
187
+ * @param string $value Value.
188
+ * @return void
189
  */
190
  public function set_parameter( $key, $value ) {
191
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
192
+ $this->parameters[ $key ] = $value;
193
  }
194
 
195
  /**
196
+ * Get HTTP method
197
+ *
198
+ * @return string
199
  */
200
+ public function get_http_method() {
201
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
202
+ return $this->http_method;
 
 
 
 
 
203
  }
204
 
205
  /**
206
+ * Set HTTP method
207
+ *
208
+ * @param string $http_method HTTP method.
209
+ * @return void
210
  */
211
+ public function set_http_method( $http_method ) {
212
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
213
+ $this->http_method = $http_method;
 
 
 
214
  }
215
 
216
  /**
217
+ * Build request URL
218
+ *
219
+ * @return void
220
  */
221
+ abstract public function build_request_url();
222
+
 
 
223
 
224
  /**
225
+ * Extract response body
226
+ *
227
+ * @param string $content Response data,
228
+ * @return array
229
  */
230
+ abstract public function extract_response_body( $content );
 
 
 
231
 
232
  /**
233
+ * Extract response header
234
+ *
235
+ * @param string $content Response data,
236
+ * @return array
237
  */
238
+ abstract public function extract_response_header( $content );
 
 
 
239
 
240
  /**
241
+ * Build request header
242
+ *
243
+ * @return array
244
  */
245
+ abstract public function build_request_header();
246
 
247
  /**
248
+ * Build request body
249
+ *
250
+ * @return array
251
  */
252
+ abstract public function build_request_body();
253
 
254
  /**
255
+ * Check configuration
256
+ *
257
+ * @return array
258
  */
259
+ abstract public function check_configuration();
260
 
261
  /**
262
+ * Check rate limiting
263
+ *
264
+ * @param string $content Response data,
265
+ * @return void
266
  */
267
+ abstract public function check_rate_limiting( $content );
268
 
269
  }
includes/class-scc-crawler.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-crawler.php
4
 
5
  Description: This class is abstract class of a data crawler
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,55 +27,78 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  abstract class SCC_Crawler {
31
 
32
  /**
33
- * URL for data crawling
 
 
34
  */
35
  protected $url = '';
36
 
37
  /**
38
- * method to crawl
 
 
39
  */
40
  protected $crawl_method = 1;
41
 
42
  /**
43
  * Timeout
 
 
44
  */
45
  protected $timeout = 10;
46
 
47
  /**
48
- * ssl verification
 
 
49
  */
50
  protected $ssl_verification = true;
51
 
52
  /**
53
- * retry flag
 
 
54
  */
55
  protected $crawl_retry = false;
56
 
57
  /**
58
  * limit of crawl retry
 
 
59
  */
60
  protected $retry_limit = 0;
61
 
62
  /**
63
- * fault tolerance mode
 
 
64
  */
65
  protected $fault_tolerance = 1;
66
 
67
  /**
68
  * Instance
 
 
69
  */
70
  private static $instance = array();
71
 
72
  /**
73
- * Crawl strategies
 
 
74
  */
75
  protected $crawl_strategies = array();
76
 
77
  /**
78
  * Cache target
 
 
79
  */
80
  protected $target_sns = array();
81
 
@@ -85,113 +108,118 @@ abstract class SCC_Crawler {
85
  *
86
  */
87
  protected function __construct() {
88
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
89
  //$this->get_object_id();
90
  }
91
 
92
  /**
93
  * Get instance
94
  *
95
- * @since 0.1.1
96
  */
97
  public static function get_instance() {
98
 
99
  $class_name = get_called_class();
100
 
101
- if ( ! isset( self::$instance[$class_name] ) ) {
102
- self::$instance[$class_name] = new $class_name();
103
  }
104
 
105
- return self::$instance[$class_name];
106
  }
107
 
108
  /**
109
- * Return object ID
110
  *
111
- * @since 0.6.0
112
  */
113
  public function get_object_id() {
114
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
115
 
116
  $object_id = spl_object_hash( $this );
117
 
118
- SCC_Common_Util::log( '[' . __METHOD__ . '] object ID: ' . $object_id );
119
 
120
  return $object_id;
121
  }
122
 
123
  /**
124
- * Inhibit clone
125
  *
126
- * @since 0.6.0
 
127
  */
128
- final public function __clone() {
129
- throw new Exception( 'Clone is not allowed against' . get_class( $this ) );
130
- }
131
 
132
  /**
133
- * Initialization
134
  *
135
- * @since 0.6.0
 
136
  */
137
  abstract public function initialize( $options = array() );
138
 
139
  /**
140
- * Abstract method for data crawling
141
  *
142
- * @since 0.1.1
 
 
143
  */
144
  abstract public function get_data( $target_sns, $options );
145
 
146
  /**
147
- * Set strategy option
148
  *
149
- * @since 0.9.0
 
 
150
  */
151
  public function initialize_crawl_strategy( $sns, $options ) {
152
- if ( isset( $this->crawl_strategies[$sns] ) ) {
153
- $this->crawl_strategies[$sns]->initialize( $options );
154
  }
155
  }
156
 
157
  /**
158
- * Set strategy option
159
  *
160
- * @since 0.9.0
 
 
161
  */
162
  public function set_crawl_strategy_parameters( $sns, $options ) {
163
- if ( isset( $this->crawl_strategies[$sns] ) ) {
164
- $this->crawl_strategies[$sns]->set_parameters( $options );
165
  }
166
  }
167
 
168
  /**
169
- * Set strategy option
170
- *
171
- * @since 0.9.0
172
  */
173
- public function set_crawl_strategy_query_parameters( $sns, $options ) {
174
- if ( isset( $this->crawl_strategies[$sns] ) ) {
175
- $this->crawl_strategies[$sns]->set_query_parameters( $options );
176
- }
177
- }
178
 
179
  /**
180
- * Get strategy option
181
  *
182
- * @since 0.9.0
 
183
  */
184
- public function get_crawl_strategy_query_parameters( $sns ) {
185
- return $this->crawl_strategies[$sns]->get_query_parameters();
186
  }
187
 
188
  /**
189
- * Set strategy option
190
  *
191
- * @since 0.9.0
 
192
  */
193
  public function check_crawl_strategy_configurations( $sns ) {
194
- return $this->crawl_strategies[$sns]->check_configuration();
195
  }
196
 
197
  }
1
  <?php
2
+ /**
3
  class-scc-crawler.php
4
 
5
  Description: This class is abstract class of a data crawler
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Crawler
32
+ */
33
  abstract class SCC_Crawler {
34
 
35
  /**
36
+ * Target URL
37
+ *
38
+ * @var string
39
  */
40
  protected $url = '';
41
 
42
  /**
43
+ * Method to crawl
44
+ *
45
+ * @var string
46
  */
47
  protected $crawl_method = 1;
48
 
49
  /**
50
  * Timeout
51
+ *
52
+ * @var integer
53
  */
54
  protected $timeout = 10;
55
 
56
  /**
57
+ * Ssl verification
58
+ *
59
+ * @var boolean
60
  */
61
  protected $ssl_verification = true;
62
 
63
  /**
64
+ * Retry flag
65
+ *
66
+ * @var boolen
67
  */
68
  protected $crawl_retry = false;
69
 
70
  /**
71
  * limit of crawl retry
72
+ *
73
+ * @var integer
74
  */
75
  protected $retry_limit = 0;
76
 
77
  /**
78
+ * Fault tolerance mode
79
+ *
80
+ * @var integer
81
  */
82
  protected $fault_tolerance = 1;
83
 
84
  /**
85
  * Instance
86
+ *
87
+ * @var array
88
  */
89
  private static $instance = array();
90
 
91
  /**
92
+ * Instance of crawl strategies
93
+ *
94
+ * @var array
95
  */
96
  protected $crawl_strategies = array();
97
 
98
  /**
99
  * Cache target
100
+ *
101
+ * @var array
102
  */
103
  protected $target_sns = array();
104
 
108
  *
109
  */
110
  protected function __construct() {
111
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
112
  //$this->get_object_id();
113
  }
114
 
115
  /**
116
  * Get instance
117
  *
118
+ * @return SCC_Crawler
119
  */
120
  public static function get_instance() {
121
 
122
  $class_name = get_called_class();
123
 
124
+ if ( ! isset( self::$instance[ $class_name ] ) ) {
125
+ self::$instance[ $class_name ] = new $class_name();
126
  }
127
 
128
+ return self::$instance[ $class_name ];
129
  }
130
 
131
  /**
132
+ * Get object ID
133
  *
134
+ * @return string
135
  */
136
  public function get_object_id() {
137
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
138
 
139
  $object_id = spl_object_hash( $this );
140
 
141
+ SCC_Logger::log( '[' . __METHOD__ . '] object ID: ' . $object_id );
142
 
143
  return $object_id;
144
  }
145
 
146
  /**
147
+ * Inhibit clone processing
148
  *
149
+ * @return void
150
+ * @throws Exception Clone is not allowed against.
151
  */
152
+ final public function __clone() {
153
+ throw new Exception( 'Clone is not allowed against' . get_class( $this ) );
154
+ }
155
 
156
  /**
157
+ * Initialize
158
  *
159
+ * @param array $options Option.
160
+ * @return void
161
  */
162
  abstract public function initialize( $options = array() );
163
 
164
  /**
165
+ * Get data
166
  *
167
+ * @param array $target_sns Target SNS.
168
+ * @param array $options Option.
169
+ * @return array
170
  */
171
  abstract public function get_data( $target_sns, $options );
172
 
173
  /**
174
+ * Initialize crawl strategy with option
175
  *
176
+ * @param string $sns Target SNS.
177
+ * @param array $options Option.
178
+ * @return void
179
  */
180
  public function initialize_crawl_strategy( $sns, $options ) {
181
+ if ( isset( $this->crawl_strategies[ $sns ] ) ) {
182
+ $this->crawl_strategies[ $sns ]->initialize( $options );
183
  }
184
  }
185
 
186
  /**
187
+ * Set option of crawl strategy
188
  *
189
+ * @param sting $sns Target SNS.
190
+ * @param array $options Option.
191
+ * @return void
192
  */
193
  public function set_crawl_strategy_parameters( $sns, $options ) {
194
+ if ( isset( $this->crawl_strategies[ $sns ] ) ) {
195
+ $this->crawl_strategies[ $sns ]->set_parameters( $options );
196
  }
197
  }
198
 
199
  /**
200
+ * [get_crawl_strategy_parameters description]
201
+ * @param [type] $sns [description]
202
+ * @return [type] [description]
203
  */
 
 
 
 
 
204
 
205
  /**
206
+ * Get parameter of crawl strategy
207
  *
208
+ * @param string target SNS.
209
+ * @return array
210
  */
211
+ public function get_crawl_strategy_parameters( $sns ) {
212
+ return $this->crawl_strategies[ $sns ]->get_parameters();
213
  }
214
 
215
  /**
216
+ * Chceck Configuration of crawl strategy
217
  *
218
+ * @param $sns Target SNS.
219
+ * @return array
220
  */
221
  public function check_crawl_strategy_configurations( $sns ) {
222
+ return $this->crawl_strategies[ $sns ]->check_configuration();
223
  }
224
 
225
  }
includes/class-scc-crypt.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ class-scc-crypt.php
4
+
5
+ Description: This class is a common utility
6
+ Author: Daisuke Maruyama
7
+ Author URI: http://marubon.info/
8
+ License: GPL2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; either version 2
18
+ of the License, or (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ */
29
+
30
+ /**
31
+ * SCC_Crypt
32
+ */
33
+ class SCC_Crypt {
34
+
35
+ /**
36
+ * Class constarctor
37
+ * Hook onto all of the actions and filters needed by the plugin.
38
+ *
39
+ */
40
+ protected function __construct() {
41
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
42
+ }
43
+
44
+ /**
45
+ * Encrypt data
46
+ *
47
+ * @param data $raw_data Raw data.
48
+ * @param string $password Password.
49
+ * @return base64 Encrypted data
50
+ */
51
+ public static function encrypt( $raw_data, $password ) {
52
+ $salt = openssl_random_pseudo_bytes( 16 );
53
+
54
+ $salted = '';
55
+ $dx = '';
56
+ // Salt the key(32) and iv(16) = 48
57
+
58
+ $salted_length = strlen( $salted );
59
+ while ( $salted_length < 48 ) {
60
+ $dx = hash( 'sha256', $dx . $password . $salt, true );
61
+ $salted .= $dx;
62
+ $salted_length = strlen( $salted );
63
+ }
64
+
65
+ $key = substr( $salted, 0, 32 );
66
+ $iv = substr( $salted, 32, 16 );
67
+
68
+ $encrypted_data = openssl_encrypt( $raw_data, 'AES-256-CBC', $key, true, $iv );
69
+ return base64_encode( $salt . $encrypted_data );
70
+ }
71
+
72
+ /**
73
+ * Decrypt data
74
+ *
75
+ * @param data $encrypted_data Encrypted data.
76
+ * @param string $password Password.
77
+ * @return decrypted Data.
78
+ */
79
+ public static function decrypt( $encrypted_data, $password ) {
80
+
81
+ $data = base64_decode( $encrypted_data );
82
+ $salt = substr( $data, 0, 16 );
83
+ $ct = substr( $data, 16 );
84
+
85
+ $rounds = 3;
86
+ $data00 = $password . $salt;
87
+ $hash = array();
88
+ $hash[0] = hash( 'sha256', $data00, true );
89
+ $result = $hash[0];
90
+
91
+ for ( $i = 1; $i < $rounds; ++$i ) {
92
+ $hash[ $i ] = hash( 'sha256', $hash[ $i - 1 ] . $data00, true );
93
+ $result .= $hash[ $i ];
94
+ }
95
+
96
+ $key = substr( $result, 0, 32 );
97
+ $iv = substr( $result, 32,16 );
98
+
99
+ return openssl_decrypt( $ct, 'AES-256-CBC', $key, true, $iv );
100
+ }
101
+
102
+ }
103
+
104
+ ?>
includes/class-scc-engine.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-engine.php
4
 
5
  Description: This class is a engine
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,89 +27,104 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  abstract class SCC_Engine {
31
 
32
  /**
33
  * Cron name to schedule cache processing
 
 
34
  */
35
- protected $prime_cron = NULL;
36
 
37
  /**
38
  * Cron name to execute cache processing
 
 
39
  */
40
- protected $execute_cron = NULL;
41
 
42
  /**
43
  * Schedule name for cache processing
 
 
44
  */
45
- protected $event_schedule = NULL;
46
 
47
  /**
48
  * Schedule description for cache processing
 
 
49
  */
50
- protected $event_description = NULL;
51
 
52
  /**
53
  * Instance
 
 
54
  */
55
  private static $instance = array();
56
 
57
  /**
58
  * Class constarctor
59
  * Hook onto all of the actions and filters needed by the plugin.
60
- *
61
  */
62
  protected function __construct() {
63
- SCC_Common_Util::log('[' . __METHOD__ . '] (line='. __LINE__ . ')');
64
- //$this->get_object_id();
65
  }
66
 
67
  /**
68
  * Get instance
69
  *
70
- * @since 0.1.1
71
  */
 
72
  public static function get_instance() {
73
  $class_name = get_called_class();
74
 
75
- if ( ! isset( self::$instance[$class_name] ) ) {
76
- self::$instance[$class_name] = new $class_name();
77
  }
78
 
79
- return self::$instance[$class_name];
80
  }
81
 
82
  /**
83
- * Return object ID
84
  *
85
- * @since 0.6.0
86
  */
87
  public function get_object_id() {
88
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
89
 
90
  $object_id = spl_object_hash( $this );
91
 
92
- SCC_Common_Util::log( '[' . __METHOD__ . '] object ID: ' . $object_id );
93
 
94
  return $object_id;
95
  }
96
 
97
  /**
98
- * Inhibit clone
99
  *
100
- * @since 0.6.0
 
101
  */
102
  final public function __clone() {
103
- throw new Exception('Clone is not allowed against' . get_class( $this ) );
104
  }
105
 
 
106
  /**
107
  * Register base schedule for this engine
108
  *
109
- * @since 0.1.0
110
  */
111
  public function register_schedule() {
112
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
113
 
114
  if ( ! wp_next_scheduled( $this->prime_cron ) ) {
115
  wp_schedule_event( time(), $this->event_schedule, $this->prime_cron );
@@ -119,19 +134,19 @@ abstract class SCC_Engine {
119
  /**
120
  * Unregister base schedule for this engine
121
  *
122
- * @since 0.1.0
123
  */
124
  public function unregister_schedule() {
125
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
126
 
127
  wp_clear_scheduled_hook( $this->prime_cron );
128
- SCC_WP_Cron_Util::clear_scheduled_hook( $this->execute_cron );
129
  }
130
 
131
  /**
132
  * Get name of prime cron
133
  *
134
- * @since 0.1.1
135
  */
136
  public function get_prime_cron() {
137
  return $this->prime_cron;
@@ -140,7 +155,7 @@ abstract class SCC_Engine {
140
  /**
141
  * Get name of execute cron
142
  *
143
- * @since 0.1.1
144
  */
145
  public function get_excute_cron() {
146
  return $this->execute_cron;
@@ -149,7 +164,8 @@ abstract class SCC_Engine {
149
  /**
150
  * Initialization
151
  *
152
- * @since 0.1.1
 
153
  */
154
  abstract public function initialize( $options = array() );
155
 
1
  <?php
2
+ /**
3
  class-scc-engine.php
4
 
5
  Description: This class is a engine
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Engine
32
+ */
33
  abstract class SCC_Engine {
34
 
35
  /**
36
  * Cron name to schedule cache processing
37
+ *
38
+ * @var string
39
  */
40
+ protected $prime_cron = null;
41
 
42
  /**
43
  * Cron name to execute cache processing
44
+ *
45
+ * @var string
46
  */
47
+ protected $execute_cron = null;
48
 
49
  /**
50
  * Schedule name for cache processing
51
+ *
52
+ * @var string
53
  */
54
+ protected $event_schedule = null;
55
 
56
  /**
57
  * Schedule description for cache processing
58
+ *
59
+ * @var string
60
  */
61
+ protected $event_description = null;
62
 
63
  /**
64
  * Instance
65
+ *
66
+ * @var array
67
  */
68
  private static $instance = array();
69
 
70
  /**
71
  * Class constarctor
72
  * Hook onto all of the actions and filters needed by the plugin.
 
73
  */
74
  protected function __construct() {
75
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
76
+ // $this->get_object_id();
77
  }
78
 
79
  /**
80
  * Get instance
81
  *
82
+ * @return SCC_Engine
83
  */
84
+
85
  public static function get_instance() {
86
  $class_name = get_called_class();
87
 
88
+ if ( ! isset( self::$instance[ $class_name ] ) ) {
89
+ self::$instance[ $class_name ] = new $class_name();
90
  }
91
 
92
+ return self::$instance[ $class_name ];
93
  }
94
 
95
  /**
96
+ * Get object ID
97
  *
98
+ * @return string
99
  */
100
  public function get_object_id() {
101
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
102
 
103
  $object_id = spl_object_hash( $this );
104
 
105
+ SCC_Logger::log( '[' . __METHOD__ . '] object ID: ' . $object_id );
106
 
107
  return $object_id;
108
  }
109
 
110
  /**
111
+ * Inhibit clone processing
112
  *
113
+ * @return void
114
+ * @throws Exception Clone is not allowed against.
115
  */
116
  final public function __clone() {
117
+ throw new Exception( 'Clone is not allowed against' . get_class( $this ) );
118
  }
119
 
120
+
121
  /**
122
  * Register base schedule for this engine
123
  *
124
+ * @return void
125
  */
126
  public function register_schedule() {
127
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
128
 
129
  if ( ! wp_next_scheduled( $this->prime_cron ) ) {
130
  wp_schedule_event( time(), $this->event_schedule, $this->prime_cron );
134
  /**
135
  * Unregister base schedule for this engine
136
  *
137
+ * @return void
138
  */
139
  public function unregister_schedule() {
140
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
141
 
142
  wp_clear_scheduled_hook( $this->prime_cron );
143
+ SCC_WP_Cron::clear_scheduled_hook( $this->execute_cron );
144
  }
145
 
146
  /**
147
  * Get name of prime cron
148
  *
149
+ * @return string
150
  */
151
  public function get_prime_cron() {
152
  return $this->prime_cron;
155
  /**
156
  * Get name of execute cron
157
  *
158
+ * @return string
159
  */
160
  public function get_excute_cron() {
161
  return $this->execute_cron;
164
  /**
165
  * Initialization
166
  *
167
+ * @param array $options Option.
168
+ * @return void
169
  */
170
  abstract public function initialize( $options = array() );
171
 
includes/class-scc-export-engine.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-export-engine.php
4
 
5
  Description: This class is a data export engine whitch exports cached data using wp-cron at regular intervals
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,17 +27,24 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  abstract class SCC_Export_Engine extends SCC_Engine {
31
 
32
  /**
33
  * Meta key for share second cache
 
 
34
  */
35
- protected $share_meta_key_prefix = NULL;
36
 
37
  /**
38
  * Meta key for follow second cache
 
 
39
  */
40
- protected $follow_meta_key_prefix = NULL;
41
 
42
  }
43
 
1
  <?php
2
+ /**
3
  class-scc-export-engine.php
4
 
5
  Description: This class is a data export engine whitch exports cached data using wp-cron at regular intervals
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Export_Engine
32
+ */
33
  abstract class SCC_Export_Engine extends SCC_Engine {
34
 
35
  /**
36
  * Meta key for share second cache
37
+ *
38
+ * @var string
39
  */
40
+ protected $share_meta_key_prefix = null;
41
 
42
  /**
43
  * Meta key for follow second cache
44
+ *
45
+ * @var string
46
  */
47
+ protected $follow_meta_key_prefix = null;
48
 
49
  }
50
 
includes/class-scc-file.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ class-scc-file.php
4
+
5
+ Description: This class is a common utility
6
+ Author: Daisuke Maruyama
7
+ Author URI: http://marubon.info/
8
+ License: GPL2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; either version 2
18
+ of the License, or (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ */
29
+
30
+ /**
31
+ * SCC_File
32
+ */
33
+ class SCC_File {
34
+
35
+ /**
36
+ * Class constarctor
37
+ * Hook onto all of the actions and filters needed by the plugin.
38
+ */
39
+ protected function __construct() {
40
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
41
+ }
42
+
43
+ /**
44
+ * Get file size of given file
45
+ *
46
+ * @param string $file File path.
47
+ * @return integer
48
+ */
49
+ public static function get_file_size( $file ) {
50
+
51
+ if ( file_exists( $file ) && is_file( $file ) ) {
52
+ $filesize = filesize( $file );
53
+ $s = array( 'B', 'KB', 'MB', 'GB', 'TB', 'PB' );
54
+ $e = floor( log( $filesize ) / log( 1024 ) );
55
+
56
+ if ( 0 === $e || 1 === $e ) {
57
+ $format = '%d ';
58
+ } else {
59
+ $format = '%.1f ';
60
+ }
61
+
62
+ $filesize = sprintf( $format . $s[ $e ], ( $filesize / pow( 1024, floor( $e ) ) ) );
63
+
64
+ return $filesize;
65
+ } else {
66
+ return null;
67
+ }
68
+ }
69
+
70
+ }
71
+
72
+ ?>
includes/class-scc-follow-analytical-engine.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-follow-analytical-engine.php
4
 
5
  Description: This class is a data analytical engine.
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,6 +27,9 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  class SCC_Follow_Analytical_Engine extends SCC_Analytical_Engine {
31
 
32
  /**
@@ -66,31 +69,40 @@ class SCC_Follow_Analytical_Engine extends SCC_Analytical_Engine {
66
 
67
  /**
68
  * Interval cheking and caching target data
 
 
69
  */
70
  private $check_interval = 600;
71
 
72
  /**
73
  * Offset suffix
 
 
74
  */
75
  private $base_schedule = '* * * 0 0';
76
 
77
  /**
78
  * Base directory
 
 
79
  */
80
- private $base_dir = NULL;
81
 
82
  /**
83
  * Crawl date key
 
 
84
  */
85
- private $crawl_date_key = NULL;
86
 
87
  /**
88
  * Initialization
89
  *
90
- * @since 0.1.1
 
91
  */
92
  public function initialize( $options = array() ) {
93
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
94
 
95
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
96
  $this->base_prefix = self::DEF_BASE_PREFIX;
@@ -101,16 +113,45 @@ class SCC_Follow_Analytical_Engine extends SCC_Analytical_Engine {
101
  $this->event_description = self::DEF_EVENT_DESCRIPTION;
102
  $this->base_dir = WP_PLUGIN_DIR . '/sns-count-cache/data/';
103
 
104
- if ( isset( $options['delegate'] ) ) $this->delegate = $options['delegate'];
105
- if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
106
- if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
107
- if ( isset( $options['base_schedule'] ) ) $this->base_schedule = $options['base_schedule'];
108
- if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
109
- if ( isset( $options['base_prefix'] ) ) $this->base_prefix = $options['base_prefix'];
110
- if ( isset( $options['delta_prefix'] ) ) $this->delta_prefix = $options['delta_prefix'];
111
- if ( isset( $options['prime_cron'] ) ) $this->prime_cron = $options['prime_cron'];
112
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
113
- if ( isset( $options['crawl_date_key'] ) ) $this->crawl_date_key = $options['crawl_date_key'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
 
115
  add_action( $this->prime_cron, array( $this, 'prime_base' ) );
116
  add_action( $this->execute_cron, array( $this, 'execute_base' ), 10, 1 );
@@ -120,44 +161,46 @@ class SCC_Follow_Analytical_Engine extends SCC_Analytical_Engine {
120
  /**
121
  * Register event schedule for this engine
122
  *
123
- * @since 0.1.0
 
124
  */
125
  public function schedule_check_interval( $schedules ) {
126
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
127
 
128
- $schedules[$this->event_schedule] = array(
129
  'interval' => $this->check_interval,
130
- 'display' => $this->event_description
131
  );
132
 
133
  return $schedules;
134
  }
135
 
136
  /**
137
- * Schedule data retrieval and cache processing
138
  *
139
- * @since 0.1.0
140
  */
141
  public function prime_base() {
142
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
143
 
144
- $next_exec_time = SCC_WP_Cron_Util::next_exec_time( $this->base_schedule );
145
 
146
- SCC_Common_Util::log( '[' . __METHOD__ . '] next_exec_time (timesatamp): ' . $next_exec_time );
147
- SCC_Common_Util::log( '[' . __METHOD__ . '] next_exec_time (date): ' . date_i18n( 'Y/m/d H:i:s', $next_exec_time ) );
148
 
149
- if ( ! SCC_WP_Cron_Util::is_scheduled_hook( $this->execute_cron ) ) {
150
- wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( SCC_Common_Util::short_hash( $next_exec_time ) ) );
151
  }
152
  }
153
 
154
  /**
155
- * Get and cache data of each published post and page
156
  *
157
- * @since 0.1.0
 
158
  */
159
  public function execute_base( $hash ) {
160
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
161
 
162
  $current_date = date_i18n( 'Y/m/d H:i:s' );
163
 
@@ -166,27 +209,29 @@ class SCC_Follow_Analytical_Engine extends SCC_Analytical_Engine {
166
 
167
  if ( ! file_exists( $base_file ) ) {
168
  if ( touch( $base_file ) ) {
169
- SCC_Common_Util::log( '[' . __METHOD__ . '] file creation succeeded: ' . $base_file );
170
  } else {
171
- SCC_Common_Util::log( '[' . __METHOD__ . '] file creation failed: ' . $base_file );
172
  }
173
  }
174
 
175
  if ( file_exists( $base_file ) ) {
176
- SCC_Common_Util::log( '[' . __METHOD__ . '] file exists: ' . $base_file );
177
 
178
  $option_key = $this->get_cache_key( 'follow' );
179
 
180
- if ( false !== ( $sns_followers = get_option( $option_key ) ) ) {
 
 
181
  foreach ( $this->target_sns as $sns => $active ) {
182
  if ( $active ) {
183
  if ( $sns !== $this->crawl_date_key ) {
184
- if ( ! isset( $sns_followers[$sns] ) || $sns_followers[$sns] < 0 ) {
185
- $sns_followers[$sns] = (int) -1;
186
  }
187
  } else {
188
  if ( ! isset( $sns_followers[$sns] ) ) {
189
- $sns_followers[$sns] = '';
190
  }
191
  }
192
  }
@@ -197,15 +242,15 @@ class SCC_Follow_Analytical_Engine extends SCC_Analytical_Engine {
197
  $fp = fopen( $base_file, 'w' );
198
 
199
  if ( fwrite( $fp, $data ) ) {
200
- SCC_Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ');
201
  } else {
202
- SCC_Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ');
203
  }
204
 
205
  if ( fclose( $fp ) ) {
206
- SCC_Common_Util::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
207
  } else {
208
- SCC_Common_Util::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
209
  }
210
  }
211
  }
@@ -213,10 +258,11 @@ class SCC_Follow_Analytical_Engine extends SCC_Analytical_Engine {
213
 
214
  }
215
 
216
- /**
217
- * Initialize meta key for ranking
218
  *
219
- * @since 0.6.1
 
220
  */
221
  public function analyze( $options = array() ) {
222
 
@@ -234,9 +280,9 @@ class SCC_Follow_Analytical_Engine extends SCC_Analytical_Engine {
234
  $data = fread( $fp, filesize( $base_file ) );
235
 
236
  if ( fclose( $fp ) ) {
237
- SCC_Common_Util::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
238
  } else {
239
- SCC_Common_Util::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
240
  }
241
 
242
  $sns_base_followers = unserialize( $data );
@@ -244,9 +290,9 @@ class SCC_Follow_Analytical_Engine extends SCC_Analytical_Engine {
244
  // if there is no base file.
245
 
246
  if ( touch( $base_file ) ) {
247
- SCC_Common_Util::log( '[' . __METHOD__ . '] file creation succeeded: ' . $base_file );
248
  } else {
249
- SCC_Common_Util::log( '[' . __METHOD__ . '] file creation failed: ' . $base_file );
250
  }
251
 
252
  if ( file_exists( $base_file ) ) {
@@ -255,16 +301,18 @@ class SCC_Follow_Analytical_Engine extends SCC_Analytical_Engine {
255
 
256
  $option_key = $this->get_cache_key( 'follow' );
257
 
258
- if ( false !== ( $sns_followers = get_option( $option_key ) ) ) {
 
 
259
  foreach ( $this->target_sns as $sns => $active ) {
260
  if ( $active ) {
261
  if ( $sns !== $this->crawl_date_key ) {
262
- if ( ! isset( $sns_followers[$sns] ) || $sns_followers[$sns] < 0 ) {
263
- $sns_followers[$sns] = (int) -1;
264
  }
265
  } else {
266
- if ( ! isset( $sns_followers[$sns] ) ) {
267
- $sns_followers[$sns] = '';
268
  }
269
  }
270
  }
@@ -276,15 +324,15 @@ class SCC_Follow_Analytical_Engine extends SCC_Analytical_Engine {
276
  $fp = fopen( $base_file, 'w' );
277
 
278
  if ( fwrite( $fp, $data ) ) {
279
- SCC_Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ' );
280
  } else {
281
- SCC_Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ' );
282
  }
283
 
284
  if ( fclose( $fp ) ) {
285
- SCC_Common_Util::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
286
  } else {
287
- SCC_Common_Util::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
288
  }
289
  }
290
  }
@@ -296,23 +344,25 @@ class SCC_Follow_Analytical_Engine extends SCC_Analytical_Engine {
296
 
297
  $diffs = array();
298
 
299
- if ( false !== ( $sns_followers = get_option( $option_key ) ) ) {
 
 
300
 
301
  foreach ( $this->target_sns as $sns => $active ) {
302
  if ( $active ){
303
  if ( $sns !== $this->crawl_date_key ) {
304
- if ( isset( $sns_followers[$sns] ) && $sns_followers[$sns] !== '' && $sns_followers[$sns] >= 0 && ! isset( $sns_base_followers[$sns] ) ) {
305
- $diffs[$sns] = (int) $sns_followers[$sns];
306
- } elseif ( isset( $sns_followers[$sns] ) && $sns_followers[$sns] >= 0 && isset( $sns_base_followers[$sns] ) && $sns_base_followers[$sns] !== '' && $sns_base_followers[$sns] >= 0 ) {
307
- $diffs[$sns] = (int)( $sns_followers[$sns] - $sns_base_followers[$sns] );
308
  } else {
309
- $diffs[$sns] = (int) 0;
310
  }
311
  } else {
312
- if ( isset( $sns_followers[$sns] ) && isset( $sns_base_followers[$sns] ) && $sns_base_followers[$sns] !== '' ) {
313
- $diffs[$sns] = $sns_base_followers[$sns] . ',' . $sns_followers[$sns];
314
  } else {
315
- $diffs[$sns] = '';
316
  }
317
  }
318
  }
@@ -326,9 +376,9 @@ class SCC_Follow_Analytical_Engine extends SCC_Analytical_Engine {
326
  foreach ( $this->target_sns as $sns => $active ) {
327
  if ( $active ){
328
  if ( $sns !== $this->crawl_date_key ) {
329
- $diffs[$sns] = (int) 0;
330
  } else {
331
- $diffs[$sns] = '';
332
  }
333
  }
334
  }
@@ -339,12 +389,12 @@ class SCC_Follow_Analytical_Engine extends SCC_Analytical_Engine {
339
  }
340
 
341
  /**
342
- * Initialize meta key for ranking
343
  *
344
- * @since 0.3.0
345
  */
346
  public function initialize_base() {
347
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
348
 
349
  /*
350
  $option_key = $this->get_cache_key( $this->offset_suffix );
@@ -356,10 +406,10 @@ class SCC_Follow_Analytical_Engine extends SCC_Analytical_Engine {
356
  /**
357
  * Clear meta key for ranking
358
  *
359
- * @since 0.3.0
360
  */
361
  public function clear_base() {
362
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
363
 
364
  $option_key = $this->get_delta_key( 'follow' );
365
 
1
  <?php
2
+ /**
3
  class-scc-follow-analytical-engine.php
4
 
5
  Description: This class is a data analytical engine.
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Follow_Analytical_Engine
32
+ */
33
  class SCC_Follow_Analytical_Engine extends SCC_Analytical_Engine {
34
 
35
  /**
69
 
70
  /**
71
  * Interval cheking and caching target data
72
+ *
73
+ * @var integer
74
  */
75
  private $check_interval = 600;
76
 
77
  /**
78
  * Offset suffix
79
+ *
80
+ * @var string
81
  */
82
  private $base_schedule = '* * * 0 0';
83
 
84
  /**
85
  * Base directory
86
+ *
87
+ * @var string
88
  */
89
+ private $base_dir = null;
90
 
91
  /**
92
  * Crawl date key
93
+ *
94
+ * @var string
95
  */
96
+ private $crawl_date_key = null;
97
 
98
  /**
99
  * Initialization
100
  *
101
+ * @param array $options Option.
102
+ * @return void
103
  */
104
  public function initialize( $options = array() ) {
105
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
106
 
107
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
108
  $this->base_prefix = self::DEF_BASE_PREFIX;
113
  $this->event_description = self::DEF_EVENT_DESCRIPTION;
114
  $this->base_dir = WP_PLUGIN_DIR . '/sns-count-cache/data/';
115
 
116
+ if ( isset( $options['delegate'] ) ) {
117
+ $this->delegate = $options['delegate'];
118
+ }
119
+
120
+ if ( isset( $options['target_sns'] ) ) {
121
+ $this->target_sns = $options['target_sns'];
122
+ }
123
+
124
+ if ( isset( $options['check_interval'] ) ) {
125
+ $this->check_interval = $options['check_interval'];
126
+ }
127
+
128
+ if ( isset( $options['base_schedule'] ) ) {
129
+ $this->base_schedule = $options['base_schedule'];
130
+ }
131
+
132
+ if ( isset( $options['cache_prefix'] ) ) {
133
+ $this->cache_prefix = $options['cache_prefix'];
134
+ }
135
+
136
+ if ( isset( $options['base_prefix'] ) ) {
137
+ $this->base_prefix = $options['base_prefix'];
138
+ }
139
+
140
+ if ( isset( $options['delta_prefix'] ) ) {
141
+ $this->delta_prefix = $options['delta_prefix'];
142
+ }
143
+
144
+ if ( isset( $options['prime_cron'] ) ) {
145
+ $this->prime_cron = $options['prime_cron'];
146
+ }
147
+
148
+ if ( isset( $options['execute_cron'] ) ) {
149
+ $this->execute_cron = $options['execute_cron'];
150
+ }
151
+
152
+ if ( isset( $options['crawl_date_key'] ) ) {
153
+ $this->crawl_date_key = $options['crawl_date_key'];
154
+ }
155
 
156
  add_action( $this->prime_cron, array( $this, 'prime_base' ) );
157
  add_action( $this->execute_cron, array( $this, 'execute_base' ), 10, 1 );
161
  /**
162
  * Register event schedule for this engine
163
  *
164
+ * @param array $schedules Schedule.
165
+ * @return array
166
  */
167
  public function schedule_check_interval( $schedules ) {
168
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
169
 
170
+ $schedules[ $this->event_schedule ] = array(
171
  'interval' => $this->check_interval,
172
+ 'display' => $this->event_description,
173
  );
174
 
175
  return $schedules;
176
  }
177
 
178
  /**
179
+ * Schedule analysis processing
180
  *
181
+ * @return void
182
  */
183
  public function prime_base() {
184
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
185
 
186
+ $next_exec_time = SCC_WP_Cron::next_exec_time( $this->base_schedule );
187
 
188
+ SCC_Logger::log( '[' . __METHOD__ . '] next_exec_time (timesatamp): ' . $next_exec_time );
189
+ SCC_Logger::log( '[' . __METHOD__ . '] next_exec_time (date): ' . date_i18n( 'Y/m/d H:i:s', $next_exec_time ) );
190
 
191
+ if ( ! SCC_WP_Cron::is_scheduled_hook( $this->execute_cron ) ) {
192
+ wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( SCC_Hash::short_hash( $next_exec_time ) ) );
193
  }
194
  }
195
 
196
  /**
197
+ * Analysis processing
198
  *
199
+ * @param string $hash Hash.
200
+ * @return void
201
  */
202
  public function execute_base( $hash ) {
203
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
204
 
205
  $current_date = date_i18n( 'Y/m/d H:i:s' );
206
 
209
 
210
  if ( ! file_exists( $base_file ) ) {
211
  if ( touch( $base_file ) ) {
212
+ SCC_Logger::log( '[' . __METHOD__ . '] file creation succeeded: ' . $base_file );
213
  } else {
214
+ SCC_Logger::log( '[' . __METHOD__ . '] file creation failed: ' . $base_file );
215
  }
216
  }
217
 
218
  if ( file_exists( $base_file ) ) {
219
+ SCC_Logger::log( '[' . __METHOD__ . '] file exists: ' . $base_file );
220
 
221
  $option_key = $this->get_cache_key( 'follow' );
222
 
223
+ $sns_followers = get_option( $option_key );
224
+
225
+ if ( false !== $sns_followers ) {
226
  foreach ( $this->target_sns as $sns => $active ) {
227
  if ( $active ) {
228
  if ( $sns !== $this->crawl_date_key ) {
229
+ if ( ! isset( $sns_followers[ $sns ] ) || $sns_followers[ $sns ] < 0 ) {
230
+ $sns_followers[ $sns ] = (int) -1;
231
  }
232
  } else {
233
  if ( ! isset( $sns_followers[$sns] ) ) {
234
+ $sns_followers[ $sns ] = '';
235
  }
236
  }
237
  }
242
  $fp = fopen( $base_file, 'w' );
243
 
244
  if ( fwrite( $fp, $data ) ) {
245
+ SCC_Logger::log( '[' . __METHOD__ . '] file write succeeded: ' );
246
  } else {
247
+ SCC_Logger::log( '[' . __METHOD__ . '] file wrote failed: ' );
248
  }
249
 
250
  if ( fclose( $fp ) ) {
251
+ SCC_Logger::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
252
  } else {
253
+ SCC_Logger::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
254
  }
255
  }
256
  }
258
 
259
  }
260
 
261
+ /**
262
+ * Analyze
263
  *
264
+ * @param array $options Option.
265
+ * @return void
266
  */
267
  public function analyze( $options = array() ) {
268
 
280
  $data = fread( $fp, filesize( $base_file ) );
281
 
282
  if ( fclose( $fp ) ) {
283
+ SCC_Logger::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
284
  } else {
285
+ SCC_Logger::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
286
  }
287
 
288
  $sns_base_followers = unserialize( $data );
290
  // if there is no base file.
291
 
292
  if ( touch( $base_file ) ) {
293
+ SCC_Logger::log( '[' . __METHOD__ . '] file creation succeeded: ' . $base_file );
294
  } else {
295
+ SCC_Logger::log( '[' . __METHOD__ . '] file creation failed: ' . $base_file );
296
  }
297
 
298
  if ( file_exists( $base_file ) ) {
301
 
302
  $option_key = $this->get_cache_key( 'follow' );
303
 
304
+ $sns_followers = get_option( $option_key );
305
+
306
+ if ( false !== $sns_followers ) {
307
  foreach ( $this->target_sns as $sns => $active ) {
308
  if ( $active ) {
309
  if ( $sns !== $this->crawl_date_key ) {
310
+ if ( ! isset( $sns_followers[ $sns ] ) || 0 > $sns_followers[ $sns ] ) {
311
+ $sns_followers[ $sns ] = (int) -1;
312
  }
313
  } else {
314
+ if ( ! isset( $sns_followers[ $sns ] ) ) {
315
+ $sns_followers[ $sns ] = '';
316
  }
317
  }
318
  }
324
  $fp = fopen( $base_file, 'w' );
325
 
326
  if ( fwrite( $fp, $data ) ) {
327
+ SCC_Logger::log( '[' . __METHOD__ . '] file write succeeded: ' );
328
  } else {
329
+ SCC_Logger::log( '[' . __METHOD__ . '] file wrote failed: ' );
330
  }
331
 
332
  if ( fclose( $fp ) ) {
333
+ SCC_Logger::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
334
  } else {
335
+ SCC_Logger::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
336
  }
337
  }
338
  }
344
 
345
  $diffs = array();
346
 
347
+ $sns_followers = get_option( $option_key );
348
+
349
+ if ( false !== $sns_followers ) {
350
 
351
  foreach ( $this->target_sns as $sns => $active ) {
352
  if ( $active ){
353
  if ( $sns !== $this->crawl_date_key ) {
354
+ if ( isset( $sns_followers[ $sns ] ) && '' !== $sns_followers[ $sns ] && 0 <= $sns_followers[ $sns ] && ! isset( $sns_base_followers[ $sns ] ) ) {
355
+ $diffs[ $sns ] = (int) $sns_followers[ $sns ];
356
+ } elseif ( isset( $sns_followers[ $sns ] ) && 0 <= $sns_followers[ $sns ] && isset( $sns_base_followers[ $sns ] ) && '' !== $sns_base_followers[ $sns ] && 0 <= $sns_base_followers[ $sns ] ) {
357
+ $diffs[ $sns ] = (int) ( $sns_followers[ $sns ] - $sns_base_followers[ $sns ] );
358
  } else {
359
+ $diffs[ $sns ] = (int) 0;
360
  }
361
  } else {
362
+ if ( isset( $sns_followers[ $sns ] ) && isset( $sns_base_followers[ $sns ] ) && '' !== $sns_base_followers[ $sns ] ) {
363
+ $diffs[ $sns ] = $sns_base_followers[ $sns ] . ',' . $sns_followers[ $sns ];
364
  } else {
365
+ $diffs[ $sns ] = '';
366
  }
367
  }
368
  }
376
  foreach ( $this->target_sns as $sns => $active ) {
377
  if ( $active ){
378
  if ( $sns !== $this->crawl_date_key ) {
379
+ $diffs[ $sns ] = (int) 0;
380
  } else {
381
+ $diffs[ $sns ] = '';
382
  }
383
  }
384
  }
389
  }
390
 
391
  /**
392
+ * Schedule analysis processing
393
  *
394
+ * @return void
395
  */
396
  public function initialize_base() {
397
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
398
 
399
  /*
400
  $option_key = $this->get_cache_key( $this->offset_suffix );
406
  /**
407
  * Clear meta key for ranking
408
  *
409
+ * @return void
410
  */
411
  public function clear_base() {
412
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
413
 
414
  $option_key = $this->get_delta_key( 'follow' );
415
 
includes/class-scc-follow-base-cache-engine.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-follow-base-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,6 +27,9 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  class SCC_Follow_Base_Cache_Engine extends SCC_Follow_Cache_Engine {
31
 
32
  /**
@@ -56,21 +59,26 @@ class SCC_Follow_Base_Cache_Engine extends SCC_Follow_Cache_Engine {
56
 
57
  /**
58
  * Interval cheking and caching target data
 
 
59
  */
60
  private $check_interval = 600;
61
 
62
- /**
63
  * Offset suffix
 
 
64
  */
65
  private $offset_suffix = 'follow_base_cache_offset';
66
 
67
  /**
68
  * Initialization
69
  *
70
- * @since 0.1.1
 
71
  */
72
  public function initialize( $options = array() ) {
73
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
74
 
75
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
76
  $this->prime_cron = self::DEF_PRIME_CRON;
@@ -80,19 +88,57 @@ class SCC_Follow_Base_Cache_Engine extends SCC_Follow_Cache_Engine {
80
 
81
  $this->load_ratio = 0.5;
82
 
83
- if ( isset( $options['delegate'] ) ) $this->delegate = $options['delegate'];
84
- if ( isset( $options['crawler'] ) ) $this->crawler = $options['crawler'];
85
- if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
86
- if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
87
- if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
88
- if ( isset( $options['prime_cron'] ) ) $this->prime_cron = $options['prime_cron'];
89
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
90
- if ( isset( $options['event_schedule'] ) ) $this->event_schedule = $options['event_schedule'];
91
- if ( isset( $options['event_description'] ) ) $this->event_description = $options['event_description'];
92
- if ( isset( $options['scheme_migration_mode'] ) ) $this->scheme_migration_mode = $options['scheme_migration_mode'];
93
- if ( isset( $options['scheme_migration_exclude_keys'] ) ) $this->scheme_migration_exclude_keys = $options['scheme_migration_exclude_keys'];
94
- if ( isset( $options['cache_retry'] ) ) $this->cache_retry = $options['cache_retry'];
95
- if ( isset( $options['retry_limit'] ) ) $this->retry_limit = $options['retry_limit'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
  add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
98
  add_action( $this->prime_cron, array( $this, 'prime_cache' ) );
@@ -102,14 +148,15 @@ class SCC_Follow_Base_Cache_Engine extends SCC_Follow_Cache_Engine {
102
  /**
103
  * Register event schedule for this engine
104
  *
105
- * @since 0.1.0
 
106
  */
107
  public function schedule_check_interval( $schedules ) {
108
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
109
 
110
- $schedules[$this->event_schedule] = array(
111
  'interval' => $this->check_interval,
112
- 'display' => $this->event_description
113
  );
114
 
115
  return $schedules;
@@ -118,39 +165,40 @@ class SCC_Follow_Base_Cache_Engine extends SCC_Follow_Cache_Engine {
118
  /**
119
  * Schedule data retrieval and cache processing
120
  *
121
- * @since 0.4.0
122
  */
123
  public function prime_cache() {
124
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
125
 
126
  $next_exec_time = (int) current_time( 'timestamp', 1 ) + $this->check_interval;
127
 
128
- SCC_Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
129
- SCC_Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
130
 
131
- wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( SCC_Common_Util::short_hash( $next_exec_time ) ) );
132
  }
133
 
134
  /**
135
- * Get and cache data of each published post and page
136
  *
137
- * @since 0.1.0
 
138
  */
139
  public function execute_cache( $hash ) {
140
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
141
 
142
- SCC_Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
143
 
144
  $cache_expiration = $this->get_cache_expiration();
145
 
146
- SCC_Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
147
 
148
  $transient_id = $this->get_cache_key( 'follow' );
149
 
150
  $options = array(
151
  'cache_key' => $transient_id,
152
  'target_sns' => $this->target_sns,
153
- 'cache_expiration' => $cache_expiration
154
  );
155
 
156
  // Primary cache
@@ -161,23 +209,24 @@ class SCC_Follow_Base_Cache_Engine extends SCC_Follow_Cache_Engine {
161
  }
162
 
163
  /**
164
- * Get and cache data for a given post
165
  *
166
- * @since 0.4.0
 
167
  */
168
  public function direct_cache( $second_sync = false ) {
169
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
170
 
171
  $cache_expiration = $this->get_cache_expiration();
172
 
173
- SCC_Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
174
 
175
  $transient_id = $this->get_cache_key( 'follow' );
176
 
177
  $options = array(
178
  'cache_key' => $transient_id,
179
  'target_sns' => $this->target_sns,
180
- 'cache_expiration' => $cache_expiration
181
  );
182
 
183
  // Primary cache
@@ -192,32 +241,32 @@ class SCC_Follow_Base_Cache_Engine extends SCC_Follow_Cache_Engine {
192
  }
193
 
194
  /**
195
- * Get cache expiration based on current number of total post and page
196
  *
197
- * @since 0.4.0
198
  */
199
  protected function get_cache_expiration() {
200
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
201
 
202
  return 3 * $this->check_interval;
203
  }
204
 
205
  /**
206
- * Initialize meta key for ranking
207
  *
208
- * @since 0.3.0
209
  */
210
  public function initialize_cache() {
211
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
212
  }
213
 
214
  /**
215
- * Clear meta key for ranking
216
  *
217
- * @since 0.3.0
218
  */
219
  public function clear_cache() {
220
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
221
 
222
  $transient_id = $this->get_cache_key( 'follow' );
223
 
@@ -227,7 +276,8 @@ class SCC_Follow_Base_Cache_Engine extends SCC_Follow_Cache_Engine {
227
  /**
228
  * Get cache
229
  *
230
- * @since 0.10.1
 
231
  */
232
  public function get_cache( $options = array() ) {
233
 
@@ -235,7 +285,9 @@ class SCC_Follow_Base_Cache_Engine extends SCC_Follow_Cache_Engine {
235
 
236
  $sns_followers = array();
237
 
238
- if ( false !== ( $sns_followers = get_transient( $transient_id ) ) ) {
 
 
239
  return $sns_followers;
240
  } else {
241
  return $this->delegate_order( SCC_Order::ORDER_GET_SECOND_CACHE, $options );
1
  <?php
2
+ /**
3
  class-scc-follow-base-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Follow_Base_Cache_Engine
32
+ */
33
  class SCC_Follow_Base_Cache_Engine extends SCC_Follow_Cache_Engine {
34
 
35
  /**
59
 
60
  /**
61
  * Interval cheking and caching target data
62
+ *
63
+ * @var integer
64
  */
65
  private $check_interval = 600;
66
 
67
+ /**
68
  * Offset suffix
69
+ *
70
+ * @var string
71
  */
72
  private $offset_suffix = 'follow_base_cache_offset';
73
 
74
  /**
75
  * Initialization
76
  *
77
+ * @param array $options Option.
78
+ * @return void
79
  */
80
  public function initialize( $options = array() ) {
81
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
82
 
83
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
84
  $this->prime_cron = self::DEF_PRIME_CRON;
88
 
89
  $this->load_ratio = 0.5;
90
 
91
+ if ( isset( $options['delegate'] ) ) {
92
+ $this->delegate = $options['delegate'];
93
+ }
94
+
95
+ if ( isset( $options['crawler'] ) ) {
96
+ $this->crawler = $options['crawler'];
97
+ }
98
+
99
+ if ( isset( $options['target_sns'] ) ) {
100
+ $this->target_sns = $options['target_sns'];
101
+ }
102
+
103
+ if ( isset( $options['check_interval'] ) ) {
104
+ $this->check_interval = $options['check_interval'];
105
+ }
106
+
107
+ if ( isset( $options['cache_prefix'] ) ) {
108
+ $this->cache_prefix = $options['cache_prefix'];
109
+ }
110
+
111
+ if ( isset( $options['prime_cron'] ) ) {
112
+ $this->prime_cron = $options['prime_cron'];
113
+ }
114
+
115
+ if ( isset( $options['execute_cron'] ) ) {
116
+ $this->execute_cron = $options['execute_cron'];
117
+ }
118
+
119
+ if ( isset( $options['event_schedule'] ) ) {
120
+ $this->event_schedule = $options['event_schedule'];
121
+ }
122
+
123
+ if ( isset( $options['event_description'] ) ) {
124
+ $this->event_description = $options['event_description'];
125
+ }
126
+
127
+ if ( isset( $options['scheme_migration_mode'] ) ) {
128
+ $this->scheme_migration_mode = $options['scheme_migration_mode'];
129
+ }
130
+
131
+ if ( isset( $options['scheme_migration_exclude_keys'] ) ) {
132
+ $this->scheme_migration_exclude_keys = $options['scheme_migration_exclude_keys'];
133
+ }
134
+
135
+ if ( isset( $options['cache_retry'] ) ) {
136
+ $this->cache_retry = $options['cache_retry'];
137
+ }
138
+
139
+ if ( isset( $options['retry_limit'] ) ) {
140
+ $this->retry_limit = $options['retry_limit'];
141
+ }
142
 
143
  add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
144
  add_action( $this->prime_cron, array( $this, 'prime_cache' ) );
148
  /**
149
  * Register event schedule for this engine
150
  *
151
+ * @param array $schedules Schedule.
152
+ * @return array
153
  */
154
  public function schedule_check_interval( $schedules ) {
155
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
156
 
157
+ $schedules[ $this->event_schedule ] = array(
158
  'interval' => $this->check_interval,
159
+ 'display' => $this->event_description,
160
  );
161
 
162
  return $schedules;
165
  /**
166
  * Schedule data retrieval and cache processing
167
  *
168
+ * @return void
169
  */
170
  public function prime_cache() {
171
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
172
 
173
  $next_exec_time = (int) current_time( 'timestamp', 1 ) + $this->check_interval;
174
 
175
+ SCC_Logger::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
176
+ SCC_Logger::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
177
 
178
+ wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( SCC_Hash::short_hash( $next_exec_time ) ) );
179
  }
180
 
181
  /**
182
+ * Get and cache data of follower
183
  *
184
+ * @param string $hash Hash.
185
+ * @return void
186
  */
187
  public function execute_cache( $hash ) {
188
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
189
 
190
+ SCC_Logger::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
191
 
192
  $cache_expiration = $this->get_cache_expiration();
193
 
194
+ SCC_Logger::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
195
 
196
  $transient_id = $this->get_cache_key( 'follow' );
197
 
198
  $options = array(
199
  'cache_key' => $transient_id,
200
  'target_sns' => $this->target_sns,
201
+ 'cache_expiration' => $cache_expiration,
202
  );
203
 
204
  // Primary cache
209
  }
210
 
211
  /**
212
+ * Get and cache data of follower
213
  *
214
+ * @param boolean $second_sync Second cache flag.
215
+ * @return array
216
  */
217
  public function direct_cache( $second_sync = false ) {
218
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
219
 
220
  $cache_expiration = $this->get_cache_expiration();
221
 
222
+ SCC_Logger::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
223
 
224
  $transient_id = $this->get_cache_key( 'follow' );
225
 
226
  $options = array(
227
  'cache_key' => $transient_id,
228
  'target_sns' => $this->target_sns,
229
+ 'cache_expiration' => $cache_expiration,
230
  );
231
 
232
  // Primary cache
241
  }
242
 
243
  /**
244
+ * Get cache expiration
245
  *
246
+ * @return integer
247
  */
248
  protected function get_cache_expiration() {
249
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
250
 
251
  return 3 * $this->check_interval;
252
  }
253
 
254
  /**
255
+ * Initialize cache
256
  *
257
+ * @return void
258
  */
259
  public function initialize_cache() {
260
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
261
  }
262
 
263
  /**
264
+ * Clear cache
265
  *
266
+ * @return void
267
  */
268
  public function clear_cache() {
269
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
270
 
271
  $transient_id = $this->get_cache_key( 'follow' );
272
 
276
  /**
277
  * Get cache
278
  *
279
+ * @param array $options Option.
280
+ * @return array
281
  */
282
  public function get_cache( $options = array() ) {
283
 
285
 
286
  $sns_followers = array();
287
 
288
+ $sns_followers = get_transient( $transient_id );
289
+
290
+ if ( false !== $sns_followers ) {
291
  return $sns_followers;
292
  } else {
293
  return $this->delegate_order( SCC_Order::ORDER_GET_SECOND_CACHE, $options );
includes/class-scc-follow-cache-engine.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-follow-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,76 +27,92 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  abstract class SCC_Follow_Cache_Engine extends SCC_Cache_Engine {
31
 
 
32
  /**
33
  * Crawler instance
 
 
34
  */
35
- protected $crawler = NULL;
36
 
37
  /**
38
  * Cache target
 
 
39
  */
40
  protected $target_sns = array();
41
 
42
  /**
43
- * migration between http and https
 
 
44
  */
45
  protected $scheme_migration_mode = false;
46
 
47
  /**
48
- * excluded keys in scheme migration
 
 
49
  */
50
  protected $scheme_migration_exclude_keys = array();
51
 
52
  /**
53
- * load ratio for throttle
 
 
54
  */
55
  protected $load_ratio = 0.5;
56
 
57
  /**
58
- * Get and cache data for a given post
59
  *
60
- * @since 0.4.0
 
61
  */
62
  public function cache( $options = array() ) {
63
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
64
 
65
  $cache_key = $options['cache_key'];
66
  $target_sns = $options['target_sns'];
67
  $cache_expiration = $options['cache_expiration'];
68
 
69
- $data = $this->crawler->get_data( $target_sns, NULL );
 
70
 
71
- SCC_Common_Util::log( $data );
72
 
73
  $target_sns_base = $target_sns;
74
 
75
- unset( $target_sns_base[SNS_Count_Cache::REF_CRAWL_DATE] );
76
- unset( $target_sns_base[SNS_Count_Cache::REF_SHARE_TOTAL] );
77
 
78
  $target_sns_url = array();
79
 
80
- $query_parameters = array();
81
 
82
- $query_parameters_origin = array();
83
 
84
  $secure_url_flag = false;
85
 
86
  foreach ( $target_sns_base as $sns => $active ) {
87
  if ( $active ) {
88
- $query_parameters[$sns] = $this->crawler->get_crawl_strategy_query_parameters( $sns );
89
- SCC_Common_Util::log( $query_parameters[$sns] );
90
- if ( isset( $query_parameters[$sns]['url'] ) ) {
91
- $target_sns_url[$sns] = true;
92
- SCC_Common_Util::log( $query_parameters[$sns] );
93
- if ( SCC_Common_Util::is_secure_url( $query_parameters[$sns]['url'] ) ) {
94
  $secure_url_flag = true;
95
  }
96
- } elseif ( isset( $query_parameters[$sns]['urls'] ) ) {
97
- $target_sns_url[$sns] = true;
98
- SCC_Common_Util::log( $query_parameters[$sns] );
99
- if ( SCC_Common_Util::is_secure_url( $query_parameters[$sns]['urls'] ) ) {
100
  $secure_url_flag = true;
101
  }
102
  }
@@ -105,7 +121,7 @@ abstract class SCC_Follow_Cache_Engine extends SCC_Cache_Engine {
105
 
106
  foreach ( $target_sns_url as $sns => $active ) {
107
  if ( $active ) {
108
- $query_parameters_origin[$sns] = $this->crawler->get_crawl_strategy_query_parameters( $sns );
109
  }
110
  }
111
 
@@ -113,10 +129,10 @@ abstract class SCC_Follow_Cache_Engine extends SCC_Cache_Engine {
113
 
114
  foreach ( $target_sns_url as $sns => $active ) {
115
  if ( $active ) {
116
- if ( isset( $query_parameters[$sns]['url'] ) ) {
117
- $query_parameters[$sns]['url'] = SCC_Common_Util::get_normal_url( $query_parameters[$sns]['url'] );
118
- } elseif ( isset( $query_parameters[$sns]['urls'] ) ) {
119
- $query_parameters[$sns]['urls'] = SCC_Common_Util::get_normal_url( $query_parameters[$sns]['urls'] );
120
  }
121
  }
122
  }
@@ -124,76 +140,82 @@ abstract class SCC_Follow_Cache_Engine extends SCC_Cache_Engine {
124
  $target_sns_migrated = $target_sns_url;
125
 
126
  foreach ( $this->scheme_migration_exclude_keys as $sns ) {
127
- unset( $target_sns_migrated[$sns] );
128
  }
129
 
130
- foreach( $target_sns_url as $sns => $active ) {
131
  if ( $active ) {
132
- $this->crawler->set_crawl_strategy_query_parameters( $sns, $query_parameters[$sns] );
133
  }
134
  }
135
 
136
- $migrated_data = $this->crawler->get_data( $target_sns_migrated, NULL );
137
 
138
- SCC_Common_Util::log( $migrated_data );
139
 
140
  foreach ( $target_sns_migrated as $sns => $active ) {
141
- if ( $active && isset( $migrated_data[$sns] ) && is_numeric( $migrated_data[$sns] ) && $migrated_data[$sns] > 0 ){
142
- $data[$sns] = $data[$sns] + $migrated_data[$sns];
143
  }
144
  }
145
 
146
  foreach ( $target_sns_url as $sns => $active ) {
147
  if ( $active ) {
148
- $this->crawler->set_crawl_strategy_query_parameters( $sns, $query_parameters_origin[$sns] );
149
  }
150
  }
151
  }
152
 
153
- SCC_Common_Util::log( $data );
154
 
155
- if ( $data ) {
 
 
 
 
 
156
  $throttle = new SCC_Sleep_Throttle( $this->load_ratio );
157
 
158
  $throttle->reset();
159
  $throttle->start();
160
 
161
- $result = set_transient( $cache_key, $data, $cache_expiration );
162
 
163
  $throttle->stop();
164
 
165
  $retry_count = 0;
166
 
167
  while ( true ) {
168
- SCC_Common_Util::log( '[' . __METHOD__ . '] set_transient result (' . $cache_key . '): ' . $result );
169
 
170
  if ( $result ) {
171
  break;
172
  } else {
173
  if ( $retry_count < $this->retry_limit ) {
174
- SCC_Common_Util::log( '[' . __METHOD__ . '] sleep before set_transient retry (' . $cache_key . '): ' . $throttle->get_sleep_time() . ' sec.' );
175
 
176
  $throttle->sleep();
177
 
178
  ++$retry_count;
179
 
180
- SCC_Common_Util::log( '[' . __METHOD__ . '] count of set_transient retry (' . $cache_key . '): ' . $retry_count );
181
 
182
  $throttle->reset();
183
  $throttle->start();
184
 
185
- $result = set_transient( $cache_key, $data, $cache_expiration );
186
 
187
  $throttle->stop();
188
  } else {
189
- SCC_Common_Util::log( '[' . __METHOD__ . '] set_transient result (' . $cache_key . '): retry failed' );
190
  break;
191
  }
192
  }
193
  }
194
- }
 
195
 
196
- return $data;
197
  }
198
 
199
  }
1
  <?php
2
+ /**
3
  class-scc-follow-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Follow_Cache_Engine
32
+ */
33
  abstract class SCC_Follow_Cache_Engine extends SCC_Cache_Engine {
34
 
35
+
36
  /**
37
  * Crawler instance
38
+ *
39
+ * @var SCC_Follow_Crawler
40
  */
41
+ protected $crawler = null;
42
 
43
  /**
44
  * Cache target
45
+ *
46
+ * @var array
47
  */
48
  protected $target_sns = array();
49
 
50
  /**
51
+ * Migration between http and https
52
+ *
53
+ * @var boolean
54
  */
55
  protected $scheme_migration_mode = false;
56
 
57
  /**
58
+ * Excluded keys in scheme migration
59
+ *
60
+ * @var array
61
  */
62
  protected $scheme_migration_exclude_keys = array();
63
 
64
  /**
65
+ * Load ratio for throttle
66
+ *
67
+ * @var integer
68
  */
69
  protected $load_ratio = 0.5;
70
 
71
  /**
72
+ * Get and cache data of follower
73
  *
74
+ * @param array $options Option.
75
+ * @return array
76
  */
77
  public function cache( $options = array() ) {
78
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
79
 
80
  $cache_key = $options['cache_key'];
81
  $target_sns = $options['target_sns'];
82
  $cache_expiration = $options['cache_expiration'];
83
 
84
+ $response = $this->crawler->get_data( $target_sns, null );
85
+ $sns_count = $response['count'];
86
 
87
+ SCC_Logger::log( $sns_count );
88
 
89
  $target_sns_base = $target_sns;
90
 
91
+ unset( $target_sns_base[ SNS_Count_Cache::REF_CRAWL_DATE ] );
92
+ unset( $target_sns_base[ SNS_Count_Cache::REF_SHARE_TOTAL ] );
93
 
94
  $target_sns_url = array();
95
 
96
+ $parameters = array();
97
 
98
+ $parameters_origin = array();
99
 
100
  $secure_url_flag = false;
101
 
102
  foreach ( $target_sns_base as $sns => $active ) {
103
  if ( $active ) {
104
+ $parameters[ $sns ] = $this->crawler->get_crawl_strategy_parameters( $sns );
105
+ SCC_Logger::log( $parameters[ $sns ] );
106
+ if ( isset( $parameters[ $sns ]['url'] ) ) {
107
+ $target_sns_url[ $sns ] = true;
108
+ SCC_Logger::log( $parameters[ $sns ] );
109
+ if ( SCC_Format::is_https_url( $parameters[ $sns ]['url'] ) ) {
110
  $secure_url_flag = true;
111
  }
112
+ } elseif ( isset( $parameters[ $sns ]['urls'] ) ) {
113
+ $target_sns_url[ $sns ] = true;
114
+ SCC_Logger::log( $parameters[ $sns ] );
115
+ if ( SCC_Format::is_https_url( $parameters[ $sns ]['urls'] ) ) {
116
  $secure_url_flag = true;
117
  }
118
  }
121
 
122
  foreach ( $target_sns_url as $sns => $active ) {
123
  if ( $active ) {
124
+ $parameters_origin[ $sns ] = $this->crawler->get_crawl_strategy_parameters( $sns );
125
  }
126
  }
127
 
129
 
130
  foreach ( $target_sns_url as $sns => $active ) {
131
  if ( $active ) {
132
+ if ( isset( $parameters[ $sns ]['url'] ) ) {
133
+ $parameters[ $sns ]['url'] = SCC_Format::get_http_url( $parameters[ $sns ]['url'] );
134
+ } elseif ( isset( $parameters[ $sns ]['urls'] ) ) {
135
+ $parameters[ $sns ]['urls'] = SCC_Format::get_http_url( $parameters[ $sns ]['urls'] );
136
  }
137
  }
138
  }
140
  $target_sns_migrated = $target_sns_url;
141
 
142
  foreach ( $this->scheme_migration_exclude_keys as $sns ) {
143
+ unset( $target_sns_migrated[ $sns ] );
144
  }
145
 
146
+ foreach ( $target_sns_url as $sns => $active ) {
147
  if ( $active ) {
148
+ $this->crawler->set_crawl_strategy_parameters( $sns, $parameters[ $sns ] );
149
  }
150
  }
151
 
152
+ $migrated_sns_count = $this->crawler->get_data( $target_sns_migrated, null );
153
 
154
+ SCC_Logger::log( $migrated_sns_count );
155
 
156
  foreach ( $target_sns_migrated as $sns => $active ) {
157
+ if ( $active && isset( $migrated_sns_count[ $sns ] ) && is_numeric( $migrated_sns_count[ $sns ] ) && $migrated_sns_count[ $sns ] > 0 ) {
158
+ $sns_count[ $sns ] = $sns_count[ $sns ] + $migrated_sns_count[ $sns ];
159
  }
160
  }
161
 
162
  foreach ( $target_sns_url as $sns => $active ) {
163
  if ( $active ) {
164
+ $this->crawler->set_crawl_strategy_parameters( $sns, $parameters_origin[ $sns ] );
165
  }
166
  }
167
  }
168
 
169
+ SCC_Logger::log( $sns_count );
170
 
171
+ if ( $sns_count ) {
172
+ $result = set_transient( $cache_key, $sns_count, $cache_expiration );
173
+ }
174
+
175
+ /*
176
+ if ( $sns_count ) {
177
  $throttle = new SCC_Sleep_Throttle( $this->load_ratio );
178
 
179
  $throttle->reset();
180
  $throttle->start();
181
 
182
+ $result = set_transient( $cache_key, $sns_count, $cache_expiration );
183
 
184
  $throttle->stop();
185
 
186
  $retry_count = 0;
187
 
188
  while ( true ) {
189
+ SCC_Logger::log( '[' . __METHOD__ . '] set_transient result (' . $cache_key . '): ' . $result );
190
 
191
  if ( $result ) {
192
  break;
193
  } else {
194
  if ( $retry_count < $this->retry_limit ) {
195
+ SCC_Logger::log( '[' . __METHOD__ . '] sleep before set_transient retry (' . $cache_key . '): ' . $throttle->get_sleep_time() . ' sec.' );
196
 
197
  $throttle->sleep();
198
 
199
  ++$retry_count;
200
 
201
+ SCC_Logger::log( '[' . __METHOD__ . '] count of set_transient retry (' . $cache_key . '): ' . $retry_count );
202
 
203
  $throttle->reset();
204
  $throttle->start();
205
 
206
+ $result = set_transient( $cache_key, $sns_count, $cache_expiration );
207
 
208
  $throttle->stop();
209
  } else {
210
+ SCC_Logger::log( '[' . __METHOD__ . '] set_transient result (' . $cache_key . '): retry failed' );
211
  break;
212
  }
213
  }
214
  }
215
+ } // End if().
216
+ */
217
 
218
+ return $sns_count;
219
  }
220
 
221
  }
includes/class-scc-follow-crawl-strategy-factory.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-follow-crawl-strategy-factory.php
4
 
5
  Description: This class is a data crawler whitch get share count using given API and cURL
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,37 +27,39 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  class SCC_Follow_Crawl_Strategy_Factory {
31
 
32
  /**
33
  * Carete crawl strategy
34
  *
35
- * @since 0.9.0
 
36
  */
37
  public static function create_crawl_strategy( $sns ) {
38
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
39
 
40
  switch ( $sns ) {
41
  case SNS_Count_Cache::REF_FOLLOW_TWITTER:
42
- SCC_Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
43
- return SCC_Follow_Twitter_Strategy::get_instance();
44
- break;
45
  case SNS_Count_Cache::REF_FOLLOW_FACEBOOK:
46
- SCC_Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
47
- return SCC_Follow_Facebook_Strategy::get_instance();
48
- break;
49
  case SNS_Count_Cache::REF_FOLLOW_FEEDLY:
50
- SCC_Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
51
- return SCC_Follow_Feedly_Strategy::get_instance();
52
- break;
53
  case SNS_Count_Cache::REF_FOLLOW_INSTAGRAM:
54
- SCC_Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
55
- return SCC_Follow_Instagram_Strategy::get_instance();
56
- break;
57
  case SNS_Count_Cache::REF_FOLLOW_PUSH7:
58
- SCC_Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
59
- return SCC_Follow_Push7_Strategy::get_instance();
60
- break;
 
 
61
  }
62
  }
63
 
1
  <?php
2
+ /**
3
  class-scc-follow-crawl-strategy-factory.php
4
 
5
  Description: This class is a data crawler whitch get share count using given API and cURL
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Follow_Crawl_Strategy_Factory
32
+ */
33
  class SCC_Follow_Crawl_Strategy_Factory {
34
 
35
  /**
36
  * Carete crawl strategy
37
  *
38
+ * @param string $sns SNS.
39
+ * @return SCC_Crawl_Strategy
40
  */
41
  public static function create_crawl_strategy( $sns ) {
42
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
43
 
44
  switch ( $sns ) {
45
  case SNS_Count_Cache::REF_FOLLOW_TWITTER:
46
+ SCC_Logger::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
47
+ return SCC_Follow_Twitter_Crawl_Strategy::get_instance();
 
48
  case SNS_Count_Cache::REF_FOLLOW_FACEBOOK:
49
+ SCC_Logger::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
50
+ return SCC_Follow_Facebook_Crawl_Strategy::get_instance();
 
51
  case SNS_Count_Cache::REF_FOLLOW_FEEDLY:
52
+ SCC_Logger::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
53
+ return SCC_Follow_Feedly_Crawl_Strategy::get_instance();
 
54
  case SNS_Count_Cache::REF_FOLLOW_INSTAGRAM:
55
+ SCC_Logger::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
56
+ return SCC_Follow_Instagram_Crawl_Strategy::get_instance();
 
57
  case SNS_Count_Cache::REF_FOLLOW_PUSH7:
58
+ SCC_Logger::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
59
+ return SCC_Follow_Push7_Crawl_Strategy::get_instance();
60
+ case SNS_Count_Cache::REF_FOLLOW_ONESIGNAL:
61
+ SCC_Logger::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
62
+ return SCC_Follow_Onesignal_Crawl_Strategy::get_instance();
63
  }
64
  }
65
 
includes/class-scc-follow-crawler.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-follow-crawler.php
4
 
5
  Description: This class is a data crawler whitch get share count using given API and cURL
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -32,27 +32,45 @@ class SCC_Follow_Crawler extends SCC_Crawler {
32
  /**
33
  * Initialization
34
  *
35
- * @since 0.5.1
 
36
  */
37
  public function initialize( $options = array() ) {
38
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
39
 
40
  //$this->throttle = new Sleep_Throttle( 0.9 );
41
 
42
- if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
43
- if ( isset( $options['crawl_method'] ) ) $this->crawl_method = $options['crawl_method'];
44
- if ( isset( $options['timeout'] ) ) $this->timeout = $options['timeout'];
45
- if ( isset( $options['ssl_verification'] ) ) $this->ssl_verification = $options['ssl_verification'];
46
- if ( isset( $options['crawl_retry'] ) ) $this->crawl_retry = $options['crawl_retry'];
47
- if ( isset( $options['retry_limit'] ) ) $this->retry_limit = $options['retry_limit'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
  $target_sns = $this->target_sns;
50
 
51
- unset( $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] );
52
 
53
  foreach ( $target_sns as $sns => $active ) {
54
  if ( $active ) {
55
- $this->crawl_strategies[$sns] = SCC_Follow_Crawl_Strategy_Factory::create_crawl_strategy( $sns );
56
  }
57
  }
58
 
@@ -61,50 +79,55 @@ class SCC_Follow_Crawler extends SCC_Crawler {
61
  /**
62
  * Check configuration
63
  *
64
- * @since 0.9.0
 
65
  */
66
  private function check_configurations( $target_sns ) {
67
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
68
 
69
- //$checked_target_sns = array();
70
 
71
- unset( $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] );
72
 
73
- SCC_Common_Util::log( $target_sns );
74
 
75
  foreach ( $target_sns as $sns => $active ) {
76
  if ( $active ) {
77
- $target_sns[$sns] = $this->crawl_strategies[$sns]->check_configuration();
78
  }
79
  }
80
 
81
- $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] = true;
82
-
83
- return $target_sns;
84
 
 
85
  }
86
 
87
  /**
88
- * Implementation of abstract method. this method gets each share count
89
  *
90
- * @since 0.1.1
 
 
91
  */
92
  public function get_data( $target_sns, $options ) {
93
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
94
 
95
- SCC_Common_Util::log( $target_sns );
96
 
97
  $valid_target_sns = $this->check_configurations( $target_sns );
 
98
 
99
- SCC_Common_Util::log( $valid_target_sns );
100
-
101
- $query_urls = $this->build_query_urls( $valid_target_sns );
102
 
103
- SCC_Common_Util::log( $query_urls );
 
104
 
105
- $query_headers = $this->build_query_headers( $valid_target_sns );
 
106
 
107
- SCC_Common_Util::log( $query_headers );
 
108
 
109
  $data = array();
110
 
@@ -113,153 +136,270 @@ class SCC_Follow_Crawler extends SCC_Crawler {
113
  $throttle->reset();
114
  $throttle->start();
115
 
116
- if ( $this->crawl_method === SNS_Count_Cache::OPT_COMMON_CRAWLER_METHOD_CURL ) {
117
- $data = SCC_Common_Util::multi_remote_get( $query_urls, $query_headers, $this->timeout, $this->ssl_verification, true );
118
  } else {
119
- $data = SCC_Common_Util::multi_remote_get( $query_urls, $query_headers, $this->timeout, $this->ssl_verification, false );
120
  }
121
 
122
  $throttle->stop();
123
 
124
- $retry_count = 0;
125
 
126
- while( true ) {
127
- $target_sns_retry = array();
128
 
129
- $tmp_count = $this->extract_count( $valid_target_sns, $data );
 
130
 
131
- foreach ( $valid_target_sns as $sns => $active ){
132
- if ( $active ) {
133
- if ( $tmp_count[$sns] === -1 ) {
134
- $target_sns_retry[$sns] = true;
 
 
 
135
  }
136
  }
137
- }
138
 
139
- if ( empty( $target_sns_retry ) ) {
140
- break;
141
- } else {
142
- SCC_Common_Util::log( '[' . __METHOD__ . '] crawl failure' );
143
- SCC_Common_Util::log( $target_sns_retry );
 
 
 
 
144
 
145
- if ( $retry_count < $this->retry_limit ) {
146
 
147
- SCC_Common_Util::log( '[' . __METHOD__ . '] sleep before crawl retry: ' . $throttle->get_sleep_time() . ' sec.' );
148
 
149
- $throttle->sleep();
150
 
151
- ++$retry_count;
152
 
153
- SCC_Common_Util::log( '[' . __METHOD__ . '] count of crawl retry: ' . $retry_count );
 
 
 
154
 
155
- $query_urls_retry = $this->build_query_urls( $target_sns_retry );
156
 
157
- $query_headers_retry = $this->build_query_headers( $target_sns_retry );
 
158
 
159
- $data_retry = array();
 
 
 
 
160
 
161
- $throttle->reset();
162
- $throttle->start();
163
 
164
- if ( $this->crawl_method === SNS_Count_Cache::OPT_COMMON_CRAWLER_METHOD_CURL ) {
165
- $data_retry = SCC_Common_Util::multi_remote_get( $query_urls_retry, $query_headers_retry, $this->timeout, $this->ssl_verification, true );
166
  } else {
167
- $data_retry = SCC_Common_Util::multi_remote_get( $query_urls_retry, $query_headers_retry, $this->timeout, $this->ssl_verification, false );
 
168
  }
 
 
 
169
 
170
- $throttle->stop();
171
 
172
- $data = array_merge( $data, $data_retry );
173
- } else {
174
- SCC_Common_Util::log( '[' . __METHOD__ . '] crawling: retry failed' );
175
- break;
176
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  }
178
  }
179
 
180
- return $this->extract_count( $target_sns, $data );
181
  }
182
 
183
  /**
184
- * build query
185
  *
186
- * @since 0.5.1
 
187
  */
188
- private function build_query_urls( $target_sns ) {
189
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
190
 
191
- $query_urls = array();
192
 
193
- unset( $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] );
194
 
195
- SCC_Common_Util::log( $target_sns );
196
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
 
198
  foreach ( $target_sns as $sns => $active ) {
199
  if ( $active ) {
200
- $query_urls[$sns] = $this->crawl_strategies[$sns]->build_query_url();
201
  }
202
  }
203
 
204
- return $query_urls;
205
  }
206
 
207
  /**
208
- * build query
209
  *
210
- * @since 0.5.1
 
211
  */
212
- private function build_query_headers( $target_sns ) {
213
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
214
 
215
- $query_headers = array();
216
 
217
- unset( $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] );
218
 
219
- SCC_Common_Util::log( $target_sns );
220
 
221
  foreach ( $target_sns as $sns => $active ) {
222
  if ( $active ) {
223
- $query_headers[$sns] = $this->crawl_strategies[$sns]->build_header();
224
  }
225
  }
226
 
227
- return $query_headers;
228
  }
229
 
230
  /**
231
- * extract count data from retrieved content
232
  *
233
- * @since 0.5.1
 
 
234
  */
235
- private function extract_count( $target_sns, $contents ) {
236
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
237
 
238
  $sns_counts = array();
239
 
240
  $extract_date = date_i18n( 'Y/m/d H:i:s' );
241
 
242
- SCC_Common_Util::log( $contents );
243
 
244
  foreach ( $target_sns as $sns => $active ) {
245
  if ( $active ) {
246
- if ( isset( $contents[$sns] ) ) {
247
- $sns_counts[$sns] = $this->crawl_strategies[$sns]->extract_count( $contents[$sns] );
248
  } else {
249
- $sns_counts[$sns] = (int) -1;
250
  }
251
  }
252
  }
253
 
254
- if ( isset( $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] ) && $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] ) {
255
- $sns_counts[SNS_Count_Cache::REF_CRAWL_DATE] = $extract_date;
256
  } else {
257
- $sns_counts[SNS_Count_Cache::REF_CRAWL_DATE] = '';
258
  }
259
 
260
  return $sns_counts;
261
  }
262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
  }
264
 
265
  ?>
1
  <?php
2
+ /**
3
  class-scc-follow-crawler.php
4
 
5
  Description: This class is a data crawler whitch get share count using given API and cURL
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
32
  /**
33
  * Initialization
34
  *
35
+ * @param array $options Option.
36
+ * @return void
37
  */
38
  public function initialize( $options = array() ) {
39
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
40
 
41
  //$this->throttle = new Sleep_Throttle( 0.9 );
42
 
43
+ if ( isset( $options['target_sns'] ) ) {
44
+ $this->target_sns = $options['target_sns'];
45
+ }
46
+
47
+ if ( isset( $options['crawl_method'] ) ) {
48
+ $this->crawl_method = $options['crawl_method'];
49
+ }
50
+
51
+ if ( isset( $options['timeout'] ) ) {
52
+ $this->timeout = $options['timeout'];
53
+ }
54
+
55
+ if ( isset( $options['ssl_verification'] ) ) {
56
+ $this->ssl_verification = $options['ssl_verification'];
57
+ }
58
+
59
+ if ( isset( $options['crawl_retry'] ) ) {
60
+ $this->crawl_retry = $options['crawl_retry'];
61
+ }
62
+
63
+ if ( isset( $options['retry_limit'] ) ) {
64
+ $this->retry_limit = $options['retry_limit'];
65
+ }
66
 
67
  $target_sns = $this->target_sns;
68
 
69
+ unset( $target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] );
70
 
71
  foreach ( $target_sns as $sns => $active ) {
72
  if ( $active ) {
73
+ $this->crawl_strategies[ $sns ] = SCC_Follow_Crawl_Strategy_Factory::create_crawl_strategy( $sns );
74
  }
75
  }
76
 
79
  /**
80
  * Check configuration
81
  *
82
+ * @param array $target_sns Target SNS.
83
+ * @return array
84
  */
85
  private function check_configurations( $target_sns ) {
86
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
87
 
88
+ unset( $target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] );
89
 
90
+ SCC_Logger::log( $target_sns );
91
 
92
+ $checked_target_sns = array();
93
 
94
  foreach ( $target_sns as $sns => $active ) {
95
  if ( $active ) {
96
+ $checked_target_sns[ $sns ] = $this->crawl_strategies[ $sns ]->check_configuration();
97
  }
98
  }
99
 
100
+ $checked_target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] = true;
 
 
101
 
102
+ return $checked_target_sns;
103
  }
104
 
105
  /**
106
+ * Get data
107
  *
108
+ * @param array $target_sns Target SNS.
109
+ * @param array $options Option.
110
+ * @return array
111
  */
112
  public function get_data( $target_sns, $options ) {
113
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
114
 
115
+ SCC_Logger::log( $target_sns );
116
 
117
  $valid_target_sns = $this->check_configurations( $target_sns );
118
+ SCC_Logger::log( $valid_target_sns );
119
 
120
+ $request_http_methods = $this->get_http_methods( $valid_target_sns );
121
+ SCC_Logger::log( $request_http_methods );
 
122
 
123
+ $request_urls = $this->build_request_urls( $valid_target_sns );
124
+ SCC_Logger::log( $request_urls );
125
 
126
+ $request_headers = $this->build_request_headers( $valid_target_sns );
127
+ SCC_Logger::log( $request_headers );
128
 
129
+ $request_bodies = $this->build_request_bodies( $valid_target_sns );
130
+ SCC_Logger::log( $request_bodies );
131
 
132
  $data = array();
133
 
136
  $throttle->reset();
137
  $throttle->start();
138
 
139
+ if ( SNS_Count_Cache::OPT_COMMON_CRAWLER_METHOD_CURL === $this->crawl_method ) {
140
+ $data = SCC_HTTP::multi_remote_request( $request_urls, $request_http_methods, $request_headers, $request_bodies, $this->timeout, $this->ssl_verification, true );
141
  } else {
142
+ $data = SCC_HTTP::multi_remote_request( $request_urls, $request_http_methods, $request_headers, $request_bodies, $this->timeout, $this->ssl_verification, false );
143
  }
144
 
145
  $throttle->stop();
146
 
147
+ if ( 0 < $this->retry_limit ) {
148
 
149
+ $retry_count = 0;
 
150
 
151
+ while ( true ) {
152
+ $target_sns_retry = array();
153
 
154
+ $tmp_count = $this->extract_response_bodies( $valid_target_sns, $data );
155
+
156
+ foreach ( $valid_target_sns as $sns => $active ) {
157
+ if ( $active ) {
158
+ if ( -1 === $tmp_count[ $sns ] ) {
159
+ $target_sns_retry[ $sns ] = true;
160
+ }
161
  }
162
  }
 
163
 
164
+ $target_sns_retry = $this->check_rate_limiting( $target_sns_retry, $data );
165
+
166
+ if ( empty( $target_sns_retry ) ) {
167
+ break;
168
+ } else {
169
+ SCC_Logger::log( '[' . __METHOD__ . '] crawl failure' );
170
+ SCC_Logger::log( $target_sns_retry );
171
+
172
+ if ( $retry_count < $this->retry_limit ) {
173
 
174
+ SCC_Logger::log( '[' . __METHOD__ . '] sleep before crawl retry: ' . $throttle->get_sleep_time() . ' sec.' );
175
 
176
+ $throttle->sleep();
177
 
178
+ ++$retry_count;
179
 
180
+ SCC_Logger::log( '[' . __METHOD__ . '] count of crawl retry: ' . $retry_count );
181
 
182
+ $request_http_methods_retry = $this->get_http_methods( $target_sns_retry );
183
+ $request_urls_retry = $this->build_request_urls( $target_sns_retry );
184
+ $request_headers_retry = $this->build_request_headers( $target_sns_retry );
185
+ $request_bodies_retry = $this->build_request_bodies( $target_sns_retry );
186
 
187
+ $data_retry = array();
188
 
189
+ $throttle->reset();
190
+ $throttle->start();
191
 
192
+ if ( SNS_Count_Cache::OPT_COMMON_CRAWLER_METHOD_CURL === $this->crawl_method ) {
193
+ $data_retry = SCC_HTTP::multi_remote_request( $request_urls_retry, $request_http_methods_retry, $request_headers_retry, $request_bodies_retry, $this->timeout, $this->ssl_verification, true );
194
+ } else {
195
+ $data_retry = SCC_HTTP::multi_remote_request( $request_urls_retry, $request_http_methods_retry, $request_headers_retry, $request_bodies_retry, $this->timeout, $this->ssl_verification, true );
196
+ }
197
 
198
+ $throttle->stop();
 
199
 
200
+ $data = array_merge( (array) $data, (array) $data_retry );
 
201
  } else {
202
+ SCC_Logger::log( '[' . __METHOD__ . '] crawl retry ended' );
203
+ break;
204
  }
205
+ } // End if().
206
+ } // End while().
207
+ } // End if().
208
 
209
+ $response = array();
210
 
211
+ $response['count'] = $this->extract_response_bodies( $target_sns, $data );
212
+ $response['info'] = $this->extract_response_headers( $target_sns, $data );
213
+
214
+ return $response;
215
+ }
216
+
217
+ /**
218
+ * Get HTTP method
219
+ *
220
+ * @param array $target_sns Target SNS.
221
+ * @return array
222
+ */
223
+ private function get_http_methods( $target_sns ) {
224
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
225
+
226
+ $http_methods = array();
227
+
228
+ unset( $target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] );
229
+
230
+ SCC_Logger::log( $target_sns );
231
+
232
+ foreach ( $target_sns as $sns => $active ) {
233
+ if ( $active ) {
234
+ $http_methods[ $sns ] = $this->crawl_strategies[ $sns ]->get_http_method();
235
  }
236
  }
237
 
238
+ return $http_methods;
239
  }
240
 
241
  /**
242
+ * Build request URLs
243
  *
244
+ * @param array $target_sns Target SNS.
245
+ * @return array
246
  */
247
+ private function build_request_urls( $target_sns ) {
248
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
249
 
250
+ $request_urls = array();
251
 
252
+ unset( $target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] );
253
 
254
+ SCC_Logger::log( $target_sns );
255
 
256
+ foreach ( $target_sns as $sns => $active ) {
257
+ if ( $active ) {
258
+ $request_urls[ $sns ] = $this->crawl_strategies[ $sns ]->build_request_url();
259
+ }
260
+ }
261
+
262
+ return $request_urls;
263
+ }
264
+
265
+ /**
266
+ * Build request bodies
267
+ *
268
+ * @param array $target_sns Target SNS.
269
+ * @return array
270
+ */
271
+ private function build_request_bodies( $target_sns ) {
272
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
273
+
274
+ $request_contents = array();
275
+
276
+ unset( $target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] );
277
+
278
+ SCC_Logger::log( $target_sns );
279
 
280
  foreach ( $target_sns as $sns => $active ) {
281
  if ( $active ) {
282
+ $request_contents[ $sns ] = $this->crawl_strategies[ $sns ]->build_request_body();
283
  }
284
  }
285
 
286
+ return $request_contents;
287
  }
288
 
289
  /**
290
+ * Build request headers
291
  *
292
+ * @param array $target_sns Target SNS.
293
+ * @return array
294
  */
295
+ private function build_request_headers( $target_sns ) {
296
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
297
 
298
+ $request_headers = array();
299
 
300
+ unset( $target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] );
301
 
302
+ SCC_Logger::log( $target_sns );
303
 
304
  foreach ( $target_sns as $sns => $active ) {
305
  if ( $active ) {
306
+ $request_headers[ $sns ] = $this->crawl_strategies[ $sns ]->build_request_header();
307
  }
308
  }
309
 
310
+ return $request_headers;
311
  }
312
 
313
  /**
314
+ * Extract response bodies
315
  *
316
+ * @param array $target_sns Target SNS.
317
+ * @param array $contents Contents.
318
+ * @return void
319
  */
320
+ private function extract_response_bodies( $target_sns, $contents ) {
321
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
322
 
323
  $sns_counts = array();
324
 
325
  $extract_date = date_i18n( 'Y/m/d H:i:s' );
326
 
327
+ SCC_Logger::log( $contents );
328
 
329
  foreach ( $target_sns as $sns => $active ) {
330
  if ( $active ) {
331
+ if ( isset( $contents[ $sns ] ) ) {
332
+ $sns_counts[ $sns ] = $this->crawl_strategies[ $sns ]->extract_response_body( $contents[ $sns ] );
333
  } else {
334
+ $sns_counts[ $sns ] = (int) -1;
335
  }
336
  }
337
  }
338
 
339
+ if ( isset( $target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] ) && $target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] ) {
340
+ $sns_counts[ SNS_Count_Cache::REF_CRAWL_DATE ] = $extract_date;
341
  } else {
342
+ $sns_counts[ SNS_Count_Cache::REF_CRAWL_DATE ] = '';
343
  }
344
 
345
  return $sns_counts;
346
  }
347
 
348
+ /**
349
+ * Extract response headers
350
+ *
351
+ * @param array $target_sns Target SNS.
352
+ * @param array $contents Contents.
353
+ * @return array
354
+ */
355
+ private function extract_response_headers( $target_sns, $contents ) {
356
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
357
+
358
+ $sns_headers = array();
359
+
360
+ unset( $target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] );
361
+
362
+ SCC_Logger::log( $contents );
363
+
364
+ foreach ( $target_sns as $sns => $active ) {
365
+ if ( $active ) {
366
+ if ( isset( $contents[ $sns ] ) ) {
367
+ $sns_headers[ $sns ] = $this->crawl_strategies[ $sns ]->extract_response_header( $contents[ $sns ] );
368
+ } else {
369
+ $sns_headers[ $sns ] = null;
370
+ }
371
+ }
372
+ }
373
+
374
+ return $sns_headers;
375
+ }
376
+
377
+ /**
378
+ * Check rate limiting
379
+ *
380
+ * @param array $target_sns Target SNS.
381
+ * @param array $contents Contents.
382
+ * @return array
383
+ */
384
+ private function check_rate_limiting( $target_sns, $contents ) {
385
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
386
+
387
+ unset( $target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] );
388
+
389
+ $checked_target_sns = array();
390
+
391
+ foreach ( $target_sns as $sns => $active ) {
392
+ if ( $active ) {
393
+ $checked_target_sns[ $sns ] = $this->crawl_strategies[ $sns ]->check_rate_limiting( $contents[ $sns ] );
394
+ }
395
+ }
396
+
397
+ // $target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] = true;
398
+ // $target_sns[ SNS_Count_Cache::REF_SHARE_TOTAL ] = true;
399
+
400
+ return $checked_target_sns;
401
+ }
402
+
403
  }
404
 
405
  ?>
includes/class-scc-follow-facebook-crawl-strategy.php ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ class-scc-follow-facebook-crawl-strategy.php
4
+
5
+ Description: This class is abstract class of a data crawler
6
+ Author: Daisuke Maruyama
7
+ Author URI: http://marubon.info/
8
+ License: GPL2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; either version 2
18
+ of the License, or (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ */
29
+
30
+ /**
31
+ * SCC_Follow_Facebook_Crawl_Strategy
32
+ */
33
+ class SCC_Follow_Facebook_Crawl_Strategy extends SCC_Crawl_Strategy {
34
+
35
+ /**
36
+ * SNS base URL
37
+ *
38
+ * @var string
39
+ */
40
+ const DEF_BASE_URL = 'https://graph.facebook.com/v3.2/';
41
+
42
+ /**
43
+ * Class constarctor
44
+ * Hook onto all of the actions and filters needed by the plugin.
45
+ */
46
+ protected function __construct() {
47
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
48
+
49
+ $this->http_method = 'GET';
50
+ }
51
+
52
+ /**
53
+ * Initialization
54
+ *
55
+ * @param array $options Option.
56
+ * @return void
57
+ */
58
+ public function initialize( $options = array() ) {
59
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
60
+
61
+ $this->set_parameters( $options );
62
+ }
63
+
64
+ /**
65
+ * Build request header
66
+ *
67
+ * @return array
68
+ */
69
+ public function build_request_header() {
70
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
71
+ return null;
72
+ }
73
+
74
+ /**
75
+ * Build request body
76
+ *
77
+ * @return array
78
+ */
79
+ public function build_request_body() {
80
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
81
+ return null;
82
+ }
83
+
84
+ /**
85
+ * Build request URL
86
+ *
87
+ * @return string
88
+ */
89
+ public function build_request_url() {
90
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
91
+
92
+ $url = self::DEF_BASE_URL . $this->parameters['page_id'] . '/insights/page_fans/lifetime' . '?' . http_build_query( $this->query_parameters , '' , '&' );
93
+
94
+ return $url;
95
+ }
96
+
97
+ /**
98
+ * Extract response body
99
+ *
100
+ * @param array $content Content.
101
+ * @return array
102
+ */
103
+ public function extract_response_body( $content ) {
104
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
105
+
106
+ $count = (int) -1;
107
+
108
+ if ( isset( $content['body'] ) && empty( $content['error'] ) ) {
109
+
110
+ $json = json_decode( $content['body'], true );
111
+
112
+ SCC_Logger::log( $json );
113
+
114
+ $i = 0;
115
+
116
+ while ( $i < 30 ) {
117
+ if ( isset( $json['data'][0]['values'][ $i ]['value'] ) && is_numeric( $json['data'][0]['values'][ $i ]['value'] ) ) {
118
+ $count = (int) $json['data'][0]['values'][ $i ]['value'];
119
+ }
120
+ ++$i;
121
+ }
122
+ } else {
123
+ $count = (int) -1;
124
+
125
+ if ( isset( $content['error'] ) ) {
126
+ SCC_Logger::log( $content['error'] );
127
+ }
128
+ }
129
+
130
+ return $count;
131
+ }
132
+
133
+ /**
134
+ * Extract response header
135
+ *
136
+ * @param array $content Content.
137
+ * @return array
138
+ */
139
+ public function extract_response_header( $content ) {
140
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
141
+ return null;
142
+ }
143
+
144
+ /**
145
+ * Set parameter
146
+ *
147
+ * @param string $key Key.
148
+ * @param string $value Value.
149
+ * @return void
150
+ */
151
+ public function set_parameter( $key, $value ) {
152
+ if ( 'access_token' === $key ) {
153
+ $this->query_parameters[ $key ] = $value;
154
+ } elseif ( 'client_id' === $key ) {
155
+ $this->parameters[ $key ] = $value;
156
+ } elseif ( 'client_secret' === $key ) {
157
+ $this->parameters[ $key ] = $value;
158
+ } elseif ( 'page_id' === $key ) {
159
+ $this->parameters[ $key ] = $value;
160
+ }
161
+ }
162
+
163
+ /**
164
+ * Check if required paramters are included or not.
165
+ *
166
+ * @return boolean
167
+ */
168
+ public function check_configuration() {
169
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
170
+
171
+ if ( ! empty( $this->parameters['client_id'] ) && ! empty( $this->parameters['client_secret'] ) &&
172
+ ! empty( $this->query_parameters['access_token'] ) && ! empty( $this->parameters['page_id'] ) ) {
173
+ return true;
174
+ } else {
175
+ return false;
176
+ }
177
+ }
178
+
179
+ /**
180
+ * Check if there is rate limiting or not.
181
+ *
182
+ * @param string $content Content.
183
+ * @return boolean
184
+ */
185
+ public function check_rate_limiting( $content ) {
186
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
187
+
188
+ return true;
189
+ }
190
+
191
+ }
includes/class-scc-follow-facebook-strategy.php DELETED
@@ -1,138 +0,0 @@
1
- <?php
2
- /*
3
- class-scc-follow-facebook-strategy.php
4
-
5
- Description: This class is abstract class of a data crawler
6
- Author: Daisuke Maruyama
7
- Author URI: http://marubon.info/
8
- License: GPL2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
-
12
- /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
-
15
- This program is free software; you can redistribute it and/or
16
- modify it under the terms of the GNU General Public License
17
- as published by the Free Software Foundation; either version 2
18
- of the License, or (at your option) any later version.
19
-
20
- This program is distributed in the hope that it will be useful,
21
- but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- GNU General Public License for more details.
24
-
25
- You should have received a copy of the GNU General Public License
26
- along with this program; if not, write to the Free Software
27
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
- */
29
-
30
- class SCC_Follow_Facebook_Strategy extends SCC_Crawl_Strategy {
31
-
32
- /**
33
- * SNS base url
34
- */
35
- const DEF_BASE_URL = 'https://graph.facebook.com/';
36
-
37
- /**
38
- * Class constarctor
39
- * Hook onto all of the actions and filters needed by the plugin.
40
- *
41
- */
42
- protected function __construct() {
43
- SCC_Common_Util::log('[' . __METHOD__ . '] (line='. __LINE__ . ')');
44
-
45
- $this->method = 'GET';
46
- }
47
-
48
- /**
49
- * Initialization
50
- *
51
- * @since 0.9.0
52
- */
53
- public function initialize( $options = array() ) {
54
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
55
-
56
- if ( isset( $options['url'] ) ) $this->url = $options['url'];
57
- if ( isset( $options['method'] ) ) $this->method = $options['method'];
58
- if ( isset( $options['parameters'] ) ) $this->parameters = $options['parameters'];
59
- }
60
-
61
- /**
62
- * Build header
63
- *
64
- * @since 0.9.0
65
- */
66
- public function build_header() {
67
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
68
- return null;
69
- }
70
-
71
- /**
72
- * Build query url
73
- *
74
- * @since 0.9.0
75
- */
76
- public function build_query_url() {
77
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
78
-
79
- $url = self::DEF_BASE_URL . $this->parameters['page_id'] . '/insights/page_fans/lifetime' . '?' . http_build_query( $this->query_parameters , '' , '&' );
80
-
81
- return $url;
82
- }
83
-
84
- /**
85
- * Extract count
86
- *
87
- * @since 0.9.0
88
- */
89
- public function extract_count( $content ) {
90
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
91
-
92
- $count = (int) -1;
93
-
94
- if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
95
-
96
- $json = json_decode( $content['data'], true );
97
-
98
- SCC_Common_Util::log( $json );
99
-
100
- if ( isset( $json['data'][0]['values'][2]['value'] ) && is_numeric( $json['data'][0]['values'][2]['value'] ) ) {
101
- $count = (int) $json['data'][0]['values'][2]['value'];
102
- } elseif ( isset( $json['data'][0]['values'][0]['value'] ) && is_numeric( $json['data'][0]['values'][0]['value'] ) ) {
103
- $count = (int) $json['data'][0]['values'][0]['value'];
104
- } else {
105
- $count = (int) -1;
106
- }
107
- } else {
108
- $count = (int) -1;
109
- }
110
-
111
- return $count;
112
- }
113
-
114
- public function set_query_parameter( $key, $value ) {
115
- if ( $key === 'access_token' ) {
116
- $this->query_parameters[$key] = $value;
117
- }
118
- }
119
-
120
- /**
121
- * Check if required paramters are included or not.
122
- *
123
- * @since 0.9.0
124
- */
125
- public function check_configuration() {
126
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
127
-
128
- if ( isset( $this->parameters['client_id'] ) && $this->parameters['client_id'] &&
129
- isset( $this->parameters['client_secret'] ) && $this->parameters['client_secret'] &&
130
- isset( $this->query_parameters['access_token'] ) && $this->query_parameters['access_token'] &&
131
- isset( $this->parameters['page_id'] ) && $this->parameters['page_id'] ) {
132
- return true;
133
- } else {
134
- return false;
135
- }
136
- }
137
-
138
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-scc-follow-feedly-crawl-strategy.php ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ class-scc-follow-feedly-crawl-strategy.php
4
+
5
+ Description: This class is abstract class of a data crawler
6
+ Author: Daisuke Maruyama
7
+ Author URI: http://marubon.info/
8
+ License: GPL2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; either version 2
18
+ of the License, or (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ */
29
+
30
+ /**
31
+ * SCC_Follow_Feedly_Crawl_Strategy
32
+ */
33
+ class SCC_Follow_Feedly_Crawl_Strategy extends SCC_Crawl_Strategy {
34
+
35
+ /**
36
+ * SNS base URL
37
+ *
38
+ * @var string
39
+ */
40
+ const DEF_BASE_URL = 'http://cloud.feedly.com/v3/feeds/feed%2F';
41
+
42
+ /**
43
+ * Class constarctor
44
+ * Hook onto all of the actions and filters needed by the plugin.
45
+ */
46
+ protected function __construct() {
47
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
48
+
49
+ $this->http_method = 'GET';
50
+ }
51
+
52
+ /**
53
+ * Initialization
54
+ *
55
+ * @param array $options Option.
56
+ * @return void
57
+ */
58
+ public function initialize( $options = array() ) {
59
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
60
+
61
+ $this->set_parameters( $options );
62
+ }
63
+
64
+ /**
65
+ * Build request header
66
+ *
67
+ * @return array
68
+ */
69
+ public function build_request_header() {
70
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
71
+ return null;
72
+ }
73
+
74
+ /**
75
+ * Build request body
76
+ *
77
+ * @return array
78
+ */
79
+ public function build_request_body() {
80
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
81
+ return null;
82
+ }
83
+
84
+ /**
85
+ * Build request URL
86
+ *
87
+ * @return string
88
+ */
89
+ public function build_request_url() {
90
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
91
+
92
+ $url = self::DEF_BASE_URL . rawurlencode( $this->query_parameters['url'] );
93
+
94
+ return $url;
95
+ }
96
+
97
+ /**
98
+ * Extract response body
99
+ *
100
+ * @param array $content Content.
101
+ * @return array
102
+ */
103
+ public function extract_response_body( $content ) {
104
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
105
+
106
+ $count = (int) -1;
107
+
108
+ if ( isset( $content['body'] ) && empty( $content['error'] ) ) {
109
+ $json = json_decode( $content['body'], true );
110
+
111
+ if ( isset( $json['subscribers'] ) && is_numeric( $json['subscribers'] ) ) {
112
+ $count = (int) $json['subscribers'];
113
+ } else {
114
+ $count = (int) -1;
115
+ }
116
+ } else {
117
+ $count = (int) -1;
118
+
119
+ if ( isset( $content['error'] ) ) {
120
+ SCC_Logger::log( $content['error'] );
121
+ }
122
+ }
123
+
124
+ return $count;
125
+ }
126
+
127
+ /**
128
+ * Extract response header
129
+ *
130
+ * @param array $content Content.
131
+ * @return array
132
+ */
133
+ public function extract_response_header( $content ) {
134
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
135
+ return null;
136
+ }
137
+
138
+ /**
139
+ * Set parameter
140
+ *
141
+ * @param string $key Key.
142
+ * @param string $value Value.
143
+ * @return void
144
+ */
145
+ public function set_parameter( $key, $value ) {
146
+ if ( 'url' === $key ) {
147
+ $this->query_parameters[ $key ] = $value;
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Check if required paramters are included or not.
153
+ *
154
+ * @return boolean
155
+ */
156
+ public function check_configuration() {
157
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
158
+
159
+ if ( ! empty( $this->query_parameters['url'] ) ) {
160
+ return true;
161
+ } else {
162
+ return false;
163
+ }
164
+ }
165
+
166
+ /**
167
+ * Check if there is rate limiting or not.
168
+ *
169
+ * @param string $content Content.
170
+ * @return boolean
171
+ */
172
+ public function check_rate_limiting( $content ) {
173
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
174
+
175
+ return true;
176
+ }
177
+
178
+ }
includes/class-scc-follow-feedly-strategy.php DELETED
@@ -1,130 +0,0 @@
1
- <?php
2
- /*
3
- class-scc-follow-feedly-strategy.php
4
-
5
- Description: This class is abstract class of a data crawler
6
- Author: Daisuke Maruyama
7
- Author URI: http://marubon.info/
8
- License: GPL2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
-
12
- /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
-
15
- This program is free software; you can redistribute it and/or
16
- modify it under the terms of the GNU General Public License
17
- as published by the Free Software Foundation; either version 2
18
- of the License, or (at your option) any later version.
19
-
20
- This program is distributed in the hope that it will be useful,
21
- but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- GNU General Public License for more details.
24
-
25
- You should have received a copy of the GNU General Public License
26
- along with this program; if not, write to the Free Software
27
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
- */
29
-
30
- class SCC_Follow_Feedly_Strategy extends SCC_Crawl_Strategy {
31
-
32
- /**
33
- * SNS base url
34
- */
35
- const DEF_BASE_URL = 'http://cloud.feedly.com/v3/feeds/feed%2F';
36
-
37
- /**
38
- * Class constarctor
39
- * Hook onto all of the actions and filters needed by the plugin.
40
- *
41
- */
42
- protected function __construct() {
43
- SCC_Common_Util::log('[' . __METHOD__ . '] (line='. __LINE__ . ')');
44
-
45
- $this->method = 'GET';
46
- }
47
-
48
- /**
49
- * Initialization
50
- *
51
- * @since 0.9.0
52
- */
53
- public function initialize( $options = array() ) {
54
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
55
-
56
- if ( isset( $options['url'] ) ) $this->url = $options['url'];
57
- if ( isset( $options['method'] ) ) $this->method = $options['method'];
58
- if ( isset( $options['parameters'] ) ) $this->parameters = $options['parameters'];
59
- }
60
-
61
- /**
62
- * Build header
63
- *
64
- * @since 0.9.0
65
- */
66
- public function build_header() {
67
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
68
- return null;
69
- }
70
-
71
- /**
72
- * Build query url
73
- *
74
- * @since 0.9.0
75
- */
76
- public function build_query_url() {
77
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
78
-
79
- $url = self::DEF_BASE_URL . rawurlencode( $this->query_parameters['url'] );
80
-
81
- return $url;
82
- }
83
-
84
- /**
85
- * Extract count
86
- *
87
- * @since 0.9.0
88
- */
89
- public function extract_count( $content ) {
90
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
91
-
92
- $count = (int) -1;
93
-
94
- if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
95
- $json = json_decode( $content['data'], true );
96
-
97
- if ( isset( $json['subscribers'] ) && is_numeric( $json['subscribers'] ) ) {
98
- $count = (int) $json['subscribers'];
99
- } else {
100
- $count = (int) -1;
101
- }
102
- } else {
103
- $count = (int) -1;
104
- }
105
-
106
- return $count;
107
- }
108
-
109
- public function set_query_parameter( $key, $value ) {
110
- if ( $key === 'url' ) {
111
- $this->query_parameters[$key] = $value;
112
- }
113
- }
114
-
115
- /**
116
- * Check if required paramters are included or not.
117
- *
118
- * @since 0.9.0
119
- */
120
- public function check_configuration() {
121
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
122
-
123
- if ( isset( $this->query_parameters['url'] ) && $this->query_parameters['url'] ) {
124
- return true;
125
- } else {
126
- return false;
127
- }
128
- }
129
-
130
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-scc-follow-instagram-crawl-strategy.php ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ class-scc-follow-instagram-crawl-strategy.php
4
+
5
+ Description: This class is abstract class of a data crawler
6
+ Author: Daisuke Maruyama
7
+ Author URI: http://marubon.info/
8
+ License: GPL2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; either version 2
18
+ of the License, or (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ */
29
+
30
+ /**
31
+ * SCC_Follow_Instagram_Crawl_Strategy
32
+ */
33
+ class SCC_Follow_Instagram_Crawl_Strategy extends SCC_Crawl_Strategy {
34
+
35
+ /**
36
+ * SNS base URL
37
+ *
38
+ * @var string
39
+ */
40
+ const DEF_BASE_URL = 'https://api.instagram.com/v1/users/self/';
41
+
42
+ /**
43
+ * Class constarctor
44
+ * Hook onto all of the actions and filters needed by the plugin.
45
+ *
46
+ */
47
+ protected function __construct() {
48
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
49
+
50
+ $this->http_method = 'GET';
51
+ }
52
+
53
+ /**
54
+ * Initialization
55
+ *
56
+ * @param array $options Option.
57
+ * @return void
58
+ */
59
+ public function initialize( $options = array() ) {
60
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
61
+
62
+ $this->set_parameters( $options );
63
+ }
64
+
65
+ /**
66
+ * Build request header
67
+ *
68
+ * @return array
69
+ */
70
+ public function build_request_header() {
71
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
72
+ return null;
73
+ }
74
+
75
+ /**
76
+ * Build request body
77
+ *
78
+ * @return array
79
+ */
80
+ public function build_request_body() {
81
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
82
+ return null;
83
+ }
84
+
85
+ /**
86
+ * Build request URL
87
+ *
88
+ * @return string
89
+ */
90
+ public function build_request_url() {
91
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
92
+
93
+ $url = self::DEF_BASE_URL . '?' . http_build_query( $this->query_parameters , '' , '&' );
94
+
95
+ return $url;
96
+ }
97
+
98
+ /**
99
+ * Extract response body
100
+ *
101
+ * @param array $content Content.
102
+ * @return array
103
+ */
104
+ public function extract_response_body( $content ) {
105
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
106
+
107
+ $count = (int) -1;
108
+
109
+ if ( isset( $content['body'] ) && empty( $content['error'] ) ) {
110
+ $json = json_decode( $content['body'], true );
111
+
112
+ if ( isset( $json['data']['counts']['followed_by'] ) && is_numeric( $json['data']['counts']['followed_by'] ) ) {
113
+ $count = (int) $json['data']['counts']['followed_by'];
114
+ } else {
115
+ $count = (int) -1;
116
+ }
117
+ } else {
118
+ $count = (int) -1;
119
+
120
+ if ( isset( $content['error'] ) ) {
121
+ SCC_Logger::log( $content['error'] );
122
+ }
123
+ }
124
+
125
+ return $count;
126
+ }
127
+
128
+ /**
129
+ * Extract response header
130
+ *
131
+ * @param array $content Content.
132
+ * @return array
133
+ */
134
+ public function extract_response_header( $content ) {
135
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
136
+ return null;
137
+ }
138
+
139
+ /**
140
+ * Set parameter
141
+ *
142
+ * @param string $key Key.
143
+ * @param string $value Value.
144
+ * @return void
145
+ */
146
+ public function set_parameter( $key, $value ) {
147
+ if ( 'access_token' === $key ) {
148
+ $this->query_parameters[ $key ] = $value;
149
+ } elseif ( 'client_id' === $key ) {
150
+ $this->parameters[ $key ] = $value;
151
+ } elseif ( 'client_secret' === $key ) {
152
+ $this->parameters[ $key ] = $value;
153
+ }
154
+ }
155
+
156
+ /**
157
+ * Check if required paramters are included or not.
158
+ *
159
+ * @return boolean
160
+ */
161
+ public function check_configuration() {
162
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
163
+
164
+ if ( ! empty( $this->parameters['client_id'] ) && ! empty( $this->parameters['client_secret'] ) && ! empty( $this->query_parameters['access_token'] ) ) {
165
+ return true;
166
+ } else {
167
+ return false;
168
+ }
169
+ }
170
+
171
+ /**
172
+ * Check if there is rate limiting or not.
173
+ *
174
+ * @param string $content Content.
175
+ * @return boolean
176
+ */
177
+ public function check_rate_limiting( $content ) {
178
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
179
+
180
+ return true;
181
+ }
182
+
183
+ }
includes/class-scc-follow-instagram-strategy.php DELETED
@@ -1,132 +0,0 @@
1
- <?php
2
- /*
3
- class-scc-follow-instagram-strategy.php
4
-
5
- Description: This class is abstract class of a data crawler
6
- Author: Daisuke Maruyama
7
- Author URI: http://marubon.info/
8
- License: GPL2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
-
12
- /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
-
15
- This program is free software; you can redistribute it and/or
16
- modify it under the terms of the GNU General Public License
17
- as published by the Free Software Foundation; either version 2
18
- of the License, or (at your option) any later version.
19
-
20
- This program is distributed in the hope that it will be useful,
21
- but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- GNU General Public License for more details.
24
-
25
- You should have received a copy of the GNU General Public License
26
- along with this program; if not, write to the Free Software
27
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
- */
29
-
30
- class SCC_Follow_Instagram_Strategy extends SCC_Crawl_Strategy {
31
-
32
- /**
33
- * SNS base url
34
- */
35
- const DEF_BASE_URL = 'https://api.instagram.com/v1/users/self/';
36
-
37
- /**
38
- * Class constarctor
39
- * Hook onto all of the actions and filters needed by the plugin.
40
- *
41
- */
42
- protected function __construct() {
43
- SCC_Common_Util::log('[' . __METHOD__ . '] (line='. __LINE__ . ')');
44
-
45
- $this->method = 'GET';
46
- }
47
-
48
- /**
49
- * Initialization
50
- *
51
- * @since 0.9.0
52
- */
53
- public function initialize( $options = array() ) {
54
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
55
-
56
- if ( isset( $options['url'] ) ) $this->url = $options['url'];
57
- if ( isset( $options['method'] ) ) $this->method = $options['method'];
58
- if ( isset( $options['parameters'] ) ) $this->parameters = $options['parameters'];
59
- }
60
-
61
- /**
62
- * Build header
63
- *
64
- * @since 0.9.0
65
- */
66
- public function build_header() {
67
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
68
- return null;
69
- }
70
-
71
- /**
72
- * Build query url
73
- *
74
- * @since 0.9.0
75
- */
76
- public function build_query_url() {
77
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
78
-
79
- $url = self::DEF_BASE_URL . '?' . http_build_query( $this->query_parameters , '' , '&' );
80
-
81
- return $url;
82
- }
83
-
84
- /**
85
- * Extract count
86
- *
87
- * @since 0.9.0
88
- */
89
- public function extract_count( $content ) {
90
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
91
-
92
- $count = (int) -1;
93
-
94
- if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
95
- $json = json_decode( $content['data'], true );
96
-
97
- if ( isset( $json['data']['counts']['followed_by'] ) && is_numeric( $json['data']['counts']['followed_by'] ) ) {
98
- $count = (int) $json['data']['counts']['followed_by'];
99
- } else {
100
- $count = (int) -1;
101
- }
102
- } else {
103
- $count = (int) -1;
104
- }
105
-
106
- return $count;
107
- }
108
-
109
- public function set_query_parameter( $key, $value ) {
110
- if ( $key === 'access_token' ) {
111
- $this->query_parameters[$key] = $value;
112
- }
113
- }
114
-
115
- /**
116
- * Check if required paramters are included or not.
117
- *
118
- * @since 0.9.0
119
- */
120
- public function check_configuration() {
121
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
122
-
123
- if ( isset( $this->parameters['client_id'] ) && $this->parameters['client_id'] &&
124
- isset( $this->parameters['client_secret'] ) && $this->parameters['client_secret'] &&
125
- isset( $this->query_parameters['access_token'] ) && $this->query_parameters['access_token'] ) {
126
- return true;
127
- } else {
128
- return false;
129
- }
130
- }
131
-
132
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-scc-follow-lazy-cache-engine.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-follow-lazy-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,6 +27,9 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  class SCC_Follow_Lazy_Cache_Engine extends SCC_Follow_Cache_Engine {
31
 
32
  /**
@@ -56,21 +59,26 @@ class SCC_Follow_Lazy_Cache_Engine extends SCC_Follow_Cache_Engine {
56
 
57
  /**
58
  * Interval cheking and caching target data
 
 
59
  */
60
  private $check_interval = 600;
61
 
62
  /**
63
  * Latency suffix
 
 
64
  */
65
  private $check_latency = 10;
66
 
67
  /**
68
  * Initialization
69
  *
70
- * @since 0.1.1
 
71
  */
72
  public function initialize( $options = array() ) {
73
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
74
 
75
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
76
  $this->prime_cron = self::DEF_PRIME_CRON;
@@ -80,17 +88,49 @@ class SCC_Follow_Lazy_Cache_Engine extends SCC_Follow_Cache_Engine {
80
 
81
  $this->load_ratio = 0.5;
82
 
83
- if ( isset( $options['delegate'] ) ) $this->delegate = $options['delegate'];
84
- if ( isset( $options['crawler'] ) ) $this->crawler = $options['crawler'];
85
- if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
86
- if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
87
- if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
88
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
89
- if ( isset( $options['check_latency'] ) ) $this->check_latency = $options['check_latency'];
90
- if ( isset( $options['scheme_migration_mode'] ) ) $this->scheme_migration_mode = $options['scheme_migration_mode'];
91
- if ( isset( $options['scheme_migration_exclude_keys'] ) ) $this->scheme_migration_exclude_keys = $options['scheme_migration_exclude_keys'];
92
- if ( isset( $options['cache_retry'] ) ) $this->cache_retry = $options['cache_retry'];
93
- if ( isset( $options['retry_limit'] ) ) $this->retry_limit = $options['retry_limit'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
 
95
  add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 0 );
96
  }
@@ -98,57 +138,58 @@ class SCC_Follow_Lazy_Cache_Engine extends SCC_Follow_Cache_Engine {
98
  /**
99
  * Register base schedule for this engine
100
  *
101
- * @since 0.1.0
102
  */
103
  public function register_schedule() {
104
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
105
  }
106
 
107
  /**
108
  * Unregister base schedule for this engine
109
  *
110
- * @since 0.1.0
111
  */
112
  public function unregister_schedule() {
113
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
114
 
115
- SCC_WP_Cron_Util::clear_scheduled_hook( $this->execute_cron );
116
  }
117
 
118
  /**
119
  * Schedule data retrieval and cache processing
120
  *
121
- * @since 0.4.0
122
  */
123
  public function prime_cache() {
124
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
125
 
126
  $next_exec_time = (int) current_time( 'timestamp', 1 ) + $this->check_latency;
127
 
128
- SCC_Common_Util::log( '[' . __METHOD__ . '] check_latency: ' . $this->check_latency );
129
- SCC_Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
130
 
131
  wp_schedule_single_event( $next_exec_time, $this->execute_cron, array() );
132
  }
133
 
134
  /**
135
- * Get and cache data of each published post
136
  *
137
- * @since 0.4.0
 
138
  */
139
  public function execute_cache() {
140
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
141
 
142
  $cache_expiration = $this->get_cache_expiration();
143
 
144
- SCC_Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
145
 
146
  $transient_id = $this->get_cache_key( 'follow' );
147
 
148
  $options = array(
149
  'cache_key' => $transient_id,
150
  'target_sns' => $this->target_sns,
151
- 'cache_expiration' => $cache_expiration
152
  );
153
 
154
  // Primary cache
@@ -159,38 +200,39 @@ class SCC_Follow_Lazy_Cache_Engine extends SCC_Follow_Cache_Engine {
159
  }
160
 
161
  /**
162
- * Get cache expiration based on current number of total post and page
163
  *
164
- * @since 0.4.0
165
  */
166
  protected function get_cache_expiration() {
167
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
168
 
169
  return 3 * $this->check_interval;
170
  }
171
 
172
  /**
173
- * Initialize meta key for ranking
174
  *
175
- * @since 0.3.0
176
  */
177
  public function initialize_cache() {
178
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
179
  }
180
 
181
  /**
182
- * Clear meta key for ranking
183
  *
184
- * @since 0.3.0
185
  */
186
  public function clear_cache() {
187
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
188
  }
189
 
190
  /**
191
  * Get cache
192
  *
193
- * @since 0.10.1
 
194
  */
195
  public function get_cache( $options = array() ) {
196
 
@@ -198,7 +240,9 @@ class SCC_Follow_Lazy_Cache_Engine extends SCC_Follow_Cache_Engine {
198
 
199
  $sns_followers = array();
200
 
201
- if ( false !== ( $sns_followers = get_transient( $transient_id ) ) ) {
 
 
202
  return $sns_followers;
203
  } else {
204
  return $this->delegate_order( SCC_Order::ORDER_GET_SECOND_CACHE, $options );
1
  <?php
2
+ /**
3
  class-scc-follow-lazy-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Follow_Lazy_Cache_Engine
32
+ */
33
  class SCC_Follow_Lazy_Cache_Engine extends SCC_Follow_Cache_Engine {
34
 
35
  /**
59
 
60
  /**
61
  * Interval cheking and caching target data
62
+ *
63
+ * @var integer
64
  */
65
  private $check_interval = 600;
66
 
67
  /**
68
  * Latency suffix
69
+ *
70
+ * @var integer
71
  */
72
  private $check_latency = 10;
73
 
74
  /**
75
  * Initialization
76
  *
77
+ * @param array $options Option.
78
+ * @return void
79
  */
80
  public function initialize( $options = array() ) {
81
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
82
 
83
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
84
  $this->prime_cron = self::DEF_PRIME_CRON;
88
 
89
  $this->load_ratio = 0.5;
90
 
91
+ if ( isset( $options['delegate'] ) ) {
92
+ $this->delegate = $options['delegate'];
93
+ }
94
+
95
+ if ( isset( $options['crawler'] ) ) {
96
+ $this->crawler = $options['crawler'];
97
+ }
98
+
99
+ if ( isset( $options['target_sns'] ) ) {
100
+ $this->target_sns = $options['target_sns'];
101
+ }
102
+
103
+ if ( isset( $options['check_interval'] ) ) {
104
+ $this->check_interval = $options['check_interval'];
105
+ }
106
+
107
+ if ( isset( $options['cache_prefix'] ) ) {
108
+ $this->cache_prefix = $options['cache_prefix'];
109
+ }
110
+
111
+ if ( isset( $options['execute_cron'] ) ) {
112
+ $this->execute_cron = $options['execute_cron'];
113
+ }
114
+
115
+ if ( isset( $options['check_latency'] ) ) {
116
+ $this->check_latency = $options['check_latency'];
117
+ }
118
+
119
+ if ( isset( $options['scheme_migration_mode'] ) ) {
120
+ $this->scheme_migration_mode = $options['scheme_migration_mode'];
121
+ }
122
+
123
+ if ( isset( $options['scheme_migration_exclude_keys'] ) ) {
124
+ $this->scheme_migration_exclude_keys = $options['scheme_migration_exclude_keys'];
125
+ }
126
+
127
+ if ( isset( $options['cache_retry'] ) ) {
128
+ $this->cache_retry = $options['cache_retry'];
129
+ }
130
+
131
+ if ( isset( $options['retry_limit'] ) ) {
132
+ $this->retry_limit = $options['retry_limit'];
133
+ }
134
 
135
  add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 0 );
136
  }
138
  /**
139
  * Register base schedule for this engine
140
  *
141
+ * @return void
142
  */
143
  public function register_schedule() {
144
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
145
  }
146
 
147
  /**
148
  * Unregister base schedule for this engine
149
  *
150
+ * @return void
151
  */
152
  public function unregister_schedule() {
153
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
154
 
155
+ SCC_WP_Cron::clear_scheduled_hook( $this->execute_cron );
156
  }
157
 
158
  /**
159
  * Schedule data retrieval and cache processing
160
  *
161
+ * @return void
162
  */
163
  public function prime_cache() {
164
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
165
 
166
  $next_exec_time = (int) current_time( 'timestamp', 1 ) + $this->check_latency;
167
 
168
+ SCC_Logger::log( '[' . __METHOD__ . '] check_latency: ' . $this->check_latency );
169
+ SCC_Logger::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
170
 
171
  wp_schedule_single_event( $next_exec_time, $this->execute_cron, array() );
172
  }
173
 
174
  /**
175
+ * Get and cache data of follower
176
  *
177
+ * @param boolean $second_sync Second cache flag.
178
+ * @return array
179
  */
180
  public function execute_cache() {
181
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
182
 
183
  $cache_expiration = $this->get_cache_expiration();
184
 
185
+ SCC_Logger::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
186
 
187
  $transient_id = $this->get_cache_key( 'follow' );
188
 
189
  $options = array(
190
  'cache_key' => $transient_id,
191
  'target_sns' => $this->target_sns,
192
+ 'cache_expiration' => $cache_expiration,
193
  );
194
 
195
  // Primary cache
200
  }
201
 
202
  /**
203
+ * Get cache expiration
204
  *
205
+ * @return integer
206
  */
207
  protected function get_cache_expiration() {
208
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
209
 
210
  return 3 * $this->check_interval;
211
  }
212
 
213
  /**
214
+ * Initialize cache
215
  *
216
+ * @return void
217
  */
218
  public function initialize_cache() {
219
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
220
  }
221
 
222
  /**
223
+ * Clear cache
224
  *
225
+ * @return void
226
  */
227
  public function clear_cache() {
228
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
229
  }
230
 
231
  /**
232
  * Get cache
233
  *
234
+ * @param array $options Option.
235
+ * @return array
236
  */
237
  public function get_cache( $options = array() ) {
238
 
240
 
241
  $sns_followers = array();
242
 
243
+ $sns_followers = get_transient( $transient_id );
244
+
245
+ if ( false !== $sns_followers ) {
246
  return $sns_followers;
247
  } else {
248
  return $this->delegate_order( SCC_Order::ORDER_GET_SECOND_CACHE, $options );
includes/class-scc-follow-onesignal-crawl-strategy.php ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ class-scc-follow-onesignal-crawl-strategy.php
4
+
5
+ Description: This class is abstract class of a data crawler
6
+ Author: Daisuke Maruyama
7
+ Author URI: http://marubon.info/
8
+ License: GPL2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; either version 2
18
+ of the License, or (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ */
29
+
30
+ /**
31
+ * SCC_Follow_Onesignal_Crawl_Strategy
32
+ */
33
+ class SCC_Follow_Onesignal_Crawl_Strategy extends SCC_Crawl_Strategy {
34
+
35
+ /**
36
+ * SNS base URL
37
+ *
38
+ * @var string
39
+ */
40
+ const DEF_BASE_URL = 'https://onesignal.com/api/v1/apps';
41
+
42
+ /**
43
+ * Class constarctor
44
+ * Hook onto all of the actions and filters needed by the plugin.
45
+ */
46
+ protected function __construct() {
47
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
48
+
49
+ $this->http_method = 'GET';
50
+ }
51
+
52
+ /**
53
+ * Initialization
54
+ *
55
+ * @param array $options Option.
56
+ * @return void
57
+ */
58
+ public function initialize( $options = array() ) {
59
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
60
+
61
+ $this->set_parameters( $options );
62
+ }
63
+
64
+ /**
65
+ * Build request header
66
+ *
67
+ * @return array
68
+ */
69
+ public function build_request_header() {
70
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
71
+
72
+ $headers = array();
73
+
74
+ $headers['Content-Type'] = 'application/json';
75
+ $headers['Authorization'] = 'Basic ' . $this->parameters['rest_api_key'];
76
+
77
+ return $headers;
78
+ }
79
+
80
+ /**
81
+ * Build request body
82
+ *
83
+ * @return array
84
+ */
85
+ public function build_request_body() {
86
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
87
+ return null;
88
+ }
89
+
90
+ /**
91
+ * Build request URL
92
+ *
93
+ * @return string
94
+ */
95
+ public function build_request_url() {
96
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
97
+
98
+ $url = self::DEF_BASE_URL . '/' . $this->parameters['app_id'];
99
+
100
+ return $url;
101
+ }
102
+
103
+ /**
104
+ * Extract response body
105
+ *
106
+ * @param array $content Content.
107
+ * @return array
108
+ */
109
+ public function extract_response_body( $content ) {
110
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
111
+
112
+ $count = (int) -1;
113
+
114
+ if ( isset( $content['body'] ) && empty( $content['error'] ) ) {
115
+ $json = json_decode( $content['body'], true );
116
+
117
+ if ( isset( $json['players'] ) && is_numeric( $json['players'] ) ) {
118
+ $count = (int) $json['players'];
119
+ } else {
120
+ $count = (int) -1;
121
+ }
122
+ } else {
123
+ $count = (int) -1;
124
+
125
+ if ( isset( $content['error'] ) ) {
126
+ SCC_Logger::log( $content['error'] );
127
+ }
128
+ }
129
+
130
+ return $count;
131
+ }
132
+
133
+ /**
134
+ * Extract response header
135
+ *
136
+ * @param array $content Content.
137
+ * @return array
138
+ */
139
+ public function extract_response_header( $content ) {
140
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
141
+ return null;
142
+ }
143
+
144
+ /**
145
+ * Set parameter
146
+ *
147
+ * @param string $key Key.
148
+ * @param string $value Value.
149
+ * @return void
150
+ */
151
+ public function set_parameter( $key, $value ) {
152
+
153
+ if ( 'app_id' === $key ) {
154
+ $this->parameters[ $key ] = $value;
155
+ } elseif ( 'rest_api_key' === $key ) {
156
+ $this->parameters[ $key ] = $value;
157
+ }
158
+
159
+ }
160
+
161
+ /**
162
+ * Check if required paramters are included or not.
163
+ *
164
+ * @return boolean
165
+ */
166
+ public function check_configuration() {
167
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
168
+
169
+ if ( ! empty( $this->parameters['app_id'] ) && ! empty( $this->parameters['rest_api_key'] ) ) {
170
+ return true;
171
+ } else {
172
+ return false;
173
+ }
174
+
175
+ }
176
+
177
+ /**
178
+ * Check if there is rate limiting or not.
179
+ *
180
+ * @param string $content Content.
181
+ * @return boolean
182
+ */
183
+ public function check_rate_limiting( $content ) {
184
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
185
+
186
+ return true;
187
+ }
188
+
189
+ }
includes/class-scc-follow-push7-crawl-strategy.php ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ class-scc-follow-push7-crawl-strategy.php
4
+
5
+ Description: This class is abstract class of a data crawler
6
+ Author: Daisuke Maruyama
7
+ Author URI: http://marubon.info/
8
+ License: GPL2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; either version 2
18
+ of the License, or (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ */
29
+
30
+ /**
31
+ * SCC_Follow_Push7_Crawl_Strategy
32
+ */
33
+ class SCC_Follow_Push7_Crawl_Strategy extends SCC_Crawl_Strategy {
34
+
35
+ /**
36
+ * SNS base URL
37
+ *
38
+ * @var string
39
+ */
40
+ const DEF_BASE_URL = 'https://api.push7.jp/api/v1/';
41
+
42
+ /**
43
+ * Class constarctor
44
+ * Hook onto all of the actions and filters needed by the plugin.
45
+ */
46
+ protected function __construct() {
47
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
48
+
49
+ $this->http_method = 'GET';
50
+ }
51
+
52
+ /**
53
+ * Initialization
54
+ *
55
+ * @param array $options Option.
56
+ * @return void
57
+ */
58
+ public function initialize( $options = array() ) {
59
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
60
+
61
+ $this->set_parameters( $options );
62
+ }
63
+
64
+ /**
65
+ * Build request header
66
+ *
67
+ * @return array
68
+ */
69
+ public function build_request_header() {
70
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
71
+ return null;
72
+ }
73
+
74
+ /**
75
+ * Build request body
76
+ *
77
+ * @return array
78
+ */
79
+ public function build_request_body() {
80
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
81
+ return null;
82
+ }
83
+
84
+ /**
85
+ * Build request URL
86
+ *
87
+ * @return string
88
+ */
89
+ public function build_request_url() {
90
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
91
+
92
+ $url = self::DEF_BASE_URL . $this->parameters['app_number'] . '/head';
93
+
94
+ return $url;
95
+ }
96
+
97
+ /**
98
+ * Extract response body
99
+ *
100
+ * @param array $content Content.
101
+ * @return array
102
+ */
103
+ public function extract_response_body( $content ) {
104
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
105
+
106
+ $count = (int) -1;
107
+
108
+ if ( isset( $content['body'] ) && empty( $content['error'] ) ) {
109
+ $json = json_decode( $content['body'], true );
110
+
111
+ if ( isset( $json['subscribers'] ) && is_numeric( $json['subscribers'] ) ) {
112
+ $count = (int) $json['subscribers'];
113
+ } else {
114
+ $count = (int) -1;
115
+ }
116
+ } else {
117
+ $count = (int) -1;
118
+
119
+ if ( isset( $content['error'] ) ) {
120
+ SCC_Logger::log( $content['error'] );
121
+ }
122
+ }
123
+
124
+ return $count;
125
+ }
126
+
127
+ /**
128
+ * Extract response header
129
+ *
130
+ * @param array $content Content.
131
+ * @return array
132
+ */
133
+ public function extract_response_header( $content ) {
134
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
135
+ return null;
136
+ }
137
+
138
+ /**
139
+ * Set parameter
140
+ *
141
+ * @param string $key Key.
142
+ * @param string $value Value.
143
+ * @return void
144
+ */
145
+ public function set_parameter( $key, $value ) {
146
+
147
+ if ( 'app_number' === $key ) {
148
+ $this->parameters[ $key ] = $value;
149
+ }
150
+
151
+ }
152
+
153
+ /**
154
+ * Check if required paramters are included or not.
155
+ *
156
+ * @return boolean
157
+ */
158
+ public function check_configuration() {
159
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
160
+
161
+ if ( ! empty( $this->parameters['app_number'] ) ) {
162
+ return true;
163
+ } else {
164
+ return false;
165
+ }
166
+ }
167
+
168
+ /**
169
+ * Check if there is rate limiting or not.
170
+ *
171
+ * @param string $content Content.
172
+ * @return boolean
173
+ */
174
+ public function check_rate_limiting( $content ) {
175
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
176
+
177
+ return true;
178
+ }
179
+
180
+ }
includes/class-scc-follow-push7-strategy.php DELETED
@@ -1,128 +0,0 @@
1
- <?php
2
- /*
3
- class-scc-follow-push7-strategy.php
4
-
5
- Description: This class is abstract class of a data crawler
6
- Author: Daisuke Maruyama
7
- Author URI: http://marubon.info/
8
- License: GPL2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
-
12
- /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
-
15
- This program is free software; you can redistribute it and/or
16
- modify it under the terms of the GNU General Public License
17
- as published by the Free Software Foundation; either version 2
18
- of the License, or (at your option) any later version.
19
-
20
- This program is distributed in the hope that it will be useful,
21
- but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- GNU General Public License for more details.
24
-
25
- You should have received a copy of the GNU General Public License
26
- along with this program; if not, write to the Free Software
27
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
- */
29
-
30
- class SCC_Follow_Push7_Strategy extends SCC_Crawl_Strategy {
31
-
32
- /**
33
- * SNS base url
34
- */
35
- const DEF_BASE_URL = 'https://api.push7.jp/api/v1/';
36
-
37
- /**
38
- * Class constarctor
39
- * Hook onto all of the actions and filters needed by the plugin.
40
- *
41
- */
42
- protected function __construct() {
43
- SCC_Common_Util::log('[' . __METHOD__ . '] (line='. __LINE__ . ')');
44
-
45
- $this->method = 'GET';
46
- }
47
-
48
- /**
49
- * Initialization
50
- *
51
- * @since 0.9.0
52
- */
53
- public function initialize( $options = array() ) {
54
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
55
-
56
- if ( isset( $options['url'] ) ) $this->url = $options['url'];
57
- if ( isset( $options['method'] ) ) $this->method = $options['method'];
58
- if ( isset( $options['parameters'] ) ) $this->parameters = $options['parameters'];
59
- }
60
-
61
- /**
62
- * Build header
63
- *
64
- * @since 0.9.0
65
- */
66
- public function build_header() {
67
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
68
- return null;
69
- }
70
-
71
- /**
72
- * Build query url
73
- *
74
- * @since 0.9.0
75
- */
76
- public function build_query_url() {
77
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
78
-
79
- $url = self::DEF_BASE_URL . $this->parameters['appno'] . '/head';
80
-
81
- return $url;
82
- }
83
-
84
- /**
85
- * Extract count
86
- *
87
- * @since 0.9.0
88
- */
89
- public function extract_count( $content ) {
90
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
91
-
92
- $count = (int) -1;
93
-
94
- if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
95
- $json = json_decode( $content['data'], true );
96
-
97
- if ( isset( $json['subscribers'] ) && is_numeric( $json['subscribers'] ) ) {
98
- $count = (int) $json['subscribers'];
99
- } else {
100
- $count = (int) -1;
101
- }
102
- } else {
103
- $count = (int) -1;
104
- }
105
-
106
- return $count;
107
- }
108
-
109
- public function set_query_parameter( $key, $value ) {
110
-
111
- }
112
-
113
- /**
114
- * Check if required paramters are included or not.
115
- *
116
- * @since 0.9.0
117
- */
118
- public function check_configuration() {
119
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
120
-
121
- if ( isset( $this->parameters['appno'] ) && $this->parameters['appno'] ) {
122
- return true;
123
- } else {
124
- return false;
125
- }
126
- }
127
-
128
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-scc-follow-restore-cache-engine.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-follow-restore-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch restore cache data from second cache.
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,6 +27,9 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  class SCC_Follow_Restore_Cache_Engine extends SCC_Cache_Engine {
31
 
32
  /**
@@ -56,21 +59,26 @@ class SCC_Follow_Restore_Cache_Engine extends SCC_Cache_Engine {
56
 
57
  /**
58
  * Interval cheking and caching target data
 
 
59
  */
60
  private $check_interval = 600;
61
 
62
  /**
63
  * Latency suffix
 
 
64
  */
65
  private $check_latency = 10;
66
 
67
  /**
68
  * Initialization
69
  *
70
- * @since 0.1.1
 
71
  */
72
  public function initialize( $options = array() ) {
73
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
74
 
75
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
76
  $this->prime_cron = self::DEF_PRIME_CRON;
@@ -78,11 +86,25 @@ class SCC_Follow_Restore_Cache_Engine extends SCC_Cache_Engine {
78
  $this->event_schedule = self::DEF_EVENT_SCHEDULE;
79
  $this->event_description = self::DEF_EVENT_DESCRIPTION;
80
 
81
- if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
82
- if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
83
- if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
84
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
85
- if ( isset( $options['check_latency'] ) ) $this->check_latency = $options['check_latency'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
 
87
  add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 0 );
88
  }
@@ -90,69 +112,70 @@ class SCC_Follow_Restore_Cache_Engine extends SCC_Cache_Engine {
90
  /**
91
  * Register base schedule for this engine
92
  *
93
- * @since 0.1.0
94
  */
95
  public function register_schedule() {
96
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
97
  }
98
 
99
  /**
100
  * Unregister base schedule for this engine
101
  *
102
- * @since 0.1.0
103
  */
104
  public function unregister_schedule() {
105
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
106
 
107
- SCC_WP_Cron_Util::clear_scheduled_hook( $this->execute_cron );
108
  }
109
 
110
  /**
111
- * Schedule data retrieval and cache processing
112
  *
113
- * @since 0.4.0
114
  */
115
  public function prime_cache() {
116
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
117
 
118
  $next_exec_time = (int) current_time( 'timestamp', 1 ) + $this->check_latency;
119
 
120
- SCC_Common_Util::log( '[' . __METHOD__ . '] check_latency: ' . $this->check_latency );
121
- SCC_Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
122
 
123
  wp_schedule_single_event( $next_exec_time, $this->execute_cron, array() );
124
  }
125
 
126
  /**
127
- * Get and cache data of each published post
128
  *
129
- * @since 0.4.0
130
  */
131
  public function execute_cache() {
132
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
133
 
134
  $cache_expiration = $this->get_cache_expiration();
135
 
136
- SCC_Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
137
 
138
  $transient_id = $this->get_cache_key( 'follow' );
139
 
140
  $options = array(
141
  'cache_key' => $transient_id,
142
  'target_sns' => $this->target_sns,
143
- 'cache_expiration' => $cache_expiration
144
  );
145
 
146
  $this->cache( $options );
147
  }
148
 
149
  /**
150
- * Get and cache data for a given post
151
  *
152
- * @since 0.1.1
 
153
  */
154
  public function cache( $options = array() ) {
155
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
156
 
157
  $transient_id = $options['cache_key'];
158
  $target_sns = $options['target_sns'];
@@ -162,11 +185,13 @@ class SCC_Follow_Restore_Cache_Engine extends SCC_Cache_Engine {
162
 
163
  $option_key = $this->get_cache_key( 'follow' );
164
 
165
- if ( false !== ( $sns_followers = get_option( $option_key ) ) ) {
 
 
166
  } else {
167
  foreach ( $this->share_base_cache_target as $sns => $active ) {
168
  if ( $active ) {
169
- $sns_followers[$sns] = (int) -1;
170
  }
171
  }
172
  }
@@ -175,38 +200,39 @@ class SCC_Follow_Restore_Cache_Engine extends SCC_Cache_Engine {
175
  }
176
 
177
  /**
178
- * Get cache expiration based on current number of total post and page
179
  *
180
- * @since 0.4.0
181
  */
182
  protected function get_cache_expiration() {
183
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
184
 
185
  return 3 * $this->check_interval;
186
  }
187
 
188
  /**
189
- * Initialize meta key for ranking
190
  *
191
- * @since 0.3.0
192
  */
193
  public function initialize_cache() {
194
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
195
  }
196
 
197
  /**
198
- * Clear meta key for ranking
199
  *
200
- * @since 0.3.0
201
  */
202
  public function clear_cache() {
203
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
204
  }
205
 
206
  /**
207
  * Get cache
208
  *
209
- * @since 0.10.1
 
210
  */
211
  public function get_cache( $options = array() ) {
212
 
@@ -216,11 +242,13 @@ class SCC_Follow_Restore_Cache_Engine extends SCC_Cache_Engine {
216
 
217
  $option_key = $this->get_cache_key( 'follow' );
218
 
219
- if ( false !== ( $sns_followers = get_option( $option_key ) ) ) {
 
 
220
  } else {
221
  foreach ( $this->share_base_cache_target as $sns => $active ) {
222
  if ( $active ) {
223
- $sns_followers[$sns] = (int) -1;
224
  }
225
  }
226
  }
1
  <?php
2
+ /**
3
  class-scc-follow-restore-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch restore cache data from second cache.
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Follow_Restore_Cache_Engine
32
+ */
33
  class SCC_Follow_Restore_Cache_Engine extends SCC_Cache_Engine {
34
 
35
  /**
59
 
60
  /**
61
  * Interval cheking and caching target data
62
+ *
63
+ * @var integer
64
  */
65
  private $check_interval = 600;
66
 
67
  /**
68
  * Latency suffix
69
+ *
70
+ * @var integer
71
  */
72
  private $check_latency = 10;
73
 
74
  /**
75
  * Initialization
76
  *
77
+ * @param array $options Option.
78
+ * @return void
79
  */
80
  public function initialize( $options = array() ) {
81
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
82
 
83
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
84
  $this->prime_cron = self::DEF_PRIME_CRON;
86
  $this->event_schedule = self::DEF_EVENT_SCHEDULE;
87
  $this->event_description = self::DEF_EVENT_DESCRIPTION;
88
 
89
+ if ( isset( $options['target_sns'] ) ) {
90
+ $this->target_sns = $options['target_sns'];
91
+ }
92
+
93
+ if ( isset( $options['check_interval'] ) ) {
94
+ $this->check_interval = $options['check_interval'];
95
+ }
96
+
97
+ if ( isset( $options['cache_prefix'] ) ) {
98
+ $this->cache_prefix = $options['cache_prefix'];
99
+ }
100
+
101
+ if ( isset( $options['execute_cron'] ) ) {
102
+ $this->execute_cron = $options['execute_cron'];
103
+ }
104
+
105
+ if ( isset( $options['check_latency'] ) ) {
106
+ $this->check_latency = $options['check_latency'];
107
+ }
108
 
109
  add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 0 );
110
  }
112
  /**
113
  * Register base schedule for this engine
114
  *
115
+ * @return void
116
  */
117
  public function register_schedule() {
118
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
119
  }
120
 
121
  /**
122
  * Unregister base schedule for this engine
123
  *
124
+ * @return void
125
  */
126
  public function unregister_schedule() {
127
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
128
 
129
+ SCC_WP_Cron::clear_scheduled_hook( $this->execute_cron );
130
  }
131
 
132
  /**
133
+ * Schedule cache restoring
134
  *
135
+ * @return void
136
  */
137
  public function prime_cache() {
138
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
139
 
140
  $next_exec_time = (int) current_time( 'timestamp', 1 ) + $this->check_latency;
141
 
142
+ SCC_Logger::log( '[' . __METHOD__ . '] check_latency: ' . $this->check_latency );
143
+ SCC_Logger::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
144
 
145
  wp_schedule_single_event( $next_exec_time, $this->execute_cron, array() );
146
  }
147
 
148
  /**
149
+ * Restore cache
150
  *
151
+ * @return void
152
  */
153
  public function execute_cache() {
154
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
155
 
156
  $cache_expiration = $this->get_cache_expiration();
157
 
158
+ SCC_Logger::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
159
 
160
  $transient_id = $this->get_cache_key( 'follow' );
161
 
162
  $options = array(
163
  'cache_key' => $transient_id,
164
  'target_sns' => $this->target_sns,
165
+ 'cache_expiration' => $cache_expiration,
166
  );
167
 
168
  $this->cache( $options );
169
  }
170
 
171
  /**
172
+ * Restore cache
173
  *
174
+ * @param array $options Option.
175
+ * @return void
176
  */
177
  public function cache( $options = array() ) {
178
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
179
 
180
  $transient_id = $options['cache_key'];
181
  $target_sns = $options['target_sns'];
185
 
186
  $option_key = $this->get_cache_key( 'follow' );
187
 
188
+ $sns_followers = get_option( $option_key );
189
+
190
+ if ( false !== $sns_followers ) {
191
  } else {
192
  foreach ( $this->share_base_cache_target as $sns => $active ) {
193
  if ( $active ) {
194
+ $sns_followers[ $sns ] = (int) -1;
195
  }
196
  }
197
  }
200
  }
201
 
202
  /**
203
+ * Get cache expiration
204
  *
205
+ * @return integer
206
  */
207
  protected function get_cache_expiration() {
208
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
209
 
210
  return 3 * $this->check_interval;
211
  }
212
 
213
  /**
214
+ * Initialize cache
215
  *
216
+ * @return void
217
  */
218
  public function initialize_cache() {
219
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
220
  }
221
 
222
  /**
223
+ * Clear cache
224
  *
225
+ * @return void
226
  */
227
  public function clear_cache() {
228
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
229
  }
230
 
231
  /**
232
  * Get cache
233
  *
234
+ * @param array $options Option.
235
+ * @return array
236
  */
237
  public function get_cache( $options = array() ) {
238
 
242
 
243
  $option_key = $this->get_cache_key( 'follow' );
244
 
245
+ $sns_followers = get_option( $option_key );
246
+
247
+ if ( false !== $sns_followers ) {
248
  } else {
249
  foreach ( $this->share_base_cache_target as $sns => $active ) {
250
  if ( $active ) {
251
+ $sns_followers[ $sns ] = (int) -1;
252
  }
253
  }
254
  }
includes/class-scc-follow-second-cache-engine.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-follow-second-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -56,26 +56,34 @@ class SCC_Follow_Second_Cache_Engine extends SCC_Cache_Engine {
56
 
57
  /**
58
  * Interval cheking and caching target data
 
 
59
  */
60
  private $check_interval = 600;
61
 
62
  /**
63
  * Prefix of cache ID
 
 
64
  */
65
  private $meta_key_prefix = 'scc_follow_count_';
66
 
67
  /**
68
  * Cache target
 
 
69
  */
70
  private $target_sns = array();
71
 
72
  /**
73
  * Initialization
74
  *
75
- * @since 0.1.1
 
76
  */
 
77
  public function initialize( $options = array() ) {
78
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
79
 
80
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
81
  $this->prime_cron = self::DEF_PRIME_CRON;
@@ -83,15 +91,41 @@ class SCC_Follow_Second_Cache_Engine extends SCC_Cache_Engine {
83
  $this->event_schedule = self::DEF_EVENT_SCHEDULE;
84
  $this->event_description = self::DEF_EVENT_DESCRIPTION;
85
 
86
- if ( isset( $options['delegate'] ) ) $this->delegate = $options['delegate'];
87
- if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
88
- if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
89
- if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
90
- if ( isset( $options['prime_cron'] ) ) $this->prime_cron = $options['prime_cron'];
91
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
92
- if ( isset( $options['event_schedule'] ) ) $this->event_schedule = $options['event_schedule'];
93
- if ( isset( $options['event_description'] ) ) $this->event_description = $options['event_description'];
94
- if ( isset( $options['meta_key_prefix'] ) ) $this->meta_key_prefix = $options['meta_key_prefix'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
  add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
97
  add_action( $this->prime_cron, array( $this, 'prime_cache' ) );
@@ -101,14 +135,15 @@ class SCC_Follow_Second_Cache_Engine extends SCC_Cache_Engine {
101
  /**
102
  * Register event schedule for this engine
103
  *
104
- * @since 0.1.0
 
105
  */
106
  public function schedule_check_interval( $schedules ) {
107
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
108
 
109
- $schedules[$this->event_schedule] = array(
110
  'interval' => $this->check_interval,
111
- 'display' => $this->event_description
112
  );
113
 
114
  return $schedules;
@@ -117,26 +152,27 @@ class SCC_Follow_Second_Cache_Engine extends SCC_Cache_Engine {
117
  /**
118
  * Schedule data retrieval and cache processing
119
  *
120
- * @since 0.3.0
121
  */
122
  public function prime_cache() {
123
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
124
 
125
  $next_exec_time = (int) current_time( 'timestamp', 1 ) + $this->check_interval;
126
 
127
- SCC_Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
128
- SCC_Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
129
 
130
  wp_schedule_single_event( $next_exec_time, $this->execute_cron );
131
  }
132
 
133
  /**
134
- * Get and cache data of each published post and page
135
  *
136
- * @since 0.4.0
 
137
  */
138
  public function execute_cache() {
139
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
140
 
141
  $url = get_feed_link();
142
 
@@ -153,15 +189,18 @@ class SCC_Follow_Second_Cache_Engine extends SCC_Cache_Engine {
153
  /**
154
  * Get and cache data for a given post
155
  *
156
- * @since 0.1.1
 
157
  */
158
  public function cache( $options = array() ) {
159
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
160
 
161
  $transient_id = $options['cache_key'];
162
  $target_sns = $options['target_sns'];
163
 
164
- if ( false !== ( $sns_followers = get_transient( $transient_id ) ) ) {
 
 
165
 
166
  $option_key = $this->get_cache_key( 'follow' );
167
 
@@ -173,23 +212,23 @@ class SCC_Follow_Second_Cache_Engine extends SCC_Cache_Engine {
173
  }
174
 
175
  /**
176
- * Get cache expiration based on current number of total post and page
177
  *
178
- * @since 0.2.0
179
  */
180
  protected function get_cache_expiration() {
181
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
182
 
183
  return 0;
184
  }
185
 
186
  /**
187
- * Initialize meta key for ranking
188
  *
189
- * @since 0.3.0
190
  */
191
  public function initialize_cache() {
192
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
193
 
194
  $option_key = $this->get_cache_key( 'follow' );
195
 
@@ -197,7 +236,7 @@ class SCC_Follow_Second_Cache_Engine extends SCC_Cache_Engine {
197
 
198
  foreach ( $this->target_sns as $sns => $active ) {
199
  if ( $active ) {
200
- $sns_followers[$sns] = (int) -1;
201
  }
202
  }
203
 
@@ -205,12 +244,12 @@ class SCC_Follow_Second_Cache_Engine extends SCC_Cache_Engine {
205
  }
206
 
207
  /**
208
- * Clear meta key for ranking
209
  *
210
- * @since 0.3.0
211
  */
212
  public function clear_cache() {
213
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
214
 
215
  $option_key = $this->get_cache_key( 'follow' );
216
 
@@ -230,17 +269,20 @@ class SCC_Follow_Second_Cache_Engine extends SCC_Cache_Engine {
230
  /**
231
  * Get cache
232
  *
233
- * @since 0.10.1
 
234
  */
235
  public function get_cache( $options = array() ) {
236
  $option_key = $this->get_cache_key( 'follow' );
237
  $sns_followers = array();
238
 
239
- if ( false !== ( $sns_followers = get_option( $option_key ) ) ) {
 
 
240
  } else {
241
  foreach ( $this->target_sns as $sns => $active ) {
242
  if ( $active ) {
243
- $sns_followers[$sns] = (int) -1;
244
  }
245
  }
246
  }
1
  <?php
2
+ /**
3
  class-scc-follow-second-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
56
 
57
  /**
58
  * Interval cheking and caching target data
59
+ *
60
+ * @var integer
61
  */
62
  private $check_interval = 600;
63
 
64
  /**
65
  * Prefix of cache ID
66
+ *
67
+ * @var string
68
  */
69
  private $meta_key_prefix = 'scc_follow_count_';
70
 
71
  /**
72
  * Cache target
73
+ *
74
+ * @var array
75
  */
76
  private $target_sns = array();
77
 
78
  /**
79
  * Initialization
80
  *
81
+ * @param array $options Option.
82
+ * @return void
83
  */
84
+
85
  public function initialize( $options = array() ) {
86
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
87
 
88
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
89
  $this->prime_cron = self::DEF_PRIME_CRON;
91
  $this->event_schedule = self::DEF_EVENT_SCHEDULE;
92
  $this->event_description = self::DEF_EVENT_DESCRIPTION;
93
 
94
+ if ( isset( $options['delegate'] ) ) {
95
+ $this->delegate = $options['delegate'];
96
+ }
97
+
98
+ if ( isset( $options['target_sns'] ) ) {
99
+ $this->target_sns = $options['target_sns'];
100
+ }
101
+
102
+ if ( isset( $options['check_interval'] ) ) {
103
+ $this->check_interval = $options['check_interval'];
104
+ }
105
+
106
+ if ( isset( $options['cache_prefix'] ) ) {
107
+ $this->cache_prefix = $options['cache_prefix'];
108
+ }
109
+
110
+ if ( isset( $options['prime_cron'] ) ) {
111
+ $this->prime_cron = $options['prime_cron'];
112
+ }
113
+
114
+ if ( isset( $options['execute_cron'] ) ) {
115
+ $this->execute_cron = $options['execute_cron'];
116
+ }
117
+
118
+ if ( isset( $options['event_schedule'] ) ) {
119
+ $this->event_schedule = $options['event_schedule'];
120
+ }
121
+
122
+ if ( isset( $options['event_description'] ) ) {
123
+ $this->event_description = $options['event_description'];
124
+ }
125
+
126
+ if ( isset( $options['meta_key_prefix'] ) ) {
127
+ $this->meta_key_prefix = $options['meta_key_prefix'];
128
+ }
129
 
130
  add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
131
  add_action( $this->prime_cron, array( $this, 'prime_cache' ) );
135
  /**
136
  * Register event schedule for this engine
137
  *
138
+ * @param array $schedules Schedule.
139
+ * @return array
140
  */
141
  public function schedule_check_interval( $schedules ) {
142
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
143
 
144
+ $schedules[ $this->event_schedule ] = array(
145
  'interval' => $this->check_interval,
146
+ 'display' => $this->event_description,
147
  );
148
 
149
  return $schedules;
152
  /**
153
  * Schedule data retrieval and cache processing
154
  *
155
+ * @return void
156
  */
157
  public function prime_cache() {
158
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
159
 
160
  $next_exec_time = (int) current_time( 'timestamp', 1 ) + $this->check_interval;
161
 
162
+ SCC_Logger::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
163
+ SCC_Logger::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
164
 
165
  wp_schedule_single_event( $next_exec_time, $this->execute_cron );
166
  }
167
 
168
  /**
169
+ * Get and cache data of follower
170
  *
171
+ * @param string $hash Hash.
172
+ * @return void
173
  */
174
  public function execute_cache() {
175
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
176
 
177
  $url = get_feed_link();
178
 
189
  /**
190
  * Get and cache data for a given post
191
  *
192
+ * @param array $options Option.
193
+ * @return void
194
  */
195
  public function cache( $options = array() ) {
196
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
197
 
198
  $transient_id = $options['cache_key'];
199
  $target_sns = $options['target_sns'];
200
 
201
+ $sns_followers = get_transient( $transient_id );
202
+
203
+ if ( false !== $sns_followers ) {
204
 
205
  $option_key = $this->get_cache_key( 'follow' );
206
 
212
  }
213
 
214
  /**
215
+ * Get cache expiration
216
  *
217
+ * @return integer
218
  */
219
  protected function get_cache_expiration() {
220
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
221
 
222
  return 0;
223
  }
224
 
225
  /**
226
+ * Initialize cache
227
  *
228
+ * @return void
229
  */
230
  public function initialize_cache() {
231
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
232
 
233
  $option_key = $this->get_cache_key( 'follow' );
234
 
236
 
237
  foreach ( $this->target_sns as $sns => $active ) {
238
  if ( $active ) {
239
+ $sns_followers[ $sns ] = (int) -1;
240
  }
241
  }
242
 
244
  }
245
 
246
  /**
247
+ * Clear cache
248
  *
249
+ * @return void
250
  */
251
  public function clear_cache() {
252
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
253
 
254
  $option_key = $this->get_cache_key( 'follow' );
255
 
269
  /**
270
  * Get cache
271
  *
272
+ * @param array $options Option.
273
+ * @return array
274
  */
275
  public function get_cache( $options = array() ) {
276
  $option_key = $this->get_cache_key( 'follow' );
277
  $sns_followers = array();
278
 
279
+ $sns_followers = get_option( $option_key );
280
+
281
+ if ( false !== $sns_followers ) {
282
  } else {
283
  foreach ( $this->target_sns as $sns => $active ) {
284
  if ( $active ) {
285
+ $sns_followers[ $sns ] = (int) -1;
286
  }
287
  }
288
  }
includes/{class-scc-follow-twitter-strategy.php → class-scc-follow-twitter-crawl-strategy.php} RENAMED
@@ -1,16 +1,16 @@
1
  <?php
2
- /*
3
- class-scc-follow-twitter-strategy.php
4
 
5
  Description: This class is abstract class of a data crawler
6
  Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,51 +27,54 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
- class SCC_Follow_Twitter_Strategy extends SCC_Crawl_Strategy {
 
 
 
31
 
32
  /**
33
- * SNS base url
 
 
34
  */
35
  const DEF_BASE_URL = 'https://api.twitter.com/1.1/users/show.json';
36
 
37
  /**
38
  * Class constarctor
39
  * Hook onto all of the actions and filters needed by the plugin.
40
- *
41
  */
42
  protected function __construct() {
43
- SCC_Common_Util::log('[' . __METHOD__ . '] (line='. __LINE__ . ')');
44
 
45
- $this->method = 'GET';
46
  }
47
 
48
  /**
49
  * Initialization
50
  *
51
- * @since 0.9.0
 
52
  */
53
  public function initialize( $options = array() ) {
54
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
55
 
56
- if ( isset( $options['url'] ) ) $this->url = $options['url'];
57
- if ( isset( $options['method'] ) ) $this->method = $options['method'];
58
- if ( isset( $options['parameters'] ) ) $this->parameters = $options['parameters'];
59
  }
60
 
61
- /**
62
- * Build header
63
  *
64
- * @since 0.9.0
65
  */
66
- public function build_header() {
67
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
68
 
69
  $headers = array();
70
 
71
  /*
72
  // vesion using user auth
73
  $oauth_parameters = array(
74
- 'oauth_consumer_key' => $this->parameters['consumer_key'],
75
  'oauth_token' => $this->parameters['access_token'],
76
  'oauth_nonce' => microtime(),
77
  'oauth_signature_method' => 'HMAC-SHA1',
@@ -79,7 +82,7 @@ class SCC_Follow_Twitter_Strategy extends SCC_Crawl_Strategy {
79
  'oauth_version' => '1.0'
80
  );
81
 
82
- $signature_key = rawurlencode( $this->parameters['consumer_secret'] ) . '&' . rawurlencode( $this->parameters['access_token_secret'] );
83
 
84
  $oauth_parameters = array_merge( $oauth_parameters, $this->query_parameters );
85
 
@@ -98,19 +101,29 @@ class SCC_Follow_Twitter_Strategy extends SCC_Crawl_Strategy {
98
  $headers['Authorization'] = 'OAuth ' . $header_parameters;
99
  */
100
 
101
- //version using application-only auth
102
  $headers['Authorization'] = 'Bearer ' . $this->parameters['bearer_token'];
103
 
104
  return $headers;
105
  }
106
 
107
  /**
108
- * Build query url
 
 
 
 
 
 
 
 
 
 
109
  *
110
- * @since 0.9.0
111
  */
112
- public function build_query_url() {
113
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
114
 
115
  $url = self::DEF_BASE_URL . '?' . http_build_query( $this->query_parameters , '' , '&' );
116
 
@@ -118,17 +131,18 @@ class SCC_Follow_Twitter_Strategy extends SCC_Crawl_Strategy {
118
  }
119
 
120
  /**
121
- * Extract count
122
  *
123
- * @since 0.9.0
 
124
  */
125
- public function extract_count( $content ) {
126
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
127
 
128
  $count = (int) -1;
129
 
130
- if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
131
- $json = json_decode( $content['data'], true );
132
 
133
  if ( isset( $json['followers_count'] ) && is_numeric( $json['followers_count'] ) ) {
134
  $count = (int) $json['followers_count'];
@@ -137,30 +151,58 @@ class SCC_Follow_Twitter_Strategy extends SCC_Crawl_Strategy {
137
  }
138
  } else {
139
  $count = (int) -1;
 
 
 
 
140
  }
141
 
142
  return $count;
143
  }
144
 
145
- public function set_query_parameter( $key, $value ) {
146
- if ( $key === 'screen_name' ) {
147
- $this->query_parameters[$key] = $value;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  }
149
  }
150
 
151
  /**
152
  * Check if required paramters are included or not.
153
  *
154
- * @since 0.9.0
155
  */
156
  public function check_configuration() {
157
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
158
 
159
  /*
160
  // vesion using user auth
161
  if ( isset( $this->query_parameters['screen_name'] ) && $this->query_parameters['screen_name'] &&
162
- isset( $this->parameters['consumer_key'] ) && $this->parameters['consumer_key'] &&
163
- isset( $this->parameters['consumer_secret'] ) && $this->parameters['consumer_secret'] &&
164
  isset( $this->parameters['access_token'] ) && $this->parameters['access_token'] &&
165
  isset( $this->parameters['access_token_secret'] ) && $this->parameters['access_token_secret']
166
  ) {
@@ -170,17 +212,25 @@ class SCC_Follow_Twitter_Strategy extends SCC_Crawl_Strategy {
170
  }
171
  */
172
 
173
- //version using application-only auth
174
- if ( isset( $this->query_parameters['screen_name'] ) && $this->query_parameters['screen_name'] &&
175
- isset( $this->parameters['consumer_key'] ) && $this->parameters['consumer_key'] &&
176
- isset( $this->parameters['consumer_secret'] ) && $this->parameters['consumer_secret'] &&
177
- isset( $this->parameters['bearer_token'] ) && $this->parameters['bearer_token']
178
- ) {
179
  return true;
180
  } else {
181
  return false;
182
  }
 
 
 
 
 
 
 
 
 
 
183
 
 
184
  }
185
 
186
  }
1
  <?php
2
+ /**
3
+ class-scc-follow-twitter-crawl-strategy.php
4
 
5
  Description: This class is abstract class of a data crawler
6
  Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Follow_Twitter_Crawl_Strategy
32
+ */
33
+ class SCC_Follow_Twitter_Crawl_Strategy extends SCC_Crawl_Strategy {
34
 
35
  /**
36
+ * SNS base URL
37
+ *
38
+ * @var string
39
  */
40
  const DEF_BASE_URL = 'https://api.twitter.com/1.1/users/show.json';
41
 
42
  /**
43
  * Class constarctor
44
  * Hook onto all of the actions and filters needed by the plugin.
 
45
  */
46
  protected function __construct() {
47
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
48
 
49
+ $this->http_method = 'GET';
50
  }
51
 
52
  /**
53
  * Initialization
54
  *
55
+ * @param array $options Option.
56
+ * @return void
57
  */
58
  public function initialize( $options = array() ) {
59
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
60
 
61
+ $this->set_parameters( $options );
 
 
62
  }
63
 
64
+ /**
65
+ * Build request header
66
  *
67
+ * @return array
68
  */
69
+ public function build_request_header() {
70
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
71
 
72
  $headers = array();
73
 
74
  /*
75
  // vesion using user auth
76
  $oauth_parameters = array(
77
+ 'oauth_consumer_key' => $this->parameters['api_key'],
78
  'oauth_token' => $this->parameters['access_token'],
79
  'oauth_nonce' => microtime(),
80
  'oauth_signature_method' => 'HMAC-SHA1',
82
  'oauth_version' => '1.0'
83
  );
84
 
85
+ $signature_key = rawurlencode( $this->parameters['api_secret_key'] ) . '&' . rawurlencode( $this->parameters['access_token_secret'] );
86
 
87
  $oauth_parameters = array_merge( $oauth_parameters, $this->query_parameters );
88
 
101
  $headers['Authorization'] = 'OAuth ' . $header_parameters;
102
  */
103
 
104
+ // version using application-only auth
105
  $headers['Authorization'] = 'Bearer ' . $this->parameters['bearer_token'];
106
 
107
  return $headers;
108
  }
109
 
110
  /**
111
+ * Build request body
112
+ *
113
+ * @return array
114
+ */
115
+ public function build_request_body() {
116
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
117
+ return null;
118
+ }
119
+
120
+ /**
121
+ * Build request URL
122
  *
123
+ * @return string
124
  */
125
+ public function build_request_url() {
126
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
127
 
128
  $url = self::DEF_BASE_URL . '?' . http_build_query( $this->query_parameters , '' , '&' );
129
 
131
  }
132
 
133
  /**
134
+ * Extract response body
135
  *
136
+ * @param array $content Content.
137
+ * @return array
138
  */
139
+ public function extract_response_body( $content ) {
140
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
141
 
142
  $count = (int) -1;
143
 
144
+ if ( isset( $content['body'] ) && empty( $content['error'] ) ) {
145
+ $json = json_decode( $content['body'], true );
146
 
147
  if ( isset( $json['followers_count'] ) && is_numeric( $json['followers_count'] ) ) {
148
  $count = (int) $json['followers_count'];
151
  }
152
  } else {
153
  $count = (int) -1;
154
+
155
+ if ( isset( $content['error'] ) ) {
156
+ SCC_Logger::log( $content['error'] );
157
+ }
158
  }
159
 
160
  return $count;
161
  }
162
 
163
+ /**
164
+ * Extract response header
165
+ *
166
+ * @param array $content Content.
167
+ * @return array
168
+ */
169
+ public function extract_response_header( $content ) {
170
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
171
+ return null;
172
+ }
173
+
174
+ /**
175
+ * Set parameter
176
+ *
177
+ * @param string $key Key.
178
+ * @param string $value Value.
179
+ * @return void
180
+ */
181
+ public function set_parameter( $key, $value ) {
182
+ if ( 'screen_name' === $key ) {
183
+ $this->query_parameters[ $key ] = $value;
184
+ } elseif ( 'api_key' === $key ) {
185
+ $this->parameters[ $key ] = $value;
186
+ } elseif ( 'api_secret_key' === $key ) {
187
+ $this->parameters[ $key ] = $value;
188
+ } elseif ( 'bearer_token' === $key ) {
189
+ $this->parameters[ $key ] = $value;
190
  }
191
  }
192
 
193
  /**
194
  * Check if required paramters are included or not.
195
  *
196
+ * @return boolean
197
  */
198
  public function check_configuration() {
199
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
200
 
201
  /*
202
  // vesion using user auth
203
  if ( isset( $this->query_parameters['screen_name'] ) && $this->query_parameters['screen_name'] &&
204
+ isset( $this->parameters['api_key'] ) && $this->parameters['api_key'] &&
205
+ isset( $this->parameters['api_secret_key'] ) && $this->parameters['api_secret_key'] &&
206
  isset( $this->parameters['access_token'] ) && $this->parameters['access_token'] &&
207
  isset( $this->parameters['access_token_secret'] ) && $this->parameters['access_token_secret']
208
  ) {
212
  }
213
  */
214
 
215
+ // version using application-only auth
216
+ if ( ! empty( $this->query_parameters['screen_name'] ) && ! empty( $this->parameters['api_key'] ) &&
217
+ ! empty( $this->parameters['api_secret_key'] ) && ! empty( $this->parameters['bearer_token'] ) ) {
 
 
 
218
  return true;
219
  } else {
220
  return false;
221
  }
222
+ }
223
+
224
+ /**
225
+ * Check if there is rate limiting or not.
226
+ *
227
+ * @param string $content Content.
228
+ * @return boolean
229
+ */
230
+ public function check_rate_limiting( $content ) {
231
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
232
 
233
+ return true;
234
  }
235
 
236
  }
includes/class-scc-format.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ class-scc-format.php
4
+
5
+ Description: This class is a common utility
6
+ Author: Daisuke Maruyama
7
+ Author URI: http://marubon.info/
8
+ License: GPL2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; either version 2
18
+ of the License, or (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ */
29
+
30
+ /**
31
+ * SCC_Format
32
+ */
33
+ class SCC_Format {
34
+
35
+ /**
36
+ * Class constarctor
37
+ * Hook onto all of the actions and filters needed by the plugin.
38
+ */
39
+ protected function __construct() {
40
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
41
+ }
42
+
43
+ /**
44
+ * Convert url based on http into url based on https
45
+ *
46
+ * @param string $url URL.
47
+ * @return string
48
+ */
49
+ public static function get_secure_url( $url ) {
50
+ $url = str_replace( 'http://', 'https://', $url );
51
+ return $url;
52
+ }
53
+
54
+ /**
55
+ * Convert url based on https into url based on http
56
+ *
57
+ * @param string $url URL.
58
+ * @return string
59
+ */
60
+ public static function get_http_url( $url ) {
61
+ $url = str_replace( 'https://', 'http://', $url );
62
+ return $url;
63
+ }
64
+
65
+ /**
66
+ * Check if a given URL is based on https or not.
67
+ *
68
+ * @param string $url URL.
69
+ * @return boolean
70
+ */
71
+ public static function is_https_url( $url ) {
72
+ if ( preg_match( '/^(https)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/', $url ) ) {
73
+ return true;
74
+ } else {
75
+ return false;
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Check if a given URL is based on http or not.
81
+ *
82
+ * @param string $url URL.
83
+ * @return boolean
84
+ */
85
+ public static function is_http_url( $url ) {
86
+ if ( preg_match( '/^(http)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/', $url ) ) {
87
+ return true;
88
+ } else {
89
+ return false;
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Check if a given URL is valid URL or not
95
+ *
96
+ * @param string $url URL.
97
+ * @return boolean
98
+ */
99
+ public static function is_url( $url ) {
100
+ if ( false !== filter_var( $url, FILTER_VALIDATE_URL ) && preg_match( '@^https?+://@i', $url ) ) {
101
+ return true;
102
+ } else {
103
+ return false;
104
+ }
105
+ }
106
+
107
+ /**
108
+ * Check if a given ID is vaild or not.
109
+ *
110
+ * @param mixed $id ID.
111
+ * @return boolean
112
+ */
113
+ public static function is_content_id( $id ) {
114
+ if ( is_numeric( $id ) || 'home' === $id ) {
115
+ return true;
116
+ } else {
117
+ return false;
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Sanitize
123
+ *
124
+ * @param string $str Input string.
125
+ * @return string
126
+ */
127
+ public static function sanitize( $str ) {
128
+ $filtered = wp_check_invalid_utf8( $str );
129
+
130
+ if ( strpos( $filtered, '<' ) !== false ) {
131
+ $filtered = wp_pre_kses_less_than( $filtered );
132
+ // This will strip extra whitespace for us.
133
+ $filtered = wp_strip_all_tags( $filtered, true );
134
+ } else {
135
+ $filtered = trim( preg_replace( '/[\r\n\t ]+/', ' ', $filtered ) );
136
+ }
137
+
138
+ $filtered = trim( preg_replace( '/ +/', ' ', $filtered ) );
139
+
140
+ return $filtered;
141
+ }
142
+
143
+ /**
144
+ * Sanitize key
145
+ *
146
+ * @param string $cache_key Cache key.
147
+ * @return string
148
+ */
149
+ public static function sanitize_cache_key( $cache_key ) {
150
+ $cache_key = strtolower( $cache_key );
151
+ $cache_key = preg_replace( '/[^a-z0-9_\-\+]/', '', $cache_key );
152
+ return $cache_key;
153
+ }
154
+
155
+ }
156
+
157
+ ?>
includes/class-scc-hash.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ class-scc-hash.php
4
+
5
+ Description: This class is a common utility
6
+ Author: Daisuke Maruyama
7
+ Author URI: http://marubon.info/
8
+ License: GPL2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; either version 2
18
+ of the License, or (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ */
29
+
30
+ /**
31
+ * SCC_Hash
32
+ */
33
+ class SCC_Hash {
34
+
35
+ /**
36
+ * Class constarctor
37
+ * Hook onto all of the actions and filters needed by the plugin.
38
+ */
39
+ protected function __construct() {
40
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
41
+ }
42
+
43
+ /**
44
+ * Get short hash code
45
+ *
46
+ * @param string $data Data.
47
+ * @param string $algo Algorithm.
48
+ * @return string
49
+ */
50
+ public static function short_hash( $data, $algo = 'CRC32' ) {
51
+ return strtr( rtrim( base64_encode( pack( 'H*', sprintf( '%u', $algo( $data ) ) ) ), '=' ), '+/', '-_' );
52
+ }
53
+
54
+ }
55
+
56
+ ?>
includes/class-scc-http.php ADDED
@@ -0,0 +1,300 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ class-scc-http.php
4
+
5
+ Description: This class is a common utility
6
+ Author: Daisuke Maruyama
7
+ Author URI: http://marubon.info/
8
+ License: GPL2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; either version 2
18
+ of the License, or (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ */
29
+
30
+ /**
31
+ * SCC_HTTP
32
+ */
33
+ class SCC_HTTP {
34
+
35
+ /**
36
+ * Class constarctor
37
+ * Hook onto all of the actions and filters needed by the plugin.
38
+ */
39
+ protected function __construct() {
40
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
41
+ }
42
+
43
+ /**
44
+ * Request based on given parameters,
45
+ *
46
+ * @param array $urls URLs.
47
+ * @param array $methods HTTP methos.
48
+ * @param array $headers Headers.
49
+ * @param array $bodies Bodies.
50
+ * @param integer $timeout Timeout.
51
+ * @param boolean $sslverify SSL verification.
52
+ * @param boolean $curl cURL flag.
53
+ * @return array
54
+ */
55
+ public static function multi_remote_request( $urls, $methods, $headers, $bodies, $timeout = 0, $sslverify = true, $curl = false ) {
56
+ global $wp_version;
57
+
58
+ $responses = array();
59
+
60
+ if ( empty( $urls ) ) {
61
+ return $responses;
62
+ }
63
+
64
+ if ( $curl ) {
65
+ SCC_Logger::log( '[' . __METHOD__ . '] cURL: On' );
66
+
67
+ $mh = curl_multi_init();
68
+ $ch = array();
69
+
70
+ $handle_to_sns = array();
71
+
72
+ foreach ( $urls as $sns => $url ) {
73
+ $ch[ $sns ] = curl_init();
74
+
75
+ curl_setopt( $ch[ $sns ], CURLOPT_URL, $url );
76
+ curl_setopt( $ch[ $sns ], CURLOPT_USERAGENT, 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) );
77
+ curl_setopt( $ch[ $sns ], CURLOPT_FOLLOWLOCATION, true );
78
+ curl_setopt( $ch[ $sns ], CURLOPT_RETURNTRANSFER, true );
79
+ curl_setopt( $ch[ $sns ], CURLOPT_ENCODING, 'gzip' );
80
+ curl_setopt( $ch[ $sns ], CURLOPT_HEADER, true );
81
+
82
+ if ( ! empty( $headers[ $sns ] ) ) {
83
+ $http_headers = array();
84
+
85
+ foreach ( $headers[ $sns ] as $key => $value ) {
86
+ $http_headers[] = $key . ': ' . $value;
87
+ }
88
+
89
+ curl_setopt( $ch[ $sns ], CURLOPT_HTTPHEADER, $http_headers );
90
+ }
91
+
92
+ if ( $sslverify ) {
93
+ curl_setopt( $ch[ $sns ], CURLOPT_SSL_VERIFYPEER, true );
94
+ curl_setopt( $ch[ $sns ], CURLOPT_SSL_VERIFYHOST, 2 );
95
+ } else {
96
+ curl_setopt( $ch[ $sns ], CURLOPT_SSL_VERIFYPEER, false );
97
+ curl_setopt( $ch[ $sns ], CURLOPT_SSL_VERIFYHOST, 0 );
98
+ }
99
+
100
+ if ( $timeout > 0 ) {
101
+ curl_setopt( $ch[ $sns ], CURLOPT_CONNECTTIMEOUT, $timeout );
102
+ curl_setopt( $ch[ $sns ], CURLOPT_TIMEOUT, $timeout );
103
+ }
104
+
105
+ if ( isset( $methods[ $sns ] ) && 'POST' === $methods[ $sns ] ) {
106
+ curl_setopt( $ch[ $sns ], CURLOPT_POST, true );
107
+ if ( isset( $bodies[ $sns ] ) ) {
108
+ curl_setopt( $ch[ $sns ], CURLOPT_POSTFIELDS, wp_json_encode( $bodies[ $sns ] ) );
109
+ }
110
+ }
111
+
112
+ $handle_to_sns[ (string) $ch[ $sns ] ] = $sns;
113
+
114
+ curl_multi_add_handle( $mh, $ch[ $sns ] );
115
+ } // End foreach().
116
+
117
+ do {
118
+ curl_multi_exec( $mh, $active );
119
+ curl_multi_select( $mh );
120
+ } while ( $active > 0 );
121
+
122
+ foreach ( $urls as $sns => $url ) {
123
+ $error = curl_error( $ch[ $sns ] );
124
+ $response = curl_multi_getcontent( $ch[ $sns ] );
125
+
126
+ $info = curl_getinfo( $ch[ $sns ] );
127
+ $header_size = $info['header_size'];
128
+
129
+ $header = substr( $response, 0, $header_size );
130
+ $body = substr( $response, $header_size );
131
+
132
+ $headers = array();
133
+ $data = preg_split( '/[\r\n]+/', $header );
134
+ // $data = explode( '\r\n', $header );
135
+ array_shift( $data );
136
+ array_pop( $data );
137
+
138
+ foreach ( $data as $part ) {
139
+ $middle = explode( ':', $part, 2 );
140
+ $headers[ trim( strtolower( $middle[0] ) ) ] = trim( $middle[1] );
141
+ }
142
+
143
+ // SCC_Logger::log( $header );
144
+ // SCC_Logger::log( $headers );
145
+
146
+ if ( ! empty( $error ) || false === $response ) {
147
+ $responses[ $sns ]['body'] = '';
148
+ $responses[ $sns ]['error'] = $error;
149
+ $responses[ $sns ]['header'] = $headers;
150
+ } else {
151
+ $responses[ $sns ]['body'] = $body;
152
+ $responses[ $sns ]['error'] = $error;
153
+ $responses[ $sns ]['header'] = $headers;
154
+ }
155
+
156
+ curl_multi_remove_handle( $mh, $ch[ $sns ] );
157
+ curl_close( $ch[ $sns ] );
158
+ } // End foreach().
159
+
160
+ curl_multi_close( $mh );
161
+
162
+ /*
163
+
164
+ do {
165
+ $stat = curl_multi_exec( $mh, $running );
166
+ } while ( CURLM_CALL_MULTI_PERFORM === $stat );
167
+
168
+ if ( ! $running || CURLM_OK !== $stat ) {
169
+ throw new RuntimeException( 'リクエストが開始出来なかった。マルチリクエスト内のどれか、URLの設定がおかしいのでは?' );
170
+ }
171
+
172
+ do switch ( curl_multi_select( $mh, $timeout ) ) {
173
+
174
+ case -1:
175
+ usleep( 10 );
176
+ do {
177
+ $stat = curl_multi_exec( $mh, $running );
178
+ } while ( CURLM_CALL_MULTI_PERFORM === $stat );
179
+ continue 2;
180
+
181
+ case 0:
182
+ continue 2;
183
+
184
+ default:
185
+ do {
186
+ $stat = curl_multi_exec( $mh, $running );
187
+ } while ( CURLM_CALL_MULTI_PERFORM === $stat );
188
+
189
+ do if ( $raised = curl_multi_info_read( $mh, $remains ) ) {
190
+
191
+ $sns = (string) $handle_to_sns[ (string) $raised['handle'] ];
192
+
193
+ $info = curl_getinfo( $raised['handle'] );
194
+ //echo "$info[url]: $info[http_code]\n";
195
+
196
+ $header_size = $info['header_size'];
197
+
198
+ $error = curl_error( $raised['handle'] );
199
+ $response = curl_multi_getcontent( $raised['handle'] );
200
+
201
+ $header = substr( $response, 0, $header_size );
202
+ $body = substr( $response, $header_size );
203
+
204
+ $headers = array();
205
+ $data = preg_split( '/[\r\n]+/', $header );
206
+ //$data = explode( '\r\n', $header );
207
+ array_shift( $data );
208
+ array_pop( $data );
209
+
210
+ foreach ( $data as $part ) {
211
+ $middle = explode( ':', $part, 2 );
212
+ $headers[ trim( strtolower( $middle[0] ) ) ] = trim( $middle[1] );
213
+ }
214
+
215
+ //SCC_Logger::log( $header );
216
+ //SCC_Logger::log( $headers );
217
+
218
+ if ( ! empty( $error ) || false === $response ) {
219
+ $responses[ $sns ]['body'] = '';
220
+ $responses[ $sns ]['error'] = $error;
221
+ $responses[ $sns ]['header'] = $headers;
222
+ } else {
223
+ $responses[ $sns ]['body'] = $body;
224
+ $responses[ $sns ]['error'] = $error;
225
+ $responses[ $sns ]['header'] = $headers;
226
+ }
227
+
228
+ curl_multi_remove_handle( $mh, $raised['handle'] );
229
+ curl_close( $raised['handle'] );
230
+ } while ( $remains );
231
+ } while ( $running );
232
+
233
+ curl_multi_close( $mh );
234
+ */
235
+
236
+ return $responses;
237
+
238
+ } else {
239
+
240
+ SCC_Logger::log( '[' . __METHOD__ . '] cURL: Off' );
241
+
242
+ foreach ( $urls as $sns => $url ) {
243
+
244
+ $options = array(
245
+ 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
246
+ );
247
+
248
+ if ( $sslverify ) {
249
+ $options['sslverify'] = true;
250
+ } else {
251
+ $options['sslverify'] = false;
252
+ }
253
+
254
+ if ( $timeout > 0 ) {
255
+ $options['timeout'] = $timeout;
256
+ }
257
+
258
+ if ( ! empty( $headers[ $sns ] ) ) {
259
+ $options['headers'] = $headers[ $sns ];
260
+ }
261
+
262
+ if ( isset( $methods[ $sns ] ) ) {
263
+ if ( 'GET' === $methods[ $sns ] ) {
264
+ $response = wp_remote_get( $url, $options );
265
+ } elseif ( 'POST' === $methods[ $sns ] ) {
266
+ if ( isset( $bodies[ $sns ] ) ) {
267
+ $options['body'] = wp_json_encode( $bodies[ $sns ] );
268
+ }
269
+ $response = wp_remote_post( $url, $options );
270
+ } else {
271
+ $response = wp_remote_get( $url, $options );
272
+ }
273
+ }
274
+
275
+ // SCC_Logger::log( $response );
276
+
277
+ if ( ! is_wp_error( $response ) ) {
278
+ if ( 200 === $response['response']['code'] ) {
279
+ $responses[ $sns ]['body'] = $response['body'];
280
+ $responses[ $sns ]['error'] = '';
281
+ $responses[ $sns ]['header'] = wp_remote_retrieve_headers( $response );
282
+ } else {
283
+ $responses[ $sns ]['body'] = '';
284
+ $responses[ $sns ]['error'] = 'Response Code: ' . $response['response']['code'] . ' Message: ' . $response['response']['message'];
285
+ $responses[ $sns ]['header'] = wp_remote_retrieve_headers( $response );
286
+ }
287
+ } else {
288
+ $responses[ $sns ]['body'] = '';
289
+ $responses[ $sns ]['error'] = $response->get_error_message();
290
+ $responses[ $sns ]['header'] = wp_remote_retrieve_headers( $response );
291
+ }
292
+ } // End foreach().
293
+
294
+ return $responses;
295
+ } // End if().
296
+ }
297
+
298
+ }
299
+
300
+ ?>
includes/class-scc-logger.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ class-scc-logger.php
4
+
5
+ Description: This class is a common utility
6
+ Author: Daisuke Maruyama
7
+ Author URI: http://marubon.info/
8
+ License: GPL2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; either version 2
18
+ of the License, or (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ */
29
+
30
+ class SCC_Logger {
31
+
32
+ /**
33
+ * Class constarctor
34
+ * Hook onto all of the actions and filters needed by the plugin.
35
+ */
36
+ protected function __construct() {
37
+ self::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
38
+ }
39
+
40
+ /**
41
+ * Output log message according to WP_DEBUG setting
42
+ *
43
+ * @param string $message Message.
44
+ * @return void
45
+ */
46
+ public static function log( $message ) {
47
+ if ( WP_DEBUG === true ) {
48
+ if ( is_array( $message ) || is_object( $message ) ) {
49
+ error_log( print_r( $message, true ) );
50
+ } else {
51
+ error_log( $message );
52
+ }
53
+ }
54
+ }
55
+
56
+ }
57
+
58
+ ?>
includes/class-scc-oauth.php ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ class-scc-oauth.php
4
+
5
+ Description: This class is a common utility
6
+ Author: Daisuke Maruyama
7
+ Author URI: http://marubon.info/
8
+ License: GPL2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; either version 2
18
+ of the License, or (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ */
29
+
30
+ /**
31
+ * SCC_Oauth
32
+ */
33
+ class SCC_Oauth {
34
+
35
+ /**
36
+ * Class constarctor
37
+ * Hook onto all of the actions and filters needed by the plugin.
38
+ */
39
+ protected function __construct() {
40
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
41
+ }
42
+
43
+ /**
44
+ * Get bearer token for Twitter
45
+ *
46
+ * @param string $cosumer_key Consumer key.
47
+ * @param string $consumer_secret Consumer secret.
48
+ * @param boolean $sslverify SSL verification.
49
+ * @param integer $timeout Timeout.
50
+ * @return string
51
+ */
52
+ public static function get_twitter_bearer_token( $cosumer_key, $consumer_secret, $sslverify = true, $timeout = 10 ) {
53
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
54
+
55
+ global $wp_version;
56
+
57
+ $bearer_token = '';
58
+ $url = 'https://api.twitter.com/oauth2/token';
59
+
60
+ $credential = base64_encode( $cosumer_key . ':' . $consumer_secret );
61
+
62
+ $options = array(
63
+ 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
64
+ );
65
+
66
+ if ( $sslverify ) {
67
+ $options['sslverify'] = true;
68
+ } else {
69
+ $options['sslverify'] = false;
70
+ }
71
+
72
+ if ( $timeout > 0 ) {
73
+ $options['timeout'] = $timeout;
74
+ }
75
+
76
+ $headers = array(
77
+ 'Authorization' => 'Basic ' . $credential,
78
+ 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8',
79
+ );
80
+
81
+ if ( ! empty( $headers ) ) {
82
+ $options['headers'] = $headers;
83
+ }
84
+
85
+ $body = array(
86
+ 'grant_type' => 'client_credentials',
87
+ );
88
+
89
+ if ( ! empty( $body ) ) {
90
+ $options['body'] = $body;
91
+ }
92
+
93
+ $response = wp_remote_post( $url, $options );
94
+
95
+ if ( ! is_wp_error( $response ) ) {
96
+ if ( 200 === $response['response']['code'] ) {
97
+ $json = $response['body'];
98
+ $content = json_decode( $json, true );
99
+ if ( ! empty( $content['token_type'] ) && 'bearer' === $content['token_type'] ) {
100
+ if ( ! empty( $content['access_token'] ) ) {
101
+ $bearer_token = $content['access_token'];
102
+ } else {
103
+ return new WP_Error( 'no_bearer_token', '[ERROR] No bearer token' );
104
+ }
105
+ } else {
106
+ return new WP_Error( 'no_bearer_token', '[ERROR] No bearer token' );
107
+ }
108
+ } else {
109
+ return new WP_Error( 'invalid_response_code', '[ERROR] Invalid response code: ' . $response['response']['code'] . ' ' . $response['response']['message'] );
110
+ }
111
+ } else {
112
+ return $response;
113
+ }
114
+
115
+ return $bearer_token;
116
+ }
117
+
118
+ /**
119
+ * Get acess token for Instagram
120
+ *
121
+ * @param string $client_id Client ID.
122
+ * @param string $client_secret Client Secret.
123
+ * @param string $redirect_uri Redirect URI.
124
+ * @param string $code Code.
125
+ * @param boolean $sslverify SSL verification.
126
+ * @param integer $timeout Timeout.
127
+ * @return string
128
+ */
129
+ public static function get_instagram_access_token( $client_id, $client_secret, $redirect_uri, $code, $sslverify = true, $timeout = 10 ) {
130
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
131
+
132
+ global $wp_version;
133
+
134
+ $access_token = '';
135
+ $url = 'https://api.instagram.com/oauth/access_token';
136
+
137
+ $options = array(
138
+ 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
139
+ );
140
+
141
+ if ( $sslverify ) {
142
+ $options['sslverify'] = true;
143
+ } else {
144
+ $options['sslverify'] = false;
145
+ }
146
+
147
+ if ( $timeout > 0 ) {
148
+ $options['timeout'] = $timeout;
149
+ }
150
+
151
+ $body = array(
152
+ 'client_id' => $client_id,
153
+ 'client_secret' => $client_secret,
154
+ 'grant_type' => 'authorization_code',
155
+ 'redirect_uri' => $redirect_uri,
156
+ 'code' => $code,
157
+ );
158
+
159
+ if ( ! empty( $body ) ) {
160
+ $options['body'] = $body;
161
+ }
162
+
163
+ $response = wp_remote_post( $url, $options );
164
+
165
+ if ( ! is_wp_error( $response ) ) {
166
+ if ( 200 === $response['response']['code'] ) {
167
+ $json = $response['body'];
168
+ $content = json_decode( $json, true );
169
+ if ( ! empty( $content['access_token'] ) ) {
170
+ $access_token = $content['access_token'];
171
+ } else {
172
+ return new WP_Error( 'no_access_token', '[ERROR] No access token' );
173
+ }
174
+ } else {
175
+ return new WP_Error( 'invalid_response_code', '[ERROR] Invalid response code: ' . $response['response']['code'] . ' ' . $response['response']['message'] );
176
+ }
177
+ } else {
178
+ return $response;
179
+ }
180
+
181
+ return $access_token;
182
+ }
183
+
184
+ /**
185
+ * Get acess token for Facebook
186
+ *
187
+ * @param string $app_id App ID,
188
+ * @param string $app_secret App secret.
189
+ * @param string $redirect_uri Redirect URI.
190
+ * @param string $code Code.
191
+ * @param string $page_id Page ID.
192
+ * @param boolean $sslverify SSL verification.
193
+ * @param integer $timeout Timeout.
194
+ * @return string
195
+ */
196
+ public static function get_facebook_access_token( $app_id, $app_secret, $redirect_uri, $code, $page_id, $sslverify = true, $timeout = 10 ) {
197
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
198
+
199
+ global $wp_version;
200
+
201
+ $original_access_token = '';
202
+ $extended_access_token = '';
203
+ $access_token = '';
204
+
205
+ $url = 'https://graph.facebook.com/oauth/access_token';
206
+
207
+ $options = array(
208
+ 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
209
+ );
210
+
211
+ if ( $sslverify ) {
212
+ $options['sslverify'] = true;
213
+ } else {
214
+ $options['sslverify'] = false;
215
+ }
216
+
217
+ if ( $timeout > 0 ) {
218
+ $options['timeout'] = $timeout;
219
+ }
220
+
221
+ $query_parameters = array(
222
+ 'client_id' => $app_id,
223
+ 'client_secret' => $app_secret,
224
+ 'redirect_uri' => $redirect_uri,
225
+ 'code' => $code,
226
+ );
227
+
228
+ $request_url = $url . '?' . http_build_query( $query_parameters , '' , '&' );
229
+
230
+ $response = wp_remote_get( $request_url, $options );
231
+
232
+ if ( ! is_wp_error( $response ) ) {
233
+ if ( 200 === $response['response']['code'] ) {
234
+
235
+ $data = json_decode( $response['body'], true );
236
+
237
+ if ( ! empty( $data['access_token'] ) ) {
238
+ $original_access_token = $data['access_token'];
239
+ } else {
240
+ return new WP_Error( 'no_original_access_token', '[ERROR] No original access token' );
241
+ }
242
+ } else {
243
+ return new WP_Error( 'invalid_response_code', '[ERROR] Invalid response code: ' . $response['response']['code'] . ' ' . $response['response']['message'] );
244
+ }
245
+ } else {
246
+ return new WP_Error( 'request_error', '[ERROR] Request error' );
247
+ }
248
+
249
+ // SCC_Logger::log( $response );
250
+ // SCC_Logger::log( '[' . __METHOD__ . '] Original access token: ' . $original_access_token );
251
+
252
+ if ( ! empty( $original_access_token ) ) {
253
+ $url = 'https://graph.facebook.com/oauth/access_token';
254
+
255
+ $query_parameters = array(
256
+ 'client_id' => $app_id,
257
+ 'client_secret' => $app_secret,
258
+ 'grant_type' => 'fb_exchange_token',
259
+ 'fb_exchange_token' => $original_access_token,
260
+ );
261
+
262
+ $request_url = $url . '?' . http_build_query( $query_parameters, '' , '&' );
263
+
264
+ $response = wp_remote_get( $request_url, $options );
265
+
266
+ $data = array();
267
+
268
+ if ( ! is_wp_error( $response ) ) {
269
+ if ( 200 === $response['response']['code'] ) {
270
+
271
+ $data = json_decode( $response['body'], true );
272
+
273
+ if ( ! empty( $data['access_token'] ) ) {
274
+ $extended_access_token = $data['access_token'];
275
+ } else {
276
+ return new WP_Error( 'no_extended_access_token', '[ERROR] No extended access token' );
277
+ }
278
+ } else {
279
+ return new WP_Error( 'invalid_response_code', '[ERROR] Invalid response code: ' . $response['response']['code'] . ' ' . $response['response']['message'] );
280
+ }
281
+ } else {
282
+ return new WP_Error( 'request_error', '[ERROR] Request error' );
283
+ }
284
+ } // End if().
285
+
286
+ // SCC_Logger::log( $response );
287
+ // SCC_Logger::log( '[' . __METHOD__ . '] Extended access token: ' . $original_access_token );
288
+
289
+ if ( ! empty( $extended_access_token ) ) {
290
+ $url = 'https://graph.facebook.com/me/accounts';
291
+
292
+ $query_parameters = array(
293
+ 'access_token' => $extended_access_token,
294
+ );
295
+
296
+ $request_url = $url . '?' . http_build_query( $query_parameters, '' , '&' );
297
+
298
+ $response = wp_remote_get( $request_url, $options );
299
+
300
+ // SCC_Logger::log( $response );
301
+
302
+ if ( ! is_wp_error( $response ) ) {
303
+ if ( 200 === $response['response']['code'] ) {
304
+ $content = json_decode( $response['body'], true );
305
+
306
+ $i = 0;
307
+
308
+ while ( true ) {
309
+ if ( ! isset( $content['data'][ $i ] ) ) {
310
+ break;
311
+ }
312
+
313
+ if ( isset( $content['data'][ $i ]['id'] ) && $content['data'][ $i ]['id'] === $page_id ) {
314
+ if ( ! empty( $content['data'][ $i ]['access_token'] ) ) {
315
+ $access_token = $content['data'][ $i ]['access_token'];
316
+ }
317
+ break;
318
+ }
319
+
320
+ ++$i;
321
+ }
322
+
323
+ if ( ! $access_token ) {
324
+ return new WP_Error( 'no_target_access_token', '[ERROR] No access token' );
325
+ } else {
326
+ return $access_token;
327
+ }
328
+ } else {
329
+ return new WP_Error( 'invalid_response_code', '[ERROR] Invalid response code: ' . $response['response']['code'] . ' ' . $response['response']['message'] );
330
+ }
331
+ } else {
332
+ return new WP_Error( 'request_error', '[ERROR] Request error' );
333
+ }
334
+ } // End if().
335
+
336
+ }
337
+
338
+ }
339
+
340
+ ?>
includes/class-scc-share-analytical-engine.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-share-analytical-engine.php
4
 
5
  Description: This class is a data analytical engine.
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,6 +27,9 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
31
 
32
  /**
@@ -66,36 +69,47 @@ class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
66
 
67
  /**
68
  * Cache post types
 
 
69
  */
70
  private $post_types = array( 'post', 'page' );
71
 
72
  /**
73
  * Interval cheking and caching target data
 
 
74
  */
75
  private $check_interval = 600;
76
 
77
  /**
78
  * Offset suffix
 
 
79
  */
80
  private $base_schedule = '* * * 0 0';
81
 
82
  /**
83
  * Base directory
 
 
84
  */
85
- private $base_dir = NULL;
86
 
87
  /**
88
  * Crawl date key
 
 
89
  */
90
- private $crawl_date_key = NULL;
91
 
92
  /**
93
  * Initialization
94
  *
95
- * @since 0.1.1
 
96
  */
97
  public function initialize( $options = array() ) {
98
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
99
 
100
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
101
  $this->base_prefix = self::DEF_BASE_PREFIX;
@@ -106,17 +120,49 @@ class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
106
  $this->event_description = self::DEF_EVENT_DESCRIPTION;
107
  $this->base_dir = WP_PLUGIN_DIR . '/sns-count-cache/data/';
108
 
109
- if ( isset( $options['delegate'] ) ) $this->delegate = $options['delegate'];
110
- if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
111
- if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
112
- if ( isset( $options['base_schedule'] ) ) $this->base_schedule = $options['base_schedule'];
113
- if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
114
- if ( isset( $options['base_prefix'] ) ) $this->base_prefix = $options['base_prefix'];
115
- if ( isset( $options['delta_prefix'] ) ) $this->delta_prefix = $options['delta_prefix'];
116
- if ( isset( $options['prime_cron'] ) ) $this->prime_cron = $options['prime_cron'];
117
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
118
- if ( isset( $options['post_types'] ) ) $this->post_types = $options['post_types'];
119
- if ( isset( $options['crawl_date_key'] ) ) $this->crawl_date_key = $options['crawl_date_key'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
 
121
  add_action( $this->prime_cron, array( $this, 'prime_base' ) );
122
  add_action( $this->execute_cron, array( $this, 'execute_base' ), 10, 1 );
@@ -126,44 +172,46 @@ class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
126
  /**
127
  * Register event schedule for this engine
128
  *
129
- * @since 0.1.0
 
130
  */
131
  public function schedule_check_interval( $schedules ) {
132
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
133
 
134
- $schedules[$this->event_schedule] = array(
135
  'interval' => $this->check_interval,
136
- 'display' => $this->event_description
137
  );
138
 
139
  return $schedules;
140
  }
141
 
142
  /**
143
- * Schedule data retrieval and cache processing
144
  *
145
- * @since 0.1.0
146
  */
147
  public function prime_base() {
148
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
149
 
150
- $next_exec_time = SCC_WP_Cron_Util::next_exec_time( $this->base_schedule );
151
 
152
- SCC_Common_Util::log( '[' . __METHOD__ . '] next_exec_time (timesatamp): ' . $next_exec_time );
153
- SCC_Common_Util::log( '[' . __METHOD__ . '] next_exec_time (date): ' . date_i18n( 'Y/m/d H:i:s', $next_exec_time ) );
154
 
155
- if ( ! SCC_WP_Cron_Util::is_scheduled_hook( $this->execute_cron ) ) {
156
- wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( SCC_Common_Util::short_hash( $next_exec_time ) ) );
157
  }
158
  }
159
 
160
  /**
161
- * Get and cache data of each published post and page
162
  *
163
- * @since 0.1.0
 
164
  */
165
  public function execute_base( $hash ) {
166
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
167
 
168
  $current_date = date_i18n( 'Y/m/d H:i:s' );
169
 
@@ -172,27 +220,29 @@ class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
172
 
173
  if ( ! file_exists( $base_file ) ) {
174
  if ( touch( $base_file ) ) {
175
- SCC_Common_Util::log( '[' . __METHOD__ . '] file creation succeeded: ' . $base_file );
176
  } else {
177
- SCC_Common_Util::log( '[' . __METHOD__ . '] file creation failed: ' . $base_file );
178
  }
179
  }
180
 
181
  if ( file_exists( $base_file ) ) {
182
- SCC_Common_Util::log( '[' . __METHOD__ . '] file exists: ' . $base_file );
183
 
184
  $option_key = $this->get_cache_key( 'home' );
185
 
186
- if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
 
 
187
  foreach ( $this->target_sns as $sns => $active ) {
188
  if ( $active ) {
189
  if ( $sns !== $this->crawl_date_key ) {
190
- if ( ! isset( $sns_counts[$sns] ) || $sns_counts[$sns] < 0 ) {
191
- $sns_counts[$sns] = (int) -1;
192
  }
193
  } else {
194
- if ( ! isset( $sns_counts[$sns] ) ) {
195
- $sns_counts[$sns] = '';
196
  }
197
  }
198
  }
@@ -203,25 +253,25 @@ class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
203
  $fp = fopen( $base_file, 'w' );
204
 
205
  if ( fwrite( $fp, $data ) ) {
206
- SCC_Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ');
207
  } else {
208
- SCC_Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ');
209
  }
210
 
211
  if ( fclose( $fp ) ) {
212
- SCC_Common_Util::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
213
  } else {
214
- SCC_Common_Util::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
215
  }
216
  }
217
- }
218
 
219
  $query_args = array(
220
  'post_type' => $this->post_types,
221
  'post_status' => 'publish',
222
  'nopaging' => true,
223
  'update_post_term_cache' => false,
224
- 'update_post_meta_cache' => false
225
  );
226
 
227
  $posts_query = new WP_Query( $query_args );
@@ -236,9 +286,9 @@ class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
236
 
237
  if ( ! file_exists( $base_file ) ) {
238
  if ( touch( $base_file ) ) {
239
- SCC_Common_Util::log( '[' . __METHOD__ . '] export file creation succeeded: ' . $base_file );
240
  } else {
241
- SCC_Common_Util::log( '[' . __METHOD__ . '] export file creation failed: ' . $base_file );
242
  }
243
  }
244
 
@@ -253,19 +303,19 @@ class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
253
  $sns_count = get_post_meta( $post_id, $meta_key, true );
254
 
255
  if ( isset( $sns_count ) && $sns_count !== '' && $sns_count >= 0 ) {
256
- $sns_counts[$sns] = (int) $sns_count;
257
  } else {
258
- $sns_counts[$sns] = (int) -1;
259
  }
260
  } else {
261
  $meta_key = $this->get_cache_key( $sns );
262
 
263
  $sns_count = get_post_meta( $post_id, $meta_key, true );
264
 
265
- if ( isset( $sns_count ) && $sns_count !== '' ) {
266
- $sns_counts[$sns] = $sns_count;
267
  } else {
268
- $sns_counts[$sns] = '';
269
  }
270
  }
271
  }
@@ -276,29 +326,31 @@ class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
276
  $fp = fopen( $base_file, 'w' );
277
 
278
  if ( fwrite( $fp, $data ) ) {
279
- SCC_Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ' );
280
  } else {
281
- SCC_Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ' );
282
  }
283
 
284
  if ( fclose( $fp ) ) {
285
- SCC_Common_Util::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
286
  } else {
287
- SCC_Common_Util::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
288
  }
289
 
290
- }
291
- }
292
- }
293
- wp_reset_postdata();
294
- }
 
295
 
296
  }
297
 
298
- /**
299
- * Initialize meta key for ranking
300
  *
301
- * @since 0.6.1
 
302
  */
303
  public function analyze( $options = array() ) {
304
 
@@ -317,9 +369,9 @@ class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
317
  $data = fread( $fp, filesize( $base_file ) );
318
 
319
  if ( fclose( $fp ) ) {
320
- SCC_Common_Util::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
321
  } else {
322
- SCC_Common_Util::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
323
  }
324
 
325
  $sns_base_counts = unserialize( $data );
@@ -327,16 +379,16 @@ class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
327
  // if there is no base file.
328
 
329
  if ( touch( $base_file ) ) {
330
- SCC_Common_Util::log( '[' . __METHOD__ . '] file creation succeeded: ' . $base_file );
331
  } else {
332
- SCC_Common_Util::log( '[' . __METHOD__ . '] file creation failed: ' . $base_file );
333
  }
334
 
335
  if ( file_exists( $base_file ) ) {
336
 
337
  $sns_counts = array();
338
 
339
- if ( $post_id !== 'home' ) {
340
  foreach ( $this->target_sns as $sns => $active ) {
341
  if ( $active ) {
342
  if ( $sns !== $this->crawl_date_key ) {
@@ -344,20 +396,20 @@ class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
344
 
345
  $sns_count = get_post_meta( $post_id, $meta_key, true );
346
 
347
- if ( isset( $sns_count ) && $sns_count !== '' && $sns_count >= 0 ) {
348
- $sns_counts[$sns] = (int) $sns_count;
349
  } else {
350
- $sns_counts[$sns] = (int) -1;
351
  }
352
  } else {
353
  $meta_key = $this->get_cache_key( $sns );
354
 
355
  $sns_count = get_post_meta( $post_id, $meta_key, true );
356
 
357
- if ( isset( $sns_count ) && $sns_count !== '' ) {
358
- $sns_counts[$sns] = $sns_count;
359
  } else {
360
- $sns_counts[$sns] = '';
361
  }
362
  }
363
  }
@@ -365,16 +417,18 @@ class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
365
  } else {
366
  $option_key = $this->get_cache_key( 'home' );
367
 
368
- if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
 
 
369
  foreach ( $this->target_sns as $sns => $active ) {
370
  if ( $active ) {
371
  if ( $sns !== $this->crawl_date_key ) {
372
- if ( ! isset( $sns_counts[$sns] ) || $sns_counts[$sns] < 0 ) {
373
- $sns_counts[$sns] = (int) -1;
374
  }
375
  } else {
376
- if ( ! isset( $sns_counts[$sns] ) ) {
377
- $sns_counts[$sns] = '';
378
  }
379
  }
380
  }
@@ -387,15 +441,15 @@ class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
387
  $fp = fopen( $base_file, 'w' );
388
 
389
  if ( fwrite( $fp, $data ) ) {
390
- SCC_Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ' );
391
  } else {
392
- SCC_Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ' );
393
  }
394
 
395
  if ( fclose( $fp ) ) {
396
- SCC_Common_Util::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
397
  } else {
398
- SCC_Common_Util::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
399
  }
400
  }
401
  }
@@ -403,23 +457,23 @@ class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
403
  $sns_counts = array();
404
  $diffs = array();
405
 
406
- if ( $post_id !== 'home' ) {
407
  foreach ( $this->target_sns as $sns => $active ) {
408
- if( $active ){
409
  $meta_key = $this->get_cache_key( $sns );
410
- $sns_counts[$sns] = get_post_meta( $post_id, $meta_key, true );
411
  }
412
  }
413
 
414
  foreach ( $this->target_sns as $sns => $active ) {
415
- if ( $active ){
416
  if ( $sns !== $this->crawl_date_key ) {
417
  $diff = (int) 0;
418
 
419
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] !== '' && $sns_counts[$sns] >= 0 && ! isset( $sns_base_counts[$sns] ) ) {
420
- $diff = (int) $sns_counts[$sns];
421
- } elseif ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] !== '' && $sns_counts[$sns] >= 0 && isset( $sns_base_counts[$sns] ) && $sns_base_counts[$sns] !== '' && $sns_base_counts[$sns] >= 0 ) {
422
- $diff = (int) ( $sns_counts[$sns] - $sns_base_counts[$sns] );
423
  } else {
424
  $diff = (int) 0;
425
  }
@@ -428,8 +482,8 @@ class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
428
 
429
  update_post_meta( $post_id, $meta_key, (int) $diff );
430
  } else {
431
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] !== '' && isset( $sns_base_counts[$sns] ) && $sns_base_counts[$sns] !== '' ) {
432
- $crawl_date = $sns_base_counts[$sns] . ',' . $sns_counts[$sns];
433
  } else {
434
  $crawl_date = '';
435
  }
@@ -445,23 +499,25 @@ class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
445
 
446
  $diffs = array();
447
 
448
- if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
 
 
449
 
450
  foreach ( $this->target_sns as $sns => $active ) {
451
- if ( $active ){
452
  if ( $sns !== $this->crawl_date_key ) {
453
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] !== '' && $sns_counts[$sns] >= 0 && ! isset( $sns_base_counts[$sns] ) ) {
454
- $diffs[$sns] = (int) $sns_counts[$sns];
455
- } elseif ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 && isset( $sns_base_counts[$sns] ) && $sns_base_counts[$sns] !== '' && $sns_base_counts[$sns] >= 0 ) {
456
- $diffs[$sns] = (int)( $sns_counts[$sns] - $sns_base_counts[$sns] );
457
  } else {
458
- $diffs[$sns] = (int) 0;
459
  }
460
  } else {
461
- if ( isset( $sns_counts[$sns] ) && isset( $sns_base_counts[$sns] ) && $sns_base_counts[$sns] !== '' ) {
462
- $diffs[$sns] = $sns_base_counts[$sns] . ',' . $sns_counts[$sns];
463
  } else {
464
- $diffs[$sns] = '';
465
  }
466
  }
467
  }
@@ -474,11 +530,11 @@ class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
474
  } else {
475
 
476
  foreach ( $this->target_sns as $sns => $active ) {
477
- if ( $active ){
478
  if ( $sns !== $this->crawl_date_key ) {
479
- $diffs[$sns] = (int) 0;
480
  } else {
481
- $diffs[$sns] = '';
482
  }
483
  }
484
  }
@@ -492,12 +548,12 @@ class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
492
  }
493
 
494
  /**
495
- * Initialize meta key for ranking
496
  *
497
- * @since 0.3.0
498
  */
499
  public function initialize_base() {
500
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
501
 
502
  /*
503
  $option_key = $this->get_cache_key( $this->offset_suffix );
@@ -507,12 +563,12 @@ class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
507
  }
508
 
509
  /**
510
- * Clear meta key for ranking
511
  *
512
- * @since 0.3.0
513
  */
514
  public function clear_base() {
515
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
516
 
517
  $option_key = $this->get_delta_key( 'home' );
518
 
@@ -526,15 +582,20 @@ class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
526
  }
527
  }
528
 
 
 
 
 
529
  }
530
 
531
  /**
532
- * Clear meta key for ranking
533
  *
534
- * @since 0.7.0
 
535
  */
536
  public function clear_base_by_post_id( $post_id ) {
537
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
538
 
539
  foreach ( $this->target_sns as $sns => $active ) {
540
  if ( $active ) {
@@ -543,6 +604,10 @@ class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
543
  }
544
  }
545
 
 
 
 
 
546
  }
547
 
548
  }
1
  <?php
2
+ /**
3
  class-scc-share-analytical-engine.php
4
 
5
  Description: This class is a data analytical engine.
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Share_Analytical_Engine
32
+ */
33
  class SCC_Share_Analytical_Engine extends SCC_Analytical_Engine {
34
 
35
  /**
69
 
70
  /**
71
  * Cache post types
72
+ *
73
+ * @var array
74
  */
75
  private $post_types = array( 'post', 'page' );
76
 
77
  /**
78
  * Interval cheking and caching target data
79
+ *
80
+ * @var integer
81
  */
82
  private $check_interval = 600;
83
 
84
  /**
85
  * Offset suffix
86
+ *
87
+ * @var string
88
  */
89
  private $base_schedule = '* * * 0 0';
90
 
91
  /**
92
  * Base directory
93
+ *
94
+ * @var string
95
  */
96
+ private $base_dir = null;
97
 
98
  /**
99
  * Crawl date key
100
+ *
101
+ * @var string
102
  */
103
+ private $crawl_date_key = null;
104
 
105
  /**
106
  * Initialization
107
  *
108
+ * @param array $options Option.
109
+ * @return void
110
  */
111
  public function initialize( $options = array() ) {
112
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
113
 
114
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
115
  $this->base_prefix = self::DEF_BASE_PREFIX;
120
  $this->event_description = self::DEF_EVENT_DESCRIPTION;
121
  $this->base_dir = WP_PLUGIN_DIR . '/sns-count-cache/data/';
122
 
123
+ if ( isset( $options['delegate'] ) ) {
124
+ $this->delegate = $options['delegate'];
125
+ }
126
+
127
+ if ( isset( $options['target_sns'] ) ) {
128
+ $this->target_sns = $options['target_sns'];
129
+ }
130
+
131
+ if ( isset( $options['check_interval'] ) ) {
132
+ $this->check_interval = $options['check_interval'];
133
+ }
134
+
135
+ if ( isset( $options['base_schedule'] ) ) {
136
+ $this->base_schedule = $options['base_schedule'];
137
+ }
138
+
139
+ if ( isset( $options['cache_prefix'] ) ) {
140
+ $this->cache_prefix = $options['cache_prefix'];
141
+ }
142
+
143
+ if ( isset( $options['base_prefix'] ) ) {
144
+ $this->base_prefix = $options['base_prefix'];
145
+ }
146
+
147
+ if ( isset( $options['delta_prefix'] ) ) {
148
+ $this->delta_prefix = $options['delta_prefix'];
149
+ }
150
+
151
+ if ( isset( $options['prime_cron'] ) ) {
152
+ $this->prime_cron = $options['prime_cron'];
153
+ }
154
+
155
+ if ( isset( $options['execute_cron'] ) ) {
156
+ $this->execute_cron = $options['execute_cron'];
157
+ }
158
+
159
+ if ( isset( $options['post_types'] ) ) {
160
+ $this->post_types = $options['post_types'];
161
+ }
162
+
163
+ if ( isset( $options['crawl_date_key'] ) ) {
164
+ $this->crawl_date_key = $options['crawl_date_key'];
165
+ }
166
 
167
  add_action( $this->prime_cron, array( $this, 'prime_base' ) );
168
  add_action( $this->execute_cron, array( $this, 'execute_base' ), 10, 1 );
172
  /**
173
  * Register event schedule for this engine
174
  *
175
+ * @param array $schedules Schedule.
176
+ * @return array
177
  */
178
  public function schedule_check_interval( $schedules ) {
179
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
180
 
181
+ $schedules[ $this->event_schedule ] = array(
182
  'interval' => $this->check_interval,
183
+ 'display' => $this->event_description,
184
  );
185
 
186
  return $schedules;
187
  }
188
 
189
  /**
190
+ * Schedule analysis processing
191
  *
192
+ * @return void
193
  */
194
  public function prime_base() {
195
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
196
 
197
+ $next_exec_time = SCC_WP_Cron::next_exec_time( $this->base_schedule );
198
 
199
+ SCC_Logger::log( '[' . __METHOD__ . '] next_exec_time (timesatamp): ' . $next_exec_time );
200
+ SCC_Logger::log( '[' . __METHOD__ . '] next_exec_time (date): ' . date_i18n( 'Y/m/d H:i:s', $next_exec_time ) );
201
 
202
+ if ( ! SCC_WP_Cron::is_scheduled_hook( $this->execute_cron ) ) {
203
+ wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( SCC_Hash::short_hash( $next_exec_time ) ) );
204
  }
205
  }
206
 
207
  /**
208
+ * Analyze
209
  *
210
+ * @param string $hash Hash.
211
+ * @return void
212
  */
213
  public function execute_base( $hash ) {
214
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
215
 
216
  $current_date = date_i18n( 'Y/m/d H:i:s' );
217
 
220
 
221
  if ( ! file_exists( $base_file ) ) {
222
  if ( touch( $base_file ) ) {
223
+ SCC_Logger::log( '[' . __METHOD__ . '] file creation succeeded: ' . $base_file );
224
  } else {
225
+ SCC_Logger::log( '[' . __METHOD__ . '] file creation failed: ' . $base_file );
226
  }
227
  }
228
 
229
  if ( file_exists( $base_file ) ) {
230
+ SCC_Logger::log( '[' . __METHOD__ . '] file exists: ' . $base_file );
231
 
232
  $option_key = $this->get_cache_key( 'home' );
233
 
234
+ $sns_counts = get_option( $option_key );
235
+
236
+ if ( false !== $sns_counts ) {
237
  foreach ( $this->target_sns as $sns => $active ) {
238
  if ( $active ) {
239
  if ( $sns !== $this->crawl_date_key ) {
240
+ if ( ! isset( $sns_counts[ $sns ] ) || 0 > $sns_counts[ $sns ] ) {
241
+ $sns_counts[ $sns ] = (int) -1;
242
  }
243
  } else {
244
+ if ( ! isset( $sns_counts[ $sns ] ) ) {
245
+ $sns_counts[ $sns ] = '';
246
  }
247
  }
248
  }
253
  $fp = fopen( $base_file, 'w' );
254
 
255
  if ( fwrite( $fp, $data ) ) {
256
+ SCC_Logger::log( '[' . __METHOD__ . '] file write succeeded: ');
257
  } else {
258
+ SCC_Logger::log( '[' . __METHOD__ . '] file wrote failed: ');
259
  }
260
 
261
  if ( fclose( $fp ) ) {
262
+ SCC_Logger::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
263
  } else {
264
+ SCC_Logger::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
265
  }
266
  }
267
+ } // End if().
268
 
269
  $query_args = array(
270
  'post_type' => $this->post_types,
271
  'post_status' => 'publish',
272
  'nopaging' => true,
273
  'update_post_term_cache' => false,
274
+ 'update_post_meta_cache' => false,
275
  );
276
 
277
  $posts_query = new WP_Query( $query_args );
286
 
287
  if ( ! file_exists( $base_file ) ) {
288
  if ( touch( $base_file ) ) {
289
+ SCC_Logger::log( '[' . __METHOD__ . '] export file creation succeeded: ' . $base_file );
290
  } else {
291
+ SCC_Logger::log( '[' . __METHOD__ . '] export file creation failed: ' . $base_file );
292
  }
293
  }
294
 
303
  $sns_count = get_post_meta( $post_id, $meta_key, true );
304
 
305
  if ( isset( $sns_count ) && $sns_count !== '' && $sns_count >= 0 ) {
306
+ $sns_counts[ $sns ] = (int) $sns_count;
307
  } else {
308
+ $sns_counts[ $sns ] = (int) -1;
309
  }
310
  } else {
311
  $meta_key = $this->get_cache_key( $sns );
312
 
313
  $sns_count = get_post_meta( $post_id, $meta_key, true );
314
 
315
+ if ( isset( $sns_count ) && '' !== $sns_count ) {
316
+ $sns_counts[ $sns ] = $sns_count;
317
  } else {
318
+ $sns_counts[ $sns ] = '';
319
  }
320
  }
321
  }
326
  $fp = fopen( $base_file, 'w' );
327
 
328
  if ( fwrite( $fp, $data ) ) {
329
+ SCC_Logger::log( '[' . __METHOD__ . '] file write succeeded: ' );
330
  } else {
331
+ SCC_Logger::log( '[' . __METHOD__ . '] file wrote failed: ' );
332
  }
333
 
334
  if ( fclose( $fp ) ) {
335
+ SCC_Logger::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
336
  } else {
337
+ SCC_Logger::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
338
  }
339
 
340
+ } // End if().
341
+ } // End while().
342
+ } // End if().
343
+
344
+ wp_reset_postdata();
345
+ } // End if().
346
 
347
  }
348
 
349
+ /**
350
+ * Analyze
351
  *
352
+ * @param array $options Option.
353
+ * @return void
354
  */
355
  public function analyze( $options = array() ) {
356
 
369
  $data = fread( $fp, filesize( $base_file ) );
370
 
371
  if ( fclose( $fp ) ) {
372
+ SCC_Logger::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
373
  } else {
374
+ SCC_Logger::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
375
  }
376
 
377
  $sns_base_counts = unserialize( $data );
379
  // if there is no base file.
380
 
381
  if ( touch( $base_file ) ) {
382
+ SCC_Logger::log( '[' . __METHOD__ . '] file creation succeeded: ' . $base_file );
383
  } else {
384
+ SCC_Logger::log( '[' . __METHOD__ . '] file creation failed: ' . $base_file );
385
  }
386
 
387
  if ( file_exists( $base_file ) ) {
388
 
389
  $sns_counts = array();
390
 
391
+ if ( 'home' !== $post_id ) {
392
  foreach ( $this->target_sns as $sns => $active ) {
393
  if ( $active ) {
394
  if ( $sns !== $this->crawl_date_key ) {
396
 
397
  $sns_count = get_post_meta( $post_id, $meta_key, true );
398
 
399
+ if ( isset( $sns_count ) && '' !== $sns_count && 0 <= $sns_count ) {
400
+ $sns_counts[ $sns ] = (int) $sns_count;
401
  } else {
402
+ $sns_counts[ $sns ] = (int) -1;
403
  }
404
  } else {
405
  $meta_key = $this->get_cache_key( $sns );
406
 
407
  $sns_count = get_post_meta( $post_id, $meta_key, true );
408
 
409
+ if ( isset( $sns_count ) && '' !== $sns_count ) {
410
+ $sns_counts[ $sns ] = $sns_count;
411
  } else {
412
+ $sns_counts[ $sns ] = '';
413
  }
414
  }
415
  }
417
  } else {
418
  $option_key = $this->get_cache_key( 'home' );
419
 
420
+ $sns_counts = get_option( $option_key );
421
+
422
+ if ( false !== $sns_counts ) {
423
  foreach ( $this->target_sns as $sns => $active ) {
424
  if ( $active ) {
425
  if ( $sns !== $this->crawl_date_key ) {
426
+ if ( ! isset( $sns_counts[ $sns ] ) || 0 > $sns_counts[ $sns ] ) {
427
+ $sns_counts[ $sns ] = (int) -1;
428
  }
429
  } else {
430
+ if ( ! isset( $sns_counts[ $sns ] ) ) {
431
+ $sns_counts[ $sns ] = '';
432
  }
433
  }
434
  }
441
  $fp = fopen( $base_file, 'w' );
442
 
443
  if ( fwrite( $fp, $data ) ) {
444
+ SCC_Logger::log( '[' . __METHOD__ . '] file write succeeded: ' );
445
  } else {
446
+ SCC_Logger::log( '[' . __METHOD__ . '] file wrote failed: ' );
447
  }
448
 
449
  if ( fclose( $fp ) ) {
450
+ SCC_Logger::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
451
  } else {
452
+ SCC_Logger::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
453
  }
454
  }
455
  }
457
  $sns_counts = array();
458
  $diffs = array();
459
 
460
+ if ( 'home' !== $post_id ) {
461
  foreach ( $this->target_sns as $sns => $active ) {
462
+ if ( $active ) {
463
  $meta_key = $this->get_cache_key( $sns );
464
+ $sns_counts[ $sns ] = get_post_meta( $post_id, $meta_key, true );
465
  }
466
  }
467
 
468
  foreach ( $this->target_sns as $sns => $active ) {
469
+ if ( $active ) {
470
  if ( $sns !== $this->crawl_date_key ) {
471
  $diff = (int) 0;
472
 
473
+ if ( isset( $sns_counts[ $sns ] ) && '' !== $sns_counts[ $sns ] && 0 <= $sns_counts[ $sns ] && ! isset( $sns_base_counts[ $sns ] ) ) {
474
+ $diff = (int) $sns_counts[ $sns ];
475
+ } elseif ( isset( $sns_counts[ $sns ] ) && '' !== $sns_counts[ $sns ] && 0 <= $sns_counts[ $sns ] && isset( $sns_base_counts[ $sns ] ) && '' !== $sns_base_counts[ $sns ] && 0 <= $sns_base_counts[ $sns ] ) {
476
+ $diff = (int) ( $sns_counts[ $sns ] - $sns_base_counts[ $sns ] );
477
  } else {
478
  $diff = (int) 0;
479
  }
482
 
483
  update_post_meta( $post_id, $meta_key, (int) $diff );
484
  } else {
485
+ if ( isset( $sns_counts[ $sns ] ) && '' !== $sns_counts[ $sns ] && isset( $sns_base_counts[ $sns ] ) && '' !== $sns_base_counts[ $sns ] ) {
486
+ $crawl_date = $sns_base_counts[ $sns ] . ',' . $sns_counts[ $sns ];
487
  } else {
488
  $crawl_date = '';
489
  }
499
 
500
  $diffs = array();
501
 
502
+ $sns_counts = get_option( $option_key );
503
+
504
+ if ( false !== $sns_counts ) {
505
 
506
  foreach ( $this->target_sns as $sns => $active ) {
507
+ if ( $active ) {
508
  if ( $sns !== $this->crawl_date_key ) {
509
+ if ( isset( $sns_counts[ $sns ] ) && '' !== $sns_counts[ $sns ] && 0 <= $sns_counts[ $sns ] && ! isset( $sns_base_counts[ $sns ] ) ) {
510
+ $diffs[ $sns ] = (int) $sns_counts[ $sns ];
511
+ } elseif ( isset( $sns_counts[ $sns ] ) && 0 <= $sns_counts[ $sns ] && isset( $sns_base_counts[ $sns ] ) && '' !== $sns_base_counts[ $sns ] && 0 <= $sns_base_counts[ $sns ] ) {
512
+ $diffs[ $sns ] = (int) ( $sns_counts[ $sns ] - $sns_base_counts[ $sns ] );
513
  } else {
514
+ $diffs[ $sns ] = (int) 0;
515
  }
516
  } else {
517
+ if ( isset( $sns_counts[ $sns ] ) && isset( $sns_base_counts[ $sns ] ) && '' !== $sns_base_counts[ $sns ] ) {
518
+ $diffs[ $sns ] = $sns_base_counts[ $sns ] . ',' . $sns_counts[ $sns ];
519
  } else {
520
+ $diffs[ $sns ] = '';
521
  }
522
  }
523
  }
530
  } else {
531
 
532
  foreach ( $this->target_sns as $sns => $active ) {
533
+ if ( $active ) {
534
  if ( $sns !== $this->crawl_date_key ) {
535
+ $diffs[ $sns ] = (int) 0;
536
  } else {
537
+ $diffs[ $sns ] = '';
538
  }
539
  }
540
  }
548
  }
549
 
550
  /**
551
+ * Initialize base
552
  *
553
+ * @return void
554
  */
555
  public function initialize_base() {
556
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
557
 
558
  /*
559
  $option_key = $this->get_cache_key( $this->offset_suffix );
563
  }
564
 
565
  /**
566
+ * Clear base
567
  *
568
+ * @return void
569
  */
570
  public function clear_base() {
571
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
572
 
573
  $option_key = $this->get_delta_key( 'home' );
574
 
582
  }
583
  }
584
 
585
+ // Processing for Google+ count removal
586
+ $meta_key = $this->get_delta_key( SNS_Count_Cache::REF_SHARE_GPLUS );
587
+ delete_post_meta_by_key( $meta_key );
588
+
589
  }
590
 
591
  /**
592
+ * Clear base
593
  *
594
+ * @param integer $post_id Post ID.
595
+ * @return void
596
  */
597
  public function clear_base_by_post_id( $post_id ) {
598
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
599
 
600
  foreach ( $this->target_sns as $sns => $active ) {
601
  if ( $active ) {
604
  }
605
  }
606
 
607
+ // Processing for Google+ count removal
608
+ $meta_key = $this->get_delta_key( SNS_Count_Cache::REF_SHARE_GPLUS );
609
+ delete_post_meta_by_key( $meta_key );
610
+
611
  }
612
 
613
  }
includes/class-scc-share-app-status-engine.php ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ class-scc-share-app-status-engine.php
4
+
5
+ Description:
6
+ Author: Daisuke Maruyama
7
+ Author URI: http://marubon.info/
8
+ License: GPL2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; either version 2
18
+ of the License, or (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ */
29
+
30
+ /**
31
+ * SCC_Share_App_Status_Engine
32
+ */
33
+ class SCC_Share_App_Status_Engine extends SCC_Engine {
34
+
35
+ /**
36
+ * Cron name to schedule cache processing
37
+ */
38
+ const DEF_PRIME_CRON = 'scc_share_appstatus_prime';
39
+
40
+ /**
41
+ * Cron name to execute cache processing
42
+ */
43
+ const DEF_EXECUTE_CRON = 'scc_share_appstatus_exec';
44
+
45
+ /**
46
+ * Schedule name for cache processing
47
+ */
48
+ const DEF_EVENT_SCHEDULE = 'share_app_status_event';
49
+
50
+ /**
51
+ * Schedule description for cache processing
52
+ */
53
+ const DEF_EVENT_DESCRIPTION = '[SCC] Share App Status Interval';
54
+
55
+ /**
56
+ * Interval cheking and caching target data
57
+ *
58
+ * @var integer
59
+ */
60
+ private $check_interval = 600;
61
+
62
+ /**
63
+ * Initialization
64
+ *
65
+ * @param array $options Option.
66
+ * @return void
67
+ */
68
+ public function initialize( $options = array() ) {
69
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
70
+
71
+ $this->prime_cron = self::DEF_PRIME_CRON;
72
+ $this->execute_cron = self::DEF_EXECUTE_CRON;
73
+ $this->event_schedule = self::DEF_EVENT_SCHEDULE;
74
+ $this->event_description = self::DEF_EVENT_DESCRIPTION;
75
+
76
+ $this->load_ratio = 0.5;
77
+
78
+ if ( isset( $options['delegate'] ) ) {
79
+ $this->delegate = $options['delegate'];
80
+ }
81
+
82
+ if ( isset( $options['crawler'] ) ) {
83
+ $this->crawler = $options['crawler'];
84
+ }
85
+
86
+ if ( isset( $options['target_sns'] ) ) {
87
+ $this->target_sns = $options['target_sns'];
88
+ }
89
+
90
+ if ( isset( $options['check_interval'] ) ) {
91
+ $this->check_interval = $options['check_interval'];
92
+ }
93
+
94
+ if ( isset( $options['cache_prefix'] ) ) {
95
+ $this->cache_prefix = $options['cache_prefix'];
96
+ }
97
+
98
+ if ( isset( $options['prime_cron'] ) ) {
99
+ $this->prime_cron = $options['prime_cron'];
100
+ }
101
+
102
+ if ( isset( $options['execute_cron'] ) ) {
103
+ $this->execute_cron = $options['execute_cron'];
104
+ }
105
+
106
+ if ( isset( $options['event_schedule'] ) ) {
107
+ $this->event_schedule = $options['event_schedule'];
108
+ }
109
+
110
+ if ( isset( $options['event_description'] ) ) {
111
+ $this->event_description = $options['event_description'];
112
+ }
113
+
114
+ add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
115
+ add_action( $this->prime_cron, array( $this, 'prime_check' ) );
116
+ add_action( $this->execute_cron, array( $this, 'execute_check' ), 10, 0 );
117
+ }
118
+
119
+ /**
120
+ * Register event schedule for this engine
121
+ *
122
+ * @param array $schedules Schedule.
123
+ * @return array
124
+ */
125
+ public function schedule_check_interval( $schedules ) {
126
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
127
+
128
+ $schedules[ $this->event_schedule ] = array(
129
+ 'interval' => $this->check_interval,
130
+ 'display' => $this->event_description,
131
+ );
132
+
133
+ return $schedules;
134
+ }
135
+
136
+ /**
137
+ * Schedule app status ckeck
138
+ *
139
+ * @return void
140
+ */
141
+ public function prime_check() {
142
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
143
+
144
+ $next_exec_time = (int) current_time( 'timestamp', 1 ) + $this->check_interval;
145
+
146
+ SCC_Logger::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
147
+ SCC_Logger::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
148
+
149
+ wp_schedule_single_event( $next_exec_time, $this->execute_cron );
150
+
151
+ }
152
+
153
+ /**
154
+ * Check app status
155
+ *
156
+ * @return void
157
+ */
158
+ public function execute_check() {
159
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
160
+
161
+ SCC_Logger::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
162
+
163
+ $url = home_url( '/' );
164
+ $title = get_bloginfo( 'name' );
165
+
166
+ $target_option = array(
167
+ 'target_url' => $url,
168
+ 'target_title' => $title,
169
+ );
170
+
171
+ $response = $this->get_data( $this->target_sns, $target_option );
172
+
173
+ $app_info = $response['info'];
174
+
175
+ if ( ! empty( $app_info ) ) {
176
+ update_option( SNS_Count_Cache::DB_SHARE_APP_STATUS, $app_info );
177
+ }
178
+
179
+ }
180
+
181
+ /**
182
+ * Get data
183
+ *
184
+ * @param array $target_sns Target SNS.
185
+ * @param array $target_option Target Option.
186
+ * @return array
187
+ */
188
+ private function get_data( $target_sns, $target_option ) {
189
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
190
+
191
+ $target_sns_base = $target_sns;
192
+
193
+ $target_url = $target_option['target_url'];
194
+ $target_title = $target_option['target_title'];
195
+
196
+ unset( $target_sns_base[ SNS_Count_Cache::REF_CRAWL_DATE ] );
197
+ unset( $target_sns_base[ SNS_Count_Cache::REF_SHARE_TOTAL ] );
198
+
199
+ $parameters = array(
200
+ 'url' => $target_url,
201
+ 'title' => $target_title,
202
+ );
203
+
204
+ foreach ( $target_sns_base as $sns => $active ) {
205
+ if ( $active ) {
206
+ $this->crawler->set_crawl_strategy_parameters( $sns, $parameters );
207
+ }
208
+ }
209
+
210
+ return $this->crawler->get_data( $target_sns, null );
211
+ }
212
+
213
+ /**
214
+ * Check nessesary of throttle processing
215
+ *
216
+ * @param array $options Option.
217
+ * @return boolean
218
+ */
219
+ public function need_throttle( $options ) {
220
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
221
+
222
+ $expected_call_count = $options['expected_call_count'];
223
+
224
+ $app_info = get_option( SNS_Count_Cache::DB_SHARE_APP_STATUS );
225
+
226
+ if ( false !== $app_info ) {
227
+ if ( ! empty( $app_info[ SNS_Count_Cache::REF_SHARE_FACEBOOK ][ strtolower( 'X-App-Usage' ) ]['call_count'] ) ) {
228
+ $current_call_count = (int) $app_info[ SNS_Count_Cache::REF_SHARE_FACEBOOK ][ strtolower( 'X-App-Usage' ) ]['call_count'];
229
+
230
+ SCC_Logger::log( '[' . __METHOD__ . '] current_call_count: ' . $current_call_count );
231
+ SCC_Logger::log( '[' . __METHOD__ . '] expected_call_count: ' . $expected_call_count );
232
+
233
+ $threshold = 100;
234
+
235
+ if ( $current_call_count + $expected_call_count > $threshold ) {
236
+ return true;
237
+ } else {
238
+ return false;
239
+ }
240
+ } else {
241
+ return true;
242
+ }
243
+ } else {
244
+ return true;
245
+ }
246
+ }
247
+
248
+ }
249
+
250
+ ?>
includes/class-scc-share-base-cache-engine.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-share-base-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,6 +27,9 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  class SCC_Share_Base_Cache_Engine extends SCC_Share_Cache_Engine {
31
 
32
  /**
@@ -56,31 +59,40 @@ class SCC_Share_Base_Cache_Engine extends SCC_Share_Cache_Engine {
56
 
57
  /**
58
  * Cache post types
 
 
59
  */
60
  private $post_types = array( 'post', 'page' );
61
 
62
  /**
63
  * Interval cheking and caching target data
 
 
64
  */
65
  private $check_interval = 600;
66
 
67
  /**
68
  * Number of posts to check at a time
 
 
69
  */
70
  private $posts_per_check = 20;
71
 
72
  /**
73
  * Offset suffix
 
 
74
  */
75
  private $offset_suffix = 'base_offset';
76
 
77
  /**
78
  * Initialization
79
  *
80
- * @since 0.1.1
 
81
  */
82
  public function initialize( $options = array() ) {
83
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
84
 
85
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
86
  $this->prime_cron = self::DEF_PRIME_CRON;
@@ -90,23 +102,73 @@ class SCC_Share_Base_Cache_Engine extends SCC_Share_Cache_Engine {
90
 
91
  $this->load_ratio = 0.5;
92
 
93
- if ( isset( $options['delegate'] ) ) $this->delegate = $options['delegate'];
94
- if ( isset( $options['crawler'] ) ) $this->crawler = $options['crawler'];
95
- if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
96
- if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
97
- if ( isset( $options['posts_per_check'] ) ) $this->posts_per_check = $options['posts_per_check'];
98
- if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
99
- if ( isset( $options['prime_cron'] ) ) $this->prime_cron = $options['prime_cron'];
100
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
101
- if ( isset( $options['event_schedule'] ) ) $this->event_schedule = $options['event_schedule'];
102
- if ( isset( $options['event_description'] ) ) $this->event_description = $options['event_description'];
103
- if ( isset( $options['post_types'] ) ) $this->post_types = $options['post_types'];
104
- if ( isset( $options['scheme_migration_mode'] ) ) $this->scheme_migration_mode = $options['scheme_migration_mode'];
105
- if ( isset( $options['scheme_migration_date'] ) ) $this->scheme_migration_date = $options['scheme_migration_date'];
106
- if ( isset( $options['scheme_migration_exclude_keys'] ) ) $this->scheme_migration_exclude_keys = $options['scheme_migration_exclude_keys'];
107
- if ( isset( $options['cache_retry'] ) ) $this->cache_retry = $options['cache_retry'];
108
- if ( isset( $options['retry_limit'] ) ) $this->retry_limit = $options['retry_limit'];
109
- if ( isset( $options['fault_tolerance'] ) ) $this->fault_tolerance = $options['fault_tolerance'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
 
111
  add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
112
  add_action( $this->prime_cron, array( $this, 'prime_cache' ) );
@@ -116,14 +178,15 @@ class SCC_Share_Base_Cache_Engine extends SCC_Share_Cache_Engine {
116
  /**
117
  * Register event schedule for this engine
118
  *
119
- * @since 0.1.0
 
120
  */
121
  public function schedule_check_interval( $schedules ) {
122
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
123
 
124
- $schedules[$this->event_schedule] = array(
125
  'interval' => $this->check_interval,
126
- 'display' => $this->event_description
127
  );
128
 
129
  return $schedules;
@@ -132,26 +195,28 @@ class SCC_Share_Base_Cache_Engine extends SCC_Share_Cache_Engine {
132
  /**
133
  * Schedule data retrieval and cache processing
134
  *
135
- * @since 0.1.0
136
  */
137
  public function prime_cache() {
138
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
139
 
140
  $next_exec_time = (int) current_time( 'timestamp', 1 ) + $this->check_interval;
141
  $posts_total = $this->get_posts_total();
142
 
143
- SCC_Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
144
- SCC_Common_Util::log( '[' . __METHOD__ . '] posts_per_check: ' . $this->posts_per_check );
145
- SCC_Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
146
- SCC_Common_Util::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
147
 
148
  $option_key = $this->get_cache_key( $this->offset_suffix );
149
 
150
- if ( false === ( $posts_offset = get_option( $option_key ) ) ) {
 
 
151
  $posts_offset = 0;
152
  }
153
 
154
- SCC_Common_Util::log( '[' . __METHOD__ . '] posts_offset: ' . $posts_offset );
155
 
156
  wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( (int) $posts_offset ) );
157
 
@@ -167,36 +232,64 @@ class SCC_Share_Base_Cache_Engine extends SCC_Share_Cache_Engine {
167
  /**
168
  * Get and cache data of each published post and page
169
  *
170
- * @since 0.1.0
 
171
  */
172
  public function execute_cache( $posts_offset ) {
173
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
 
175
- SCC_Common_Util::log( '[' . __METHOD__ . '] posts_offset: ' . $posts_offset );
176
- SCC_Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
177
- SCC_Common_Util::log( '[' . __METHOD__ . '] posts_per_check: ' . $this->posts_per_check );
 
 
178
 
179
  $cache_expiration = $this->get_cache_expiration();
180
 
181
- SCC_Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
182
 
183
  // Cache home url
184
- if ( $posts_offset == 0 ) {
185
- $post_ID = 'home';
186
 
187
- $transient_id = $this->get_cache_key( $post_ID );
188
  $url = home_url( '/' );
189
  $title = get_bloginfo( 'name' );
190
 
191
  $options = array(
192
  'cache_key' => $transient_id,
193
- 'post_id' => $post_ID,
194
  'target_url' => $url,
195
  'target_sns' => $this->target_sns,
196
  'target_title' => $title,
197
- 'publish_date' => NULL,
198
- 'cache_expiration' => $cache_expiration
199
- );
200
 
201
  // Primary cache
202
  $this->cache( $options );
@@ -212,8 +305,8 @@ class SCC_Share_Base_Cache_Engine extends SCC_Share_Cache_Engine {
212
  'posts_per_page' => $this->posts_per_check,
213
  'no_found_rows' => true,
214
  'update_post_term_cache' => false,
215
- 'update_post_meta_cache' => false
216
- );
217
 
218
  $posts_query = new WP_Query( $query_args );
219
 
@@ -221,24 +314,24 @@ class SCC_Share_Base_Cache_Engine extends SCC_Share_Cache_Engine {
221
  while ( $posts_query->have_posts() ) {
222
  $posts_query->the_post();
223
 
224
- $post_ID = get_the_ID();
225
 
226
- SCC_Common_Util::log( '[' . __METHOD__ . '] post_id: ' . $post_ID );
227
 
228
- $transient_id = $this->get_cache_key( $post_ID );
229
 
230
- $url = get_permalink( $post_ID );
231
- $title = get_the_title( $post_ID );
232
 
233
  $options = array(
234
  'cache_key' => $transient_id,
235
- 'post_id' => $post_ID,
236
  'target_url' => $url,
237
  'target_sns' => $this->target_sns,
238
  'target_title' => $title,
239
  'publish_date' => get_the_date( 'Y/m/d' ),
240
- 'cache_expiration' => $cache_expiration
241
- );
242
 
243
  // Primary cache
244
  $this->cache( $options );
@@ -253,36 +346,38 @@ class SCC_Share_Base_Cache_Engine extends SCC_Share_Cache_Engine {
253
  /**
254
  * Get and cache data for a given post
255
  *
256
- * @since 0.1.1
 
 
257
  */
258
- public function direct_cache( $post_ID, $second_sync = false ) {
259
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
260
 
261
  $cache_expiration = $this->get_cache_expiration();
262
 
263
- SCC_Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
264
 
265
- $transient_id = $this->get_cache_key( $post_ID );
266
 
267
- if ( $post_ID != 'home' ) {
268
- $url = get_permalink( $post_ID );
269
- $title = get_the_title( $post_ID );
270
- $publish_date = get_the_date( 'Y/m/d', $post_ID );
271
  } else {
272
  $url = home_url( '/' );
273
  $title = get_bloginfo( 'name' );
274
- $publish_date = NULL;
275
  }
276
 
277
  $options = array(
278
  'cache_key' => $transient_id,
279
- 'post_id' => $post_ID,
280
  'target_url' => $url,
281
  'target_sns' => $this->target_sns,
282
  'target_title' => $title,
283
  'publish_date' => $publish_date,
284
- 'cache_expiration' => $cache_expiration
285
- );
286
 
287
  // Primary cache
288
  $result = $this->cache( $options );
@@ -298,25 +393,25 @@ class SCC_Share_Base_Cache_Engine extends SCC_Share_Cache_Engine {
298
  /**
299
  * Get cache expiration based on current number of total post and page
300
  *
301
- * @since 0.1.1
302
  */
303
  protected function get_cache_expiration() {
304
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
305
 
306
  $posts_total = $this->get_posts_total();
307
 
308
- SCC_Common_Util::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
309
 
310
  return ceil( $posts_total / $this->posts_per_check ) * $this->check_interval * 3;
311
  }
312
 
313
  /**
314
- * Initialize meta key for ranking
315
  *
316
- * @since 0.3.0
317
  */
318
  public function initialize_cache() {
319
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
320
 
321
  $option_key = $this->get_cache_key( $this->offset_suffix );
322
 
@@ -324,12 +419,12 @@ class SCC_Share_Base_Cache_Engine extends SCC_Share_Cache_Engine {
324
  }
325
 
326
  /**
327
- * Clear meta key for ranking
328
  *
329
- * @since 0.3.0
330
  */
331
  public function clear_cache() {
332
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
333
 
334
  $transient_id = $this->get_cache_key( 'home' );
335
 
@@ -340,8 +435,8 @@ class SCC_Share_Base_Cache_Engine extends SCC_Share_Cache_Engine {
340
  'post_status' => 'publish',
341
  'nopaging' => true,
342
  'update_post_term_cache' => false,
343
- 'update_post_meta_cache' => false
344
- );
345
 
346
  $posts_query = new WP_Query( $query_args );
347
 
@@ -349,9 +444,9 @@ class SCC_Share_Base_Cache_Engine extends SCC_Share_Cache_Engine {
349
  while ( $posts_query->have_posts() ) {
350
  $posts_query->the_post();
351
 
352
- $post_ID = get_the_ID();
353
 
354
- $transient_id = $this->get_cache_key( $post_ID );
355
 
356
  delete_transient( $transient_id );
357
  }
@@ -363,14 +458,14 @@ class SCC_Share_Base_Cache_Engine extends SCC_Share_Cache_Engine {
363
  delete_option( $option_key );
364
  }
365
 
366
-
367
  /**
368
- * Clear meta key for ranking
369
  *
370
- * @since 0.7.0
 
371
  */
372
  public function clear_cache_by_post_id( $post_id ) {
373
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
374
 
375
  $transient_id = $this->get_cache_key( $post_id );
376
 
@@ -380,18 +475,18 @@ class SCC_Share_Base_Cache_Engine extends SCC_Share_Cache_Engine {
380
  /**
381
  * Get total count of current published post and page
382
  *
383
- * @since 0.1.0
384
  */
385
  private function get_posts_total() {
386
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
387
 
388
  $query_args = array(
389
  'post_type' => $this->post_types,
390
  'post_status' => 'publish',
391
  'nopaging' => true,
392
  'update_post_term_cache' => false,
393
- 'update_post_meta_cache' => false
394
- );
395
 
396
  $posts_query = new WP_Query( $query_args );
397
 
@@ -401,7 +496,8 @@ class SCC_Share_Base_Cache_Engine extends SCC_Share_Cache_Engine {
401
  /**
402
  * Get cache
403
  *
404
- * @since 0.9.3
 
405
  */
406
  public function get_cache( $options = array() ) {
407
  $post_id = $options['post_id'];
@@ -410,7 +506,9 @@ class SCC_Share_Base_Cache_Engine extends SCC_Share_Cache_Engine {
410
 
411
  $sns_counts = array();
412
 
413
- if ( false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
 
 
414
  return $sns_counts;
415
  } else {
416
  return $this->delegate_order( SCC_Order::ORDER_GET_SECOND_CACHE, $options );
1
  <?php
2
+ /**
3
  class-scc-share-base-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Share_Base_Cache_Engine
32
+ */
33
  class SCC_Share_Base_Cache_Engine extends SCC_Share_Cache_Engine {
34
 
35
  /**
59
 
60
  /**
61
  * Cache post types
62
+ *
63
+ * @var array
64
  */
65
  private $post_types = array( 'post', 'page' );
66
 
67
  /**
68
  * Interval cheking and caching target data
69
+ *
70
+ * @var integer
71
  */
72
  private $check_interval = 600;
73
 
74
  /**
75
  * Number of posts to check at a time
76
+ *
77
+ * @var integer
78
  */
79
  private $posts_per_check = 20;
80
 
81
  /**
82
  * Offset suffix
83
+ *
84
+ * @var string
85
  */
86
  private $offset_suffix = 'base_offset';
87
 
88
  /**
89
  * Initialization
90
  *
91
+ * @param array $options Option.
92
+ * @return void
93
  */
94
  public function initialize( $options = array() ) {
95
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
96
 
97
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
98
  $this->prime_cron = self::DEF_PRIME_CRON;
102
 
103
  $this->load_ratio = 0.5;
104
 
105
+ if ( isset( $options['delegate'] ) ) {
106
+ $this->delegate = $options['delegate'];
107
+ }
108
+
109
+ if ( isset( $options['crawler'] ) ) {
110
+ $this->crawler = $options['crawler'];
111
+ }
112
+
113
+ if ( isset( $options['target_sns'] ) ) {
114
+ $this->target_sns = $options['target_sns'];
115
+ }
116
+
117
+ if ( isset( $options['check_interval'] ) ) {
118
+ $this->check_interval = $options['check_interval'];
119
+ }
120
+
121
+ if ( isset( $options['posts_per_check'] ) ) {
122
+ $this->posts_per_check = $options['posts_per_check'];
123
+ }
124
+
125
+ if ( isset( $options['cache_prefix'] ) ) {
126
+ $this->cache_prefix = $options['cache_prefix'];
127
+ }
128
+
129
+ if ( isset( $options['prime_cron'] ) ) {
130
+ $this->prime_cron = $options['prime_cron'];
131
+ }
132
+
133
+ if ( isset( $options['execute_cron'] ) ) {
134
+ $this->execute_cron = $options['execute_cron'];
135
+ }
136
+
137
+ if ( isset( $options['event_schedule'] ) ) {
138
+ $this->event_schedule = $options['event_schedule'];
139
+ }
140
+
141
+ if ( isset( $options['event_description'] ) ) {
142
+ $this->event_description = $options['event_description'];
143
+ }
144
+
145
+ if ( isset( $options['post_types'] ) ) {
146
+ $this->post_types = $options['post_types'];
147
+ }
148
+
149
+ if ( isset( $options['scheme_migration_mode'] ) ) {
150
+ $this->scheme_migration_mode = $options['scheme_migration_mode'];
151
+ }
152
+
153
+ if ( isset( $options['scheme_migration_date'] ) ) {
154
+ $this->scheme_migration_date = $options['scheme_migration_date'];
155
+ }
156
+
157
+ if ( isset( $options['scheme_migration_exclude_keys'] ) ) {
158
+ $this->scheme_migration_exclude_keys = $options['scheme_migration_exclude_keys'];
159
+ }
160
+
161
+ if ( isset( $options['cache_retry'] ) ) {
162
+ $this->cache_retry = $options['cache_retry'];
163
+ }
164
+
165
+ if ( isset( $options['retry_limit'] ) ) {
166
+ $this->retry_limit = $options['retry_limit'];
167
+ }
168
+
169
+ if ( isset( $options['fault_tolerance'] ) ) {
170
+ $this->fault_tolerance = $options['fault_tolerance'];
171
+ }
172
 
173
  add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
174
  add_action( $this->prime_cron, array( $this, 'prime_cache' ) );
178
  /**
179
  * Register event schedule for this engine
180
  *
181
+ * @param array $schedules Schedule.
182
+ * @return array
183
  */
184
  public function schedule_check_interval( $schedules ) {
185
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
186
 
187
+ $schedules[ $this->event_schedule ] = array(
188
  'interval' => $this->check_interval,
189
+ 'display' => $this->event_description,
190
  );
191
 
192
  return $schedules;
195
  /**
196
  * Schedule data retrieval and cache processing
197
  *
198
+ * @return void
199
  */
200
  public function prime_cache() {
201
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
202
 
203
  $next_exec_time = (int) current_time( 'timestamp', 1 ) + $this->check_interval;
204
  $posts_total = $this->get_posts_total();
205
 
206
+ SCC_Logger::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
207
+ SCC_Logger::log( '[' . __METHOD__ . '] posts_per_check: ' . $this->posts_per_check );
208
+ SCC_Logger::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
209
+ SCC_Logger::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
210
 
211
  $option_key = $this->get_cache_key( $this->offset_suffix );
212
 
213
+ $posts_offset = get_option( $option_key );
214
+
215
+ if ( false === $posts_offset ) {
216
  $posts_offset = 0;
217
  }
218
 
219
+ SCC_Logger::log( '[' . __METHOD__ . '] posts_offset: ' . $posts_offset );
220
 
221
  wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( (int) $posts_offset ) );
222
 
232
  /**
233
  * Get and cache data of each published post and page
234
  *
235
+ * @param integer $posts_offset Post offset.
236
+ * @return void
237
  */
238
  public function execute_cache( $posts_offset ) {
239
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
240
+
241
+ SCC_Logger::log( '[' . __METHOD__ . '] posts_offset: ' . $posts_offset );
242
+ SCC_Logger::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
243
+ SCC_Logger::log( '[' . __METHOD__ . '] posts_per_check: ' . $this->posts_per_check );
244
+
245
+ $options = array();
246
+
247
+ /*
248
+ if ( $this->scheme_migration_mode ) {
249
+ $options['expected_call_count'] = $this->posts_per_check * 2;
250
+ } else {
251
+ $options['expected_call_count'] = $this->posts_per_check;
252
+ }
253
+
254
+ $need_throttle = $this->delegate_order( SCC_Order::ORDER_CHECK_APP_STATUS, $options );
255
+
256
+ SCC_Logger::log( '[' . __METHOD__ . '] need throttle: ' . $need_throttle );
257
+
258
+ if ( $need_throttle ) {
259
+
260
+ // SCC_WP_Cron::clear_scheduled_hook( $this->execute_cron );
261
+
262
+ $option_key = $this->get_cache_key( $this->offset_suffix );
263
+
264
+ update_option( $option_key, $posts_offset );
265
 
266
+ SCC_Logger::log( '[' . __METHOD__ . '] Count retrieval was throttled to handle API rate limiting.' );
267
+
268
+ return;
269
+ }
270
+ */
271
 
272
  $cache_expiration = $this->get_cache_expiration();
273
 
274
+ SCC_Logger::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
275
 
276
  // Cache home url
277
+ if ( 0 === $posts_offset ) {
278
+ $post_id = 'home';
279
 
280
+ $transient_id = $this->get_cache_key( $post_id );
281
  $url = home_url( '/' );
282
  $title = get_bloginfo( 'name' );
283
 
284
  $options = array(
285
  'cache_key' => $transient_id,
286
+ 'post_id' => $post_id,
287
  'target_url' => $url,
288
  'target_sns' => $this->target_sns,
289
  'target_title' => $title,
290
+ 'publish_date' => null,
291
+ 'cache_expiration' => $cache_expiration,
292
+ );
293
 
294
  // Primary cache
295
  $this->cache( $options );
305
  'posts_per_page' => $this->posts_per_check,
306
  'no_found_rows' => true,
307
  'update_post_term_cache' => false,
308
+ 'update_post_meta_cache' => false,
309
+ );
310
 
311
  $posts_query = new WP_Query( $query_args );
312
 
314
  while ( $posts_query->have_posts() ) {
315
  $posts_query->the_post();
316
 
317
+ $post_id = get_the_ID();
318
 
319
+ SCC_Logger::log( '[' . __METHOD__ . '] post_id: ' . $post_id );
320
 
321
+ $transient_id = $this->get_cache_key( $post_id );
322
 
323
+ $url = get_permalink( $post_id );
324
+ $title = get_the_title( $post_id );
325
 
326
  $options = array(
327
  'cache_key' => $transient_id,
328
+ 'post_id' => $post_id,
329
  'target_url' => $url,
330
  'target_sns' => $this->target_sns,
331
  'target_title' => $title,
332
  'publish_date' => get_the_date( 'Y/m/d' ),
333
+ 'cache_expiration' => $cache_expiration,
334
+ );
335
 
336
  // Primary cache
337
  $this->cache( $options );
346
  /**
347
  * Get and cache data for a given post
348
  *
349
+ * @param integer $post_id Post ID.
350
+ * @param boolean $second_sync Second sync flag.
351
+ * @return array
352
  */
353
+ public function direct_cache( $post_id, $second_sync = false ) {
354
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
355
 
356
  $cache_expiration = $this->get_cache_expiration();
357
 
358
+ SCC_Logger::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
359
 
360
+ $transient_id = $this->get_cache_key( $post_id );
361
 
362
+ if ( 'home' !== $post_id ) {
363
+ $url = get_permalink( $post_id );
364
+ $title = get_the_title( $post_id );
365
+ $publish_date = get_the_date( 'Y/m/d', $post_id );
366
  } else {
367
  $url = home_url( '/' );
368
  $title = get_bloginfo( 'name' );
369
+ $publish_date = null;
370
  }
371
 
372
  $options = array(
373
  'cache_key' => $transient_id,
374
+ 'post_id' => $post_id,
375
  'target_url' => $url,
376
  'target_sns' => $this->target_sns,
377
  'target_title' => $title,
378
  'publish_date' => $publish_date,
379
+ 'cache_expiration' => $cache_expiration,
380
+ );
381
 
382
  // Primary cache
383
  $result = $this->cache( $options );
393
  /**
394
  * Get cache expiration based on current number of total post and page
395
  *
396
+ * @return integer
397
  */
398
  protected function get_cache_expiration() {
399
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
400
 
401
  $posts_total = $this->get_posts_total();
402
 
403
+ SCC_Logger::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
404
 
405
  return ceil( $posts_total / $this->posts_per_check ) * $this->check_interval * 3;
406
  }
407
 
408
  /**
409
+ * Initialize cache
410
  *
411
+ * @return void
412
  */
413
  public function initialize_cache() {
414
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
415
 
416
  $option_key = $this->get_cache_key( $this->offset_suffix );
417
 
419
  }
420
 
421
  /**
422
+ * Clear cache
423
  *
424
+ * @return void
425
  */
426
  public function clear_cache() {
427
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
428
 
429
  $transient_id = $this->get_cache_key( 'home' );
430
 
435
  'post_status' => 'publish',
436
  'nopaging' => true,
437
  'update_post_term_cache' => false,
438
+ 'update_post_meta_cache' => false,
439
+ );
440
 
441
  $posts_query = new WP_Query( $query_args );
442
 
444
  while ( $posts_query->have_posts() ) {
445
  $posts_query->the_post();
446
 
447
+ $post_id = get_the_ID();
448
 
449
+ $transient_id = $this->get_cache_key( $post_id );
450
 
451
  delete_transient( $transient_id );
452
  }
458
  delete_option( $option_key );
459
  }
460
 
 
461
  /**
462
+ * Clear cache
463
  *
464
+ * @param integer $post_id Post ID.
465
+ * @return void
466
  */
467
  public function clear_cache_by_post_id( $post_id ) {
468
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
469
 
470
  $transient_id = $this->get_cache_key( $post_id );
471
 
475
  /**
476
  * Get total count of current published post and page
477
  *
478
+ * @return integer
479
  */
480
  private function get_posts_total() {
481
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
482
 
483
  $query_args = array(
484
  'post_type' => $this->post_types,
485
  'post_status' => 'publish',
486
  'nopaging' => true,
487
  'update_post_term_cache' => false,
488
+ 'update_post_meta_cache' => false,
489
+ );
490
 
491
  $posts_query = new WP_Query( $query_args );
492
 
496
  /**
497
  * Get cache
498
  *
499
+ * @param array $options Option.
500
+ * @return array
501
  */
502
  public function get_cache( $options = array() ) {
503
  $post_id = $options['post_id'];
506
 
507
  $sns_counts = array();
508
 
509
+ $sns_counts = get_transient( $transient_id );
510
+
511
+ if ( false !== $sns_counts ) {
512
  return $sns_counts;
513
  } else {
514
  return $this->delegate_order( SCC_Order::ORDER_GET_SECOND_CACHE, $options );
includes/class-scc-share-cache-engine.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-share-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,45 +27,61 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  abstract class SCC_Share_Cache_Engine extends SCC_Cache_Engine {
31
 
32
  /**
33
  * Crawler instance
 
 
34
  */
35
- protected $crawler = NULL;
36
 
37
  /**
38
  * Cache target
 
 
39
  */
40
  protected $target_sns = array();
41
 
42
  /**
43
- * migration mode from http to https
 
 
44
  */
45
  protected $scheme_migration_mode = false;
46
 
47
  /**
48
- * migration date from http to https
 
 
49
  */
50
- protected $scheme_migration_date = NULL;
51
 
52
  /**
53
- * excluded keys in scheme migration
 
 
54
  */
55
  protected $scheme_migration_exclude_keys = array();
56
 
57
  /**
58
- * load ratio for throttle
 
 
59
  */
60
  protected $load_ratio = 0.5;
61
 
62
- /**
63
  * Get and cache data for a given post
64
  *
65
- * @since 0.1.1
 
66
  */
67
  public function cache( $options = array() ) {
68
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
69
 
70
  $cache_key = $options['cache_key'];
71
  $target_url = $options['target_url'];
@@ -74,95 +90,102 @@ abstract class SCC_Share_Cache_Engine extends SCC_Cache_Engine {
74
  $publish_date = $options['publish_date'];
75
  $target_title = $options['target_title'];
76
 
77
- SCC_Common_Util::log( '[' . __METHOD__ . '] current memory usage: ' . round( memory_get_usage( true )/1024/1024, 2 ) . ' MB' );
78
- SCC_Common_Util::log( '[' . __METHOD__ . '] target url: ' . $target_url );
79
 
80
  $target_option = array(
81
- 'target_url' => $target_url,
82
- 'target_title' => $target_title
83
  );
84
 
85
- $data = $this->get_data( $target_sns, $target_option );
 
 
86
 
87
- SCC_Common_Util::log( $data );
88
- SCC_Common_Util::log( '[' . __METHOD__ . '] scheme migration date: ' . $this->scheme_migration_date );
89
- SCC_Common_Util::log( '[' . __METHOD__ . '] publish date: ' . $publish_date );
90
 
91
- if ( $this->scheme_migration_mode && SCC_Common_Util::is_secure_url( $target_url ) ) {
92
  if ( ! isset( $this->scheme_migration_date ) ) {
93
- $target_normal_url = SCC_Common_Util::get_normal_url( $target_url );
94
  $target_sns_migrated = $target_sns;
95
 
96
  foreach ( $this->scheme_migration_exclude_keys as $sns ) {
97
- unset( $target_sns_migrated[$sns] );
98
  }
99
 
100
- SCC_Common_Util::log( '[' . __METHOD__ . '] target url: ' . $target_normal_url );
101
 
102
  $target_option = array(
103
- 'target_url' => $target_normal_url,
104
- 'target_title' => $target_title
105
  );
106
 
107
- $migrated_data = $this->get_data( $target_sns_migrated, $target_option );
 
 
108
 
109
- SCC_Common_Util::log( $migrated_data );
110
 
111
  foreach ( $target_sns_migrated as $sns => $active ) {
112
- if ( $active && isset( $migrated_data[$sns] ) && is_numeric( $migrated_data[$sns] ) && $migrated_data[$sns] > 0 ){
113
- $data[$sns] = $data[$sns] + $migrated_data[$sns];
114
  }
115
  }
116
-
117
  } else {
118
  if ( isset( $publish_date ) ) {
119
  if ( strtotime( $publish_date ) <= strtotime( $this->scheme_migration_date ) ) {
120
- $target_normal_url = SCC_Common_Util::get_normal_url( $target_url );
121
  $target_sns_migrated = $target_sns;
122
 
123
  foreach ( $this->scheme_migration_exclude_keys as $sns ) {
124
- unset( $target_sns_migrated[$sns] );
125
  }
126
 
127
- SCC_Common_Util::log( '[' . __METHOD__ . '] target url: ' . $target_normal_url );
128
 
129
  $target_option = array(
130
- 'target_url' => $target_normal_url,
131
- 'target_title' => $target_title
132
  );
133
 
134
- $migrated_data = $this->get_data( $target_sns_migrated, $target_option );
 
 
135
 
136
- SCC_Common_Util::log( $migrated_data );
137
 
138
  foreach ( $target_sns_migrated as $sns => $active ) {
139
- if ( $active && isset( $migrated_data[$sns] ) && is_numeric( $migrated_data[$sns] ) && $migrated_data[$sns] > 0 ){
140
- $data[$sns] = $data[$sns] + $migrated_data[$sns];
141
  }
142
  }
143
  }
144
  } else {
145
- $target_normal_url = SCC_Common_Util::get_normal_url( $target_url );
146
  $target_sns_migrated = $target_sns;
147
 
148
  foreach ( $this->scheme_migration_exclude_keys as $sns ) {
149
- unset( $target_sns_migrated[$sns] );
150
  }
151
 
152
- SCC_Common_Util::log( '[' . __METHOD__ . '] target url: ' . $target_url );
153
 
154
  $target_option = array(
155
- 'target_url' => $target_url,
156
- 'target_title' => $target_title
157
  );
158
 
159
- $migrated_data = $this->get_data( $target_sns_migrated, $target_option );
 
 
160
 
161
- SCC_Common_Util::log( $migrated_data );
162
 
163
  foreach ( $target_sns_migrated as $sns => $active ) {
164
- if ( $active && isset( $migrated_data[$sns] ) && is_numeric( $migrated_data[$sns] ) && $migrated_data[$sns] > 0 ){
165
- $data[$sns] = $data[$sns] + $migrated_data[$sns];
166
  }
167
  }
168
  }
@@ -170,63 +193,73 @@ abstract class SCC_Share_Cache_Engine extends SCC_Cache_Engine {
170
 
171
  $target_sns_param = $target_sns;
172
 
173
- unset( $target_sns_param[SNS_Count_Cache::REF_CRAWL_DATE] );
174
- unset( $target_sns_param[SNS_Count_Cache::REF_SHARE_TOTAL] );
175
 
176
  $query_parameters = array(
177
- 'url' => $target_url
178
- );
179
 
180
  foreach ( $target_sns_param as $sns => $active ) {
181
  if ( $active ) {
182
- $this->crawler->set_crawl_strategy_query_parameters( $sns, $query_parameters );
183
  }
184
  }
185
- }
186
 
187
- if ( $this->fault_tolerance === SNS_Count_Cache::OPT_COMMON_FAULT_TOLERANCE_ON ) {
188
 
189
  $target_sns_tmp = $target_sns;
190
- unset( $target_sns_tmp[SNS_Count_Cache::REF_CRAWL_DATE] );
191
- unset( $target_sns_tmp[SNS_Count_Cache::REF_SHARE_TOTAL] );
192
 
193
  $target_sns_tolerance = array();
194
 
195
- foreach ( $target_sns_tmp as $sns => $active ){
196
  if ( $active ) {
197
- if ( ! isset( $data[$sns] ) || $data[$sns] === -1 ) {
198
- $target_sns_tolerance[$sns] = true;
199
  }
200
  }
201
  }
202
 
203
- if ( ! empty( $target_sns_tolerance) ) {
204
- $current_data = $this->get_cache( $options );
205
 
206
- foreach ( $target_sns_tolerance as $sns => $active ){
207
  if ( $active ) {
208
- if ( isset( $current_data[$sns] ) && $current_data[$sns] >= 0 ) {
209
- $data[$sns] = $current_data[$sns];
 
210
  }
211
  }
212
  }
213
 
214
  $total = 0;
215
 
216
- foreach ( $target_sns_tmp as $sns => $active ){
217
  if ( $active ) {
218
- if ( isset( $data[$sns] ) && $data[$sns] >= 0 ) {
219
- $total = $total + $data[$sns];
220
  }
221
  }
222
  }
223
 
224
- $data[SNS_Count_Cache::REF_SHARE_TOTAL] = $total;
225
  }
 
 
 
 
 
 
226
  }
227
 
228
- SCC_Common_Util::log( $data );
 
 
229
 
 
230
  if ( $data ) {
231
  $throttle = new SCC_Sleep_Throttle( $this->load_ratio );
232
 
@@ -240,18 +273,18 @@ abstract class SCC_Share_Cache_Engine extends SCC_Cache_Engine {
240
 
241
  while ( true ) {
242
 
243
- SCC_Common_Util::log( '[' . __METHOD__ . '] set_transient result (' . $cache_key . '): ' . $result );
244
 
245
  if ( $result ) {
246
  break;
247
  } else {
248
  if ( $retry_count < $this->retry_limit ) {
249
- SCC_Common_Util::log( '[' . __METHOD__ . '] sleep before set_transient retry (' . $cache_key . '): ' . $throttle->get_sleep_time() . ' sec.' );
250
 
251
  $throttle->sleep();
252
  ++$retry_count;
253
 
254
- SCC_Common_Util::log( '[' . __METHOD__ . '] count of set_transient retry (' . $cache_key . '): ' . $retry_count );
255
 
256
  $throttle->reset();
257
  $throttle->start();
@@ -260,47 +293,50 @@ abstract class SCC_Share_Cache_Engine extends SCC_Cache_Engine {
260
 
261
  $throttle->stop();
262
  } else {
263
- SCC_Common_Util::log( '[' . __METHOD__ . '] set_transient result (' . $cache_key . '): retry failed' );
264
  break;
265
  }
266
  }
267
  }
268
- }
 
269
 
270
- SCC_Common_Util::log( '[' . __METHOD__ . '] current memory usage: ' . round( memory_get_usage( true )/1024/1024, 2 ) . ' MB' );
271
- SCC_Common_Util::log( '[' . __METHOD__ . '] max memory usage: ' . round( memory_get_peak_usage( true )/1024/1024, 2 ) . ' MB' );
272
 
273
- return $data;
274
  }
275
 
276
  /**
277
  * Get data
278
  *
279
- * @since 0.9.0
 
 
280
  */
281
  private function get_data( $target_sns, $target_option ) {
282
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
283
 
284
  $target_sns_base = $target_sns;
285
 
286
  $target_url = $target_option['target_url'];
287
  $target_title = $target_option['target_title'];
288
 
289
- unset( $target_sns_base[SNS_Count_Cache::REF_CRAWL_DATE] );
290
- unset( $target_sns_base[SNS_Count_Cache::REF_SHARE_TOTAL] );
291
 
292
- $query_parameters = array(
293
  'url' => $target_url,
294
- 'title' => $target_title
295
  );
296
 
297
  foreach ( $target_sns_base as $sns => $active ) {
298
  if ( $active ) {
299
- $this->crawler->set_crawl_strategy_query_parameters( $sns, $query_parameters );
300
  }
301
  }
302
 
303
- return $this->crawler->get_data( $target_sns, NULL );
304
  }
305
 
306
  }
1
  <?php
2
+ /**
3
  class-scc-share-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Share_Cache_Engine
32
+ */
33
  abstract class SCC_Share_Cache_Engine extends SCC_Cache_Engine {
34
 
35
  /**
36
  * Crawler instance
37
+ *
38
+ * @var SCC_Share_Crawler
39
  */
40
+ protected $crawler = null;
41
 
42
  /**
43
  * Cache target
44
+ *
45
+ * @var array
46
  */
47
  protected $target_sns = array();
48
 
49
  /**
50
+ * Migration mode from http to https
51
+ *
52
+ * @var boolean
53
  */
54
  protected $scheme_migration_mode = false;
55
 
56
  /**
57
+ * Migration date from http to https
58
+ *
59
+ * @var string
60
  */
61
+ protected $scheme_migration_date = null;
62
 
63
  /**
64
+ * Excluded keys in scheme migration
65
+ *
66
+ * @var array
67
  */
68
  protected $scheme_migration_exclude_keys = array();
69
 
70
  /**
71
+ * Load ratio for throttle
72
+ *
73
+ * @var float
74
  */
75
  protected $load_ratio = 0.5;
76
 
77
+ /**
78
  * Get and cache data for a given post
79
  *
80
+ * @param array $options Option.
81
+ * @return array
82
  */
83
  public function cache( $options = array() ) {
84
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
85
 
86
  $cache_key = $options['cache_key'];
87
  $target_url = $options['target_url'];
90
  $publish_date = $options['publish_date'];
91
  $target_title = $options['target_title'];
92
 
93
+ SCC_Logger::log( '[' . __METHOD__ . '] current memory usage: ' . round( memory_get_usage( true ) / 1024 / 1024, 2 ) . ' MB' );
94
+ SCC_Logger::log( '[' . __METHOD__ . '] target url: ' . $target_url );
95
 
96
  $target_option = array(
97
+ 'target_url' => $target_url,
98
+ 'target_title' => $target_title,
99
  );
100
 
101
+ $response = $this->get_data( $target_sns, $target_option );
102
+ $sns_count = $response['count'];
103
+ $sns_info = $response['info'];
104
 
105
+ SCC_Logger::log( $sns_count );
106
+ SCC_Logger::log( '[' . __METHOD__ . '] scheme migration date: ' . $this->scheme_migration_date );
107
+ SCC_Logger::log( '[' . __METHOD__ . '] publish date: ' . $publish_date );
108
 
109
+ if ( $this->scheme_migration_mode && SCC_Format::is_https_url( $target_url ) ) {
110
  if ( ! isset( $this->scheme_migration_date ) ) {
111
+ $target_normal_url = SCC_Format::get_http_url( $target_url );
112
  $target_sns_migrated = $target_sns;
113
 
114
  foreach ( $this->scheme_migration_exclude_keys as $sns ) {
115
+ unset( $target_sns_migrated[ $sns ] );
116
  }
117
 
118
+ SCC_Logger::log( '[' . __METHOD__ . '] target url: ' . $target_normal_url );
119
 
120
  $target_option = array(
121
+ 'target_url' => $target_normal_url,
122
+ 'target_title' => $target_title,
123
  );
124
 
125
+ $migrated_response = $this->get_data( $target_sns_migrated, $target_option );
126
+
127
+ $migrated_sns_count = $migrated_response['count'];
128
 
129
+ SCC_Logger::log( $migrated_sns_count );
130
 
131
  foreach ( $target_sns_migrated as $sns => $active ) {
132
+ if ( $active && isset( $migrated_sns_count[ $sns ] ) && is_numeric( $migrated_sns_count[ $sns ] ) && 0 < $migrated_sns_count[ $sns ] ) {
133
+ $sns_count[ $sns ] = $sns_count[ $sns ] + $migrated_sns_count[ $sns ];
134
  }
135
  }
 
136
  } else {
137
  if ( isset( $publish_date ) ) {
138
  if ( strtotime( $publish_date ) <= strtotime( $this->scheme_migration_date ) ) {
139
+ $target_normal_url = SCC_Format::get_http_url( $target_url );
140
  $target_sns_migrated = $target_sns;
141
 
142
  foreach ( $this->scheme_migration_exclude_keys as $sns ) {
143
+ unset( $target_sns_migrated[ $sns ] );
144
  }
145
 
146
+ SCC_Logger::log( '[' . __METHOD__ . '] target url: ' . $target_normal_url );
147
 
148
  $target_option = array(
149
+ 'target_url' => $target_normal_url,
150
+ 'target_title' => $target_title,
151
  );
152
 
153
+ $migrated_response = $this->get_data( $target_sns_migrated, $target_option );
154
+
155
+ $migrated_sns_count = $migrated_response['count'];
156
 
157
+ SCC_Logger::log( $migrated_sns_count );
158
 
159
  foreach ( $target_sns_migrated as $sns => $active ) {
160
+ if ( $active && isset( $migrated_sns_count[ $sns ] ) && is_numeric( $migrated_sns_count[ $sns ] ) && 0 < $migrated_sns_count[ $sns ] ){
161
+ $sns_count[ $sns ] = $sns_count[ $sns ] + $migrated_sns_count[ $sns ];
162
  }
163
  }
164
  }
165
  } else {
166
+ $target_normal_url = SCC_Format::get_http_url( $target_url );
167
  $target_sns_migrated = $target_sns;
168
 
169
  foreach ( $this->scheme_migration_exclude_keys as $sns ) {
170
+ unset( $target_sns_migrated[ $sns ] );
171
  }
172
 
173
+ SCC_Logger::log( '[' . __METHOD__ . '] target url: ' . $target_url );
174
 
175
  $target_option = array(
176
+ 'target_url' => $target_url,
177
+ 'target_title' => $target_title,
178
  );
179
 
180
+ $migrated_response = $this->get_data( $target_sns_migrated, $target_option );
181
+
182
+ $migrated_sns_count = $migrated_response['count'];
183
 
184
+ SCC_Logger::log( $migrated_sns_count );
185
 
186
  foreach ( $target_sns_migrated as $sns => $active ) {
187
+ if ( $active && isset( $migrated_sns_count[ $sns ] ) && is_numeric( $migrated_sns_count[ $sns ] ) && 0 < $migrated_sns_count[ $sns ] ) {
188
+ $sns_count[ $sns ] = $sns_count[ $sns ] + $migrated_sns_count[ $sns ];
189
  }
190
  }
191
  }
193
 
194
  $target_sns_param = $target_sns;
195
 
196
+ unset( $target_sns_param[ SNS_Count_Cache::REF_CRAWL_DATE ] );
197
+ unset( $target_sns_param[ SNS_Count_Cache::REF_SHARE_TOTAL ] );
198
 
199
  $query_parameters = array(
200
+ 'url' => $target_url,
201
+ );
202
 
203
  foreach ( $target_sns_param as $sns => $active ) {
204
  if ( $active ) {
205
+ $this->crawler->set_crawl_strategy_parameters( $sns, $query_parameters );
206
  }
207
  }
208
+ } // End if().
209
 
210
+ if ( SNS_Count_Cache::OPT_COMMON_FAULT_TOLERANCE_ON === $this->fault_tolerance ) {
211
 
212
  $target_sns_tmp = $target_sns;
213
+ unset( $target_sns_tmp[ SNS_Count_Cache::REF_CRAWL_DATE ] );
214
+ unset( $target_sns_tmp[ SNS_Count_Cache::REF_SHARE_TOTAL ] );
215
 
216
  $target_sns_tolerance = array();
217
 
218
+ foreach ( $target_sns_tmp as $sns => $active ) {
219
  if ( $active ) {
220
+ if ( ! isset( $sns_count[ $sns ] ) || -1 === $sns_count[ $sns ] ) {
221
+ $target_sns_tolerance[ $sns ] = true;
222
  }
223
  }
224
  }
225
 
226
+ if ( ! empty( $target_sns_tolerance ) ) {
227
+ $current_sns_count = $this->get_cache( $options );
228
 
229
+ foreach ( $target_sns_tolerance as $sns => $active ) {
230
  if ( $active ) {
231
+ if ( isset( $current_sns_count[ $sns ] ) && 0 <= $current_sns_count[ $sns ] ) {
232
+ $sns_count[ $sns ] = $current_sns_count[ $sns ];
233
+ SCC_Logger::log( '[' . __METHOD__ . '] replaced by current count: ' . $sns );
234
  }
235
  }
236
  }
237
 
238
  $total = 0;
239
 
240
+ foreach ( $target_sns_tmp as $sns => $active ) {
241
  if ( $active ) {
242
+ if ( isset( $sns_count[ $sns ] ) && 0 <= $sns_count[ $sns ] ) {
243
+ $total = $total + $sns_count[ $sns ];
244
  }
245
  }
246
  }
247
 
248
+ $sns_count[ SNS_Count_Cache::REF_SHARE_TOTAL ] = $total;
249
  }
250
+ } // End if().
251
+
252
+ SCC_Logger::log( $sns_count );
253
+
254
+ if ( $sns_count ) {
255
+ $result = set_transient( $cache_key, $sns_count, $cache_expiration );
256
  }
257
 
258
+ if ( $sns_info ) {
259
+ update_option( SNS_Count_Cache::DB_SHARE_APP_STATUS, $sns_info );
260
+ }
261
 
262
+ /*
263
  if ( $data ) {
264
  $throttle = new SCC_Sleep_Throttle( $this->load_ratio );
265
 
273
 
274
  while ( true ) {
275
 
276
+ SCC_Logger::log( '[' . __METHOD__ . '] set_transient result (' . $cache_key . '): ' . $result );
277
 
278
  if ( $result ) {
279
  break;
280
  } else {
281
  if ( $retry_count < $this->retry_limit ) {
282
+ SCC_Logger::log( '[' . __METHOD__ . '] sleep before set_transient retry (' . $cache_key . '): ' . $throttle->get_sleep_time() . ' sec.' );
283
 
284
  $throttle->sleep();
285
  ++$retry_count;
286
 
287
+ SCC_Logger::log( '[' . __METHOD__ . '] count of set_transient retry (' . $cache_key . '): ' . $retry_count );
288
 
289
  $throttle->reset();
290
  $throttle->start();
293
 
294
  $throttle->stop();
295
  } else {
296
+ SCC_Logger::log( '[' . __METHOD__ . '] set_transient result (' . $cache_key . '): retry failed' );
297
  break;
298
  }
299
  }
300
  }
301
+ } // End if().
302
+ */
303
 
304
+ SCC_Logger::log( '[' . __METHOD__ . '] current memory usage: ' . round( memory_get_usage( true ) / 1024 / 1024, 2 ) . ' MB' );
305
+ SCC_Logger::log( '[' . __METHOD__ . '] max memory usage: ' . round( memory_get_peak_usage( true ) / 1024 / 1024, 2 ) . ' MB' );
306
 
307
+ return $sns_count;
308
  }
309
 
310
  /**
311
  * Get data
312
  *
313
+ * @param array $target_sns Target SNS.
314
+ * @param array $target_option Target option.
315
+ * @return array
316
  */
317
  private function get_data( $target_sns, $target_option ) {
318
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
319
 
320
  $target_sns_base = $target_sns;
321
 
322
  $target_url = $target_option['target_url'];
323
  $target_title = $target_option['target_title'];
324
 
325
+ unset( $target_sns_base[ SNS_Count_Cache::REF_CRAWL_DATE ] );
326
+ unset( $target_sns_base[ SNS_Count_Cache::REF_SHARE_TOTAL ] );
327
 
328
+ $parameters = array(
329
  'url' => $target_url,
330
+ 'title' => $target_title,
331
  );
332
 
333
  foreach ( $target_sns_base as $sns => $active ) {
334
  if ( $active ) {
335
+ $this->crawler->set_crawl_strategy_parameters( $sns, $parameters );
336
  }
337
  }
338
 
339
+ return $this->crawler->get_data( $target_sns, null );
340
  }
341
 
342
  }
includes/class-scc-share-crawl-strategy-factory.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-share-crawl-strategy-factory.php
4
 
5
  Description: This class is a data crawler whitch get share count using given API and cURL
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,45 +27,42 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  class SCC_Share_Crawl_Strategy_Factory {
31
 
32
  /**
33
  * Carete crawl strategy
34
  *
35
- * @since 0.9.0
 
36
  */
37
  public static function create_crawl_strategy( $sns ) {
38
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
39
 
40
  switch ( $sns ) {
41
  case SNS_Count_Cache::REF_SHARE_TWITTER:
42
- SCC_Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
43
- return SCC_Share_Twitter_Strategy::get_instance();
44
- break;
45
  case SNS_Count_Cache::REF_SHARE_FACEBOOK:
46
- SCC_Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
47
- return SCC_Share_Facebook_Strategy::get_instance();
48
- break;
49
  case SNS_Count_Cache::REF_SHARE_GPLUS:
50
- SCC_Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
51
- return SCC_Share_Google_Strategy::get_instance();
52
- break;
53
  case SNS_Count_Cache::REF_SHARE_POCKET:
54
- SCC_Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
55
- return SCC_Share_Pocket_Strategy::get_instance();
56
- break;
57
  case SNS_Count_Cache::REF_SHARE_HATEBU:
58
- SCC_Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
59
- return SCC_Share_Hatebu_Strategy::get_instance();
60
- break;
61
  case SNS_Count_Cache::REF_SHARE_PINTEREST:
62
- SCC_Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
63
- return SCC_Share_Pinterest_Strategy::get_instance();
64
- break;
65
  case SNS_Count_Cache::REF_SHARE_LINKEDIN:
66
- SCC_Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
67
- return SCC_Share_Linkedin_Strategy::get_instance();
68
- break;
69
  }
70
  }
71
 
1
  <?php
2
+ /**
3
  class-scc-share-crawl-strategy-factory.php
4
 
5
  Description: This class is a data crawler whitch get share count using given API and cURL
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Share_Crawl_Strategy_Factory
32
+ */
33
  class SCC_Share_Crawl_Strategy_Factory {
34
 
35
  /**
36
  * Carete crawl strategy
37
  *
38
+ * @param string $sns
39
+ * @return SCC_Crawl_Strategy
40
  */
41
  public static function create_crawl_strategy( $sns ) {
42
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
43
 
44
  switch ( $sns ) {
45
  case SNS_Count_Cache::REF_SHARE_TWITTER:
46
+ SCC_Logger::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
47
+ return SCC_Share_Twitter_Crawl_Strategy::get_instance();
 
48
  case SNS_Count_Cache::REF_SHARE_FACEBOOK:
49
+ SCC_Logger::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
50
+ return SCC_Share_Facebook_Crawl_Strategy::get_instance();
 
51
  case SNS_Count_Cache::REF_SHARE_GPLUS:
52
+ SCC_Logger::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
53
+ return SCC_Share_Google_Crawl_Strategy::get_instance();
 
54
  case SNS_Count_Cache::REF_SHARE_POCKET:
55
+ SCC_Logger::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
56
+ return SCC_Share_Pocket_Crawl_Strategy::get_instance();
 
57
  case SNS_Count_Cache::REF_SHARE_HATEBU:
58
+ SCC_Logger::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
59
+ return SCC_Share_Hatebu_Crawl_Strategy::get_instance();
 
60
  case SNS_Count_Cache::REF_SHARE_PINTEREST:
61
+ SCC_Logger::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
62
+ return SCC_Share_Pinterest_Crawl_Strategy::get_instance();
 
63
  case SNS_Count_Cache::REF_SHARE_LINKEDIN:
64
+ SCC_Logger::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
65
+ return SCC_Share_Linkedin_Crawl_Strategy::get_instance();
 
66
  }
67
  }
68
 
includes/class-scc-share-crawler.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-share-crawler.php
4
 
5
  Description: This class is a data crawler whitch get share count using given API and cURL
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,33 +27,49 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  class SCC_Share_Crawler extends SCC_Crawler {
31
 
32
  /**
33
  * Initialization
34
  *
35
- * @since 0.5.1
 
36
  */
37
  public function initialize( $options = array() ) {
38
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
39
 
40
  //$this->throttle = new Sleep_Throttle( 0.9 );
41
 
42
- if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
43
- if ( isset( $options['crawl_method'] ) ) $this->crawl_method = $options['crawl_method'];
44
- if ( isset( $options['timeout'] ) ) $this->timeout = $options['timeout'];
45
- if ( isset( $options['ssl_verification'] ) ) $this->ssl_verification = $options['ssl_verification'];
46
- if ( isset( $options['crawl_retry'] ) ) $this->crawl_retry = $options['crawl_retry'];
47
- if ( isset( $options['retry_limit'] ) ) $this->retry_limit = $options['retry_limit'];
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
  $target_sns = $this->target_sns;
50
 
51
- unset( $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] );
52
- unset( $target_sns[SNS_Count_Cache::REF_SHARE_TOTAL] );
53
 
54
  foreach ( $target_sns as $sns => $active ) {
55
  if ( $active ) {
56
- $this->crawl_strategies[$sns] = SCC_Share_Crawl_Strategy_Factory::create_crawl_strategy( $sns );
57
  }
58
  }
59
 
@@ -62,49 +78,58 @@ class SCC_Share_Crawler extends SCC_Crawler {
62
  /**
63
  * Check configuration
64
  *
65
- * @since 0.9.0
 
66
  */
67
  private function check_configurations( $target_sns ) {
68
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
69
 
70
- //$checked_target_sns = array();
71
 
72
- unset( $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] );
73
- unset( $target_sns[SNS_Count_Cache::REF_SHARE_TOTAL] );
74
 
75
- SCC_Common_Util::log( $target_sns );
76
 
77
  foreach ( $target_sns as $sns => $active ) {
78
  if ( $active ) {
79
- $target_sns[$sns] = $this->crawl_strategies[$sns]->check_configuration();
80
  }
81
  }
82
 
83
- $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] = true;
84
- $target_sns[SNS_Count_Cache::REF_SHARE_TOTAL] = true;
85
 
86
- return $target_sns;
87
 
88
  }
89
 
90
  /**
91
- * Implementation of abstract method. this method gets each share count
92
  *
93
- * @since 0.1.1
 
 
94
  */
95
  public function get_data( $target_sns, $options ) {
96
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
97
 
98
- SCC_Common_Util::log( $target_sns );
99
 
100
  $valid_target_sns = $this->check_configurations( $target_sns );
101
- SCC_Common_Util::log( $valid_target_sns );
 
 
 
 
 
 
102
 
103
- $query_urls = $this->build_query_urls( $valid_target_sns );
104
- SCC_Common_Util::log( $query_urls );
105
 
106
- $query_headers = $this->build_query_headers( $valid_target_sns );
107
- SCC_Common_Util::log( $query_headers );
108
 
109
  $data = array();
110
 
@@ -112,140 +137,210 @@ class SCC_Share_Crawler extends SCC_Crawler {
112
  $throttle->reset();
113
  $throttle->start();
114
 
115
- if ( $this->crawl_method === SNS_Count_Cache::OPT_COMMON_CRAWLER_METHOD_CURL ) {
116
- $data = SCC_Common_Util::multi_remote_get( $query_urls, $query_headers, $this->timeout, $this->ssl_verification, true );
117
  } else {
118
- $data = SCC_Common_Util::multi_remote_get( $query_urls, $query_headers, $this->timeout, $this->ssl_verification, false );
119
  }
120
 
121
  $throttle->stop();
122
- $retry_count = 0;
123
 
124
- while( true ) {
125
- $target_sns_retry = array();
126
- $tmp_count = $this->extract_count( $valid_target_sns, $data );
127
 
128
- foreach ( $valid_target_sns as $sns => $active ){
129
- if ( $active ) {
130
- if( $tmp_count[$sns] === -1 ) {
131
- $target_sns_retry[$sns] = true;
 
 
 
 
 
 
 
132
  }
133
  }
134
- }
135
 
136
- if ( empty( $target_sns_retry ) ) {
137
- break;
138
- } else {
139
- SCC_Common_Util::log( '[' . __METHOD__ . '] crawl failure' );
140
- SCC_Common_Util::log( $target_sns_retry );
 
 
 
 
 
141
 
142
- if ( $retry_count < $this->retry_limit ) {
143
- SCC_Common_Util::log( '[' . __METHOD__ . '] sleep before crawl retry: ' . $throttle->get_sleep_time() . ' sec.' );
144
 
145
- $throttle->sleep();
 
146
 
147
- ++$retry_count;
148
- SCC_Common_Util::log( '[' . __METHOD__ . '] count of crawl retry: ' . $retry_count );
 
 
149
 
150
- $query_urls_retry = $this->build_query_urls( $target_sns_retry );
151
- $query_headers_retry = $this->build_query_headers( $target_sns_retry );
152
 
153
- $data_retry = array();
 
154
 
155
- $throttle->reset();
156
- $throttle->start();
 
 
 
157
 
158
- if ( $this->crawl_method === SNS_Count_Cache::OPT_COMMON_CRAWLER_METHOD_CURL ) {
159
- $data_retry = SCC_Common_Util::multi_remote_get( $query_urls_retry, $query_headers_retry, $this->timeout, $this->ssl_verification, true );
160
  } else {
161
- $data_retry = SCC_Common_Util::multi_remote_get( $query_urls_retry, $query_headers_retry, $this->timeout, $this->ssl_verification, false );
 
162
  }
 
 
 
163
 
164
- $throttle->stop();
165
- $data = array_merge( $data, $data_retry );
166
- } else {
167
- SCC_Common_Util::log( '[' . __METHOD__ . '] crawl retry ended' );
168
- break;
169
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  }
171
  }
172
 
173
- return $this->extract_count( $target_sns, $data );
174
  }
175
 
176
  /**
177
- * build query
178
  *
179
- * @since 0.5.1
 
180
  */
181
- private function build_query_urls( $target_sns ) {
182
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
183
 
184
- $query_urls = array();
185
 
186
- unset( $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] );
187
- unset( $target_sns[SNS_Count_Cache::REF_SHARE_TOTAL] );
188
 
189
- SCC_Common_Util::log( $target_sns );
190
 
191
  foreach ( $target_sns as $sns => $active ) {
192
  if ( $active ) {
193
- $query_urls[$sns] = $this->crawl_strategies[$sns]->build_query_url();
194
  }
195
  }
196
 
197
- return $query_urls;
198
  }
199
 
200
  /**
201
- * build query
202
  *
203
- * @since 0.5.1
 
204
  */
205
- private function build_query_headers( $target_sns ) {
206
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
207
 
208
- $query_headers = array();
209
 
210
- unset( $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] );
211
- unset( $target_sns[SNS_Count_Cache::REF_SHARE_TOTAL] );
212
 
213
- SCC_Common_Util::log( $target_sns );
214
 
215
  foreach ( $target_sns as $sns => $active ) {
216
  if ( $active ) {
217
- $query_headers[$sns] = $this->crawl_strategies[$sns]->build_header();
218
  }
219
  }
220
 
221
- return $query_headers;
222
  }
223
 
224
  /**
225
- * extract count data from retrieved content
226
  *
227
- * @since 0.5.1
 
228
  */
229
- private function extract_count( $target_sns, $contents ) {
230
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
 
232
  $sns_counts = array();
233
 
234
  $extract_date = date_i18n( 'Y/m/d H:i:s' );
235
 
236
- SCC_Common_Util::log( $contents );
237
 
238
  foreach ( $target_sns as $sns => $active ) {
239
  if ( $active ) {
240
- if ( isset( $contents[$sns] ) ) {
241
- $sns_counts[$sns] = $this->crawl_strategies[$sns]->extract_count( $contents[$sns] );
242
  } else {
243
- $sns_counts[$sns] = (int) -1;
244
  }
245
  }
246
  }
247
 
248
- if ( isset( $target_sns[SNS_Count_Cache::REF_SHARE_TOTAL] ) && $target_sns[SNS_Count_Cache::REF_SHARE_TOTAL] ) {
249
  $total = 0;
250
 
251
  foreach ( $sns_counts as $sns => $count ) {
@@ -254,18 +349,77 @@ class SCC_Share_Crawler extends SCC_Crawler {
254
  }
255
  }
256
 
257
- $sns_counts[SNS_Count_Cache::REF_SHARE_TOTAL] = (int) $total;
258
  }
259
 
260
- if ( isset( $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] ) && $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] ) {
261
- $sns_counts[SNS_Count_Cache::REF_CRAWL_DATE] = $extract_date;
262
  } else {
263
- $sns_counts[SNS_Count_Cache::REF_CRAWL_DATE] = '';
264
  }
265
 
266
  return $sns_counts;
267
  }
268
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
269
  }
270
 
271
  ?>
1
  <?php
2
+ /**
3
  class-scc-share-crawler.php
4
 
5
  Description: This class is a data crawler whitch get share count using given API and cURL
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Share_Crawler
32
+ */
33
  class SCC_Share_Crawler extends SCC_Crawler {
34
 
35
  /**
36
  * Initialization
37
  *
38
+ * @param array $options Option.
39
+ * @return void
40
  */
41
  public function initialize( $options = array() ) {
42
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
43
 
44
  //$this->throttle = new Sleep_Throttle( 0.9 );
45
 
46
+ if ( isset( $options['target_sns'] ) ) {
47
+ $this->target_sns = $options['target_sns'];
48
+ }
49
+ if ( isset( $options['crawl_method'] ) ) {
50
+ $this->crawl_method = $options['crawl_method'];
51
+ }
52
+ if ( isset( $options['timeout'] ) ) {
53
+ $this->timeout = $options['timeout'];
54
+ }
55
+ if ( isset( $options['ssl_verification'] ) ) {
56
+ $this->ssl_verification = $options['ssl_verification'];
57
+ }
58
+ if ( isset( $options['crawl_retry'] ) ) {
59
+ $this->crawl_retry = $options['crawl_retry'];
60
+ }
61
+ if ( isset( $options['retry_limit'] ) ) {
62
+ $this->retry_limit = $options['retry_limit'];
63
+ }
64
 
65
  $target_sns = $this->target_sns;
66
 
67
+ unset( $target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] );
68
+ unset( $target_sns[ SNS_Count_Cache::REF_SHARE_TOTAL ] );
69
 
70
  foreach ( $target_sns as $sns => $active ) {
71
  if ( $active ) {
72
+ $this->crawl_strategies[ $sns ] = SCC_Share_Crawl_Strategy_Factory::create_crawl_strategy( $sns );
73
  }
74
  }
75
 
78
  /**
79
  * Check configuration
80
  *
81
+ * @param array $target_sns Target SNS.
82
+ * @return array
83
  */
84
  private function check_configurations( $target_sns ) {
85
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
86
 
87
+ $checked_target_sns = array();
88
 
89
+ unset( $target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] );
90
+ unset( $target_sns[ SNS_Count_Cache::REF_SHARE_TOTAL ] );
91
 
92
+ SCC_Logger::log( $target_sns );
93
 
94
  foreach ( $target_sns as $sns => $active ) {
95
  if ( $active ) {
96
+ $checked_target_sns[ $sns ] = $this->crawl_strategies[ $sns ]->check_configuration();
97
  }
98
  }
99
 
100
+ $checked_target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] = true;
101
+ $checked_target_sns[ SNS_Count_Cache::REF_SHARE_TOTAL ] = true;
102
 
103
+ return $checked_target_sns;
104
 
105
  }
106
 
107
  /**
108
+ * Get data
109
  *
110
+ * @param array $target_sns Target SNS.
111
+ * @param array $options Option.
112
+ * @return array
113
  */
114
  public function get_data( $target_sns, $options ) {
115
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
116
 
117
+ SCC_Logger::log( $target_sns );
118
 
119
  $valid_target_sns = $this->check_configurations( $target_sns );
120
+ SCC_Logger::log( $valid_target_sns );
121
+
122
+ $request_http_methods = $this->get_http_methods( $valid_target_sns );
123
+ SCC_Logger::log( $request_http_methods );
124
+
125
+ $request_urls = $this->build_request_urls( $valid_target_sns );
126
+ SCC_Logger::log( $request_urls );
127
 
128
+ $request_headers = $this->build_request_headers( $valid_target_sns );
129
+ SCC_Logger::log( $request_headers );
130
 
131
+ $request_bodies = $this->build_request_bodies( $valid_target_sns );
132
+ SCC_Logger::log( $request_bodies );
133
 
134
  $data = array();
135
 
137
  $throttle->reset();
138
  $throttle->start();
139
 
140
+ if ( SNS_Count_Cache::OPT_COMMON_CRAWLER_METHOD_CURL === $this->crawl_method ) {
141
+ $data = SCC_HTTP::multi_remote_request( $request_urls, $request_http_methods, $request_headers, $request_bodies, $this->timeout, $this->ssl_verification, true );
142
  } else {
143
+ $data = SCC_HTTP::multi_remote_request( $request_urls, $request_http_methods, $request_headers, $request_bodies, $this->timeout, $this->ssl_verification, false );
144
  }
145
 
146
  $throttle->stop();
 
147
 
148
+ if ( 0 < $this->retry_limit ) {
 
 
149
 
150
+ $retry_count = 0;
151
+
152
+ while ( true ) {
153
+ $target_sns_retry = array();
154
+ $tmp_count = $this->extract_response_bodies( $valid_target_sns, $data );
155
+
156
+ foreach ( $valid_target_sns as $sns => $active ) {
157
+ if ( $active ) {
158
+ if ( -1 === $tmp_count[ $sns ] ) {
159
+ $target_sns_retry[ $sns ] = true;
160
+ }
161
  }
162
  }
 
163
 
164
+ $target_sns_retry = $this->check_rate_limiting( $target_sns_retry, $data );
165
+
166
+ if ( empty( $target_sns_retry ) ) {
167
+ break;
168
+ } else {
169
+ SCC_Logger::log( '[' . __METHOD__ . '] crawl failure' );
170
+ SCC_Logger::log( $target_sns_retry );
171
+
172
+ if ( $retry_count < $this->retry_limit ) {
173
+ SCC_Logger::log( '[' . __METHOD__ . '] sleep before crawl retry: ' . $throttle->get_sleep_time() . ' sec.' );
174
 
175
+ $throttle->sleep();
 
176
 
177
+ ++$retry_count;
178
+ SCC_Logger::log( '[' . __METHOD__ . '] count of crawl retry: ' . $retry_count );
179
 
180
+ $request_http_methods_retry = $this->get_http_methods( $target_sns_retry );
181
+ $request_urls_retry = $this->build_request_urls( $target_sns_retry );
182
+ $request_headers_retry = $this->build_request_headers( $target_sns_retry );
183
+ $request_bodies_retry = $this->build_request_bodies( $target_sns_retry );
184
 
185
+ $data_retry = array();
 
186
 
187
+ $throttle->reset();
188
+ $throttle->start();
189
 
190
+ if ( SNS_Count_Cache::OPT_COMMON_CRAWLER_METHOD_CURL === $this->crawl_method ) {
191
+ $data_retry = SCC_HTTP::multi_remote_request( $request_urls_retry, $request_http_methods_retry, $request_headers_retry, $request_bodies_retry, $this->timeout, $this->ssl_verification, true );
192
+ } else {
193
+ $data_retry = SCC_HTTP::multi_remote_request( $request_urls_retry, $request_http_methods_retry, $request_headers_retry, $request_bodies_retry, $this->timeout, $this->ssl_verification, true );
194
+ }
195
 
196
+ $throttle->stop();
197
+ $data = array_merge( (array) $data, (array) $data_retry );
198
  } else {
199
+ SCC_Logger::log( '[' . __METHOD__ . '] crawl retry ended' );
200
+ break;
201
  }
202
+ } // End if().
203
+ } // End while().
204
+ } // End if().
205
 
206
+ $response = array();
207
+
208
+ $response['count'] = $this->extract_response_bodies( $target_sns, $data );
209
+ $response['info'] = $this->extract_response_headers( $target_sns, $data );
210
+
211
+ SCC_Logger::log( $response['count'] );
212
+ SCC_Logger::log( $response['info'] );
213
+
214
+ return $response;
215
+ }
216
+
217
+ /**
218
+ * Get HTTP method
219
+ *
220
+ * @param array $target_sns Target SNS.
221
+ * @return array
222
+ */
223
+ private function get_http_methods( $target_sns ) {
224
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
225
+
226
+ $http_methods = array();
227
+
228
+ unset( $target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] );
229
+ unset( $target_sns[ SNS_Count_Cache::REF_SHARE_TOTAL ] );
230
+
231
+ SCC_Logger::log( $target_sns );
232
+
233
+ foreach ( $target_sns as $sns => $active ) {
234
+ if ( $active ) {
235
+ $http_methods[ $sns ] = $this->crawl_strategies[ $sns ]->get_http_method();
236
  }
237
  }
238
 
239
+ return $http_methods;
240
  }
241
 
242
  /**
243
+ * Build request URLs
244
  *
245
+ * @param array $target_sns Target SNS.
246
+ * @return array
247
  */
248
+ private function build_request_urls( $target_sns ) {
249
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
250
 
251
+ $request_urls = array();
252
 
253
+ unset( $target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] );
254
+ unset( $target_sns[ SNS_Count_Cache::REF_SHARE_TOTAL ] );
255
 
256
+ SCC_Logger::log( $target_sns );
257
 
258
  foreach ( $target_sns as $sns => $active ) {
259
  if ( $active ) {
260
+ $request_urls[ $sns ] = $this->crawl_strategies[ $sns ]->build_request_url();
261
  }
262
  }
263
 
264
+ return $request_urls;
265
  }
266
 
267
  /**
268
+ * Build request bodies
269
  *
270
+ * @param array $target_sns Target SNS.
271
+ * @return array
272
  */
273
+ private function build_request_bodies( $target_sns ) {
274
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
275
 
276
+ $request_contents = array();
277
 
278
+ unset( $target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] );
279
+ unset( $target_sns[ SNS_Count_Cache::REF_SHARE_TOTAL ] );
280
 
281
+ SCC_Logger::log( $target_sns );
282
 
283
  foreach ( $target_sns as $sns => $active ) {
284
  if ( $active ) {
285
+ $request_contents[ $sns ] = $this->crawl_strategies[ $sns ]->build_request_body();
286
  }
287
  }
288
 
289
+ return $request_contents;
290
  }
291
 
292
  /**
293
+ * Build request headers
294
  *
295
+ * @param array $target_sns Target SNS.
296
+ * @return array
297
  */
298
+ private function build_request_headers( $target_sns ) {
299
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
300
+
301
+ $request_headers = array();
302
+
303
+ unset( $target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] );
304
+ unset( $target_sns[ SNS_Count_Cache::REF_SHARE_TOTAL ] );
305
+
306
+ SCC_Logger::log( $target_sns );
307
+
308
+ foreach ( $target_sns as $sns => $active ) {
309
+ if ( $active ) {
310
+ $request_headers[ $sns ] = $this->crawl_strategies[ $sns ]->build_request_header();
311
+ }
312
+ }
313
+
314
+ return $request_headers;
315
+ }
316
+
317
+ /**
318
+ * Extract response bodies
319
+ *
320
+ * @param array $target_sns Target SNS.
321
+ * @param array $contents Contents.
322
+ * @return void
323
+ */
324
+ private function extract_response_bodies( $target_sns, $contents ) {
325
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
326
 
327
  $sns_counts = array();
328
 
329
  $extract_date = date_i18n( 'Y/m/d H:i:s' );
330
 
331
+ SCC_Logger::log( $contents );
332
 
333
  foreach ( $target_sns as $sns => $active ) {
334
  if ( $active ) {
335
+ if ( isset( $contents[ $sns ] ) ) {
336
+ $sns_counts[ $sns ] = $this->crawl_strategies[ $sns ]->extract_response_body( $contents[ $sns ] );
337
  } else {
338
+ $sns_counts[ $sns ] = (int) -1;
339
  }
340
  }
341
  }
342
 
343
+ if ( ! empty( $target_sns[ SNS_Count_Cache::REF_SHARE_TOTAL ] ) ) {
344
  $total = 0;
345
 
346
  foreach ( $sns_counts as $sns => $count ) {
349
  }
350
  }
351
 
352
+ $sns_counts[ SNS_Count_Cache::REF_SHARE_TOTAL ] = (int) $total;
353
  }
354
 
355
+ if ( ! empty( $target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] ) ) {
356
+ $sns_counts[ SNS_Count_Cache::REF_CRAWL_DATE ] = $extract_date;
357
  } else {
358
+ $sns_counts[ SNS_Count_Cache::REF_CRAWL_DATE ] = '';
359
  }
360
 
361
  return $sns_counts;
362
  }
363
 
364
+ /**
365
+ * Extract response headers
366
+ *
367
+ * @param array $target_sns Target SNS.
368
+ * @param array $contents Contents.
369
+ * @return array
370
+ */
371
+ private function extract_response_headers( $target_sns, $contents ) {
372
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
373
+
374
+ $sns_headers = array();
375
+
376
+ unset( $target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] );
377
+ unset( $target_sns[ SNS_Count_Cache::REF_SHARE_TOTAL ] );
378
+
379
+ SCC_Logger::log( $contents );
380
+
381
+ foreach ( $target_sns as $sns => $active ) {
382
+ if ( $active ) {
383
+ if ( isset( $contents[ $sns ] ) ) {
384
+ $sns_headers[ $sns ] = $this->crawl_strategies[ $sns ]->extract_response_header( $contents[ $sns ] );
385
+ } else {
386
+ $sns_headers[ $sns ] = null;
387
+ }
388
+ }
389
+ }
390
+
391
+ return $sns_headers;
392
+ }
393
+
394
+ /**
395
+ * Check rate limiting
396
+ *
397
+ * @param array $target_sns Target SNS.
398
+ * @param array $contents Contents.
399
+ * @return array
400
+ */
401
+ private function check_rate_limiting( $target_sns, $contents ) {
402
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
403
+
404
+ unset( $target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] );
405
+ unset( $target_sns[ SNS_Count_Cache::REF_SHARE_TOTAL ] );
406
+
407
+ SCC_Logger::log( $target_sns );
408
+
409
+ $checked_target_sns = array();
410
+
411
+ foreach ( $target_sns as $sns => $active ) {
412
+ if ( $active ) {
413
+ $checked_target_sns[ $sns ] = $this->crawl_strategies[ $sns ]->check_rate_limiting( $contents[ $sns ] );
414
+ }
415
+ }
416
+
417
+ // $target_sns[ SNS_Count_Cache::REF_CRAWL_DATE ] = true;
418
+ // $target_sns[ SNS_Count_Cache::REF_SHARE_TOTAL ] = true;
419
+
420
+ return $checked_target_sns;
421
+ }
422
+
423
  }
424
 
425
  ?>
includes/class-scc-share-facebook-crawl-strategy.php ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ class-scc-share-facebook-crawl-strategy.php
4
+
5
+ Description: This class is abstract class of a data crawler
6
+ Author: Daisuke Maruyama
7
+ Author URI: http://marubon.info/
8
+ License: GPL2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; either version 2
18
+ of the License, or (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ */
29
+
30
+ /**
31
+ * SCC_Share_Facebook_Crawl_Strategy
32
+ */
33
+ class SCC_Share_Facebook_Crawl_Strategy extends SCC_Crawl_Strategy {
34
+
35
+ /**
36
+ * SNS base URL
37
+ *
38
+ * @var string
39
+ */
40
+ const DEF_BASE_URL = 'https://graph.facebook.com/v3.2/';
41
+
42
+ /**
43
+ * Class constarctor
44
+ * Hook onto all of the actions and filters needed by the plugin.
45
+ */
46
+ protected function __construct() {
47
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
48
+
49
+ $this->http_method = 'GET';
50
+ $this->query_parameters['fields'] = 'og_object{engagement}';
51
+ }
52
+
53
+ /**
54
+ * Initialization
55
+ *
56
+ * @param array $options Option.
57
+ * @return void
58
+ */
59
+ public function initialize( $options = array() ) {
60
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
61
+
62
+ $this->set_parameters( $options );
63
+ }
64
+
65
+ /**
66
+ * Build request header
67
+ *
68
+ * @return array
69
+ */
70
+ public function build_request_header() {
71
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
72
+ return null;
73
+ }
74
+
75
+ /**
76
+ * Build request body
77
+ *
78
+ * @return array
79
+ */
80
+ public function build_request_body() {
81
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
82
+ return null;
83
+ }
84
+
85
+ /**
86
+ * Build request URL
87
+ *
88
+ * @return string
89
+ */
90
+ public function build_request_url() {
91
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
92
+
93
+ $url = self::DEF_BASE_URL . '?' . http_build_query( $this->query_parameters , '' , '&' );
94
+
95
+ return $url;
96
+ }
97
+
98
+ /**
99
+ * Extract response body
100
+ *
101
+ * @param array $content Content.
102
+ * @return array
103
+ */
104
+ public function extract_response_body( $content ) {
105
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
106
+
107
+ $count = (int) -1;
108
+
109
+ if ( isset( $content['body'] ) && empty( $content['error'] ) ) {
110
+ // SCC_Logger::log( '[' . __METHOD__ . '] X-App-Usage: ' . $content['header'][ strtolower( 'X-App-Usage' ) ] );
111
+
112
+ $json = json_decode( $content['body'], true );
113
+
114
+ if ( isset( $json['og_object']['engagement']['count'] ) && is_numeric( $json['og_object']['engagement']['count'] ) ) {
115
+ $count = (int) $json['og_object']['engagement']['count'];
116
+ } elseif ( isset( $json['id'] ) && ! isset( $json['og_object']['engagement']['count'] ) ) {
117
+ $count = (int) 0;
118
+ } else {
119
+ $count = (int) - 1;
120
+ }
121
+ } else {
122
+ $count = (int) - 1;
123
+
124
+ if ( isset( $content['error'] ) ) {
125
+ SCC_Logger::log( $content['error'] );
126
+ }
127
+ }
128
+
129
+ return $count;
130
+ }
131
+
132
+ /**
133
+ * Extract response header
134
+ *
135
+ * @param array $content Content.
136
+ * @return array
137
+ */
138
+ public function extract_response_header( $content ) {
139
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
140
+
141
+ if ( isset( $content['header'] ) ) {
142
+
143
+ $headers = array();
144
+
145
+ if ( isset( $content['header'][ strtolower( 'X-App-Usage' ) ] ) ) {
146
+ SCC_Logger::log( '[' . __METHOD__ . '] X-App-Usage: ' . $content['header'][ strtolower( 'X-App-Usage' ) ] );
147
+
148
+ $headers['x-app-usage'] = json_decode( $content['header'][ strtolower( 'X-App-Usage' ) ], true );
149
+
150
+ return $headers;
151
+ }
152
+ }
153
+
154
+ return null;
155
+ }
156
+
157
+ /**
158
+ * Set parameter
159
+ *
160
+ * @param string $key Key.
161
+ * @param string $value Value.
162
+ * @return void
163
+ */
164
+ public function set_parameter( $key, $value ) {
165
+ if ( 'url' === $key ) {
166
+ $this->query_parameters['id'] = $value;
167
+ } elseif ( 'access_token' === $key ) {
168
+ $this->query_parameters[ $key ] = $value;
169
+ } elseif ( 'app_id' === $key ) {
170
+ $this->parameters[ $key ] = $value;
171
+ } elseif ( 'app_secret' === $key ) {
172
+ $this->parameters[ $key ] = $value;
173
+ }
174
+ }
175
+
176
+ /**
177
+ * Check if required paramters are included or not.
178
+ *
179
+ * @return boolean
180
+ */
181
+ public function check_configuration() {
182
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
183
+
184
+ if ( ! empty( $this->parameters['app_id'] ) && ! empty( $this->parameters['app_secret'] ) && ! empty( $this->query_parameters['access_token'] ) ) {
185
+ return true;
186
+ } else {
187
+ return false;
188
+ }
189
+ }
190
+
191
+ /**
192
+ * Check if there is rate limiting or not.
193
+ *
194
+ * @param string $content Content.
195
+ * @return boolean
196
+ */
197
+ public function check_rate_limiting( $content ) {
198
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
199
+
200
+ if ( isset( $content['header'] ) ) {
201
+
202
+ $headers = array();
203
+
204
+ if ( isset( $content['header'][ strtolower( 'X-App-Usage' ) ] ) ) {
205
+
206
+ $headers['x-app-usage'] = json_decode( $content['header'][ strtolower( 'X-App-Usage' ) ], true );
207
+
208
+ if ( ! empty( $headers[ strtolower( 'X-App-Usage' ) ]['call_count'] ) ) {
209
+ $current_call_count = (int) $headers[ strtolower( 'X-App-Usage' ) ]['call_count'];
210
+
211
+ SCC_Logger::log( '[' . __METHOD__ . '] current_call_count: ' . $current_call_count );
212
+
213
+ $threshold = 100;
214
+
215
+ if ( $current_call_count + 20 > $threshold ) {
216
+ SCC_Logger::log( '[' . __METHOD__ . '] hogehoge ' );
217
+ return false;
218
+ } else {
219
+ return true;
220
+ }
221
+ } else {
222
+ return false;
223
+ }
224
+ } else {
225
+ return false;
226
+ }
227
+ } else {
228
+ return false;
229
+ }
230
+ }
231
+
232
+
233
+ }
includes/class-scc-share-facebook-strategy.php DELETED
@@ -1,136 +0,0 @@
1
- <?php
2
- /*
3
- class-scc-share-facebook-strategy.php
4
-
5
- Description: This class is abstract class of a data crawler
6
- Author: Daisuke Maruyama
7
- Author URI: http://marubon.info/
8
- License: GPL2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
-
12
- /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
-
15
- This program is free software; you can redistribute it and/or
16
- modify it under the terms of the GNU General Public License
17
- as published by the Free Software Foundation; either version 2
18
- of the License, or (at your option) any later version.
19
-
20
- This program is distributed in the hope that it will be useful,
21
- but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- GNU General Public License for more details.
24
-
25
- You should have received a copy of the GNU General Public License
26
- along with this program; if not, write to the Free Software
27
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
- */
29
-
30
- class SCC_Share_Facebook_Strategy extends SCC_Crawl_Strategy {
31
-
32
- /**
33
- * SNS base url
34
- */
35
- const DEF_BASE_URL = 'https://graph.facebook.com/';
36
-
37
- /**
38
- * Class constarctor
39
- * Hook onto all of the actions and filters needed by the plugin.
40
- *
41
- */
42
- protected function __construct() {
43
- SCC_Common_Util::log('[' . __METHOD__ . '] (line='. __LINE__ . ')');
44
-
45
- $this->method = 'GET';
46
- }
47
-
48
- /**
49
- * Initialization
50
- *
51
- * @since 0.9.0
52
- */
53
- public function initialize( $options = array() ) {
54
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
55
-
56
- if ( isset( $options['url'] ) ) $this->url = $options['url'];
57
- if ( isset( $options['method'] ) ) $this->method = $options['method'];
58
- if ( isset( $options['parameters'] ) ) $this->parameters = $options['parameters'];
59
- }
60
-
61
- /**
62
- * Build header
63
- *
64
- * @since 0.9.0
65
- */
66
- public function build_header() {
67
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
68
- return null;
69
- }
70
-
71
- /**
72
- * Build query url
73
- *
74
- * @since 0.9.0
75
- */
76
- public function build_query_url() {
77
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
78
-
79
- $url = self::DEF_BASE_URL . '?' . http_build_query( $this->query_parameters , '' , '&' );
80
-
81
- return $url;
82
- }
83
-
84
- /**
85
- * Extract count
86
- *
87
- * @since 0.9.0
88
- */
89
- public function extract_count( $content ) {
90
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
91
-
92
- $count = (int) -1;
93
-
94
- if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
95
- $json = json_decode( $content['data'], true );
96
-
97
- if ( isset( $json['share']['share_count'] ) && is_numeric( $json['share']['share_count'] ) ) {
98
- $count = (int) $json['share']['share_count'];
99
- } elseif ( isset( $json['id'] ) && ! isset( $json['share']['share_count'] ) ) {
100
- $count = (int) 0;
101
- } else {
102
- $count = (int) -1;
103
- }
104
- } else {
105
- $count = (int) -1;
106
- }
107
-
108
- return $count;
109
- }
110
-
111
- public function set_query_parameter( $key, $value ) {
112
- if ( $key === 'url' ) {
113
- $this->query_parameters['id'] = $value;
114
- } elseif ( $key === 'access_token' ) {
115
- $this->query_parameters[$key] = $value;
116
- }
117
- }
118
-
119
- /**
120
- * Check if required paramters are included or not.
121
- *
122
- * @since 0.9.0
123
- */
124
- public function check_configuration() {
125
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
126
-
127
- if ( isset( $this->parameters['app_id'] ) && $this->parameters['app_id'] &&
128
- isset( $this->parameters['app_secret'] ) && $this->parameters['app_secret'] &&
129
- isset( $this->query_parameters['access_token'] ) && $this->query_parameters['access_token'] ) {
130
- return true;
131
- } else {
132
- return false;
133
- }
134
- }
135
-
136
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-scc-share-google-crawl-strategy.php ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ class-scc-share-google-crawl-strategy.php
4
+
5
+ Description: This class is abstract class of a data crawler
6
+ Author: Daisuke Maruyama
7
+ Author URI: http://marubon.info/
8
+ License: GPL2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; either version 2
18
+ of the License, or (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ */
29
+
30
+ /**
31
+ * SCC_Share_Google_Crawl_Strategy
32
+ */
33
+ class SCC_Share_Google_Crawl_Strategy extends SCC_Crawl_Strategy {
34
+
35
+ /**
36
+ * SNS base URL
37
+ *
38
+ * @var string
39
+ */
40
+ const DEF_BASE_URL = 'https://clients6.google.com/rpc';
41
+
42
+ /**
43
+ * Class constarctor
44
+ * Hook onto all of the actions and filters needed by the plugin.
45
+ */
46
+ protected function __construct() {
47
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
48
+
49
+ $this->http_method = 'POST';
50
+ }
51
+
52
+ /**
53
+ * Initialization
54
+ *
55
+ * @param array $options Option.
56
+ * @return void
57
+ */
58
+ public function initialize( $options = array() ) {
59
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
60
+
61
+ $this->set_parameters( $options );
62
+ }
63
+
64
+ /**
65
+ * Build request header
66
+ *
67
+ * @return array
68
+ */
69
+ public function build_request_header() {
70
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
71
+ $headers = array();
72
+
73
+ $headers['Content-Type'] = 'application/json';
74
+
75
+ return $headers;
76
+ }
77
+
78
+ /**
79
+ * Build request body
80
+ *
81
+ * @return array
82
+ */
83
+ public function build_request_body() {
84
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
85
+
86
+ $bodies['method'] = 'pos.plusones.get';
87
+ $bodies['params'] = array(
88
+ 'id' => $this->parameters['url'],
89
+ );
90
+ $bodies['apiVersion'] = 'v1';
91
+
92
+ return $bodies;
93
+ }
94
+
95
+ /**
96
+ * Build request URL
97
+ *
98
+ * @return string
99
+ */
100
+ public function build_request_url() {
101
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
102
+
103
+ $url = self::DEF_BASE_URL;
104
+
105
+ return $url;
106
+ }
107
+
108
+ /**
109
+ * Extract response body
110
+ *
111
+ * @param array $content Content.
112
+ * @return array
113
+ */
114
+ public function extract_response_body( $content ) {
115
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
116
+
117
+ $count = (int) -1;
118
+
119
+ if ( isset( $content['body'] ) && empty( $content['error'] ) ) {
120
+ $json = json_decode( $content['body'], true );
121
+
122
+ if ( isset( $json['result']['metadata']['globalCounts']['count'] ) && is_numeric( $json['result']['metadata']['globalCounts']['count'] ) ) {
123
+ $count = (int) $json['result']['metadata']['globalCounts']['count'];
124
+ } else {
125
+ $count = (int) -1;
126
+ }
127
+ } else {
128
+ $count = (int) -1;
129
+
130
+ if ( isset( $content['error'] ) ) {
131
+ SCC_Logger::log( $content['error'] );
132
+ }
133
+ }
134
+
135
+ return $count;
136
+ }
137
+
138
+ /**
139
+ * Extract response header
140
+ *
141
+ * @param array $content Content.
142
+ * @return array
143
+ */
144
+ public function extract_response_header( $content ) {
145
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
146
+ return null;
147
+ }
148
+
149
+ /**
150
+ * Set parameter
151
+ *
152
+ * @param string $key Key.
153
+ * @param string $value Value.
154
+ * @return void
155
+ */
156
+ public function set_parameter( $key, $value ) {
157
+ if ( 'url' === $key ) {
158
+ $this->parameters[ $key ] = $value;
159
+ }
160
+ }
161
+
162
+ /**
163
+ * Check if required paramters are included or not.
164
+ *
165
+ * @return boolean
166
+ */
167
+ public function check_configuration() {
168
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
169
+
170
+ if ( ! empty( $this->parameters['url'] ) ) {
171
+ return true;
172
+ } else {
173
+ return false;
174
+ }
175
+ }
176
+
177
+ /**
178
+ * Check if there is rate limiting or not.
179
+ *
180
+ * @param string $content Content.
181
+ * @return boolean
182
+ */
183
+ public function check_rate_limiting( $content ) {
184
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
185
+
186
+ return true;
187
+ }
188
+ }
includes/class-scc-share-google-strategy.php DELETED
@@ -1,130 +0,0 @@
1
- <?php
2
- /*
3
- class-scc-share-google-strategy.php
4
-
5
- Description: This class is abstract class of a data crawler
6
- Author: Daisuke Maruyama
7
- Author URI: http://marubon.info/
8
- License: GPL2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
-
12
- /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
-
15
- This program is free software; you can redistribute it and/or
16
- modify it under the terms of the GNU General Public License
17
- as published by the Free Software Foundation; either version 2
18
- of the License, or (at your option) any later version.
19
-
20
- This program is distributed in the hope that it will be useful,
21
- but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- GNU General Public License for more details.
24
-
25
- You should have received a copy of the GNU General Public License
26
- along with this program; if not, write to the Free Software
27
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
- */
29
-
30
- class SCC_Share_Google_Strategy extends SCC_Crawl_Strategy {
31
-
32
- /**
33
- * SNS base url
34
- */
35
- const DEF_BASE_URL = 'https://apis.google.com/_/+1/fastbutton';
36
-
37
- /**
38
- * Class constarctor
39
- * Hook onto all of the actions and filters needed by the plugin.
40
- *
41
- */
42
- protected function __construct() {
43
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
44
-
45
- $this->method = 'GET';
46
- }
47
-
48
- /**
49
- * Initialization
50
- *
51
- * @since 0.9.0
52
- */
53
- public function initialize( $options = array() ) {
54
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
55
-
56
- if ( isset( $options['url'] ) ) $this->url = $options['url'];
57
- if ( isset( $options['method'] ) ) $this->method = $options['method'];
58
- if ( isset( $options['parameters'] ) ) $this->parameters = $options['parameters'];
59
- }
60
-
61
- /**
62
- * Build header
63
- *
64
- * @since 0.9.0
65
- */
66
- public function build_header() {
67
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
68
- return null;
69
- }
70
-
71
- /**
72
- * Build query url
73
- *
74
- * @since 0.9.0
75
- */
76
- public function build_query_url() {
77
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
78
-
79
- $url = self::DEF_BASE_URL . '?' . http_build_query( $this->query_parameters, '' , '&' );
80
-
81
- return $url;
82
- }
83
-
84
- /**
85
- * Extract count
86
- *
87
- * @since 0.9.0
88
- */
89
- public function extract_count( $content ) {
90
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
91
-
92
- $count = (int) -1;
93
-
94
- if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
95
- $return_code = preg_match( '/\[2,([0-9.]+),\[/', $content['data'], $matches );
96
-
97
- if ( $return_code && isset( $matches[1] ) && is_numeric( $matches[1] ) ) {
98
- $count = (int) $matches[1];
99
- } else {
100
- $count = (int) -1;
101
- }
102
- } else {
103
- $count = (int) -1;
104
- }
105
-
106
- return $count;
107
- }
108
-
109
- public function set_query_parameter( $key, $value ) {
110
- if ( $key === 'url' ) {
111
- $this->query_parameters[$key] = $value;
112
- }
113
- }
114
-
115
- /**
116
- * Check if required paramters are included or not.
117
- *
118
- * @since 0.9.0
119
- */
120
- public function check_configuration() {
121
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
122
-
123
- if ( isset( $this->query_parameters['url'] ) && $this->query_parameters['url'] ) {
124
- return true;
125
- } else {
126
- return false;
127
- }
128
- }
129
-
130
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-scc-share-hatebu-crawl-strategy.php ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ class-scc-share-hatebu-crawl-strategy.php
4
+
5
+ Description: This class is abstract class of a data crawler
6
+ Author: Daisuke Maruyama
7
+ Author URI: http://marubon.info/
8
+ License: GPL2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; either version 2
18
+ of the License, or (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ */
29
+
30
+ /**
31
+ * SCC_Share_Hatebu_Crawl_Strategy
32
+ */
33
+ class SCC_Share_Hatebu_Crawl_Strategy extends SCC_Crawl_Strategy {
34
+
35
+ /**
36
+ * SNS base URL
37
+ *
38
+ * @var string
39
+ */
40
+
41
+ const DEF_BASE_URL = 'http://api.b.st-hatena.com/entry.count';
42
+
43
+ /**
44
+ * Class constarctor
45
+ * Hook onto all of the actions and filters needed by the plugin.
46
+ */
47
+ protected function __construct() {
48
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
49
+
50
+ $this->http_method = 'GET';
51
+ }
52
+
53
+ /**
54
+ * Initialization
55
+ *
56
+ * @param array $options Option.
57
+ * @return void
58
+ */
59
+ public function initialize( $options = array() ) {
60
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
61
+
62
+ $this->set_parameters( $options );
63
+ }
64
+
65
+ /**
66
+ * Build request header
67
+ *
68
+ * @return array
69
+ */
70
+ public function build_request_header() {
71
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
72
+ return null;
73
+ }
74
+
75
+ /**
76
+ * Build request body
77
+ *
78
+ * @return array
79
+ */
80
+ public function build_request_body() {
81
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
82
+
83
+ return null;
84
+ }
85
+
86
+ /**
87
+ * Build request URL
88
+ *
89
+ * @return string
90
+ */
91
+ public function build_request_url() {
92
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
93
+
94
+ $url = self::DEF_BASE_URL . '?' . http_build_query( $this->query_parameters , '' , '&' );
95
+
96
+ return $url;
97
+ }
98
+
99
+ /**
100
+ * Extract response body
101
+ *
102
+ * @param array $content Content.
103
+ * @return array
104
+ */
105
+ public function extract_response_body( $content ) {
106
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
107
+
108
+ $count = (int) -1;
109
+
110
+ if ( isset( $content['body'] ) && empty( $content['error'] ) && is_numeric( $content['body'] ) ) {
111
+ $count = (int) $content['body'];
112
+ } elseif ( empty( $content['body'] ) && empty( $content['error'] ) ) {
113
+ $count = (int) 0;
114
+ } else {
115
+ $count = (int) -1;
116
+
117
+ if ( isset( $content['error'] ) ) {
118
+ SCC_Logger::log( $content['error'] );
119
+ }
120
+ }
121
+
122
+ return $count;
123
+ }
124
+
125
+ /**
126
+ * Extract response header
127
+ *
128
+ * @param array $content Content.
129
+ * @return array
130
+ */
131
+ public function extract_response_header( $content ) {
132
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
133
+ return null;
134
+ }
135
+
136
+ /**
137
+ * Set parameter
138
+ *
139
+ * @param string $key Key.
140
+ * @param string $value Value.
141
+ * @return void
142
+ */
143
+ public function set_parameter( $key, $value ) {
144
+ if ( 'url' === $key ) {
145
+ $this->query_parameters[ $key ] = $value;
146
+ }
147
+ }
148
+
149
+ /**
150
+ * Check if required paramters are included or not.
151
+ *
152
+ * @return boolean
153
+ */
154
+ public function check_configuration() {
155
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
156
+
157
+ if ( ! empty( $this->query_parameters['url'] ) ) {
158
+ return true;
159
+ } else {
160
+ return false;
161
+ }
162
+ }
163
+
164
+ /**
165
+ * Check if there is rate limiting or not.
166
+ *
167
+ * @param string $content Content.
168
+ * @return boolean
169
+ */
170
+ public function check_rate_limiting( $content ) {
171
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
172
+
173
+ return true;
174
+ }
175
+
176
+ }
includes/class-scc-share-hatebu-strategy.php DELETED
@@ -1,126 +0,0 @@
1
- <?php
2
- /*
3
- class-scc-share-hatebu-strategy.php
4
-
5
- Description: This class is abstract class of a data crawler
6
- Author: Daisuke Maruyama
7
- Author URI: http://marubon.info/
8
- License: GPL2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
-
12
- /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
-
15
- This program is free software; you can redistribute it and/or
16
- modify it under the terms of the GNU General Public License
17
- as published by the Free Software Foundation; either version 2
18
- of the License, or (at your option) any later version.
19
-
20
- This program is distributed in the hope that it will be useful,
21
- but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- GNU General Public License for more details.
24
-
25
- You should have received a copy of the GNU General Public License
26
- along with this program; if not, write to the Free Software
27
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
- */
29
-
30
- class SCC_Share_Hatebu_Strategy extends SCC_Crawl_Strategy {
31
-
32
- /**
33
- * SNS base url
34
- */
35
- const DEF_BASE_URL = 'http://api.b.st-hatena.com/entry.count';
36
-
37
- /**
38
- * Class constarctor
39
- * Hook onto all of the actions and filters needed by the plugin.
40
- *
41
- */
42
- protected function __construct() {
43
- SCC_Common_Util::log('[' . __METHOD__ . '] (line='. __LINE__ . ')');
44
-
45
- $this->method = 'GET';
46
- }
47
-
48
- /**
49
- * Initialization
50
- *
51
- * @since 0.9.0
52
- */
53
- public function initialize( $options = array() ) {
54
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
55
-
56
- if ( isset( $options['url'] ) ) $this->url = $options['url'];
57
- if ( isset( $options['method'] ) ) $this->method = $options['method'];
58
- if ( isset( $options['parameters'] ) ) $this->parameters = $options['parameters'];
59
- }
60
-
61
- /**
62
- * Build header
63
- *
64
- * @since 0.9.0
65
- */
66
- public function build_header() {
67
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
68
- return null;
69
- }
70
-
71
- /**
72
- * Build query url
73
- *
74
- * @since 0.9.0
75
- */
76
- public function build_query_url() {
77
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
78
-
79
- $url = self::DEF_BASE_URL . '?' . http_build_query( $this->query_parameters , '' , '&' );
80
-
81
- return $url;
82
- }
83
-
84
- /**
85
- * Extract count
86
- *
87
- * @since 0.9.0
88
- */
89
- public function extract_count( $content ) {
90
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
91
-
92
- $count = (int) -1;
93
-
94
- if ( isset( $content['data'] ) && empty( $content['error'] ) && is_numeric( $content['data'] ) ) {
95
- $count = (int) $content['data'];
96
- } elseif ( empty( $content['data'] ) && empty( $content['error'] ) ) {
97
- $count = (int) 0;
98
- } else {
99
- $count = (int) -1;
100
- }
101
-
102
- return $count;
103
- }
104
-
105
- public function set_query_parameter( $key, $value ) {
106
- if ( $key === 'url' ) {
107
- $this->query_parameters[$key] = $value;
108
- }
109
- }
110
-
111
- /**
112
- * Check if required paramters are included or not.
113
- *
114
- * @since 0.9.0
115
- */
116
- public function check_configuration() {
117
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
118
-
119
- if ( isset( $this->query_parameters['url'] ) && $this->query_parameters['url'] ) {
120
- return true;
121
- } else {
122
- return false;
123
- }
124
- }
125
-
126
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-scc-share-lazy-cache-engine.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-share-lazy-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,6 +27,9 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  class SCC_Share_Lazy_Cache_Engine extends SCC_Share_Cache_Engine {
31
 
32
  /**
@@ -56,31 +59,40 @@ class SCC_Share_Lazy_Cache_Engine extends SCC_Share_Cache_Engine {
56
 
57
  /**
58
  * Cache post types
 
 
59
  */
60
  private $post_types = array( 'post', 'page' );
61
 
62
  /**
63
  * Interval cheking and caching target data
 
 
64
  */
65
  private $check_interval = 600;
66
 
67
  /**
68
  * Number of posts to check at a time
 
 
69
  */
70
  private $posts_per_check = 20;
71
 
72
  /**
73
  * Latency suffix
 
 
74
  */
75
  private $check_latency = 10;
76
 
77
  /**
78
  * Initialization
79
  *
80
- * @since 0.1.1
 
81
  */
82
  public function initialize( $options = array() ) {
83
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
84
 
85
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
86
  $this->prime_cron = self::DEF_PRIME_CRON;
@@ -90,21 +102,65 @@ class SCC_Share_Lazy_Cache_Engine extends SCC_Share_Cache_Engine {
90
 
91
  $this->load_ratio = 0.5;
92
 
93
- if ( isset( $options['delegate'] ) ) $this->delegate = $options['delegate'];
94
- if ( isset( $options['crawler'] ) ) $this->crawler = $options['crawler'];
95
- if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
96
- if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
97
- if ( isset( $options['posts_per_check'] ) ) $this->posts_per_check = $options['posts_per_check'];
98
- if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
99
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
100
- if ( isset( $options['check_latency'] ) ) $this->check_latency = $options['check_latency'];
101
- if ( isset( $options['post_types'] ) ) $this->post_types = $options['post_types'];
102
- if ( isset( $options['scheme_migration_mode'] ) ) $this->scheme_migration_mode = $options['scheme_migration_mode'];
103
- if ( isset( $options['scheme_migration_date'] ) ) $this->scheme_migration_date = $options['scheme_migration_date'];
104
- if ( isset( $options['scheme_migration_exclude_keys'] ) ) $this->scheme_migration_exclude_keys = $options['scheme_migration_exclude_keys'];
105
- if ( isset( $options['cache_retry'] ) ) $this->cache_retry = $options['cache_retry'];
106
- if ( isset( $options['retry_limit'] ) ) $this->retry_limit = $options['retry_limit'];
107
- if ( isset( $options['fault_tolerance'] ) ) $this->fault_tolerance = $options['fault_tolerance'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
  add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 1 );
110
  }
@@ -112,71 +168,73 @@ class SCC_Share_Lazy_Cache_Engine extends SCC_Share_Cache_Engine {
112
  /**
113
  * Register base schedule for this engine
114
  *
115
- * @since 0.1.0
116
  */
117
  public function register_schedule() {
118
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
119
  }
120
 
121
  /**
122
  * Unregister base schedule for this engine
123
  *
124
- * @since 0.1.0
125
  */
126
  public function unregister_schedule() {
127
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
128
 
129
- SCC_WP_Cron_Util::clear_scheduled_hook( $this->execute_cron );
130
  }
131
 
132
  /**
133
  * Schedule data retrieval and cache processing
134
  *
135
- * @since 0.2.0
 
136
  */
137
- public function prime_cache( $post_ID ) {
138
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
139
 
140
  $next_exec_time = (int) current_time( 'timestamp', 1 ) + $this->check_latency;
141
 
142
- SCC_Common_Util::log( '[' . __METHOD__ . '] check_latency: ' . $this->check_latency );
143
- SCC_Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
144
 
145
- wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( $post_ID ) );
146
  }
147
 
148
  /**
149
  * Get and cache data of each published post
150
  *
151
- * @since 0.2.0
 
152
  */
153
- public function execute_cache( $post_ID ) {
154
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
155
 
156
  $cache_expiration = $this->get_cache_expiration();
157
 
158
- SCC_Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
159
 
160
- $transient_id = $this->get_cache_key( $post_ID );
161
 
162
- if ( $post_ID != 'home' ) {
163
- $url = get_permalink( $post_ID );
164
- $title = get_the_title( $post_ID );
165
- $publish_date = get_the_date( 'Y/m/d', $post_ID );
166
  } else {
167
  $url = home_url( '/' );
168
  $title = get_bloginfo( 'name' );
169
- $publish_date = NULL;
170
  }
171
 
172
  $options = array(
173
  'cache_key' => $transient_id,
174
- 'post_id' => $post_ID,
175
  'target_url' => $url,
176
  'target_sns' => $this->target_sns,
177
  'target_title' => $title,
178
  'publish_date' => $publish_date,
179
- 'cache_expiration' => $cache_expiration
180
  );
181
 
182
  // Primary cache
@@ -189,14 +247,14 @@ class SCC_Share_Lazy_Cache_Engine extends SCC_Share_Cache_Engine {
189
  /**
190
  * Get cache expiration based on current number of total post and page
191
  *
192
- * @since 0.1.1
193
  */
194
  protected function get_cache_expiration() {
195
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
196
 
197
  $posts_total = $this->get_posts_total();
198
 
199
- SCC_Common_Util::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
200
 
201
  return ceil( $posts_total / $this->posts_per_check ) * $this->check_interval * 3;
202
  }
@@ -204,17 +262,17 @@ class SCC_Share_Lazy_Cache_Engine extends SCC_Share_Cache_Engine {
204
  /**
205
  * Get total count of current published post and page
206
  *
207
- * @since 0.1.0
208
  */
209
  private function get_posts_total() {
210
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
211
 
212
  $query_args = array(
213
  'post_type' => $this->post_types,
214
  'post_status' => 'publish',
215
  'nopaging' => true,
216
  'update_post_term_cache' => false,
217
- 'update_post_meta_cache' => false
218
  );
219
 
220
  $posts_query = new WP_Query( $query_args );
@@ -223,27 +281,28 @@ class SCC_Share_Lazy_Cache_Engine extends SCC_Share_Cache_Engine {
223
  }
224
 
225
  /**
226
- * Initialize meta key for ranking
227
  *
228
- * @since 0.3.0
229
  */
230
  public function initialize_cache() {
231
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
232
  }
233
 
234
  /**
235
- * Clear meta key for ranking
236
  *
237
- * @since 0.3.0
238
  */
239
  public function clear_cache() {
240
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
241
  }
242
 
243
  /**
244
- * Get current cache
245
  *
246
- * @since 0.9.3
 
247
  */
248
  public function get_cache( $options = array() ) {
249
  $post_id = $options['post_id'];
@@ -252,7 +311,9 @@ class SCC_Share_Lazy_Cache_Engine extends SCC_Share_Cache_Engine {
252
 
253
  $sns_counts = array();
254
 
255
- if ( false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
 
 
256
  return $sns_counts;
257
  } else {
258
  return $this->delegate_order( SCC_Order::ORDER_GET_SECOND_CACHE, $options );
1
  <?php
2
+ /**
3
  class-scc-share-lazy-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Share_Lazy_Cache_Engine
32
+ */
33
  class SCC_Share_Lazy_Cache_Engine extends SCC_Share_Cache_Engine {
34
 
35
  /**
59
 
60
  /**
61
  * Cache post types
62
+ *
63
+ * @var array
64
  */
65
  private $post_types = array( 'post', 'page' );
66
 
67
  /**
68
  * Interval cheking and caching target data
69
+ *
70
+ * @var integer
71
  */
72
  private $check_interval = 600;
73
 
74
  /**
75
  * Number of posts to check at a time
76
+ *
77
+ * @var integer
78
  */
79
  private $posts_per_check = 20;
80
 
81
  /**
82
  * Latency suffix
83
+ *
84
+ * @var integer
85
  */
86
  private $check_latency = 10;
87
 
88
  /**
89
  * Initialization
90
  *
91
+ * @param array $options Option.
92
+ * @return void
93
  */
94
  public function initialize( $options = array() ) {
95
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
96
 
97
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
98
  $this->prime_cron = self::DEF_PRIME_CRON;
102
 
103
  $this->load_ratio = 0.5;
104
 
105
+ if ( isset( $options['delegate'] ) ) {
106
+ $this->delegate = $options['delegate'];
107
+ }
108
+
109
+ if ( isset( $options['crawler'] ) ) {
110
+ $this->crawler = $options['crawler'];
111
+ }
112
+
113
+ if ( isset( $options['target_sns'] ) ) {
114
+ $this->target_sns = $options['target_sns'];
115
+ }
116
+
117
+ if ( isset( $options['check_interval'] ) ) {
118
+ $this->check_interval = $options['check_interval'];
119
+ }
120
+
121
+ if ( isset( $options['posts_per_check'] ) ) {
122
+ $this->posts_per_check = $options['posts_per_check'];
123
+ }
124
+
125
+ if ( isset( $options['cache_prefix'] ) ) {
126
+ $this->cache_prefix = $options['cache_prefix'];
127
+ }
128
+
129
+ if ( isset( $options['execute_cron'] ) ) {
130
+ $this->execute_cron = $options['execute_cron'];
131
+ }
132
+
133
+ if ( isset( $options['check_latency'] ) ) {
134
+ $this->check_latency = $options['check_latency'];
135
+ }
136
+
137
+ if ( isset( $options['post_types'] ) ) {
138
+ $this->post_types = $options['post_types'];
139
+ }
140
+
141
+ if ( isset( $options['scheme_migration_mode'] ) ) {
142
+ $this->scheme_migration_mode = $options['scheme_migration_mode'];
143
+ }
144
+
145
+ if ( isset( $options['scheme_migration_date'] ) ) {
146
+ $this->scheme_migration_date = $options['scheme_migration_date'];
147
+ }
148
+
149
+ if ( isset( $options['scheme_migration_exclude_keys'] ) ) {
150
+ $this->scheme_migration_exclude_keys = $options['scheme_migration_exclude_keys'];
151
+ }
152
+
153
+ if ( isset( $options['cache_retry'] ) ) {
154
+ $this->cache_retry = $options['cache_retry'];
155
+ }
156
+
157
+ if ( isset( $options['retry_limit'] ) ) {
158
+ $this->retry_limit = $options['retry_limit'];
159
+ }
160
+
161
+ if ( isset( $options['fault_tolerance'] ) ) {
162
+ $this->fault_tolerance = $options['fault_tolerance'];
163
+ }
164
 
165
  add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 1 );
166
  }
168
  /**
169
  * Register base schedule for this engine
170
  *
171
+ * @return void
172
  */
173
  public function register_schedule() {
174
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
175
  }
176
 
177
  /**
178
  * Unregister base schedule for this engine
179
  *
180
+ * @return void
181
  */
182
  public function unregister_schedule() {
183
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
184
 
185
+ SCC_WP_Cron::clear_scheduled_hook( $this->execute_cron );
186
  }
187
 
188
  /**
189
  * Schedule data retrieval and cache processing
190
  *
191
+ * @param integer $post_id Post OD.
192
+ * @return void
193
  */
194
+ public function prime_cache( $post_id ) {
195
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
196
 
197
  $next_exec_time = (int) current_time( 'timestamp', 1 ) + $this->check_latency;
198
 
199
+ SCC_Logger::log( '[' . __METHOD__ . '] check_latency: ' . $this->check_latency );
200
+ SCC_Logger::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
201
 
202
+ wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( $post_id ) );
203
  }
204
 
205
  /**
206
  * Get and cache data of each published post
207
  *
208
+ * @param integer $post_id Post ID.
209
+ * @return void
210
  */
211
+ public function execute_cache( $post_id ) {
212
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
213
 
214
  $cache_expiration = $this->get_cache_expiration();
215
 
216
+ SCC_Logger::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
217
 
218
+ $transient_id = $this->get_cache_key( $post_id );
219
 
220
+ if ( 'home' != $post_id ) {
221
+ $url = get_permalink( $post_id );
222
+ $title = get_the_title( $post_id );
223
+ $publish_date = get_the_date( 'Y/m/d', $post_id );
224
  } else {
225
  $url = home_url( '/' );
226
  $title = get_bloginfo( 'name' );
227
+ $publish_date = null;
228
  }
229
 
230
  $options = array(
231
  'cache_key' => $transient_id,
232
+ 'post_id' => $post_id,
233
  'target_url' => $url,
234
  'target_sns' => $this->target_sns,
235
  'target_title' => $title,
236
  'publish_date' => $publish_date,
237
+ 'cache_expiration' => $cache_expiration,
238
  );
239
 
240
  // Primary cache
247
  /**
248
  * Get cache expiration based on current number of total post and page
249
  *
250
+ * @return void
251
  */
252
  protected function get_cache_expiration() {
253
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
254
 
255
  $posts_total = $this->get_posts_total();
256
 
257
+ SCC_Logger::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
258
 
259
  return ceil( $posts_total / $this->posts_per_check ) * $this->check_interval * 3;
260
  }
262
  /**
263
  * Get total count of current published post and page
264
  *
265
+ * @return integer
266
  */
267
  private function get_posts_total() {
268
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
269
 
270
  $query_args = array(
271
  'post_type' => $this->post_types,
272
  'post_status' => 'publish',
273
  'nopaging' => true,
274
  'update_post_term_cache' => false,
275
+ 'update_post_meta_cache' => false,
276
  );
277
 
278
  $posts_query = new WP_Query( $query_args );
281
  }
282
 
283
  /**
284
+ * Initialize cache
285
  *
286
+ * @return void
287
  */
288
  public function initialize_cache() {
289
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
290
  }
291
 
292
  /**
293
+ * Clear cache
294
  *
295
+ * @return void
296
  */
297
  public function clear_cache() {
298
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
299
  }
300
 
301
  /**
302
+ * Get cache
303
  *
304
+ * @param array $options Option.
305
+ * @return array
306
  */
307
  public function get_cache( $options = array() ) {
308
  $post_id = $options['post_id'];
311
 
312
  $sns_counts = array();
313
 
314
+ $sns_counts = get_transient( $transient_id );
315
+
316
+ if ( false !== $sns_counts ) {
317
  return $sns_counts;
318
  } else {
319
  return $this->delegate_order( SCC_Order::ORDER_GET_SECOND_CACHE, $options );
includes/class-scc-share-linkedin-crawl-strategy.php ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ class-scc-share-linkedin-crawl-strategy.php
4
+
5
+ Description: This class is abstract class of a data crawler
6
+ Author: Daisuke Maruyama
7
+ Author URI: http://marubon.info/
8
+ License: GPL2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; either version 2
18
+ of the License, or (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ */
29
+
30
+ /**
31
+ * SCC_Share_Linkedin_Crawl_Strategy
32
+ */
33
+ class SCC_Share_Linkedin_Crawl_Strategy extends SCC_Crawl_Strategy {
34
+
35
+ /**
36
+ * SNS base URL
37
+ *
38
+ * @var string
39
+ */
40
+ const DEF_BASE_URL = 'https://www.linkedin.com/countserv/count/share';
41
+
42
+ /**
43
+ * Class constarctor
44
+ * Hook onto all of the actions and filters needed by the plugin.
45
+ */
46
+ protected function __construct() {
47
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
48
+
49
+ $this->http_method = 'GET';
50
+ $this->query_parameters['format'] = 'json';
51
+ }
52
+
53
+ /**
54
+ * Initialization
55
+ *
56
+ * @param array $options Option.
57
+ * @return void
58
+ */
59
+ public function initialize( $options = array() ) {
60
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
61
+
62
+ $this->set_parameters( $options );
63
+ }
64
+
65
+ /**
66
+ * Build request header
67
+ *
68
+ * @return array
69
+ */
70
+ public function build_request_header() {
71
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
72
+ return null;
73
+ }
74
+
75
+ /**
76
+ * Build request body
77
+ *
78
+ * @return array
79
+ */
80
+ public function build_request_body() {
81
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
82
+ return null;
83
+ }
84
+
85
+ /**
86
+ * Build request URL
87
+ *
88
+ * @return string
89
+ */
90
+ public function build_request_url() {
91
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
92
+
93
+ $url = self::DEF_BASE_URL . '?' . http_build_query( $this->query_parameters , '' , '&' );
94
+
95
+ return $url;
96
+ }
97
+
98
+ /**
99
+ * Extract response body
100
+ *
101
+ * @param array $content Content.
102
+ * @return array
103
+ */
104
+ public function extract_response_body( $content ) {
105
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
106
+
107
+ $count = (int) -1;
108
+
109
+ if ( isset( $content['body'] ) && empty( $content['error'] ) ) {
110
+
111
+ $json = json_decode( $content['body'], true );
112
+
113
+ if ( isset( $json['count'] ) && is_numeric( $json['count'] ) ) {
114
+ $count = (int) $json['count'];
115
+ } else {
116
+ $count = (int) -1;
117
+ }
118
+ } else {
119
+ $count = (int) -1;
120
+
121
+ if ( isset( $content['error'] ) ) {
122
+ SCC_Logger::log( $content['error'] );
123
+ }
124
+ }
125
+
126
+ return $count;
127
+ }
128
+
129
+ /**
130
+ * Extract response header
131
+ *
132
+ * @param array $content Content.
133
+ * @return array
134
+ */
135
+ public function extract_response_header( $content ) {
136
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
137
+ return null;
138
+ }
139
+
140
+ /**
141
+ * Set parameter
142
+ *
143
+ * @param string $key Key.
144
+ * @param string $value Value.
145
+ * @return void
146
+ */
147
+ public function set_parameter( $key, $value ) {
148
+ if ( 'url' === $key ) {
149
+ $this->query_parameters[ $key ] = $value;
150
+ }
151
+ }
152
+
153
+ /**
154
+ * Check if required paramters are included or not.
155
+ *
156
+ * @return boolean
157
+ */
158
+ public function check_configuration() {
159
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
160
+
161
+ if ( ! empty( $this->query_parameters['url'] ) ) {
162
+ return true;
163
+ } else {
164
+ return false;
165
+ }
166
+ }
167
+
168
+ /**
169
+ * Check if there is rate limiting or not.
170
+ *
171
+ * @param string $content Content.
172
+ * @return boolean
173
+ */
174
+ public function check_rate_limiting( $content ) {
175
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
176
+
177
+ return true;
178
+ }
179
+
180
+ }
includes/class-scc-share-linkedin-strategy.php DELETED
@@ -1,140 +0,0 @@
1
- <?php
2
- /*
3
- class-scc-share-linkedin-strategy.php
4
-
5
- Description: This class is abstract class of a data crawler
6
- Author: Daisuke Maruyama
7
- Author URI: http://marubon.info/
8
- License: GPL2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
-
12
- /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
-
15
- This program is free software; you can redistribute it and/or
16
- modify it under the terms of the GNU General Public License
17
- as published by the Free Software Foundation; either version 2
18
- of the License, or (at your option) any later version.
19
-
20
- This program is distributed in the hope that it will be useful,
21
- but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- GNU General Public License for more details.
24
-
25
- You should have received a copy of the GNU General Public License
26
- along with this program; if not, write to the Free Software
27
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
- */
29
-
30
- class SCC_Share_Linkedin_Strategy extends SCC_Crawl_Strategy {
31
-
32
- /**
33
- * SNS base url
34
- * @var string
35
- */
36
- const DEF_BASE_URL = 'https://www.linkedin.com/countserv/count/share';
37
-
38
- /**
39
- * Class constarctor
40
- * Hook onto all of the actions and filters needed by the plugin.
41
- *
42
- */
43
- protected function __construct() {
44
- SCC_Common_Util::log('[' . __METHOD__ . '] (line='. __LINE__ . ')');
45
-
46
- $this->method = 'GET';
47
- $this->query_parameters['format'] = 'json';
48
- }
49
-
50
- /**
51
- * Initialization
52
- * @since 0.11.0
53
- * @param array $options Option for this strategy
54
- * @return null There is no return.
55
- */
56
- public function initialize( $options = array() ) {
57
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
58
-
59
- if ( isset( $options['url'] ) ) $this->url = $options['url'];
60
- if ( isset( $options['method'] ) ) $this->method = $options['method'];
61
- if ( isset( $options['parameters'] ) ) $this->parameters = $options['parameters'];
62
- }
63
-
64
- /**
65
- * Build header
66
- * @since 0.11.0
67
- * @return null no need to build header for Twitter share count retrieval.
68
- */
69
- public function build_header() {
70
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
71
- return null;
72
- }
73
-
74
- /**
75
- * Build query URL
76
- * @since 0.11.0
77
- * @return string Query URL
78
- */
79
- public function build_query_url() {
80
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
81
-
82
- $url = self::DEF_BASE_URL . '?' . http_build_query( $this->query_parameters , '' , '&' );
83
-
84
- return $url;
85
- }
86
-
87
- /**
88
- * Extract count
89
- * @since 0.11.0
90
- * @param string $content Target content
91
- * @return int SNS count
92
- */
93
- public function extract_count( $content ) {
94
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
95
-
96
- $count = (int) -1;
97
-
98
- if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
99
-
100
- $json = json_decode( $content['data'], true );
101
-
102
- if ( isset( $json['count'] ) && is_numeric( $json['count'] ) ) {
103
- $count = (int) $json['count'];
104
- } else {
105
- $count = (int) -1;
106
- }
107
- } else {
108
- $count = (int) -1;
109
- }
110
-
111
- return $count;
112
- }
113
-
114
- /**
115
- * Setter of query parameters
116
- * @param string $key key
117
- * @param string $value value
118
- */
119
- public function set_query_parameter( $key, $value ) {
120
- if ( $key === 'url' ) {
121
- $this->query_parameters[$key] = $value;
122
- }
123
- }
124
-
125
- /**
126
- * Check if required paramters are included or not.
127
- * @since 0.11.0
128
- * @return boolean Check result
129
- */
130
- public function check_configuration() {
131
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
132
-
133
- if ( isset( $this->query_parameters['url'] ) && $this->query_parameters['url'] ) {
134
- return true;
135
- } else {
136
- return false;
137
- }
138
- }
139
-
140
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-scc-share-pinterest-crawl-strategy.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ class-scc-share-pinterest-crawl-strategy.php
4
+
5
+ Description: This class is abstract class of a data crawler
6
+ Author: Daisuke Maruyama
7
+ Author URI: http://marubon.info/
8
+ License: GPL2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; either version 2
18
+ of the License, or (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ */
29
+
30
+ /**
31
+ * SCC_Share_Pinterest_Crawl_Strategy
32
+ */
33
+ class SCC_Share_Pinterest_Crawl_Strategy extends SCC_Crawl_Strategy {
34
+
35
+ /**
36
+ * SNS base URL
37
+ *
38
+ * @var string
39
+ */
40
+ const DEF_BASE_URL = 'https://api.pinterest.com/v1/urls/count.json';
41
+
42
+ /**
43
+ * Class constarctor
44
+ * Hook onto all of the actions and filters needed by the plugin.
45
+ */
46
+ protected function __construct() {
47
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
48
+
49
+ $this->http_method = 'GET';
50
+ }
51
+
52
+ /**
53
+ * Initialization
54
+ *
55
+ * @param array $options Option.
56
+ * @return void
57
+ */
58
+ public function initialize( $options = array() ) {
59
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
60
+
61
+ $this->set_parameters( $options );
62
+ }
63
+
64
+ /**
65
+ * Build request header
66
+ *
67
+ * @return array
68
+ */
69
+ public function build_request_header() {
70
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
71
+ return null;
72
+ }
73
+
74
+ /**
75
+ * Build request body
76
+ *
77
+ * @return array
78
+ */
79
+ public function build_request_body() {
80
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
81
+ return null;
82
+ }
83
+
84
+ /**
85
+ * Build request URL
86
+ *
87
+ * @return string
88
+ */
89
+ public function build_request_url() {
90
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
91
+
92
+ $url = self::DEF_BASE_URL . '?' . http_build_query( $this->query_parameters , '' , '&' );
93
+
94
+ return $url;
95
+ }
96
+
97
+ /**
98
+ * Extract response body
99
+ *
100
+ * @param array $content Content.
101
+ * @return array
102
+ */
103
+ public function extract_response_body( $content ) {
104
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
105
+
106
+ $count = (int) -1;
107
+
108
+ if ( isset( $content['body'] ) && empty( $content['error'] ) ) {
109
+
110
+ $data = rtrim( $content['body'], ');' );
111
+ $data = ltrim( $data, 'receiveCount(' );
112
+
113
+ $json = json_decode( $data, true );
114
+
115
+ if ( isset( $json['count'] ) && is_numeric( $json['count'] ) ) {
116
+ $count = (int) $json['count'];
117
+ } else {
118
+ $count = (int) -1;
119
+ }
120
+ } else {
121
+ $count = (int) -1;
122
+
123
+ if ( isset( $content['error'] ) ) {
124
+ SCC_Logger::log( $content['error'] );
125
+ }
126
+ }
127
+
128
+ return $count;
129
+ }
130
+
131
+ /**
132
+ * Extract response header
133
+ *
134
+ * @param array $content Content.
135
+ * @return array
136
+ */
137
+ public function extract_response_header( $content ) {
138
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
139
+ return null;
140
+ }
141
+
142
+ /**
143
+ * Set parameter
144
+ *
145
+ * @param string $key Key.
146
+ * @param string $value Value.
147
+ * @return void
148
+ */
149
+ public function set_parameter( $key, $value ) {
150
+ if ( 'url' === $key ) {
151
+ $this->query_parameters[ $key ] = $value;
152
+ }
153
+ }
154
+
155
+ /**
156
+ * Check if required paramters are included or not.
157
+ *
158
+ * @return boolean
159
+ */
160
+ public function check_configuration() {
161
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
162
+
163
+ if ( ! empty( $this->query_parameters['url'] ) ) {
164
+ return true;
165
+ } else {
166
+ return false;
167
+ }
168
+ }
169
+
170
+ /**
171
+ * Check if there is rate limiting or not.
172
+ *
173
+ * @param string $content Content.
174
+ * @return boolean
175
+ */
176
+ public function check_rate_limiting( $content ) {
177
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
178
+
179
+ return true;
180
+ }
181
+
182
+ }
includes/class-scc-share-pinterest-strategy.php DELETED
@@ -1,134 +0,0 @@
1
- <?php
2
- /*
3
- class-scc-share-pinterest-strategy.php
4
-
5
- Description: This class is abstract class of a data crawler
6
- Author: Daisuke Maruyama
7
- Author URI: http://marubon.info/
8
- License: GPL2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
-
12
- /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
-
15
- This program is free software; you can redistribute it and/or
16
- modify it under the terms of the GNU General Public License
17
- as published by the Free Software Foundation; either version 2
18
- of the License, or (at your option) any later version.
19
-
20
- This program is distributed in the hope that it will be useful,
21
- but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- GNU General Public License for more details.
24
-
25
- You should have received a copy of the GNU General Public License
26
- along with this program; if not, write to the Free Software
27
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
- */
29
-
30
- class SCC_Share_Pinterest_Strategy extends SCC_Crawl_Strategy {
31
-
32
- /**
33
- * SNS base url
34
- */
35
- const DEF_BASE_URL = 'https://api.pinterest.com/v1/urls/count.json';
36
-
37
- /**
38
- * Class constarctor
39
- * Hook onto all of the actions and filters needed by the plugin.
40
- *
41
- */
42
- protected function __construct() {
43
- SCC_Common_Util::log('[' . __METHOD__ . '] (line='. __LINE__ . ')');
44
-
45
- $this->method = 'GET';
46
- }
47
-
48
- /**
49
- * Initialization
50
- *
51
- * @since 0.9.0
52
- */
53
- public function initialize( $options = array() ) {
54
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
55
-
56
- if ( isset( $options['url'] ) ) $this->url = $options['url'];
57
- if ( isset( $options['method'] ) ) $this->method = $options['method'];
58
- if ( isset( $options['parameters'] ) ) $this->parameters = $options['parameters'];
59
- }
60
-
61
- /**
62
- * Build header
63
- *
64
- * @since 0.9.0
65
- */
66
- public function build_header() {
67
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
68
- return null;
69
- }
70
-
71
- /**
72
- * Build query url
73
- *
74
- * @since 0.9.0
75
- */
76
- public function build_query_url() {
77
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
78
-
79
- $url = self::DEF_BASE_URL . '?' . http_build_query( $this->query_parameters , '' , '&' );
80
-
81
- return $url;
82
- }
83
-
84
- /**
85
- * Extract count
86
- *
87
- * @since 0.9.0
88
- */
89
- public function extract_count( $content ) {
90
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
91
-
92
- $count = (int) -1;
93
-
94
- if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
95
-
96
- $data = rtrim( $content['data'], ');' );
97
- $data = ltrim( $data, 'receiveCount(' );
98
-
99
- $json = json_decode( $data, true );
100
-
101
- if ( isset( $json['count'] ) && is_numeric( $json['count'] ) ) {
102
- $count = (int) $json['count'];
103
- } else {
104
- $count = (int) -1;
105
- }
106
- } else {
107
- $count = (int) -1;
108
- }
109
-
110
- return $count;
111
- }
112
-
113
- public function set_query_parameter( $key, $value ) {
114
- if ( $key === 'url' ) {
115
- $this->query_parameters[$key] = $value;
116
- }
117
- }
118
-
119
- /**
120
- * Check if required paramters are included or not.
121
- *
122
- * @since 0.9.0
123
- */
124
- public function check_configuration() {
125
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
126
-
127
- if ( isset( $this->query_parameters['url'] ) && $this->query_parameters['url'] ) {
128
- return true;
129
- } else {
130
- return false;
131
- }
132
- }
133
-
134
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-scc-share-pocket-crawl-strategy.php ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ class-scc-share-pocket-crawl-strategy.php
4
+
5
+ Description: This class is abstract class of a data crawler
6
+ Author: Daisuke Maruyama
7
+ Author URI: http://marubon.info/
8
+ License: GPL2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; either version 2
18
+ of the License, or (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ */
29
+
30
+ /**
31
+ * SCC_Share_Pocket_Crawl_Strateg
32
+ */
33
+ class SCC_Share_Pocket_Crawl_Strategy extends SCC_Crawl_Strategy {
34
+
35
+ /**
36
+ * SNS base URL
37
+ *
38
+ * @var string
39
+ */
40
+ const DEF_BASE_URL = 'http://widgets.getpocket.com/v1/button';
41
+
42
+ /**
43
+ * Class constarctor
44
+ * Hook onto all of the actions and filters needed by the plugin.
45
+ */
46
+ protected function __construct() {
47
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
48
+
49
+ $this->http_method = 'GET';
50
+ $this->query_parameters['v'] = '1';
51
+ $this->query_parameters['count'] = 'horizontal';
52
+ }
53
+
54
+ /**
55
+ * Initialization
56
+ *
57
+ * @param array $options Option.
58
+ * @return void
59
+ */
60
+ public function initialize( $options = array() ) {
61
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
62
+
63
+ $this->set_parameters( $options );
64
+ }
65
+
66
+ /**
67
+ * Build request header
68
+ *
69
+ * @return array
70
+ */
71
+ public function build_request_header() {
72
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
73
+ return null;
74
+ }
75
+
76
+ /**
77
+ * Build request body
78
+ *
79
+ * @return array
80
+ */
81
+ public function build_request_body() {
82
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
83
+ return null;
84
+ }
85
+
86
+ /**
87
+ * Build request URL
88
+ *
89
+ * @return string
90
+ */
91
+ public function build_request_url() {
92
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
93
+
94
+ $url = self::DEF_BASE_URL . '?' . http_build_query( $this->query_parameters , '' , '&' );
95
+
96
+ return $url;
97
+ }
98
+
99
+ /**
100
+ * Extract response body
101
+ *
102
+ * @param array $content Content.
103
+ * @return array
104
+ */
105
+ public function extract_response_body( $content ) {
106
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
107
+
108
+ $count = (int) -1;
109
+
110
+ if ( isset( $content['body'] ) && empty( $content['error'] ) ) {
111
+
112
+ $return_code = preg_match( '/<em\sid=\"cnt\">([0-9]+)<\/em>/i', $content['body'], $matches );
113
+
114
+ if ( $return_code && isset( $matches[1] ) && is_numeric( $matches[1] ) ) {
115
+ $count = (int) $matches[1];
116
+ } else {
117
+ $count = (int) -1;
118
+ }
119
+ } else {
120
+ $count = (int) -1;
121
+
122
+ if ( isset( $content['error'] ) ) {
123
+ SCC_Logger::log( $content['error'] );
124
+ }
125
+ }
126
+
127
+ return $count;
128
+ }
129
+
130
+ /**
131
+ * Extract response header
132
+ *
133
+ * @param array $content Content.
134
+ * @return array
135
+ */
136
+ public function extract_response_header( $content ) {
137
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
138
+ return null;
139
+ }
140
+
141
+ /**
142
+ * Set parameter
143
+ *
144
+ * @param string $key Key.
145
+ * @param string $value Value.
146
+ * @return void
147
+ */
148
+ public function set_parameter( $key, $value ) {
149
+ if ( 'url' === $key ) {
150
+ $this->query_parameters['url'] = $value;
151
+ $this->query_parameters['src'] = $value;
152
+ } elseif ( 'title' === $key ) {
153
+ $this->query_parameters[ $key ] = $value;
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Check if required paramters are included or not.
159
+ *
160
+ * @return boolean
161
+ */
162
+ public function check_configuration() {
163
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
164
+
165
+ if ( ! empty( $this->query_parameters['url'] ) ) {
166
+ return true;
167
+ } else {
168
+ return false;
169
+ }
170
+ }
171
+
172
+ /**
173
+ * Check if there is rate limiting or not.
174
+ *
175
+ * @param string $content Content.
176
+ * @return boolean
177
+ */
178
+ public function check_rate_limiting( $content ) {
179
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
180
+
181
+ return true;
182
+ }
183
+
184
+ }
includes/class-scc-share-pocket-strategy.php DELETED
@@ -1,138 +0,0 @@
1
- <?php
2
- /*
3
- class-scc-share-pocket-strategy.php
4
-
5
- Description: This class is abstract class of a data crawler
6
- Author: Daisuke Maruyama
7
- Author URI: http://marubon.info/
8
- License: GPL2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
-
12
- /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
-
15
- This program is free software; you can redistribute it and/or
16
- modify it under the terms of the GNU General Public License
17
- as published by the Free Software Foundation; either version 2
18
- of the License, or (at your option) any later version.
19
-
20
- This program is distributed in the hope that it will be useful,
21
- but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- GNU General Public License for more details.
24
-
25
- You should have received a copy of the GNU General Public License
26
- along with this program; if not, write to the Free Software
27
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
- */
29
-
30
- class SCC_Share_Pocket_Strategy extends SCC_Crawl_Strategy {
31
-
32
- /**
33
- * SNS base url
34
- */
35
- const DEF_BASE_URL = 'http://widgets.getpocket.com/v1/button';
36
-
37
- /**
38
- * Class constarctor
39
- * Hook onto all of the actions and filters needed by the plugin.
40
- *
41
- */
42
- protected function __construct() {
43
- SCC_Common_Util::log('[' . __METHOD__ . '] (line='. __LINE__ . ')');
44
-
45
- $this->method = 'GET';
46
- $this->query_parameters['v'] = '1';
47
- $this->query_parameters['count'] = 'horizontal';
48
- //$this->query_parameters['title'] = 'hoge';
49
- //$this->query_parameters['src'] = 'hoge';
50
- }
51
-
52
- /**
53
- * Initialization
54
- *
55
- * @since 0.9.0
56
- */
57
- public function initialize( $options = array() ) {
58
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
59
-
60
- if ( isset( $options['url'] ) ) $this->url = $options['url'];
61
- if ( isset( $options['method'] ) ) $this->method = $options['method'];
62
- if ( isset( $options['parameters'] ) ) $this->parameters = $options['parameters'];
63
- }
64
-
65
- /**
66
- * Build header
67
- *
68
- * @since 0.9.0
69
- */
70
- public function build_header() {
71
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
72
- return null;
73
- }
74
-
75
- /**
76
- * Build query url
77
- *
78
- * @since 0.9.0
79
- */
80
- public function build_query_url() {
81
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
82
-
83
- $url = self::DEF_BASE_URL . '?' . http_build_query( $this->query_parameters , '' , '&' );
84
-
85
- return $url;
86
- }
87
-
88
- /**
89
- * Extract count
90
- *
91
- * @since 0.9.0
92
- */
93
- public function extract_count( $content ) {
94
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
95
-
96
- $count = (int) -1;
97
-
98
- if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
99
-
100
- $return_code = preg_match( '/<em\sid=\"cnt\">([0-9]+)<\/em>/i', $content['data'], $matches );
101
-
102
- if ( $return_code && isset( $matches[1] ) && is_numeric( $matches[1] ) ) {
103
- $count = (int) $matches[1];
104
- } else {
105
- $count = (int) -1;
106
- }
107
- } else {
108
- $count = (int) -1;
109
- }
110
-
111
- return $count;
112
- }
113
-
114
- public function set_query_parameter( $key, $value ) {
115
- if ( $key === 'url' ) {
116
- $this->query_parameters['url'] = $value;
117
- $this->query_parameters['src'] = $value;
118
- } elseif ( $key === 'title' ) {
119
- $this->query_parameters[$key] = $value;
120
- }
121
- }
122
-
123
- /**
124
- * Check if required paramters are included or not.
125
- *
126
- * @since 0.9.0
127
- */
128
- public function check_configuration() {
129
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
130
-
131
- if ( isset( $this->query_parameters['url'] ) && $this->query_parameters['url'] ) {
132
- return true;
133
- } else {
134
- return false;
135
- }
136
- }
137
-
138
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-scc-share-restore-cache-engine.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-share-restore-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch restore cache data from second cache.
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,6 +27,9 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  class SCC_Share_Restore_Cache_Engine extends SCC_Cache_Engine {
31
 
32
  /**
@@ -56,31 +59,40 @@ class SCC_Share_Restore_Cache_Engine extends SCC_Cache_Engine {
56
 
57
  /**
58
  * Interval cheking and caching target data
 
 
59
  */
60
  private $check_interval = 600;
61
 
62
  /**
63
  * Number of posts to check at a time
 
 
64
  */
65
  private $posts_per_check = 20;
66
 
67
  /**
68
  * Latency suffix
 
 
69
  */
70
  private $check_latency = 10;
71
 
72
  /**
73
  * Cache post types
 
 
74
  */
75
  private $post_types = array( 'post', 'page' );
76
 
77
  /**
78
  * Initialization
79
  *
80
- * @since 0.1.1
 
81
  */
82
  public function initialize( $options = array() ) {
83
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
84
 
85
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
86
  $this->prime_cron = self::DEF_PRIME_CRON;
@@ -88,13 +100,33 @@ class SCC_Share_Restore_Cache_Engine extends SCC_Cache_Engine {
88
  $this->event_schedule = self::DEF_EVENT_SCHEDULE;
89
  $this->event_description = self::DEF_EVENT_DESCRIPTION;
90
 
91
- if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
92
- if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
93
- if ( isset( $options['posts_per_check'] ) ) $this->posts_per_check = $options['posts_per_check'];
94
- if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
95
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
96
- if ( isset( $options['check_latency'] ) ) $this->check_latency = $options['check_latency'];
97
- if ( isset( $options['post_types'] ) ) $this->post_types = $options['post_types'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
 
99
  add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 1 );
100
  }
@@ -102,70 +134,73 @@ class SCC_Share_Restore_Cache_Engine extends SCC_Cache_Engine {
102
  /**
103
  * Register base schedule for this engine
104
  *
105
- * @since 0.1.0
106
  */
107
  public function register_schedule() {
108
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
109
  }
110
 
111
  /**
112
  * Unregister base schedule for this engine
113
  *
114
- * @since 0.1.0
115
  */
116
  public function unregister_schedule() {
117
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
118
 
119
- SCC_WP_Cron_Util::clear_scheduled_hook( $this->execute_cron );
120
  }
121
 
122
  /**
123
- * Schedule data retrieval and cache processing
124
  *
125
- * @since 0.2.0
 
126
  */
127
- public function prime_cache( $post_ID ) {
128
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
129
 
130
  $next_exec_time = (int) current_time( 'timestamp', 1 ) + $this->check_latency;
131
 
132
- SCC_Common_Util::log( '[' . __METHOD__ . '] check_latency: ' . $this->check_latency );
133
- SCC_Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
134
 
135
- wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( $post_ID ) );
136
  }
137
 
138
  /**
139
- * Get and cache data of each published post
140
  *
141
- * @since 0.2.0
 
142
  */
143
- public function execute_cache( $post_ID ) {
144
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
145
 
146
  $cache_expiration = $this->get_cache_expiration();
147
 
148
- SCC_Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
149
 
150
- $transient_id = $this->get_cache_key( $post_ID );
151
 
152
  $options = array(
153
  'cache_key' => $transient_id,
154
- 'post_id' => $post_ID,
155
  'target_sns' => $this->target_sns,
156
- 'cache_expiration' => $cache_expiration
157
- );
158
 
159
  $this->cache( $options );
160
  }
161
 
162
  /**
163
- * Get and cache data for a given post
164
  *
165
- * @since 0.1.1
 
166
  */
167
  public function cache( $options = array() ) {
168
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
169
 
170
  $transient_id = $options['cache_key'];
171
  $target_sns = $options['target_sns'];
@@ -174,18 +209,18 @@ class SCC_Share_Restore_Cache_Engine extends SCC_Cache_Engine {
174
 
175
  $sns_counts = array();
176
 
177
- if ( $post_id !== 'home' ) {
178
  foreach ( $target_sns as $sns => $active ) {
179
  if ( $active ) {
180
  $meta_key = $this->get_cache_key( $sns );
181
 
182
  $sns_count = get_post_meta( $post_id, $meta_key, true );
183
 
184
- if ( isset( $sns_count ) && $sns_count !== '' ) {
185
  if ( is_numeric( $sns_count ) ) {
186
- $sns_counts[$sns] = (int) $sns_count;
187
  } else {
188
- $sns_counts[$sns] = $sns_count;
189
  }
190
  } else {
191
 
@@ -195,11 +230,13 @@ class SCC_Share_Restore_Cache_Engine extends SCC_Cache_Engine {
195
  } else {
196
  $option_key = $this->get_cache_key( 'home' );
197
 
198
- if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
 
 
199
  } else {
200
  foreach ( $this->share_base_cache_target as $sns => $active ) {
201
  if ( $active ) {
202
- $sns_counts[$sns] = (int) -1;
203
  }
204
  }
205
  }
@@ -211,14 +248,14 @@ class SCC_Share_Restore_Cache_Engine extends SCC_Cache_Engine {
211
  /**
212
  * Get cache expiration based on current number of total post and page
213
  *
214
- * @since 0.1.1
215
  */
216
  protected function get_cache_expiration() {
217
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
218
 
219
  $posts_total = $this->get_posts_total();
220
 
221
- SCC_Common_Util::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
222
 
223
  return ceil( $posts_total / $this->posts_per_check ) * $this->check_interval * 3;
224
  }
@@ -226,17 +263,17 @@ class SCC_Share_Restore_Cache_Engine extends SCC_Cache_Engine {
226
  /**
227
  * Get total count of current published post and page
228
  *
229
- * @since 0.1.0
230
  */
231
  private function get_posts_total() {
232
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
233
 
234
  $query_args = array(
235
  'post_type' => $this->post_types,
236
  'post_status' => 'publish',
237
  'nopaging' => true,
238
  'update_post_term_cache' => false,
239
- 'update_post_meta_cache' => false
240
  );
241
 
242
  $posts_query = new WP_Query( $query_args );
@@ -245,27 +282,28 @@ class SCC_Share_Restore_Cache_Engine extends SCC_Cache_Engine {
245
  }
246
 
247
  /**
248
- * Initialize meta key for ranking
249
  *
250
- * @since 0.3.0
251
  */
252
  public function initialize_cache() {
253
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
254
  }
255
 
256
  /**
257
- * Clear meta key for ranking
258
  *
259
- * @since 0.3.0
260
  */
261
  public function clear_cache() {
262
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
263
  }
264
 
265
  /**
266
  * Get cache
267
  *
268
- * @since 0.10.1
 
269
  */
270
  public function get_cache( $options = array() ) {
271
  $target_sns = $options['target_sns'];
@@ -273,18 +311,18 @@ class SCC_Share_Restore_Cache_Engine extends SCC_Cache_Engine {
273
 
274
  $sns_counts = array();
275
 
276
- if ( $post_id !== 'home' ) {
277
  foreach ( $target_sns as $sns => $active ) {
278
  if ( $active ) {
279
  $meta_key = $this->get_cache_key( $sns );
280
 
281
  $sns_count = get_post_meta( $post_id, $meta_key, true );
282
 
283
- if ( isset( $sns_count ) && $sns_count !== '' ) {
284
  if ( is_numeric( $sns_count ) ) {
285
- $sns_counts[$sns] = (int) $sns_count;
286
  } else {
287
- $sns_counts[$sns] = $sns_count;
288
  }
289
  } else {
290
 
@@ -294,11 +332,13 @@ class SCC_Share_Restore_Cache_Engine extends SCC_Cache_Engine {
294
  } else {
295
  $option_key = $this->get_cache_key( 'home' );
296
 
297
- if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
 
 
298
  } else {
299
  foreach ( $this->share_base_cache_target as $sns => $active ) {
300
  if ( $active ) {
301
- $sns_counts[$sns] = (int) -1;
302
  }
303
  }
304
  }
1
  <?php
2
+ /**
3
  class-scc-share-restore-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch restore cache data from second cache.
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Share_Restore_Cache_Engine
32
+ */
33
  class SCC_Share_Restore_Cache_Engine extends SCC_Cache_Engine {
34
 
35
  /**
59
 
60
  /**
61
  * Interval cheking and caching target data
62
+ *
63
+ * @var integer
64
  */
65
  private $check_interval = 600;
66
 
67
  /**
68
  * Number of posts to check at a time
69
+ *
70
+ * @var integer
71
  */
72
  private $posts_per_check = 20;
73
 
74
  /**
75
  * Latency suffix
76
+ *
77
+ * @var integer
78
  */
79
  private $check_latency = 10;
80
 
81
  /**
82
  * Cache post types
83
+ *
84
+ * @var array
85
  */
86
  private $post_types = array( 'post', 'page' );
87
 
88
  /**
89
  * Initialization
90
  *
91
+ * @param array $options Option.
92
+ * @return void
93
  */
94
  public function initialize( $options = array() ) {
95
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
96
 
97
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
98
  $this->prime_cron = self::DEF_PRIME_CRON;
100
  $this->event_schedule = self::DEF_EVENT_SCHEDULE;
101
  $this->event_description = self::DEF_EVENT_DESCRIPTION;
102
 
103
+ if ( isset( $options['target_sns'] ) ) {
104
+ $this->target_sns = $options['target_sns'];
105
+ }
106
+
107
+ if ( isset( $options['check_interval'] ) ) {
108
+ $this->check_interval = $options['check_interval'];
109
+ }
110
+
111
+ if ( isset( $options['posts_per_check'] ) ) {
112
+ $this->posts_per_check = $options['posts_per_check'];
113
+ }
114
+
115
+ if ( isset( $options['cache_prefix'] ) ) {
116
+ $this->cache_prefix = $options['cache_prefix'];
117
+ }
118
+
119
+ if ( isset( $options['execute_cron'] ) ) {
120
+ $this->execute_cron = $options['execute_cron'];
121
+ }
122
+
123
+ if ( isset( $options['check_latency'] ) ) {
124
+ $this->check_latency = $options['check_latency'];
125
+ }
126
+
127
+ if ( isset( $options['post_types'] ) ) {
128
+ $this->post_types = $options['post_types'];
129
+ }
130
 
131
  add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 1 );
132
  }
134
  /**
135
  * Register base schedule for this engine
136
  *
137
+ * @return void
138
  */
139
  public function register_schedule() {
140
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
141
  }
142
 
143
  /**
144
  * Unregister base schedule for this engine
145
  *
146
+ * @return void
147
  */
148
  public function unregister_schedule() {
149
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
150
 
151
+ SCC_WP_Cron::clear_scheduled_hook( $this->execute_cron );
152
  }
153
 
154
  /**
155
+ * Schedule cache restoring
156
  *
157
+ * @param string $post_id Post ID.
158
+ * @return void
159
  */
160
+ public function prime_cache( $post_id ) {
161
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
162
 
163
  $next_exec_time = (int) current_time( 'timestamp', 1 ) + $this->check_latency;
164
 
165
+ SCC_Logger::log( '[' . __METHOD__ . '] check_latency: ' . $this->check_latency );
166
+ SCC_Logger::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
167
 
168
+ wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( $post_id ) );
169
  }
170
 
171
  /**
172
+ * Restore cache
173
  *
174
+ * @param string $post_id Post ID,
175
+ * @return array
176
  */
177
+ public function execute_cache( $post_id ) {
178
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
179
 
180
  $cache_expiration = $this->get_cache_expiration();
181
 
182
+ SCC_Logger::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
183
 
184
+ $transient_id = $this->get_cache_key( $post_id );
185
 
186
  $options = array(
187
  'cache_key' => $transient_id,
188
+ 'post_id' => $post_id,
189
  'target_sns' => $this->target_sns,
190
+ 'cache_expiration' => $cache_expiration,
191
+ );
192
 
193
  $this->cache( $options );
194
  }
195
 
196
  /**
197
+ * Restore cache
198
  *
199
+ * @param array $options Option.
200
+ * @return void
201
  */
202
  public function cache( $options = array() ) {
203
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
204
 
205
  $transient_id = $options['cache_key'];
206
  $target_sns = $options['target_sns'];
209
 
210
  $sns_counts = array();
211
 
212
+ if ( 'home' !== $post_id ) {
213
  foreach ( $target_sns as $sns => $active ) {
214
  if ( $active ) {
215
  $meta_key = $this->get_cache_key( $sns );
216
 
217
  $sns_count = get_post_meta( $post_id, $meta_key, true );
218
 
219
+ if ( isset( $sns_count ) && '' !== $sns_count ) {
220
  if ( is_numeric( $sns_count ) ) {
221
+ $sns_counts[ $sns ] = (int) $sns_count;
222
  } else {
223
+ $sns_counts[ $sns ] = $sns_count;
224
  }
225
  } else {
226
 
230
  } else {
231
  $option_key = $this->get_cache_key( 'home' );
232
 
233
+ $sns_counts = get_option( $option_key );
234
+
235
+ if ( false !== $sns_counts ) {
236
  } else {
237
  foreach ( $this->share_base_cache_target as $sns => $active ) {
238
  if ( $active ) {
239
+ $sns_counts[ $sns ] = (int) -1;
240
  }
241
  }
242
  }
248
  /**
249
  * Get cache expiration based on current number of total post and page
250
  *
251
+ * @return integer
252
  */
253
  protected function get_cache_expiration() {
254
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
255
 
256
  $posts_total = $this->get_posts_total();
257
 
258
+ SCC_Logger::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
259
 
260
  return ceil( $posts_total / $this->posts_per_check ) * $this->check_interval * 3;
261
  }
263
  /**
264
  * Get total count of current published post and page
265
  *
266
+ * @return integer
267
  */
268
  private function get_posts_total() {
269
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
270
 
271
  $query_args = array(
272
  'post_type' => $this->post_types,
273
  'post_status' => 'publish',
274
  'nopaging' => true,
275
  'update_post_term_cache' => false,
276
+ 'update_post_meta_cache' => false,
277
  );
278
 
279
  $posts_query = new WP_Query( $query_args );
282
  }
283
 
284
  /**
285
+ * Initialize cache
286
  *
287
+ * @return void
288
  */
289
  public function initialize_cache() {
290
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
291
  }
292
 
293
  /**
294
+ * Clear cache
295
  *
296
+ * @return void
297
  */
298
  public function clear_cache() {
299
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
300
  }
301
 
302
  /**
303
  * Get cache
304
  *
305
+ * @param array $options Option.
306
+ * @return array
307
  */
308
  public function get_cache( $options = array() ) {
309
  $target_sns = $options['target_sns'];
311
 
312
  $sns_counts = array();
313
 
314
+ if ( 'home' !== $post_id ) {
315
  foreach ( $target_sns as $sns => $active ) {
316
  if ( $active ) {
317
  $meta_key = $this->get_cache_key( $sns );
318
 
319
  $sns_count = get_post_meta( $post_id, $meta_key, true );
320
 
321
+ if ( isset( $sns_count ) && '' !== $sns_count ) {
322
  if ( is_numeric( $sns_count ) ) {
323
+ $sns_counts[ $sns ] = (int) $sns_count;
324
  } else {
325
+ $sns_counts[ $sns ] = $sns_count;
326
  }
327
  } else {
328
 
332
  } else {
333
  $option_key = $this->get_cache_key( 'home' );
334
 
335
+ $sns_counts = get_option( $option_key );
336
+
337
+ if ( false !== $sns_counts ) {
338
  } else {
339
  foreach ( $this->share_base_cache_target as $sns => $active ) {
340
  if ( $active ) {
341
+ $sns_counts[ $sns ] = (int) -1;
342
  }
343
  }
344
  }
includes/class-scc-share-rush-cache-engine.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-share-rush-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,6 +27,9 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  class SCC_Share_Rush_Cache_Engine extends SCC_Share_Cache_Engine {
31
 
32
  /**
@@ -56,36 +59,47 @@ class SCC_Share_Rush_Cache_Engine extends SCC_Share_Cache_Engine {
56
 
57
  /**
58
  * Cache post types
 
 
59
  */
60
  private $post_types = array( 'post', 'page' );
61
 
62
  /**
63
  * Interval cheking and caching target data
 
 
64
  */
65
  private $check_interval = 600;
66
 
67
  /**
68
  * Number of posts to check at a time
 
 
69
  */
70
  private $posts_per_check = 20;
71
 
72
  /**
73
  * Offset suffix
 
 
74
  */
75
  private $offset_suffix = 'rush_offset';
76
 
77
  /**
78
  * Term considered as new content
 
 
79
  */
80
  private $new_content_term = 3;
81
 
82
  /**
83
  * Initialization
84
  *
85
- * @since 0.1.1
 
86
  */
87
  public function initialize( $options = array() ) {
88
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
89
 
90
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
91
  $this->prime_cron = self::DEF_PRIME_CRON;
@@ -95,24 +109,77 @@ class SCC_Share_Rush_Cache_Engine extends SCC_Share_Cache_Engine {
95
 
96
  $this->load_ratio = 0.5;
97
 
98
- if ( isset( $options['delegate'] ) ) $this->delegate = $options['delegate'];
99
- if ( isset( $options['crawler'] ) ) $this->crawler = $options['crawler'];
100
- if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
101
- if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
102
- if ( isset( $options['posts_per_check'] ) ) $this->posts_per_check = $options['posts_per_check'];
103
- if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
104
- if ( isset( $options['prime_cron'] ) ) $this->prime_cron = $options['prime_cron'];
105
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
106
- if ( isset( $options['event_schedule'] ) ) $this->event_schedule = $options['event_schedule'];
107
- if ( isset( $options['event_description'] ) ) $this->event_description = $options['event_description'];
108
- if ( isset( $options['post_types'] ) ) $this->post_types = $options['post_types'];
109
- if ( isset( $options['new_content_term'] ) ) $this->new_content_term = $options['new_content_term'];
110
- if ( isset( $options['scheme_migration_mode'] ) ) $this->scheme_migration_mode = $options['scheme_migration_mode'];
111
- if ( isset( $options['scheme_migration_date'] ) ) $this->scheme_migration_date = $options['scheme_migration_date'];
112
- if ( isset( $options['scheme_migration_exclude_keys'] ) ) $this->scheme_migration_exclude_keys = $options['scheme_migration_exclude_keys'];
113
- if ( isset( $options['cache_retry'] ) ) $this->cache_retry = $options['cache_retry'];
114
- if ( isset( $options['retry_limit'] ) ) $this->retry_limit = $options['retry_limit'];
115
- if ( isset( $options['fault_tolerance'] ) ) $this->fault_tolerance = $options['fault_tolerance'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
 
117
  add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
118
  add_action( $this->prime_cron, array( $this, 'prime_cache' ) );
@@ -122,14 +189,15 @@ class SCC_Share_Rush_Cache_Engine extends SCC_Share_Cache_Engine {
122
  /**
123
  * Register event schedule for this engine
124
  *
125
- * @since 0.1.0
 
126
  */
127
  public function schedule_check_interval( $schedules ) {
128
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
129
 
130
  $schedules[$this->event_schedule] = array(
131
  'interval' => $this->check_interval,
132
- 'display' => $this->event_description
133
  );
134
 
135
  return $schedules;
@@ -138,28 +206,30 @@ class SCC_Share_Rush_Cache_Engine extends SCC_Share_Cache_Engine {
138
  /**
139
  * Schedule data retrieval and cache processing
140
  *
141
- * @since 0.2.0
142
  */
143
  public function prime_cache() {
144
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
145
 
146
  $next_exec_time = (int) current_time( 'timestamp', 1 ) + $this->check_interval;
147
  $posts_total = $this->get_posts_total();
148
 
149
- SCC_Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
150
- SCC_Common_Util::log( '[' . __METHOD__ . '] posts_per_check: ' . $this->posts_per_check );
151
- SCC_Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
152
- SCC_Common_Util::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
153
 
154
- $option_key = $this->get_cache_key($this->offset_suffix);
155
 
156
- if ( false === ( $posts_offset = get_option( $option_key ) ) ) {
 
 
157
  $posts_offset = 0;
158
  }
159
 
160
- SCC_Common_Util::log( '[' . __METHOD__ . '] posts_offset: ' . $posts_offset );
161
 
162
- wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( (int) $posts_offset, SCC_Common_Util::short_hash( $next_exec_time ) ) );
163
 
164
  $posts_offset = $posts_offset + $this->posts_per_check;
165
 
@@ -173,22 +243,23 @@ class SCC_Share_Rush_Cache_Engine extends SCC_Share_Cache_Engine {
173
  /**
174
  * Get and cache data of each published post and page
175
  *
176
- * @since 0.2.0
 
177
  */
178
  public function execute_cache( $posts_offset, $hash ) {
179
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
180
 
181
- SCC_Common_Util::log( '[' . __METHOD__ . '] posts_offset: ' . $posts_offset );
182
- SCC_Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
183
- SCC_Common_Util::log( '[' . __METHOD__ . '] posts_per_check: ' . $this->posts_per_check );
184
 
185
  $cache_expiration = $this->get_cache_expiration();
186
 
187
  $term_threshold = $this->get_new_contet_term();
188
 
189
- SCC_Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
190
 
191
- SCC_Common_Util::log( '[' . __METHOD__ . '] term_threshold: ' . $term_threshold );
192
 
193
  $query_args = array(
194
  'post_type' => $this->post_types,
@@ -197,11 +268,11 @@ class SCC_Share_Rush_Cache_Engine extends SCC_Share_Cache_Engine {
197
  'posts_per_page' => $this->posts_per_check,
198
  'date_query' => array(
199
  'column' => 'post_date_gmt',
200
- 'after' => $term_threshold
201
  ),
202
  'no_found_rows' => true,
203
  'update_post_term_cache' => false,
204
- 'update_post_meta_cache' => false
205
  );
206
 
207
  $posts_query = new WP_Query( $query_args );
@@ -210,23 +281,23 @@ class SCC_Share_Rush_Cache_Engine extends SCC_Share_Cache_Engine {
210
  while ( $posts_query->have_posts() ) {
211
  $posts_query->the_post();
212
 
213
- $post_ID = get_the_ID();
214
 
215
- SCC_Common_Util::log( '[' . __METHOD__ . '] post_id: ' . $post_ID );
216
 
217
- $transient_id = $this->get_cache_key( $post_ID );
218
 
219
- $url = get_permalink( $post_ID );
220
- $title = get_the_title( $post_ID );
221
 
222
  $options = array(
223
  'cache_key' => $transient_id,
224
- 'post_id' => $post_ID,
225
  'target_url' => $url,
226
  'target_sns' => $this->target_sns,
227
  'target_title' => $title,
228
  'publish_date' => get_the_date( 'Y/m/d' ),
229
- 'cache_expiration' => $cache_expiration
230
  );
231
 
232
  // Primary cache
@@ -242,16 +313,16 @@ class SCC_Share_Rush_Cache_Engine extends SCC_Share_Cache_Engine {
242
  /**
243
  * Get term considered as new content
244
  *
245
- * @since 0.4.0
246
  */
247
  private function get_new_contet_term() {
248
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
249
 
250
  $term_threshold = '3 days ago';
251
 
252
- if ( $this->new_content_term > 1 ) {
253
  $term_threshold = $this->new_content_term . ' days ago';
254
- } elseif ( $this->new_content_term == 1 ) {
255
  $term_threshold = $this->new_content_term . ' day ago';
256
  }
257
 
@@ -261,14 +332,14 @@ class SCC_Share_Rush_Cache_Engine extends SCC_Share_Cache_Engine {
261
  /**
262
  * Get cache expiration based on current number of total post and page
263
  *
264
- * @since 0.2.0
265
  */
266
  protected function get_cache_expiration() {
267
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
268
 
269
  $posts_total = $this->get_posts_total();
270
 
271
- SCC_Common_Util::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
272
 
273
  return ceil( $posts_total / $this->posts_per_check ) * $this->check_interval * 3;
274
  }
@@ -276,10 +347,10 @@ class SCC_Share_Rush_Cache_Engine extends SCC_Share_Cache_Engine {
276
  /**
277
  * Get total count of current published post and page
278
  *
279
- * @since 0.2.0
280
  */
281
  private function get_posts_total() {
282
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
283
 
284
  $term_threshold = $this->get_new_contet_term();
285
 
@@ -288,12 +359,12 @@ class SCC_Share_Rush_Cache_Engine extends SCC_Share_Cache_Engine {
288
  'post_status' => 'publish',
289
  'date_query' => array(
290
  'column' => 'post_date_gmt',
291
- 'after' => $term_threshold
292
  ),
293
  'nopaging' => true,
294
  'no_found_rows' => true,
295
  'update_post_term_cache' => false,
296
- 'update_post_meta_cache' => false
297
  );
298
 
299
  $posts_query = new WP_Query( $query_args );
@@ -302,12 +373,12 @@ class SCC_Share_Rush_Cache_Engine extends SCC_Share_Cache_Engine {
302
  }
303
 
304
  /**
305
- * Initialize meta key for ranking
306
  *
307
- * @since 0.3.0
308
  */
309
  public function initialize_cache() {
310
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
311
 
312
  $option_key = $this->get_cache_key( $this->offset_suffix );
313
 
@@ -315,12 +386,12 @@ class SCC_Share_Rush_Cache_Engine extends SCC_Share_Cache_Engine {
315
  }
316
 
317
  /**
318
- * Clear meta key for ranking
319
  *
320
- * @since 0.3.0
321
  */
322
  public function clear_cache() {
323
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
324
 
325
  $option_key = $this->get_cache_key( $this->offset_suffix );
326
 
@@ -329,9 +400,10 @@ class SCC_Share_Rush_Cache_Engine extends SCC_Share_Cache_Engine {
329
  }
330
 
331
  /**
332
- * Get current cache
333
  *
334
- * @since 0.9.3
 
335
  */
336
  public function get_cache( $options = array() ) {
337
  $post_id = $options['post_id'];
@@ -340,7 +412,9 @@ class SCC_Share_Rush_Cache_Engine extends SCC_Share_Cache_Engine {
340
 
341
  $sns_counts = array();
342
 
343
- if ( false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
 
 
344
  return $sns_counts;
345
  } else {
346
  return $this->delegate_order( SCC_Order::ORDER_GET_SECOND_CACHE, $options );
1
  <?php
2
+ /**
3
  class-scc-share-rush-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Share_Rush_Cache_Engine
32
+ */
33
  class SCC_Share_Rush_Cache_Engine extends SCC_Share_Cache_Engine {
34
 
35
  /**
59
 
60
  /**
61
  * Cache post types
62
+ *
63
+ * @var array
64
  */
65
  private $post_types = array( 'post', 'page' );
66
 
67
  /**
68
  * Interval cheking and caching target data
69
+ *
70
+ * @var integer
71
  */
72
  private $check_interval = 600;
73
 
74
  /**
75
  * Number of posts to check at a time
76
+ *
77
+ * @var integer
78
  */
79
  private $posts_per_check = 20;
80
 
81
  /**
82
  * Offset suffix
83
+ *
84
+ * @var string
85
  */
86
  private $offset_suffix = 'rush_offset';
87
 
88
  /**
89
  * Term considered as new content
90
+ *
91
+ * @var integer
92
  */
93
  private $new_content_term = 3;
94
 
95
  /**
96
  * Initialization
97
  *
98
+ * @param array $options Option.
99
+ * @return void
100
  */
101
  public function initialize( $options = array() ) {
102
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
103
 
104
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
105
  $this->prime_cron = self::DEF_PRIME_CRON;
109
 
110
  $this->load_ratio = 0.5;
111
 
112
+ if ( isset( $options['delegate'] ) ) {
113
+ $this->delegate = $options['delegate'];
114
+ }
115
+
116
+ if ( isset( $options['crawler'] ) ) {
117
+ $this->crawler = $options['crawler'];
118
+ }
119
+
120
+ if ( isset( $options['target_sns'] ) ) {
121
+ $this->target_sns = $options['target_sns'];
122
+ }
123
+
124
+ if ( isset( $options['check_interval'] ) ) {
125
+ $this->check_interval = $options['check_interval'];
126
+ }
127
+
128
+ if ( isset( $options['posts_per_check'] ) ) {
129
+ $this->posts_per_check = $options['posts_per_check'];
130
+ }
131
+
132
+ if ( isset( $options['cache_prefix'] ) ) {
133
+ $this->cache_prefix = $options['cache_prefix'];
134
+ }
135
+
136
+ if ( isset( $options['prime_cron'] ) ) {
137
+ $this->prime_cron = $options['prime_cron'];
138
+ }
139
+
140
+ if ( isset( $options['execute_cron'] ) ) {
141
+ $this->execute_cron = $options['execute_cron'];
142
+ }
143
+
144
+ if ( isset( $options['event_schedule'] ) ) {
145
+ $this->event_schedule = $options['event_schedule'];
146
+ }
147
+
148
+ if ( isset( $options['event_description'] ) ) {
149
+ $this->event_description = $options['event_description'];
150
+ }
151
+
152
+ if ( isset( $options['post_types'] ) ) {
153
+ $this->post_types = $options['post_types'];
154
+ }
155
+
156
+ if ( isset( $options['new_content_term'] ) ) {
157
+ $this->new_content_term = $options['new_content_term'];
158
+ }
159
+
160
+ if ( isset( $options['scheme_migration_mode'] ) ) {
161
+ $this->scheme_migration_mode = $options['scheme_migration_mode'];
162
+ }
163
+
164
+ if ( isset( $options['scheme_migration_date'] ) ) {
165
+ $this->scheme_migration_date = $options['scheme_migration_date'];
166
+ }
167
+
168
+ if ( isset( $options['scheme_migration_exclude_keys'] ) ) {
169
+ $this->scheme_migration_exclude_keys = $options['scheme_migration_exclude_keys'];
170
+ }
171
+
172
+ if ( isset( $options['cache_retry'] ) ) {
173
+ $this->cache_retry = $options['cache_retry'];
174
+ }
175
+
176
+ if ( isset( $options['retry_limit'] ) ) {
177
+ $this->retry_limit = $options['retry_limit'];
178
+ }
179
+
180
+ if ( isset( $options['fault_tolerance'] ) ) {
181
+ $this->fault_tolerance = $options['fault_tolerance'];
182
+ }
183
 
184
  add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
185
  add_action( $this->prime_cron, array( $this, 'prime_cache' ) );
189
  /**
190
  * Register event schedule for this engine
191
  *
192
+ * @param array $schedules Schedule.
193
+ * @return array
194
  */
195
  public function schedule_check_interval( $schedules ) {
196
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
197
 
198
  $schedules[$this->event_schedule] = array(
199
  'interval' => $this->check_interval,
200
+ 'display' => $this->event_description,
201
  );
202
 
203
  return $schedules;
206
  /**
207
  * Schedule data retrieval and cache processing
208
  *
209
+ * @return void
210
  */
211
  public function prime_cache() {
212
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
213
 
214
  $next_exec_time = (int) current_time( 'timestamp', 1 ) + $this->check_interval;
215
  $posts_total = $this->get_posts_total();
216
 
217
+ SCC_Logger::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
218
+ SCC_Logger::log( '[' . __METHOD__ . '] posts_per_check: ' . $this->posts_per_check );
219
+ SCC_Logger::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
220
+ SCC_Logger::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
221
 
222
+ $option_key = $this->get_cache_key( $this->offset_suffix );
223
 
224
+ $posts_offset = get_option( $option_key );
225
+
226
+ if ( false === $posts_offset ) {
227
  $posts_offset = 0;
228
  }
229
 
230
+ SCC_Logger::log( '[' . __METHOD__ . '] posts_offset: ' . $posts_offset );
231
 
232
+ wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( (int) $posts_offset, SCC_Hash::short_hash( $next_exec_time ) ) );
233
 
234
  $posts_offset = $posts_offset + $this->posts_per_check;
235
 
243
  /**
244
  * Get and cache data of each published post and page
245
  *
246
+ * @param integer $posts_offset Post offset.
247
+ * @return void
248
  */
249
  public function execute_cache( $posts_offset, $hash ) {
250
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
251
 
252
+ SCC_Logger::log( '[' . __METHOD__ . '] posts_offset: ' . $posts_offset );
253
+ SCC_Logger::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
254
+ SCC_Logger::log( '[' . __METHOD__ . '] posts_per_check: ' . $this->posts_per_check );
255
 
256
  $cache_expiration = $this->get_cache_expiration();
257
 
258
  $term_threshold = $this->get_new_contet_term();
259
 
260
+ SCC_Logger::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
261
 
262
+ SCC_Logger::log( '[' . __METHOD__ . '] term_threshold: ' . $term_threshold );
263
 
264
  $query_args = array(
265
  'post_type' => $this->post_types,
268
  'posts_per_page' => $this->posts_per_check,
269
  'date_query' => array(
270
  'column' => 'post_date_gmt',
271
+ 'after' => $term_threshold,
272
  ),
273
  'no_found_rows' => true,
274
  'update_post_term_cache' => false,
275
+ 'update_post_meta_cache' => false,
276
  );
277
 
278
  $posts_query = new WP_Query( $query_args );
281
  while ( $posts_query->have_posts() ) {
282
  $posts_query->the_post();
283
 
284
+ $post_id = get_the_ID();
285
 
286
+ SCC_Logger::log( '[' . __METHOD__ . '] post_id: ' . $post_id );
287
 
288
+ $transient_id = $this->get_cache_key( $post_id );
289
 
290
+ $url = get_permalink( $post_id );
291
+ $title = get_the_title( $post_id );
292
 
293
  $options = array(
294
  'cache_key' => $transient_id,
295
+ 'post_id' => $post_id,
296
  'target_url' => $url,
297
  'target_sns' => $this->target_sns,
298
  'target_title' => $title,
299
  'publish_date' => get_the_date( 'Y/m/d' ),
300
+ 'cache_expiration' => $cache_expiration,
301
  );
302
 
303
  // Primary cache
313
  /**
314
  * Get term considered as new content
315
  *
316
+ * @return string
317
  */
318
  private function get_new_contet_term() {
319
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
320
 
321
  $term_threshold = '3 days ago';
322
 
323
+ if ( 1 < $this->new_content_term ) {
324
  $term_threshold = $this->new_content_term . ' days ago';
325
+ } elseif ( 1 == $this->new_content_term ) {
326
  $term_threshold = $this->new_content_term . ' day ago';
327
  }
328
 
332
  /**
333
  * Get cache expiration based on current number of total post and page
334
  *
335
+ * @return integer
336
  */
337
  protected function get_cache_expiration() {
338
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
339
 
340
  $posts_total = $this->get_posts_total();
341
 
342
+ SCC_Logger::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
343
 
344
  return ceil( $posts_total / $this->posts_per_check ) * $this->check_interval * 3;
345
  }
347
  /**
348
  * Get total count of current published post and page
349
  *
350
+ * @return integer
351
  */
352
  private function get_posts_total() {
353
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
354
 
355
  $term_threshold = $this->get_new_contet_term();
356
 
359
  'post_status' => 'publish',
360
  'date_query' => array(
361
  'column' => 'post_date_gmt',
362
+ 'after' => $term_threshold,
363
  ),
364
  'nopaging' => true,
365
  'no_found_rows' => true,
366
  'update_post_term_cache' => false,
367
+ 'update_post_meta_cache' => false,
368
  );
369
 
370
  $posts_query = new WP_Query( $query_args );
373
  }
374
 
375
  /**
376
+ * Initialize cache
377
  *
378
+ * @return void
379
  */
380
  public function initialize_cache() {
381
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
382
 
383
  $option_key = $this->get_cache_key( $this->offset_suffix );
384
 
386
  }
387
 
388
  /**
389
+ * Clear cache
390
  *
391
+ * @return void
392
  */
393
  public function clear_cache() {
394
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
395
 
396
  $option_key = $this->get_cache_key( $this->offset_suffix );
397
 
400
  }
401
 
402
  /**
403
+ * Get cache
404
  *
405
+ * @param array $options Option.
406
+ * @return array
407
  */
408
  public function get_cache( $options = array() ) {
409
  $post_id = $options['post_id'];
412
 
413
  $sns_counts = array();
414
 
415
+ $sns_counts = get_transient( $transient_id );
416
+
417
+ if ( false !== $sns_counts ) {
418
  return $sns_counts;
419
  } else {
420
  return $this->delegate_order( SCC_Order::ORDER_GET_SECOND_CACHE, $options );
includes/class-scc-share-second-cache-engine.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-share-second-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,6 +27,9 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  class SCC_Share_Second_Cache_Engine extends SCC_Cache_Engine {
31
 
32
  /**
@@ -56,36 +59,47 @@ class SCC_Share_Second_Cache_Engine extends SCC_Cache_Engine {
56
 
57
  /**
58
  * Interval cheking and caching target data
 
 
59
  */
60
  private $check_interval = 600;
61
 
62
  /**
63
  * Number of posts to check at a time
 
 
64
  */
65
  private $posts_per_check = 20;
66
 
67
  /**
68
  * Cache target
 
 
69
  */
70
  private $target_sns = array();
71
 
72
  /**
73
  * Cache post types
 
 
74
  */
75
  private $post_types = array( 'post', 'page' );
76
 
77
  /**
78
  * Crawl date key
 
 
79
  */
80
- private $crawl_date_key = NULL;
81
 
82
  /**
83
  * Initialization
84
  *
85
- * @since 0.1.1
 
86
  */
87
  public function initialize( $options = array() ) {
88
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
89
 
90
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
91
  $this->prime_cron = self::DEF_PRIME_CRON;
@@ -93,17 +107,49 @@ class SCC_Share_Second_Cache_Engine extends SCC_Cache_Engine {
93
  $this->event_schedule = self::DEF_EVENT_SCHEDULE;
94
  $this->event_description = self::DEF_EVENT_DESCRIPTION;
95
 
96
- if ( isset( $options['delegate'] ) ) $this->delegate = $options['delegate'];
97
- if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
98
- if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
99
- if ( isset( $options['posts_per_check'] ) ) $this->posts_per_check = $options['posts_per_check'];
100
- if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
101
- if ( isset( $options['prime_cron'] ) ) $this->prime_cron = $options['prime_cron'];
102
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
103
- if ( isset( $options['event_schedule'] ) ) $this->event_schedule = $options['event_schedule'];
104
- if ( isset( $options['event_description'] ) ) $this->event_description = $options['event_description'];
105
- if ( isset( $options['post_types'] ) ) $this->post_types = $options['post_types'];
106
- if ( isset( $options['crawl_date_key'] ) ) $this->crawl_date_key = $options['crawl_date_key'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
 
108
  add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
109
  add_action( $this->prime_cron, array( $this, 'prime_cache' ) );
@@ -113,14 +159,15 @@ class SCC_Share_Second_Cache_Engine extends SCC_Cache_Engine {
113
  /**
114
  * Register event schedule for this engine
115
  *
116
- * @since 0.1.0
 
117
  */
118
  public function schedule_check_interval( $schedules ) {
119
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
120
 
121
- $schedules[$this->event_schedule] = array(
122
  'interval' => $this->check_interval,
123
- 'display' => $this->event_description
124
  );
125
 
126
  return $schedules;
@@ -129,15 +176,15 @@ class SCC_Share_Second_Cache_Engine extends SCC_Cache_Engine {
129
  /**
130
  * Schedule data retrieval and cache processing
131
  *
132
- * @since 0.3.0
133
  */
134
  public function prime_cache() {
135
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
136
 
137
  $next_exec_time = (int) current_time( 'timestamp', 1 ) + $this->check_interval;
138
 
139
- SCC_Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
140
- SCC_Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
141
 
142
  wp_schedule_single_event( $next_exec_time, $this->execute_cron );
143
  }
@@ -145,17 +192,18 @@ class SCC_Share_Second_Cache_Engine extends SCC_Cache_Engine {
145
  /**
146
  * Get and cache data of each published post and page
147
  *
148
- * @since 0.3.0
 
149
  */
150
  public function execute_cache() {
151
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
152
 
153
  $query_args = array(
154
  'post_type' => $this->post_types,
155
  'post_status' => 'publish',
156
  'nopaging' => true,
157
  'update_post_term_cache' => false,
158
- 'update_post_meta_cache' => false
159
  );
160
 
161
  $posts_query = new WP_Query( $query_args );
@@ -173,7 +221,7 @@ class SCC_Share_Second_Cache_Engine extends SCC_Cache_Engine {
173
  $options = array(
174
  'cache_key' => $transient_id,
175
  'post_id' => $post_id,
176
- 'target_sns' => $this->target_sns
177
  );
178
 
179
  $this->cache( $options );
@@ -186,10 +234,12 @@ class SCC_Share_Second_Cache_Engine extends SCC_Cache_Engine {
186
  /**
187
  * Get and cache data for a given post
188
  *
189
- * @since 0.1.1
 
 
190
  */
191
  public function cache( $options = array() ) {
192
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
193
 
194
  $transient_id = $options['cache_key'];
195
  $target_sns = $options['target_sns'];
@@ -197,22 +247,25 @@ class SCC_Share_Second_Cache_Engine extends SCC_Cache_Engine {
197
 
198
  $sns_counts = array();
199
 
200
- if ( $post_id !== 'home' ) {
201
- if ( false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
 
 
 
202
  foreach ( $target_sns as $sns => $active ) {
203
  if ( $active ) {
204
  $meta_key = $this->get_cache_key( $sns );
205
 
206
  if ( $sns !== $this->crawl_date_key ) {
207
 
208
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
209
- update_post_meta( $post_id, $meta_key, (int) $sns_counts[$sns] );
210
  } else {
211
  update_post_meta( $post_id, $meta_key, (int) -1 );
212
  }
213
  } else {
214
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] !== '' ) {
215
- update_post_meta( $post_id, $meta_key, $sns_counts[$sns] );
216
  } else {
217
  update_post_meta( $post_id, $meta_key, '' );
218
  }
@@ -221,19 +274,21 @@ class SCC_Share_Second_Cache_Engine extends SCC_Cache_Engine {
221
  }
222
  }
223
  } else {
224
- if ( false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
 
 
225
 
226
  $option_key = $this->get_cache_key( 'home' );
227
 
228
  foreach ( $target_sns as $sns => $active ) {
229
  if ( $active ) {
230
  if ( $sns !== $this->crawl_date_key ) {
231
- if ( ! isset( $sns_counts[$sns] ) || $sns_counts[$sns] < 0 ) {
232
- $sns_counts[$sns] = (int) -1;
233
  }
234
  } else {
235
- if ( ! isset( $sns_counts[$sns] ) || $sns_counts[$sns] === '' ) {
236
- $sns_counts[$sns] = '';
237
  }
238
  }
239
  }
@@ -250,21 +305,21 @@ class SCC_Share_Second_Cache_Engine extends SCC_Cache_Engine {
250
  /**
251
  * Get cache expiration based on current number of total post and page
252
  *
253
- * @since 0.2.0
254
  */
255
  protected function get_cache_expiration() {
256
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
257
 
258
  return 0;
259
  }
260
 
261
  /**
262
- * Initialize meta key for ranking
263
  *
264
- * @since 0.3.0
265
  */
266
  public function initialize_cache() {
267
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
268
 
269
  $option_key = $this->get_cache_key( 'home' );
270
 
@@ -272,7 +327,7 @@ class SCC_Share_Second_Cache_Engine extends SCC_Cache_Engine {
272
 
273
  foreach ( $this->target_sns as $sns => $active ) {
274
  if ( $active ) {
275
- $sns_counts[$sns] = (int) -1;
276
  }
277
  }
278
 
@@ -283,7 +338,7 @@ class SCC_Share_Second_Cache_Engine extends SCC_Cache_Engine {
283
  'post_status' => 'publish',
284
  'nopaging' => true,
285
  'update_post_term_cache' => false,
286
- 'update_post_meta_cache' => false
287
  );
288
 
289
  $posts_query = new WP_Query( $query_args );
@@ -309,33 +364,34 @@ class SCC_Share_Second_Cache_Engine extends SCC_Cache_Engine {
309
  /**
310
  * Get cache
311
  *
312
- * @since 0.10.1
 
313
  */
314
  public function get_cache( $options = array() ) {
315
  $post_id = $options['post_id'];
316
  $sns_counts = array();
317
 
318
- if ( $post_id !== 'home' ) {
319
  foreach ( $this->target_sns as $sns => $active ) {
320
  if ( $active ) {
321
  $meta_key = $this->get_cache_key( $sns );
322
- $sns_counts[$sns] = get_post_meta( $post_id, $meta_key, true );
323
  }
324
  }
325
  } else {
326
- $option_key = $this-->get_cache_key( 'home' );
327
  $sns_counts = get_option( $option_key );
328
  }
329
  return $sns_counts;
330
  }
331
 
332
  /**
333
- * Clear meta key for ranking
334
  *
335
- * @since 0.3.0
336
  */
337
  public function clear_cache() {
338
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
339
 
340
  $option_key = $this->get_cache_key( 'home' );
341
  delete_option( $option_key );
@@ -346,15 +402,20 @@ class SCC_Share_Second_Cache_Engine extends SCC_Cache_Engine {
346
  delete_post_meta_by_key( $meta_key );
347
  }
348
  }
 
 
 
 
349
  }
350
 
351
- /**
352
- * Clear meta key for ranking
353
  *
354
- * @since 0.7.0
 
355
  */
356
  public function clear_cache_by_post_id( $post_id ) {
357
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
358
 
359
  foreach ( $this->target_sns as $sns => $active ) {
360
  if ( $active ) {
@@ -363,6 +424,10 @@ class SCC_Share_Second_Cache_Engine extends SCC_Cache_Engine {
363
  }
364
  }
365
 
 
 
 
 
366
  }
367
 
368
  }
1
  <?php
2
+ /**
3
  class-scc-share-second-cache-engine.php
4
 
5
  Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Share_Second_Cache_Engine
32
+ */
33
  class SCC_Share_Second_Cache_Engine extends SCC_Cache_Engine {
34
 
35
  /**
59
 
60
  /**
61
  * Interval cheking and caching target data
62
+ *
63
+ * @var integer
64
  */
65
  private $check_interval = 600;
66
 
67
  /**
68
  * Number of posts to check at a time
69
+ *
70
+ * @var integer
71
  */
72
  private $posts_per_check = 20;
73
 
74
  /**
75
  * Cache target
76
+ *
77
+ * @var array
78
  */
79
  private $target_sns = array();
80
 
81
  /**
82
  * Cache post types
83
+ *
84
+ * @var array
85
  */
86
  private $post_types = array( 'post', 'page' );
87
 
88
  /**
89
  * Crawl date key
90
+ *
91
+ * @var array
92
  */
93
+ private $crawl_date_key = null;
94
 
95
  /**
96
  * Initialization
97
  *
98
+ * @param array $options Option.
99
+ * @return void
100
  */
101
  public function initialize( $options = array() ) {
102
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
103
 
104
  $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
105
  $this->prime_cron = self::DEF_PRIME_CRON;
107
  $this->event_schedule = self::DEF_EVENT_SCHEDULE;
108
  $this->event_description = self::DEF_EVENT_DESCRIPTION;
109
 
110
+ if ( isset( $options['delegate'] ) ) {
111
+ $this->delegate = $options['delegate'];
112
+ }
113
+
114
+ if ( isset( $options['target_sns'] ) ) {
115
+ $this->target_sns = $options['target_sns'];
116
+ }
117
+
118
+ if ( isset( $options['check_interval'] ) ) {
119
+ $this->check_interval = $options['check_interval'];
120
+ }
121
+
122
+ if ( isset( $options['posts_per_check'] ) ) {
123
+ $this->posts_per_check = $options['posts_per_check'];
124
+ }
125
+
126
+ if ( isset( $options['cache_prefix'] ) ) {
127
+ $this->cache_prefix = $options['cache_prefix'];
128
+ }
129
+
130
+ if ( isset( $options['prime_cron'] ) ) {
131
+ $this->prime_cron = $options['prime_cron'];
132
+ }
133
+
134
+ if ( isset( $options['execute_cron'] ) ) {
135
+ $this->execute_cron = $options['execute_cron'];
136
+ }
137
+
138
+ if ( isset( $options['event_schedule'] ) ) {
139
+ $this->event_schedule = $options['event_schedule'];
140
+ }
141
+
142
+ if ( isset( $options['event_description'] ) ) {
143
+ $this->event_description = $options['event_description'];
144
+ }
145
+
146
+ if ( isset( $options['post_types'] ) ) {
147
+ $this->post_types = $options['post_types'];
148
+ }
149
+
150
+ if ( isset( $options['crawl_date_key'] ) ) {
151
+ $this->crawl_date_key = $options['crawl_date_key'];
152
+ }
153
 
154
  add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
155
  add_action( $this->prime_cron, array( $this, 'prime_cache' ) );
159
  /**
160
  * Register event schedule for this engine
161
  *
162
+ * @param array $schedules Schedule.
163
+ * @return array
164
  */
165
  public function schedule_check_interval( $schedules ) {
166
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
167
 
168
+ $schedules[ $this->event_schedule ] = array(
169
  'interval' => $this->check_interval,
170
+ 'display' => $this->event_description,
171
  );
172
 
173
  return $schedules;
176
  /**
177
  * Schedule data retrieval and cache processing
178
  *
179
+ * @return void
180
  */
181
  public function prime_cache() {
182
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
183
 
184
  $next_exec_time = (int) current_time( 'timestamp', 1 ) + $this->check_interval;
185
 
186
+ SCC_Logger::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
187
+ SCC_Logger::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
188
 
189
  wp_schedule_single_event( $next_exec_time, $this->execute_cron );
190
  }
192
  /**
193
  * Get and cache data of each published post and page
194
  *
195
+ * @param integer $posts_offset Post offset.
196
+ * @return void
197
  */
198
  public function execute_cache() {
199
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
200
 
201
  $query_args = array(
202
  'post_type' => $this->post_types,
203
  'post_status' => 'publish',
204
  'nopaging' => true,
205
  'update_post_term_cache' => false,
206
+ 'update_post_meta_cache' => false,
207
  );
208
 
209
  $posts_query = new WP_Query( $query_args );
221
  $options = array(
222
  'cache_key' => $transient_id,
223
  'post_id' => $post_id,
224
+ 'target_sns' => $this->target_sns,
225
  );
226
 
227
  $this->cache( $options );
234
  /**
235
  * Get and cache data for a given post
236
  *
237
+ * @param integer $post_id Post ID.
238
+ * @param boolean $second_sync Second sync flag.
239
+ * @return array
240
  */
241
  public function cache( $options = array() ) {
242
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
243
 
244
  $transient_id = $options['cache_key'];
245
  $target_sns = $options['target_sns'];
247
 
248
  $sns_counts = array();
249
 
250
+ if ( 'home' !== $post_id ) {
251
+
252
+ $sns_counts = get_transient( $transient_id );
253
+
254
+ if ( false !== $sns_counts ) {
255
  foreach ( $target_sns as $sns => $active ) {
256
  if ( $active ) {
257
  $meta_key = $this->get_cache_key( $sns );
258
 
259
  if ( $sns !== $this->crawl_date_key ) {
260
 
261
+ if ( isset( $sns_counts[ $sns ] ) && 0 <= $sns_counts[ $sns ] ) {
262
+ update_post_meta( $post_id, $meta_key, (int) $sns_counts[ $sns ] );
263
  } else {
264
  update_post_meta( $post_id, $meta_key, (int) -1 );
265
  }
266
  } else {
267
+ if ( isset( $sns_counts[ $sns ] ) && '' !== $sns_counts[ $sns ] ) {
268
+ update_post_meta( $post_id, $meta_key, $sns_counts[ $sns ] );
269
  } else {
270
  update_post_meta( $post_id, $meta_key, '' );
271
  }
274
  }
275
  }
276
  } else {
277
+ $sns_counts = get_transient( $transient_id );
278
+
279
+ if ( false !== $sns_counts ) {
280
 
281
  $option_key = $this->get_cache_key( 'home' );
282
 
283
  foreach ( $target_sns as $sns => $active ) {
284
  if ( $active ) {
285
  if ( $sns !== $this->crawl_date_key ) {
286
+ if ( ! isset( $sns_counts[ $sns ] ) || 0 > $sns_counts[ $sns ] ) {
287
+ $sns_counts[ $sns ] = (int) -1;
288
  }
289
  } else {
290
+ if ( ! isset( $sns_counts[ $sns ] ) || '' === $sns_counts[ $sns ] ) {
291
+ $sns_counts[ $sns ] = '';
292
  }
293
  }
294
  }
305
  /**
306
  * Get cache expiration based on current number of total post and page
307
  *
308
+ * @return integer
309
  */
310
  protected function get_cache_expiration() {
311
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
312
 
313
  return 0;
314
  }
315
 
316
  /**
317
+ * Initialize cache
318
  *
319
+ * @return void
320
  */
321
  public function initialize_cache() {
322
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
323
 
324
  $option_key = $this->get_cache_key( 'home' );
325
 
327
 
328
  foreach ( $this->target_sns as $sns => $active ) {
329
  if ( $active ) {
330
+ $sns_counts[ $sns ] = (int) -1;
331
  }
332
  }
333
 
338
  'post_status' => 'publish',
339
  'nopaging' => true,
340
  'update_post_term_cache' => false,
341
+ 'update_post_meta_cache' => false,
342
  );
343
 
344
  $posts_query = new WP_Query( $query_args );
364
  /**
365
  * Get cache
366
  *
367
+ * @param array $options Option.
368
+ * @return array
369
  */
370
  public function get_cache( $options = array() ) {
371
  $post_id = $options['post_id'];
372
  $sns_counts = array();
373
 
374
+ if ( 'home' !== $post_id ) {
375
  foreach ( $this->target_sns as $sns => $active ) {
376
  if ( $active ) {
377
  $meta_key = $this->get_cache_key( $sns );
378
+ $sns_counts[ $sns ] = get_post_meta( $post_id, $meta_key, true );
379
  }
380
  }
381
  } else {
382
+ $option_key = $this->get_cache_key( 'home' );
383
  $sns_counts = get_option( $option_key );
384
  }
385
  return $sns_counts;
386
  }
387
 
388
  /**
389
+ * Clear cache
390
  *
391
+ * @return void
392
  */
393
  public function clear_cache() {
394
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
395
 
396
  $option_key = $this->get_cache_key( 'home' );
397
  delete_option( $option_key );
402
  delete_post_meta_by_key( $meta_key );
403
  }
404
  }
405
+
406
+ // Processing for Google+ count removal
407
+ $meta_key = $this->get_cache_key( SNS_Count_Cache::REF_SHARE_GPLUS );
408
+ delete_post_meta_by_key( $meta_key );
409
  }
410
 
411
+ /**
412
+ * Clear cache
413
  *
414
+ * @param integer $post_id Post ID.
415
+ * @return void
416
  */
417
  public function clear_cache_by_post_id( $post_id ) {
418
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
419
 
420
  foreach ( $this->target_sns as $sns => $active ) {
421
  if ( $active ) {
424
  }
425
  }
426
 
427
+ // Processing for Google+ count removal
428
+ $meta_key = $this->get_cache_key( SNS_Count_Cache::REF_SHARE_GPLUS );
429
+ delete_post_meta_by_key( $meta_key );
430
+
431
  }
432
 
433
  }
includes/class-scc-share-twitter-crawl-strategy.php ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ class-scc-share-twitter-crawl-strategy.php
4
+
5
+ Description: This class is abstract class of a data crawler
6
+ Author: Daisuke Maruyama
7
+ Author URI: http://marubon.info/
8
+ License: GPL2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; either version 2
18
+ of the License, or (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
+ */
29
+
30
+ /**
31
+ * SCC_Share_Twitter_Crawl_Strategy
32
+ *
33
+ */
34
+ class SCC_Share_Twitter_Crawl_Strategy extends SCC_Crawl_Strategy {
35
+
36
+ /**
37
+ * SNS base url (widgetoon.js & count.jsoon)
38
+ */
39
+ const DEF_BASE_URL_JSOON = 'http://jsoon.digitiminimi.com/twitter/count.json';
40
+
41
+ /**
42
+ * SNS base url (OpenShareCount)
43
+ */
44
+ const DEF_BASE_URL_OPENSHARECOUNT = 'http://opensharecount.com/count.json';
45
+
46
+ /**
47
+ * SNS base url (TwitCount)
48
+ */
49
+ const DEF_BASE_URL_TWITCOUNT = 'http://counts.twitcount.com/counts.php';
50
+
51
+ /**
52
+ * SNS base url (NewShareCounts)
53
+ */
54
+ const DEF_BASE_URL_NEWSHARECOUNTS = 'http://public.newsharecounts.com/count.json';
55
+
56
+ /**
57
+ * Class constarctor
58
+ * Hook onto all of the actions and filters needed by the plugin.
59
+ */
60
+ protected function __construct() {
61
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
62
+ $this->http_method = 'GET';
63
+ }
64
+
65
+ /**
66
+ * Initialization
67
+ *
68
+ * @param array $options Option.
69
+ * @return void
70
+ */
71
+ public function initialize( $options = array() ) {
72
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
73
+
74
+ if ( isset( $options['twitter_api'] ) ) {
75
+ $this->twitter_api = $options['twitter_api'];
76
+ }
77
+
78
+ }
79
+
80
+ /**
81
+ * Build request header
82
+ *
83
+ * @return array
84
+ */
85
+ public function build_request_header() {
86
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
87
+ return null;
88
+ }
89
+
90
+ /**
91
+ * Build request body
92
+ *
93
+ * @return array
94
+ */
95
+ public function build_request_body() {
96
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
97
+ return null;
98
+ }
99
+
100
+ /**
101
+ * Build request URL
102
+ *
103
+ * @return string
104
+ */
105
+ public function build_request_url() {
106
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
107
+
108
+ $base_url = self::DEF_BASE_URL_JSOON;
109
+
110
+ if ( isset( $this->twitter_api ) && $this->twitter_api ) {
111
+ if ( SNS_Count_Cache::OPT_SHARE_TWITTER_API_JSOON === $this->twitter_api ) {
112
+ $base_url = self::DEF_BASE_URL_JSOON;
113
+ } elseif ( SNS_Count_Cache::OPT_SHARE_TWITTER_API_OPENSHARECOUNT === $this->twitter_api ) {
114
+ $base_url = self::DEF_BASE_URL_OPENSHARECOUNT;
115
+ } elseif ( SNS_Count_Cache::OPT_SHARE_TWITTER_API_TWITCOUNT === $this->twitter_api ) {
116
+ $base_url = self::DEF_BASE_URL_TWITCOUNT;
117
+ } elseif ( SNS_Count_Cache::OPT_SHARE_TWITTER_API_NEWSHARECOUNTS === $this->twitter_api ) {
118
+ $base_url = self::DEF_BASE_URL_NEWSHARECOUNTS;
119
+ }
120
+ }
121
+
122
+ $url = $base_url . '?' . http_build_query( $this->query_parameters , '' , '&' );
123
+
124
+ return $url;
125
+ }
126
+
127
+ /**
128
+ * Extract response body
129
+ *
130
+ * @param array $content Content.
131
+ * @return array
132
+ */
133
+ public function extract_response_body( $content ) {
134
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
135
+
136
+ $count = (int) -1;
137
+
138
+ if ( isset( $content['body'] ) && empty( $content['error'] ) ) {
139
+ $json = json_decode( $content['body'], true );
140
+
141
+ if ( isset( $json['count'] ) && is_numeric( $json['count'] ) ) {
142
+ $count = (int) $json['count'];
143
+ } else {
144
+ $count = (int) -1;
145
+ }
146
+ } else {
147
+ $count = (int) -1;
148
+
149
+ if ( isset( $content['error'] ) ) {
150
+ SCC_Logger::log( $content['error'] );
151
+ }
152
+ }
153
+
154
+ return $count;
155
+ }
156
+
157
+ /**
158
+ * Extract response header
159
+ *
160
+ * @param array $content Content.
161
+ * @return array
162
+ */
163
+ public function extract_response_header( $content ) {
164
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
165
+
166
+ return null;
167
+ }
168
+
169
+ /**
170
+ * Set parameter
171
+ *
172
+ * @param string $key Key.
173
+ * @param string $value Value.
174
+ * @return void
175
+ */
176
+ public function set_parameter( $key, $value ) {
177
+ if ( isset( $this->twitter_api ) && $this->twitter_api ) {
178
+ if ( SNS_Count_Cache::OPT_SHARE_TWITTER_API_JSOON === $this->twitter_api ) {
179
+ if ( 'url' === $key ) {
180
+ if ( home_url( '/', 'http' ) === $value || home_url( '/', 'https' ) === $value ) {
181
+ $this->query_parameters[ $key ] = '"' . $value . '"';
182
+ } else {
183
+ $this->query_parameters[ $key ] = $value;
184
+ }
185
+ }
186
+ } elseif ( SNS_Count_Cache::OPT_SHARE_TWITTER_API_OPENSHARECOUNT === $this->twitter_api ) {
187
+ if ( 'url' === $key ) {
188
+ $this->query_parameters[ $key ] = $value;
189
+ }
190
+ } elseif ( SNS_Count_Cache::OPT_SHARE_TWITTER_API_TWITCOUNT === $this->twitter_api ) {
191
+ if ( 'url' === $key ) {
192
+ $this->query_parameters[ $key ] = $value;
193
+ }
194
+ } elseif ( SNS_Count_Cache::OPT_SHARE_TWITTER_API_NEWSHARECOUNTS === $this->twitter_api ) {
195
+ if ( 'url' === $key ) {
196
+ $this->query_parameters[ $key ] = $value;
197
+ }
198
+ }
199
+ } else {
200
+ if ( 'url' === $key ) {
201
+ $this->query_parameters[ $key ] = $value;
202
+ }
203
+ }
204
+ }
205
+
206
+ /**
207
+ * Check if required paramters are included or not.
208
+ *
209
+ * @return boolean
210
+ */
211
+ public function check_configuration() {
212
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
213
+
214
+ if ( ! empty( $this->query_parameters['url'] ) ) {
215
+ return true;
216
+ } else {
217
+ return false;
218
+ }
219
+ }
220
+
221
+ /**
222
+ * Check if there is rate limiting or not.
223
+ *
224
+ * @param string $content Content.
225
+ * @return boolean
226
+ */
227
+ public function check_rate_limiting( $content ) {
228
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
229
+
230
+ return true;
231
+ }
232
+
233
+ }
includes/class-scc-share-twitter-strategy.php DELETED
@@ -1,194 +0,0 @@
1
- <?php
2
- /*
3
- class-scc-share-twitter-strategy.php
4
-
5
- Description: This class is abstract class of a data crawler
6
- Author: Daisuke Maruyama
7
- Author URI: http://marubon.info/
8
- License: GPL2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
-
12
- /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
-
15
- This program is free software; you can redistribute it and/or
16
- modify it under the terms of the GNU General Public License
17
- as published by the Free Software Foundation; either version 2
18
- of the License, or (at your option) any later version.
19
-
20
- This program is distributed in the hope that it will be useful,
21
- but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- GNU General Public License for more details.
24
-
25
- You should have received a copy of the GNU General Public License
26
- along with this program; if not, write to the Free Software
27
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
- */
29
-
30
- class SCC_Share_Twitter_Strategy extends SCC_Crawl_Strategy {
31
-
32
- /**
33
- * SNS base url (widgetoon.js & count.jsoon)
34
- * @var string
35
- */
36
- const DEF_BASE_URL_JSOON = 'http://jsoon.digitiminimi.com/twitter/count.json';
37
-
38
- /**
39
- * SNS base url (OpenShareCount)
40
- * @var string
41
- */
42
- const DEF_BASE_URL_OPENSHARECOUNT = 'http://opensharecount.com/count.json';
43
-
44
- /**
45
- * SNS base url (TwitCount)
46
- * @var string
47
- */
48
- const DEF_BASE_URL_TWITCOUNT = 'http://counts.twitcount.com/counts.php';
49
-
50
- /**
51
- * SNS base url (NewShareCounts)
52
- * @var string
53
- */
54
- const DEF_BASE_URL_NEWSHARECOUNTS = 'http://public.newsharecounts.com/count.json';
55
-
56
- /**
57
- * Class constarctor
58
- * Hook onto all of the actions and filters needed by the plugin.
59
- *
60
- */
61
- protected function __construct() {
62
- SCC_Common_Util::log('[' . __METHOD__ . '] (line='. __LINE__ . ')');
63
- $this->method = 'GET';
64
- }
65
-
66
- /**
67
- * Initialization
68
- * @since 0.9.0
69
- * @param array $options Option for this strategy
70
- * @return null There is no return.
71
- */
72
- public function initialize( $options = array() ) {
73
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
74
-
75
- if ( isset( $options['url'] ) ) $this->url = $options['url'];
76
- if ( isset( $options['method'] ) ) $this->method = $options['method'];
77
- if ( isset( $options['parameters'] ) ) $this->parameters = $options['parameters'];
78
- if ( isset( $options['twitter_api'] ) ) $this->twitter_api = $options['twitter_api'];
79
- }
80
-
81
- /**
82
- * Build header
83
- * @since 0.9.0
84
- * @return null no need to build header for Twitter share count retrieval.
85
- */
86
- public function build_header() {
87
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
88
- return null;
89
- }
90
-
91
- /**
92
- * Build query URL
93
- * @since 0.9.0
94
- * @return string Query URL
95
- */
96
- public function build_query_url() {
97
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
98
-
99
- $base_url = self::DEF_BASE_URL_JSOON;
100
-
101
- if ( isset( $this->twitter_api ) && $this->twitter_api ) {
102
- if ( $this->twitter_api === SNS_Count_Cache::OPT_SHARE_TWITTER_API_JSOON ) {
103
- $base_url = self::DEF_BASE_URL_JSOON;
104
- } elseif ( $this->twitter_api === SNS_Count_Cache::OPT_SHARE_TWITTER_API_OPENSHARECOUNT ) {
105
- $base_url = self::DEF_BASE_URL_OPENSHARECOUNT;
106
- } elseif( $this->twitter_api === SNS_Count_Cache::OPT_SHARE_TWITTER_API_TWITCOUNT ) {
107
- $base_url = self::DEF_BASE_URL_TWITCOUNT;
108
- } elseif( $this->twitter_api === SNS_Count_Cache::OPT_SHARE_TWITTER_API_NEWSHARECOUNTS ) {
109
- $base_url = self::DEF_BASE_URL_NEWSHARECOUNTS;
110
- }
111
- }
112
-
113
- $url = $base_url . '?' . http_build_query( $this->query_parameters , '' , '&' );
114
-
115
- return $url;
116
- }
117
-
118
- /**
119
- * Extract count
120
- * @since 0.9.0
121
- * @param string $content Target content
122
- * @return int SNS count
123
- */
124
- public function extract_count( $content ) {
125
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
126
-
127
- $count = (int) -1;
128
-
129
- if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
130
- $json = json_decode( $content['data'], true );
131
-
132
- if ( isset( $json['count'] ) && is_numeric( $json['count'] ) ) {
133
- $count = (int) $json['count'];
134
- } else {
135
- $count = (int) -1;
136
- }
137
- } else {
138
- $count = (int) -1;
139
- }
140
-
141
- return $count;
142
- }
143
-
144
- /**
145
- * Setter of query parameters
146
- * @param string $key key
147
- * @param string $value value
148
- */
149
- public function set_query_parameter( $key, $value ) {
150
- if ( isset( $this->twitter_api ) && $this->twitter_api ) {
151
- if ( $this->twitter_api === SNS_Count_Cache::OPT_SHARE_TWITTER_API_JSOON ) {
152
- if ( $key === 'url' ) {
153
- if ( $value === home_url( '/', 'http' ) || $value === home_url( '/', 'https' ) ) {
154
- $this->query_parameters[$key] = '"' . $value . '"';
155
- } else {
156
- $this->query_parameters[$key] = $value;
157
- }
158
- }
159
- } elseif ( $this->twitter_api === SNS_Count_Cache::OPT_SHARE_TWITTER_API_OPENSHARECOUNT ) {
160
- if ( $key === 'url' ) {
161
- $this->query_parameters[$key] = $value;
162
- }
163
- } elseif( $this->twitter_api === SNS_Count_Cache::OPT_SHARE_TWITTER_API_TWITCOUNT ) {
164
- if ( $key === 'url' ) {
165
- $this->query_parameters[$key] = $value;
166
- }
167
- } elseif ( $this->twitter_api === SNS_Count_Cache::OPT_SHARE_TWITTER_API_NEWSHARECOUNTS ) {
168
- if ( $key === 'url' ) {
169
- $this->query_parameters[$key] = $value;
170
- }
171
- }
172
- } else {
173
- if ( $key === 'url' ) {
174
- $this->query_parameters[$key] = $value;
175
- }
176
- }
177
- }
178
-
179
- /**
180
- * Check if required paramters are included or not.
181
- * @since 0.9.0
182
- * @return boolean Check result
183
- */
184
- public function check_configuration() {
185
- SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
186
-
187
- if ( isset( $this->query_parameters['url'] ) && $this->query_parameters['url'] ) {
188
- return true;
189
- } else {
190
- return false;
191
- }
192
- }
193
-
194
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-scc-sleep-throttle.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  class-scc-sleep-throttle.php
4
 
5
  Description: sleep utility
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,42 +27,57 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  final class SCC_Sleep_Throttle {
31
 
32
- /*
33
- *
34
  */
35
  const SECOND_TO_MICRO_SECONDS = 1000000;
36
 
37
- /*
 
38
  *
 
39
  */
40
  private $load_ratio = 0.9;
41
 
42
- /*
 
43
  *
 
44
  */
45
  private $start_time = null;
46
 
47
- /*
 
48
  *
 
49
  */
50
  private $stop_time = null;
51
 
52
- /*
 
53
  *
 
54
  */
55
  private $sleep_time = null;
56
 
57
- /*
 
58
  *
 
59
  */
60
  function __construct( $load_ratio ) {
61
  $this->load_ratio = $load_ratio;
62
  }
63
 
64
- /*
 
65
  *
 
66
  */
67
  public function reset() {
68
  $this->start_time = null;
@@ -70,15 +85,19 @@ final class SCC_Sleep_Throttle {
70
  $this->sleep_time = null;
71
  }
72
 
73
- /*
 
74
  *
 
75
  */
76
  public function start() {
77
  $this->start_time = gettimeofday( true );
78
  }
79
 
80
- /*
 
81
  *
 
82
  */
83
  public function stop() {
84
  $this->stop_time = gettimeofday( true );
@@ -88,28 +107,36 @@ final class SCC_Sleep_Throttle {
88
  }
89
  }
90
 
91
- /*
 
92
  *
 
93
  */
94
  public function sleep() {
95
- if ( ! is_null( $this->sleep_time) && $this->sleep_time > 0 ) {
96
  usleep( $this->sleep_time * self::SECOND_TO_MICRO_SECONDS );
97
  }
98
  }
99
 
100
- /*
 
101
  *
 
102
  */
103
  public function get_sleep_time() {
104
- if ( ! is_null( $this->sleep_time) && $this->sleep_time > 0 ) {
105
  return $this->sleep_time;
106
  } else {
107
  return 0;
108
  }
109
  }
110
 
111
- /*
 
112
  *
 
 
 
113
  */
114
  private function calculate_sleep_time( $load_ratio, $time ) {
115
  if ( $time > 0.0 ) {
1
  <?php
2
+ /**
3
  class-scc-sleep-throttle.php
4
 
5
  Description: sleep utility
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Sleep_Throttle
32
+ */
33
  final class SCC_Sleep_Throttle {
34
 
35
+ /**
36
+ * Second to micro seconds
37
  */
38
  const SECOND_TO_MICRO_SECONDS = 1000000;
39
 
40
+ /**
41
+ * Load ratio
42
  *
43
+ * @var float
44
  */
45
  private $load_ratio = 0.9;
46
 
47
+ /**
48
+ * Start time
49
  *
50
+ * @var float
51
  */
52
  private $start_time = null;
53
 
54
+ /**
55
+ * End time
56
  *
57
+ * @var float
58
  */
59
  private $stop_time = null;
60
 
61
+ /**
62
+ * Sleep time
63
  *
64
+ * @var float
65
  */
66
  private $sleep_time = null;
67
 
68
+ /**
69
+ * Constructor
70
  *
71
+ * @param float $load_ratio Load ratio.
72
  */
73
  function __construct( $load_ratio ) {
74
  $this->load_ratio = $load_ratio;
75
  }
76
 
77
+ /**
78
+ * Reset
79
  *
80
+ * @return void
81
  */
82
  public function reset() {
83
  $this->start_time = null;
85
  $this->sleep_time = null;
86
  }
87
 
88
+ /**
89
+ * Start
90
  *
91
+ * @return void
92
  */
93
  public function start() {
94
  $this->start_time = gettimeofday( true );
95
  }
96
 
97
+ /**
98
+ * Stop
99
  *
100
+ * @return void
101
  */
102
  public function stop() {
103
  $this->stop_time = gettimeofday( true );
107
  }
108
  }
109
 
110
+ /**
111
+ * Sleep
112
  *
113
+ * @return void
114
  */
115
  public function sleep() {
116
+ if ( ! is_null( $this->sleep_time ) && $this->sleep_time > 0 ) {
117
  usleep( $this->sleep_time * self::SECOND_TO_MICRO_SECONDS );
118
  }
119
  }
120
 
121
+ /**
122
+ * Get sleep time
123
  *
124
+ * @return float
125
  */
126
  public function get_sleep_time() {
127
+ if ( ! is_null( $this->sleep_time ) && $this->sleep_time > 0 ) {
128
  return $this->sleep_time;
129
  } else {
130
  return 0;
131
  }
132
  }
133
 
134
+ /**
135
+ * Calculate sleep time
136
  *
137
+ * @param float $load_ratio Load ratio.
138
+ * @param float $time Time.
139
+ * @return float
140
  */
141
  private function calculate_sleep_time( $load_ratio, $time ) {
142
  if ( $time > 0.0 ) {
includes/{class-scc-wp-cron-util.php → class-scc-wp-cron.php} RENAMED
@@ -1,16 +1,16 @@
1
  <?php
2
- /*
3
- class-scc-wp-cron-util.php
4
 
5
  Description: This class is a utility for WP-Cron
6
  Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,22 +27,25 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
- class SCC_WP_Cron_Util {
 
 
 
31
 
32
  /**
33
  * Class constarctor
34
  * Hook onto all of the actions and filters needed by the plugin.
35
- *
36
  */
37
  protected function __construct() {
38
 
39
  }
40
 
41
-
42
  /**
43
  * Clear expired scheduled hook based related to specified hook name
44
  *
45
- * @since 0.4.1
 
 
46
  */
47
  public static function clear_expired_scheduled_hook( $hook, $elapsed_time ) {
48
  $crons = _get_cron_array();
@@ -51,14 +54,14 @@ class SCC_WP_Cron_Util {
51
  return;
52
  }
53
 
54
- $current_time = (int) current_time( 'timestamp', 1 );
55
 
56
- foreach( $crons as $timestamp => $cron ) {
57
- if ( isset( $cron[$hook] ) ) {
58
  $duration = $current_time - $timestamp;
59
 
60
  if ( $duration > $elapsed_time ) {
61
- foreach ( $cron[$hook] as $signature => $data ) {
62
  wp_unschedule_event( $timestamp, $hook, $data['args'] );
63
  }
64
  }
@@ -66,38 +69,43 @@ class SCC_WP_Cron_Util {
66
  }
67
  }
68
 
69
-
70
  /**
71
  * Clear scheduled hook based related to specified hook name
72
  *
73
- * @since 0.1.1
 
74
  */
75
  public static function clear_scheduled_hook( $hook ) {
76
  $crons = _get_cron_array();
77
 
78
- if ( empty( $crons ) ) return;
 
 
79
 
80
- foreach( $crons as $timestamp => $cron ) {
81
- if ( isset( $cron[$hook] ) ) {
82
- foreach ( $cron[$hook] as $signature => $data ) {
83
- wp_unschedule_event( $timestamp, $hook, $data['args'] );
84
- }
85
  }
 
86
  }
87
  }
88
 
89
  /**
90
  * Return if there is the given hook or not
91
  *
92
- * @since 0.1.1
 
93
  */
94
  public static function is_scheduled_hook( $hook ) {
95
  $crons = _get_cron_array();
96
 
97
- if ( empty( $crons ) ) return false;
 
 
98
 
99
- foreach( $crons as $timestamp => $cron ) {
100
- if ( isset( $cron[$hook] ) ) {
101
  return true;
102
  }
103
  }
@@ -108,31 +116,28 @@ class SCC_WP_Cron_Util {
108
  /**
109
  * Get scheduled hook related to specified hook name
110
  *
111
- * @since 0.1.1
 
112
  */
113
  public static function get_scheduled_hook( $hook ) {
114
- //SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
115
 
116
  $crons = _get_cron_array();
117
 
118
  $info = array();
119
  $index = 0;
120
 
121
- if ( empty( $crons ) ) return;
122
-
123
- foreach( $crons as $timestamp => $cron ) {
124
- if ( isset( $cron[$hook] ) ) {
125
- //SCC_Common_Util::log( $cron[$hook] );
126
- foreach ( $cron[$hook] as $signature => $data ) {
127
-
128
- //SCC_Common_Util::log( '[' . __METHOD__ . '] hook: ' . $hook . ' offset: ' . $data['args'][0]. ' timestamp: ' . $timestamp );
129
 
130
- $info[$index]['hook'] = $hook;
131
- $info[$index]['timestamp'] = $timestamp;
132
- $info[$index]['args'] = $data['args'];
133
- //wp_unschedule_event( $timestamp, $hook, $data['args'] );
 
 
134
  }
135
- $index++;
136
  }
137
  }
138
 
@@ -140,11 +145,10 @@ class SCC_WP_Cron_Util {
140
  }
141
 
142
  /**
143
- *
144
  * Get the local time timestamp of the next cron execution
145
  * This code is cited from wordpress plugin BackWPup
146
  *
147
- * @param string $cronstring cron (* * * * *)
148
  * @return int timestamp
149
  */
150
  public static function next_exec_time( $cronstring ) {
@@ -233,7 +237,7 @@ class SCC_WP_Cron_Util {
233
 
234
  //generate years
235
  $year = (int) gmdate( 'Y' );
236
- for ( $i = $year; $i < $year + 100; $i ++ ) {
237
  $cron[ 'year' ][ ] = $i;
238
  }
239
 
@@ -263,6 +267,9 @@ class SCC_WP_Cron_Util {
263
  /**
264
  * Gets the status of WP-Cron functionality on the site by performing a test spawn. Cached for one hour when all is well.
265
  * This code is cited from wordpress plugin WP Crontrol
 
 
 
266
  */
267
  public static function test_cron_spawn( $cache = true ) {
268
  global $wp_version;
1
  <?php
2
+ /**
3
+ class-scc-wp-cron.php
4
 
5
  Description: This class is a utility for WP-Cron
6
  Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_WP_Cron
32
+ */
33
+ class SCC_WP_Cron {
34
 
35
  /**
36
  * Class constarctor
37
  * Hook onto all of the actions and filters needed by the plugin.
 
38
  */
39
  protected function __construct() {
40
 
41
  }
42
 
 
43
  /**
44
  * Clear expired scheduled hook based related to specified hook name
45
  *
46
+ * @param string $hook Hook.
47
+ * @param integer $elapsed_time Time.
48
+ * @return void
49
  */
50
  public static function clear_expired_scheduled_hook( $hook, $elapsed_time ) {
51
  $crons = _get_cron_array();
54
  return;
55
  }
56
 
57
+ $current_time = (int) current_time( 'timestamp', 1 );
58
 
59
+ foreach ( $crons as $timestamp => $cron ) {
60
+ if ( isset( $cron[ $hook ] ) ) {
61
  $duration = $current_time - $timestamp;
62
 
63
  if ( $duration > $elapsed_time ) {
64
+ foreach ( $cron[ $hook ] as $signature => $data ) {
65
  wp_unschedule_event( $timestamp, $hook, $data['args'] );
66
  }
67
  }
69
  }
70
  }
71
 
 
72
  /**
73
  * Clear scheduled hook based related to specified hook name
74
  *
75
+ * @param string $hook Hook.
76
+ * @return void
77
  */
78
  public static function clear_scheduled_hook( $hook ) {
79
  $crons = _get_cron_array();
80
 
81
+ if ( empty( $crons ) ) {
82
+ return;
83
+ }
84
 
85
+ foreach ( $crons as $timestamp => $cron ) {
86
+ if ( isset( $cron[ $hook ] ) ) {
87
+ foreach ( $cron[ $hook ] as $signature => $data ) {
88
+ wp_unschedule_event( $timestamp, $hook, $data['args'] );
 
89
  }
90
+ }
91
  }
92
  }
93
 
94
  /**
95
  * Return if there is the given hook or not
96
  *
97
+ * @param string $hook Hook.
98
+ * @return boolean
99
  */
100
  public static function is_scheduled_hook( $hook ) {
101
  $crons = _get_cron_array();
102
 
103
+ if ( empty( $crons ) ) {
104
+ return false;
105
+ }
106
 
107
+ foreach ( $crons as $timestamp => $cron ) {
108
+ if ( isset( $cron[ $hook ] ) ) {
109
  return true;
110
  }
111
  }
116
  /**
117
  * Get scheduled hook related to specified hook name
118
  *
119
+ * @param string $hook Hook.
120
+ * @return array
121
  */
122
  public static function get_scheduled_hook( $hook ) {
 
123
 
124
  $crons = _get_cron_array();
125
 
126
  $info = array();
127
  $index = 0;
128
 
129
+ if ( empty( $crons ) ) {
130
+ return;
131
+ }
 
 
 
 
 
132
 
133
+ foreach ( $crons as $timestamp => $cron ) {
134
+ if ( isset( $cron[ $hook ] ) ) {
135
+ foreach ( $cron[ $hook ] as $signature => $data ) {
136
+ $info[ $index ]['hook'] = $hook;
137
+ $info[ $index ]['timestamp'] = $timestamp;
138
+ $info[ $index ]['args'] = $data['args'];
139
  }
140
+ ++$index;
141
  }
142
  }
143
 
145
  }
146
 
147
  /**
 
148
  * Get the local time timestamp of the next cron execution
149
  * This code is cited from wordpress plugin BackWPup
150
  *
151
+ * @param string $cronstring cron (* * * * *).
152
  * @return int timestamp
153
  */
154
  public static function next_exec_time( $cronstring ) {
237
 
238
  //generate years
239
  $year = (int) gmdate( 'Y' );
240
+ for ( $i = $year; $i < $year + 100; ++$i ) {
241
  $cron[ 'year' ][ ] = $i;
242
  }
243
 
267
  /**
268
  * Gets the status of WP-Cron functionality on the site by performing a test spawn. Cached for one hour when all is well.
269
  * This code is cited from wordpress plugin WP Crontrol
270
+ *
271
+ * @param boolean $cache Cache.
272
+ * @return boolean
273
  */
274
  public static function test_cron_spawn( $cache = true ) {
275
  global $wp_version;
includes/download.php CHANGED
@@ -10,7 +10,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
  */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -29,15 +29,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
 
30
  require_once( '../../../../wp-load.php' );
31
 
32
- if ( ! defined( 'ABSPATH' ) ) exit(); // Exit if accessed directly
 
 
33
 
34
  $abs_path = WP_PLUGIN_DIR . '/sns-count-cache/data/sns-count-cache-data.csv';
35
 
36
- if ( current_user_can( 'manage_options' ) ) {
37
- if ( isset( $_POST['_wpnonce'] ) && $_POST['_wpnonce'] && check_admin_referer( 'download', '_wpnonce' ) ) {
38
- if ( isset( $_POST["download_data"] ) && $_POST["download_data"] === __( 'Download', SNS_Count_Cache::DOMAIN ) ) {
39
  if ( file_exists( $abs_path ) ) {
40
- $file_name = "sns-count-cache_data_" . date_i18n( 'YmdHis' ) . ".csv";
41
 
42
  $size = filesize( $abs_path );
43
  header( 'Content-Length: ' . $size );
@@ -51,7 +53,7 @@ if ( current_user_can( 'manage_options' ) ) {
51
 
52
  ob_start();
53
  if ( $fp = fopen( $abs_path, 'rb' ) ) {
54
- while( ! feof( $fp ) && ( connection_status() == 0 ) ) {
55
  echo fread( $fp, 8192 );
56
  ob_flush();
57
  }
@@ -69,7 +71,7 @@ if ( current_user_can( 'manage_options' ) ) {
69
  }
70
  } else {
71
  wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
72
- }
73
  die();
74
 
75
  ?>
10
  */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
29
 
30
  require_once( '../../../../wp-load.php' );
31
 
32
+ if ( ! defined( 'ABSPATH' ) ) {
33
+ exit(); // Exit if accessed directly
34
+ }
35
 
36
  $abs_path = WP_PLUGIN_DIR . '/sns-count-cache/data/sns-count-cache-data.csv';
37
 
38
+ if ( ! empty( $_POST['_wpnonce'] ) && check_admin_referer( 'download', '_wpnonce' ) ) {
39
+ if ( current_user_can( SNS_Count_Cache::OPT_COMMON_CAPABILITY ) ) {
40
+ if ( isset( $_POST['download_data'] ) && __( 'Download', SNS_Count_Cache::DOMAIN ) === wp_unslash( $_POST['download_data'] ) ) {
41
  if ( file_exists( $abs_path ) ) {
42
+ $file_name = sanitize_file_name( 'sns-count-cache_data_' . date_i18n( 'YmdHis' ) . '.csv' );
43
 
44
  $size = filesize( $abs_path );
45
  header( 'Content-Length: ' . $size );
53
 
54
  ob_start();
55
  if ( $fp = fopen( $abs_path, 'rb' ) ) {
56
+ while ( ! feof( $fp ) && ( connection_status() == 0 ) ) {
57
  echo fread( $fp, 8192 );
58
  ob_flush();
59
  }
71
  }
72
  } else {
73
  wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
74
+ } // End if().
75
  die();
76
 
77
  ?>
includes/interface-scc-order.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /*
3
  interface-scc-order.php
4
 
5
  Description: This is a interface
@@ -7,10 +7,10 @@ Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
- */
11
 
12
  /*
13
- Copyright (C) 2014 - 2017 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
@@ -27,14 +27,39 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
 
 
 
30
  interface SCC_Order {
31
 
 
 
 
32
  const ORDER_DO_SECOND_CACHE = 'do_second_cache';
33
 
 
 
 
34
  const ORDER_GET_SECOND_CACHE = 'get_second_cache';
35
 
 
 
 
36
  const ORDER_DO_ANALYSIS = 'do_analysis';
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  public function order( SCC_Cache_Engine $engine, $order, $options = array() );
39
  }
40
 
1
  <?php
2
+ /**
3
  interface-scc-order.php
4
 
5
  Description: This is a interface
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
+ */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
14
 
15
  This program is free software; you can redistribute it and/or
16
  modify it under the terms of the GNU General Public License
27
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
+ /**
31
+ * SCC_Order
32
+ */
33
  interface SCC_Order {
34
 
35
+ /**
36
+ * Order do second cache
37
+ */
38
  const ORDER_DO_SECOND_CACHE = 'do_second_cache';
39
 
40
+ /**
41
+ * Order get second cache
42
+ */
43
  const ORDER_GET_SECOND_CACHE = 'get_second_cache';
44
 
45
+ /**
46
+ * Order do analysis
47
+ */
48
  const ORDER_DO_ANALYSIS = 'do_analysis';
49
 
50
+ /**
51
+ * Order check app status
52
+ */
53
+ const ORDER_CHECK_APP_STATUS = 'check_app_status';
54
+
55
+ /**
56
+ * Order
57
+ *
58
+ * @param SCC_Cache_Engine $engine Instance.
59
+ * @param string $order Order.
60
+ * @param array $options Option.
61
+ * @return mixed
62
+ */
63
  public function order( SCC_Cache_Engine $engine, $order, $options = array() );
64
  }
65
 
index.php CHANGED
@@ -32,18 +32,18 @@ require_once( '../../../wp-load.php' );
32
  if ( ! defined( 'ABSPATH' ) ) exit(); // Exit if accessed directly
33
 
34
  if ( current_user_can( 'manage_options' ) ) {
35
- if ( isset( $_GET['state'] ) && $_GET['state'] && isset( $_GET['action'] ) && $_GET['action'] && isset( $_GET['code'] ) && $_GET['code'] ) {
36
- if ( $_GET['action'] === 'instagram-auth' ) {
37
  if ( check_admin_referer( 'instagram-auth', 'state' ) ) {
38
- $redirect_url = admin_url( 'admin.php?page=scc-setting' ) . '&action=instagram-auth&code=' . $_GET['code'] .'&_wpnonce=' . $_GET['state'];
39
  wp_safe_redirect( $redirect_url );
40
  exit;
41
  } else {
42
  wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
43
  }
44
- } elseif ( $_GET['action'] === 'facebook-auth' ) {
45
  if ( check_admin_referer( 'facebook-auth', 'state' ) ) {
46
- $redirect_url = admin_url( 'admin.php?page=scc-setting' ) . '&action=facebook-auth&code=' . $_GET['code'] .'&_wpnonce=' . $_GET['state'];
47
  wp_safe_redirect( $redirect_url );
48
  exit;
49
  } else {
32
  if ( ! defined( 'ABSPATH' ) ) exit(); // Exit if accessed directly
33
 
34
  if ( current_user_can( 'manage_options' ) ) {
35
+ if ( ! empty( $_GET['state'] ) && ! empty( $_GET['action'] ) && ! empty( $_GET['code'] ) ) {
36
+ if ( 'instagram-auth' === $_GET['action'] ) {
37
  if ( check_admin_referer( 'instagram-auth', 'state' ) ) {
38
+ $redirect_url = admin_url( 'admin.php?page=scc-setting' ) . '&action=instagram-auth&code=' . $_GET['code'] . '&_wpnonce=' . $_GET['state'];
39
  wp_safe_redirect( $redirect_url );
40
  exit;
41
  } else {
42
  wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
43
  }
44
+ } elseif ( 'facebook-auth' === $_GET['action'] ) {
45
  if ( check_admin_referer( 'facebook-auth', 'state' ) ) {
46
+ $redirect_url = admin_url( 'admin.php?page=scc-setting' ) . '&action=facebook-auth&code=' . $_GET['code'] . '&_wpnonce=' . $_GET['state'];
47
  wp_safe_redirect( $redirect_url );
48
  exit;
49
  } else {
js/jquery.floatThead.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ /** @preserve jQuery.floatThead 2.1.2 - https://mkoryak.github.io/floatThead/ - Copyright (c) 2012 - 2018 Misha Koryak **/
2
+ !function(ht){ht.floatThead=ht.floatThead||{},ht.floatThead.defaults={headerCellSelector:"tr:visible:first>*:visible",zIndex:1001,position:"auto",top:0,bottom:0,scrollContainer:function(t){return ht([])},responsiveContainer:function(t){return ht([])},getSizingRow:function(t,e,o){return t.find("tbody tr:visible:first>*:visible")},floatTableClass:"floatThead-table",floatWrapperClass:"floatThead-wrapper",floatContainerClass:"floatThead-container",copyTableClass:!0,autoReflow:!1,debug:!1,support:{bootstrap:!0,datatables:!0,jqueryUI:!0,perfectScrollbar:!0},floatContainerCss:{"overflow-x":"hidden"}};var vt=function(){var n={},o=Object.prototype.hasOwnProperty;n.has=function(t,e){return o.call(t,e)},n.keys=Object.keys||function(t){if(t!==Object(t))throw new TypeError("Invalid object");var e=[];for(var o in t)n.has(t,o)&&e.push(o);return e};var r=0;return n.uniqueId=function(t){var e=++r+"";return t?t+e:e},ht.each(["Arguments","Function","String","Number","Date","RegExp"],function(){var e=this;n["is"+e]=function(t){return Object.prototype.toString.call(t)=="[object "+e+"]"}}),n.debounce=function(o,n,r){var a,i,l,s,d;return function(){l=this,i=arguments,s=new Date;var e=function(){var t=new Date-s;t<n?a=setTimeout(e,n-t):(a=null,r||(d=o.apply(l,i)))},t=r&&!a;return a||(a=setTimeout(e,n)),t&&(d=o.apply(l,i)),d}},n}(),bt="undefined"!=typeof MutationObserver,wt=function(){for(var t=3,e=document.createElement("b"),o=e.all||[];t=1+t,e.innerHTML="\x3c!--[if gt IE "+t+"]><i><![endif]--\x3e",o[0];);return 4<t?t:document.documentMode}(),t=/Gecko\//.test(navigator.userAgent),gt=/WebKit\//.test(navigator.userAgent);wt||t||gt||(wt=11);var l=function(){if(gt){var t=ht("<div>").css("width",0).append(ht("<table>").css("max-width","100%").append(ht("<tr>").append(ht("<th>").append(ht("<div>").css("min-width",100).text("X")))));ht("body").append(t);var e=0==t.find("table").width();return t.remove(),e}return!1},mt=!t&&!wt,yt=ht(window),Tt=t&&window.matchMedia;if(!window.matchMedia||Tt){var e=window.onbeforeprint,o=window.onafterprint;window.onbeforeprint=function(){e&&e(),yt.triggerHandler("fth-beforeprint")},window.onafterprint=function(){o&&o(),yt.triggerHandler("fth-afterprint")}}function Ct(t){var e=t[0].parentElement;do{if("visible"!=window.getComputedStyle(e).getPropertyValue("overflow"))break}while(e=e.parentElement);return e==document.body?ht([]):ht(e)}function xt(t){window&&window.console&&window.console.error&&window.console.error("jQuery.floatThead: "+t)}function jt(t){var e=t.getBoundingClientRect();return e.width||e.right-e.left}function St(){var t=document.createElement("scrolltester");t.style.cssText="width:100px;height:100px;overflow:scroll!important;position:absolute;top:-9999px;display:block",document.body.appendChild(t);var e=t.offsetWidth-t.clientWidth;return document.body.removeChild(t),e}function zt(t,e,o){var n=o?"outerWidth":"width";if(l&&t.css("max-width")){var r=0;o&&(r+=parseInt(t.css("borderLeft"),10),r+=parseInt(t.css("borderRight"),10));for(var a=0;a<e.length;a++)r+=jt(e.get(a));return r}return t[n]()}ht.fn.floatThead=function(t){if(t=t||{},wt<8)return this;var ut=null;if(vt.isFunction(l)&&(l=l()),vt.isString(t)){var r=t,a=Array.prototype.slice.call(arguments,1),i=this;return this.filter("table").each(function(){var t=ht(this),e=t.data("floatThead-lazy");e&&t.floatThead(e);var o=t.data("floatThead-attached");if(o&&vt.isFunction(o[r])){var n=o[r].apply(this,a);void 0!==n&&(i=n)}}),i}var pt=ht.extend({},ht.floatThead.defaults||{},t);if(ht.each(t,function(t,e){t in ht.floatThead.defaults||!pt.debug||xt("Used ["+t+"] key to init plugin, but that param is not an option for the plugin. Valid options are: "+vt.keys(ht.floatThead.defaults).join(", "))}),pt.debug){var e=ht.fn.jquery.split(".");1==parseInt(e[0],10)&&parseInt(e[1],10)<=7&&xt("jQuery version "+ht.fn.jquery+" detected! This plugin supports 1.8 or better, or 1.7.x with jQuery UI 1.8.24 -> http://jqueryui.com/resources/download/jquery-ui-1.8.24.zip")}return this.filter(":not(."+pt.floatTableClass+")").each(function(){var e=vt.uniqueId(),m=ht(this);if(m.data("floatThead-attached"))return!0;if(!m.is("table"))throw new Error('jQuery.floatThead must be run on a table element. ex: $("table").floatThead();');bt=pt.autoReflow&&bt;var d=m.children("thead:first"),o=m.children("tbody:first");if(0==d.length||0==o.length)return pt.debug&&(0==d.length?xt("The thead element is missing."):xt("The tbody element is missing.")),m.data("floatThead-lazy",pt),void m.unbind("reflow").one("reflow",function(){m.floatThead(pt)});m.data("floatThead-lazy")&&m.unbind("reflow"),m.data("floatThead-lazy",!1);var y,T,n=!0,C={vertical:0,horizontal:0};vt.isFunction(St)&&(St=St());var f=0;!0===pt.scrollContainer&&(pt.scrollContainer=Ct);var x=pt.scrollContainer(m)||ht([]),j=0<x.length,S=j?ht([]):pt.responsiveContainer(m)||ht([]),z=$(),I=null;"auto"===pt.position?I=null:"fixed"===pt.position?I=!1:"absolute"===pt.position?I=!0:pt.debug&&xt('Invalid value given to "position" option, valid is "fixed", "absolute" and "auto". You passed: ',pt.position),null==I&&(I=j);var r=m.find("caption"),L=1==r.length;if(L)var H="top"===(r.css("caption-side")||r.attr("align")||"top");var a=ht("<fthfoot>").css({display:"table-footer-group","border-spacing":0,height:0,"border-collapse":"collapse",visibility:"hidden"}),W=!1,i=ht([]),q=wt<=9&&!j&&I,c=ht("<table/>"),u=ht("<colgroup/>"),p=m.children("colgroup:first"),h=!0;0==p.length&&(p=ht("<colgroup/>"),h=!1);var v=ht("<fthtr>").css({display:"table-row","border-spacing":0,height:0,"border-collapse":"collapse"}),R=ht("<div>").css(pt.floatContainerCss).attr("aria-hidden","true"),M=!1,l=ht("<thead/>"),b=ht('<tr class="size-row" aria-hidden="true"/>'),w=ht([]),g=ht([]),E=ht([]),k=ht([]);l.append(b),m.prepend(p),mt&&(a.append(v),m.append(a)),c.append(u),R.append(c),pt.copyTableClass&&c.attr("class",m.attr("class")),c.attr({cellpadding:m.attr("cellpadding"),cellspacing:m.attr("cellspacing"),border:m.attr("border")});var t=m.css("display");if(c.css({borderCollapse:m.css("borderCollapse"),border:m.css("border"),display:t}),j||c.css("width","auto"),"none"===t&&(M=!0),c.addClass(pt.floatTableClass).css({margin:0,"border-bottom-width":0}),I){var s=function(t,e){var o=t.css("position"),n=t;if(!("relative"==o||"absolute"==o)||e){var r={paddingLeft:t.css("paddingLeft"),paddingRight:t.css("paddingRight")};R.css(r),n=t.data("floatThead-containerWrap")||t.wrap(ht("<div>").addClass(pt.floatWrapperClass).css({position:"relative",clear:"both"})).parent(),t.data("floatThead-containerWrap",n),W=!0}return n};j?(i=s(x,!0)).prepend(R):(i=s(m),m.before(R))}else m.before(R);R.css({position:I?"absolute":"fixed",marginTop:0,top:I?0:"auto",zIndex:pt.zIndex,willChange:"transform"}),R.addClass(pt.floatContainerClass),U();var D={"table-layout":"fixed"},F={"table-layout":m.css("tableLayout")||"auto"},O=m[0].style.width||"",N=m.css("minWidth")||"";function A(t){return t+".fth-"+e+".floatTHead"}function Q(){var t=0;if(d.children("tr:visible").each(function(){t+=ht(this).outerHeight(!0)}),"collapse"==m.css("border-collapse")){var e=parseInt(m.css("border-top-width"),10);parseInt(m.find("thead tr:first").find(">*:first").css("border-top-width"),10)<e&&(t-=e/2)}b.outerHeight(t),w.outerHeight(t)}function U(){y=(vt.isFunction(pt.top)?pt.top(m):pt.top)||0,T=(vt.isFunction(pt.bottom)?pt.bottom(m):pt.bottom)||0}function G(){if(!n){if(n=!0,I){var t=zt(m,k,!0);i.width()<t&&m.css("minWidth",t)}m.css(D),c.css(D),c.append(d),o.before(l),Q()}}function P(){n&&(n=!1,I&&m.width(O),l.detach(),m.prepend(d),m.css(F),c.css(F),m.css("minWidth",N),m.css("minWidth",zt(m,k)))}var V=!1;function X(t){V!=t&&(V=t,m.triggerHandler("floatThead",[t,R]))}function Y(t){I!=t&&(I=t,R.css({position:I?"absolute":"fixed"}))}function B(){var l,s=function(){var t,e=d.find(pt.headerCellSelector);if(h?t=p.find("col").length:(t=0,e.each(function(){t+=parseInt(ht(this).attr("colspan")||1,10)})),t!==f){f=t;for(var o,n=[],r=[],a=[],i=0;i<t;i++)o=e.eq(i).text(),n.push('<th class="floatThead-col" aria-label="'+o+'"/>'),r.push("<col/>"),a.push(ht("<fthtd>").css({display:"table-cell",height:0,width:"auto"}));r=r.join(""),n=n.join(""),mt&&(v.empty(),v.append(a),k=v.find("fthtd")),b.html(n),w=b.find("th"),h||p.html(r),g=p.find("col"),u.html(r),E=u.find("col")}return t}();return function(){var t=R.scrollLeft();g=p.find("col");var e,o,n,r,a=(e=m,o=g,n=k,r=wt,mt?n:r?pt.getSizingRow(e,o,n):o);if(a.length==s&&0<s){if(!h)for(l=0;l<s;l++)g.eq(l).css("width","");P();var i=[];for(l=0;l<s;l++)i[l]=jt(a.get(l));for(l=0;l<s;l++)E.eq(l).width(i[l]),g.eq(l).width(i[l]);G()}else c.append(d),m.css(F),c.css(F),Q();R.scrollLeft(t),m.triggerHandler("reflowed",[R])}}function K(t){var e=x.css("border-"+t+"-width"),o=0;return e&&~e.indexOf("px")&&(o=parseInt(e,10)),o}function $(){return"auto"==S.css("overflow-x")}function J(){var i,l=x.scrollTop(),s=0,d=L?r.outerHeight(!0):0,f=H?d:-d,c=R.height(),u=m.offset(),p=0,h=0;if(j){var t=x.offset();s=u.top-t.top+l,L&&H&&(s+=d),p=K("left"),h=K("top"),s-=h}else i=u.top-y-c+T+C.horizontal;var v=yt.scrollTop(),b=yt.scrollLeft(),w=function(){return($()?S:x).scrollLeft()||0},g=w();return function(t){z=$();var e=m[0].offsetWidth<=0&&m[0].offsetHeight<=0;if(!e&&M)return M=!1,setTimeout(function(){m.triggerHandler("reflow")},1),null;if(e&&(M=!0,!I))return null;if("windowScroll"==t)v=yt.scrollTop(),b=yt.scrollLeft();else if("containerScroll"==t)if(S.length){if(!z)return;g=S.scrollLeft()}else l=x.scrollTop(),g=x.scrollLeft();else"init"!=t&&(v=yt.scrollTop(),b=yt.scrollLeft(),l=x.scrollTop(),g=w());if(!gt||!(v<0||b<0)){if(q)Y("windowScrollDone"==t);else if("windowScrollDone"==t)return null;var o,n;u=m.offset(),L&&H&&(u.top+=d);var r=m.outerHeight();if(j&&I){if(l<=s){var a=s-l+h;o=0<a?a:0,X(!1)}else r-c<l-s?o=r-c-l-s:(o=W?h:l,X(!0));n=p}else!j&&I?(i+r+f<v?o=r-c+f+T:u.top>=v+y?(o=0,P(),X(!1)):(o=y+v-u.top+s+(H?d:0),G(),X(!0)),n=g):j&&!I?(l<s||r<l-s?(o=u.top-v,P(),X(!1)):(o=u.top+l-v-s,G(),X(!0)),n=u.left+g-b):j||I||(i+r+f<v?o=r+y-v+i+f:u.top>v+y?(o=u.top-v,G(),X(!1)):(o=y,X(!0)),n=u.left+g-b);return{top:Math.round(o),left:Math.round(n)}}}}function Z(){var i=null,l=null,s=null;return function(t,e,o){if(null!=t&&(i!=t.top||l!=t.left)){if(8===wt)R.css({top:t.top,left:t.left});else{var n="translateX("+t.left+"px) translateY("+t.top+"px)",r={"-webkit-transform":n,"-moz-transform":n,"-ms-transform":n,"-o-transform":n,transform:n,top:0};r[/rtl/i.test(document.documentElement.dir||"")?"right":"left"]=0,R.css(r)}i=t.top,l=t.left}e&&function(){var t=zt(m,k,!0),e=z?S:x,o=e.length?jt(e[0]):t,n="hidden"!=e.css("overflow-y")?o-C.vertical:o;if(R.width(n),j){var r=100*t/n;c.css("width",r+"%")}else c.css("width",t+"px")}(),o&&Q();var a=(z?S:x).scrollLeft();I&&s==a||(R.scrollLeft(a),s=a)}}function _(){if(x.length)if(pt.support&&pt.support.perfectScrollbar&&x.data().perfectScrollbar)C={horizontal:0,vertical:0};else{if("scroll"==x.css("overflow-x"))C.horizontal=St;else{var t=x.width(),e=zt(m,k),o=n<r?St:0;C.horizontal=t-o<e?St:0}if("scroll"==x.css("overflow-y"))C.vertical=St;else{var n=x.height(),r=m.height(),a=t<e?St:0;C.vertical=n-a<r?St:0}}}_();var tt=function(){B()()};tt();var et=J(),ot=Z();ot(et("init"),!0);var nt=vt.debounce(function(){ot(et("windowScrollDone"),!1)},1),rt=function(){ot(et("windowScroll"),!1),q&&nt()},at=function(){ot(et("containerScroll"),!1)},it=vt.debounce(function(){m.is(":hidden")||(_(),U(),tt(),et=J(),ot(et("reflow"),!0,!0))},1),lt=function(){P()},st=function(){G()},dt=function(t){t.matches?lt():st()},ft=null;if(window.matchMedia&&window.matchMedia("print").addListener&&!Tt?(ft=window.matchMedia("print")).addListener(dt):(yt.on("fth-beforeprint",lt),yt.on("fth-afterprint",st)),j?I?x.on(A("scroll"),at):(x.on(A("scroll"),at),yt.on(A("scroll"),rt)):(S.on(A("scroll"),at),yt.on(A("scroll"),rt)),yt.on(A("load"),it),function(t,e){if(8==wt){var o=yt.width(),n=vt.debounce(function(){var t=yt.width();o!=t&&(o=t,e())},1);yt.on(t,n)}else yt.on(t,vt.debounce(e,1))}(A("resize"),function(){m.is(":hidden")||(U(),_(),tt(),et=J(),(ot=Z())(et("resize"),!0,!0))}),m.on("reflow",it),pt.support&&pt.support.datatables&&function(t){if(t.dataTableSettings)for(var e=0;e<t.dataTableSettings.length;e++){var o=t.dataTableSettings[e].nTable;if(t[0]==o)return!0}return!1}(m)&&m.on("filter",it).on("sort",it).on("page",it),pt.support&&pt.support.bootstrap&&yt.on(A("shown.bs.tab"),it),pt.support&&pt.support.jqueryUI&&yt.on(A("tabsactivate"),it),bt){var ct=null;vt.isFunction(pt.autoReflow)&&(ct=pt.autoReflow(m,x)),ct||(ct=x.length?x[0]:m[0]),(ut=new MutationObserver(function(t){for(var e=function(t){return t&&t[0]&&("THEAD"==t[0].nodeName||"TD"==t[0].nodeName||"TH"==t[0].nodeName)},o=0;o<t.length;o++)if(!e(t[o].addedNodes)&&!e(t[o].removedNodes)){it();break}})).observe(ct,{childList:!0,subtree:!0})}m.data("floatThead-attached",{destroy:function(){var t=".fth-"+e;return P(),m.css(F),p.remove(),mt&&a.remove(),l.parent().length&&l.replaceWith(d),X(!1),bt&&(ut.disconnect(),ut=null),m.off("reflow reflowed"),x.off(t),S.off(t),W&&(x.length?x.unwrap():m.unwrap()),j?x.data("floatThead-containerWrap",!1):m.data("floatThead-containerWrap",!1),m.css("minWidth",N),R.remove(),m.data("floatThead-attached",!1),yt.off(t),yt.off("fth-beforeprint fth-afterprint"),ft&&ft.removeListener(dt),lt=st=function(){},function(){return m.floatThead(pt)}},reflow:function(){it()},setHeaderHeight:function(){Q()},getFloatContainer:function(){return R},getRowGroups:function(){return n?R.find(">table>thead").add(m.children("tbody,tfoot")):m.children("thead,tbody,tfoot")}})}),this}}(function(){var t=window.jQuery;return"undefined"!=typeof module&&module.exports&&!t&&(t=require("jquery")),t}());
js/jquery.scc-cache-info.js CHANGED
@@ -155,6 +155,16 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
155
  }
156
  }
157
 
 
 
 
 
 
 
 
 
 
 
158
  $(".loading").css('display', 'none');
159
  $("span[data-scc]").fadeIn();
160
  } else {
155
  }
156
  }
157
 
158
+ if ( isset( res.follow_count ) ) {
159
+ if (isset(res.follow_delta) && res.follow_delta.onesignal > 0) {
160
+ $("span[data-scc='fonesignal']").html(res.follow_count.onesignal + ' (<span class="delta-rise">+' + res.follow_delta.onesignal + '</span>)');
161
+ } else if (isset(res.follow_delta) && res.follow_delta.onesignal < 0) {
162
+ $("span[data-scc='fonesignal']").html(res.follow_count.onesignal + ' (<span class="delta-fall">' + res.follow_delta.onesignal + '</span>)');
163
+ } else {
164
+ $("span[data-scc='fonesignal']").html(res.follow_count.onesignal);
165
+ }
166
+ }
167
+
168
  $(".loading").css('display', 'none');
169
  $("span[data-scc]").fadeIn();
170
  } else {
js/jquery.scc-cache-info.min.js CHANGED
@@ -10,4 +10,5 @@ b("span[data-scc='fsncc']").text(a.follow.secondary.no_cache_count),b("span[data
10
  c(a.follow_count)&&(c(a.follow_delta)&&0<a.follow_delta.facebook?b("span[data-scc='ffacebook']").html(a.follow_count.facebook+' (<span class="delta-rise">+'+a.follow_delta.facebook+"</span>)"):c(a.follow_delta)&&0>a.follow_delta.facebook?b("span[data-scc='ffacebook']").html(a.follow_count.facebook+' (<span class="delta-fall">'+a.follow_delta.facebook+"</span>)"):b("span[data-scc='ffacebook']").html(a.follow_count.facebook)),c(a.follow_count)&&(c(a.follow_delta)&&0<a.follow_delta.feedly?b("span[data-scc='ffeedly']").html(a.follow_count.feedly+
11
  ' (<span class="delta-rise">+'+a.follow_delta.feedly+"</span>)"):c(a.follow_delta)&&0>a.follow_delta.feedly?b("span[data-scc='ffeedly']").html(a.follow_count.feedly+' (<span class="delta-fall">'+a.follow_delta.feedly+"</span>)"):b("span[data-scc='ffeedly']").html(a.follow_count.feedly)),c(a.follow_count)&&(c(a.follow_delta)&&0<a.follow_delta.push7?b("span[data-scc='fpush7']").html(a.follow_count.push7+' (<span class="delta-rise">+'+a.follow_delta.push7+"</span>)"):c(a.follow_delta)&&0>a.follow_delta.push7?
12
  b("span[data-scc='fpush7']").html(a.follow_count.push7+' (<span class="delta-fall">'+a.follow_delta.push7+"</span>)"):b("span[data-scc='fpush7']").html(a.follow_count.push7)),c(a.follow_count)&&(c(a.follow_delta)&&0<a.follow_delta.instagram?b("span[data-scc='finstagram']").html(a.follow_count.instagram+' (<span class="delta-rise">+'+a.follow_delta.instagram+"</span>)"):c(a.follow_delta)&&0>a.follow_delta.instagram?b("span[data-scc='finstagram']").html(a.follow_count.instagram+' (<span class="delta-fall">'+
13
- a.follow_delta.instagram+"</span>)"):b("span[data-scc='finstagram']").html(a.follow_count.instagram)),b(".loading").css("display","none"),b("span[data-scc]").fadeIn()):b("span[data-scc]").text("?")},error:function(a){b("span[data-scc]").text("?")}})})});
 
10
  c(a.follow_count)&&(c(a.follow_delta)&&0<a.follow_delta.facebook?b("span[data-scc='ffacebook']").html(a.follow_count.facebook+' (<span class="delta-rise">+'+a.follow_delta.facebook+"</span>)"):c(a.follow_delta)&&0>a.follow_delta.facebook?b("span[data-scc='ffacebook']").html(a.follow_count.facebook+' (<span class="delta-fall">'+a.follow_delta.facebook+"</span>)"):b("span[data-scc='ffacebook']").html(a.follow_count.facebook)),c(a.follow_count)&&(c(a.follow_delta)&&0<a.follow_delta.feedly?b("span[data-scc='ffeedly']").html(a.follow_count.feedly+
11
  ' (<span class="delta-rise">+'+a.follow_delta.feedly+"</span>)"):c(a.follow_delta)&&0>a.follow_delta.feedly?b("span[data-scc='ffeedly']").html(a.follow_count.feedly+' (<span class="delta-fall">'+a.follow_delta.feedly+"</span>)"):b("span[data-scc='ffeedly']").html(a.follow_count.feedly)),c(a.follow_count)&&(c(a.follow_delta)&&0<a.follow_delta.push7?b("span[data-scc='fpush7']").html(a.follow_count.push7+' (<span class="delta-rise">+'+a.follow_delta.push7+"</span>)"):c(a.follow_delta)&&0>a.follow_delta.push7?
12
  b("span[data-scc='fpush7']").html(a.follow_count.push7+' (<span class="delta-fall">'+a.follow_delta.push7+"</span>)"):b("span[data-scc='fpush7']").html(a.follow_count.push7)),c(a.follow_count)&&(c(a.follow_delta)&&0<a.follow_delta.instagram?b("span[data-scc='finstagram']").html(a.follow_count.instagram+' (<span class="delta-rise">+'+a.follow_delta.instagram+"</span>)"):c(a.follow_delta)&&0>a.follow_delta.instagram?b("span[data-scc='finstagram']").html(a.follow_count.instagram+' (<span class="delta-fall">'+
13
+ a.follow_delta.instagram+"</span>)"):b("span[data-scc='finstagram']").html(a.follow_count.instagram)),c(a.follow_count)&&(c(a.follow_delta)&&0<a.follow_delta.onesignal?b("span[data-scc='fonesignal']").html(a.follow_count.onesignal+' (<span class="delta-rise">+'+a.follow_delta.onesignal+"</span>)"):c(a.follow_delta)&&0>a.follow_delta.onesignal?b("span[data-scc='fonesignal']").html(a.follow_count.onesignal+' (<span class="delta-fall">'+a.follow_delta.onesignal+"</span>)"):b("span[data-scc='fonesignal']").html(a.follow_count.onesignal)),
14
+ b(".loading").css("display","none"),b("span[data-scc]").fadeIn()):b("span[data-scc]").text("?")},error:function(a){b("span[data-scc]").text("?")}})})});
js/jquery.scc-table.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ jquery.scc-table.js
3
+ Author: Daisuke Maruyama
4
+ Author URI: http://marubon.info/
5
+ License: GPL2 or later
6
+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
7
+ */
8
+ ;jQuery(document).ready(function ($) {
9
+ var $table = $('table.tfloat');
10
+ $table.floatThead({top: 32});
11
+ });
js/jquery.scc-table.min.js ADDED
@@ -0,0 +1 @@
 
1
+ ;jQuery(document).ready(function(a){a("table.tfloat").floatThead({top:32})});
languages/sns-count-cache-ja.mo CHANGED
Binary file
languages/sns-count-cache-ja.po CHANGED
@@ -1,15 +1,15 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: SNS Count Cache\n"
4
- "POT-Creation-Date: 2017-01-29 01:40+0900\n"
5
- "PO-Revision-Date: 2017-01-29 01:41+0900\n"
6
  "Last-Translator: Daisuke Maruyama <marubon@gmail.com>\n"
7
  "Language-Team: Daisuke Maruyama <marubon@gmail.com>\n"
8
  "Language: ja\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.8.11\n"
13
  "X-Poedit-Basepath: ..\n"
14
  "X-Poedit-WPHeader: sns-count-cache.php\n"
15
  "Plural-Forms: nplurals=1; plural=0;\n"
@@ -21,248 +21,253 @@ msgstr ""
21
  "X-Poedit-SearchPathExcluded-0: *.js\n"
22
 
23
  #. Plugin Name of the plugin/theme
24
- #: includes/admin-cache-status.php:65 includes/admin-dashboard.php:43
25
- #: includes/admin-help.php:34 includes/admin-hot-content.php:69
26
- #: includes/admin-setting.php:497 includes/admin-share-count.php:67
27
- #: sns-count-cache.php:1755
28
  msgid "SNS Count Cache"
29
  msgstr "SNS Count Cache"
30
 
31
- #: includes/admin-cache-status.php:68 includes/admin-dashboard.php:47
32
- #: includes/admin-help.php:37 includes/admin-hot-content.php:72
33
- #: includes/admin-setting.php:586 includes/admin-share-count.php:70
34
- #: sns-count-cache.php:1756
35
  msgid "Dashboard"
36
  msgstr "ダッシュボード"
37
 
38
- #: includes/admin-cache-status.php:69 includes/admin-cache-status.php:80
39
- #: includes/admin-dashboard-widget.php:47
40
- #: includes/admin-dashboard-widget.php:150 includes/admin-dashboard.php:48
41
- #: includes/admin-dashboard.php:61 includes/admin-dashboard.php:169
42
- #: includes/admin-help.php:38 includes/admin-help.php:64
43
- #: includes/admin-hot-content.php:73 includes/admin-setting.php:587
44
- #: includes/admin-share-count.php:71 sns-count-cache.php:1757
45
  msgid "Cache Status"
46
  msgstr "キャッシュ状況"
47
 
48
- #: includes/admin-cache-status.php:70 includes/admin-dashboard-widget.php:82
49
- #: includes/admin-dashboard.php:49 includes/admin-dashboard.php:96
50
- #: includes/admin-help.php:39 includes/admin-hot-content.php:74
51
- #: includes/admin-setting.php:588 includes/admin-share-count.php:72
52
- #: includes/admin-share-count.php:82 sns-count-cache.php:1758
53
  msgid "Share Count"
54
  msgstr "シェア数"
55
 
56
- #: includes/admin-cache-status.php:72 includes/admin-dashboard.php:51
57
- #: includes/admin-help.php:41 includes/admin-hot-content.php:75
58
- #: includes/admin-hot-content.php:82 includes/admin-setting.php:590
59
- #: includes/admin-share-count.php:74 sns-count-cache.php:1761
60
  msgid "Hot Content"
61
  msgstr "話題のコンテンツ"
62
 
63
- #: includes/admin-cache-status.php:74 includes/admin-dashboard.php:53
64
- #: includes/admin-help.php:43 includes/admin-hot-content.php:76
65
- #: includes/admin-setting.php:592 includes/admin-share-count.php:76
66
- #: sns-count-cache.php:1764 sns-count-cache.php:1774
67
  msgid "Setting"
68
  msgstr "設定"
69
 
70
- #: includes/admin-cache-status.php:75 includes/admin-dashboard.php:54
71
- #: includes/admin-help.php:44 includes/admin-help.php:49
72
- #: includes/admin-hot-content.php:77 includes/admin-setting.php:593
73
- #: includes/admin-share-count.php:77 sns-count-cache.php:1765
74
  msgid "Help"
75
  msgstr "ヘルプ"
76
 
77
- #: includes/admin-cache-status.php:86 includes/admin-hot-content.php:88
78
- #: includes/admin-share-count.php:88
79
  msgid "Content"
80
  msgstr "コンテンツ"
81
 
82
- #: includes/admin-cache-status.php:87 includes/admin-dashboard-widget.php:61
83
- #: includes/admin-dashboard-widget.php:164 includes/admin-dashboard.php:75
84
- #: includes/admin-dashboard.php:183
85
  msgid "Primary Cache"
86
  msgstr "一次キャッシュ"
87
 
88
- #: includes/admin-cache-status.php:88 includes/admin-dashboard-widget.php:71
89
- #: includes/admin-dashboard-widget.php:174 includes/admin-dashboard.php:85
90
- #: includes/admin-dashboard.php:193
91
  msgid "Secondary Cache"
92
  msgstr "二次キャッシュ"
93
 
94
- #: includes/admin-cache-status.php:89
95
  msgid "Crawl Date"
96
  msgstr "クロール日時"
97
 
98
- #: includes/admin-cache-status.php:128 includes/admin-cache-status.php:167
99
- #: includes/admin-cache-status.php:225 includes/admin-cache-status.php:257
100
- #: includes/admin-help.php:69
101
  msgid "full cache"
102
  msgstr "完全キャッシュ"
103
 
104
- #: includes/admin-cache-status.php:132 includes/admin-cache-status.php:171
105
- #: includes/admin-cache-status.php:229 includes/admin-cache-status.php:261
106
- #: includes/admin-help.php:70
107
  msgid "partial cache"
108
  msgstr "部分キャッシュ"
109
 
110
- #: includes/admin-cache-status.php:136 includes/admin-cache-status.php:142
111
- #: includes/admin-cache-status.php:175 includes/admin-cache-status.php:207
112
- #: includes/admin-cache-status.php:233 includes/admin-cache-status.php:265
113
- #: includes/admin-help.php:71
114
  msgid "no cache"
115
  msgstr "未キャッシュ"
116
 
117
- #: includes/admin-cache-status.php:184 includes/admin-cache-status.php:284
118
  msgid "no data"
119
  msgstr "データなし"
120
 
121
- #: includes/admin-cache-status.php:191 includes/admin-cache-status.php:292
122
- #: includes/admin-setting.php:462 includes/admin-setting.php:1555
123
  msgid "Cache"
124
  msgstr "キャッシュ"
125
 
126
- #: includes/admin-dashboard-widget.php:46 includes/admin-dashboard.php:59
127
  msgid "Share"
128
  msgstr "Share"
129
 
130
- #: includes/admin-dashboard-widget.php:51
131
- #: includes/admin-dashboard-widget.php:154 includes/admin-dashboard.php:65
132
- #: includes/admin-dashboard.php:173
133
- msgid "Cache Type"
134
- msgstr "キャッシュタイプ"
135
-
136
- #: includes/admin-dashboard-widget.php:52
137
- #: includes/admin-dashboard-widget.php:155 includes/admin-dashboard.php:66
138
- #: includes/admin-dashboard.php:174
139
- msgid "Cache Progress"
140
- msgstr "キャッシュ進捗"
141
-
142
  #: includes/admin-dashboard-widget.php:53
143
  #: includes/admin-dashboard-widget.php:156 includes/admin-dashboard.php:67
144
  #: includes/admin-dashboard.php:175
145
- msgid "Total Content"
146
- msgstr "総コンテンツ数"
147
 
148
  #: includes/admin-dashboard-widget.php:54
149
  #: includes/admin-dashboard-widget.php:157 includes/admin-dashboard.php:68
150
  #: includes/admin-dashboard.php:176
151
- msgid "State - Full Cache"
152
- msgstr "状態 - 完全キャッシュ"
153
 
154
  #: includes/admin-dashboard-widget.php:55
155
  #: includes/admin-dashboard-widget.php:158 includes/admin-dashboard.php:69
156
  #: includes/admin-dashboard.php:177
157
- msgid "State - Partial Cache"
158
- msgstr "状態 - 部分キャッシュ"
159
 
160
  #: includes/admin-dashboard-widget.php:56
161
  #: includes/admin-dashboard-widget.php:159 includes/admin-dashboard.php:70
162
  #: includes/admin-dashboard.php:178
 
 
 
 
 
 
 
 
 
 
 
 
163
  msgid "State - No Cache"
164
  msgstr "状態 - 未キャッシュ"
165
 
166
- #: includes/admin-dashboard-widget.php:96
167
- #: includes/admin-dashboard-widget.php:199 includes/admin-dashboard.php:110
168
- #: includes/admin-dashboard.php:218 includes/admin-hot-content.php:104
169
- #: includes/admin-setting.php:638 includes/admin-setting.php:1057
170
- #: includes/admin-setting.php:1541 includes/admin-share-count.php:104
171
  msgid "Twitter"
172
  msgstr "Twitter"
173
 
174
- #: includes/admin-dashboard-widget.php:99
175
- #: includes/admin-dashboard-widget.php:202 includes/admin-dashboard.php:113
176
- #: includes/admin-dashboard.php:221 includes/admin-hot-content.php:107
177
- #: includes/admin-setting.php:620 includes/admin-setting.php:1033
178
- #: includes/admin-setting.php:1525 includes/admin-share-count.php:107
179
  msgid "Facebook"
180
  msgstr "Facebook"
181
 
182
- #: includes/admin-dashboard-widget.php:102 includes/admin-dashboard.php:116
183
- #: includes/admin-hot-content.php:110 includes/admin-setting.php:623
184
- #: includes/admin-setting.php:1037 includes/admin-share-count.php:110
185
  msgid "Google+"
186
  msgstr "Google+"
187
 
188
- #: includes/admin-dashboard-widget.php:105 includes/admin-dashboard.php:119
189
- #: includes/admin-hot-content.php:113 includes/admin-setting.php:635
190
- #: includes/admin-setting.php:1053 includes/admin-share-count.php:113
191
  msgid "Pocket"
192
  msgstr "Pocket"
193
 
194
- #: includes/admin-dashboard-widget.php:108 includes/admin-dashboard.php:122
195
- #: includes/admin-hot-content.php:116 includes/admin-share-count.php:116
196
  msgid "Hatebu"
197
  msgstr "はてブ"
198
 
199
- #: includes/admin-dashboard-widget.php:111 includes/admin-dashboard.php:125
200
- #: includes/admin-hot-content.php:119 includes/admin-setting.php:632
201
- #: includes/admin-setting.php:1049 includes/admin-share-count.php:119
202
  msgid "Pinterest"
203
  msgstr "Pinterest"
204
 
205
- #: includes/admin-dashboard-widget.php:114 includes/admin-dashboard.php:128
206
- #: includes/admin-hot-content.php:122 includes/admin-setting.php:629
207
- #: includes/admin-setting.php:1045 includes/admin-share-count.php:122
208
  msgid "Linkedin"
209
  msgstr "Linkedin"
210
 
211
- #: includes/admin-dashboard-widget.php:117 includes/admin-dashboard.php:131
212
- #: includes/admin-hot-content.php:125 includes/admin-share-count.php:125
213
  msgid "Total"
214
  msgstr "合計"
215
 
216
- #: includes/admin-dashboard-widget.php:149 includes/admin-dashboard.php:167
217
  msgid "Follow"
218
  msgstr "Follow"
219
 
220
- #: includes/admin-dashboard-widget.php:185 includes/admin-dashboard.php:204
221
  msgid "Follower Count"
222
  msgstr "フォロワー数"
223
 
224
- #: includes/admin-dashboard-widget.php:205 includes/admin-dashboard.php:224
225
- #: includes/admin-setting.php:1529
226
  msgid "Feedly"
227
  msgstr "Feedly"
228
 
229
- #: includes/admin-dashboard-widget.php:208 includes/admin-dashboard.php:227
230
- #: includes/admin-setting.php:1533
231
  msgid "Instagram"
232
  msgstr "Instagram"
233
 
234
- #: includes/admin-dashboard-widget.php:211 includes/admin-dashboard.php:230
235
- #: includes/admin-setting.php:1537
236
  msgid "Push7"
237
  msgstr "Push7"
238
 
239
- #: includes/admin-help.php:51
 
 
 
 
 
240
  msgid "What is WordPress plugin SNS Cout Cache?"
241
  msgstr "WordPressプラグイン SNS Count Cacheとは何か?"
242
 
243
- #: includes/admin-help.php:52
244
  msgid ""
245
  "WordPress plugin SNS Count Cache is a plugin which helps you to shorten page "
246
  "loading time when your site displays share and follower counts. This plugin "
247
- "gets share counts such as Twitter and Facebook, Google+, Pocket, Pinterest, "
248
- "Linkedin and caches these counts in the background. This plugin alse caches "
249
- "follower counts such as Twitter and Facebook, Feedly, Instagram, Push7 in "
250
  "the same way. The share and follower counts can be retrieved quickly not "
251
  "through network but through the cache using given functions."
252
  msgstr ""
253
  "WordPressプラグイン SNS Count Cacheは、シェア数やフォロワー数を表示している場"
254
  "合にページの表示時間を高速化するプラグインです。このプラグインは、Twitter、"
255
- "Facebook、Google+、Pocket、Pinterest、Linkedin、はてなブックマークのシェア数"
256
- "をバックグラウンドで取得し、キャッシュします。またTwitter、Facebook、Feedly、"
257
- "Instagram、Push7のフォロワー数も同様の方法でキャッシュします。これらのシェア"
258
- "数とフォロワー数は、所定の関数を用いることでネットワークからではなくキャッ"
259
- "シュ経由で迅速に取得可能になります。"
260
 
261
- #: includes/admin-help.php:53
262
  msgid "How often does this plugin get and cache share counts?"
263
  msgstr "シェア数を取得、キャッシュする頻度は?"
264
 
265
- #: includes/admin-help.php:54
266
  msgid ""
267
  "Although this plugin gets share count of 20 posts at a time every 10 minutes "
268
  "by default, you can modify the setting in the \"Setting\" tab in the "
@@ -271,21 +276,21 @@ msgstr ""
271
  "デフォルトで10分ごとに20記事のシェア数を取得しますが、管理ページの「設定」タ"
272
  "ブにてその取得間隔と一度に取得対象とする記事数を変更できます。"
273
 
274
- #: includes/admin-help.php:55
275
  msgid "How can I know whether share count of each post is cached or not?"
276
  msgstr "各記事のシェア数のキャッシュ有無を確認する方法は?"
277
 
278
- #: includes/admin-help.php:56
279
  msgid ""
280
  "Cache status is described in the \"Cache Status\" tab in the administration "
281
  "page."
282
  msgstr "キャッシュ状況は、管理ページの「キャッシュ状況」タブにて確認可能です。"
283
 
284
- #: includes/admin-help.php:57
285
  msgid "How often does this plugin get and cache follower counts?"
286
  msgstr "フォロワー数を取得、キャッシュする頻度は?"
287
 
288
- #: includes/admin-help.php:58
289
  msgid ""
290
  "Although this plugin gets follower count once a day by default, you can "
291
  "modify the setting in the \"Setting\" tab in the administration page."
@@ -293,7 +298,7 @@ msgstr ""
293
  "デフォルトで1日に一回フォロワー数を取得しますが、管理ページの「設定」タブにて"
294
  "その取得間隔を変更できます。"
295
 
296
- #: includes/admin-help.php:59
297
  msgid ""
298
  "What is cache status such as \"full cache\", \"partial cache\" and \"no cache"
299
  "\"?"
@@ -301,33 +306,33 @@ msgstr ""
301
  "「完全キャッシュ」、「部分キャッシュ」、「未キャッシュ」等のキャッシュ状況と"
302
  "は何か?"
303
 
304
- #: includes/admin-help.php:60
305
  msgid "The following is the explanation of the cache status."
306
  msgstr "以下は、そのキャッシュ状況に関する説明です。"
307
 
308
- #: includes/admin-help.php:65 includes/admin-help.php:80
309
- #: includes/admin-help.php:100 includes/admin-help.php:173
310
- #: includes/admin-help.php:193
311
  msgid "Description"
312
  msgstr "説明"
313
 
314
- #: includes/admin-help.php:69
315
- msgid "Counts for selected all SNS are cached."
316
- msgstr "選択された全てのSNSのカウントがキャッシュされています。"
317
 
318
- #: includes/admin-help.php:70
319
- msgid "A subset of counts for selected SNS are cached."
320
- msgstr "選択された一部のSNSのカウントがキャッシュされています。"
321
 
322
- #: includes/admin-help.php:71
323
- msgid "Count for selected SNS are not cached at all."
324
- msgstr "選択されたSNSのカウントが全くキャッシュされていません。"
325
 
326
- #: includes/admin-help.php:74
327
  msgid "How can I get share count from the cache?"
328
  msgstr "キャッシュからSNSカウントを参照する方法は?"
329
 
330
- #: includes/admin-help.php:75
331
  msgid ""
332
  "The share count is retrieved from the cache using the following functions in "
333
  "the WordPress loop such as query_posts(), get_posts() and WP_Query()."
@@ -335,76 +340,76 @@ msgstr ""
335
  "WordPressのquery_posts()、get_posts()、WP_Query()等のループ内で下記の関数を使"
336
  "うことでキャッシュからSNSカウントを参照できます。"
337
 
338
- #: includes/admin-help.php:79 includes/admin-help.php:99
339
  msgid "Function"
340
  msgstr "関数"
341
 
342
- #: includes/admin-help.php:84
343
  msgid "Twitter share count is returned from cache."
344
- msgstr "キャッシュからTwitterのシェア数を取得します。"
345
 
346
- #: includes/admin-help.php:85
347
  msgid "Facebook share count is returned from cache."
348
- msgstr "キャッシュからFacebookのシェア数を取得します。"
349
 
350
- #: includes/admin-help.php:86
351
- msgid "Google Plus share count is returned from cache."
352
- msgstr "キャッシュからGoogle+のシェア数を取得します。"
353
-
354
- #: includes/admin-help.php:87
355
  msgid "Hatena Bookmark share count is returned from cache."
356
- msgstr "キャッシュからはてなブックマークのシェア数を取得します。"
357
 
358
- #: includes/admin-help.php:88
359
  msgid "Pocket share count is returned from cache."
360
- msgstr "キャッシュからPocketのシェア数を取得します。"
361
 
362
- #: includes/admin-help.php:89
363
  msgid "Pinterest share count is returned from cache."
364
- msgstr "キャッシュからPinterestのシェア数を取得します。"
365
 
366
- #: includes/admin-help.php:90
367
  msgid "Linkedin share count is returned from cache."
368
- msgstr "キャッシュからLinkedinのシェア数を取得します。"
369
 
370
- #: includes/admin-help.php:91
371
  msgid "Total share count of selected SNS is returned from cache."
372
- msgstr "キャッシュから対象として設定されたSNSのカウントの総和を取得します。"
373
 
374
- #: includes/admin-help.php:94
375
  msgid "How can I get follower count from the cache?"
376
  msgstr "キャッシュからフォロワーの数を参照する方法は?"
377
 
378
- #: includes/admin-help.php:95
379
  msgid ""
380
  "The follower count is retrieved from the cache using the following functions."
381
  msgstr "フォロワーの数は、以下の関数を用いることでキャッシュから参照可能です。"
382
 
383
- #: includes/admin-help.php:104
384
  msgid "Feedly follower count is returned from cache."
385
- msgstr "キャッシュからFeedlyのフォロワーの数を取得します。"
386
 
387
- #: includes/admin-help.php:105
388
  msgid "Twitter follower count is returned from cache."
389
- msgstr "キャッシュからTwitterのフォロワーの数を取得します。"
390
 
391
- #: includes/admin-help.php:106
392
  msgid "Facebook follower count is returned from cache."
393
- msgstr "キャッシュからFacebookのフォロワーの数を取得します。"
394
 
395
- #: includes/admin-help.php:107
396
  msgid "Instagram follower count is returned from cache."
397
- msgstr "キャッシュからInstagramのフォロワーの数を取得します。"
398
 
399
- #: includes/admin-help.php:108
400
  msgid "Push7 follower count is returned from cache."
401
- msgstr "キャッシュからPush7のフォロワーの数を取得します。"
402
 
403
- #: includes/admin-help.php:111
 
 
 
 
404
  msgid "Example Code"
405
  msgstr "サンプルコード"
406
 
407
- #: includes/admin-help.php:112
408
  msgid ""
409
  "The code below describes a simple example which displays share count and "
410
  "follower count using the above functions."
@@ -412,60 +417,56 @@ msgstr ""
412
  "以下のコードは、上述した関数を用いてシェア数やフォロワー数を表示する簡単な例"
413
  "です。"
414
 
415
- #: includes/admin-help.php:167
416
  msgid "How can I access specific custom field containing each share count?"
417
  msgstr "シェア数を含むカスタムフィールドにアクセスする方法は?"
418
 
419
- #: includes/admin-help.php:168
420
  msgid ""
421
  "Custom fields including share count are accessed using the following meta "
422
  "keys."
423
  msgstr ""
424
  "シェア数を含むカスタムフィールドは、以下のmeta keyを用いて参照可能です。"
425
 
426
- #: includes/admin-help.php:172 includes/admin-help.php:192
427
  msgid "Meta Key"
428
  msgstr "Meta Key"
429
 
430
- #: includes/admin-help.php:177
431
  msgid "A meta key to access Twitter share count"
432
- msgstr "Twitterのシェア数にアクセスするためのMeta Keyです。"
433
 
434
- #: includes/admin-help.php:178
435
  msgid "A meta key to access Facebook share count"
436
- msgstr "Facebookのシェア数にアクセスするためのMeta Keyです。"
437
-
438
- #: includes/admin-help.php:179
439
- msgid "A meta key to access Google+ share count"
440
- msgstr "Google+のシェア数にアクセスするためのMeta Keyです。"
441
 
442
- #: includes/admin-help.php:180
443
  msgid "A meta key to access Hatena Bookmark share count"
444
- msgstr "はてなブックマークのシェア数にアクセスするためのMeta Keyです。"
445
 
446
- #: includes/admin-help.php:181
447
  msgid "A meta key to access Pocket share count"
448
- msgstr "Pocketのシェア数にアクセスするためのMeta Keyです。"
449
 
450
- #: includes/admin-help.php:182
451
  msgid "A meta key to access Pinterest share count"
452
- msgstr "Pinterestのシェア数にアクセスするためのMeta Keyです。"
453
 
454
- #: includes/admin-help.php:183
455
  msgid "A meta key to access Linkedin share count"
456
- msgstr "Linkedinのシェア数の増減数にアクセスするためのMeta Keyです。"
457
 
458
- #: includes/admin-help.php:184
459
  msgid "A meta key to access total share count"
460
- msgstr "シェア数の合計にアクセスするためのMeta Keyです。"
461
 
462
- #: includes/admin-help.php:187
463
  msgid ""
464
  "How can I access specific custom field containing each variation of share "
465
  "count?"
466
  msgstr "シェア数の増減を含むカスタムフィールドにアクセスする方法は?"
467
 
468
- #: includes/admin-help.php:188
469
  msgid ""
470
  "Custom fields including variation of share count are accessed using the "
471
  "following meta keys."
@@ -473,91 +474,87 @@ msgstr ""
473
  "シェア数の増減を含むカスタムフィールドは、以下のmeta keyを用いて参照可能で"
474
  "す。"
475
 
476
- #: includes/admin-help.php:197
477
- msgid "A meta key to access variation of Twitter share count"
478
- msgstr "Twitterのシェア数の増減数にアクセスするためのMeta Keyです。"
479
-
480
  #: includes/admin-help.php:198
481
- msgid "A meta key to access variation of Facebook share count"
482
- msgstr "Facebookのシェア数の増減数にアクセスするためのMeta Keyです。"
483
 
484
  #: includes/admin-help.php:199
485
- msgid "A meta key to access variation of Google+ share count"
486
- msgstr "Google+のシェア数の増減数にアクセスするためのMeta Keyです。"
487
 
488
  #: includes/admin-help.php:200
489
  msgid "A meta key to access variation of Hatena Bookmark share count"
490
- msgstr "はてなブックマークのシェア数の増減数にアクセスするためのMeta Keyです。"
491
 
492
  #: includes/admin-help.php:201
493
  msgid "A meta key to access variation of Pocket share count"
494
- msgstr "Pocketのシェア数の増減数にアクセスするためのMeta Keyです。"
495
 
496
  #: includes/admin-help.php:202
497
  msgid "A meta key to access variation of Pinterest share count"
498
- msgstr "Pinterestのシェア数の増減数にアクセスするためのMeta Keyです。"
499
 
500
  #: includes/admin-help.php:203
501
  msgid "A meta key to access variation of Linkedin share count"
502
- msgstr "Linkedinのシェア数にアクセスするためのMeta Keyです"
503
 
504
  #: includes/admin-help.php:204
505
  msgid "A meta key to access variation of total share count"
506
- msgstr "シェア数合計の増減数にアクセスするためのMeta Keyです。"
507
-
508
- #: includes/admin-hot-content.php:270 includes/admin-hot-content.php:299
509
- #: includes/admin-hot-content.php:317 includes/admin-setting.php:652
510
- #: includes/admin-setting.php:689 includes/admin-setting.php:846
511
- #: includes/admin-setting.php:861 includes/admin-share-count.php:194
512
- #: includes/admin-share-count.php:208 includes/admin-share-count.php:236
513
- #: includes/admin-share-count.php:250 includes/admin-share-count.php:260
514
- #: includes/admin-share-count.php:288 includes/admin-share-count.php:302
515
- #: includes/admin-share-count.php:330 includes/admin-share-count.php:344
516
- #: includes/admin-share-count.php:354 includes/admin-share-count.php:397
517
- #: includes/admin-share-count.php:428
518
  msgid "N/A"
519
  msgstr "N/A"
520
 
521
- #: includes/admin-hot-content.php:313
522
  msgid "No hot content."
523
  msgstr "話題のコンテンツはありません。"
524
 
525
- #: includes/admin-setting.php:37 includes/admin-setting.php:1111
526
- #: includes/admin-setting.php:1158 includes/admin-setting.php:1201
527
- #: includes/admin-setting.php:1249 includes/admin-setting.php:1510
528
- #: includes/admin-setting.php:1554 includes/admin-setting.php:1632
529
- #: includes/admin-setting.php:1665 includes/admin-setting.php:1734
530
- #: includes/admin-setting.php:1766 includes/admin-setting.php:1836
531
- #: includes/admin-setting.php:2101 includes/admin-setting.php:2123
532
- #: includes/admin-setting.php:2144 includes/admin-setting.php:2194
533
- #: includes/admin-setting.php:2482
534
  msgid "Update All Options"
535
  msgstr "設定の更新"
536
 
537
- #: includes/admin-setting.php:389 includes/admin-setting.php:2537
538
  msgid "Reset"
539
  msgstr "リセット"
540
 
541
- #: includes/admin-setting.php:397 includes/admin-setting.php:2519
542
  msgid "Export"
543
  msgstr "エクスポート"
544
 
545
- #: includes/admin-setting.php:409 includes/admin-setting.php:421
546
- #: includes/admin-setting.php:1511 includes/admin-setting.php:2102
547
  msgid "Update Basis of Comparison"
548
  msgstr "比較基準の更新"
549
 
550
- #: includes/admin-setting.php:433 includes/admin-setting.php:448
551
- #: includes/admin-setting.php:1112 includes/admin-setting.php:1556
552
  msgid "Clear Cache"
553
  msgstr "キャッシュの消去"
554
 
555
- #: includes/admin-setting.php:474 includes/admin-setting.php:1810
556
- #: includes/admin-setting.php:1838
557
  msgid "Get Bearer Token"
558
  msgstr "Bearer Tokenの取得"
559
 
560
- #: includes/admin-setting.php:522
561
  msgid ""
562
  "There was a problem spawning a call to the WP-Cron system on your site. This "
563
  "means WP-Cron jobs on your site may not work. The problem was: "
@@ -565,7 +562,7 @@ msgstr ""
565
  "あなたのサイト上でWP-Cronシステムの呼び出し処理に問題が見つかりました。あなた"
566
  "のサイト上でWP-Cronジョブが動作しない可能性があります。問題は次の通りです。"
567
 
568
- #: includes/admin-setting.php:532
569
  msgid ""
570
  "Configuratin is not enough to get share count. Please set required "
571
  "parameters at "
@@ -573,12 +570,13 @@ msgstr ""
573
  "シェア数を取得するために必要な設定が不足しています。次のセクションで必要なパ"
574
  "ラメータを設定して下さい。"
575
 
576
- #: includes/admin-setting.php:533 includes/admin-setting.php:1119
577
  msgid "Share Base Cache - Facebook"
578
  msgstr "シェア基本キャッシュ - Facebook"
579
 
580
- #: includes/admin-setting.php:543 includes/admin-setting.php:554
581
- #: includes/admin-setting.php:565 includes/admin-setting.php:576
 
582
  msgid ""
583
  "Configuratin is not enough to get follower count. Please set required "
584
  "parameters at "
@@ -586,343 +584,346 @@ msgstr ""
586
  "フォロワー数を取得するために必要な設定が不足しています。次のセクションで必要"
587
  "なパラメータを設定して下さい。"
588
 
589
- #: includes/admin-setting.php:544 includes/admin-setting.php:1673
590
  msgid "Follow Base Cache - Instagram"
591
  msgstr "フォロー基本キャシュ機能 - Instagram"
592
 
593
- #: includes/admin-setting.php:555 includes/admin-setting.php:854
594
- #: includes/admin-setting.php:1563
595
  msgid "Follow Base Cache - Facebook"
596
  msgstr "フォロー基本キャッシュ機能 - Facebook"
597
 
598
- #: includes/admin-setting.php:566 includes/admin-setting.php:1745
599
  msgid "Follow Base Cache - Push7"
600
  msgstr "フォロー基本キャッシュ機能 - Push7"
601
 
602
- #: includes/admin-setting.php:577 includes/admin-setting.php:839
603
- #: includes/admin-setting.php:1774
604
  msgid "Follow Base Cache - Twitter"
605
  msgstr "フォロー基本キャッシュ機能 - Twitter"
606
 
607
- #: includes/admin-setting.php:596 includes/admin-setting.php:601
 
 
 
 
608
  msgid "Current Setting"
609
  msgstr "現在の設定"
610
 
611
- #: includes/admin-setting.php:596 includes/admin-setting.php:613
612
- #: includes/admin-setting.php:645 includes/admin-setting.php:658
613
- #: includes/admin-setting.php:663 includes/admin-setting.php:668
614
- #: includes/admin-setting.php:682 includes/admin-setting.php:1025
615
  msgid "Share Base Cache"
616
  msgstr "シェア基本キャッシュ機能"
617
 
618
- #: includes/admin-setting.php:596 includes/admin-setting.php:716
619
- #: includes/admin-setting.php:729 includes/admin-setting.php:737
620
- #: includes/admin-setting.php:1208
621
  msgid "Share Rush Cache"
622
  msgstr "シェア臨時キャッシュ機能"
623
 
624
- #: includes/admin-setting.php:596 includes/admin-setting.php:743
625
- #: includes/admin-setting.php:766 includes/admin-setting.php:1255
626
  msgid "Share Variation Analysis"
627
  msgstr "シェア変動分析機能"
628
 
629
- #: includes/admin-setting.php:596 includes/admin-setting.php:774
630
- #: includes/admin-setting.php:799 includes/admin-setting.php:1517
631
  msgid "Follow Base Cache"
632
  msgstr "フォロー基本キャッシュ機能"
633
 
634
- #: includes/admin-setting.php:596 includes/admin-setting.php:868
635
- #: includes/admin-setting.php:891 includes/admin-setting.php:1846
636
  msgid "Follow Variation Analysis"
637
  msgstr "フォロー変動分析機能"
638
 
639
- #: includes/admin-setting.php:596 includes/admin-setting.php:899
640
- #: includes/admin-setting.php:2108
641
  msgid "Dynamic Cache"
642
  msgstr "動的キャッシュ機能"
643
 
644
- #: includes/admin-setting.php:596 includes/admin-setting.php:916
645
- #: includes/admin-setting.php:2129
646
  msgid "Fault Tolerance"
647
  msgstr "フォールトトレランス機能"
648
 
649
- #: includes/admin-setting.php:596 includes/admin-setting.php:933
650
- #: includes/admin-setting.php:949 includes/admin-setting.php:977
651
- #: includes/admin-setting.php:2150
652
  msgid "Data Crawler"
653
  msgstr "データクローラ機能"
654
 
655
- #: includes/admin-setting.php:596 includes/admin-setting.php:990
656
- #: includes/admin-setting.php:1008 includes/admin-setting.php:2200
657
  msgid "Data Export"
658
  msgstr "データエクスポート機能"
659
 
660
- #: includes/admin-setting.php:596 includes/admin-setting.php:2491
661
  msgid "Exported File"
662
  msgstr "エクスポートされたファイル"
663
 
664
- #: includes/admin-setting.php:606
665
  msgid "Capability"
666
  msgstr "機能"
667
 
668
- #: includes/admin-setting.php:607
669
  msgid "Parameter"
670
  msgstr "パラメータ"
671
 
672
- #: includes/admin-setting.php:608
673
  msgid "Value"
674
  msgstr "値"
675
 
676
- #: includes/admin-setting.php:614 includes/admin-setting.php:775
677
- #: includes/admin-setting.php:1029 includes/admin-setting.php:1521
678
  msgid "Target SNS"
679
  msgstr "対象SNS"
680
 
681
- #: includes/admin-setting.php:626 includes/admin-setting.php:1041
682
  msgid "Hatena Bookmark"
683
  msgstr "はてなブックマーク"
684
 
685
- #: includes/admin-setting.php:646 includes/admin-setting.php:1062
686
  msgid "Custom post types"
687
  msgstr "カスタム投稿タイプ"
688
 
689
- #: includes/admin-setting.php:659 includes/admin-setting.php:730
690
- #: includes/admin-setting.php:1070 includes/admin-setting.php:1234
691
  msgid "Interval cheking share count (sec)"
692
  msgstr "シェア数のチェック間隔(秒)"
693
 
694
- #: includes/admin-setting.php:660 includes/admin-setting.php:733
695
- #: includes/admin-setting.php:801
696
  msgid "seconds"
697
  msgstr "秒"
698
 
699
- #: includes/admin-setting.php:664 includes/admin-setting.php:738
700
- #: includes/admin-setting.php:1077 includes/admin-setting.php:1241
701
  msgid "Number of contents to check at a time"
702
  msgstr "一度にチェックするコンテンツ数"
703
 
704
- #: includes/admin-setting.php:665 includes/admin-setting.php:739
705
  msgid "contents"
706
  msgstr "コンテンツ"
707
 
708
- #: includes/admin-setting.php:669 includes/admin-setting.php:1084
709
  msgid "Scheme migration mode from http to https"
710
  msgstr "HTTPからHTTPSへのスキーム移行モード"
711
 
712
- #: includes/admin-setting.php:673 includes/admin-setting.php:982
713
- #: includes/admin-setting.php:1088 includes/admin-setting.php:2187
714
  msgid "On"
715
  msgstr "有効"
716
 
717
- #: includes/admin-setting.php:675 includes/admin-setting.php:984
718
- #: includes/admin-setting.php:1087 includes/admin-setting.php:2186
719
  msgid "Off"
720
  msgstr "無効"
721
 
722
- #: includes/admin-setting.php:683 includes/admin-setting.php:1095
723
  msgid "Scheme migration date from http to https"
724
  msgstr "HTTPからHTTPSへのスキーム移行日"
725
 
726
- #: includes/admin-setting.php:698 includes/admin-setting.php:1166
727
  msgid "Share Base Cache - Twitter"
728
  msgstr "シェア基本キャッシュ機能 - Twitter"
729
 
730
- #: includes/admin-setting.php:699 includes/admin-setting.php:1170
731
  msgid "Alternative Twitter API"
732
  msgstr "代替Twitter API"
733
 
734
- #: includes/admin-setting.php:717 includes/admin-setting.php:1212
735
  msgid "Term considering posted content as new content"
736
  msgstr "投稿日からコンテンツを新着とみなす期間"
737
 
738
- #: includes/admin-setting.php:721
739
  msgid "day"
740
  msgstr "日"
741
 
742
- #: includes/admin-setting.php:723
743
  msgid "days"
744
  msgstr "日"
745
 
746
- #: includes/admin-setting.php:744 includes/admin-setting.php:869
747
- #: includes/admin-setting.php:1259 includes/admin-setting.php:1850
748
  msgid "Method to update basis of comparison"
749
  msgstr "比較基準の更新方式"
750
 
751
- #: includes/admin-setting.php:748 includes/admin-setting.php:757
752
- #: includes/admin-setting.php:873 includes/admin-setting.php:882
753
- #: includes/admin-setting.php:1262 includes/admin-setting.php:1266
754
- #: includes/admin-setting.php:1853 includes/admin-setting.php:1857
755
  msgid "Disabled (None)"
756
  msgstr "無効(なし)"
757
 
758
- #: includes/admin-setting.php:751 includes/admin-setting.php:876
759
- #: includes/admin-setting.php:1263 includes/admin-setting.php:1854
760
  msgid "Enabled (Manual)"
761
  msgstr "有効(手動)"
762
 
763
- #: includes/admin-setting.php:754 includes/admin-setting.php:879
764
- #: includes/admin-setting.php:1264 includes/admin-setting.php:1855
765
  msgid "Enabled (Scheduler)"
766
  msgstr "有効(スケジューラ)"
767
 
768
- #: includes/admin-setting.php:767 includes/admin-setting.php:892
769
  msgid "Schedule"
770
  msgstr "スケジュール"
771
 
772
- #: includes/admin-setting.php:800 includes/admin-setting.php:1546
773
  msgid "Interval cheking follower count (sec)"
774
  msgstr "フォロワー数のチェック間隔(秒)"
775
 
776
- #: includes/admin-setting.php:805 includes/admin-setting.php:832
777
- #: includes/admin-setting.php:1643
778
  msgid "Follow Base Cache - Feedly"
779
  msgstr "フォロー基本キャッシュ機能 - Feedly"
780
 
781
- #: includes/admin-setting.php:806 includes/admin-setting.php:1647
782
  msgid "Target feed type"
783
  msgstr "対象フィードタイプ"
784
 
785
- #: includes/admin-setting.php:811 includes/admin-setting.php:826
786
- #: includes/admin-setting.php:1650
787
  msgid "Default"
788
  msgstr "デフォルト"
789
 
790
- #: includes/admin-setting.php:814 includes/admin-setting.php:1651
791
  msgid "RSS"
792
  msgstr "RSS"
793
 
794
- #: includes/admin-setting.php:817 includes/admin-setting.php:1652
795
  msgid "RSS2"
796
  msgstr "RSS2"
797
 
798
- #: includes/admin-setting.php:820 includes/admin-setting.php:1653
799
  msgid "RDF"
800
  msgstr "RDF"
801
 
802
- #: includes/admin-setting.php:823 includes/admin-setting.php:1654
803
  msgid "ATOM"
804
  msgstr "ATOM"
805
 
806
- #: includes/admin-setting.php:833 includes/admin-setting.php:1660
807
  msgid "Target feed"
808
  msgstr "対象フィード"
809
 
810
- #: includes/admin-setting.php:840
811
  msgid "Target screen name"
812
  msgstr "対象スクリーンネーム"
813
 
814
- #: includes/admin-setting.php:855 includes/admin-setting.php:1567
815
  msgid "Page ID"
816
  msgstr "対象ページID"
817
 
818
- #: includes/admin-setting.php:900 includes/admin-setting.php:2112
819
  msgid "Dynamic caching based on user access"
820
  msgstr "ユーザアクセスをトリガとする動的キャッシュ"
821
 
822
- #: includes/admin-setting.php:904 includes/admin-setting.php:910
823
- #: includes/admin-setting.php:921 includes/admin-setting.php:927
824
- #: includes/admin-setting.php:2115 includes/admin-setting.php:2136
825
  msgid "Disabled"
826
  msgstr "無効"
827
 
828
- #: includes/admin-setting.php:907 includes/admin-setting.php:924
829
- #: includes/admin-setting.php:2116 includes/admin-setting.php:2137
830
  msgid "Enabled"
831
  msgstr "有効"
832
 
833
- #: includes/admin-setting.php:917
834
  msgid "Fault tolerance of count retrieval"
835
  msgstr "カウント取得における障害耐性"
836
 
837
- #: includes/admin-setting.php:934 includes/admin-setting.php:2154
838
  msgid "Crawl method"
839
  msgstr "クロールの方式"
840
 
841
- #: includes/admin-setting.php:939 includes/admin-setting.php:2159
842
  msgid "Normal (Sequential Retrieval)"
843
  msgstr "標準(逐次検索)"
844
 
845
- #: includes/admin-setting.php:942 includes/admin-setting.php:2162
846
  msgid "Extended (Parallel Retrieval)"
847
  msgstr "拡張(並列検索)"
848
 
849
- #: includes/admin-setting.php:950 includes/admin-setting.php:2169
850
  msgid "Crawl retry limit"
851
  msgstr "クロールの再試行上限"
852
 
853
- #: includes/admin-setting.php:955 includes/admin-setting.php:2172
854
  msgid "no retry"
855
  msgstr "再試行なし"
856
 
857
- #: includes/admin-setting.php:958 includes/admin-setting.php:2173
858
  msgid "1 time"
859
  msgstr "1回"
860
 
861
- #: includes/admin-setting.php:961 includes/admin-setting.php:967
862
- #: includes/admin-setting.php:2174
863
  msgid "2 times"
864
  msgstr "2回"
865
 
866
- #: includes/admin-setting.php:964 includes/admin-setting.php:2175
867
  msgid "3 times"
868
  msgstr "3回"
869
 
870
- #: includes/admin-setting.php:970 includes/admin-setting.php:2177
871
  msgid "5 times"
872
  msgstr "5回"
873
 
874
- #: includes/admin-setting.php:978 includes/admin-setting.php:2183
875
  msgid "SSL verification"
876
  msgstr "SSL証明書の検証"
877
 
878
- #: includes/admin-setting.php:991 includes/admin-setting.php:2204
879
  msgid "Method of data export"
880
  msgstr "データのエクスポート方式"
881
 
882
- #: includes/admin-setting.php:995 includes/admin-setting.php:2207
883
  msgid "Manual"
884
  msgstr "手動"
885
 
886
- #: includes/admin-setting.php:998 includes/admin-setting.php:1299
887
- #: includes/admin-setting.php:1890 includes/admin-setting.php:2208
888
- #: includes/admin-setting.php:2243
889
  msgid "Scheduler"
890
- msgstr "有効(スケジューラ)"
891
 
892
- #: includes/admin-setting.php:1009
893
  msgid "Interval exporting share count to a csv file"
894
  msgstr "シェア数をCSVファイルにエクスポートする間隔"
895
 
896
- #: includes/admin-setting.php:1010
897
  msgid "hours"
898
  msgstr "時間"
899
 
900
- #: includes/admin-setting.php:1066
901
  msgid "e.g. aaa, bbb, ccc (comma-delimited)"
902
  msgstr "例. aaa, bbb, ccc(カンマ区切り)"
903
 
904
- #: includes/admin-setting.php:1073 includes/admin-setting.php:1237
905
- msgid "Default: 600"
906
- msgstr "既定値: 600"
907
 
908
- #: includes/admin-setting.php:1080 includes/admin-setting.php:1244
909
- msgid "Default: 20"
910
- msgstr "既定値: 20"
911
 
912
- #: includes/admin-setting.php:1090
913
  msgid "Default: Off"
914
  msgstr "既定値: 無効"
915
 
916
- #: includes/admin-setting.php:1098
917
  msgid "Default: N/A"
918
  msgstr "既定値: N/A"
919
 
920
- #: includes/admin-setting.php:1123 includes/admin-setting.php:1575
921
- #: includes/admin-setting.php:1677 includes/admin-setting.php:1787
922
  msgid "Developer page"
923
  msgstr "開発者向けページ"
924
 
925
- #: includes/admin-setting.php:1127 includes/admin-setting.php:1579
926
  msgid ""
927
  "Register a application in Facebook developer page to get the following App "
928
  "ID and App Secret."
@@ -930,41 +931,41 @@ msgstr ""
930
  "以下のApp IDとApp Secretを取得するために、Facebook開発者向けページでアプリ"
931
  "ケーションを登録して下さい。"
932
 
933
- #: includes/admin-setting.php:1131 includes/admin-setting.php:1583
934
- msgid "App ID (Client ID)"
935
- msgstr "App ID (Client ID)"
936
 
937
- #: includes/admin-setting.php:1135 includes/admin-setting.php:1587
938
  msgid "App ID for Facebook API"
939
- msgstr "Facebook API用のAPP ID"
940
 
941
- #: includes/admin-setting.php:1139 includes/admin-setting.php:1591
942
- msgid "App Secret (Client Secret)"
943
- msgstr "App Secret (Client Secret)"
944
 
945
- #: includes/admin-setting.php:1143 includes/admin-setting.php:1595
946
  msgid "App Secret for Facebook API"
947
  msgstr "Facebook API用のApp Secret"
948
 
949
- #: includes/admin-setting.php:1148 includes/admin-setting.php:1608
950
- #: includes/admin-setting.php:1622 includes/admin-setting.php:1710
951
- #: includes/admin-setting.php:1724
952
  msgid "Access Token"
953
  msgstr "Access Token"
954
 
955
- #: includes/admin-setting.php:1152 includes/admin-setting.php:1626
956
  msgid "Access Token for Facebook API"
957
  msgstr "Facebook API用のAccess Token"
958
 
959
- #: includes/admin-setting.php:1178
960
- msgid "Default: "
961
- msgstr "既定値: "
962
 
963
- #: includes/admin-setting.php:1182
964
  msgid "Registration destination"
965
  msgstr "登録先"
966
 
967
- #: includes/admin-setting.php:1196
968
  msgid ""
969
  "You need to register information such as your domain with the above site in "
970
  "order to start counting."
@@ -972,307 +973,315 @@ msgstr ""
972
  "カウントを開始するためには、上記サイトにドメイン等の情報を登録する必要があり"
973
  "ます。"
974
 
975
- #: includes/admin-setting.php:1215
976
  msgid "1 day"
977
  msgstr "1日"
978
 
979
- #: includes/admin-setting.php:1216
980
  msgid "2 days"
981
  msgstr "2日"
982
 
983
- #: includes/admin-setting.php:1217
984
  msgid "3 days"
985
  msgstr "3日"
986
 
987
- #: includes/admin-setting.php:1218
988
  msgid "4 days"
989
  msgstr "4日"
990
 
991
- #: includes/admin-setting.php:1219
992
  msgid "5 days"
993
  msgstr "5日"
994
 
995
- #: includes/admin-setting.php:1220
996
  msgid "6 days"
997
  msgstr "6日"
998
 
999
- #: includes/admin-setting.php:1221
1000
  msgid "7 days"
1001
  msgstr "7日"
1002
 
1003
- #: includes/admin-setting.php:1222
1004
  msgid "8 days"
1005
  msgstr "8日"
1006
 
1007
- #: includes/admin-setting.php:1223
1008
  msgid "9 days"
1009
  msgstr "9日"
1010
 
1011
- #: includes/admin-setting.php:1224
1012
  msgid "10 days"
1013
  msgstr "10日"
1014
 
1015
- #: includes/admin-setting.php:1225
1016
  msgid "11 days"
1017
  msgstr "11日"
1018
 
1019
- #: includes/admin-setting.php:1226
1020
  msgid "12 days"
1021
  msgstr "12日"
1022
 
1023
- #: includes/admin-setting.php:1227
1024
  msgid "13 days"
1025
  msgstr "13日"
1026
 
1027
- #: includes/admin-setting.php:1228
1028
  msgid "14 days"
1029
  msgstr "14日"
1030
 
1031
- #: includes/admin-setting.php:1230
1032
  msgid "Default: 3 days"
1033
  msgstr "既定値: 3日"
1034
 
1035
- #: includes/admin-setting.php:1304 includes/admin-setting.php:1895
1036
- #: includes/admin-setting.php:2248
 
 
 
 
 
 
 
 
1037
  msgid "Type"
1038
  msgstr "タイプ"
1039
 
1040
- #: includes/admin-setting.php:1309 includes/admin-setting.php:1900
1041
- #: includes/admin-setting.php:2253
1042
  msgid "Hour"
1043
  msgstr "時"
1044
 
1045
- #: includes/admin-setting.php:1312 includes/admin-setting.php:1903
1046
- #: includes/admin-setting.php:2256
1047
  msgid "Minute"
1048
  msgstr "分"
1049
 
1050
- #: includes/admin-setting.php:1318 includes/admin-setting.php:1909
1051
- #: includes/admin-setting.php:2262
1052
  msgid "monthly"
1053
  msgstr "毎月"
1054
 
1055
- #: includes/admin-setting.php:1329 includes/admin-setting.php:1920
1056
- #: includes/admin-setting.php:2273
1057
  msgid "on 1."
1058
  msgstr "1日"
1059
 
1060
- #: includes/admin-setting.php:1332 includes/admin-setting.php:1923
1061
- #: includes/admin-setting.php:2276
1062
  msgid "on 2."
1063
  msgstr "2日"
1064
 
1065
- #: includes/admin-setting.php:1335 includes/admin-setting.php:1926
1066
- #: includes/admin-setting.php:2279
1067
  msgid "on 3."
1068
  msgstr "3日"
1069
 
1070
- #: includes/admin-setting.php:1338 includes/admin-setting.php:1929
1071
- #: includes/admin-setting.php:2282
1072
  msgid "on 4."
1073
  msgstr "4日"
1074
 
1075
- #: includes/admin-setting.php:1341 includes/admin-setting.php:1932
1076
- #: includes/admin-setting.php:2285
1077
  msgid "on 5."
1078
  msgstr "5日"
1079
 
1080
- #: includes/admin-setting.php:1344 includes/admin-setting.php:1935
1081
- #: includes/admin-setting.php:2288
1082
  msgid "on 6."
1083
  msgstr "6日"
1084
 
1085
- #: includes/admin-setting.php:1347 includes/admin-setting.php:1938
1086
- #: includes/admin-setting.php:2291
1087
  msgid "on 7."
1088
  msgstr "7日"
1089
 
1090
- #: includes/admin-setting.php:1350 includes/admin-setting.php:1941
1091
- #: includes/admin-setting.php:2294
1092
  msgid "on 8."
1093
  msgstr "8日"
1094
 
1095
- #: includes/admin-setting.php:1353 includes/admin-setting.php:1944
1096
- #: includes/admin-setting.php:2297
1097
  msgid "on 9."
1098
  msgstr "9日"
1099
 
1100
- #: includes/admin-setting.php:1356 includes/admin-setting.php:1947
1101
- #: includes/admin-setting.php:2300
1102
  msgid "on 10."
1103
  msgstr "10日"
1104
 
1105
- #: includes/admin-setting.php:1359 includes/admin-setting.php:1950
1106
- #: includes/admin-setting.php:2303
1107
  msgid "on 11."
1108
  msgstr "11日"
1109
 
1110
- #: includes/admin-setting.php:1362 includes/admin-setting.php:1953
1111
- #: includes/admin-setting.php:2306
1112
  msgid "on 12."
1113
  msgstr "12日"
1114
 
1115
- #: includes/admin-setting.php:1365 includes/admin-setting.php:1956
1116
- #: includes/admin-setting.php:2309
1117
  msgid "on 13."
1118
  msgstr "13日"
1119
 
1120
- #: includes/admin-setting.php:1368 includes/admin-setting.php:1959
1121
- #: includes/admin-setting.php:2312
1122
  msgid "on 14."
1123
  msgstr "14日"
1124
 
1125
- #: includes/admin-setting.php:1371 includes/admin-setting.php:1962
1126
- #: includes/admin-setting.php:2315
1127
  msgid "on 15."
1128
  msgstr "15日"
1129
 
1130
- #: includes/admin-setting.php:1374 includes/admin-setting.php:1965
1131
- #: includes/admin-setting.php:2318
1132
  msgid "on 16."
1133
  msgstr "16日"
1134
 
1135
- #: includes/admin-setting.php:1377 includes/admin-setting.php:1968
1136
- #: includes/admin-setting.php:2321
1137
  msgid "on 17."
1138
  msgstr "17日"
1139
 
1140
- #: includes/admin-setting.php:1380 includes/admin-setting.php:1971
1141
- #: includes/admin-setting.php:2324
1142
  msgid "on 18."
1143
  msgstr "18日"
1144
 
1145
- #: includes/admin-setting.php:1383 includes/admin-setting.php:1974
1146
- #: includes/admin-setting.php:2327
1147
  msgid "on 19."
1148
  msgstr "19日"
1149
 
1150
- #: includes/admin-setting.php:1386 includes/admin-setting.php:1977
1151
- #: includes/admin-setting.php:2330
1152
  msgid "on 20."
1153
  msgstr "20日"
1154
 
1155
- #: includes/admin-setting.php:1389 includes/admin-setting.php:1980
1156
- #: includes/admin-setting.php:2333
1157
  msgid "on 21."
1158
  msgstr "21日"
1159
 
1160
- #: includes/admin-setting.php:1392 includes/admin-setting.php:1983
1161
- #: includes/admin-setting.php:2336
1162
  msgid "on 22."
1163
  msgstr "22日"
1164
 
1165
- #: includes/admin-setting.php:1395 includes/admin-setting.php:1986
1166
- #: includes/admin-setting.php:2339
1167
  msgid "on 23."
1168
  msgstr "23日"
1169
 
1170
- #: includes/admin-setting.php:1398 includes/admin-setting.php:1989
1171
- #: includes/admin-setting.php:2342
1172
  msgid "on 24."
1173
  msgstr "24日"
1174
 
1175
- #: includes/admin-setting.php:1401 includes/admin-setting.php:1992
1176
- #: includes/admin-setting.php:2345
1177
  msgid "on 25."
1178
  msgstr "25日"
1179
 
1180
- #: includes/admin-setting.php:1404 includes/admin-setting.php:1995
1181
- #: includes/admin-setting.php:2348
1182
  msgid "on 26."
1183
  msgstr "26日"
1184
 
1185
- #: includes/admin-setting.php:1407 includes/admin-setting.php:1998
1186
- #: includes/admin-setting.php:2351
1187
  msgid "on 27."
1188
  msgstr "27日"
1189
 
1190
- #: includes/admin-setting.php:1410 includes/admin-setting.php:2001
1191
- #: includes/admin-setting.php:2354
1192
  msgid "on 28."
1193
  msgstr "28日"
1194
 
1195
- #: includes/admin-setting.php:1413 includes/admin-setting.php:2004
1196
- #: includes/admin-setting.php:2357
1197
  msgid "on 29."
1198
  msgstr "29日"
1199
 
1200
- #: includes/admin-setting.php:1416 includes/admin-setting.php:2007
1201
- #: includes/admin-setting.php:2360
1202
  msgid "on 30."
1203
  msgstr "30日"
1204
 
1205
- #: includes/admin-setting.php:1419 includes/admin-setting.php:2010
1206
- #: includes/admin-setting.php:2363
1207
  msgid "on 31."
1208
  msgstr "31日"
1209
 
1210
- #: includes/admin-setting.php:1446 includes/admin-setting.php:2037
1211
- #: includes/admin-setting.php:2394
1212
  msgid "weekly"
1213
  msgstr "毎週"
1214
 
1215
- #: includes/admin-setting.php:1452 includes/admin-setting.php:2043
1216
- #: includes/admin-setting.php:2400
1217
  msgid "Sunday"
1218
  msgstr "日曜日"
1219
 
1220
- #: includes/admin-setting.php:1453 includes/admin-setting.php:2044
1221
- #: includes/admin-setting.php:2401
1222
  msgid "Monday"
1223
  msgstr "月曜日"
1224
 
1225
- #: includes/admin-setting.php:1454 includes/admin-setting.php:2045
1226
- #: includes/admin-setting.php:2402
1227
  msgid "Tuesday"
1228
  msgstr "火曜日"
1229
 
1230
- #: includes/admin-setting.php:1455 includes/admin-setting.php:2046
1231
- #: includes/admin-setting.php:2403
1232
  msgid "Wednesday"
1233
  msgstr "水曜日"
1234
 
1235
- #: includes/admin-setting.php:1456 includes/admin-setting.php:2047
1236
- #: includes/admin-setting.php:2404
1237
  msgid "Thursday"
1238
  msgstr "木曜日"
1239
 
1240
- #: includes/admin-setting.php:1457 includes/admin-setting.php:2048
1241
- #: includes/admin-setting.php:2405
1242
  msgid "Friday"
1243
  msgstr "金曜日"
1244
 
1245
- #: includes/admin-setting.php:1458 includes/admin-setting.php:2049
1246
- #: includes/admin-setting.php:2406
1247
  msgid "Saturday"
1248
  msgstr "土曜日"
1249
 
1250
- #: includes/admin-setting.php:1480 includes/admin-setting.php:2071
1251
- #: includes/admin-setting.php:2432
1252
  msgid "daily"
1253
  msgstr "毎日"
1254
 
1255
- #: includes/admin-setting.php:1549
1256
  msgid "Default: 86400 Minimum: 3600"
1257
  msgstr "既定値: 86400 最小値: 3600"
1258
 
1259
- #: includes/admin-setting.php:1571
1260
  msgid "Facebook page ID that you want to get follower count"
1261
  msgstr "フォロワー数取得対象のFacebookページID"
1262
 
1263
- #: includes/admin-setting.php:1599 includes/admin-setting.php:1701
1264
  msgid "Redirect URI"
1265
  msgstr "Redirect URI"
1266
 
1267
- #: includes/admin-setting.php:1601 includes/admin-setting.php:1611
1268
- #: includes/admin-setting.php:1703 includes/admin-setting.php:1713
1269
- #: includes/admin-setting.php:1815
1270
  msgid "To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac)."
1271
  msgstr ""
1272
  "フィールドをクリック後、Ctrl + C (PC)、またはCmd + C (Mac)を押下しコピーして"
1273
  "下さい。"
1274
 
1275
- #: includes/admin-setting.php:1603
1276
  msgid ""
1277
  "Copy and set this to the field of \"Valid OAuth redirect URIs\" in "
1278
  "application management page of Facebook developer page."
@@ -1280,20 +1289,20 @@ msgstr ""
1280
  "Facebook開発者向けページ内のアプリケーション管理ページにて「有効なOAuthリダイ"
1281
  "レクトURI」フィールドにこのURIを設定して下さい。"
1282
 
1283
- #: includes/admin-setting.php:1613 includes/admin-setting.php:1715
1284
- #: includes/admin-setting.php:1817
1285
  msgid "Copy and pase this into the fields below."
1286
  msgstr "以下のフィールドにコピー&ペーストして下さい。"
1287
 
1288
- #: includes/admin-setting.php:1634 includes/admin-setting.php:1736
1289
  msgid "Get Access Token"
1290
  msgstr "Access Tokenの取得"
1291
 
1292
- #: includes/admin-setting.php:1656
1293
  msgid "Default: Default"
1294
  msgstr "既定値: デフォルト"
1295
 
1296
- #: includes/admin-setting.php:1681
1297
  msgid ""
1298
  "Register a client in Instagram developer page to get the following Client ID "
1299
  "and Client Secret."
@@ -1301,23 +1310,23 @@ msgstr ""
1301
  "以下のClient IDとClient Secretを取得するために、Instagram開発者向けページでク"
1302
  "ライアントを登録して下さい。"
1303
 
1304
- #: includes/admin-setting.php:1685
1305
  msgid "Client ID"
1306
  msgstr "Client ID"
1307
 
1308
- #: includes/admin-setting.php:1689
1309
  msgid "Client ID for Instagram API"
1310
  msgstr "Instagram API用のClient ID"
1311
 
1312
- #: includes/admin-setting.php:1693
1313
  msgid "Client Secret"
1314
  msgstr "Client Secret"
1315
 
1316
- #: includes/admin-setting.php:1697
1317
  msgid "Client Secret for Instagram API"
1318
  msgstr "Instagram API用のClient Secret"
1319
 
1320
- #: includes/admin-setting.php:1705
1321
  msgid ""
1322
  "Copy and set this to the field of \"Valid redirect URIs\" in the client "
1323
  "management page of Instagram developer page."
@@ -1325,37 +1334,65 @@ msgstr ""
1325
  "Instagram開発者向けページ内のクライアント管理ページにて「Valid redirect "
1326
  "URIs」フィールドにこのURIを設定して下さい。"
1327
 
1328
- #: includes/admin-setting.php:1728
1329
  msgid "Access Token for Instagram API"
1330
  msgstr "Instagram API用のAccess Token"
1331
 
1332
- #: includes/admin-setting.php:1749
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1333
  msgid "Push7 page"
1334
  msgstr "Push7ページ"
1335
 
1336
- #: includes/admin-setting.php:1753
1337
- msgid "Register a application in Push7 page to get the following AppNo."
1338
  msgstr ""
1339
- "以下のAppNoを取得するために、Push7のページでアプリケーションを登録して下さ"
1340
- "い。"
1341
 
1342
- #: includes/admin-setting.php:1757
1343
- msgid "AppNo"
1344
- msgstr "AppNo"
1345
 
1346
- #: includes/admin-setting.php:1761
1347
- msgid "AppNo for Push7 API"
1348
- msgstr "Push7 API用のAppNo"
1349
 
1350
- #: includes/admin-setting.php:1778
1351
  msgid "Screen Name"
1352
  msgstr "スクリーン名"
1353
 
1354
- #: includes/admin-setting.php:1783
1355
  msgid "Twitter screen name that you want to get follower count"
1356
  msgstr "フォロワー数を取得するTwitterのスクリーン名"
1357
 
1358
- #: includes/admin-setting.php:1791
1359
  msgid ""
1360
  "Register a application in Twitter developer page to get the following "
1361
  "Consumer Key and Consumer Secret."
@@ -1363,153 +1400,153 @@ msgstr ""
1363
  "以下のConsumer KeyとConsumer Secretを取得するために、Twitter開発者向けページ"
1364
  "でアプリケーションを登録して下さい。"
1365
 
1366
- #: includes/admin-setting.php:1795
1367
- msgid "Consumer Key (API Key)"
1368
- msgstr "Consumer Key (API Key)"
1369
 
1370
- #: includes/admin-setting.php:1799
1371
- msgid "Cconsumer Key for Twitter API"
1372
- msgstr "Twitter API用のCconsumer Key"
1373
 
1374
- #: includes/admin-setting.php:1803
1375
- msgid "Consumer Secret (API Secret)"
1376
- msgstr "Consumer Secret (API Secret)"
1377
 
1378
- #: includes/admin-setting.php:1807
1379
- msgid "Consumer Secret for Twitter API"
1380
- msgstr "Twitter API用のConsumer Secret"
1381
 
1382
- #: includes/admin-setting.php:1812 includes/admin-setting.php:1826
1383
  msgid "Bearer Token"
1384
  msgstr "Bearer Token"
1385
 
1386
- #: includes/admin-setting.php:1830
1387
  msgid "Bearer Token for Twitter API"
1388
  msgstr "Twitter API用のBearer Token"
1389
 
1390
- #: includes/admin-setting.php:2118 includes/admin-setting.php:2139
1391
  msgid "Default: Disabled"
1392
  msgstr "既定値: 無効"
1393
 
1394
- #: includes/admin-setting.php:2133
1395
  msgid "Fault tolerant mode of count retrieval"
1396
  msgstr "カウント取得における耐障害モード"
1397
 
1398
- #: includes/admin-setting.php:2176
1399
  msgid "4 times"
1400
  msgstr "4回"
1401
 
1402
- #: includes/admin-setting.php:2179
1403
- msgid "Default: 1 time"
1404
- msgstr "既定値: 1回"
1405
 
1406
- #: includes/admin-setting.php:2189
1407
  msgid "Default: On"
1408
  msgstr "既定値: 有効"
1409
 
1410
- #: includes/admin-setting.php:2210
1411
  msgid "Default: Manual"
1412
  msgstr "既定値: 手動"
1413
 
1414
- #: includes/admin-setting.php:2459
1415
  msgid "hourly"
1416
  msgstr "毎時"
1417
 
1418
- #: includes/admin-setting.php:2496
1419
  msgid "Disk usage of exported file"
1420
  msgstr "エクスポートされたファイルのディスク使用量"
1421
 
1422
- #: includes/admin-setting.php:2505
1423
  msgid "No exported file"
1424
  msgstr "エクスポートされたファイルは存在しません。"
1425
 
1426
- #: includes/admin-setting.php:2517
1427
  msgid "Manual export"
1428
  msgstr "手動エクスポート"
1429
 
1430
- #: includes/admin-setting.php:2521
1431
  msgid "Export share count to a csv file."
1432
  msgstr "シェア数をCSVファイルにエクスポートします。"
1433
 
1434
- #: includes/admin-setting.php:2535
1435
  msgid "Reset of exported file"
1436
  msgstr "エクスポートされたファイルのリセット"
1437
 
1438
- #: includes/admin-setting.php:2539
1439
  msgid "Clear exported csv file."
1440
  msgstr "エクスポートされたCSVファイルを削除します。"
1441
 
1442
- #: includes/admin-setting.php:2550
1443
  msgid "Download of exported file"
1444
  msgstr "エクスポートされたファイルのダウンロード"
1445
 
1446
- #: includes/admin-setting.php:2552 includes/download.php:38
1447
  msgid "Download"
1448
  msgstr "ダウンロード"
1449
 
1450
- #: includes/admin-setting.php:2554
1451
  msgid "Download the exported csv file."
1452
  msgstr "エクスポートされたCSVファイルをダウンロードします。"
1453
 
1454
- #: includes/class-scc-wp-cron-util.php:271
1455
  #, php-format
1456
  msgid "The %s constant is set to true. WP-Cron spawning is disabled."
1457
  msgstr ""
1458
 
1459
- #: includes/class-scc-wp-cron-util.php:275
1460
  #, php-format
1461
  msgid "The %s constant is set to true."
1462
  msgstr ""
1463
 
1464
- #: includes/class-scc-wp-cron-util.php:305
1465
  #, php-format
1466
  msgid "Unexpected HTTP response code: %s"
1467
  msgstr ""
1468
 
1469
- #: includes/download.php:68 includes/download.php:71 index.php:42 index.php:50
1470
- #: index.php:53 index.php:56 index.php:59 sns-count-cache.php:1798
1471
- #: sns-count-cache.php:1811 sns-count-cache.php:1823 sns-count-cache.php:1835
1472
- #: sns-count-cache.php:1847 sns-count-cache.php:1859 sns-count-cache.php:1871
1473
- #: sns-count-cache.php:1883
1474
  msgid "You do not have sufficient permissions to access this page."
1475
  msgstr "このページにアクセスするために必要な権限がありません。"
1476
 
1477
- #: sns-count-cache.php:1756
1478
  msgid "Dashboard | SNS Count Cache"
1479
  msgstr "ダッシュボード | SNS Count Cache"
1480
 
1481
- #: sns-count-cache.php:1757
1482
  msgid "Cache Status | SNS Count Cache"
1483
  msgstr "キャッシュ状況 | SNS Count Cache"
1484
 
1485
- #: sns-count-cache.php:1758
1486
  msgid "Share Count | SNS Count Cache"
1487
  msgstr "シェア数 | SNS Count Cache"
1488
 
1489
- #: sns-count-cache.php:1761
1490
  msgid "Hot Content | SNS Count Cache"
1491
  msgstr "話題のコンテンツ | SNS Count Cache"
1492
 
1493
- #: sns-count-cache.php:1764
1494
  msgid "Setting | SNS Count Cache"
1495
  msgstr "設定 | SNS Count Cache"
1496
 
1497
- #: sns-count-cache.php:1765
1498
  msgid "Help | SNS Count Cache"
1499
  msgstr "ヘルプ | SNS Count Cache"
1500
 
1501
- #: sns-count-cache.php:2314 sns-count-cache.php:2322 sns-count-cache.php:2484
1502
- #: sns-count-cache.php:2492
1503
  msgid "Completed"
1504
  msgstr "完了"
1505
 
1506
- #: sns-count-cache.php:2316 sns-count-cache.php:2324 sns-count-cache.php:2486
1507
- #: sns-count-cache.php:2494
1508
  msgid "Partially Completed"
1509
  msgstr "部分完了"
1510
 
1511
- #: sns-count-cache.php:2318 sns-count-cache.php:2326 sns-count-cache.php:2488
1512
- #: sns-count-cache.php:2496
1513
  msgid "Ongoing"
1514
  msgstr "進行中"
1515
 
@@ -1519,16 +1556,16 @@ msgstr "https://wordpress.org/plugins/sns-count-cache/"
1519
 
1520
  #. Description of the plugin/theme
1521
  msgid ""
1522
- "SNS Count Cache gets share count for Twitter and Facebook, Google Plus, "
1523
- "Pocket, Pinterest, Linkedin, Hatena Bookmark and caches these count in the "
1524
  "background. This plugin may help you to shorten page loading time because "
1525
  "the share count can be retrieved not through network but through the cache "
1526
  "using given functions."
1527
  msgstr ""
1528
- "SNS Count Cacheは、Twitter、Facebook、Google+、Pocket、Pinterest、Linkedin"
1529
- "はてなブックマークのシェア数を取得し、バックグラウンドでキャッシュします。用"
1530
- "意された関数を利用することで、ネットワーク経由でなくキャッシュからシェア数を"
1531
- "参照できようになるため、ページ読み込みの高速化が見込めます。"
1532
 
1533
  #. Author of the plugin/theme
1534
  msgid "Daisuke Maruyama"
@@ -1538,6 +1575,39 @@ msgstr "Daisuke Maruyama"
1538
  msgid "https://marubon.info/"
1539
  msgstr "https://marubon.info/"
1540
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1541
  #~ msgid "Follow Count"
1542
  #~ msgstr "フォロー数"
1543
 
@@ -1665,9 +1735,6 @@ msgstr "https://marubon.info/"
1665
  #~ msgid "Twitter bearer token for OAuth"
1666
  #~ msgstr "OAuth認証のためのTwitter bearer token"
1667
 
1668
- #~ msgid "Default: None"
1669
- #~ msgstr "既定値: なし"
1670
-
1671
  #~ msgid ""
1672
  #~ "Copy and set this to the field of \"Valid OAuth redirect URIs\" in client "
1673
  #~ "management page of Facebook developer page"
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: SNS Count Cache\n"
4
+ "POT-Creation-Date: 2019-05-05 20:13+0900\n"
5
+ "PO-Revision-Date: 2019-05-05 20:16+0900\n"
6
  "Last-Translator: Daisuke Maruyama <marubon@gmail.com>\n"
7
  "Language-Team: Daisuke Maruyama <marubon@gmail.com>\n"
8
  "Language: ja\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 2.2.1\n"
13
  "X-Poedit-Basepath: ..\n"
14
  "X-Poedit-WPHeader: sns-count-cache.php\n"
15
  "Plural-Forms: nplurals=1; plural=0;\n"
21
  "X-Poedit-SearchPathExcluded-0: *.js\n"
22
 
23
  #. Plugin Name of the plugin/theme
24
+ #: includes/admin-cache-status.php:69 includes/admin-dashboard.php:45
25
+ #: includes/admin-help.php:36 includes/admin-hot-content.php:70
26
+ #: includes/admin-setting.php:528 includes/admin-share-count.php:69
27
+ #: sns-count-cache.php:1949
28
  msgid "SNS Count Cache"
29
  msgstr "SNS Count Cache"
30
 
31
+ #: includes/admin-cache-status.php:72 includes/admin-dashboard.php:49
32
+ #: includes/admin-help.php:39 includes/admin-hot-content.php:73
33
+ #: includes/admin-setting.php:629 includes/admin-share-count.php:72
34
+ #: sns-count-cache.php:1950
35
  msgid "Dashboard"
36
  msgstr "ダッシュボード"
37
 
38
+ #: includes/admin-cache-status.php:73 includes/admin-cache-status.php:84
39
+ #: includes/admin-dashboard-widget.php:49
40
+ #: includes/admin-dashboard-widget.php:152 includes/admin-dashboard.php:50
41
+ #: includes/admin-dashboard.php:63 includes/admin-dashboard.php:171
42
+ #: includes/admin-help.php:40 includes/admin-help.php:66
43
+ #: includes/admin-hot-content.php:74 includes/admin-setting.php:630
44
+ #: includes/admin-share-count.php:73 sns-count-cache.php:1951
45
  msgid "Cache Status"
46
  msgstr "キャッシュ状況"
47
 
48
+ #: includes/admin-cache-status.php:74 includes/admin-dashboard-widget.php:84
49
+ #: includes/admin-dashboard.php:51 includes/admin-dashboard.php:98
50
+ #: includes/admin-help.php:41 includes/admin-hot-content.php:75
51
+ #: includes/admin-setting.php:631 includes/admin-share-count.php:74
52
+ #: includes/admin-share-count.php:84 sns-count-cache.php:1952
53
  msgid "Share Count"
54
  msgstr "シェア数"
55
 
56
+ #: includes/admin-cache-status.php:76 includes/admin-dashboard.php:53
57
+ #: includes/admin-help.php:43 includes/admin-hot-content.php:76
58
+ #: includes/admin-hot-content.php:83 includes/admin-setting.php:633
59
+ #: includes/admin-share-count.php:76 sns-count-cache.php:1955
60
  msgid "Hot Content"
61
  msgstr "話題のコンテンツ"
62
 
63
+ #: includes/admin-cache-status.php:78 includes/admin-dashboard.php:55
64
+ #: includes/admin-help.php:45 includes/admin-hot-content.php:77
65
+ #: includes/admin-setting.php:635 includes/admin-share-count.php:78
66
+ #: sns-count-cache.php:1958 sns-count-cache.php:1973
67
  msgid "Setting"
68
  msgstr "設定"
69
 
70
+ #: includes/admin-cache-status.php:79 includes/admin-dashboard.php:56
71
+ #: includes/admin-help.php:46 includes/admin-help.php:51
72
+ #: includes/admin-hot-content.php:78 includes/admin-setting.php:636
73
+ #: includes/admin-share-count.php:79 sns-count-cache.php:1959
74
  msgid "Help"
75
  msgstr "ヘルプ"
76
 
77
+ #: includes/admin-cache-status.php:93 includes/admin-hot-content.php:89
78
+ #: includes/admin-share-count.php:116
79
  msgid "Content"
80
  msgstr "コンテンツ"
81
 
82
+ #: includes/admin-cache-status.php:94 includes/admin-dashboard-widget.php:63
83
+ #: includes/admin-dashboard-widget.php:166 includes/admin-dashboard.php:77
84
+ #: includes/admin-dashboard.php:185
85
  msgid "Primary Cache"
86
  msgstr "一次キャッシュ"
87
 
88
+ #: includes/admin-cache-status.php:95 includes/admin-dashboard-widget.php:73
89
+ #: includes/admin-dashboard-widget.php:176 includes/admin-dashboard.php:87
90
+ #: includes/admin-dashboard.php:195
91
  msgid "Secondary Cache"
92
  msgstr "二次キャッシュ"
93
 
94
+ #: includes/admin-cache-status.php:96
95
  msgid "Crawl Date"
96
  msgstr "クロール日時"
97
 
98
+ #: includes/admin-cache-status.php:137 includes/admin-cache-status.php:178
99
+ #: includes/admin-cache-status.php:239 includes/admin-cache-status.php:271
100
+ #: includes/admin-help.php:71
101
  msgid "full cache"
102
  msgstr "完全キャッシュ"
103
 
104
+ #: includes/admin-cache-status.php:141 includes/admin-cache-status.php:182
105
+ #: includes/admin-cache-status.php:243 includes/admin-cache-status.php:275
106
+ #: includes/admin-help.php:72
107
  msgid "partial cache"
108
  msgstr "部分キャッシュ"
109
 
110
+ #: includes/admin-cache-status.php:145 includes/admin-cache-status.php:151
111
+ #: includes/admin-cache-status.php:186 includes/admin-cache-status.php:221
112
+ #: includes/admin-cache-status.php:247 includes/admin-cache-status.php:279
113
+ #: includes/admin-help.php:73
114
  msgid "no cache"
115
  msgstr "未キャッシュ"
116
 
117
+ #: includes/admin-cache-status.php:196 includes/admin-cache-status.php:298
118
  msgid "no data"
119
  msgstr "データなし"
120
 
121
+ #: includes/admin-cache-status.php:203 includes/admin-cache-status.php:306
122
+ #: includes/admin-setting.php:488 includes/admin-setting.php:1601
123
  msgid "Cache"
124
  msgstr "キャッシュ"
125
 
126
+ #: includes/admin-dashboard-widget.php:48 includes/admin-dashboard.php:61
127
  msgid "Share"
128
  msgstr "Share"
129
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  #: includes/admin-dashboard-widget.php:53
131
  #: includes/admin-dashboard-widget.php:156 includes/admin-dashboard.php:67
132
  #: includes/admin-dashboard.php:175
133
+ msgid "Cache Type"
134
+ msgstr "キャッシュタイプ"
135
 
136
  #: includes/admin-dashboard-widget.php:54
137
  #: includes/admin-dashboard-widget.php:157 includes/admin-dashboard.php:68
138
  #: includes/admin-dashboard.php:176
139
+ msgid "Cache Progress"
140
+ msgstr "キャッシュ進捗"
141
 
142
  #: includes/admin-dashboard-widget.php:55
143
  #: includes/admin-dashboard-widget.php:158 includes/admin-dashboard.php:69
144
  #: includes/admin-dashboard.php:177
145
+ msgid "Total Content"
146
+ msgstr "総コンテンツ数"
147
 
148
  #: includes/admin-dashboard-widget.php:56
149
  #: includes/admin-dashboard-widget.php:159 includes/admin-dashboard.php:70
150
  #: includes/admin-dashboard.php:178
151
+ msgid "State - Full Cache"
152
+ msgstr "状態 - 完全キャッシュ"
153
+
154
+ #: includes/admin-dashboard-widget.php:57
155
+ #: includes/admin-dashboard-widget.php:160 includes/admin-dashboard.php:71
156
+ #: includes/admin-dashboard.php:179
157
+ msgid "State - Partial Cache"
158
+ msgstr "状態 - 部分キャッシュ"
159
+
160
+ #: includes/admin-dashboard-widget.php:58
161
+ #: includes/admin-dashboard-widget.php:161 includes/admin-dashboard.php:72
162
+ #: includes/admin-dashboard.php:180
163
  msgid "State - No Cache"
164
  msgstr "状態 - 未キャッシュ"
165
 
166
+ #: includes/admin-dashboard-widget.php:98
167
+ #: includes/admin-dashboard-widget.php:201 includes/admin-dashboard.php:112
168
+ #: includes/admin-dashboard.php:220 includes/admin-hot-content.php:105
169
+ #: includes/admin-setting.php:681 includes/admin-setting.php:1099
170
+ #: includes/admin-setting.php:1587 includes/admin-share-count.php:132
171
  msgid "Twitter"
172
  msgstr "Twitter"
173
 
174
+ #: includes/admin-dashboard-widget.php:101
175
+ #: includes/admin-dashboard-widget.php:204 includes/admin-dashboard.php:115
176
+ #: includes/admin-dashboard.php:223 includes/admin-hot-content.php:108
177
+ #: includes/admin-setting.php:663 includes/admin-setting.php:1079
178
+ #: includes/admin-setting.php:1567 includes/admin-share-count.php:135
179
  msgid "Facebook"
180
  msgstr "Facebook"
181
 
182
+ #: includes/admin-dashboard-widget.php:104 includes/admin-dashboard.php:118
183
+ #: includes/admin-hot-content.php:111 includes/admin-setting.php:666
184
+ #: includes/admin-share-count.php:138
185
  msgid "Google+"
186
  msgstr "Google+"
187
 
188
+ #: includes/admin-dashboard-widget.php:107 includes/admin-dashboard.php:121
189
+ #: includes/admin-hot-content.php:114 includes/admin-setting.php:678
190
+ #: includes/admin-setting.php:1095 includes/admin-share-count.php:141
191
  msgid "Pocket"
192
  msgstr "Pocket"
193
 
194
+ #: includes/admin-dashboard-widget.php:110 includes/admin-dashboard.php:124
195
+ #: includes/admin-hot-content.php:117 includes/admin-share-count.php:144
196
  msgid "Hatebu"
197
  msgstr "はてブ"
198
 
199
+ #: includes/admin-dashboard-widget.php:113 includes/admin-dashboard.php:127
200
+ #: includes/admin-hot-content.php:120 includes/admin-setting.php:675
201
+ #: includes/admin-setting.php:1091 includes/admin-share-count.php:147
202
  msgid "Pinterest"
203
  msgstr "Pinterest"
204
 
205
+ #: includes/admin-dashboard-widget.php:116 includes/admin-dashboard.php:130
206
+ #: includes/admin-hot-content.php:123 includes/admin-setting.php:672
207
+ #: includes/admin-setting.php:1087 includes/admin-share-count.php:150
208
  msgid "Linkedin"
209
  msgstr "Linkedin"
210
 
211
+ #: includes/admin-dashboard-widget.php:119 includes/admin-dashboard.php:133
212
+ #: includes/admin-hot-content.php:126 includes/admin-share-count.php:153
213
  msgid "Total"
214
  msgstr "合計"
215
 
216
+ #: includes/admin-dashboard-widget.php:151 includes/admin-dashboard.php:169
217
  msgid "Follow"
218
  msgstr "Follow"
219
 
220
+ #: includes/admin-dashboard-widget.php:187 includes/admin-dashboard.php:206
221
  msgid "Follower Count"
222
  msgstr "フォロワー数"
223
 
224
+ #: includes/admin-dashboard-widget.php:207 includes/admin-dashboard.php:226
225
+ #: includes/admin-setting.php:1571
226
  msgid "Feedly"
227
  msgstr "Feedly"
228
 
229
+ #: includes/admin-dashboard-widget.php:210 includes/admin-dashboard.php:229
230
+ #: includes/admin-setting.php:1575
231
  msgid "Instagram"
232
  msgstr "Instagram"
233
 
234
+ #: includes/admin-dashboard-widget.php:213 includes/admin-dashboard.php:235
235
+ #: includes/admin-setting.php:1583
236
  msgid "Push7"
237
  msgstr "Push7"
238
 
239
+ #: includes/admin-dashboard-widget.php:216 includes/admin-dashboard.php:232
240
+ #: includes/admin-setting.php:1579
241
+ msgid "OneSignal"
242
+ msgstr "OneSignal"
243
+
244
+ #: includes/admin-help.php:53
245
  msgid "What is WordPress plugin SNS Cout Cache?"
246
  msgstr "WordPressプラグイン SNS Count Cacheとは何か?"
247
 
248
+ #: includes/admin-help.php:54
249
  msgid ""
250
  "WordPress plugin SNS Count Cache is a plugin which helps you to shorten page "
251
  "loading time when your site displays share and follower counts. This plugin "
252
+ "gets share counts such as Twitter and Facebook, Pocket, Pinterest, Linkedin "
253
+ "and caches these counts in the background. This plugin alse caches follower "
254
+ "counts such as Twitter and Facebook, Feedly, Instagram, OneSignal, Push7 in "
255
  "the same way. The share and follower counts can be retrieved quickly not "
256
  "through network but through the cache using given functions."
257
  msgstr ""
258
  "WordPressプラグイン SNS Count Cacheは、シェア数やフォロワー数を表示している場"
259
  "合にページの表示時間を高速化するプラグインです。このプラグインは、Twitter、"
260
+ "Facebook、Pocket、Pinterest、Linkedin、はてなブックマークのシェア数をバックグ"
261
+ "ラウンドで取得し、キャッシュします。またTwitter、Facebook、Feedly、"
262
+ "Instagram、OneSignal、Push7のフォロワー数も同様の方法でキャッシュします。これ"
263
+ "らのシェア数とフォロワー数は、所定の関数を用いることでネットワークからではな"
264
+ "くキャッシュ経由で迅速に取得可能になります。"
265
 
266
+ #: includes/admin-help.php:55
267
  msgid "How often does this plugin get and cache share counts?"
268
  msgstr "シェア数を取得、キャッシュする頻度は?"
269
 
270
+ #: includes/admin-help.php:56
271
  msgid ""
272
  "Although this plugin gets share count of 20 posts at a time every 10 minutes "
273
  "by default, you can modify the setting in the \"Setting\" tab in the "
276
  "デフォルトで10分ごとに20記事のシェア数を取得しますが、管理ページの「設定」タ"
277
  "ブにてその取得間隔と一度に取得対象とする記事数を変更できます。"
278
 
279
+ #: includes/admin-help.php:57
280
  msgid "How can I know whether share count of each post is cached or not?"
281
  msgstr "各記事のシェア数のキャッシュ有無を確認する方法は?"
282
 
283
+ #: includes/admin-help.php:58
284
  msgid ""
285
  "Cache status is described in the \"Cache Status\" tab in the administration "
286
  "page."
287
  msgstr "キャッシュ状況は、管理ページの「キャッシュ状況」タブにて確認可能です。"
288
 
289
+ #: includes/admin-help.php:59
290
  msgid "How often does this plugin get and cache follower counts?"
291
  msgstr "フォロワー数を取得、キャッシュする頻度は?"
292
 
293
+ #: includes/admin-help.php:60
294
  msgid ""
295
  "Although this plugin gets follower count once a day by default, you can "
296
  "modify the setting in the \"Setting\" tab in the administration page."
298
  "デフォルトで1日に一回フォロワー数を取得しますが、管理ページの「設定」タブにて"
299
  "その取得間隔を変更できます。"
300
 
301
+ #: includes/admin-help.php:61
302
  msgid ""
303
  "What is cache status such as \"full cache\", \"partial cache\" and \"no cache"
304
  "\"?"
306
  "「完全キャッシュ」、「部分キャッシュ」、「未キャッシュ」等のキャッシュ状況と"
307
  "は何か?"
308
 
309
+ #: includes/admin-help.php:62
310
  msgid "The following is the explanation of the cache status."
311
  msgstr "以下は、そのキャッシュ状況に関する説明です。"
312
 
313
+ #: includes/admin-help.php:67 includes/admin-help.php:82
314
+ #: includes/admin-help.php:101 includes/admin-help.php:175
315
+ #: includes/admin-help.php:194
316
  msgid "Description"
317
  msgstr "説明"
318
 
319
+ #: includes/admin-help.php:71
320
+ msgid "Counts for configured all SNS are cached."
321
+ msgstr "設定した全てのSNSのカウントがキャッシュされている。"
322
 
323
+ #: includes/admin-help.php:72
324
+ msgid "A subset of counts for configured SNS are cached."
325
+ msgstr "設定したSNSの内、一部のSNSのカウントがキャッシュされている。"
326
 
327
+ #: includes/admin-help.php:73
328
+ msgid "Count for configured SNS are not cached at all."
329
+ msgstr "設定したSNSのカウントが全くキャッシュされていない。"
330
 
331
+ #: includes/admin-help.php:76
332
  msgid "How can I get share count from the cache?"
333
  msgstr "キャッシュからSNSカウントを参照する方法は?"
334
 
335
+ #: includes/admin-help.php:77
336
  msgid ""
337
  "The share count is retrieved from the cache using the following functions in "
338
  "the WordPress loop such as query_posts(), get_posts() and WP_Query()."
340
  "WordPressのquery_posts()、get_posts()、WP_Query()等のループ内で下記の関数を使"
341
  "うことでキャッシュからSNSカウントを参照できます。"
342
 
343
+ #: includes/admin-help.php:81 includes/admin-help.php:100
344
  msgid "Function"
345
  msgstr "関数"
346
 
347
+ #: includes/admin-help.php:86
348
  msgid "Twitter share count is returned from cache."
349
+ msgstr "キャッシュからTwitterのシェア数を取得"
350
 
351
+ #: includes/admin-help.php:87
352
  msgid "Facebook share count is returned from cache."
353
+ msgstr "キャッシュからFacebookのシェア数を取得"
354
 
355
+ #: includes/admin-help.php:88
 
 
 
 
356
  msgid "Hatena Bookmark share count is returned from cache."
357
+ msgstr "キャッシュからはてなブックマークのシェア数を取得"
358
 
359
+ #: includes/admin-help.php:89
360
  msgid "Pocket share count is returned from cache."
361
+ msgstr "キャッシュからPocketのシェア数を取得"
362
 
363
+ #: includes/admin-help.php:90
364
  msgid "Pinterest share count is returned from cache."
365
+ msgstr "キャッシュからPinterestのシェア数を取得"
366
 
367
+ #: includes/admin-help.php:91
368
  msgid "Linkedin share count is returned from cache."
369
+ msgstr "キャッシュからLinkedinのシェア数を取得"
370
 
371
+ #: includes/admin-help.php:92
372
  msgid "Total share count of selected SNS is returned from cache."
373
+ msgstr "キャッシュから対象として設定されたSNSのカウントの総和を取得"
374
 
375
+ #: includes/admin-help.php:95
376
  msgid "How can I get follower count from the cache?"
377
  msgstr "キャッシュからフォロワーの数を参照する方法は?"
378
 
379
+ #: includes/admin-help.php:96
380
  msgid ""
381
  "The follower count is retrieved from the cache using the following functions."
382
  msgstr "フォロワーの数は、以下の関数を用いることでキャッシュから参照可能です。"
383
 
384
+ #: includes/admin-help.php:105
385
  msgid "Feedly follower count is returned from cache."
386
+ msgstr "キャッシュからFeedlyのフォロワーの数を取得"
387
 
388
+ #: includes/admin-help.php:106
389
  msgid "Twitter follower count is returned from cache."
390
+ msgstr "キャッシュからTwitterのフォロワーの数を取得"
391
 
392
+ #: includes/admin-help.php:107
393
  msgid "Facebook follower count is returned from cache."
394
+ msgstr "キャッシュからFacebookのフォロワーの数を取得"
395
 
396
+ #: includes/admin-help.php:108
397
  msgid "Instagram follower count is returned from cache."
398
+ msgstr "キャッシュからInstagramのフォロワーの数を取得"
399
 
400
+ #: includes/admin-help.php:109
401
  msgid "Push7 follower count is returned from cache."
402
+ msgstr "キャッシュからPush7のフォロワーの数を取得"
403
 
404
+ #: includes/admin-help.php:110
405
+ msgid "OneSignal follower count is returned from cache."
406
+ msgstr "キャッシュからOneSignalのフォロワーの数を取得"
407
+
408
+ #: includes/admin-help.php:113
409
  msgid "Example Code"
410
  msgstr "サンプルコード"
411
 
412
+ #: includes/admin-help.php:114
413
  msgid ""
414
  "The code below describes a simple example which displays share count and "
415
  "follower count using the above functions."
417
  "以下のコードは、上述した関数を用いてシェア数やフォロワー数を表示する簡単な例"
418
  "です。"
419
 
420
+ #: includes/admin-help.php:169
421
  msgid "How can I access specific custom field containing each share count?"
422
  msgstr "シェア数を含むカスタムフィールドにアクセスする方法は?"
423
 
424
+ #: includes/admin-help.php:170
425
  msgid ""
426
  "Custom fields including share count are accessed using the following meta "
427
  "keys."
428
  msgstr ""
429
  "シェア数を含むカスタムフィールドは、以下のmeta keyを用いて参照可能です。"
430
 
431
+ #: includes/admin-help.php:174 includes/admin-help.php:193
432
  msgid "Meta Key"
433
  msgstr "Meta Key"
434
 
435
+ #: includes/admin-help.php:179
436
  msgid "A meta key to access Twitter share count"
437
+ msgstr "Twitterのシェア数にアクセスするためのMeta Key"
438
 
439
+ #: includes/admin-help.php:180
440
  msgid "A meta key to access Facebook share count"
441
+ msgstr "Facebookのシェア数にアクセスするためのMeta Key"
 
 
 
 
442
 
443
+ #: includes/admin-help.php:181
444
  msgid "A meta key to access Hatena Bookmark share count"
445
+ msgstr "はてなブックマークのシェア数にアクセスするためのMeta Key"
446
 
447
+ #: includes/admin-help.php:182
448
  msgid "A meta key to access Pocket share count"
449
+ msgstr "Pocketのシェア数にアクセスするためのMeta Key"
450
 
451
+ #: includes/admin-help.php:183
452
  msgid "A meta key to access Pinterest share count"
453
+ msgstr "Pinterestのシェア数にアクセスするためのMeta Key"
454
 
455
+ #: includes/admin-help.php:184
456
  msgid "A meta key to access Linkedin share count"
457
+ msgstr "Linkedinのシェア数の増減数にアクセスするためのMeta Key"
458
 
459
+ #: includes/admin-help.php:185
460
  msgid "A meta key to access total share count"
461
+ msgstr "シェア数の合計にアクセスするためのMeta Key"
462
 
463
+ #: includes/admin-help.php:188
464
  msgid ""
465
  "How can I access specific custom field containing each variation of share "
466
  "count?"
467
  msgstr "シェア数の増減を含むカスタムフィールドにアクセスする方法は?"
468
 
469
+ #: includes/admin-help.php:189
470
  msgid ""
471
  "Custom fields including variation of share count are accessed using the "
472
  "following meta keys."
474
  "シェア数の増減を含むカスタムフィールドは、以下のmeta keyを用いて参照可能で"
475
  "す。"
476
 
 
 
 
 
477
  #: includes/admin-help.php:198
478
+ msgid "A meta key to access variation of Twitter share count"
479
+ msgstr "Twitterのシェア数の増減数にアクセスするためのMeta Key"
480
 
481
  #: includes/admin-help.php:199
482
+ msgid "A meta key to access variation of Facebook share count"
483
+ msgstr "Facebookのシェア数の増減数にアクセスするためのMeta Key"
484
 
485
  #: includes/admin-help.php:200
486
  msgid "A meta key to access variation of Hatena Bookmark share count"
487
+ msgstr "はてなブックマークのシェア数の増減数にアクセスするためのMeta Key"
488
 
489
  #: includes/admin-help.php:201
490
  msgid "A meta key to access variation of Pocket share count"
491
+ msgstr "Pocketのシェア数の増減数にアクセスするためのMeta Key"
492
 
493
  #: includes/admin-help.php:202
494
  msgid "A meta key to access variation of Pinterest share count"
495
+ msgstr "Pinterestのシェア数の増減数にアクセスするためのMeta Key"
496
 
497
  #: includes/admin-help.php:203
498
  msgid "A meta key to access variation of Linkedin share count"
499
+ msgstr "Linkedinのシェア数にアクセスするためのMeta Key"
500
 
501
  #: includes/admin-help.php:204
502
  msgid "A meta key to access variation of total share count"
503
+ msgstr "シェア数合計の増減数にアクセスするためのMeta Key"
504
+
505
+ #: includes/admin-hot-content.php:273 includes/admin-hot-content.php:302
506
+ #: includes/admin-hot-content.php:320 includes/admin-setting.php:695
507
+ #: includes/admin-setting.php:732 includes/admin-setting.php:891
508
+ #: includes/admin-setting.php:906 includes/admin-share-count.php:203
509
+ #: includes/admin-share-count.php:217 includes/admin-share-count.php:249
510
+ #: includes/admin-share-count.php:263 includes/admin-share-count.php:273
511
+ #: includes/admin-share-count.php:305 includes/admin-share-count.php:319
512
+ #: includes/admin-share-count.php:351 includes/admin-share-count.php:365
513
+ #: includes/admin-share-count.php:375 includes/admin-share-count.php:420
514
+ #: includes/admin-share-count.php:451
515
  msgid "N/A"
516
  msgstr "N/A"
517
 
518
+ #: includes/admin-hot-content.php:316
519
  msgid "No hot content."
520
  msgstr "話題のコンテンツはありません。"
521
 
522
+ #: includes/admin-setting.php:40 includes/admin-setting.php:1153
523
+ #: includes/admin-setting.php:1200 includes/admin-setting.php:1243
524
+ #: includes/admin-setting.php:1291 includes/admin-setting.php:1552
525
+ #: includes/admin-setting.php:1600 includes/admin-setting.php:1678
526
+ #: includes/admin-setting.php:1711 includes/admin-setting.php:1780
527
+ #: includes/admin-setting.php:1820 includes/admin-setting.php:1849
528
+ #: includes/admin-setting.php:1919 includes/admin-setting.php:2184
529
+ #: includes/admin-setting.php:2206 includes/admin-setting.php:2227
530
+ #: includes/admin-setting.php:2277 includes/admin-setting.php:2565
531
  msgid "Update All Options"
532
  msgstr "設定の更新"
533
 
534
+ #: includes/admin-setting.php:427 includes/admin-setting.php:2620
535
  msgid "Reset"
536
  msgstr "リセット"
537
 
538
+ #: includes/admin-setting.php:433 includes/admin-setting.php:2602
539
  msgid "Export"
540
  msgstr "エクスポート"
541
 
542
+ #: includes/admin-setting.php:443 includes/admin-setting.php:453
543
+ #: includes/admin-setting.php:1553 includes/admin-setting.php:2185
544
  msgid "Update Basis of Comparison"
545
  msgstr "比較基準の更新"
546
 
547
+ #: includes/admin-setting.php:463 includes/admin-setting.php:476
548
+ #: includes/admin-setting.php:1154 includes/admin-setting.php:1602
549
  msgid "Clear Cache"
550
  msgstr "キャッシュの消去"
551
 
552
+ #: includes/admin-setting.php:498 includes/admin-setting.php:1893
553
+ #: includes/admin-setting.php:1921
554
  msgid "Get Bearer Token"
555
  msgstr "Bearer Tokenの取得"
556
 
557
+ #: includes/admin-setting.php:554
558
  msgid ""
559
  "There was a problem spawning a call to the WP-Cron system on your site. This "
560
  "means WP-Cron jobs on your site may not work. The problem was: "
562
  "あなたのサイト上でWP-Cronシステムの呼び出し処理に問題が見つかりました。あなた"
563
  "のサイト上でWP-Cronジョブが動作しない可能性があります。問題は次の通りです。"
564
 
565
+ #: includes/admin-setting.php:564
566
  msgid ""
567
  "Configuratin is not enough to get share count. Please set required "
568
  "parameters at "
570
  "シェア数を取得するために必要な設定が不足しています。次のセクションで必要なパ"
571
  "ラメータを設定して下さい。"
572
 
573
+ #: includes/admin-setting.php:565 includes/admin-setting.php:1161
574
  msgid "Share Base Cache - Facebook"
575
  msgstr "シェア基本キャッシュ - Facebook"
576
 
577
+ #: includes/admin-setting.php:575 includes/admin-setting.php:586
578
+ #: includes/admin-setting.php:597 includes/admin-setting.php:608
579
+ #: includes/admin-setting.php:619
580
  msgid ""
581
  "Configuratin is not enough to get follower count. Please set required "
582
  "parameters at "
584
  "フォロワー数を取得するために必要な設定が不足しています。次のセクションで必要"
585
  "なパラメータを設定して下さい。"
586
 
587
+ #: includes/admin-setting.php:576 includes/admin-setting.php:1719
588
  msgid "Follow Base Cache - Instagram"
589
  msgstr "フォロー基本キャシュ機能 - Instagram"
590
 
591
+ #: includes/admin-setting.php:587 includes/admin-setting.php:899
592
+ #: includes/admin-setting.php:1609
593
  msgid "Follow Base Cache - Facebook"
594
  msgstr "フォロー基本キャッシュ機能 - Facebook"
595
 
596
+ #: includes/admin-setting.php:598 includes/admin-setting.php:1828
597
  msgid "Follow Base Cache - Push7"
598
  msgstr "フォロー基本キャッシュ機能 - Push7"
599
 
600
+ #: includes/admin-setting.php:609 includes/admin-setting.php:884
601
+ #: includes/admin-setting.php:1857
602
  msgid "Follow Base Cache - Twitter"
603
  msgstr "フォロー基本キャッシュ機能 - Twitter"
604
 
605
+ #: includes/admin-setting.php:620 includes/admin-setting.php:1791
606
+ msgid "Follow Base Cache - OneSignal"
607
+ msgstr "フォロー基本キャッシュ機能 - OneSignal"
608
+
609
+ #: includes/admin-setting.php:639 includes/admin-setting.php:644
610
  msgid "Current Setting"
611
  msgstr "現在の設定"
612
 
613
+ #: includes/admin-setting.php:639 includes/admin-setting.php:656
614
+ #: includes/admin-setting.php:688 includes/admin-setting.php:701
615
+ #: includes/admin-setting.php:706 includes/admin-setting.php:711
616
+ #: includes/admin-setting.php:725 includes/admin-setting.php:1071
617
  msgid "Share Base Cache"
618
  msgstr "シェア基本キャッシュ機能"
619
 
620
+ #: includes/admin-setting.php:639 includes/admin-setting.php:758
621
+ #: includes/admin-setting.php:771 includes/admin-setting.php:779
622
+ #: includes/admin-setting.php:1250
623
  msgid "Share Rush Cache"
624
  msgstr "シェア臨時キャッシュ機能"
625
 
626
+ #: includes/admin-setting.php:639 includes/admin-setting.php:785
627
+ #: includes/admin-setting.php:808 includes/admin-setting.php:1297
628
  msgid "Share Variation Analysis"
629
  msgstr "シェア変動分析機能"
630
 
631
+ #: includes/admin-setting.php:639 includes/admin-setting.php:816
632
+ #: includes/admin-setting.php:844 includes/admin-setting.php:1559
633
  msgid "Follow Base Cache"
634
  msgstr "フォロー基本キャッシュ機能"
635
 
636
+ #: includes/admin-setting.php:639 includes/admin-setting.php:913
637
+ #: includes/admin-setting.php:937 includes/admin-setting.php:1929
638
  msgid "Follow Variation Analysis"
639
  msgstr "フォロー変動分析機能"
640
 
641
+ #: includes/admin-setting.php:639 includes/admin-setting.php:945
642
+ #: includes/admin-setting.php:2191
643
  msgid "Dynamic Cache"
644
  msgstr "動的キャッシュ機能"
645
 
646
+ #: includes/admin-setting.php:639 includes/admin-setting.php:962
647
+ #: includes/admin-setting.php:2212
648
  msgid "Fault Tolerance"
649
  msgstr "フォールトトレランス機能"
650
 
651
+ #: includes/admin-setting.php:639 includes/admin-setting.php:979
652
+ #: includes/admin-setting.php:995 includes/admin-setting.php:1023
653
+ #: includes/admin-setting.php:2233
654
  msgid "Data Crawler"
655
  msgstr "データクローラ機能"
656
 
657
+ #: includes/admin-setting.php:639 includes/admin-setting.php:1036
658
+ #: includes/admin-setting.php:1054 includes/admin-setting.php:2283
659
  msgid "Data Export"
660
  msgstr "データエクスポート機能"
661
 
662
+ #: includes/admin-setting.php:639 includes/admin-setting.php:2574
663
  msgid "Exported File"
664
  msgstr "エクスポートされたファイル"
665
 
666
+ #: includes/admin-setting.php:649
667
  msgid "Capability"
668
  msgstr "機能"
669
 
670
+ #: includes/admin-setting.php:650
671
  msgid "Parameter"
672
  msgstr "パラメータ"
673
 
674
+ #: includes/admin-setting.php:651
675
  msgid "Value"
676
  msgstr "値"
677
 
678
+ #: includes/admin-setting.php:657 includes/admin-setting.php:817
679
+ #: includes/admin-setting.php:1075 includes/admin-setting.php:1563
680
  msgid "Target SNS"
681
  msgstr "対象SNS"
682
 
683
+ #: includes/admin-setting.php:669 includes/admin-setting.php:1083
684
  msgid "Hatena Bookmark"
685
  msgstr "はてなブックマーク"
686
 
687
+ #: includes/admin-setting.php:689 includes/admin-setting.php:1104
688
  msgid "Custom post types"
689
  msgstr "カスタム投稿タイプ"
690
 
691
+ #: includes/admin-setting.php:702 includes/admin-setting.php:772
692
+ #: includes/admin-setting.php:1112 includes/admin-setting.php:1276
693
  msgid "Interval cheking share count (sec)"
694
  msgstr "シェア数のチェック間隔(秒)"
695
 
696
+ #: includes/admin-setting.php:703 includes/admin-setting.php:775
697
+ #: includes/admin-setting.php:846
698
  msgid "seconds"
699
  msgstr "秒"
700
 
701
+ #: includes/admin-setting.php:707 includes/admin-setting.php:780
702
+ #: includes/admin-setting.php:1119 includes/admin-setting.php:1283
703
  msgid "Number of contents to check at a time"
704
  msgstr "一度にチェックするコンテンツ数"
705
 
706
+ #: includes/admin-setting.php:708 includes/admin-setting.php:781
707
  msgid "contents"
708
  msgstr "コンテンツ"
709
 
710
+ #: includes/admin-setting.php:712 includes/admin-setting.php:1126
711
  msgid "Scheme migration mode from http to https"
712
  msgstr "HTTPからHTTPSへのスキーム移行モード"
713
 
714
+ #: includes/admin-setting.php:716 includes/admin-setting.php:1028
715
+ #: includes/admin-setting.php:1130 includes/admin-setting.php:2270
716
  msgid "On"
717
  msgstr "有効"
718
 
719
+ #: includes/admin-setting.php:718 includes/admin-setting.php:1030
720
+ #: includes/admin-setting.php:1129 includes/admin-setting.php:2269
721
  msgid "Off"
722
  msgstr "無効"
723
 
724
+ #: includes/admin-setting.php:726 includes/admin-setting.php:1137
725
  msgid "Scheme migration date from http to https"
726
  msgstr "HTTPからHTTPSへのスキーム移行日"
727
 
728
+ #: includes/admin-setting.php:740 includes/admin-setting.php:1208
729
  msgid "Share Base Cache - Twitter"
730
  msgstr "シェア基本キャッシュ機能 - Twitter"
731
 
732
+ #: includes/admin-setting.php:741 includes/admin-setting.php:1212
733
  msgid "Alternative Twitter API"
734
  msgstr "代替Twitter API"
735
 
736
+ #: includes/admin-setting.php:759 includes/admin-setting.php:1254
737
  msgid "Term considering posted content as new content"
738
  msgstr "投稿日からコンテンツを新着とみなす期間"
739
 
740
+ #: includes/admin-setting.php:763
741
  msgid "day"
742
  msgstr "日"
743
 
744
+ #: includes/admin-setting.php:765
745
  msgid "days"
746
  msgstr "日"
747
 
748
+ #: includes/admin-setting.php:786 includes/admin-setting.php:914
749
+ #: includes/admin-setting.php:1301 includes/admin-setting.php:1933
750
  msgid "Method to update basis of comparison"
751
  msgstr "比較基準の更新方式"
752
 
753
+ #: includes/admin-setting.php:790 includes/admin-setting.php:799
754
+ #: includes/admin-setting.php:918 includes/admin-setting.php:927
755
+ #: includes/admin-setting.php:1304 includes/admin-setting.php:1936
 
756
  msgid "Disabled (None)"
757
  msgstr "無効(なし)"
758
 
759
+ #: includes/admin-setting.php:793 includes/admin-setting.php:921
760
+ #: includes/admin-setting.php:1305 includes/admin-setting.php:1937
761
  msgid "Enabled (Manual)"
762
  msgstr "有効(手動)"
763
 
764
+ #: includes/admin-setting.php:796 includes/admin-setting.php:924
765
+ #: includes/admin-setting.php:1306 includes/admin-setting.php:1938
766
  msgid "Enabled (Scheduler)"
767
  msgstr "有効(スケジューラ)"
768
 
769
+ #: includes/admin-setting.php:809 includes/admin-setting.php:938
770
  msgid "Schedule"
771
  msgstr "スケジュール"
772
 
773
+ #: includes/admin-setting.php:845 includes/admin-setting.php:1592
774
  msgid "Interval cheking follower count (sec)"
775
  msgstr "フォロワー数のチェック間隔(秒)"
776
 
777
+ #: includes/admin-setting.php:850 includes/admin-setting.php:877
778
+ #: includes/admin-setting.php:1689
779
  msgid "Follow Base Cache - Feedly"
780
  msgstr "フォロー基本キャッシュ機能 - Feedly"
781
 
782
+ #: includes/admin-setting.php:851 includes/admin-setting.php:1693
783
  msgid "Target feed type"
784
  msgstr "対象フィードタイプ"
785
 
786
+ #: includes/admin-setting.php:856 includes/admin-setting.php:871
787
+ #: includes/admin-setting.php:1696
788
  msgid "Default"
789
  msgstr "デフォルト"
790
 
791
+ #: includes/admin-setting.php:859 includes/admin-setting.php:1697
792
  msgid "RSS"
793
  msgstr "RSS"
794
 
795
+ #: includes/admin-setting.php:862 includes/admin-setting.php:1698
796
  msgid "RSS2"
797
  msgstr "RSS2"
798
 
799
+ #: includes/admin-setting.php:865 includes/admin-setting.php:1699
800
  msgid "RDF"
801
  msgstr "RDF"
802
 
803
+ #: includes/admin-setting.php:868 includes/admin-setting.php:1700
804
  msgid "ATOM"
805
  msgstr "ATOM"
806
 
807
+ #: includes/admin-setting.php:878 includes/admin-setting.php:1706
808
  msgid "Target feed"
809
  msgstr "対象フィード"
810
 
811
+ #: includes/admin-setting.php:885
812
  msgid "Target screen name"
813
  msgstr "対象スクリーンネーム"
814
 
815
+ #: includes/admin-setting.php:900 includes/admin-setting.php:1613
816
  msgid "Page ID"
817
  msgstr "対象ページID"
818
 
819
+ #: includes/admin-setting.php:946 includes/admin-setting.php:2195
820
  msgid "Dynamic caching based on user access"
821
  msgstr "ユーザアクセスをトリガとする動的キャッシュ"
822
 
823
+ #: includes/admin-setting.php:950 includes/admin-setting.php:956
824
+ #: includes/admin-setting.php:967 includes/admin-setting.php:973
825
+ #: includes/admin-setting.php:2198 includes/admin-setting.php:2219
826
  msgid "Disabled"
827
  msgstr "無効"
828
 
829
+ #: includes/admin-setting.php:953 includes/admin-setting.php:970
830
+ #: includes/admin-setting.php:2199 includes/admin-setting.php:2220
831
  msgid "Enabled"
832
  msgstr "有効"
833
 
834
+ #: includes/admin-setting.php:963
835
  msgid "Fault tolerance of count retrieval"
836
  msgstr "カウント取得における障害耐性"
837
 
838
+ #: includes/admin-setting.php:980 includes/admin-setting.php:2237
839
  msgid "Crawl method"
840
  msgstr "クロールの方式"
841
 
842
+ #: includes/admin-setting.php:985 includes/admin-setting.php:2242
843
  msgid "Normal (Sequential Retrieval)"
844
  msgstr "標準(逐次検索)"
845
 
846
+ #: includes/admin-setting.php:988 includes/admin-setting.php:2245
847
  msgid "Extended (Parallel Retrieval)"
848
  msgstr "拡張(並列検索)"
849
 
850
+ #: includes/admin-setting.php:996 includes/admin-setting.php:2252
851
  msgid "Crawl retry limit"
852
  msgstr "クロールの再試行上限"
853
 
854
+ #: includes/admin-setting.php:1001 includes/admin-setting.php:2255
855
  msgid "no retry"
856
  msgstr "再試行なし"
857
 
858
+ #: includes/admin-setting.php:1004 includes/admin-setting.php:2256
859
  msgid "1 time"
860
  msgstr "1回"
861
 
862
+ #: includes/admin-setting.php:1007 includes/admin-setting.php:1013
863
+ #: includes/admin-setting.php:2257
864
  msgid "2 times"
865
  msgstr "2回"
866
 
867
+ #: includes/admin-setting.php:1010 includes/admin-setting.php:2258
868
  msgid "3 times"
869
  msgstr "3回"
870
 
871
+ #: includes/admin-setting.php:1016 includes/admin-setting.php:2260
872
  msgid "5 times"
873
  msgstr "5回"
874
 
875
+ #: includes/admin-setting.php:1024 includes/admin-setting.php:2266
876
  msgid "SSL verification"
877
  msgstr "SSL証明書の検証"
878
 
879
+ #: includes/admin-setting.php:1037 includes/admin-setting.php:2287
880
  msgid "Method of data export"
881
  msgstr "データのエクスポート方式"
882
 
883
+ #: includes/admin-setting.php:1041 includes/admin-setting.php:2290
884
  msgid "Manual"
885
  msgstr "手動"
886
 
887
+ #: includes/admin-setting.php:1044 includes/admin-setting.php:1341
888
+ #: includes/admin-setting.php:1973 includes/admin-setting.php:2291
889
+ #: includes/admin-setting.php:2326
890
  msgid "Scheduler"
891
+ msgstr "スケジューラ"
892
 
893
+ #: includes/admin-setting.php:1055
894
  msgid "Interval exporting share count to a csv file"
895
  msgstr "シェア数をCSVファイルにエクスポートする間隔"
896
 
897
+ #: includes/admin-setting.php:1056
898
  msgid "hours"
899
  msgstr "時間"
900
 
901
+ #: includes/admin-setting.php:1108
902
  msgid "e.g. aaa, bbb, ccc (comma-delimited)"
903
  msgstr "例. aaa, bbb, ccc(カンマ区切り)"
904
 
905
+ #: includes/admin-setting.php:1115 includes/admin-setting.php:1279
906
+ msgid "Default: 900"
907
+ msgstr "既定値: 900"
908
 
909
+ #: includes/admin-setting.php:1122
910
+ msgid "Default: 15"
911
+ msgstr "既定値: 15"
912
 
913
+ #: includes/admin-setting.php:1132
914
  msgid "Default: Off"
915
  msgstr "既定値: 無効"
916
 
917
+ #: includes/admin-setting.php:1140
918
  msgid "Default: N/A"
919
  msgstr "既定値: N/A"
920
 
921
+ #: includes/admin-setting.php:1165 includes/admin-setting.php:1621
922
+ #: includes/admin-setting.php:1723 includes/admin-setting.php:1870
923
  msgid "Developer page"
924
  msgstr "開発者向けページ"
925
 
926
+ #: includes/admin-setting.php:1169 includes/admin-setting.php:1625
927
  msgid ""
928
  "Register a application in Facebook developer page to get the following App "
929
  "ID and App Secret."
931
  "以下のApp IDとApp Secretを取得するために、Facebook開発者向けページでアプリ"
932
  "ケーションを登録して下さい。"
933
 
934
+ #: includes/admin-setting.php:1173 includes/admin-setting.php:1629
935
+ msgid "App ID"
936
+ msgstr "App ID"
937
 
938
+ #: includes/admin-setting.php:1177 includes/admin-setting.php:1633
939
  msgid "App ID for Facebook API"
940
+ msgstr "Facebook API用のApp ID"
941
 
942
+ #: includes/admin-setting.php:1181 includes/admin-setting.php:1637
943
+ msgid "App Secret"
944
+ msgstr "App Secret"
945
 
946
+ #: includes/admin-setting.php:1185 includes/admin-setting.php:1641
947
  msgid "App Secret for Facebook API"
948
  msgstr "Facebook API用のApp Secret"
949
 
950
+ #: includes/admin-setting.php:1190 includes/admin-setting.php:1654
951
+ #: includes/admin-setting.php:1668 includes/admin-setting.php:1756
952
+ #: includes/admin-setting.php:1770
953
  msgid "Access Token"
954
  msgstr "Access Token"
955
 
956
+ #: includes/admin-setting.php:1194 includes/admin-setting.php:1672
957
  msgid "Access Token for Facebook API"
958
  msgstr "Facebook API用のAccess Token"
959
 
960
+ #: includes/admin-setting.php:1220
961
+ msgid "Default: widgetoon.js & count.jsoon"
962
+ msgstr "既定値: widgetoon.js & count.jsoon"
963
 
964
+ #: includes/admin-setting.php:1224
965
  msgid "Registration destination"
966
  msgstr "登録先"
967
 
968
+ #: includes/admin-setting.php:1238
969
  msgid ""
970
  "You need to register information such as your domain with the above site in "
971
  "order to start counting."
973
  "カウントを開始するためには、上記サイトにドメイン等の情報を登録する必要があり"
974
  "ます。"
975
 
976
+ #: includes/admin-setting.php:1257
977
  msgid "1 day"
978
  msgstr "1日"
979
 
980
+ #: includes/admin-setting.php:1258
981
  msgid "2 days"
982
  msgstr "2日"
983
 
984
+ #: includes/admin-setting.php:1259
985
  msgid "3 days"
986
  msgstr "3日"
987
 
988
+ #: includes/admin-setting.php:1260
989
  msgid "4 days"
990
  msgstr "4日"
991
 
992
+ #: includes/admin-setting.php:1261
993
  msgid "5 days"
994
  msgstr "5日"
995
 
996
+ #: includes/admin-setting.php:1262
997
  msgid "6 days"
998
  msgstr "6日"
999
 
1000
+ #: includes/admin-setting.php:1263
1001
  msgid "7 days"
1002
  msgstr "7日"
1003
 
1004
+ #: includes/admin-setting.php:1264
1005
  msgid "8 days"
1006
  msgstr "8日"
1007
 
1008
+ #: includes/admin-setting.php:1265
1009
  msgid "9 days"
1010
  msgstr "9日"
1011
 
1012
+ #: includes/admin-setting.php:1266
1013
  msgid "10 days"
1014
  msgstr "10日"
1015
 
1016
+ #: includes/admin-setting.php:1267
1017
  msgid "11 days"
1018
  msgstr "11日"
1019
 
1020
+ #: includes/admin-setting.php:1268
1021
  msgid "12 days"
1022
  msgstr "12日"
1023
 
1024
+ #: includes/admin-setting.php:1269
1025
  msgid "13 days"
1026
  msgstr "13日"
1027
 
1028
+ #: includes/admin-setting.php:1270
1029
  msgid "14 days"
1030
  msgstr "14日"
1031
 
1032
+ #: includes/admin-setting.php:1272
1033
  msgid "Default: 3 days"
1034
  msgstr "既定値: 3日"
1035
 
1036
+ #: includes/admin-setting.php:1286
1037
+ msgid "Default: 10"
1038
+ msgstr "既定値: 10"
1039
+
1040
+ #: includes/admin-setting.php:1308 includes/admin-setting.php:1940
1041
+ msgid "Default: Disabled (None)"
1042
+ msgstr "既定値: 無効(なし)"
1043
+
1044
+ #: includes/admin-setting.php:1346 includes/admin-setting.php:1978
1045
+ #: includes/admin-setting.php:2331
1046
  msgid "Type"
1047
  msgstr "タイプ"
1048
 
1049
+ #: includes/admin-setting.php:1351 includes/admin-setting.php:1983
1050
+ #: includes/admin-setting.php:2336
1051
  msgid "Hour"
1052
  msgstr "時"
1053
 
1054
+ #: includes/admin-setting.php:1354 includes/admin-setting.php:1986
1055
+ #: includes/admin-setting.php:2339
1056
  msgid "Minute"
1057
  msgstr "分"
1058
 
1059
+ #: includes/admin-setting.php:1360 includes/admin-setting.php:1992
1060
+ #: includes/admin-setting.php:2345
1061
  msgid "monthly"
1062
  msgstr "毎月"
1063
 
1064
+ #: includes/admin-setting.php:1371 includes/admin-setting.php:2003
1065
+ #: includes/admin-setting.php:2356
1066
  msgid "on 1."
1067
  msgstr "1日"
1068
 
1069
+ #: includes/admin-setting.php:1374 includes/admin-setting.php:2006
1070
+ #: includes/admin-setting.php:2359
1071
  msgid "on 2."
1072
  msgstr "2日"
1073
 
1074
+ #: includes/admin-setting.php:1377 includes/admin-setting.php:2009
1075
+ #: includes/admin-setting.php:2362
1076
  msgid "on 3."
1077
  msgstr "3日"
1078
 
1079
+ #: includes/admin-setting.php:1380 includes/admin-setting.php:2012
1080
+ #: includes/admin-setting.php:2365
1081
  msgid "on 4."
1082
  msgstr "4日"
1083
 
1084
+ #: includes/admin-setting.php:1383 includes/admin-setting.php:2015
1085
+ #: includes/admin-setting.php:2368
1086
  msgid "on 5."
1087
  msgstr "5日"
1088
 
1089
+ #: includes/admin-setting.php:1386 includes/admin-setting.php:2018
1090
+ #: includes/admin-setting.php:2371
1091
  msgid "on 6."
1092
  msgstr "6日"
1093
 
1094
+ #: includes/admin-setting.php:1389 includes/admin-setting.php:2021
1095
+ #: includes/admin-setting.php:2374
1096
  msgid "on 7."
1097
  msgstr "7日"
1098
 
1099
+ #: includes/admin-setting.php:1392 includes/admin-setting.php:2024
1100
+ #: includes/admin-setting.php:2377
1101
  msgid "on 8."
1102
  msgstr "8日"
1103
 
1104
+ #: includes/admin-setting.php:1395 includes/admin-setting.php:2027
1105
+ #: includes/admin-setting.php:2380
1106
  msgid "on 9."
1107
  msgstr "9日"
1108
 
1109
+ #: includes/admin-setting.php:1398 includes/admin-setting.php:2030
1110
+ #: includes/admin-setting.php:2383
1111
  msgid "on 10."
1112
  msgstr "10日"
1113
 
1114
+ #: includes/admin-setting.php:1401 includes/admin-setting.php:2033
1115
+ #: includes/admin-setting.php:2386
1116
  msgid "on 11."
1117
  msgstr "11日"
1118
 
1119
+ #: includes/admin-setting.php:1404 includes/admin-setting.php:2036
1120
+ #: includes/admin-setting.php:2389
1121
  msgid "on 12."
1122
  msgstr "12日"
1123
 
1124
+ #: includes/admin-setting.php:1407 includes/admin-setting.php:2039
1125
+ #: includes/admin-setting.php:2392
1126
  msgid "on 13."
1127
  msgstr "13日"
1128
 
1129
+ #: includes/admin-setting.php:1410 includes/admin-setting.php:2042
1130
+ #: includes/admin-setting.php:2395
1131
  msgid "on 14."
1132
  msgstr "14日"
1133
 
1134
+ #: includes/admin-setting.php:1413 includes/admin-setting.php:2045
1135
+ #: includes/admin-setting.php:2398
1136
  msgid "on 15."
1137
  msgstr "15日"
1138
 
1139
+ #: includes/admin-setting.php:1416 includes/admin-setting.php:2048
1140
+ #: includes/admin-setting.php:2401
1141
  msgid "on 16."
1142
  msgstr "16日"
1143
 
1144
+ #: includes/admin-setting.php:1419 includes/admin-setting.php:2051
1145
+ #: includes/admin-setting.php:2404
1146
  msgid "on 17."
1147
  msgstr "17日"
1148
 
1149
+ #: includes/admin-setting.php:1422 includes/admin-setting.php:2054
1150
+ #: includes/admin-setting.php:2407
1151
  msgid "on 18."
1152
  msgstr "18日"
1153
 
1154
+ #: includes/admin-setting.php:1425 includes/admin-setting.php:2057
1155
+ #: includes/admin-setting.php:2410
1156
  msgid "on 19."
1157
  msgstr "19日"
1158
 
1159
+ #: includes/admin-setting.php:1428 includes/admin-setting.php:2060
1160
+ #: includes/admin-setting.php:2413
1161
  msgid "on 20."
1162
  msgstr "20日"
1163
 
1164
+ #: includes/admin-setting.php:1431 includes/admin-setting.php:2063
1165
+ #: includes/admin-setting.php:2416
1166
  msgid "on 21."
1167
  msgstr "21日"
1168
 
1169
+ #: includes/admin-setting.php:1434 includes/admin-setting.php:2066
1170
+ #: includes/admin-setting.php:2419
1171
  msgid "on 22."
1172
  msgstr "22日"
1173
 
1174
+ #: includes/admin-setting.php:1437 includes/admin-setting.php:2069
1175
+ #: includes/admin-setting.php:2422
1176
  msgid "on 23."
1177
  msgstr "23日"
1178
 
1179
+ #: includes/admin-setting.php:1440 includes/admin-setting.php:2072
1180
+ #: includes/admin-setting.php:2425
1181
  msgid "on 24."
1182
  msgstr "24日"
1183
 
1184
+ #: includes/admin-setting.php:1443 includes/admin-setting.php:2075
1185
+ #: includes/admin-setting.php:2428
1186
  msgid "on 25."
1187
  msgstr "25日"
1188
 
1189
+ #: includes/admin-setting.php:1446 includes/admin-setting.php:2078
1190
+ #: includes/admin-setting.php:2431
1191
  msgid "on 26."
1192
  msgstr "26日"
1193
 
1194
+ #: includes/admin-setting.php:1449 includes/admin-setting.php:2081
1195
+ #: includes/admin-setting.php:2434
1196
  msgid "on 27."
1197
  msgstr "27日"
1198
 
1199
+ #: includes/admin-setting.php:1452 includes/admin-setting.php:2084
1200
+ #: includes/admin-setting.php:2437
1201
  msgid "on 28."
1202
  msgstr "28日"
1203
 
1204
+ #: includes/admin-setting.php:1455 includes/admin-setting.php:2087
1205
+ #: includes/admin-setting.php:2440
1206
  msgid "on 29."
1207
  msgstr "29日"
1208
 
1209
+ #: includes/admin-setting.php:1458 includes/admin-setting.php:2090
1210
+ #: includes/admin-setting.php:2443
1211
  msgid "on 30."
1212
  msgstr "30日"
1213
 
1214
+ #: includes/admin-setting.php:1461 includes/admin-setting.php:2093
1215
+ #: includes/admin-setting.php:2446
1216
  msgid "on 31."
1217
  msgstr "31日"
1218
 
1219
+ #: includes/admin-setting.php:1488 includes/admin-setting.php:2120
1220
+ #: includes/admin-setting.php:2477
1221
  msgid "weekly"
1222
  msgstr "毎週"
1223
 
1224
+ #: includes/admin-setting.php:1494 includes/admin-setting.php:2126
1225
+ #: includes/admin-setting.php:2483
1226
  msgid "Sunday"
1227
  msgstr "日曜日"
1228
 
1229
+ #: includes/admin-setting.php:1495 includes/admin-setting.php:2127
1230
+ #: includes/admin-setting.php:2484
1231
  msgid "Monday"
1232
  msgstr "月曜日"
1233
 
1234
+ #: includes/admin-setting.php:1496 includes/admin-setting.php:2128
1235
+ #: includes/admin-setting.php:2485
1236
  msgid "Tuesday"
1237
  msgstr "火曜日"
1238
 
1239
+ #: includes/admin-setting.php:1497 includes/admin-setting.php:2129
1240
+ #: includes/admin-setting.php:2486
1241
  msgid "Wednesday"
1242
  msgstr "水曜日"
1243
 
1244
+ #: includes/admin-setting.php:1498 includes/admin-setting.php:2130
1245
+ #: includes/admin-setting.php:2487
1246
  msgid "Thursday"
1247
  msgstr "木曜日"
1248
 
1249
+ #: includes/admin-setting.php:1499 includes/admin-setting.php:2131
1250
+ #: includes/admin-setting.php:2488
1251
  msgid "Friday"
1252
  msgstr "金曜日"
1253
 
1254
+ #: includes/admin-setting.php:1500 includes/admin-setting.php:2132
1255
+ #: includes/admin-setting.php:2489
1256
  msgid "Saturday"
1257
  msgstr "土曜日"
1258
 
1259
+ #: includes/admin-setting.php:1522 includes/admin-setting.php:2154
1260
+ #: includes/admin-setting.php:2515
1261
  msgid "daily"
1262
  msgstr "毎日"
1263
 
1264
+ #: includes/admin-setting.php:1595
1265
  msgid "Default: 86400 Minimum: 3600"
1266
  msgstr "既定値: 86400 最小値: 3600"
1267
 
1268
+ #: includes/admin-setting.php:1617
1269
  msgid "Facebook page ID that you want to get follower count"
1270
  msgstr "フォロワー数取得対象のFacebookページID"
1271
 
1272
+ #: includes/admin-setting.php:1645 includes/admin-setting.php:1747
1273
  msgid "Redirect URI"
1274
  msgstr "Redirect URI"
1275
 
1276
+ #: includes/admin-setting.php:1647 includes/admin-setting.php:1657
1277
+ #: includes/admin-setting.php:1749 includes/admin-setting.php:1759
1278
+ #: includes/admin-setting.php:1898
1279
  msgid "To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac)."
1280
  msgstr ""
1281
  "フィールドをクリック後、Ctrl + C (PC)、またはCmd + C (Mac)を押下しコピーして"
1282
  "下さい。"
1283
 
1284
+ #: includes/admin-setting.php:1649
1285
  msgid ""
1286
  "Copy and set this to the field of \"Valid OAuth redirect URIs\" in "
1287
  "application management page of Facebook developer page."
1289
  "Facebook開発者向けページ内のアプリケーション管理ページにて「有効なOAuthリダイ"
1290
  "レクトURI」フィールドにこのURIを設定して下さい。"
1291
 
1292
+ #: includes/admin-setting.php:1659 includes/admin-setting.php:1761
1293
+ #: includes/admin-setting.php:1900
1294
  msgid "Copy and pase this into the fields below."
1295
  msgstr "以下のフィールドにコピー&ペーストして下さい。"
1296
 
1297
+ #: includes/admin-setting.php:1680 includes/admin-setting.php:1782
1298
  msgid "Get Access Token"
1299
  msgstr "Access Tokenの取得"
1300
 
1301
+ #: includes/admin-setting.php:1702
1302
  msgid "Default: Default"
1303
  msgstr "既定値: デフォルト"
1304
 
1305
+ #: includes/admin-setting.php:1727
1306
  msgid ""
1307
  "Register a client in Instagram developer page to get the following Client ID "
1308
  "and Client Secret."
1310
  "以下のClient IDとClient Secretを取得するために、Instagram開発者向けページでク"
1311
  "ライアントを登録して下さい。"
1312
 
1313
+ #: includes/admin-setting.php:1731
1314
  msgid "Client ID"
1315
  msgstr "Client ID"
1316
 
1317
+ #: includes/admin-setting.php:1735
1318
  msgid "Client ID for Instagram API"
1319
  msgstr "Instagram API用のClient ID"
1320
 
1321
+ #: includes/admin-setting.php:1739
1322
  msgid "Client Secret"
1323
  msgstr "Client Secret"
1324
 
1325
+ #: includes/admin-setting.php:1743
1326
  msgid "Client Secret for Instagram API"
1327
  msgstr "Instagram API用のClient Secret"
1328
 
1329
+ #: includes/admin-setting.php:1751
1330
  msgid ""
1331
  "Copy and set this to the field of \"Valid redirect URIs\" in the client "
1332
  "management page of Instagram developer page."
1334
  "Instagram開発者向けページ内のクライアント管理ページにて「Valid redirect "
1335
  "URIs」フィールドにこのURIを設定して下さい。"
1336
 
1337
+ #: includes/admin-setting.php:1774
1338
  msgid "Access Token for Instagram API"
1339
  msgstr "Instagram API用のAccess Token"
1340
 
1341
+ #: includes/admin-setting.php:1795
1342
+ msgid "Home page"
1343
+ msgstr "ホームページ"
1344
+
1345
+ #: includes/admin-setting.php:1799
1346
+ msgid ""
1347
+ "Register a application in OneSignal page to get the following App ID and "
1348
+ "User Auth Key."
1349
+ msgstr ""
1350
+ "以下のApp IDとUser Auth Keyを取得するために、OneSignalページでアプリケーショ"
1351
+ "ンを登録して下さい。"
1352
+
1353
+ #: includes/admin-setting.php:1803
1354
+ msgid "OneSignal App ID"
1355
+ msgstr "OneSignal App ID"
1356
+
1357
+ #: includes/admin-setting.php:1807
1358
+ msgid "OneSignal app ID that you want to get follower count"
1359
+ msgstr "フォロワー数取得対象のOneSignal App ID"
1360
+
1361
+ #: includes/admin-setting.php:1811
1362
+ msgid "REST API Key"
1363
+ msgstr "REST API Key"
1364
+
1365
+ #: includes/admin-setting.php:1815
1366
+ msgid "REST API Key for OneSignal API"
1367
+ msgstr "OneSignal API用のREST API Key"
1368
+
1369
+ #: includes/admin-setting.php:1832
1370
  msgid "Push7 page"
1371
  msgstr "Push7ページ"
1372
 
1373
+ #: includes/admin-setting.php:1836
1374
+ msgid "Register a application in Push7 page to get the following App Number."
1375
  msgstr ""
1376
+ "以下のApp Numberを取得するために、Push7のページでアプリケーションを登録して下"
1377
+ "さい。"
1378
 
1379
+ #: includes/admin-setting.php:1840
1380
+ msgid "App Number"
1381
+ msgstr "App Number"
1382
 
1383
+ #: includes/admin-setting.php:1844
1384
+ msgid "App Number for Push7 API"
1385
+ msgstr "Push7 API用のApp Number"
1386
 
1387
+ #: includes/admin-setting.php:1861
1388
  msgid "Screen Name"
1389
  msgstr "スクリーン名"
1390
 
1391
+ #: includes/admin-setting.php:1866
1392
  msgid "Twitter screen name that you want to get follower count"
1393
  msgstr "フォロワー数を取得するTwitterのスクリーン名"
1394
 
1395
+ #: includes/admin-setting.php:1874
1396
  msgid ""
1397
  "Register a application in Twitter developer page to get the following "
1398
  "Consumer Key and Consumer Secret."
1400
  "以下のConsumer KeyとConsumer Secretを取得するために、Twitter開発者向けページ"
1401
  "でアプリケーションを登録して下さい。"
1402
 
1403
+ #: includes/admin-setting.php:1878
1404
+ msgid "API Key"
1405
+ msgstr "API Key"
1406
 
1407
+ #: includes/admin-setting.php:1882
1408
+ msgid "API key for Twitter API"
1409
+ msgstr "Twitter API用のAPI Key"
1410
 
1411
+ #: includes/admin-setting.php:1886
1412
+ msgid "API Secret Key"
1413
+ msgstr "API Secret Key"
1414
 
1415
+ #: includes/admin-setting.php:1890
1416
+ msgid "API Secret Key for Twitter API"
1417
+ msgstr "Twitter API用のAPI Secret Key"
1418
 
1419
+ #: includes/admin-setting.php:1895 includes/admin-setting.php:1909
1420
  msgid "Bearer Token"
1421
  msgstr "Bearer Token"
1422
 
1423
+ #: includes/admin-setting.php:1913
1424
  msgid "Bearer Token for Twitter API"
1425
  msgstr "Twitter API用のBearer Token"
1426
 
1427
+ #: includes/admin-setting.php:2201 includes/admin-setting.php:2222
1428
  msgid "Default: Disabled"
1429
  msgstr "既定値: 無効"
1430
 
1431
+ #: includes/admin-setting.php:2216
1432
  msgid "Fault tolerant mode of count retrieval"
1433
  msgstr "カウント取得における耐障害モード"
1434
 
1435
+ #: includes/admin-setting.php:2259
1436
  msgid "4 times"
1437
  msgstr "4回"
1438
 
1439
+ #: includes/admin-setting.php:2262
1440
+ msgid "Default: no retry"
1441
+ msgstr "既定値: 再試行なし"
1442
 
1443
+ #: includes/admin-setting.php:2272
1444
  msgid "Default: On"
1445
  msgstr "既定値: 有効"
1446
 
1447
+ #: includes/admin-setting.php:2293
1448
  msgid "Default: Manual"
1449
  msgstr "既定値: 手動"
1450
 
1451
+ #: includes/admin-setting.php:2542
1452
  msgid "hourly"
1453
  msgstr "毎時"
1454
 
1455
+ #: includes/admin-setting.php:2579
1456
  msgid "Disk usage of exported file"
1457
  msgstr "エクスポートされたファイルのディスク使用量"
1458
 
1459
+ #: includes/admin-setting.php:2588
1460
  msgid "No exported file"
1461
  msgstr "エクスポートされたファイルは存在しません。"
1462
 
1463
+ #: includes/admin-setting.php:2600
1464
  msgid "Manual export"
1465
  msgstr "手動エクスポート"
1466
 
1467
+ #: includes/admin-setting.php:2604
1468
  msgid "Export share count to a csv file."
1469
  msgstr "シェア数をCSVファイルにエクスポートします。"
1470
 
1471
+ #: includes/admin-setting.php:2618
1472
  msgid "Reset of exported file"
1473
  msgstr "エクスポートされたファイルのリセット"
1474
 
1475
+ #: includes/admin-setting.php:2622
1476
  msgid "Clear exported csv file."
1477
  msgstr "エクスポートされたCSVファイルを削除します。"
1478
 
1479
+ #: includes/admin-setting.php:2633
1480
  msgid "Download of exported file"
1481
  msgstr "エクスポートされたファイルのダウンロード"
1482
 
1483
+ #: includes/admin-setting.php:2635 includes/download.php:40
1484
  msgid "Download"
1485
  msgstr "ダウンロード"
1486
 
1487
+ #: includes/admin-setting.php:2637
1488
  msgid "Download the exported csv file."
1489
  msgstr "エクスポートされたCSVファイルをダウンロードします。"
1490
 
1491
+ #: includes/class-scc-wp-cron.php:278
1492
  #, php-format
1493
  msgid "The %s constant is set to true. WP-Cron spawning is disabled."
1494
  msgstr ""
1495
 
1496
+ #: includes/class-scc-wp-cron.php:282
1497
  #, php-format
1498
  msgid "The %s constant is set to true."
1499
  msgstr ""
1500
 
1501
+ #: includes/class-scc-wp-cron.php:312
1502
  #, php-format
1503
  msgid "Unexpected HTTP response code: %s"
1504
  msgstr ""
1505
 
1506
+ #: includes/download.php:70 includes/download.php:73 index.php:42 index.php:50
1507
+ #: index.php:53 index.php:56 index.php:59 sns-count-cache.php:1997
1508
+ #: sns-count-cache.php:2010 sns-count-cache.php:2022 sns-count-cache.php:2034
1509
+ #: sns-count-cache.php:2046 sns-count-cache.php:2058 sns-count-cache.php:2070
1510
+ #: sns-count-cache.php:2082
1511
  msgid "You do not have sufficient permissions to access this page."
1512
  msgstr "このページにアクセスするために必要な権限がありません。"
1513
 
1514
+ #: sns-count-cache.php:1950
1515
  msgid "Dashboard | SNS Count Cache"
1516
  msgstr "ダッシュボード | SNS Count Cache"
1517
 
1518
+ #: sns-count-cache.php:1951
1519
  msgid "Cache Status | SNS Count Cache"
1520
  msgstr "キャッシュ状況 | SNS Count Cache"
1521
 
1522
+ #: sns-count-cache.php:1952
1523
  msgid "Share Count | SNS Count Cache"
1524
  msgstr "シェア数 | SNS Count Cache"
1525
 
1526
+ #: sns-count-cache.php:1955
1527
  msgid "Hot Content | SNS Count Cache"
1528
  msgstr "話題のコンテンツ | SNS Count Cache"
1529
 
1530
+ #: sns-count-cache.php:1958
1531
  msgid "Setting | SNS Count Cache"
1532
  msgstr "設定 | SNS Count Cache"
1533
 
1534
+ #: sns-count-cache.php:1959
1535
  msgid "Help | SNS Count Cache"
1536
  msgstr "ヘルプ | SNS Count Cache"
1537
 
1538
+ #: sns-count-cache.php:2533 sns-count-cache.php:2541 sns-count-cache.php:2713
1539
+ #: sns-count-cache.php:2721
1540
  msgid "Completed"
1541
  msgstr "完了"
1542
 
1543
+ #: sns-count-cache.php:2535 sns-count-cache.php:2543 sns-count-cache.php:2715
1544
+ #: sns-count-cache.php:2723
1545
  msgid "Partially Completed"
1546
  msgstr "部分完了"
1547
 
1548
+ #: sns-count-cache.php:2537 sns-count-cache.php:2545 sns-count-cache.php:2717
1549
+ #: sns-count-cache.php:2725
1550
  msgid "Ongoing"
1551
  msgstr "進行中"
1552
 
1556
 
1557
  #. Description of the plugin/theme
1558
  msgid ""
1559
+ "SNS Count Cache gets share count for Twitter and Facebook, Pocket, "
1560
+ "Pinterest, Linkedin, Hatena Bookmark and caches these count in the "
1561
  "background. This plugin may help you to shorten page loading time because "
1562
  "the share count can be retrieved not through network but through the cache "
1563
  "using given functions."
1564
  msgstr ""
1565
+ "SNS Count Cacheは、Twitter、Facebook、Pocket、Pinterest、Linkedin、はてなブッ"
1566
+ "クマークのシェア数を取得し、バックグラウンドでキャッシュします。用意された関"
1567
+ "数を利用することで、ネットワーク経由でなくキャッシュからシェア数を参照できよ"
1568
+ "うになるため、ページ読み込みの高速化が見込めます。"
1569
 
1570
  #. Author of the plugin/theme
1571
  msgid "Daisuke Maruyama"
1575
  msgid "https://marubon.info/"
1576
  msgstr "https://marubon.info/"
1577
 
1578
+ #~ msgid "App ID (Client ID)"
1579
+ #~ msgstr "App ID (Client ID)"
1580
+
1581
+ #~ msgid "App Secret (Client Secret)"
1582
+ #~ msgstr "App Secret (Client Secret)"
1583
+
1584
+ #~ msgid "User Auth Key"
1585
+ #~ msgstr "User Auth Key"
1586
+
1587
+ #~ msgid "AppNo"
1588
+ #~ msgstr "AppNo"
1589
+
1590
+ #~ msgid "Consumer Key (API Key)"
1591
+ #~ msgstr "Consumer Key (API Key)"
1592
+
1593
+ #~ msgid "Cconsumer Key for Twitter API"
1594
+ #~ msgstr "Twitter API用のCconsumer Key"
1595
+
1596
+ #~ msgid "Consumer Secret (API Secret)"
1597
+ #~ msgstr "Consumer Secret (API Secret)"
1598
+
1599
+ #~ msgid "Default: 1 time"
1600
+ #~ msgstr "既定値: 1回"
1601
+
1602
+ #~ msgid "Google Plus share count is returned from cache."
1603
+ #~ msgstr "キャッシュからGoogle+のシェア数を取得します。"
1604
+
1605
+ #~ msgid "A meta key to access Google+ share count"
1606
+ #~ msgstr "Google+のシェア数にアクセスするためのMeta Keyです。"
1607
+
1608
+ #~ msgid "A meta key to access variation of Google+ share count"
1609
+ #~ msgstr "Google+のシェア数の増減数にアクセスするためのMeta Keyです。"
1610
+
1611
  #~ msgid "Follow Count"
1612
  #~ msgstr "フォロー数"
1613
 
1735
  #~ msgid "Twitter bearer token for OAuth"
1736
  #~ msgstr "OAuth認証のためのTwitter bearer token"
1737
 
 
 
 
1738
  #~ msgid ""
1739
  #~ "Copy and set this to the field of \"Valid OAuth redirect URIs\" in client "
1740
  #~ "management page of Facebook developer page"
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: marubon
3
  Donate link:
4
  Tags: performance, SNS, social, cache, share, follower
5
  Requires at least: 3.7
6
- Tested up to: 4.7.2
7
- Stable tag: 0.11.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -14,13 +14,13 @@ This plugin gets and caches SNS counts in the background, and help you to shorte
14
 
15
  SNS Count Cache is a plugin which helps you to shorten page loading time displaying share and follower counts through the use of cache mechanism.
16
 
17
- Notice: PHP Version 5.3+ is required in order to activate and execute this plugin.
 
18
 
19
  The plugin gets share counts for the following SNS and caches these counts in the background.
20
 
21
  * Twitter
22
  * Facebook
23
- * Google+
24
  * Pocket
25
  * Pinterest
26
  * Linkedin
@@ -39,6 +39,7 @@ The plugin also caches follower counts for the following SNS in the same way.
39
  * Facebook
40
  * Feedly
41
  * Instagram
 
42
  * Push7
43
 
44
  The share and follower counts can be retrieved quickly not through network but through the cache using given functions.
@@ -47,7 +48,6 @@ The following shows functions to get share count from the cache:
47
 
48
  * scc_get_share_twitter()
49
  * scc_get_share_facebook()
50
- * scc_get_share_gplus()
51
  * scc_get_share_pocket()
52
  * scc_get_share_pinterest()
53
  * scc_get_share_linkedin()
@@ -60,13 +60,13 @@ The following shows functions to get follower count from the cache:
60
  * scc_get_follow_twitter()
61
  * scc_get_follow_facebook()
62
  * scc_get_follow_instagram()
 
63
  * scc_get_follow_push7()
64
 
65
  The following describes meta keys to get share count from custom field.
66
 
67
  * scc_share_count_twitter
68
  * scc_share_count_facebook
69
- * scc_share_count_google+
70
  * scc_share_count_pocket
71
  * scc_share_count_pinterest
72
  * scc_share_count_linkedin
@@ -77,7 +77,6 @@ The following describes meta keys to get delta of share count from custom field.
77
 
78
  * scc_share_delta_twitter
79
  * scc_share_delta_facebook
80
- * scc_share_delta_google+
81
  * scc_share_delta_pocket
82
  * scc_share_delta_pinterest
83
  * scc_share_delta_linkedin
@@ -186,7 +185,20 @@ There are no questions.
186
  = 0.11.1 =
187
  * Fixed: Facebook share count becomes N/A in share count page in a certain situation.
188
 
 
 
 
 
 
 
189
  == Upgrade Notice ==
 
 
 
 
 
 
 
190
  The following functions are deprecated.
191
 
192
  * get_scc_twitter()
@@ -194,5 +206,6 @@ The following functions are deprecated.
194
  * get_scc_gplus()
195
  * get_scc_pocket()
196
  * get_scc_hatebu()
 
197
 
198
  == Arbitrary section ==
3
  Donate link:
4
  Tags: performance, SNS, social, cache, share, follower
5
  Requires at least: 3.7
6
+ Tested up to: 5.2
7
+ Stable tag: 1.0.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
14
 
15
  SNS Count Cache is a plugin which helps you to shorten page loading time displaying share and follower counts through the use of cache mechanism.
16
 
17
+ Notice:
18
+ In this version, Reregistration of information such as client ID, client secret, and access token is needed in the setting page.
19
 
20
  The plugin gets share counts for the following SNS and caches these counts in the background.
21
 
22
  * Twitter
23
  * Facebook
 
24
  * Pocket
25
  * Pinterest
26
  * Linkedin
39
  * Facebook
40
  * Feedly
41
  * Instagram
42
+ * OneSignal
43
  * Push7
44
 
45
  The share and follower counts can be retrieved quickly not through network but through the cache using given functions.
48
 
49
  * scc_get_share_twitter()
50
  * scc_get_share_facebook()
 
51
  * scc_get_share_pocket()
52
  * scc_get_share_pinterest()
53
  * scc_get_share_linkedin()
60
  * scc_get_follow_twitter()
61
  * scc_get_follow_facebook()
62
  * scc_get_follow_instagram()
63
+ * scc_get_follow_onesignal()
64
  * scc_get_follow_push7()
65
 
66
  The following describes meta keys to get share count from custom field.
67
 
68
  * scc_share_count_twitter
69
  * scc_share_count_facebook
 
70
  * scc_share_count_pocket
71
  * scc_share_count_pinterest
72
  * scc_share_count_linkedin
77
 
78
  * scc_share_delta_twitter
79
  * scc_share_delta_facebook
 
80
  * scc_share_delta_pocket
81
  * scc_share_delta_pinterest
82
  * scc_share_delta_linkedin
185
  = 0.11.1 =
186
  * Fixed: Facebook share count becomes N/A in share count page in a certain situation.
187
 
188
+ = 1.0.0 =
189
+ * Added: function to retrieve follower count of OneSignal.
190
+ * Fixed: Facebook share count is not retrieved and cached.
191
+ * Removed: Function to retrieve Google+ share count because the count is no longer provided.
192
+ * Fixed: Facebook access token can not be obtained in the setting page.
193
+
194
  == Upgrade Notice ==
195
+ Reregistration of information such as client ID, client secret, and access token is needed in the setting page.
196
+
197
+ The following describes meta keys are deprecated.
198
+
199
+ * scc_share_count_google+
200
+ * scc_share_delta_google+
201
+
202
  The following functions are deprecated.
203
 
204
  * get_scc_twitter()
206
  * get_scc_gplus()
207
  * get_scc_pocket()
208
  * get_scc_hatebu()
209
+ * scc_get_share_gplus()
210
 
211
  == Arbitrary section ==
screenshot-1.png CHANGED
Binary file
screenshot-2.png CHANGED
Binary file
screenshot-3.png CHANGED
Binary file
screenshot-4.png CHANGED
Binary file
screenshot-5.png CHANGED
Binary file
screenshot-6.png CHANGED
Binary file
sns-count-cache.php CHANGED
@@ -1,18 +1,18 @@
1
  <?php
2
- /*
3
  Plugin Name: SNS Count Cache
4
- Description: SNS Count Cache gets share count for Twitter and Facebook, Google Plus, Pocket, Pinterest, Linkedin, Hatena Bookmark and caches these count in the background. This plugin may help you to shorten page loading time because the share count can be retrieved not through network but through the cache using given functions.
5
- Version: 0.11.1
6
  Plugin URI: https://wordpress.org/plugins/sns-count-cache/
7
  Author: Daisuke Maruyama
8
  Author URI: https://marubon.info/
9
  License: GPL2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
11
  Text Domain: sns-count-cache
12
- */
13
 
14
  /*
15
- Copyright (C) 2014 - 2017 Daisuke Maruyama
16
 
17
  This program is free software; you can redistribute it and/or
18
  modify it under the terms of the GNU General Public License
@@ -29,3003 +29,3290 @@ along with this program; if not, write to the Free Software
29
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30
  */
31
 
32
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-common-util.php' );
33
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-wp-cron-util.php' );
34
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-sleep-throttle.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
- require_once ( dirname( __FILE__ ) . '/includes/interface-scc-order.php' );
37
 
38
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-engine.php' );
39
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-cache-engine.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-share-cache-engine.php' );
42
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-share-base-cache-engine.php' );
43
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-share-rush-cache-engine.php' );
44
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-share-lazy-cache-engine.php' );
45
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-share-second-cache-engine.php' );
46
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-share-restore-cache-engine.php' );
47
 
48
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-follow-cache-engine.php' );
49
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-follow-base-cache-engine.php' );
50
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-follow-lazy-cache-engine.php' );
51
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-follow-second-cache-engine.php' );
52
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-follow-restore-cache-engine.php' );
 
 
53
 
54
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-export-engine.php' );
55
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-common-data-export-engine.php' );
56
 
57
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-common-job-reset-engine.php' );
58
 
59
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-crawler.php' );
60
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-share-crawler.php' );
61
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-follow-crawler.php' );
62
 
63
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-analytical-engline.php' );
64
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-share-analytical-engine.php' );
65
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-follow-analytical-engine.php' );
 
 
 
 
 
 
66
 
67
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-crawl-strategy.php' );
68
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-share-crawl-strategy-factory.php' );
69
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-follow-crawl-strategy-factory.php' );
 
 
 
 
70
 
71
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-share-facebook-strategy.php' );
72
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-share-twitter-strategy.php' );
73
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-share-pocket-strategy.php' );
74
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-share-google-strategy.php' );
75
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-share-hatebu-strategy.php' );
76
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-share-pinterest-strategy.php' );
77
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-share-linkedin-strategy.php' );
78
 
79
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-follow-twitter-strategy.php' );
80
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-follow-feedly-strategy.php' );
81
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-follow-facebook-strategy.php' );
82
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-follow-push7-strategy.php' );
83
- require_once ( dirname( __FILE__ ) . '/includes/class-scc-follow-instagram-strategy.php' );
84
 
85
- require_once ( dirname( __FILE__ ) . '/includes/class-crypt-blowfish.php' );
86
- require_once ( dirname( __FILE__ ) . '/includes/class-default-key.php' );
 
 
 
87
 
88
- if ( ! defined( 'ABSPATH' ) ) exit(); // Exit if accessed directly
 
 
 
 
 
 
 
89
 
90
- if ( ! class_exists( 'SNS_Count_Cache' ) ) {
 
 
 
 
91
 
92
- final class SNS_Count_Cache implements SCC_Order {
 
 
 
 
93
 
94
- /**
95
- * Prefix of share cache ID
96
- */
97
- const OPT_SHARE_BASE_TRANSIENT_PREFIX = 'scc_share_count_';
 
98
 
99
- /**
100
- * Meta key for share second cache
101
- */
102
- const OPT_SHARE_2ND_META_KEY_PREFIX = 'scc_share_count_';
 
103
 
104
- /**
105
- * Prefix of follow cache ID
106
- */
107
- const OPT_FOLLOW_BASE_TRANSIENT_PREFIX = 'scc_follow_count_';
 
108
 
109
- /**
110
- * Meta key for follow second cache
111
- */
112
- const OPT_FOLLOW_2ND_META_KEY_PREFIX = 'scc_follow_count_';
 
113
 
114
- /**
115
- * Interval cheking and caching share count for share base cache
116
- */
117
- const OPT_SHARE_BASE_CHECK_INTERVAL = 600;
 
118
 
119
- /**
120
- * Number of posts to check at a time for share base cache
121
- */
122
- const OPT_SHARE_BASE_POSTS_PER_CHECK = 20;
 
123
 
124
- /**
125
- * Interval cheking and caching share count for share rush cache
126
- */
127
- const OPT_SHARE_RUSH_CHECK_INTERVAL = 600;
 
128
 
129
- /**
130
- * Number of posts to check at a time for share rush cache
131
- */
132
- const OPT_SHARE_RUSH_POSTS_PER_CHECK = 20;
 
133
 
134
- /**
135
- * Term that a content is considered as new content in share rush cache
136
- */
137
- const OPT_SHARE_RUSH_NEW_CONTENT_TERM = 3;
 
138
 
139
- /**
140
- * Interval for share second cache
141
- */
142
- const OPT_SHARE_2ND_CHECK_INTERVAL = 600;
 
143
 
144
- /**
145
- * Twitter alternative API (widgetoon.js & count.jsoon)
146
- */
147
- const OPT_SHARE_TWITTER_API_JSOON = 1;
148
 
149
- /**
150
- * Twitter alternative API (OpenShareCount)
151
- */
152
- const OPT_SHARE_TWITTER_API_OPENSHARECOUNT = 2;
 
 
 
153
 
154
- /**
155
- * Twitter alternative API (TwitCount)
156
- */
157
- const OPT_SHARE_TWITTER_API_TWITCOUNT = 3;
158
 
159
- /**
160
- * Twitter alternative API (NewShareCounts)
161
- */
162
- const OPT_SHARE_TWITTER_API_NEWSHARECOUNTS = 4;
 
163
 
164
- /**
165
- * Interval cheking and caching share count for follow base cache
166
- */
167
- const OPT_FOLLOW_BASE_CHECK_INTERVAL = 86400;
168
- const OPT_FOLLOW_BASE_CHECK_INTERVAL_MIN = 3600;
 
 
 
 
 
 
169
 
170
- /**
171
- * Interval for follow second cache
172
- */
173
- const OPT_FOLLOW_2ND_CHECK_INTERVAL = 600;
174
 
175
- /**
176
- * Type of data export
177
- */
178
- const OPT_COMMON_DATA_EXPORT_MANUAL = 1;
 
179
 
180
- /**
181
- * Type of data export
182
- */
183
- const OPT_COMMON_DATA_EXPORT_SCHEDULER = 2;
184
 
185
- /**
186
- * Type of share analysis
187
- */
188
- const OPT_SHARE_VARIATION_ANALYSIS_NONE = 1;
 
189
 
190
- /**
191
- * Type of share analysis
192
- */
193
- const OPT_SHARE_VARIATION_ANALYSIS_MANUAL = 2;
 
194
 
195
- /**
196
- * Type of share analysis
197
- */
198
- const OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER = 3;
199
 
200
- /**
201
- * Type of share analysis
202
- */
203
- const OPT_SHARE_VARIATION_ANALYSIS_SCHEDULE = '0 0 * * *';
 
204
 
205
- /**
206
- * Type of follow analysis
207
- */
208
- const OPT_FOLLOW_VARIATION_ANALYSIS_NONE = 1;
 
209
 
210
- /**
211
- * Type of follow analysis
212
- */
213
- const OPT_FOLLOW_VARIATION_ANALYSIS_MANUAL = 2;
 
214
 
215
- /**
216
- * Type of follow analysis
217
- */
218
- const OPT_FOLLOW_VARIATION_ANALYSIS_SCHEDULER = 3;
219
 
220
- /**
221
- * Type of follow analysis
222
- */
223
- const OPT_FOLLOW_VARIATION_ANALYSIS_SCHEDULE = '0 0 * * *';
224
 
225
- /**
226
- * File name of data export
227
- */
228
- const OPT_COMMON_DATA_EXPORT_FILE_NAME = 'sns-count-cache-data.csv';
229
 
230
- /**
231
- * Data export schedule
232
- */
233
- const OPT_COMMON_DATA_EXPORT_SCHEDULE = '0 0 * * *';
234
 
235
- /**
236
- * Type of dynamic cache processing
237
- */
238
- const OPT_COMMON_ACCESS_BASED_CACHE_OFF = 1;
239
 
240
- /**
241
- * Type of dynamic cache processing
242
- */
243
- const OPT_COMMON_ACCESS_BASED_CACHE_ON = 5;
244
 
245
- /**
246
- * Type of fault tolerance processing
247
- */
248
- const OPT_COMMON_FAULT_TOLERANCE_OFF = 1;
249
 
250
- /**
251
- * Type of fault tolerance processing
252
- */
253
- const OPT_COMMON_FAULT_TOLERANCE_ON = 2;
254
 
255
- /**
256
- * Type of scheme migration mode
257
- */
258
- const OPT_COMMON_SCHEME_MIGRATION_MODE_OFF = false;
 
259
 
260
- /**
261
- * Type of scheme migration mode
262
- */
263
- const OPT_COMMON_SCHEME_MIGRATION_MODE_ON = true;
264
 
265
- /**
266
- * Error message
267
- */
268
- const OPT_COMMON_ERROR_MESSAGE = 'scc_error_message';
269
 
270
- /**
271
- * Update message
272
- */
273
- const OPT_COMMON_UPDATE_MESSAGE = 'scc_update_message';
274
 
275
- /**
276
- * Type of crawl method
277
- */
278
- const OPT_COMMON_CRAWLER_METHOD_NORMAL = 1;
279
 
280
- /**
281
- * Type of crawl method
282
- */
283
- const OPT_COMMON_CRAWLER_METHOD_CURL = 2;
284
 
285
- /**
286
- * Type of crawl ssl verification
287
- */
288
- const OPT_COMMON_CRAWLER_SSL_VERIFY_ON = true;
289
 
290
- /**
291
- * Type of crawl ssl verification
292
- */
293
- const OPT_COMMON_CRAWLER_SSL_VERIFY_OFF = false;
294
 
295
- /**
296
- * crawler timeout
297
- */
298
- const OPT_COMMON_CRAWLER_TIMEOUT = 10;
299
 
300
- /**
301
- * crawler retry limit
302
- */
303
- const OPT_COMMON_CRAWLER_RETRY_LIMIT = 1;
304
 
305
- /**
306
- * Type of feed
307
- */
308
- const OPT_FEED_TYPE_DEFAULT = '';
309
 
310
- /**
311
- * Type of feed
312
- */
313
- const OPT_FEED_TYPE_RSS = 'rss';
 
 
 
 
314
 
315
- /**
316
- * Type of feed
317
- */
318
- const OPT_FEED_TYPE_RSS2 = 'rss2';
319
 
320
- /**
321
- * Type of feed
322
- */
323
- const OPT_FEED_TYPE_RDF = 'rdf';
 
324
 
325
- /**
326
- * Type of feed
327
- */
328
- const OPT_FEED_TYPE_ATOM = 'atom';
329
 
330
- /**
331
- * Capability for admin
332
- */
333
- const OPT_COMMON_CAPABILITY = 'manage_options';
 
 
 
334
 
335
- /**
336
- * Option key for custom post types for share base cache
337
- */
338
- const DB_SHARE_CUSTOM_POST_TYPES = 'share_custom_post_types';
339
 
340
- /**
341
- * Option key for check interval of share base cache
342
- */
343
- const DB_SHARE_BASE_CHECK_INTERVAL = 'share_base_check_interval';
 
 
 
 
344
 
345
- /**
346
- * Option key for twitter alternative api
347
- */
348
- const DB_SHARE_BASE_TWITTER_API = 'share_base_twitter_api';
349
 
350
- /**
351
- * Option key for number of posts to check at a time for share base cache
352
- */
353
- const DB_SHARE_BASE_POSTS_PER_CHECK = 'share_posts_per_check';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
354
 
355
- /**
356
- * Option key for dynamic cache
357
- */
358
- const DB_COMMON_DYNAMIC_CACHE_MODE = 'common_dynamic_cache_mode';
 
359
 
360
- /**
361
- * Option key for fault tolerance
362
- */
363
- const DB_COMMON_FAULT_TOLERANCE_MODE = 'common_fault_tolerance_mode';
364
 
365
- /**
366
- * Option key for new content term for share rush cache
367
- */
368
- const DB_SHARE_RUSH_NEW_CONTENT_TERM = 'share_new_content_term';
369
 
370
- /**
371
- * Option key for check interval of share rush cache
372
- */
373
- const DB_SHARE_RUSH_CHECK_INTERVAL = 'share_rush_check_interval';
 
 
374
 
375
- /**
376
- * Option key for number of posts to check at a time for share rush cache
377
- */
378
- const DB_SHARE_RUSH_POSTS_PER_CHECK = 'share_rush_posts_per_check';
379
 
380
- /**
381
- * Option key of cache target for share base cache
382
- */
383
- const DB_SHARE_CACHE_TARGET = 'share_cache_target';
 
384
 
385
- /**
386
- * Option key of cache target for follow base cache
387
- */
388
- const DB_FOLLOW_CACHE_TARGET = 'follow_cache_target';
389
 
390
- /**
391
- * Option key of cache target for follow base cache
392
- */
393
- const DB_FOLLOW_FEED_TYPE = '';
394
 
395
- /**
396
- * Option key of checking interval for follow base cache
397
- */
398
- const DB_FOLLOW_CHECK_INTERVAL = 'follow_check_interval';
 
399
 
400
- /**
401
- * Option key of data export
402
- */
403
- const DB_COMMON_DATA_EXPORT_MODE = 'common_data_export_mode';
404
 
405
- /**
406
- * Option key of data export schedule
407
- */
408
- const DB_COMMON_DATA_EXPORT_SCHEDULE = 'common_data_export_schedule';
 
 
409
 
410
- /**
411
- * Option key of http migration
412
- */
413
- const DB_COMMON_SCHEME_MIGRATION_MODE = 'common_scheme_migration_mode';
414
 
415
- /**
416
- * Option key of http migration
417
- */
418
- const DB_COMMON_SCHEME_MIGRATION_DATE = 'common_scheme_migration_date';
 
 
 
 
 
 
 
 
 
419
 
420
- /**
421
- * Option key of crawl ssl verification
422
- */
423
- const DB_COMMON_CRAWLER_SSL_VERIFICATION = 'common_crawler_ssl_verification';
 
 
 
 
 
 
 
 
 
 
 
 
 
424
 
425
- /**
426
- * Option key of crawl ssl verification
427
- */
428
- const DB_COMMON_CRAWLER_RETRY_LIMIT = 'common_crawler_retry_limit';
 
 
 
 
 
 
 
 
 
 
 
 
429
 
430
- /**
431
- * Option key of share variation analysis
432
- */
433
- const DB_SHARE_VARIATION_ANALYSIS_MODE = 'share_variation_analysis_mode';
 
 
 
 
 
 
 
 
434
 
435
- /**
436
- * Option key of share variation analysis
437
- */
438
- const DB_SHARE_VARIATION_ANALYSIS_SCHEDULE = 'share_variation_analysis_schedule';
439
 
440
- /**
441
- * Option key of follow variation analysis
442
- */
443
- const DB_FOLLOW_VARIATION_ANALYSIS_MODE = 'follow_variation_analysis_mode';
 
 
 
444
 
445
- /**
446
- * Option key of follow variation analysis
447
- */
448
- const DB_FOLLOW_VARIATION_ANALYSIS_SCHEDULE = 'follow_variation_analysis_schedule';
 
 
 
 
 
 
 
 
 
449
 
450
- /**
451
- * Option key of twitter consumer key
452
- */
453
- const DB_FOLLOW_TWITTER_SCREEN_NAME = 'follow_twitter_screen_name';
 
 
 
 
 
 
 
 
 
454
 
455
- /**
456
- * Option key of twitter consumer key
457
- */
458
- const DB_FOLLOW_TWITTER_CONSUMER_KEY = 'follow_twitter_consumer_key';
459
 
460
- /**
461
- * Option key of twitter consumer secret
462
- */
463
- const DB_FOLLOW_TWITTER_CONSUMER_SECRET = 'follow_twitter_consumer_secret';
 
 
 
464
 
465
- /**
466
- * Option key of twitter bearer token
467
- */
468
- const DB_FOLLOW_TWITTER_BEARER_TOKEN = 'follow_twitter_bearer_token';
469
 
470
- /**
471
- * Option key of twitter access token
472
- */
473
- const DB_FOLLOW_TWITTER_ACCESS_TOKEN = 'follow_twitter_access_token';
 
474
 
475
- /**
476
- * Option key of twitter access token secret
477
- */
478
- const DB_FOLLOW_TWITTER_ACCESS_TOKEN_SECRET = 'follow_twitter_access_token_secret';
 
 
 
 
 
 
 
 
 
479
 
480
- /**
481
- * Option key of facebook page ID
482
- */
483
- const DB_FOLLOW_FACEBOOK_PAGE_ID = 'follow_facebook_page_id';
484
-
485
- /**
486
- * Option key of facebook app ID
487
- */
488
- const DB_FOLLOW_FACEBOOK_APP_ID = 'follow_facebook_app_id';
489
-
490
- /**
491
- * Option key of facebook app secret
492
- */
493
- const DB_FOLLOW_FACEBOOK_APP_SECRET = 'follow_facebook_app_secret';
494
-
495
- /**
496
- * Option key of facebook access token
497
- */
498
- const DB_FOLLOW_FACEBOOK_ACCESS_TOKEN = 'follow_facebook_access_token';
499
-
500
- /**
501
- * Option key of facebook app ID
502
- */
503
- const DB_SHARE_FACEBOOK_APP_ID = 'share_facebook_app_id';
504
-
505
- /**
506
- * Option key of facebook app secret
507
- */
508
- const DB_SHARE_FACEBOOK_APP_SECRET = 'share_facebook_app_secret';
509
-
510
- /**
511
- * Option key of facebook access token
512
- */
513
- const DB_SHARE_FACEBOOK_ACCESS_TOKEN = 'share_facebook_access_token';
514
-
515
- /**
516
- * Option key of push7 appno
517
- */
518
- const DB_FOLLOW_PUSH7_APPNO = 'follow_push7_appno';
519
-
520
- /**
521
- * Option key of instagram client id
522
- */
523
- const DB_FOLLOW_INSTAGRAM_CLIENT_ID = 'follow_instagram_client_id';
524
-
525
- /**
526
- * Option key of instagram client secret
527
- */
528
- const DB_FOLLOW_INSTAGRAM_CLIENT_SECRET = 'follow_instagram_client_secret';
529
-
530
- /**
531
- * Option key of instagram access token
532
- */
533
- const DB_FOLLOW_INSTAGRAM_ACCESS_TOKEN = 'follow_instagram_access_token';
534
-
535
- /**
536
- * Option key of setting
537
- */
538
- const DB_SETTINGS = 'scc_settings';
539
-
540
- /**
541
- * Slug of the plugin
542
- */
543
- const DOMAIN = 'sns-count-cache';
544
-
545
- /**
546
- * ID of share base cache
547
- */
548
- const REF_SHARE_BASE = 'share-base';
549
-
550
- /**
551
- * ID of share rush cache
552
- */
553
- const REF_SHARE_RUSH = 'share-rush';
554
-
555
- /**
556
- * ID of share lazy cache
557
- */
558
- const REF_SHARE_LAZY = 'share-lazy';
559
-
560
- /**
561
- * ID of share second cache
562
- */
563
- const REF_SHARE_2ND = 'share-second';
564
-
565
- /**
566
- * ID of share analysis cache
567
- */
568
- const REF_SHARE_ANALYSIS = 'share-analysis';
569
-
570
- /**
571
- * ID of share restore cache
572
- */
573
- const REF_SHARE_RESTORE = 'share-restore';
574
-
575
- /**
576
- * ID of follow base cache
577
- */
578
- const REF_FOLLOW_BASE = 'follow-base';
579
-
580
- /**
581
- * ID of follow lazy cache
582
- */
583
- const REF_FOLLOW_LAZY = 'follow-lazy';
584
-
585
- /**
586
- * ID of follow second cache
587
- */
588
- const REF_FOLLOW_2ND = 'follow-second';
589
-
590
- /**
591
- * ID of follow analysis cache
592
- */
593
- const REF_FOLLOW_ANALYSIS = 'follow-analysis';
594
-
595
- /**
596
- * ID of share restore cache
597
- */
598
- const REF_FOLLOW_RESTORE = 'follow-restore';
599
-
600
- /**
601
- * ID of common data export
602
- */
603
- const REF_COMMON_EXPORT = 'common-export';
604
-
605
- /**
606
- * ID of common data export
607
- */
608
- const REF_COMMON_CONTROL = 'common-control';
609
-
610
- /**
611
- * ID of share
612
- */
613
- const REF_SHARE = 'share';
614
-
615
- /**
616
- * ID of follow
617
- */
618
- const REF_FOLLOW = 'follow';
619
-
620
- /**
621
- * ID of share count (Twitter)
622
- */
623
- const REF_SHARE_TWITTER = 'Twitter';
624
-
625
- /**
626
- * ID of share count (Facebook)
627
- */
628
- const REF_SHARE_FACEBOOK = 'Facebook';
629
-
630
- /**
631
- * ID of share count (Google Plus)
632
- */
633
- const REF_SHARE_GPLUS = 'Google+';
634
-
635
- /**
636
- * ID of share count (Hatena Bookmark)
637
- */
638
- const REF_SHARE_HATEBU = 'Hatebu';
639
-
640
- /**
641
- * ID of share count (Pocket)
642
- */
643
- const REF_SHARE_POCKET = 'Pocket';
644
-
645
- /**
646
- * ID of share count (Pinterest)
647
- */
648
- const REF_SHARE_PINTEREST = 'Pinterest';
649
-
650
- /**
651
- * ID of share count (LinkedIn)
652
- */
653
- const REF_SHARE_LINKEDIN = 'Linkedin';
654
-
655
- /**
656
- * ID of share count (Total)
657
- */
658
- const REF_SHARE_TOTAL = 'Total';
659
-
660
- /**
661
- * ID of follow count (Feedly)
662
- */
663
- const REF_FOLLOW_FEEDLY = 'Feedly';
664
-
665
- /**
666
- * ID of follow count (Feedly)
667
- */
668
- const REF_FOLLOW_TWITTER = 'Twitter';
669
-
670
- /**
671
- * ID of follow count (Feedly)
672
- */
673
- const REF_FOLLOW_FACEBOOK = 'Facebook';
674
-
675
- /**
676
- * ID of follow count (Push7)
677
- */
678
- const REF_FOLLOW_PUSH7 = 'Push7';
679
-
680
- /**
681
- * ID of follow count (Instagram)
682
- */
683
- const REF_FOLLOW_INSTAGRAM = 'Instagram';
684
-
685
- /**
686
- * ID of crawl date
687
- */
688
- const REF_CRAWL_DATE = 'CrawlDate';
689
-
690
- /**
691
- * Plugin version, used for cache-busting of style and script file references.
692
- */
693
- private $version = '0.11.1';
694
-
695
- /**
696
- * Instances of crawler
697
- */
698
- private $crawlers = array();
699
-
700
- /**
701
- * Instance of cache engine
702
- */
703
- private $cache_engines = array();
704
-
705
- /**
706
- * Instance of export engine
707
- */
708
- private $export_engines = array();
709
-
710
- /**
711
- * Instance of control engine
712
- */
713
- private $control_engines = array();
714
-
715
- /**
716
- * Instance of analytical engine
717
- */
718
- private $analytical_engines = array();
719
-
720
- /**
721
- * Slug of the plugin screen
722
- */
723
- private $plugin_screen_hook_suffix = array();
724
-
725
- /**
726
- * Cache target for share base cache
727
- */
728
- private $share_base_cache_target = array();
729
-
730
- /**
731
- * Post types to be cached
732
- */
733
- private $share_base_cache_post_types = array( 'post', 'page' );
734
-
735
- /**
736
- * Post types to be cached
737
- */
738
- private $share_base_custom_post_types = array();
739
-
740
- /**
741
- * Check interval for share base cahce
742
- */
743
- private $share_base_check_interval = 600;
744
-
745
- /**
746
- * Post per check for share base cache
747
- */
748
- private $share_base_posts_per_check = 20;
749
-
750
- /**
751
- * Post per check for share base cache
752
- */
753
- private $share_base_twitter_api = '';
754
-
755
- /**
756
- * Term considering content as new one
757
- */
758
- private $share_rush_new_content_term = 3;
759
-
760
- /**
761
- *Check interval for share rush cahce
762
- */
763
- private $share_rush_check_interval = 600;
764
-
765
- /**
766
- * Post per check for share rush cache
767
- */
768
- private $share_rush_posts_per_check = 20;
769
-
770
- /**
771
- * Facebook app ID
772
- */
773
- private $share_facebook_app_id = '';
774
-
775
- /**
776
- * Facebook app ID
777
- */
778
- private $share_facebook_app_secret = '';
779
-
780
- /**
781
- * Facebook access token
782
- */
783
- private $share_facebook_access_token = '';
784
-
785
- /**
786
- * Cache target for follow base cache
787
- */
788
- private $follow_base_cache_target = array();
789
-
790
- /**
791
- * Check
1
  <?php
2
+ /**
3
  Plugin Name: SNS Count Cache
4
+ Description: SNS Count Cache gets share count for Twitter and Facebook, Pocket, Pinterest, Linkedin, Hatena Bookmark and caches these count in the background. This plugin may help you to shorten page loading time because the share count can be retrieved not through network but through the cache using given functions.
5
+ Version: 1.0.0
6
  Plugin URI: https://wordpress.org/plugins/sns-count-cache/
7
  Author: Daisuke Maruyama
8
  Author URI: https://marubon.info/
9
  License: GPL2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
11
  Text Domain: sns-count-cache
12
+ */
13
 
14
  /*
15
+ Copyright (C) 2014 - 2019 Daisuke Maruyama
16
 
17
  This program is free software; you can redistribute it and/or
18
  modify it under the terms of the GNU General Public License
29
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30
  */
31
 
32
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-logger.php' );
33
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-http.php' );
34
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-crypt.php' );
35
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-oauth.php' );
36
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-format.php' );
37
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-file.php' );
38
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-hash.php' );
39
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-cache.php' );
40
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-wp-cron.php' );
41
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-sleep-throttle.php' );
42
+
43
+ require_once( dirname( __FILE__ ) . '/includes/interface-scc-order.php' );
44
+
45
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-engine.php' );
46
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-cache-engine.php' );
47
+
48
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-share-cache-engine.php' );
49
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-share-base-cache-engine.php' );
50
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-share-rush-cache-engine.php' );
51
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-share-lazy-cache-engine.php' );
52
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-share-second-cache-engine.php' );
53
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-share-restore-cache-engine.php' );
54
+
55
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-follow-cache-engine.php' );
56
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-follow-base-cache-engine.php' );
57
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-follow-lazy-cache-engine.php' );
58
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-follow-second-cache-engine.php' );
59
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-follow-restore-cache-engine.php' );
60
+
61
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-export-engine.php' );
62
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-common-data-export-engine.php' );
63
+
64
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-common-job-reset-engine.php' );
65
+
66
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-crawler.php' );
67
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-share-crawler.php' );
68
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-follow-crawler.php' );
69
+
70
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-analytical-engline.php' );
71
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-share-analytical-engine.php' );
72
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-follow-analytical-engine.php' );
73
+
74
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-crawl-strategy.php' );
75
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-share-crawl-strategy-factory.php' );
76
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-follow-crawl-strategy-factory.php' );
77
+
78
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-share-facebook-crawl-strategy.php' );
79
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-share-twitter-crawl-strategy.php' );
80
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-share-pocket-crawl-strategy.php' );
81
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-share-google-crawl-strategy.php' );
82
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-share-hatebu-crawl-strategy.php' );
83
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-share-pinterest-crawl-strategy.php' );
84
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-share-linkedin-crawl-strategy.php' );
85
+
86
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-follow-twitter-crawl-strategy.php' );
87
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-follow-feedly-crawl-strategy.php' );
88
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-follow-facebook-crawl-strategy.php' );
89
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-follow-push7-crawl-strategy.php' );
90
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-follow-instagram-crawl-strategy.php' );
91
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-follow-onesignal-crawl-strategy.php' );
92
+
93
+ require_once( dirname( __FILE__ ) . '/includes/class-scc-share-app-status-engine.php' );
94
+
95
+
96
+
97
+ if ( ! defined( 'ABSPATH' ) ) {
98
+ exit(); // Exit if accessed directly
99
+ }
100
 
101
+ if ( ! class_exists( 'SNS_Count_Cache' ) ) {
102
 
103
+ /**
104
+ * SNS_Count_Cache
105
+ */
106
+ final class SNS_Count_Cache implements SCC_Order {
107
+
108
+ /**
109
+ * Prefix of share cache ID
110
+ */
111
+ const OPT_SHARE_BASE_TRANSIENT_PREFIX = 'scc_share_count_';
112
+
113
+ /**
114
+ * Meta key for share second cache
115
+ */
116
+ const OPT_SHARE_2ND_META_KEY_PREFIX = 'scc_share_count_';
117
+
118
+ /**
119
+ * Prefix of follow cache ID
120
+ */
121
+ const OPT_FOLLOW_BASE_TRANSIENT_PREFIX = 'scc_follow_count_';
122
+
123
+ /**
124
+ * Meta key for follow second cache
125
+ */
126
+ const OPT_FOLLOW_2ND_META_KEY_PREFIX = 'scc_follow_count_';
127
+
128
+ /**
129
+ * Interval cheking and caching share count for share base cache
130
+ */
131
+ const OPT_SHARE_BASE_CHECK_INTERVAL = 900;
132
+
133
+ /**
134
+ * Number of posts to check at a time for share base cache
135
+ */
136
+ const OPT_SHARE_BASE_POSTS_PER_CHECK = 15;
137
+
138
+ /**
139
+ * Interval cheking and caching share count for share rush cache
140
+ */
141
+ const OPT_SHARE_RUSH_CHECK_INTERVAL = 900;
142
+
143
+ /**
144
+ * Number of posts to check at a time for share rush cache
145
+ */
146
+ const OPT_SHARE_RUSH_POSTS_PER_CHECK = 10;
147
+
148
+ /**
149
+ * Term that a content is considered as new content in share rush cache
150
+ */
151
+ const OPT_SHARE_RUSH_NEW_CONTENT_TERM = 3;
152
+
153
+ /**
154
+ * Interval for share second cache
155
+ */
156
+ const OPT_SHARE_2ND_CHECK_INTERVAL = 600;
157
+
158
+ /**
159
+ * Twitter alternative API (widgetoon.js & count.jsoon)
160
+ */
161
+ const OPT_SHARE_TWITTER_API_JSOON = 1;
162
+
163
+ /**
164
+ * Twitter alternative API (OpenShareCount)
165
+ */
166
+ const OPT_SHARE_TWITTER_API_OPENSHARECOUNT = 2;
167
+
168
+ /**
169
+ * Twitter alternative API (TwitCount)
170
+ */
171
+ const OPT_SHARE_TWITTER_API_TWITCOUNT = 3;
172
+
173
+ /**
174
+ * Twitter alternative API (NewShareCounts)
175
+ */
176
+ const OPT_SHARE_TWITTER_API_NEWSHARECOUNTS = 4;
177
+
178
+ /**
179
+ * Interval cheking and caching share count for follow base cache
180
+ */
181
+ const OPT_FOLLOW_BASE_CHECK_INTERVAL = 86400;
182
+ const OPT_FOLLOW_BASE_CHECK_INTERVAL_MIN = 3600;
183
+
184
+ /**
185
+ * Interval for follow second cache
186
+ */
187
+ const OPT_FOLLOW_2ND_CHECK_INTERVAL = 600;
188
+
189
+ /**
190
+ * Type of data export
191
+ */
192
+ const OPT_COMMON_DATA_EXPORT_MANUAL = 1;
193
+
194
+ /**
195
+ * Type of data export
196
+ */
197
+ const OPT_COMMON_DATA_EXPORT_SCHEDULER = 2;
198
+
199
+ /**
200
+ * Type of share analysis
201
+ */
202
+ const OPT_SHARE_VARIATION_ANALYSIS_NONE = 1;
203
+
204
+ /**
205
+ * Type of share analysis
206
+ */
207
+ const OPT_SHARE_VARIATION_ANALYSIS_MANUAL = 2;
208
+
209
+ /**
210
+ * Type of share analysis
211
+ */
212
+ const OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER = 3;
213
+
214
+ /**
215
+ * Type of share analysis
216
+ */
217
+ const OPT_SHARE_VARIATION_ANALYSIS_SCHEDULE = '0 0 * * *';
218
+
219
+ /**
220
+ * Type of follow analysis
221
+ */
222
+ const OPT_FOLLOW_VARIATION_ANALYSIS_NONE = 1;
223
+
224
+ /**
225
+ * Type of follow analysis
226
+ */
227
+ const OPT_FOLLOW_VARIATION_ANALYSIS_MANUAL = 2;
228
+
229
+ /**
230
+ * Type of follow analysis
231
+ */
232
+ const OPT_FOLLOW_VARIATION_ANALYSIS_SCHEDULER = 3;
233
+
234
+ /**
235
+ * Type of follow analysis
236
+ */
237
+ const OPT_FOLLOW_VARIATION_ANALYSIS_SCHEDULE = '0 0 * * *';
238
+
239
+ /**
240
+ * File name of data export
241
+ */
242
+ const OPT_COMMON_DATA_EXPORT_FILE_NAME = 'sns-count-cache-data.csv';
243
+
244
+ /**
245
+ * Data export schedule
246
+ */
247
+ const OPT_COMMON_DATA_EXPORT_SCHEDULE = '0 0 * * *';
248
+
249
+ /**
250
+ * Type of dynamic cache processing
251
+ */
252
+ const OPT_COMMON_ACCESS_BASED_CACHE_OFF = 1;
253
+
254
+ /**
255
+ * Type of dynamic cache processing
256
+ */
257
+ const OPT_COMMON_ACCESS_BASED_CACHE_ON = 5;
258
+
259
+ /**
260
+ * Type of fault tolerance processing
261
+ */
262
+ const OPT_COMMON_FAULT_TOLERANCE_OFF = 1;
263
+
264
+ /**
265
+ * Type of fault tolerance processing
266
+ */
267
+ const OPT_COMMON_FAULT_TOLERANCE_ON = 2;
268
+
269
+ /**
270
+ * Type of scheme migration mode
271
+ */
272
+ const OPT_COMMON_SCHEME_MIGRATION_MODE_OFF = false;
273
+
274
+ /**
275
+ * Type of scheme migration mode
276
+ */
277
+ const OPT_COMMON_SCHEME_MIGRATION_MODE_ON = true;
278
+
279
+ /**
280
+ * Error message
281
+ */
282
+ const OPT_COMMON_ERROR_MESSAGE = 'scc_error_message';
283
+
284
+ /**
285
+ * Update message
286
+ */
287
+ const OPT_COMMON_UPDATE_MESSAGE = 'scc_update_message';
288
+
289
+ /**
290
+ * Type of crawl method
291
+ */
292
+ const OPT_COMMON_CRAWLER_METHOD_NORMAL = 1;
293
+
294
+ /**
295
+ * Type of crawl method
296
+ */
297
+ const OPT_COMMON_CRAWLER_METHOD_CURL = 2;
298
+
299
+ /**
300
+ * Type of crawl ssl verification
301
+ */
302
+ const OPT_COMMON_CRAWLER_SSL_VERIFY_ON = true;
303
+
304
+ /**
305
+ * Type of crawl ssl verification
306
+ */
307
+ const OPT_COMMON_CRAWLER_SSL_VERIFY_OFF = false;
308
+
309
+ /**
310
+ * crawler timeout
311
+ */
312
+ const OPT_COMMON_CRAWLER_TIMEOUT = 10;
313
+
314
+ /**
315
+ * crawler retry limit
316
+ */
317
+ const OPT_COMMON_CRAWLER_RETRY_LIMIT = -1;
318
+
319
+ /**
320
+ * Type of feed
321
+ */
322
+ const OPT_FEED_TYPE_DEFAULT = '';
323
+
324
+ /**
325
+ * Type of feed
326
+ */
327
+ const OPT_FEED_TYPE_RSS = 'rss';
328
+
329
+ /**
330
+ * Type of feed
331
+ */
332
+ const OPT_FEED_TYPE_RSS2 = 'rss2';
333
+
334
+ /**
335
+ * Type of feed
336
+ */
337
+ const OPT_FEED_TYPE_RDF = 'rdf';
338
+
339
+ /**
340
+ * Type of feed
341
+ */
342
+ const OPT_FEED_TYPE_ATOM = 'atom';
343
+
344
+ /**
345
+ * Capability for admin
346
+ */
347
+ const OPT_COMMON_CAPABILITY = 'manage_options';
348
+
349
+ /**
350
+ * Option key for custom post types for share base cache
351
+ */
352
+ const DB_SHARE_CUSTOM_POST_TYPES = 'share_custom_post_types';
353
+
354
+ /**
355
+ * Option key for check interval of share base cache
356
+ */
357
+ const DB_SHARE_BASE_CHECK_INTERVAL = 'share_base_check_interval';
358
+
359
+ /**
360
+ * Option key for twitter alternative api
361
+ */
362
+ const DB_SHARE_BASE_TWITTER_API = 'share_base_twitter_api';
363
+
364
+ /**
365
+ * Option key for number of posts to check at a time for share base cache
366
+ */
367
+ const DB_SHARE_BASE_POSTS_PER_CHECK = 'share_posts_per_check';
368
+
369
+ /**
370
+ * Option key for dynamic cache
371
+ */
372
+ const DB_COMMON_DYNAMIC_CACHE_MODE = 'common_dynamic_cache_mode';
373
+
374
+ /**
375
+ * Option key for fault tolerance
376
+ */
377
+ const DB_COMMON_FAULT_TOLERANCE_MODE = 'common_fault_tolerance_mode';
378
+
379
+ /**
380
+ * Option key for new content term for share rush cache
381
+ */
382
+ const DB_SHARE_RUSH_NEW_CONTENT_TERM = 'share_new_content_term';
383
+
384
+ /**
385
+ * Option key for check interval of share rush cache
386
+ */
387
+ const DB_SHARE_RUSH_CHECK_INTERVAL = 'share_rush_check_interval';
388
+
389
+ /**
390
+ * Option key for number of posts to check at a time for share rush cache
391
+ */
392
+ const DB_SHARE_RUSH_POSTS_PER_CHECK = 'share_rush_posts_per_check';
393
+
394
+ /**
395
+ * Option key of cache target for share base cache
396
+ */
397
+ const DB_SHARE_CACHE_TARGET = 'share_cache_target';
398
+
399
+ /**
400
+ * Option key of cache target for follow base cache
401
+ */
402
+ const DB_FOLLOW_CACHE_TARGET = 'follow_cache_target';
403
+
404
+ /**
405
+ * Option key of cache target for follow base cache
406
+ */
407
+ const DB_FOLLOW_FEED_TYPE = '';
408
+
409
+ /**
410
+ * Option key of checking interval for follow base cache
411
+ */
412
+ const DB_FOLLOW_CHECK_INTERVAL = 'follow_check_interval';
413
+
414
+ /**
415
+ * Option key of data export
416
+ */
417
+ const DB_COMMON_DATA_EXPORT_MODE = 'common_data_export_mode';
418
+
419
+ /**
420
+ * Option key of data export schedule
421
+ */
422
+ const DB_COMMON_DATA_EXPORT_SCHEDULE = 'common_data_export_schedule';
423
+
424
+ /**
425
+ * Option key of http migration
426
+ */
427
+ const DB_COMMON_SCHEME_MIGRATION_MODE = 'common_scheme_migration_mode';
428
+
429
+ /**
430
+ * Option key of http migration
431
+ */
432
+ const DB_COMMON_SCHEME_MIGRATION_DATE = 'common_scheme_migration_date';
433
+
434
+ /**
435
+ * Option key of crawl ssl verification
436
+ */
437
+ const DB_COMMON_CRAWLER_SSL_VERIFICATION = 'common_crawler_ssl_verification';
438
+
439
+ /**
440
+ * Option key of crawl ssl verification
441
+ */
442
+ const DB_COMMON_CRAWLER_RETRY_LIMIT = 'common_crawler_retry_limit';
443
+
444
+ /**
445
+ * Option key of share variation analysis
446
+ */
447
+ const DB_SHARE_VARIATION_ANALYSIS_MODE = 'share_variation_analysis_mode';
448
+
449
+ /**
450
+ * Option key of share variation analysis
451
+ */
452
+ const DB_SHARE_VARIATION_ANALYSIS_SCHEDULE = 'share_variation_analysis_schedule';
453
+
454
+ /**
455
+ * Option key of follow variation analysis
456
+ */
457
+ const DB_FOLLOW_VARIATION_ANALYSIS_MODE = 'follow_variation_analysis_mode';
458
+
459
+ /**
460
+ * Option key of follow variation analysis
461
+ */
462
+ const DB_FOLLOW_VARIATION_ANALYSIS_SCHEDULE = 'follow_variation_analysis_schedule';
463
+
464
+ /**
465
+ * Option key of twitter consumer key
466
+ */
467
+ const DB_FOLLOW_TWITTER_SCREEN_NAME = 'follow_twitter_screen_name';
468
+
469
+ /**
470
+ * Option key of twitter consumer key
471
+ */
472
+ const DB_FOLLOW_TWITTER_API_KEY = 'follow_twitter_consumer_key';
473
+
474
+ /**
475
+ * Option key of twitter consumer secret
476
+ */
477
+ const DB_FOLLOW_TWITTER_API_SECRET_KEY = 'follow_twitter_consumer_secret';
478
+
479
+ /**
480
+ * Option key of twitter bearer token
481
+ */
482
+ const DB_FOLLOW_TWITTER_BEARER_TOKEN = 'follow_twitter_bearer_token';
483
+
484
+ /**
485
+ * Option key of twitter access token
486
+ */
487
+ const DB_FOLLOW_TWITTER_ACCESS_TOKEN = 'follow_twitter_access_token';
488
+
489
+ /**
490
+ * Option key of twitter access token secret
491
+ */
492
+ const DB_FOLLOW_TWITTER_ACCESS_TOKEN_SECRET = 'follow_twitter_access_token_secret';
493
+
494
+ /**
495
+ * Option key of facebook page ID
496
+ */
497
+ const DB_FOLLOW_FACEBOOK_PAGE_ID = 'follow_facebook_page_id';
498
+
499
+ /**
500
+ * Option key of facebook app ID
501
+ */
502
+ const DB_FOLLOW_FACEBOOK_APP_ID = 'follow_facebook_app_id';
503
+
504
+ /**
505
+ * Option key of facebook app secret
506
+ */
507
+ const DB_FOLLOW_FACEBOOK_APP_SECRET = 'follow_facebook_app_secret';
508
+
509
+ /**
510
+ * Option key of facebook access token
511
+ */
512
+ const DB_FOLLOW_FACEBOOK_ACCESS_TOKEN = 'follow_facebook_access_token';
513
+
514
+ /**
515
+ * Option key of facebook app ID
516
+ */
517
+ const DB_SHARE_FACEBOOK_APP_ID = 'share_facebook_app_id';
518
+
519
+ /**
520
+ * Option key of facebook app secret
521
+ */
522
+ const DB_SHARE_FACEBOOK_APP_SECRET = 'share_facebook_app_secret';
523
+
524
+ /**
525
+ * Option key of facebook access token
526
+ */
527
+ const DB_SHARE_FACEBOOK_ACCESS_TOKEN = 'share_facebook_access_token';
528
+
529
+ /**
530
+ * Option key of push7 appno
531
+ */
532
+ const DB_FOLLOW_PUSH7_APP_NUMBER = 'follow_push7_appno';
533
+
534
+ /**
535
+ * Option key of instagram client id
536
+ */
537
+ const DB_FOLLOW_INSTAGRAM_CLIENT_ID = 'follow_instagram_client_id';
538
+
539
+ /**
540
+ * Option key of instagram client secret
541
+ */
542
+ const DB_FOLLOW_INSTAGRAM_CLIENT_SECRET = 'follow_instagram_client_secret';
543
+
544
+ /**
545
+ * Option key of instagram access token
546
+ */
547
+ const DB_FOLLOW_INSTAGRAM_ACCESS_TOKEN = 'follow_instagram_access_token';
548
+
549
+ /**
550
+ * Option key of onesignal user auth key
551
+ */
552
+ const DB_FOLLOW_ONESIGNAL_REST_API_KEY = 'follow_onesignal_user_auth_key';
553
+
554
+ /**
555
+ * Option key of onesignal app key
556
+ */
557
+ const DB_FOLLOW_ONESIGNAL_APP_ID = 'follow_onesignal_app_id';
558
+
559
+ /**
560
+ * Option key of app status
561
+ */
562
+ const DB_SHARE_APP_STATUS = 'scc_share_app_status';
563
+
564
+ /**
565
+ * Option key of setting
566
+ */
567
+ const DB_SETTINGS = 'scc_settings';
568
+
569
+ /**
570
+ * Slug of the plugin
571
+ */
572
+ const DOMAIN = 'sns-count-cache';
573
+
574
+ /**
575
+ * ID of share base cache
576
+ */
577
+ const REF_SHARE_BASE = 'share-base';
578
+
579
+ /**
580
+ * ID of share rush cache
581
+ */
582
+ const REF_SHARE_RUSH = 'share-rush';
583
+
584
+ /**
585
+ * ID of share lazy cache
586
+ */
587
+ const REF_SHARE_LAZY = 'share-lazy';
588
+
589
+ /**
590
+ * ID of share second cache
591
+ */
592
+ const REF_SHARE_2ND = 'share-second';
593
+
594
+ /**
595
+ * ID of share analysis cache
596
+ */
597
+ const REF_SHARE_ANALYSIS = 'share-analysis';
598
+
599
+ /**
600
+ * ID of share restore cache
601
+ */
602
+ const REF_SHARE_RESTORE = 'share-restore';
603
+
604
+ /**
605
+ * ID of follow base cache
606
+ */
607
+ const REF_FOLLOW_BASE = 'follow-base';
608
+
609
+ /**
610
+ * ID of follow lazy cache
611
+ */
612
+ const REF_FOLLOW_LAZY = 'follow-lazy';
613
+
614
+ /**
615
+ * ID of follow second cache
616
+ */
617
+ const REF_FOLLOW_2ND = 'follow-second';
618
+
619
+ /**
620
+ * ID of follow analysis cache
621
+ */
622
+ const REF_FOLLOW_ANALYSIS = 'follow-analysis';
623
+
624
+ /**
625
+ * ID of share restore cache
626
+ */
627
+ const REF_FOLLOW_RESTORE = 'follow-restore';
628
+
629
+ /**
630
+ * ID of common data export
631
+ */
632
+ const REF_COMMON_EXPORT = 'common-export';
633
+
634
+ /**
635
+ * ID of common data export
636
+ */
637
+ const REF_COMMON_CONTROL = 'common-control';
638
+
639
+ /**
640
+ * ID of share
641
+ */
642
+ const REF_SHARE = 'share';
643
+
644
+ /**
645
+ * ID of follow
646
+ */
647
+ const REF_FOLLOW = 'follow';
648
+
649
+ /**
650
+ * ID of share count (Twitter)
651
+ */
652
+ const REF_SHARE_TWITTER = 'Twitter';
653
+
654
+ /**
655
+ * ID of share count (Facebook)
656
+ */
657
+ const REF_SHARE_FACEBOOK = 'Facebook';
658
+
659
+ /**
660
+ * ID of share count (Google Plus)
661
+ */
662
+ const REF_SHARE_GPLUS = 'Google+';
663
+
664
+ /**
665
+ * ID of share count (Hatena Bookmark)
666
+ */
667
+ const REF_SHARE_HATEBU = 'Hatebu';
668
+
669
+ /**
670
+ * ID of share count (Pocket)
671
+ */
672
+ const REF_SHARE_POCKET = 'Pocket';
673
+
674
+ /**
675
+ * ID of share count (Pinterest)
676
+ */
677
+ const REF_SHARE_PINTEREST = 'Pinterest';
678
+
679
+ /**
680
+ * ID of share count (LinkedIn)
681
+ */
682
+ const REF_SHARE_LINKEDIN = 'Linkedin';
683
+
684
+ /**
685
+ * ID of share count (Total)
686
+ */
687
+ const REF_SHARE_TOTAL = 'Total';
688
+
689
+ /**
690
+ * ID of follow count (Feedly)
691
+ */
692
+ const REF_FOLLOW_FEEDLY = 'Feedly';
693
+
694
+ /**
695
+ * ID of follow count (Feedly)
696
+ */
697
+ const REF_FOLLOW_TWITTER = 'Twitter';
698
+
699
+ /**
700
+ * ID of follow count (Feedly)
701
+ */
702
+ const REF_FOLLOW_FACEBOOK = 'Facebook';
703
+
704
+ /**
705
+ * ID of follow count (Push7)
706
+ */
707
+ const REF_FOLLOW_PUSH7 = 'Push7';
708
+
709
+ /**
710
+ * ID of follow count (Instagram)
711
+ */
712
+ const REF_FOLLOW_INSTAGRAM = 'Instagram';
713
+
714
+ /**
715
+ * ID of follow count (OneSignal)
716
+ */
717
+ const REF_FOLLOW_ONESIGNAL = 'OneSignal';
718
+
719
+ /**
720
+ * ID of crawl date
721
+ */
722
+ const REF_CRAWL_DATE = 'CrawlDate';
723
+
724
+ /**
725
+ * Plugin version, used for cache-busting of style and script file references.
726
+ * @var string
727
+ */
728
+ private $version = '1.0.0';
729
+
730
+ /**
731
+ * Instances of crawler
732
+ * @var array
733
+ */
734
+ private $crawlers = array();
735
+
736
+ /**
737
+ * Instance of cache engine
738
+ * @var array
739
+ */
740
+ private $cache_engines = array();
741
+
742
+ /**
743
+ * Instance of export engine
744
+ * @var array
745
+ */
746
+ private $export_engines = array();
747
+
748
+ /**
749
+ * Instance of control engine
750
+ * @var array
751
+ */
752
+ private $control_engines = array();
753
+
754
+ /**
755
+ * Instance of analytical engine
756
+ * @var array
757
+ */
758
+ private $analytical_engines = array();
759
+
760
+ /**
761
+ * Instance of status engine
762
+ * @var array
763
+ */
764
+ private $status_engines = array();
765
+
766
+ /**
767
+ * Slug of the plugin screen
768
+ * @var array
769
+ */
770
+ private $plugin_screen_hook_suffix = array();
771
+
772
+ /**
773
+ * Cache target for share base cache
774
+ * @var array
775
+ */
776
+ private $share_base_cache_target = array();
777
+
778
+ /**
779
+ * Post types to be cached
780
+ * @var array
781
+ */
782
+ private $share_base_cache_post_types = array( 'post', 'page' );
783
+
784
+ /**
785
+ * Post types to be cached
786
+ * @var array
787
+ */
788
+ private $share_base_custom_post_types = array();
789
+
790
+ /**
791
+ * Check interval for share base cahce
792
+ *
793
+ * @var integer
794
+ */
795
+ private $share_base_check_interval = 600;
796
+
797
+ /**
798
+ * Post per check for share base cache
799
+ *
800
+ * @var integer
801
+ */
802
+ private $share_base_posts_per_check = 20;
803
+
804
+ /**
805
+ * Post per check for share base cache
806
+ *
807
+ * @var string
808
+ */
809
+ private $share_base_twitter_api = '';
810
+
811
+ /**
812
+ * Term considering content as new one
813
+ *
814
+ * @var integer
815
+ */
816
+ private $share_rush_new_content_term = 3;
817
+
818
+ /**
819
+ * Check interval for share rush cahce
820
+ *
821
+ * @var integer
822
+ */
823
+ private $share_rush_check_interval = 600;
824
+
825
+ /**
826
+ * Post per check for share rush cache
827
+ *
828
+ * @var integer
829
+ */
830
+ private $share_rush_posts_per_check = 20;
831
+
832
+ /**
833
+ * Facebook app ID
834
+ *
835
+ * @var string
836
+ */
837
+ private $share_facebook_app_id = '';
838
+
839
+ /**
840
+ * Facebook app ID
841
+ *
842
+ * @var string
843
+ */
844
+ private $share_facebook_app_secret = '';
845
+
846
+ /**
847
+ * Facebook access token
848
+ *
849
+ * @var string
850
+ */
851
+ private $share_facebook_access_token = '';
852
+
853
+ /**
854
+ * Cache target for follow base cache
855
+ *
856
+ * @var array
857
+ */
858
+ private $follow_base_cache_target = array();
859
+
860
+ /**
861
+ * Check interval for follow base cache
862
+ *
863
+ * @var integer
864
+ */
865
+ private $follow_base_check_interval = 1800;
866
+
867
+ /**
868
+ * Feed type to be followed
869
+ *
870
+ * @var string
871
+ */
872
+ private $follow_feed_type = '';
873
+
874
+ /**
875
+ * Twitter consumer key
876
+ *
877
+ * @var string
878
+ */
879
+ private $follow_twitter_api_key = '';
880
+
881
+ /**
882
+ * Twitter consumer secret
883
+ *
884
+ * @var string
885
+ */
886
+ private $follow_twitter_api_secret_key = '';
887
+
888
+ /**
889
+ * Twitter access token
890
+ *
891
+ * @var string
892
+ */
893
+ private $follow_twitter_access_token = '';
894
+
895
+ /**
896
+ * Twitter bearer token
897
+ *
898
+ * @var string
899
+ */
900
+ private $follow_twitter_bearer_token = '';
901
+
902
+ /**
903
+ * Twitter access token secret
904
+ *
905
+ * @var string
906
+ */
907
+ private $follow_twitter_access_token_secret = '';
908
+
909
+ /**
910
+ * Twitter screen name
911
+ *
912
+ * @var string
913
+ */
914
+ private $follow_twitter_screen_name = '';
915
+
916
+ /**
917
+ * Facebook page ID
918
+ *
919
+ * @var string
920
+ */
921
+ private $follow_facebook_page_id = '';
922
+
923
+ /**
924
+ * Facebook app ID
925
+ *
926
+ * @var string
927
+ */
928
+ private $follow_facebook_app_id = '';
929
+
930
+ /**
931
+ * Facebook app ID
932
+ *
933
+ * @var string
934
+ */
935
+ private $follow_facebook_app_secret = '';
936
+
937
+ /**
938
+ * Facebook access token
939
+ *
940
+ * @var string
941
+ */
942
+ private $follow_facebook_access_token = '';
943
+
944
+ /**
945
+ * Push7 appno
946
+ *
947
+ * @var integer
948
+ */
949
+ private $follow_push7_app_number = '';
950
+
951
+ /**
952
+ * Instagram client id
953
+ *
954
+ * @var string
955
+ */
956
+ private $follow_instagram_client_id = '';
957
+
958
+ /**
959
+ * Instagram client secret
960
+ *
961
+ * @var string
962
+ */
963
+ private $follow_instagram_client_secret = '';
964
+
965
+ /**
966
+ * Instagram access token
967
+ *
968
+ * @var string
969
+ */
970
+ private $follow_instagram_access_token = '';
971
+
972
+ /**
973
+ * OneSignal user auth key
974
+ *
975
+ * @var string
976
+ */
977
+ private $follow_onesignal_rest_api_key = '';
978
+
979
+ /**
980
+ * OneSignal user auth key
981
+ *
982
+ * @var string
983
+ */
984
+ private $follow_onesignal_app_id = '';
985
+
986
+ /**
987
+ * Dynamic cache mode
988
+ *
989
+ * @var integer
990
+ */
991
+ private $dynamic_cache_mode = 1;
992
+
993
+ /**
994
+ * Fault tolerance mode
995
+ *
996
+ * @var integer
997
+ */
998
+ private $fault_tolerance_mode = 1;
999
+
1000
+ /**
1001
+ * Data export mode
1002
+ *
1003
+ * @var integer
1004
+ */
1005
+ private $data_export_mode = 1;
1006
+
1007
+ /**
1008
+ * Data export schedule
1009
+ *
1010
+ * @var string
1011
+ */
1012
+ private $data_export_schedule = '0 0 * * *';
1013
+
1014
+ /**
1015
+ * Share variation analysis mode
1016
+ *
1017
+ * @var integer
1018
+ */
1019
+ private $share_variation_analysis_mode = 1;
1020
+
1021
+ /**
1022
+ * Share variation analysis schedule
1023
+ *
1024
+ * @var string
1025
+ */
1026
+ private $share_variation_analysis_schedule = '0 0 * * *';
1027
+
1028
+ /**
1029
+ * Follow variation analysis mode
1030
+ *
1031
+ * @var integer
1032
+ */
1033
+ private $follow_variation_analysis_mode = 1;
1034
+
1035
+ /**
1036
+ * Follow variation analysis schedule
1037
+ *
1038
+ * @var string
1039
+ */
1040
+ private $follow_variation_analysis_schedule = '0 0 * * *';
1041
+
1042
+ /**
1043
+ * Migration mode from http to https
1044
+ *
1045
+ * @var boolean
1046
+ */
1047
+ private $scheme_migration_mode = false;
1048
+
1049
+ /**
1050
+ * Migration date from http to https
1051
+ *
1052
+ * @var string
1053
+ */
1054
+ private $scheme_migration_date = null;
1055
+
1056
+ /**
1057
+ * Excluded key in migration from http to https
1058
+ *
1059
+ * @var array
1060
+ */
1061
+ private $scheme_migration_exclude_keys = array();
1062
+
1063
+ /**
1064
+ * Max execution time
1065
+ *
1066
+ * @var integer
1067
+ */
1068
+ private $original_max_execution_time = 0;
1069
+
1070
+ /**
1071
+ * Extended max execution time
1072
+ *
1073
+ * @var integer
1074
+ */
1075
+ private $extended_max_execution_time = 600;
1076
+
1077
+ /**
1078
+ * URL of loading image
1079
+ *
1080
+ * @var string
1081
+ */
1082
+ private $loading_img_url = '';
1083
+
1084
+ /**
1085
+ * ajax action
1086
+ *
1087
+ * @var string
1088
+ */
1089
+ private $ajax_action = 'scc_cache_info';
1090
+
1091
+ /**
1092
+ * Cralwer method
1093
+ *
1094
+ * @var integer
1095
+ */
1096
+ private $crawler_method = 1;
1097
+
1098
+ /**
1099
+ * Cralwer method
1100
+ *
1101
+ * @var integer
1102
+ */
1103
+ private $crawler_retry_limit = 1;
1104
+
1105
+ /**
1106
+ * Cralwer SSL verification
1107
+ *
1108
+ * @var boolean
1109
+ */
1110
+ private $crawler_ssl_verification = true;
1111
+
1112
+ /**
1113
+ * Instance
1114
+ *
1115
+ * @var SNS_Count_Cache
1116
+ */
1117
+ private static $instance = null;
1118
+
1119
+ /**
1120
+ * Class constarctor
1121
+ * Hook onto all of the actions and filters needed by the plugin.
1122
+ */
1123
+ private function __construct() {
1124
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
1125
+
1126
+ load_plugin_textdomain( self::DOMAIN, false, basename( dirname( __FILE__ ) ) . '/languages' );
1127
+
1128
+ add_action( 'init', array( $this, 'initialize' ) );
1129
+
1130
+ register_activation_hook( __FILE__, array( $this, 'activate_plugin' ) );
1131
+ register_deactivation_hook( __FILE__, array( $this, 'deactivate_plugin' ) );
1132
+
1133
+ add_action( 'admin_menu', array( $this, 'register_admin_menu' ) );
1134
+ add_action( 'admin_print_styles', array( $this, 'register_admin_styles' ) );
1135
+ add_action( 'admin_enqueue_scripts', array( $this, 'register_admin_scripts' ) );
1136
+ // add_action( 'admin_notices', array( $this, 'notice_page' ) );
1137
+ add_action( 'wp_ajax_' . $this->ajax_action, array( $this, 'get_cache_info' ) );
1138
+ add_action( 'wp_dashboard_setup', array( $this, 'add_wp_dashboard_widget' ) );
1139
+ add_action( 'deleted_post' , array( $this, 'clear_cache_deleted_post' ) );
1140
+
1141
+ add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_plugin_action_links' ), 10, 4 );
1142
+ }
1143
+
1144
+ /**
1145
+ * Get instance
1146
+ *
1147
+ * @return SNS_Count_Cache
1148
+ */
1149
+ public static function get_instance() {
1150
+
1151
+ if ( ! isset( self::$instance ) ) {
1152
+ self::$instance = new self;
1153
+ }
1154
 
1155
+ return self::$instance;
1156
+ }
 
 
 
 
1157
 
1158
+ /**
1159
+ * Get object ID
1160
+ *
1161
+ * @return string
1162
+ */
1163
+ public function get_object_id() {
1164
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
1165
 
1166
+ $object_id = spl_object_hash( $this );
 
1167
 
1168
+ SCC_Logger::log( '[' . __METHOD__ . '] object ID: ' . $object_id );
1169
 
1170
+ return $object_id;
1171
+ }
 
1172
 
1173
+ /**
1174
+ * Inhibit clone processing
1175
+ *
1176
+ * @return void
1177
+ * @throws Exception Clone is not allowed against.
1178
+ */
1179
+ final public function __clone() {
1180
+ throw new Exception( 'Clone is not allowed against' . get_class( $this ) );
1181
+ }
1182
 
1183
+ /**
1184
+ * Initialization
1185
+ *
1186
+ * @return void
1187
+ */
1188
+ public function initialize() {
1189
+ SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
1190
 
1191
+ $settings = get_option( self::DB_SETTINGS );
 
 
 
 
 
 
1192
 
1193
+ if ( ! empty( $settings[ self::DB_SHARE_BASE_CHECK_INTERVAL ] ) ) {
1194
+ $this->share_base_check_interval = (int) $settings[ self::DB_SHARE_BASE_CHECK_INTERVAL ];
1195
+ } else {
1196
+ $this->share_base_check_interval = self::OPT_SHARE_BASE_CHECK_INTERVAL;
1197
+ }
1198
 
1199
+ if ( ! empty( $settings[ self::DB_SHARE_BASE_POSTS_PER_CHECK ] ) ) {
1200
+ $this->share_base_posts_per_check = (int) $settings[ self::DB_SHARE_BASE_POSTS_PER_CHECK ];
1201
+ } else {
1202
+ $this->share_base_posts_per_check = self::OPT_SHARE_BASE_POSTS_PER_CHECK;
1203
+ }
1204
 
1205
+ if ( ! empty( $settings[ self::DB_FOLLOW_CHECK_INTERVAL ] ) ) {
1206
+ $this->follow_base_check_interval = (int) $settings[ self::DB_FOLLOW_CHECK_INTERVAL ];
1207
+ if ( $this->follow_base_check_interval < self::OPT_FOLLOW_BASE_CHECK_INTERVAL_MIN ) {
1208
+ $this->follow_base_check_interval = self::OPT_FOLLOW_BASE_CHECK_INTERVAL_MIN;
1209
+ }
1210
+ } else {
1211
+ $this->follow_base_check_interval = self::OPT_FOLLOW_BASE_CHECK_INTERVAL;
1212
+ }
1213
 
1214
+ if ( ! empty( $settings[ self::DB_COMMON_DYNAMIC_CACHE_MODE ] ) ) {
1215
+ $this->dynamic_cache_mode = (int) $settings[ self::DB_COMMON_DYNAMIC_CACHE_MODE ];
1216
+ } else {
1217
+ $this->dynamic_cache_mode = self::OPT_COMMON_ACCESS_BASED_CACHE_OFF;
1218
+ }
1219
 
1220
+ if ( ! empty( $settings[ self::DB_COMMON_FAULT_TOLERANCE_MODE ] ) ) {
1221
+ $this->fault_tolerance_mode = (int) $settings[ self::DB_COMMON_FAULT_TOLERANCE_MODE ];
1222
+ } else {
1223
+ $this->fault_tolerance_mode = self::OPT_COMMON_FAULT_TOLERANCE_OFF;
1224
+ }
1225
 
1226
+ if ( ! empty( $settings[ self::DB_SHARE_RUSH_CHECK_INTERVAL ] ) ) {
1227
+ $this->share_rush_check_interval = (int) $settings[ self::DB_SHARE_RUSH_CHECK_INTERVAL ];
1228
+ } else {
1229
+ $this->share_rush_check_interval = self::OPT_SHARE_RUSH_CHECK_INTERVAL;
1230
+ }
1231
 
1232
+ if ( ! empty( $settings[ self::DB_SHARE_RUSH_POSTS_PER_CHECK ] ) ) {
1233
+ $this->share_rush_posts_per_check = (int) $settings[ self::DB_SHARE_RUSH_POSTS_PER_CHECK ];
1234
+ } else {
1235
+ $this->share_rush_posts_per_check = self::OPT_SHARE_RUSH_POSTS_PER_CHECK;
1236
+ }
1237
 
1238
+ if ( ! empty( $settings[ self::DB_SHARE_RUSH_NEW_CONTENT_TERM ] ) ) {
1239
+ $this->share_rush_new_content_term = (int) $settings[ self::DB_SHARE_RUSH_NEW_CONTENT_TERM ];
1240
+ } else {
1241
+ $this->share_rush_new_content_term = self::OPT_SHARE_RUSH_NEW_CONTENT_TERM;
1242
+ }
1243
 
1244
+ if ( ! empty( $settings[ self::DB_COMMON_DATA_EXPORT_MODE ] ) ) {
1245
+ $this->data_export_mode = (int) $settings[ self::DB_COMMON_DATA_EXPORT_MODE ];
1246
+ } else {
1247
+ $this->data_export_mode = self::OPT_COMMON_DATA_EXPORT_MANUAL;
1248
+ }
1249
 
1250
+ if ( ! empty( $settings[ self::DB_COMMON_DATA_EXPORT_SCHEDULE ] ) ) {
1251
+ $this->data_export_schedule = $settings[ self::DB_COMMON_DATA_EXPORT_SCHEDULE ];
1252
+ } else {
1253
+ $this->data_export_schedule = self::OPT_COMMON_DATA_EXPORT_SCHEDULE;
1254
+ }
1255
 
1256
+ if ( ! empty( $settings[ self::DB_SHARE_VARIATION_ANALYSIS_MODE ] ) ) {
1257
+ $this->share_variation_analysis_mode = (int) $settings[ self::DB_SHARE_VARIATION_ANALYSIS_MODE ];
1258
+ } else {
1259
+ $this->share_variation_analysis_mode = self::OPT_SHARE_VARIATION_ANALYSIS_NONE;
1260
+ }
1261
 
1262
+ if ( ! empty( $settings[ self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE ] ) ) {
1263
+ $this->share_variation_analysis_schedule = $settings[ self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE ];
1264
+ } else {
1265
+ $this->share_variation_analysis_schedule = self::OPT_SHARE_VARIATION_ANALYSIS_SCHEDULE;
1266
+ }
1267
 
1268
+ if ( ! empty( $settings[ self::DB_FOLLOW_VARIATION_ANALYSIS_MODE ] ) ) {
1269
+ $this->follow_variation_analysis_mode = (int) $settings[ self::DB_FOLLOW_VARIATION_ANALYSIS_MODE ];
1270
+ } else {
1271
+ $this->follow_variation_analysis_mode = self::OPT_FOLLOW_VARIATION_ANALYSIS_NONE;
1272
+ }
1273
 
1274
+ if ( isset( $settings[ self::DB_FOLLOW_VARIATION_ANALYSIS_SCHEDULE ] ) ) {
1275
+ $this->follow_variation_analysis_schedule = $settings[ self::DB_FOLLOW_VARIATION_ANALYSIS_SCHEDULE ];
1276
+ } else {
1277
+ $this->follow_variation_analysis_schedule = self::OPT_FOLLOW_VARIATION_ANALYSIS_SCHEDULE;
1278
+ }
1279
 
1280
+ if ( isset( $settings[ self::DB_COMMON_SCHEME_MIGRATION_MODE ] ) ) {
1281
+ $this->scheme_migration_mode = $settings[ self::DB_COMMON_SCHEME_MIGRATION_MODE ];
1282
+ } else {
1283
+ $this->scheme_migration_mode = self::OPT_COMMON_SCHEME_MIGRATION_MODE_OFF;
1284
+ }
1285
 
1286
+ if ( isset( $settings[ self::DB_COMMON_SCHEME_MIGRATION_DATE ] ) ) {
1287
+ $this->scheme_migration_date = $settings[ self::DB_COMMON_SCHEME_MIGRATION_DATE ];
1288
+ }
 
1289
 
1290
+ if ( ! empty( $settings[ self::DB_SHARE_CACHE_TARGET ] ) ) {
1291
+ $this->share_base_cache_target = $settings[ self::DB_SHARE_CACHE_TARGET ];
1292
+ } else {
1293
+ $this->share_base_cache_target[ self::REF_SHARE_FACEBOOK ] = true;
1294
+ $this->share_base_cache_target[ self::REF_SHARE_POCKET ] = true;
1295
+ $this->share_base_cache_target[ self::REF_SHARE_HATEBU ] = true;
1296
+ }
1297
 
1298
+ // Exclude Google+ count retrieval because +1 count is no longer supplied.
1299
+ $this->share_base_cache_target[ self::REF_SHARE_GPLUS ] = false;
1300
+ $this->share_base_cache_target[ self::REF_CRAWL_DATE ] = true;
1301
+ $this->share_base_cache_target[ self::REF_SHARE_TOTAL ] = true;
1302
 
1303
+ if ( ! empty( $settings[ self::DB_SHARE_BASE_TWITTER_API ] ) ) {
1304
+ $this->share_base_twitter_api = (int) $settings[ self::DB_SHARE_BASE_TWITTER_API ];
1305
+ } else {
1306
+ $this->share_base_twitter_api = self::OPT_SHARE_TWITTER_API_JSOON;
1307
+ }
1308
 
1309
+ // Pocket and Google+, Linkedin are excluded from migration target because they are migrated automatically.
1310
+ $this->scheme_migration_exclude_keys = array(
1311
+ self::REF_SHARE_POCKET,
1312
+ self::REF_SHARE_GPLUS,
1313
+ self::REF_SHARE_LINKEDIN,
1314
+ self::REF_FOLLOW_TWITTER,
1315
+ self::REF_FOLLOW_FACEBOOK,
1316
+ self::REF_FOLLOW_PUSH7,
1317
+ self::REF_FOLLOW_INSTAGRAM,
1318
+ self::REF_FOLLOW_ONESIGNAL,
1319
+ );
1320
 
1321
+ if ( self::OPT_SHARE_TWITTER_API_JSOON === $this->share_base_twitter_api ) {
1322
+ $this->scheme_migration_exclude_keys[] = self::REF_SHARE_TWITTER;
1323
+ }
 
1324
 
1325
+ if ( ! empty( $settings[ self::DB_FOLLOW_CACHE_TARGET ] ) ) {
1326
+ $this->follow_base_cache_target = $settings[ self::DB_FOLLOW_CACHE_TARGET ];
1327
+ } else {
1328
+ $this->follow_base_cache_target[ self::REF_FOLLOW_FEEDLY ] = true;
1329
+ }
1330
 
1331
+ $this->follow_base_cache_target[ self::REF_CRAWL_DATE ] = true;
 
 
 
1332
 
1333
+ if ( ! empty( $settings[ self::DB_FOLLOW_FEED_TYPE ] ) ) {
1334
+ $this->follow_feed_type = $settings[ self::DB_FOLLOW_FEED_TYPE ];
1335
+ } else {
1336
+ $this->follow_feed_type = self::OPT_FEED_TYPE_DEFAULT;
1337
+ }
1338
 
1339
+ if ( ! empty( $settings[ self::DB_SHARE_CUSTOM_POST_TYPES ] ) ) {
1340
+ $this->share_base_custom_post_types = $settings[ self::DB_SHARE_CUSTOM_POST_TYPES ];
1341
+ } else {
1342
+ $this->share_base_custom_post_types = array();
1343
+ }
1344
 
1345
+ $this->share_base_cache_post_types = array_merge( $this->share_base_cache_post_types, $this->share_base_custom_post_types );
 
 
 
1346
 
1347
+ if ( extension_loaded( 'curl' ) ) {
1348
+ $this->crawler_method = self::OPT_COMMON_CRAWLER_METHOD_CURL;
1349
+ } else {
1350
+ $this->crawler_method = self::OPT_COMMON_CRAWLER_METHOD_NORMAL;
1351
+ }
1352
 
1353
+ if ( ! empty( $settings[ self::DB_COMMON_CRAWLER_SSL_VERIFICATION ] ) ) {
1354
+ $this->crawler_ssl_verification = $settings[ self::DB_COMMON_CRAWLER_SSL_VERIFICATION ];
1355
+ } else {
1356
+ $this->crawler_ssl_verification = self::OPT_COMMON_CRAWLER_SSL_VERIFY_ON;
1357
+ }
1358
 
1359
+ if ( ! empty( $settings[ self::DB_COMMON_CRAWLER_RETRY_LIMIT ] ) ) {
1360
+ $this->crawler_retry_limit = (int) $settings[ self::DB_COMMON_CRAWLER_RETRY_LIMIT ];
1361
+ } else {
1362
+ $this->crawler_retry_limit = self::OPT_COMMON_CRAWLER_RETRY_LIMIT;
1363
+ }
1364
 
1365
+ if ( ! empty( $settings[ self::DB_FOLLOW_TWITTER_SCREEN_NAME ] ) ) {
1366
+ $this->follow_twitter_screen_name = $settings[ self::DB_FOLLOW_TWITTER_SCREEN_NAME ];
1367
+ }
 
1368
 
1369
+ if ( ! empty( $settings[ self::DB_FOLLOW_TWITTER_API_KEY ] ) ) {
1370
+ $this->follow_twitter_api_key = trim( SCC_Crypt::decrypt( $settings[ self::DB_FOLLOW_TWITTER_API_KEY ], AUTH_KEY ) );
1371
+ }
 
1372
 
1373
+ if ( ! empty( $settings[ self::DB_FOLLOW_TWITTER_API_SECRET_KEY ] ) ) {
1374
+ $this->follow_twitter_api_secret_key = trim( SCC_Crypt::decrypt( $settings[ self::DB_FOLLOW_TWITTER_API_SECRET_KEY ], AUTH_KEY ) );
1375
+ }
 
1376
 
1377
+ if ( ! empty( $settings[ self::DB_FOLLOW_TWITTER_BEARER_TOKEN ] ) ) {
1378
+ $this->follow_twitter_bearer_token = trim( SCC_Crypt::decrypt( $settings[ self::DB_FOLLOW_TWITTER_BEARER_TOKEN ], AUTH_KEY ) );
1379
+ }
 
1380
 
1381
+ /*
1382
+ if ( isset( $settings[self::DB_FOLLOW_TWITTER_ACCESS_TOKEN] ) && $settings[self::DB_FOLLOW_TWITTER_ACCESS_TOKEN] ) {
1383
+ $this->follow_twitter_access_token = trim( SCC_Crypt::decrypt( $settings[self::DB_FOLLOW_TWITTER_ACCESS_TOKEN], AUTH_KEY ) );
1384
+ }
1385
 
1386
+ if ( isset( $settings[self::DB_FOLLOW_TWITTER_ACCESS_TOKEN_SECRET] ) && $settings[self::DB_FOLLOW_TWITTER_ACCESS_TOKEN_SECRET] ) {
1387
+ $this->follow_twitter_access_token_secret = trim( SCC_Crypt::decrypt( $settings[self::DB_FOLLOW_TWITTER_ACCESS_TOKEN_SECRET], AUTH_KEY ) );
1388
+ }
1389
+ */
1390
 
1391
+ if ( ! empty( $settings[ self::DB_SHARE_FACEBOOK_APP_ID ] ) ) {
1392
+ $this->share_facebook_app_id = trim( SCC_Crypt::decrypt( $settings[ self::DB_SHARE_FACEBOOK_APP_ID ], AUTH_KEY ) );
1393
+ }
 
1394
 
1395
+ if ( ! empty( $settings[ self::DB_SHARE_FACEBOOK_APP_SECRET ] ) ) {
1396
+ $this->share_facebook_app_secret = trim( SCC_Crypt::decrypt( $settings[ self::DB_SHARE_FACEBOOK_APP_SECRET ], AUTH_KEY ) );
1397
+ }
 
1398
 
1399
+ if ( ! empty( $this->share_facebook_app_id ) && ! empty( $this->share_facebook_app_secret ) ) {
1400
+ $this->share_facebook_access_token = $this->share_facebook_app_id . '|' . $this->share_facebook_app_secret;
1401
+ } else {
1402
+ $this->share_facebook_access_token = '';
1403
+ }
1404
 
1405
+ if ( ! empty( $settings[ self::DB_FOLLOW_FACEBOOK_PAGE_ID ] ) ) {
1406
+ $this->follow_facebook_page_id = $settings[ self::DB_FOLLOW_FACEBOOK_PAGE_ID ];
1407
+ }
 
1408
 
1409
+ if ( ! empty( $settings[ self::DB_FOLLOW_FACEBOOK_APP_ID ] ) ) {
1410
+ $this->follow_facebook_app_id = trim( SCC_Crypt::decrypt( $settings[ self::DB_FOLLOW_FACEBOOK_APP_ID ], AUTH_KEY ) );
1411
+ }
 
1412
 
1413
+ if ( ! empty( $settings[ self::DB_FOLLOW_FACEBOOK_APP_SECRET ] ) ) {
1414
+ $this->follow_facebook_app_secret = trim( SCC_Crypt::decrypt( $settings[ self::DB_FOLLOW_FACEBOOK_APP_SECRET ], AUTH_KEY ) );
1415
+ }
 
1416
 
1417
+ if ( ! empty( $settings[ self::DB_FOLLOW_FACEBOOK_ACCESS_TOKEN ] ) ) {
1418
+ $this->follow_facebook_access_token = trim( SCC_Crypt::decrypt( $settings[ self::DB_FOLLOW_FACEBOOK_ACCESS_TOKEN ], AUTH_KEY ) );
1419
+ }
 
1420
 
1421
+ if ( ! empty( $settings[ self::DB_FOLLOW_PUSH7_APP_NUMBER ] ) ) {
1422
+ $this->follow_push7_app_number = trim( SCC_Crypt::decrypt( $settings[ self::DB_FOLLOW_PUSH7_APP_NUMBER ], AUTH_KEY ) );
1423
+ }
 
1424
 
1425
+ if ( ! empty( $settings[ self::DB_FOLLOW_INSTAGRAM_CLIENT_ID ] ) ) {
1426
+ $this->follow_instagram_client_id = trim( SCC_Crypt::decrypt( $settings[ self::DB_FOLLOW_INSTAGRAM_CLIENT_ID ], AUTH_KEY ) );
1427
+ }
 
1428
 
1429
+ if ( ! empty( $settings[ self::DB_FOLLOW_INSTAGRAM_CLIENT_SECRET ] ) ) {
1430
+ $this->follow_instagram_client_secret = trim( SCC_Crypt::decrypt( $settings[ self::DB_FOLLOW_INSTAGRAM_CLIENT_SECRET ], AUTH_KEY ) );
1431
+ }
 
1432
 
1433
+ if ( ! empty( $settings[ self::DB_FOLLOW_INSTAGRAM_ACCESS_TOKEN ] ) ) {
1434
+ $this->follow_instagram_access_token = trim( SCC_Crypt::decrypt( $settings[ self::DB_FOLLOW_INSTAGRAM_ACCESS_TOKEN ], AUTH_KEY ) );
1435
+ }
 
1436
 
1437
+ if ( ! empty( $settings[ self::DB_FOLLOW_ONESIGNAL_APP_ID ] ) ) {
1438
+ $this->follow_onesignal_app_id = trim( SCC_Crypt::decrypt( $settings[ self::DB_FOLLOW_ONESIGNAL_APP_ID ], AUTH_KEY ) );
1439
+ }
 
1440
 
1441
+ if ( ! empty( $settings[ self::DB_FOLLOW_ONESIGNAL_REST_API_KEY ] ) ) {
1442
+ $this->follow_onesignal_rest_api_key = trim( SCC_Crypt::decrypt( $settings[ self::DB_FOLLOW_ONESIGNAL_REST_API_KEY ], AUTH_KEY ) );
1443
+ }
 
1444
 
1445
+ // Share Crawler
1446
+ $options = array(
1447
+ 'target_sns' => $this->share_base_cache_target,
1448
+ 'crawl_method' => $this->crawler_method,
1449
+ 'timeout' => self::OPT_COMMON_CRAWLER_TIMEOUT,
1450
+ 'retry_limit' => $this->crawler_retry_limit,
1451
+ 'ssl_verification' => $this->crawler_ssl_verification,
1452
+ );
1453
 
1454
+ $this->crawlers[ self::REF_SHARE ] = SCC_Share_Crawler::get_instance();
1455
+ $this->crawlers[ self::REF_SHARE ]->initialize( $options );
 
 
1456
 
1457
+ // Share Twitter Crawl Strategy
1458
+ if ( ! empty( $this->share_base_cache_target[ self::REF_SHARE_TWITTER ] ) ) {
1459
+ $options = array(
1460
+ 'twitter_api' => $this->share_base_twitter_api,
1461
+ );
1462
 
1463
+ $this->crawlers[ self::REF_SHARE ]->initialize_crawl_strategy( self::REF_SHARE_TWITTER, $options );
1464
+ }
 
 
1465
 
1466
+ // Share Facebook Crawl Strategy
1467
+ if ( ! empty( $this->share_base_cache_target[ self::REF_SHARE_FACEBOOK ] ) ) {
1468
+ $parameters = array(
1469
+ 'app_id' => $this->share_facebook_app_id,
1470
+ 'app_secret' => $this->share_facebook_app_secret,
1471
+ 'access_token' => $this->share_facebook_access_token,
1472
+ );
1473
 
1474
+ $this->crawlers[ self::REF_SHARE ]->set_crawl_strategy_parameters( self::REF_SHARE_FACEBOOK, $parameters );
1475
+ }
 
 
1476
 
1477
+ // Follow Crawler
1478
+ $options = array(
1479
+ 'target_sns' => $this->follow_base_cache_target,
1480
+ 'crawl_method' => $this->crawler_method,
1481
+ 'timeout' => self::OPT_COMMON_CRAWLER_TIMEOUT,
1482
+ 'retry_limit' => $this->crawler_retry_limit,
1483
+ 'ssl_verification' => $this->crawler_ssl_verification,
1484
+ );
1485
 
1486
+ $this->crawlers[ self::REF_FOLLOW ] = SCC_Follow_Crawler::get_instance();
1487
+ $this->crawlers[ self::REF_FOLLOW ]->initialize( $options );
 
 
1488
 
1489
+ // Follow Twitter Crawl Strategy
1490
+ if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_TWITTER ] ) ) {
1491
+ /*
1492
+ $query_parameters = array(
1493
+ 'screen_name' => $this->follow_twitter_screen_name
1494
+ );
1495
+ */
1496
+
1497
+ /*
1498
+ // version using user auth
1499
+ $parameters = array(
1500
+ 'consumer_key' => $this->follow_twitter_api_key,
1501
+ 'consumer_secret' => $this->follow_twitter_api_secret_key,
1502
+ 'access_token' => $this->follow_twitter_access_token,
1503
+ 'access_token_secret' => $this->follow_twitter_access_token_secret
1504
+ );
1505
+ */
1506
+
1507
+ // version using application-only auth
1508
+ $parameters = array(
1509
+ 'screen_name' => $this->follow_twitter_screen_name,
1510
+ 'api_key' => $this->follow_twitter_api_key,
1511
+ 'api_secret_key' => $this->follow_twitter_api_secret_key,
1512
+ 'bearer_token' => $this->follow_twitter_bearer_token,
1513
+ );
1514
+
1515
+ $this->crawlers[ self::REF_FOLLOW ]->set_crawl_strategy_parameters( self::REF_FOLLOW_TWITTER, $parameters );
1516
+ }
1517
 
1518
+ // Follow Feedly Crawl Strategy
1519
+ if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_FEEDLY ] ) ) {
1520
+ $parameters = array(
1521
+ 'url' => get_feed_link( $this->follow_feed_type ),
1522
+ );
1523
 
1524
+ $this->crawlers[ self::REF_FOLLOW ]->set_crawl_strategy_parameters( self::REF_FOLLOW_FEEDLY, $parameters );
1525
+ }
 
 
1526
 
1527
+ // Follow Facebook Crawl Strategy
1528
+ if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_FACEBOOK ] ) ) {
 
 
1529
 
1530
+ $parameters = array(
1531
+ 'access_token' => $this->follow_facebook_access_token,
1532
+ 'page_id' => $this->follow_facebook_page_id,
1533
+ 'client_id' => $this->follow_facebook_app_id,
1534
+ 'client_secret' => $this->follow_facebook_app_secret,
1535
+ );
1536
 
1537
+ $this->crawlers[ self::REF_FOLLOW ]->set_crawl_strategy_parameters( self::REF_FOLLOW_FACEBOOK, $parameters );
1538
+ }
 
 
1539
 
1540
+ // Follow Push7 Crawl Strategy
1541
+ if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_PUSH7 ] ) ) {
1542
+ $parameters = array(
1543
+ 'app_number' => $this->follow_push7_app_number,
1544
+ );
1545
 
1546
+ $this->crawlers[ self::REF_FOLLOW ]->set_crawl_strategy_parameters( self::REF_FOLLOW_PUSH7, $parameters );
1547
+ }
 
 
1548
 
1549
+ // Follow Instagram Crawl Strategy
1550
+ if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_INSTAGRAM ] ) ) {
 
 
1551
 
1552
+ $parameters = array(
1553
+ 'access_token' => $this->follow_instagram_access_token,
1554
+ 'client_id' => $this->follow_instagram_client_id,
1555
+ 'client_secret' => $this->follow_instagram_client_secret,
1556
+ );
1557
 
1558
+ $this->crawlers[ self::REF_FOLLOW ]->set_crawl_strategy_parameters( self::REF_FOLLOW_INSTAGRAM, $parameters );
1559
+ }
 
 
1560
 
1561
+ // Follow OneSignal Crawl Strategy
1562
+ if ( ! empty( $this->follow_base_cache_target[ self::REF_FOLLOW_ONESIGNAL ] ) ) {
1563
+ $parameters = array(
1564
+ 'app_id' => $this->follow_onesignal_app_id,
1565
+ 'rest_api_key' => $this->follow_onesignal_rest_api_key,
1566
+ );
1567
 
1568
+ $this->crawlers[ self::REF_FOLLOW ]->set_crawl_strategy_parameters( self::REF_FOLLOW_ONESIGNAL, $parameters );
1569
+ }
 
 
1570
 
1571
+ // Share base cache engine
1572
+ $options = array(
1573
+ 'delegate' => $this,
1574
+ 'crawler' => $this->crawlers[ self::REF_SHARE ],
1575
+ 'target_sns' => $this->share_base_cache_target,
1576
+ 'check_interval' => $this->share_base_check_interval,
1577
+ 'posts_per_check' => $this->share_base_posts_per_check,
1578
+ 'post_types' => $this->share_base_cache_post_types,
1579
+ 'scheme_migration_mode' => $this->scheme_migration_mode,
1580
+ 'scheme_migration_date' => $this->scheme_migration_date,
1581
+ 'scheme_migration_exclude_keys' => $this->scheme_migration_exclude_keys,
1582
+ 'fault_tolerance' => $this->fault_tolerance_mode,
1583
+ );
1584
 
1585
+ $this->cache_engines[ self::REF_SHARE_BASE ] = SCC_Share_Base_Cache_Engine::get_instance();
1586
+ $this->cache_engines[ self::REF_SHARE_BASE ]->initialize( $options );
1587
+
1588
+ // Share rush cache engine
1589
+ $options = array(
1590
+ 'delegate' => $this,
1591
+ 'crawler' => $this->crawlers[ self::REF_SHARE ],
1592
+ 'target_sns' => $this->share_base_cache_target,
1593
+ 'check_interval' => $this->share_rush_check_interval,
1594
+ 'posts_per_check' => $this->share_rush_posts_per_check,
1595
+ 'new_content_term' => $this->share_rush_new_content_term,
1596
+ 'post_types' => $this->share_base_cache_post_types,
1597
+ 'scheme_migration_mode' => $this->scheme_migration_mode,
1598
+ 'scheme_migration_date' => $this->scheme_migration_date,
1599
+ 'scheme_migration_exclude_keys' => $this->scheme_migration_exclude_keys,
1600
+ 'fault_tolerance' => $this->fault_tolerance_mode,
1601
+ );
1602
 
1603
+ $this->cache_engines[ self::REF_SHARE_RUSH ] = SCC_Share_Rush_Cache_Engine::get_instance();
1604
+ $this->cache_engines[ self::REF_SHARE_RUSH ]->initialize( $options );
1605
+
1606
+ // Share lazy cache engine
1607
+ $options = array(
1608
+ 'delegate' => $this,
1609
+ 'crawler' => $this->crawlers[ self::REF_SHARE ],
1610
+ 'target_sns' => $this->share_base_cache_target,
1611
+ 'check_interval' => $this->share_base_check_interval,
1612
+ 'posts_per_check' => $this->share_base_posts_per_check,
1613
+ 'post_types' => $this->share_base_cache_post_types,
1614
+ 'scheme_migration_mode' => $this->scheme_migration_mode,
1615
+ 'scheme_migration_date' => $this->scheme_migration_date,
1616
+ 'scheme_migration_exclude_keys' => $this->scheme_migration_exclude_keys,
1617
+ 'fault_tolerance' => $this->fault_tolerance_mode,
1618
+ );
1619
 
1620
+ $this->cache_engines[ self::REF_SHARE_LAZY ] = SCC_Share_Lazy_Cache_Engine::get_instance();
1621
+ $this->cache_engines[ self::REF_SHARE_LAZY ]->initialize( $options );
1622
+
1623
+ // Share second cache engine
1624
+ $options = array(
1625
+ 'delegate' => $this,
1626
+ 'target_sns' => $this->share_base_cache_target,
1627
+ 'check_interval' => self::OPT_SHARE_2ND_CHECK_INTERVAL,
1628
+ 'post_types' => $this->share_base_cache_post_types,
1629
+ 'cache_prefix' => self::OPT_SHARE_2ND_META_KEY_PREFIX,
1630
+ 'crawl_date_key' => self::REF_CRAWL_DATE,
1631
+ );
1632
 
1633
+ $this->cache_engines[ self::REF_SHARE_2ND ] = SCC_Share_Second_Cache_Engine::get_instance();
1634
+ $this->cache_engines[ self::REF_SHARE_2ND ]->initialize( $options );
 
 
1635
 
1636
+ // Share restore cache engine
1637
+ $options = array(
1638
+ 'target_sns' => $this->share_base_cache_target,
1639
+ 'check_interval' => $this->share_base_check_interval,
1640
+ 'posts_per_check' => $this->share_base_posts_per_check,
1641
+ 'post_types' => $this->share_base_cache_post_types,
1642
+ );
1643
 
1644
+ $this->cache_engines[ self::REF_SHARE_RESTORE ] = SCC_Share_Restore_Cache_Engine::get_instance();
1645
+ $this->cache_engines[ self::REF_SHARE_RESTORE ]->initialize( $options );
1646
+
1647
+ // Follow base cache engine
1648
+ $options = array(
1649
+ 'delegate' => $this,
1650
+ 'crawler' => $this->crawlers[ self::REF_FOLLOW ],
1651
+ 'target_sns' => $this->follow_base_cache_target,
1652
+ 'check_interval' => $this->follow_base_check_interval,
1653
+ 'scheme_migration_mode' => $this->scheme_migration_mode,
1654
+ 'scheme_migration_exclude_keys' => $this->scheme_migration_exclude_keys,
1655
+ 'feed_type' => $this->follow_feed_type,
1656
+ );
1657
 
1658
+ $this->cache_engines[ self::REF_FOLLOW_BASE ] = SCC_Follow_Base_Cache_Engine::get_instance();
1659
+ $this->cache_engines[ self::REF_FOLLOW_BASE ]->initialize( $options );
1660
+
1661
+ // Follow lazy cache engine
1662
+ $options = array(
1663
+ 'delegate' => $this,
1664
+ 'crawler' => $this->crawlers[ self::REF_FOLLOW ],
1665
+ 'target_sns' => $this->follow_base_cache_target,
1666
+ 'check_interval' => $this->follow_base_check_interval,
1667
+ 'scheme_migration_mode' => $this->scheme_migration_mode,
1668
+ 'scheme_migration_exclude_keys' => $this->scheme_migration_exclude_keys,
1669
+ 'feed_type' => $this->follow_feed_type,
1670
+ );
1671
 
1672
+ $this->cache_engines[ self::REF_FOLLOW_LAZY ] = SCC_Follow_Lazy_Cache_Engine::get_instance();
1673
+ $this->cache_engines[ self::REF_FOLLOW_LAZY ]->initialize( $options );
 
 
1674
 
1675
+ // Follow second cache engine
1676
+ $options = array(
1677
+ 'delegate' => $this,
1678
+ 'target_sns' => $this->follow_base_cache_target,
1679
+ 'check_interval' => self::OPT_FOLLOW_2ND_CHECK_INTERVAL,
1680
+ 'cache_prefix' => self::OPT_FOLLOW_2ND_META_KEY_PREFIX,
1681
+ );
1682
 
1683
+ $this->cache_engines[ self::REF_FOLLOW_2ND ] = SCC_Follow_Second_Cache_Engine::get_instance();
1684
+ $this->cache_engines[ self::REF_FOLLOW_2ND ]->initialize( $options );
 
 
1685
 
1686
+ // Follow restore cache engine
1687
+ $options = array(
1688
+ 'target_sns' => $this->follow_base_cache_target,
1689
+ 'check_interval' => $this->follow_base_check_interval,
1690
+ );
1691
 
1692
+ $this->cache_engines[ self::REF_FOLLOW_RESTORE ] = SCC_Follow_Restore_Cache_Engine::get_instance();
1693
+ $this->cache_engines[ self::REF_FOLLOW_RESTORE ]->initialize( $options );
1694
+
1695
+ // Data export engine
1696
+ $options = array(
1697
+ 'export_activation' => $this->data_export_mode,
1698
+ 'export_schedule' => $this->data_export_schedule,
1699
+ 'share_target_sns' => $this->share_base_cache_target,
1700
+ 'follow_target_sns' => $this->follow_base_cache_target,
1701
+ 'export_file_name' => self::OPT_COMMON_DATA_EXPORT_FILE_NAME,
1702
+ 'export_exclude_keys' => array( self::REF_SHARE_TOTAL, self::REF_CRAWL_DATE ),
1703
+ 'post_types' => $this->share_base_cache_post_types,
1704
+ );
1705