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 -52
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 |