SEO SQUIRRLY™ - Version 11.1.01

Version Description

  • 04/04/2021 = Update - Added the option to reactivate the ignored success messages Update - Make the Local SEO feature more visible while active Update - Add the KML download option in GEO Settings Update - Add more infos about the Sitemap XML for each post type Update - Knowledge base based on each section Fixed - Corrected the KML file for Local SEO Fixed - Show all keywords link in Briefcase if no keyword is found on search
Download this release

Release Info

Developer cifi
Plugin Icon 128x128 SEO SQUIRRLY™
Version 11.1.01
Comparing to
See all releases

Code changes from version 11.1.00 to 11.1.01

classes/ActionController.php CHANGED
@@ -9,9 +9,6 @@ class SQ_Classes_ActionController extends SQ_Classes_FrontController {
9
  /** @var array with all form and ajax actions */
10
  var $actions = array();
11
 
12
- /** @var array from core config */
13
- private static $config;
14
-
15
  /**
16
  * The hookAjax is loaded as custom hook in hookController class
17
  *
@@ -52,61 +49,328 @@ class SQ_Classes_ActionController extends SQ_Classes_FrontController {
52
  }
53
  }
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  /**
56
  * Get all actions from config.json in core directory and add them in the WP
57
  *
58
  */
59
  public function getActions() {
60
 
61
- $wp_filesystem = SQ_Classes_Helpers_Tools::initFilesystem();
 
 
62
 
63
  $this->actions = array();
64
  $cur_action = SQ_Classes_Helpers_Tools::getValue('action', false);
65
  $http_referer = SQ_Classes_Helpers_Tools::getValue('_wp_http_referer', false);
66
  $sq_nonce = SQ_Classes_Helpers_Tools::getValue('sq_nonce', false);
67
 
68
- if (!function_exists('is_user_logged_in')) {
69
- return;
70
- }
71
-
72
  //Let only the logged users to access the actions
73
- if ($cur_action <> '' && $sq_nonce <> '' && is_admin()) {
74
- /* if config allready in cache */
75
- if (!isset(self::$config)) {
76
- $config_file = _SQ_ROOT_DIR_ . 'config.json';
77
- if (!$wp_filesystem->exists($config_file)) {
78
- return;
79
- }
80
 
81
- /* load configuration blocks data from core config files */
82
- self::$config = json_decode($wp_filesystem->get_contents($config_file), 1);
83
- }
84
 
85
- if (is_array(self::$config))
86
- foreach (self::$config['blocks']['block'] as $block) {
87
  if (isset($block['active']) && $block['active'] == 1) {
88
  /* if there is a single action */
89
  if (isset($block['actions']['action']))
90
- if (isset($block['admin']) && (($block['admin'] == 1 && is_user_logged_in()) || $block['admin'] == 0)) {
 
 
 
 
 
 
91
  /* if there are more actions for the current block */
92
- if (!is_array($block['actions']['action'])) {
93
- /* add the action in the actions array */
94
- if ($block['actions']['action'] == $cur_action) {
95
  $this->actions[] = array('class' => $block['name']);
96
  }
97
- } else {
98
- /* if there are more actions for the current block */
99
- foreach ($block['actions']['action'] as $action) {
100
- /* add the actions in the actions array */
101
- if ($action == $cur_action) {
102
- $this->actions[] = array('class' => $block['name']);
103
- }
104
- }
105
  }
106
  }
107
-
108
  }
109
  }
 
110
 
111
  //If there is an action found in the config.js file
112
  if (!empty($this->actions)) {
9
  /** @var array with all form and ajax actions */
10
  var $actions = array();
11
 
 
 
 
12
  /**
13
  * The hookAjax is loaded as custom hook in hookController class
14
  *
49
  }
50
  }
51
 
52
+ public function getActionsList(){
53
+ return array(
54
+ array(
55
+ 'name' => 'SQ_Core_Blocklogin',
56
+ 'description' => 'Connection Block',
57
+ 'actions' => array(
58
+ 'action' => array(
59
+ 'sq_login',
60
+ 'sq_register',
61
+ ),
62
+ ),
63
+ 'active' => '1',
64
+ ),
65
+ array(
66
+ 'name' => 'SQ_Core_BlockConnect',
67
+ 'description' => 'Connection Block to API',
68
+ 'actions' => array(
69
+ 'action' => array(
70
+ 'sq_cloud_connect',
71
+ 'sq_cloud_disconnect',
72
+ ),
73
+ ),
74
+ 'active' => '1',
75
+ ),
76
+ array(
77
+ 'name' => 'SQ_Controllers_Account',
78
+ 'description' => 'Account Class',
79
+ 'actions' => array(
80
+ 'action' => array(
81
+ 'sq_ajax_account_getaccount',
82
+ ),
83
+ ),
84
+ 'active' => '1',
85
+ ),
86
+ array(
87
+ 'name' => 'SQ_Controllers_FocusPages',
88
+ 'description' => 'Focus Pages Controller',
89
+ 'actions' => array(
90
+ 'action' => array(
91
+ 'sq_focuspages_getpage',
92
+ 'sq_focuspages_addnew',
93
+ 'sq_focuspages_update',
94
+ 'sq_focuspages_delete',
95
+ 'sq_focuspages_inspecturl',
96
+ ),
97
+ ),
98
+ 'active' => '1',
99
+ ),
100
+ array(
101
+ 'name' => 'SQ_Controllers_PostsList',
102
+ 'description' => 'Posts List Page',
103
+ 'actions' => array(
104
+ 'action' => array(
105
+ 'inline-save',
106
+ 'sq_ajax_postslist',
107
+ ),
108
+ ),
109
+ 'active' => '1',
110
+ ),
111
+ array(
112
+ 'name' => 'SQ_Controllers_Post',
113
+ 'description' => 'Post Page',
114
+ 'actions' => array(
115
+ 'action' => array(
116
+ 'sq_create_demo',
117
+ 'sq_ajax_save_ogimage',
118
+ 'sq_ajax_get_post',
119
+ 'sq_ajax_save_post',
120
+ 'sq_ajax_type_click',
121
+ 'sq_ajax_search_blog',
122
+ ),
123
+ ),
124
+ 'active' => '1',
125
+ ),
126
+ array(
127
+ 'name' => 'SQ_Controllers_Snippet',
128
+ 'description' => 'Snippet Page',
129
+ 'actions' => array(
130
+ 'action' => array(
131
+ 'sq_saveseo',
132
+ 'sq_getsnippet',
133
+ 'sq_previewsnippet',
134
+ ),
135
+ ),
136
+ 'active' => '1',
137
+ ),
138
+ array(
139
+ 'name' => 'SQ_Controllers_Patterns',
140
+ 'description' => 'Patterns Class',
141
+ 'actions' => array(
142
+ 'action' => array(
143
+ 'sq_getpatterns',
144
+ ),
145
+ ),
146
+ 'active' => '1',
147
+ ),
148
+ array(
149
+ 'name' => 'SQ_Controllers_BulkSeo',
150
+ 'actions' => array(
151
+ 'action' => array(
152
+ 'sq_ajax_assistant_bulkseo',
153
+ ),
154
+ ),
155
+ 'active' => '1',
156
+ ),
157
+ array(
158
+ 'name' => 'SQ_Controllers_SeoSettings',
159
+ 'actions' => array(
160
+ 'action' => array(
161
+ 'sq_seosettings_automation',
162
+ 'sq_seosettings_bulkseo',
163
+ 'sq_seosettings_jsonld',
164
+ 'sq_seosettings_metas',
165
+ 'sq_seosettings_links',
166
+ 'sq_seosettings_social',
167
+ 'sq_seosettings_tracking',
168
+ 'sq_seosettings_webmaster',
169
+ 'sq_seosettings_sitemap',
170
+ 'sq_seosettings_robots',
171
+ 'sq_seosettings_favicon',
172
+ 'sq_seosettings_backupsettings',
173
+ 'sq_seosettings_backupseo',
174
+ 'sq_seosettings_restoresettings',
175
+ 'sq_seosettings_restoreseo',
176
+ 'sq_seosettings_importsettings',
177
+ 'sq_seosettings_importseo',
178
+ 'sq_seosettings_importall',
179
+ 'sq_seosettings_ga_revoke',
180
+ 'sq_seosettings_gsc_revoke',
181
+ 'sq_seosettings_gsc_check',
182
+ 'sq_seosettings_ga_check',
183
+ 'sq_reinstall',
184
+ 'sq_rollback',
185
+ 'sq_alerts_close',
186
+ 'sq_ajax_seosettings_save',
187
+ 'sq_ajax_automation_addpostype',
188
+ 'sq_ajax_automation_deletepostype',
189
+ 'sq_ajax_sla_sticky',
190
+ 'sq_ajax_gsc_code',
191
+ 'sq_ajax_ga_code',
192
+ 'sq_ajax_connection_check',
193
+ 'sq_seosettings_advanced',
194
+ ),
195
+ ),
196
+ 'active' => '1',
197
+ ),
198
+ array(
199
+ 'name' => 'SQ_Controllers_Research',
200
+ 'actions' => array(
201
+ 'action' => array(
202
+ 'sq_briefcase_addlabel',
203
+ 'sq_briefcase_editlabel',
204
+ 'sq_briefcase_keywordlabel',
205
+ 'sq_briefcase_article',
206
+ 'sq_briefcase_doresearch',
207
+ 'sq_briefcase_addkeyword',
208
+ 'sq_briefcase_deletekeyword',
209
+ 'sq_briefcase_deletelabel',
210
+ 'sq_briefcase_deletefound',
211
+ 'sq_briefcase_savemain',
212
+ 'sq_briefcase_backup',
213
+ 'sq_briefcase_restore',
214
+ 'sq_ajax_briefcase_doserp',
215
+ 'sq_ajax_research_others',
216
+ 'sq_ajax_research_process',
217
+ 'sq_ajax_research_history',
218
+ 'sq_ajax_briefcase_bulk_delete',
219
+ 'sq_ajax_briefcase_bulk_label',
220
+ 'sq_ajax_briefcase_bulk_doserp',
221
+ 'sq_ajax_labels_bulk_delete',
222
+ ),
223
+ ),
224
+ 'active' => '1',
225
+ ),
226
+ array(
227
+ 'name' => 'SQ_Controllers_Audits',
228
+ 'actions' => array(
229
+ 'action' => array(
230
+ 'sq_audits_settings',
231
+ 'sq_auditpages_getaudit',
232
+ 'sq_audits_getpage',
233
+ 'sq_audits_addnew',
234
+ 'sq_audits_page_update',
235
+ 'sq_audits_update',
236
+ 'sq_audits_delete',
237
+ ),
238
+ ),
239
+ 'active' => '1',
240
+ ),
241
+ array(
242
+ 'name' => 'SQ_Controllers_Ranking',
243
+ 'actions' => array(
244
+ 'action' => array(
245
+ 'sq_ranking_settings',
246
+ 'sq_serp_refresh_post',
247
+ 'sq_serp_delete_keyword',
248
+ 'sq_ajax_rank_bulk_delete',
249
+ 'sq_ajax_rank_bulk_refresh',
250
+ ),
251
+ ),
252
+ 'active' => '1',
253
+ ),
254
+ array(
255
+ 'name' => 'SQ_Controllers_Assistant',
256
+ 'actions' => array(
257
+ 'action' => array(
258
+ 'sq_settings_assistant',
259
+ 'sq_ajax_assistant',
260
+ ),
261
+ ),
262
+ 'active' => '1',
263
+ ),
264
+ array(
265
+ 'name' => 'SQ_Controllers_CheckSeo',
266
+ 'actions' => array(
267
+ 'action' => array(
268
+ 'sq_checkseo',
269
+ 'sq_fixsettings',
270
+ 'sq_donetask',
271
+ 'sq_resetignored',
272
+ 'sq_moretasks',
273
+ 'sq_ajax_checkseo',
274
+ 'sq_ajax_getgoals',
275
+ ),
276
+ ),
277
+ 'active' => '1',
278
+ ),
279
+ array(
280
+ 'name' => 'SQ_Controllers_Onboarding',
281
+ 'actions' => array(
282
+ 'action' => array(
283
+ 'sq_onboarding_commitment',
284
+ 'sq_onboading_checksite',
285
+ 'sq_onboarding_settings',
286
+ ),
287
+ ),
288
+ 'active' => '1',
289
+ ),
290
+ array(
291
+ 'name' => 'SQ_Core_BlockJorney',
292
+ 'actions' => array(
293
+ 'action' => array(
294
+ 'sq_journey_close',
295
+ ),
296
+ ),
297
+ 'active' => '1',
298
+ ),
299
+ array(
300
+ 'name' => 'SQ_Core_BlockSupport',
301
+ 'actions' => array(
302
+ 'action' => array(
303
+ 'sq_feedback',
304
+ 'sq_uninstall_feedback',
305
+ ),
306
+ ),
307
+ 'active' => '1',
308
+ ),
309
+ array(
310
+ 'name' => 'SQ_Core_BlockSearch',
311
+ 'actions' => array(
312
+ 'action' => array(
313
+ 'sq_ajax_search',
314
+ ),
315
+ ),
316
+ 'active' => '1',
317
+ ),
318
+ array(
319
+ 'name' => 'SQ_Controllers_Dashboard',
320
+ 'actions' => array(
321
+ 'action' => array(
322
+ 'sq_ajaxcheckseo',
323
+ ),
324
+ ),
325
+ 'active' => '1',
326
+ ),
327
+ );
328
+ }
329
+
330
  /**
331
  * Get all actions from config.json in core directory and add them in the WP
332
  *
333
  */
334
  public function getActions() {
335
 
336
+ if (!is_admin()) {
337
+ return;
338
+ }
339
 
340
  $this->actions = array();
341
  $cur_action = SQ_Classes_Helpers_Tools::getValue('action', false);
342
  $http_referer = SQ_Classes_Helpers_Tools::getValue('_wp_http_referer', false);
343
  $sq_nonce = SQ_Classes_Helpers_Tools::getValue('sq_nonce', false);
344
 
 
 
 
 
345
  //Let only the logged users to access the actions
346
+ if ($cur_action <> '' && $sq_nonce <> '') {
 
 
 
 
 
 
347
 
348
+ //load the actions list for each class
349
+ $actions = $this->getActionsList();
 
350
 
351
+ if(!empty($actions)) {
352
+ foreach ($actions as $block) {
353
  if (isset($block['active']) && $block['active'] == 1) {
354
  /* if there is a single action */
355
  if (isset($block['actions']['action']))
356
+ /* if there are more actions for the current block */
357
+ if (!is_array($block['actions']['action'])) {
358
+ /* add the action in the actions array */
359
+ if ($block['actions']['action'] == $cur_action) {
360
+ $this->actions[] = array('class' => $block['name']);
361
+ }
362
+ } else {
363
  /* if there are more actions for the current block */
364
+ foreach ($block['actions']['action'] as $action) {
365
+ /* add the actions in the actions array */
366
+ if ($action == $cur_action) {
367
  $this->actions[] = array('class' => $block['name']);
368
  }
 
 
 
 
 
 
 
 
369
  }
370
  }
 
371
  }
372
  }
373
+ }
374
 
375
  //If there is an action found in the config.js file
376
  if (!empty($this->actions)) {
classes/RemoteController.php CHANGED
@@ -1337,7 +1337,7 @@ class SQ_Classes_RemoteController {
1337
  prevNonce: "' . wp_create_nonce('post_preview_' . $sq_postID) . '",
1338
  __keyword: "' . esc_html__('Keyword:', _SQ_PLUGIN_NAME_) . '",
1339
  __date: "' . esc_html__('date', _SQ_PLUGIN_NAME_) . '",
1340
- __noconnection: "' . esc_html__("To load Squirrly Live Assistant and optimize this page, click to connect to Squirrly Data Cloud.", _SQ_PLUGIN_NAME_) . '",
1341
  __saved: "' . esc_html__('Saved!', _SQ_PLUGIN_NAME_) . '",
1342
  __readit: "' . esc_html__('Read it!', _SQ_PLUGIN_NAME_) . '",
1343
  __insertit: "' . esc_html__('Insert it!', _SQ_PLUGIN_NAME_) . '",
@@ -1370,12 +1370,16 @@ class SQ_Classes_RemoteController {
1370
  __add_keyword_briefcase: "' . esc_html__('Add Keyword to Briefcase', _SQ_PLUGIN_NAME_) . '",
1371
  __usekeyword: "' . esc_html__('Select', _SQ_PLUGIN_NAME_) . '",
1372
  __new_post_title: "' . esc_html__('Auto Draft') . '",
1373
- __frontend_optimized: "' . esc_html__('You’ve already used the Live Assistant to optimize this post when creating it in your Page Builder. Please go back and resume your optimization work there.', _SQ_PLUGIN_NAME_) . '",
 
 
1374
  };
1375
  $.sq_params = {
1376
  max_length_title: ' . (int)$metas->title_maxlength . ',
1377
  max_length_description: ' . (int)$metas->description_maxlength . ',
1378
  };
 
 
1379
  })(jQuery);
1380
  </script>';
1381
 
@@ -1383,4 +1387,4 @@ class SQ_Classes_RemoteController {
1383
 
1384
  }
1385
 
1386
- }
1337
  prevNonce: "' . wp_create_nonce('post_preview_' . $sq_postID) . '",
1338
  __keyword: "' . esc_html__('Keyword:', _SQ_PLUGIN_NAME_) . '",
1339
  __date: "' . esc_html__('date', _SQ_PLUGIN_NAME_) . '",
1340
+ __noconnection: "' . esc_html__("To load the Live Assistant and optimize this page, click to connect to Squirrly Cloud.", _SQ_PLUGIN_NAME_) . '",
1341
  __saved: "' . esc_html__('Saved!', _SQ_PLUGIN_NAME_) . '",
1342
  __readit: "' . esc_html__('Read it!', _SQ_PLUGIN_NAME_) . '",
1343
  __insertit: "' . esc_html__('Insert it!', _SQ_PLUGIN_NAME_) . '",
1370
  __add_keyword_briefcase: "' . esc_html__('Add Keyword to Briefcase', _SQ_PLUGIN_NAME_) . '",
1371
  __usekeyword: "' . esc_html__('Select', _SQ_PLUGIN_NAME_) . '",
1372
  __new_post_title: "' . esc_html__('Auto Draft') . '",
1373
+ __enter_keyword: "' . esc_html__('Enter keyword above and press ENTER', _SQ_PLUGIN_NAME_) . '",
1374
+ __add_keyword: "' . esc_html__('Add Keywords from Briefcase', _SQ_PLUGIN_NAME_) . '",
1375
+ __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.', _SQ_PLUGIN_NAME_) . '",
1376
  };
1377
  $.sq_params = {
1378
  max_length_title: ' . (int)$metas->title_maxlength . ',
1379
  max_length_description: ' . (int)$metas->description_maxlength . ',
1380
  };
1381
+
1382
+
1383
  })(jQuery);
1384
  </script>';
1385
 
1387
 
1388
  }
1389
 
1390
+ }
classes/helpers/DevKit.php CHANGED
@@ -20,14 +20,16 @@ class SQ_Classes_Helpers_DevKit {
20
  }
21
 
22
  //Hook DevKit options
23
- add_filter('admin_head', array($this, 'hookHead'));
24
- add_filter('sq_menu', array($this, 'manageMenu'));
25
- add_filter('sq_features', array($this, 'manageFeatures'));
26
- add_filter('sq_logo', array($this, 'getCustomLogo'));
27
- add_filter('sq_name', array($this, 'getCustomName'));
28
- add_filter('sq_menu_name', array($this, 'getCustomMenuName'));
29
- add_filter('sq_audit_success_task', array($this, 'getCustomAuditSuccessTask'));
30
- add_filter('sq_audit_fail_task', array($this, 'getCustomAuditFailTask'));
 
 
31
 
32
  }
33
 
@@ -36,12 +38,12 @@ class SQ_Classes_Helpers_DevKit {
36
  * @param $task
37
  * @return mixed
38
  */
39
- public function getCustomAuditSuccessTask($task){
40
 
41
- if(SQ_Classes_Helpers_Tools::getOption('sq_devkit_audit_success')) {
42
  if ($customTask = SQ_Classes_Helpers_Tools::getOption('sq_devkit_audit_success')) {
43
  foreach ($customTask as $key => $value) {
44
- if ($value <> ''|| $value === false) {
45
  $task->$key = stripslashes($value);
46
  }
47
  }
@@ -56,12 +58,12 @@ class SQ_Classes_Helpers_DevKit {
56
  * @param $task
57
  * @return mixed
58
  */
59
- public function getCustomAuditFailTask($task){
60
 
61
- if(SQ_Classes_Helpers_Tools::getOption('sq_devkit_audit_fail')) {
62
  if ($customTask = SQ_Classes_Helpers_Tools::getOption('sq_devkit_audit_fail')) {
63
  foreach ($customTask as $key => $value) {
64
- if ($value <> ''|| $value === false) {
65
  $task->$key = stripslashes($value);
66
  }
67
  }
@@ -77,12 +79,12 @@ class SQ_Classes_Helpers_DevKit {
77
  public function hookHead() {
78
  //Hide the ads
79
  if (!SQ_Classes_Helpers_Tools::getMenuVisible('show_ads')) {
80
- echo '<style>.sq_offer {display: none !important;}</style>';
81
  }
82
 
83
  //Dev Kit images
84
  if (SQ_Classes_Helpers_Tools::getOption('sq_devkit_logo')) {
85
- echo '<style>.toplevel_page_sq_dashboard .wp-menu-image img{max-width: 24px !important;}.sq_logo{background-image:url("' . SQ_Classes_Helpers_Tools::getOption('sq_devkit_logo') . '") !important;background-size: 100%;}</style>';
86
  }
87
  }
88
 
@@ -129,7 +131,7 @@ class SQ_Classes_Helpers_DevKit {
129
  }
130
 
131
  //Change the features
132
- public function manageFeatures($features){
133
  if (!SQ_Classes_Helpers_Tools::getMenuVisible('show_panel')) {
134
  unset($features[0]); //remove the Cloud App features
135
  }
@@ -190,8 +192,13 @@ class SQ_Classes_Helpers_DevKit {
190
  SQ_Classes_Helpers_Tools::saveOptions();
191
  unlink($package_file);
192
 
193
- wp_redirect(SQ_Classes_Helpers_Tools::getAdminUrl('sq_dashboard'));
194
- exit();
 
 
 
 
 
195
  }
196
  }
197
 
20
  }
21
 
22
  //Hook DevKit options
23
+ if (SQ_Classes_Helpers_Tools::getOption('sq_api')) {
24
+ add_filter('admin_head', array($this, 'hookHead'));
25
+ add_filter('sq_menu', array($this, 'manageMenu'));
26
+ add_filter('sq_features', array($this, 'manageFeatures'));
27
+ add_filter('sq_logo', array($this, 'getCustomLogo'));
28
+ add_filter('sq_name', array($this, 'getCustomName'));
29
+ add_filter('sq_menu_name', array($this, 'getCustomMenuName'));
30
+ add_filter('sq_audit_success_task', array($this, 'getCustomAuditSuccessTask'));
31
+ add_filter('sq_audit_fail_task', array($this, 'getCustomAuditFailTask'));
32
+ }
33
 
34
  }
35
 
38
  * @param $task
39
  * @return mixed
40
  */
41
+ public function getCustomAuditSuccessTask($task) {
42
 
43
+ if (SQ_Classes_Helpers_Tools::getOption('sq_devkit_audit_success')) {
44
  if ($customTask = SQ_Classes_Helpers_Tools::getOption('sq_devkit_audit_success')) {
45
  foreach ($customTask as $key => $value) {
46
+ if ($value <> '' || $value === false) {
47
  $task->$key = stripslashes($value);
48
  }
49
  }
58
  * @param $task
59
  * @return mixed
60
  */
61
+ public function getCustomAuditFailTask($task) {
62
 
63
+ if (SQ_Classes_Helpers_Tools::getOption('sq_devkit_audit_fail')) {
64
  if ($customTask = SQ_Classes_Helpers_Tools::getOption('sq_devkit_audit_fail')) {
65
  foreach ($customTask as $key => $value) {
66
+ if ($value <> '' || $value === false) {
67
  $task->$key = stripslashes($value);
68
  }
69
  }
79
  public function hookHead() {
80
  //Hide the ads
81
  if (!SQ_Classes_Helpers_Tools::getMenuVisible('show_ads')) {
82
+ echo '<style>.sq_offer{display: none !important;}</style>';
83
  }
84
 
85
  //Dev Kit images
86
  if (SQ_Classes_Helpers_Tools::getOption('sq_devkit_logo')) {
87
+ echo '<style>.sq_logo{background-image:url("' . SQ_Classes_Helpers_Tools::getOption('sq_devkit_logo') . '") !important;}#sq_blocksnippet .postbox-header h2:before,.toplevel_page_sq_dashboard .wp-menu-image:before{background-image:url("' . SQ_Classes_Helpers_Tools::getOption('sq_devkit_logo') . '") !important;}.components-squirrly-icon img{content:url("' . SQ_Classes_Helpers_Tools::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%;}.toplevel_page_sq_dashboard .wp-menu-image img{display: none !important;}</style>';
88
  }
89
  }
90
 
131
  }
132
 
133
  //Change the features
134
+ public function manageFeatures($features) {
135
  if (!SQ_Classes_Helpers_Tools::getMenuVisible('show_panel')) {
136
  unset($features[0]); //remove the Cloud App features
137
  }
192
  SQ_Classes_Helpers_Tools::saveOptions();
193
  unlink($package_file);
194
 
195
+ if (SQ_Classes_Helpers_Tools::getMenuVisible('show_tutorial')) {
196
+ wp_redirect(SQ_Classes_Helpers_Tools::getAdminUrl('sq_onboarding'));
197
+ die();
198
+ } else {
199
+ wp_redirect(SQ_Classes_Helpers_Tools::getAdminUrl('sq_dashboard'));
200
+ die();
201
+ }
202
  }
203
  }
204
 
classes/helpers/Tools.php CHANGED
@@ -47,10 +47,6 @@ class SQ_Classes_Helpers_Tools {
47
 
48
  }
49
 
50
- public static function getUsedMemory() {
51
- return number_format(memory_get_usage() / 1024 / 1024, 0);
52
- }
53
-
54
  public static function isAjax() {
55
  return (defined('DOING_AJAX') && DOING_AJAX);
56
  }
@@ -156,7 +152,7 @@ class SQ_Classes_Helpers_Tools {
156
  'sq_sla_type' => 'auto',
157
  'sq_sla_exclude_post_types' => array(),
158
  'sq_keyword_help' => 1,
159
- 'sq_local_images' => 1,
160
  'sq_img_licence' => 1,
161
  'sq_sla_social_fetch' => 1,
162
 
@@ -168,6 +164,8 @@ class SQ_Classes_Helpers_Tools {
168
  'sq_jsonld_breadcrumbs' => 1,
169
  'sq_jsonld_woocommerce' => 1,
170
  'sq_jsonld_clearcode' => 0,
 
 
171
  'sq_jsonld_product_defaults' => 1,
172
  'sq_jsonld_local' => array(
173
  'priceRange' => '',
@@ -236,6 +234,7 @@ class SQ_Classes_Helpers_Tools {
236
  '@type' => 'PostalAddress',
237
  'streetAddress' => '',
238
  'addressLocality' => '',
 
239
  'postalCode' => '',
240
  'addressCountry' => '',
241
  ),
@@ -269,7 +268,7 @@ class SQ_Classes_Helpers_Tools {
269
  'images' => 1,
270
  'videos' => 0,
271
  ),
272
- 'sq_sitemap_perpage' => 200,
273
  'sq_sitemap_frequency' => 'weekly',
274
  'sq_sitemap_combinelangs' => 0,
275
  'sq_sitemap' => array(
@@ -303,6 +302,7 @@ class SQ_Classes_Helpers_Tools {
303
  'sq_use' => 1,
304
  'sq_auto_metas' => 1,
305
  'sq_auto_links' => 0,
 
306
  'sq_auto_title' => 1,
307
  'sq_auto_description' => 1,
308
  'sq_auto_keywords' => 1,
@@ -313,10 +313,11 @@ class SQ_Classes_Helpers_Tools {
313
  'sq_auto_noindex' => 1,
314
  'sq_use_frontend' => 1,
315
  'sq_attachment_redirect' => 0,
316
- 'sq_permalink_redirect' => 1,
 
317
  'sq_external_nofollow' => 1,
318
  'sq_external_exception' => array(),
319
- 'sq_external_blank' => 1,
320
  'sq_metas' => array(
321
  'title_maxlength' => 75,
322
  'description_maxlength' => 320,
@@ -366,6 +367,8 @@ class SQ_Classes_Helpers_Tools {
366
  'sq_auto_facebook' => 1,
367
  'sq_auto_twitter' => 1,
368
  'sq_og_locale' => 'en_US',
 
 
369
 
370
  'socials' => array(
371
  'fb_admins' => array(),
@@ -1189,13 +1192,13 @@ class SQ_Classes_Helpers_Tools {
1189
  public static function isPluginInstalled($name) {
1190
  if (empty(self::$allplugins)) {
1191
  self::$allplugins = (array)get_option('active_plugins', array());
1192
- }
1193
 
1194
- if (!empty(self::$allplugins)) {
1195
  if (is_multisite()) {
1196
  self::$allplugins = array_merge(array_values(self::$allplugins), array_keys(get_site_option('active_sitewide_plugins')));
1197
  }
 
1198
 
 
1199
  return in_array($name, self::$allplugins, true);
1200
  }
1201
 
@@ -1207,7 +1210,7 @@ class SQ_Classes_Helpers_Tools {
1207
  * @return bool
1208
  */
1209
  public static function isFrontAdmin() {
1210
- return (!is_admin() && is_user_logged_in());
1211
  }
1212
 
1213
  /**
@@ -1223,6 +1226,11 @@ class SQ_Classes_Helpers_Tools {
1223
  * @return bool
1224
  */
1225
  public static function isEcommerce() {
 
 
 
 
 
1226
  $products = array('product', 'wpsc-product');
1227
  $post_types = get_post_types(array('public' => true));
1228
 
@@ -1263,6 +1271,32 @@ class SQ_Classes_Helpers_Tools {
1263
  return false;
1264
  }
1265
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1266
  /**
1267
  * Get the admin url for the specific age
1268
  *
@@ -1306,43 +1340,8 @@ class SQ_Classes_Helpers_Tools {
1306
  global $wp_filesystem;
1307
 
1308
  if (!$wp_filesystem || empty($wp_filesystem)) {
1309
- $credentials = array();
1310
-
1311
- if (!defined('FS_METHOD')) {
1312
- define('FS_METHOD', 'direct');
1313
- }
1314
-
1315
- $method = defined('FS_METHOD') ? FS_METHOD : false;
1316
-
1317
- if ('ftpext' === $method) {
1318
- // If defined, set it to that, Else, set to NULL.
1319
- $credentials['hostname'] = defined('FTP_HOST') ? preg_replace('|\w+://|', '', FTP_HOST) : null;
1320
- $credentials['username'] = defined('FTP_USER') ? FTP_USER : null;
1321
- $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : null;
1322
-
1323
- // Set FTP port.
1324
- if (strpos($credentials['hostname'], ':') && null !== $credentials['hostname']) {
1325
- list($credentials['hostname'], $credentials['port']) = explode(':', $credentials['hostname'], 2);
1326
- if (!is_numeric($credentials['port'])) {
1327
- unset($credentials['port']);
1328
- }
1329
- } else {
1330
- unset($credentials['port']);
1331
- }
1332
-
1333
- // Set connection type.
1334
- if ((defined('FTP_SSL') && FTP_SSL) && 'ftpext' === $method) {
1335
- $credentials['connection_type'] = 'ftps';
1336
- } elseif (!array_filter($credentials)) {
1337
- $credentials['connection_type'] = null;
1338
- } else {
1339
- $credentials['connection_type'] = 'ftp';
1340
- }
1341
- }
1342
-
1343
-
1344
  require_once wp_normalize_path(ABSPATH . '/wp-admin/includes/file.php');
1345
- WP_Filesystem($credentials);
1346
  }
1347
 
1348
  return $wp_filesystem;
47
 
48
  }
49
 
 
 
 
 
50
  public static function isAjax() {
51
  return (defined('DOING_AJAX') && DOING_AJAX);
52
  }
152
  'sq_sla_type' => 'auto',
153
  'sq_sla_exclude_post_types' => array(),
154
  'sq_keyword_help' => 1,
155
+ 'sq_local_images' => 0,
156
  'sq_img_licence' => 1,
157
  'sq_sla_social_fetch' => 1,
158
 
164
  'sq_jsonld_breadcrumbs' => 1,
165
  'sq_jsonld_woocommerce' => 1,
166
  'sq_jsonld_clearcode' => 0,
167
+ 'sq_jsonld_product_rating' => 0,
168
+ 'sq_jsonld_product_custom' => 1,
169
  'sq_jsonld_product_defaults' => 1,
170
  'sq_jsonld_local' => array(
171
  'priceRange' => '',
234
  '@type' => 'PostalAddress',
235
  'streetAddress' => '',
236
  'addressLocality' => '',
237
+ 'addressRegion' => '',
238
  'postalCode' => '',
239
  'addressCountry' => '',
240
  ),
268
  'images' => 1,
269
  'videos' => 0,
270
  ),
271
+ 'sq_sitemap_perpage' => 500,
272
  'sq_sitemap_frequency' => 'weekly',
273
  'sq_sitemap_combinelangs' => 0,
274
  'sq_sitemap' => array(
302
  'sq_use' => 1,
303
  'sq_auto_metas' => 1,
304
  'sq_auto_links' => 0,
305
+ 'sq_auto_redirects' => 1,
306
  'sq_auto_title' => 1,
307
  'sq_auto_description' => 1,
308
  'sq_auto_keywords' => 1,
313
  'sq_auto_noindex' => 1,
314
  'sq_use_frontend' => 1,
315
  'sq_attachment_redirect' => 0,
316
+ 'profile_noindex_empty' => 0,
317
+ '404_url_redirect' => home_url(),
318
  'sq_external_nofollow' => 1,
319
  'sq_external_exception' => array(),
320
+ 'sq_external_blank' => 0,
321
  'sq_metas' => array(
322
  'title_maxlength' => 75,
323
  'description_maxlength' => 320,
367
  'sq_auto_facebook' => 1,
368
  'sq_auto_twitter' => 1,
369
  'sq_og_locale' => 'en_US',
370
+ 'sq_og_image' => '',
371
+ 'sq_tc_image' => '',
372
 
373
  'socials' => array(
374
  'fb_admins' => array(),
1192
  public static function isPluginInstalled($name) {
1193
  if (empty(self::$allplugins)) {
1194
  self::$allplugins = (array)get_option('active_plugins', array());
 
1195
 
 
1196
  if (is_multisite()) {
1197
  self::$allplugins = array_merge(array_values(self::$allplugins), array_keys(get_site_option('active_sitewide_plugins')));
1198
  }
1199
+ }
1200
 
1201
+ if (!empty(self::$allplugins)) {
1202
  return in_array($name, self::$allplugins, true);
1203
  }
1204
 
1210
  * @return bool
1211
  */
1212
  public static function isFrontAdmin() {
1213
+ return (!is_admin() && (function_exists('is_user_logged_in') && is_user_logged_in()));
1214
  }
1215
 
1216
  /**
1226
  * @return bool
1227
  */
1228
  public static function isEcommerce() {
1229
+
1230
+ if(self::isPluginInstalled('woocommerce/woocommerce.php')){
1231
+ return true;
1232
+ }
1233
+
1234
  $products = array('product', 'wpsc-product');
1235
  $post_types = get_post_types(array('public' => true));
1236
 
1271
  return false;
1272
  }
1273
 
1274
+ /**
1275
+ * Check the user capability for the roles attached
1276
+ *
1277
+ * @param $cap
1278
+ * @param mixed ...$args
1279
+ * @return bool
1280
+ */
1281
+ public static function userCan($cap, ...$args ) {
1282
+
1283
+ if (current_user_can($cap, ...$args)) {
1284
+ return true;
1285
+ }
1286
+
1287
+ $user = wp_get_current_user();
1288
+ if (count((array)$user->roles) > 1) {
1289
+ foreach ($user->roles as $role) {
1290
+ $role_object = get_role($role);
1291
+ if ($role_object->has_cap($cap)) {
1292
+ return true;
1293
+ }
1294
+ }
1295
+ }
1296
+
1297
+ return false;
1298
+ }
1299
+
1300
  /**
1301
  * Get the admin url for the specific age
1302
  *
1340
  global $wp_filesystem;
1341
 
1342
  if (!$wp_filesystem || empty($wp_filesystem)) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1343
  require_once wp_normalize_path(ABSPATH . '/wp-admin/includes/file.php');
1344
+ WP_Filesystem();
1345
  }
1346
 
1347
  return $wp_filesystem;
config/config.php CHANGED
@@ -45,21 +45,25 @@ define('SQ_ALL_PATTERNS', wp_json_encode(array(
45
  '{{searchphrase}}' => esc_html__("Displays the search phrase (if it appears in the post)", _SQ_PLUGIN_NAME_),
46
  '{{modified}}' => esc_html__("Replaces the publication date of a post/page with the modified one", _SQ_PLUGIN_NAME_),
47
  '{{name}}' => esc_html__("Displays the author's nicename", _SQ_PLUGIN_NAME_),
 
 
48
  '{{user_description}}' => esc_html__("Adds the author's biographical info to the post description", _SQ_PLUGIN_NAME_),
49
- '{{currentdate}}' => esc_html__("Displays the current date", _SQ_PLUGIN_NAME_),
50
  '{{date}}' => esc_html__("Displays the date of the post/page once it's published", _SQ_PLUGIN_NAME_),
 
51
  '{{currentday}}' => esc_html__("Adds the current day", _SQ_PLUGIN_NAME_),
52
  '{{currentmonth}}' => esc_html__("Adds the current month", _SQ_PLUGIN_NAME_),
53
  '{{currentyear}}' => esc_html__("Adds the current year", _SQ_PLUGIN_NAME_),
54
  '{{parent_title}}' => esc_html__("Adds the title of a page's parent page", _SQ_PLUGIN_NAME_),
55
  '{{product_name}}' => esc_html__("Adds the product name from Woocommerce for the current product", _SQ_PLUGIN_NAME_),
56
  '{{product_price}}' => esc_html__("Adds the product price from Woocommerce for the current product", _SQ_PLUGIN_NAME_),
 
57
  '{{product_sale}}' => esc_html__("Adds the product sale price from Woocommerce for the current product", _SQ_PLUGIN_NAME_),
58
  '{{product_currency}}' => esc_html__("Adds the product price currency from Woocommerce for the current product", _SQ_PLUGIN_NAME_),
 
59
  )));
60
 
61
- define('SQ_ALL_OG_TYPES', wp_json_encode(array('website','article','profile','book','music','video')));
62
- define('SQ_ALL_JSONLD_TYPES', wp_json_encode(array('website','article','newsarticle','FAQ page','question','recipe','review','movie','video','local store','local restaurant','profile')));
63
 
64
  define('SQ_ALL_SEP', wp_json_encode(array(
65
  'sc-dash' => '-',
45
  '{{searchphrase}}' => esc_html__("Displays the search phrase (if it appears in the post)", _SQ_PLUGIN_NAME_),
46
  '{{modified}}' => esc_html__("Replaces the publication date of a post/page with the modified one", _SQ_PLUGIN_NAME_),
47
  '{{name}}' => esc_html__("Displays the author's nicename", _SQ_PLUGIN_NAME_),
48
+ '{{single}}' => esc_html__("Displays the post type singular label", _SQ_PLUGIN_NAME_),
49
+ '{{plural}}' => esc_html__("Displays the post type plural label", _SQ_PLUGIN_NAME_),
50
  '{{user_description}}' => esc_html__("Adds the author's biographical info to the post description", _SQ_PLUGIN_NAME_),
 
51
  '{{date}}' => esc_html__("Displays the date of the post/page once it's published", _SQ_PLUGIN_NAME_),
52
+ '{{currentdate}}' => esc_html__("Displays the current date", _SQ_PLUGIN_NAME_),
53
  '{{currentday}}' => esc_html__("Adds the current day", _SQ_PLUGIN_NAME_),
54
  '{{currentmonth}}' => esc_html__("Adds the current month", _SQ_PLUGIN_NAME_),
55
  '{{currentyear}}' => esc_html__("Adds the current year", _SQ_PLUGIN_NAME_),
56
  '{{parent_title}}' => esc_html__("Adds the title of a page's parent page", _SQ_PLUGIN_NAME_),
57
  '{{product_name}}' => esc_html__("Adds the product name from Woocommerce for the current product", _SQ_PLUGIN_NAME_),
58
  '{{product_price}}' => esc_html__("Adds the product price from Woocommerce for the current product", _SQ_PLUGIN_NAME_),
59
+ '{{product_price_with_tax}}' => esc_html__("Adds the product price with Tax from Woocommerce for the current product", _SQ_PLUGIN_NAME_),
60
  '{{product_sale}}' => esc_html__("Adds the product sale price from Woocommerce for the current product", _SQ_PLUGIN_NAME_),
61
  '{{product_currency}}' => esc_html__("Adds the product price currency from Woocommerce for the current product", _SQ_PLUGIN_NAME_),
62
+ '{{product_brand}}' => esc_html__("Adds the product brand from Woocommerce for the current product", _SQ_PLUGIN_NAME_),
63
  )));
64
 
65
+ define('SQ_ALL_OG_TYPES', wp_json_encode(array('website', 'article', 'profile', 'book', 'music', 'video')));
66
+ define('SQ_ALL_JSONLD_TYPES', wp_json_encode(array('website', 'article', 'newsarticle', 'FAQ page', 'question', 'recipe', 'review', 'movie', 'video', 'local store', 'local restaurant', 'profile')));
67
 
68
  define('SQ_ALL_SEP', wp_json_encode(array(
69
  'sc-dash' => '-',
config/paths.php CHANGED
@@ -8,11 +8,11 @@ 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())) ? 'https:' : 'http:')); //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 . '//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');
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');
controllers/Assistant.php CHANGED
@@ -97,7 +97,7 @@ class SQ_Controllers_Assistant extends SQ_Classes_FrontController {
97
 
98
  ///////////////////////////////////////////LIVE ASSISTANT SETTINGS
99
  case 'sq_settings_assistant':
100
- if (!current_user_can('sq_manage_settings')) {
101
  return;
102
  }
103
 
@@ -112,7 +112,7 @@ class SQ_Controllers_Assistant extends SQ_Classes_FrontController {
112
  break;
113
 
114
  case 'sq_ajax_assistant':
115
- if (!current_user_can('sq_manage_snippets')) {
116
  $response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", _SQ_PLUGIN_NAME_), 'sq_error');
117
  SQ_Classes_Helpers_Tools::setHeader('json');
118
  echo wp_json_encode($response);
97
 
98
  ///////////////////////////////////////////LIVE ASSISTANT SETTINGS
99
  case 'sq_settings_assistant':
100
+ if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
101
  return;
102
  }
103
 
112
  break;
113
 
114
  case 'sq_ajax_assistant':
115
+ if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippets')) {
116
  $response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", _SQ_PLUGIN_NAME_), 'sq_error');
117
  SQ_Classes_Helpers_Tools::setHeader('json');
118
  echo wp_json_encode($response);
controllers/Audits.php CHANGED
@@ -262,7 +262,7 @@ class SQ_Controllers_Audits extends SQ_Classes_FrontController {
262
  }
263
  break;
264
  case 'sq_audits_addnew':
265
- if (!current_user_can('sq_manage_focuspages')) {
266
  return;
267
  }
268
 
@@ -296,7 +296,7 @@ class SQ_Controllers_Audits extends SQ_Classes_FrontController {
296
  }
297
  break;
298
  case 'sq_audits_page_update':
299
- if (!current_user_can('sq_manage_focuspages')) {
300
  return;
301
  }
302
 
@@ -320,7 +320,7 @@ class SQ_Controllers_Audits extends SQ_Classes_FrontController {
320
  }
321
  break;
322
  case 'sq_audits_update':
323
- if (!current_user_can('sq_manage_focuspages')) {
324
  return;
325
  }
326
 
@@ -336,7 +336,7 @@ class SQ_Controllers_Audits extends SQ_Classes_FrontController {
336
  }
337
  break;
338
  case 'sq_audits_delete':
339
- if (!current_user_can('sq_manage_focuspages')) {
340
  return;
341
  }
342
 
@@ -349,7 +349,7 @@ class SQ_Controllers_Audits extends SQ_Classes_FrontController {
349
 
350
  break;
351
  case 'sq_audits_settings':
352
- if (!current_user_can('sq_manage_settings')) {
353
  return;
354
  }
355
 
262
  }
263
  break;
264
  case 'sq_audits_addnew':
265
+ if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_focuspages')) {
266
  return;
267
  }
268
 
296
  }
297
  break;
298
  case 'sq_audits_page_update':
299
+ if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_focuspages')) {
300
  return;
301
  }
302
 
320
  }
321
  break;
322
  case 'sq_audits_update':
323
+ if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_focuspages')) {
324
  return;
325
  }
326
 
336
  }
337
  break;
338
  case 'sq_audits_delete':
339
+ if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_focuspages')) {
340
  return;
341
  }
342
 
349
 
350
  break;
351
  case 'sq_audits_settings':
352
+ if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
353
  return;
354
  }
355
 
controllers/BulkSeo.php CHANGED
@@ -69,7 +69,7 @@ class SQ_Controllers_BulkSeo extends SQ_Classes_FrontController {
69
  SQ_Classes_Helpers_Tools::setHeader('json');
70
 
71
  $response = array();
72
- if (!current_user_can('sq_manage_snippet')) {
73
  $response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", _SQ_PLUGIN_NAME_), 'sq_error');
74
  echo wp_json_encode($response);
75
  exit();
69
  SQ_Classes_Helpers_Tools::setHeader('json');
70
 
71
  $response = array();
72
+ if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
73
  $response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", _SQ_PLUGIN_NAME_), 'sq_error');
74
  echo wp_json_encode($response);
75
  exit();
controllers/CheckSeo.php CHANGED
@@ -236,7 +236,7 @@ class SQ_Controllers_CheckSeo extends SQ_Classes_FrontController {
236
  $row = array_merge(array('completed' => false, 'active' => true, 'done' => false, 'positive' => false), $row);
237
  $row['status'] = $row['active'] ? (($row['completed'] || $row['done']) ? 'completed' : '') : 'ignore';
238
 
239
- if ($tasks[$function]['positive'] && $row['status'] == 'completed') {
240
  $row = array_merge($tasks[$function], $row);
241
  } else {
242
  unset($report[$function]);
@@ -274,7 +274,7 @@ class SQ_Controllers_CheckSeo extends SQ_Classes_FrontController {
274
  public function action() {
275
  parent::action();
276
 
277
- if (!current_user_can('sq_manage_snippets')) {
278
  return;
279
  }
280
 
236
  $row = array_merge(array('completed' => false, 'active' => true, 'done' => false, 'positive' => false), $row);
237
  $row['status'] = $row['active'] ? (($row['completed'] || $row['done']) ? 'completed' : '') : 'ignore';
238
 
239
+ if ($tasks[$function]['positive'] && in_array($row['status'], array('completed', 'ignore'))) {
240
  $row = array_merge($tasks[$function], $row);
241
  } else {
242
  unset($report[$function]);
274
  public function action() {
275
  parent::action();
276
 
277
+ if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippets')) {
278
  return;
279
  }
280
 
controllers/Dashboard.php CHANGED
@@ -23,7 +23,7 @@ class SQ_Controllers_Dashboard extends SQ_Classes_FrontController {
23
  public function action() {
24
  parent::action();
25
 
26
- if (!current_user_can('sq_manage_snippets')) {
27
  return;
28
  }
29
 
23
  public function action() {
24
  parent::action();
25
 
26
+ if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippets')) {
27
  return;
28
  }
29
 
controllers/FocusPages.php CHANGED
@@ -323,7 +323,7 @@ class SQ_Controllers_FocusPages extends SQ_Classes_FrontController {
323
  echo wp_json_encode($json);
324
  exit();
325
  case 'sq_focuspages_addnew':
326
- if (!current_user_can('sq_manage_focuspages')) {
327
  return;
328
  }
329
 
@@ -366,7 +366,7 @@ class SQ_Controllers_FocusPages extends SQ_Classes_FrontController {
366
  }
367
  break;
368
  case 'sq_focuspages_update':
369
- if (!current_user_can('sq_manage_focuspages')) {
370
  return;
371
  }
372
 
@@ -405,7 +405,7 @@ class SQ_Controllers_FocusPages extends SQ_Classes_FrontController {
405
  }
406
  break;
407
  case 'sq_focuspages_delete':
408
- if (!current_user_can('sq_manage_focuspages')) {
409
  return;
410
  }
411
 
323
  echo wp_json_encode($json);
324
  exit();
325
  case 'sq_focuspages_addnew':
326
+ if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_focuspages')) {
327
  return;
328
  }
329
 
366
  }
367
  break;
368
  case 'sq_focuspages_update':
369
+ if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_focuspages')) {
370
  return;
371
  }
372
 
405
  }
406
  break;
407
  case 'sq_focuspages_delete':
408
+ if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_focuspages')) {
409
  return;
410
  }
411
 
controllers/Frontend.php CHANGED
@@ -32,11 +32,6 @@ class SQ_Controllers_Frontend extends SQ_Classes_FrontController {
32
  //Set the post so that Squirrly will know which one to process
33
  add_action('template_redirect', array($this->model, 'setPost'), 9);
34
 
35
- //Check the old permalink and redirect to the new permalink
36
- if (SQ_Classes_Helpers_Tools::getOption('sq_permalink_redirect')) {
37
- add_action('template_redirect', array($this->model, 'redirectPermalinks'), 10);
38
- }
39
-
40
  /* Check if sitemap is on and Load the Sitemap */
41
  if (SQ_Classes_Helpers_Tools::getOption('sq_auto_sitemap')) {
42
  add_filter('wp_sitemaps_enabled', '__return_false');
@@ -50,11 +45,6 @@ class SQ_Controllers_Frontend extends SQ_Classes_FrontController {
50
  add_action('template_redirect', array($this->model, 'redirectAttachments'), 10);
51
  }
52
 
53
- /* Fix the Links in content */
54
- if (SQ_Classes_Helpers_Tools::getOption('sq_external_nofollow') || SQ_Classes_Helpers_Tools::getOption('sq_external_blank')) {
55
- add_action('the_content', array($this, 'fixNofollowLinks'), 11);
56
- }
57
-
58
  }
59
  }
60
 
@@ -67,7 +57,11 @@ class SQ_Controllers_Frontend extends SQ_Classes_FrontController {
67
  remove_action('template_redirect', array($this, 'hookBuffer'), 1);
68
  }
69
 
70
- $this->model->startBuffer();
 
 
 
 
71
  }
72
 
73
  /**
@@ -114,95 +108,29 @@ class SQ_Controllers_Frontend extends SQ_Classes_FrontController {
114
  * Hook the Header load
115
  */
116
  public function hookFronthead() {
117
- if (!is_admin() && (!SQ_Classes_Helpers_Tools::getOption('sq_load_css') || defined('SQ_NOCSS') && SQ_NOCSS)) {
118
- return;
119
- }
120
 
121
- if (!SQ_Classes_Helpers_Tools::isAjax()) {
122
- SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia(_SQ_ASSETS_URL_ . 'css/frontend' . (SQ_DEBUG ? '' : '.min') . '.css');
123
  }
124
- }
125
 
126
-
127
- /**
128
- * Change the image path to absolute when in feed
129
- * @param string $content
130
- *
131
- * @return string
132
- */
133
- public function fixNofollowLinks($content) {
134
-
135
- if (!is_feed() && !is_404()) {
136
- preg_match_all('/<a[^>]*href=[\'"]([^\'"]+)[\'"][^>]*>/i', $content, $out);
137
- if (empty($out) || empty($out[0])) {
138
- return $content;
139
  }
 
140
 
141
- $domain = parse_url(home_url(), PHP_URL_HOST);
142
-
143
- foreach ($out[0] as $index => $link) {
144
- $newlink = $link;
145
-
146
- //only for external links
147
- if (isset($out[1][$index])) {
148
- //If it's not a valid link
149
- if(!$linkdomain = parse_url($out[1][$index], PHP_URL_HOST)){
150
- continue;
151
- }
152
-
153
- //If it's not an external link
154
- if (strpos($linkdomain, $domain) !== false) {
155
- continue;
156
- }
157
-
158
- //If it's not an exception link
159
- $exceptions = SQ_Classes_Helpers_Tools::getOption('sq_external_exception');
160
- if(!empty($exceptions)){
161
- foreach ($exceptions as $exception){
162
- if (strpos($exception, $linkdomain) !== false) {
163
- continue 2;
164
- }
165
- }
166
- }
167
- }
168
-
169
- //If nofollow rel is set
170
- if (SQ_Classes_Helpers_Tools::getOption('sq_external_nofollow')) {
171
-
172
- if (strpos($newlink, 'rel=') === false) {
173
- $newlink = str_replace('<a', '<a rel="nofollow" ', $newlink);
174
- } elseif (strpos($newlink, 'nofollow') === false) {
175
- $newlink = preg_replace('/(rel=[\'"])([^\'"]+)([\'"])/i', '$1nofollow $2$3', $newlink);
176
- }
177
-
178
- }
179
-
180
- //if force external open
181
- if (SQ_Classes_Helpers_Tools::getOption('sq_external_blank')) {
182
-
183
- if (strpos($newlink, 'target=') === false) {
184
- $newlink = str_replace('<a', '<a target="_blank" ', $newlink);
185
- } elseif (strpos($link, '_blank') === false) {
186
- $newlink = preg_replace('/(target=[\'"])([^\'"]+)([\'"])/i', '$1_blank$3', $newlink);
187
- }
188
-
189
- }
190
-
191
- //Check the link and replace it
192
- if ($newlink <> $link) {
193
- $content = str_replace($link, $newlink, $content);
194
- }
195
  }
196
-
197
  }
198
- return $content;
199
  }
200
 
201
  /**
202
  * Hook the footer
203
  */
204
  public function hookFrontfooter() {
205
- echo (string)$this->model->getFooter();
206
  }
207
 
208
  /**
32
  //Set the post so that Squirrly will know which one to process
33
  add_action('template_redirect', array($this->model, 'setPost'), 9);
34
 
 
 
 
 
 
35
  /* Check if sitemap is on and Load the Sitemap */
36
  if (SQ_Classes_Helpers_Tools::getOption('sq_auto_sitemap')) {
37
  add_filter('wp_sitemaps_enabled', '__return_false');
45
  add_action('template_redirect', array($this->model, 'redirectAttachments'), 10);
46
  }
47
 
 
 
 
 
 
48
  }
49
  }
50
 
57
  remove_action('template_redirect', array($this, 'hookBuffer'), 1);
58
  }
59
 
60
+ //Check if there is an editor loading
61
+ //Don't load Squirrly METAs while in frontend editors
62
+ if(!SQ_Classes_ObjController::getClass('SQ_Models_Compatibility')->isBuilderEditor()) {
63
+ $this->model->startBuffer();
64
+ }
65
  }
66
 
67
  /**
108
  * Hook the Header load
109
  */
110
  public function hookFronthead() {
 
 
 
111
 
112
+ if (is_admin() || (defined('SQ_NOCSS') && SQ_NOCSS)) {
113
+ return;
114
  }
 
115
 
116
+ if (SQ_Classes_Helpers_Tools::isPluginInstalled('elementor/elementor.php')) {
117
+ if (SQ_Classes_Helpers_Tools::getValue('elementor-preview', false)) {
118
+ SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('elementor');
 
 
 
 
 
 
 
 
 
 
119
  }
120
+ }
121
 
122
+ if(SQ_Classes_Helpers_Tools::getOption('sq_load_css')) {
123
+ if (!SQ_Classes_Helpers_Tools::isAjax()) {
124
+ SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('frontend');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  }
 
126
  }
 
127
  }
128
 
129
  /**
130
  * Hook the footer
131
  */
132
  public function hookFrontfooter() {
133
+ echo $this->model->getFooter();
134
  }
135
 
136
  /**
controllers/Menu.php CHANGED
@@ -40,6 +40,7 @@ class SQ_Controllers_Menu extends SQ_Classes_FrontController {
40
  $sq_fullscreen = true;
41
  }
42
 
 
43
  add_action('admin_enqueue_scripts', array(SQ_Classes_ObjController::getClass('SQ_Models_Compatibility'), 'fixEnqueueErrors'), PHP_INT_MAX);
44
  add_action('admin_head', array($this, 'setViewport'), PHP_INT_MAX);
45
  }
@@ -62,7 +63,7 @@ class SQ_Controllers_Menu extends SQ_Classes_FrontController {
62
  public function hookInit() {
63
 
64
  /* add the plugin menu in admin */
65
- if (current_user_can('manage_options')) {
66
  try {
67
  //check if activated
68
  if (get_transient('sq_activate') == 1) {
@@ -112,7 +113,7 @@ class SQ_Controllers_Menu extends SQ_Classes_FrontController {
112
  public function hookTopmenuDashboard($wp_admin_bar) {
113
  global $sq_fullscreen;
114
 
115
- if (is_user_logged_in()) {
116
  if (isset($sq_fullscreen) && $sq_fullscreen) {
117
  $wp_admin_bar->add_node(array(
118
  'parent' => 'site-name',
@@ -137,13 +138,13 @@ class SQ_Controllers_Menu extends SQ_Classes_FrontController {
137
 
138
  if (is_admin()) {
139
 
140
- if (current_user_can('edit_posts')) {
141
  //Get count local SEO errors
142
  $errors = apply_filters('sq_seo_errors', 0);
143
 
144
  $wp_admin_bar->add_node(array(
145
  'id' => 'sq_toolbar',
146
- 'title' => '<span class="sq_logo" style="margin-right: 2px"></span>' . esc_html__("Squirrly SEO", _SQ_PLUGIN_NAME_) . (($errors) ? '<span class="sq_errorcount">' . $errors . '</span>' : ''),
147
  'href' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_dashboard'),
148
  'parent' => false
149
  ));
@@ -166,7 +167,7 @@ class SQ_Controllers_Menu extends SQ_Classes_FrontController {
166
  }
167
 
168
  //make sure the user has the capabilities
169
- if (current_user_can($item['capability'])) {
170
  $wp_admin_bar->add_node(array(
171
  'id' => $menuid,
172
  'title' => $item['title'],
@@ -197,7 +198,7 @@ class SQ_Controllers_Menu extends SQ_Classes_FrontController {
197
  $post = get_post();
198
  if ('post' == $current_screen->base
199
  && ($post_type_object = get_post_type_object($post->post_type))
200
- && (current_user_can('edit_post', $post->ID) || current_user_can('sq_manage_snippets'))
201
  && ($post_type_object->public)) {
202
  } elseif ('edit' == $current_screen->base
203
  && ($post_type_object = get_post_type_object($current_screen->post_type))
@@ -212,22 +213,16 @@ class SQ_Controllers_Menu extends SQ_Classes_FrontController {
212
  }
213
 
214
  $this->model->addMeta(array('sq_blocksnippet',
215
- ucfirst(_SQ_NAME_) . ' ' . esc_html__("SEO Snippet", _SQ_PLUGIN_NAME_),
216
  array(SQ_Classes_ObjController::getClass('SQ_Controllers_Snippet'), 'init'),
217
  null,
218
  'normal',
219
  'high'
220
  ));
221
 
222
- //Dev Kit images
223
- $style = '';
224
- if (SQ_Classes_Helpers_Tools::getOption('sq_devkit_logo')) {
225
- $style = '<style>.sq_logo{background-image:url("' . SQ_Classes_Helpers_Tools::getOption('sq_devkit_logo') . '") !important;background-size: 100%;}</style>';
226
- }
227
-
228
  $wp_admin_bar->add_node(array(
229
  'id' => 'sq_bar_menu',
230
- 'title' => $style . '<span class="sq_logo"></span> ' . esc_html__("Custom SEO", _SQ_PLUGIN_NAME_),
231
  'parent' => 'top-secondary',
232
  ));
233
 
@@ -315,12 +310,14 @@ class SQ_Controllers_Menu extends SQ_Classes_FrontController {
315
 
316
  //Update the external links in the menu
317
  global $submenu;
318
- foreach ($submenu['sq_dashboard'] as &$item) {
319
- if (isset($mainmenu[$item[2]]['href']) && $mainmenu[$item[2]]['href']) {
320
- if (parse_url($mainmenu[$item[2]]['href'], PHP_URL_HOST) !== parse_url(home_url(), PHP_URL_HOST)) {
321
- $item[0] .= '<i class="dashicons dashicons-external" style="font-size:12px;vertical-align:-2px;height:10px;"></i>';
 
 
 
322
  }
323
- $item[2] = $mainmenu[$item[2]]['href'];
324
  }
325
  }
326
  }
@@ -460,7 +457,7 @@ class SQ_Controllers_Menu extends SQ_Classes_FrontController {
460
  */
461
  public function getCloudMenu($url, $path) {
462
  if (function_exists('wp_get_current_user') && SQ_Classes_Helpers_Tools::getOption('sq_api')) {
463
- if (SQ_Classes_Helpers_Tools::getMenuVisible('show_panel') && current_user_can('sq_manage_settings')) {
464
  $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;
465
  }
466
  }
40
  $sq_fullscreen = true;
41
  }
42
 
43
+ //dequeue other css when on Squirrly Settings page
44
  add_action('admin_enqueue_scripts', array(SQ_Classes_ObjController::getClass('SQ_Models_Compatibility'), 'fixEnqueueErrors'), PHP_INT_MAX);
45
  add_action('admin_head', array($this, 'setViewport'), PHP_INT_MAX);
46
  }
63
  public function hookInit() {
64
 
65
  /* add the plugin menu in admin */
66
+ if (SQ_Classes_Helpers_Tools::userCan('manage_options')) {
67
  try {
68
  //check if activated
69
  if (get_transient('sq_activate') == 1) {
113
  public function hookTopmenuDashboard($wp_admin_bar) {
114
  global $sq_fullscreen;
115
 
116
+ if (function_exists('is_user_logged_in') && is_user_logged_in()) {
117
  if (isset($sq_fullscreen) && $sq_fullscreen) {
118
  $wp_admin_bar->add_node(array(
119
  'parent' => 'site-name',
138
 
139
  if (is_admin()) {
140
 
141
+ if (SQ_Classes_Helpers_Tools::userCan('edit_posts')) {
142
  //Get count local SEO errors
143
  $errors = apply_filters('sq_seo_errors', 0);
144
 
145
  $wp_admin_bar->add_node(array(
146
  'id' => 'sq_toolbar',
147
+ 'title' => '<span class="sq_logo" style="margin-right: 2px"></span>' . apply_filters('sq_menu_name', _SQ_MENU_NAME_) . (($errors) ? '<span class="sq_errorcount">' . $errors . '</span>' : ''),
148
  'href' => SQ_Classes_Helpers_Tools::getAdminUrl('sq_dashboard'),
149
  'parent' => false
150
  ));
167
  }
168
 
169
  //make sure the user has the capabilities
170
+ if (SQ_Classes_Helpers_Tools::userCan($item['capability'])) {
171
  $wp_admin_bar->add_node(array(
172
  'id' => $menuid,
173
  'title' => $item['title'],
198
  $post = get_post();
199
  if ('post' == $current_screen->base
200
  && ($post_type_object = get_post_type_object($post->post_type))
201
+ && (SQ_Classes_Helpers_Tools::userCan('edit_post', $post->ID) || SQ_Classes_Helpers_Tools::userCan('sq_manage_snippets'))
202
  && ($post_type_object->public)) {
203
  } elseif ('edit' == $current_screen->base
204
  && ($post_type_object = get_post_type_object($current_screen->post_type))
213
  }
214
 
215
  $this->model->addMeta(array('sq_blocksnippet',
216
+ esc_html__("SEO Snippet", _SQ_PLUGIN_NAME_),
217
  array(SQ_Classes_ObjController::getClass('SQ_Controllers_Snippet'), 'init'),
218
  null,
219
  'normal',
220
  'high'
221
  ));
222
 
 
 
 
 
 
 
223
  $wp_admin_bar->add_node(array(
224
  'id' => 'sq_bar_menu',
225
+ 'title' => '<span class="sq_logo"></span> ' . esc_html__("Custom SEO", _SQ_PLUGIN_NAME_),
226
  'parent' => 'top-secondary',
227
  ));
228
 
310
 
311
  //Update the external links in the menu
312
  global $submenu;
313
+ if(!empty($submenu['sq_dashboard'])) {
314
+ foreach ($submenu['sq_dashboard'] as &$item) {
315
+ if (isset($mainmenu[$item[2]]['href']) && $mainmenu[$item[2]]['href']) {
316
+ if (parse_url($mainmenu[$item[2]]['href'], PHP_URL_HOST) !== parse_url(home_url(), PHP_URL_HOST)) {
317
+ $item[0] .= '<i class="dashicons dashicons-external" style="font-size:12px;vertical-align:-2px;height:10px;"></i>';
318
+ }
319
+ $item[2] = $mainmenu[$item[2]]['href'];
320
  }
 
321
  }
322
  }
323
  }
457
  */
458
  public function getCloudMenu($url, $path) {
459
  if (function_exists('wp_get_current_user') && SQ_Classes_Helpers_Tools::getOption('sq_api')) {
460
+ if (SQ_Classes_Helpers_Tools::getMenuVisible('show_panel') && SQ_Classes_Helpers_Tools::userCan('sq_manage_settings')) {
461
  $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;
462
  }
463
  }
controllers/Onboarding.php CHANGED
@@ -72,6 +72,15 @@ class SQ_Controllers_Onboarding extends SQ_Classes_FrontController {
72
  SQ_Classes_Helpers_Tools::saveOptions('sq_seoexpert', ($sq_onboarding_data['seo_level'] == 'expert'));
73
  }
74
  if (isset($sq_onboarding_data['website_type'])) {
 
 
 
 
 
 
 
 
 
75
  SQ_Classes_Helpers_Tools::saveOptions('sq_jsonld_type', ($sq_onboarding_data['website_type'] == 'personal' ? 'Person' : 'Organization'));
76
  }
77
 
72
  SQ_Classes_Helpers_Tools::saveOptions('sq_seoexpert', ($sq_onboarding_data['seo_level'] == 'expert'));
73
  }
74
  if (isset($sq_onboarding_data['website_type'])) {
75
+ if ($sq_onboarding_data['website_type'] == 'local') {
76
+ SQ_Classes_Helpers_Tools::saveOptions('sq_auto_jsonld_local', 1);
77
+ }
78
+ if ($sq_onboarding_data['website_type'] == 'portofolio') {
79
+ SQ_Classes_Helpers_Tools::saveOptions('sq_attachment_redirect', 0);
80
+ }else{
81
+ SQ_Classes_Helpers_Tools::saveOptions('sq_attachment_redirect', 1);
82
+ SQ_Classes_Helpers_Tools::saveOptions('sq_auto_links', 1);
83
+ }
84
  SQ_Classes_Helpers_Tools::saveOptions('sq_jsonld_type', ($sq_onboarding_data['website_type'] == 'personal' ? 'Person' : 'Organization'));
85
  }
86
 
controllers/Overview.php CHANGED
@@ -9,14 +9,15 @@ class SQ_Controllers_Overview extends SQ_Classes_FrontController {
9
  public $checkin;
10
 
11
  public function init() {
12
- //Checkin to API V2
13
- $this->checkin = SQ_Classes_RemoteController::checkin();
14
 
15
  if (SQ_Classes_Helpers_Tools::getOption('sq_api') == '') {
16
  echo $this->getView('Errors/Connect');
17
  return;
18
  }
19
 
 
 
 
20
  SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap-reboot');
21
  if (is_rtl()) {
22
  SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('popper');
@@ -44,7 +45,7 @@ class SQ_Controllers_Overview extends SQ_Classes_FrontController {
44
  }
45
 
46
  public function getJourneyNotification() {
47
- if (!current_user_can('sq_manage_snippets')) {
48
  return;
49
  }
50
 
9
  public $checkin;
10
 
11
  public function init() {
 
 
12
 
13
  if (SQ_Classes_Helpers_Tools::getOption('sq_api') == '') {
14
  echo $this->getView('Errors/Connect');
15
  return;
16
  }
17
 
18
+ //Checkin to API V2
19
+ $this->checkin = SQ_Classes_RemoteController::checkin();
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');
45
  }
46
 
47
  public function getJourneyNotification() {
48
+ if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippets')) {
49
  return;
50
  }
51
 
controllers/Patterns.php CHANGED
@@ -67,11 +67,21 @@ class SQ_Controllers_Patterns extends SQ_Classes_FrontController {
67
  if (!empty($values)) {
68
  foreach ($values as $name => $value) {
69
  if ($name <> '' && !is_array($value) && $value <> '') {
 
 
 
 
 
70
  if (strpos($value, '%%') !== false) { //in case there are still patterns from Yoast
71
  $value = preg_replace('/%%([^\%]+)%%/s', '{{$1}}', $value);
72
  $object->$name = preg_replace('/%%([^\%]+)%%/s', '{{$1}}', $object->$name);
73
  }
74
 
 
 
 
 
 
75
  if(is_string($value) && $value <> '') {
76
  if (strpos($value, '{{') !== false && strpos($value, '}}') !== false) {
77
  $sq_with_patterns[$name] = $value;
@@ -89,6 +99,7 @@ class SQ_Controllers_Patterns extends SQ_Classes_FrontController {
89
  }
90
  }
91
  }
 
92
  }
93
  }
94
 
@@ -103,7 +114,7 @@ class SQ_Controllers_Patterns extends SQ_Classes_FrontController {
103
  public function action() {
104
  parent::action();
105
 
106
- if (!current_user_can('sq_manage_snippet')) {
107
  $response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", _SQ_PLUGIN_NAME_), 'sq_error');
108
  SQ_Classes_Helpers_Tools::setHeader('json');
109
  echo wp_json_encode($response);
@@ -139,12 +150,7 @@ class SQ_Controllers_Patterns extends SQ_Classes_FrontController {
139
  //return json with the results
140
  SQ_Classes_Helpers_Tools::setHeader('json');
141
 
142
- if (SQ_Classes_Helpers_Tools::getValue('sq_debug') !== 'on') {
143
- echo wp_json_encode(array('json' => wp_json_encode($all_patterns)));
144
- } else {
145
- SQ_Debug::dump($all_patterns, $patterns);
146
- }
147
-
148
  exit();
149
  }
150
  break;
67
  if (!empty($values)) {
68
  foreach ($values as $name => $value) {
69
  if ($name <> '' && !is_array($value) && $value <> '') {
70
+ // if (strpos($value, '#') !== false) { //in case there are still patterns from AIOS
71
+ // $value = preg_replace('/#([a-z_]+)/s', '{{$1}}', $value);
72
+ // $object->$name = preg_replace('/#([a-z_]+)/s', '{{$1}}', $object->$name);
73
+ // }
74
+
75
  if (strpos($value, '%%') !== false) { //in case there are still patterns from Yoast
76
  $value = preg_replace('/%%([^\%]+)%%/s', '{{$1}}', $value);
77
  $object->$name = preg_replace('/%%([^\%]+)%%/s', '{{$1}}', $object->$name);
78
  }
79
 
80
+ if (strpos($value, '%') !== false) { //in case there are still patterns from Rank Math
81
+ $value = preg_replace('/%([^\%]+)%/s', '{{$1}}', $value);
82
+ $object->$name = preg_replace('/%([^\%]+)%/s', '{{$1}}', $object->$name);
83
+ }
84
+
85
  if(is_string($value) && $value <> '') {
86
  if (strpos($value, '{{') !== false && strpos($value, '}}') !== false) {
87
  $sq_with_patterns[$name] = $value;
99
  }
100
  }
101
  }
102
+
103
  }
104
  }
105
 
114
  public function action() {
115
  parent::action();
116
 
117
+ if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
118
  $response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", _SQ_PLUGIN_NAME_), 'sq_error');
119
  SQ_Classes_Helpers_Tools::setHeader('json');
120
  echo wp_json_encode($response);
150
  //return json with the results
151
  SQ_Classes_Helpers_Tools::setHeader('json');
152
 
153
+ echo wp_json_encode(array('json' => wp_json_encode($all_patterns)));
 
 
 
 
 
154
  exit();
155
  }
156
  break;
controllers/Post.php CHANGED
@@ -11,6 +11,7 @@ class SQ_Controllers_Post extends SQ_Classes_FrontController {
11
  if (is_rtl()) {
12
  SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('rtl');
13
  }
 
14
  //load the draggable script in post edit for the floating SLA
15
  wp_enqueue_script("jquery-ui-core");
16
  wp_enqueue_script("jquery-ui-draggable");
@@ -23,10 +24,16 @@ class SQ_Controllers_Post extends SQ_Classes_FrontController {
23
  if (SQ_Classes_Helpers_Tools::getOption('sq_api') == '')
24
  return;
25
 
26
- //Hook and save the Snippet and Keywords
27
  add_action('wp_insert_attachment_data', array($this, 'hookAttachmentSave'), 12, 2);
 
 
 
 
 
 
 
28
  add_filter('wp_insert_post_data', array($this, 'removeHighlight'), 12, 2);
29
- add_filter('wp_insert_post_data', array($this, 'checkImage'), 13, 2);
30
 
31
  //Hook the save post action
32
  add_action('save_post', array($this, 'hookSavePost'), 11, 2);
@@ -38,14 +45,30 @@ class SQ_Controllers_Post extends SQ_Classes_FrontController {
38
  add_action('transition_post_status', array(SQ_Classes_ObjController::getClass('SQ_Controllers_Sitemaps'), 'refreshSitemap'), PHP_INT_MAX, 3);
39
  }
40
 
 
 
 
 
 
 
 
 
 
41
  //Make sure the URL is local and not changed by other plugins
42
- add_filter('sq_homeurl', function ($url) {
43
- if (defined('WP_HOME')) {
44
- return WP_HOME;
45
- } else {
46
- return get_option('home');
47
- }
48
- });
 
 
 
 
 
 
 
49
  }
50
 
51
  /**
@@ -64,6 +87,15 @@ class SQ_Controllers_Post extends SQ_Classes_FrontController {
64
  * @return array
65
  */
66
  public function removeHighlight($post_data, $postarr) {
 
 
 
 
 
 
 
 
 
67
  if (!isset($post_data['post_content']) || !isset($postarr['ID'])) {
68
  return $post_data;
69
  }
@@ -82,61 +114,69 @@ class SQ_Controllers_Post extends SQ_Classes_FrontController {
82
  * @return array
83
  */
84
  public function checkImage($post_data, $postarr) {
 
85
  if (!isset($post_data['post_content']) || !isset($postarr['ID'])) {
86
  return $post_data;
87
  }
88
 
 
 
 
 
 
 
 
 
89
  require_once(ABSPATH . 'wp-admin/includes/image.php');
90
 
91
- //if the option to save the images locally is set on
92
- if (SQ_Classes_Helpers_Tools::getOption('sq_local_images')) {
93
- $urls = array();
94
- if (function_exists('preg_match_all')) {
95
- @preg_match_all('/<img[^>]*src=[\'"]([^\'"]+)[\'"][^>]*>/i', stripslashes($post_data['post_content']), $out);
96
 
97
- if (!empty($out)) {
98
- if (!is_array($out[1]) || count((array)$out[1]) == 0) {
99
- return $post_data;
100
- }
101
 
102
- if (get_bloginfo('wpurl') <> '') {
103
- $domain = parse_url(home_url(), PHP_URL_HOST);
104
 
105
- foreach ($out[1] as $row) {
106
- if (strpos($row, '//') !== false && strpos($row, $domain) === false) {
107
- if (!in_array($row, $urls)) {
108
- $urls[] = $row;
109
- }
110
  }
111
  }
112
  }
113
  }
114
  }
 
115
 
116
- if (!is_array($urls) || (is_array($urls) && count((array)$urls) == 0)) {
117
- return $post_data;
118
- }
119
 
120
- if (count((array)$urls) > 1) {
121
- $urls = array_unique($urls);
122
- }
123
 
124
- $time = microtime(true);
125
 
126
- //get the already downloaded images
127
- $images = get_post_meta((int)$postarr['ID'], '_sq_image_downloaded');
128
 
129
- foreach ($urls as $url) {
130
 
131
- //Set the title and filename
132
- $basename = md5(basename($url));
133
- $keyword = SQ_Classes_Helpers_Tools::getValue('sq_keyword', false);
134
- if ($keyword) {
135
- $title = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\[\]\\x80-\\xff ]|i', '', $keyword);
136
- $basename = preg_replace('|[^a-z0-9-_]|i', '', str_replace(' ', '-', strtolower($keyword)));
137
- }
138
 
139
- //check the images
 
140
  foreach ($images as $key => $local) {
141
  $local = json_decode($local, true);
142
  if ($local['url'] == md5($url)) {
@@ -147,42 +187,40 @@ class SQ_Controllers_Post extends SQ_Classes_FrontController {
147
  continue 2;
148
  }
149
  }
 
150
 
151
- //Upload the image on server
152
- if ($file = $this->model->upload_image($url, $basename)) {
153
- if (!file_is_valid_image($file['file']))
154
- continue;
155
 
156
- $local_file = $file['url'];
157
- if ($local_file !== false) {
158
 
159
- //save as downloaded image to avoid duplicates
160
- add_post_meta((int)$postarr['ID'], '_sq_image_downloaded', wp_json_encode(array('url' => md5($url), 'file' => $local_file)));
161
 
162
- //replace the image in the content
163
- $post_data['post_content'] = str_replace($url, $local_file, $post_data['post_content']);
164
 
165
- //add the attachment image
166
- $attach_id = wp_insert_attachment(array(
167
- 'post_mime_type' => $file['type'],
168
- 'post_title' => $title,
169
- 'post_content' => '',
170
- 'post_status' => 'inherit',
171
- 'guid' => $local_file
172
- ), $file['file'], $postarr['ID']);
173
-
174
- $attach_data = wp_generate_attachment_metadata($attach_id, $file['file']);
175
- wp_update_attachment_metadata($attach_id, $attach_data);
176
 
177
- }
178
- }
179
 
180
- if (microtime(true) - $time >= 10) {
181
- break;
182
  }
183
-
184
  }
185
 
 
 
 
186
 
187
  }
188
 
@@ -232,6 +270,14 @@ class SQ_Controllers_Post extends SQ_Classes_FrontController {
232
  get_post_status($post->ID) <> 'inherit'
233
  ) {
234
 
 
 
 
 
 
 
 
 
235
  //Update the SEO Keywords from Live Assistant and Permalink
236
  add_filter('sq_seo_before_save', array($this, 'addSeoKeywords'), 11, 1);
237
  //Update the redirect to old slugs
@@ -282,7 +328,7 @@ class SQ_Controllers_Post extends SQ_Classes_FrontController {
282
  parent::action();
283
  switch (SQ_Classes_Helpers_Tools::getValue('action')) {
284
  case 'sq_create_demo':
285
- if (!current_user_can('sq_manage_snippet')) {
286
  SQ_Classes_Error::setError(esc_html__("You do not have permission to perform this action", _SQ_PLUGIN_NAME_), 'sq_error');
287
  break;
288
  }
@@ -335,7 +381,7 @@ class SQ_Controllers_Post extends SQ_Classes_FrontController {
335
 
336
  /**************************** AJAX CALLS *************************/
337
  case 'sq_ajax_save_ogimage':
338
- if (!current_user_can('sq_manage_snippet')) {
339
  $response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", _SQ_PLUGIN_NAME_), 'sq_error');
340
  SQ_Classes_Helpers_Tools::setHeader('json');
341
  echo wp_json_encode($response);
@@ -366,7 +412,7 @@ class SQ_Controllers_Post extends SQ_Classes_FrontController {
366
  case 'sq_ajax_save_post':
367
  SQ_Classes_Helpers_Tools::setHeader('json');
368
 
369
- if (!current_user_can('sq_manage_snippet')) {
370
  $response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", _SQ_PLUGIN_NAME_), 'sq_error');
371
  echo wp_json_encode($response);
372
  exit();
@@ -401,7 +447,7 @@ class SQ_Controllers_Post extends SQ_Classes_FrontController {
401
  case 'sq_ajax_get_post':
402
  SQ_Classes_Helpers_Tools::setHeader('json');
403
 
404
- if (!current_user_can('sq_manage_snippet')) {
405
  $response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", _SQ_PLUGIN_NAME_), 'sq_error');
406
  echo wp_json_encode($response);
407
  exit();
@@ -586,4 +632,5 @@ class SQ_Controllers_Post extends SQ_Classes_FrontController {
586
  }
587
  }
588
 
 
589
  }
11
  if (is_rtl()) {
12
  SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('rtl');
13
  }
14
+
15
  //load the draggable script in post edit for the floating SLA
16
  wp_enqueue_script("jquery-ui-core");
17
  wp_enqueue_script("jquery-ui-draggable");
24
  if (SQ_Classes_Helpers_Tools::getOption('sq_api') == '')
25
  return;
26
 
27
+ //Hook and save the Snippet and Keywords for Attachment Pages
28
  add_action('wp_insert_attachment_data', array($this, 'hookAttachmentSave'), 12, 2);
29
+
30
+ //if the option to save the images locally is activated
31
+ if (SQ_Classes_Helpers_Tools::getOption('sq_local_images')) {
32
+ add_filter('wp_insert_post_data', array($this, 'checkImage'), 13, 2);
33
+ }
34
+
35
+ //Remove the SLA highlight from post
36
  add_filter('wp_insert_post_data', array($this, 'removeHighlight'), 12, 2);
 
37
 
38
  //Hook the save post action
39
  add_action('save_post', array($this, 'hookSavePost'), 11, 2);
45
  add_action('transition_post_status', array(SQ_Classes_ObjController::getClass('SQ_Controllers_Sitemaps'), 'refreshSitemap'), PHP_INT_MAX, 3);
46
  }
47
 
48
+ //Check the compatibility with Woocommerce
49
+ if (SQ_Classes_Helpers_Tools::getOption('sq_jsonld_product_custom')) {
50
+ SQ_Classes_ObjController::getClass('SQ_Models_Compatibility')->checkWooCommerce();
51
+ }
52
+
53
+
54
+ //add compatibility for backend
55
+ SQ_Classes_ObjController::getClass('SQ_Models_Compatibility')->hookPostEditorBackend();
56
+
57
  //Make sure the URL is local and not changed by other plugins
58
+ add_filter('sq_homeurl', array($this, 'getHomeUrl'));
59
+ }
60
+
61
+ /**
62
+ * Get the current Home URL
63
+ * @param $url
64
+ * @return mixed
65
+ */
66
+ public function getHomeUrl($url) {
67
+ if (defined('WP_HOME')) {
68
+ return WP_HOME;
69
+ } else {
70
+ return get_option('home');
71
+ }
72
  }
73
 
74
  /**
87
  * @return array
88
  */
89
  public function removeHighlight($post_data, $postarr) {
90
+
91
+ if (isset($post_data['post_type']) && $post_data['post_type'] <> '') {
92
+ //Exclude types for SLA
93
+ $excludes = SQ_Classes_Helpers_Tools::getOption('sq_sla_exclude_post_types');
94
+ if (in_array($post_data['post_type'], $excludes)) {
95
+ return $post_data;
96
+ }
97
+ }
98
+
99
  if (!isset($post_data['post_content']) || !isset($postarr['ID'])) {
100
  return $post_data;
101
  }
114
  * @return array
115
  */
116
  public function checkImage($post_data, $postarr) {
117
+
118
  if (!isset($post_data['post_content']) || !isset($postarr['ID'])) {
119
  return $post_data;
120
  }
121
 
122
+ if (isset($post_data['post_type']) && $post_data['post_type'] <> '') {
123
+ //Exclude types for SLA
124
+ $excludes = SQ_Classes_Helpers_Tools::getOption('sq_sla_exclude_post_types');
125
+ if (in_array($post_data['post_type'], $excludes)) {
126
+ return $post_data;
127
+ }
128
+ }
129
+
130
  require_once(ABSPATH . 'wp-admin/includes/image.php');
131
 
132
+ $urls = array();
133
+ if (function_exists('preg_match_all')) {
134
+ @preg_match_all('/<img[^>]*src=[\'"]([^\'"]+)[\'"][^>]*>/i', stripslashes($post_data['post_content']), $out);
 
 
135
 
136
+ if (!empty($out)) {
137
+ if (!is_array($out[1]) || count((array)$out[1]) == 0) {
138
+ return $post_data;
139
+ }
140
 
141
+ if (get_bloginfo('wpurl') <> '') {
142
+ $domain = parse_url(home_url(), PHP_URL_HOST);
143
 
144
+ foreach ($out[1] as $row) {
145
+ if (strpos($row, '//') !== false && strpos($row, $domain) === false) {
146
+ if (!in_array($row, $urls)) {
147
+ $urls[] = $row;
 
148
  }
149
  }
150
  }
151
  }
152
  }
153
+ }
154
 
155
+ if (!is_array($urls) || (is_array($urls) && count((array)$urls) == 0)) {
156
+ return $post_data;
157
+ }
158
 
159
+ if (count((array)$urls) > 1) {
160
+ $urls = array_unique($urls);
161
+ }
162
 
163
+ $time = microtime(true);
164
 
165
+ //get the already downloaded images
166
+ $images = get_post_meta((int)$postarr['ID'], '_sq_image_downloaded');
167
 
168
+ foreach ($urls as $url) {
169
 
170
+ //Set the title and filename
171
+ $basename = md5(basename($url));
172
+ $keyword = SQ_Classes_Helpers_Tools::getValue('sq_keyword', false);
173
+ if ($keyword) {
174
+ $title = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\[\]\\x80-\\xff ]|i', '', $keyword);
175
+ $basename = preg_replace('|[^a-z0-9-_]|i', '', str_replace(' ', '-', strtolower($keyword)));
176
+ }
177
 
178
+ //check the images
179
+ if (!empty($images)) {
180
  foreach ($images as $key => $local) {
181
  $local = json_decode($local, true);
182
  if ($local['url'] == md5($url)) {
187
  continue 2;
188
  }
189
  }
190
+ }
191
 
192
+ //Upload the image on server
193
+ if ($file = $this->model->upload_image($url, $basename)) {
194
+ if (!file_is_valid_image($file['file']))
195
+ continue;
196
 
197
+ $local_file = $file['url'];
198
+ if ($local_file !== false) {
199
 
200
+ //save as downloaded image to avoid duplicates
201
+ add_post_meta((int)$postarr['ID'], '_sq_image_downloaded', wp_json_encode(array('url' => md5($url), 'file' => $local_file)));
202
 
203
+ //replace the image in the content
204
+ $post_data['post_content'] = str_replace($url, $local_file, $post_data['post_content']);
205
 
206
+ //add the attachment image
207
+ $attach_id = wp_insert_attachment(array(
208
+ 'post_mime_type' => $file['type'],
209
+ 'post_title' => $title,
210
+ 'post_content' => '',
211
+ 'post_status' => 'inherit',
212
+ 'guid' => $local_file
213
+ ), $file['file'], $postarr['ID']);
 
 
 
214
 
215
+ $attach_data = wp_generate_attachment_metadata($attach_id, $file['file']);
216
+ wp_update_attachment_metadata($attach_id, $attach_data);
217
 
 
 
218
  }
 
219
  }
220
 
221
+ if (microtime(true) - $time >= 10) {
222
+ break;
223
+ }
224
 
225
  }
226
 
270
  get_post_status($post->ID) <> 'inherit'
271
  ) {
272
 
273
+ //Exclude types for SLA
274
+ if (isset($post->post_type) && $post->post_type <> '') {
275
+ $excludes = SQ_Classes_Helpers_Tools::getOption('sq_sla_exclude_post_types');
276
+ if (in_array($post->post_type, $excludes)) {
277
+ return;
278
+ }
279
+ }
280
+
281
  //Update the SEO Keywords from Live Assistant and Permalink
282
  add_filter('sq_seo_before_save', array($this, 'addSeoKeywords'), 11, 1);
283
  //Update the redirect to old slugs
328
  parent::action();
329
  switch (SQ_Classes_Helpers_Tools::getValue('action')) {
330
  case 'sq_create_demo':
331
+ if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
332
  SQ_Classes_Error::setError(esc_html__("You do not have permission to perform this action", _SQ_PLUGIN_NAME_), 'sq_error');
333
  break;
334
  }
381
 
382
  /**************************** AJAX CALLS *************************/
383
  case 'sq_ajax_save_ogimage':
384
+ if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
385
  $response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", _SQ_PLUGIN_NAME_), 'sq_error');
386
  SQ_Classes_Helpers_Tools::setHeader('json');
387
  echo wp_json_encode($response);
412
  case 'sq_ajax_save_post':
413
  SQ_Classes_Helpers_Tools::setHeader('json');
414
 
415
+ if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
416
  $response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", _SQ_PLUGIN_NAME_), 'sq_error');
417
  echo wp_json_encode($response);
418
  exit();
447
  case 'sq_ajax_get_post':
448
  SQ_Classes_Helpers_Tools::setHeader('json');
449
 
450
+ if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
451
  $response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", _SQ_PLUGIN_NAME_), 'sq_error');
452
  echo wp_json_encode($response);
453
  exit();
632
  }
633
  }
634
 
635
+
636
  }
controllers/PostsList.php CHANGED
@@ -202,7 +202,7 @@ class SQ_Controllers_PostsList extends SQ_Classes_FrontController {
202
  parent::action();
203
  switch (SQ_Classes_Helpers_Tools::getValue('action')) {
204
  case 'sq_ajax_postslist':
205
- if (!current_user_can('sq_manage_snippet')) {
206
  $response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", _SQ_PLUGIN_NAME_), 'sq_error');
207
  SQ_Classes_Helpers_Tools::setHeader('json');
208
  echo wp_json_encode($response);
202
  parent::action();
203
  switch (SQ_Classes_Helpers_Tools::getValue('action')) {
204
  case 'sq_ajax_postslist':
205
+ if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_snippet')) {
206
  $response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", _SQ_PLUGIN_NAME_), 'sq_error');
207
  SQ_Classes_Helpers_Tools::setHeader('json');
208
  echo wp_json_encode($response);
controllers/Ranking.php CHANGED
@@ -125,7 +125,7 @@ class SQ_Controllers_Ranking extends SQ_Classes_FrontController {
125
  public function action() {
126
  parent::action();
127
 
128
- if (!current_user_can('sq_manage_focuspages')) {
129
  return;
130
  }
131
 
125
  public function action() {
126
  parent::action();
127
 
128
+ if (!SQ_Classes_Helpers_Tools::userCan('sq_manage_focuspages')) {
129
  return;
130
  }
131
 
controllers/Research.php CHANGED
@@ -30,10 +30,10 @@ class SQ_Controllers_Research extends SQ_Classes_FrontController {
30
  $this->checkin = SQ_Classes_RemoteController::checkin();
31
 
32
  if (is_wp_error($this->checkin)) {
33
- if($this->checkin->get_error_message() == 'no_data') {
34
  echo $this->getView('Errors/Error');
35
  return;
36
- }elseif($this->checkin->get_error_message() == 'maintenance') {
37
  echo $this->getView('Errors/Maintenance');
38
  return;
39
  }
@@ -42,11 +42,11 @@ class SQ_Controllers_Research extends SQ_Classes_FrontController {
42
  $tab = SQ_Classes_Helpers_Tools::getValue('tab', 'research');
43
 
44
  SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap-reboot');
45
- if(is_rtl()){
46
  SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('popper');
47
  SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap.rtl');
48
  SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('rtl');
49
- }else{
50
  SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap');
51
  }
52
  SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('switchery');
@@ -71,7 +71,7 @@ class SQ_Controllers_Research extends SQ_Classes_FrontController {
71
  }
72
 
73
  public function research() {
74
- add_action('sq_form_notices', array($this,'getNotificationBar'));
75
 
76
  $countries = SQ_Classes_RemoteController::getKrCountries();
77
 
@@ -83,7 +83,7 @@ class SQ_Controllers_Research extends SQ_Classes_FrontController {
83
  }
84
 
85
  public function briefcase() {
86
- add_action('sq_form_notices', array($this,'getNotificationBar'));
87
 
88
  $search = (string)SQ_Classes_Helpers_Tools::getValue('skeyword', '');
89
  $labels = SQ_Classes_Helpers_Tools::getValue('slabel', false);
@@ -102,7 +102,7 @@ class SQ_Controllers_Research extends SQ_Classes_FrontController {
102
  if (isset($briefcase->keywords) && !empty($briefcase->keywords)) {
103
  $this->keywords = $briefcase->keywords;
104
  } else {
105
- $this->error = sprintf(esc_html__("No keyword found. %s Show all %s keywords from Briefcase.", _SQ_PLUGIN_NAME_),'<a href="'.SQ_Classes_Helpers_Tools::getAdminUrl('sq_research','briefcase').'">','</a>');
106
  }
107
 
108
  if (isset($briefcase->labels)) {
@@ -119,7 +119,7 @@ class SQ_Controllers_Research extends SQ_Classes_FrontController {
119
  }
120
 
121
  public function labels() {
122
- add_action('sq_form_notices', array($this,'getNotificationBar'));
123
 
124
  $args = array();
125
  if (!empty($labels)) {
@@ -142,7 +142,7 @@ class SQ_Controllers_Research extends SQ_Classes_FrontController {
142
  }
143
 
144
  public function suggested() {
145
- add_action('sq_form_notices', array($this,'getNotificationBar'));
146
 
147
  //Get the briefcase keywords
148
  if ($briefcase = SQ_Classes_RemoteController::getBriefcase()) {
@@ -162,7 +162,7 @@ class SQ_Controllers_Research extends SQ_Classes_FrontController {
162
 
163
  }
164
 
165
- function history() {
166
 
167
  $args = array();
168
  $args['limit'] = 100;
@@ -170,6 +170,24 @@ class SQ_Controllers_Research extends SQ_Classes_FrontController {
170
 
171
  }
172
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
 
174
  /**
175
  * Called when action is triggered
@@ -182,7 +200,7 @@ class SQ_Controllers_Research extends SQ_Classes_FrontController {
182
  switch (SQ_Classes_Helpers_Tools::getValue('action')) {
183
 
184
  case 'sq_briefcase_addkeyword':
185
- if (!current_user_can('sq_manage_snippet')) {
186
  $response['error'] = SQ_Classes_Error::showNotices(esc_html__("You do not have permission to perform this action", _SQ_PLUGIN_NAME_), 'sq_error');
187
  SQ_Classes_Helpers_Tools::setHeader('json');