Version Description
Download this release
Release Info
Developer | cifi |
Plugin | SEO SQUIRRLY™ |
Version | 11.1.11 |
Comparing to | |
See all releases |
Code changes from version 11.1.10 to 11.1.11
- classes/ActionController.php +413 -403
- classes/BlockController.php +132 -87
- classes/DisplayController.php +127 -123
- classes/Error.php +153 -136
- classes/FrontController.php +185 -140
- classes/HookController.php +131 -115
- classes/ObjController.php +176 -164
- classes/RemoteController.php +1572 -1455
- classes/helpers/DevKit.php +327 -302
- classes/helpers/Sanitize.php +605 -553
- classes/helpers/Tools.php +1411 -1360
- config/config.php +90 -82
- config/paths.php +66 -66
- controllers/Account.php +45 -39
- controllers/Api.php +213 -194
- controllers/Assistant.php +157 -151
- controllers/Audits.php +411 -381
- controllers/BulkSeo.php +115 -111
- controllers/CheckSeo.php +392 -381
- controllers/Dashboard.php +46 -43
- controllers/Features.php +34 -32
- controllers/FocusPages.php +459 -430
- controllers/Frontend.php +177 -164
- controllers/Menu.php +535 -483
- controllers/Onboarding.php +104 -95
- controllers/Overview.php +109 -101
- controllers/Patterns.php +168 -158
- controllers/Post.php +658 -635
- controllers/PostsList.php +333 -307
- controllers/Ranking.php +263 -253
- controllers/Research.php +813 -794
- controllers/SeoSettings.php +878 -843
- controllers/Sitemaps.php +780 -727
- controllers/Snippet.php +302 -281
- controllers/Uninstall.php +19 -16
- core/BlockAssistant.php +11 -9
- core/BlockConnect.php +60 -55
- core/BlockFeatures.php +664 -661
- core/BlockJorney.php +52 -48
- core/BlockKnowledgeBase.php +11 -9
- core/BlockSearch.php +39 -36
- core/BlockStats.php +23 -21
- core/BlockSupport.php +66 -63
- core/BlockToolbar.php +12 -10
- core/Blocklogin.php +159 -149
- debug/index.php +0 -156
classes/ActionController.php
CHANGED
@@ -1,403 +1,413 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Set the ajax action and call for wordpress
|
6 |
-
*/
|
7 |
-
class SQ_Classes_ActionController extends SQ_Classes_FrontController
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
*
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
'
|
67 |
-
'
|
68 |
-
|
69 |
-
|
70 |
-
'
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
'
|
78 |
-
'
|
79 |
-
|
80 |
-
|
81 |
-
'
|
82 |
-
),
|
83 |
-
),
|
84 |
-
'active' => '1',
|
85 |
-
),
|
86 |
-
array(
|
87 |
-
'name' => '
|
88 |
-
'description' => '
|
89 |
-
'actions' => array(
|
90 |
-
'action' => array(
|
91 |
-
'
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
'
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
'
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
'
|
113 |
-
'
|
114 |
-
|
115 |
-
|
116 |
-
'
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
'
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
'
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
'
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
'
|
144 |
-
),
|
145 |
-
),
|
146 |
-
'active' => '1',
|
147 |
-
),
|
148 |
-
array(
|
149 |
-
'name' => '
|
150 |
-
'
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
'
|
160 |
-
|
161 |
-
|
162 |
-
'
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
'
|
172 |
-
'
|
173 |
-
'
|
174 |
-
'
|
175 |
-
'
|
176 |
-
'
|
177 |
-
'
|
178 |
-
'
|
179 |
-
'
|
180 |
-
'
|
181 |
-
'
|
182 |
-
'
|
183 |
-
'
|
184 |
-
'
|
185 |
-
'
|
186 |
-
'
|
187 |
-
'
|
188 |
-
'
|
189 |
-
'
|
190 |
-
'
|
191 |
-
'
|
192 |
-
'
|
193 |
-
'
|
194 |
-
'
|
195 |
-
'
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
'
|
205 |
-
'
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
'
|
215 |
-
'
|
216 |
-
'
|
217 |
-
'
|
218 |
-
'
|
219 |
-
'
|
220 |
-
'
|
221 |
-
'
|
222 |
-
'
|
223 |
-
'
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
'
|
233 |
-
'
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
'
|
248 |
-
'
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
'
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
'
|
261 |
-
'
|
262 |
-
),
|
263 |
-
),
|
264 |
-
'active' => '1',
|
265 |
-
),
|
266 |
-
array(
|
267 |
-
'name' => '
|
268 |
-
'actions' => array(
|
269 |
-
'action' => array(
|
270 |
-
'
|
271 |
-
'
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
'
|
286 |
-
'
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
'
|
294 |
-
|
295 |
-
|
296 |
-
'
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
'
|
304 |
-
|
305 |
-
|
306 |
-
'
|
307 |
-
),
|
308 |
-
),
|
309 |
-
'active' => '1',
|
310 |
-
),
|
311 |
-
array(
|
312 |
-
'name' => '
|
313 |
-
'actions' => array(
|
314 |
-
'action' => array(
|
315 |
-
'
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
'
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
}
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Set the ajax action and call for wordpress
|
6 |
+
*/
|
7 |
+
class SQ_Classes_ActionController extends SQ_Classes_FrontController
|
8 |
+
{
|
9 |
+
|
10 |
+
/**
|
11 |
+
*
|
12 |
+
*
|
13 |
+
* @var array with all form and ajax actions
|
14 |
+
*/
|
15 |
+
var $actions = array();
|
16 |
+
|
17 |
+
/**
|
18 |
+
* The hookAjax is loaded as custom hook in hookController class
|
19 |
+
*
|
20 |
+
* @return void
|
21 |
+
*/
|
22 |
+
public function hookInit()
|
23 |
+
{
|
24 |
+
/* Only if ajax */
|
25 |
+
if (SQ_Classes_Helpers_Tools::isAjax()) {
|
26 |
+
$this->getActions();
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* The hookSubmit is loaded when action si posted
|
32 |
+
*
|
33 |
+
* @return void
|
34 |
+
*/
|
35 |
+
public function hookMenu()
|
36 |
+
{
|
37 |
+
/* Only if post */
|
38 |
+
if (!SQ_Classes_Helpers_Tools::isAjax()) {
|
39 |
+
$this->getActions();
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* The hookHead is loaded as admin hook in hookController class for script load
|
45 |
+
* Is needed for security check as nonce
|
46 |
+
*
|
47 |
+
* @return void
|
48 |
+
*/
|
49 |
+
public function hookHead()
|
50 |
+
{
|
51 |
+
echo '<script>var sqQuery = {"adminurl": "' . esc_url(admin_url()) . '","ajaxurl": "' . esc_url(admin_url('admin-ajax.php')) . '","adminposturl": "' . esc_url(admin_url('post.php')) . '","adminlisturl": "' . esc_url(admin_url('edit.php')) . '","nonce": "' . esc_attr(wp_create_nonce(_SQ_NONCE_ID_)) . '"}</script>';
|
52 |
+
}
|
53 |
+
|
54 |
+
public function hookFronthead()
|
55 |
+
{
|
56 |
+
if (SQ_Classes_Helpers_Tools::isFrontAdmin()) {
|
57 |
+
echo '<script>var sqQuery = {"adminurl": "' . esc_url(admin_url()) . '","ajaxurl": "' . esc_url(admin_url('admin-ajax.php')) . '","nonce": "' . esc_attr(wp_create_nonce(_SQ_NONCE_ID_)). '"}</script>';
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
public function getActionsList()
|
62 |
+
{
|
63 |
+
return array(
|
64 |
+
array(
|
65 |
+
'name' => 'SQ_Core_Blocklogin',
|
66 |
+
'description' => 'Connection Block',
|
67 |
+
'actions' => array(
|
68 |
+
'action' => array(
|
69 |
+
'sq_login',
|
70 |
+
'sq_register',
|
71 |
+
),
|
72 |
+
),
|
73 |
+
'active' => '1',
|
74 |
+
),
|
75 |
+
array(
|
76 |
+
'name' => 'SQ_Core_BlockConnect',
|
77 |
+
'description' => 'Connection Block to API',
|
78 |
+
'actions' => array(
|
79 |
+
'action' => array(
|
80 |
+
'sq_cloud_connect',
|
81 |
+
'sq_cloud_disconnect',
|
82 |
+
),
|
83 |
+
),
|
84 |
+
'active' => '1',
|
85 |
+
),
|
86 |
+
array(
|
87 |
+
'name' => 'SQ_Controllers_Account',
|
88 |
+
'description' => 'Account Class',
|
89 |
+
'actions' => array(
|
90 |
+
'action' => array(
|
91 |
+
'sq_ajax_account_getaccount',
|
92 |
+
),
|
93 |
+
),
|
94 |
+
'active' => '1',
|
95 |
+
),
|
96 |
+
array(
|
97 |
+
'name' => 'SQ_Controllers_FocusPages',
|
98 |
+
'description' => 'Focus Pages Controller',
|
99 |
+
'actions' => array(
|
100 |
+
'action' => array(
|
101 |
+
'sq_focuspages_getpage',
|
102 |
+
'sq_focuspages_addnew',
|
103 |
+
'sq_focuspages_update',
|
104 |
+
'sq_focuspages_delete',
|
105 |
+
'sq_focuspages_inspecturl',
|
106 |
+
),
|
107 |
+
),
|
108 |
+
'active' => '1',
|
109 |
+
),
|
110 |
+
array(
|
111 |
+
'name' => 'SQ_Controllers_PostsList',
|
112 |
+
'description' => 'Posts List Page',
|
113 |
+
'actions' => array(
|
114 |
+
'action' => array(
|
115 |
+
'inline-save',
|
116 |
+
'sq_ajax_postslist',
|
117 |
+
),
|
118 |
+
),
|
119 |
+
'active' => '1',
|
120 |
+
),
|
121 |
+
array(
|
122 |
+
'name' => 'SQ_Controllers_Post',
|
123 |
+
'description' => 'Post Page',
|
124 |
+
'actions' => array(
|
125 |
+
'action' => array(
|
126 |
+
'sq_create_demo',
|
127 |
+
'sq_ajax_save_ogimage',
|
128 |
+
'sq_ajax_get_post',
|
129 |
+
'sq_ajax_save_post',
|
130 |
+
'sq_ajax_type_click',
|
131 |
+
'sq_ajax_search_blog',
|
132 |
+
),
|
133 |
+
),
|
134 |
+
'active' => '1',
|
135 |
+
),
|
136 |
+
array(
|
137 |
+
'name' => 'SQ_Controllers_Snippet',
|
138 |
+
'description' => 'Snippet Page',
|
139 |
+
'actions' => array(
|
140 |
+
'action' => array(
|
141 |
+
'sq_saveseo',
|
142 |
+
'sq_getsnippet',
|
143 |
+
'sq_previewsnippet',
|
144 |
+
),
|
145 |
+
),
|
146 |
+
'active' => '1',
|
147 |
+
),
|
148 |
+
array(
|
149 |
+
'name' => 'SQ_Controllers_Patterns',
|
150 |
+
'description' => 'Patterns Class',
|
151 |
+
'actions' => array(
|
152 |
+
'action' => array(
|
153 |
+
'sq_getpatterns',
|
154 |
+
),
|
155 |
+
),
|
156 |
+
'active' => '1',
|
157 |
+
),
|
158 |
+
array(
|
159 |
+
'name' => 'SQ_Controllers_BulkSeo',
|
160 |
+
'actions' => array(
|
161 |
+
'action' => array(
|
162 |
+
'sq_ajax_assistant_bulkseo',
|
163 |
+
),
|
164 |
+
),
|
165 |
+
'active' => '1',
|
166 |
+
),
|
167 |
+
array(
|
168 |
+
'name' => 'SQ_Controllers_SeoSettings',
|
169 |
+
'actions' => array(
|
170 |
+
'action' => array(
|
171 |
+
'sq_seosettings_automation',
|
172 |
+
'sq_seosettings_bulkseo',
|
173 |
+
'sq_seosettings_jsonld',
|
174 |
+
'sq_seosettings_metas',
|
175 |
+
'sq_seosettings_links',
|
176 |
+
'sq_seosettings_social',
|
177 |
+
'sq_seosettings_tracking',
|
178 |
+
'sq_seosettings_webmaster',
|
179 |
+
'sq_seosettings_sitemap',
|
180 |
+
'sq_seosettings_robots',
|
181 |
+
'sq_seosettings_favicon',
|
182 |
+
'sq_seosettings_backupsettings',
|
183 |
+
'sq_seosettings_backupseo',
|
184 |
+
'sq_seosettings_restoresettings',
|
185 |
+
'sq_seosettings_restoreseo',
|
186 |
+
'sq_seosettings_importsettings',
|
187 |
+
'sq_seosettings_importseo',
|
188 |
+
'sq_seosettings_importall',
|
189 |
+
'sq_seosettings_ga_revoke',
|
190 |
+
'sq_seosettings_gsc_revoke',
|
191 |
+
'sq_seosettings_gsc_check',
|
192 |
+
'sq_seosettings_ga_check',
|
193 |
+
'sq_seosettings_clear_cache',
|
194 |
+
'sq_seosettings_ga_save',
|
195 |
+
'sq_reinstall',
|
196 |
+
'sq_rollback',
|
197 |
+
'sq_alerts_close',
|
198 |
+
'sq_ajax_seosettings_save',
|
199 |
+
'sq_ajax_automation_addpostype',
|
200 |
+
'sq_ajax_automation_deletepostype',
|
201 |
+
'sq_ajax_sla_sticky',
|
202 |
+
'sq_ajax_gsc_code',
|
203 |
+
'sq_ajax_ga_code',
|
204 |
+
'sq_ajax_connection_check',
|
205 |
+
'sq_seosettings_advanced',
|
206 |
+
),
|
207 |
+
),
|
208 |
+
'active' => '1',
|
209 |
+
),
|
210 |
+
array(
|
211 |
+
'name' => 'SQ_Controllers_Research',
|
212 |
+
'actions' => array(
|
213 |
+
'action' => array(
|
214 |
+
'sq_briefcase_addlabel',
|
215 |
+
'sq_briefcase_editlabel',
|
216 |
+
'sq_briefcase_keywordlabel',
|
217 |
+
'sq_briefcase_article',
|
218 |
+
'sq_briefcase_doresearch',
|
219 |
+
'sq_briefcase_addkeyword',
|
220 |
+
'sq_briefcase_deletekeyword',
|
221 |
+
'sq_briefcase_deletelabel',
|
222 |
+
'sq_briefcase_deletefound',
|
223 |
+
'sq_briefcase_savemain',
|
224 |
+
'sq_briefcase_backup',
|
225 |
+
'sq_briefcase_restore',
|
226 |
+
'sq_ajax_briefcase_doserp',
|
227 |
+
'sq_ajax_research_others',
|
228 |
+
'sq_ajax_research_process',
|
229 |
+
'sq_ajax_research_history',
|
230 |
+
'sq_ajax_briefcase_bulk_delete',
|
231 |
+
'sq_ajax_briefcase_bulk_label',
|
232 |
+
'sq_ajax_briefcase_bulk_doserp',
|
233 |
+
'sq_ajax_labels_bulk_delete',
|
234 |
+
),
|
235 |
+
),
|
236 |
+
'active' => '1',
|
237 |
+
),
|
238 |
+
array(
|
239 |
+
'name' => 'SQ_Controllers_Audits',
|
240 |
+
'actions' => array(
|
241 |
+
'action' => array(
|
242 |
+
'sq_audits_settings',
|
243 |
+
'sq_auditpages_getaudit',
|
244 |
+
'sq_audits_getpage',
|
245 |
+
'sq_audits_addnew',
|
246 |
+
'sq_audits_page_update',
|
247 |
+
'sq_audits_update',
|
248 |
+
'sq_audits_delete',
|
249 |
+
),
|
250 |
+
),
|
251 |
+
'active' => '1',
|
252 |
+
),
|
253 |
+
array(
|
254 |
+
'name' => 'SQ_Controllers_Ranking',
|
255 |
+
'actions' => array(
|
256 |
+
'action' => array(
|
257 |
+
'sq_ranking_settings',
|
258 |
+
'sq_serp_refresh_post',
|
259 |
+
'sq_serp_delete_keyword',
|
260 |
+
'sq_ajax_rank_bulk_delete',
|
261 |
+
'sq_ajax_rank_bulk_refresh',
|
262 |
+
),
|
263 |
+
),
|
264 |
+
'active' => '1',
|
265 |
+
),
|
266 |
+
array(
|
267 |
+
'name' => 'SQ_Controllers_Assistant',
|
268 |
+
'actions' => array(
|
269 |
+
'action' => array(
|
270 |
+
'sq_settings_assistant',
|
271 |
+
'sq_ajax_assistant',
|
272 |
+
),
|
273 |
+
),
|
274 |
+
'active' => '1',
|
275 |
+
),
|
276 |
+
array(
|
277 |
+
'name' => 'SQ_Controllers_CheckSeo',
|
278 |
+
'actions' => array(
|
279 |
+
'action' => array(
|
280 |
+
'sq_checkseo',
|
281 |
+
'sq_fixsettings',
|
282 |
+
'sq_donetask',
|
283 |
+
'sq_resetignored',
|
284 |
+
'sq_moretasks',
|
285 |
+
'sq_ajax_checkseo',
|
286 |
+
'sq_ajax_getgoals',
|
287 |
+
),
|
288 |
+
),
|
289 |
+
'active' => '1',
|
290 |
+
),
|
291 |
+
array(
|
292 |
+
'name' => 'SQ_Controllers_Onboarding',
|
293 |
+
'actions' => array(
|
294 |
+
'action' => array(
|
295 |
+
'sq_onboarding_commitment',
|
296 |
+
'sq_onboading_checksite',
|
297 |
+
'sq_onboarding_settings',
|
298 |
+
),
|
299 |
+
),
|
300 |
+
'active' => '1',
|
301 |
+
),
|
302 |
+
array(
|
303 |
+
'name' => 'SQ_Core_BlockJorney',
|
304 |
+
'actions' => array(
|
305 |
+
'action' => array(
|
306 |
+
'sq_journey_close',
|
307 |
+
),
|
308 |
+
),
|
309 |
+
'active' => '1',
|
310 |
+
),
|
311 |
+
array(
|
312 |
+
'name' => 'SQ_Core_BlockSupport',
|
313 |
+
'actions' => array(
|
314 |
+
'action' => array(
|
315 |
+
'sq_feedback',
|
316 |
+
'sq_uninstall_feedback',
|
317 |
+
),
|
318 |
+
),
|
319 |
+
'active' => '1',
|
320 |
+
),
|
321 |
+
array(
|
322 |
+
'name' => 'SQ_Core_BlockSearch',
|
323 |
+
'actions' => array(
|
324 |
+
'action' => array(
|
325 |
+
'sq_ajax_search',
|
326 |
+
),
|
327 |
+
),
|
328 |
+
'active' => '1',
|
329 |
+
),
|
330 |
+
array(
|
331 |
+
'name' => 'SQ_Controllers_Dashboard',
|
332 |
+
'actions' => array(
|
333 |
+
'action' => array(
|
334 |
+
'sq_ajaxcheckseo',
|
335 |
+
),
|
336 |
+
),
|
337 |
+
'active' => '1',
|
338 |
+
),
|
339 |
+
);
|
340 |
+
}
|
341 |
+
|
342 |
+
/**
|
343 |
+
* Get all actions from config.json in core directory and add them in the WP
|
344 |
+
*/
|
345 |
+
public function getActions()
|
346 |
+
{
|
347 |
+
|
348 |
+
if (!is_admin()) {
|
349 |
+
return;
|
350 |
+
}
|
351 |
+
|
352 |
+
$this->actions = array();
|
353 |
+
$cur_action = SQ_Classes_Helpers_Tools::getValue('action', false);
|
354 |
+
$http_referer = SQ_Classes_Helpers_Tools::getValue('_wp_http_referer', false);
|
355 |
+
$sq_nonce = SQ_Classes_Helpers_Tools::getValue('sq_nonce', false);
|
356 |
+
|
357 |
+
//Let only the logged users to access the actions
|
358 |
+
if ($cur_action <> '' && $sq_nonce <> '') {
|
359 |
+
|
360 |
+
//load the actions list for each class
|
361 |
+
$actions = $this->getActionsList();
|
362 |
+
|
363 |
+
if(!empty($actions)) {
|
364 |
+
foreach ($actions as $block) {
|
365 |
+
if (isset($block['active']) && $block['active'] == 1) {
|
366 |
+
/* if there is a single action */
|
367 |
+
if (isset($block['actions']['action']))
|
368 |
+
/* if there are more actions for the current block */
|
369 |
+
if (!is_array($block['actions']['action'])) {
|
370 |
+
/* add the action in the actions array */
|
371 |
+
if ($block['actions']['action'] == $cur_action) {
|
372 |
+
$this->actions[] = array('class' => $block['name']);
|
373 |
+
}
|
374 |
+
} else {
|
375 |
+
/* if there are more actions for the current block */
|
376 |
+
foreach ($block['actions']['action'] as $action) {
|
377 |
+
/* add the actions in the actions array */
|
378 |
+
if ($action == $cur_action) {
|
379 |
+
$this->actions[] = array('class' => $block['name']);
|
380 |
+
}
|
381 |
+
}
|
382 |
+
}
|
383 |
+
}
|
384 |
+
}
|
385 |
+
}
|
386 |
+
|
387 |
+
//If there is an action found in the config.js file
|
388 |
+
if (!empty($this->actions)) {
|
389 |
+
/* add the actions in WP */
|
390 |
+
foreach ($this->actions as $actions) {
|
391 |
+
if (SQ_Classes_Helpers_Tools::isAjax() && !$http_referer) {
|
392 |
+
check_ajax_referer(_SQ_NONCE_ID_, 'sq_nonce');
|
393 |
+
add_action('wp_ajax_' . $cur_action, array(SQ_Classes_ObjController::getClass($actions['class']), 'action'));
|
394 |
+
} else {
|
395 |
+
check_admin_referer($cur_action, 'sq_nonce');
|
396 |
+
|
397 |
+
SQ_Classes_ObjController::getClass($actions['class'])->action();
|
398 |
+
}
|
399 |
+
}
|
400 |
+
}
|
401 |
+
}
|
402 |
+
|
403 |
+
//For Post List
|
404 |
+
if(SQ_Classes_Helpers_Tools::isAjax() && $cur_action <> '' && $cur_action == 'inline-save') {
|
405 |
+
check_ajax_referer('inlineeditnonce', '_inline_edit');
|
406 |
+
SQ_Classes_ObjController::getClass('SQ_Controllers_PostsList')->action();
|
407 |
+
|
408 |
+
}
|
409 |
+
|
410 |
+
|
411 |
+
}
|
412 |
+
|
413 |
+
}
|
classes/BlockController.php
CHANGED
@@ -1,87 +1,132 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
/**
|
5 |
-
* The main class for core blocks
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
/**
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
public
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
*
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
/*
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
if (
|
46 |
-
|
47 |
-
}
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
*
|
76 |
-
*
|
77 |
-
*/
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
/**
|
5 |
+
* The main class for core blocks
|
6 |
+
*/
|
7 |
+
class SQ_Classes_BlockController
|
8 |
+
{
|
9 |
+
|
10 |
+
/**
|
11 |
+
*
|
12 |
+
*
|
13 |
+
* @var object of the model class
|
14 |
+
*/
|
15 |
+
protected $model;
|
16 |
+
|
17 |
+
/**
|
18 |
+
*
|
19 |
+
*
|
20 |
+
* @var boolean
|
21 |
+
*/
|
22 |
+
public $flush = true;
|
23 |
+
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
*
|
27 |
+
* @var object of the view class
|
28 |
+
*/
|
29 |
+
protected $view;
|
30 |
+
|
31 |
+
/**
|
32 |
+
*
|
33 |
+
*
|
34 |
+
* @var string name of the class
|
35 |
+
*/
|
36 |
+
private $name;
|
37 |
+
|
38 |
+
public function __construct()
|
39 |
+
{
|
40 |
+
/* get the name of the current class */
|
41 |
+
$this->name = get_class($this);
|
42 |
+
|
43 |
+
/* create the model and view instances */
|
44 |
+
$model_classname = str_replace('Core', 'Models', $this->name);
|
45 |
+
if (SQ_Classes_ObjController::getClassPath($model_classname)) {
|
46 |
+
$this->model = SQ_Classes_ObjController::getClass($model_classname);
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* load sequence of classes
|
52 |
+
* Function called usualy when the controller is loaded in WP
|
53 |
+
*
|
54 |
+
* @return mixed
|
55 |
+
*/
|
56 |
+
public function init()
|
57 |
+
{
|
58 |
+
/* check if there is a hook defined in the block class */
|
59 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_HookController')->setBlockHooks($this);
|
60 |
+
//get the class path
|
61 |
+
$class = SQ_Classes_ObjController::getClassPath($this->name);
|
62 |
+
|
63 |
+
if (!$this->flush) {
|
64 |
+
return $this->get_view($class['name']);
|
65 |
+
}
|
66 |
+
|
67 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia($class['name']);
|
68 |
+
$this->show_view($class['name']);
|
69 |
+
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Get the block view
|
74 |
+
*
|
75 |
+
* @param string $view Class name
|
76 |
+
* @return string The file from /view directory
|
77 |
+
*/
|
78 |
+
public function get_view($view)
|
79 |
+
{
|
80 |
+
return SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->get_view($view, $this);
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Show the view block
|
85 |
+
*
|
86 |
+
* @param string $view Class name
|
87 |
+
* @return string the included view file from /view directory
|
88 |
+
*/
|
89 |
+
public function show_view($view)
|
90 |
+
{
|
91 |
+
$content = SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->get_view($view, $this);
|
92 |
+
|
93 |
+
//Support for international languages
|
94 |
+
if (function_exists('iconv') && SQ_Classes_Helpers_Tools::getOption('sq_non_utf8_support')) {
|
95 |
+
if (strpos(get_bloginfo("language"), 'en') === false) {
|
96 |
+
$content = iconv('UTF-8', 'UTF-8//IGNORE', $content);
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
//echo the file from /view directory
|
101 |
+
//already escaped in the view
|
102 |
+
//Contains HTML output
|
103 |
+
echo $content;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Called as menu callback to show the block
|
108 |
+
*/
|
109 |
+
public function show()
|
110 |
+
{
|
111 |
+
$this->flush = true;
|
112 |
+
|
113 |
+
echo $this->init();
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* This function is called from Ajax class as a wp_ajax_action
|
118 |
+
*/
|
119 |
+
protected function action()
|
120 |
+
{
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* This function will load the media in the header for each class
|
125 |
+
*
|
126 |
+
* @return void
|
127 |
+
*/
|
128 |
+
protected function hookHead()
|
129 |
+
{
|
130 |
+
}
|
131 |
+
|
132 |
+
}
|
classes/DisplayController.php
CHANGED
@@ -1,123 +1,127 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
/**
|
5 |
-
* The class handles the theme part in WP
|
6 |
-
*/
|
7 |
-
class SQ_Classes_DisplayController
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* @param string $
|
16 |
-
*
|
17 |
-
*
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
$
|
65 |
-
}
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
*
|
103 |
-
*
|
104 |
-
* @
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
/**
|
5 |
+
* The class handles the theme part in WP
|
6 |
+
*/
|
7 |
+
class SQ_Classes_DisplayController
|
8 |
+
{
|
9 |
+
|
10 |
+
private static $cache;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* echo the css link from theme css directory
|
14 |
+
*
|
15 |
+
* @param string $uri The name of the css file or the entire uri path of the css file
|
16 |
+
* @param string $params : trigger, media
|
17 |
+
*
|
18 |
+
* @return void
|
19 |
+
*/
|
20 |
+
public static function loadMedia($uri = '', $params = array())
|
21 |
+
{
|
22 |
+
if (SQ_Classes_Helpers_Tools::isAjax()) {
|
23 |
+
return;
|
24 |
+
}
|
25 |
+
|
26 |
+
if (empty($params)) {
|
27 |
+
$params = array(
|
28 |
+
'trigger' => false,
|
29 |
+
'media' => 'all'
|
30 |
+
);
|
31 |
+
}
|
32 |
+
|
33 |
+
$css_uri = '';
|
34 |
+
$js_uri = '';
|
35 |
+
|
36 |
+
if (isset(self::$cache[$uri]))
|
37 |
+
return;
|
38 |
+
|
39 |
+
self::$cache[$uri] = true;
|
40 |
+
|
41 |
+
/* if is a custom css file */
|
42 |
+
if (strpos($uri, '//') === false) {
|
43 |
+
$name = substr(md5($uri), 0, 10);
|
44 |
+
|
45 |
+
if (strpos($uri, '.css') !== false && file_exists(_SQ_ASSETS_DIR_ . 'css/' . strtolower($uri))) {
|
46 |
+
$css_uri = _SQ_ASSETS_URL_ . 'css/' . strtolower($uri);
|
47 |
+
}
|
48 |
+
if (file_exists(_SQ_ASSETS_DIR_ . 'css/' . strtolower($uri) . (SQ_DEBUG ? '' : '.min') . '.css')) {
|
49 |
+
$css_uri = _SQ_ASSETS_URL_ . 'css/' . strtolower($uri) . (SQ_DEBUG ? '' : '.min') . '.css';
|
50 |
+
}
|
51 |
+
|
52 |
+
if (strpos($uri, '.js') !== false && file_exists(_SQ_ASSETS_DIR_ . 'js/' . strtolower($uri))) {
|
53 |
+
$js_uri = _SQ_ASSETS_URL_ . 'js/' . strtolower($uri);
|
54 |
+
}
|
55 |
+
if (file_exists(_SQ_ASSETS_DIR_ . 'js/' . strtolower($uri) . (SQ_DEBUG ? '' : '.min') . '.js')) {
|
56 |
+
$js_uri = _SQ_ASSETS_URL_ . 'js/' . strtolower($uri) . (SQ_DEBUG ? '' : '.min') . '.js';
|
57 |
+
}
|
58 |
+
|
59 |
+
} else {
|
60 |
+
|
61 |
+
$name = substr(md5($uri), 0, 10);
|
62 |
+
|
63 |
+
if (strpos($uri, '.css') !== false) {
|
64 |
+
$css_uri = $uri;
|
65 |
+
} elseif (strpos($uri, '.js') !== false) {
|
66 |
+
$js_uri = $uri;
|
67 |
+
}
|
68 |
+
|
69 |
+
}
|
70 |
+
|
71 |
+
|
72 |
+
if ($css_uri <> '') {
|
73 |
+
if (!wp_style_is($name)) {
|
74 |
+
wp_enqueue_style($name, $css_uri, null, SQ_VERSION, $params['media']);
|
75 |
+
|
76 |
+
if (is_admin() || (isset($params['trigger']) && $params['trigger'] === true)) { //load CSS for admin or on triggered
|
77 |
+
wp_print_styles(array($name));
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
}
|
82 |
+
|
83 |
+
if ($js_uri <> '') {
|
84 |
+
if (!wp_script_is($name)) {
|
85 |
+
|
86 |
+
if (!wp_script_is('jquery')) {
|
87 |
+
wp_enqueue_script('jquery');
|
88 |
+
wp_print_scripts(array('jquery'));
|
89 |
+
}
|
90 |
+
|
91 |
+
wp_enqueue_script($name, $js_uri, null, SQ_VERSION);
|
92 |
+
|
93 |
+
if (is_admin() || isset($params['trigger']) && $params['trigger'] === true) {
|
94 |
+
wp_print_scripts(array($name));
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* return the block content from theme directory
|
103 |
+
*
|
104 |
+
* @param $block
|
105 |
+
* @param $view
|
106 |
+
* @return bool|string
|
107 |
+
*/
|
108 |
+
public function get_view($block, $view)
|
109 |
+
{
|
110 |
+
|
111 |
+
try {
|
112 |
+
$file = apply_filters('sq_view', _SQ_THEME_DIR_ . $block . '.php', $block);
|
113 |
+
|
114 |
+
if (file_exists($file)) {
|
115 |
+
ob_start();
|
116 |
+
include $file;
|
117 |
+
return ob_get_clean();
|
118 |
+
}
|
119 |
+
|
120 |
+
} catch (Exception $e) {
|
121 |
+
}
|
122 |
+
|
123 |
+
return false;
|
124 |
+
}
|
125 |
+
|
126 |
+
|
127 |
+
}
|
classes/Error.php
CHANGED
@@ -1,136 +1,153 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Classes_Error extends SQ_Classes_FrontController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
*
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
*
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
*
|
122 |
-
*
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Classes_Error extends SQ_Classes_FrontController
|
5 |
+
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
*
|
9 |
+
*
|
10 |
+
* @var array
|
11 |
+
*/
|
12 |
+
private static $errors = array();
|
13 |
+
private static $switch_off = array();
|
14 |
+
|
15 |
+
public function __construct()
|
16 |
+
{
|
17 |
+
parent::__construct();
|
18 |
+
|
19 |
+
add_action('sq_notices', array('SQ_Classes_Error', 'hookNotices'));
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Get the error message
|
24 |
+
*
|
25 |
+
* @return int
|
26 |
+
*/
|
27 |
+
public static function getError()
|
28 |
+
{
|
29 |
+
if (count(self::$errors) > 0) {
|
30 |
+
return self::$errors[0]['text'];
|
31 |
+
}
|
32 |
+
|
33 |
+
return false;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Clear all the Errors from Squirrly SEO
|
38 |
+
*/
|
39 |
+
public static function clearErrors()
|
40 |
+
{
|
41 |
+
self::$errors = array();
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Show the error in wrodpress
|
46 |
+
*
|
47 |
+
* @param string $error
|
48 |
+
* @param string $type
|
49 |
+
* @param string $id
|
50 |
+
*/
|
51 |
+
public static function setError($error = '', $type = 'notice', $id = '')
|
52 |
+
{
|
53 |
+
self::$errors[] = array(
|
54 |
+
'id' => $id,
|
55 |
+
'type' => $type,
|
56 |
+
'text' => $error);
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Check if there is a Squirrly Error triggered
|
61 |
+
*
|
62 |
+
* @return bool
|
63 |
+
*/
|
64 |
+
public static function isError()
|
65 |
+
{
|
66 |
+
if(!empty(self::$errors)) {
|
67 |
+
foreach (self::$errors as $error){
|
68 |
+
if($error['type'] <> 'success' ) {
|
69 |
+
return true;
|
70 |
+
}
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Set a success message
|
77 |
+
*
|
78 |
+
* @param string $message
|
79 |
+
* @param string $id
|
80 |
+
*/
|
81 |
+
public static function setMessage($message = '', $id = '')
|
82 |
+
{
|
83 |
+
self::$errors[] = array(
|
84 |
+
'id' => $id,
|
85 |
+
'type' => 'success',
|
86 |
+
'text' => $message);
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* This hook will show the error in WP header
|
91 |
+
*/
|
92 |
+
public static function hookNotices()
|
93 |
+
{
|
94 |
+
if (is_array(self::$errors))
|
95 |
+
foreach (self::$errors as $error) {
|
96 |
+
|
97 |
+
switch ($error['type']) {
|
98 |
+
case 'fatal':
|
99 |
+
self::showError(ucfirst(_SQ_PLUGIN_NAME_ . " " . $error['type']) . ': ' . $error['text'], $error['id']);
|
100 |
+
die();
|
101 |
+
break;
|
102 |
+
case 'settings':
|
103 |
+
/* switch off option for notifications */
|
104 |
+
self::showError($error['text'] . " ", $error['id']);
|
105 |
+
break;
|
106 |
+
|
107 |
+
case 'success':
|
108 |
+
self::showError($error['text'] . " ", $error['id'], 'sq_success');
|
109 |
+
break;
|
110 |
+
|
111 |
+
default:
|
112 |
+
self::showError($error['text'], $error['id']);
|
113 |
+
}
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Show the notices to WP
|
119 |
+
*
|
120 |
+
* @param $message
|
121 |
+
* @param string $type
|
122 |
+
* @return string
|
123 |
+
*/
|
124 |
+
public static function showNotices($message, $type = 'sq_notices')
|
125 |
+
{
|
126 |
+
if (file_exists(_SQ_THEME_DIR_ . 'Notices.php')) {
|
127 |
+
ob_start();
|
128 |
+
include _SQ_THEME_DIR_ . 'Notices.php';
|
129 |
+
$message = ob_get_contents();
|
130 |
+
ob_end_clean();
|
131 |
+
}
|
132 |
+
|
133 |
+
return (string)$message;
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Show the notices to WP
|
138 |
+
*
|
139 |
+
* @param $message
|
140 |
+
* @param string $id
|
141 |
+
* @param string $type
|
142 |
+
*
|
143 |
+
* return void
|
144 |
+
*/
|
145 |
+
public static function showError($message, $id = '', $type = 'sq_error')
|
146 |
+
{
|
147 |
+
if (file_exists(_SQ_THEME_DIR_ . 'Notices.php')) {
|
148 |
+
include _SQ_THEME_DIR_ . 'Notices.php';
|
149 |
+
}
|
150 |
+
}
|
151 |
+
|
152 |
+
|
153 |
+
}
|
classes/FrontController.php
CHANGED
@@ -1,140 +1,185 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
/**
|
5 |
-
* The main class for controllers
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
/**
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
//
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
SQ_Classes_ObjController::
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
*
|
130 |
-
*
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
/**
|
5 |
+
* The main class for controllers
|
6 |
+
*/
|
7 |
+
class SQ_Classes_FrontController
|
8 |
+
{
|
9 |
+
|
10 |
+
/**
|
11 |
+
*
|
12 |
+
*
|
13 |
+
* @var object of the model class
|
14 |
+
*/
|
15 |
+
public $model;
|
16 |
+
|
17 |
+
/**
|
18 |
+
*
|
19 |
+
*
|
20 |
+
* @var boolean
|
21 |
+
*/
|
22 |
+
public $flush = true;
|
23 |
+
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
*
|
27 |
+
* @var name of the class
|
28 |
+
*/
|
29 |
+
private $name;
|
30 |
+
|
31 |
+
public function __construct()
|
32 |
+
{
|
33 |
+
// Load error class
|
34 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_Error');
|
35 |
+
|
36 |
+
/* get the name of the current class */
|
37 |
+
$this->name = get_class($this);
|
38 |
+
|
39 |
+
/* load the model and hooks here for wordpress actions to take efect */
|
40 |
+
/* create the model and view instances */
|
41 |
+
$model_classname = str_replace('Controllers', 'Models', $this->name);
|
42 |
+
if (SQ_Classes_ObjController::getClassPath($model_classname)) {
|
43 |
+
$this->model = SQ_Classes_ObjController::getClass($model_classname);
|
44 |
+
}
|
45 |
+
|
46 |
+
//IMPORTANT TO LOAD HOOKS HERE
|
47 |
+
/* check if there is a hook defined in the controller clients class */
|
48 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_HookController')->setHooks($this);
|
49 |
+
|
50 |
+
/* Load the Submit Actions Handler */
|
51 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_ActionController');
|
52 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController');
|
53 |
+
|
54 |
+
// load the abstract classes
|
55 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Abstract_Domain');
|
56 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Abstract_Models');
|
57 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Abstract_Seo');
|
58 |
+
}
|
59 |
+
|
60 |
+
public function getClass()
|
61 |
+
{
|
62 |
+
return $this->name;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* load sequence of classes
|
67 |
+
* Function called usualy when the controller is loaded in WP
|
68 |
+
*
|
69 |
+
* @return mixed
|
70 |
+
*/
|
71 |
+
public function init()
|
72 |
+
{
|
73 |
+
$class = SQ_Classes_ObjController::getClassPath($this->name);
|
74 |
+
|
75 |
+
if (!$this->flush) {
|
76 |
+
return $this->get_view($class['name']);
|
77 |
+
}
|
78 |
+
|
79 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia($class['name']);
|
80 |
+
$this->show_view($class['name']);
|
81 |
+
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Get the view block
|
86 |
+
*
|
87 |
+
* @param string $view Class name
|
88 |
+
* @return mixed
|
89 |
+
*/
|
90 |
+
public function get_view($view)
|
91 |
+
{
|
92 |
+
return SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->get_view($view, $this);
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Show the view block
|
97 |
+
*
|
98 |
+
* @param string $view Class name
|
99 |
+
* @return string the included view file from /view directory
|
100 |
+
*/
|
101 |
+
public function show_view($view)
|
102 |
+
{
|
103 |
+
$content = SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->get_view($view, $this);
|
104 |
+
|
105 |
+
//Support for international languages
|
106 |
+
if (function_exists('iconv') && SQ_Classes_Helpers_Tools::getOption('sq_non_utf8_support')) {
|
107 |
+
if (strpos(get_bloginfo("language"), 'en') === false) {
|
108 |
+
$content = iconv('UTF-8', 'UTF-8//IGNORE', $content);
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
//echo the file from /view directory
|
113 |
+
//already escaped in the view
|
114 |
+
//Contains HTML output
|
115 |
+
echo $content;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Called as menu callback to show the block
|
120 |
+
*/
|
121 |
+
public function show()
|
122 |
+
{
|
123 |
+
$this->flush = true;
|
124 |
+
|
125 |
+
echo $this->init();
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* initialize settings
|
130 |
+
* Called from index
|
131 |
+
*
|
132 |
+
* @return void
|
133 |
+
*/
|
134 |
+
public function runAdmin()
|
135 |
+
{
|
136 |
+
// load the remote controller in admin
|
137 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_RemoteController');
|
138 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Abstract_Assistant');
|
139 |
+
|
140 |
+
// show the admin menu and post actions
|
141 |
+
SQ_Classes_ObjController::getClass('SQ_Controllers_Menu');
|
142 |
+
SQ_Classes_ObjController::getClass('SQ_Models_RoleManager');
|
143 |
+
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Run fron frontend
|
148 |
+
*/
|
149 |
+
public function runFrontend()
|
150 |
+
{
|
151 |
+
//Load Frontend only if Squirrly SEO is enabled
|
152 |
+
SQ_Classes_ObjController::getClass('SQ_Controllers_Frontend');
|
153 |
+
|
154 |
+
/* show the topbar admin menu and post actions */
|
155 |
+
SQ_Classes_ObjController::getClass('SQ_Controllers_Snippet');
|
156 |
+
|
157 |
+
/* call the API for save posts */
|
158 |
+
SQ_Classes_ObjController::getClass('SQ_Controllers_Api');
|
159 |
+
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* first function call for any class
|
164 |
+
*/
|
165 |
+
protected function action()
|
166 |
+
{
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* This function will load the media in the header for each class
|
171 |
+
*
|
172 |
+
* @return void
|
173 |
+
*/
|
174 |
+
public function hookHead()
|
175 |
+
{
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Show the notification bar
|
180 |
+
*/
|
181 |
+
public function getNotificationBar()
|
182 |
+
{
|
183 |
+
$this->show_view('Blocks/VersionBar');
|
184 |
+
}
|
185 |
+
}
|
classes/HookController.php
CHANGED
@@ -1,115 +1,131 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
/**
|
5 |
-
* The class handles the actions in WP
|
6 |
-
*/
|
7 |
-
class SQ_Classes_HookController
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
'
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
*
|
100 |
-
* @param
|
101 |
-
*
|
102 |
-
*
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
/**
|
5 |
+
* The class handles the actions in WP
|
6 |
+
*/
|
7 |
+
class SQ_Classes_HookController
|
8 |
+
{
|
9 |
+
|
10 |
+
/**
|
11 |
+
*
|
12 |
+
*
|
13 |
+
* @var array the WP actions list from admin
|
14 |
+
*/
|
15 |
+
private $admin_hooks = array();
|
16 |
+
private $front_hooks = array();
|
17 |
+
private $block_hooks = array();
|
18 |
+
|
19 |
+
public function __construct()
|
20 |
+
{
|
21 |
+
$this->admin_hooks = array(
|
22 |
+
'init' => 'admin_init',
|
23 |
+
'head' => 'admin_head',
|
24 |
+
'footer' => 'admin_footer',
|
25 |
+
'menu' => 'admin_menu',
|
26 |
+
'networkMenu' => 'network_admin_menu',
|
27 |
+
'notices' => 'admin_notices',
|
28 |
+
);
|
29 |
+
|
30 |
+
//called in frontend
|
31 |
+
$this->front_hooks = array(
|
32 |
+
// --
|
33 |
+
'init' => 'init',
|
34 |
+
'preload' => 'template_redirect',
|
35 |
+
'frontinit' => 'init',
|
36 |
+
'fronthead' => 'wp_head',
|
37 |
+
'frontfooter' => 'wp_footer',
|
38 |
+
);
|
39 |
+
|
40 |
+
$this->block_hooks = array('getContent' => 'getContent');
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Calls the specified action in WP
|
45 |
+
*
|
46 |
+
* @param object $instance The parent class instance
|
47 |
+
*
|
48 |
+
* @return void
|
49 |
+
*/
|
50 |
+
public function setHooks($instance)
|
51 |
+
{
|
52 |
+
if (is_admin() || is_network_admin()) {
|
53 |
+
$this->setAdminHooks($instance);
|
54 |
+
} else {
|
55 |
+
$this->setFrontHooks($instance);
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Calls the specified action in WP
|
61 |
+
*
|
62 |
+
* @param object $instance The parent class instance
|
63 |
+
*
|
64 |
+
* @return void
|
65 |
+
*/
|
66 |
+
public function setAdminHooks($instance)
|
67 |
+
{
|
68 |
+
|
69 |
+
/* for each admin action check if is defined in class and call it */
|
70 |
+
foreach ($this->admin_hooks as $hook => $value) {
|
71 |
+
|
72 |
+
if (is_callable(array($instance, 'hook' . ucfirst($hook)))) {
|
73 |
+
//call the WP add_action function
|
74 |
+
add_action($value, array($instance, 'hook' . ucfirst($hook)), 5);
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Calls the specified action in WP
|
81 |
+
*
|
82 |
+
* @param object $instance The parent class instance
|
83 |
+
*
|
84 |
+
* @return void
|
85 |
+
*/
|
86 |
+
public function setFrontHooks($instance)
|
87 |
+
{
|
88 |
+
/* for each admin action check if is defined in class and call it */
|
89 |
+
foreach ($this->front_hooks as $hook => $value) {
|
90 |
+
if (is_callable(array($instance, 'hook' . ucfirst($hook)))) {
|
91 |
+
//call the WP add_action function
|
92 |
+
add_action($value, array($instance, 'hook' . ucfirst($hook)), 5);
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Calls the specified action in WP
|
99 |
+
*
|
100 |
+
* @param string $action
|
101 |
+
* @param array $callback Contains the class name or object and the callback function
|
102 |
+
*
|
103 |
+
* @return void
|
104 |
+
*/
|
105 |
+
public function setAction($action, $obj, $callback)
|
106 |
+
{
|
107 |
+
|
108 |
+
/* calls the custom action function from WP */
|
109 |
+
add_action($action, array($obj, $callback), 10);
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Calls the specified action in WP
|
114 |
+
*
|
115 |
+
* @param object $instance The parent class instance
|
116 |
+
*
|
117 |
+
* @return void
|
118 |
+
*/
|
119 |
+
public function setBlockHooks($instance)
|
120 |
+
{
|
121 |
+
$param_arr = array();
|
122 |
+
|
123 |
+
/* for each admin action check if is defined in class and call it */
|
124 |
+
foreach ($this->block_hooks as $hook => $value)
|
125 |
+
if (is_callable(array($instance, 'hook' . ucfirst($hook)))) {
|
126 |
+
//call the WP add_action function
|
127 |
+
call_user_func_array(array($instance, 'hook' . ucfirst($hook)), $param_arr);
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
}
|
classes/ObjController.php
CHANGED
@@ -1,164 +1,176 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
/**
|
5 |
-
* The class creates object for plugin classes
|
6 |
-
*/
|
7 |
-
class SQ_Classes_ObjController
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
* @
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
self::$instances[$className] =
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
/**
|
5 |
+
* The class creates object for plugin classes
|
6 |
+
*/
|
7 |
+
class SQ_Classes_ObjController
|
8 |
+
{
|
9 |
+
|
10 |
+
/**
|
11 |
+
*
|
12 |
+
*
|
13 |
+
* @var array of instances
|
14 |
+
*/
|
15 |
+
public static $instances;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @param $className $className
|
19 |
+
* @param array $args
|
20 |
+
* @return object|false
|
21 |
+
*/
|
22 |
+
public static function getClass($className, $args = array())
|
23 |
+
{
|
24 |
+
|
25 |
+
if ($class = self::getClassPath($className)) {
|
26 |
+
if (!isset(self::$instances[$className])) {
|
27 |
+
/* check if class is already defined */
|
28 |
+
if (!class_exists($className) || $className == get_class()) {
|
29 |
+
try {
|
30 |
+
self::includeClass($class['dir'], $class['name']);
|
31 |
+
|
32 |
+
//check if abstract
|
33 |
+
$check = new ReflectionClass($className);
|
34 |
+
$abstract = $check->isAbstract();
|
35 |
+
if (!$abstract) {
|
36 |
+
self::$instances[$className] = new $className();
|
37 |
+
if (!empty($args)) {
|
38 |
+
call_user_func_array(array(self::$instances[$className], '__construct'), $args);
|
39 |
+
}
|
40 |
+
return self::$instances[$className];
|
41 |
+
} else {
|
42 |
+
self::$instances[$className] = true;
|
43 |
+
}
|
44 |
+
} catch (Exception $e) {
|
45 |
+
}
|
46 |
+
}
|
47 |
+
} else
|
48 |
+
return self::$instances[$className];
|
49 |
+
}
|
50 |
+
return false;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Get a new instance of the class
|
55 |
+
*
|
56 |
+
* @param $className
|
57 |
+
* @param array $args
|
58 |
+
* @return bool|mixed
|
59 |
+
*/
|
60 |
+
public static function getNewClass($className, $args = array())
|
61 |
+
{
|
62 |
+
$instance = false;
|
63 |
+
if ($class = self::getClassPath($className)) {
|
64 |
+
/* check if class is already defined */
|
65 |
+
try {
|
66 |
+
if (!class_exists($className) || $className == get_class()) {
|
67 |
+
self::includeClass($class['dir'], $class['name']);
|
68 |
+
}
|
69 |
+
|
70 |
+
//check if abstract
|
71 |
+
$check = new ReflectionClass($className);
|
72 |
+
$abstract = $check->isAbstract();
|
73 |
+
if (!$abstract) {
|
74 |
+
$instance = new $className();
|
75 |
+
|
76 |
+
if (!empty($args)) {
|
77 |
+
call_user_func_array(array($instance, '__construct'), $args);
|
78 |
+
}
|
79 |
+
return $instance;
|
80 |
+
} else {
|
81 |
+
$instance = true;
|
82 |
+
}
|
83 |
+
} catch (Exception $e) {
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
}
|
88 |
+
return $instance;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* @param $classDir
|
93 |
+
* @param $className
|
94 |
+
* @throws Exception
|
95 |
+
*/
|
96 |
+
private static function includeClass($classDir, $className)
|
97 |
+
{
|
98 |
+
$file = $classDir . $className . '.php';
|
99 |
+
try {
|
100 |
+
if (file_exists($file)) {
|
101 |
+
include_once $file;
|
102 |
+
}
|
103 |
+
} catch (Exception $e) {
|
104 |
+
throw new Exception('Controller Error: ' . $e->getMessage());
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* @param $className
|
110 |
+
* @param array $args
|
111 |
+
* @return stdClass
|
112 |
+
*/
|
113 |
+
public static function getDomain($className, $args = array())
|
114 |
+
{
|
115 |
+
try {
|
116 |
+
if ($class = self::getClassPath($className)) {
|
117 |
+
self::includeClass($class['dir'], $class['name']);
|
118 |
+
return new $className($args);
|
119 |
+
}
|
120 |
+
} catch (Exception $e) {
|
121 |
+
|
122 |
+
}
|
123 |
+
|
124 |
+
return new stdClass();
|
125 |
+
}
|
126 |
+
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Check if the class is correctly set
|
130 |
+
*
|
131 |
+
* @param string $className
|
132 |
+
* @return boolean
|
133 |
+
*/
|
134 |
+
private static function checkClassPath($className)
|
135 |
+
{
|
136 |
+
$path = preg_split('/[_]+/', $className);
|
137 |
+
if (is_array($path) && count($path) > 1) {
|
138 |
+
if (in_array(_SQ_NAMESPACE_, $path)) {
|
139 |
+
return true;
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
return false;
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Get the path of the class and name of the class
|
148 |
+
*
|
149 |
+
* @param string $className
|
150 |
+
* @return array | boolean
|
151 |
+
* array(
|
152 |
+
* dir - absolute path of the class
|
153 |
+
* name - the name of the file
|
154 |
+
* }
|
155 |
+
*/
|
156 |
+
public static function getClassPath($className)
|
157 |
+
{
|
158 |
+
$dir = '';
|
159 |
+
|
160 |
+
|
161 |
+
if (self::checkClassPath($className)) {
|
162 |
+
$path = preg_split('/[_]+/', $className);
|
163 |
+
for ($i = 1; $i < sizeof($path) - 1; $i++)
|
164 |
+
$dir .= strtolower($path[$i]) . '/';
|
165 |
+
|
166 |
+
$class = array('dir' => _SQ_ROOT_DIR_ . $dir,
|
167 |
+
'name' => $path[sizeof($path) - 1]);
|
168 |
+
|
169 |
+
if (file_exists($class['dir'] . $class['name'] . '.php')) {
|
170 |
+
return $class;
|
171 |
+
}
|
172 |
+
}
|
173 |
+
return false;
|
174 |
+
}
|
175 |
+
|
176 |
+
}
|
classes/RemoteController.php
CHANGED
@@ -1,1455 +1,1572 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Classes_RemoteController
|
5 |
-
|
6 |
-
|
7 |
-
public static $
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
*
|
12 |
-
*
|
13 |
-
* @param
|
14 |
-
* @
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
'
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
'
|
37 |
-
'
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
return
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
*
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
*
|
114 |
-
*
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
/**
|
158 |
-
*
|
159 |
-
*
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
if (!empty($json->data)) {
|
251 |
-
return $json->data;
|
252 |
-
}
|
253 |
-
|
254 |
-
return false;
|
255 |
-
}
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
}
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
if (isset($json->
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
}
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
/**
|
339 |
-
* Get the API
|
340 |
-
*
|
341 |
-
* @return array|WP_Error
|
342 |
-
*/
|
343 |
-
public static function
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
$json = json_decode(self::apiCall('api/
|
378 |
-
|
379 |
-
if (isset($json->error) && $json->error <> '') {
|
380 |
-
return (new WP_Error('api_error', $json->error));
|
381 |
-
} elseif (!isset($json->data)) {
|
382 |
-
return (new WP_Error('api_error', 'no_data'));
|
383 |
-
}
|
384 |
-
|
385 |
-
if (!
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
return
|
521 |
-
}
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
if (
|
535 |
-
return
|
536 |
-
}
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
self::$apimethod = 'post'; //call method
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
return
|
621 |
-
}
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
*
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
$json = json_decode(self::apiCall('api/kr/
|
662 |
-
|
663 |
-
if (isset($json->error) && $json->error <> '') {
|
664 |
-
return (new WP_Error('api_error', $json->error));
|
665 |
-
} elseif (!isset($json->data)) {
|
666 |
-
return (new WP_Error('api_error', 'no_data'));
|
667 |
-
}
|
668 |
-
|
669 |
-
if (!empty($json->data)) {
|
670 |
-
return $json->data;
|
671 |
-
}
|
672 |
-
|
673 |
-
return false;
|
674 |
-
}
|
675 |
-
|
676 |
-
public static function
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
*
|
698 |
-
* @param
|
699 |
-
* @return array|bool|mixed|object|WP_Error
|
700 |
-
*/
|
701 |
-
public static function
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
public static function
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
*
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
*
|
890 |
-
* @param
|
891 |
-
* @return bool|WP_Error
|
892 |
-
*/
|
893 |
-
public static function
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
*
|
914 |
-
*
|
915 |
-
* @
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
return (new WP_Error('api_error',
|
926 |
-
}
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
/**
|
938 |
-
* Get
|
939 |
-
*
|
940 |
-
* @param
|
941 |
-
* @return
|
942 |
-
*/
|
943 |
-
public static function
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
*
|
964 |
-
*
|
965 |
-
* @
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
return (new WP_Error('api_error',
|
976 |
-
}
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
*
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
return
|
1003 |
-
}
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
public static function
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
}
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
if (
|
1359 |
-
return $json->
|
1360 |
-
}
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Classes_RemoteController
|
5 |
+
{
|
6 |
+
|
7 |
+
public static $cache = array();
|
8 |
+
public static $apimethod = 'get';
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Call the Squirrly Cloud Server
|
12 |
+
*
|
13 |
+
* @param string $module
|
14 |
+
* @param array $args
|
15 |
+
* @param array $options
|
16 |
+
* @return string
|
17 |
+
*/
|
18 |
+
public static function apiCall($module, $args = array(), $options = array())
|
19 |
+
{
|
20 |
+
$parameters = "";
|
21 |
+
|
22 |
+
//Don't make API calls without the token unless it's login or register
|
23 |
+
if (!SQ_Classes_Helpers_Tools::getOption('sq_api')) {
|
24 |
+
if (!in_array($module, array('api/user/login', 'api/user/register'))) {
|
25 |
+
return '';
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
//predefined options
|
30 |
+
$options = array_merge(
|
31 |
+
array(
|
32 |
+
'method' => self::$apimethod,
|
33 |
+
'sslverify' => SQ_CHECK_SSL,
|
34 |
+
'timeout' => 20,
|
35 |
+
'headers' => array(
|
36 |
+
'USER-TOKEN' => SQ_Classes_Helpers_Tools::getOption('sq_api'),
|
37 |
+
'URL-TOKEN' => (SQ_Classes_Helpers_Tools::getOption('sq_cloud_connect') ? SQ_Classes_Helpers_Tools::getOption('sq_cloud_token') : false),
|
38 |
+
'USER-URL' => apply_filters('sq_homeurl', get_bloginfo('url')),
|
39 |
+
'LANG' => apply_filters('sq_language', get_bloginfo('language')),
|
40 |
+
'VERSQ' => (int)str_replace('.', '', SQ_VERSION)
|
41 |
+
)
|
42 |
+
),
|
43 |
+
$options
|
44 |
+
);
|
45 |
+
|
46 |
+
try {
|
47 |
+
if (!empty($args)) {
|
48 |
+
foreach ($args as $key => $value) {
|
49 |
+
if ($value <> '') {
|
50 |
+
$parameters .= ($parameters == "" ? "" : "&") . $key . "=" . urlencode($value);
|
51 |
+
}
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
//call it with http to prevent curl issues with ssls
|
56 |
+
$url = self::cleanUrl(_SQ_APIV2_URL_ . $module . "?" . $parameters);
|
57 |
+
|
58 |
+
if (!isset(self::$cache[md5($url)])) {
|
59 |
+
if ($options['method'] == 'post') {
|
60 |
+
$options['body'] = $args;
|
61 |
+
}
|
62 |
+
|
63 |
+
self::$cache[md5($url)] = self::sq_wpcall($url, $options);
|
64 |
+
}
|
65 |
+
|
66 |
+
return self::$cache[md5($url)];
|
67 |
+
|
68 |
+
|
69 |
+
} catch (Exception $e) {
|
70 |
+
return '';
|
71 |
+
}
|
72 |
+
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Clear the url before the call
|
77 |
+
*
|
78 |
+
* @param string $url
|
79 |
+
* @return string
|
80 |
+
*/
|
81 |
+
private static function cleanUrl($url)
|
82 |
+
{
|
83 |
+
return str_replace(array(' '), array('+'), $url);
|
84 |
+
}
|
85 |
+
|
86 |
+
public static function generatePassword($length = 12)
|
87 |
+
{
|
88 |
+
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
89 |
+
|
90 |
+
$password = '';
|
91 |
+
for ($i = 0; $i < $length; $i++) {
|
92 |
+
$password .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
|
93 |
+
}
|
94 |
+
|
95 |
+
return $password;
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Get My Squirrly Link
|
100 |
+
*
|
101 |
+
* @param $path
|
102 |
+
* @return string
|
103 |
+
*/
|
104 |
+
public static function getMySquirrlyLink($path)
|
105 |
+
{
|
106 |
+
return apply_filters('sq_cloudmenu', _SQ_DASH_URL_, $path);
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Get API Link
|
111 |
+
*
|
112 |
+
* @param string $path
|
113 |
+
* @param integer $version
|
114 |
+
* @return string
|
115 |
+
*/
|
116 |
+
public static function getApiLink($path)
|
117 |
+
{
|
118 |
+
return _SQ_APIV2_URL_ . $path . '?token=' . SQ_Classes_Helpers_Tools::getOption('sq_api') . '&url_token='.(SQ_Classes_Helpers_Tools::getOption('sq_cloud_connect') ? SQ_Classes_Helpers_Tools::getOption('sq_cloud_token') : false).'&url=' . apply_filters('sq_homeurl', get_bloginfo('url'));
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Use the WP remote call
|
123 |
+
*
|
124 |
+
* @param $url
|
125 |
+
* @param $options
|
126 |
+
* @return array|bool|string|WP_Error
|
127 |
+
*/
|
128 |
+
public static function sq_wpcall($url, $options)
|
129 |
+
{
|
130 |
+
$method = $options['method'];
|
131 |
+
//not accepted as option
|
132 |
+
unset($options['method']);
|
133 |
+
|
134 |
+
switch ($method) {
|
135 |
+
case 'get':
|
136 |
+
$response = wp_remote_get($url, $options);
|
137 |
+
break;
|
138 |
+
case 'post':
|
139 |
+
$response = wp_remote_post($url, $options);
|
140 |
+
break;
|
141 |
+
default:
|
142 |
+
$response = wp_remote_request($url, $options);
|
143 |
+
break;
|
144 |
+
}
|
145 |
+
|
146 |
+
if (is_wp_error($response)) {
|
147 |
+
SQ_Classes_Error::setError($response->get_error_message(), 'sq_error');
|
148 |
+
return false;
|
149 |
+
}
|
150 |
+
|
151 |
+
$response = self::cleanResponce(wp_remote_retrieve_body($response)); //clear and get the body
|
152 |
+
|
153 |
+
SQ_Debug::dump('wp_remote_get', $method, $url, $options, $response); //output debug
|
154 |
+
return $response;
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Get the Json from responce if any
|
159 |
+
*
|
160 |
+
* @param string $response
|
161 |
+
* @return string
|
162 |
+
*/
|
163 |
+
private static function cleanResponce($response)
|
164 |
+
{
|
165 |
+
return trim($response, '()');
|
166 |
+
}
|
167 |
+
|
168 |
+
/**********************
|
169 |
+
*
|
170 |
+
* USER
|
171 |
+
******************************/
|
172 |
+
/**
|
173 |
+
* @param array $args
|
174 |
+
* @return array|mixed|object|WP_Error
|
175 |
+
*/
|
176 |
+
public static function connect($args = array())
|
177 |
+
{
|
178 |
+
self::$apimethod = 'post'; //call method
|
179 |
+
$json = json_decode(self::apiCall('api/user/connect', $args));
|
180 |
+
|
181 |
+
if (isset($json->error) && $json->error <> '') {
|
182 |
+
|
183 |
+
if ($json->error == 'invalid_token') {
|
184 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_api', false);
|
185 |
+
}
|
186 |
+
if ($json->error == 'disconnected') {
|
187 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_api', false);
|
188 |
+
}
|
189 |
+
if ($json->error == 'banned') {
|
190 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_api', false);
|
191 |
+
}
|
192 |
+
return (new WP_Error('api_error', $json->error));
|
193 |
+
}
|
194 |
+
|
195 |
+
//Refresh the checkin on login
|
196 |
+
delete_transient('sq_checkin');
|
197 |
+
|
198 |
+
return $json;
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Login user to API
|
203 |
+
*
|
204 |
+
* @param array $args
|
205 |
+
* @return bool|WP_Error
|
206 |
+
*/
|
207 |
+
public static function login($args = array())
|
208 |
+
{
|
209 |
+
self::$apimethod = 'post'; //call method
|
210 |
+
|
211 |
+
$json = json_decode(self::apiCall('api/user/login', $args));
|
212 |
+
|
213 |
+
if (isset($json->error) && $json->error <> '') {
|
214 |
+
return (new WP_Error('api_error', $json->error));
|
215 |
+
} elseif (!isset($json->data)) {
|
216 |
+
return (new WP_Error('api_error', 'no_data'));
|
217 |
+
}
|
218 |
+
|
219 |
+
//Refresh the checkin on login
|
220 |
+
delete_transient('sq_checkin');
|
221 |
+
|
222 |
+
if (!empty($json->data)) {
|
223 |
+
return $json->data;
|
224 |
+
}
|
225 |
+
|
226 |
+
return false;
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Register user to API
|
231 |
+
*
|
232 |
+
* @param array $args
|
233 |
+
* @return bool|WP_Error
|
234 |
+
*/
|
235 |
+
public static function register($args = array())
|
236 |
+
{
|
237 |
+
self::$apimethod = 'post'; //call method
|
238 |
+
|
239 |
+
$json = json_decode(self::apiCall('api/user/register', $args));
|
240 |
+
|
241 |
+
if (isset($json->error) && $json->error <> '') {
|
242 |
+
return (new WP_Error('api_error', $json->error));
|
243 |
+
} elseif (!isset($json->data)) {
|
244 |
+
return (new WP_Error('api_error', 'no_data'));
|
245 |
+
}
|
246 |
+
|
247 |
+
//Refresh the checkin on login
|
248 |
+
delete_transient('sq_checkin');
|
249 |
+
|
250 |
+
if (!empty($json->data)) {
|
251 |
+
return $json->data;
|
252 |
+
}
|
253 |
+
|
254 |
+
return false;
|
255 |
+
}
|
256 |
+
|
257 |
+
public static function getCloudToken($args = array())
|
258 |
+
{
|
259 |
+
self::$apimethod = 'get'; //call method
|
260 |
+
|
261 |
+
$json = json_decode(self::apiCall('api/user/token', $args));
|
262 |
+
|
263 |
+
if (isset($json->error) && $json->error <> '') {
|
264 |
+
return (new WP_Error('api_error', $json->error));
|
265 |
+
} elseif (!isset($json->data)) {
|
266 |
+
return (new WP_Error('api_error', 'no_data'));
|
267 |
+
}
|
268 |
+
|
269 |
+
if (!empty($json->data)) {
|
270 |
+
return $json->data;
|
271 |
+
}
|
272 |
+
|
273 |
+
return false;
|
274 |
+
}
|
275 |
+
|
276 |
+
/**
|
277 |
+
* User Checkin
|
278 |
+
*
|
279 |
+
* @param array $args
|
280 |
+
* @return bool|WP_Error
|
281 |
+
*/
|
282 |
+
public static function checkin($args = array())
|
283 |
+
{
|
284 |
+
self::$apimethod = 'get'; //call method
|
285 |
+
|
286 |
+
if (get_transient('sq_checkin')) {
|
287 |
+
return get_transient('sq_checkin');
|
288 |
+
}
|
289 |
+
|
290 |
+
$json = json_decode(self::apiCall('api/user/checkin', $args));
|
291 |
+
|
292 |
+
if (isset($json->error) && $json->error <> '') {
|
293 |
+
|
294 |
+
//prevent throttling on API
|
295 |
+
if ($json->error == 'too_many_requests') {
|
296 |
+
SQ_Classes_Error::setError(esc_html__("Too many API attempts, please slow down the request.", 'squirrly-seo'));
|
297 |
+
SQ_Classes_Error::hookNotices();
|
298 |
+
return (new WP_Error('api_error', $json->error));
|
299 |
+
} elseif ($json->error == 'maintenance') {
|
300 |
+
SQ_Classes_Error::setError(esc_html__("Squirrly Cloud is down for a bit of maintenance right now. But we'll be back in a minute.", 'squirrly-seo'));
|
301 |
+
SQ_Classes_Error::hookNotices();
|
302 |
+
return (new WP_Error('maintenance', $json->error));
|
303 |
+
}
|
304 |
+
|
305 |
+
self::connect(); //connect the website
|
306 |
+
return (new WP_Error('api_error', $json->error));
|
307 |
+
|
308 |
+
} elseif (!isset($json->data)) {
|
309 |
+
return (new WP_Error('api_error', 'no_data'));
|
310 |
+
}
|
311 |
+
|
312 |
+
if (isset($json->data->offer) && $json->data->offer <> '') {
|
313 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_offer', $json->data->offer);
|
314 |
+
} else {
|
315 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_offer', false);
|
316 |
+
}
|
317 |
+
|
318 |
+
//Save the connections into database
|
319 |
+
if (isset($json->data->connection_gsc) && isset($json->data->connection_ga)) {
|
320 |
+
$connect = SQ_Classes_Helpers_Tools::getOption('connect');
|
321 |
+
$connect['google_analytics'] = $json->data->connection_ga;
|
322 |
+
$connect['google_search_console'] = $json->data->connection_gsc;
|
323 |
+
SQ_Classes_Helpers_Tools::saveOptions('connect', $connect);
|
324 |
+
}
|
325 |
+
|
326 |
+
if(isset($json->data->subscription_devkit)) {
|
327 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_auto_devkit', (int)$json->data->subscription_devkit);
|
328 |
+
}
|
329 |
+
|
330 |
+
set_transient('sq_checkin', $json->data, 60);
|
331 |
+
return $json->data;
|
332 |
+
}
|
333 |
+
|
334 |
+
/********************************
|
335 |
+
*
|
336 |
+
* NOTIFICATIONS
|
337 |
+
*********************/
|
338 |
+
/**
|
339 |
+
* Get the Notifications from API for the current blog
|
340 |
+
*
|
341 |
+
* @return array|WP_Error
|
342 |
+
*/
|
343 |
+
public static function getNotifications()
|
344 |
+
{
|
345 |
+
self::$apimethod = 'get'; //call method
|
346 |
+
|
347 |
+
$notifications = array();
|
348 |
+
if ($json = json_decode(self::apiCall('api/audits/notifications', array()))) {
|
349 |
+
|
350 |
+
if (isset($json->error) && $json->error <> '') {
|
351 |
+
return (new WP_Error('api_error', $json->error));
|
352 |
+
} elseif (!isset($json->data)) {
|
353 |
+
return (new WP_Error('api_error', 'no_data'));
|
354 |
+
}
|
355 |
+
|
356 |
+
$notifications = $json->data;
|
357 |
+
|
358 |
+
}
|
359 |
+
|
360 |
+
return $notifications;
|
361 |
+
}
|
362 |
+
|
363 |
+
/**
|
364 |
+
* Get the API stats for this blog
|
365 |
+
*
|
366 |
+
* @return array|WP_Error|false
|
367 |
+
*/
|
368 |
+
public static function getStats()
|
369 |
+
{
|
370 |
+
self::$apimethod = 'get'; //call method
|
371 |
+
|
372 |
+
if (get_transient('sq_stats')) {
|
373 |
+
return get_transient('sq_stats');
|
374 |
+
}
|
375 |
+
|
376 |
+
$args = array();
|
377 |
+
$json = json_decode(self::apiCall('api/user/stats', $args));
|
378 |
+
|
379 |
+
if (isset($json->error) && $json->error <> '') {
|
380 |
+
return (new WP_Error('api_error', $json->error));
|
381 |
+
} elseif (!isset($json->data)) {
|
382 |
+
return (new WP_Error('api_error', 'no_data'));
|
383 |
+
}
|
384 |
+
|
385 |
+
if (!empty($json->data)) {
|
386 |
+
set_transient('sq_stats', $json->data, 60);
|
387 |
+
return $json->data;
|
388 |
+
}
|
389 |
+
|
390 |
+
return false;
|
391 |
+
|
392 |
+
}
|
393 |
+
|
394 |
+
/**
|
395 |
+
* Get audits from API
|
396 |
+
*
|
397 |
+
* @param array $args
|
398 |
+
* @return bool|WP_Error
|
399 |
+
*/
|
400 |
+
public static function getBlogAudits($args = array())
|
401 |
+
{
|
402 |
+
self::$apimethod = 'get'; //call method
|
403 |
+
|
404 |
+
$json = json_decode(self::apiCall('api/audits/get-audits', $args));
|
405 |
+
|
406 |
+
if (isset($json->error) && $json->error <> '') {
|
407 |
+
return (new WP_Error('api_error', $json->error));
|
408 |
+
} elseif (!isset($json->data)) {
|
409 |
+
return (new WP_Error('api_error', 'no_data'));
|
410 |
+
}
|
411 |
+
|
412 |
+
if (!isset($json->data->audits)) {
|
413 |
+
return (new WP_Error('api_error', 'no_data'));
|
414 |
+
}
|
415 |
+
|
416 |
+
return $json->data->audits;
|
417 |
+
}
|
418 |
+
|
419 |
+
public static function saveFeedback($args = array())
|
420 |
+
{
|
421 |
+
self::$apimethod = 'post'; //call method
|
422 |
+
|
423 |
+
$json = json_decode(self::apiCall('api/user/feedback', $args));
|
424 |
+
|
425 |
+
if (isset($json->error) && $json->error <> '') {
|
426 |
+
return (new WP_Error('api_error', $json->error));
|
427 |
+
} elseif (!isset($json->data)) {
|
428 |
+
return (new WP_Error('api_error', 'no_data'));
|
429 |
+
}
|
430 |
+
|
431 |
+
if (!empty($json->data)) {
|
432 |
+
return $json->data;
|
433 |
+
}
|
434 |
+
|
435 |
+
return false;
|
436 |
+
}
|
437 |
+
|
438 |
+
|
439 |
+
/********************************
|
440 |
+
*
|
441 |
+
* BRIEFCASE
|
442 |
+
*********************/
|
443 |
+
public static function getBriefcaseStats($args = array())
|
444 |
+
{
|
445 |
+
self::$apimethod = 'get'; //call method
|
446 |
+
|
447 |
+
if (get_transient('sq_briefcase_stats')) {
|
448 |
+
return get_transient('sq_briefcase_stats');
|
449 |
+
}
|
450 |
+
|
451 |
+
$json = json_decode(self::apiCall('api/briefcase/stats', $args));
|
452 |
+
|
453 |
+
if (isset($json->error) && $json->error <> '') {
|
454 |
+
return (new WP_Error('api_error', $json->error));
|
455 |
+
} elseif (!isset($json->data)) {
|
456 |
+
return (new WP_Error('api_error', 'no_data'));
|
457 |
+
}
|
458 |
+
|
459 |
+
if (!empty($json->data)) {
|
460 |
+
set_transient('sq_briefcase_stats', $json->data, 60);
|
461 |
+
return $json->data;
|
462 |
+
}
|
463 |
+
|
464 |
+
return false;
|
465 |
+
}
|
466 |
+
|
467 |
+
public static function getBriefcase($args = array())
|
468 |
+
{
|
469 |
+
self::$apimethod = 'get'; //call method
|
470 |
+
|
471 |
+
$json = json_decode(self::apiCall('api/briefcase/get', $args, ['timeout' => 60]));
|
472 |
+
|
473 |
+
if (isset($json->error) && $json->error <> '') {
|
474 |
+
return (new WP_Error('api_error', $json->error));
|
475 |
+
} elseif (!isset($json->data)) {
|
476 |
+
return (new WP_Error('api_error', 'no_data'));
|
477 |
+
}
|
478 |
+
|
479 |
+
if (!empty($json->data)) {
|
480 |
+
return $json->data;
|
481 |
+
}
|
482 |
+
|
483 |
+
return false;
|
484 |
+
}
|
485 |
+
|
486 |
+
public static function importBriefcaseKeywords($args = array())
|
487 |
+
{
|
488 |
+
self::$apimethod = 'post'; //call method
|
489 |
+
|
490 |
+
//clear the briefcase stats
|
491 |
+
delete_transient('sq_briefcase_stats');
|
492 |
+
|
493 |
+
$json = json_decode(self::apiCall('api/briefcase/import', $args));
|
494 |
+
|
495 |
+
if (isset($json->error) && $json->error <> '') {
|
496 |
+
return (new WP_Error('api_error', $json->error));
|
497 |
+
} elseif (!isset($json->data)) {
|
498 |
+
return (new WP_Error('api_error', 'no_data'));
|
499 |
+
}
|
500 |
+
|
501 |
+
if (!empty($json->data)) {
|
502 |
+
return $json->data;
|
503 |
+
}
|
504 |
+
|
505 |
+
return false;
|
506 |
+
}
|
507 |
+
|
508 |
+
public static function addBriefcaseKeyword($args = array())
|
509 |
+
{
|
510 |
+
self::$apimethod = 'post'; //call method
|
511 |
+
|
512 |
+
//clear the briefcase stats
|
513 |
+
delete_transient('sq_briefcase_stats');
|
514 |
+
|
515 |
+
$json = json_decode(self::apiCall('api/briefcase/add', $args));
|
516 |
+
|
517 |
+
if (isset($json->error) && $json->error <> '') {
|
518 |
+
return (new WP_Error('api_error', $json->error));
|
519 |
+
} elseif (!isset($json->data)) {
|
520 |
+
return (new WP_Error('api_error', 'no_data'));
|
521 |
+
}
|
522 |
+
|
523 |
+
if (!empty($json->data)) {
|
524 |
+
return $json->data;
|
525 |
+
}
|
526 |
+
|
527 |
+
return false;
|
528 |
+
}
|
529 |
+
|
530 |
+
public static function removeBriefcaseKeyword($args = array())
|
531 |
+
{
|
532 |
+
self::$apimethod = 'post'; //call method
|
533 |
+
|
534 |
+
if ($json = json_decode(self::apiCall('api/briefcase/hide', $args))) {
|
535 |
+
return $json;
|
536 |
+
}
|
537 |
+
|
538 |
+
return false;
|
539 |
+
}
|
540 |
+
|
541 |
+
public static function saveBriefcaseKeywordLabel($args = array())
|
542 |
+
{
|
543 |
+
self::$apimethod = 'post'; //call method
|
544 |
+
|
545 |
+
//clear the briefcase stats
|
546 |
+
delete_transient('sq_briefcase_stats');
|
547 |
+
|
548 |
+
$json = json_decode(self::apiCall('api/briefcase/label/keyword', $args));
|
549 |
+
|
550 |
+
if (isset($json->error) && $json->error <> '') {
|
551 |
+
return (new WP_Error('api_error', $json->error));
|
552 |
+
} elseif (!isset($json->data)) {
|
553 |
+
return (new WP_Error('api_error', 'no_data'));
|
554 |
+
}
|
555 |
+
|
556 |
+
if (!empty($json->data)) {
|
557 |
+
return $json->data;
|
558 |
+
}
|
559 |
+
|
560 |
+
return false;
|
561 |
+
}
|
562 |
+
|
563 |
+
public static function addBriefcaseLabel($args = array())
|
564 |
+
{
|
565 |
+
self::$apimethod = 'post'; //call method
|
566 |
+
|
567 |
+
//clear the briefcase stats
|
568 |
+
delete_transient('sq_briefcase_stats');
|
569 |
+
|
570 |
+
$json = json_decode(self::apiCall('api/briefcase/label/add', $args));
|
571 |
+
|
572 |
+
if (isset($json->error) && $json->error <> '') {
|
573 |
+
return (new WP_Error('api_error', $json->error));
|
574 |
+
} elseif (!isset($json->data)) {
|
575 |
+
return (new WP_Error('api_error', 'no_data'));
|
576 |
+
}
|
577 |
+
|
578 |
+
if (!empty($json->data)) {
|
579 |
+
return $json->data;
|
580 |
+
}
|
581 |
+
|
582 |
+
return false;
|
583 |
+
}
|
584 |
+
|
585 |
+
public static function saveBriefcaseLabel($args = array())
|
586 |
+
{
|
587 |
+
self::$apimethod = 'post'; //call method
|
588 |
+
|
589 |
+
//clear the briefcase stats
|
590 |
+
delete_transient('sq_briefcase_stats');
|
591 |
+
|
592 |
+
$json = json_decode(self::apiCall('api/briefcase/label/save', $args));
|
593 |
+
|
594 |
+
if (isset($json->error) && $json->error <> '') {
|
595 |
+
return (new WP_Error('api_error', $json->error));
|
596 |
+
} elseif (!isset($json->data)) {
|
597 |
+
return (new WP_Error('api_error', 'no_data'));
|
598 |
+
}
|
599 |
+
|
600 |
+
if (!empty($json->data)) {
|
601 |
+
return $json->data;
|
602 |
+
}
|
603 |
+
|
604 |
+
return false;
|
605 |
+
}
|
606 |
+
|
607 |
+
public static function removeBriefcaseLabel($args = array())
|
608 |
+
{
|
609 |
+
self::$apimethod = 'post'; //call method
|
610 |
+
|
611 |
+
$json = json_decode(self::apiCall('api/briefcase/label/delete', $args));
|
612 |
+
|
613 |
+
if (isset($json->error) && $json->error <> '') {
|
614 |
+
return (new WP_Error('api_error', $json->error));
|
615 |
+
} elseif (!isset($json->data)) {
|
616 |
+
return (new WP_Error('api_error', 'no_data'));
|
617 |
+
}
|
618 |
+
|
619 |
+
if (!empty($json->data)) {
|
620 |
+
return $json->data;
|
621 |
+
}
|
622 |
+
|
623 |
+
return false;
|
624 |
+
}
|
625 |
+
|
626 |
+
public static function saveBriefcaseMainKeyword($args = array())
|
627 |
+
{
|
628 |
+
self::$apimethod = 'post'; //call method
|
629 |
+
|
630 |
+
$json = json_decode(self::apiCall('api/briefcase/main', $args));
|
631 |
+
|
632 |
+
if (isset($json->error) && $json->error <> '') {
|
633 |
+
return (new WP_Error('api_error', $json->error));
|
634 |
+
} elseif (!isset($json->data)) {
|
635 |
+
return (new WP_Error('api_error', 'no_data'));
|
636 |
+
}
|
637 |
+
|
638 |
+
if (!empty($json->data)) {
|
639 |
+
return $json->data;
|
640 |
+
}
|
641 |
+
|
642 |
+
return false;
|
643 |
+
}
|
644 |
+
|
645 |
+
|
646 |
+
/********************************
|
647 |
+
*
|
648 |
+
* KEYWORD RESEARCH
|
649 |
+
****************/
|
650 |
+
|
651 |
+
/**
|
652 |
+
* Get KR Countries
|
653 |
+
*
|
654 |
+
* @param array $args
|
655 |
+
* @return bool|WP_Error
|
656 |
+
*/
|
657 |
+
public static function getKrCountries($args = array())
|
658 |
+
{
|
659 |
+
self::$apimethod = 'get'; //call method
|
660 |
+
|
661 |
+
$json = json_decode(self::apiCall('api/kr/countries', $args));
|
662 |
+
|
663 |
+
if (isset($json->error) && $json->error <> '') {
|
664 |
+
return (new WP_Error('api_error', $json->error));
|
665 |
+
} elseif (!isset($json->data)) {
|
666 |
+
return (new WP_Error('api_error', 'no_data'));
|
667 |
+
}
|
668 |
+
|
669 |
+
if (!empty($json->data)) {
|
670 |
+
return $json->data;
|
671 |
+
}
|
672 |
+
|
673 |
+
return false;
|
674 |
+
}
|
675 |
+
|
676 |
+
public static function getKROthers($args = array())
|
677 |
+
{
|
678 |
+
self::$apimethod = 'get'; //call method
|
679 |
+
|
680 |
+
$json = json_decode(self::apiCall('api/kr/other', $args));
|
681 |
+
|
682 |
+
if (isset($json->error) && $json->error <> '') {
|
683 |
+
return (new WP_Error('api_error', $json->error));
|
684 |
+
} elseif (!isset($json->data)) {
|
685 |
+
return (new WP_Error('api_error', 'no_data'));
|
686 |
+
}
|
687 |
+
|
688 |
+
if (!empty($json->data)) {
|
689 |
+
return $json->data;
|
690 |
+
}
|
691 |
+
|
692 |
+
return false;
|
693 |
+
}
|
694 |
+
|
695 |
+
/**
|
696 |
+
* Set Keyword Research
|
697 |
+
*
|
698 |
+
* @param array $args
|
699 |
+
* @return array|bool|mixed|object|WP_Error
|
700 |
+
*/
|
701 |
+
public static function setKRSuggestion($args = array())
|
702 |
+
{
|
703 |
+
self::$apimethod = 'post'; //call method
|
704 |
+
|
705 |
+
//clear the briefcase stats
|
706 |
+
delete_transient('sq_stats');
|
707 |
+
delete_transient('sq_briefcase_stats');
|
708 |
+
|
709 |
+
$json = json_decode(self::apiCall('api/kr/suggestion', $args));
|
710 |
+
|
711 |
+
if (isset($json->error) && $json->error <> '') {
|
712 |
+
return (new WP_Error('api_error', $json->error));
|
713 |
+
} elseif (!isset($json->data)) {
|
714 |
+
return (new WP_Error('api_error', 'no_data'));
|
715 |
+
}
|
716 |
+
|
717 |
+
if (!empty($json->data)) {
|
718 |
+
return $json->data;
|
719 |
+
}
|
720 |
+
|
721 |
+
return false;
|
722 |
+
}
|
723 |
+
|
724 |
+
public static function getKRSuggestion($args = array())
|
725 |
+
{
|
726 |
+
self::$apimethod = 'get'; //call method
|
727 |
+
|
728 |
+
$json = json_decode(self::apiCall('api/kr/suggestion', $args));
|
729 |
+
|
730 |
+
if (isset($json->error) && $json->error <> '') {
|
731 |
+
return (new WP_Error('api_error', $json->error));
|
732 |
+
} elseif (!isset($json->data)) {
|
733 |
+
return (new WP_Error('api_error', 'no_data'));
|
734 |
+
}
|
735 |
+
|
736 |
+
if (!empty($json->data)) {
|
737 |
+
return $json->data;
|
738 |
+
}
|
739 |
+
|
740 |
+
return false;
|
741 |
+
}
|
742 |
+
|
743 |
+
/********************************
|
744 |
+
*
|
745 |
+
* KEYWORD HISTORY & FOUND
|
746 |
+
****************/
|
747 |
+
|
748 |
+
/**
|
749 |
+
* Get Keyword Research History
|
750 |
+
*
|
751 |
+
* @param array $args
|
752 |
+
* @return array|bool|mixed|object|WP_Error
|
753 |
+
*/
|
754 |
+
public static function getKRHistory($args = array())
|
755 |
+
{
|
756 |
+
self::$apimethod = 'get'; //call method
|
757 |
+
|
758 |
+
$json = json_decode(self::apiCall('api/kr/history', $args));
|
759 |
+
|
760 |
+
if (isset($json->error) && $json->error <> '') {
|
761 |
+
return (new WP_Error('api_error', $json->error));
|
762 |
+
} elseif (!isset($json->data)) {
|
763 |
+
return (new WP_Error('api_error', 'no_data'));
|
764 |
+
}
|
765 |
+
|
766 |
+
if (!empty($json->data)) {
|
767 |
+
return $json->data;
|
768 |
+
}
|
769 |
+
|
770 |
+
return false;
|
771 |
+
}
|
772 |
+
|
773 |
+
/**
|
774 |
+
* Get the Kr Found by API
|
775 |
+
*
|
776 |
+
* @param array $args
|
777 |
+
* @return bool|WP_Error
|
778 |
+
*/
|
779 |
+
public static function getKrFound($args = array())
|
780 |
+
{
|
781 |
+
self::$apimethod = 'get'; //call method
|
782 |
+
|
783 |
+
$json = json_decode(self::apiCall('api/kr/found', $args));
|
784 |
+
|
785 |
+
if (isset($json->error) && $json->error <> '') {
|
786 |
+
return (new WP_Error('api_error', $json->error));
|
787 |
+
} elseif (!isset($json->data)) {
|
788 |
+
return (new WP_Error('api_error', 'no_data'));
|
789 |
+
}
|
790 |
+
|
791 |
+
if (!empty($json->data)) {
|
792 |
+
return $json->data;
|
793 |
+
}
|
794 |
+
|
795 |
+
return false;
|
796 |
+
}
|
797 |
+
|
798 |
+
/**
|
799 |
+
*
|
800 |
+
* Remove Keyword from Suggestions
|
801 |
+
*
|
802 |
+
* @param array $args
|
803 |
+
* @return bool|WP_Error
|
804 |
+
*/
|
805 |
+
public static function removeKrFound($args = array())
|
806 |
+
{
|
807 |
+
self::$apimethod = 'post'; //call method
|
808 |
+
|
809 |
+
$json = json_decode(self::apiCall('api/kr/found/delete', $args));
|
810 |
+
|
811 |
+
if (isset($json->error) && $json->error <> '') {
|
812 |
+
return (new WP_Error('api_error', $json->error));
|
813 |
+
} elseif (!isset($json->data)) {
|
814 |
+
return (new WP_Error('api_error', 'no_data'));
|
815 |
+
}
|
816 |
+
|
817 |
+
if (!empty($json->data)) {
|
818 |
+
return $json->data;
|
819 |
+
}
|
820 |
+
|
821 |
+
return false;
|
822 |
+
}
|
823 |
+
/********************
|
824 |
+
*
|
825 |
+
* WP Posts
|
826 |
+
***************************/
|
827 |
+
/**
|
828 |
+
* Save the post status on API
|
829 |
+
*
|
830 |
+
* @param array $args
|
831 |
+
* @return bool|WP_Error
|
832 |
+
*/
|
833 |
+
public static function savePost($args = array())
|
834 |
+
{
|
835 |
+
self::$apimethod = 'post'; //call method
|
836 |
+
|
837 |
+
//clear the briefcase stats
|
838 |
+
delete_transient('sq_stats');
|
839 |
+
|
840 |
+
$json = json_decode(self::apiCall('api/posts/update', $args, ['timeout' => 5]));
|
841 |
+
|
842 |
+
if (isset($json->error) && $json->error <> '') {
|
843 |
+
return (new WP_Error('api_error', $json->error));
|
844 |
+
} elseif (!isset($json->data)) {
|
845 |
+
return (new WP_Error('api_error', 'no_data'));
|
846 |
+
}
|
847 |
+
|
848 |
+
if (!empty($json->data)) {
|
849 |
+
return $json->data;
|
850 |
+
}
|
851 |
+
|
852 |
+
return false;
|
853 |
+
|
854 |
+
}
|
855 |
+
|
856 |
+
/**
|
857 |
+
* Get the post optimization
|
858 |
+
*
|
859 |
+
* @param array $args
|
860 |
+
* @return array|mixed|object
|
861 |
+
*/
|
862 |
+
public static function getPostOptimization($args = array())
|
863 |
+
{
|
864 |
+
self::$apimethod = 'get'; //call method
|
865 |
+
|
866 |
+
$json = json_decode(self::apiCall('api/posts/optimizations', $args));
|
867 |
+
|
868 |
+
if (isset($json->error) && $json->error <> '') {
|
869 |
+
return (new WP_Error('api_error', $json->error));
|
870 |
+
} elseif (!isset($json->data)) {
|
871 |
+
return (new WP_Error('api_error', 'no_data'));
|
872 |
+
}
|
873 |
+
|
874 |
+
if (!empty($json->data)) {
|
875 |
+
return $json->data;
|
876 |
+
}
|
877 |
+
|
878 |
+
return false;
|
879 |
+
|
880 |
+
}
|
881 |
+
|
882 |
+
/********************
|
883 |
+
*
|
884 |
+
* RANKINGS
|
885 |
+
***************************/
|
886 |
+
|
887 |
+
/**
|
888 |
+
* Add a keyword in Rank Checker
|
889 |
+
*
|
890 |
+
* @param array $args
|
891 |
+
* @return bool|WP_Error
|
892 |
+
*/
|
893 |
+
public static function addSerpKeyword($args = array())
|
894 |
+
{
|
895 |
+
self::$apimethod = 'post'; //call method
|
896 |
+
|
897 |
+
$json = json_decode(self::apiCall('api/briefcase/serp', $args));
|
898 |
+
|
899 |
+
if (isset($json->error) && $json->error <> '') {
|
900 |
+
return (new WP_Error('api_error', $json->error));
|
901 |
+
} elseif (!isset($json->data)) {
|
902 |
+
return (new WP_Error('api_error', 'no_data'));
|
903 |
+
}
|
904 |
+
|
905 |
+
if (!empty($json->data)) {
|
906 |
+
return $json->data;
|
907 |
+
}
|
908 |
+
|
909 |
+
return false;
|
910 |
+
}
|
911 |
+
|
912 |
+
/**
|
913 |
+
* Delete a keyword from Rank Checker
|
914 |
+
*
|
915 |
+
* @param array $args
|
916 |
+
* @return bool|WP_Error
|
917 |
+
*/
|
918 |
+
public static function deleteSerpKeyword($args = array())
|
919 |
+
{
|
920 |
+
self::$apimethod = 'post'; //call method
|
921 |
+
|
922 |
+
$json = json_decode(self::apiCall('api/briefcase/serp-delete', $args));
|
923 |
+
|
924 |
+
if (isset($json->error) && $json->error <> '') {
|
925 |
+
return (new WP_Error('api_error', $json->error));
|
926 |
+
} elseif (!isset($json->data)) {
|
927 |
+
return (new WP_Error('api_error', 'no_data'));
|
928 |
+
}
|
929 |
+
|
930 |
+
if (!empty($json->data)) {
|
931 |
+
return $json->data;
|
932 |
+
}
|
933 |
+
|
934 |
+
return false;
|
935 |
+
}
|
936 |
+
|
937 |
+
/**
|
938 |
+
* Get the Ranks for this blog
|
939 |
+
*
|
940 |
+
* @param array $args
|
941 |
+
* @return bool|WP_Error
|
942 |
+
*/
|
943 |
+
public static function getRanksStats($args = array())
|
944 |
+
{
|
945 |
+
self::$apimethod = 'get'; //call method
|
946 |
+
|
947 |
+
$json = json_decode(self::apiCall('api/serp/stats', $args));
|
948 |
+
|
949 |
+
if (isset($json->error) && $json->error <> '') {
|
950 |
+
return (new WP_Error('api_error', $json->error));
|
951 |
+
} elseif (!isset($json->data)) {
|
952 |
+
return (new WP_Error('api_error', 'no_data'));
|
953 |
+
}
|
954 |
+
|
955 |
+
if (!empty($json->data)) {
|
956 |
+
return $json->data;
|
957 |
+
}
|
958 |
+
|
959 |
+
return false;
|
960 |
+
}
|
961 |
+
|
962 |
+
/**
|
963 |
+
* Get the Ranks for this blog
|
964 |
+
*
|
965 |
+
* @param array $args
|
966 |
+
* @return bool|WP_Error
|
967 |
+
*/
|
968 |
+
public static function getRanks($args = array())
|
969 |
+
{
|
970 |
+
self::$apimethod = 'get'; //call method
|
971 |
+
|
972 |
+
$json = json_decode(self::apiCall('api/serp/get-ranks', $args));
|
973 |
+
|
974 |
+
if (isset($json->error) && $json->error <> '') {
|
975 |
+
return (new WP_Error('api_error', $json->error));
|
976 |
+
} elseif (!isset($json->data)) {
|
977 |
+
return (new WP_Error('api_error', 'no_data'));
|
978 |
+
}
|
979 |
+
|
980 |
+
if (!empty($json->data)) {
|
981 |
+
return $json->data;
|
982 |
+
}
|
983 |
+
|
984 |
+
return false;
|
985 |
+
}
|
986 |
+
|
987 |
+
/**
|
988 |
+
* Refresh the rank for a page/post
|
989 |
+
*
|
990 |
+
* @param array $args
|
991 |
+
* @return bool|WP_Error
|
992 |
+
*/
|
993 |
+
public static function checkPostRank($args = array())
|
994 |
+
{
|
995 |
+
self::$apimethod = 'get'; //call method
|
996 |
+
|
997 |
+
$json = json_decode(self::apiCall('api/serp/refresh', $args));
|
998 |
+
|
999 |
+
if (isset($json->error) && $json->error <> '') {
|
1000 |
+
return (new WP_Error('api_error', $json->error));
|
1001 |
+
} elseif (!isset($json->data)) {
|
1002 |
+
return (new WP_Error('api_error', 'no_data'));
|
1003 |
+
}
|
1004 |
+
|
1005 |
+
if (!empty($json->data)) {
|
1006 |
+
return $json->data;
|
1007 |
+
}
|
1008 |
+
|
1009 |
+
return false;
|
1010 |
+
}
|
1011 |
+
|
1012 |
+
/********************
|
1013 |
+
*
|
1014 |
+
* FOCUS PAGES
|
1015 |
+
***********************/
|
1016 |
+
|
1017 |
+
/**
|
1018 |
+
* Get all focus pages and add them in the SQ_Models_Domain_FocusPage object
|
1019 |
+
* Add the audit data for each focus page
|
1020 |
+
*
|
1021 |
+
* @param array $args
|
1022 |
+
* @return SQ_Models_Domain_FocusPage|WP_Error|false
|
1023 |
+
*/
|
1024 |
+
public static function getFocusPages($args = array())
|
1025 |
+
{
|
1026 |
+
self::$apimethod = 'get'; //call method
|
1027 |
+
|
1028 |
+
$json = json_decode(self::apiCall('api/posts/focus', $args));
|
1029 |
+
|
1030 |
+
if (isset($json->error) && $json->error <> '') {
|
1031 |
+
return (new WP_Error('api_error', $json->error));
|
1032 |
+
} elseif (!isset($json->data)) {
|
1033 |
+
return (new WP_Error('api_error', 'no_data'));
|
1034 |
+
}
|
1035 |
+
|
1036 |
+
if (!empty($json->data)) {
|
1037 |
+
return $json->data;
|
1038 |
+
}
|
1039 |
+
|
1040 |
+
return false;
|
1041 |
+
}
|
1042 |
+
|
1043 |
+
/**
|
1044 |
+
* Get the focus page audit
|
1045 |
+
*
|
1046 |
+
* @param array $args
|
1047 |
+
* @return bool|WP_Error
|
1048 |
+
*/
|
1049 |
+
public static function getFocusAudits($args = array())
|
1050 |
+
{
|
1051 |
+
self::$apimethod = 'get'; //call method
|
1052 |
+
|
1053 |
+
$json = json_decode(self::apiCall('api/audits/focus', $args));
|
1054 |
+
|
1055 |
+
if (isset($json->error) && $json->error <> '') {
|
1056 |
+
return (new WP_Error('api_error', $json->error));
|
1057 |
+
} elseif (!isset($json->data)) {
|
1058 |
+
return (new WP_Error('api_error', 'no_data'));
|
1059 |
+
}
|
1060 |
+
|
1061 |
+
if (!empty($json->data)) {
|
1062 |
+
return $json->data;
|
1063 |
+
}
|
1064 |
+
|
1065 |
+
return false;
|
1066 |
+
}
|
1067 |
+
|
1068 |
+
/**
|
1069 |
+
* Add Focus Page
|
1070 |
+
*
|
1071 |
+
* @param array $args
|
1072 |
+
* @return bool|WP_Error
|
1073 |
+
*/
|
1074 |
+
public static function addFocusPage($args = array())
|
1075 |
+
{
|
1076 |
+
self::$apimethod = 'post'; //post call
|
1077 |
+
|
1078 |
+
$json = json_decode(self::apiCall('api/posts/set-focus', $args));
|
1079 |
+
|
1080 |
+
if (isset($json->error) && $json->error <> '') {
|
1081 |
+
return (new WP_Error('api_error', $json->error));
|
1082 |
+
} elseif (!isset($json->data)) {
|
1083 |
+
return (new WP_Error('api_error', 'no_data'));
|
1084 |
+
}
|
1085 |
+
|
1086 |
+
if (!empty($json->data)) {
|
1087 |
+
return $json->data;
|
1088 |
+
}
|
1089 |
+
|
1090 |
+
return false;
|
1091 |
+
}
|
1092 |
+
|
1093 |
+
public static function updateFocusPage($args = array())
|
1094 |
+
{
|
1095 |
+
self::$apimethod = 'post'; //post call
|
1096 |
+
|
1097 |
+
$json = json_decode(self::apiCall('api/posts/update-focus', $args));
|
1098 |
+
|
1099 |
+
if (isset($json->error) && $json->error <> '') {
|
1100 |
+
return (new WP_Error('api_error', $json->error));
|
1101 |
+
} elseif (!isset($json->data)) {
|
1102 |
+
return (new WP_Error('api_error', 'no_data'));
|
1103 |
+
}
|
1104 |
+
|
1105 |
+
if (!empty($json->data)) {
|
1106 |
+
return $json->data;
|
1107 |
+
}
|
1108 |
+
|
1109 |
+
return false;
|
1110 |
+
}
|
1111 |
+
|
1112 |
+
/**
|
1113 |
+
* Delete the Focus Page
|
1114 |
+
*
|
1115 |
+
* @param array $args
|
1116 |
+
* @return bool|WP_Error
|
1117 |
+
*/
|
1118 |
+
public static function deleteFocusPage($args = array())
|
1119 |
+
{
|
1120 |
+
self::$apimethod = 'post'; //post call
|
1121 |
+
|
1122 |
+
if (isset($args['user_post_id']) && $args['user_post_id'] > 0) {
|
1123 |
+
$json = json_decode(self::apiCall('api/posts/remove-focus/' . $args['user_post_id']));
|
1124 |
+
|
1125 |
+
if (isset($json->error) && $json->error <> '') {
|
1126 |
+
return (new WP_Error('api_error', $json->error));
|
1127 |
+
} elseif (!isset($json->data)) {
|
1128 |
+
return (new WP_Error('api_error', 'no_data'));
|
1129 |
+
}
|
1130 |
+
|
1131 |
+
return $json->data;
|
1132 |
+
}
|
1133 |
+
|
1134 |
+
return false;
|
1135 |
+
}
|
1136 |
+
|
1137 |
+
/**
|
1138 |
+
* Get all focus pages and add them in the SQ_Models_Domain_FocusPage object
|
1139 |
+
* Add the audit data for each focus page
|
1140 |
+
*
|
1141 |
+
* @param array $args
|
1142 |
+
* @return SQ_Models_Domain_FocusPage|WP_Error|false
|
1143 |
+
*/
|
1144 |
+
public static function getInspectURL($args = array())
|
1145 |
+
{
|
1146 |
+
self::$apimethod = 'get'; //call method
|
1147 |
+
|
1148 |
+
$json = json_decode(self::apiCall('api/posts/crawl', $args, ['timeout' => 60]));
|
1149 |
+
|
1150 |
+
if (isset($json->error) && $json->error <> '') {
|
1151 |
+
return (new WP_Error('api_error', $json->error));
|
1152 |
+
} elseif (!isset($json->data)) {
|
1153 |
+
return (new WP_Error('api_error', 'no_data'));
|
1154 |
+
}
|
1155 |
+
|
1156 |
+
if (!empty($json->data)) {
|
1157 |
+
return $json->data;
|
1158 |
+
}
|
1159 |
+
|
1160 |
+
return false;
|
1161 |
+
}
|
1162 |
+
/****************************************
|
1163 |
+
*
|
1164 |
+
* CONNECTIONS
|
1165 |
+
*/
|
1166 |
+
/**
|
1167 |
+
* Disconnect Google Analytics account
|
1168 |
+
*
|
1169 |
+
* @return bool|WP_Error
|
1170 |
+
*/
|
1171 |
+
public static function revokeGaConnection()
|
1172 |
+
{
|
1173 |
+
self::$apimethod = 'get'; //post call
|
1174 |
+
|
1175 |
+
$json = json_decode(self::apiCall('api/ga/revoke'));
|
1176 |
+
|
1177 |
+
if (isset($json->error) && $json->error <> '') {
|
1178 |
+
return (new WP_Error('api_error', $json->error));
|
1179 |
+
} elseif (!isset($json->data)) {
|
1180 |
+
return (new WP_Error('api_error', 'no_data'));
|
1181 |
+
}
|
1182 |
+
|
1183 |
+
//Refresh the checkin on login
|
1184 |
+
delete_transient('sq_checkin');
|
1185 |
+
|
1186 |
+
if (!empty($json->data)) {
|
1187 |
+
return $json->data;
|
1188 |
+
}
|
1189 |
+
|
1190 |
+
return false;
|
1191 |
+
}
|
1192 |
+
|
1193 |
+
public static function getGAToken($args = array())
|
1194 |
+
{
|
1195 |
+
self::$apimethod = 'get'; //post call
|
1196 |
+
|
1197 |
+
$json = json_decode(self::apiCall('api/ga/token', $args));
|
1198 |
+
|
1199 |
+
if (isset($json->error) && $json->error <> '') {
|
1200 |
+
return (new WP_Error('api_error', $json->error));
|
1201 |
+
} elseif (!isset($json->data)) {
|
1202 |
+
return (new WP_Error('api_error', 'no_data'));
|
1203 |
+
}
|
1204 |
+
|
1205 |
+
if (!empty($json->data)) {
|
1206 |
+
return $json->data;
|
1207 |
+
}
|
1208 |
+
|
1209 |
+
return false;
|
1210 |
+
|
1211 |
+
}
|
1212 |
+
|
1213 |
+
public static function getGAProperties($args = array())
|
1214 |
+
{
|
1215 |
+
self::$apimethod = 'get'; //post call
|
1216 |
+
|
1217 |
+
$json = json_decode(self::apiCall('api/ga/properties', $args));
|
1218 |
+
|
1219 |
+
if (isset($json->error) && $json->error <> '') {
|
1220 |
+
return (new WP_Error('api_error', $json->error));
|
1221 |
+
} elseif (!isset($json->data)) {
|
1222 |
+
return (new WP_Error('api_error', 'no_data'));
|
1223 |
+
}
|
1224 |
+
|
1225 |
+
if (!empty($json->data)) {
|
1226 |
+
return $json->data;
|
1227 |
+
}
|
1228 |
+
|
1229 |
+
return false;
|
1230 |
+
|
1231 |
+
}
|
1232 |
+
|
1233 |
+
public static function saveGAProperties($args = array())
|
1234 |
+
{
|
1235 |
+
self::$apimethod = 'post'; //post call
|
1236 |
+
|
1237 |
+
$json = json_decode(self::apiCall('api/ga/properties', $args));
|
1238 |
+
|
1239 |
+
if (isset($json->error) && $json->error <> '') {
|
1240 |
+
return (new WP_Error('api_error', $json->error));
|
1241 |
+
} elseif (!isset($json->data)) {
|
1242 |
+
return (new WP_Error('api_error', 'no_data'));
|
1243 |
+
}
|
1244 |
+
|
1245 |
+
if (!empty($json->data)) {
|
1246 |
+
return $json->data;
|
1247 |
+
}
|
1248 |
+
|
1249 |
+
return false;
|
1250 |
+
|
1251 |
+
}
|
1252 |
+
|
1253 |
+
/**
|
1254 |
+
* Disconnect Google Search Console account
|
1255 |
+
*
|
1256 |
+
* @return bool|WP_Error
|
1257 |
+
*/
|
1258 |
+
public static function revokeGscConnection()
|
1259 |
+
{
|
1260 |
+
self::$apimethod = 'get'; //post call
|
1261 |
+
|
1262 |
+
$json = json_decode(self::apiCall('api/gsc/revoke'));
|
1263 |
+
|
1264 |
+
if (isset($json->error) && $json->error <> '') {
|
1265 |
+
return (new WP_Error('api_error', $json->error));
|
1266 |
+
} elseif (!isset($json->data)) {
|
1267 |
+
return (new WP_Error('api_error', 'no_data'));
|
1268 |
+
}
|
1269 |
+
|
1270 |
+
//Refresh the checkin on login
|
1271 |
+
delete_transient('sq_checkin');
|
1272 |
+
|
1273 |
+
if (!empty($json->data)) {
|
1274 |
+
return $json->data;
|
1275 |
+
}
|
1276 |
+
|
1277 |
+
return false;
|
1278 |
+
|
1279 |
+
}
|
1280 |
+
|
1281 |
+
public static function syncGSC($args = array())
|
1282 |
+
{
|
1283 |
+
self::$apimethod = 'get'; //post call
|
1284 |
+
|
1285 |
+
$json = json_decode(self::apiCall('api/gsc/sync/kr', $args));
|
1286 |
+
|
1287 |
+
if (isset($json->error) && $json->error <> '') {
|
1288 |
+
return (new WP_Error('api_error', $json->error));
|
1289 |
+
} elseif (!isset($json->data)) {
|
1290 |
+
return (new WP_Error('api_error', 'no_data'));
|
1291 |
+
}
|
1292 |
+
|
1293 |
+
if (!empty($json->data)) {
|
1294 |
+
return $json->data;
|
1295 |
+
}
|
1296 |
+
|
1297 |
+
return false;
|
1298 |
+
|
1299 |
+
}
|
1300 |
+
|
1301 |
+
public static function getGSCToken($args = array())
|
1302 |
+
{
|
1303 |
+
self::$apimethod = 'get'; //post call
|
1304 |
+
|
1305 |
+
$json = json_decode(self::apiCall('api/gsc/token', $args));
|
1306 |
+
|
1307 |
+
if (isset($json->error) && $json->error <> '') {
|
1308 |
+
return (new WP_Error('api_error', $json->error));
|
1309 |
+
} elseif (!isset($json->data)) {
|
1310 |
+
return (new WP_Error('api_error', 'no_data'));
|
1311 |
+
}
|
1312 |
+
|
1313 |
+
if (!empty($json->data)) {
|
1314 |
+
return $json->data;
|
1315 |
+
}
|
1316 |
+
|
1317 |
+
return false;
|
1318 |
+
|
1319 |
+
}
|
1320 |
+
|
1321 |
+
/********************
|
1322 |
+
*
|
1323 |
+
* AUDITS
|
1324 |
+
*****************************/
|
1325 |
+
|
1326 |
+
public static function getAuditPages($args = array())
|
1327 |
+
{
|
1328 |
+
self::$apimethod = 'get'; //call method
|
1329 |
+
|
1330 |
+
$json = json_decode(self::apiCall('api/posts/audits', $args));
|
1331 |
+
|
1332 |
+
if (isset($json->error) && $json->error <> '') {
|
1333 |
+
return (new WP_Error('api_error', $json->error));
|
1334 |
+
} elseif (!isset($json->data)) {
|
1335 |
+
return (new WP_Error('api_error', 'no_data'));
|
1336 |
+
}
|
1337 |
+
|
1338 |
+
if (!empty($json->data)) {
|
1339 |
+
return $json->data;
|
1340 |
+
}
|
1341 |
+
|
1342 |
+
return false;
|
1343 |
+
|
1344 |
+
}
|
1345 |
+
|
1346 |
+
/**
|
1347 |
+
* Get the audit page
|
1348 |
+
*
|
1349 |
+
* @param array $args
|
1350 |
+
* @return bool|WP_Error
|
1351 |
+
*/
|
1352 |
+
public static function getAudit($args = array())
|
1353 |
+
{
|
1354 |
+
self::$apimethod = 'get'; //call method
|
1355 |
+
|
1356 |
+
$json = json_decode(self::apiCall('api/audits/audit', $args));
|
1357 |
+
|
1358 |
+
if (isset($json->error) && $json->error <> '') {
|
1359 |
+
return (new WP_Error('api_error', $json->error));
|
1360 |
+
} elseif (!isset($json->data)) {
|
1361 |
+
return (new WP_Error('api_error', 'no_data'));
|
1362 |
+
}
|
1363 |
+
|
1364 |
+
if (!empty($json->data)) {
|
1365 |
+
return $json->data;
|
1366 |
+
}
|
1367 |
+
|
1368 |
+
return false;
|
1369 |
+
|
1370 |
+
}
|
1371 |
+
|
1372 |
+
/**
|
1373 |
+
* Add Audit Page
|
1374 |
+
*
|
1375 |
+
* @param array $args
|
1376 |
+
* @return bool|WP_Error
|
1377 |
+
*/
|
1378 |
+
public static function addAuditPage($args = array())
|
1379 |
+
{
|
1380 |
+
self::$apimethod = 'post'; //post call
|
1381 |
+
|
1382 |
+
$json = json_decode(self::apiCall('api/posts/set-audit', $args));
|
1383 |
+
|
1384 |
+
if (isset($json->error) && $json->error <> '') {
|
1385 |
+
return (new WP_Error('api_error', $json->error));
|
1386 |
+
} elseif (!isset($json->data)) {
|
1387 |
+
return (new WP_Error('api_error', 'no_data'));
|
1388 |
+
}
|
1389 |
+
|
1390 |
+
if (!empty($json->data)) {
|
1391 |
+
return $json->data;
|
1392 |
+
}
|
1393 |
+
|
1394 |
+
return false;
|
1395 |
+
|
1396 |
+
}
|
1397 |
+
|
1398 |
+
public static function updateAudit($args = array())
|
1399 |
+
{
|
1400 |
+
self::$apimethod = 'post'; //post call
|
1401 |
+
|
1402 |
+
$json = json_decode(self::apiCall('api/posts/update-audit', $args));
|
1403 |
+
|
1404 |
+
if (isset($json->error) && $json->error <> '') {
|
1405 |
+
return (new WP_Error('api_error', $json->error));
|
1406 |
+
} elseif (!isset($json->data)) {
|
1407 |
+
return (new WP_Error('api_error', 'no_data'));
|
1408 |
+
}
|
1409 |
+
|
1410 |
+
if (!empty($json->data)) {
|
1411 |
+
return $json->data;
|
1412 |
+
}
|
1413 |
+
|
1414 |
+
return false;
|
1415 |
+
}
|
1416 |
+
|
1417 |
+
/**
|
1418 |
+
* Delete the Audit Page
|
1419 |
+
*
|
1420 |
+
* @param array $args
|
1421 |
+
* @return bool|WP_Error
|
1422 |
+
*/
|
1423 |
+
public static function deleteAuditPage($args = array())
|
1424 |
+
{
|
1425 |
+
self::$apimethod = 'post'; //post call
|
1426 |
+
|
1427 |
+
if (isset($args['user_post_id']) && $args['user_post_id'] > 0) {
|
1428 |
+
|
1429 |
+
$json = json_decode(self::apiCall('api/posts/remove-audit/' . $args['user_post_id']));
|
1430 |
+
|
1431 |
+
if (isset($json->error) && $json->error <> '') {
|
1432 |
+
return (new WP_Error('api_error', $json->error));
|
1433 |
+
} elseif (!isset($json->data)) {
|
1434 |
+
return (new WP_Error('api_error', 'no_data'));
|
1435 |
+
}
|
1436 |
+
|
1437 |
+
if (!empty($json->data)) {
|
1438 |
+
return $json->data;
|
1439 |
+
}
|
1440 |
+
|
1441 |
+
}
|
1442 |
+
return false;
|
1443 |
+
}
|
1444 |
+
|
1445 |
+
/********************
|
1446 |
+
*
|
1447 |
+
* OTHERS
|
1448 |
+
*****************************/
|
1449 |
+
public static function saveSettings($args)
|
1450 |
+
{
|
1451 |
+
self::$apimethod = 'post'; //call method
|
1452 |
+
|
1453 |
+
self::apiCall('api/user/settings', array('settings' => wp_json_encode($args)));
|
1454 |
+
}
|
1455 |
+
|
1456 |
+
/**
|
1457 |
+
* Get the Facebook APi Code
|
1458 |
+
*
|
1459 |
+
* @param $args
|
1460 |
+
* @return bool|WP_Error
|
1461 |
+
*/
|
1462 |
+
public static function getFacebookApi($args)
|
1463 |
+
{
|
1464 |
+
self::$apimethod = 'get'; //call method
|
1465 |
+
|
1466 |
+
$json = json_decode(self::apiCall('api/tools/facebook', $args));
|
1467 |
+
|
1468 |
+
if (isset($json->error) && $json->error <> '') {
|
1469 |
+
return (new WP_Error('api_error', $json->error));
|
1470 |
+
} elseif (!isset($json->data)) {
|
1471 |
+
return (new WP_Error('api_error', 'no_data'));
|
1472 |
+
}
|
1473 |
+
|
1474 |
+
if (!empty($json->data)) {
|
1475 |
+
return $json->data;
|
1476 |
+
}
|
1477 |
+
|
1478 |
+
return false;
|
1479 |
+
|
1480 |
+
}
|
1481 |
+
|
1482 |
+
/**
|
1483 |
+
* Load the JS for API
|
1484 |
+
*/
|
1485 |
+
public static function loadJsVars()
|
1486 |
+
{
|
1487 |
+
global $post;
|
1488 |
+
$referer = '';
|
1489 |
+
|
1490 |
+
$metas = json_decode(wp_json_encode(SQ_Classes_Helpers_Tools::getOption('sq_metas')));
|
1491 |
+
$sq_postID = (isset($post->ID) ? $post->ID : 0);
|
1492 |
+
|
1493 |
+
//Load Squirrly Live Assistant for Elementor builder
|
1494 |
+
if (SQ_Classes_Helpers_Tools::isPluginInstalled('elementor/elementor.php')) {
|
1495 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_sla_frontend')) {
|
1496 |
+
$referer = get_post_meta($sq_postID, '_sq_sla', true);
|
1497 |
+
}
|
1498 |
+
}
|
1499 |
+
|
1500 |
+
echo '<script>
|
1501 |
+
var SQ_DEBUG = ' . (int)SQ_DEBUG . ';
|
1502 |
+
(function($){
|
1503 |
+
$.sq_config = {
|
1504 |
+
sq_use: ' . (int)SQ_Classes_Helpers_Tools::getOption('sq_use') . ',
|
1505 |
+
sq_version: "' . esc_attr(SQ_VERSION) . '",
|
1506 |
+
sq_sla_type: "' . esc_attr(SQ_Classes_Helpers_Tools::getOption('sq_sla_type')) . '",
|
1507 |
+
token: "' . esc_attr(SQ_Classes_Helpers_Tools::getOption('sq_api')) . '",
|
1508 |
+
url_token: "' . (SQ_Classes_Helpers_Tools::getOption('sq_cloud_connect') ? esc_attr(SQ_Classes_Helpers_Tools::getOption('sq_cloud_token')) : false) . '",
|
1509 |
+
sq_baseurl: "' . esc_url(_SQ_STATIC_API_URL_) . '",
|
1510 |
+
sq_uri: "' . esc_attr(SQ_URI) . '",
|
1511 |
+
sq_apiurl: "' . esc_url(_SQ_APIV2_URL_) . '",
|
1512 |
+
user_url: "' . esc_url(apply_filters('sq_homeurl', get_bloginfo('url'))) . '",
|
1513 |
+
language: "' . esc_attr(apply_filters('sq_language', get_bloginfo('language'))) . '",
|
1514 |
+
referer: "' . esc_attr($referer) . '",
|
1515 |
+
sq_keywordtag: ' . (int)SQ_Classes_Helpers_Tools::getOption('sq_keywordtag') . ',
|
1516 |
+
sq_keyword_help: ' . (int)SQ_Classes_Helpers_Tools::getOption('sq_keyword_help') . ',
|
1517 |
+
frontend_css: "' . esc_url(_SQ_ASSETS_URL_ . 'css/frontend' . (SQ_DEBUG ? '' : '.min') . '.css') . '",
|
1518 |
+
postID: "' . (int)$sq_postID . '",
|
1519 |
+
prevNonce: "' . esc_attr(wp_create_nonce('post_preview_' . $sq_postID)) . '",
|
1520 |
+
__keyword: "' . esc_html__('Keyword:', 'squirrly-seo') . '",
|
1521 |
+
__date: "' . esc_html__('date', 'squirrly-seo') . '",
|
1522 |
+
__noconnection: "' . esc_html__("To load the Live Assistant and optimize this page, click to connect to Squirrly Cloud.", 'squirrly-seo') . '",
|
1523 |
+
__saved: "' . esc_html__('Saved!', 'squirrly-seo') . '",
|
1524 |
+
__readit: "' . esc_html__('Read it!', 'squirrly-seo') . '",
|
1525 |
+
__insertit: "' . esc_html__('Insert it!', 'squirrly-seo') . '",
|
1526 |
+
__reference: "' . esc_html__('Reference', 'squirrly-seo') . '",
|
1527 |
+
__insertasbox: "' . esc_html__('Insert as box', 'squirrly-seo') . '",
|
1528 |
+
__addlink: "' . esc_html__('Insert Link', 'squirrly-seo') . '",
|
1529 |
+
__notrelevant: "' . esc_html__('Not relevant?', 'squirrly-seo') . '",
|
1530 |
+
__insertparagraph: "' . esc_html__('Insert in your article', 'squirrly-seo') . '",
|
1531 |
+
__ajaxerror: "' . esc_html__(':( An error occurred while processing your request. Please try again', 'squirrly-seo') . '",
|
1532 |
+
__nofound: "' . esc_html__('No results found!', 'squirrly-seo') . '",
|
1533 |
+
__sq_photo_copyright: "' . esc_html__('[ ATTRIBUTE: Please check: %s to find out how to attribute this image ]', 'squirrly-seo') . '",
|
1534 |
+
__has_attributes: "' . esc_html__('Has creative commons attributes', 'squirrly-seo') . '",
|
1535 |
+
__no_attributes: "' . esc_html__('No known copyright restrictions', 'squirrly-seo') . '",
|
1536 |
+
__noopt: "' . esc_html__('You haven`t used Squirrly SEO to optimize your article. Do you want to optimize for a keyword before publishing?', 'squirrly-seo') . '",
|
1537 |
+
__subscription_expired: "' . esc_html__('Your Subscription has Expired', 'squirrly-seo') . '",
|
1538 |
+
__no_briefcase: "' . esc_html__('There are no keywords saved in briefcase yet', 'squirrly-seo') . '",
|
1539 |
+
__fulloptimized: "' . esc_html__('Congratulations! Your article is 100% optimized!', 'squirrly-seo') . '",
|
1540 |
+
__toomanytimes: "' . esc_html__('appears too many times. Try to remove %s of them', 'squirrly-seo') . '",
|
1541 |
+
__writemorewords: "' . esc_html__('write %s more words', 'squirrly-seo') . '",
|
1542 |
+
__keywordinintroduction: "' . esc_html__('Add the keyword in the %s of your article', 'squirrly-seo') . '",
|
1543 |
+
__clicktohighlight: "' . esc_html__('Click to keep the highlight on', 'squirrly-seo') . '",
|
1544 |
+
__introduction: "' . esc_html__('introduction', 'squirrly-seo') . '",
|
1545 |
+
__morewordsafter: "' . esc_html__('Write more words after the %s keyword', 'squirrly-seo') . '",
|
1546 |
+
__orusesynonyms: "' . esc_html__('or use synonyms', 'squirrly-seo') . '",
|
1547 |
+
__addmorewords: "' . esc_html__('add %s more word(s)', 'squirrly-seo') . '",
|
1548 |
+
__removewords: "' . esc_html__('or remove %s word(s)', 'squirrly-seo') . '",
|
1549 |
+
__addmorekeywords: "' . esc_html__('add the selected keyword %s more time(s) ', 'squirrly-seo') . '",
|
1550 |
+
__addminimumwords: "' . esc_html__('write %s more words to start calculating', 'squirrly-seo') . '",
|
1551 |
+
__add_to_briefcase: "' . esc_html__('Add to Briefcase', 'squirrly-seo') . '",
|
1552 |
+
__add_keyword_briefcase: "' . esc_html__('Add Keyword to Briefcase', 'squirrly-seo') . '",
|
1553 |
+
__usekeyword: "' . esc_html__('Select', 'squirrly-seo') . '",
|
1554 |
+
__new_post_title: "' . esc_html__('Auto Draft') . '",
|
1555 |
+
__enter_keyword: "' . esc_html__('Enter keyword above and press ENTER', 'squirrly-seo') . '",
|
1556 |
+
__add_keyword: "' . esc_html__('Add Keywords from Briefcase', 'squirrly-seo') . '",
|
1557 |
+
__frontend_optimized: "' . esc_html__('Live Assistant was used to optimize this page with the Page Builder. Please go back and resume your optimization work there.', 'squirrly-seo') . '",
|
1558 |
+
};
|
1559 |
+
$.sq_params = {
|
1560 |
+
max_length_title: ' . (int)$metas->title_maxlength . ',
|
1561 |
+
max_length_description: ' . (int)$metas->description_maxlength . ',
|
1562 |
+
};
|
1563 |
+
|
1564 |
+
|
1565 |
+
})(jQuery);
|
1566 |
+
</script>';
|
1567 |
+
|
1568 |
+
echo '<script src="' . esc_url(_SQ_STATIC_API_URL_ . SQ_URI . '/js/squirrly' . (SQ_DEBUG ? '' : '.min') . '.js?ver=' . SQ_VERSION) . '"></script>';
|
1569 |
+
|
1570 |
+
}
|
1571 |
+
|
1572 |
+
}
|
classes/helpers/DevKit.php
CHANGED
@@ -1,302 +1,327 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Classes_Helpers_DevKit
|
5 |
-
|
6 |
-
|
7 |
-
public static $
|
8 |
-
public static $
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
add_filter('
|
31 |
-
add_filter('
|
32 |
-
add_filter('
|
33 |
-
add_filter('
|
34 |
-
add_filter('
|
35 |
-
add_filter('
|
36 |
-
add_filter('
|
37 |
-
add_filter('
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
*
|
46 |
-
*
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
}
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
*
|
164 |
-
* @param
|
165 |
-
* @return
|
166 |
-
*/
|
167 |
-
public function
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
*
|
179 |
-
*
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
$
|
214 |
-
}
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
$menu['
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
$menu['
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
$menu['
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
}
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Classes_Helpers_DevKit
|
5 |
+
{
|
6 |
+
|
7 |
+
public static $plugin;
|
8 |
+
public static $options;
|
9 |
+
public static $package;
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
|
14 |
+
if(SQ_Classes_Helpers_DevKit::getOption('sq_auto_devkit')) {
|
15 |
+
|
16 |
+
if (SQ_Classes_Helpers_DevKit::getOption('sq_devkit_name') <> '') {
|
17 |
+
if (isset($_SERVER['REQUEST_URI']) && function_exists('get_plugin_data')) {
|
18 |
+
if (strpos($_SERVER['REQUEST_URI'], '/plugins.php') !== false) {
|
19 |
+
$data = get_plugin_data(_SQ_ROOT_DIR_ . 'squirrly.php');
|
20 |
+
if (isset($data['Name'])) {
|
21 |
+
self::$plugin['name'] = $data['Name'];
|
22 |
+
add_filter('pre_kses', array($this, 'changeString'), 1, 1);
|
23 |
+
}
|
24 |
+
}
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
//Hook DevKit options
|
29 |
+
if (SQ_Classes_Helpers_DevKit::getOption('sq_api')) {
|
30 |
+
add_filter('admin_head', array($this, 'hookHead'));
|
31 |
+
add_filter('sq_menu', array($this, 'manageMenu'));
|
32 |
+
add_filter('sq_features', array($this, 'manageFeatures'));
|
33 |
+
add_filter('sq_logo', array($this, 'getCustomLogo'));
|
34 |
+
add_filter('sq_name', array($this, 'getCustomName'));
|
35 |
+
add_filter('sq_menu_name', array($this, 'getCustomMenuName'));
|
36 |
+
add_filter('sq_audit_success_task', array($this, 'getCustomAuditSuccessTask'));
|
37 |
+
add_filter('sq_audit_fail_task', array($this, 'getCustomAuditFailTask'));
|
38 |
+
add_filter('sq_seo_errors', array($this, 'getSEOErrors'));
|
39 |
+
add_filter('sq_menu_visible', array($this, 'getDevKitMenuVisible'), 11, 2);
|
40 |
+
}
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Show the devkit menu from the main website on wp multisite
|
46 |
+
*
|
47 |
+
* @param $value
|
48 |
+
* @param $key
|
49 |
+
* @return bool
|
50 |
+
*/
|
51 |
+
public function getDevKitMenuVisible($value, $key)
|
52 |
+
{
|
53 |
+
|
54 |
+
if (isset(self::$options['menu'][$key])) {
|
55 |
+
return self::$options['menu'][$key];
|
56 |
+
}
|
57 |
+
|
58 |
+
return true;
|
59 |
+
}
|
60 |
+
|
61 |
+
//Check if Next SEO Goals are active
|
62 |
+
public function getSEOErrors($errors)
|
63 |
+
{
|
64 |
+
if (SQ_Classes_Helpers_Tools::getMenuVisible('show_seogoals')) {
|
65 |
+
return $errors;
|
66 |
+
}
|
67 |
+
|
68 |
+
return 0;
|
69 |
+
}
|
70 |
+
|
71 |
+
public static function getOptions()
|
72 |
+
{
|
73 |
+
if (is_multisite()) {
|
74 |
+
self::$options = json_decode(get_blog_option(get_main_site_id(), SQ_OPTION), true);
|
75 |
+
} else {
|
76 |
+
self::$options = json_decode(get_option(SQ_OPTION), true);
|
77 |
+
}
|
78 |
+
|
79 |
+
return self::$options;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Get the option from database
|
84 |
+
*
|
85 |
+
* @param $key
|
86 |
+
* @return mixed
|
87 |
+
*/
|
88 |
+
public static function getOption($key)
|
89 |
+
{
|
90 |
+
if (!isset(self::$options[$key])) {
|
91 |
+
self::$options = self::getOptions();
|
92 |
+
|
93 |
+
if (!isset(self::$options[$key])) {
|
94 |
+
self::$options[$key] = false;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
return self::$options[$key];
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Customize the Audit task
|
103 |
+
*
|
104 |
+
* @param $task
|
105 |
+
* @return mixed
|
106 |
+
*/
|
107 |
+
public function getCustomAuditSuccessTask($task)
|
108 |
+
{
|
109 |
+
|
110 |
+
if (SQ_Classes_Helpers_DevKit::getOption('sq_devkit_audit_success')) {
|
111 |
+
if ($customTask = SQ_Classes_Helpers_DevKit::getOption('sq_devkit_audit_success')) {
|
112 |
+
foreach ($customTask as $key => $value) {
|
113 |
+
if ($value <> '' || $value === false) {
|
114 |
+
$task->$key = stripslashes($value);
|
115 |
+
}
|
116 |
+
}
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
return $task;
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Customize the Audit task
|
125 |
+
*
|
126 |
+
* @param $task
|
127 |
+
* @return mixed
|
128 |
+
*/
|
129 |
+
public function getCustomAuditFailTask($task)
|
130 |
+
{
|
131 |
+
|
132 |
+
if (SQ_Classes_Helpers_DevKit::getOption('sq_devkit_audit_fail')) {
|
133 |
+
if ($customTask = SQ_Classes_Helpers_DevKit::getOption('sq_devkit_audit_fail')) {
|
134 |
+
foreach ($customTask as $key => $value) {
|
135 |
+
if ($value <> '' || $value === false) {
|
136 |
+
$task->$key = stripslashes($value);
|
137 |
+
}
|
138 |
+
}
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
return $task;
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Hook the head
|
147 |
+
*/
|
148 |
+
public function hookHead()
|
149 |
+
{
|
150 |
+
//Hide the ads
|
151 |
+
if (!SQ_Classes_Helpers_Tools::getMenuVisible('show_ads')) {
|
152 |
+
echo '<style>.sq_offer{display: none !important;}</style>';
|
153 |
+
}
|
154 |
+
|
155 |
+
//Dev Kit images
|
156 |
+
if (SQ_Classes_Helpers_DevKit::getOption('sq_devkit_logo')) {
|
157 |
+
echo '<style>.sq_logo{background-image:url("' . SQ_Classes_Helpers_DevKit::getOption('sq_devkit_logo') . '") !important;}#sq_blocksnippet .postbox-header h2:before,li.toplevel_page_sq_dashboard .wp-menu-image:before{background-image:url("' . SQ_Classes_Helpers_DevKit::getOption('sq_devkit_logo') . '") !important;}.components-squirrly-icon img{content:url("' . SQ_Classes_Helpers_DevKit::getOption('sq_devkit_logo') . '") !important;}.menu-top.toplevel_page_sq_dashboard .wp-menu-image:before {content: " ";width: 24px !important;height: 24px !important;display: inline-block;vertical-align: middle !important;line-height: inherit;background-repeat: no-repeat;background-position: center;background-size: 100%;}li.toplevel_page_sq_dashboard .wp-menu-image img{display: none !important;}</style>';
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Change the Squirrly SEO logo in DevKit
|
163 |
+
*
|
164 |
+
* @param $logo
|
165 |
+
* @return mixed
|
166 |
+
*/
|
167 |
+
public function getCustomLogo($logo)
|
168 |
+
{
|
169 |
+
|
170 |
+
if (SQ_Classes_Helpers_DevKit::getOption('sq_devkit_logo')) {
|
171 |
+
$logo = SQ_Classes_Helpers_DevKit::getOption('sq_devkit_logo');
|
172 |
+
}
|
173 |
+
|
174 |
+
return $logo;
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Get Plugin Custom Name
|
179 |
+
*
|
180 |
+
* @param $name
|
181 |
+
* @return string
|
182 |
+
*/
|
183 |
+
public function getCustomName($name)
|
184 |
+
{
|
185 |
+
|
186 |
+
if (SQ_Classes_Helpers_DevKit::getOption('sq_devkit_name')) {
|
187 |
+
$name = SQ_Classes_Helpers_DevKit::getOption('sq_devkit_name');
|
188 |
+
}
|
189 |
+
|
190 |
+
return $name;
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Get Plugin Custom Menu Name
|
195 |
+
*
|
196 |
+
* @param $name
|
197 |
+
* @return string
|
198 |
+
*/
|
199 |
+
public function getCustomMenuName($name)
|
200 |
+
{
|
201 |
+
|
202 |
+
if (SQ_Classes_Helpers_DevKit::getOption('sq_devkit_menu_name')) {
|
203 |
+
$name = SQ_Classes_Helpers_DevKit::getOption('sq_devkit_menu_name');
|
204 |
+
}
|
205 |
+
|
206 |
+
return $name;
|
207 |
+
}
|
208 |
+
|
209 |
+
//Change the features
|
210 |
+
public function manageFeatures($features)
|
211 |
+
{
|
212 |
+
if (!SQ_Classes_Helpers_Tools::getMenuVisible('show_panel')) {
|
213 |
+
unset($features[0]); //remove the Cloud App features
|
214 |
+
}
|
215 |
+
|
216 |
+
return $features;
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Manage the menu visibility
|
221 |
+
*/
|
222 |
+
public function manageMenu($menu)
|
223 |
+
{
|
224 |
+
if (!SQ_Classes_Helpers_Tools::getMenuVisible('show_tutorial')) {
|
225 |
+
$menu['sq_onboarding']['leftmenu'] = false;
|
226 |
+
$menu['sq_onboarding']['topmenu'] = false;
|
227 |
+
}
|
228 |
+
if (!SQ_Classes_Helpers_Tools::getMenuVisible('show_audit')) {
|
229 |
+
$menu['sq_audits']['leftmenu'] = false;
|
230 |
+
$menu['sq_audits']['topmenu'] = false;
|
231 |
+
}
|
232 |
+
if (!SQ_Classes_Helpers_Tools::getMenuVisible('show_rankings')) {
|
233 |
+
$menu['sq_rankings']['leftmenu'] = false;
|
234 |
+
$menu['sq_rankings']['topmenu'] = false;
|
235 |
+
}
|
236 |
+
if (!SQ_Classes_Helpers_Tools::getMenuVisible('show_focuspages')) {
|
237 |
+
$menu['sq_focuspages']['leftmenu'] = false;
|
238 |
+
$menu['sq_focuspages']['topmenu'] = false;
|
239 |
+
}
|
240 |
+
if (!SQ_Classes_Helpers_Tools::getMenuVisible('show_bulkseo')) {
|
241 |
+
$menu['sq_bulkseo']['leftmenu'] = false;
|
242 |
+
$menu['sq_bulkseo']['topmenu'] = false;
|
243 |
+
}
|
244 |
+
if (!SQ_Classes_Helpers_Tools::getMenuVisible('show_assistant')) {
|
245 |
+
$menu['sq_assistant']['leftmenu'] = false;
|
246 |
+
$menu['sq_assistant']['topmenu'] = false;
|
247 |
+
}
|
248 |
+
if (!SQ_Classes_Helpers_Tools::getMenuVisible('show_research')) {
|
249 |
+
$menu['sq_research']['leftmenu'] = false;
|
250 |
+
$menu['sq_research']['topmenu'] = false;
|
251 |
+
}
|
252 |
+
if (!SQ_Classes_Helpers_Tools::getMenuVisible('show_account_info')) {
|
253 |
+
$menu['sq_account']['leftmenu'] = false;
|
254 |
+
$menu['sq_account']['topmenu'] = false;
|
255 |
+
}
|
256 |
+
|
257 |
+
return $menu;
|
258 |
+
}
|
259 |
+
|
260 |
+
/**
|
261 |
+
* Check if Dev Kit is installed
|
262 |
+
*
|
263 |
+
* @return bool
|
264 |
+
*/
|
265 |
+
public function updatePluginData()
|
266 |
+
{
|
267 |
+
|
268 |
+
$wp_filesystem = SQ_Classes_Helpers_Tools::initFilesystem();
|
269 |
+
|
270 |
+
$package_file = _SQ_ROOT_DIR_ . 'package.json';
|
271 |
+
if (!$wp_filesystem->exists($package_file)) {
|
272 |
+
return false;
|
273 |
+
}
|
274 |
+
|
275 |
+
/* load configuration blocks data from core config files */
|
276 |
+
$config = json_decode($wp_filesystem->get_contents($package_file), 1);
|
277 |
+
if (isset($config['package'])) {
|
278 |
+
self::$package = $config['package'];
|
279 |
+
|
280 |
+
if (isset(self::$package['settings']) && !empty(SQ_Classes_Helpers_Tools::$options) && function_exists('array_replace_recursive')) {
|
281 |
+
SQ_Classes_Helpers_Tools::$options = array_replace_recursive((array)SQ_Classes_Helpers_Tools::$options, (array)self::$package['settings']);
|
282 |
+
|
283 |
+
SQ_Classes_Helpers_Tools::saveOptions();
|
284 |
+
unlink($package_file);
|
285 |
+
|
286 |
+
if (SQ_Classes_Helpers_Tools::getMenuVisible('show_tutorial')) {
|
287 |
+
wp_redirect(SQ_Classes_Helpers_Tools::getAdminUrl('sq_onboarding'));
|
288 |
+
die();
|
289 |
+
} else {
|
290 |
+
wp_redirect(SQ_Classes_Helpers_Tools::getAdminUrl('sq_dashboard'));
|
291 |
+
die();
|
292 |
+
}
|
293 |
+
}
|
294 |
+
}
|
295 |
+
|
296 |
+
|
297 |
+
//remove the package after activation
|
298 |
+
unlink($package_file);
|
299 |
+
|
300 |
+
return true;
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Change the plugin name
|
305 |
+
*
|
306 |
+
* @param $string
|
307 |
+
* @return mixed
|
308 |
+
*/
|
309 |
+
public function changeString($string)
|
310 |
+
{
|
311 |
+
if (isset(self::$plugin['name'])) {
|
312 |
+
return str_replace(self::$plugin['name'], apply_filters('sq_name', self::$plugin['name']), $string);
|
313 |
+
}
|
314 |
+
return $string;
|
315 |
+
}
|
316 |
+
|
317 |
+
//Get the package info in case of custom details
|
318 |
+
public function getPackageInfo($key)
|
319 |
+
{
|
320 |
+
if (isset(self::$package[$key])) {
|
321 |
+
return self::$package[$key];
|
322 |
+
}
|
323 |
+
|
324 |
+
return false;
|
325 |
+
}
|
326 |
+
|
327 |
+
}
|
classes/helpers/Sanitize.php
CHANGED
@@ -1,553 +1,605 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Classes_Helpers_Sanitize
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
*
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
$
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
'
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
'
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
'
|
167 |
-
'
|
168 |
-
'
|
169 |
-
'
|
170 |
-
'
|
171 |
-
'
|
172 |
-
'
|
173 |
-
'
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
$code =
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
}
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
*
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
$code
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
return $
|
403 |
-
}
|
404 |
-
|
405 |
-
/**
|
406 |
-
* Check the
|
407 |
-
*
|
408 |
-
* @
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
if ($
|
413 |
-
$
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
$
|
419 |
-
}
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
$account
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
*
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
}
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Classes_Helpers_Sanitize
|
5 |
+
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Escape the parameter for html
|
9 |
+
*
|
10 |
+
* @param $key
|
11 |
+
* @return string|void
|
12 |
+
*/
|
13 |
+
public static function escapeGetValue($key)
|
14 |
+
{
|
15 |
+
return esc_attr(SQ_Classes_Helpers_Tools::getValue($key));
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Clear the title string
|
20 |
+
*
|
21 |
+
* @param $title
|
22 |
+
* @return mixed|null|string|string[]
|
23 |
+
*/
|
24 |
+
public static function clearTitle($title)
|
25 |
+
{
|
26 |
+
if ($title <> '') {
|
27 |
+
if (function_exists('preg_replace')) {
|
28 |
+
$search = array(
|
29 |
+
"/[\n\r]/si",
|
30 |
+
"/[\n]/si",
|
31 |
+
"/ /si",
|
32 |
+
"/\[[^\]]+\]/si",
|
33 |
+
"/\s{2,}/",
|
34 |
+
);
|
35 |
+
$title = preg_replace($search, " ", $title);
|
36 |
+
}
|
37 |
+
|
38 |
+
$title = SQ_Classes_Helpers_Sanitize::i18n(trim(esc_html(ent2ncr(strip_tags($title)))));
|
39 |
+
|
40 |
+
}
|
41 |
+
return $title;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Clear description
|
46 |
+
*
|
47 |
+
* @param $description
|
48 |
+
* @return null|string|string[]
|
49 |
+
*/
|
50 |
+
public static function clearDescription($description)
|
51 |
+
{
|
52 |
+
if ($description <> '') {
|
53 |
+
if (function_exists('preg_replace')) {
|
54 |
+
$search = array(
|
55 |
+
"'<!--(.*?)-->'is",
|
56 |
+
"'<script[^>]*?>.*?<\/script>'si", // strip out javascript
|
57 |
+
"'<style[^>]*?>.*?<\/style>'si", // strip out styles
|
58 |
+
"'<form.*?<\/form>'si",
|
59 |
+
"'<iframe.*?<\/iframe>'si",
|
60 |
+
"'<!--(.*?)-->'is",
|
61 |
+
"'<script>.*?<\/script>'si", // strip out javascript
|
62 |
+
"'<style>.*?<\/style>'si", // strip out styles
|
63 |
+
);
|
64 |
+
$description = preg_replace($search, "", $description);
|
65 |
+
$search = array(
|
66 |
+
"/[\n\r]/si",
|
67 |
+
"/[\n]/si",
|
68 |
+
"/ /si",
|
69 |
+
"/\[[^\]]+\]/si",
|
70 |
+
"/\s{2,}/",
|
71 |
+
);
|
72 |
+
$description = preg_replace($search, " ", $description);
|
73 |
+
}
|
74 |
+
|
75 |
+
$description = SQ_Classes_Helpers_Sanitize::i18n(trim(esc_html(ent2ncr(strip_tags($description)))));
|
76 |
+
}
|
77 |
+
|
78 |
+
return $description;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Clear the keywords
|
83 |
+
*
|
84 |
+
* @param $keywords
|
85 |
+
* @return mixed|null|string|string[]
|
86 |
+
*/
|
87 |
+
public static function clearKeywords($keywords)
|
88 |
+
{
|
89 |
+
return self::clearTitle($keywords);
|
90 |
+
}
|
91 |
+
|
92 |
+
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Escape the keyword for tags and urls
|
96 |
+
*
|
97 |
+
* @param $keyword
|
98 |
+
* @param string $for
|
99 |
+
* @return string|void
|
100 |
+
*/
|
101 |
+
public static function escapeKeyword($keyword, $for = 'all')
|
102 |
+
{
|
103 |
+
switch ($for){
|
104 |
+
case 'url':
|
105 |
+
$keyword = urlencode(esc_attr($keyword));
|
106 |
+
break;
|
107 |
+
case 'attr':
|
108 |
+
$keyword = htmlspecialchars(str_replace('"', '\"', $keyword));
|
109 |
+
break;
|
110 |
+
default:
|
111 |
+
$keyword = esc_attr($keyword);
|
112 |
+
}
|
113 |
+
return $keyword;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Truncate the text
|
118 |
+
*
|
119 |
+
* @param $text
|
120 |
+
* @param int $min
|
121 |
+
* @param int $max
|
122 |
+
* @return bool|mixed|null|string|string[]
|
123 |
+
*/
|
124 |
+
public static function truncate($text, $min = 100, $max = 110)
|
125 |
+
{
|
126 |
+
//make sure they are values
|
127 |
+
$max = (int)$max;
|
128 |
+
$min = (int)$min;
|
129 |
+
|
130 |
+
if ($max > 0 && $text <> '' && strlen($text) > $max) {
|
131 |
+
if (function_exists('strip_tags')) {
|
132 |
+
$text = strip_tags($text);
|
133 |
+
}
|
134 |
+
|
135 |
+
$text = str_replace(']]>', ']]>', $text);
|
136 |
+
$text = preg_replace('/\[(.+?)\]/is', '', $text);
|
137 |
+
|
138 |
+
if ($max < strlen($text)) {
|
139 |
+
while ($text[$max] != ' ' && $max > $min) {
|
140 |
+
$max--;
|
141 |
+
}
|
142 |
+
}
|
143 |
+
|
144 |
+
//Use internation truncate
|
145 |
+
if (function_exists('mb_substr')) {
|
146 |
+
$text = mb_substr($text, 0, $max);
|
147 |
+
} else {
|
148 |
+
$text = substr($text, 0, $max);
|
149 |
+
}
|
150 |
+
|
151 |
+
return trim(stripcslashes($text));
|
152 |
+
}
|
153 |
+
|
154 |
+
return $text;
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Replace language-specific characters by ASCII-equivalents.
|
159 |
+
*
|
160 |
+
* @param string $s
|
161 |
+
* @return string
|
162 |
+
*/
|
163 |
+
public static function normalizeChars($s)
|
164 |
+
{
|
165 |
+
$replace = array(
|
166 |
+
'ъ'=>'-', 'Ь'=>'-', 'Ъ'=>'-', 'ь'=>'-',
|
167 |
+
'Ă'=>'A', 'Ą'=>'A', 'À'=>'A', 'Ã'=>'A', 'Á'=>'A', 'Æ'=>'A', 'Â'=>'A', 'Å'=>'A', 'Ä'=>'Ae',
|
168 |
+
'Þ'=>'B',
|
169 |
+
'Ć'=>'C', 'ץ'=>'C', 'Ç'=>'C',
|
170 |
+
'È'=>'E', 'Ę'=>'E', 'É'=>'E', 'Ë'=>'E', 'Ê'=>'E',
|
171 |
+
'Ğ'=>'G',
|
172 |
+
'İ'=>'I', 'Ï'=>'I', 'Î'=>'I', 'Í'=>'I', 'Ì'=>'I',
|
173 |
+
'Ł'=>'L',
|
174 |
+
'Ñ'=>'N', 'Ń'=>'N',
|
175 |
+
'Ø'=>'O', 'Ó'=>'O', 'Ò'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'Oe',
|
176 |
+
'Ş'=>'S', 'Ś'=>'S', 'Ș'=>'S', 'Š'=>'S',
|
177 |
+
'Ț'=>'T',
|
178 |
+
'Ù'=>'U', 'Û'=>'U', 'Ú'=>'U', 'Ü'=>'Ue',
|
179 |
+
'Ý'=>'Y',
|
180 |
+
'Ź'=>'Z', 'Ž'=>'Z', 'Ż'=>'Z',
|
181 |
+
'â'=>'a', 'ǎ'=>'a', 'ą'=>'a', 'á'=>'a', 'ă'=>'a', 'ã'=>'a', 'Ǎ'=>'a', 'а'=>'a', 'А'=>'a', 'å'=>'a', 'à'=>'a', 'א'=>'a', 'Ǻ'=>'a', 'Ā'=>'a', 'ǻ'=>'a', 'ā'=>'a', 'ä'=>'ae', 'æ'=>'ae', 'Ǽ'=>'ae', 'ǽ'=>'ae',
|
182 |
+
'б'=>'b', 'ב'=>'b', 'Б'=>'b', 'þ'=>'b',
|
183 |
+
'ĉ'=>'c', 'Ĉ'=>'c', 'Ċ'=>'c', 'ć'=>'c', 'ç'=>'c', 'ц'=>'c', 'צ'=>'c', 'ċ'=>'c', 'Ц'=>'c', 'Č'=>'c', 'č'=>'c', 'Ч'=>'ch', 'ч'=>'ch',
|
184 |
+
'ד'=>'d', 'ď'=>'d', 'Đ'=>'d', 'Ď'=>'d', 'đ'=>'d', 'д'=>'d', 'Д'=>'D', 'ð'=>'d',
|
185 |
+
'є'=>'e', 'ע'=>'e', 'е'=>'e', 'Е'=>'e', 'Ə'=>'e', 'ę'=>'e', 'ĕ'=>'e', 'ē'=>'e', 'Ē'=>'e', 'Ė'=>'e', 'ė'=>'e', 'ě'=>'e', 'Ě'=>'e', 'Є'=>'e', 'Ĕ'=>'e', 'ê'=>'e', 'ə'=>'e', 'è'=>'e', 'ë'=>'e', 'é'=>'e',
|
186 |
+
'ф'=>'f', 'ƒ'=>'f', 'Ф'=>'f',
|
187 |
+
'ġ'=>'g', 'Ģ'=>'g', 'Ġ'=>'g', 'Ĝ'=>'g', 'Г'=>'g', 'г'=>'g', 'ĝ'=>'g', 'ğ'=>'g', 'ג'=>'g', 'Ґ'=>'g', 'ґ'=>'g', 'ģ'=>'g',
|
188 |
+
'ח'=>'h', 'ħ'=>'h', 'Х'=>'h', 'Ħ'=>'h', 'Ĥ'=>'h', 'ĥ'=>'h', 'х'=>'h', 'ה'=>'h',
|
189 |
+
'î'=>'i', 'ï'=>'i', 'í'=>'i', 'ì'=>'i', 'į'=>'i', 'ĭ'=>'i', 'ı'=>'i', 'Ĭ'=>'i', 'И'=>'i', 'ĩ'=>'i', 'ǐ'=>'i', 'Ĩ'=>'i', 'Ǐ'=>'i', 'и'=>'i', 'Į'=>'i', 'י'=>'i', 'Ї'=>'i', 'Ī'=>'i', 'І'=>'i', 'ї'=>'i', 'і'=>'i', 'ī'=>'i', 'ij'=>'ij', 'IJ'=>'ij',
|
190 |
+
'й'=>'j', 'Й'=>'j', 'Ĵ'=>'j', 'ĵ'=>'j', 'я'=>'ja', 'Я'=>'ja', 'Э'=>'je', 'э'=>'je', 'ё'=>'jo', 'Ё'=>'jo', 'ю'=>'ju', 'Ю'=>'ju',
|
191 |
+
'ĸ'=>'k', 'כ'=>'k', 'Ķ'=>'k', 'К'=>'k', 'к'=>'k', 'ķ'=>'k', 'ך'=>'k',
|
192 |
+
'Ŀ'=>'l', 'ŀ'=>'l', 'Л'=>'l', 'ł'=>'l', 'ļ'=>'l', 'ĺ'=>'l', 'Ĺ'=>'l', 'Ļ'=>'l', 'л'=>'l', 'Ľ'=>'l', 'ľ'=>'l', 'ל'=>'l',
|
193 |
+
'מ'=>'m', 'М'=>'m', 'ם'=>'m', 'м'=>'m',
|
194 |
+
'ñ'=>'n', 'н'=>'n', 'Ņ'=>'n', 'ן'=>'n', 'ŋ'=>'n', 'נ'=>'n', 'Н'=>'n', 'ń'=>'n', 'Ŋ'=>'n', 'ņ'=>'n', 'ʼn'=>'n', 'Ň'=>'n', 'ň'=>'n',
|
195 |
+
'о'=>'o', 'О'=>'o', 'ő'=>'o', 'õ'=>'o', 'ô'=>'o', 'Ő'=>'o', 'ŏ'=>'o', 'Ŏ'=>'o', 'Ō'=>'o', 'ō'=>'o', 'ø'=>'o', 'ǿ'=>'o', 'ǒ'=>'o', 'ò'=>'o', 'Ǿ'=>'o', 'Ǒ'=>'o', 'ơ'=>'o', 'ó'=>'o', 'Ơ'=>'o', 'œ'=>'oe', 'Œ'=>'oe', 'ö'=>'oe',
|
196 |
+
'פ'=>'p', 'ף'=>'p', 'п'=>'p', 'П'=>'p',
|
197 |
+
'ק'=>'q',
|
198 |
+
'ŕ'=>'r', 'ř'=>'r', 'Ř'=>'r', 'ŗ'=>'r', 'Ŗ'=>'r', 'ר'=>'r', 'Ŕ'=>'r', 'Р'=>'r', 'р'=>'r',
|
199 |
+
'ș'=>'s', 'с'=>'s', 'Ŝ'=>'s', 'š'=>'s', 'ś'=>'s', 'ס'=>'s', 'ş'=>'s', 'С'=>'s', 'ŝ'=>'s', 'Щ'=>'sch', 'щ'=>'sch', 'ш'=>'sh', 'Ш'=>'sh', 'ß'=>'ss',
|
200 |
+
'т'=>'t', 'ט'=>'t', 'ŧ'=>'t', 'ת'=>'t', 'ť'=>'t', 'ţ'=>'t', 'Ţ'=>'t', 'Т'=>'t', 'ț'=>'t', 'Ŧ'=>'t', 'Ť'=>'t', '™'=>'tm',
|
201 |
+
'ū'=>'u', 'у'=>'u', 'Ũ'=>'u', 'ũ'=>'u', 'Ư'=>'u', 'ư'=>'u', 'Ū'=>'u', 'Ǔ'=>'u', 'ų'=>'u', 'Ų'=>'u', 'ŭ'=>'u', 'Ŭ'=>'u', 'Ů'=>'u', 'ů'=>'u', 'ű'=>'u', 'Ű'=>'u', 'Ǖ'=>'u', 'ǔ'=>'u', 'Ǜ'=>'u', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'У'=>'u', 'ǚ'=>'u', 'ǜ'=>'u', 'Ǚ'=>'u', 'Ǘ'=>'u', 'ǖ'=>'u', 'ǘ'=>'u', 'ü'=>'ue',
|
202 |
+
'в'=>'v', 'ו'=>'v', 'В'=>'v',
|
203 |
+
'ש'=>'w', 'ŵ'=>'w', 'Ŵ'=>'w',
|
204 |
+
'ы'=>'y', 'ŷ'=>'y', 'ý'=>'y', 'ÿ'=>'y', 'Ÿ'=>'y', 'Ŷ'=>'y',
|
205 |
+
'Ы'=>'y', 'ž'=>'z', 'З'=>'z', 'з'=>'z', 'ź'=>'z', 'ז'=>'z', 'ż'=>'z', 'ſ'=>'z', 'Ж'=>'zh', 'ж'=>'zh'
|
206 |
+
);
|
207 |
+
return strtr($s, $replace);
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Check the google code saved at settings
|
212 |
+
*
|
213 |
+
* @param string $code
|
214 |
+
* @return string
|
215 |
+
*/
|
216 |
+
public static function checkGoogleWTCode($code)
|
217 |
+
{
|
218 |
+
if ($code <> '') {
|
219 |
+
$code = stripslashes($code);
|
220 |
+
if (strpos($code, 'content') !== false) {
|
221 |
+
preg_match('/content\\s*=\\s*[\"]([^\"]+)[\"]/i', $code, $result);
|
222 |
+
if (isset($result[1]) && !empty($result[1])) $code = $result[1];
|
223 |
+
}
|
224 |
+
if (strpos($code, '"') !== false) {
|
225 |
+
preg_match('/[\"]([^\"]+)[\"]/i', $code, $result);
|
226 |
+
if (isset($result[1]) && !empty($result[1])) $code = $result[1];
|
227 |
+
}
|
228 |
+
|
229 |
+
if ($code == '') SQ_Classes_Error::setError(esc_html__("The code for Google Webmaster Tool is incorrect.", 'squirrly-seo'));
|
230 |
+
}
|
231 |
+
return $code;
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
* Check the google code saved at settings
|
236 |
+
*
|
237 |
+
* @param string $code
|
238 |
+
* @return string
|
239 |
+
*/
|
240 |
+
public static function checkGoogleAnalyticsCode($code)
|
241 |
+
{
|
242 |
+
if ($code <> '') {
|
243 |
+
$code = stripslashes($code);
|
244 |
+
|
245 |
+
if (strpos($code, 'GoogleAnalyticsObject') !== false) {
|
246 |
+
preg_match('/ga\(\'create\',[^\'"]*[\'"]([^\'"]+)[\'"],/i', $code, $result);
|
247 |
+
if (isset($result[1]) && !empty($result[1])) $code = $result[1];
|
248 |
+
}
|
249 |
+
|
250 |
+
if (strpos($code, '"') !== false) {
|
251 |
+
preg_match('/[\"]([^\"]+)[\"]/i', $code, $result);
|
252 |
+
if (isset($result[1]) && !empty($result[1])) $code = $result[1];
|
253 |
+
}
|
254 |
+
|
255 |
+
if (strpos($code, 'UA-') === false && strpos($code, 'G-') === false) {
|
256 |
+
$code = '';
|
257 |
+
SQ_Classes_Error::setError(esc_html__("The code for Google Analytics is incorrect.", 'squirrly-seo'));
|
258 |
+
}
|
259 |
+
}
|
260 |
+
return trim($code);
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Check the Facebook code saved at settings
|
265 |
+
*
|
266 |
+
* @param string $code
|
267 |
+
* @return string
|
268 |
+
*/
|
269 |
+
public static function checkFacebookAdminCode($code)
|
270 |
+
{
|
271 |
+
if ($code <> '') {
|
272 |
+
$code = trim($code);
|
273 |
+
|
274 |
+
if (strpos($code, 'facebook.com/') !== false) {
|
275 |
+
preg_match('/facebook.com\/([^\/]+)/i', $code, $result);
|
276 |
+
if (isset($result[1]) && !empty($result[1])) {
|
277 |
+
if (is_string($result[1])) {
|
278 |
+
$response = SQ_Classes_RemoteController::getFacebookApi(array('profile' => $result[1]));
|
279 |
+
if (!is_wp_error($response) && isset($response->code)) {
|
280 |
+
return $response->code;
|
281 |
+
}
|
282 |
+
} elseif (is_numeric($result[1])) {
|
283 |
+
return $result[1];
|
284 |
+
}
|
285 |
+
}
|
286 |
+
} elseif ($code <> (int)$code) {
|
287 |
+
$response = SQ_Classes_RemoteController::getFacebookApi(array('profile' => $code));
|
288 |
+
if (!is_wp_error($response) && isset($response->code)) {
|
289 |
+
return $response->code;
|
290 |
+
}
|
291 |
+
} else {
|
292 |
+
return $code;
|
293 |
+
}
|
294 |
+
|
295 |
+
SQ_Classes_Error::setError(esc_html__("The code for Facebook is incorrect.", 'squirrly-seo'));
|
296 |
+
|
297 |
+
}
|
298 |
+
return false;
|
299 |
+
}
|
300 |
+
|
301 |
+
/**
|
302 |
+
* Check the Pinterest code saved at settings
|
303 |
+
*
|
304 |
+
* @param string $code
|
305 |
+
* @return string
|
306 |
+
*/
|
307 |
+
public static function checkPinterestCode($code)
|
308 |
+
{
|
309 |
+
if ($code <> '') {
|
310 |
+
$code = stripslashes($code);
|
311 |
+
|
312 |
+
if (strpos($code, 'content') !== false) {
|
313 |
+
preg_match('/content\\s*=\\s*[\"]([^\"]+)[\"]/i', $code, $result);
|
314 |
+
if (isset($result[1]) && !empty($result[1])) $code = $result[1];
|
315 |
+
}
|
316 |
+
|
317 |
+
if (strpos($code, '"') !== false) {
|
318 |
+
preg_match('/[\"]([^\"]+)[\"]/i', $code, $result);
|
319 |
+
if (isset($result[1]) && !empty($result[1])) $code = $result[1];
|
320 |
+
}
|
321 |
+
|
322 |
+
if ($code == '') SQ_Classes_Error::setError(esc_html__("The code for Pinterest is incorrect.", 'squirrly-seo'));
|
323 |
+
}
|
324 |
+
return $code;
|
325 |
+
}
|
326 |
+
|
327 |
+
/**
|
328 |
+
* Check the Bing code saved at settings
|
329 |
+
*
|
330 |
+
* @return string
|
331 |
+
*/
|
332 |
+
public static function checkBingWTCode($code)
|
333 |
+
{
|
334 |
+
if ($code <> '') {
|
335 |
+
$code = stripslashes($code);
|
336 |
+
|
337 |
+
|
338 |
+
if (strpos($code, 'content') !== false) {
|
339 |
+
preg_match('/content\\s*=\\s*[\"]([^\"]+)[\"]/i', $code, $result);
|
340 |
+
if (isset($result[1]) && !empty($result[1])) $code = $result[1];
|
341 |
+
}
|
342 |
+
|
343 |
+
if (strpos($code, '"') !== false) {
|
344 |
+
preg_match('/[\"]([^\"]+)[\"]/i', $code, $result);
|
345 |
+
if (isset($result[1]) && !empty($result[1])) $code = $result[1];
|
346 |
+
}
|
347 |
+
|
348 |
+
if ($code == '') SQ_Classes_Error::setError(esc_html__("The code for Bing is incorrect.", 'squirrly-seo'));
|
349 |
+
}
|
350 |
+
return $code;
|
351 |
+
}
|
352 |
+
|
353 |
+
/**
|
354 |
+
* Check the Baidu code saved at settings
|
355 |
+
*
|
356 |
+
* @return string
|
357 |
+
*/
|
358 |
+
public static function checkBaiduWTCode($code)
|
359 |
+
{
|
360 |
+
if ($code <> '') {
|
361 |
+
$code = stripslashes($code);
|
362 |
+
|
363 |
+
|
364 |
+
if (strpos($code, 'content') !== false) {
|
365 |
+
preg_match('/content\\s*=\\s*[\"]([^\"]+)[\"]/i', $code, $result);
|
366 |
+
if (isset($result[1]) && !empty($result[1])) $code = $result[1];
|
367 |
+
}
|
368 |
+
|
369 |
+
if (strpos($code, '"') !== false) {
|
370 |
+
preg_match('/[\"]([^\"]+)[\"]/i', $code, $result);
|
371 |
+
if (isset($result[1]) && !empty($result[1])) $code = $result[1];
|
372 |
+
}
|
373 |
+
|
374 |
+
if ($code == '') SQ_Classes_Error::setError(esc_html__("The code for Baidu is incorrect.", 'squirrly-seo'));
|
375 |
+
}
|
376 |
+
return $code;
|
377 |
+
}
|
378 |
+
|
379 |
+
/**
|
380 |
+
* Check the Yandex code saved at settings
|
381 |
+
*
|
382 |
+
* @return string
|
383 |
+
*/
|
384 |
+
public static function checkYandexWTCode($code)
|
385 |
+
{
|
386 |
+
if ($code <> '') {
|
387 |
+
$code = stripslashes($code);
|
388 |
+
|
389 |
+
|
390 |
+
if (strpos($code, 'content') !== false) {
|
391 |
+
preg_match('/content\\s*=\\s*[\"]([^\"]+)[\"]/i', $code, $result);
|
392 |
+
if (isset($result[1]) && !empty($result[1])) $code = $result[1];
|
393 |
+
}
|
394 |
+
|
395 |
+
if (strpos($code, '"') !== false) {
|
396 |
+
preg_match('/[\"]([^\"]+)[\"]/i', $code, $result);
|
397 |
+
if (isset($result[1]) && !empty($result[1])) $code = $result[1];
|
398 |
+
}
|
399 |
+
|
400 |
+
if ($code == '') SQ_Classes_Error::setError(esc_html__("The code for Yandex is incorrect.", 'squirrly-seo'));
|
401 |
+
}
|
402 |
+
return $code;
|
403 |
+
}
|
404 |
+
|
405 |
+
/**
|
406 |
+
* Check the Alexa code saved at settings
|
407 |
+
*
|
408 |
+
* @return string
|
409 |
+
*/
|
410 |
+
public static function checkAlexaCode($code)
|
411 |
+
{
|
412 |
+
if ($code <> '') {
|
413 |
+
$code = stripslashes($code);
|
414 |
+
|
415 |
+
|
416 |
+
if (strpos($code, 'content') !== false) {
|
417 |
+
preg_match('/content\\s*=\\s*[\"]([^\"]+)[\"]/i', $code, $result);
|
418 |
+
if (isset($result[1]) && !empty($result[1])) $code = $result[1];
|
419 |
+
}
|
420 |
+
|
421 |
+
if (strpos($code, '"') !== false) {
|
422 |
+
preg_match('/[\"]([^\"]+)[\"]/i', $code, $result);
|
423 |
+
if (isset($result[1]) && !empty($result[1])) $code = $result[1];
|
424 |
+
}
|
425 |
+
|
426 |
+
if ($code == '') SQ_Classes_Error::setError(esc_html__("The code for Alexa is incorrect.", 'squirrly-seo'));
|
427 |
+
}
|
428 |
+
return $code;
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Check the twitter account
|
433 |
+
*
|
434 |
+
* @param string $account
|
435 |
+
* @return string
|
436 |
+
*/
|
437 |
+
public static function checkTwitterAccount($account)
|
438 |
+
{
|
439 |
+
if ($account <> '' && strpos($account, '//') === false) {
|
440 |
+
$account = 'https://twitter.com/' . $account;
|
441 |
+
}
|
442 |
+
|
443 |
+
return $account;
|
444 |
+
}
|
445 |
+
|
446 |
+
/**
|
447 |
+
* Check the twitter account
|
448 |
+
*
|
449 |
+
* @param string $account
|
450 |
+
* @return string
|
451 |
+
*/
|
452 |
+
public static function checkTwitterAccountName($account)
|
453 |
+
{
|
454 |
+
if ($account <> '' && strpos($account, '//') !== false) {
|
455 |
+
$account = parse_url($account, PHP_URL_PATH);
|
456 |
+
if ($account <> '') {
|
457 |
+
$account = str_replace('/', '', $account);
|
458 |
+
}
|
459 |
+
if (strpos($account, '@') == false) {
|
460 |
+
$account = '@' . $account;
|
461 |
+
}
|
462 |
+
}
|
463 |
+
|
464 |
+
return $account;
|
465 |
+
}
|
466 |
+
|
467 |
+
/**
|
468 |
+
* Check the google + account
|
469 |
+
*
|
470 |
+
* @param string $account
|
471 |
+
* @return string
|
472 |
+
*/
|
473 |
+
public static function checkGoogleAccount($account)
|
474 |
+
{
|
475 |
+
if ($account <> '' && strpos($account, '//') === false) {
|
476 |
+
$account = 'https://plus.google.com/' . $account;
|
477 |
+
}
|
478 |
+
return str_replace(" ", "+", $account);
|
479 |
+
}
|
480 |
+
|
481 |
+
/**
|
482 |
+
* Check the google + account
|
483 |
+
*
|
484 |
+
* @param string $account
|
485 |
+
* @return string
|
486 |
+
*/
|
487 |
+
public static function checkLinkeinAccount($account)
|
488 |
+
{
|
489 |
+
if ($account <> '' && strpos($account, '//') === false) {
|
490 |
+
$account = 'https://www.linkedin.com/in/' . $account;
|
491 |
+
}
|
492 |
+
return $account;
|
493 |
+
}
|
494 |
+
|
495 |
+
/**
|
496 |
+
* Check the facebook account
|
497 |
+
*
|
498 |
+
* @param string $account
|
499 |
+
* @return string
|
500 |
+
*/
|
501 |
+
public static function checkFacebookAccount($account)
|
502 |
+
{
|
503 |
+
if ($account <> '' && strpos($account, '//') === false) {
|
504 |
+
$account = 'https://www.facebook.com/' . $account;
|
505 |
+
}
|
506 |
+
return $account;
|
507 |
+
}
|
508 |
+
|
509 |
+
/**
|
510 |
+
* Check the Pinterest account
|
511 |
+
*
|
512 |
+
* @param $account
|
513 |
+
* @return string
|
514 |
+
*/
|
515 |
+
public static function checkPinterestAccount($account)
|
516 |
+
{
|
517 |
+
if ($account <> '' && strpos($account, '//') === false) {
|
518 |
+
$account = 'https://www.pinterest.com/' . $account;
|
519 |
+
}
|
520 |
+
return $account;
|
521 |
+
}
|
522 |
+
|
523 |
+
/**
|
524 |
+
* Check the Instagram
|
525 |
+
*
|
526 |
+
* @param $account
|
527 |
+
* @return string
|
528 |
+
*/
|
529 |
+
public static function checkInstagramAccount($account)
|
530 |
+
{
|
531 |
+
if ($account <> '' && strpos($account, '//') === false) {
|
532 |
+
$account = 'https://www.instagram.com/' . $account;
|
533 |
+
}
|
534 |
+
return $account;
|
535 |
+
}
|
536 |
+
|
537 |
+
/**
|
538 |
+
* Check the Youtube account
|
539 |
+
*
|
540 |
+
* @param $account
|
541 |
+
* @return string
|
542 |
+
*/
|
543 |
+
public static function checkYoutubeAccount($account)
|
544 |
+
{
|
545 |
+
if ($account <> '' && strpos($account, '//') === false) {
|
546 |
+
if (strpos($account, 'user/') === false && strpos($account, 'channel/') === false) {
|
547 |
+
$account = 'https://www.youtube.com/channel/' . $account;
|
548 |
+
}
|
549 |
+
}
|
550 |
+
return $account;
|
551 |
+
}
|
552 |
+
|
553 |
+
/**
|
554 |
+
* Check the Facebook Pixel code
|
555 |
+
*
|
556 |
+
* @return string
|
557 |
+
*/
|
558 |
+
public static function checkFacebookPixel($code)
|
559 |
+
{
|
560 |
+
if ($code <> '') {
|
561 |
+
if ((int)$code == 0) {
|
562 |
+
SQ_Classes_Error::setError(esc_html__("The code for Facebook Pixel must only contain numbers.", 'squirrly-seo'));
|
563 |
+
$code = '';
|
564 |
+
}
|
565 |
+
}
|
566 |
+
return $code;
|
567 |
+
}
|
568 |
+
|
569 |
+
/**
|
570 |
+
* Check the Facebook App code
|
571 |
+
*
|
572 |
+
* @return string
|
573 |
+
*/
|
574 |
+
public static function checkFacebookApp($code)
|
575 |
+
{
|
576 |
+
if ($code <> '') {
|
577 |
+
if ((int)$code == 0) {
|
578 |
+
SQ_Classes_Error::setError(esc_html__("The code for Facebook App must only contain numbers.", 'squirrly-seo'));
|
579 |
+
$code = '';
|
580 |
+
}
|
581 |
+
}
|
582 |
+
return $code;
|
583 |
+
}
|
584 |
+
|
585 |
+
/**
|
586 |
+
* Support for i18n with wpml, polyglot or qtrans
|
587 |
+
*
|
588 |
+
* @param string $in
|
589 |
+
* @return string $in localized
|
590 |
+
*/
|
591 |
+
public static function i18n($in)
|
592 |
+
{
|
593 |
+
if (function_exists('langswitch_filter_langs_with_message')) {
|
594 |
+
$in = langswitch_filter_langs_with_message($in);
|
595 |
+
}
|
596 |
+
if (function_exists('polyglot_filter')) {
|
597 |
+
$in = polyglot_filter($in);
|
598 |
+
}
|
599 |
+
if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) {
|
600 |
+
$in = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($in);
|
601 |
+
}
|
602 |
+
$in = apply_filters('localization', $in);
|
603 |
+
return $in;
|
604 |
+
}
|
605 |
+
}
|
classes/helpers/Tools.php
CHANGED
@@ -1,1360 +1,1411 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Handles the parameters and url
|
6 |
-
*
|
7 |
-
* @author Squirrly
|
8 |
-
*/
|
9 |
-
class SQ_Classes_Helpers_Tools
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
'
|
131 |
-
|
132 |
-
//
|
133 |
-
'
|
134 |
-
'
|
135 |
-
'
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
'
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
'
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
'
|
152 |
-
'
|
153 |
-
|
154 |
-
|
155 |
-
'
|
156 |
-
'
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
'
|
164 |
-
'
|
165 |
-
'
|
166 |
-
'
|
167 |
-
'
|
168 |
-
'
|
169 |
-
'
|
170 |
-
'
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
array(
|
190 |
-
'@type' => 'OpeningHoursSpecification',
|
191 |
-
'dayOfWeek' => '
|
192 |
-
'opens' => '',
|
193 |
-
'closes' => '',
|
194 |
-
),
|
195 |
-
array(
|
196 |
-
'@type' => 'OpeningHoursSpecification',
|
197 |
-
'dayOfWeek' => '
|
198 |
-
'opens' => '',
|
199 |
-
'closes' => '',
|
200 |
-
),
|
201 |
-
array(
|
202 |
-
'@type' => 'OpeningHoursSpecification',
|
203 |
-
'dayOfWeek' => '
|
204 |
-
'opens' => '',
|
205 |
-
'closes' => '',
|
206 |
-
),
|
207 |
-
array(
|
208 |
-
'@type' => 'OpeningHoursSpecification',
|
209 |
-
'dayOfWeek' => '
|
210 |
-
'opens' => '',
|
211 |
-
'closes' => '',
|
212 |
-
),
|
213 |
-
array(
|
214 |
-
'@type' => 'OpeningHoursSpecification',
|
215 |
-
'dayOfWeek' => '
|
216 |
-
'opens' => '',
|
217 |
-
'closes' => '',
|
218 |
-
),
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
'@type' => '
|
227 |
-
'
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
'
|
239 |
-
'
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
'
|
244 |
-
'
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
'
|
283 |
-
'
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
'sitemap
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
'
|
296 |
-
'
|
297 |
-
'
|
298 |
-
'
|
299 |
-
'
|
300 |
-
'
|
301 |
-
'
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
'
|
306 |
-
'
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
'
|
317 |
-
'
|
318 |
-
'
|
319 |
-
'
|
320 |
-
'
|
321 |
-
'
|
322 |
-
'
|
323 |
-
'
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
'
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
'
|
353 |
-
'
|
354 |
-
'
|
355 |
-
'
|
356 |
-
|
357 |
-
|
358 |
-
'
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
'
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
'
|
394 |
-
'
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
'
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
'
|
435 |
-
'
|
436 |
-
'
|
437 |
-
'
|
438 |
-
'
|
439 |
-
|
440 |
-
|
441 |
-
'
|
442 |
-
'
|
443 |
-
'
|
444 |
-
'
|
445 |
-
'
|
446 |
-
'
|
447 |
-
'
|
448 |
-
'
|
449 |
-
'
|
450 |
-
'
|
451 |
-
|
452 |
-
|
453 |
-
'
|
454 |
-
'
|
455 |
-
'
|
456 |
-
'
|
457 |
-
'
|
458 |
-
|
459 |
-
|
460 |
-
'
|
461 |
-
'
|
462 |
-
'
|
463 |
-
'
|
464 |
-
'
|
465 |
-
'
|
466 |
-
'
|
467 |
-
'
|
468 |
-
'
|
469 |
-
'
|
470 |
-
|
471 |
-
|
472 |
-
'
|
473 |
-
'
|
474 |
-
'
|
475 |
-
'
|
476 |
-
'
|
477 |
-
|
478 |
-
|
479 |
-
'
|
480 |
-
'
|
481 |
-
'
|
482 |
-
'
|
483 |
-
'
|
484 |
-
'
|
485 |
-
'
|
486 |
-
'
|
487 |
-
'
|
488 |
-
'
|
489 |
-
|
490 |
-
|
491 |
-
'
|
492 |
-
'
|
493 |
-
'
|
494 |
-
'
|
495 |
-
'
|
496 |
-
|
497 |
-
|
498 |
-
'
|
499 |
-
'
|
500 |
-
'
|
501 |
-
'
|
502 |
-
'
|
503 |
-
'
|
504 |
-
'
|
505 |
-
'
|
506 |
-
'
|
507 |
-
'
|
508 |
-
|
509 |
-
|
510 |
-
'
|
511 |
-
'
|
512 |
-
'
|
513 |
-
'
|
514 |
-
'
|
515 |
-
|
516 |
-
|
517 |
-
'
|
518 |
-
'
|
519 |
-
'
|
520 |
-
'
|
521 |
-
'
|
522 |
-
'
|
523 |
-
'
|
524 |
-
'
|
525 |
-
'
|
526 |
-
'
|
527 |
-
|
528 |
-
|
529 |
-
'
|
530 |
-
'
|
531 |
-
'
|
532 |
-
'
|
533 |
-
'
|
534 |
-
|
535 |
-
|
536 |
-
'
|
537 |
-
'
|
538 |
-
'
|
539 |
-
'
|
540 |
-
'
|
541 |
-
'
|
542 |
-
'
|
543 |
-
'
|
544 |
-
'
|
545 |
-
'
|
546 |
-
|
547 |
-
|
548 |
-
'
|
549 |
-
'
|
550 |
-
'
|
551 |
-
'
|
552 |
-
'
|
553 |
-
|
554 |
-
|
555 |
-
'
|
556 |
-
'
|
557 |
-
'
|
558 |
-
'
|
559 |
-
'
|
560 |
-
'
|
561 |
-
'
|
562 |
-
'
|
563 |
-
'
|
564 |
-
'
|
565 |
-
|
566 |
-
|
567 |
-
'
|
568 |
-
'
|
569 |
-
'
|
570 |
-
'
|
571 |
-
'
|
572 |
-
|
573 |
-
|
574 |
-
'
|
575 |
-
'
|
576 |
-
'
|
577 |
-
'
|
578 |
-
'
|
579 |
-
'
|
580 |
-
'
|
581 |
-
'
|
582 |
-
'
|
583 |
-
'
|
584 |
-
|
585 |
-
|
586 |
-
'
|
587 |
-
'
|
588 |
-
'
|
589 |
-
'
|
590 |
-
'
|
591 |
-
|
592 |
-
|
593 |
-
'
|
594 |
-
'
|
595 |
-
'
|
596 |
-
'
|
597 |
-
'
|
598 |
-
'
|
599 |
-
'
|
600 |
-
'
|
601 |
-
'
|
602 |
-
'
|
603 |
-
|
604 |
-
|
605 |
-
'
|
606 |
-
'
|
607 |
-
'
|
608 |
-
'
|
609 |
-
'
|
610 |
-
|
611 |
-
|
612 |
-
'
|
613 |
-
'
|
614 |
-
'
|
615 |
-
'
|
616 |
-
'
|
617 |
-
'
|
618 |
-
'
|
619 |
-
'
|
620 |
-
'
|
621 |
-
'
|
622 |
-
|
623 |
-
|
624 |
-
'
|
625 |
-
'
|
626 |
-
'
|
627 |
-
'
|
628 |
-
'
|
629 |
-
|
630 |
-
|
631 |
-
'
|
632 |
-
'
|
633 |
-
'
|
634 |
-
'
|
635 |
-
'
|
636 |
-
'
|
637 |
-
'
|
638 |
-
'
|
639 |
-
'
|
640 |
-
'
|
641 |
-
|
642 |
-
|
643 |
-
'
|
644 |
-
'
|
645 |
-
'
|
646 |
-
'
|
647 |
-
'
|
648 |
-
|
649 |
-
|
650 |
-
'
|
651 |
-
'
|
652 |
-
'
|
653 |
-
'
|
654 |
-
'
|
655 |
-
'
|
656 |
-
'
|
657 |
-
'
|
658 |
-
'
|
659 |
-
'
|
660 |
-
|
661 |
-
|
662 |
-
'
|
663 |
-
'
|
664 |
-
'
|
665 |
-
'
|
666 |
-
'
|
667 |
-
|
668 |
-
|
669 |
-
'
|
670 |
-
'
|
671 |
-
'
|
672 |
-
'
|
673 |
-
'
|
674 |
-
'
|
675 |
-
'
|
676 |
-
'
|
677 |
-
'
|
678 |
-
'
|
679 |
-
|
680 |
-
|
681 |
-
'
|
682 |
-
'
|
683 |
-
'
|
684 |
-
'
|
685 |
-
'
|
686 |
-
|
687 |
-
|
688 |
-
'
|
689 |
-
'
|
690 |
-
'
|
691 |
-
'
|
692 |
-
'
|
693 |
-
'
|
694 |
-
'
|
695 |
-
'
|
696 |
-
'
|
697 |
-
'
|
698 |
-
|
699 |
-
|
700 |
-
'
|
701 |
-
'
|
702 |
-
'
|
703 |
-
'
|
704 |
-
'
|
705 |
-
|
706 |
-
|
707 |
-
'
|
708 |
-
'
|
709 |
-
'
|
710 |
-
'
|
711 |
-
'
|
712 |
-
'
|
713 |
-
'
|
714 |
-
'
|
715 |
-
'
|
716 |
-
'
|
717 |
-
|
718 |
-
|
719 |
-
'
|
720 |
-
'
|
721 |
-
'
|
722 |
-
'
|
723 |
-
|
724 |
-
|
725 |
-
'
|
726 |
-
'
|
727 |
-
'
|
728 |
-
'
|
729 |
-
'
|
730 |
-
'
|
731 |
-
'
|
732 |
-
'
|
733 |
-
'
|
734 |
-
'
|
735 |
-
|
736 |
-
|
737 |
-
'
|
738 |
-
'
|
739 |
-
'
|
740 |
-
'
|
741 |
-
'
|
742 |
-
|
743 |
-
|
744 |
-
'
|
745 |
-
'
|
746 |
-
'
|
747 |
-
'
|
748 |
-
'
|
749 |
-
'
|
750 |
-
'
|
751 |
-
'
|
752 |
-
'
|
753 |
-
'
|
754 |
-
|
755 |
-
|
756 |
-
'
|
757 |
-
'
|
758 |
-
'
|
759 |
-
'
|
760 |
-
'
|
761 |
-
|
762 |
-
|
763 |
-
'
|
764 |
-
'
|
765 |
-
'
|
766 |
-
'
|
767 |
-
'
|
768 |
-
'
|
769 |
-
'
|
770 |
-
'
|
771 |
-
'
|
772 |
-
'
|
773 |
-
|
774 |
-
|
775 |
-
'
|
776 |
-
'
|
777 |
-
'
|
778 |
-
'
|
779 |
-
'
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
if (isset($options['sq_jsonld']['
|
807 |
-
$options['sq_jsonld']['
|
808 |
-
'@type' => '
|
809 |
-
'
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
}
|
855 |
-
|
856 |
-
|
857 |
-
}
|
858 |
-
|
859 |
-
/**
|
860 |
-
*
|
861 |
-
*
|
862 |
-
* @
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
}
|
900 |
-
|
901 |
-
return
|
902 |
-
}
|
903 |
-
|
904 |
-
/**
|
905 |
-
*
|
906 |
-
*
|
907 |
-
* @param
|
908 |
-
* @
|
909 |
-
*/
|
910 |
-
public static function
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
*
|
1010 |
-
*
|
1011 |
-
* @param
|
1012 |
-
* @
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
$
|
1023 |
-
}
|
1024 |
-
|
1025 |
-
if (
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
}
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
*
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
//////////////////////////////////////////////////////////////////////////////
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
if (
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
*
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
}
|
1325 |
-
|
1326 |
-
if (
|
1327 |
-
|
1328 |
-
}
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Handles the parameters and url
|
6 |
+
*
|
7 |
+
* @author Squirrly
|
8 |
+
*/
|
9 |
+
class SQ_Classes_Helpers_Tools
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
*
|
14 |
+
*
|
15 |
+
* @var array Options, User Metas, Package and Plugin details
|
16 |
+
*/
|
17 |
+
public static $options, $usermeta, $allplugins = array();
|
18 |
+
|
19 |
+
public function __construct()
|
20 |
+
{
|
21 |
+
self::$options = $this->getOptions();
|
22 |
+
|
23 |
+
// $maxmemory = self::getMaxMemory();
|
24 |
+
// if ($maxmemory && $maxmemory < 60) {
|
25 |
+
// @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
|
26 |
+
// }
|
27 |
+
|
28 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_HookController')->setHooks($this);
|
29 |
+
}
|
30 |
+
|
31 |
+
public static function getMaxMemory()
|
32 |
+
{
|
33 |
+
try {
|
34 |
+
$memory_limit = @ini_get('memory_limit');
|
35 |
+
if ((int)$memory_limit > 0) {
|
36 |
+
if (preg_match('/^(\d+)(.)$/', $memory_limit, $matches)) {
|
37 |
+
if ($matches[2] == 'G') {
|
38 |
+
$memory_limit = $matches[1] * 1024 * 1024 * 1024; // nnnM -> nnn MB
|
39 |
+
} elseif ($matches[2] == 'M') {
|
40 |
+
$memory_limit = $matches[1] * 1024 * 1024; // nnnM -> nnn MB
|
41 |
+
} elseif ($matches[2] == 'K') {
|
42 |
+
$memory_limit = $matches[1] * 1024; // nnnK -> nnn KB
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
if ((int)$memory_limit > 0) {
|
47 |
+
return number_format($memory_limit / 1024 / 1024, 0, '', '');
|
48 |
+
}
|
49 |
+
}
|
50 |
+
} catch (Exception $e) {
|
51 |
+
}
|
52 |
+
|
53 |
+
return false;
|
54 |
+
|
55 |
+
}
|
56 |
+
|
57 |
+
public static function isAjax()
|
58 |
+
{
|
59 |
+
return (defined('DOING_AJAX') && DOING_AJAX);
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* This hook will save the current version in database
|
64 |
+
*
|
65 |
+
* @return void
|
66 |
+
*/
|
67 |
+
function hookInit()
|
68 |
+
{
|
69 |
+
//Load the languages pack
|
70 |
+
$this->loadMultilanguage();
|
71 |
+
|
72 |
+
//add extra links to the plugin in the Plugins list
|
73 |
+
add_filter("plugin_row_meta", array($this, 'hookExtraLinks'), 10, 4);
|
74 |
+
//add setting link in plugin
|
75 |
+
add_filter('plugin_action_links', array($this, 'hookActionlink'), 5, 2);
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Add a link to settings in the plugin list
|
80 |
+
*
|
81 |
+
* @param array $links
|
82 |
+
* @param string $file
|
83 |
+
* @return array
|
84 |
+
*/
|
85 |
+
public function hookActionlink($links, $file)
|
86 |
+
{
|
87 |
+
if ($file == _SQ_PLUGIN_NAME_ . '/squirrly.php') {
|
88 |
+
$link = '<a href="' . self::getAdminUrl('sq_dashboard') . '">' . esc_html__("Getting started", 'squirrly-seo') . '</a>';
|
89 |
+
array_unshift($links, $link);
|
90 |
+
}
|
91 |
+
|
92 |
+
return $links;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Adds extra links to plugin page
|
97 |
+
*
|
98 |
+
* @param $meta
|
99 |
+
* @param $file
|
100 |
+
* @param $data
|
101 |
+
* @param $status
|
102 |
+
* @return array
|
103 |
+
*/
|
104 |
+
public function hookExtraLinks($meta, $file, $data = null, $status = null)
|
105 |
+
{
|
106 |
+
if ($file == _SQ_PLUGIN_NAME_ . '/squirrly.php') {
|
107 |
+
echo '<style>
|
108 |
+
.ml-stars{display:inline-block;color:#ffb900;position:relative;top:3px}
|
109 |
+
.ml-stars svg{fill:#ffb900}
|
110 |
+
.ml-stars svg:hover{fill:#ffb900}
|
111 |
+
.ml-stars svg:hover ~ svg{fill:none}
|
112 |
+
</style>';
|
113 |
+
|
114 |
+
$meta[] = "<a href='https://howto.squirrly.co/wordpress-seo/' target='_blank'>" . esc_html__("Documentation", 'squirrly-seo') . "</a>";
|
115 |
+
$meta[] = "<a href='https://wordpress.org/support/plugin/squirrly-seo/reviews/#new-post' target='_blank' title='" . esc_html__("Leave a review", 'squirrly-seo') . "'><i class='ml-stars'><svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg><svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg><svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg><svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg><svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg></i></a>";
|
116 |
+
}
|
117 |
+
return $meta;
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Load the Options from user option table in DB
|
122 |
+
*
|
123 |
+
* @param string $action
|
124 |
+
* @return array|mixed|object
|
125 |
+
*/
|
126 |
+
public static function getOptions($action = '')
|
127 |
+
{
|
128 |
+
$default = array(
|
129 |
+
//Global settings
|
130 |
+
'sq_api' => '',
|
131 |
+
'sq_installed' => date('Y-m-d H:i:s'),
|
132 |
+
//
|
133 |
+
'sq_cloud_connect' => 0,
|
134 |
+
'sq_cloud_token' => false,
|
135 |
+
'sq_offer' => false,
|
136 |
+
'sq_alert_overview' => true,
|
137 |
+
'sq_alert_journey' => true,
|
138 |
+
//Advanced settings
|
139 |
+
'sq_seoexpert' => 0,
|
140 |
+
//later buffer load
|
141 |
+
'sq_laterload' => 0,
|
142 |
+
'sq_audit_email' => '',
|
143 |
+
|
144 |
+
//SEO Journey
|
145 |
+
'sq_seojourney' => 0,
|
146 |
+
'sq_seojourney_congrats' => 1,
|
147 |
+
'sq_menu_visited' => array(),
|
148 |
+
|
149 |
+
//minify Squirrly Metas
|
150 |
+
'sq_load_css' => 1,
|
151 |
+
'sq_minify' => 0,
|
152 |
+
'sq_non_utf8_support' => 1,
|
153 |
+
|
154 |
+
//Settings Assistant
|
155 |
+
'sq_assistant' => 1,
|
156 |
+
'sq_complete_uninstall' => 0,
|
157 |
+
|
158 |
+
//Onboarding
|
159 |
+
'sq_onboarding' => 0,
|
160 |
+
'sq_onboarding_data' => array(),
|
161 |
+
|
162 |
+
//Live Assistant
|
163 |
+
'sq_sla' => 1,
|
164 |
+
'sq_sla_frontend' => 1,
|
165 |
+
'sq_sla_type' => 'auto',
|
166 |
+
'sq_sla_exclude_post_types' => array(),
|
167 |
+
'sq_keyword_help' => 1,
|
168 |
+
'sq_local_images' => 0,
|
169 |
+
'sq_img_licence' => 1,
|
170 |
+
'sq_sla_social_fetch' => 1,
|
171 |
+
|
172 |
+
//JsonLD
|
173 |
+
'sq_auto_jsonld' => 1,
|
174 |
+
'sq_auto_jsonld_local' => 0,
|
175 |
+
'sq_jsonld_type' => 'Organization',
|
176 |
+
'sq_jsonld_global_person' => 0,
|
177 |
+
'sq_jsonld_breadcrumbs' => 1,
|
178 |
+
'sq_jsonld_woocommerce' => 1,
|
179 |
+
'sq_jsonld_clearcode' => 0,
|
180 |
+
'sq_jsonld_product_rating' => 0,
|
181 |
+
'sq_jsonld_product_custom' => 1,
|
182 |
+
'sq_jsonld_product_defaults' => 1,
|
183 |
+
'sq_jsonld_local' => array(
|
184 |
+
'priceRange' => '',
|
185 |
+
'servesCuisine' => '',
|
186 |
+
'menu' => '',
|
187 |
+
'acceptsReservations' => '',
|
188 |
+
'openingHoursSpecification' => array(
|
189 |
+
array(
|
190 |
+
'@type' => 'OpeningHoursSpecification',
|
191 |
+
'dayOfWeek' => 'Monday',
|
192 |
+
'opens' => '',
|
193 |
+
'closes' => '',
|
194 |
+
),
|
195 |
+
array(
|
196 |
+
'@type' => 'OpeningHoursSpecification',
|
197 |
+
'dayOfWeek' => 'Tuesday',
|
198 |
+
'opens' => '',
|
199 |
+
'closes' => '',
|
200 |
+
),
|
201 |
+
array(
|
202 |
+
'@type' => 'OpeningHoursSpecification',
|
203 |
+
'dayOfWeek' => 'Wednesday',
|
204 |
+
'opens' => '',
|
205 |
+
'closes' => '',
|
206 |
+
),
|
207 |
+
array(
|
208 |
+
'@type' => 'OpeningHoursSpecification',
|
209 |
+
'dayOfWeek' => 'Thursday',
|
210 |
+
'opens' => '',
|
211 |
+
'closes' => '',
|
212 |
+
),
|
213 |
+
array(
|
214 |
+
'@type' => 'OpeningHoursSpecification',
|
215 |
+
'dayOfWeek' => 'Friday',
|
216 |
+
'opens' => '',
|
217 |
+
'closes' => '',
|
218 |
+
),
|
219 |
+
array(
|
220 |
+
'@type' => 'OpeningHoursSpecification',
|
221 |
+
'dayOfWeek' => 'Saturday',
|
222 |
+
'opens' => '',
|
223 |
+
'closes' => '',
|
224 |
+
),
|
225 |
+
array(
|
226 |
+
'@type' => 'OpeningHoursSpecification',
|
227 |
+
'dayOfWeek' => 'Sunday',
|
228 |
+
'opens' => '',
|
229 |
+
'closes' => '',
|
230 |
+
),
|
231 |
+
|
232 |
+
),
|
233 |
+
),
|
234 |
+
'sq_jsonld' => array(
|
235 |
+
'Organization' => array(
|
236 |
+
'name' => '',
|
237 |
+
'logo' => array(
|
238 |
+
'@type' => 'ImageObject',
|
239 |
+
'url' => '',
|
240 |
+
),
|
241 |
+
'contactPoint' => array(
|
242 |
+
'@type' => 'ContactPoint',
|
243 |
+
'telephone' => '',
|
244 |
+
'contactType' => '',
|
245 |
+
),
|
246 |
+
'address' => array(
|
247 |
+
'@type' => 'PostalAddress',
|
248 |
+
'streetAddress' => '',
|
249 |
+
'addressLocality' => '',
|
250 |
+
'addressRegion' => '',
|
251 |
+
'postalCode' => '',
|
252 |
+
'addressCountry' => '',
|
253 |
+
),
|
254 |
+
'place' => array(
|
255 |
+
'@type' => 'Place',
|
256 |
+
'geo' => array(
|
257 |
+
'@type' => 'GeoCoordinates',
|
258 |
+
'latitude' => '',
|
259 |
+
'longitude' => '',
|
260 |
+
),
|
261 |
+
|
262 |
+
),
|
263 |
+
|
264 |
+
'description' => ''
|
265 |
+
),
|
266 |
+
'Person' => array(
|
267 |
+
'name' => '',
|
268 |
+
'image' => array(
|
269 |
+
'@type' => 'ImageObject',
|
270 |
+
'url' => '',
|
271 |
+
),
|
272 |
+
'telephone' => '',
|
273 |
+
'jobTitle' => '',
|
274 |
+
'description' => ''
|
275 |
+
)),
|
276 |
+
|
277 |
+
//Sitemap
|
278 |
+
'sq_auto_sitemap' => 1,
|
279 |
+
'sq_sitemap_ping' => 0,
|
280 |
+
'sq_sitemap_exclude_noindex' => 0,
|
281 |
+
'sq_sitemap_show' => array(
|
282 |
+
'images' => 1,
|
283 |
+
'videos' => 0,
|
284 |
+
),
|
285 |
+
'sq_sitemap_perpage' => 500,
|
286 |
+
'sq_sitemap_frequency' => 'weekly',
|
287 |
+
'sq_sitemap_combinelangs' => 0,
|
288 |
+
'sq_sitemap' => array(
|
289 |
+
'sitemap' => array('sitemap.xml', 1),
|
290 |
+
'sitemap-home' => array('sitemap-home.xml', 1),
|
291 |
+
'sitemap-news' => array('sitemap-news.xml', 0),
|
292 |
+
'sitemap-product' => array('sitemap-product.xml', 1),
|
293 |
+
'sitemap-post' => array('sitemap-posts.xml', 1),
|
294 |
+
'sitemap-page' => array('sitemap-pages.xml', 1),
|
295 |
+
'sitemap-category' => array('sitemap-categories.xml', 1),
|
296 |
+
'sitemap-post_tag' => array('sitemap-tags.xml', 1),
|
297 |
+
'sitemap-archive' => array('sitemap-archives.xml', 1),
|
298 |
+
'sitemap-author' => array('sitemap-authors.xml', 0),
|
299 |
+
'sitemap-custom-tax' => array('sitemap-custom-taxonomies.xml', 0),
|
300 |
+
'sitemap-custom-post' => array('sitemap-custom-posts.xml', 0),
|
301 |
+
'sitemap-attachment' => array('sitemap-attachment.xml', 0),
|
302 |
+
),
|
303 |
+
|
304 |
+
//Robots
|
305 |
+
'sq_auto_robots' => 1,
|
306 |
+
'sq_robots_permission' => array(
|
307 |
+
'User-agent: *',
|
308 |
+
'Disallow: */trackback/',
|
309 |
+
'Disallow: */xmlrpc.php',
|
310 |
+
'Disallow: /wp-*.php',
|
311 |
+
'Disallow: /cgi-bin/',
|
312 |
+
'Disallow: /wp-admin/',
|
313 |
+
'Allow: */wp-content/uploads/',),
|
314 |
+
|
315 |
+
//Metas
|
316 |
+
'sq_use' => 1,
|
317 |
+
'sq_auto_metas' => 1,
|
318 |
+
'sq_auto_links' => 0,
|
319 |
+
'sq_auto_redirects' => 1,
|
320 |
+
'sq_auto_title' => 1,
|
321 |
+
'sq_auto_description' => 1,
|
322 |
+
'sq_auto_keywords' => 1,
|
323 |
+
'sq_keywordtag' => 0,
|
324 |
+
'sq_auto_canonical' => 1,
|
325 |
+
'sq_auto_dublincore' => 0,
|
326 |
+
'sq_auto_feed' => 0,
|
327 |
+
'sq_auto_noindex' => 1,
|
328 |
+
'sq_use_frontend' => 1,
|
329 |
+
'sq_attachment_redirect' => 0,
|
330 |
+
'sq_term_noindex_empty' => 1,
|
331 |
+
'404_url_redirect' => home_url(),
|
332 |
+
'sq_external_nofollow' => 1,
|
333 |
+
'sq_external_exception' => array(),
|
334 |
+
'sq_external_blank' => 0,
|
335 |
+
'sq_metas' => array(
|
336 |
+
'title_maxlength' => 75,
|
337 |
+
'description_maxlength' => 320,
|
338 |
+
'og_title_maxlength' => 75,
|
339 |
+
'og_description_maxlength' => 200,
|
340 |
+
'tw_title_maxlength' => 75,
|
341 |
+
'tw_description_maxlength' => 280,
|
342 |
+
'jsonld_title_maxlength' => 75,
|
343 |
+
'jsonld_description_maxlength' => 320,
|
344 |
+
),
|
345 |
+
|
346 |
+
//favicon
|
347 |
+
'sq_auto_favicon' => 0,
|
348 |
+
'sq_favicon_apple' => 1,
|
349 |
+
'favicon' => '',
|
350 |
+
|
351 |
+
//Ranking Option
|
352 |
+
'sq_google_country' => 'com',
|
353 |
+
'sq_google_language' => 'en',
|
354 |
+
'sq_google_device' => 'desktop',
|
355 |
+
'sq_google_serpsperhour' => 500,
|
356 |
+
'connect' => array(
|
357 |
+
'google_analytics' => 0,
|
358 |
+
'google_search_console' => 0,
|
359 |
+
),
|
360 |
+
|
361 |
+
// dev kit
|
362 |
+
'sq_auto_devkit' => 1,
|
363 |
+
'sq_devkit_logo' => false,
|
364 |
+
'sq_devkit_name' => false,
|
365 |
+
'sq_devkit_menu_name' => false,
|
366 |
+
'sq_devkit_audit_success' => false,
|
367 |
+
'sq_devkit_audit_fail' => false,
|
368 |
+
//menu restrictions
|
369 |
+
'menu' => array(
|
370 |
+
'show_account_info' => 1,
|
371 |
+
'show_journey' => 1,
|
372 |
+
'show_panel' => 1,
|
373 |
+
'show_tutorial' => 1,
|
374 |
+
'show_audit' => 1,
|
375 |
+
'show_assistant' => 1,
|
376 |
+
'show_bulkseo' => 1,
|
377 |
+
'show_research' => 1,
|
378 |
+
'show_rankings' => 1,
|
379 |
+
'show_focuspages' => 1,
|
380 |
+
'show_seogoals' => 1,
|
381 |
+
'show_ads' => 1,
|
382 |
+
),
|
383 |
+
|
384 |
+
//socials
|
385 |
+
'sq_auto_social' => 1,
|
386 |
+
'sq_auto_facebook' => 1,
|
387 |
+
'sq_auto_twitter' => 1,
|
388 |
+
'sq_og_locale' => 'en_US',
|
389 |
+
'sq_og_image' => '',
|
390 |
+
'sq_tc_image' => '',
|
391 |
+
|
392 |
+
'socials' => array(
|
393 |
+
'fb_admins' => array(),
|
394 |
+
'fbconnectkey' => "",
|
395 |
+
'fbadminapp' => "",
|
396 |
+
|
397 |
+
'facebook_site' => "",
|
398 |
+
'twitter_site' => "https://twitter.com/twitter",
|
399 |
+
'twitter' => "",
|
400 |
+
'instagram_url' => "",
|
401 |
+
'linkedin_url' => "",
|
402 |
+
'myspace_url' => "",
|
403 |
+
'pinterest_url' => "",
|
404 |
+
'youtube_url' => "",
|
405 |
+
'twitter_card_type' => "summary_large_image",
|
406 |
+
'plus_publisher' => ""
|
407 |
+
),
|
408 |
+
|
409 |
+
//Webmasters and Tracking
|
410 |
+
'sq_auto_amp' => 1,
|
411 |
+
'sq_auto_tracking' => 1,
|
412 |
+
'sq_auto_pixels' => 1,
|
413 |
+
'sq_tracking_logged_users' => 1,
|
414 |
+
'sq_tracking_ip_users' => 1,
|
415 |
+
'sq_auto_webmasters' => 1,
|
416 |
+
'sq_analytics_google_js' => 'analytics',
|
417 |
+
'codes' => array(
|
418 |
+
'google_wt' => "",
|
419 |
+
'google_analytics' => "",
|
420 |
+
'facebook_pixel' => "",
|
421 |
+
|
422 |
+
'bing_wt' => "",
|
423 |
+
'baidu_wt' => "",
|
424 |
+
'yandex_wt' => "",
|
425 |
+
'pinterest_verify' => "",
|
426 |
+
'alexa_verify' => "",
|
427 |
+
'norton_verify' => "",
|
428 |
+
),
|
429 |
+
|
430 |
+
//Patterns
|
431 |
+
'sq_auto_pattern' => 1,
|
432 |
+
'patterns' => array(
|
433 |
+
'home' => array(
|
434 |
+
'protected' => 1,
|
435 |
+
'sep' => '|',
|
436 |
+
'title' => '{{sitename}} {{page}} {{sep}} {{sitedesc}}',
|
437 |
+
'description' => '{{excerpt}} {{page}} {{sep}} {{sitename}}',
|
438 |
+
'noindex' => 0,
|
439 |
+
'nofollow' => 0,
|
440 |
+
'og_type' => 'website',
|
441 |
+
'jsonld_types' => array('website'),
|
442 |
+
'do_metas' => 1,
|
443 |
+
'do_sitemap' => 1,
|
444 |
+
'do_jsonld' => 1,
|
445 |
+
'do_pattern' => 1,
|
446 |
+
'do_og' => 1,
|
447 |
+
'do_twc' => 1,
|
448 |
+
'do_analytics' => 1,
|
449 |
+
'do_fpixel' => 1,
|
450 |
+
'do_redirects' => 0,
|
451 |
+
),
|
452 |
+
'post' => array(
|
453 |
+
'protected' => 1,
|
454 |
+
'sep' => '|',
|
455 |
+
'title' => '{{title}} {{page}}',
|
456 |
+
'description' => '{{excerpt}}',
|
457 |
+
'noindex' => 0,
|
458 |
+
'nofollow' => 0,
|
459 |
+
'og_type' => 'article',
|
460 |
+
'jsonld_types' => array('newsarticle'),
|
461 |
+
'do_metas' => 1,
|
462 |
+
'do_sitemap' => 1,
|
463 |
+
'do_jsonld' => 1,
|
464 |
+
'do_pattern' => 1,
|
465 |
+
'do_og' => 1,
|
466 |
+
'do_twc' => 1,
|
467 |
+
'do_analytics' => 1,
|
468 |
+
'do_fpixel' => 1,
|
469 |
+
'do_redirects' => 1,
|
470 |
+
),
|
471 |
+
'page' => array(
|
472 |
+
'protected' => 1,
|
473 |
+
'sep' => '|',
|
474 |
+
'title' => '{{title}} {{page}} {{sep}} {{sitename}}',
|
475 |
+
'description' => '{{excerpt}}',
|
476 |
+
'noindex' => 0,
|
477 |
+
'nofollow' => 0,
|
478 |
+
'og_type' => 'website',
|
479 |
+
'jsonld_types' => array('website'),
|
480 |
+
'do_metas' => 1,
|
481 |
+
'do_sitemap' => 1,
|
482 |
+
'do_jsonld' => 1,
|
483 |
+
'do_pattern' => 1,
|
484 |
+
'do_og' => 1,
|
485 |
+
'do_twc' => 1,
|
486 |
+
'do_analytics' => 1,
|
487 |
+
'do_fpixel' => 1,
|
488 |
+
'do_redirects' => 1,
|
489 |
+
),
|
490 |
+
'product' => array(
|
491 |
+
'protected' => 1,
|
492 |
+
'sep' => '|',
|
493 |
+
'title' => '{{title}} {{page}} {{sep}} {{sitename}}',
|
494 |
+
'description' => '{{excerpt}}',
|
495 |
+
'noindex' => 0,
|
496 |
+
'nofollow' => 0,
|
497 |
+
'og_type' => 'product',
|
498 |
+
'jsonld_types' => array('product'),
|
499 |
+
'do_metas' => 1,
|
500 |
+
'do_sitemap' => 1,
|
501 |
+
'do_jsonld' => 1,
|
502 |
+
'do_pattern' => 1,
|
503 |
+
'do_og' => 1,
|
504 |
+
'do_twc' => 1,
|
505 |
+
'do_analytics' => 1,
|
506 |
+
'do_fpixel' => 1,
|
507 |
+
'do_redirects' => 1,
|
508 |
+
),
|
509 |
+
'category' => array(
|
510 |
+
'protected' => 1,
|
511 |
+
'sep' => '|',
|
512 |
+
'title' => '{{category}} {{page}} {{sep}} {{sitename}}',
|
513 |
+
'description' => '{{category_description}}',
|
514 |
+
'noindex' => 0,
|
515 |
+
'nofollow' => 0,
|
516 |
+
'og_type' => 'website',
|
517 |
+
'jsonld_types' => array('website'),
|
518 |
+
'do_metas' => 1,
|
519 |
+
'do_sitemap' => 1,
|
520 |
+
'do_jsonld' => 0,
|
521 |
+
'do_pattern' => 1,
|
522 |
+
'do_og' => 1,
|
523 |
+
'do_twc' => 1,
|
524 |
+
'do_analytics' => 1,
|
525 |
+
'do_fpixel' => 1,
|
526 |
+
'do_redirects' => 0,
|
527 |
+
),
|
528 |
+
'tag' => array(
|
529 |
+
'protected' => 1,
|
530 |
+
'sep' => '|',
|
531 |
+
'title' => '{{tag}} {{page}} {{sep}} {{sitename}}',
|
532 |
+
'description' => '{{excerpt}}',
|
533 |
+
'noindex' => 0,
|
534 |
+
'nofollow' => 0,
|
535 |
+
'og_type' => 'website',
|
536 |
+
'jsonld_types' => array('website'),
|
537 |
+
'do_metas' => 1,
|
538 |
+
'do_sitemap' => 1,
|
539 |
+
'do_jsonld' => 0,
|
540 |
+
'do_pattern' => 1,
|
541 |
+
'do_og' => 1,
|
542 |
+
'do_twc' => 1,
|
543 |
+
'do_analytics' => 1,
|
544 |
+
'do_fpixel' => 1,
|
545 |
+
'do_redirects' => 0,
|
546 |
+
),
|
547 |
+
'tax-product_cat' => array(
|
548 |
+
'protected' => 1,
|
549 |
+
'sep' => '|',
|
550 |
+
'title' => '{{term_title}} ' . esc_html__("Category", 'squirrly-seo') . ' {{page}} {{sep}} {{sitename}}',
|
551 |
+
'description' => '{{excerpt}}',
|
552 |
+
'noindex' => 0,
|
553 |
+
'nofollow' => 0,
|
554 |
+
'og_type' => 'website',
|
555 |
+
'jsonld_types' => array('website'),
|
556 |
+
'do_metas' => 1,
|
557 |
+
'do_sitemap' => 1,
|
558 |
+
'do_jsonld' => 1,
|
559 |
+
'do_pattern' => 1,
|
560 |
+
'do_og' => 1,
|
561 |
+
'do_twc' => 1,
|
562 |
+
'do_analytics' => 1,
|
563 |
+
'do_fpixel' => 1,
|
564 |
+
'do_redirects' => 0,
|
565 |
+
),
|
566 |
+
'tax-product_tag' => array(
|
567 |
+
'protected' => 1,
|
568 |
+
'sep' => '|',
|
569 |
+
'title' => '{{term_title}} ' . esc_html__("Tag", 'squirrly-seo') . ' {{page}} {{sep}} {{sitename}}',
|
570 |
+
'description' => '{{excerpt}}',
|
571 |
+
'noindex' => 0,
|
572 |
+
'nofollow' => 0,
|
573 |
+
'og_type' => 'website',
|
574 |
+
'jsonld_types' => array('website'),
|
575 |
+
'do_metas' => 1,
|
576 |
+
'do_sitemap' => 1,
|
577 |
+
'do_jsonld' => 1,
|
578 |
+
'do_pattern' => 1,
|
579 |
+
'do_og' => 1,
|
580 |
+
'do_twc' => 1,
|
581 |
+
'do_analytics' => 1,
|
582 |
+
'do_fpixel' => 1,
|
583 |
+
'do_redirects' => 0,
|
584 |
+
),
|
585 |
+
'tax-post_format' => array(
|
586 |
+
'protected' => 1,
|
587 |
+
'sep' => '|',
|
588 |
+
'title' => '{{term_title}} ' . esc_html__("Format", 'squirrly-seo') . ' {{page}} {{sep}} {{sitename}}',
|
589 |
+
'description' => '{{excerpt}}',
|
590 |
+
'noindex' => 0,
|
591 |
+
'nofollow' => 0,
|
592 |
+
'og_type' => 'website',
|
593 |
+
'jsonld_types' => array('website'),
|
594 |
+
'do_metas' => 1,
|
595 |
+
'do_sitemap' => 1,
|
596 |
+
'do_jsonld' => 1,
|
597 |
+
'do_pattern' => 1,
|
598 |
+
'do_og' => 1,
|
599 |
+
'do_twc' => 1,
|
600 |
+
'do_analytics' => 1,
|
601 |
+
'do_fpixel' => 1,
|
602 |
+
'do_redirects' => 0,
|
603 |
+
),
|
604 |
+
'tax-category' => array(
|
605 |
+
'protected' => 1,
|
606 |
+
'sep' => '|',
|
607 |
+
'title' => '{{term_title}} ' . esc_html__("Category", 'squirrly-seo') . ' {{page}} {{sep}} {{sitename}}',
|
608 |
+
'description' => '{{excerpt}}',
|
609 |
+
'noindex' => 0,
|
610 |
+
'nofollow' => 0,
|
611 |
+
'og_type' => 'website',
|
612 |
+
'jsonld_types' => array('website'),
|
613 |
+
'do_metas' => 1,
|
614 |
+
'do_sitemap' => 1,
|
615 |
+
'do_jsonld' => 1,
|
616 |
+
'do_pattern' => 1,
|
617 |
+
'do_og' => 1,
|
618 |
+
'do_twc' => 1,
|
619 |
+
'do_analytics' => 1,
|
620 |
+
'do_fpixel' => 1,
|
621 |
+
'do_redirects' => 0,
|
622 |
+
),
|
623 |
+
'tax-post_tag' => array(
|
624 |
+
'protected' => 1,
|
625 |
+
'sep' => '|',
|
626 |
+
'title' => '{{term_title}} ' . esc_html__("Tag", 'squirrly-seo') . ' {{page}} {{sep}} {{sitename}}',
|
627 |
+
'description' => '{{excerpt}}',
|
628 |
+
'noindex' => 0,
|
629 |
+
'nofollow' => 0,
|
630 |
+
'og_type' => 'website',
|
631 |
+
'jsonld_types' => array('website'),
|
632 |
+
'do_metas' => 1,
|
633 |
+
'do_sitemap' => 1,
|
634 |
+
'do_jsonld' => 1,
|
635 |
+
'do_pattern' => 1,
|
636 |
+
'do_og' => 1,
|
637 |
+
'do_twc' => 1,
|
638 |
+
'do_analytics' => 1,
|
639 |
+
'do_fpixel' => 1,
|
640 |
+
'do_redirects' => 0,
|
641 |
+
),
|
642 |
+
'tax-product_shipping_class' => array(
|
643 |
+
'protected' => 1,
|
644 |
+
'sep' => '|',
|
645 |
+
'title' => '{{term_title}} ' . esc_html__("Shipping Option", 'squirrly-seo') . ' {{page}} {{sep}} {{sitename}}',
|
646 |
+
'description' => '{{excerpt}}',
|
647 |
+
'noindex' => 0,
|
648 |
+
'nofollow' => 0,
|
649 |
+
'og_type' => 'website',
|
650 |
+
'jsonld_types' => array('website'),
|
651 |
+
'do_metas' => 1,
|
652 |
+
'do_sitemap' => 1,
|
653 |
+
'do_jsonld' => 1,
|
654 |
+
'do_pattern' => 1,
|
655 |
+
'do_og' => 1,
|
656 |
+
'do_twc' => 1,
|
657 |
+
'do_analytics' => 1,
|
658 |
+
'do_fpixel' => 1,
|
659 |
+
'do_redirects' => 0,
|
660 |
+
),
|
661 |
+
'shop' => array(
|
662 |
+
'protected' => 1,
|
663 |
+
'sep' => '|',
|
664 |
+
'title' => '{{title}} {{page}} {{sep}} {{sitename}}',
|
665 |
+
'description' => '{{excerpt}}',
|
666 |
+
'noindex' => 0,
|
667 |
+
'nofollow' => 0,
|
668 |
+
'og_type' => 'website',
|
669 |
+
'jsonld_types' => array('website'),
|
670 |
+
'do_metas' => 1,
|
671 |
+
'do_sitemap' => 1,
|
672 |
+
'do_jsonld' => 1,
|
673 |
+
'do_pattern' => 1,
|
674 |
+
'do_og' => 1,
|
675 |
+
'do_twc' => 1,
|
676 |
+
'do_analytics' => 1,
|
677 |
+
'do_fpixel' => 1,
|
678 |
+
'do_redirects' => 0,
|
679 |
+
),
|
680 |
+
'profile' => array(
|
681 |
+
'protected' => 1,
|
682 |
+
'sep' => '|',
|
683 |
+
'title' => '{{name}}, ' . esc_html__("Author at", 'squirrly-seo') . ' {{sitename}} {{page}}',
|
684 |
+
'description' => '{{excerpt}}',
|
685 |
+
'noindex' => 0,
|
686 |
+
'nofollow' => 0,
|
687 |
+
'og_type' => 'profile',
|
688 |
+
'jsonld_types' => array('profile'),
|
689 |
+
'do_metas' => 1,
|
690 |
+
'do_sitemap' => 1,
|
691 |
+
'do_jsonld' => 1,
|
692 |
+
'do_pattern' => 1,
|
693 |
+
'do_og' => 1,
|
694 |
+
'do_twc' => 1,
|
695 |
+
'do_analytics' => 1,
|
696 |
+
'do_fpixel' => 1,
|
697 |
+
'do_redirects' => 0,
|
698 |
+
),
|
699 |
+
'archive' => array(
|
700 |
+
'protected' => 1,
|
701 |
+
'sep' => '|',
|
702 |
+
'title' => '{{plural}} {{date}} {{page}} {{sep}} {{sitename}}',
|
703 |
+
'description' => '{{excerpt}}',
|
704 |
+
'noindex' => 0,
|
705 |
+
'nofollow' => 0,
|
706 |
+
'og_type' => 'website',
|
707 |
+
'jsonld_types' => array('website'),
|
708 |
+
'do_metas' => 1,
|
709 |
+
'do_sitemap' => 1,
|
710 |
+
'do_jsonld' => 1,
|
711 |
+
'do_pattern' => 1,
|
712 |
+
'do_og' => 1,
|
713 |
+
'do_twc' => 1,
|
714 |
+
'do_analytics' => 1,
|
715 |
+
'do_fpixel' => 1,
|
716 |
+
'do_redirects' => 0,
|
717 |
+
),
|
718 |
+
'search' => array(
|
719 |
+
'protected' => 1,
|
720 |
+
'sep' => '|',
|
721 |
+
'title' => esc_html__("Are you looking for", 'squirrly-seo') . ' {{searchphrase}}? {{page}} {{sep}} {{sitename}}',
|
722 |
+
'description' => esc_html__("These are the results for", 'squirrly-seo') . ' {{searchphrase}} ' . esc_html__("that you can find on our website.", 'squirrly-seo') . ' {{excerpt}}',
|
723 |
+
'noindex' => 1,
|
724 |
+
'nofollow' => 0,
|
725 |
+
'og_type' => 'website',
|
726 |
+
'jsonld_types' => array('website'),
|
727 |
+
'do_metas' => 1,
|
728 |
+
'do_sitemap' => 0,
|
729 |
+
'do_jsonld' => 1,
|
730 |
+
'do_pattern' => 1,
|
731 |
+
'do_og' => 1,
|
732 |
+
'do_twc' => 1,
|
733 |
+
'do_analytics' => 1,
|
734 |
+
'do_fpixel' => 1,
|
735 |
+
),
|
736 |
+
'attachment' => array(
|
737 |
+
'protected' => 1,
|
738 |
+
'sep' => '|',
|
739 |
+
'title' => '{{title}} {{page}} {{sep}} {{sitename}}',
|
740 |
+
'description' => '{{excerpt}}',
|
741 |
+
'noindex' => 0,
|
742 |
+
'nofollow' => 0,
|
743 |
+
'og_type' => 'website',
|
744 |
+
'jsonld_types' => array('website'),
|
745 |
+
'do_metas' => 1,
|
746 |
+
'do_sitemap' => 1,
|
747 |
+
'do_jsonld' => 1,
|
748 |
+
'do_pattern' => 1,
|
749 |
+
'do_og' => 1,
|
750 |
+
'do_twc' => 1,
|
751 |
+
'do_analytics' => 1,
|
752 |
+
'do_fpixel' => 1,
|
753 |
+
'do_redirects' => 1,
|
754 |
+
),
|
755 |
+
'404' => array(
|
756 |
+
'protected' => 1,
|
757 |
+
'sep' => '|',
|
758 |
+
'title' => esc_html__("Page not found", 'squirrly-seo') . ' {{sep}} {{sitename}}',
|
759 |
+
'description' => esc_html__("This page could not be found on our website.", 'squirrly-seo') . ' {{excerpt}}',
|
760 |
+
'noindex' => 1,
|
761 |
+
'nofollow' => 1,
|
762 |
+
'og_type' => 'website',
|
763 |
+
'jsonld_types' => array('website'),
|
764 |
+
'do_metas' => 1,
|
765 |
+
'do_sitemap' => 0,
|
766 |
+
'do_jsonld' => 0,
|
767 |
+
'do_pattern' => 1,
|
768 |
+
'do_og' => 0,
|
769 |
+
'do_twc' => 0,
|
770 |
+
'do_analytics' => 1,
|
771 |
+
'do_fpixel' => 1,
|
772 |
+
'do_redirects' => 0,
|
773 |
+
),
|
774 |
+
'custom' => array(
|
775 |
+
'protected' => 1,
|
776 |
+
'sep' => '|',
|
777 |
+
'title' => '{{title}} {{page}} {{sep}} {{sitename}}',
|
778 |
+
'description' => '{{excerpt}}',
|
779 |
+
'noindex' => 0,
|
780 |
+
'nofollow' => 0,
|
781 |
+
'og_type' => 'website',
|
782 |
+
'jsonld_types' => array('website'),
|
783 |
+
'do_metas' => 1,
|
784 |
+
'do_sitemap' => 1,
|
785 |
+
'do_jsonld' => 1,
|
786 |
+
'do_pattern' => 1,
|
787 |
+
'do_og' => 1,
|
788 |
+
'do_twc' => 1,
|
789 |
+
'do_analytics' => 1,
|
790 |
+
'do_fpixel' => 1,
|
791 |
+
'do_redirects' => 0,
|
792 |
+
),
|
793 |
+
)
|
794 |
+
|
795 |
+
);
|
796 |
+
$options = json_decode(get_option(SQ_OPTION), true);
|
797 |
+
|
798 |
+
//Update the Json-LD for Organization Logo
|
799 |
+
if (isset($options['sq_jsonld']['Organization']['logo']) && !is_array($options['sq_jsonld']['Organization']['logo'])) {
|
800 |
+
$options['sq_jsonld']['Organization']['logo'] = array(
|
801 |
+
'@type' => 'ImageObject',
|
802 |
+
'url' => $options['sq_jsonld']['Organization']['logo'],
|
803 |
+
);
|
804 |
+
}
|
805 |
+
|
806 |
+
if (isset($options['sq_jsonld']['Organization']['telephone']) && isset($options['sq_jsonld']['Organization']['contactType'])) {
|
807 |
+
$options['sq_jsonld']['Organization']['contactPoint'] = array(
|
808 |
+
'@type' => 'ContactPoint',
|
809 |
+
'telephone' => $options['sq_jsonld']['Organization']['telephone'],
|
810 |
+
'contactType' => $options['sq_jsonld']['Organization']['contactType']
|
811 |
+
);
|
812 |
+
|
813 |
+
unset($options['sq_jsonld']['Organization']['telephone']);
|
814 |
+
unset($options['sq_jsonld']['Organization']['contactType']);
|
815 |
+
}
|
816 |
+
|
817 |
+
//Update the Json-LD for Person Image
|
818 |
+
if (isset($options['sq_jsonld']['Person']['logo'])) {
|
819 |
+
$options['sq_jsonld']['Person']['image'] = array(
|
820 |
+
'@type' => 'ImageObject',
|
821 |
+
'url' => $options['sq_jsonld']['Person']['logo'],
|
822 |
+
);
|
823 |
+
|
824 |
+
unset($options['sq_jsonld']['Person']['logo']);
|
825 |
+
}
|
826 |
+
|
827 |
+
if ($action == 'reset') {
|
828 |
+
$init['sq_api'] = $options['sq_api'];
|
829 |
+
return $init;
|
830 |
+
}
|
831 |
+
|
832 |
+
if (is_array($options)) {
|
833 |
+
$options = array_replace_recursive((array)$default, (array)$options);
|
834 |
+
return $options;
|
835 |
+
}
|
836 |
+
|
837 |
+
return $default;
|
838 |
+
}
|
839 |
+
|
840 |
+
/**
|
841 |
+
* Get the option from database
|
842 |
+
*
|
843 |
+
* @param $key
|
844 |
+
* @return mixed
|
845 |
+
*/
|
846 |
+
public static function getOption($key)
|
847 |
+
{
|
848 |
+
if (!isset(self::$options[$key])) {
|
849 |
+
self::$options = self::getOptions();
|
850 |
+
|
851 |
+
if (!isset(self::$options[$key])) {
|
852 |
+
self::$options[$key] = false;
|
853 |
+
}
|
854 |
+
}
|
855 |
+
|
856 |
+
return apply_filters('sq_option_' . $key, self::$options[$key]);
|
857 |
+
}
|
858 |
+
|
859 |
+
/**
|
860 |
+
* Save the Options in user option table in DB
|
861 |
+
*
|
862 |
+
* @param null $key
|
863 |
+
* @param string $value
|
864 |
+
*/
|
865 |
+
public static function saveOptions($key = null, $value = '')
|
866 |
+
{
|
867 |
+
if (isset($key)) {
|
868 |
+
self::$options[$key] = $value;
|
869 |
+
}
|
870 |
+
|
871 |
+
update_option(SQ_OPTION, wp_json_encode(self::$options));
|
872 |
+
}
|
873 |
+
|
874 |
+
/**
|
875 |
+
* Get user metas
|
876 |
+
*
|
877 |
+
* @param null $user_id
|
878 |
+
* @return array|mixed
|
879 |
+
*/
|
880 |
+
public static function getUserMetas($user_id = null)
|
881 |
+
{
|
882 |
+
if (!isset($user_id)) {
|
883 |
+
$user_id = get_current_user_id();
|
884 |
+
}
|
885 |
+
|
886 |
+
$default = array('sq_auto_sticky' => 0,);
|
887 |
+
|
888 |
+
$usermeta = get_user_meta($user_id);
|
889 |
+
$usermetatmp = array();
|
890 |
+
if (is_array($usermeta)) foreach ($usermeta as $key => $values) {
|
891 |
+
$usermetatmp[$key] = $values[0];
|
892 |
+
}
|
893 |
+
$usermeta = $usermetatmp;
|
894 |
+
|
895 |
+
if (is_array($usermeta)) {
|
896 |
+
$usermeta = array_merge((array)$default, (array)$usermeta);
|
897 |
+
} else {
|
898 |
+
$usermeta = $default;
|
899 |
+
}
|
900 |
+
self::$usermeta = $usermeta;
|
901 |
+
return $usermeta;
|
902 |
+
}
|
903 |
+
|
904 |
+
/**
|
905 |
+
* Get use meta
|
906 |
+
*
|
907 |
+
* @param $value
|
908 |
+
* @return bool
|
909 |
+
*/
|
910 |
+
public static function getUserMeta($value)
|
911 |
+
{
|
912 |
+
if (!isset(self::$usermeta[$value])) {
|
913 |
+
self::getUserMetas();
|
914 |
+
}
|
915 |
+
|
916 |
+
if (isset(self::$usermeta[$value])) {
|
917 |
+
return apply_filters('sq_usermeta_' . $value, self::$usermeta[$value]);
|
918 |
+
}
|
919 |
+
|
920 |
+
return false;
|
921 |
+
}
|
922 |
+
|
923 |
+
/**
|
924 |
+
* Save user meta
|
925 |
+
*
|
926 |
+
* @param $key
|
927 |
+
* @param $value
|
928 |
+
* @param null $user_id
|
929 |
+
*/
|
930 |
+
public static function saveUserMeta($key, $value, $user_id = null)
|
931 |
+
{
|
932 |
+
if (!isset($user_id)) {
|
933 |
+
$user_id = get_current_user_id();
|
934 |
+
}
|
935 |
+
self::$usermeta[$key] = $value;
|
936 |
+
update_user_meta($user_id, $key, $value);
|
937 |
+
}
|
938 |
+
|
939 |
+
/**
|
940 |
+
* Delete User meta
|
941 |
+
*
|
942 |
+
* @param $key
|
943 |
+
* @param null $user_id
|
944 |
+
*/
|
945 |
+
public static function deleteUserMeta($key, $user_id = null)
|
946 |
+
{
|
947 |
+
if (!isset($user_id)) {
|
948 |
+
$user_id = get_current_user_id();
|
949 |
+
}
|
950 |
+
unset(self::$usermeta[$key]);
|
951 |
+
delete_user_meta($user_id, $key);
|
952 |
+
}
|
953 |
+
|
954 |
+
/**
|
955 |
+
* Get the option from database
|
956 |
+
*
|
957 |
+
* @param $key
|
958 |
+
* @return mixed
|
959 |
+
*/
|
960 |
+
public static function getMenuVisible($key)
|
961 |
+
{
|
962 |
+
if(self::$options['sq_auto_devkit']) {
|
963 |
+
if (!isset(self::$options['menu'][$key])) {
|
964 |
+
self::$options = self::getOptions();
|
965 |
+
|
966 |
+
if (!isset(self::$options['menu'][$key])) {
|
967 |
+
self::$options['menu'][$key] = false;
|
968 |
+
}
|
969 |
+
}
|
970 |
+
|
971 |
+
return apply_filters('sq_menu_visible', self::$options['menu'][$key], $key);
|
972 |
+
}
|
973 |
+
|
974 |
+
return true;
|
975 |
+
}
|
976 |
+
|
977 |
+
/**
|
978 |
+
* Set the header type
|
979 |
+
*
|
980 |
+
* @param string $type
|
981 |
+
*/
|
982 |
+
public static function setHeader($type)
|
983 |
+
{
|
984 |
+
if (self::getValue('sq_debug') == 'on') {
|
985 |
+
// header("Content-type: text/html");
|
986 |
+
return;
|
987 |
+
}
|
988 |
+
|
989 |
+
switch ($type) {
|
990 |
+
case 'json':
|
991 |
+
header('Content-Type: application/json');
|
992 |
+
break;
|
993 |
+
case 'ico':
|
994 |
+
header('Content-Type: image/x-icon');
|
995 |
+
break;
|
996 |
+
case 'png':
|
997 |
+
header('Content-Type: image/png');
|
998 |
+
break;
|
999 |
+
case'text':
|
1000 |
+
header("Content-type: text/plain");
|
1001 |
+
break;
|
1002 |
+
case'html':
|
1003 |
+
header("Content-type: text/html");
|
1004 |
+
break;
|
1005 |
+
}
|
1006 |
+
}
|
1007 |
+
|
1008 |
+
/**
|
1009 |
+
* Set the Nonce action
|
1010 |
+
*
|
1011 |
+
* @param $action
|
1012 |
+
* @param string $name
|
1013 |
+
* @param bool $referer
|
1014 |
+
* @param bool $echo
|
1015 |
+
* @return string
|
1016 |
+
*/
|
1017 |
+
public static function setNonce($action, $name = '_wpnonce', $referer = true, $echo = true)
|
1018 |
+
{
|
1019 |
+
$nonce_field = '<input type="hidden" name="' . esc_attr($name) . '" value="' . esc_attr(wp_create_nonce($action)) . '" />';
|
1020 |
+
|
1021 |
+
if ($referer) {
|
1022 |
+
$nonce_field .= wp_referer_field(false);
|
1023 |
+
}
|
1024 |
+
|
1025 |
+
if ($echo) {
|
1026 |
+
echo $nonce_field;
|
1027 |
+
}
|
1028 |
+
|
1029 |
+
return $nonce_field;
|
1030 |
+
}
|
1031 |
+
|
1032 |
+
/**
|
1033 |
+
* Get a value from $_POST / $_GET
|
1034 |
+
* if unavailable, take a default value
|
1035 |
+
*
|
1036 |
+
* @param string $key Value key
|
1037 |
+
* @param mixed $defaultValue (optional)
|
1038 |
+
* @param bool $htmlcode
|
1039 |
+
* @param bool $keep_newlines
|
1040 |
+
* @return mixed Value
|
1041 |
+
*/
|
1042 |
+
public static function getValue($key, $defaultValue = false, $keep_newlines = false)
|
1043 |
+
{
|
1044 |
+
if (!isset($key) || (isset($key) && $key == '')) {
|
1045 |
+
return $defaultValue;
|
1046 |
+
}
|
1047 |
+
|
1048 |
+
//Get the params from forms
|
1049 |
+
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
1050 |
+
$ret = (isset($_POST[$key]) ? $_POST[$key] : (isset($_GET[$key]) ? $_GET[$key] : ''));
|
1051 |
+
} else {
|
1052 |
+
$ret = (isset($_GET[$key]) ? $_GET[$key] : '');
|
1053 |
+
}
|
1054 |
+
|
1055 |
+
//Start sanitization of each param
|
1056 |
+
//based on the type
|
1057 |
+
if (is_array($ret)) { //if array, sanitize each value from the array
|
1058 |
+
if (!empty($ret)) {
|
1059 |
+
foreach ($ret as &$row) {
|
1060 |
+
if (!is_array($row)) {
|
1061 |
+
$row = sanitize_text_field($row); //sanitize
|
1062 |
+
}
|
1063 |
+
}
|
1064 |
+
}
|
1065 |
+
} elseif (is_string($ret) && $ret <> '' && $keep_newlines && function_exists('sanitize_textarea_field')) {
|
1066 |
+
$ret = sanitize_textarea_field($ret);
|
1067 |
+
} elseif (is_numeric($ret)) {
|
1068 |
+
$ret = (int) $ret;
|
1069 |
+
} else{
|
1070 |
+
$ret = sanitize_text_field($ret);
|
1071 |
+
}
|
1072 |
+
|
1073 |
+
if (!$ret) {
|
1074 |
+
return $defaultValue;
|
1075 |
+
} else {
|
1076 |
+
return wp_unslash($ret);
|
1077 |
+
}
|
1078 |
+
|
1079 |
+
}
|
1080 |
+
|
1081 |
+
/**
|
1082 |
+
* Check if the parameter is set
|
1083 |
+
*
|
1084 |
+
* @param string $key
|
1085 |
+
* @return boolean
|
1086 |
+
*/
|
1087 |
+
public static function getIsset($key)
|
1088 |
+
{
|
1089 |
+
return (isset($_GET[$key]) || isset($_POST[$key]));
|
1090 |
+
}
|
1091 |
+
|
1092 |
+
|
1093 |
+
/**
|
1094 |
+
* Find the string in the content
|
1095 |
+
*
|
1096 |
+
* @param string $content
|
1097 |
+
* @param string $string
|
1098 |
+
* @param bool $normalize
|
1099 |
+
* @return bool|false|int
|
1100 |
+
*/
|
1101 |
+
public static function findStr($content, $string, $normalize = false)
|
1102 |
+
{
|
1103 |
+
if ($normalize) {
|
1104 |
+
//Check if the search requires char normalization
|
1105 |
+
$content = SQ_Classes_Helpers_Sanitize::normalizeChars($content);
|
1106 |
+
$string = SQ_Classes_Helpers_Sanitize::normalizeChars($string);
|
1107 |
+
} else {
|
1108 |
+
//decode the content to match quotes and special chars
|
1109 |
+
$content = html_entity_decode($content, ENT_QUOTES);
|
1110 |
+
$string = html_entity_decode($string, ENT_QUOTES);
|
1111 |
+
}
|
1112 |
+
|
1113 |
+
if (function_exists('mb_stripos')) {
|
1114 |
+
return mb_stripos($content, $string);
|
1115 |
+
} else {
|
1116 |
+
SQ_Classes_Error::setMessage(esc_html__("For better text comparison you need to install PHP mbstring extension.", 'squirrly-seo'));
|
1117 |
+
|
1118 |
+
return stripos($content, $string);
|
1119 |
+
}
|
1120 |
+
}
|
1121 |
+
|
1122 |
+
/**
|
1123 |
+
* Load the multilanguage support from .mo
|
1124 |
+
*/
|
1125 |
+
private function loadMultilanguage()
|
1126 |
+
{
|
1127 |
+
load_plugin_textdomain(_SQ_PLUGIN_NAME_, false, _SQ_PLUGIN_NAME_ . '/languages/');
|
1128 |
+
}
|
1129 |
+
|
1130 |
+
/**
|
1131 |
+
* Hook the activate process
|
1132 |
+
*/
|
1133 |
+
public function sq_activate()
|
1134 |
+
{
|
1135 |
+
set_transient('sq_activate', true);
|
1136 |
+
set_transient('sq_import', true);
|
1137 |
+
SQ_Classes_ObjController::getClass('SQ_Models_RoleManager')->addSQRoles();
|
1138 |
+
}
|
1139 |
+
|
1140 |
+
/**
|
1141 |
+
* Hook the deactivate process
|
1142 |
+
*/
|
1143 |
+
public function sq_deactivate()
|
1144 |
+
{
|
1145 |
+
SQ_Classes_ObjController::getClass('SQ_Models_RoleManager')->removeSQCaps();
|
1146 |
+
SQ_Classes_ObjController::getClass('SQ_Models_RoleManager')->removeSQRoles();
|
1147 |
+
}
|
1148 |
+
|
1149 |
+
/**
|
1150 |
+
* Empty the cache from other plugins
|
1151 |
+
*/
|
1152 |
+
public static function emptyCache()
|
1153 |
+
{
|
1154 |
+
try {
|
1155 |
+
//////////////////////////////////////////////////////////////////////////////
|
1156 |
+
if (function_exists('w3tc_pgcache_flush')) {
|
1157 |
+
w3tc_pgcache_flush();
|
1158 |
+
}
|
1159 |
+
|
1160 |
+
if (function_exists('w3tc_minify_flush')) {
|
1161 |
+
w3tc_minify_flush();
|
1162 |
+
}
|
1163 |
+
if (function_exists('w3tc_dbcache_flush')) {
|
1164 |
+
w3tc_dbcache_flush();
|
1165 |
+
}
|
1166 |
+
if (function_exists('w3tc_objectcache_flush')) {
|
1167 |
+
w3tc_objectcache_flush();
|
1168 |
+
}
|
1169 |
+
//////////////////////////////////////////////////////////////////////////////
|
1170 |
+
|
1171 |
+
if (function_exists('wp_cache_clear_cache')) {
|
1172 |
+
wp_cache_clear_cache();
|
1173 |
+
}
|
1174 |
+
|
1175 |
+
if (function_exists('rocket_clean_domain') && function_exists('rocket_clean_minify') && function_exists('rocket_clean_cache_busting')) {
|
1176 |
+
// Remove all cache files
|
1177 |
+
rocket_clean_domain();
|
1178 |
+
rocket_clean_minify();
|
1179 |
+
rocket_clean_cache_busting();
|
1180 |
+
}
|
1181 |
+
//////////////////////////////////////////////////////////////////////////////
|
1182 |
+
|
1183 |
+
if (function_exists('apc_clear_cache')) {
|
1184 |
+
// Remove all apc if enabled
|
1185 |
+
apc_clear_cache();
|
1186 |
+
}
|
1187 |
+
//////////////////////////////////////////////////////////////////////////////
|
1188 |
+
|
1189 |
+
if (class_exists('Cache_Enabler_Disk') && method_exists('Cache_Enabler_Disk', 'clear_cache')) {
|
1190 |
+
// clear disk cache
|
1191 |
+
Cache_Enabler_Disk::clear_cache();
|
1192 |
+
}
|
1193 |
+
//////////////////////////////////////////////////////////////////////////////
|
1194 |
+
|
1195 |
+
if (class_exists('LiteSpeed_Cache')) {
|
1196 |
+
LiteSpeed_Cache::get_instance()->purge_all();
|
1197 |
+
}
|
1198 |
+
//////////////////////////////////////////////////////////////////////////////
|
1199 |
+
|
1200 |
+
if (self::isPluginInstalled('hummingbird-performance/wp-hummingbird.php')) {
|
1201 |
+
do_action('wphb_clear_page_cache');
|
1202 |
+
}
|
1203 |
+
//////////////////////////////////////////////////////////////////////////////
|
1204 |
+
|
1205 |
+
if (class_exists('WpeCommon')) {
|
1206 |
+
if (method_exists('WpeCommon', 'purge_memcached')) {
|
1207 |
+
WpeCommon::purge_memcached();
|
1208 |
+
}
|
1209 |
+
if (method_exists('WpeCommon', 'clear_maxcdn_cache')) {
|
1210 |
+
WpeCommon::clear_maxcdn_cache();
|
1211 |
+
}
|
1212 |
+
if (method_exists('WpeCommon', 'purge_varnish_cache')) {
|
1213 |
+
WpeCommon::purge_varnish_cache();
|
1214 |
+
}
|
1215 |
+
}
|
1216 |
+
//////////////////////////////////////////////////////////////////////////////
|
1217 |
+
|
1218 |
+
if (self::isPluginInstalled('sg-cachepress/sg-cachepress.php') && class_exists('Supercacher')) {
|
1219 |
+
if (method_exists('Supercacher', 'purge_cache') && method_exists('Supercacher', 'delete_assets')) {
|
1220 |
+
Supercacher::purge_cache();
|
1221 |
+
Supercacher::delete_assets();
|
1222 |
+
}
|
1223 |
+
}
|
1224 |
+
|
1225 |
+
//Clear the fastest cache
|
1226 |
+
global $wp_fastest_cache;
|
1227 |
+
if (isset($wp_fastest_cache) && method_exists($wp_fastest_cache, 'deleteCache')) {
|
1228 |
+
$wp_fastest_cache->deleteCache();
|
1229 |
+
}
|
1230 |
+
//////////////////////////////////////////////////////////////////////////////
|
1231 |
+
} catch (Exception $e) {
|
1232 |
+
|
1233 |
+
}
|
1234 |
+
}
|
1235 |
+
|
1236 |
+
/**
|
1237 |
+
* Check if a plugin is installed
|
1238 |
+
*
|
1239 |
+
* @param $name
|
1240 |
+
* @return bool
|
1241 |
+
*/
|
1242 |
+
public static function isPluginInstalled($name)
|
1243 |
+
{
|
1244 |
+
if (empty(self::$allplugins)) {
|
1245 |
+
self::$allplugins = (array)get_option('active_plugins', array());
|
1246 |
+
|
1247 |
+
if (is_multisite()) {
|
1248 |
+
self::$allplugins = array_merge(array_values(self::$allplugins), array_keys(get_site_option('active_sitewide_plugins')));
|
1249 |
+
}
|
1250 |
+
}
|
1251 |
+
|
1252 |
+
if (!empty(self::$allplugins)) {
|
1253 |
+
return in_array($name, self::$allplugins, true);
|
1254 |
+
}
|
1255 |
+
|
1256 |
+
return false;
|
1257 |
+
}
|
1258 |
+
|
1259 |
+
/**
|
1260 |
+
* Check if frontend and user is logged in
|
1261 |
+
*
|
1262 |
+
* @return bool
|
1263 |
+
*/
|
1264 |
+
public static function isFrontAdmin()
|
1265 |
+
{
|
1266 |
+
return (!is_admin() && (function_exists('is_user_logged_in') && is_user_logged_in()));
|
1267 |
+
}
|
1268 |
+
|
1269 |
+
/**
|
1270 |
+
* Check if user is in dashboard
|
1271 |
+
*
|
1272 |
+
* @return bool
|
1273 |
+
*/
|
1274 |
+
public static function isBackedAdmin()
|
1275 |
+
{
|
1276 |
+
return (is_admin() || is_network_admin());
|
1277 |
+
}
|
1278 |
+
|
1279 |
+
/**
|
1280 |
+
* Check if the current website is an E-commerce website
|
1281 |
+
*
|
1282 |
+
* @return bool
|
1283 |
+
*/
|
1284 |
+
public static function isEcommerce()
|
1285 |
+
{
|
1286 |
+
|
1287 |
+
if(self::isPluginInstalled('woocommerce/woocommerce.php')) {
|
1288 |
+
return true;
|
1289 |
+
}
|
1290 |
+
|
1291 |
+
$products = array('product', 'wpsc-product');
|
1292 |
+
$post_types = get_post_types(array('public' => true));
|
1293 |
+
|
1294 |
+
foreach ($products as $type) {
|
1295 |
+
if (in_array($type, array_keys($post_types))) {
|
1296 |
+
return true;
|
1297 |
+
}
|
1298 |
+
}
|
1299 |
+
|
1300 |
+
return false;
|
1301 |
+
}
|
1302 |
+
|
1303 |
+
/**
|
1304 |
+
* Check if it's an AMP Endpoint
|
1305 |
+
*
|
1306 |
+
* @return bool|void
|
1307 |
+
*/
|
1308 |
+
public static function isAMPEndpoint()
|
1309 |
+
{
|
1310 |
+
if (defined('AMPFORWP_AMP_QUERY_VAR')) {
|
1311 |
+
$url_path = trim(parse_url(add_query_arg(array()), PHP_URL_PATH), '/');
|
1312 |
+
$explode_path = explode('/', $url_path);
|
1313 |
+
if (AMPFORWP_AMP_QUERY_VAR === end($explode_path)) {
|
1314 |
+
return true;
|
1315 |
+
}
|
1316 |
+
}
|
1317 |
+
|
1318 |
+
if (function_exists('is_amp_endpoint')) {
|
1319 |
+
return is_amp_endpoint();
|
1320 |
+
}
|
1321 |
+
|
1322 |
+
if (function_exists('is_amp') && is_amp()) {
|
1323 |
+
return is_amp();
|
1324 |
+
}
|
1325 |
+
|
1326 |
+
if (function_exists('ampforwp_is_amp_endpoint')) {
|
1327 |
+
return ampforwp_is_amp_endpoint();
|
1328 |
+
}
|
1329 |
+
|
1330 |
+
return false;
|
1331 |
+
}
|
1332 |
+
|
1333 |
+
/**
|
1334 |
+
* Check the user capability for the roles attached
|
1335 |
+
*
|
1336 |
+
* @param $cap
|
1337 |
+
* @param mixed ...$args
|
1338 |
+
* @return bool
|
1339 |
+
*/
|
1340 |
+
public static function userCan($cap, ...$args )
|
1341 |
+
{
|
1342 |
+
|
1343 |
+
if (current_user_can($cap, ...$args)) {
|
1344 |
+
return true;
|
1345 |
+
}
|
1346 |
+
|
1347 |
+
$user = wp_get_current_user();
|
1348 |
+
if (count((array)$user->roles) > 1) {
|
1349 |
+
foreach ($user->roles as $role) {
|
1350 |
+
$role_object = get_role($role);
|
1351 |
+
if ($role_object->has_cap($cap)) {
|
1352 |
+
return true;
|
1353 |
+
}
|
1354 |
+
}
|
1355 |
+
}
|
1356 |
+
|
1357 |
+
return false;
|
1358 |
+
}
|
1359 |
+
|
1360 |
+
/**
|
1361 |
+
* Get the admin url for the specific age
|
1362 |
+
*
|
1363 |
+
* @param string $page
|
1364 |
+
* @param string $tab
|
1365 |
+
* @param array $args
|
1366 |
+
* @return string
|
1367 |
+
*/
|
1368 |
+
public static function getAdminUrl($page, $tab = null, $args = array())
|
1369 |
+
{
|
1370 |
+
if (strpos($page, '.php')) {
|
1371 |
+
$url = admin_url($page);
|
1372 |
+
} else {
|
1373 |
+
$url = admin_url('admin.php?page=' . $page);
|
1374 |
+
}
|
1375 |
+
|
1376 |
+
if (isset($tab) && $tab <> '') {
|
1377 |
+
$url .= '&tab=' . $tab;
|
1378 |
+
}
|
1379 |
+
|
1380 |
+
if (!empty($args)) {
|
1381 |
+
if (strpos($url, '?') !== false) {
|
1382 |
+
$url .= '&';
|
1383 |
+
} else {
|
1384 |
+
$url .= '?';
|
1385 |
+
}
|
1386 |
+
$url .= join('&', $args);
|
1387 |
+
}
|
1388 |
+
|
1389 |
+
return apply_filters('sq_menu_url', $url, $page, $tab, $args);
|
1390 |
+
}
|
1391 |
+
|
1392 |
+
/**
|
1393 |
+
* Instantiates the WordPress filesystem.
|
1394 |
+
*
|
1395 |
+
* @static
|
1396 |
+
* @access public
|
1397 |
+
* @return object
|
1398 |
+
*/
|
1399 |
+
public static function initFilesystem()
|
1400 |
+
{
|
1401 |
+
// The WordPress filesystem.
|
1402 |
+
global $wp_filesystem;
|
1403 |
+
|
1404 |
+
if (!$wp_filesystem || empty($wp_filesystem)) {
|
1405 |
+
include_once wp_normalize_path(ABSPATH . '/wp-admin/includes/file.php');
|
1406 |
+
WP_Filesystem();
|
1407 |
+
}
|
1408 |
+
|
1409 |
+
return $wp_filesystem;
|
1410 |
+
}
|
1411 |
+
}
|
config/config.php
CHANGED
@@ -1,82 +1,90 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
/**
|
5 |
-
* The configuration file
|
6 |
-
*/
|
7 |
-
if (!defined('_SQ_NONCE_ID_')) {
|
8 |
-
if (defined('NONCE_KEY')) {
|
9 |
-
define('_SQ_NONCE_ID_', NONCE_KEY);
|
10 |
-
} else {
|
11 |
-
define('_SQ_NONCE_ID_', md5(date('Y-d')));
|
12 |
-
}
|
13 |
-
}
|
14 |
-
|
15 |
-
define('_SQ_MOBILE_ICON_SIZES', '76,120,152');
|
16 |
-
|
17 |
-
define('SQ_ONBOARDING', '9.0.0');
|
18 |
-
defined('SQ_DEBUG') || define('SQ_DEBUG', 0);
|
19 |
-
define('SQ_REQUEST_TIME', microtime(true));
|
20 |
-
|
21 |
-
/* No path file? error ... */
|
22 |
-
require_once
|
23 |
-
|
24 |
-
/* Define the record name in the Option and UserMeta tables */
|
25 |
-
defined('SQ_OPTION') || define('SQ_OPTION', 'sq_options');
|
26 |
-
defined('SQ_TASKS') || define('SQ_TASKS', 'sq_tasks');
|
27 |
-
defined('_SQ_DB_') || define('_SQ_DB_', 'qss');
|
28 |
-
|
29 |
-
define(
|
30 |
-
'
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
)
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
'
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
/**
|
5 |
+
* The configuration file
|
6 |
+
*/
|
7 |
+
if (!defined('_SQ_NONCE_ID_')) {
|
8 |
+
if (defined('NONCE_KEY')) {
|
9 |
+
define('_SQ_NONCE_ID_', NONCE_KEY);
|
10 |
+
} else {
|
11 |
+
define('_SQ_NONCE_ID_', md5(date('Y-d')));
|
12 |
+
}
|
13 |
+
}
|
14 |
+
|
15 |
+
define('_SQ_MOBILE_ICON_SIZES', '76,120,152');
|
16 |
+
|
17 |
+
define('SQ_ONBOARDING', '9.0.0');
|
18 |
+
defined('SQ_DEBUG') || define('SQ_DEBUG', 0);
|
19 |
+
define('SQ_REQUEST_TIME', microtime(true));
|
20 |
+
|
21 |
+
/* No path file? error ... */
|
22 |
+
require_once dirname(__FILE__) . '/paths.php';
|
23 |
+
|
24 |
+
/* Define the record name in the Option and UserMeta tables */
|
25 |
+
defined('SQ_OPTION') || define('SQ_OPTION', 'sq_options');
|
26 |
+
defined('SQ_TASKS') || define('SQ_TASKS', 'sq_tasks');
|
27 |
+
defined('_SQ_DB_') || define('_SQ_DB_', 'qss');
|
28 |
+
|
29 |
+
define(
|
30 |
+
'SQ_ALL_PATTERNS', wp_json_encode(
|
31 |
+
array(
|
32 |
+
'{{sep}}' => esc_html__("Places a separator between the elements of the post description", 'squirrly-seo'),
|
33 |
+
'{{title}}' => esc_html__("Adds the title of the post/page/term once it’s published", 'squirrly-seo'),
|
34 |
+
'{{excerpt}}' => esc_html__("Will display an excerpt from the post/page/term (if not customized, the excerpt will be auto-generated)", 'squirrly-seo'),
|
35 |
+
'{{excerpt_only}}' => esc_html__("Will display an excerpt from the post/page (no auto-generation)", 'squirrly-seo'),
|
36 |
+
'{{keyword}}' => esc_html__("Adds the post's keyword to the post description", 'squirrly-seo'),
|
37 |
+
'{{page}}' => esc_html__("Displays the number of the current page (i.e. 1 of 6)", 'squirrly-seo'),
|
38 |
+
'{{sitename}}' => esc_html__("Adds the site's name to the post description", 'squirrly-seo'),
|
39 |
+
'{{sitedesc}}' => esc_html__("Adds the tagline/description of your site", 'squirrly-seo'),
|
40 |
+
'{{category}}' => esc_html__("Adds the post category (several categories will be comma-separated)", 'squirrly-seo'),
|
41 |
+
'{{primary_category}}' => esc_html__("Adds the primary category of the post/page", 'squirrly-seo'),
|
42 |
+
'{{category_description}}' => esc_html__("Adds the category description to the post description", 'squirrly-seo'),
|
43 |
+
'{{tag}}' => esc_html__("Adds the current tag(s) (several tags will be comma-separated)", 'squirrly-seo'),
|
44 |
+
'{{tag_description}}' => esc_html__("Adds the tag description", 'squirrly-seo'),
|
45 |
+
'{{term_title}}' => esc_html__("Adds the term name", 'squirrly-seo'),
|
46 |
+
'{{term_description}}' => esc_html__("Adds the term description", 'squirrly-seo'),
|
47 |
+
'{{searchphrase}}' => esc_html__("Displays the search phrase (if it appears in the post)", 'squirrly-seo'),
|
48 |
+
'{{modified}}' => esc_html__("Replaces the publication date of a post/page with the modified one", 'squirrly-seo'),
|
49 |
+
'{{name}}' => esc_html__("Displays the author's nicename", 'squirrly-seo'),
|
50 |
+
'{{single}}' => esc_html__("Displays the post type singular label", 'squirrly-seo'),
|
51 |
+
'{{plural}}' => esc_html__("Displays the post type plural label", 'squirrly-seo'),
|
52 |
+
'{{user_description}}' => esc_html__("Adds the author's biographical info to the post description", 'squirrly-seo'),
|
53 |
+
'{{date}}' => esc_html__("Displays the date of the post/page once it's published", 'squirrly-seo'),
|
54 |
+
'{{currentdate}}' => esc_html__("Displays the current date", 'squirrly-seo'),
|
55 |
+
'{{currentday}}' => esc_html__("Adds the current day", 'squirrly-seo'),
|
56 |
+
'{{currentmonth}}' => esc_html__("Adds the current month", 'squirrly-seo'),
|
57 |
+
'{{currentyear}}' => esc_html__("Adds the current year", 'squirrly-seo'),
|
58 |
+
'{{parent_title}}' => esc_html__("Adds the title of a page's parent page", 'squirrly-seo'),
|
59 |
+
'{{product_name}}' => esc_html__("Adds the product name from Woocommerce for the current product", 'squirrly-seo'),
|
60 |
+
'{{product_price}}' => esc_html__("Adds the product price from Woocommerce for the current product", 'squirrly-seo'),
|
61 |
+
'{{product_price_with_tax}}' => esc_html__("Adds the product price with Tax from Woocommerce for the current product", 'squirrly-seo'),
|
62 |
+
'{{product_sale}}' => esc_html__("Adds the product sale price from Woocommerce for the current product", 'squirrly-seo'),
|
63 |
+
'{{product_currency}}' => esc_html__("Adds the product price currency from Woocommerce for the current product", 'squirrly-seo'),
|
64 |
+
'{{product_brand}}' => esc_html__("Adds the product brand from Woocommerce for the current product", 'squirrly-seo'),
|
65 |
+
)
|
66 |
+
)
|
67 |
+
);
|
68 |
+
|
69 |
+
define('SQ_ALL_OG_TYPES', wp_json_encode(array('website', 'article', 'profile', 'book', 'music', 'video')));
|
70 |
+
define('SQ_ALL_JSONLD_TYPES', wp_json_encode(array('website', 'article', 'newsarticle', 'FAQ page', 'question', 'recipe', 'review', 'movie', 'video', 'local store', 'local restaurant', 'profile')));
|
71 |
+
|
72 |
+
define(
|
73 |
+
'SQ_ALL_SEP', wp_json_encode(
|
74 |
+
array(
|
75 |
+
'sc-dash' => '-',
|
76 |
+
'sc-ndash' => '–',
|
77 |
+
'sc-mdash' => '—',
|
78 |
+
'sc-middot' => '·',
|
79 |
+
'sc-bull' => '•',
|
80 |
+
'sc-star' => '*',
|
81 |
+
'sc-smstar' => '⋆',
|
82 |
+
'sc-pipe' => '|',
|
83 |
+
'sc-tilde' => '~',
|
84 |
+
'sc-laquo' => '«',
|
85 |
+
'sc-raquo' => '»',
|
86 |
+
'sc-lt' => '<',
|
87 |
+
'sc-gt' => '>',
|
88 |
+
)
|
89 |
+
)
|
90 |
+
);
|
config/paths.php
CHANGED
@@ -1,66 +1,66 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
$currentDir = dirname(__FILE__);
|
5 |
-
|
6 |
-
define('_SQ_NAME_', 'squirrly');
|
7 |
-
define('_SQ_MENU_NAME_', 'Squirrly SEO');
|
8 |
-
define('_SQ_NAMESPACE_', 'SQ');
|
9 |
-
define('_SQ_PLUGIN_NAME_', 'squirrly-seo'); //THIS LINE WILL BE CHANGED WITH THE USER SETTINGS
|
10 |
-
|
11 |
-
defined('SQ_SSL') || define('SQ_SSL', (((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") || (defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN) || (function_exists('is_ssl') && is_ssl())) ? true : false)); //CHECK SSL
|
12 |
-
defined('SQ_CHECK_SSL') || define('SQ_CHECK_SSL', SQ_SSL);
|
13 |
-
defined('SQ_URI') || define('SQ_URI', 'wp530');
|
14 |
-
defined('_SQ_DASH_URL_') || define('_SQ_DASH_URL_', 'https://cloud.squirrly.co/');
|
15 |
-
defined('_SQ_APIV2_URL_') || define('_SQ_APIV2_URL_', (SQ_SSL ? 'https:' : 'http:') . '//api.squirrly.co/v2/');
|
16 |
-
define('_SQ_SITE_HOST_', parse_url(home_url(), PHP_URL_HOST));
|
17 |
-
|
18 |
-
define('_SQ_SUPPORT_EMAIL_', 'support@squirrly.co');
|
19 |
-
defined('_SQ_STATIC_API_URL_') || define('_SQ_STATIC_API_URL_', '//storage.googleapis.com/squirrly/');
|
20 |
-
defined('_SQ_SUPPORT_EMAIL_URL_') || define('_SQ_SUPPORT_EMAIL_URL_', 'http://plugin.squirrly.co/contact/');
|
21 |
-
defined('_SQ_SUPPORT_FACEBOOK_URL_') || define('_SQ_SUPPORT_FACEBOOK_URL_', 'https://www.facebook.com/Squirrly.co');
|
22 |
-
defined('_SQ_HOWTO_URL_') || define('_SQ_HOWTO_URL_', 'https://howto.squirrly.co/wordpress-seo/');
|
23 |
-
defined('_SQ_SUPPORT_URL_') || define('_SQ_SUPPORT_URL_', 'https://www.dmsuperstars.com/squirrly-support/');
|
24 |
-
|
25 |
-
/* Directories */
|
26 |
-
define('_SQ_ROOT_DIR_', realpath(dirname($currentDir)) . '/');
|
27 |
-
define('_SQ_CLASSES_DIR_', _SQ_ROOT_DIR_ . 'classes/');
|
28 |
-
define('_SQ_CONTROLLER_DIR_', _SQ_ROOT_DIR_ . 'controllers/');
|
29 |
-
define('_SQ_MODEL_DIR_', _SQ_ROOT_DIR_ . 'models/');
|
30 |
-
define('_SQ_SERVICE_DIR_', _SQ_MODEL_DIR_ . 'services/');
|
31 |
-
define('_SQ_TRANSLATIONS_DIR_', _SQ_ROOT_DIR_ . 'translations/');
|
32 |
-
define('_SQ_CORE_DIR_', _SQ_ROOT_DIR_ . 'core/');
|
33 |
-
define('_SQ_THEME_DIR_', _SQ_ROOT_DIR_ . 'view/');
|
34 |
-
define('_SQ_ASSETS_DIR_', _SQ_THEME_DIR_ . 'assets/');
|
35 |
-
|
36 |
-
/* URLS */
|
37 |
-
define('_SQ_URL_', rtrim(plugins_url('', $currentDir), '/') . '/');
|
38 |
-
define('_SQ_THEME_URL_', _SQ_URL_ . 'view/');
|
39 |
-
define('_SQ_ASSETS_URL_', _SQ_THEME_URL_ . 'assets/');
|
40 |
-
define('_SQ_ASSETS_RELATIVE_URL_', ltrim(parse_url(_SQ_ASSETS_URL_, PHP_URL_PATH), '/'));
|
41 |
-
|
42 |
-
|
43 |
-
$upload_dir = array();
|
44 |
-
$upload_dir['baseurl'] = WP_CONTENT_URL . '/uploads';
|
45 |
-
$upload_dir['basedir'] = WP_CONTENT_DIR . '/uploads';
|
46 |
-
|
47 |
-
if (!defined('UPLOADS')) {
|
48 |
-
$basedir = WP_CONTENT_DIR . '/uploads/' . _SQ_NAME_;
|
49 |
-
$baseurl = rtrim(content_url(), '/') . '/uploads/' . _SQ_NAME_;
|
50 |
-
} else {
|
51 |
-
$basedir = rtrim(ABSPATH, '/') . '/' . trim(UPLOADS, '/') . '/' . _SQ_NAME_;
|
52 |
-
$baseurl = home_url() . '/' . trim(UPLOADS, '/') . '/' . _SQ_NAME_;
|
53 |
-
}
|
54 |
-
|
55 |
-
if (!is_dir($basedir)) {
|
56 |
-
@wp_mkdir_p($basedir);
|
57 |
-
}
|
58 |
-
|
59 |
-
if (!is_dir($basedir) || !function_exists('wp_is_writable') || !wp_is_writable($basedir)) {
|
60 |
-
$basedir = _SQ_ROOT_DIR_ . 'cache';
|
61 |
-
$baseurl = _SQ_URL_ . 'cache';
|
62 |
-
}
|
63 |
-
|
64 |
-
defined('_SQ_CACHE_DIR_') || define('_SQ_CACHE_DIR_', $basedir . '/');
|
65 |
-
defined('_SQ_CACHE_URL_') || define('_SQ_CACHE_URL_', $baseurl . '/');
|
66 |
-
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
$currentDir = dirname(__FILE__);
|
5 |
+
|
6 |
+
define('_SQ_NAME_', 'squirrly');
|
7 |
+
define('_SQ_MENU_NAME_', 'Squirrly SEO');
|
8 |
+
define('_SQ_NAMESPACE_', 'SQ');
|
9 |
+
define('_SQ_PLUGIN_NAME_', 'squirrly-seo'); //THIS LINE WILL BE CHANGED WITH THE USER SETTINGS
|
10 |
+
|
11 |
+
defined('SQ_SSL') || define('SQ_SSL', (((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") || (defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN) || (function_exists('is_ssl') && is_ssl())) ? true : false)); //CHECK SSL
|
12 |
+
defined('SQ_CHECK_SSL') || define('SQ_CHECK_SSL', SQ_SSL);
|
13 |
+
defined('SQ_URI') || define('SQ_URI', 'wp530');
|
14 |
+
defined('_SQ_DASH_URL_') || define('_SQ_DASH_URL_', 'https://cloud.squirrly.co/');
|
15 |
+
defined('_SQ_APIV2_URL_') || define('_SQ_APIV2_URL_', (SQ_SSL ? 'https:' : 'http:') . '//api.squirrly.co/v2/');
|
16 |
+
define('_SQ_SITE_HOST_', parse_url(home_url(), PHP_URL_HOST));
|
17 |
+
|
18 |
+
define('_SQ_SUPPORT_EMAIL_', 'support@squirrly.co');
|
19 |
+
defined('_SQ_STATIC_API_URL_') || define('_SQ_STATIC_API_URL_', '//storage.googleapis.com/squirrly/');
|
20 |
+
defined('_SQ_SUPPORT_EMAIL_URL_') || define('_SQ_SUPPORT_EMAIL_URL_', 'http://plugin.squirrly.co/contact/');
|
21 |
+
defined('_SQ_SUPPORT_FACEBOOK_URL_') || define('_SQ_SUPPORT_FACEBOOK_URL_', 'https://www.facebook.com/Squirrly.co');
|
22 |
+
defined('_SQ_HOWTO_URL_') || define('_SQ_HOWTO_URL_', 'https://howto.squirrly.co/wordpress-seo/');
|
23 |
+
defined('_SQ_SUPPORT_URL_') || define('_SQ_SUPPORT_URL_', 'https://www.dmsuperstars.com/squirrly-support/');
|
24 |
+
|
25 |
+
/* Directories */
|
26 |
+
define('_SQ_ROOT_DIR_', realpath(dirname($currentDir)) . '/');
|
27 |
+
define('_SQ_CLASSES_DIR_', _SQ_ROOT_DIR_ . 'classes/');
|
28 |
+
define('_SQ_CONTROLLER_DIR_', _SQ_ROOT_DIR_ . 'controllers/');
|
29 |
+
define('_SQ_MODEL_DIR_', _SQ_ROOT_DIR_ . 'models/');
|
30 |
+
define('_SQ_SERVICE_DIR_', _SQ_MODEL_DIR_ . 'services/');
|
31 |
+
define('_SQ_TRANSLATIONS_DIR_', _SQ_ROOT_DIR_ . 'translations/');
|
32 |
+
define('_SQ_CORE_DIR_', _SQ_ROOT_DIR_ . 'core/');
|
33 |
+
define('_SQ_THEME_DIR_', _SQ_ROOT_DIR_ . 'view/');
|
34 |
+
define('_SQ_ASSETS_DIR_', _SQ_THEME_DIR_ . 'assets/');
|
35 |
+
|
36 |
+
/* URLS */
|
37 |
+
define('_SQ_URL_', rtrim(plugins_url('', $currentDir), '/') . '/');
|
38 |
+
define('_SQ_THEME_URL_', _SQ_URL_ . 'view/');
|
39 |
+
define('_SQ_ASSETS_URL_', _SQ_THEME_URL_ . 'assets/');
|
40 |
+
define('_SQ_ASSETS_RELATIVE_URL_', ltrim(parse_url(_SQ_ASSETS_URL_, PHP_URL_PATH), '/'));
|
41 |
+
|
42 |
+
|
43 |
+
$upload_dir = array();
|
44 |
+
$upload_dir['baseurl'] = WP_CONTENT_URL . '/uploads';
|
45 |
+
$upload_dir['basedir'] = WP_CONTENT_DIR . '/uploads';
|
46 |
+
|
47 |
+
if (!defined('UPLOADS')) {
|
48 |
+
$basedir = WP_CONTENT_DIR . '/uploads/' . _SQ_NAME_;
|
49 |
+
$baseurl = rtrim(content_url(), '/') . '/uploads/' . _SQ_NAME_;
|
50 |
+
} else {
|
51 |
+
$basedir = rtrim(ABSPATH, '/') . '/' . trim(UPLOADS, '/') . '/' . _SQ_NAME_;
|
52 |
+
$baseurl = home_url() . '/' . trim(UPLOADS, '/') . '/' . _SQ_NAME_;
|
53 |
+
}
|
54 |
+
|
55 |
+
if (!is_dir($basedir)) {
|
56 |
+
@wp_mkdir_p($basedir);
|
57 |
+
}
|
58 |
+
|
59 |
+
if (!is_dir($basedir) || !function_exists('wp_is_writable') || !wp_is_writable($basedir)) {
|
60 |
+
$basedir = _SQ_ROOT_DIR_ . 'cache';
|
61 |
+
$baseurl = _SQ_URL_ . 'cache';
|
62 |
+
}
|
63 |
+
|
64 |
+
defined('_SQ_CACHE_DIR_') || define('_SQ_CACHE_DIR_', $basedir . '/');
|
65 |
+
defined('_SQ_CACHE_URL_') || define('_SQ_CACHE_URL_', $baseurl . '/');
|
66 |
+
|
controllers/Account.php
CHANGED
@@ -1,39 +1,45 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
/**
|
5 |
-
* User Account
|
6 |
-
*/
|
7 |
-
class SQ_Controllers_Account extends SQ_Classes_FrontController
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
/**
|
5 |
+
* User Account
|
6 |
+
*/
|
7 |
+
class SQ_Controllers_Account extends SQ_Classes_FrontController
|
8 |
+
{
|
9 |
+
|
10 |
+
/**
|
11 |
+
*
|
12 |
+
*
|
13 |
+
* @var object Checkin process
|
14 |
+
*/
|
15 |
+
public $checkin;
|
16 |
+
|
17 |
+
public function action()
|
18 |
+
{
|
19 |
+
|
20 |
+
switch (SQ_Classes_Helpers_Tools::getValue('action')) {
|
21 |
+
case 'sq_ajax_account_getaccount':
|
22 |
+
$json = array();
|
23 |
+
|
24 |
+
$this->checkin = SQ_Classes_RemoteController::checkin();
|
25 |
+
|
26 |
+
if (!is_wp_error($this->checkin)) {
|
27 |
+
|
28 |
+
$json['html'] = $this->get_view('Blocks/Account');
|
29 |
+
|
30 |
+
if (SQ_Classes_Helpers_Tools::isAjax()) {
|
31 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
32 |
+
|
33 |
+
if (SQ_Classes_Error::isError()) {
|
34 |
+
$json['error'] = SQ_Classes_Error::getError();
|
35 |
+
}
|
36 |
+
|
37 |
+
echo wp_json_encode($json);
|
38 |
+
exit();
|
39 |
+
}
|
40 |
+
|
41 |
+
}
|
42 |
+
break;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
controllers/Api.php
CHANGED
@@ -1,194 +1,213 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Controllers_Api extends SQ_Classes_FrontController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
*
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
if
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
'
|
40 |
-
'
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
}
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Controllers_Api extends SQ_Classes_FrontController
|
5 |
+
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
*
|
9 |
+
*
|
10 |
+
* @var string token local key
|
11 |
+
*/
|
12 |
+
private $token;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Initialize the TinyMCE editor for the current use
|
16 |
+
*
|
17 |
+
* @return void
|
18 |
+
*/
|
19 |
+
public function hookInit()
|
20 |
+
{
|
21 |
+
|
22 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_api') == '')
|
23 |
+
return;
|
24 |
+
|
25 |
+
if (!SQ_Classes_Helpers_Tools::getOption('sq_cloud_connect'))
|
26 |
+
return;
|
27 |
+
|
28 |
+
$this->token = SQ_Classes_Helpers_Tools::getOption('sq_cloud_token');
|
29 |
+
|
30 |
+
//Change the rest api if needed
|
31 |
+
add_action('rest_api_init', array($this, 'sqApiCall'));
|
32 |
+
}
|
33 |
+
|
34 |
+
|
35 |
+
function sqApiCall()
|
36 |
+
{
|
37 |
+
if (function_exists('register_rest_route')) {
|
38 |
+
register_rest_route(
|
39 |
+
'save', '/squirrly/', array(
|
40 |
+
'methods' => WP_REST_Server::EDITABLE,
|
41 |
+
'callback' => array($this, 'savePost'),
|
42 |
+
'permission_callback' => '__return_true'
|
43 |
+
)
|
44 |
+
);
|
45 |
+
|
46 |
+
register_rest_route(
|
47 |
+
'test', '/squirrly/', array(
|
48 |
+
'methods' => WP_REST_Server::EDITABLE,
|
49 |
+
'callback' => array($this, 'testConnection'),
|
50 |
+
'permission_callback' => '__return_true'
|
51 |
+
)
|
52 |
+
);
|
53 |
+
|
54 |
+
register_rest_route(
|
55 |
+
'get', '/squirrly/', array(
|
56 |
+
'methods' => WP_REST_Server::READABLE,
|
57 |
+
'callback' => array($this, 'getData'),
|
58 |
+
'permission_callback' => '__return_true'
|
59 |
+
)
|
60 |
+
);
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Test the connection
|
66 |
+
*
|
67 |
+
* @param WP_REST_Request $request Full details about the request.
|
68 |
+
*/
|
69 |
+
public function testConnection($request)
|
70 |
+
{
|
71 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
72 |
+
|
73 |
+
//get the token from API
|
74 |
+
$token = $request->get_param('token');
|
75 |
+
if ($token <> '') {
|
76 |
+
$token = sanitize_text_field($token);
|
77 |
+
}
|
78 |
+
|
79 |
+
if (!$this->token || $this->token <> $token) {
|
80 |
+
exit(wp_json_encode(array('connected' => false, 'error' => esc_html__("Invalid Token. Please try again", 'squirrly-seo'))));
|
81 |
+
}
|
82 |
+
|
83 |
+
echo wp_json_encode(array('connected' => true, 'error' => false));
|
84 |
+
exit();
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Save the Post
|
89 |
+
*
|
90 |
+
* @param WP_REST_Request $request Full details about the request.
|
91 |
+
*/
|
92 |
+
public function savePost($request)
|
93 |
+
{
|
94 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
95 |
+
|
96 |
+
//get the token from API
|
97 |
+
$token = $request->get_param('token');
|
98 |
+
if ($token <> '') {
|
99 |
+
$token = sanitize_text_field($token);
|
100 |
+
}
|
101 |
+
|
102 |
+
if (!$this->token || $this->token <> $token) {
|
103 |
+
exit(wp_json_encode(array('error' => esc_html__("Connection expired. Please try again", 'squirrly-seo'))));
|
104 |
+
}
|
105 |
+
|
106 |
+
$post = $request->get_param('post');
|
107 |
+
if ($post = json_decode($post)) {
|
108 |
+
if (isset($post->ID) && $post->ID > 0) {
|
109 |
+
$post = new WP_Post($post);
|
110 |
+
$post->ID = 0;
|
111 |
+
if (isset($post->post_author)) {
|
112 |
+
if (is_email($post->post_author)) {
|
113 |
+
if ($user = get_user_by('email', $post->post_author)) {
|
114 |
+
$post->post_author = $user->ID;
|
115 |
+
} else {
|
116 |
+
exit(wp_json_encode(array('error' => esc_html__("Author not found", 'squirrly-seo'))));
|
117 |
+
}
|
118 |
+
} else {
|
119 |
+
exit(wp_json_encode(array('error' => esc_html__("Author not found", 'squirrly-seo'))));
|
120 |
+
}
|
121 |
+
} else {
|
122 |
+
exit(wp_json_encode(array('error' => esc_html__("Author not found", 'squirrly-seo'))));
|
123 |
+
}
|
124 |
+
|
125 |
+
$post_ID = wp_insert_post($post->to_array());
|
126 |
+
if (is_wp_error($post_ID)) {
|
127 |
+
echo wp_json_encode(array('error' => $post_ID->get_error_message()));
|
128 |
+
} else {
|
129 |
+
echo wp_json_encode(array('saved' => true, 'post_ID' => $post_ID, 'permalink' => get_permalink($post_ID)));
|
130 |
+
}
|
131 |
+
exit();
|
132 |
+
}
|
133 |
+
}
|
134 |
+
echo wp_json_encode(array('error' => true));
|
135 |
+
exit();
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Get data for the Focus Page Audit
|
140 |
+
*
|
141 |
+
* @param \WP_REST_Request $request
|
142 |
+
*/
|
143 |
+
public function getData($request)
|
144 |
+
{
|
145 |
+
|
146 |
+
global $wpdb;
|
147 |
+
$response = array();
|
148 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
149 |
+
|
150 |
+
//get the token from API
|
151 |
+
$token = $request->get_param('token');
|
152 |
+
if ($token <> '') {
|
153 |
+
$token = sanitize_text_field($token);
|
154 |
+
}
|
155 |
+
|
156 |
+
if (!$this->token || $this->token <> $token) {
|
157 |
+
exit(wp_json_encode(array('error' => esc_html__("Connection expired. Please try again.", 'squirrly-seo'))));
|
158 |
+
}
|
159 |
+
|
160 |
+
$select = $request->get_param('select');
|
161 |
+
|
162 |
+
|
163 |
+
switch ($select) {
|
164 |
+
case 'innerlinks':
|
165 |
+
$url = $request->get_param('url');
|
166 |
+
if ($url == '') {
|
167 |
+
exit(wp_json_encode(array('error' => esc_html__("Wrong Params", 'squirrly-seo'))));
|
168 |
+
}
|
169 |
+
|
170 |
+
//get post inner links
|
171 |
+
$total_posts = 0;
|
172 |
+
$inner_links = array();
|
173 |
+
if ($row = $wpdb->get_row($wpdb->prepare("SELECT COUNT(`ID`) as count FROM `$wpdb->posts` WHERE `post_status` = %s", 'publish'))) {
|
174 |
+
$total_posts = $row->count;
|
175 |
+
}
|
176 |
+
if ($rows = $wpdb->get_results($wpdb->prepare("SELECT `ID` FROM `$wpdb->posts` WHERE `post_content` LIKE '%%%s%' AND `post_status` = %s", $url, 'publish'), OBJECT)) {
|
177 |
+
if (!empty($rows)) {
|
178 |
+
foreach ($rows as $row) {
|
179 |
+
$post = SQ_Classes_ObjController::getClass('SQ_Models_Snippet')->setPostByID($row->ID);
|
180 |
+
if ($post->sq->nositemap || !$post->sq->do_sitemap) {
|
181 |
+
continue;
|
182 |
+
}
|
183 |
+
$inner_links[] = $post->url;
|
184 |
+
}
|
185 |
+
}
|
186 |
+
}
|
187 |
+
$response = array('url' => $url, 'total_posts' => $total_posts, 'inner_links' => $inner_links);
|
188 |
+
break;
|
189 |
+
case 'post':
|
190 |
+
$url = $request->get_param('url');
|
191 |
+
if ($url == '') {
|
192 |
+
exit(wp_json_encode(array('error' => esc_html__("Wrong Params", 'squirrly-seo'))));
|
193 |
+
}
|
194 |
+
//get Squirrly SEO post metas
|
195 |
+
if ($post = SQ_Classes_ObjController::getClass('SQ_Models_Snippet')->setPostByURL($url)) {
|
196 |
+
$response = $post->toArray();
|
197 |
+
}
|
198 |
+
|
199 |
+
break;
|
200 |
+
case 'squirrly':
|
201 |
+
//Get Squirrly settings
|
202 |
+
if ($options = SQ_Classes_Helpers_Tools::getOptions()) {
|
203 |
+
$response = (array)$options;
|
204 |
+
}
|
205 |
+
|
206 |
+
break;
|
207 |
+
}
|
208 |
+
echo wp_json_encode($response);
|
209 |
+
|
210 |
+
exit();
|
211 |
+
|
212 |
+
}
|
213 |
+
}
|
controllers/Assistant.php
CHANGED
@@ -1,151 +1,157 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Controllers_Assistant extends SQ_Classes_FrontController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
32 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
33 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
34 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
$
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
$
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
$this->
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Controllers_Assistant extends SQ_Classes_FrontController
|
5 |
+
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
*
|
9 |
+
*
|
10 |
+
* @var object Checkin process
|
11 |
+
*/
|
12 |
+
public $checkin;
|
13 |
+
|
14 |
+
function init()
|
15 |
+
{
|
16 |
+
|
17 |
+
$tab = preg_replace("/[^a-zA-Z0-9]/", "", SQ_Classes_Helpers_Tools::getValue('tab', 'assistant'));
|
18 |
+
|
19 |
+
if (method_exists($this, $tab)) {
|
20 |
+
call_user_func(array($this, $tab));
|
21 |
+
}
|
22 |
+
|
23 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap-reboot');
|
24 |
+
if(is_rtl()) {
|
25 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('popper');
|
26 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap.rtl');
|
27 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('rtl');
|
28 |
+
}else{
|
29 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap');
|
30 |
+
}
|
31 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap-select');
|
32 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('switchery');
|
33 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('datatables');
|
34 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('fontawesome');
|
35 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('global');
|
36 |
+
|
37 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('assistant');
|
38 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('navbar');
|
39 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('assistant');
|
40 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('chart');
|
41 |
+
|
42 |
+
//@ob_flush();
|
43 |
+
$this->show_view('Assistant/' . esc_attr(ucfirst($tab)));
|
44 |
+
|
45 |
+
//get the modal window for the assistant popup
|
46 |
+
echo SQ_Classes_ObjController::getClass('SQ_Models_Assistant')->getModal();
|
47 |
+
}
|
48 |
+
|
49 |
+
public function assistant()
|
50 |
+
{
|
51 |
+
//Checkin to API V2
|
52 |
+
$this->checkin = SQ_Classes_RemoteController::checkin();
|
53 |
+
|
54 |
+
add_action('sq_form_notices', array($this, 'getNotificationBar'));
|
55 |
+
}
|
56 |
+
|
57 |
+
public function settings()
|
58 |
+
{
|
59 |
+
$search = (string)SQ_Classes_Helpers_Tools::getValue('skeyword', '');
|
60 |
+
$labels = SQ_Classes_Helpers_Tools::getValue('slabel', false);
|
61 |
+
|
62 |
+
$args = array();
|
63 |
+
$args['search'] = $search;
|
64 |
+
if ($labels && !empty($labels)) {
|
65 |
+
$args['label'] = join(',', $labels);
|
66 |
+
}
|
67 |
+
|
68 |
+
$json = SQ_Classes_RemoteController::getBriefcase($args);
|
69 |
+
|
70 |
+
$this->rankkeywords = SQ_Classes_RemoteController::getRanks();
|
71 |
+
|
72 |
+
if (isset($json->keywords) && !empty($json->keywords)) {
|
73 |
+
$this->keywords = $json->keywords;
|
74 |
+
} else {
|
75 |
+
|
76 |
+
$this->error = esc_html__("No keyword found.", 'squirrly-seo');
|
77 |
+
|
78 |
+
}
|
79 |
+
|
80 |
+
if (isset($json->labels)) {
|
81 |
+
$this->labels = $json->labels;
|
82 |
+
}
|
83 |
+
|
84 |
+
wp_enqueue_style('wp-color-picker');
|
85 |
+
wp_enqueue_script('wp-color-picker');
|
86 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('briefcase');
|
87 |
+
|
88 |
+
}
|
89 |
+
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Called when action is triggered
|
93 |
+
*
|
94 |
+
* @return void
|
95 |
+
*/
|
96 |
+
public function action()
|
97 |
+
{
|
98 |
+
|
99 |
+
parent::action();
|
100 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
101 |
+
|
102 |
+
switch (SQ_Classes_Helpers_Tools::getValue('action')) {
|
103 |
+
|
104 |
+
///////////////////////////////////////////LIVE ASSISTANT SETTINGS
|
105 |
+
case 'sq_settings_assistant':
|
106 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
107 |
+
return;
|
108 |
+
}
|
109 |
+
|
110 |
+
//Save the settings
|
111 |
+
if (!empty($_POST)) {
|
112 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Settings')->saveValues($_POST);
|
113 |
+
}
|
114 |
+
|
115 |
+
//show the saved message
|
116 |
+
SQ_Classes_Error::setMessage(esc_html__("Saved", 'squirrly-seo'));
|
117 |
+
|
118 |
+
break;
|
119 |
+
|
120 |
+
case 'sq_ajax_assistant':
|
121 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippets')) {
|
122 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
123 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
124 |
+
echo wp_json_encode($response);
|
125 |
+
exit();
|
126 |
+
}
|
127 |
+
|
128 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
129 |
+
|
130 |
+
$input = SQ_Classes_Helpers_Tools::getValue('input', '');
|
131 |
+
$value = (bool)SQ_Classes_Helpers_Tools::getValue('value', false);
|
132 |
+
if ($input) {
|
133 |
+
//unpack the input into expected variables
|
134 |
+
list($category_name, $name, $option) = explode('|', $input);
|
135 |
+
$dbtasks = json_decode(get_option(SQ_TASKS), true);
|
136 |
+
|
137 |
+
if ($category_name <> '' && $name <> '') {
|
138 |
+
if (!$option) $option = 'active';
|
139 |
+
$dbtasks[$category_name][$name][$option] = $value;
|
140 |
+
update_option(SQ_TASKS, wp_json_encode($dbtasks));
|
141 |
+
}
|
142 |
+
|
143 |
+
$response['data'] = SQ_Classes_Error::showNotices(esc_html__("Saved", 'squirrly-seo'), 'sq_success');
|
144 |
+
echo wp_json_encode($response);
|
145 |
+
exit;
|
146 |
+
}
|
147 |
+
|
148 |
+
$response['data'] = SQ_Classes_Error::showNotices(esc_html__("Error: Could not save the data.", 'squirrly-seo'), 'sq_error');
|
149 |
+
echo wp_json_encode($response);
|
150 |
+
exit();
|
151 |
+
|
152 |
+
|
153 |
+
}
|
154 |
+
|
155 |
+
|
156 |
+
}
|
157 |
+
}
|
controllers/Audits.php
CHANGED
@@ -1,381 +1,411 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Controllers_Audits extends SQ_Classes_FrontController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
public $
|
13 |
-
|
14 |
-
public $
|
15 |
-
|
16 |
-
|
17 |
-
public $
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
public function
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
}
|
321 |
-
SQ_Classes_Error::setError(esc_html__("
|
322 |
-
}
|
323 |
-
}
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
if (
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Controllers_Audits extends SQ_Classes_FrontController
|
5 |
+
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
*
|
9 |
+
*
|
10 |
+
* @var object Checkin process
|
11 |
+
*/
|
12 |
+
public $checkin;
|
13 |
+
|
14 |
+
public $blogs;
|
15 |
+
public $auditpage;
|
16 |
+
public $audit;
|
17 |
+
public $pages;
|
18 |
+
public $audits;
|
19 |
+
public $auditpages;
|
20 |
+
|
21 |
+
/**
|
22 |
+
*
|
23 |
+
*
|
24 |
+
* @var int Audit history limit
|
25 |
+
*/
|
26 |
+
public $limit = 10;
|
27 |
+
|
28 |
+
function init()
|
29 |
+
{
|
30 |
+
|
31 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_api') == '') {
|
32 |
+
$this->show_view('Errors/Connect');
|
33 |
+
return;
|
34 |
+
}
|
35 |
+
|
36 |
+
//Checkin to API V2
|
37 |
+
$this->checkin = SQ_Classes_RemoteController::checkin();
|
38 |
+
|
39 |
+
if (is_wp_error($this->checkin)) {
|
40 |
+
if ($this->checkin->get_error_message() == 'no_data') {
|
41 |
+
$this->show_view('Errors/Error');
|
42 |
+
return;
|
43 |
+
} elseif ($this->checkin->get_error_message() == 'maintenance') {
|
44 |
+
$this->show_view('Errors/Maintenance');
|
45 |
+
return;
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
$tab = preg_replace("/[^a-zA-Z0-9]/", "", SQ_Classes_Helpers_Tools::getValue('tab', 'audits'));
|
50 |
+
|
51 |
+
if (method_exists($this, $tab)) {
|
52 |
+
call_user_func(array($this, $tab));
|
53 |
+
}
|
54 |
+
if (method_exists($this, $tab)) {
|
55 |
+
call_user_func(array($this, $tab));
|
56 |
+
}
|
57 |
+
|
58 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap-reboot');
|
59 |
+
if (is_rtl()) {
|
60 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('popper');
|
61 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap.rtl');
|
62 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('rtl');
|
63 |
+
} else {
|
64 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap');
|
65 |
+
}
|
66 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('switchery');
|
67 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('fontawesome');
|
68 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('global');
|
69 |
+
|
70 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('assistant');
|
71 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('navbar');
|
72 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('audits');
|
73 |
+
|
74 |
+
//@ob_flush();
|
75 |
+
$this->show_view('Audits/' . esc_attr(ucfirst($tab)));
|
76 |
+
|
77 |
+
//get the modal window for the assistant popup
|
78 |
+
echo SQ_Classes_ObjController::getClass('SQ_Models_Assistant')->getModal();
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Load for Add Audit Page menu tab
|
83 |
+
*/
|
84 |
+
public function addpage()
|
85 |
+
{
|
86 |
+
$search = (string)SQ_Classes_Helpers_Tools::getValue('skeyword', '');
|
87 |
+
$this->pages = SQ_Classes_ObjController::getClass('SQ_Models_Snippet')->getPages($search);
|
88 |
+
|
89 |
+
//get also the audit pages
|
90 |
+
$this->auditpage = SQ_Classes_RemoteController::getAuditPages();
|
91 |
+
|
92 |
+
if (is_wp_error($this->auditpage)) {
|
93 |
+
$this->auditpage = false;
|
94 |
+
}
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
public function compare()
|
99 |
+
{
|
100 |
+
$sids = SQ_Classes_Helpers_Tools::getValue('sid', false);
|
101 |
+
|
102 |
+
//get all the ids
|
103 |
+
if ($sids && !empty($sids)) {
|
104 |
+
foreach ($sids as $sid) {
|
105 |
+
$audit = SQ_Classes_RemoteController::getAudit(array('id' => $sid));
|
106 |
+
|
107 |
+
//Don't add error audits
|
108 |
+
if (!is_wp_error($audit)) {
|
109 |
+
$this->audits[] = $this->model->prepareAudit($audit);
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
}
|
114 |
+
|
115 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('audits');
|
116 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('knob');
|
117 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('scrolltotop');
|
118 |
+
|
119 |
+
}
|
120 |
+
|
121 |
+
public function audit()
|
122 |
+
{
|
123 |
+
$days_back = (int)SQ_Classes_Helpers_Tools::getValue('days_back', 30);
|
124 |
+
$sid = (int)SQ_Classes_Helpers_Tools::getValue('sid', false);
|
125 |
+
|
126 |
+
if ($sid) {
|
127 |
+
|
128 |
+
$this->audit = SQ_Classes_RemoteController::getAudit(array('id' => $sid, 'days_back' => $days_back));
|
129 |
+
|
130 |
+
if ($auditpages = SQ_Classes_RemoteController::getAuditPages()) {
|
131 |
+
|
132 |
+
if (is_wp_error($auditpages)) {
|
133 |
+
SQ_Classes_Error::setError('Could not load the Audit Pages.');
|
134 |
+
} else {
|
135 |
+
|
136 |
+
if (!empty($auditpages)) {
|
137 |
+
foreach ($auditpages as $auditpage) {
|
138 |
+
|
139 |
+
/**
|
140 |
+
*
|
141 |
+
*
|
142 |
+
* @var SQ_Models_Domain_FocusPage $auditpage
|
143 |
+
*/
|
144 |
+
$auditpage = SQ_Classes_ObjController::getDomain('SQ_Models_Domain_AuditPage', $auditpage);
|
145 |
+
|
146 |
+
//If there is a local page, then show focus
|
147 |
+
if ($auditpage->getWppost()) {
|
148 |
+
$this->auditpages[] = SQ_Classes_ObjController::getClass('SQ_Models_Audits')->parseAuditPage($auditpage)->getAuditPage();
|
149 |
+
}
|
150 |
+
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
if (!is_wp_error($this->audit)) {
|
155 |
+
$this->audit = $this->model->prepareAudit($this->audit);
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
+
}
|
160 |
+
|
161 |
+
} else {
|
162 |
+
SQ_Classes_Error::setError(esc_html__("The audit was not found. Please load another audit.", 'squirrly-seo'));
|
163 |
+
|
164 |
+
}
|
165 |
+
|
166 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('audits');
|
167 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('knob');
|
168 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('scrolltotop');
|
169 |
+
SQ_Classes_Error::clearErrors();
|
170 |
+
|
171 |
+
}
|
172 |
+
|
173 |
+
public function audits()
|
174 |
+
{
|
175 |
+
add_action('sq_form_notices', array($this, 'getNotificationBar'));
|
176 |
+
|
177 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('audits');
|
178 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('knob');
|
179 |
+
|
180 |
+
$this->setAuditPages();
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Set the audit pages and populate them
|
185 |
+
*
|
186 |
+
* @return mixed
|
187 |
+
*/
|
188 |
+
public function setAuditPages()
|
189 |
+
{
|
190 |
+
$days_back = (int)SQ_Classes_Helpers_Tools::getValue('days_back', 30);
|
191 |
+
$this->audit = SQ_Classes_RemoteController::getAudit(array('days_back' => $days_back));
|
192 |
+
|
193 |
+
if (is_wp_error($this->audit)) {
|
194 |
+
SQ_Classes_Error::setError(esc_html__("Could not load the Audit Page.", 'squirrly-seo'));
|
195 |
+
} elseif ($auditpages = SQ_Classes_RemoteController::getAuditPages()) {
|
196 |
+
|
197 |
+
if (is_wp_error($auditpages)) {
|
198 |
+
SQ_Classes_Error::setError('Could not load the Audit Pages.');
|
199 |
+
} else {
|
200 |
+
|
201 |
+
if (!empty($auditpages)) {
|
202 |
+
foreach ($auditpages as $auditpage) {
|
203 |
+
|
204 |
+
/**
|
205 |
+
*
|
206 |
+
*
|
207 |
+
* @var SQ_Models_Domain_FocusPage $auditpage
|
208 |
+
*/
|
209 |
+
$auditpage = SQ_Classes_ObjController::getDomain('SQ_Models_Domain_AuditPage', $auditpage);
|
210 |
+
|
211 |
+
//If there is a local page, then show focus
|
212 |
+
$this->auditpages[] = SQ_Classes_ObjController::getClass('SQ_Models_Audits')->parseAuditPage($auditpage)->getAuditPage();
|
213 |
+
}
|
214 |
+
}
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
return $this->auditpages;
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Load the Google Chart
|
223 |
+
*
|
224 |
+
* @return string
|
225 |
+
*/
|
226 |
+
public function loadScripts()
|
227 |
+
{
|
228 |
+
echo '<script>
|
229 |
+
function drawScoreChart(id, values, reverse) {
|
230 |
+
var data = google.visualization.arrayToDataTable(values);
|
231 |
+
|
232 |
+
var options = {
|
233 |
+
|
234 |
+
title : "",
|
235 |
+
chartArea:{width:"80%",height:"70%"},
|
236 |
+
vAxis: {title: "",
|
237 |
+
viewWindowMode:"explicit",
|
238 |
+
viewWindow: {
|
239 |
+
max:100,
|
240 |
+
min:0
|
241 |
+
}},
|
242 |
+
hAxis: {title: ""},
|
243 |
+
seriesType: "bars",
|
244 |
+
series: {2: {type: "line"}},
|
245 |
+
legend: {position: "bottom"},
|
246 |
+
colors:["#589ee4","#17d1f3"]
|
247 |
+
};
|
248 |
+
|
249 |
+
var chart = new google.visualization.ComboChart(document.getElementById(id));
|
250 |
+
chart.draw(data, options);
|
251 |
+
return chart;
|
252 |
+
}
|
253 |
+
</script>';
|
254 |
+
}
|
255 |
+
|
256 |
+
/**
|
257 |
+
* Called when action is triggered
|
258 |
+
*
|
259 |
+
* @return void
|
260 |
+
*/
|
261 |
+
public function action()
|
262 |
+
{
|
263 |
+
parent::action();
|
264 |
+
|
265 |
+
switch (SQ_Classes_Helpers_Tools::getValue('action')) {
|
266 |
+
case 'sq_auditpages_getaudit':
|
267 |
+
|
268 |
+
$json = array();
|
269 |
+
|
270 |
+
//Set all audit pages
|
271 |
+
$this->setAuditPages();
|
272 |
+
|
273 |
+
$json['stats'] = $this->get_view('Audits/AuditStats');
|
274 |
+
$json['html'] = $this->get_view('Audits/AuditPages');
|
275 |
+
|
276 |
+
//Support for international languages
|
277 |
+
if (function_exists('iconv') && SQ_Classes_Helpers_Tools::getOption('sq_non_utf8_support')) {
|
278 |
+
if (strpos(get_bloginfo("language"), 'en') === false) {
|
279 |
+
$json['html'] = iconv('UTF-8', 'UTF-8//IGNORE', $json['html']);
|
280 |
+
}
|
281 |
+
}
|
282 |
+
|
283 |
+
if (SQ_Classes_Helpers_Tools::isAjax()) {
|
284 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
285 |
+
|
286 |
+
if (SQ_Classes_Error::isError()) {
|
287 |
+
$json['error'] = SQ_Classes_Error::getError();
|
288 |
+
}
|
289 |
+
|
290 |
+
if (SQ_Classes_Helpers_Tools::getValue('sq_debug') == 'on') {
|
291 |
+
return;
|
292 |
+
}
|
293 |
+
echo wp_json_encode($json);
|
294 |
+
exit();
|
295 |
+
}
|
296 |
+
break;
|
297 |
+
case 'sq_audits_addnew':
|
298 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_focuspages')) {
|
299 |
+
return;
|
300 |
+
}
|
301 |
+
|
302 |
+
$post_id = (int)SQ_Classes_Helpers_Tools::getValue('post_id', 0);
|
303 |
+
$term_id = (int)SQ_Classes_Helpers_Tools::getValue('term_id', 0);
|
304 |
+
$taxonomy = SQ_Classes_Helpers_Tools::getValue('taxonomy', '');
|
305 |
+
$post_type = SQ_Classes_Helpers_Tools::getValue('type', '');
|
306 |
+
|
307 |
+
if ($post = SQ_Classes_ObjController::getClass('SQ_Models_Snippet')->getCurrentSnippet($post_id, $term_id, $taxonomy, $post_type)) {
|
308 |
+
|
309 |
+
//Save the post data in DB with the hash
|
310 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Snippet')->savePost($post);
|
311 |
+
|
312 |
+
$args = array();
|
313 |
+
$args['post_id'] = $post->ID;
|
314 |
+
$args['hash'] = $post->hash;
|
315 |
+
$args['permalink'] = $post->url;
|
316 |
+
if ($auditpage = SQ_Classes_RemoteController::addAuditPage($args)) {
|
317 |
+
if (!is_wp_error($auditpage)) {
|
318 |
+
SQ_Classes_Error::setError(esc_html__("Audit page is added. The audit may take a while so please be patient.", 'squirrly-seo') . " <br /> ", 'success');
|
319 |
+
set_transient('sq_auditpage_all', time());
|
320 |
+
} elseif ($auditpage->get_error_message() == 'limit_exceed') {
|
321 |
+
SQ_Classes_Error::setError(esc_html__("You reached the maximum number of audit pages for your account.", 'squirrly-seo') . " <br /> ");
|
322 |
+
}
|
323 |
+
} else {
|
324 |
+
SQ_Classes_Error::setError(esc_html__("Error! Could not add the audit page.", 'squirrly-seo') . " <br /> ");
|
325 |
+
}
|
326 |
+
|
327 |
+
} else {
|
328 |
+
SQ_Classes_Error::setError(esc_html__("Error! Could not find the audit page in your website.", 'squirrly-seo') . " <br /> ");
|
329 |
+
}
|
330 |
+
break;
|
331 |
+
case 'sq_audits_page_update':
|
332 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_focuspages')) {
|
333 |
+
return;
|
334 |
+
}
|
335 |
+
|
336 |
+
$post_id = (int)SQ_Classes_Helpers_Tools::getValue('post_id', 0);
|
337 |
+
|
338 |
+
if ($post_id) {
|
339 |
+
$args = array();
|
340 |
+
$args['post_id'] = $post_id;
|
341 |
+
|
342 |
+
if ($auditpage = SQ_Classes_RemoteController::updateAudit($args)) {
|
343 |
+
if (!is_wp_error($auditpage)) {
|
344 |
+
SQ_Classes_Error::setMessage(esc_html__("Audit page sent for recheck. It may take a while so please be patient.", 'squirrly-seo') . " <br /> ");
|
345 |
+
} elseif ($auditpage->get_error_message() == 'too_many_attempts') {
|
346 |
+
SQ_Classes_Error::setError(esc_html__("You've made too many requests, you can request one page audit per hour.", 'squirrly-seo') . " <br /> ");
|
347 |
+
} else {
|
348 |
+
SQ_Classes_Error::setError(esc_html__("The page could not be sent for reaudit.", 'squirrly-seo') . " <br /> ");
|
349 |
+
}
|
350 |
+
} else {
|
351 |
+
SQ_Classes_Error::setError(esc_html__("The page could not be sent for reaudit.", 'squirrly-seo') . " <br /> ");
|
352 |
+
}
|
353 |
+
}
|
354 |
+
break;
|
355 |
+
case 'sq_audits_update':
|
356 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_focuspages')) {
|
357 |
+
return;
|
358 |
+
}
|
359 |
+
|
360 |
+
if ($auditpage = SQ_Classes_RemoteController::updateAudit()) {
|
361 |
+
if (!is_wp_error($auditpage)) {
|
362 |
+
SQ_Classes_Error::setError(esc_html__("Audit page sent for recheck. It may take a while so please be patient.", 'squirrly-seo') . " <br /> ", 'success');
|
363 |
+
set_transient('sq_auditpage_all', time());
|
364 |
+
} elseif ($auditpage->get_error_message() == 'too_many_attempts') {
|
365 |
+
SQ_Classes_Error::setError(esc_html__("The audit for all pages can be made once an hour.", 'squirrly-seo') . " <br /> ");
|
366 |
+
}
|
367 |
+
} else {
|
368 |
+
SQ_Classes_Error::setError(esc_html__("The audit for all pages can be made once an hour.", 'squirrly-seo') . " <br /> ");
|
369 |
+
}
|
370 |
+
break;
|
371 |
+
case 'sq_audits_delete':
|
372 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_focuspages')) {
|
373 |
+
return;
|
374 |
+
}
|
375 |
+
|
376 |
+
if ($post_id = SQ_Classes_Helpers_Tools::getValue('id', false)) {
|
377 |
+
SQ_Classes_RemoteController::deleteAuditPage(array('user_post_id' => $post_id));
|
378 |
+
SQ_Classes_Error::setError(esc_html__("The audit page is deleted.", 'squirrly-seo') . " <br /> ", 'success');
|
379 |
+
} else {
|
380 |
+
SQ_Classes_Error::setError(esc_html__("Invalid params!", 'squirrly-seo') . " <br /> ");
|
381 |
+
}
|
382 |
+
|
383 |
+
break;
|
384 |
+
case 'sq_audits_settings':
|
385 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
386 |
+
return;
|
387 |
+
}
|
388 |
+
|
389 |
+
$email = sanitize_email(SQ_Classes_Helpers_Tools::getValue('sq_audit_email'));
|
390 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_audit_email', $email);
|
391 |
+
|
392 |
+
if ($email <> '') {
|
393 |
+
|
394 |
+
//Save the settings on API too
|
395 |
+
$args = array();
|
396 |
+
$args['audit_email'] = $email;
|
397 |
+
SQ_Classes_RemoteController::saveSettings($args);
|
398 |
+
///////////////////////////////
|
399 |
+
|
400 |
+
//show the saved message
|
401 |
+
SQ_Classes_Error::setMessage(esc_html__("Saved", 'squirrly-seo'));
|
402 |
+
} else {
|
403 |
+
SQ_Classes_Error::setError(esc_html__("Not a valid email address.", 'squirrly-seo'));
|
404 |
+
|
405 |
+
}
|
406 |
+
|
407 |
+
break;
|
408 |
+
}
|
409 |
+
|
410 |
+
}
|
411 |
+
}
|
controllers/BulkSeo.php
CHANGED
@@ -1,111 +1,115 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Controllers_BulkSeo extends SQ_Classes_FrontController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
17 |
-
|
18 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
19 |
-
}
|
20 |
-
|
21 |
-
|
22 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
23 |
-
|
24 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
25 |
-
|
26 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
$
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
}
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Controllers_BulkSeo extends SQ_Classes_FrontController
|
5 |
+
{
|
6 |
+
|
7 |
+
public $pages = array();
|
8 |
+
|
9 |
+
function init()
|
10 |
+
{
|
11 |
+
|
12 |
+
$tab = preg_replace("/[^a-zA-Z0-9]/", "", SQ_Classes_Helpers_Tools::getValue('tab', 'bulkseo'));
|
13 |
+
|
14 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap-reboot');
|
15 |
+
if(is_rtl()) {
|
16 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('popper');
|
17 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap.rtl');
|
18 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('rtl');
|
19 |
+
}else{
|
20 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap');
|
21 |
+
}
|
22 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('switchery');
|
23 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('fontawesome');
|
24 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('global');
|
25 |
+
|
26 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('assistant');
|
27 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('navbar');
|
28 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('seosettings');
|
29 |
+
|
30 |
+
if (method_exists($this, $tab)) {
|
31 |
+
call_user_func(array($this, $tab));
|
32 |
+
}
|
33 |
+
|
34 |
+
if (function_exists('wp_enqueue_media')) {
|
35 |
+
wp_enqueue_media();
|
36 |
+
}
|
37 |
+
|
38 |
+
//@ob_flush();
|
39 |
+
$this->show_view('BulkSeo/' . esc_attr(ucfirst($tab)));
|
40 |
+
|
41 |
+
//get the modal window for the assistant popup
|
42 |
+
echo SQ_Classes_ObjController::getClass('SQ_Models_Assistant')->getModal();
|
43 |
+
}
|
44 |
+
|
45 |
+
public function bulkseo()
|
46 |
+
{
|
47 |
+
add_action('sq_form_notices', array($this,'getNotificationBar'));
|
48 |
+
|
49 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bulkseo');
|
50 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('labels');
|
51 |
+
|
52 |
+
$search = (string)SQ_Classes_Helpers_Tools::getValue('skeyword', '');
|
53 |
+
$this->pages = SQ_Classes_ObjController::getClass('SQ_Models_Snippet')->getPages($search);
|
54 |
+
|
55 |
+
if (!empty($labels) || count((array)$this->pages) > 1) {
|
56 |
+
//Get the labels for view use
|
57 |
+
$this->labels = SQ_Classes_ObjController::getClass('SQ_Models_BulkSeo')->getLabels();
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Called when action is triggered
|
63 |
+
*
|
64 |
+
* @return void
|
65 |
+
*/
|
66 |
+
public function action()
|
67 |
+
{
|
68 |
+
parent::action();
|
69 |
+
|
70 |
+
switch (SQ_Classes_Helpers_Tools::getValue('action')) {
|
71 |
+
|
72 |
+
case 'sq_ajax_assistant_bulkseo':
|
73 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
74 |
+
|
75 |
+
$response = array();
|
76 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
77 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
78 |
+
echo wp_json_encode($response);
|
79 |
+
exit();
|
80 |
+
}
|
81 |
+
|
82 |
+
$post_id = (int)SQ_Classes_Helpers_Tools::getValue('post_id', 0);
|
83 |
+
$term_id = (int)SQ_Classes_Helpers_Tools::getValue('term_id', 0);
|
84 |
+
$taxonomy = SQ_Classes_Helpers_Tools::getValue('taxonomy', '');
|
85 |
+
$post_type = SQ_Classes_Helpers_Tools::getValue('post_type', '');
|
86 |
+
|
87 |
+
//Set the Labels and Categories
|
88 |
+
SQ_Classes_ObjController::getClass('SQ_Models_BulkSeo')->init();
|
89 |
+
if ($post = SQ_Classes_ObjController::getClass('SQ_Models_Snippet')->getCurrentSnippet($post_id, $term_id, $taxonomy, $post_type)) {
|
90 |
+
$this->post = SQ_Classes_ObjController::getClass('SQ_Models_BulkSeo')->parsePage($post)->getPage();
|
91 |
+
}
|
92 |
+
|
93 |
+
$json = array();
|
94 |
+
$json['html'] = $this->get_view('BulkSeo/BulkseoRow');
|
95 |
+
$json['html_dest'] = "#sq_row_" . $this->post->hash;
|
96 |
+
|
97 |
+
$json['assistant'] = '';
|
98 |
+
$categories = apply_filters('sq_assistant_categories_page', $this->post->hash);
|
99 |
+
if (!empty($categories)) {
|
100 |
+
foreach ($categories as $index => $category) {
|
101 |
+
if (isset($category->assistant)) {
|
102 |
+
$json['assistant'] .= $category->assistant;
|
103 |
+
}
|
104 |
+
}
|
105 |
+
}
|
106 |
+
$json['assistant_dest'] = "#sq_assistant_" . $this->post->hash;
|
107 |
+
|
108 |
+
echo wp_json_encode($json);
|
109 |
+
exit();
|
110 |
+
|
111 |
+
}
|
112 |
+
|
113 |
+
}
|
114 |
+
|
115 |
+
}
|
controllers/CheckSeo.php
CHANGED
@@ -1,381 +1,392 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Controllers_CheckSeo extends SQ_Classes_FrontController
|
5 |
-
|
6 |
-
public $
|
7 |
-
public $
|
8 |
-
public $
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
*
|
13 |
-
*
|
14 |
-
* @
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
//
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
if (!isset($
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
$
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
//
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
if (
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
'
|
112 |
-
'
|
113 |
-
'
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
$count
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
//
|
200 |
-
|
201 |
-
$
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Controllers_CheckSeo extends SQ_Classes_FrontController
|
5 |
+
{
|
6 |
+
public $report;
|
7 |
+
public $score = 100;
|
8 |
+
public $congratulations;
|
9 |
+
public $report_time;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Set a custom category name
|
13 |
+
*
|
14 |
+
* @param $category_name
|
15 |
+
* @return $this
|
16 |
+
*/
|
17 |
+
public function setCategory($category_name)
|
18 |
+
{
|
19 |
+
$this->model->category_name = $category_name;
|
20 |
+
return $this;
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Call the init on Dashboard
|
25 |
+
*
|
26 |
+
* @return mixed|void
|
27 |
+
*/
|
28 |
+
public function init()
|
29 |
+
{
|
30 |
+
|
31 |
+
if (!isset($this->congratulations)) {
|
32 |
+
$this->congratulations = $this->getCongratulations();
|
33 |
+
}
|
34 |
+
|
35 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('checkseo');
|
36 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('knob');
|
37 |
+
|
38 |
+
//get the modal window for the assistant popup
|
39 |
+
echo SQ_Classes_ObjController::getClass('SQ_Models_Assistant')->getModal();
|
40 |
+
|
41 |
+
$this->show_view('Goals/CheckSeo');
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Get the notifications from database
|
46 |
+
*
|
47 |
+
* @return mixed
|
48 |
+
*/
|
49 |
+
public function getNotifications()
|
50 |
+
{
|
51 |
+
|
52 |
+
//Load the report
|
53 |
+
$report = $this->model->getDbTasks();
|
54 |
+
//Load the tasks from database and filter them
|
55 |
+
$tasks = $this->model->getTasks();
|
56 |
+
|
57 |
+
// $this->model->dbtasks['tasks_for_today'] = array();
|
58 |
+
// $this->model->dbtasks['count_tasks_for_today'] = 300;
|
59 |
+
if (!empty($report)) {
|
60 |
+
|
61 |
+
if (!isset($this->model->dbtasks['count_tasks_for_today'])) {
|
62 |
+
$this->model->dbtasks['count_tasks_for_today'] = 3; //Show 3 goals per day
|
63 |
+
}
|
64 |
+
|
65 |
+
$urgent_tasks = array();
|
66 |
+
$tasks_for_today = isset($this->model->dbtasks['tasks_for_today']) ? $this->model->dbtasks['tasks_for_today'] : array();
|
67 |
+
if (!isset($tasks_for_today[date('Y-m-d')]) || count($tasks_for_today[date('Y-m-d')]) < $this->model->dbtasks['count_tasks_for_today']) {
|
68 |
+
//If the tasks for today are not yet set
|
69 |
+
$tasks_for_today = array(date('Y-m-d') => array());
|
70 |
+
} else {
|
71 |
+
//update the report to todays tasks
|
72 |
+
foreach ($report as $function => $row) {
|
73 |
+
//Limit today tasks
|
74 |
+
if (isset($tasks[$function]['priority']) && $tasks[$function]['priority'] == 1) {
|
75 |
+
if (!isset($tasks[$function]['positive'])) $tasks[$function]['positive'] = false;
|
76 |
+
|
77 |
+
if (!$tasks[$function]['positive'] && isset($row['completed']) && !$row['completed']) {
|
78 |
+
$urgent_tasks[$function] = $row;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
if (isset($tasks_for_today[date('Y-m-d')][$function])) {
|
83 |
+
$tasks_for_today[date('Y-m-d')][$function] = $row;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
//add the urgent tasks first in the todays tasks
|
88 |
+
if (!empty($urgent_tasks)) {
|
89 |
+
$tasks_for_today[date('Y-m-d')] = array_merge($urgent_tasks, $tasks_for_today[date('Y-m-d')]);
|
90 |
+
}
|
91 |
+
|
92 |
+
//get the report from todays tasks
|
93 |
+
$report = $tasks_for_today[date('Y-m-d')];
|
94 |
+
}
|
95 |
+
|
96 |
+
foreach ($report as $function => &$row) {
|
97 |
+
|
98 |
+
//Make sure the function is set in the task
|
99 |
+
if (is_array($row) && isset($tasks[$function])) {
|
100 |
+
if (!isset($tasks[$function]['positive'])) $tasks[$function]['positive'] = false;
|
101 |
+
|
102 |
+
$row = array_merge(array('completed' => false, 'active' => true, 'done' => false), $row);
|
103 |
+
$row['status'] = $row['active'] ? ($row['done'] ? 'done' : (($row['completed']) ? 'completed' : '')) : 'ignore';
|
104 |
+
|
105 |
+
//if isn't a success task and is not completes
|
106 |
+
if (!$tasks[$function]['positive'] && ($row['status'] == '' || !empty($tasks_for_today[date('Y-m-d')]))) {
|
107 |
+
$row = array_merge($tasks[$function], $row);
|
108 |
+
|
109 |
+
//set defaults for each task
|
110 |
+
$default = array(
|
111 |
+
'completed' => false,
|
112 |
+
'warning' => '',
|
113 |
+
'message' => '',
|
114 |
+
'solution' => '',
|
115 |
+
'link' => '',
|
116 |
+
'color' => '#4f1440',
|
117 |
+
'bullet' => false,
|
118 |
+
'priority' => 0,
|
119 |
+
'ignore' => false
|
120 |
+
);
|
121 |
+
$row = array_merge($default, $row);
|
122 |
+
|
123 |
+
//replace links
|
124 |
+
$row['warning'] = preg_replace('/\[link\]([^\[]*)\[\/link\]/i', '<a href="$1" target="_blank">$1</a>', $row['warning']);
|
125 |
+
$row['message'] = preg_replace('/\[link\]([^\[]*)\[\/link\]/i', '<a href="$1" target="_blank">$1</a>', $row['message']);
|
126 |
+
$row['solution'] = preg_replace('/\[link\]([^\[]*)\[\/link\]/i', '<a href="$1" target="_blank">$1</a>', $row['solution']);
|
127 |
+
|
128 |
+
//add links to all tools
|
129 |
+
if (!empty($row['tools'])) {
|
130 |
+
foreach ($row['tools'] as &$tool) {
|
131 |
+
switch ($tool) {
|
132 |
+
case 'On-Page SEO':
|
133 |
+
$tool = '<a href="https://plugin.squirrly.co/bulk-seo-settings/" target="_blank"><strong class="text-info">' . $tool . '</strong></a>';
|
134 |
+
break;
|
135 |
+
case 'SEO Automation':
|
136 |
+
$tool = '<a href="https://howto.squirrly.co/kb/seo-automation/" target="_blank"><strong class="text-info">' . $tool . '</strong></a>';
|
137 |
+
break;
|
138 |
+
case 'SEO Snippet':
|
139 |
+
$tool = '<a href="https://plugin.squirrly.co/seo-snippet-tool/" target="_blank"><strong class="text-info">' . $tool . '</strong></a>';
|
140 |
+
break;
|
141 |
+
case 'Focus Pages':
|
142 |
+
$tool = '<a href="https://plugin.squirrly.co/focus-pages/" target="_blank"><strong class="text-info">' . $tool . '</strong></a>';
|
143 |
+
break;
|
144 |
+
case 'Live Assistant':
|
145 |
+
$tool = '<a href="https://plugin.squirrly.co/seo-virtual-assistant/" target="_blank"><strong class="text-info">' . $tool . '</strong></a>';
|
146 |
+
break;
|
147 |
+
case 'Multiple Keyword Optimization':
|
148 |
+
$tool = '<a href="https://plugin.squirrly.co/seo-virtual-assistant/" target="_blank"><strong class="text-info">' . $tool . '</strong></a>';
|
149 |
+
break;
|
150 |
+
case 'Keyword Research':
|
151 |
+
$tool = '<a href="https://plugin.squirrly.co/best-keyword-research-tool-for-seo/" target="_blank"><strong class="text-info">' . $tool . '</strong></a>';
|
152 |
+
break;
|
153 |
+
case 'Briefcase':
|
154 |
+
$tool = '<a href="https://plugin.squirrly.co/briefcase-keyword-management-tool/" target="_blank"><strong class="text-info">' . $tool . '</strong></a>';
|
155 |
+
break;
|
156 |
+
case 'Rankings':
|
157 |
+
$tool = '<a href="https://plugin.squirrly.co/google-serp-checker/" target="_blank"><strong class="text-info">' . $tool . '</strong></a>';
|
158 |
+
break;
|
159 |
+
case 'Audits':
|
160 |
+
$tool = '<a href="https://plugin.squirrly.co/site-seo-audit-tool/" target="_blank"><strong class="text-info">' . $tool . '</strong></a>';
|
161 |
+
break;
|
162 |
+
}
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
|
167 |
+
} else {
|
168 |
+
//if task is complete, remove it
|
169 |
+
unset($report[$function]);
|
170 |
+
}
|
171 |
+
} else {
|
172 |
+
//if function doesn't exists, remove the task
|
173 |
+
unset($report[$function]);
|
174 |
+
}
|
175 |
+
}
|
176 |
+
|
177 |
+
|
178 |
+
//Set the todays tasks if empty
|
179 |
+
if (empty($tasks_for_today[date('Y-m-d')])) {
|
180 |
+
$count = 1;
|
181 |
+
foreach ($report as $function => $task) {
|
182 |
+
//Limit today tasks
|
183 |
+
if ($count > $this->model->dbtasks['count_tasks_for_today'] && $task['priority'] > 1) {
|
184 |
+
unset($report[$function]);
|
185 |
+
} else {
|
186 |
+
$tasks_for_today[date('Y-m-d')][$function] = $task;
|
187 |
+
}
|
188 |
+
|
189 |
+
$count++;
|
190 |
+
}
|
191 |
+
}
|
192 |
+
|
193 |
+
//Verify the goals gor today completion and progress
|
194 |
+
if (!empty($tasks_for_today[date('Y-m-d')])) {
|
195 |
+
|
196 |
+
$countdone = 0;
|
197 |
+
foreach ($tasks_for_today[date('Y-m-d')] as $function => $task) {
|
198 |
+
|
199 |
+
if (!isset($report[$function])) { //in case the goal was removed from API
|
200 |
+
//remove the daily goal and move on
|
201 |
+
unset($tasks_for_today[date('Y-m-d')][$function]);
|
202 |
+
continue;
|
203 |
+
}
|
204 |
+
|
205 |
+
//count the completed goals for today's progress
|
206 |
+
if (in_array($report[$function]['status'], array('completed', 'done', 'ignore'))) {
|
207 |
+
$countdone++;
|
208 |
+
}
|
209 |
+
}
|
210 |
+
|
211 |
+
//Calculate today's progress
|
212 |
+
if (count($tasks_for_today[date('Y-m-d')]) > 0) {
|
213 |
+
$this->score = number_format((100 * $countdone) / count($tasks_for_today[date('Y-m-d')]), 0);
|
214 |
+
}
|
215 |
+
|
216 |
+
}
|
217 |
+
|
218 |
+
$this->model->dbtasks['tasks_for_today'] = $tasks_for_today;
|
219 |
+
$this->model->saveDbTasks();
|
220 |
+
|
221 |
+
}
|
222 |
+
|
223 |
+
//return the report
|
224 |
+
return $report;
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Get the notifications from database
|
229 |
+
*
|
230 |
+
* @return mixed
|
231 |
+
*/
|
232 |
+
public function getCongratulations()
|
233 |
+
{
|
234 |
+
|
235 |
+
$report = $this->model->getDbTasks();
|
236 |
+
$tasks = $this->model->getTasks();
|
237 |
+
|
238 |
+
if (!empty($report)) {
|
239 |
+
foreach ($report as $function => &$row) {
|
240 |
+
|
241 |
+
if (is_array($row) && isset($tasks[$function])) {
|
242 |
+
if (!isset($tasks[$function]['positive'])) $tasks[$function]['positive'] = false;
|
243 |
+
|
244 |
+
$row = array_merge(array('completed' => false, 'active' => true, 'done' => false, 'positive' => false), $row);
|
245 |
+
$row['status'] = $row['active'] ? (($row['completed'] || $row['done']) ? 'completed' : '') : 'ignore';
|
246 |
+
|
247 |
+
if ($tasks[$function]['positive'] && in_array($row['status'], array('completed', 'ignore'))) {
|
248 |
+
$row = array_merge($tasks[$function], $row);
|
249 |
+
} else {
|
250 |
+
unset($report[$function]);
|
251 |
+
}
|
252 |
+
|
253 |
+
} else {
|
254 |
+
unset($report[$function]);
|
255 |
+
}
|
256 |
+
}
|
257 |
+
}
|
258 |
+
|
259 |
+
//return the report
|
260 |
+
return $report;
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Return the number of SEO errors if exists
|
265 |
+
*
|
266 |
+
* @return bool|int
|
267 |
+
*/
|
268 |
+
public function getErrorsCount()
|
269 |
+
{
|
270 |
+
|
271 |
+
$errors = 0;
|
272 |
+
|
273 |
+
if (!isset($this->report)) {
|
274 |
+
$this->report = $this->getNotifications();
|
275 |
+
}
|
276 |
+
|
277 |
+
if(!empty($this->report)) {
|
278 |
+
foreach ($this->report as $row){
|
279 |
+
if($row['active'] && !$row['positive'] && !$row['completed'] && !$row['done'] ) {
|
280 |
+
$errors ++;
|
281 |
+
}
|
282 |
+
}
|
283 |
+
}
|
284 |
+
|
285 |
+
return $errors;
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Check SEO Actions
|
290 |
+
*/
|
291 |
+
public function action()
|
292 |
+
{
|
293 |
+
parent::action();
|
294 |
+
|
295 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippets')) {
|
296 |
+
return;
|
297 |
+
}
|
298 |
+
|
299 |
+
switch (SQ_Classes_Helpers_Tools::getValue('action')) {
|
300 |
+
|
301 |
+
case 'sq_checkseo':
|
302 |
+
SQ_Classes_Error::setMessage(esc_html__("Done!", 'squirrly-seo'));
|
303 |
+
//Check all the SEO
|
304 |
+
//Process all the tasks and save the report
|
305 |
+
$this->model->checkSEO();
|
306 |
+
|
307 |
+
break;
|
308 |
+
case 'sq_moretasks':
|
309 |
+
$this->model->dbtasks['tasks_for_today'] = array();
|
310 |
+
$this->model->saveDbTasks();
|
311 |
+
|
312 |
+
SQ_Classes_Error::setMessage(esc_html__("Done!", 'squirrly-seo'));
|
313 |
+
//Check all the SEO
|
314 |
+
//Process all the tasks and save the report
|
315 |
+
$this->model->checkSEO();
|
316 |
+
|
317 |
+
break;
|
318 |
+
case 'sq_fixsettings':
|
319 |
+
$name = SQ_Classes_Helpers_Tools::getValue('name', false);
|
320 |
+
$value = SQ_Classes_Helpers_Tools::getValue('value', false);
|
321 |
+
|
322 |
+
if ($name) {
|
323 |
+
if (in_array($name, array_keys(SQ_Classes_Helpers_Tools::$options))) {
|
324 |
+
SQ_Classes_Helpers_Tools::saveOptions($name, (bool)$value);
|
325 |
+
|
326 |
+
//Process all the tasks and save the report
|
327 |
+
$this->model->checkSEO();
|
328 |
+
|
329 |
+
SQ_Classes_Error::setMessage(esc_html__("Fixed!", 'squirrly-seo'));
|
330 |
+
return;
|
331 |
+
}
|
332 |
+
}
|
333 |
+
|
334 |
+
SQ_Classes_Error::setError(esc_html__("Could not fix it. You need to change it manually.", 'squirrly-seo'));
|
335 |
+
break;
|
336 |
+
case 'sq_donetask':
|
337 |
+
$name = SQ_Classes_Helpers_Tools::getValue('name', false);
|
338 |
+
|
339 |
+
$this->model->doneTask($name);
|
340 |
+
|
341 |
+
SQ_Classes_Error::setMessage(esc_html__("Saved! Task marked as done.", 'squirrly-seo'));
|
342 |
+
break;
|
343 |
+
case 'sq_resetignored':
|
344 |
+
//Remove ignored tasks
|
345 |
+
$this->model->clearIgnoredTasks();
|
346 |
+
|
347 |
+
SQ_Classes_Error::setMessage(esc_html__("Saved!", 'squirrly-seo'));
|
348 |
+
|
349 |
+
break;
|
350 |
+
case 'sq_ajax_checkseo':
|
351 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
352 |
+
$json = array();
|
353 |
+
|
354 |
+
//Check all the SEO
|
355 |
+
//Process all the tasks and save the report
|
356 |
+
$this->model->checkSEO();
|
357 |
+
|
358 |
+
if (SQ_Classes_Error::isError()) {
|
359 |
+
$json['error'] = SQ_Classes_Error::getError();
|
360 |
+
}
|
361 |
+
|
362 |
+
echo wp_json_encode($json);
|
363 |
+
exit();
|
364 |
+
case 'sq_ajax_getgoals':
|
365 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
366 |
+
$json = array();
|
367 |
+
|
368 |
+
if (!isset($this->report)) {
|
369 |
+
$this->report = $this->getNotifications();
|
370 |
+
}
|
371 |
+
|
372 |
+
$json['html'] = $this->get_view('Goals/Goals');
|
373 |
+
|
374 |
+
//Support for international languages
|
375 |
+
if (function_exists('iconv') && SQ_Classes_Helpers_Tools::getOption('sq_non_utf8_support')) {
|
376 |
+
if (strpos(get_bloginfo("language"), 'en') === false) {
|
377 |
+
$json['html'] = iconv('UTF-8', 'UTF-8//IGNORE', $json['html']);
|
378 |
+
}
|
379 |
+
}
|
380 |
+
|
381 |
+
if (SQ_Classes_Error::isError()) {
|
382 |
+
$json['error'] = SQ_Classes_Error::getError();
|
383 |
+
}
|
384 |
+
|
385 |
+
echo wp_json_encode($json);
|
386 |
+
exit();
|
387 |
+
}
|
388 |
+
|
389 |
+
|
390 |
+
}
|
391 |
+
|
392 |
+
}
|
controllers/Dashboard.php
CHANGED
@@ -1,43 +1,46 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Show on the WordPress Dashboard
|
6 |
-
* Class SQ_Controllers_Dashboard
|
7 |
-
*/
|
8 |
-
class SQ_Controllers_Dashboard extends SQ_Classes_FrontController
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Show on the WordPress Dashboard
|
6 |
+
* Class SQ_Controllers_Dashboard
|
7 |
+
*/
|
8 |
+
class SQ_Controllers_Dashboard extends SQ_Classes_FrontController
|
9 |
+
{
|
10 |
+
|
11 |
+
|
12 |
+
public function dashboard()
|
13 |
+
{
|
14 |
+
|
15 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('dashboard');
|
16 |
+
if (is_rtl()) {
|
17 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('rtl');
|
18 |
+
}
|
19 |
+
|
20 |
+
add_action('sq_form_notices', array($this, 'getNotificationBar'));
|
21 |
+
|
22 |
+
$this->show_view('Blocks/Dashboard');
|
23 |
+
}
|
24 |
+
|
25 |
+
public function action()
|
26 |
+
{
|
27 |
+
parent::action();
|
28 |
+
|
29 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippets')) {
|
30 |
+
return;
|
31 |
+
}
|
32 |
+
|
33 |
+
switch (SQ_Classes_Helpers_Tools::getValue('action')) {
|
34 |
+
case 'sq_ajaxcheckseo':
|
35 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
36 |
+
|
37 |
+
//Check all the SEO
|
38 |
+
//Process all the tasks and save the report
|
39 |
+
SQ_Classes_ObjController::getClass('SQ_Models_CheckSeo')->checkSEO();
|
40 |
+
|
41 |
+
echo wp_json_encode(array('data' => $this->get_view('Blocks/Dashboard')));
|
42 |
+
exit();
|
43 |
+
|
44 |
+
}
|
45 |
+
}
|
46 |
+
}
|
controllers/Features.php
CHANGED
@@ -1,32 +1,34 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Features
|
6 |
-
*/
|
7 |
-
class SQ_Controllers_Features extends SQ_Classes_FrontController
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
16 |
-
|
17 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
18 |
-
}
|
19 |
-
|
20 |
-
|
21 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
22 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
23 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
24 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
25 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
26 |
-
|
27 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
}
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Features
|
6 |
+
*/
|
7 |
+
class SQ_Controllers_Features extends SQ_Classes_FrontController
|
8 |
+
{
|
9 |
+
|
10 |
+
public function init()
|
11 |
+
{
|
12 |
+
|
13 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap-reboot');
|
14 |
+
if (is_rtl()) {
|
15 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('popper');
|
16 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap.rtl');
|
17 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('rtl');
|
18 |
+
} else {
|
19 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap');
|
20 |
+
}
|
21 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('fontawesome');
|
22 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('switchery');
|
23 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('global');
|
24 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('research');
|
25 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('navbar');
|
26 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('dashboard');
|
27 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('account');
|
28 |
+
|
29 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('assistant');
|
30 |
+
|
31 |
+
parent::init();
|
32 |
+
}
|
33 |
+
|
34 |
+
}
|
controllers/FocusPages.php
CHANGED
@@ -1,430 +1,459 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Controllers_FocusPages extends SQ_Classes_FrontController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
*
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
if (
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
SQ_Classes_ObjController::getClass('
|
94 |
-
|
95 |
-
//
|
96 |
-
$this->
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
//
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
var
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
chart
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Controllers_FocusPages extends SQ_Classes_FrontController
|
5 |
+
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
*
|
9 |
+
*
|
10 |
+
* @var object Checkin process with Squirrly Cloud
|
11 |
+
*/
|
12 |
+
public $checkin;
|
13 |
+
/**
|
14 |
+
*
|
15 |
+
*
|
16 |
+
* @var array list of tasks labels
|
17 |
+
*/
|
18 |
+
public $labels = array();
|
19 |
+
/**
|
20 |
+
*
|
21 |
+
*
|
22 |
+
* @var array found pages in DB
|
23 |
+
*/
|
24 |
+
public $pages = array();
|
25 |
+
/**
|
26 |
+
*
|
27 |
+
*
|
28 |
+
* @var array of focus pages from API
|
29 |
+
*/
|
30 |
+
public $focuspages = array();
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Initiate the class if called from menu
|
34 |
+
*
|
35 |
+
* @return mixed|void
|
36 |
+
*/
|
37 |
+
function init()
|
38 |
+
{
|
39 |
+
|
40 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_api') == '') {
|
41 |
+
$this->show_view('Errors/Connect');
|
42 |
+
return;
|
43 |
+
}
|
44 |
+
|
45 |
+
//Checkin to API V2
|
46 |
+
$this->checkin = SQ_Classes_RemoteController::checkin();
|
47 |
+
|
48 |
+
if (is_wp_error($this->checkin)) {
|
49 |
+
if ($this->checkin->get_error_message() == 'no_data') {
|
50 |
+
$this->show_view('Errors/Error');
|
51 |
+
return;
|
52 |
+
} elseif ($this->checkin->get_error_message() == 'maintenance') {
|
53 |
+
$this->show_view('Errors/Maintenance');
|
54 |
+
return;
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
$tab = preg_replace("/[^a-zA-Z0-9]/", "", SQ_Classes_Helpers_Tools::getValue('tab', 'pagelist'));
|
59 |
+
|
60 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap-reboot');
|
61 |
+
if (is_rtl()) {
|
62 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('popper');
|
63 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap.rtl');
|
64 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('rtl');
|
65 |
+
} else {
|
66 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap');
|
67 |
+
}
|
68 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('switchery');
|
69 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('fontawesome');
|
70 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('global');
|
71 |
+
|
72 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('assistant');
|
73 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('navbar');
|
74 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('seosettings');
|
75 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('chart');
|
76 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('knob');
|
77 |
+
|
78 |
+
if (method_exists($this, $tab)) {
|
79 |
+
call_user_func(array($this, $tab));
|
80 |
+
}
|
81 |
+
$this->show_view('FocusPages/' . esc_attr(ucfirst($tab)));
|
82 |
+
|
83 |
+
//get the modal window for the assistant popup
|
84 |
+
echo SQ_Classes_ObjController::getClass('SQ_Models_Assistant')->getModal();
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Load for Add Focus Page menu tab
|
89 |
+
*/
|
90 |
+
public function addpage()
|
91 |
+
{
|
92 |
+
$search = (string)SQ_Classes_Helpers_Tools::getValue('skeyword', '');
|
93 |
+
$this->pages = SQ_Classes_ObjController::getClass('SQ_Models_Snippet')->getPages($search);
|
94 |
+
|
95 |
+
//get also the focus pages
|
96 |
+
$this->focuspages = SQ_Classes_RemoteController::getFocusPages();
|
97 |
+
|
98 |
+
if (!empty($this->focuspages)) {
|
99 |
+
foreach ($this->focuspages as &$focuspage) {
|
100 |
+
$focuspage = SQ_Classes_ObjController::getDomain('SQ_Models_Domain_FocusPage', $focuspage);
|
101 |
+
}
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Called for List of the Focus Pages
|
107 |
+
*/
|
108 |
+
public function pagelist()
|
109 |
+
{
|
110 |
+
add_action('sq_form_notices', array($this, 'getNotificationBar'));
|
111 |
+
|
112 |
+
//Set the Labels and Categories
|
113 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('focuspages');
|
114 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('labels');
|
115 |
+
|
116 |
+
//Set the focus pages and labels
|
117 |
+
$this->setFocusPages();
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Set the Focus Pages and Labels
|
122 |
+
*/
|
123 |
+
public function setFocusPages()
|
124 |
+
{
|
125 |
+
$labels = SQ_Classes_Helpers_Tools::getValue('slabel', array());
|
126 |
+
$days_back = (int)SQ_Classes_Helpers_Tools::getValue('days_back', 90);
|
127 |
+
$sid = SQ_Classes_Helpers_Tools::getValue('sid', false);
|
128 |
+
|
129 |
+
SQ_Classes_ObjController::getClass('SQ_Models_FocusPages')->init();
|
130 |
+
$this->checkin = SQ_Classes_RemoteController::checkin();
|
131 |
+
|
132 |
+
if ($focuspages = SQ_Classes_RemoteController::getFocusPages()) {
|
133 |
+
|
134 |
+
if (is_wp_error($focuspages)) {
|
135 |
+
SQ_Classes_Error::setError('Could not load the Focus Pages.');
|
136 |
+
} else {
|
137 |
+
|
138 |
+
//Get the audits for the focus pages
|
139 |
+
$audits = SQ_Classes_RemoteController::getFocusAudits(array('post_id' => $sid, 'days_back' => $days_back));
|
140 |
+
|
141 |
+
if (!empty($focuspages)) {
|
142 |
+
foreach ($focuspages as $focuspage) {
|
143 |
+
|
144 |
+
//Add the audit data if exists
|
145 |
+
if (!is_wp_error($audits)) {
|
146 |
+
if (isset($focuspage->user_post_id) && !empty($audits)) {
|
147 |
+
foreach ($audits as $audit) {
|
148 |
+
if ($focuspage->user_post_id == $audit->user_post_id) {
|
149 |
+
if (isset($audit->audit)) $audit->audit = json_decode($audit->audit); //set the audit data
|
150 |
+
if (isset($audit->stats)) $audit->stats = json_decode($audit->stats); //set the stats and progress data
|
151 |
+
$focuspage = (object)array_merge((array)$focuspage, (array)$audit);
|
152 |
+
break;
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
*
|
160 |
+
*
|
161 |
+
* @var SQ_Models_Domain_FocusPage $focuspage
|
162 |
+
*/
|
163 |
+
$focuspage = SQ_Classes_ObjController::getDomain('SQ_Models_Domain_FocusPage', $focuspage);
|
164 |
+
|
165 |
+
//set the connection info with GSC and GA
|
166 |
+
$focuspage->audit->sq_analytics_gsc_connected = (isset($this->checkin->connection_gsc) ? $this->checkin->connection_gsc : 0);
|
167 |
+
$focuspage->audit->sq_analytics_google_connected = (isset($this->checkin->connection_ga) ? $this->checkin->connection_ga : 0);
|
168 |
+
$focuspage->audit->sq_subscription_serpcheck = (isset($this->checkin->subscription_serpcheck) ? $this->checkin->subscription_serpcheck : 0);
|
169 |
+
|
170 |
+
//SQ_Debug::dump($focuspage, $focuspage->audit);
|
171 |
+
|
172 |
+
//If there is a local page, then show focus
|
173 |
+
if ($focuspage->getWppost()) {
|
174 |
+
//if post_id is set, show only that focus page
|
175 |
+
if ($sid && $focuspage->id <> $sid) {
|
176 |
+
continue;
|
177 |
+
}
|
178 |
+
|
179 |
+
$this->focuspages[] = SQ_Classes_ObjController::getClass('SQ_Models_FocusPages')->parseFocusPage($focuspage, $labels)->getFocusPage();
|
180 |
+
|
181 |
+
} elseif ($focuspage->user_post_id) {
|
182 |
+
SQ_Classes_Error::setError(esc_html__("Focus Page does not exist or was deleted from your website.", 'squirrly-seo'));
|
183 |
+
SQ_Classes_RemoteController::deleteFocusPage(array('user_post_id' => $focuspage->user_post_id));
|
184 |
+
}
|
185 |
+
}
|
186 |
+
}
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
//Remove the blank focus pages
|
191 |
+
$this->focuspages = array_filter($this->focuspages);
|
192 |
+
|
193 |
+
//Get the labels for view use
|
194 |
+
if (!empty($labels) || count((array)$this->focuspages) > 1) {
|
195 |
+
$this->labels = SQ_Classes_ObjController::getClass('SQ_Models_FocusPages')->getLabels();
|
196 |
+
}
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Load the Google Chart
|
201 |
+
*
|
202 |
+
* @return string
|
203 |
+
*/
|
204 |
+
public function loadScripts()
|
205 |
+
{
|
206 |
+
echo '<script>
|
207 |
+
function drawScoreChart(id, values, reverse) {
|
208 |
+
var data = google.visualization.arrayToDataTable(values);
|
209 |
+
|
210 |
+
var options = {
|
211 |
+
|
212 |
+
title : "",
|
213 |
+
chartArea:{width:"85%",height:"80%"},
|
214 |
+
enableInteractivity: "true",
|
215 |
+
tooltip: {trigger: "auto"},
|
216 |
+
vAxis: {
|
217 |
+
direction: ((reverse) ? -1 : 1),
|
218 |
+
title: "",
|
219 |
+
viewWindowMode:"explicit",
|
220 |
+
viewWindow: {
|
221 |
+
max:100,
|
222 |
+
min:0
|
223 |
+
}},
|
224 |
+
hAxis: {
|
225 |
+
title: "",
|
226 |
+
baselineColor: "transparent",
|
227 |
+
gridlineColor: "transparent",
|
228 |
+
textPosition: "none"
|
229 |
+
} ,
|
230 |
+
seriesType: "bars",
|
231 |
+
series: {2: {type: "line"}},
|
232 |
+
legend: {position: "bottom"},
|
233 |
+
colors:["#17c6ea"]
|
234 |
+
};
|
235 |
+
|
236 |
+
var chart = new google.visualization.ComboChart(document.getElementById(id));
|
237 |
+
chart.draw(data, options);
|
238 |
+
return chart;
|
239 |
+
}
|
240 |
+
function drawRankingChart(id, values, reverse) {
|
241 |
+
var data = google.visualization.arrayToDataTable(values);
|
242 |
+
|
243 |
+
var options = {
|
244 |
+
|
245 |
+
curveType: "function",
|
246 |
+
title: "",
|
247 |
+
chartArea:{width:"100%",height:"100%"},
|
248 |
+
enableInteractivity: "true",
|
249 |
+
tooltip: {trigger: "auto"},
|
250 |
+
pointSize: "2",
|
251 |
+
colors: ["#55b2ca"],
|
252 |
+
hAxis: {
|
253 |
+
baselineColor: "transparent",
|
254 |
+
gridlineColor: "transparent",
|
255 |
+
textPosition: "none"
|
256 |
+
} ,
|
257 |
+
vAxis:{
|
258 |
+
direction: ((reverse) ? -1 : 1),
|
259 |
+
baselineColor: "transparent",
|
260 |
+
gridlineColor: "transparent",
|
261 |
+
textPosition: "none"
|
262 |
+
}
|
263 |
+
};
|
264 |
+
|
265 |
+
var chart = new google.visualization.LineChart(document.getElementById(id));
|
266 |
+
chart.draw(data, options);
|
267 |
+
return chart;
|
268 |
+
}
|
269 |
+
function drawTrafficChart(id, values, reverse) {
|
270 |
+
var data = google.visualization.arrayToDataTable(values);
|
271 |
+
|
272 |
+
var options = {
|
273 |
+
|
274 |
+
title : "",
|
275 |
+
chartArea:{width:"85%",height:"80%"},
|
276 |
+
enableInteractivity: "true",
|
277 |
+
tooltip: {trigger: "auto"},
|
278 |
+
vAxis: {
|
279 |
+
direction: ((reverse) ? -1 : 1),
|
280 |
+
title: "",
|
281 |
+
viewWindowMode:"explicit"
|
282 |
+
},
|
283 |
+
hAxis: {
|
284 |
+
title: "",
|
285 |
+
baselineColor: "transparent",
|
286 |
+
gridlineColor: "transparent",
|
287 |
+
textPosition: "none"
|
288 |
+
} ,
|
289 |
+
seriesType: "bars",
|
290 |
+
series: {2: {type: "line"}},
|
291 |
+
legend: {position: "bottom"},
|
292 |
+
colors:["#17c6ea"]
|
293 |
+
};
|
294 |
+
|
295 |
+
var chart = new google.visualization.ComboChart(document.getElementById(id));
|
296 |
+
chart.draw(data, options);
|
297 |
+
return chart;
|
298 |
+
}
|
299 |
+
</script>';
|
300 |
+
}
|
301 |
+
|
302 |
+
/**
|
303 |
+
* Called when action is triggered
|
304 |
+
*
|
305 |
+
* @return void
|
306 |
+
*/
|
307 |
+
public function action()
|
308 |
+
{
|
309 |
+
|
310 |
+
parent::action();
|
311 |
+
|
312 |
+
switch (SQ_Classes_Helpers_Tools::getValue('action')) {
|
313 |
+
|
314 |
+
case 'sq_focuspages_inspecturl':
|
315 |
+
$json = array();
|
316 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
317 |
+
$post_id = (int)SQ_Classes_Helpers_Tools::getValue('post_id', 0);
|
318 |
+
|
319 |
+
//Set the focus pages and labels
|
320 |
+
$args = array();
|
321 |
+
$args['post_id'] = $post_id;
|
322 |
+
if ($json['html'] = SQ_Classes_RemoteController::getInspectURL($args)) {
|
323 |
+
|
324 |
+
//Support for international languages
|
325 |
+
if (function_exists('iconv') && SQ_Classes_Helpers_Tools::getOption('sq_non_utf8_support')) {
|
326 |
+
if (strpos(get_bloginfo("language"), 'en') === false) {
|
327 |
+
$json['html'] = iconv('UTF-8', 'UTF-8//IGNORE', $json['html']);
|
328 |
+
}
|
329 |
+
}
|
330 |
+
}
|
331 |
+
|
332 |
+
if (SQ_Classes_Error::isError()) {
|
333 |
+
$json['error'] = SQ_Classes_Error::getError();
|
334 |
+
}
|
335 |
+
|
336 |
+
echo wp_json_encode($json);
|
337 |
+
exit();
|
338 |
+
case 'sq_focuspages_getpage':
|
339 |
+
$json = array();
|
340 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
341 |
+
|
342 |
+
|
343 |
+
//Set the focus pages and labels
|
344 |
+
$this->setFocusPages();
|
345 |
+
|
346 |
+
$json['html'] = $this->get_view('FocusPages/FocusPages');
|
347 |
+
|
348 |
+
//Support for international languages
|
349 |
+
if (function_exists('iconv') && SQ_Classes_Helpers_Tools::getOption('sq_non_utf8_support')) {
|
350 |
+
if (strpos(get_bloginfo("language"), 'en') === false) {
|
351 |
+
$json['html'] = iconv('UTF-8', 'UTF-8//IGNORE', $json['html']);
|
352 |
+
}
|
353 |
+
}
|
354 |
+
|
355 |
+
if (SQ_Classes_Error::isError()) {
|
356 |
+
$json['error'] = SQ_Classes_Error::getError();
|
357 |
+
}
|
358 |
+
|
359 |
+
echo wp_json_encode($json);
|
360 |
+
exit();
|
361 |
+
case 'sq_focuspages_addnew':
|
362 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_focuspages')) {
|
363 |
+
return;
|
364 |
+
}
|
365 |
+
|
366 |
+
$term_id = (int)SQ_Classes_Helpers_Tools::getValue('term_id', 0);
|
367 |
+
$taxonomy = SQ_Classes_Helpers_Tools::getValue('taxonomy', '');
|
368 |
+
$post_type = SQ_Classes_Helpers_Tools::getValue('type', '');
|
369 |
+
|
370 |
+
if ($post_id = (int)SQ_Classes_Helpers_Tools::getValue('post_id', 0)) {
|
371 |
+
if ($post = SQ_Classes_ObjController::getClass('SQ_Models_Snippet')->getCurrentSnippet($post_id, $term_id, $taxonomy, $post_type)) {
|
372 |
+
//Save the post data in DB with the hash
|
373 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Snippet')->savePost($post);
|
374 |
+
|
375 |
+
if ($post->post_status == 'publish' && $post->ID == $post_id) {
|
376 |
+
//send the post to API
|
377 |
+
$args = array();
|
378 |
+
$args['post_id'] = $post->ID;
|
379 |
+
$args['hash'] = $post->hash;
|
380 |
+
$args['permalink'] = $post->url;
|
381 |
+
if ($focuspage = SQ_Classes_RemoteController::addFocusPage($args)) {
|
382 |
+
if (!is_wp_error($focuspage)) {
|
383 |
+
SQ_Classes_Error::setError(esc_html__("Focus page is added. The audit may take a while so please be patient.", 'squirrly-seo') . " <br /> ", 'success');
|
384 |
+
if (isset($focuspage->user_post_id)) {
|
385 |
+
set_transient('sq_auditpage_' . $focuspage->user_post_id, time());
|
386 |
+
|
387 |
+
SQ_Classes_Helpers_Tools::saveOptions('seoreport_time', false);
|
388 |
+
}
|
389 |
+
} elseif ($focuspage->get_error_message() == 'limit_exceed') {
|
390 |
+
SQ_Classes_Error::setError(esc_html__("You reached the maximum number of focus pages for all your websites.", 'squirrly-seo') . " <br /> ");
|
391 |
+
}
|
392 |
+
} else {
|
393 |
+
SQ_Classes_Error::setError(esc_html__("Error! Could not add the focus page.", 'squirrly-seo') . " <br /> ");
|
394 |
+
}
|
395 |
+
} else {
|
396 |
+
SQ_Classes_Error::setError(esc_html__("Error! This focus page is not public.", 'squirrly-seo') . " <br /> ");
|
397 |
+
}
|
398 |
+
|
399 |
+
} else {
|
400 |
+
SQ_Classes_Error::setError(sprintf(esc_html__("Error! Could not find the focus page %d in your website.", 'squirrly-seo'), $post_id) . " <br /> ");
|
401 |
+
}
|
402 |
+
}
|
403 |
+
break;
|
404 |
+
case 'sq_focuspages_update':
|
405 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_focuspages')) {
|
406 |
+
return;
|
407 |
+
}
|
408 |
+
|
409 |
+
$post_id = (int)SQ_Classes_Helpers_Tools::getValue('post_id', 0);
|
410 |
+
$term_id = (int)SQ_Classes_Helpers_Tools::getValue('term_id', 0);
|
411 |
+
$taxonomy = SQ_Classes_Helpers_Tools::getValue('taxonomy', '');
|
412 |
+
$post_type = SQ_Classes_Helpers_Tools::getValue('type', '');
|
413 |
+
if ($id = (int)SQ_Classes_Helpers_Tools::getValue('id', 0)) {
|
414 |
+
if ($post = SQ_Classes_ObjController::getClass('SQ_Models_Snippet')->getCurrentSnippet($post_id, $term_id, $taxonomy, $post_type)) {
|
415 |
+
|
416 |
+
//Save the post data in DB with the hash
|
417 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Snippet')->savePost($post);
|
418 |
+
|
419 |
+
//send the post to API
|
420 |
+
$args = array();
|
421 |
+
$args['post_id'] = $id;
|
422 |
+
$args['hash'] = $post->hash;
|
423 |
+
$args['permalink'] = $post->url;
|
424 |
+
if ($focuspage = SQ_Classes_RemoteController::updateFocusPage($args)) {
|
425 |
+
|
426 |
+
if (!is_wp_error($focuspage)) {
|
427 |
+
SQ_Classes_Error::setError(esc_html__("Focus page sent for recheck. It may take a while so please be patient.", 'squirrly-seo') . " <br /> ", 'success');
|
428 |
+
set_transient('sq_auditpage_' . $id, time());
|
429 |
+
} elseif ($focuspage->get_error_message() == 'too_many_attempts') {
|
430 |
+
SQ_Classes_Error::setError(esc_html__("You've made too many requests, please wait a few minutes.", 'squirrly-seo') . " <br /> ");
|
431 |
+
}
|
432 |
+
|
433 |
+
} else {
|
434 |
+
SQ_Classes_Error::setError(esc_html__("You've made too many requests, please wait a few minutes.", 'squirrly-seo') . " <br /> ");
|
435 |
+
set_transient('sq_auditpage_' . $id, time());
|
436 |
+
}
|
437 |
+
|
438 |
+
} else {
|
439 |
+
SQ_Classes_Error::setError(sprintf(esc_html__("Error! Could not find the focus page %d in your website.", 'squirrly-seo'), $post_id) . " <br /> ");
|
440 |
+
}
|
441 |
+
}
|
442 |
+
break;
|
443 |
+
case 'sq_focuspages_delete':
|
444 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_focuspages')) {
|
445 |
+
return;
|
446 |
+
}
|
447 |
+
|
448 |
+
if ($post_id = SQ_Classes_Helpers_Tools::getValue('id', false)) {
|
449 |
+
SQ_Classes_RemoteController::deleteFocusPage(array('user_post_id' => $post_id));
|
450 |
+
SQ_Classes_Error::setError(esc_html__("The focus page is deleted", 'squirrly-seo') . " <br /> ", 'success');
|
451 |
+
} else {
|
452 |
+
SQ_Classes_Error::setError(esc_html__("Invalid params!", 'squirrly-seo') . " <br /> ");
|
453 |
+
}
|
454 |
+
|
455 |
+
break;
|
456 |
+
}
|
457 |
+
|
458 |
+
}
|
459 |
+
}
|
controllers/Frontend.php
CHANGED
@@ -1,164 +1,177 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Controllers_Frontend extends SQ_Classes_FrontController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
//
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
if (SQ_Classes_Helpers_Tools::getOption('
|
82 |
-
if ($basename == "
|
83 |
-
|
84 |
-
|
85 |
-
exit();
|
86 |
-
}
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
*
|
139 |
-
*/
|
140 |
-
public function
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
}
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Controllers_Frontend extends SQ_Classes_FrontController
|
5 |
+
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
*
|
9 |
+
*
|
10 |
+
* @var SQ_Models_Frontend
|
11 |
+
*/
|
12 |
+
public $model;
|
13 |
+
|
14 |
+
public function __construct()
|
15 |
+
{
|
16 |
+
if (is_admin() || is_network_admin() || SQ_Classes_Helpers_Tools::isAjax()) {
|
17 |
+
return;
|
18 |
+
}
|
19 |
+
|
20 |
+
//load the hooks
|
21 |
+
parent::__construct();
|
22 |
+
|
23 |
+
//For favicon and Robots
|
24 |
+
$this->hookCheckFiles();
|
25 |
+
|
26 |
+
/* Check if sitemap is on and Load the Sitemap */
|
27 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_auto_sitemap')) {
|
28 |
+
add_filter('wp_sitemaps_enabled', '__return_false');
|
29 |
+
SQ_Classes_ObjController::getClass('SQ_Controllers_Sitemaps');
|
30 |
+
}
|
31 |
+
|
32 |
+
//Check cache plugin compatibility
|
33 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Compatibility')->checkCompatibility();
|
34 |
+
|
35 |
+
//Check if late loading is on
|
36 |
+
if (!apply_filters('sq_lateloading', SQ_Classes_Helpers_Tools::getOption('sq_laterload'))) {
|
37 |
+
//Hook the buffer on both actions in case one fails
|
38 |
+
add_action('plugins_loaded', array($this, 'hookBuffer'), 9);
|
39 |
+
}
|
40 |
+
|
41 |
+
//In case plugins_loaded hook is disabled
|
42 |
+
add_action('template_redirect', array($this, 'hookBuffer'), 1);
|
43 |
+
|
44 |
+
//Set the post so that Squirrly will know which one to process
|
45 |
+
add_action('template_redirect', array($this->model, 'setPost'), 9);
|
46 |
+
|
47 |
+
if(SQ_Classes_Helpers_Tools::getOption('sq_auto_links')) {
|
48 |
+
|
49 |
+
//Check if attachment to image redirect is needed
|
50 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_attachment_redirect')) {
|
51 |
+
add_action('template_redirect', array($this->model, 'redirectAttachments'), 10);
|
52 |
+
}
|
53 |
+
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* HOOK THE BUFFER
|
59 |
+
*/
|
60 |
+
public function hookBuffer()
|
61 |
+
{
|
62 |
+
//remove the action is already hocked in plugins_loaded
|
63 |
+
if (!did_action('template_redirect')) {
|
64 |
+
remove_action('template_redirect', array($this, 'hookBuffer'), 1);
|
65 |
+
}
|
66 |
+
|
67 |
+
//Check if there is an editor loading
|
68 |
+
//Don't load Squirrly METAs while in frontend editors
|
69 |
+
if(!SQ_Classes_ObjController::getClass('SQ_Models_Compatibility')->isBuilderEditor()) {
|
70 |
+
$this->model->startBuffer();
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Called after plugins are loaded
|
76 |
+
*/
|
77 |
+
public function hookCheckFiles()
|
78 |
+
{
|
79 |
+
//Check for sitemap and robots
|
80 |
+
if ($basename = $this->getFileName($_SERVER['REQUEST_URI'])) {
|
81 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_auto_robots') == 1) {
|
82 |
+
if ($basename == "robots.txt") {
|
83 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Services_Robots');
|
84 |
+
apply_filters('sq_robots', false);
|
85 |
+
exit();
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_auto_favicon') && SQ_Classes_Helpers_Tools::getOption('favicon') <> '') {
|
90 |
+
if ($basename == "favicon.icon") {
|
91 |
+
SQ_Classes_Helpers_Tools::setHeader('ico');
|
92 |
+
@readfile(_SQ_CACHE_DIR_ . SQ_Classes_Helpers_Tools::getOption('favicon'));
|
93 |
+
exit();
|
94 |
+
} elseif ($basename == "touch-icon.png") {
|
95 |
+
SQ_Classes_Helpers_Tools::setHeader('png');
|
96 |
+
@readfile(_SQ_CACHE_DIR_ . SQ_Classes_Helpers_Tools::getOption('favicon'));
|
97 |
+
exit();
|
98 |
+
} else {
|
99 |
+
$appleSizes = preg_split('/[,]+/', _SQ_MOBILE_ICON_SIZES);
|
100 |
+
foreach ($appleSizes as $appleSize) {
|
101 |
+
if ($basename == "touch-icon$appleSize.png") {
|
102 |
+
SQ_Classes_Helpers_Tools::setHeader('png');
|
103 |
+
@readfile(_SQ_CACHE_DIR_ . SQ_Classes_Helpers_Tools::getOption('favicon') . $appleSize);
|
104 |
+
exit();
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
}
|
111 |
+
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Hook the Header load
|
116 |
+
*/
|
117 |
+
public function hookFronthead()
|
118 |
+
{
|
119 |
+
|
120 |
+
if (is_admin() || (defined('SQ_NOCSS') && SQ_NOCSS)) {
|
121 |
+
return;
|
122 |
+
}
|
123 |
+
|
124 |
+
if (SQ_Classes_Helpers_Tools::isPluginInstalled('elementor/elementor.php')) {
|
125 |
+
if (SQ_Classes_Helpers_Tools::getValue('elementor-preview', false)) {
|
126 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('elementor');
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
if(SQ_Classes_Helpers_Tools::getOption('sq_load_css')) {
|
131 |
+
if (!SQ_Classes_Helpers_Tools::isAjax()) {
|
132 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('frontend');
|
133 |
+
}
|
134 |
+
}
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Hook the footer function
|
139 |
+
*/
|
140 |
+
public function hookFrontfooter()
|
141 |
+
{
|
142 |
+
//Show the analytics code in footer
|
143 |
+
echo $this->model->getFooter();
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Get the File Name if itțs a file in URL
|
148 |
+
*
|
149 |
+
* @param null $url
|
150 |
+
* @return bool|string|null
|
151 |
+
*/
|
152 |
+
public function getFileName($url = null)
|
153 |
+
{
|
154 |
+
if (isset($url) && $url <> '') {
|
155 |
+
$url = basename($url);
|
156 |
+
if (strpos($url, '?') <> '') {
|
157 |
+
$url = substr($url, 0, strpos($url, '?'));
|
158 |
+
}
|
159 |
+
|
160 |
+
$files = array('ico', 'icon', 'txt', 'jpg', 'jpeg', 'png', 'bmp', 'gif', 'webp',
|
161 |
+
'css', 'scss', 'js',
|
162 |
+
'pdf', 'doc', 'docx', 'csv', 'xls', 'xslx',
|
163 |
+
'mp4', 'mpeg',
|
164 |
+
'zip', 'rar');
|
165 |
+
|
166 |
+
if (strrpos($url, '.') !== false) {
|
167 |
+
$ext = substr($url, strrpos($url, '.') + 1);
|
168 |
+
if (in_array($ext, $files)) {
|
169 |
+
return $url;
|
170 |
+
}
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
+
return false;
|
175 |
+
|
176 |
+
}
|
177 |
+
}
|
controllers/Menu.php
CHANGED
@@ -1,483 +1,535 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Controllers_Menu extends SQ_Classes_FrontController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
$
|
231 |
-
|
232 |
-
|
233 |
-
'
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
'
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
)
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
$
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
'
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
$
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
if (
|
477 |
-
|
478 |
-
}
|
479 |
-
}
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Controllers_Menu extends SQ_Classes_FrontController
|
5 |
+
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
*
|
9 |
+
*
|
10 |
+
* @var array snippet
|
11 |
+
*/
|
12 |
+
public $post_type;
|
13 |
+
/**
|
14 |
+
*
|
15 |
+
*
|
16 |
+
* @var array snippet
|
17 |
+
*/
|
18 |
+
var $options = array();
|
19 |
+
|
20 |
+
public function __construct()
|
21 |
+
{
|
22 |
+
parent::__construct();
|
23 |
+
|
24 |
+
global $sq_fullscreen, $sq_setting_page;
|
25 |
+
|
26 |
+
//Only on subsites
|
27 |
+
if (!is_network_admin()) {
|
28 |
+
$sq_fullscreen = $sq_setting_page = false;
|
29 |
+
|
30 |
+
add_action('admin_bar_menu', array($this, 'hookTopmenuDashboard'), 10);
|
31 |
+
add_action('admin_bar_menu', array($this, 'hookTopmenuSquirrly'), 91);
|
32 |
+
|
33 |
+
add_action('do_meta_boxes', array($this, 'addMetabox'));
|
34 |
+
add_filter('sq_cloudmenu', array($this, 'getCloudMenu'), 10, 2);
|
35 |
+
|
36 |
+
//run compatibility check on Squirrly settings
|
37 |
+
if (SQ_Classes_Helpers_Tools::getIsset('page')) {
|
38 |
+
|
39 |
+
//Get all the Squirrly SEO menus
|
40 |
+
$menus = $this->model->getMainMenu();
|
41 |
+
//Get current accessed page
|
42 |
+
$page = apply_filters('sq_page', SQ_Classes_Helpers_Tools::getValue('page'));
|
43 |
+
|
44 |
+
if (in_array($page, array_keys($menus))) {
|
45 |
+
//Set if it's a Squirrly SEO Page
|
46 |
+
$sq_setting_page = true;
|
47 |
+
|
48 |
+
//Check if the menu requires full screen window
|
49 |
+
if (isset($menus[$page]['fullscreen']) && $menus[$page]['fullscreen']) {
|
50 |
+
$sq_fullscreen = true;
|
51 |
+
}
|
52 |
+
|
53 |
+
//dequeue other css when on Squirrly Settings page
|
54 |
+
add_action('admin_enqueue_scripts', array(SQ_Classes_ObjController::getClass('SQ_Models_Compatibility'), 'fixEnqueueErrors'), PHP_INT_MAX);
|
55 |
+
add_action('admin_head', array($this, 'setViewport'), PHP_INT_MAX);
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
//Hook the Frontend Editors
|
60 |
+
$this->hookBuilders();
|
61 |
+
}
|
62 |
+
|
63 |
+
add_action(
|
64 |
+
'current_screen', function () {
|
65 |
+
if (in_array(get_current_screen()->id, array('plugins', 'plugins-network'))) {
|
66 |
+
SQ_Classes_ObjController::getClass('SQ_Controllers_Uninstall');
|
67 |
+
}
|
68 |
+
}
|
69 |
+
);
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Hook the Admin load
|
74 |
+
*/
|
75 |
+
public function hookInit()
|
76 |
+
{
|
77 |
+
|
78 |
+
/* add the plugin menu in admin */
|
79 |
+
if (SQ_Classes_Helpers_Tools::userCan('manage_options')) {
|
80 |
+
try {
|
81 |
+
//check if activated
|
82 |
+
if (get_transient('sq_activate') == 1) {
|
83 |
+
// Delete the redirect transient
|
84 |
+
delete_transient('sq_activate');
|
85 |
+
|
86 |
+
//Create Qss table if not exists
|
87 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Qss')->checkTableExists();
|
88 |
+
|
89 |
+
//This option is use for custom Package installs
|
90 |
+
//update text in case of devkit
|
91 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_Helpers_DevKit')->updatePluginData();
|
92 |
+
|
93 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_api') == '') {
|
94 |
+
wp_redirect(SQ_Classes_Helpers_Tools::getAdminUrl('sq_dashboard'));
|
95 |
+
die();
|
96 |
+
}
|
97 |
+
|
98 |
+
//Connect to cloud with an unique Token for API access
|
99 |
+
SQ_Classes_ObjController::getClass('SQ_Core_BlockConnect')->connectToCloud();
|
100 |
+
}
|
101 |
+
|
102 |
+
} catch (Exception $e) {
|
103 |
+
SQ_Classes_Error::setMessage(sprintf(esc_html__("An error occurred during activation. If this error persists, please contact us at: %s", 'squirrly-seo'), _SQ_SUPPORT_URL_));
|
104 |
+
}
|
105 |
+
|
106 |
+
}
|
107 |
+
|
108 |
+
//Add Squirrly SEO in Posts list
|
109 |
+
SQ_Classes_ObjController::getClass('SQ_Controllers_PostsList')->init();
|
110 |
+
|
111 |
+
//Hook the post save action
|
112 |
+
SQ_Classes_ObjController::getClass('SQ_Controllers_Post')->hookPost();
|
113 |
+
|
114 |
+
//Show Squirrly SEO in Dashboard if connected to Squirrly Cloud
|
115 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_api') <> '') {
|
116 |
+
add_action('wp_dashboard_setup', array($this, 'hookDashboardSetup'));
|
117 |
+
}
|
118 |
+
|
119 |
+
//Add the Squirrly Class in all Squirrly SEO Pages
|
120 |
+
add_filter('admin_body_class', array($this, 'addSquirrlySettingsClass'));
|
121 |
+
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Show the Dashboard link when Full Screen
|
126 |
+
*
|
127 |
+
* @param \WP_Admin_Bar $wp_admin_bar
|
128 |
+
* @return mixed
|
129 |
+
*/
|
130 |
+
public function hookTopmenuDashboard($wp_admin_bar)
|
131 |
+
{
|
132 |
+
global $sq_fullscreen;
|
133 |
+
|
134 |
+
if (function_exists('is_user_logged_in') && is_user_logged_in()) {
|
135 |
+
if (isset($sq_fullscreen) && $sq_fullscreen) {
|
136 |
+
$wp_admin_bar->add_node(
|
137 |
+
array(
|
138 |
+
'parent' => 'site-name',
|
139 |
+
'id' => 'dashboard',
|
140 |
+
'title' => esc_html__("Dashboard"),
|
141 |
+
'href' => admin_url(),
|
142 |
+
)
|
143 |
+
);
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
return $wp_admin_bar;
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Show the Squirrly Menu in toolbar
|
152 |
+
*
|
153 |
+
* @param \WP_Admin_Bar $wp_admin_bar
|
154 |
+
*
|
155 |
+
* @return \WP_Admin_Bar
|
156 |
+
*/
|
157 |
+
public function hookTopmenuSquirrly($wp_admin_bar)
|
158 |
+
{
|
159 |
+
global $tag;
|
160 |
+
|
161 |
+
if (!apply_filters('sq_load_snippet', true) || !SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
162 |
+
return;
|
163 |
+
}
|
164 |
+
|
165 |
+
if (is_admin()) {
|
166 |
+
|
167 |
+
if (SQ_Classes_Helpers_Tools::userCan('edit_posts')) {
|
168 |
+
//Get count local SEO errors
|
169 |
+
$errors = apply_filters('sq_seo_errors', 0);
|
170 |
+
|
171 |
+
$wp_admin_bar->add_node(
|
172 |
+
array(
|
173 |
+
'id' => 'sq_toolbar',
|
174 |
+
'title' => '<span class="sq_logo" style="margin-right: 2px"></span>' . esc_html(apply_filters('sq_menu_name', _SQ_MENU_NAME_)) . (($errors) ? '<span class="sq_errorcount">' . esc_html($errors) . '</span>' : ''),
|
175 |
+
'href' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_dashboard'),
|
176 |
+
'parent' => false
|
177 |
+
)
|
178 |
+
);
|
179 |
+
|
180 |
+
$mainmenu = $this->model->getMainMenu();
|
181 |
+
if (!empty($mainmenu)) {
|
182 |
+
foreach ($mainmenu as $menuid => $item) {
|
183 |
+
|
184 |
+
//Check if the menu item is visible on the top
|
185 |
+
if (isset($item['topmenu']) && !$item['topmenu']) {
|
186 |
+
continue;
|
187 |
+
}
|
188 |
+
|
189 |
+
if ($menuid == 'sq_dashboard' && $errors) {
|
190 |
+
if (is_rtl()) {
|
191 |
+
$item['title'] = '<span class="sq_errorcount" style="margin: 6px 0 0 0 !important; float: left !important;">' . $errors . '</span>' . $item['title'];
|
192 |
+
} else {
|
193 |
+
$item['title'] = $item['title'] . '<span class="sq_errorcount" style="margin: 6px 35px 0 0 !important;">' . $errors . '</span>';
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
+
//make sure the user has the capabilities
|
198 |
+
if (SQ_Classes_Helpers_Tools::userCan($item['capability'])) {
|
199 |
+
$wp_admin_bar->add_node(
|
200 |
+
array(
|
201 |
+
'id' => $menuid,
|
202 |
+
'title' => $item['title'],
|
203 |
+
'href' => SQ_Classes_Helpers_Tools::getAdminUrl($menuid),
|
204 |
+
'parent' => 'sq_toolbar'
|
205 |
+
)
|
206 |
+
);
|
207 |
+
$tabs = $this->model->getTabs($menuid);
|
208 |
+
if (!empty($tabs)) {
|
209 |
+
foreach ($tabs as $id => $tab) {
|
210 |
+
$array_id = explode('/', $id);
|
211 |
+
if (count((array)$array_id) == 2) {
|
212 |
+
$wp_admin_bar->add_node(
|
213 |
+
array(
|
214 |
+
'id' => $menuid . str_replace('/', '_', $id),
|
215 |
+
'title' => $tab['title'],
|
216 |
+
'href' => SQ_Classes_Helpers_Tools::getAdminUrl($array_id[0], $array_id[1]),
|
217 |
+
'parent' => $menuid
|
218 |
+
)
|
219 |
+
);
|
220 |
+
}
|
221 |
+
}
|
222 |
+
}
|
223 |
+
}
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
+
}
|
228 |
+
|
229 |
+
$current_screen = get_current_screen();
|
230 |
+
$post = get_post();
|
231 |
+
if ('post' == $current_screen->base
|
232 |
+
&& ($post_type_object = get_post_type_object($post->post_type))
|
233 |
+
&& (SQ_Classes_Helpers_Tools::userCan('edit_post', $post->ID) || SQ_Classes_Helpers_Tools::userCan('sq_manage_snippets'))
|
234 |
+
&& ($post_type_object->public)
|
235 |
+
) {
|
236 |
+
} elseif ('edit' == $current_screen->base
|
237 |
+
&& ($post_type_object = get_post_type_object($current_screen->post_type))
|
238 |
+
&& ($post_type_object->show_in_admin_bar)
|
239 |
+
&& !('edit-' . $current_screen->post_type === $current_screen->id)
|
240 |
+
) {
|
241 |
+
} elseif ('term' == $current_screen->base
|
242 |
+
&& isset($tag) && is_object($tag) && !is_wp_error($tag)
|
243 |
+
&& ($tax = get_taxonomy($tag->taxonomy))
|
244 |
+
&& $tax->public
|
245 |
+
) {
|
246 |
+
} else {
|
247 |
+
return $wp_admin_bar;
|
248 |
+
}
|
249 |
+
|
250 |
+
$this->model->addMeta(
|
251 |
+
array('sq_blocksnippet',
|
252 |
+
esc_html__("SEO Snippet", 'squirrly-seo'),
|
253 |
+
array(SQ_Classes_ObjController::getClass('SQ_Controllers_Snippet'), 'init'),
|
254 |
+
null,
|
255 |
+
'normal',
|
256 |
+
'high'
|
257 |
+
)
|
258 |
+
);
|
259 |
+
|
260 |
+
$wp_admin_bar->add_node(
|
261 |
+
array(
|
262 |
+
'id' => 'sq_bar_menu',
|
263 |
+
'title' => '<span class="sq_logo"></span> ' . esc_html__("Custom SEO", 'squirrly-seo'),
|
264 |
+
'parent' => 'top-secondary',
|
265 |
+
)
|
266 |
+
);
|
267 |
+
|
268 |
+
|
269 |
+
//Add snippet body
|
270 |
+
$wp_admin_bar->add_menu(
|
271 |
+
array(
|
272 |
+
'id' => 'sq_bar_submenu',
|
273 |
+
'parent' => 'sq_bar_menu',
|
274 |
+
'meta' => array(
|
275 |
+
'html' => SQ_Classes_ObjController::getClass('SQ_Controllers_Snippet')->init(),
|
276 |
+
'tabindex' => PHP_INT_MAX,
|
277 |
+
),
|
278 |
+
)
|
279 |
+
);
|
280 |
+
}
|
281 |
+
|
282 |
+
return $wp_admin_bar;
|
283 |
+
}
|
284 |
+
|
285 |
+
public function hookDashboardSetup()
|
286 |
+
{
|
287 |
+
wp_add_dashboard_widget(
|
288 |
+
'sq_dashboard_widget',
|
289 |
+
esc_html__("Squirrly SEO", 'squirrly-seo'),
|
290 |
+
array(SQ_Classes_ObjController::getClass('SQ_Controllers_Dashboard'), 'dashboard')
|
291 |
+
);
|
292 |
+
|
293 |
+
// Move our widget to top.
|
294 |
+
global $wp_meta_boxes;
|
295 |
+
|
296 |
+
$dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
|
297 |
+
$ours = array('sq_dashboard_widget' => $dashboard['sq_dashboard_widget']);
|
298 |
+
$wp_meta_boxes['dashboard']['normal']['core'] = array_merge($ours, $dashboard);
|
299 |
+
}
|
300 |
+
|
301 |
+
public function hookNetworkMenu()
|
302 |
+
{
|
303 |
+
//Check the Dev Kit settings
|
304 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_Helpers_DevKit');
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* Creates the Setting menu in Wordpress
|
309 |
+
*/
|
310 |
+
public function hookMenu()
|
311 |
+
{
|
312 |
+
//Hook the SEO Errors from Squirrly SEO Check
|
313 |
+
add_action('sq_seo_errors', array($this, 'getSEOErrors'));
|
314 |
+
|
315 |
+
//Check the Dev Kit settings
|
316 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_Helpers_DevKit');
|
317 |
+
|
318 |
+
//Get all the post types
|
319 |
+
$this->post_type = SQ_Classes_Helpers_Tools::getOption('sq_post_types');
|
320 |
+
|
321 |
+
//Get count local SEO errors
|
322 |
+
$errors = apply_filters('sq_seo_errors', 0);
|
323 |
+
|
324 |
+
///////////////
|
325 |
+
$this->model->addMenu(
|
326 |
+
array(apply_filters('sq_menu_name', _SQ_MENU_NAME_),
|
327 |
+
apply_filters('sq_menu_name', _SQ_MENU_NAME_) . (($errors) ? '<span class="sq_errorcount">' . $errors . '</span>' : ''),
|
328 |
+
'edit_posts',
|
329 |
+
'sq_dashboard',
|
330 |
+
null,
|
331 |
+
apply_filters('sq_logo', _SQ_ASSETS_URL_ . 'img/logos/menu_icon_16.png')
|
332 |
+
)
|
333 |
+
);
|
334 |
+
|
335 |
+
//Load the Squirrly Menu
|
336 |
+
$mainmenu = $this->model->getMainMenu();
|
337 |
+
if (!empty($mainmenu)) {
|
338 |
+
foreach ($mainmenu as $name => $item) {
|
339 |
+
|
340 |
+
//Check if the menu is set to show in the left side
|
341 |
+
if (isset($item['leftmenu'])) {
|
342 |
+
if (is_bool($item['leftmenu'])) {
|
343 |
+
if (!$item['leftmenu'] && SQ_Classes_Helpers_Tools::getValue('page', '') <> $name) {
|
344 |
+
continue;
|
345 |
+
}
|
346 |
+
} else {
|
347 |
+
$item['title'] = $item['leftmenu'];
|
348 |
+
}
|
349 |
+
}
|
350 |
+
|
351 |
+
//Add the page
|
352 |
+
$this->model->addSubmenu(
|
353 |
+
array($item['parent'],
|
354 |
+
$item['description'],
|
355 |
+
$item['title'],
|
356 |
+
$item['capability'],
|
357 |
+
$name,
|
358 |
+
$item['function'],
|
359 |
+
)
|
360 |
+
);
|
361 |
+
|
362 |
+
}
|
363 |
+
|
364 |
+
//Update the external links in the menu
|
365 |
+
global $submenu;
|
366 |
+
if (!empty($submenu['sq_dashboard'])) {
|
367 |
+
foreach ($submenu['sq_dashboard'] as &$item) {
|
368 |
+
if (isset($mainmenu[$item[2]]['href']) && $mainmenu[$item[2]]['href']) {
|
369 |
+
if (parse_url($mainmenu[$item[2]]['href'], PHP_URL_HOST) !== parse_url(home_url(), PHP_URL_HOST)) {
|
370 |
+
$item[0] .= '<i class="dashicons dashicons-external" style="font-size:12px;vertical-align:-2px;height:10px;"></i>';
|
371 |
+
}
|
372 |
+
$item[2] = $mainmenu[$item[2]]['href'];
|
373 |
+
}
|
374 |
+
}
|
375 |
+
}
|
376 |
+
}
|
377 |
+
}
|
378 |
+
|
379 |
+
/**
|
380 |
+
* Add Post Editor Meta Box
|
381 |
+
* Load Squirrly Live Assistant
|
382 |
+
*/
|
383 |
+
public function addMetabox()
|
384 |
+
{
|
385 |
+
$types = get_post_types(array('public' => true));
|
386 |
+
|
387 |
+
if (!apply_filters('sq_load_snippet', true) || !SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
388 |
+
return;
|
389 |
+
}
|
390 |
+
|
391 |
+
//Exclude types for SLA
|
392 |
+
$excludes = SQ_Classes_Helpers_Tools::getOption('sq_sla_exclude_post_types');
|
393 |
+
if (!empty($types) && !empty($excludes)) {
|
394 |
+
foreach ($excludes as $exclude) {
|
395 |
+
if ($exclude) {
|
396 |
+
if (in_array($exclude, $types)) {
|
397 |
+
unset($types[$exclude]);
|
398 |
+
}
|
399 |
+
}
|
400 |
+
}
|
401 |
+
}
|
402 |
+
|
403 |
+
//Add Live Assistant For Selected Post Types
|
404 |
+
if (!empty($types)) {
|
405 |
+
foreach ($types as $type) {
|
406 |
+
if (is_string($type) && $type <> '' && $metabox = unserialize(SQ_Classes_Helpers_Tools::getUserMeta('meta-box-order_' . $type))) {
|
407 |
+
extract($metabox);
|
408 |
+
|
409 |
+
if (isset($side) && isset($normal) && is_string($side) && is_string($normal)) {
|
410 |
+
$side = explode(',', $side);
|
411 |
+
$normal = explode(',', $normal);
|
412 |
+
if (in_array('post' . _SQ_NAME_, $normal)) {
|
413 |
+
$side = array_merge(array('post' . _SQ_NAME_), $side);
|
414 |
+
$metabox['side'] = join(',', array_unique($side));
|
415 |
+
|
416 |
+
$normal = array_diff($normal, array('post' . _SQ_NAME_));
|
417 |
+
$metabox['normal'] = join(',', array_unique($normal));
|
418 |
+
SQ_Classes_Helpers_Tools::saveUserMeta('meta-box-order_' . $type, $metabox);
|
419 |
+
}
|
420 |
+
|
421 |
+
if (in_array('sq_blocksnippet', $side)) {
|
422 |
+
$normal = array_merge(array('sq_blocksnippet'), $normal);
|
423 |
+
$metabox['normal'] = join(',', array_unique($normal));
|
424 |
+
|
425 |
+
$side = array_diff($side, array('sq_blocksnippet'));
|
426 |
+
$metabox['side'] = join(',', array_unique($side));
|
427 |
+
SQ_Classes_Helpers_Tools::saveUserMeta('meta-box-order_' . $type, $metabox);
|
428 |
+
}
|
429 |
+
}
|
430 |
+
}
|
431 |
+
|
432 |
+
//Load the SLA in Post
|
433 |
+
$this->model->addMeta(
|
434 |
+
array('post' . _SQ_NAME_,
|
435 |
+
ucfirst(_SQ_NAME_),
|
436 |
+
array(SQ_Classes_ObjController::getClass('SQ_Controllers_Post'), 'init'),
|
437 |
+
$type,
|
438 |
+
'side',
|
439 |
+
'high'
|
440 |
+
)
|
441 |
+
);
|
442 |
+
}
|
443 |
+
|
444 |
+
}
|
445 |
+
}
|
446 |
+
|
447 |
+
/**
|
448 |
+
* Add the Squirrly Setttings Class in all Squirrly SEO Pages
|
449 |
+
* Used for personal layout
|
450 |
+
*
|
451 |
+
* @param $classes
|
452 |
+
* @return string
|
453 |
+
*/
|
454 |
+
public function addSquirrlySettingsClass($classes)
|
455 |
+
{
|
456 |
+
global $sq_setting_page;
|
457 |
+
|
458 |
+
if (isset($sq_setting_page) && $sq_setting_page) {
|
459 |
+
$classes = "$classes squirrly-seo-settings";
|
460 |
+
}
|
461 |
+
|
462 |
+
return $classes;
|
463 |
+
}
|
464 |
+
|
465 |
+
/**
|
466 |
+
* Hook the Head
|
467 |
+
*/
|
468 |
+
public function hookHead()
|
469 |
+
{
|
470 |
+
global $sq_fullscreen, $sq_setting_page;
|
471 |
+
|
472 |
+
//Load settings only in the Squirrly Menu
|
473 |
+
if (isset($sq_setting_page) && $sq_setting_page) {
|
474 |
+
echo '<script type="text/javascript" src="//www.google.com/jsapi"></script>';
|
475 |
+
echo '<script>google.load("visualization", "1.0", {packages: ["corechart"]});</script>';
|
476 |
+
if (isset($sq_fullscreen) && $sq_fullscreen) {
|
477 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('fullwidth', array('trigger' => true, 'media' => 'all'));
|
478 |
+
}
|
479 |
+
}
|
480 |
+
|
481 |
+
//Load the Squirrly Logo on all Dashboard
|
482 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('logo');
|
483 |
+
|
484 |
+
}
|
485 |
+
|
486 |
+
/**
|
487 |
+
* Set the viewport for a google Squirrly Settings layout
|
488 |
+
*/
|
489 |
+
function setViewport()
|
490 |
+
{
|
491 |
+
$page = apply_filters('sq_page', SQ_Classes_Helpers_Tools::getValue('page', ''));
|
492 |
+
if ($page == 'sq_dashboard') {
|
493 |
+
echo '<meta name="viewport" content="width=900">';
|
494 |
+
} else {
|
495 |
+
echo '<meta name="viewport" content="width=1200">';
|
496 |
+
}
|
497 |
+
}
|
498 |
+
|
499 |
+
/**
|
500 |
+
* Hook the Elementor Builder
|
501 |
+
*/
|
502 |
+
public function hookBuilders()
|
503 |
+
{
|
504 |
+
add_action('elementor/editor/footer', array(SQ_Classes_ObjController::getClass('SQ_Controllers_Post'), 'loadLiveAssistant'), 99);
|
505 |
+
}
|
506 |
+
|
507 |
+
/**
|
508 |
+
* Count the SEO Errors from SEO Goals
|
509 |
+
*
|
510 |
+
* @return mixed
|
511 |
+
*/
|
512 |
+
public function getSEOErrors()
|
513 |
+
{
|
514 |
+
return SQ_Classes_ObjController::getClass('SQ_Controllers_CheckSeo')->setCategory('sq_dashboard')->getErrorsCount();
|
515 |
+
}
|
516 |
+
|
517 |
+
|
518 |
+
/**
|
519 |
+
* Set the cloud.squirrly.co menu based on the client rights
|
520 |
+
*
|
521 |
+
* @param $url
|
522 |
+
* @param $path
|
523 |
+
* @return string
|
524 |
+
*/
|
525 |
+
public function getCloudMenu($url, $path)
|
526 |
+
{
|
527 |
+
if (function_exists('wp_get_current_user') && SQ_Classes_Helpers_Tools::getOption('sq_api')) {
|
528 |
+
if (SQ_Classes_Helpers_Tools::getMenuVisible('show_panel') && SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
529 |
+
$url .= 'login/?token=' . SQ_Classes_Helpers_Tools::getOption('sq_api') . '&user_url=' . apply_filters('sq_homeurl', get_bloginfo('url')) . '&redirect_to=' . _SQ_DASH_URL_ . 'user/' . $path;
|
530 |
+
}
|
531 |
+
}
|
532 |
+
|
533 |
+
return esc_url($url);
|
534 |
+
}
|
535 |
+
}
|
controllers/Onboarding.php
CHANGED
@@ -1,95 +1,104 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Controllers_Onboarding extends SQ_Classes_FrontController
|
5 |
-
|
6 |
-
|
7 |
-
public $
|
8 |
-
public $
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
*
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap');
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
31 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Controllers_Onboarding extends SQ_Classes_FrontController
|
5 |
+
{
|
6 |
+
|
7 |
+
public $metas;
|
8 |
+
public $platforms;
|
9 |
+
public $active_plugins;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Call for Onboarding
|
13 |
+
*
|
14 |
+
* @return mixed|void
|
15 |
+
*/
|
16 |
+
public function init()
|
17 |
+
{
|
18 |
+
|
19 |
+
$tab = preg_replace("/[^a-zA-Z0-9]/", "", SQ_Classes_Helpers_Tools::getValue('tab', 'step1'));
|
20 |
+
|
21 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap-reboot');
|
22 |
+
if (is_rtl()) {
|
23 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('popper');
|
24 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap.rtl');
|
25 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('rtl');
|
26 |
+
} else {
|
27 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap');
|
28 |
+
}
|
29 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('switchery');
|
30 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('fontawesome');
|
31 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('global');
|
32 |
+
|
33 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('assistant');
|
34 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('navbar');
|
35 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('onboarding');
|
36 |
+
|
37 |
+
if (method_exists($this, $tab)) {
|
38 |
+
call_user_func(array($this, $tab));
|
39 |
+
}
|
40 |
+
|
41 |
+
//Load the Themes and Plugins
|
42 |
+
add_filter('sq_themes', array(SQ_Classes_ObjController::getClass('SQ_Models_ImportExport'), 'getAvailableThemes'));
|
43 |
+
add_filter('sq_plugins', array(SQ_Classes_ObjController::getClass('SQ_Models_ImportExport'), 'getAvailablePlugins'));
|
44 |
+
$this->platforms = apply_filters('sq_importList', false);
|
45 |
+
|
46 |
+
//@ob_flush();
|
47 |
+
$this->show_view('Onboarding/' . esc_attr(ucfirst($tab)));
|
48 |
+
}
|
49 |
+
|
50 |
+
public function step1()
|
51 |
+
{
|
52 |
+
//Set the onboarding version
|
53 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_onboarding', SQ_VERSION);
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Check SEO Actions
|
58 |
+
*/
|
59 |
+
public function action()
|
60 |
+
{
|
61 |
+
parent::action();
|
62 |
+
|
63 |
+
switch (SQ_Classes_Helpers_Tools::getValue('action')) {
|
64 |
+
case 'sq_onboading_checksite':
|
65 |
+
/**
|
66 |
+
*
|
67 |
+
*
|
68 |
+
* @var SQ_Models_CheckSeo $seoCheck
|
69 |
+
*/
|
70 |
+
$seoCheck = SQ_Classes_ObjController::getClass('SQ_Models_CheckSeo');
|
71 |
+
$seoCheck->getSourceCode();
|
72 |
+
$this->metas = $seoCheck->checkMetas();
|
73 |
+
|
74 |
+
break;
|
75 |
+
|
76 |
+
case 'sq_onboarding_settings':
|
77 |
+
$sq_onboarding_data = SQ_Classes_Helpers_Tools::getValue('sq_onboarding_data');
|
78 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_onboarding_data', $sq_onboarding_data);
|
79 |
+
|
80 |
+
if (isset($sq_onboarding_data['seo_level'])) {
|
81 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_seoexpert', ($sq_onboarding_data['seo_level'] == 'expert'));
|
82 |
+
}
|
83 |
+
if (isset($sq_onboarding_data['website_type'])) {
|
84 |
+
if ($sq_onboarding_data['website_type'] == 'local') {
|
85 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_auto_jsonld_local', 1);
|
86 |
+
}
|
87 |
+
if ($sq_onboarding_data['website_type'] == 'portofolio') {
|
88 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_attachment_redirect', 0);
|
89 |
+
}else{
|
90 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_attachment_redirect', 1);
|
91 |
+
}
|
92 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_jsonld_type', ($sq_onboarding_data['website_type'] == 'personal' ? 'Person' : 'Organization'));
|
93 |
+
}
|
94 |
+
|
95 |
+
break;
|
96 |
+
case 'sq_onboarding_commitment':
|
97 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_seojourney', date('Y-m-d'));
|
98 |
+
|
99 |
+
break;
|
100 |
+
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
controllers/Overview.php
CHANGED
@@ -1,101 +1,109 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Overview
|
6 |
-
*/
|
7 |
-
class SQ_Controllers_Overview extends SQ_Classes_FrontController
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
36 |
-
|
37 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
if
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Overview
|
6 |
+
*/
|
7 |
+
class SQ_Controllers_Overview extends SQ_Classes_FrontController
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
*
|
11 |
+
*
|
12 |
+
* @var object Checkin process with Squirrly Cloud
|
13 |
+
*/
|
14 |
+
public $checkin;
|
15 |
+
|
16 |
+
public function init()
|
17 |
+
{
|
18 |
+
|
19 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_api') == '') {
|
20 |
+
$this->show_view('Errors/Connect');
|
21 |
+
return;
|
22 |
+
}
|
23 |
+
|
24 |
+
//Checkin to API V2
|
25 |
+
$this->checkin = SQ_Classes_RemoteController::checkin();
|
26 |
+
|
27 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap-reboot');
|
28 |
+
if (is_rtl()) {
|
29 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('popper');
|
30 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap.rtl');
|
31 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('rtl');
|
32 |
+
} else {
|
33 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap');
|
34 |
+
}
|
35 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('fontawesome');
|
36 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('switchery');
|
37 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('global');
|
38 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('research');
|
39 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('navbar');
|
40 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('dashboard');
|
41 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('account');
|
42 |
+
|
43 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('assistant');
|
44 |
+
|
45 |
+
add_action('sq_form_notices', array($this, 'getNotificationBar'));
|
46 |
+
add_action('sq_form_notices', array($this, 'getNotificationCompatibility'));
|
47 |
+
|
48 |
+
parent::init();
|
49 |
+
|
50 |
+
}
|
51 |
+
|
52 |
+
public function getJourneyNotification()
|
53 |
+
{
|
54 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippets')) {
|
55 |
+
return;
|
56 |
+
}
|
57 |
+
|
58 |
+
//Get the user name
|
59 |
+
$username = '';
|
60 |
+
if(get_current_user_id()) {
|
61 |
+
$user_info = get_userdata(get_current_user_id());
|
62 |
+
if(!$username = $user_info->first_name) {
|
63 |
+
$username = $user_info->user_login;
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
if (!SQ_Classes_Helpers_Tools::getOption('sq_seojourney') && SQ_Classes_Helpers_Tools::getOption('sq_alert_journey')) {
|
68 |
+
if ((time() - strtotime(SQ_Classes_Helpers_Tools::getOption('sq_installed'))) / (3600 * 24) > 4) { ?>
|
69 |
+
<div class="alert alert-warning text-center m-0 mt-2 p-2">
|
70 |
+
<form method="post" class="p-0 m-0">
|
71 |
+
<?php SQ_Classes_Helpers_Tools::setNonce('sq_alerts_close', 'sq_nonce'); ?>
|
72 |
+
<input type="hidden" name="action" value="sq_alerts_close"/>
|
73 |
+
<input type="hidden" name="alert" value="sq_alert_journey"/>
|
74 |
+
<button type="submit" class="btn float-right bg-transparent p-0 m-0">x</button>
|
75 |
+
</form>
|
76 |
+
<?php echo sprintf(esc_html__("%s, why don't you start a two weeks journey for better rankings? %sStart driving your most valuable pages to Better Rankings today with your current plan.%s", 'squirrly-seo'), '<strong>' . esc_attr($username) . '</strong>', '<br /><a href="' . SQ_Classes_Helpers_Tools::getAdminUrl('sq_onboarding', 'journey1') . '" style="font-weight: bold;" >', '</a>'); ?>
|
77 |
+
</div>
|
78 |
+
<?php
|
79 |
+
}
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
public function getNotificationCompatibility()
|
85 |
+
{
|
86 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_alert_overview') && SQ_Classes_Helpers_Tools::getOption('sq_api')) {
|
87 |
+
add_filter('sq_plugins', array(SQ_Classes_ObjController::getClass('SQ_Models_ImportExport'), 'getActivePlugins'));
|
88 |
+
$platforms = apply_filters('sq_importList', false);
|
89 |
+
if ($platforms && count((array)$platforms) > 0) {
|
90 |
+
foreach ($platforms as $platform => $data) {
|
91 |
+
$plugin = SQ_Classes_ObjController::getClass('SQ_Models_ImportExport')->getName($platform);
|
92 |
+
?>
|
93 |
+
<div class="sq_offer alert alert-warning text-center m-0 mt-2 p-2">
|
94 |
+
<form method="post" class="p-0 m-0">
|
95 |
+
<?php SQ_Classes_Helpers_Tools::setNonce('sq_alerts_close', 'sq_nonce'); ?>
|
96 |
+
<input type="hidden" name="action" value="sq_alerts_close"/>
|
97 |
+
<input type="hidden" name="alert" value="sq_alert_overview"/>
|
98 |
+
<button type="submit" class="btn float-right bg-transparent p-0 m-0">x</button>
|
99 |
+
</form>
|
100 |
+
<?php echo sprintf(esc_html__("Detected %s: We encourage you to %sImport the Settings and SEO%s from %s and deactivate %s to increase the page loading speed for better Google ranking.", 'squirrly-seo'), '<strong>' . esc_attr($plugin) . '</strong>', '<a href="' . SQ_Classes_Helpers_Tools::getAdminUrl('sq_seosettings', 'backup') . '" style="font-weight: bold;" >', '</a>', esc_attr($plugin), esc_attr($plugin)); ?>
|
101 |
+
</div>
|
102 |
+
<?php
|
103 |
+
break;
|
104 |
+
}
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
}
|
controllers/Patterns.php
CHANGED
@@ -1,158 +1,168 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Controllers_Patterns extends SQ_Classes_FrontController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
if ($
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
}
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Controllers_Patterns extends SQ_Classes_FrontController
|
5 |
+
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
*
|
9 |
+
*
|
10 |
+
* @var SQ_Models_Domain_Patterns $patterns
|
11 |
+
*/
|
12 |
+
public $patterns;
|
13 |
+
|
14 |
+
public function init()
|
15 |
+
{
|
16 |
+
if (is_rtl()) {
|
17 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('sqbootstrap.rtl', array('trigger' => true, 'media' => 'all'));
|
18 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('rtl', array('trigger' => true, 'media' => 'all'));
|
19 |
+
} else {
|
20 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('sqbootstrap', array('trigger' => true, 'media' => 'all'));
|
21 |
+
}
|
22 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('patterns', array('trigger' => true, 'media' => 'all'));
|
23 |
+
|
24 |
+
echo '
|
25 |
+
<script>
|
26 |
+
jQuery.sq_patterns_list = jQuery.parseJSON("' . addslashes(SQ_ALL_PATTERNS) . '");
|
27 |
+
var __sq_save_message = "' . esc_html__("Saved!", 'squirrly-seo') . '";
|
28 |
+
var __sq_save_message_preview = "' . esc_html__("Saved! This is how the preview looks like", 'squirrly-seo') . '";
|
29 |
+
</script>';
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Replace the patterns by each tags
|
34 |
+
*
|
35 |
+
* @param SQ_Models_Domain_Post $post
|
36 |
+
* @return SQ_Models_Domain_Post | false
|
37 |
+
*/
|
38 |
+
public function replacePatterns($post)
|
39 |
+
{
|
40 |
+
if ($post instanceof SQ_Models_Domain_Post) {
|
41 |
+
//set the patterns based on the current post
|
42 |
+
$this->patterns = SQ_Classes_ObjController::getDomain('SQ_Models_Domain_Patterns', $post->toArray());
|
43 |
+
|
44 |
+
//set the current post for excerpt and description
|
45 |
+
$this->patterns->currentpost = $post;
|
46 |
+
|
47 |
+
//Foreach SQ, if has patterns, replace them
|
48 |
+
if ($sq_array = $post->sq->toArray()) {
|
49 |
+
|
50 |
+
//set the keywords from sq and not from post
|
51 |
+
$this->patterns->keywords = $post->sq->keywords;
|
52 |
+
|
53 |
+
$post->sq = $this->processPatterns($sq_array, $post->sq);
|
54 |
+
}
|
55 |
+
}
|
56 |
+
return $post;
|
57 |
+
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Get all patterns to process and add them in the object
|
62 |
+
*
|
63 |
+
* @param $values
|
64 |
+
* @param $object
|
65 |
+
* @return mixed
|
66 |
+
*/
|
67 |
+
public function processPatterns($values, $object)
|
68 |
+
{
|
69 |
+
|
70 |
+
//Foreach SQ, if has patterns, replace them
|
71 |
+
$sq_with_patterns = array();
|
72 |
+
//Set the Separator from object automation
|
73 |
+
//do not remove it from here
|
74 |
+
$this->patterns->sep = $object->sep;
|
75 |
+
|
76 |
+
if (!empty($values)) {
|
77 |
+
foreach ($values as $name => $value) {
|
78 |
+
if ($name <> '' && !is_array($value) && $value <> '') {
|
79 |
+
|
80 |
+
if (strpos($value, '%%') !== false) { //in case there are still patterns from Yoast
|
81 |
+
$value = preg_replace('/%%([^\%]+)%%/s', '{{$1}}', $value);
|
82 |
+
$object->$name = preg_replace('/%%([^\%]+)%%/s', '{{$1}}', $object->$name);
|
83 |
+
}
|
84 |
+
|
85 |
+
if (strpos($value, '%') !== false) { //in case there are still patterns from Rank Math
|
86 |
+
$value = preg_replace('/%([^\%]+)%/s', '{{$1}}', $value);
|
87 |
+
$object->$name = preg_replace('/%([^\%]+)%/s', '{{$1}}', $object->$name);
|
88 |
+
}
|
89 |
+
|
90 |
+
if(is_string($value) && $value <> '') {
|
91 |
+
if (strpos($value, '{{') !== false && strpos($value, '}}') !== false) {
|
92 |
+
$sq_with_patterns[$name] = $value;
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
96 |
+
}
|
97 |
+
if (!empty($sq_with_patterns)) {
|
98 |
+
foreach ($this->patterns->getPatterns() as $key => $pattern) {
|
99 |
+
foreach ($sq_with_patterns as $name => $value) {
|
100 |
+
if ($name <> '' && is_string($value) && $value <> '' && $pattern <> '') {
|
101 |
+
if (stripos($value, $pattern) !== false) {
|
102 |
+
$object->$name = str_ireplace($pattern, $this->patterns->$key, $object->$name);
|
103 |
+
}
|
104 |
+
}
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
return $object;
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Called when Post action is triggered
|
116 |
+
*
|
117 |
+
* @return void
|
118 |
+
*/
|
119 |
+
public function action()
|
120 |
+
{
|
121 |
+
parent::action();
|
122 |
+
|
123 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
124 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
125 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
126 |
+
echo wp_json_encode($response);
|
127 |
+
exit();
|
128 |
+
}
|
129 |
+
|
130 |
+
switch (SQ_Classes_Helpers_Tools::getValue('action')) {
|
131 |
+
case 'sq_getpatterns':
|
132 |
+
$all_patterns = json_decode(SQ_ALL_PATTERNS, true);
|
133 |
+
$patterns = false;
|
134 |
+
|
135 |
+
$post_id = (int)SQ_Classes_Helpers_Tools::getValue('post_id', 0);
|
136 |
+
$term_id = (int)SQ_Classes_Helpers_Tools::getValue('term_id', 0);
|
137 |
+
$taxonomy = SQ_Classes_Helpers_Tools::getValue('taxonomy', 'category');
|
138 |
+
$post_type = SQ_Classes_Helpers_Tools::getValue('post_type', 'post');
|
139 |
+
|
140 |
+
if ($post = SQ_Classes_ObjController::getDomain('SQ_Models_Snippet')->getCurrentSnippet($post_id, $term_id, $taxonomy, $post_type)) {
|
141 |
+
|
142 |
+
$patterns = SQ_Classes_ObjController::getDomain('SQ_Models_Domain_Patterns', $post->toArray());
|
143 |
+
$patterns = $this->processPatterns(array_keys($all_patterns), $patterns);
|
144 |
+
|
145 |
+
//Set the separator character from post sep
|
146 |
+
$patterns->sep = $post->sq->sep;
|
147 |
+
|
148 |
+
foreach ($all_patterns as $pattern => $title) {
|
149 |
+
$name = preg_replace('/{{([^\}]+)}}/s', '$1', $pattern);
|
150 |
+
$all_patterns[$pattern] = array('value' => $patterns->$name, 'details' => $all_patterns[$pattern]);
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
|
155 |
+
if (SQ_Classes_Helpers_Tools::isAjax()) {
|
156 |
+
//return json with the results
|
157 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
158 |
+
|
159 |
+
echo wp_json_encode(array('json' => wp_json_encode($all_patterns)));
|
160 |
+
exit();
|
161 |
+
}
|
162 |
+
break;
|
163 |
+
|
164 |
+
}
|
165 |
+
}
|
166 |
+
|
167 |
+
|
168 |
+
}
|
controllers/Post.php
CHANGED
@@ -1,635 +1,658 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Controllers_Post extends SQ_Classes_FrontController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
//
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
//
|
39 |
-
|
40 |
-
|
41 |
-
//Hook the
|
42 |
-
add_action('
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
//
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
if (
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
}
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
//
|
289 |
-
$this
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
$
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
$
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
$
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
}
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
*
|
533 |
-
*
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
}
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Controllers_Post extends SQ_Classes_FrontController
|
5 |
+
{
|
6 |
+
|
7 |
+
public $saved;
|
8 |
+
|
9 |
+
public function init()
|
10 |
+
{
|
11 |
+
parent::init();
|
12 |
+
|
13 |
+
if (is_rtl()) {
|
14 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('rtl');
|
15 |
+
}
|
16 |
+
|
17 |
+
//load the draggable script in post edit for the floating SLA
|
18 |
+
wp_enqueue_script("jquery-ui-core");
|
19 |
+
wp_enqueue_script("jquery-ui-draggable");
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Hook the post save
|
24 |
+
*/
|
25 |
+
public function hookPost()
|
26 |
+
{
|
27 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_api') == '')
|
28 |
+
return;
|
29 |
+
|
30 |
+
//Hook and save the Snippet and Keywords for Attachment Pages
|
31 |
+
add_action('wp_insert_attachment_data', array($this, 'hookAttachmentSave'), 12, 2);
|
32 |
+
|
33 |
+
//if the option to save the images locally is activated
|
34 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_local_images')) {
|
35 |
+
add_filter('wp_insert_post_data', array($this, 'checkImage'), 13, 2);
|
36 |
+
}
|
37 |
+
|
38 |
+
//Remove the SLA highlight from post
|
39 |
+
add_filter('wp_insert_post_data', array($this, 'removeHighlight'), 12, 2);
|
40 |
+
|
41 |
+
//Hook the save post action
|
42 |
+
add_action('save_post', array($this, 'hookSavePost'), 11, 2);
|
43 |
+
|
44 |
+
//Hook the Move To Trash action
|
45 |
+
add_action('wp_trash_post', array(SQ_Classes_ObjController::getClass('SQ_Models_PostsList'), 'hookUpdateStatus'));
|
46 |
+
|
47 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_auto_sitemap')) {
|
48 |
+
add_action('transition_post_status', array(SQ_Classes_ObjController::getClass('SQ_Controllers_Sitemaps'), 'refreshSitemap'), PHP_INT_MAX, 3);
|
49 |
+
}
|
50 |
+
|
51 |
+
//Check the compatibility with Woocommerce
|
52 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_jsonld_product_custom')) {
|
53 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Compatibility')->checkWooCommerce();
|
54 |
+
}
|
55 |
+
|
56 |
+
//add compatibility for backend
|
57 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Compatibility')->hookPostEditorBackend();
|
58 |
+
|
59 |
+
//Make sure the URL is local and not changed by other plugins
|
60 |
+
add_filter('sq_homeurl', array($this, 'getHomeUrl'));
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Get the current Home URL
|
65 |
+
*
|
66 |
+
* @param $url
|
67 |
+
* @return mixed
|
68 |
+
*/
|
69 |
+
public function getHomeUrl($url)
|
70 |
+
{
|
71 |
+
if (defined('WP_HOME')) {
|
72 |
+
return WP_HOME;
|
73 |
+
} else {
|
74 |
+
return get_option('home');
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Initialize the TinyMCE editor for the current use
|
80 |
+
*
|
81 |
+
* @return void
|
82 |
+
*/
|
83 |
+
public function hookEditor()
|
84 |
+
{
|
85 |
+
$this->saved = array();
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Remove the Squirrly Highlights in case there are some left
|
90 |
+
*
|
91 |
+
* @param array $post_data
|
92 |
+
* @param array $postarr
|
93 |
+
* @return array
|
94 |
+
*/
|
95 |
+
public function removeHighlight($post_data, $postarr)
|
96 |
+
{
|
97 |
+
|
98 |
+
if (isset($post_data['post_type']) && $post_data['post_type'] <> '') {
|
99 |
+
//Exclude types for SLA
|
100 |
+
$excludes = SQ_Classes_Helpers_Tools::getOption('sq_sla_exclude_post_types');
|
101 |
+
if (in_array($post_data['post_type'], $excludes)) {
|
102 |
+
return $post_data;
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
if (!isset($post_data['post_content']) || !isset($postarr['ID'])) {
|
107 |
+
return $post_data;
|
108 |
+
}
|
109 |
+
|
110 |
+
if (strpos($post_data['post_content'], '<mark') !== false) {
|
111 |
+
$post_data['post_content'] = preg_replace('/<mark[^>]*(data-markjs|mark_counter)[^>]*>([^<]*)<\/mark>/i', '$2', $post_data['post_content']);
|
112 |
+
}
|
113 |
+
return $post_data;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Check if the image is a remote image and save it locally
|
118 |
+
*
|
119 |
+
* @param array $post_data
|
120 |
+
* @param array $postarr
|
121 |
+
* @return array
|
122 |
+
*/
|
123 |
+
public function checkImage($post_data, $postarr)
|
124 |
+
{
|
125 |
+
|
126 |
+
if (!isset($post_data['post_content']) || !isset($postarr['ID'])) {
|
127 |
+
return $post_data;
|
128 |
+
}
|
129 |
+
|
130 |
+
if (isset($post_data['post_type']) && $post_data['post_type'] <> '') {
|
131 |
+
//Exclude types for SLA
|
132 |
+
$excludes = SQ_Classes_Helpers_Tools::getOption('sq_sla_exclude_post_types');
|
133 |
+
if (in_array($post_data['post_type'], $excludes)) {
|
134 |
+
return $post_data;
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
include_once ABSPATH . 'wp-admin/includes/image.php';
|
139 |
+
|
140 |
+
$urls = array();
|
141 |
+
if (function_exists('preg_match_all')) {
|
142 |
+
@preg_match_all('/<img[^>]*src=[\'"]([^\'"]+)[\'"][^>]*>/i', stripslashes($post_data['post_content']), $out);
|
143 |
+
|
144 |
+
if (!empty($out)) {
|
145 |
+
if (!is_array($out[1]) || count((array)$out[1]) == 0) {
|
146 |
+
return $post_data;
|
147 |
+
}
|
148 |
+
|
149 |
+
if (get_bloginfo('wpurl') <> '') {
|
150 |
+
$domain = parse_url(home_url(), PHP_URL_HOST);
|
151 |
+
|
152 |
+
foreach ($out[1] as $row) {
|
153 |
+
if (strpos($row, '//') !== false && strpos($row, $domain) === false) {
|
154 |
+
if (!in_array($row, $urls)) {
|
155 |
+
$urls[] = $row;
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
+
}
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
if (!is_array($urls) || (is_array($urls) && count((array)$urls) == 0)) {
|
164 |
+
return $post_data;
|
165 |
+
}
|
166 |
+
|
167 |
+
if (count((array)$urls) > 1) {
|
168 |
+
$urls = array_unique($urls);
|
169 |
+
}
|
170 |
+
|
171 |
+
$time = microtime(true);
|
172 |
+
|
173 |
+
//get the already downloaded images
|
174 |
+
$images = get_post_meta((int)$postarr['ID'], '_sq_image_downloaded');
|
175 |
+
|
176 |
+
foreach ($urls as $url) {
|
177 |
+
|
178 |
+
//Set the title and filename
|
179 |
+
$basename = md5(basename($url));
|
180 |
+
$keyword = SQ_Classes_Helpers_Tools::getValue('sq_keyword', false);
|
181 |
+
if ($keyword) {
|
182 |
+
$title = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\[\]\\x80-\\xff ]|i', '', $keyword);
|
183 |
+
$basename = preg_replace('|[^a-z0-9-_]|i', '', str_replace(' ', '-', strtolower($keyword)));
|
184 |
+
}
|
185 |
+
|
186 |
+
//check the images
|
187 |
+
if (!empty($images)) {
|
188 |
+
foreach ($images as $key => $local) {
|
189 |
+
$local = json_decode($local, true);
|
190 |
+
if ($local['url'] == md5($url)) {
|
191 |
+
|
192 |
+
//replace the image in the content
|
193 |
+
$post_data['post_content'] = str_replace($url, $local['file'], $post_data['post_content']);
|
194 |
+
|
195 |
+
continue 2;
|
196 |
+
}
|
197 |
+
}
|
198 |
+
}
|
199 |
+
|
200 |
+
//Upload the image on server
|
201 |
+
if ($file = $this->model->upload_image($url, $basename)) {
|
202 |
+
if (!file_is_valid_image($file['file']))
|
203 |
+
continue;
|
204 |
+
|
205 |
+
$local_file = $file['url'];
|
206 |
+
if ($local_file !== false) {
|
207 |
+
|
208 |
+
//save as downloaded image to avoid duplicates
|
209 |
+
add_post_meta((int)$postarr['ID'], '_sq_image_downloaded', wp_json_encode(array('url' => md5($url), 'file' => $local_file)));
|
210 |
+
|
211 |
+
//replace the image in the content
|
212 |
+
$post_data['post_content'] = str_replace($url, $local_file, $post_data['post_content']);
|
213 |
+
|
214 |
+
//add the attachment image
|
215 |
+
$attach_id = wp_insert_attachment(
|
216 |
+
array(
|
217 |
+
'post_mime_type' => $file['type'],
|
218 |
+
'post_title' => $title,
|
219 |
+
'post_content' => '',
|
220 |
+
'post_status' => 'inherit',
|
221 |
+
'guid' => $local_file
|
222 |
+
), $file['file'], $postarr['ID']
|
223 |
+
);
|
224 |
+
|
225 |
+
$attach_data = wp_generate_attachment_metadata($attach_id, $file['file']);
|
226 |
+
wp_update_attachment_metadata($attach_id, $attach_data);
|
227 |
+
|
228 |
+
}
|
229 |
+
}
|
230 |
+
|
231 |
+
if (microtime(true) - $time >= 10) {
|
232 |
+
break;
|
233 |
+
}
|
234 |
+
|
235 |
+
}
|
236 |
+
|
237 |
+
return $post_data;
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Hook the Attachment save data
|
242 |
+
* Don't use it for post save
|
243 |
+
*
|
244 |
+
* @param array $post_data
|
245 |
+
* @param array $postarr
|
246 |
+
* @return array
|
247 |
+
*/
|
248 |
+
public function hookAttachmentSave($post_data, $postarr)
|
249 |
+
{
|
250 |
+
|
251 |
+
if (isset($postarr['ID']) && $post = get_post($postarr['ID'])) {
|
252 |
+
//If the post is a new or edited post
|
253 |
+
if (wp_is_post_autosave($post->ID) == ''
|
254 |
+
&& get_post_status($post->ID) <> 'auto-draft'
|
255 |
+
&& get_post_status($post->ID) <> 'inherit'
|
256 |
+
) {
|
257 |
+
|
258 |
+
if ($post_data['post_type'] == 'attachment') {
|
259 |
+
//Save the SEO
|
260 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Snippet')->saveSEO($post->ID);
|
261 |
+
|
262 |
+
//Send the optimization when attachment page
|
263 |
+
$this->sendSeo($post);
|
264 |
+
}
|
265 |
+
}
|
266 |
+
}
|
267 |
+
|
268 |
+
return $post_data;
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Hook after save post to make sure the data is saved
|
273 |
+
*
|
274 |
+
* @param $post_id
|
275 |
+
*/
|
276 |
+
public function hookSavePost($post_id)
|
277 |
+
{
|
278 |
+
|
279 |
+
if ($post_id && $post = get_post($post_id)) {
|
280 |
+
//If the post is a new or edited post
|
281 |
+
if (wp_is_post_autosave($post->ID) == ''
|
282 |
+
&& get_post_status($post->ID) <> 'auto-draft'
|
283 |
+
&& get_post_status($post->ID) <> 'inherit'
|
284 |
+
) {
|
285 |
+
|
286 |
+
//Update the SEO Keywords from Live Assistant and Permalink
|
287 |
+
add_filter('sq_seo_before_save', array($this, 'addSeoKeywords'), 11, 1);
|
288 |
+
//Update the redirect to old slugs
|
289 |
+
add_filter('sq_url_before_save', array($this, 'checkOldSlugs'), 11, 2);
|
290 |
+
|
291 |
+
//Save the SEO
|
292 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Snippet')->saveSEO($post->ID);
|
293 |
+
|
294 |
+
//Exclude types for SLA
|
295 |
+
if (isset($post->post_type) && $post->post_type <> '') {
|
296 |
+
$excludes = SQ_Classes_Helpers_Tools::getOption('sq_sla_exclude_post_types');
|
297 |
+
if (in_array($post->post_type, $excludes)) {
|
298 |
+
return;
|
299 |
+
}
|
300 |
+
}
|
301 |
+
|
302 |
+
//Send the optimization when attachment page
|
303 |
+
$this->sendSeo($post);
|
304 |
+
}
|
305 |
+
}
|
306 |
+
|
307 |
+
}
|
308 |
+
|
309 |
+
/**
|
310 |
+
* Send the Post to Squirrly API
|
311 |
+
*
|
312 |
+
* @param $post
|
313 |
+
*/
|
314 |
+
public function sendSeo($post)
|
315 |
+
{
|
316 |
+
$args = array();
|
317 |
+
|
318 |
+
$seo = SQ_Classes_Helpers_Tools::getValue('sq_seo', '');
|
319 |
+
|
320 |
+
if (is_array($seo) && count((array)$seo) > 0) {
|
321 |
+
$args['seo'] = implode(',', $seo);
|
322 |
+
}
|
323 |
+
|
324 |
+
$args['keyword'] = SQ_Classes_Helpers_Tools::getValue('sq_keyword', '');
|
325 |
+
$args['status'] = $post->post_status;
|
326 |
+
$args['permalink'] = get_permalink($post->ID);
|
327 |
+
$args['author'] = $post->post_author;
|
328 |
+
$args['post_id'] = $post->ID;
|
329 |
+
$args['referer'] = 'edit';
|
330 |
+
|
331 |
+
if ($args['permalink']) {
|
332 |
+
SQ_Classes_RemoteController::savePost($args);
|
333 |
+
}
|
334 |
+
|
335 |
+
}
|
336 |
+
|
337 |
+
/**
|
338 |
+
* Called when Post action is triggered
|
339 |
+
*
|
340 |
+
* @return void
|
341 |
+
*/
|
342 |
+
public function action()
|
343 |
+
{
|
344 |
+
parent::action();
|
345 |
+
switch (SQ_Classes_Helpers_Tools::getValue('action')) {
|
346 |
+
case 'sq_create_demo':
|
347 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
348 |
+
SQ_Classes_Error::setError(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
349 |
+
break;
|
350 |
+
}
|
351 |
+
|
352 |
+
$post_type = 'post';
|
353 |
+
if (post_type_exists($post_type)) {
|
354 |
+
$wp_filesystem = SQ_Classes_Helpers_Tools::initFilesystem();
|
355 |
+
|
356 |
+
if ($wp_filesystem->exists(_SQ_ROOT_DIR_ . 'demo.json')) {
|
357 |
+
$json = json_decode($wp_filesystem->get_contents(_SQ_ROOT_DIR_ . 'demo.json'));
|
358 |
+
|
359 |
+
if (isset($json->demo->title) && isset($json->demo->content)) {
|
360 |
+
$args = array();
|
361 |
+
$args['s'] = '"' . addslashes($json->demo->title) . '"';
|
362 |
+
$args['post_type'] = $post_type;
|
363 |
+
//if the post doesn't exists already or is changed
|
364 |
+
if (!$posts = SQ_Classes_ObjController::getClass('SQ_Models_Post')->searchPost($args)) {
|
365 |
+
|
366 |
+
// Create post object
|
367 |
+
$post = array(
|
368 |
+
'post_title' => $json->demo->title,
|
369 |
+
'post_content' => $json->demo->content,
|
370 |
+
'post_status' => 'draft',
|
371 |
+
'comment_status' => 'closed',
|
372 |
+
'ping_status' => 'closed',
|
373 |
+
'post_type' => $post_type,
|
374 |
+
'post_author' => get_current_user_id(),
|
375 |
+
'post_category' => array()
|
376 |
+
);
|
377 |
+
|
378 |
+
if ($post_id = wp_insert_post($post)) {
|
379 |
+
if (!is_wp_error($post_id)) {
|
380 |
+
wp_redirect(admin_url("post.php?post=" . $post_id . "&action=edit&post_type=" . $post_type . "&keyword=" . SQ_Classes_Helpers_Sanitize::escapeKeyword($json->demo->keyword, 'url')));
|
381 |
+
exit();
|
382 |
+
|
383 |
+
}
|
384 |
+
}
|
385 |
+
} else {
|
386 |
+
foreach ($posts as $post) {
|
387 |
+
wp_redirect(admin_url("post.php?post=" . $post->ID . "&action=edit&post_type=" . $post_type . "&keyword=" . SQ_Classes_Helpers_Sanitize::escapeKeyword($json->demo->keyword, 'url')));
|
388 |
+
exit();
|
389 |
+
}
|
390 |
+
}
|
391 |
+
|
392 |
+
}
|
393 |
+
}
|
394 |
+
}
|
395 |
+
SQ_Classes_Error::setError(esc_html__("Could not add the demo post.", 'squirrly-seo'));
|
396 |
+
break;
|
397 |
+
|
398 |
+
/** AJAX CALLS ***/
|
399 |
+
case 'sq_ajax_save_ogimage':
|
400 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
401 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
402 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
403 |
+
echo wp_json_encode($response);
|
404 |
+
exit();
|
405 |
+
}
|
406 |
+
|
407 |
+
if (!empty($_FILES['ogimage'])) {
|
408 |
+
$return = $this->model->addImage($_FILES['ogimage']);
|
409 |
+
}
|
410 |
+
if (isset($return['file'])) {
|
411 |
+
$return['filename'] = basename($return['file']);
|
412 |
+
$local_file = str_replace($return['filename'], urlencode($return['filename']), $return['url']);
|
413 |
+
$attach_id = wp_insert_attachment(
|
414 |
+
array(
|
415 |
+
'post_mime_type' => $return['type'],
|
416 |
+
'post_title' => preg_replace('/\.[^.]+$/', '', $return['filename']),
|
417 |
+
'post_content' => '',
|
418 |
+
'post_status' => 'inherit',
|
419 |
+
'guid' => $local_file
|
420 |
+
), $return['file'], SQ_Classes_Helpers_Tools::getValue('post_id')
|
421 |
+
);
|
422 |
+
|
423 |
+
$attach_data = wp_generate_attachment_metadata($attach_id, $return['file']);
|
424 |
+
wp_update_attachment_metadata($attach_id, $attach_data);
|
425 |
+
}
|
426 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
427 |
+
|
428 |
+
echo wp_json_encode($return);
|
429 |
+
exit();
|
430 |
+
case 'sq_ajax_save_post':
|
431 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
432 |
+
|
433 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
434 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
435 |
+
echo wp_json_encode($response);
|
436 |
+
exit();
|
437 |
+
}
|
438 |
+
|
439 |
+
$post_id = (int)SQ_Classes_Helpers_Tools::getValue('post_id');
|
440 |
+
$referer = SQ_Classes_Helpers_Tools::getValue('referer', false);
|
441 |
+
|
442 |
+
if ($post = SQ_Classes_ObjController::getClass('SQ_Models_Snippet')->getCurrentSnippet($post_id)) {
|
443 |
+
|
444 |
+
if (wp_is_post_autosave($post->ID) == ''
|
445 |
+
&& get_post_status($post->ID) <> 'auto-draft'
|
446 |
+
&& get_post_status($post->ID) <> 'inherit'
|
447 |
+
) {
|
448 |
+
|
449 |
+
//Send the post optimization to Squirrly API
|
450 |
+
$this->sendSeo($post);
|
451 |
+
|
452 |
+
//save the reference for this post ID
|
453 |
+
if ($referer) update_post_meta($post_id, '_sq_sla', $referer);
|
454 |
+
}
|
455 |
+
|
456 |
+
$response['data'] = array('data' => esc_html__("Saved", 'squirrly-seo'));
|
457 |
+
echo wp_json_encode($response);
|
458 |
+
} else {
|
459 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("Can't get the post URL", 'squirrly-seo'), 'sq_error');
|
460 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
461 |
+
echo wp_json_encode($response);
|
462 |
+
}
|
463 |
+
|
464 |
+
exit();
|
465 |
+
case 'sq_ajax_get_post':
|
466 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
467 |
+
|
468 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
469 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
470 |
+
echo wp_json_encode($response);
|
471 |
+
exit();
|
472 |
+
}
|
473 |
+
|
474 |
+
$post_id = (int)SQ_Classes_Helpers_Tools::getValue('post_id');
|
475 |
+
|
476 |
+
if ($post_id > 0) {
|
477 |
+
if ($post = SQ_Classes_ObjController::getClass('SQ_Models_Snippet')->getCurrentSnippet($post_id)) {
|
478 |
+
if ($post->post_status <> 'publish') {
|
479 |
+
$post->url = sanitize_title($post->post_title);
|
480 |
+
}
|
481 |
+
echo wp_json_encode($post->toArray());
|
482 |
+
} else {
|
483 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("Can't get the post URL", 'squirrly-seo'), 'sq_error');
|
484 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
485 |
+
echo wp_json_encode($response);
|
486 |
+
}
|
487 |
+
} else {
|
488 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("Invalid request", 'squirrly-seo'), 'sq_error');
|
489 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
490 |
+
echo wp_json_encode($response);
|
491 |
+
}
|
492 |
+
exit();
|
493 |
+
case 'sq_ajax_type_click':
|
494 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_img_licence', SQ_Classes_Helpers_Tools::getValue('licence'));
|
495 |
+
exit();
|
496 |
+
case 'sq_ajax_search_blog':
|
497 |
+
$args = array();
|
498 |
+
$args['post_type'] = 'post';
|
499 |
+
$args['post_status'] = 'publish';
|
500 |
+
|
501 |
+
if (SQ_Classes_Helpers_Tools::getValue('exclude') && SQ_Classes_Helpers_Tools::getValue('exclude') <> 'undefined') {
|
502 |
+
$args['post__not_in'] = array((int)SQ_Classes_Helpers_Tools::getValue('exclude'));
|
503 |
+
}
|
504 |
+
if (SQ_Classes_Helpers_Tools::getValue('start'))
|
505 |
+
$args['start'] = array((int)SQ_Classes_Helpers_Tools::getValue('start'));
|
506 |
+
|
507 |
+
if (SQ_Classes_Helpers_Tools::getValue('nrb'))
|
508 |
+
$args['posts_per_page'] = (int)SQ_Classes_Helpers_Tools::getValue('nrb');
|
509 |
+
|
510 |
+
if (SQ_Classes_Helpers_Tools::getValue('q') <> '')
|
511 |
+
$args['s'] = SQ_Classes_Helpers_Tools::getValue('q');
|
512 |
+
|
513 |
+
$responce = array();
|
514 |
+
if ($posts = SQ_Classes_ObjController::getClass('SQ_Models_Post')->searchPost($args)) {
|
515 |
+
foreach ($posts as $post) {
|
516 |
+
$responce['results'][] = array('id' => $post->ID,
|
517 |
+
'url' => get_permalink($post->ID),
|
518 |
+
'title' => $post->post_title,
|
519 |
+
'content' => SQ_Classes_Helpers_Sanitize::truncate($post->post_content, 50),
|
520 |
+
'date' => $post->post_date_gmt);
|
521 |
+
}
|
522 |
+
}
|
523 |
+
|
524 |
+
echo wp_json_encode($responce);
|
525 |
+
exit();
|
526 |
+
}
|
527 |
+
}
|
528 |
+
|
529 |
+
/**
|
530 |
+
* Save the keywords from briefcase into the meta keywords if there are no keywords saved
|
531 |
+
*
|
532 |
+
* @param SQ_Models_Domain_Sq $sq
|
533 |
+
* @return SQ_Models_Domain_Sq
|
534 |
+
*/
|
535 |
+
public function addSeoKeywords($sq)
|
536 |
+
{
|
537 |
+
if (empty($sq->keywords)) {
|
538 |
+
$keywords = (array)SQ_Classes_Helpers_Tools::getValue('sq_briefcase_keyword', array());
|
539 |
+
|
540 |
+
if (SQ_Classes_Helpers_Tools::getValue('sq_keyword', false)) {
|
541 |
+
array_unshift($keywords, SQ_Classes_Helpers_Tools::getValue('sq_keyword'));
|
542 |
+
}
|
543 |
+
|
544 |
+
$keywords = array_filter($keywords);
|
545 |
+
$keywords = array_unique($keywords);
|
546 |
+
$sq->keywords = join(',', $keywords);
|
547 |
+
}
|
548 |
+
|
549 |
+
return $sq;
|
550 |
+
}
|
551 |
+
|
552 |
+
/**
|
553 |
+
* Rewrite the function for pages and other post types
|
554 |
+
*
|
555 |
+
* @param string $url
|
556 |
+
* @param string $sq_hash
|
557 |
+
* @return string
|
558 |
+
*/
|
559 |
+
public function checkOldSlugs($url, $sq_hash)
|
560 |
+
{
|
561 |
+
|
562 |
+
// Don't bother if it hasn't changed.
|
563 |
+
$post = SQ_Classes_ObjController::getClass('SQ_Models_Qss')->getSqPost($sq_hash);
|
564 |
+
$patterns = (array)SQ_Classes_Helpers_Tools::getOption('patterns');
|
565 |
+
|
566 |
+
if (!isset($post->ID)) {
|
567 |
+
return $url;
|
568 |
+
}
|
569 |
+
|
570 |
+
if (!empty($patterns) && $permalink = get_permalink($post->ID)) {
|
571 |
+
if ($post->ID > 0 && get_post_status($post->ID) === 'publish' && $permalink <> $post->url) {
|
572 |
+
|
573 |
+
//Get the Squirrly SEO Patterns
|
574 |
+
foreach ($patterns as $pattern => $type) {
|
575 |
+
if (get_post_type($post->ID) == $pattern) {
|
576 |
+
if (isset($type['do_redirects']) && $type['do_redirects']) {
|
577 |
+
|
578 |
+
//do_redirects
|
579 |
+
$post_name = basename($post->url);
|
580 |
+
$old_slugs = (array)get_post_meta($post->ID, '_sq_old_slug');
|
581 |
+
|
582 |
+
// If we haven't added this old slug before, add it now.
|
583 |
+
if (!empty($post_name) && !in_array($post_name, $old_slugs)) {
|
584 |
+
add_post_meta($post->ID, '_sq_old_slug', $post_name);
|
585 |
+
}
|
586 |
+
|
587 |
+
// If the new slug was used previously, delete it from the list.
|
588 |
+
if (in_array($post->post_name, $old_slugs)) {
|
589 |
+
delete_post_meta($post->ID, '_sq_old_slug', $post->post_name);
|
590 |
+
}
|
591 |
+
|
592 |
+
}
|
593 |
+
}
|
594 |
+
}
|
595 |
+
|
596 |
+
}
|
597 |
+
}
|
598 |
+
|
599 |
+
return get_permalink($post->ID);
|
600 |
+
}
|
601 |
+
|
602 |
+
/**
|
603 |
+
* Load Squirrly Assistant in frontend
|
604 |
+
*/
|
605 |
+
public function loadLiveAssistant()
|
606 |
+
{
|
607 |
+
//Load the Frontend Assistant for the current post
|
608 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_sla_frontend')) {
|
609 |
+
|
610 |
+
$elementor = (SQ_Classes_Helpers_Tools::getValue('action', false) == 'elementor');
|
611 |
+
|
612 |
+
if (($elementor && is_admin())) {
|
613 |
+
global $post;
|
614 |
+
|
615 |
+
if (isset($post->ID) && isset($post->post_type)) {
|
616 |
+
$types = get_post_types(array('public' => true));
|
617 |
+
|
618 |
+
//Exclude types for SLA
|
619 |
+
$excludes = SQ_Classes_Helpers_Tools::getOption('sq_sla_exclude_post_types');
|
620 |
+
if (!empty($types) && !empty($excludes)) {
|
621 |
+
foreach ($excludes as $exclude) {
|
622 |
+
if (in_array($exclude, $types)) {
|
623 |
+
unset($types[$exclude]);
|
624 |
+
}
|
625 |
+
}
|
626 |
+
}
|
627 |
+
|
628 |
+
if (in_array($post->post_type, (array)$types)) {
|
629 |
+
//Load the assistant for frontend
|
630 |
+
if (!wp_script_is('jquery')) {
|
631 |
+
wp_enqueue_script('jquery');
|
632 |
+
}
|
633 |
+
|
634 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_RemoteController');
|
635 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_ActionController')->hookHead();
|
636 |
+
|
637 |
+
//Load post style in post edit
|
638 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('post');
|
639 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('fontawesome');
|
640 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('slaseo');
|
641 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('slasearch');
|
642 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('slaresearch');
|
643 |
+
|
644 |
+
//load the draggable script in post edit for the floating SLA
|
645 |
+
wp_enqueue_script("jquery-ui-core");
|
646 |
+
wp_enqueue_script("jquery-ui-draggable");
|
647 |
+
|
648 |
+
$this->show_view('Frontend/Assistant');
|
649 |
+
}
|
650 |
+
|
651 |
+
}
|
652 |
+
}
|
653 |
+
|
654 |
+
}
|
655 |
+
}
|
656 |
+
|
657 |
+
|
658 |
+
}
|
controllers/PostsList.php
CHANGED
@@ -1,307 +1,333 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Controllers_PostsList extends SQ_Classes_FrontController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
*
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
*
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
}
|
132 |
-
|
133 |
-
if ($column == $this->
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
*
|
174 |
-
*
|
175 |
-
* @
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
$
|
186 |
-
}
|
187 |
-
}
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
*
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Controllers_PostsList extends SQ_Classes_FrontController
|
5 |
+
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
*
|
9 |
+
*
|
10 |
+
* @var array Post Type in
|
11 |
+
*/
|
12 |
+
private $_types = array();
|
13 |
+
private $_taxonomies = array();
|
14 |
+
|
15 |
+
/**
|
16 |
+
*
|
17 |
+
*
|
18 |
+
* @var integer Set the column index for Squirrly
|
19 |
+
*/
|
20 |
+
private $_pos = 5;
|
21 |
+
|
22 |
+
/**
|
23 |
+
*
|
24 |
+
*
|
25 |
+
* @var string Set the column name for Squirrly
|
26 |
+
*/
|
27 |
+
private $_slacolumn_id = 'sq_slacolumn';
|
28 |
+
private $_column_id = 'sq_column';
|
29 |
+
|
30 |
+
/**
|
31 |
+
*
|
32 |
+
*
|
33 |
+
* @var array list of the posts to load the optimization for
|
34 |
+
*/
|
35 |
+
public $posts = array();
|
36 |
+
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Create the column and filter for the Posts List
|
40 |
+
*/
|
41 |
+
public function init()
|
42 |
+
{
|
43 |
+
$this->_types = get_post_types(array('public' => true));
|
44 |
+
SQ_Classes_ObjController::getClass('SQ_Models_BulkSeo')->init();
|
45 |
+
|
46 |
+
array_push($this->_types, 'posts');
|
47 |
+
array_push($this->_types, 'pages');
|
48 |
+
array_push($this->_types, 'media');
|
49 |
+
|
50 |
+
//Exclude types for SLA
|
51 |
+
$excludes = SQ_Classes_Helpers_Tools::getOption('sq_sla_exclude_post_types');
|
52 |
+
|
53 |
+
if (!empty($this->_types) && !empty($excludes)) {
|
54 |
+
foreach ($excludes as $exclude) {
|
55 |
+
if ($exclude) {
|
56 |
+
if (false !== $key = array_search($exclude, $this->_types)) {
|
57 |
+
unset($this->_types[$key]);
|
58 |
+
}
|
59 |
+
if (false !== $key = array_search($exclude . 's', $this->_types)) {
|
60 |
+
unset($this->_types[$key]);
|
61 |
+
}
|
62 |
+
}
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
$this->_taxonomies = get_taxonomies(array('public' => true));
|
67 |
+
|
68 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_api') == '') {
|
69 |
+
return;
|
70 |
+
}
|
71 |
+
|
72 |
+
if (!apply_filters('sq_load_snippet', true) || !SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
73 |
+
return;
|
74 |
+
}
|
75 |
+
|
76 |
+
foreach ($this->_types as $type) {
|
77 |
+
add_filter('manage_' . $type . '_columns', array($this, 'add_post_column'), 10, 1);
|
78 |
+
add_action('manage_' . $type . '_custom_column', array($this, 'add_post_row'), 10, 2);
|
79 |
+
}
|
80 |
+
|
81 |
+
foreach ($this->_taxonomies as $taxonomy) {
|
82 |
+
add_filter('manage_edit-' . $taxonomy . '_columns', array($this, 'add_tax_column'), 10, 1);
|
83 |
+
add_action('manage_' . $taxonomy . '_custom_column', array($this, 'add_tax_row'), 10, 3);
|
84 |
+
}
|
85 |
+
|
86 |
+
//Update post status on API
|
87 |
+
add_action('before_delete_post', array($this->model, 'hookUpdateStatus'), 10, 1);
|
88 |
+
add_action('untrashed_post', array($this->model, 'hookUpdateStatus'), 10, 1);
|
89 |
+
add_action('trashed_post', array($this->model, 'hookUpdateStatus'), 10, 1);
|
90 |
+
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Hook the Wordpress header only on postslist header table
|
95 |
+
*/
|
96 |
+
public function loadHead()
|
97 |
+
{
|
98 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('postslist');
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Add the Squirrly column in the Post List
|
103 |
+
*
|
104 |
+
* @param array $columns
|
105 |
+
* @return array
|
106 |
+
*/
|
107 |
+
public function add_post_column($columns)
|
108 |
+
{
|
109 |
+
$this->loadHead(); //load the js only for post list
|
110 |
+
|
111 |
+
//$columns = $this->insert($columns, array($this->_column_id => esc_html__("SQ Snippet", 'squirrly-seo')), $this->_pos);
|
112 |
+
$columns = $this->insert($columns, array($this->_slacolumn_id => esc_html__("Optimized", 'squirrly-seo')), $this->_pos);
|
113 |
+
|
114 |
+
return $columns;
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Add row in Post list
|
119 |
+
*
|
120 |
+
* @param object $column
|
121 |
+
* @param integer $post_id
|
122 |
+
*/
|
123 |
+
public function add_post_row($column, $post_id)
|
124 |
+
{
|
125 |
+
if (!$post_type = get_post_type($post_id)) {
|
126 |
+
$post_type = 'post';
|
127 |
+
}
|
128 |
+
|
129 |
+
if(!SQ_Classes_Helpers_Tools::userCan('edit_post', $post_id)) {
|
130 |
+
return;
|
131 |
+
}
|
132 |
+
|
133 |
+
if ($column == $this->_slacolumn_id) {
|
134 |
+
$html = false;
|
135 |
+
if (SQ_Classes_Helpers_Tools::isAjax()) {
|
136 |
+
$args = array();
|
137 |
+
$args['posts'] = $post_id;
|
138 |
+
|
139 |
+
if ($json = SQ_Classes_RemoteController::getPostOptimization($args)) {
|
140 |
+
if (!is_wp_error($json)) {
|
141 |
+
$posts = $this->model->processPost($json, $post_type);
|
142 |
+
$html = $posts[$post_id];
|
143 |
+
}
|
144 |
+
}
|
145 |
+
} else {
|
146 |
+
if (get_post_status($post_id) == 'publish')
|
147 |
+
array_push($this->posts, $post_id);
|
148 |
+
}
|
149 |
+
|
150 |
+
echo '<div class="' . esc_attr($this->_slacolumn_id) . '_row" ref="' . esc_attr($post_id) . '">' . (($html) ? wp_kses_post($html) : 'loading ...') . '</div>';
|
151 |
+
}
|
152 |
+
|
153 |
+
// if ($column == $this->_column_id) {
|
154 |
+
// echo '<div class="' . (int)$this->_column_id . '_row">' . $this->model->getPostButton($post_id, $post_type) . '</div>';
|
155 |
+
// }
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Add the Squirrly column in the Post List
|
160 |
+
*
|
161 |
+
* @param array $columns
|
162 |
+
* @return array
|
163 |
+
*/
|
164 |
+
public function add_tax_column($columns)
|
165 |
+
{
|
166 |
+
$this->loadHead(); //load the js only for post list
|
167 |
+
|
168 |
+
$columns = $this->insert($columns, array($this->_column_id => esc_html__("SQ Snippet", 'squirrly-seo')), $this->_pos);
|
169 |
+
return $columns;
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Add row in Categories and Tags
|
174 |
+
*
|
175 |
+
* @param string $html
|
176 |
+
* @param object $column
|
177 |
+
* @param integer $post_id
|
178 |
+
*/
|
179 |
+
public function add_tax_row($html = '', $column = 0, $tax_id = 0)
|
180 |
+
{
|
181 |
+
if ((int)$tax_id > 0 && (int)$column > 0) {
|
182 |
+
$term = get_term($tax_id);
|
183 |
+
|
184 |
+
if (!is_wp_error($term) && $column == $this->_column_id) {
|
185 |
+
return '<div class="' . $this->_column_id . '_row">' . $this->model->getTaxButton($term->term_id, 'tax-' . $term->taxonomy) . '</div>';
|
186 |
+
}
|
187 |
+
}
|
188 |
+
|
189 |
+
return $html;
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Push the array to a specific index
|
194 |
+
*
|
195 |
+
* @param array $src
|
196 |
+
* @param array $in
|
197 |
+
* @param integer $pos
|
198 |
+
* @return array
|
199 |
+
*/
|
200 |
+
public function insert($src, $in, $pos)
|
201 |
+
{
|
202 |
+
$array = array();
|
203 |
+
if (is_int($pos))
|
204 |
+
$array = array_merge(array_slice($src, 0, $pos), $in, array_slice($src, $pos));
|
205 |
+
else {
|
206 |
+
foreach ($src as $k => $v) {
|
207 |
+
if ($k == $pos)
|
208 |
+
$array = array_merge($array, $in);
|
209 |
+
$array[$k] = $v;
|
210 |
+
}
|
211 |
+
}
|
212 |
+
return $array;
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Hook Get/Post action
|
217 |
+
*
|
218 |
+
* @return void
|
219 |
+
*/
|
220 |
+
public function action()
|
221 |
+
{
|
222 |
+
switch (SQ_Classes_Helpers_Tools::getValue('action')) {
|
223 |
+
case 'inline-save':
|
224 |
+
|
225 |
+
if (isset($_POST['post_ID']) && ($post_id = (int)$_POST['post_ID']) && isset($_POST['_status']) && $_POST['_status'] == 'publish') {
|
226 |
+
|
227 |
+
// Don't bother if it hasn't changed.
|
228 |
+
$sq_hash = md5($post_id);
|
229 |
+
$post = SQ_Classes_ObjController::getClass('SQ_Models_Qss')->getSqPost($sq_hash);
|
230 |
+
$patterns = (array)SQ_Classes_Helpers_Tools::getOption('patterns');
|
231 |
+
if (!empty($patterns) && $permalink = get_permalink($post->ID)) {
|
232 |
+
|
233 |
+
if ($post->ID > 0 && $permalink <> $post->url) {
|
234 |
+
|
235 |
+
//Get the Squirrly SEO Patterns
|
236 |
+
foreach ($patterns as $pattern => $type) {
|
237 |
+
if (get_post_type($post->ID) == $pattern) {
|
238 |
+
if (isset($type['do_redirects']) && $type['do_redirects']) {
|
239 |
+
|
240 |
+
//do_redirects
|
241 |
+
$post_name = basename($post->url);
|
242 |
+
$old_slugs = (array)get_post_meta($post->ID, '_sq_old_slug');
|
243 |
+
|
244 |
+
// If we haven't added this old slug before, add it now.
|
245 |
+
if (!empty($post_name) && !in_array($post_name, $old_slugs)) {
|
246 |
+
add_post_meta($post->ID, '_sq_old_slug', $post_name);
|
247 |
+
}
|
248 |
+
|
249 |
+
// If the new slug was used previously, delete it from the list.
|
250 |
+
if (in_array($post->post_name, $old_slugs)) {
|
251 |
+
delete_post_meta($post->ID, '_sq_old_slug', $post->post_name);
|
252 |
+
}
|
253 |
+
|
254 |
+
//Update the permalink in QSS
|
255 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Qss')->savePermalink($permalink, $sq_hash);
|
256 |
+
|
257 |
+
}
|
258 |
+
}
|
259 |
+
}
|
260 |
+
|
261 |
+
}
|
262 |
+
}
|
263 |
+
|
264 |
+
}
|
265 |
+
return;
|
266 |
+
}
|
267 |
+
|
268 |
+
parent::action();
|
269 |
+
switch (SQ_Classes_Helpers_Tools::getValue('action')) {
|
270 |
+
case 'sq_ajax_postslist':
|
271 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
272 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
273 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
274 |
+
echo wp_json_encode($response);
|
275 |
+
exit();
|
276 |
+
}
|
277 |
+
|
278 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
279 |
+
$args = array();
|
280 |
+
$posts = SQ_Classes_Helpers_Tools::getValue('posts');
|
281 |
+
if (is_array($posts) && !empty($posts)) {
|
282 |
+
$post_type = SQ_Classes_Helpers_Tools::getValue('post_type', 'post');
|
283 |
+
$args['posts'] = join(',', SQ_Classes_Helpers_Tools::getValue('posts', array()));
|
284 |
+
|
285 |
+
if ($json = SQ_Classes_RemoteController::getPostOptimization($args)) {
|
286 |
+
if (is_wp_error($json)) {
|
287 |
+
$array = array();
|
288 |
+
if ($json->get_error_message() == 'no_data') {
|
289 |
+
foreach ($posts as $post_id) {
|
290 |
+
$array[$post_id] = esc_html__("Network Error. Please Refresh.", 'squirrly-seo');
|
291 |
+
}
|
292 |
+
} elseif ($json->get_error_message() == 'maintenance') {
|
293 |
+
foreach ($posts as $post_id) {
|
294 |
+
$array[$post_id] = sprintf(esc_html__("Maintenance. %sWe'll be back in a minute.", 'squirrly-seo'), '<br />');
|
295 |
+
}
|
296 |
+
}
|
297 |
+
|
298 |
+
echo wp_json_encode(array('posts' => $array));
|
299 |
+
} else {
|
300 |
+
$posts = $this->model->processPost($json, $post_type);
|
301 |
+
echo wp_json_encode(array('posts' => $posts));
|
302 |
+
}
|
303 |
+
|
304 |
+
exit();
|
305 |
+
}
|
306 |
+
}
|
307 |
+
echo wp_json_encode(array('posts' => array()));
|
308 |
+
exit();
|
309 |
+
}
|
310 |
+
}
|
311 |
+
|
312 |
+
/**
|
313 |
+
* Hook the Footer
|
314 |
+
*/
|
315 |
+
public function hookFooter()
|
316 |
+
{
|
317 |
+
$posts = '';
|
318 |
+
foreach ($this->posts as $post) {
|
319 |
+
$posts .= '"' . $post . '",';
|
320 |
+
}
|
321 |
+
|
322 |
+
if (strlen($posts) > 0) $posts = substr($posts, 0, strlen($posts) - 1);
|
323 |
+
|
324 |
+
echo '<script>
|
325 |
+
var __sq_ranknotpublic_text = "' . esc_html__("Not Public", 'squirrly-seo') . '";
|
326 |
+
var __sq_couldnotprocess_text = "' . esc_html__("Could not process", 'squirrly-seo') . '";
|
327 |
+
var __sq_subscriptionexpired_text = "' . esc_html__("The Squirrly subscription has expired!", 'squirrly-seo') . '";
|
328 |
+
var sq_posts = new Array(' . $posts . ');
|
329 |
+
</script>';
|
330 |
+
|
331 |
+
}
|
332 |
+
|
333 |
+
}
|
controllers/Ranking.php
CHANGED
@@ -1,253 +1,263 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Controllers_Ranking extends SQ_Classes_FrontController
|
5 |
-
|
6 |
-
|
7 |
-
public $
|
8 |
-
public $
|
9 |
-
public $
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
}
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
55 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
$this->
|
90 |
-
}
|
91 |
-
}
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Controllers_Ranking extends SQ_Classes_FrontController
|
5 |
+
{
|
6 |
+
|
7 |
+
public $info;
|
8 |
+
public $ranks;
|
9 |
+
public $serps;
|
10 |
+
public $suggested;
|
11 |
+
|
12 |
+
/**
|
13 |
+
*
|
14 |
+
*
|
15 |
+
* @var object Checkin process with Squirrly Cloud
|
16 |
+
*/
|
17 |
+
public $checkin;
|
18 |
+
|
19 |
+
function init()
|
20 |
+
{
|
21 |
+
|
22 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_api') == '') {
|
23 |
+
$this->show_view('Errors/Connect');
|
24 |
+
return;
|
25 |
+
}
|
26 |
+
|
27 |
+
//Checkin to API V2
|
28 |
+
$this->checkin = SQ_Classes_RemoteController::checkin();
|
29 |
+
|
30 |
+
if (is_wp_error($this->checkin)) {
|
31 |
+
if($this->checkin->get_error_message() == 'no_data') {
|
32 |
+
$this->show_view('Errors/Error');
|
33 |
+
return;
|
34 |
+
}elseif($this->checkin->get_error_message() == 'maintenance') {
|
35 |
+
$this->show_view('Errors/Maintenance');
|
36 |
+
return;
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
$tab = preg_replace("/[^a-zA-Z0-9]/", "", SQ_Classes_Helpers_Tools::getValue('tab', 'rankings'));
|
41 |
+
|
42 |
+
if (method_exists($this, $tab)) {
|
43 |
+
call_user_func(array($this, $tab));
|
44 |
+
}
|
45 |
+
|
46 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap-reboot');
|
47 |
+
if(is_rtl()) {
|
48 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('popper');
|
49 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap.rtl');
|
50 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('rtl');
|
51 |
+
}else{
|
52 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap');
|
53 |
+
}
|
54 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('switchery');
|
55 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('fontawesome');
|
56 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('datatables');
|
57 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('global');
|
58 |
+
|
59 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('assistant');
|
60 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('navbar');
|
61 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('rankings');
|
62 |
+
|
63 |
+
//@ob_flush();
|
64 |
+
$this->show_view('Ranking/' . esc_attr(ucfirst($tab)));
|
65 |
+
|
66 |
+
//get the modal window for the assistant popup
|
67 |
+
echo SQ_Classes_ObjController::getClass('SQ_Models_Assistant')->getModal();
|
68 |
+
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Call the rankings
|
73 |
+
*/
|
74 |
+
public function rankings()
|
75 |
+
{
|
76 |
+
add_action('sq_form_notices', array($this,'getNotificationBar'));
|
77 |
+
|
78 |
+
$days_back = (int)SQ_Classes_Helpers_Tools::getValue('days_back', 30);
|
79 |
+
|
80 |
+
$args = array();
|
81 |
+
$args['days_back'] = $days_back;
|
82 |
+
$args['keyword'] = (string)SQ_Classes_Helpers_Tools::getValue('skeyword', '');
|
83 |
+
$args['has_change'] = (string)SQ_Classes_Helpers_Tools::getValue('schanges', '');
|
84 |
+
$args['has_ranks'] = (string)SQ_Classes_Helpers_Tools::getValue('ranked', '');
|
85 |
+
|
86 |
+
|
87 |
+
if ($this->info = SQ_Classes_RemoteController::getRanksStats($args)) {
|
88 |
+
if (is_wp_error($this->info)) {
|
89 |
+
$this->info = array();
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
if ($this->ranks = SQ_Classes_RemoteController::getRanks($args)) {
|
94 |
+
if (is_wp_error($this->ranks)) {
|
95 |
+
SQ_Classes_Error::setError(esc_html__("Could not load the Rankings.", 'squirrly-seo'));
|
96 |
+
$this->ranks = array();
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
public function gscsync()
|
102 |
+
{
|
103 |
+
|
104 |
+
$this->suggested = array();
|
105 |
+
|
106 |
+
if($this->checkin->connection_gsc) {
|
107 |
+
$args = array();
|
108 |
+
$args['max_results'] = '100';
|
109 |
+
$args['max_position'] = '100';
|
110 |
+
if ($this->suggested = SQ_Classes_RemoteController::syncGSC($args)) {
|
111 |
+
if (is_wp_error($this->suggested)) {
|
112 |
+
SQ_Classes_Error::setError(esc_html__("Could not load data.", 'squirrly-seo'));
|
113 |
+
|
114 |
+
}
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
//Get the briefcase keywords
|
119 |
+
if ($briefcase = SQ_Classes_RemoteController::getBriefcase()) {
|
120 |
+
if (!is_wp_error($briefcase)) {
|
121 |
+
if (isset($briefcase->keywords)) {
|
122 |
+
$this->keywords = $briefcase->keywords;
|
123 |
+
}
|
124 |
+
}
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Called when action is triggered
|
130 |
+
*
|
131 |
+
* @return void
|
132 |
+
*/
|
133 |
+
public function action()
|
134 |
+
{
|
135 |
+
parent::action();
|
136 |
+
|
137 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_focuspages')) {
|
138 |
+
return;
|
139 |
+
}
|
140 |
+
|
141 |
+
switch (SQ_Classes_Helpers_Tools::getValue('action')) {
|
142 |
+
|
143 |
+
case 'sq_ranking_settings':
|
144 |
+
//Save the settings
|
145 |
+
if (!empty($_POST)) {
|
146 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Settings')->saveValues($_POST);
|
147 |
+
}
|
148 |
+
|
149 |
+
//Save the settings on API too
|
150 |
+
$args = array();
|
151 |
+
$args['sq_google_country'] = SQ_Classes_Helpers_Tools::getValue('sq_google_country');
|
152 |
+
$args['sq_google_language'] = SQ_Classes_Helpers_Tools::getValue('sq_google_language');
|
153 |
+
$args['sq_google_device'] = SQ_Classes_Helpers_Tools::getValue('sq_google_device');
|
154 |
+
SQ_Classes_RemoteController::saveSettings($args);
|
155 |
+
///////////////////////////////
|
156 |
+
|
157 |
+
//show the saved message
|
158 |
+
SQ_Classes_Error::setMessage(esc_html__("Saved", 'squirrly-seo'));
|
159 |
+
|
160 |
+
break;
|
161 |
+
case 'sq_serp_refresh_post':
|
162 |
+
$keyword = SQ_Classes_Helpers_Tools::getValue('keyword', false);
|
163 |
+
if ($keyword) {
|
164 |
+
$args = array();
|
165 |
+
$args['keyword'] = $keyword;
|
166 |
+
if (SQ_Classes_RemoteController::checkPostRank($args) === false) {
|
167 |
+
SQ_Classes_Error::setError(sprintf(esc_html__("Could not refresh the rank. Please check your SERP credits %shere%s", 'squirrly-seo'), '<a href="' . SQ_Classes_RemoteController::getMySquirrlyLink('account') . '">', '</a>'));
|
168 |
+
} else {
|
169 |
+
SQ_Classes_Error::setMessage(sprintf(esc_html__("%s is queued and the rank will be checked soon.", 'squirrly-seo'), '<strong>' . $keyword . '</strong>'));
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
break;
|
174 |
+
case 'sq_serp_delete_keyword':
|
175 |
+
$keyword = SQ_Classes_Helpers_Tools::getValue('keyword', false);
|
176 |
+
|
177 |
+
if ($keyword) {
|
178 |
+
$response = SQ_Classes_RemoteController::deleteSerpKeyword(array('keyword' => $keyword));
|
179 |
+
if (!is_wp_error($response)) {
|
180 |
+
SQ_Classes_Error::setError(esc_html__("The keyword is deleted.", 'squirrly-seo') . " <br /> ", 'success');
|
181 |
+
} else {
|
182 |
+
SQ_Classes_Error::setError(esc_html__("Could not delete the keyword!", 'squirrly-seo') . " <br /> ");
|
183 |
+
}
|
184 |
+
} else {
|
185 |
+
SQ_Classes_Error::setError(esc_html__("Invalid params!", 'squirrly-seo') . " <br /> ");
|
186 |
+
}
|
187 |
+
break;
|
188 |
+
case 'sq_ajax_rank_bulk_delete':
|
189 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
190 |
+
$inputs = SQ_Classes_Helpers_Tools::getValue('inputs', array());
|
191 |
+
|
192 |
+
if (! empty($inputs) ) {
|
193 |
+
foreach ( $inputs as $keyword ) {
|
194 |
+
if ($keyword <> '' ) {
|
195 |
+
$args = array();
|
196 |
+
$args['keyword'] = $keyword;
|
197 |
+
SQ_Classes_RemoteController::deleteSerpKeyword($args);
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
echo wp_json_encode(array( 'message' => esc_html__("Deleted!", 'squirrly-seo') ));
|
202 |
+
} else {
|
203 |
+
echo wp_json_encode(array( 'error' => esc_html__("Invalid params!", 'squirrly-seo') ));
|
204 |
+
}
|
205 |
+
exit();
|
206 |
+
case 'sq_ajax_rank_bulk_refresh':
|
207 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
208 |
+
$inputs = SQ_Classes_Helpers_Tools::getValue('inputs', array());
|
209 |
+
|
210 |
+
if (! empty($inputs) ) {
|
211 |
+
foreach ( $inputs as $keyword ) {
|
212 |
+
if ($keyword <> '' ) {
|
213 |
+
$args = array();
|
214 |
+
$args['keyword'] = $keyword;
|
215 |
+
SQ_Classes_RemoteController::checkPostRank($args);
|
216 |
+
}
|
217 |
+
|
218 |
+
echo wp_json_encode(array( 'message' => esc_html__("Sent!", 'squirrly-seo') ));
|
219 |
+
}
|
220 |
+
} else {
|
221 |
+
echo wp_json_encode(array( 'error' => esc_html__("Invalid params!", 'squirrly-seo') ));
|
222 |
+
}
|
223 |
+
exit();
|
224 |
+
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
public function loadScripts()
|
229 |
+
{
|
230 |
+
echo '<script type="text/javascript">
|
231 |
+
function drawChart(id, values, reverse) {
|
232 |
+
var data = google.visualization.arrayToDataTable(values);
|
233 |
+
|
234 |
+
var options = {
|
235 |
+
|
236 |
+
curveType: "function",
|
237 |
+
title: "",
|
238 |
+
chartArea:{width:"100%",height:"100%"},
|
239 |
+
enableInteractivity: "true",
|
240 |
+
tooltip: {trigger: "auto"},
|
241 |
+
pointSize: "2",
|
242 |
+
colors: ["#55b2ca"],
|
243 |
+
hAxis: {
|
244 |
+
baselineColor: "transparent",
|
245 |
+
gridlineColor: "transparent",
|
246 |
+
textPosition: "none"
|
247 |
+
} ,
|
248 |
+
vAxis:{
|
249 |
+
direction: ((reverse) ? -1 : 1),
|
250 |
+
baselineColor: "transparent",
|
251 |
+
gridlineColor: "transparent",
|
252 |
+
textPosition: "none"
|
253 |
+
}
|
254 |
+
};
|
255 |
+
|
256 |
+
var chart = new google.visualization.LineChart(document.getElementById(id));
|
257 |
+
chart.draw(data, options);
|
258 |
+
return chart;
|
259 |
+
}
|
260 |
+
</script>';
|
261 |
+
}
|
262 |
+
|
263 |
+
}
|
controllers/Research.php
CHANGED
@@ -1,794 +1,813 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Controllers_Research extends SQ_Classes_FrontController
|
5 |
-
|
6 |
-
|
7 |
-
public $
|
8 |
-
|
9 |
-
|
10 |
-
public $
|
11 |
-
public $
|
12 |
-
public $
|
13 |
-
public $
|
14 |
-
public $
|
15 |
-
|
16 |
-
|
17 |
-
public $
|
18 |
-
public $
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
62 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
63 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
64 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia(
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
$
|
104 |
-
$
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
if (isset($briefcase->
|
114 |
-
$this->
|
115 |
-
}
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
$
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
$
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
}
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
$
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
}
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
}
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
$keyword =
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
echo wp_json_encode(array('done' => true, 'html' => $this->
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
$
|
633 |
-
$
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
if (
|
663 |
-
|
664 |
-
}
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
$
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
exit();
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
exit();
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Controllers_Research extends SQ_Classes_FrontController
|
5 |
+
{
|
6 |
+
|
7 |
+
public $blogs;
|
8 |
+
public $kr;
|
9 |
+
//--
|
10 |
+
public $keywords = array();
|
11 |
+
public $suggested = array();
|
12 |
+
public $rankkeywords = array();
|
13 |
+
public $labels = array();
|
14 |
+
public $countries = array();
|
15 |
+
public $post_id = false;
|
16 |
+
//--
|
17 |
+
public $index;
|
18 |
+
public $error;
|
19 |
+
public $user;
|
20 |
+
|
21 |
+
/**
|
22 |
+
*
|
23 |
+
*
|
24 |
+
* @var object Checkin process with Squirrly Cloud
|
25 |
+
*/
|
26 |
+
public $checkin;
|
27 |
+
|
28 |
+
function init()
|
29 |
+
{
|
30 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_api') == '') {
|
31 |
+
$this->show_view('Errors/Connect');
|
32 |
+
return;
|
33 |
+
}
|
34 |
+
|
35 |
+
//Checkin to API V2
|
36 |
+
$this->checkin = SQ_Classes_RemoteController::checkin();
|
37 |
+
|
38 |
+
if (is_wp_error($this->checkin)) {
|
39 |
+
if ($this->checkin->get_error_message() == 'no_data') {
|
40 |
+
$this->show_view('Errors/Error');
|
41 |
+
return;
|
42 |
+
} elseif ($this->checkin->get_error_message() == 'maintenance') {
|
43 |
+
$this->show_view('Errors/Maintenance');
|
44 |
+
return;
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
$tab = preg_replace("/[^a-zA-Z0-9]/", "", SQ_Classes_Helpers_Tools::getValue('tab', 'research'));
|
49 |
+
|
50 |
+
wp_enqueue_style('wp-color-picker');
|
51 |
+
wp_enqueue_script('wp-color-picker');
|
52 |
+
|
53 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap-reboot');
|
54 |
+
if (is_rtl()) {
|
55 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('popper');
|
56 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap.rtl');
|
57 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('rtl');
|
58 |
+
} else {
|
59 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap');
|
60 |
+
}
|
61 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('switchery');
|
62 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('datatables');
|
63 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('fontawesome');
|
64 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('global');
|
65 |
+
|
66 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('assistant');
|
67 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('navbar');
|
68 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('research');
|
69 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia($tab);
|
70 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('chart');
|
71 |
+
|
72 |
+
if (method_exists($this, $tab)) {
|
73 |
+
call_user_func(array($this, $tab));
|
74 |
+
}
|
75 |
+
|
76 |
+
$this->show_view('Research/' . esc_attr(ucfirst($tab)));
|
77 |
+
|
78 |
+
|
79 |
+
//get the modal window for the assistant popup
|
80 |
+
echo SQ_Classes_ObjController::getClass('SQ_Models_Assistant')->getModal();
|
81 |
+
}
|
82 |
+
|
83 |
+
public function research()
|
84 |
+
{
|
85 |
+
add_action('sq_form_notices', array($this, 'getNotificationBar'));
|
86 |
+
|
87 |
+
$countries = SQ_Classes_RemoteController::getKrCountries();
|
88 |
+
|
89 |
+
if (!is_wp_error($countries)) {
|
90 |
+
$this->countries = $countries;
|
91 |
+
} else {
|
92 |
+
$this->error = $countries->get_error_message();
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
public function briefcase()
|
97 |
+
{
|
98 |
+
add_action('sq_form_notices', array($this, 'getNotificationBar'));
|
99 |
+
|
100 |
+
$search = (string)SQ_Classes_Helpers_Tools::getValue('skeyword', '');
|
101 |
+
$labels = SQ_Classes_Helpers_Tools::getValue('slabel', false);
|
102 |
+
|
103 |
+
$args = array();
|
104 |
+
$args['search'] = $search;
|
105 |
+
if ($labels && !empty($labels)) {
|
106 |
+
$args['label'] = join(',', $labels);
|
107 |
+
}
|
108 |
+
|
109 |
+
$briefcase = SQ_Classes_RemoteController::getBriefcase($args);
|
110 |
+
$this->rankkeywords = SQ_Classes_RemoteController::getRanks();
|
111 |
+
|
112 |
+
if (!is_wp_error($briefcase)) {
|
113 |
+
if (isset($briefcase->keywords) && !empty($briefcase->keywords)) {
|
114 |
+
$this->keywords = $briefcase->keywords;
|
115 |
+
} else {
|
116 |
+
$this->error = sprintf(esc_html__("No keyword found. %s Show all %s keywords from Briefcase.", 'squirrly-seo'), '<a href="' . SQ_Classes_Helpers_Tools::getAdminUrl('sq_research', 'briefcase') . '">', '</a>');
|
117 |
+
}
|
118 |
+
|
119 |
+
if (isset($briefcase->labels)) {
|
120 |
+
$this->labels = $briefcase->labels;
|
121 |
+
}
|
122 |
+
|
123 |
+
}
|
124 |
+
|
125 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('briefcase');
|
126 |
+
|
127 |
+
}
|
128 |
+
|
129 |
+
public function labels()
|
130 |
+
{
|
131 |
+
add_action('sq_form_notices', array($this, 'getNotificationBar'));
|
132 |
+
|
133 |
+
$args = array();
|
134 |
+
if (!empty($labels)) {
|
135 |
+
$args['label'] = join(',', $labels);
|
136 |
+
}
|
137 |
+
|
138 |
+
$briefcase = SQ_Classes_RemoteController::getBriefcase($args);
|
139 |
+
|
140 |
+
if (!is_wp_error($briefcase)) {
|
141 |
+
if (isset($briefcase->labels)) {
|
142 |
+
$this->labels = $briefcase->labels;
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('briefcase');
|
147 |
+
|
148 |
+
}
|
149 |
+
|
150 |
+
public function suggested()
|
151 |
+
{
|
152 |
+
add_action('sq_form_notices', array($this, 'getNotificationBar'));
|
153 |
+
|
154 |
+
//Get the briefcase keywords
|
155 |
+
if ($briefcase = SQ_Classes_RemoteController::getBriefcase()) {
|
156 |
+
if (!is_wp_error($briefcase)) {
|
157 |
+
if (isset($briefcase->keywords)) {
|
158 |
+
$this->keywords = $briefcase->keywords;
|
159 |
+
}
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
$this->suggested = SQ_Classes_RemoteController::getKrFound();
|
164 |
+
|
165 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('briefcase');
|
166 |
+
|
167 |
+
}
|
168 |
+
|
169 |
+
public function history()
|
170 |
+
{
|
171 |
+
|
172 |
+
$args = array();
|
173 |
+
$args['limit'] = 100;
|
174 |
+
$this->kr = SQ_Classes_RemoteController::getKRHistory($args);
|
175 |
+
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Return the text for the stats in details
|
180 |
+
*
|
181 |
+
* @param $key
|
182 |
+
* @param $index
|
183 |
+
* @return string
|
184 |
+
*/
|
185 |
+
public function getReasearchStatsText($key, $index)
|
186 |
+
{
|
187 |
+
$stats = array(
|
188 |
+
'tw' => array(esc_html__("very few", 'squirrly-seo'), esc_html__("few", 'squirrly-seo'), esc_html__("few", 'squirrly-seo'), esc_html__("few", 'squirrly-seo'), esc_html__("few", 'squirrly-seo'), esc_html__("some", 'squirrly-seo'), esc_html__("some", 'squirrly-seo'), esc_html__("some", 'squirrly-seo'), esc_html__("some", 'squirrly-seo'), esc_html__("many", 'squirrly-seo'), esc_html__("many", 'squirrly-seo')),
|
189 |
+
'sc' => array(esc_html__("very low ranking chance", 'squirrly-seo'), esc_html__("very low ranking chance", 'squirrly-seo'), esc_html__("low ranking chance", 'squirrly-seo'), esc_html__("low ranking chance", 'squirrly-seo'), esc_html__("modest ranking chance", 'squirrly-seo'), esc_html__("modest ranking chance", 'squirrly-seo'), esc_html__("decent ranking chance", 'squirrly-seo'), esc_html__("decent ranking chance", 'squirrly-seo'), esc_html__("high ranking chance", 'squirrly-seo'), esc_html__("very high ranking chance", 'squirrly-seo'), esc_html__("very high ranking chance", 'squirrly-seo')),
|
190 |
+
);
|
191 |
+
|
192 |
+
if(isset($stats[$key][$index])) {
|
193 |
+
return $stats[$key][$index];
|
194 |
+
}
|
195 |
+
|
196 |
+
return '';
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Called when action is triggered
|
201 |
+
*
|
202 |
+
* @return void
|
203 |
+
*/
|
204 |
+
public function action()
|
205 |
+
{
|
206 |
+
parent::action();
|
207 |
+
|
208 |
+
switch (SQ_Classes_Helpers_Tools::getValue('action')) {
|
209 |
+
|
210 |
+
case 'sq_briefcase_addkeyword':
|
211 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
212 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
213 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
214 |
+
|
215 |
+
if (SQ_Classes_Helpers_Tools::isAjax()) {
|
216 |
+
echo wp_json_encode($response);
|
217 |
+
exit();
|
218 |
+
} else {
|
219 |
+
SQ_Classes_Error::setError(esc_html__("You do not have permission to perform this action", 'squirrly-seo'));
|
220 |
+
}
|
221 |
+
}
|
222 |
+
|
223 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
224 |
+
$keyword = (string)SQ_Classes_Helpers_Tools::getValue('keyword', '');
|
225 |
+
$do_serp = (int)SQ_Classes_Helpers_Tools::getValue('doserp', 0);
|
226 |
+
$is_hidden = (int)SQ_Classes_Helpers_Tools::getValue('hidden', 0);
|
227 |
+
|
228 |
+
if ($keyword <> '') {
|
229 |
+
//set ignore on API
|
230 |
+
$args = array();
|
231 |
+
$args['keyword'] = $keyword;
|
232 |
+
$args['do_serp'] = $do_serp;
|
233 |
+
$args['is_hidden'] = $is_hidden;
|
234 |
+
SQ_Classes_RemoteController::addBriefcaseKeyword($args);
|
235 |
+
|
236 |
+
if (SQ_Classes_Helpers_Tools::isAjax()) {
|
237 |
+
if ($do_serp) {
|
238 |
+
echo wp_json_encode(array('message' => esc_html__("Keyword Saved. The rank check will be ready in a minute.", 'squirrly-seo')));
|
239 |
+
} else {
|
240 |
+
echo wp_json_encode(array('message' => esc_html__("Keyword Saved!", 'squirrly-seo')));
|
241 |
+
}
|
242 |
+
exit();
|
243 |
+
} else {
|
244 |
+
SQ_Classes_Error::setMessage(esc_html__("Keyword Saved!", 'squirrly-seo'));
|
245 |
+
}
|
246 |
+
} else {
|
247 |
+
if (SQ_Classes_Helpers_Tools::isAjax()) {
|
248 |
+
echo wp_json_encode(array('error' => esc_html__("Invalid params!", 'squirrly-seo')));
|
249 |
+
exit();
|
250 |
+
} else {
|
251 |
+
SQ_Classes_Error::setError(esc_html__("Invalid params!", 'squirrly-seo'));
|
252 |
+
}
|
253 |
+
}
|
254 |
+
break;
|
255 |
+
case 'sq_briefcase_deletekeyword':
|
256 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
257 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
258 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
259 |
+
echo wp_json_encode($response);
|
260 |
+
exit();
|
261 |
+
}
|
262 |
+
|
263 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
264 |
+
$keyword = (string)SQ_Classes_Helpers_Tools::getValue('keyword', '');
|
265 |
+
|
266 |
+
if ($keyword <> '') {
|
267 |
+
//set ignore on API
|
268 |
+
$args = array();
|
269 |
+
$args['keyword'] = stripslashes($keyword);
|
270 |
+
SQ_Classes_RemoteController::removeBriefcaseKeyword($args);
|
271 |
+
|
272 |
+
echo wp_json_encode(array('message' => esc_html__("Deleted!", 'squirrly-seo')));
|
273 |
+
} else {
|
274 |
+
echo wp_json_encode(array('error' => esc_html__("Invalid params!", 'squirrly-seo')));
|
275 |
+
}
|
276 |
+
exit();
|
277 |
+
case 'sq_briefcase_deletefound':
|
278 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
279 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
280 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
281 |
+
echo wp_json_encode($response);
|
282 |
+
exit();
|
283 |
+
}
|
284 |
+
|
285 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
286 |
+
$keyword = (string)SQ_Classes_Helpers_Tools::getValue('keyword', '');
|
287 |
+
|
288 |
+
if ($keyword <> '') {
|
289 |
+
//set ignore on API
|
290 |
+
$args = array();
|
291 |
+
$args['keyword'] = stripslashes($keyword);
|
292 |
+
SQ_Classes_RemoteController::removeKrFound($args);
|
293 |
+
|
294 |
+
echo wp_json_encode(array('message' => esc_html__("Deleted!", 'squirrly-seo')));
|
295 |
+
} else {
|
296 |
+
echo wp_json_encode(array('error' => esc_html__("Invalid params!", 'squirrly-seo')));
|
297 |
+
}
|
298 |
+
exit();
|
299 |
+
/**********************************/
|
300 |
+
case 'sq_briefcase_addlabel':
|
301 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
302 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
303 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
304 |
+
echo wp_json_encode($response);
|
305 |
+
exit();
|
306 |
+
}
|
307 |
+
|
308 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
309 |
+
|
310 |
+
$name = (string)SQ_Classes_Helpers_Tools::getValue('name', '');
|
311 |
+
$color = (string)SQ_Classes_Helpers_Tools::getValue('color', '#ffffff');
|
312 |
+
|
313 |
+
if ($name <> '' && $color <> '') {
|
314 |
+
$args = array();
|
315 |
+
|
316 |
+
$args['name'] = $name;
|
317 |
+
$args['color'] = $color;
|
318 |
+
$json = SQ_Classes_RemoteController::addBriefcaseLabel($args);
|
319 |
+
|
320 |
+
if (!is_wp_error($json)) {
|
321 |
+
echo wp_json_encode(array('saved' => esc_html__("Saved!", 'squirrly-seo')));
|
322 |
+
} else {
|
323 |
+
echo wp_json_encode(array('error' => $json->get_error_message()));
|
324 |
+
}
|
325 |
+
|
326 |
+
} else {
|
327 |
+
echo wp_json_encode(array('error' => esc_html__("Invalid Label or Color!", 'squirrly-seo')));
|
328 |
+
}
|
329 |
+
exit();
|
330 |
+
case 'sq_briefcase_editlabel':
|
331 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
332 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
333 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
334 |
+
echo wp_json_encode($response);
|
335 |
+
exit();
|
336 |
+
}
|
337 |
+
|
338 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
339 |
+
|
340 |
+
$id = (int)SQ_Classes_Helpers_Tools::getValue('id', 0);
|
341 |
+
$name = (string)SQ_Classes_Helpers_Tools::getValue('name', 0);
|
342 |
+
$color = (string)SQ_Classes_Helpers_Tools::getValue('color', '#ffffff');
|
343 |
+
|
344 |
+
if ((int)$id > 0 && $name <> '' && $color <> '') {
|
345 |
+
$args = array();
|
346 |
+
|
347 |
+
$args['id'] = $id;
|
348 |
+
$args['name'] = $name;
|
349 |
+
$args['color'] = $color;
|
350 |
+
SQ_Classes_RemoteController::saveBriefcaseLabel($args);
|
351 |
+
|
352 |
+
echo wp_json_encode(array('saved' => esc_html__("Saved!", 'squirrly-seo')));
|
353 |
+
} else {
|
354 |
+
echo wp_json_encode(array('error' => esc_html__("Invalid params!", 'squirrly-seo')));
|
355 |
+
}
|
356 |
+
exit();
|
357 |
+
case 'sq_briefcase_deletelabel':
|
358 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippets')) {
|
359 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
360 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
361 |
+
echo wp_json_encode($response);
|
362 |
+
exit();
|
363 |
+
}
|
364 |
+
|
365 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
366 |
+
|
367 |
+
$id = (int)SQ_Classes_Helpers_Tools::getValue('id', 0);
|
368 |
+
|
369 |
+
if ($id > 0) {
|
370 |
+
//set ignore on API
|
371 |
+
$args = array();
|
372 |
+
|
373 |
+
$args['id'] = $id;
|
374 |
+
SQ_Classes_RemoteController::removeBriefcaseLabel($args);
|
375 |
+
|
376 |
+
echo wp_json_encode(array('deleted' => esc_html__("Deleted!", 'squirrly-seo')));
|
377 |
+
} else {
|
378 |
+
echo wp_json_encode(array('error' => esc_html__("Invalid params!", 'squirrly-seo')));
|
379 |
+
}
|
380 |
+
exit();
|
381 |
+
case 'sq_briefcase_keywordlabel':
|
382 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
383 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
384 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
385 |
+
echo wp_json_encode($response);
|
386 |
+
exit();
|
387 |
+
}
|
388 |
+
|
389 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
390 |
+
|
391 |
+
$keyword = (string)SQ_Classes_Helpers_Tools::getValue('keyword', '');
|
392 |
+
$labels = SQ_Classes_Helpers_Tools::getValue('labels', array());
|
393 |
+
|
394 |
+
if ($keyword <> '') {
|
395 |
+
$args = array();
|
396 |
+
|
397 |
+
$args['keyword'] = $keyword;
|
398 |
+
$args['labels'] = '';
|
399 |
+
if (is_array($labels) && !empty($labels)) {
|
400 |
+
$args['labels'] = join(',', $labels);
|
401 |
+
SQ_Classes_RemoteController::saveBriefcaseKeywordLabel($args);
|
402 |
+
} else {
|
403 |
+
SQ_Classes_RemoteController::saveBriefcaseKeywordLabel($args);
|
404 |
+
|
405 |
+
}
|
406 |
+
echo wp_json_encode(array('saved' => esc_html__("Saved!", 'squirrly-seo')));
|
407 |
+
} else {
|
408 |
+
echo wp_json_encode(array('error' => esc_html__("Invalid Keyword!", 'squirrly-seo')));
|
409 |
+
}
|
410 |
+
exit();
|
411 |
+
case 'sq_briefcase_backup':
|
412 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
413 |
+
SQ_Classes_Error::setError(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
414 |
+
return;
|
415 |
+
}
|
416 |
+
|
417 |
+
$args = array();
|
418 |
+
$args['limit'] = -1;
|
419 |
+
$briefcase = SQ_Classes_RemoteController::getBriefcase($args);
|
420 |
+
|
421 |
+
if(isset($briefcase->keywords) && !empty($briefcase->keywords)) {
|
422 |
+
$fp = fopen(_SQ_CACHE_DIR_ . 'file.txt', 'w');
|
423 |
+
foreach ($briefcase->keywords as $row) {
|
424 |
+
fwrite($fp, $row->keyword . PHP_EOL);
|
425 |
+
}
|
426 |
+
fclose($fp);
|
427 |
+
|
428 |
+
header("Content-type: text;");
|
429 |
+
header("Content-Encoding: UTF-8");
|
430 |
+
header("Content-Disposition: attachment; filename=squirrly-briefcase-" . gmdate('Y-m-d') . ".txt");
|
431 |
+
header("Pragma: no-cache");
|
432 |
+
header("Expires: 0");
|
433 |
+
readfile(_SQ_CACHE_DIR_ . 'file.txt');
|
434 |
+
}else{
|
435 |
+
SQ_Classes_Error::setError(esc_html__("No keywords in Briefcase to backup", 'squirrly-seo'), 'sq_error');
|
436 |
+
return;
|
437 |
+
}
|
438 |
+
|
439 |
+
exit();
|
440 |
+
case 'sq_briefcase_restore':
|
441 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
442 |
+
SQ_Classes_Error::setError(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
443 |
+
return;
|
444 |
+
}
|
445 |
+
|
446 |
+
if (!empty($_FILES['sq_upload_file']) && $_FILES['sq_upload_file']['tmp_name'] <> '') {
|
447 |
+
$fp = fopen($_FILES['sq_upload_file']['tmp_name'], 'rb');
|
448 |
+
|
449 |
+
try {
|
450 |
+
$data = '';
|
451 |
+
$keywords = array();
|
452 |
+
|
453 |
+
while (($line = fgets($fp)) !== false) {
|
454 |
+
$data .= $line;
|
455 |
+
}
|
456 |
+
|
457 |
+
if ($data = json_decode($data)) {
|
458 |
+
if (is_array($data) and !empty($data)) {
|
459 |
+
foreach ($data as $row) {
|
460 |
+
if (isset($row->keyword)) {
|
461 |
+
$keywords[] = $row->keyword;
|
462 |
+
}
|
463 |
+
}
|
464 |
+
}
|
465 |
+
} else {
|
466 |
+
//Get the data from CSV
|
467 |
+
$fp = fopen($_FILES['sq_upload_file']['tmp_name'], 'rb');
|
468 |
+
|
469 |
+
while (($data = fgetcsv($fp, 1000, ";")) !== false) {
|
470 |
+
if (!isset($data[0]) || $data[0] == '' || strlen($data[0]) > 255 || is_numeric($data[0])) {
|
471 |
+
SQ_Classes_Error::setError(esc_html__("Error! The backup is not valid.", 'squirrly-seo') . " <br /> ");
|
472 |
+
break;
|
473 |
+
}
|
474 |
+
|
475 |
+
if (is_string($data[0]) && $data[0] <> '') {
|
476 |
+
$keywords[] = strip_tags($data[0]);
|
477 |
+
}
|
478 |
+
}
|
479 |
+
|
480 |
+
if (empty($keywords)) {
|
481 |
+
$fp = fopen($_FILES['sq_upload_file']['tmp_name'], 'rb');
|
482 |
+
|
483 |
+
while (($data = fgetcsv($fp, 1000, ",")) !== false) {
|
484 |
+
if (!isset($data[0]) || $data[0] == '' || strlen($data[0]) > 255 || is_numeric($data[0])) {
|
485 |
+
SQ_Classes_Error::setError(esc_html__("Error! The backup is not valid.", 'squirrly-seo') . " <br /> ");
|
486 |
+
break;
|
487 |
+
}
|
488 |
+
|
489 |
+
if (is_string($data[0]) && $data[0] <> '') {
|
490 |
+
$keywords[] = strip_tags($data[0]);
|
491 |
+
}
|
492 |
+
}
|
493 |
+
}
|
494 |
+
|
495 |
+
|
496 |
+
}
|
497 |
+
|
498 |
+
if (!empty($keywords)) {
|
499 |
+
$keywords = array_chunk($keywords, 100);
|
500 |
+
|
501 |
+
foreach ($keywords as $chunk) {
|
502 |
+
SQ_Classes_RemoteController::importBriefcaseKeywords(array('keywords' => json_encode($chunk)));
|
503 |
+
}
|
504 |
+
|
505 |
+
SQ_Classes_Error::setError(esc_html__("Great! The backup is restored.", 'squirrly-seo') . " <br /> ", 'success');
|
506 |
+
} else {
|
507 |
+
SQ_Classes_Error::setError(esc_html__("Error! The backup is not valid.", 'squirrly-seo') . " <br /> ");
|
508 |
+
}
|
509 |
+
} catch (Exception $e) {
|
510 |
+
SQ_Classes_Error::setError(esc_html__("Error! The backup is not valid.", 'squirrly-seo') . " <br /> ");
|
511 |
+
}
|
512 |
+
} else {
|
513 |
+
SQ_Classes_Error::setError(esc_html__("Error! You have to enter a previously saved backup file.", 'squirrly-seo') . " <br /> ");
|
514 |
+
}
|
515 |
+
break;
|
516 |
+
case 'sq_briefcase_savemain':
|
517 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
518 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
519 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
520 |
+
echo wp_json_encode($response);
|
521 |
+
exit();
|
522 |
+
}
|
523 |
+
|
524 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
525 |
+
|
526 |
+
$post_id = (int)SQ_Classes_Helpers_Tools::getValue('post_id', 0);
|
527 |
+
$keyword = (string)SQ_Classes_Helpers_Tools::getValue('keyword', '');
|
528 |
+
|
529 |
+
if ((int)$post_id > 0 && $keyword <> '') {
|
530 |
+
$args = array();
|
531 |
+
|
532 |
+
$args['post_id'] = $post_id;
|
533 |
+
$args['keyword'] = $keyword;
|
534 |
+
SQ_Classes_RemoteController::saveBriefcaseMainKeyword($args);
|
535 |
+
|
536 |
+
echo wp_json_encode(array('saved' => esc_html__("Saved!", 'squirrly-seo')));
|
537 |
+
} else {
|
538 |
+
echo wp_json_encode(array('error' => esc_html__("Invalid params!", 'squirrly-seo')));
|
539 |
+
}
|
540 |
+
exit();
|
541 |
+
/*************************************************
|
542 |
+
*
|
543 |
+
* AJAX
|
544 |
+
*/
|
545 |
+
case 'sq_ajax_briefcase_doserp':
|
546 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
547 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
548 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
549 |
+
echo wp_json_encode($response);
|
550 |
+
exit();
|
551 |
+
}
|
552 |
+
|
553 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
554 |
+
|
555 |
+
$json = array();
|
556 |
+
$keyword = (string)SQ_Classes_Helpers_Tools::getValue('keyword', '');
|
557 |
+
|
558 |
+
if ($keyword <> '') {
|
559 |
+
$args = array();
|
560 |
+
$args['keyword'] = $keyword;
|
561 |
+
if (SQ_Classes_RemoteController::addSerpKeyword($args) === false) {
|
562 |
+
$json['error'] = SQ_Classes_Error::showNotices(esc_html__("Could not add the keyword to SERP Check. Please try again.", 'squirrly-seo'), 'sq_error');
|
563 |
+
} else {
|
564 |
+
$json['message'] = SQ_Classes_Error::showNotices(esc_html__("The keyword is added to SERP Check.", 'squirrly-seo'), 'sq_success');
|
565 |
+
}
|
566 |
+
} else {
|
567 |
+
$json['error'] = SQ_Classes_Error::showNotices(esc_html__("Invalid parameters.", 'squirrly-seo'), 'sq_error');
|
568 |
+
}
|
569 |
+
|
570 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
571 |
+
echo wp_json_encode($json);
|
572 |
+
exit();
|
573 |
+
case 'sq_ajax_research_others':
|
574 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
575 |
+
$keyword = SQ_Classes_Helpers_Tools::getValue('keyword', false);
|
576 |
+
$country = SQ_Classes_Helpers_Tools::getValue('country', 'com');
|
577 |
+
$lang = SQ_Classes_Helpers_Tools::getValue('lang', 'en');
|
578 |
+
|
579 |
+
if ($keyword) {
|
580 |
+
$args = array();
|
581 |
+
$args['keyword'] = $keyword;
|
582 |
+
$args['country'] = $country;
|
583 |
+
$args['lang'] = $lang;
|
584 |
+
$json = SQ_Classes_RemoteController::getKROthers($args);
|
585 |
+
|
586 |
+
if (!is_wp_error($json)) {
|
587 |
+
if (isset($json->keywords)) {
|
588 |
+
echo wp_json_encode(array('keywords' => $json->keywords));
|
589 |
+
}
|
590 |
+
} else {
|
591 |
+
echo wp_json_encode(array('error' => $json->get_error_message()));
|
592 |
+
}
|
593 |
+
} else {
|
594 |
+
echo wp_json_encode(array('error' => esc_html__("Invalid params!", 'squirrly-seo')));
|
595 |
+
}
|
596 |
+
|
597 |
+
exit();
|
598 |
+
case 'sq_ajax_research_process':
|
599 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
600 |
+
$keywords = SQ_Classes_Helpers_Tools::getValue('keywords', false);
|
601 |
+
$lang = SQ_Classes_Helpers_Tools::getValue('lang', 'en');
|
602 |
+
$country = SQ_Classes_Helpers_Tools::getValue('country', 'com');
|
603 |
+
|
604 |
+
$count = (int)SQ_Classes_Helpers_Tools::getValue('count', 10);
|
605 |
+
$id = (int)SQ_Classes_Helpers_Tools::getValue('id', 0);
|
606 |
+
$this->post_id = SQ_Classes_Helpers_Tools::getValue('post_id', false);
|
607 |
+
|
608 |
+
if ($id > 0) {
|
609 |
+
$args = array();
|
610 |
+
$args['id'] = $id;
|
611 |
+
$this->kr = SQ_Classes_RemoteController::getKRSuggestion($args);
|
612 |
+
|
613 |
+
if (!is_wp_error($this->kr)) {
|
614 |
+
if (!empty($this->kr)) {
|
615 |
+
//Get the briefcase keywords
|
616 |
+
if ($briefcase = SQ_Classes_RemoteController::getBriefcase()) {
|
617 |
+
if (!is_wp_error($briefcase)) {
|
618 |
+
if (isset($briefcase->keywords)) {
|
619 |
+
$this->keywords = $briefcase->keywords;
|
620 |
+
}
|
621 |
+
}
|
622 |
+
}
|
623 |
+
|
624 |
+
//research ready, return the results
|
625 |
+
echo wp_json_encode(array('done' => true, 'html' => $this->get_view('Research/ResearchDetails')));
|
626 |
+
} else {
|
627 |
+
//still loading
|
628 |
+
echo wp_json_encode(array('done' => false));
|
629 |
+
}
|
630 |
+
} else {
|
631 |
+
//show the keywords in results to be able to add them to brifcase
|
632 |
+
$keywords = explode(',', $keywords);
|
633 |
+
if (!empty($keywords)) {
|
634 |
+
foreach ($keywords as $keyword) {
|
635 |
+
$this->kr[] = json_decode(
|
636 |
+
wp_json_encode(
|
637 |
+
array(
|
638 |
+
'keyword' => $keyword,
|
639 |
+
)
|
640 |
+
)
|
641 |
+
);
|
642 |
+
}
|
643 |
+
}
|
644 |
+
echo wp_json_encode(array('done' => true, 'html' => $this->get_view('Research/ResearchDetails')));
|
645 |
+
|
646 |
+
}
|
647 |
+
} elseif ($keywords) {
|
648 |
+
$args = array();
|
649 |
+
$args['q'] = $keywords;
|
650 |
+
$args['country'] = $country;
|
651 |
+
$args['lang'] = $lang;
|
652 |
+
$args['count'] = $count;
|
653 |
+
$process = SQ_Classes_RemoteController::setKRSuggestion($args);
|
654 |
+
|
655 |
+
if (!is_wp_error($process)) {
|
656 |
+
if (isset($process->id)) {
|
657 |
+
//Get the briefcase keywords
|
658 |
+
echo wp_json_encode(array('done' => false, 'id' => $process->id));
|
659 |
+
|
660 |
+
}
|
661 |
+
} else {
|
662 |
+
if ($process->get_error_code() == 'limit_exceeded') {
|
663 |
+
echo wp_json_encode(array('done' => true, 'error' => esc_html__("Keyword Research limit exceeded", 'squirrly-seo')));
|
664 |
+
} else {
|
665 |
+
echo wp_json_encode(array('done' => true, 'error' => $process->get_error_message()));
|
666 |
+
}
|
667 |
+
}
|
668 |
+
} else {
|
669 |
+
echo wp_json_encode(array('done' => true, 'error' => esc_html__("Invalid params!", 'squirrly-seo')));
|
670 |
+
}
|
671 |
+
exit();
|
672 |
+
case 'sq_ajax_research_history':
|
673 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
674 |
+
$id = (int)SQ_Classes_Helpers_Tools::getValue('id', 0);
|
675 |
+
|
676 |
+
if ($id > 0) {
|
677 |
+
$args = $this->kr = array();
|
678 |
+
$args['id'] = $id;
|
679 |
+
$krHistory = SQ_Classes_RemoteController::getKRHistory($args);
|
680 |
+
|
681 |
+
if (!empty($krHistory)) { //get only the first report
|
682 |
+
$this->kr = current($krHistory);
|
683 |
+
}
|
684 |
+
|
685 |
+
//Get the briefcase keywords
|
686 |
+
if ($briefcase = SQ_Classes_RemoteController::getBriefcase()) {
|
687 |
+
if (!is_wp_error($briefcase)) {
|
688 |
+
if (isset($briefcase->keywords)) {
|
689 |
+
$this->keywords = $briefcase->keywords;
|
690 |
+
}
|
691 |
+
}
|
692 |
+
}
|
693 |
+
|
694 |
+
echo wp_json_encode(array('html' => $this->get_view('Research/HistoryDetails')));
|
695 |
+
} else {
|
696 |
+
echo wp_json_encode(array('error' => esc_html__("Invalid params!", 'squirrly-seo')));
|
697 |
+
}
|
698 |
+
exit();
|
699 |
+
|
700 |
+
case 'sq_ajax_briefcase_bulk_delete':
|
701 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
702 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
703 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
704 |
+
echo wp_json_encode($response);
|
705 |
+
exit();
|
706 |
+
}
|
707 |
+
|
708 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
709 |
+
$keywords = SQ_Classes_Helpers_Tools::getValue('inputs', array());
|
710 |
+
|
711 |
+
if (!empty($keywords)) {
|
712 |
+
foreach ($keywords as $keyword) {
|
713 |
+
//set ignore on API
|
714 |
+
$args = array();
|
715 |
+
$args['keyword'] = stripslashes($keyword);
|
716 |
+
SQ_Classes_RemoteController::removeBriefcaseKeyword($args);
|
717 |
+
}
|
718 |
+
|
719 |
+
echo wp_json_encode(array('message' => esc_html__("Deleted!", 'squirrly-seo')));
|
720 |
+
} else {
|
721 |
+
echo wp_json_encode(array('error' => esc_html__("Invalid params!", 'squirrly-seo')));
|
722 |
+
}
|
723 |
+
exit();
|
724 |
+
case 'sq_ajax_briefcase_bulk_label':
|
725 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
726 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
727 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
728 |
+
echo wp_json_encode($response);
|
729 |
+
exit();
|
730 |
+
}
|
731 |
+
|
732 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
733 |
+
|
734 |
+
$keywords = SQ_Classes_Helpers_Tools::getValue('inputs', array());
|
735 |
+
$labels = SQ_Classes_Helpers_Tools::getValue('labels', array());
|
736 |
+
|
737 |
+
if (!empty($keywords)) {
|
738 |
+
foreach ($keywords as $keyword) {
|
739 |
+
$args = array();
|
740 |
+
|
741 |
+
$args['keyword'] = $keyword;
|
742 |
+
$args['labels'] = '';
|
743 |
+
if (is_array($labels) && !empty($labels)) {
|
744 |
+
$args['labels'] = join(',', $labels);
|
745 |
+
SQ_Classes_RemoteController::saveBriefcaseKeywordLabel($args);
|
746 |
+
} else {
|
747 |
+
SQ_Classes_RemoteController::saveBriefcaseKeywordLabel($args);
|
748 |
+
|
749 |
+
}
|
750 |
+
}
|
751 |
+
|
752 |
+
echo wp_json_encode(array('message' => esc_html__("Saved!", 'squirrly-seo')));
|
753 |
+
} else {
|
754 |
+
echo wp_json_encode(array('error' => esc_html__("Invalid Keyword!", 'squirrly-seo')));
|
755 |
+
}
|
756 |
+
|
757 |
+
exit();
|
758 |
+
case 'sq_ajax_briefcase_bulk_doserp':
|
759 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
760 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
761 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
762 |
+
echo wp_json_encode($response);
|
763 |
+
exit();
|
764 |
+
}
|
765 |
+
|
766 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
767 |
+
|
768 |
+
$keywords = SQ_Classes_Helpers_Tools::getValue('inputs', array());
|
769 |
+
|
770 |
+
if (!empty($keywords)) {
|
771 |
+
foreach ($keywords as $keyword) {
|
772 |
+
$args = array();
|
773 |
+
$args['keyword'] = $keyword;
|
774 |
+
SQ_Classes_RemoteController::addSerpKeyword($args);
|
775 |
+
|
776 |
+
}
|
777 |
+
|
778 |
+
echo wp_json_encode(array('message' => esc_html__("The keywords are added to SERP Check!", 'squirrly-seo')));
|
779 |
+
} else {
|
780 |
+
echo wp_json_encode(array('error' => esc_html__("Invalid Keyword!", 'squirrly-seo')));
|
781 |
+
}
|
782 |
+
exit();
|
783 |
+
|
784 |
+
case 'sq_ajax_labels_bulk_delete':
|
785 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
786 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
787 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
788 |
+
echo wp_json_encode($response);
|
789 |
+
exit();
|
790 |
+
}
|
791 |
+
|
792 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
793 |
+
$inputs = SQ_Classes_Helpers_Tools::getValue('inputs', array());
|
794 |
+
|
795 |
+
if (!empty($inputs)) {
|
796 |
+
foreach ($inputs as $id) {
|
797 |
+
if ($id > 0) {
|
798 |
+
$args = array();
|
799 |
+
$args['id'] = $id;
|
800 |
+
SQ_Classes_RemoteController::removeBriefcaseLabel($args);
|
801 |
+
}
|
802 |
+
}
|
803 |
+
|
804 |
+
echo wp_json_encode(array('message' => esc_html__("Deleted!", 'squirrly-seo')));
|
805 |
+
} else {
|
806 |
+
echo wp_json_encode(array('error' => esc_html__("Invalid params!", 'squirrly-seo')));
|
807 |
+
}
|
808 |
+
exit();
|
809 |
+
}
|
810 |
+
|
811 |
+
|
812 |
+
}
|
813 |
+
}
|
controllers/SeoSettings.php
CHANGED
@@ -1,843 +1,878 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Controllers_SeoSettings extends SQ_Classes_FrontController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
16 |
-
|
17 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
18 |
-
}
|
19 |
-
|
20 |
-
|
21 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
22 |
-
|
23 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
24 |
-
|
25 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
26 |
-
|
27 |
-
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
add_action('sq_form_notices', array($this, 'getNotificationBar'));
|
85 |
-
}
|
86 |
-
|
87 |
-
public function
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
SQ_Classes_Helpers_Tools
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
}
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
if ($
|
527 |
-
try {
|
528 |
-
|
529 |
-
$
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
}
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
$
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
$
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
$response =
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
echo wp_json_encode($response);
|
733 |
-
exit();
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Controllers_SeoSettings extends SQ_Classes_FrontController
|
5 |
+
{
|
6 |
+
|
7 |
+
public $pages = array();
|
8 |
+
|
9 |
+
function init()
|
10 |
+
{
|
11 |
+
$tab = preg_replace("/[^a-zA-Z0-9]/", "", SQ_Classes_Helpers_Tools::getValue('tab', 'automation'));
|
12 |
+
|
13 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap-reboot');
|
14 |
+
if (is_rtl()) {
|
15 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('popper');
|
16 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap.rtl');
|
17 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('rtl');
|
18 |
+
} else {
|
19 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap');
|
20 |
+
}
|
21 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap-select');
|
22 |
+
|
23 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('switchery');
|
24 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('fontawesome');
|
25 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('global');
|
26 |
+
|
27 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('assistant');
|
28 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('navbar');
|
29 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('seosettings');
|
30 |
+
|
31 |
+
if (method_exists($this, $tab)) {
|
32 |
+
call_user_func(array($this, $tab));
|
33 |
+
}
|
34 |
+
|
35 |
+
if (function_exists('wp_enqueue_media')) {
|
36 |
+
wp_enqueue_media();
|
37 |
+
wp_enqueue_style('media-views');
|
38 |
+
}
|
39 |
+
|
40 |
+
//@ob_flush();
|
41 |
+
$this->show_view('SeoSettings/' . esc_attr(ucfirst($tab)));
|
42 |
+
|
43 |
+
//get the modal window for the assistant popup
|
44 |
+
echo SQ_Classes_ObjController::getClass('SQ_Models_Assistant')->getModal();
|
45 |
+
}
|
46 |
+
|
47 |
+
public function gotoImport()
|
48 |
+
{
|
49 |
+
$_GET['tab'] = 'backup';
|
50 |
+
return $this->init();
|
51 |
+
}
|
52 |
+
|
53 |
+
public function automation()
|
54 |
+
{
|
55 |
+
add_action('sq_form_notices', array($this, 'getNotificationBar'));
|
56 |
+
|
57 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('highlight');
|
58 |
+
SQ_Classes_ObjController::getClass('SQ_Controllers_Patterns')->init();
|
59 |
+
}
|
60 |
+
|
61 |
+
public function metas()
|
62 |
+
{
|
63 |
+
add_action('sq_form_notices', array($this, 'getNotificationBar'));
|
64 |
+
|
65 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('highlight');
|
66 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('snippet');
|
67 |
+
}
|
68 |
+
|
69 |
+
public function links()
|
70 |
+
{
|
71 |
+
add_action('sq_form_notices', array($this, 'getNotificationBar'));
|
72 |
+
|
73 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('highlight');
|
74 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('snippet');
|
75 |
+
}
|
76 |
+
|
77 |
+
public function jsonld()
|
78 |
+
{
|
79 |
+
add_action('sq_form_notices', array($this, 'getNotificationBar'));
|
80 |
+
}
|
81 |
+
|
82 |
+
public function social()
|
83 |
+
{
|
84 |
+
add_action('sq_form_notices', array($this, 'getNotificationBar'));
|
85 |
+
}
|
86 |
+
|
87 |
+
public function tracking()
|
88 |
+
{
|
89 |
+
add_action('sq_form_notices', array($this, 'getNotificationBar'));
|
90 |
+
}
|
91 |
+
|
92 |
+
public function webmaster()
|
93 |
+
{
|
94 |
+
add_action('sq_form_notices', array($this, 'getNotificationBar'));
|
95 |
+
}
|
96 |
+
|
97 |
+
public function sitemap()
|
98 |
+
{
|
99 |
+
add_action('sq_form_notices', array($this, 'getNotificationBar'));
|
100 |
+
}
|
101 |
+
|
102 |
+
public function robots()
|
103 |
+
{
|
104 |
+
add_action('sq_form_notices', array($this, 'getNotificationBar'));
|
105 |
+
}
|
106 |
+
|
107 |
+
public function favicon()
|
108 |
+
{
|
109 |
+
add_action('sq_form_notices', array($this, 'getNotificationBar'));
|
110 |
+
}
|
111 |
+
|
112 |
+
public function backup()
|
113 |
+
{
|
114 |
+
add_filter('sq_themes', array(SQ_Classes_ObjController::getClass('SQ_Models_ImportExport'), 'getAvailableThemes'), 10, 1);
|
115 |
+
add_filter('sq_importList', array(SQ_Classes_ObjController::getClass('SQ_Models_ImportExport'), 'importList'));
|
116 |
+
}
|
117 |
+
|
118 |
+
|
119 |
+
public function hookFooter()
|
120 |
+
{
|
121 |
+
if (!SQ_Classes_Helpers_Tools::getOption('sq_seoexpert')) {
|
122 |
+
echo "<script>jQuery('.sq_advanced').hide();</script>";
|
123 |
+
} else {
|
124 |
+
echo "<script>jQuery('.sq_advanced').show();</script>";
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Called when action is triggered
|
130 |
+
*
|
131 |
+
* @return void
|
132 |
+
*/
|
133 |
+
public function action()
|
134 |
+
{
|
135 |
+
parent::action();
|
136 |
+
|
137 |
+
switch (SQ_Classes_Helpers_Tools::getValue('action')) {
|
138 |
+
|
139 |
+
case 'sq_seosettings_links':
|
140 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
141 |
+
return;
|
142 |
+
}
|
143 |
+
|
144 |
+
//Save the settings
|
145 |
+
if (!empty($_POST)) {
|
146 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Settings')->saveValues($_POST);
|
147 |
+
}
|
148 |
+
|
149 |
+
//Save custom robots
|
150 |
+
$links = SQ_Classes_Helpers_Tools::getValue('links_permission', '', true);
|
151 |
+
$links = explode(PHP_EOL, $links);
|
152 |
+
$links = str_replace("\r", "", $links);
|
153 |
+
|
154 |
+
if (!empty($links)) {
|
155 |
+
SQ_Classes_Helpers_Tools::$options['sq_external_exception'] = array_unique($links);
|
156 |
+
}
|
157 |
+
|
158 |
+
//save the options in database
|
159 |
+
SQ_Classes_Helpers_Tools::saveOptions();
|
160 |
+
|
161 |
+
//show the saved message
|
162 |
+
if (!SQ_Classes_Error::isError()) SQ_Classes_Error::setMessage(esc_html__("Saved", 'squirrly-seo'));
|
163 |
+
|
164 |
+
break;
|
165 |
+
|
166 |
+
///////////////////////////////////////////SEO SETTINGS METAS
|
167 |
+
case 'sq_seosettings_metas':
|
168 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
169 |
+
return;
|
170 |
+
}
|
171 |
+
|
172 |
+
//Save the settings
|
173 |
+
if (!empty($_POST)) {
|
174 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Settings')->saveValues($_POST);
|
175 |
+
}
|
176 |
+
|
177 |
+
///////////////////////////////////////////
|
178 |
+
/////////////////////////////FIRST PAGE OPTIMIZATION
|
179 |
+
$url = home_url();
|
180 |
+
$post = SQ_Classes_ObjController::getClass('SQ_Models_Snippet')->setHomePage();
|
181 |
+
|
182 |
+
$post->sq->doseo = 1;
|
183 |
+
$post->sq->title = urldecode(SQ_Classes_Helpers_Tools::getValue('sq_fp_title', false));
|
184 |
+
$post->sq->description = urldecode(SQ_Classes_Helpers_Tools::getValue('sq_fp_description', false));
|
185 |
+
$post->sq->keywords = SQ_Classes_Helpers_Tools::getValue('sq_fp_keywords', false);
|
186 |
+
|
187 |
+
if (SQ_Classes_Helpers_Tools::getIsset('sq_fp_ogimage')) {
|
188 |
+
$post->sq->og_media = SQ_Classes_Helpers_Tools::getValue('sq_fp_ogimage', '');
|
189 |
+
}
|
190 |
+
|
191 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Qss')->saveSqSEO(
|
192 |
+
$url,
|
193 |
+
md5('wp_homepage'),
|
194 |
+
maybe_serialize(
|
195 |
+
array(
|
196 |
+
'ID' => 0,
|
197 |
+
'post_type' => 'home',
|
198 |
+
'term_id' => 0,
|
199 |
+
'taxonomy' => '',
|
200 |
+
)
|
201 |
+
),
|
202 |
+
maybe_serialize($post->sq->toArray()),
|
203 |
+
gmdate('Y-m-d H:i:s')
|
204 |
+
);
|
205 |
+
|
206 |
+
//reset the report time
|
207 |
+
SQ_Classes_Helpers_Tools::saveOptions('seoreport_time', false);
|
208 |
+
|
209 |
+
//show the saved message
|
210 |
+
if (!SQ_Classes_Error::isError()) SQ_Classes_Error::setMessage(esc_html__("Saved", 'squirrly-seo'));
|
211 |
+
|
212 |
+
break;
|
213 |
+
|
214 |
+
///////////////////////////////////////////SEO SETTINGS AUTOMATION
|
215 |
+
case 'sq_seosettings_automation':
|
216 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
217 |
+
return;
|
218 |
+
}
|
219 |
+
|
220 |
+
//Save the settings
|
221 |
+
if (!empty($_POST)) {
|
222 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Settings')->saveValues($_POST);
|
223 |
+
}
|
224 |
+
|
225 |
+
|
226 |
+
//show the saved message
|
227 |
+
if (!SQ_Classes_Error::isError()) SQ_Classes_Error::setMessage(esc_html__("Saved", 'squirrly-seo'));
|
228 |
+
|
229 |
+
break;
|
230 |
+
///////////////////////////////////////////SEO SETTINGS METAS
|
231 |
+
case 'sq_seosettings_social':
|
232 |
+
case 'sq_seosettings_tracking':
|
233 |
+
case 'sq_seosettings_webmaster':
|
234 |
+
case 'sq_seosettings_advanced':
|
235 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
236 |
+
return;
|
237 |
+
}
|
238 |
+
|
239 |
+
//Save the settings
|
240 |
+
if (!empty($_POST)) {
|
241 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Settings')->saveValues($_POST);
|
242 |
+
}
|
243 |
+
|
244 |
+
//save the options in database
|
245 |
+
SQ_Classes_Helpers_Tools::saveOptions();
|
246 |
+
|
247 |
+
//reset the report time
|
248 |
+
SQ_Classes_Helpers_Tools::saveOptions('seoreport_time', false);
|
249 |
+
|
250 |
+
//show the saved message
|
251 |
+
if (!SQ_Classes_Error::isError()) SQ_Classes_Error::setMessage(esc_html__("Saved", 'squirrly-seo'));
|
252 |
+
|
253 |
+
|
254 |
+
break;
|
255 |
+
|
256 |
+
///////////////////////////////////////////SEO SETTINGS METAS
|
257 |
+
case 'sq_seosettings_sitemap':
|
258 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
259 |
+
return;
|
260 |
+
}
|
261 |
+
|
262 |
+
//Save the settings
|
263 |
+
if (!empty($_POST)) {
|
264 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Settings')->saveValues($_POST);
|
265 |
+
}
|
266 |
+
|
267 |
+
//Make sure we get the Sitemap data from the form
|
268 |
+
if ($sitemap = SQ_Classes_Helpers_Tools::getValue('sitemap', false)) {
|
269 |
+
foreach (SQ_Classes_Helpers_Tools::$options['sq_sitemap'] as $key => $value) {
|
270 |
+
if (isset($sitemap[$key])) {
|
271 |
+
SQ_Classes_Helpers_Tools::$options['sq_sitemap'][$key][1] = (int)$sitemap[$key];
|
272 |
+
} elseif ($key <> 'sitemap') {
|
273 |
+
SQ_Classes_Helpers_Tools::$options['sq_sitemap'][$key][1] = 0;
|
274 |
+
}
|
275 |
+
}
|
276 |
+
}
|
277 |
+
|
278 |
+
//save the options in database
|
279 |
+
SQ_Classes_Helpers_Tools::saveOptions();
|
280 |
+
|
281 |
+
//delete other sitemap xml files from root
|
282 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_auto_sitemap') && file_exists(ABSPATH . "/" . 'sitemap.xml')) {
|
283 |
+
@rename(ABSPATH . "/" . 'sitemap.xml', ABSPATH . "/" . 'sitemap_ren' . time() . '.xml');
|
284 |
+
}
|
285 |
+
|
286 |
+
//reset the report time
|
287 |
+
SQ_Classes_Helpers_Tools::saveOptions('seoreport_time', false);
|
288 |
+
|
289 |
+
//show the saved message
|
290 |
+
if (!SQ_Classes_Error::isError()) SQ_Classes_Error::setMessage(esc_html__("Saved", 'squirrly-seo'));
|
291 |
+
|
292 |
+
break;
|
293 |
+
|
294 |
+
//Save the JSON-LD page from SEO Settings
|
295 |
+
case 'sq_seosettings_jsonld':
|
296 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
297 |
+
return;
|
298 |
+
}
|
299 |
+
|
300 |
+
//Save the settings
|
301 |
+
if (!empty($_POST)) {
|
302 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Settings')->saveValues($_POST);
|
303 |
+
}
|
304 |
+
|
305 |
+
if (SQ_Classes_Helpers_Tools::$options['sq_jsonld']['Person']['telephone'] <> '') {
|
306 |
+
SQ_Classes_Helpers_Tools::$options['sq_jsonld']['Person']['telephone'] = '+' . ltrim(SQ_Classes_Helpers_Tools::$options['sq_jsonld']['Person']['telephone'], '+');
|
307 |
+
}
|
308 |
+
if (SQ_Classes_Helpers_Tools::$options['sq_jsonld']['Organization']['contactPoint']['telephone'] <> '') {
|
309 |
+
SQ_Classes_Helpers_Tools::$options['sq_jsonld']['Organization']['contactPoint']['telephone'] = '+' . ltrim(SQ_Classes_Helpers_Tools::$options['sq_jsonld']['Organization']['contactPoint']['telephone'], '+');
|
310 |
+
}
|
311 |
+
|
312 |
+
//save the options in database
|
313 |
+
SQ_Classes_Helpers_Tools::saveOptions();
|
314 |
+
|
315 |
+
//reset the report time
|
316 |
+
SQ_Classes_Helpers_Tools::saveOptions('seoreport_time', false);
|
317 |
+
|
318 |
+
//show the saved message
|
319 |
+
if (!SQ_Classes_Error::isError()) SQ_Classes_Error::setMessage(esc_html__("Saved", 'squirrly-seo'));
|
320 |
+
|
321 |
+
break;
|
322 |
+
|
323 |
+
//Save the Robots permissions
|
324 |
+
case 'sq_seosettings_robots':
|
325 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
326 |
+
return;
|
327 |
+
}
|
328 |
+
|
329 |
+
//Save the settings
|
330 |
+
if (!empty($_POST)) {
|
331 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Settings')->saveValues($_POST);
|
332 |
+
}
|
333 |
+
|
334 |
+
//Save custom robots
|
335 |
+
$robots = SQ_Classes_Helpers_Tools::getValue('robots_permission', '', true);
|
336 |
+
$robots = explode(PHP_EOL, $robots);
|
337 |
+
$robots = str_replace("\r", "", $robots);
|
338 |
+
|
339 |
+
if (!empty($robots)) {
|
340 |
+
SQ_Classes_Helpers_Tools::$options['sq_robots_permission'] = array_unique($robots);
|
341 |
+
}
|
342 |
+
|
343 |
+
//save the options in database
|
344 |
+
SQ_Classes_Helpers_Tools::saveOptions();
|
345 |
+
|
346 |
+
//reset the report time
|
347 |
+
SQ_Classes_Helpers_Tools::saveOptions('seoreport_time', false);
|
348 |
+
|
349 |
+
//show the saved message
|
350 |
+
if (!SQ_Classes_Error::isError()) SQ_Classes_Error::setMessage(esc_html__("Saved", 'squirrly-seo'));
|
351 |
+
|
352 |
+
|
353 |
+
break;
|
354 |
+
|
355 |
+
//Save the Favicon image
|
356 |
+
case 'sq_seosettings_favicon':
|
357 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
358 |
+
return;
|
359 |
+
}
|
360 |
+
|
361 |
+
//If the favicon is turned off delete the favicon image created
|
362 |
+
if (!SQ_Classes_Helpers_Tools::getValue('sq_auto_favicon')
|
363 |
+
&& SQ_Classes_Helpers_Tools::getOption('sq_auto_favicon')
|
364 |
+
&& SQ_Classes_Helpers_Tools::getOption('favicon') <> ''
|
365 |
+
&& file_exists(ABSPATH . "/" . 'favicon.ico')
|
366 |
+
) {
|
367 |
+
@rename(ABSPATH . "/" . 'favicon.ico', ABSPATH . "/" . 'favicon_ren' . time() . '.ico');
|
368 |
+
}
|
369 |
+
|
370 |
+
//Save the settings
|
371 |
+
if (!empty($_POST)) {
|
372 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Settings')->saveValues($_POST);
|
373 |
+
}
|
374 |
+
|
375 |
+
/* if there is an icon to upload */
|
376 |
+
if (!empty($_FILES['favicon'])) {
|
377 |
+
if ($return = SQ_Classes_ObjController::getClass('SQ_Models_Ico')->addFavicon($_FILES['favicon'])) {
|
378 |
+
if ($return['favicon'] <> '') {
|
379 |
+
SQ_Classes_Helpers_Tools::saveOptions('favicon', strtolower(basename($return['favicon'])));
|
380 |
+
}
|
381 |
+
}
|
382 |
+
}
|
383 |
+
|
384 |
+
|
385 |
+
break;
|
386 |
+
case 'sq_seosettings_ga_revoke':
|
387 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
388 |
+
return;
|
389 |
+
}
|
390 |
+
|
391 |
+
//remove connection with Google Analytics
|
392 |
+
$response = SQ_Classes_RemoteController::revokeGaConnection();
|
393 |
+
if (!is_wp_error($response)) {
|
394 |
+
SQ_Classes_Error::setError(esc_html__("Google Analytics account is disconnected.", 'squirrly-seo') . " <br /> ", 'success');
|
395 |
+
} else {
|
396 |
+
SQ_Classes_Error::setError(esc_html__("Error! Could not disconnect the account.", 'squirrly-seo') . " <br /> ");
|
397 |
+
}
|
398 |
+
break;
|
399 |
+
case 'sq_seosettings_gsc_revoke':
|
400 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
401 |
+
return;
|
402 |
+
}
|
403 |
+
|
404 |
+
//remove connection with Google Search Console
|
405 |
+
$response = SQ_Classes_RemoteController::revokeGscConnection();
|
406 |
+
if (!is_wp_error($response)) {
|
407 |
+
SQ_Classes_Error::setError(esc_html__("Google Search Console account is disconnected.", 'squirrly-seo') . " <br /> ", 'success');
|
408 |
+
} else {
|
409 |
+
SQ_Classes_Error::setError(esc_html__("Error! Could not disconnect the account.", 'squirrly-seo') . " <br /> ");
|
410 |
+
}
|
411 |
+
break;
|
412 |
+
case 'sq_seosettings_ga_check':
|
413 |
+
case 'sq_seosettings_gsc_check':
|
414 |
+
case 'sq_seosettings_clear_cache':
|
415 |
+
|
416 |
+
//Refresh the checkin on login
|
417 |
+
delete_transient('sq_checkin');
|
418 |
+
|
419 |
+
break;
|
420 |
+
case 'sq_seosettings_ga_save':
|
421 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
422 |
+
return;
|
423 |
+
}
|
424 |
+
|
425 |
+
$property_id = SQ_Classes_Helpers_Tools::getValue('property_id', false);
|
426 |
+
|
427 |
+
if ($property_id) {
|
428 |
+
$args = array();
|
429 |
+
$args['property_id'] = $property_id;
|
430 |
+
SQ_Classes_RemoteController::saveGAProperties($args);
|
431 |
+
}
|
432 |
+
|
433 |
+
SQ_Classes_Error::setMessage(esc_html__("Saved", 'squirrly-seo'));
|
434 |
+
break;
|
435 |
+
case 'sq_seosettings_backupsettings':
|
436 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
437 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
438 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
439 |
+
echo wp_json_encode($response);
|
440 |
+
exit();
|
441 |
+
}
|
442 |
+
|
443 |
+
SQ_Classes_Helpers_Tools::setHeader('text');
|
444 |
+
header("Content-Disposition: attachment; filename=squirrly-settings-" . gmdate('Y-m-d') . ".txt");
|
445 |
+
|
446 |
+
if (function_exists('base64_encode')) {
|
447 |
+
echo base64_encode(wp_json_encode(SQ_Classes_Helpers_Tools::$options));
|
448 |
+
} else {
|
449 |
+
echo wp_json_encode(SQ_Classes_Helpers_Tools::$options);
|
450 |
+
}
|
451 |
+
exit();
|
452 |
+
case 'sq_seosettings_restoresettings':
|
453 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
454 |
+
return;
|
455 |
+
}
|
456 |
+
|
457 |
+
if (!empty($_FILES['sq_options']) && $_FILES['sq_options']['tmp_name'] <> '') {
|
458 |
+
$fp = fopen($_FILES['sq_options']['tmp_name'], 'rb');
|
459 |
+
$options = '';
|
460 |
+
while (($line = fgets($fp)) !== false) {
|
461 |
+
$options .= $line;
|
462 |
+
}
|
463 |
+
try {
|
464 |
+
if (function_exists('base64_encode') && base64_decode($options) <> '') {
|
465 |
+
$options = @base64_decode($options);
|
466 |
+
}
|
467 |
+
$options = json_decode($options, true);
|
468 |
+
if (is_array($options) && isset($options['sq_api'])) {
|
469 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_api') <> '') {
|
470 |
+
$options['sq_api'] = SQ_Classes_Helpers_Tools::getOption('sq_api');
|
471 |
+
}
|
472 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_seojourney') <> '') {
|
473 |
+
$options['sq_seojourney'] = SQ_Classes_Helpers_Tools::getOption('sq_seojourney');
|
474 |
+
}
|
475 |
+
SQ_Classes_Helpers_Tools::$options = $options;
|
476 |
+
SQ_Classes_Helpers_Tools::saveOptions();
|
477 |
+
|
478 |
+
//Check if there is an old backup from Squirrly
|
479 |
+
SQ_Classes_Helpers_Tools::getOptions();
|
480 |
+
|
481 |
+
//reset the report time
|
482 |
+
SQ_Classes_Helpers_Tools::saveOptions('seoreport_time', false);
|
483 |
+
|
484 |
+
SQ_Classes_Error::setError(esc_html__("Great! The backup is restored.", 'squirrly-seo') . " <br /> ", 'success');
|
485 |
+
} else {
|
486 |
+
SQ_Classes_Error::setError(esc_html__("Error! The backup is not valid.", 'squirrly-seo') . " <br /> ");
|
487 |
+
}
|
488 |
+
} catch (Exception $e) {
|
489 |
+
SQ_Classes_Error::setError(esc_html__("Error! The backup is not valid.", 'squirrly-seo') . " <br /> ");
|
490 |
+
}
|
491 |
+
} else {
|
492 |
+
SQ_Classes_Error::setError(esc_html__("Error! You have to enter a previously saved backup file.", 'squirrly-seo') . " <br /> ");
|
493 |
+
}
|
494 |
+
break;
|
495 |
+
case 'sq_seosettings_backupseo':
|
496 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
497 |
+
return;
|
498 |
+
}
|
499 |
+
|
500 |
+
header('Content-Type: application/octet-stream');
|
501 |
+
header("Content-Transfer-Encoding: Binary");
|
502 |
+
header("Content-Disposition: attachment; filename=squirrly-seo-" . gmdate('Y-m-d') . ".sql");
|
503 |
+
|
504 |
+
if (function_exists('base64_encode')) {
|
505 |
+
echo base64_encode(SQ_Classes_ObjController::getClass('SQ_Models_ImportExport')->createTableBackup());
|
506 |
+
} else {
|
507 |
+
echo SQ_Classes_ObjController::getClass('SQ_Models_ImportExport')->createTableBackup();
|
508 |
+
}
|
509 |
+
exit();
|
510 |
+
case 'sq_seosettings_restoreseo':
|
511 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
512 |
+
return;
|
513 |
+
}
|
514 |
+
|
515 |
+
if (!empty($_FILES['sq_sql']) && $_FILES['sq_sql']['tmp_name'] <> '') {
|
516 |
+
$fp = fopen($_FILES['sq_sql']['tmp_name'], 'rb');
|
517 |
+
$sql_file = '';
|
518 |
+
while (($line = fgets($fp)) !== false) {
|
519 |
+
$sql_file .= $line;
|
520 |
+
}
|
521 |
+
|
522 |
+
if (function_exists('base64_encode')) {
|
523 |
+
$sql_file = @base64_decode($sql_file);
|
524 |
+
}
|
525 |
+
|
526 |
+
if ($sql_file <> '' && strpos($sql_file, 'INSERT INTO') !== false) {
|
527 |
+
try {
|
528 |
+
|
529 |
+
$queries = explode("INSERT INTO", $sql_file);
|
530 |
+
SQ_Classes_ObjController::getClass('SQ_Models_ImportExport')->executeSql($queries);
|
531 |
+
SQ_Classes_Error::setError(esc_html__("Great! The SEO backup is restored.", 'squirrly-seo') . " <br /> ", 'success');
|
532 |
+
|
533 |
+
} catch (Exception $e) {
|
534 |
+
SQ_Classes_Error::setError(esc_html__("Error! The backup is not valid.", 'squirrly-seo') . " <br /> ");
|
535 |
+
}
|
536 |
+
} else {
|
537 |
+
SQ_Classes_Error::setError(esc_html__("Error! The backup is not valid.", 'squirrly-seo') . " <br /> ");
|
538 |
+
}
|
539 |
+
} else {
|
540 |
+
SQ_Classes_Error::setError(esc_html__("Error! You have to enter a previously saved backup file.", 'squirrly-seo') . " <br /> ");
|
541 |
+
}
|
542 |
+
break;
|
543 |
+
case 'sq_seosettings_importall':
|
544 |
+
$platform = SQ_Classes_Helpers_Tools::getValue('sq_import_platform', '');
|
545 |
+
if ($platform <> '') {
|
546 |
+
try {
|
547 |
+
SQ_Classes_ObjController::getClass('SQ_Models_ImportExport')->importDBSettings($platform);
|
548 |
+
$seo = SQ_Classes_ObjController::getClass('SQ_Models_ImportExport')->importDBSeo($platform);
|
549 |
+
if (!empty($seo)) {
|
550 |
+
//Check if the Squirrly Table Exists
|
551 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Qss')->checkTableExists();
|
552 |
+
|
553 |
+
foreach ($seo as $sq_hash => $metas) {
|
554 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Qss')->saveSqSEO(
|
555 |
+
(isset($metas['url']) ? $metas['url'] : ''),
|
556 |
+
$sq_hash,
|
557 |
+
maybe_serialize(
|
558 |
+
array(
|
559 |
+
'ID' => (isset($metas['post_id']) ? (int)$metas['post_id'] : 0),
|
560 |
+
'post_type' => (isset($metas['post_type']) ? $metas['post_type'] : ''),
|
561 |
+
'term_id' => (isset($metas['term_id']) ? (int)$metas['term_id'] : 0),
|
562 |
+
'taxonomy' => (isset($metas['taxonomy']) ? $metas['taxonomy'] : ''),
|
563 |
+
)
|
564 |
+
),
|
565 |
+
maybe_serialize($metas),
|
566 |
+
gmdate('Y-m-d H:i:s')
|
567 |
+
);
|
568 |
+
}
|
569 |
+
}
|
570 |
+
|
571 |
+
SQ_Classes_Error::setMessage(sprintf(esc_html__("Success! The import from %s was completed successfully and your SEO is safe!", 'squirrly-seo'), SQ_Classes_ObjController::getClass('SQ_Models_ImportExport')->getName($platform)));
|
572 |
+
} catch (Exception $e) {
|
573 |
+
SQ_Classes_Error::setMessage(esc_html__("Error! An error occured while import. Please try again.", 'squirrly-seo'));
|
574 |
+
}
|
575 |
+
}
|
576 |
+
break;
|
577 |
+
case 'sq_seosettings_importsettings':
|
578 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
579 |
+
return;
|
580 |
+
}
|
581 |
+
|
582 |
+
$platform = SQ_Classes_Helpers_Tools::getValue('sq_import_platform', '');
|
583 |
+
if ($platform <> '') {
|
584 |
+
if (SQ_Classes_ObjController::getClass('SQ_Models_ImportExport')->importDBSettings($platform)) {
|
585 |
+
SQ_Classes_Error::setMessage(esc_html__("All the Plugin settings were imported successfuly!", 'squirrly-seo'));
|
586 |
+
} else {
|
587 |
+
SQ_Classes_Error::setMessage(esc_html__("No settings found for this plugin/theme.", 'squirrly-seo'));
|
588 |
+
}
|
589 |
+
}
|
590 |
+
break;
|
591 |
+
case 'sq_seosettings_importseo':
|
592 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
593 |
+
return;
|
594 |
+
}
|
595 |
+
|
596 |
+
$platform = SQ_Classes_Helpers_Tools::getValue('sq_import_platform', '');
|
597 |
+
$overwrite = SQ_Classes_Helpers_Tools::getValue('sq_import_overwrite', false);
|
598 |
+
|
599 |
+
if ($platform <> '') {
|
600 |
+
$seo = SQ_Classes_ObjController::getClass('SQ_Models_ImportExport')->importDBSeo($platform);
|
601 |
+
|
602 |
+
if (!empty($seo)) {
|
603 |
+
foreach ($seo as $sq_hash => $metas) {
|
604 |
+
$sq = SQ_Classes_ObjController::getClass('SQ_Models_Qss')->getSqSeo($sq_hash);
|
605 |
+
|
606 |
+
if ($overwrite || !($sq->title && $sq->description)) {
|
607 |
+
|
608 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Qss')->saveSqSEO(
|
609 |
+
(isset($metas['url']) ? $metas['url'] : ''),
|
610 |
+
$sq_hash,
|
611 |
+
maybe_serialize(
|
612 |
+
array(
|
613 |
+
'ID' => (isset($metas['post_id']) ? (int)$metas['post_id'] : 0),
|
614 |
+
'post_type' => (isset($metas['post_type']) ? $metas['post_type'] : ''),
|
615 |
+
'term_id' => (isset($metas['term_id']) ? (int)$metas['term_id'] : 0),
|
616 |
+
'taxonomy' => (isset($metas['taxonomy']) ? $metas['taxonomy'] : ''),
|
617 |
+
)
|
618 |
+
),
|
619 |
+
maybe_serialize($metas),
|
620 |
+
gmdate('Y-m-d H:i:s')
|
621 |
+
);
|
622 |
+
|
623 |
+
}
|
624 |
+
}
|
625 |
+
}
|
626 |
+
|
627 |
+
SQ_Classes_Error::setMessage(sprintf(esc_html__("Success! The import from %s was completed successfully and your SEO is safe!", 'squirrly-seo'), SQ_Classes_ObjController::getClass('SQ_Models_ImportExport')->getName($platform)));
|
628 |
+
}
|
629 |
+
break;
|
630 |
+
case 'sq_rollback':
|
631 |
+
SQ_Classes_Helpers_Tools::setHeader('html');
|
632 |
+
$plugin_slug = basename(_SQ_PLUGIN_NAME_, '.php');
|
633 |
+
|
634 |
+
|
635 |
+
$rollback = SQ_Classes_ObjController::getClass('SQ_Models_Rollback');
|
636 |
+
|
637 |
+
$rollback->set_plugin(
|
638 |
+
array(
|
639 |
+
'version' => SQ_STABLE_VERSION,
|
640 |
+
'plugin_name' => _SQ_ROOT_DIR_,
|
641 |
+
'plugin_slug' => $plugin_slug,
|
642 |
+
'package_url' => sprintf('https://downloads.wordpress.org/plugin/%s.%s.zip', $plugin_slug, SQ_STABLE_VERSION),
|
643 |
+
)
|
644 |
+
);
|
645 |
+
|
646 |
+
$rollback->run();
|
647 |
+
|
648 |
+
wp_die(
|
649 |
+
'', esc_html__("Rollback to Previous Version", 'squirrly-seo'), [
|
650 |
+
'response' => 200,
|
651 |
+
]
|
652 |
+
);
|
653 |
+
exit();
|
654 |
+
case 'sq_reinstall':
|
655 |
+
SQ_Classes_Helpers_Tools::setHeader('html');
|
656 |
+
$plugin_slug = basename(_SQ_PLUGIN_NAME_, '.php');
|
657 |
+
|
658 |
+
|
659 |
+
$rollback = SQ_Classes_ObjController::getClass('SQ_Models_Rollback');
|
660 |
+
|
661 |
+
$rollback->set_plugin(
|
662 |
+
array(
|
663 |
+
'version' => SQ_VERSION,
|
664 |
+
'plugin_name' => _SQ_ROOT_DIR_,
|
665 |
+
'plugin_slug' => $plugin_slug,
|
666 |
+
'package_url' => sprintf('https://downloads.wordpress.org/plugin/%s.%s.zip', $plugin_slug, SQ_VERSION),
|
667 |
+
)
|
668 |
+
);
|
669 |
+
|
670 |
+
$rollback->run();
|
671 |
+
|
672 |
+
wp_die(
|
673 |
+
'', esc_html__("Reinstall Current Version", 'squirrly-seo'), [
|
674 |
+
'response' => 200,
|
675 |
+
]
|
676 |
+
);
|
677 |
+
exit();
|
678 |
+
case 'sq_alerts_close':
|
679 |
+
//remove the specified alert from showing again
|
680 |
+
if ($alert = SQ_Classes_Helpers_Tools::getValue('alert', false)) {
|
681 |
+
if (in_array($alert, array('sq_alert_overview', 'sq_alert_journey'))) {
|
682 |
+
SQ_Classes_Helpers_Tools::saveOptions($alert, false);
|
683 |
+
}
|
684 |
+
}
|
685 |
+
break;
|
686 |
+
/****************************
|
687 |
+
*
|
688 |
+
* Ajax
|
689 |
+
*******************************************************/
|
690 |
+
case 'sq_ajax_seosettings_save':
|
691 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
692 |
+
$response = array();
|
693 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
694 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
695 |
+
echo wp_json_encode($response);
|
696 |
+
exit();
|
697 |
+
}
|
698 |
+
|
699 |
+
|
700 |
+
$name = SQ_Classes_Helpers_Tools::getValue('input', false);
|
701 |
+
$value = SQ_Classes_Helpers_Tools::getValue('value', false);
|
702 |
+
|
703 |
+
if (isset(SQ_Classes_Helpers_Tools::$options[$name])) {
|
704 |
+
SQ_Classes_Helpers_Tools::saveOptions($name, $value);
|
705 |
+
$response['data'] = SQ_Classes_Error::showNotices(esc_html__("Saved", 'squirrly-seo'), 'sq_success');
|
706 |
+
} else {
|
707 |
+
$response['data'] = SQ_Classes_Error::showNotices(esc_html__("Could not save the changes", 'squirrly-seo'), 'sq_error');
|
708 |
+
|
709 |
+
}
|
710 |
+
|
711 |
+
echo wp_json_encode($response);
|
712 |
+
exit();
|
713 |
+
case 'sq_ajax_sla_sticky':
|
714 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
715 |
+
|
716 |
+
$response = array();
|
717 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
718 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
719 |
+
echo wp_json_encode($response);
|
720 |
+
exit();
|
721 |
+
}
|
722 |
+
|
723 |
+
SQ_Classes_Helpers_Tools::saveUserMeta('sq_auto_sticky', (int)SQ_Classes_Helpers_Tools::getValue('sq_auto_sticky'));
|
724 |
+
echo wp_json_encode(array());
|
725 |
+
exit();
|
726 |
+
case 'sq_ajax_gsc_code':
|
727 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
728 |
+
|
729 |
+
$response = array();
|
730 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
731 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
732 |
+
echo wp_json_encode($response);
|
733 |
+
exit();
|
734 |
+
}
|
735 |
+
|
736 |
+
//remove connection with Google Analytics
|
737 |
+
$code = SQ_Classes_RemoteController::getGSCToken();
|
738 |
+
|
739 |
+
if (!is_wp_error($code) && $code) {
|
740 |
+
$response['code'] = SQ_Classes_Helpers_Sanitize::checkGoogleWTCode($code);
|
741 |
+
} else {
|
742 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("Error! Could not get the code. Connect to Google Search Console and validate the connection.", 'squirrly-seo'), 'sq_error');
|
743 |
+
}
|
744 |
+
|
745 |
+
echo wp_json_encode($response);
|
746 |
+
exit();
|
747 |
+
case 'sq_ajax_ga_code':
|
748 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
749 |
+
|
750 |
+
$response = array();
|
751 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
752 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
753 |
+
echo wp_json_encode($response);
|
754 |
+
exit();
|
755 |
+
}
|
756 |
+
|
757 |
+
//remove connection with Google Analytics
|
758 |
+
$code = SQ_Classes_RemoteController::getGAToken();
|
759 |
+
if (!is_wp_error($code) && $code) {
|
760 |
+
$response['code'] = $code;
|
761 |
+
} else {
|
762 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("Error! Could not get the tracking code. Connect to Google Analytics and get the website tracking code from Admin area.", 'squirrly-seo'), 'sq_error');
|
763 |
+
}
|
764 |
+
echo wp_json_encode($response);
|
765 |
+
exit();
|
766 |
+
case 'sq_ajax_connection_check':
|
767 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
768 |
+
|
769 |
+
$response = array();
|
770 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
771 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
772 |
+
echo wp_json_encode($response);
|
773 |
+
exit();
|
774 |
+
}
|
775 |
+
|
776 |
+
//delete local checking cache
|
777 |
+
delete_transient('sq_checkin');
|
778 |
+
//check the connection again
|
779 |
+
SQ_Classes_RemoteController::checkin();
|
780 |
+
|
781 |
+
echo wp_json_encode(array());
|
782 |
+
exit();
|
783 |
+
|
784 |
+
|
785 |
+
/************************
|
786 |
+
*
|
787 |
+
* Automation
|
788 |
+
********************************************************/
|
789 |
+
case 'sq_ajax_automation_addpostype':
|
790 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
791 |
+
$response = array();
|
792 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
793 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
794 |
+
echo wp_json_encode($response);
|
795 |
+
exit();
|
796 |
+
}
|
797 |
+
|
798 |
+
//Get the new post type
|
799 |
+
$posttype = SQ_Classes_Helpers_Tools::getValue('value', false);
|
800 |
+
$filter = array('public' => true, '_builtin' => false);
|
801 |
+
$types = get_post_types($filter);
|
802 |
+
foreach ($types as $pattern => $type) {
|
803 |
+
if($post_type_obj = get_post_type_object($pattern)) {
|
804 |
+
if($post_type_obj->has_archive) {
|
805 |
+
$types['archive-' . $pattern] = 'archive-' . $pattern;
|
806 |
+
}
|
807 |
+
}
|
808 |
+
}
|
809 |
+
|
810 |
+
$filter = array('public' => true,);
|
811 |
+
$taxonomies = get_taxonomies($filter);
|
812 |
+
foreach ($taxonomies as $pattern => $type) {
|
813 |
+
$types['tax-' . $pattern] = 'tax-' . $pattern;
|
814 |
+
}
|
815 |
+
|
816 |
+
//If the post type is in the list of types
|
817 |
+
if ($posttype && in_array($posttype, $types)) {
|
818 |
+
$patterns = SQ_Classes_Helpers_Tools::getOption('patterns');
|
819 |
+
//if the post type does not already exists
|
820 |
+
if (!isset($patterns[$posttype])) {
|
821 |
+
//add the custom rights to the new post type
|
822 |
+
$patterns[$posttype] = $patterns['custom'];
|
823 |
+
$patterns[$posttype]['protected'] = 0;
|
824 |
+
//save the options in database
|
825 |
+
SQ_Classes_Helpers_Tools::saveOptions('patterns', $patterns);
|
826 |
+
|
827 |
+
$response['data'] = SQ_Classes_Error::showNotices(esc_html__("Saved", 'squirrly-seo'), 'sq_success');
|
828 |
+
echo wp_json_encode($response);
|
829 |
+
exit();
|
830 |
+
}
|
831 |
+
}
|
832 |
+
|
833 |
+
|
834 |
+
//Return error in case the post is not saved
|
835 |
+
$response['data'] = SQ_Classes_Error::showNotices(esc_html__("Could not add the post type.", 'squirrly-seo'), 'sq_error');
|
836 |
+
echo wp_json_encode($response);
|
837 |
+
exit();
|
838 |
+
case 'sq_ajax_automation_deletepostype':
|
839 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
840 |
+
$response = array();
|
841 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
|
842 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
843 |
+
echo wp_json_encode($response);
|
844 |
+
exit();
|
845 |
+
}
|
846 |
+
|
847 |
+
|
848 |
+
//Get the new post type
|
849 |
+
$posttype = SQ_Classes_Helpers_Tools::getValue('value', false);
|
850 |
+
|
851 |
+
//If the post type is in the list of types
|
852 |
+
if ($posttype && $posttype <> '') {
|
853 |
+
$patterns = SQ_Classes_Helpers_Tools::getOption('patterns');
|
854 |
+
//if the post type exists in the patterns
|
855 |
+
if (isset($patterns[$posttype])) {
|
856 |
+
//add the custom rights to the new post type
|
857 |
+
unset($patterns[$posttype]);
|
858 |
+
|
859 |
+
//save the options in database
|
860 |
+
SQ_Classes_Helpers_Tools::saveOptions('patterns', $patterns);
|
861 |
+
|
862 |
+
$response['data'] = SQ_Classes_Error::showNotices(esc_html__("Saved", 'squirrly-seo'), 'sq_success');
|
863 |
+
echo wp_json_encode($response);
|
864 |
+
exit();
|
865 |
+
}
|
866 |
+
}
|
867 |
+
|
868 |
+
|
869 |
+
//Return error in case the post is not saved
|
870 |
+
$response['data'] = SQ_Classes_Error::showNotices(esc_html__("Could not add the post type.", 'squirrly-seo'), 'sq_error');
|
871 |
+
echo wp_json_encode($response);
|
872 |
+
exit();
|
873 |
+
|
874 |
+
}
|
875 |
+
|
876 |
+
}
|
877 |
+
|
878 |
+
}
|
controllers/Sitemaps.php
CHANGED
@@ -1,727 +1,780 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Class for Sitemap Generator
|
6 |
-
*/
|
7 |
-
class SQ_Controllers_Sitemaps extends SQ_Classes_FrontController
|
8 |
-
|
9 |
-
var
|
10 |
-
|
11 |
-
|
12 |
-
var
|
13 |
-
var $
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
$
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
*
|
88 |
-
*
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
$
|
112 |
-
|
113 |
-
if (
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
$
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
'
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
if (
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
if (
|
202 |
-
|
203 |
-
}
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
);
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
echo '
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
}
|
381 |
-
}
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
$this->
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
}
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
$sq_sitemap = SQ_Classes_Helpers_Tools::getOption('sq_sitemap');
|
544 |
-
|
545 |
-
if (!get_option('permalink_structure')) {
|
546 |
-
$sitemap = '?sq_feed=' . str_replace('.
|
547 |
-
} else {
|
548 |
-
if (isset($sq_sitemap[$sitemap])) {
|
549 |
-
$sitemap = $sq_sitemap[$sitemap][0] . (isset($page) ? '?page=' . $page : '');
|
550 |
-
}
|
551 |
-
|
552 |
-
if (strpos($sitemap, '.
|
553 |
-
$sitemap .= '.
|
554 |
-
}
|
555 |
-
}
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
*
|
641 |
-
*
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
public function
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
$query->
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
$query->set('
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
global $wpdb;
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Class for Sitemap Generator
|
6 |
+
*/
|
7 |
+
class SQ_Controllers_Sitemaps extends SQ_Classes_FrontController
|
8 |
+
{
|
9 |
+
/* @var string root name */
|
10 |
+
var $root = 'sitemap';
|
11 |
+
|
12 |
+
/* @var string post limit */
|
13 |
+
var $posts_limit;
|
14 |
+
var $news_limit;
|
15 |
+
|
16 |
+
public function __construct()
|
17 |
+
{
|
18 |
+
parent::__construct();
|
19 |
+
$this->posts_limit = SQ_Classes_Helpers_Tools::getOption('sq_sitemap_perpage');
|
20 |
+
$this->news_limit = SQ_Classes_Helpers_Tools::getOption('sq_sitemap_perpage');
|
21 |
+
add_filter('sq_sitemap_style', array($this, 'getSquirrlyHeader'));
|
22 |
+
add_action('wp', array($this, 'hookPreventRedirect'), 9);
|
23 |
+
|
24 |
+
add_filter('user_trailingslashit', array($this, 'untrailingslashit'));
|
25 |
+
|
26 |
+
//Process the cron if created
|
27 |
+
add_action('sq_processPing', array($this, 'processCron'));
|
28 |
+
|
29 |
+
}
|
30 |
+
|
31 |
+
public function hookPreventRedirect()
|
32 |
+
{
|
33 |
+
global $wp_query;
|
34 |
+
|
35 |
+
if (isset($_SERVER['REQUEST_URI'])) {
|
36 |
+
if (isset($_SERVER['QUERY_STRING']) && strpos($_SERVER['QUERY_STRING'], 'sq_feed') !== false) {
|
37 |
+
parse_str($_SERVER['QUERY_STRING'], $query);
|
38 |
+
$sitemap = 'sitemap';
|
39 |
+
$page = 0;
|
40 |
+
|
41 |
+
if (isset($query['sq_feed'])) {
|
42 |
+
$sitemap = $query['sq_feed'];
|
43 |
+
$page = (isset($query['page']) ? $query['page'] : 0);
|
44 |
+
}
|
45 |
+
|
46 |
+
$wp_query->is_404 = false;
|
47 |
+
$wp_query->is_feed = true;
|
48 |
+
|
49 |
+
$this->feedRequest($sitemap, $page);
|
50 |
+
apply_filters('sq_sitemapxml', $this->showSitemap());
|
51 |
+
die();
|
52 |
+
|
53 |
+
} elseif (strpos($_SERVER['REQUEST_URI'], '.xml') !== false) {
|
54 |
+
$parseurl = parse_url($_SERVER['REQUEST_URI']);
|
55 |
+
$stemaplist = SQ_Classes_Helpers_Tools::getOption('sq_sitemap');
|
56 |
+
$page = 0;
|
57 |
+
|
58 |
+
foreach ($stemaplist as $request => $sitemap) {
|
59 |
+
if (isset($sitemap[0]) && $sitemap[1] && substr($parseurl['path'], (strrpos($parseurl['path'], '/') + 1)) == $sitemap[0]) {
|
60 |
+
|
61 |
+
$wp_query->is_404 = false;
|
62 |
+
$wp_query->is_feed = true;
|
63 |
+
|
64 |
+
if (isset($parseurl['query'])) {
|
65 |
+
parse_str($parseurl['query'], $query);
|
66 |
+
$page = (isset($query['page']) ? $query['page'] : 0);
|
67 |
+
}
|
68 |
+
|
69 |
+
$this->feedRequest($request, $page);
|
70 |
+
apply_filters('sq_sitemapxml', $this->showSitemap());
|
71 |
+
die();
|
72 |
+
}
|
73 |
+
}
|
74 |
+
} elseif (strpos($_SERVER['REQUEST_URI'], 'locations.kml') !== false) {
|
75 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_jsonld_type') == 'Organization') {
|
76 |
+
$wp_query->is_404 = false;
|
77 |
+
$wp_query->is_feed = true;
|
78 |
+
$this->model->type = 'locations';
|
79 |
+
apply_filters('sq_sitemapxml', $this->showSitemap());
|
80 |
+
die();
|
81 |
+
}
|
82 |
+
}
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Send the sitemap to Search Engines only if a page is freshly posted
|
88 |
+
*
|
89 |
+
* @param $new_status
|
90 |
+
* @param $old_status
|
91 |
+
* @param $post
|
92 |
+
*/
|
93 |
+
public function refreshSitemap($new_status, $old_status, $post)
|
94 |
+
{
|
95 |
+
if ($old_status <> $new_status && $new_status = 'publish') {
|
96 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_sitemap_ping')) {
|
97 |
+
wp_schedule_single_event(time() + 5, 'sq_processPing');
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Listen the feed call from wordpress
|
104 |
+
*
|
105 |
+
* @param string $request
|
106 |
+
* @param integer $page
|
107 |
+
*/
|
108 |
+
public function feedRequest($request = null, $page = 1)
|
109 |
+
{
|
110 |
+
global $sq_query;
|
111 |
+
$sq_query = array();
|
112 |
+
|
113 |
+
if (!isset($request)) {
|
114 |
+
return;
|
115 |
+
}
|
116 |
+
|
117 |
+
$this->model->type = $request;
|
118 |
+
|
119 |
+
if (strpos($request, 'sitemap') !== false) {
|
120 |
+
$sq_sitemap = SQ_Classes_Helpers_Tools::getOption('sq_sitemap');
|
121 |
+
|
122 |
+
//reset the previous query
|
123 |
+
wp_reset_query();
|
124 |
+
|
125 |
+
//Set Current Language
|
126 |
+
$this->model->setCurrentLanguage();
|
127 |
+
|
128 |
+
if ($request == 'sitemap') { //if sitemapindex, return
|
129 |
+
return;
|
130 |
+
}
|
131 |
+
|
132 |
+
if ($this->model->type == 'sitemap-news') {
|
133 |
+
$this->posts_limit = $this->news_limit;
|
134 |
+
}
|
135 |
+
|
136 |
+
remove_all_actions('pre_get_posts');
|
137 |
+
remove_all_actions('parse_query');
|
138 |
+
remove_all_actions('posts_where');
|
139 |
+
|
140 |
+
//init the query
|
141 |
+
$sq_query = array(
|
142 |
+
'post_type' => array('post'),
|
143 |
+
'tax_query' => array(),
|
144 |
+
'post_status' => 'publish',
|
145 |
+
'posts_per_page' => 1000,
|
146 |
+
'paged' => $page,
|
147 |
+
'orderby' => 'date',
|
148 |
+
'order' => 'DESC',
|
149 |
+
);
|
150 |
+
|
151 |
+
if ($this->model->language <> '') {
|
152 |
+
if (!SQ_Classes_Helpers_Tools::getOption('sq_sitemap_combinelangs')) {
|
153 |
+
$sq_query['lang'] = apply_filters('sq_sitemap_language', $this->model->language);
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
|
158 |
+
|
159 |
+
//show products
|
160 |
+
if ($this->model->type == 'sitemap-product') {
|
161 |
+
if (SQ_Classes_Helpers_Tools::isEcommerce() && $sq_sitemap[$this->model->type][1] == 2) {
|
162 |
+
$sq_sitemap[$this->model->type][1] = 1;
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
if (isset($sq_sitemap[$this->model->type]) && $sq_sitemap[$this->model->type][1]) {
|
167 |
+
|
168 |
+
//PREPARE CUSTOM QUERIES
|
169 |
+
switch ($this->model->type) {
|
170 |
+
case 'sitemap-news':
|
171 |
+
case 'sitemap-post':
|
172 |
+
$sq_query['posts_per_page'] = $this->posts_limit;
|
173 |
+
break;
|
174 |
+
case 'sitemap-category':
|
175 |
+
case 'sitemap-post_tag':
|
176 |
+
case 'sitemap-custom-tax':
|
177 |
+
remove_all_filters('terms_clauses'); //prevent language filters
|
178 |
+
add_filter('get_terms_fields', array($this, 'customTaxFilter'), 5, 2);
|
179 |
+
break;
|
180 |
+
case 'sitemap-page':
|
181 |
+
$sq_query['post_type'] = array('page');
|
182 |
+
$sq_query['posts_per_page'] = $this->posts_limit;
|
183 |
+
break;
|
184 |
+
case 'sitemap-attachment':
|
185 |
+
$sq_query['post_type'] = array('attachment');
|
186 |
+
$sq_query['post_status'] = array('publish', 'inherit');
|
187 |
+
break;
|
188 |
+
case 'sitemap-author':
|
189 |
+
add_filter('sq-sitemap-authors', array($this, 'authorFilter'), 5);
|
190 |
+
break;
|
191 |
+
case 'sitemap-custom-post':
|
192 |
+
$types = get_post_types(array('public' => true));
|
193 |
+
foreach (array('post', 'page', 'attachment', 'revision', 'nav_menu_item', 'product', 'wpsc-product', 'ngg_tag') as $exclude) {
|
194 |
+
if (in_array($exclude, $types)) {
|
195 |
+
unset($types[$exclude]);
|
196 |
+
}
|
197 |
+
}
|
198 |
+
|
199 |
+
foreach ($types as $type) {
|
200 |
+
$type_data = get_post_type_object($type);
|
201 |
+
if ((isset($type_data->rewrite['publicly_queryable']) && $type_data->rewrite['publicly_queryable'] == 1) || (isset($type_data->publicly_queryable) && $type_data->publicly_queryable == 1)) {
|
202 |
+
continue;
|
203 |
+
}
|
204 |
+
unset($types[$type]);
|
205 |
+
}
|
206 |
+
|
207 |
+
if (empty($types)) {
|
208 |
+
array_push($types, 'custom-post');
|
209 |
+
}
|
210 |
+
|
211 |
+
$sq_query['post_type'] = $types;
|
212 |
+
break;
|
213 |
+
case 'sitemap-product':
|
214 |
+
if (SQ_Classes_Helpers_Tools::isEcommerce()) {
|
215 |
+
$types = array('product', 'wpsc-product');
|
216 |
+
} else {
|
217 |
+
$types = array('custom-post');
|
218 |
+
}
|
219 |
+
$sq_query['post_type'] = $types;
|
220 |
+
$sq_query['posts_per_page'] = $this->posts_limit;
|
221 |
+
|
222 |
+
break;
|
223 |
+
case 'sitemap-archive':
|
224 |
+
add_filter('sq-sitemap-archive', array($this, 'archiveFilter'), 5);
|
225 |
+
break;
|
226 |
+
}
|
227 |
+
|
228 |
+
//add custom filter
|
229 |
+
do_action('do_feed_' . $this->model->type);
|
230 |
+
}
|
231 |
+
}
|
232 |
+
|
233 |
+
}
|
234 |
+
|
235 |
+
public function getSquirrlyHeader($header)
|
236 |
+
{
|
237 |
+
if ($this->model->type <> 'locations') {
|
238 |
+
$header = '<?xml-stylesheet type="text/xsl" href="/' . _SQ_ASSETS_RELATIVE_URL_ . 'css/sitemap' . ($this->model->type == 'sitemap' ? 'index' : '') . '.xsl"?>' . "\n";
|
239 |
+
$header .= '<!-- generated-on="' . date('Y-m-d\TH:i:s+00:00') . '" -->' . "\n";
|
240 |
+
$header .= '<!-- generator="Squirrly SEO Sitemap" -->' . "\n";
|
241 |
+
$header .= '<!-- generator-url="https://wordpress.org/plugins/squirrly-seo/" -->' . "\n";
|
242 |
+
$header .= '<!-- generator-version="' . esc_attr(SQ_VERSION) . '" -->' . "\n";
|
243 |
+
}
|
244 |
+
|
245 |
+
return $header;
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* Show the Sitemap Header
|
250 |
+
*
|
251 |
+
* @param array $include Include schema
|
252 |
+
*/
|
253 |
+
public function showSitemapHeader($include = array())
|
254 |
+
{
|
255 |
+
@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
|
256 |
+
|
257 |
+
header('Status: 200 OK', true, 200);
|
258 |
+
header('Content-Type: text/xml; charset=' . get_bloginfo('charset'), true);
|
259 |
+
//Generate header
|
260 |
+
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>' . "\n";
|
261 |
+
echo apply_filters('sq_sitemap_style', false);
|
262 |
+
|
263 |
+
echo '' . "\n";
|
264 |
+
|
265 |
+
$schema = array(
|
266 |
+
'image' => 'xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"',
|
267 |
+
'video' => 'xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"',
|
268 |
+
'news' => 'xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"',
|
269 |
+
'mobile' => 'xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0"',
|
270 |
+
);
|
271 |
+
|
272 |
+
if (!empty($include))
|
273 |
+
$include = array_unique($include);
|
274 |
+
|
275 |
+
switch ($this->model->type) {
|
276 |
+
case 'locations':
|
277 |
+
echo '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">' . "\n";
|
278 |
+
echo '<Document>' . "\n";
|
279 |
+
break;
|
280 |
+
case 'sitemap':
|
281 |
+
echo '<sitemapindex xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
|
282 |
+
. 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd" '
|
283 |
+
. 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"';
|
284 |
+
foreach ($include as $value) {
|
285 |
+
//echo the xmlns for the current sitemap type
|
286 |
+
echo ' ' . $schema[$value] . "\n";
|
287 |
+
}
|
288 |
+
echo '>' . "\n";
|
289 |
+
break;
|
290 |
+
case 'sitemap-news':
|
291 |
+
array_push($include, 'news');
|
292 |
+
$include = array_unique($include);
|
293 |
+
default:
|
294 |
+
echo '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
|
295 |
+
. 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" '
|
296 |
+
. 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"';
|
297 |
+
if (!empty($include))
|
298 |
+
foreach ($include as $value) {
|
299 |
+
//echo the xmlns for the current sitemap type
|
300 |
+
echo " " . $schema[$value] . " ";
|
301 |
+
}
|
302 |
+
echo '>' . "\n";
|
303 |
+
break;
|
304 |
+
}
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* Show the Sitemap Footer
|
309 |
+
*/
|
310 |
+
private function showSitemapFooter()
|
311 |
+
{
|
312 |
+
switch ($this->model->type) {
|
313 |
+
case 'locations':
|
314 |
+
echo '</Document>' . "\n";
|
315 |
+
echo '</kml>' . "\n";
|
316 |
+
break;
|
317 |
+
case 'sitemap':
|
318 |
+
echo '</sitemapindex>' . "\n";
|
319 |
+
break;
|
320 |
+
default :
|
321 |
+
echo '</urlset>' . "\n";
|
322 |
+
break;
|
323 |
+
}
|
324 |
+
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
* Create the XML sitemap
|
328 |
+
*
|
329 |
+
* @return string
|
330 |
+
*/
|
331 |
+
public function showSitemap()
|
332 |
+
{
|
333 |
+
switch ($this->model->type) {
|
334 |
+
case 'sitemap':
|
335 |
+
$this->showSitemapHeader();
|
336 |
+
$sq_sitemap = SQ_Classes_Helpers_Tools::getOption('sq_sitemap');
|
337 |
+
$patterns = SQ_Classes_Helpers_Tools::getOption('patterns');
|
338 |
+
|
339 |
+
if (!empty($sq_sitemap))
|
340 |
+
foreach ($sq_sitemap as $name => $value) {
|
341 |
+
|
342 |
+
//check if available from SEO Automation
|
343 |
+
$pname = str_replace(array('sitemap-', 'post_'), '', $name);
|
344 |
+
if (isset($patterns[$pname]['do_sitemap']) && !$patterns[$pname]['do_sitemap']) {
|
345 |
+
continue;
|
346 |
+
}
|
347 |
+
|
348 |
+
//force to show products if not preset
|
349 |
+
if ($name == 'sitemap-product' && !SQ_Classes_Helpers_Tools::isEcommerce()) {
|
350 |
+
continue;
|
351 |
+
}
|
352 |
+
|
353 |
+
if ($name !== 'sitemap' && ($value[1] == 1 || $value[1] == 2)) {
|
354 |
+
echo "\t" . '<sitemap>' . "\n";
|
355 |
+
echo "\t" . '<loc>' . esc_url($this->getXmlUrl($name)) . '</loc>' . "\n";
|
356 |
+
echo "\t" . '<lastmod>' . mysql2date('Y-m-d\TH:i:s+00:00', get_lastpostmodified('gmt'), false) . '</lastmod>' . "\n";
|
357 |
+
echo "\t" . '</sitemap>' . "\n";
|
358 |
+
|
359 |
+
|
360 |
+
if ($name == 'sitemap-post' && $count_posts = wp_count_posts()) {
|
361 |
+
if (isset($count_posts->publish) && (int)$count_posts->publish > 0 && (int)$count_posts->publish > (int)$this->posts_limit) {
|
362 |
+
$pages = ceil((int)$count_posts->publish / (int)$this->posts_limit);
|
363 |
+
for ($page = 2; $page <= $pages; $page++) {
|
364 |
+
echo "\t" . '<sitemap>' . "\n";
|
365 |
+
echo "\t" . '<loc>' . esc_url($this->getXmlUrl($name, $page)) . '</loc>' . "\n";
|
366 |
+
echo "\t" . '<lastmod>' . mysql2date('Y-m-d\TH:i:s+00:00', get_lastpostmodified('gmt'), false) . '</lastmod>' . "\n";
|
367 |
+
echo "\t" . '</sitemap>' . "\n";
|
368 |
+
}
|
369 |
+
}
|
370 |
+
}
|
371 |
+
if ($name == 'sitemap-page' && $count_posts = wp_count_posts('page')) {
|
372 |
+
if (isset($count_posts->publish) && (int)$count_posts->publish > 0 && (int)$count_posts->publish > (int)$this->posts_limit) {
|
373 |
+
$pages = ceil((int)$count_posts->publish / (int)$this->posts_limit);
|
374 |
+
for ($page = 2; $page <= $pages; $page++) {
|
375 |
+
echo "\t" . '<sitemap>' . "\n";
|
376 |
+
echo "\t" . '<loc>' . esc_url($this->getXmlUrl($name, $page)) . '</loc>' . "\n";
|
377 |
+
echo "\t" . '<lastmod>' . mysql2date('Y-m-d\TH:i:s+00:00', get_lastpostmodified('gmt'), false) . '</lastmod>' . "\n";
|
378 |
+
echo "\t" . '</sitemap>' . "\n";
|
379 |
+
}
|
380 |
+
}
|
381 |
+
}
|
382 |
+
if ($name == 'sitemap-product' && $count_posts = wp_count_posts('product')) {
|
383 |
+
if (isset($count_posts->publish) && (int)$count_posts->publish > 0 && (int)$count_posts->publish > (int)$this->posts_limit) {
|
384 |
+
$pages = ceil((int)$count_posts->publish / (int)$this->posts_limit);
|
385 |
+
for ($page = 2; $page <= $pages; $page++) {
|
386 |
+
echo "\t" . '<sitemap>' . "\n";
|
387 |
+
echo "\t" . '<loc>' . esc_url($this->getXmlUrl($name, $page)) . '</loc>' . "\n";
|
388 |
+
echo "\t" . '<lastmod>' . mysql2date('Y-m-d\TH:i:s+00:00', get_lastpostmodified('gmt'), false) . '</lastmod>' . "\n";
|
389 |
+
echo "\t" . '</sitemap>' . "\n";
|
390 |
+
}
|
391 |
+
}
|
392 |
+
}
|
393 |
+
|
394 |
+
}
|
395 |
+
}
|
396 |
+
$this->showSitemapFooter();
|
397 |
+
break;
|
398 |
+
case 'sitemap-home':
|
399 |
+
$this->showPackXml($this->model->getHomeLink());
|
400 |
+
break;
|
401 |
+
case 'sitemap-news':
|
402 |
+
$this->showPackXml($this->model->getListNews());
|
403 |
+
break;
|
404 |
+
case 'sitemap-category':
|
405 |
+
case 'sitemap-post_tag':
|
406 |
+
case 'sitemap-custom-tax':
|
407 |
+
$this->showPackXml($this->model->getListTerms());
|
408 |
+
break;
|
409 |
+
case 'sitemap-author':
|
410 |
+
$this->showPackXml($this->model->getListAuthors());
|
411 |
+
break;
|
412 |
+
case 'sitemap-archive':
|
413 |
+
$this->showPackXml($this->model->getListArchive());
|
414 |
+
break;
|
415 |
+
case 'sitemap-attachment':
|
416 |
+
$this->showPackXml($this->model->getListAttachments());
|
417 |
+
break;
|
418 |
+
case 'locations':
|
419 |
+
$this->showPackKml($this->model->getKmlXML());
|
420 |
+
break;
|
421 |
+
default:
|
422 |
+
$this->showPackXml($this->model->getListPosts());
|
423 |
+
break;
|
424 |
+
}
|
425 |
+
}
|
426 |
+
|
427 |
+
/**
|
428 |
+
* Pach the XML for each sitemap
|
429 |
+
*
|
430 |
+
* @param array $xml
|
431 |
+
* @return void
|
432 |
+
*/
|
433 |
+
public function showPackXml($xml = array())
|
434 |
+
{
|
435 |
+
if (empty($xml)) {
|
436 |
+
$xml['contains'] = '';
|
437 |
+
}
|
438 |
+
if (!isset($xml['contains'])) {
|
439 |
+
$xml['contains'] = '';
|
440 |
+
}
|
441 |
+
$this->showSitemapHeader($xml['contains']);
|
442 |
+
|
443 |
+
unset($xml['contains']);
|
444 |
+
foreach ($xml as $row) {
|
445 |
+
echo "\t" . '<url>' . "\n";
|
446 |
+
|
447 |
+
if (is_array($row)) {
|
448 |
+
echo $this->getRecursiveXml($row);
|
449 |
+
}
|
450 |
+
echo "\t" . '</url>' . "\n";
|
451 |
+
}
|
452 |
+
$this->showSitemapFooter();
|
453 |
+
unset($xml);
|
454 |
+
}
|
455 |
+
|
456 |
+
/**
|
457 |
+
* Pach the XML for each sitemap
|
458 |
+
*
|
459 |
+
* @param array $kml
|
460 |
+
* @return void
|
461 |
+
*/
|
462 |
+
public function showPackKml($kml = array())
|
463 |
+
{
|
464 |
+
|
465 |
+
$this->showSitemapHeader();
|
466 |
+
header('Content-Type: application/vnd.google-earth.kml+xml; charset=' . get_bloginfo('charset'), true);
|
467 |
+
echo $this->getRecursiveXml($kml);
|
468 |
+
$this->showSitemapFooter();
|
469 |
+
|
470 |
+
unset($kml);
|
471 |
+
}
|
472 |
+
|
473 |
+
/**
|
474 |
+
* Return XML Structure for the Sitemap
|
475 |
+
* @param $xml
|
476 |
+
* @param string $pkey
|
477 |
+
* @param int $level
|
478 |
+
* @return string XML
|
479 |
+
*/
|
480 |
+
public function getRecursiveXml($xml, $pkey = '', $level = 2)
|
481 |
+
{
|
482 |
+
$str = '';
|
483 |
+
$tab = str_repeat("\t", $level);
|
484 |
+
if (is_array($xml)) {
|
485 |
+
$cnt = 0;
|
486 |
+
foreach ($xml as $key => $data) {
|
487 |
+
if ($data === false) {
|
488 |
+
$str .= $tab . '<' . $key . '>' . "\n";
|
489 |
+
} elseif (!is_array($data) && $data <> '') {
|
490 |
+
$str .= $tab . '<' . $key . ($key == 'video:player_loc' ? ' allow_embed="yes"' : '') . '>' . $data . ((strpos($data, '?') == false && $key == 'video:player_loc') ? '' : '') . '</' . $key . '>' . "\n";
|
491 |
+
} else {
|
492 |
+
if ($this->getRecursiveXml($data) <> '') {
|
493 |
+
if (!$this->_ckeckIntergerArray($data)) {
|
494 |
+
$str .= $tab . '<' . (!is_numeric($key) ? $key : $pkey) . '>' . "\n";
|
495 |
+
}
|
496 |
+
$str .= $this->getRecursiveXml($data, $key, ($this->_ckeckIntergerArray($data) ? $level : $level + 1));
|
497 |
+
if (!$this->_ckeckIntergerArray($data)) {
|
498 |
+
$str .= $tab . '</' . (!is_numeric($key) ? $key : $pkey) . '>' . "\n";
|
499 |
+
}
|
500 |
+
}
|
501 |
+
}
|
502 |
+
$cnt++;
|
503 |
+
}
|
504 |
+
}
|
505 |
+
return $str;
|
506 |
+
}
|
507 |
+
|
508 |
+
private function _ckeckIntergerArray($data)
|
509 |
+
{
|
510 |
+
foreach ($data as $key => $value) {
|
511 |
+
if (is_numeric($key)) {
|
512 |
+
return true;
|
513 |
+
}
|
514 |
+
break;
|
515 |
+
}
|
516 |
+
return false;
|
517 |
+
}
|
518 |
+
|
519 |
+
/**
|
520 |
+
* Set the query limit
|
521 |
+
*
|
522 |
+
* @param integer $limits
|
523 |
+
* @return string
|
524 |
+
*/
|
525 |
+
public function setLimits($limits)
|
526 |
+
{
|
527 |
+
if (isset($this->posts_limit) && $this->posts_limit > 0) {
|
528 |
+
return 'LIMIT 0, ' . $this->posts_limit;
|
529 |
+
}
|
530 |
+
|
531 |
+
return '';
|
532 |
+
}
|
533 |
+
|
534 |
+
/**
|
535 |
+
* Get the url for each sitemap
|
536 |
+
*
|
537 |
+
* @param string $sitemap
|
538 |
+
* @param integer $page
|
539 |
+
* @return string
|
540 |
+
*/
|
541 |
+
public function getXmlUrl($sitemap, $page = null)
|
542 |
+
{
|
543 |
+
$sq_sitemap = SQ_Classes_Helpers_Tools::getOption('sq_sitemap');
|
544 |
+
|
545 |
+
if (!get_option('permalink_structure')) {
|
546 |
+
$sitemap = '?sq_feed=' . str_replace('.xml', '', $sitemap) . (isset($page) ? '&page=' . $page : '');
|
547 |
+
} else {
|
548 |
+
if (isset($sq_sitemap[$sitemap])) {
|
549 |
+
$sitemap = $sq_sitemap[$sitemap][0] . (isset($page) ? '?page=' . $page : '');
|
550 |
+
}
|
551 |
+
|
552 |
+
if (strpos($sitemap, '.xml') === false) {
|
553 |
+
$sitemap .= '.xml';
|
554 |
+
}
|
555 |
+
}
|
556 |
+
|
557 |
+
if ($this->model->language <> '') {
|
558 |
+
if(function_exists('pll_home_url')) {
|
559 |
+
return pll_home_url($this->model->language) . $sitemap;
|
560 |
+
}elseif (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] <> '') {
|
561 |
+
if(strpos($this->model->language, '_') !== false) {
|
562 |
+
$language = substr($this->model->language, 0, strpos($this->model->language, '_'));
|
563 |
+
if(preg_match("/\/$language\//", $_SERVER['REQUEST_URI'])) {
|
564 |
+
return esc_url(trailingslashit(home_url())) . $language . '/' . $sitemap;
|
565 |
+
}
|
566 |
+
}
|
567 |
+
}
|
568 |
+
}
|
569 |
+
|
570 |
+
return esc_url(trailingslashit(home_url())) . $sitemap;
|
571 |
+
}
|
572 |
+
|
573 |
+
public function getKmlUrl($sitemap, $page = null)
|
574 |
+
{
|
575 |
+
$sq_sitemap = SQ_Classes_Helpers_Tools::getOption('sq_sitemap');
|
576 |
+
|
577 |
+
if (!get_option('permalink_structure')) {
|
578 |
+
$sitemap = '?sq_feed=' . str_replace('.kml', '', $sitemap) . (isset($page) ? '&page=' . $page : '');
|
579 |
+
} else {
|
580 |
+
if (isset($sq_sitemap[$sitemap])) {
|
581 |
+
$sitemap = $sq_sitemap[$sitemap][0] . (isset($page) ? '?page=' . $page : '');
|
582 |
+
}
|
583 |
+
|
584 |
+
if (strpos($sitemap, '.kml') === false) {
|
585 |
+
$sitemap .= '.kml';
|
586 |
+
}
|
587 |
+
}
|
588 |
+
|
589 |
+
return esc_url(trailingslashit(home_url())) . $sitemap;
|
590 |
+
}
|
591 |
+
|
592 |
+
|
593 |
+
/**
|
594 |
+
* Process the on-time cron if called
|
595 |
+
*/
|
596 |
+
public function processCron()
|
597 |
+
{
|
598 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_Helpers_Tools');
|
599 |
+
|
600 |
+
$sq_sitemap = SQ_Classes_Helpers_Tools::getOption('sq_sitemap');
|
601 |
+
if (!empty($sq_sitemap)) {
|
602 |
+
foreach ($sq_sitemap as $name => $sitemap) {
|
603 |
+
if ($sitemap[1] == 1) { //is the default sitemap
|
604 |
+
$this->SendPing($this->getXmlUrl($name));
|
605 |
+
}
|
606 |
+
}
|
607 |
+
}
|
608 |
+
}
|
609 |
+
|
610 |
+
/**
|
611 |
+
* Ping the sitemap to Google and Bing
|
612 |
+
*
|
613 |
+
* @param string $sitemapUrl
|
614 |
+
* @return boolean
|
615 |
+
*/
|
616 |
+
protected function SendPing($sitemapUrl)
|
617 |
+
{
|
618 |
+
$success = true;
|
619 |
+
$urls = array(
|
620 |
+
"https://www.google.com/ping?sitemap=%s",
|
621 |
+
"http://www.bing.com/ping?sitemap=%s",
|
622 |
+
);
|
623 |
+
|
624 |
+
$options = array(
|
625 |
+
'method' => 'get',
|
626 |
+
'sslverify' => false,
|
627 |
+
'timeout' => 10
|
628 |
+
);
|
629 |
+
|
630 |
+
foreach ($urls as $url) {
|
631 |
+
if ($responce = SQ_Classes_ObjController::getClass('SQ_Classes_RemoteController')->sq_wpcall(sprintf($url, $sitemapUrl), $options)) {
|
632 |
+
$success = true;
|
633 |
+
}
|
634 |
+
}
|
635 |
+
|
636 |
+
return $success;
|
637 |
+
}
|
638 |
+
|
639 |
+
/**
|
640 |
+
* Delete the fizical file if exists
|
641 |
+
*
|
642 |
+
* @return boolean
|
643 |
+
*/
|
644 |
+
public function deleteSitemapFile()
|
645 |
+
{
|
646 |
+
$sq_sitemap = SQ_Classes_Helpers_Tools::getOption('sq_sitemap');
|
647 |
+
if (isset($sq_sitemap[$this->root])) {
|
648 |
+
if (file_exists(ABSPATH . $sq_sitemap[$this->root])) {
|
649 |
+
@unlink(ABSPATH . $sq_sitemap[$this->root]);
|
650 |
+
return true;
|
651 |
+
}
|
652 |
+
}
|
653 |
+
return false;
|
654 |
+
}
|
655 |
+
|
656 |
+
/**
|
657 |
+
* Remove the trailing slash from permalinks that have an extension,
|
658 |
+
* such as /sitemap.xml
|
659 |
+
*
|
660 |
+
* @param $request
|
661 |
+
* @return string
|
662 |
+
*/
|
663 |
+
public function untrailingslashit($request)
|
664 |
+
{
|
665 |
+
if (pathinfo($request, PATHINFO_EXTENSION)) {
|
666 |
+
return untrailingslashit($request);
|
667 |
+
}
|
668 |
+
return $request; // trailingslashit($request);
|
669 |
+
}
|
670 |
+
|
671 |
+
public function postFilter(&$query)
|
672 |
+
{
|
673 |
+
$query->set('tax_query', array());
|
674 |
+
}
|
675 |
+
|
676 |
+
/**
|
677 |
+
* Filter the Custom Taxonomy
|
678 |
+
*
|
679 |
+
* @param $query
|
680 |
+
* @param $args
|
681 |
+
* @return array
|
682 |
+
*/
|
683 |
+
public function customTaxFilter($query, $args)
|
684 |
+
{
|
685 |
+
global $wpdb;
|
686 |
+
$query[] = $wpdb->prepare(
|
687 |
+
"(SELECT
|
688 |
+
UNIX_TIMESTAMP(MAX(p.post_date_gmt)) as _mod_date
|
689 |
+
FROM `$wpdb->posts` p, `$wpdb->term_relationships` r
|
690 |
+
WHERE p.ID = r.object_id
|
691 |
+
AND p.post_status = %s
|
692 |
+
AND p.post_password = ''
|
693 |
+
AND r.term_taxonomy_id = tt.term_taxonomy_id
|
694 |
+
) as lastmod", 'publish'
|
695 |
+
);
|
696 |
+
|
697 |
+
|
698 |
+
return $query;
|
699 |
+
}
|
700 |
+
|
701 |
+
public function pageFilter(&$query)
|
702 |
+
{
|
703 |
+
$query->set('post_type', array('page'));
|
704 |
+
$query->set('tax_query', array());
|
705 |
+
}
|
706 |
+
|
707 |
+
public function authorFilter()
|
708 |
+
{
|
709 |
+
//get only the author with posts
|
710 |
+
add_filter('pre_user_query', array($this, 'userFilter'));
|
711 |
+
return get_users();
|
712 |
+
}
|
713 |
+
|
714 |
+
public function userFilter($query)
|
715 |
+
{
|
716 |
+
global $wpdb;
|
717 |
+
|
718 |
+
$query->query_fields .= ',p.lastmod';
|
719 |
+
$query->query_from .= ' LEFT OUTER JOIN (
|
720 |
+
SELECT MAX(post_modified) as lastmod, post_author, COUNT(*) as post_count
|
721 |
+
FROM `' . $wpdb->posts . '`
|
722 |
+
WHERE post_type = "post" AND post_status = "publish"
|
723 |
+
GROUP BY post_author
|
724 |
+
) p ON (wp_users.ID = p.post_author)';
|
725 |
+
$query->query_where .= ' AND post_count > 0 ';
|
726 |
+
}
|
727 |
+
|
728 |
+
public function customPostFilter(&$query)
|
729 |
+
{
|
730 |
+
$types = get_post_types(array('public' => true));
|
731 |
+
foreach (array('post', 'page', 'attachment', 'revision', 'nav_menu_item', 'product', 'wpsc-product') as $exclude) {
|
732 |
+
if (in_array($exclude, $types)) {
|
733 |
+
unset($types[$exclude]);
|
734 |
+
}
|
735 |
+
}
|
736 |
+
|
737 |
+
foreach ($types as $type) {
|
738 |
+
$type_data = get_post_type_object($type);
|
739 |
+
if ((isset($type_data->rewrite['feeds']) && $type_data->rewrite['feeds'] == 1) || (isset($type_data->feeds) && $type_data->feeds == 1)) {
|
740 |
+
continue;
|
741 |
+
}
|
742 |
+
unset($types[$type]);
|
743 |
+
}
|
744 |
+
|
745 |
+
if (empty($types)) {
|
746 |
+
array_push($types, 'custom-post');
|
747 |
+
}
|
748 |
+
|
749 |
+
$query->set('post_type', $types); // id of page or post
|
750 |
+
$query->set('tax_query', array());
|
751 |
+
}
|
752 |
+
|
753 |
+
public function productFilter(&$query)
|
754 |
+
{
|
755 |
+
|
756 |
+
if (!$types = SQ_Classes_Helpers_Tools::isEcommerce()) {
|
757 |
+
$types = array('custom-post');
|
758 |
+
}
|
759 |
+
$query->set('post_type', $types); // id of page or post
|
760 |
+
$query->set('tax_query', array());
|
761 |
+
}
|
762 |
+
|
763 |
+
public function archiveFilter()
|
764 |
+
{
|
765 |
+
global $wpdb;
|
766 |
+
$archives = $wpdb->get_results(
|
767 |
+
$wpdb->prepare(
|
768 |
+
"
|
769 |
+
SELECT DISTINCT YEAR(post_date_gmt) as `year`, MONTH(post_date_gmt) as `month`, max(post_date_gmt) as lastmod, count(ID) as posts
|
770 |
+
FROM `$wpdb->posts`
|
771 |
+
WHERE post_date_gmt < NOW() AND post_status = %s AND post_type = %s
|
772 |
+
GROUP BY YEAR(post_date_gmt), MONTH(post_date_gmt)
|
773 |
+
ORDER BY post_date_gmt DESC
|
774 |
+
", 'publish', 'post'
|
775 |
+
)
|
776 |
+
);
|
777 |
+
return $archives;
|
778 |
+
}
|
779 |
+
|
780 |
+
}
|
controllers/Snippet.php
CHANGED
@@ -1,281 +1,302 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Controllers_Snippet extends SQ_Classes_FrontController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
*
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
*
|
98 |
-
*/
|
99 |
-
public function
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
}
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
)
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
}
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
$json =
|
231 |
-
|
232 |
-
$
|
233 |
-
$
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
$
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
}
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Controllers_Snippet extends SQ_Classes_FrontController
|
5 |
+
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
*
|
9 |
+
*
|
10 |
+
* @var array Post Type in
|
11 |
+
*/
|
12 |
+
private $_types = array();
|
13 |
+
public $post;
|
14 |
+
|
15 |
+
public function __construct()
|
16 |
+
{
|
17 |
+
parent::__construct();
|
18 |
+
add_action('admin_bar_menu', array($this, 'hookTopmenuFrontend'), 11);
|
19 |
+
|
20 |
+
if (is_admin()) {
|
21 |
+
add_action('category_add_form_fields', array($this, 'hookTermsPage'), 10);
|
22 |
+
|
23 |
+
$taxonomies = get_taxonomies(array('public' => true));
|
24 |
+
if (!empty($taxonomies)) {
|
25 |
+
foreach ($taxonomies as $taxonomy) {
|
26 |
+
if (is_string($taxonomy) && $taxonomy <> '') {
|
27 |
+
add_filter($taxonomy . '_edit_form', array($this, 'hookTermsPage'), 10);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Init Snippet and return the view for Admin Bar
|
36 |
+
*
|
37 |
+
* @return mixed
|
38 |
+
*/
|
39 |
+
public function init()
|
40 |
+
{
|
41 |
+
if (is_rtl()) {
|
42 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('sqbootstrap.rtl', array('trigger' => true, 'media' => 'all'));
|
43 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('rtl', array('trigger' => true, 'media' => 'all'));
|
44 |
+
} else {
|
45 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('sqbootstrap', array('trigger' => true, 'media' => 'all'));
|
46 |
+
}
|
47 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('fontawesome', array('trigger' => true, 'media' => 'all'));
|
48 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('highlight', array('trigger' => true, 'media' => 'all'));
|
49 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('patterns', array('trigger' => true, 'media' => 'all'));
|
50 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('snippet', array('trigger' => true, 'media' => 'all'));
|
51 |
+
|
52 |
+
|
53 |
+
if(is_admin()) {
|
54 |
+
global $post;
|
55 |
+
|
56 |
+
//Set the current post in admin panel
|
57 |
+
if (isset($post->ID) && $post->ID > 0) {
|
58 |
+
$this->post = SQ_Classes_ObjController::getClass('SQ_Models_Frontend')->setPost($post)->getPost();
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
return $this->get_view('Blocks/Snippet');
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Hook the Head sequence in frontend when user is logged in
|
67 |
+
*/
|
68 |
+
public function hookFronthead()
|
69 |
+
{
|
70 |
+
if (SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
71 |
+
//prevent some compatibility errors with other plugins
|
72 |
+
remove_all_actions('print_media_templates');
|
73 |
+
|
74 |
+
//loade the media library
|
75 |
+
@wp_enqueue_media();
|
76 |
+
|
77 |
+
//Set the current post domain with all the data
|
78 |
+
$this->post = SQ_Classes_ObjController::getClass('SQ_Models_Frontend')->getPost();
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Set the post in SEO Snippet for Bulk SEO
|
85 |
+
*
|
86 |
+
* @param $post
|
87 |
+
* @return $this
|
88 |
+
*/
|
89 |
+
public function setPost($post)
|
90 |
+
{
|
91 |
+
$this->post = $post;
|
92 |
+
|
93 |
+
return $this;
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Hook pages like Terms and Categories
|
98 |
+
*/
|
99 |
+
public function hookTermsPage()
|
100 |
+
{
|
101 |
+
echo $this->getSnippetDiv(SQ_Classes_ObjController::getClass('SQ_Controllers_Snippet')->init());
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Get the Snippet div for different pages
|
106 |
+
*
|
107 |
+
* @param $content
|
108 |
+
* @param string $attributes
|
109 |
+
* @return string
|
110 |
+
*/
|
111 |
+
public function getSnippetDiv($content, $attributes = '')
|
112 |
+
{
|
113 |
+
|
114 |
+
if (!apply_filters('sq_load_snippet', true) || !SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
115 |
+
return false;
|
116 |
+
}
|
117 |
+
|
118 |
+
return '<div id="sq_blocksnippet" ' . $attributes . ' class="sq_blocksnippet sq-shadow-sm sq-border-bottom sq-mb-4"><h2 class="hndle"><span class="sq_logo" style="margin-right: 5px;width: 30px !important;height: 30px !important;"></span>' . esc_html__("Squirrly SEO Snippet", 'squirrly-seo') . '</span></h2><div class="inside">' . $content . '</div></div>';
|
119 |
+
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Add a menu in Frontend Admin Bar
|
124 |
+
*
|
125 |
+
* @param WP_Admin_Bar $wp_admin_bar
|
126 |
+
*/
|
127 |
+
public function hookTopmenuFrontend($wp_admin_bar)
|
128 |
+
{
|
129 |
+
global $wp_the_query;
|
130 |
+
|
131 |
+
if (is_admin() || !function_exists('is_user_logged_in') || !is_user_logged_in()) {
|
132 |
+
return;
|
133 |
+
}
|
134 |
+
|
135 |
+
//If user set not to load Squirrly in frontend
|
136 |
+
if (!SQ_Classes_Helpers_Tools::getOption('sq_use_frontend')) {
|
137 |
+
return;
|
138 |
+
}
|
139 |
+
|
140 |
+
if (!$wp_the_query || !method_exists($wp_the_query, 'get_queried_object') || !function_exists('current_user_can')) {
|
141 |
+
return;
|
142 |
+
}
|
143 |
+
|
144 |
+
if (!apply_filters('sq_load_snippet', true) || !SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
145 |
+
return;
|
146 |
+
}
|
147 |
+
|
148 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippets')) {
|
149 |
+
$current_object = $wp_the_query->get_queried_object();
|
150 |
+
|
151 |
+
if (empty($current_object))
|
152 |
+
return;
|
153 |
+
|
154 |
+
if (!empty($current_object->post_type)
|
155 |
+
&& ($post_type_object = get_post_type_object($current_object->post_type))
|
156 |
+
&& SQ_Classes_Helpers_Tools::userCan('edit_post', $current_object->ID)
|
157 |
+
&& $post_type_object->show_in_admin_bar
|
158 |
+
&& $edit_post_link = get_edit_post_link($current_object->ID)
|
159 |
+
) {
|
160 |
+
} elseif (!empty($current_object->taxonomy)
|
161 |
+
&& ($tax = get_taxonomy($current_object->taxonomy))
|
162 |
+
&& SQ_Classes_Helpers_Tools::userCan('edit_term', $current_object->term_id)
|
163 |
+
&& $edit_term_link = get_edit_term_link($current_object->term_id, $current_object->taxonomy)
|
164 |
+
) {
|
165 |
+
} else {
|
166 |
+
return;
|
167 |
+
}
|
168 |
+
}
|
169 |
+
|
170 |
+
try {
|
171 |
+
|
172 |
+
//Dev Kit
|
173 |
+
$style = '';
|
174 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_devkit_logo')) {
|
175 |
+
$style = '<style>.sq_logo{background-image:url("' . SQ_Classes_Helpers_Tools::getOption('sq_devkit_logo') . '") !important;background-size: 100%; background-repeat: no-repeat; background-position: center;}</style>';
|
176 |
+
}
|
177 |
+
|
178 |
+
$wp_admin_bar->add_node(
|
179 |
+
array(
|
180 |
+
'id' => 'sq_bar_menu',
|
181 |
+
'title' => $style . '<span class="sq_logo"></span> ' . esc_html__("Custom SEO", 'squirrly-seo'),
|
182 |
+
'parent' => 'top-secondary',
|
183 |
+
)
|
184 |
+
);
|
185 |
+
|
186 |
+
|
187 |
+
$wp_admin_bar->add_menu(
|
188 |
+
array(
|
189 |
+
'id' => 'sq_bar_submenu',
|
190 |
+
'parent' => 'sq_bar_menu',
|
191 |
+
'meta' => array(
|
192 |
+
'html' => $this->getSnippetDiv(SQ_Classes_ObjController::getClass('SQ_Controllers_Snippet')->init(), 'data-snippet="topmenu"'),
|
193 |
+
'tabindex' => PHP_INT_MAX,
|
194 |
+
),
|
195 |
+
)
|
196 |
+
);
|
197 |
+
} catch (Exception $e) {
|
198 |
+
|
199 |
+
}
|
200 |
+
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Called when Post action is triggered
|
205 |
+
*
|
206 |
+
* @return void
|
207 |
+
*/
|
208 |
+
public function action()
|
209 |
+
{
|
210 |
+
parent::action();
|
211 |
+
|
212 |
+
$response = array();
|
213 |
+
if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
|
214 |
+
$response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", 'squirrly-seo'), 'sq_error');
|
215 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
216 |
+
echo wp_json_encode($response);
|
217 |
+
exit();
|
218 |
+
}
|
219 |
+
|
220 |
+
switch (SQ_Classes_Helpers_Tools::getValue('action')) {
|
221 |
+
case 'sq_saveseo':
|
222 |
+
$sq_hash = SQ_Classes_Helpers_Tools::getValue('sq_hash', false);
|
223 |
+
$post_id = (int)SQ_Classes_Helpers_Tools::getValue('post_id', 0);
|
224 |
+
$term_id = (int)SQ_Classes_Helpers_Tools::getValue('term_id', 0);
|
225 |
+
$taxonomy = SQ_Classes_Helpers_Tools::getValue('taxonomy', '');
|
226 |
+
$post_type = SQ_Classes_Helpers_Tools::getValue('post_type', '');
|
227 |
+
|
228 |
+
//Save the SEO settings
|
229 |
+
if ($this->model->saveSEO($post_id, $term_id, $taxonomy, $post_type)) {
|
230 |
+
$json['saved'] = $sq_hash;
|
231 |
+
} else {
|
232 |
+
global $wpdb;
|
233 |
+
$json['error'] = sprintf(esc_html__("Could not save the snippet. Please check the database table %s integrity.", 'squirrly-seo'), '<strong>' . $wpdb->prefix . _SQ_DB_ . '</strong>');
|
234 |
+
}
|
235 |
+
|
236 |
+
if ($this->post = $this->model->getCurrentSnippet($post_id, $term_id, $taxonomy, $post_type)) {
|
237 |
+
$json['html'] = $this->get_view('Blocks/Snippet');
|
238 |
+
}
|
239 |
+
if (SQ_Classes_Helpers_Tools::isAjax()) {
|
240 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
241 |
+
SQ_Classes_Helpers_Tools::emptyCache();
|
242 |
+
|
243 |
+
echo wp_json_encode($json);
|
244 |
+
exit();
|
245 |
+
}
|
246 |
+
break;
|
247 |
+
|
248 |
+
case 'sq_getsnippet':
|
249 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
250 |
+
|
251 |
+
$json = array();
|
252 |
+
$post_id = (int)SQ_Classes_Helpers_Tools::getValue('post_id', 0);
|
253 |
+
$term_id = (int)SQ_Classes_Helpers_Tools::getValue('term_id', 0);
|
254 |
+
$taxonomy = SQ_Classes_Helpers_Tools::getValue('taxonomy', 'category');
|
255 |
+
$post_type = SQ_Classes_Helpers_Tools::getValue('post_type', 'post');
|
256 |
+
|
257 |
+
if ($this->post = $this->model->getCurrentSnippet($post_id, $term_id, $taxonomy, $post_type)) {
|
258 |
+
$json['html'] = $this->get_view('Blocks/Snippet');
|
259 |
+
|
260 |
+
//Support for international languages
|
261 |
+
if (function_exists('iconv') && SQ_Classes_Helpers_Tools::getOption('sq_non_utf8_support')) {
|
262 |
+
if (strpos(get_bloginfo("language"), 'en') === false) {
|
263 |
+
$json['html'] = iconv('UTF-8', 'UTF-8//IGNORE', $json['html']);
|
264 |
+
}
|
265 |
+
}
|
266 |
+
|
267 |
+
if (SQ_Classes_Error::isError()) {
|
268 |
+
$json['error'] = SQ_Classes_Error::getError();
|
269 |
+
}
|
270 |
+
|
271 |
+
} else {
|
272 |
+
$json['error'] = 'Not found!';
|
273 |
+
}
|
274 |
+
|
275 |
+
echo wp_json_encode($json);
|
276 |
+
exit();
|
277 |
+
case 'sq_previewsnippet':
|
278 |
+
|
279 |
+
$snippet = array();
|
280 |
+
try {
|
281 |
+
|
282 |
+
if (SQ_Classes_Helpers_Tools::getValue('url') <> '') {
|
283 |
+
$url = SQ_Classes_Helpers_Tools::getValue('url');
|
284 |
+
} else {
|
285 |
+
$url = get_bloginfo('url');
|
286 |
+
}
|
287 |
+
|
288 |
+
$snippet = SQ_Classes_RemoteController::getSnippet($url);
|
289 |
+
|
290 |
+
} catch (Exception $e) {
|
291 |
+
}
|
292 |
+
|
293 |
+
if (SQ_Classes_Helpers_Tools::isAjax()) {
|
294 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
295 |
+
echo wp_json_encode($snippet);
|
296 |
+
exit();
|
297 |
+
}
|
298 |
+
}
|
299 |
+
}
|
300 |
+
|
301 |
+
|
302 |
+
}
|
controllers/Uninstall.php
CHANGED
@@ -1,16 +1,19 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Uninstall Options
|
6 |
-
*/
|
7 |
-
class SQ_Controllers_Uninstall extends SQ_Classes_FrontController
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Uninstall Options
|
6 |
+
*/
|
7 |
+
class SQ_Controllers_Uninstall extends SQ_Classes_FrontController
|
8 |
+
{
|
9 |
+
|
10 |
+
public function hookHead()
|
11 |
+
{
|
12 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('uninstall');
|
13 |
+
}
|
14 |
+
|
15 |
+
public function hookFooter()
|
16 |
+
{
|
17 |
+
$this->show_view('Blocks/Uninstall');
|
18 |
+
}
|
19 |
+
}
|
core/BlockAssistant.php
CHANGED
@@ -1,9 +1,11 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Core_BlockAssistant extends SQ_Classes_BlockController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Core_BlockAssistant extends SQ_Classes_BlockController
|
5 |
+
{
|
6 |
+
|
7 |
+
public function init()
|
8 |
+
{
|
9 |
+
$this->show_view('Blocks/Assistant');
|
10 |
+
}
|
11 |
+
}
|
core/BlockConnect.php
CHANGED
@@ -1,55 +1,60 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Core_BlockConnect extends SQ_Classes_BlockController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
}
|
55 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Core_BlockConnect extends SQ_Classes_BlockController
|
5 |
+
{
|
6 |
+
|
7 |
+
public $message;
|
8 |
+
|
9 |
+
public function init()
|
10 |
+
{
|
11 |
+
/* If logged in, then return */
|
12 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_api') == '') {
|
13 |
+
return;
|
14 |
+
}
|
15 |
+
|
16 |
+
$this->show_view('Blocks/Connect');
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Called for sq_login on Post action
|
21 |
+
* Login or register a user
|
22 |
+
*/
|
23 |
+
public function action()
|
24 |
+
{
|
25 |
+
switch (SQ_Classes_Helpers_Tools::getValue('action')) {
|
26 |
+
//sign-up action
|
27 |
+
case 'sq_cloud_connect':
|
28 |
+
$this->connectToCloud();
|
29 |
+
break;
|
30 |
+
|
31 |
+
case 'sq_cloud_disconnect':
|
32 |
+
$this->disconnectFromCloud();
|
33 |
+
break;
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
public function connectToCloud()
|
38 |
+
{
|
39 |
+
if(function_exists('rest_get_url_prefix')) {
|
40 |
+
$apiUrl = trim(rest_get_url_prefix(), '/');
|
41 |
+
}elseif(function_exists('rest_url')) {
|
42 |
+
$apiUrl = trim(parse_url(rest_url(), PHP_URL_PATH), '/');
|
43 |
+
}
|
44 |
+
|
45 |
+
//Make sure the website exists on the Cloud
|
46 |
+
SQ_Classes_RemoteController::connect();
|
47 |
+
|
48 |
+
if ($token = SQ_Classes_RemoteController::getCloudToken(array('wp-json' => $apiUrl))) {
|
49 |
+
if(isset($token->token) && $token->token <> '') {
|
50 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_cloud_token', $token->token);
|
51 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_cloud_connect', 1);
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
public function disconnectFromCloud()
|
57 |
+
{
|
58 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_cloud_connect', 0);
|
59 |
+
}
|
60 |
+
}
|
core/BlockFeatures.php
CHANGED
@@ -1,661 +1,664 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Core_BlockFeatures extends SQ_Classes_BlockController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
'
|
19 |
-
'
|
20 |
-
'
|
21 |
-
'
|
22 |
-
'
|
23 |
-
'
|
24 |
-
'
|
25 |
-
'
|
26 |
-
|
27 |
-
|
28 |
-
'
|
29 |
-
|
30 |
-
|
31 |
-
'
|
32 |
-
'
|
33 |
-
'
|
34 |
-
'
|
35 |
-
'
|
36 |
-
'
|
37 |
-
'
|
38 |
-
'
|
39 |
-
|
40 |
-
|
41 |
-
'
|
42 |
-
|
43 |
-
|
44 |
-
'
|
45 |
-
'
|
46 |
-
'
|
47 |
-
'
|
48 |
-
'
|
49 |
-
'
|
50 |
-
'
|
51 |
-
'
|
52 |
-
|
53 |
-
|
54 |
-
'
|
55 |
-
|
56 |
-
|
57 |
-
'
|
58 |
-
'
|
59 |
-
'
|
60 |
-
'
|
61 |
-
'
|
62 |
-
'
|
63 |
-
'
|
64 |
-
'
|
65 |
-
|
66 |
-
|
67 |
-
'
|
68 |
-
|
69 |
-
|
70 |
-
'
|
71 |
-
'
|
72 |
-
'
|
73 |
-
'
|
74 |
-
'
|
75 |
-
'
|
76 |
-
'
|
77 |
-
'
|
78 |
-
|
79 |
-
|
80 |
-
'
|
81 |
-
|
82 |
-
|
83 |
-
'
|
84 |
-
'
|
85 |
-
'
|
86 |
-
'
|
87 |
-
'
|
88 |
-
'
|
89 |
-
'
|
90 |
-
'
|
91 |
-
|
92 |
-
|
93 |
-
'
|
94 |
-
|
95 |
-
|
96 |
-
'
|
97 |
-
'
|
98 |
-
'
|
99 |
-
'
|
100 |
-
'
|
101 |
-
'
|
102 |
-
'
|
103 |
-
'
|
104 |
-
|
105 |
-
|
106 |
-
'
|
107 |
-
|
108 |
-
|
109 |
-
'
|
110 |
-
'
|
111 |
-
'
|
112 |
-
'
|
113 |
-
'
|
114 |
-
'
|
115 |
-
'
|
116 |
-
'
|
117 |
-
|
118 |
-
|
119 |
-
'
|
120 |
-
|
121 |
-
|
122 |
-
'
|
123 |
-
'
|
124 |
-
'
|
125 |
-
'
|
126 |
-
'
|
127 |
-
'
|
128 |
-
'
|
129 |
-
'
|
130 |
-
|
131 |
-
|
132 |
-
'
|
133 |
-
|
134 |
-
|
135 |
-
'
|
136 |
-
'
|
137 |
-
'
|
138 |
-
'
|
139 |
-
'
|
140 |
-
'
|
141 |
-
'
|
142 |
-
'
|
143 |
-
|
144 |
-
|
145 |
-
'
|
146 |
-
|
147 |
-
|
148 |
-
'
|
149 |
-
'
|
150 |
-
'
|
151 |
-
'
|
152 |
-
'
|
153 |
-
'
|
154 |
-
'
|
155 |
-
'
|
156 |
-
|
157 |
-
|
158 |
-
'
|
159 |
-
|
160 |
-
|
161 |
-
'
|
162 |
-
'
|
163 |
-
'
|
164 |
-
'
|
165 |
-
'
|
166 |
-
'
|
167 |
-
'
|
168 |
-
'
|
169 |
-
|
170 |
-
|
171 |
-
'
|
172 |
-
|
173 |
-
|
174 |
-
'
|
175 |
-
'
|
176 |
-
'
|
177 |
-
'
|
178 |
-
'
|
179 |
-
'
|
180 |
-
'
|
181 |
-
'
|
182 |
-
|
183 |
-
|
184 |
-
'
|
185 |
-
|
186 |
-
|
187 |
-
'
|
188 |
-
'
|
189 |
-
'
|
190 |
-
'
|
191 |
-
'
|
192 |
-
'
|
193 |
-
'
|
194 |
-
'
|
195 |
-
|
196 |
-
|
197 |
-
'
|
198 |
-
|
199 |
-
|
200 |
-
'
|
201 |
-
'
|
202 |
-
'
|
203 |
-
'
|
204 |
-
'
|
205 |
-
'
|
206 |
-
'
|
207 |
-
'
|
208 |
-
|
209 |
-
|
210 |
-
'
|
211 |
-
|
212 |
-
|
213 |
-
'
|
214 |
-
'
|
215 |
-
'
|
216 |
-
'
|
217 |
-
'
|
218 |
-
'
|
219 |
-
'
|
220 |
-
'
|
221 |
-
|
222 |
-
|
223 |
-
'
|
224 |
-
|
225 |
-
|
226 |
-
'
|
227 |
-
'
|
228 |
-
'
|
229 |
-
'
|
230 |
-
'
|
231 |
-
'
|
232 |
-
'
|
233 |
-
'
|
234 |
-
|
235 |
-
|
236 |
-
'
|
237 |
-
|
238 |
-
|
239 |
-
'
|
240 |
-
'
|
241 |
-
'
|
242 |
-
'
|
243 |
-
'
|
244 |
-
'
|
245 |
-
'
|
246 |
-
'
|
247 |
-
|
248 |
-
|
249 |
-
'
|
250 |
-
|
251 |
-
|
252 |
-
'
|
253 |
-
'
|
254 |
-
'
|
255 |
-
'
|
256 |
-
'
|
257 |
-
'
|
258 |
-
'
|
259 |
-
'
|
260 |
-
|
261 |
-
|
262 |
-
'
|
263 |
-
|
264 |
-
|
265 |
-
'
|
266 |
-
'
|
267 |
-
'
|
268 |
-
'
|
269 |
-
'
|
270 |
-
'
|
271 |
-
'
|
272 |
-
'
|
273 |
-
|
274 |
-
|
275 |
-
'
|
276 |
-
|
277 |
-
|
278 |
-
'
|
279 |
-
'
|
280 |
-
'
|
281 |
-
'
|
282 |
-
'
|
283 |
-
'
|
284 |
-
'
|
285 |
-
'
|
286 |
-
|
287 |
-
|
288 |
-
'
|
289 |
-
|
290 |
-
|
291 |
-
'
|
292 |
-
'
|
293 |
-
'
|
294 |
-
'
|
295 |
-
'
|
296 |
-
'
|
297 |
-
'
|
298 |
-
'
|
299 |
-
|
300 |
-
|
301 |
-
'
|
302 |
-
|
303 |
-
|
304 |
-
'
|
305 |
-
'
|
306 |
-
'
|
307 |
-
'
|
308 |
-
'
|
309 |
-
'
|
310 |
-
'
|
311 |
-
'
|
312 |
-
|
313 |
-
|
314 |
-
'
|
315 |
-
|
316 |
-
|
317 |
-
'
|
318 |
-
'
|
319 |
-
'
|
320 |
-
'
|
321 |
-
'
|
322 |
-
'
|
323 |
-
'
|
324 |
-
'
|
325 |
-
|
326 |
-
|
327 |
-
'
|
328 |
-
|
329 |
-
|
330 |
-
'
|
331 |
-
'
|
332 |
-
'
|
333 |
-
'
|
334 |
-
'
|
335 |
-
'
|
336 |
-
'
|
337 |
-
'
|
338 |
-
|
339 |
-
|
340 |
-
'
|
341 |
-
|
342 |
-
|
343 |
-
'
|
344 |
-
'
|
345 |
-
'
|
346 |
-
'
|
347 |
-
'
|
348 |
-
'
|
349 |
-
'
|
350 |
-
'
|
351 |
-
|
352 |
-
|
353 |
-
'
|
354 |
-
|
355 |
-
|
356 |
-
'
|
357 |
-
'
|
358 |
-
'
|
359 |
-
'
|
360 |
-
'
|
361 |
-
'
|
362 |
-
'
|
363 |
-
'
|
364 |
-
|
365 |
-
|
366 |
-
'
|
367 |
-
|
368 |
-
|
369 |
-
'
|
370 |
-
'
|
371 |
-
'
|
372 |
-
'
|
373 |
-
'
|
374 |
-
'
|
375 |
-
'
|
376 |
-
'
|
377 |
-
|
378 |
-
|
379 |
-
'
|
380 |
-
|
381 |
-
|
382 |
-
'
|
383 |
-
'
|
384 |
-
'
|
385 |
-
'
|
386 |
-
'
|
387 |
-
'
|
388 |
-
'
|
389 |
-
'
|
390 |
-
|
391 |
-
|
392 |
-
'
|
393 |
-
|
394 |
-
|
395 |
-
'
|
396 |
-
'
|
397 |
-
'
|
398 |
-
'
|
399 |
-
'
|
400 |
-
'
|
401 |
-
'
|
402 |
-
'
|
403 |
-
|
404 |
-
|
405 |
-
'
|
406 |
-
|
407 |
-
|
408 |
-
'
|
409 |
-
'
|
410 |
-
'
|
411 |
-
'
|
412 |
-
'
|
413 |
-
'
|
414 |
-
'
|
415 |
-
'
|
416 |
-
|
417 |
-
|
418 |
-
'
|
419 |
-
|
420 |
-
|
421 |
-
'
|
422 |
-
'
|
423 |
-
'
|
424 |
-
'
|
425 |
-
'
|
426 |
-
'
|
427 |
-
'
|
428 |
-
'
|
429 |
-
|
430 |
-
|
431 |
-
'
|
432 |
-
|
433 |
-
|
434 |
-
'
|
435 |
-
'
|
436 |
-
'
|
437 |
-
'
|
438 |
-
'
|
439 |
-
'
|
440 |
-
'
|
441 |
-
'
|
442 |
-
|
443 |
-
|
444 |
-
'
|
445 |
-
|
446 |
-
|
447 |
-
'
|
448 |
-
'
|
449 |
-
'
|
450 |
-
'
|
451 |
-
'
|
452 |
-
'
|
453 |
-
'
|
454 |
-
'
|
455 |
-
|
456 |
-
|
457 |
-
'
|
458 |
-
|
459 |
-
|
460 |
-
'
|
461 |
-
'
|
462 |
-
'
|
463 |
-
'
|
464 |
-
'
|
465 |
-
'
|
466 |
-
'
|
467 |
-
'
|
468 |
-
|
469 |
-
|
470 |
-
'
|
471 |
-
|
472 |
-
|
473 |
-
'
|
474 |
-
'
|
475 |
-
'
|
476 |
-
'
|
477 |
-
'
|
478 |
-
'
|
479 |
-
'
|
480 |
-
'
|
481 |
-
|
482 |
-
|
483 |
-
'
|
484 |
-
|
485 |
-
|
486 |
-
'
|
487 |
-
'
|
488 |
-
'
|
489 |
-
'
|
490 |
-
'
|
491 |
-
'
|
492 |
-
'
|
493 |
-
'
|
494 |
-
|
495 |
-
|
496 |
-
'
|
497 |
-
|
498 |
-
|
499 |
-
'
|
500 |
-
'
|
501 |
-
'
|
502 |
-
'
|
503 |
-
'
|
504 |
-
'
|
505 |
-
'
|
506 |
-
'
|
507 |
-
|
508 |
-
|
509 |
-
'
|
510 |
-
|
511 |
-
|
512 |
-
'
|
513 |
-
'
|
514 |
-
'
|
515 |
-
'
|
516 |
-
'
|
517 |
-
'
|
518 |
-
'
|
519 |
-
'
|
520 |
-
|
521 |
-
|
522 |
-
'
|
523 |
-
|
524 |
-
|
525 |
-
'
|
526 |
-
'
|
527 |
-
'
|
528 |
-
'
|
529 |
-
'
|
530 |
-
'
|
531 |
-
'
|
532 |
-
'
|
533 |
-
|
534 |
-
|
535 |
-
'
|
536 |
-
|
537 |
-
|
538 |
-
'
|
539 |
-
'
|
540 |
-
'
|
541 |
-
'
|
542 |
-
'
|
543 |
-
'
|
544 |
-
'
|
545 |
-
'
|
546 |
-
|
547 |
-
|
548 |
-
'
|
549 |
-
|
550 |
-
|
551 |
-
'
|
552 |
-
'
|
553 |
-
'
|
554 |
-
'
|
555 |
-
'
|
556 |
-
'
|
557 |
-
'
|
558 |
-
'
|
559 |
-
|
560 |
-
|
561 |
-
'
|
562 |
-
|
563 |
-
|
564 |
-
'
|
565 |
-
'
|
566 |
-
'
|
567 |
-
'
|
568 |
-
'
|
569 |
-
'
|
570 |
-
'
|
571 |
-
'
|
572 |
-
|
573 |
-
|
574 |
-
'
|
575 |
-
|
576 |
-
|
577 |
-
'
|
578 |
-
'
|
579 |
-
'
|
580 |
-
'
|
581 |
-
'
|
582 |
-
'
|
583 |
-
'
|
584 |
-
'
|
585 |
-
|
586 |
-
|
587 |
-
'
|
588 |
-
|
589 |
-
|
590 |
-
'
|
591 |
-
'
|
592 |
-
'
|
593 |
-
'
|
594 |
-
'
|
595 |
-
'
|
596 |
-
'
|
597 |
-
'
|
598 |
-
|
599 |
-
|
600 |
-
'
|
601 |
-
|
602 |
-
|
603 |
-
'
|
604 |
-
'
|
605 |
-
'
|
606 |
-
'
|
607 |
-
'
|
608 |
-
'
|
609 |
-
'
|
610 |
-
'
|
611 |
-
|
612 |
-
|
613 |
-
'
|
614 |
-
|
615 |
-
|
616 |
-
'
|
617 |
-
'
|
618 |
-
'
|
619 |
-
'
|
620 |
-
'
|
621 |
-
'
|
622 |
-
'
|
623 |
-
'
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
'
|
631 |
-
'
|
632 |
-
'
|
633 |
-
'
|
634 |
-
'
|
635 |
-
'
|
636 |
-
'
|
637 |
-
'
|
638 |
-
|
639 |
-
|
640 |
-
'
|
641 |
-
|
642 |
-
|
643 |
-
'
|
644 |
-
'
|
645 |
-
'
|
646 |
-
'
|
647 |
-
'
|
648 |
-
'
|
649 |
-
'
|
650 |
-
'
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Core_BlockFeatures extends SQ_Classes_BlockController
|
5 |
+
{
|
6 |
+
|
7 |
+
public function init()
|
8 |
+
{
|
9 |
+
$this->show_view('Blocks/Features');
|
10 |
+
}
|
11 |
+
|
12 |
+
public function getFeatures()
|
13 |
+
{
|
14 |
+
$connect = SQ_Classes_Helpers_Tools::getOption('connect');
|
15 |
+
$sitemap = SQ_Classes_Helpers_Tools::getOption('sq_sitemap');
|
16 |
+
$features = array(
|
17 |
+
array(
|
18 |
+
'title' => "Squirrly Cloud App",
|
19 |
+
'description' => "Many Squirrly features work from <bold>cloud.squirrly.co</bold> and helps you optimize the content and manage the keywords, audits and rankings.",
|
20 |
+
'mode' => "Free",
|
21 |
+
'option' => false,
|
22 |
+
'active' => true,
|
23 |
+
'optional' => false,
|
24 |
+
'connection' => true,
|
25 |
+
'logo' => 'squirrly.png',
|
26 |
+
'link' => SQ_Classes_RemoteController::getMySquirrlyLink('dashboard'),
|
27 |
+
'details' => 'https://howto.squirrly.co/kb/squirrly-cloud-app/',
|
28 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_panel'),
|
29 |
+
), //Squirrly Cloud
|
30 |
+
array(
|
31 |
+
'title' => "14 Days Journey Course",
|
32 |
+
'description' => "<strong>Improve your Online Presence</strong> by knowing how your website is performing. All you need now is to start driving One of your most valuable pages to <strong>Better Rankings</strong>.",
|
33 |
+
'mode' => "Free",
|
34 |
+
'option' => false,
|
35 |
+
'active' => SQ_Classes_Helpers_Tools::getOption('sq_seojourney'),
|
36 |
+
'optional' => false,
|
37 |
+
'connection' => true,
|
38 |
+
'logo' => 'journey_92.png',
|
39 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_onboarding', 'journey1'),
|
40 |
+
'details' => 'https://howto.squirrly.co/kb/install-squirrly-seo-plugin/#journey',
|
41 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_journey'),
|
42 |
+
), //14 Days Journey Course
|
43 |
+
array(
|
44 |
+
'title' => "Next SEO Goals",
|
45 |
+
'description' => "The AI SEO Consultant with <strong>over 100+ signals</strong> that prepares your goals to take you closer to the first page of Google.",
|
46 |
+
'mode' => "Free",
|
47 |
+
'option' => false,
|
48 |
+
'active' => true,
|
49 |
+
'optional' => false,
|
50 |
+
'connection' => true,
|
51 |
+
'logo' => 'goals_92.png',
|
52 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_dashboard', '', array('#tasks')),
|
53 |
+
'details' => 'https://howto.squirrly.co/kb/next-seo-goals/',
|
54 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_seogoals'),
|
55 |
+
),//Next SEO Goals
|
56 |
+
array(
|
57 |
+
'title' => "Progress & Achievements",
|
58 |
+
'description' => "Displays <strong>Success Messages</strong> and <strong>Progress & Achievements</strong> for SEO Goals, Focus Pages, Audits, and Rankings",
|
59 |
+
'mode' => "Free",
|
60 |
+
'option' => false,
|
61 |
+
'active' => true,
|
62 |
+
'optional' => false,
|
63 |
+
'connection' => true,
|
64 |
+
'logo' => 'progress_92.png',
|
65 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_dashboard', '', array('#tasks')),
|
66 |
+
'details' => 'https://howto.squirrly.co/kb/squirrly-seo-goals/',
|
67 |
+
'show' => true,
|
68 |
+
),//Progress
|
69 |
+
array(
|
70 |
+
'title' => "Focus Pages",
|
71 |
+
'description' => "Brings you clear methods to take your pages <strong>from never found to always found on Google</strong>. Rank your pages by influencing the right ranking factors.",
|
72 |
+
'mode' => "Free",
|
73 |
+
'option' => false,
|
74 |
+
'active' => true,
|
75 |
+
'optional' => false,
|
76 |
+
'connection' => true,
|
77 |
+
'logo' => 'focuspages_92.png',
|
78 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_focuspages', 'pagelist'),
|
79 |
+
'details' => 'https://howto.squirrly.co/kb/focus-pages-page-audits/',
|
80 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_focuspages'),
|
81 |
+
), //Focus Pages
|
82 |
+
array(
|
83 |
+
'title' => "Chances of Ranking",
|
84 |
+
'description' => "Get information about <strong>Chances of Ranking for each Focus Page</strong> based on our <strong>Machine Learning Algorithms and Ranking Vision A.I.</strong>",
|
85 |
+
'mode' => "Free",
|
86 |
+
'option' => false,
|
87 |
+
'active' => true,
|
88 |
+
'optional' => false,
|
89 |
+
'connection' => true,
|
90 |
+
'logo' => 'focuspages_92.png',
|
91 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_focuspages', 'pagelist'),
|
92 |
+
'details' => 'https://howto.squirrly.co/kb/focus-pages-page-audits/#chance_to_rank',
|
93 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_focuspages'),
|
94 |
+
), //Chances of Ranking
|
95 |
+
array(
|
96 |
+
'title' => "Keyword Research",
|
97 |
+
'description' => "Find the <strong>Best Keywords</strong> that your own website can rank for and get <strong>personalized competition data</strong> for each keyword. Provides info on Region that was used for Keyword Research.",
|
98 |
+
'mode' => "Free",
|
99 |
+
'option' => false ,
|
100 |
+
'active' => true,
|
101 |
+
'optional' => false,
|
102 |
+
'connection' => true,
|
103 |
+
'logo' => 'kr_92.png',
|
104 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_research', 'research'),
|
105 |
+
'details' => 'https://howto.squirrly.co/kb/keyword-research-and-seo-strategy/',
|
106 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_research'),
|
107 |
+
), //Keyword Research
|
108 |
+
array(
|
109 |
+
'title' => "Google Search & Trends",
|
110 |
+
'description' => "Keyword Research uses tird-party services like <strong>Google Search API and Google Trends API</strong> to get live research data for each keyword. The research algorithm processes <strong>more than 100 processes</strong> for each keyword you selected.",
|
111 |
+
'mode' => "Free",
|
112 |
+
'option' => false,
|
113 |
+
'active' => true,
|
114 |
+
'optional' => false,
|
115 |
+
'connection' => true,
|
116 |
+
'logo' => 'kr_92.png',
|
117 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_research', 'research'),
|
118 |
+
'details' => 'https://howto.squirrly.co/kb/keyword-research-and-seo-strategy/',
|
119 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_research'),
|
120 |
+
), //Keyword Research
|
121 |
+
array(
|
122 |
+
'title' => "Briefcase",
|
123 |
+
'description' => "Add keywords in your portfolio based on your current Campaigns, Trends, Performance <strong>for a successful SEO strategy</strong>.",
|
124 |
+
'mode' => "Free",
|
125 |
+
'option' => false,
|
126 |
+
'active' => true,
|
127 |
+
'optional' => false,
|
128 |
+
'connection' => true,
|
129 |
+
'logo' => 'briefcase_92.png',
|
130 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_research', 'briefcase'),
|
131 |
+
'details' => 'https://howto.squirrly.co/kb/keyword-research-and-seo-strategy/#briefcase',
|
132 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_research'),
|
133 |
+
),//SEO Briefcase
|
134 |
+
array(
|
135 |
+
'title' => "Live Assistant",
|
136 |
+
'description' => "Publish <strong>content that is fully optimized</strong> for BOTH Search Engines and Humans – every single time!",
|
137 |
+
'mode' => "Free",
|
138 |
+
'option' => false,
|
139 |
+
'active' => true,
|
140 |
+
'optional' => false,
|
141 |
+
'connection' => true,
|
142 |
+
'logo' => 'sla_92.png',
|
143 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_assistant'),
|
144 |
+
'details' => 'https://howto.squirrly.co/kb/squirrly-live-assistant/',
|
145 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_assistant'),
|
146 |
+
),//Live Assistant
|
147 |
+
array(
|
148 |
+
'title' => "Keywords Optimization",
|
149 |
+
'description' => "Optimize for <strong>Multiple Keywords at once in a Single Page</strong>. Automatically Calculates Optimization Scores for all secondary keywords and displays them to you as you’re typing your page.",
|
150 |
+
'mode' => "Free",
|
151 |
+
'option' => false,
|
152 |
+
'active' => true,
|
153 |
+
'optional' => false,
|
154 |
+
'connection' => true,
|
155 |
+
'logo' => 'briefcase_92.png',
|
156 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_assistant'),
|
157 |
+
'details' => 'https://howto.squirrly.co/kb/squirrly-live-assistant/#add_keyword',
|
158 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_assistant'),
|
159 |
+
),//Keywords Optimization
|
160 |
+
array(
|
161 |
+
'title' => "Elementor Website Builder",
|
162 |
+
'description' => "The SEO Live Assistant <strong>works on the front-end of Elementor</strong>, just as you're creating or editing your Elementor page.",
|
163 |
+
'mode' => "Free",
|
164 |
+
'option' => 'sq_sla_frontend',
|
165 |
+
'active' => SQ_Classes_Helpers_Tools::getOption('sq_sla_frontend'),
|
166 |
+
'optional' => true,
|
167 |
+
'connection' => false,
|
168 |
+
'logo' => 'sla_92.png',
|
169 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_assistant', 'settings'),
|
170 |
+
'details' => 'https://howto.squirrly.co/kb/squirrly-live-assistant/#elementor',
|
171 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_assistant'),
|
172 |
+
),//Live Assistant Elementor
|
173 |
+
array(
|
174 |
+
'title' => "Google Rankings with GSC",
|
175 |
+
'description' => "Get <strong>Google Search Console (GSC)</strong> average <strong>positions, clicks and impressions</strong> for organic keywords.",
|
176 |
+
'mode' => "Free",
|
177 |
+
'option' => false,
|
178 |
+
'active' => true,
|
179 |
+
'optional' => false,
|
180 |
+
'connection' => true,
|
181 |
+
'logo' => 'ranking_92.png',
|
182 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_rankings', 'rankings'),
|
183 |
+
'details' => 'https://howto.squirrly.co/kb/ranking-serp-checker/',
|
184 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_rankings'),
|
185 |
+
),//Google SERP with GSC
|
186 |
+
array(
|
187 |
+
'title' => "SEO Automation",
|
188 |
+
'description' => "Configure the <strong>SEO in 2 minutes</strong> for the entire website without writing a line of code.",
|
189 |
+
'mode' => "Free",
|
190 |
+
'option' => 'sq_auto_pattern',
|
191 |
+
'active' => SQ_Classes_Helpers_Tools::getOption('sq_auto_pattern'),
|
192 |
+
'optional' => true,
|
193 |
+
'connection' => false,
|
194 |
+
'logo' => 'automation_92.png',
|
195 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_seosettings', 'automation'),
|
196 |
+
'details' => 'https://howto.squirrly.co/kb/seo-automation/',
|
197 |
+
'show' => true,
|
198 |
+
),//SEO Automation
|
199 |
+
array(
|
200 |
+
'title' => "Bulk SEO & Snippets",
|
201 |
+
'description' => "Simplify the SEO process to <strong>Optimize all the SEO Snippets</strong> in just minutes. Edit Snippets in BULK for all post types directly from All Snippets",
|
202 |
+
'mode' => "Free",
|
203 |
+
'option' => false,
|
204 |
+
'active' => true,
|
205 |
+
'optional' => false,
|
206 |
+
'connection' => false,
|
207 |
+
'logo' => 'bulkseo_92.png',
|
208 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_bulkseo', 'bulkseo'),
|
209 |
+
'details' => 'https://howto.squirrly.co/kb/bulk-seo/',
|
210 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_bulkseo'),
|
211 |
+
),//Bulk SEO
|
212 |
+
array(
|
213 |
+
'title' => "Frontend SEO Snippet",
|
214 |
+
'description' => "Optimize each page by loading the <strong>SEO Snippet directly on the front-end</strong> of your site. You have <strong>Custom SEO</strong> directly in the WP Admin Toolbar.",
|
215 |
+
'mode' => "Free",
|
216 |
+
'option' => 'sq_use_frontend',
|
217 |
+
'active' => SQ_Classes_Helpers_Tools::getOption('sq_use_frontend'),
|
218 |
+
'optional' => true,
|
219 |
+
'connection' => false,
|
220 |
+
'logo' => 'bulkseo_92.png',
|
221 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_seosettings', 'metas'),
|
222 |
+
'details' => 'https://howto.squirrly.co/kb/seo-metas/#Add-Snippet-in-Frontend',
|
223 |
+
'show' => true,
|
224 |
+
),//Frontend SEO Snippet
|
225 |
+
array(
|
226 |
+
'title' => "Open Graph Optimization",
|
227 |
+
'description' => "Add Social Open Graph protocol so that <strong>your Facebook Shares look awesome</strong>.",
|
228 |
+
'mode' => "Free",
|
229 |
+
'option' => 'sq_auto_facebook',
|
230 |
+
'active' => SQ_Classes_Helpers_Tools::getOption('sq_auto_facebook'),
|
231 |
+
'optional' => true,
|
232 |
+
'connection' => false,
|
233 |
+
'logo' => 'social_92.png',
|
234 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_seosettings', 'social'),
|
235 |
+
'details' => 'https://howto.squirrly.co/kb/social-media-settings/#opengraph',
|
236 |
+
'show' => true,
|
237 |
+
),//Open Graph Optimization
|
238 |
+
array(
|
239 |
+
'title' => "Twitter Card Optimization",
|
240 |
+
'description' => "Add Twitter Card in your tweets so that your <strong>Twitter Shares look awesome</strong>.",
|
241 |
+
'mode' => "Free",
|
242 |
+
'option' => 'sq_auto_twitter',
|
243 |
+
'active' => SQ_Classes_Helpers_Tools::getOption('sq_auto_twitter'),
|
244 |
+
'optional' => true,
|
245 |
+
'connection' => false,
|
246 |
+
'logo' => 'social_92.png',
|
247 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_seosettings', 'social'),
|
248 |
+
'details' => 'https://howto.squirrly.co/kb/social-media-settings/#twittercard',
|
249 |
+
'show' => true,
|
250 |
+
),//Twitter Card Optimization
|
251 |
+
array(
|
252 |
+
'title' => "Sitemap XML",
|
253 |
+
'description' => "Use Sitemap Generator to <strong>help your website get crawled</strong> and indexed by Search Engines. Add Sitemap Support for News, Posts, Pages, Products, Tags, Categories, Taxonomies, Images, Videos, etc.",
|
254 |
+
'mode' => "Free",
|
255 |
+
'option' => 'sq_auto_sitemap',
|
256 |
+
'active' => SQ_Classes_Helpers_Tools::getOption('sq_auto_sitemap'),
|
257 |
+
'optional' => true,
|
258 |
+
'connection' => false,
|
259 |
+
'logo' => 'sitemap_92.png',
|
260 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_seosettings', 'sitemap'),
|
261 |
+
'details' => 'https://howto.squirrly.co/kb/sitemap-xml-settings/',
|
262 |
+
'show' => true,
|
263 |
+
), //XML Sitemap
|
264 |
+
array(
|
265 |
+
'title' => "Google News",
|
266 |
+
'description' => "For a news website it's really important to have a Google News Sitemap. This way you will have <strong>all your News Posts instantly on Google News</strong>.",
|
267 |
+
'mode' => "Free",
|
268 |
+
'option' => false,
|
269 |
+
'active' => ($sitemap['sitemap-news'][1] == 1),
|
270 |
+
'optional' => false,
|
271 |
+
'connection' => false,
|
272 |
+
'logo' => 'news_92.png',
|
273 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_seosettings', 'sitemap'),
|
274 |
+
'details' => 'https://howto.squirrly.co/kb/sitemap-xml-settings/#news_sitemap',
|
275 |
+
'show' => true,
|
276 |
+
), //Sitemap Instant Indexing
|
277 |
+
array(
|
278 |
+
'title' => "JSON-LD Structured Data",
|
279 |
+
'description' => "Edit your website's JSON-LD Schema with Squirrly's powerful <strong>semantic SEO Markup Solution</strong>. Use the built-in Structured Data or add your custom Schema code.",
|
280 |
+
'mode' => "Free",
|
281 |
+
'option' => 'sq_auto_jsonld',
|
282 |
+
'active' => SQ_Classes_Helpers_Tools::getOption('sq_auto_jsonld'),
|
283 |
+
'optional' => true,
|
284 |
+
'connection' => false,
|
285 |
+
'logo' => 'jsonld_92.png',
|
286 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_seosettings', 'jsonld'),
|
287 |
+
'details' => 'https://howto.squirrly.co/kb/json-ld-structured-data/',
|
288 |
+
'show' => true,
|
289 |
+
), //JSON-LD Optimizaition
|
290 |
+
array(
|
291 |
+
'title' => "ACF Integration",
|
292 |
+
'description' => "Use <strong>Advanced Custom Fields (ACF)</strong> plugin to add advanced and custom JSON-LD Schema code on your pages.",
|
293 |
+
'mode' => "Free",
|
294 |
+
'option' => false,
|
295 |
+
'active' => true,
|
296 |
+
'optional' => false,
|
297 |
+
'connection' => false,
|
298 |
+
'logo' => 'jsonld_92.png',
|
299 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_seosettings', 'jsonld'),
|
300 |
+
'details' => 'https://howto.squirrly.co/kb/json-ld-structured-data/#ACF',
|
301 |
+
'show' => true,
|
302 |
+
), //Advanced Custom Fields
|
303 |
+
array(
|
304 |
+
'title' => "Google Analytics Tracking",
|
305 |
+
'description' => "Add the <strong>Google Analytics</strong> and <strong>Google Tag Manager</strong> tracking on your website.",
|
306 |
+
'mode' => "Free",
|
307 |
+
'option' => 'sq_auto_tracking',
|
308 |
+
'active' => SQ_Classes_Helpers_Tools::getOption('sq_auto_tracking'),
|
309 |
+
'optional' => true,
|
310 |
+
'connection' => false,
|
311 |
+
'logo' => 'traffic_92.png',
|
312 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_seosettings', 'tracking'),
|
313 |
+
'details' => 'https://howto.squirrly.co/kb/google-analytics-tracking-tool/#google_analytics',
|
314 |
+
'show' => true,
|
315 |
+
), //Google Analytics Tracking
|
316 |
+
array(
|
317 |
+
'title' => "AMP Support",
|
318 |
+
'description' => sprintf("Automatically load the <strong>Accelerate Mobile Pages (AMP)</strong> support for plugins like %sAMP for WP%s or %sAMP%s.", '<a href="https://wordpress.org/plugins/accelerated-mobile-pages/" target="_blank">', '</a>', '<a href="https://wordpress.org/plugins/amp/" target="_blank">', '</a>'),
|
319 |
+
'mode' => "Free",
|
320 |
+
'option' => 'sq_auto_amp',
|
321 |
+
'active' => SQ_Classes_Helpers_Tools::getOption('sq_auto_amp'),
|
322 |
+
'optional' => true,
|
323 |
+
'connection' => false,
|
324 |
+
'logo' => 'amp_92.png',
|
325 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_seosettings', 'tracking'),
|
326 |
+
'details' => 'https://howto.squirrly.co/kb/google-analytics-tracking-tool/#amp_support',
|
327 |
+
'show' => true,
|
328 |
+
), //
|
329 |
+
array(
|
330 |
+
'title' => "Facebook Pixel Tracking",
|
331 |
+
'description' => "Track visitors with <strong>website and e-commerce events</strong> for better Retargeting Campaigns. <strong>Integrated with Woocommerce</strong> plugin with events like Add to Cart, Initiate Checkout, Payment, and more.",
|
332 |
+
'mode' => "Free",
|
333 |
+
'option' => 'sq_auto_pixels',
|
334 |
+
'active' => SQ_Classes_Helpers_Tools::getOption('sq_auto_pixels'),
|
335 |
+
'optional' => true,
|
336 |
+
'connection' => false,
|
337 |
+
'logo' => 'traffic_92.png',
|
338 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_seosettings', 'tracking'),
|
339 |
+
'details' => 'https://howto.squirrly.co/kb/google-analytics-tracking-tool/#facebook_pixel',
|
340 |
+
'show' => true,
|
341 |
+
), //Facebook Pixel Tracking
|
342 |
+
array(
|
343 |
+
'title' => "Webmaster Tools",
|
344 |
+
'description' => "Connect your website with the popular webmasters like <strong>Google Search Console (GSC), Bing, Baidu, Yandex, Alexa</strong>.",
|
345 |
+
'mode' => "Free",
|
346 |
+
'option' => 'sq_auto_webmasters',
|
347 |
+
'active' => SQ_Classes_Helpers_Tools::getOption('sq_auto_webmasters'),
|
348 |
+
'optional' => true,
|
349 |
+
'connection' => false,
|
350 |
+
'logo' => 'websites_92.png',
|
351 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_seosettings', 'webmaster'),
|
352 |
+
'details' => 'https://howto.squirrly.co/kb/webmaster-tools-settings/',
|
353 |
+
'show' => true,
|
354 |
+
), //Webmaster Tools
|
355 |
+
array(
|
356 |
+
'title' => "Google Search Console (GSC)",
|
357 |
+
'description' => "Connect your website with <strong>Google Search Console</strong> and get insights based on <strong>organic searched keywords</strong>.",
|
358 |
+
'mode' => "Free",
|
359 |
+
'option' => 'sq_auto_webmasters',
|
360 |
+
'active' => (isset($connect['google_search_console']) ? $connect['google_search_console'] : true),
|
361 |
+
'optional' => false,
|
362 |
+
'connection' => true,
|
363 |
+
'logo' => 'websites_92.png',
|
364 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_rankings', 'settings'),
|
365 |
+
'details' => 'https://howto.squirrly.co/kb/ranking-serp-checker/#google_search_console',
|
366 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_rankings'),
|
367 |
+
), //Google Search Console
|
368 |
+
array(
|
369 |
+
'title' => "Robots.txt File",
|
370 |
+
'description' => "Tell search engine crawlers which pages or files the crawler can or can't request from your site.",
|
371 |
+
'mode' => "Free",
|
372 |
+
'option' => 'sq_auto_robots',
|
373 |
+
'active' => SQ_Classes_Helpers_Tools::getOption('sq_auto_robots'),
|
374 |
+
'optional' => true,
|
375 |
+
'connection' => false,
|
376 |
+
'logo' => 'robots_92.png',
|
377 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_seosettings', 'robots'),
|
378 |
+
'details' => false,
|
379 |
+
'show' => true,
|
380 |
+
), //Robots.txt File
|
381 |
+
array(
|
382 |
+
'title' => "Favicon Site Icon",
|
383 |
+
'description' => "Add your <strong>website icon</strong> in the browser tabs and on other devices like <strong>iPhone, iPad and Android phones</strong>.",
|
384 |
+
'mode' => "Free",
|
385 |
+
'option' => 'sq_auto_favicon',
|
386 |
+
'active' => SQ_Classes_Helpers_Tools::getOption('sq_auto_favicon'),
|
387 |
+
'optional' => true,
|
388 |
+
'connection' => false,
|
389 |
+
'logo' => 'favicon_92.png',
|
390 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_seosettings', 'favicon'),
|
391 |
+
'details' => 'https://howto.squirrly.co/kb/website-favicon-settings/',
|
392 |
+
'show' => true,
|
393 |
+
), //Favicon Site Icon
|
394 |
+
array(
|
395 |
+
'title' => "SEO Links",
|
396 |
+
'description' => "Increase the <strong>website authority</strong> by correctly managing all the external links on your website. Instantly add <strong>nofollow</strong> to all external links.",
|
397 |
+
'mode' => "Free",
|
398 |
+
'option' => 'sq_auto_links',
|
399 |
+
'active' => (bool)SQ_Classes_Helpers_Tools::getOption('sq_auto_links'),
|
400 |
+
'optional' => true,
|
401 |
+
'connection' => false,
|
402 |
+
'logo' => 'links_92.png',
|
403 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_seosettings', 'links'),
|
404 |
+
'details' => 'https://howto.squirrly.co/kb/seo-links/',
|
405 |
+
'show' => true,
|
406 |
+
), //SEO Links
|
407 |
+
array(
|
408 |
+
'title' => "On-Page SEO METAs",
|
409 |
+
'description' => "Add all the required Search Engine METAs like <strong>Title Meta, Description, Canonical Link, Dublin Core, Robots Meta</strong> and more.",
|
410 |
+
'mode' => "Free",
|
411 |
+
'option' => 'sq_auto_metas',
|
412 |
+
'active' => SQ_Classes_Helpers_Tools::getOption('sq_auto_metas'),
|
413 |
+
'optional' => true,
|
414 |
+
'connection' => false,
|
415 |
+
'logo' => 'metas_92.png',
|
416 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_seosettings', 'metas'),
|
417 |
+
'details' => 'https://howto.squirrly.co/kb/seo-metas/',
|
418 |
+
'show' => true,
|
419 |
+
), //On-Page SEO METAs
|
420 |
+
array(
|
421 |
+
'title' => "Remove META Duplicate",
|
422 |
+
'description' => "Fix Duplicate Title, Description, Canonical, Dublin Core, Robots and more without writing a line of code.",
|
423 |
+
'mode' => "Free",
|
424 |
+
'option' => false,
|
425 |
+
'active' => true,
|
426 |
+
'optional' => false,
|
427 |
+
'connection' => false,
|
428 |
+
'logo' => 'metas_92.png',
|
429 |
+
'link' => false,
|
430 |
+
'details' => 'https://howto.squirrly.co/kb/seo-metas/#remove_duplicates',
|
431 |
+
'show' => true,
|
432 |
+
), //Remove META Duplicate
|
433 |
+
array(
|
434 |
+
'title' => "404 URLs Redirects",
|
435 |
+
'description' => "Automatically <strong>redirect 404 URLs</strong> to the new URLs and keep the post authority. You can manage the <strong>Redirect Broken URLs</strong> for each post type.",
|
436 |
+
'mode' => "Free",
|
437 |
+
'option' => false,
|
438 |
+
'active' => true,
|
439 |
+
'optional' => false,
|
440 |
+
'connection' => false,
|
441 |
+
'logo' => 'redirect_92.png',
|
442 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_seosettings', 'automation', array('#tab=nav-post')),
|
443 |
+
'details' => 'https://howto.squirrly.co/kb/seo-automation/#redirect_broken_urls',
|
444 |
+
'show' => true,
|
445 |
+
), //404 Redirects
|
446 |
+
array(
|
447 |
+
'title' => "SEO Audit",
|
448 |
+
'description' => "Improve your Online Presence by knowing how your website is performing online. <strong>Generate and Compare SEO Audits</strong> and follow the Assistant to optimize the website.",
|
449 |
+
'mode' => "Free",
|
450 |
+
'option' => false,
|
451 |
+
'active' => true,
|
452 |
+
'optional' => false,
|
453 |
+
'connection' => true,
|
454 |
+
'logo' => 'audit_92.png',
|
455 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_audits', 'audits'),
|
456 |
+
'details' => 'https://howto.squirrly.co/kb/seo-audit/',
|
457 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_audit'),
|
458 |
+
), //SEO Audit
|
459 |
+
array(
|
460 |
+
'title' => "Moz",
|
461 |
+
'description' => "Receive information about <strong>Backlinks and Authority from Moz.com</strong> directly in your SEO Audit report.",
|
462 |
+
'mode' => "Free",
|
463 |
+
'option' => false,
|
464 |
+
'active' => true,
|
465 |
+
'optional' => false,
|
466 |
+
'connection' => true,
|
467 |
+
'logo' => 'audit_92.png',
|
468 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_audits', 'audits'),
|
469 |
+
'details' => 'https://howto.squirrly.co/kb/seo-audit/#moz',
|
470 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_audit'),
|
471 |
+
), //SEO Audit Moz
|
472 |
+
array(
|
473 |
+
'title' => "Majestic",
|
474 |
+
'description' => "Receive information about <strong>Backlinks from Majestic.com</strong> directly in your SEO Audit report.",
|
475 |
+
'mode' => "Free",
|
476 |
+
'option' => false,
|
477 |
+
'active' => true,
|
478 |
+
'optional' => false,
|
479 |
+
'connection' => true,
|
480 |
+
'logo' => 'audit_92.png',
|
481 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_audits', 'audits'),
|
482 |
+
'details' => 'https://howto.squirrly.co/kb/seo-audit/#majestic',
|
483 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_audit'),
|
484 |
+
), //SEO Audit Majestic
|
485 |
+
array(
|
486 |
+
'title' => "Alexa",
|
487 |
+
'description' => "Receive <strong>Alexa Score and Backlinks</strong> information directly in your SEO Audit report.",
|
488 |
+
'mode' => "Free",
|
489 |
+
'option' => false,
|
490 |
+
'active' => true,
|
491 |
+
'optional' => false,
|
492 |
+
'connection' => true,
|
493 |
+
'logo' => 'audit_92.png',
|
494 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_audits', 'audits'),
|
495 |
+
'details' => 'https://howto.squirrly.co/kb/seo-audit/#alexa',
|
496 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_audit'),
|
497 |
+
), //SEO Audit Alexa
|
498 |
+
array(
|
499 |
+
'title' => "Google PageSpeed Insights",
|
500 |
+
'description' => "Get precise information about the <strong>Average Loading Time</strong> of your website using Google PageSpeed Insights in your SEO Audit report.",
|
501 |
+
'mode' => "Free",
|
502 |
+
'option' => false,
|
503 |
+
'active' => true,
|
504 |
+
'optional' => false,
|
505 |
+
'connection' => true,
|
506 |
+
'logo' => 'audit_92.png',
|
507 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_audits', 'audits'),
|
508 |
+
'details' => 'https://howto.squirrly.co/kb/seo-audit/#google_pagespeed',
|
509 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_audit'),
|
510 |
+
), //SEO Audit Google PageSpeed
|
511 |
+
array(
|
512 |
+
'title' => "Blogging Assistant",
|
513 |
+
'description' => "Add relevant <strong>Copyright-Free images, Tweets, Wikis, Blog Excerpts</strong> in your posts.",
|
514 |
+
'mode' => "Pro",
|
515 |
+
'option' => false,
|
516 |
+
'active' => true,
|
517 |
+
'optional' => false,
|
518 |
+
'connection' => true,
|
519 |
+
'logo' => 'sla_92.png',
|
520 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_assistant'),
|
521 |
+
'details' => 'https://howto.squirrly.co/kb/squirrly-live-assistant/#live_assistant_box',
|
522 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_assistant'),
|
523 |
+
), //Blogging Assistant
|
524 |
+
array(
|
525 |
+
'title' => "Google SERP Checker",
|
526 |
+
'description' => "Accurately track your <strong>Google Rankings every day</strong> with Squirrly's user-friendly Google SERP Checker.",
|
527 |
+
'mode' => "Business",
|
528 |
+
'option' => false,
|
529 |
+
'active' => true,
|
530 |
+
'optional' => false,
|
531 |
+
'connection' => true,
|
532 |
+
'logo' => 'ranking_92.png',
|
533 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_rankings', 'rankings'),
|
534 |
+
'details' => 'https://howto.squirrly.co/kb/ranking-serp-checker/',
|
535 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_rankings'),
|
536 |
+
), //Google SERP Checker
|
537 |
+
array(
|
538 |
+
'title' => "Copyright Free Images",
|
539 |
+
'description' => "Search <strong>Copyright Free Images</strong> in Squirrly Live Assistant and import them directly on your content.",
|
540 |
+
'mode' => "free",
|
541 |
+
'option' => false,
|
542 |
+
'active' => true,
|
543 |
+
'optional' => false,
|
544 |
+
'connection' => true,
|
545 |
+
'logo' => 'image_92.png',
|
546 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_assistant'),
|
547 |
+
'details' => 'https://howto.squirrly.co/kb/squirrly-live-assistant/#copyright_free_images',
|
548 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_assistant'),
|
549 |
+
), //Blogging Assistant
|
550 |
+
array(
|
551 |
+
'title' => "WooCommerce SEO",
|
552 |
+
'description' => "<strong>Optimize all WooCommerce Products</strong> with Squirrly Live Assistant for better ranking. Add the required Metas, Google Tracking, Facebook Pixel Events and JSON-LD Schema. Useful for loading Rich Snippets on Google search results.",
|
553 |
+
'mode' => "Free",
|
554 |
+
'option' => false,
|
555 |
+
'active' => true,
|
556 |
+
'optional' => false,
|
557 |
+
'connection' => false,
|
558 |
+
'logo' => 'shop_92.png',
|
559 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_bulkseo', 'bulkseo', array('stype=product')),
|
560 |
+
'details' => 'https://howto.squirrly.co/kb/json-ld-structured-data/#woocommerce',
|
561 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_bulkseo'),
|
562 |
+
), //
|
563 |
+
array(
|
564 |
+
'title' => "Polylang",
|
565 |
+
'description' => "<strong>Multilingual Support</strong> with Polylang plugin for fast multilingual optimization. Load Squirrly Live Assistant, SEO Snippets and Sitemap XML based on Polylang language.",
|
566 |
+
'mode' => "Free",
|
567 |
+
'option' => false,
|
568 |
+
'active' => true,
|
569 |
+
'optional' => false,
|
570 |
+
'connection' => false,
|
571 |
+
'logo' => 'multilingual_92.png',
|
572 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_bulkseo', 'bulkseo'),
|
573 |
+
'details' => 'https://howto.squirrly.co/wordpress-seo/compatibility-with-polylang-plugin/',
|
574 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_bulkseo'),
|
575 |
+
), //
|
576 |
+
array(
|
577 |
+
'title' => "Local SEO",
|
578 |
+
'description' => "Optimize the website for <strong>local audience</strong> to have a huge advantage in front of your competitors.",
|
579 |
+
'mode' => "Free",
|
580 |
+
'option' => 'sq_auto_jsonld_local',
|
581 |
+
'active' => SQ_Classes_Helpers_Tools::getOption('sq_auto_jsonld_local'),
|
582 |
+
'optional' => true,
|
583 |
+
'connection' => false,
|
584 |
+
'logo' => 'local_92.png',
|
585 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_seosettings', 'jsonld', array('#localseo')),
|
586 |
+
'details' => 'https://howto.squirrly.co/kb/json-ld-structured-data/#local_seo',
|
587 |
+
'show' => true,
|
588 |
+
), //
|
589 |
+
array(
|
590 |
+
'title' => "Settings Assistant",
|
591 |
+
'description' => "With many of the Assistant panels in all Squirrly Setting pages, all a user needs to do is <strong>turn Red dots into Green dots</strong>.",
|
592 |
+
'mode' => "Free",
|
593 |
+
'option' => false,
|
594 |
+
'active' => true,
|
595 |
+
'optional' => false,
|
596 |
+
'connection' => false,
|
597 |
+
'logo' => 'audit_92.png',
|
598 |
+
'link' => false,
|
599 |
+
'details' => 'https://howto.squirrly.co/kb/squirrly-settings-assistant/',
|
600 |
+
'show' => true,
|
601 |
+
),//Live Assistant Elementor
|
602 |
+
array(
|
603 |
+
'title' => "Fetch SEO Snippet",
|
604 |
+
'description' => sprintf("Automatically <strong>fetch the Squirrly Snippet</strong> on %sFacebook Sharing Debugger%s every time you update the content on a page.", '<a href="https://developers.facebook.com/tools/debug/" target="_blank">', '</a>'),
|
605 |
+
'mode' => "Free",
|
606 |
+
'option' => 'sq_sla_social_fetch',
|
607 |
+
'active' => SQ_Classes_Helpers_Tools::getOption('sq_sla_social_fetch'),
|
608 |
+
'optional' => true,
|
609 |
+
'connection' => true,
|
610 |
+
'logo' => 'social_92.png',
|
611 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_assistant', 'settings'),
|
612 |
+
'details' => 'https://howto.squirrly.co/kb/squirrly-live-assistant/#fetch_social',
|
613 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_assistant'),
|
614 |
+
), //
|
615 |
+
array(
|
616 |
+
'title' => "SEO Images",
|
617 |
+
'description' => "Automatically <strong>downloads image and adds image alt tag</strong> for you, if you searched for images using your focus keyword <strong>inside the Blogging Assistant</strong>.",
|
618 |
+
'mode' => "Free",
|
619 |
+
'option' => 'sq_local_images',
|
620 |
+
'active' => SQ_Classes_Helpers_Tools::getOption('sq_local_images'),
|
621 |
+
'optional' => true,
|
622 |
+
'connection' => false,
|
623 |
+
'logo' => 'image_92.png',
|
624 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_assistant', 'settings'),
|
625 |
+
'details' => 'https://howto.squirrly.co/kb/squirrly-live-assistant/#seo_image',
|
626 |
+
'show' => SQ_Classes_Helpers_Tools::getMenuVisible('show_assistant'),
|
627 |
+
), //
|
628 |
+
|
629 |
+
array(
|
630 |
+
'title' => "Plugins Integration",
|
631 |
+
'description' => "Squirrly SEO works with all websites types and popular plugins like <strong>E-commerce plugins, Page Builder plugins, Cache plugins, SEO plugins, Multilingual plugins, and more</strong>.",
|
632 |
+
'mode' => "Free",
|
633 |
+
'option' => false,
|
634 |
+
'active' => true,
|
635 |
+
'optional' => false,
|
636 |
+
'connection' => false,
|
637 |
+
'logo' => 'settings_92.png',
|
638 |
+
'link' => false,
|
639 |
+
'details' => 'https://howto.squirrly.co/',
|
640 |
+
'show' => true,
|
641 |
+
), //
|
642 |
+
array(
|
643 |
+
'title' => "Import SEO & Settings",
|
644 |
+
'description' => "Import the settings and SEO from other plugins so you can use only Squirrly SEO for on-page SEO.",
|
645 |
+
'mode' => "Free",
|
646 |
+
'option' => false,
|
647 |
+
'active' => true,
|
648 |
+
'optional' => false,
|
649 |
+
'connection' => false,
|
650 |
+
'logo' => 'settings_92.png',
|
651 |
+
'link' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_seosettings', 'backup'),
|
652 |
+
'details' => 'https://howto.squirrly.co/kb/import-export-seo-settings/',
|
653 |
+
'show' => true,
|
654 |
+
), //Import SEO & Settings
|
655 |
+
|
656 |
+
|
657 |
+
);
|
658 |
+
|
659 |
+
//for PHP 7.3.1 version
|
660 |
+
$features = array_filter($features);
|
661 |
+
|
662 |
+
return apply_filters('sq_features', $features);
|
663 |
+
}
|
664 |
+
}
|
core/BlockJorney.php
CHANGED
@@ -1,48 +1,52 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Core_BlockJorney extends SQ_Classes_BlockController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Core_BlockJorney extends SQ_Classes_BlockController
|
5 |
+
{
|
6 |
+
|
7 |
+
public $days = false;
|
8 |
+
|
9 |
+
public function init()
|
10 |
+
{
|
11 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('jorney');
|
12 |
+
|
13 |
+
if (!$seojorney = SQ_Classes_Helpers_Tools::getOption('sq_seojourney')) {
|
14 |
+
$this->show_view('Blocks/Jorney');
|
15 |
+
}else {
|
16 |
+
|
17 |
+
if (!SQ_Classes_Helpers_Tools::getOption('sq_seojourney_congrats')) {
|
18 |
+
return false;
|
19 |
+
}
|
20 |
+
|
21 |
+
$days = 1;
|
22 |
+
$seconds = strtotime(date('Y-m-d')) - strtotime($seojorney);
|
23 |
+
|
24 |
+
if ($seconds > 0) {
|
25 |
+
$days = $seconds / (3600 * 24);
|
26 |
+
$days = (int)$days + 1;
|
27 |
+
}
|
28 |
+
|
29 |
+
$this->days = $days;
|
30 |
+
$this->show_view('Blocks/Jorney');
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
public function getJourneyDays()
|
35 |
+
{
|
36 |
+
return $this->days;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* 14 days journey action
|
41 |
+
*/
|
42 |
+
public function action()
|
43 |
+
{
|
44 |
+
switch (SQ_Classes_Helpers_Tools::getValue('action')) {
|
45 |
+
//login action
|
46 |
+
case 'sq_journey_close':
|
47 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_seojourney_congrats', 0);
|
48 |
+
break;
|
49 |
+
|
50 |
+
}
|
51 |
+
}
|
52 |
+
}
|
core/BlockKnowledgeBase.php
CHANGED
@@ -1,9 +1,11 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Core_BlockKnowledgeBase extends SQ_Classes_BlockController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Core_BlockKnowledgeBase extends SQ_Classes_BlockController
|
5 |
+
{
|
6 |
+
|
7 |
+
public function init()
|
8 |
+
{
|
9 |
+
$this->show_view('Blocks/KnowledgeBase');
|
10 |
+
}
|
11 |
+
}
|
core/BlockSearch.php
CHANGED
@@ -1,36 +1,39 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Core_BlockSearch extends SQ_Classes_BlockController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
}
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Core_BlockSearch extends SQ_Classes_BlockController
|
5 |
+
{
|
6 |
+
|
7 |
+
public function init()
|
8 |
+
{
|
9 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('search');
|
10 |
+
|
11 |
+
$this->show_view('Blocks/Search');
|
12 |
+
}
|
13 |
+
|
14 |
+
public function action()
|
15 |
+
{
|
16 |
+
switch (SQ_Classes_Helpers_Tools::getValue('action')) {
|
17 |
+
case 'sq_ajax_search':
|
18 |
+
|
19 |
+
//SQ_Classes_Helpers_Tools::setHeader('json');
|
20 |
+
$search_query = SQ_Classes_Helpers_Tools::getValue('search_query', '');
|
21 |
+
|
22 |
+
$args = array();
|
23 |
+
$args['action'] = 'lsvr-lore-ajax-search';
|
24 |
+
$args['nonce'] = 'plugin_search';
|
25 |
+
$args['search_query'] = $search_query;
|
26 |
+
|
27 |
+
$parameters = "";
|
28 |
+
foreach ($args as $key => $value) {
|
29 |
+
if ($value <> '') {
|
30 |
+
$parameters .= ($parameters == "" ? "" : "&") . $key . "=" . urlencode($value);
|
31 |
+
}
|
32 |
+
}
|
33 |
+
$url = 'https://howto.squirrly.co/wp-admin/admin-ajax.php' . "?" . $parameters;
|
34 |
+
echo SQ_Classes_RemoteController::sq_wpcall($url, array('sslverify' => false, 'timeout' => 10));
|
35 |
+
exit();
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
}
|
core/BlockStats.php
CHANGED
@@ -1,21 +1,23 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Core_BlockStats extends SQ_Classes_BlockController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
}
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Core_BlockStats extends SQ_Classes_BlockController
|
5 |
+
{
|
6 |
+
var $stats = array();
|
7 |
+
|
8 |
+
function init()
|
9 |
+
{
|
10 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('global');
|
11 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('stats');
|
12 |
+
|
13 |
+
parent::init();
|
14 |
+
|
15 |
+
$dbtasks = json_decode(get_option(SQ_TASKS), true);
|
16 |
+
if(isset($dbtasks['sq_stats'])) {
|
17 |
+
$this->stats = $dbtasks['sq_stats'];
|
18 |
+
|
19 |
+
$this->show_view('Blocks/Stats');
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
}
|
core/BlockSupport.php
CHANGED
@@ -1,63 +1,66 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Core_BlockSupport extends SQ_Classes_BlockController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
*
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
SQ_Classes_Helpers_Tools::
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Core_BlockSupport extends SQ_Classes_BlockController
|
5 |
+
{
|
6 |
+
|
7 |
+
public function init()
|
8 |
+
{
|
9 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('support');
|
10 |
+
|
11 |
+
$this->show_view('Blocks/Support');
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Called when Post action is triggered
|
16 |
+
*
|
17 |
+
* @return void
|
18 |
+
*/
|
19 |
+
public function action()
|
20 |
+
{
|
21 |
+
switch (SQ_Classes_Helpers_Tools::getValue('action')) {
|
22 |
+
case 'sq_feedback':
|
23 |
+
$return = array();
|
24 |
+
|
25 |
+
$feedback = SQ_Classes_Helpers_Tools::getValue('feedback', false);
|
26 |
+
|
27 |
+
if ($feedback) {
|
28 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_feedback', 1);
|
29 |
+
|
30 |
+
$args['action'] = 'feedback';
|
31 |
+
$args['value'] = $feedback;
|
32 |
+
SQ_Classes_RemoteController::saveFeedback($args);
|
33 |
+
|
34 |
+
$return['message'] = esc_html__("Thank you for your feedback.", 'squirrly-seo');
|
35 |
+
$return['success'] = true;
|
36 |
+
|
37 |
+
} else {
|
38 |
+
$return['message'] = esc_html__("No message.", 'squirrly-seo');
|
39 |
+
$return['error'] = true;
|
40 |
+
}
|
41 |
+
|
42 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
43 |
+
echo wp_json_encode($return);
|
44 |
+
exit();
|
45 |
+
|
46 |
+
case 'sq_uninstall_feedback':
|
47 |
+
$reason['select'] = SQ_Classes_Helpers_Tools::getValue('reason_key', false);
|
48 |
+
$reason['plugin'] = SQ_Classes_Helpers_Tools::getValue('reason_found_a_better_plugin', false);
|
49 |
+
$reason['other'] = SQ_Classes_Helpers_Tools::getValue('reason_other', false);
|
50 |
+
|
51 |
+
$args['action'] = 'deactivate';
|
52 |
+
$args['value'] = json_encode($reason);
|
53 |
+
SQ_Classes_RemoteController::saveFeedback($args);
|
54 |
+
|
55 |
+
if (SQ_Classes_Helpers_Tools::getValue('option_remove_records', false)) {
|
56 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_api', false);
|
57 |
+
}
|
58 |
+
|
59 |
+
SQ_Classes_Helpers_Tools::setHeader('json');
|
60 |
+
echo wp_json_encode(array());
|
61 |
+
exit();
|
62 |
+
}
|
63 |
+
exit();
|
64 |
+
}
|
65 |
+
|
66 |
+
}
|
core/BlockToolbar.php
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Core_BlockToolbar extends SQ_Classes_BlockController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
}
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Core_BlockToolbar extends SQ_Classes_BlockController
|
5 |
+
{
|
6 |
+
|
7 |
+
function init()
|
8 |
+
{
|
9 |
+
$this->show_view('Blocks/Toolbar');
|
10 |
+
}
|
11 |
+
|
12 |
+
}
|
core/Blocklogin.php
CHANGED
@@ -1,149 +1,159 @@
|
|
1 |
-
<?php
|
2 |
-
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
-
|
4 |
-
class SQ_Core_Blocklogin extends SQ_Classes_BlockController
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
//
|
50 |
-
$
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
SQ_Classes_Error::
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
//if
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') || die('Cheatin\' uh?');
|
3 |
+
|
4 |
+
class SQ_Core_Blocklogin extends SQ_Classes_BlockController
|
5 |
+
{
|
6 |
+
|
7 |
+
public $message;
|
8 |
+
|
9 |
+
public function init()
|
10 |
+
{
|
11 |
+
/* If logged in, then return */
|
12 |
+
if (SQ_Classes_Helpers_Tools::getOption('sq_api') <> '') {
|
13 |
+
return;
|
14 |
+
}
|
15 |
+
|
16 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('login');
|
17 |
+
SQ_Classes_Error::hookNotices();
|
18 |
+
$this->show_view('Blocks/Login');
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Called for sq_login on Post action
|
23 |
+
* Login or register a user
|
24 |
+
*/
|
25 |
+
public function action()
|
26 |
+
{
|
27 |
+
switch (SQ_Classes_Helpers_Tools::getValue('action')) {
|
28 |
+
//login action
|
29 |
+
case 'sq_login':
|
30 |
+
$this->squirrlyLogin();
|
31 |
+
break;
|
32 |
+
|
33 |
+
//sign-up action
|
34 |
+
case 'sq_register':
|
35 |
+
$this->squirrlyRegister();
|
36 |
+
break;
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Register a new user to Squirrly and get the token
|
42 |
+
*
|
43 |
+
* @global string $current_user
|
44 |
+
*/
|
45 |
+
public function squirrlyRegister()
|
46 |
+
{
|
47 |
+
//if email is set
|
48 |
+
if (SQ_Classes_Helpers_Tools::getIsset('email')) {
|
49 |
+
//post arguments
|
50 |
+
$args = array();
|
51 |
+
$args['name'] = '';
|
52 |
+
$args['user'] = SQ_Classes_Helpers_Tools::getValue('email');
|
53 |
+
|
54 |
+
//create an object from json responce
|
55 |
+
$responce = SQ_Classes_RemoteController::register($args);
|
56 |
+
if (is_wp_error($responce)) {
|
57 |
+
switch ($responce->get_error_message()) {
|
58 |
+
case 'alreadyregistered':
|
59 |
+
SQ_Classes_Error::setError(sprintf(esc_html__("We found your email, so it means you already have a Squirrly.co account. %sClick %sI already have an account%s and login. If you forgot your password, click %shere%s", 'squirrly-seo'), '<br />', '<a href="' . SQ_Classes_Helpers_Tools::getAdminUrl('sq_dashboard', 'login') . '" style="color:yellow">', '</a>', '<a href="' . _SQ_DASH_URL_ . '/login?action=lostpassword" target="_blank" style="color:yellow">', '</a>'));
|
60 |
+
break;
|
61 |
+
case 'invalidemail':
|
62 |
+
SQ_Classes_Error::setError(esc_html__("Your email is not valid. Please enter a valid email.", 'squirrly-seo'));
|
63 |
+
break;
|
64 |
+
default:
|
65 |
+
if (!SQ_Classes_Error::isError()) {
|
66 |
+
SQ_Classes_Error::setError(esc_html__("We could not create your account. Please enter a valid email.", 'squirrly-seo'));
|
67 |
+
}
|
68 |
+
break;
|
69 |
+
}
|
70 |
+
|
71 |
+
} elseif (isset($responce->token)) { //check if token is set and save it
|
72 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_api', $responce->token);
|
73 |
+
|
74 |
+
//Connect to cloud with an unique blog Token for API access
|
75 |
+
SQ_Classes_ObjController::getClass('SQ_Core_BlockConnect')->connectToCloud();
|
76 |
+
|
77 |
+
//redirect users to onboarding if necessary
|
78 |
+
if (!$onboarding = SQ_Classes_Helpers_Tools::getOption('sq_onboarding')) {
|
79 |
+
wp_redirect(SQ_Classes_Helpers_Tools::getAdminUrl('sq_onboarding'));
|
80 |
+
die();
|
81 |
+
} else {
|
82 |
+
wp_redirect(SQ_Classes_Helpers_Tools::getAdminUrl('sq_dashboard'));
|
83 |
+
die();
|
84 |
+
}
|
85 |
+
|
86 |
+
} elseif (!SQ_Classes_Error::isError()) {
|
87 |
+
//if unknown error
|
88 |
+
SQ_Classes_Error::setError(sprintf(esc_html__("Error: Couldn't connect to host :( . Please contact your site's webhost (or webmaster) and request them to add %s to their IP whitelist.", 'squirrly-seo'), _SQ_APIV2_URL_));
|
89 |
+
}
|
90 |
+
} else {
|
91 |
+
SQ_Classes_Error::setError(esc_html__("Your email is not set. Please enter a valid email.", 'squirrly-seo'));
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Login a user to Squirrly and get the token
|
97 |
+
*/
|
98 |
+
public function squirrlyLogin()
|
99 |
+
{
|
100 |
+
//if email is set
|
101 |
+
if (SQ_Classes_Helpers_Tools::getIsset('email') && SQ_Classes_Helpers_Tools::getIsset('password') && isset($_POST['password'])) {
|
102 |
+
//get the user and password
|
103 |
+
$args['user'] = SQ_Classes_Helpers_Tools::getValue('email');
|
104 |
+
$args['password'] = $_POST['password'];
|
105 |
+
|
106 |
+
//get the responce from server on login call
|
107 |
+
/**
|
108 |
+
*
|
109 |
+
*
|
110 |
+
* @var bool|WP_Error $responce
|
111 |
+
*/
|
112 |
+
$responce = SQ_Classes_RemoteController::login($args);
|
113 |
+
|
114 |
+
/** */
|
115 |
+
if (is_wp_error($responce)) {
|
116 |
+
switch ($responce->get_error_message()) {
|
117 |
+
case 'badlogin':
|
118 |
+
SQ_Classes_Error::setError(esc_html__("Wrong email or password!", 'squirrly-seo'));
|
119 |
+
break;
|
120 |
+
case 'multisite':
|
121 |
+
SQ_Classes_Error::setError(esc_html__("You can only use this account for the URL you registered first!", 'squirrly-seo'));
|
122 |
+
break;
|
123 |
+
case 'disconnected':
|
124 |
+
SQ_Classes_Error::setError(esc_html__("You disconnected your website from", 'squirrly-seo') . ' ' . _SQ_DASH_URL_);
|
125 |
+
break;
|
126 |
+
default:
|
127 |
+
if (!SQ_Classes_Error::isError()) {
|
128 |
+
SQ_Classes_Error::setError(esc_html__("An error occured.", 'squirrly-seo') . ':' . $responce->get_error_message());
|
129 |
+
}
|
130 |
+
break;
|
131 |
+
}
|
132 |
+
|
133 |
+
} elseif (isset($responce->token)) { //check if token is set and save it
|
134 |
+
SQ_Classes_Helpers_Tools::saveOptions('sq_api', $responce->token);
|
135 |
+
|
136 |
+
//Connect to cloud with an unique blog Token for API access
|
137 |
+
SQ_Classes_ObjController::getClass('SQ_Core_BlockConnect')->connectToCloud();
|
138 |
+
|
139 |
+
//redirect users to onboarding if necessary
|
140 |
+
if (!$onboarding = SQ_Classes_Helpers_Tools::getOption('sq_onboarding')) {
|
141 |
+
wp_redirect(SQ_Classes_Helpers_Tools::getAdminUrl('sq_onboarding'));
|
142 |
+
die();
|
143 |
+
} else {
|
144 |
+
wp_redirect(SQ_Classes_Helpers_Tools::getAdminUrl('sq_dashboard'));
|
145 |
+
die();
|
146 |
+
}
|
147 |
+
|
148 |
+
} elseif (!SQ_Classes_Error::isError()) {
|
149 |
+
//if unknown error
|
150 |
+
SQ_Classes_Error::setError(sprintf(esc_html__("Error: Couldn't connect to host :( . Please contact your site's webhost (or webmaster) and request them to add %s to their IP whitelist.", 'squirrly-seo'), _SQ_APIV2_URL_));
|
151 |
+
}
|
152 |
+
|
153 |
+
} else {
|
154 |
+
SQ_Classes_Error::setError(esc_html__("Both fields are required.", 'squirrly-seo'));
|
155 |
+
}
|
156 |
+
|
157 |
+
}
|
158 |
+
|
159 |
+
}
|
debug/index.php
CHANGED
@@ -1,230 +1,96 @@
|
|
1 |
-
<?php
|
2 |
-
defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
|
3 |
-
|
4 |
-
class SQ_Debug {
|
5 |
-
|
6 |
-
/** @var array */
|
7 |
-
private static $debug;
|
8 |
-
|
9 |
-
public function logQueries($query) {
|
10 |
-
self::dump($query);
|
11 |
-
return $query;
|
12 |
-
}
|
13 |
-
|
14 |
-
public function _isAjax() {
|
15 |
-
if (defined('DOING_AJAX') && DOING_AJAX) {
|
16 |
-
return true;
|
17 |
-
}
|
18 |
-
return false;
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Get a value from $_POST / $_GET
|
23 |
-
* if unavailable, take a default value
|
24 |
-
*
|
25 |
-
* @param string $key Value key
|
26 |
-
* @param mixed $defaultValue (optional)
|
27 |
-
* @return mixed Value
|
28 |
-
*/
|
29 |
-
public static function getValue($key, $defaultValue = false) {
|
30 |
-
if (!isset($key) OR empty($key) OR !is_string($key))
|
31 |
-
return false;
|
32 |
-
$ret = (isset($_POST[$key]) ? $_POST[$key] : (isset($_GET[$key]) ? $_GET[$key] : $defaultValue));
|
33 |
-
|
34 |
-
if (is_string($ret) === true)
|
35 |
-
$ret = urldecode(preg_replace('/((\%5C0+)|(\%00+))/i', '', urlencode($ret)));
|
36 |
-
return !is_string($ret) ? $ret : stripslashes($ret);
|
37 |
-
}
|
38 |
-
|
39 |
-
public static function setValue($key, $value) {
|
40 |
-
$_POST[$key] = $value;
|
41 |
-
$_GET[$key] = $value;
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Check if the parameter is set
|
46 |
-
*
|
47 |
-
* @param string $key
|
48 |
-
* @return boolean
|
49 |
-
*/
|
50 |
-
public static function getIsset($key) {
|
51 |
-
if (!isset($key) OR empty($key) OR !is_string($key))
|
52 |
-
return false;
|
53 |
-
return isset($_POST[$key]) ? true : (isset($_GET[$key]) ? true : false);
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Check if debug is called
|
58 |
-
*/
|
59 |
-
public static function checkDebug() {
|
60 |
-
//if debug is called
|
61 |
-
if (self::getIsset('sq_debug')) {
|
62 |
-
if (self::getValue('sq_debug') === 'on' && SQ_DEBUG) {
|
63 |
-
error_reporting(E_ALL);
|
64 |
-
@ini_set('display_errors', true);
|
65 |
-
if (function_exists('register_shutdown_function')) {
|
66 |
-
register_shutdown_function(array(new SQ_Debug(), 'showDebug'));
|
67 |
-
}
|
68 |
-
echo '<script>var SQ_DEBUG = true;</script>';
|
69 |
-
}
|
70 |
-
}
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Get the debug buffer
|
75 |
-
* @param $buffer
|
76 |
-
* @return mixed
|
77 |
-
*/
|
78 |
-
public function getBuffer($buffer) {
|
79 |
-
if (SQ_Classes_Helpers_Tools::isAjax()) {
|
80 |
-
return $buffer;
|
81 |
-
}
|
82 |
-
if (!$this->getIsset('sq_debug')) {
|
83 |
-
return $buffer;
|
84 |
-
}
|
85 |
-
|
86 |
-
return false;
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Store the debug for a later view
|
91 |
-
*
|
92 |
-
* @return bool|void
|
93 |
-
*/
|
94 |
-
public static function dump() {
|
95 |
-
if (SQ_DEBUG) {
|
96 |
-
if (self::getValue('sq_debug') !== 'on') {
|
97 |
-
return;
|
98 |
-
}
|
99 |
-
|
100 |
-
$output = '';
|
101 |
-
$callee = array('file' => '', 'line' => '');
|
102 |
-
if (function_exists('func_get_args')) {
|
103 |
-
$arguments = func_get_args();
|
104 |
-
$total_arguments = count($arguments);
|
105 |
-
} else
|
106 |
-
$arguments = array();
|
107 |
-
|
108 |
-
|
109 |
-
$run_time = number_format(microtime(true) - SQ_REQUEST_TIME, 3);
|
110 |
-
if (function_exists('debug_backtrace'))
|
111 |
-
list($callee) = debug_backtrace();
|
112 |
-
|
113 |
-
$output .= '<fieldset style="background: #FFFFFF; border: 1px #CCCCCC solid; padding: 5px; font-size: 9pt; margin: 0;">';
|
114 |
-
$output .= '<legend style="background: #EEEEEE; padding: 2px; font-size: 8pt;">' . $callee['file'] . ' Time: ' . $run_time . ' @ line: ' . $callee['line']
|
115 |
-
. '</legend><pre style="margin: 0; font-size: 8pt; text-align: left;">';
|
116 |
-
|
117 |
-
$i = 0;
|
118 |
-
foreach ($arguments as $argument) {
|
119 |
-
if (count($arguments) > 1)
|
120 |
-
$output .= "\n" . '<strong>#' . (++$i) . ' of ' . $total_arguments . '</strong>: ';
|
121 |
-
|
122 |
-
// if argument is boolean, false value does not display, so ...
|
123 |
-
if (is_bool($argument))
|
124 |
-
$argument = ($argument) ? 'TRUE' : 'FALSE';
|
125 |
-
else
|
126 |
-
if (is_object($argument) && function_exists('array_reverse') && function_exists('class_parents'))
|
127 |
-
$output .= implode("\n" . '|' . "\n", array_reverse(class_parents($argument))) . "\n" . '|' . "\n";
|
128 |
-
|
129 |
-
$output .= htmlspecialchars(print_r($argument, TRUE))
|
130 |
-
. ((is_object($argument) && function_exists('spl_object_hash')) ? spl_object_hash($argument) : '');
|
131 |
-
}
|
132 |
-
$output .= "</pre>";
|
133 |
-
$output .= "</fieldset>";
|
134 |
-
|
135 |
-
self::$debug[] = $output;
|
136 |
-
}
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* Show the debug dump
|
141 |
-
*/
|
142 |
-
public static function showDebug() {
|
143 |
-
SQ_Classes_Helpers_Tools::setHeader('html');
|
144 |
-
error_get_last();
|
145 |
-
echo "Debug result: <br />" . '<div id="wpcontent">' . '<br />' . implode('<br />', (array)self::$debug) . '<div>';
|
146 |
-
|
147 |
-
$run_time = number_format(microtime(true) - SQ_REQUEST_TIME, 3);
|
148 |
-
$pps = number_format(1 / $run_time, 0);
|
149 |
-
$memory_avail = ini_get('memory_limit');
|
150 |
-
$memory_used = number_format(memory_get_usage(true) / (1024 * 1024), 2);
|
151 |
-
$memory_peak = number_format(memory_get_peak_usage(true) / (1024 * 1024), 2);
|
152 |
-
|
153 |
-
if (PHP_SAPI == 'cli') {
|
154 |
-
// if run for command line, display some info
|
155 |
-
$debug = PHP_EOL
|
156 |
-
. "=======================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|