SEO SQUIRRLY™ - Version 8.4.07

Version Description

  • 02/22/2019 =
  • SEO Update - Tested and Compatible with WordPress 5.1
Download this release

Release Info

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

Code changes from version 8.3.12 to 8.4.07

Files changed (80) hide show
  1. classes/Action.php +42 -50
  2. classes/BlockController.php +3 -1
  3. classes/DisplayController.php +15 -27
  4. classes/FrontController.php +0 -2
  5. classes/ObjController.php +26 -30
  6. classes/Tools.php +153 -35
  7. config/config.php +15 -1
  8. config/paths.php +9 -6
  9. controllers/Api.php +1 -1
  10. controllers/Frontend.php +8 -6
  11. controllers/Menu.php +78 -54
  12. controllers/Post.php +78 -113
  13. controllers/SerpChecker.php +40 -18
  14. controllers/Sitemaps.php +26 -6
  15. core/BlockBriefcaseKeywords.php +13 -5
  16. core/BlockImport.php +6 -4
  17. core/BlockPostsAnalytics.php +6 -3
  18. core/BlockSerpKeywords.php +2 -5
  19. core/BlockSettings.php +14 -3
  20. core/BlockSettingsSeo.php +28 -23
  21. core/BlockSupport.php +17 -17
  22. core/Blocklogin.php +2 -0
  23. core/Loading.php +8 -19
  24. core/config.json +225 -0
  25. core/config.xml +0 -224
  26. languages/squirrly-seo-cs_CZ.mo +0 -0
  27. languages/squirrly-seo-cs_CZ.po +4429 -0
  28. languages/squirrly-seo-de_DE.mo +0 -0
  29. languages/squirrly-seo-de_DE.po +760 -696
  30. languages/squirrly-seo-ro_RO.mo +0 -0
  31. languages/squirrly-seo-ro_RO.po +754 -693
  32. models/BlockSettingsSeo.php +0 -1
  33. models/Frontend.php +37 -12
  34. models/Post.php +41 -27
  35. models/SerpChecker.php +4 -10
  36. models/SerpCheckerTable.php +4 -4
  37. models/Sitemaps.php +88 -25
  38. models/abstract/Seo.php +20 -13
  39. models/domain/Patterns.php +127 -25
  40. models/domain/Sq.php +1 -9
  41. models/services/Analytics.php +6 -1
  42. models/services/JsonLD.php +131 -17
  43. models/services/Keywords.php +10 -3
  44. models/services/Noindex.php +2 -0
  45. models/services/OpenGraph.php +31 -17
  46. readme.txt +921 -359
  47. squirrly.php +5 -6
  48. view/BlockAccount.php +7 -2
  49. view/BlockAffiliate.php +2 -54
  50. view/BlockAnalytics.php +0 -15
  51. view/BlockAudit.php +4 -4
  52. view/BlockBriefcaseKeywords.php +309 -289
  53. view/BlockCustomerService.php +14 -1
  54. view/BlockDashboard.php +5 -2
  55. view/BlockImport.php +4 -1
  56. view/BlockKeywordResearch.php +34 -30
  57. view/BlockPatterns.php +7 -4
  58. view/BlockPostsAnalytics.php +1 -0
  59. view/BlockSerpKeywords.php +0 -6
  60. view/BlockSettings.php +24 -7
  61. view/BlockSettingsSeo.php +42 -19
  62. view/BlockSupport.php +102 -86
  63. view/Blocklogin.php +1 -1
  64. view/FrontMenu.php +19 -15
  65. view/css/blockaccount.css +1 -1
  66. view/css/blockaccount.min.css +1 -1
  67. view/css/blockkeywordresearch.css +1 -1
  68. view/css/blockkeywordresearch.min.css +1 -1
  69. view/css/blockresearch.css +4 -10
  70. view/css/blockresearch.min.css +1 -1
  71. view/css/blocksearch.css +27 -43
  72. view/css/blocksearch.min.css +1 -1
  73. view/css/blockseo.css +9 -0
  74. view/css/blockseo.min.css +1 -1
  75. view/css/blocksettings.css +1 -1
  76. view/css/blocksettings.min.css +1 -1
  77. view/css/blocksettingsseo.css +1 -1
  78. view/css/blocksettingsseo.min.css +1 -1
  79. view/css/bootstrap.css +1 -0
  80. view/css/bootstrap.min.css +1 -0
classes/Action.php CHANGED
@@ -12,13 +12,8 @@ class SQ_Classes_Action extends SQ_Classes_FrontController {
12
  private static $config;
13
 
14
 
15
- private function _isAjax() {
16
- $url = (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : false);
17
- if ($url && (strpos($url, str_replace(get_bloginfo('url'), '', admin_url('admin-ajax.php', 'relative'))) !== false)) {
18
- return true;
19
- }
20
-
21
- return false;
22
  }
23
 
24
  /**
@@ -81,62 +76,58 @@ class SQ_Classes_Action extends SQ_Classes_FrontController {
81
  }
82
 
83
  /**
84
- * Get all actions from config.xml in core directory and add them in the WP
85
  *
86
  * @return void
87
  */
88
  public function getActions($cur_action) {
89
- if(function_exists('simplexml_load_string')) {
90
- //Let only the logged users to access the actions
91
- if (is_admin() || is_network_admin()) {
92
- /* if config allready in cache */
93
- if (!isset(self::$config)) {
94
- $config_file = _SQ_CORE_DIR_ . 'config.xml';
95
- if (!file_exists($config_file)) {
96
- return;
97
- }
98
-
99
- /* load configuration blocks data from core config files */
100
- $data = file_get_contents($config_file);
101
- self::$config = json_decode(json_encode((array)simplexml_load_string($data)), 1);
102
  }
103
 
104
- if (is_array(self::$config))
105
- foreach (self::$config['block'] as $block) {
106
- if (isset($block['active']) && $block['active'] == 1) {
107
- /* if there is a single action */
108
- if (isset($block['actions']['action']))
109
- if (isset($block['admin']) &&
110
- (($block['admin'] == 1 && is_user_logged_in()) ||
111
- $block['admin'] == 0)
112
- ) {
 
 
 
 
 
 
 
 
 
 
113
  /* if there are more actions for the current block */
114
- if (!is_array($block['actions']['action'])) {
115
- /* add the action in the actions array */
116
- if ($block['actions']['action'] == $cur_action)
117
  $this->actions[] = array('class' => $block['name']);
118
- } else {
119
- /* if there are more actions for the current block */
120
- foreach ($block['actions']['action'] as $action) {
121
- /* add the actions in the actions array */
122
- if ($action == $cur_action)
123
- $this->actions[] = array('class' => $block['name']);
124
- }
125
  }
126
  }
 
127
 
128
- }
129
  }
 
130
 
131
 
132
- /* add the actions in WP */
133
- foreach ($this->actions as $actions) {
134
- SQ_Classes_ObjController::getClass($actions['class'])->action();
135
- }
136
  }
137
- }else{
138
- SQ_Classes_Error::setMessage(__('You need to activate the PHP simplexml_load_string extension for Squirrly SEO to work.', _SQ_PLUGIN_NAME_));
139
  }
 
140
  }
141
 
142
  /**
@@ -153,7 +144,8 @@ class SQ_Classes_Action extends SQ_Classes_FrontController {
153
  return false;
154
  }
155
 
156
- $extra = array('user_url' => home_url(),
 
157
  'lang' => (defined('WPLANG') ? WPLANG : 'en_US'),
158
  'versq' => SQ_VERSION_ID,
159
  'verwp' => WP_VERSION_ID,
@@ -188,7 +180,7 @@ class SQ_Classes_Action extends SQ_Classes_FrontController {
188
  try {
189
  //echo $url;exit();
190
  return SQ_Classes_Tools::sq_remote_get($url, array(), array('timeout' => $timeout));
191
- }catch (Exception $e){
192
  return '';
193
  }
194
 
@@ -203,7 +195,7 @@ class SQ_Classes_Action extends SQ_Classes_FrontController {
203
  return str_replace(array(' '), array('+'), $url);
204
  }
205
 
206
- public static function apiSaveSettings(){
207
  self::apiCall('sq/user/settings', array('settings' => json_encode(SQ_Classes_Tools::getBriefOptions())), 10);
208
  }
209
 
12
  private static $config;
13
 
14
 
15
+ public function _isAjax() {
16
+ return (defined('DOING_AJAX') && DOING_AJAX);
 
 
 
 
 
17
  }
18
 
19
  /**
76
  }
77
 
78
  /**
79
+ * Get all actions from config.json in core directory and add them in the WP
80
  *
81
  * @return void
82
  */
83
  public function getActions($cur_action) {
84
+ //Let only the logged users to access the actions
85
+ if (is_admin() || is_network_admin()) {
86
+ /* if config allready in cache */
87
+ if (!isset(self::$config)) {
88
+ $config_file = _SQ_CORE_DIR_ . 'config.json';
89
+ if (!file_exists($config_file)) {
90
+ return;
 
 
 
 
 
 
91
  }
92
 
93
+ /* load configuration blocks data from core config files */
94
+ self::$config = json_decode(file_get_contents($config_file), 1);
95
+ }
96
+
97
+ if (is_array(self::$config))
98
+ foreach (self::$config['blocks']['block'] as $block) {
99
+ if (isset($block['active']) && $block['active'] == 1) {
100
+ /* if there is a single action */
101
+ if (isset($block['actions']['action']))
102
+ if (isset($block['admin']) &&
103
+ (($block['admin'] == 1 && is_user_logged_in()) ||
104
+ $block['admin'] == 0)
105
+ ) {
106
+ /* if there are more actions for the current block */
107
+ if (!is_array($block['actions']['action'])) {
108
+ /* add the action in the actions array */
109
+ if ($block['actions']['action'] == $cur_action)
110
+ $this->actions[] = array('class' => $block['name']);
111
+ } else {
112
  /* if there are more actions for the current block */
113
+ foreach ($block['actions']['action'] as $action) {
114
+ /* add the actions in the actions array */
115
+ if ($action == $cur_action)
116
  $this->actions[] = array('class' => $block['name']);
 
 
 
 
 
 
 
117
  }
118
  }
119
+ }
120
 
 
121
  }
122
+ }
123
 
124
 
125
+ /* add the actions in WP */
126
+ foreach ($this->actions as $actions) {
127
+ SQ_Classes_ObjController::getClass($actions['class'])->action();
 
128
  }
 
 
129
  }
130
+
131
  }
132
 
133
  /**
144
  return false;
145
  }
146
 
147
+ $extra = array(
148
+ 'user_url' => home_url(),
149
  'lang' => (defined('WPLANG') ? WPLANG : 'en_US'),
150
  'versq' => SQ_VERSION_ID,
151
  'verwp' => WP_VERSION_ID,
180
  try {
181
  //echo $url;exit();
182
  return SQ_Classes_Tools::sq_remote_get($url, array(), array('timeout' => $timeout));
183
+ } catch (Exception $e) {
184
  return '';
185
  }
186
 
195
  return str_replace(array(' '), array('+'), $url);
196
  }
197
 
198
+ public static function apiSaveSettings() {
199
  self::apiCall('sq/user/settings', array('settings' => json_encode(SQ_Classes_Tools::getBriefOptions())), 10);
200
  }
201
 
classes/BlockController.php CHANGED
@@ -77,7 +77,8 @@ class SQ_Classes_BlockController {
77
 
78
 
79
  public function preloadSettings() {
80
- echo '<script type="text/javascript">
 
81
  var __blog_url = "' . get_bloginfo('url') . '";
82
  var __token = "' . SQ_Classes_Tools::getOption('sq_api') . '";
83
  var __language = "' . get_bloginfo('language') . '";
@@ -86,6 +87,7 @@ class SQ_Classes_BlockController {
86
  jQuery.sq_getHelp("' . str_replace(array("sq_core_block", "sq_controller_block_"), "", strtolower($this->name)) . '", "content");
87
  });
88
  </script>';
 
89
  }
90
 
91
  /**
77
 
78
 
79
  public function preloadSettings() {
80
+ if(SQ_Classes_Tools::getOption('sq_api') <> '') {
81
+ echo '<script type="text/javascript">
82
  var __blog_url = "' . get_bloginfo('url') . '";
83
  var __token = "' . SQ_Classes_Tools::getOption('sq_api') . '";
84
  var __language = "' . get_bloginfo('language') . '";
87
  jQuery.sq_getHelp("' . str_replace(array("sq_core_block", "sq_controller_block_"), "", strtolower($this->name)) . '", "content");
88
  });
89
  </script>';
90
+ }
91
  }
92
 
93
  /**
classes/DisplayController.php CHANGED
@@ -12,19 +12,6 @@ class SQ_Classes_DisplayController {
12
  self::loadMedia('global');
13
  }
14
 
15
- /**
16
- * Check if ajax
17
- * @return bool
18
- */
19
- private static function _isAjax() {
20
- $url = (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : false);
21
- if ($url && (strpos($url, str_replace(get_bloginfo('url'), '', admin_url('admin-ajax.php', 'relative'))) !== false)) {
22
- return true;
23
- }
24
-
25
- return false;
26
- }
27
-
28
  /**
29
  * echo the css link from theme css directory
30
  *
@@ -34,7 +21,7 @@ class SQ_Classes_DisplayController {
34
  * @return string
35
  */
36
  public static function loadMedia($uri = '', $params = array('trigger' => false, 'media' => 'all')) {
37
- if (self::_isAjax()) {
38
  return;
39
  }
40
 
@@ -56,18 +43,18 @@ class SQ_Classes_DisplayController {
56
  } else {
57
  $name = strtolower(_SQ_NAMESPACE_ . $uri);
58
  }
59
- if (strpos($uri,'.css') !== false && file_exists(_SQ_THEME_DIR_ . 'css/' . strtolower($uri))) {
60
  $css_uri = _SQ_THEME_URL_ . 'css/' . strtolower($uri);
61
  }
62
- if (strpos($uri,'.js') !== false && file_exists(_SQ_THEME_DIR_ . 'js/' . strtolower($uri))) {
63
  $js_uri = _SQ_THEME_URL_ . 'js/' . strtolower($uri);
64
  }
65
 
66
- if (file_exists(_SQ_THEME_DIR_ . 'css/' . strtolower($uri) . '.css')) {
67
- $css_uri = _SQ_THEME_URL_ . 'css/' . strtolower($uri) . '.css';
68
  }
69
- if (file_exists(_SQ_THEME_DIR_ . 'js/' . strtolower($uri) . '.js')) {
70
- $js_uri = _SQ_THEME_URL_ . 'js/' . strtolower($uri) . '.js';
71
  }
72
  } else {
73
  $name = strtolower(basename($uri));
@@ -82,19 +69,20 @@ class SQ_Classes_DisplayController {
82
  if ($css_uri <> '') {
83
  if (!wp_style_is($name)) {
84
  wp_enqueue_style($name, $css_uri, null, SQ_VERSION_ID, $params['media']);
 
 
 
85
  }
86
 
87
- if(is_admin() || (isset($params['trigger']) && $params['trigger'] === true)){ //load CSS for admin or on triggered
88
- wp_print_styles(array($name));
89
- }
90
  }
91
 
92
  if ($js_uri <> '') {
93
  if (!wp_script_is($name)) {
94
- wp_enqueue_script($name, $js_uri, array('jquery'), SQ_VERSION_ID);
95
- }
96
- if (isset($params['trigger']) && $params['trigger'] === true) {
97
- wp_print_scripts(array($name));
98
  }
99
 
100
  }
12
  self::loadMedia('global');
13
  }
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  /**
16
  * echo the css link from theme css directory
17
  *
21
  * @return string
22
  */
23
  public static function loadMedia($uri = '', $params = array('trigger' => false, 'media' => 'all')) {
24
+ if (SQ_Classes_ObjController::getClass('SQ_Classes_Action')->_isAjax()) {
25
  return;
26
  }
27
 
43
  } else {
44
  $name = strtolower(_SQ_NAMESPACE_ . $uri);
45
  }
46
+ if (strpos($uri, '.css') !== false && file_exists(_SQ_THEME_DIR_ . 'css/' . strtolower($uri))) {
47
  $css_uri = _SQ_THEME_URL_ . 'css/' . strtolower($uri);
48
  }
49
+ if (strpos($uri, '.js') !== false && file_exists(_SQ_THEME_DIR_ . 'js/' . strtolower($uri))) {
50
  $js_uri = _SQ_THEME_URL_ . 'js/' . strtolower($uri);
51
  }
52
 
53
+ if (file_exists(_SQ_THEME_DIR_ . 'css/' . strtolower($uri) . (SQ_DEBUG ? '' : '.min') . '.css')) {
54
+ $css_uri = _SQ_THEME_URL_ . 'css/' . strtolower($uri) . (SQ_DEBUG ? '' : '.min') . '.css';
55
  }
56
+ if (file_exists(_SQ_THEME_DIR_ . 'js/' . strtolower($uri) . (SQ_DEBUG ? '' : '.min') . '.js')) {
57
+ $js_uri = _SQ_THEME_URL_ . 'js/' . strtolower($uri) . (SQ_DEBUG ? '' : '.min') . '.js';
58
  }
59
  } else {
60
  $name = strtolower(basename($uri));
69
  if ($css_uri <> '') {
70
  if (!wp_style_is($name)) {
71
  wp_enqueue_style($name, $css_uri, null, SQ_VERSION_ID, $params['media']);
72
+ if (is_admin() || (isset($params['trigger']) && $params['trigger'] === true)) { //load CSS for admin or on triggered
73
+ wp_print_styles(array($name));
74
+ }
75
  }
76
 
77
+
 
 
78
  }
79
 
80
  if ($js_uri <> '') {
81
  if (!wp_script_is($name)) {
82
+ wp_enqueue_script($name, $js_uri, null, SQ_VERSION_ID);
83
+ if (is_admin() || isset($params['trigger']) && $params['trigger'] === true) {
84
+ wp_print_scripts(array($name));
85
+ }
86
  }
87
 
88
  }
classes/FrontController.php CHANGED
@@ -19,13 +19,11 @@ class SQ_Classes_FrontController {
19
  private $name;
20
 
21
  public function __construct() {
22
-
23
  /* Load error class */
24
  SQ_Classes_ObjController::getClass('SQ_Classes_Error');
25
  /* Load Tools */
26
  SQ_Classes_ObjController::getClass('SQ_Classes_Tools');
27
 
28
-
29
  /* get the name of the current class */
30
  $this->name = get_class($this);
31
 
19
  private $name;
20
 
21
  public function __construct() {
 
22
  /* Load error class */
23
  SQ_Classes_ObjController::getClass('SQ_Classes_Error');
24
  /* Load Tools */
25
  SQ_Classes_ObjController::getClass('SQ_Classes_Tools');
26
 
 
27
  /* get the name of the current class */
28
  $this->name = get_class($this);
29
 
classes/ObjController.php CHANGED
@@ -161,44 +161,40 @@ class SQ_Classes_ObjController {
161
  }
162
 
163
  /**
164
- * Get all core classes from config.xml in core directory
165
  * eg.SQ_Controllers_Post
166
  * @param string $for
167
  */
168
  public function getBlocks($for) {
169
- if (function_exists('simplexml_load_string')) {
170
- /* if config allready in cache */
171
- if (!isset(self::$config)) {
172
- $config_file = _SQ_CORE_DIR_ . 'config.xml';
173
- if (!file_exists($config_file))
174
- return;
175
-
176
- /* load configuration blocks data from core config files */
177
- $data = file_get_contents($config_file);
178
- self::$config = json_decode(json_encode((array)simplexml_load_string($data)), 1);;
179
- }
180
- //print_r(self::$config);
181
- if (is_array(self::$config))
182
- foreach (self::$config['block'] as $block) {
183
- if ($block['active'] == 1)
184
- if (isset($block['controllers']['controller']))
185
- if (!is_array($block['controllers']['controller'])) {
 
 
 
 
186
  /* if the block should load for the current controller */
187
- if ($for == $block['controllers']['controller']) {
188
  SQ_Classes_ObjController::getClass($block['name'])->init();
189
  }
190
- } else {
191
- foreach ($block['controllers']['controller'] as $controller) {
192
- /* if the block should load for the current controller */
193
- if ($for == $controller) {
194
- SQ_Classes_ObjController::getClass($block['name'])->init();
195
- }
196
- }
197
  }
198
- }
199
- } else {
200
- SQ_Classes_Error::setMessage(__('You need to activate the PHP simplexml_load_string extension for Squirrly SEO to work.', _SQ_PLUGIN_NAME_));
201
- }
202
  }
203
 
204
  }
161
  }
162
 
163
  /**
164
+ * Get all core classes from config.json in core directory
165
  * eg.SQ_Controllers_Post
166
  * @param string $for
167
  */
168
  public function getBlocks($for) {
169
+ /* if config allready in cache */
170
+ if (!isset(self::$config)) {
171
+ $config_file = _SQ_CORE_DIR_ . 'config.json';
172
+ if (!file_exists($config_file))
173
+ return;
174
+
175
+ /* load configuration blocks data from core config files */
176
+ self::$config = json_decode(file_get_contents($config_file), 1);;
177
+ }
178
+ //print_r(self::$config);
179
+ if (is_array(self::$config))
180
+ foreach (self::$config['blocks']['block'] as $block) {
181
+ if ($block['active'] == 1)
182
+ if (isset($block['controllers']['controller']))
183
+ if (!is_array($block['controllers']['controller'])) {
184
+ /* if the block should load for the current controller */
185
+ if ($for == $block['controllers']['controller']) {
186
+ SQ_Classes_ObjController::getClass($block['name'])->init();
187
+ }
188
+ } else {
189
+ foreach ($block['controllers']['controller'] as $controller) {
190
  /* if the block should load for the current controller */
191
+ if ($for == $controller) {
192
  SQ_Classes_ObjController::getClass($block['name'])->init();
193
  }
 
 
 
 
 
 
 
194
  }
195
+ }
196
+ }
197
+
 
198
  }
199
 
200
  }
classes/Tools.php CHANGED
@@ -7,10 +7,8 @@
7
  */
8
  class SQ_Classes_Tools extends SQ_Classes_FrontController {
9
 
10
- /** @var array Saved options in database */
11
- public static $options = array();
12
- public static $usermeta = array();
13
-
14
  /** @var integer Count the errors in site */
15
  static $errors_count;
16
 
@@ -20,30 +18,34 @@ class SQ_Classes_Tools extends SQ_Classes_FrontController {
20
  public static $is_ajax = null;
21
 
22
  public function __construct() {
23
- parent::__construct();
24
 
25
  $maxmemory = self::getMaxMemory();
26
  if ($maxmemory && $maxmemory < 60) {
27
  @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
28
  }
29
 
30
- self::$options = $this->getOptions();
31
-
32
  $this->checkDebug(); //dev mode
33
  }
34
 
35
  public static function getMaxMemory() {
36
  try {
37
  $memory_limit = @ini_get('memory_limit');
38
- if((int) $memory_limit > 0) {
39
  if (preg_match('/^(\d+)(.)$/', $memory_limit, $matches)) {
40
- if ($matches[2] == 'M') {
 
 
41
  $memory_limit = $matches[1] * 1024 * 1024; // nnnM -> nnn MB
42
- } else if ($matches[2] == 'K') {
43
  $memory_limit = $matches[1] * 1024; // nnnK -> nnn KB
44
  }
45
  }
46
- return number_format($memory_limit / 1024 / 1024, 0);
 
 
 
47
  }
48
  } catch (Exception $e) {
49
  }
@@ -56,23 +58,67 @@ class SQ_Classes_Tools extends SQ_Classes_FrontController {
56
  return number_format(memory_get_usage() / 1024 / 1024, 0);
57
  }
58
 
59
- public static function getUserID() {
60
- global $current_user;
61
- return $current_user->ID;
62
- }
63
-
64
  /**
65
  * This hook will save the current version in database
66
  *
67
  * @return void
68
  */
69
  function hookInit() {
70
-
71
-
72
  $this->loadMultilanguage();
73
-
74
  //add setting link in plugin
75
  add_filter('plugin_action_links', array($this, 'hookActionlink'), 5, 2);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  }
77
 
78
  /**
@@ -91,6 +137,36 @@ class SQ_Classes_Tools extends SQ_Classes_FrontController {
91
  return $links;
92
  }
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  /**
95
  * Load the Options from user option table in DB
96
  *
@@ -99,8 +175,9 @@ class SQ_Classes_Tools extends SQ_Classes_FrontController {
99
  public static function getOptions($action = '') {
100
  $default = array(
101
  'sq_ver' => 0,
102
- 'sq_token' => md5(home_url() . date('d')), //daily token
103
  'sq_api' => '',
 
 
104
  'sq_checkedissues' => 0,
105
  'sq_areissues' => 0,
106
  'sq_use' => 1,
@@ -110,6 +187,7 @@ class SQ_Classes_Tools extends SQ_Classes_FrontController {
110
  'post', 'page', 'product', 'shopp_page_shopp-products'
111
  ),
112
  'sq_exclude_post_types' => array(),
 
113
  // --
114
  'sq_auto_canonical' => 1,
115
  'sq_auto_sitemap' => 0,
@@ -133,13 +211,14 @@ class SQ_Classes_Tools extends SQ_Classes_FrontController {
133
  'jobTitle' => '',
134
  'description' => ''
135
  )),
136
- 'sq_sitemap_ping' => 1,
137
  'sq_sitemap_show' => array(
138
  'images' => 1,
139
  'videos' => 0,
140
  ),
141
  'sq_sitemap_perpage' => 200,
142
  'sq_sitemap_frequency' => 'weekly',
 
143
  'sq_sitemap' => array(
144
  'sitemap' => array('sitemap.xml', 1),
145
  'sitemap-home' => array('sitemap-home.xml', 1),
@@ -153,6 +232,7 @@ class SQ_Classes_Tools extends SQ_Classes_FrontController {
153
  'sitemap-author' => array('sitemap-authors.xml', 0),
154
  'sitemap-custom-tax' => array('sitemap-custom-taxonomies.xml', 0),
155
  'sitemap-custom-post' => array('sitemap-custom-posts.xml', 0),
 
156
  ),
157
  'sq_auto_robots' => 1,
158
  'sq_robots_permission' => array(
@@ -180,6 +260,7 @@ class SQ_Classes_Tools extends SQ_Classes_FrontController {
180
  'sq_keyword_help' => 1,
181
  'sq_keyword_information' => 0,
182
  'sq_url_fix' => 1,
 
183
  //Ranking Option
184
  'sq_google_country' => 'com',
185
  'sq_google_language' => 'en',
@@ -201,7 +282,15 @@ class SQ_Classes_Tools extends SQ_Classes_FrontController {
201
  //--
202
  'sq_dashboard' => 0,
203
  'sq_analytics' => 0,
204
-
 
 
 
 
 
 
 
 
205
  'sq_metas' => array(
206
  'title_maxlength' => 75,
207
  'description_maxlength' => 320,
@@ -212,7 +301,6 @@ class SQ_Classes_Tools extends SQ_Classes_FrontController {
212
  'jsonld_title_maxlength' => 75,
213
  'jsonld_description_maxlength' => 110,
214
  ),
215
-
216
  'socials' => array(
217
  'fb_admins' => array(),
218
  'fbconnectkey' => "",
@@ -226,7 +314,6 @@ class SQ_Classes_Tools extends SQ_Classes_FrontController {
226
  'myspace_url' => "",
227
  'pinterest_url' => "",
228
  'youtube_url' => "",
229
- 'google_plus_url' => "",
230
  'twitter_card_type' => "summary",
231
  'plus_publisher' => ""
232
  ),
@@ -267,7 +354,7 @@ class SQ_Classes_Tools extends SQ_Classes_FrontController {
267
  ),
268
  'category' => array(
269
  'sep' => '|',
270
- 'title' => '{{category}} {{page}} {{sep}} {{sitename}}',
271
  'description' => '{{category_description}}',
272
  'noindex' => 0,
273
  'nofollow' => 0,
@@ -275,7 +362,7 @@ class SQ_Classes_Tools extends SQ_Classes_FrontController {
275
  ),
276
  'tag' => array(
277
  'sep' => '|',
278
- 'title' => '{{tag}} {{page}} {{sep}} {{sitename}}',
279
  'description' => '{{excerpt}}',
280
  'noindex' => 0,
281
  'nofollow' => 0,
@@ -428,6 +515,14 @@ class SQ_Classes_Tools extends SQ_Classes_FrontController {
428
  return apply_filters('sq_option_' . $key, self::$options[$key]);
429
  }
430
 
 
 
 
 
 
 
 
 
431
 
432
  /**
433
  * Get user metas
@@ -513,8 +608,8 @@ class SQ_Classes_Tools extends SQ_Classes_FrontController {
513
  return array(
514
  'sq_version' => SQ_VERSION_ID,
515
  'sq_use' => self::getOption('sq_use'),
516
- 'sq_token' => self::getOption('sq_token'),
517
- 'sq_rest' => rest_get_url_prefix(),
518
  'sq_checkedissues' => self::getOption('sq_checkedissues'),
519
  'sq_areissues' => self::getOption('sq_areissues'),
520
  'sq_auto_canonical' => self::getOption('sq_auto_canonical'),
@@ -531,7 +626,6 @@ class SQ_Classes_Tools extends SQ_Classes_FrontController {
531
  'sq_auto_description' => (int)(SQ_Classes_Tools::getOption('sq_auto_description') == 1),
532
  'sq_auto_keywords' => (int)(SQ_Classes_Tools::getOption('sq_auto_keywords') == 1),
533
  'sq_auto_noindex' => (int)(SQ_Classes_Tools::getOption('sq_auto_noindex') == 1),
534
- 'sq_google_plus' => (int)($socials['google_plus_url'] <> ''),
535
  'sq_google_wt' => (int)($codes['google_wt'] <> ''),
536
  'sq_google_analytics' => (int)($codes['google_analytics'] <> ''),
537
  'sq_google_serpsperhour' => (int)SQ_Classes_Tools::getOption('sq_google_serpsperhour'),
@@ -600,15 +694,21 @@ class SQ_Classes_Tools extends SQ_Classes_FrontController {
600
  *
601
  * @param string $key Value key
602
  * @param mixed $defaultValue (optional)
 
 
603
  * @return mixed Value
604
  */
605
- public static function getValue($key, $defaultValue = false, $withcode = false) {
606
  if (!isset($key) OR empty($key) OR !is_string($key))
607
  return false;
608
- $ret = (isset($_POST[$key]) ? (is_string($_POST[$key]) ? urldecode($_POST[$key]) : $_POST[$key]) : (isset($_GET[$key]) ? (is_string($_GET[$key]) ? urldecode($_GET[$key]) : $_GET[$key]) : $defaultValue));
609
 
610
- if (is_string($ret) === true && $withcode === false) {
611
- $ret = sanitize_text_field($ret);
 
 
 
 
612
  }
613
 
614
  return !is_string($ret) ? $ret : stripslashes($ret);
@@ -1322,7 +1422,7 @@ class SQ_Classes_Tools extends SQ_Classes_FrontController {
1322
  * Check if debug is called
1323
  */
1324
  private function checkDebug() {
1325
- //if debug is called
1326
  if (SQ_DEBUG && self::getIsset('sq_debug')) {
1327
  if (self::getValue('sq_debug') === 'on') {
1328
  if (function_exists('register_shutdown_function')) {
@@ -1394,6 +1494,17 @@ class SQ_Classes_Tools extends SQ_Classes_FrontController {
1394
  echo "Debug result: <br />" . '<div id="wpcontent">' . @implode('<br />', self::$debug) . '</div>';
1395
  }
1396
 
 
 
 
 
 
 
 
 
 
 
 
1397
  public function sq_activate() {
1398
  set_transient('sq_activate', true);
1399
  set_transient('sq_rewrite', true);
@@ -1539,10 +1650,17 @@ class SQ_Classes_Tools extends SQ_Classes_FrontController {
1539
 
1540
  public static function getBusinessLink() {
1541
  if (!self::getOption('sq_google_serp_active')) {
1542
- return _SQ_DASH_URL_ . 'login/?token=' . self::getOption('sq_api') . '&redirect_to=' . _SQ_DASH_URL_ . 'user/plans?pid=31';
1543
  } else {
1544
  return admin_url('admin.php?page=sq_posts');
1545
  }
1546
 
1547
  }
 
 
 
 
 
 
 
1548
  }
7
  */
8
  class SQ_Classes_Tools extends SQ_Classes_FrontController {
9
 
10
+ /** @var array Options, User Metas, Package and Plugin details */
11
+ public static $options, $usermeta, $package, $plugin = array();
 
 
12
  /** @var integer Count the errors in site */
13
  static $errors_count;
14
 
18
  public static $is_ajax = null;
19
 
20
  public function __construct() {
21
+ self::$options = $this->getOptions();
22
 
23
  $maxmemory = self::getMaxMemory();
24
  if ($maxmemory && $maxmemory < 60) {
25
  @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
26
  }
27
 
28
+ SQ_Classes_ObjController::getClass('SQ_Classes_HookController')->setHooks($this);
 
29
  $this->checkDebug(); //dev mode
30
  }
31
 
32
  public static function getMaxMemory() {
33
  try {
34
  $memory_limit = @ini_get('memory_limit');
35
+ if ((int)$memory_limit > 0) {
36
  if (preg_match('/^(\d+)(.)$/', $memory_limit, $matches)) {
37
+ if ($matches[2] == 'G') {
38
+ $memory_limit = $matches[1] * 1024 * 1024 * 1024; // nnnM -> nnn MB
39
+ } elseif ($matches[2] == 'M') {
40
  $memory_limit = $matches[1] * 1024 * 1024; // nnnM -> nnn MB
41
+ } elseif ($matches[2] == 'K') {
42
  $memory_limit = $matches[1] * 1024; // nnnK -> nnn KB
43
  }
44
  }
45
+
46
+ if ((int)$memory_limit > 0) {
47
+ return number_format($memory_limit / 1024 / 1024, 0, '', '');
48
+ }
49
  }
50
  } catch (Exception $e) {
51
  }
58
  return number_format(memory_get_usage() / 1024 / 1024, 0);
59
  }
60
 
 
 
 
 
 
61
  /**
62
  * This hook will save the current version in database
63
  *
64
  * @return void
65
  */
66
  function hookInit() {
 
 
67
  $this->loadMultilanguage();
68
+ add_filter("plugin_row_meta", array($this, 'hookExtraLinks'), 10, 4);
69
  //add setting link in plugin
70
  add_filter('plugin_action_links', array($this, 'hookActionlink'), 5, 2);
71
+
72
+ if (self::getOption('sq_name') <> '') {
73
+ if (isset($_SERVER['REQUEST_URI']) && function_exists('get_plugin_data')) {
74
+ if (strpos($_SERVER['REQUEST_URI'], '/plugins.php') !== false) {
75
+ $data = get_plugin_data(_SQ_ROOT_DIR_ . '/squirrly.php');
76
+ if (isset($data['Name'])) {
77
+ self::$plugin['name'] = $data['Name'];
78
+ add_filter('pre_kses', array('SQ_Classes_Tools', 'changeString'), 1, 1);
79
+ }
80
+ }
81
+ }
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Check if Dev Kit is installed
87
+ * @return mixed|false
88
+ */
89
+ public static function updatePluginData() {
90
+ $package_file = _SQ_ROOT_DIR_ . '/package.json';
91
+ if (!file_exists($package_file)) {
92
+ return false;
93
+ }
94
+
95
+ /* load configuration blocks data from core config files */
96
+ $config = json_decode(file_get_contents($package_file), 1);
97
+ if (isset($config['package'])) {
98
+ self::$package = $config['package'];
99
+
100
+ if (isset(self::$package['settings']) && !empty(self::$options)) {
101
+ self::$options = @array_merge(self::$options, self::$package['settings']);
102
+
103
+ if (isset(self::$package['name']) && self::$package['name'] <> '') {
104
+ self::$options['sq_name'] = self::$package['name'] . ' - Squirrly Special';
105
+ }
106
+
107
+ self::saveOptions();
108
+ wp_redirect(admin_url('admin.php?page=sq_dashboard'));
109
+ }
110
+ }
111
+
112
+
113
+ //remove the package after activation
114
+ @unlink($package_file);
115
+ }
116
+
117
+ public static function changeString($string) {
118
+ if (isset(self::$plugin['name']) && self::getOption('sq_name') <> '') {
119
+ return str_replace(self::$plugin['name'], self::getOption('sq_name'), $string);
120
+ }
121
+ return $string;
122
  }
123
 
124
  /**
137
  return $links;
138
  }
139
 
140
+ /**
141
+ * Adds extra links to plugin page
142
+ */
143
+ public function hookExtraLinks($meta, $file, $data, $status) {
144
+ if ($file == _SQ_PLUGIN_NAME_ . '/squirrly.php') {
145
+ echo '<style>
146
+ .ml-stars{display:inline-block;color:#ffb900;position:relative;top:3px}
147
+ .ml-stars svg{fill:#ffb900}
148
+ .ml-stars svg:hover{fill:#ffb900}
149
+ .ml-stars svg:hover ~ svg{fill:none}
150
+ </style>';
151
+
152
+ $meta[] = "<a href='https://howto.squirrly.co/wordpress-seo/' target='_blank'>" . __('Documentation', _SQ_PLUGIN_NAME_) . "</a>";
153
+ $meta[] = "<a href='https://wordpress.org/support/plugin/squirrly-seo/reviews/#new-post' target='_blank' title='" . __('Leave a review', _SQ_PLUGIN_NAME_) . "'><i class='ml-stars'><svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg><svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg><svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg><svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg><svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg></i></a>";
154
+ }
155
+ return $meta;
156
+ }
157
+
158
+
159
+ public static function getToken() {
160
+ if (get_transient('sq_token')) {
161
+ $token = get_transient('sq_token');
162
+ } else {
163
+ $token = md5(self::generatePassword(32));
164
+ set_transient('sq_token', md5($token));
165
+ }
166
+
167
+ return $token;
168
+ }
169
+
170
  /**
171
  * Load the Options from user option table in DB
172
  *
175
  public static function getOptions($action = '') {
176
  $default = array(
177
  'sq_ver' => 0,
 
178
  'sq_api' => '',
179
+ 'sq_logo' => _SQ_THEME_URL_ . 'img/settings/menu_icon_16.png',
180
+ 'sq_name' => '',
181
  'sq_checkedissues' => 0,
182
  'sq_areissues' => 0,
183
  'sq_use' => 1,
187
  'post', 'page', 'product', 'shopp_page_shopp-products'
188
  ),
189
  'sq_exclude_post_types' => array(),
190
+ 'sq_support_email' => '',
191
  // --
192
  'sq_auto_canonical' => 1,
193
  'sq_auto_sitemap' => 0,
211
  'jobTitle' => '',
212
  'description' => ''
213
  )),
214
+ 'sq_sitemap_ping' => 0,
215
  'sq_sitemap_show' => array(
216
  'images' => 1,
217
  'videos' => 0,
218
  ),
219
  'sq_sitemap_perpage' => 200,
220
  'sq_sitemap_frequency' => 'weekly',
221
+ 'sq_sitemap_combinelangs' => 1,
222
  'sq_sitemap' => array(
223
  'sitemap' => array('sitemap.xml', 1),
224
  'sitemap-home' => array('sitemap-home.xml', 1),
232
  'sitemap-author' => array('sitemap-authors.xml', 0),
233
  'sitemap-custom-tax' => array('sitemap-custom-taxonomies.xml', 0),
234
  'sitemap-custom-post' => array('sitemap-custom-posts.xml', 0),
235
+ 'sitemap-attachment' => array('sitemap-attachment.xml', 0),
236
  ),
237
  'sq_auto_robots' => 1,
238
  'sq_robots_permission' => array(
260
  'sq_keyword_help' => 1,
261
  'sq_keyword_information' => 0,
262
  'sq_url_fix' => 1,
263
+ 'sq_img_licence' => 1,
264
  //Ranking Option
265
  'sq_google_country' => 'com',
266
  'sq_google_language' => 'en',
282
  //--
283
  'sq_dashboard' => 0,
284
  'sq_analytics' => 0,
285
+ 'sq_analytics_google_js' => 'analytics',
286
+ 'menu' => array(
287
+ 'show_account_info' => 1,
288
+ 'show_affiliate' => 1,
289
+ 'show_panel' => 1,
290
+ 'show_tutorial' => 1,
291
+ 'show_audit' => 1,
292
+ 'show_ads' => 1,
293
+ ),
294
  'sq_metas' => array(
295
  'title_maxlength' => 75,
296
  'description_maxlength' => 320,
301
  'jsonld_title_maxlength' => 75,
302
  'jsonld_description_maxlength' => 110,
303
  ),
 
304
  'socials' => array(
305
  'fb_admins' => array(),
306
  'fbconnectkey' => "",
314
  'myspace_url' => "",
315
  'pinterest_url' => "",
316
  'youtube_url' => "",
 
317
  'twitter_card_type' => "summary",
318
  'plus_publisher' => ""
319
  ),
354
  ),
355
  'category' => array(
356
  'sep' => '|',
357
+ 'title' => '{{title}} {{page}} {{sep}} {{sitename}}',
358
  'description' => '{{category_description}}',
359
  'noindex' => 0,
360
  'nofollow' => 0,
362
  ),
363
  'tag' => array(
364
  'sep' => '|',
365
+ 'title' => '{{title}} {{page}} {{sep}} {{sitename}}',
366
  'description' => '{{excerpt}}',
367
  'noindex' => 0,
368
  'nofollow' => 0,
515
  return apply_filters('sq_option_' . $key, self::$options[$key]);
516
  }
517
 
518
+ //Get the package info in case of custom details
519
+ public static function getPackageInfo($key) {
520
+ if (isset(self::$package[$key])) {
521
+ return self::$package[$key];
522
+ }
523
+
524
+ return false;
525
+ }
526
 
527
  /**
528
  * Get user metas
608
  return array(
609
  'sq_version' => SQ_VERSION_ID,
610
  'sq_use' => self::getOption('sq_use'),
611
+ 'sq_token' => self::getToken(),
612
+ 'sq_rest' => (function_exists('rest_get_url_prefix') ? rest_get_url_prefix() : ''),
613
  'sq_checkedissues' => self::getOption('sq_checkedissues'),
614
  'sq_areissues' => self::getOption('sq_areissues'),
615
  'sq_auto_canonical' => self::getOption('sq_auto_canonical'),
626
  'sq_auto_description' => (int)(SQ_Classes_Tools::getOption('sq_auto_description') == 1),
627
  'sq_auto_keywords' => (int)(SQ_Classes_Tools::getOption('sq_auto_keywords') == 1),
628
  'sq_auto_noindex' => (int)(SQ_Classes_Tools::getOption('sq_auto_noindex') == 1),
 
629
  'sq_google_wt' => (int)($codes['google_wt'] <> ''),
630
  'sq_google_analytics' => (int)($codes['google_analytics'] <> ''),
631
  'sq_google_serpsperhour' => (int)SQ_Classes_Tools::getOption('sq_google_serpsperhour'),
694
  *
695
  * @param string $key Value key
696
  * @param mixed $defaultValue (optional)
697
+ * @param bool $htmlcode
698
+ * @param bool $keep_newlines
699
  * @return mixed Value
700
  */
701
+ public static function getValue($key, $defaultValue = false, $htmlcode = false, $keep_newlines = false) {
702
  if (!isset($key) OR empty($key) OR !is_string($key))
703
  return false;
704
+ $ret = (isset($_POST[$key]) ? (is_string($_POST[$key]) ? rawurldecode($_POST[$key]) : $_POST[$key]) : (isset($_GET[$key]) ? (is_string($_GET[$key]) ? rawurldecode($_GET[$key]) : $_GET[$key]) : $defaultValue));
705
 
706
+ if (is_string($ret) === true && $htmlcode === false) {
707
+ if ($keep_newlines && function_exists('sanitize_textarea_field')) {
708
+ $ret = sanitize_textarea_field($ret);
709
+ } else {
710
+ $ret = sanitize_text_field($ret);
711
+ }
712
  }
713
 
714
  return !is_string($ret) ? $ret : stripslashes($ret);
1422
  * Check if debug is called
1423
  */
1424
  private function checkDebug() {
1425
+ //if debug is called
1426
  if (SQ_DEBUG && self::getIsset('sq_debug')) {
1427
  if (self::getValue('sq_debug') === 'on') {
1428
  if (function_exists('register_shutdown_function')) {
1494
  echo "Debug result: <br />" . '<div id="wpcontent">' . @implode('<br />', self::$debug) . '</div>';
1495
  }
1496
 
1497
+ public static function generatePassword($length = 12) {
1498
+ $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
1499
+
1500
+ $password = '';
1501
+ for ($i = 0; $i < $length; $i++) {
1502
+ $password .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
1503
+ }
1504
+
1505
+ return $password;
1506
+ }
1507
+
1508
  public function sq_activate() {
1509
  set_transient('sq_activate', true);
1510
  set_transient('sq_rewrite', true);
1650
 
1651
  public static function getBusinessLink() {
1652
  if (!self::getOption('sq_google_serp_active')) {
1653
+ return _SQ_DASH_URL_ . 'login/?token=' . self::getToken() . '&redirect_to=' . _SQ_DASH_URL_ . 'user/plans?pid=31';
1654
  } else {
1655
  return admin_url('admin.php?page=sq_posts');
1656
  }
1657
 
1658
  }
1659
+
1660
+ public static function isGutenberg() {
1661
+ if (function_exists('is_gutenberg_page')) {
1662
+ return @is_gutenberg_page();
1663
+ }
1664
+ return false;
1665
+ }
1666
  }
config/config.php CHANGED
@@ -60,8 +60,11 @@ define('SQ_ALL_PATTERNS', json_encode(array(
60
  '{{modified}}' => __("Replaces the publication date of a post/page with the modified one", _SQ_PLUGIN_NAME_),
61
  '{{name}}' => __("Displays the author's nicename", _SQ_PLUGIN_NAME_),
62
  '{{user_description}}' => __("Adds the author's biographical info to the post description", _SQ_PLUGIN_NAME_),
63
- '{{currentdate}}' => __("Displays the current date of a post/page", _SQ_PLUGIN_NAME_),
64
  '{{keyword}}' => __("Adds the post's keyword to the post description", _SQ_PLUGIN_NAME_),
 
 
 
65
  )));
66
 
67
 
@@ -80,3 +83,14 @@ define('SQ_ALL_SEP', json_encode(array(
80
  'sc-lt' => '&lt;',
81
  'sc-gt' => '&gt;',
82
  )));
 
 
 
 
 
 
 
 
 
 
 
60
  '{{modified}}' => __("Replaces the publication date of a post/page with the modified one", _SQ_PLUGIN_NAME_),
61
  '{{name}}' => __("Displays the author's nicename", _SQ_PLUGIN_NAME_),
62
  '{{user_description}}' => __("Adds the author's biographical info to the post description", _SQ_PLUGIN_NAME_),
63
+ '{{currentdate}}' => __("Displays the current date", _SQ_PLUGIN_NAME_),
64
  '{{keyword}}' => __("Adds the post's keyword to the post description", _SQ_PLUGIN_NAME_),
65
+ '{{currentday}}' => __("Adds the current day", _SQ_PLUGIN_NAME_),
66
+ '{{currentmonth}}' => __("Adds the current month", _SQ_PLUGIN_NAME_),
67
+ '{{currentyear}}' => __("Adds the current year", _SQ_PLUGIN_NAME_),
68
  )));
69
 
70
 
83
  'sc-lt' => '&lt;',
84
  'sc-gt' => '&gt;',
85
  )));
86
+
87
+ define('SQ_ALL_JSONLD_TYPES', json_encode(array(
88
+ 'home' => 'website',
89
+ 'profile' => 'profile',
90
+ 'post' => 'article',
91
+ 'page' => 'website',
92
+ 'book' => 'book',
93
+ 'music' => 'music',
94
+ 'product' => 'product',
95
+ 'video' => 'video'
96
+ )));
config/paths.php CHANGED
@@ -14,7 +14,6 @@ defined('_SQ_API_URL_') || define('_SQ_API_URL_', '//api.squirrly.co/');
14
 
15
  defined('_SQ_STATIC_API_URL_') || define('_SQ_STATIC_API_URL_', '//storage.googleapis.com/squirrly/');
16
  defined('_SQ_SUPPORT_EMAIL_URL_') || define('_SQ_SUPPORT_EMAIL_URL_', 'http://plugin.squirrly.co/contact/');
17
- defined('_SQ_SUPPORT_GOOGLE_URL_') || define('_SQ_SUPPORT_GOOGLE_URL_', 'https://plus.google.com/u/0/communities/104196720668136264985');
18
  defined('_SQ_SUPPORT_FACEBOOK_URL_') || define('_SQ_SUPPORT_FACEBOOK_URL_', 'https://www.facebook.com/Squirrly.co');
19
  defined('_SQ_SUPPORT_URL_') || define('_SQ_SUPPORT_URL_', _SQ_SUPPORT_FACEBOOK_URL_);
20
 
@@ -33,19 +32,23 @@ define('_SQ_URL_', plugins_url('', $currentDir));
33
  define('_SQ_THEME_URL_', _SQ_URL_ . '/view/');
34
  define('_SQ_THEME_RELATIVE_URL_', ltrim(parse_url(_SQ_THEME_URL_, PHP_URL_PATH), '/'));
35
 
 
 
 
36
 
37
- $upload_dir = wp_upload_dir();
38
  if (is_dir($upload_dir['basedir'])) {
39
  $upload_path = $upload_dir['basedir'] . '/' . _SQ_NAME_ . '/';
 
40
 
41
- //create directory if doesn't exists
42
  if (!is_dir($upload_path)) {
43
  wp_mkdir_p($upload_path);
44
  }
45
 
46
- if (is_dir($upload_path) && (function_exists('wp_is_writable') && wp_is_writable($upload_path))) {
47
- define('_SQ_CACHE_DIR_', realpath($upload_path) . '/');
48
- define('_SQ_CACHE_URL_', $upload_dir['baseurl'] . '/' . _SQ_NAME_ . '/');
49
  }
50
  }
51
 
14
 
15
  defined('_SQ_STATIC_API_URL_') || define('_SQ_STATIC_API_URL_', '//storage.googleapis.com/squirrly/');
16
  defined('_SQ_SUPPORT_EMAIL_URL_') || define('_SQ_SUPPORT_EMAIL_URL_', 'http://plugin.squirrly.co/contact/');
 
17
  defined('_SQ_SUPPORT_FACEBOOK_URL_') || define('_SQ_SUPPORT_FACEBOOK_URL_', 'https://www.facebook.com/Squirrly.co');
18
  defined('_SQ_SUPPORT_URL_') || define('_SQ_SUPPORT_URL_', _SQ_SUPPORT_FACEBOOK_URL_);
19
 
32
  define('_SQ_THEME_URL_', _SQ_URL_ . '/view/');
33
  define('_SQ_THEME_RELATIVE_URL_', ltrim(parse_url(_SQ_THEME_URL_, PHP_URL_PATH), '/'));
34
 
35
+ $upload_dir = array();
36
+ $upload_dir['baseurl'] = WP_CONTENT_URL . '/uploads';
37
+ $upload_dir['basedir'] = WP_CONTENT_DIR . '/uploads';
38
 
39
+ $upload_path = '';
40
  if (is_dir($upload_dir['basedir'])) {
41
  $upload_path = $upload_dir['basedir'] . '/' . _SQ_NAME_ . '/';
42
+ }
43
 
44
+ if ($upload_path <> '') {
45
  if (!is_dir($upload_path)) {
46
  wp_mkdir_p($upload_path);
47
  }
48
 
49
+ if (is_dir($upload_path) && function_exists('wp_is_writable') && wp_is_writable($upload_path)) {
50
+ defined('_SQ_CACHE_DIR_') || define('_SQ_CACHE_DIR_', realpath($upload_path) . '/');
51
+ defined('_SQ_CACHE_URL_') || define('_SQ_CACHE_URL_', $upload_dir['baseurl'] . '/' . _SQ_NAME_ . '/');
52
  }
53
  }
54
 
controllers/Api.php CHANGED
@@ -35,7 +35,7 @@ class SQ_Controllers_Api extends SQ_Classes_FrontController {
35
  $token = sanitize_text_field($token);
36
  }
37
 
38
- if (SQ_Classes_Tools::getOption('sq_token') <> $token) {
39
  SQ_Classes_Action::apiSaveSettings();
40
  exit(json_encode(array('error' => __('Connection expired. Please try again', _SQ_PLUGIN_NAME_))));
41
 
35
  $token = sanitize_text_field($token);
36
  }
37
 
38
+ if (SQ_Classes_Tools::getToken() <> $token) {
39
  SQ_Classes_Action::apiSaveSettings();
40
  exit(json_encode(array('error' => __('Connection expired. Please try again', _SQ_PLUGIN_NAME_))));
41
 
controllers/Frontend.php CHANGED
@@ -8,19 +8,21 @@ class SQ_Controllers_Frontend extends SQ_Classes_FrontController {
8
  public function __construct() {
9
  if (SQ_Classes_Tools::isAjax()) return;
10
  parent::__construct();
11
-
12
  //For favicon and Robots
13
  $this->hookCheckFiles();
14
 
15
  //Hook the buffer on both actions in case one fails
16
  if (!defined('CE_FILE')) { //compatible with other cache plugins
17
- add_action('plugins_loaded', array($this, 'hookBuffer'));
18
  }
19
- add_action('template_redirect', array($this, 'hookBuffer'));
20
 
21
  //Set the post so that Squirrly will know which one to process
22
- add_action('template_redirect', array($this->model, 'setPost'), 9);
23
-
 
 
 
24
  /* Check if sitemap is on and Load the Sitemap */
25
  if (SQ_Classes_Tools::getOption('sq_auto_sitemap')) SQ_Classes_ObjController::getClass('SQ_Controllers_Sitemaps');
26
 
@@ -38,7 +40,7 @@ class SQ_Controllers_Frontend extends SQ_Classes_FrontController {
38
  public function hookBuffer() {
39
  //remove the action is already hocked in plugins_loaded
40
  if (!did_action('template_redirect')) {
41
- remove_action('template_redirect', array($this, 'hookBuffer'));
42
  }
43
 
44
  if ($this->isSquirrlySeoEnabled()) {
8
  public function __construct() {
9
  if (SQ_Classes_Tools::isAjax()) return;
10
  parent::__construct();
 
11
  //For favicon and Robots
12
  $this->hookCheckFiles();
13
 
14
  //Hook the buffer on both actions in case one fails
15
  if (!defined('CE_FILE')) { //compatible with other cache plugins
16
+ add_action('plugins_loaded', array($this, 'hookBuffer'), 9);
17
  }
18
+ add_action('template_redirect', array($this, 'hookBuffer'), 1);
19
 
20
  //Set the post so that Squirrly will know which one to process
21
+ if(defined('BP_REQUIRED_PHP_VERSION')) {
22
+ add_action('template_redirect', array($this->model, 'setPost'), 10);
23
+ }else{
24
+ add_action('template_redirect', array($this->model, 'setPost'), 9);
25
+ }
26
  /* Check if sitemap is on and Load the Sitemap */
27
  if (SQ_Classes_Tools::getOption('sq_auto_sitemap')) SQ_Classes_ObjController::getClass('SQ_Controllers_Sitemaps');
28
 
40
  public function hookBuffer() {
41
  //remove the action is already hocked in plugins_loaded
42
  if (!did_action('template_redirect')) {
43
+ remove_action('template_redirect', array($this, 'hookBuffer'), 1);
44
  }
45
 
46
  if ($this->isSquirrlySeoEnabled()) {
controllers/Menu.php CHANGED
@@ -11,6 +11,7 @@ class SQ_Controllers_Menu extends SQ_Classes_FrontController {
11
  public function __construct() {
12
  parent::__construct();
13
  add_action('admin_bar_menu', array($this, 'hookTopmenu'), 999);
 
14
  }
15
 
16
  /**
@@ -69,12 +70,17 @@ class SQ_Controllers_Menu extends SQ_Classes_FrontController {
69
  SQ_Classes_Error::setMessage(sprintf(__("An error occurred during activation. If this error persists, please contact us at: %s", _SQ_PLUGIN_NAME_), _SQ_SUPPORT_EMAIL_));
70
  }
71
 
 
 
 
72
  }
73
  //activate the cron job if not exists
74
  if (!wp_get_schedule('sq_processCron')) {
75
  wp_schedule_event(time(), 'hourly', 'sq_processCron');
76
  }
77
 
 
 
78
  add_filter('rewrite_rules_array', array(SQ_Classes_ObjController::getClass('SQ_Core_BlockSettingsSeo'), 'rewrite_rules'), 999, 1);
79
  }
80
 
@@ -97,6 +103,9 @@ class SQ_Controllers_Menu extends SQ_Classes_FrontController {
97
  'href' => admin_url('admin.php?page=sq_posts'),
98
  'parent' => false
99
  ));
 
 
 
100
  }
101
 
102
  if (is_admin()) {
@@ -118,8 +127,14 @@ class SQ_Controllers_Menu extends SQ_Classes_FrontController {
118
  return;
119
  }
120
 
121
- //Add the snippet in all post types
122
- $this->addMetabox();
 
 
 
 
 
 
123
  } else {
124
  //If user set not to load Squirrly in frontend
125
  if (!SQ_Classes_Tools::getOption('sq_use_frontend')) {
@@ -176,6 +191,7 @@ class SQ_Controllers_Menu extends SQ_Classes_FrontController {
176
  public function hookMenu() {
177
 
178
  $this->post_type = SQ_Classes_Tools::getOption('sq_post_types');
 
179
 
180
  //Push the Analytics Check
181
  if (strpos($_SERVER['REQUEST_URI'], '?page=sq_dashboard') !== false) {
@@ -198,29 +214,15 @@ class SQ_Controllers_Menu extends SQ_Classes_FrontController {
198
  }
199
  }
200
 
201
-
202
- //Show bar to go back and finish the help
203
- if (current_user_can('manage_options') && ($this->is_page('edit') || strpos($_SERVER['REQUEST_URI'], '?page=sq_posts') !== false)) {
204
- if (SQ_Classes_Tools::getOption('active_help') <> '' && !SQ_Classes_Tools::getOption('ignore_warn')) {
205
- SQ_Classes_Error::setError(sprintf(__('Go back and complete the Squirrly Tasks for today %sContinue%s', _SQ_PLUGIN_NAME_), '<a href="admin.php?page=sq_' . SQ_Classes_Tools::getOption('active_help') . '" class="sq_button" title="Continue the Help">', '</a>'), 'helpnotice');
206
- }
207
-
208
- if (strpos($_SERVER['REQUEST_URI'], '?page=sq_posts') !== false) {
209
- $analytics_alert = 0;
210
- }
211
- }
212
-
213
  $dashboard_alert = (int)(SQ_Classes_Tools::getOption('sq_dashboard') == 0);
214
 
215
-
216
  ///////////////
217
-
218
  $this->model->addMenu(array(ucfirst(_SQ_NAME_),
219
  'Squirrly' . (($analytics_alert) ? SQ_Classes_Tools::showNotices($analytics_alert, 'errors_count') : ''),
220
  'edit_posts',
221
  'sq_dashboard',
222
  null,
223
- _SQ_THEME_URL_ . 'img/settings/menu_icon_16.png'
224
  ));
225
 
226
  $this->model->addSubmenu(array('sq_dashboard',
@@ -281,7 +283,7 @@ class SQ_Controllers_Menu extends SQ_Classes_FrontController {
281
  array(SQ_Classes_ObjController::getClass('SQ_Core_BlockCopyright'), 'init')
282
  ));
283
 
284
- if (current_user_can('manage_options')) {
285
  $this->model->addSubmenu(array('sq_dashboard',
286
  ucfirst(_SQ_NAME_) . __(' SEO Audit', _SQ_PLUGIN_NAME_),
287
  __('Site Audit', _SQ_PLUGIN_NAME_),
@@ -316,13 +318,15 @@ class SQ_Controllers_Menu extends SQ_Classes_FrontController {
316
  array(SQ_Classes_ObjController::getClass('SQ_Core_BlockPatterns'), 'init')
317
  ));
318
 
319
- $this->model->addSubmenu(array('sq_dashboard',
320
- ucfirst(_SQ_NAME_) . __(' Account Info', _SQ_PLUGIN_NAME_),
321
- __('Account Info', _SQ_PLUGIN_NAME_),
322
- 'manage_options',
323
- 'sq_account',
324
- array(SQ_Classes_ObjController::getClass('SQ_Core_BlockAccount'), 'init')
325
- ));
 
 
326
 
327
  $this->model->addSubmenu(array('sq_dashboard',
328
  ucfirst(_SQ_NAME_) . __(' Support', _SQ_PLUGIN_NAME_),
@@ -332,56 +336,76 @@ class SQ_Controllers_Menu extends SQ_Classes_FrontController {
332
  array(SQ_Classes_ObjController::getClass('SQ_Core_BlockCustomerService'), 'init')
333
  ));
334
 
335
- $this->model->addSubmenu(array('sq_dashboard',
336
- __('Become an Affiliate with ', _SQ_PLUGIN_NAME_) . ucfirst(_SQ_NAME_),
337
- __('Become an Affiliate', _SQ_PLUGIN_NAME_),
338
- 'edit_posts',
339
- 'sq_affiliate',
340
- array(SQ_Classes_ObjController::getClass('SQ_Core_BlockAffiliate'), 'init')
341
- ));
 
 
342
 
343
  if (current_user_can('manage_options')) {
344
  $this->model->addSubmenu(array('sq_dashboard',
345
- __('Import SEO ', _SQ_PLUGIN_NAME_),
346
- __('Import SEO', _SQ_PLUGIN_NAME_),
347
  'edit_posts',
348
  'sq_import',
349
  array(SQ_Classes_ObjController::getClass('SQ_Core_BlockImport'), 'init')
350
  ));
351
  }
352
 
353
-
354
- foreach ($this->post_type as $type) {
355
- $this->model->addMeta(array('post' . _SQ_NAME_,
356
- ucfirst(_SQ_NAME_),
357
- array(SQ_Classes_ObjController::getClass('SQ_Controllers_Post'), 'init'),
358
- $type,
359
- 'side',
360
- 'high'
361
- ));
362
- }
363
-
364
-
365
  //Add the Rank in the Posts list
366
  $postlist = SQ_Classes_ObjController::getClass('SQ_Controllers_PostsList');
367
  if (is_object($postlist)) {
368
  $postlist->init();
369
  }
370
 
371
-
372
  }
373
 
374
  /**
375
  * Add Post Editor Meta Box
376
  */
377
  public function addMetabox() {
378
- $this->model->addMeta(array('sq_blocksnippet',
379
- ucfirst(_SQ_NAME_) . ' ' . __('SEO Snippet', _SQ_PLUGIN_NAME_),
380
- array(SQ_Classes_ObjController::getClass('SQ_Controllers_FrontMenu'), 'show'),
381
- null,
382
- 'normal',
383
- 'high'
384
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
385
  }
386
 
387
  /**
11
  public function __construct() {
12
  parent::__construct();
13
  add_action('admin_bar_menu', array($this, 'hookTopmenu'), 999);
14
+ add_action('do_meta_boxes', array($this, 'addMetabox'));
15
  }
16
 
17
  /**
70
  SQ_Classes_Error::setMessage(sprintf(__("An error occurred during activation. If this error persists, please contact us at: %s", _SQ_PLUGIN_NAME_), _SQ_SUPPORT_EMAIL_));
71
  }
72
 
73
+ //This option is use for custom Package details
74
+ SQ_Classes_Tools::updatePluginData(); //update text in case of devkit
75
+
76
  }
77
  //activate the cron job if not exists
78
  if (!wp_get_schedule('sq_processCron')) {
79
  wp_schedule_event(time(), 'hourly', 'sq_processCron');
80
  }
81
 
82
+ //Hook the post save action
83
+ SQ_Classes_ObjController::getClass('SQ_Controllers_Post')->hookPost();
84
  add_filter('rewrite_rules_array', array(SQ_Classes_ObjController::getClass('SQ_Core_BlockSettingsSeo'), 'rewrite_rules'), 999, 1);
85
  }
86
 
103
  'href' => admin_url('admin.php?page=sq_posts'),
104
  'parent' => false
105
  ));
106
+
107
+ //Hood the TinyMCE editor andd add the H2 button
108
+ SQ_Classes_ObjController::getClass('SQ_Controllers_Post')->hookEditor();
109
  }
110
 
111
  if (is_admin()) {
127
  return;
128
  }
129
 
130
+ $this->model->addMeta(array('sq_blocksnippet',
131
+ ucfirst(_SQ_NAME_) . ' ' . __('SEO Snippet', _SQ_PLUGIN_NAME_),
132
+ array(SQ_Classes_ObjController::getClass('SQ_Controllers_FrontMenu'), 'show'),
133
+ null,
134
+ 'normal',
135
+ 'high'
136
+ ));
137
+
138
  } else {
139
  //If user set not to load Squirrly in frontend
140
  if (!SQ_Classes_Tools::getOption('sq_use_frontend')) {
191
  public function hookMenu() {
192
 
193
  $this->post_type = SQ_Classes_Tools::getOption('sq_post_types');
194
+ $menu = SQ_Classes_Tools::getOption('menu');
195
 
196
  //Push the Analytics Check
197
  if (strpos($_SERVER['REQUEST_URI'], '?page=sq_dashboard') !== false) {
214
  }
215
  }
216
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  $dashboard_alert = (int)(SQ_Classes_Tools::getOption('sq_dashboard') == 0);
218
 
 
219
  ///////////////
 
220
  $this->model->addMenu(array(ucfirst(_SQ_NAME_),
221
  'Squirrly' . (($analytics_alert) ? SQ_Classes_Tools::showNotices($analytics_alert, 'errors_count') : ''),
222
  'edit_posts',
223
  'sq_dashboard',
224
  null,
225
+ SQ_Classes_Tools::getOption('sq_logo')
226
  ));
227
 
228
  $this->model->addSubmenu(array('sq_dashboard',
283
  array(SQ_Classes_ObjController::getClass('SQ_Core_BlockCopyright'), 'init')
284
  ));
285
 
286
+ if ($menu['show_audit'] && current_user_can('manage_options')) {
287
  $this->model->addSubmenu(array('sq_dashboard',
288
  ucfirst(_SQ_NAME_) . __(' SEO Audit', _SQ_PLUGIN_NAME_),
289
  __('Site Audit', _SQ_PLUGIN_NAME_),
318
  array(SQ_Classes_ObjController::getClass('SQ_Core_BlockPatterns'), 'init')
319
  ));
320
 
321
+ if ($menu['show_account_info']) {
322
+ $this->model->addSubmenu(array('sq_dashboard',
323
+ ucfirst(_SQ_NAME_) . __(' Account Info', _SQ_PLUGIN_NAME_),
324
+ __('Account Info', _SQ_PLUGIN_NAME_),
325
+ 'manage_options',
326
+ 'sq_account',
327
+ array(SQ_Classes_ObjController::getClass('SQ_Core_BlockAccount'), 'init')
328
+ ));
329
+ }
330
 
331
  $this->model->addSubmenu(array('sq_dashboard',
332
  ucfirst(_SQ_NAME_) . __(' Support', _SQ_PLUGIN_NAME_),
336
  array(SQ_Classes_ObjController::getClass('SQ_Core_BlockCustomerService'), 'init')
337
  ));
338
 
339
+ if ($menu['show_affiliate']) {
340
+ $this->model->addSubmenu(array('sq_dashboard',
341
+ __('Become an Affiliate with ', _SQ_PLUGIN_NAME_) . ucfirst(_SQ_NAME_),
342
+ __('Become an Affiliate', _SQ_PLUGIN_NAME_),
343
+ 'edit_posts',
344
+ 'sq_affiliate',
345
+ array(SQ_Classes_ObjController::getClass('SQ_Core_BlockAffiliate'), 'init')
346
+ ));
347
+ }
348
 
349
  if (current_user_can('manage_options')) {
350
  $this->model->addSubmenu(array('sq_dashboard',
351
+ __('Import, Backup & Restore SEO', _SQ_PLUGIN_NAME_),
352
+ __('Import/Backup SEO', _SQ_PLUGIN_NAME_),
353
  'edit_posts',
354
  'sq_import',
355
  array(SQ_Classes_ObjController::getClass('SQ_Core_BlockImport'), 'init')
356
  ));
357
  }
358
 
 
 
 
 
 
 
 
 
 
 
 
 
359
  //Add the Rank in the Posts list
360
  $postlist = SQ_Classes_ObjController::getClass('SQ_Controllers_PostsList');
361
  if (is_object($postlist)) {
362
  $postlist->init();
363
  }
364
 
 
365
  }
366
 
367
  /**
368
  * Add Post Editor Meta Box
369
  */
370
  public function addMetabox() {
371
+ //Move the Box is gutenberg is active
372
+ if(!empty($this->post_type)) {
373
+ foreach ($this->post_type as $type) {
374
+ if ($metabox = unserialize(SQ_Classes_Tools::getUserMeta('meta-box-order_' . $type))) {
375
+ extract($metabox);
376
+
377
+ if (isset($side) && isset($normal)) {
378
+ $side = explode(',', $side);
379
+ $normal = explode(',', $normal);
380
+ if (SQ_Classes_Tools::isGutenberg() && !in_array('post' . _SQ_NAME_, $normal)) {
381
+ $normal = array_merge(array('post' . _SQ_NAME_), $normal);
382
+ $metabox['normal'] = join(',', array_unique($normal));
383
+
384
+ $side = array_diff($side, array('post' . _SQ_NAME_));
385
+ $metabox['side'] = join(',', array_unique($side));
386
+ SQ_Classes_Tools::saveUserMeta('meta-box-order_' . $type, $metabox);
387
+
388
+ } elseif (!SQ_Classes_Tools::isGutenberg() && in_array('post' . _SQ_NAME_, $normal)) {
389
+ $side = array_merge(array('post' . _SQ_NAME_), $side);
390
+ $metabox['side'] = join(',', array_unique($side));
391
+
392
+ $normal = array_diff($normal, array('post' . _SQ_NAME_));
393
+ $metabox['normal'] = join(',', array_unique($normal));
394
+ SQ_Classes_Tools::saveUserMeta('meta-box-order_' . $type, $metabox);
395
+ }
396
+ }
397
+ }
398
+
399
+ $this->model->addMeta(array('post' . _SQ_NAME_,
400
+ ucfirst(_SQ_NAME_),
401
+ array(SQ_Classes_ObjController::getClass('SQ_Controllers_Post'), 'init'),
402
+ $type,
403
+ (SQ_Classes_Tools::isGutenberg() ? 'normal' : 'side'),
404
+ 'high'
405
+ ));
406
+ }
407
+ }
408
+
409
  }
410
 
411
  /**
controllers/Post.php CHANGED
@@ -4,28 +4,41 @@ class SQ_Controllers_Post extends SQ_Classes_FrontController {
4
 
5
  public $saved;
6
 
 
 
 
 
 
7
  /**
8
- * Initialize the TinyMCE editor for the current use
9
- *
10
- * @return void
11
  */
12
- public function hookInit() {
13
- $this->saved = array();
14
-
15
- add_filter('tiny_mce_before_init', array($this->model, 'setCallback'));
16
- add_filter('mce_external_plugins', array($this->model, 'addHeadingButton'));
17
- add_filter('mce_buttons', array($this->model, 'registerButton'));
18
-
19
  if (SQ_Classes_Tools::getOption('sq_api') == '')
20
  return;
21
 
22
- add_action('save_post', array($this, 'hookSavePost'), 99, 1);
23
- add_action('shopp_product_saved', array($this, 'hookShopp'), 11, 1);
24
- add_action('edit_attachment', array($this, 'checkSeo'), 99, 1);
 
 
25
 
26
  if (SQ_Classes_Tools::getOption('sq_use') && SQ_Classes_Tools::getOption('sq_auto_sitemap')) {
27
  add_action('transition_post_status', array(SQ_Classes_ObjController::getClass('SQ_Controllers_Sitemaps'), 'refreshSitemap'), 9999, 3);
28
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  }
30
 
31
  /**
@@ -54,90 +67,49 @@ class SQ_Controllers_Post extends SQ_Classes_FrontController {
54
  echo '<script type="text/javascript">(function($) {$.sq_tinymce = { callback: function () {}, setup: function(ed){} } })(jQuery);</script>';
55
  }
56
 
57
- /**
58
- * Hook the Shopp plugin save product
59
- */
60
- public function hookShopp($product) {
61
- $this->checkSeo($product->id);
62
- }
63
 
64
  /**
65
- * Hook the post save/update
66
- * @param type $post_id
 
 
67
  */
68
- public function hookSavePost($post_id) {
69
-
70
- if (!isset($this->saved[$post_id])) {
71
- $this->saved[$post_id] = false;
72
  }
73
 
74
- // unhook this function so it doesn't loop infinitely
75
- remove_action('save_post', array($this, 'hookSavePost'), 99);
76
-
77
- //If the post is a new or edited post
78
- if ((SQ_Classes_Tools::getValue('action')) == 'editpost' &&
79
- wp_is_post_autosave($post_id) == '' &&
80
- get_post_status($post_id) != 'auto-draft' &&
81
- get_post_status($post_id) != 'inherit' &&
82
- SQ_Classes_Tools::getValue('autosave') == ''
83
- ) {
84
-
85
- if ($this->saved[$post_id] === false) {
86
- //check the SEO from Squirrly Live Assistant
87
- $this->checkSeo($post_id, get_post_status($post_id));
88
- //check the remote images
89
- $this->checkImage($post_id);
90
- //check sq mark remained
91
- $this->removeHighlight($post_id);
92
- }
93
- $this->saved[$post_id] = true;
94
- }
95
-
96
-
97
- add_action('save_post', array($this, 'hookSavePost'), 99);
98
- }
99
-
100
- /**
101
- * Remove the Squirrly Highlights in case there are some left
102
- * @param $post_id
103
- */
104
- public function removeHighlight($post_id) {
105
- $content = SQ_Classes_Tools::getValue('post_content', '', true); //get the content in html format
106
-
107
- if (strpos($content, '<mark') !== false) {
108
- $content = preg_replace('/<mark[^>]*data-markjs="true"[^>]*>([^<]*)<\/mark>/i', '$1', $content);
109
- wp_update_post(array(
110
- 'ID' => $post_id,
111
- 'post_content' => $content)
112
- );
113
  }
 
114
  }
115
 
116
  /**
117
  * Check if the image is a remote image and save it locally
118
  *
119
- * @param integer $post_id
120
- * @return false|void
 
121
  */
122
- public function checkImage($post_id) {
 
 
 
 
 
123
 
124
  //if the option to save the images locally is set on
125
  if (SQ_Classes_Tools::getOption('sq_local_images')) {
126
-
127
  @set_time_limit(90);
128
- $local_file = false;
129
 
130
- $content = SQ_Classes_Tools::getValue('post_content', '', true); //get the content in html format
131
- $tmpcontent = trim(html_entity_decode($content), "\n");
132
  $urls = array();
133
-
134
  if (function_exists('preg_match_all')) {
 
135
 
136
- @preg_match_all('/<img[^>]*src=[\'"]([^\'"]+)[\'"][^>]*>/i', $tmpcontent, $out);
137
- if (is_array($out)) {
138
-
139
  if (!is_array($out[1]) || count($out[1]) == 0)
140
- return;
141
 
142
  if (get_bloginfo('wpurl') <> '') {
143
  $domain = parse_url(get_bloginfo('wpurl'));
@@ -155,8 +127,9 @@ class SQ_Controllers_Post extends SQ_Classes_FrontController {
155
  }
156
  }
157
 
158
- if (!is_array($urls) || (is_array($urls) && count($urls) == 0))
159
- return;
 
160
 
161
  $urls = @array_unique($urls);
162
 
@@ -168,16 +141,16 @@ class SQ_Controllers_Post extends SQ_Classes_FrontController {
168
 
169
  $local_file = $file['url'];
170
  if ($local_file !== false) {
171
- $content = str_replace($url, $local_file, $content);
172
 
173
- if (!$this->model->findAttachmentByUrl(basename($url))) {
174
  $attach_id = wp_insert_attachment(array(
175
  'post_mime_type' => $file['type'],
176
  'post_title' => SQ_Classes_Tools::getValue('sq_keyword', preg_replace('/\.[^.]+$/', '', $file['filename'])),
177
  'post_content' => '',
178
  'post_status' => 'inherit',
179
  'guid' => $local_file
180
- ), $file['file'], $post_id);
181
 
182
  $attach_data = wp_generate_attachment_metadata($attach_id, $file['file']);
183
  wp_update_attachment_metadata($attach_id, $attach_data);
@@ -186,44 +159,43 @@ class SQ_Controllers_Post extends SQ_Classes_FrontController {
186
  }
187
 
188
  if (microtime(true) - $time >= 20) {
189
- break;
190
  }
191
 
192
  }
193
 
194
 
195
- if ($local_file !== false) {
196
- wp_update_post(array(
197
- 'ID' => $post_id,
198
- 'post_content' => $content)
199
- );
200
- }
201
  }
 
 
202
  }
203
 
204
 
205
  /**
206
  * Check the SEO from Squirrly Live Assistant
207
  *
208
- * @param integer $post_id
209
- * @param void
 
210
  */
211
- public function checkSeo($post_id, $status = '') {
 
 
 
 
212
  $args = array();
213
 
214
- $seo = SQ_Classes_Tools::getValue('sq_seo');
215
 
216
  if (is_array($seo) && count($seo) > 0)
217
  $args['seo'] = implode(',', $seo);
218
 
219
- $args['keyword'] = SQ_Classes_Tools::getValue('sq_keyword');
220
-
221
- $args['status'] = $status;
222
- $args['permalink'] = get_permalink($post_id);
223
- $args['permalink'] = $this->getPaged($args['permalink']);
224
- $args['author'] = (int)SQ_Classes_Tools::getUserID();
225
- $args['post_id'] = $post_id;
226
 
 
 
 
 
227
 
228
  if (SQ_Classes_Tools::getOption('sq_force_savepost')) {
229
  SQ_Classes_Action::apiCall('sq/seo/post', $args, 10);
@@ -240,33 +212,26 @@ class SQ_Controllers_Post extends SQ_Classes_FrontController {
240
  wp_schedule_single_event(time(), 'sq_processApi');
241
 
242
  //If the queue is too big ... means that the cron is not working
243
- if(count($process) > 5){
244
- SQ_Classes_Tools::saveOptions('sq_force_savepost',1);
245
- }
246
  }
247
 
248
  //Save the keyword for this post
249
- if ($json = $this->model->getKeyword($post_id)) {
250
  $json->keyword = addslashes(SQ_Classes_Tools::getValue('sq_keyword'));
251
- $this->model->saveKeyword($post_id, $json);
252
  } else {
253
  $args = array();
254
  $args['keyword'] = addslashes(SQ_Classes_Tools::getValue('sq_keyword'));
255
- $this->model->saveKeyword($post_id, json_decode(json_encode($args)));
256
  }
257
 
258
  //Save the snippet in case is edited in backend and not saved
259
  SQ_Classes_ObjController::getClass('SQ_Controllers_FrontMenu')->saveSEO();
 
260
  //check for custom SEO
261
- $this->_checkBriefcaseKeywords($post_id);
262
- }
263
 
264
- public function getPaged($link) {
265
- $page = (int)get_query_var('paged');
266
- if ($page && $page > 1) {
267
- $link = trailingslashit($link) . "page/" . "$page" . '/';
268
- }
269
- return $link;
270
  }
271
 
272
  /**
4
 
5
  public $saved;
6
 
7
+ public function init() {
8
+ parent::init();
9
+ SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('post');
10
+ }
11
+
12
  /**
13
+ * Hook the post save
 
 
14
  */
15
+ public function hookPost() {
 
 
 
 
 
 
16
  if (SQ_Classes_Tools::getOption('sq_api') == '')
17
  return;
18
 
19
+ //Hook and save the Snippet and Keywords
20
+ add_action('wp_insert_attachment_data', array($this, 'checkSeo'), 11, 2);
21
+ add_filter('wp_insert_post_data', array($this, 'checkSeo'), 11, 2);
22
+ add_filter('wp_insert_post_data', array($this, 'removeHighlight'), 12, 2);
23
+ add_filter('wp_insert_post_data', array($this, 'checkImage'), 13, 2);
24
 
25
  if (SQ_Classes_Tools::getOption('sq_use') && SQ_Classes_Tools::getOption('sq_auto_sitemap')) {
26
  add_action('transition_post_status', array(SQ_Classes_ObjController::getClass('SQ_Controllers_Sitemaps'), 'refreshSitemap'), 9999, 3);
27
  }
28
+
29
+ }
30
+
31
+ /**
32
+ * Initialize the TinyMCE editor for the current use
33
+ *
34
+ * @return void
35
+ */
36
+ public function hookEditor() {
37
+ $this->saved = array();
38
+
39
+ //Add the H2 icon on visual editor
40
+ add_filter('mce_external_plugins', array($this->model, 'addHeadingButton'));
41
+ add_filter('mce_buttons', array($this->model, 'registerButton'));
42
  }
43
 
44
  /**
67
  echo '<script type="text/javascript">(function($) {$.sq_tinymce = { callback: function () {}, setup: function(ed){} } })(jQuery);</script>';
68
  }
69
 
 
 
 
 
 
 
70
 
71
  /**
72
+ * Remove the Squirrly Highlights in case there are some left
73
+ * @param array $post_data
74
+ * @param array $postarr
75
+ * @return array
76
  */
77
+ public function removeHighlight($post_data, $postarr) {
78
+ if (!isset($post_data['post_content']) || !isset($postarr['ID'])) {
79
+ return $post_data;
 
80
  }
81
 
82
+ if (strpos($post_data['post_content'], '<mark') !== false) {
83
+ $post_data['post_content'] = preg_replace('/<mark[^>]*(data-markjs|mark_counter)[^>]*>([^<]*)<\/mark>/i', '$2', $post_data['post_content']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  }
85
+ return $post_data;
86
  }
87
 
88
  /**
89
  * Check if the image is a remote image and save it locally
90
  *
91
+ * @param array $post_data
92
+ * @param array $postarr
93
+ * @return array
94
  */
95
+ public function checkImage($post_data, $postarr) {
96
+ if (!isset($post_data['post_content']) || !isset($postarr['ID'])) {
97
+ return $post_data;
98
+ }
99
+
100
+ require_once( ABSPATH . 'wp-admin/includes/image.php' );
101
 
102
  //if the option to save the images locally is set on
103
  if (SQ_Classes_Tools::getOption('sq_local_images')) {
 
104
  @set_time_limit(90);
 
105
 
 
 
106
  $urls = array();
 
107
  if (function_exists('preg_match_all')) {
108
+ @preg_match_all('/<img[^>]*src=[\'"]([^\'"]+)[\'"][^>]*>/i', stripslashes($post_data['post_content']), $out);
109
 
110
+ if (!empty($out)) {
 
 
111
  if (!is_array($out[1]) || count($out[1]) == 0)
112
+ return $post_data;
113
 
114
  if (get_bloginfo('wpurl') <> '') {
115
  $domain = parse_url(get_bloginfo('wpurl'));
127
  }
128
  }
129
 
130
+ if (!is_array($urls) || (is_array($urls) && count($urls) == 0)) {
131
+ return $post_data;
132
+ }
133
 
134
  $urls = @array_unique($urls);
135
 
141
 
142
  $local_file = $file['url'];
143
  if ($local_file !== false) {
144
+ $post_data['post_content'] = str_replace($url, $local_file, $post_data['post_content']);
145
 
146
+ if (!$this->model->findAttachmentByUrl($local_file)) {
147
  $attach_id = wp_insert_attachment(array(
148
  'post_mime_type' => $file['type'],
149
  'post_title' => SQ_Classes_Tools::getValue('sq_keyword', preg_replace('/\.[^.]+$/', '', $file['filename'])),
150
  'post_content' => '',
151
  'post_status' => 'inherit',
152
  'guid' => $local_file
153
+ ), $file['file'], $postarr['ID']);
154
 
155
  $attach_data = wp_generate_attachment_metadata($attach_id, $file['file']);
156
  wp_update_attachment_metadata($attach_id, $attach_data);
159
  }
160
 
161
  if (microtime(true) - $time >= 20) {
162
+ return $post_data;
163
  }
164
 
165
  }
166
 
167
 
 
 
 
 
 
 
168
  }
169
+
170
+ return $post_data;
171
  }
172
 
173
 
174
  /**
175
  * Check the SEO from Squirrly Live Assistant
176
  *
177
+ * @param array $post_data
178
+ * @param array $postarr
179
+ * @return array
180
  */
181
+ public function checkSeo($post_data, $postarr) {
182
+ if (!isset($post_data['post_content']) || !isset($postarr['ID'])) {
183
+ return $post_data;
184
+ }
185
+
186
  $args = array();
187
 
188
+ $seo = SQ_Classes_Tools::getValue('sq_seo', '');
189
 
190
  if (is_array($seo) && count($seo) > 0)
191
  $args['seo'] = implode(',', $seo);
192
 
193
+ $args['keyword'] = SQ_Classes_Tools::getValue('sq_keyword', '');
 
 
 
 
 
 
194
 
195
+ $args['status'] = $post_data['post_status'];
196
+ $args['permalink'] = get_permalink($postarr['ID']);
197
+ $args['author'] = $post_data['post_author'];
198
+ $args['post_id'] = $postarr['ID'];
199
 
200
  if (SQ_Classes_Tools::getOption('sq_force_savepost')) {
201
  SQ_Classes_Action::apiCall('sq/seo/post', $args, 10);
212
  wp_schedule_single_event(time(), 'sq_processApi');
213
 
214
  //If the queue is too big ... means that the cron is not working
215
+ if (count($process) > 5) SQ_Classes_Tools::saveOptions('sq_force_savepost', 1);
 
 
216
  }
217
 
218
  //Save the keyword for this post
219
+ if ($json = $this->model->getKeyword($postarr['ID'])) {
220
  $json->keyword = addslashes(SQ_Classes_Tools::getValue('sq_keyword'));
221
+ $this->model->saveKeyword($postarr['ID'], $json);
222
  } else {
223
  $args = array();
224
  $args['keyword'] = addslashes(SQ_Classes_Tools::getValue('sq_keyword'));
225
+ $this->model->saveKeyword($postarr['ID'], json_decode(json_encode($args)));
226
  }
227
 
228
  //Save the snippet in case is edited in backend and not saved
229
  SQ_Classes_ObjController::getClass('SQ_Controllers_FrontMenu')->saveSEO();
230
+
231
  //check for custom SEO
232
+ $this->_checkBriefcaseKeywords($postarr['ID']);
 
233
 
234
+ return $post_data;
 
 
 
 
 
235
  }
236
 
237
  /**
controllers/SerpChecker.php CHANGED
@@ -39,8 +39,7 @@ class SQ_Controllers_SerpChecker extends SQ_Classes_FrontController {
39
  $this->_tabs['keywords'] = 'Top Keywords';
40
  $this->_tab = SQ_Classes_Tools::getValue('tab', false);
41
 
42
- SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('//storage.googleapis.com/squirrly/wp480/js/bootstrap.min.js');
43
- SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('//storage.googleapis.com/squirrly/wp480/css/bootstrap.min.css');
44
  SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('serpchecker');
45
 
46
  if ($this->_tab <> '') {
@@ -305,7 +304,8 @@ class SQ_Controllers_SerpChecker extends SQ_Classes_FrontController {
305
  /**
306
  * Get all ranks from API Server
307
  */
308
- public function getAllRanks($paged = 1, $per_page = 100, $loop = true, $cnt = 0) {
 
309
  $args = array('paged' => $paged, 'per_page' => $per_page);
310
  set_transient('sq_progress', $paged, 60);
311
 
@@ -313,24 +313,46 @@ class SQ_Controllers_SerpChecker extends SQ_Classes_FrontController {
313
  if (isset($json->ranks)) {
314
  if (!empty($json->ranks)) {
315
  foreach ($json->ranks as $post_id => $rank) {
316
- $status = get_post_status($post_id);
317
- if ($status <> 'publish') {
318
- $args = array();
319
- $args['status'] = ($status ? $status : 'deleted');
320
- $args['post_id'] = $post_id;
321
- //Make sure the API has the correct status of the post
322
- SQ_Classes_Action::apiCall('sq/seo/update', $args, 10);
323
-
324
- //delete the records for this post to insert all the keywords fresh
325
- $this->model->purgeMeta($post_id, array('key' => '_src_keyword'));
326
- continue;
 
 
 
 
 
 
 
327
  } else {
328
- $this->model->saveKeyword($post_id, $rank);
329
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
  }
331
  }
332
- } else {
333
- SQ_Classes_ObjController::getClass('SQ_Models_SerpChecker')->purgeAllMeta(array('key' => '_src_keyword'));
334
  }
335
  }
336
 
39
  $this->_tabs['keywords'] = 'Top Keywords';
40
  $this->_tab = SQ_Classes_Tools::getValue('tab', false);
41
 
42
+ SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap');
 
43
  SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('serpchecker');
44
 
45
  if ($this->_tab <> '') {
304
  /**
305
  * Get all ranks from API Server
306
  */
307
+ public function getAllRanks($paged = 1, $per_page = 20, $loop = true, $cnt = 0) {
308
+ set_time_limit(90);
309
  $args = array('paged' => $paged, 'per_page' => $per_page);
310
  set_transient('sq_progress', $paged, 60);
311
 
313
  if (isset($json->ranks)) {
314
  if (!empty($json->ranks)) {
315
  foreach ($json->ranks as $post_id => $rank) {
316
+ if ($post_id == 0) {
317
+ foreach ($rank as $row) {
318
+ if($post_id = url_to_postid($row->permalink)) {
319
+ $status = get_post_status($post_id);
320
+ if ($status <> 'publish') {
321
+ //delete the records for this post to insert all the keywords fresh
322
+ $this->model->purgeMeta($post_id, array('key' => '_src_keyword'));
323
+ continue;
324
+ } else {
325
+ $this->model->saveKeyword($post_id, $rank);
326
+ }
327
+ }
328
+ //prevent timeout
329
+ if(number_format(microtime(true) - REQUEST_TIME, 0) >= 30){
330
+ $loop = false;
331
+ break;
332
+ }
333
+ }
334
  } else {
335
+ $status = get_post_status($post_id);
336
+ if ($status <> 'publish') {
337
+ $args = array();
338
+ $args['status'] = ($status ? $status : 'deleted');
339
+ $args['post_id'] = $post_id;
340
+ //Make sure the API has the correct status of the post
341
+ SQ_Classes_Action::apiCall('sq/seo/update', $args, 10);
342
+
343
+ //delete the records for this post to insert all the keywords fresh
344
+ $this->model->purgeMeta($post_id, array('key' => '_src_keyword'));
345
+ continue;
346
+ } else {
347
+ $this->model->saveKeyword($post_id, $rank);
348
+ }
349
+ }
350
+ //prevent timeout
351
+ if(number_format(microtime(true) - REQUEST_TIME, 30) >= 85){
352
+ $loop = false;
353
+ break;
354
  }
355
  }
 
 
356
  }
357
  }
358
 
controllers/Sitemaps.php CHANGED
@@ -14,9 +14,11 @@ class SQ_Controllers_Sitemaps extends SQ_Classes_FrontController {
14
  public function __construct() {
15
  parent::__construct();
16
  $this->posts_limit = SQ_Classes_Tools::getOption('sq_sitemap_perpage');
 
17
  add_filter('template_redirect', array($this, 'hookPreventRedirect'), 0);
18
  add_filter('user_trailingslashit', array($this, 'untrailingslashit'));
19
  add_action('sq_processPing', array($this, 'processCron'));
 
20
  }
21
 
22
  public function hookPreventRedirect() {
@@ -134,12 +136,16 @@ class SQ_Controllers_Sitemaps extends SQ_Classes_FrontController {
134
  case 'sitemap-page':
135
  $sq_query['post_type'] = array('page');
136
  break;
 
 
 
 
137
  case 'sitemap-author':
138
  add_filter('sq-sitemap-authors', array($this, 'authorFilter'), 5);
139
  break;
140
  case 'sitemap-custom-post':
141
  $types = get_post_types();
142
- foreach (array('post', 'page', 'attachment', 'revision', 'nav_menu_item', 'product', 'wpsc-product') as $exclude) {
143
  if (in_array($exclude, $types)) {
144
  unset($types[$exclude]);
145
  }
@@ -174,6 +180,10 @@ class SQ_Controllers_Sitemaps extends SQ_Classes_FrontController {
174
 
175
  }
176
 
 
 
 
 
177
  /**
178
  * Show the Sitemap Header
179
  * @param array $include Include schema
@@ -185,7 +195,7 @@ class SQ_Controllers_Sitemaps extends SQ_Classes_FrontController {
185
  header('Content-Type: text/xml; charset=' . get_bloginfo('charset'), true);
186
  //Generate header
187
  echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>' . "\n";
188
- echo '<?xml-stylesheet type="text/xsl" href="/' . _SQ_THEME_RELATIVE_URL_ . 'css/sitemap' . ($this->model->type == 'sitemap' ? 'index' : '') . '.xsl"?>' . "\n";
189
  echo '<!-- generated-on="' . date('Y-m-d\TH:i:s+00:00') . '" -->' . "\n";
190
  echo '<!-- generator="Squirrly SEO Sitemap" -->' . "\n";
191
  echo '<!-- generator-url="https://wordpress.org/plugins/squirrly-seo/" -->' . "\n";
@@ -320,7 +330,9 @@ class SQ_Controllers_Sitemaps extends SQ_Classes_FrontController {
320
  case 'sitemap-archive':
321
  $this->showPackXml($this->model->getListArchive());
322
  break;
323
-
 
 
324
  default:
325
  $this->showPackXml($this->model->getListPosts());
326
  break;
@@ -490,13 +502,21 @@ class SQ_Controllers_Sitemaps extends SQ_Classes_FrontController {
490
  $query->set('tax_query', array());
491
  }
492
 
493
- public function customTaxFilter($query) {
 
 
 
 
 
 
494
  global $wpdb;
495
-
496
  $query[] = "(SELECT
497
  UNIX_TIMESTAMP(MAX(p.post_date_gmt)) as _mod_date
498
  FROM {$wpdb->posts} p, {$wpdb->term_relationships} r
499
- WHERE p.ID = r.object_id AND p.post_status = 'publish' AND p.post_password = '' AND r.term_taxonomy_id = tt.term_taxonomy_id
 
 
 
500
  ) as lastmod";
501
 
502
  return $query;
14
  public function __construct() {
15
  parent::__construct();
16
  $this->posts_limit = SQ_Classes_Tools::getOption('sq_sitemap_perpage');
17
+ add_filter('sq_sitemap_style', array($this, 'getFeedStyle'));
18
  add_filter('template_redirect', array($this, 'hookPreventRedirect'), 0);
19
  add_filter('user_trailingslashit', array($this, 'untrailingslashit'));
20
  add_action('sq_processPing', array($this, 'processCron'));
21
+
22
  }
23
 
24
  public function hookPreventRedirect() {
136
  case 'sitemap-page':
137
  $sq_query['post_type'] = array('page');
138
  break;
139
+ case 'sitemap-attachment':
140
+ $sq_query['post_type'] = array('attachment');
141
+ $sq_query['post_status'] = array('publish', 'inherit');
142
+ break;
143
  case 'sitemap-author':
144
  add_filter('sq-sitemap-authors', array($this, 'authorFilter'), 5);
145
  break;
146
  case 'sitemap-custom-post':
147
  $types = get_post_types();
148
+ foreach (array('post', 'page', 'attachment', 'revision', 'nav_menu_item', 'product', 'wpsc-product', 'ngg_tag') as $exclude) {
149
  if (in_array($exclude, $types)) {
150
  unset($types[$exclude]);
151
  }
180
 
181
  }
182
 
183
+ public function getFeedStyle() {
184
+ return '<?xml-stylesheet type="text/xsl" href="/' . _SQ_THEME_RELATIVE_URL_ . 'css/sitemap' . ($this->model->type == 'sitemap' ? 'index' : '') . '.xsl"?>' . "\n";
185
+ }
186
+
187
  /**
188
  * Show the Sitemap Header
189
  * @param array $include Include schema
195
  header('Content-Type: text/xml; charset=' . get_bloginfo('charset'), true);
196
  //Generate header
197
  echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>' . "\n";
198
+ echo apply_filters('sq_sitemap_style', false);
199
  echo '<!-- generated-on="' . date('Y-m-d\TH:i:s+00:00') . '" -->' . "\n";
200
  echo '<!-- generator="Squirrly SEO Sitemap" -->' . "\n";
201
  echo '<!-- generator-url="https://wordpress.org/plugins/squirrly-seo/" -->' . "\n";
330
  case 'sitemap-archive':
331
  $this->showPackXml($this->model->getListArchive());
332
  break;
333
+ case 'sitemap-attachment':
334
+ $this->showPackXml($this->model->getListAttachments());
335
+ break;
336
  default:
337
  $this->showPackXml($this->model->getListPosts());
338
  break;
502
  $query->set('tax_query', array());
503
  }
504
 
505
+ /**
506
+ * Filter the Custom Taxonomy
507
+ * @param $query
508
+ * @param $args
509
+ * @return array
510
+ */
511
+ public function customTaxFilter($query, $args) {
512
  global $wpdb;
 
513
  $query[] = "(SELECT
514
  UNIX_TIMESTAMP(MAX(p.post_date_gmt)) as _mod_date
515
  FROM {$wpdb->posts} p, {$wpdb->term_relationships} r
516
+ WHERE p.ID = r.object_id
517
+ AND p.post_status = 'publish'
518
+ AND p.post_password = ''
519
+ AND r.term_taxonomy_id = tt.term_taxonomy_id
520
  ) as lastmod";
521
 
522
  return $query;
core/BlockBriefcaseKeywords.php CHANGED
@@ -21,6 +21,8 @@ class SQ_Core_BlockBriefcaseKeywords extends SQ_Classes_BlockController {
21
  SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('serpchecker.css');
22
  SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('switchery');
23
 
 
 
24
  //Not yet available
25
  if (SQ_Classes_Tools::getOption('sq_google_serp_active') == 0) {
26
  $this->checkin = json_decode(SQ_Classes_Action::apiCall('sq/rank-checker/checkin'));
@@ -33,7 +35,9 @@ class SQ_Core_BlockBriefcaseKeywords extends SQ_Classes_BlockController {
33
  SQ_Classes_Tools::saveOptions('sq_google_serp_active', 1);
34
  SQ_Classes_ObjController::getClass('SQ_Classes_Error')->setError(sprintf(__('%sYou activated the Business Plan with Advanced Analytics. %sStart Here%s %s'), '<strong style="font-size: 16px;">', '<a href="' . admin_url('admin.php?page=sq_posts') . '">', '</a>', '</strong>'), 'success');
35
  } elseif (isset($this->checkin->error) && $this->checkin->error == "subscription_notfound" && !SQ_Classes_Tools::getOption('sq_google_serp_active')) {
36
- SQ_Classes_ObjController::getClass('SQ_Classes_Error')->setError(sprintf(__('%sStart a FREE Trial of the Business Plan with Advanced Analytics for 7 days. No credit card required. %sSee details%s %s'), '<strong style="font-size: 16px;">', '<a href="' . _SQ_DASH_URL_ . 'login/?token=' . SQ_Classes_Tools::getOption('sq_api') . '&redirect_to=' . _SQ_DASH_URL_ . 'user/plans?pid=31" target="_blank">', '</a>', '</strong>'), 'trial');
 
 
37
  }
38
  }
39
 
@@ -61,17 +65,21 @@ class SQ_Core_BlockBriefcaseKeywords extends SQ_Classes_BlockController {
61
  ));
62
 
63
  $this->index = (($paged - 1) * $per_page);
64
- $this->labels = $json->labels;
65
  $this->keywords = $json->keywords;
66
- $this->countries = $json->countries;
67
  } else {
68
  $this->error = __('No keyword found in the briefcase.', _SQ_PLUGIN_NAME_);
69
  }
70
 
 
 
 
 
 
 
 
71
  wp_enqueue_style('wp-color-picker');
72
  wp_enqueue_script('wp-color-picker');
73
- SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('//storage.googleapis.com/squirrly/wp480/js/bootstrap.min.js');
74
- SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('//storage.googleapis.com/squirrly/wp480/css/bootstrap.min.css');
75
  SQ_Classes_ObjController::getClass('SQ_Classes_Error')->hookNotices();
76
 
77
  return parent::init();
21
  SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('serpchecker.css');
22
  SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('switchery');
23
 
24
+ $menu = SQ_Classes_Tools::getOption('menu');
25
+
26
  //Not yet available
27
  if (SQ_Classes_Tools::getOption('sq_google_serp_active') == 0) {
28
  $this->checkin = json_decode(SQ_Classes_Action::apiCall('sq/rank-checker/checkin'));
35
  SQ_Classes_Tools::saveOptions('sq_google_serp_active', 1);
36
  SQ_Classes_ObjController::getClass('SQ_Classes_Error')->setError(sprintf(__('%sYou activated the Business Plan with Advanced Analytics. %sStart Here%s %s'), '<strong style="font-size: 16px;">', '<a href="' . admin_url('admin.php?page=sq_posts') . '">', '</a>', '</strong>'), 'success');
37
  } elseif (isset($this->checkin->error) && $this->checkin->error == "subscription_notfound" && !SQ_Classes_Tools::getOption('sq_google_serp_active')) {
38
+ if ($menu['show_ads']) {
39
+ SQ_Classes_ObjController::getClass('SQ_Classes_Error')->setError(sprintf(__('%sStart a FREE Trial of the Business Plan with Advanced Analytics for 7 days. No credit card required. %sSee details%s %s'), '<strong style="font-size: 16px;">', '<a href="' . _SQ_DASH_URL_ . 'login/?token=' . SQ_Classes_Tools::getToken(). '&redirect_to=' . _SQ_DASH_URL_ . 'user/plans?pid=31" target="_blank">', '</a>', '</strong>'), 'trial');
40
+ }
41
  }
42
  }
43
 
65
  ));
66
 
67
  $this->index = (($paged - 1) * $per_page);
 
68
  $this->keywords = $json->keywords;
 
69
  } else {
70
  $this->error = __('No keyword found in the briefcase.', _SQ_PLUGIN_NAME_);
71
  }
72
 
73
+ if (isset($json->labels)) {
74
+ $this->labels = $json->labels;
75
+ }
76
+ if (isset($json->countries)) {
77
+ $this->countries = $json->countries;
78
+ }
79
+
80
  wp_enqueue_style('wp-color-picker');
81
  wp_enqueue_script('wp-color-picker');
82
+ SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia('bootstrap');
 
83
  SQ_Classes_ObjController::getClass('SQ_Classes_Error')->hookNotices();
84
 
85
  return parent::init();
core/BlockImport.php CHANGED
@@ -6,11 +6,13 @@
6
  class SQ_Core_BlockImport extends SQ_Classes_BlockController {
7
 
8
  function hookGetContent() {
9
- //Remove the notification is Inport Settings are shown
10
- delete_transient('sq_import');
 
11
 
12
- parent::preloadSettings();
13
- SQ_Classes_ObjController::getClass('SQ_Classes_Error')->hookNotices();
 
14
  }
15
 
16
  /**
6
  class SQ_Core_BlockImport extends SQ_Classes_BlockController {
7
 
8
  function hookGetContent() {
9
+ if(SQ_Classes_Tools::getOption('sq_api') <> '') {
10
+ //Remove the notification is Inport Settings are shown
11
+ delete_transient('sq_import');
12
 
13
+ parent::preloadSettings();
14
+ SQ_Classes_ObjController::getClass('SQ_Classes_Error')->hookNotices();
15
+ }
16
  }
17
 
18
  /**
core/BlockPostsAnalytics.php CHANGED
@@ -17,13 +17,16 @@ class SQ_Core_BlockPostsAnalytics extends SQ_Classes_BlockController {
17
  if (isset($this->checkin->active) && $this->checkin->active) {
18
  if (isset($this->checkin->trial) && $this->checkin->trial) {
19
  SQ_Classes_Tools::saveOptions('sq_google_serp_trial', 1);
20
- }else{
21
  SQ_Classes_Tools::saveOptions('sq_google_serp_trial', 0);
22
  }
23
  SQ_Classes_Tools::saveOptions('sq_google_serp_active', 1);
24
- SQ_Classes_ObjController::getClass('SQ_Classes_Error')->setError(sprintf(__('%sYou activated the Business Plan with Advanced Analytics. %sStart Here%s %s'), '<strong style="font-size: 16px;">', '<a href="' . admin_url('admin.php?page=sq_posts') . '">', '</a>', '</strong>'),'success');
25
  } elseif (isset($this->checkin->error) && $this->checkin->error == "subscription_notfound" && !SQ_Classes_Tools::getOption('sq_google_serp_active')) {
26
- SQ_Classes_ObjController::getClass('SQ_Classes_Error')->setError(sprintf(__('%sStart a FREE Trial of the Business Plan with Advanced Analytics for 7 days. No credit card required. %sSee details%s %s'), '<strong style="font-size: 16px;">', '<a href="' . _SQ_DASH_URL_ . 'login/?token=' . SQ_Classes_Tools::getOption('sq_api') . '&redirect_to=' . _SQ_DASH_URL_ . 'user/plans?pid=31" target="_blank">', '</a>', '</strong>'),'trial');
 
 
 
27
  } elseif (!SQ_Classes_Tools::getOption('sq_google_serp_active')) {
28
  SQ_Classes_ObjController::getClass('SQ_Classes_Error')->setError(sprintf(__('To get back to the Advanced Analytics and see rankings for all the keywords in Briefcase upgrade to %sBusiness Plan%s.'), '<a href="' . SQ_Classes_Tools::getBusinessLink() . '" target="_blank">', '</a>'), 'error');
29