SNS Count Cache - Version 0.9.0

Version Description

  • Fixed: Twitter share count retrieval is implemented using alternative Twitter APIs.
  • Improved: Cache processing is stabilized.
  • Added: function to retrieve follower count of Twitter.
  • Added: function to retrieve follower count of Facebook page.
  • Added: function to retrieve follower count of Instagram.
  • Added: function to retrieve follower count of Push7.
  • Added: Information related to the above new functions is added to the help page.

=

Download this release

Release Info

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

Code changes from version 0.8.0 to 0.9.0

Files changed (65) hide show
  1. css/monokai.css +70 -0
  2. css/prettify.css +0 -30
  3. css/sns-count-cache.css +206 -171
  4. data/.htaccess +12 -12
  5. data/index.php +4 -3
  6. includes/admin-cache-status.php +310 -327
  7. includes/admin-dashboard-widget.php +231 -150
  8. includes/admin-dashboard.php +253 -173
  9. includes/admin-help.php +201 -179
  10. includes/admin-hot-content.php +328 -352
  11. includes/admin-notice.php +48 -21
  12. includes/admin-setting.php +2016 -1459
  13. includes/admin-share-count.php +446 -488
  14. includes/class-analytical-engline.php +43 -46
  15. includes/class-blowfish.php +272 -0
  16. includes/class-cache-engine.php +49 -52
  17. includes/class-common-data-export-engine.php +339 -356
  18. includes/class-common-job-reset-engine.php +147 -153
  19. includes/class-common-util.php +610 -321
  20. includes/class-crawl-strategy.php +229 -0
  21. includes/class-crawler.php +194 -0
  22. includes/class-data-crawler.php +0 -135
  23. includes/class-default-key.php +320 -0
  24. includes/class-engine.php +68 -73
  25. includes/class-export-engine.php +44 -47
  26. includes/class-follow-base-cache-engine.php +118 -127
  27. includes/class-follow-cache-engine.php +134 -88
  28. includes/class-follow-crawler.php +230 -141
  29. includes/class-follow-facebook-strategy.php +132 -0
  30. includes/class-follow-feedly-strategy.php +124 -0
  31. includes/class-follow-instagram-strategy.php +126 -0
  32. includes/class-follow-lazy-cache-engine.php +181 -197
  33. includes/class-follow-push7-strategy.php +124 -0
  34. includes/class-follow-restore-cache-engine.php +197 -0
  35. includes/class-follow-second-cache-engine.php +228 -238
  36. includes/class-follow-twitter-strategy.php +181 -0
  37. includes/class-mcrypt.php +65 -0
  38. includes/class-share-analytical-engine.php +580 -667
  39. includes/class-share-base-cache-engine.php +391 -400
  40. includes/class-share-cache-engine.php +247 -223
  41. includes/class-share-crawler.php +235 -281
  42. includes/class-share-facebook-strategy.php +134 -0
  43. includes/class-share-google-strategy.php +124 -0
  44. includes/class-share-hatebu-strategy.php +120 -0
  45. includes/class-share-lazy-cache-engine.php +236 -243
  46. includes/class-share-pocket-strategy.php +127 -0
  47. includes/class-share-rescue-cache-engine.php +328 -339
  48. includes/class-share-restore-cache-engine.php +267 -0
  49. includes/class-share-rush-cache-engine.php +325 -330
  50. includes/class-share-second-cache-engine.php +348 -366
  51. includes/class-share-twitter-strategy.php +162 -0
  52. includes/class-sleep-throttle.php +91 -57
  53. includes/class-wp-cron-util.php +75 -80
  54. includes/download.php +75 -79
  55. includes/interface-cache-order.php +3 -5
  56. includes/interface-order.php +4 -6
  57. index.php +58 -0
  58. js/highlight.pack.js +2 -0
  59. js/jquery.scc-cache-info.js +146 -80
  60. js/jquery.scc-cache-info.min.js +12 -6
  61. js/prettify.js +0 -28
  62. languages/sns-count-cache-ja.mo +0 -0
  63. languages/sns-count-cache-ja.po +1430 -1097
  64. readme.txt +163 -134
  65. sns-count-cache.php +2548 -2366
css/monokai.css ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Monokai style - ported by Luigi Maselli - http://grigio.org
3
+ */
4
+
5
+ .hljs {
6
+ display: block;
7
+ overflow-x: auto;
8
+ padding: 0.5em;
9
+ background: #272822; color: #ddd;
10
+ }
11
+
12
+ .hljs-tag,
13
+ .hljs-keyword,
14
+ .hljs-selector-tag,
15
+ .hljs-literal,
16
+ .hljs-strong,
17
+ .hljs-name {
18
+ color: #f92672;
19
+ }
20
+
21
+ .hljs-code {
22
+ color: #66d9ef;
23
+ }
24
+
25
+ .hljs-class .hljs-title {
26
+ color: white;
27
+ }
28
+
29
+ .hljs-attribute,
30
+ .hljs-symbol,
31
+ .hljs-regexp,
32
+ .hljs-link {
33
+ color: #bf79db;
34
+ }
35
+
36
+ .hljs-string,
37
+ .hljs-bullet,
38
+ .hljs-subst,
39
+ .hljs-title,
40
+ .hljs-section,
41
+ .hljs-emphasis,
42
+ .hljs-type,
43
+ .hljs-built_in,
44
+ .hljs-builtin-name,
45
+ .hljs-selector-attr,
46
+ .hljs-selector-pseudo,
47
+ .hljs-addition,
48
+ .hljs-variable,
49
+ .hljs-template-tag,
50
+ .hljs-template-variable {
51
+ color: #a6e22e;
52
+ }
53
+
54
+ .hljs-comment,
55
+ .hljs-quote,
56
+ .hljs-deletion,
57
+ .hljs-meta {
58
+ color: #75715e;
59
+ }
60
+
61
+ .hljs-keyword,
62
+ .hljs-selector-tag,
63
+ .hljs-literal,
64
+ .hljs-doctag,
65
+ .hljs-title,
66
+ .hljs-section,
67
+ .hljs-type,
68
+ .hljs-selector-id {
69
+ font-weight: bold;
70
+ }
css/prettify.css DELETED
@@ -1,30 +0,0 @@
1
- .com { color: #93a1a1; }
2
- .lit { color: #195f91; }
3
- .pun, .opn, .clo { color: #93a1a1; }
4
- .fun { color: #dc322f; }
5
- .str, .atv { color: #D14; }
6
- .kwd, .prettyprint .tag { color: #1e347b; }
7
- .typ, .atn, .dec, .var { color: teal; }
8
- .pln { color: #48484c; }
9
-
10
- .prettyprint {
11
- padding: 8px;
12
- background-color: #f9f9f9;
13
- border: 1px solid #e1e1e8;
14
- }
15
- .prettyprint.linenums {
16
- -webkit-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
17
- -moz-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
18
- box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
19
- }
20
-
21
- /* Specify class=linenums on a pre to get line numbering */
22
- ol.linenums {
23
- margin: 0 0 0 33px; /* IE indents via margin-left */
24
- }
25
- ol.linenums li {
26
- padding-left: 12px;
27
- color: #bebec5;
28
- line-height: 20px;
29
- text-shadow: 0 1px 0 #fff;
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
css/sns-count-cache.css CHANGED
@@ -1,171 +1,206 @@
1
- .wrap h2 a {
2
- color: #222;
3
- text-decoration: none;
4
- }
5
-
6
- .sns-cnt-cache h3.hndle {
7
- font-size: 16px !important;
8
- }
9
-
10
- .sns-cnt-cache h4 {
11
- font-size: 15px;
12
- padding: 15px 0 10px 0 !important;
13
- font-weight: 700;
14
- }
15
-
16
- .sns-cnt-cache .postbox .inside {
17
- padding: 0 10px;
18
- }
19
-
20
- .sns-cnt-cache .view-table {
21
- border: 1px solid #000;
22
- margin: 0;
23
- padding: 0;
24
- width: 100%;
25
- border-collapse: collapse;
26
- border-spacing: 0;
27
- }
28
-
29
- .sns-cnt-cache .view-table tr:nth-child(odd) {
30
- background-color: #ffffff;
31
- }
32
-
33
- .sns-cnt-cache .view-table tr:nth-child(even) {
34
- background-color: #f9f9f9;
35
- }
36
-
37
- .sns-cnt-cache .view-table tr.home {
38
- border-bottom: 1px solid #dbdbdb;
39
- }
40
-
41
- .sns-cnt-cache .view-table th {
42
- vertical-align: middle;
43
- padding: 3px;
44
- text-align: left;
45
- background-color: #4c4c4c;
46
- color: #fff;
47
- }
48
-
49
- .sns-cnt-cache .pagination {
50
- margin: 10px 0;
51
- }
52
-
53
- .sns-cnt-cache .form-table .section-label {
54
- font-weight: 600;
55
- font-size: 1.3em;
56
- }
57
-
58
- .sns-cnt-cache .view-table td {
59
- vertical-align: middle;
60
- padding: 2px 4px;
61
- border: 1px dotted #dfdfdf;
62
- }
63
-
64
- .sns-cnt-cache .full-cache {
65
- color: #468847;
66
- /* color: #5cb85c; */
67
- /* background-color: #dff0d8 */;
68
- }
69
-
70
- .sns-cnt-cache .partial-cache {
71
- color: #f0ad4e;
72
- /* background-color: #dff0d8 */;
73
- }
74
-
75
- .sns-cnt-cache .no-cache {
76
- /* color: #d9534f; */
77
- /* background-color: #dff0d8 */;
78
- color: #ccc;
79
- }
80
-
81
- .sns-cnt-cache .not-cached {
82
- color: #ccc;
83
- }
84
-
85
- .sns-cnt-cache .share-count {
86
- text-align: right;
87
- }
88
-
89
- .sns-cnt-cache .submit-button {
90
- margin: 20px 0;
91
- }
92
-
93
- .sns-cnt-cache a {
94
- text-decoration: none;
95
- color: #444;
96
- -webkit-transition-property: border,background,color;
97
- transition-property: border,background,color;
98
- -webkit-transition-duration: .05s;
99
- transition-duration: .05s;
100
- -webkit-transition-timing-function: ease-in-out;
101
- transition-timing-function: ease-in-out;
102
- text-decoration: none;
103
- }
104
-
105
- .sns-cnt-cache a:hover {
106
- color: #0074a2;
107
- }
108
-
109
- .sns-cnt-cache .view-table th a {
110
- color: #fff;
111
- }
112
-
113
- .sns-cnt-cache a.sort-exec-key {
114
- text-decoration: underline;
115
- }
116
-
117
- .pagination span, .pagination a {
118
- display: inline-block;
119
- padding: 2px 10px;
120
- }
121
-
122
- .pagination a {
123
- background: #555;
124
- color: #fff;
125
- }
126
-
127
- .pagination a:hover {
128
- background: #3279bb;
129
- color: #fff;
130
- }
131
-
132
- .pagination span.page-num {
133
- margin-right: 10px;
134
- padding: 0;
135
- }
136
-
137
- .pagination span.dots {
138
- padding: 0;
139
- color: gainsboro;
140
- }
141
-
142
- .pagination span.current {
143
- background-color: #ccc;
144
- color: #fff;
145
- }
146
-
147
- .sns-cnt-cache a.button {
148
- font-size: 12px;
149
- padding: 1px 5px;
150
- height: 20px;
151
- line-height: 15px;
152
- }
153
-
154
- .sns-cnt-cache .delta-rise {
155
- color: #FF6866;
156
- text-decoration: underline;
157
- background: #FFEFEF;
158
- font-weight: bold;
159
- font-size: 11px;
160
- border-radius: 5%;
161
- }
162
-
163
- .sns-cnt-cache .delta-fall {
164
- color: #f0ad4e;
165
- text-decoration: underline;
166
- /* background-color: #dff0d8 */;
167
- }
168
-
169
- .sns-cnt-cache .wpcron td {
170
- border-top: 1px solid #dedede;
171
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wrap h2 a {
2
+ color: #222;
3
+ text-decoration: none;
4
+ }
5
+
6
+ .sns-cnt-cache h3.hndle {
7
+ font-size: 16px !important;
8
+ }
9
+
10
+ .sns-cnt-cache h4 {
11
+ font-size: 15px;
12
+ font-weight: 700;
13
+ }
14
+
15
+ .sns-cnt-cache .postbox .inside {
16
+ padding: 0 10px;
17
+ }
18
+
19
+ .sns-cnt-cache .view-table {
20
+ border: 1px solid #000;
21
+ margin: 10px 0;
22
+ padding: 0;
23
+ width: 100%;
24
+ border-collapse: collapse;
25
+ border-spacing: 0;
26
+ word-break: break-word;
27
+ font-size: 13px;
28
+ }
29
+
30
+ .sns-cnt-cache .view-table tr:nth-child(odd) {
31
+ background-color: #ffffff;
32
+ }
33
+
34
+ .sns-cnt-cache .view-table tr:nth-child(even) {
35
+ background-color: #f9f9f9;
36
+ }
37
+
38
+ .sns-cnt-cache .view-table tr.home {
39
+ border-bottom: 1px solid #dbdbdb;
40
+ }
41
+
42
+ .sns-cnt-cache .view-table th {
43
+ vertical-align: middle;
44
+ padding: 3px;
45
+ text-align: left;
46
+ background-color: #4c4c4c;
47
+ color: #fff;
48
+ }
49
+
50
+ .sns-cnt-cache .pagination {
51
+ margin: 10px 0;
52
+ }
53
+
54
+ .sns-cnt-cache .form-table .section-label {
55
+ font-weight: 600;
56
+ font-size: 1.3em;
57
+ }
58
+
59
+ .sns-cnt-cache .view-table td {
60
+ vertical-align: middle;
61
+ padding: 2px 4px;
62
+ border: 1px dotted #dfdfdf;
63
+ }
64
+
65
+ .sns-cnt-cache .full-cache {
66
+ color: #468847;
67
+ }
68
+
69
+ .sns-cnt-cache .partial-cache {
70
+ color: #f0ad4e;
71
+ }
72
+
73
+ .sns-cnt-cache .no-cache {
74
+ color: #ccc;
75
+ }
76
+
77
+ .sns-cnt-cache .not-cached {
78
+ color: #ccc;
79
+ }
80
+
81
+ .sns-cnt-cache .share-count {
82
+ text-align: right;
83
+ }
84
+
85
+ .sns-cnt-cache .submit-button {
86
+ margin: 20px 0;
87
+ }
88
+
89
+ .sns-cnt-cache a {
90
+ text-decoration: none;
91
+ color: #444;
92
+ -webkit-transition-property: border,background,color;
93
+ transition-property: border,background,color;
94
+ -webkit-transition-duration: .05s;
95
+ transition-duration: .05s;
96
+ -webkit-transition-timing-function: ease-in-out;
97
+ transition-timing-function: ease-in-out;
98
+ text-decoration: none;
99
+ }
100
+
101
+ .sns-cnt-cache a:hover {
102
+ color: #0074a2;
103
+ }
104
+
105
+ .sns-cnt-cache .view-table th a {
106
+ color: #fff;
107
+ }
108
+
109
+ .sns-cnt-cache a.sort-exec-key {
110
+ text-decoration: underline;
111
+ }
112
+
113
+ .pagination span, .pagination a {
114
+ display: inline-block;
115
+ padding: 2px 10px;
116
+ }
117
+
118
+ .pagination a {
119
+ background: #555;
120
+ color: #fff;
121
+ }
122
+
123
+ .pagination a:hover {
124
+ background: #3279bb;
125
+ color: #fff;
126
+ }
127
+
128
+ .pagination span.page-num {
129
+ margin-right: 10px;
130
+ padding: 0;
131
+ }
132
+
133
+ .pagination span.dots {
134
+ padding: 0;
135
+ color: gainsboro;
136
+ }
137
+
138
+ .pagination span.current {
139
+ background-color: #ccc;
140
+ color: #fff;
141
+ }
142
+
143
+ /*
144
+ .sns-cnt-cache .button-small {
145
+ font-size: 12px;
146
+ padding: 1px 5px;
147
+ height: 20px;
148
+ line-height: 15px;
149
+ }
150
+ */
151
+
152
+ .sns-cnt-cache .delta-rise {
153
+ color: #FF6866;
154
+ text-decoration: underline;
155
+ background: #FFEFEF;
156
+ font-weight: bold;
157
+ font-size: 11px;
158
+ border-radius: 5%;
159
+ }
160
+
161
+ .sns-cnt-cache .delta-fall {
162
+ color: #f0ad4e;
163
+ text-decoration: underline;
164
+ }
165
+
166
+ .sns-cnt-cache .wpcron td {
167
+ border-top: 1px solid #dedede;
168
+ }
169
+
170
+ .sns-cnt-cache .at-mark {
171
+ padding: 3px 5px;
172
+ margin: 0 -5px 0 0;
173
+ font-size: 14px;
174
+ font-weight: normal;
175
+ text-align: center;
176
+ text-shadow: 0 1px 0 #ffffff;
177
+ background-color: #eeeeee;
178
+ border: 1px solid #ddd;
179
+ }
180
+
181
+ .sns-cnt-cache .button.button-small {
182
+ height: 18px;
183
+ line-height: 16px;
184
+ padding: 0 4px;
185
+ font-size: 11px;
186
+ }
187
+
188
+ @media screen and (max-width: 782px) {
189
+
190
+ .sns-cnt-cache .at-mark {
191
+ display: block;
192
+ font-size: 14px;
193
+ font-weight: normal;
194
+ text-align: center;
195
+ text-shadow: 0 1px 0 #ffffff;
196
+ background-color: #eeeeee;
197
+ border: 1px solid #ddd;
198
+ padding: 7px 10px;
199
+ width: 100%;
200
+ max-width: none;
201
+ -webkit-box-sizing: border-box;
202
+ -moz-box-sizing: border-box;
203
+ box-sizing: border-box;
204
+ margin: 0 0 -1px 1px;
205
+ }
206
+ }
data/.htaccess CHANGED
@@ -1,13 +1,13 @@
1
- <Files "*">
2
- <IfModule mod_access.c>
3
- Deny from all
4
- </IfModule>
5
- <IfModule !mod_access_compat>
6
- <IfModule mod_authz_host.c>
7
- Deny from all
8
- </IfModule>
9
- </IfModule>
10
- <IfModule mod_access_compat>
11
- Deny from all
12
- </IfModule>
13
  </Files>
1
+ <Files "*">
2
+ <IfModule mod_access.c>
3
+ Deny from all
4
+ </IfModule>
5
+ <IfModule !mod_access_compat>
6
+ <IfModule mod_authz_host.c>
7
+ Deny from all
8
+ </IfModule>
9
+ </IfModule>
10
+ <IfModule mod_access_compat>
11
+ Deny from all
12
+ </IfModule>
13
  </Files>
data/index.php CHANGED
@@ -1,3 +1,4 @@
1
- <?php
2
- header( $_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found' );
3
- header( 'Status: 404 Not Found' );
 
1
+ <?php
2
+ header( $_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found' );
3
+ header( 'Status: 404 Not Found' );
4
+ ?>
includes/admin-cache-status.php CHANGED
@@ -1,327 +1,310 @@
1
- <?php
2
- /*
3
- admin-cache-status.php
4
-
5
- Description: Option page implementation
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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
31
-
32
- $posts_per_page = 50;
33
-
34
- $paged = 1;
35
-
36
- if ( isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) && $_GET['paged'] > 0 ) {
37
- $paged = $_GET['paged'];
38
- } else {
39
- $paged = 1;
40
- }
41
-
42
- if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], __FILE__ ) ) {
43
-
44
- if ( current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
45
-
46
- if( isset( $_GET["action"] ) && $_GET["action"] === 'cache' ) {
47
- if( isset( $_GET["post_id"] ) ) {
48
- $post_id = $_GET["post_id"];
49
-
50
- //$this->retrieve_share_cache( $post_id, true );
51
- $this->cache_engines[self::REF_SHARE_BASE]->direct_cache( $post_id, true );
52
-
53
- //Common_Util::log( '[' . __METHOD__ . '] redirect destination: ' . menu_page_url( 'scc-cache-status', false ) );
54
- //wp_safe_redirect( menu_page_url( 'scc-cache-status', false ) );
55
- }
56
- }
57
- }
58
-
59
- }
60
-
61
- $query_args = array(
62
- 'post_type' => $this->share_base_cache_post_types,
63
- 'post_status' => 'publish',
64
- 'posts_per_page' => $posts_per_page,
65
- 'paged' => $paged,
66
- 'update_post_term_cache' => false
67
- );
68
-
69
- $posts_query = new WP_Query( $query_args );
70
-
71
- ?>
72
- <div class="wrap">
73
- <h2><a href="admin.php?page=scc-cache-status"><?php _e( 'SNS Count Cache', self::DOMAIN ); ?></a></h2>
74
- <div class="sns-cnt-cache">
75
- <h3 class="nav-tab-wrapper">
76
- <a class="nav-tab" href="admin.php?page=scc-dashboard"><?php _e( 'Dashboard', self::DOMAIN ); ?></a>
77
- <a class="nav-tab nav-tab-active" href="admin.php?page=scc-cache-status"><?php _e( 'Cache Status', self::DOMAIN ); ?></a>
78
- <a class="nav-tab" href="admin.php?page=scc-share-count"><?php _e( 'Share Count', self::DOMAIN ); ?></a>
79
- <?php if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) { ?>
80
- <a class="nav-tab" href="admin.php?page=scc-hot-content"><?php _e( 'Hot Content', self::DOMAIN ); ?></a>
81
- <?php } ?>
82
- <a class="nav-tab" href="admin.php?page=scc-setting"><?php _e( 'Setting', self::DOMAIN ); ?></a>
83
- <a class="nav-tab" href="admin.php?page=scc-help"><?php _e( 'Help', self::DOMAIN ); ?></a>
84
- </h3>
85
- <div class="metabox-holder">
86
- <div id="share-site-summary" class="postbox">
87
- <div class="handlediv" title="Click to toggle"><br></div>
88
- <h3 class="hndle"><span><?php _e( 'Cache Status', self::DOMAIN ); ?></span></h3>
89
- <div class="inside">
90
- <table class="view-table">
91
- <thead>
92
- <tr>
93
- <th>No.</th>
94
- <th><?php _e( 'Content', self::DOMAIN ); ?></th>
95
- <th><?php _e( 'Primary Cache', self::DOMAIN ); ?></th>
96
- <th><?php _e( 'Secondary Cache', self::DOMAIN ); ?></th>
97
- <th><?php _e( 'Crawl Date', self::DOMAIN ); ?></th>
98
- <th></th>
99
- </tr>
100
- </thead>
101
- <tbody>
102
-
103
- <?php
104
-
105
- $count = ( $paged - 1 ) * $posts_per_page + 1;
106
-
107
- $share_base_cache_target = $this->share_base_cache_target ;
108
- unset( $share_base_cache_target[self::REF_CRAWL_DATE] );
109
-
110
- if ( $paged === 1 ) {
111
- ?>
112
- <tr class="home">
113
- <td><?php echo '-'; ?></td>
114
- <td><a href="<?php echo esc_url( home_url( '/' ) ); ?>" target="_blank"><?php echo esc_html( home_url( '/' ) ); ?></a></td>
115
-
116
- <?php
117
-
118
- $share_base_cache_target = $this->share_base_cache_target ;
119
- unset( $share_base_cache_target[self::REF_CRAWL_DATE] );
120
-
121
- $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( 'home' );
122
-
123
- if ( false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
124
- $full_cache_flag = true;
125
- $partial_cache_flag = false;
126
-
127
- foreach ( $share_base_cache_target as $sns => $active ) {
128
- if ( $active ) {
129
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
130
- $partial_cache_flag = true;
131
- } else {
132
- $full_cache_flag = false;
133
- }
134
- }
135
- }
136
-
137
- if ( $partial_cache_flag && $full_cache_flag ) {
138
- echo '<td class="full-cache">';
139
- _e( 'full cache', self::DOMAIN );
140
- echo '</td>';
141
- } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
142
- echo '<td class="partial-cache">';
143
- _e( 'partial cache', self::DOMAIN );
144
- echo '</td>';
145
- } else {
146
- echo '<td class="no-cache">';
147
- _e( 'no cache', self::DOMAIN );
148
- echo '</td>';
149
- }
150
- } else {
151
- Common_Util::log( '[' . __METHOD__ . '] : no transient' );
152
- echo '<td class="no-cache">';
153
- _e( 'no cache', self::DOMAIN );
154
- echo '</td>';
155
- }
156
-
157
- $full_cache_flag = true;
158
- $partial_cache_flag = false;
159
-
160
- $option_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( 'home' );
161
-
162
- if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
163
- foreach ( $share_base_cache_target as $sns => $active ) {
164
- if ( $active ) {
165
- if ( $sns_counts[$sns] >= 0 ){
166
- $partial_cache_flag = true;
167
- } else {
168
- $full_cache_flag = false;
169
- }
170
- }
171
- }
172
-
173
- } else {
174
- $full_cache_flag = false;
175
- }
176
-
177
- if ( $partial_cache_flag && $full_cache_flag ) {
178
- echo '<td class="full-cache">';
179
- _e( 'full cache', self::DOMAIN );
180
- echo '</td>';
181
- } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
182
- echo '<td class="partial-cache">';
183
- _e( 'partial cache', self::DOMAIN );
184
- echo '</td>';
185
- } else {
186
- echo '<td class="no-cache">';
187
- _e( 'no cache', self::DOMAIN );
188
- echo '</td>';
189
- }
190
-
191
- if ( isset( $sns_counts[self::REF_CRAWL_DATE] ) && $sns_counts[self::REF_CRAWL_DATE] && $sns_counts[self::REF_CRAWL_DATE] !== -1 ) {
192
- echo '<td class="full-cache">';
193
- echo esc_html( $sns_counts[self::REF_CRAWL_DATE] );
194
- echo '</td>';
195
- } else {
196
- echo '<td class="no-cache">';
197
- _e( 'no data', self::DOMAIN );
198
- echo '</td>';
199
- }
200
-
201
- $nonce = wp_create_nonce( __FILE__ );
202
- $cache_url = esc_url( 'admin.php?page=scc-cache-status&action=cache&post_id=' . 'home' . '&_wpnonce=' . $nonce . '&paged=' . $paged );
203
- ?>
204
- <td><a class="button" href="<?php echo $cache_url ?>">Cache</a></td>
205
- </tr>
206
- <?php
207
- }
208
-
209
- if ( $posts_query->have_posts() ) {
210
- while ( $posts_query->have_posts() ) {
211
- $posts_query->the_post();
212
- ?>
213
- <tr>
214
- <td><?php echo $count; ?></td>
215
- <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>
216
- <?php
217
- $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( get_the_ID() );
218
-
219
- if ( false === ( $sns_counts = get_transient( $transient_id ) ) ) {
220
- echo '<td class="no-cache">';
221
- _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 ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
230
- $partial_cache_flag = true;
231
- } else {
232
- $full_cache_flag = false;
233
- }
234
- }
235
- }
236
-
237
- if ( $partial_cache_flag && $full_cache_flag ) {
238
- echo '<td class="full-cache">';
239
- _e( 'full cache', self::DOMAIN );
240
- echo '</td>';
241
- } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
242
- echo '<td class="partial-cache">';
243
- _e( 'partial cache', self::DOMAIN );
244
- echo '</td>';
245
- } else {
246
- echo '<td class="no-cache">';
247
- _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
-
258
- $meta_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( $sns );
259
-
260
- $sns_count = get_post_meta( get_the_ID(), $meta_key, true );
261
-
262
- if ( isset( $sns_count ) && $sns_count !== '' && $sns_count >= 0 ) {
263
- $partial_cache_flag = true;
264
- } else {
265
- $full_cache_flag = false;
266
- }
267
- }
268
- }
269
-
270
- if ( $partial_cache_flag && $full_cache_flag ) {
271
- echo '<td class="full-cache">';
272
- _e( 'full cache', self::DOMAIN );
273
- echo '</td>';
274
- } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
275
- echo '<td class="partial-cache">';
276
- _e( 'partial cache', self::DOMAIN );
277
- echo '</td>';
278
- } else {
279
- echo '<td class="no-cache">';
280
- _e( 'no cache', self::DOMAIN );
281
- echo '</td>';
282
- }
283
-
284
- if ( isset( $sns_counts[self::REF_CRAWL_DATE] ) ) {
285
- echo '<td class="full-cache">';
286
- echo esc_html( $sns_counts[self::REF_CRAWL_DATE] );
287
- echo '</td>';
288
- } else {
289
- $meta_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( self::REF_CRAWL_DATE );
290
-
291
- $crawl_date = get_post_meta( get_the_ID(), $meta_key, true );
292
-
293
- if ( isset( $crawl_date ) && $crawl_date !== '' && $crawl_date !== '-1' ) {
294
- echo '<td class="full-cache">';
295
- echo esc_html( $crawl_date );
296
- echo '</td>';
297
- } else {
298
- echo '<td class="no-cache">';
299
- _e( 'no data', self::DOMAIN );
300
- echo '</td>';
301
- }
302
- }
303
-
304
- $nonce = wp_create_nonce( __FILE__ );
305
- $cache_url = esc_url( 'admin.php?page=scc-cache-status&action=cache&post_id=' . get_the_ID() . '&_wpnonce=' . $nonce . '&paged=' . $paged );
306
- ?>
307
- <td><a class="button" href="<?php echo $cache_url ?>"><?php _e( 'Cache', self::DOMAIN ); ?></a></td>
308
- </tr>
309
-
310
- <?php
311
- ++$count;
312
-
313
- }
314
- }
315
- ?>
316
- </tbody>
317
- </table>
318
- <?php
319
- $this->pagination( $posts_query->max_num_pages, '', $paged, false );
320
-
321
- wp_reset_postdata();
322
- ?>
323
- </div>
324
- </div>
325
- </div>
326
- </div>
327
- </div>
1
+ <?php
2
+ /*
3
+ admin-cache-status.php
4
+
5
+ Description: Option page implementation
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 - 2016 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
+ if ( ! defined( 'ABSPATH' ) ) exit(); // Exit if accessed directly
31
+
32
+ $posts_per_page = 50;
33
+
34
+ $paged = 1;
35
+
36
+ if ( isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) && $_GET['paged'] > 0 ) {
37
+ $paged = $_GET['paged'];
38
+ } else {
39
+ $paged = 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
+ 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
+ }
252
+ }
253
+ }
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>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/admin-dashboard-widget.php CHANGED
@@ -1,150 +1,231 @@
1
- <?php
2
- /*
3
- admin-dashboard-widget.php
4
-
5
- Description: Option page implementation
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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
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
-
44
- <div class="sns-cnt-cache">
45
- <div id="scc-dashboard">
46
- <div id="site-summary-cache" class="site-summary">
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="pcs"></span>
64
- </td>
65
- <td class="share-count"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='pc'></span></td>
66
- <td class="share-count full-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='pfcc'></span></td>
67
- <td class="share-count partial-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='ppcc'></span></td>
68
- <td class="share-count no-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='pncc'></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="scs"></span>
74
- </td>
75
- <td class="share-count"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='pc'></span></td>
76
- <td class="share-count full-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='sfcc'></span></td>
77
- <td class="share-count partial-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='spcc'></span></td>
78
- <td class="share-count no-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='sncc'></span></td>
79
- </tr>
80
- </tbody>
81
- </table>
82
- </div>
83
- <div id="site-summary-count" class="site-summary">
84
- <h4><a href="admin.php?page=scc-share-count"><?php _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
-
95
- $sns_name = '';
96
-
97
- switch ( $sns ) {
98
- case self::REF_SHARE_TWITTER:
99
- $sns_name = __( 'Twitter', self::DOMAIN );
100
- break;
101
- case self::REF_SHARE_FACEBOOK:
102
- $sns_name = __( 'Facebook', self::DOMAIN );
103
- break;
104
- case self::REF_SHARE_GPLUS:
105
- $sns_name = __( 'Google+', self::DOMAIN );
106
- break;
107
- case self::REF_SHARE_POCKET:
108
- $sns_name = __( 'Pocket', self::DOMAIN );
109
- break;
110
- case self::REF_SHARE_HATEBU:
111
- $sns_name = __( 'Hatebu', self::DOMAIN );
112
- break;
113
- case self::REF_SHARE_TOTAL:
114
- $sns_name = __( 'Total', self::DOMAIN );
115
- break;
116
- }
117
-
118
- echo '<th>' . esc_html( $sns_name ) . '</th>';
119
- }
120
- }
121
- ?>
122
- </tr>
123
- </thead>
124
- <tbody>
125
- <tr>
126
- <?php
127
-
128
- foreach ( $share_base_cache_target as $sns => $active ) {
129
- if ( $active ) {
130
- if ( $sns === self::REF_SHARE_GPLUS ){
131
- echo '<td class="share-count">';
132
- echo '<img class="loading" src="' . $this->loading_img_url . '" /><span data-scc="gplus"></span>';
133
- echo '</td>';
134
- } else {
135
- echo '<td class="share-count">';
136
- echo '<img class="loading" src="' . $this->loading_img_url . '" /><span data-scc="' . strtolower( $sns ) . '"></span>';
137
- echo '</td>';
138
- }
139
-
140
- }
141
- }
142
-
143
- ?>
144
- </tr>
145
- </tbody>
146
- </table>
147
- </div>
148
- </div>
149
- </div>
150
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ admin-dashboard-widget.php
4
+
5
+ Description: Option page implementation
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 - 2016 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
+ 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_TOTAL:
111
+ $sns_name = __( 'Total', self::DOMAIN );
112
+ break;
113
+ }
114
+
115
+ echo '<th>' . esc_html( $sns_name ) . '</th>';
116
+ }
117
+ }
118
+ ?>
119
+ </tr>
120
+ </thead>
121
+ <tbody>
122
+ <tr>
123
+ <?php
124
+ foreach ( $share_base_cache_target as $sns => $active ) {
125
+ if ( $active ) {
126
+ if ( $sns === self::REF_SHARE_GPLUS ){
127
+ echo '<td class="share-count">';
128
+ echo '<img class="loading" src="' . $this->loading_img_url . '" /><span data-scc="sgplus"></span>';
129
+ echo '</td>';
130
+ } else {
131
+ echo '<td class="share-count">';
132
+ echo '<img class="loading" src="' . $this->loading_img_url . '" /><span data-scc="s' . strtolower( $sns ) . '"></span>';
133
+ echo '</td>';
134
+ }
135
+ }
136
+ }
137
+ ?>
138
+ </tr>
139
+ </tbody>
140
+ </table>
141
+ </div>
142
+ <div id="site-summary-follow-cache" class="site-summary activity-block">
143
+ <h3><?php _e( 'Follow', self::DOMAIN ); ?></h3>
144
+ <h4><?php _e( 'Cache Status', self::DOMAIN ); ?></h4>
145
+ <table class="view-table">
146
+ <thead>
147
+ <tr>
148
+ <th><?php _e( 'Cache Type', self::DOMAIN ); ?></th>
149
+ <th><?php _e( 'Cache Progress', self::DOMAIN ); ?></th>
150
+ <th><?php _e( 'Total Content', self::DOMAIN ); ?></th>
151
+ <th><?php _e( 'State - Full Cache', self::DOMAIN ); ?></th>
152
+ <th><?php _e( 'State - Partial Cache', self::DOMAIN ); ?></th>
153
+ <th><?php _e( 'State - No Cache', self::DOMAIN ); ?></th>
154
+ </tr>
155
+ </thead>
156
+ <tbody>
157
+ <tr>
158
+ <td><?php _e( 'Primary Cache', self::DOMAIN ); ?></td>
159
+ <td>
160
+ <img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc="fpcs"></span>
161
+ </td>
162
+ <td class="share-count"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fpc'></span></td>
163
+ <td class="share-count full-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fpfcc'></span></td>
164
+ <td class="share-count partial-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fppcc'></span></td>
165
+ <td class="share-count no-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fpncc'></span></td>
166
+ </tr>
167
+ <tr>
168
+ <td><?php _e( 'Secondary Cache', self::DOMAIN ); ?></td>
169
+ <td>
170
+ <img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc="fscs"></span>
171
+ </td>
172
+ <td class="share-count"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fpc'></span></td>
173
+ <td class="share-count full-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fsfcc'></span></td>
174
+ <td class="share-count partial-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fspcc'></span></td>
175
+ <td class="share-count no-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fsncc'></span></td>
176
+ </tr>
177
+ </tbody>
178
+ </table>
179
+ <h4><?php _e( 'Follower Count', self::DOMAIN ); ?></h4>
180
+ <table class="view-table">
181
+ <thead>
182
+ <tr>
183
+ <?php
184
+ $follow_base_cache_target = $this->follow_base_cache_target ;
185
+ unset( $follow_base_cache_target[self::REF_CRAWL_DATE] );
186
+
187
+ foreach ( $follow_base_cache_target as $sns => $active ){
188
+ if ( $active ) {
189
+ $sns_name = '';
190
+
191
+ switch ( $sns ) {
192
+ case self::REF_FOLLOW_TWITTER:
193
+ $sns_name = __( 'Twitter', self::DOMAIN );
194
+ break;
195
+ case self::REF_FOLLOW_FACEBOOK:
196
+ $sns_name = __( 'Facebook', self::DOMAIN );
197
+ break;
198
+ case self::REF_FOLLOW_FEEDLY:
199
+ $sns_name = __( 'Feedly', self::DOMAIN );
200
+ break;
201
+ case self::REF_FOLLOW_INSTAGRAM:
202
+ $sns_name = __( 'Instagram', self::DOMAIN );
203
+ break;
204
+ case self::REF_FOLLOW_PUSH7:
205
+ $sns_name = __( 'Push7', self::DOMAIN );
206
+ break;
207
+ }
208
+
209
+ echo '<th>' . esc_html( $sns_name ) . '</th>';
210
+ }
211
+ }
212
+ ?>
213
+ </tr>
214
+ </thead>
215
+ <tbody>
216
+ <tr>
217
+ <?php
218
+ foreach ( $follow_base_cache_target as $sns => $active ) {
219
+ if ( $active ) {
220
+ echo '<td class="share-count">';
221
+ echo '<img class="loading" src="' . $this->loading_img_url . '" /><span data-scc="f' . strtolower( $sns ) . '"></span>';
222
+ echo '</td>';
223
+ }
224
+ }
225
+ ?>
226
+ </tr>
227
+ </tbody>
228
+ </table>
229
+ </div>
230
+ </div>
231
+ </div>
includes/admin-dashboard.php CHANGED
@@ -1,173 +1,253 @@
1
- <?php
2
- /*
3
- admin-dashboard.php
4
-
5
- Description: Option page implementation
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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
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="wrap">
44
- <h2><a href="admin.php?page=scc-dashboard"><?php _e( 'SNS Count Cache', self::DOMAIN ); ?></a></h2>
45
- <div class="sns-cnt-cache">
46
- <div id="scc-dashboard">
47
- <h3 class="nav-tab-wrapper">
48
- <a class="nav-tab nav-tab-active" href="admin.php?page=scc-dashboard"><?php _e( 'Dashboard', self::DOMAIN ); ?></a>
49
- <a class="nav-tab" href="admin.php?page=scc-cache-status"><?php _e( 'Cache Status', self::DOMAIN ); ?></a>
50
- <a class="nav-tab" href="admin.php?page=scc-share-count"><?php _e( 'Share Count', self::DOMAIN ); ?></a>
51
- <?php if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) { ?>
52
- <a class="nav-tab" href="admin.php?page=scc-hot-content"><?php _e( 'Hot Content', self::DOMAIN ); ?></a>
53
- <?php } ?>
54
- <a class="nav-tab" href="admin.php?page=scc-setting"><?php _e( 'Setting', self::DOMAIN ); ?></a>
55
- <a class="nav-tab" href="admin.php?page=scc-help"><?php _e( 'Help', self::DOMAIN ); ?></a>
56
- </h3>
57
-
58
- <div class="metabox-holder">
59
- <div id="site-summary-cache" class="site-summary postbox">
60
- <div class="handlediv" title="Click to toggle"><br></div>
61
- <h3 class="hndle"><span><?php _e( 'Cache Status', self::DOMAIN ); ?></span></h3>
62
- <div class="inside">
63
- <table class="view-table">
64
- <thead>
65
- <tr>
66
- <th><?php _e( 'Cache Type', self::DOMAIN ); ?></th>
67
- <th><?php _e( 'Cache Progress', self::DOMAIN ); ?></th>
68
- <th><?php _e( 'Total Content', self::DOMAIN ); ?></th>
69
- <th><?php _e( 'State - Full Cache', self::DOMAIN ); ?></th>
70
- <th><?php _e( 'State - Partial Cache', self::DOMAIN ); ?></th>
71
- <th><?php _e( 'State - No Cache', self::DOMAIN ); ?></th>
72
- </tr>
73
- </thead>
74
- <tbody>
75
- <tr>
76
- <td><?php _e( 'Primary Cache', self::DOMAIN ); ?></td>
77
- <td>
78
- <img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc="pcs"></span>
79
- </td>
80
- <td class="share-count"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='pc'></span></td>
81
- <td class="share-count full-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='pfcc'></span></td>
82
- <td class="share-count partial-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='ppcc'></span></td>
83
- <td class="share-count no-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='pncc'></span></td>
84
- </tr>
85
- <tr>
86
- <td><?php _e( 'Secondary Cache', self::DOMAIN ); ?></td>
87
- <td>
88
- <img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc="scs"></span>
89
- </td>
90
- <td class="share-count"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='pc'></span></td>
91
- <td class="share-count full-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='sfcc'></span></td>
92
- <td class="share-count partial-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='spcc'></span></td>
93
- <td class="share-count no-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='sncc'></span></td>
94
- </tr>
95
- </tbody>
96
- </table>
97
- </div>
98
- </div>
99
- </div>
100
-
101
- <div class="metabox-holder">
102
- <div id="site-summary-count" class="site-summary postbox">
103
- <div class="handlediv" title="Click to toggle"><br></div>
104
- <h3 class="hndle"><span><?php _e( 'Share Count', self::DOMAIN ); ?></span></h3>
105
- <div class="inside">
106
- <table class="view-table">
107
- <thead>
108
- <tr>
109
- <?php
110
- $share_base_cache_target = $this->share_base_cache_target ;
111
- unset( $share_base_cache_target[self::REF_CRAWL_DATE] );
112
-
113
- foreach ( $share_base_cache_target as $sns => $active ){
114
- if ( $active ) {
115
-
116
- $sns_name = '';
117
-
118
- switch ( $sns ) {
119
- case self::REF_SHARE_TWITTER:
120
- $sns_name = __( 'Twitter', self::DOMAIN );
121
- break;
122
- case self::REF_SHARE_FACEBOOK:
123
- $sns_name = __( 'Facebook', self::DOMAIN );
124
- break;
125
- case self::REF_SHARE_GPLUS:
126
- $sns_name = __( 'Google+', self::DOMAIN );
127
- break;
128
- case self::REF_SHARE_POCKET:
129
- $sns_name = __( 'Pocket', self::DOMAIN );
130
- break;
131
- case self::REF_SHARE_HATEBU:
132
- $sns_name = __( 'Hatebu', self::DOMAIN );
133
- break;
134
- case self::REF_SHARE_TOTAL:
135
- $sns_name = __( 'Total', self::DOMAIN );
136
- break;
137
- }
138
-
139
- echo '<th>' . esc_html( $sns_name ) . '</th>';
140
- }
141
- }
142
- ?>
143
- </tr>
144
- </thead>
145
- <tbody>
146
- <tr>
147
- <?php
148
-
149
- foreach ( $share_base_cache_target as $sns => $active ) {
150
- if ( $active ) {
151
- if ( $sns === self::REF_SHARE_GPLUS ){
152
- echo '<td class="share-count">';
153
- echo '<img class="loading" src="' . $this->loading_img_url . '" /><span data-scc="gplus"></span>';
154
- echo '</td>';
155
- } else {
156
- echo '<td class="share-count">';
157
- echo '<img class="loading" src="' . $this->loading_img_url . '" /><span data-scc="' . strtolower( $sns ) . '"></span>';
158
- echo '</td>';
159
- }
160
-
161
- }
162
- }
163
-
164
- ?>
165
- </tr>
166
- </tbody>
167
- </table>
168
- </div>
169
- </div>
170
- </div>
171
- </div>
172
- </div>
173
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ admin-dashboard.php
4
+
5
+ Description: Option page implementation
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 - 2016 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
+ 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_TOTAL:
125
+ $sns_name = __( 'Total', self::DOMAIN );
126
+ break;
127
+ }
128
+
129
+ echo '<th>' . esc_html( $sns_name ) . '</th>';
130
+ }
131
+ }
132
+ ?>
133
+ </tr>
134
+ </thead>
135
+ <tbody>
136
+ <tr>
137
+ <?php
138
+ foreach ( $share_base_cache_target as $sns => $active ) {
139
+ if ( $active ) {
140
+ if ( $sns === self::REF_SHARE_GPLUS ){
141
+ echo '<td class="share-count">';
142
+ echo '<img class="loading" src="' . $this->loading_img_url . '" /><span data-scc="sgplus"></span>';
143
+ echo '</td>';
144
+ } else {
145
+ echo '<td class="share-count">';
146
+ echo '<img class="loading" src="' . $this->loading_img_url . '" /><span data-scc="s' . strtolower( $sns ) . '"></span>';
147
+ echo '</td>';
148
+ }
149
+ }
150
+ }
151
+ ?>
152
+ </tr>
153
+ </tbody>
154
+ </table>
155
+ </div>
156
+ </div>
157
+ </div>
158
+ <div class="metabox-holder">
159
+ <div id="site-summary-follow-cache" class="site-summary postbox">
160
+ <div class="handlediv" title="Click to toggle"><br></div>
161
+ <h3 class="hndle"><span><?php _e( 'Follow', self::DOMAIN ); ?></span></h3>
162
+ <div class="inside">
163
+ <h4><?php _e( 'Cache Status', self::DOMAIN ); ?></h4>
164
+ <table class="view-table">
165
+ <thead>
166
+ <tr>
167
+ <th><?php _e( 'Cache Type', self::DOMAIN ); ?></th>
168
+ <th><?php _e( 'Cache Progress', self::DOMAIN ); ?></th>
169
+ <th><?php _e( 'Total Content', self::DOMAIN ); ?></th>
170
+ <th><?php _e( 'State - Full Cache', self::DOMAIN ); ?></th>
171
+ <th><?php _e( 'State - Partial Cache', self::DOMAIN ); ?></th>
172
+ <th><?php _e( 'State - No Cache', self::DOMAIN ); ?></th>
173
+ </tr>
174
+ </thead>
175
+ <tbody>
176
+ <tr>
177
+ <td><?php _e( 'Primary Cache', self::DOMAIN ); ?></td>
178
+ <td>
179
+ <img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc="fpcs"></span>
180
+ </td>
181
+ <td class="share-count"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fpc'></span></td>
182
+ <td class="share-count full-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fpfcc'></span></td>
183
+ <td class="share-count partial-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fppcc'></span></td>
184
+ <td class="share-count no-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fpncc'></span></td>
185
+ </tr>
186
+ <tr>
187
+ <td><?php _e( 'Secondary Cache', self::DOMAIN ); ?></td>
188
+ <td>
189
+ <img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc="fscs"></span>
190
+ </td>
191
+ <td class="share-count"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fpc'></span></td>
192
+ <td class="share-count full-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fsfcc'></span></td>
193
+ <td class="share-count partial-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fspcc'></span></td>
194
+ <td class="share-count no-cache"><img class="loading" src="<?php echo $this->loading_img_url; ?>" /><span data-scc='fsncc'></span></td>
195
+ </tr>
196
+ </tbody>
197
+ </table>
198
+ <h4><?php _e( 'Follow Count', self::DOMAIN ); ?></h4>
199
+ <table class="view-table">
200
+ <thead>
201
+ <tr>
202
+ <?php
203
+ $follow_base_cache_target = $this->follow_base_cache_target ;
204
+ unset( $follow_base_cache_target[self::REF_CRAWL_DATE] );
205
+
206
+ foreach ( $follow_base_cache_target as $sns => $active ){
207
+ if ( $active ) {
208
+ $sns_name = '';
209
+
210
+ switch ( $sns ) {
211
+ case self::REF_FOLLOW_TWITTER:
212
+ $sns_name = __( 'Twitter', self::DOMAIN );
213
+ break;
214
+ case self::REF_FOLLOW_FACEBOOK:
215
+ $sns_name = __( 'Facebook', self::DOMAIN );
216
+ break;
217
+ case self::REF_FOLLOW_FEEDLY:
218
+ $sns_name = __( 'Feedly', self::DOMAIN );
219
+ break;
220
+ case self::REF_FOLLOW_INSTAGRAM:
221
+ $sns_name = __( 'Instagram', self::DOMAIN );
222
+ break;
223
+ case self::REF_FOLLOW_PUSH7:
224
+ $sns_name = __( 'Push7', self::DOMAIN );
225
+ break;
226
+ }
227
+
228
+ echo '<th>' . esc_html( $sns_name ) . '</th>';
229
+ }
230
+ }
231
+ ?>
232
+ </tr>
233
+ </thead>
234
+ <tbody>
235
+ <tr>
236
+ <?php
237
+ foreach ( $follow_base_cache_target as $sns => $active ) {
238
+ if ( $active ) {
239
+ echo '<td class="share-count">';
240
+ echo '<img class="loading" src="' . $this->loading_img_url . '" /><span data-scc="f' . strtolower( $sns ) . '"></span>';
241
+ echo '</td>';
242
+ }
243
+ }
244
+ ?>
245
+ </tr>
246
+ </tbody>
247
+ </table>
248
+ </div>
249
+ </div>
250
+ </div>
251
+ </div>
252
+ </div>
253
+ </div>
includes/admin-help.php CHANGED
@@ -1,179 +1,201 @@
1
- <?php
2
- /*
3
- admin-help.php
4
-
5
- Description: Option page implementation
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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
31
-
32
- ?>
33
-
34
- <div class="wrap">
35
- <h2><a href="admin.php?page=scc-help"><?php _e( 'SNS Count Cache', self::DOMAIN ); ?></a></h2>
36
- <div class="sns-cnt-cache">
37
-
38
- <h3 class="nav-tab-wrapper">
39
- <a class="nav-tab" href="admin.php?page=scc-dashboard"><?php _e( 'Dashboard', self::DOMAIN ); ?></a>
40
- <a class="nav-tab" href="admin.php?page=scc-cache-status"><?php _e( 'Cache Status', self::DOMAIN ); ?></a>
41
- <a class="nav-tab" href="admin.php?page=scc-share-count"><?php _e( 'Share Count', self::DOMAIN ); ?></a>
42
- <?php if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) { ?>
43
- <a class="nav-tab" href="admin.php?page=scc-hot-content"><?php _e( 'Hot Content', self::DOMAIN ); ?></a>
44
- <?php } ?>
45
- <a class="nav-tab" href="admin.php?page=scc-setting"><?php _e( 'Setting', self::DOMAIN ) ?></a>
46
- <a class="nav-tab nav-tab-active" href="admin.php?page=scc-help"><?php _e( 'Help', self::DOMAIN ); ?></a>
47
- </h3>
48
-
49
- <div class="metabox-holder">
50
- <div id="share-site-summary" class="postbox">
51
- <div class="handlediv" title="Click to toggle"><br></div>
52
- <h3 class="hndle"><span><?php _e( 'Help', self::DOMAIN ); ?></span></h3>
53
- <div class="inside">
54
-
55
-
56
- <h4><?php _e( 'What is WordPress plugin SNS Cout Cache?', self::DOMAIN ); ?></h4>
57
- <p><?php _e( 'WordPress plugin SNS Count Cache is a plugin whitch helps you to shorten page loading time when you display share counts. This plugin gets share count for Twitter and Facebook, Google Plus, Pocket, Hatena Bookmark and caches these count in the background. The share count can be retrieved not through network but through the cache using given functions.', self::DOMAIN ); ?></p>
58
- <h4><?php _e( 'How often does this plugin get and cache share counts?', self::DOMAIN ); ?></h4>
59
- <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>
60
- <h4><?php _e( 'How can I know whether share count of each post is cached or not?', self::DOMAIN ); ?></h4>
61
- <p><?php _e( 'Cache status is described in the "Cache Status" tab in the administration page.', self::DOMAIN ); ?></p>
62
- <h4><?php _e( 'How can I get share count from the cache?', self::DOMAIN ); ?></h4>
63
- <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>
64
- <table class="view-table">
65
- <thead>
66
- <tr>
67
- <th><?php _e( 'Function', self::DOMAIN ); ?></th>
68
- <th><?php _e( 'Description', self::DOMAIN ); ?></th>
69
- </tr>
70
- </thead>
71
- <tbody>
72
- <tr><td>scc_get_share_twitter()</td><td><?php _e( 'Twitter share count is returned from cache.', self::DOMAIN ); ?></td></tr>
73
- <tr><td>scc_get_share_facebook()</td><td><?php _e( 'Facebook share count is returned from cache.', self::DOMAIN ); ?></td></tr>
74
- <tr><td>scc_get_share_gplus()</td><td><?php _e( 'Google Plus share count is returned from cache.', self::DOMAIN ); ?></td></tr>
75
- <tr><td>scc_get_share_hatebu()</td><td><?php _e( 'Hatena Bookmark share count is returned from cache.', self::DOMAIN ); ?></td></tr>
76
- <tr><td>scc_get_share_pocket()</td><td><?php _e( 'Pocket share count is returned from cache.', self::DOMAIN ); ?></td></tr>
77
- <tr><td>scc_get_share_total()</td><td><?php _e( 'Total share count of selected SNS is returned from cache.', self::DOMAIN ); ?></td></tr>
78
- </tbody>
79
- </table>
80
- <h4><?php _e( 'How can I get follow count from the cache?', self::DOMAIN ); ?></h4>
81
- <p><?php _e( 'The follow count is retrieved from the cache using the following functions.', self::DOMAIN ); ?></p>
82
- <table class="view-table">
83
- <thead>
84
- <tr>
85
- <th><?php _e( 'Function', self::DOMAIN ); ?></th>
86
- <th><?php _e( 'Description', self::DOMAIN ); ?></th>
87
- </tr>
88
- </thead>
89
- <tbody>
90
- <tr><td>scc_get_follow_feedly()</td><td><?php _e( 'Feedly follow count is returned from cache.', self::DOMAIN ); ?></td></tr>
91
- </tbody>
92
- </table>
93
- <h4><?php _e( 'Example Code', self::DOMAIN ); ?></h4>
94
- <?php _e( 'The code below describes a simple example which displays share count and follower count using the above functions for each post.', self::DOMAIN ); ?>
95
- <pre class="prettyprint">&lt;?php
96
- $query_args = array(
97
- &#039;post_type&#039; =&gt; &#039;post&#039;,
98
- &#039;post_status&#039; =&gt; &#039;publish&#039;,
99
- &#039;posts_per_page&#039; =&gt; 5
100
- );
101
-
102
- $posts_query = new WP_Query( $query_args );
103
-
104
- if ( $posts_query-&gt;have_posts() ) {
105
- while ( $posts_query-&gt;have_posts() ){
106
- $posts_query-&gt;the_post();
107
-
108
- if(function_exists('scc_get_share_twitter') &amp;&amp;
109
- function_exists('scc_get_share_facebook') &amp;&amp;
110
- function_exists('scc_get_share_gplus') &amp;&amp;
111
- function_exists('scc_get_share_pocket') &amp;&amp;
112
- function_exists('scc_get_share_total') &amp;&amp;
113
- function_exists('scc_get_follow_feedly')
114
- ){
115
-
116
- ?&gt;
117
-
118
- &lt;!--
119
- In WordPress loop, you can use the given function
120
- in order to get share count for current post and follower count.
121
- --&gt;
122
-
123
- &lt;p&gt;Twitter: &lt;?php echo scc_get_share_twitter(); ?&gt;&lt;/p&gt;
124
- &lt;p&gt;Facebook: &lt;?php echo scc_get_share_facebook(); ?&gt;&lt;/p&gt;
125
- &lt;p&gt;Google Plus: &lt;?php echo scc_get_share_gplus(); ?&gt;&lt;/p&gt;
126
- &lt;p&gt;Pocket: &lt;?php echo scc_get_share_pocket(); ?&gt;&lt;/p&gt;
127
- &lt;p&gt;Total: &lt;?php echo scc_get_share_total(); ?&gt;&lt;/p&gt;
128
- &lt;p&gt;Feedly: &lt;?php echo scc_get_follow_feedly(); ?&gt;&lt;/p&gt;
129
-
130
- &lt;?php
131
- }
132
- }
133
- }
134
- wp_reset_postdata();
135
- ?&gt;</pre>
136
- <h4><?php _e( 'How can I access specific custom field containing each share count?', self::DOMAIN ); ?></h4>
137
- <p><?php _e( 'Custom fields including share count are accessed using the following meta keys.', self::DOMAIN ); ?></p>
138
- <table class="view-table">
139
- <thead>
140
- <tr>
141
- <th><?php _e( 'Meta Key', self::DOMAIN ); ?></th>
142
- <th><?php _e( 'Description', self::DOMAIN ); ?></th>
143
- </tr>
144
- </thead>
145
- <tbody>
146
- <tr><td>scc_share_count_twitter</td><td><?php _e( 'A meta key for Twitter share count', self::DOMAIN ); ?></td></tr>
147
- <tr><td>scc_share_count_facebook</td><td><?php _e( 'A meta key for Facebook share count', self::DOMAIN ); ?></td></tr>
148
- <tr><td>scc_share_count_google+</td><td><?php _e( 'A meta key for Google Plus share count', self::DOMAIN ); ?></td></tr>
149
- <tr><td>scc_share_count_hatebu</td><td><?php _e( 'A meta key for Hatena Bookmark share count', self::DOMAIN ); ?></td></tr>
150
- <tr><td>scc_share_count_pocket</td><td><?php _e( 'A meta key for Pocket share count', self::DOMAIN ); ?></td></tr>
151
- <tr><td>scc_share_count_total</td><td><?php _e( 'A meta key for total share count', self::DOMAIN ); ?></td></tr>
152
- </tbody>
153
- </table>
154
- <h4><?php _e( 'How can I access specific custom field containing each variation of share count?', self::DOMAIN ); ?></h4>
155
- <p><?php _e( 'Custom fields including variation of share count are accessed using the following meta keys.', self::DOMAIN ); ?></p>
156
- <table class="view-table">
157
- <thead>
158
- <tr>
159
- <th><?php _e( 'Meta Key', self::DOMAIN ); ?></th>
160
- <th><?php _e( 'Description', self::DOMAIN ); ?></th>
161
- </tr>
162
- </thead>
163
- <tbody>
164
- <tr><td>scc_share_delta_twitter</td><td><?php _e( 'A meta key for variation of Twitter share count', self::DOMAIN ); ?></td></tr>
165
- <tr><td>scc_share_delta_facebook</td><td><?php _e( 'A meta key for variation of Facebook share count', self::DOMAIN ); ?></td></tr>
166
- <tr><td>scc_share_delta_google+</td><td><?php _e( 'A meta key for variation of Google Plus share count', self::DOMAIN ); ?></td></tr>
167
- <tr><td>scc_share_delta_hatebu</td><td><?php _e( 'A meta key for variation of Hatena Bookmark share count', self::DOMAIN ); ?></td></tr>
168
- <tr><td>scc_share_delta_pocket</td><td><?php _e( 'A meta key for variation of Pocket share count', self::DOMAIN ); ?></td></tr>
169
- <tr><td>scc_share_delta_total</td><td><?php _e( 'A meta key for variation of total share count', self::DOMAIN ); ?></td></tr>
170
- </tbody>
171
- </table>
172
- </div>
173
- </div>
174
- </div>
175
-
176
- </div>
177
- </div>
178
-
179
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ admin-help.php
4
+
5
+ Description: Option page implementation
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 - 2016 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
+ 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 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_total()</td><td><?php _e( 'Total share count of selected SNS is returned from cache.', self::DOMAIN ); ?></td></tr>
90
+ </tbody>
91
+ </table>
92
+ <h4><?php _e( 'How can I get follower count from the cache?', self::DOMAIN ); ?></h4>
93
+ <p><?php _e( 'The follower count is retrieved from the cache using the following functions.', self::DOMAIN ); ?></p>
94
+ <table class="view-table">
95
+ <thead>
96
+ <tr>
97
+ <th><?php _e( 'Function', self::DOMAIN ); ?></th>
98
+ <th><?php _e( 'Description', self::DOMAIN ); ?></th>
99
+ </tr>
100
+ </thead>
101
+ <tbody>
102
+ <tr><td>scc_get_follow_feedly()</td><td><?php _e( 'Feedly follower count is returned from cache.', self::DOMAIN ); ?></td></tr>
103
+ <tr><td>scc_get_follow_twitter()</td><td><?php _e( 'Twitter follower count is returned from cache.', self::DOMAIN ); ?></td></tr>
104
+ <tr><td>scc_get_follow_facebook()</td><td><?php _e( 'Facebook follower count is returned from cache.', self::DOMAIN ); ?></td></tr>
105
+ <tr><td>scc_get_follow_instagram()</td><td><?php _e( 'Instagram follower count is returned from cache.', self::DOMAIN ); ?></td></tr>
106
+ <tr><td>scc_get_follow_push7()</td><td><?php _e( 'Push7 follower count is returned from cache.', self::DOMAIN ); ?></td></tr>
107
+ </tbody>
108
+ </table>
109
+ <h4><?php _e( 'Example Code', self::DOMAIN ); ?></h4>
110
+ <?php _e( 'The code below describes a simple example which displays share count and follower count using the above functions.', self::DOMAIN ); ?>
111
+ <pre><code class="php">
112
+ &lt;?php
113
+ $query_args = array(
114
+ &#039;post_type&#039; =&gt; &#039;post&#039;,
115
+ &#039;post_status&#039; =&gt; &#039;publish&#039;,
116
+ &#039;posts_per_page&#039; =&gt; 5
117
+ );
118
+
119
+ $posts_query = new WP_Query( $query_args );
120
+
121
+ if ( $posts_query-&gt;have_posts() ) {
122
+ while ( $posts_query-&gt;have_posts() ){
123
+ $posts_query-&gt;the_post();
124
+
125
+ echo &#039;&lt;div&gt;Article Title: &#039; . esc_html( get_the_title( $posts_query-&gt;ID ) ) . &#039;&lt;/div&gt;&#039;;
126
+
127
+ if ( function_exists( &#039;scc_get_share_twitter&#039; ) &amp;&amp;
128
+ function_exists( &#039;scc_get_share_facebook&#039; ) &amp;&amp;
129
+ function_exists( &#039;scc_get_share_gplus&#039; ) &amp;&amp;
130
+ function_exists( &#039;scc_get_share_pocket&#039; ) &amp;&amp;
131
+ function_exists( &#039;scc_get_share_total&#039; )
132
+ ) {
133
+ // In WordPress loop, you can use the given function
134
+ // in order to get share count for current post and follower count.
135
+ echo &#039;&lt;div&gt;Twitter share count: &#039; . scc_get_share_twitter() . &#039;&lt;/div&gt;&#039;;
136
+ echo &#039;&lt;div&gt;Facebook share count: &#039; . scc_get_share_facebook() . &#039;&lt;/div&gt;&#039;;
137
+ echo &#039;&lt;div&gt;Google+ share count: &#039; . scc_get_share_gplus() . &#039;&lt;/div&gt;&#039;;
138
+ echo &#039;&lt;div&gt;Pocket share count: &#039; . scc_get_share_pocket() . &#039;&lt;/div&gt;&#039;;
139
+ echo &#039;&lt;div&gt;Total of share count: &#039; . scc_get_share_total() . &#039;&lt;/div&gt;&#039;;
140
+ }
141
+ }
142
+ wp_reset_postdata();
143
+ }
144
+
145
+ if ( function_exists( &#039;scc_get_follow_feedly&#039; ) &amp;&amp;
146
+ function_exists( &#039;scc_get_follow_twitter&#039; ) &amp;&amp;
147
+ function_exists( &#039;scc_get_follow_facebook&#039; ) &amp;&amp;
148
+ function_exists( &#039;scc_get_follow_instagram&#039; ) &amp;&amp;
149
+ function_exists( &#039;scc_get_follow_push7&#039; )
150
+ ) {
151
+ // You can use the given function in order to get follower count.
152
+ echo &#039;&lt;div&gt;Feedly follower count: &#039; . scc_get_follow_feedly() . &#039;&lt;/div&gt;&#039;;
153
+ echo &#039;&lt;div&gt;Twitter follower count: &#039; . scc_get_follow_twitter() . &#039;&lt;/div&gt;&#039;;
154
+ echo &#039;&lt;div&gt;Facebook follower count: &#039; . scc_get_follow_facebook() . &#039;&lt;/div&gt;&#039;;
155
+ echo &#039;&lt;div&gt;Instagram follower count: &#039; . scc_get_follow_instagram() . &#039;&lt;/div&gt;&#039;;
156
+ echo &#039;&lt;div&gt;Push7 follower count: &#039; . scc_get_follow_push7() . &#039;&lt;/div&gt;&#039;;
157
+ }
158
+ ?&gt;
159
+ </code></pre>
160
+ <script>hljs.initHighlightingOnLoad();</script>
161
+ <h4><?php _e( 'How can I access specific custom field containing each share count?', self::DOMAIN ); ?></h4>
162
+ <p><?php _e( 'Custom fields including share count are accessed using the following meta keys.', self::DOMAIN ); ?></p>
163
+ <table class="view-table">
164
+ <thead>
165
+ <tr>
166
+ <th><?php _e( 'Meta Key', self::DOMAIN ); ?></th>
167
+ <th><?php _e( 'Description', self::DOMAIN ); ?></th>
168
+ </tr>
169
+ </thead>
170
+ <tbody>
171
+ <tr><td>scc_share_count_twitter</td><td><?php _e( 'A meta key to access Twitter share count', self::DOMAIN ); ?></td></tr>
172
+ <tr><td>scc_share_count_facebook</td><td><?php _e( 'A meta key to access Facebook share count', self::DOMAIN ); ?></td></tr>
173
+ <tr><td>scc_share_count_google+</td><td><?php _e( 'A meta key to access Google+ share count', self::DOMAIN ); ?></td></tr>
174
+ <tr><td>scc_share_count_hatebu</td><td><?php _e( 'A meta key to access Hatena Bookmark share count', self::DOMAIN ); ?></td></tr>
175
+ <tr><td>scc_share_count_pocket</td><td><?php _e( 'A meta key to access Pocket share count', self::DOMAIN ); ?></td></tr>
176
+ <tr><td>scc_share_count_total</td><td><?php _e( 'A meta key to access total share count', self::DOMAIN ); ?></td></tr>
177
+ </tbody>
178
+ </table>
179
+ <h4><?php _e( 'How can I access specific custom field containing each variation of share count?', self::DOMAIN ); ?></h4>
180
+ <p><?php _e( 'Custom fields including variation of share count are accessed using the following meta keys.', self::DOMAIN ); ?></p>
181
+ <table class="view-table">
182
+ <thead>
183
+ <tr>
184
+ <th><?php _e( 'Meta Key', self::DOMAIN ); ?></th>
185
+ <th><?php _e( 'Description', self::DOMAIN ); ?></th>
186
+ </tr>
187
+ </thead>
188
+ <tbody>
189
+ <tr><td>scc_share_delta_twitter</td><td><?php _e( 'A meta key to access variation of Twitter share count', self::DOMAIN ); ?></td></tr>
190
+ <tr><td>scc_share_delta_facebook</td><td><?php _e( 'A meta key to access variation of Facebook share count', self::DOMAIN ); ?></td></tr>
191
+ <tr><td>scc_share_delta_google+</td><td><?php _e( 'A meta key to access variation of Google+ share count', self::DOMAIN ); ?></td></tr>
192
+ <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>
193
+ <tr><td>scc_share_delta_pocket</td><td><?php _e( 'A meta key to access variation of Pocket share count', self::DOMAIN ); ?></td></tr>
194
+ <tr><td>scc_share_delta_total</td><td><?php _e( 'A meta key to access variation of total share count', self::DOMAIN ); ?></td></tr>
195
+ </tbody>
196
+ </table>
197
+ </div>
198
+ </div>
199
+ </div>
200
+ </div>
201
+ </div>
includes/admin-hot-content.php CHANGED
@@ -1,352 +1,328 @@
1
- <?php
2
- /*
3
- admin-hot-content.php
4
-
5
- Description: Option page implementation
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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
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
-
39
- if ( current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
40
- if( isset( $_GET["key"] ) ) {
41
- $sort_mode = true;
42
- $sns = $_GET["key"];
43
-
44
- if ( $sns === 'Google' ) {
45
- $sns = $sns . '+';
46
- }
47
-
48
- $sort_exec_key = $sns;
49
-
50
- $meta_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( $sns );
51
- $meta_key2 = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( $sns );
52
- }
53
- }
54
-
55
- }
56
-
57
- $paged = 1;
58
-
59
- if ( isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) && $_GET['paged'] > 0 ) {
60
- $paged = $_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 _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 _e( 'Dashboard', self::DOMAIN ); ?></a>
74
- <a class="nav-tab" href="admin.php?page=scc-cache-status"><?php _e( 'Cache Status', self::DOMAIN ); ?></a>
75
- <a class="nav-tab" href="admin.php?page=scc-share-count"><?php _e( 'Share Count', self::DOMAIN ); ?></a>
76
- <a class="nav-tab nav-tab-active" href="admin.php?page=scc-hot-content"><?php _e( 'Hot Content', self::DOMAIN ); ?></a>
77
- <a class="nav-tab" href="admin.php?page=scc-setting"><?php _e( 'Setting', self::DOMAIN ); ?></a>
78
- <a class="nav-tab" href="admin.php?page=scc-help"><?php _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 _e( 'Hot Content', self::DOMAIN ); ?></span></h3>
84
- <div class="inside">
85
- <table class="view-table">
86
- <thead>
87
- <tr>
88
- <th>No.</th>
89
- <th><?php _e( 'Content', self::DOMAIN ); ?></th>
90
- <?php
91
-
92
- foreach ( $share_base_cache_target as $sns => $active ) {
93
-
94
- if ( $active ) {
95
-
96
- $sort_key = $sns;
97
-
98
- if ( $sort_key === self::REF_SHARE_GPLUS ) {
99
- $sort_key = str_replace( '+', '', $sort_key );
100
- }
101
-
102
- $sort_url = esc_url( 'admin.php?page=scc-hot-content&action=sort&key=' . $sort_key );
103
-
104
- $sns_name = '';
105
-
106
- switch ( $sns ) {
107
- case self::REF_SHARE_TWITTER:
108
- $sns_name = __( 'Twitter', self::DOMAIN );
109
- break;
110
- case self::REF_SHARE_FACEBOOK:
111
- $sns_name = __( 'Facebook', self::DOMAIN );
112
- break;
113
- case self::REF_SHARE_GPLUS:
114
- $sns_name = __( 'Google+', self::DOMAIN );
115
- break;
116
- case self::REF_SHARE_POCKET:
117
- $sns_name = __( 'Pocket', self::DOMAIN );
118
- break;
119
- case self::REF_SHARE_HATEBU:
120
- $sns_name = __( 'Hatebu', self::DOMAIN );
121
- break;
122
- case self::REF_SHARE_TOTAL:
123
- $sns_name = __( 'Total', self::DOMAIN );
124
- break;
125
- }
126
-
127
- if ( $sns === $sort_exec_key ){
128
- echo '<th><a class="sort-exec-key" href="' . $sort_url . '">' . esc_html( $sns_name ) . '</th>';
129
- } else {
130
- echo '<th><a href="' . $sort_url . '">' . esc_html( $sns_name ) . '</th>';
131
- }
132
- }
133
- }
134
- ?>
135
- </tr>
136
- </thead>
137
- <tbody>
138
-
139
- <?php
140
-
141
- $meta_query = array();
142
-
143
- if( $sort_mode ) {
144
-
145
- if ( version_compare( get_bloginfo('version'), '4.2', '>=') ) {
146
-
147
-
148
- $meta_query['relation'] = 'AND';
149
-
150
- $meta_query[0]['relation'] = 'OR';
151
-
152
- foreach ( $share_base_cache_target as $sns => $active ) {
153
- if ( $active ) {
154
- $meta_query[0][] = array(
155
- 'key' => 'scc_share_delta_' . strtolower( $sns ),
156
- 'value' => 0,
157
- 'compare'=>'>',
158
- 'type'=>'NUMERIC'
159
- );
160
- }
161
- }
162
-
163
- $meta_query['meta_primary'] = array(
164
- 'key' => $meta_key,
165
- 'type'=>'NUMERIC'
166
- );
167
-
168
- $meta_query['meta_secondary'] = array(
169
- 'key' => $meta_key2,
170
- 'type'=>'NUMERIC'
171
- );
172
-
173
- Common_Util::log( $meta_query );
174
-
175
- Common_Util::log( 'version: ' . get_bloginfo( 'version') );
176
-
177
- $query_args = array(
178
- 'post_type' => $this->share_base_cache_post_types,
179
- 'post_status' => 'publish',
180
- 'posts_per_page' => $posts_per_page,
181
- 'paged' => $paged,
182
- 'update_post_term_cache' => false,
183
- 'meta_query' => $meta_query,
184
- 'orderby' => array(
185
- 'meta_primary' => 'DESC',
186
- 'meta_secondary' => 'DESC'
187
- )
188
- );
189
-
190
- } else {
191
-
192
- foreach ( $share_base_cache_target as $sns => $active ) {
193
- if ( $active ) {
194
- $meta_query[] = array(
195
- 'key' => 'scc_share_delta_' . strtolower( $sns ),
196
- 'value' => 0,
197
- 'compare'=>'>',
198
- 'type'=>'NUMERIC'
199
- );
200
-
201
- }
202
- }
203
-
204
- $meta_query['relation'] = 'OR';
205
-
206
- $query_args = array(
207
- 'post_type' => $this->share_base_cache_post_types,
208
- 'post_status' => 'publish',
209
- 'posts_per_page' => $posts_per_page,
210
- 'paged' => $paged,
211
- 'meta_key' => $meta_key,
212
- 'orderby' => 'meta_value_num',
213
- 'update_post_term_cache' => false,
214
- 'order' => 'DESC',
215
- 'meta_query' => $meta_query
216
- );
217
- }
218
-
219
- } else {
220
-
221
- foreach ( $share_base_cache_target as $sns => $active ) {
222
- if ( $active ) {
223
- $meta_query[] = array(
224
- 'key' => 'scc_share_delta_' . strtolower( $sns ),
225
- 'value' => 0,
226
- 'compare'=>'>',
227
- 'type'=>'NUMERIC'
228
- );
229
-
230
- }
231
- }
232
-
233
- $meta_query['relation'] = 'OR';
234
-
235
- $query_args = array(
236
- 'post_type' => $this->share_base_cache_post_types,
237
- 'post_status' => 'publish',
238
- 'posts_per_page' => $posts_per_page,
239
- 'paged' => $paged,
240
- 'meta_query' => $meta_query,
241
- 'update_post_term_cache' => false
242
- );
243
- }
244
-
245
- $posts_query = new WP_Query( $query_args );
246
-
247
- $count = ( $paged - 1 ) * $posts_per_page + 1;
248
-
249
- if ( $posts_query->have_posts() ) {
250
- while ( $posts_query->have_posts() ) {
251
- $posts_query->the_post();
252
- ?>
253
- <tr>
254
- <td><?php echo $count; ?></td>
255
- <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>
256
- <?php
257
- $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( get_the_ID() );
258
-
259
- if( ! $sort_mode && false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
260
-
261
- foreach ( $share_base_cache_target as $sns => $active ) {
262
- if ( $active ) {
263
-
264
- //delta
265
- $meta_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( $sns );
266
- $sns_deltas[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
267
-
268
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
269
- echo '<td class="share-count">';
270
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
271
-
272
- if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
273
- echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
274
- } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
275
- echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
276
- }
277
-
278
- echo '</td>';
279
- } else {
280
- echo '<td class="not-cached share-count">';
281
- _e( 'N/A', self::DOMAIN );
282
- echo '</td>';
283
- }
284
- }
285
- }
286
-
287
- } else {
288
-
289
- foreach ( $share_base_cache_target as $sns => $active ) {
290
- if( $active ){
291
-
292
- $meta_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( $sns );
293
-
294
- $sns_counts[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
295
-
296
- //delta
297
- $meta_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( $sns );
298
- $sns_deltas[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
299
-
300
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] !== '' && $sns_counts[$sns] >= 0 ) {
301
- echo '<td class="share-count">';
302
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
303
-
304
- if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
305
- echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
306
- } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
307
- echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
308
- }
309
-
310
- echo '</td>';
311
- } else {
312
- echo '<td class="not-cached share-count">';
313
- _e( 'N/A', self::DOMAIN );
314
- echo '</td>';
315
- }
316
- }
317
- }
318
-
319
- }
320
-
321
- ?>
322
- </tr>
323
- <?php
324
- ++$count;
325
-
326
- }
327
- } else {
328
- echo '<tr>';
329
- echo '<td>' . $count . '</td>';
330
- echo '<td>' . __( 'No hot content.', self::DOMAIN ) . '</td>';
331
- foreach ( $share_base_cache_target as $sns => $active ) {
332
- if ( $active ) {
333
- echo '<td class="not-cached share-count">';
334
- _e( 'N/A', self::DOMAIN );
335
- echo '</td>';
336
- }
337
- }
338
- echo '</tr>';
339
- }
340
- ?>
341
- </tbody>
342
- </table>
343
- <?php
344
- $this->pagination( $posts_query->max_num_pages, '', $paged, true );
345
- wp_reset_postdata();
346
- ?>
347
-
348
- </div>
349
- </div>
350
- </div>
351
- </div>
352
- </div>
1
+ <?php
2
+ /*
3
+ admin-hot-content.php
4
+
5
+ Description: Option page implementation
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 - 2016 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
+ 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_TOTAL:
119
+ $sns_name = __( 'Total', self::DOMAIN );
120
+ break;
121
+ }
122
+
123
+ if ( $sns === $sort_exec_key ){
124
+ echo '<th><a class="sort-exec-key" href="' . $sort_url . '">' . esc_html( $sns_name ) . '</th>';
125
+ } else {
126
+ echo '<th><a href="' . $sort_url . '">' . esc_html( $sns_name ) . '</th>';
127
+ }
128
+ }
129
+ }
130
+ ?>
131
+ </tr>
132
+ </thead>
133
+ <tbody>
134
+ <?php
135
+ $meta_query = array();
136
+
137
+ if ( $sort_mode ) {
138
+ if ( version_compare( get_bloginfo('version'), '4.2', '>=') ) {
139
+ $meta_query['relation'] = 'AND';
140
+
141
+ $meta_query[0]['relation'] = 'OR';
142
+
143
+ foreach ( $share_base_cache_target as $sns => $active ) {
144
+ if ( $active ) {
145
+ $meta_query[0][] = array(
146
+ 'key' => 'scc_share_delta_' . strtolower( $sns ),
147
+ 'value' => 0,
148
+ 'compare'=>'>',
149
+ 'type'=>'NUMERIC'
150
+ );
151
+ }
152
+ }
153
+
154
+ $meta_query['meta_primary'] = array(
155
+ 'key' => $meta_key,
156
+ 'type'=>'NUMERIC'
157
+ );
158
+
159
+ $meta_query['meta_secondary'] = array(
160
+ 'key' => $meta_key2,
161
+ 'type'=>'NUMERIC'
162
+ );
163
+
164
+ Common_Util::log( $meta_query );
165
+
166
+ Common_Util::log( 'version: ' . get_bloginfo( 'version') );
167
+
168
+ $query_args = array(
169
+ 'post_type' => $this->share_base_cache_post_types,
170
+ 'post_status' => 'publish',
171
+ 'posts_per_page' => $posts_per_page,
172
+ 'paged' => $paged,
173
+ 'update_post_term_cache' => false,
174
+ 'meta_query' => $meta_query,
175
+ 'orderby' => array(
176
+ 'meta_primary' => 'DESC',
177
+ 'meta_secondary' => 'DESC'
178
+ )
179
+ );
180
+ } else {
181
+ foreach ( $share_base_cache_target as $sns => $active ) {
182
+ if ( $active ) {
183
+ $meta_query[] = array(
184
+ 'key' => 'scc_share_delta_' . strtolower( $sns ),
185
+ 'value' => 0,
186
+ 'compare'=>'>',
187
+ 'type'=>'NUMERIC'
188
+ );
189
+ }
190
+ }
191
+
192
+ $meta_query['relation'] = 'OR';
193
+
194
+ $query_args = array(
195
+ 'post_type' => $this->share_base_cache_post_types,
196
+ 'post_status' => 'publish',
197
+ 'posts_per_page' => $posts_per_page,
198
+ 'paged' => $paged,
199
+ 'meta_key' => $meta_key,
200
+ 'orderby' => 'meta_value_num',
201
+ 'update_post_term_cache' => false,
202
+ 'order' => 'DESC',
203
+ 'meta_query' => $meta_query
204
+ );
205
+ }
206
+ } else {
207
+ foreach ( $share_base_cache_target as $sns => $active ) {
208
+ if ( $active ) {
209
+ $meta_query[] = array(
210
+ 'key' => 'scc_share_delta_' . strtolower( $sns ),
211
+ 'value' => 0,
212
+ 'compare'=>'>',
213
+ 'type'=>'NUMERIC'
214
+ );
215
+ }
216
+ }
217
+
218
+ $meta_query['relation'] = 'OR';
219
+
220
+ $query_args = array(
221
+ 'post_type' => $this->share_base_cache_post_types,
222
+ 'post_status' => 'publish',
223
+ 'posts_per_page' => $posts_per_page,
224
+ 'paged' => $paged,
225
+ 'meta_query' => $meta_query,
226
+ 'update_post_term_cache' => false
227
+ );
228
+ }
229
+
230
+ $posts_query = new WP_Query( $query_args );
231
+
232
+ $count = ( $paged - 1 ) * $posts_per_page + 1;
233
+
234
+ if ( $posts_query->have_posts() ) {
235
+ while ( $posts_query->have_posts() ) {
236
+ $posts_query->the_post();
237
+ ?>
238
+ <tr>
239
+ <td><?php echo $count; ?></td>
240
+ <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>
241
+ <?php
242
+ $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( get_the_ID() );
243
+
244
+ if ( ! $sort_mode && false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
245
+ foreach ( $share_base_cache_target as $sns => $active ) {
246
+ if ( $active ) {
247
+ //delta
248
+ $meta_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( $sns );
249
+ $sns_deltas[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
250
+
251
+ if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
252
+ echo '<td class="share-count">';
253
+ echo esc_html( number_format( (int) $sns_counts[$sns] ) );
254
+
255
+ if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
256
+ echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
257
+ } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
258
+ echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
259
+ }
260
+
261
+ echo '</td>';
262
+ } else {
263
+ echo '<td class="not-cached share-count">';
264
+ _e( 'N/A', self::DOMAIN );
265
+ echo '</td>';
266
+ }
267
+ }
268
+ }
269
+ } else {
270
+ foreach ( $share_base_cache_target as $sns => $active ) {
271
+ if ( $active ){
272
+ $meta_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( $sns );
273
+
274
+ $sns_counts[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
275
+
276
+ //delta
277
+ $meta_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( $sns );
278
+ $sns_deltas[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
279
+
280
+ if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] !== '' && $sns_counts[$sns] >= 0 ) {
281
+ echo '<td class="share-count">';
282
+ echo esc_html( number_format( (int) $sns_counts[$sns] ) );
283
+
284
+ if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
285
+ echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
286
+ } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
287
+ echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
288
+ }
289
+
290
+ echo '</td>';
291
+ } else {
292
+ echo '<td class="not-cached share-count">';
293
+ _e( 'N/A', self::DOMAIN );
294
+ echo '</td>';
295
+ }
296
+ }
297
+ }
298
+ }
299
+ ?>
300
+ </tr>
301
+ <?php
302
+ ++$count;
303
+ }
304
+ } else {
305
+ echo '<tr>';
306
+ echo '<td>' . $count . '</td>';
307
+ echo '<td>' . __( 'No hot content.', self::DOMAIN ) . '</td>';
308
+ foreach ( $share_base_cache_target as $sns => $active ) {
309
+ if ( $active ) {
310
+ echo '<td class="not-cached share-count">';
311
+ _e( 'N/A', self::DOMAIN );
312
+ echo '</td>';
313
+ }
314
+ }
315
+ echo '</tr>';
316
+ }
317
+ ?>
318
+ </tbody>
319
+ </table>
320
+ <?php
321
+ $this->pagination( $posts_query->max_num_pages, '', $paged, true );
322
+ wp_reset_postdata();
323
+ ?>
324
+ </div>
325
+ </div>
326
+ </div>
327
+ </div>
328
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/admin-notice.php CHANGED
@@ -1,21 +1,48 @@
1
-
2
-
3
- <?php
4
-
5
- if ( $messages = get_option( self::OPT_COMMON_ERROR_MESSAGE ) ) {
6
- ?>
7
- <div class="error">
8
- <ul>
9
- <?php
10
- foreach( $messages as $message ) {
11
- ?>
12
- <li><?php echo esc_html( $message ); ?></li>
13
- <?php
14
- }
15
- ?>
16
- </ul>
17
- </div>
18
- <?php
19
- delete_option( self::OPT_COMMON_ERROR_MESSAGE );
20
- }
21
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ admin-notice.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 - 2016 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
+ 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
+ ?>
includes/admin-setting.php CHANGED
@@ -1,1459 +1,2016 @@
1
- <?php
2
- /*
3
- admin-setting.php
4
-
5
- Description: Option page implementation
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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
31
-
32
- if ( isset( $_POST['_wpnonce'] ) && $_POST['_wpnonce'] ) {
33
- if( check_admin_referer( __FILE__, '_wpnonce' ) ) {
34
-
35
- if( isset( $_POST["update_all_options"] ) && $_POST["update_all_options"] === __( 'Update All Options', self::DOMAIN ) ) {
36
-
37
- $wp_error = new WP_Error();
38
-
39
- $settings = array();
40
-
41
- $share_base_cache_target = array();
42
- $follow_base_cache_target = array();
43
-
44
- if ( isset( $_POST["share_base_custom_post_types"] ) && $_POST["share_base_custom_post_types"] ) {
45
- $share_base_custom_post_types = explode( ',', $_POST["share_base_custom_post_types"] );
46
- $settings[self::DB_SHARE_CUSTOM_POST_TYPES] = $share_base_custom_post_types;
47
- } else {
48
- $settings[self::DB_SHARE_CUSTOM_POST_TYPES] = array();
49
- }
50
-
51
- if ( isset( $_POST["share_base_check_interval"] ) && $_POST["share_base_check_interval"] && is_numeric( $_POST["share_base_check_interval"] ) ) {
52
- $settings[self::DB_SHARE_BASE_CHECK_INTERVAL] = $_POST["share_base_check_interval"];
53
- }
54
-
55
- if ( isset( $_POST["share_base_posts_per_check"] ) && $_POST["share_base_posts_per_check"] && is_numeric( $_POST["share_base_posts_per_check"] ) ) {
56
- $settings[self::DB_SHARE_POSTS_PER_CHECK] = $_POST["share_base_posts_per_check"];
57
- }
58
-
59
- if ( isset( $_POST["dynamic_cache_mode"] ) && $_POST["dynamic_cache_mode"] ) {
60
- $settings[self::DB_COMMON_DYNAMIC_CACHE_MODE] = $_POST["dynamic_cache_mode"];
61
- }
62
-
63
- if ( isset( $_POST["share_variation_analysis_mode"] ) && $_POST["share_variation_analysis_mode"] ) {
64
- $settings[self::DB_SHARE_VARIATION_ANALYSIS_MODE] = $_POST["share_variation_analysis_mode"];
65
- }
66
-
67
- if ( isset( $_POST["share_rush_new_content_term"] ) && $_POST["share_rush_new_content_term"] && is_numeric( $_POST["share_rush_new_content_term"] ) ) {
68
- $settings[self::DB_SHARE_RUSH_NEW_CONTENT_TERM] = $_POST["share_rush_new_content_term"];
69
- }
70
-
71
- if ( isset( $_POST["share_rush_check_interval"] ) && $_POST["share_rush_check_interval"] && is_numeric( $_POST["share_rush_check_interval"] ) ) {
72
- $settings[self::DB_SHARE_RUSH_CHECK_INTERVAL] = $_POST["share_rush_check_interval"];
73
- }
74
-
75
- if ( isset( $_POST["data_export_mode"] ) && $_POST["data_export_mode"] ) {
76
- $settings[self::DB_COMMON_DATA_EXPORT_MODE] = $_POST["data_export_mode"];
77
- }
78
-
79
- if ( isset( $_POST["data_export_interval"] ) && $_POST["data_export_interval"] && is_numeric( $_POST["data_export_interval"] ) ) {
80
- $settings[self::DB_COMMON_DATA_EXPORT_INTERVAL] = $_POST["data_export_interval"];
81
- }
82
-
83
- if ( isset( $_POST["share_base_cache_target_twitter"] ) && $_POST["share_base_cache_target_twitter"] ) {
84
- $share_base_cache_target[self::REF_SHARE_TWITTER] = true;
85
- } else {
86
- $share_base_cache_target[self::REF_SHARE_TWITTER] = false;
87
- }
88
-
89
- if ( isset( $_POST["share_base_cache_target_facebook"] ) && $_POST["share_base_cache_target_facebook"] ) {
90
- $share_base_cache_target[self::REF_SHARE_FACEBOOK] = true;
91
- } else {
92
- $share_base_cache_target[self::REF_SHARE_FACEBOOK] = false;
93
- }
94
-
95
- if ( isset( $_POST["share_base_cache_target_gplus"] ) && $_POST["share_base_cache_target_gplus"] ) {
96
- $share_base_cache_target[self::REF_SHARE_GPLUS] = true;
97
- } else {
98
- $share_base_cache_target[self::REF_SHARE_GPLUS] = false;
99
- }
100
-
101
- if ( isset( $_POST["share_base_cache_target_pocket"] ) && $_POST["share_base_cache_target_pocket"] ) {
102
- $share_base_cache_target[self::REF_SHARE_POCKET] = true;
103
- } else {
104
- $share_base_cache_target[self::REF_SHARE_POCKET] = false;
105
- }
106
-
107
- if ( isset( $_POST["share_base_cache_target_hatebu"] ) && $_POST["share_base_cache_target_hatebu"] ) {
108
- $share_base_cache_target[self::REF_SHARE_HATEBU] = true;
109
- } else {
110
- $share_base_cache_target[self::REF_SHARE_HATEBU] = false;
111
- }
112
-
113
- /*
114
- if ( isset( $_POST["share_base_cache_target_pinterest"] ) && $_POST["share_base_cache_target_pinterest"] ) {
115
- $share_base_cache_target[self::REF_SHARE_PINTEREST] = true;
116
- } else {
117
- $share_base_cache_target[self::REF_SHARE_PINTEREST] = false;
118
- }
119
-
120
- if ( isset( $_POST["share_base_cache_target_linkedin"] ) && $_POST["share_base_cache_target_linkedin"] ) {
121
- $share_base_cache_target[self::REF_SHARE_LINKEDIN] = true;
122
- } else {
123
- $share_base_cache_target[self::REF_SHARE_LINKEDIN] = false;
124
- }
125
- */
126
-
127
- if ( ! empty( $share_base_cache_target ) ) {
128
- $settings[self::DB_SHARE_CACHE_TARGET] = $share_base_cache_target;
129
- }
130
-
131
- if ( isset( $_POST["follow_base_check_interval"] ) && $_POST["follow_base_check_interval"] && is_numeric( $_POST["follow_base_check_interval"] ) ) {
132
- if ( $_POST["follow_base_check_interval"] >= self::OPT_FOLLOW_BASE_CHECK_INTERVAL_MIN ) {
133
- $settings[self::DB_FOLLOW_CHECK_INTERVAL] = $_POST["follow_base_check_interval"];
134
- } else {
135
- $settings[self::DB_FOLLOW_CHECK_INTERVAL] = self::OPT_FOLLOW_BASE_CHECK_INTERVAL_MIN;
136
- }
137
- }
138
-
139
- if ( isset( $_POST["follow_base_cache_target_feedly"] ) && $_POST["follow_base_cache_target_feedly"] ) {
140
- $follow_base_cache_target[self::REF_FOLLOW_FEEDLY] = true;
141
- } else {
142
- $follow_base_cache_target[self::REF_FOLLOW_FEEDLY] = false;
143
- }
144
-
145
- if ( ! empty( $follow_base_cache_target ) ) {
146
- $settings[self::DB_FOLLOW_CACHE_TARGET] = $follow_base_cache_target;
147
- }
148
-
149
- if ( isset( $_POST["follow_feed_type"] ) && $_POST["follow_feed_type"] ) {
150
- switch ( $_POST["follow_feed_type"] ) {
151
- case 'default':
152
- $settings[self::DB_FOLLOW_FEED_TYPE] = self::OPT_FEED_TYPE_DEFAULT;
153
- break;
154
- case 'rss2':
155
- $settings[self::DB_FOLLOW_FEED_TYPE] = self::OPT_FEED_TYPE_RSS2;
156
- break;
157
- case 'rss':
158
- $settings[self::DB_FOLLOW_FEED_TYPE] = self::OPT_FEED_TYPE_RSS;
159
- break;
160
- case 'rdf':
161
- $settings[self::DB_FOLLOW_FEED_TYPE] = self::OPT_FEED_TYPE_RDF;
162
- break;
163
- case 'atom':
164
- $settings[self::DB_FOLLOW_FEED_TYPE] = self::OPT_FEED_TYPE_ATOM;
165
- break;
166
- default:
167
- $settings[self::DB_FOLLOW_FEED_TYPE] = self::OPT_FEED_TYPE_DEFAULT;
168
- }
169
-
170
- } else {
171
- $settings[self::DB_FOLLOW_FEED_TYPE] = self::OPT_FEED_TYPE_DEFAULT;
172
- }
173
-
174
- if ( isset( $_POST["scheme_migration_mode"] ) && $_POST["scheme_migration_mode"] ) {
175
- $settings[self::DB_COMMON_SCHEME_MIGRATION_MODE] = self::OPT_COMMON_SCHEME_MIGRATION_MODE_ON;
176
- } else {
177
- $settings[self::DB_COMMON_SCHEME_MIGRATION_MODE] = self::OPT_COMMON_SCHEME_MIGRATION_MODE_OFF;
178
- }
179
-
180
- if ( isset( $_POST["scheme_migration_date"] ) && $_POST["scheme_migration_date"] && strptime( $_POST["scheme_migration_date"], '%Y/%m/%d' ) ) {
181
- $settings[self::DB_COMMON_SCHEME_MIGRATION_DATE] = $_POST["scheme_migration_date"];
182
- }
183
-
184
- if ( isset( $_POST["crawler_ssl_verification"] ) && $_POST["crawler_ssl_verification"] ) {
185
- $settings[self::DB_COMMON_CRAWLER_SSL_VERIFICATION] = self::OPT_COMMON_CRAWLER_SSL_VERIFY_ON;
186
- } else {
187
- $settings[self::DB_COMMON_CRAWLER_SSL_VERIFICATION] = self::OPT_COMMON_CRAWLER_SSL_VERIFY_OFF;
188
- }
189
-
190
- if ( isset( $_POST['a_cronbtype'] ) && $_POST['a_cronbtype'] === 'mon' ) {
191
- $settings[self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE] = $_POST['a_moncronminutes'] . ' ' . $_POST['a_moncronhours'] . ' ' . $_POST['a_moncronmday'] . ' * *';
192
- }
193
- if ( isset( $_POST['a_cronbtype'] ) && $_POST['a_cronbtype'] === 'week' ) {
194
- $settings[self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE] = $_POST['a_weekcronminutes'] . ' ' . $_POST['a_weekcronhours'] . ' * * ' . $_POST['a_weekcronwday'];
195
- }
196
- if ( isset( $_POST['a_cronbtype'] ) && $_POST['a_cronbtype'] === 'day' ) {
197
- $settings[self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE] = $_POST['a_daycronminutes'] . ' ' . $_POST['a_daycronhours'] . ' * * *';
198
- }
199
- if ( isset( $_POST['a_cronbtype'] ) && $_POST['a_cronbtype'] === 'hour' ) {
200
- $settings[self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE] = $_POST['a_hourcronminutes'] . ' * * * *';
201
- }
202
-
203
- if ( isset( $_POST['e_cronbtype'] ) && $_POST['e_cronbtype'] === 'mon' ) {
204
- $settings[self::DB_COMMON_DATA_EXPORT_SCHEDULE] = $_POST['e_moncronminutes'] . ' ' . $_POST['e_moncronhours'] . ' ' . $_POST['e_moncronmday'] . ' * *';
205
- }
206
- if ( isset( $_POST['e_cronbtype'] ) && $_POST['e_cronbtype'] === 'week' ) {
207
- $settings[self::DB_COMMON_DATA_EXPORT_SCHEDULE] = $_POST['e_weekcronminutes'] . ' ' . $_POST['e_weekcronhours'] . ' * * ' . $_POST['e_weekcronwday'];
208
- }
209
- if ( isset( $_POST['e_cronbtype'] ) && $_POST['e_cronbtype'] === 'day' ) {
210
- $settings[self::DB_COMMON_DATA_EXPORT_SCHEDULE] = $_POST['e_daycronminutes'] . ' ' . $_POST['e_daycronhours'] . ' * * *';
211
- }
212
- if ( isset( $_POST['e_cronbtype'] ) && $_POST['e_cronbtype'] === 'hour' ) {
213
- $settings[self::DB_COMMON_DATA_EXPORT_SCHEDULE] = $_POST['e_hourcronminutes'] . ' * * * *';
214
- }
215
-
216
- update_option( self::DB_SETTINGS, $settings );
217
-
218
- $this->reactivate_plugin();
219
-
220
- set_transient( self::OPT_COMMON_ERROR_MESSAGE, $wp_error->get_error_messages(), 10 );
221
-
222
- //wp_safe_redirect( menu_page_url( 'scc-setting', false ) );
223
- }
224
-
225
- if( isset( $_POST["reset_data"] ) && $_POST["reset_data"] === __( 'Reset', self::DOMAIN ) ) {
226
- Common_Util::log( '[' . __METHOD__ . '] reset' );
227
-
228
- $this->export_engines[self::REF_COMMON_EXPORT]->reset_export();
229
-
230
- //wp_safe_redirect( menu_page_url( 'scc-setting', false ) );
231
- }
232
-
233
- if( isset( $_POST["export_data"] ) && $_POST["export_data"] === __( 'Export', self::DOMAIN ) ) {
234
- Common_Util::log( '[' . __METHOD__ . '] export' );
235
-
236
- set_time_limit( $this->extended_max_execution_time );
237
-
238
- $this->export_engines[self::REF_COMMON_EXPORT]->execute_export( NULL );
239
-
240
- set_time_limit( $this->original_max_execution_time );
241
-
242
- //wp_safe_redirect( menu_page_url('scc-setting', false ) );
243
- }
244
-
245
- if( isset( $_POST["update_share_comparison_base"] ) && $_POST["update_share_comparison_base"] === __( 'Update Basis of Comparison', self::DOMAIN ) ) {
246
- Common_Util::log( '[' . __METHOD__ . '] base' );
247
-
248
- set_time_limit( $this->extended_max_execution_time );
249
-
250
- $this->analytical_engines[self::REF_SHARE_ANALYSIS]->execute_base( NULL );
251
-
252
- set_time_limit( $this->original_max_execution_time );
253
-
254
- //wp_safe_redirect( menu_page_url( 'scc-setting', false ) );
255
- }
256
-
257
- if( isset( $_POST["clear_share_base_cache"] ) && $_POST["clear_share_base_cache"] === __( 'Clear Cache', self::DOMAIN ) ) {
258
- Common_Util::log( '[' . __METHOD__ . '] clear cache' );
259
-
260
- set_time_limit( $this->extended_max_execution_time );
261
-
262
- $this->cache_engines[self::REF_SHARE_BASE]->clear_cache();
263
- //$this->cache_engines[self::REF_SHARE_2ND]->clear_cache();
264
- $this->cache_engines[self::REF_SHARE_2ND]->initialize_cache();
265
- $this->analytical_engines[self::REF_SHARE_ANALYSIS]->clear_base();
266
-
267
- set_time_limit( $this->original_max_execution_time );
268
-
269
- //wp_safe_redirect( menu_page_url('scc-setting', false ) );
270
- }
271
-
272
- if( isset( $_POST["clear_follow_base_cache"] ) && $_POST["clear_follow_base_cache"] === __( 'Clear Cache', self::DOMAIN ) ) {
273
- Common_Util::log( '[' . __METHOD__ . '] clear cache' );
274
-
275
- set_time_limit( $this->extended_max_execution_time );
276
-
277
- $this->cache_engines[self::REF_FOLLOW_BASE]->clear_cache();
278
- //$this->cache_engines[self::REF_FOLLOW_2ND]->clear_cache();
279
- $this->cache_engines[self::REF_FOLLOW_2ND]->initialize_cache();
280
-
281
- set_time_limit( $this->original_max_execution_time );
282
-
283
- //wp_safe_redirect( menu_page_url('scc-setting', false ) );
284
- }
285
- }
286
- }
287
-
288
- ?>
289
- <div class="wrap">
290
- <h2><a href="admin.php?page=scc-setting"><?php _e( 'SNS Count Cache', self::DOMAIN ); ?></a></h2>
291
- <?php
292
- if ( $messages = get_transient( self::OPT_COMMON_ERROR_MESSAGE ) ) {
293
- ?>
294
- <div class="error">
295
- <ul>
296
- <?php
297
- foreach( $messages as $message ) {
298
- ?>
299
- <li><?php echo esc_html( $message ); ?></li>
300
- <?php
301
- }
302
- ?>
303
- </ul>
304
- </div>
305
- <?php
306
- delete_option( self::OPT_COMMON_ERROR_MESSAGE );
307
- }
308
- ?>
309
- <div class="sns-cnt-cache">
310
- <h3 class="nav-tab-wrapper">
311
- <a class="nav-tab" href="admin.php?page=scc-dashboard"><?php _e( 'Dashboard', self::DOMAIN ); ?></a>
312
- <a class="nav-tab" href="admin.php?page=scc-cache-status"><?php _e( 'Cache Status', self::DOMAIN ); ?></a>
313
- <a class="nav-tab" href="admin.php?page=scc-share-count"><?php _e( 'Share Count', self::DOMAIN ); ?></a>
314
- <?php if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) { ?>
315
- <a class="nav-tab" href="admin.php?page=scc-hot-content"><?php _e( 'Hot Content', self::DOMAIN ); ?></a>
316
- <?php } ?>
317
- <a class="nav-tab nav-tab-active" href="admin.php?page=scc-setting"><?php _e( 'Setting', self::DOMAIN ); ?></a>
318
- <a class="nav-tab" href="admin.php?page=scc-help"><?php _e( 'Help', self::DOMAIN ); ?></a>
319
- </h3>
320
- <p id="options-menu">
321
- <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="#common-dynamic-cache"><?php _e( 'Dynamic Cache', 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>
322
- </p>
323
- <div class="metabox-holder">
324
- <div id="current-parameter" class="postbox">
325
- <div class="handlediv" title="Click to toggle"><br></div>
326
- <h3 class="hndle"><span><?php _e( 'Current Setting', self::DOMAIN ); ?></span></h3>
327
- <div class="inside">
328
- <table class="view-table">
329
- <thead>
330
- <tr>
331
- <th><?php _e( 'Capability', self::DOMAIN ); ?></th>
332
- <th><?php _e( 'Parameter', self::DOMAIN ); ?></th>
333
- <th><?php _e( 'Value', self::DOMAIN ); ?></th>
334
- </tr>
335
- </thead>
336
- <tbody>
337
- <tr>
338
- <td><?php _e( 'Share Base Cache', self::DOMAIN); ?></td>
339
- <td><?php _e( 'Target SNS', self::DOMAIN ); ?></td>
340
- <td>
341
- <?php
342
- $target_sns = array();
343
- if ( isset( $this->share_base_cache_target[self::REF_SHARE_FACEBOOK] ) && $this->share_base_cache_target[self::REF_SHARE_FACEBOOK] ) {
344
- $target_sns[] = 'Facebook';
345
- }
346
- if ( isset( $this->share_base_cache_target[self::REF_SHARE_GPLUS] ) && $this->share_base_cache_target[self::REF_SHARE_GPLUS] ) {
347
- $target_sns[] = 'Google+';
348
- }
349
- if ( isset( $this->share_base_cache_target[self::REF_SHARE_HATEBU] ) && $this->share_base_cache_target[self::REF_SHARE_HATEBU] ) {
350
- $target_sns[] = __( 'Hatena Bookmark', self::DOMAIN );
351
- }
352
- /*
353
- if ( isset( $this->share_base_cache_target[self::REF_SHARE_LINKEDIN] ) && $this->share_base_cache_target[self::REF_SHARE_LINKEDIN] ) {
354
- $target_sns[] = 'Linkedin';
355
- }
356
- if ( isset( $this->share_base_cache_target[self::REF_SHARE_PINTEREST] ) && $this->share_base_cache_target[self::REF_SHARE_PINTEREST] ) {
357
- $target_sns[] = 'Pinterest';
358
- }
359
- */
360
- if ( isset( $this->share_base_cache_target[self::REF_SHARE_POCKET] ) && $this->share_base_cache_target[self::REF_SHARE_POCKET] ) {
361
- $target_sns[] = 'Pocket';
362
- }
363
- if ( isset( $this->share_base_cache_target[self::REF_SHARE_TWITTER] ) && $this->share_base_cache_target[self::REF_SHARE_TWITTER] ) {
364
- $target_sns[] = 'Twitter';
365
- }
366
- echo esc_html( implode( ", ", $target_sns ) );
367
- ?>
368
- </td>
369
- </tr>
370
- <tr>
371
- <td><?php _e( 'Share Base Cache', self::DOMAIN ); ?></td>
372
- <td><?php _e( 'Custom post types', self::DOMAIN ); ?></td>
373
- <td><?php
374
- if ( ! empty( $this->share_base_custom_post_types ) && $this->share_base_custom_post_types ) {
375
- echo esc_html( implode( ',', $this->share_base_custom_post_types ) );
376
- } else {
377
- _e( 'N/A', self::DOMAIN );
378
- }
379
- ?>
380
- </td>
381
- </tr>
382
- <tr>
383
- <td><?php _e( 'Share Base Cache', self::DOMAIN ); ?></td>
384
- <td><?php _e( 'Interval cheking share count (sec)', self::DOMAIN ); ?></td>
385
- <td><?php echo esc_html( $this->share_base_check_interval ) . ' ' . __( 'seconds', self::DOMAIN ); ?></td>
386
- </tr>
387
- <tr>
388
- <td><?php _e( 'Share Base Cache', self::DOMAIN ); ?></td>
389
- <td><?php _e( 'Number of contents to check at a time', self::DOMAIN ) ?></td>
390
- <td><?php echo esc_html( $this->share_base_posts_per_check ) . ' ' . __( 'contents', self::DOMAIN ); ?></td>
391
- </tr>
392
- <tr>
393
- <td><?php _e( 'Share Base Cache', self::DOMAIN ); ?></td>
394
- <td><?php _e( 'Scheme migration mode from http to https', self::DOMAIN ); ?></td>
395
- <td>
396
- <?php
397
- if ( $this->scheme_migration_mode ) {
398
- _e( 'On', self::DOMAIN );
399
- } else {
400
- _e( 'Off', self::DOMAIN );
401
- }
402
- ?>
403
- </td>
404
- </tr>
405
- <?php if ( $this->scheme_migration_mode ) { ?>
406
- <tr>
407
- <td><?php _e( 'Share Base Cache', self::DOMAIN ); ?></td>
408
- <td><?php _e( 'Scheme migration date from http to https', self::DOMAIN ); ?></td>
409
- <td>
410
- <?php
411
- if ( isset( $this->scheme_migration_date ) ) {
412
- echo esc_html( $this->scheme_migration_date );
413
- } else {
414
- _e( 'N/A', self::DOMAIN );
415
- }
416
- ?>
417
- </td>
418
- </tr>
419
- <?php } ?>
420
- <tr>
421
- <td><?php _e( 'Share Rush Cache', self::DOMAIN ); ?></td>
422
- <td><?php _e( 'Term considering posted content as new content', self::DOMAIN ); ?></td>
423
- <td>
424
- <?php
425
- if ( $this->share_rush_new_content_term == 1 ) {
426
- echo esc_html( $this->share_rush_new_content_term ) . ' ' . __( 'day', self::DOMAIN );
427
- } elseif ( $this->share_rush_new_content_term > 1 ) {
428
- echo esc_html( $this->share_rush_new_content_term ) . ' ' . __( 'days', self::DOMAIN );
429
- }
430
- ?>
431
- </td>
432
- </tr>
433
- <tr>
434
- <td><?php _e( 'Share Rush Cache', self::DOMAIN ); ?></td>
435
- <td><?php _e( 'Interval cheking share count (sec)', self::DOMAIN ); ?></td>
436
- <td>
437
- <?php
438
- echo esc_html( $this->share_rush_check_interval ) . ' ' . __( 'seconds', self::DOMAIN );
439
- ?>
440
- </td>
441
- </tr>
442
-
443
- <tr>
444
- <td><?php _e( 'Share Variation Analysis', self::DOMAIN ); ?></td>
445
- <td><?php _e( 'Method to update basis of comparison', self::DOMAIN ); ?></td><td>
446
- <?php
447
- switch ( $this->share_variation_analysis_mode ) {
448
- case self::OPT_SHARE_VARIATION_ANALYSIS_NONE:
449
- _e( 'Disabled (None)', self::DOMAIN );
450
- break;
451
- case self::OPT_SHARE_VARIATION_ANALYSIS_MANUAL:
452
- _e( 'Enabled (Manual)', self::DOMAIN );
453
- break;
454
- case self::OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER:
455
- _e( 'Enabled (Scheduler)', self::DOMAIN );
456
- break;
457
- }
458
- ?>
459
- </td>
460
- </tr>
461
- <?php
462
- if ( $this->share_variation_analysis_mode === self::OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER ) {
463
- ?>
464
- <tr>
465
- <td><?php _e( 'Share Variation Analysis', self::DOMAIN ); ?></td>
466
- <td><?php _e( 'Schedule', self::DOMAIN ); ?></td>
467
- <td><?php echo esc_html( $this->share_variation_analysis_schedule ); ?></td>
468
- </tr>
469
- <?php
470
- }
471
- ?>
472
- <tr>
473
- <td><?php _e( 'Follow Base Cache', self::DOMAIN); ?></td>
474
- <td><?php _e( 'Target SNS', self::DOMAIN ); ?></td>
475
- <td>
476
- <?php
477
- $target_sns = array();
478
- if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_FEEDLY] ) && $this->follow_base_cache_target[self::REF_FOLLOW_FEEDLY] ) {
479
- $target_sns[] = 'Feedly';
480
- }
481
- echo esc_html( implode( ', ', $target_sns ) );
482
- ?>
483
- </td>
484
- </tr>
485
- <tr>
486
- <td><?php _e( 'Follow Base Cache', self::DOMAIN ); ?></td>
487
- <td><?php _e( 'Interval cheking follower count (sec)', self::DOMAIN ); ?></td>
488
- <td><?php echo esc_html( $this->follow_base_check_interval ) . ' ' . __( 'seconds', self::DOMAIN ); ?></td>
489
- </tr>
490
- <?php if ( $this->follow_base_cache_target[self::REF_FOLLOW_FEEDLY] ) { ?>
491
- <tr>
492
- <td><?php _e( 'Follow Base Cache - Feedly', self::DOMAIN ); ?></td>
493
- <td><?php _e( 'Target feed type', self::DOMAIN ); ?></td>
494
- <td>
495
- <?php
496
- switch ( $this->follow_feed_type ) {
497
- case self::OPT_FEED_TYPE_DEFAULT:
498
- _e( 'Default', self::DOMAIN );
499
- break;
500
- case self::OPT_FEED_TYPE_RSS:
501
- _e( 'RSS', self::DOMAIN );
502
- break;
503
- case self::OPT_FEED_TYPE_RSS2:
504
- _e( 'RSS2', self::DOMAIN );
505
- break;
506
- case self::OPT_FEED_TYPE_RDF:
507
- _e( 'RDF', self::DOMAIN );
508
- break;
509
- case self::OPT_FEED_TYPE_ATOM:
510
- _e( 'ATOM', self::DOMAIN );
511
- break;
512
- default:
513
- _e( 'Default', self::DOMAIN );
514
- }
515
- ?>
516
- </td>
517
- </tr>
518
- <tr>
519
- <td><?php _e( 'Follow Base Cache - Feedly', self::DOMAIN ); ?></td>
520
- <td><?php _e( 'Target feed', self::DOMAIN ); ?></td>
521
- <td><?php echo get_feed_link( $this->follow_feed_type ); ?></td>
522
- </tr>
523
- <?php } ?>
524
- <tr>
525
- <td><?php _e( 'Dynamic Cache', self::DOMAIN); ?></td>
526
- <td><?php _e( 'Dynamic caching based on user access', self::DOMAIN ); ?></td><td>
527
- <?php
528
- switch ( $this->dynamic_cache_mode ) {
529
- case self::OPT_COMMON_ACCESS_BASED_CACHE_NONE:
530
- _e( 'Disabled (None)', self::DOMAIN );
531
- break;
532
- case self::OPT_COMMON_ACCESS_BASED_SYNC_CACHE:
533
- _e( 'Enabled (Synchronous Cache)', self::DOMAIN );
534
- break;
535
- case self::OPT_COMMON_ACCESS_BASED_ASYNC_CACHE:
536
- _e( 'Enabled (Asynchronous Cache)', self::DOMAIN );
537
- break;
538
- case self::OPT_COMMON_ACCESS_BASED_2ND_CACHE:
539
- _e( 'Enabled (Asynchronous 2nd Cache)', self::DOMAIN );
540
- break;
541
- }
542
- ?>
543
- </td>
544
- </tr>
545
- <tr>
546
- <td><?php _e( 'Data Crawler', self::DOMAIN ); ?></td>
547
- <td><?php _e( 'Crawl method', self::DOMAIN ); ?></td>
548
- <td>
549
- <?php
550
- switch ( $this->crawler_method ) {
551
- case self::OPT_COMMON_CRAWLER_METHOD_NORMAL:
552
- _e( 'Normal (Sequential Retrieval)', self::DOMAIN );
553
- break;
554
- case self::OPT_COMMON_CRAWLER_METHOD_CURL:
555
- _e( 'Extended (Parallel Retrieval)', self::DOMAIN );
556
- break;
557
- }
558
- ?>
559
- </td>
560
- </tr>
561
- <tr>
562
- <td><?php _e( 'Data Crawler', self::DOMAIN ); ?></td>
563
- <td><?php _e( 'SSL verification', self::DOMAIN ); ?></td>
564
- <td>
565
- <?php
566
- if ( $this->crawler_ssl_verification ) {
567
- _e( 'On', self::DOMAIN );
568
- } else {
569
- _e( 'Off', self::DOMAIN );
570
- }
571
- ?>
572
- </td>
573
- </tr>
574
- <tr>
575
- <td><?php _e( 'Data Export', self::DOMAIN ); ?></td>
576
- <td><?php _e( 'Method of data export', self::DOMAIN ); ?></td><td>
577
- <?php
578
- switch ( $this->data_export_mode ) {
579
- case self::OPT_COMMON_DATA_EXPORT_MANUAL:
580
- _e( 'Manual', self::DOMAIN );
581
- break;
582
- case self::OPT_COMMON_DATA_EXPORT_SCHEDULER:
583
- _e( 'Scheduler', self::DOMAIN );
584
- break;
585
- }
586
- ?>
587
- </td>
588
- </tr>
589
- <?php
590
- if ( $this->data_export_mode === self::OPT_COMMON_DATA_EXPORT_SCHEDULER ) {
591
- ?>
592
- <tr>
593
- <td><?php _e( 'Data Export', self::DOMAIN ); ?></td>
594
- <td><?php _e( 'Interval exporting share count to a csv file', self::DOMAIN ); ?></td>
595
- <td><?php echo esc_html( $this->data_export_interval / 3600 ) . ' ' . __( 'hours', self::DOMAIN ); ?></td>
596
- </tr>
597
- <?php
598
- }
599
- ?>
600
- </tbody>
601
- </table>
602
- </div>
603
- </div>
604
- </div>
605
- <div class="metabox-holder">
606
- <form action="admin.php?page=scc-setting" method="post">
607
- <?php wp_nonce_field( __FILE__, '_wpnonce' ); ?>
608
- <div id="share-base-cache" class="postbox">
609
- <div class="handlediv" title="Click to toggle"><br></div>
610
- <h3 class="hndle"><span><?php _e('Share Base Cache', self::DOMAIN); ?></span></h3>
611
- <div class="inside">
612
- <table class="form-table">
613
- <tr>
614
- <th><label><?php _e( 'Target SNS', self::DOMAIN ); ?></label></th>
615
- <td>
616
- <div class="sns-check">
617
- <input type="checkbox" value="1" name="share_base_cache_target_facebook"<?php if ( $this->share_base_cache_target[self::REF_SHARE_FACEBOOK] ) echo ' checked="checked"'; ?> />
618
- <label><?php _e( 'Facebook', self::DOMAIN ); ?></label>
619
- </div>
620
- <div class="sns-check">
621
- <input type="checkbox" value="1" name="share_base_cache_target_gplus"<?php if ( $this->share_base_cache_target[self::REF_SHARE_GPLUS] ) echo ' checked="checked"'; ?> />
622
- <label><?php _e( 'Google+', self::DOMAIN ); ?></label>
623
- </div>
624
- <div class="sns-check">
625
- <input type="checkbox" value="1" name="share_base_cache_target_hatebu"<?php if ( $this->share_base_cache_target[self::REF_SHARE_HATEBU] ) echo ' checked="checked"'; ?> />
626
- <label><?php _e( 'Hatena Bookmark', self::DOMAIN ); ?></label>
627
- </div>
628
- <div class="sns-check">
629
- <input type="checkbox" value="1" name="share_base_cache_target_pocket"<?php if ( $this->share_base_cache_target[self::REF_SHARE_POCKET] ) echo ' checked="checked"'; ?> />
630
- <label><?php _e( 'Pocket', self::DOMAIN ); ?></label>
631
- </div>
632
- <div class="sns-check">
633
- <input type="checkbox" value="1" name="share_base_cache_target_twitter"<?php if ( $this->share_base_cache_target[self::REF_SHARE_TWITTER] ) echo ' checked="checked"'; ?> />
634
- <label><?php _e( 'Twitter', self::DOMAIN ); ?></label>
635
- </div>
636
- </td>
637
- </tr>
638
- <tr>
639
- <th><label><?php _e( 'Custom post types', self::DOMAIN ); ?></label></th>
640
- <td>
641
- <input type="text" class="text" name="share_base_custom_post_types" size="60" value="<?php echo esc_html( implode( ',', $this->share_base_custom_post_types ) ); ?>" />
642
- <br>
643
- <label><?php _e( 'e.g. aaa, bbb, ccc (comma-delimited)', self::DOMAIN ); ?></label>
644
- </td>
645
- </tr>
646
- <tr>
647
- <th><label><?php _e( 'Interval cheking share count (sec)', self::DOMAIN ); ?></label></th>
648
- <td>
649
- <input type="text" class="text" name="share_base_check_interval" size="20" value="<?php echo esc_html( $this->share_base_check_interval ); ?>" />
650
- <label><?php _e( 'Default: 600', self::DOMAIN ); ?></label>
651
- </td>
652
- </tr>
653
- <tr>
654
- <th><label><?php _e( 'Number of contents to check at a time', self::DOMAIN ); ?></label></th>
655
- <td>
656
- <input type="text" class="text" name="share_base_posts_per_check" size="20" value="<?php echo esc_html( $this->share_base_posts_per_check ); ?>" />
657
- <label><?php _e( 'Default: 20', self::DOMAIN ); ?></label>
658
- </td>
659
- </tr>
660
- <tr>
661
- <th><label><?php _e( 'Scheme migration mode from http to https', self::DOMAIN ); ?></label></th>
662
- <td>
663
- <select name="scheme_migration_mode">
664
- <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>
665
- <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>
666
- </select>
667
- <label><?php _e('Default: Off', self::DOMAIN ); ?></label>
668
- </td>
669
- </tr>
670
- <?php if ( $this->scheme_migration_mode ) { ?>
671
- <tr>
672
- <th><label><?php _e( 'Scheme migration date from http to https', self::DOMAIN ); ?></label></th>
673
- <td>
674
- <input id="scheme-migration-date" type="text" class="text" name="scheme_migration_date" size="20" value="<?php echo esc_html( $this->scheme_migration_date ); ?>" />
675
- <label><?php _e( 'Default: N/A', self::DOMAIN ); ?></label>
676
- <script>
677
- jQuery(document).ready(function() {
678
- jQuery('#scheme-migration-date').datepicker({
679
- dateFormat : 'yy/mm/dd'
680
- });
681
- });
682
- </script>
683
- </td>
684
- </tr>
685
- <?php } ?>
686
- </table>
687
- <div class="submit-button">
688
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
689
- <input type="submit" class="button" name="clear_share_base_cache" value="<?php _e( 'Clear Cache', self::DOMAIN ); ?>">
690
- </div>
691
- </div>
692
- </div>
693
- <div id="share-rush-cache" class="postbox">
694
- <div class="handlediv" title="Click to toggle"><br></div>
695
- <h3 class="hndle"><span><?php _e( 'Share Rush Cache', self::DOMAIN); ?></span></h3>
696
- <div class="inside">
697
- <table class="form-table">
698
- <tr>
699
- <th><label><?php _e( 'Term considering posted content as new content', self::DOMAIN ); ?></label></th>
700
- <td>
701
- <select name="share_rush_new_content_term">
702
- <option value="1"<?php if ( $this->share_rush_new_content_term === 1 ) echo ' selected="selected"'; ?>><?php _e( '1 day', self::DOMAIN ); ?></option>
703
- <option value="2"<?php if ( $this->share_rush_new_content_term === 2 ) echo ' selected="selected"'; ?>><?php _e( '2 days', self::DOMAIN ); ?></option>
704
- <option value="3"<?php if ( $this->share_rush_new_content_term === 3 ) echo ' selected="selected"'; ?>><?php _e( '3 days', self::DOMAIN ); ?></option>
705
- <option value="4"<?php if ( $this->share_rush_new_content_term === 4 ) echo ' selected="selected"'; ?>><?php _e( '4 days', self::DOMAIN ); ?></option>
706
- <option value="5"<?php if ( $this->share_rush_new_content_term === 5 ) echo ' selected="selected"'; ?>><?php _e( '5 days', self::DOMAIN ); ?></option>
707
- <option value="6"<?php if ( $this->share_rush_new_content_term === 6 ) echo ' selected="selected"'; ?>><?php _e( '6 days', self::DOMAIN ); ?></option>
708
- <option value="7"<?php if ( $this->share_rush_new_content_term === 7 ) echo ' selected="selected"'; ?>><?php _e( '7 days', self::DOMAIN ); ?></option>
709
- <option value="8"<?php if ( $this->share_rush_new_content_term === 8 ) echo ' selected="selected"'; ?>><?php _e( '8 days', self::DOMAIN ); ?></option>
710
- <option value="9"<?php if ( $this->share_rush_new_content_term === 9 ) echo ' selected="selected"'; ?>><?php _e( '9 days', self::DOMAIN ); ?></option>
711
- <option value="10"<?php if ( $this->share_rush_new_content_term === 10 ) echo ' selected="selected"'; ?>><?php _e( '10 days', self::DOMAIN ); ?></option>
712
- <option value="11"<?php if ( $this->share_rush_new_content_term === 11 ) echo ' selected="selected"'; ?>><?php _e( '11 days', self::DOMAIN ); ?></option>
713
- <option value="12"<?php if ( $this->share_rush_new_content_term === 12 ) echo ' selected="selected"'; ?>><?php _e( '12 days', self::DOMAIN ); ?></option>
714
- <option value="13"<?php if ( $this->share_rush_new_content_term === 13 ) echo ' selected="selected"'; ?>><?php _e( '13 days', self::DOMAIN ); ?></option>
715
- <option value="14"<?php if ( $this->share_rush_new_content_term === 14 ) echo ' selected="selected"'; ?>><?php _e( '14 days', self::DOMAIN ); ?></option>
716
- </select>
717
- <label><?php _e( 'Default: 3 days', self::DOMAIN ); ?></label>
718
- </td>
719
- </tr>
720
-
721
- <tr>
722
- <th><label><?php _e( 'Interval cheking share count (sec)', self::DOMAIN ); ?></label></th>
723
- <td>
724
- <?php
725
- echo esc_html( $this->share_rush_check_interval ) . ' ' . __( 'seconds', self::DOMAIN );
726
- ?>
727
- </td>
728
- </tr>
729
-
730
- </table>
731
- <div class="submit-button">
732
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
733
- </div>
734
- </div>
735
- </div>
736
- <div id="share-variation-analysis" class="postbox">
737
- <div class="handlediv" title="Click to toggle"><br></div>
738
- <h3 class="hndle"><span><?php _e('Share Variation Analysis', self::DOMAIN); ?></span></h3>
739
- <div class="inside">
740
- <table class="form-table">
741
- <tr>
742
- <th><label><?php _e( 'Method to update basis of comparison', self::DOMAIN ); ?></label></th>
743
- <td>
744
- <select name="share_variation_analysis_mode">
745
- <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>
746
- <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>
747
- <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>
748
- </select>
749
- <label><?php _e( 'Default: None', self::DOMAIN ); ?></label>
750
- </td>
751
- </tr>
752
-
753
- <?php
754
- if ( $this->share_variation_analysis_mode === self::OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER ) {
755
-
756
- list( $cronstr['minutes'], $cronstr['hours'], $cronstr['mday'], $cronstr['mon'], $cronstr['wday'] ) = explode( ' ', $this->share_variation_analysis_schedule, 5 );
757
- if ( strstr( $cronstr['minutes'], '*/' ) ) {
758
- $minutes = explode( '/', $cronstr['minutes'] );
759
- } else {
760
- $minutes = explode( ',', $cronstr['minutes'] );
761
- }
762
- if ( strstr( $cronstr['hours'], '*/' ) ) {
763
- $hours = explode( '/', $cronstr['hours'] );
764
- } else {
765
- $hours = explode( ',', $cronstr['hours'] );
766
- }
767
- if ( strstr( $cronstr['mday'], '*/' ) ) {
768
- $mday = explode( '/', $cronstr['mday'] );
769
- } else {
770
- $mday = explode( ',', $cronstr['mday'] );
771
- }
772
- if ( strstr( $cronstr['mon'], '*/' ) ) {
773
- $mon = explode( '/', $cronstr['mon'] );
774
- } else {
775
- $mon = explode( ',', $cronstr['mon'] );
776
- }
777
- if ( strstr( $cronstr['wday'], '*/' ) ) {
778
- $wday = explode( '/', $cronstr['wday'] );
779
- } else {
780
- $wday = explode( ',', $cronstr['wday'] );
781
- }
782
- ?>
783
- <tr class="a_wpcron">
784
- <th scope="row"><?php _e( 'Scheduler', self::DOMAIN ); ?></th>
785
- <td>
786
- <table class="wpcron">
787
- <tr>
788
- <th>
789
- <?php _e( 'Type', self::DOMAIN ); ?>
790
- </th>
791
- <th>
792
- </th>
793
- <th>
794
- <?php _e( 'Hour', self::DOMAIN ); ?>
795
- </th>
796
- <th>
797
- <?php _e( 'Minute', self::DOMAIN ); ?>
798
- </th>
799
- </tr>
800
- <tr>
801
- <td>
802
- <label for="idcronbtype-mon">
803
- <?php echo '<input class="radio" type="radio"' . checked( TRUE, is_numeric( $mday[0] ), FALSE ) . ' name="a_cronbtype" value="mon" /> ' . __( 'monthly', self::DOMAIN ); ?>
804
- </label>
805
- </td>
806
- <td>
807
- <select name="a_moncronmday">
808
- <?php for ( $i = 1; $i <= 31; $i ++ ) {
809
- $on_day = '';
810
- switch ( $i ) {
811
- case 1:
812
- $on_day = __( 'on 1.', self::DOMAIN );
813
- break;
814
- case 2:
815
- $on_day = __( 'on 2.', self::DOMAIN );
816
- break;
817
- case 3:
818
- $on_day = __( 'on 3.', self::DOMAIN );
819
- break;
820
- case 4:
821
- $on_day = __( 'on 4.', self::DOMAIN );
822
- break;
823
- case 5:
824
- $on_day = __( 'on 5.', self::DOMAIN );
825
- break;
826
- case 6:
827
- $on_day = __( 'on 6.', self::DOMAIN );
828
- break;
829
- case 7:
830
- $on_day = __( 'on 7.', self::DOMAIN );
831
- break;
832
- case 8:
833
- $on_day = __( 'on 8.', self::DOMAIN );
834
- break;
835
- case 9:
836
- $on_day = __( 'on 9.', self::DOMAIN );
837
- break;
838
- case 10:
839
- $on_day = __( 'on 10.', self::DOMAIN );
840
- break;
841
- case 11:
842
- $on_day = __( 'on 11.', self::DOMAIN );
843
- break;
844
- case 12:
845
- $on_day = __( 'on 12.', self::DOMAIN );
846
- break;
847
- case 13:
848
- $on_day = __( 'on 13.', self::DOMAIN );
849
- break;
850
- case 14:
851
- $on_day = __( 'on 14.', self::DOMAIN );
852
- break;
853
- case 15:
854
- $on_day = __( 'on 15.', self::DOMAIN );
855
- break;
856
- case 16:
857
- $on_day = __( 'on 16.', self::DOMAIN );
858
- break;
859
- case 17:
860
- $on_day = __( 'on 17.', self::DOMAIN );
861
- break;
862
- case 18:
863
- $on_day = __( 'on 18.', self::DOMAIN );
864
- break;
865
- case 19:
866
- $on_day = __( 'on 19.', self::DOMAIN );
867
- break;
868
- case 20:
869
- $on_day = __( 'on 20.', self::DOMAIN );
870
- break;
871
- case 21:
872
- $on_day = __( 'on 21.', self::DOMAIN );
873
- break;
874
- case 22:
875
- $on_day = __( 'on 22.', self::DOMAIN );
876
- break;
877
- case 23:
878
- $on_day = __( 'on 23.', self::DOMAIN );
879
- break;
880
- case 24:
881
- $on_day = __( 'on 24.', self::DOMAIN );
882
- break;
883
- case 25:
884
- $on_day = __( 'on 25.', self::DOMAIN );
885
- break;
886
- case 26:
887
- $on_day = __( 'on 26.', self::DOMAIN );
888
- break;
889
- case 27:
890
- $on_day = __( 'on 27.', self::DOMAIN );
891
- break;
892
- case 28:
893
- $on_day = __( 'on 28.', self::DOMAIN );
894
- break;
895
- case 29:
896
- $on_day = __( 'on 29.', self::DOMAIN );
897
- break;
898
- case 30:
899
- $on_day = __( 'on 30.', self::DOMAIN );
900
- break;
901
- case 31:
902
- $on_day = __( 'on 31.', self::DOMAIN );
903
- break;
904
- }
905
-
906
- echo '<option ' . selected( in_array( "$i", $mday, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $on_day . '</option>';
907
- } ?>
908
- </select>
909
- </td>
910
- <td>
911
- <select name="a_moncronhours">
912
- <?php for ( $i = 0; $i < 24; $i ++ ) {
913
- echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
914
- } ?>
915
- </select>
916
- </td>
917
- <td>
918
- <select name="a_moncronminutes">
919
- <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
920
- echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
921
- } ?>
922
- </select>
923
- </td>
924
- </tr>
925
- <tr>
926
- <td>
927
- <label for="idcronbtype-week">
928
- <?php echo '<input class="radio" type="radio"' . checked( TRUE, is_numeric( $wday[0] ), FALSE ) . ' name="a_cronbtype" value="week" /> ' . __( 'weekly', self::DOMAIN ); ?>
929
- </label>
930
- </td>
931
- <td>
932
- <select name="a_weekcronwday">
933
- <?php echo '<option ' . selected( in_array( '0', $wday, TRUE ), TRUE, FALSE ) . ' value="0" />' . __( 'Sunday', self::DOMAIN ) . '</option>';
934
- echo '<option ' . selected( in_array( '1', $wday, TRUE ), TRUE, FALSE ) . ' value="1" />' . __( 'Monday', self::DOMAIN ) . '</option>';
935
- echo '<option ' . selected( in_array( '2', $wday, TRUE ), TRUE, FALSE ) . ' value="2" />' . __( 'Tuesday', self::DOMAIN ) . '</option>';
936
- echo '<option ' . selected( in_array( '3', $wday, TRUE ), TRUE, FALSE ) . ' value="3" />' . __( 'Wednesday', self::DOMAIN ) . '</option>';
937
- echo '<option ' . selected( in_array( '4', $wday, TRUE ), TRUE, FALSE ) . ' value="4" />' . __( 'Thursday', self::DOMAIN ) . '</option>';
938
- echo '<option ' . selected( in_array( '5', $wday, TRUE ), TRUE, FALSE ) . ' value="5" />' . __( 'Friday', self::DOMAIN ) . '</option>';
939
- echo '<option ' . selected( in_array( '6', $wday, TRUE ), TRUE, FALSE ) . ' value="6" />' . __( 'Saturday', self::DOMAIN ) . '</option>'; ?>
940
- </select>
941
- </td>
942
- <td>
943
- <select name="a_weekcronhours">
944
- <?php for ( $i = 0; $i < 24; $i ++ ) {
945
- echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
946
- } ?>
947
- </select>
948
- </td>
949
- <td>
950
- <select name="a_weekcronminutes">
951
- <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
952
- echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
953
- } ?></select>
954
- </td>
955
- </tr>
956
- <tr>
957
- <td>
958
- <label for="idcronbtype-day">
959
- <?php echo '<input class="radio" type="radio"' . checked( "**", $mday[0] . $wday[0], FALSE ) . ' name="a_cronbtype" value="day" /> ' . __( 'daily', self::DOMAIN ); ?>
960
- </label>
961
- </td>
962
- <td>
963
- </td>
964
- <td>
965
- <select name="a_daycronhours">
966
- <?php for ( $i = 0; $i < 24; $i ++ ) {
967
- echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
968
- } ?>
969
- </select>
970
- </td>
971
- <td>
972
- <select name="a_daycronminutes">
973
- <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
974
- echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
975
- } ?>
976
- </select>
977
- </td>
978
- </tr>
979
- </table>
980
- </td>
981
- </tr>
982
- <?php
983
- }
984
- ?>
985
- </table>
986
- <div class="submit-button">
987
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
988
- <input type="submit" class="button" name="update_share_comparison_base" value="<?php _e( 'Update Basis of Comparison', self::DOMAIN ); ?>" />
989
- </div>
990
- </div>
991
- </div>
992
- <div id="follow-base-cache" class="postbox">
993
- <div class="handlediv" title="Click to toggle"><br></div>
994
- <h3 class="hndle"><span><?php _e( 'Follow Base Cache', self::DOMAIN ); ?></span></h3>
995
- <div class="inside">
996
- <table class="form-table">
997
- <tr>
998
- <th><label><?php _e( 'Target SNS', self::DOMAIN ); ?></label></th>
999
- <td>
1000
- <div class="sns-check">
1001
- <input type="checkbox" value="1" name="follow_base_cache_target_feedly"<?php if ( $this->follow_base_cache_target[self::REF_FOLLOW_FEEDLY] ) echo ' checked="checked"'; ?> />
1002
- <label><?php _e( 'Feedly', self::DOMAIN ); ?></label>
1003
- </div>
1004
- </td>
1005
- </tr>
1006
- <tr>
1007
- <th><label><?php _e( 'Interval cheking follower count (sec)', self::DOMAIN ); ?></label></th>
1008
- <td>
1009
- <input type="text" class="text" name="follow_base_check_interval" size="20" value="<?php echo esc_html( $this->follow_base_check_interval); ?>" />
1010
- <label><?php _e( 'Default: 86400 Minimum: 3600', self::DOMAIN ); ?></label>
1011
- </td>
1012
- </tr>
1013
- </table>
1014
- <div class="submit-button">
1015
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1016
- <input type="submit" class="button" name="clear_follow_base_cache" value="<?php _e( 'Clear Cache', self::DOMAIN ); ?>">
1017
- </div>
1018
- </div>
1019
- </div>
1020
- <?php if ( $this->follow_base_cache_target[self::REF_FOLLOW_FEEDLY] ) { ?>
1021
- <div id="follow-base-cache-feedly" class="postbox">
1022
- <div class="handlediv" title="Click to toggle"><br></div>
1023
- <h3 class="hndle"><span><?php _e( 'Follow Base Cache - Feedly', self::DOMAIN ); ?></span></h3>
1024
- <div class="inside">
1025
- <table class="form-table">
1026
- <tr>
1027
- <th><label><?php _e( 'Target feed type', self::DOMAIN ); ?></label></th>
1028
- <td>
1029
- <select name="follow_feed_type">
1030
- <option value="default"<?php if ( $this->follow_feed_type === self::OPT_FEED_TYPE_DEFAULT ) echo ' selected="selected"'; ?>><?php _e( 'Default', self::DOMAIN ) ?></option>
1031
- <option value="rss"<?php if ( $this->follow_feed_type === self::OPT_FEED_TYPE_RSS ) echo ' selected="selected"'; ?>><?php _e( 'RSS', self::DOMAIN ); ?></option>
1032
- <option value="rss2"<?php if ( $this->follow_feed_type === self::OPT_FEED_TYPE_RSS2 ) echo ' selected="selected"'; ?>><?php _e( 'RSS2', self::DOMAIN ); ?></option>
1033
- <option value="rdf"<?php if ( $this->follow_feed_type === self::OPT_FEED_TYPE_RDF ) echo ' selected="selected"'; ?>><?php _e( 'RDF', self::DOMAIN ); ?></option>
1034
- <option value="atom"<?php if ( $this->follow_feed_type === self::OPT_FEED_TYPE_ATOM ) echo ' selected="selected"'; ?>><?php _e( 'ATOM', self::DOMAIN ); ?></option>
1035
- </select>
1036
- <label><?php _e( 'Default: Default', self::DOMAIN ); ?></label>
1037
- </td>
1038
- </tr>
1039
- <tr>
1040
- <th><label><?php _e( 'Target feed', self::DOMAIN ); ?></label></th>
1041
- <td><?php echo get_feed_link( $this->follow_feed_type ); ?></td>
1042
- </tr>
1043
- </table>
1044
- <div class="submit-button">
1045
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1046
- </div>
1047
- </div>
1048
- </div>
1049
- <?php } ?>
1050
- <div id="common-dynamic-cache" class="postbox">
1051
- <div class="handlediv" title="Click to toggle"><br></div>
1052
- <h3 class="hndle"><span><?php _e( 'Dynamic Cache', self::DOMAIN ); ?></span></h3>
1053
- <div class="inside">
1054
- <table class="form-table">
1055
- <tr>
1056
- <th><label><?php _e( 'Dynamic caching based on user access', self::DOMAIN ); ?></label></th>
1057
- <td>
1058
- <select name="dynamic_cache_mode">
1059
- <option value="1"<?php if ( $this->dynamic_cache_mode === self::OPT_COMMON_ACCESS_BASED_CACHE_NONE ) echo ' selected="selected"'; ?>><?php _e( 'Disabled (None)', self::DOMAIN ); ?></option>
1060
- <option value="2"<?php if ( $this->dynamic_cache_mode === self::OPT_COMMON_ACCESS_BASED_SYNC_CACHE ) echo ' selected="selected"'; ?>><?php _e( 'Enabled (Synchronous Cache)', self::DOMAIN ); ?></option>
1061
- <option value="3"<?php if ( $this->dynamic_cache_mode === self::OPT_COMMON_ACCESS_BASED_ASYNC_CACHE ) echo ' selected="selected"'; ?>><?php _e( 'Enabled (Asynchronous Cache)', self::DOMAIN ); ?></option>
1062
- <option value="4"<?php if ( $this->dynamic_cache_mode === self::OPT_COMMON_ACCESS_BASED_2ND_CACHE ) echo ' selected="selected"'; ?>><?php _e( 'Enabled (Asynchronous 2nd Cache)', self::DOMAIN ); ?></option>
1063
- </select>
1064
- <label><?php _e( 'Default: Enabled (Asynchronous 2nd Cache)', self::DOMAIN ); ?></label>
1065
- </td>
1066
- </tr>
1067
- </table>
1068
- <div class="submit-button">
1069
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1070
- </div>
1071
- </div>
1072
- </div>
1073
- <div id="common-data-crawler" class="postbox">
1074
- <div class="handlediv" title="Click to toggle"><br></div>
1075
- <h3 class="hndle"><span><?php _e( 'Data Crawler', self::DOMAIN ); ?></span></h3>
1076
- <div class="inside">
1077
- <table class="form-table">
1078
- <tr>
1079
- <th><label><?php _e( 'Crawl method', self::DOMAIN ); ?></label></th>
1080
- <td>
1081
- <?php
1082
- switch ( $this->crawler_method ) {
1083
- case self::OPT_COMMON_CRAWLER_METHOD_NORMAL:
1084
- _e( 'Normal (Sequential Retrieval)', self::DOMAIN );
1085
- break;
1086
- case self::OPT_COMMON_CRAWLER_METHOD_CURL:
1087
- _e( 'Extended (Parallel Retrieval)', self::DOMAIN );
1088
- break;
1089
- }
1090
- ?>
1091
- </td>
1092
- </tr>
1093
- <tr>
1094
- <th><label><?php _e( 'SSL verification', self::DOMAIN ); ?></label></th>
1095
- <td>
1096
- <select name="crawler_ssl_verification">
1097
- <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>
1098
- <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>
1099
- </select>
1100
- <label><?php _e( 'Default: On', self::DOMAIN ); ?></label>
1101
- </td>
1102
- </tr>
1103
- </table>
1104
- <div class="submit-button">
1105
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1106
- </div>
1107
- </div>
1108
- </div>
1109
- <div id="common-data-export" class="postbox">
1110
- <div class="handlediv" title="Click to toggle"><br></div>
1111
- <h3 class="hndle"><span><?php _e( 'Data Export', self::DOMAIN ); ?></span></h3>
1112
- <div class="inside">
1113
- <table class="form-table">
1114
- <tr>
1115
- <th><label><?php _e( 'Method of data export', self::DOMAIN ); ?></label></th>
1116
- <td>
1117
- <select name="data_export_mode">
1118
- <option value="1"<?php if ( $this->data_export_mode === self::OPT_COMMON_DATA_EXPORT_MANUAL ) echo ' selected="selected"'; ?>><?php _e( 'Manual', self::DOMAIN ); ?></option>
1119
- <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>
1120
- </select>
1121
- <label><?php _e( 'Default: Manual', self::DOMAIN ); ?></label>
1122
- </td>
1123
- </tr>
1124
- <?php
1125
- if ( $this->data_export_mode === self::OPT_COMMON_DATA_EXPORT_SCHEDULER ) {
1126
-
1127
- list( $cronstr[ 'minutes' ], $cronstr[ 'hours' ], $cronstr[ 'mday' ], $cronstr[ 'mon' ], $cronstr[ 'wday' ] ) = explode( ' ', $this->data_export_schedule, 5 );
1128
- if ( strstr( $cronstr[ 'minutes' ], '*/' ) ) {
1129
- $minutes = explode( '/', $cronstr[ 'minutes' ] );
1130
- } else {
1131
- $minutes = explode( ',', $cronstr[ 'minutes' ] );
1132
- }
1133
- if ( strstr( $cronstr[ 'hours' ], '*/' ) ) {
1134
- $hours = explode( '/', $cronstr[ 'hours' ] );
1135
- } else {
1136
- $hours = explode( ',', $cronstr[ 'hours' ] );
1137
- }
1138
- if ( strstr( $cronstr[ 'mday' ], '*/' ) ) {
1139
- $mday = explode( '/', $cronstr[ 'mday' ] );
1140
- } else {
1141
- $mday = explode( ',', $cronstr[ 'mday' ] );
1142
- }
1143
- if ( strstr( $cronstr[ 'mon' ], '*/' ) ) {
1144
- $mon = explode( '/', $cronstr[ 'mon' ] );
1145
- } else {
1146
- $mon = explode( ',', $cronstr[ 'mon' ] );
1147
- }
1148
- if ( strstr( $cronstr[ 'wday' ], '*/' ) ) {
1149
- $wday = explode( '/', $cronstr[ 'wday' ] );
1150
- } else {
1151
- $wday = explode( ',', $cronstr[ 'wday' ] );
1152
- }
1153
- ?>
1154
- <tr class="e_wpcron">
1155
- <th scope="row"><?php _e( 'Scheduler', self::DOMAIN ); ?></th>
1156
- <td>
1157
- <table class="wpcron">
1158
- <tr>
1159
- <th>
1160
- <?php _e( 'Type', self::DOMAIN ); ?>
1161
- </th>
1162
- <th>
1163
- </th>
1164
- <th>
1165
- <?php _e( 'Hour', self::DOMAIN ); ?>
1166
- </th>
1167
- <th>
1168
- <?php _e( 'Minute', self::DOMAIN ); ?>
1169
- </th>
1170
- </tr>
1171
- <tr>
1172
- <td>
1173
- <label for="idcronbtype-mon">
1174
- <?php echo '<input class="radio" type="radio"' . checked( TRUE, is_numeric( $mday[0] ), FALSE ) . ' name="e_cronbtype" value="mon" /> ' . __( 'monthly', self::DOMAIN ); ?>
1175
- </label>
1176
- </td>
1177
- <td>
1178
- <select name="e_moncronmday">
1179
- <?php for ( $i = 1; $i <= 31; $i ++ ) {
1180
- $on_day = '';
1181
- switch ( $i ) {
1182
- case 1:
1183
- $on_day = __( 'on 1.', self::DOMAIN );
1184
- break;
1185
- case 2:
1186
- $on_day = __( 'on 2.', self::DOMAIN );
1187
- break;
1188
- case 3:
1189
- $on_day = __( 'on 3.', self::DOMAIN );
1190
- break;
1191
- case 4:
1192
- $on_day = __( 'on 4.', self::DOMAIN );
1193
- break;
1194
- case 5:
1195
- $on_day = __( 'on 5.', self::DOMAIN );
1196
- break;
1197
- case 6:
1198
- $on_day = __( 'on 6.', self::DOMAIN );
1199
- break;
1200
- case 7:
1201
- $on_day = __( 'on 7.', self::DOMAIN );
1202
- break;
1203
- case 8:
1204
- $on_day = __( 'on 8.', self::DOMAIN );
1205
- break;
1206
- case 9:
1207
- $on_day = __( 'on 9.', self::DOMAIN );
1208
- break;
1209
- case 10:
1210
- $on_day = __( 'on 10.', self::DOMAIN );
1211
- break;
1212
- case 11:
1213
- $on_day = __( 'on 11.', self::DOMAIN );
1214
- break;
1215
- case 12:
1216
- $on_day = __( 'on 12.', self::DOMAIN );
1217
- break;
1218
- case 13:
1219
- $on_day = __( 'on 13.', self::DOMAIN );
1220
- break;
1221
- case 14:
1222
- $on_day = __( 'on 14.', self::DOMAIN );
1223
- break;
1224
- case 15:
1225
- $on_day = __( 'on 15.', self::DOMAIN );
1226
- break;
1227
- case 16:
1228
- $on_day = __( 'on 16.', self::DOMAIN );
1229
- break;
1230
- case 17:
1231
- $on_day = __( 'on 17.', self::DOMAIN );
1232
- break;
1233
- case 18:
1234
- $on_day = __( 'on 18.', self::DOMAIN );
1235
- break;
1236
- case 19:
1237
- $on_day = __( 'on 19.', self::DOMAIN );
1238
- break;
1239
- case 20:
1240
- $on_day = __( 'on 20.', self::DOMAIN );
1241
- break;
1242
- case 21:
1243
- $on_day = __( 'on 21.', self::DOMAIN );
1244
- break;
1245
- case 22:
1246
- $on_day = __( 'on 22.', self::DOMAIN );
1247
- break;
1248
- case 23:
1249
- $on_day = __( 'on 23.', self::DOMAIN );
1250
- break;
1251
- case 24:
1252
- $on_day = __( 'on 24.', self::DOMAIN );
1253
- break;
1254
- case 25:
1255
- $on_day = __( 'on 25.', self::DOMAIN );
1256
- break;
1257
- case 26:
1258
- $on_day = __( 'on 26.', self::DOMAIN );
1259
- break;
1260
- case 27:
1261
- $on_day = __( 'on 27.', self::DOMAIN );
1262
- break;
1263
- case 28:
1264
- $on_day = __( 'on 28.', self::DOMAIN );
1265
- break;
1266
- case 29:
1267
- $on_day = __( 'on 29.', self::DOMAIN );
1268
- break;
1269
- case 30:
1270
- $on_day = __( 'on 30.', self::DOMAIN );
1271
- break;
1272
- case 31:
1273
- $on_day = __( 'on 31.', self::DOMAIN );
1274
- break;
1275
- }
1276
-
1277
- echo '<option ' . selected( in_array( "$i", $mday, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $on_day . '</option>';
1278
- } ?>
1279
- </select>
1280
- </td>
1281
- <td>
1282
- <select name="e_moncronhours">
1283
- <?php for ( $i = 0; $i < 24; $i ++ ) {
1284
- echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1285
- } ?>
1286
- </select>
1287
- </td>
1288
- <td>
1289
- <select name="e_moncronminutes">
1290
- <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
1291
- echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1292
- } ?>
1293
- </select>
1294
- </td>
1295
- </tr>
1296
- <tr>
1297
- <td>
1298
- <label for="idcronbtype-week">
1299
- <?php echo '<input class="radio" type="radio"' . checked( TRUE, is_numeric( $wday[0] ), FALSE ) . ' name="e_cronbtype" value="week" /> ' . __( 'weekly', self::DOMAIN ); ?>
1300
- </label>
1301
- </td>
1302
- <td>
1303
- <select name="e_weekcronwday">
1304
- <?php echo '<option ' . selected( in_array( '0', $wday, TRUE ), TRUE, FALSE ) . ' value="0" />' . __( 'Sunday', self::DOMAIN ) . '</option>';
1305
- echo '<option ' . selected( in_array( '1', $wday, TRUE ), TRUE, FALSE ) . ' value="1" />' . __( 'Monday', self::DOMAIN ) . '</option>';
1306
- echo '<option ' . selected( in_array( '2', $wday, TRUE ), TRUE, FALSE ) . ' value="2" />' . __( 'Tuesday', self::DOMAIN ) . '</option>';
1307
- echo '<option ' . selected( in_array( '3', $wday, TRUE ), TRUE, FALSE ) . ' value="3" />' . __( 'Wednesday', self::DOMAIN ) . '</option>';
1308
- echo '<option ' . selected( in_array( '4', $wday, TRUE ), TRUE, FALSE ) . ' value="4" />' . __( 'Thursday', self::DOMAIN ) . '</option>';
1309
- echo '<option ' . selected( in_array( '5', $wday, TRUE ), TRUE, FALSE ) . ' value="5" />' . __( 'Friday', self::DOMAIN ) . '</option>';
1310
- echo '<option ' . selected( in_array( '6', $wday, TRUE ), TRUE, FALSE ) . ' value="6" />' . __( 'Saturday', self::DOMAIN ) . '</option>'; ?>
1311
- </select>
1312
- </td>
1313
- <td>
1314
- <select name="e_weekcronhours">
1315
- <?php for ( $i = 0; $i < 24; $i ++ ) {
1316
- echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1317
- } ?>
1318
- </select>
1319
- </td>
1320
- <td>
1321
- <select name="e_weekcronminutes">
1322
- <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
1323
- echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1324
- } ?></select>
1325
- </td>
1326
- </tr>
1327
- <tr>
1328
- <td>
1329
- <label for="idcronbtype-day">
1330
- <?php echo '<input class="radio" type="radio"' . checked( "**", $mday[0] . $wday[0], FALSE ) . ' name="e_cronbtype" value="day" /> ' . __( 'daily', self::DOMAIN ); ?>
1331
- </label>
1332
- </td>
1333
- <td>
1334
- </td>
1335
- <td>
1336
- <select name="e_daycronhours">
1337
- <?php for ( $i = 0; $i < 24; $i ++ ) {
1338
- echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1339
- } ?>
1340
- </select>
1341
- </td>
1342
- <td>
1343
- <select name="e_daycronminutes">
1344
- <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
1345
- echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1346
- } ?>
1347
- </select>
1348
- </td>
1349
- </tr>
1350
- <tr>
1351
- <td>
1352
- <label for="idcronbtype-hour">
1353
- <?php echo '<input class="radio" type="radio"' . checked( "*", $hours[0], FALSE, FALSE ) . ' name="e_cronbtype" value="hour" /> ' . __( 'hourly', self::DOMAIN ); ?>
1354
- </label>
1355
- </td>
1356
- <td></td>
1357
- <td></td>
1358
- <td>
1359
- <select name="e_hourcronminutes">
1360
- <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
1361
- echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1362
- } ?>
1363
- </select>
1364
- </td>
1365
- </tr>
1366
- </table>
1367
- </td>
1368
- </tr>
1369
- <?php
1370
- }
1371
- ?>
1372
- </table>
1373
- <div class="submit-button">
1374
- <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1375
- </div>
1376
- </div>
1377
- </div>
1378
- </form>
1379
- </div>
1380
- <div class="metabox-holder">
1381
- <div id="common-exported-file" class="postbox">
1382
- <div class="handlediv" title="Click to toggle"><br></div>
1383
- <h3 class="hndle"><span><?php _e( 'Exported File', self::DOMAIN ); ?></span></h3>
1384
- <div class="inside">
1385
- <table class="form-table">
1386
- <tbody>
1387
- <tr>
1388
- <th><?php _e( 'Disk usage of exported file', self::DOMAIN ); ?></th>
1389
- <td>
1390
- <?php
1391
- $abs_path = WP_PLUGIN_DIR . '/sns-count-cache/data/sns-count-cache-data.csv';
1392
- $file_size = Common_Util::get_file_size( $abs_path );
1393
-
1394
- if ( isset( $file_size ) ) {
1395
- echo $file_size;
1396
- } else {
1397
- _e( 'No exported file', self::DOMAIN );
1398
- }
1399
- ?>
1400
- </td>
1401
- </tr>
1402
- </tbody>
1403
- </table>
1404
- <form action="admin.php?page=scc-setting" method="post">
1405
- <?php wp_nonce_field( __FILE__, '_wpnonce' ); ?>
1406
- <table class="form-table">
1407
- <tbody>
1408
- <tr>
1409
- <th><?php _e( 'Manual export', self::DOMAIN ); ?></th>
1410
- <td>
1411
- <input type="submit" class="button" name="export_data" value="<?php _e( 'Export', self::DOMAIN ); ?>" />
1412
- <br>
1413
- <span class="description"><?php _e( 'Export share count to a csv file.', self::DOMAIN ); ?></span>
1414
- </td>
1415
- </tr>
1416
- </tbody>
1417
- </table>
1418
- </form>
1419
- <?php
1420
- if ( file_exists( $abs_path ) ) {
1421
- ?>
1422
- <form action="admin.php?page=scc-setting" method="post">
1423
- <?php wp_nonce_field( __FILE__, '_wpnonce' ); ?>
1424
- <table class="form-table">
1425
- <tbody>
1426
- <tr>
1427
- <th><?php _e( 'Reset of exported file', self::DOMAIN ); ?></th>
1428
- <td>
1429
- <input type="submit" class="button" name="reset_data" value="<?php _e( 'Reset', self::DOMAIN ); ?>" />
1430
- <br>
1431
- <span class="description"><?php _e( 'Clear exported csv file.', self::DOMAIN ); ?></span>
1432
- </td>
1433
- </tr>
1434
- </tbody>
1435
- </table>
1436
- </form>
1437
- <form action="<?php echo plugins_url(); ?>/sns-count-cache/includes/download.php" method="post">
1438
- <?php wp_nonce_field( 'mynonce', '_wpnonce' ); ?>
1439
- <table class="form-table">
1440
- <tbody>
1441
- <tr>
1442
- <th><?php _e( 'Download of exported file', self::DOMAIN ); ?></th>
1443
- <td>
1444
- <input type="submit" class="button" name="download_data" value="<?php _e( 'Download', self::DOMAIN ); ?>" />
1445
- <br>
1446
- <span class="description"><?php _e( 'Download the exported csv file.', self::DOMAIN ); ?></span>
1447
- </td>
1448
- </tr>
1449
- </tbody>
1450
- </table>
1451
- </form>
1452
- <?php
1453
- }
1454
- ?>
1455
- </div>
1456
- </div>
1457
- </div>
1458
- </div>
1459
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ admin-setting.php
4
+
5
+ Description: Option page implementation
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 - 2016 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
+ 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
+ $share_base_custom_post_types = explode( ',', $_POST["share_base_custom_post_types"] );
49
+ $settings[self::DB_SHARE_CUSTOM_POST_TYPES] = $share_base_custom_post_types;
50
+ } else {
51
+ $settings[self::DB_SHARE_CUSTOM_POST_TYPES] = array();
52
+ }
53
+
54
+ if ( isset( $_POST["share_base_check_interval"] ) && $_POST["share_base_check_interval"] && is_numeric( $_POST["share_base_check_interval"] ) ) {
55
+ $settings[self::DB_SHARE_BASE_CHECK_INTERVAL] = $_POST["share_base_check_interval"];
56
+ }
57
+
58
+ if ( isset( $_POST["share_base_posts_per_check"] ) && $_POST["share_base_posts_per_check"] && is_numeric( $_POST["share_base_posts_per_check"] ) ) {
59
+ $settings[self::DB_SHARE_POSTS_PER_CHECK] = $_POST["share_base_posts_per_check"];
60
+ }
61
+
62
+ if ( isset( $_POST["dynamic_cache_mode"] ) && $_POST["dynamic_cache_mode"] ) {
63
+ $settings[self::DB_COMMON_DYNAMIC_CACHE_MODE] = $_POST["dynamic_cache_mode"];
64
+ }
65
+
66
+ if ( isset( $_POST["share_variation_analysis_mode"] ) && $_POST["share_variation_analysis_mode"] ) {
67
+ $settings[self::DB_SHARE_VARIATION_ANALYSIS_MODE] = $_POST["share_variation_analysis_mode"];
68
+ }
69
+
70
+ if ( isset( $_POST["share_rush_new_content_term"] ) && $_POST["share_rush_new_content_term"] && is_numeric( $_POST["share_rush_new_content_term"] ) ) {
71
+ $settings[self::DB_SHARE_RUSH_NEW_CONTENT_TERM] = $_POST["share_rush_new_content_term"];
72
+ }
73
+
74
+ if ( isset( $_POST["share_rush_check_interval"] ) && $_POST["share_rush_check_interval"] && is_numeric( $_POST["share_rush_check_interval"] ) ) {
75
+ $settings[self::DB_SHARE_RUSH_CHECK_INTERVAL] = $_POST["share_rush_check_interval"];
76
+ }
77
+
78
+ if ( isset( $_POST["data_export_mode"] ) && $_POST["data_export_mode"] ) {
79
+ $settings[self::DB_COMMON_DATA_EXPORT_MODE] = $_POST["data_export_mode"];
80
+ }
81
+
82
+ if ( isset( $_POST["data_export_interval"] ) && $_POST["data_export_interval"] && is_numeric( $_POST["data_export_interval"] ) ) {
83
+ $settings[self::DB_COMMON_DATA_EXPORT_INTERVAL] = $_POST["data_export_interval"];
84
+ }
85
+
86
+ if ( isset( $_POST["share_base_cache_target_twitter"] ) && $_POST["share_base_cache_target_twitter"] ) {
87
+ $share_base_cache_target[self::REF_SHARE_TWITTER] = true;
88
+ } else {
89
+ $share_base_cache_target[self::REF_SHARE_TWITTER] = false;
90
+ }
91
+
92
+ if ( isset( $_POST["share_alternative_twitter_api"] ) && $_POST["share_alternative_twitter_api"] ) {
93
+ $settings[self::DB_SHARE_BASE_TWITTER_API] = $_POST["share_alternative_twitter_api"];
94
+ }
95
+
96
+ if ( isset( $_POST["share_base_cache_target_facebook"] ) && $_POST["share_base_cache_target_facebook"] ) {
97
+ $share_base_cache_target[self::REF_SHARE_FACEBOOK] = true;
98
+ } else {
99
+ $share_base_cache_target[self::REF_SHARE_FACEBOOK] = false;
100
+ }
101
+
102
+ if ( isset( $_POST["share_base_cache_target_gplus"] ) && $_POST["share_base_cache_target_gplus"] ) {
103
+ $share_base_cache_target[self::REF_SHARE_GPLUS] = true;
104
+ } else {
105
+ $share_base_cache_target[self::REF_SHARE_GPLUS] = false;
106
+ }
107
+
108
+ if ( isset( $_POST["share_base_cache_target_pocket"] ) && $_POST["share_base_cache_target_pocket"] ) {
109
+ $share_base_cache_target[self::REF_SHARE_POCKET] = true;
110
+ } else {
111
+ $share_base_cache_target[self::REF_SHARE_POCKET] = false;
112
+ }
113
+
114
+ if ( isset( $_POST["share_base_cache_target_hatebu"] ) && $_POST["share_base_cache_target_hatebu"] ) {
115
+ $share_base_cache_target[self::REF_SHARE_HATEBU] = true;
116
+ } else {
117
+ $share_base_cache_target[self::REF_SHARE_HATEBU] = false;
118
+ }
119
+
120
+ /*
121
+ if ( isset( $_POST["share_base_cache_target_pinterest"] ) && $_POST["share_base_cache_target_pinterest"] ) {
122
+ $share_base_cache_target[self::REF_SHARE_PINTEREST] = true;
123
+ } else {
124
+ $share_base_cache_target[self::REF_SHARE_PINTEREST] = false;
125
+ }
126
+
127
+ if ( isset( $_POST["share_base_cache_target_linkedin"] ) && $_POST["share_base_cache_target_linkedin"] ) {
128
+ $share_base_cache_target[self::REF_SHARE_LINKEDIN] = true;
129
+ } else {
130
+ $share_base_cache_target[self::REF_SHARE_LINKEDIN] = false;
131
+ }
132
+ */
133
+
134
+ if ( ! empty( $share_base_cache_target ) ) {
135
+ $settings[self::DB_SHARE_CACHE_TARGET] = $share_base_cache_target;
136
+ }
137
+
138
+ if ( isset( $_POST["follow_base_check_interval"] ) && $_POST["follow_base_check_interval"] && is_numeric( $_POST["follow_base_check_interval"] ) ) {
139
+ if ( $_POST["follow_base_check_interval"] >= self::OPT_FOLLOW_BASE_CHECK_INTERVAL_MIN ) {
140
+ $settings[self::DB_FOLLOW_CHECK_INTERVAL] = $_POST["follow_base_check_interval"];
141
+ } else {
142
+ $settings[self::DB_FOLLOW_CHECK_INTERVAL] = self::OPT_FOLLOW_BASE_CHECK_INTERVAL_MIN;
143
+ }
144
+ }
145
+
146
+ if ( isset( $_POST["follow_base_cache_target_feedly"] ) && $_POST["follow_base_cache_target_feedly"] ) {
147
+ $follow_base_cache_target[self::REF_FOLLOW_FEEDLY] = true;
148
+ } else {
149
+ $follow_base_cache_target[self::REF_FOLLOW_FEEDLY] = false;
150
+ }
151
+
152
+ if ( isset( $_POST["follow_base_cache_target_twitter"] ) && $_POST["follow_base_cache_target_twitter"] ) {
153
+ $follow_base_cache_target[self::REF_FOLLOW_TWITTER] = true;
154
+ } else {
155
+ $follow_base_cache_target[self::REF_FOLLOW_TWITTER] = false;
156
+ }
157
+
158
+ if ( isset( $_POST["follow_base_cache_target_facebook"] ) && $_POST["follow_base_cache_target_facebook"] ) {
159
+ $follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] = true;
160
+ } else {
161
+ $follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] = false;
162
+ }
163
+
164
+ if ( isset( $_POST["follow_base_cache_target_push7"] ) && $_POST["follow_base_cache_target_push7"] ) {
165
+ $follow_base_cache_target[self::REF_FOLLOW_PUSH7] = true;
166
+ } else {
167
+ $follow_base_cache_target[self::REF_FOLLOW_PUSH7] = false;
168
+ }
169
+
170
+ if ( isset( $_POST["follow_base_cache_target_instagram"] ) && $_POST["follow_base_cache_target_instagram"] ) {
171
+ $follow_base_cache_target[self::REF_FOLLOW_INSTAGRAM] = true;
172
+ } else {
173
+ $follow_base_cache_target[self::REF_FOLLOW_INSTAGRAM] = false;
174
+ }
175
+
176
+ if ( ! empty( $follow_base_cache_target ) ) {
177
+ $settings[self::DB_FOLLOW_CACHE_TARGET] = $follow_base_cache_target;
178
+ }
179
+
180
+ $follow_twitter_preparation_flag = true;
181
+
182
+ if ( isset( $_POST["follow_twitter_screen_name"] ) && $_POST["follow_twitter_screen_name"] ) {
183
+ $settings[self::DB_FOLLOW_TWITTER_SCREEN_NAME] = $_POST["follow_twitter_screen_name"];
184
+ }
185
+
186
+ if ( isset( $_POST["follow_twitter_consumer_key"] ) && $_POST["follow_twitter_consumer_key"] ) {
187
+ $settings[self::DB_FOLLOW_TWITTER_CONSUMER_KEY] = Common_Util::encrypt_data( $_POST["follow_twitter_consumer_key"], AUTH_KEY );
188
+ } else {
189
+ $follow_twitter_preparation_flag = false;
190
+ }
191
+
192
+ if ( isset( $_POST["follow_twitter_consumer_secret"] ) && $_POST["follow_twitter_consumer_secret"] ) {
193
+ $settings[self::DB_FOLLOW_TWITTER_CONSUMER_SECRET] = Common_Util::encrypt_data( $_POST["follow_twitter_consumer_secret"], AUTH_KEY );
194
+ } else {
195
+ $follow_twitter_preparation_flag = false;
196
+ }
197
+
198
+ if ( isset( $_POST["follow_twitter_bearer_token"] ) && $_POST["follow_twitter_bearer_token"] ) {
199
+ $settings[self::DB_FOLLOW_TWITTER_BEARER_TOKEN] = Common_Util::encrypt_data( $_POST["follow_twitter_bearer_token"], AUTH_KEY );
200
+ }
201
+
202
+ /*
203
+ if ( isset( $_POST["follow_twitter_access_token"] ) && $_POST["follow_twitter_access_token"] ) {
204
+ $settings[self::DB_FOLLOW_TWITTER_ACCESS_TOKEN] = Common_Util::encrypt_data( $_POST["follow_twitter_access_token"], AUTH_KEY );
205
+ }
206
+
207
+ if ( isset( $_POST["follow_twitter_access_token_secret"] ) && $_POST["follow_twitter_access_token_secret"] ) {
208
+ $settings[self::DB_FOLLOW_TWITTER_ACCESS_TOKEN_SECRET] = Common_Util::encrypt_data( $_POST["follow_twitter_access_token_secret"], AUTH_KEY );
209
+ }
210
+ */
211
+
212
+ if ( isset( $_POST["follow_facebook_page_id"] ) && $_POST["follow_facebook_page_id"] ) {
213
+ $settings[self::DB_FOLLOW_FACEBOOK_PAGE_ID] = $_POST["follow_facebook_page_id"];
214
+ }
215
+
216
+ if ( isset( $_POST["follow_facebook_app_id"] ) && $_POST["follow_facebook_app_id"] ) {
217
+ $settings[self::DB_FOLLOW_FACEBOOK_APP_ID] = Common_Util::encrypt_data( $_POST["follow_facebook_app_id"], AUTH_KEY );
218
+ }
219
+
220
+ if ( isset( $_POST["follow_facebook_app_secret"] ) && $_POST["follow_facebook_app_secret"] ) {
221
+ $settings[self::DB_FOLLOW_FACEBOOK_APP_SECRET] = Common_Util::encrypt_data( $_POST["follow_facebook_app_secret"], AUTH_KEY );
222
+ }
223
+
224
+ if ( isset( $_POST["follow_facebook_access_token"] ) && $_POST["follow_facebook_access_token"] ) {
225
+ $settings[self::DB_FOLLOW_FACEBOOK_ACCESS_TOKEN] = Common_Util::encrypt_data( $_POST["follow_facebook_access_token"], AUTH_KEY );
226
+ }
227
+
228
+ if ( isset( $_POST["follow_push7_appno"] ) && $_POST["follow_push7_appno"] ) {
229
+ $settings[self::DB_FOLLOW_PUSH7_APPNO] = Common_Util::encrypt_data( $_POST["follow_push7_appno"], AUTH_KEY );
230
+ }
231
+
232
+ if ( isset( $_POST["follow_instagram_access_token"] ) && $_POST["follow_instagram_access_token"] ) {
233
+ $settings[self::DB_FOLLOW_INSTAGRAM_ACCESS_TOKEN] = Common_Util::encrypt_data( $_POST["follow_instagram_access_token"], AUTH_KEY );
234
+ }
235
+
236
+ if ( isset( $_POST["follow_instagram_client_id"] ) && $_POST["follow_instagram_client_id"] ) {
237
+ $settings[self::DB_FOLLOW_INSTAGRAM_CLIENT_ID] = Common_Util::encrypt_data( $_POST["follow_instagram_client_id"], AUTH_KEY );
238
+ }
239
+
240
+ if ( isset( $_POST["follow_instagram_client_secret"] ) && $_POST["follow_instagram_client_secret"] ) {
241
+ $settings[self::DB_FOLLOW_INSTAGRAM_CLIENT_SECRET] = Common_Util::encrypt_data( $_POST["follow_instagram_client_secret"], AUTH_KEY );
242
+ }
243
+
244
+ if ( isset( $_POST["follow_feed_type"] ) && $_POST["follow_feed_type"] ) {
245
+ switch ( $_POST["follow_feed_type"] ) {
246
+ case 'default':
247
+ $settings[self::DB_FOLLOW_FEED_TYPE] = self::OPT_FEED_TYPE_DEFAULT;
248
+ break;
249
+ case 'rss2':
250
+ $settings[self::DB_FOLLOW_FEED_TYPE] = self::OPT_FEED_TYPE_RSS2;
251
+ break;
252
+ case 'rss':
253
+ $settings[self::DB_FOLLOW_FEED_TYPE] = self::OPT_FEED_TYPE_RSS;
254
+ break;
255
+ case 'rdf':
256
+ $settings[self::DB_FOLLOW_FEED_TYPE] = self::OPT_FEED_TYPE_RDF;
257
+ break;
258
+ case 'atom':
259
+ $settings[self::DB_FOLLOW_FEED_TYPE] = self::OPT_FEED_TYPE_ATOM;
260
+ break;
261
+ default:
262
+ $settings[self::DB_FOLLOW_FEED_TYPE] = self::OPT_FEED_TYPE_DEFAULT;
263
+ }
264
+ } else {
265
+ $settings[self::DB_FOLLOW_FEED_TYPE] = self::OPT_FEED_TYPE_DEFAULT;
266
+ }
267
+
268
+ if ( isset( $_POST["scheme_migration_mode"] ) && $_POST["scheme_migration_mode"] ) {
269
+ $settings[self::DB_COMMON_SCHEME_MIGRATION_MODE] = self::OPT_COMMON_SCHEME_MIGRATION_MODE_ON;
270
+ } else {
271
+ $settings[self::DB_COMMON_SCHEME_MIGRATION_MODE] = self::OPT_COMMON_SCHEME_MIGRATION_MODE_OFF;
272
+ }
273
+
274
+ if ( isset( $_POST["scheme_migration_date"] ) && $_POST["scheme_migration_date"] && strptime( $_POST["scheme_migration_date"], '%Y/%m/%d' ) ) {
275
+ $settings[self::DB_COMMON_SCHEME_MIGRATION_DATE] = $_POST["scheme_migration_date"];
276
+ }
277
+
278
+ if ( isset( $_POST["crawler_ssl_verification"] ) && $_POST["crawler_ssl_verification"] ) {
279
+ $settings[self::DB_COMMON_CRAWLER_SSL_VERIFICATION] = self::OPT_COMMON_CRAWLER_SSL_VERIFY_ON;
280
+ } else {
281
+ $settings[self::DB_COMMON_CRAWLER_SSL_VERIFICATION] = self::OPT_COMMON_CRAWLER_SSL_VERIFY_OFF;
282
+ }
283
+
284
+ if ( isset( $_POST['a_cronbtype'] ) && $_POST['a_cronbtype'] === 'mon' ) {
285
+ $settings[self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE] = $_POST['a_moncronminutes'] . ' ' . $_POST['a_moncronhours'] . ' ' . $_POST['a_moncronmday'] . ' * *';
286
+ }
287
+
288
+ if ( isset( $_POST['a_cronbtype'] ) && $_POST['a_cronbtype'] === 'week' ) {
289
+ $settings[self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE] = $_POST['a_weekcronminutes'] . ' ' . $_POST['a_weekcronhours'] . ' * * ' . $_POST['a_weekcronwday'];
290
+ }
291
+
292
+ if ( isset( $_POST['a_cronbtype'] ) && $_POST['a_cronbtype'] === 'day' ) {
293
+ $settings[self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE] = $_POST['a_daycronminutes'] . ' ' . $_POST['a_daycronhours'] . ' * * *';
294
+ }
295
+
296
+ if ( isset( $_POST['a_cronbtype'] ) && $_POST['a_cronbtype'] === 'hour' ) {
297
+ $settings[self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE] = $_POST['a_hourcronminutes'] . ' * * * *';
298
+ }
299
+
300
+ if ( isset( $_POST['e_cronbtype'] ) && $_POST['e_cronbtype'] === 'mon' ) {
301
+ $settings[self::DB_COMMON_DATA_EXPORT_SCHEDULE] = $_POST['e_moncronminutes'] . ' ' . $_POST['e_moncronhours'] . ' ' . $_POST['e_moncronmday'] . ' * *';
302
+ }
303
+
304
+ if ( isset( $_POST['e_cronbtype'] ) && $_POST['e_cronbtype'] === 'week' ) {
305
+ $settings[self::DB_COMMON_DATA_EXPORT_SCHEDULE] = $_POST['e_weekcronminutes'] . ' ' . $_POST['e_weekcronhours'] . ' * * ' . $_POST['e_weekcronwday'];
306
+ }
307
+
308
+ if ( isset( $_POST['e_cronbtype'] ) && $_POST['e_cronbtype'] === 'day' ) {
309
+ $settings[self::DB_COMMON_DATA_EXPORT_SCHEDULE] = $_POST['e_daycronminutes'] . ' ' . $_POST['e_daycronhours'] . ' * * *';
310
+ }
311
+
312
+ if ( isset( $_POST['e_cronbtype'] ) && $_POST['e_cronbtype'] === 'hour' ) {
313
+ $settings[self::DB_COMMON_DATA_EXPORT_SCHEDULE] = $_POST['e_hourcronminutes'] . ' * * * *';
314
+ }
315
+
316
+ update_option( self::DB_SETTINGS, $settings );
317
+
318
+ $this->reactivate_plugin();
319
+
320
+ set_transient( self::OPT_COMMON_ERROR_MESSAGE, $wp_error->get_error_messages(), 10 );
321
+
322
+ //wp_safe_redirect( menu_page_url( 'scc-setting', false ) );
323
+ }
324
+
325
+ if ( isset( $_POST["reset_data"] ) && $_POST["reset_data"] === __( 'Reset', self::DOMAIN ) ) {
326
+ Common_Util::log( '[' . __METHOD__ . '] reset' );
327
+
328
+ $this->export_engines[self::REF_COMMON_EXPORT]->reset_export();
329
+
330
+ //wp_safe_redirect( menu_page_url( 'scc-setting', false ) );
331
+ }
332
+
333
+ if ( isset( $_POST["export_data"] ) && $_POST["export_data"] === __( 'Export', self::DOMAIN ) ) {
334
+ Common_Util::log( '[' . __METHOD__ . '] export' );
335
+
336
+ set_time_limit( $this->extended_max_execution_time );
337
+
338
+ $this->export_engines[self::REF_COMMON_EXPORT]->execute_export( NULL );
339
+
340
+ set_time_limit( $this->original_max_execution_time );
341
+
342
+ //wp_safe_redirect( menu_page_url('scc-setting', false ) );
343
+ }
344
+
345
+ if ( isset( $_POST["update_share_comparison_base"] ) && $_POST["update_share_comparison_base"] === __( 'Update Basis of Comparison', self::DOMAIN ) ) {
346
+ Common_Util::log( '[' . __METHOD__ . '] base' );
347
+
348
+ set_time_limit( $this->extended_max_execution_time );
349
+
350
+ $this->analytical_engines[self::REF_SHARE_ANALYSIS]->execute_base( NULL );
351
+
352
+ set_time_limit( $this->original_max_execution_time );
353
+
354
+ //wp_safe_redirect( menu_page_url( 'scc-setting', false ) );
355
+ }
356
+
357
+ if ( isset( $_POST["clear_share_base_cache"] ) && $_POST["clear_share_base_cache"] === __( 'Clear Cache', self::DOMAIN ) ) {
358
+ Common_Util::log( '[' . __METHOD__ . '] clear cache' );
359
+
360
+ set_time_limit( $this->extended_max_execution_time );
361
+
362
+ $this->cache_engines[self::REF_SHARE_BASE]->clear_cache();
363
+ //$this->cache_engines[self::REF_SHARE_2ND]->clear_cache();
364
+ $this->cache_engines[self::REF_SHARE_2ND]->initialize_cache();
365
+ $this->analytical_engines[self::REF_SHARE_ANALYSIS]->clear_base();
366
+
367
+ set_time_limit( $this->original_max_execution_time );
368
+
369
+ //wp_safe_redirect( menu_page_url('scc-setting', false ) );
370
+ }
371
+
372
+ if ( isset( $_POST["clear_follow_base_cache"] ) && $_POST["clear_follow_base_cache"] === __( 'Clear Cache', self::DOMAIN ) ) {
373
+ Common_Util::log( '[' . __METHOD__ . '] clear cache' );
374
+
375
+ set_time_limit( $this->extended_max_execution_time );
376
+
377
+ $this->cache_engines[self::REF_FOLLOW_BASE]->clear_cache();
378
+ //$this->cache_engines[self::REF_FOLLOW_2ND]->clear_cache();
379
+ $this->cache_engines[self::REF_FOLLOW_2ND]->initialize_cache();
380
+
381
+ set_time_limit( $this->original_max_execution_time );
382
+
383
+ //wp_safe_redirect( menu_page_url('scc-setting', false ) );
384
+ }
385
+
386
+ if ( isset( $_POST["direct_follow_base_cache"] ) && $_POST["direct_follow_base_cache"] === __( 'Cache', self::DOMAIN ) ) {
387
+ Common_Util::log( '[' . __METHOD__ . '] cache' );
388
+
389
+ set_time_limit( $this->extended_max_execution_time );
390
+
391
+ $this->cache_engines[self::REF_FOLLOW_BASE]->direct_cache( true );
392
+
393
+ set_time_limit( $this->original_max_execution_time );
394
+
395
+ //wp_safe_redirect( menu_page_url('scc-setting', false ) );
396
+ }
397
+
398
+ if ( isset( $_POST["get_tiwtter_bearer_token"] ) && $_POST["get_tiwtter_bearer_token"] === __( 'Get Bearer Token', self::DOMAIN ) ) {
399
+ $tmp_twitter_bearer_token = Common_Util::get_twitter_bearer_token( $this->follow_twitter_consumer_key, $this->follow_twitter_consumer_secret );
400
+ }
401
+
402
+ } elseif( isset( $_GET['_wpnonce'] ) && $_GET['_wpnonce'] && isset( $_GET['action'] ) && $_GET['action'] && isset( $_GET['code'] ) && $_GET['code'] ) {
403
+ if ( $_GET['action'] === 'instagram-auth' ) {
404
+ if ( check_admin_referer( 'instagram-auth', '_wpnonce' ) ) {
405
+ if ( current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
406
+ $redirect_uri = plugins_url() . '/sns-count-cache/?action=instagram-auth';
407
+ $tmp_instagram_access_token = Common_Util::get_instagram_access_token( $this->follow_instagram_client_id, $this->follow_instagram_client_secret, $redirect_uri, $_GET['code'] );
408
+ }
409
+ }
410
+ } elseif ( $_GET['action'] === 'facebook-auth' ) {
411
+ if ( check_admin_referer( 'facebook-auth', '_wpnonce' ) ) {
412
+ if ( current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
413
+ $redirect_uri = plugins_url() . '/sns-count-cache/?action=facebook-auth';
414
+ $tmp_facebook_access_token = Common_Util::get_facebook_access_token( $this->follow_facebook_app_id, $this->follow_facebook_app_secret, $redirect_uri, $_GET['code'] );
415
+ }
416
+ }
417
+ }
418
+ }
419
+ ?>
420
+ <div class="wrap">
421
+ <h2><a href="admin.php?page=scc-setting"><?php _e( 'SNS Count Cache', self::DOMAIN ); ?></a></h2>
422
+ <?php
423
+ if ( $messages = get_transient( self::OPT_COMMON_ERROR_MESSAGE ) ) {
424
+ ?>
425
+ <div class="error">
426
+ <ul>
427
+ <?php
428
+ foreach( $messages as $message ) {
429
+ ?>
430
+ <li><?php echo esc_html( $message ); ?></li>
431
+ <?php
432
+ }
433
+ ?>
434
+ </ul>
435
+ </div>
436
+ <?php
437
+ delete_transient( self::OPT_COMMON_ERROR_MESSAGE );
438
+ }
439
+ ?>
440
+
441
+ <?php
442
+ $status = $this->test_cron_capability();
443
+
444
+ if ( is_wp_error( $status ) ) {
445
+ echo '<div class="error"><p>';
446
+ _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 );
447
+ echo '<br><strong>' . esc_html( $status->get_error_message() ) . '</strong>';
448
+ echo '.</p></div>';
449
+ }
450
+
451
+ if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_INSTAGRAM] ) && $this->follow_base_cache_target[self::REF_FOLLOW_INSTAGRAM] ) {
452
+ $configuration_check = $this->crawlers[self::REF_FOLLOW]->check_crawl_strategy_configurations( self::REF_FOLLOW_INSTAGRAM);
453
+
454
+ if ( ! $configuration_check ) {
455
+ echo '<div class="error"><p>';
456
+ _e( 'Configuratin is not enough to get follower count. Please set required parameters at ', self::DOMAIN );
457
+ echo '<a href="#follow-base-cache-instagram">' . __( 'Follow Base Cache - Instagram', self::DOMAIN ) . '</a>';
458
+ echo '.</p></div>';
459
+ }
460
+ }
461
+
462
+ if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] ) && $this->follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] ) {
463
+ $configuration_check = $this->crawlers[self::REF_FOLLOW]->check_crawl_strategy_configurations( self::REF_FOLLOW_FACEBOOK );
464
+
465
+ if ( ! $configuration_check ) {
466
+ echo '<div class="error"><p>';
467
+ _e( 'Configuratin is not enough to get follower count. Please set required parameters at ', self::DOMAIN );
468
+ echo '<a href="#follow-base-cache-facebook">' . __( 'Follow Base Cache - Facebook', self::DOMAIN ) . '</a>';
469
+ echo '.</p></div>';
470
+ }
471
+ }
472
+
473
+ if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_PUSH7] ) && $this->follow_base_cache_target[self::REF_FOLLOW_PUSH7] ) {
474
+ $configuration_check = $this->crawlers[self::REF_FOLLOW]->check_crawl_strategy_configurations( self::REF_FOLLOW_PUSH7 );
475
+
476
+ if ( ! $configuration_check ) {
477
+ echo '<div class="error"><p>';
478
+ _e( 'Configuratin is not enough to get follower count. Please set required parameters at ', self::DOMAIN );
479
+ echo '<a href="#follow-base-cache-push7">' . __( 'Follow Base Cache - Push7', self::DOMAIN ) . '</a>';
480
+ echo '.</p></div>';
481
+ }
482
+ }
483
+
484
+ if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_TWITTER] ) && $this->follow_base_cache_target[self::REF_FOLLOW_TWITTER] ) {
485
+ $configuration_check = $this->crawlers[self::REF_FOLLOW]->check_crawl_strategy_configurations( self::REF_FOLLOW_TWITTER );
486
+
487
+ if ( ! $configuration_check ) {
488
+ echo '<div class="error"><p>';
489
+ _e( 'Configuratin is not enough to get follower count. Please set required parameters at ', self::DOMAIN );
490
+ echo '<a href="#follow-base-cache-twitter">' . __( 'Follow Base Cache - Twitter', self::DOMAIN ) . '</a>';
491
+ echo '.</p></div>';
492
+ }
493
+ }
494
+
495
+ ?>
496
+
497
+ <div class="sns-cnt-cache">
498
+ <h3 class="nav-tab-wrapper">
499
+ <a class="nav-tab" href="admin.php?page=scc-dashboard"><?php _e( 'Dashboard', self::DOMAIN ); ?></a>
500
+ <a class="nav-tab" href="admin.php?page=scc-cache-status"><?php _e( 'Cache Status', self::DOMAIN ); ?></a>
501
+ <a class="nav-tab" href="admin.php?page=scc-share-count"><?php _e( 'Share Count', self::DOMAIN ); ?></a>
502
+ <?php if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) { ?>
503
+ <a class="nav-tab" href="admin.php?page=scc-hot-content"><?php _e( 'Hot Content', self::DOMAIN ); ?></a>
504
+ <?php } ?>
505
+ <a class="nav-tab nav-tab-active" href="admin.php?page=scc-setting"><?php _e( 'Setting', self::DOMAIN ); ?></a>
506
+ <a class="nav-tab" href="admin.php?page=scc-help"><?php _e( 'Help', self::DOMAIN ); ?></a>
507
+ </h3>
508
+ <p id="options-menu">
509
+ <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="#common-dynamic-cache"><?php _e( 'Dynamic Cache', 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>
510
+ </p>
511
+ <div class="metabox-holder">
512
+ <div id="current-parameter" class="postbox">
513
+ <div class="handlediv" title="Click to toggle"><br></div>
514
+ <h3 class="hndle"><span><?php _e( 'Current Setting', self::DOMAIN ); ?></span></h3>
515
+ <div class="inside">
516
+ <table class="view-table">
517
+ <thead>
518
+ <tr>
519
+ <th><?php _e( 'Capability', self::DOMAIN ); ?></th>
520
+ <th><?php _e( 'Parameter', self::DOMAIN ); ?></th>
521
+ <th><?php _e( 'Value', self::DOMAIN ); ?></th>
522
+ </tr>
523
+ </thead>
524
+ <tbody>
525
+ <tr>
526
+ <td><?php _e( 'Share Base Cache', self::DOMAIN); ?></td>
527
+ <td><?php _e( 'Target SNS', self::DOMAIN ); ?></td>
528
+ <td>
529
+ <?php
530
+ $target_sns = array();
531
+
532
+ if ( isset( $this->share_base_cache_target[self::REF_SHARE_FACEBOOK] ) && $this->share_base_cache_target[self::REF_SHARE_FACEBOOK] ) {
533
+ $target_sns[] = 'Facebook';
534
+ }
535
+ if ( isset( $this->share_base_cache_target[self::REF_SHARE_GPLUS] ) && $this->share_base_cache_target[self::REF_SHARE_GPLUS] ) {
536
+ $target_sns[] = 'Google+';
537
+ }
538
+ if ( isset( $this->share_base_cache_target[self::REF_SHARE_HATEBU] ) && $this->share_base_cache_target[self::REF_SHARE_HATEBU] ) {
539
+ $target_sns[] = __( 'Hatena Bookmark', self::DOMAIN );
540
+ }
541
+ /*
542
+ if ( isset( $this->share_base_cache_target[self::REF_SHARE_LINKEDIN] ) && $this->share_base_cache_target[self::REF_SHARE_LINKEDIN] ) {
543
+ $target_sns[] = 'Linkedin';
544
+ }
545
+ if ( isset( $this->share_base_cache_target[self::REF_SHARE_PINTEREST] ) && $this->share_base_cache_target[self::REF_SHARE_PINTEREST] ) {
546
+ $target_sns[] = 'Pinterest';
547
+ }
548
+ */
549
+ if ( isset( $this->share_base_cache_target[self::REF_SHARE_POCKET] ) && $this->share_base_cache_target[self::REF_SHARE_POCKET] ) {
550
+ $target_sns[] = 'Pocket';
551
+ }
552
+ if ( isset( $this->share_base_cache_target[self::REF_SHARE_TWITTER] ) && $this->share_base_cache_target[self::REF_SHARE_TWITTER] ) {
553
+ $target_sns[] = 'Twitter';
554
+ }
555
+ echo esc_html( implode( ", ", $target_sns ) );
556
+ ?>
557
+ </td>
558
+ </tr>
559
+ <tr>
560
+ <td><?php _e( 'Share Base Cache', self::DOMAIN ); ?></td>
561
+ <td><?php _e( 'Custom post types', self::DOMAIN ); ?></td>
562
+ <td>
563
+ <?php
564
+ if ( ! empty( $this->share_base_custom_post_types ) && $this->share_base_custom_post_types ) {
565
+ echo esc_html( implode( ',', $this->share_base_custom_post_types ) );
566
+ } else {
567
+ _e( 'N/A', self::DOMAIN );
568
+ }
569
+ ?>
570
+ </td>
571
+ </tr>
572
+ <tr>
573
+ <td><?php _e( 'Share Base Cache', self::DOMAIN ); ?></td>
574
+ <td><?php _e( 'Interval cheking share count (sec)', self::DOMAIN ); ?></td>
575
+ <td><?php echo esc_html( $this->share_base_check_interval ) . ' ' . __( 'seconds', self::DOMAIN ); ?></td>
576
+ </tr>
577
+ <tr>
578
+ <td><?php _e( 'Share Base Cache', self::DOMAIN ); ?></td>
579
+ <td><?php _e( 'Number of contents to check at a time', self::DOMAIN ) ?></td>
580
+ <td><?php echo esc_html( $this->share_base_posts_per_check ) . ' ' . __( 'contents', self::DOMAIN ); ?></td>
581
+ </tr>
582
+ <tr>
583
+ <td><?php _e( 'Share Base Cache', self::DOMAIN ); ?></td>
584
+ <td><?php _e( 'Scheme migration mode from http to https', self::DOMAIN ); ?></td>
585
+ <td>
586
+ <?php
587
+ if ( $this->scheme_migration_mode ) {
588
+ _e( 'On', self::DOMAIN );
589
+ } else {
590
+ _e( 'Off', self::DOMAIN );
591
+ }
592
+ ?>
593
+ </td>
594
+ </tr>
595
+ <?php if ( $this->scheme_migration_mode ) { ?>
596
+ <tr>
597
+ <td><?php _e( 'Share Base Cache', self::DOMAIN ); ?></td>
598
+ <td><?php _e( 'Scheme migration date from http to https', self::DOMAIN ); ?></td>
599
+ <td>
600
+ <?php
601
+ if ( isset( $this->scheme_migration_date ) ) {
602
+ echo esc_html( $this->scheme_migration_date );
603
+ } else {
604
+ _e( 'N/A', self::DOMAIN );
605
+ }
606
+ ?>
607
+ </td>
608
+ </tr>
609
+ <?php } ?>
610
+
611
+ <?php if ( isset( $this->share_base_cache_target[self::REF_SHARE_TWITTER] ) && $this->share_base_cache_target[self::REF_SHARE_TWITTER] ) { ?>
612
+ <tr>
613
+ <td><?php _e( 'Share Base Cache - Twitter', self::DOMAIN ); ?></td>
614
+ <td><?php _e( 'Alternative Twitter API', self::DOMAIN ); ?></td>
615
+ <td>
616
+ <?php
617
+ if ( $this->share_base_twitter_api === self::OPT_SHARE_TWITTER_API_JSOON ) {
618
+ echo '<a href="' . esc_url( 'https://jsoon.digitiminimi.com/' ) . '" target="_blank">' . esc_html( 'widgetoon.js & count.jsoon' ) . '</a>';
619
+ } elseif ( $this->share_base_twitter_api === self::OPT_SHARE_TWITTER_API_OPENSHARECOUNT ) {
620
+ echo '<a href="' . esc_url( 'https://opensharecount.com/' ) . '" target="_blank">' . esc_html( 'OpenShareCount' ) . '</a>';
621
+ } elseif ( $this->share_base_twitter_api === self::OPT_SHARE_TWITTER_API_TWITCOUNT ) {
622
+ echo '<a href="' . esc_url( 'http://twitcount.com/' ) . '" target="_blank">' . esc_html( 'TwitCount' ) . '</a>';
623
+ }
624
+ ?>
625
+ </td>
626
+ </tr>
627
+ <?php } ?>
628
+ <tr>
629
+ <td><?php _e( 'Share Rush Cache', self::DOMAIN ); ?></td>
630
+ <td><?php _e( 'Term considering posted content as new content', self::DOMAIN ); ?></td>
631
+ <td>
632
+ <?php
633
+ if ( $this->share_rush_new_content_term == 1 ) {
634
+ echo esc_html( $this->share_rush_new_content_term ) . ' ' . __( 'day', self::DOMAIN );
635
+ } elseif ( $this->share_rush_new_content_term > 1 ) {
636
+ echo esc_html( $this->share_rush_new_content_term ) . ' ' . __( 'days', self::DOMAIN );
637
+ }
638
+ ?>
639
+ </td>
640
+ </tr>
641
+ <tr>
642
+ <td><?php _e( 'Share Rush Cache', self::DOMAIN ); ?></td>
643
+ <td><?php _e( 'Interval cheking share count (sec)', self::DOMAIN ); ?></td>
644
+ <td>
645
+ <?php
646
+ echo esc_html( $this->share_rush_check_interval ) . ' ' . __( 'seconds', self::DOMAIN );
647
+ ?>
648
+ </td>
649
+ </tr>
650
+ <tr>
651
+ <td><?php _e( 'Share Variation Analysis', self::DOMAIN ); ?></td>
652
+ <td><?php _e( 'Method to update basis of comparison', self::DOMAIN ); ?></td><td>
653
+ <?php
654
+ switch ( $this->share_variation_analysis_mode ) {
655
+ case self::OPT_SHARE_VARIATION_ANALYSIS_NONE:
656
+ _e( 'Disabled (None)', self::DOMAIN );
657
+ break;
658
+ case self::OPT_SHARE_VARIATION_ANALYSIS_MANUAL:
659
+ _e( 'Enabled (Manual)', self::DOMAIN );
660
+ break;
661
+ case self::OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER:
662
+ _e( 'Enabled (Scheduler)', self::DOMAIN );
663
+ break;
664
+ }
665
+ ?>
666
+ </td>
667
+ </tr>
668
+ <?php
669
+ if ( $this->share_variation_analysis_mode === self::OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER ) {
670
+ ?>
671
+ <tr>
672
+ <td><?php _e( 'Share Variation Analysis', self::DOMAIN ); ?></td>
673
+ <td><?php _e( 'Schedule', self::DOMAIN ); ?></td>
674
+ <td><?php echo esc_html( $this->share_variation_analysis_schedule ); ?></td>
675
+ </tr>
676
+ <?php
677
+ }
678
+ ?>
679
+ <tr>
680
+ <td><?php _e( 'Follow Base Cache', self::DOMAIN); ?></td>
681
+ <td><?php _e( 'Target SNS', self::DOMAIN ); ?></td>
682
+ <td>
683
+ <?php
684
+ $target_sns = array();
685
+ if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_INSTAGRAM] ) && $this->follow_base_cache_target[self::REF_FOLLOW_INSTAGRAM] ) {
686
+ $target_sns[] = 'Instagram';
687
+ }
688
+ if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] ) && $this->follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] ) {
689
+ $target_sns[] = 'Facebook';
690
+ }
691
+ if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_FEEDLY] ) && $this->follow_base_cache_target[self::REF_FOLLOW_FEEDLY] ) {
692
+ $target_sns[] = 'Feedly';
693
+ }
694
+ if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_PUSH7] ) && $this->follow_base_cache_target[self::REF_FOLLOW_PUSH7] ) {
695
+ $target_sns[] = 'Push7';
696
+ }
697
+ if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_TWITTER] ) && $this->follow_base_cache_target[self::REF_FOLLOW_TWITTER] ) {
698
+ $target_sns[] = 'Twitter';
699
+ }
700
+ echo esc_html( implode( ', ', $target_sns ) );
701
+ ?>
702
+ </td>
703
+ </tr>
704
+ <tr>
705
+ <td><?php _e( 'Follow Base Cache', self::DOMAIN ); ?></td>
706
+ <td><?php _e( 'Interval cheking follower count (sec)', self::DOMAIN ); ?></td>
707
+ <td><?php echo esc_html( $this->follow_base_check_interval ) . ' ' . __( 'seconds', self::DOMAIN ); ?></td>
708
+ </tr>
709
+ <?php if ( $this->follow_base_cache_target[self::REF_FOLLOW_FEEDLY] ) { ?>
710
+ <tr>
711
+ <td><?php _e( 'Follow Base Cache - Feedly', self::DOMAIN ); ?></td>
712
+ <td><?php _e( 'Target feed type', self::DOMAIN ); ?></td>
713
+ <td>
714
+ <?php
715
+ switch ( $this->follow_feed_type ) {
716
+ case self::OPT_FEED_TYPE_DEFAULT:
717
+ _e( 'Default', self::DOMAIN );
718
+ break;
719
+ case self::OPT_FEED_TYPE_RSS:
720
+ _e( 'RSS', self::DOMAIN );
721
+ break;
722
+ case self::OPT_FEED_TYPE_RSS2:
723
+ _e( 'RSS2', self::DOMAIN );
724
+ break;
725
+ case self::OPT_FEED_TYPE_RDF:
726
+ _e( 'RDF', self::DOMAIN );
727
+ break;
728
+ case self::OPT_FEED_TYPE_ATOM:
729
+ _e( 'ATOM', self::DOMAIN );
730
+ break;
731
+ default:
732
+ _e( 'Default', self::DOMAIN );
733
+ }
734
+ ?>
735
+ </td>
736
+ </tr>
737
+ <tr>
738
+ <td><?php _e( 'Follow Base Cache - Feedly', self::DOMAIN ); ?></td>
739
+ <td><?php _e( 'Target feed', self::DOMAIN ); ?></td>
740
+ <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>
741
+ </tr>
742
+ <?php } ?>
743
+ <?php if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_TWITTER] ) && $this->follow_base_cache_target[self::REF_FOLLOW_TWITTER] ) { ?>
744
+ <tr>
745
+ <td><?php _e( 'Follow Base Cache - Twitter', self::DOMAIN ); ?></td>
746
+ <td><?php _e( 'Target screen name', self::DOMAIN ); ?></td>
747
+ <td>
748
+ <?php
749
+ if ( isset( $this->follow_twitter_screen_name ) ) {
750
+ echo '@' . esc_html( $this->follow_twitter_screen_name );
751
+ } else {
752
+ _e( 'N/A', self::DOMAIN );
753
+ }
754
+ ?>
755
+ </td>
756
+ </tr>
757
+ <?php } ?>
758
+ <?php if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] ) && $this->follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] ) { ?>
759
+ <tr>
760
+ <td><?php _e( 'Follow Base Cache - Facebook', self::DOMAIN ); ?></td>
761
+ <td><?php _e( 'Page ID', self::DOMAIN ); ?></td>
762
+ <td>
763
+ <?php
764
+ if ( isset( $this->follow_facebook_page_id ) ) {
765
+ echo esc_html( $this->follow_facebook_page_id );
766
+ } else {
767
+ _e( 'N/A', self::DOMAIN );
768
+ }
769
+ ?>
770
+ </td>
771
+ </tr>
772
+ <?php } ?>
773
+ <tr>
774
+ <td><?php _e( 'Dynamic Cache', self::DOMAIN); ?></td>
775
+ <td><?php _e( 'Dynamic caching based on user access', self::DOMAIN ); ?></td><td>
776
+ <?php
777
+ switch ( $this->dynamic_cache_mode ) {
778
+ case self::OPT_COMMON_ACCESS_BASED_CACHE_NONE:
779
+ _e( 'Disabled (None)', self::DOMAIN );
780
+ break;
781
+ case self::OPT_COMMON_ACCESS_BASED_SYNC_CACHE:
782
+ _e( 'Enabled (Synchronous Cache)', self::DOMAIN );
783
+ break;
784
+ case self::OPT_COMMON_ACCESS_BASED_ASYNC_CACHE:
785
+ _e( 'Enabled (Asynchronous Cache)', self::DOMAIN );
786
+ break;
787
+ case self::OPT_COMMON_ACCESS_BASED_2ND_CACHE:
788
+ _e( 'Enabled (Asynchronous 2nd Cache)', self::DOMAIN );
789
+ break;
790
+ }
791
+ ?>
792
+ </td>
793
+ </tr>
794
+ <tr>
795
+ <td><?php _e( 'Data Crawler', self::DOMAIN ); ?></td>
796
+ <td><?php _e( 'Crawl method', self::DOMAIN ); ?></td>
797
+ <td>
798
+ <?php
799
+ switch ( $this->crawler_method ) {
800
+ case self::OPT_COMMON_CRAWLER_METHOD_NORMAL:
801
+ _e( 'Normal (Sequential Retrieval)', self::DOMAIN );
802
+ break;
803
+ case self::OPT_COMMON_CRAWLER_METHOD_CURL:
804
+ _e( 'Extended (Parallel Retrieval)', self::DOMAIN );
805
+ break;
806
+ }
807
+ ?>
808
+ </td>
809
+ </tr>
810
+ <tr>
811
+ <td><?php _e( 'Data Crawler', self::DOMAIN ); ?></td>
812
+ <td><?php _e( 'SSL verification', self::DOMAIN ); ?></td>
813
+ <td>
814
+ <?php
815
+ if ( $this->crawler_ssl_verification ) {
816
+ _e( 'On', self::DOMAIN );
817
+ } else {
818
+ _e( 'Off', self::DOMAIN );
819
+ }
820
+ ?>
821
+ </td>
822
+ </tr>
823
+ <tr>
824
+ <td><?php _e( 'Data Export', self::DOMAIN ); ?></td>
825
+ <td><?php _e( 'Method of data export', self::DOMAIN ); ?></td><td>
826
+ <?php
827
+ switch ( $this->data_export_mode ) {
828
+ case self::OPT_COMMON_DATA_EXPORT_MANUAL:
829
+ _e( 'Manual', self::DOMAIN );
830
+ break;
831
+ case self::OPT_COMMON_DATA_EXPORT_SCHEDULER:
832
+ _e( 'Scheduler', self::DOMAIN );
833
+ break;
834
+ }
835
+ ?>
836
+ </td>
837
+ </tr>
838
+ <?php
839
+ if ( $this->data_export_mode === self::OPT_COMMON_DATA_EXPORT_SCHEDULER ) {
840
+ ?>
841
+ <tr>
842
+ <td><?php _e( 'Data Export', self::DOMAIN ); ?></td>
843
+ <td><?php _e( 'Interval exporting share count to a csv file', self::DOMAIN ); ?></td>
844
+ <td><?php echo esc_html( $this->data_export_interval / 3600 ) . ' ' . __( 'hours', self::DOMAIN ); ?></td>
845
+ </tr>
846
+ <?php
847
+ }
848
+ ?>
849
+ </tbody>
850
+ </table>
851
+ </div>
852
+ </div>
853
+ </div>
854
+ <div class="metabox-holder">
855
+ <form action="admin.php?page=scc-setting" method="post">
856
+ <?php wp_nonce_field( __FILE__, '_wpnonce' ); ?>
857
+ <div id="share-base-cache" class="postbox">
858
+ <div class="handlediv" title="Click to toggle"><br></div>
859
+ <h3 class="hndle"><span><?php _e('Share Base Cache', self::DOMAIN); ?></span></h3>
860
+ <div class="inside">
861
+ <table class="form-table">
862
+ <tr>
863
+ <th><label><?php _e( 'Target SNS', self::DOMAIN ); ?></label></th>
864
+ <td>
865
+ <div class="sns-check">
866
+ <input type="checkbox" value="1" 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"'; ?> />
867
+ <label><?php _e( 'Facebook', self::DOMAIN ); ?></label>
868
+ </div>
869
+ <div class="sns-check">
870
+ <input type="checkbox" value="1" 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"'; ?> />
871
+ <label><?php _e( 'Google+', self::DOMAIN ); ?></label>
872
+ </div>
873
+ <div class="sns-check">
874
+ <input type="checkbox" value="1" 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"'; ?> />
875
+ <label><?php _e( 'Hatena Bookmark', self::DOMAIN ); ?></label>
876
+ </div>
877
+ <div class="sns-check">
878
+ <input type="checkbox" value="1" 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"'; ?> />
879
+ <label><?php _e( 'Pocket', self::DOMAIN ); ?></label>
880
+ </div>
881
+ <div class="sns-check">
882
+ <input type="checkbox" value="1" 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"'; ?> />
883
+ <label><?php _e( 'Twitter', self::DOMAIN ); ?></label>
884
+ </div>
885
+ </td>
886
+ </tr>
887
+ <tr>
888
+ <th><label><?php _e( 'Custom post types', self::DOMAIN ); ?></label></th>
889
+ <td>
890
+ <input type="text" class="text" name="share_base_custom_post_types" size="60" value="<?php echo esc_attr( implode( ',', $this->share_base_custom_post_types ) ); ?>" />
891
+ <br>
892
+ <label><?php _e( 'e.g. aaa, bbb, ccc (comma-delimited)', self::DOMAIN ); ?></label>
893
+ </td>
894
+ </tr>
895
+ <tr>
896
+ <th><label><?php _e( 'Interval cheking share count (sec)', self::DOMAIN ); ?></label></th>
897
+ <td>
898
+ <input type="text" class="text" name="share_base_check_interval" size="20" value="<?php echo esc_attr( $this->share_base_check_interval ); ?>" />
899
+ <label><?php _e( 'Default: 600', self::DOMAIN ); ?></label>
900
+ </td>
901
+ </tr>
902
+ <tr>
903
+ <th><label><?php _e( 'Number of contents to check at a time', self::DOMAIN ); ?></label></th>
904
+ <td>
905
+ <input type="text" class="text" name="share_base_posts_per_check" size="20" value="<?php echo esc_attr( $this->share_base_posts_per_check ); ?>" />
906
+ <label><?php _e( 'Default: 20', self::DOMAIN ); ?></label>
907
+ </td>
908
+ </tr>
909
+ <tr>
910
+ <th><label><?php _e( 'Scheme migration mode from http to https', self::DOMAIN ); ?></label></th>
911
+ <td>
912
+ <select name="scheme_migration_mode">
913
+ <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>
914
+ <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>
915
+ </select>
916
+ <label><?php _e('Default: Off', self::DOMAIN ); ?></label>
917
+ </td>
918
+ </tr>
919
+ <?php if ( $this->scheme_migration_mode ) { ?>
920
+ <tr>
921
+ <th><label><?php _e( 'Scheme migration date from http to https', self::DOMAIN ); ?></label></th>
922
+ <td>
923
+ <input id="scheme-migration-date" type="text" class="text" name="scheme_migration_date" size="20" value="<?php echo esc_attr( $this->scheme_migration_date ); ?>" />
924
+ <label><?php _e( 'Default: N/A', self::DOMAIN ); ?></label>
925
+ <script>
926
+ jQuery(document).ready(function() {
927
+ jQuery('#scheme-migration-date').datepicker({
928
+ dateFormat : 'yy/mm/dd'
929
+ });
930
+ });
931
+ </script>
932
+ </td>
933
+ </tr>
934
+ <?php } ?>
935
+ </table>
936
+ <div class="submit-button">
937
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
938
+ <input type="submit" class="button button-secondary" name="clear_share_base_cache" value="<?php _e( 'Clear Cache', self::DOMAIN ); ?>">
939
+ </div>
940
+ </div>
941
+ </div>
942
+ <?php if ( isset( $this->share_base_cache_target[self::REF_SHARE_TWITTER] ) && $this->share_base_cache_target[self::REF_SHARE_TWITTER] ) { ?>
943
+ <div id="share-base-cache-twitter" class="postbox">
944
+ <div class="handlediv" title="Click to toggle"><br></div>
945
+ <h3 class="hndle"><span><?php _e( 'Share Base Cache - Twitter', self::DOMAIN ); ?></span></h3>
946
+ <div class="inside">
947
+ <table class="form-table">
948
+ <tr>
949
+ <th><label><?php _e( 'Alternative Twitter API', self::DOMAIN ); ?></label></th>
950
+ <td>
951
+ <select name="share_alternative_twitter_api">
952
+ <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>
953
+ <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>
954
+ <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>
955
+ </select>
956
+ <label><?php _e( 'Default: ', self::DOMAIN ); echo esc_html( 'widgetoon.js & count.jsoon' ); ?></label>
957
+ </td>
958
+ </tr>
959
+ <tr>
960
+ <th><label><?php _e( 'Registration destination', self::DOMAIN ); ?></label></th>
961
+ <td>
962
+ <?php
963
+ if ( $this->share_base_twitter_api === self::OPT_SHARE_TWITTER_API_JSOON ) {
964
+ echo '<a href="' . esc_url( 'https://jsoon.digitiminimi.com/' ) . '" target="_blank">' . esc_html( 'https://jsoon.digitiminimi.com/' ) . '</a>';
965
+ } elseif ( $this->share_base_twitter_api === self::OPT_SHARE_TWITTER_API_OPENSHARECOUNT ) {
966
+ echo '<a href="' . esc_url( 'https://opensharecount.com/' ) . '" target="_blank">' . esc_html( 'https://opensharecount.com/' ) . '</a>';
967
+ } elseif ( $this->share_base_twitter_api === self::OPT_SHARE_TWITTER_API_TWITCOUNT ) {
968
+ echo '<a href="' . esc_url( 'http://twitcount.com/' ) . '" target="_blank">' . esc_html( 'http://twitcount.com/' ) . '</a>';
969
+ }
970
+ ?>
971
+ <br />
972
+ <label><?php _e( 'You need to register information such as your domain with the above site in order to start counting.', self::DOMAIN ); ?></label>
973
+ </td>
974
+ </tr>
975
+ </table>
976
+ <div class="submit-button">
977
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
978
+ </div>
979
+ </div>
980
+ </div>
981
+ <?php } ?>
982
+ <div id="share-rush-cache" class="postbox">
983
+ <div class="handlediv" title="Click to toggle"><br></div>
984
+ <h3 class="hndle"><span><?php _e( 'Share Rush Cache', self::DOMAIN); ?></span></h3>
985
+ <div class="inside">
986
+ <table class="form-table">
987
+ <tr>
988
+ <th><label><?php _e( 'Term considering posted content as new content', self::DOMAIN ); ?></label></th>
989
+ <td>
990
+ <select name="share_rush_new_content_term">
991
+ <option value="1"<?php if ( $this->share_rush_new_content_term === 1 ) echo ' selected="selected"'; ?>><?php _e( '1 day', self::DOMAIN ); ?></option>
992
+ <option value="2"<?php if ( $this->share_rush_new_content_term === 2 ) echo ' selected="selected"'; ?>><?php _e( '2 days', self::DOMAIN ); ?></option>
993
+ <option value="3"<?php if ( $this->share_rush_new_content_term === 3 ) echo ' selected="selected"'; ?>><?php _e( '3 days', self::DOMAIN ); ?></option>
994
+ <option value="4"<?php if ( $this->share_rush_new_content_term === 4 ) echo ' selected="selected"'; ?>><?php _e( '4 days', self::DOMAIN ); ?></option>
995
+ <option value="5"<?php if ( $this->share_rush_new_content_term === 5 ) echo ' selected="selected"'; ?>><?php _e( '5 days', self::DOMAIN ); ?></option>
996
+ <option value="6"<?php if ( $this->share_rush_new_content_term === 6 ) echo ' selected="selected"'; ?>><?php _e( '6 days', self::DOMAIN ); ?></option>
997
+ <option value="7"<?php if ( $this->share_rush_new_content_term === 7 ) echo ' selected="selected"'; ?>><?php _e( '7 days', self::DOMAIN ); ?></option>
998
+ <option value="8"<?php if ( $this->share_rush_new_content_term === 8 ) echo ' selected="selected"'; ?>><?php _e( '8 days', self::DOMAIN ); ?></option>
999
+ <option value="9"<?php if ( $this->share_rush_new_content_term === 9 ) echo ' selected="selected"'; ?>><?php _e( '9 days', self::DOMAIN ); ?></option>
1000
+ <option value="10"<?php if ( $this->share_rush_new_content_term === 10 ) echo ' selected="selected"'; ?>><?php _e( '10 days', self::DOMAIN ); ?></option>
1001
+ <option value="11"<?php if ( $this->share_rush_new_content_term === 11 ) echo ' selected="selected"'; ?>><?php _e( '11 days', self::DOMAIN ); ?></option>
1002
+ <option value="12"<?php if ( $this->share_rush_new_content_term === 12 ) echo ' selected="selected"'; ?>><?php _e( '12 days', self::DOMAIN ); ?></option>
1003
+ <option value="13"<?php if ( $this->share_rush_new_content_term === 13 ) echo ' selected="selected"'; ?>><?php _e( '13 days', self::DOMAIN ); ?></option>
1004
+ <option value="14"<?php if ( $this->share_rush_new_content_term === 14 ) echo ' selected="selected"'; ?>><?php _e( '14 days', self::DOMAIN ); ?></option>
1005
+ </select>
1006
+ <label><?php _e( 'Default: 3 days', self::DOMAIN ); ?></label>
1007
+ </td>
1008
+ </tr>
1009
+ <tr>
1010
+ <th><label><?php _e( 'Interval cheking share count (sec)', self::DOMAIN ); ?></label></th>
1011
+ <td>
1012
+ <?php
1013
+ echo esc_html( $this->share_rush_check_interval ) . ' ' . __( 'seconds', self::DOMAIN );
1014
+ ?>
1015
+ </td>
1016
+ </tr>
1017
+ </table>
1018
+ <div class="submit-button">
1019
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1020
+ </div>
1021
+ </div>
1022
+ </div>
1023
+ <div id="share-variation-analysis" class="postbox">
1024
+ <div class="handlediv" title="Click to toggle"><br></div>
1025
+ <h3 class="hndle"><span><?php _e( 'Share Variation Analysis', self::DOMAIN ); ?></span></h3>
1026
+ <div class="inside">
1027
+ <table class="form-table">
1028
+ <tr>
1029
+ <th><label><?php _e( 'Method to update basis of comparison', self::DOMAIN ); ?></label></th>
1030
+ <td>
1031
+ <select name="share_variation_analysis_mode">
1032
+ <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>
1033
+ <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>
1034
+ <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>
1035
+ </select>
1036
+ <label><?php _e( 'Default: None', self::DOMAIN ); ?></label>
1037
+ </td>
1038
+ </tr>
1039
+ <?php
1040
+ if ( $this->share_variation_analysis_mode === self::OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER ) {
1041
+ list( $cronstr['minutes'], $cronstr['hours'], $cronstr['mday'], $cronstr['mon'], $cronstr['wday'] ) = explode( ' ', $this->share_variation_analysis_schedule, 5 );
1042
+ if ( strstr( $cronstr['minutes'], '*/' ) ) {
1043
+ $minutes = explode( '/', $cronstr['minutes'] );
1044
+ } else {
1045
+ $minutes = explode( ',', $cronstr['minutes'] );
1046
+ }
1047
+ if ( strstr( $cronstr['hours'], '*/' ) ) {
1048
+ $hours = explode( '/', $cronstr['hours'] );
1049
+ } else {
1050
+ $hours = explode( ',', $cronstr['hours'] );
1051
+ }
1052
+ if ( strstr( $cronstr['mday'], '*/' ) ) {
1053
+ $mday = explode( '/', $cronstr['mday'] );
1054
+ } else {
1055
+ $mday = explode( ',', $cronstr['mday'] );
1056
+ }
1057
+ if ( strstr( $cronstr['mon'], '*/' ) ) {
1058
+ $mon = explode( '/', $cronstr['mon'] );
1059
+ } else {
1060
+ $mon = explode( ',', $cronstr['mon'] );
1061
+ }
1062
+ if ( strstr( $cronstr['wday'], '*/' ) ) {
1063
+ $wday = explode( '/', $cronstr['wday'] );
1064
+ } else {
1065
+ $wday = explode( ',', $cronstr['wday'] );
1066
+ }
1067
+ ?>
1068
+ <tr class="a_wpcron">
1069
+ <th scope="row"><?php _e( 'Scheduler', self::DOMAIN ); ?></th>
1070
+ <td>
1071
+ <table class="wpcron">
1072
+ <tr>
1073
+ <th>
1074
+ <?php _e( 'Type', self::DOMAIN ); ?>
1075
+ </th>
1076
+ <th>
1077
+ </th>
1078
+ <th>
1079
+ <?php _e( 'Hour', self::DOMAIN ); ?>
1080
+ </th>
1081
+ <th>
1082
+ <?php _e( 'Minute', self::DOMAIN ); ?>
1083
+ </th>
1084
+ </tr>
1085
+ <tr>
1086
+ <td>
1087
+ <label for="idcronbtype-mon">
1088
+ <?php echo '<input class="radio" type="radio"' . checked( TRUE, is_numeric( $mday[0] ), FALSE ) . ' name="a_cronbtype" value="mon" /> ' . __( 'monthly', self::DOMAIN ); ?>
1089
+ </label>
1090
+ </td>
1091
+ <td>
1092
+ <select name="a_moncronmday">
1093
+ <?php
1094
+ for ( $i = 1; $i <= 31; $i ++ ) {
1095
+ $on_day = '';
1096
+
1097
+ switch ( $i ) {
1098
+ case 1:
1099
+ $on_day = __( 'on 1.', self::DOMAIN );
1100
+ break;
1101
+ case 2:
1102
+ $on_day = __( 'on 2.', self::DOMAIN );
1103
+ break;
1104
+ case 3:
1105
+ $on_day = __( 'on 3.', self::DOMAIN );
1106
+ break;
1107
+ case 4:
1108
+ $on_day = __( 'on 4.', self::DOMAIN );
1109
+ break;
1110
+ case 5:
1111
+ $on_day = __( 'on 5.', self::DOMAIN );
1112
+ break;
1113
+ case 6:
1114
+ $on_day = __( 'on 6.', self::DOMAIN );
1115
+ break;
1116
+ case 7:
1117
+ $on_day = __( 'on 7.', self::DOMAIN );
1118
+ break;
1119
+ case 8:
1120
+ $on_day = __( 'on 8.', self::DOMAIN );
1121
+ break;
1122
+ case 9:
1123
+ $on_day = __( 'on 9.', self::DOMAIN );
1124
+ break;
1125
+ case 10:
1126
+ $on_day = __( 'on 10.', self::DOMAIN );
1127
+ break;
1128
+ case 11:
1129
+ $on_day = __( 'on 11.', self::DOMAIN );
1130
+ break;
1131
+ case 12:
1132
+ $on_day = __( 'on 12.', self::DOMAIN );
1133
+ break;
1134
+ case 13:
1135
+ $on_day = __( 'on 13.', self::DOMAIN );
1136
+ break;
1137
+ case 14:
1138
+ $on_day = __( 'on 14.', self::DOMAIN );
1139
+ break;
1140
+ case 15:
1141
+ $on_day = __( 'on 15.', self::DOMAIN );
1142
+ break;
1143
+ case 16:
1144
+ $on_day = __( 'on 16.', self::DOMAIN );
1145
+ break;
1146
+ case 17:
1147
+ $on_day = __( 'on 17.', self::DOMAIN );
1148
+ break;
1149
+ case 18:
1150
+ $on_day = __( 'on 18.', self::DOMAIN );
1151
+ break;
1152
+ case 19:
1153
+ $on_day = __( 'on 19.', self::DOMAIN );
1154
+ break;
1155
+ case 20:
1156
+ $on_day = __( 'on 20.', self::DOMAIN );
1157
+ break;
1158
+ case 21:
1159
+ $on_day = __( 'on 21.', self::DOMAIN );
1160
+ break;
1161
+ case 22:
1162
+ $on_day = __( 'on 22.', self::DOMAIN );
1163
+ break;
1164
+ case 23:
1165
+ $on_day = __( 'on 23.', self::DOMAIN );
1166
+ break;
1167
+ case 24:
1168
+ $on_day = __( 'on 24.', self::DOMAIN );
1169
+ break;
1170
+ case 25:
1171
+ $on_day = __( 'on 25.', self::DOMAIN );
1172
+ break;
1173
+ case 26:
1174
+ $on_day = __( 'on 26.', self::DOMAIN );
1175
+ break;
1176
+ case 27:
1177
+ $on_day = __( 'on 27.', self::DOMAIN );
1178
+ break;
1179
+ case 28:
1180
+ $on_day = __( 'on 28.', self::DOMAIN );
1181
+ break;
1182
+ case 29:
1183
+ $on_day = __( 'on 29.', self::DOMAIN );
1184
+ break;
1185
+ case 30:
1186
+ $on_day = __( 'on 30.', self::DOMAIN );
1187
+ break;
1188
+ case 31:
1189
+ $on_day = __( 'on 31.', self::DOMAIN );
1190
+ break;
1191
+ }
1192
+
1193
+ echo '<option ' . selected( in_array( "$i", $mday, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $on_day . '</option>';
1194
+ }
1195
+ ?>
1196
+ </select>
1197
+ </td>
1198
+ <td>
1199
+ <select name="a_moncronhours">
1200
+ <?php for ( $i = 0; $i < 24; $i ++ ) {
1201
+ echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1202
+ } ?>
1203
+ </select>
1204
+ </td>
1205
+ <td>
1206
+ <select name="a_moncronminutes">
1207
+ <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
1208
+ echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1209
+ } ?>
1210
+ </select>
1211
+ </td>
1212
+ </tr>
1213
+ <tr>
1214
+ <td>
1215
+ <label for="idcronbtype-week">
1216
+ <?php echo '<input class="radio" type="radio"' . checked( TRUE, is_numeric( $wday[0] ), FALSE ) . ' name="a_cronbtype" value="week" /> ' . __( 'weekly', self::DOMAIN ); ?>
1217
+ </label>
1218
+ </td>
1219
+ <td>
1220
+ <select name="a_weekcronwday">
1221
+ <?php
1222
+ echo '<option ' . selected( in_array( '0', $wday, TRUE ), TRUE, FALSE ) . ' value="0" />' . __( 'Sunday', self::DOMAIN ) . '</option>';
1223
+ echo '<option ' . selected( in_array( '1', $wday, TRUE ), TRUE, FALSE ) . ' value="1" />' . __( 'Monday', self::DOMAIN ) . '</option>';
1224
+ echo '<option ' . selected( in_array( '2', $wday, TRUE ), TRUE, FALSE ) . ' value="2" />' . __( 'Tuesday', self::DOMAIN ) . '</option>';
1225
+ echo '<option ' . selected( in_array( '3', $wday, TRUE ), TRUE, FALSE ) . ' value="3" />' . __( 'Wednesday', self::DOMAIN ) . '</option>';
1226
+ echo '<option ' . selected( in_array( '4', $wday, TRUE ), TRUE, FALSE ) . ' value="4" />' . __( 'Thursday', self::DOMAIN ) . '</option>';
1227
+ echo '<option ' . selected( in_array( '5', $wday, TRUE ), TRUE, FALSE ) . ' value="5" />' . __( 'Friday', self::DOMAIN ) . '</option>';
1228
+ echo '<option ' . selected( in_array( '6', $wday, TRUE ), TRUE, FALSE ) . ' value="6" />' . __( 'Saturday', self::DOMAIN ) . '</option>';
1229
+ ?>
1230
+ </select>
1231
+ </td>
1232
+ <td>
1233
+ <select name="a_weekcronhours">
1234
+ <?php for ( $i = 0; $i < 24; $i ++ ) {
1235
+ echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1236
+ } ?>
1237
+ </select>
1238
+ </td>
1239
+ <td>
1240
+ <select name="a_weekcronminutes">
1241
+ <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
1242
+ echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1243
+ } ?>
1244
+ </select>
1245
+ </td>
1246
+ </tr>
1247
+ <tr>
1248
+ <td>
1249
+ <label for="idcronbtype-day">
1250
+ <?php echo '<input class="radio" type="radio"' . checked( "**", $mday[0] . $wday[0], FALSE ) . ' name="a_cronbtype" value="day" /> ' . __( 'daily', self::DOMAIN ); ?>
1251
+ </label>
1252
+ </td>
1253
+ <td>
1254
+ </td>
1255
+ <td>
1256
+ <select name="a_daycronhours">
1257
+ <?php
1258
+ for ( $i = 0; $i < 24; $i ++ ) {
1259
+ echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1260
+ }
1261
+ ?>
1262
+ </select>
1263
+ </td>
1264
+ <td>
1265
+ <select name="a_daycronminutes">
1266
+ <?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
1267
+ echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1268
+ } ?>
1269
+ </select>
1270
+ </td>
1271
+ </tr>
1272
+ </table>
1273
+ </td>
1274
+ </tr>
1275
+ <?php
1276
+ }
1277
+ ?>
1278
+ </table>
1279
+ <div class="submit-button">
1280
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1281
+ <input type="submit" class="button button-secondary" name="update_share_comparison_base" value="<?php _e( 'Update Basis of Comparison', self::DOMAIN ); ?>" />
1282
+ </div>
1283
+ </div>
1284
+ </div>
1285
+ <div id="follow-base-cache" class="postbox">
1286
+ <div class="handlediv" title="Click to toggle"><br></div>
1287
+ <h3 class="hndle"><span><?php _e( 'Follow Base Cache', self::DOMAIN ); ?></span></h3>
1288
+ <div class="inside">
1289
+ <table class="form-table">
1290
+ <tr>
1291
+ <th><label><?php _e( 'Target SNS', self::DOMAIN ); ?></label></th>
1292
+ <td>
1293
+ <div class="sns-check">
1294
+ <input type="checkbox" value="1" 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"'; ?> />
1295
+ <label><?php _e( 'Instagram', self::DOMAIN ); ?></label>
1296
+ </div>
1297
+ <div class="sns-check">
1298
+ <input type="checkbox" value="1" 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"'; ?> />
1299
+ <label><?php _e( 'Facebook', self::DOMAIN ); ?></label>
1300
+ </div>
1301
+ <div class="sns-check">
1302
+ <input type="checkbox" value="1" 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"'; ?> />
1303
+ <label><?php _e( 'Feedly', self::DOMAIN ); ?></label>
1304
+ </div>
1305
+ <div class="sns-check">
1306
+ <input type="checkbox" value="1" 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"'; ?> />
1307
+ <label><?php _e( 'Push7', self::DOMAIN ); ?></label>
1308
+ </div>
1309
+ <div class="sns-check">
1310
+ <input type="checkbox" value="1" 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"'; ?> />
1311
+ <label><?php _e( 'Twitter', self::DOMAIN ); ?></label>
1312
+ </div>
1313
+ </td>
1314
+ </tr>
1315
+ <tr>
1316
+ <th><label><?php _e( 'Interval cheking follower count (sec)', self::DOMAIN ); ?></label></th>
1317
+ <td>
1318
+ <input type="text" class="text" name="follow_base_check_interval" size="20" value="<?php echo esc_attr( $this->follow_base_check_interval); ?>" />
1319
+ <label><?php _e( 'Default: 86400 Minimum: 3600', self::DOMAIN ); ?></label>
1320
+ </td>
1321
+ </tr>
1322
+ </table>
1323
+ <div class="submit-button">
1324
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1325
+ <input type="submit" class="button button-secondary" name="direct_follow_base_cache" value="<?php _e( 'Cache', self::DOMAIN ); ?>">
1326
+ <input type="submit" class="button button-secondary" name="clear_follow_base_cache" value="<?php _e( 'Clear Cache', self::DOMAIN ); ?>">
1327
+ </div>
1328
+ </div>
1329
+ </div>
1330
+ <?php if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_INSTAGRAM] ) && $this->follow_base_cache_target[self::REF_FOLLOW_INSTAGRAM] ) { ?>
1331
+ <div id="follow-base-cache-instagram" class="postbox">
1332
+ <div class="handlediv" title="Click to toggle"><br></div>
1333
+ <h3 class="hndle"><span><?php _e( 'Follow Base Cache - Instagram', self::DOMAIN ); ?></span></h3>
1334
+ <div class="inside">
1335
+ <table class="form-table">
1336
+ <tr>
1337
+ <th><label><?php _e( 'Client ID', self::DOMAIN ); ?></label></th>
1338
+ <td>
1339
+ <input type="password" class="text" name="follow_instagram_client_id" size="60" value="<?php echo esc_attr( $this->follow_instagram_client_id ); ?>" />
1340
+ <br>
1341
+ <label><?php _e( 'Instagram client ID for OAuth', self::DOMAIN ); ?></label>
1342
+ </td>
1343
+ </tr>
1344
+ <tr>
1345
+ <th><label><?php _e( 'Client secret', self::DOMAIN ); ?></label></th>
1346
+ <td>
1347
+ <input type="password" class="text" name="follow_instagram_client_secret" size="60" value="<?php echo esc_attr( $this->follow_instagram_client_secret ); ?>" />
1348
+ <br>
1349
+ <label><?php _e( 'Instagram client secret for OAuth', self::DOMAIN ); ?></label>
1350
+ </td>
1351
+ </tr>
1352
+ <tr>
1353
+ <th><label><?php _e( 'Redirect URI', self::DOMAIN ); ?></label></th>
1354
+ <td>
1355
+ <input type="text" 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 />
1356
+ <br>
1357
+ <label><?php _e( 'Copy and set this to the field of "Valid redirect URIs" in the client management page of Instagram developer page.', self::DOMAIN ); ?></label>
1358
+ </td>
1359
+ </tr>
1360
+ <?php if ( isset( $_GET['action'] ) && $_GET['action'] && $_GET['action'] === 'instagram-auth' ) { ?>
1361
+ <tr>
1362
+ <th><label><?php _e( 'Access token', self::DOMAIN ); ?></label></th>
1363
+ <td>
1364
+ <input type="text" 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 />
1365
+ <br>
1366
+ <label><?php _e( 'Copy and pase this into the fields below.', self::DOMAIN ); ?></label>
1367
+ </td>
1368
+ </tr>
1369
+ <?php } ?>
1370
+ <?php if ( isset( $this->follow_instagram_client_id ) && $this->follow_instagram_client_id && isset( $this->follow_instagram_client_secret ) && $this->follow_instagram_client_secret ) { ?>
1371
+ <tr>
1372
+ <th><label><?php _e( 'Access token', self::DOMAIN ); ?></label></th>
1373
+ <td>
1374
+ <input type="password" class="text" name="follow_instagram_access_token" size="60" value="<?php echo esc_attr( $this->follow_instagram_access_token ); ?>" />
1375
+ <br>
1376
+ <label><?php _e( 'Instagram access token for OAuth', self::DOMAIN ); ?></label>
1377
+ </td>
1378
+ </tr>
1379
+ <?php } ?>
1380
+ </table>
1381
+ <div class="submit-button">
1382
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1383
+ <?php if ( isset( $this->follow_instagram_client_id ) && $this->follow_instagram_client_id && isset( $this->follow_instagram_client_secret ) && $this->follow_instagram_client_secret ) { ?>
1384
+ <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>
1385
+ <?php } ?>
1386
+ </div>
1387
+ </div>
1388
+ </div>
1389
+ <?php } ?>
1390
+ <?php if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] ) && $this->follow_base_cache_target[self::REF_FOLLOW_FACEBOOK] ) { ?>
1391
+ <div id="follow-base-cache-facebook" class="postbox">
1392
+ <div class="handlediv" title="Click to toggle"><br></div>
1393
+ <h3 class="hndle"><span><?php _e( 'Follow Base Cache - Facebook', self::DOMAIN ); ?></span></h3>
1394
+ <div class="inside">
1395
+ <table class="form-table">
1396
+ <tr>
1397
+ <th><label><?php _e( 'Page ID', self::DOMAIN ); ?></label></th>
1398
+ <td>
1399
+ <input type="text" class="text" name="follow_facebook_page_id" size="30" value="<?php echo esc_attr( $this->follow_facebook_page_id ); ?>" />
1400
+ <br>
1401
+ <label><?php _e( 'Facebook page ID that you want to get follower count', self::DOMAIN ); ?></label>
1402
+ </td>
1403
+ </tr>
1404
+ <tr>
1405
+ <th><label><?php _e( 'App ID (Client ID)', self::DOMAIN ); ?></label></th>
1406
+ <td>
1407
+ <input type="password" class="text" name="follow_facebook_app_id" size="60" value="<?php echo esc_attr( $this->follow_facebook_app_id ); ?>" />
1408
+ <br>
1409
+ <label><?php _e( 'Facebook app ID for OAuth', self::DOMAIN ); ?></label>
1410
+ </td>
1411
+ </tr>
1412
+ <tr>
1413
+ <th><label><?php _e( 'App secret (Client secret)', self::DOMAIN ); ?></label></th>
1414
+ <td>
1415
+ <input type="password" class="text" name="follow_facebook_app_secret" size="60" value="<?php echo esc_attr( $this->follow_facebook_app_secret ); ?>" />
1416
+ <br>
1417
+ <label><?php _e( 'Facebook app secret for OAuth', self::DOMAIN ); ?></label>
1418
+ </td>
1419
+ </tr>
1420
+ <tr>
1421
+ <th><label><?php _e( 'Redirect URI', self::DOMAIN ); ?></label></th>
1422
+ <td>
1423
+ <input type="text" 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 />
1424
+ <br>
1425
+ <label><?php _e( 'Copy and set this to the field of "Valid OAuth redirect URIs" in client management page of Facebook developer page', self::DOMAIN ); ?></label>
1426
+ </td>
1427
+ </tr>
1428
+ <?php if ( isset( $_GET['action'] ) && $_GET['action'] && $_GET['action'] === 'facebook-auth' ) { ?>
1429
+ <tr>
1430
+ <th><label><?php _e( 'Access token', self::DOMAIN ); ?></label></th>
1431
+ <td>
1432
+ <input type="text" 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 />
1433
+ <br>
1434
+ <label><?php _e( 'Copy and pase this into the fields below.', self::DOMAIN ); ?></label>
1435
+ </td>
1436
+ </tr>
1437
+ <?php } ?>
1438
+ <?php if ( isset( $this->follow_facebook_app_id ) && $this->follow_facebook_app_id && isset( $this->follow_facebook_app_secret ) && $this->follow_facebook_app_secret ) { ?>
1439
+ <tr>
1440
+ <th><label><?php _e( 'Access token', self::DOMAIN ); ?></label></th>
1441
+ <td>
1442
+ <input type="password" class="text" name="follow_facebook_access_token" size="60" value="<?php echo esc_attr( $this->follow_facebook_access_token ); ?>" />
1443
+ <br>
1444
+ <label><?php _e( 'Facebook access token for OAuth', self::DOMAIN ); ?></label>
1445
+ </td>
1446
+ </tr>
1447
+ <?php } ?>
1448
+ </table>
1449
+ <div class="submit-button">
1450
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1451
+ <?php if ( isset( $this->follow_facebook_app_id ) && $this->follow_facebook_app_id && isset( $this->follow_facebook_app_secret ) && $this->follow_facebook_app_secret ) { ?>
1452
+ <a href="https://www.facebook.com/dialog/oauth?client_id=<?php echo esc_attr( $this->follow_facebook_app_id ); ?>&scope=manage_pages&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>
1453
+ <?php } ?>
1454
+ </div>
1455
+ </div>
1456
+ </div>
1457
+ <?php } ?>
1458
+ <?php if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_FEEDLY] ) && $this->follow_base_cache_target[self::REF_FOLLOW_FEEDLY] ) { ?>
1459
+ <div id="follow-base-cache-feedly" class="postbox">
1460
+ <div class="handlediv" title="Click to toggle"><br></div>
1461
+ <h3 class="hndle"><span><?php _e( 'Follow Base Cache - Feedly', self::DOMAIN ); ?></span></h3>
1462
+ <div class="inside">
1463
+ <table class="form-table">
1464
+ <tr>
1465
+ <th><label><?php _e( 'Target feed type', self::DOMAIN ); ?></label></th>
1466
+ <td>
1467
+ <select name="follow_feed_type">
1468
+ <option value="default"<?php if ( $this->follow_feed_type === self::OPT_FEED_TYPE_DEFAULT ) echo ' selected="selected"'; ?>><?php _e( 'Default', self::DOMAIN ) ?></option>
1469
+ <option value="rss"<?php if ( $this->follow_feed_type === self::OPT_FEED_TYPE_RSS ) echo ' selected="selected"'; ?>><?php _e( 'RSS', self::DOMAIN ); ?></option>
1470
+ <option value="rss2"<?php if ( $this->follow_feed_type === self::OPT_FEED_TYPE_RSS2 ) echo ' selected="selected"'; ?>><?php _e( 'RSS2', self::DOMAIN ); ?></option>
1471
+ <option value="rdf"<?php if ( $this->follow_feed_type === self::OPT_FEED_TYPE_RDF ) echo ' selected="selected"'; ?>><?php _e( 'RDF', self::DOMAIN ); ?></option>
1472
+ <option value="atom"<?php if ( $this->follow_feed_type === self::OPT_FEED_TYPE_ATOM ) echo ' selected="selected"'; ?>><?php _e( 'ATOM', self::DOMAIN ); ?></option>
1473
+ </select>
1474
+ <label><?php _e( 'Default: Default', self::DOMAIN ); ?></label>
1475
+ </td>
1476
+ </tr>
1477
+ <tr>
1478
+ <th><label><?php _e( 'Target feed', self::DOMAIN ); ?></label></th>
1479
+ <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>
1480
+ </tr>
1481
+ </table>
1482
+ <div class="submit-button">
1483
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1484
+ </div>
1485
+ </div>
1486
+ </div>
1487
+ <?php } ?>
1488
+ <?php if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_PUSH7] ) && $this->follow_base_cache_target[self::REF_FOLLOW_PUSH7] ) { ?>
1489
+ <div id="follow-base-cache-push7" class="postbox">
1490
+ <div class="handlediv" title="Click to toggle"><br></div>
1491
+ <h3 class="hndle"><span><?php _e( 'Follow Base Cache - Push7', self::DOMAIN ); ?></span></h3>
1492
+ <div class="inside">
1493
+ <table class="form-table">
1494
+ <tr>
1495
+ <th><label><?php _e( 'AppNo', self::DOMAIN ); ?></label></th>
1496
+ <td>
1497
+ <input type="password" class="text" name="follow_push7_appno" size="60" value="<?php echo esc_attr( $this->follow_push7_appno ); ?>" />
1498
+ <br>
1499
+ <label><?php _e( 'Push7 appno to access Push7 API', self::DOMAIN ); ?></label>
1500
+ </td>
1501
+ </tr>
1502
+ </table>
1503
+ <div class="submit-button">
1504
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1505
+ </div>
1506
+ </div>
1507
+ </div>
1508
+ <?php } ?>
1509
+ <?php if ( isset( $this->follow_base_cache_target[self::REF_FOLLOW_TWITTER] ) && $this->follow_base_cache_target[self::REF_FOLLOW_TWITTER] ) { ?>
1510
+ <div id="follow-base-cache-twitter" class="postbox">
1511
+ <div class="handlediv" title="Click to toggle"><br></div>
1512
+ <h3 class="hndle"><span><?php _e( 'Follow Base Cache - Twitter', self::DOMAIN ); ?></span></h3>
1513
+ <div class="inside">
1514
+ <table class="form-table">
1515
+ <tr>
1516
+ <th><label><?php _e( 'Screen name', self::DOMAIN ); ?></label></th>
1517
+ <td>
1518
+ <span class="at-mark">@</span>
1519
+ <input type="text" class="text" name="follow_twitter_screen_name" size="30" value="<?php echo esc_attr( $this->follow_twitter_screen_name ); ?>" />
1520
+ <br>
1521
+ <label><?php _e( 'Twitter screen name that you want to get follower count', self::DOMAIN ); ?></label>
1522
+ </td>
1523
+ </tr>
1524
+ <tr>
1525
+ <th><label><?php _e( 'Consumer key (API Key)', self::DOMAIN ); ?></label></th>
1526
+ <td>
1527
+ <input type="password" class="text" name="follow_twitter_consumer_key" size="60" value="<?php echo esc_attr( $this->follow_twitter_consumer_key ); ?>" />
1528
+ <br>
1529
+ <label><?php _e( 'Twitter consumer key for OAuth', self::DOMAIN ); ?></label>
1530
+ </td>
1531
+ </tr>
1532
+ <tr>
1533
+ <th><label><?php _e( 'Consumer secret (API Secret)', self::DOMAIN ); ?></label></th>
1534
+ <td>
1535
+ <input type="password" class="text" name="follow_twitter_consumer_secret" size="60" value="<?php echo esc_attr( $this->follow_twitter_consumer_secret ); ?>" />
1536
+ <br>
1537
+ <label><?php _e( 'Twitter consumer secret for OAuth', self::DOMAIN ); ?></label>
1538
+ </td>
1539
+ </tr>
1540
+ <?php if ( isset( $_POST["get_tiwtter_bearer_token"] ) && $_POST["get_tiwtter_bearer_token"] === __( 'Get Bearer Token', self::DOMAIN ) ) { ?>
1541
+ <tr>
1542
+ <th><label><?php _e( 'Bearer token', self::DOMAIN ); ?></label></th>
1543
+ <td>
1544
+ <input type="text" 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 />
1545
+ <br>
1546
+ <label><?php _e( 'Copy and pase this into the fields below.', self::DOMAIN ); ?></label>
1547
+ </td>
1548
+ </tr>
1549
+ <?php } ?>
1550
+ <?php if ( isset( $this->follow_twitter_consumer_key ) && $this->follow_twitter_consumer_key && isset( $this->follow_twitter_consumer_secret ) && $this->follow_twitter_consumer_secret ) { ?>
1551
+ <tr>
1552
+ <th><label><?php _e( 'Bearer token', self::DOMAIN ); ?></label></th>
1553
+ <td>
1554
+ <input type="password" class="text" name="follow_twitter_bearer_token" size="60" value="<?php echo esc_attr( $this->follow_twitter_bearer_token ); ?>" />
1555
+ <br>
1556
+ <label><?php _e( 'Twitter bearer token for OAuth', self::DOMAIN ); ?></label>
1557
+ </td>
1558
+ </tr>
1559
+ <?php } ?>
1560
+ <!--
1561
+ <tr>
1562
+ <th><label><?php /* _e( 'Access token', self::DOMAIN ); */ ?></label></th>
1563
+ <td>
1564
+ <input type="password" class="text" name="follow_twitter_access_token" size="60" value="<?php /* echo esc_attr( $this->follow_twitter_access_token ); */ ?>" />
1565
+ <br>
1566
+ <label><?php /* _e( 'Twitter access token for OAuth', self::DOMAIN ); */ ?></label>
1567
+ </td>
1568
+ </tr>
1569
+ <tr>
1570
+ <th><label><?php /* _e( 'Access token secret', self::DOMAIN ); */ ?></label></th>
1571
+ <td>
1572
+ <input type="password" class="text" name="follow_twitter_access_token_secret" size="60" value="<?php /* echo esc_attr( $this->follow_twitter_access_token_secret ); */ ?>" />
1573
+ <br>
1574
+ <label><?php /* _e( 'Twitter access token secret for OAuth', self::DOMAIN ); */ ?></label>
1575
+ </td>
1576
+ </tr>
1577
+ -->
1578
+ </table>
1579
+ <div class="submit-button">
1580
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1581
+ <?php if ( isset( $this->follow_twitter_consumer_key ) && $this->follow_twitter_consumer_key && isset( $this->follow_twitter_consumer_secret ) && $this->follow_twitter_consumer_secret ) { ?>
1582
+ <input type="submit" class="button button-secondary" name="get_tiwtter_bearer_token" value="<?php _e( 'Get Bearer Token', self::DOMAIN ); ?>" />
1583
+ <?php } ?>
1584
+ </div>
1585
+ </div>
1586
+ </div>
1587
+ <?php } ?>
1588
+ <div id="common-dynamic-cache" class="postbox">
1589
+ <div class="handlediv" title="Click to toggle"><br></div>
1590
+ <h3 class="hndle"><span><?php _e( 'Dynamic Cache', self::DOMAIN ); ?></span></h3>
1591
+ <div class="inside">
1592
+ <table class="form-table">
1593
+ <tr>
1594
+ <th><label><?php _e( 'Dynamic caching based on user access', self::DOMAIN ); ?></label></th>
1595
+ <td>
1596
+ <select name="dynamic_cache_mode">
1597
+ <option value="1"<?php if ( $this->dynamic_cache_mode === self::OPT_COMMON_ACCESS_BASED_CACHE_NONE ) echo ' selected="selected"'; ?>><?php _e( 'Disabled (None)', self::DOMAIN ); ?></option>
1598
+ <option value="2"<?php if ( $this->dynamic_cache_mode === self::OPT_COMMON_ACCESS_BASED_SYNC_CACHE ) echo ' selected="selected"'; ?>><?php _e( 'Enabled (Synchronous Cache)', self::DOMAIN ); ?></option>
1599
+ <option value="3"<?php if ( $this->dynamic_cache_mode === self::OPT_COMMON_ACCESS_BASED_ASYNC_CACHE ) echo ' selected="selected"'; ?>><?php _e( 'Enabled (Asynchronous Cache)', self::DOMAIN ); ?></option>
1600
+ <option value="4"<?php if ( $this->dynamic_cache_mode === self::OPT_COMMON_ACCESS_BASED_2ND_CACHE ) echo ' selected="selected"'; ?>><?php _e( 'Enabled (Asynchronous 2nd Cache)', self::DOMAIN ); ?></option>
1601
+ </select>
1602
+ <label><?php _e( 'Default: Enabled (Asynchronous 2nd Cache)', self::DOMAIN ); ?></label>
1603
+ </td>
1604
+ </tr>
1605
+ </table>
1606
+ <div class="submit-button">
1607
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1608
+ </div>
1609
+ </div>
1610
+ </div>
1611
+ <div id="common-data-crawler" class="postbox">
1612
+ <div class="handlediv" title="Click to toggle"><br></div>
1613
+ <h3 class="hndle"><span><?php _e( 'Data Crawler', self::DOMAIN ); ?></span></h3>
1614
+ <div class="inside">
1615
+ <table class="form-table">
1616
+ <tr>
1617
+ <th><label><?php _e( 'Crawl method', self::DOMAIN ); ?></label></th>
1618
+ <td>
1619
+ <?php
1620
+ switch ( $this->crawler_method ) {
1621
+ case self::OPT_COMMON_CRAWLER_METHOD_NORMAL:
1622
+ _e( 'Normal (Sequential Retrieval)', self::DOMAIN );
1623
+ break;
1624
+ case self::OPT_COMMON_CRAWLER_METHOD_CURL:
1625
+ _e( 'Extended (Parallel Retrieval)', self::DOMAIN );
1626
+ break;
1627
+ }
1628
+ ?>
1629
+ </td>
1630
+ </tr>
1631
+ <tr>
1632
+ <th><label><?php _e( 'SSL verification', self::DOMAIN ); ?></label></th>
1633
+ <td>
1634
+ <select name="crawler_ssl_verification">
1635
+ <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>
1636
+ <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>
1637
+ </select>
1638
+ <label><?php _e( 'Default: On', self::DOMAIN ); ?></label>
1639
+ </td>
1640
+ </tr>
1641
+ </table>
1642
+ <div class="submit-button">
1643
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1644
+ </div>
1645
+ </div>
1646
+ </div>
1647
+ <div id="common-data-export" class="postbox">
1648
+ <div class="handlediv" title="Click to toggle"><br></div>
1649
+ <h3 class="hndle"><span><?php _e( 'Data Export', self::DOMAIN ); ?></span></h3>
1650
+ <div class="inside">
1651
+ <table class="form-table">
1652
+ <tr>
1653
+ <th><label><?php _e( 'Method of data export', self::DOMAIN ); ?></label></th>
1654
+ <td>
1655
+ <select name="data_export_mode">
1656
+ <option value="1"<?php if ( $this->data_export_mode === self::OPT_COMMON_DATA_EXPORT_MANUAL ) echo ' selected="selected"'; ?>><?php _e( 'Manual', self::DOMAIN ); ?></option>
1657
+ <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>
1658
+ </select>
1659
+ <label><?php _e( 'Default: Manual', self::DOMAIN ); ?></label>
1660
+ </td>
1661
+ </tr>
1662
+ <?php
1663
+ if ( $this->data_export_mode === self::OPT_COMMON_DATA_EXPORT_SCHEDULER ) {
1664
+ list( $cronstr[ 'minutes' ], $cronstr[ 'hours' ], $cronstr[ 'mday' ], $cronstr[ 'mon' ], $cronstr[ 'wday' ] ) = explode( ' ', $this->data_export_schedule, 5 );
1665
+ if ( strstr( $cronstr[ 'minutes' ], '*/' ) ) {
1666
+ $minutes = explode( '/', $cronstr[ 'minutes' ] );
1667
+ } else {
1668
+ $minutes = explode( ',', $cronstr[ 'minutes' ] );
1669
+ }
1670
+ if ( strstr( $cronstr[ 'hours' ], '*/' ) ) {
1671
+ $hours = explode( '/', $cronstr[ 'hours' ] );
1672
+ } else {
1673
+ $hours = explode( ',', $cronstr[ 'hours' ] );
1674
+ }
1675
+ if ( strstr( $cronstr[ 'mday' ], '*/' ) ) {
1676
+ $mday = explode( '/', $cronstr[ 'mday' ] );
1677
+ } else {
1678
+ $mday = explode( ',', $cronstr[ 'mday' ] );
1679
+ }
1680
+ if ( strstr( $cronstr[ 'mon' ], '*/' ) ) {
1681
+ $mon = explode( '/', $cronstr[ 'mon' ] );
1682
+ } else {
1683
+ $mon = explode( ',', $cronstr[ 'mon' ] );
1684
+ }
1685
+ if ( strstr( $cronstr[ 'wday' ], '*/' ) ) {
1686
+ $wday = explode( '/', $cronstr[ 'wday' ] );
1687
+ } else {
1688
+ $wday = explode( ',', $cronstr[ 'wday' ] );
1689
+ }
1690
+ ?>
1691
+ <tr class="e_wpcron">
1692
+ <th scope="row"><?php _e( 'Scheduler', self::DOMAIN ); ?></th>
1693
+ <td>
1694
+ <table class="wpcron">
1695
+ <tr>
1696
+ <th>
1697
+ <?php _e( 'Type', self::DOMAIN ); ?>
1698
+ </th>
1699
+ <th>
1700
+ </th>
1701
+ <th>
1702
+ <?php _e( 'Hour', self::DOMAIN ); ?>
1703
+ </th>
1704
+ <th>
1705
+ <?php _e( 'Minute', self::DOMAIN ); ?>
1706
+ </th>
1707
+ </tr>
1708
+ <tr>
1709
+ <td>
1710
+ <label for="idcronbtype-mon">
1711
+ <?php echo '<input class="radio" type="radio"' . checked( TRUE, is_numeric( $mday[0] ), FALSE ) . ' name="e_cronbtype" value="mon" /> ' . __( 'monthly', self::DOMAIN ); ?>
1712
+ </label>
1713
+ </td>
1714
+ <td>
1715
+ <select name="e_moncronmday">
1716
+ <?php
1717
+ for ( $i = 1; $i <= 31; $i ++ ) {
1718
+ $on_day = '';
1719
+
1720
+ switch ( $i ) {
1721
+ case 1:
1722
+ $on_day = __( 'on 1.', self::DOMAIN );
1723
+ break;
1724
+ case 2:
1725
+ $on_day = __( 'on 2.', self::DOMAIN );
1726
+ break;
1727
+ case 3:
1728
+ $on_day = __( 'on 3.', self::DOMAIN );
1729
+ break;
1730
+ case 4:
1731
+ $on_day = __( 'on 4.', self::DOMAIN );
1732
+ break;
1733
+ case 5:
1734
+ $on_day = __( 'on 5.', self::DOMAIN );
1735
+ break;
1736
+ case 6:
1737
+ $on_day = __( 'on 6.', self::DOMAIN );
1738
+ break;
1739
+ case 7:
1740
+ $on_day = __( 'on 7.', self::DOMAIN );
1741
+ break;
1742
+ case 8:
1743
+ $on_day = __( 'on 8.', self::DOMAIN );
1744
+ break;
1745
+ case 9:
1746
+ $on_day = __( 'on 9.', self::DOMAIN );
1747
+ break;
1748
+ case 10:
1749
+ $on_day = __( 'on 10.', self::DOMAIN );
1750
+ break;
1751
+ case 11:
1752
+ $on_day = __( 'on 11.', self::DOMAIN );
1753
+ break;
1754
+ case 12:
1755
+ $on_day = __( 'on 12.', self::DOMAIN );
1756
+ break;
1757
+ case 13:
1758
+ $on_day = __( 'on 13.', self::DOMAIN );
1759
+ break;
1760
+ case 14:
1761
+ $on_day = __( 'on 14.', self::DOMAIN );
1762
+ break;
1763
+ case 15:
1764
+ $on_day = __( 'on 15.', self::DOMAIN );
1765
+ break;
1766
+ case 16:
1767
+ $on_day = __( 'on 16.', self::DOMAIN );
1768
+ break;
1769
+ case 17:
1770
+ $on_day = __( 'on 17.', self::DOMAIN );
1771
+ break;
1772
+ case 18:
1773
+ $on_day = __( 'on 18.', self::DOMAIN );
1774
+ break;
1775
+ case 19:
1776
+ $on_day = __( 'on 19.', self::DOMAIN );
1777
+ break;
1778
+ case 20:
1779
+ $on_day = __( 'on 20.', self::DOMAIN );
1780
+ break;
1781
+ case 21:
1782
+ $on_day = __( 'on 21.', self::DOMAIN );
1783
+ break;
1784
+ case 22:
1785
+ $on_day = __( 'on 22.', self::DOMAIN );
1786
+ break;
1787
+ case 23:
1788
+ $on_day = __( 'on 23.', self::DOMAIN );
1789
+ break;
1790
+ case 24:
1791
+ $on_day = __( 'on 24.', self::DOMAIN );
1792
+ break;
1793
+ case 25:
1794
+ $on_day = __( 'on 25.', self::DOMAIN );
1795
+ break;
1796
+ case 26:
1797
+ $on_day = __( 'on 26.', self::DOMAIN );
1798
+ break;
1799
+ case 27:
1800
+ $on_day = __( 'on 27.', self::DOMAIN );
1801
+ break;
1802
+ case 28:
1803
+ $on_day = __( 'on 28.', self::DOMAIN );
1804
+ break;
1805
+ case 29:
1806
+ $on_day = __( 'on 29.', self::DOMAIN );
1807
+ break;
1808
+ case 30:
1809
+ $on_day = __( 'on 30.', self::DOMAIN );
1810
+ break;
1811
+ case 31:
1812
+ $on_day = __( 'on 31.', self::DOMAIN );
1813
+ break;
1814
+ }
1815
+
1816
+ echo '<option ' . selected( in_array( "$i", $mday, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $on_day . '</option>';
1817
+ }
1818
+ ?>
1819
+ </select>
1820
+ </td>
1821
+ <td>
1822
+ <select name="e_moncronhours">
1823
+ <?php
1824
+ for ( $i = 0; $i < 24; $i ++ ) {
1825
+ echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1826
+ }
1827
+ ?>
1828
+ </select>
1829
+ </td>
1830
+ <td>
1831
+ <select name="e_moncronminutes">
1832
+ <?php
1833
+ for ( $i = 0; $i < 60; $i = $i + 5 ) {
1834
+ echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1835
+ }
1836
+ ?>
1837
+ </select>
1838
+ </td>
1839
+ </tr>
1840
+ <tr>
1841
+ <td>
1842
+ <label for="idcronbtype-week">
1843
+ <?php echo '<input class="radio" type="radio"' . checked( TRUE, is_numeric( $wday[0] ), FALSE ) . ' name="e_cronbtype" value="week" /> ' . __( 'weekly', self::DOMAIN ); ?>
1844
+ </label>
1845
+ </td>
1846
+ <td>
1847
+ <select name="e_weekcronwday">
1848
+ <?php
1849
+ echo '<option ' . selected( in_array( '0', $wday, TRUE ), TRUE, FALSE ) . ' value="0" />' . __( 'Sunday', self::DOMAIN ) . '</option>';
1850
+ echo '<option ' . selected( in_array( '1', $wday, TRUE ), TRUE, FALSE ) . ' value="1" />' . __( 'Monday', self::DOMAIN ) . '</option>';
1851
+ echo '<option ' . selected( in_array( '2', $wday, TRUE ), TRUE, FALSE ) . ' value="2" />' . __( 'Tuesday', self::DOMAIN ) . '</option>';
1852
+ echo '<option ' . selected( in_array( '3', $wday, TRUE ), TRUE, FALSE ) . ' value="3" />' . __( 'Wednesday', self::DOMAIN ) . '</option>';
1853
+ echo '<option ' . selected( in_array( '4', $wday, TRUE ), TRUE, FALSE ) . ' value="4" />' . __( 'Thursday', self::DOMAIN ) . '</option>';
1854
+ echo '<option ' . selected( in_array( '5', $wday, TRUE ), TRUE, FALSE ) . ' value="5" />' . __( 'Friday', self::DOMAIN ) . '</option>';
1855
+ echo '<option ' . selected( in_array( '6', $wday, TRUE ), TRUE, FALSE ) . ' value="6" />' . __( 'Saturday', self::DOMAIN ) . '</option>';
1856
+ ?>
1857
+ </select>
1858
+ </td>
1859
+ <td>
1860
+ <select name="e_weekcronhours">
1861
+ <?php
1862
+ for ( $i = 0; $i < 24; $i ++ ) {
1863
+ echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1864
+ }
1865
+ ?>
1866
+ </select>
1867
+ </td>
1868
+ <td>
1869
+ <select name="e_weekcronminutes">
1870
+ <?php
1871
+ for ( $i = 0; $i < 60; $i = $i + 5 ) {
1872
+ echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1873
+ }
1874
+ ?>
1875
+ </select>
1876
+ </td>
1877
+ </tr>
1878
+ <tr>
1879
+ <td>
1880
+ <label for="idcronbtype-day">
1881
+ <?php echo '<input class="radio" type="radio"' . checked( "**", $mday[0] . $wday[0], FALSE ) . ' name="e_cronbtype" value="day" /> ' . __( 'daily', self::DOMAIN ); ?>
1882
+ </label>
1883
+ </td>
1884
+ <td>
1885
+ </td>
1886
+ <td>
1887
+ <select name="e_daycronhours">
1888
+ <?php
1889
+ for ( $i = 0; $i < 24; $i ++ ) {
1890
+ echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1891
+ }
1892
+ ?>
1893
+ </select>
1894
+ </td>
1895
+ <td>
1896
+ <select name="e_daycronminutes">
1897
+ <?php
1898
+ for ( $i = 0; $i < 60; $i = $i + 5 ) {
1899
+ echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1900
+ }
1901
+ ?>
1902
+ </select>
1903
+ </td>
1904
+ </tr>
1905
+ <tr>
1906
+ <td>
1907
+ <label for="idcronbtype-hour">
1908
+ <?php echo '<input class="radio" type="radio"' . checked( "*", $hours[0], FALSE, FALSE ) . ' name="e_cronbtype" value="hour" /> ' . __( 'hourly', self::DOMAIN ); ?>
1909
+ </label>
1910
+ </td>
1911
+ <td></td>
1912
+ <td></td>
1913
+ <td>
1914
+ <select name="e_hourcronminutes">
1915
+ <?php
1916
+ for ( $i = 0; $i < 60; $i = $i + 5 ) {
1917
+ echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
1918
+ }
1919
+ ?>
1920
+ </select>
1921
+ </td>
1922
+ </tr>
1923
+ </table>
1924
+ </td>
1925
+ </tr>
1926
+ <?php
1927
+ }
1928
+ ?>
1929
+ </table>
1930
+ <div class="submit-button">
1931
+ <input type="submit" class="button button-primary" name="update_all_options" value="<?php _e( 'Update All Options', self::DOMAIN ); ?>" />
1932
+ </div>
1933
+ </div>
1934
+ </div>
1935
+ </form>
1936
+ </div>
1937
+ <div class="metabox-holder">
1938
+ <div id="common-exported-file" class="postbox">
1939
+ <div class="handlediv" title="Click to toggle"><br></div>
1940
+ <h3 class="hndle"><span><?php _e( 'Exported File', self::DOMAIN ); ?></span></h3>
1941
+ <div class="inside">
1942
+ <table class="form-table">
1943
+ <tbody>
1944
+ <tr>
1945
+ <th><?php _e( 'Disk usage of exported file', self::DOMAIN ); ?></th>
1946
+ <td>
1947
+ <?php
1948
+ $abs_path = WP_PLUGIN_DIR . '/sns-count-cache/data/sns-count-cache-data.csv';
1949
+ $file_size = Common_Util::get_file_size( $abs_path );
1950
+
1951
+ if ( isset( $file_size ) ) {
1952
+ echo $file_size;
1953
+ } else {
1954
+ _e( 'No exported file', self::DOMAIN );
1955
+ }
1956
+ ?>
1957
+ </td>
1958
+ </tr>
1959
+ </tbody>
1960
+ </table>
1961
+ <form action="admin.php?page=scc-setting" method="post">
1962
+ <?php wp_nonce_field( __FILE__, '_wpnonce' ); ?>
1963
+ <table class="form-table">
1964
+ <tbody>
1965
+ <tr>
1966
+ <th><?php _e( 'Manual export', self::DOMAIN ); ?></th>
1967
+ <td>
1968
+ <input type="submit" class="button button-secondary" name="export_data" value="<?php _e( 'Export', self::DOMAIN ); ?>" />
1969
+ <br>
1970
+ <span class="description"><?php _e( 'Export share count to a csv file.', self::DOMAIN ); ?></span>
1971
+ </td>
1972
+ </tr>
1973
+ </tbody>
1974
+ </table>
1975
+ </form>
1976
+ <?php
1977
+ if ( file_exists( $abs_path ) ) {
1978
+ ?>
1979
+ <form action="admin.php?page=scc-setting" method="post">
1980
+ <?php wp_nonce_field( __FILE__, '_wpnonce' ); ?>
1981
+ <table class="form-table">
1982
+ <tbody>
1983
+ <tr>
1984
+ <th><?php _e( 'Reset of exported file', self::DOMAIN ); ?></th>
1985
+ <td>
1986
+ <input type="submit" class="button button-secondary" name="reset_data" value="<?php _e( 'Reset', self::DOMAIN ); ?>" />
1987
+ <br>
1988
+ <span class="description"><?php _e( 'Clear exported csv file.', self::DOMAIN ); ?></span>
1989
+ </td>
1990
+ </tr>
1991
+ </tbody>
1992
+ </table>
1993
+ </form>
1994
+ <form action="<?php echo plugins_url(); ?>/sns-count-cache/includes/download.php" method="post">
1995
+ <?php wp_nonce_field( 'download', '_wpnonce' ); ?>
1996
+ <table class="form-table">
1997
+ <tbody>
1998
+ <tr>
1999
+ <th><?php _e( 'Download of exported file', self::DOMAIN ); ?></th>
2000
+ <td>
2001
+ <input type="submit" class="button button-secondary" name="download_data" value="<?php _e( 'Download', self::DOMAIN ); ?>" />
2002
+ <br>
2003
+ <span class="description"><?php _e( 'Download the exported csv file.', self::DOMAIN ); ?></span>
2004
+ </td>
2005
+ </tr>
2006
+ </tbody>
2007
+ </table>
2008
+ </form>
2009
+ <?php
2010
+ }
2011
+ ?>
2012
+ </div>
2013
+ </div>
2014
+ </div>
2015
+ </div>
2016
+ </div>
includes/admin-share-count.php CHANGED
@@ -1,488 +1,446 @@
1
- <?php
2
- /*
3
- admin-share-count.php
4
-
5
- Description: Option page implementation
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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
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
-
39
- if ( current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
40
- if( isset( $_GET["key"] ) ) {
41
- $sort_mode = true;
42
- $sns = $_GET["key"];
43
-
44
- if ( $sns === 'Google' ) {
45
- $sns = $sns . '+';
46
- }
47
-
48
- $sort_exec_key = $sns;
49
-
50
- $meta_key = $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-share-count"><?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 nav-tab-active" href="admin.php?page=scc-share-count"><?php _e( 'Share Count', self::DOMAIN ); ?></a>
75
- <?php if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) { ?>
76
- <a class="nav-tab" href="admin.php?page=scc-hot-content"><?php _e( 'Hot Content', self::DOMAIN ); ?></a>
77
- <?php } ?>
78
- <a class="nav-tab" href="admin.php?page=scc-setting"><?php _e( 'Setting', self::DOMAIN ); ?></a>
79
- <a class="nav-tab" href="admin.php?page=scc-help"><?php _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 _e( 'Share Count', self::DOMAIN ); ?></span></h3>
85
- <div class="inside">
86
- <table class="view-table">
87
- <thead>
88
- <tr>
89
- <th>No.</th>
90
- <th><?php _e( 'Content', self::DOMAIN ); ?></th>
91
- <?php
92
-
93
- foreach ( $share_base_cache_target as $sns => $active ) {
94
-
95
- if ( $active ) {
96
-
97
- $sort_key = $sns;
98
-
99
- if ( $sort_key === self::REF_SHARE_GPLUS ) {
100
- $sort_key = str_replace( '+', '', $sort_key );
101
- }
102
-
103
- $sort_url = esc_url( 'admin.php?page=scc-share-count&action=sort&key=' . $sort_key );
104
-
105
- $sns_name = '';
106
-
107
- switch ( $sns ) {
108
- case self::REF_SHARE_TWITTER:
109
- $sns_name = __( 'Twitter', self::DOMAIN );
110
- break;
111
- case self::REF_SHARE_FACEBOOK:
112
- $sns_name = __( 'Facebook', self::DOMAIN );
113
- break;
114
- case self::REF_SHARE_GPLUS:
115
- $sns_name = __( 'Google+', self::DOMAIN );
116
- break;
117
- case self::REF_SHARE_POCKET:
118
- $sns_name = __( 'Pocket', self::DOMAIN );
119
- break;
120
- case self::REF_SHARE_HATEBU:
121
- $sns_name = __( 'Hatebu', self::DOMAIN );
122
- break;
123
- case self::REF_SHARE_TOTAL:
124
- $sns_name = __( 'Total', self::DOMAIN );
125
- break;
126
- }
127
-
128
- if ( $sns === $sort_exec_key ) {
129
- echo '<th><a class="sort-exec-key" href="' . $sort_url . '">' . esc_html( $sns_name ) . '</th>';
130
- } else {
131
- echo '<th><a href="' . $sort_url . '">' . esc_html( $sns_name ) . '</th>';
132
- }
133
- }
134
- }
135
- ?>
136
- </tr>
137
- </thead>
138
- <tbody>
139
-
140
- <?php
141
-
142
- if( $sort_mode ) {
143
- $query_args = array(
144
- 'post_type' => $this->share_base_cache_post_types,
145
- 'post_status' => 'publish',
146
- 'posts_per_page' => $posts_per_page,
147
- 'paged' => $paged,
148
- 'meta_key' => $meta_key,
149
- 'orderby' => 'meta_value_num',
150
- 'update_post_term_cache' => false,
151
- 'order' => 'DESC'
152
- );
153
-
154
- } else {
155
-
156
- $query_args = array(
157
- 'post_type' => $this->share_base_cache_post_types,
158
- 'post_status' => 'publish',
159
- 'posts_per_page' => $posts_per_page,
160
- 'paged' => $paged,
161
- 'update_post_term_cache' => false
162
- );
163
- }
164
-
165
- $posts_query = new WP_Query( $query_args );
166
-
167
- $count = ( $paged - 1 ) * $posts_per_page + 1;
168
-
169
- if ( $paged === 1 ) {
170
- ?>
171
-
172
- <tr class="home">
173
- <td><?php echo '-'; ?></td>
174
- <td><a href="<?php echo esc_url( home_url( '/' ) ); ?>" target="_blank"><?php echo esc_html( bloginfo('name') ); ?></a></td>
175
- <?php
176
-
177
- if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) {
178
- $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( 'home' );
179
-
180
- if ( false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
181
-
182
- $option_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( 'home' );
183
-
184
- if ( false !== ( $sns_deltas = get_option( $option_key ) ) ) {
185
-
186
- foreach ( $share_base_cache_target as $sns => $active ) {
187
- if ( $active ) {
188
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
189
- echo '<td class="share-count">';
190
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
191
-
192
- if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
193
- echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
194
- } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
195
- echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
196
- }
197
-
198
- echo '</td>';
199
- } else {
200
- echo '<td class="not-cached share-count">';
201
- _e( 'N/A', self::DOMAIN );
202
- echo '</td>';
203
- }
204
- }
205
- }
206
-
207
- } else {
208
-
209
- foreach ( $share_base_cache_target as $sns => $active ) {
210
- if ( $active ) {
211
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
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
- _e( 'N/A', self::DOMAIN );
218
- echo '</td>';
219
- }
220
- }
221
- }
222
- }
223
-
224
- } else {
225
-
226
- $option_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( 'home' );
227
-
228
- if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
229
-
230
- $option_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( 'home' );
231
-
232
- if ( false !== ( $sns_deltas = get_option( $option_key ) ) ) {
233
- foreach ( $share_base_cache_target as $sns => $active ) {
234
- if( $active ){
235
-
236
- if ( $sns_counts[$sns] >= 0 ) {
237
- echo '<td class="share-count">';
238
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
239
-
240
- if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
241
- echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
242
- } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
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
- _e( 'N/A', self::DOMAIN );
250
- echo '</td>';
251
- }
252
- }
253
- }
254
- } else {
255
- foreach ( $share_base_cache_target as $sns => $active ) {
256
- if ( $active ) {
257
-
258
- if ( $sns_counts[$sns] >= 0 ) {
259
- echo '<td class="share-count">';
260
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
261
- echo '</td>';
262
- } else {
263
- echo '<td class="not-cached share-count">';
264
- _e( 'N/A', self::DOMAIN );
265
- echo '</td>';
266
- }
267
- }
268
- }
269
- }
270
- } else {
271
- foreach ( $share_base_cache_target as $sns => $active ) {
272
- if ( $active ) {
273
- echo '<td class="not-cached share-count">';
274
- _e( 'N/A', self::DOMAIN );
275
- echo '</td>';
276
- }
277
- }
278
- }
279
-
280
- }
281
- } else {
282
- $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( 'home' );
283
-
284
- if ( false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
285
-
286
- $option_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( 'home' );
287
-
288
- if ( false !== ( $sns_deltas = get_option( $option_key ) ) ) {
289
-
290
- foreach ( $share_base_cache_target as $sns => $active ) {
291
- if ( $active ) {
292
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
293
- echo '<td class="share-count">';
294
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
295
-
296
- if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
297
- echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
298
- } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
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
- _e( 'N/A', self::DOMAIN );
306
- echo '</td>';
307
- }
308
- }
309
- }
310
-
311
- } else {
312
-
313
- foreach ( $share_base_cache_target as $sns => $active ) {
314
- if ( $active ) {
315
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
316
- echo '<td class="share-count">';
317
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
318
- echo '</td>';
319
- } else {
320
- echo '<td class="not-cached share-count">';
321
- _e( 'N/A', self::DOMAIN );
322
- echo '</td>';
323
- }
324
- }
325
- }
326
- }
327
-
328
-
329
- } else {
330
-
331
- $option_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( 'home' );
332
-
333
- if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
334
-
335
- $option_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( 'home' );
336
-
337
- if ( false !== ( $sns_deltas = get_option( $option_key ) ) ) {
338
- foreach ( $share_base_cache_target as $sns => $active ) {
339
- if( $active ){
340
-
341
- if ( $sns_counts[$sns] >= 0 ) {
342
- echo '<td class="share-count">';
343
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
344
-
345
- if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
346
- echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
347
- } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
348
- echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
349
- }
350
-
351
- echo '</td>';
352
- } else {
353
- echo '<td class="not-cached share-count">';
354
- _e( 'N/A', self::DOMAIN );
355
- echo '</td>';
356
- }
357
- }
358
- }
359
- } else {
360
- foreach ( $share_base_cache_target as $sns => $active ) {
361
- if ( $active ){
362
-
363
- if ( $sns_counts[$sns] >= 0 ) {
364
- echo '<td class="share-count">';
365
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
366
- echo '</td>';
367
- } else {
368
- echo '<td class="not-cached share-count">';
369
- _e( 'N/A', self::DOMAIN );
370
- echo '</td>';
371
- }
372
- }
373
- }
374
- }
375
- } else {
376
- foreach ( $share_base_cache_target as $sns => $active ) {
377
- if ( $active ) {
378
- echo '<td class="not-cached share-count">';
379
- _e( 'N/A', self::DOMAIN );
380
- echo '</td>';
381
- }
382
- }
383
- }
384
- }
385
- }
386
-
387
-
388
- ?>
389
- </tr>
390
- <?php
391
- }
392
-
393
- if ( $posts_query->have_posts() ) {
394
- while ( $posts_query->have_posts() ) {
395
- $posts_query->the_post();
396
- ?>
397
- <tr>
398
- <td><?php echo $count; ?></td>
399
- <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>
400
- <?php
401
- $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( get_the_ID() );
402
-
403
- if( ! $sort_mode && false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
404
-
405
- foreach ( $share_base_cache_target as $sns => $active ) {
406
- if ( $active ) {
407
-
408
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
409
- echo '<td class="share-count">';
410
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
411
-
412
- if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) {
413
- //delta
414
- $meta_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( $sns );
415
- $sns_deltas[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
416
-
417
- if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
418
- echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
419
- } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
420
- echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
421
- }
422
- }
423
-
424
- echo '</td>';
425
- } else {
426
- echo '<td class="not-cached share-count">';
427
- _e( 'N/A', self::DOMAIN );
428
- echo '</td>';
429
- }
430
- }
431
- }
432
-
433
- } else {
434
-
435
- foreach ( $share_base_cache_target as $sns => $active ) {
436
- if( $active ){
437
-
438
- $meta_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( $sns );
439
-
440
- $sns_counts[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
441
-
442
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] !== '' && $sns_counts[$sns] >= 0 ) {
443
- echo '<td class="share-count">';
444
- echo esc_html( number_format( (int) $sns_counts[$sns] ) );
445
-
446
- if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) {
447
-
448
- //delta
449
- $meta_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( $sns );
450
- $sns_deltas[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
451
-
452
- if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
453
- echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
454
- } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
455
- echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
456
- }
457
- }
458
-
459
- echo '</td>';
460
- } else {
461
- echo '<td class="not-cached share-count">';
462
- _e( 'N/A', self::DOMAIN );
463
- echo '</td>';
464
- }
465
- }
466
- }
467
- }
468
-
469
- ?>
470
- </tr>
471
- <?php
472
- ++$count;
473
-
474
- }
475
- }
476
- ?>
477
- </tbody>
478
- </table>
479
- <?php
480
- $this->pagination( $posts_query->max_num_pages, '', $paged, true );
481
- wp_reset_postdata();
482
- ?>
483
-
484
- </div>
485
- </div>
486
- </div>
487
- </div>
488
- </div>
1
+ <?php
2
+ /*
3
+ admin-share-count.php
4
+
5
+ Description: Option page implementation
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 - 2016 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
+ 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_TOTAL:
119
+ $sns_name = __( 'Total', self::DOMAIN );
120
+ break;
121
+ }
122
+
123
+ if ( $sns === $sort_exec_key ) {
124
+ echo '<th><a class="sort-exec-key" href="' . $sort_url . '">' . esc_html( $sns_name ) . '</th>';
125
+ } else {
126
+ echo '<th><a href="' . $sort_url . '">' . esc_html( $sns_name ) . '</th>';
127
+ }
128
+ }
129
+ }
130
+ ?>
131
+ </tr>
132
+ </thead>
133
+ <tbody>
134
+ <?php
135
+ if ( $sort_mode ) {
136
+ $query_args = array(
137
+ 'post_type' => $this->share_base_cache_post_types,
138
+ 'post_status' => 'publish',
139
+ 'posts_per_page' => $posts_per_page,
140
+ 'paged' => $paged,
141
+ 'meta_key' => $meta_key,
142
+ 'orderby' => 'meta_value_num',
143
+ 'update_post_term_cache' => false,
144
+ 'order' => 'DESC'
145
+ );
146
+ } else {
147
+ $query_args = array(
148
+ 'post_type' => $this->share_base_cache_post_types,
149
+ 'post_status' => 'publish',
150
+ 'posts_per_page' => $posts_per_page,
151
+ 'paged' => $paged,
152
+ 'update_post_term_cache' => false
153
+ );
154
+ }
155
+
156
+ $posts_query = new WP_Query( $query_args );
157
+
158
+ $count = ( $paged - 1 ) * $posts_per_page + 1;
159
+
160
+ if ( $paged === 1 ) {
161
+ ?>
162
+ <tr class="home">
163
+ <td><?php echo '-'; ?></td>
164
+ <td><a href="<?php echo esc_url( home_url( '/' ) ); ?>" target="_blank"><?php echo esc_html( bloginfo('name') ); ?></a></td>
165
+ <?php
166
+ if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) {
167
+ $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( 'home' );
168
+
169
+ if ( false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
170
+ $option_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( 'home' );
171
+
172
+ if ( false !== ( $sns_deltas = get_option( $option_key ) ) ) {
173
+ foreach ( $share_base_cache_target as $sns => $active ) {
174
+ if ( $active ) {
175
+ if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
176
+ echo '<td class="share-count">';
177
+ echo esc_html( number_format( (int) $sns_counts[$sns] ) );
178
+
179
+ if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
180
+ echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
181
+ } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
182
+ echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
183
+ }
184
+
185
+ echo '</td>';
186
+ } else {
187
+ echo '<td class="not-cached share-count">';
188
+ _e( 'N/A', self::DOMAIN );
189
+ echo '</td>';
190
+ }
191
+ }
192
+ }
193
+ } else {
194
+ foreach ( $share_base_cache_target as $sns => $active ) {
195
+ if ( $active ) {
196
+ if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
197
+ echo '<td class="share-count">';
198
+ echo esc_html( number_format( (int) $sns_counts[$sns] ) );
199
+ echo '</td>';
200
+ } else {
201
+ echo '<td class="not-cached share-count">';
202
+ _e( 'N/A', self::DOMAIN );
203
+ echo '</td>';
204
+ }
205
+ }
206
+ }
207
+ }
208
+ } else {
209
+ $option_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( 'home' );
210
+
211
+ if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
212
+ $option_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( 'home' );
213
+
214
+ if ( false !== ( $sns_deltas = get_option( $option_key ) ) ) {
215
+ foreach ( $share_base_cache_target as $sns => $active ) {
216
+ if ( $active ) {
217
+ if ( $sns_counts[$sns] >= 0 ) {
218
+ echo '<td class="share-count">';
219
+ echo esc_html( number_format( (int) $sns_counts[$sns] ) );
220
+
221
+ if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
222
+ echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
223
+ } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
224
+ echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
225
+ }
226
+
227
+ echo '</td>';
228
+ } else {
229
+ echo '<td class="not-cached share-count">';
230
+ _e( 'N/A', self::DOMAIN );
231
+ echo '</td>';
232
+ }
233
+ }
234
+ }
235
+ } else {
236
+ foreach ( $share_base_cache_target as $sns => $active ) {
237
+ if ( $active ) {
238
+ if ( $sns_counts[$sns] >= 0 ) {
239
+ echo '<td class="share-count">';
240
+ echo esc_html( number_format( (int) $sns_counts[$sns] ) );
241
+ echo '</td>';
242
+ } else {
243
+ echo '<td class="not-cached share-count">';
244
+ _e( 'N/A', self::DOMAIN );
245
+ echo '</td>';
246
+ }
247
+ }
248
+ }
249
+ }
250
+ } else {
251
+ foreach ( $share_base_cache_target as $sns => $active ) {
252
+ if ( $active ) {
253
+ echo '<td class="not-cached share-count">';
254
+ _e( 'N/A', self::DOMAIN );
255
+ echo '</td>';
256
+ }
257
+ }
258
+ }
259
+ }
260
+ } else {
261
+ $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( 'home' );
262
+
263
+ if ( false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
264
+ $option_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( 'home' );
265
+
266
+ if ( false !== ( $sns_deltas = get_option( $option_key ) ) ) {
267
+ foreach ( $share_base_cache_target as $sns => $active ) {
268
+ if ( $active ) {
269
+ if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
270
+ echo '<td class="share-count">';
271
+ echo esc_html( number_format( (int) $sns_counts[$sns] ) );
272
+
273
+ if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
274
+ echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
275
+ } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
276
+ echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
277
+ }
278
+
279
+ echo '</td>';
280
+ } else {
281
+ echo '<td class="not-cached share-count">';
282
+ _e( 'N/A', self::DOMAIN );
283
+ echo '</td>';
284
+ }
285
+ }
286
+ }
287
+ } else {
288
+ foreach ( $share_base_cache_target as $sns => $active ) {
289
+ if ( $active ) {
290
+ if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
291
+ echo '<td class="share-count">';
292
+ echo esc_html( number_format( (int) $sns_counts[$sns] ) );
293
+ echo '</td>';
294
+ } else {
295
+ echo '<td class="not-cached share-count">';
296
+ _e( 'N/A', self::DOMAIN );
297
+ echo '</td>';
298
+ }
299
+ }
300
+ }
301
+ }
302
+ } else {
303
+ $option_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( 'home' );
304
+
305
+ if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
306
+ $option_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( 'home' );
307
+
308
+ if ( false !== ( $sns_deltas = get_option( $option_key ) ) ) {
309
+ foreach ( $share_base_cache_target as $sns => $active ) {
310
+ if ( $active ){
311
+ if ( $sns_counts[$sns] >= 0 ) {
312
+ echo '<td class="share-count">';
313
+ echo esc_html( number_format( (int) $sns_counts[$sns] ) );
314
+
315
+ if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
316
+ echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
317
+ } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
318
+ echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
319
+ }
320
+
321
+ echo '</td>';
322
+ } else {
323
+ echo '<td class="not-cached share-count">';
324
+ _e( 'N/A', self::DOMAIN );
325
+ echo '</td>';
326
+ }
327
+ }
328
+ }
329
+ } else {
330
+ foreach ( $share_base_cache_target as $sns => $active ) {
331
+ if ( $active ){
332
+ if ( $sns_counts[$sns] >= 0 ) {
333
+ echo '<td class="share-count">';
334
+ echo esc_html( number_format( (int) $sns_counts[$sns] ) );
335
+ echo '</td>';
336
+ } else {
337
+ echo '<td class="not-cached share-count">';
338
+ _e( 'N/A', self::DOMAIN );
339
+ echo '</td>';
340
+ }
341
+ }
342
+ }
343
+ }
344
+ } else {
345
+ foreach ( $share_base_cache_target as $sns => $active ) {
346
+ if ( $active ) {
347
+ echo '<td class="not-cached share-count">';
348
+ _e( 'N/A', self::DOMAIN );
349
+ echo '</td>';
350
+ }
351
+ }
352
+ }
353
+ }
354
+ }
355
+ ?>
356
+ </tr>
357
+ <?php
358
+ }
359
+ if ( $posts_query->have_posts() ) {
360
+ while ( $posts_query->have_posts() ) {
361
+ $posts_query->the_post();
362
+ ?>
363
+ <tr>
364
+ <td><?php echo $count; ?></td>
365
+ <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>
366
+ <?php
367
+ $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( get_the_ID() );
368
+
369
+ if ( ! $sort_mode && false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
370
+ foreach ( $share_base_cache_target as $sns => $active ) {
371
+ if ( $active ) {
372
+ if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
373
+ echo '<td class="share-count">';
374
+ echo esc_html( number_format( (int) $sns_counts[$sns] ) );
375
+
376
+ if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) {
377
+ //delta
378
+ $meta_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( $sns );
379
+ $sns_deltas[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
380
+
381
+ if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
382
+ echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
383
+ } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
384
+ echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
385
+ }
386
+ }
387
+
388
+ echo '</td>';
389
+ } else {
390
+ echo '<td class="not-cached share-count">';
391
+ _e( 'N/A', self::DOMAIN );
392
+ echo '</td>';
393
+ }
394
+ }
395
+ }
396
+ } else {
397
+ foreach ( $share_base_cache_target as $sns => $active ) {
398
+ if( $active ){
399
+ $meta_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( $sns );
400
+
401
+ $sns_counts[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
402
+
403
+ if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] !== '' && $sns_counts[$sns] >= 0 ) {
404
+ echo '<td class="share-count">';
405
+ echo esc_html( number_format( (int) $sns_counts[$sns] ) );
406
+
407
+ if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) {
408
+ //delta
409
+ $meta_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( $sns );
410
+ $sns_deltas[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
411
+
412
+ if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] > 0 ) {
413
+ echo ' (<span class="delta-rise">+' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
414
+ } elseif ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' && $sns_deltas[$sns] < 0 ) {
415
+ echo ' (<span class="delta-fall">' . esc_html( number_format( (int) $sns_deltas[$sns] ) ) . '</span>)';
416
+ }
417
+ }
418
+
419
+ echo '</td>';
420
+ } else {
421
+ echo '<td class="not-cached share-count">';
422
+ _e( 'N/A', self::DOMAIN );
423
+ echo '</td>';
424
+ }
425
+ }
426
+ }
427
+ }
428
+ ?>
429
+ </tr>
430
+ <?php
431
+ ++$count;
432
+
433
+ }
434
+ }
435
+ ?>
436
+ </tbody>
437
+ </table>
438
+ <?php
439
+ $this->pagination( $posts_query->max_num_pages, '', $paged, true );
440
+ wp_reset_postdata();
441
+ ?>
442
+ </div>
443
+ </div>
444
+ </div>
445
+ </div>
446
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-analytical-engline.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  class-analytical-engline.php
4
 
5
- Description: This class is a data analytical engine.
6
  Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
@@ -10,8 +10,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
  */
11
 
12
  /*
13
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
 
16
  This program is free software; you can redistribute it and/or
17
  modify it under the terms of the GNU General Public License
@@ -26,80 +25,78 @@ GNU General Public License for more details.
26
  You should have received a copy of the GNU General Public License
27
  along with this program; if not, write to the Free Software
28
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
  */
31
 
32
-
33
  abstract class Analytical_Engine extends Engine {
34
 
35
  /**
36
  * Prefix of cache ID
37
- */
38
- protected $cache_prefix = NULL;
39
 
40
- /**
41
  * Prefix of base ID
42
- */
43
- protected $base_prefix = NULL;
44
 
45
- /**
46
  * Prefix of base ID
47
- */
48
- protected $delta_prefix = NULL;
49
-
50
- /**
51
  * instance for delegation
52
- */
53
- protected $delegate = NULL;
54
-
55
- /**
56
  * Get and cache data for a given post
57
  *
58
  * @since 0.1.1
59
- */
60
- abstract public function analyze( $options = array() );
61
 
62
- /**
63
- * Initialize cache
64
  *
65
  * @since 0.3.0
66
- */
67
- abstract public function initialize_base();
68
 
69
- /**
70
- * Clear cache
71
  *
72
  * @since 0.3.0
73
- */
74
- abstract public function clear_base();
75
-
76
- /**
77
  * Get cache key
78
  *
79
  * @since 0.6.0
80
- */
81
- public function get_cache_key( $suffix ) {
82
- return $this->cache_prefix . strtolower( $suffix );
83
- }
84
 
85
- /**
86
  * Get base key
87
  *
88
  * @since 0.6.1
89
- */
90
- public function get_base_key( $suffix ) {
91
- return $this->base_prefix . strtolower( $suffix );
92
- }
93
 
94
- /**
95
  * Get delta key
96
  *
97
  * @since 0.6.1
98
- */
99
- public function get_delta_key( $suffix ) {
100
- return $this->delta_prefix . strtolower( $suffix );
101
- }
102
-
103
  }
104
 
105
  ?>
2
  /*
3
  class-analytical-engline.php
4
 
5
+ Description: This class is a data analytical engine.
6
  Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
10
  */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2016 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
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
  abstract class Analytical_Engine extends 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 );
80
+ }
81
 
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 );
89
+ }
90
 
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 );
98
+ }
99
+
100
  }
101
 
102
  ?>
includes/class-blowfish.php ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ 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
+ 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
+ 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
+ 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-cache-engine.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  class-cache-engine.php
4
 
5
- Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
6
  Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
@@ -10,8 +10,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
  */
11
 
12
  /*
13
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
 
16
  This program is free software; you can redistribute it and/or
17
  modify it under the terms of the GNU General Public License
@@ -26,91 +25,89 @@ GNU General Public License for more details.
26
  You should have received a copy of the GNU General Public License
27
  along with this program; if not, write to the Free Software
28
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
  */
31
 
32
-
33
  abstract class Cache_Engine extends Engine {
34
 
35
  /**
36
  * Prefix of cache ID
37
- */
38
- protected $cache_prefix = NULL;
39
-
40
- /**
41
  * instance for delegation
42
- */
43
- protected $delegate = NULL;
44
 
45
- /**
46
  * retry of cache processing
47
- */
48
- protected $cache_retry = false;
49
-
50
- /**
51
  * limit of cache retry
52
- */
53
- protected $retry_limit = 3;
54
-
55
- /**
56
  * Get cache expiration based on current number of total post and page
57
  *
58
  * @since 0.1.1
59
- */
60
- abstract protected function get_cache_expiration();
61
-
62
- /**
63
  * Get and cache data for a given post
64
  *
65
  * @since 0.1.1
66
- */
67
- abstract public function cache( $options = array() );
68
 
69
- /**
70
- * Initialize cache
71
  *
72
  * @since 0.3.0
73
- */
74
- abstract public function initialize_cache();
75
 
76
- /**
77
- * Clear cache
78
  *
79
  * @since 0.3.0
80
- */
81
- abstract public function clear_cache();
82
-
83
- /**
84
  * Get cache key
85
  *
86
  * @since 0.6.0
87
- */
88
- public function get_cache_key( $suffix ) {
89
- return $this->cache_prefix . strtolower( $suffix );
90
- }
91
-
92
- /**
93
  * Order cache
94
  *
95
  * @since 0.5.1
96
- */
97
- protected function delegate_cache( $options = array() ) {
98
- if ( ! is_null( $this->delegate ) && method_exists( $this->delegate, 'order_cache' ) ) {
99
  $this->delegate->order_cache( $this, $options );
100
- }
101
  }
102
 
103
- /**
104
  * Order analysis
105
  *
106
  * @since 0.6.1
107
- */
108
- protected function delegate_analysis( $options = array() ) {
109
- if ( ! is_null( $this->delegate ) && method_exists( $this->delegate, 'order_analysis' ) ) {
110
  $this->delegate->order_analysis( $this, $options );
111
- }
112
  }
113
-
114
  }
115
 
116
  ?>
2
  /*
3
  class-cache-engine.php
4
 
5
+ Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
6
  Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
10
  */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2016 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
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
  abstract class Cache_Engine extends 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
  * Get cache expiration based on current number of total post and page
54
  *
55
  * @since 0.1.1
56
+ */
57
+ abstract protected function get_cache_expiration();
58
+
59
+ /**
60
  * Get and cache data for a given post
61
  *
62
  * @since 0.1.1
63
+ */
64
+ abstract public function cache( $options = array() );
65
 
66
+ /**
67
+ * Initialize cache
68
  *
69
  * @since 0.3.0
70
+ */
71
+ abstract public function initialize_cache();
72
 
73
+ /**
74
+ * Clear cache
75
  *
76
  * @since 0.3.0
77
+ */
78
+ abstract public function clear_cache();
79
+
80
+ /**
81
  * Get cache key
82
  *
83
  * @since 0.6.0
84
+ */
85
+ public function get_cache_key( $suffix ) {
86
+ return $this->cache_prefix . strtolower( $suffix );
87
+ }
88
+
89
+ /**
90
  * Order cache
91
  *
92
  * @since 0.5.1
93
+ */
94
+ protected function delegate_cache( $options = array() ) {
95
+ if ( ! is_null( $this->delegate ) && method_exists( $this->delegate, 'order_cache' ) ) {
96
  $this->delegate->order_cache( $this, $options );
97
+ }
98
  }
99
 
100
+ /**
101
  * Order analysis
102
  *
103
  * @since 0.6.1
104
+ */
105
+ protected function delegate_analysis( $options = array() ) {
106
+ if ( ! is_null( $this->delegate ) && method_exists( $this->delegate, 'order_analysis' ) ) {
107
  $this->delegate->order_analysis( $this, $options );
108
+ }
109
  }
110
+
111
  }
112
 
113
  ?>
includes/class-common-data-export-engine.php CHANGED
@@ -1,356 +1,339 @@
1
- <?php
2
- /*
3
- class-common-data-export.php
4
-
5
- Description: This class is a data export engine whitch exports cached data using wp-cron at regular intervals
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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
31
-
32
-
33
- class Common_Data_Export_Engine extends Export_Engine {
34
-
35
- /**
36
- * Meta key for share second cache
37
- */
38
- const DEF_SHARE_META_KEY_PREFIX = 'scc_share_count_';
39
-
40
- /**
41
- * Meta key for follow second cache
42
- */
43
- const DEF_FOLLOW_META_KEY_PREFIX = 'scc_follow_count_';
44
-
45
- /**
46
- * Cron name to schedule cache processing
47
- */
48
- const DEF_PRIME_CRON = 'scc_common_dataexport_prime';
49
-
50
- /**
51
- * Cron name to execute cache processing
52
- */
53
- const DEF_EXECUTE_CRON = 'scc_common_dataexport_exec';
54
-
55
- /**
56
- * Schedule name for cache processing
57
- */
58
- const DEF_EVENT_SCHEDULE = 'common_data_export_event';
59
-
60
- /**
61
- * Schedule description for cache processing
62
- */
63
- const DEF_EVENT_DESCRIPTION = '[SCC] Common Data Export Interval';
64
-
65
- /**
66
- * Option flag of data export
67
- */
68
- private $export_activation = 0;
69
-
70
- /**
71
- * Interval for data export
72
- */
73
- private $export_interval = 43200;
74
-
75
- /**
76
- * Schedule for data export
77
- */
78
- private $export_schedule = '0 0 * * *';
79
-
80
- /**
81
- * Excluded keys of data export
82
- */
83
- private $export_exclude_keys = array();
84
-
85
- /**
86
- * File name of data export
87
- */
88
- private $export_file_name = 'sns-count-cache-data.csv';
89
-
90
- /**
91
- * Cache post types
92
- */
93
- private $post_types = array( 'post', 'page' );
94
-
95
- /**
96
- * Cache target of share count
97
- */
98
- private $share_target_sns = array();
99
-
100
- /**
101
- * Cache target of follow count
102
- */
103
- private $follow_target_sns = array();
104
-
105
- /**
106
- * Initialization
107
- *
108
- * @since 0.1.1
109
- */
110
- public function initialize( $options = array() ) {
111
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
112
-
113
- $this->share_cache_key_prefix = self::DEF_SHARE_META_KEY_PREFIX;
114
- $this->follow_cache_key_prefix = self::DEF_FOLLOW_META_KEY_PREFIX;
115
- $this->prime_cron = self::DEF_PRIME_CRON;
116
- $this->execute_cron = self::DEF_EXECUTE_CRON;
117
- $this->event_schedule = self::DEF_EVENT_SCHEDULE;
118
- $this->event_description = self::DEF_EVENT_DESCRIPTION;
119
-
120
- if ( isset( $options['export_activation'] ) ) $this->export_activation = $options['export_activation'];
121
- if ( isset( $options['export_interval'] ) ) $this->export_interval = $options['export_interval'];
122
- if ( isset( $options['export_schedule'] ) ) $this->export_schedule = $options['export_schedule'];
123
- if ( isset( $options['prime_cron'] ) ) $this->prime_cron = $options['prime_cron'];
124
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
125
- if ( isset( $options['event_schedule'] ) ) $this->event_schedule = $options['event_schedule'];
126
- if ( isset( $options['event_description'] ) ) $this->event_description = $options['event_description'];
127
- if ( isset( $options['export_exclude_keys'] ) ) $this->export_exclude_keys = $options['export_exclude_keys'];
128
- if ( isset( $options['export_file_name'] ) ) $this->export_file_name = $options['export_file_name'];
129
- if ( isset( $options['post_types'] ) ) $this->post_types = $options['post_types'];
130
- if ( isset( $options['share_cache_key_prefix'] ) ) $this->share_cache_key_prefix = $options['share_cache_key_prefix'];
131
- if ( isset( $options['follow_cache_key_prefix'] ) ) $this->follow_cache_key_prefix = $options['follow_cache_key_prefix'];
132
- if ( isset( $options['share_target_sns'] ) ) $this->share_target_sns = $options['share_target_sns'];
133
- if ( isset( $options['follow_target_sns'] ) ) $this->follow_target_sns = $options['follow_target_sns'];
134
-
135
- add_filter( 'cron_schedules', array( $this, 'schedule_export_interval' ) );
136
- add_action( $this->prime_cron, array( $this, 'prime_export' ) );
137
- add_action( $this->execute_cron, array( $this, 'execute_export' ), 10, 1 );
138
- }
139
-
140
- /**
141
- * Register event schedule for this engine
142
- *
143
- * @since 0.1.0
144
- */
145
- public function schedule_export_interval( $schedules ) {
146
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
147
-
148
- $schedules[$this->event_schedule] = array(
149
- 'interval' => $this->export_interval,
150
- 'display' => $this->event_description
151
- );
152
-
153
- return $schedules;
154
- }
155
-
156
- /**
157
- * Prime data export
158
- *
159
- * @since 0.4.0
160
- */
161
- public function prime_export() {
162
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
163
-
164
- //$next_exec_time = time() + $this->export_interval;
165
-
166
- //$next_exec_time = time() + 5;
167
-
168
- $next_exec_time = WP_Cron_Util::next_exec_time( $this->export_schedule );
169
-
170
- Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->export_interval );
171
-
172
- Common_Util::log( '[' . __METHOD__ . '] next_exec_time (timesatamp): ' . $next_exec_time );
173
- Common_Util::log( '[' . __METHOD__ . '] next_exec_time (date): ' . date_i18n( 'Y/m/d H:i:s', $next_exec_time ) );
174
-
175
-
176
- if( ! WP_Cron_Util::is_scheduled_hook( $this->execute_cron ) ) {
177
- wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( Common_Util::short_hash( $next_exec_time ) ) );
178
- }
179
-
180
-
181
- /*
182
- wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( Common_Util::short_hash( $next_exec_time ) ) );
183
- */
184
- }
185
-
186
-
187
- /**
188
- * Execute data export
189
- *
190
- * @since 0.4.0
191
- */
192
- public function execute_export( $hash ) {
193
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
194
-
195
- $base_dir = WP_PLUGIN_DIR . '/sns-count-cache/data/';
196
-
197
- $current_date = date_i18n( 'Y/m/d H:i:s' );
198
-
199
- if( file_exists( $base_dir ) ) {
200
- $abs_path = $base_dir . $this->export_file_name;
201
-
202
-
203
- if ( ! file_exists( $abs_path ) ) {
204
-
205
- if ( touch( $abs_path ) ) {
206
- Common_Util::log( '[' . __METHOD__ . '] export file creation succeeded: ' . $abs_path );
207
- } else {
208
- Common_Util::log( '[' . __METHOD__ . '] export file creation failed: ' . $abs_path );
209
- }
210
-
211
- if ( file_exists( $abs_path ) ) {
212
- Common_Util::log( '[' . __METHOD__ . '] file exists: ' . $abs_path );
213
- $fp = fopen( $abs_path, 'a' );
214
-
215
- $header = '"Retrieval Date","Post ID","Post Type","Post Title","Permalink","Post Date","SNS","Data Type","Data Value",' . "\r\n";
216
-
217
- if ( fwrite( $fp, mb_convert_encoding( $header, "SJIS", "UTF-8" ) ) ) {
218
- Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ' . $header );
219
- } else {
220
- Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ' . $header );
221
- }
222
-
223
- if ( fclose($fp) ) {
224
- Common_Util::log( '[' . __METHOD__ . '] file close succeeded: ' . $abs_path );
225
- } else {
226
- Common_Util::log( '[' . __METHOD__ . '] file close failed: ' . $abs_path );
227
- }
228
- }
229
- }
230
-
231
- if ( file_exists( $abs_path ) ) {
232
- Common_Util::log( '[' . __METHOD__ . '] file exists: ' . $abs_path );
233
-
234
- $fp = fopen( $abs_path, 'a' );
235
-
236
- $content = '"' . $current_date . '","' . 'home' . '","' . '-' . '","' . get_bloginfo('name') . '","' . home_url( '/' ) . '","' . '-';
237
-
238
- $option_key = $this->share_cache_key_prefix . strtolower( 'home' );
239
-
240
- if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
241
-
242
- foreach ( $this->share_target_sns as $sns => $active ) {
243
- if ( ! in_array( $sns, $this->export_exclude_keys ) ) {
244
- if( $active ){
245
- if ( $sns_counts[$sns] >= 0 ) {
246
- $data_value = $sns_counts[$sns];
247
- } else {
248
- $data_value = '';
249
- }
250
- $data = $content . '","' . $sns . '","' . 'Share' . '","' . $data_value . '",' . "\r\n";
251
- }
252
- if ( fwrite( $fp, mb_convert_encoding( $data, "SJIS", "UTF-8" ) ) ) {
253
- Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ' . $data );
254
- } else {
255
- Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ' . $data );
256
- }
257
- }
258
- }
259
- }
260
-
261
- $query_args = array(
262
- 'post_type' => $this->post_types,
263
- 'post_status' => 'publish',
264
- 'nopaging' => true,
265
- 'update_post_term_cache' => false,
266
- 'update_post_meta_cache' => false
267
- );
268
-
269
- $posts_query = new WP_Query( $query_args );
270
-
271
- if ( $posts_query->have_posts() ) {
272
- while ( $posts_query->have_posts() ) {
273
- $posts_query->the_post();
274
-
275
- $post_ID = get_the_ID();
276
-
277
- $content = '"' . $current_date . '","' . $post_ID . '","' . get_post_type( $post_ID ) . '","' . get_the_title( $post_ID ) . '","' . get_permalink( $post_ID ) . '","' . get_post_time( 'Y/m/d H:i', false, $post_ID );
278
-
279
- foreach ( $this->share_target_sns as $sns => $active ) {
280
-
281
- if ( ! in_array( $sns, $this->export_exclude_keys ) ) {
282
-
283
- $meta_key = $this->share_cache_key_prefix . strtolower( $sns );
284
-
285
- if ( $active ) {
286
-
287
- $data_value = get_post_meta( $post_ID, $meta_key, true );
288
-
289
- if ( $data_value < 0 ){
290
- $data_value = '';
291
- }
292
-
293
- $data = $content . '","' . $sns . '","' . 'Share' . '","' . $data_value . '",' . "\r\n";
294
- }
295
- if ( fwrite( $fp, mb_convert_encoding( $data, "SJIS", "UTF-8" ) ) ) {
296
- Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ' . $data );
297
- } else {
298
- Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ' . $data );
299
- }
300
- }
301
- }
302
-
303
- /*
304
- foreach ( $this->follow_target_sns as $key => $value ) {
305
- $meta_key = $this->follow_cache_key_prefix . strtolower( $key );
306
-
307
- if ( $value ) {
308
-
309
- $data_value = get_post_meta( $post_ID, $meta_key, true );
310
-
311
- if ( $data_value == -1 ){
312
- $data_value = '';
313
- }
314
-
315
- $data = $content . '","' . $key . '","' . 'Follow' . '","' . $data_value . '",' . "\r\n";
316
- }
317
- if ( fwrite( $fp, mb_convert_encoding( $data, "SJIS", "UTF-8" ) ) ) {
318
- Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ' . $data );
319
- } else {
320
- Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ' . $data );
321
- }
322
-
323
- }
324
- */
325
-
326
- }
327
- }
328
- wp_reset_postdata();
329
-
330
- if ( fclose($fp) ) {
331
- Common_Util::log( '[' . __METHOD__ . '] file close succeeded: ' . $abs_path );
332
- } else {
333
- Common_Util::log( '[' . __METHOD__ . '] file close failed: ' . $abs_path );
334
- }
335
- }
336
- }
337
- }
338
-
339
- /**
340
- * Reset exported file
341
- *
342
- * @since 0.4.0
343
- */
344
- public function reset_export() {
345
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
346
-
347
- $base_dir = WP_PLUGIN_DIR . '/sns-count-cache/data/';
348
- $abs_path = $base_dir . $this->export_file_name;
349
-
350
- if ( file_exists( $abs_path ) ) {
351
- unlink( $abs_path );
352
- }
353
- }
354
- }
355
-
356
- ?>
1
+ <?php
2
+ /*
3
+ class-common-data-export.php
4
+
5
+ Description: This class is a data export engine whitch exports cached data using wp-cron at regular intervals
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 - 2016 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 Common_Data_Export_Engine extends Export_Engine {
31
+
32
+ /**
33
+ * Meta key for share second cache
34
+ */
35
+ const DEF_SHARE_META_KEY_PREFIX = 'scc_share_count_';
36
+
37
+ /**
38
+ * Meta key for follow second cache
39
+ */
40
+ const DEF_FOLLOW_META_KEY_PREFIX = 'scc_follow_count_';
41
+
42
+ /**
43
+ * Cron name to schedule cache processing
44
+ */
45
+ const DEF_PRIME_CRON = 'scc_common_dataexport_prime';
46
+
47
+ /**
48
+ * Cron name to execute cache processing
49
+ */
50
+ const DEF_EXECUTE_CRON = 'scc_common_dataexport_exec';
51
+
52
+ /**
53
+ * Schedule name for cache processing
54
+ */
55
+ const DEF_EVENT_SCHEDULE = 'common_data_export_event';
56
+
57
+ /**
58
+ * Schedule description for cache processing
59
+ */
60
+ const DEF_EVENT_DESCRIPTION = '[SCC] Common Data Export Interval';
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
+ 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;
112
+ $this->prime_cron = self::DEF_PRIME_CRON;
113
+ $this->execute_cron = self::DEF_EXECUTE_CRON;
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' ) );
134
+ add_action( $this->execute_cron, array( $this, 'execute_export' ), 10, 1 );
135
+ }
136
+
137
+ /**
138
+ * Register event schedule for this engine
139
+ *
140
+ * @since 0.1.0
141
+ */
142
+ public function schedule_export_interval( $schedules ) {
143
+ 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
+ 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 = WP_Cron_Util::next_exec_time( $this->export_schedule );
166
+
167
+ Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->export_interval );
168
+
169
+ Common_Util::log( '[' . __METHOD__ . '] next_exec_time (timesatamp): ' . $next_exec_time );
170
+ Common_Util::log( '[' . __METHOD__ . '] next_exec_time (date): ' . date_i18n( 'Y/m/d H:i:s', $next_exec_time ) );
171
+
172
+ if ( ! WP_Cron_Util::is_scheduled_hook( $this->execute_cron ) ) {
173
+ wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( Common_Util::short_hash( $next_exec_time ) ) );
174
+ }
175
+
176
+ //wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( 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
+ 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
+ Common_Util::log( '[' . __METHOD__ . '] export file creation succeeded: ' . $abs_path );
198
+ } else {
199
+ Common_Util::log( '[' . __METHOD__ . '] export file creation failed: ' . $abs_path );
200
+ }
201
+ if ( file_exists( $abs_path ) ) {
202
+ 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
+ Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ' . $header );
209
+ } else {
210
+ Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ' . $header );
211
+ }
212
+ if ( fclose( $fp ) ) {
213
+ Common_Util::log( '[' . __METHOD__ . '] file close succeeded: ' . $abs_path );
214
+ } else {
215
+ Common_Util::log( '[' . __METHOD__ . '] file close failed: ' . $abs_path );
216
+ }
217
+ }
218
+ }
219
+
220
+ if ( file_exists( $abs_path ) ) {
221
+ 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 {
237
+ $data_value = '';
238
+ }
239
+ $data = $content . '","' . $sns . '","' . 'Share' . '","' . $data_value . '",' . "\r\n";
240
+ }
241
+ if ( fwrite( $fp, mb_convert_encoding( $data, "SJIS", "UTF-8" ) ) ) {
242
+ Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ' . $data );
243
+ } else {
244
+ Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ' . $data );
245
+ }
246
+ }
247
+ }
248
+ }
249
+
250
+ $query_args = array(
251
+ 'post_type' => $this->post_types,
252
+ 'post_status' => 'publish',
253
+ 'nopaging' => true,
254
+ 'update_post_term_cache' => false,
255
+ 'update_post_meta_cache' => false
256
+ );
257
+
258
+ $posts_query = new WP_Query( $query_args );
259
+
260
+ if ( $posts_query->have_posts() ) {
261
+ while ( $posts_query->have_posts() ) {
262
+ $posts_query->the_post();
263
+
264
+ $post_ID = get_the_ID();
265
+
266
+ $content = '"' . $current_date . '","' . $post_ID . '","' . get_post_type( $post_ID ) . '","' . get_the_title( $post_ID ) . '","' . get_permalink( $post_ID ) . '","' . get_post_time( 'Y/m/d H:i', false, $post_ID );
267
+
268
+ foreach ( $this->share_target_sns as $sns => $active ) {
269
+ if ( ! in_array( $sns, $this->export_exclude_keys ) ) {
270
+ $meta_key = $this->share_cache_key_prefix . strtolower( $sns );
271
+
272
+ if ( $active ) {
273
+ $data_value = get_post_meta( $post_ID, $meta_key, true );
274
+
275
+ if ( $data_value < 0 ){
276
+ $data_value = '';
277
+ }
278
+
279
+ $data = $content . '","' . $sns . '","' . 'Share' . '","' . $data_value . '",' . "\r\n";
280
+ }
281
+ if ( fwrite( $fp, mb_convert_encoding( $data, "SJIS", "UTF-8" ) ) ) {
282
+ Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ' . $data );
283
+ } else {
284
+ Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ' . $data );
285
+ }
286
+ }
287
+ }
288
+
289
+ /*
290
+ foreach ( $this->follow_target_sns as $key => $value ) {
291
+ $meta_key = $this->follow_cache_key_prefix . strtolower( $key );
292
+ if ( $value ) {
293
+ $data_value = get_post_meta( $post_ID, $meta_key, true );
294
+
295
+ if ( $data_value == -1 ){
296
+ $data_value = '';
297
+ }
298
+
299
+ $data = $content . '","' . $key . '","' . 'Follow' . '","' . $data_value . '",' . "\r\n";
300
+ }
301
+ if ( fwrite( $fp, mb_convert_encoding( $data, "SJIS", "UTF-8" ) ) ) {
302
+ Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ' . $data );
303
+ } else {
304
+ Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ' . $data );
305
+ }
306
+ }
307
+ */
308
+
309
+ }
310
+ }
311
+ wp_reset_postdata();
312
+
313
+ if ( fclose($fp) ) {
314
+ Common_Util::log( '[' . __METHOD__ . '] file close succeeded: ' . $abs_path );
315
+ } else {
316
+ Common_Util::log( '[' . __METHOD__ . '] file close failed: ' . $abs_path );
317
+ }
318
+ }
319
+ }
320
+ }
321
+
322
+ /**
323
+ * Reset exported file
324
+ *
325
+ * @since 0.4.0
326
+ */
327
+ public function reset_export() {
328
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
329
+
330
+ $base_dir = WP_PLUGIN_DIR . '/sns-count-cache/data/';
331
+ $abs_path = $base_dir . $this->export_file_name;
332
+
333
+ if ( file_exists( $abs_path ) ) {
334
+ unlink( $abs_path );
335
+ }
336
+ }
337
+ }
338
+
339
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-common-job-reset-engine.php CHANGED
@@ -1,153 +1,147 @@
1
- <?php
2
- /*
3
- class-common-job-reset-engine.php
4
-
5
- Description: This class is a job reset engine whitch reset expired jobs
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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
31
-
32
-
33
- class Common_Job_Reset_Engine extends Engine {
34
-
35
- /**
36
- * Cron name to schedule reset processing
37
- */
38
- const DEF_PRIME_CRON = 'scc_common_jobreset_prime';
39
-
40
- /**
41
- * Cron name to execute reset processing
42
- */
43
- const DEF_EXECUTE_CRON = 'scc_common_jobreset_exec';
44
-
45
- /**
46
- * Schedule name for reset processing
47
- */
48
- const DEF_EVENT_SCHEDULE = 'common_job_reset_event';
49
-
50
- /**
51
- * Schedule description for reset processing
52
- */
53
- const DEF_EVENT_DESCRIPTION = '[SCC] Common Job Reset Interval';
54
-
55
- /**
56
- * Interval cheking and caching target data
57
- */
58
- private $check_interval = 600;
59
-
60
- /**
61
- * Time expired
62
- */
63
- private $expiration_time = 1800;
64
-
65
- /**
66
- * Cache target
67
- */
68
- private $target_cron = array();
69
-
70
- /**
71
- * instance for delegation
72
- */
73
- private $delegate = NULL;
74
-
75
- /**
76
- * Initialization
77
- *
78
- * @since 0.1.1
79
- */
80
- public function initialize( $options = array() ) {
81
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
82
-
83
- $this->prime_cron = self::DEF_PRIME_CRON;
84
- $this->execute_cron = self::DEF_EXECUTE_CRON;
85
- $this->event_schedule = self::DEF_EVENT_SCHEDULE;
86
- $this->event_description = self::DEF_EVENT_DESCRIPTION;
87
-
88
- if ( isset( $options['delegate'] ) ) $this->delegate = $options['delegate'];
89
- if ( isset( $options['target_cron'] ) ) $this->target_cron = $options['target_cron'];
90
- if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
91
- if ( isset( $options['prime_cron'] ) ) $this->prime_cron = $options['prime_cron'];
92
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
93
- if ( isset( $options['event_schedule'] ) ) $this->event_schedule = $options['event_schedule'];
94
- if ( isset( $options['event_description'] ) ) $this->event_description = $options['event_description'];
95
- if ( isset( $options['expiration_time'] ) ) $this->expiration_time = $options['expiration_time'];
96
-
97
- add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
98
- add_action( $this->prime_cron, array( $this, 'prime_reset' ) );
99
- add_action( $this->execute_cron, array( $this, 'execute_reset' ), 10, 0 );
100
-
101
- }
102
-
103
- /**
104
- * Register event schedule for this engine
105
- *
106
- * @since 0.1.0
107
- */
108
- public function schedule_check_interval( $schedules ) {
109
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
110
-
111
- $schedules[$this->event_schedule] = array(
112
- 'interval' => $this->check_interval,
113
- 'display' => $this->event_description
114
- );
115
-
116
- return $schedules;
117
- }
118
-
119
- /**
120
- * Schedule job reset processing
121
- *
122
- * @since 0.2.0
123
- */
124
- public function prime_reset() {
125
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
126
-
127
- $next_exec_time = time() + $this->check_interval;
128
-
129
- Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
130
- Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
131
-
132
- wp_schedule_single_event( $next_exec_time, $this->execute_cron, array() );
133
-
134
- }
135
-
136
- /**
137
- * Reset expired jobs
138
- *
139
- * @since 0.2.0
140
- */
141
- public function execute_reset() {
142
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
143
-
144
- foreach ( $this->target_cron as $key => $hook ) {
145
- Common_Util::log( '[' . __METHOD__ . '] hook: ' . $hook );
146
- WP_Cron_Util::clear_expired_scheduled_hook( $hook, $this->expiration_time );
147
- }
148
-
149
- }
150
-
151
- }
152
-
153
- ?>
1
+ <?php
2
+ /*
3
+ class-common-job-reset-engine.php
4
+
5
+ Description: This class is a job reset engine whitch reset expired jobs
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 - 2016 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 Common_Job_Reset_Engine extends Engine {
31
+
32
+ /**
33
+ * Cron name to schedule reset processing
34
+ */
35
+ const DEF_PRIME_CRON = 'scc_common_jobreset_prime';
36
+
37
+ /**
38
+ * Cron name to execute reset processing
39
+ */
40
+ const DEF_EXECUTE_CRON = 'scc_common_jobreset_exec';
41
+
42
+ /**
43
+ * Schedule name for reset processing
44
+ */
45
+ const DEF_EVENT_SCHEDULE = 'common_job_reset_event';
46
+
47
+ /**
48
+ * Schedule description for reset processing
49
+ */
50
+ const DEF_EVENT_DESCRIPTION = '[SCC] Common Job Reset Interval';
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
+ 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' ) );
96
+ add_action( $this->execute_cron, array( $this, 'execute_reset' ), 10, 0 );
97
+ }
98
+
99
+ /**
100
+ * Register event schedule for this engine
101
+ *
102
+ * @since 0.1.0
103
+ */
104
+ public function schedule_check_interval( $schedules ) {
105
+ 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;
113
+ }
114
+
115
+ /**
116
+ * Schedule job reset processing
117
+ *
118
+ * @since 0.2.0
119
+ */
120
+ public function prime_reset() {
121
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
122
+
123
+ $next_exec_time = time() + $this->check_interval;
124
+
125
+ Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
126
+ Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
127
+
128
+ wp_schedule_single_event( $next_exec_time, $this->execute_cron, array() );
129
+ }
130
+
131
+ /**
132
+ * Reset expired jobs
133
+ *
134
+ * @since 0.2.0
135
+ */
136
+ public function execute_reset() {
137
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
138
+
139
+ foreach ( $this->target_cron as $key => $hook ) {
140
+ Common_Util::log( '[' . __METHOD__ . '] hook: ' . $hook );
141
+ WP_Cron_Util::clear_expired_scheduled_hook( $hook, $this->expiration_time );
142
+ }
143
+ }
144
+
145
+ }
146
+
147
+ ?>
 
 
 
 
 
 
includes/class-common-util.php CHANGED
@@ -1,321 +1,610 @@
1
- <?php
2
- /*
3
- class-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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
31
-
32
- class Common_Util {
33
-
34
- /**
35
- * Class constarctor
36
- * Hook onto all of the actions and filters needed by the plugin.
37
- *
38
- */
39
- protected function __construct() {
40
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
41
-
42
- }
43
-
44
- /**
45
- * Output log message according to WP_DEBUG setting
46
- *
47
- * @since 0.1.0
48
- */
49
- public static function log( $message ) {
50
- if ( WP_DEBUG === true ) {
51
- if ( is_array( $message ) || is_object( $message ) ) {
52
- error_log( print_r( $message, true ) );
53
- } else {
54
- error_log( $message );
55
- }
56
- }
57
- }
58
-
59
- /**
60
- * Get short hash code
61
- *
62
- * @since 0.2.0
63
- */
64
- public static function short_hash( $data, $algo = 'CRC32' ) {
65
- return strtr( rtrim( base64_encode( pack('H*', $algo($data) ) ), '=' ), '+/', '-_' );
66
- }
67
-
68
- /**
69
- * Get file size of given file
70
- *
71
- * @since 0.4.0
72
- */
73
- public static function get_file_size( $file ) {
74
-
75
- if ( file_exists( $file ) && is_file( $file ) ) {
76
- $filesize = filesize( $file );
77
- $s = array( 'B', 'KB', 'MB', 'GB', 'TB', 'PB' );
78
- $e = floor( log( $filesize ) / log( 1024 ) );
79
-
80
- if( $e == 0 || $e == 1 ) {
81
- $format = '%d ';
82
- } else {
83
- $format = '%.1f ';
84
- }
85
-
86
- $filesize = sprintf( $format . $s[$e], ( $filesize / pow( 1024, floor( $e ) ) ) );
87
-
88
- return $filesize;
89
- } else {
90
- return null;
91
- }
92
- }
93
-
94
- /**
95
- * Get custom post types
96
- *
97
- * @since 0.4.0
98
- */
99
- public static function get_custom_post_types() {
100
-
101
- global $wpdb;
102
-
103
- $custom_post_types = array();
104
-
105
- $builtin_post_types = get_post_types( array( '_builtin' => true ) );
106
-
107
- $exclude_post_types = "'";
108
- $exclude_post_types .= implode( "','", $builtin_post_types );
109
- $exclude_post_types .= "'";
110
-
111
- $sql = 'SELECT DISTINCT post_type FROM ' . $wpdb->posts . ' WHERE post_type NOT IN ( ' . $exclude_post_types . ' )';
112
-
113
- $results = $wpdb->get_results( $sql );
114
-
115
- foreach ( $results as $value ) {
116
- $custom_post_types[] = $value->post_type;
117
- }
118
-
119
- return $custom_post_types;
120
- }
121
-
122
- /**
123
- * check if php-xml module is loaded or not
124
- *
125
- * @since 0.4.0
126
- */
127
- public static function extension_loaded_php_xml() {
128
- if ( extension_loaded( 'xml' ) && extension_loaded( 'xmlreader' ) && extension_loaded( 'xmlwriter' ) ) {
129
- return true;
130
- } else {
131
- return false;
132
- }
133
- }
134
-
135
- /**
136
- * convert url based on http into url based on https
137
- *
138
- * @since 0.4.0
139
- */
140
- public static function get_secure_url( $url ){
141
-
142
- $url = str_replace( 'http://', 'https://', $url );
143
-
144
- return $url;
145
- }
146
-
147
- /**
148
- * convert url based on https into url based on http
149
- *
150
- * @since 0.4.0
151
- */
152
- public static function get_normal_url( $url ){
153
-
154
- $url = str_replace( 'https://', 'http://', $url );
155
-
156
- return $url;
157
- }
158
-
159
- /**
160
- * check if a given url is based on https or not.
161
- *
162
- * @since 0.4.0
163
- */
164
- public static function is_secure_url( $url ){
165
-
166
- if ( preg_match( '/^(https)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/', $url ) ) {
167
- return true;
168
- } else {
169
- return false;
170
- }
171
- }
172
-
173
- /**
174
- * check if a given url is based on http or not.
175
- *
176
- * @since 0.4.0
177
- */
178
- public static function is_normal_url( $url ){
179
-
180
- if ( preg_match( '/^(http)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/', $url ) ) {
181
- return true;
182
- } else {
183
- return false;
184
- }
185
- }
186
-
187
- /**
188
- * get cout data from SNS
189
- *
190
- * @since 0.5.1
191
- */
192
- public static function multi_remote_get( $urls, $timeout = 0, $sslverify = true, $curl = false ) {
193
-
194
- global $wp_version;
195
-
196
- $responses = array();
197
-
198
- if ( empty( $urls ) ) {
199
- return $responses;
200
- }
201
-
202
- if ( $curl ) {
203
-
204
- Common_Util::log( '[' . __METHOD__ . '] cURL: On' );
205
-
206
- $mh = curl_multi_init();
207
- $ch = array();
208
-
209
- foreach ( $urls as $sns => $url ) {
210
- $ch[$sns] = curl_init();
211
-
212
- curl_setopt( $ch[$sns], CURLOPT_URL, $url );
213
- curl_setopt( $ch[$sns], CURLOPT_USERAGENT, 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) );
214
- curl_setopt( $ch[$sns], CURLOPT_FOLLOWLOCATION, true );
215
- curl_setopt( $ch[$sns], CURLOPT_RETURNTRANSFER, true );
216
-
217
- if ( $sslverify ) {
218
- curl_setopt( $ch[$sns], CURLOPT_SSL_VERIFYPEER, true );
219
- curl_setopt( $ch[$sns], CURLOPT_SSL_VERIFYHOST, 2 );
220
- } else {
221
- curl_setopt( $ch[$sns], CURLOPT_SSL_VERIFYPEER, false );
222
- curl_setopt( $ch[$sns], CURLOPT_SSL_VERIFYHOST, 0 );
223
- }
224
-
225
- if ( $timeout > 0 ) {
226
- curl_setopt( $ch[$sns], CURLOPT_CONNECTTIMEOUT, $timeout );
227
- curl_setopt( $ch[$sns], CURLOPT_TIMEOUT, $timeout );
228
- }
229
-
230
- curl_multi_add_handle( $mh, $ch[$sns] );
231
- }
232
-
233
- /*
234
- $running = null;
235
-
236
- do {
237
- $mrc = curl_multi_exec( $mh, $running );
238
- } while ( $mrc == CURLM_CALL_MULTI_PERFORM );
239
-
240
- while ( $running && $mrc == CURLM_OK ) {
241
- if ( curl_multi_select( $mh ) != -1 ) {
242
- do {
243
- $mrc = curl_multi_exec( $mh, $running );
244
- } while ( $mrc == CURLM_CALL_MULTI_PERFORM );
245
- }
246
- }
247
- */
248
-
249
- $active = null;
250
-
251
- do {
252
- curl_multi_exec( $mh, $active );
253
- curl_multi_select( $mh );
254
- } while ( $active > 0);
255
-
256
- foreach( $urls as $sns => $url ){
257
- $responses[$sns]['error'] = curl_error( $ch[$sns] );
258
-
259
- if( ! empty( $responses[$sns]['error'] ) ) {
260
- $responses[$sns]['data'] = '';
261
- } else {
262
- $responses[$sns]['data'] = curl_multi_getcontent( $ch[$sns] );
263
- }
264
-
265
- curl_multi_remove_handle( $mh, $ch[$sns] );
266
- curl_close( $ch[$sns] );
267
- }
268
-
269
- curl_multi_close( $mh );
270
-
271
- return $responses;
272
- } else {
273
-
274
- Common_Util::log( '[' . __METHOD__ . '] cURL: Off' );
275
-
276
- $options = array(
277
- 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
278
- );
279
-
280
- if ( $sslverify ) {
281
- $options['sslverify'] = true;
282
- } else {
283
- $options['sslverify'] = false;
284
- }
285
-
286
- if ( $timeout > 0 ) {
287
- $options['timeout'] = $timeout;
288
- }
289
-
290
- foreach ( $urls as $sns => $url ) {
291
- $response = wp_remote_get( $url, $options );
292
-
293
- if ( ! is_wp_error( $response ) && $response['response']['code'] === 200 ) {
294
- $responses[$sns]['data'] = $response['body'];
295
- } else {
296
- $responses[$sns]['data'] = '';
297
- $responses[$sns]['error'] = $response->get_error_message();
298
- }
299
- }
300
-
301
- return $responses;
302
- }
303
- }
304
-
305
- public static function serialize_base64_encode( $array ) {
306
- $data = serialize( $array );
307
- $data = base64_encode( $data );
308
-
309
- return $data;
310
- }
311
-
312
- public static function unserialize_base64_decode( $data ) {
313
- $data = base64_decode( $data );
314
- $array = unserialize( $data );
315
-
316
- return $array;
317
- }
318
-
319
- }
320
-
321
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ class-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 - 2016 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 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
+ 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
+ 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
+ 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
+
342
+ $crypt = new Mcrypt();
343
+ return $crypt->encrypt( $input, $key );
344
+ } else {
345
+ self::log( 'mcrypt not loaded' );
346
+ $crypt = new Crypt_Blowfish( $key );
347
+ return $crypt->encrypt( $input );
348
+ }
349
+ }
350
+
351
+ /**
352
+ * decrypt given data
353
+ *
354
+ * @since 0.9.0
355
+ */
356
+ public static function decrypt_data( $input, $key = 'KEY_DEFAULT' ) {
357
+
358
+ if ( extension_loaded( 'mcrypt' ) ) {
359
+ self::log( 'mcrypt loaded' );
360
+
361
+ $key = md5( $key );
362
+
363
+ $td = mcrypt_module_open( 'blowfish', '', 'ecb', '' );
364
+ $key = substr( $key, 0, mcrypt_enc_get_key_size( $td ) );
365
+ $iv = mcrypt_create_iv( mcrypt_enc_get_iv_size( $td ), MCRYPT_RAND );
366
+
367
+ if ( mcrypt_generic_init( $td, $key, $iv ) < 0 ) {
368
+ exit( 'error.' );
369
+ }
370
+
371
+ $data = mdecrypt_generic( $td, base64_decode( $input ) );
372
+
373
+ mcrypt_generic_deinit( $td );
374
+ mcrypt_module_close( $td );
375
+
376
+ return $data;
377
+ } else {
378
+ self::log( 'mcrypt not loaded' );
379
+ $crypt = new Crypt_Blowfish( $key );
380
+ return $crypt->decrypt( $input );
381
+ }
382
+ }
383
+
384
+ /**
385
+ * Get bearer token for Twitter
386
+ *
387
+ * @since 0.9.0
388
+ */
389
+ public static function get_twitter_bearer_token( $cosumer_key, $consumer_secret, $sslverify = true, $timeout = 10 ) {
390
+ global $wp_version;
391
+
392
+ $bearer_token = '';
393
+ $url = 'https://api.twitter.com/oauth2/token';
394
+
395
+ $credential = base64_encode( $cosumer_key . ':' . $consumer_secret );
396
+
397
+ $options = array(
398
+ 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
399
+ );
400
+
401
+ if ( $sslverify ) {
402
+ $options['sslverify'] = true;
403
+ } else {
404
+ $options['sslverify'] = false;
405
+ }
406
+
407
+ if ( $timeout > 0 ) {
408
+ $options['timeout'] = $timeout;
409
+ }
410
+
411
+ $headers = array(
412
+ 'Authorization' => 'Basic ' . $credential,
413
+ 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'
414
+ );
415
+
416
+ if ( ! empty( $headers ) ) {
417
+ $options['headers'] = $headers;
418
+ }
419
+
420
+ $body = array(
421
+ 'grant_type' => 'client_credentials'
422
+ );
423
+
424
+ if ( ! empty( $body ) ) {
425
+ $options['body'] = $body;
426
+ }
427
+
428
+ $response = wp_remote_post( $url, $options );
429
+
430
+ self::log( $response );
431
+
432
+ if ( ! is_wp_error( $response ) ) {
433
+ if ( $response['response']['code'] === 200 ) {
434
+ $json = $response['body'];
435
+ $content = json_decode( $json, true ) ;
436
+ if ( isset( $content['token_type'] ) && $content['token_type'] && $content['token_type'] === 'bearer' ) {
437
+ if ( isset( $content['access_token'] ) && $content['access_token'] ) {
438
+ $bearer_token = $content['access_token'];
439
+ }
440
+ }
441
+ }
442
+ }
443
+
444
+ return $bearer_token;
445
+ }
446
+
447
+ /**
448
+ * Get acess token for Instagram
449
+ *
450
+ * @since 0.9.0
451
+ */
452
+ public static function get_instagram_access_token( $client_id, $client_secret, $redirect_uri, $code, $sslverify = true, $timeout = 10 ) {
453
+ global $wp_version;
454
+
455
+ $access_token = '';
456
+ $url = 'https://api.instagram.com/oauth/access_token';
457
+
458
+ $options = array(
459
+ 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
460
+ );
461
+
462
+ if ( $sslverify ) {
463
+ $options['sslverify'] = true;
464
+ } else {
465
+ $options['sslverify'] = false;
466
+ }
467
+
468
+ if ( $timeout > 0 ) {
469
+ $options['timeout'] = $timeout;
470
+ }
471
+
472
+ $body = array(
473
+ 'client_id' => $client_id,
474
+ 'client_secret' => $client_secret,
475
+ 'grant_type' => 'authorization_code',
476
+ 'redirect_uri' => $redirect_uri,
477
+ 'code' => $code
478
+ );
479
+
480
+ if ( ! empty( $body ) ) {
481
+ $options['body'] = $body;
482
+ }
483
+
484
+ $response = wp_remote_post( $url, $options );
485
+
486
+ self::log( $response );
487
+
488
+ if ( ! is_wp_error( $response ) ) {
489
+ if ( $response['response']['code'] === 200 ) {
490
+ $json = $response['body'];
491
+ $content = json_decode( $json, true ) ;
492
+ if ( isset( $content['access_token'] ) && $content['access_token'] ) {
493
+ $access_token = $content['access_token'];
494
+ }
495
+ }
496
+ }
497
+
498
+ return $access_token;
499
+ }
500
+
501
+ /**
502
+ * Get acess token for Facebook
503
+ *
504
+ * @since 0.9.0
505
+ */
506
+ public static function get_facebook_access_token( $app_id, $app_secret, $redirect_uri, $code, $sslverify = true, $timeout = 10 ) {
507
+ global $wp_version;
508
+
509
+ $original_access_token = '';
510
+ $extended_access_token = '';
511
+ $access_token = '';
512
+
513
+ $url = 'https://graph.facebook.com/v2.3/oauth/access_token';
514
+
515
+ $options = array(
516
+ 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
517
+ );
518
+
519
+ if ( $sslverify ) {
520
+ $options['sslverify'] = true;
521
+ } else {
522
+ $options['sslverify'] = false;
523
+ }
524
+
525
+ if ( $timeout > 0 ) {
526
+ $options['timeout'] = $timeout;
527
+ }
528
+
529
+ $query_parameters = array(
530
+ 'client_id' => $app_id,
531
+ 'client_secret' => $app_secret,
532
+ 'redirect_uri' => $redirect_uri,
533
+ 'code' => $code
534
+ );
535
+
536
+ $request_url = $url . '?' . http_build_query( $query_parameters , '' , '&' );
537
+
538
+ $response = wp_remote_get( $request_url, $options );
539
+
540
+ self::log( $response );
541
+
542
+ if ( ! is_wp_error( $response ) ) {
543
+ if ( $response['response']['code'] === 200 ) {
544
+ $json = $response['body'];
545
+ $content = json_decode( $json, true ) ;
546
+ if ( isset( $content['access_token'] ) && $content['access_token'] ) {
547
+ $original_access_token = $content['access_token'];
548
+ }
549
+ }
550
+ }
551
+
552
+ if ( isset( $original_access_token ) && $original_access_token ) {
553
+ $url = 'https://graph.facebook.com/oauth/access_token';
554
+
555
+ $query_parameters = array(
556
+ 'client_id' => $app_id,
557
+ 'client_secret' => $app_secret,
558
+ 'grant_type' => 'fb_exchange_token',
559
+ 'fb_exchange_token' => $original_access_token
560
+ );
561
+
562
+ $request_url = $url . '?' . http_build_query( $query_parameters , '' , '&' );
563
+
564
+ $response = wp_remote_get( $request_url, $options );
565
+
566
+ self::log( $response );
567
+
568
+ $data = array();
569
+
570
+ if ( ! is_wp_error( $response ) ) {
571
+ if ( $response['response']['code'] === 200 ) {
572
+ parse_str( $response['body'], $data );
573
+ if ( isset( $data['access_token'] ) && $data['access_token'] ) {
574
+ $extended_access_token = $data['access_token'];
575
+ }
576
+ }
577
+ }
578
+ }
579
+
580
+ if ( isset( $extended_access_token ) && $extended_access_token ) {
581
+ $url = 'https://graph.facebook.com/me/accounts';
582
+
583
+ $query_parameters = array(
584
+ 'access_token' => $extended_access_token
585
+ );
586
+
587
+ $request_url = $url . '?' . http_build_query( $query_parameters , '' , '&' );
588
+
589
+ $response = wp_remote_get( $request_url, $options );
590
+
591
+ self::log( $response );
592
+
593
+ if ( ! is_wp_error( $response ) ) {
594
+ if ( $response['response']['code'] === 200 ) {
595
+ $json = $response['body'];
596
+ $content = json_decode( $json, true ) ;
597
+
598
+ if ( isset( $content['data'][0]['access_token'] ) && $content['data'][0]['access_token'] ) {
599
+ $access_token = $content['data'][0]['access_token'];
600
+ }
601
+ }
602
+ }
603
+ }
604
+
605
+ return $access_token;
606
+ }
607
+
608
+ }
609
+
610
+ ?>
includes/class-crawl-strategy.php ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ class-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 - 2016 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
+ abstract class 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
+ 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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
89
+
90
+ $object_id = spl_object_hash( $this );
91
+
92
+ 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
+ * 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
+ 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
+ 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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
134
+ return $this->parameters;
135
+ }
136
+
137
+ public function get_parameter( $key ) {
138
+ 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
+ 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
+ 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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
166
+ return $this->query_parameters;
167
+ }
168
+
169
+ public function get_query_parameter( $key ) {
170
+ 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
+ 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
+ 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
+ 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
+ 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
+ }
includes/class-crawler.php ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ class-crawler.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 - 2016 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
+ abstract class 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 = 2;
61
+
62
+ /**
63
+ * Instance
64
+ */
65
+ private static $instance = array();
66
+
67
+ /**
68
+ * Crawl strategies
69
+ */
70
+ protected $crawl_strategies = array();
71
+
72
+ /**
73
+ * Cache target
74
+ */
75
+ protected $target_sns = array();
76
+
77
+ /**
78
+ * Class constarctor
79
+ * Hook onto all of the actions and filters needed by the plugin.
80
+ *
81
+ */
82
+ protected function __construct() {
83
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
84
+ //$this->get_object_id();
85
+ }
86
+
87
+ /**
88
+ * Get instance
89
+ *
90
+ * @since 0.1.1
91
+ */
92
+ public static function get_instance() {
93
+
94
+ $class_name = get_called_class();
95
+
96
+ if ( ! isset( self::$instance[$class_name] ) ) {
97
+ self::$instance[$class_name] = new $class_name();
98
+ }
99
+
100
+ return self::$instance[$class_name];
101
+ }
102
+
103
+ /**
104
+ * Return object ID
105
+ *
106
+ * @since 0.6.0
107
+ */
108
+ public function get_object_id() {
109
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
110
+
111
+ $object_id = spl_object_hash( $this );
112
+
113
+ Common_Util::log( '[' . __METHOD__ . '] object ID: ' . $object_id );
114
+
115
+ return $object_id;
116
+ }
117
+
118
+ /**
119
+ * Inhibit clone
120
+ *
121
+ * @since 0.6.0
122
+ */
123
+ final public function __clone() {
124
+ throw new Exception( 'Clone is not allowed against' . get_class( $this ) );
125
+ }
126
+
127
+ /**
128
+ * Initialization
129
+ *
130
+ * @since 0.6.0
131
+ */
132
+ abstract public function initialize( $options = array() );
133
+
134
+ /**
135
+ * Abstract method for data crawling
136
+ *
137
+ * @since 0.1.1
138
+ */
139
+ abstract public function get_data( $target_sns, $options );
140
+
141
+ /**
142
+ * Set strategy option
143
+ *
144
+ * @since 0.9.0
145
+ */
146
+ public function initialize_crawl_strategy( $sns, $options ) {
147
+ if ( isset( $this->crawl_strategies[$sns] ) ) {
148
+ $this->crawl_strategies[$sns]->initialize( $options );
149
+ }
150
+ }
151
+
152
+ /**
153
+ * Set strategy option
154
+ *
155
+ * @since 0.9.0
156
+ */
157
+ public function set_crawl_strategy_parameters( $sns, $options ) {
158
+ if ( isset( $this->crawl_strategies[$sns] ) ) {
159
+ $this->crawl_strategies[$sns]->set_parameters( $options );
160
+ }
161
+ }
162
+
163
+ /**
164
+ * Set strategy option
165
+ *
166
+ * @since 0.9.0
167
+ */
168
+ public function set_crawl_strategy_query_parameters( $sns, $options ) {
169
+ if ( isset( $this->crawl_strategies[$sns] ) ) {
170
+ $this->crawl_strategies[$sns]->set_query_parameters( $options );
171
+ }
172
+ }
173
+
174
+ /**
175
+ * Get strategy option
176
+ *
177
+ * @since 0.9.0
178
+ */
179
+ public function get_crawl_strategy_query_parameters( $sns ) {
180
+ return $this->crawl_strategies[$sns]->get_query_parameters();
181
+ }
182
+
183
+ /**
184
+ * Set strategy option
185
+ *
186
+ * @since 0.9.0
187
+ */
188
+ public function check_crawl_strategy_configurations( $sns ) {
189
+ return $this->crawl_strategies[$sns]->check_configuration();
190
+ }
191
+
192
+ }
193
+
194
+ ?>
includes/class-data-crawler.php DELETED
@@ -1,135 +0,0 @@
1
- <?php
2
- /*
3
- class-data-crawler.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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
31
-
32
- abstract class Data_Crawler {
33
-
34
- /**
35
- * URL for data crawling
36
- */
37
- protected $url = '';
38
-
39
- /**
40
- * method to crawl
41
- */
42
- protected $crawl_method = 1;
43
-
44
- /**
45
- * Timeout
46
- */
47
- protected $timeout = 10;
48
-
49
- /**
50
- * ssl verification
51
- */
52
- protected $ssl_verification = true;
53
-
54
- /**
55
- * retry flag
56
- */
57
- protected $crawl_retry = false;
58
-
59
- /**
60
- * limit of crawl retry
61
- */
62
- protected $retry_limit = 2;
63
-
64
- /**
65
- * Instance
66
- */
67
- private static $instance = array();
68
-
69
- /**
70
- * Class constarctor
71
- * Hook onto all of the actions and filters needed by the plugin.
72
- *
73
- */
74
- protected function __construct() {
75
- Common_Util::log('[' . __METHOD__ . '] (line='. __LINE__ . ')');
76
- //$this->get_object_id();
77
- }
78
-
79
- /**
80
- * Get instance
81
- *
82
- * @since 0.1.1
83
- */
84
- public static function get_instance() {
85
-
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
- * Return object ID
97
- *
98
- * @since 0.6.0
99
- */
100
- public function get_object_id() {
101
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
102
-
103
- $object_id = spl_object_hash( $this );
104
-
105
- Common_Util::log( '[' . __METHOD__ . '] object ID: ' . $object_id );
106
-
107
- return $object_id;
108
- }
109
-
110
- /**
111
- * Inhibit clone
112
- *
113
- * @since 0.6.0
114
- */
115
- final public function __clone() {
116
- throw new Exception('Clone is not allowed against' . get_class( $this ) );
117
- }
118
-
119
- /**
120
- * Initialization
121
- *
122
- * @since 0.6.0
123
- */
124
- abstract public function initialize( $options = array() );
125
-
126
- /**
127
- * Abstract method for data crawling
128
- *
129
- * @since 0.1.1
130
- */
131
- abstract public function get_data( $target_sns, $url );
132
-
133
- }
134
-
135
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-default-key.php ADDED
@@ -0,0 +1,320 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ /**
25
+ * Class containing default key
26
+ *
27
+ * @category Encryption
28
+ * @package Crypt_Blowfish
29
+ * @author Matthew Fonda <mfonda@php.net>
30
+ * @copyright 2005 Matthew Fonda
31
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
32
+ * @link http://pear.php.net/package/Crypt_Blowfish
33
+ * @version @package_version@
34
+ * @access public
35
+ */
36
+ class Crypt_Blowfish_DefaultKey {
37
+ public $P = array();
38
+
39
+ public $S = array();
40
+
41
+ public function __construct() {
42
+ $this->P = array(
43
+ 0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344,
44
+ 0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89,
45
+ 0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C,
46
+ 0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917,
47
+ 0x9216D5D9, 0x8979FB1B
48
+ );
49
+
50
+ $this->S = array(
51
+ array(
52
+ 0xD1310BA6, 0x98DFB5AC, 0x2FFD72DB, 0xD01ADFB7,
53
+ 0xB8E1AFED, 0x6A267E96, 0xBA7C9045, 0xF12C7F99,
54
+ 0x24A19947, 0xB3916CF7, 0x0801F2E2, 0x858EFC16,
55
+ 0x636920D8, 0x71574E69, 0xA458FEA3, 0xF4933D7E,
56
+ 0x0D95748F, 0x728EB658, 0x718BCD58, 0x82154AEE,
57
+ 0x7B54A41D, 0xC25A59B5, 0x9C30D539, 0x2AF26013,
58
+ 0xC5D1B023, 0x286085F0, 0xCA417918, 0xB8DB38EF,
59
+ 0x8E79DCB0, 0x603A180E, 0x6C9E0E8B, 0xB01E8A3E,
60
+ 0xD71577C1, 0xBD314B27, 0x78AF2FDA, 0x55605C60,
61
+ 0xE65525F3, 0xAA55AB94, 0x57489862, 0x63E81440,
62
+ 0x55CA396A, 0x2AAB10B6, 0xB4CC5C34, 0x1141E8CE,
63
+ 0xA15486AF, 0x7C72E993, 0xB3EE1411, 0x636FBC2A,
64
+ 0x2BA9C55D, 0x741831F6, 0xCE5C3E16, 0x9B87931E,
65
+ 0xAFD6BA33, 0x6C24CF5C, 0x7A325381, 0x28958677,
66
+ 0x3B8F4898, 0x6B4BB9AF, 0xC4BFE81B, 0x66282193,
67
+ 0x61D809CC, 0xFB21A991, 0x487CAC60, 0x5DEC8032,
68
+ 0xEF845D5D, 0xE98575B1, 0xDC262302, 0xEB651B88,
69
+ 0x23893E81, 0xD396ACC5, 0x0F6D6FF3, 0x83F44239,
70
+ 0x2E0B4482, 0xA4842004, 0x69C8F04A, 0x9E1F9B5E,
71
+ 0x21C66842, 0xF6E96C9A, 0x670C9C61, 0xABD388F0,
72
+ 0x6A51A0D2, 0xD8542F68, 0x960FA728, 0xAB5133A3,
73
+ 0x6EEF0B6C, 0x137A3BE4, 0xBA3BF050, 0x7EFB2A98,
74
+ 0xA1F1651D, 0x39AF0176, 0x66CA593E, 0x82430E88,
75
+ 0x8CEE8619, 0x456F9FB4, 0x7D84A5C3, 0x3B8B5EBE,
76
+ 0xE06F75D8, 0x85C12073, 0x401A449F, 0x56C16AA6,
77
+ 0x4ED3AA62, 0x363F7706, 0x1BFEDF72, 0x429B023D,
78
+ 0x37D0D724, 0xD00A1248, 0xDB0FEAD3, 0x49F1C09B,
79
+ 0x075372C9, 0x80991B7B, 0x25D479D8, 0xF6E8DEF7,
80
+ 0xE3FE501A, 0xB6794C3B, 0x976CE0BD, 0x04C006BA,
81
+ 0xC1A94FB6, 0x409F60C4, 0x5E5C9EC2, 0x196A2463,
82
+ 0x68FB6FAF, 0x3E6C53B5, 0x1339B2EB, 0x3B52EC6F,
83
+ 0x6DFC511F, 0x9B30952C, 0xCC814544, 0xAF5EBD09,
84
+ 0xBEE3D004, 0xDE334AFD, 0x660F2807, 0x192E4BB3,
85
+ 0xC0CBA857, 0x45C8740F, 0xD20B5F39, 0xB9D3FBDB,
86
+ 0x5579C0BD, 0x1A60320A, 0xD6A100C6, 0x402C7279,
87
+ 0x679F25FE, 0xFB1FA3CC, 0x8EA5E9F8, 0xDB3222F8,
88
+ 0x3C7516DF, 0xFD616B15, 0x2F501EC8, 0xAD0552AB,
89
+ 0x323DB5FA, 0xFD238760, 0x53317B48, 0x3E00DF82,
90
+ 0x9E5C57BB, 0xCA6F8CA0, 0x1A87562E, 0xDF1769DB,
91
+ 0xD542A8F6, 0x287EFFC3, 0xAC6732C6, 0x8C4F5573,
92
+ 0x695B27B0, 0xBBCA58C8, 0xE1FFA35D, 0xB8F011A0,
93
+ 0x10FA3D98, 0xFD2183B8, 0x4AFCB56C, 0x2DD1D35B,
94
+ 0x9A53E479, 0xB6F84565, 0xD28E49BC, 0x4BFB9790,
95
+ 0xE1DDF2DA, 0xA4CB7E33, 0x62FB1341, 0xCEE4C6E8,
96
+ 0xEF20CADA, 0x36774C01, 0xD07E9EFE, 0x2BF11FB4,
97
+ 0x95DBDA4D, 0xAE909198, 0xEAAD8E71, 0x6B93D5A0,
98
+ 0xD08ED1D0, 0xAFC725E0, 0x8E3C5B2F, 0x8E7594B7,
99
+ 0x8FF6E2FB, 0xF2122B64, 0x8888B812, 0x900DF01C,
100
+ 0x4FAD5EA0, 0x688FC31C, 0xD1CFF191, 0xB3A8C1AD,
101
+ 0x2F2F2218, 0xBE0E1777, 0xEA752DFE, 0x8B021FA1,
102
+ 0xE5A0CC0F, 0xB56F74E8, 0x18ACF3D6, 0xCE89E299,
103
+ 0xB4A84FE0, 0xFD13E0B7, 0x7CC43B81, 0xD2ADA8D9,
104
+ 0x165FA266, 0x80957705, 0x93CC7314, 0x211A1477,
105
+ 0xE6AD2065, 0x77B5FA86, 0xC75442F5, 0xFB9D35CF,
106
+ 0xEBCDAF0C, 0x7B3E89A0, 0xD6411BD3, 0xAE1E7E49,
107
+ 0x00250E2D, 0x2071B35E, 0x226800BB, 0x57B8E0AF,
108
+ 0x2464369B, 0xF009B91E, 0x5563911D, 0x59DFA6AA,
109
+ 0x78C14389, 0xD95A537F, 0x207D5BA2, 0x02E5B9C5,
110
+ 0x83260376, 0x6295CFA9, 0x11C81968, 0x4E734A41,
111
+ 0xB3472DCA, 0x7B14A94A, 0x1B510052, 0x9A532915,
112
+ 0xD60F573F, 0xBC9BC6E4, 0x2B60A476, 0x81E67400,
113
+ 0x08BA6FB5, 0x571BE91F, 0xF296EC6B, 0x2A0DD915,
114
+ 0xB6636521, 0xE7B9F9B6, 0xFF34052E, 0xC5855664,
115
+ 0x53B02D5D, 0xA99F8FA1, 0x08BA4799, 0x6E85076A
116
+ ),
117
+ array(
118
+ 0x4B7A70E9, 0xB5B32944, 0xDB75092E, 0xC4192623,
119
+ 0xAD6EA6B0, 0x49A7DF7D, 0x9CEE60B8, 0x8FEDB266,
120
+ 0xECAA8C71, 0x699A17FF, 0x5664526C, 0xC2B19EE1,
121
+ 0x193602A5, 0x75094C29, 0xA0591340, 0xE4183A3E,
122
+ 0x3F54989A, 0x5B429D65, 0x6B8FE4D6, 0x99F73FD6,
123
+ 0xA1D29C07, 0xEFE830F5, 0x4D2D38E6, 0xF0255DC1,
124
+ 0x4CDD2086, 0x8470EB26, 0x6382E9C6, 0x021ECC5E,
125
+ 0x09686B3F, 0x3EBAEFC9, 0x3C971814, 0x6B6A70A1,
126
+ 0x687F3584, 0x52A0E286, 0xB79C5305, 0xAA500737,
127
+ 0x3E07841C, 0x7FDEAE5C, 0x8E7D44EC, 0x5716F2B8,
128
+ 0xB03ADA37, 0xF0500C0D, 0xF01C1F04, 0x0200B3FF,
129
+ 0xAE0CF51A, 0x3CB574B2, 0x25837A58, 0xDC0921BD,
130
+ 0xD19113F9, 0x7CA92FF6, 0x94324773, 0x22F54701,
131
+ 0x3AE5E581, 0x37C2DADC, 0xC8B57634, 0x9AF3DDA7,
132
+ 0xA9446146, 0x0FD0030E, 0xECC8C73E, 0xA4751E41,
133
+ 0xE238CD99, 0x3BEA0E2F, 0x3280BBA1, 0x183EB331,
134
+ 0x4E548B38, 0x4F6DB908, 0x6F420D03, 0xF60A04BF,
135
+ 0x2CB81290, 0x24977C79, 0x5679B072, 0xBCAF89AF,
136
+ 0xDE9A771F, 0xD9930810, 0xB38BAE12, 0xDCCF3F2E,
137
+ 0x5512721F, 0x2E6B7124, 0x501ADDE6, 0x9F84CD87,
138
+ 0x7A584718, 0x7408DA17, 0xBC9F9ABC, 0xE94B7D8C,
139
+ 0xEC7AEC3A, 0xDB851DFA, 0x63094366, 0xC464C3D2,
140
+ 0xEF1C1847, 0x3215D908, 0xDD433B37, 0x24C2BA16,
141
+ 0x12A14D43, 0x2A65C451, 0x50940002, 0x133AE4DD,
142
+ 0x71DFF89E, 0x10314E55, 0x81AC77D6, 0x5F11199B,
143
+ 0x043556F1, 0xD7A3C76B, 0x3C11183B, 0x5924A509,
144
+ 0xF28FE6ED, 0x97F1FBFA, 0x9EBABF2C, 0x1E153C6E,
145
+ 0x86E34570, 0xEAE96FB1, 0x860E5E0A, 0x5A3E2AB3,
146
+ 0x771FE71C, 0x4E3D06FA, 0x2965DCB9, 0x99E71D0F,
147
+ 0x803E89D6, 0x5266C825, 0x2E4CC978, 0x9C10B36A,
148
+ 0xC6150EBA, 0x94E2EA78, 0xA5FC3C53, 0x1E0A2DF4,
149
+ 0xF2F74EA7, 0x361D2B3D, 0x1939260F, 0x19C27960,
150
+ 0x5223A708, 0xF71312B6, 0xEBADFE6E, 0xEAC31F66,
151
+ 0xE3BC4595, 0xA67BC883, 0xB17F37D1, 0x018CFF28,
152
+ 0xC332DDEF, 0xBE6C5AA5, 0x65582185, 0x68AB9802,
153
+ 0xEECEA50F, 0xDB2F953B, 0x2AEF7DAD, 0x5B6E2F84,
154
+ 0x1521B628, 0x29076170, 0xECDD4775, 0x619F1510,
155
+ 0x13CCA830, 0xEB61BD96, 0x0334FE1E, 0xAA0363CF,
156
+ 0xB5735C90, 0x4C70A239, 0xD59E9E0B, 0xCBAADE14,
157
+ 0xEECC86BC, 0x60622CA7, 0x9CAB5CAB, 0xB2F3846E,
158
+ 0x648B1EAF, 0x19BDF0CA, 0xA02369B9, 0x655ABB50,
159
+ 0x40685A32, 0x3C2AB4B3, 0x319EE9D5, 0xC021B8F7,
160
+ 0x9B540B19, 0x875FA099, 0x95F7997E, 0x623D7DA8,
161
+ 0xF837889A, 0x97E32D77, 0x11ED935F, 0x16681281,
162
+ 0x0E358829, 0xC7E61FD6, 0x96DEDFA1, 0x7858BA99,
163
+ 0x57F584A5, 0x1B227263, 0x9B83C3FF, 0x1AC24696,
164
+ 0xCDB30AEB, 0x532E3054, 0x8FD948E4, 0x6DBC3128,
165
+ 0x58EBF2EF, 0x34C6FFEA, 0xFE28ED61, 0xEE7C3C73,
166
+ 0x5D4A14D9, 0xE864B7E3, 0x42105D14, 0x203E13E0,
167
+ 0x45EEE2B6, 0xA3AAABEA, 0xDB6C4F15, 0xFACB4FD0,
168
+ 0xC742F442, 0xEF6ABBB5, 0x654F3B1D, 0x41CD2105,
169
+ 0xD81E799E, 0x86854DC7, 0xE44B476A, 0x3D816250,
170
+ 0xCF62A1F2, 0x5B8D2646, 0xFC8883A0, 0xC1C7B6A3,
171
+ 0x7F1524C3, 0x69CB7492, 0x47848A0B, 0x5692B285,
172
+ 0x095BBF00, 0xAD19489D, 0x1462B174, 0x23820E00,
173
+ 0x58428D2A, 0x0C55F5EA, 0x1DADF43E, 0x233F7061,
174
+ 0x3372F092, 0x8D937E41, 0xD65FECF1, 0x6C223BDB,
175
+ 0x7CDE3759, 0xCBEE7460, 0x4085F2A7, 0xCE77326E,
176
+ 0xA6078084, 0x19F8509E, 0xE8EFD855, 0x61D99735,
177
+ 0xA969A7AA, 0xC50C06C2, 0x5A04ABFC, 0x800BCADC,
178
+ 0x9E447A2E, 0xC3453484, 0xFDD56705, 0x0E1E9EC9,
179
+ 0xDB73DBD3, 0x105588CD, 0x675FDA79, 0xE3674340,
180
+ 0xC5C43465, 0x713E38D8, 0x3D28F89E, 0xF16DFF20,
181
+ 0x153E21E7, 0x8FB03D4A, 0xE6E39F2B, 0xDB83ADF7
182
+ ),
183
+ array(
184
+ 0xE93D5A68, 0x948140F7, 0xF64C261C, 0x94692934,
185
+ 0x411520F7, 0x7602D4F7, 0xBCF46B2E, 0xD4A20068,
186
+ 0xD4082471, 0x3320F46A, 0x43B7D4B7, 0x500061AF,
187
+ 0x1E39F62E, 0x97244546, 0x14214F74, 0xBF8B8840,
188
+ 0x4D95FC1D, 0x96B591AF, 0x70F4DDD3, 0x66A02F45,
189
+ 0xBFBC09EC, 0x03BD9785, 0x7FAC6DD0, 0x31CB8504,
190
+ 0x96EB27B3, 0x55FD3941, 0xDA2547E6, 0xABCA0A9A,
191
+ 0x28507825, 0x530429F4, 0x0A2C86DA, 0xE9B66DFB,
192
+ 0x68DC1462, 0xD7486900, 0x680EC0A4, 0x27A18DEE,
193
+ 0x4F3FFEA2, 0xE887AD8C, 0xB58CE006, 0x7AF4D6B6,
194
+ 0xAACE1E7C, 0xD3375FEC, 0xCE78A399, 0x406B2A42,
195
+ 0x20FE9E35, 0xD9F385B9, 0xEE39D7AB, 0x3B124E8B,
196
+ 0x1DC9FAF7, 0x4B6D1856, 0x26A36631, 0xEAE397B2,
197
+ 0x3A6EFA74, 0xDD5B4332, 0x6841E7F7, 0xCA7820FB,
198
+ 0xFB0AF54E, 0xD8FEB397, 0x454056AC, 0xBA489527,
199
+ 0x55533A3A, 0x20838D87, 0xFE6BA9B7, 0xD096954B,
200
+ 0x55A867BC, 0xA1159A58, 0xCCA92963, 0x99E1DB33,
201
+ 0xA62A4A56, 0x3F3125F9, 0x5EF47E1C, 0x9029317C,
202
+ 0xFDF8E802, 0x04272F70, 0x80BB155C, 0x05282CE3,
203
+ 0x95C11548, 0xE4C66D22, 0x48C1133F, 0xC70F86DC,
204
+ 0x07F9C9EE, 0x41041F0F, 0x404779A4, 0x5D886E17,
205
+ 0x325F51EB, 0xD59BC0D1, 0xF2BCC18F, 0x41113564,
206
+ 0x257B7834, 0x602A9C60, 0xDFF8E8A3, 0x1F636C1B,
207
+ 0x0E12B4C2, 0x02E1329E, 0xAF664FD1, 0xCAD18115,
208
+ 0x6B2395E0, 0x333E92E1, 0x3B240B62, 0xEEBEB922,
209
+ 0x85B2A20E, 0xE6BA0D99, 0xDE720C8C, 0x2DA2F728,
210
+ 0xD0127845, 0x95B794FD, 0x647D0862, 0xE7CCF5F0,
211
+ 0x5449A36F, 0x877D48FA, 0xC39DFD27, 0xF33E8D1E,
212
+ 0x0A476341, 0x992EFF74, 0x3A6F6EAB, 0xF4F8FD37,
213
+ 0xA812DC60, 0xA1EBDDF8, 0x991BE14C, 0xDB6E6B0D,
214
+ 0xC67B5510, 0x6D672C37, 0x2765D43B, 0xDCD0E804,
215
+ 0xF1290DC7, 0xCC00FFA3, 0xB5390F92, 0x690FED0B,
216
+ 0x667B9FFB, 0xCEDB7D9C, 0xA091CF0B, 0xD9155EA3,
217
+ 0xBB132F88, 0x515BAD24, 0x7B9479BF, 0x763BD6EB,
218
+ 0x37392EB3, 0xCC115979, 0x8026E297, 0xF42E312D,
219
+ 0x6842ADA7, 0xC66A2B3B, 0x12754CCC, 0x782EF11C,
220
+ 0x6A124237, 0xB79251E7, 0x06A1BBE6, 0x4BFB6350,
221
+ 0x1A6B1018, 0x11CAEDFA, 0x3D25BDD8, 0xE2E1C3C9,
222
+ 0x44421659, 0x0A121386, 0xD90CEC6E, 0xD5ABEA2A,
223
+ 0x64AF674E, 0xDA86A85F, 0xBEBFE988, 0x64E4C3FE,
224
+ 0x9DBC8057, 0xF0F7C086, 0x60787BF8, 0x6003604D,
225
+ 0xD1FD8346, 0xF6381FB0, 0x7745AE04, 0xD736FCCC,
226
+ 0x83426B33, 0xF01EAB71, 0xB0804187, 0x3C005E5F,
227
+ 0x77A057BE, 0xBDE8AE24, 0x55464299, 0xBF582E61,
228
+ 0x4E58F48F, 0xF2DDFDA2, 0xF474EF38, 0x8789BDC2,
229
+ 0x5366F9C3, 0xC8B38E74, 0xB475F255, 0x46FCD9B9,
230
+ 0x7AEB2661, 0x8B1DDF84, 0x846A0E79, 0x915F95E2,
231
+ 0x466E598E, 0x20B45770, 0x8CD55591, 0xC902DE4C,
232
+ 0xB90BACE1, 0xBB8205D0, 0x11A86248, 0x7574A99E,
233
+ 0xB77F19B6, 0xE0A9DC09, 0x662D09A1, 0xC4324633,
234
+ 0xE85A1F02, 0x09F0BE8C, 0x4A99A025, 0x1D6EFE10,
235
+ 0x1AB93D1D, 0x0BA5A4DF, 0xA186F20F, 0x2868F169,
236
+ 0xDCB7DA83, 0x573906FE, 0xA1E2CE9B, 0x4FCD7F52,
237
+ 0x50115E01, 0xA70683FA, 0xA002B5C4, 0x0DE6D027,
238
+ 0x9AF88C27, 0x773F8641, 0xC3604C06, 0x61A806B5,
239
+ 0xF0177A28, 0xC0F586E0, 0x006058AA, 0x30DC7D62,
240
+ 0x11E69ED7, 0x2338EA63, 0x53C2DD94, 0xC2C21634,
241
+ 0xBBCBEE56, 0x90BCB6DE, 0xEBFC7DA1, 0xCE591D76,
242
+ 0x6F05E409, 0x4B7C0188, 0x39720A3D, 0x7C927C24,
243
+ 0x86E3725F, 0x724D9DB9, 0x1AC15BB4, 0xD39EB8FC,
244
+ 0xED545578, 0x08FCA5B5, 0xD83D7CD3, 0x4DAD0FC4,
245
+ 0x1E50EF5E, 0xB161E6F8, 0xA28514D9, 0x6C51133C,
246
+ 0x6FD5C7E7, 0x56E14EC4, 0x362ABFCE, 0xDDC6C837,
247
+ 0xD79A3234, 0x92638212, 0x670EFA8E, 0x406000E0
248
+ ),
249
+ array(
250
+ 0x3A39CE37, 0xD3FAF5CF, 0xABC27737, 0x5AC52D1B,
251
+ 0x5CB0679E, 0x4FA33742, 0xD3822740, 0x99BC9BBE,
252
+ 0xD5118E9D, 0xBF0F7315, 0xD62D1C7E, 0xC700C47B,
253
+ 0xB78C1B6B, 0x21A19045, 0xB26EB1BE, 0x6A366EB4,
254
+ 0x5748AB2F, 0xBC946E79, 0xC6A376D2, 0x6549C2C8,
255
+ 0x530FF8EE, 0x468DDE7D, 0xD5730A1D, 0x4CD04DC6,
256
+ 0x2939BBDB, 0xA9BA4650, 0xAC9526E8, 0xBE5EE304,
257
+ 0xA1FAD5F0, 0x6A2D519A, 0x63EF8CE2, 0x9A86EE22,
258
+ 0xC089C2B8, 0x43242EF6, 0xA51E03AA, 0x9CF2D0A4,
259
+ 0x83C061BA, 0x9BE96A4D, 0x8FE51550, 0xBA645BD6,
260
+ 0x2826A2F9, 0xA73A3AE1, 0x4BA99586, 0xEF5562E9,
261
+ 0xC72FEFD3, 0xF752F7DA, 0x3F046F69, 0x77FA0A59,
262
+ 0x80E4A915, 0x87B08601, 0x9B09E6AD, 0x3B3EE593,
263
+ 0xE990FD5A, 0x9E34D797, 0x2CF0B7D9, 0x022B8B51,
264
+ 0x96D5AC3A, 0x017DA67D, 0xD1CF3ED6, 0x7C7D2D28,
265
+ 0x1F9F25CF, 0xADF2B89B, 0x5AD6B472, 0x5A88F54C,
266
+ 0xE029AC71, 0xE019A5E6, 0x47B0ACFD, 0xED93FA9B,
267
+ 0xE8D3C48D, 0x283B57CC, 0xF8D56629, 0x79132E28,
268
+ 0x785F0191, 0xED756055, 0xF7960E44, 0xE3D35E8C,
269
+ 0x15056DD4, 0x88F46DBA, 0x03A16125, 0x0564F0BD,
270
+ 0xC3EB9E15, 0x3C9057A2, 0x97271AEC, 0xA93A072A,
271
+ 0x1B3F6D9B, 0x1E6321F5, 0xF59C66FB, 0x26DCF319,
272
+ 0x7533D928, 0xB155FDF5, 0x03563482, 0x8ABA3CBB,
273
+ 0x28517711, 0xC20AD9F8, 0xABCC5167, 0xCCAD925F,
274
+ 0x4DE81751, 0x3830DC8E, 0x379D5862, 0x9320F991,
275
+ 0xEA7A90C2, 0xFB3E7BCE, 0x5121CE64, 0x774FBE32,
276
+ 0xA8B6E37E, 0xC3293D46, 0x48DE5369, 0x6413E680,
277
+ 0xA2AE0810, 0xDD6DB224, 0x69852DFD, 0x09072166,
278
+ 0xB39A460A, 0x6445C0DD, 0x586CDECF, 0x1C20C8AE,
279
+ 0x5BBEF7DD, 0x1B588D40, 0xCCD2017F, 0x6BB4E3BB,
280
+ 0xDDA26A7E, 0x3A59FF45, 0x3E350A44, 0xBCB4CDD5,
281
+ 0x72EACEA8, 0xFA6484BB, 0x8D6612AE, 0xBF3C6F47,
282
+ 0xD29BE463, 0x542F5D9E, 0xAEC2771B, 0xF64E6370,
283
+ 0x740E0D8D, 0xE75B1357, 0xF8721671, 0xAF537D5D,
284
+ 0x4040CB08, 0x4EB4E2CC, 0x34D2466A, 0x0115AF84,
285
+ 0xE1B00428, 0x95983A1D, 0x06B89FB4, 0xCE6EA048,
286
+ 0x6F3F3B82, 0x3520AB82, 0x011A1D4B, 0x277227F8,
287
+ 0x611560B1, 0xE7933FDC, 0xBB3A792B, 0x344525BD,
288
+ 0xA08839E1, 0x51CE794B, 0x2F32C9B7, 0xA01FBAC9,
289
+ 0xE01CC87E, 0xBCC7D1F6, 0xCF0111C3, 0xA1E8AAC7,
290
+ 0x1A908749, 0xD44FBD9A, 0xD0DADECB, 0xD50ADA38,
291
+ 0x0339C32A, 0xC6913667, 0x8DF9317C, 0xE0B12B4F,
292
+ 0xF79E59B7, 0x43F5BB3A, 0xF2D519FF, 0x27D9459C,
293
+ 0xBF97222C, 0x15E6FC2A, 0x0F91FC71, 0x9B941525,
294
+ 0xFAE59361, 0xCEB69CEB, 0xC2A86459, 0x12BAA8D1,
295
+ 0xB6C1075E, 0xE3056A0C, 0x10D25065, 0xCB03A442,
296
+ 0xE0EC6E0E, 0x1698DB3B, 0x4C98A0BE, 0x3278E964,
297
+ 0x9F1F9532, 0xE0D392DF, 0xD3A0342B, 0x8971F21E,
298
+ 0x1B0A7441, 0x4BA3348C, 0xC5BE7120, 0xC37632D8,
299
+ 0xDF359F8D, 0x9B992F2E, 0xE60B6F47, 0x0FE3F11D,
300
+ 0xE54CDA54, 0x1EDAD891, 0xCE6279CF, 0xCD3E7E6F,
301
+ 0x1618B166, 0xFD2C1D05, 0x848FD2C5, 0xF6FB2299,
302
+ 0xF523F357, 0xA6327623, 0x93A83531, 0x56CCCD02,
303
+ 0xACF08162, 0x5A75EBB5, 0x6E163697, 0x88D273CC,
304
+ 0xDE966292, 0x81B949D0, 0x4C50901B, 0x71C65614,
305
+ 0xE6C6C7BD, 0x327A140A, 0x45E1D006, 0xC3F27B9A,
306
+ 0xC9AA53FD, 0x62A80F00, 0xBB25BFE2, 0x35BDD2F6,
307
+ 0x71126905, 0xB2040222, 0xB6CBCF7C, 0xCD769C2B,
308
+ 0x53113EC0, 0x1640E3D3, 0x38ABBD60, 0x2547ADF0,
309
+ 0xBA38209C, 0xF746CE76, 0x77AFA1C5, 0x20756060,
310
+ 0x85CBFE4E, 0x8AE88DD8, 0x7AAAF9B0, 0x4CF9AA7E,
311
+ 0x1948C25C, 0x02FB8A8C, 0x01C36AE4, 0xD6EBE1F9,
312
+ 0x90D4F869, 0xA65CDEA0, 0x3F09252D, 0xC208E69F,
313
+ 0xB74E6132, 0xCE77E25B, 0x578FDFE3, 0x3AC372E6
314
+ )
315
+ );
316
+ }
317
+
318
+ }
319
+
320
+ ?>
includes/class-engine.php CHANGED
@@ -10,8 +10,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
  */
11
 
12
  /*
13
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
 
16
  This program is free software; you can redistribute it and/or
17
  modify it under the terms of the GNU General Public License
@@ -26,56 +25,53 @@ GNU General Public License for more details.
26
  You should have received a copy of the GNU General Public License
27
  along with this program; if not, write to the Free Software
28
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
  */
31
 
32
-
33
  abstract class Engine {
34
-
35
  /**
36
  * Cron name to schedule cache processing
37
- */
38
- protected $prime_cron = NULL;
39
 
40
  /**
41
  * Cron name to execute cache processing
42
- */
43
- protected $execute_cron = NULL;
44
 
45
  /**
46
  * Schedule name for cache processing
47
- */
48
- protected $event_schedule = NULL;
49
 
50
- /**
51
  * Schedule description for cache processing
52
- */
53
- protected $event_description = NULL;
54
-
55
- /**
56
  * Instance
57
  */
58
- private static $instance = array();
59
-
60
  /**
61
  * Class constarctor
62
  * Hook onto all of the actions and filters needed by the plugin.
63
  *
64
  */
65
  protected function __construct() {
66
- Common_Util::log('[' . __METHOD__ . '] (line='. __LINE__ . ')');
67
- //$this->get_object_id();
68
  }
69
-
70
- /**
71
  * Get instance
72
  *
73
  * @since 0.1.1
74
- */
75
- public static function get_instance() {
 
76
 
77
- $class_name = get_called_class();
78
-
79
  if ( ! isset( self::$instance[$class_name] ) ) {
80
  self::$instance[$class_name] = new $class_name();
81
  }
@@ -83,81 +79,80 @@ abstract class Engine {
83
  return self::$instance[$class_name];
84
  }
85
 
86
- /**
87
- * Return object ID
88
- *
89
  * @since 0.6.0
90
- */
91
- public function get_object_id() {
92
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
93
-
94
- $object_id = spl_object_hash( $this );
95
-
96
- Common_Util::log( '[' . __METHOD__ . '] object ID: ' . $object_id );
97
-
98
- return $object_id;
99
- }
100
-
101
- /**
102
- * Inhibit clone
103
- *
104
  * @since 0.6.0
105
- */
106
- final public function __clone() {
107
- throw new Exception('Clone is not allowed against' . get_class( $this ) );
108
- }
109
-
110
- /**
111
  * Register base schedule for this engine
112
  *
113
  * @since 0.1.0
114
- */
115
  public function register_schedule() {
116
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
117
-
118
  if ( ! wp_next_scheduled( $this->prime_cron ) ) {
119
  wp_schedule_event( time(), $this->event_schedule, $this->prime_cron );
120
  }
121
  }
122
-
123
- /**
124
  * Unregister base schedule for this engine
125
  *
126
  * @since 0.1.0
127
- */
128
  public function unregister_schedule() {
129
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
130
 
131
- wp_clear_scheduled_hook( $this->prime_cron );
132
- WP_Cron_Util::clear_scheduled_hook( $this->execute_cron );
133
  }
134
-
135
- /**
136
  * Get name of prime cron
137
  *
138
  * @since 0.1.1
139
- */
140
- public function get_prime_cron() {
141
- return $this->prime_cron;
142
- }
143
 
144
- /**
145
  * Get name of execute cron
146
  *
147
  * @since 0.1.1
148
- */
149
- public function get_excute_cron() {
150
- return $this->execute_cron;
151
- }
152
 
153
- /**
154
  * Initialization
155
  *
156
  * @since 0.1.1
157
  */
158
- abstract public function initialize( $options = array() );
159
 
160
-
161
  }
162
 
163
- ?>
10
  */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2016 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
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
  abstract class 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
+ 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
  }
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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
89
+
90
+ $object_id = spl_object_hash( $this );
91
+
92
+ 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
+ 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 );
116
  }
117
  }
118
+
119
+ /**
120
  * Unregister base schedule for this engine
121
  *
122
  * @since 0.1.0
123
+ */
124
  public function unregister_schedule() {
125
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
126
 
127
+ wp_clear_scheduled_hook( $this->prime_cron );
128
+ 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;
138
+ }
139
 
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;
147
+ }
148
 
149
+ /**
150
  * Initialization
151
  *
152
  * @since 0.1.1
153
  */
154
+ abstract public function initialize( $options = array() );
155
 
 
156
  }
157
 
158
+ ?>
includes/class-export-engine.php CHANGED
@@ -1,47 +1,44 @@
1
- <?php
2
- /*
3
- class-export-engine.php
4
-
5
- Description: This class is a data export engine whitch exports cached data using wp-cron at regular intervals
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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
31
-
32
-
33
- abstract class Export_Engine extends Engine {
34
-
35
- /**
36
- * Meta key for share second cache
37
- */
38
- protected $share_meta_key_prefix = NULL;
39
-
40
- /**
41
- * Meta key for follow second cache
42
- */
43
- protected $follow_meta_key_prefix = NULL;
44
-
45
- }
46
-
47
- ?>
1
+ <?php
2
+ /*
3
+ class-export-engine.php
4
+
5
+ Description: This class is a data export engine whitch exports cached data using wp-cron at regular intervals
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 - 2016 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
+ abstract class Export_Engine extends 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
+
44
+ ?>
 
 
 
includes/class-follow-base-cache-engine.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  class-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
6
  Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
@@ -10,8 +10,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
  */
11
 
12
  /*
13
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
 
16
  This program is free software; you can redistribute it and/or
17
  modify it under the terms of the GNU General Public License
@@ -26,213 +25,205 @@ GNU General Public License for more details.
26
  You should have received a copy of the GNU General Public License
27
  along with this program; if not, write to the Free Software
28
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
  */
31
 
32
-
33
  class Follow_Base_Cache_Engine extends Follow_Cache_Engine {
34
 
35
  /**
36
  * Prefix of cache ID
37
- */
38
- const DEF_TRANSIENT_PREFIX = 'scc_follow_count_';
39
-
40
  /**
41
  * Cron name to schedule cache processing
42
- */
43
- const DEF_PRIME_CRON = 'scc_follow_basecache_prime';
44
 
45
  /**
46
  * Cron name to execute cache processing
47
- */
48
- const DEF_EXECUTE_CRON = 'scc_follow_basecache_exec';
49
 
50
  /**
51
  * Schedule name for cache processing
52
- */
53
- const DEF_EVENT_SCHEDULE = 'follow_base_cache_event';
54
 
55
- /**
56
  * Schedule description for cache processing
57
- */
58
- const DEF_EVENT_DESCRIPTION = '[SCC] Follow Base Cache Interval';
59
-
60
  /**
61
  * Interval cheking and caching target data
62
- */
63
  private $check_interval = 600;
64
 
65
- /**
66
- * Feed type
67
- */
68
- private $feed_type = '';
69
-
70
  /**
71
  * Offset suffix
72
- */
73
- private $offset_suffix = 'follow_base_cache_offset';
74
 
75
- /**
76
  * Initialization
77
  *
78
  * @since 0.1.1
79
  */
80
- public function initialize( $options = array() ) {
81
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
82
-
83
- $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
84
- $this->prime_cron = self::DEF_PRIME_CRON;
85
- $this->execute_cron = self::DEF_EXECUTE_CRON;
86
- $this->event_schedule = self::DEF_EVENT_SCHEDULE;
87
- $this->event_description = self::DEF_EVENT_DESCRIPTION;
88
-
89
- $this->load_ratio = 0.5;
90
-
91
- if ( isset( $options['delegate'] ) ) $this->delegate = $options['delegate'];
92
- if ( isset( $options['crawler'] ) ) $this->crawler = $options['crawler'];
93
- if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
94
- if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
95
- if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
96
  if ( isset( $options['prime_cron'] ) ) $this->prime_cron = $options['prime_cron'];
97
  if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
98
  if ( isset( $options['event_schedule'] ) ) $this->event_schedule = $options['event_schedule'];
99
- if ( isset( $options['event_description'] ) ) $this->event_description = $options['event_description'];
100
- if ( isset( $options['scheme_migration_mode'] ) ) $this->scheme_migration_mode = $options['scheme_migration_mode'];
101
- if ( isset( $options['scheme_migration_exclude_keys'] ) ) $this->scheme_migration_exclude_keys = $options['scheme_migration_exclude_keys'];
102
- if ( isset( $options['feed_type'] ) ) $this->feed_type = $options['feed_type'];
103
- if ( isset( $options['cache_retry'] ) ) $this->cache_retry = $options['cache_retry'];
104
- if ( isset( $options['retry_limit'] ) ) $this->retry_limit = $options['retry_limit'];
105
-
106
- add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
107
  add_action( $this->prime_cron, array( $this, 'prime_cache' ) );
108
  add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 1 );
 
109
 
110
- }
111
-
112
- /**
113
  * Register event schedule for this engine
114
  *
115
  * @since 0.1.0
116
- */
117
  public function schedule_check_interval( $schedules ) {
118
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
119
-
120
  $schedules[$this->event_schedule] = array(
121
  'interval' => $this->check_interval,
122
  'display' => $this->event_description
123
- );
124
-
125
  return $schedules;
126
  }
127
 
128
- /**
129
  * Schedule data retrieval and cache processing
130
  *
131
  * @since 0.4.0
132
- */
133
  public function prime_cache() {
134
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
135
 
136
  $next_exec_time = time() + $this->check_interval;
137
 
138
  Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
139
  Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
140
-
141
- wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( Common_Util::short_hash( $next_exec_time ) ) );
142
  }
143
-
144
- /**
145
  * Get and cache data of each published post and page
146
  *
147
  * @since 0.1.0
148
- */
149
  public function execute_cache( $hash ) {
150
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
151
-
152
  Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
153
-
154
- $cache_expiration = $this->get_cache_expiration();
155
-
156
  Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
157
-
158
- $url = get_feed_link( $this->feed_type );
159
-
160
- $transient_id = $this->get_cache_key( 'follow' );
161
-
162
  $options = array(
163
  'cache_key' => $transient_id,
164
- 'target_url' => $url,
165
- 'target_sns' => $this->target_sns,
166
  'cache_expiration' => $cache_expiration
167
- );
168
-
169
- // Primary cache
170
  $this->cache( $options );
171
-
172
- // Secondary cache
173
- $this->delegate_cache( $options );
174
  }
175
 
176
- /**
177
  * Get and cache data for a given post
178
  *
179
  * @since 0.4.0
180
  */
181
- public function direct_cache() {
182
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
183
-
184
- $cache_expiration = $this->get_cache_expiration();
185
 
186
- Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
 
 
187
 
188
- $url = get_feed_link();
189
-
190
- $transient_id = $this->get_cache_key( 'follow' );
191
-
192
  $options = array(
193
  'cache_key' => $transient_id,
194
- 'target_url' => $url,
195
- 'target_sns' => $this->target_sns,
196
  'cache_expiration' => $cache_expiration
197
- );
198
-
199
- return $this->cache( $options );
200
- }
201
-
202
- /**
 
 
 
 
 
 
 
 
203
  * Get cache expiration based on current number of total post and page
204
  *
205
  * @since 0.4.0
206
- */
207
- protected function get_cache_expiration() {
208
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
209
-
210
  return 3 * $this->check_interval;
211
- }
212
-
213
- /**
214
- * Initialize meta key for ranking
215
  *
216
  * @since 0.3.0
217
- */
218
- public function initialize_cache() {
219
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
220
-
221
- }
222
 
223
- /**
224
- * Clear meta key for ranking
225
  *
226
  * @since 0.3.0
227
- */
228
- public function clear_cache() {
229
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
230
-
231
  $transient_id = $this->get_cache_key( 'follow' );
232
-
233
- delete_transient( $transient_id );
234
- }
235
-
236
  }
237
 
238
- ?>
2
  /*
3
  class-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
6
  Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
10
  */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2016 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
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 Follow_Base_Cache_Engine extends Follow_Cache_Engine {
31
 
32
  /**
33
  * Prefix of cache ID
34
+ */
35
+ const DEF_TRANSIENT_PREFIX = 'scc_follow_count_';
36
+
37
  /**
38
  * Cron name to schedule cache processing
39
+ */
40
+ const DEF_PRIME_CRON = 'scc_follow_basecache_prime';
41
 
42
  /**
43
  * Cron name to execute cache processing
44
+ */
45
+ const DEF_EXECUTE_CRON = 'scc_follow_basecache_exec';
46
 
47
  /**
48
  * Schedule name for cache processing
49
+ */
50
+ const DEF_EVENT_SCHEDULE = 'follow_base_cache_event';
51
 
52
+ /**
53
  * Schedule description for cache processing
54
+ */
55
+ const DEF_EVENT_DESCRIPTION = '[SCC] Follow Base Cache Interval';
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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
74
+
75
+ $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
76
+ $this->prime_cron = self::DEF_PRIME_CRON;
77
+ $this->execute_cron = self::DEF_EXECUTE_CRON;
78
+ $this->event_schedule = self::DEF_EVENT_SCHEDULE;
79
+ $this->event_description = self::DEF_EVENT_DESCRIPTION;
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' ) );
99
  add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 1 );
100
+ }
101
 
102
+ /**
 
 
103
  * Register event schedule for this engine
104
  *
105
  * @since 0.1.0
106
+ */
107
  public function schedule_check_interval( $schedules ) {
108
+ 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;
116
  }
117
 
118
+ /**
119
  * Schedule data retrieval and cache processing
120
  *
121
  * @since 0.4.0
122
+ */
123
  public function prime_cache() {
124
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
125
 
126
  $next_exec_time = time() + $this->check_interval;
127
 
128
  Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
129
  Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
130
+
131
+ wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( 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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
141
+
142
  Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
143
+
144
+ $cache_expiration = $this->get_cache_expiration();
145
+
146
  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
157
  $this->cache( $options );
158
+
159
+ // Secondary cache
160
+ $this->delegate_cache( $options );
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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
170
+
171
+ $cache_expiration = $this->get_cache_expiration();
172
 
173
+ 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
184
+ $result = $this->cache( $options );
185
+
186
+ if ( $second_sync ) {
187
+ // Secondary cache
188
+ $this->delegate_cache( $options );
189
+ }
190
+
191
+ return $result;
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
+ 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
+ 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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
221
+
222
  $transient_id = $this->get_cache_key( 'follow' );
223
+
224
+ delete_transient( $transient_id );
225
+ }
226
+
227
  }
228
 
229
+ ?>
includes/class-follow-cache-engine.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  class-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
6
  Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
@@ -10,8 +10,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
  */
11
 
12
  /*
13
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
 
16
  This program is free software; you can redistribute it and/or
17
  modify it under the terms of the GNU General Public License
@@ -26,130 +25,177 @@ GNU General Public License for more details.
26
  You should have received a copy of the GNU General Public License
27
  along with this program; if not, write to the Free Software
28
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
  */
31
 
32
-
33
  abstract class Follow_Cache_Engine extends Cache_Engine {
34
 
35
- /**
36
  * Crawler instance
37
- */
38
  protected $crawler = NULL;
39
-
40
- /**
41
  * Cache target
42
- */
43
- protected $target_sns = array();
44
 
45
- /**
46
  * migration between http and https
47
- */
48
- protected $scheme_migration_mode = false;
49
 
50
- /**
51
  * excluded keys in scheme migration
52
- */
53
- protected $scheme_migration_exclude_keys = array();
54
 
55
- /**
56
  * load ratio for throttle
57
- */
58
- protected $load_ratio = 0.5;
59
-
60
- /**
61
  * Get and cache data for a given post
62
  *
63
  * @since 0.4.0
64
- */
65
- public function cache( $options = array() ) {
66
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
67
-
68
- $cache_key = $options['cache_key'];
69
- $target_url = $options['target_url'];
70
  $target_sns = $options['target_sns'];
71
  $cache_expiration = $options['cache_expiration'];
72
-
73
- Common_Util::log( '[' . __METHOD__ . '] feed: ' . $target_url );
74
-
75
- $data = $this->crawler->get_data( $target_sns, $target_url );
76
-
77
  Common_Util::log( $data );
78
 
79
- if ( $this->scheme_migration_mode && Common_Util::is_secure_url( $target_url ) ) {
80
- $target_url = Common_Util::get_normal_url( $target_url );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
- $target_sns_migrated = $target_sns;
83
-
84
- foreach ( $this->scheme_migration_exclude_keys as $sns ) {
85
- unset( $target_sns_migrated[$sns] );
86
- }
87
-
88
- Common_Util::log( '[' . __METHOD__ . '] feed: ' . $target_url );
89
-
90
- $migrated_data = $this->crawler->get_data( $target_sns_migrated, $target_url );
 
 
 
 
91
 
92
  Common_Util::log( $migrated_data );
93
 
94
- foreach ( $target_sns_migrated as $sns => $active ) {
95
  if ( $active && isset( $migrated_data[$sns] ) && is_numeric( $migrated_data[$sns] ) && $migrated_data[$sns] > 0 ){
96
- $data[$sns] = $data[$sns] + $migrated_data[$sns];
97
  }
98
  }
99
-
100
- }
101
-
102
- if ( $data ) {
103
-
104
- $throttle = new Sleep_Throttle( $this->load_ratio );
 
 
 
 
 
 
105
 
106
  $throttle->reset();
107
  $throttle->start();
108
-
109
- $result = set_transient( $cache_key, $data, $cache_expiration );
110
-
111
- $throttle->stop();
112
-
113
- $retry_count = 0;
114
-
115
- while ( true ) {
116
-
117
- Common_Util::log( '[' . __METHOD__ . '] set_transient result (' . $cache_key . '): ' . $result );
118
-
119
- if ( $result ) {
120
- break;
121
-
122
  } else {
123
-
124
  if ( $retry_count < $this->retry_limit ) {
125
-
126
- Common_Util::log( '[' . __METHOD__ . '] sleep before set_transient retry (' . $cache_key . '): ' . $throttle->get_sleep_time() . ' sec.' );
127
-
128
- $throttle->sleep();
129
-
130
- ++$retry_count;
131
-
132
- Common_Util::log( '[' . __METHOD__ . '] count of set_transient retry (' . $cache_key . '): ' . $retry_count );
133
-
134
  $throttle->reset();
135
- $throttle->start();
136
-
137
- $result = set_transient( $cache_key, $data, $cache_expiration );
138
-
139
- $throttle->stop();
140
-
141
  } else {
142
  Common_Util::log( '[' . __METHOD__ . '] set_transient result (' . $cache_key . '): retry failed' );
143
  break;
144
  }
145
  }
146
  }
147
-
148
  }
149
-
150
- return $data;
151
- }
152
-
153
  }
154
 
155
- ?>
2
  /*
3
  class-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
6
  Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
10
  */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2016 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
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
  abstract class Follow_Cache_Engine extends 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
+ 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
  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
+ Common_Util::log( $query_parameters[$sns] );
90
+ if ( isset( $query_parameters[$sns]['url'] ) ) {
91
+ $target_sns_url[$sns] = true;
92
+ Common_Util::log( $query_parameters[$sns] );
93
+ if ( 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
+ Common_Util::log( $query_parameters[$sns] );
99
+ if ( Common_Util::is_secure_url( $query_parameters[$sns]['urls'] ) ) {
100
+ $secure_url_flag = true;
101
+ }
102
+ }
103
+ }
104
+ }
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
+
112
+ if ( $this->scheme_migration_mode && $secure_url_flag ) {
113
+
114
+ foreach ( $target_sns_url as $sns => $active ) {
115
+ if ( $active ) {
116
+ if ( isset( $query_parameters[$sns]['url'] ) ) {
117
+ $query_parameters[$sns]['url'] = Common_Util::get_normal_url( $query_parameters[$sns]['url'] );
118
+ } elseif ( isset( $query_parameters[$sns]['urls'] ) ) {
119
+ $query_parameters[$sns]['urls'] = Common_Util::get_normal_url( $query_parameters[$sns]['urls'] );
120
+ }
121
+ }
122
+ }
123
 
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
  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
+ Common_Util::log( $data );
154
+
155
+ if ( $data ) {
156
+ $throttle = new 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
+ 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
+ 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
+ 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
  Common_Util::log( '[' . __METHOD__ . '] set_transient result (' . $cache_key . '): retry failed' );
190
  break;
191
  }
192
  }
193
  }
 
194
  }
195
+
196
+ return $data;
197
+ }
198
+
199
  }
200
 
201
+ ?>
includes/class-follow-crawler.php CHANGED
@@ -10,8 +10,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
  */
11
 
12
  /*
13
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
 
16
  This program is free software; you can redistribute it and/or
17
  modify it under the terms of the GNU General Public License
@@ -26,183 +25,273 @@ GNU General Public License for more details.
26
  You should have received a copy of the GNU General Public License
27
  along with this program; if not, write to the Free Software
28
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
  */
31
 
32
- class Follow_Crawler extends Data_Crawler {
33
-
34
- /**
35
  * Initialization
36
  *
37
  * @since 0.5.1
38
  */
39
- public function initialize( $options = array() ) {
40
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
41
-
42
- //$this->throttle = new Sleep_Throttle( 0.9 );
43
-
44
- if ( isset( $options['crawl_method'] ) ) $this->crawl_method = $options['crawl_method'];
45
- if ( isset( $options['timeout'] ) ) $this->timeout = $options['timeout'];
46
- if ( isset( $options['ssl_verification'] ) ) $this->ssl_verification = $options['ssl_verification'];
47
- if ( isset( $options['crawl_retry'] ) ) $this->crawl_retry = $options['crawl_retry'];
48
- if ( isset( $options['retry_limit'] ) ) $this->retry_limit = $options['retry_limit'];
49
- }
50
-
51
- /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  * Implementation of abstract method. this method gets each share count
53
  *
54
  * @since 0.1.1
55
- */
56
- public function get_data( $target_sns, $url ) {
57
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
58
-
59
- Common_Util::log( '[' . __METHOD__ . '] Feedly' );
60
-
61
- $url = rawurlencode( $url );
62
-
63
- $query_urls = $this->build_query_urls( $target_sns, $url );
64
-
65
- $data = array();
66
-
67
- $throttle = new Sleep_Throttle( 0.9 );
68
-
 
 
 
 
 
 
 
 
69
  $throttle->reset();
70
  $throttle->start();
71
-
72
- if ( $this->crawl_method === SNS_Count_Cache::OPT_COMMON_CRAWLER_METHOD_CURL ) {
73
- $data = Common_Util::multi_remote_get( $query_urls, $this->timeout, $this->ssl_verification, true );
74
  } else {
75
- $data = Common_Util::multi_remote_get( $query_urls, $this->timeout, $this->ssl_verification, false );
76
  }
77
-
78
- $throttle->stop();
79
-
80
- $retry_count = 0;
81
-
82
- while( true ) {
83
-
84
- $target_sns_retry = array();
85
-
86
- $tmp_count = $this->extract_count( $target_sns, $data );
87
-
88
- foreach ( $target_sns as $sns => $active ){
89
- if ( $active ) {
90
- if( $tmp_count[$sns] === -1 ) {
91
- $target_sns_retry[$sns] = true;
92
- }
93
- }
94
  }
95
-
96
- if ( empty( $target_sns_retry ) ) {
97
- break;
98
-
99
  } else {
 
 
 
 
 
 
 
 
100
 
101
- Common_Util::log( '[' . __METHOD__ . '] crawl failure' );
102
- Common_Util::log( $target_sns_retry );
103
-
104
- if ( $retry_count < $this->retry_limit ) {
105
-
106
- Common_Util::log( '[' . __METHOD__ . '] sleep before crawl retry: ' . $throttle->get_sleep_time() . ' sec.' );
107
-
108
- $throttle->sleep();
109
-
110
- ++$retry_count;
111
-
112
- Common_Util::log( '[' . __METHOD__ . '] count of crawl retry: ' . $retry_count );
113
-
114
- $query_urls_retry = $this->build_query_urls( $target_sns_retry, $url );
115
-
116
- $data_retry = array();
117
-
118
- $throttle->reset();
119
  $throttle->start();
120
-
121
- if ( $this->crawl_method === SNS_Count_Cache::OPT_COMMON_CRAWLER_METHOD_CURL ) {
122
- $data_retry = Common_Util::multi_remote_get( $query_urls_retry, $this->timeout, $this->ssl_verification, true );
123
  } else {
124
- $data_retry = Common_Util::multi_remote_get( $query_urls_retry, $this->timeout, $this->ssl_verification, false );
125
  }
126
-
127
- $throttle->stop();
128
-
129
- $data = array_merge( $data, $data_retry );
130
  } else {
131
- Common_Util::log( '[' . __METHOD__ . '] crawling: retry failed' );
132
- break;
133
  }
134
- }
135
  }
136
-
137
- return $this->extract_count( $target_sns, $data );
138
- }
139
-
140
- /**
141
  * build query
142
  *
143
  * @since 0.5.1
144
- */
145
- private function build_query_urls( $target_sns, $url ) {
146
  Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
147
-
148
- $query_urls = array();
149
-
150
- if ( isset( $url ) ) {
151
- if ( isset( $target_sns[SNS_Count_Cache::REF_FOLLOW_FEEDLY] ) && $target_sns[SNS_Count_Cache::REF_FOLLOW_FEEDLY] ) {
152
- $query_urls[SNS_Count_Cache::REF_FOLLOW_FEEDLY] = 'http://cloud.feedly.com/v3/feeds/feed%2F' . $url;
 
 
 
 
 
153
  }
154
- }
155
-
156
- return $query_urls;
157
-
158
- }
159
 
160
- /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  * extract count data from retrieved content
162
  *
163
  * @since 0.5.1
164
  */
165
- private function extract_count( $target_sns, $contents ) {
166
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
167
-
168
- $sns_counts = array();
169
-
170
- $extract_date = date_i18n( 'Y/m/d H:i:s' );
171
-
172
- Common_Util::log( $contents );
173
-
174
- foreach ( $contents as $sns => $content ) {
175
-
176
- if ( $sns == SNS_Count_Cache::REF_FOLLOW_FEEDLY ) {
177
-
178
- if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
179
- $json = json_decode( $content['data'], true );
180
-
181
- if ( isset( $json['subscribers'] ) && is_numeric( $json['subscribers'] ) ) {
182
- $count = (int) $json['subscribers'];
183
- } else {
184
- $count = (int) -1;
185
- }
186
  } else {
187
- $count = (int) -1;
188
  }
189
-
190
- $sns_counts[SNS_Count_Cache::REF_FOLLOW_FEEDLY] = $count;
191
-
192
- }
193
  }
194
 
195
- if ( isset( $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] ) && $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] ) {
196
- $sns_counts[SNS_Count_Cache::REF_CRAWL_DATE] = $extract_date;
197
  } else {
198
- $sns_counts[SNS_Count_Cache::REF_CRAWL_DATE] = '';
199
  }
200
-
201
- return $sns_counts;
202
-
203
- }
204
-
205
-
206
  }
207
 
208
  ?>
10
  */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2016 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
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 Follow_Crawler extends Crawler {
31
+
32
+ /**
33
  * Initialization
34
  *
35
  * @since 0.5.1
36
  */
37
+ public function initialize( $options = array() ) {
38
+ 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] = $this->create_crawl_strategy( $sns );
56
+ }
57
+ }
58
+
59
+ }
60
+
61
+ /**
62
+ * Carete crawl strategy
63
+ *
64
+ * @since 0.9.0
65
+ */
66
+ private function create_crawl_strategy( $sns ) {
67
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
68
+
69
+ switch ( $sns ) {
70
+ case SNS_Count_Cache::REF_FOLLOW_TWITTER:
71
+ Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
72
+ return Follow_Twitter_Strategy::get_instance();
73
+ break;
74
+ case SNS_Count_Cache::REF_FOLLOW_FACEBOOK:
75
+ Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
76
+ return Follow_Facebook_Strategy::get_instance();
77
+ break;
78
+ case SNS_Count_Cache::REF_FOLLOW_FEEDLY:
79
+ Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
80
+ return Follow_Feedly_Strategy::get_instance();
81
+ break;
82
+ case SNS_Count_Cache::REF_FOLLOW_INSTAGRAM:
83
+ Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
84
+ return Follow_Instagram_Strategy::get_instance();
85
+ break;
86
+ case SNS_Count_Cache::REF_FOLLOW_PUSH7:
87
+ Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
88
+ return Follow_Push7_Strategy::get_instance();
89
+ break;
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Check configuration
95
+ *
96
+ * @since 0.9.0
97
+ */
98
+ private function check_configurations( $target_sns ) {
99
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
100
+
101
+ //$checked_target_sns = array();
102
+
103
+ unset( $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] );
104
+
105
+ Common_Util::log( $target_sns );
106
+
107
+ foreach ( $target_sns as $sns => $active ) {
108
+ if ( $active ) {
109
+ $target_sns[$sns] = $this->crawl_strategies[$sns]->check_configuration();
110
+ }
111
+ }
112
+
113
+ $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] = true;
114
+
115
+ return $target_sns;
116
+
117
+ }
118
+
119
+ /**
120
  * Implementation of abstract method. this method gets each share count
121
  *
122
  * @since 0.1.1
123
+ */
124
+ public function get_data( $target_sns, $options ) {
125
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
126
+
127
+ Common_Util::log( $target_sns );
128
+
129
+ $target_sns = $this->check_configurations( $target_sns );
130
+
131
+ Common_Util::log( $target_sns );
132
+
133
+ $query_urls = $this->build_query_urls( $target_sns );
134
+
135
+ Common_Util::log( $query_urls );
136
+
137
+ $query_headers = $this->build_query_headers( $target_sns );
138
+
139
+ Common_Util::log( $query_headers );
140
+
141
+ $data = array();
142
+
143
+ $throttle = new Sleep_Throttle( 0.9 );
144
+
145
  $throttle->reset();
146
  $throttle->start();
147
+
148
+ if ( $this->crawl_method === SNS_Count_Cache::OPT_COMMON_CRAWLER_METHOD_CURL ) {
149
+ $data = Common_Util::multi_remote_get( $query_urls, $query_headers, $this->timeout, $this->ssl_verification, true );
150
  } else {
151
+ $data = Common_Util::multi_remote_get( $query_urls, $query_headers, $this->timeout, $this->ssl_verification, false );
152
  }
153
+
154
+ $throttle->stop();
155
+
156
+ $retry_count = 0;
157
+
158
+ while( true ) {
159
+ $target_sns_retry = array();
160
+
161
+ $tmp_count = $this->extract_count( $target_sns, $data );
162
+
163
+ foreach ( $target_sns as $sns => $active ){
164
+ if ( $active ) {
165
+ if ( $tmp_count[$sns] === -1 ) {
166
+ $target_sns_retry[$sns] = true;
167
+ }
168
+ }
 
169
  }
170
+
171
+ if ( empty( $target_sns_retry ) ) {
172
+ break;
 
173
  } else {
174
+ Common_Util::log( '[' . __METHOD__ . '] crawl failure' );
175
+ Common_Util::log( $target_sns_retry );
176
+
177
+ if ( $retry_count < $this->retry_limit ) {
178
+
179
+ Common_Util::log( '[' . __METHOD__ . '] sleep before crawl retry: ' . $throttle->get_sleep_time() . ' sec.' );
180
+
181
+ $throttle->sleep();
182
 
183
+ ++$retry_count;
184
+
185
+ Common_Util::log( '[' . __METHOD__ . '] count of crawl retry: ' . $retry_count );
186
+
187
+ $query_urls_retry = $this->build_query_urls( $target_sns_retry );
188
+
189
+ $query_headers_retry = $this->build_query_headers( $target_sns_retry );
190
+
191
+ $data_retry = array();
192
+
193
+ $throttle->reset();
 
 
 
 
 
 
 
194
  $throttle->start();
195
+
196
+ if ( $this->crawl_method === SNS_Count_Cache::OPT_COMMON_CRAWLER_METHOD_CURL ) {
197
+ $data_retry = Common_Util::multi_remote_get( $query_urls_retry, $query_headers_retry, $this->timeout, $this->ssl_verification, true );
198
  } else {
199
+ $data_retry = Common_Util::multi_remote_get( $query_urls_retry, $query_headers_retry, $this->timeout, $this->ssl_verification, false );
200
  }
201
+
202
+ $throttle->stop();
203
+
204
+ $data = array_merge( $data, $data_retry );
205
  } else {
206
+ Common_Util::log( '[' . __METHOD__ . '] crawling: retry failed' );
207
+ break;
208
  }
209
+ }
210
  }
211
+
212
+ return $this->extract_count( $target_sns, $data );
213
+ }
214
+
215
+ /**
216
  * build query
217
  *
218
  * @since 0.5.1
219
+ */
220
+ private function build_query_urls( $target_sns ) {
221
  Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
222
+
223
+ $query_urls = array();
224
+
225
+ unset( $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] );
226
+
227
+ Common_Util::log( $target_sns );
228
+
229
+
230
+ foreach ( $target_sns as $sns => $active ) {
231
+ if ( $active ) {
232
+ $query_urls[$sns] = $this->crawl_strategies[$sns]->build_query_url();
233
  }
234
+ }
 
 
 
 
235
 
236
+ return $query_urls;
237
+ }
238
+
239
+ /**
240
+ * build query
241
+ *
242
+ * @since 0.5.1
243
+ */
244
+ private function build_query_headers( $target_sns ) {
245
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
246
+
247
+ $query_headers = array();
248
+
249
+ unset( $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] );
250
+
251
+ Common_Util::log( $target_sns );
252
+
253
+ foreach ( $target_sns as $sns => $active ) {
254
+ if ( $active ) {
255
+ $query_headers[$sns] = $this->crawl_strategies[$sns]->build_header();
256
+ }
257
+ }
258
+
259
+ return $query_headers;
260
+ }
261
+
262
+ /**
263
  * extract count data from retrieved content
264
  *
265
  * @since 0.5.1
266
  */
267
+ private function extract_count( $target_sns, $contents ) {
268
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
269
+
270
+ $sns_counts = array();
271
+
272
+ $extract_date = date_i18n( 'Y/m/d H:i:s' );
273
+
274
+ Common_Util::log( $contents );
275
+
276
+ foreach ( $target_sns as $sns => $active ) {
277
+ if ( $active ) {
278
+ if ( isset( $contents[$sns] ) ) {
279
+ $sns_counts[$sns] = $this->crawl_strategies[$sns]->extract_count( $contents[$sns] );
 
 
 
 
 
 
 
 
280
  } else {
281
+ $sns_counts[$sns] = (int) -1;
282
  }
283
+ }
 
 
 
284
  }
285
 
286
+ if ( isset( $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] ) && $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] ) {
287
+ $sns_counts[SNS_Count_Cache::REF_CRAWL_DATE] = $extract_date;
288
  } else {
289
+ $sns_counts[SNS_Count_Cache::REF_CRAWL_DATE] = '';
290
  }
291
+
292
+ return $sns_counts;
293
+ }
294
+
 
 
295
  }
296
 
297
  ?>
includes/class-follow-facebook-strategy.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ class-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 - 2016 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 Follow_Facebook_Strategy extends 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ /**
115
+ * Check if required paramters are included or not.
116
+ *
117
+ * @since 0.9.0
118
+ */
119
+ public function check_configuration() {
120
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
121
+
122
+ if ( isset( $this->parameters['client_id'] ) && $this->parameters['client_id'] &&
123
+ isset( $this->parameters['client_secret'] ) && $this->parameters['client_secret'] &&
124
+ isset( $this->query_parameters['access_token'] ) && $this->query_parameters['access_token'] &&
125
+ isset( $this->parameters['page_id'] ) && $this->parameters['page_id'] ) {
126
+ return true;
127
+ } else {
128
+ return false;
129
+ }
130
+ }
131
+
132
+ }
includes/class-follow-feedly-strategy.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ class-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 - 2016 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 Follow_Feedly_Strategy extends 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ /**
110
+ * Check if required paramters are included or not.
111
+ *
112
+ * @since 0.9.0
113
+ */
114
+ public function check_configuration() {
115
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
116
+
117
+ if ( isset( $this->query_parameters['url'] ) && $this->query_parameters['url'] ) {
118
+ return true;
119
+ } else {
120
+ return false;
121
+ }
122
+ }
123
+
124
+ }
includes/class-follow-instagram-strategy.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ class-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 - 2016 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 Follow_Instagram_Strategy extends 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ /**
110
+ * Check if required paramters are included or not.
111
+ *
112
+ * @since 0.9.0
113
+ */
114
+ public function check_configuration() {
115
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
116
+
117
+ if ( isset( $this->parameters['client_id'] ) && $this->parameters['client_id'] &&
118
+ isset( $this->parameters['client_secret'] ) && $this->parameters['client_secret'] &&
119
+ isset( $this->query_parameters['access_token'] ) && $this->query_parameters['access_token'] ) {
120
+ return true;
121
+ } else {
122
+ return false;
123
+ }
124
+ }
125
+
126
+ }
includes/class-follow-lazy-cache-engine.php CHANGED
@@ -1,197 +1,181 @@
1
- <?php
2
- /*
3
- class-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
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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
31
-
32
-
33
- class Follow_Lazy_Cache_Engine extends Follow_Cache_Engine {
34
-
35
- /**
36
- * Prefix of cache ID
37
- */
38
- const DEF_TRANSIENT_PREFIX = 'scc_follow_count_';
39
-
40
- /**
41
- * Cron name to schedule cache processing
42
- */
43
- const DEF_PRIME_CRON = 'scc_follow_lazycache_prime';
44
-
45
- /**
46
- * Cron name to execute cache processing
47
- */
48
- const DEF_EXECUTE_CRON = 'scc_follow_lazycache_exec';
49
-
50
- /**
51
- * Schedule name for cache processing
52
- */
53
- const DEF_EVENT_SCHEDULE = 'follow_lazy_cache_event';
54
-
55
- /**
56
- * Schedule description for cache processing
57
- */
58
- const DEF_EVENT_DESCRIPTION = '[SCC] Follow Lazy Cache Interval';
59
-
60
- /**
61
- * Interval cheking and caching target data
62
- */
63
- private $check_interval = 600;
64
-
65
- /**
66
- * Latency suffix
67
- */
68
- private $check_latency = 10;
69
-
70
- /**
71
- * Feed type
72
- */
73
- private $feed_type = '';
74
-
75
- /**
76
- * Initialization
77
- *
78
- * @since 0.1.1
79
- */
80
- public function initialize( $options = array() ) {
81
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
82
-
83
- $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
84
- $this->prime_cron = self::DEF_PRIME_CRON;
85
- $this->execute_cron = self::DEF_EXECUTE_CRON;
86
- $this->event_schedule = self::DEF_EVENT_SCHEDULE;
87
- $this->event_description = self::DEF_EVENT_DESCRIPTION;
88
-
89
- $this->load_ratio = 0.5;
90
-
91
- if ( isset( $options['delegate'] ) ) $this->delegate = $options['delegate'];
92
- if ( isset( $options['crawler'] ) ) $this->crawler = $options['crawler'];
93
- if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
94
- if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
95
- if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
96
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
97
- if ( isset( $options['check_latency'] ) ) $this->check_latency = $options['check_latency'];
98
- if ( isset( $options['scheme_migration_mode'] ) ) $this->scheme_migration_mode = $options['scheme_migration_mode'];
99
- if ( isset( $options['scheme_migration_exclude_keys'] ) ) $this->scheme_migration_exclude_keys = $options['scheme_migration_exclude_keys'];
100
- if ( isset( $options['feed_type'] ) ) $this->feed_type = $options['feed_type'];
101
- if ( isset( $options['cache_retry'] ) ) $this->cache_retry = $options['cache_retry'];
102
- if ( isset( $options['retry_limit'] ) ) $this->retry_limit = $options['retry_limit'];
103
-
104
- add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 0 );
105
-
106
- }
107
-
108
- /**
109
- * Register base schedule for this engine
110
- *
111
- * @since 0.1.0
112
- */
113
- public function register_schedule() {
114
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
115
-
116
- }
117
-
118
- /**
119
- * Schedule data retrieval and cache processing
120
- *
121
- * @since 0.4.0
122
- */
123
- public function prime_cache() {
124
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
125
-
126
- $next_exec_time = time() + $this->check_latency;
127
-
128
- Common_Util::log( '[' . __METHOD__ . '] check_latency: ' . $this->check_latency );
129
- 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
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
141
-
142
- $cache_expiration = $this->get_cache_expiration();
143
-
144
- Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
145
-
146
- $url = get_feed_link( $this->feed_type );
147
-
148
- $transient_id = $this->get_cache_key( 'follow' );
149
-
150
- $options = array(
151
- 'cache_key' => $transient_id,
152
- 'target_url' => $url,
153
- 'target_sns' => $this->target_sns,
154
- 'cache_expiration' => $cache_expiration
155
- );
156
-
157
- // Primary cache
158
- $this->cache( $options );
159
-
160
- // Secondary cache
161
- $this->delegate_cache( $options );
162
- }
163
-
164
- /**
165
- * Get cache expiration based on current number of total post and page
166
- *
167
- * @since 0.4.0
168
- */
169
- protected function get_cache_expiration() {
170
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
171
-
172
- return 3 * $this->check_interval;
173
- }
174
-
175
- /**
176
- * Initialize meta key for ranking
177
- *
178
- * @since 0.3.0
179
- */
180
- public function initialize_cache() {
181
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
182
-
183
- }
184
-
185
- /**
186
- * Clear meta key for ranking
187
- *
188
- * @since 0.3.0
189
- */
190
- public function clear_cache() {
191
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
192
-
193
- }
194
-
195
- }
196
-
197
- ?>
1
+ <?php
2
+ /*
3
+ class-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
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 - 2016 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 Follow_Lazy_Cache_Engine extends Follow_Cache_Engine {
31
+
32
+ /**
33
+ * Prefix of cache ID
34
+ */
35
+ const DEF_TRANSIENT_PREFIX = 'scc_follow_count_';
36
+
37
+ /**
38
+ * Cron name to schedule cache processing
39
+ */
40
+ const DEF_PRIME_CRON = 'scc_follow_lazycache_prime';
41
+
42
+ /**
43
+ * Cron name to execute cache processing
44
+ */
45
+ const DEF_EXECUTE_CRON = 'scc_follow_lazycache_exec';
46
+
47
+ /**
48
+ * Schedule name for cache processing
49
+ */
50
+ const DEF_EVENT_SCHEDULE = 'follow_lazy_cache_event';
51
+
52
+ /**
53
+ * Schedule description for cache processing
54
+ */
55
+ const DEF_EVENT_DESCRIPTION = '[SCC] Follow Lazy Cache Interval';
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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
74
+
75
+ $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
76
+ $this->prime_cron = self::DEF_PRIME_CRON;
77
+ $this->execute_cron = self::DEF_EXECUTE_CRON;
78
+ $this->event_schedule = self::DEF_EVENT_SCHEDULE;
79
+ $this->event_description = self::DEF_EVENT_DESCRIPTION;
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
+ }
97
+
98
+ /**
99
+ * Register base schedule for this engine
100
+ *
101
+ * @since 0.1.0
102
+ */
103
+ public function register_schedule() {
104
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
105
+ }
106
+
107
+ /**
108
+ * Schedule data retrieval and cache processing
109
+ *
110
+ * @since 0.4.0
111
+ */
112
+ public function prime_cache() {
113
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
114
+
115
+ $next_exec_time = time() + $this->check_latency;
116
+
117
+ Common_Util::log( '[' . __METHOD__ . '] check_latency: ' . $this->check_latency );
118
+ Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
119
+
120
+ wp_schedule_single_event( $next_exec_time, $this->execute_cron, array() );
121
+ }
122
+
123
+ /**
124
+ * Get and cache data of each published post
125
+ *
126
+ * @since 0.4.0
127
+ */
128
+ public function execute_cache() {
129
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
130
+
131
+ $cache_expiration = $this->get_cache_expiration();
132
+
133
+ Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
134
+
135
+ $transient_id = $this->get_cache_key( 'follow' );
136
+
137
+ $options = array(
138
+ 'cache_key' => $transient_id,
139
+ 'target_sns' => $this->target_sns,
140
+ 'cache_expiration' => $cache_expiration
141
+ );
142
+
143
+ // Primary cache
144
+ $this->cache( $options );
145
+
146
+ // Secondary cache
147
+ $this->delegate_cache( $options );
148
+ }
149
+
150
+ /**
151
+ * Get cache expiration based on current number of total post and page
152
+ *
153
+ * @since 0.4.0
154
+ */
155
+ protected function get_cache_expiration() {
156
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
157
+
158
+ return 3 * $this->check_interval;
159
+ }
160
+
161
+ /**
162
+ * Initialize meta key for ranking
163
+ *
164
+ * @since 0.3.0
165
+ */
166
+ public function initialize_cache() {
167
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
168
+ }
169
+
170
+ /**
171
+ * Clear meta key for ranking
172
+ *
173
+ * @since 0.3.0
174
+ */
175
+ public function clear_cache() {
176
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
177
+ }
178
+
179
+ }
180
+
181
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-follow-push7-strategy.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ class-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 - 2016 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 Follow_Push7_Strategy extends 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ /**
110
+ * Check if required paramters are included or not.
111
+ *
112
+ * @since 0.9.0
113
+ */
114
+ public function check_configuration() {
115
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
116
+
117
+ if ( isset( $this->parameters['appno'] ) && $this->parameters['appno'] ) {
118
+ return true;
119
+ } else {
120
+ return false;
121
+ }
122
+ }
123
+
124
+ }
includes/class-follow-restore-cache-engine.php ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ class-follow-restore-cache-engine.php
4
+
5
+ Description: This class is a data cache engine whitch restore cache data from second cache.
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 - 2016 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 Follow_Restore_Cache_Engine extends Cache_Engine {
31
+
32
+ /**
33
+ * Prefix of cache ID
34
+ */
35
+ const DEF_TRANSIENT_PREFIX = 'scc_follow_count_';
36
+
37
+ /**
38
+ * Cron name to schedule cache processing
39
+ */
40
+ const DEF_PRIME_CRON = 'scc_follow_restorecache_prime';
41
+
42
+ /**
43
+ * Cron name to execute cache processing
44
+ */
45
+ const DEF_EXECUTE_CRON = 'scc_follow_restorecache_exec';
46
+
47
+ /**
48
+ * Schedule name for cache processing
49
+ */
50
+ const DEF_EVENT_SCHEDULE = 'follow_restore_cache_event';
51
+
52
+ /**
53
+ * Schedule description for cache processing
54
+ */
55
+ const DEF_EVENT_DESCRIPTION = '[SCC] Follow Restore Cache Interval';
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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
74
+
75
+ $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
76
+ $this->prime_cron = self::DEF_PRIME_CRON;
77
+ $this->execute_cron = self::DEF_EXECUTE_CRON;
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
+ }
89
+
90
+ /**
91
+ * Register base schedule for this engine
92
+ *
93
+ * @since 0.1.0
94
+ */
95
+ public function register_schedule() {
96
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
97
+ }
98
+
99
+ /**
100
+ * Schedule data retrieval and cache processing
101
+ *
102
+ * @since 0.4.0
103
+ */
104
+ public function prime_cache() {
105
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
106
+
107
+ $next_exec_time = time() + $this->check_latency;
108
+
109
+ Common_Util::log( '[' . __METHOD__ . '] check_latency: ' . $this->check_latency );
110
+ Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
111
+
112
+ wp_schedule_single_event( $next_exec_time, $this->execute_cron, array() );
113
+ }
114
+
115
+ /**
116
+ * Get and cache data of each published post
117
+ *
118
+ * @since 0.4.0
119
+ */
120
+ public function execute_cache() {
121
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
122
+
123
+ $cache_expiration = $this->get_cache_expiration();
124
+
125
+ Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
126
+
127
+ $transient_id = $this->get_cache_key( 'follow' );
128
+
129
+ $options = array(
130
+ 'cache_key' => $transient_id,
131
+ 'target_sns' => $this->target_sns,
132
+ 'cache_expiration' => $cache_expiration
133
+ );
134
+
135
+ $this->cache( $options );
136
+ }
137
+
138
+ /**
139
+ * Get and cache data for a given post
140
+ *
141
+ * @since 0.1.1
142
+ */
143
+ public function cache( $options = array() ) {
144
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
145
+
146
+ $transient_id = $options['cache_key'];
147
+ $target_sns = $options['target_sns'];
148
+ $cache_expiration = $options['cache_expiration'];
149
+
150
+ $sns_followers = array();
151
+
152
+ $option_key = $this->get_cache_key( 'follow' );
153
+
154
+ if ( false !== ( $sns_followers = get_option( $option_key ) ) ) {
155
+ } else {
156
+ foreach ( $this->share_base_cache_target as $sns => $active ) {
157
+ if ( $active ) {
158
+ $sns_followers[$sns] = (int) -1;
159
+ }
160
+ }
161
+ }
162
+
163
+ $result = set_transient( $transient_id, $sns_followers, $cache_expiration );
164
+ }
165
+
166
+ /**
167
+ * Get cache expiration based on current number of total post and page
168
+ *
169
+ * @since 0.4.0
170
+ */
171
+ protected function get_cache_expiration() {
172
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
173
+
174
+ return 3 * $this->check_interval;
175
+ }
176
+
177
+ /**
178
+ * Initialize meta key for ranking
179
+ *
180
+ * @since 0.3.0
181
+ */
182
+ public function initialize_cache() {
183
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
184
+ }
185
+
186
+ /**
187
+ * Clear meta key for ranking
188
+ *
189
+ * @since 0.3.0
190
+ */
191
+ public function clear_cache() {
192
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
193
+ }
194
+
195
+ }
196
+
197
+ ?>
includes/class-follow-second-cache-engine.php CHANGED
@@ -1,238 +1,228 @@
1
- <?php
2
- /*
3
- class-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
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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
31
-
32
-
33
- class Follow_Second_Cache_Engine extends Cache_Engine {
34
-
35
- /**
36
- * Prefix of cache ID
37
- */
38
- const DEF_TRANSIENT_PREFIX = 'scc_follow_count_';
39
-
40
- /**
41
- * Cron name to schedule cache processing
42
- */
43
- const DEF_PRIME_CRON = 'scc_follow_2ndcache_prime';
44
-
45
- /**
46
- * Cron name to execute cache processing
47
- */
48
- const DEF_EXECUTE_CRON = 'scc_follow_2ndcache_exec';
49
-
50
- /**
51
- * Schedule name for cache processing
52
- */
53
- const DEF_EVENT_SCHEDULE = 'follow_second_cache_event';
54
-
55
- /**
56
- * Schedule description for cache processing
57
- */
58
- const DEF_EVENT_DESCRIPTION = '[SCC] Follow Second Cache Interval';
59
- /**
60
- * Interval cheking and caching target data
61
- */
62
- private $check_interval = 600;
63
-
64
- /**
65
- * Prefix of cache ID
66
- */
67
- private $meta_key_prefix = 'scc_follow_count_';
68
-
69
- /**
70
- * Cache target
71
- */
72
- private $target_sns = array();
73
-
74
- /**
75
- * Initialization
76
- *
77
- * @since 0.1.1
78
- */
79
- public function initialize( $options = array() ) {
80
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
81
-
82
- $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
83
- $this->prime_cron = self::DEF_PRIME_CRON;
84
- $this->execute_cron = self::DEF_EXECUTE_CRON;
85
- $this->event_schedule = self::DEF_EVENT_SCHEDULE;
86
- $this->event_description = self::DEF_EVENT_DESCRIPTION;
87
-
88
- if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
89
- if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
90
- if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
91
- if ( isset( $options['prime_cron'] ) ) $this->prime_cron = $options['prime_cron'];
92
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
93
- if ( isset( $options['event_schedule'] ) ) $this->event_schedule = $options['event_schedule'];
94
- if ( isset( $options['event_description'] ) ) $this->event_description = $options['event_description'];
95
- if ( isset( $options['meta_key_prefix'] ) ) $this->meta_key_prefix = $options['meta_key_prefix'];
96
-
97
- add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
98
- add_action( $this->prime_cron, array( $this, 'prime_cache' ) );
99
- add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 0 );
100
-
101
- }
102
-
103
- /**
104
- * Register event schedule for this engine
105
- *
106
- * @since 0.1.0
107
- */
108
- public function schedule_check_interval( $schedules ) {
109
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
110
-
111
- $schedules[$this->event_schedule] = array(
112
- 'interval' => $this->check_interval,
113
- 'display' => $this->event_description
114
- );
115
-
116
- return $schedules;
117
- }
118
-
119
- /**
120
- * Schedule data retrieval and cache processing
121
- *
122
- * @since 0.3.0
123
- */
124
- public function prime_cache() {
125
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
126
-
127
- $next_exec_time = time() + $this->check_interval;
128
-
129
- Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
130
- Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
131
-
132
- wp_schedule_single_event( $next_exec_time, $this->execute_cron );
133
- }
134
-
135
- /**
136
- * Get and cache data of each published post and page
137
- *
138
- * @since 0.4.0
139
- */
140
- public function execute_cache() {
141
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
142
-
143
- $url = get_feed_link();
144
-
145
- $transient_id = $this->get_cache_key( 'follow' );
146
-
147
- $options = array(
148
- 'cache_key' => $transient_id,
149
- 'target_url' => $url,
150
- 'target_sns' => $this->target_sns,
151
- );
152
-
153
- $this->cache( $options );
154
-
155
- }
156
-
157
- /**
158
- * Get and cache data for a given post
159
- *
160
- * @since 0.1.1
161
- */
162
- public function cache( $options = array() ) {
163
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
164
-
165
- $transient_id = $options['cache_key'];
166
- $target_url = $options['target_url'];
167
- $target_sns = $options['target_sns'];
168
-
169
- if ( false !== ( $sns_followers = get_transient( $transient_id ) ) ) {
170
-
171
- $option_key = $this->get_cache_key( 'follow' );
172
-
173
- update_option( $option_key, $sns_followers );
174
-
175
- }
176
-
177
- }
178
-
179
- /**
180
- * Get cache expiration based on current number of total post and page
181
- *
182
- * @since 0.2.0
183
- */
184
- protected function get_cache_expiration() {
185
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
186
-
187
- return 0;
188
- }
189
-
190
- /**
191
- * Initialize meta key for ranking
192
- *
193
- * @since 0.3.0
194
- */
195
- public function initialize_cache() {
196
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
197
-
198
- $option_key = $this->get_cache_key( 'follow' );
199
-
200
- $sns_followers = array();
201
-
202
- foreach ( $this->target_sns as $sns => $active ) {
203
- if ( $active ) {
204
- $sns_followers[$sns] = (int) -1;
205
- }
206
- }
207
-
208
- update_option( $option_key, $sns_followers );
209
-
210
- }
211
-
212
- /**
213
- * Clear meta key for ranking
214
- *
215
- * @since 0.3.0
216
- */
217
- public function clear_cache() {
218
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
219
-
220
- $option_key = $this->get_cache_key( 'follow' );
221
-
222
- delete_option( $option_key );
223
-
224
- // Compatibility for old version
225
- foreach ( $this->target_sns as $sns => $active ) {
226
-
227
- $option_key = $this->get_cache_key( $sns );
228
-
229
- if ( $active ) {
230
- delete_option( $option_key );
231
- }
232
- }
233
-
234
- }
235
-
236
- }
237
-
238
- ?>
1
+ <?php
2
+ /*
3
+ class-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
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 - 2016 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 Follow_Second_Cache_Engine extends Cache_Engine {
31
+
32
+ /**
33
+ * Prefix of cache ID
34
+ */
35
+ const DEF_TRANSIENT_PREFIX = 'scc_follow_count_';
36
+
37
+ /**
38
+ * Cron name to schedule cache processing
39
+ */
40
+ const DEF_PRIME_CRON = 'scc_follow_2ndcache_prime';
41
+
42
+ /**
43
+ * Cron name to execute cache processing
44
+ */
45
+ const DEF_EXECUTE_CRON = 'scc_follow_2ndcache_exec';
46
+
47
+ /**
48
+ * Schedule name for cache processing
49
+ */
50
+ const DEF_EVENT_SCHEDULE = 'follow_second_cache_event';
51
+
52
+ /**
53
+ * Schedule description for cache processing
54
+ */
55
+ const DEF_EVENT_DESCRIPTION = '[SCC] Follow Second Cache Interval';
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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
79
+
80
+ $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
81
+ $this->prime_cron = self::DEF_PRIME_CRON;
82
+ $this->execute_cron = self::DEF_EXECUTE_CRON;
83
+ $this->event_schedule = self::DEF_EVENT_SCHEDULE;
84
+ $this->event_description = self::DEF_EVENT_DESCRIPTION;
85
+
86
+ if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
87
+ if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
88
+ if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
89
+ if ( isset( $options['prime_cron'] ) ) $this->prime_cron = $options['prime_cron'];
90
+ if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
91
+ if ( isset( $options['event_schedule'] ) ) $this->event_schedule = $options['event_schedule'];
92
+ if ( isset( $options['event_description'] ) ) $this->event_description = $options['event_description'];
93
+ if ( isset( $options['meta_key_prefix'] ) ) $this->meta_key_prefix = $options['meta_key_prefix'];
94
+
95
+ add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
96
+ add_action( $this->prime_cron, array( $this, 'prime_cache' ) );
97
+ add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 0 );
98
+ }
99
+
100
+ /**
101
+ * Register event schedule for this engine
102
+ *
103
+ * @since 0.1.0
104
+ */
105
+ public function schedule_check_interval( $schedules ) {
106
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
107
+
108
+ $schedules[$this->event_schedule] = array(
109
+ 'interval' => $this->check_interval,
110
+ 'display' => $this->event_description
111
+ );
112
+
113
+ return $schedules;
114
+ }
115
+
116
+ /**
117
+ * Schedule data retrieval and cache processing
118
+ *
119
+ * @since 0.3.0
120
+ */
121
+ public function prime_cache() {
122
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
123
+
124
+ $next_exec_time = time() + $this->check_interval;
125
+
126
+ Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
127
+ Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
128
+
129
+ wp_schedule_single_event( $next_exec_time, $this->execute_cron );
130
+ }
131
+
132
+ /**
133
+ * Get and cache data of each published post and page
134
+ *
135
+ * @since 0.4.0
136
+ */
137
+ public function execute_cache() {
138
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
139
+
140
+ $url = get_feed_link();
141
+
142
+ $transient_id = $this->get_cache_key( 'follow' );
143
+
144
+ $options = array(
145
+ 'cache_key' => $transient_id,
146
+ 'target_sns' => $this->target_sns,
147
+ );
148
+
149
+ $this->cache( $options );
150
+ }
151
+
152
+ /**
153
+ * Get and cache data for a given post
154
+ *
155
+ * @since 0.1.1
156
+ */
157
+ public function cache( $options = array() ) {
158
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
159
+
160
+ $transient_id = $options['cache_key'];
161
+ $target_sns = $options['target_sns'];
162
+
163
+ if ( false !== ( $sns_followers = get_transient( $transient_id ) ) ) {
164
+
165
+ $option_key = $this->get_cache_key( 'follow' );
166
+
167
+ update_option( $option_key, $sns_followers );
168
+ }
169
+ }
170
+
171
+ /**
172
+ * Get cache expiration based on current number of total post and page
173
+ *
174
+ * @since 0.2.0
175
+ */
176
+ protected function get_cache_expiration() {
177
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
178
+
179
+ return 0;
180
+ }
181
+
182
+ /**
183
+ * Initialize meta key for ranking
184
+ *
185
+ * @since 0.3.0
186
+ */
187
+ public function initialize_cache() {
188
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
189
+
190
+ $option_key = $this->get_cache_key( 'follow' );
191
+
192
+ $sns_followers = array();
193
+
194
+ foreach ( $this->target_sns as $sns => $active ) {
195
+ if ( $active ) {
196
+ $sns_followers[$sns] = (int) -1;
197
+ }
198
+ }
199
+
200
+ update_option( $option_key, $sns_followers );
201
+ }
202
+
203
+ /**
204
+ * Clear meta key for ranking
205
+ *
206
+ * @since 0.3.0
207
+ */
208
+ public function clear_cache() {
209
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
210
+
211
+ $option_key = $this->get_cache_key( 'follow' );
212
+
213
+ delete_option( $option_key );
214
+
215
+ // Compatibility for old version
216
+ foreach ( $this->target_sns as $sns => $active ) {
217
+
218
+ $option_key = $this->get_cache_key( $sns );
219
+
220
+ if ( $active ) {
221
+ delete_option( $option_key );
222
+ }
223
+ }
224
+ }
225
+
226
+ }
227
+
228
+ ?>
 
 
 
 
 
 
 
 
 
 
includes/class-follow-twitter-strategy.php ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ class-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 - 2016 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 Follow_Twitter_Strategy extends 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
+ /**
39
+ * Class constarctor
40
+ * Hook onto all of the actions and filters needed by the plugin.
41
+ *
42
+ */
43
+ protected function __construct() {
44
+ Common_Util::log('[' . __METHOD__ . '] (line='. __LINE__ . ')');
45
+
46
+ $this->method = 'GET';
47
+ }
48
+
49
+ /**
50
+ * Initialization
51
+ *
52
+ * @since 0.9.0
53
+ */
54
+ public function initialize( $options = array() ) {
55
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
56
+
57
+ if ( isset( $options['url'] ) ) $this->url = $options['url'];
58
+ if ( isset( $options['method'] ) ) $this->method = $options['method'];
59
+ if ( isset( $options['parameters'] ) ) $this->parameters = $options['parameters'];
60
+ }
61
+
62
+ /**
63
+ * Build header
64
+ *
65
+ * @since 0.9.0
66
+ */
67
+ public function build_header() {
68
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
69
+
70
+ $headers = array();
71
+
72
+ /*
73
+ // vesion using user auth
74
+ $oauth_parameters = array(
75
+ 'oauth_consumer_key' => $this->parameters['consumer_key'],
76
+ 'oauth_token' => $this->parameters['access_token'],
77
+ 'oauth_nonce' => microtime(),
78
+ 'oauth_signature_method' => 'HMAC-SHA1',
79
+ 'oauth_timestamp' => time(),
80
+ 'oauth_version' => '1.0'
81
+ );
82
+
83
+ $signature_key = rawurlencode( $this->parameters['consumer_secret'] ) . '&' . rawurlencode( $this->parameters['access_token_secret'] );
84
+
85
+ $oauth_parameters = array_merge( $oauth_parameters, $this->query_parameters );
86
+
87
+ ksort( $oauth_parameters );
88
+
89
+ $signature_parameters = str_replace( array( '+' , '%7E' ) , array( '%20' , '~' ) , http_build_query( $oauth_parameters , '' , '&' ) );
90
+
91
+ $signature_data = rawurlencode( $this->method ) . '&' . rawurlencode( self::DEF_BASE_URL ) . '&' . rawurlencode( $signature_parameters );
92
+
93
+ $signature = base64_encode( hash_hmac( 'sha1' , $signature_data , $signature_key , true ) );
94
+
95
+ $oauth_parameters['oauth_signature'] = $signature;
96
+
97
+ $header_parameters = http_build_query( $oauth_parameters, '', ',' );
98
+
99
+ $headers['Authorization'] = 'OAuth ' . $header_parameters;
100
+ */
101
+
102
+ //version using application-only auth
103
+ $headers['Authorization'] = 'Bearer ' . $this->parameters['bearer_token'];
104
+
105
+ return $headers;
106
+ }
107
+
108
+ /**
109
+ * Build query url
110
+ *
111
+ * @since 0.9.0
112
+ */
113
+ public function build_query_url() {
114
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
115
+
116
+ $url = self::DEF_BASE_URL . '?' . http_build_query( $this->query_parameters , '' , '&' );
117
+
118
+ return $url;
119
+ }
120
+
121
+ /**
122
+ * Extract count
123
+ *
124
+ * @since 0.9.0
125
+ */
126
+ public function extract_count( $content ) {
127
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
128
+
129
+ $count = (int) -1;
130
+
131
+ if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
132
+ $json = json_decode( $content['data'], true );
133
+
134
+ if ( isset( $json['followers_count'] ) && is_numeric( $json['followers_count'] ) ) {
135
+ $count = (int) $json['followers_count'];
136
+ } else {
137
+ $count = (int) -1;
138
+ }
139
+ } else {
140
+ $count = (int) -1;
141
+ }
142
+
143
+ return $count;
144
+ }
145
+
146
+ /**
147
+ * Check if required paramters are included or not.
148
+ *
149
+ * @since 0.9.0
150
+ */
151
+ public function check_configuration() {
152
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
153
+
154
+ /*
155
+ // vesion using user auth
156
+ if ( isset( $this->query_parameters['screen_name'] ) && $this->query_parameters['screen_name'] &&
157
+ isset( $this->parameters['consumer_key'] ) && $this->parameters['consumer_key'] &&
158
+ isset( $this->parameters['consumer_secret'] ) && $this->parameters['consumer_secret'] &&
159
+ isset( $this->parameters['access_token'] ) && $this->parameters['access_token'] &&
160
+ isset( $this->parameters['access_token_secret'] ) && $this->parameters['access_token_secret']
161
+ ) {
162
+ return true;
163
+ } else {
164
+ return false;
165
+ }
166
+ */
167
+
168
+ //version using application-only auth
169
+ if ( isset( $this->query_parameters['screen_name'] ) && $this->query_parameters['screen_name'] &&
170
+ isset( $this->parameters['consumer_key'] ) && $this->parameters['consumer_key'] &&
171
+ isset( $this->parameters['consumer_secret'] ) && $this->parameters['consumer_secret'] &&
172
+ isset( $this->parameters['bearer_token'] ) && $this->parameters['bearer_token']
173
+ ) {
174
+ return true;
175
+ } else {
176
+ return false;
177
+ }
178
+
179
+ }
180
+
181
+ }
includes/class-mcrypt.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Mcrypt {
3
+
4
+ private $td;
5
+ private $iv_size;
6
+ private $algorithm;
7
+ private $mode;
8
+ private $init = false;
9
+
10
+ function __construct( $algorithm = 'blowfish', $mode = 'ecb' ) {
11
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
12
+ $this->algorithm = $algorithm;
13
+ $this->mode = $mode;
14
+ $this->td = mcrypt_module_open( $this->algorithm, '', $this->mode, '' );
15
+ $this->iv_size = mcrypt_enc_get_iv_size( $this->td );
16
+ }
17
+
18
+ function __destruct(){
19
+ if ( $this->init ) mcrypt_generic_deinit( $this->td );
20
+ mcrypt_module_close( $this->td );
21
+ }
22
+
23
+ private function init( $pass, $iv = null ) {
24
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
25
+ if ( is_null( $iv ) ) {
26
+ $iv = mcrypt_create_iv( $this->iv_size, MCRYPT_DEV_RANDOM );
27
+ } else {
28
+ $iv = base64_decode( $iv );
29
+ }
30
+
31
+ if ( $this->iv_size !== strlen( $iv ) ) {
32
+ throw new Exception( 'Incorrect IV size.' );
33
+ }
34
+
35
+ $key = substr( md5( $pass ), 0, mcrypt_enc_get_key_size( $this->td ) );
36
+ mcrypt_generic_init( $this->td, $key, $iv );
37
+ $this->init = true;
38
+ }
39
+
40
+ public function encrypt( $str, $pass, $iv = null ) {
41
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
42
+ $iv = $this->init( $pass, $iv );
43
+ Common_Util::log( '[' . __METHOD__ . '] iv' );
44
+ $encrypted = mcrypt_generic( $this->td, $str );
45
+ return base64_encode( $encrypted );
46
+ }
47
+
48
+ public function decrypt( $str, $pass, $iv = null ) {
49
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
50
+ $iv = $this->init( $pass, $iv );
51
+ Common_Util::log( '[' . __METHOD__ . '] iv' );
52
+ $str = base64_decode( $str );
53
+ $decrypted = mdecrypt_generic( $this->td, $str );
54
+ Common_Util::log( '[' . __METHOD__ . '] decrypted: ' . $decrypted );
55
+ return $decrypted;
56
+ }
57
+
58
+ public function create_iv() {
59
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
60
+ $iv = mcrypt_create_iv( $this->iv_size, MCRYPT_DEV_RANDOM );
61
+ return base64_encode( $iv );
62
+ }
63
+ }
64
+
65
+ ?>
includes/class-share-analytical-engine.php CHANGED
@@ -1,667 +1,580 @@
1
- <?php
2
- /*
3
- class-share-analytical-engine.php
4
-
5
- Description: This class is a data analytical engine.
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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
31
-
32
-
33
- class Share_Analytical_Engine extends Analytical_Engine {
34
-
35
- /**
36
- * Prefix of cache ID
37
- */
38
- const DEF_TRANSIENT_PREFIX = 'scc_share_count_';
39
-
40
- /**
41
- * Prefix of cache ID
42
- */
43
- const DEF_BASE_PREFIX = 'scc_share_base_';
44
-
45
- /**
46
- * Prefix of cache ID
47
- */
48
- const DEF_DELTA_PREFIX = 'scc_share_delta_';
49
-
50
- /**
51
- * Cron name to schedule cache processing
52
- */
53
- const DEF_PRIME_CRON = 'scc_share_updatebase_prime';
54
-
55
- /**
56
- * Cron name to execute cache processing
57
- */
58
- const DEF_EXECUTE_CRON = 'scc_share_updatebase_exec';
59
-
60
- /**
61
- * Schedule name for cache processing
62
- */
63
- const DEF_EVENT_SCHEDULE = 'share_update_base_event';
64
-
65
- /**
66
- * Schedule description for cache processing
67
- */
68
- const DEF_EVENT_DESCRIPTION = '[SCC] Share Update Base Interval';
69
-
70
- /**
71
- * Interval cheking and caching target data
72
- */
73
- private $check_interval = 600;
74
-
75
- /**
76
- * Offset suffix
77
- */
78
- private $base_schedule = '* * * 0 0';
79
-
80
- /**
81
- * Base directory
82
- */
83
- private $base_dir = NULL;
84
-
85
- /**
86
- * Crawl date key
87
- */
88
- private $crawl_date_key = NULL;
89
-
90
- /**
91
- * Initialization
92
- *
93
- * @since 0.1.1
94
- */
95
- public function initialize( $options = array() ) {
96
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
97
-
98
- $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
99
- $this->base_prefix = self::DEF_BASE_PREFIX;
100
- $this->delta_prefix = self::DEF_DELTA_PREFIX;
101
- $this->prime_cron = self::DEF_PRIME_CRON;
102
- $this->execute_cron = self::DEF_EXECUTE_CRON;
103
- $this->event_schedule = self::DEF_EVENT_SCHEDULE;
104
- $this->event_description = self::DEF_EVENT_DESCRIPTION;
105
- $this->base_dir = WP_PLUGIN_DIR . '/sns-count-cache/data/';
106
-
107
- if ( isset( $options['delegate'] ) ) $this->delegate = $options['delegate'];
108
- if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
109
- if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
110
- if ( isset( $options['base_schedule'] ) ) $this->base_schedule = $options['base_schedule'];
111
- if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
112
- if ( isset( $options['base_prefix'] ) ) $this->base_prefix = $options['base_prefix'];
113
- if ( isset( $options['delta_prefix'] ) ) $this->delta_prefix = $options['delta_prefix'];
114
- if ( isset( $options['prime_cron'] ) ) $this->prime_cron = $options['prime_cron'];
115
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
116
- if ( isset( $options['post_types'] ) ) $this->post_types = $options['post_types'];
117
- if ( isset( $options['crawl_date_key'] ) ) $this->crawl_date_key = $options['crawl_date_key'];
118
-
119
- add_action( $this->prime_cron, array( $this, 'prime_base' ) );
120
- add_action( $this->execute_cron, array( $this, 'execute_base' ), 10, 1 );
121
- add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
122
- }
123
-
124
- /**
125
- * Register event schedule for this engine
126
- *
127
- * @since 0.1.0
128
- */
129
- public function schedule_check_interval( $schedules ) {
130
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
131
-
132
- $schedules[$this->event_schedule] = array(
133
- 'interval' => $this->check_interval,
134
- 'display' => $this->event_description
135
- );
136
-
137
- return $schedules;
138
- }
139
-
140
- /**
141
- * Schedule data retrieval and cache processing
142
- *
143
- * @since 0.1.0
144
- */
145
- public function prime_base() {
146
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
147
-
148
- $next_exec_time = WP_Cron_Util::next_exec_time( $this->base_schedule );
149
-
150
- Common_Util::log( '[' . __METHOD__ . '] next_exec_time (timesatamp): ' . $next_exec_time );
151
- Common_Util::log( '[' . __METHOD__ . '] next_exec_time (date): ' . date_i18n( 'Y/m/d H:i:s', $next_exec_time ) );
152
-
153
-
154
- if( ! WP_Cron_Util::is_scheduled_hook( $this->execute_cron ) ) {
155
- wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( Common_Util::short_hash( $next_exec_time ) ) );
156
- }
157
- }
158
-
159
- /**
160
- * Get and cache data of each published post and page
161
- *
162
- * @since 0.1.0
163
- */
164
- public function execute_base( $hash ) {
165
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
166
-
167
- $current_date = date_i18n( 'Y/m/d H:i:s' );
168
-
169
- if( file_exists( $this->base_dir ) ) {
170
-
171
- $base_file = $this->base_dir . $this->get_base_key( 'home' );
172
-
173
- if ( ! file_exists( $base_file ) ) {
174
-
175
- if ( touch( $base_file ) ) {
176
- Common_Util::log( '[' . __METHOD__ . '] file creation succeeded: ' . $base_file );
177
- } else {
178
- Common_Util::log( '[' . __METHOD__ . '] file creation failed: ' . $base_file );
179
- }
180
- }
181
-
182
- if ( file_exists( $base_file ) ) {
183
- Common_Util::log( '[' . __METHOD__ . '] file exists: ' . $base_file );
184
-
185
- $option_key = $this->get_cache_key( 'home' );
186
-
187
- if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
188
-
189
- foreach ( $this->target_sns as $sns => $active ) {
190
-
191
- if ( $active ) {
192
- if ( $sns !== $this->crawl_date_key ) {
193
- if ( ! isset( $sns_counts[$sns] ) || $sns_counts[$sns] < 0 ) {
194
- $sns_counts[$sns] = (int) -1;
195
- }
196
- } else {
197
- if ( ! isset( $sns_counts[$sns] ) ) {
198
- $sns_counts[$sns] = '';
199
- }
200
- }
201
- }
202
- }
203
-
204
- if ( ! in_array( -1, $sns_counts, true ) ) {
205
-
206
- $data = serialize( $sns_counts );
207
-
208
- $fp = fopen( $base_file, 'w' );
209
-
210
- if ( fwrite( $fp, $data ) ) {
211
- Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ');
212
- } else {
213
- Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ');
214
- }
215
-
216
- if ( fclose( $fp ) ) {
217
- Common_Util::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
218
- } else {
219
- Common_Util::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
220
- }
221
- }
222
-
223
- }
224
-
225
- }
226
-
227
- $query_args = array(
228
- 'post_type' => $this->post_types,
229
- 'post_status' => 'publish',
230
- 'nopaging' => true,
231
- 'update_post_term_cache' => false,
232
- 'update_post_meta_cache' => false
233
- );
234
-
235
- $posts_query = new WP_Query( $query_args );
236
-
237
- if ( $posts_query->have_posts() ) {
238
- while ( $posts_query->have_posts() ) {
239
- $posts_query->the_post();
240
-
241
- $post_id = get_the_ID();
242
-
243
- $base_file = $this->base_dir . $this->get_base_key( $post_id );
244
-
245
- if ( ! file_exists( $base_file ) ) {
246
-
247
- if ( touch( $base_file ) ) {
248
- Common_Util::log( '[' . __METHOD__ . '] export file creation succeeded: ' . $base_file );
249
- } else {
250
- Common_Util::log( '[' . __METHOD__ . '] export file creation failed: ' . $base_file );
251
- }
252
- }
253
-
254
- if ( file_exists( $base_file ) ) {
255
-
256
- $sns_counts = array();
257
-
258
- foreach ( $this->target_sns as $sns => $active ) {
259
-
260
- if ( $active ) {
261
-
262
- if ( $sns !== $this->crawl_date_key ) {
263
-
264
- $meta_key = $this->get_cache_key( $sns );
265
-
266
- $sns_count = get_post_meta( $post_id, $meta_key, true );
267
-
268
- if ( isset( $sns_count ) && $sns_count !== '' && $sns_count >= 0 ) {
269
- $sns_counts[$sns] = (int) $sns_count;
270
- } else {
271
- $sns_counts[$sns] = (int) -1;
272
- }
273
- } else {
274
-
275
- $meta_key = $this->get_cache_key( $sns );
276
-
277
- $sns_count = get_post_meta( $post_id, $meta_key, true );
278
-
279
- if ( isset( $sns_count ) && $sns_count !== '' ) {
280
- $sns_counts[$sns] = $sns_count;
281
- } else {
282
- $sns_counts[$sns] = '';
283
- }
284
-
285
- }
286
- }
287
- }
288
-
289
- if ( ! in_array( -1, $sns_counts, true ) ) {
290
-
291
- $data = serialize( $sns_counts );
292
-
293
- $fp = fopen( $base_file, 'w' );
294
-
295
- if ( fwrite( $fp, $data ) ) {
296
- Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ' );
297
- } else {
298
- Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ' );
299
- }
300
-
301
- if ( fclose( $fp ) ) {
302
- Common_Util::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
303
- } else {
304
- Common_Util::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
305
- }
306
- }
307
- }
308
- }
309
- }
310
- wp_reset_postdata();
311
- }
312
-
313
- }
314
-
315
- /**
316
- * Initialize meta key for ranking
317
- *
318
- * @since 0.6.1
319
- */
320
- public function analyze( $options = array() ) {
321
-
322
- $transient_id = $options['cache_key'];
323
- $target_sns = $options['target_sns'];
324
- $post_id = $options['post_id'];
325
-
326
- $base_file = $this->base_dir . $this->get_base_key( $post_id );
327
-
328
- $sns_counts = array();
329
- $sns_base_counts = array();
330
-
331
- if ( file_exists( $base_file ) ) {
332
-
333
- $fp = fopen( $base_file, 'r' );
334
-
335
- $data = fread( $fp, filesize( $base_file ) );
336
-
337
- if ( fclose( $fp ) ) {
338
- Common_Util::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
339
- } else {
340
- Common_Util::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
341
- }
342
-
343
- $sns_base_counts = unserialize( $data );
344
-
345
- } else {
346
- // if there is no base file.
347
-
348
- if ( touch( $base_file ) ) {
349
- Common_Util::log( '[' . __METHOD__ . '] file creation succeeded: ' . $base_file );
350
- } else {
351
- Common_Util::log( '[' . __METHOD__ . '] file creation failed: ' . $base_file );
352
- }
353
-
354
- if ( file_exists( $base_file ) ) {
355
-
356
- $sns_counts = array();
357
-
358
- if ( $post_id !== 'home' ) {
359
-
360
- foreach ( $this->target_sns as $sns => $active ) {
361
-
362
- if ( $active ) {
363
-
364
- if ( $sns !== $this->crawl_date_key ) {
365
-
366
- $meta_key = $this->get_cache_key( $sns );
367
-
368
- $sns_count = get_post_meta( $post_id, $meta_key, true );
369
-
370
- if ( isset( $sns_count ) && $sns_count !== '' && $sns_count >= 0 ) {
371
- $sns_counts[$sns] = (int) $sns_count;
372
- } else {
373
- $sns_count[$sns] = (int) -1;
374
- }
375
- } else {
376
-
377
- $meta_key = $this->get_cache_key( $sns );
378
-
379
- $sns_count = get_post_meta( $post_id, $meta_key, true );
380
-
381
- if ( isset( $sns_count ) && $sns_count !== '' ) {
382
- $sns_counts[$sns] = $sns_count;
383
- } else {
384
- $sns_counts[$sns] = '';
385
- }
386
-
387
- }
388
- }
389
-
390
- }
391
- } else {
392
- $option_key = $this->get_cache_key( 'home' );
393
-
394
- if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
395
-
396
- foreach ( $this->target_sns as $sns => $active ) {
397
-
398
- if ( $active ) {
399
- if ( $sns !== $this->crawl_date_key ) {
400
- if ( ! isset( $sns_counts[$sns] ) || $sns_counts[$sns] < 0 ) {
401
- $sns_counts[$sns] = (int) -1;
402
- }
403
- } else {
404
- if ( ! isset( $sns_counts[$sns] ) ) {
405
- $sns_counts[$sns] = '';
406
- }
407
- }
408
- }
409
- }
410
- }
411
-
412
- }
413
-
414
- if ( ! in_array( -1, $sns_counts, true ) ) {
415
-
416
- $data = serialize( $sns_counts );
417
-
418
- $fp = fopen( $base_file, 'w' );
419
-
420
- if ( fwrite( $fp, $data ) ) {
421
- Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ' );
422
- } else {
423
- Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ' );
424
- }
425
-
426
- if ( fclose( $fp ) ) {
427
- Common_Util::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
428
- } else {
429
- Common_Util::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
430
- }
431
- }
432
- }
433
-
434
- }
435
-
436
- $sns_counts = array();
437
- $diffs = array();
438
-
439
- if ( $post_id !== 'home' ) {
440
-
441
- foreach ( $this->target_sns as $sns => $active ) {
442
- if( $active ){
443
- $meta_key = $this->get_cache_key( $sns );
444
- $sns_counts[$sns] = get_post_meta( $post_id, $meta_key, true );
445
- }
446
- }
447
-
448
- if ( ! in_array( -1, $sns_counts, true ) ) {
449
-
450
- foreach ( $this->target_sns as $sns => $active ) {
451
-
452
- if( $active ){
453
-
454
- if ( $sns !== $this->crawl_date_key ) {
455
-
456
- $diff = 0;
457
-
458
- if ( 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 ) {
459
- $diff = $sns_counts[$sns] - $sns_base_counts[$sns];
460
- } else {
461
- $diff = 0;
462
- }
463
-
464
- $meta_key = $this->get_delta_key( $sns );
465
-
466
- update_post_meta( $post_id, $meta_key, (int) $diff );
467
-
468
- } else {
469
-
470
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] !== '' && isset( $sns_base_counts[$sns] ) && $sns_base_counts[$sns] !== '' ) {
471
- $crawl_date = $sns_base_counts[$sns] . ',' . $sns_counts[$sns];
472
- } else {
473
- $crawl_date = '';
474
- }
475
-
476
- $meta_key = $this->get_delta_key( $sns );
477
-
478
- update_post_meta( $post_id, $meta_key, $crawl_date );
479
-
480
- }
481
- }
482
- }
483
- } else {
484
-
485
- foreach ( $this->target_sns as $sns => $active ) {
486
-
487
- if( $active ){
488
-
489
- $meta_key = $this->get_delta_key( $sns );
490
-
491
- if ( $sns !== $this->crawl_date_key ) {
492
-
493
- $diff = 0;
494
-
495
- update_post_meta( $post_id, $meta_key, (int) $diff );
496
-
497
- } else {
498
-
499
- $crawl_date = '';
500
-
501
- update_post_meta( $post_id, $meta_key, $crawl_date );
502
- }
503
- }
504
- }
505
-
506
- }
507
-
508
- } else {
509
-
510
- $option_key = $this->get_cache_key( 'home' );
511
-
512
- $diffs = array();
513
-
514
- if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
515
-
516
- if ( ! in_array( -1, $sns_counts, true ) ) {
517
- foreach ( $this->target_sns as $sns => $active ) {
518
- if( $active ){
519
- if ( $sns !== $this->crawl_date_key ) {
520
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 && isset( $sns_base_counts[$sns] ) && $sns_base_counts[$sns] !== '' && $sns_base_counts[$sns] >= 0 ) {
521
- $diffs[$sns] = (int)( $sns_counts[$sns] - $sns_base_counts[$sns] );
522
- } else {
523
- $diffs[$sns] = 0;
524
- }
525
- } else {
526
- if ( isset( $sns_counts[$sns] ) && isset( $sns_base_counts[$sns] ) && $sns_base_counts[$sns] !== '' ) {
527
- $diffs[$sns] = $sns_base_counts[$sns] . ',' . $sns_counts[$sns];
528
- } else {
529
- $diffs[$sns] = '';
530
- }
531
- }
532
- }
533
- }
534
-
535
- $option_key = $this->get_delta_key( 'home' );
536
-
537
- update_option( $option_key, $diffs );
538
-
539
- } else {
540
- foreach ( $this->target_sns as $sns => $active ) {
541
- if( $active ){
542
- if ( $sns !== $this->crawl_date_key ) {
543
- $diffs[$sns] = (int) 0;
544
- } else {
545
- $diffs[$sns] = '';
546
- }
547
- }
548
- }
549
-
550
- $option_key = $this->get_delta_key( 'home' );
551
-
552
- update_option( $option_key, $diffs );
553
- }
554
-
555
- } else {
556
-
557
- foreach ( $this->target_sns as $sns => $active ) {
558
- if( $active ){
559
- if ( $sns !== $this->crawl_date_key ) {
560
- $diffs[$sns] = (int) 0;
561
- } else {
562
- $diffs[$sns] = '';
563
- }
564
- }
565
- }
566
-
567
- $option_key = $this->get_delta_key( 'home' );
568
-
569
- update_option( $option_key, $diffs );
570
-
571
- }
572
-
573
- }
574
-
575
- }
576
-
577
- /**
578
- * Initialize meta key for ranking
579
- *
580
- * @since 0.3.0
581
- */
582
- public function initialize_base() {
583
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
584
-
585
- /*
586
- $option_key = $this->get_cache_key( $this->offset_suffix );
587
-
588
- update_option( $option_key, 0 );
589
- */
590
- }
591
-
592
- /**
593
- * Clear meta key for ranking
594
- *
595
- * @since 0.3.0
596
- */
597
- public function clear_base() {
598
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
599
-
600
- $option_key = $this->get_delta_key( 'home' );
601
-
602
- delete_option( $option_key );
603
-
604
- /*
605
- $query_args = array(
606
- 'post_type' => $this->post_types,
607
- 'post_status' => 'publish',
608
- 'nopaging' => true,
609
- 'update_post_term_cache' => false,
610
- 'update_post_meta_cache' => false
611
- );
612
-
613
- $posts_query = new WP_Query( $query_args );
614
-
615
- if ( $posts_query->have_posts() ) {
616
- while ( $posts_query->have_posts() ) {
617
- $posts_query->the_post();
618
-
619
- $post_id = get_the_ID();
620
-
621
- foreach ( $this->target_sns as $sns => $active ) {
622
-
623
- if ( $active ) {
624
- $meta_key = $this->get_delta_key( $sns );
625
-
626
- delete_post_meta( $post_id, $meta_key );
627
- }
628
- }
629
- }
630
- }
631
- wp_reset_postdata();
632
- */
633
-
634
- foreach ( $this->target_sns as $sns => $active ) {
635
-
636
- if ( $active ) {
637
- $meta_key = $this->get_delta_key( $sns );
638
-
639
- delete_post_meta_by_key( $meta_key );
640
- }
641
- }
642
-
643
- }
644
-
645
- /**
646
- * Clear meta key for ranking
647
- *
648
- * @since 0.7.0
649
- */
650
- public function clear_base_by_post_id( $post_id ) {
651
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
652
-
653
- foreach ( $this->target_sns as $sns => $active ) {
654
-
655
- if ( $active ) {
656
- $meta_key = $this->get_delta_key( $sns );
657
- delete_post_meta( $post_id, $meta_key );
658
- }
659
-
660
- }
661
-
662
- }
663
-
664
-
665
- }
666
-
667
- ?>
1
+ <?php
2
+ /*
3
+ class-share-analytical-engine.php
4
+
5
+ Description: This class is a data analytical engine.
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 - 2016 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 Share_Analytical_Engine extends Analytical_Engine {
31
+
32
+ /**
33
+ * Prefix of cache ID
34
+ */
35
+ const DEF_TRANSIENT_PREFIX = 'scc_share_count_';
36
+
37
+ /**
38
+ * Prefix of cache ID
39
+ */
40
+ const DEF_BASE_PREFIX = 'scc_share_base_';
41
+
42
+ /**
43
+ * Prefix of cache ID
44
+ */
45
+ const DEF_DELTA_PREFIX = 'scc_share_delta_';
46
+
47
+ /**
48
+ * Cron name to schedule cache processing
49
+ */
50
+ const DEF_PRIME_CRON = 'scc_share_updatebase_prime';
51
+
52
+ /**
53
+ * Cron name to execute cache processing
54
+ */
55
+ const DEF_EXECUTE_CRON = 'scc_share_updatebase_exec';
56
+
57
+ /**
58
+ * Schedule name for cache processing
59
+ */
60
+ const DEF_EVENT_SCHEDULE = 'share_update_base_event';
61
+
62
+ /**
63
+ * Schedule description for cache processing
64
+ */
65
+ const DEF_EVENT_DESCRIPTION = '[SCC] Share Update Base Interval';
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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
94
+
95
+ $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
96
+ $this->base_prefix = self::DEF_BASE_PREFIX;
97
+ $this->delta_prefix = self::DEF_DELTA_PREFIX;
98
+ $this->prime_cron = self::DEF_PRIME_CRON;
99
+ $this->execute_cron = self::DEF_EXECUTE_CRON;
100
+ $this->event_schedule = self::DEF_EVENT_SCHEDULE;
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['post_types'] ) ) $this->post_types = $options['post_types'];
114
+ if ( isset( $options['crawl_date_key'] ) ) $this->crawl_date_key = $options['crawl_date_key'];
115
+
116
+ add_action( $this->prime_cron, array( $this, 'prime_base' ) );
117
+ add_action( $this->execute_cron, array( $this, 'execute_base' ), 10, 1 );
118
+ add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
119
+ }
120
+
121
+ /**
122
+ * Register event schedule for this engine
123
+ *
124
+ * @since 0.1.0
125
+ */
126
+ public function schedule_check_interval( $schedules ) {
127
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
128
+
129
+ $schedules[$this->event_schedule] = array(
130
+ 'interval' => $this->check_interval,
131
+ 'display' => $this->event_description
132
+ );
133
+
134
+ return $schedules;
135
+ }
136
+
137
+ /**
138
+ * Schedule data retrieval and cache processing
139
+ *
140
+ * @since 0.1.0
141
+ */
142
+ public function prime_base() {
143
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
144
+
145
+ $next_exec_time = WP_Cron_Util::next_exec_time( $this->base_schedule );
146
+
147
+ Common_Util::log( '[' . __METHOD__ . '] next_exec_time (timesatamp): ' . $next_exec_time );
148
+ Common_Util::log( '[' . __METHOD__ . '] next_exec_time (date): ' . date_i18n( 'Y/m/d H:i:s', $next_exec_time ) );
149
+
150
+ if ( ! WP_Cron_Util::is_scheduled_hook( $this->execute_cron ) ) {
151
+ wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( Common_Util::short_hash( $next_exec_time ) ) );
152
+ }
153
+ }
154
+
155
+ /**
156
+ * Get and cache data of each published post and page
157
+ *
158
+ * @since 0.1.0
159
+ */
160
+ public function execute_base( $hash ) {
161
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
162
+
163
+ $current_date = date_i18n( 'Y/m/d H:i:s' );
164
+
165
+ if ( file_exists( $this->base_dir ) ) {
166
+ $base_file = $this->base_dir . $this->get_base_key( 'home' );
167
+
168
+ if ( ! file_exists( $base_file ) ) {
169
+ if ( touch( $base_file ) ) {
170
+ Common_Util::log( '[' . __METHOD__ . '] file creation succeeded: ' . $base_file );
171
+ } else {
172
+ Common_Util::log( '[' . __METHOD__ . '] file creation failed: ' . $base_file );
173
+ }
174
+ }
175
+
176
+ if ( file_exists( $base_file ) ) {
177
+ Common_Util::log( '[' . __METHOD__ . '] file exists: ' . $base_file );
178
+
179
+ $option_key = $this->get_cache_key( 'home' );
180
+
181
+ if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
182
+ foreach ( $this->target_sns as $sns => $active ) {
183
+ if ( $active ) {
184
+ if ( $sns !== $this->crawl_date_key ) {
185
+ if ( ! isset( $sns_counts[$sns] ) || $sns_counts[$sns] < 0 ) {
186
+ $sns_counts[$sns] = (int) -1;
187
+ }
188
+ } else {
189
+ if ( ! isset( $sns_counts[$sns] ) ) {
190
+ $sns_counts[$sns] = '';
191
+ }
192
+ }
193
+ }
194
+ }
195
+
196
+ if ( ! in_array( -1, $sns_counts, true ) ) {
197
+ $data = serialize( $sns_counts );
198
+
199
+ $fp = fopen( $base_file, 'w' );
200
+
201
+ if ( fwrite( $fp, $data ) ) {
202
+ Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ');
203
+ } else {
204
+ Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ');
205
+ }
206
+
207
+ if ( fclose( $fp ) ) {
208
+ Common_Util::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
209
+ } else {
210
+ Common_Util::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
211
+ }
212
+ }
213
+ }
214
+ }
215
+
216
+ $query_args = array(
217
+ 'post_type' => $this->post_types,
218
+ 'post_status' => 'publish',
219
+ 'nopaging' => true,
220
+ 'update_post_term_cache' => false,
221
+ 'update_post_meta_cache' => false
222
+ );
223
+
224
+ $posts_query = new WP_Query( $query_args );
225
+
226
+ if ( $posts_query->have_posts() ) {
227
+ while ( $posts_query->have_posts() ) {
228
+ $posts_query->the_post();
229
+
230
+ $post_id = get_the_ID();
231
+
232
+ $base_file = $this->base_dir . $this->get_base_key( $post_id );
233
+
234
+ if ( ! file_exists( $base_file ) ) {
235
+ if ( touch( $base_file ) ) {
236
+ Common_Util::log( '[' . __METHOD__ . '] export file creation succeeded: ' . $base_file );
237
+ } else {
238
+ Common_Util::log( '[' . __METHOD__ . '] export file creation failed: ' . $base_file );
239
+ }
240
+ }
241
+
242
+ if ( file_exists( $base_file ) ) {
243
+ $sns_counts = array();
244
+
245
+ foreach ( $this->target_sns as $sns => $active ) {
246
+ if ( $active ) {
247
+ if ( $sns !== $this->crawl_date_key ) {
248
+ $meta_key = $this->get_cache_key( $sns );
249
+
250
+ $sns_count = get_post_meta( $post_id, $meta_key, true );
251
+
252
+ if ( isset( $sns_count ) && $sns_count !== '' && $sns_count >= 0 ) {
253
+ $sns_counts[$sns] = (int) $sns_count;
254
+ } else {
255
+ $sns_counts[$sns] = (int) -1;
256
+ }
257
+ } else {
258
+ $meta_key = $this->get_cache_key( $sns );
259
+
260
+ $sns_count = get_post_meta( $post_id, $meta_key, true );
261
+
262
+ if ( isset( $sns_count ) && $sns_count !== '' ) {
263
+ $sns_counts[$sns] = $sns_count;
264
+ } else {
265
+ $sns_counts[$sns] = '';
266
+ }
267
+ }
268
+ }
269
+ }
270
+
271
+ if ( ! in_array( -1, $sns_counts, true ) ) {
272
+
273
+ $data = serialize( $sns_counts );
274
+
275
+ $fp = fopen( $base_file, 'w' );
276
+
277
+ if ( fwrite( $fp, $data ) ) {
278
+ Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ' );
279
+ } else {
280
+ Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ' );
281
+ }
282
+
283
+ if ( fclose( $fp ) ) {
284
+ Common_Util::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
285
+ } else {
286
+ Common_Util::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
287
+ }
288
+ }
289
+ }
290
+ }
291
+ }
292
+ wp_reset_postdata();
293
+ }
294
+
295
+ }
296
+
297
+ /**
298
+ * Initialize meta key for ranking
299
+ *
300
+ * @since 0.6.1
301
+ */
302
+ public function analyze( $options = array() ) {
303
+
304
+ $transient_id = $options['cache_key'];
305
+ $target_sns = $options['target_sns'];
306
+ $post_id = $options['post_id'];
307
+
308
+ $base_file = $this->base_dir . $this->get_base_key( $post_id );
309
+
310
+ $sns_counts = array();
311
+ $sns_base_counts = array();
312
+
313
+ if ( file_exists( $base_file ) ) {
314
+ $fp = fopen( $base_file, 'r' );
315
+
316
+ $data = fread( $fp, filesize( $base_file ) );
317
+
318
+ if ( fclose( $fp ) ) {
319
+ Common_Util::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
320
+ } else {
321
+ Common_Util::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
322
+ }
323
+
324
+ $sns_base_counts = unserialize( $data );
325
+ } else {
326
+ // if there is no base file.
327
+
328
+ if ( touch( $base_file ) ) {
329
+ Common_Util::log( '[' . __METHOD__ . '] file creation succeeded: ' . $base_file );
330
+ } else {
331
+ Common_Util::log( '[' . __METHOD__ . '] file creation failed: ' . $base_file );
332
+ }
333
+
334
+ if ( file_exists( $base_file ) ) {
335
+
336
+ $sns_counts = array();
337
+
338
+ if ( $post_id !== 'home' ) {
339
+ foreach ( $this->target_sns as $sns => $active ) {
340
+ if ( $active ) {
341
+ if ( $sns !== $this->crawl_date_key ) {
342
+ $meta_key = $this->get_cache_key( $sns );
343
+
344
+ $sns_count = get_post_meta( $post_id, $meta_key, true );
345
+
346
+ if ( isset( $sns_count ) && $sns_count !== '' && $sns_count >= 0 ) {
347
+ $sns_counts[$sns] = (int) $sns_count;
348
+ } else {
349
+ $sns_count[$sns] = (int) -1;
350
+ }
351
+ } else {
352
+ $meta_key = $this->get_cache_key( $sns );
353
+
354
+ $sns_count = get_post_meta( $post_id, $meta_key, true );
355
+
356
+ if ( isset( $sns_count ) && $sns_count !== '' ) {
357
+ $sns_counts[$sns] = $sns_count;
358
+ } else {
359
+ $sns_counts[$sns] = '';
360
+ }
361
+ }
362
+ }
363
+ }
364
+ } else {
365
+ $option_key = $this->get_cache_key( 'home' );
366
+
367
+ if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
368
+ foreach ( $this->target_sns as $sns => $active ) {
369
+ if ( $active ) {
370
+ if ( $sns !== $this->crawl_date_key ) {
371
+ if ( ! isset( $sns_counts[$sns] ) || $sns_counts[$sns] < 0 ) {
372
+ $sns_counts[$sns] = (int) -1;
373
+ }
374
+ } else {
375
+ if ( ! isset( $sns_counts[$sns] ) ) {
376
+ $sns_counts[$sns] = '';
377
+ }
378
+ }
379
+ }
380
+ }
381
+ }
382
+ }
383
+
384
+ if ( ! in_array( -1, $sns_counts, true ) ) {
385
+ $data = serialize( $sns_counts );
386
+
387
+ $fp = fopen( $base_file, 'w' );
388
+
389
+ if ( fwrite( $fp, $data ) ) {
390
+ Common_Util::log( '[' . __METHOD__ . '] file write succeeded: ' );
391
+ } else {
392
+ Common_Util::log( '[' . __METHOD__ . '] file wrote failed: ' );
393
+ }
394
+
395
+ if ( fclose( $fp ) ) {
396
+ Common_Util::log( '[' . __METHOD__ . '] file close succeeded: ' . $base_file );
397
+ } else {
398
+ Common_Util::log( '[' . __METHOD__ . '] file close failed: ' . $base_file );
399
+ }
400
+ }
401
+ }
402
+ }
403
+
404
+ $sns_counts = array();
405
+ $diffs = array();
406
+
407
+ if ( $post_id !== 'home' ) {
408
+ foreach ( $this->target_sns as $sns => $active ) {
409
+ if( $active ){
410
+ $meta_key = $this->get_cache_key( $sns );
411
+ $sns_counts[$sns] = get_post_meta( $post_id, $meta_key, true );
412
+ }
413
+ }
414
+
415
+ if ( ! in_array( -1, $sns_counts, true ) ) {
416
+
417
+ foreach ( $this->target_sns as $sns => $active ) {
418
+ if ( $active ){
419
+ if ( $sns !== $this->crawl_date_key ) {
420
+ $diff = 0;
421
+
422
+ if ( 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 ) {
423
+ $diff = $sns_counts[$sns] - $sns_base_counts[$sns];
424
+ } else {
425
+ $diff = 0;
426
+ }
427
+
428
+ $meta_key = $this->get_delta_key( $sns );
429
+
430
+ update_post_meta( $post_id, $meta_key, (int) $diff );
431
+ } else {
432
+ if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] !== '' && isset( $sns_base_counts[$sns] ) && $sns_base_counts[$sns] !== '' ) {
433
+ $crawl_date = $sns_base_counts[$sns] . ',' . $sns_counts[$sns];
434
+ } else {
435
+ $crawl_date = '';
436
+ }
437
+
438
+ $meta_key = $this->get_delta_key( $sns );
439
+
440
+ update_post_meta( $post_id, $meta_key, $crawl_date );
441
+ }
442
+ }
443
+ }
444
+ } else {
445
+ foreach ( $this->target_sns as $sns => $active ) {
446
+ if( $active ){
447
+ $meta_key = $this->get_delta_key( $sns );
448
+ if ( $sns !== $this->crawl_date_key ) {
449
+ $diff = 0;
450
+
451
+ update_post_meta( $post_id, $meta_key, (int) $diff );
452
+ } else {
453
+ $crawl_date = '';
454
+
455
+ update_post_meta( $post_id, $meta_key, $crawl_date );
456
+ }
457
+ }
458
+ }
459
+ }
460
+ } else {
461
+ $option_key = $this->get_cache_key( 'home' );
462
+
463
+ $diffs = array();
464
+
465
+ if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
466
+
467
+ if ( ! in_array( -1, $sns_counts, true ) ) {
468
+ foreach ( $this->target_sns as $sns => $active ) {
469
+ if( $active ){
470
+ if ( $sns !== $this->crawl_date_key ) {
471
+ if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 && isset( $sns_base_counts[$sns] ) && $sns_base_counts[$sns] !== '' && $sns_base_counts[$sns] >= 0 ) {
472
+ $diffs[$sns] = (int)( $sns_counts[$sns] - $sns_base_counts[$sns] );
473
+ } else {
474
+ $diffs[$sns] = 0;
475
+ }
476
+ } else {
477
+ if ( isset( $sns_counts[$sns] ) && isset( $sns_base_counts[$sns] ) && $sns_base_counts[$sns] !== '' ) {
478
+ $diffs[$sns] = $sns_base_counts[$sns] . ',' . $sns_counts[$sns];
479
+ } else {
480
+ $diffs[$sns] = '';
481
+ }
482
+ }
483
+ }
484
+ }
485
+
486
+ $option_key = $this->get_delta_key( 'home' );
487
+
488
+ update_option( $option_key, $diffs );
489
+ } else {
490
+ foreach ( $this->target_sns as $sns => $active ) {
491
+ if ( $active ) {
492
+ if ( $sns !== $this->crawl_date_key ) {
493
+ $diffs[$sns] = (int) 0;
494
+ } else {
495
+ $diffs[$sns] = '';
496
+ }
497
+ }
498
+ }
499
+
500
+ $option_key = $this->get_delta_key( 'home' );
501
+
502
+ update_option( $option_key, $diffs );
503
+ }
504
+ } else {
505
+
506
+ foreach ( $this->target_sns as $sns => $active ) {
507
+ if ( $active ){
508
+ if ( $sns !== $this->crawl_date_key ) {
509
+ $diffs[$sns] = (int) 0;
510
+ } else {
511
+ $diffs[$sns] = '';
512
+ }
513
+ }
514
+ }
515
+
516
+ $option_key = $this->get_delta_key( 'home' );
517
+
518
+ update_option( $option_key, $diffs );
519
+ }
520
+ }
521
+
522
+ }
523
+
524
+ /**
525
+ * Initialize meta key for ranking
526
+ *
527
+ * @since 0.3.0
528
+ */
529
+ public function initialize_base() {
530
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
531
+
532
+ /*
533
+ $option_key = $this->get_cache_key( $this->offset_suffix );
534
+
535
+ update_option( $option_key, 0 );
536
+ */
537
+ }
538
+
539
+ /**
540
+ * Clear meta key for ranking
541
+ *
542
+ * @since 0.3.0
543
+ */
544
+ public function clear_base() {
545
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
546
+
547
+ $option_key = $this->get_delta_key( 'home' );
548
+
549
+ delete_option( $option_key );
550
+
551
+ foreach ( $this->target_sns as $sns => $active ) {
552
+ if ( $active ) {
553
+ $meta_key = $this->get_delta_key( $sns );
554
+
555
+ delete_post_meta_by_key( $meta_key );
556
+ }
557
+ }
558
+
559
+ }
560
+
561
+ /**
562
+ * Clear meta key for ranking
563
+ *
564
+ * @since 0.7.0
565
+ */
566
+ public function clear_base_by_post_id( $post_id ) {
567
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
568
+
569
+ foreach ( $this->target_sns as $sns => $active ) {
570
+ if ( $active ) {
571
+ $meta_key = $this->get_delta_key( $sns );
572
+ delete_post_meta( $post_id, $meta_key );
573
+ }
574
+ }
575
+
576
+ }
577
+
578
+ }
579
+
580
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-share-base-cache-engine.php CHANGED
@@ -1,400 +1,391 @@
1
- <?php
2
- /*
3
- class-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
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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
31
-
32
-
33
- class Share_Base_Cache_Engine extends Share_Cache_Engine {
34
-
35
- /**
36
- * Prefix of cache ID
37
- */
38
- const DEF_TRANSIENT_PREFIX = 'scc_share_count_';
39
-
40
- /**
41
- * Cron name to schedule cache processing
42
- */
43
- const DEF_PRIME_CRON = 'scc_share_basecache_prime';
44
-
45
- /**
46
- * Cron name to execute cache processing
47
- */
48
- const DEF_EXECUTE_CRON = 'scc_share_basecache_exec';
49
-
50
- /**
51
- * Schedule name for cache processing
52
- */
53
- const DEF_EVENT_SCHEDULE = 'share_base_cache_event';
54
-
55
- /**
56
- * Schedule description for cache processing
57
- */
58
- const DEF_EVENT_DESCRIPTION = '[SCC] Share Base Cache Interval';
59
-
60
- /**
61
- * Interval cheking and caching target data
62
- */
63
- private $check_interval = 600;
64
-
65
- /**
66
- * Number of posts to check at a time
67
- */
68
- private $posts_per_check = 20;
69
-
70
- /**
71
- * Offset suffix
72
- */
73
- private $offset_suffix = 'base_offset';
74
-
75
- /**
76
- * Initialization
77
- *
78
- * @since 0.1.1
79
- */
80
- public function initialize( $options = array() ) {
81
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
82
-
83
- $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
84
- $this->prime_cron = self::DEF_PRIME_CRON;
85
- $this->execute_cron = self::DEF_EXECUTE_CRON;
86
- $this->event_schedule = self::DEF_EVENT_SCHEDULE;
87
- $this->event_description = self::DEF_EVENT_DESCRIPTION;
88
-
89
- $this->load_ratio = 0.5;
90
-
91
- if ( isset( $options['delegate'] ) ) $this->delegate = $options['delegate'];
92
- if ( isset( $options['crawler'] ) ) $this->crawler = $options['crawler'];
93
- if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
94
- if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
95
- if ( isset( $options['posts_per_check'] ) ) $this->posts_per_check = $options['posts_per_check'];
96
- if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
97
- if ( isset( $options['prime_cron'] ) ) $this->prime_cron = $options['prime_cron'];
98
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
99
- if ( isset( $options['event_schedule'] ) ) $this->event_schedule = $options['event_schedule'];
100
- if ( isset( $options['event_description'] ) ) $this->event_description = $options['event_description'];
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
-
108
- add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
109
- add_action( $this->prime_cron, array( $this, 'prime_cache' ) );
110
- add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 1 );
111
-
112
- }
113
-
114
- /**
115
- * Register event schedule for this engine
116
- *
117
- * @since 0.1.0
118
- */
119
- public function schedule_check_interval( $schedules ) {
120
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
121
-
122
- $schedules[$this->event_schedule] = array(
123
- 'interval' => $this->check_interval,
124
- 'display' => $this->event_description
125
- );
126
-
127
- return $schedules;
128
- }
129
-
130
- /**
131
- * Schedule data retrieval and cache processing
132
- *
133
- * @since 0.1.0
134
- */
135
- public function prime_cache() {
136
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
137
-
138
- $next_exec_time = time() + $this->check_interval;
139
- $posts_total = $this->get_posts_total();
140
-
141
- Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
142
- Common_Util::log( '[' . __METHOD__ . '] posts_per_check: ' . $this->posts_per_check );
143
- Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
144
- Common_Util::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
145
-
146
- $option_key = $this->get_cache_key( $this->offset_suffix );
147
-
148
- if ( false === ( $posts_offset = get_option( $option_key ) ) ) {
149
- $posts_offset = 0;
150
- }
151
-
152
- Common_Util::log( '[' . __METHOD__ . '] posts_offset: ' . $posts_offset );
153
-
154
- wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( (int) $posts_offset ) );
155
-
156
- $posts_offset = $posts_offset + $this->posts_per_check;
157
-
158
- if ( $posts_offset > $posts_total ) {
159
- $posts_offset = 0;
160
- }
161
-
162
- update_option( $option_key, $posts_offset );
163
- }
164
-
165
- /**
166
- * Get and cache data of each published post and page
167
- *
168
- * @since 0.1.0
169
- */
170
- public function execute_cache( $posts_offset ) {
171
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
172
-
173
- Common_Util::log( '[' . __METHOD__ . '] posts_offset: ' . $posts_offset );
174
- Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
175
- Common_Util::log( '[' . __METHOD__ . '] posts_per_check: ' . $this->posts_per_check );
176
-
177
- $cache_expiration = $this->get_cache_expiration();
178
-
179
- Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
180
-
181
- // Cache home url
182
- if ( $posts_offset == 0 ) {
183
-
184
- $post_ID = 'home';
185
-
186
- $transient_id = $this->get_cache_key( $post_ID );
187
- $url = home_url( '/' );
188
-
189
- $options = array(
190
- 'cache_key' => $transient_id,
191
- 'post_id' => $post_ID,
192
- 'target_url' => $url,
193
- 'target_sns' => $this->target_sns,
194
- 'publish_date' => NULL,
195
- 'cache_expiration' => $cache_expiration
196
- );
197
-
198
- // Primary cache
199
- $this->cache( $options );
200
-
201
- // Secondary cache
202
- $this->delegate_cache( $options );
203
-
204
- }
205
-
206
- $query_args = array(
207
- 'post_type' => $this->post_types,
208
- 'post_status' => 'publish',
209
- 'offset' => $posts_offset,
210
- 'posts_per_page' => $this->posts_per_check,
211
- 'no_found_rows' => true,
212
- 'update_post_term_cache' => false,
213
- 'update_post_meta_cache' => false
214
- );
215
-
216
- $posts_query = new WP_Query( $query_args );
217
-
218
- if ( $posts_query->have_posts() ) {
219
- while ( $posts_query->have_posts() ) {
220
- $posts_query->the_post();
221
-
222
- $post_ID = get_the_ID();
223
-
224
- Common_Util::log( '[' . __METHOD__ . '] post_id: ' . $post_ID );
225
-
226
- $transient_id = $this->get_cache_key( $post_ID );
227
-
228
- $url = get_permalink( $post_ID );
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
- 'publish_date' => get_the_date( 'Y/m/d' ),
236
- 'cache_expiration' => $cache_expiration
237
- );
238
-
239
- // Primary cache
240
- $this->cache( $options );
241
-
242
- // Secondary cache
243
- $this->delegate_cache( $options );
244
-
245
- }
246
- }
247
- wp_reset_postdata();
248
- }
249
-
250
- /**
251
- * Get and cache data for a given post
252
- *
253
- * @since 0.1.1
254
- */
255
- public function direct_cache( $post_ID, $second_sync = false ) {
256
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
257
-
258
- $cache_expiration = $this->get_cache_expiration();
259
-
260
- Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
261
-
262
- $transient_id = $this->get_cache_key( $post_ID );
263
-
264
- if ( $post_ID != 'home' ) {
265
- $url = get_permalink( $post_ID );
266
- $publish_date = get_the_date( 'Y/m/d', $post_ID );
267
- } else {
268
- $url = home_url( '/' );
269
- $publish_date = NULL;
270
- }
271
-
272
- $options = array(
273
- 'cache_key' => $transient_id,
274
- 'post_id' => $post_ID,
275
- 'target_url' => $url,
276
- 'target_sns' => $this->target_sns,
277
- 'publish_date' => $publish_date,
278
- 'cache_expiration' => $cache_expiration
279
- );
280
-
281
- // Primary cache
282
- $result = $this->cache( $options );
283
-
284
- if ( $second_sync ) {
285
- // Secondary cache
286
- $this->delegate_cache( $options );
287
- }
288
-
289
- return $result;
290
- }
291
-
292
- /**
293
- * Get cache expiration based on current number of total post and page
294
- *
295
- * @since 0.1.1
296
- */
297
- protected function get_cache_expiration() {
298
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
299
-
300
- $posts_total = $this->get_posts_total();
301
-
302
- Common_Util::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
303
-
304
- return ceil( $posts_total / $this->posts_per_check ) * $this->check_interval * 3;
305
- }
306
-
307
- /**
308
- * Initialize meta key for ranking
309
- *
310
- * @since 0.3.0
311
- */
312
- public function initialize_cache() {
313
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
314
-
315
- $option_key = $this->get_cache_key( $this->offset_suffix );
316
-
317
- update_option( $option_key, 0 );
318
-
319
- }
320
-
321
- /**
322
- * Clear meta key for ranking
323
- *
324
- * @since 0.3.0
325
- */
326
- public function clear_cache() {
327
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
328
-
329
- $transient_id = $this->get_cache_key( 'home' );
330
-
331
- delete_transient( $transient_id );
332
-
333
- $query_args = array(
334
- 'post_type' => $this->post_types,
335
- 'post_status' => 'publish',
336
- 'nopaging' => true,
337
- 'update_post_term_cache' => false,
338
- 'update_post_meta_cache' => false
339
- );
340
-
341
- $posts_query = new WP_Query( $query_args );
342
-
343
- if ( $posts_query->have_posts() ) {
344
- while ( $posts_query->have_posts() ) {
345
- $posts_query->the_post();
346
-
347
- $post_ID = get_the_ID();
348
-
349
- $transient_id = $this->get_cache_key( $post_ID );
350
-
351
- delete_transient( $transient_id );
352
- }
353
- }
354
- wp_reset_postdata();
355
-
356
- $option_key = $this->get_cache_key( $this->offset_suffix );
357
-
358
- delete_option( $option_key );
359
-
360
- }
361
-
362
-
363
- /**
364
- * Clear meta key for ranking
365
- *
366
- * @since 0.7.0
367
- */
368
- public function clear_cache_by_post_id( $post_id ) {
369
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
370
-
371
- $transient_id = $this->get_cache_key( $post_id );
372
-
373
- delete_transient( $transient_id );
374
-
375
- }
376
-
377
- /**
378
- * Get total count of current published post and page
379
- *
380
- * @since 0.1.0
381
- */
382
- private function get_posts_total() {
383
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
384
-
385
- $query_args = array(
386
- 'post_type' => $this->post_types,
387
- 'post_status' => 'publish',
388
- 'nopaging' => true,
389
- 'update_post_term_cache' => false,
390
- 'update_post_meta_cache' => false
391
- );
392
-
393
- $posts_query = new WP_Query( $query_args );
394
-
395
- return $posts_query->found_posts;
396
- }
397
-
398
- }
399
-
400
- ?>
1
+ <?php
2
+ /*
3
+ class-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
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 - 2016 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 Share_Base_Cache_Engine extends Share_Cache_Engine {
31
+
32
+ /**
33
+ * Prefix of cache ID
34
+ */
35
+ const DEF_TRANSIENT_PREFIX = 'scc_share_count_';
36
+
37
+ /**
38
+ * Cron name to schedule cache processing
39
+ */
40
+ const DEF_PRIME_CRON = 'scc_share_basecache_prime';
41
+
42
+ /**
43
+ * Cron name to execute cache processing
44
+ */
45
+ const DEF_EXECUTE_CRON = 'scc_share_basecache_exec';
46
+
47
+ /**
48
+ * Schedule name for cache processing
49
+ */
50
+ const DEF_EVENT_SCHEDULE = 'share_base_cache_event';
51
+
52
+ /**
53
+ * Schedule description for cache processing
54
+ */
55
+ const DEF_EVENT_DESCRIPTION = '[SCC] Share Base Cache Interval';
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
+ * Offset suffix
69
+ */
70
+ private $offset_suffix = 'base_offset';
71
+
72
+ /**
73
+ * Initialization
74
+ *
75
+ * @since 0.1.1
76
+ */
77
+ public function initialize( $options = array() ) {
78
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
79
+
80
+ $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
81
+ $this->prime_cron = self::DEF_PRIME_CRON;
82
+ $this->execute_cron = self::DEF_EXECUTE_CRON;
83
+ $this->event_schedule = self::DEF_EVENT_SCHEDULE;
84
+ $this->event_description = self::DEF_EVENT_DESCRIPTION;
85
+
86
+ $this->load_ratio = 0.5;
87
+
88
+ if ( isset( $options['delegate'] ) ) $this->delegate = $options['delegate'];
89
+ if ( isset( $options['crawler'] ) ) $this->crawler = $options['crawler'];
90
+ if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
91
+ if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
92
+ if ( isset( $options['posts_per_check'] ) ) $this->posts_per_check = $options['posts_per_check'];
93
+ if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
94
+ if ( isset( $options['prime_cron'] ) ) $this->prime_cron = $options['prime_cron'];
95
+ if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
96
+ if ( isset( $options['event_schedule'] ) ) $this->event_schedule = $options['event_schedule'];
97
+ if ( isset( $options['event_description'] ) ) $this->event_description = $options['event_description'];
98
+ if ( isset( $options['post_types'] ) ) $this->post_types = $options['post_types'];
99
+ if ( isset( $options['scheme_migration_mode'] ) ) $this->scheme_migration_mode = $options['scheme_migration_mode'];
100
+ if ( isset( $options['scheme_migration_date'] ) ) $this->scheme_migration_date = $options['scheme_migration_date'];
101
+ if ( isset( $options['scheme_migration_exclude_keys'] ) ) $this->scheme_migration_exclude_keys = $options['scheme_migration_exclude_keys'];
102
+ if ( isset( $options['cache_retry'] ) ) $this->cache_retry = $options['cache_retry'];
103
+ if ( isset( $options['retry_limit'] ) ) $this->retry_limit = $options['retry_limit'];
104
+
105
+ add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
106
+ add_action( $this->prime_cron, array( $this, 'prime_cache' ) );
107
+ add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 1 );
108
+ }
109
+
110
+ /**
111
+ * Register event schedule for this engine
112
+ *
113
+ * @since 0.1.0
114
+ */
115
+ public function schedule_check_interval( $schedules ) {
116
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
117
+
118
+ $schedules[$this->event_schedule] = array(
119
+ 'interval' => $this->check_interval,
120
+ 'display' => $this->event_description
121
+ );
122
+
123
+ return $schedules;
124
+ }
125
+
126
+ /**
127
+ * Schedule data retrieval and cache processing
128
+ *
129
+ * @since 0.1.0
130
+ */
131
+ public function prime_cache() {
132
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
133
+
134
+ $next_exec_time = time() + $this->check_interval;
135
+ $posts_total = $this->get_posts_total();
136
+
137
+ Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
138
+ Common_Util::log( '[' . __METHOD__ . '] posts_per_check: ' . $this->posts_per_check );
139
+ Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
140
+ Common_Util::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
141
+
142
+ $option_key = $this->get_cache_key( $this->offset_suffix );
143
+
144
+ if ( false === ( $posts_offset = get_option( $option_key ) ) ) {
145
+ $posts_offset = 0;
146
+ }
147
+
148
+ Common_Util::log( '[' . __METHOD__ . '] posts_offset: ' . $posts_offset );
149
+
150
+ wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( (int) $posts_offset ) );
151
+
152
+ $posts_offset = $posts_offset + $this->posts_per_check;
153
+
154
+ if ( $posts_offset > $posts_total ) {
155
+ $posts_offset = 0;
156
+ }
157
+
158
+ update_option( $option_key, $posts_offset );
159
+ }
160
+
161
+ /**
162
+ * Get and cache data of each published post and page
163
+ *
164
+ * @since 0.1.0
165
+ */
166
+ public function execute_cache( $posts_offset ) {
167
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
168
+
169
+ Common_Util::log( '[' . __METHOD__ . '] posts_offset: ' . $posts_offset );
170
+ Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
171
+ Common_Util::log( '[' . __METHOD__ . '] posts_per_check: ' . $this->posts_per_check );
172
+
173
+ $cache_expiration = $this->get_cache_expiration();
174
+
175
+ Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
176
+
177
+ // Cache home url
178
+ if ( $posts_offset == 0 ) {
179
+ $post_ID = 'home';
180
+
181
+ $transient_id = $this->get_cache_key( $post_ID );
182
+ $url = home_url( '/' );
183
+
184
+ $options = array(
185
+ 'cache_key' => $transient_id,
186
+ 'post_id' => $post_ID,
187
+ 'target_url' => $url,
188
+ 'target_sns' => $this->target_sns,
189
+ 'publish_date' => NULL,
190
+ 'cache_expiration' => $cache_expiration
191
+ );
192
+
193
+ // Primary cache
194
+ $this->cache( $options );
195
+
196
+ // Secondary cache
197
+ $this->delegate_cache( $options );
198
+
199
+ }
200
+
201
+ $query_args = array(
202
+ 'post_type' => $this->post_types,
203
+ 'post_status' => 'publish',
204
+ 'offset' => $posts_offset,
205
+ 'posts_per_page' => $this->posts_per_check,
206
+ 'no_found_rows' => true,
207
+ 'update_post_term_cache' => false,
208
+ 'update_post_meta_cache' => false
209
+ );
210
+
211
+ $posts_query = new WP_Query( $query_args );
212
+
213
+ if ( $posts_query->have_posts() ) {
214
+ while ( $posts_query->have_posts() ) {
215
+ $posts_query->the_post();
216
+
217
+ $post_ID = get_the_ID();
218
+
219
+ Common_Util::log( '[' . __METHOD__ . '] post_id: ' . $post_ID );
220
+
221
+ $transient_id = $this->get_cache_key( $post_ID );
222
+
223
+ $url = get_permalink( $post_ID );
224
+
225
+ $options = array(
226
+ 'cache_key' => $transient_id,
227
+ 'post_id' => $post_ID,
228
+ 'target_url' => $url,
229
+ 'target_sns' => $this->target_sns,
230
+ 'publish_date' => get_the_date( 'Y/m/d' ),
231
+ 'cache_expiration' => $cache_expiration
232
+ );
233
+
234
+ // Primary cache
235
+ $this->cache( $options );
236
+
237
+ // Secondary cache
238
+ $this->delegate_cache( $options );
239
+ }
240
+ }
241
+ wp_reset_postdata();
242
+ }
243
+
244
+ /**
245
+ * Get and cache data for a given post
246
+ *
247
+ * @since 0.1.1
248
+ */
249
+ public function direct_cache( $post_ID, $second_sync = false ) {
250
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
251
+
252
+ $cache_expiration = $this->get_cache_expiration();
253
+
254
+ Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
255
+
256
+ $transient_id = $this->get_cache_key( $post_ID );
257
+
258
+ if ( $post_ID != 'home' ) {
259
+ $url = get_permalink( $post_ID );
260
+ $publish_date = get_the_date( 'Y/m/d', $post_ID );
261
+ } else {
262
+ $url = home_url( '/' );
263
+ $publish_date = NULL;
264
+ }
265
+
266
+ $options = array(
267
+ 'cache_key' => $transient_id,
268
+ 'post_id' => $post_ID,
269
+ 'target_url' => $url,
270
+ 'target_sns' => $this->target_sns,
271
+ 'publish_date' => $publish_date,
272
+ 'cache_expiration' => $cache_expiration
273
+ );
274
+
275
+ // Primary cache
276
+ $result = $this->cache( $options );
277
+
278
+ if ( $second_sync ) {
279
+ // Secondary cache
280
+ $this->delegate_cache( $options );
281
+ }
282
+
283
+ return $result;
284
+ }
285
+
286
+ /**
287
+ * Get cache expiration based on current number of total post and page
288
+ *
289
+ * @since 0.1.1
290
+ */
291
+ protected function get_cache_expiration() {
292
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
293
+
294
+ $posts_total = $this->get_posts_total();
295
+
296
+ Common_Util::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
297
+
298
+ return ceil( $posts_total / $this->posts_per_check ) * $this->check_interval * 3;
299
+ }
300
+
301
+ /**
302
+ * Initialize meta key for ranking
303
+ *
304
+ * @since 0.3.0
305
+ */
306
+ public function initialize_cache() {
307
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
308
+
309
+ $option_key = $this->get_cache_key( $this->offset_suffix );
310
+
311
+ update_option( $option_key, 0 );
312
+ }
313
+
314
+ /**
315
+ * Clear meta key for ranking
316
+ *
317
+ * @since 0.3.0
318
+ */
319
+ public function clear_cache() {
320
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
321
+
322
+ $transient_id = $this->get_cache_key( 'home' );
323
+
324
+ delete_transient( $transient_id );
325
+
326
+ $query_args = array(
327
+ 'post_type' => $this->post_types,
328
+ 'post_status' => 'publish',
329
+ 'nopaging' => true,
330
+ 'update_post_term_cache' => false,
331
+ 'update_post_meta_cache' => false
332
+ );
333
+
334
+ $posts_query = new WP_Query( $query_args );
335
+
336
+ if ( $posts_query->have_posts() ) {
337
+ while ( $posts_query->have_posts() ) {
338
+ $posts_query->the_post();
339
+
340
+ $post_ID = get_the_ID();
341
+
342
+ $transient_id = $this->get_cache_key( $post_ID );
343
+
344
+ delete_transient( $transient_id );
345
+ }
346
+ }
347
+ wp_reset_postdata();
348
+
349
+ $option_key = $this->get_cache_key( $this->offset_suffix );
350
+
351
+ delete_option( $option_key );
352
+ }
353
+
354
+
355
+ /**
356
+ * Clear meta key for ranking
357
+ *
358
+ * @since 0.7.0
359
+ */
360
+ public function clear_cache_by_post_id( $post_id ) {
361
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
362
+
363
+ $transient_id = $this->get_cache_key( $post_id );
364
+
365
+ delete_transient( $transient_id );
366
+ }
367
+
368
+ /**
369
+ * Get total count of current published post and page
370
+ *
371
+ * @since 0.1.0
372
+ */
373
+ private function get_posts_total() {
374
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
375
+
376
+ $query_args = array(
377
+ 'post_type' => $this->post_types,
378
+ 'post_status' => 'publish',
379
+ 'nopaging' => true,
380
+ 'update_post_term_cache' => false,
381
+ 'update_post_meta_cache' => false
382
+ );
383
+
384
+ $posts_query = new WP_Query( $query_args );
385
+
386
+ return $posts_query->found_posts;
387
+ }
388
+
389
+ }
390
+
391
+ ?>
 
 
 
 
 
 
 
 
 
includes/class-share-cache-engine.php CHANGED
@@ -1,223 +1,247 @@
1
- <?php
2
- /*
3
- class-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
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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
31
-
32
- abstract class Share_Cache_Engine extends Cache_Engine {
33
-
34
- /**
35
- * Crawler instance
36
- */
37
- protected $crawler = NULL;
38
-
39
- /**
40
- * Cache target
41
- */
42
- protected $target_sns = array();
43
-
44
- /**
45
- * Cache post types
46
- */
47
- protected $post_types = array( 'post', 'page' );
48
-
49
- /**
50
- * migration mode from http to https
51
- */
52
- protected $scheme_migration_mode = false;
53
-
54
- /**
55
- * migration date from http to https
56
- */
57
- protected $scheme_migration_date = NULL;
58
-
59
- /**
60
- * excluded keys in scheme migration
61
- */
62
- protected $scheme_migration_exclude_keys = array();
63
-
64
- /**
65
- * load ratio for throttle
66
- */
67
- protected $load_ratio = 0.5;
68
-
69
- /**
70
- * Get and cache data for a given post
71
- *
72
- * @since 0.1.1
73
- */
74
- public function cache( $options = array() ) {
75
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
76
-
77
- $cache_key = $options['cache_key'];
78
- $target_url = $options['target_url'];
79
- $target_sns = $options['target_sns'];
80
- $cache_expiration = $options['cache_expiration'];
81
- $publish_date = $options['publish_date'];
82
-
83
- Common_Util::log( '[' . __METHOD__ . '] current memory usage: ' . round( memory_get_usage( true )/1024/1024, 2 ) . ' MB' );
84
-
85
- Common_Util::log( '[' . __METHOD__ . '] target url: ' . $target_url );
86
-
87
- $data = $this->crawler->get_data( $target_sns, $target_url );
88
-
89
- Common_Util::log( $data );
90
-
91
- Common_Util::log( '[' . __METHOD__ . '] scheme migration date: ' . $this->scheme_migration_date );
92
- Common_Util::log( '[' . __METHOD__ . '] publish date: ' . $publish_date );
93
-
94
- if ( $this->scheme_migration_mode && Common_Util::is_secure_url( $target_url ) ) {
95
-
96
- if ( ! isset( $this->scheme_migration_date ) ) {
97
- $target_url = Common_Util::get_normal_url( $target_url );
98
-
99
- $target_sns_migrated = $target_sns;
100
-
101
- foreach ( $this->scheme_migration_exclude_keys as $sns ) {
102
- unset( $target_sns_migrated[$sns] );
103
- }
104
-
105
- Common_Util::log( '[' . __METHOD__ . '] target url: ' . $target_url );
106
-
107
- $migrated_data = $this->crawler->get_data( $target_sns_migrated, $target_url );
108
-
109
- 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
-
121
- $target_url = Common_Util::get_normal_url( $target_url );
122
-
123
- $target_sns_migrated = $target_sns;
124
-
125
- foreach ( $this->scheme_migration_exclude_keys as $sns ) {
126
- unset( $target_sns_migrated[$sns] );
127
- }
128
-
129
- Common_Util::log( '[' . __METHOD__ . '] target url: ' . $target_url );
130
-
131
- $migrated_data = $this->crawler->get_data( $target_sns_migrated, $target_url );
132
-
133
- Common_Util::log( $migrated_data );
134
-
135
- foreach ( $target_sns_migrated as $sns => $active ) {
136
- if ( $active && isset( $migrated_data[$sns] ) && is_numeric( $migrated_data[$sns] ) && $migrated_data[$sns] > 0 ){
137
- $data[$sns] = $data[$sns] + $migrated_data[$sns];
138
- }
139
- }
140
- }
141
- } else {
142
- $target_url = Common_Util::get_normal_url( $target_url );
143
-
144
- $target_sns_migrated = $target_sns;
145
-
146
- foreach ( $this->scheme_migration_exclude_keys as $sns ) {
147
- unset( $target_sns_migrated[$sns] );
148
- }
149
-
150
- Common_Util::log( '[' . __METHOD__ . '] target url: ' . $target_url );
151
-
152
- $migrated_data = $this->crawler->get_data( $target_sns_migrated, $target_url );
153
-
154
- Common_Util::log( $migrated_data );
155
-
156
- foreach ( $target_sns_migrated as $sns => $active ) {
157
- if ( $active && isset( $migrated_data[$sns] ) && is_numeric( $migrated_data[$sns] ) && $migrated_data[$sns] > 0 ){
158
- $data[$sns] = $data[$sns] + $migrated_data[$sns];
159
- }
160
- }
161
- }
162
-
163
- }
164
-
165
- }
166
-
167
- if ( $data ) {
168
-
169
- $throttle = new Sleep_Throttle( $this->load_ratio );
170
-
171
- $throttle->reset();
172
- $throttle->start();
173
-
174
- $result = set_transient( $cache_key, $data, $cache_expiration );
175
-
176
- $throttle->stop();
177
-
178
- $retry_count = 0;
179
-
180
- while ( true ) {
181
-
182
- Common_Util::log( '[' . __METHOD__ . '] set_transient result (' . $cache_key . '): ' . $result );
183
-
184
- if ( $result ) {
185
- break;
186
-
187
- } else {
188
-
189
- if ( $retry_count < $this->retry_limit ) {
190
-
191
- Common_Util::log( '[' . __METHOD__ . '] sleep before set_transient retry (' . $cache_key . '): ' . $throttle->get_sleep_time() . ' sec.' );
192
-
193
- $throttle->sleep();
194
-
195
- ++$retry_count;
196
-
197
- Common_Util::log( '[' . __METHOD__ . '] count of set_transient retry (' . $cache_key . '): ' . $retry_count );
198
-
199
- $throttle->reset();
200
- $throttle->start();
201
-
202
- $result = set_transient( $cache_key, $data, $cache_expiration );
203
-
204
- $throttle->stop();
205
-
206
- } else {
207
- Common_Util::log( '[' . __METHOD__ . '] set_transient result (' . $cache_key . '): retry failed' );
208
- break;
209
- }
210
- }
211
- }
212
-
213
- }
214
-
215
- Common_Util::log( '[' . __METHOD__ . '] current memory usage: ' . round( memory_get_usage( true )/1024/1024, 2 ) . ' MB' );
216
- Common_Util::log( '[' . __METHOD__ . '] max memory usage: ' . round( memory_get_peak_usage( true )/1024/1024, 2 ) . ' MB' );
217
-
218
- return $data;
219
- }
220
-
221
- }
222
-
223
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ class-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
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 - 2016 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
+ abstract class Share_Cache_Engine extends 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
+ * Cache post types
44
+ */
45
+ protected $post_types = array( 'post', 'page' );
46
+
47
+ /**
48
+ * migration mode from http to https
49
+ */
50
+ protected $scheme_migration_mode = false;
51
+
52
+ /**
53
+ * migration date from http to https
54
+ */
55
+ protected $scheme_migration_date = NULL;
56
+
57
+ /**
58
+ * excluded keys in scheme migration
59
+ */
60
+ protected $scheme_migration_exclude_keys = array();
61
+
62
+ /**
63
+ * load ratio for throttle
64
+ */
65
+ protected $load_ratio = 0.5;
66
+
67
+ /**
68
+ * Get and cache data for a given post
69
+ *
70
+ * @since 0.1.1
71
+ */
72
+ public function cache( $options = array() ) {
73
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
74
+
75
+ $cache_key = $options['cache_key'];
76
+ $target_url = $options['target_url'];
77
+ $target_sns = $options['target_sns'];
78
+ $cache_expiration = $options['cache_expiration'];
79
+ $publish_date = $options['publish_date'];
80
+
81
+ Common_Util::log( '[' . __METHOD__ . '] current memory usage: ' . round( memory_get_usage( true )/1024/1024, 2 ) . ' MB' );
82
+ Common_Util::log( '[' . __METHOD__ . '] target url: ' . $target_url );
83
+
84
+ $data = $this->get_data( $target_sns, $target_url );
85
+
86
+ Common_Util::log( $data );
87
+ Common_Util::log( '[' . __METHOD__ . '] scheme migration date: ' . $this->scheme_migration_date );
88
+ Common_Util::log( '[' . __METHOD__ . '] publish date: ' . $publish_date );
89
+
90
+ if ( $this->scheme_migration_mode && Common_Util::is_secure_url( $target_url ) ) {
91
+ if ( ! isset( $this->scheme_migration_date ) ) {
92
+ $target_normal_url = Common_Util::get_normal_url( $target_url );
93
+ $target_sns_migrated = $target_sns;
94
+
95
+ foreach ( $this->scheme_migration_exclude_keys as $sns ) {
96
+ unset( $target_sns_migrated[$sns] );
97
+ }
98
+
99
+ Common_Util::log( '[' . __METHOD__ . '] target url: ' . $target_normal_url );
100
+
101
+ $migrated_data = $this->get_data( $target_sns_migrated, $target_normal_url );
102
+
103
+ Common_Util::log( $migrated_data );
104
+
105
+ foreach ( $target_sns_migrated as $sns => $active ) {
106
+ if ( $active && isset( $migrated_data[$sns] ) && is_numeric( $migrated_data[$sns] ) && $migrated_data[$sns] > 0 ){
107
+ $data[$sns] = $data[$sns] + $migrated_data[$sns];
108
+ }
109
+ }
110
+
111
+ } else {
112
+ if ( isset( $publish_date ) ) {
113
+ if ( strtotime( $publish_date ) <= strtotime( $this->scheme_migration_date ) ) {
114
+ $target_normal_url = Common_Util::get_normal_url( $target_url );
115
+ $target_sns_migrated = $target_sns;
116
+
117
+ foreach ( $this->scheme_migration_exclude_keys as $sns ) {
118
+ unset( $target_sns_migrated[$sns] );
119
+ }
120
+
121
+ Common_Util::log( '[' . __METHOD__ . '] target url: ' . $target_normal_url );
122
+
123
+ $migrated_data = $this->get_data( $target_sns_migrated, $target_normal_url );
124
+
125
+ Common_Util::log( $migrated_data );
126
+
127
+ foreach ( $target_sns_migrated as $sns => $active ) {
128
+ if ( $active && isset( $migrated_data[$sns] ) && is_numeric( $migrated_data[$sns] ) && $migrated_data[$sns] > 0 ){
129
+ $data[$sns] = $data[$sns] + $migrated_data[$sns];
130
+ }
131
+ }
132
+ }
133
+ } else {
134
+ $target_normal_url = Common_Util::get_normal_url( $target_url );
135
+ $target_sns_migrated = $target_sns;
136
+
137
+ foreach ( $this->scheme_migration_exclude_keys as $sns ) {
138
+ unset( $target_sns_migrated[$sns] );
139
+ }
140
+
141
+ Common_Util::log( '[' . __METHOD__ . '] target url: ' . $target_url );
142
+
143
+ $migrated_data = $this->get_data( $target_sns_migrated, $target_url );
144
+
145
+ Common_Util::log( $migrated_data );
146
+
147
+ foreach ( $target_sns_migrated as $sns => $active ) {
148
+ if ( $active && isset( $migrated_data[$sns] ) && is_numeric( $migrated_data[$sns] ) && $migrated_data[$sns] > 0 ){
149
+ $data[$sns] = $data[$sns] + $migrated_data[$sns];
150
+ }
151
+ }
152
+ }
153
+ }
154
+
155
+ $target_sns_param = $target_sns;
156
+
157
+ unset( $target_sns_param[SNS_Count_Cache::REF_CRAWL_DATE] );
158
+ unset( $target_sns_param[SNS_Count_Cache::REF_SHARE_TOTAL] );
159
+
160
+ $query_parameters = array(
161
+ 'url' => $target_url
162
+ );
163
+
164
+ foreach ( $target_sns_param as $sns => $active ) {
165
+ if ( $active ) {
166
+ $this->crawler->set_crawl_strategy_query_parameters( $sns, $query_parameters );
167
+ }
168
+ }
169
+ }
170
+
171
+ Common_Util::log( $data );
172
+
173
+ if ( $data ) {
174
+ $throttle = new Sleep_Throttle( $this->load_ratio );
175
+
176
+ $throttle->reset();
177
+ $throttle->start();
178
+
179
+ $result = set_transient( $cache_key, $data, $cache_expiration );
180
+ $throttle->stop();
181
+
182
+ $retry_count = 0;
183
+
184
+ while ( true ) {
185
+
186
+ Common_Util::log( '[' . __METHOD__ . '] set_transient result (' . $cache_key . '): ' . $result );
187
+
188
+ if ( $result ) {
189
+ break;
190
+ } else {
191
+ if ( $retry_count < $this->retry_limit ) {
192
+ Common_Util::log( '[' . __METHOD__ . '] sleep before set_transient retry (' . $cache_key . '): ' . $throttle->get_sleep_time() . ' sec.' );
193
+
194
+ $throttle->sleep();
195
+ ++$retry_count;
196
+
197
+ Common_Util::log( '[' . __METHOD__ . '] count of set_transient retry (' . $cache_key . '): ' . $retry_count );
198
+
199
+ $throttle->reset();
200
+ $throttle->start();
201
+
202
+ $result = set_transient( $cache_key, $data, $cache_expiration );
203
+
204
+ $throttle->stop();
205
+ } else {
206
+ Common_Util::log( '[' . __METHOD__ . '] set_transient result (' . $cache_key . '): retry failed' );
207
+ break;
208
+ }
209
+ }
210
+ }
211
+ }
212
+
213
+ Common_Util::log( '[' . __METHOD__ . '] current memory usage: ' . round( memory_get_usage( true )/1024/1024, 2 ) . ' MB' );
214
+ Common_Util::log( '[' . __METHOD__ . '] max memory usage: ' . round( memory_get_peak_usage( true )/1024/1024, 2 ) . ' MB' );
215
+
216
+ return $data;
217
+ }
218
+
219
+ /**
220
+ * Get data
221
+ *
222
+ * @since 0.9.0
223
+ */
224
+ private function get_data( $target_sns, $target_url ) {
225
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
226
+
227
+ $target_sns_base = $target_sns;
228
+
229
+ unset( $target_sns_base[SNS_Count_Cache::REF_CRAWL_DATE] );
230
+ unset( $target_sns_base[SNS_Count_Cache::REF_SHARE_TOTAL] );
231
+
232
+ $query_parameters = array(
233
+ 'url' => $target_url
234
+ );
235
+
236
+ foreach ( $target_sns_base as $sns => $active ) {
237
+ if ( $active ) {
238
+ $this->crawler->set_crawl_strategy_query_parameters( $sns, $query_parameters );
239
+ }
240
+ }
241
+
242
+ return $this->crawler->get_data( $target_sns, NULL );
243
+ }
244
+
245
+ }
246
+
247
+ ?>
includes/class-share-crawler.php CHANGED
@@ -10,8 +10,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
  */
11
 
12
  /*
13
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
 
16
  This program is free software; you can redistribute it and/or
17
  modify it under the terms of the GNU General Public License
@@ -26,324 +25,279 @@ GNU General Public License for more details.
26
  You should have received a copy of the GNU General Public License
27
  along with this program; if not, write to the Free Software
28
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
  */
31
 
32
- class Share_Crawler extends Data_Crawler {
33
-
34
- /**
35
  * Initialization
36
  *
37
  * @since 0.5.1
38
  */
39
- public function initialize( $options = array() ) {
40
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
41
-
42
- //$this->throttle = new Sleep_Throttle( 0.9 );
43
-
44
- if ( isset( $options['crawl_method'] ) ) $this->crawl_method = $options['crawl_method'];
45
- if ( isset( $options['timeout'] ) ) $this->timeout = $options['timeout'];
46
- if ( isset( $options['ssl_verification'] ) ) $this->ssl_verification = $options['ssl_verification'];
47
- if ( isset( $options['crawl_retry'] ) ) $this->crawl_retry = $options['crawl_retry'];
48
- if ( isset( $options['retry_limit'] ) ) $this->retry_limit = $options['retry_limit'];
49
- }
50
-
51
- /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  * Implementation of abstract method. this method gets each share count
53
  *
54
  * @since 0.1.1
55
- */
56
- public function get_data( $target_sns, $url ) {
57
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
58
-
59
- $url = rawurlencode( $url );
60
-
61
- $query_urls = $this->build_query_urls( $target_sns, $url );
62
-
63
- $data = array();
64
-
65
- $throttle = new Sleep_Throttle( 0.9 );
66
-
 
 
 
 
 
 
67
  $throttle->reset();
68
  $throttle->start();
69
-
70
- if ( $this->crawl_method === SNS_Count_Cache::OPT_COMMON_CRAWLER_METHOD_CURL ) {
71
- $data = Common_Util::multi_remote_get( $query_urls, $this->timeout, $this->ssl_verification, true );
72
  } else {
73
- $data = Common_Util::multi_remote_get( $query_urls, $this->timeout, $this->ssl_verification, false );
74
  }
75
-
76
- $throttle->stop();
77
-
78
- $retry_count = 0;
79
-
80
- while( true ) {
81
-
82
- $target_sns_retry = array();
83
-
84
- $tmp_count = $this->extract_count( $target_sns, $data );
85
-
86
- foreach ( $target_sns as $sns => $active ){
87
- if ( $active ) {
88
- if( $tmp_count[$sns] === -1 ) {
89
- $target_sns_retry[$sns] = true;
90
- }
91
- }
92
  }
93
-
94
- if ( empty( $target_sns_retry ) ) {
95
- break;
96
-
97
  } else {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
 
99
- Common_Util::log( '[' . __METHOD__ . '] crawl failure' );
100
- Common_Util::log( $target_sns_retry );
101
-
102
- if ( $retry_count < $this->retry_limit ) {
103
-
104
- Common_Util::log( '[' . __METHOD__ . '] sleep before crawl retry: ' . $throttle->get_sleep_time() . ' sec.' );
105
-
106
- $throttle->sleep();
107
-
108
- ++$retry_count;
109
-
110
- Common_Util::log( '[' . __METHOD__ . '] count of crawl retry: ' . $retry_count );
111
-
112
- $query_urls_retry = $this->build_query_urls( $target_sns_retry, $url );
113
-
114
- $data_retry = array();
115
-
116
- $throttle->reset();
117
  $throttle->start();
118
-
119
- if ( $this->crawl_method === SNS_Count_Cache::OPT_COMMON_CRAWLER_METHOD_CURL ) {
120
- $data_retry = Common_Util::multi_remote_get( $query_urls_retry, $this->timeout, $this->ssl_verification, true );
121
  } else {
122
- $data_retry = Common_Util::multi_remote_get( $query_urls_retry, $this->timeout, $this->ssl_verification, false );
123
  }
124
-
125
- $throttle->stop();
126
-
127
- $data = array_merge( $data, $data_retry );
128
  } else {
129
- Common_Util::log( '[' . __METHOD__ . '] crawling: retry failed' );
130
- break;
131
  }
132
  }
133
-
134
  }
135
-
136
- return $this->extract_count( $target_sns, $data );
137
- }
138
 
139
- /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  * build query
141
  *
142
  * @since 0.5.1
143
- */
144
- private function build_query_urls( $target_sns, $url ) {
145
  Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
146
-
147
- $query_urls = array();
148
-
149
- if ( isset( $url ) ) {
150
- if ( isset( $target_sns[SNS_Count_Cache::REF_SHARE_HATEBU] ) && $target_sns[SNS_Count_Cache::REF_SHARE_HATEBU] ) {
151
- $query_urls[SNS_Count_Cache::REF_SHARE_HATEBU] = 'http://api.b.st-hatena.com/entry.count?url=' . $url;
152
- }
153
-
154
- if ( isset( $target_sns[SNS_Count_Cache::REF_SHARE_TWITTER] ) && $target_sns[SNS_Count_Cache::REF_SHARE_TWITTER] ) {
155
- $query_urls[SNS_Count_Cache::REF_SHARE_TWITTER] = 'http://urls.api.twitter.com/1/urls/count.json?url=' . $url;
156
- }
157
-
158
- if ( isset( $target_sns[SNS_Count_Cache::REF_SHARE_FACEBOOK] ) && $target_sns[SNS_Count_Cache::REF_SHARE_FACEBOOK] ) {
159
- $query_urls[SNS_Count_Cache::REF_SHARE_FACEBOOK] = 'https://api.facebook.com/method/links.getStats?urls=' . $url . '&format=json';
160
- }
161
-
162
- if ( isset( $target_sns[SNS_Count_Cache::REF_SHARE_GPLUS] ) && $target_sns[SNS_Count_Cache::REF_SHARE_GPLUS] ) {
163
- $query_urls[SNS_Count_Cache::REF_SHARE_GPLUS] = 'https://apis.google.com/_/+1/fastbutton?url=' . $url;
164
- }
165
-
166
- if ( isset( $target_sns[SNS_Count_Cache::REF_SHARE_POCKET] ) && $target_sns[SNS_Count_Cache::REF_SHARE_POCKET] ) {
167
- $query_urls[SNS_Count_Cache::REF_SHARE_POCKET] = 'http://widgets.getpocket.com/v1/button?v=1&count=horizontal&url=' . $url;
168
- }
169
-
170
- /*
171
- if ( isset( $target_sns[SNS_Count_Cache::REF_SHARE_PINTEREST] ) && $target_sns[SNS_Count_Cache::REF_SHARE_PINTEREST] ) {
172
- $query_urls[SNS_Count_Cache::REF_SHARE_PINTEREST] = 'http://api.pinterest.com/v1/urls/count.json?url=' . $url;
173
- }
174
-
175
- if ( isset( $target_sns[SNS_Count_Cache::REF_SHARE_LINKEDIN] ) && $target_sns[SNS_Count_Cache::REF_SHARE_LINKEDIN] ) {
176
- $query_urls[SNS_Count_Cache::REF_SHARE_LINKEDIN] = 'http://www.linkedin.com/countserv/count/share?url=' . $url;
177
- }
178
- */
179
-
180
- }
181
-
182
- return $query_urls;
183
-
184
- }
185
-
186
- /**
187
  * extract count data from retrieved content
188
  *
189
  * @since 0.5.1
190
  */
191
- private function extract_count( $target_sns, $contents ) {
192
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
193
-
194
- $sns_counts = array();
195
-
196
- $extract_date = date_i18n( 'Y/m/d H:i:s' );
197
-
198
- Common_Util::log( $contents );
199
-
200
- foreach ( $contents as $sns => $content ) {
201
-
202
- switch ( $sns ) {
203
- case SNS_Count_Cache::REF_SHARE_HATEBU:
204
- if ( isset( $content['data'] ) && empty( $content['error'] ) && is_numeric( $content['data'] ) ) {
205
- $count = (int) $content['data'];
206
- } elseif ( empty( $content['data'] ) && empty( $content['error'] ) ) {
207
- $count = (int) 0;
208
- } else {
209
- $count = (int) -1;
210
- }
211
-
212
- $sns_counts[SNS_Count_Cache::REF_SHARE_HATEBU] = $count;
213
- break;
214
- case SNS_Count_Cache::REF_SHARE_FACEBOOK:
215
- if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
216
-
217
- $json = json_decode( $content['data'], true );
218
-
219
- if ( isset( $json[0]['total_count'] ) && is_numeric( $json[0]['total_count'] ) ) {
220
- $count = (int) $json[0]['total_count'];
221
- } else {
222
- $count = (int) -1;
223
- }
224
- } else {
225
- $count = (int) -1;
226
- }
227
-
228
- $sns_counts[SNS_Count_Cache::REF_SHARE_FACEBOOK] = $count;
229
- break;
230
- case SNS_Count_Cache::REF_SHARE_TWITTER:
231
- if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
232
- $json = json_decode( $content['data'], true );
233
-
234
- if ( isset( $json['count'] ) && is_numeric( $json['count'] ) ) {
235
- $count = (int) $json['count'];
236
- } else {
237
- $count = (int) -1;
238
- }
239
- } else {
240
- $count = (int) -1;
241
- }
242
-
243
- $sns_counts[SNS_Count_Cache::REF_SHARE_TWITTER] = $count;
244
- break;
245
- case SNS_Count_Cache::REF_SHARE_GPLUS:
246
- if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
247
-
248
- $return_code = preg_match( '/\[2,([0-9.]+),\[/', $content['data'], $matches );
249
-
250
- if ( $return_code && isset( $matches[1] ) && is_numeric( $matches[1] ) ) {
251
- $count = (int) $matches[1];
252
- } else {
253
- $count = (int) -1;
254
- }
255
- } else {
256
- $count = (int) -1;
257
- }
258
-
259
- $sns_counts[SNS_Count_Cache::REF_SHARE_GPLUS] = $count;
260
- break;
261
- case SNS_Count_Cache::REF_SHARE_POCKET:
262
- if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
263
-
264
- $return_code = preg_match( '/<em\sid=\"cnt\">([0-9]+)<\/em>/i', $content['data'], $matches );
265
-
266
- if ( $return_code && isset( $matches[1] ) && is_numeric( $matches[1] ) ) {
267
- $count = (int) $matches[1];
268
- } else {
269
- $count = (int) -1;
270
- }
271
- } else {
272
- $count = (int) -1;
273
- }
274
-
275
- $sns_counts[SNS_Count_Cache::REF_SHARE_POCKET] = $count;
276
- break;
277
- /*
278
- case SNS_Count_Cache::REF_SHARE_PINTEREST:
279
- if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
280
-
281
- $json = rtrim( $content['data'], ')' );
282
- $json = ltrim( $json, 'receiveCount(' );
283
-
284
- $json = json_decode( $json, true );
285
-
286
- if ( isset( $json['count'] ) && is_numeric( $json['count'] ) ) {
287
- $count = (int) $json['count'];
288
- } else {
289
- $count = (int) -1;
290
- }
291
- } else {
292
- $count = (int) -1;
293
- }
294
-
295
- $sns_counts[SNS_Count_Cache::REF_SHARE_PINTEREST] = $count;
296
- break;
297
- case SNS_Count_Cache::REF_SHARE_LINKEDIN:
298
- if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
299
-
300
- $json = rtrim( $content['data'], ');' );
301
- $json = ltrim( $json, 'IN.Tags.Share.handleCount(' );
302
-
303
- $json = json_decode( $json, true );
304
-
305
- if ( isset( $json['count'] ) && is_numeric( $json['count'] ) ) {
306
- $count = (int) $json['count'];
307
- } else {
308
- $count = (int) -1;
309
- }
310
- } else {
311
- $count = (int) -1;
312
- }
313
-
314
- $sns_counts[SNS_Count_Cache::REF_SHARE_LINKEDIN] = $count;
315
- break;
316
- */
317
-
318
- }
319
-
320
  }
321
-
322
- if ( isset( $target_sns[SNS_Count_Cache::REF_SHARE_TOTAL] ) && $target_sns[SNS_Count_Cache::REF_SHARE_TOTAL] ) {
323
-
324
- $total = 0;
325
-
326
- foreach ( $sns_counts as $sns => $count ) {
327
- if ( isset( $count ) && $count >= 0 ) {
328
- $total = $total + $count;
329
  }
330
- }
331
-
332
- $sns_counts[SNS_Count_Cache::REF_SHARE_TOTAL] = (int) $total;
333
  }
334
 
335
- if ( isset( $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] ) && $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] ) {
336
- $sns_counts[SNS_Count_Cache::REF_CRAWL_DATE] = $extract_date;
337
  } else {
338
- $sns_counts[SNS_Count_Cache::REF_CRAWL_DATE] = '';
339
  }
340
-
341
- return $sns_counts;
342
-
343
- }
344
-
345
 
346
-
 
 
347
  }
348
 
349
  ?>
10
  */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2016 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
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 Share_Crawler extends Crawler {
31
+
32
+ /**
33
  * Initialization
34
  *
35
  * @since 0.5.1
36
  */
37
+ public function initialize( $options = array() ) {
38
+ 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] = $this->create_crawl_strategy( $sns );
57
+ }
58
+ }
59
+
60
+ }
61
+
62
+ /**
63
+ * Carete crawl strategy
64
+ *
65
+ * @since 0.9.0
66
+ */
67
+ private function create_crawl_strategy( $sns ) {
68
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
69
+
70
+ switch ( $sns ) {
71
+ case SNS_Count_Cache::REF_SHARE_TWITTER:
72
+ Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
73
+ return Share_Twitter_Strategy::get_instance();
74
+ break;
75
+ case SNS_Count_Cache::REF_SHARE_FACEBOOK:
76
+ Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
77
+ return Share_Facebook_Strategy::get_instance();
78
+ break;
79
+ case SNS_Count_Cache::REF_SHARE_GPLUS:
80
+ Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
81
+ return Share_Google_Strategy::get_instance();
82
+ break;
83
+ case SNS_Count_Cache::REF_SHARE_POCKET:
84
+ Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
85
+ return Share_Pocket_Strategy::get_instance();
86
+ break;
87
+ case SNS_Count_Cache::REF_SHARE_HATEBU:
88
+ Common_Util::log( '[' . __METHOD__ . '] create crawl strategy: ' . $sns );
89
+ return Share_Hatebu_Strategy::get_instance();
90
+ break;
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Check configuration
96
+ *
97
+ * @since 0.9.0
98
+ */
99
+ private function check_configurations( $target_sns ) {
100
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
101
+
102
+ //$checked_target_sns = array();
103
+
104
+ unset( $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] );
105
+ unset( $target_sns[SNS_Count_Cache::REF_SHARE_TOTAL] );
106
+
107
+ Common_Util::log( $target_sns );
108
+
109
+ foreach ( $target_sns as $sns => $active ) {
110
+ if ( $active ) {
111
+ $target_sns[$sns] = $this->crawl_strategies[$sns]->check_configuration();
112
+ }
113
+ }
114
+
115
+ $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] = true;
116
+ $target_sns[SNS_Count_Cache::REF_SHARE_TOTAL] = true;
117
+
118
+ return $target_sns;
119
+
120
+ }
121
+
122
+ /**
123
  * Implementation of abstract method. this method gets each share count
124
  *
125
  * @since 0.1.1
126
+ */
127
+ public function get_data( $target_sns, $options ) {
128
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
129
+
130
+ Common_Util::log( $target_sns );
131
+
132
+ $target_sns = $this->check_configurations( $target_sns );
133
+ Common_Util::log( $target_sns );
134
+
135
+ $query_urls = $this->build_query_urls( $target_sns );
136
+ Common_Util::log( $query_urls );
137
+
138
+ $query_headers = $this->build_query_headers( $target_sns );
139
+ Common_Util::log( $query_headers );
140
+
141
+ $data = array();
142
+
143
+ $throttle = new Sleep_Throttle( 0.9 );
144
  $throttle->reset();
145
  $throttle->start();
146
+
147
+ if ( $this->crawl_method === SNS_Count_Cache::OPT_COMMON_CRAWLER_METHOD_CURL ) {
148
+ $data = Common_Util::multi_remote_get( $query_urls, $query_headers, $this->timeout, $this->ssl_verification, true );
149
  } else {
150
+ $data = Common_Util::multi_remote_get( $query_urls, $query_headers, $this->timeout, $this->ssl_verification, false );
151
  }
152
+
153
+ $throttle->stop();
154
+ $retry_count = 0;
155
+
156
+ while( true ) {
157
+ $target_sns_retry = array();
158
+ $tmp_count = $this->extract_count( $target_sns, $data );
159
+
160
+ foreach ( $target_sns as $sns => $active ){
161
+ if ( $active ) {
162
+ if( $tmp_count[$sns] === -1 ) {
163
+ $target_sns_retry[$sns] = true;
164
+ }
165
+ }
 
 
 
166
  }
167
+
168
+ if ( empty( $target_sns_retry ) ) {
169
+ break;
 
170
  } else {
171
+ Common_Util::log( '[' . __METHOD__ . '] crawl failure' );
172
+ Common_Util::log( $target_sns_retry );
173
+
174
+ if ( $retry_count < $this->retry_limit ) {
175
+ Common_Util::log( '[' . __METHOD__ . '] sleep before crawl retry: ' . $throttle->get_sleep_time() . ' sec.' );
176
+
177
+ $throttle->sleep();
178
+
179
+ ++$retry_count;
180
+ Common_Util::log( '[' . __METHOD__ . '] count of crawl retry: ' . $retry_count );
181
+
182
+ $query_urls_retry = $this->build_query_urls( $target_sns_retry );
183
+ $query_headers_retry = $this->build_query_headers( $target_sns_retry );
184
+
185
+ $data_retry = array();
186
 
187
+ $throttle->reset();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  $throttle->start();
189
+
190
+ if ( $this->crawl_method === SNS_Count_Cache::OPT_COMMON_CRAWLER_METHOD_CURL ) {
191
+ $data_retry = Common_Util::multi_remote_get( $query_urls_retry, $query_headers_retry, $this->timeout, $this->ssl_verification, true );
192
  } else {
193
+ $data_retry = Common_Util::multi_remote_get( $query_urls_retry, $query_headers_retry, $this->timeout, $this->ssl_verification, false );
194
  }
195
+
196
+ $throttle->stop();
197
+ $data = array_merge( $data, $data_retry );
 
198
  } else {
199
+ Common_Util::log( '[' . __METHOD__ . '] crawling: retry failed' );
200
+ break;
201
  }
202
  }
 
203
  }
 
 
 
204
 
205
+ return $this->extract_count( $target_sns, $data );
206
+ }
207
+
208
+ /**
209
+ * build query
210
+ *
211
+ * @since 0.5.1
212
+ */
213
+ private function build_query_urls( $target_sns ) {
214
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
215
+
216
+ $query_urls = array();
217
+
218
+ unset( $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] );
219
+ unset( $target_sns[SNS_Count_Cache::REF_SHARE_TOTAL] );
220
+
221
+ Common_Util::log( $target_sns );
222
+
223
+ foreach ( $target_sns as $sns => $active ) {
224
+ if ( $active ) {
225
+ $query_urls[$sns] = $this->crawl_strategies[$sns]->build_query_url();
226
+ }
227
+ }
228
+
229
+ return $query_urls;
230
+ }
231
+
232
+ /**
233
  * build query
234
  *
235
  * @since 0.5.1
236
+ */
237
+ private function build_query_headers( $target_sns ) {
238
  Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
239
+
240
+ $query_headers = array();
241
+
242
+ unset( $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] );
243
+ unset( $target_sns[SNS_Count_Cache::REF_SHARE_TOTAL] );
244
+
245
+ Common_Util::log( $target_sns );
246
+
247
+ foreach ( $target_sns as $sns => $active ) {
248
+ if ( $active ) {
249
+ $query_headers[$sns] = $this->crawl_strategies[$sns]->build_header();
250
+ }
251
+ }
252
+
253
+ return $query_headers;
254
+ }
255
+
256
+ /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  * extract count data from retrieved content
258
  *
259
  * @since 0.5.1
260
  */
261
+ private function extract_count( $target_sns, $contents ) {
262
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
263
+
264
+ $sns_counts = array();
265
+
266
+ $extract_date = date_i18n( 'Y/m/d H:i:s' );
267
+
268
+ Common_Util::log( $contents );
269
+
270
+ foreach ( $target_sns as $sns => $active ) {
271
+ if ( $active ) {
272
+ if ( isset( $contents[$sns] ) ) {
273
+ $sns_counts[$sns] = $this->crawl_strategies[$sns]->extract_count( $contents[$sns] );
274
+ } else {
275
+ $sns_counts[$sns] = (int) -1;
276
+ }
277
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
  }
279
+
280
+ if ( isset( $target_sns[SNS_Count_Cache::REF_SHARE_TOTAL] ) && $target_sns[SNS_Count_Cache::REF_SHARE_TOTAL] ) {
281
+ $total = 0;
282
+
283
+ foreach ( $sns_counts as $sns => $count ) {
284
+ if ( isset( $count ) && $count >= 0 ) {
285
+ $total = $total + $count;
 
286
  }
287
+ }
288
+
289
+ $sns_counts[SNS_Count_Cache::REF_SHARE_TOTAL] = (int) $total;
290
  }
291
 
292
+ if ( isset( $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] ) && $target_sns[SNS_Count_Cache::REF_CRAWL_DATE] ) {
293
+ $sns_counts[SNS_Count_Cache::REF_CRAWL_DATE] = $extract_date;
294
  } else {
295
+ $sns_counts[SNS_Count_Cache::REF_CRAWL_DATE] = '';
296
  }
 
 
 
 
 
297
 
298
+ return $sns_counts;
299
+ }
300
+
301
  }
302
 
303
  ?>
includes/class-share-facebook-strategy.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ class-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 - 2016 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 Share_Facebook_Strategy extends Crawl_Strategy {
31
+
32
+ /**
33
+ * SNS base url
34
+ */
35
+ const DEF_BASE_URL = 'https://api.facebook.com/method/links.getStats';
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
+ Common_Util::log('[' . __METHOD__ . '] (line='. __LINE__ . ')');
44
+
45
+ $this->method = 'GET';
46
+ $this->query_parameters['format'] = 'json';
47
+ }
48
+
49
+ /**
50
+ * Initialization
51
+ *
52
+ * @since 0.9.0
53
+ */
54
+ public function initialize( $options = array() ) {
55
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
56
+
57
+ if ( isset( $options['url'] ) ) $this->url = $options['url'];
58
+ if ( isset( $options['method'] ) ) $this->method = $options['method'];
59
+ if ( isset( $options['parameters'] ) ) $this->parameters = $options['parameters'];
60
+ }
61
+
62
+ /**
63
+ * Build header
64
+ *
65
+ * @since 0.9.0
66
+ */
67
+ public function build_header() {
68
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
69
+ return null;
70
+ }
71
+
72
+ /**
73
+ * Build query url
74
+ *
75
+ * @since 0.9.0
76
+ */
77
+ public function build_query_url() {
78
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
79
+
80
+ $url = self::DEF_BASE_URL . '?' . http_build_query( $this->query_parameters , '' , '&' );
81
+
82
+ return $url;
83
+ }
84
+
85
+ /**
86
+ * Extract count
87
+ *
88
+ * @since 0.9.0
89
+ */
90
+ public function extract_count( $content ) {
91
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
92
+
93
+ $count = (int) -1;
94
+
95
+ if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
96
+ $json = json_decode( $content['data'], true );
97
+
98
+ if ( isset( $json[0]['total_count'] ) && is_numeric( $json[0]['total_count'] ) ) {
99
+ $count = (int) $json[0]['total_count'];
100
+ } else {
101
+ $count = (int) -1;
102
+ }
103
+ } else {
104
+ $count = (int) -1;
105
+ }
106
+
107
+ return $count;
108
+ }
109
+
110
+
111
+ public function set_query_parameter( $key, $value ) {
112
+ if ( $key === 'url' ) {
113
+ $this->query_parameters['urls'] = $value;
114
+ } else {
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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
126
+
127
+ if ( isset( $this->query_parameters['urls'] ) && $this->query_parameters['urls'] ) {
128
+ return true;
129
+ } else {
130
+ return false;
131
+ }
132
+ }
133
+
134
+ }
includes/class-share-google-strategy.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ class-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 - 2016 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 Share_Google_Strategy extends 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ /**
110
+ * Check if required paramters are included or not.
111
+ *
112
+ * @since 0.9.0
113
+ */
114
+ public function check_configuration() {
115
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
116
+
117
+ if ( isset( $this->query_parameters['url'] ) && $this->query_parameters['url'] ) {
118
+ return true;
119
+ } else {
120
+ return false;
121
+ }
122
+ }
123
+
124
+ }
includes/class-share-hatebu-strategy.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ class-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 - 2016 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 Share_Hatebu_Strategy extends 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ /**
106
+ * Check if required paramters are included or not.
107
+ *
108
+ * @since 0.9.0
109
+ */
110
+ public function check_configuration() {
111
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
112
+
113
+ if ( isset( $this->query_parameters['url'] ) && $this->query_parameters['url'] ) {
114
+ return true;
115
+ } else {
116
+ return false;
117
+ }
118
+ }
119
+
120
+ }
includes/class-share-lazy-cache-engine.php CHANGED
@@ -1,243 +1,236 @@
1
- <?php
2
- /*
3
- class-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
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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
31
-
32
-
33
- class Share_Lazy_Cache_Engine extends Share_Cache_Engine {
34
-
35
- /**
36
- * Prefix of cache ID
37
- */
38
- const DEF_TRANSIENT_PREFIX = 'scc_share_count_';
39
-
40
- /**
41
- * Cron name to schedule cache processing
42
- */
43
- const DEF_PRIME_CRON = 'scc_share_lazycache_prime';
44
-
45
- /**
46
- * Cron name to execute cache processing
47
- */
48
- const DEF_EXECUTE_CRON = 'scc_share_lazycache_exec';
49
-
50
- /**
51
- * Schedule name for cache processing
52
- */
53
- const DEF_EVENT_SCHEDULE = 'share_lazy_cache_event';
54
-
55
- /**
56
- * Schedule description for cache processing
57
- */
58
- const DEF_EVENT_DESCRIPTION = '[SCC] Share Lazy Cache Interval';
59
-
60
- /**
61
- * Interval cheking and caching target data
62
- */
63
- private $check_interval = 600;
64
-
65
- /**
66
- * Number of posts to check at a time
67
- */
68
- private $posts_per_check = 20;
69
-
70
- /**
71
- * Latency suffix
72
- */
73
- private $check_latency = 10;
74
-
75
- /**
76
- * Initialization
77
- *
78
- * @since 0.1.1
79
- */
80
- public function initialize( $options = array() ) {
81
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
82
-
83
- $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
84
- $this->prime_cron = self::DEF_PRIME_CRON;
85
- $this->execute_cron = self::DEF_EXECUTE_CRON;
86
- $this->event_schedule = self::DEF_EVENT_SCHEDULE;
87
- $this->event_description = self::DEF_EVENT_DESCRIPTION;
88
-
89
- $this->load_ratio = 0.5;
90
-
91
- if ( isset( $options['delegate'] ) ) $this->delegate = $options['delegate'];
92
- if ( isset( $options['crawler'] ) ) $this->crawler = $options['crawler'];
93
- if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
94
- if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
95
- if ( isset( $options['posts_per_check'] ) ) $this->posts_per_check = $options['posts_per_check'];
96
- if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
97
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
98
- if ( isset( $options['check_latency'] ) ) $this->check_latency = $options['check_latency'];
99
- if ( isset( $options['post_types'] ) ) $this->post_types = $options['post_types'];
100
- if ( isset( $options['scheme_migration_mode'] ) ) $this->scheme_migration_mode = $options['scheme_migration_mode'];
101
- if ( isset( $options['scheme_migration_date'] ) ) $this->scheme_migration_date = $options['scheme_migration_date'];
102
- if ( isset( $options['scheme_migration_exclude_keys'] ) ) $this->scheme_migration_exclude_keys = $options['scheme_migration_exclude_keys'];
103
- if ( isset( $options['cache_retry'] ) ) $this->cache_retry = $options['cache_retry'];
104
- if ( isset( $options['retry_limit'] ) ) $this->retry_limit = $options['retry_limit'];
105
-
106
- add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 1 );
107
-
108
- }
109
-
110
- /**
111
- * Register base schedule for this engine
112
- *
113
- * @since 0.1.0
114
- */
115
- public function register_schedule() {
116
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
117
-
118
- }
119
-
120
- /**
121
- * Unregister base schedule for this engine
122
- *
123
- * @since 0.1.0
124
- */
125
- public function unregister_schedule() {
126
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
127
-
128
- WP_Cron_Util::clear_scheduled_hook( $this->execute_cron );
129
- }
130
-
131
- /**
132
- * Schedule data retrieval and cache processing
133
- *
134
- * @since 0.2.0
135
- */
136
- public function prime_cache( $post_ID ) {
137
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
138
-
139
- $next_exec_time = time() + $this->check_latency;
140
-
141
- Common_Util::log( '[' . __METHOD__ . '] check_latency: ' . $this->check_latency );
142
- Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
143
-
144
- wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( $post_ID ) );
145
- }
146
-
147
- /**
148
- * Get and cache data of each published post
149
- *
150
- * @since 0.2.0
151
- */
152
- public function execute_cache( $post_ID ) {
153
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
154
-
155
- $cache_expiration = $this->get_cache_expiration();
156
-
157
- Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
158
-
159
- $transient_id = $this->get_cache_key( $post_ID );
160
-
161
- if ( $post_ID != 'home' ) {
162
- $url = get_permalink( $post_ID );
163
- $publish_date = get_the_date( 'Y/m/d', $post_ID );
164
- } else {
165
- $url = home_url( '/' );
166
- $publish_date = NULL;
167
- }
168
-
169
- $options = array(
170
- 'cache_key' => $transient_id,
171
- 'post_id' => $post_ID,
172
- 'target_url' => $url,
173
- 'target_sns' => $this->target_sns,
174
- 'publish_date' => $publish_date,
175
- 'cache_expiration' => $cache_expiration
176
- );
177
-
178
- // Primary cache
179
- $this->cache( $options );
180
-
181
- // Secondary cache
182
- $this->delegate_cache( $options );
183
- }
184
-
185
- /**
186
- * Get cache expiration based on current number of total post and page
187
- *
188
- * @since 0.1.1
189
- */
190
- protected function get_cache_expiration() {
191
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
192
-
193
- $posts_total = $this->get_posts_total();
194
-
195
- Common_Util::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
196
-
197
- return ceil( $posts_total / $this->posts_per_check ) * $this->check_interval * 3;
198
- }
199
-
200
- /**
201
- * Get total count of current published post and page
202
- *
203
- * @since 0.1.0
204
- */
205
- private function get_posts_total() {
206
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
207
-
208
- $query_args = array(
209
- 'post_type' => $this->post_types,
210
- 'post_status' => 'publish',
211
- 'nopaging' => true,
212
- 'update_post_term_cache' => false,
213
- 'update_post_meta_cache' => false
214
- );
215
-
216
- $posts_query = new WP_Query( $query_args );
217
-
218
- return $posts_query->found_posts;
219
- }
220
-
221
- /**
222
- * Initialize meta key for ranking
223
- *
224
- * @since 0.3.0
225
- */
226
- public function initialize_cache() {
227
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
228
-
229
- }
230
-
231
- /**
232
- * Clear meta key for ranking
233
- *
234
- * @since 0.3.0
235
- */
236
- public function clear_cache() {
237
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
238
-
239
- }
240
-
241
- }
242
-
243
- ?>
1
+ <?php
2
+ /*
3
+ class-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
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 - 2016 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 Share_Lazy_Cache_Engine extends Share_Cache_Engine {
31
+
32
+ /**
33
+ * Prefix of cache ID
34
+ */
35
+ const DEF_TRANSIENT_PREFIX = 'scc_share_count_';
36
+
37
+ /**
38
+ * Cron name to schedule cache processing
39
+ */
40
+ const DEF_PRIME_CRON = 'scc_share_lazycache_prime';
41
+
42
+ /**
43
+ * Cron name to execute cache processing
44
+ */
45
+ const DEF_EXECUTE_CRON = 'scc_share_lazycache_exec';
46
+
47
+ /**
48
+ * Schedule name for cache processing
49
+ */
50
+ const DEF_EVENT_SCHEDULE = 'share_lazy_cache_event';
51
+
52
+ /**
53
+ * Schedule description for cache processing
54
+ */
55
+ const DEF_EVENT_DESCRIPTION = '[SCC] Share Lazy Cache Interval';
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
+ * Initialization
74
+ *
75
+ * @since 0.1.1
76
+ */
77
+ public function initialize( $options = array() ) {
78
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
79
+
80
+ $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
81
+ $this->prime_cron = self::DEF_PRIME_CRON;
82
+ $this->execute_cron = self::DEF_EXECUTE_CRON;
83
+ $this->event_schedule = self::DEF_EVENT_SCHEDULE;
84
+ $this->event_description = self::DEF_EVENT_DESCRIPTION;
85
+
86
+ $this->load_ratio = 0.5;
87
+
88
+ if ( isset( $options['delegate'] ) ) $this->delegate = $options['delegate'];
89
+ if ( isset( $options['crawler'] ) ) $this->crawler = $options['crawler'];
90
+ if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
91
+ if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
92
+ if ( isset( $options['posts_per_check'] ) ) $this->posts_per_check = $options['posts_per_check'];
93
+ if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
94
+ if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
95
+ if ( isset( $options['check_latency'] ) ) $this->check_latency = $options['check_latency'];
96
+ if ( isset( $options['post_types'] ) ) $this->post_types = $options['post_types'];
97
+ if ( isset( $options['scheme_migration_mode'] ) ) $this->scheme_migration_mode = $options['scheme_migration_mode'];
98
+ if ( isset( $options['scheme_migration_date'] ) ) $this->scheme_migration_date = $options['scheme_migration_date'];
99
+ if ( isset( $options['scheme_migration_exclude_keys'] ) ) $this->scheme_migration_exclude_keys = $options['scheme_migration_exclude_keys'];
100
+ if ( isset( $options['cache_retry'] ) ) $this->cache_retry = $options['cache_retry'];
101
+ if ( isset( $options['retry_limit'] ) ) $this->retry_limit = $options['retry_limit'];
102
+
103
+ add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 1 );
104
+ }
105
+
106
+ /**
107
+ * Register base schedule for this engine
108
+ *
109
+ * @since 0.1.0
110
+ */
111
+ public function register_schedule() {
112
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
113
+ }
114
+
115
+ /**
116
+ * Unregister base schedule for this engine
117
+ *
118
+ * @since 0.1.0
119
+ */
120
+ public function unregister_schedule() {
121
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
122
+
123
+ WP_Cron_Util::clear_scheduled_hook( $this->execute_cron );
124
+ }
125
+
126
+ /**
127
+ * Schedule data retrieval and cache processing
128
+ *
129
+ * @since 0.2.0
130
+ */
131
+ public function prime_cache( $post_ID ) {
132
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
133
+
134
+ $next_exec_time = time() + $this->check_latency;
135
+
136
+ Common_Util::log( '[' . __METHOD__ . '] check_latency: ' . $this->check_latency );
137
+ Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
138
+
139
+ wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( $post_ID ) );
140
+ }
141
+
142
+ /**
143
+ * Get and cache data of each published post
144
+ *
145
+ * @since 0.2.0
146
+ */
147
+ public function execute_cache( $post_ID ) {
148
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
149
+
150
+ $cache_expiration = $this->get_cache_expiration();
151
+
152
+ Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
153
+
154
+ $transient_id = $this->get_cache_key( $post_ID );
155
+
156
+ if ( $post_ID != 'home' ) {
157
+ $url = get_permalink( $post_ID );
158
+ $publish_date = get_the_date( 'Y/m/d', $post_ID );
159
+ } else {
160
+ $url = home_url( '/' );
161
+ $publish_date = NULL;
162
+ }
163
+
164
+ $options = array(
165
+ 'cache_key' => $transient_id,
166
+ 'post_id' => $post_ID,
167
+ 'target_url' => $url,
168
+ 'target_sns' => $this->target_sns,
169
+ 'publish_date' => $publish_date,
170
+ 'cache_expiration' => $cache_expiration
171
+ );
172
+
173
+ // Primary cache
174
+ $this->cache( $options );
175
+
176
+ // Secondary cache
177
+ $this->delegate_cache( $options );
178
+ }
179
+
180
+ /**
181
+ * Get cache expiration based on current number of total post and page
182
+ *
183
+ * @since 0.1.1
184
+ */
185
+ protected function get_cache_expiration() {
186
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
187
+
188
+ $posts_total = $this->get_posts_total();
189
+
190
+ Common_Util::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
191
+
192
+ return ceil( $posts_total / $this->posts_per_check ) * $this->check_interval * 3;
193
+ }
194
+
195
+ /**
196
+ * Get total count of current published post and page
197
+ *
198
+ * @since 0.1.0
199
+ */
200
+ private function get_posts_total() {
201
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
202
+
203
+ $query_args = array(
204
+ 'post_type' => $this->post_types,
205
+ 'post_status' => 'publish',
206
+ 'nopaging' => true,
207
+ 'update_post_term_cache' => false,
208
+ 'update_post_meta_cache' => false
209
+ );
210
+
211
+ $posts_query = new WP_Query( $query_args );
212
+
213
+ return $posts_query->found_posts;
214
+ }
215
+
216
+ /**
217
+ * Initialize meta key for ranking
218
+ *
219
+ * @since 0.3.0
220
+ */
221
+ public function initialize_cache() {
222
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
223
+ }
224
+
225
+ /**
226
+ * Clear meta key for ranking
227
+ *
228
+ * @since 0.3.0
229
+ */
230
+ public function clear_cache() {
231
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
232
+ }
233
+
234
+ }
235
+
236
+ ?>
 
 
 
 
 
 
 
includes/class-share-pocket-strategy.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ class-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 - 2016 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 Share_Pocket_Strategy extends 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
+ Common_Util::log('[' . __METHOD__ . '] (line='. __LINE__ . ')');
44
+
45
+ $this->method = 'GET';
46
+ $this->query_parameters['v'] = '1';
47
+ $this->query_parameters['count'] = 'horizontal';
48
+ }
49
+
50
+ /**
51
+ * Initialization
52
+ *
53
+ * @since 0.9.0
54
+ */
55
+ public function initialize( $options = array() ) {
56
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
57
+
58
+ if ( isset( $options['url'] ) ) $this->url = $options['url'];
59
+ if ( isset( $options['method'] ) ) $this->method = $options['method'];
60
+ if ( isset( $options['parameters'] ) ) $this->parameters = $options['parameters'];
61
+ }
62
+
63
+ /**
64
+ * Build header
65
+ *
66
+ * @since 0.9.0
67
+ */
68
+ public function build_header() {
69
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
70
+ return null;
71
+ }
72
+
73
+ /**
74
+ * Build query url
75
+ *
76
+ * @since 0.9.0
77
+ */
78
+ public function build_query_url() {
79
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
80
+
81
+ $url = self::DEF_BASE_URL . '?' . http_build_query( $this->query_parameters , '' , '&' );
82
+
83
+ return $url;
84
+ }
85
+
86
+ /**
87
+ * Extract count
88
+ *
89
+ * @since 0.9.0
90
+ */
91
+ public function extract_count( $content ) {
92
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
93
+
94
+ $count = (int) -1;
95
+
96
+ if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
97
+
98
+ $return_code = preg_match( '/<em\sid=\"cnt\">([0-9]+)<\/em>/i', $content['data'], $matches );
99
+
100
+ if ( $return_code && isset( $matches[1] ) && is_numeric( $matches[1] ) ) {
101
+ $count = (int) $matches[1];
102
+ } else {
103
+ $count = (int) -1;
104
+ }
105
+ } else {
106
+ $count = (int) -1;
107
+ }
108
+
109
+ return $count;
110
+ }
111
+
112
+ /**
113
+ * Check if required paramters are included or not.
114
+ *
115
+ * @since 0.9.0
116
+ */
117
+ public function check_configuration() {
118
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
119
+
120
+ if ( isset( $this->query_parameters['url'] ) && $this->query_parameters['url'] ) {
121
+ return true;
122
+ } else {
123
+ return false;
124
+ }
125
+ }
126
+
127
+ }
includes/class-share-rescue-cache-engine.php CHANGED
@@ -1,339 +1,328 @@
1
- <?php
2
- /*
3
- class-share-rescue-cache-engine.php
4
-
5
- Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
31
-
32
-
33
- class Share_Rescue_Cache_Engine extends Share_Cache_Engine {
34
-
35
- /**
36
- * Prefix of cache ID
37
- */
38
- const DEF_TRANSIENT_PREFIX = 'scc_share_count_';
39
-
40
- /**
41
- * Cron name to schedule cache processing
42
- */
43
- const DEF_PRIME_CRON = 'scc_share_rescuecache_prime';
44
-
45
- /**
46
- * Cron name to execute cache processing
47
- */
48
- const DEF_EXECUTE_CRON = 'scc_share_rescuecache_exec';
49
-
50
- /**
51
- * Schedule name for cache processing
52
- */
53
- const DEF_EVENT_SCHEDULE = 'share_rescue_cache_event';
54
-
55
- /**
56
- * Schedule description for cache processing
57
- */
58
- const DEF_EVENT_DESCRIPTION = '[SCC] Share Rescue Cache Interval';
59
-
60
- /**
61
- * Interval cheking and caching target data
62
- */
63
- private $check_interval = 600;
64
-
65
- /**
66
- * Number of posts to check at a time
67
- */
68
- private $posts_per_check = 20;
69
-
70
- /**
71
- * Prefix of cache ID
72
- */
73
- private $meta_key_prefix = 'scc_share_count_';
74
-
75
- /**
76
- * Initialization
77
- *
78
- * @since 0.1.1
79
- */
80
- public function initialize( $options = array() ) {
81
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
82
-
83
- $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
84
- $this->prime_cron = self::DEF_PRIME_CRON;
85
- $this->execute_cron = self::DEF_EXECUTE_CRON;
86
- $this->event_schedule = self::DEF_EVENT_SCHEDULE;
87
- $this->event_description = self::DEF_EVENT_DESCRIPTION;
88
-
89
- if ( isset( $options['delegate'] ) ) $this->delegate = $options['delegate'];
90
- if ( isset( $options['crawler'] ) ) $this->crawler = $options['crawler'];
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['prime_cron'] ) ) $this->prime_cron = $options['prime_cron'];
96
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
97
- if ( isset( $options['event_schedule'] ) ) $this->event_schedule = $options['event_schedule'];
98
- if ( isset( $options['event_description'] ) ) $this->event_description = $options['event_description'];
99
- if ( isset( $options['post_types'] ) ) $this->post_types = $options['post_types'];
100
- if ( isset( $options['meta_key_prefix'] ) ) $this->meta_key_prefix = $options['meta_key_prefix'];
101
- if ( isset( $options['scheme_migration_mode'] ) ) $this->scheme_migration_mode = $options['scheme_migration_mode'];
102
- if ( isset( $options['scheme_migration_exclude_keys'] ) ) $this->scheme_migration_exclude_keys = $options['scheme_migration_exclude_keys'];
103
-
104
- add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
105
- add_action( $this->prime_cron, array( $this, 'prime_cache' ) );
106
- add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 1 );
107
-
108
- }
109
-
110
- /**
111
- * Register event schedule for this engine
112
- *
113
- * @since 0.1.0
114
- */
115
- public function schedule_check_interval( $schedules ) {
116
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
117
-
118
- $schedules[$this->event_schedule] = array(
119
- 'interval' => $this->check_interval,
120
- 'display' => $this->event_description
121
- );
122
-
123
- return $schedules;
124
- }
125
-
126
- /**
127
- * Schedule data retrieval and cache processing
128
- *
129
- * @since 0.1.0
130
- */
131
- public function prime_cache() {
132
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
133
-
134
- $next_exec_time = time() + $this->check_interval;
135
- $posts_total = $this->get_posts_total();
136
-
137
- Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
138
- Common_Util::log( '[' . __METHOD__ . '] posts_per_check: ' . $this->posts_per_check );
139
- Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
140
- Common_Util::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
141
-
142
- wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( Common_Util::short_hash( $next_exec_time ) ) );
143
-
144
- }
145
-
146
- /**
147
- * Get and cache data of each published post and page
148
- *
149
- * @since 0.1.0
150
- */
151
- public function execute_cache( $hash ) {
152
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
153
-
154
- Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
155
- Common_Util::log( '[' . __METHOD__ . '] posts_per_check: ' . $this->posts_per_check );
156
-
157
- $no_cache_post_IDs = array();
158
-
159
- $cache_expiration = $this->get_cache_expiration();
160
-
161
- Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
162
-
163
- $check_range_min = 0;
164
- $check_range_max = 0;
165
-
166
- $crons = WP_Cron_Util::get_scheduled_hook( 'scc_share_basecache_exec' );
167
-
168
- foreach ( $crons as $key => $cron ) {
169
- $hook = $cron['hook'];
170
- $timestamp = $cron['timestamp'];
171
- $offset = $cron['args'][0];
172
-
173
- Common_Util::log( '[' . __METHOD__ . '] hook: ' . $hook . ' offset: ' . $offset . ' timestamp: ' . $timestamp );
174
-
175
- //if ( time() + 300 < $timestamp ) {
176
- $check_range_min = $offset;
177
- $check_range_max = $offset + $this->posts_per_check;
178
- //}
179
- }
180
-
181
- $query_args = array(
182
- 'post_type' => $this->post_types,
183
- 'post_status' => 'publish',
184
- 'nopaging' => true,
185
- 'update_post_term_cache' => false,
186
- 'update_post_meta_cache' => false
187
- );
188
-
189
- $posts_query = new WP_Query( $query_args );
190
-
191
- if ( $posts_query->have_posts() ) {
192
- while ( $posts_query->have_posts() ) {
193
- $posts_query->the_post();
194
-
195
- $post_ID = get_the_ID();
196
-
197
- $full_cache_flag = true;
198
- $partial_cache_flag = false;
199
-
200
- foreach ( $this->target_sns as $sns => $active ) {
201
-
202
- if ( $active ) {
203
-
204
- $meta_key = $this->get_cache_key( $sns );
205
-
206
- $sns_count = get_post_meta( get_the_ID(), $meta_key, true );
207
-
208
- if ( isset( $sns_count ) && $sns_count >= 0 ) {
209
- $partial_cache_flag = true;
210
- } else {
211
- $full_cache_flag = false;
212
- }
213
-
214
- }
215
- }
216
-
217
- if ( $partial_cache_flag && $full_cache_flag ) {
218
- //full cache
219
- $transient_id = $this->get_cache_key( $post_ID );
220
-
221
- if ( false === ( $sns_counts = get_transient( $transient_id ) ) ) {
222
- if ( $post_ID < $check_range_min || $post_ID > $check_range_max ) {
223
- $no_cache_post_IDs[$post_ID] = 1;
224
- }
225
- }
226
- } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
227
- //partial cache
228
- $transient_id = $this->get_cache_key( $post_ID );
229
-
230
- if ( false === ( $sns_counts = get_transient( $transient_id ) ) ) {
231
- if ( $post_ID < $check_range_min || $post_ID > $check_range_max ) {
232
- $no_cache_post_IDs[$post_ID] = 2;
233
- }
234
- }
235
- } else {
236
- if ( $post_ID < $check_range_min || $post_ID > $check_range_max ) {
237
- $no_cache_post_IDs[$post_ID] = 3;
238
- }
239
- }
240
-
241
- }
242
- }
243
- wp_reset_postdata();
244
-
245
- Common_Util::log( '[' . __METHOD__ . '] no cache post IDs:');
246
-
247
- Common_Util::log( $no_cache_post_IDs );
248
-
249
- arsort( $no_cache_post_IDs, SORT_NUMERIC );
250
-
251
- $rescue_post_IDs = array_slice( $no_cache_post_IDs, 0, $this->posts_per_check, true );
252
-
253
- unset( $no_cache_post_IDs );
254
-
255
- Common_Util::log( $rescue_post_IDs );
256
-
257
- foreach ( $rescue_post_IDs as $post_ID => $priority ) {
258
- Common_Util::log( '[' . __METHOD__ . '] post_id: ' . $post_ID );
259
-
260
- $transient_id = $this->get_cache_key( $post_ID );
261
-
262
- $url = get_permalink( $post_ID );
263
-
264
- $options = array(
265
- 'cache_key' => $transient_id,
266
- 'post_id' => $post_ID,
267
- 'target_url' => $url,
268
- 'target_sns' => $this->target_sns,
269
- 'cache_expiration' => $cache_expiration
270
- );
271
-
272
- // Primary cache
273
- $this->cache( $options );
274
-
275
- // Secondary cache
276
- $this->delegate_cache( $options );
277
- }
278
-
279
- }
280
-
281
- /**
282
- * Get cache expiration based on current number of total post and page
283
- *
284
- * @since 0.1.1
285
- */
286
- protected function get_cache_expiration() {
287
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
288
-
289
- $posts_total = $this->get_posts_total();
290
-
291
- Common_Util::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
292
-
293
- return ( ( ceil( $posts_total / $this->posts_per_check ) + 2 ) * $this->check_interval ) + 2 * $this->check_interval;
294
- }
295
-
296
- /**
297
- * Initialize meta key for ranking
298
- *
299
- * @since 0.3.0
300
- */
301
- public function initialize_cache() {
302
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
303
-
304
- }
305
-
306
- /**
307
- * Clear meta key for ranking
308
- *
309
- * @since 0.3.0
310
- */
311
- public function clear_cache() {
312
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
313
-
314
- }
315
-
316
- /**
317
- * Get total count of current published post and page
318
- *
319
- * @since 0.1.0
320
- */
321
- private function get_posts_total() {
322
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
323
-
324
- $query_args = array(
325
- 'post_type' => $this->post_types,
326
- 'post_status' => 'publish',
327
- 'nopaging' => true,
328
- 'update_post_term_cache' => false,
329
- 'update_post_meta_cache' => false
330
- );
331
-
332
- $posts_query = new WP_Query( $query_args );
333
-
334
- return $posts_query->found_posts;
335
- }
336
-
337
- }
338
-
339
- ?>
1
+ <?php
2
+ /*
3
+ class-share-rescue-cache-engine.php
4
+
5
+ Description: This class is a data cache engine whitch get and cache data using wp-cron at regular intervals
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 - 2016 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 Share_Rescue_Cache_Engine extends Share_Cache_Engine {
31
+
32
+ /**
33
+ * Prefix of cache ID
34
+ */
35
+ const DEF_TRANSIENT_PREFIX = 'scc_share_count_';
36
+
37
+ /**
38
+ * Cron name to schedule cache processing
39
+ */
40
+ const DEF_PRIME_CRON = 'scc_share_rescuecache_prime';
41
+
42
+ /**
43
+ * Cron name to execute cache processing
44
+ */
45
+ const DEF_EXECUTE_CRON = 'scc_share_rescuecache_exec';
46
+
47
+ /**
48
+ * Schedule name for cache processing
49
+ */
50
+ const DEF_EVENT_SCHEDULE = 'share_rescue_cache_event';
51
+
52
+ /**
53
+ * Schedule description for cache processing
54
+ */
55
+ const DEF_EVENT_DESCRIPTION = '[SCC] Share Rescue Cache Interval';
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
+ * Prefix of cache ID
69
+ */
70
+ private $meta_key_prefix = 'scc_share_count_';
71
+
72
+ /**
73
+ * Initialization
74
+ *
75
+ * @since 0.1.1
76
+ */
77
+ public function initialize( $options = array() ) {
78
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
79
+
80
+ $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
81
+ $this->prime_cron = self::DEF_PRIME_CRON;
82
+ $this->execute_cron = self::DEF_EXECUTE_CRON;
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['crawler'] ) ) $this->crawler = $options['crawler'];
88
+ if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
89
+ if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
90
+ if ( isset( $options['posts_per_check'] ) ) $this->posts_per_check = $options['posts_per_check'];
91
+ if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
92
+ if ( isset( $options['prime_cron'] ) ) $this->prime_cron = $options['prime_cron'];
93
+ if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
94
+ if ( isset( $options['event_schedule'] ) ) $this->event_schedule = $options['event_schedule'];
95
+ if ( isset( $options['event_description'] ) ) $this->event_description = $options['event_description'];
96
+ if ( isset( $options['post_types'] ) ) $this->post_types = $options['post_types'];
97
+ if ( isset( $options['meta_key_prefix'] ) ) $this->meta_key_prefix = $options['meta_key_prefix'];
98
+ if ( isset( $options['scheme_migration_mode'] ) ) $this->scheme_migration_mode = $options['scheme_migration_mode'];
99
+ if ( isset( $options['scheme_migration_exclude_keys'] ) ) $this->scheme_migration_exclude_keys = $options['scheme_migration_exclude_keys'];
100
+
101
+ add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
102
+ add_action( $this->prime_cron, array( $this, 'prime_cache' ) );
103
+ add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 1 );
104
+ }
105
+
106
+ /**
107
+ * Register event schedule for this engine
108
+ *
109
+ * @since 0.1.0
110
+ */
111
+ public function schedule_check_interval( $schedules ) {
112
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
113
+
114
+ $schedules[$this->event_schedule] = array(
115
+ 'interval' => $this->check_interval,
116
+ 'display' => $this->event_description
117
+ );
118
+
119
+ return $schedules;
120
+ }
121
+
122
+ /**
123
+ * Schedule data retrieval and cache processing
124
+ *
125
+ * @since 0.1.0
126
+ */
127
+ public function prime_cache() {
128
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
129
+
130
+ $next_exec_time = time() + $this->check_interval;
131
+ $posts_total = $this->get_posts_total();
132
+
133
+ Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
134
+ Common_Util::log( '[' . __METHOD__ . '] posts_per_check: ' . $this->posts_per_check );
135
+ Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
136
+ Common_Util::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
137
+
138
+ wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( Common_Util::short_hash( $next_exec_time ) ) );
139
+ }
140
+
141
+ /**
142
+ * Get and cache data of each published post and page
143
+ *
144
+ * @since 0.1.0
145
+ */
146
+ public function execute_cache( $hash ) {
147
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
148
+
149
+ Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
150
+ Common_Util::log( '[' . __METHOD__ . '] posts_per_check: ' . $this->posts_per_check );
151
+
152
+ $no_cache_post_IDs = array();
153
+
154
+ $cache_expiration = $this->get_cache_expiration();
155
+
156
+ Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
157
+
158
+ $check_range_min = 0;
159
+ $check_range_max = 0;
160
+
161
+ $crons = WP_Cron_Util::get_scheduled_hook( 'scc_share_basecache_exec' );
162
+
163
+ foreach ( $crons as $key => $cron ) {
164
+ $hook = $cron['hook'];
165
+ $timestamp = $cron['timestamp'];
166
+ $offset = $cron['args'][0];
167
+
168
+ Common_Util::log( '[' . __METHOD__ . '] hook: ' . $hook . ' offset: ' . $offset . ' timestamp: ' . $timestamp );
169
+
170
+ //if ( time() + 300 < $timestamp ) {
171
+ $check_range_min = $offset;
172
+ $check_range_max = $offset + $this->posts_per_check;
173
+ //}
174
+ }
175
+
176
+ $query_args = array(
177
+ 'post_type' => $this->post_types,
178
+ 'post_status' => 'publish',
179
+ 'nopaging' => true,
180
+ 'update_post_term_cache' => false,
181
+ 'update_post_meta_cache' => false
182
+ );
183
+
184
+ $posts_query = new WP_Query( $query_args );
185
+
186
+ if ( $posts_query->have_posts() ) {
187
+ while ( $posts_query->have_posts() ) {
188
+ $posts_query->the_post();
189
+
190
+ $post_ID = get_the_ID();
191
+
192
+ $full_cache_flag = true;
193
+ $partial_cache_flag = false;
194
+
195
+ foreach ( $this->target_sns as $sns => $active ) {
196
+ if ( $active ) {
197
+ $meta_key = $this->get_cache_key( $sns );
198
+
199
+ $sns_count = get_post_meta( get_the_ID(), $meta_key, true );
200
+
201
+ if ( isset( $sns_count ) && $sns_count >= 0 ) {
202
+ $partial_cache_flag = true;
203
+ } else {
204
+ $full_cache_flag = false;
205
+ }
206
+ }
207
+ }
208
+
209
+ if ( $partial_cache_flag && $full_cache_flag ) {
210
+ //full cache
211
+ $transient_id = $this->get_cache_key( $post_ID );
212
+
213
+ if ( false === ( $sns_counts = get_transient( $transient_id ) ) ) {
214
+ if ( $post_ID < $check_range_min || $post_ID > $check_range_max ) {
215
+ $no_cache_post_IDs[$post_ID] = 1;
216
+ }
217
+ }
218
+ } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
219
+ //partial cache
220
+ $transient_id = $this->get_cache_key( $post_ID );
221
+
222
+ if ( false === ( $sns_counts = get_transient( $transient_id ) ) ) {
223
+ if ( $post_ID < $check_range_min || $post_ID > $check_range_max ) {
224
+ $no_cache_post_IDs[$post_ID] = 2;
225
+ }
226
+ }
227
+ } else {
228
+ if ( $post_ID < $check_range_min || $post_ID > $check_range_max ) {
229
+ $no_cache_post_IDs[$post_ID] = 3;
230
+ }
231
+ }
232
+ }
233
+ }
234
+ wp_reset_postdata();
235
+
236
+ Common_Util::log( '[' . __METHOD__ . '] no cache post IDs:');
237
+
238
+ Common_Util::log( $no_cache_post_IDs );
239
+
240
+ arsort( $no_cache_post_IDs, SORT_NUMERIC );
241
+
242
+ $rescue_post_IDs = array_slice( $no_cache_post_IDs, 0, $this->posts_per_check, true );
243
+
244
+ unset( $no_cache_post_IDs );
245
+
246
+ Common_Util::log( $rescue_post_IDs );
247
+
248
+ foreach ( $rescue_post_IDs as $post_ID => $priority ) {
249
+ Common_Util::log( '[' . __METHOD__ . '] post_id: ' . $post_ID );
250
+
251
+ $transient_id = $this->get_cache_key( $post_ID );
252
+
253
+ $url = get_permalink( $post_ID );
254
+
255
+ $options = array(
256
+ 'cache_key' => $transient_id,
257
+ 'post_id' => $post_ID,
258
+ 'target_url' => $url,
259
+ 'target_sns' => $this->target_sns,
260
+ 'cache_expiration' => $cache_expiration
261
+ );
262
+
263
+ // Primary cache
264
+ $this->cache( $options );
265
+
266
+ // Secondary cache
267
+ $this->delegate_cache( $options );
268
+ }
269
+
270
+ }
271
+
272
+ /**
273
+ * Get cache expiration based on current number of total post and page
274
+ *
275
+ * @since 0.1.1
276
+ */
277
+ protected function get_cache_expiration() {
278
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
279
+
280
+ $posts_total = $this->get_posts_total();
281
+
282
+ Common_Util::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
283
+
284
+ return ( ( ceil( $posts_total / $this->posts_per_check ) + 2 ) * $this->check_interval ) + 2 * $this->check_interval;
285
+ }
286
+
287
+ /**
288
+ * Initialize meta key for ranking
289
+ *
290
+ * @since 0.3.0
291
+ */
292
+ public function initialize_cache() {
293
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
294
+ }
295
+
296
+ /**
297
+ * Clear meta key for ranking
298
+ *
299
+ * @since 0.3.0
300
+ */
301
+ public function clear_cache() {
302
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
303
+ }
304
+
305
+ /**
306
+ * Get total count of current published post and page
307
+ *
308
+ * @since 0.1.0
309
+ */
310
+ private function get_posts_total() {
311
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
312
+
313
+ $query_args = array(
314
+ 'post_type' => $this->post_types,
315
+ 'post_status' => 'publish',
316
+ 'nopaging' => true,
317
+ 'update_post_term_cache' => false,
318
+ 'update_post_meta_cache' => false
319
+ );
320
+
321
+ $posts_query = new WP_Query( $query_args );
322
+
323
+ return $posts_query->found_posts;
324
+ }
325
+
326
+ }
327
+
328
+ ?>
 
 
 
 
 
 
 
 
 
 
 
includes/class-share-restore-cache-engine.php ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ class-share-restore-cache-engine.php
4
+
5
+ Description: This class is a data cache engine whitch restore cache data from second cache.
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 - 2016 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 Share_Restore_Cache_Engine extends Cache_Engine {
31
+
32
+ /**
33
+ * Prefix of cache ID
34
+ */
35
+ const DEF_TRANSIENT_PREFIX = 'scc_share_count_';
36
+
37
+ /**
38
+ * Cron name to schedule cache processing
39
+ */
40
+ const DEF_PRIME_CRON = 'scc_share_restorecache_prime';
41
+
42
+ /**
43
+ * Cron name to execute cache processing
44
+ */
45
+ const DEF_EXECUTE_CRON = 'scc_share_restorecache_exec';
46
+
47
+ /**
48
+ * Schedule name for cache processing
49
+ */
50
+ const DEF_EVENT_SCHEDULE = 'share_restore_cache_event';
51
+
52
+ /**
53
+ * Schedule description for cache processing
54
+ */
55
+ const DEF_EVENT_DESCRIPTION = '[SCC] Share Restore Cache Interval';
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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
84
+
85
+ $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
86
+ $this->prime_cron = self::DEF_PRIME_CRON;
87
+ $this->execute_cron = self::DEF_EXECUTE_CRON;
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
+ }
101
+
102
+ /**
103
+ * Register base schedule for this engine
104
+ *
105
+ * @since 0.1.0
106
+ */
107
+ public function register_schedule() {
108
+ 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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
118
+
119
+ 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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
129
+
130
+ $next_exec_time = time() + $this->check_latency;
131
+
132
+ Common_Util::log( '[' . __METHOD__ . '] check_latency: ' . $this->check_latency );
133
+ 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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
145
+
146
+ $cache_expiration = $this->get_cache_expiration();
147
+
148
+ 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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
169
+
170
+ $transient_id = $options['cache_key'];
171
+ $target_sns = $options['target_sns'];
172
+ $post_id = $options['post_id'];
173
+ $cache_expiration = $options['cache_expiration'];
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
+
192
+ }
193
+ }
194
+ }
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
+ }
206
+ }
207
+
208
+ $result = set_transient( $transient_id, $sns_counts, $cache_expiration );
209
+ }
210
+
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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
218
+
219
+ $posts_total = $this->get_posts_total();
220
+
221
+ Common_Util::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
222
+
223
+ return ceil( $posts_total / $this->posts_per_check ) * $this->check_interval * 3;
224
+ }
225
+
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
+ 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 );
243
+
244
+ return $posts_query->found_posts;
245
+ }
246
+
247
+ /**
248
+ * Initialize meta key for ranking
249
+ *
250
+ * @since 0.3.0
251
+ */
252
+ public function initialize_cache() {
253
+ 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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
263
+ }
264
+
265
+ }
266
+
267
+ ?>
includes/class-share-rush-cache-engine.php CHANGED
@@ -1,330 +1,325 @@
1
- <?php
2
- /*
3
- class-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
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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
31
-
32
-
33
- class Share_Rush_Cache_Engine extends Share_Cache_Engine {
34
-
35
- /**
36
- * Prefix of cache ID
37
- */
38
- const DEF_TRANSIENT_PREFIX = 'scc_share_count_';
39
-
40
- /**
41
- * Cron name to schedule cache processing
42
- */
43
- const DEF_PRIME_CRON = 'scc_share_rushcache_prime';
44
-
45
- /**
46
- * Cron name to execute cache processing
47
- */
48
- const DEF_EXECUTE_CRON = 'scc_share_rushcache_exec';
49
-
50
- /**
51
- * Schedule name for cache processing
52
- */
53
- const DEF_EVENT_SCHEDULE = 'share_rush_cache_event';
54
-
55
- /**
56
- * Schedule description for cache processing
57
- */
58
- const DEF_EVENT_DESCRIPTION = '[SCC] Share Rush Cache Interval';
59
-
60
- /**
61
- * Interval cheking and caching target data
62
- */
63
- private $check_interval = 600;
64
-
65
- /**
66
- * Number of posts to check at a time
67
- */
68
- private $posts_per_check = 20;
69
-
70
- /**
71
- * Offset suffix
72
- */
73
- private $offset_suffix = 'rush_offset';
74
-
75
- /**
76
- * Term considered as new content
77
- */
78
- private $new_content_term = 3;
79
-
80
- /**
81
- * Initialization
82
- *
83
- * @since 0.1.1
84
- */
85
- public function initialize( $options = array() ) {
86
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
87
-
88
- $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
89
- $this->prime_cron = self::DEF_PRIME_CRON;
90
- $this->execute_cron = self::DEF_EXECUTE_CRON;
91
- $this->event_schedule = self::DEF_EVENT_SCHEDULE;
92
- $this->event_description = self::DEF_EVENT_DESCRIPTION;
93
-
94
- $this->load_ratio = 0.5;
95
-
96
- if ( isset( $options['delegate'] ) ) $this->delegate = $options['delegate'];
97
- if ( isset( $options['crawler'] ) ) $this->crawler = $options['crawler'];
98
- if ( isset( $options['target_sns'] ) ) $this->target_sns = $options['target_sns'];
99
- if ( isset( $options['check_interval'] ) ) $this->check_interval = $options['check_interval'];
100
- if ( isset( $options['posts_per_check'] ) ) $this->posts_per_check = $options['posts_per_check'];
101
- if ( isset( $options['cache_prefix'] ) ) $this->cache_prefix = $options['cache_prefix'];
102
- if ( isset( $options['prime_cron'] ) ) $this->prime_cron = $options['prime_cron'];
103
- if ( isset( $options['execute_cron'] ) ) $this->execute_cron = $options['execute_cron'];
104
- if ( isset( $options['event_schedule'] ) ) $this->event_schedule = $options['event_schedule'];
105
- if ( isset( $options['event_description'] ) ) $this->event_description = $options['event_description'];
106
- if ( isset( $options['post_types'] ) ) $this->post_types = $options['post_types'];
107
- if ( isset( $options['new_content_term'] ) ) $this->new_content_term = $options['new_content_term'];
108
- if ( isset( $options['scheme_migration_mode'] ) ) $this->scheme_migration_mode = $options['scheme_migration_mode'];
109
- if ( isset( $options['scheme_migration_date'] ) ) $this->scheme_migration_date = $options['scheme_migration_date'];
110
- if ( isset( $options['scheme_migration_exclude_keys'] ) ) $this->scheme_migration_exclude_keys = $options['scheme_migration_exclude_keys'];
111
- if ( isset( $options['cache_retry'] ) ) $this->cache_retry = $options['cache_retry'];
112
- if ( isset( $options['retry_limit'] ) ) $this->retry_limit = $options['retry_limit'];
113
-
114
- add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
115
- add_action( $this->prime_cron, array( $this, 'prime_cache' ) );
116
- add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 2 );
117
-
118
- }
119
-
120
- /**
121
- * Register event schedule for this engine
122
- *
123
- * @since 0.1.0
124
- */
125
- public function schedule_check_interval( $schedules ) {
126
- 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.2.0
140
- */
141
- public function prime_cache() {
142
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
143
-
144
- $next_exec_time = time() + $this->check_interval;
145
- $posts_total = $this->get_posts_total();
146
-
147
- Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
148
- Common_Util::log( '[' . __METHOD__ . '] posts_per_check: ' . $this->posts_per_check );
149
- Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
150
- Common_Util::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
151
-
152
- $option_key = $this->get_cache_key($this->offset_suffix);
153
-
154
- if ( false === ( $posts_offset = get_option( $option_key ) ) ) {
155
- $posts_offset = 0;
156
- }
157
-
158
- Common_Util::log( '[' . __METHOD__ . '] posts_offset: ' . $posts_offset );
159
-
160
- wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( (int) $posts_offset, Common_Util::short_hash( $next_exec_time ) ) );
161
-
162
- $posts_offset = $posts_offset + $this->posts_per_check;
163
-
164
- if ( $posts_offset > $posts_total ) {
165
- $posts_offset = 0;
166
- }
167
-
168
- update_option( $option_key, $posts_offset );
169
-
170
- }
171
-
172
- /**
173
- * Get and cache data of each published post and page
174
- *
175
- * @since 0.2.0
176
- */
177
- public function execute_cache( $posts_offset, $hash ) {
178
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
179
-
180
- Common_Util::log( '[' . __METHOD__ . '] posts_offset: ' . $posts_offset );
181
- Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
182
- Common_Util::log( '[' . __METHOD__ . '] posts_per_check: ' . $this->posts_per_check );
183
-
184
- $cache_expiration = $this->get_cache_expiration();
185
-
186
- $term_threshold = $this->get_new_contet_term();
187
-
188
- Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
189
-
190
- Common_Util::log( '[' . __METHOD__ . '] term_threshold: ' . $term_threshold );
191
-
192
- $query_args = array(
193
- 'post_type' => $this->post_types,
194
- 'post_status' => 'publish',
195
- 'offset' => $posts_offset,
196
- 'posts_per_page' => $this->posts_per_check,
197
- 'date_query' => array(
198
- 'column' => 'post_date_gmt',
199
- 'after' => $term_threshold
200
- ),
201
- 'no_found_rows' => true,
202
- 'update_post_term_cache' => false,
203
- 'update_post_meta_cache' => false
204
- );
205
-
206
- $posts_query = new WP_Query( $query_args );
207
-
208
- if ( $posts_query->have_posts() ) {
209
- while ( $posts_query->have_posts() ) {
210
- $posts_query->the_post();
211
-
212
- $post_ID = get_the_ID();
213
-
214
- Common_Util::log( '[' . __METHOD__ . '] post_id: ' . $post_ID );
215
-
216
- $transient_id = $this->get_cache_key( $post_ID );
217
-
218
- $url = get_permalink( $post_ID );
219
-
220
- $options = array(
221
- 'cache_key' => $transient_id,
222
- 'post_id' => $post_ID,
223
- 'target_url' => $url,
224
- 'target_sns' => $this->target_sns,
225
- 'publish_date' => get_the_date( 'Y/m/d' ),
226
- 'cache_expiration' => $cache_expiration
227
- );
228
-
229
- // Primary cache
230
- $this->cache( $options );
231
-
232
- // Secondary cache
233
- $this->delegate_cache( $options );
234
- }
235
- }
236
- wp_reset_postdata();
237
- }
238
-
239
- /**
240
- * Get term considered as new content
241
- *
242
- * @since 0.4.0
243
- */
244
- private function get_new_contet_term() {
245
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
246
-
247
- $term_threshold = '3 days ago';
248
-
249
- if ( $this->new_content_term > 1 ) {
250
- $term_threshold = $this->new_content_term . ' days ago';
251
- } elseif ( $this->new_content_term == 1 ) {
252
- $term_threshold = $this->new_content_term . ' day ago';
253
- }
254
-
255
- return $term_threshold;
256
- }
257
-
258
- /**
259
- * Get cache expiration based on current number of total post and page
260
- *
261
- * @since 0.2.0
262
- */
263
- protected function get_cache_expiration() {
264
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
265
-
266
- $posts_total = $this->get_posts_total();
267
-
268
- Common_Util::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
269
-
270
- return ceil( $posts_total / $this->posts_per_check ) * $this->check_interval * 3;
271
- }
272
-
273
- /**
274
- * Get total count of current published post and page
275
- *
276
- * @since 0.2.0
277
- */
278
- private function get_posts_total() {
279
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
280
-
281
- $term_threshold = $this->get_new_contet_term();
282
-
283
- $query_args = array(
284
- 'post_type' => $this->post_types,
285
- 'post_status' => 'publish',
286
- 'date_query' => array(
287
- 'column' => 'post_date_gmt',
288
- 'after' => $term_threshold
289
- ),
290
- 'nopaging' => true,
291
- 'no_found_rows' => true,
292
- 'update_post_term_cache' => false,
293
- 'update_post_meta_cache' => false
294
- );
295
-
296
- $posts_query = new WP_Query( $query_args );
297
-
298
- return $posts_query->found_posts;
299
- }
300
-
301
- /**
302
- * Initialize meta key for ranking
303
- *
304
- * @since 0.3.0
305
- */
306
- public function initialize_cache() {
307
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
308
-
309
- $option_key = $this->get_cache_key( $this->offset_suffix );
310
-
311
- update_option( $option_key, 0 );
312
- }
313
-
314
- /**
315
- * Clear meta key for ranking
316
- *
317
- * @since 0.3.0
318
- */
319
- public function clear_cache() {
320
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
321
-
322
- $option_key = $this->get_cache_key( $this->offset_suffix );
323
-
324
- delete_option( $option_key );
325
-
326
- }
327
-
328
- }
329
-
330
- ?>
1
+ <?php
2
+ /*
3
+ class-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
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 - 2016 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 Share_Rush_Cache_Engine extends Share_Cache_Engine {
31
+
32
+ /**
33
+ * Prefix of cache ID
34
+ */
35
+ const DEF_TRANSIENT_PREFIX = 'scc_share_count_';
36
+
37
+ /**
38
+ * Cron name to schedule cache processing
39
+ */
40
+ const DEF_PRIME_CRON = 'scc_share_rushcache_prime';
41
+
42
+ /**
43
+ * Cron name to execute cache processing
44
+ */
45
+ const DEF_EXECUTE_CRON = 'scc_share_rushcache_exec';
46
+
47
+ /**
48
+ * Schedule name for cache processing
49
+ */
50
+ const DEF_EVENT_SCHEDULE = 'share_rush_cache_event';
51
+
52
+ /**
53
+ * Schedule description for cache processing
54
+ */
55
+ const DEF_EVENT_DESCRIPTION = '[SCC] Share Rush Cache Interval';
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
+ * Offset suffix
69
+ */
70
+ private $offset_suffix = 'rush_offset';
71
+
72
+ /**
73
+ * Term considered as new content
74
+ */
75
+ private $new_content_term = 3;
76
+
77
+ /**
78
+ * Initialization
79
+ *
80
+ * @since 0.1.1
81
+ */
82
+ public function initialize( $options = array() ) {
83
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
84
+
85
+ $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
86
+ $this->prime_cron = self::DEF_PRIME_CRON;
87
+ $this->execute_cron = self::DEF_EXECUTE_CRON;
88
+ $this->event_schedule = self::DEF_EVENT_SCHEDULE;
89
+ $this->event_description = self::DEF_EVENT_DESCRIPTION;
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['new_content_term'] ) ) $this->new_content_term = $options['new_content_term'];
105
+ if ( isset( $options['scheme_migration_mode'] ) ) $this->scheme_migration_mode = $options['scheme_migration_mode'];
106
+ if ( isset( $options['scheme_migration_date'] ) ) $this->scheme_migration_date = $options['scheme_migration_date'];
107
+ if ( isset( $options['scheme_migration_exclude_keys'] ) ) $this->scheme_migration_exclude_keys = $options['scheme_migration_exclude_keys'];
108
+ if ( isset( $options['cache_retry'] ) ) $this->cache_retry = $options['cache_retry'];
109
+ if ( isset( $options['retry_limit'] ) ) $this->retry_limit = $options['retry_limit'];
110
+
111
+ add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
112
+ add_action( $this->prime_cron, array( $this, 'prime_cache' ) );
113
+ add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 2 );
114
+ }
115
+
116
+ /**
117
+ * Register event schedule for this engine
118
+ *
119
+ * @since 0.1.0
120
+ */
121
+ public function schedule_check_interval( $schedules ) {
122
+ 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;
130
+ }
131
+
132
+ /**
133
+ * Schedule data retrieval and cache processing
134
+ *
135
+ * @since 0.2.0
136
+ */
137
+ public function prime_cache() {
138
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
139
+
140
+ $next_exec_time = time() + $this->check_interval;
141
+ $posts_total = $this->get_posts_total();
142
+
143
+ Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
144
+ Common_Util::log( '[' . __METHOD__ . '] posts_per_check: ' . $this->posts_per_check );
145
+ Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
146
+ 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
+ Common_Util::log( '[' . __METHOD__ . '] posts_offset: ' . $posts_offset );
155
+
156
+ wp_schedule_single_event( $next_exec_time, $this->execute_cron, array( (int) $posts_offset, Common_Util::short_hash( $next_exec_time ) ) );
157
+
158
+ $posts_offset = $posts_offset + $this->posts_per_check;
159
+
160
+ if ( $posts_offset > $posts_total ) {
161
+ $posts_offset = 0;
162
+ }
163
+
164
+ update_option( $option_key, $posts_offset );
165
+ }
166
+
167
+ /**
168
+ * Get and cache data of each published post and page
169
+ *
170
+ * @since 0.2.0
171
+ */
172
+ public function execute_cache( $posts_offset, $hash ) {
173
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
174
+
175
+ Common_Util::log( '[' . __METHOD__ . '] posts_offset: ' . $posts_offset );
176
+ Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
177
+ Common_Util::log( '[' . __METHOD__ . '] posts_per_check: ' . $this->posts_per_check );
178
+
179
+ $cache_expiration = $this->get_cache_expiration();
180
+
181
+ $term_threshold = $this->get_new_contet_term();
182
+
183
+ Common_Util::log( '[' . __METHOD__ . '] cache_expiration: ' . $cache_expiration );
184
+
185
+ Common_Util::log( '[' . __METHOD__ . '] term_threshold: ' . $term_threshold );
186
+
187
+ $query_args = array(
188
+ 'post_type' => $this->post_types,
189
+ 'post_status' => 'publish',
190
+ 'offset' => $posts_offset,
191
+ 'posts_per_page' => $this->posts_per_check,
192
+ 'date_query' => array(
193
+ 'column' => 'post_date_gmt',
194
+ 'after' => $term_threshold
195
+ ),
196
+ 'no_found_rows' => true,
197
+ 'update_post_term_cache' => false,
198
+ 'update_post_meta_cache' => false
199
+ );
200
+
201
+ $posts_query = new WP_Query( $query_args );
202
+
203
+ if ( $posts_query->have_posts() ) {
204
+ while ( $posts_query->have_posts() ) {
205
+ $posts_query->the_post();
206
+
207
+ $post_ID = get_the_ID();
208
+
209
+ Common_Util::log( '[' . __METHOD__ . '] post_id: ' . $post_ID );
210
+
211
+ $transient_id = $this->get_cache_key( $post_ID );
212
+
213
+ $url = get_permalink( $post_ID );
214
+
215
+ $options = array(
216
+ 'cache_key' => $transient_id,
217
+ 'post_id' => $post_ID,
218
+ 'target_url' => $url,
219
+ 'target_sns' => $this->target_sns,
220
+ 'publish_date' => get_the_date( 'Y/m/d' ),
221
+ 'cache_expiration' => $cache_expiration
222
+ );
223
+
224
+ // Primary cache
225
+ $this->cache( $options );
226
+
227
+ // Secondary cache
228
+ $this->delegate_cache( $options );
229
+ }
230
+ }
231
+ wp_reset_postdata();
232
+ }
233
+
234
+ /**
235
+ * Get term considered as new content
236
+ *
237
+ * @since 0.4.0
238
+ */
239
+ private function get_new_contet_term() {
240
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
241
+
242
+ $term_threshold = '3 days ago';
243
+
244
+ if ( $this->new_content_term > 1 ) {
245
+ $term_threshold = $this->new_content_term . ' days ago';
246
+ } elseif ( $this->new_content_term == 1 ) {
247
+ $term_threshold = $this->new_content_term . ' day ago';
248
+ }
249
+
250
+ return $term_threshold;
251
+ }
252
+
253
+ /**
254
+ * Get cache expiration based on current number of total post and page
255
+ *
256
+ * @since 0.2.0
257
+ */
258
+ protected function get_cache_expiration() {
259
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
260
+
261
+ $posts_total = $this->get_posts_total();
262
+
263
+ Common_Util::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
264
+
265
+ return ceil( $posts_total / $this->posts_per_check ) * $this->check_interval * 3;
266
+ }
267
+
268
+ /**
269
+ * Get total count of current published post and page
270
+ *
271
+ * @since 0.2.0
272
+ */
273
+ private function get_posts_total() {
274
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
275
+
276
+ $term_threshold = $this->get_new_contet_term();
277
+
278
+ $query_args = array(
279
+ 'post_type' => $this->post_types,
280
+ 'post_status' => 'publish',
281
+ 'date_query' => array(
282
+ 'column' => 'post_date_gmt',
283
+ 'after' => $term_threshold
284
+ ),
285
+ 'nopaging' => true,
286
+ 'no_found_rows' => true,
287
+ 'update_post_term_cache' => false,
288
+ 'update_post_meta_cache' => false
289
+ );
290
+
291
+ $posts_query = new WP_Query( $query_args );
292
+
293
+ return $posts_query->found_posts;
294
+ }
295
+
296
+ /**
297
+ * Initialize meta key for ranking
298
+ *
299
+ * @since 0.3.0
300
+ */
301
+ public function initialize_cache() {
302
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
303
+
304
+ $option_key = $this->get_cache_key( $this->offset_suffix );
305
+
306
+ update_option( $option_key, 0 );
307
+ }
308
+
309
+ /**
310
+ * Clear meta key for ranking
311
+ *
312
+ * @since 0.3.0
313
+ */
314
+ public function clear_cache() {
315
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
316
+
317
+ $option_key = $this->get_cache_key( $this->offset_suffix );
318
+
319
+ delete_option( $option_key );
320
+
321
+ }
322
+
323
+ }
324
+
325
+ ?>
 
 
 
 
 
includes/class-share-second-cache-engine.php CHANGED
@@ -1,366 +1,348 @@
1
- <?php
2
- /*
3
- class-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
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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
31
-
32
-
33
- class Share_Second_Cache_Engine extends Cache_Engine {
34
-
35
- /**
36
- * Prefix of cache ID
37
- */
38
- const DEF_TRANSIENT_PREFIX = 'scc_share_count_';
39
-
40
- /**
41
- * Cron name to schedule cache processing
42
- */
43
- const DEF_PRIME_CRON = 'scc_share_2ndcache_prime';
44
-
45
- /**
46
- * Cron name to execute cache processing
47
- */
48
- const DEF_EXECUTE_CRON = 'scc_share_2ndcache_exec';
49
-
50
- /**
51
- * Schedule name for cache processing
52
- */
53
- const DEF_EVENT_SCHEDULE = 'share_second_cache_event';
54
-
55
- /**
56
- * Schedule description for cache processing
57
- */
58
- const DEF_EVENT_DESCRIPTION = '[SCC] Share Second Cache Interval';
59
-
60
- /**
61
- * Interval cheking and caching target data
62
- */
63
- private $check_interval = 600;
64
-
65
- /**
66
- * Number of posts to check at a time
67
- */
68
- private $posts_per_check = 20;
69
-
70
- /**
71
- * Cache target
72
- */
73
- private $target_sns = array();
74
-
75
- /**
76
- * Cache post types
77
- */
78
- private $post_types = array( 'post', 'page' );
79
-
80
- /**
81
- * Crawl date key
82
- */
83
- private $crawl_date_key = NULL;
84
-
85
- /**
86
- * Initialization
87
- *
88
- * @since 0.1.1
89
- */
90
- public function initialize( $options = array() ) {
91
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
92
-
93
- $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
94
- $this->prime_cron = self::DEF_PRIME_CRON;
95
- $this->execute_cron = self::DEF_EXECUTE_CRON;
96
- $this->event_schedule = self::DEF_EVENT_SCHEDULE;
97
- $this->event_description = self::DEF_EVENT_DESCRIPTION;
98
-
99
- if ( isset( $options['delegate'] ) ) $this->delegate = $options['delegate'];
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['crawl_date_key'] ) ) $this->crawl_date_key = $options['crawl_date_key'];
110
-
111
- add_filter( 'cron_schedules', array( $this, 'schedule_check_interval' ) );
112
- add_action( $this->prime_cron, array( $this, 'prime_cache' ) );
113
- add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 0 );
114
-
115
- }
116
-
117
- /**
118
- * Register event schedule for this engine
119
- *
120
- * @since 0.1.0
121
- */
122
- public function schedule_check_interval( $schedules ) {
123
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
124
-
125
- $schedules[$this->event_schedule] = array(
126
- 'interval' => $this->check_interval,
127
- 'display' => $this->event_description
128
- );
129
-
130
- return $schedules;
131
- }
132
-
133
- /**
134
- * Schedule data retrieval and cache processing
135
- *
136
- * @since 0.3.0
137
- */
138
- public function prime_cache() {
139
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
140
-
141
- $next_exec_time = time() + $this->check_interval;
142
-
143
- Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
144
- Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
145
-
146
- wp_schedule_single_event( $next_exec_time, $this->execute_cron );
147
- }
148
-
149
- /**
150
- * Get and cache data of each published post and page
151
- *
152
- * @since 0.3.0
153
- */
154
- public function execute_cache() {
155
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
156
-
157
- $query_args = array(
158
- 'post_type' => $this->post_types,
159
- 'post_status' => 'publish',
160
- 'nopaging' => true,
161
- 'update_post_term_cache' => false,
162
- 'update_post_meta_cache' => false
163
- );
164
-
165
- $posts_query = new WP_Query( $query_args );
166
-
167
- if ( $posts_query->have_posts() ) {
168
- while ( $posts_query->have_posts() ) {
169
- $posts_query->the_post();
170
-
171
- $post_id = get_the_ID();
172
-
173
- $transient_id = $this->get_cache_key( $post_id );
174
-
175
- $url = get_permalink( $post_id );
176
-
177
- $options = array(
178
- 'cache_key' => $transient_id,
179
- 'post_id' => $post_id,
180
- 'target_sns' => $this->target_sns
181
- );
182
-
183
- $this->cache( $options );
184
-
185
- }
186
- }
187
- wp_reset_postdata();
188
-
189
- }
190
-
191
- /**
192
- * Get and cache data for a given post
193
- *
194
- * @since 0.1.1
195
- */
196
- public function cache( $options = array() ) {
197
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
198
-
199
- $transient_id = $options['cache_key'];
200
- $target_sns = $options['target_sns'];
201
- $post_id = $options['post_id'];
202
-
203
- $sns_counts = array();
204
-
205
- if ( $post_id !== 'home' ) {
206
- if ( false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
207
- foreach ( $target_sns as $sns => $active ) {
208
-
209
- if ( $active ) {
210
-
211
- $meta_key = $this->get_cache_key( $sns );
212
-
213
- if ( $sns !== $this->crawl_date_key ) {
214
-
215
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
216
- update_post_meta( $post_id, $meta_key, (int) $sns_counts[$sns] );
217
- } else {
218
- update_post_meta( $post_id, $meta_key, (int) -1 );
219
- }
220
- } else {
221
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] !== '' ) {
222
- update_post_meta( $post_id, $meta_key, $sns_counts[$sns] );
223
- } else {
224
- update_post_meta( $post_id, $meta_key, '' );
225
- }
226
- }
227
- }
228
- }
229
-
230
- }
231
- } else {
232
- if ( false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
233
-
234
- $option_key = $this->get_cache_key( 'home' );
235
-
236
- foreach ( $target_sns as $sns => $active ) {
237
-
238
- if ( $active ) {
239
-
240
- if ( $sns !== $this->crawl_date_key ) {
241
-
242
- if ( ! isset( $sns_counts[$sns] ) || $sns_counts[$sns] < 0 ) {
243
- $sns_counts[$sns] = (int) -1;
244
- }
245
-
246
- } else {
247
- if ( ! isset( $sns_counts[$sns] ) || $sns_counts[$sns] === '' ) {
248
- $sns_counts[$sns] = '';
249
- }
250
- }
251
- }
252
- }
253
-
254
- update_option( $option_key, $sns_counts );
255
- }
256
- }
257
-
258
- // Analysis
259
- $this->delegate_analysis( $options );
260
-
261
- }
262
-
263
- /**
264
- * Get cache expiration based on current number of total post and page
265
- *
266
- * @since 0.2.0
267
- */
268
- protected function get_cache_expiration() {
269
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
270
-
271
- return 0;
272
- }
273
-
274
- /**
275
- * Initialize meta key for ranking
276
- *
277
- * @since 0.3.0
278
- */
279
- public function initialize_cache() {
280
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
281
-
282
- $option_key = $this->get_cache_key( 'home' );
283
-
284
- $sns_counts = array();
285
-
286
- foreach ( $this->target_sns as $sns => $active ) {
287
- if ( $active ) {
288
- $sns_counts[$sns] = (int) -1;
289
- }
290
- }
291
-
292
- update_option( $option_key, $sns_counts );
293
-
294
- $query_args = array(
295
- 'post_type' => $this->post_types,
296
- 'post_status' => 'publish',
297
- 'nopaging' => true,
298
- 'update_post_term_cache' => false,
299
- 'update_post_meta_cache' => false
300
- );
301
-
302
- $posts_query = new WP_Query( $query_args );
303
-
304
- if ( $posts_query->have_posts() ) {
305
- while ( $posts_query->have_posts() ) {
306
- $posts_query->the_post();
307
-
308
- $post_id = get_the_ID();
309
-
310
- foreach ( $this->target_sns as $sns => $active ) {
311
-
312
- $meta_key = $this->get_cache_key( $sns );
313
-
314
- if ( $active ) {
315
- update_post_meta( $post_id, $meta_key, (int) -1 );
316
- }
317
- }
318
- }
319
- }
320
- wp_reset_postdata();
321
- }
322
-
323
- /**
324
- * Clear meta key for ranking
325
- *
326
- * @since 0.3.0
327
- */
328
- public function clear_cache() {
329
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
330
-
331
- $option_key = $this->get_cache_key( 'home' );
332
-
333
- delete_option( $option_key );
334
-
335
- foreach ( $this->target_sns as $sns => $active ) {
336
-
337
- if ( $active ) {
338
- $meta_key = $this->get_cache_key( $sns );
339
-
340
- delete_post_meta_by_key( $meta_key );
341
- }
342
- }
343
- }
344
-
345
- /**
346
- * Clear meta key for ranking
347
- *
348
- * @since 0.7.0
349
- */
350
- public function clear_cache_by_post_id( $post_id ) {
351
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
352
-
353
- foreach ( $this->target_sns as $sns => $active ) {
354
-
355
- if ( $active ) {
356
- $meta_key = $this->get_cache_key( $sns );
357
- delete_post_meta( $post_id, $meta_key );
358
- }
359
-
360
- }
361
-
362
- }
363
-
364
- }
365
-
366
- ?>
1
+ <?php
2
+ /*
3
+ class-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
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 - 2016 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 Share_Second_Cache_Engine extends Cache_Engine {
31
+
32
+ /**
33
+ * Prefix of cache ID
34
+ */
35
+ const DEF_TRANSIENT_PREFIX = 'scc_share_count_';
36
+
37
+ /**
38
+ * Cron name to schedule cache processing
39
+ */
40
+ const DEF_PRIME_CRON = 'scc_share_2ndcache_prime';
41
+
42
+ /**
43
+ * Cron name to execute cache processing
44
+ */
45
+ const DEF_EXECUTE_CRON = 'scc_share_2ndcache_exec';
46
+
47
+ /**
48
+ * Schedule name for cache processing
49
+ */
50
+ const DEF_EVENT_SCHEDULE = 'share_second_cache_event';
51
+
52
+ /**
53
+ * Schedule description for cache processing
54
+ */
55
+ const DEF_EVENT_DESCRIPTION = '[SCC] Share Second Cache Interval';
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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
89
+
90
+ $this->cache_prefix = self::DEF_TRANSIENT_PREFIX;
91
+ $this->prime_cron = self::DEF_PRIME_CRON;
92
+ $this->execute_cron = self::DEF_EXECUTE_CRON;
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' ) );
110
+ add_action( $this->execute_cron, array( $this, 'execute_cache' ), 10, 0 );
111
+ }
112
+
113
+ /**
114
+ * Register event schedule for this engine
115
+ *
116
+ * @since 0.1.0
117
+ */
118
+ public function schedule_check_interval( $schedules ) {
119
+ 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;
127
+ }
128
+
129
+ /**
130
+ * Schedule data retrieval and cache processing
131
+ *
132
+ * @since 0.3.0
133
+ */
134
+ public function prime_cache() {
135
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
136
+
137
+ $next_exec_time = time() + $this->check_interval;
138
+
139
+ Common_Util::log( '[' . __METHOD__ . '] check_interval: ' . $this->check_interval );
140
+ Common_Util::log( '[' . __METHOD__ . '] next_exec_time: ' . $next_exec_time );
141
+
142
+ wp_schedule_single_event( $next_exec_time, $this->execute_cron );
143
+ }
144
+
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
+ 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 );
162
+
163
+ if ( $posts_query->have_posts() ) {
164
+ while ( $posts_query->have_posts() ) {
165
+ $posts_query->the_post();
166
+
167
+ $post_id = get_the_ID();
168
+
169
+ $transient_id = $this->get_cache_key( $post_id );
170
+
171
+ $url = get_permalink( $post_id );
172
+
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 );
180
+ }
181
+ }
182
+ wp_reset_postdata();
183
+
184
+ }
185
+
186
+ /**
187
+ * Get and cache data for a given post
188
+ *
189
+ * @since 0.1.1
190
+ */
191
+ public function cache( $options = array() ) {
192
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
193
+
194
+ $transient_id = $options['cache_key'];
195
+ $target_sns = $options['target_sns'];
196
+ $post_id = $options['post_id'];
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
+ }
219
+ }
220
+ }
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
+ }
240
+ }
241
+
242
+ update_option( $option_key, $sns_counts );
243
+ }
244
+ }
245
+
246
+ // Analysis
247
+ $this->delegate_analysis( $options );
248
+
249
+ }
250
+
251
+ /**
252
+ * Get cache expiration based on current number of total post and page
253
+ *
254
+ * @since 0.2.0
255
+ */
256
+ protected function get_cache_expiration() {
257
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
258
+
259
+ return 0;
260
+ }
261
+
262
+ /**
263
+ * Initialize meta key for ranking
264
+ *
265
+ * @since 0.3.0
266
+ */
267
+ public function initialize_cache() {
268
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
269
+
270
+ $option_key = $this->get_cache_key( 'home' );
271
+
272
+ $sns_counts = array();
273
+
274
+ foreach ( $this->target_sns as $sns => $active ) {
275
+ if ( $active ) {
276
+ $sns_counts[$sns] = (int) -1;
277
+ }
278
+ }
279
+
280
+ update_option( $option_key, $sns_counts );
281
+
282
+ $query_args = array(
283
+ 'post_type' => $this->post_types,
284
+ 'post_status' => 'publish',
285
+ 'nopaging' => true,
286
+ 'update_post_term_cache' => false,
287
+ 'update_post_meta_cache' => false
288
+ );
289
+
290
+ $posts_query = new WP_Query( $query_args );
291
+
292
+ if ( $posts_query->have_posts() ) {
293
+ while ( $posts_query->have_posts() ) {
294
+ $posts_query->the_post();
295
+
296
+ $post_id = get_the_ID();
297
+
298
+ foreach ( $this->target_sns as $sns => $active ) {
299
+ $meta_key = $this->get_cache_key( $sns );
300
+
301
+ if ( $active ) {
302
+ update_post_meta( $post_id, $meta_key, (int) -1 );
303
+ }
304
+ }
305
+ }
306
+ }
307
+ wp_reset_postdata();
308
+ }
309
+
310
+ /**
311
+ * Clear meta key for ranking
312
+ *
313
+ * @since 0.3.0
314
+ */
315
+ public function clear_cache() {
316
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
317
+
318
+ $option_key = $this->get_cache_key( 'home' );
319
+ delete_option( $option_key );
320
+
321
+ foreach ( $this->target_sns as $sns => $active ) {
322
+ if ( $active ) {
323
+ $meta_key = $this->get_cache_key( $sns );
324
+ delete_post_meta_by_key( $meta_key );
325
+ }
326
+ }
327
+ }
328
+
329
+ /**
330
+ * Clear meta key for ranking
331
+ *
332
+ * @since 0.7.0
333
+ */
334
+ public function clear_cache_by_post_id( $post_id ) {
335
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
336
+
337
+ foreach ( $this->target_sns as $sns => $active ) {
338
+ if ( $active ) {
339
+ $meta_key = $this->get_cache_key( $sns );
340
+ delete_post_meta( $post_id, $meta_key );
341
+ }
342
+ }
343
+
344
+ }
345
+
346
+ }
347
+
348
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-share-twitter-strategy.php ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ class-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 - 2016 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 Share_Twitter_Strategy extends Crawl_Strategy {
31
+
32
+ /**
33
+ * SNS base url
34
+ */
35
+ const DEF_BASE_URL_JSOON = 'http://jsoon.digitiminimi.com/twitter/count.json';
36
+
37
+ const DEF_BASE_URL_OPENSHARECOUNT = 'http://opensharecount.com/count.json';
38
+
39
+ const DEF_BASE_URL_TWITCOUNT = 'http://opensharecount.com/count.json';
40
+
41
+ /**
42
+ * Class constarctor
43
+ * Hook onto all of the actions and filters needed by the plugin.
44
+ *
45
+ */
46
+ protected function __construct() {
47
+ Common_Util::log('[' . __METHOD__ . '] (line='. __LINE__ . ')');
48
+ $this->method = 'GET';
49
+ }
50
+
51
+ /**
52
+ * Initialization
53
+ *
54
+ * @since 0.9.0
55
+ */
56
+ public function initialize( $options = array() ) {
57
+ 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
+ if ( isset( $options['twitter_api'] ) ) $this->twitter_api = $options['twitter_api'];
63
+ }
64
+
65
+ /**
66
+ * Build header
67
+ *
68
+ * @since 0.9.0
69
+ */
70
+ public function build_header() {
71
+ 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
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
82
+
83
+ $base_url = self::DEF_BASE_URL_JSOON;
84
+
85
+ if ( isset( $this->twitter_api ) && $this->twitter_api ) {
86
+ if ( $this->twitter_api === SNS_Count_Cache::OPT_SHARE_TWITTER_API_JSOON ) {
87
+ $base_url = self::DEF_BASE_URL_JSOON;
88
+ } elseif ( $this->twitter_api === SNS_Count_Cache::OPT_SHARE_TWITTER_API_OPENSHARECOUNT ) {
89
+ $base_url = self::DEF_BASE_URL_OPENSHARECOUNT;
90
+ } elseif( $this->twitter_api === SNS_Count_Cache::OPT_SHARE_TWITTER_API_TWITCOUNT ) {
91
+ $base_url = self::DEF_BASE_URL_TWITCOUNT;
92
+ }
93
+ }
94
+
95
+ $url = $base_url . '?' . http_build_query( $this->query_parameters , '' , '&' );
96
+
97
+ return $url;
98
+ }
99
+
100
+ /**
101
+ * Extract count
102
+ *
103
+ * @since 0.9.0
104
+ */
105
+ public function extract_count( $content ) {
106
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
107
+
108
+ $count = (int) -1;
109
+
110
+ if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
111
+ $json = json_decode( $content['data'], 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
+
122
+ return $count;
123
+ }
124
+
125
+ public function set_query_parameter( $key, $value ) {
126
+ if ( isset( $this->twitter_api ) && $this->twitter_api ) {
127
+ if ( $this->twitter_api === SNS_Count_Cache::OPT_SHARE_TWITTER_API_JSOON ) {
128
+ if ( $key === 'url' ) {
129
+ if ( $value === home_url( '/', 'http' ) || $value === home_url( '/', 'https' ) ) {
130
+ $this->query_parameters[$key] = '"' . $value . '"';
131
+ } else {
132
+ $this->query_parameters[$key] = $value;
133
+ }
134
+ } else {
135
+ $this->query_parameters[$key] = $value;
136
+ }
137
+ } elseif ( $this->twitter_api === SNS_Count_Cache::OPT_SHARE_TWITTER_API_OPENSHARECOUNT ) {
138
+ $this->query_parameters[$key] = $value;
139
+ } elseif( $this->twitter_api === SNS_Count_Cache::OPT_SHARE_TWITTER_API_TWITCOUNT ) {
140
+ $this->query_parameters[$key] = $value;
141
+ }
142
+ } else {
143
+ $this->query_parameters[$key] = $value;
144
+ }
145
+ }
146
+
147
+ /**
148
+ * Check if required paramters are included or not.
149
+ *
150
+ * @since 0.9.0
151
+ */
152
+ public function check_configuration() {
153
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
154
+
155
+ if ( isset( $this->query_parameters['url'] ) && $this->query_parameters['url'] ) {
156
+ return true;
157
+ } else {
158
+ return false;
159
+ }
160
+ }
161
+
162
+ }
includes/class-sleep-throttle.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  class-sleep-throttle.php
4
 
5
- Description: sleep utility
6
  Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
@@ -10,8 +10,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
  */
11
 
12
  /*
13
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
 
16
  This program is free software; you can redistribute it and/or
17
  modify it under the terms of the GNU General Public License
@@ -26,65 +25,100 @@ GNU General Public License for more details.
26
  You should have received a copy of the GNU General Public License
27
  along with this program; if not, write to the Free Software
28
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
  */
31
 
32
  final class Sleep_Throttle {
33
-
34
- const SECOND_TO_MICRO_SECONDS = 1000000;
35
-
36
- private $load_ratio = 0.9;
37
-
38
- private $start_time = null;
39
-
40
- private $stop_time = null;
41
-
42
- private $sleep_time = null;
43
-
44
- function __construct( $load_ratio ) {
45
- $this->load_ratio = $load_ratio;
46
- }
47
-
48
- public function reset() {
49
- $this->start_time = null;
50
- $this->stop_time = null;
51
- $this->sleep_time = null;
52
- }
53
-
54
- public function start() {
55
- $this->start_time = gettimeofday( true );
56
- }
57
-
58
- public function stop() {
59
- $this->stop_time = gettimeofday( true );
60
-
61
- if ( ! is_null( $this->start_time ) && ! is_null( $this->stop_time ) ) {
62
- $this->sleep_time = $this->calculate_sleep_time( $this->load_ratio, $this->stop_time - $this->start_time );
63
- }
64
- }
65
-
66
- public function sleep() {
67
- if ( ! is_null( $this->sleep_time) && $this->sleep_time > 0 ) {
68
- usleep( $this->sleep_time * self::SECOND_TO_MICRO_SECONDS );
69
- }
70
- }
71
-
72
- public function get_sleep_time() {
73
- if ( ! is_null( $this->sleep_time) && $this->sleep_time > 0 ) {
74
- return $this->sleep_time;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  } else {
76
- return 0;
77
  }
78
- }
79
-
80
- private function calculate_sleep_time( $load_ratio, $time ) {
81
- if ( $time > 0.0 ) {
82
- return $time * ( 1 - $load_ratio ) / $load_ratio;
83
- } else {
84
- return 0;
85
- }
86
- }
87
 
88
  }
89
 
90
- ?>
2
  /*
3
  class-sleep-throttle.php
4
 
5
+ Description: sleep utility
6
  Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
10
  */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2016 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
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
  final class 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;
69
+ $this->stop_time = null;
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 );
85
+
86
+ if ( ! is_null( $this->start_time ) && ! is_null( $this->stop_time ) ) {
87
+ $this->sleep_time = $this->calculate_sleep_time( $this->load_ratio, $this->stop_time - $this->start_time );
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 ) {
116
+ return $time * ( 1 - $load_ratio ) / $load_ratio;
117
  } else {
118
+ return 0;
119
  }
120
+ }
 
 
 
 
 
 
 
 
121
 
122
  }
123
 
124
+ ?>
includes/class-wp-cron-util.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  class-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
@@ -10,8 +10,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
  */
11
 
12
  /*
13
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
 
16
  This program is free software; you can redistribute it and/or
17
  modify it under the terms of the GNU General Public License
@@ -26,10 +25,8 @@ GNU General Public License for more details.
26
  You should have received a copy of the GNU General Public License
27
  along with this program; if not, write to the Free Software
28
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
  */
31
 
32
-
33
  class WP_Cron_Util {
34
 
35
  /**
@@ -38,107 +35,107 @@ class WP_Cron_Util {
38
  *
39
  */
40
  protected function __construct() {
41
-
42
- }
43
 
44
-
45
- /**
46
- * Clear expired scheduled hook based related to specified hook name
 
 
47
  *
48
  * @since 0.4.1
49
- */
50
- public static function clear_expired_scheduled_hook( $hook, $elapsed_time ) {
51
  $crons = _get_cron_array();
52
-
53
  if ( empty( $crons ) ) return;
54
-
55
- $current_time = time();
56
-
57
- foreach( $crons as $timestamp => $cron ) {
58
- if( isset( $cron[$hook] ) ) {
59
- $duration = $timestamp - $current_time;
60
-
61
- if ( $duration > $elapsed_time ) {
62
- foreach ( $cron[$hook] as $signature => $data ) {
63
  wp_unschedule_event( $timestamp, $hook, $data['args'] );
64
  }
65
  }
66
- }
67
  }
68
- }
69
 
70
-
71
- /**
72
- * Clear scheduled hook based related to specified hook name
73
  *
74
  * @since 0.1.1
75
- */
76
- public static function clear_scheduled_hook( $hook ) {
77
  $crons = _get_cron_array();
78
-
79
  if ( empty( $crons ) ) return;
80
-
81
- foreach( $crons as $timestamp => $cron ) {
82
- if( isset( $cron[$hook] ) ) {
83
- foreach ( $cron[$hook] as $signature => $data ) {
84
  wp_unschedule_event( $timestamp, $hook, $data['args'] );
85
- }
86
- }
87
  }
88
- }
89
 
90
- /**
91
- * Return if there is the given hook or not
92
  *
93
  * @since 0.1.1
94
- */
95
- public static function is_scheduled_hook( $hook ) {
96
  $crons = _get_cron_array();
97
-
98
  if ( empty( $crons ) ) return false;
99
-
100
- foreach( $crons as $timestamp => $cron ) {
101
- if( isset( $cron[$hook] ) ) {
102
  return true;
103
  }
104
  }
105
-
106
- return false;
107
- }
108
 
109
- /**
110
- * Get scheduled hook related to specified hook name
 
 
 
111
  *
112
  * @since 0.1.1
113
- */
114
- public static function get_scheduled_hook( $hook ) {
115
- //Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
116
 
117
  $crons = _get_cron_array();
118
-
119
- $info = array();
120
- $index = 0;
121
-
122
  if ( empty( $crons ) ) return;
123
-
124
- foreach( $crons as $timestamp => $cron ) {
125
- if( isset( $cron[$hook] ) ) {
126
- //Common_Util::log( $cron[$hook] );
127
- foreach ( $cron[$hook] as $signature => $data ) {
128
-
129
- //Common_Util::log( '[' . __METHOD__ . '] hook: ' . $hook . ' offset: ' . $data['args'][0]. ' timestamp: ' . $timestamp );
130
-
131
- $info[$index]['hook'] = $hook;
132
- $info[$index]['timestamp'] = $timestamp;
133
- $info[$index]['args'] = $data['args'];
134
- //wp_unschedule_event( $timestamp, $hook, $data['args'] );
135
- }
136
- $index++;
137
- }
138
  }
139
-
140
- return $info;
141
- }
142
 
143
  /**
144
  *
@@ -149,7 +146,6 @@ class WP_Cron_Util {
149
  * @return int timestamp
150
  */
151
  public static function next_exec_time( $cronstring ) {
152
-
153
  $cron = array();
154
  $cronarray = array();
155
  //Cron string
@@ -290,11 +286,10 @@ class WP_Cron_Util {
290
  }
291
 
292
  return 2147483647;
293
- }
294
-
295
-
296
  }
297
 
298
 
299
 
300
- ?>
2
  /*
3
  class-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
10
  */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2016 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
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 WP_Cron_Util {
31
 
32
  /**
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();
49
+
50
  if ( empty( $crons ) ) return;
51
+
52
+ $current_time = time();
53
+
54
+ foreach( $crons as $timestamp => $cron ) {
55
+ if ( isset( $cron[$hook] ) ) {
56
+ $duration = $timestamp - $current_time;
57
+
58
+ if ( $duration > $elapsed_time ) {
59
+ foreach ( $cron[$hook] as $signature => $data ) {
60
  wp_unschedule_event( $timestamp, $hook, $data['args'] );
61
  }
62
  }
63
+ }
64
  }
65
+ }
66
 
67
+
68
+ /**
69
+ * Clear scheduled hook based related to specified hook name
70
  *
71
  * @since 0.1.1
72
+ */
73
+ public static function clear_scheduled_hook( $hook ) {
74
  $crons = _get_cron_array();
75
+
76
  if ( empty( $crons ) ) return;
77
+
78
+ foreach( $crons as $timestamp => $cron ) {
79
+ if ( isset( $cron[$hook] ) ) {
80
+ foreach ( $cron[$hook] as $signature => $data ) {
81
  wp_unschedule_event( $timestamp, $hook, $data['args'] );
82
+ }
83
+ }
84
  }
85
+ }
86
 
87
+ /**
88
+ * Return if there is the given hook or not
89
  *
90
  * @since 0.1.1
91
+ */
92
+ public static function is_scheduled_hook( $hook ) {
93
  $crons = _get_cron_array();
94
+
95
  if ( empty( $crons ) ) return false;
96
+
97
+ foreach( $crons as $timestamp => $cron ) {
98
+ if ( isset( $cron[$hook] ) ) {
99
  return true;
100
  }
101
  }
 
 
 
102
 
103
+ return false;
104
+ }
105
+
106
+ /**
107
+ * Get scheduled hook related to specified hook name
108
  *
109
  * @since 0.1.1
110
+ */
111
+ public static function get_scheduled_hook( $hook ) {
112
+ //Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
113
 
114
  $crons = _get_cron_array();
115
+
116
+ $info = array();
117
+ $index = 0;
118
+
119
  if ( empty( $crons ) ) return;
120
+
121
+ foreach( $crons as $timestamp => $cron ) {
122
+ if ( isset( $cron[$hook] ) ) {
123
+ //Common_Util::log( $cron[$hook] );
124
+ foreach ( $cron[$hook] as $signature => $data ) {
125
+
126
+ //Common_Util::log( '[' . __METHOD__ . '] hook: ' . $hook . ' offset: ' . $data['args'][0]. ' timestamp: ' . $timestamp );
127
+
128
+ $info[$index]['hook'] = $hook;
129
+ $info[$index]['timestamp'] = $timestamp;
130
+ $info[$index]['args'] = $data['args'];
131
+ //wp_unschedule_event( $timestamp, $hook, $data['args'] );
132
+ }
133
+ $index++;
134
+ }
135
  }
136
+
137
+ return $info;
138
+ }
139
 
140
  /**
141
  *
146
  * @return int timestamp
147
  */
148
  public static function next_exec_time( $cronstring ) {
 
149
  $cron = array();
150
  $cronarray = array();
151
  //Cron string
286
  }
287
 
288
  return 2147483647;
289
+ }
290
+
 
291
  }
292
 
293
 
294
 
295
+ ?>
includes/download.php CHANGED
@@ -1,79 +1,75 @@
1
- <?php
2
- /*
3
- download.php
4
-
5
- Description: Download page implementation
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
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
-
16
- This program is free software; you can redistribute it and/or
17
- modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
- of the License, or (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
- */
31
-
32
- require_once( '../../../../wp-blog-header.php' );
33
-
34
- $abs_path = WP_PLUGIN_DIR . '/sns-count-cache/data/sns-count-cache-data.csv';
35
-
36
- if ( isset( $_POST['_wpnonce'] ) && $_POST['_wpnonce'] && check_admin_referer( 'mynonce', '_wpnonce' ) ) {
37
-
38
- if ( isset( $_POST["download_data"] ) && $_POST["download_data"] === __( 'Download', SNS_Count_Cache::DOMAIN ) ) {
39
-
40
- if ( file_exists( $abs_path ) ) {
41
-
42
- $file_name = "sns-count-cache_data_" . date_i18n( 'YmdHis' ) . ".csv";
43
-
44
- header( 'Content-Type: application/octet-stream' );
45
- header( 'Content-Disposition: attachment; filename=' . $file_name );
46
-
47
- while ( ob_get_level() > 0 ) {
48
- ob_end_clean();
49
- }
50
-
51
- ob_start();
52
-
53
- if ( $fp = fopen( $abs_path, 'rb' ) ) {
54
-
55
- while( ! feof( $fp ) && ( connection_status() == 0 ) ) {
56
- echo fread( $fp, 8192 );
57
- ob_flush();
58
- }
59
-
60
- ob_flush();
61
- fclose( $fp );
62
-
63
- }
64
-
65
- ob_end_clean();
66
-
67
- } else {
68
- echo 'There is no exported file.';
69
- }
70
- }
71
-
72
- } else {
73
- status_header( '403' );
74
- echo 'Forbidden';
75
- }
76
-
77
- die();
78
-
79
- ?>
1
+ <?php
2
+ /*
3
+ download.php
4
+
5
+ Description: Download page implementation
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 - 2016 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
+ 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 );
44
+ header( 'Content-Disposition: attachment; filename="' . $file_name . '"' );
45
+ header( 'Content-Transfer-Encoding: binary' );
46
+ header( 'Content-Type: application/octet-stream' );
47
+
48
+ while ( ob_get_level() > 0 ) {
49
+ ob_end_clean();
50
+ }
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
+ }
58
+
59
+ ob_flush();
60
+ fclose( $fp );
61
+ }
62
+ ob_end_clean();
63
+ } else {
64
+ echo 'There is no exported file.';
65
+ }
66
+ }
67
+ } else {
68
+ wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
69
+ }
70
+ } else {
71
+ wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
72
+ }
73
+ die();
74
+
75
+ ?>
 
 
 
 
includes/interface-cache-order.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  interface-cache-order.php
4
 
5
- Description: This is a interface
6
  Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
@@ -10,8 +10,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
  */
11
 
12
  /*
13
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
 
16
  This program is free software; you can redistribute it and/or
17
  modify it under the terms of the GNU General Public License
@@ -26,11 +25,10 @@ GNU General Public License for more details.
26
  You should have received a copy of the GNU General Public License
27
  along with this program; if not, write to the Free Software
28
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
  */
31
 
32
  interface Cache_Order {
33
  public function order_cache( Cache_Engine $engine, $options = array() );
34
  }
35
 
36
- ?>
2
  /*
3
  interface-cache-order.php
4
 
5
+ Description: This is a interface
6
  Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
10
  */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2016 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
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
  interface Cache_Order {
31
  public function order_cache( Cache_Engine $engine, $options = array() );
32
  }
33
 
34
+ ?>
includes/interface-order.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  interface-cache-order.php
4
 
5
- Description: This is a interface
6
  Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
@@ -10,8 +10,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.txt
10
  */
11
 
12
  /*
13
-
14
- Copyright (C) 2014 - 2015 Daisuke Maruyama
15
 
16
  This program is free software; you can redistribute it and/or
17
  modify it under the terms of the GNU General Public License
@@ -26,12 +25,11 @@ GNU General Public License for more details.
26
  You should have received a copy of the GNU General Public License
27
  along with this program; if not, write to the Free Software
28
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
-
30
  */
31
 
32
  interface Order {
33
  public function order_cache( Cache_Engine $engine, $options = array() );
34
- public function order_analysis( Cache_Engine $engine, $options = array() );
35
  }
36
 
37
- ?>
2
  /*
3
  interface-cache-order.php
4
 
5
+ Description: This is a interface
6
  Author: Daisuke Maruyama
7
  Author URI: http://marubon.info/
8
  License: GPL2 or later
10
  */
11
 
12
  /*
13
+ Copyright (C) 2014 - 2016 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
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
  interface Order {
31
  public function order_cache( Cache_Engine $engine, $options = array() );
32
+ public function order_analysis( Cache_Engine $engine, $options = array() );
33
  }
34
 
35
+ ?>
index.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ index.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 - 2016 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
+ require_once( '../../../wp-load.php' );
31
+
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
+ }
42
+ } elseif ( $_GET['action'] === 'facebook-auth' ) {
43
+ if ( check_admin_referer( 'facebook-auth', 'state' ) ) {
44
+ $redirect_url = admin_url( 'admin.php?page=scc-setting' ) . '&action=facebook-auth&code=' . $_GET['code'] .'&_wpnonce=' . $_GET['state'];
45
+ wp_safe_redirect( $redirect_url );
46
+ exit;
47
+ }
48
+ } else {
49
+ wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
50
+ }
51
+ } else {
52
+ wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
53
+ }
54
+ } else {
55
+ wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
56
+ }
57
+
58
+ ?>
js/highlight.pack.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ /*! highlight.js v9.3.0 | BSD3 License | git.io/hljslicense */
2
+ !function(e){var n="object"==typeof window&&window||"object"==typeof self&&self;"undefined"!=typeof exports?e(exports):n&&(n.hljs=e({}),"function"==typeof define&&define.amd&&define([],function(){return n.hljs}))}(function(e){function n(e){return e.replace(/&/gm,"&amp;").replace(/</gm,"&lt;").replace(/>/gm,"&gt;")}function t(e){return e.nodeName.toLowerCase()}function r(e,n){var t=e&&e.exec(n);return t&&0==t.index}function a(e){return/^(no-?highlight|plain|text)$/i.test(e)}function i(e){var n,t,r,i=e.className+" ";if(i+=e.parentNode?e.parentNode.className:"",t=/\blang(?:uage)?-([\w-]+)\b/i.exec(i))return w(t[1])?t[1]:"no-highlight";for(i=i.split(/\s+/),n=0,r=i.length;r>n;n++)if(w(i[n])||a(i[n]))return i[n]}function o(e,n){var t,r={};for(t in e)r[t]=e[t];if(n)for(t in n)r[t]=n[t];return r}function u(e){var n=[];return function r(e,a){for(var i=e.firstChild;i;i=i.nextSibling)3==i.nodeType?a+=i.nodeValue.length:1==i.nodeType&&(n.push({event:"start",offset:a,node:i}),a=r(i,a),t(i).match(/br|hr|img|input/)||n.push({event:"stop",offset:a,node:i}));return a}(e,0),n}function c(e,r,a){function i(){return e.length&&r.length?e[0].offset!=r[0].offset?e[0].offset<r[0].offset?e:r:"start"==r[0].event?e:r:e.length?e:r}function o(e){function r(e){return" "+e.nodeName+'="'+n(e.value)+'"'}f+="<"+t(e)+Array.prototype.map.call(e.attributes,r).join("")+">"}function u(e){f+="</"+t(e)+">"}function c(e){("start"==e.event?o:u)(e.node)}for(var s=0,f="",l=[];e.length||r.length;){var g=i();if(f+=n(a.substr(s,g[0].offset-s)),s=g[0].offset,g==e){l.reverse().forEach(u);do c(g.splice(0,1)[0]),g=i();while(g==e&&g.length&&g[0].offset==s);l.reverse().forEach(o)}else"start"==g[0].event?l.push(g[0].node):l.pop(),c(g.splice(0,1)[0])}return f+n(a.substr(s))}function s(e){function n(e){return e&&e.source||e}function t(t,r){return new RegExp(n(t),"m"+(e.cI?"i":"")+(r?"g":""))}function r(a,i){if(!a.compiled){if(a.compiled=!0,a.k=a.k||a.bK,a.k){var u={},c=function(n,t){e.cI&&(t=t.toLowerCase()),t.split(" ").forEach(function(e){var t=e.split("|");u[t[0]]=[n,t[1]?Number(t[1]):1]})};"string"==typeof a.k?c("keyword",a.k):Object.keys(a.k).forEach(function(e){c(e,a.k[e])}),a.k=u}a.lR=t(a.l||/\w+/,!0),i&&(a.bK&&(a.b="\\b("+a.bK.split(" ").join("|")+")\\b"),a.b||(a.b=/\B|\b/),a.bR=t(a.b),a.e||a.eW||(a.e=/\B|\b/),a.e&&(a.eR=t(a.e)),a.tE=n(a.e)||"",a.eW&&i.tE&&(a.tE+=(a.e?"|":"")+i.tE)),a.i&&(a.iR=t(a.i)),void 0===a.r&&(a.r=1),a.c||(a.c=[]);var s=[];a.c.forEach(function(e){e.v?e.v.forEach(function(n){s.push(o(e,n))}):s.push("self"==e?a:e)}),a.c=s,a.c.forEach(function(e){r(e,a)}),a.starts&&r(a.starts,i);var f=a.c.map(function(e){return e.bK?"\\.?("+e.b+")\\.?":e.b}).concat([a.tE,a.i]).map(n).filter(Boolean);a.t=f.length?t(f.join("|"),!0):{exec:function(){return null}}}}r(e)}function f(e,t,a,i){function o(e,n){for(var t=0;t<n.c.length;t++)if(r(n.c[t].bR,e))return n.c[t]}function u(e,n){if(r(e.eR,n)){for(;e.endsParent&&e.parent;)e=e.parent;return e}return e.eW?u(e.parent,n):void 0}function c(e,n){return!a&&r(n.iR,e)}function g(e,n){var t=N.cI?n[0].toLowerCase():n[0];return e.k.hasOwnProperty(t)&&e.k[t]}function p(e,n,t,r){var a=r?"":E.classPrefix,i='<span class="'+a,o=t?"":"</span>";return i+=e+'">',i+n+o}function h(){if(!k.k)return n(M);var e="",t=0;k.lR.lastIndex=0;for(var r=k.lR.exec(M);r;){e+=n(M.substr(t,r.index-t));var a=g(k,r);a?(B+=a[1],e+=p(a[0],n(r[0]))):e+=n(r[0]),t=k.lR.lastIndex,r=k.lR.exec(M)}return e+n(M.substr(t))}function d(){var e="string"==typeof k.sL;if(e&&!R[k.sL])return n(M);var t=e?f(k.sL,M,!0,y[k.sL]):l(M,k.sL.length?k.sL:void 0);return k.r>0&&(B+=t.r),e&&(y[k.sL]=t.top),p(t.language,t.value,!1,!0)}function b(){L+=void 0!==k.sL?d():h(),M=""}function v(e,n){L+=e.cN?p(e.cN,"",!0):"",k=Object.create(e,{parent:{value:k}})}function m(e,n){if(M+=e,void 0===n)return b(),0;var t=o(n,k);if(t)return t.skip?M+=n:(t.eB&&(M+=n),b(),t.rB||t.eB||(M=n)),v(t,n),t.rB?0:n.length;var r=u(k,n);if(r){var a=k;a.skip?M+=n:(a.rE||a.eE||(M+=n),b(),a.eE&&(M=n));do k.cN&&(L+="</span>"),k.skip||(B+=k.r),k=k.parent;while(k!=r.parent);return r.starts&&v(r.starts,""),a.rE?0:n.length}if(c(n,k))throw new Error('Illegal lexeme "'+n+'" for mode "'+(k.cN||"<unnamed>")+'"');return M+=n,n.length||1}var N=w(e);if(!N)throw new Error('Unknown language: "'+e+'"');s(N);var x,k=i||N,y={},L="";for(x=k;x!=N;x=x.parent)x.cN&&(L=p(x.cN,"",!0)+L);var M="",B=0;try{for(var C,j,I=0;;){if(k.t.lastIndex=I,C=k.t.exec(t),!C)break;j=m(t.substr(I,C.index-I),C[0]),I=C.index+j}for(m(t.substr(I)),x=k;x.parent;x=x.parent)x.cN&&(L+="</span>");return{r:B,value:L,language:e,top:k}}catch(O){if(-1!=O.message.indexOf("Illegal"))return{r:0,value:n(t)};throw O}}function l(e,t){t=t||E.languages||Object.keys(R);var r={r:0,value:n(e)},a=r;return t.filter(w).forEach(function(n){var t=f(n,e,!1);t.language=n,t.r>a.r&&(a=t),t.r>r.r&&(a=r,r=t)}),a.language&&(r.second_best=a),r}function g(e){return E.tabReplace&&(e=e.replace(/^((<[^>]+>|\t)+)/gm,function(e,n){return n.replace(/\t/g,E.tabReplace)})),E.useBR&&(e=e.replace(/\n/g,"<br>")),e}function p(e,n,t){var r=n?x[n]:t,a=[e.trim()];return e.match(/\bhljs\b/)||a.push("hljs"),-1===e.indexOf(r)&&a.push(r),a.join(" ").trim()}function h(e){var n=i(e);if(!a(n)){var t;E.useBR?(t=document.createElementNS("http://www.w3.org/1999/xhtml","div"),t.innerHTML=e.innerHTML.replace(/\n/g,"").replace(/<br[ \/]*>/g,"\n")):t=e;var r=t.textContent,o=n?f(n,r,!0):l(r),s=u(t);if(s.length){var h=document.createElementNS("http://www.w3.org/1999/xhtml","div");h.innerHTML=o.value,o.value=c(s,u(h),r)}o.value=g(o.value),e.innerHTML=o.value,e.className=p(e.className,n,o.language),e.result={language:o.language,re:o.r},o.second_best&&(e.second_best={language:o.second_best.language,re:o.second_best.r})}}function d(e){E=o(E,e)}function b(){if(!b.called){b.called=!0;var e=document.querySelectorAll("pre code");Array.prototype.forEach.call(e,h)}}function v(){addEventListener("DOMContentLoaded",b,!1),addEventListener("load",b,!1)}function m(n,t){var r=R[n]=t(e);r.aliases&&r.aliases.forEach(function(e){x[e]=n})}function N(){return Object.keys(R)}function w(e){return e=(e||"").toLowerCase(),R[e]||R[x[e]]}var E={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0},R={},x={};return e.highlight=f,e.highlightAuto=l,e.fixMarkup=g,e.highlightBlock=h,e.configure=d,e.initHighlighting=b,e.initHighlightingOnLoad=v,e.registerLanguage=m,e.listLanguages=N,e.getLanguage=w,e.inherit=o,e.IR="[a-zA-Z]\\w*",e.UIR="[a-zA-Z_]\\w*",e.NR="\\b\\d+(\\.\\d+)?",e.CNR="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",e.BNR="\\b(0b[01]+)",e.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",e.BE={b:"\\\\[\\s\\S]",r:0},e.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[e.BE]},e.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[e.BE]},e.PWM={b:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|like)\b/},e.C=function(n,t,r){var a=e.inherit({cN:"comment",b:n,e:t,c:[]},r||{});return a.c.push(e.PWM),a.c.push({cN:"doctag",b:"(?:TODO|FIXME|NOTE|BUG|XXX):",r:0}),a},e.CLCM=e.C("//","$"),e.CBCM=e.C("/\\*","\\*/"),e.HCM=e.C("#","$"),e.NM={cN:"number",b:e.NR,r:0},e.CNM={cN:"number",b:e.CNR,r:0},e.BNM={cN:"number",b:e.BNR,r:0},e.CSSNM={cN:"number",b:e.NR+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",r:0},e.RM={cN:"regexp",b:/\//,e:/\/[gimuy]*/,i:/\n/,c:[e.BE,{b:/\[/,e:/\]/,r:0,c:[e.BE]}]},e.TM={cN:"title",b:e.IR,r:0},e.UTM={cN:"title",b:e.UIR,r:0},e.METHOD_GUARD={b:"\\.\\s*"+e.UIR,r:0},e});hljs.registerLanguage("xml",function(s){var e="[A-Za-z0-9\\._:-]+",t={eW:!0,i:/</,r:0,c:[{cN:"attr",b:e,r:0},{b:/=\s*/,r:0,c:[{cN:"string",endsParent:!0,v:[{b:/"/,e:/"/},{b:/'/,e:/'/},{b:/[^\s"'=<>`]+/}]}]}]};return{aliases:["html","xhtml","rss","atom","xsl","plist"],cI:!0,c:[{cN:"meta",b:"<!DOCTYPE",e:">",r:10,c:[{b:"\\[",e:"\\]"}]},s.C("<!--","-->",{r:10}),{b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{b:/<\?(php)?/,e:/\?>/,sL:"php",c:[{b:"/\\*",e:"\\*/",skip:!0}]},{cN:"tag",b:"<style(?=\\s|>|$)",e:">",k:{name:"style"},c:[t],starts:{e:"</style>",rE:!0,sL:["css","xml"]}},{cN:"tag",b:"<script(?=\\s|>|$)",e:">",k:{name:"script"},c:[t],starts:{e:"</script>",rE:!0,sL:["actionscript","javascript","handlebars","xml"]}},{cN:"meta",v:[{b:/<\?xml/,e:/\?>/,r:10},{b:/<\?\w+/,e:/\?>/}]},{cN:"tag",b:"</?",e:"/?>",c:[{cN:"name",b:/[^\/><\s]+/,r:0},t]}]}});hljs.registerLanguage("php",function(e){var c={b:"\\$+[a-zA-Z_-ÿ][a-zA-Z0-9_-ÿ]*"},a={cN:"meta",b:/<\?(php)?|\?>/},i={cN:"string",c:[e.BE,a],v:[{b:'b"',e:'"'},{b:"b'",e:"'"},e.inherit(e.ASM,{i:null}),e.inherit(e.QSM,{i:null})]},t={v:[e.BNM,e.CNM]};return{aliases:["php3","php4","php5","php6"],cI:!0,k:"and include_once list abstract global private echo interface as static endswitch array null if endwhile or const for endforeach self var while isset public protected exit foreach throw elseif include __FILE__ empty require_once do xor return parent clone use __CLASS__ __LINE__ else break print eval new catch __METHOD__ case exception default die require __FUNCTION__ enddeclare final try switch continue endfor endif declare unset true false trait goto instanceof insteadof __DIR__ __NAMESPACE__ yield finally",c:[e.HCM,e.C("//","$",{c:[a]}),e.C("/\\*","\\*/",{c:[{cN:"doctag",b:"@[A-Za-z]+"}]}),e.C("__halt_compiler.+?;",!1,{eW:!0,k:"__halt_compiler",l:e.UIR}),{cN:"string",b:/<<<['"]?\w+['"]?$/,e:/^\w+;?$/,c:[e.BE,{cN:"subst",v:[{b:/\$\w+/},{b:/\{\$/,e:/\}/}]}]},a,c,{b:/(::|->)+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/},{cN:"function",bK:"function",e:/[;{]/,eE:!0,i:"\\$|\\[|%",c:[e.UTM,{cN:"params",b:"\\(",e:"\\)",c:["self",c,e.CBCM,i,t]}]},{cN:"class",bK:"class interface",e:"{",eE:!0,i:/[:\(\$"]/,c:[{bK:"extends implements"},e.UTM]},{bK:"namespace",e:";",i:/[\.']/,c:[e.UTM]},{bK:"use",e:";",c:[e.UTM]},{b:"=>"},i,t]}});
js/jquery.scc-cache-info.js CHANGED
@@ -5,83 +5,149 @@ 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
- return $('#scc-dashboard').each(function(){
10
- $("span[data-scc]").css('display', 'none');
11
- $.ajax({
12
- url: scc.endpoint + '?action=' + scc.action + '&nonce=' + scc.nonce,
13
- dataType: 'jsonp',
14
- cache: false,
15
- success: function(res){
16
- if(res){
17
-
18
- $("span[data-scc='pc']").text(res.post_count);
19
- $("span[data-scc='pfcc']").text(res.primary.full_cache_count);
20
- $("span[data-scc='ppcc']").text(res.primary.partial_cache_count);
21
- $("span[data-scc='pncc']").text(res.primary.no_cache_count);
22
- $("span[data-scc='pcs']").text(res.primary.cache_status);
23
-
24
- $("span[data-scc='sfcc']").text(res.secondary.full_cache_count);
25
- $("span[data-scc='spcc']").text(res.secondary.partial_cache_count);
26
- $("span[data-scc='sncc']").text(res.secondary.no_cache_count);
27
- $("span[data-scc='scs']").text(res.secondary.cache_status);
28
-
29
- if(res.share_delta.twitter > 0){
30
- $("span[data-scc='twitter']").html(res.share_count.twitter + ' (<span class="delta-rise">+' + res.share_delta.twitter + '</span>)');
31
- } else if(res.share_delta.twitter < 0){
32
- $("span[data-scc='twitter']").html(res.share_count.twitter + ' (<span class="delta-fall">' + res.share_delta.twitter + '</span>)');
33
- } else {
34
- $("span[data-scc='twitter']").html(res.share_count.twitter);
35
- }
36
- if(res.share_delta.facebook > 0){
37
- $("span[data-scc='facebook']").html(res.share_count.facebook + ' (<span class="delta-rise">+' + res.share_delta.facebook + '</span>)');
38
- } else if(res.share_delta.facebook < 0){
39
- $("span[data-scc='facebook']").html(res.share_count.facebook + ' (<span class="delta-fall">' + res.share_delta.facebook + '</span>)');
40
- } else {
41
- $("span[data-scc='facebook']").html(res.share_count.facebook);
42
- }
43
-
44
- if(res.share_delta.gplus > 0){
45
- $("span[data-scc='gplus']").html(res.share_count.gplus + ' (<span class="delta-rise">+' + res.share_delta.gplus + '</span>)');
46
- } else if(res.share_delta.gplus < 0){
47
- $("span[data-scc='gplus']").html(res.share_count.gplus + ' (<span class="delta-fall">' + res.share_delta.gplus + '</span>)');
48
- } else {
49
- $("span[data-scc='gplus']").html(res.share_count.gplus);
50
- }
51
-
52
- if(res.share_delta.pocket > 0){
53
- $("span[data-scc='pocket']").html(res.share_count.pocket + ' (<span class="delta-rise">+' + res.share_delta.pocket + '</span>)');
54
- } else if(res.share_delta.pocket < 0){
55
- $("span[data-scc='pocket']").html(res.share_count.pocket + ' (<span class="delta-fall">' + res.share_delta.pocket + '</span>)');
56
- } else {
57
- $("span[data-scc='pocket']").html(res.share_count.pocket);
58
- }
59
-
60
- if(res.share_delta.hatebu > 0){
61
- $("span[data-scc='hatebu']").html(res.share_count.hatebu + ' (<span class="delta-rise">+' + res.share_delta.hatebu + '</span>)');
62
- } else if(res.share_delta.hatebu < 0){
63
- $("span[data-scc='hatebu']").html(res.share_count.hatebu + ' (<span class="delta-fall">' + res.share_delta.hatebu + '</span>)');
64
- } else {
65
- $("span[data-scc='hatebu']").html(res.share_count.hatebu);
66
- }
67
-
68
- if(res.share_delta.total > 0){
69
- $("span[data-scc='total']").html(res.share_count.total + ' (<span class="delta-rise">+' + res.share_delta.total + '</span>)');
70
- } else if(res.share_delta.total < 0){
71
- $("span[data-scc='total']").html(res.share_count.total + ' (<span class="delta-fall">' + res.share_delta.total + '</span>)');
72
- } else {
73
- $("span[data-scc='total']").html(res.share_count.total);
74
- }
75
-
76
- $(".loading").css('display', 'none');
77
- $("span[data-scc]").fadeIn();
78
- } else {
79
- $("span[data-scc]").text('?');
80
- }
81
- },
82
- error: function(res){
83
- $("span[data-scc]").text('?');
84
- }
85
- });
86
- });
87
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  License: GPL2 or later
6
  License URI: http://www.gnu.org/licenses/gpl-2.0.txt
7
  */
8
+ ;jQuery(document).ready(function ($) {
9
+ return $('#scc-dashboard,#scc-dashboard-widget').each(function() {
10
+ $("span[data-scc]").css('display', 'none');
11
+
12
+ function isset( data ){
13
+ return ( typeof( data ) != 'undefined' );
14
+ }
15
+
16
+ $.ajax({
17
+ url: scc.endpoint + '?action=' + scc.action + '&nonce=' + scc.nonce,
18
+ dataType: 'jsonp',
19
+ cache: false,
20
+ success: function(res) {
21
+ if (res) {
22
+ console.log(res);
23
+ $("span[data-scc='spc']").text(res.share.post_count);
24
+ $("span[data-scc='spfcc']").text(res.share.primary.full_cache_count);
25
+ $("span[data-scc='sppcc']").text(res.share.primary.partial_cache_count);
26
+ $("span[data-scc='spncc']").text(res.share.primary.no_cache_count);
27
+ $("span[data-scc='spcs']").text(res.share.primary.cache_status);
28
+
29
+ $("span[data-scc='ssfcc']").text(res.share.secondary.full_cache_count);
30
+ $("span[data-scc='sspcc']").text(res.share.secondary.partial_cache_count);
31
+ $("span[data-scc='ssncc']").text(res.share.secondary.no_cache_count);
32
+ $("span[data-scc='sscs']").text(res.share.secondary.cache_status);
33
+
34
+ if ( res.share_delta.twitter > 0) {
35
+ $("span[data-scc='stwitter']").html(res.share_count.twitter + ' (<span class="delta-rise">+' + res.share_delta.twitter + '</span>)');
36
+ } else if (res.share_delta.twitter < 0) {
37
+ $("span[data-scc='stwitter']").html(res.share_count.twitter + ' (<span class="delta-fall">' + res.share_delta.twitter + '</span>)');
38
+ } else {
39
+ $("span[data-scc='stwitter']").html(res.share_count.twitter);
40
+ }
41
+ if (res.share_delta.facebook > 0) {
42
+ $("span[data-scc='sfacebook']").html(res.share_count.facebook + ' (<span class="delta-rise">+' + res.share_delta.facebook + '</span>)');
43
+ } else if (res.share_delta.facebook < 0) {
44
+ $("span[data-scc='sfacebook']").html(res.share_count.facebook + ' (<span class="delta-fall">' + res.share_delta.facebook + '</span>)');
45
+ } else {
46
+ $("span[data-scc='sfacebook']").html(res.share_count.facebook);
47
+ }
48
+
49
+ if (res.share_delta.gplus > 0) {
50
+ $("span[data-scc='sgplus']").html(res.share_count.gplus + ' (<span class="delta-rise">+' + res.share_delta.gplus + '</span>)');
51
+ } else if (res.share_delta.gplus < 0) {
52
+ $("span[data-scc='sgplus']").html(res.share_count.gplus + ' (<span class="delta-fall">' + res.share_delta.gplus + '</span>)');
53
+ } else {
54
+ $("span[data-scc='sgplus']").html(res.share_count.gplus);
55
+ }
56
+
57
+ if (res.share_delta.pocket > 0) {
58
+ $("span[data-scc='spocket']").html(res.share_count.pocket + ' (<span class="delta-rise">+' + res.share_delta.pocket + '</span>)');
59
+ } else if (res.share_delta.pocket < 0) {
60
+ $("span[data-scc='spocket']").html(res.share_count.pocket + ' (<span class="delta-fall">' + res.share_delta.pocket + '</span>)');
61
+ } else {
62
+ $("span[data-scc='spocket']").html(res.share_count.pocket);
63
+ }
64
+
65
+ if (res.share_delta.hatebu > 0) {
66
+ $("span[data-scc='shatebu']").html(res.share_count.hatebu + ' (<span class="delta-rise">+' + res.share_delta.hatebu + '</span>)');
67
+ } else if (res.share_delta.hatebu < 0) {
68
+ $("span[data-scc='shatebu']").html(res.share_count.hatebu + ' (<span class="delta-fall">' + res.share_delta.hatebu + '</span>)');
69
+ } else {
70
+ $("span[data-scc='shatebu']").html(res.share_count.hatebu);
71
+ }
72
+
73
+ if (res.share_delta.total > 0) {
74
+ $("span[data-scc='stotal']").html(res.share_count.total + ' (<span class="delta-rise">+' + res.share_delta.total + '</span>)');
75
+ } else if (res.share_delta.total < 0) {
76
+ $("span[data-scc='stotal']").html(res.share_count.total + ' (<span class="delta-fall">' + res.share_delta.total + '</span>)');
77
+ } else {
78
+ $("span[data-scc='stotal']").html(res.share_count.total);
79
+ }
80
+
81
+ $("span[data-scc='fpc']").text(res.follow.post_count);
82
+ $("span[data-scc='fpfcc']").text(res.follow.primary.full_cache_count);
83
+ $("span[data-scc='fppcc']").text(res.follow.primary.partial_cache_count);
84
+ $("span[data-scc='fpncc']").text(res.follow.primary.no_cache_count);
85
+ $("span[data-scc='fpcs']").text(res.follow.primary.cache_status);
86
+
87
+ $("span[data-scc='fsfcc']").text(res.follow.secondary.full_cache_count);
88
+ $("span[data-scc='fspcc']").text(res.follow.secondary.partial_cache_count);
89
+ $("span[data-scc='fsncc']").text(res.follow.secondary.no_cache_count);
90
+ $("span[data-scc='fscs']").text(res.follow.secondary.cache_status);
91
+
92
+ if (isset(res.follow_count)) {
93
+ if (isset(res.follow_delta) && res.follow_delta.twitter > 0) {
94
+ $("span[data-scc='ftwitter']").html(res.follow_count.twitter + ' (<span class="delta-rise">+' + res.follow_delta.twitter + '</span>)');
95
+ } else if (isset(res.follow_delta) && res.follow_delta.twitter < 0) {
96
+ $("span[data-scc='ftwitter']").html(res.follow_count.twitter + ' (<span class="delta-fall">' + res.follow_delta.twitter + '</span>)');
97
+ } else {
98
+ $("span[data-scc='ftwitter']").html(res.follow_count.twitter);
99
+ }
100
+ }
101
+
102
+ if (isset(res.follow_count)) {
103
+ if (isset(res.follow_delta) && res.follow_delta.facebook > 0) {
104
+ $("span[data-scc='ffacebook']").html(res.follow_count.facebook + ' (<span class="delta-rise">+' + res.follow_delta.facebook + '</span>)');
105
+ } else if (isset(res.follow_delta) && res.follow_delta.facebook < 0) {
106
+ $("span[data-scc='ffacebook']").html(res.follow_count.facebook + ' (<span class="delta-fall">' + res.follow_delta.facebook + '</span>)');
107
+ } else {
108
+ $("span[data-scc='ffacebook']").html(res.follow_count.facebook);
109
+ }
110
+ }
111
+
112
+ if ( isset( res.follow_count ) ) {
113
+ if (isset(res.follow_delta) && res.follow_delta.feedly > 0) {
114
+ $("span[data-scc='ffeedly']").html(res.follow_count.feedly + ' (<span class="delta-rise">+' + res.follow_delta.feedly + '</span>)');
115
+ } else if (isset(res.follow_delta) && res.follow_delta.feedly < 0) {
116
+ $("span[data-scc='ffeedly']").html(res.follow_count.feedly + ' (<span class="delta-fall">' + res.follow_delta.feedly + '</span>)');
117
+ } else {
118
+ $("span[data-scc='ffeedly']").html(res.follow_count.feedly);
119
+ }
120
+ }
121
+
122
+ if ( isset( res.follow_count ) ) {
123
+ if (isset(res.follow_delta) && res.follow_delta.push7 > 0) {
124
+ $("span[data-scc='fpush7']").html(res.follow_count.push7 + ' (<span class="delta-rise">+' + res.follow_delta.push7 + '</span>)');
125
+ } else if (isset(res.follow_delta) && res.follow_delta.push7 < 0) {
126
+ $("span[data-scc='fpush7']").html(res.follow_count.push7 + ' (<span class="delta-fall">' + res.follow_delta.push7 + '</span>)');
127
+ } else {
128
+ $("span[data-scc='fpush7']").html(res.follow_count.push7);
129
+ }
130
+ }
131
+
132
+ if ( isset( res.follow_count ) ) {
133
+ if (isset(res.follow_delta) && res.follow_delta.instagram > 0) {
134
+ $("span[data-scc='finstagram']").html(res.follow_count.instagram + ' (<span class="delta-rise">+' + res.follow_delta.instagram + '</span>)');
135
+ } else if (isset(res.follow_delta) && res.follow_delta.instagram < 0) {
136
+ $("span[data-scc='finstagram']").html(res.follow_count.instagram + ' (<span class="delta-fall">' + res.follow_delta.instagram + '</span>)');
137
+ } else {
138
+ $("span[data-scc='finstagram']").html(res.follow_count.instagram);
139
+ }
140
+ }
141
+
142
+ $(".loading").css('display', 'none');
143
+ $("span[data-scc]").fadeIn();
144
+ } else {
145
+ $("span[data-scc]").text('?');
146
+ }
147
+ },
148
+ error: function(res) {
149
+ $("span[data-scc]").text('?');
150
+ }
151
+ });
152
+ });
153
+ });
js/jquery.scc-cache-info.min.js CHANGED
@@ -1,6 +1,12 @@
1
- ;jQuery(document).ready(function(b){return b("#scc-dashboard").each(function(){b("span[data-scc]").css("display","none");b.ajax({url:scc.endpoint+"?action="+scc.action+"&nonce="+scc.nonce,dataType:"jsonp",cache:!1,success:function(a){a?(b("span[data-scc='pc']").text(a.post_count),b("span[data-scc='pfcc']").text(a.primary.full_cache_count),b("span[data-scc='ppcc']").text(a.primary.partial_cache_count),b("span[data-scc='pncc']").text(a.primary.no_cache_count),b("span[data-scc='pcs']").text(a.primary.cache_status),
2
- b("span[data-scc='sfcc']").text(a.secondary.full_cache_count),b("span[data-scc='spcc']").text(a.secondary.partial_cache_count),b("span[data-scc='sncc']").text(a.secondary.no_cache_count),b("span[data-scc='scs']").text(a.secondary.cache_status),0<a.share_delta.twitter?b("span[data-scc='twitter']").html(a.share_count.twitter+' (<span class="delta-rise">+'+a.share_delta.twitter+"</span>)"):0>a.share_delta.twitter?b("span[data-scc='twitter']").html(a.share_count.twitter+' (<span class="delta-fall">'+
3
- a.share_delta.twitter+"</span>)"):b("span[data-scc='twitter']").html(a.share_count.twitter),0<a.share_delta.facebook?b("span[data-scc='facebook']").html(a.share_count.facebook+' (<span class="delta-rise">+'+a.share_delta.facebook+"</span>)"):0>a.share_delta.facebook?b("span[data-scc='facebook']").html(a.share_count.facebook+' (<span class="delta-fall">'+a.share_delta.facebook+"</span>)"):b("span[data-scc='facebook']").html(a.share_count.facebook),0<a.share_delta.gplus?b("span[data-scc='gplus']").html(a.share_count.gplus+
4
- ' (<span class="delta-rise">+'+a.share_delta.gplus+"</span>)"):0>a.share_delta.gplus?b("span[data-scc='gplus']").html(a.share_count.gplus+' (<span class="delta-fall">'+a.share_delta.gplus+"</span>)"):b("span[data-scc='gplus']").html(a.share_count.gplus),0<a.share_delta.pocket?b("span[data-scc='pocket']").html(a.share_count.pocket+' (<span class="delta-rise">+'+a.share_delta.pocket+"</span>)"):0>a.share_delta.pocket?b("span[data-scc='pocket']").html(a.share_count.pocket+' (<span class="delta-fall">'+
5
- a.share_delta.pocket+"</span>)"):b("span[data-scc='pocket']").html(a.share_count.pocket),0<a.share_delta.hatebu?b("span[data-scc='hatebu']").html(a.share_count.hatebu+' (<span class="delta-rise">+'+a.share_delta.hatebu+"</span>)"):0>a.share_delta.hatebu?b("span[data-scc='hatebu']").html(a.share_count.hatebu+' (<span class="delta-fall">'+a.share_delta.hatebu+"</span>)"):b("span[data-scc='hatebu']").html(a.share_count.hatebu),0<a.share_delta.total?b("span[data-scc='total']").html(a.share_count.total+
6
- ' (<span class="delta-rise">+'+a.share_delta.total+"</span>)"):0>a.share_delta.total?b("span[data-scc='total']").html(a.share_count.total+' (<span class="delta-fall">'+a.share_delta.total+"</span>)"):b("span[data-scc='total']").html(a.share_count.total),b(".loading").css("display","none"),b("span[data-scc]").fadeIn()):b("span[data-scc]").text("?")},error:function(a){b("span[data-scc]").text("?")}})})});
 
 
 
 
 
 
1
+ ;jQuery(document).ready(function(b){return b("#scc-dashboard,#scc-dashboard-widget").each(function(){function c(a){return"undefined"!=typeof a}b("span[data-scc]").css("display","none");b.ajax({url:scc.endpoint+"?action="+scc.action+"&nonce="+scc.nonce,dataType:"jsonp",cache:!1,success:function(a){a?(console.log(a),b("span[data-scc='spc']").text(a.share.post_count),b("span[data-scc='spfcc']").text(a.share.primary.full_cache_count),b("span[data-scc='sppcc']").text(a.share.primary.partial_cache_count),
2
+ b("span[data-scc='spncc']").text(a.share.primary.no_cache_count),b("span[data-scc='spcs']").text(a.share.primary.cache_status),b("span[data-scc='ssfcc']").text(a.share.secondary.full_cache_count),b("span[data-scc='sspcc']").text(a.share.secondary.partial_cache_count),b("span[data-scc='ssncc']").text(a.share.secondary.no_cache_count),b("span[data-scc='sscs']").text(a.share.secondary.cache_status),0<a.share_delta.twitter?b("span[data-scc='stwitter']").html(a.share_count.twitter+' (<span class="delta-rise">+'+
3
+ a.share_delta.twitter+"</span>)"):0>a.share_delta.twitter?b("span[data-scc='stwitter']").html(a.share_count.twitter+' (<span class="delta-fall">'+a.share_delta.twitter+"</span>)"):b("span[data-scc='stwitter']").html(a.share_count.twitter),0<a.share_delta.facebook?b("span[data-scc='sfacebook']").html(a.share_count.facebook+' (<span class="delta-rise">+'+a.share_delta.facebook+"</span>)"):0>a.share_delta.facebook?b("span[data-scc='sfacebook']").html(a.share_count.facebook+' (<span class="delta-fall">'+
4
+ a.share_delta.facebook+"</span>)"):b("span[data-scc='sfacebook']").html(a.share_count.facebook),0<a.share_delta.gplus?b("span[data-scc='sgplus']").html(a.share_count.gplus+' (<span class="delta-rise">+'+a.share_delta.gplus+"</span>)"):0>a.share_delta.gplus?b("span[data-scc='sgplus']").html(a.share_count.gplus+' (<span class="delta-fall">'+a.share_delta.gplus+"</span>)"):b("span[data-scc='sgplus']").html(a.share_count.gplus),0<a.share_delta.pocket?b("span[data-scc='spocket']").html(a.share_count.pocket+
5
+ ' (<span class="delta-rise">+'+a.share_delta.pocket+"</span>)"):0>a.share_delta.pocket?b("span[data-scc='spocket']").html(a.share_count.pocket+' (<span class="delta-fall">'+a.share_delta.pocket+"</span>)"):b("span[data-scc='spocket']").html(a.share_count.pocket),0<a.share_delta.hatebu?b("span[data-scc='shatebu']").html(a.share_count.hatebu+' (<span class="delta-rise">+'+a.share_delta.hatebu+"</span>)"):0>a.share_delta.hatebu?b("span[data-scc='shatebu']").html(a.share_count.hatebu+' (<span class="delta-fall">'+
6
+ a.share_delta.hatebu+"</span>)"):b("span[data-scc='shatebu']").html(a.share_count.hatebu),0<a.share_delta.total?b("span[data-scc='stotal']").html(a.share_count.total+' (<span class="delta-rise">+'+a.share_delta.total+"</span>)"):0>a.share_delta.total?b("span[data-scc='stotal']").html(a.share_count.total+' (<span class="delta-fall">'+a.share_delta.total+"</span>)"):b("span[data-scc='stotal']").html(a.share_count.total),b("span[data-scc='fpc']").text(a.follow.post_count),b("span[data-scc='fpfcc']").text(a.follow.primary.full_cache_count),
7
+ b("span[data-scc='fppcc']").text(a.follow.primary.partial_cache_count),b("span[data-scc='fpncc']").text(a.follow.primary.no_cache_count),b("span[data-scc='fpcs']").text(a.follow.primary.cache_status),b("span[data-scc='fsfcc']").text(a.follow.secondary.full_cache_count),b("span[data-scc='fspcc']").text(a.follow.secondary.partial_cache_count),b("span[data-scc='fsncc']").text(a.follow.secondary.no_cache_count),b("span[data-scc='fscs']").text(a.follow.secondary.cache_status),c(a.follow_count)&&(c(a.follow_delta)&&
8
+ 0<a.follow_delta.twitter?b("span[data-scc='ftwitter']").html(a.follow_count.twitter+' (<span class="delta-rise">+'+a.follow_delta.twitter+"</span>)"):c(a.follow_delta)&&0>a.follow_delta.twitter?b("span[data-scc='ftwitter']").html(a.follow_count.twitter+' (<span class="delta-fall">'+a.follow_delta.twitter+"</span>)"):b("span[data-scc='ftwitter']").html(a.follow_count.twitter)),c(a.follow_count)&&(c(a.follow_delta)&&0<a.follow_delta.facebook?b("span[data-scc='ffacebook']").html(a.follow_count.facebook+
9
+ ' (<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+' (<span class="delta-rise">+'+a.follow_delta.feedly+"</span>)"):c(a.follow_delta)&&
10
+ 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?b("span[data-scc='fpush7']").html(a.follow_count.push7+' (<span class="delta-fall">'+
11
+ 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">'+a.follow_delta.instagram+"</span>)"):b("span[data-scc='finstagram']").html(a.follow_count.instagram)),
12
+ b(".loading").css("display","none"),b("span[data-scc]").fadeIn()):b("span[data-scc]").text("?")},error:function(a){b("span[data-scc]").text("?")}})})});
js/prettify.js DELETED
@@ -1,28 +0,0 @@
1
- var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
2
- (function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
3
- [],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c<
4
- f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&&
5
- (j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r=
6
- {b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length,
7
- t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b===
8
- "string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
9
- l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
10
- q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
11
- q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
12
- "");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
13
- a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
14
- for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g<d.length;++g)e(d[g]);m===(m|0)&&d[0].setAttribute("value",
15
- m);var r=s.createElement("OL");r.className="linenums";for(var n=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}function k(a,m){for(var e=m.length;--e>=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";return A[a]}function E(a){var m=
16
- a.g;try{var e=M(a.h),h=e.a;a.a=h;a.c=e.c;a.d=0;C(m,h)(a);var k=/\bMSIE\b/.test(navigator.userAgent),m=/\n/g,t=a.a,s=t.length,e=0,l=a.c,p=l.length,h=0,d=a.e,g=d.length,a=0;d[g]=s;var r,n;for(n=r=0;n<g;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;g=r;for(n=r=0;n<g;){for(var z=d[n],f=d[n+1],b=n+2;b+2<=g&&d[b+1]===f;)b+=2;d[r++]=z;d[r++]=f;n=b}for(d.length=r;h<p;){var o=l[h+2]||s,c=d[a+2]||s,b=Math.min(o,c),i=l[h+1],j;if(i.nodeType!==1&&(j=t.substring(e,b))){k&&(j=j.replace(m,"\r"));i.nodeValue=
17
- j;var u=i.ownerDocument,v=u.createElement("SPAN");v.className=d[a+1];var x=i.parentNode;x.replaceChild(v,i);v.appendChild(i);e<o&&(l[h+1]=i=u.createTextNode(t.substring(b,o)),x.insertBefore(i,v.nextSibling))}e=b;e>=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
18
- "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
19
- H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
20
- J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
21
- I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),
22
- ["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",
23
- /^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),
24
- ["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes",
25
- hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b=
26
- !k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m,
27
- 250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",
28
- PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
languages/sns-count-cache-ja.mo CHANGED
Binary file
languages/sns-count-cache-ja.po CHANGED
@@ -1,1097 +1,1430 @@
1
- # Copyright (C) 2015 SNS Count Cache
2
- # This file is distributed under the same license as the SNS Count Cache package.
3
- msgid ""
4
- msgstr ""
5
- "Project-Id-Version: SNS Count Cache 0.8.0\n"
6
- "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/sns-count-cache\n"
7
- "POT-Creation-Date: 2015-08-23 10:44+0900\n"
8
- "PO-Revision-Date: 2015-08-23 18:27+0900\n"
9
- "Last-Translator: Daisuke Maruyama <marubon@gmail.com>\n"
10
- "Language-Team: \n"
11
- "Language: ja\n"
12
- "MIME-Version: 1.0\n"
13
- "Content-Type: text/plain; charset=UTF-8\n"
14
- "Content-Transfer-Encoding: 8bit\n"
15
- "X-Generator: Poedit 1.8.4\n"
16
- "Plural-Forms: nplurals=1; plural=0;\n"
17
-
18
- #. Plugin Name of the plugin/theme
19
- #: includes/admin-cache-status.php:73 includes/admin-dashboard.php:44
20
- #: includes/admin-help.php:35 includes/admin-hot-content.php:70
21
- #: includes/admin-setting.php:290 includes/admin-share-count.php:69
22
- #: sns-count-cache.php:1222
23
- msgid "SNS Count Cache"
24
- msgstr ""
25
-
26
- #: includes/admin-cache-status.php:76 includes/admin-dashboard.php:48
27
- #: includes/admin-help.php:39 includes/admin-hot-content.php:73
28
- #: includes/admin-setting.php:311 includes/admin-share-count.php:72
29
- #: sns-count-cache.php:1223
30
- msgid "Dashboard"
31
- msgstr "ダッシュボード"
32
-
33
- #: includes/admin-cache-status.php:77 includes/admin-cache-status.php:88
34
- #: includes/admin-dashboard-widget.php:47 includes/admin-dashboard.php:49
35
- #: includes/admin-dashboard.php:61 includes/admin-help.php:40
36
- #: includes/admin-hot-content.php:74 includes/admin-setting.php:312
37
- #: includes/admin-share-count.php:73 sns-count-cache.php:1224
38
- msgid "Cache Status"
39
- msgstr "キャッシュ状況"
40
-
41
- #: includes/admin-cache-status.php:78 includes/admin-dashboard-widget.php:84
42
- #: includes/admin-dashboard.php:50 includes/admin-dashboard.php:104
43
- #: includes/admin-help.php:41 includes/admin-hot-content.php:75
44
- #: includes/admin-setting.php:313 includes/admin-share-count.php:74
45
- #: includes/admin-share-count.php:84 sns-count-cache.php:1225
46
- msgid "Share Count"
47
- msgstr "シェア数"
48
-
49
- #: includes/admin-cache-status.php:80 includes/admin-dashboard.php:52
50
- #: includes/admin-help.php:43 includes/admin-hot-content.php:76
51
- #: includes/admin-hot-content.php:83 includes/admin-setting.php:315
52
- #: includes/admin-share-count.php:76 sns-count-cache.php:1228
53
- msgid "Hot Content"
54
- msgstr "話題のコンテンツ"
55
-
56
- #: includes/admin-cache-status.php:82 includes/admin-dashboard.php:54
57
- #: includes/admin-help.php:45 includes/admin-hot-content.php:77
58
- #: includes/admin-setting.php:317 includes/admin-share-count.php:78
59
- #: sns-count-cache.php:1231
60
- msgid "Setting"
61
- msgstr "設定"
62
-
63
- #: includes/admin-cache-status.php:83 includes/admin-dashboard.php:55
64
- #: includes/admin-help.php:46 includes/admin-help.php:52
65
- #: includes/admin-hot-content.php:78 includes/admin-setting.php:318
66
- #: includes/admin-share-count.php:79 sns-count-cache.php:1232
67
- msgid "Help"
68
- msgstr "ヘルプ"
69
-
70
- #: includes/admin-cache-status.php:94 includes/admin-hot-content.php:89
71
- #: includes/admin-share-count.php:90
72
- msgid "Content"
73
- msgstr "コンテンツ"
74
-
75
- #: includes/admin-cache-status.php:95 includes/admin-dashboard-widget.php:61
76
- #: includes/admin-dashboard.php:76
77
- msgid "Primary Cache"
78
- msgstr "一次キャッシュ"
79
-
80
- #: includes/admin-cache-status.php:96 includes/admin-dashboard-widget.php:71
81
- #: includes/admin-dashboard.php:86
82
- msgid "Secondary Cache"
83
- msgstr "二次キャッシュ"
84
-
85
- #: includes/admin-cache-status.php:97
86
- msgid "Crawl Date"
87
- msgstr "クロール日時"
88
-
89
- #: includes/admin-cache-status.php:139 includes/admin-cache-status.php:179
90
- #: includes/admin-cache-status.php:239 includes/admin-cache-status.php:272
91
- msgid "full cache"
92
- msgstr "完全キャッシュ"
93
-
94
- #: includes/admin-cache-status.php:143 includes/admin-cache-status.php:183
95
- #: includes/admin-cache-status.php:243 includes/admin-cache-status.php:276
96
- msgid "partial cache"
97
- msgstr "部分キャッシュ"
98
-
99
- #: includes/admin-cache-status.php:147 includes/admin-cache-status.php:153
100
- #: includes/admin-cache-status.php:187 includes/admin-cache-status.php:221
101
- #: includes/admin-cache-status.php:247 includes/admin-cache-status.php:280
102
- msgid "no cache"
103
- msgstr "未キャッシュ"
104
-
105
- #: includes/admin-cache-status.php:197 includes/admin-cache-status.php:299
106
- msgid "no data"
107
- msgstr "データなし"
108
-
109
- #: includes/admin-cache-status.php:307
110
- msgid "Cache"
111
- msgstr "Cache"
112
-
113
- #: includes/admin-dashboard-widget.php:51 includes/admin-dashboard.php:66
114
- msgid "Cache Type"
115
- msgstr "キャッシュタイプ"
116
-
117
- #: includes/admin-dashboard-widget.php:52 includes/admin-dashboard.php:67
118
- msgid "Cache Progress"
119
- msgstr "キャッシュ進捗"
120
-
121
- #: includes/admin-dashboard-widget.php:53 includes/admin-dashboard.php:68
122
- msgid "Total Content"
123
- msgstr "総コンテンツ数"
124
-
125
- #: includes/admin-dashboard-widget.php:54 includes/admin-dashboard.php:69
126
- msgid "State - Full Cache"
127
- msgstr "状態 - 完全キャッシュ"
128
-
129
- #: includes/admin-dashboard-widget.php:55 includes/admin-dashboard.php:70
130
- msgid "State - Partial Cache"
131
- msgstr "状態 - 部分キャッシュ"
132
-
133
- #: includes/admin-dashboard-widget.php:56 includes/admin-dashboard.php:71
134
- msgid "State - No Cache"
135
- msgstr "状態 - 未キャッシュ"
136
-
137
- #: includes/admin-dashboard-widget.php:99 includes/admin-dashboard.php:120
138
- #: includes/admin-hot-content.php:108 includes/admin-setting.php:634
139
- #: includes/admin-share-count.php:109
140
- msgid "Twitter"
141
- msgstr "Twitter"
142
-
143
- #: includes/admin-dashboard-widget.php:102 includes/admin-dashboard.php:123
144
- #: includes/admin-hot-content.php:111 includes/admin-setting.php:618
145
- #: includes/admin-share-count.php:112
146
- msgid "Facebook"
147
- msgstr "Facebook"
148
-
149
- #: includes/admin-dashboard-widget.php:105 includes/admin-dashboard.php:126
150
- #: includes/admin-hot-content.php:114 includes/admin-setting.php:622
151
- #: includes/admin-share-count.php:115
152
- msgid "Google+"
153
- msgstr "Google+"
154
-
155
- #: includes/admin-dashboard-widget.php:108 includes/admin-dashboard.php:129
156
- #: includes/admin-hot-content.php:117 includes/admin-setting.php:630
157
- #: includes/admin-share-count.php:118
158
- msgid "Pocket"
159
- msgstr "Pocket"
160
-
161
- #: includes/admin-dashboard-widget.php:111 includes/admin-dashboard.php:132
162
- #: includes/admin-hot-content.php:120 includes/admin-share-count.php:121
163
- msgid "Hatebu"
164
- msgstr "はてブ"
165
-
166
- #: includes/admin-dashboard-widget.php:114 includes/admin-dashboard.php:135
167
- #: includes/admin-hot-content.php:123 includes/admin-share-count.php:124
168
- msgid "Total"
169
- msgstr "合計"
170
-
171
- #: includes/admin-help.php:56
172
- msgid "What is WordPress plugin SNS Cout Cache?"
173
- msgstr "WordPressプラグイン SNS Count Cacheとは何か?"
174
-
175
- #: includes/admin-help.php:57
176
- msgid ""
177
- "WordPress plugin SNS Count Cache is a plugin whitch helps you to shorten page "
178
- "loading time when you display share counts. This plugin gets share count for "
179
- "Twitter and Facebook, Google Plus, Pocket, Hatena Bookmark and caches these "
180
- "count in the background. The share count can be retrieved not through network "
181
- "but through the cache using given functions."
182
- msgstr ""
183
- "WordPressプラグイン SNS Count Cacheは、シェア数を表示している場合にページの表示"
184
- "時間を高速化するプラグインです。このプラグインは、Twitter、Facebook、Google+、"
185
- "Pocket、はてなブックマークのシェア数をバックグラウンドで取得し、キャッシュしま"
186
- "す。これらのシェア数は、指定された関数を用いることでネットワーク経由ではなく、"
187
- "キャッシュから参照可能になります。"
188
-
189
- #: includes/admin-help.php:58
190
- msgid "How often does this plugin get and cache share counts?"
191
- msgstr "SNSカウントを取得、キャッシュする頻度は?"
192
-
193
- #: includes/admin-help.php:59
194
- msgid ""
195
- "Although this plugin gets share count of 20 posts at a time every 10 minutes "
196
- "by default, you can modify the setting in the \"Setting\" tab in the "
197
- "administration page."
198
- msgstr ""
199
- "デフォルトで10分ごとに20記事の取得するが、管理ページの「設定」タブにて変更する"
200
- "ことが可能です。"
201
-
202
- #: includes/admin-help.php:60
203
- msgid "How can I know whether share count of each post is cached or not?"
204
- msgstr "各記事のSNSカウントのキャッシュ有無を確認する方法は?"
205
-
206
- #: includes/admin-help.php:61
207
- msgid ""
208
- "Cache status is described in the \"Cache Status\" tab in the administration "
209
- "page."
210
- msgstr "キャッシュ状態は、管理ページの「キャッシュ状況」タブにて確認可能です。"
211
-
212
- #: includes/admin-help.php:62
213
- msgid "How can I get share count from the cache?"
214
- msgstr "キャッシュからSNSカウントを参照する方法は?"
215
-
216
- #: includes/admin-help.php:63
217
- msgid ""
218
- "The share count is retrieved from the cache using the following functions in "
219
- "the WordPress loop such as query_posts(), get_posts() and WP_Query()."
220
- msgstr ""
221
- "WordPressのquery_posts()、get_posts()、WP_Query()等のループ内で下記の関数を使う"
222
- "ことでキャッシュからSNSカウントを参照できます。"
223
-
224
- #: includes/admin-help.php:67 includes/admin-help.php:85
225
- msgid "Function"
226
- msgstr "関数"
227
-
228
- #: includes/admin-help.php:68 includes/admin-help.php:86
229
- #: includes/admin-help.php:142 includes/admin-help.php:160
230
- msgid "Description"
231
- msgstr "説明"
232
-
233
- #: includes/admin-help.php:72
234
- msgid "Twitter share count is returned from cache."
235
- msgstr "キャッシュからTwitterのSNSカウントが返されます。"
236
-
237
- #: includes/admin-help.php:73
238
- msgid "Facebook share count is returned from cache."
239
- msgstr "キャッシュからFacebookのSNSカウントが返されます。"
240
-
241
- #: includes/admin-help.php:74
242
- msgid "Google Plus share count is returned from cache."
243
- msgstr "キャッシュからGoogle+のSNSカウントが返されます。"
244
-
245
- #: includes/admin-help.php:75
246
- msgid "Hatena Bookmark share count is returned from cache."
247
- msgstr "キャッシュからはてなブックマークのSNSカウントが返されます。"
248
-
249
- #: includes/admin-help.php:76
250
- msgid "Pocket share count is returned from cache."
251
- msgstr "キャッシュからPocketのSNSカウントが返されます。"
252
-
253
- #: includes/admin-help.php:77
254
- msgid "Total share count of selected SNS is returned from cache."
255
- msgstr "キャッシュから対象として設定されたSNSのカウントの総和が返されます。"
256
-
257
- #: includes/admin-help.php:80
258
- msgid "How can I get follow count from the cache?"
259
- msgstr "キャッシュからフォロー数を参照する方法は?"
260
-
261
- #: includes/admin-help.php:81
262
- msgid ""
263
- "The follow count is retrieved from the cache using the following functions."
264
- msgstr "フォロー数は、以下の関数を用いることでキャッシュから参照可能です。"
265
-
266
- #: includes/admin-help.php:90
267
- msgid "Feedly follow count is returned from cache."
268
- msgstr "キャッシュからFeedlyのフォロー数が返されます。"
269
-
270
- #: includes/admin-help.php:93
271
- msgid "Example Code"
272
- msgstr "サンプルコード"
273
-
274
- #: includes/admin-help.php:94
275
- msgid ""
276
- "The code below describes a simple example which displays share count and "
277
- "follower count using the above functions for each post."
278
- msgstr ""
279
- "以下のコードは、上述した関数を用いて記事ごとにシェア数やフォロー数を表示する簡"
280
- "単な例です。"
281
-
282
- #: includes/admin-help.php:136
283
- msgid "How can I access specific custom field containing each share count?"
284
- msgstr "シェア数を含むカスタムフィールドにアクセスする方法は?"
285
-
286
- #: includes/admin-help.php:137
287
- msgid ""
288
- "Custom fields including share count are accessed using the following meta keys."
289
- msgstr "シェア数を含むカスタムフィールドは、以下のmeta keyを用いて参照可能です。"
290
-
291
- #: includes/admin-help.php:141 includes/admin-help.php:159
292
- msgid "Meta Key"
293
- msgstr "Meta Key"
294
-
295
- #: includes/admin-help.php:146
296
- msgid "A meta key for Twitter share count"
297
- msgstr "Twitterのシェア数のためのMeta Keyです。"
298
-
299
- #: includes/admin-help.php:147
300
- msgid "A meta key for Facebook share count"
301
- msgstr "Facebookのシェア数のためのMeta Keyです。"
302
-
303
- #: includes/admin-help.php:148
304
- msgid "A meta key for Google Plus share count"
305
- msgstr "Google+のシェア数のためのMeta Keyです。"
306
-
307
- #: includes/admin-help.php:149
308
- msgid "A meta key for Hatena Bookmark share count"
309
- msgstr "はてなブックマークのシェア数のためのMeta Keyです。"
310
-
311
- #: includes/admin-help.php:150
312
- msgid "A meta key for Pocket share count"
313
- msgstr "Pocketのシェア数のためのMeta Keyです。"
314
-
315
- #: includes/admin-help.php:151
316
- msgid "A meta key for total share count"
317
- msgstr "シェア数の合計のためのMeta Keyです。"
318
-
319
- #: includes/admin-help.php:154
320
- msgid ""
321
- "How can I access specific custom field containing each variation of share "
322
- "count?"
323
- msgstr "シェア数の増減を含むカスタムフィールドにアクセスする方法は?"
324
-
325
- #: includes/admin-help.php:155
326
- msgid ""
327
- "Custom fields including variation of share count are accessed using the "
328
- "following meta keys."
329
- msgstr ""
330
- "シェア数の増減を含むカスタムフィールドは、以下のmeta keyを用いて参照可能です。"
331
-
332
- #: includes/admin-help.php:164
333
- msgid "A meta key for variation of Twitter share count"
334
- msgstr "Twitterのシェア数増減のためのMeta Keyです。"
335
-
336
- #: includes/admin-help.php:165
337
- msgid "A meta key for variation of Facebook share count"
338
- msgstr "Facebookのシェア数増減のためのMeta Keyです。"
339
-
340
- #: includes/admin-help.php:166
341
- msgid "A meta key for variation of Google Plus share count"
342
- msgstr "Google+のシェア数増減のためのMeta Keyです。"
343
-
344
- #: includes/admin-help.php:167
345
- msgid "A meta key for variation of Hatena Bookmark share count"
346
- msgstr "はてなブックマークのシェア数増減のためのMeta Keyです。"
347
-
348
- #: includes/admin-help.php:168
349
- msgid "A meta key for variation of Pocket share count"
350
- msgstr "Pocketのシェア数増減のためのMeta Keyです。"
351
-
352
- #: includes/admin-help.php:169
353
- msgid "A meta key for variation of total share count"
354
- msgstr "シェア数増減の合計のためのMeta Keyです。"
355
-
356
- #: includes/admin-hot-content.php:281 includes/admin-hot-content.php:313
357
- #: includes/admin-hot-content.php:334 includes/admin-setting.php:377
358
- #: includes/admin-setting.php:414 includes/admin-share-count.php:201
359
- #: includes/admin-share-count.php:217 includes/admin-share-count.php:249
360
- #: includes/admin-share-count.php:264 includes/admin-share-count.php:274
361
- #: includes/admin-share-count.php:305 includes/admin-share-count.php:321
362
- #: includes/admin-share-count.php:354 includes/admin-share-count.php:369
363
- #: includes/admin-share-count.php:379 includes/admin-share-count.php:427
364
- #: includes/admin-share-count.php:462
365
- msgid "N/A"
366
- msgstr "N/A"
367
-
368
- #: includes/admin-hot-content.php:330
369
- msgid "No hot content."
370
- msgstr "話題のコンテンツはありません。"
371
-
372
- #: includes/admin-setting.php:35 includes/admin-setting.php:688
373
- #: includes/admin-setting.php:732 includes/admin-setting.php:987
374
- #: includes/admin-setting.php:1015 includes/admin-setting.php:1045
375
- #: includes/admin-setting.php:1069 includes/admin-setting.php:1105
376
- #: includes/admin-setting.php:1374
377
- msgid "Update All Options"
378
- msgstr "設定の更新"
379
-
380
- #: includes/admin-setting.php:225 includes/admin-setting.php:1429
381
- msgid "Reset"
382
- msgstr "リセット"
383
-
384
- #: includes/admin-setting.php:233 includes/admin-setting.php:1411
385
- msgid "Export"
386
- msgstr "エクスポート"
387
-
388
- #: includes/admin-setting.php:245 includes/admin-setting.php:988
389
- msgid "Update Basis of Comparison"
390
- msgstr "比較基準の更新"
391
-
392
- #: includes/admin-setting.php:257 includes/admin-setting.php:272
393
- #: includes/admin-setting.php:689 includes/admin-setting.php:1016
394
- msgid "Clear Cache"
395
- msgstr "キャッシュの消去"
396
-
397
- #: includes/admin-setting.php:321 includes/admin-setting.php:326
398
- msgid "Current Setting"
399
- msgstr "現在の設定"
400
-
401
- #: includes/admin-setting.php:321 includes/admin-setting.php:338
402
- #: includes/admin-setting.php:371 includes/admin-setting.php:383
403
- #: includes/admin-setting.php:388 includes/admin-setting.php:393
404
- #: includes/admin-setting.php:407 includes/admin-setting.php:610
405
- msgid "Share Base Cache"
406
- msgstr "シェア基本キャッシュ機能"
407
-
408
- #: includes/admin-setting.php:321 includes/admin-setting.php:421
409
- #: includes/admin-setting.php:434 includes/admin-setting.php:695
410
- msgid "Share Rush Cache"
411
- msgstr "シェア臨時キャッシュ機能"
412
-
413
- #: includes/admin-setting.php:321 includes/admin-setting.php:444
414
- #: includes/admin-setting.php:465 includes/admin-setting.php:738
415
- msgid "Share Variation Analysis"
416
- msgstr "シェア変動分析機能"
417
-
418
- #: includes/admin-setting.php:321 includes/admin-setting.php:473
419
- #: includes/admin-setting.php:486 includes/admin-setting.php:994
420
- msgid "Follow Base Cache"
421
- msgstr "フォロー基本キャッシュ機能"
422
-
423
- #: includes/admin-setting.php:321 includes/admin-setting.php:525
424
- #: includes/admin-setting.php:1052
425
- msgid "Dynamic Cache"
426
- msgstr "動的キャッシュ機能"
427
-
428
- #: includes/admin-setting.php:321 includes/admin-setting.php:546
429
- #: includes/admin-setting.php:562 includes/admin-setting.php:1075
430
- msgid "Data Crawler"
431
- msgstr "データクローラ機能"
432
-
433
- #: includes/admin-setting.php:321 includes/admin-setting.php:575
434
- #: includes/admin-setting.php:593 includes/admin-setting.php:1111
435
- msgid "Data Export"
436
- msgstr "データエクスポート機能"
437
-
438
- #: includes/admin-setting.php:321 includes/admin-setting.php:1383
439
- msgid "Exported File"
440
- msgstr "エクスポートされたファイル"
441
-
442
- #: includes/admin-setting.php:331
443
- msgid "Capability"
444
- msgstr "機能"
445
-
446
- #: includes/admin-setting.php:332
447
- msgid "Parameter"
448
- msgstr "パラメータ"
449
-
450
- #: includes/admin-setting.php:333
451
- msgid "Value"
452
- msgstr "値"
453
-
454
- #: includes/admin-setting.php:339 includes/admin-setting.php:474
455
- #: includes/admin-setting.php:614 includes/admin-setting.php:998
456
- msgid "Target SNS"
457
- msgstr "対象SNS"
458
-
459
- #: includes/admin-setting.php:350 includes/admin-setting.php:626
460
- msgid "Hatena Bookmark"
461
- msgstr "はてなブックマーク"
462
-
463
- #: includes/admin-setting.php:372 includes/admin-setting.php:639
464
- msgid "Custom post types"
465
- msgstr "カスタム投稿タイプ"
466
-
467
- #: includes/admin-setting.php:384 includes/admin-setting.php:435
468
- #: includes/admin-setting.php:647 includes/admin-setting.php:722
469
- msgid "Interval cheking share count (sec)"
470
- msgstr "シェア数のチェック間隔(秒)"
471
-
472
- #: includes/admin-setting.php:385 includes/admin-setting.php:438
473
- #: includes/admin-setting.php:488 includes/admin-setting.php:725
474
- msgid "seconds"
475
- msgstr "秒"
476
-
477
- #: includes/admin-setting.php:389 includes/admin-setting.php:654
478
- msgid "Number of contents to check at a time"
479
- msgstr "一度にチェックするコンテンツ数"
480
-
481
- #: includes/admin-setting.php:390
482
- msgid "contents"
483
- msgstr "コンテンツ"
484
-
485
- #: includes/admin-setting.php:394 includes/admin-setting.php:661
486
- msgid "Scheme migration mode from http to https"
487
- msgstr "HTTPからHTTPSへのスキーム移行モード"
488
-
489
- #: includes/admin-setting.php:398 includes/admin-setting.php:567
490
- #: includes/admin-setting.php:665 includes/admin-setting.php:1098
491
- msgid "On"
492
- msgstr "有効"
493
-
494
- #: includes/admin-setting.php:400 includes/admin-setting.php:569
495
- #: includes/admin-setting.php:664 includes/admin-setting.php:1097
496
- msgid "Off"
497
- msgstr "無効"
498
-
499
- #: includes/admin-setting.php:408 includes/admin-setting.php:672
500
- msgid "Scheme migration date from http to https"
501
- msgstr "HTTPからHTTPSへのスキーム移行日"
502
-
503
- #: includes/admin-setting.php:422 includes/admin-setting.php:699
504
- msgid "Term considering posted content as new content"
505
- msgstr "投稿日からコンテンツを新着とみなす期間"
506
-
507
- #: includes/admin-setting.php:426
508
- msgid "day"
509
- msgstr ""
510
-
511
- #: includes/admin-setting.php:428
512
- msgid "days"
513
- msgstr ""
514
-
515
- #: includes/admin-setting.php:445 includes/admin-setting.php:742
516
- msgid "Method to update basis of comparison"
517
- msgstr "比較基準の更新方式"
518
-
519
- #: includes/admin-setting.php:449 includes/admin-setting.php:530
520
- #: includes/admin-setting.php:745 includes/admin-setting.php:1059
521
- msgid "Disabled (None)"
522
- msgstr "無効(なし)"
523
-
524
- #: includes/admin-setting.php:452 includes/admin-setting.php:746
525
- msgid "Enabled (Manual)"
526
- msgstr "有効(手動)"
527
-
528
- #: includes/admin-setting.php:455 includes/admin-setting.php:747
529
- msgid "Enabled (Scheduler)"
530
- msgstr "有効(スケジューラ)"
531
-
532
- #: includes/admin-setting.php:466
533
- msgid "Schedule"
534
- msgstr "スケジュール"
535
-
536
- #: includes/admin-setting.php:487 includes/admin-setting.php:1007
537
- msgid "Interval cheking follower count (sec)"
538
- msgstr "フォロー数のチェック間隔(秒)"
539
-
540
- #: includes/admin-setting.php:492 includes/admin-setting.php:519
541
- #: includes/admin-setting.php:1023
542
- msgid "Follow Base Cache - Feedly"
543
- msgstr "フォロー基本キャッシュ機能 - Feedly"
544
-
545
- #: includes/admin-setting.php:493 includes/admin-setting.php:1027
546
- msgid "Target feed type"
547
- msgstr "対象フィードタイプ"
548
-
549
- #: includes/admin-setting.php:498 includes/admin-setting.php:513
550
- #: includes/admin-setting.php:1030
551
- msgid "Default"
552
- msgstr "デフォルト"
553
-
554
- #: includes/admin-setting.php:501 includes/admin-setting.php:1031
555
- msgid "RSS"
556
- msgstr "RSS"
557
-
558
- #: includes/admin-setting.php:504 includes/admin-setting.php:1032
559
- msgid "RSS2"
560
- msgstr "RSS2"
561
-
562
- #: includes/admin-setting.php:507 includes/admin-setting.php:1033
563
- msgid "RDF"
564
- msgstr "RDF"
565
-
566
- #: includes/admin-setting.php:510 includes/admin-setting.php:1034
567
- msgid "ATOM"
568
- msgstr "ATOM"
569
-
570
- #: includes/admin-setting.php:520 includes/admin-setting.php:1040
571
- msgid "Target feed"
572
- msgstr "対象フィード"
573
-
574
- #: includes/admin-setting.php:526 includes/admin-setting.php:1056
575
- msgid "Dynamic caching based on user access"
576
- msgstr "ユーザアクセスをトリガとする動的キャッシュ"
577
-
578
- #: includes/admin-setting.php:533 includes/admin-setting.php:1060
579
- msgid "Enabled (Synchronous Cache)"
580
- msgstr "有効(同期キャッシュ)"
581
-
582
- #: includes/admin-setting.php:536 includes/admin-setting.php:1061
583
- msgid "Enabled (Asynchronous Cache)"
584
- msgstr "有効(非同期キャッシュ)"
585
-
586
- #: includes/admin-setting.php:539 includes/admin-setting.php:1062
587
- msgid "Enabled (Asynchronous 2nd Cache)"
588
- msgstr "有効(非同期2次キャッシュ)"
589
-
590
- #: includes/admin-setting.php:547 includes/admin-setting.php:1079
591
- msgid "Crawl method"
592
- msgstr "クロールの方式"
593
-
594
- #: includes/admin-setting.php:552 includes/admin-setting.php:1084
595
- msgid "Normal (Sequential Retrieval)"
596
- msgstr "標準(逐次検索)"
597
-
598
- #: includes/admin-setting.php:555 includes/admin-setting.php:1087
599
- msgid "Extended (Parallel Retrieval)"
600
- msgstr "拡張(並列検索)"
601
-
602
- #: includes/admin-setting.php:563 includes/admin-setting.php:1094
603
- msgid "SSL verification"
604
- msgstr "SSL証明書の検証"
605
-
606
- #: includes/admin-setting.php:576 includes/admin-setting.php:1115
607
- msgid "Method of data export"
608
- msgstr "データのエクスポート方式"
609
-
610
- #: includes/admin-setting.php:580 includes/admin-setting.php:1118
611
- msgid "Manual"
612
- msgstr "手動"
613
-
614
- #: includes/admin-setting.php:583 includes/admin-setting.php:784
615
- #: includes/admin-setting.php:1119 includes/admin-setting.php:1155
616
- msgid "Scheduler"
617
- msgstr "有効(スケジューラ)"
618
-
619
- #: includes/admin-setting.php:594
620
- msgid "Interval exporting share count to a csv file"
621
- msgstr "シェア数をCSVファイルにエクスポートする間隔"
622
-
623
- #: includes/admin-setting.php:595
624
- msgid "hours"
625
- msgstr "時間"
626
-
627
- #: includes/admin-setting.php:643
628
- msgid "e.g. aaa, bbb, ccc (comma-delimited)"
629
- msgstr "例. aaa, bbb, ccc(カンマ区切り)"
630
-
631
- #: includes/admin-setting.php:650
632
- msgid "Default: 600"
633
- msgstr "既定値: 600"
634
-
635
- #: includes/admin-setting.php:657
636
- msgid "Default: 20"
637
- msgstr "既定値: 20"
638
-
639
- #: includes/admin-setting.php:667
640
- msgid "Default: Off"
641
- msgstr "既定値: 無効"
642
-
643
- #: includes/admin-setting.php:675
644
- msgid "Default: N/A"
645
- msgstr "既定値: N/A"
646
-
647
- #: includes/admin-setting.php:702
648
- msgid "1 day"
649
- msgstr "1日"
650
-
651
- #: includes/admin-setting.php:703
652
- msgid "2 days"
653
- msgstr "2日"
654
-
655
- #: includes/admin-setting.php:704
656
- msgid "3 days"
657
- msgstr "3日"
658
-
659
- #: includes/admin-setting.php:705
660
- msgid "4 days"
661
- msgstr "4日"
662
-
663
- #: includes/admin-setting.php:706
664
- msgid "5 days"
665
- msgstr "5日"
666
-
667
- #: includes/admin-setting.php:707
668
- msgid "6 days"
669
- msgstr "6日"
670
-
671
- #: includes/admin-setting.php:708
672
- msgid "7 days"
673
- msgstr "7日"
674
-
675
- #: includes/admin-setting.php:709
676
- msgid "8 days"
677
- msgstr "8日"
678
-
679
- #: includes/admin-setting.php:710
680
- msgid "9 days"
681
- msgstr "9日"
682
-
683
- #: includes/admin-setting.php:711
684
- msgid "10 days"
685
- msgstr "10日"
686
-
687
- #: includes/admin-setting.php:712
688
- msgid "11 days"
689
- msgstr "11日"
690
-
691
- #: includes/admin-setting.php:713
692
- msgid "12 days"
693
- msgstr "12日"
694
-
695
- #: includes/admin-setting.php:714
696
- msgid "13 days"
697
- msgstr "13日"
698
-
699
- #: includes/admin-setting.php:715
700
- msgid "14 days"
701
- msgstr "14日"
702
-
703
- #: includes/admin-setting.php:717
704
- msgid "Default: 3 days"
705
- msgstr "既定値: 3日"
706
-
707
- #: includes/admin-setting.php:749
708
- msgid "Default: None"
709
- msgstr "既定値: なし"
710
-
711
- #: includes/admin-setting.php:789 includes/admin-setting.php:1160
712
- msgid "Type"
713
- msgstr "タイプ"
714
-
715
- #: includes/admin-setting.php:794 includes/admin-setting.php:1165
716
- msgid "Hour"
717
- msgstr ""
718
-
719
- #: includes/admin-setting.php:797 includes/admin-setting.php:1168
720
- msgid "Minute"
721
- msgstr "分"
722
-
723
- #: includes/admin-setting.php:803 includes/admin-setting.php:1174
724
- msgid "monthly"
725
- msgstr "毎月"
726
-
727
- #: includes/admin-setting.php:812 includes/admin-setting.php:1183
728
- msgid "on 1."
729
- msgstr "1日"
730
-
731
- #: includes/admin-setting.php:815 includes/admin-setting.php:1186
732
- msgid "on 2."
733
- msgstr "2日"
734
-
735
- #: includes/admin-setting.php:818 includes/admin-setting.php:1189
736
- msgid "on 3."
737
- msgstr "3日"
738
-
739
- #: includes/admin-setting.php:821 includes/admin-setting.php:1192
740
- msgid "on 4."
741
- msgstr "4日"
742
-
743
- #: includes/admin-setting.php:824 includes/admin-setting.php:1195
744
- msgid "on 5."
745
- msgstr "5日"
746
-
747
- #: includes/admin-setting.php:827 includes/admin-setting.php:1198
748
- msgid "on 6."
749
- msgstr "6日"
750
-
751
- #: includes/admin-setting.php:830 includes/admin-setting.php:1201
752
- msgid "on 7."
753
- msgstr "7日"
754
-
755
- #: includes/admin-setting.php:833 includes/admin-setting.php:1204
756
- msgid "on 8."
757
- msgstr "8日"
758
-
759
- #: includes/admin-setting.php:836 includes/admin-setting.php:1207
760
- msgid "on 9."
761
- msgstr "9日"
762
-
763
- #: includes/admin-setting.php:839 includes/admin-setting.php:1210
764
- msgid "on 10."
765
- msgstr "10日"
766
-
767
- #: includes/admin-setting.php:842 includes/admin-setting.php:1213
768
- msgid "on 11."
769
- msgstr "11日"
770
-
771
- #: includes/admin-setting.php:845 includes/admin-setting.php:1216
772
- msgid "on 12."
773
- msgstr "12日"
774
-
775
- #: includes/admin-setting.php:848 includes/admin-setting.php:1219
776
- msgid "on 13."
777
- msgstr "13日"
778
-
779
- #: includes/admin-setting.php:851 includes/admin-setting.php:1222
780
- msgid "on 14."
781
- msgstr "14日"
782
-
783
- #: includes/admin-setting.php:854 includes/admin-setting.php:1225
784
- msgid "on 15."
785
- msgstr "15日"
786
-
787
- #: includes/admin-setting.php:857 includes/admin-setting.php:1228
788
- msgid "on 16."
789
- msgstr "16日"
790
-
791
- #: includes/admin-setting.php:860 includes/admin-setting.php:1231
792
- msgid "on 17."
793
- msgstr "17日"
794
-
795
- #: includes/admin-setting.php:863 includes/admin-setting.php:1234
796
- msgid "on 18."
797
- msgstr "18日"
798
-
799
- #: includes/admin-setting.php:866 includes/admin-setting.php:1237
800
- msgid "on 19."
801
- msgstr "19日"
802
-
803
- #: includes/admin-setting.php:869 includes/admin-setting.php:1240
804
- msgid "on 20."
805
- msgstr "20日"
806
-
807
- #: includes/admin-setting.php:872 includes/admin-setting.php:1243
808
- msgid "on 21."
809
- msgstr "21日"
810
-
811
- #: includes/admin-setting.php:875 includes/admin-setting.php:1246
812
- msgid "on 22."
813
- msgstr "22日"
814
-
815
- #: includes/admin-setting.php:878 includes/admin-setting.php:1249
816
- msgid "on 23."
817
- msgstr "23日"
818
-
819
- #: includes/admin-setting.php:881 includes/admin-setting.php:1252
820
- msgid "on 24."
821
- msgstr "24日"
822
-
823
- #: includes/admin-setting.php:884 includes/admin-setting.php:1255
824
- msgid "on 25."
825
- msgstr "25日"
826
-
827
- #: includes/admin-setting.php:887 includes/admin-setting.php:1258
828
- msgid "on 26."
829
- msgstr "26日"
830
-
831
- #: includes/admin-setting.php:890 includes/admin-setting.php:1261
832
- msgid "on 27."
833
- msgstr "27日"
834
-
835
- #: includes/admin-setting.php:893 includes/admin-setting.php:1264
836
- msgid "on 28."
837
- msgstr "28日"
838
-
839
- #: includes/admin-setting.php:896 includes/admin-setting.php:1267
840
- msgid "on 29."
841
- msgstr "29日"
842
-
843
- #: includes/admin-setting.php:899 includes/admin-setting.php:1270
844
- msgid "on 30."
845
- msgstr "30日"
846
-
847
- #: includes/admin-setting.php:902 includes/admin-setting.php:1273
848
- msgid "on 31."
849
- msgstr "31日"
850
-
851
- #: includes/admin-setting.php:928 includes/admin-setting.php:1299
852
- msgid "weekly"
853
- msgstr "毎週"
854
-
855
- #: includes/admin-setting.php:933 includes/admin-setting.php:1304
856
- msgid "Sunday"
857
- msgstr "日曜日"
858
-
859
- #: includes/admin-setting.php:934 includes/admin-setting.php:1305
860
- msgid "Monday"
861
- msgstr "月曜日"
862
-
863
- #: includes/admin-setting.php:935 includes/admin-setting.php:1306
864
- msgid "Tuesday"
865
- msgstr "火曜日"
866
-
867
- #: includes/admin-setting.php:936 includes/admin-setting.php:1307
868
- msgid "Wednesday"
869
- msgstr "水曜日"
870
-
871
- #: includes/admin-setting.php:937 includes/admin-setting.php:1308
872
- msgid "Thursday"
873
- msgstr "木曜日"
874
-
875
- #: includes/admin-setting.php:938 includes/admin-setting.php:1309
876
- msgid "Friday"
877
- msgstr "金曜日"
878
-
879
- #: includes/admin-setting.php:939 includes/admin-setting.php:1310
880
- msgid "Saturday"
881
- msgstr "土曜日"
882
-
883
- #: includes/admin-setting.php:959 includes/admin-setting.php:1330
884
- msgid "daily"
885
- msgstr "毎日"
886
-
887
- #: includes/admin-setting.php:1002
888
- msgid "Feedly"
889
- msgstr "Feedly"
890
-
891
- #: includes/admin-setting.php:1010
892
- msgid "Default: 86400 Minimum: 3600"
893
- msgstr "既定値: 86400 最小値: 3600"
894
-
895
- #: includes/admin-setting.php:1036
896
- msgid "Default: Default"
897
- msgstr "既定値: デフォルト"
898
-
899
- #: includes/admin-setting.php:1064
900
- msgid "Default: Enabled (Asynchronous 2nd Cache)"
901
- msgstr "既定値: 有効(非同期2次キャッシュ)"
902
-
903
- #: includes/admin-setting.php:1100
904
- msgid "Default: On"
905
- msgstr "既定値: 有効"
906
-
907
- #: includes/admin-setting.php:1121
908
- msgid "Default: Manual"
909
- msgstr "既定値: 手動"
910
-
911
- #: includes/admin-setting.php:1353
912
- msgid "hourly"
913
- msgstr "毎時"
914
-
915
- #: includes/admin-setting.php:1388
916
- msgid "Disk usage of exported file"
917
- msgstr "エクスポートされたファイルのディスク使用量"
918
-
919
- #: includes/admin-setting.php:1397
920
- msgid "No exported file"
921
- msgstr "エクスポートされたファイルは存在しません。"
922
-
923
- #: includes/admin-setting.php:1409
924
- msgid "Manual export"
925
- msgstr "手動エクスポート"
926
-
927
- #: includes/admin-setting.php:1413
928
- msgid "Export share count to a csv file."
929
- msgstr "シェア数をCSVファイルにエクスポートします。"
930
-
931
- #: includes/admin-setting.php:1427
932
- msgid "Reset of exported file"
933
- msgstr "エクスポートされたファイルのリセット"
934
-
935
- #: includes/admin-setting.php:1431
936
- msgid "Clear exported csv file."
937
- msgstr "エクスポートされたCSVファイルを削除します。"
938
-
939
- #: includes/admin-setting.php:1442
940
- msgid "Download of exported file"
941
- msgstr "エクスポートされたファイルのダウンロード"
942
-
943
- #: includes/admin-setting.php:1444 includes/download.php:38
944
- msgid "Download"
945
- msgstr "ダウンロード"
946
-
947
- #: includes/admin-setting.php:1446
948
- msgid "Download the exported csv file."
949
- msgstr "エクスポートされたCSVファイルをダウンロードします。"
950
-
951
- #: sns-count-cache.php:1223
952
- msgid "Dashboard | SNS Count Cache"
953
- msgstr "ダッシュボード | SNS Count Cache"
954
-
955
- #: sns-count-cache.php:1224
956
- msgid "Cache Status | SNS Count Cache"
957
- msgstr "キャッシュ状況 | SNS Count Cache"
958
-
959
- #: sns-count-cache.php:1225
960
- msgid "Share Count | SNS Count Cache"
961
- msgstr "シェア数 | SNS Count Cache"
962
-
963
- #: sns-count-cache.php:1228
964
- msgid "Hot Content | SNS Count Cache"
965
- msgstr "話題のコンテンツ | SNS Count Cache"
966
-
967
- #: sns-count-cache.php:1231
968
- msgid "Setting | SNS Count Cache"
969
- msgstr "設定 | SNS Count Cache"
970
-
971
- #: sns-count-cache.php:1232
972
- msgid "Help | SNS Count Cache"
973
- msgstr "ヘルプ | SNS Count Cache"
974
-
975
- #: sns-count-cache.php:1257 sns-count-cache.php:1272 sns-count-cache.php:1287
976
- #: sns-count-cache.php:1301 sns-count-cache.php:1315 sns-count-cache.php:1329
977
- #: sns-count-cache.php:1343 sns-count-cache.php:1357
978
- msgid "You do not have sufficient permissions to access this page."
979
- msgstr "このページにアクセスするために必要な権限がありません。"
980
-
981
- #: sns-count-cache.php:1507
982
- msgid "&laquo;"
983
- msgstr ""
984
-
985
- #: sns-count-cache.php:1508
986
- msgid "&raquo;"
987
- msgstr ""
988
-
989
- #: sns-count-cache.php:1839 sns-count-cache.php:1847
990
- msgid "Completed"
991
- msgstr "完了"
992
-
993
- #: sns-count-cache.php:1841 sns-count-cache.php:1849
994
- msgid "Partially Completed"
995
- msgstr "部分的完了"
996
-
997
- #: sns-count-cache.php:1843 sns-count-cache.php:1851
998
- msgid "Ongoing"
999
- msgstr "進行中"
1000
-
1001
- #. Plugin URI of the plugin/theme
1002
- msgid "https://ja.wordpress.org/plugins/sns-count-cache/"
1003
- msgstr ""
1004
-
1005
- #. Description of the plugin/theme
1006
- msgid ""
1007
- "SNS Count Cache gets share count for Twitter and Facebook, Google Plus, "
1008
- "Pocket, Hatena Bookmark and caches these count in the background. This plugin "
1009
- "may help you to shorten page loading time because the share count can be "
1010
- "retrieved not through network but through the cache using given functions."
1011
- msgstr ""
1012
- "SNS Count Cacheは、Twitter、Facebook、Google+、Pocket、はてなブックマークのシェ"
1013
- "ア数を取得し、バックグラウンドでキャッシュします。用意された関数を利用すること"
1014
- "で、ネットワーク経由でなくキャッシュからシェア数を参照できようになるため、ペー"
1015
- "ジ読み込みの高速化が見込めます。"
1016
-
1017
- #. Author of the plugin/theme
1018
- msgid "Daisuke Maruyama"
1019
- msgstr ""
1020
-
1021
- #. Author URI of the plugin/theme
1022
- msgid "http://marubon.info/"
1023
- msgstr ""
1024
-
1025
- #~ msgid "Additional custom post types"
1026
- #~ msgstr "追加のカスタム投稿タイプ"
1027
-
1028
- #~ msgid "on"
1029
- #~ msgstr "on"
1030
-
1031
- #~ msgid "What is SNS Cout Cache?"
1032
- #~ msgstr "SNS Count Cacheは何なのか?"
1033
-
1034
- #~ msgid ""
1035
- #~ "SNS Count Cache gets share count for Twitter and Facebook, Google Plus, "
1036
- #~ "Hatena Bookmark and caches these count in the background. This plugin may "
1037
- #~ "help you to shorten page loading time because the share count can be "
1038
- #~ "retrieved not through network but through the cache using given functions."
1039
- #~ msgstr ""
1040
- #~ "SNS Count Cacheは、Twitter、Facebook、Google+、はてなブックマーク、Pocketの"
1041
- #~ "カウントをバックグラウンドで取得し、それらのカウントをキャッシュします。SNS"
1042
- #~ "のカウントをネットワーク経由ではなく、キャッシュから取得することでページの読"
1043
- #~ "み込み時間の短縮が可能になります。"
1044
-
1045
- #~ msgid "How often does this plugin get and cache share count?"
1046
- #~ msgstr "SNSカウントを取得、キャッシュする頻度は?"
1047
-
1048
- #~ msgid ""
1049
- #~ "Although this plugin gets share count of 20 posts at a time every 10 "
1050
- #~ "minutes by default, you can modify the setting in the \"Setting\" tab in "
1051
- #~ "the setting page."
1052
- #~ msgstr ""
1053
- #~ "デフォルトで10分ごとに20記事の取得するが、管理ページの設定タブにて変更が可能"
1054
- #~ "です。"
1055
-
1056
- #~ msgid ""
1057
- #~ "Cache status is described in the \"Cache Status\" tab in the setting page."
1058
- #~ msgstr "キャッシュ状態は、管理ページのキャッシュ状態タブにて確認可能です。"
1059
-
1060
- #~ msgid "Status Overview"
1061
- #~ msgstr "ステータス概要"
1062
-
1063
- #~ msgid "Target feed type:"
1064
- #~ msgstr "対象フィードタイプ:"
1065
-
1066
- #~ msgid "Target feed:"
1067
- #~ msgstr "対象フィード:"
1068
-
1069
- #~ msgid "posts"
1070
- #~ msgstr "posts"
1071
-
1072
- #~ msgid "Number of contents to check at a time (posts)"
1073
- #~ msgstr "一度にチェックするコンテンツ数(コンテンツ数)"
1074
-
1075
- #~ msgid "Target Content"
1076
- #~ msgstr "対象コンテンツ"
1077
-
1078
- #~ msgid "Interval cheking and caching share count"
1079
- #~ msgstr "シェア数をチェック、キャッシュする間隔"
1080
-
1081
- #~ msgid "Number of posts to check at a time"
1082
- #~ msgstr "一度にチェックするコンテンツ数"
1083
-
1084
- #~ msgid "Interval cheking and caching share count(sec)"
1085
- #~ msgstr "シェア数をチェック、キャッシュする間隔"
1086
-
1087
- #~ msgid "Interval cheking and caching follower count"
1088
- #~ msgstr "フォロー数をチェック、キャッシュする間隔"
1089
-
1090
- #~ msgid "Interval cheking and caching share count (sec)"
1091
- #~ msgstr "シェア数をチェック、キャッシュする間隔(秒)"
1092
-
1093
- #~ msgid "Number of posts to check at a time (posts)"
1094
- #~ msgstr "一度にチェックするコンテンツ数(コンテンツ数)"
1095
-
1096
- #~ msgid "Interval cheking and caching follower count (sec)"
1097
- #~ msgstr "シェア数をチェック、キャッシュする間隔(秒)"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: SNS Count Cache\n"
4
+ "POT-Creation-Date: 2016-05-14 15:20+0900\n"
5
+ "PO-Revision-Date: 2016-05-14 15:20+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.7\n"
13
+ "X-Poedit-Basepath: ..\n"
14
+ "X-Poedit-WPHeader: sns-count-cache.php\n"
15
+ "Plural-Forms: nplurals=1; plural=0;\n"
16
+ "X-Poedit-SourceCharset: UTF-8\n"
17
+ "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
18
+ "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
19
+ "_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
20
+ "X-Poedit-SearchPath-0: .\n"
21
+ "X-Poedit-SearchPathExcluded-0: *.js\n"
22
+
23
+ #. Plugin Name of the plugin/theme
24
+ #: includes/admin-cache-status.php:63 includes/admin-dashboard.php:42
25
+ #: includes/admin-help.php:33 includes/admin-hot-content.php:67
26
+ #: includes/admin-setting.php:419 includes/admin-share-count.php:65
27
+ #: sns-count-cache.php:1590
28
+ msgid "SNS Count Cache"
29
+ msgstr "SNS Count Cache"
30
+
31
+ #: includes/admin-cache-status.php:66 includes/admin-dashboard.php:46
32
+ #: includes/admin-help.php:36 includes/admin-hot-content.php:70
33
+ #: includes/admin-setting.php:497 includes/admin-share-count.php:68
34
+ #: sns-count-cache.php:1591
35
+ msgid "Dashboard"
36
+ msgstr "ダッシュボード"
37
+
38
+ #: includes/admin-cache-status.php:67 includes/admin-cache-status.php:78
39
+ #: includes/admin-dashboard-widget.php:45
40
+ #: includes/admin-dashboard-widget.php:142 includes/admin-dashboard.php:47
41
+ #: includes/admin-dashboard.php:60 includes/admin-dashboard.php:162
42
+ #: includes/admin-help.php:37 includes/admin-help.php:63
43
+ #: includes/admin-hot-content.php:71 includes/admin-setting.php:498
44
+ #: includes/admin-share-count.php:69 sns-count-cache.php:1592
45
+ msgid "Cache Status"
46
+ msgstr "キャッシュ状況"
47
+
48
+ #: includes/admin-cache-status.php:68 includes/admin-dashboard-widget.php:80
49
+ #: includes/admin-dashboard.php:48 includes/admin-dashboard.php:95
50
+ #: includes/admin-help.php:38 includes/admin-hot-content.php:72
51
+ #: includes/admin-setting.php:499 includes/admin-share-count.php:70
52
+ #: includes/admin-share-count.php:80 sns-count-cache.php:1593
53
+ msgid "Share Count"
54
+ msgstr "シェア数"
55
+
56
+ #: includes/admin-cache-status.php:70 includes/admin-dashboard.php:50
57
+ #: includes/admin-help.php:40 includes/admin-hot-content.php:73
58
+ #: includes/admin-hot-content.php:80 includes/admin-setting.php:501
59
+ #: includes/admin-share-count.php:72 sns-count-cache.php:1596
60
+ msgid "Hot Content"
61
+ msgstr "話題のコンテンツ"
62
+
63
+ #: includes/admin-cache-status.php:72 includes/admin-dashboard.php:52
64
+ #: includes/admin-help.php:42 includes/admin-hot-content.php:74
65
+ #: includes/admin-setting.php:503 includes/admin-share-count.php:74
66
+ #: sns-count-cache.php:1599
67
+ msgid "Setting"
68
+ msgstr "設定"
69
+
70
+ #: includes/admin-cache-status.php:73 includes/admin-dashboard.php:53
71
+ #: includes/admin-help.php:43 includes/admin-help.php:48
72
+ #: includes/admin-hot-content.php:75 includes/admin-setting.php:504
73
+ #: includes/admin-share-count.php:75 sns-count-cache.php:1600
74
+ msgid "Help"
75
+ msgstr "ヘルプ"
76
+
77
+ #: includes/admin-cache-status.php:84 includes/admin-hot-content.php:86
78
+ #: includes/admin-share-count.php:86
79
+ msgid "Content"
80
+ msgstr "コンテンツ"
81
+
82
+ #: includes/admin-cache-status.php:85 includes/admin-dashboard-widget.php:59
83
+ #: includes/admin-dashboard-widget.php:156 includes/admin-dashboard.php:74
84
+ #: includes/admin-dashboard.php:176
85
+ msgid "Primary Cache"
86
+ msgstr "一次キャッシュ"
87
+
88
+ #: includes/admin-cache-status.php:86 includes/admin-dashboard-widget.php:69
89
+ #: includes/admin-dashboard-widget.php:166 includes/admin-dashboard.php:84
90
+ #: includes/admin-dashboard.php:186
91
+ msgid "Secondary Cache"
92
+ msgstr "二次キャッシュ"
93
+
94
+ #: includes/admin-cache-status.php:87
95
+ msgid "Crawl Date"
96
+ msgstr "クロール日時"
97
+
98
+ #: includes/admin-cache-status.php:126 includes/admin-cache-status.php:165
99
+ #: includes/admin-cache-status.php:223 includes/admin-cache-status.php:255
100
+ #: includes/admin-help.php:68
101
+ msgid "full cache"
102
+ msgstr "完全キャッシュ"
103
+
104
+ #: includes/admin-cache-status.php:130 includes/admin-cache-status.php:169
105
+ #: includes/admin-cache-status.php:227 includes/admin-cache-status.php:259
106
+ #: includes/admin-help.php:69
107
+ msgid "partial cache"
108
+ msgstr "部分キャッシュ"
109
+
110
+ #: includes/admin-cache-status.php:134 includes/admin-cache-status.php:140
111
+ #: includes/admin-cache-status.php:173 includes/admin-cache-status.php:205
112
+ #: includes/admin-cache-status.php:231 includes/admin-cache-status.php:263
113
+ #: includes/admin-help.php:70
114
+ msgid "no cache"
115
+ msgstr "未キャッシュ"
116
+
117
+ #: includes/admin-cache-status.php:182 includes/admin-cache-status.php:282
118
+ msgid "no data"
119
+ msgstr "データなし"
120
+
121
+ #: includes/admin-cache-status.php:189 includes/admin-cache-status.php:290
122
+ #: includes/admin-setting.php:384 includes/admin-setting.php:1323
123
+ msgid "Cache"
124
+ msgstr "キャッシュ"
125
+
126
+ #: includes/admin-dashboard-widget.php:44 includes/admin-dashboard.php:58
127
+ msgid "Share"
128
+ msgstr "Share"
129
+
130
+ #: includes/admin-dashboard-widget.php:49
131
+ #: includes/admin-dashboard-widget.php:146 includes/admin-dashboard.php:64
132
+ #: includes/admin-dashboard.php:166
133
+ msgid "Cache Type"
134
+ msgstr "キャッシュタイプ"
135
+
136
+ #: includes/admin-dashboard-widget.php:50
137
+ #: includes/admin-dashboard-widget.php:147 includes/admin-dashboard.php:65
138
+ #: includes/admin-dashboard.php:167
139
+ msgid "Cache Progress"
140
+ msgstr "キャッシュ進捗"
141
+
142
+ #: includes/admin-dashboard-widget.php:51
143
+ #: includes/admin-dashboard-widget.php:148 includes/admin-dashboard.php:66
144
+ #: includes/admin-dashboard.php:168
145
+ msgid "Total Content"
146
+ msgstr "総コンテンツ数"
147
+
148
+ #: includes/admin-dashboard-widget.php:52
149
+ #: includes/admin-dashboard-widget.php:149 includes/admin-dashboard.php:67
150
+ #: includes/admin-dashboard.php:169
151
+ msgid "State - Full Cache"
152
+ msgstr "状態 - 完全キャッシュ"
153
+
154
+ #: includes/admin-dashboard-widget.php:53
155
+ #: includes/admin-dashboard-widget.php:150 includes/admin-dashboard.php:68
156
+ #: includes/admin-dashboard.php:170
157
+ msgid "State - Partial Cache"
158
+ msgstr "状態 - 部分キャッシュ"
159
+
160
+ #: includes/admin-dashboard-widget.php:54
161
+ #: includes/admin-dashboard-widget.php:151 includes/admin-dashboard.php:69
162
+ #: includes/admin-dashboard.php:171
163
+ msgid "State - No Cache"
164
+ msgstr "状態 - 未キャッシュ"
165
+
166
+ #: includes/admin-dashboard-widget.php:94
167
+ #: includes/admin-dashboard-widget.php:191 includes/admin-dashboard.php:109
168
+ #: includes/admin-dashboard.php:211 includes/admin-hot-content.php:102
169
+ #: includes/admin-setting.php:881 includes/admin-setting.php:1309
170
+ #: includes/admin-share-count.php:102
171
+ msgid "Twitter"
172
+ msgstr "Twitter"
173
+
174
+ #: includes/admin-dashboard-widget.php:97
175
+ #: includes/admin-dashboard-widget.php:194 includes/admin-dashboard.php:112
176
+ #: includes/admin-dashboard.php:214 includes/admin-hot-content.php:105
177
+ #: includes/admin-setting.php:865 includes/admin-setting.php:1297
178
+ #: includes/admin-share-count.php:105
179
+ msgid "Facebook"
180
+ msgstr "Facebook"
181
+
182
+ #: includes/admin-dashboard-widget.php:100 includes/admin-dashboard.php:115
183
+ #: includes/admin-hot-content.php:108 includes/admin-setting.php:869
184
+ #: includes/admin-share-count.php:108
185
+ msgid "Google+"
186
+ msgstr "Google+"
187
+
188
+ #: includes/admin-dashboard-widget.php:103 includes/admin-dashboard.php:118
189
+ #: includes/admin-hot-content.php:111 includes/admin-setting.php:877
190
+ #: includes/admin-share-count.php:111
191
+ msgid "Pocket"
192
+ msgstr "Pocket"
193
+
194
+ #: includes/admin-dashboard-widget.php:106 includes/admin-dashboard.php:121
195
+ #: includes/admin-hot-content.php:114 includes/admin-share-count.php:114
196
+ msgid "Hatebu"
197
+ msgstr "はてブ"
198
+
199
+ #: includes/admin-dashboard-widget.php:109 includes/admin-dashboard.php:124
200
+ #: includes/admin-hot-content.php:117 includes/admin-share-count.php:117
201
+ msgid "Total"
202
+ msgstr "合計"
203
+
204
+ #: includes/admin-dashboard-widget.php:141 includes/admin-dashboard.php:160
205
+ msgid "Follow"
206
+ msgstr "Follow"
207
+
208
+ #: includes/admin-dashboard-widget.php:177
209
+ msgid "Follower Count"
210
+ msgstr "フォロワー数"
211
+
212
+ #: includes/admin-dashboard-widget.php:197 includes/admin-dashboard.php:217
213
+ #: includes/admin-setting.php:1301
214
+ msgid "Feedly"
215
+ msgstr "Feedly"
216
+
217
+ #: includes/admin-dashboard-widget.php:200 includes/admin-dashboard.php:220
218
+ #: includes/admin-setting.php:1293
219
+ msgid "Instagram"
220
+ msgstr "Instagram"
221
+
222
+ #: includes/admin-dashboard-widget.php:203 includes/admin-dashboard.php:223
223
+ #: includes/admin-setting.php:1305
224
+ msgid "Push7"
225
+ msgstr "Push7"
226
+
227
+ #: includes/admin-dashboard.php:197
228
+ msgid "Follow Count"
229
+ msgstr "フォロー数"
230
+
231
+ #: includes/admin-help.php:50
232
+ msgid "What is WordPress plugin SNS Cout Cache?"
233
+ msgstr "WordPressプラグイン SNS Count Cacheとは何か?"
234
+
235
+ #: includes/admin-help.php:51
236
+ msgid ""
237
+ "WordPress plugin SNS Count Cache is a plugin which helps you to shorten page "
238
+ "loading time when your site displays share and follower counts. This plugin "
239
+ "gets share counts such as Twitter and Facebook, Google+, Pocket and caches "
240
+ "these counts in the background. This plugin alse caches follower counts such "
241
+ "as Twitter and Facebook, Feedly, Instagram, Push7 in the same way. The share "
242
+ "and follower counts can be retrieved quickly not through network but through "
243
+ "the cache using given functions."
244
+ msgstr ""
245
+ "WordPressプラグイン SNS Count Cacheは、シェア数やフォロワー数を表示している場"
246
+ "合にページの表示時間を高速化するプラグインです。このプラグインは、Twitter、"
247
+ "Facebook、Google+、Pocket、はてなブックマークのシェア数をバックグラウンドで取"
248
+ "得し、キャッシュします。またTwitter、Facebook、Feedly、Instagram、Push7のフォ"
249
+ "ロワー数も同様の方法でキャッシュします。これらのシェア数とフォロワー数は、所"
250
+ "定の関数を用いることでネットワークからではなくキャッシュ経由で迅速に取得可能"
251
+ "になります。"
252
+
253
+ #: includes/admin-help.php:52
254
+ msgid "How often does this plugin get and cache share counts?"
255
+ msgstr "シェア数を取得、キャッシュする頻度は?"
256
+
257
+ #: includes/admin-help.php:53
258
+ msgid ""
259
+ "Although this plugin gets share count of 20 posts at a time every 10 minutes "
260
+ "by default, you can modify the setting in the \"Setting\" tab in the "
261
+ "administration page."
262
+ msgstr ""
263
+ "デフォルトで10分ごとに20記事のシェア数を取得しますが、管理ページの「設定」タ"
264
+ "ブにてその取得間隔と一度に取得対象とする記事数を変更できます。"
265
+
266
+ #: includes/admin-help.php:54
267
+ msgid "How can I know whether share count of each post is cached or not?"
268
+ msgstr "各記事のシェア数のキャッシュ有無を確認する方法は?"
269
+
270
+ #: includes/admin-help.php:55
271
+ msgid ""
272
+ "Cache status is described in the \"Cache Status\" tab in the administration "
273
+ "page."
274
+ msgstr "キャッシュ状況は、管理ページの「キャッシュ状況」タブにて確認可能です。"
275
+
276
+ #: includes/admin-help.php:56
277
+ msgid "How often does this plugin get and cache follower counts?"
278
+ msgstr "フォロワー数を取得、キャッシュする頻度は?"
279
+
280
+ #: includes/admin-help.php:57
281
+ msgid ""
282
+ "Although this plugin gets follower count once a day by default, you can "
283
+ "modify the setting in the \"Setting\" tab in the administration page."
284
+ msgstr ""
285
+ "デフォルトで1日に一回フォロワー数を取得しますが、管理ページの「設定」タブにて"
286
+ "その取得間隔を変更できます。"
287
+
288
+ #: includes/admin-help.php:58
289
+ msgid ""
290
+ "What is cache status such as \"full cache\", \"partial cache\" and \"no cache"
291
+ "\"?"
292
+ msgstr ""
293
+ "「完全キャッシュ」、「部分キャッシュ」、「未キャッシュ」等のキャッシュ状況と"
294
+ "は何か?"
295
+
296
+ #: includes/admin-help.php:59
297
+ msgid "The following is the explanation of the cache status."
298
+ msgstr "以下は、そのキャッシュ状況に関する説明です。"
299
+
300
+ #: includes/admin-help.php:64 includes/admin-help.php:79
301
+ #: includes/admin-help.php:97 includes/admin-help.php:166
302
+ #: includes/admin-help.php:184
303
+ msgid "Description"
304
+ msgstr "説明"
305
+
306
+ #: includes/admin-help.php:68
307
+ msgid "Counts for selected all SNS are cached."
308
+ msgstr "選択された全てのSNSのカウントがキャッシュされています。"
309
+
310
+ #: includes/admin-help.php:69
311
+ msgid "A subset of counts for selected SNS are cached."
312
+ msgstr "選択された一部のSNSのカウントがキャッシュされています。"
313
+
314
+ #: includes/admin-help.php:70
315
+ msgid "Count for selected SNS are not cached at all."
316
+ msgstr "選択されたSNSのカウントが全くキャッシュされていません。"
317
+
318
+ #: includes/admin-help.php:73
319
+ msgid "How can I get share count from the cache?"
320
+ msgstr "キャッシュからSNSカウントを参照する方法は?"
321
+
322
+ #: includes/admin-help.php:74
323
+ msgid ""
324
+ "The share count is retrieved from the cache using the following functions in "
325
+ "the WordPress loop such as query_posts(), get_posts() and WP_Query()."
326
+ msgstr ""
327
+ "WordPressのquery_posts()、get_posts()、WP_Query()等のループ内で下記の関数を使"
328
+ "うことでキャッシュからSNSカウントを参照できます。"
329
+
330
+ #: includes/admin-help.php:78 includes/admin-help.php:96
331
+ msgid "Function"
332
+ msgstr "関数"
333
+
334
+ #: includes/admin-help.php:83
335
+ msgid "Twitter share count is returned from cache."
336
+ msgstr "キャッシュからTwitterのシェア数を取得します。"
337
+
338
+ #: includes/admin-help.php:84
339
+ msgid "Facebook share count is returned from cache."
340
+ msgstr "キャッシュからFacebookのシェア数を取得します。"
341
+
342
+ #: includes/admin-help.php:85
343
+ msgid "Google Plus share count is returned from cache."
344
+ msgstr "キャッシュからGoogle+のシェア数を取得します。"
345
+
346
+ #: includes/admin-help.php:86
347
+ msgid "Hatena Bookmark share count is returned from cache."
348
+ msgstr "キャッシュからはてなブックマークのシェア数を取得します。"
349
+
350
+ #: includes/admin-help.php:87
351
+ msgid "Pocket share count is returned from cache."
352
+ msgstr "キャッシュからPocketのシェア数を取得します。"
353
+
354
+ #: includes/admin-help.php:88
355
+ msgid "Total share count of selected SNS is returned from cache."
356
+ msgstr "キャッシュから対象として設定されたSNSのカウントの総和を取得します。"
357
+
358
+ #: includes/admin-help.php:91
359
+ msgid "How can I get follower count from the cache?"
360
+ msgstr "キャッシュからフォロワーの数を参照する方法は?"
361
+
362
+ #: includes/admin-help.php:92
363
+ msgid ""
364
+ "The follower count is retrieved from the cache using the following functions."
365
+ msgstr "フォロワーの数は、以下の関数を用いることでキャッシュから参照可能です。"
366
+
367
+ #: includes/admin-help.php:101
368
+ msgid "Feedly follower count is returned from cache."
369
+ msgstr "キャッシュからFeedlyのフォロワーの数を取得します。"
370
+
371
+ #: includes/admin-help.php:102
372
+ msgid "Twitter follower count is returned from cache."
373
+ msgstr "キャッシュからTwitterのフォロワーの数を取得します。"
374
+
375
+ #: includes/admin-help.php:103
376
+ msgid "Facebook follower count is returned from cache."
377
+ msgstr "キャッシュからFacebookのフォロワーの数を取得します。"
378
+
379
+ #: includes/admin-help.php:104
380
+ msgid "Instagram follower count is returned from cache."
381
+ msgstr "キャッシュからInstagramのフォロワーの数を取得します。"
382
+
383
+ #: includes/admin-help.php:105
384
+ msgid "Push7 follower count is returned from cache."
385
+ msgstr "キャッシュからPush7のフォロワーの数を取得します。"
386
+
387
+ #: includes/admin-help.php:108
388
+ msgid "Example Code"
389
+ msgstr "サンプルコード"
390
+
391
+ #: includes/admin-help.php:109
392
+ msgid ""
393
+ "The code below describes a simple example which displays share count and "
394
+ "follower count using the above functions."
395
+ msgstr ""
396
+ "以下のコードは、上述した関数を用いてシェア数やフォロワー数を表示する簡単な例"
397
+ "です。"
398
+
399
+ #: includes/admin-help.php:160
400
+ msgid "How can I access specific custom field containing each share count?"
401
+ msgstr "シェア数を含むカスタムフィールドにアクセスする方法は?"
402
+
403
+ #: includes/admin-help.php:161
404
+ msgid ""
405
+ "Custom fields including share count are accessed using the following meta "
406
+ "keys."
407
+ msgstr ""
408
+ "シェア数を含むカスタムフィールドは、以下のmeta keyを用いて参照可能です。"
409
+
410
+ #: includes/admin-help.php:165 includes/admin-help.php:183
411
+ msgid "Meta Key"
412
+ msgstr "Meta Key"
413
+
414
+ #: includes/admin-help.php:170
415
+ msgid "A meta key to access Twitter share count"
416
+ msgstr "Twitterのシェア数にアクセスするためのMeta Keyです。"
417
+
418
+ #: includes/admin-help.php:171
419
+ msgid "A meta key to access Facebook share count"
420
+ msgstr "Facebookのシェア数にアクセスするためのMeta Keyです。"
421
+
422
+ #: includes/admin-help.php:172
423
+ msgid "A meta key to access Google+ share count"
424
+ msgstr "Google+のシェア数にアクセスするためのMeta Keyです。"
425
+
426
+ #: includes/admin-help.php:173
427
+ msgid "A meta key to access Hatena Bookmark share count"
428
+ msgstr "はてなブックマークのシェア数にアクセスするためのMeta Keyです。"
429
+
430
+ #: includes/admin-help.php:174
431
+ msgid "A meta key to access Pocket share count"
432
+ msgstr "Pocketのシェア数にアクセスするためのMeta Keyです。"
433
+
434
+ #: includes/admin-help.php:175
435
+ msgid "A meta key to access total share count"
436
+ msgstr "シェア数の合計にアクセスするためのMeta Keyです。"
437
+
438
+ #: includes/admin-help.php:178
439
+ msgid ""
440
+ "How can I access specific custom field containing each variation of share "
441
+ "count?"
442
+ msgstr "シェア数の増減を含むカスタムフィールドにアクセスする方法は?"
443
+
444
+ #: includes/admin-help.php:179
445
+ msgid ""
446
+ "Custom fields including variation of share count are accessed using the "
447
+ "following meta keys."
448
+ msgstr ""
449
+ "シェア数の増減を含むカスタムフィールドは、以下のmeta keyを用いて参照可能で"
450
+ "す。"
451
+
452
+ #: includes/admin-help.php:188
453
+ msgid "A meta key to access variation of Twitter share count"
454
+ msgstr "Twitterのシェア数の増減数にアクセスするためのMeta Keyです。"
455
+
456
+ #: includes/admin-help.php:189
457
+ msgid "A meta key to access variation of Facebook share count"
458
+ msgstr "Facebookのシェア数の増減数にアクセスするためのMeta Keyです。"
459
+
460
+ #: includes/admin-help.php:190
461
+ msgid "A meta key to access variation of Google+ share count"
462
+ msgstr "Google+のシェア数の増減数にアクセスするためのMeta Keyです。"
463
+
464
+ #: includes/admin-help.php:191
465
+ msgid "A meta key to access variation of Hatena Bookmark share count"
466
+ msgstr "はてなブックマークのシェア数の増減数にアクセスするためのMeta Keyです。"
467
+
468
+ #: includes/admin-help.php:192
469
+ msgid "A meta key to access variation of Pocket share count"
470
+ msgstr "Pocketのシェア数の増減数にアクセスするためのMeta Keyです。"
471
+
472
+ #: includes/admin-help.php:193
473
+ msgid "A meta key to access variation of total share count"
474
+ msgstr "シェア数合計の増減数にアクセスするためのMeta Keyです。"
475
+
476
+ #: includes/admin-hot-content.php:262 includes/admin-hot-content.php:291
477
+ #: includes/admin-hot-content.php:309 includes/admin-setting.php:565
478
+ #: includes/admin-setting.php:602 includes/admin-setting.php:750
479
+ #: includes/admin-setting.php:765 includes/admin-share-count.php:186
480
+ #: includes/admin-share-count.php:200 includes/admin-share-count.php:228
481
+ #: includes/admin-share-count.php:242 includes/admin-share-count.php:252
482
+ #: includes/admin-share-count.php:280 includes/admin-share-count.php:294
483
+ #: includes/admin-share-count.php:322 includes/admin-share-count.php:336
484
+ #: includes/admin-share-count.php:346 includes/admin-share-count.php:389
485
+ #: includes/admin-share-count.php:420
486
+ msgid "N/A"
487
+ msgstr "N/A"
488
+
489
+ #: includes/admin-hot-content.php:305
490
+ msgid "No hot content."
491
+ msgstr "話題のコンテンツはありません。"
492
+
493
+ #: includes/admin-setting.php:35 includes/admin-setting.php:935
494
+ #: includes/admin-setting.php:975 includes/admin-setting.php:1017
495
+ #: includes/admin-setting.php:1278 includes/admin-setting.php:1322
496
+ #: includes/admin-setting.php:1380 includes/admin-setting.php:1448
497
+ #: includes/admin-setting.php:1481 includes/admin-setting.php:1502
498
+ #: includes/admin-setting.php:1578 includes/admin-setting.php:1605
499
+ #: includes/admin-setting.php:1641 includes/admin-setting.php:1929
500
+ msgid "Update All Options"
501
+ msgstr "設定の更新"
502
+
503
+ #: includes/admin-setting.php:323 includes/admin-setting.php:1984
504
+ msgid "Reset"
505
+ msgstr "リセット"
506
+
507
+ #: includes/admin-setting.php:331 includes/admin-setting.php:1966
508
+ msgid "Export"
509
+ msgstr "エクスポート"
510
+
511
+ #: includes/admin-setting.php:343 includes/admin-setting.php:1279
512
+ msgid "Update Basis of Comparison"
513
+ msgstr "比較基準の更新"
514
+
515
+ #: includes/admin-setting.php:355 includes/admin-setting.php:370
516
+ #: includes/admin-setting.php:936 includes/admin-setting.php:1324
517
+ msgid "Clear Cache"
518
+ msgstr "キャッシュの消去"
519
+
520
+ #: includes/admin-setting.php:396 includes/admin-setting.php:1538
521
+ #: includes/admin-setting.php:1580
522
+ msgid "Get Bearer Token"
523
+ msgstr "Bearer Tokenの取得"
524
+
525
+ #: includes/admin-setting.php:444
526
+ msgid ""
527
+ "There was a problem spawning a call to the WP-Cron system on your site. This "
528
+ "means WP-Cron jobs on your site may not work. The problem was: "
529
+ msgstr ""
530
+ "あなたのサイト上でWP-Cronシステムの呼び出し処理に問題が見つかりました。あなた"
531
+ "のサイト上でWP-Cronジョブが動作しない可能性があります。問題は次の通りです。"
532
+
533
+ #: includes/admin-setting.php:454 includes/admin-setting.php:465
534
+ #: includes/admin-setting.php:476 includes/admin-setting.php:487
535
+ msgid ""
536
+ "Configuratin is not enough to get follower count. Please set required "
537
+ "parameters at "
538
+ msgstr ""
539
+ "フォロワー数を取得するために必要な設定が不足しています。次のセクションで必要"
540
+ "なパラメータを設定して下さい。"
541
+
542
+ #: includes/admin-setting.php:455 includes/admin-setting.php:1331
543
+ msgid "Follow Base Cache - Instagram"
544
+ msgstr "フォロー基本キャシュ機能 - Instagram"
545
+
546
+ #: includes/admin-setting.php:466 includes/admin-setting.php:758
547
+ #: includes/admin-setting.php:1391
548
+ msgid "Follow Base Cache - Facebook"
549
+ msgstr "フォロー基本キャッシュ機能 - Facebook"
550
+
551
+ #: includes/admin-setting.php:477 includes/admin-setting.php:1489
552
+ msgid "Follow Base Cache - Push7"
553
+ msgstr "フォロー基本キャッシュ機能 - Push7"
554
+
555
+ #: includes/admin-setting.php:488 includes/admin-setting.php:743
556
+ #: includes/admin-setting.php:1510
557
+ msgid "Follow Base Cache - Twitter"
558
+ msgstr "フォロー基本キャッシュ機能 - Twitter"
559
+
560
+ #: includes/admin-setting.php:507 includes/admin-setting.php:512
561
+ msgid "Current Setting"
562
+ msgstr "現在の設定"
563
+
564
+ #: includes/admin-setting.php:507 includes/admin-setting.php:524
565
+ #: includes/admin-setting.php:558 includes/admin-setting.php:571
566
+ #: includes/admin-setting.php:576 includes/admin-setting.php:581
567
+ #: includes/admin-setting.php:595 includes/admin-setting.php:857
568
+ msgid "Share Base Cache"
569
+ msgstr "シェア基本キャッシュ機能"
570
+
571
+ #: includes/admin-setting.php:507 includes/admin-setting.php:627
572
+ #: includes/admin-setting.php:640 includes/admin-setting.php:982
573
+ msgid "Share Rush Cache"
574
+ msgstr "シェア臨時キャッシュ機能"
575
+
576
+ #: includes/admin-setting.php:507 includes/admin-setting.php:649
577
+ #: includes/admin-setting.php:670 includes/admin-setting.php:1023
578
+ msgid "Share Variation Analysis"
579
+ msgstr "シェア変動分析機能"
580
+
581
+ #: includes/admin-setting.php:507 includes/admin-setting.php:678
582
+ #: includes/admin-setting.php:703 includes/admin-setting.php:1285
583
+ msgid "Follow Base Cache"
584
+ msgstr "フォロー基本キャッシュ機能"
585
+
586
+ #: includes/admin-setting.php:507 includes/admin-setting.php:772
587
+ #: includes/admin-setting.php:1588
588
+ msgid "Dynamic Cache"
589
+ msgstr "動的キャッシュ機能"
590
+
591
+ #: includes/admin-setting.php:507 includes/admin-setting.php:793
592
+ #: includes/admin-setting.php:809 includes/admin-setting.php:1611
593
+ msgid "Data Crawler"
594
+ msgstr "データクローラ機能"
595
+
596
+ #: includes/admin-setting.php:507 includes/admin-setting.php:822
597
+ #: includes/admin-setting.php:840 includes/admin-setting.php:1647
598
+ msgid "Data Export"
599
+ msgstr "データエクスポート機能"
600
+
601
+ #: includes/admin-setting.php:507 includes/admin-setting.php:1938
602
+ msgid "Exported File"
603
+ msgstr "エクスポートされたファイル"
604
+
605
+ #: includes/admin-setting.php:517
606
+ msgid "Capability"
607
+ msgstr "機能"
608
+
609
+ #: includes/admin-setting.php:518
610
+ msgid "Parameter"
611
+ msgstr "パラメータ"
612
+
613
+ #: includes/admin-setting.php:519
614
+ msgid "Value"
615
+ msgstr "値"
616
+
617
+ #: includes/admin-setting.php:525 includes/admin-setting.php:679
618
+ #: includes/admin-setting.php:861 includes/admin-setting.php:1289
619
+ msgid "Target SNS"
620
+ msgstr "対象SNS"
621
+
622
+ #: includes/admin-setting.php:537 includes/admin-setting.php:873
623
+ msgid "Hatena Bookmark"
624
+ msgstr "はてなブックマーク"
625
+
626
+ #: includes/admin-setting.php:559 includes/admin-setting.php:886
627
+ msgid "Custom post types"
628
+ msgstr "カスタム投稿タイプ"
629
+
630
+ #: includes/admin-setting.php:572 includes/admin-setting.php:641
631
+ #: includes/admin-setting.php:894 includes/admin-setting.php:1008
632
+ msgid "Interval cheking share count (sec)"
633
+ msgstr "シェア数のチェック間隔(秒)"
634
+
635
+ #: includes/admin-setting.php:573 includes/admin-setting.php:644
636
+ #: includes/admin-setting.php:705 includes/admin-setting.php:1011
637
+ msgid "seconds"
638
+ msgstr "秒"
639
+
640
+ #: includes/admin-setting.php:577 includes/admin-setting.php:901
641
+ msgid "Number of contents to check at a time"
642
+ msgstr "一度にチェックするコンテンツ数"
643
+
644
+ #: includes/admin-setting.php:578
645
+ msgid "contents"
646
+ msgstr "コンテンツ"
647
+
648
+ #: includes/admin-setting.php:582 includes/admin-setting.php:908
649
+ msgid "Scheme migration mode from http to https"
650
+ msgstr "HTTPからHTTPSへのスキーム移行モード"
651
+
652
+ #: includes/admin-setting.php:586 includes/admin-setting.php:814
653
+ #: includes/admin-setting.php:912 includes/admin-setting.php:1634
654
+ msgid "On"
655
+ msgstr "有効"
656
+
657
+ #: includes/admin-setting.php:588 includes/admin-setting.php:816
658
+ #: includes/admin-setting.php:911 includes/admin-setting.php:1633
659
+ msgid "Off"
660
+ msgstr "無効"
661
+
662
+ #: includes/admin-setting.php:596 includes/admin-setting.php:919
663
+ msgid "Scheme migration date from http to https"
664
+ msgstr "HTTPからHTTPSへのスキーム移行日"
665
+
666
+ #: includes/admin-setting.php:611 includes/admin-setting.php:943
667
+ msgid "Share Base Cache - Twitter"
668
+ msgstr "シェア基本キャッシュ機能 - Twitter"
669
+
670
+ #: includes/admin-setting.php:612 includes/admin-setting.php:947
671
+ msgid "Alternative Twitter API"
672
+ msgstr "代替Twitter API"
673
+
674
+ #: includes/admin-setting.php:628 includes/admin-setting.php:986
675
+ msgid "Term considering posted content as new content"
676
+ msgstr "投稿日からコンテンツを新着とみなす期間"
677
+
678
+ #: includes/admin-setting.php:632
679
+ msgid "day"
680
+ msgstr ""
681
+
682
+ #: includes/admin-setting.php:634
683
+ msgid "days"
684
+ msgstr ""
685
+
686
+ #: includes/admin-setting.php:650 includes/admin-setting.php:1027
687
+ msgid "Method to update basis of comparison"
688
+ msgstr "比較基準の更新方式"
689
+
690
+ #: includes/admin-setting.php:654 includes/admin-setting.php:777
691
+ #: includes/admin-setting.php:1030 includes/admin-setting.php:1595
692
+ msgid "Disabled (None)"
693
+ msgstr "無効(なし)"
694
+
695
+ #: includes/admin-setting.php:657 includes/admin-setting.php:1031
696
+ msgid "Enabled (Manual)"
697
+ msgstr "有効(手動)"
698
+
699
+ #: includes/admin-setting.php:660 includes/admin-setting.php:1032
700
+ msgid "Enabled (Scheduler)"
701
+ msgstr "有効(スケジューラ)"
702
+
703
+ #: includes/admin-setting.php:671
704
+ msgid "Schedule"
705
+ msgstr "スケジュール"
706
+
707
+ #: includes/admin-setting.php:704 includes/admin-setting.php:1314
708
+ msgid "Interval cheking follower count (sec)"
709
+ msgstr "フォロワー数のチェック間隔(秒)"
710
+
711
+ #: includes/admin-setting.php:709 includes/admin-setting.php:736
712
+ #: includes/admin-setting.php:1459
713
+ msgid "Follow Base Cache - Feedly"
714
+ msgstr "フォロー基本キャッシュ機能 - Feedly"
715
+
716
+ #: includes/admin-setting.php:710 includes/admin-setting.php:1463
717
+ msgid "Target feed type"
718
+ msgstr "対象フィードタイプ"
719
+
720
+ #: includes/admin-setting.php:715 includes/admin-setting.php:730
721
+ #: includes/admin-setting.php:1466
722
+ msgid "Default"
723
+ msgstr "デフォルト"
724
+
725
+ #: includes/admin-setting.php:718 includes/admin-setting.php:1467
726
+ msgid "RSS"
727
+ msgstr "RSS"
728
+
729
+ #: includes/admin-setting.php:721 includes/admin-setting.php:1468
730
+ msgid "RSS2"
731
+ msgstr "RSS2"
732
+
733
+ #: includes/admin-setting.php:724 includes/admin-setting.php:1469
734
+ msgid "RDF"
735
+ msgstr "RDF"
736
+
737
+ #: includes/admin-setting.php:727 includes/admin-setting.php:1470
738
+ msgid "ATOM"
739
+ msgstr "ATOM"
740
+
741
+ #: includes/admin-setting.php:737 includes/admin-setting.php:1476
742
+ msgid "Target feed"
743
+ msgstr "対象フィード"
744
+
745
+ #: includes/admin-setting.php:744
746
+ msgid "Target screen name"
747
+ msgstr "対象スクリーンネーム"
748
+
749
+ #: includes/admin-setting.php:759 includes/admin-setting.php:1395
750
+ msgid "Page ID"
751
+ msgstr "対象ページID"
752
+
753
+ #: includes/admin-setting.php:773 includes/admin-setting.php:1592
754
+ msgid "Dynamic caching based on user access"
755
+ msgstr "ユーザアクセスをトリガとする動的キャッシュ"
756
+
757
+ #: includes/admin-setting.php:780 includes/admin-setting.php:1596
758
+ msgid "Enabled (Synchronous Cache)"
759
+ msgstr "有効(同期キャッシュ)"
760
+
761
+ #: includes/admin-setting.php:783 includes/admin-setting.php:1597
762
+ msgid "Enabled (Asynchronous Cache)"
763
+ msgstr "有効(非同期キャッシュ)"
764
+
765
+ #: includes/admin-setting.php:786 includes/admin-setting.php:1598
766
+ msgid "Enabled (Asynchronous 2nd Cache)"
767
+ msgstr "有効(非同期2次キャッシュ)"
768
+
769
+ #: includes/admin-setting.php:794 includes/admin-setting.php:1615
770
+ msgid "Crawl method"
771
+ msgstr "クロールの方式"
772
+
773
+ #: includes/admin-setting.php:799 includes/admin-setting.php:1620
774
+ msgid "Normal (Sequential Retrieval)"
775
+ msgstr "標準(逐次検索)"
776
+
777
+ #: includes/admin-setting.php:802 includes/admin-setting.php:1623
778
+ msgid "Extended (Parallel Retrieval)"
779
+ msgstr "拡張(並列検索)"
780
+
781
+ #: includes/admin-setting.php:810 includes/admin-setting.php:1630
782
+ msgid "SSL verification"
783
+ msgstr "SSL証明書の検証"
784
+
785
+ #: includes/admin-setting.php:823 includes/admin-setting.php:1651
786
+ msgid "Method of data export"
787
+ msgstr "データのエクスポート方式"
788
+
789
+ #: includes/admin-setting.php:827 includes/admin-setting.php:1654
790
+ msgid "Manual"
791
+ msgstr "手動"
792
+
793
+ #: includes/admin-setting.php:830 includes/admin-setting.php:1067
794
+ #: includes/admin-setting.php:1655 includes/admin-setting.php:1690
795
+ msgid "Scheduler"
796
+ msgstr "有効(スケジューラ)"
797
+
798
+ #: includes/admin-setting.php:841
799
+ msgid "Interval exporting share count to a csv file"
800
+ msgstr "シェア数をCSVファイルにエクスポートする間隔"
801
+
802
+ #: includes/admin-setting.php:842
803
+ msgid "hours"
804
+ msgstr "時間"
805
+
806
+ #: includes/admin-setting.php:890
807
+ msgid "e.g. aaa, bbb, ccc (comma-delimited)"
808
+ msgstr "例. aaa, bbb, ccc(カンマ区切り)"
809
+
810
+ #: includes/admin-setting.php:897
811
+ msgid "Default: 600"
812
+ msgstr "既定値: 600"
813
+
814
+ #: includes/admin-setting.php:904
815
+ msgid "Default: 20"
816
+ msgstr "既定値: 20"
817
+
818
+ #: includes/admin-setting.php:914
819
+ msgid "Default: Off"
820
+ msgstr "既定値: 無効"
821
+
822
+ #: includes/admin-setting.php:922
823
+ msgid "Default: N/A"
824
+ msgstr "既定値: N/A"
825
+
826
+ #: includes/admin-setting.php:954
827
+ msgid "Default: "
828
+ msgstr "規定値: "
829
+
830
+ #: includes/admin-setting.php:958
831
+ msgid "Registration destination"
832
+ msgstr "登録先"
833
+
834
+ #: includes/admin-setting.php:970
835
+ msgid ""
836
+ "You need to register information such as your domain with the above site in "
837
+ "order to start counting."
838
+ msgstr ""
839
+ "カウントを開始するためには、上記サイトにドメイン等の情報を登録する必要があり"
840
+ "ます。"
841
+
842
+ #: includes/admin-setting.php:989
843
+ msgid "1 day"
844
+ msgstr "1日"
845
+
846
+ #: includes/admin-setting.php:990
847
+ msgid "2 days"
848
+ msgstr "2日"
849
+
850
+ #: includes/admin-setting.php:991
851
+ msgid "3 days"
852
+ msgstr "3日"
853
+
854
+ #: includes/admin-setting.php:992
855
+ msgid "4 days"
856
+ msgstr "4日"
857
+
858
+ #: includes/admin-setting.php:993
859
+ msgid "5 days"
860
+ msgstr "5日"
861
+
862
+ #: includes/admin-setting.php:994
863
+ msgid "6 days"
864
+ msgstr "6日"
865
+
866
+ #: includes/admin-setting.php:995
867
+ msgid "7 days"
868
+ msgstr "7日"
869
+
870
+ #: includes/admin-setting.php:996
871
+ msgid "8 days"
872
+ msgstr "8日"
873
+
874
+ #: includes/admin-setting.php:997
875
+ msgid "9 days"
876
+ msgstr "9日"
877
+
878
+ #: includes/admin-setting.php:998
879
+ msgid "10 days"
880
+ msgstr "10日"
881
+
882
+ #: includes/admin-setting.php:999
883
+ msgid "11 days"
884
+ msgstr "11日"
885
+
886
+ #: includes/admin-setting.php:1000
887
+ msgid "12 days"
888
+ msgstr "12日"
889
+
890
+ #: includes/admin-setting.php:1001
891
+ msgid "13 days"
892
+ msgstr "13日"
893
+
894
+ #: includes/admin-setting.php:1002
895
+ msgid "14 days"
896
+ msgstr "14日"
897
+
898
+ #: includes/admin-setting.php:1004
899
+ msgid "Default: 3 days"
900
+ msgstr "既定値: 3日"
901
+
902
+ #: includes/admin-setting.php:1034
903
+ msgid "Default: None"
904
+ msgstr "既定値: なし"
905
+
906
+ #: includes/admin-setting.php:1072 includes/admin-setting.php:1695
907
+ msgid "Type"
908
+ msgstr "タイプ"
909
+
910
+ #: includes/admin-setting.php:1077 includes/admin-setting.php:1700
911
+ msgid "Hour"
912
+ msgstr ""
913
+
914
+ #: includes/admin-setting.php:1080 includes/admin-setting.php:1703
915
+ msgid "Minute"
916
+ msgstr ""
917
+
918
+ #: includes/admin-setting.php:1086 includes/admin-setting.php:1709
919
+ msgid "monthly"
920
+ msgstr "毎月"
921
+
922
+ #: includes/admin-setting.php:1097 includes/admin-setting.php:1720
923
+ msgid "on 1."
924
+ msgstr "1日"
925
+
926
+ #: includes/admin-setting.php:1100 includes/admin-setting.php:1723
927
+ msgid "on 2."
928
+ msgstr "2日"
929
+
930
+ #: includes/admin-setting.php:1103 includes/admin-setting.php:1726
931
+ msgid "on 3."
932
+ msgstr "3日"
933
+
934
+ #: includes/admin-setting.php:1106 includes/admin-setting.php:1729
935
+ msgid "on 4."
936
+ msgstr "4日"
937
+
938
+ #: includes/admin-setting.php:1109 includes/admin-setting.php:1732
939
+ msgid "on 5."
940
+ msgstr "5日"
941
+
942
+ #: includes/admin-setting.php:1112 includes/admin-setting.php:1735
943
+ msgid "on 6."
944
+ msgstr "6日"
945
+
946
+ #: includes/admin-setting.php:1115 includes/admin-setting.php:1738
947
+ msgid "on 7."
948
+ msgstr "7日"
949
+
950
+ #: includes/admin-setting.php:1118 includes/admin-setting.php:1741
951
+ msgid "on 8."
952
+ msgstr "8日"
953
+
954
+ #: includes/admin-setting.php:1121 includes/admin-setting.php:1744
955
+ msgid "on 9."
956
+ msgstr "9日"
957
+
958
+ #: includes/admin-setting.php:1124 includes/admin-setting.php:1747
959
+ msgid "on 10."
960
+ msgstr "10日"
961
+
962
+ #: includes/admin-setting.php:1127 includes/admin-setting.php:1750
963
+ msgid "on 11."
964
+ msgstr "11日"
965
+
966
+ #: includes/admin-setting.php:1130 includes/admin-setting.php:1753
967
+ msgid "on 12."
968
+ msgstr "12日"
969
+
970
+ #: includes/admin-setting.php:1133 includes/admin-setting.php:1756
971
+ msgid "on 13."
972
+ msgstr "13日"
973
+
974
+ #: includes/admin-setting.php:1136 includes/admin-setting.php:1759
975
+ msgid "on 14."
976
+ msgstr "14日"
977
+
978
+ #: includes/admin-setting.php:1139 includes/admin-setting.php:1762
979
+ msgid "on 15."
980
+ msgstr "15日"
981
+
982
+ #: includes/admin-setting.php:1142 includes/admin-setting.php:1765
983
+ msgid "on 16."
984
+ msgstr "16日"
985
+
986
+ #: includes/admin-setting.php:1145 includes/admin-setting.php:1768
987
+ msgid "on 17."
988
+ msgstr "17日"
989
+
990
+ #: includes/admin-setting.php:1148 includes/admin-setting.php:1771
991
+ msgid "on 18."
992
+ msgstr "18日"
993
+
994
+ #: includes/admin-setting.php:1151 includes/admin-setting.php:1774
995
+ msgid "on 19."
996
+ msgstr "19日"
997
+
998
+ #: includes/admin-setting.php:1154 includes/admin-setting.php:1777
999
+ msgid "on 20."
1000
+ msgstr "20日"
1001
+
1002
+ #: includes/admin-setting.php:1157 includes/admin-setting.php:1780
1003
+ msgid "on 21."
1004
+ msgstr "21日"
1005
+
1006
+ #: includes/admin-setting.php:1160 includes/admin-setting.php:1783
1007
+ msgid "on 22."
1008
+ msgstr "22日"
1009
+
1010
+ #: includes/admin-setting.php:1163 includes/admin-setting.php:1786
1011
+ msgid "on 23."
1012
+ msgstr "23日"
1013
+
1014
+ #: includes/admin-setting.php:1166 includes/admin-setting.php:1789
1015
+ msgid "on 24."
1016
+ msgstr "24日"
1017
+
1018
+ #: includes/admin-setting.php:1169 includes/admin-setting.php:1792
1019
+ msgid "on 25."
1020
+ msgstr "25日"
1021
+
1022
+ #: includes/admin-setting.php:1172 includes/admin-setting.php:1795
1023
+ msgid "on 26."
1024
+ msgstr "26日"
1025
+
1026
+ #: includes/admin-setting.php:1175 includes/admin-setting.php:1798
1027
+ msgid "on 27."
1028
+ msgstr "27日"
1029
+
1030
+ #: includes/admin-setting.php:1178 includes/admin-setting.php:1801
1031
+ msgid "on 28."
1032
+ msgstr "28日"
1033
+
1034
+ #: includes/admin-setting.php:1181 includes/admin-setting.php:1804
1035
+ msgid "on 29."
1036
+ msgstr "29日"
1037
+
1038
+ #: includes/admin-setting.php:1184 includes/admin-setting.php:1807
1039
+ msgid "on 30."
1040
+ msgstr "30日"
1041
+
1042
+ #: includes/admin-setting.php:1187 includes/admin-setting.php:1810
1043
+ msgid "on 31."
1044
+ msgstr "31日"
1045
+
1046
+ #: includes/admin-setting.php:1214 includes/admin-setting.php:1841
1047
+ msgid "weekly"
1048
+ msgstr "毎週"
1049
+
1050
+ #: includes/admin-setting.php:1220 includes/admin-setting.php:1847
1051
+ msgid "Sunday"
1052
+ msgstr "日曜日"
1053
+
1054
+ #: includes/admin-setting.php:1221 includes/admin-setting.php:1848
1055
+ msgid "Monday"
1056
+ msgstr "月曜日"
1057
+
1058
+ #: includes/admin-setting.php:1222 includes/admin-setting.php:1849
1059
+ msgid "Tuesday"
1060
+ msgstr "火曜日"
1061
+
1062
+ #: includes/admin-setting.php:1223 includes/admin-setting.php:1850
1063
+ msgid "Wednesday"
1064
+ msgstr "水曜日"
1065
+
1066
+ #: includes/admin-setting.php:1224 includes/admin-setting.php:1851
1067
+ msgid "Thursday"
1068
+ msgstr "木曜日"
1069
+
1070
+ #: includes/admin-setting.php:1225 includes/admin-setting.php:1852
1071
+ msgid "Friday"
1072
+ msgstr "金曜日"
1073
+
1074
+ #: includes/admin-setting.php:1226 includes/admin-setting.php:1853
1075
+ msgid "Saturday"
1076
+ msgstr "土曜日"
1077
+
1078
+ #: includes/admin-setting.php:1248 includes/admin-setting.php:1879
1079
+ msgid "daily"
1080
+ msgstr "毎日"
1081
+
1082
+ #: includes/admin-setting.php:1317
1083
+ msgid "Default: 86400 Minimum: 3600"
1084
+ msgstr "既定値: 86400 最小値: 3600"
1085
+
1086
+ #: includes/admin-setting.php:1335
1087
+ msgid "Client ID"
1088
+ msgstr "Client ID"
1089
+
1090
+ #: includes/admin-setting.php:1339
1091
+ msgid "Instagram client ID for OAuth"
1092
+ msgstr "OAuth認証のためのInstagram client ID"
1093
+
1094
+ #: includes/admin-setting.php:1343
1095
+ msgid "Client secret"
1096
+ msgstr "Client secret"
1097
+
1098
+ #: includes/admin-setting.php:1347
1099
+ msgid "Instagram client secret for OAuth"
1100
+ msgstr "OAuth認証のためのInstagram client secret"
1101
+
1102
+ #: includes/admin-setting.php:1351 includes/admin-setting.php:1419
1103
+ msgid "Redirect URI"
1104
+ msgstr "Redirect URI"
1105
+
1106
+ #: includes/admin-setting.php:1353 includes/admin-setting.php:1362
1107
+ #: includes/admin-setting.php:1421 includes/admin-setting.php:1430
1108
+ #: includes/admin-setting.php:1542
1109
+ msgid "To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac)."
1110
+ msgstr ""
1111
+ "フィールドをクリック後、Ctrl + C (PC)、またはCmd + C (Mac)を押下しコピーして"
1112
+ "下さい。"
1113
+
1114
+ #: includes/admin-setting.php:1355
1115
+ msgid ""
1116
+ "Copy and set this to the field of \"Valid redirect URIs\" in the client "
1117
+ "management page of Instagram developer page."
1118
+ msgstr ""
1119
+ "Instagram開発者向けページ内のクライアント管理ページにて「Valid redirect "
1120
+ "URIs」フィールドにこのURIを設定して下さい。"
1121
+
1122
+ #: includes/admin-setting.php:1360 includes/admin-setting.php:1370
1123
+ #: includes/admin-setting.php:1428 includes/admin-setting.php:1438
1124
+ msgid "Access token"
1125
+ msgstr "Access Token"
1126
+
1127
+ #: includes/admin-setting.php:1364 includes/admin-setting.php:1432
1128
+ #: includes/admin-setting.php:1544
1129
+ msgid "Copy and pase this into the fields below."
1130
+ msgstr "以下のフィールドにコピー&ペーストして下さい。"
1131
+
1132
+ #: includes/admin-setting.php:1374
1133
+ msgid "Instagram access token for OAuth"
1134
+ msgstr "OAuth認証のためのInstagram access token"
1135
+
1136
+ #: includes/admin-setting.php:1382 includes/admin-setting.php:1450
1137
+ msgid "Get Access Token"
1138
+ msgstr "Access Tokenの取得"
1139
+
1140
+ #: includes/admin-setting.php:1399
1141
+ msgid "Facebook page ID that you want to get follower count"
1142
+ msgstr "フォロワー数を取得するFacebookページID"
1143
+
1144
+ #: includes/admin-setting.php:1403
1145
+ msgid "App ID (Client ID)"
1146
+ msgstr "App ID (Client ID)"
1147
+
1148
+ #: includes/admin-setting.php:1407
1149
+ msgid "Facebook app ID for OAuth"
1150
+ msgstr "OAuth認証のためのFacebook app ID"
1151
+
1152
+ #: includes/admin-setting.php:1411
1153
+ msgid "App secret (Client secret)"
1154
+ msgstr "App secret (Client secret)"
1155
+
1156
+ #: includes/admin-setting.php:1415
1157
+ msgid "Facebook app secret for OAuth"
1158
+ msgstr "OAuth認証のためのFacebook app secret"
1159
+
1160
+ #: includes/admin-setting.php:1423
1161
+ msgid ""
1162
+ "Copy and set this to the field of \"Valid OAuth redirect URIs\" in client "
1163
+ "management page of Facebook developer page"
1164
+ msgstr ""
1165
+ "Facebook開発者向けページ内のクライアント管理ページにて「Valid OAuth redirect "
1166
+ "URIs」フィールドにこのURIを設定して下さい。"
1167
+
1168
+ #: includes/admin-setting.php:1442
1169
+ msgid "Facebook access token for OAuth"
1170
+ msgstr "OAuth認証のためのFacebook access token"
1171
+
1172
+ #: includes/admin-setting.php:1472
1173
+ msgid "Default: Default"
1174
+ msgstr "規定値: デフォルト"
1175
+
1176
+ #: includes/admin-setting.php:1493
1177
+ msgid "AppNo"
1178
+ msgstr "AppNo"
1179
+
1180
+ #: includes/admin-setting.php:1497
1181
+ msgid "Push7 appno to access Push7 API"
1182
+ msgstr "Push7 APIにアクセスするためのAppNo"
1183
+
1184
+ #: includes/admin-setting.php:1514
1185
+ msgid "Screen name"
1186
+ msgstr "スクリーン名"
1187
+
1188
+ #: includes/admin-setting.php:1519
1189
+ msgid "Twitter screen name that you want to get follower count"
1190
+ msgstr "フォロワー数を取得するTwitterのスクリーン名"
1191
+
1192
+ #: includes/admin-setting.php:1523
1193
+ msgid "Consumer key (API Key)"
1194
+ msgstr "Consumer key (API Key)"
1195
+
1196
+ #: includes/admin-setting.php:1527
1197
+ msgid "Twitter consumer key for OAuth"
1198
+ msgstr "OAuth認証のためのTwitter consumer key"
1199
+
1200
+ #: includes/admin-setting.php:1531
1201
+ msgid "Consumer secret (API Secret)"
1202
+ msgstr "Consumer secret (API Secret)"
1203
+
1204
+ #: includes/admin-setting.php:1535
1205
+ msgid "Twitter consumer secret for OAuth"
1206
+ msgstr "OAuth認証のためのTwitter consumer secret"
1207
+
1208
+ #: includes/admin-setting.php:1540 includes/admin-setting.php:1550
1209
+ msgid "Bearer token"
1210
+ msgstr "Bearer token"
1211
+
1212
+ #: includes/admin-setting.php:1554
1213
+ msgid "Twitter bearer token for OAuth"
1214
+ msgstr "OAuth認証のためのTwitter bearer token"
1215
+
1216
+ #: includes/admin-setting.php:1600
1217
+ msgid "Default: Enabled (Asynchronous 2nd Cache)"
1218
+ msgstr "既定値: 有効(非同期2次キャッシュ)"
1219
+
1220
+ #: includes/admin-setting.php:1636
1221
+ msgid "Default: On"
1222
+ msgstr "既定値: 有効"
1223
+
1224
+ #: includes/admin-setting.php:1657
1225
+ msgid "Default: Manual"
1226
+ msgstr "既定値: 手動"
1227
+
1228
+ #: includes/admin-setting.php:1906
1229
+ msgid "hourly"
1230
+ msgstr "毎時"
1231
+
1232
+ #: includes/admin-setting.php:1943
1233
+ msgid "Disk usage of exported file"
1234
+ msgstr "エクスポートされたファイルのディスク使用量"
1235
+
1236
+ #: includes/admin-setting.php:1952
1237
+ msgid "No exported file"
1238
+ msgstr "エクスポートされたファイルは存在しません。"
1239
+
1240
+ #: includes/admin-setting.php:1964
1241
+ msgid "Manual export"
1242
+ msgstr "手動エクスポート"
1243
+
1244
+ #: includes/admin-setting.php:1968
1245
+ msgid "Export share count to a csv file."
1246
+ msgstr "シェア数をCSVファイルにエクスポートします。"
1247
+
1248
+ #: includes/admin-setting.php:1982
1249
+ msgid "Reset of exported file"
1250
+ msgstr "エクスポートされたファイルのリセット"
1251
+
1252
+ #: includes/admin-setting.php:1986
1253
+ msgid "Clear exported csv file."
1254
+ msgstr "エクスポートされたCSVファイルを削除します。"
1255
+
1256
+ #: includes/admin-setting.php:1997
1257
+ msgid "Download of exported file"
1258
+ msgstr "エクスポートされたファイルのダウンロード"
1259
+
1260
+ #: includes/admin-setting.php:1999 includes/download.php:36
1261
+ msgid "Download"
1262
+ msgstr "ダウンロード"
1263
+
1264
+ #: includes/admin-setting.php:2001
1265
+ msgid "Download the exported csv file."
1266
+ msgstr "エクスポートされたCSVファイルをダウンロードします。"
1267
+
1268
+ #: includes/download.php:66 includes/download.php:69 index.php:47 index.php:50
1269
+ #: index.php:53 sns-count-cache.php:1622 sns-count-cache.php:1635
1270
+ #: sns-count-cache.php:1647 sns-count-cache.php:1659 sns-count-cache.php:1671
1271
+ #: sns-count-cache.php:1683 sns-count-cache.php:1695 sns-count-cache.php:1707
1272
+ msgid "You do not have sufficient permissions to access this page."
1273
+ msgstr "このページにアクセスするために必要な権限がありません。"
1274
+
1275
+ #: sns-count-cache.php:1591
1276
+ msgid "Dashboard | SNS Count Cache"
1277
+ msgstr "ダッシュボード | SNS Count Cache"
1278
+
1279
+ #: sns-count-cache.php:1592
1280
+ msgid "Cache Status | SNS Count Cache"
1281
+ msgstr "キャッシュ状況 | SNS Count Cache"
1282
+
1283
+ #: sns-count-cache.php:1593
1284
+ msgid "Share Count | SNS Count Cache"
1285
+ msgstr "シェア数 | SNS Count Cache"
1286
+
1287
+ #: sns-count-cache.php:1596
1288
+ msgid "Hot Content | SNS Count Cache"
1289
+ msgstr "話題のコンテンツ | SNS Count Cache"
1290
+
1291
+ #: sns-count-cache.php:1599
1292
+ msgid "Setting | SNS Count Cache"
1293
+ msgstr "設定 | SNS Count Cache"
1294
+
1295
+ #: sns-count-cache.php:1600
1296
+ msgid "Help | SNS Count Cache"
1297
+ msgstr "ヘルプ | SNS Count Cache"
1298
+
1299
+ #: sns-count-cache.php:2169 sns-count-cache.php:2177 sns-count-cache.php:2309
1300
+ #: sns-count-cache.php:2317
1301
+ msgid "Completed"
1302
+ msgstr "完了"
1303
+
1304
+ #: sns-count-cache.php:2171 sns-count-cache.php:2179 sns-count-cache.php:2311
1305
+ #: sns-count-cache.php:2319
1306
+ msgid "Partially Completed"
1307
+ msgstr "部分的完了"
1308
+
1309
+ #: sns-count-cache.php:2173 sns-count-cache.php:2181 sns-count-cache.php:2313
1310
+ #: sns-count-cache.php:2321
1311
+ msgid "Ongoing"
1312
+ msgstr "進行中"
1313
+
1314
+ #. Plugin URI of the plugin/theme
1315
+ msgid "https://wordpress.org/plugins/sns-count-cache/"
1316
+ msgstr "https://wordpress.org/plugins/sns-count-cache/"
1317
+
1318
+ #. Description of the plugin/theme
1319
+ msgid ""
1320
+ "SNS Count Cache gets share count for Twitter and Facebook, Google Plus, "
1321
+ "Pocket, Hatena Bookmark and caches these count in the background. This "
1322
+ "plugin may help you to shorten page loading time because the share count can "
1323
+ "be retrieved not through network but through the cache using given functions."
1324
+ msgstr ""
1325
+ "SNS Count Cacheは、Twitter、Facebook、Google+、Pocket、はてなブックマークの"
1326
+ "シェア数を取得し、バックグラウンドでキャッシュします。用意された関数を利用す"
1327
+ "ることで、ネットワーク経由でなくキャッシュからシェア数を参照できようになるた"
1328
+ "め、ページ読み込みの高速化が見込めます。"
1329
+
1330
+ #. Author of the plugin/theme
1331
+ msgid "Daisuke Maruyama"
1332
+ msgstr "Daisuke Maruyama"
1333
+
1334
+ #. Author URI of the plugin/theme
1335
+ msgid "http://marubon.info/"
1336
+ msgstr "http://marubon.info/"
1337
+
1338
+ #~ msgid ""
1339
+ #~ "WordPress plugin SNS Count Cache is a plugin which helps you to shorten "
1340
+ #~ "page loading time when your site displays share counts and follow counts. "
1341
+ #~ "This plugin gets share count for Twitter and Facebook, Google Plus, "
1342
+ #~ "Pocket, Hatena Bookmark and caches these count in the background. This "
1343
+ #~ "plugin also caches follower count for Twitter and Facebook, Feedly, "
1344
+ #~ "Instagram, Push7 and caches these count in the same way. The share counts "
1345
+ #~ "and follower counts can be retrieved quickly not through network but "
1346
+ #~ "through the cache using given functions."
1347
+ #~ msgstr ""
1348
+ #~ "WordPressプラグイン SNS Count Cacheは、シェア数やフォロワー数を表示してい"
1349
+ #~ "る場合にページの表示時間を高速化するプラグインです。このプラグインは、"
1350
+ #~ "Twitter、Facebook、Google+、Pocket、はてなブックマークのシェア数をバックグ"
1351
+ #~ "ラウンドで取得し、キャッシュします。またTwitter、Facebook、Feedly、"
1352
+ #~ "Instagram、Push7のフォロワー数も同様の方法でキャッシュします。これらのシェ"
1353
+ #~ "ア数とフォロワー数は、所定の関数を用いることでネットワークからではなく"
1354
+ #~ "キャッシュ経由で迅速に取得可能になります。"
1355
+
1356
+ #~ msgid ""
1357
+ #~ "Copy and set this to the field of Valid redirect URIs in the Instagram "
1358
+ #~ "developer page of manage clients."
1359
+ #~ msgstr ""
1360
+ #~ "これをコピーし、Instagram開発者向けページの「manage clients」内の「Valid "
1361
+ #~ "redirect URIs」のフィールドに設定して下さい。"
1362
+
1363
+ #~ msgid ""
1364
+ #~ "Copy and set this to the field of Valid OAuth redirect URIs in the "
1365
+ #~ "Facebook developer page of Client OAuth Settings."
1366
+ #~ msgstr ""
1367
+ #~ "これをコピーし、Facebook開発者向けページの「Client OAuth Settings」内の"
1368
+ #~ "「Valid OAuth redirect URIs」のフィールドに設定して下さい。"
1369
+
1370
+ #~ msgid ""
1371
+ #~ "WordPress plugin SNS Count Cache is a plugin whitch helps you to shorten "
1372
+ #~ "page loading time when you display share counts. This plugin gets share "
1373
+ #~ "count for Twitter and Facebook, Google Plus, Pocket, Hatena Bookmark and "
1374
+ #~ "caches these count in the background. The share count can be retrieved "
1375
+ #~ "not through network but through the cache using given functions."
1376
+ #~ msgstr ""
1377
+ #~ "WordPressプラグイン SNS Count Cacheは、シェア数を表示している場合にページ"
1378
+ #~ "の表示時間を高速化するプラグインです。このプラグインは、Twitter、"
1379
+ #~ "Facebook、Google+、Pocket、はてなブックマークのシェア数をバックグラウンド"
1380
+ #~ "で取得し、キャッシュします。これらのシェア数は、指定された関数を用いること"
1381
+ #~ "でネットワーク経由ではなく、キャッシュから参照可能になります。"
1382
+
1383
+ #~ msgid ""
1384
+ #~ "What is cache status of \"full cache\", \"partial cache\" and \"no cache"
1385
+ #~ "\"?"
1386
+ #~ msgstr "「完全キャッシュ」、「部分キャッシュ」"
1387
+
1388
+ #~ msgid ""
1389
+ #~ "You need to register your domain with the above site in order to start "
1390
+ #~ "counting."
1391
+ #~ msgstr "カウントを開始するために上記サイトにドメイン"
1392
+
1393
+ #~ msgid ""
1394
+ #~ "The code below describes a simple example which displays share count and "
1395
+ #~ "follower count using the above functions for each post."
1396
+ #~ msgstr ""
1397
+ #~ "以下のコードは、上述した関数を用いて記事ごとにシェア数やフォロワーの数を表"
1398
+ #~ "示する簡単な例です。"
1399
+
1400
+ #~ msgid "A meta key for Twitter share count"
1401
+ #~ msgstr "Twitterのシェア数のためのMeta Keyです。"
1402
+
1403
+ #~ msgid "A meta key for Facebook share count"
1404
+ #~ msgstr "Facebookのシェア数のためのMeta Keyです。"
1405
+
1406
+ #~ msgid "A meta key for Google+ share count"
1407
+ #~ msgstr "Google+のシェア数のためのMeta Keyです。"
1408
+
1409
+ #~ msgid "A meta key for Hatena Bookmark share count"
1410
+ #~ msgstr "はてなブックマークのシェア数のためのMeta Keyです。"
1411
+
1412
+ #~ msgid "A meta key for Pocket share count"
1413
+ #~ msgstr "Pocketのシェア数のためのMeta Keyです。"
1414
+
1415
+ #~ msgid "A meta key for total share count"
1416
+ #~ msgstr "シェア数の合計のためのMeta Keyです。"
1417
+
1418
+ #~ msgid "How can I get follow count from the cache?"
1419
+ #~ msgstr "キャッシュからフォロー数を参照する方法は?"
1420
+
1421
+ #~ msgid ""
1422
+ #~ "The follow count is retrieved from the cache using the following "
1423
+ #~ "functions."
1424
+ #~ msgstr "フォロー数は、以下の関数を用いることでキャッシュから参照可能です。"
1425
+
1426
+ #~ msgid "Feedly follow count is returned from cache."
1427
+ #~ msgstr "キャッシュからFeedlyのフォロー数を取得します。"
1428
+
1429
+ #~ msgid "Twitter follow count is returned from cache."
1430
+ #~ msgstr "キャッシュからFeedlyのフォロー数を取得します。"
readme.txt CHANGED
@@ -1,134 +1,163 @@
1
- === SNS Count Cache ===
2
- Contributors: marubon
3
- Donate link:
4
- Tags: performance, SNS, social, cache, share
5
- Requires at least: 3.7
6
- Tested up to: 4.3
7
- Stable tag: 0.8.0
8
- License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
-
11
- This plugin gets and caches SNS share count in the background, and help you to shorten page loading time.
12
-
13
- == Description ==
14
-
15
- SNS Count Cache gets share count for Twitter and Facebook, Google Plus, Pocket, Hatena Bookmark and caches these count in the background.
16
- 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.
17
-
18
- Notice: PHP Version 5.3+ is required in order to activate and execute this plugin.
19
-
20
- The following shows functions to get share count from the cache:
21
-
22
- * scc_get_share_twitter()
23
- * scc_get_share_facebook()
24
- * scc_get_share_gplus()
25
- * scc_get_share_pocket()
26
- * scc_get_share_hatebu()
27
- * scc_get_share_total()
28
-
29
- The following shows function to get follower count from the cache:
30
-
31
- * scc_get_follow_feedly()
32
-
33
- The following describes meta keys to get share count from custom field.
34
-
35
- * scc_share_count_twitter
36
- * scc_share_count_facebook
37
- * scc_share_count_google+
38
- * scc_share_count_pocket
39
- * scc_share_count_hatebu
40
- * scc_share_count_total
41
-
42
- The following describes meta keys to get delta of share count from custom field.
43
-
44
- * scc_share_delta_twitter
45
- * scc_share_delta_facebook
46
- * scc_share_delta_google+
47
- * scc_share_delta_pocket
48
- * scc_share_delta_hatebu
49
- * scc_share_delta_total
50
-
51
-
52
- == Installation ==
53
-
54
- 1. Download zip archive file from this repository.
55
-
56
- 2. Login as an administrator to your WordPress admin page.
57
- Using the "Add New" menu option under the "Plugins" section of the navigation,
58
- Click the "Upload" link, find the .zip file you download and then click "Install Now".
59
- You can also unzip and upload the plugin to your plugins directory (i.e. wp-content/plugins/) through FTP/SFTP.
60
-
61
- 3. Finally, activate the plugin on the "Plugins" page.
62
-
63
- == Frequently Asked Questions ==
64
- There are no questions.
65
-
66
- == Screenshots ==
67
- 1. Dashboard to overview cache status and share count
68
- 2. Cache status is described in setting page
69
- 3. Share count for each post can be viewed
70
- 4. Described parameters can be modified in this page
71
- 5. Help page shows available functions to access the cache
72
- 6. Hot content can be viewd.
73
-
74
- == Changelog ==
75
-
76
- = 0.1.0 =
77
- * Initial working version.
78
-
79
- = 0.2.0 =
80
- * Added: function to modify check interval of SNS share count and its number of target posts and pages at a time
81
- * Added: function to cache SNS share count for latest posts and pages preferentially
82
- * Added: function to cache SNS share count based on user access dynamically
83
-
84
- = 0.3.0 =
85
- * Added: Pocket was included as one of cache targets.
86
- * Added: function to modify target SNS that share count is cached
87
- * Added: function to modify term considering posted content as new content in the rush cache.
88
- * Added: page to display share count for specified all tagets.
89
- * Added: function to query pages and posts based on SNS share count using specific custom fields in WP_Query and so on.
90
-
91
- = 0.4.0 =
92
- * Added: admin page was totally improved.
93
- * Added: function to sort contents based on share count was added to admin page of share count.
94
- * Added: content of custom post type was added as share count cache target.
95
- * Added: number of Feedly follower was included as one of cache targets.
96
- * Added: function to export share count data was added.
97
- * Added: cache logic was improved.
98
-
99
- = 0.5.0 =
100
- * Added: function to cache share count for both old and new url in https migration.
101
- * Fixed: share count of Facebook becomes invalid when the count is more than four digits.
102
-
103
- = 0.6.0 =
104
- * Added: function to cache share count for home page.
105
- * Improved: Each retrieval time of SNS count is shortened.
106
- * Improved: loading time of dashboard page is shortened using ajax loading technique.
107
- * Fixed: SNS count of facebook can be 0.
108
- * Fixed: "PHP Notice: has_cap..." is output.
109
-
110
- = 0.7.0 =
111
- * Added: function to display variation of SNS count
112
- * Added: function to access variation of SNS count through custom filed
113
- * Fixed: custom filed used in this plugin is not deleted in a certain case.
114
-
115
- = 0.7.1 =
116
- * Modified: Check interval of follower count is tuned.
117
-
118
- = 0.8.0 =
119
- * Added: Japanese translation
120
- * Improved: Cache processing is stabilized.
121
- * Added: function to select feed type for feedly follower retrieval.
122
-
123
- == Upgrade Notice ==
124
- The following functions are deprecated.
125
-
126
- * get_scc_twitter()
127
- * get_scc_facebook()
128
- * get_scc_gplus()
129
- * get_scc_pocket()
130
- * get_scc_hatebu()
131
-
132
- == Arbitrary section ==
133
-
134
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === SNS Count Cache ===
2
+ Contributors: marubon
3
+ Donate link:
4
+ Tags: performance, SNS, social, cache, share, follower
5
+ Requires at least: 3.7
6
+ Tested up to: 4.5.2
7
+ Stable tag: 0.9.0
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ This plugin gets and caches SNS counts in the background, and help you to shorten page loading time through the use of cache mechanism.
12
+
13
+ == Description ==
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
+ * Hatena Bookmark
26
+
27
+ Note: You can select alternative Twitter API for share count retrieval from among alternatives such as "widgetoon.js & count.jsoon", "OpenShareCount", and "TwitCount".
28
+
29
+ The plugin also caches follower counts for the following SNS in the same way.
30
+
31
+ * Twitter
32
+ * Facebook
33
+ * Feedly
34
+ * Instagram
35
+ * Push7
36
+
37
+ The share and follower counts can be retrieved quickly not through network but through the cache using given functions.
38
+
39
+ The following shows functions to get share count from the cache:
40
+
41
+ * scc_get_share_twitter()
42
+ * scc_get_share_facebook()
43
+ * scc_get_share_gplus()
44
+ * scc_get_share_pocket()
45
+ * scc_get_share_hatebu()
46
+ * scc_get_share_total()
47
+
48
+ The following shows functions to get follower count from the cache:
49
+
50
+ * scc_get_follow_feedly()
51
+ * scc_get_follow_twitter()
52
+ * scc_get_follow_facebook()
53
+ * scc_get_follow_instagram()
54
+ * scc_get_follow_push7()
55
+
56
+ The following describes meta keys to get share count from custom field.
57
+
58
+ * scc_share_count_twitter
59
+ * scc_share_count_facebook
60
+ * scc_share_count_google+
61
+ * scc_share_count_pocket
62
+ * scc_share_count_hatebu
63
+ * scc_share_count_total
64
+
65
+ The following describes meta keys to get delta of share count from custom field.
66
+
67
+ * scc_share_delta_twitter
68
+ * scc_share_delta_facebook
69
+ * scc_share_delta_google+
70
+ * scc_share_delta_pocket
71
+ * scc_share_delta_hatebu
72
+ * scc_share_delta_total
73
+
74
+ == Installation ==
75
+
76
+ 1. Download zip archive file from this repository.
77
+
78
+ 2. Login as an administrator to your WordPress admin page.
79
+ Using the "Add New" menu option under the "Plugins" section of the navigation,
80
+ Click the "Upload" link, find the .zip file you download and then click "Install Now".
81
+ You can also unzip and upload the plugin to your plugins directory (i.e. wp-content/plugins/) through FTP/SFTP.
82
+
83
+ 3. Finally, activate the plugin on the "Plugins" page.
84
+
85
+ == Frequently Asked Questions ==
86
+ There are no questions.
87
+
88
+ == Screenshots ==
89
+ 1. Dashboard to overview cache status and share count
90
+ 2. Cache status is described in setting page
91
+ 3. Share count for each post can be viewed
92
+ 4. Described parameters can be modified in this page
93
+ 5. Help page shows available functions to access the cache
94
+ 6. Hot content can be viewd.
95
+
96
+ == Changelog ==
97
+
98
+ = 0.1.0 =
99
+ * Initial working version.
100
+
101
+ = 0.2.0 =
102
+ * Added: function to modify check interval of SNS share count and its number of target posts and pages at a time
103
+ * Added: function to cache SNS share count for latest posts and pages preferentially
104
+ * Added: function to cache SNS share count based on user access dynamically
105
+
106
+ = 0.3.0 =
107
+ * Added: Pocket is included as one of cache targets.
108
+ * Added: function to modify target SNS that share count is cached
109
+ * Added: function to modify term considering posted content as new content in the rush cache.
110
+ * Added: page to display share count for specified all targets.
111
+ * Added: function to query pages and posts based on SNS share count using specific custom fields in WP_Query and so on.
112
+
113
+ = 0.4.0 =
114
+ * Added: admin page is totally improved.
115
+ * Added: function to sort contents based on share count is added to admin page of share count.
116
+ * Added: content of custom post type is added as share count cache target.
117
+ * Added: number of Feedly follower is included as one of cache targets.
118
+ * Added: function to export share count data is added.
119
+ * Added: cache logic is improved.
120
+
121
+ = 0.5.0 =
122
+ * Added: function to cache share count for both old and new url in https migration.
123
+ * Fixed: share count of Facebook becomes invalid when the count is more than four digits.
124
+
125
+ = 0.6.0 =
126
+ * Added: function to cache share count for home page.
127
+ * Improved: Each retrieval time of SNS count is shortened.
128
+ * Improved: loading time of dashboard page is shortened using ajax loading technique.
129
+ * Fixed: SNS count of facebook can be 0.
130
+ * Fixed: "PHP Notice: has_cap..." is output.
131
+
132
+ = 0.7.0 =
133
+ * Added: function to display variation of SNS count
134
+ * Added: function to access variation of SNS count through custom filed
135
+ * Fixed: custom filed used in this plugin is not deleted in a certain case.
136
+
137
+ = 0.7.1 =
138
+ * Modified: Check interval of follower count is tuned.
139
+
140
+ = 0.8.0 =
141
+ * Added: Japanese translation
142
+ * Improved: Cache processing is stabilized.
143
+ * Added: function to select feed type for feedly follower retrieval.
144
+
145
+ = 0.9.0 =
146
+ * Fixed: Twitter share count retrieval is implemented using alternative Twitter APIs.
147
+ * Improved: Cache processing is stabilized.
148
+ * Added: function to retrieve follower count of Twitter.
149
+ * Added: function to retrieve follower count of Facebook page.
150
+ * Added: function to retrieve follower count of Instagram.
151
+ * Added: function to retrieve follower count of Push7.
152
+ * Added: Information related to the above new functions is added to the help page.
153
+
154
+ == Upgrade Notice ==
155
+ The following functions are deprecated.
156
+
157
+ * get_scc_twitter()
158
+ * get_scc_facebook()
159
+ * get_scc_gplus()
160
+ * get_scc_pocket()
161
+ * get_scc_hatebu()
162
+
163
+ == Arbitrary section ==
sns-count-cache.php CHANGED
@@ -1,2366 +1,2929 @@
1
- <?php
2
- /*
3
- Plugin Name: SNS Count Cache
4
- Description: SNS Count Cache gets share count for Twitter and Facebook, Google Plus, Pocket, 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.8.0
6
- Plugin URI: https://wordpress.org/plugins/sns-count-cache/
7
- Author: Daisuke Maruyama
8
- Author URI: http://marubon.info/
9
- License: GPL2 or later
10
- License URI: http://www.gnu.org/licenses/gpl-2.0.txt
11
- */
12
-
13
- /*
14
-
15
- Copyright (C) 2014 - 2015 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
19
- as published by the Free Software Foundation; either version 2
20
- of the License, or (at your option) any later version.
21
-
22
- This program is distributed in the hope that it will be useful,
23
- but WITHOUT ANY WARRANTY; without even the implied warranty of
24
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
- GNU General Public License for more details.
26
-
27
- You should have received a copy of the GNU General Public License
28
- 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
-
33
- require_once ( dirname( __FILE__ ) . '/includes/class-common-util.php' );
34
- require_once ( dirname( __FILE__ ) . '/includes/class-wp-cron-util.php' );
35
- require_once ( dirname( __FILE__ ) . '/includes/class-sleep-throttle.php' );
36
-
37
- require_once ( dirname( __FILE__ ) . '/includes/interface-order.php' );
38
-
39
- require_once ( dirname( __FILE__ ) . '/includes/class-engine.php' );
40
- require_once ( dirname( __FILE__ ) . '/includes/class-cache-engine.php' );
41
-
42
- require_once ( dirname( __FILE__ ) . '/includes/class-share-cache-engine.php' );
43
- require_once ( dirname( __FILE__ ) . '/includes/class-share-base-cache-engine.php' );
44
- require_once ( dirname( __FILE__ ) . '/includes/class-share-rush-cache-engine.php' );
45
- require_once ( dirname( __FILE__ ) . '/includes/class-share-lazy-cache-engine.php' );
46
- require_once ( dirname( __FILE__ ) . '/includes/class-share-second-cache-engine.php' );
47
- //require_once ( dirname( __FILE__ ) . '/includes/class-share-rescue-cache-engine.php' );
48
-
49
- require_once ( dirname( __FILE__ ) . '/includes/class-follow-cache-engine.php' );
50
- require_once ( dirname( __FILE__ ) . '/includes/class-follow-base-cache-engine.php' );
51
- require_once ( dirname( __FILE__ ) . '/includes/class-follow-lazy-cache-engine.php' );
52
- require_once ( dirname( __FILE__ ) . '/includes/class-follow-second-cache-engine.php' );
53
-
54
- require_once ( dirname( __FILE__ ) . '/includes/class-export-engine.php' );
55
- require_once ( dirname( __FILE__ ) . '/includes/class-common-data-export-engine.php' );
56
-
57
- require_once ( dirname( __FILE__ ) . '/includes/class-common-job-reset-engine.php' );
58
-
59
- require_once ( dirname( __FILE__ ) . '/includes/class-data-crawler.php' );
60
- require_once ( dirname( __FILE__ ) . '/includes/class-share-crawler.php' );
61
- require_once ( dirname( __FILE__ ) . '/includes/class-follow-crawler.php' );
62
-
63
- require_once ( dirname( __FILE__ ) . '/includes/class-analytical-engline.php' );
64
- require_once ( dirname( __FILE__ ) . '/includes/class-share-analytical-engine.php' );
65
-
66
- if ( ! class_exists( 'SNS_Count_Cache' ) ) {
67
-
68
- final class SNS_Count_Cache implements Order {
69
-
70
- /**
71
- * Prefix of share cache ID
72
- */
73
- const OPT_SHARE_BASE_TRANSIENT_PREFIX = 'scc_share_count_';
74
-
75
- /**
76
- * Meta key for share second cache
77
- */
78
- const OPT_SHARE_2ND_META_KEY_PREFIX = 'scc_share_count_';
79
-
80
- /**
81
- * Prefix of follow cache ID
82
- */
83
- const OPT_FOLLOW_BASE_TRANSIENT_PREFIX = 'scc_follow_count_';
84
-
85
- /**
86
- * Meta key for follow second cache
87
- */
88
- const OPT_FOLLOW_2ND_META_KEY_PREFIX = 'scc_follow_count_';
89
-
90
- /**
91
- * Interval cheking and caching share count for share base cache
92
- */
93
- const OPT_SHARE_BASE_CHECK_INTERVAL = 600;
94
-
95
- /**
96
- * Number of posts to check at a time for share base cache
97
- */
98
- const OPT_SHARE_BASE_POSTS_PER_CHECK = 20;
99
-
100
- /**
101
- * Interval cheking and caching share count for share rush cache
102
- */
103
- const OPT_SHARE_RUSH_CHECK_INTERVAL = 300;
104
-
105
- /**
106
- * Term that a content is considered as new content in share rush cache
107
- */
108
- const OPT_SHARE_RUSH_NEW_CONTENT_TERM = 3;
109
-
110
- /**
111
- * Interval for share second cache
112
- */
113
- const OPT_SHARE_2ND_CHECK_INTERVAL = 600;
114
-
115
- /**
116
- * Interval cheking and caching share count for follow base cache
117
- */
118
- const OPT_FOLLOW_BASE_CHECK_INTERVAL = 86400;
119
- const OPT_FOLLOW_BASE_CHECK_INTERVAL_MIN = 3600;
120
-
121
- /**
122
- * Interval for follow second cache
123
- */
124
- const OPT_FOLLOW_2ND_CHECK_INTERVAL = 600;
125
-
126
- /**
127
- * Type of data export
128
- */
129
- const OPT_COMMON_DATA_EXPORT_MANUAL = 1;
130
-
131
- /**
132
- * Type of data export
133
- */
134
- const OPT_COMMON_DATA_EXPORT_SCHEDULER = 2;
135
-
136
- /**
137
- * Type of share analysis
138
- */
139
- const OPT_SHARE_VARIATION_ANALYSIS_NONE = 1;
140
-
141
- /**
142
- * Type of share analysis
143
- */
144
- const OPT_SHARE_VARIATION_ANALYSIS_MANUAL = 2;
145
-
146
- /**
147
- * Type of share analysis
148
- */
149
- const OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER = 3;
150
-
151
- /**
152
- * Type of share analysis
153
- */
154
- const OPT_SHARE_VARIATION_ANALYSIS_SCHEDULE = '0 0 * * *';
155
-
156
- /**
157
- * File name of data export
158
- */
159
- const OPT_COMMON_DATA_EXPORT_FILE_NAME = 'sns-count-cache-data.csv';
160
-
161
- /**
162
- * Data export schedule
163
- */
164
- const OPT_COMMON_DATA_EXPORT_SCHEDULE = '0 0 * * *';
165
-
166
- /**
167
- * Type of dynamic cache processing
168
- */
169
- const OPT_COMMON_ACCESS_BASED_CACHE_NONE = 1;
170
-
171
- /**
172
- * Type of dynamic cache processing
173
- */
174
- const OPT_COMMON_ACCESS_BASED_SYNC_CACHE = 2;
175
-
176
- /**
177
- * Type of dynamic cache processing
178
- */
179
- const OPT_COMMON_ACCESS_BASED_ASYNC_CACHE = 3;
180
-
181
- /**
182
- * Type of dynamic cache processing
183
- */
184
- const OPT_COMMON_ACCESS_BASED_2ND_CACHE = 4;
185
-
186
- /**
187
- * Type of scheme migration mode
188
- */
189
- const OPT_COMMON_SCHEME_MIGRATION_MODE_OFF = false;
190
-
191
- /**
192
- * Type of scheme migration mode
193
- */
194
- const OPT_COMMON_SCHEME_MIGRATION_MODE_ON = true;
195
-
196
- /**
197
- * Error message
198
- */
199
- const OPT_COMMON_ERROR_MESSAGE = 'scc_error_message';
200
-
201
- /**
202
- * Update message
203
- */
204
- const OPT_COMMON_UPDATE_MESSAGE = 'scc_update_message';
205
-
206
- /**
207
- * Type of crawl method
208
- */
209
- const OPT_COMMON_CRAWLER_METHOD_NORMAL = 1;
210
-
211
- /**
212
- * Type of crawl method
213
- */
214
- const OPT_COMMON_CRAWLER_METHOD_CURL = 2;
215
-
216
- /**
217
- * Type of crawl ssl verification
218
- */
219
- const OPT_COMMON_CRAWLER_SSL_VERIFY_ON = true;
220
-
221
- /**
222
- * Type of crawl ssl verification
223
- */
224
- const OPT_COMMON_CRAWLER_SSL_VERIFY_OFF = false;
225
-
226
- /**
227
- * crawler timeout
228
- */
229
- const OPT_COMMON_CRAWLER_TIMEOUT = 10;
230
-
231
- /**
232
- * crawler retry limit
233
- */
234
- const OPT_COMMON_CRAWLER_RETRY_LIMIT = 2;
235
-
236
- /**
237
- * Type of feed
238
- */
239
- const OPT_FEED_TYPE_DEFAULT = '';
240
-
241
- /**
242
- * Type of feed
243
- */
244
- const OPT_FEED_TYPE_RSS = 'rss';
245
-
246
- /**
247
- * Type of feed
248
- */
249
- const OPT_FEED_TYPE_RSS2 = 'rss2';
250
-
251
- /**
252
- * Type of feed
253
- */
254
- const OPT_FEED_TYPE_RDF = 'rdf';
255
-
256
- /**
257
- * Type of feed
258
- */
259
- const OPT_FEED_TYPE_ATOM = 'atom';
260
-
261
- /**
262
- * Capability for admin
263
- */
264
- const OPT_COMMON_CAPABILITY = 'manage_options';
265
-
266
- /**
267
- * Option key for custom post types for share base cache
268
- */
269
- const DB_SHARE_CUSTOM_POST_TYPES = 'share_custom_post_types';
270
-
271
- /**
272
- * Option key for check interval of share base cache
273
- */
274
- const DB_SHARE_BASE_CHECK_INTERVAL = 'share_base_check_interval';
275
-
276
- /**
277
- * Option key for number of posts to check at a time for share base cache
278
- */
279
- const DB_SHARE_POSTS_PER_CHECK = 'share_posts_per_check';
280
-
281
- /**
282
- * Option key for dynamic cache
283
- */
284
- const DB_COMMON_DYNAMIC_CACHE_MODE = 'common_dynamic_cache_mode';
285
-
286
- /**
287
- * Option key for new content term for share rush cache
288
- */
289
- const DB_SHARE_RUSH_NEW_CONTENT_TERM = 'share_new_content_term';
290
-
291
- /**
292
- * Option key for check interval of share rush cache
293
- */
294
- const DB_SHARE_RUSH_CHECK_INTERVAL = 'share_rush_check_interval';
295
-
296
- /**
297
- * Option key of cache target for share base cache
298
- */
299
- const DB_SHARE_CACHE_TARGET = 'share_cache_target';
300
-
301
- /**
302
- * Option key of cache target for follow base cache
303
- */
304
- const DB_FOLLOW_CACHE_TARGET = 'follow_cache_target';
305
-
306
- /**
307
- * Option key of cache target for follow base cache
308
- */
309
- const DB_FOLLOW_FEED_TYPE = '';
310
-
311
- /**
312
- * Option key of checking interval for follow base cache
313
- */
314
- const DB_FOLLOW_CHECK_INTERVAL = 'follow_check_interval';
315
-
316
- /**
317
- * Option key of data export
318
- */
319
- const DB_COMMON_DATA_EXPORT_MODE = 'common_data_export_mode';
320
-
321
- /**
322
- * Option key of data export schedule
323
- */
324
- const DB_COMMON_DATA_EXPORT_SCHEDULE = 'common_data_export_schedule';
325
-
326
- /**
327
- * Option key of http migration
328
- */
329
- const DB_COMMON_SCHEME_MIGRATION_MODE = 'common_scheme_migration_mode';
330
-
331
- /**
332
- * Option key of http migration
333
- */
334
- const DB_COMMON_SCHEME_MIGRATION_DATE = 'common_scheme_migration_date';
335
-
336
- /**
337
- * Option key of crawl ssl verification
338
- */
339
- const DB_COMMON_CRAWLER_SSL_VERIFICATION = 'common_crawler_ssl_verification';
340
-
341
- /**
342
- * Option key of share variation analysis
343
- */
344
- const DB_SHARE_VARIATION_ANALYSIS_MODE = 'share_variation_analysis_mode';
345
-
346
- /**
347
- * Option key of share variation analysis
348
- */
349
- const DB_SHARE_VARIATION_ANALYSIS_SCHEDULE = 'share_variation_analysis_schedule';
350
-
351
- /**
352
- * Option key of setting
353
- */
354
- const DB_SETTINGS = 'scc_settings';
355
-
356
- /**
357
- * Slug of the plugin
358
- */
359
- const DOMAIN = 'sns-count-cache';
360
-
361
- /**
362
- * ID of share base cache
363
- */
364
- const REF_SHARE_BASE = 'share-base';
365
-
366
- /**
367
- * ID of share rush cache
368
- */
369
- const REF_SHARE_RUSH = 'share-rush';
370
-
371
- /**
372
- * ID of share lazy cache
373
- */
374
- const REF_SHARE_LAZY = 'share-lazy';
375
-
376
- /**
377
- * ID of share second cache
378
- */
379
- const REF_SHARE_2ND = 'share-second';
380
-
381
- /**
382
- * ID of share second cache
383
- */
384
- const REF_SHARE_ANALYSIS = 'share-analysis';
385
-
386
- /**
387
- * ID of share second cache
388
- */
389
- const REF_SHARE_RESCUE = 'share-rescue';
390
-
391
- /**
392
- * ID of follow base cache
393
- */
394
- const REF_FOLLOW_BASE = 'follow-base';
395
-
396
- /**
397
- * ID of follow lazy cache
398
- */
399
- const REF_FOLLOW_LAZY = 'follow-lazy';
400
-
401
- /**
402
- * ID of follow second cache
403
- */
404
- const REF_FOLLOW_2ND = 'follow-second';
405
-
406
- /**
407
- * ID of common data export
408
- */
409
- const REF_COMMON_EXPORT = 'common-export';
410
-
411
- /**
412
- * ID of common data export
413
- */
414
- const REF_COMMON_CONTROL = 'common-control';
415
-
416
- /**
417
- * ID of share
418
- */
419
- const REF_SHARE = 'share';
420
-
421
- /**
422
- * ID of follow
423
- */
424
- const REF_FOLLOW = 'follow';
425
-
426
- /**
427
- * ID of share count (Twitter)
428
- */
429
- const REF_SHARE_TWITTER = 'Twitter';
430
-
431
- /**
432
- * ID of share count (Facebook)
433
- */
434
- const REF_SHARE_FACEBOOK = 'Facebook';
435
-
436
- /**
437
- * ID of share count (Google Plus)
438
- */
439
- const REF_SHARE_GPLUS = 'Google+';
440
-
441
- /**
442
- * ID of share count (Hatena Bookmark)
443
- */
444
- const REF_SHARE_HATEBU = 'Hatebu';
445
-
446
- /**
447
- * ID of share count (Pocket)
448
- */
449
- const REF_SHARE_POCKET = 'Pocket';
450
-
451
- /**
452
- * ID of share count (Pinterest)
453
- */
454
- const REF_SHARE_PINTEREST = 'Pinterest';
455
-
456
- /**
457
- * ID of share count (LinkedIn)
458
- */
459
- const REF_SHARE_LINKEDIN = 'Linkedin';
460
-
461
- /**
462
- * ID of share count (Total)
463
- */
464
- const REF_SHARE_TOTAL = 'Total';
465
-
466
- /**
467
- * ID of follow count (Feedly)
468
- */
469
- const REF_FOLLOW_FEEDLY = 'Feedly';
470
-
471
- /**
472
- * ID of crawl date
473
- */
474
- const REF_CRAWL_DATE = 'CrawlDate';
475
-
476
- /**
477
- * Plugin version, used for cache-busting of style and script file references.
478
- */
479
- private $version = '0.8.0';
480
-
481
- /**
482
- * Instances of crawler
483
- */
484
- private $crawlers = array();
485
-
486
- /**
487
- * Instance of cache engine
488
- */
489
- private $cache_engines = array();
490
-
491
- /**
492
- * Instance of export engine
493
- */
494
- private $export_engines = array();
495
-
496
- /**
497
- * Instance of control engine
498
- */
499
- private $control_engines = array();
500
-
501
- /**
502
- * Instance of analytical engine
503
- */
504
- private $analytical_engines = array();
505
-
506
- /**
507
- * Slug of the plugin screen
508
- */
509
- private $plugin_screen_hook_suffix = array();
510
-
511
- /**
512
- * Cache target for share base cache
513
- */
514
- private $share_base_cache_target = array();
515
-
516
- /**
517
- * Post types to be cached
518
- */
519
- private $share_base_cache_post_types = array( 'post', 'page' );
520
-
521
- /**
522
- * Post types to be cached
523
- */
524
- private $share_base_custom_post_types = array();
525
-
526
- /**
527
- * Check interval for share base cahce
528
- */
529
- private $share_base_check_interval = 600;
530
-
531
- /**
532
- * Post per check for share base cache
533
- */
534
- private $share_base_posts_per_check = 20;
535
-
536
- /**
537
- * Term considering content as new one
538
- */
539
- private $share_rush_new_content_term = 3;
540
-
541
- /**
542
- *Check interval for share rush cahce
543
- */
544
- private $share_rush_check_interval = 300;
545
-
546
- /**
547
- * Cache target for follow base cache
548
- */
549
- private $follow_base_cache_target = array();
550
-
551
- /**
552
- * Check interval for follow base cache
553
- */
554
- private $follow_base_check_interval = 1800;
555
-
556
- /**
557
- * Feed type to be followed
558
- */
559
- private $follow_feed_type = '';
560
-
561
- /**
562
- * Dynamic cache mode
563
- */
564
- private $dynamic_cache_mode = 1;
565
-
566
- /**
567
- * Data export mode
568
- */
569
- private $data_export_mode = 1;
570
-
571
- /**
572
- * Data export schedule
573
- */
574
- private $data_export_schedule = '0 0 * * *';
575
-
576
- /**
577
- * Share variation analysis mode
578
- */
579
- private $share_variation_analysis_mode = 1;
580
-
581
- /**
582
- * Share variation analysis schedule
583
- */
584
- private $share_variation_analysis_schedule = '0 0 * * *';
585
-
586
- /**
587
- * Migration mode from http to https
588
- */
589
- private $scheme_migration_mode = false;
590
-
591
- /**
592
- * Migration date from http to https
593
- */
594
- private $scheme_migration_date = NULL;
595
-
596
- /**
597
- * Excluded key in migration from http to https
598
- */
599
- private $scheme_migration_exclude_keys = array();
600
-
601
- /**
602
- * Max execution time
603
- */
604
- private $original_max_execution_time = 0;
605
-
606
- /**
607
- * Extended max execution time
608
- */
609
- private $extended_max_execution_time = 600;
610
-
611
- /**
612
- * URL of loding image
613
- */
614
- private $loading_img_url = '';
615
-
616
- /**
617
- * ajax action
618
- */
619
- private $ajax_action = 'scc_cache_info';
620
-
621
- /**
622
- * Cralwer method
623
- */
624
- private $crawler_method = 1;
625
-
626
- /**
627
- * Cralwer SSL verification
628
- */
629
- private $crawler_ssl_verification = true;
630
-
631
- /**
632
- * Instance
633
- */
634
- private static $instance = NULL;
635
-
636
- /**
637
- * Class constarctor
638
- * Hook onto all of the actions and filters needed by the plugin.
639
- */
640
- private function __construct() {
641
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
642
-
643
- load_plugin_textdomain( self::DOMAIN, false, basename( dirname( __FILE__ ) ) . '/languages' );
644
-
645
- register_activation_hook( __FILE__, array( $this, 'activate_plugin' ) );
646
- register_deactivation_hook( __FILE__, array( $this, 'deactivate_plugin' ) );
647
-
648
- add_action( 'admin_menu', array( $this, 'register_admin_menu' ) );
649
-
650
- add_action( 'admin_print_styles', array( $this, 'register_admin_styles' ) );
651
- add_action( 'admin_enqueue_scripts', array( $this, 'register_admin_scripts' ) );
652
-
653
- //add_action( 'admin_notices', array( $this, 'notice_page' ) );
654
-
655
- add_action( 'wp_ajax_' . $this->ajax_action, array( $this, 'get_cache_info' ) );
656
-
657
- add_action( 'wp_dashboard_setup', array( $this, 'add_wp_dashboard_widget' ) );
658
-
659
- add_action( 'plugins_loaded', array( $this, 'initialize' ) );
660
-
661
- add_action( 'deleted_post' , array( $this, 'clear_cache_deleted_post' ) );
662
-
663
- }
664
-
665
- /**
666
- * Get instance
667
- *
668
- * @since 0.1.1
669
- */
670
- public static function get_instance() {
671
-
672
- if ( ! isset( self::$instance ) ) {
673
- self::$instance = new self;
674
- }
675
-
676
- return self::$instance;
677
- }
678
-
679
- /**
680
- * Return object ID
681
- *
682
- * @since 0.6.0
683
- */
684
- public function get_object_id() {
685
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
686
-
687
- $object_id = spl_object_hash( $this );
688
-
689
- Common_Util::log( '[' . __METHOD__ . '] object ID: ' . $object_id );
690
-
691
- return $object_id;
692
- }
693
-
694
- /**
695
- * Inhibit clone
696
- *
697
- * @since 0.6.0
698
- */
699
- final public function __clone() {
700
- throw new Exception('Clone is not allowed against' . get_class( $this ) );
701
- }
702
-
703
- /**
704
- * Initialization
705
- *
706
- * @since 0.1.1
707
- */
708
- public function initialize() {
709
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
710
-
711
- $settings = get_option( self::DB_SETTINGS );
712
-
713
- if ( isset( $settings[self::DB_SHARE_BASE_CHECK_INTERVAL] ) && $settings[self::DB_SHARE_BASE_CHECK_INTERVAL] ) {
714
- $this->share_base_check_interval = (int) $settings[self::DB_SHARE_BASE_CHECK_INTERVAL];
715
- } else {
716
- $this->share_base_check_interval = self::OPT_SHARE_BASE_CHECK_INTERVAL;
717
- }
718
-
719
- if ( isset( $settings[self::DB_SHARE_POSTS_PER_CHECK] ) && $settings[self::DB_SHARE_POSTS_PER_CHECK] ) {
720
- $this->share_base_posts_per_check = (int) $settings[self::DB_SHARE_POSTS_PER_CHECK];
721
- } else {
722
- $this->share_base_posts_per_check = self::OPT_SHARE_BASE_POSTS_PER_CHECK;
723
- }
724
-
725
- if ( isset( $settings[self::DB_FOLLOW_CHECK_INTERVAL] ) && $settings[self::DB_FOLLOW_CHECK_INTERVAL] ) {
726
- $this->follow_base_check_interval = (int) $settings[self::DB_FOLLOW_CHECK_INTERVAL];
727
- if ( $this->follow_base_check_interval < self::OPT_FOLLOW_BASE_CHECK_INTERVAL_MIN ) {
728
- $this->follow_base_check_interval = self::OPT_FOLLOW_BASE_CHECK_INTERVAL_MIN;
729
- }
730
- } else {
731
- $this->follow_base_check_interval = self::OPT_FOLLOW_BASE_CHECK_INTERVAL;
732
- }
733
-
734
- if ( isset( $settings[self::DB_COMMON_DYNAMIC_CACHE_MODE] ) && $settings[self::DB_COMMON_DYNAMIC_CACHE_MODE] ) {
735
- $this->dynamic_cache_mode = (int) $settings[self::DB_COMMON_DYNAMIC_CACHE_MODE];
736
- } else {
737
- $this->dynamic_cache_mode = self::OPT_COMMON_ACCESS_BASED_2ND_CACHE;
738
- }
739
-
740
- if ( isset( $settings[self::DB_SHARE_RUSH_CHECK_INTERVAL] ) && $settings[self::DB_SHARE_RUSH_CHECK_INTERVAL] ) {
741
- $this->share_rush_check_interval = (int) $settings[self::DB_SHARE_RUSH_CHECK_INTERVAL];
742
- } else {
743
- $this->share_rush_check_interval = self::OPT_SHARE_RUSH_CHECK_INTERVAL;
744
- }
745
-
746
- if ( isset( $settings[self::DB_SHARE_RUSH_NEW_CONTENT_TERM] ) && $settings[self::DB_SHARE_RUSH_NEW_CONTENT_TERM] ) {
747
- $this->share_rush_new_content_term = (int) $settings[self::DB_SHARE_RUSH_NEW_CONTENT_TERM];
748
- } else {
749
- $this->share_rush_new_content_term = self::OPT_SHARE_RUSH_NEW_CONTENT_TERM;
750
- }
751
-
752
- if ( isset( $settings[self::DB_COMMON_DATA_EXPORT_MODE] ) && $settings[self::DB_COMMON_DATA_EXPORT_MODE] ) {
753
- $this->data_export_mode = (int) $settings[self::DB_COMMON_DATA_EXPORT_MODE];
754
- } else {
755
- $this->data_export_mode = self::OPT_COMMON_DATA_EXPORT_MANUAL;
756
- }
757
-
758
- if ( isset( $settings[self::DB_COMMON_DATA_EXPORT_SCHEDULE] ) && $settings[self::DB_COMMON_DATA_EXPORT_SCHEDULE] ) {
759
- $this->data_export_schedule = $settings[self::DB_COMMON_DATA_EXPORT_SCHEDULE];
760
- } else {
761
- $this->data_export_schedule = self::OPT_COMMON_DATA_EXPORT_SCHEDULE;
762
- }
763
-
764
- if ( isset( $settings[self::DB_SHARE_VARIATION_ANALYSIS_MODE] ) && $settings[self::DB_SHARE_VARIATION_ANALYSIS_MODE] ) {
765
- $this->share_variation_analysis_mode = (int) $settings[self::DB_SHARE_VARIATION_ANALYSIS_MODE];
766
- } else {
767
- $this->share_variation_analysis_mode = self::OPT_SHARE_VARIATION_ANALYSIS_NONE;
768
- }
769
-
770
- if ( isset( $settings[self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE] ) && $settings[self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE] ) {
771
- $this->share_variation_analysis_schedule = $settings[self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE];
772
- } else {
773
- $this->share_variation_analysis_schedule = self::OPT_SHARE_VARIATION_ANALYSIS_SCHEDULE;
774
- }
775
-
776
- if ( isset( $settings[self::DB_COMMON_SCHEME_MIGRATION_MODE] ) ) {
777
- $this->scheme_migration_mode = $settings[self::DB_COMMON_SCHEME_MIGRATION_MODE];
778
- } else {
779
- $this->scheme_migration_mode = self::OPT_COMMON_SCHEME_MIGRATION_MODE_OFF;
780
- }
781
-
782
- if ( isset( $settings[self::DB_COMMON_SCHEME_MIGRATION_DATE] ) ) {
783
- $this->scheme_migration_date = $settings[self::DB_COMMON_SCHEME_MIGRATION_DATE];
784
- }
785
-
786
- // Pocket and Google+ are excluded from migration target because they are migrated automatically.
787
- $this->scheme_migration_exclude_keys = array( self::REF_SHARE_POCKET, self::REF_SHARE_GPLUS );
788
-
789
- if ( isset( $settings[self::DB_SHARE_CACHE_TARGET] ) && $settings[self::DB_SHARE_CACHE_TARGET] ) {
790
- $this->share_base_cache_target = $settings[self::DB_SHARE_CACHE_TARGET];
791
- } else {
792
- $this->share_base_cache_target[self::REF_SHARE_TWITTER] = true;
793
- $this->share_base_cache_target[self::REF_SHARE_GPLUS] = true;
794
- $this->share_base_cache_target[self::REF_SHARE_FACEBOOK] = true;
795
- $this->share_base_cache_target[self::REF_SHARE_POCKET] = true;
796
- $this->share_base_cache_target[self::REF_SHARE_HATEBU] = true;
797
- }
798
-
799
- $this->share_base_cache_target[self::REF_CRAWL_DATE] = true;
800
- $this->share_base_cache_target[self::REF_SHARE_TOTAL] = true;
801
-
802
- if ( isset( $settings[self::DB_FOLLOW_CACHE_TARGET] ) && $settings[self::DB_FOLLOW_CACHE_TARGET] ) {
803
- $this->follow_base_cache_target = $settings[self::DB_FOLLOW_CACHE_TARGET];
804
- } else {
805
- $this->follow_base_cache_target[self::REF_FOLLOW_FEEDLY] = true;
806
- }
807
-
808
- if ( isset( $settings[self::DB_FOLLOW_FEED_TYPE] ) && $settings[self::DB_FOLLOW_FEED_TYPE] ) {
809
- $this->follow_feed_type = $settings[self::DB_FOLLOW_FEED_TYPE];
810
- } else {
811
- $this->follow_feed_type = self::OPT_FEED_TYPE_DEFAULT;
812
- }
813
-
814
- if ( isset( $settings[self::DB_SHARE_CUSTOM_POST_TYPES] ) && $settings[self::DB_SHARE_CUSTOM_POST_TYPES] ) {
815
- $this->share_base_custom_post_types = $settings[self::DB_SHARE_CUSTOM_POST_TYPES];
816
- } else {
817
- $this->share_base_custom_post_types = array();
818
- }
819
-
820
- $this->share_base_cache_post_types = array_merge( $this->share_base_cache_post_types, $this->share_base_custom_post_types );
821
-
822
- if ( extension_loaded( 'curl' ) ) {
823
- $this->crawler_method = self::OPT_COMMON_CRAWLER_METHOD_CURL;
824
- } else {
825
- $this->crawler_method = self::OPT_COMMON_CRAWLER_METHOD_NORMAL;
826
- }
827
-
828
- if ( isset( $settings[self::DB_COMMON_CRAWLER_SSL_VERIFICATION] ) ) {
829
- $this->crawler_ssl_verification = $settings[self::DB_COMMON_CRAWLER_SSL_VERIFICATION];
830
- } else {
831
- $this->crawler_ssl_verification = self::OPT_COMMON_CRAWLER_SSL_VERIFY_ON;
832
- }
833
-
834
- // Crawler
835
- $options = array(
836
- 'crawl_method' => $this->crawler_method,
837
- 'timeout' => self::OPT_COMMON_CRAWLER_TIMEOUT,
838
- 'retry_limit' => self::OPT_COMMON_CRAWLER_RETRY_LIMIT,
839
- 'ssl_verification' => $this->crawler_ssl_verification
840
- );
841
-
842
- $this->crawlers[self::REF_SHARE] = Share_Crawler::get_instance();
843
- $this->crawlers[self::REF_SHARE]->initialize( $options );
844
-
845
- $this->crawlers[self::REF_FOLLOW] = Follow_Crawler::get_instance();
846
- $this->crawlers[self::REF_FOLLOW]->initialize( $options );
847
-
848
- // Share base cache engine
849
- $options = array(
850
- 'delegate' => $this,
851
- 'crawler' => $this->crawlers[self::REF_SHARE],
852
- 'target_sns' => $this->share_base_cache_target,
853
- 'check_interval' => $this->share_base_check_interval,
854
- 'posts_per_check' => $this->share_base_posts_per_check,
855
- 'post_types' => $this->share_base_cache_post_types,
856
- 'scheme_migration_mode' => $this->scheme_migration_mode,
857
- 'scheme_migration_date' => $this->scheme_migration_date,
858
- 'scheme_migration_exclude_keys' => $this->scheme_migration_exclude_keys
859
- );
860
-
861
- $this->cache_engines[self::REF_SHARE_BASE] = Share_Base_Cache_Engine::get_instance();
862
- $this->cache_engines[self::REF_SHARE_BASE]->initialize( $options );
863
-
864
- // Share rush cache engine
865
- $options = array(
866
- 'delegate' => $this,
867
- 'crawler' => $this->crawlers[self::REF_SHARE],
868
- 'target_sns' => $this->share_base_cache_target,
869
- 'check_interval' => $this->share_rush_check_interval,
870
- 'posts_per_check' => 30,
871
- 'new_content_term' => $this->share_rush_new_content_term,
872
- 'post_types' => $this->share_base_cache_post_types,
873
- 'scheme_migration_mode' => $this->scheme_migration_mode,
874
- 'scheme_migration_date' => $this->scheme_migration_date,
875
- 'scheme_migration_exclude_keys' => $this->scheme_migration_exclude_keys
876
- );
877
-
878
- $this->cache_engines[self::REF_SHARE_RUSH] = Share_Rush_Cache_Engine::get_instance();
879
- $this->cache_engines[self::REF_SHARE_RUSH]->initialize( $options );
880
-
881
- // Share lazy cache engine
882
- $options = array(
883
- 'delegate' => $this,
884
- 'crawler' => $this->crawlers[self::REF_SHARE],
885
- 'target_sns' => $this->share_base_cache_target,
886
- 'check_interval' => $this->share_base_check_interval,
887
- 'posts_per_check' => $this->share_base_posts_per_check,
888
- 'post_types' => $this->share_base_cache_post_types,
889
- 'scheme_migration_mode' => $this->scheme_migration_mode,
890
- 'scheme_migration_date' => $this->scheme_migration_date,
891
- 'scheme_migration_exclude_keys' => $this->scheme_migration_exclude_keys
892
- );
893
-
894
- $this->cache_engines[self::REF_SHARE_LAZY] = Share_Lazy_Cache_Engine::get_instance();
895
- $this->cache_engines[self::REF_SHARE_LAZY]->initialize( $options );
896
-
897
- // Share second cache engine
898
- $options = array(
899
- 'delegate' => $this,
900
- 'target_sns' => $this->share_base_cache_target,
901
- 'check_interval' => self::OPT_SHARE_2ND_CHECK_INTERVAL,
902
- 'post_types' => $this->share_base_cache_post_types,
903
- 'cache_prefix' => self::OPT_SHARE_2ND_META_KEY_PREFIX,
904
- 'scheme_migration_mode' => $this->scheme_migration_mode,
905
- 'scheme_migration_exclude_keys' => $this->scheme_migration_exclude_keys,
906
- 'crawl_date_key' => self::REF_CRAWL_DATE
907
- );
908
-
909
- $this->cache_engines[self::REF_SHARE_2ND] = Share_Second_Cache_Engine::get_instance();
910
- $this->cache_engines[self::REF_SHARE_2ND]->initialize( $options );
911
-
912
- /*
913
- // Share rescue cache engine
914
- $options = array(
915
- 'delegate' => $this,
916
- 'crawler' => $this->crawlers[self::REF_SHARE],
917
- 'target_sns' => $this->share_base_cache_target,
918
- 'check_interval' => $this->share_base_check_interval,
919
- 'posts_per_check' => $this->share_base_posts_per_check,
920
- 'post_types' => $this->share_base_cache_post_types,
921
- 'scheme_migration_mode' => $this->scheme_migration_mode,
922
- 'scheme_migration_exclude_keys' => $this->scheme_migration_exclude_keys
923
- );
924
-
925
- $this->cache_engines[self::REF_SHARE_RESCUE] = Share_Rescue_Cache_Engine::get_instance();
926
- $this->cache_engines[self::REF_SHARE_RESCUE]->initialize( $options );
927
- */
928
-
929
- // Follow base cache engine
930
- $options = array(
931
- 'delegate' => $this,
932
- 'crawler' => $this->crawlers[self::REF_FOLLOW],
933
- 'target_sns' => $this->follow_base_cache_target,
934
- 'check_interval' => $this->follow_base_check_interval,
935
- 'scheme_migration_mode' => $this->scheme_migration_mode,
936
- 'feed_type' => $this->follow_feed_type
937
- );
938
-
939
- $this->cache_engines[self::REF_FOLLOW_BASE] = Follow_Base_Cache_Engine::get_instance();
940
- $this->cache_engines[self::REF_FOLLOW_BASE]->initialize( $options );
941
-
942
- // Follow lazy cache engine
943
- $options = array(
944
- 'delegate' => $this,
945
- 'crawler' => $this->crawlers[self::REF_FOLLOW],
946
- 'target_sns' => $this->follow_base_cache_target,
947
- 'check_interval' => $this->follow_base_check_interval,
948
- 'scheme_migration_mode' => $this->scheme_migration_mode,
949
- 'feed_type' => $this->follow_feed_type
950
- );
951
-
952
- $this->cache_engines[self::REF_FOLLOW_LAZY] = Follow_Lazy_Cache_Engine::get_instance();
953
- $this->cache_engines[self::REF_FOLLOW_LAZY]->initialize( $options );
954
-
955
- // Follow second cache engine
956
- $options = array(
957
- 'crawler' => $this->crawlers[self::REF_FOLLOW],
958
- 'target_sns' => $this->follow_base_cache_target,
959
- 'check_interval' => self::OPT_FOLLOW_2ND_CHECK_INTERVAL,
960
- 'cache_prefix' => self::OPT_FOLLOW_2ND_META_KEY_PREFIX
961
- );
962
-
963
- $this->cache_engines[self::REF_FOLLOW_2ND] = Follow_Second_Cache_Engine::get_instance();
964
- $this->cache_engines[self::REF_FOLLOW_2ND]->initialize( $options );
965
-
966
- // Data export engine
967
- $options = array(
968
- 'export_activation' => $this->data_export_mode,
969
- 'export_schedule' => $this->data_export_schedule,
970
- 'share_target_sns' => $this->share_base_cache_target,
971
- 'follow_target_sns' => $this->follow_base_cache_target,
972
- 'export_file_name' => self::OPT_COMMON_DATA_EXPORT_FILE_NAME,
973
- 'export_exclude_keys' => array( self::REF_SHARE_TOTAL, self::REF_CRAWL_DATE ),
974
- 'post_types' => $this->share_base_cache_post_types
975
- );
976
-
977
- $this->export_engines[self::REF_COMMON_EXPORT] = Common_Data_Export_Engine::get_instance();
978
- $this->export_engines[self::REF_COMMON_EXPORT]->initialize( $options );
979
-
980
- // Share analytical engine
981
- $options = array(
982
- 'delegate' => $this,
983
- 'target_sns' => $this->share_base_cache_target,
984
- 'check_interval' => $this->share_base_check_interval,
985
- 'post_types' => $this->share_base_cache_post_types,
986
- 'base_schedule' => $this->share_variation_analysis_schedule,
987
- 'crawl_date_key' => self::REF_CRAWL_DATE
988
- );
989
-
990
- $this->analytical_engines[self::REF_SHARE_ANALYSIS] = Share_Analytical_Engine::get_instance();
991
- $this->analytical_engines[self::REF_SHARE_ANALYSIS]->initialize( $options );
992
-
993
- // Job reset engine
994
- $target_crons = array();
995
-
996
- foreach ( $this->cache_engines as $key => $cache_engine ) {
997
- $target_crons[] = $cache_engine->get_excute_cron();
998
- }
999
-
1000
- foreach ( $this->control_engines as $key => $control_engine ) {
1001
- $target_crons[] = $control_engine->get_excute_cron();
1002
- }
1003
-
1004
- if ( $this->data_export_mode === self::OPT_COMMON_DATA_EXPORT_SCHEDULER ) {
1005
- $target_crons[] = $this->export_engines[self::REF_COMMON_EXPORT]->get_excute_cron();
1006
- }
1007
-
1008
- if ( $this->share_variation_analysis_mode === self::OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER ) {
1009
- $target_crons[] = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_excute_cron();
1010
- }
1011
-
1012
- $options = array(
1013
- 'delegate' => $this,
1014
- 'check_interval' => 600,
1015
- 'expiration_time ' => 1800,
1016
- 'target_cron' => $target_crons
1017
- );
1018
-
1019
- $this->control_engines[self::REF_COMMON_CONTROL] = Common_Job_Reset_Engine::get_instance();
1020
- $this->control_engines[self::REF_COMMON_CONTROL]->initialize( $options );
1021
-
1022
- $tmp_max_execution_time = ini_get( 'max_execution_time' );
1023
-
1024
- if ( isset( $tmp_max_execution_time ) && $tmp_max_execution_time > 0 ) {
1025
- $this->original_max_execution_time = $tmp_max_execution_time;
1026
- } else {
1027
- $this->original_max_execution_time = 30;
1028
- }
1029
-
1030
- $this->loading_img_url = plugins_url( '/images/loading.gif', __FILE__ );
1031
-
1032
- // delete old hooks
1033
- WP_Cron_Util::clear_scheduled_hook( 'scc_basecache_prime' );
1034
- WP_Cron_Util::clear_scheduled_hook( 'scc_rushcache_prime' );
1035
- WP_Cron_Util::clear_scheduled_hook( 'scc_2ndcache_prime' );
1036
- WP_Cron_Util::clear_scheduled_hook( 'scc_share_rescuecache_prime' );
1037
-
1038
- }
1039
-
1040
- /**
1041
- * Registers and enqueues admin-specific styles.
1042
- *
1043
- * @since 0.1.0
1044
- */
1045
- public function register_admin_styles() {
1046
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1047
-
1048
- if ( ! isset( $this->plugin_screen_hook_suffix ) ) {
1049
- return;
1050
- }
1051
-
1052
- $screen = get_current_screen();
1053
-
1054
- if ( in_array( $screen->id, $this->plugin_screen_hook_suffix ) ) {
1055
- wp_enqueue_style( self::DOMAIN .'-admin-style-1', plugins_url( ltrim( '/css/sns-count-cache.css', '/' ), __FILE__) );
1056
- wp_enqueue_style( self::DOMAIN .'-admin-style-2', plugins_url( ltrim( '/css/prettify.css', '/' ), __FILE__ ) );
1057
- wp_enqueue_style( 'jquery-ui-datepicker-style' , '//ajax.googleapis.com/ajax/libs/jqueryui/1/themes/smoothness/jquery-ui.css');
1058
- }
1059
- }
1060
-
1061
- /**
1062
- * Registers and enqueues admin-specific JavaScript.
1063
- *
1064
- * @since 0.1.0
1065
- */
1066
- public function register_admin_scripts() {
1067
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1068
-
1069
- if ( ! isset( $this->plugin_screen_hook_suffix ) ) {
1070
- return;
1071
- }
1072
-
1073
- $screen = get_current_screen();
1074
-
1075
- if ( in_array( $screen->id, $this->plugin_screen_hook_suffix ) ) {
1076
- wp_enqueue_script( self::DOMAIN . '-admin-script-1', plugins_url( ltrim( '/js/prettify.js', '/' ) , __FILE__ ), array( 'jquery' ) );
1077
-
1078
- wp_enqueue_script( self::DOMAIN . '-admin-script-2', plugins_url( ltrim( '/js/jquery.scc-cache-info.min.js', '/' ), __FILE__ ), array( 'jquery' ) );
1079
- wp_localize_script( self::DOMAIN . '-admin-script-2', 'scc', array( 'endpoint' => admin_url( 'admin-ajax.php' ), 'action' => $this->ajax_action, 'nonce' => wp_create_nonce( $this->ajax_action ) ) );
1080
-
1081
- wp_enqueue_script( 'jquery-ui-datepicker' );
1082
- }
1083
- }
1084
-
1085
- /**
1086
- * Activate cache engine (schedule cron)
1087
- *
1088
- * @since 0.1.1
1089
- */
1090
- public function activate_plugin() {
1091
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1092
-
1093
- $this->initialize();
1094
-
1095
- set_time_limit( $this->extended_max_execution_time );
1096
-
1097
- foreach ( $this->cache_engines as $key => $cache_engine ) {
1098
- switch ( $key ) {
1099
- case self::REF_SHARE_2ND:
1100
- $cache_engine->initialize_cache();
1101
- break;
1102
- case self::REF_FOLLOW_2ND:
1103
- $cache_engine->initialize_cache();
1104
- break;
1105
- default:
1106
- $cache_engine->initialize_cache();
1107
- $cache_engine->register_schedule();
1108
- }
1109
- }
1110
-
1111
- foreach ( $this->control_engines as $key => $control_engine ) {
1112
- $control_engine->register_schedule();
1113
- }
1114
-
1115
- if ( $this->share_variation_analysis_mode === self::OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER ) {
1116
- $this->analytical_engines[self::REF_SHARE_ANALYSIS]->register_schedule();
1117
- }
1118
-
1119
- if ( $this->data_export_mode === self::OPT_COMMON_DATA_EXPORT_SCHEDULER ) {
1120
- $this->export_engines[self::REF_COMMON_EXPORT]->register_schedule();
1121
- }
1122
-
1123
- set_time_limit( $this->original_max_execution_time );
1124
-
1125
- }
1126
-
1127
- /**
1128
- * Deactivate cache engine (schedule cron)
1129
- *
1130
- * @since 0.1.1
1131
- */
1132
- public function deactivate_plugin() {
1133
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1134
-
1135
- set_time_limit( $this->extended_max_execution_time );
1136
-
1137
- foreach ( $this->cache_engines as $key => $cache_engine ) {
1138
- $cache_engine->unregister_schedule();
1139
- $cache_engine->clear_cache();
1140
- }
1141
-
1142
- // compatibility for old version
1143
- $query_args = array(
1144
- 'post_type' => $this->share_base_cache_post_types,
1145
- 'post_status' => 'publish',
1146
- 'nopaging' => true,
1147
- 'update_post_term_cache' => false,
1148
- 'update_post_meta_cache' => false
1149
- );
1150
-
1151
- $posts_query = new WP_Query( $query_args );
1152
-
1153
- if ( $posts_query->have_posts() ) {
1154
- while ( $posts_query->have_posts() ) {
1155
- $posts_query->the_post();
1156
-
1157
- $post_ID = get_the_ID();
1158
-
1159
- foreach ( $this->follow_base_cache_target as $sns => $active ) {
1160
-
1161
- if ( $active ) {
1162
- $meta_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( $sns );
1163
-
1164
- delete_post_meta( $post_ID, $meta_key );
1165
- }
1166
- }
1167
- }
1168
- }
1169
- wp_reset_postdata();
1170
-
1171
- foreach ( $this->control_engines as $key => $control_engine ) {
1172
- $control_engine->unregister_schedule();
1173
- }
1174
-
1175
- $this->analytical_engines[self::REF_SHARE_ANALYSIS]->unregister_schedule();
1176
- $this->analytical_engines[self::REF_SHARE_ANALYSIS]->clear_base();
1177
-
1178
- $this->export_engines[self::REF_COMMON_EXPORT]->unregister_schedule();
1179
-
1180
- set_time_limit( $this->original_max_execution_time );
1181
-
1182
- }
1183
-
1184
- /**
1185
- * Reactivate cache engine
1186
- *
1187
- * @since 0.1.1
1188
- */
1189
- function reactivate_plugin() {
1190
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1191
-
1192
- $this->deactivate_plugin();
1193
- $this->activate_plugin();
1194
-
1195
- }
1196
-
1197
- /**
1198
- * Delete related cache when the post was deleted.
1199
- *
1200
- * @since 0.7.0
1201
- */
1202
- public function clear_cache_deleted_post( $post_id ) {
1203
-
1204
- if ( isset( $post_id ) ) {
1205
- $this->cache_engines[self::REF_SHARE_BASE]->clear_cache_by_post_id( $post_id );
1206
- $this->cache_engines[self::REF_SHARE_2ND]->clear_cache_by_post_id( $post_id );
1207
- $this->analytical_engines[self::REF_SHARE_ANALYSIS]->clear_base_by_post_id( $post_id );
1208
- }
1209
- }
1210
-
1211
- /**
1212
- * Adds options & management pages to the admin menu.
1213
- *
1214
- * Run using the 'admin_menu' action.
1215
- *
1216
- * @since 0.1.0
1217
- */
1218
- public function register_admin_menu() {
1219
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1220
-
1221
- $this->plugin_screen_hook_suffix[] = 'dashboard';
1222
- $this->plugin_screen_hook_suffix[] = add_menu_page( __( 'SNS Count Cache', self::DOMAIN ), __( 'SNS Count Cache', self::DOMAIN ), self::OPT_COMMON_CAPABILITY, 'scc-dashboard', array( $this, 'dashboard_page' ), 'dashicons-share' );
1223
- $this->plugin_screen_hook_suffix[] = add_submenu_page( 'scc-dashboard', __( 'Dashboard | SNS Count Cache', self::DOMAIN ), __( 'Dashboard', self::DOMAIN ), self::OPT_COMMON_CAPABILITY, 'scc-dashboard', array( $this, 'dashboard_page' ) );
1224
- $this->plugin_screen_hook_suffix[] = add_submenu_page( 'scc-dashboard', __( 'Cache Status | SNS Count Cache', self::DOMAIN ), __( 'Cache Status', self::DOMAIN ), self::OPT_COMMON_CAPABILITY, 'scc-cache-status', array( $this, 'cache_status_page' ) );
1225
- $this->plugin_screen_hook_suffix[] = add_submenu_page( 'scc-dashboard', __( 'Share Count | SNS Count Cache', self::DOMAIN ), __( 'Share Count', self::DOMAIN ), self::OPT_COMMON_CAPABILITY, 'scc-share-count', array( $this, 'share_count_page' ) );
1226
-
1227
- if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) {
1228
- $this->plugin_screen_hook_suffix[] = add_submenu_page( 'scc-dashboard', __( 'Hot Content | SNS Count Cache', self::DOMAIN ), __( 'Hot Content', self::DOMAIN ), self::OPT_COMMON_CAPABILITY, 'scc-hot-content', array( $this, 'hot_content_page' ) );
1229
- }
1230
-
1231
- $this->plugin_screen_hook_suffix[] = add_submenu_page( 'scc-dashboard', __( 'Setting | SNS Count Cache', self::DOMAIN ), __( 'Setting', self::DOMAIN ), self::OPT_COMMON_CAPABILITY, 'scc-setting', array( $this, 'setting_page' ) );
1232
- $this->plugin_screen_hook_suffix[] = add_submenu_page( 'scc-dashboard', __( 'Help | SNS Count Cache', self::DOMAIN ), __( 'Help', self::DOMAIN ), self::OPT_COMMON_CAPABILITY, 'scc-help', array( $this, 'help_page' ) );
1233
- }
1234
-
1235
- /**
1236
- * Add widget to wordpress dashboard
1237
- *
1238
- * @since 0.5.1
1239
- */
1240
- public function add_wp_dashboard_widget() {
1241
-
1242
- if ( ! current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
1243
- return false;
1244
- }
1245
-
1246
- wp_add_dashboard_widget( 'scc_dashboard', 'SNS Count Cache', array( $this, 'wp_dashboard_page' ) );
1247
- }
1248
-
1249
- /**
1250
- * Option page implementation
1251
- *
1252
- * @since 0.5.1
1253
- */
1254
- public function wp_dashboard_page() {
1255
-
1256
- if ( ! current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
1257
- wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
1258
- }
1259
-
1260
- include_once( dirname( __FILE__ ) . '/includes/admin-dashboard-widget.php' );
1261
- }
1262
-
1263
-
1264
- /**
1265
- * Option page implementation
1266
- *
1267
- * @since 0.1.0
1268
- */
1269
- public function dashboard_page() {
1270
-
1271
- if ( ! current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
1272
- wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
1273
- }
1274
-
1275
- include_once( dirname( __FILE__ ) . '/includes/admin-dashboard.php' );
1276
- }
1277
-
1278
-
1279
- /**
1280
- * Option page implementation
1281
- *
1282
- * @since 0.1.0
1283
- */
1284
- public function cache_status_page() {
1285
-
1286
- if ( ! current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
1287
- wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
1288
- }
1289
-
1290
- include_once( dirname( __FILE__ ) . '/includes/admin-cache-status.php' );
1291
- }
1292
-
1293
- /**
1294
- * Option page implementation
1295
- *
1296
- * @since 0.1.0
1297
- */
1298
- public function share_count_page() {
1299
-
1300
- if ( ! current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
1301
- wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
1302
- }
1303
-
1304
- include_once( dirname( __FILE__ ) . '/includes/admin-share-count.php' );
1305
- }
1306
-
1307
- /**
1308
- * Option page implementation
1309
- *
1310
- * @since 0.1.0
1311
- */
1312
- public function setting_page() {
1313
-
1314
- if ( ! current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
1315
- wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
1316
- }
1317
-
1318
- include( dirname( __FILE__ ) . '/includes/admin-setting.php' );
1319
- }
1320
-
1321
- /**
1322
- * Option page implementation
1323
- *
1324
- * @since 0.1.0
1325
- */
1326
- public function help_page() {
1327
-
1328
- if ( ! current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
1329
- wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
1330
- }
1331
-
1332
- include_once( dirname( __FILE__ ) . '/includes/admin-help.php' );
1333
- }
1334
-
1335
- /**
1336
- * Option page implementation
1337
- *
1338
- * @since 0.5.1
1339
- */
1340
- public function notice_page() {
1341
-
1342
- if ( ! current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
1343
- wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
1344
- }
1345
-
1346
- include_once( dirname( __FILE__ ) . '/includes/admin-notice.php' );
1347
- }
1348
-
1349
- /**
1350
- * Option page implementation
1351
- *
1352
- * @since 0.6.1
1353
- */
1354
- public function hot_content_page() {
1355
-
1356
- if ( ! current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
1357
- wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
1358
- }
1359
-
1360
- include_once( dirname( __FILE__ ) . '/includes/admin-hot-content.php' );
1361
- }
1362
-
1363
-
1364
- /**
1365
- * Cache share count for a given post ID
1366
- *
1367
- * @since 0.2.0
1368
- */
1369
- private function retrieve_share_cache( $post_ID, $second_sync = false ) {
1370
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1371
-
1372
- return $this->cache_engines[self::REF_SHARE_BASE]->direct_cache( $post_ID, $second_sync );
1373
- }
1374
-
1375
- /**
1376
- * Cache follow count
1377
- *
1378
- * @since 0.2.0
1379
- */
1380
- private function retrieve_follow_cache() {
1381
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1382
-
1383
- return $this->cache_engines[self::REF_FOLLOW_BASE]->direct_cache();
1384
- }
1385
-
1386
- /**
1387
- * Reserve cache processing of share count for a given post ID
1388
- *
1389
- * @since 0.2.0
1390
- */
1391
- private function reserve_share_cache( $post_ID ) {
1392
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1393
-
1394
- $this->cache_engines[self::REF_SHARE_LAZY]->prime_cache( $post_ID );
1395
- }
1396
-
1397
- /**
1398
- * Reserve cache processing of follow count
1399
- *
1400
- * @since 0.4.0
1401
- */
1402
- private function reserve_follow_cache() {
1403
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1404
-
1405
- $this->cache_engines[self::REF_FOLLOW_LAZY]->prime_cache();
1406
- }
1407
-
1408
- /**
1409
- * Method call between one cache engine and another
1410
- *
1411
- * @since 0.4.0
1412
- */
1413
- public function order_cache( Cache_Engine $engine, $options = array() ) {
1414
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1415
-
1416
- switch ( get_class( $engine ) ) {
1417
- case 'Share_Lazy_Cache_Engine':
1418
- $this->cache_engines[self::REF_SHARE_2ND]->cache( $options );
1419
- break;
1420
- case 'Share_Rescue_Cache_Engine':
1421
- $this->cache_engines[self::REF_SHARE_2ND]->cache( $options );
1422
- break;
1423
- case 'Share_Base_Cache_Engine':
1424
- $this->cache_engines[self::REF_SHARE_2ND]->cache( $options );
1425
- break;
1426
- case 'Share_Rush_Cache_Engine':
1427
- $this->cache_engines[self::REF_SHARE_2ND]->cache( $options );
1428
- break;
1429
- case 'Follow_Lazy_Cache_Engine':
1430
- $this->cache_engines[self::REF_FOLLOW_2ND]->cache( $options );
1431
- break;
1432
- case 'Follow_Base_Cache_Engine':
1433
- $this->cache_engines[self::REF_FOLLOW_2ND]->cache( $options );
1434
- break;
1435
- }
1436
-
1437
- }
1438
-
1439
- /**
1440
- * Method call between one cache engine and another
1441
- *
1442
- * @since 0.6.1
1443
- */
1444
- public function order_analysis( Cache_Engine $engine, $options = array() ) {
1445
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1446
-
1447
- if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) {
1448
- switch ( get_class( $engine ) ) {
1449
- case 'Share_Second_Cache_Engine':
1450
- $this->analytical_engines[self::REF_SHARE_ANALYSIS]->analyze( $options );
1451
- break;
1452
- }
1453
- }
1454
-
1455
- }
1456
-
1457
- /**
1458
- * Return pagination
1459
- *
1460
- * @since 0.4.0
1461
- */
1462
- private function pagination( $numpages = '', $pagerange = '', $paged='', $inherit_param = true ) {
1463
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1464
-
1465
- if ( empty( $pagerange ) ) {
1466
- $pagerange = 2;
1467
- }
1468
-
1469
- if ( $paged === '' ) {
1470
- global $paged;
1471
-
1472
- if ( empty( $paged ) ) {
1473
- $paged = 1;
1474
- }
1475
- }
1476
-
1477
- if ( $numpages === '' ) {
1478
- global $wp_query;
1479
-
1480
- $numpages = $wp_query->max_num_pages;
1481
-
1482
- if( ! $numpages ) {
1483
- $numpages = 1;
1484
- }
1485
- }
1486
-
1487
- $pagination_args = array();
1488
-
1489
- $url = parse_url( get_pagenum_link(1) );
1490
- $base_url = $url['scheme'] . '://' . $url['host'] . $url['path'];
1491
-
1492
- parse_str ( $url['query'], $query );
1493
-
1494
- $base_url = $base_url . '?page=' . $query['page'];
1495
-
1496
- Common_Util::log( '[' . __METHOD__ . '] base url: ' . $base_url );
1497
-
1498
- $pagination_args = array(
1499
- 'base' => $base_url . '%_%',
1500
- 'format' => '&paged=%#%',
1501
- 'total' => $numpages,
1502
- 'current' => $paged,
1503
- 'show_all' => false,
1504
- 'end_size' => 1,
1505
- 'mid_size' => $pagerange,
1506
- 'prev_next' => true,
1507
- 'prev_text' => __('&laquo;'),
1508
- 'next_text' => __('&raquo;'),
1509
- 'type' => 'plain',
1510
- 'add_args' => '',
1511
- 'add_fragment' => ''
1512
- );
1513
-
1514
- $paginate_links = paginate_links( $pagination_args );
1515
-
1516
- if ( $inherit_param ) {
1517
- Common_Util::log( '[' . __METHOD__ . '] inherit param: true' );
1518
- } else {
1519
- Common_Util::log( '[' . __METHOD__ . '] inherit param: false' );
1520
-
1521
- $pattern = '/(?:&#038;action=cache&#038;post_id=[0-9]+&#038;_wpnonce=.{10})/';
1522
- $paginate_links = preg_replace( $pattern, '', $paginate_links );
1523
- }
1524
-
1525
- if ( $paginate_links ) {
1526
- echo "<nav class='pagination'>";
1527
- echo "<span class='page-numbers page-num'>Page " . $paged . " of " . $numpages . "</span> ";
1528
- echo $paginate_links;
1529
- echo "</nav>";
1530
- }
1531
-
1532
- }
1533
-
1534
- /**
1535
- * Return cache information through ajax interface
1536
- *
1537
- * @since 0.5.1
1538
- */
1539
- public function get_cache_info() {
1540
- Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1541
-
1542
- if ( isset( $_REQUEST['nonce'] ) && wp_verify_nonce( $_REQUEST['nonce'], $this->ajax_action ) ) {
1543
- if ( current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
1544
-
1545
- $share_base_cache_target = $this->share_base_cache_target;
1546
-
1547
- unset( $share_base_cache_target[self::REF_CRAWL_DATE] );
1548
-
1549
- $posts_count = 0;
1550
- $primary_full_cache_count = 0;
1551
- $primary_partial_cache_count = 0;
1552
- $primary_no_cache_count = 0;
1553
-
1554
- $secondary_full_cache_count = 0;
1555
- $secondary_partial_cache_count = 0;
1556
- $secondary_no_cache_count = 0;
1557
-
1558
- $sum = array();
1559
- $delta = array();
1560
- $return = array();
1561
-
1562
- foreach ( $share_base_cache_target as $sns => $active ) {
1563
- if( $active ){
1564
- $sum[$sns] = 0;
1565
- $delta[$sns] = 0;
1566
- }
1567
- }
1568
-
1569
- $query_args = array(
1570
- 'post_type' => $this->share_base_cache_post_types,
1571
- 'post_status' => 'publish',
1572
- 'nopaging' => true,
1573
- 'update_post_term_cache' => false,
1574
- 'update_post_meta_cache' => false
1575
- );
1576
-
1577
- set_time_limit( $this->extended_max_execution_time );
1578
-
1579
- //home
1580
- ++$posts_count;
1581
-
1582
- $full_cache_flag = true;
1583
- $partial_cache_flag = false;
1584
-
1585
- $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( 'home' );
1586
-
1587
- if ( false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
1588
-
1589
- foreach ( $share_base_cache_target as $sns => $active ) {
1590
- if ( $active ) {
1591
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
1592
- $sum[$sns] = $sum[$sns] + $sns_counts[$sns];
1593
- $partial_cache_flag = true;
1594
- } else {
1595
- $full_cache_flag = false;
1596
- }
1597
- }
1598
- }
1599
-
1600
- if ( $partial_cache_flag && $full_cache_flag ) {
1601
- ++$primary_full_cache_count;
1602
- } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
1603
- ++$primary_partial_cache_count;
1604
- } else {
1605
- ++$primary_no_cache_count;
1606
- }
1607
-
1608
- $full_cache_flag = true;
1609
- $partial_cache_flag = false;
1610
-
1611
- $option_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( 'home' );
1612
-
1613
- if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
1614
-
1615
- foreach ( $share_base_cache_target as $sns => $active ) {
1616
- if( $active ){
1617
-
1618
- if ( $sns_counts[$sns] >= 0 ) {
1619
- $partial_cache_flag = true;
1620
- } else {
1621
- $full_cache_flag = false;
1622
- }
1623
- }
1624
- }
1625
- } else {
1626
- foreach ( $share_base_cache_target as $sns => $active ) {
1627
- if( $active ){
1628
- $full_cache_flag = false;
1629
- }
1630
- }
1631
- }
1632
-
1633
- if ( $partial_cache_flag && $full_cache_flag ) {
1634
- ++$secondary_full_cache_count;
1635
- } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
1636
- ++$secondary_partial_cache_count;
1637
- } else {
1638
- ++$secondary_no_cache_count;
1639
- }
1640
-
1641
- } else {
1642
-
1643
- $option_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( 'home' );
1644
-
1645
- if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
1646
-
1647
- foreach ( $share_base_cache_target as $sns => $active ) {
1648
- if( $active ){
1649
-
1650
- if ( $sns_counts[$sns] >= 0 ) {
1651
- $sum[$sns] = $sum[$sns] + $sns_counts[$sns];
1652
- $partial_cache_flag = true;
1653
- } else {
1654
- $full_cache_flag = false;
1655
- }
1656
- }
1657
- }
1658
- } else {
1659
- foreach ( $share_base_cache_target as $sns => $active ) {
1660
- if( $active ){
1661
- $full_cache_flag = false;
1662
- }
1663
- }
1664
- }
1665
-
1666
- if ( $partial_cache_flag && $full_cache_flag ) {
1667
- ++$secondary_full_cache_count;
1668
- } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
1669
- ++$secondary_partial_cache_count;
1670
- } else {
1671
- ++$secondary_no_cache_count;
1672
- }
1673
-
1674
- ++$primary_no_cache_count;
1675
-
1676
- }
1677
-
1678
- $option_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( 'home' );
1679
-
1680
- if ( false !== ( $sns_deltas = get_option( $option_key ) ) ) {
1681
-
1682
- foreach ( $share_base_cache_target as $sns => $active ) {
1683
- if( $active ){
1684
-
1685
- if ( isset( $sns_deltas[$sns] ) ) {
1686
- $delta[$sns] = $delta[$sns] + $sns_deltas[$sns];
1687
- }
1688
- }
1689
- }
1690
- }
1691
-
1692
- //page, post
1693
- $site_query = new WP_Query( $query_args );
1694
-
1695
- if ( $site_query->have_posts() ) {
1696
- while ( $site_query->have_posts() ) {
1697
- $site_query->the_post();
1698
-
1699
- ++$posts_count;
1700
-
1701
- $full_cache_flag = true;
1702
- $partial_cache_flag = false;
1703
-
1704
- $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( get_the_ID() );
1705
-
1706
- if ( false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
1707
-
1708
- foreach ( $share_base_cache_target as $sns => $active ) {
1709
- if ( $active ) {
1710
-
1711
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
1712
- $sum[$sns] = $sum[$sns] + $sns_counts[$sns];
1713
- $partial_cache_flag = true;
1714
- } else {
1715
- $full_cache_flag = false;
1716
- }
1717
- }
1718
- }
1719
-
1720
- if ( $partial_cache_flag && $full_cache_flag ) {
1721
- ++$primary_full_cache_count;
1722
- } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
1723
- ++$primary_partial_cache_count;
1724
- } else {
1725
- ++$primary_no_cache_count;
1726
- }
1727
-
1728
- $full_cache_flag = true;
1729
- $partial_cache_flag = false;
1730
-
1731
- $sns_counts = array();
1732
- $sns_deltas = array();
1733
-
1734
- foreach ( $share_base_cache_target as $sns => $active ) {
1735
-
1736
- if ( $active ) {
1737
-
1738
- $meta_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( $sns );
1739
- $sns_counts[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
1740
-
1741
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] !== '' && $sns_counts[$sns] >= 0 ) {
1742
- $partial_cache_flag = true;
1743
- } else {
1744
- $full_cache_flag = false;
1745
- }
1746
-
1747
- if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) {
1748
- //delta
1749
- $meta_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( $sns );
1750
-
1751
- $sns_deltas[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
1752
-
1753
- if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' ) {
1754
- $delta[$sns] = $delta[$sns] + $sns_deltas[$sns];
1755
- }
1756
- }
1757
- }
1758
- }
1759
-
1760
- if ( $partial_cache_flag && $full_cache_flag ) {
1761
- ++$secondary_full_cache_count;
1762
- } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
1763
- ++$secondary_partial_cache_count;
1764
- } else {
1765
- ++$secondary_no_cache_count;
1766
- }
1767
-
1768
- } else {
1769
-
1770
- $sns_deltas = array();
1771
- $sns_counts = array();
1772
-
1773
- foreach ( $share_base_cache_target as $sns => $active ) {
1774
-
1775
- if( $active ){
1776
- $meta_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( $sns );
1777
-
1778
- $sns_counts[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
1779
-
1780
- if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] !== '' && $sns_counts[$sns] >= 0 ) {
1781
- $sum[$sns] = $sum[$sns] + $sns_counts[$sns];
1782
- $partial_cache_flag = true;
1783
- } else {
1784
- $full_cache_flag = false;
1785
- }
1786
-
1787
- if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) {
1788
- //delta
1789
- $meta_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( $sns );
1790
-
1791
- $sns_deltas[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
1792
-
1793
- if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' ) {
1794
- $delta[$sns] = $delta[$sns] + $sns_deltas[$sns];
1795
- }
1796
- }
1797
- }
1798
- }
1799
-
1800
- if ( $partial_cache_flag && $full_cache_flag ) {
1801
- ++$secondary_full_cache_count;
1802
- } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
1803
- ++$secondary_partial_cache_count;
1804
- } else {
1805
- ++$secondary_no_cache_count;
1806
- }
1807
-
1808
- ++$primary_no_cache_count;
1809
-
1810
- }
1811
- }
1812
- wp_reset_postdata();
1813
- }
1814
-
1815
- set_time_limit( $this->original_max_execution_time );
1816
-
1817
- foreach ( $share_base_cache_target as $sns => $active ) {
1818
-
1819
- if ( $active && isset( $sum[$sns] ) ) {
1820
- if ( $sns === self::REF_SHARE_GPLUS ){
1821
- $return['share_count']['gplus'] = number_format( (int) $sum[$sns] );
1822
- $return['share_delta']['gplus'] = number_format( (int) $delta[$sns] );
1823
- } else {
1824
- $return['share_count'][strtolower( $sns )] = number_format( (int) $sum[$sns] );
1825
- $return['share_delta'][strtolower( $sns )] = number_format( (int) $delta[$sns] );
1826
- }
1827
- }
1828
- }
1829
-
1830
- $return['post_count'] = $posts_count;
1831
- $return['primary']['full_cache_count'] = $primary_full_cache_count;
1832
- $return['primary']['partial_cache_count'] = $primary_partial_cache_count;
1833
- $return['primary']['no_cache_count'] = $primary_no_cache_count;
1834
- $return['secondary']['full_cache_count'] = $secondary_full_cache_count;
1835
- $return['secondary']['partial_cache_count'] = $secondary_partial_cache_count;
1836
- $return['secondary']['no_cache_count'] = $secondary_no_cache_count;
1837
-
1838
- if ( $primary_full_cache_count === $posts_count ) {
1839
- $return['primary']['cache_status'] = __( 'Completed', self::DOMAIN );
1840
- } elseif ( ( $primary_full_cache_count + $primary_partial_cache_count ) === $posts_count ) {
1841
- $return['primary']['cache_status'] = __( 'Partially Completed', self::DOMAIN );
1842
- } else {
1843
- $return['primary']['cache_status'] = __( 'Ongoing', self::DOMAIN );
1844
- }
1845
-
1846
- if ( $secondary_full_cache_count === $posts_count ) {
1847
- $return['secondary']['cache_status'] = __( 'Completed', self::DOMAIN );
1848
- } elseif ( ( $secondary_full_cache_count + $secondary_partial_cache_count ) === $posts_count ) {
1849
- $return['secondary']['cache_status'] = __( 'Partially Completed', self::DOMAIN );
1850
- } else {
1851
- $return['secondary']['cache_status'] = __( 'Ongoing', self::DOMAIN );
1852
- }
1853
-
1854
- $callback = $_REQUEST["callback"];
1855
-
1856
- header( 'Content-type: application/javascript; charset=utf-8' );
1857
-
1858
- echo $callback . '(' . json_encode( $return ) . ')';
1859
- } else {
1860
- status_header( '403' );
1861
- echo 'Forbidden';
1862
- }
1863
- } else {
1864
- status_header( '403' );
1865
- echo 'Forbidden';
1866
- }
1867
-
1868
- die();
1869
- }
1870
-
1871
- /**
1872
- * Return share count
1873
- *
1874
- * @since 0.5.1
1875
- */
1876
- public function get_share_counts( $post_ID = '', $sns_key = '' ) {
1877
-
1878
- $sns_counts = array();
1879
-
1880
- $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( $post_ID );
1881
-
1882
- if ( false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
1883
- if ( $sns_key ) {
1884
- if ( ! isset( $sns_counts[$sns_key] ) || $sns_counts[$sns_key] < 0 ) {
1885
- $sns_counts[$sns_key] = 0;
1886
- }
1887
-
1888
- return $sns_counts[$sns_key];
1889
- } else {
1890
- foreach ( $this->share_base_cache_target as $sns => $active ) {
1891
- if ( $active ) {
1892
- if ( ! isset( $sns_counts[$sns] ) || $sns_counts[$sns] < 0 ) {
1893
- $sns_counts[$sns] = 0;
1894
- }
1895
- }
1896
- }
1897
-
1898
- return $sns_counts;
1899
- }
1900
- } else {
1901
- switch ( $this->dynamic_cache_mode ) {
1902
- case self::OPT_COMMON_ACCESS_BASED_2ND_CACHE:
1903
- $this->cache_engines[self::REF_SHARE_LAZY]->prime_cache( $post_ID );
1904
-
1905
- if ( $sns_key ) {
1906
-
1907
- if ( $post_ID !== 'home' ) {
1908
-
1909
- $meta_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( $sns_key );
1910
-
1911
- $sns_count = get_post_meta( $post_ID, $meta_key, true );
1912
-
1913
- if ( isset( $sns_count ) && $sns_count !== '' && $sns_count >= 0) {
1914
- $sns_counts[$sns_key] = $sns_count;
1915
- } else {
1916
- $sns_counts[$sns_key] = 0;
1917
- }
1918
- } else {
1919
- $option_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( 'home' );
1920
-
1921
- if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
1922
- if ( ! isset( $sns_counts[$sns_key] ) || $sns_counts[$sns_key] < 0 ) {
1923
- $sns_counts[$sns_key] = 0;
1924
- }
1925
- }else {
1926
- $sns_counts[$sns_key] = 0;
1927
- }
1928
- }
1929
-
1930
- return $sns_counts[$sns_key];
1931
- } else {
1932
- if ( $post_ID !== 'home' ) {
1933
-
1934
- foreach ( $this->share_base_cache_target as $sns => $active ) {
1935
- if ( $active ) {
1936
- $meta_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( $sns );
1937
-
1938
- $sns_count = get_post_meta( $post_ID, $meta_key, true );
1939
-
1940
- if ( isset( $sns_count ) && $sns_count !== '' && $sns_count >= 0 ) {
1941
- $sns_counts[$sns] = $sns_count;
1942
- } else {
1943
- $sns_counts[$sns] = 0;
1944
- }
1945
- }
1946
- }
1947
- } else {
1948
-
1949
- $option_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( 'home' );
1950
-
1951
- if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
1952
-
1953
- foreach ( $this->share_base_cache_target as $sns => $active ) {
1954
- if ( $active ) {
1955
- if ( ! isset( $sns_counts[$sns] ) || $sns_counts[$sns] < 0 ) {
1956
- $sns_counts[$sns] = 0;
1957
- }
1958
- }
1959
- }
1960
- } else {
1961
- foreach ( $this->share_base_cache_target as $sns => $active ) {
1962
- if ( $active ) {
1963
- $sns_counts[$sns] = 0;
1964
- }
1965
- }
1966
- }
1967
- }
1968
-
1969
- return $sns_counts;
1970
- }
1971
- break;
1972
- case self::OPT_COMMON_ACCESS_BASED_ASYNC_CACHE:
1973
- $this->cache_engines[self::REF_SHARE_LAZY]->prime_cache( $post_ID );
1974
-
1975
- if ( $sns_key ) {
1976
- $sns_counts[$sns_key] = 0;
1977
-
1978
- return $sns_counts[$sns_key];
1979
- } else {
1980
- foreach ( $this->share_base_cache_target as $sns => $active ) {
1981
- if ( $active ) {
1982
- $sns_counts[$sns] = 0;
1983
- }
1984
- }
1985
-
1986
- return $sns_counts;
1987
- }
1988
- break;
1989
- case self::OPT_COMMON_ACCESS_BASED_SYNC_CACHE:
1990
- $sns_counts = $this->cache_engines[self::REF_SHARE_BASE]->direct_cache( $post_ID, true );
1991
-
1992
- if ( $sns_key ) {
1993
- if ( ! isset( $sns_counts[$sns_key] ) || $sns_counts[$sns_key] < 0 ) {
1994
- $sns_counts[$sns_key] = 0;
1995
- }
1996
-
1997
- return $sns_counts[$sns_key];
1998
- } else {
1999
- foreach ( $this->share_base_cache_target as $sns => $active ) {
2000
- if ( $active ) {
2001
- if ( ! isset( $sns_counts[$sns] ) || $sns_counts[$sns] < 0 ) {
2002
- $sns_counts[$sns] = 0;
2003
- }
2004
- }
2005
- }
2006
-
2007
- return $sns_counts;
2008
- }
2009
- break;
2010
- case self::OPT_COMMON_ACCESS_BASED_CACHE_NONE:
2011
- if ( $sns_key ) {
2012
- $sns_counts[$sns_key] = 0;
2013
-
2014
- return $sns_counts[$sns_key];
2015
- } else {
2016
- foreach ( $this->share_base_cache_target as $sns => $active ) {
2017
- if ( $active ) {
2018
- $sns_counts[$sns] = 0;
2019
- }
2020
- }
2021
-
2022
- return $sns_counts;
2023
- }
2024
- break;
2025
- }
2026
- }
2027
- }
2028
-
2029
- /**
2030
- * Return follow count
2031
- *
2032
- * @since 0.5.1
2033
- */
2034
- public function get_follow_counts( $sns_key = '' ) {
2035
-
2036
- $sns_followers = array();
2037
-
2038
- $transient_id = $this->cache_engines[self::REF_FOLLOW_BASE]->get_cache_key( 'follow' );
2039
-
2040
- if ( false !== ( $sns_followers = get_transient( $transient_id ) ) ) {
2041
- if ( $sns_key ) {
2042
- if ( ! isset( $sns_followers[$sns_key] ) || $sns_followers[$sns_key] < 0 ) {
2043
- $sns_followers[$sns_key] = 0;
2044
- }
2045
-
2046
- return $sns_followers[$sns_key];
2047
- } else {
2048
- foreach ( $this->follow_base_cache_target as $sns => $active ) {
2049
- if ( $active ) {
2050
- if ( ! isset( $sns_followers[$sns] ) || $sns_followers[$sns] < 0 ) {
2051
- $sns_followers[$sns] = 0;
2052
- }
2053
- }
2054
- }
2055
-
2056
- return $sns_followers;
2057
- }
2058
- } else {
2059
- switch ( $this->dynamic_cache_mode ) {
2060
- case self::OPT_COMMON_ACCESS_BASED_2ND_CACHE:
2061
- $this->cache_engines[self::REF_FOLLOW_LAZY]->prime_cache();
2062
-
2063
- $option_key = $this->cache_engines[self::REF_FOLLOW_2ND]->get_cache_key( 'follow' );
2064
-
2065
- if ( $sns_key ) {
2066
-
2067
- if ( false !== ( $sns_followers = get_option( $option_key ) ) ) {
2068
- if ( ! isset( $sns_followers[$sns_key] ) || $sns_followers[$sns_key] < 0 ) {
2069
- $sns_followers[$sns_key] = 0;
2070
- }
2071
- } else {
2072
- $sns_followers[$sns_key] = 0;
2073
- }
2074
-
2075
- return $sns_followers[$sns_key];
2076
- } else {
2077
-
2078
- if ( false !== ( $sns_followers = get_option( $option_key ) ) ) {
2079
-
2080
- foreach ( $this->follow_base_cache_target as $sns => $active ) {
2081
- if ( $active ) {
2082
- if ( ! isset( $sns_followers[$sns] ) || $sns_followers[$sns] < 0 ) {
2083
- $sns_followers[$sns] = 0;
2084
- }
2085
- }
2086
- }
2087
- } else {
2088
- foreach ( $this->follow_base_cache_target as $sns => $active ) {
2089
- if ( $active ) {
2090
- $sns_followers[$sns] = 0;
2091
- }
2092
- }
2093
- }
2094
-
2095
- return $sns_followers;
2096
- }
2097
- break;
2098
- case self::OPT_COMMON_ACCESS_BASED_ASYNC_CACHE:
2099
- $this->cache_engines[self::REF_FOLLOW_LAZY]->prime_cache();
2100
-
2101
- if ( $sns_key ) {
2102
- $sns_followers[$sns_key] = 0;
2103
-
2104
- return $sns_followers[$sns_key];
2105
- } else {
2106
- foreach ( $this->follow_base_cache_target as $sns => $active ) {
2107
- if ( $active ) {
2108
- $sns_followers[$sns] = 0;
2109
- }
2110
- }
2111
-
2112
- return $sns_followers;
2113
- }
2114
- break;
2115
- case self::OPT_COMMON_ACCESS_BASED_SYNC_CACHE:
2116
- $sns_followers = $this->cache_engines[self::REF_FOLLOW_BASE]->direct_cache();
2117
-
2118
- if ( $sns_key ) {
2119
- if ( ! isset( $sns_followers[$sns_key] ) || $sns_followers[$sns_key] < 0 ) {
2120
- $sns_followers[$sns_key] = 0;
2121
- }
2122
-
2123
- return $sns_followers[$sns_key];
2124
- } else {
2125
- foreach ( $this->follow_base_cache_target as $sns => $active ) {
2126
- if ( $active ) {
2127
- if ( ! isset( $sns_followers[$sns] ) || $sns_followers[$sns] < 0 ) {
2128
- $sns_followers[$sns] = 0;
2129
- }
2130
- }
2131
- }
2132
-
2133
- return $sns_followers;
2134
- }
2135
- break;
2136
- case self::OPT_COMMON_ACCESS_BASED_CACHE_NONE:
2137
- if ( $sns_key ) {
2138
- $sns_followers[$sns_key] = 0;
2139
-
2140
- return $sns_followers[$sns_key];
2141
- } else {
2142
- foreach ( $this->follow_base_cache_target as $sns => $active ) {
2143
- if ( $active ) {
2144
- $sns_followers[$sns] = 0;
2145
- }
2146
- }
2147
-
2148
- return $sns_followers;
2149
- }
2150
- break;
2151
- }
2152
- }
2153
- }
2154
-
2155
- /**
2156
- * Return if variation alaysis is enabled or not.
2157
- *
2158
- * @since 0.7.0
2159
- */
2160
- public function is_variation_analysis_enabled() {
2161
-
2162
- if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) {
2163
- return true;
2164
- } else {
2165
- return false;
2166
- }
2167
- }
2168
-
2169
-
2170
- }
2171
-
2172
- SNS_Count_Cache::get_instance();
2173
-
2174
- /**
2175
- * Get share count from cache
2176
- *
2177
- * @since 0.4.0
2178
- */
2179
- function scc_get_share( $options = array( 'post_id' => '', 'url' => '', 'sns' => '' ) ) {
2180
-
2181
- $post_ID = '';
2182
- $sns_key = '';
2183
-
2184
- if ( isset( $options['url'] ) && $options['url'] ) {
2185
- $post_ID = url_to_postid( $options['url'] );
2186
- } elseif ( isset( $options['post_id'] ) && $options['post_id'] ) {
2187
- $post_ID = $options['post_id'];
2188
- } else {
2189
- $post_ID = get_the_ID();
2190
- }
2191
-
2192
- if ( isset( $options['sns'] ) && $options['sns'] ) {
2193
- $sns_key = $options['sns'];
2194
- }
2195
-
2196
- $sns_count_cache = SNS_Count_Cache::get_instance();
2197
-
2198
- return $sns_count_cache->get_share_counts( $post_ID, $sns_key );
2199
- }
2200
-
2201
- /**
2202
- * Get follow count from cache
2203
- *
2204
- * @since 0.4.0
2205
- */
2206
- function scc_get_follow( $options = array( 'sns' => '' ) ) {
2207
-
2208
- $sns_key = '';
2209
-
2210
- if ( isset( $options['sns'] ) && $options['sns'] ) {
2211
- $sns_key = $options['sns'];
2212
- }
2213
-
2214
- $sns_count_cache = SNS_Count_Cache::get_instance();
2215
-
2216
- return $sns_count_cache->get_follow_counts( $sns_key );
2217
-
2218
- }
2219
-
2220
- /**
2221
- * Get share count from cache (Hatena Bookmark).
2222
- *
2223
- * @since 0.4.0
2224
- */
2225
- function scc_get_share_hatebu( $options = array( 'post_id' => '', 'url' => '' ) ) {
2226
-
2227
- $options['sns'] = SNS_Count_Cache::REF_SHARE_HATEBU;
2228
- return scc_get_share( $options );
2229
- }
2230
-
2231
- /**
2232
- * Get share count from cache (Twitter)
2233
- *
2234
- * @since 0.4.0
2235
- */
2236
- function scc_get_share_twitter( $options = array( 'post_id' => '', 'url' => '' ) ) {
2237
-
2238
- $options['sns'] = SNS_Count_Cache::REF_SHARE_TWITTER;
2239
- return scc_get_share( $options );
2240
- }
2241
-
2242
- /**
2243
- * Get share count from cache (Facebook)
2244
- *
2245
- * @since 0.4.0
2246
- */
2247
- function scc_get_share_facebook( $options = array( 'post_id' => '', 'url' => '' ) ) {
2248
-
2249
- $options['sns'] = SNS_Count_Cache::REF_SHARE_FACEBOOK;
2250
- return scc_get_share( $options );
2251
- }
2252
-
2253
- /**
2254
- * Get share count from cache (Google Plus)
2255
- *
2256
- * @since 0.4.0
2257
- */
2258
- function scc_get_share_gplus( $options = array( 'post_id' => '', 'url' => '' ) ) {
2259
-
2260
- $options['sns'] = SNS_Count_Cache::REF_SHARE_GPLUS;
2261
- return scc_get_share( $options );
2262
- }
2263
-
2264
- /**
2265
- * Get share count from cache (Pocket)
2266
- *
2267
- * @since 0.4.0
2268
- */
2269
- function scc_get_share_pocket( $options = array( 'post_id' => '', 'url' => '' ) ) {
2270
-
2271
- $options['sns'] = SNS_Count_Cache::REF_SHARE_POCKET;
2272
- return scc_get_share( $options );
2273
-
2274
- }
2275
-
2276
- /**
2277
- * Get share count from cache (Pocket)
2278
- *
2279
- * @since 0.4.0
2280
- */
2281
- function scc_get_share_total( $options = array( 'post_id' => '', 'url' => '' ) ) {
2282
-
2283
- $options['sns'] = SNS_Count_Cache::REF_SHARE_TOTAL;
2284
- return scc_get_share( $options );
2285
- }
2286
-
2287
- /**
2288
- * Get share count from cache (Hatena Bookmark).
2289
- *
2290
- * @since 0.1.0
2291
- * @deprecated Function deprecated in Release 0.4.0
2292
- */
2293
- function get_scc_hatebu( $options = array( 'post_id' => '', 'url' => '' ) ) {
2294
-
2295
- return scc_get_share_hatebu( $options );
2296
- }
2297
-
2298
- /**
2299
- * Get share count from cache (Twitter)
2300
- *
2301
- * @since 0.1.0
2302
- * @deprecated Function deprecated in Release 0.4.0
2303
- */
2304
- function get_scc_twitter( $options = array( 'post_id' => '', 'url' => '' ) ) {
2305
-
2306
- return scc_get_share_twitter( $options );
2307
- }
2308
-
2309
- /**
2310
- * Get share count from cache (Facebook)
2311
- *
2312
- * @since 0.1.0
2313
- * @deprecated Function deprecated in Release 0.4.0
2314
- */
2315
- function get_scc_facebook( $options = array( 'post_id' => '', 'url' => '' ) ) {
2316
-
2317
- return scc_get_share_facebook( $options );
2318
- }
2319
-
2320
- /**
2321
- * Get share count from cache (Google Plus)
2322
- *
2323
- * @since 0.1.0
2324
- * @deprecated Function deprecated in Release 0.4.0
2325
- */
2326
- function get_scc_gplus( $options = array( 'post_id' => '', 'url' => '' ) ) {
2327
-
2328
- return scc_get_share_gplus( $options );
2329
- }
2330
-
2331
- /**
2332
- * Get share count from cache (Pocket)
2333
- *
2334
- * @since 0.2.1
2335
- * @deprecated Function deprecated in Release 0.4.0
2336
- */
2337
- function get_scc_pocket( $options = array( 'post_id' => '', 'url' => '' ) ) {
2338
-
2339
- return scc_get_share_pocket( $options );
2340
- }
2341
-
2342
- /**
2343
- * Get follow count from cache (Feedly)
2344
- *
2345
- * @since 0.2.1
2346
- */
2347
- function scc_get_follow_feedly() {
2348
-
2349
- $options['sns'] = SNS_Count_Cache::REF_FOLLOW_FEEDLY;
2350
- return scc_get_follow( $options );
2351
- }
2352
-
2353
- /**
2354
- * Return if variation alaysis is enabled or not.
2355
- *
2356
- * @since 0.7.0
2357
- */
2358
- function scc_is_variation_analysis_enabled() {
2359
- return SNS_Count_Cache::get_instance()->is_variation_analysis_enabled();
2360
- }
2361
-
2362
-
2363
-
2364
- }
2365
-
2366
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: SNS Count Cache
4
+ Description: SNS Count Cache gets share count for Twitter and Facebook, Google Plus, Pocket, 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.9.0
6
+ Plugin URI: https://wordpress.org/plugins/sns-count-cache/
7
+ Author: Daisuke Maruyama
8
+ Author URI: http://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 - 2016 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
19
+ as published by the Free Software Foundation; either version 2
20
+ of the License, or (at your option) any later version.
21
+
22
+ This program is distributed in the hope that it will be useful,
23
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
24
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
+ GNU General Public License for more details.
26
+
27
+ You should have received a copy of the GNU General Public License
28
+ 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-common-util.php' );
33
+ require_once ( dirname( __FILE__ ) . '/includes/class-wp-cron-util.php' );
34
+ require_once ( dirname( __FILE__ ) . '/includes/class-sleep-throttle.php' );
35
+
36
+ require_once ( dirname( __FILE__ ) . '/includes/interface-order.php' );
37
+
38
+ require_once ( dirname( __FILE__ ) . '/includes/class-engine.php' );
39
+ require_once ( dirname( __FILE__ ) . '/includes/class-cache-engine.php' );
40
+
41
+ require_once ( dirname( __FILE__ ) . '/includes/class-share-cache-engine.php' );
42
+ require_once ( dirname( __FILE__ ) . '/includes/class-share-base-cache-engine.php' );
43
+ require_once ( dirname( __FILE__ ) . '/includes/class-share-rush-cache-engine.php' );
44
+ require_once ( dirname( __FILE__ ) . '/includes/class-share-lazy-cache-engine.php' );
45
+ require_once ( dirname( __FILE__ ) . '/includes/class-share-second-cache-engine.php' );
46
+ require_once ( dirname( __FILE__ ) . '/includes/class-share-restore-cache-engine.php' );
47
+
48
+ require_once ( dirname( __FILE__ ) . '/includes/class-follow-cache-engine.php' );
49
+ require_once ( dirname( __FILE__ ) . '/includes/class-follow-base-cache-engine.php' );
50
+ require_once ( dirname( __FILE__ ) . '/includes/class-follow-lazy-cache-engine.php' );
51
+ require_once ( dirname( __FILE__ ) . '/includes/class-follow-second-cache-engine.php' );
52
+ require_once ( dirname( __FILE__ ) . '/includes/class-follow-restore-cache-engine.php' );
53
+
54
+ require_once ( dirname( __FILE__ ) . '/includes/class-export-engine.php' );
55
+ require_once ( dirname( __FILE__ ) . '/includes/class-common-data-export-engine.php' );
56
+
57
+ require_once ( dirname( __FILE__ ) . '/includes/class-common-job-reset-engine.php' );
58
+
59
+ require_once ( dirname( __FILE__ ) . '/includes/class-crawler.php' );
60
+ require_once ( dirname( __FILE__ ) . '/includes/class-share-crawler.php' );
61
+ require_once ( dirname( __FILE__ ) . '/includes/class-follow-crawler.php' );
62
+
63
+ require_once ( dirname( __FILE__ ) . '/includes/class-analytical-engline.php' );
64
+ require_once ( dirname( __FILE__ ) . '/includes/class-share-analytical-engine.php' );
65
+
66
+ require_once ( dirname( __FILE__ ) . '/includes/class-crawl-strategy.php' );
67
+
68
+ require_once ( dirname( __FILE__ ) . '/includes/class-share-facebook-strategy.php' );
69
+ require_once ( dirname( __FILE__ ) . '/includes/class-share-twitter-strategy.php' );
70
+ require_once ( dirname( __FILE__ ) . '/includes/class-share-pocket-strategy.php' );
71
+ require_once ( dirname( __FILE__ ) . '/includes/class-share-google-strategy.php' );
72
+ require_once ( dirname( __FILE__ ) . '/includes/class-share-hatebu-strategy.php' );
73
+
74
+ require_once ( dirname( __FILE__ ) . '/includes/class-follow-twitter-strategy.php' );
75
+ require_once ( dirname( __FILE__ ) . '/includes/class-follow-feedly-strategy.php' );
76
+ require_once ( dirname( __FILE__ ) . '/includes/class-follow-facebook-strategy.php' );
77
+ require_once ( dirname( __FILE__ ) . '/includes/class-follow-push7-strategy.php' );
78
+ require_once ( dirname( __FILE__ ) . '/includes/class-follow-instagram-strategy.php' );
79
+
80
+ require_once ( dirname( __FILE__ ) . '/includes/class-mcrypt.php' );
81
+ require_once ( dirname( __FILE__ ) . '/includes/class-blowfish.php' );
82
+ require_once ( dirname( __FILE__ ) . '/includes/class-default-key.php' );
83
+
84
+ if ( ! defined( 'ABSPATH' ) ) exit(); // Exit if accessed directly
85
+
86
+ if ( ! class_exists( 'SNS_Count_Cache' ) ) {
87
+
88
+ final class SNS_Count_Cache implements Order {
89
+
90
+ /**
91
+ * Prefix of share cache ID
92
+ */
93
+ const OPT_SHARE_BASE_TRANSIENT_PREFIX = 'scc_share_count_';
94
+
95
+ /**
96
+ * Meta key for share second cache
97
+ */
98
+ const OPT_SHARE_2ND_META_KEY_PREFIX = 'scc_share_count_';
99
+
100
+ /**
101
+ * Prefix of follow cache ID
102
+ */
103
+ const OPT_FOLLOW_BASE_TRANSIENT_PREFIX = 'scc_follow_count_';
104
+
105
+ /**
106
+ * Meta key for follow second cache
107
+ */
108
+ const OPT_FOLLOW_2ND_META_KEY_PREFIX = 'scc_follow_count_';
109
+
110
+ /**
111
+ * Interval cheking and caching share count for share base cache
112
+ */
113
+ const OPT_SHARE_BASE_CHECK_INTERVAL = 600;
114
+
115
+ /**
116
+ * Number of posts to check at a time for share base cache
117
+ */
118
+ const OPT_SHARE_BASE_POSTS_PER_CHECK = 20;
119
+
120
+ /**
121
+ * Interval cheking and caching share count for share rush cache
122
+ */
123
+ const OPT_SHARE_RUSH_CHECK_INTERVAL = 300;
124
+
125
+ /**
126
+ * Term that a content is considered as new content in share rush cache
127
+ */
128
+ const OPT_SHARE_RUSH_NEW_CONTENT_TERM = 3;
129
+
130
+ /**
131
+ * Interval for share second cache
132
+ */
133
+ const OPT_SHARE_2ND_CHECK_INTERVAL = 600;
134
+
135
+ /**
136
+ * Twitter alternative API (jsoon)
137
+ */
138
+ //const OPT_SHARE_TWITTER_API_JSOON = 'jsoon.digitiminimi.com';
139
+ const OPT_SHARE_TWITTER_API_JSOON = 1;
140
+
141
+ /**
142
+ * Twitter alternative API (OpenShareCount)
143
+ */
144
+ //const OPT_SHARE_TWITTER_API_OPENSHARECOUNT = 'opensharecount.com';
145
+ const OPT_SHARE_TWITTER_API_OPENSHARECOUNT = 2;
146
+
147
+ /**
148
+ * Twitter alternative API (TwitCount)
149
+ */
150
+ //const OPT_SHARE_TWITTER_API_TWITCOUNT = 'twitcount.com';
151
+ const OPT_SHARE_TWITTER_API_TWITCOUNT = 3;
152
+
153
+ /**
154
+ * Interval cheking and caching share count for follow base cache
155
+ */
156
+ const OPT_FOLLOW_BASE_CHECK_INTERVAL = 86400;
157
+ const OPT_FOLLOW_BASE_CHECK_INTERVAL_MIN = 3600;
158
+
159
+ /**
160
+ * Interval for follow second cache
161
+ */
162
+ const OPT_FOLLOW_2ND_CHECK_INTERVAL = 600;
163
+
164
+ /**
165
+ * Type of data export
166
+ */
167
+ const OPT_COMMON_DATA_EXPORT_MANUAL = 1;
168
+
169
+ /**
170
+ * Type of data export
171
+ */
172
+ const OPT_COMMON_DATA_EXPORT_SCHEDULER = 2;
173
+
174
+ /**
175
+ * Type of share analysis
176
+ */
177
+ const OPT_SHARE_VARIATION_ANALYSIS_NONE = 1;
178
+
179
+ /**
180
+ * Type of share analysis
181
+ */
182
+ const OPT_SHARE_VARIATION_ANALYSIS_MANUAL = 2;
183
+
184
+ /**
185
+ * Type of share analysis
186
+ */
187
+ const OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER = 3;
188
+
189
+ /**
190
+ * Type of share analysis
191
+ */
192
+ const OPT_SHARE_VARIATION_ANALYSIS_SCHEDULE = '0 0 * * *';
193
+
194
+ /**
195
+ * File name of data export
196
+ */
197
+ const OPT_COMMON_DATA_EXPORT_FILE_NAME = 'sns-count-cache-data.csv';
198
+
199
+ /**
200
+ * Data export schedule
201
+ */
202
+ const OPT_COMMON_DATA_EXPORT_SCHEDULE = '0 0 * * *';
203
+
204
+ /**
205
+ * Type of dynamic cache processing
206
+ */
207
+ const OPT_COMMON_ACCESS_BASED_CACHE_NONE = 1;
208
+
209
+ /**
210
+ * Type of dynamic cache processing
211
+ */
212
+ const OPT_COMMON_ACCESS_BASED_SYNC_CACHE = 2;
213
+
214
+ /**
215
+ * Type of dynamic cache processing
216
+ */
217
+ const OPT_COMMON_ACCESS_BASED_ASYNC_CACHE = 3;
218
+
219
+ /**
220
+ * Type of dynamic cache processing
221
+ */
222
+ const OPT_COMMON_ACCESS_BASED_2ND_CACHE = 4;
223
+
224
+ /**
225
+ * Type of scheme migration mode
226
+ */
227
+ const OPT_COMMON_SCHEME_MIGRATION_MODE_OFF = false;
228
+
229
+ /**
230
+ * Type of scheme migration mode
231
+ */
232
+ const OPT_COMMON_SCHEME_MIGRATION_MODE_ON = true;
233
+
234
+ /**
235
+ * Error message
236
+ */
237
+ const OPT_COMMON_ERROR_MESSAGE = 'scc_error_message';
238
+
239
+ /**
240
+ * Update message
241
+ */
242
+ const OPT_COMMON_UPDATE_MESSAGE = 'scc_update_message';
243
+
244
+ /**
245
+ * Type of crawl method
246
+ */
247
+ const OPT_COMMON_CRAWLER_METHOD_NORMAL = 1;
248
+
249
+ /**
250
+ * Type of crawl method
251
+ */
252
+ const OPT_COMMON_CRAWLER_METHOD_CURL = 2;
253
+
254
+ /**
255
+ * Type of crawl ssl verification
256
+ */
257
+ const OPT_COMMON_CRAWLER_SSL_VERIFY_ON = true;
258
+
259
+ /**
260
+ * Type of crawl ssl verification
261
+ */
262
+ const OPT_COMMON_CRAWLER_SSL_VERIFY_OFF = false;
263
+
264
+ /**
265
+ * crawler timeout
266
+ */
267
+ const OPT_COMMON_CRAWLER_TIMEOUT = 10;
268
+
269
+ /**
270
+ * crawler retry limit
271
+ */
272
+ const OPT_COMMON_CRAWLER_RETRY_LIMIT = 2;
273
+
274
+ /**
275
+ * Type of feed
276
+ */
277
+ const OPT_FEED_TYPE_DEFAULT = '';
278
+
279
+ /**
280
+ * Type of feed
281
+ */
282
+ const OPT_FEED_TYPE_RSS = 'rss';
283
+
284
+ /**
285
+ * Type of feed
286
+ */
287
+ const OPT_FEED_TYPE_RSS2 = 'rss2';
288
+
289
+ /**
290
+ * Type of feed
291
+ */
292
+ const OPT_FEED_TYPE_RDF = 'rdf';
293
+
294
+ /**
295
+ * Type of feed
296
+ */
297
+ const OPT_FEED_TYPE_ATOM = 'atom';
298
+
299
+ /**
300
+ * Capability for admin
301
+ */
302
+ const OPT_COMMON_CAPABILITY = 'manage_options';
303
+
304
+ /**
305
+ * Option key for custom post types for share base cache
306
+ */
307
+ const DB_SHARE_CUSTOM_POST_TYPES = 'share_custom_post_types';
308
+
309
+ /**
310
+ * Option key for check interval of share base cache
311
+ */
312
+ const DB_SHARE_BASE_CHECK_INTERVAL = 'share_base_check_interval';
313
+
314
+ /**
315
+ * Option key for twitter alternative api
316
+ */
317
+ const DB_SHARE_BASE_TWITTER_API = 'share_base_twitter_api';
318
+
319
+ /**
320
+ * Option key for number of posts to check at a time for share base cache
321
+ */
322
+ const DB_SHARE_POSTS_PER_CHECK = 'share_posts_per_check';
323
+
324
+ /**
325
+ * Option key for dynamic cache
326
+ */
327
+ const DB_COMMON_DYNAMIC_CACHE_MODE = 'common_dynamic_cache_mode';
328
+
329
+ /**
330
+ * Option key for new content term for share rush cache
331
+ */
332
+ const DB_SHARE_RUSH_NEW_CONTENT_TERM = 'share_new_content_term';
333
+
334
+ /**
335
+ * Option key for check interval of share rush cache
336
+ */
337
+ const DB_SHARE_RUSH_CHECK_INTERVAL = 'share_rush_check_interval';
338
+
339
+ /**
340
+ * Option key of cache target for share base cache
341
+ */
342
+ const DB_SHARE_CACHE_TARGET = 'share_cache_target';
343
+
344
+ /**
345
+ * Option key of cache target for follow base cache
346
+ */
347
+ const DB_FOLLOW_CACHE_TARGET = 'follow_cache_target';
348
+
349
+ /**
350
+ * Option key of cache target for follow base cache
351
+ */
352
+ const DB_FOLLOW_FEED_TYPE = '';
353
+
354
+ /**
355
+ * Option key of checking interval for follow base cache
356
+ */
357
+ const DB_FOLLOW_CHECK_INTERVAL = 'follow_check_interval';
358
+
359
+ /**
360
+ * Option key of data export
361
+ */
362
+ const DB_COMMON_DATA_EXPORT_MODE = 'common_data_export_mode';
363
+
364
+ /**
365
+ * Option key of data export schedule
366
+ */
367
+ const DB_COMMON_DATA_EXPORT_SCHEDULE = 'common_data_export_schedule';
368
+
369
+ /**
370
+ * Option key of http migration
371
+ */
372
+ const DB_COMMON_SCHEME_MIGRATION_MODE = 'common_scheme_migration_mode';
373
+
374
+ /**
375
+ * Option key of http migration
376
+ */
377
+ const DB_COMMON_SCHEME_MIGRATION_DATE = 'common_scheme_migration_date';
378
+
379
+ /**
380
+ * Option key of crawl ssl verification
381
+ */
382
+ const DB_COMMON_CRAWLER_SSL_VERIFICATION = 'common_crawler_ssl_verification';
383
+
384
+ /**
385
+ * Option key of share variation analysis
386
+ */
387
+ const DB_SHARE_VARIATION_ANALYSIS_MODE = 'share_variation_analysis_mode';
388
+
389
+ /**
390
+ * Option key of share variation analysis
391
+ */
392
+ const DB_SHARE_VARIATION_ANALYSIS_SCHEDULE = 'share_variation_analysis_schedule';
393
+
394
+ /**
395
+ * Option key of twitter consumer key
396
+ */
397
+ const DB_FOLLOW_TWITTER_SCREEN_NAME = 'follow_twitter_screen_name';
398
+
399
+ /**
400
+ * Option key of twitter consumer key
401
+ */
402
+ const DB_FOLLOW_TWITTER_CONSUMER_KEY = 'follow_twitter_consumer_key';
403
+
404
+ /**
405
+ * Option key of twitter consumer secret
406
+ */
407
+ const DB_FOLLOW_TWITTER_CONSUMER_SECRET = 'follow_twitter_consumer_secret';
408
+
409
+ /**
410
+ * Option key of twitter bearer token
411
+ */
412
+ const DB_FOLLOW_TWITTER_BEARER_TOKEN = 'follow_twitter_bearer_token';
413
+
414
+ /**
415
+ * Option key of twitter access token
416
+ */
417
+ const DB_FOLLOW_TWITTER_ACCESS_TOKEN = 'follow_twitter_access_token';
418
+
419
+ /**
420
+ * Option key of twitter access token secret
421
+ */
422
+ const DB_FOLLOW_TWITTER_ACCESS_TOKEN_SECRET = 'follow_twitter_access_token_secret';
423
+
424
+ /**
425
+ * Option key of facebook page ID
426
+ */
427
+ const DB_FOLLOW_FACEBOOK_PAGE_ID = 'follow_facebook_page_id';
428
+
429
+ /**
430
+ * Option key of facebook app ID
431
+ */
432
+ const DB_FOLLOW_FACEBOOK_APP_ID = 'follow_facebook_app_id';
433
+
434
+ /**
435
+ * Option key of facebook app secret
436
+ */
437
+ const DB_FOLLOW_FACEBOOK_APP_SECRET = 'follow_facebook_app_secret';
438
+
439
+ /**
440
+ * Option key of facebook access token
441
+ */
442
+ const DB_FOLLOW_FACEBOOK_ACCESS_TOKEN = 'follow_facebook_access_token';
443
+
444
+ /**
445
+ * Option key of push7 appno
446
+ */
447
+ const DB_FOLLOW_PUSH7_APPNO = 'follow_push7_appno';
448
+
449
+ /**
450
+ * Option key of instagram client id
451
+ */
452
+ const DB_FOLLOW_INSTAGRAM_CLIENT_ID = 'follow_instagram_client_id';
453
+
454
+ /**
455
+ * Option key of instagram client secret
456
+ */
457
+ const DB_FOLLOW_INSTAGRAM_CLIENT_SECRET = 'follow_instagram_client_secret';
458
+
459
+ /**
460
+ * Option key of instagram access token
461
+ */
462
+ const DB_FOLLOW_INSTAGRAM_ACCESS_TOKEN = 'follow_instagram_access_token';
463
+
464
+ /**
465
+ * Option key of setting
466
+ */
467
+ const DB_SETTINGS = 'scc_settings';
468
+
469
+ /**
470
+ * Slug of the plugin
471
+ */
472
+ const DOMAIN = 'sns-count-cache';
473
+
474
+ /**
475
+ * ID of share base cache
476
+ */
477
+ const REF_SHARE_BASE = 'share-base';
478
+
479
+ /**
480
+ * ID of share rush cache
481
+ */
482
+ const REF_SHARE_RUSH = 'share-rush';
483
+
484
+ /**
485
+ * ID of share lazy cache
486
+ */
487
+ const REF_SHARE_LAZY = 'share-lazy';
488
+
489
+ /**
490
+ * ID of share second cache
491
+ */
492
+ const REF_SHARE_2ND = 'share-second';
493
+
494
+ /**
495
+ * ID of share analysis cache
496
+ */
497
+ const REF_SHARE_ANALYSIS = 'share-analysis';
498
+
499
+ /**
500
+ * ID of share rescue cache
501
+ */
502
+ const REF_SHARE_RESCUE = 'share-rescue';
503
+
504
+ /**
505
+ * ID of share restore cache
506
+ */
507
+ const REF_SHARE_RESTORE = 'share-restore';
508
+
509
+ /**
510
+ * ID of follow base cache
511
+ */
512
+ const REF_FOLLOW_BASE = 'follow-base';
513
+
514
+ /**
515
+ * ID of follow lazy cache
516
+ */
517
+ const REF_FOLLOW_LAZY = 'follow-lazy';
518
+
519
+ /**
520
+ * ID of follow second cache
521
+ */
522
+ const REF_FOLLOW_2ND = 'follow-second';
523
+
524
+ /**
525
+ * ID of share restore cache
526
+ */
527
+ const REF_FOLLOW_RESTORE = 'follow-restore';
528
+
529
+ /**
530
+ * ID of common data export
531
+ */
532
+ const REF_COMMON_EXPORT = 'common-export';
533
+
534
+ /**
535
+ * ID of common data export
536
+ */
537
+ const REF_COMMON_CONTROL = 'common-control';
538
+
539
+ /**
540
+ * ID of share
541
+ */
542
+ const REF_SHARE = 'share';
543
+
544
+ /**
545
+ * ID of follow
546
+ */
547
+ const REF_FOLLOW = 'follow';
548
+
549
+ /**
550
+ * ID of share count (Twitter)
551
+ */
552
+ const REF_SHARE_TWITTER = 'Twitter';
553
+
554
+ /**
555
+ * ID of share count (Facebook)
556
+ */
557
+ const REF_SHARE_FACEBOOK = 'Facebook';
558
+
559
+ /**
560
+ * ID of share count (Google Plus)
561
+ */
562
+ const REF_SHARE_GPLUS = 'Google+';
563
+
564
+ /**
565
+ * ID of share count (Hatena Bookmark)
566
+ */
567
+ const REF_SHARE_HATEBU = 'Hatebu';
568
+
569
+ /**
570
+ * ID of share count (Pocket)
571
+ */
572
+ const REF_SHARE_POCKET = 'Pocket';
573
+
574
+ /**
575
+ * ID of share count (Pinterest)
576
+ */
577
+ const REF_SHARE_PINTEREST = 'Pinterest';
578
+
579
+ /**
580
+ * ID of share count (LinkedIn)
581
+ */
582
+ const REF_SHARE_LINKEDIN = 'Linkedin';
583
+
584
+ /**
585
+ * ID of share count (Total)
586
+ */
587
+ const REF_SHARE_TOTAL = 'Total';
588
+
589
+ /**
590
+ * ID of follow count (Feedly)
591
+ */
592
+ const REF_FOLLOW_FEEDLY = 'Feedly';
593
+
594
+ /**
595
+ * ID of follow count (Feedly)
596
+ */
597
+ const REF_FOLLOW_TWITTER = 'Twitter';
598
+
599
+ /**
600
+ * ID of follow count (Feedly)
601
+ */
602
+ const REF_FOLLOW_FACEBOOK = 'Facebook';
603
+
604
+ /**
605
+ * ID of follow count (Push7)
606
+ */
607
+ const REF_FOLLOW_PUSH7 = 'Push7';
608
+
609
+ /**
610
+ * ID of follow count (Instagram)
611
+ */
612
+ const REF_FOLLOW_INSTAGRAM = 'Instagram';
613
+
614
+ /**
615
+ * ID of crawl date
616
+ */
617
+ const REF_CRAWL_DATE = 'CrawlDate';
618
+
619
+ /**
620
+ * Plugin version, used for cache-busting of style and script file references.
621
+ */
622
+ private $version = '0.9.0';
623
+
624
+ /**
625
+ * Instances of crawler
626
+ */
627
+ private $crawlers = array();
628
+
629
+ /**
630
+ * Instance of cache engine
631
+ */
632
+ private $cache_engines = array();
633
+
634
+ /**
635
+ * Instance of export engine
636
+ */
637
+ private $export_engines = array();
638
+
639
+ /**
640
+ * Instance of control engine
641
+ */
642
+ private $control_engines = array();
643
+
644
+ /**
645
+ * Instance of analytical engine
646
+ */
647
+ private $analytical_engines = array();
648
+
649
+ /**
650
+ * Slug of the plugin screen
651
+ */
652
+ private $plugin_screen_hook_suffix = array();
653
+
654
+ /**
655
+ * Cache target for share base cache
656
+ */
657
+ private $share_base_cache_target = array();
658
+
659
+ /**
660
+ * Post types to be cached
661
+ */
662
+ private $share_base_cache_post_types = array( 'post', 'page' );
663
+
664
+ /**
665
+ * Post types to be cached
666
+ */
667
+ private $share_base_custom_post_types = array();
668
+
669
+ /**
670
+ * Check interval for share base cahce
671
+ */
672
+ private $share_base_check_interval = 600;
673
+
674
+ /**
675
+ * Post per check for share base cache
676
+ */
677
+ private $share_base_posts_per_check = 20;
678
+
679
+ /**
680
+ * Post per check for share base cache
681
+ */
682
+ private $share_base_twitter_api = '';
683
+
684
+ /**
685
+ * Term considering content as new one
686
+ */
687
+ private $share_rush_new_content_term = 3;
688
+
689
+ /**
690
+ *Check interval for share rush cahce
691
+ */
692
+ private $share_rush_check_interval = 300;
693
+
694
+ /**
695
+ * Cache target for follow base cache
696
+ */
697
+ private $follow_base_cache_target = array();
698
+
699
+ /**
700
+ * Check interval for follow base cache
701
+ */
702
+ private $follow_base_check_interval = 1800;
703
+
704
+ /**
705
+ * Feed type to be followed
706
+ */
707
+ private $follow_feed_type = '';
708
+
709
+ /**
710
+ * Twitter consumer key
711
+ */
712
+ private $follow_twitter_consumer_key = '';
713
+
714
+ /**
715
+ * Twitter consumer secret
716
+ */
717
+ private $follow_twitter_consumer_secret = '';
718
+
719
+ /**
720
+ * Twitter access token
721
+ */
722
+ private $follow_twitter_access_token = '';
723
+
724
+ /**
725
+ * Twitter bearer token
726
+ */
727
+ private $follow_twitter_bearer_token = '';
728
+
729
+ /**
730
+ * Twitter access token secret
731
+ */
732
+ private $follow_twitter_access_token_secret = '';
733
+
734
+ /**
735
+ * Twitter screen name
736
+ */
737
+ private $follow_twitter_screen_name = '';
738
+
739
+ /**
740
+ * Facebook page ID
741
+ */
742
+ private $follow_facebook_page_id = '';
743
+
744
+ /**
745
+ * Facebook app ID
746
+ */
747
+ private $follow_facebook_app_id = '';
748
+
749
+ /**
750
+ * Facebook app ID
751
+ */
752
+ private $follow_facebook_app_secret = '';
753
+
754
+ /**
755
+ * Facebook access token
756
+ */
757
+ private $follow_facebook_access_token = '';
758
+
759
+ /**
760
+ * Push7 appno
761
+ */
762
+ private $follow_push7_appno = '';
763
+
764
+ /**
765
+ * Instagram client id
766
+ */
767
+ private $follow_instagram_client_id = '';
768
+
769
+ /**
770
+ * Instagram client secret
771
+ */
772
+ private $follow_instagram_client_secret = '';
773
+
774
+ /**
775
+ * Instagram access token
776
+ */
777
+ private $follow_instagram_access_token = '';
778
+
779
+ /**
780
+ * Dynamic cache mode
781
+ */
782
+ private $dynamic_cache_mode = 1;
783
+
784
+ /**
785
+ * Data export mode
786
+ */
787
+ private $data_export_mode = 1;
788
+
789
+ /**
790
+ * Data export schedule
791
+ */
792
+ private $data_export_schedule = '0 0 * * *';
793
+
794
+ /**
795
+ * Share variation analysis mode
796
+ */
797
+ private $share_variation_analysis_mode = 1;
798
+
799
+ /**
800
+ * Share variation analysis schedule
801
+ */
802
+ private $share_variation_analysis_schedule = '0 0 * * *';
803
+
804
+ /**
805
+ * Migration mode from http to https
806
+ */
807
+ private $scheme_migration_mode = false;
808
+
809
+ /**
810
+ * Migration date from http to https
811
+ */
812
+ private $scheme_migration_date = NULL;
813
+
814
+ /**
815
+ * Excluded key in migration from http to https
816
+ */
817
+ private $scheme_migration_exclude_keys = array();
818
+
819
+ /**
820
+ * Max execution time
821
+ */
822
+ private $original_max_execution_time = 0;
823
+
824
+ /**
825
+ * Extended max execution time
826
+ */
827
+ private $extended_max_execution_time = 600;
828
+
829
+ /**
830
+ * URL of loding image
831
+ */
832
+ private $loading_img_url = '';
833
+
834
+ /**
835
+ * ajax action
836
+ */
837
+ private $ajax_action = 'scc_cache_info';
838
+
839
+ /**
840
+ * Cralwer method
841
+ */
842
+ private $crawler_method = 1;
843
+
844
+ /**
845
+ * Cralwer SSL verification
846
+ */
847
+ private $crawler_ssl_verification = true;
848
+
849
+ /**
850
+ * Instance
851
+ */
852
+ private static $instance = NULL;
853
+
854
+ /**
855
+ * Class constarctor
856
+ * Hook onto all of the actions and filters needed by the plugin.
857
+ */
858
+ private function __construct() {
859
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
860
+
861
+ load_plugin_textdomain( self::DOMAIN, false, basename( dirname( __FILE__ ) ) . '/languages' );
862
+
863
+ add_action( 'init', array( $this, 'initialize' ) );
864
+
865
+ register_activation_hook( __FILE__, array( $this, 'activate_plugin' ) );
866
+ register_deactivation_hook( __FILE__, array( $this, 'deactivate_plugin' ) );
867
+
868
+ add_action( 'admin_menu', array( $this, 'register_admin_menu' ) );
869
+ add_action( 'admin_print_styles', array( $this, 'register_admin_styles' ) );
870
+ add_action( 'admin_enqueue_scripts', array( $this, 'register_admin_scripts' ) );
871
+ //add_action( 'admin_notices', array( $this, 'notice_page' ) );
872
+ add_action( 'wp_ajax_' . $this->ajax_action, array( $this, 'get_cache_info' ) );
873
+ add_action( 'wp_dashboard_setup', array( $this, 'add_wp_dashboard_widget' ) );
874
+ add_action( 'deleted_post' , array( $this, 'clear_cache_deleted_post' ) );
875
+ }
876
+
877
+ /**
878
+ * Get instance
879
+ *
880
+ * @since 0.1.1
881
+ */
882
+ public static function get_instance() {
883
+
884
+ if ( ! isset( self::$instance ) ) {
885
+ self::$instance = new self;
886
+ }
887
+
888
+ return self::$instance;
889
+ }
890
+
891
+ /**
892
+ * Return object ID
893
+ *
894
+ * @since 0.6.0
895
+ */
896
+ public function get_object_id() {
897
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
898
+
899
+ $object_id = spl_object_hash( $this );
900
+
901
+ Common_Util::log( '[' . __METHOD__ . '] object ID: ' . $object_id );
902
+
903
+ return $object_id;
904
+ }
905
+
906
+ /**
907
+ * Inhibit clone
908
+ *
909
+ * @since 0.6.0
910
+ */
911
+ final public function __clone() {
912
+ throw new Exception('Clone is not allowed against' . get_class( $this ) );
913
+ }
914
+
915
+ /**
916
+ * Initialization
917
+ *
918
+ * @since 0.1.1
919
+ */
920
+ public function initialize() {
921
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
922
+
923
+ $settings = get_option( self::DB_SETTINGS );
924
+
925
+ if ( isset( $settings[self::DB_SHARE_BASE_CHECK_INTERVAL] ) && $settings[self::DB_SHARE_BASE_CHECK_INTERVAL] ) {
926
+ $this->share_base_check_interval = (int) $settings[self::DB_SHARE_BASE_CHECK_INTERVAL];
927
+ } else {
928
+ $this->share_base_check_interval = self::OPT_SHARE_BASE_CHECK_INTERVAL;
929
+ }
930
+
931
+ if ( isset( $settings[self::DB_SHARE_POSTS_PER_CHECK] ) && $settings[self::DB_SHARE_POSTS_PER_CHECK] ) {
932
+ $this->share_base_posts_per_check = (int) $settings[self::DB_SHARE_POSTS_PER_CHECK];
933
+ } else {
934
+ $this->share_base_posts_per_check = self::OPT_SHARE_BASE_POSTS_PER_CHECK;
935
+ }
936
+
937
+ if ( isset( $settings[self::DB_FOLLOW_CHECK_INTERVAL] ) && $settings[self::DB_FOLLOW_CHECK_INTERVAL] ) {
938
+ $this->follow_base_check_interval = (int) $settings[self::DB_FOLLOW_CHECK_INTERVAL];
939
+ if ( $this->follow_base_check_interval < self::OPT_FOLLOW_BASE_CHECK_INTERVAL_MIN ) {
940
+ $this->follow_base_check_interval = self::OPT_FOLLOW_BASE_CHECK_INTERVAL_MIN;
941
+ }
942
+ } else {
943
+ $this->follow_base_check_interval = self::OPT_FOLLOW_BASE_CHECK_INTERVAL;
944
+ }
945
+
946
+ if ( isset( $settings[self::DB_COMMON_DYNAMIC_CACHE_MODE] ) && $settings[self::DB_COMMON_DYNAMIC_CACHE_MODE] ) {
947
+ $this->dynamic_cache_mode = (int) $settings[self::DB_COMMON_DYNAMIC_CACHE_MODE];
948
+ } else {
949
+ $this->dynamic_cache_mode = self::OPT_COMMON_ACCESS_BASED_2ND_CACHE;
950
+ }
951
+
952
+ if ( isset( $settings[self::DB_SHARE_RUSH_CHECK_INTERVAL] ) && $settings[self::DB_SHARE_RUSH_CHECK_INTERVAL] ) {
953
+ $this->share_rush_check_interval = (int) $settings[self::DB_SHARE_RUSH_CHECK_INTERVAL];
954
+ } else {
955
+ $this->share_rush_check_interval = self::OPT_SHARE_RUSH_CHECK_INTERVAL;
956
+ }
957
+
958
+ if ( isset( $settings[self::DB_SHARE_RUSH_NEW_CONTENT_TERM] ) && $settings[self::DB_SHARE_RUSH_NEW_CONTENT_TERM] ) {
959
+ $this->share_rush_new_content_term = (int) $settings[self::DB_SHARE_RUSH_NEW_CONTENT_TERM];
960
+ } else {
961
+ $this->share_rush_new_content_term = self::OPT_SHARE_RUSH_NEW_CONTENT_TERM;
962
+ }
963
+
964
+ if ( isset( $settings[self::DB_COMMON_DATA_EXPORT_MODE] ) && $settings[self::DB_COMMON_DATA_EXPORT_MODE] ) {
965
+ $this->data_export_mode = (int) $settings[self::DB_COMMON_DATA_EXPORT_MODE];
966
+ } else {
967
+ $this->data_export_mode = self::OPT_COMMON_DATA_EXPORT_MANUAL;
968
+ }
969
+
970
+ if ( isset( $settings[self::DB_COMMON_DATA_EXPORT_SCHEDULE] ) && $settings[self::DB_COMMON_DATA_EXPORT_SCHEDULE] ) {
971
+ $this->data_export_schedule = $settings[self::DB_COMMON_DATA_EXPORT_SCHEDULE];
972
+ } else {
973
+ $this->data_export_schedule = self::OPT_COMMON_DATA_EXPORT_SCHEDULE;
974
+ }
975
+
976
+ if ( isset( $settings[self::DB_SHARE_VARIATION_ANALYSIS_MODE] ) && $settings[self::DB_SHARE_VARIATION_ANALYSIS_MODE] ) {
977
+ $this->share_variation_analysis_mode = (int) $settings[self::DB_SHARE_VARIATION_ANALYSIS_MODE];
978
+ } else {
979
+ $this->share_variation_analysis_mode = self::OPT_SHARE_VARIATION_ANALYSIS_NONE;
980
+ }
981
+
982
+ if ( isset( $settings[self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE] ) && $settings[self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE] ) {
983
+ $this->share_variation_analysis_schedule = $settings[self::DB_SHARE_VARIATION_ANALYSIS_SCHEDULE];
984
+ } else {
985
+ $this->share_variation_analysis_schedule = self::OPT_SHARE_VARIATION_ANALYSIS_SCHEDULE;
986
+ }
987
+
988
+ if ( isset( $settings[self::DB_COMMON_SCHEME_MIGRATION_MODE] ) ) {
989
+ $this->scheme_migration_mode = $settings[self::DB_COMMON_SCHEME_MIGRATION_MODE];
990
+ } else {
991
+ $this->scheme_migration_mode = self::OPT_COMMON_SCHEME_MIGRATION_MODE_OFF;
992
+ }
993
+
994
+ if ( isset( $settings[self::DB_COMMON_SCHEME_MIGRATION_DATE] ) ) {
995
+ $this->scheme_migration_date = $settings[self::DB_COMMON_SCHEME_MIGRATION_DATE];
996
+ }
997
+
998
+ if ( isset( $settings[self::DB_SHARE_CACHE_TARGET] ) && $settings[self::DB_SHARE_CACHE_TARGET] ) {
999
+ $this->share_base_cache_target = $settings[self::DB_SHARE_CACHE_TARGET];
1000
+ } else {
1001
+ $this->share_base_cache_target[self::REF_SHARE_GPLUS] = true;
1002
+ $this->share_base_cache_target[self::REF_SHARE_FACEBOOK] = true;
1003
+ $this->share_base_cache_target[self::REF_SHARE_POCKET] = true;
1004
+ $this->share_base_cache_target[self::REF_SHARE_HATEBU] = true;
1005
+ }
1006
+
1007
+ $this->share_base_cache_target[self::REF_CRAWL_DATE] = true;
1008
+ $this->share_base_cache_target[self::REF_SHARE_TOTAL] = true;
1009
+
1010
+ if ( isset( $settings[self::DB_SHARE_BASE_TWITTER_API] ) ) {
1011
+ $this->share_base_twitter_api = (int) $settings[self::DB_SHARE_BASE_TWITTER_API];
1012
+ } else {
1013
+ $this->share_base_twitter_api = self::OPT_SHARE_TWITTER_API_JSOON;
1014
+ }
1015
+
1016
+ // Pocket and Google+ are excluded from migration target because they are migrated automatically.
1017
+ $this->scheme_migration_exclude_keys = array(
1018
+ self::REF_SHARE_POCKET,
1019
+ self::REF_SHARE_GPLUS,
1020
+ self::REF_FOLLOW_TWITTER,
1021
+ self::REF_FOLLOW_FACEBOOK,
1022
+ self::REF_FOLLOW_PUSH7,
1023
+ self::REF_FOLLOW_INSTAGRAM
1024
+ );
1025
+
1026
+ if ( $this->share_base_twitter_api === self::OPT_SHARE_TWITTER_API_JSOON ) {
1027
+ $this->scheme_migration_exclude_keys[] = self::REF_SHARE_TWITTER;
1028
+ }
1029
+
1030
+ if ( isset( $settings[self::DB_FOLLOW_CACHE_TARGET] ) && $settings[self::DB_FOLLOW_CACHE_TARGET] ) {
1031
+ $this->follow_base_cache_target = $settings[self::DB_FOLLOW_CACHE_TARGET];
1032
+ } else {
1033
+ $this->follow_base_cache_target[self::REF_FOLLOW_FEEDLY] = true;
1034
+ }
1035
+
1036
+ $this->follow_base_cache_target[self::REF_CRAWL_DATE] = true;
1037
+
1038
+ if ( isset( $settings[self::DB_FOLLOW_FEED_TYPE] ) && $settings[self::DB_FOLLOW_FEED_TYPE] ) {
1039
+ $this->follow_feed_type = $settings[self::DB_FOLLOW_FEED_TYPE];
1040
+ } else {
1041
+ $this->follow_feed_type = self::OPT_FEED_TYPE_DEFAULT;
1042
+ }
1043
+
1044
+ if ( isset( $settings[self::DB_SHARE_CUSTOM_POST_TYPES] ) && $settings[self::DB_SHARE_CUSTOM_POST_TYPES] ) {
1045
+ $this->share_base_custom_post_types = $settings[self::DB_SHARE_CUSTOM_POST_TYPES];
1046
+ } else {
1047
+ $this->share_base_custom_post_types = array();
1048
+ }
1049
+
1050
+ $this->share_base_cache_post_types = array_merge( $this->share_base_cache_post_types, $this->share_base_custom_post_types );
1051
+
1052
+ if ( extension_loaded( 'curl' ) ) {
1053
+ $this->crawler_method = self::OPT_COMMON_CRAWLER_METHOD_CURL;
1054
+ } else {
1055
+ $this->crawler_method = self::OPT_COMMON_CRAWLER_METHOD_NORMAL;
1056
+ }
1057
+
1058
+ if ( isset( $settings[self::DB_COMMON_CRAWLER_SSL_VERIFICATION] ) ) {
1059
+ $this->crawler_ssl_verification = $settings[self::DB_COMMON_CRAWLER_SSL_VERIFICATION];
1060
+ } else {
1061
+ $this->crawler_ssl_verification = self::OPT_COMMON_CRAWLER_SSL_VERIFY_ON;
1062
+ }
1063
+
1064
+ if ( isset( $settings[self::DB_FOLLOW_TWITTER_SCREEN_NAME] ) && $settings[self::DB_FOLLOW_TWITTER_SCREEN_NAME] ) {
1065
+ $this->follow_twitter_screen_name = $settings[self::DB_FOLLOW_TWITTER_SCREEN_NAME];
1066
+ }
1067
+
1068
+ if ( isset( $settings[self::DB_FOLLOW_TWITTER_CONSUMER_KEY] ) && $settings[self::DB_FOLLOW_TWITTER_CONSUMER_KEY] ) {
1069
+ $this->follow_twitter_consumer_key = trim( Common_Util::decrypt_data( $settings[self::DB_FOLLOW_TWITTER_CONSUMER_KEY], AUTH_KEY ) );
1070
+ }
1071
+
1072
+ if ( isset( $settings[self::DB_FOLLOW_TWITTER_CONSUMER_SECRET] ) && $settings[self::DB_FOLLOW_TWITTER_CONSUMER_SECRET] ) {
1073
+ $this->follow_twitter_consumer_secret = trim( Common_Util::decrypt_data( $settings[self::DB_FOLLOW_TWITTER_CONSUMER_SECRET], AUTH_KEY ) );
1074
+ }
1075
+
1076
+ if ( isset( $settings[self::DB_FOLLOW_TWITTER_BEARER_TOKEN] ) && $settings[self::DB_FOLLOW_TWITTER_BEARER_TOKEN] ) {
1077
+ $this->follow_twitter_bearer_token = trim( Common_Util::decrypt_data( $settings[self::DB_FOLLOW_TWITTER_BEARER_TOKEN], AUTH_KEY ) );
1078
+ }
1079
+
1080
+ /*
1081
+ if ( isset( $settings[self::DB_FOLLOW_TWITTER_ACCESS_TOKEN] ) && $settings[self::DB_FOLLOW_TWITTER_ACCESS_TOKEN] ) {
1082
+ $this->follow_twitter_access_token = trim( Common_Util::decrypt_data( $settings[self::DB_FOLLOW_TWITTER_ACCESS_TOKEN], AUTH_KEY ) );
1083
+ }
1084
+
1085
+ if ( isset( $settings[self::DB_FOLLOW_TWITTER_ACCESS_TOKEN_SECRET] ) && $settings[self::DB_FOLLOW_TWITTER_ACCESS_TOKEN_SECRET] ) {
1086
+ $this->follow_twitter_access_token_secret = trim( Common_Util::decrypt_data( $settings[self::DB_FOLLOW_TWITTER_ACCESS_TOKEN_SECRET], AUTH_KEY ) );
1087
+ }
1088
+ */
1089
+
1090
+ if ( isset( $settings[self::DB_FOLLOW_FACEBOOK_PAGE_ID] ) && $settings[self::DB_FOLLOW_FACEBOOK_PAGE_ID] ) {
1091
+ $this->follow_facebook_page_id = $settings[self::DB_FOLLOW_FACEBOOK_PAGE_ID];
1092
+ }
1093
+
1094
+ if ( isset( $settings[self::DB_FOLLOW_FACEBOOK_APP_ID] ) && $settings[self::DB_FOLLOW_FACEBOOK_APP_ID] ) {
1095
+ $this->follow_facebook_app_id = trim( Common_Util::decrypt_data( $settings[self::DB_FOLLOW_FACEBOOK_APP_ID], AUTH_KEY ) );
1096
+ }
1097
+
1098
+ if ( isset( $settings[self::DB_FOLLOW_FACEBOOK_APP_SECRET] ) && $settings[self::DB_FOLLOW_FACEBOOK_APP_SECRET] ) {
1099
+ $this->follow_facebook_app_secret = trim( Common_Util::decrypt_data( $settings[self::DB_FOLLOW_FACEBOOK_APP_SECRET], AUTH_KEY ) );
1100
+ }
1101
+
1102
+ if ( isset( $settings[self::DB_FOLLOW_FACEBOOK_ACCESS_TOKEN] ) && $settings[self::DB_FOLLOW_FACEBOOK_ACCESS_TOKEN] ) {
1103
+ $this->follow_facebook_access_token = trim( Common_Util::decrypt_data( $settings[self::DB_FOLLOW_FACEBOOK_ACCESS_TOKEN], AUTH_KEY ) );
1104
+ }
1105
+
1106
+ if ( isset( $settings[self::DB_FOLLOW_PUSH7_APPNO] ) && $settings[self::DB_FOLLOW_PUSH7_APPNO] ) {
1107
+ $this->follow_push7_appno = trim( Common_Util::decrypt_data( $settings[self::DB_FOLLOW_PUSH7_APPNO], AUTH_KEY ) );
1108
+ }
1109
+
1110
+ if ( isset( $settings[self::DB_FOLLOW_INSTAGRAM_CLIENT_ID] ) && $settings[self::DB_FOLLOW_INSTAGRAM_CLIENT_ID] ) {
1111
+ $this->follow_instagram_client_id = trim( Common_Util::decrypt_data( $settings[self::DB_FOLLOW_INSTAGRAM_CLIENT_ID], AUTH_KEY ) );
1112
+ }
1113
+
1114
+ if ( isset( $settings[self::DB_FOLLOW_INSTAGRAM_CLIENT_SECRET] ) && $settings[self::DB_FOLLOW_INSTAGRAM_CLIENT_SECRET] ) {
1115
+ $this->follow_instagram_client_secret = trim( Common_Util::decrypt_data( $settings[self::DB_FOLLOW_INSTAGRAM_CLIENT_SECRET], AUTH_KEY ) );
1116
+ }
1117
+
1118
+ if ( isset( $settings[self::DB_FOLLOW_INSTAGRAM_ACCESS_TOKEN] ) && $settings[self::DB_FOLLOW_INSTAGRAM_ACCESS_TOKEN] ) {
1119
+ $this->follow_instagram_access_token = trim( Common_Util::decrypt_data( $settings[self::DB_FOLLOW_INSTAGRAM_ACCESS_TOKEN], AUTH_KEY ) );
1120
+ }
1121
+
1122
+ // Share Crawler
1123
+ $options = array(
1124
+ 'target_sns' => $this->share_base_cache_target,
1125
+ 'crawl_method' => $this->crawler_method,
1126
+ 'timeout' => self::OPT_COMMON_CRAWLER_TIMEOUT,
1127
+ 'retry_limit' => self::OPT_COMMON_CRAWLER_RETRY_LIMIT,
1128
+ 'ssl_verification' => $this->crawler_ssl_verification,
1129
+ );
1130
+
1131
+ $this->crawlers[self::REF_SHARE] = Share_Crawler::get_instance();
1132
+ $this->crawlers[self::REF_SHARE]->initialize( $options );
1133
+
1134
+ // Share Twitter Crawl Strategy
1135
+ $options = array(
1136
+ 'twitter_api' => $this->share_base_twitter_api
1137
+ );
1138
+
1139
+ $this->crawlers[self::REF_SHARE]->initialize_crawl_strategy( self::REF_SHARE_TWITTER, $options );
1140
+
1141
+ // Follow Crawler
1142
+ $options = array(
1143
+ 'target_sns' => $this->follow_base_cache_target,
1144
+ 'crawl_method' => $this->crawler_method,
1145
+ 'timeout' => self::OPT_COMMON_CRAWLER_TIMEOUT,
1146
+ 'retry_limit' => self::OPT_COMMON_CRAWLER_RETRY_LIMIT,
1147
+ 'ssl_verification' => $this->crawler_ssl_verification
1148
+ );
1149
+
1150
+ $this->crawlers[self::REF_FOLLOW] = Follow_Crawler::get_instance();
1151
+ $this->crawlers[self::REF_FOLLOW]->initialize( $options );
1152
+
1153
+ // Follow Twitter Crawl Strategy
1154
+ $query_parameters = array(
1155
+ 'screen_name' => $this->follow_twitter_screen_name
1156
+ );
1157
+
1158
+ /*
1159
+ // version using user auth
1160
+ $parameters = array(
1161
+ 'consumer_key' => $this->follow_twitter_consumer_key,
1162
+ 'consumer_secret' => $this->follow_twitter_consumer_secret,
1163
+ 'access_token' => $this->follow_twitter_access_token,
1164
+ 'access_token_secret' => $this->follow_twitter_access_token_secret
1165
+ );
1166
+ */
1167
+
1168
+ // version using application-only auth
1169
+ $parameters = array(
1170
+ 'consumer_key' => $this->follow_twitter_consumer_key,
1171
+ 'consumer_secret' => $this->follow_twitter_consumer_secret,
1172
+ 'bearer_token' => $this->follow_twitter_bearer_token
1173
+ );
1174
+
1175
+ $this->crawlers[self::REF_FOLLOW]->set_crawl_strategy_query_parameters( self::REF_FOLLOW_TWITTER, $query_parameters );
1176
+ $this->crawlers[self::REF_FOLLOW]->set_crawl_strategy_parameters( self::REF_FOLLOW_TWITTER, $parameters );
1177
+
1178
+ // Follow Feedly Crawl Strategy
1179
+ $query_parameters = array(
1180
+ 'url' => get_feed_link( $this->follow_feed_type )
1181
+ );
1182
+
1183
+ $this->crawlers[self::REF_FOLLOW]->set_crawl_strategy_query_parameters( self::REF_FOLLOW_FEEDLY, $query_parameters );
1184
+
1185
+ // Follow Facebook Crawl Strategy
1186
+ $query_parameters = array(
1187
+ 'access_token' => $this->follow_facebook_access_token
1188
+ );
1189
+
1190
+ $parameters = array(
1191
+ 'page_id' => $this->follow_facebook_page_id,
1192
+ 'client_id' => $this->follow_facebook_app_id,
1193
+ 'client_secret' => $this->follow_facebook_app_secret
1194
+ );
1195
+
1196
+ $this->crawlers[self::REF_FOLLOW]->set_crawl_strategy_query_parameters( self::REF_FOLLOW_FACEBOOK, $query_parameters );
1197
+ $this->crawlers[self::REF_FOLLOW]->set_crawl_strategy_parameters( self::REF_FOLLOW_FACEBOOK, $parameters );
1198
+
1199
+ // Follow Push7 Crawl Strategy
1200
+ $parameters = array(
1201
+ 'appno' => $this->follow_push7_appno
1202
+ );
1203
+
1204
+ //$this->crawlers[self::REF_FOLLOW]->set_crawl_strategy_query_parameters( self::REF_FOLLOW_PUSH7, $query_parameters );
1205
+ $this->crawlers[self::REF_FOLLOW]->set_crawl_strategy_parameters( self::REF_FOLLOW_PUSH7, $parameters );
1206
+
1207
+ // Follow Instagram Crawl Strategy
1208
+ $query_parameters = array(
1209
+ 'access_token' => $this->follow_instagram_access_token
1210
+ );
1211
+
1212
+ $parameters = array(
1213
+ 'client_id' => $this->follow_instagram_client_id,
1214
+ 'client_secret' => $this->follow_instagram_client_secret
1215
+ );
1216
+
1217
+ $this->crawlers[self::REF_FOLLOW]->set_crawl_strategy_query_parameters( self::REF_FOLLOW_INSTAGRAM, $query_parameters );
1218
+ $this->crawlers[self::REF_FOLLOW]->set_crawl_strategy_parameters( self::REF_FOLLOW_INSTAGRAM, $parameters );
1219
+
1220
+ // Share base cache engine
1221
+ $options = array(
1222
+ 'delegate' => $this,
1223
+ 'crawler' => $this->crawlers[self::REF_SHARE],
1224
+ 'target_sns' => $this->share_base_cache_target,
1225
+ 'check_interval' => $this->share_base_check_interval,
1226
+ 'posts_per_check' => $this->share_base_posts_per_check,
1227
+ 'post_types' => $this->share_base_cache_post_types,
1228
+ 'scheme_migration_mode' => $this->scheme_migration_mode,
1229
+ 'scheme_migration_date' => $this->scheme_migration_date,
1230
+ 'scheme_migration_exclude_keys' => $this->scheme_migration_exclude_keys
1231
+ );
1232
+
1233
+ $this->cache_engines[self::REF_SHARE_BASE] = Share_Base_Cache_Engine::get_instance();
1234
+ $this->cache_engines[self::REF_SHARE_BASE]->initialize( $options );
1235
+
1236
+ // Share rush cache engine
1237
+ $options = array(
1238
+ 'delegate' => $this,
1239
+ 'crawler' => $this->crawlers[self::REF_SHARE],
1240
+ 'target_sns' => $this->share_base_cache_target,
1241
+ 'check_interval' => $this->share_rush_check_interval,
1242
+ 'posts_per_check' => 30,
1243
+ 'new_content_term' => $this->share_rush_new_content_term,
1244
+ 'post_types' => $this->share_base_cache_post_types,
1245
+ 'scheme_migration_mode' => $this->scheme_migration_mode,
1246
+ 'scheme_migration_date' => $this->scheme_migration_date,
1247
+ 'scheme_migration_exclude_keys' => $this->scheme_migration_exclude_keys
1248
+ );
1249
+
1250
+ $this->cache_engines[self::REF_SHARE_RUSH] = Share_Rush_Cache_Engine::get_instance();
1251
+ $this->cache_engines[self::REF_SHARE_RUSH]->initialize( $options );
1252
+
1253
+ // Share lazy cache engine
1254
+ $options = array(
1255
+ 'delegate' => $this,
1256
+ 'crawler' => $this->crawlers[self::REF_SHARE],
1257
+ 'target_sns' => $this->share_base_cache_target,
1258
+ 'check_interval' => $this->share_base_check_interval,
1259
+ 'posts_per_check' => $this->share_base_posts_per_check,
1260
+ 'post_types' => $this->share_base_cache_post_types,
1261
+ 'scheme_migration_mode' => $this->scheme_migration_mode,
1262
+ 'scheme_migration_date' => $this->scheme_migration_date,
1263
+ 'scheme_migration_exclude_keys' => $this->scheme_migration_exclude_keys
1264
+ );
1265
+
1266
+ $this->cache_engines[self::REF_SHARE_LAZY] = Share_Lazy_Cache_Engine::get_instance();
1267
+ $this->cache_engines[self::REF_SHARE_LAZY]->initialize( $options );
1268
+
1269
+ // Share second cache engine
1270
+ $options = array(
1271
+ 'delegate' => $this,
1272
+ 'target_sns' => $this->share_base_cache_target,
1273
+ 'check_interval' => self::OPT_SHARE_2ND_CHECK_INTERVAL,
1274
+ 'post_types' => $this->share_base_cache_post_types,
1275
+ 'cache_prefix' => self::OPT_SHARE_2ND_META_KEY_PREFIX,
1276
+ 'crawl_date_key' => self::REF_CRAWL_DATE
1277
+ );
1278
+
1279
+ $this->cache_engines[self::REF_SHARE_2ND] = Share_Second_Cache_Engine::get_instance();
1280
+ $this->cache_engines[self::REF_SHARE_2ND]->initialize( $options );
1281
+
1282
+ // Share restore cache engine
1283
+ $options = array(
1284
+ 'target_sns' => $this->share_base_cache_target,
1285
+ 'check_interval' => $this->share_base_check_interval,
1286
+ 'posts_per_check' => $this->share_base_posts_per_check,
1287
+ 'post_types' => $this->share_base_cache_post_types,
1288
+ );
1289
+
1290
+ $this->cache_engines[self::REF_SHARE_RESTORE] = Share_Restore_Cache_Engine::get_instance();
1291
+ $this->cache_engines[self::REF_SHARE_RESTORE]->initialize( $options );
1292
+
1293
+ // Follow base cache engine
1294
+ $options = array(
1295
+ 'delegate' => $this,
1296
+ 'crawler' => $this->crawlers[self::REF_FOLLOW],
1297
+ 'target_sns' => $this->follow_base_cache_target,
1298
+ 'check_interval' => $this->follow_base_check_interval,
1299
+ 'scheme_migration_mode' => $this->scheme_migration_mode,
1300
+ 'scheme_migration_exclude_keys' => $this->scheme_migration_exclude_keys,
1301
+ 'feed_type' => $this->follow_feed_type
1302
+ );
1303
+
1304
+ $this->cache_engines[self::REF_FOLLOW_BASE] = Follow_Base_Cache_Engine::get_instance();
1305
+ $this->cache_engines[self::REF_FOLLOW_BASE]->initialize( $options );
1306
+
1307
+ // Follow lazy cache engine
1308
+ $options = array(
1309
+ 'delegate' => $this,
1310
+ 'crawler' => $this->crawlers[self::REF_FOLLOW],
1311
+ 'target_sns' => $this->follow_base_cache_target,
1312
+ 'check_interval' => $this->follow_base_check_interval,
1313
+ 'scheme_migration_mode' => $this->scheme_migration_mode,
1314
+ 'scheme_migration_exclude_keys' => $this->scheme_migration_exclude_keys,
1315
+ 'feed_type' => $this->follow_feed_type
1316
+ );
1317
+
1318
+ $this->cache_engines[self::REF_FOLLOW_LAZY] = Follow_Lazy_Cache_Engine::get_instance();
1319
+ $this->cache_engines[self::REF_FOLLOW_LAZY]->initialize( $options );
1320
+
1321
+ // Follow second cache engine
1322
+ $options = array(
1323
+ 'crawler' => $this->crawlers[self::REF_FOLLOW],
1324
+ 'target_sns' => $this->follow_base_cache_target,
1325
+ 'check_interval' => self::OPT_FOLLOW_2ND_CHECK_INTERVAL,
1326
+ 'cache_prefix' => self::OPT_FOLLOW_2ND_META_KEY_PREFIX
1327
+ );
1328
+
1329
+ $this->cache_engines[self::REF_FOLLOW_2ND] = Follow_Second_Cache_Engine::get_instance();
1330
+ $this->cache_engines[self::REF_FOLLOW_2ND]->initialize( $options );
1331
+
1332
+ // Follow restore cache engine
1333
+ $options = array(
1334
+ 'target_sns' => $this->follow_base_cache_target,
1335
+ 'check_interval' => $this->follow_base_check_interval,
1336
+ );
1337
+
1338
+ $this->cache_engines[self::REF_FOLLOW_RESTORE] = Follow_Restore_Cache_Engine::get_instance();
1339
+ $this->cache_engines[self::REF_FOLLOW_RESTORE]->initialize( $options );
1340
+
1341
+ // Data export engine
1342
+ $options = array(
1343
+ 'export_activation' => $this->data_export_mode,
1344
+ 'export_schedule' => $this->data_export_schedule,
1345
+ 'share_target_sns' => $this->share_base_cache_target,
1346
+ 'follow_target_sns' => $this->follow_base_cache_target,
1347
+ 'export_file_name' => self::OPT_COMMON_DATA_EXPORT_FILE_NAME,
1348
+ 'export_exclude_keys' => array( self::REF_SHARE_TOTAL, self::REF_CRAWL_DATE ),
1349
+ 'post_types' => $this->share_base_cache_post_types
1350
+ );
1351
+
1352
+ $this->export_engines[self::REF_COMMON_EXPORT] = Common_Data_Export_Engine::get_instance();
1353
+ $this->export_engines[self::REF_COMMON_EXPORT]->initialize( $options );
1354
+
1355
+ // Share analytical engine
1356
+ $options = array(
1357
+ 'delegate' => $this,
1358
+ 'target_sns' => $this->share_base_cache_target,
1359
+ 'check_interval' => $this->share_base_check_interval,
1360
+ 'post_types' => $this->share_base_cache_post_types,
1361
+ 'base_schedule' => $this->share_variation_analysis_schedule,
1362
+ 'crawl_date_key' => self::REF_CRAWL_DATE
1363
+ );
1364
+
1365
+ $this->analytical_engines[self::REF_SHARE_ANALYSIS] = Share_Analytical_Engine::get_instance();
1366
+ $this->analytical_engines[self::REF_SHARE_ANALYSIS]->initialize( $options );
1367
+
1368
+ // Job reset engine
1369
+ $target_crons = array();
1370
+
1371
+ foreach ( $this->cache_engines as $key => $cache_engine ) {
1372
+ $target_crons[] = $cache_engine->get_excute_cron();
1373
+ }
1374
+
1375
+ foreach ( $this->control_engines as $key => $control_engine ) {
1376
+ $target_crons[] = $control_engine->get_excute_cron();
1377
+ }
1378
+
1379
+ if ( $this->data_export_mode === self::OPT_COMMON_DATA_EXPORT_SCHEDULER ) {
1380
+ $target_crons[] = $this->export_engines[self::REF_COMMON_EXPORT]->get_excute_cron();
1381
+ }
1382
+
1383
+ if ( $this->share_variation_analysis_mode === self::OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER ) {
1384
+ $target_crons[] = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_excute_cron();
1385
+ }
1386
+
1387
+ $options = array(
1388
+ 'delegate' => $this,
1389
+ 'check_interval' => 600,
1390
+ 'expiration_time ' => 1800,
1391
+ 'target_cron' => $target_crons
1392
+ );
1393
+
1394
+ $this->control_engines[self::REF_COMMON_CONTROL] = Common_Job_Reset_Engine::get_instance();
1395
+ $this->control_engines[self::REF_COMMON_CONTROL]->initialize( $options );
1396
+
1397
+ $tmp_max_execution_time = ini_get( 'max_execution_time' );
1398
+
1399
+ if ( isset( $tmp_max_execution_time ) && $tmp_max_execution_time > 0 ) {
1400
+ $this->original_max_execution_time = $tmp_max_execution_time;
1401
+ } else {
1402
+ $this->original_max_execution_time = 30;
1403
+ }
1404
+
1405
+ $this->loading_img_url = plugins_url( '/images/loading.gif', __FILE__ );
1406
+
1407
+ // delete old hooks
1408
+ WP_Cron_Util::clear_scheduled_hook( 'scc_basecache_prime' );
1409
+ WP_Cron_Util::clear_scheduled_hook( 'scc_rushcache_prime' );
1410
+ WP_Cron_Util::clear_scheduled_hook( 'scc_2ndcache_prime' );
1411
+ WP_Cron_Util::clear_scheduled_hook( 'scc_share_rescuecache_prime' );
1412
+ }
1413
+
1414
+ /**
1415
+ * Registers and enqueues admin-specific styles.
1416
+ *
1417
+ * @since 0.1.0
1418
+ */
1419
+ public function register_admin_styles() {
1420
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1421
+
1422
+ if ( ! isset( $this->plugin_screen_hook_suffix ) ) {
1423
+ return;
1424
+ }
1425
+
1426
+ $screen = get_current_screen();
1427
+
1428
+ if ( in_array( $screen->id, $this->plugin_screen_hook_suffix ) ) {
1429
+ wp_enqueue_style( self::DOMAIN .'-admin-style-1', plugins_url( ltrim( '/css/sns-count-cache.css', '/' ), __FILE__) );
1430
+ wp_enqueue_style( self::DOMAIN .'-admin-style-2', plugins_url( ltrim( '/css/monokai.css', '/' ), __FILE__ ) );
1431
+ wp_enqueue_style( 'jquery-ui-datepicker-style' , '//ajax.googleapis.com/ajax/libs/jqueryui/1/themes/smoothness/jquery-ui.css');
1432
+ }
1433
+ }
1434
+
1435
+ /**
1436
+ * Registers and enqueues admin-specific JavaScript.
1437
+ *
1438
+ * @since 0.1.0
1439
+ */
1440
+ public function register_admin_scripts() {
1441
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1442
+
1443
+ if ( ! isset( $this->plugin_screen_hook_suffix ) ) {
1444
+ return;
1445
+ }
1446
+
1447
+ $screen = get_current_screen();
1448
+
1449
+ if ( in_array( $screen->id, $this->plugin_screen_hook_suffix ) ) {
1450
+ wp_enqueue_script( self::DOMAIN . '-admin-script-1', plugins_url( ltrim( '/js/highlight.pack.js', '/' ) , __FILE__ ), array( 'jquery' ) );
1451
+
1452
+ wp_enqueue_script( self::DOMAIN . '-admin-script-2', plugins_url( ltrim( '/js/jquery.scc-cache-info.js', '/' ), __FILE__ ), array( 'jquery' ) );
1453
+ wp_localize_script( self::DOMAIN . '-admin-script-2', 'scc', array( 'endpoint' => admin_url( 'admin-ajax.php' ), 'action' => $this->ajax_action, 'nonce' => wp_create_nonce( $this->ajax_action ) ) );
1454
+
1455
+ wp_enqueue_script( 'jquery-ui-datepicker' );
1456
+ }
1457
+ }
1458
+
1459
+ /**
1460
+ * Activate cache engine (schedule cron)
1461
+ *
1462
+ * @since 0.1.1
1463
+ */
1464
+ public function activate_plugin() {
1465
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1466
+
1467
+ $this->initialize();
1468
+
1469
+ set_time_limit( $this->extended_max_execution_time );
1470
+
1471
+ foreach ( $this->cache_engines as $key => $cache_engine ) {
1472
+ switch ( $key ) {
1473
+ case self::REF_SHARE_2ND:
1474
+ $cache_engine->initialize_cache();
1475
+ break;
1476
+ case self::REF_FOLLOW_2ND:
1477
+ $cache_engine->initialize_cache();
1478
+ break;
1479
+ default:
1480
+ $cache_engine->initialize_cache();
1481
+ $cache_engine->register_schedule();
1482
+ }
1483
+ }
1484
+
1485
+ foreach ( $this->control_engines as $key => $control_engine ) {
1486
+ $control_engine->register_schedule();
1487
+ }
1488
+
1489
+ if ( $this->share_variation_analysis_mode === self::OPT_SHARE_VARIATION_ANALYSIS_SCHEDULER ) {
1490
+ $this->analytical_engines[self::REF_SHARE_ANALYSIS]->register_schedule();
1491
+ }
1492
+
1493
+ if ( $this->data_export_mode === self::OPT_COMMON_DATA_EXPORT_SCHEDULER ) {
1494
+ $this->export_engines[self::REF_COMMON_EXPORT]->register_schedule();
1495
+ }
1496
+
1497
+ set_time_limit( $this->original_max_execution_time );
1498
+ }
1499
+
1500
+ /**
1501
+ * Deactivate cache engine (schedule cron)
1502
+ *
1503
+ * @since 0.1.1
1504
+ */
1505
+ public function deactivate_plugin() {
1506
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1507
+
1508
+ set_time_limit( $this->extended_max_execution_time );
1509
+
1510
+ foreach ( $this->cache_engines as $key => $cache_engine ) {
1511
+ $cache_engine->unregister_schedule();
1512
+ $cache_engine->clear_cache();
1513
+ }
1514
+
1515
+ // compatibility for old version
1516
+ $query_args = array(
1517
+ 'post_type' => $this->share_base_cache_post_types,
1518
+ 'post_status' => 'publish',
1519
+ 'nopaging' => true,
1520
+ 'update_post_term_cache' => false,
1521
+ 'update_post_meta_cache' => false
1522
+ );
1523
+
1524
+ $posts_query = new WP_Query( $query_args );
1525
+
1526
+ if ( $posts_query->have_posts() ) {
1527
+ while ( $posts_query->have_posts() ) {
1528
+ $posts_query->the_post();
1529
+
1530
+ $post_ID = get_the_ID();
1531
+
1532
+ foreach ( $this->follow_base_cache_target as $sns => $active ) {
1533
+
1534
+ if ( $active ) {
1535
+ $meta_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( $sns );
1536
+
1537
+ delete_post_meta( $post_ID, $meta_key );
1538
+ }
1539
+ }
1540
+ }
1541
+ }
1542
+ wp_reset_postdata();
1543
+
1544
+ foreach ( $this->control_engines as $key => $control_engine ) {
1545
+ $control_engine->unregister_schedule();
1546
+ }
1547
+
1548
+ $this->analytical_engines[self::REF_SHARE_ANALYSIS]->unregister_schedule();
1549
+ $this->analytical_engines[self::REF_SHARE_ANALYSIS]->clear_base();
1550
+
1551
+ $this->export_engines[self::REF_COMMON_EXPORT]->unregister_schedule();
1552
+
1553
+ set_time_limit( $this->original_max_execution_time );
1554
+ }
1555
+
1556
+ /**
1557
+ * Reactivate cache engine
1558
+ *
1559
+ * @since 0.1.1
1560
+ */
1561
+ function reactivate_plugin() {
1562
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1563
+
1564
+ $this->deactivate_plugin();
1565
+ $this->activate_plugin();
1566
+ }
1567
+
1568
+ /**
1569
+ * Delete related cache when the post was deleted.
1570
+ *
1571
+ * @since 0.7.0
1572
+ */
1573
+ public function clear_cache_deleted_post( $post_id ) {
1574
+ if ( isset( $post_id ) && $post_id ) {
1575
+ $this->cache_engines[self::REF_SHARE_BASE]->clear_cache_by_post_id( $post_id );
1576
+ $this->cache_engines[self::REF_SHARE_2ND]->clear_cache_by_post_id( $post_id );
1577
+ $this->analytical_engines[self::REF_SHARE_ANALYSIS]->clear_base_by_post_id( $post_id );
1578
+ }
1579
+ }
1580
+
1581
+ /**
1582
+ * Adds options & management pages to the admin menu.
1583
+ *
1584
+ * Run using the 'admin_menu' action.
1585
+ *
1586
+ * @since 0.1.0
1587
+ */
1588
+ public function register_admin_menu() {
1589
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1590
+
1591
+ $this->plugin_screen_hook_suffix[] = 'dashboard';
1592
+ $this->plugin_screen_hook_suffix[] = add_menu_page( __( 'SNS Count Cache', self::DOMAIN ), __( 'SNS Count Cache', self::DOMAIN ), self::OPT_COMMON_CAPABILITY, 'scc-dashboard', array( $this, 'dashboard_page' ), 'dashicons-share' );
1593
+ $this->plugin_screen_hook_suffix[] = add_submenu_page( 'scc-dashboard', __( 'Dashboard | SNS Count Cache', self::DOMAIN ), __( 'Dashboard', self::DOMAIN ), self::OPT_COMMON_CAPABILITY, 'scc-dashboard', array( $this, 'dashboard_page' ) );
1594
+ $this->plugin_screen_hook_suffix[] = add_submenu_page( 'scc-dashboard', __( 'Cache Status | SNS Count Cache', self::DOMAIN ), __( 'Cache Status', self::DOMAIN ), self::OPT_COMMON_CAPABILITY, 'scc-cache-status', array( $this, 'cache_status_page' ) );
1595
+ $this->plugin_screen_hook_suffix[] = add_submenu_page( 'scc-dashboard', __( 'Share Count | SNS Count Cache', self::DOMAIN ), __( 'Share Count', self::DOMAIN ), self::OPT_COMMON_CAPABILITY, 'scc-share-count', array( $this, 'share_count_page' ) );
1596
+
1597
+ if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) {
1598
+ $this->plugin_screen_hook_suffix[] = add_submenu_page( 'scc-dashboard', __( 'Hot Content | SNS Count Cache', self::DOMAIN ), __( 'Hot Content', self::DOMAIN ), self::OPT_COMMON_CAPABILITY, 'scc-hot-content', array( $this, 'hot_content_page' ) );
1599
+ }
1600
+
1601
+ $this->plugin_screen_hook_suffix[] = add_submenu_page( 'scc-dashboard', __( 'Setting | SNS Count Cache', self::DOMAIN ), __( 'Setting', self::DOMAIN ), self::OPT_COMMON_CAPABILITY, 'scc-setting', array( $this, 'setting_page' ) );
1602
+ $this->plugin_screen_hook_suffix[] = add_submenu_page( 'scc-dashboard', __( 'Help | SNS Count Cache', self::DOMAIN ), __( 'Help', self::DOMAIN ), self::OPT_COMMON_CAPABILITY, 'scc-help', array( $this, 'help_page' ) );
1603
+ }
1604
+
1605
+ /**
1606
+ * Add widget to wordpress dashboard
1607
+ *
1608
+ * @since 0.5.1
1609
+ */
1610
+ public function add_wp_dashboard_widget() {
1611
+ if ( ! current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
1612
+ return false;
1613
+ }
1614
+ wp_add_dashboard_widget( 'scc_dashboard', 'SNS Count Cache', array( $this, 'wp_dashboard_page' ) );
1615
+ }
1616
+
1617
+ /**
1618
+ * Option page implementation
1619
+ *
1620
+ * @since 0.5.1
1621
+ */
1622
+ public function wp_dashboard_page() {
1623
+ if ( ! current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
1624
+ wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
1625
+ }
1626
+ include_once( dirname( __FILE__ ) . '/includes/admin-dashboard-widget.php' );
1627
+ }
1628
+
1629
+
1630
+ /**
1631
+ * Option page implementation
1632
+ *
1633
+ * @since 0.1.0
1634
+ */
1635
+ public function dashboard_page() {
1636
+ if ( ! current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
1637
+ wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
1638
+ }
1639
+ include_once( dirname( __FILE__ ) . '/includes/admin-dashboard.php' );
1640
+ }
1641
+
1642
+ /**
1643
+ * Option page implementation
1644
+ *
1645
+ * @since 0.1.0
1646
+ */
1647
+ public function cache_status_page() {
1648
+ if ( ! current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
1649
+ wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
1650
+ }
1651
+ include_once( dirname( __FILE__ ) . '/includes/admin-cache-status.php' );
1652
+ }
1653
+
1654
+ /**
1655
+ * Option page implementation
1656
+ *
1657
+ * @since 0.1.0
1658
+ */
1659
+ public function share_count_page() {
1660
+ if ( ! current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
1661
+ wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
1662
+ }
1663
+ include_once( dirname( __FILE__ ) . '/includes/admin-share-count.php' );
1664
+ }
1665
+
1666
+ /**
1667
+ * Option page implementation
1668
+ *
1669
+ * @since 0.1.0
1670
+ */
1671
+ public function setting_page() {
1672
+ if ( ! current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
1673
+ wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
1674
+ }
1675
+ include( dirname( __FILE__ ) . '/includes/admin-setting.php' );
1676
+ }
1677
+
1678
+ /**
1679
+ * Option page implementation
1680
+ *
1681
+ * @since 0.1.0
1682
+ */
1683
+ public function help_page() {
1684
+ if ( ! current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
1685
+ wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
1686
+ }
1687
+ include_once( dirname( __FILE__ ) . '/includes/admin-help.php' );
1688
+ }
1689
+
1690
+ /**
1691
+ * Option page implementation
1692
+ *
1693
+ * @since 0.5.1
1694
+ */
1695
+ public function notice_page() {
1696
+ if ( ! current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
1697
+ wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
1698
+ }
1699
+ include_once( dirname( __FILE__ ) . '/includes/admin-notice.php' );
1700
+ }
1701
+
1702
+ /**
1703
+ * Option page implementation
1704
+ *
1705
+ * @since 0.6.1
1706
+ */
1707
+ public function hot_content_page() {
1708
+ if ( ! current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
1709
+ wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
1710
+ }
1711
+ include_once( dirname( __FILE__ ) . '/includes/admin-hot-content.php' );
1712
+ }
1713
+
1714
+
1715
+ /**
1716
+ * Cache share count for a given post ID
1717
+ *
1718
+ * @since 0.2.0
1719
+ */
1720
+ private function retrieve_share_cache( $post_ID, $second_sync = false ) {
1721
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1722
+ return $this->cache_engines[self::REF_SHARE_BASE]->direct_cache( $post_ID, $second_sync );
1723
+ }
1724
+
1725
+ /**
1726
+ * Cache follow count
1727
+ *
1728
+ * @since 0.2.0
1729
+ */
1730
+ private function retrieve_follow_cache( $second_sync = false ) {
1731
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1732
+ return $this->cache_engines[self::REF_FOLLOW_BASE]->direct_cache( $second_sync );
1733
+ }
1734
+
1735
+ /**
1736
+ * Reserve cache processing of share count for a given post ID
1737
+ *
1738
+ * @since 0.2.0
1739
+ */
1740
+ private function reserve_share_cache( $post_ID ) {
1741
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1742
+ $this->cache_engines[self::REF_SHARE_LAZY]->prime_cache( $post_ID );
1743
+ }
1744
+
1745
+ /**
1746
+ * Reserve cache processing of follow count
1747
+ *
1748
+ * @since 0.4.0
1749
+ */
1750
+ private function reserve_follow_cache() {
1751
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1752
+ $this->cache_engines[self::REF_FOLLOW_LAZY]->prime_cache();
1753
+ }
1754
+
1755
+ /**
1756
+ * Method call between one cache engine and another
1757
+ *
1758
+ * @since 0.4.0
1759
+ */
1760
+ public function order_cache( Cache_Engine $engine, $options = array() ) {
1761
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1762
+
1763
+ switch ( get_class( $engine ) ) {
1764
+ case 'Share_Lazy_Cache_Engine':
1765
+ $this->cache_engines[self::REF_SHARE_2ND]->cache( $options );
1766
+ break;
1767
+ case 'Share_Rescue_Cache_Engine':
1768
+ $this->cache_engines[self::REF_SHARE_2ND]->cache( $options );
1769
+ break;
1770
+ case 'Share_Base_Cache_Engine':
1771
+ $this->cache_engines[self::REF_SHARE_2ND]->cache( $options );
1772
+ break;
1773
+ case 'Share_Rush_Cache_Engine':
1774
+ $this->cache_engines[self::REF_SHARE_2ND]->cache( $options );
1775
+ break;
1776
+ case 'Follow_Lazy_Cache_Engine':
1777
+ $this->cache_engines[self::REF_FOLLOW_2ND]->cache( $options );
1778
+ break;
1779
+ case 'Follow_Base_Cache_Engine':
1780
+ $this->cache_engines[self::REF_FOLLOW_2ND]->cache( $options );
1781
+ break;
1782
+ }
1783
+ }
1784
+
1785
+ /**
1786
+ * Method call between one cache engine and another
1787
+ *
1788
+ * @since 0.6.1
1789
+ */
1790
+ public function order_analysis( Cache_Engine $engine, $options = array() ) {
1791
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1792
+
1793
+ if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) {
1794
+ switch ( get_class( $engine ) ) {
1795
+ case 'Share_Second_Cache_Engine':
1796
+ $this->analytical_engines[self::REF_SHARE_ANALYSIS]->analyze( $options );
1797
+ break;
1798
+ }
1799
+ }
1800
+ }
1801
+
1802
+ /**
1803
+ * Return pagination
1804
+ *
1805
+ * @since 0.4.0
1806
+ */
1807
+ private function pagination( $numpages = '', $pagerange = '', $paged='', $inherit_param = true ) {
1808
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1809
+
1810
+ if ( empty( $pagerange ) ) {
1811
+ $pagerange = 2;
1812
+ }
1813
+
1814
+ if ( $paged === '' ) {
1815
+ global $paged;
1816
+
1817
+ if ( empty( $paged ) ) {
1818
+ $paged = 1;
1819
+ }
1820
+ }
1821
+
1822
+ if ( $numpages === '' ) {
1823
+ global $wp_query;
1824
+
1825
+ $numpages = $wp_query->max_num_pages;
1826
+
1827
+ if( ! $numpages ) {
1828
+ $numpages = 1;
1829
+ }
1830
+ }
1831
+
1832
+ $pagination_args = array();
1833
+
1834
+ $url = parse_url( get_pagenum_link(1) );
1835
+ $base_url = $url['scheme'] . '://' . $url['host'] . $url['path'];
1836
+
1837
+ parse_str ( $url['query'], $query );
1838
+
1839
+ $base_url = $base_url . '?page=' . $query['page'];
1840
+
1841
+ Common_Util::log( '[' . __METHOD__ . '] base url: ' . $base_url );
1842
+
1843
+ $pagination_args = array(
1844
+ 'base' => $base_url . '%_%',
1845
+ 'format' => '&paged=%#%',
1846
+ 'total' => $numpages,
1847
+ 'current' => $paged,
1848
+ 'show_all' => false,
1849
+ 'end_size' => 1,
1850
+ 'mid_size' => $pagerange,
1851
+ 'prev_next' => true,
1852
+ 'prev_text' => '&laquo;',
1853
+ 'next_text' => '&raquo;',
1854
+ 'type' => 'plain',
1855
+ 'add_args' => '',
1856
+ 'add_fragment' => ''
1857
+ );
1858
+
1859
+ $paginate_links = paginate_links( $pagination_args );
1860
+
1861
+ if ( $inherit_param ) {
1862
+ Common_Util::log( '[' . __METHOD__ . '] inherit param: true' );
1863
+ } else {
1864
+ Common_Util::log( '[' . __METHOD__ . '] inherit param: false' );
1865
+
1866
+ $pattern = '/(?:&#038;action=cache&#038;post_id=[0-9]+&#038;_wpnonce=.{10})/';
1867
+ $paginate_links = preg_replace( $pattern, '', $paginate_links );
1868
+ }
1869
+
1870
+ if ( $paginate_links ) {
1871
+ echo "<nav class='pagination'>";
1872
+ echo "<span class='page-numbers page-num'>Page " . $paged . " of " . $numpages . "</span> ";
1873
+ echo $paginate_links;
1874
+ echo "</nav>";
1875
+ }
1876
+ }
1877
+
1878
+ /**
1879
+ * Return cache information through ajax interface
1880
+ *
1881
+ * @since 0.5.1
1882
+ */
1883
+ public function get_cache_info() {
1884
+ Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
1885
+
1886
+ if ( isset( $_REQUEST['nonce'] ) && wp_verify_nonce( $_REQUEST['nonce'], $this->ajax_action ) ) {
1887
+ if ( current_user_can( self::OPT_COMMON_CAPABILITY ) ) {
1888
+
1889
+ $share_base_cache_target = $this->share_base_cache_target;
1890
+
1891
+ unset( $share_base_cache_target[self::REF_CRAWL_DATE] );
1892
+
1893
+ $posts_count = 0;
1894
+ $primary_full_cache_count = 0;
1895
+ $primary_partial_cache_count = 0;
1896
+ $primary_no_cache_count = 0;
1897
+
1898
+ $secondary_full_cache_count = 0;
1899
+ $secondary_partial_cache_count = 0;
1900
+ $secondary_no_cache_count = 0;
1901
+
1902
+ $sum = array();
1903
+ $delta = array();
1904
+ $return = array();
1905
+
1906
+ foreach ( $share_base_cache_target as $sns => $active ) {
1907
+ if ( $active ) {
1908
+ $sum[$sns] = 0;
1909
+ $delta[$sns] = 0;
1910
+ }
1911
+ }
1912
+
1913
+ $query_args = array(
1914
+ 'post_type' => $this->share_base_cache_post_types,
1915
+ 'post_status' => 'publish',
1916
+ 'nopaging' => true,
1917
+ 'update_post_term_cache' => false,
1918
+ 'update_post_meta_cache' => false
1919
+ );
1920
+
1921
+ set_time_limit( $this->extended_max_execution_time );
1922
+
1923
+ //home
1924
+ ++$posts_count;
1925
+
1926
+ $full_cache_flag = true;
1927
+ $partial_cache_flag = false;
1928
+
1929
+ $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( 'home' );
1930
+
1931
+ if ( false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
1932
+
1933
+ foreach ( $share_base_cache_target as $sns => $active ) {
1934
+ if ( $active ) {
1935
+ if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
1936
+ $sum[$sns] = $sum[$sns] + $sns_counts[$sns];
1937
+ $partial_cache_flag = true;
1938
+ } else {
1939
+ $full_cache_flag = false;
1940
+ }
1941
+ }
1942
+ }
1943
+
1944
+ if ( $partial_cache_flag && $full_cache_flag ) {
1945
+ ++$primary_full_cache_count;
1946
+ } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
1947
+ ++$primary_partial_cache_count;
1948
+ } else {
1949
+ ++$primary_no_cache_count;
1950
+ }
1951
+
1952
+ $full_cache_flag = true;
1953
+ $partial_cache_flag = false;
1954
+
1955
+ $option_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( 'home' );
1956
+
1957
+ if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
1958
+ foreach ( $share_base_cache_target as $sns => $active ) {
1959
+ if ( $active ) {
1960
+ if ( $sns_counts[$sns] >= 0 ) {
1961
+ $partial_cache_flag = true;
1962
+ } else {
1963
+ $full_cache_flag = false;
1964
+ }
1965
+ }
1966
+ }
1967
+ } else {
1968
+ foreach ( $share_base_cache_target as $sns => $active ) {
1969
+ if ( $active ){
1970
+ $full_cache_flag = false;
1971
+ }
1972
+ }
1973
+ }
1974
+
1975
+ if ( $partial_cache_flag && $full_cache_flag ) {
1976
+ ++$secondary_full_cache_count;
1977
+ } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
1978
+ ++$secondary_partial_cache_count;
1979
+ } else {
1980
+ ++$secondary_no_cache_count;
1981
+ }
1982
+
1983
+ } else {
1984
+
1985
+ $option_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( 'home' );
1986
+
1987
+ if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
1988
+ foreach ( $share_base_cache_target as $sns => $active ) {
1989
+ if ( $active ){
1990
+ if ( $sns_counts[$sns] >= 0 ) {
1991
+ $sum[$sns] = $sum[$sns] + $sns_counts[$sns];
1992
+ $partial_cache_flag = true;
1993
+ } else {
1994
+ $full_cache_flag = false;
1995
+ }
1996
+ }
1997
+ }
1998
+ } else {
1999
+ foreach ( $share_base_cache_target as $sns => $active ) {
2000
+ if ( $active ){
2001
+ $full_cache_flag = false;
2002
+ }
2003
+ }
2004
+ }
2005
+
2006
+ if ( $partial_cache_flag && $full_cache_flag ) {
2007
+ ++$secondary_full_cache_count;
2008
+ } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
2009
+ ++$secondary_partial_cache_count;
2010
+ } else {
2011
+ ++$secondary_no_cache_count;
2012
+ }
2013
+
2014
+ ++$primary_no_cache_count;
2015
+ }
2016
+
2017
+ $option_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( 'home' );
2018
+
2019
+ if ( false !== ( $sns_deltas = get_option( $option_key ) ) ) {
2020
+ foreach ( $share_base_cache_target as $sns => $active ) {
2021
+ if ( $active ){
2022
+ if ( isset( $sns_deltas[$sns] ) ) {
2023
+ $delta[$sns] = $delta[$sns] + $sns_deltas[$sns];
2024
+ }
2025
+ }
2026
+ }
2027
+ }
2028
+
2029
+ //page, post
2030
+ $site_query = new WP_Query( $query_args );
2031
+
2032
+ if ( $site_query->have_posts() ) {
2033
+ while ( $site_query->have_posts() ) {
2034
+ $site_query->the_post();
2035
+
2036
+ ++$posts_count;
2037
+
2038
+ $full_cache_flag = true;
2039
+ $partial_cache_flag = false;
2040
+
2041
+ $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( get_the_ID() );
2042
+
2043
+ if ( false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
2044
+
2045
+ foreach ( $share_base_cache_target as $sns => $active ) {
2046
+ if ( $active ) {
2047
+ if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] >= 0 ) {
2048
+ $sum[$sns] = $sum[$sns] + $sns_counts[$sns];
2049
+ $partial_cache_flag = true;
2050
+ } else {
2051
+ $full_cache_flag = false;
2052
+ }
2053
+ }
2054
+ }
2055
+
2056
+ if ( $partial_cache_flag && $full_cache_flag ) {
2057
+ ++$primary_full_cache_count;
2058
+ } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
2059
+ ++$primary_partial_cache_count;
2060
+ } else {
2061
+ ++$primary_no_cache_count;
2062
+ }
2063
+
2064
+ $full_cache_flag = true;
2065
+ $partial_cache_flag = false;
2066
+
2067
+ $sns_counts = array();
2068
+ $sns_deltas = array();
2069
+
2070
+ foreach ( $share_base_cache_target as $sns => $active ) {
2071
+ if ( $active ) {
2072
+ $meta_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( $sns );
2073
+ $sns_counts[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
2074
+
2075
+ if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] !== '' && $sns_counts[$sns] >= 0 ) {
2076
+ $partial_cache_flag = true;
2077
+ } else {
2078
+ $full_cache_flag = false;
2079
+ }
2080
+
2081
+ if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) {
2082
+ //delta
2083
+ $meta_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( $sns );
2084
+
2085
+ $sns_deltas[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
2086
+
2087
+ if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' ) {
2088
+ $delta[$sns] = $delta[$sns] + $sns_deltas[$sns];
2089
+ }
2090
+ }
2091
+ }
2092
+ }
2093
+
2094
+ if ( $partial_cache_flag && $full_cache_flag ) {
2095
+ ++$secondary_full_cache_count;
2096
+ } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
2097
+ ++$secondary_partial_cache_count;
2098
+ } else {
2099
+ ++$secondary_no_cache_count;
2100
+ }
2101
+
2102
+ } else {
2103
+ $sns_deltas = array();
2104
+ $sns_counts = array();
2105
+
2106
+ foreach ( $share_base_cache_target as $sns => $active ) {
2107
+ if ( $active ){
2108
+ $meta_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( $sns );
2109
+
2110
+ $sns_counts[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
2111
+
2112
+ if ( isset( $sns_counts[$sns] ) && $sns_counts[$sns] !== '' && $sns_counts[$sns] >= 0 ) {
2113
+ $sum[$sns] = $sum[$sns] + $sns_counts[$sns];
2114
+ $partial_cache_flag = true;
2115
+ } else {
2116
+ $full_cache_flag = false;
2117
+ }
2118
+
2119
+ if ( $this->share_variation_analysis_mode !== self::OPT_SHARE_VARIATION_ANALYSIS_NONE ) {
2120
+ //delta
2121
+ $meta_key = $this->analytical_engines[self::REF_SHARE_ANALYSIS]->get_delta_key( $sns );
2122
+
2123
+ $sns_deltas[$sns] = get_post_meta( get_the_ID(), $meta_key, true );
2124
+
2125
+ if ( isset( $sns_deltas[$sns] ) && $sns_deltas[$sns] !== '' ) {
2126
+ $delta[$sns] = $delta[$sns] + $sns_deltas[$sns];
2127
+ }
2128
+ }
2129
+ }
2130
+ }
2131
+
2132
+ if ( $partial_cache_flag && $full_cache_flag ) {
2133
+ ++$secondary_full_cache_count;
2134
+ } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
2135
+ ++$secondary_partial_cache_count;
2136
+ } else {
2137
+ ++$secondary_no_cache_count;
2138
+ }
2139
+
2140
+ ++$primary_no_cache_count;
2141
+ }
2142
+ }
2143
+ wp_reset_postdata();
2144
+ }
2145
+
2146
+ set_time_limit( $this->original_max_execution_time );
2147
+
2148
+ foreach ( $share_base_cache_target as $sns => $active ) {
2149
+ if ( $active ) {
2150
+ if ( isset( $sum[$sns] ) ) {
2151
+ if ( $sns === self::REF_SHARE_GPLUS ){
2152
+ $return['share_count']['gplus'] = number_format( (int) $sum[$sns] );
2153
+ $return['share_delta']['gplus'] = number_format( (int) $delta[$sns] );
2154
+ } else {
2155
+ $return['share_count'][strtolower( $sns )] = number_format( (int) $sum[$sns] );
2156
+ $return['share_delta'][strtolower( $sns )] = number_format( (int) $delta[$sns] );
2157
+ }
2158
+ }
2159
+ }
2160
+ }
2161
+
2162
+ $return['share']['post_count'] = $posts_count;
2163
+ $return['share']['primary']['full_cache_count'] = $primary_full_cache_count;
2164
+ $return['share']['primary']['partial_cache_count'] = $primary_partial_cache_count;
2165
+ $return['share']['primary']['no_cache_count'] = $primary_no_cache_count;
2166
+ $return['share']['secondary']['full_cache_count'] = $secondary_full_cache_count;
2167
+ $return['share']['secondary']['partial_cache_count'] = $secondary_partial_cache_count;
2168
+ $return['share']['secondary']['no_cache_count'] = $secondary_no_cache_count;
2169
+
2170
+ if ( $primary_full_cache_count === $posts_count ) {
2171
+ $return['share']['primary']['cache_status'] = __( 'Completed', self::DOMAIN );
2172
+ } elseif ( ( $primary_full_cache_count + $primary_partial_cache_count ) === $posts_count ) {
2173
+ $return['share']['primary']['cache_status'] = __( 'Partially Completed', self::DOMAIN );
2174
+ } else {
2175
+ $return['share']['primary']['cache_status'] = __( 'Ongoing', self::DOMAIN );
2176
+ }
2177
+
2178
+ if ( $secondary_full_cache_count === $posts_count ) {
2179
+ $return['share']['secondary']['cache_status'] = __( 'Completed', self::DOMAIN );
2180
+ } elseif ( ( $secondary_full_cache_count + $secondary_partial_cache_count ) === $posts_count ) {
2181
+ $return['share']['secondary']['cache_status'] = __( 'Partially Completed', self::DOMAIN );
2182
+ } else {
2183
+ $return['share']['secondary']['cache_status'] = __( 'Ongoing', self::DOMAIN );
2184
+ }
2185
+
2186
+ // Follow count
2187
+ $follow_base_cache_target = $this->follow_base_cache_target;
2188
+
2189
+ unset( $follow_base_cache_target[self::REF_CRAWL_DATE] );
2190
+
2191
+ $primary_full_cache_count = 0;
2192
+ $primary_partial_cache_count = 0;
2193
+ $primary_no_cache_count = 0;
2194
+
2195
+ $secondary_full_cache_count = 0;
2196
+ $secondary_partial_cache_count = 0;
2197
+ $secondary_no_cache_count = 0;
2198
+
2199
+ $sum = array();
2200
+ $delta = array();
2201
+
2202
+ foreach ( $follow_base_cache_target as $sns => $active ) {
2203
+ if ( $active ){
2204
+ $sum[$sns] = 0;
2205
+ $delta[$sns] = 0;
2206
+ }
2207
+ }
2208
+
2209
+ $full_cache_flag = true;
2210
+ $partial_cache_flag = false;
2211
+
2212
+ $transient_id = $this->cache_engines[self::REF_FOLLOW_BASE]->get_cache_key( 'follow' );
2213
+
2214
+ if ( false !== ( $sns_followers = get_transient( $transient_id ) ) ) {
2215
+
2216
+ foreach ( $follow_base_cache_target as $sns => $active ) {
2217
+ if ( $active ) {
2218
+ if ( isset( $sns_followers[$sns] ) && $sns_followers[$sns] >= 0 ) {
2219
+ $sum[$sns] = $sum[$sns] + $sns_followers[$sns];
2220
+ $partial_cache_flag = true;
2221
+ } else {
2222
+ $full_cache_flag = false;
2223
+ }
2224
+ }
2225
+ }
2226
+
2227
+ if ( $partial_cache_flag && $full_cache_flag ) {
2228
+ ++$primary_full_cache_count;
2229
+ } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
2230
+ ++$primary_partial_cache_count;
2231
+ } else {
2232
+ ++$primary_no_cache_count;
2233
+ }
2234
+
2235
+ $full_cache_flag = true;
2236
+ $partial_cache_flag = false;
2237
+
2238
+ $option_key = $this->cache_engines[self::REF_FOLLOW_2ND]->get_cache_key( 'follow' );
2239
+
2240
+ if ( false !== ( $sns_followers = get_option( $option_key ) ) ) {
2241
+ foreach ( $follow_base_cache_target as $sns => $active ) {
2242
+ if ( $active ) {
2243
+ if ( isset( $sns_followers[$sns] ) && $sns_followers[$sns] >= 0 ) {
2244
+ $partial_cache_flag = true;
2245
+ } else {
2246
+ $full_cache_flag = false;
2247
+ }
2248
+ }
2249
+ }
2250
+ }
2251
+
2252
+ if ( $partial_cache_flag && $full_cache_flag ) {
2253
+ ++$secondary_full_cache_count;
2254
+ } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
2255
+ ++$secondary_partial_cache_count;
2256
+ } else {
2257
+ ++$secondary_no_cache_count;
2258
+ }
2259
+
2260
+ } else {
2261
+ $option_key = $this->cache_engines[self::REF_FOLLOW_2ND]->get_cache_key( 'follow' );
2262
+
2263
+ if ( false !== ( $sns_followers = get_option( $option_key ) ) ) {
2264
+ foreach ( $follow_base_cache_target as $sns => $active ) {
2265
+ if ( $active ) {
2266
+ if ( isset( $sns_followers[$sns] ) && $sns_followers[$sns] >= 0 ) {
2267
+ $sum[$sns] = $sum[$sns] + $sns_followers[$sns];
2268
+ $partial_cache_flag = true;
2269
+ } else {
2270
+ $full_cache_flag = false;
2271
+ }
2272
+ }
2273
+ }
2274
+ }
2275
+
2276
+ if ( $partial_cache_flag && $full_cache_flag ) {
2277
+ ++$secondary_full_cache_count;
2278
+ } elseif ( $partial_cache_flag && ! $full_cache_flag ) {
2279
+ ++$secondary_partial_cache_count;
2280
+ } else {
2281
+ ++$secondary_no_cache_count;
2282
+ }
2283
+
2284
+ ++$primary_no_cache_count;
2285
+ }
2286
+
2287
+ foreach ( $follow_base_cache_target as $sns => $active ) {
2288
+ if ( $active ) {
2289
+ if ( isset( $sum[$sns] ) ) {
2290
+ if ( $sns === self::REF_SHARE_GPLUS ){
2291
+ $return['follow_count']['gplus'] = number_format( (int) $sum[$sns] );
2292
+ $return['follow_delta']['gplus'] = number_format( (int) $delta[$sns] );
2293
+ } else {
2294
+ $return['follow_count'][strtolower( $sns )] = number_format( (int) $sum[$sns] );
2295
+ $return['follow_delta'][strtolower( $sns )] = number_format( (int) $delta[$sns] );
2296
+ }
2297
+ }
2298
+ }
2299
+ }
2300
+
2301
+ $posts_count = 1;
2302
+ $return['follow']['post_count'] = $posts_count;
2303
+ $return['follow']['primary']['full_cache_count'] = $primary_full_cache_count;
2304
+ $return['follow']['primary']['partial_cache_count'] = $primary_partial_cache_count;
2305
+ $return['follow']['primary']['no_cache_count'] = $primary_no_cache_count;
2306
+ $return['follow']['secondary']['full_cache_count'] = $secondary_full_cache_count;
2307
+ $return['follow']['secondary']['partial_cache_count'] = $secondary_partial_cache_count;
2308
+ $return['follow']['secondary']['no_cache_count'] = $secondary_no_cache_count;
2309
+
2310
+ if ( $primary_full_cache_count === $posts_count ) {
2311
+ $return['follow']['primary']['cache_status'] = __( 'Completed', self::DOMAIN );
2312
+ } elseif ( ( $primary_full_cache_count + $primary_partial_cache_count ) === $posts_count ) {
2313
+ $return['follow']['primary']['cache_status'] = __( 'Partially Completed', self::DOMAIN );
2314
+ } else {
2315
+ $return['follow']['primary']['cache_status'] = __( 'Ongoing', self::DOMAIN );
2316
+ }
2317
+
2318
+ if ( $secondary_full_cache_count === $posts_count ) {
2319
+ $return['follow']['secondary']['cache_status'] = __( 'Completed', self::DOMAIN );
2320
+ } elseif ( ( $secondary_full_cache_count + $secondary_partial_cache_count ) === $posts_count ) {
2321
+ $return['follow']['secondary']['cache_status'] = __( 'Partially Completed', self::DOMAIN );
2322
+ } else {
2323
+ $return['follow']['secondary']['cache_status'] = __( 'Ongoing', self::DOMAIN );
2324
+ }
2325
+
2326
+ Common_Util::log( $return );
2327
+
2328
+ $callback = $_REQUEST["callback"];
2329
+
2330
+ header( 'Content-type: application/javascript; charset=utf-8' );
2331
+
2332
+ echo $callback . '(' . json_encode( $return ) . ')';
2333
+ } else {
2334
+ status_header( '403' );
2335
+ echo 'Forbidden';
2336
+ }
2337
+ } else {
2338
+ status_header( '403' );
2339
+ echo 'Forbidden';
2340
+ }
2341
+
2342
+ die();
2343
+ }
2344
+
2345
+ /**
2346
+ * Return share count
2347
+ *
2348
+ * @since 0.5.1
2349
+ */
2350
+ public function get_share_counts( $post_ID = '', $sns_key = '' ) {
2351
+
2352
+ $sns_counts = array();
2353
+
2354
+ $transient_id = $this->cache_engines[self::REF_SHARE_BASE]->get_cache_key( $post_ID );
2355
+
2356
+ if ( false !== ( $sns_counts = get_transient( $transient_id ) ) ) {
2357
+ if ( $sns_key ) {
2358
+ if ( ! isset( $sns_counts[$sns_key] ) || $sns_counts[$sns_key] < 0 ) {
2359
+ $sns_counts[$sns_key] = 0;
2360
+ }
2361
+ return $sns_counts[$sns_key];
2362
+ } else {
2363
+ foreach ( $this->share_base_cache_target as $sns => $active ) {
2364
+ if ( $active ) {
2365
+ if ( ! isset( $sns_counts[$sns] ) || $sns_counts[$sns] < 0 ) {
2366
+ $sns_counts[$sns] = 0;
2367
+ }
2368
+ }
2369
+ }
2370
+ return $sns_counts;
2371
+ }
2372
+ } else {
2373
+ switch ( $this->dynamic_cache_mode ) {
2374
+ case self::OPT_COMMON_ACCESS_BASED_2ND_CACHE:
2375
+ if ( $sns_key ) {
2376
+ if ( $post_ID !== 'home' ) {
2377
+ $meta_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( $sns_key );
2378
+ $sns_count = get_post_meta( $post_ID, $meta_key, true );
2379
+
2380
+ $second_cache_flag = false;
2381
+
2382
+ if ( isset( $sns_count ) && $sns_count !== '' ) {
2383
+ if ( $sns_count >= 0 ) {
2384
+ $sns_counts[$sns_key] = $sns_count;
2385
+ $second_cache_flag = true;
2386
+ } else {
2387
+ $sns_counts[$sns_key] = 0;
2388
+ }
2389
+ } else {
2390
+ $sns_counts[$sns_key] = 0;
2391
+ }
2392
+
2393
+ if ( $second_cache_flag ) {
2394
+ $this->cache_engines[self::REF_SHARE_RESTORE]->prime_cache( $post_ID );
2395
+ } else {
2396
+ $this->cache_engines[self::REF_SHARE_LAZY]->prime_cache( $post_ID );
2397
+ }
2398
+ } else {
2399
+ $option_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( 'home' );
2400
+
2401
+ $second_cache_flag = false;
2402
+
2403
+ if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
2404
+ if ( ! isset( $sns_counts[$sns_key] ) || $sns_counts[$sns_key] < 0 ) {
2405
+ $sns_counts[$sns_key] = 0;
2406
+ } else {
2407
+ $second_cache_flag = true;
2408
+ }
2409
+ }else {
2410
+ $sns_counts[$sns_key] = 0;
2411
+ }
2412
+
2413
+ if ( $second_cache_flag ) {
2414
+ $this->cache_engines[self::REF_SHARE_RESTORE]->prime_cache( $post_ID );
2415
+ } else {
2416
+ $this->cache_engines[self::REF_SHARE_LAZY]->prime_cache( $post_ID );
2417
+ }
2418
+ }
2419
+
2420
+ return $sns_counts[$sns_key];
2421
+ } else {
2422
+ if ( $post_ID !== 'home' ) {
2423
+
2424
+ $second_cache_flag = false;
2425
+
2426
+ foreach ( $this->share_base_cache_target as $sns => $active ) {
2427
+ if ( $active ) {
2428
+ $meta_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( $sns );
2429
+
2430
+ $sns_count = get_post_meta( $post_ID, $meta_key, true );
2431
+
2432
+ if ( isset( $sns_count ) && $sns_count !== '' ) {
2433
+ if ( $sns_count >= 0 ) {
2434
+ $sns_counts[$sns] = $sns_count;
2435
+ $second_cache_flag = true;
2436
+ } else {
2437
+ $sns_counts[$sns] = 0;
2438
+ }
2439
+ } else {
2440
+ $sns_counts[$sns] = 0;
2441
+ }
2442
+ }
2443
+ }
2444
+
2445
+ if ( $second_cache_flag ) {
2446
+ $this->cache_engines[self::REF_SHARE_RESTORE]->prime_cache( $post_ID );
2447
+ } else {
2448
+ $this->cache_engines[self::REF_SHARE_LAZY]->prime_cache( $post_ID );
2449
+ }
2450
+ } else {
2451
+ $option_key = $this->cache_engines[self::REF_SHARE_2ND]->get_cache_key( 'home' );
2452
+
2453
+ $second_cache_flag = false;
2454
+
2455
+ if ( false !== ( $sns_counts = get_option( $option_key ) ) ) {
2456
+ foreach ( $this->share_base_cache_target as $sns => $active ) {
2457
+ if ( $active ) {
2458
+ if ( ! isset( $sns_counts[$sns] ) || $sns_counts[$sns] < 0 ) {
2459
+ $sns_counts[$sns] = 0;
2460
+ } else {
2461
+ $second_cache_flag = true;
2462
+ }
2463
+ }
2464
+ }
2465
+ } else {
2466
+ foreach ( $this->share_base_cache_target as $sns => $active ) {
2467
+ if ( $active ) {
2468
+ $sns_counts[$sns] = 0;
2469
+ }
2470
+ }
2471
+ }
2472
+
2473
+ if ( $second_cache_flag ) {
2474
+ $this->cache_engines[self::REF_SHARE_RESTORE]->prime_cache( $post_ID );
2475
+ } else {
2476
+ $this->cache_engines[self::REF_SHARE_LAZY]->prime_cache( $post_ID );
2477
+ }
2478
+ }
2479
+ return $sns_counts;
2480
+ }
2481
+ break;
2482
+ case self::OPT_COMMON_ACCESS_BASED_ASYNC_CACHE:
2483
+ $this->cache_engines[self::REF_SHARE_LAZY]->prime_cache( $post_ID );
2484
+
2485
+ if ( $sns_key ) {
2486
+ $sns_counts[$sns_key] = 0;
2487
+ return $sns_counts[$sns_key];
2488
+ } else {
2489
+ foreach ( $this->share_base_cache_target as $sns => $active ) {
2490
+ if ( $active ) {
2491
+ $sns_counts[$sns] = 0;
2492
+ }
2493
+ }
2494
+ return $sns_counts;
2495
+ }
2496
+ break;
2497
+ case self::OPT_COMMON_ACCESS_BASED_SYNC_CACHE:
2498
+ $sns_counts = $this->cache_engines[self::REF_SHARE_BASE]->direct_cache( $post_ID, true );
2499
+
2500
+ if ( $sns_key ) {
2501
+ if ( ! isset( $sns_counts[$sns_key] ) || $sns_counts[$sns_key] < 0 ) {
2502
+ $sns_counts[$sns_key] = 0;
2503
+ }
2504
+ return $sns_counts[$sns_key];
2505
+ } else {
2506
+ foreach ( $this->share_base_cache_target as $sns => $active ) {
2507
+ if ( $active ) {
2508
+ if ( ! isset( $sns_counts[$sns] ) || $sns_counts[$sns] < 0 ) {
2509
+ $sns_counts[$sns] = 0;
2510
+ }
2511
+ }
2512
+ }
2513
+ return $sns_counts;
2514
+ }
2515
+ break;
2516
+ case self::OPT_COMMON_ACCESS_BASED_CACHE_NONE:
2517
+ if ( $sns_key ) {
2518
+ $sns_counts[$sns_key] = 0;
2519
+ return $sns_counts[$sns_key];
2520
+ } else {
2521
+ foreach ( $this->share_base_cache_target as $sns => $active ) {
2522
+ if ( $active ) {
2523
+ $sns_counts[$sns] = 0;
2524
+ }
2525
+ }
2526
+ return $sns_counts;
2527
+ }
2528
+ break;
2529
+ }
2530
+ }
2531
+ }
2532
+
2533
+ /**
2534
+ * Return follow count
2535
+ *
2536
+ * @since 0.5.1
2537
+ */
2538
+ public function get_follow_counts( $sns_key = '' ) {
2539
+ $sns_followers = array();
2540
+
2541
+ $transient_id = $this->cache_engines[self::REF_FOLLOW_BASE]->get_cache_key( 'follow' );
2542
+
2543
+ if ( false !== ( $sns_followers = get_transient( $transient_id ) ) ) {
2544
+ if ( $sns_key ) {
2545
+ if ( ! isset( $sns_followers[$sns_key] ) || $sns_followers[$sns_key] < 0 ) {
2546
+ $sns_followers[$sns_key] = 0;
2547
+ }
2548
+ return $sns_followers[$sn