SEO SQUIRRLY™ - Version 3.4.4

Version Description

  • Updated the Twitter Card information
  • Compatible with WP 4.1.1
  • Fixed the SEO Analytics and the Rank updates
  • Fixed the SEO for First Page if the Home Page is not a static page
  • Fixed the SEO for the First Page when it starts with woocommerce shop
Download this release

Release Info

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

Code changes from version 3.1.1 to 3.4.4

Files changed (50) hide show
  1. classes/SQ_Action.php +4 -6
  2. classes/SQ_BlockController.php +2 -2
  3. classes/SQ_DisplayController.php +19 -12
  4. classes/SQ_Error.php +1 -1
  5. classes/SQ_FrontController.php +3 -2
  6. classes/SQ_HookController.php +1 -0
  7. classes/SQ_Ranking.php +94 -42
  8. classes/SQ_Sitemap.php +3 -2
  9. classes/SQ_Tools.php +48 -36
  10. classes/SQ_Traffic.php +0 -18
  11. config/config.php +1 -1
  12. config/paths.php +1 -1
  13. controllers/SQ_Frontend.php +21 -22
  14. controllers/SQ_Menu.php +55 -15
  15. controllers/SQ_Post.php +117 -81
  16. controllers/SQ_PostsList.php +65 -25
  17. core/SQ_BlockPostsAnalytics/SQ_BlockPostsAnalytics.php +1 -0
  18. core/SQ_Blocklogin/SQ_Blocklogin.php +1 -1
  19. core/SQ_Loading/SQ_Loading.php +3 -3
  20. core/config.xml +3 -0
  21. languages/squirrly-seo-ro_RO.mo +0 -0
  22. languages/squirrly-seo-ro_RO.po +1553 -568
  23. models/SQ_BlockPostsAnalytics.php +6 -6
  24. models/SQ_Blocksearch.php +4 -2
  25. models/SQ_Blockseo.php +2 -1
  26. models/SQ_Frontend.php +357 -287
  27. models/SQ_Menu.php +26 -3
  28. models/SQ_Post.php +273 -3
  29. readme.txt +200 -179
  30. squirrly.php +47 -46
  31. themes/default/SQ_BlockAnalytics.php +2 -0
  32. themes/default/SQ_BlockAudit.php +2 -2
  33. themes/default/SQ_BlockDashboard.php +6 -2
  34. themes/default/SQ_BlockHelp.php +22 -1
  35. themes/default/SQ_BlockPostsAnalytics.php +1 -0
  36. themes/default/SQ_BlockSupport.php +8 -8
  37. themes/default/SQ_Blocklogin.php +14 -10
  38. themes/default/SQ_Menu.php +63 -23
  39. themes/default/SQ_notices.php +3 -6
  40. themes/default/css/sq_global.css +1 -1
  41. themes/default/css/sq_menu.css +1 -1
  42. themes/default/css/sq_post.css +1 -1
  43. themes/default/css/sq_postslist.css +1 -1
  44. themes/default/img/sprite.png +0 -0
  45. themes/default/js/sq_blockaudit.js +1 -1
  46. themes/default/js/sq_blocklogin.js +19 -17
  47. themes/default/js/sq_blocksupport.js +12 -14
  48. themes/default/js/sq_menu.js +23 -21
  49. themes/default/js/tinymce.js +1 -1
  50. uninstall.php +2 -1
classes/SQ_Action.php CHANGED
@@ -19,7 +19,7 @@ class SQ_Action extends SQ_FrontController {
19
  public function hookInit() {
20
 
21
  /* Only if ajax */
22
- if ((isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') || strpos($_SERVER['PHP_SELF'], '/admin-ajax.php') !== false) {
23
  $this->actions = array();
24
  $this->getActions(((isset($_GET['action']) ? $_GET['action'] : (isset($_POST['action']) ? $_POST['action'] : ''))));
25
  }
@@ -32,10 +32,7 @@ class SQ_Action extends SQ_FrontController {
32
  */
33
  public function hookMenu() {
34
  /* Only if post */
35
- if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
36
- return;
37
- }
38
- if (strpos($_SERVER['PHP_SELF'], '/admin-ajax.php') !== false) {
39
  return;
40
  }
41
 
@@ -132,9 +129,10 @@ class SQ_Action extends SQ_FrontController {
132
  if (SQ_Tools::$options['sq_api'] == '' && $module <> 'sq/login' && $module <> 'sq/register') {
133
  return false;
134
  }
 
135
 
136
  $extra = array('user_url' => urlencode(get_bloginfo('wpurl')),
137
- 'lang' => WPLANG,
138
  'versq' => SQ_VERSION_ID,
139
  'verwp' => WP_VERSION_ID,
140
  'verphp' => PHP_VERSION_ID,
19
  public function hookInit() {
20
 
21
  /* Only if ajax */
22
+ if (isset($_SERVER['PHP_SELF']) && strpos($_SERVER['PHP_SELF'], '/admin-ajax.php') !== false) {
23
  $this->actions = array();
24
  $this->getActions(((isset($_GET['action']) ? $_GET['action'] : (isset($_POST['action']) ? $_POST['action'] : ''))));
25
  }
32
  */
33
  public function hookMenu() {
34
  /* Only if post */
35
+ if (isset($_SERVER['PHP_SELF']) && strpos($_SERVER['PHP_SELF'], '/admin-ajax.php') !== false) {
 
 
 
36
  return;
37
  }
38
 
129
  if (SQ_Tools::$options['sq_api'] == '' && $module <> 'sq/login' && $module <> 'sq/register') {
130
  return false;
131
  }
132
+ $lang = (defined('WPLANG') ? WPLANG : 'en_US');
133
 
134
  $extra = array('user_url' => urlencode(get_bloginfo('wpurl')),
135
+ 'lang' => $lang,
136
  'versq' => SQ_VERSION_ID,
137
  'verwp' => WP_VERSION_ID,
138
  'verphp' => PHP_VERSION_ID,
classes/SQ_BlockController.php CHANGED
@@ -63,8 +63,8 @@ class SQ_BlockController {
63
  protected function action() {
64
  // check to see if the submitted nonce matches with the
65
  // generated nonce we created
66
- if (class_exists('wp_verify_nonce'))
67
- if (!wp_verify_nonce(SQ_Tools::getValue(_SQ_NONCE_ID_), _SQ_NONCE_ID_))
68
  die('Invalid request!');
69
  }
70
 
63
  protected function action() {
64
  // check to see if the submitted nonce matches with the
65
  // generated nonce we created
66
+ if (function_exists('wp_verify_nonce'))
67
+ if (!wp_verify_nonce(SQ_Tools::getValue('nonce'), _SQ_NONCE_ID_))
68
  die('Invalid request!');
69
  }
70
 
classes/SQ_DisplayController.php CHANGED
@@ -17,17 +17,20 @@ class SQ_DisplayController {
17
  * echo the css link from theme css directory
18
  *
19
  * @param string $uri The name of the css file or the entire uri path of the css file
20
- * @param string $media
21
  *
22
  * @return string
23
  */
24
- public static function loadMedia($uri = '', $media = 'all', $params = null) {
25
- if (strpos($_SERVER['PHP_SELF'], '/admin-ajax.php') !== false || (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER ['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'))
26
  return;
27
 
28
  $css_uri = '';
29
  $js_uri = '';
30
  $local = true;
 
 
 
31
 
32
  if (isset(self::$cache[$uri]))
33
  return;
@@ -53,20 +56,24 @@ class SQ_DisplayController {
53
  }
54
 
55
 
 
56
  if ($css_uri <> '') {
57
- if (wp_style_is($name))
58
- wp_deregister_style($name);
 
59
 
60
- wp_register_style($name, $css_uri, null, SQ_VERSION_ID, 'all');
61
- wp_enqueue_style($name);
 
62
  }
63
 
64
  if ($js_uri <> '') {
65
- if (wp_script_is($name))
66
- wp_deregister_script($name);
67
-
68
- wp_register_script($name, $js_uri);
69
- wp_enqueue_script($name);
 
70
  }
71
  }
72
 
17
  * echo the css link from theme css directory
18
  *
19
  * @param string $uri The name of the css file or the entire uri path of the css file
20
+ * @param string $params : trigger, media
21
  *
22
  * @return string
23
  */
24
+ public static function loadMedia($uri = '', $params = array('trigger' => true, 'media' => 'all')) {
25
+ if (isset($_SERVER['PHP_SELF']) && strpos($_SERVER['PHP_SELF'], '/admin-ajax.php') !== false)
26
  return;
27
 
28
  $css_uri = '';
29
  $js_uri = '';
30
  $local = true;
31
+ if (!isset($params['media'])) {
32
+ $params['media'] = 'all';
33
+ }
34
 
35
  if (isset(self::$cache[$uri]))
36
  return;
56
  }
57
 
58
 
59
+
60
  if ($css_uri <> '') {
61
+ if (!wp_style_is($name)) {
62
+ wp_enqueue_style($name, $css_uri, null, SQ_VERSION_ID, $params['media']);
63
+ }
64
 
65
+ if (isset($params['trigger']) && $params['trigger'] === true) {
66
+ wp_print_styles(array($name));
67
+ }
68
  }
69
 
70
  if ($js_uri <> '') {
71
+ if (!wp_script_is($name)) {
72
+ wp_enqueue_script($name, $js_uri, null, SQ_VERSION_ID);
73
+ }
74
+ if (isset($params['trigger']) && $params['trigger'] === true) {
75
+ wp_print_scripts(array($name));
76
+ }
77
  }
78
  }
79
 
classes/SQ_Error.php CHANGED
@@ -59,7 +59,7 @@ class SQ_Error extends SQ_FrontController {
59
  break;
60
 
61
  /* switch off option for notifications */
62
- self::$switch_off = "<a href=\"javascript:void(0);\" onclick=\"jQuery.post( ajaxurl, {action: 'sq_warnings_off', nonce: '" . wp_create_nonce('sq_none') . "'}, function(data) { if (data) { jQuery('#sq_ignore_warn').attr('checked', true); jQuery('.sq_message').hide(); jQuery('#toplevel_page_squirrly .awaiting-mod').fadeOut('slow'); } });\" >" . __("Turn off warnings!", _SQ_PLUGIN_NAME_) . "</a>";
63
  self::showError(ucfirst(_SQ_PLUGIN_NAME_) . " " . __('Notice: ', _SQ_PLUGIN_NAME_) . $error['text'] . " " . self::$switch_off, $error['id']);
64
  break;
65
  default:
59
  break;
60
 
61
  /* switch off option for notifications */
62
+ self::$switch_off = "<a href=\"javascript:void(0);\" onclick=\"jQuery.post( ajaxurl, {action: 'sq_warnings_off', nonce: '" . wp_create_nonce(_SQ_NONCE_ID_) . "'}, function(data) { if (data) { jQuery('#sq_ignore_warn').attr('checked', true); jQuery('.sq_message').hide(); jQuery('#toplevel_page_squirrly .awaiting-mod').fadeOut('slow'); } });\" >" . __("Turn off warnings!", _SQ_PLUGIN_NAME_) . "</a>";
63
  self::showError(ucfirst(_SQ_PLUGIN_NAME_) . " " . __('Notice: ', _SQ_PLUGIN_NAME_) . $error['text'] . " " . self::$switch_off, $error['id']);
64
  break;
65
  default:
classes/SQ_FrontController.php CHANGED
@@ -106,10 +106,11 @@ class SQ_FrontController {
106
  *
107
  */
108
  protected function action() {
 
109
  // check to see if the submitted nonce matches with the
110
  // generated nonce we created
111
- if (class_exists('wp_verify_nonce'))
112
- if (!wp_verify_nonce(SQ_Tools::getValue(_SQ_NONCE_ID_), _SQ_NONCE_ID_))
113
  die('Invalid request!');
114
  }
115
 
106
  *
107
  */
108
  protected function action() {
109
+
110
  // check to see if the submitted nonce matches with the
111
  // generated nonce we created
112
+ if (function_exists('wp_verify_nonce'))
113
+ if (!wp_verify_nonce(SQ_Tools::getValue('nonce'), _SQ_NONCE_ID_))
114
  die('Invalid request!');
115
  }
116
 
classes/SQ_HookController.php CHANGED
@@ -17,6 +17,7 @@ class SQ_HookController {
17
  'wmenu' => '_admin_menu',
18
  'menu' => 'admin_menu',
19
  'submenu' => 'add_submenu_page',
 
20
  'loaded' => 'plugins_loaded',
21
  'xml' => 'admin_xml_ns',
22
  'scripts' => 'admin_enqueue_scripts',
17
  'wmenu' => '_admin_menu',
18
  'menu' => 'admin_menu',
19
  'submenu' => 'add_submenu_page',
20
+ 'preload' => 'template_redirect',
21
  'loaded' => 'plugins_loaded',
22
  'xml' => 'admin_xml_ns',
23
  'scripts' => 'admin_enqueue_scripts',
classes/SQ_Ranking.php CHANGED
@@ -7,10 +7,23 @@ class SQ_Ranking extends SQ_FrontController {
7
 
8
  private $keyword;
9
  private $post_id;
 
10
 
11
  //--
12
  public function getCountry() {
13
- return SQ_Tools::$options['sq_google_country'];
 
 
 
 
 
 
 
 
 
 
 
 
14
  }
15
 
16
  /**
@@ -18,7 +31,10 @@ class SQ_Ranking extends SQ_FrontController {
18
  * @return type
19
  */
20
  public function getLanguage() {
21
- return SQ_Tools::$options['sq_google_language'];
 
 
 
22
  }
23
 
24
  /**
@@ -43,9 +59,9 @@ class SQ_Ranking extends SQ_FrontController {
43
  */
44
  public function processRanking($post_id, $keyword) {
45
  $this->setPost($post_id);
46
- $this->setKeyword($keyword);
47
 
48
- if (isset($this->keyword)) {
49
  return $this->getGoogleRank();
50
  }
51
  return false;
@@ -62,47 +78,79 @@ class SQ_Ranking extends SQ_FrontController {
62
  */
63
  public function getGoogleRank() {
64
  global $wpdb;
65
- $country = $this->getCountry();
66
 
67
- if (!function_exists('preg_match_all'))
68
- return;
 
 
 
 
 
 
69
 
70
  $arg = array('timeout' => 10);
71
- $arg['q'] = $this->keyword;
72
  $arg['hl'] = $this->getLanguage();
 
 
 
 
 
 
73
  $arg['num'] = '100';
74
- $arg['as_qdr'] = 'all';
75
- $arg['safe'] = 'off';
76
  $arg['pws'] = '0';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
  //Grab the remote informations from google
79
  $response = utf8_decode(SQ_Tools::sq_remote_get("https://www.google.$country/search", $arg));
80
 
81
  //Check the values for block IP
82
- if (strpos($response, "computer virus or spyware application") !== false ||
83
- strpos($response, "entire network is affected") !== false ||
84
- strpos($response, "http://www.download.com/Antivirus") !== false ||
85
- strpos($response, "/images/yellow_warning.gif") !== false ||
86
- strpos($response, "302 Moved") !== false) {
87
  return -2; //return error
88
  }
89
 
90
-
91
  //Get the permalink of the current post
92
  $permalink = get_permalink($this->post_id);
93
- preg_match_all('/<h3 class="r"><a href="\/url\?q=(.*?)&amp;sa=U&amp;ei=/', $response, $matches);
 
 
 
 
 
94
 
95
- $pos = -1;
96
  if (!empty($matches[1])) {
 
97
  foreach ($matches[1] as $index => $url) {
98
-
99
- if (strpos($url, $permalink) !== false) {
100
  $pos = $index + 1;
101
  break;
102
  }
103
  }
 
104
  }
105
- return $pos;
 
106
  }
107
 
108
  /**
@@ -111,7 +159,10 @@ class SQ_Ranking extends SQ_FrontController {
111
  */
112
  public function processCron() {
113
  global $wpdb;
114
- set_time_limit(400);
 
 
 
115
  /* Load the Submit Actions Handler */
116
  SQ_ObjController::getController('SQ_Tools', false);
117
  SQ_ObjController::getController('SQ_Action', false);
@@ -125,7 +176,7 @@ class SQ_Ranking extends SQ_FrontController {
125
  if ($rows = $wpdb->get_results($sql)) {
126
  $count = 0;
127
  foreach ($rows as $row) {
128
- if ($count > 20) {
129
  break; //check only 10 keywords at the time
130
  }
131
  if ($row->meta_value <> '') {
@@ -137,36 +188,37 @@ class SQ_Ranking extends SQ_FrontController {
137
  (isset($json->update) && isset($json->rank) && $json->rank == -1 && (time() - $json->update > (60 * 60 * 24))) //if not indexed than check often
138
  )) {
139
 
140
- $json->rank = $this->processRanking($row->post_id, $json->keyword);
141
- if ($json->rank == -1) {
142
  $count++;
143
- sleep(mt_rand(10, 20));
144
  //if not indexed with the keyword then find the url
145
  if ($this->processRanking($row->post_id, get_permalink($row->post_id)) > 0) {
146
- $json->rank = 0; //for permalink index set 0
147
  }
148
  }
149
 
150
-
151
- if (isset($json->rank)) {
 
152
  $json->country = $this->getCountry();
153
  $json->language = $this->getLanguage();
154
  SQ_ObjController::getModel('SQ_Post')->saveKeyword($row->post_id, $json);
155
- set_transient('sq_rank' . $row->post_id, $json->rank, (60 * 60 * 24));
 
 
156
 
157
- //if rank proccess has no error
158
- if ($json->rank >= -1) {
159
- $args = array();
160
- $args['post_id'] = $row->post_id;
161
- $args['rank'] = (string) $json->rank;
162
- $args['country'] = $this->getCountry();
163
- $args['language'] = $this->getLanguage();
164
 
165
- SQ_Action::apiCall('sq/user-analytics/saveserp', $args);
166
- }
167
- $count++;
168
- sleep(mt_rand(10, 20));
169
- }
170
  }
171
  }
172
  }
7
 
8
  private $keyword;
9
  private $post_id;
10
+ private $error;
11
 
12
  //--
13
  public function getCountry() {
14
+ if (isset(SQ_Tools::$options['sq_google_country']) && SQ_Tools::$options['sq_google_country'] <> '') {
15
+ return SQ_Tools::$options['sq_google_country'];
16
+ }
17
+ return 'com';
18
+ }
19
+
20
+ public function getRefererCountry() {
21
+ $convert_refc = array('com' => 'us', '.off.ai' => 'ai', 'com.ag' => 'ag', 'com.ar' => 'ar', 'com.au' => 'au', 'com.br' => 'br', 'com.co' => 'co', 'co.cr' => 'cr', 'com.cu' => 'cu', 'com.do' => 'do', 'com.ec' => 'ec', 'com.sv' => 'sv', 'com.fj' => 'fj', 'com.gi' => 'gi', 'com.gr' => 'gr', 'com.hk' => 'hk', 'co.hu' => 'hu', 'co.in' => 'in', 'co.im' => 'im', 'co.il' => 'il', 'com.jm' => 'jm', 'co.jp' => 'jp', 'co.je' => 'je', 'co.kr' => 'kr', 'co.ls' => 'ls', 'com.my' => 'my', 'com.mt' => 'mt', 'com.mx' => 'mx', 'com.na' => 'na', 'com.np' => 'np', 'com.ni' => 'ni', 'com.nf' => 'nf', 'com.pk' => 'pk', 'com.pa' => 'pa', 'com.py' => 'py', 'com.pe' => 'pe', 'com.ph' => 'ph', 'com.pr' => 'pr', 'com.sg' => 'sg', 'co.za' => 'za', 'com.tw' => 'tw', 'com.th' => 'th', 'com.tr' => 'tr', 'com.ua' => 'ua', 'com.uk' => 'uk', 'com.uy' => 'uy',);
22
+ $country = $this->getCountry();
23
+ if (array_key_exists($country, $convert_refc)) {
24
+ return $convert_refc[$country];
25
+ }
26
+ return $country;
27
  }
28
 
29
  /**
31
  * @return type
32
  */
33
  public function getLanguage() {
34
+ if (isset(SQ_Tools::$options['sq_google_language']) && SQ_Tools::$options['sq_google_language'] <> '') {
35
+ return SQ_Tools::$options['sq_google_language'];
36
+ }
37
+ return 'en';
38
  }
39
 
40
  /**
59
  */
60
  public function processRanking($post_id, $keyword) {
61
  $this->setPost($post_id);
62
+ $this->setKeyword(trim($keyword));
63
 
64
+ if (isset($this->keyword) && $this->keyword <> '') {
65
  return $this->getGoogleRank();
66
  }
67
  return false;
78
  */
79
  public function getGoogleRank() {
80
  global $wpdb;
81
+ $this->error = '';
82
 
83
+ if (trim($this->keyword) == '') {
84
+ $this->error = 'no keyword for post_id:' . $this->post_id;
85
+ return false;
86
+ }
87
+
88
+ if (!function_exists('preg_match_all')) {
89
+ return false;
90
+ }
91
 
92
  $arg = array('timeout' => 10);
93
+ $arg['as_q'] = str_replace(" ", "+", strtolower(trim($this->keyword)));
94
  $arg['hl'] = $this->getLanguage();
95
+ //$arg['gl'] = $this->getRefererCountry();
96
+
97
+ if (SQ_Tools::$options['sq_google_country_strict'] == 1) {
98
+ $arg['cr'] = 'country' . strtoupper($this->getRefererCountry());
99
+ }
100
+ $arg['start'] = '0';
101
  $arg['num'] = '100';
102
+
103
+ $arg['safe'] = 'active';
104
  $arg['pws'] = '0';
105
+ $arg['as_epq'] = '';
106
+ $arg['as_oq'] = '';
107
+ $arg['as_nlo'] = '';
108
+ $arg['as_nhi'] = '';
109
+ $arg['as_qdr'] = 'all';
110
+ $arg['as_sitesearch'] = '';
111
+ $arg['as_occt'] = 'any';
112
+ $arg['tbs'] = '';
113
+ $arg['as_filetype'] = '';
114
+ $arg['as_rights'] = '';
115
+
116
+ $country = $this->getCountry();
117
+
118
+ if ($country == '' || $arg['hl'] == '') {
119
+ $this->error = 'no country (' . $country . ')';
120
+ return false;
121
+ }
122
 
123
  //Grab the remote informations from google
124
  $response = utf8_decode(SQ_Tools::sq_remote_get("https://www.google.$country/search", $arg));
125
 
126
  //Check the values for block IP
127
+ if (strpos($response, "</h3>") === false) {
128
+ set_transient('google_blocked', 1, (60 * 60 * 1));
 
 
 
129
  return -2; //return error
130
  }
131
 
 
132
  //Get the permalink of the current post
133
  $permalink = get_permalink($this->post_id);
134
+ if ($permalink == '') {
135
+ $this->error = 'no permalink for post_id:' . $this->post_id;
136
+ return false;
137
+ }
138
+
139
+ preg_match_all('/<h3.*?><a href="(.*?)".*?<\/h3>/is', $response, $matches);
140
 
141
+ SQ_Tools::dump($matches[1]);
142
  if (!empty($matches[1])) {
143
+ $pos = -1;
144
  foreach ($matches[1] as $index => $url) {
145
+ if (strpos($url, rtrim($permalink, '/')) !== false) {
 
146
  $pos = $index + 1;
147
  break;
148
  }
149
  }
150
+ return $pos;
151
  }
152
+ $this->error = 'no results returned by google';
153
+ return false;
154
  }
155
 
156
  /**
159
  */
160
  public function processCron() {
161
  global $wpdb;
162
+ if (get_transient('google_blocked') !== false) {
163
+ return;
164
+ }
165
+ set_time_limit(3000);
166
  /* Load the Submit Actions Handler */
167
  SQ_ObjController::getController('SQ_Tools', false);
168
  SQ_ObjController::getController('SQ_Action', false);
176
  if ($rows = $wpdb->get_results($sql)) {
177
  $count = 0;
178
  foreach ($rows as $row) {
179
+ if ($count > 15) {
180
  break; //check only 10 keywords at the time
181
  }
182
  if ($row->meta_value <> '') {
188
  (isset($json->update) && isset($json->rank) && $json->rank == -1 && (time() - $json->update > (60 * 60 * 24))) //if not indexed than check often
189
  )) {
190
 
191
+ $rank = $this->processRanking($row->post_id, $json->keyword);
192
+ if ($rank == -1) {
193
  $count++;
194
+ sleep(mt_rand(20, 50));
195
  //if not indexed with the keyword then find the url
196
  if ($this->processRanking($row->post_id, get_permalink($row->post_id)) > 0) {
197
+ $rank = 0; //for permalink index set 0
198
  }
199
  }
200
 
201
+ //if there is a success response than save it
202
+ if (isset($rank) && $rank >= -1) {
203
+ $json->rank = $rank;
204
  $json->country = $this->getCountry();
205
  $json->language = $this->getLanguage();
206
  SQ_ObjController::getModel('SQ_Post')->saveKeyword($row->post_id, $json);
207
+ }
208
+ set_transient('sq_rank' . $row->post_id, $rank, (60 * 60 * 24));
209
+ //if rank proccess has no error
210
 
211
+ $args = array();
212
+ $args['post_id'] = $row->post_id;
213
+ $args['rank'] = (string) $rank;
214
+ $args['error'] = $this->error;
215
+ $args['country'] = $this->getCountry();
216
+ $args['language'] = $this->getLanguage();
 
217
 
218
+ SQ_Action::apiCall('sq/user-analytics/saveserp', $args);
219
+
220
+ $count++;
221
+ sleep(mt_rand(20, 50));
 
222
  }
223
  }
224
  }
classes/SQ_Sitemap.php CHANGED
@@ -173,7 +173,7 @@ class SQ_Sitemap extends SQ_FrontController {
173
  $categories = get_terms("category", array("hide_empty" => true, "hierarchical" => false));
174
  if ($categories && is_array($categories) && count($categories) > 0) {
175
  foreach ($categories AS $category) {
176
- $this->addLine(get_category_link($category->term_id), 0, $this->opt['category'][1], $this->opt['category'][0]);
177
  }
178
  }
179
  }
@@ -319,8 +319,9 @@ class SQ_Sitemap extends SQ_FrontController {
319
  * @return string
320
  */
321
  private function getTimestamp($time) {
 
 
322
 
323
- $time = date('Y-m-d H:i:s');
324
  list($date, $hours) = explode(' ', $time);
325
  list($year, $month, $day) = explode('-', $date);
326
  list($hour, $min, $sec) = explode(':', $hours);
173
  $categories = get_terms("category", array("hide_empty" => true, "hierarchical" => false));
174
  if ($categories && is_array($categories) && count($categories) > 0) {
175
  foreach ($categories AS $category) {
176
+ $this->addLine(get_category_link($category->term_id), $this->getTimestamp(get_lastpostmodified('GMT')), $this->opt['category'][1], $this->opt['category'][0]);
177
  }
178
  }
179
  }
319
  * @return string
320
  */
321
  private function getTimestamp($time) {
322
+ if (!isset($time) || $time == '')
323
+ $time = date('Y-m-d H:i:s');
324
 
 
325
  list($date, $hours) = explode(' ', $time);
326
  list($year, $month, $day) = explode('-', $date);
327
  list($hour, $min, $sec) = explode(':', $hours);
classes/SQ_Tools.php CHANGED
@@ -11,7 +11,7 @@ class SQ_Tools extends SQ_FrontController {
11
  public static $options = array();
12
 
13
  /** @var integer Count the errors in site */
14
- static $errors_count = 0;
15
 
16
  /** @var array */
17
  private static $debug;
@@ -75,11 +75,11 @@ class SQ_Tools extends SQ_FrontController {
75
  public static function getOptions() {
76
  $default = array(
77
  'sq_api' => '',
78
- 'sq_use' => 1,
79
  'sq_hide_survey' => 0,
80
  // --
81
  'sq_auto_canonical' => 1,
82
- 'sq_auto_sitemap' => 1,
83
  'sq_auto_meta' => 1,
84
  'sq_auto_favicon' => 1,
85
  'sq_auto_twitter' => 1,
@@ -98,6 +98,7 @@ class SQ_Tools extends SQ_FrontController {
98
  'sq_google_analytics' => '',
99
  'sq_facebook_insights' => '',
100
  'sq_bing_wt' => '',
 
101
  'sq_alexa' => '',
102
  // --
103
  'ignore_warn' => 0,
@@ -106,12 +107,16 @@ class SQ_Tools extends SQ_FrontController {
106
  //
107
  'sq_google_country' => 'com',
108
  'sq_google_language' => 'en',
 
109
  // --
110
  'sq_advance_user' => 0,
111
  'sq_affiliate_link' => '',
112
  'sq_sla' => 1,
 
 
113
  //--
114
  'sq_dbtables' => 0,
 
115
  'sq_analytics' => 0,
116
  );
117
  $options = json_decode(get_option(SQ_OPTION), true);
@@ -157,12 +162,12 @@ class SQ_Tools extends SQ_FrontController {
157
  * @return mixed Value
158
  */
159
  public static function getValue($key, $defaultValue = false) {
160
- if (!isset($key) OR empty($key) OR !is_string($key))
161
  return false;
162
  $ret = (isset($_POST[$key]) ? $_POST[$key] : (isset($_GET[$key]) ? $_GET[$key] : $defaultValue));
163
 
164
  if (is_string($ret) === true)
165
- $ret = urldecode(preg_replace('/((\%5C0+)|(\%00+))/i', '', urlencode($ret)));
166
  return !is_string($ret) ? $ret : stripslashes($ret);
167
  }
168
 
@@ -173,7 +178,7 @@ class SQ_Tools extends SQ_FrontController {
173
  * @return boolean
174
  */
175
  public static function getIsset($key) {
176
- if (!isset($key) OR empty($key) OR !is_string($key))
177
  return false;
178
  return isset($_POST[$key]) ? true : (isset($_GET[$key]) ? true : false);
179
  }
@@ -217,7 +222,7 @@ class SQ_Tools extends SQ_FrontController {
217
  $url_domain = $url_domain['host'];
218
 
219
  foreach ($param as $key => $value) {
220
- if ($value <> '' && $key <> 'timeout')
221
  $parameters .= ($parameters == "" ? "" : "&") . $key . "=" . $value;
222
  }
223
  if ($parameters <> '')
@@ -257,7 +262,6 @@ class SQ_Tools extends SQ_FrontController {
257
  //--
258
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
259
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
260
- curl_setopt($ch, CURLOPT_FAILONERROR, false);
261
  //--
262
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
263
  curl_setopt($ch, CURLOPT_TIMEOUT, $param['timeout']);
@@ -342,13 +346,16 @@ class SQ_Tools extends SQ_FrontController {
342
  * Check for SEO blog bad settings
343
  */
344
  public static function checkErrorSettings($count_only = false) {
 
345
  if (function_exists('is_network_admin') && is_network_admin())
346
  return;
347
 
348
  if (isset(self::$options['ignore_warn']) && self::$options['ignore_warn'] == 1)
349
  return;
350
 
351
- $fixit = "<a href=\"javascript:void(0);\" onclick=\"%s jQuery(this).closest('div').fadeOut('slow'); if(parseInt(jQuery('.sq_count').html())>0) { var notif = (parseInt(jQuery('.sq_count').html()) - 1); if (notif > 0) {jQuery('.sq_count').html(notif); }else{ jQuery('.sq_count').html(notif); jQuery('.sq_count').hide(); } } jQuery.post(ajaxurl, { action: '%s', nonce: '" . wp_create_nonce('sq_none') . "'});\" >" . __("Fix it for me!", _SQ_PLUGIN_NAME_) . "</a>";
 
 
352
 
353
 
354
  /* IF SEO INDEX IS OFF */
@@ -359,28 +366,35 @@ class SQ_Tools extends SQ_FrontController {
359
  SQ_Error::setError(__('Let Squirrly optimize your SEO automatically (recommended)', _SQ_PLUGIN_NAME_) . " <br />" . sprintf($fixit, "jQuery('#sq_use_on').attr('checked', true);", "sq_fixautoseo") . " | ", 'settings', 'sq_fix_auto');
360
  }
361
 
362
- /* IF DESCRIPTION DUPLICATES */
363
- if (self::getDuplicateDescription()) {
364
- if ($count_only)
365
- self::$errors_count ++;
366
- else
367
- SQ_Error::setError(__('You have META Description Duplicates. Disable the Squirrly SEO Description or disable the other SEO Plugins', _SQ_PLUGIN_NAME_) . " <br />" . sprintf($fixit, "jQuery('#sq_auto_description0').attr('checked', true); jQuery('#sq_automatically').attr('checked', true);", "sq_fix_descduplicate") . " | ", 'settings', 'sq_fix_descduplicate');
368
- }
369
 
370
- /* IF OG DUPLICATES */
371
- if (self::getDuplicateOG()) {
372
- if ($count_only)
373
- self::$errors_count ++;
374
- else
375
- SQ_Error::setError(__('You have Open Graph META Duplicates. Disable the Squirrly SEO Open Graph or disable the other SEO Plugins', _SQ_PLUGIN_NAME_) . " <br />" . sprintf($fixit, "jQuery('#sq_auto_facebook0').attr('checked', true);", "sq_fix_ogduplicate") . " | ", 'settings', 'sq_fix_ogduplicate');
376
- }
 
377
 
378
- /* IF TWITTER CARD DUPLICATES */
379
- if (self::getDuplicateTC()) {
380
- if ($count_only)
381
- self::$errors_count ++;
382
- else
383
- SQ_Error::setError(__('You have Twitter Card META Duplicates. Disable the Squirrly SEO Twitter Card or disable the other SEO Plugins', _SQ_PLUGIN_NAME_) . " <br />" . sprintf($fixit, "jQuery('#sq_auto_twitter0').attr('checked', true);", "sq_fix_tcduplicate") . " | ", 'settings', 'sq_fix_tcduplicate');
 
 
 
 
 
 
 
 
 
 
384
  }
385
 
386
  /* IF SEO INDEX IS OFF */
@@ -421,8 +435,6 @@ class SQ_Tools extends SQ_FrontController {
421
  }
422
 
423
  if (self::$options['sq_use'] == 1 && self::$options['sq_auto_facebook'] == 1) {
424
- if (!isset(self::$source_code))
425
- self::$source_code = self::sq_remote_get(get_bloginfo('url'), array('timeout' => 10));
426
 
427
  if (self::$source_code <> '') {
428
  preg_match_all("/<meta[\s+]property=[\"|\']og:url[\"|\'][\s+](content|value)=[\"|\']([^>]*)[\"|\'][^>]*>/i", self::$source_code, $out);
@@ -445,8 +457,6 @@ class SQ_Tools extends SQ_FrontController {
445
  }
446
 
447
  if (self::$options['sq_use'] == 1 && self::$options['sq_auto_twitter'] == 1) {
448
- if (!isset(self::$source_code))
449
- self::$source_code = self::sq_remote_get(get_bloginfo('url'), array('timeout' => 10));
450
 
451
  if (self::$source_code <> '') {
452
  preg_match_all("/<meta[\s+]name=[\"|\']twitter:card[\"|\'][\s+](content|value)=[\"|\']([^>]*)[\"|\'][^>]*>/i", self::$source_code, $out);
@@ -470,9 +480,6 @@ class SQ_Tools extends SQ_FrontController {
470
  $total = 0;
471
 
472
  if (self::$options['sq_use'] == 1 && self::$options['sq_auto_description'] == 1) {
473
- if (!isset(self::$source_code))
474
- self::$source_code = self::sq_remote_get(get_bloginfo('url'), array('timeout' => 10));
475
-
476
  if (self::$source_code <> '') {
477
  preg_match_all("/<meta[^>]*name=[\"|\']description[\"|\'][^>]*content=[\"]([^\"]*)[\"][^>]*>/i", self::$source_code, $out);
478
  if (!empty($out) && isset($out[0]) && is_array($out[0])) {
@@ -767,6 +774,11 @@ class SQ_Tools extends SQ_FrontController {
767
  if (function_exists('wp_cache_post_edit') && isset($post_id)) {
768
  wp_cache_post_edit($post_id);
769
  }
 
 
 
 
 
770
  }
771
 
772
  }
11
  public static $options = array();
12
 
13
  /** @var integer Count the errors in site */
14
+ static $errors_count;
15
 
16
  /** @var array */
17
  private static $debug;
75
  public static function getOptions() {
76
  $default = array(
77
  'sq_api' => '',
78
+ 'sq_use' => 0,
79
  'sq_hide_survey' => 0,
80
  // --
81
  'sq_auto_canonical' => 1,
82
+ 'sq_auto_sitemap' => 0,
83
  'sq_auto_meta' => 1,
84
  'sq_auto_favicon' => 1,
85
  'sq_auto_twitter' => 1,
98
  'sq_google_analytics' => '',
99
  'sq_facebook_insights' => '',
100
  'sq_bing_wt' => '',
101
+ 'sq_pinterest' => '',
102
  'sq_alexa' => '',
103
  // --
104
  'ignore_warn' => 0,
107
  //
108
  'sq_google_country' => 'com',
109
  'sq_google_language' => 'en',
110
+ 'sq_google_country_strict' => 1,
111
  // --
112
  'sq_advance_user' => 0,
113
  'sq_affiliate_link' => '',
114
  'sq_sla' => 1,
115
+ 'sq_keywordtag' => 1,
116
+ 'sq_local_images' => 1,
117
  //--
118
  'sq_dbtables' => 0,
119
+ 'sq_dashboard' => 0,
120
  'sq_analytics' => 0,
121
  );
122
  $options = json_decode(get_option(SQ_OPTION), true);
162
  * @return mixed Value
163
  */
164
  public static function getValue($key, $defaultValue = false) {
165
+ if (!isset($key) OR empty($key) OR ! is_string($key))
166
  return false;
167
  $ret = (isset($_POST[$key]) ? $_POST[$key] : (isset($_GET[$key]) ? $_GET[$key] : $defaultValue));
168
 
169
  if (is_string($ret) === true)
170
+ $ret = sanitize_text_field($ret);
171
  return !is_string($ret) ? $ret : stripslashes($ret);
172
  }
173
 
178
  * @return boolean
179
  */
180
  public static function getIsset($key) {
181
+ if (!isset($key) OR empty($key) OR ! is_string($key))
182
  return false;
183
  return isset($_POST[$key]) ? true : (isset($_GET[$key]) ? true : false);
184
  }
222
  $url_domain = $url_domain['host'];
223
 
224
  foreach ($param as $key => $value) {
225
+ if (isset($key) && $key <> '' && $key <> 'timeout')
226
  $parameters .= ($parameters == "" ? "" : "&") . $key . "=" . $value;
227
  }
228
  if ($parameters <> '')
262
  //--
263
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
264
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
 
265
  //--
266
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
267
  curl_setopt($ch, CURLOPT_TIMEOUT, $param['timeout']);
346
  * Check for SEO blog bad settings
347
  */
348
  public static function checkErrorSettings($count_only = false) {
349
+
350
  if (function_exists('is_network_admin') && is_network_admin())
351
  return;
352
 
353
  if (isset(self::$options['ignore_warn']) && self::$options['ignore_warn'] == 1)
354
  return;
355
 
356
+
357
+
358
+ $fixit = "<a href=\"javascript:void(0);\" onclick=\"%s jQuery(this).closest('div').fadeOut('slow'); if(parseInt(jQuery('.sq_count').html())>0) { var notif = (parseInt(jQuery('.sq_count').html()) - 1); if (notif > 0) {jQuery('.sq_count').html(notif); }else{ jQuery('.sq_count').html(notif); jQuery('.sq_count').hide(); } } jQuery.post(ajaxurl, { action: '%s', nonce: '" . wp_create_nonce(_SQ_NONCE_ID_) . "'});\" >" . __("Fix it for me!", _SQ_PLUGIN_NAME_) . "</a>";
359
 
360
 
361
  /* IF SEO INDEX IS OFF */
366
  SQ_Error::setError(__('Let Squirrly optimize your SEO automatically (recommended)', _SQ_PLUGIN_NAME_) . " <br />" . sprintf($fixit, "jQuery('#sq_use_on').attr('checked', true);", "sq_fixautoseo") . " | ", 'settings', 'sq_fix_auto');
367
  }
368
 
369
+ //check only when in seo settings
370
+ if (strpos($_SERVER['REQUEST_URI'], 'page=squirrly')) {
371
+ self::$source_code = self::sq_remote_get(get_bloginfo('url'), array('timeout' => 5));
 
 
 
 
372
 
373
+ if (self::$source_code <> '') {
374
+ /* IF DESCRIPTION DUPLICATES */
375
+ if (self::getDuplicateDescription()) {
376
+ if ($count_only)
377
+ self::$errors_count ++;
378
+ else
379
+ SQ_Error::setError(__('You have META Description Duplicates. Disable the Squirrly SEO Description or disable the other SEO Plugins', _SQ_PLUGIN_NAME_) . " <br />" . sprintf($fixit, "jQuery('#sq_auto_description0').attr('checked', true); jQuery('#sq_automatically').attr('checked', true);", "sq_fix_descduplicate") . " | ", 'settings', 'sq_fix_descduplicate');
380
+ }
381
 
382
+ /* IF OG DUPLICATES */
383
+ if (self::getDuplicateOG()) {
384
+ if ($count_only)
385
+ self::$errors_count ++;
386
+ else
387
+ SQ_Error::setError(__('You have Open Graph META Duplicates. Disable the Squirrly SEO Open Graph or disable the other SEO Plugins', _SQ_PLUGIN_NAME_) . " <br />" . sprintf($fixit, "jQuery('#sq_auto_facebook0').attr('checked', true);", "sq_fix_ogduplicate") . " | ", 'settings', 'sq_fix_ogduplicate');
388
+ }
389
+
390
+ /* IF TWITTER CARD DUPLICATES */
391
+ if (self::getDuplicateTC()) {
392
+ if ($count_only)
393
+ self::$errors_count ++;
394
+ else
395
+ SQ_Error::setError(__('You have Twitter Card META Duplicates. Disable the Squirrly SEO Twitter Card or disable the other SEO Plugins', _SQ_PLUGIN_NAME_) . " <br />" . sprintf($fixit, "jQuery('#sq_auto_twitter0').attr('checked', true);", "sq_fix_tcduplicate") . " | ", 'settings', 'sq_fix_tcduplicate');
396
+ }
397
+ }
398
  }
399
 
400
  /* IF SEO INDEX IS OFF */
435
  }
436
 
437
  if (self::$options['sq_use'] == 1 && self::$options['sq_auto_facebook'] == 1) {
 
 
438
 
439
  if (self::$source_code <> '') {
440
  preg_match_all("/<meta[\s+]property=[\"|\']og:url[\"|\'][\s+](content|value)=[\"|\']([^>]*)[\"|\'][^>]*>/i", self::$source_code, $out);
457
  }
458
 
459
  if (self::$options['sq_use'] == 1 && self::$options['sq_auto_twitter'] == 1) {
 
 
460
 
461
  if (self::$source_code <> '') {
462
  preg_match_all("/<meta[\s+]name=[\"|\']twitter:card[\"|\'][\s+](content|value)=[\"|\']([^>]*)[\"|\'][^>]*>/i", self::$source_code, $out);
480
  $total = 0;
481
 
482
  if (self::$options['sq_use'] == 1 && self::$options['sq_auto_description'] == 1) {
 
 
 
483
  if (self::$source_code <> '') {
484
  preg_match_all("/<meta[^>]*name=[\"|\']description[\"|\'][^>]*content=[\"]([^\"]*)[\"][^>]*>/i", self::$source_code, $out);
485
  if (!empty($out) && isset($out[0]) && is_array($out[0])) {
774
  if (function_exists('wp_cache_post_edit') && isset($post_id)) {
775
  wp_cache_post_edit($post_id);
776
  }
777
+
778
+ if (class_exists("WpFastestCache")) {
779
+ $wpfc = new WpFastestCache();
780
+ $wpfc->deleteCache();
781
+ }
782
  }
783
 
784
  }
classes/SQ_Traffic.php CHANGED
@@ -5,24 +5,6 @@
5
  */
6
  class SQ_Traffic extends SQ_FrontController {
7
 
8
- public function getTrafficScript($code) {
9
- return ' <script type="text/javascript">
10
- var _paq = _paq || [];
11
- _paq.push(["trackPageView"]);
12
- _paq.push(["enableLinkTracking"]);
13
-
14
- (function() {
15
- var u= (("https:" == document.location.protocol) ? "https" : "http") + "://analytics.squirrly.co/";
16
- _paq.push(["setTrackerUrl", u+"track.php"]);
17
- _paq.push(["setSiteId", "' . $code . '"]);
18
- var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
19
- g.defer=true; g.async=true; g.src=u+"track.js"; s.parentNode.insertBefore(g,s);
20
- })();
21
- </script>
22
- <noscript><img src="http://analytics.squirrly.co/track.php?idsite=' . $code . '&amp;rec=1" style="border:0" alt="" /></noscript>
23
- ';
24
- }
25
-
26
  }
27
 
28
  ?>
5
  */
6
  class SQ_Traffic extends SQ_FrontController {
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  }
9
 
10
  ?>
config/config.php CHANGED
@@ -4,7 +4,7 @@
4
  * The configuration file
5
  */
6
  define('_SQ_SUPPORT_EMAIL_', 'support@squirrly.co');
7
- define('_SQ_NONCE_ID_', 'sq_none');
8
 
9
  if (!defined('PHP_VERSION_ID')) {
10
  $version = explode('.', PHP_VERSION);
4
  * The configuration file
5
  */
6
  define('_SQ_SUPPORT_EMAIL_', 'support@squirrly.co');
7
+ define('_SQ_NONCE_ID_', NONCE_KEY);
8
 
9
  if (!defined('PHP_VERSION_ID')) {
10
  $version = explode('.', PHP_VERSION);
config/paths.php CHANGED
@@ -7,7 +7,7 @@ define('_SQ_PLUGIN_NAME_', 'squirrly-seo'); //THIS LINE WILL BE CHANGED WITH THE
7
  define('_THEME_NAME_', 'default'); //THIS LINE WILL BE CHANGED WITH THE USER SETTINGS
8
 
9
  define('_SQ_DASH_URL_', 'https://my.squirrly.co/');
10
- $scheme = ((strpos(get_bloginfo('wpurl'), 'https') !== false || FORCE_SSL_ADMIN) ? 'https:' : 'http:'); //CHECK IF SCURE
11
 
12
  defined('SQ_URI') || define('SQ_URI', (WP_VERSION_ID >= 3000) ? 'wp350' : 'wp2');
13
  defined('_SQ_API_URL_') || define('_SQ_API_URL_', $scheme . '//api.squirrly.co/');
7
  define('_THEME_NAME_', 'default'); //THIS LINE WILL BE CHANGED WITH THE USER SETTINGS
8
 
9
  define('_SQ_DASH_URL_', 'https://my.squirrly.co/');
10
+ $scheme = ((strpos(get_bloginfo('wpurl'), 'https') !== false || (defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN)) ? 'https:' : 'http:'); //CHECK IF SCURE
11
 
12
  defined('SQ_URI') || define('SQ_URI', (WP_VERSION_ID >= 3000) ? 'wp350' : 'wp2');
13
  defined('_SQ_API_URL_') || define('_SQ_API_URL_', $scheme . '//api.squirrly.co/');
controllers/SQ_Frontend.php CHANGED
@@ -5,31 +5,35 @@ class SQ_Frontend extends SQ_FrontController {
5
  public static $options;
6
 
7
  public function __construct() {
8
- if ((!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') || strpos($_SERVER['PHP_SELF'], '/admin-ajax.php') !== false)
9
  return;
10
 
11
  parent::__construct();
12
-
13
  SQ_ObjController::getController('SQ_Tools', false);
14
- self::$options = SQ_Tools::getOptions();
15
 
16
- if (SQ_Tools::getValue('sq_use') == 'on')
17
- self::$options['sq_use'] = 1;
18
- elseif (SQ_Tools::getValue('sq_use') == 'off')
19
- self::$options['sq_use'] = 0;
 
20
  }
21
 
22
  /**
23
  * Called after plugins are loaded
24
  */
25
- public function hookLoaded() {
26
- if (self::$options['sq_use'] == 1) {
27
- if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
28
- return;
29
- if (strpos($_SERVER['PHP_SELF'], '/admin-ajax.php') !== false)
 
 
 
 
30
  return;
31
  //Use buffer only for meta Title
32
- //if(self::$options['sq_auto_title'] == 1)
33
  $this->model->startBuffer();
34
  }
35
  }
@@ -38,16 +42,16 @@ class SQ_Frontend extends SQ_FrontController {
38
  * Hook the Header load
39
  */
40
  public function hookFronthead() {
41
- if ((!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') || strpos($_SERVER['PHP_SELF'], '/admin-ajax.php') !== false)
42
  return;
43
 
44
  echo $this->model->setStart();
45
 
46
- if (isset(self::$options['sq_use']) && (int) self::$options['sq_use'] == 1) {
47
  echo $this->model->setHeader();
48
 
49
  //Use buffer only for meta Title
50
- //if(self::$options['sq_auto_title'] == 1)
51
  $this->model->flushHeader();
52
  }
53
 
@@ -96,15 +100,10 @@ class SQ_Frontend extends SQ_FrontController {
96
  * Hook Footer load to save the visit and to close the buffer
97
  */
98
  public function hookFrontfooter() {
99
- if (isset(self::$options['sq_use']) && (int) self::$options['sq_use'] == 1) {
100
  //Be sure the heder is flushed
101
- //if(self::$options['sq_auto_title'] == 1)
102
  $this->model->flushHeader();
103
  }
104
-
105
- if (isset(self::$options['sq_analytics_code']) && !(current_user_can('edit_posts') )) {
106
- $this->model->setFooter(self::$options['sq_analytics_code']);
107
- }
108
  }
109
 
110
  }
5
  public static $options;
6
 
7
  public function __construct() {
8
+ if ($this->_isAjax())
9
  return;
10
 
11
  parent::__construct();
 
12
  SQ_ObjController::getController('SQ_Tools', false);
13
+ }
14
 
15
+ private function _isAjax() {
16
+ if (isset($_SERVER['PHP_SELF']) && strpos($_SERVER['PHP_SELF'], '/admin-ajax.php') !== false)
17
+ return true;
18
+
19
+ return false;
20
  }
21
 
22
  /**
23
  * Called after plugins are loaded
24
  */
25
+ public function hookPreload() {
26
+ if (SQ_Tools::getValue('sq_use') == 'on') {
27
+ SQ_Tools::$options['sq_use'] = 1;
28
+ } elseif (SQ_Tools::getValue('sq_use') == 'off') {
29
+ SQ_Tools::$options['sq_use'] = 0;
30
+ }
31
+
32
+ if (SQ_Tools::$options['sq_use'] == 1) {
33
+ if ($this->_isAjax())
34
  return;
35
  //Use buffer only for meta Title
36
+ //if(SQ_Tools::$options['sq_auto_title'] == 1)
37
  $this->model->startBuffer();
38
  }
39
  }
42
  * Hook the Header load
43
  */
44
  public function hookFronthead() {
45
+ if ($this->_isAjax())
46
  return;
47
 
48
  echo $this->model->setStart();
49
 
50
+ if (isset(SQ_Tools::$options['sq_use']) && (int) SQ_Tools::$options['sq_use'] == 1) {
51
  echo $this->model->setHeader();
52
 
53
  //Use buffer only for meta Title
54
+ //if(SQ_Tools::$options['sq_auto_title'] == 1)
55
  $this->model->flushHeader();
56
  }
57
 
100
  * Hook Footer load to save the visit and to close the buffer
101
  */
102
  public function hookFrontfooter() {
103
+ if (isset(SQ_Tools::$options['sq_use']) && (int) SQ_Tools::$options['sq_use'] == 1) {
104
  //Be sure the heder is flushed
 
105
  $this->model->flushHeader();
106
  }
 
 
 
 
107
  }
108
 
109
  }
controllers/SQ_Menu.php CHANGED
@@ -67,7 +67,7 @@ class SQ_Menu extends SQ_FrontController {
67
  }
68
 
69
  /* add the plugin menu in admin */
70
- if (current_user_can('administrator')) {
71
  SQ_Tools::checkErrorSettings(true);
72
  //check if activated
73
  $this->checkActivation();
@@ -80,8 +80,27 @@ class SQ_Menu extends SQ_FrontController {
80
  //Push the Analytics Check
81
  $analytics_alert = 0;
82
  if (SQ_ObjController::getModel('SQ_Post')->countKeywords() > 0) {
83
- $analytics_alert = ((SQ_Tools::$options['sq_analytics'] == 0) ? 1 : 0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  }
 
85
  SQ_Tools::$errors_count += $analytics_alert;
86
  ///////////////
87
 
@@ -121,7 +140,7 @@ class SQ_Menu extends SQ_FrontController {
121
  $this->model->addSubmenu(array($first_page,
122
  ucfirst(_SQ_NAME_) . __(' account info', _SQ_PLUGIN_NAME_),
123
  __('Account Info', _SQ_PLUGIN_NAME_),
124
- 'administrator',
125
  'sq_account',
126
  array(SQ_ObjController::getBlock('SQ_BlockAccount'), 'init')
127
  ));
@@ -129,7 +148,7 @@ class SQ_Menu extends SQ_FrontController {
129
  $this->model->addSubmenu(array($first_page,
130
  ucfirst(_SQ_NAME_) . __(' settings', _SQ_PLUGIN_NAME_),
131
  __('SEO Settings', _SQ_PLUGIN_NAME_) . SQ_Tools::showNotices(SQ_Tools::$errors_count, 'errors_count'),
132
- 'administrator',
133
  preg_replace('/\s/', '_', _SQ_NAME_),
134
  array($this, 'showMenu')
135
  ));
@@ -138,7 +157,7 @@ class SQ_Menu extends SQ_FrontController {
138
  $this->model->addSubmenu(array($first_page,
139
  __('Make money with ', _SQ_PLUGIN_NAME_) . ucfirst(_SQ_NAME_),
140
  __('Make money', _SQ_PLUGIN_NAME_),
141
- 'administrator',
142
  'sq_affiliate',
143
  array(SQ_ObjController::getBlock('SQ_BlockAffiliate'), 'init')
144
  ));
@@ -164,7 +183,7 @@ class SQ_Menu extends SQ_FrontController {
164
  * @return void
165
  */
166
  public function showMenu() {
167
-
168
  SQ_Tools::checkErrorSettings();
169
  /* Force call of error display */
170
  SQ_ObjController::getController('SQ_Error', false)->hookNotices();
@@ -173,6 +192,8 @@ class SQ_Menu extends SQ_FrontController {
173
  /* Get the options from Database */
174
  $this->options = SQ_Tools::$options;
175
  SQ_ObjController::getBlock('SQ_BlockSupport')->init();
 
 
176
  parent::init();
177
  }
178
 
@@ -207,18 +228,39 @@ class SQ_Menu extends SQ_FrontController {
207
  $sq_twitter_account = '@' . $sq_twitter_account;
208
  SQ_Tools::saveOptions('sq_twitter_account', $sq_twitter_account);
209
 
210
- SQ_Tools::saveOptions('sq_auto_seo', (int) SQ_Tools::getValue('sq_auto_seo'));
211
- SQ_Tools::saveOptions('sq_fp_title', SQ_Tools::getValue('sq_fp_title'));
212
- SQ_Tools::saveOptions('sq_fp_description', SQ_Tools::getValue('sq_fp_description'));
213
- SQ_Tools::saveOptions('sq_fp_keywords', SQ_Tools::getValue('sq_fp_keywords'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
 
215
  SQ_Tools::saveOptions('sq_google_country', SQ_Tools::getValue('sq_google_country'));
 
 
216
 
217
  SQ_Tools::saveOptions('sq_google_plus', SQ_Tools::getValue('sq_google_plus'));
218
  SQ_Tools::saveOptions('sq_google_wt', $this->model->checkGoogleWTCode(SQ_Tools::getValue('sq_google_wt')));
219
  SQ_Tools::saveOptions('sq_google_analytics', $this->model->checkGoogleAnalyticsCode(SQ_Tools::getValue('sq_google_analytics')));
220
  SQ_Tools::saveOptions('sq_facebook_insights', $this->model->checkFavebookInsightsCode(SQ_Tools::getValue('sq_facebook_insights')));
221
  SQ_Tools::saveOptions('sq_bing_wt', $this->model->checkBingWTCode(SQ_Tools::getValue('sq_bing_wt')));
 
222
  SQ_Tools::saveOptions('sq_alexa', $this->model->checkBingWTCode(SQ_Tools::getValue('sq_alexa')));
223
 
224
 
@@ -226,6 +268,8 @@ class SQ_Menu extends SQ_FrontController {
226
  SQ_Tools::saveOptions('sq_keyword_help', (int) SQ_Tools::getValue('sq_keyword_help'));
227
  SQ_Tools::saveOptions('sq_keyword_information', (int) SQ_Tools::getValue('sq_keyword_information'));
228
  SQ_Tools::saveOptions('sq_sla', (int) SQ_Tools::getValue('sq_sla'));
 
 
229
 
230
  //update_option('blog_public', (int)SQ_Tools::getValue('sq_google_index'));
231
 
@@ -248,11 +292,6 @@ class SQ_Menu extends SQ_FrontController {
248
  //empty the cache on settings changed
249
  SQ_Tools::emptyCache();
250
  break;
251
- case 'sq_save_analytics':
252
-
253
- SQ_Tools::saveOptions('sq_analytics_code', SQ_Tools::getValue('sq_analytics_code'));
254
- SQ_Tools::emptyCache();
255
- break;
256
  case 'sq_fixautoseo':
257
  SQ_Tools::saveOptions('sq_use', 1);
258
  break;
@@ -292,6 +331,7 @@ class SQ_Menu extends SQ_FrontController {
292
  $url = get_bloginfo('url');
293
  }
294
  $snippet = SQ_Tools::getSnippet($url);
 
295
 
296
  /* if((int)SQ_Tools::getValue('post_id') > 0)
297
  $snippet['url'] = get_permalink((int)SQ_Tools::getValue('post_id'));
67
  }
68
 
69
  /* add the plugin menu in admin */
70
+ if (current_user_can('manage_options')) {
71
  SQ_Tools::checkErrorSettings(true);
72
  //check if activated
73
  $this->checkActivation();
80
  //Push the Analytics Check
81
  $analytics_alert = 0;
82
  if (SQ_ObjController::getModel('SQ_Post')->countKeywords() > 0) {
83
+ if (SQ_Tools::$options['sq_analytics'] == 0) {
84
+ $analytics_alert = 1;
85
+ }
86
+
87
+ if (strpos($_SERVER['REQUEST_URI'], '?page=sq_dashboard') !== false) {
88
+ SQ_Tools::saveOptions('sq_dashboard', 1);
89
+ } else {
90
+ if (SQ_Tools::$options['sq_dashboard'] == 0) {
91
+ $analytics_alert = 1;
92
+ if (!get_transient('sq_dashboard')) {
93
+ set_transient('sq_dashboard', time(), (60 * 60 * 24 * 7));
94
+ } else {
95
+ $time_loaded = get_transient('sq_dashboard');
96
+ if (time() - $time_loaded > (60 * 60 * 24 * 3)) {
97
+ SQ_Error::setError(__('Check out your SEO Audit and the Performance Analytics section. <a href="admin.php?page=sq_dashboard" title="Squirrly Dashboard">Click here</a>', _SQ_PLUGIN_NAME_));
98
+ }
99
+ }
100
+ }
101
+ }
102
  }
103
+
104
  SQ_Tools::$errors_count += $analytics_alert;
105
  ///////////////
106
 
140
  $this->model->addSubmenu(array($first_page,
141
  ucfirst(_SQ_NAME_) . __(' account info', _SQ_PLUGIN_NAME_),
142
  __('Account Info', _SQ_PLUGIN_NAME_),
143
+ 'manage_options',
144
  'sq_account',
145
  array(SQ_ObjController::getBlock('SQ_BlockAccount'), 'init')
146
  ));
148
  $this->model->addSubmenu(array($first_page,
149
  ucfirst(_SQ_NAME_) . __(' settings', _SQ_PLUGIN_NAME_),
150
  __('SEO Settings', _SQ_PLUGIN_NAME_) . SQ_Tools::showNotices(SQ_Tools::$errors_count, 'errors_count'),
151
+ 'manage_options',
152
  preg_replace('/\s/', '_', _SQ_NAME_),
153
  array($this, 'showMenu')
154
  ));
157
  $this->model->addSubmenu(array($first_page,
158
  __('Make money with ', _SQ_PLUGIN_NAME_) . ucfirst(_SQ_NAME_),
159
  __('Make money', _SQ_PLUGIN_NAME_),
160
+ 'manage_options',
161
  'sq_affiliate',
162
  array(SQ_ObjController::getBlock('SQ_BlockAffiliate'), 'init')
163
  ));
183
  * @return void
184
  */
185
  public function showMenu() {
186
+ /* Load the error class */
187
  SQ_Tools::checkErrorSettings();
188
  /* Force call of error display */
189
  SQ_ObjController::getController('SQ_Error', false)->hookNotices();
192
  /* Get the options from Database */
193
  $this->options = SQ_Tools::$options;
194
  SQ_ObjController::getBlock('SQ_BlockSupport')->init();
195
+
196
+ //call the init function from Front class
197
  parent::init();
198
  }
199
 
228
  $sq_twitter_account = '@' . $sq_twitter_account;
229
  SQ_Tools::saveOptions('sq_twitter_account', $sq_twitter_account);
230
 
231
+ SQ_Tools::saveOptions('sq_auto_seo', 0);
232
+ if ($pageId = get_option('page_on_front')) {
233
+ $meta = array();
234
+ if (SQ_Tools::getIsset('sq_fp_title'))
235
+ $meta[] = array('key' => 'sq_fp_title', 'value' => urldecode(SQ_Tools::getValue('sq_fp_title')));
236
+
237
+ if (SQ_Tools::getIsset('sq_fp_description'))
238
+ $meta[] = array('key' => 'sq_fp_description', 'value' => urldecode(SQ_Tools::getValue('sq_fp_description')));
239
+
240
+ if (SQ_Tools::getIsset('sq_fp_keywords'))
241
+ $meta[] = array('key' => 'sq_fp_keywords', 'value' => SQ_Tools::getValue('sq_fp_keywords'));
242
+
243
+ if (SQ_Tools::getIsset('sq_fp_ogimage'))
244
+ $meta[] = array('key' => 'sq_fp_ogimage', 'value' => SQ_ObjController::getModel('SQ_Frontend')->getAdvancedMeta($pageId, 'ogimage'));
245
+
246
+ if (!empty($meta))
247
+ SQ_ObjController::getModel('SQ_Post')->saveAdvMeta($pageId, $meta);
248
+ }else {
249
+ SQ_Tools::saveOptions('sq_fp_title', SQ_Tools::getValue('sq_fp_title'));
250
+ SQ_Tools::saveOptions('sq_fp_description', SQ_Tools::getValue('sq_fp_description'));
251
+ SQ_Tools::saveOptions('sq_fp_keywords', SQ_Tools::getValue('sq_fp_keywords'));
252
+ }
253
 
254
  SQ_Tools::saveOptions('sq_google_country', SQ_Tools::getValue('sq_google_country'));
255
+ SQ_Tools::saveOptions('sq_google_country_strict', SQ_Tools::getValue('sq_google_country_strict'));
256
+
257
 
258
  SQ_Tools::saveOptions('sq_google_plus', SQ_Tools::getValue('sq_google_plus'));
259
  SQ_Tools::saveOptions('sq_google_wt', $this->model->checkGoogleWTCode(SQ_Tools::getValue('sq_google_wt')));
260
  SQ_Tools::saveOptions('sq_google_analytics', $this->model->checkGoogleAnalyticsCode(SQ_Tools::getValue('sq_google_analytics')));
261
  SQ_Tools::saveOptions('sq_facebook_insights', $this->model->checkFavebookInsightsCode(SQ_Tools::getValue('sq_facebook_insights')));
262
  SQ_Tools::saveOptions('sq_bing_wt', $this->model->checkBingWTCode(SQ_Tools::getValue('sq_bing_wt')));
263
+ SQ_Tools::saveOptions('sq_pinterest', $this->model->checkPinterestCode(SQ_Tools::getValue('sq_pinterest')));
264
  SQ_Tools::saveOptions('sq_alexa', $this->model->checkBingWTCode(SQ_Tools::getValue('sq_alexa')));
265
 
266
 
268
  SQ_Tools::saveOptions('sq_keyword_help', (int) SQ_Tools::getValue('sq_keyword_help'));
269
  SQ_Tools::saveOptions('sq_keyword_information', (int) SQ_Tools::getValue('sq_keyword_information'));
270
  SQ_Tools::saveOptions('sq_sla', (int) SQ_Tools::getValue('sq_sla'));
271
+ SQ_Tools::saveOptions('sq_keywordtag', (int) SQ_Tools::getValue('sq_keywordtag'));
272
+ SQ_Tools::saveOptions('sq_local_images', (int) SQ_Tools::getValue('sq_local_images'));
273
 
274
  //update_option('blog_public', (int)SQ_Tools::getValue('sq_google_index'));
275
 
292
  //empty the cache on settings changed
293
  SQ_Tools::emptyCache();
294
  break;
 
 
 
 
 
295
  case 'sq_fixautoseo':
296
  SQ_Tools::saveOptions('sq_use', 1);
297
  break;
331
  $url = get_bloginfo('url');
332
  }
333
  $snippet = SQ_Tools::getSnippet($url);
334
+ //SQ_Tools::dump($snippet);
335
 
336
  /* if((int)SQ_Tools::getValue('post_id') > 0)
337
  $snippet['url'] = get_permalink((int)SQ_Tools::getValue('post_id'));
controllers/SQ_Post.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  class SQ_Post extends SQ_FrontController {
4
 
5
- var $saved;
6
 
7
  /**
8
  * Initialize the TinyMCE editor for the current use
@@ -10,17 +10,19 @@ class SQ_Post extends SQ_FrontController {
10
  * @return void
11
  */
12
  public function hookInit() {
13
- add_filter('tiny_mce_before_init', array(&$this->model, 'setCallback'));
14
- add_filter('mce_external_plugins', array(&$this->model, 'addHeadingButton'));
15
- add_filter('mce_buttons', array(&$this->model, 'registerButton'));
 
 
16
 
17
  if (SQ_Tools::$options['sq_api'] == '')
18
  return;
19
 
20
- add_action('save_post', array($this, 'hookSavePost'), 10);
21
 
22
  //For Shopp plugin - product
23
- add_action('shopp_product_saved', array($this, 'hookShopp'), 10);
24
  }
25
 
26
  /**
@@ -62,39 +64,31 @@ class SQ_Post extends SQ_FrontController {
62
  */
63
  public function hookSavePost($post_id) {
64
  $file_name = false;
65
-
 
66
 
67
  // unhook this function so it doesn't loop infinitely
68
- remove_action('save_post', array($this, 'hookSavePost'), 10);
69
-
70
  //If the post is a new or edited post
71
  if ((SQ_Tools::getValue('action')) == 'editpost' &&
72
- wp_is_post_revision($post_id) == '' &&
73
  wp_is_post_autosave($post_id) == '' &&
74
  get_post_status($post_id) != 'auto-draft' &&
75
  get_post_status($post_id) != 'inherit' &&
76
  SQ_Tools::getValue('autosave') == '') {
77
- //echo 'saving';
78
- //check for custom SEO
79
- $this->_checkAdvMeta($post_id);
80
- //check the SEO from Squirrly Live Assistant
81
- $this->checkSeo($post_id, get_post_status($post_id));
82
- }
83
 
84
- //If the post is not auto-save post
85
- if ((SQ_Tools::getValue('action')) == 'editpost' &&
86
- wp_is_post_autosave($post_id) == '' &&
87
- get_post_status($post_id) != 'auto-draft' &&
88
- get_post_status($post_id) != 'inherit' &&
89
- SQ_Tools::getValue('autosave') == '') {
90
-
91
- if (!$this->saved)
92
- //check the remote images
93
  $this->checkImage($post_id);
94
- $this->saved = true;
 
95
  }
96
 
97
- add_action('save_post', array($this, 'hookSavePost'), 10);
 
98
  }
99
 
100
  /**
@@ -104,69 +98,75 @@ class SQ_Post extends SQ_FrontController {
104
  * @return false|void
105
  */
106
  public function checkImage($post_id) {
107
- @set_time_limit(90);
108
- $local_file = false;
109
-
110
- $content = stripslashes(SQ_Tools::getValue('post_content'));
111
- $tmpcontent = trim($content, "\n");
112
- $urls = array();
113
-
114
- if (function_exists('preg_match_all')) {
115
- @preg_match_all('/<img[^>]*src="([^"]+)"[^>]*>/i', $tmpcontent, $out);
116
-
117
- if (is_array($out)) {
118
- if (!is_array($out[1]) || count($out[1]) == 0)
119
- return;
120
-
121
- if (get_bloginfo('wpurl') <> '') {
122
- $domain = parse_url(get_bloginfo('wpurl'));
123
-
124
- foreach ($out[1] as $row) {
125
- if (strpos($row, 'http') !== false &&
126
- strpos($row, $domain['host']) === false) {
127
- if (!in_array($row, $urls)) {
128
- $urls[] = $row;
 
 
 
129
  }
130
  }
131
  }
132
  }
133
  }
134
- }
135
-
136
- if (!is_array($urls) || (is_array($urls) && count($urls) == 0))
137
- return;
138
 
139
- $urls = @array_unique($urls);
140
- foreach ($urls as $url) {
141
- if ($file = $this->model->upload_image($url)) {
142
- if (!file_is_valid_image($file['file']))
143
- continue;
144
-
145
- //encode special characters
146
- $local_file = str_replace($file['filename'], urlencode($file['filename']), $file['url']);
147
- if ($local_file !== false) {
148
- $content = str_replace($url, $local_file, $content);
149
-
150
- $attach_id = wp_insert_attachment(array(
151
- 'post_mime_type' => $file['type'],
152
- 'post_title' => preg_replace('/\.[^.]+$/', '', $file['filename']),
153
- 'post_content' => '',
154
- 'post_status' => 'inherit',
155
- 'guid' => $local_file
156
- ), $file['file'], $post_id);
157
-
158
- $attach_data = wp_generate_attachment_metadata($attach_id, $file['file']);
159
- wp_update_attachment_metadata($attach_id, $attach_data);
 
 
 
 
 
 
 
160
  }
161
  }
162
- }
163
 
164
 
165
- if ($local_file !== false) {
166
- wp_update_post(array(
167
- 'ID' => $post_id,
168
- 'post_content' => $content)
169
- );
 
170
  }
171
  }
172
 
@@ -193,7 +193,7 @@ class SQ_Post extends SQ_FrontController {
193
  $args['author'] = (int) SQ_Tools::getUserID();
194
  $args['post_id'] = $post_id;
195
 
196
- SQ_Action::apiCall('sq/seo/post', $args, 10);
197
 
198
  //Save the keyword for this post
199
  if ($json = $this->model->getKeyword($post_id)) {
@@ -225,7 +225,39 @@ class SQ_Post extends SQ_FrontController {
225
  switch (SQ_Tools::getValue('action')) {
226
  case 'sq_save_meta':
227
  $return = $this->_checkAdvMeta(SQ_Tools::getValue('post_id'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  echo json_encode($return);
 
 
 
 
 
 
 
 
 
 
229
  break;
230
  }
231
  exit();
@@ -253,6 +285,10 @@ class SQ_Post extends SQ_FrontController {
253
  $meta[] = array('key' => 'sq_fp_keywords',
254
  'value' => SQ_Tools::getValue('sq_fp_keywords'));
255
 
 
 
 
 
256
  $this->model->saveAdvMeta($post_id, $meta);
257
  return $meta;
258
  }
2
 
3
  class SQ_Post extends SQ_FrontController {
4
 
5
+ public $saved;
6
 
7
  /**
8
  * Initialize the TinyMCE editor for the current use
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_Tools::$options['sq_api'] == '')
20
  return;
21
 
22
+ add_action('save_post', array($this, 'hookSavePost'), 11);
23
 
24
  //For Shopp plugin - product
25
+ add_action('shopp_product_saved', array($this, 'hookShopp'), 11);
26
  }
27
 
28
  /**
64
  */
65
  public function hookSavePost($post_id) {
66
  $file_name = false;
67
+ if (!isset($this->saved[$post_id]))
68
+ $this->saved[$post_id] = false;
69
 
70
  // unhook this function so it doesn't loop infinitely
71
+ remove_action('save_post', array($this, 'hookSavePost'), 11);
 
72
  //If the post is a new or edited post
73
  if ((SQ_Tools::getValue('action')) == 'editpost' &&
 
74
  wp_is_post_autosave($post_id) == '' &&
75
  get_post_status($post_id) != 'auto-draft' &&
76
  get_post_status($post_id) != 'inherit' &&
77
  SQ_Tools::getValue('autosave') == '') {
 
 
 
 
 
 
78
 
79
+ if ($this->saved[$post_id] === false) {
80
+ //check for custom SEO
81
+ $this->_checkAdvMeta($post_id);
82
+ //check the SEO from Squirrly Live Assistant
83
+ $this->checkSeo($post_id, get_post_status($post_id));
84
+ //check the remote images
 
 
 
85
  $this->checkImage($post_id);
86
+ }
87
+ $this->saved[$post_id] = true;
88
  }
89
 
90
+
91
+ add_action('save_post', array($this, 'hookSavePost'), 11);
92
  }
93
 
94
  /**
98
  * @return false|void
99
  */
100
  public function checkImage($post_id) {
101
+ //if the option to save the images locally is set on
102
+ if (SQ_Tools::$options['sq_local_images'] == 1) {
103
+ @set_time_limit(90);
104
+ $local_file = false;
105
+
106
+ $content = stripslashes(SQ_Tools::getValue('post_content'));
107
+ $tmpcontent = trim($content, "\n");
108
+ $urls = array();
109
+
110
+ if (function_exists('preg_match_all')) {
111
+ @preg_match_all('/<img[^>]*src="([^"]+)"[^>]*>/i', $tmpcontent, $out);
112
+
113
+ if (is_array($out)) {
114
+ if (!is_array($out[1]) || count($out[1]) == 0)
115
+ return;
116
+
117
+ if (get_bloginfo('wpurl') <> '') {
118
+ $domain = parse_url(get_bloginfo('wpurl'));
119
+
120
+ foreach ($out[1] as $row) {
121
+ if (strpos($row, 'http') !== false &&
122
+ strpos($row, $domain['host']) === false) {
123
+ if (!in_array($row, $urls)) {
124
+ $urls[] = $row;
125
+ }
126
  }
127
  }
128
  }
129
  }
130
  }
 
 
 
 
131
 
132
+ if (!is_array($urls) || (is_array($urls) && count($urls) == 0))
133
+ return;
134
+
135
+ $urls = @array_unique($urls);
136
+ $time = microtime(true);
137
+ foreach ($urls as $url) {
138
+ if ($file = $this->model->upload_image($url)) {
139
+ if (!file_is_valid_image($file['file']))
140
+ continue;
141
+
142
+ $local_file = $file['url'];
143
+ if ($local_file !== false) {
144
+ $content = str_replace($url, $local_file, $content);
145
+
146
+ $attach_id = wp_insert_attachment(array(
147
+ 'post_mime_type' => $file['type'],
148
+ 'post_title' => SQ_Tools::getValue('sq_keyword', preg_replace('/\.[^.]+$/', '', $file['filename'])),
149
+ 'post_content' => urldecode(SQ_Tools::getValue('sq_fp_title', '')),
150
+ 'post_status' => 'inherit',
151
+ 'guid' => $local_file
152
+ ), $file['file'], $post_id);
153
+
154
+ $attach_data = wp_generate_attachment_metadata($attach_id, $file['file']);
155
+ wp_update_attachment_metadata($attach_id, $attach_data);
156
+ }
157
+ }
158
+ if (microtime(true) - $time >= 20) {
159
+ break;
160
  }
161
  }
 
162
 
163
 
164
+ if ($local_file !== false) {
165
+ wp_update_post(array(
166
+ 'ID' => $post_id,
167
+ 'post_content' => $content)
168
+ );
169
+ }
170
  }
171
  }
172
 
193
  $args['author'] = (int) SQ_Tools::getUserID();
194
  $args['post_id'] = $post_id;
195
 
196
+ SQ_Action::apiCall('sq/seo/post', $args, 5);
197
 
198
  //Save the keyword for this post
199
  if ($json = $this->model->getKeyword($post_id)) {
225
  switch (SQ_Tools::getValue('action')) {
226
  case 'sq_save_meta':
227
  $return = $this->_checkAdvMeta(SQ_Tools::getValue('post_id'));
228
+ SQ_Tools::setHeader('json');
229
+ echo json_encode($return);
230
+ SQ_Tools::emptyCache();
231
+ break;
232
+ case 'sq_save_ogimage':
233
+ if (!empty($_FILES['ogimage'])) {
234
+ $return = $this->model->addImage($_FILES['ogimage']);
235
+ }
236
+ $return['filename'] = basename($return['file']);
237
+ $local_file = str_replace($return['filename'], urlencode($return['filename']), $return['url']);
238
+ $attach_id = wp_insert_attachment(array(
239
+ 'post_mime_type' => $return['type'],
240
+ 'post_title' => preg_replace('/\.[^.]+$/', '', $return['filename']),
241
+ 'post_content' => '',
242
+ 'post_status' => 'inherit',
243
+ 'guid' => $local_file
244
+ ), $return['file'], SQ_Tools::getValue('post_id'));
245
+
246
+ $attach_data = wp_generate_attachment_metadata($attach_id, $return['file']);
247
+ wp_update_attachment_metadata($attach_id, $attach_data);
248
+
249
+ SQ_Tools::setHeader('json');
250
  echo json_encode($return);
251
+ SQ_Tools::emptyCache();
252
+ break;
253
+ case 'sq_get_keyword':
254
+ SQ_Tools::setHeader('json');
255
+ if (SQ_Tools::getIsset('post_id')) {
256
+ echo json_encode($this->model->getKeywordsFromPost(SQ_Tools::getValue('post_id')));
257
+ } else {
258
+ echo json_encode(array('error' => true));
259
+ }
260
+ SQ_Tools::emptyCache();
261
  break;
262
  }
263
  exit();
285
  $meta[] = array('key' => 'sq_fp_keywords',
286
  'value' => SQ_Tools::getValue('sq_fp_keywords'));
287
 
288
+ if (SQ_Tools::getIsset('sq_fp_ogimage'))
289
+ $meta[] = array('key' => 'sq_fp_ogimage',
290
+ 'value' => SQ_Tools::getValue('sq_fp_ogimage'));
291
+
292
  $this->model->saveAdvMeta($post_id, $meta);
293
  return $meta;
294
  }
controllers/SQ_PostsList.php CHANGED
@@ -23,7 +23,7 @@ class SQ_PostsList extends SQ_FrontController {
23
  'page_posts',
24
  'edit-product',
25
  'product_posts');
26
- // do_action('sq_processCron');
27
  }
28
 
29
  public function setPosts($posts) {
@@ -163,7 +163,6 @@ class SQ_PostsList extends SQ_FrontController {
163
  var __sq_article_rank = "' . __('SEO Analytics, by Squirrly', _SQ_PLUGIN_NAME_) . '";
164
  var __sq_refresh = "' . __('Update', _SQ_PLUGIN_NAME_) . '"
165
 
166
- var sq_analytics_code = "' . SQ_Tools::$options['sq_analytics_code'] . '";
167
  var __sq_dashurl = "' . _SQ_STATIC_API_URL_ . '";
168
  var __token = "' . SQ_Tools::$options['sq_api'] . '";
169
  var __sq_ranknotpublic_text = "' . __('Not Public', _SQ_PLUGIN_NAME_) . '";
@@ -241,7 +240,6 @@ class SQ_PostsList extends SQ_FrontController {
241
  */
242
  public function action() {
243
  parent::action();
244
-
245
  switch (SQ_Tools::getValue('action')) {
246
  case 'sq_posts_rank':
247
  $args = array();
@@ -250,7 +248,7 @@ class SQ_PostsList extends SQ_FrontController {
250
  $posts = SQ_Tools::getValue('posts');
251
  $args['posts'] = join(',', $posts);
252
 
253
- $response = json_decode(SQ_Action::apiCall('sq/user-analytics/total', $args));
254
  }
255
  if (isset($response) && is_object($response)) {
256
  $response = $this->model->getTotal($response);
@@ -258,29 +256,34 @@ class SQ_PostsList extends SQ_FrontController {
258
  exit(json_encode($response));
259
  }
260
  exit(json_encode(array('posts' => array())));
 
261
  case 'sq_post_rank':
262
  $args = array();
 
263
  $this->model->post_id = (int) SQ_Tools::getValue('post');
264
  $args['post_id'] = $this->model->post_id;
265
 
266
  if ($json = SQ_ObjController::getModel('SQ_Post')->getKeyword($this->model->post_id)) {
267
  if (isset($json->rank)) {
 
 
 
 
 
 
268
  $ranking = SQ_ObjController::getController('SQ_Ranking', false);
269
- $args['rank'] = (string) $json->rank;
270
  $args['country'] = $ranking->getCountry();
271
  $args['language'] = $ranking->getLanguage();
272
  }
273
  }
274
 
275
- $response = json_decode(SQ_Action::apiCall('sq/user-analytics/detail', $args));
276
 
277
  if (!is_object($response)) {
278
  exit(json_encode(array('error' => $response)));
279
  } else {
280
 
281
- //check and save the keyword serp
282
- $this->checkKeyword($response->keyword);
283
-
284
  $analytics = SQ_ObjController::getBlock('SQ_BlockAnalytics');
285
  $analytics->flush = false;
286
  $analytics->post_id = $this->model->post_id;
@@ -290,6 +293,39 @@ class SQ_PostsList extends SQ_FrontController {
290
  SQ_Tools::setHeader('json');
291
  exit(json_encode($response));
292
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293
  }
294
  }
295
 
@@ -299,44 +335,47 @@ class SQ_PostsList extends SQ_FrontController {
299
  * @param type $keyword
300
  * @return type
301
  */
302
- private function checkKeyword($keyword) {
 
 
303
  if ($keyword == '')
304
  return;
305
 
306
  $ranking = SQ_ObjController::getController('SQ_Ranking', false);
307
  if (is_object($ranking)) {
308
-
309
  $rank = get_transient('sq_rank' . $this->model->post_id);
310
- //if the rank is not in transient
311
  if ($rank === false) {
312
- //get the keyword from database
313
  $json = SQ_ObjController::getModel('SQ_Post')->getKeyword($this->model->post_id);
314
- if (isset($json->rank)) {
315
  $rank = $json->rank;
316
- //add it to transient
317
  set_transient('sq_rank' . $this->model->post_id, $rank, (60 * 60 * 24 * 1));
318
  } else {
319
  $rank = $ranking->processRanking($this->model->post_id, $keyword);
320
 
321
  if ($rank == -1) {
322
- sleep(3);
323
- //if not indexed with the keyword then find the url
324
  if ($ranking->processRanking($this->model->post_id, get_permalink($this->model->post_id)) > 0) { //for permalink index set 0
325
  $rank = 0;
326
  }
327
  }
328
- $args = array();
329
- $args['keyword'] = $keyword;
330
- $args['rank'] = $rank;
331
- $args['country'] = $ranking->getCountry();
332
- $args['language'] = $ranking->getLanguage();
333
- SQ_ObjController::getModel('SQ_Post')->saveKeyword($this->model->post_id, json_decode(json_encode($args)));
334
- //add it to transient
 
 
335
  set_transient('sq_rank' . $this->model->post_id, $rank, (60 * 60 * 24 * 1));
336
  }
337
  }
338
 
339
- //save the rank if there is no error
340
  if ($rank !== false && $rank >= -1) {
341
  $args = array();
342
  $args['post_id'] = $this->model->post_id;
@@ -346,6 +385,7 @@ class SQ_PostsList extends SQ_FrontController {
346
  SQ_Action::apiCall('sq/user-analytics/saveserp', $args);
347
  }
348
  }
 
349
  }
350
 
351
  }
23
  'page_posts',
24
  'edit-product',
25
  'product_posts');
26
+ // do_action('sq_processCron');
27
  }
28
 
29
  public function setPosts($posts) {
163
  var __sq_article_rank = "' . __('SEO Analytics, by Squirrly', _SQ_PLUGIN_NAME_) . '";
164
  var __sq_refresh = "' . __('Update', _SQ_PLUGIN_NAME_) . '"
165
 
 
166
  var __sq_dashurl = "' . _SQ_STATIC_API_URL_ . '";
167
  var __token = "' . SQ_Tools::$options['sq_api'] . '";
168
  var __sq_ranknotpublic_text = "' . __('Not Public', _SQ_PLUGIN_NAME_) . '";
240
  */
241
  public function action() {
242
  parent::action();
 
243
  switch (SQ_Tools::getValue('action')) {
244
  case 'sq_posts_rank':
245
  $args = array();
248
  $posts = SQ_Tools::getValue('posts');
249
  $args['posts'] = join(',', $posts);
250
 
251
+ $response = json_decode(SQ_Action::apiCall('sq/user-analytics/total', $args, 30));
252
  }
253
  if (isset($response) && is_object($response)) {
254
  $response = $this->model->getTotal($response);
256
  exit(json_encode($response));
257
  }
258
  exit(json_encode(array('posts' => array())));
259
+ break;
260
  case 'sq_post_rank':
261
  $args = array();
262
+ $rank = null;
263
  $this->model->post_id = (int) SQ_Tools::getValue('post');
264
  $args['post_id'] = $this->model->post_id;
265
 
266
  if ($json = SQ_ObjController::getModel('SQ_Post')->getKeyword($this->model->post_id)) {
267
  if (isset($json->rank)) {
268
+ $rank = $json->rank;
269
+ } else {
270
+ $rank = get_transient('sq_rank' . $this->model->post_id);
271
+ }
272
+
273
+ if (isset($rank) && $rank !== false) {
274
  $ranking = SQ_ObjController::getController('SQ_Ranking', false);
275
+ $args['rank'] = (string) $rank;
276
  $args['country'] = $ranking->getCountry();
277
  $args['language'] = $ranking->getLanguage();
278
  }
279
  }
280
 
281
+ $response = json_decode(SQ_Action::apiCall('sq/user-analytics/detail', $args, 30));
282
 
283
  if (!is_object($response)) {
284
  exit(json_encode(array('error' => $response)));
285
  } else {
286
 
 
 
 
287
  $analytics = SQ_ObjController::getBlock('SQ_BlockAnalytics');
288
  $analytics->flush = false;
289
  $analytics->post_id = $this->model->post_id;
293
  SQ_Tools::setHeader('json');
294
  exit(json_encode($response));
295
  }
296
+ break;
297
+ case 'sq_recheck':
298
+ if (get_transient('google_blocked') === false) {
299
+ $this->model->post_id = (int) SQ_Tools::getValue('post_id');
300
+ if ($json = SQ_ObjController::getModel('SQ_Post')->getKeyword($this->model->post_id)) {
301
+ if (get_transient('sq_rank' . $this->model->post_id) !== false) {
302
+ delete_transient('sq_rank' . $this->model->post_id);
303
+ }
304
+
305
+ $this->checkKeyword($json->keyword, true);
306
+ $json = SQ_ObjController::getModel('SQ_Post')->getKeyword($this->model->post_id);
307
+ if ($json->rank === false) {
308
+ exit(json_encode(array('error' => true)));
309
+ } else {
310
+ if ($json->rank == -2) {
311
+ $value = __('Could not receive data from google (Err: blocked IP)');
312
+ } elseif ($json->rank == -1) {
313
+ $value = __('> 100');
314
+ } elseif ($json->rank == 0) {
315
+ $value = __('URL Indexed');
316
+ } elseif ($json->rank > 0) {
317
+ $value = '<strong style="display:block; font-size: 120%; width: 100px; margin: 0 auto; text-align:right;">' . sprintf(__('%s'), $json->rank) . '</strong>' . ((isset($json->country)) ? ' (' . $json->country . ')' : '');
318
+ }
319
+ exit(json_encode(array('rank' => $value)));
320
+ }
321
+ }
322
+
323
+ exit(json_encode(array('error' => true)));
324
+ } else {
325
+ $rank = __('Could not receive data from google (Err: blocked IP)');
326
+ exit(json_encode(array('rank' => $rank)));
327
+ }
328
+ break;
329
  }
330
  }
331
 
335
  * @param type $keyword
336
  * @return type
337
  */
338
+ private function checkKeyword($keyword, $force = false) {
339
+ $rank = null;
340
+
341
  if ($keyword == '')
342
  return;
343
 
344
  $ranking = SQ_ObjController::getController('SQ_Ranking', false);
345
  if (is_object($ranking)) {
 
346
  $rank = get_transient('sq_rank' . $this->model->post_id);
347
+ //if the rank is not in transient
348
  if ($rank === false) {
349
+ //get the keyword from database
350
  $json = SQ_ObjController::getModel('SQ_Post')->getKeyword($this->model->post_id);
351
+ if ($force === false && isset($json->rank)) {
352
  $rank = $json->rank;
353
+ //add it to transient
354
  set_transient('sq_rank' . $this->model->post_id, $rank, (60 * 60 * 24 * 1));
355
  } else {
356
  $rank = $ranking->processRanking($this->model->post_id, $keyword);
357
 
358
  if ($rank == -1) {
359
+ sleep(mt_rand(5, 10));
360
+ //if not indexed with the keyword then find the url
361
  if ($ranking->processRanking($this->model->post_id, get_permalink($this->model->post_id)) > 0) { //for permalink index set 0
362
  $rank = 0;
363
  }
364
  }
365
+ if ($rank !== false && $rank >= -1) {
366
+ $args = array();
367
+ $args['keyword'] = $keyword;
368
+ $args['rank'] = $rank;
369
+ $args['country'] = $ranking->getCountry();
370
+ $args['language'] = $ranking->getLanguage();
371
+ SQ_ObjController::getModel('SQ_Post')->saveKeyword($this->model->post_id, json_decode(json_encode($args)));
372
+ }
373
+ //add it to transient
374
  set_transient('sq_rank' . $this->model->post_id, $rank, (60 * 60 * 24 * 1));
375
  }
376
  }
377
 
378
+ //save the rank if there is no error
379
  if ($rank !== false && $rank >= -1) {
380
  $args = array();
381
  $args['post_id'] = $this->model->post_id;
385
  SQ_Action::apiCall('sq/user-analytics/saveserp', $args);
386
  }
387
  }
388
+ return $rank;
389
  }
390
 
391
  }
core/SQ_BlockPostsAnalytics/SQ_BlockPostsAnalytics.php CHANGED
@@ -7,6 +7,7 @@ class SQ_BlockPostsAnalytics extends SQ_BlockController {
7
  ->loadMedia(_SQ_THEME_URL_ . '/css/sq_postslist.css');
8
 
9
  SQ_Tools::saveOptions('sq_analytics', 1); //Save analytics viewed
 
10
  $this->postlist = SQ_ObjController::getController('SQ_PostsList');
11
 
12
  $this->model->prepare_items();
7
  ->loadMedia(_SQ_THEME_URL_ . '/css/sq_postslist.css');
8
 
9
  SQ_Tools::saveOptions('sq_analytics', 1); //Save analytics viewed
10
+ SQ_Tools::saveOptions('sq_dashboard', 1); //Save dashboard viewed
11
  $this->postlist = SQ_ObjController::getController('SQ_PostsList');
12
 
13
  $this->model->prepare_items();
core/SQ_Blocklogin/SQ_Blocklogin.php CHANGED
@@ -83,7 +83,7 @@ class SQ_Blocklogin extends SQ_BlockController {
83
  }
84
  } else {
85
  //if unknown error
86
- $return->error = __('An error occured. Mabe a network error :(', _SQ_PLUGIN_NAME_);
87
  }
88
  } else
89
  $return->error = sprintf(__('Could not send your informations to squirrly. Please register %smanually%s.', _SQ_PLUGIN_NAME_), '<a href="' . _SQ_DASH_URL_ . 'login/?action=register" target="_blank">', '</a>');
83
  }
84
  } else {
85
  //if unknown error
86
+ $return->error = sprintf(__('Error: Couldn\'t connect to host :( . Please contact your site\'s webhost (or webmaster) and request them to add http://api.squirrly.co/ to their IP whitelist.', _SQ_PLUGIN_NAME_), _SQ_API_URL_);
87
  }
88
  } else
89
  $return->error = sprintf(__('Could not send your informations to squirrly. Please register %smanually%s.', _SQ_PLUGIN_NAME_), '<a href="' . _SQ_DASH_URL_ . 'login/?action=register" target="_blank">', '</a>');
core/SQ_Loading/SQ_Loading.php CHANGED
@@ -23,12 +23,12 @@ class SQ_Loading extends SQ_BlockController {
23
  jQuery("#sq_blocklogin").hide();
24
  </script>';
25
  } else {
 
26
  echo '<script type="text/javascript">
27
- var sq_use = "' . SQ_Tools::$options['sq_use'] . '"; var sq_beginner_user = "0"; var sq_baseurl = "' . _SQ_STATIC_API_URL_ . '"; var sq_uri = "' . SQ_URI . '"; var sq_language = "' . get_bloginfo('language') . '"; var sq_version = "' . SQ_VERSION_ID . '"; var sq_wpversion = "' . WP_VERSION_ID . '"; var sq_phpversion = "' . PHP_VERSION_ID . '"; var sq_seoversion = "' . (SQ_Tools::$options['sq_sla'] + 1) . '"; var __postID = "' . $sq_postID . '"; var __token = "' . SQ_Tools::$options['sq_api'] . '";
28
  var sq_keyword_information = "' . ((isset(SQ_Tools::$options['sq_keyword_information'])) ? SQ_Tools::$options['sq_keyword_information'] : '0') . '"; var __noopt = "' . __('You haven`t used Squirrly SEO to optimize your article. Do you want to optimize for a keyword before publishing?', _SQ_PLUGIN_NAME_) . '";
29
  var sq_frontend_css = "' . _SQ_THEME_URL_ . 'css/sq_frontend.css";
30
- var sq_analytics_code = "' . SQ_Tools::$options['sq_analytics_code'] . '";
31
-
32
  if (typeof sq_script === "undefined"){
33
  var sq_script = document.createElement(\'script\');
34
  sq_script.src = "' . _SQ_STATIC_API_URL_ . SQ_URI . '/js/squirrly.js?ver=' . SQ_VERSION_ID . '";
23
  jQuery("#sq_blocklogin").hide();
24
  </script>';
25
  } else {
26
+ $keyword = SQ_ObjController::getModel('SQ_Post')->getKeywordsFromPost($sq_postID);
27
  echo '<script type="text/javascript">
28
+ var sq_use = "' . SQ_Tools::$options['sq_use'] . '"; var sq_beginner_user = "0"; var sq_baseurl = "' . _SQ_STATIC_API_URL_ . '"; var sq_uri = "' . SQ_URI . '"; var sq_language = "' . get_bloginfo('language') . '"; var sq_version = "' . SQ_VERSION_ID . '"; var sq_wpversion = "' . WP_VERSION_ID . '"; var sq_phpversion = "' . PHP_VERSION_ID . '"; var sq_seoversion = "' . (SQ_Tools::$options['sq_sla'] + 1) . '"; var __postID = "' . $sq_postID . '"; var __prevNonce = "' . wp_create_nonce('post_preview_' . $sq_postID) . '"; var __token = "' . SQ_Tools::$options['sq_api'] . '";
29
  var sq_keyword_information = "' . ((isset(SQ_Tools::$options['sq_keyword_information'])) ? SQ_Tools::$options['sq_keyword_information'] : '0') . '"; var __noopt = "' . __('You haven`t used Squirrly SEO to optimize your article. Do you want to optimize for a keyword before publishing?', _SQ_PLUGIN_NAME_) . '";
30
  var sq_frontend_css = "' . _SQ_THEME_URL_ . 'css/sq_frontend.css";
31
+ ' . (($keyword <> '') ? 'var sq_keyword_from_post = "' . $keyword . '";' : '') . '
 
32
  if (typeof sq_script === "undefined"){
33
  var sq_script = document.createElement(\'script\');
34
  sq_script.src = "' . _SQ_STATIC_API_URL_ . SQ_URI . '/js/squirrly.js?ver=' . SQ_VERSION_ID . '";
core/config.xml CHANGED
@@ -5,6 +5,8 @@
5
  <description>Post Page</description>
6
  <actions>
7
  <action>sq_save_meta</action>
 
 
8
  </actions>
9
  <active>1</active>
10
  <path>controllers</path>
@@ -15,6 +17,7 @@
15
  <actions>
16
  <action>sq_posts_rank</action>
17
  <action>sq_post_rank</action>
 
18
  </actions>
19
  <active>1</active>
20
  <path>controllers</path>
5
  <description>Post Page</description>
6
  <actions>
7
  <action>sq_save_meta</action>
8
+ <action>sq_save_ogimage</action>
9
+ <action>sq_get_keyword</action>
10
  </actions>
11
  <active>1</active>
12
  <path>controllers</path>
17
  <actions>
18
  <action>sq_posts_rank</action>
19
  <action>sq_post_rank</action>
20
+ <action>sq_recheck</action>
21
  </actions>
22
  <active>1</active>
23
  <path>controllers</path>
languages/squirrly-seo-ro_RO.mo CHANGED
Binary file
languages/squirrly-seo-ro_RO.po CHANGED
@@ -1,25 +1,22 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: squirrly_seo\n"
4
- "POT-Creation-Date: 2013-06-27 13:43+0200\n"
5
- "PO-Revision-Date: 2013-06-27 13:58+0200\n"
6
  "Last-Translator: Squirrly <contact@squirrly.co>\n"
7
- "Language-Team: Squirrly UK <contact@squirrly.co>\n"
 
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
- "X-Generator: Poedit 1.5.5\n"
12
  "X-Poedit-KeywordsList: __;_e\n"
13
- "X-Poedit-Basepath: d:\\pagini_net\\se_lucreaza\\squirrly\\wordpress\\wp-"
14
- "content\\plugins\\squirrly-seo\n"
 
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
- #: squirrly.php:45
18
- msgid ""
19
- "For Squirrly to work, the PHP version has to be equal or greater then 5.1"
20
- msgstr "Versiunea PHP trebuie sa fie mai mare de 5.1"
21
-
22
- #: classes/SQ_Error.php:20
23
  msgid ""
24
  "Function get_class does not exists! Is required for Squirrly to work "
25
  "properly."
@@ -27,7 +24,7 @@ msgstr ""
27
  "Functia get_class nu exista! E necesara pentru a functiona corect pluginul "
28
  "Squirrly"
29
 
30
- #: classes/SQ_Error.php:23
31
  msgid ""
32
  "Function file_exists does not exists! Is required for Squirrly to work "
33
  "properly."
@@ -35,47 +32,71 @@ msgstr ""
35
  "Functia file_exists nu exista! E necesara pentru a functiona corect pluginul "
36
  "Squirrly"
37
 
38
- #: classes/SQ_Error.php:27
39
  msgid "The home directory is not set!"
40
  msgstr "Directorul home nu este setat!"
41
 
42
- #: classes/SQ_Error.php:31
43
  msgid "The PHP version has to be greater then 4.0"
44
  msgstr "Versiunea PHP trebuie sa fie mai mare de 4.0"
45
 
46
- #: classes/SQ_Error.php:69
47
  msgid "Turn off warnings!"
48
  msgstr "Opreste avertizarile"
49
 
50
- #: classes/SQ_Error.php:70
51
  msgid "Notice: "
52
  msgstr "Atentie:"
53
 
54
- #: classes/SQ_Error.php:74
55
  msgid "Note: "
56
  msgstr "Atentie:"
57
 
58
- #: classes/SQ_Tools.php:82 controllers/SQ_Menu.php:52
59
- msgid "Settings"
60
- msgstr "Setari"
61
-
62
- #: classes/SQ_Tools.php:85 controllers/SQ_Menu.php:35
63
  msgid "Getting started"
64
  msgstr "Ajutor"
65
 
66
- #: classes/SQ_Tools.php:394
 
 
 
 
67
  msgid "Fix it for me!"
68
  msgstr "Repara-l"
69
 
70
- #: classes/SQ_Tools.php:400
71
  msgid "Let Squirrly optimize your SEO automatically (recommended)"
72
  msgstr "Lasa Squirrly sa optimizeze SEO automat (recomandat)"
73
 
74
- #: classes/SQ_Tools.php:408
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  msgid "You're blocking google from indexing your site!"
76
  msgstr "Blochezi accesul la google spre indexarea site-ului"
77
 
78
- #: classes/SQ_Tools.php:414
79
  msgid ""
80
  "It is highly recommended that you include the %postname% variable in the "
81
  "permalink structure. <br />Go to Settings > Permalinks and add /%postname%/ "
@@ -85,121 +106,139 @@ msgstr ""
85
  ">Mergi la Setari > Legaturi permanente si adauga /%postname%/ in campul "
86
  "Structură personalizată"
87
 
88
- #: controllers/SQ_Menu.php:34
 
 
 
 
 
 
89
  msgid " getting started"
90
  msgstr "ajutor"
91
 
92
- #: controllers/SQ_Menu.php:43
93
  msgid " dashboard"
94
  msgstr "dashboard"
95
 
96
- #: controllers/SQ_Menu.php:44
97
- msgid "Dashboard"
98
- msgstr "Dashboard"
 
 
 
 
 
 
 
 
 
 
 
 
 
99
 
100
- #: controllers/SQ_Menu.php:51
101
  msgid " settings"
102
  msgstr "setari"
103
 
104
- #: controllers/SQ_Menu.php:58
 
 
 
 
 
105
  msgid "Make money with "
106
  msgstr "Castiga bani cu"
107
 
108
- #: controllers/SQ_Menu.php:59
109
  msgid "Make money"
110
  msgstr "Castiga Bani"
111
 
112
- #: controllers/SQ_Menu.php:78
113
- msgid "Squirrly Article Rank"
114
- msgstr "Squirrly article rank"
115
-
116
- #: controllers/SQ_PostsList.php:97
117
  msgid "Squirrly"
118
  msgstr "Squirrly"
119
 
120
- #: controllers/SQ_PostsList.php:134
121
  msgid "Custom description: "
122
  msgstr "Descrierea:"
123
 
124
- #: controllers/SQ_PostsList.php:134
125
  msgid "Custom title: "
126
  msgstr "Titlul"
127
 
128
- #: controllers/SQ_PostsList.php:157
129
- msgid "Squirrly article rank"
130
- msgstr "Squirrly article rank"
131
 
132
- #: controllers/SQ_PostsList.php:158 core/SQ_Blockseo/SQ_Blockseo.php:21
133
  msgid "Update"
134
  msgstr "Update"
135
 
136
- #: controllers/SQ_PostsList.php:159
137
- msgid "More details"
138
- msgstr "Mai mult"
139
-
140
- #: controllers/SQ_PostsList.php:160
141
- msgid "Less details"
142
- msgstr "Mai putin"
143
-
144
- #: controllers/SQ_PostsList.php:161
145
- msgid "Interval: "
146
- msgstr "Interval:"
147
-
148
- #: controllers/SQ_PostsList.php:162 models/SQ_PostsList.php:30
149
- msgid "Latest"
150
- msgstr "Ultima"
151
-
152
- #: controllers/SQ_PostsList.php:163 models/SQ_PostsList.php:31
153
- msgid "Last 7 days"
154
- msgstr "Ultimele 7 zile"
155
-
156
- #: controllers/SQ_PostsList.php:164 models/SQ_PostsList.php:32
157
- msgid "Last 30 days"
158
- msgstr "Ultimele 30 zile"
159
-
160
- #: controllers/SQ_PostsList.php:166 core/SQ_Blockrank/SQ_Blockrank.php:19
161
- msgid "See it in 'All Posts'"
162
- msgstr "Arata-l in 'Lista Articole'"
163
-
164
- #: controllers/SQ_PostsList.php:167
165
- msgid "progress"
166
- msgstr "progres"
167
-
168
  #: controllers/SQ_PostsList.php:168
169
- msgid "optimized"
170
- msgstr "optimizat"
171
 
172
  #: controllers/SQ_PostsList.php:169
173
- msgid "See rank"
174
- msgstr "Vezi rang"
175
 
176
- #: controllers/SQ_PostsList.php:170
177
- msgid "Hide rank"
178
- msgstr "Ascunde Rang"
 
179
 
180
- #: controllers/SQ_PostsList.php:171
181
- msgid "Optimize"
182
- msgstr "Optimizare"
183
 
184
- #: controllers/SQ_PostsList.php:173
185
- msgid "Not Public"
186
- msgstr "Ciorna"
 
187
 
188
- #: controllers/SQ_PostsList.php:259 core/SQ_Blockrank/SQ_Blockrank.php:31
189
- msgid "Publish the article to start Squirrly Article Rank"
190
- msgstr "Publica articolul pentru a pornit Squirrly Rank"
 
191
 
192
- #: core/SQ_BlockAffiliate/SQ_BlockAffiliate.php:33
193
  #, php-format
194
  msgid "Error: %s"
195
  msgstr "Eroare: %s"
196
 
197
- #: core/SQ_BlockAffiliate/SQ_BlockAffiliate.php:36
198
- #: core/SQ_Blocklogin/SQ_Blocklogin.php:85
199
  msgid "An error occured. Mabe a network error :("
200
  msgstr "A aparut o eroare. Probabil o eroare de retea :("
201
 
202
- #: core/SQ_Blocklogin/SQ_Blocklogin.php:80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  #, php-format
204
  msgid ""
205
  "We found your email, so it means you already have a Squirrly.co account. "
@@ -210,7 +249,7 @@ msgstr ""
210
  "Conecteaza-te cu contul tau de Squirrly. Daca ai uitat parola atunci apasa "
211
  "%saici%s"
212
 
213
- #: core/SQ_Blocklogin/SQ_Blocklogin.php:88
214
  #, php-format
215
  msgid ""
216
  "Could not send your informations to squirrly. Please register %smanually%s."
@@ -233,166 +272,145 @@ msgstr "A aparut o eroare."
233
  msgid "Both fields are required."
234
  msgstr "Ambele campuri sunt obligatorii!"
235
 
236
- #: core/SQ_Blockresearch/SQ_Blockresearch.php:12
237
  msgid "Recent discussions:"
238
  msgstr "Discutii recente:"
239
 
240
- #: core/SQ_Blockresearch/SQ_Blockresearch.php:12
241
  msgid "Exact search:"
242
  msgstr "Cautari exacte:"
243
 
244
- #: core/SQ_Blockresearch/SQ_Blockresearch.php:12
245
  msgid "Competition:"
246
  msgstr "Competitia:"
247
 
248
- #: core/SQ_Blockresearch/SQ_Blockresearch.php:12
249
  msgid "Trend:"
250
  msgstr "Trend:"
251
 
252
- #: core/SQ_Blocksearch/SQ_Blocksearch.php:51
253
  msgid "date"
254
  msgstr "data"
255
 
256
- #: core/SQ_Blocksearch/SQ_Blocksearch.php:51
257
  msgid "Read it!"
258
  msgstr "Citeste!"
259
 
260
- #: core/SQ_Blocksearch/SQ_Blocksearch.php:51
261
  msgid "Insert it!"
262
  msgstr "Adauga!"
263
 
264
- #: core/SQ_Blocksearch/SQ_Blocksearch.php:51
265
  msgid "Reference"
266
  msgstr "Referinta"
267
 
268
- #: core/SQ_Blocksearch/SQ_Blocksearch.php:51
269
  msgid "Insert as box"
270
  msgstr "Adauga"
271
 
272
- #: core/SQ_Blocksearch/SQ_Blocksearch.php:51
273
  msgid "Not relevant?"
274
  msgstr "Nu e ce doresti?"
275
 
276
- #: core/SQ_Blocksearch/SQ_Blocksearch.php:51
277
  msgid "Insert in your article"
278
  msgstr "Adauga paragraf in articol"
279
 
280
- #: core/SQ_Blocksearch/SQ_Blocksearch.php:51
281
  msgid "For Squirrly to work, you have to have tinymce editor installed!"
282
  msgstr ""
283
  "Pentru ca Squirrly sa functioneze, trebuie sa ai editorul TinyMCE instalat"
284
 
285
- #: core/SQ_Blocksearch/SQ_Blocksearch.php:51
286
  msgid ":( I lost my squirrel. Please reload the page."
287
  msgstr ":( Am pierdut veverita. Te rog sa dai refresh la pagina."
288
 
289
- #: core/SQ_Blocksearch/SQ_Blocksearch.php:51
290
  msgid "No results found!"
291
  msgstr "Nu s-a gasit nimic ..."
292
 
293
- #: core/SQ_Blocksearch/SQ_Blocksearch.php:51
294
  msgid "Switch to Visual editor!"
295
  msgstr "Schimba in Editor Vizual!"
296
 
297
- #: core/SQ_Blocksearch/SQ_Blocksearch.php:51
298
  msgid "Use more words in one keyword"
299
  msgstr "Am mai multe cuvinte"
300
 
301
- #: core/SQ_Blocksearch/SQ_Blocksearch.php:51
302
  msgid "Takes too long to check this keyword ..."
303
  msgstr "Ia prea mult timp sa verifice cuvantul ..."
304
 
305
- #: core/SQ_Blocksearch/SQ_Blocksearch.php:51
306
  msgid "Do a research!"
307
  msgstr "Mai multe detalii!"
308
 
309
- #: core/SQ_Blocksearch/SQ_Blocksearch.php:51
310
  msgid "Do more research!"
311
  msgstr "Mai multe detalii!"
312
 
313
- #: core/SQ_Blocksearch/SQ_Blocksearch.php:51
314
  #, php-format
315
  msgid "[ ATTRIBUTE: Please check: %s to find out how to attribute this image ]"
316
  msgstr ""
317
  "[ ATTRIBUTE: Verificati: %s pentru a vedea conditile de atribuire a "
318
  "imaginii ]"
319
 
320
- #: core/SQ_Blocksearch/SQ_Blocksearch.php:51
321
  msgid "Has creative commons attributes"
322
  msgstr "Are conditii de atribuire"
323
 
324
- #: core/SQ_Blocksearch/SQ_Blocksearch.php:51
325
  msgid "No known copyright restrictions"
326
  msgstr "Nu sunt restrictii de copyright cunoscute"
327
 
328
- #: core/SQ_Blockseo/SQ_Blockseo.php:11
329
  msgid "Save changes"
330
  msgstr "Salveaza"
331
 
332
- #: core/SQ_Blockseo/SQ_Blockseo.php:12
333
  msgid "Cancel"
334
  msgstr "Renunta"
335
 
336
- #: core/SQ_Blockseo/SQ_Blockseo.php:13
337
  msgid "Reset"
338
  msgstr "Resetare"
339
 
340
- #: core/SQ_Blockseo/SQ_Blockseo.php:15
341
- msgid "Customize Title"
 
342
  msgstr "Modificare META"
343
 
344
- #: core/SQ_Blockseo/SQ_Blockseo.php:16
345
  msgid "manage keywords"
346
  msgstr "administrare cuvinte cheie"
347
 
348
- #: core/SQ_Blockseo/SQ_Blockseo.php:17 themes/default/SQ_Menu.php:327
349
  msgid "Too short"
350
  msgstr "Prea scurt"
351
 
352
- #: core/SQ_Blockseo/SQ_Blockseo.php:18 themes/default/SQ_Menu.php:328
353
  msgid "Too long"
354
  msgstr "Prea lung"
355
 
356
- #: core/SQ_Blockseo/SQ_Blockseo.php:20 themes/default/SQ_Menu.php:214
357
  msgid "Squirrly Snippet"
358
  msgstr "Snipet Squirrly"
359
 
360
- #: core/SQ_Blockseo/SQ_Blockseo.php:22
 
 
 
 
361
  msgid ""
362
  "Click the Update button (to the right) to see the snippet from your website."
363
  msgstr "Click pe butonul Update pentru a vedea snipetul site-ului"
364
 
365
- #: core/SQ_Blockseo/SQ_Blockseo.php:23
366
  msgid "Enter a title above for the snippet to get data."
367
  msgstr "Adauga un titlu pentru a putea vedea datele in snipet"
368
 
369
- #: core/SQ_BlockSupport/SQ_BlockSupport.php:21
370
- msgid "Plugin Feedback"
371
- msgstr "Feedback Squirrly"
372
-
373
- #: core/SQ_BlockSupport/SQ_BlockSupport.php:57
374
- msgid "Thank you for your feedback"
375
- msgstr "Multumesc pentru feedback"
376
-
377
- #: core/SQ_BlockSupport/SQ_BlockSupport.php:59
378
- #: core/SQ_BlockSupport/SQ_BlockSupport.php:94
379
- msgid "Could not send the email..."
380
- msgstr "Nu s-a putut trimite email ..."
381
-
382
- #: core/SQ_BlockSupport/SQ_BlockSupport.php:62
383
- #: core/SQ_BlockSupport/SQ_BlockSupport.php:97
384
- msgid "No message."
385
- msgstr "Nici un mesaj."
386
-
387
- #: core/SQ_BlockSupport/SQ_BlockSupport.php:81
388
- msgid "Plugin Support"
389
- msgstr "Suport la plugin"
390
-
391
- #: core/SQ_BlockSupport/SQ_BlockSupport.php:92
392
- msgid "Message sent..."
393
- msgstr "Mesajul a fost trimis..."
394
-
395
- #: core/SQ_Loading/SQ_Loading.php:23
396
  msgid ""
397
  "For Squirrly to work properly you have to use a higher version of Internet "
398
  "Explorer. <br /> We recommend you to use Chrome or Mozilla."
@@ -400,7 +418,7 @@ msgstr ""
400
  "Pentru a functiona Squirrly, trebui sa folosesti o versiune mai noua de "
401
  "Internet explorer. <br /> Recomandam sa folosesti Chrome sau Mozilla."
402
 
403
- #: core/SQ_Loading/SQ_Loading.php:30
404
  msgid ""
405
  "You haven`t used Squirrly SEO to optimize your article. Do you want to "
406
  "optimize for a keyword before publishing?"
@@ -408,208 +426,390 @@ msgstr ""
408
  "Nu ai folosit Squirrly SEO pentru a optimiza articolul. Vrei sa il "
409
  "optimizezi inainte de publicare?"
410
 
411
- #: models/SQ_Menu.php:139