Version Description
- Changed Squirrly look
- Compatible with WP eCommerce plugin
- Made SEO improvements for Woocommerce plugin
- Interactive learning for the entire Squirrly SEO plugin
- Faster post save for long text and remote images
- Settings and SEO check improved
- Added robots.txt for multisites with security
- Added sitemap for multisites
- Added sitemap for images and videos for each article
- Added the Json LD in Structured Data META
- Added the social linked Data for Json LD and publisher
- Added the favicon.ico for multisites
- Added the icos for apple devices
- Added the SEO progress in post editor
- Added the SEO Star option in Dashboard
- Fixed bugs for multisites and made it compatible with WP 4.2
- Fixed the snippet title and description special chars
- Fixed the custom fields variable in post editor
- Fixed the site icon and added the site icon for multisites
- Fixed Sitemap for default permalink option
Download this release
Release Info
Developer | cifi |
Plugin | SEO SQUIRRLY™ |
Version | 5.0.0 |
Comparing to | |
See all releases |
Code changes from version 3.4.4 to 5.0.0
- classes/SQ_Action.php +2 -4
- classes/SQ_BlockController.php +12 -0
- classes/SQ_Error.php +14 -7
- classes/SQ_FrontController.php +0 -3
- classes/SQ_HookController.php +0 -7
- classes/SQ_Ranking.php +2 -2
- classes/SQ_Sitemap.php +0 -382
- classes/SQ_Tools.php +246 -118
- config/config.php +3 -1
- controllers/SQ_Frontend.php +80 -11
- controllers/SQ_Menu.php +106 -261
- controllers/SQ_Post.php +36 -22
- controllers/SQ_PostsList.php +6 -2
- controllers/SQ_Sitemaps.php +417 -0
- core/SQ_BlockAccount/SQ_BlockAccount.php +2 -8
- core/SQ_BlockAffiliate/SQ_BlockAffiliate.php +4 -4
- core/SQ_BlockAudit/SQ_BlockAudit.php +0 -9
- core/SQ_BlockDashboard/SQ_BlockDashboard.php +4 -0
- core/SQ_BlockPostsAnalytics/SQ_BlockPostsAnalytics.php +1 -0
- core/SQ_BlockSettings/SQ_BlockSettings.php +63 -0
- core/SQ_BlockSettingsSeo/SQ_BlockSettingsSeo.php +267 -0
- core/SQ_BlockStatus/SQ_BlockStatus.php +0 -11
- core/SQ_Blockseo/SQ_Blockseo.php +3 -2
- core/config.xml +10 -9
- languages/squirrly-seo-ru_RU.mo +0 -0
- languages/squirrly-seo-ru_RU.po +0 -1193
- models/SQ_BlockSettingsSeo.php +348 -0
- models/SQ_BlockStatus.php +0 -158
- models/SQ_Blockseo.php +3 -3
- models/SQ_Frontend.php +525 -450
- models/SQ_Ico.php +20 -8
- models/SQ_Menu.php +0 -245
- models/SQ_Post.php +5 -5
- models/SQ_Sitemaps.php +443 -0
- readme.txt +28 -5
- squirrly.php +3 -5
- themes/default/SQ_BlocStatus.php +0 -1
- themes/default/SQ_BlockAccount.php +23 -30
- themes/default/SQ_BlockAffiliate.php +88 -90
- themes/default/SQ_BlockAnalytics.php +17 -10
- themes/default/SQ_BlockAudit.php +0 -9
- themes/default/SQ_BlockDashboard.php +87 -47
- themes/default/SQ_BlockHelp.php +0 -36
- themes/default/SQ_BlockSettings.php +290 -0
- themes/default/SQ_BlockSettingsSeo.php +501 -0
- themes/default/SQ_Blocklogin.php +2 -4
- themes/default/SQ_Blocksearch.php +1 -1
- themes/default/SQ_Menu.php +0 -536
- themes/default/SQ_notices.php +14 -1
- themes/default/css/sq_blockaccount.css +26 -0
- themes/default/css/sq_blockaudit.css +0 -1
- themes/default/css/sq_blockdashboard.css +117 -0
- themes/default/css/sq_blockresearch.css +443 -1
- themes/default/css/sq_blocksearch.css +1004 -1
- themes/default/css/sq_blockseo.css +500 -1
- themes/default/css/sq_blocksettings.css +37 -0
- themes/default/css/sq_blocksettingsseo.css +175 -0
- themes/default/css/sq_frontend.css +126 -1
- themes/default/css/sq_global.css +414 -1
- themes/default/css/sq_menu.css +890 -1
- themes/default/css/sq_post.css +398 -1
- themes/default/css/sq_postslist.css +622 -1
- themes/default/css/sq_sitemap.xsl +97 -0
- themes/default/css/sq_sitemapindex.xsl +61 -0
- themes/default/img/avatar-margin.png +0 -0
- themes/default/img/banners/banner1.jpg +0 -0
- themes/default/img/banners/banner2.jpg +0 -0
- themes/default/img/banners/banner3.png +0 -0
- themes/default/img/complete.png +0 -0
- themes/default/img/dashboard_analytics.png +0 -0
- themes/default/img/dashboard_assistant.png +0 -0
- themes/default/img/dashboard_audit.png +0 -0
- themes/default/img/dashboard_research.png +0 -0
- themes/default/img/editor/complete.png +0 -0
- themes/default/img/editor/heading.png +0 -0
- themes/default/img/{sq_searching.gif → editor/sq_searching.gif} +0 -0
- themes/default/img/front/avatar-margin.png +0 -0
- themes/default/img/header_back.png +0 -0
- themes/default/img/header_stars.png +0 -0
- themes/default/img/heading.png +0 -0
- themes/default/img/loading.gif +0 -0
- themes/default/img/menu_icon_16.png +0 -0
- themes/default/img/minloading.gif +0 -0
- themes/default/img/minloading.png +0 -0
- themes/default/img/settings/facebook.png +0 -0
- themes/default/img/settings/facebook_tmb.png +0 -0
- themes/default/img/settings/googlejsonld.png +0 -0
- themes/default/img/settings/googlejsonld_tmb.png +0 -0
- themes/default/img/settings/header_stars.png +0 -0
- themes/default/img/{settings_login.jpg → settings/login.jpg} +0 -0
- themes/default/img/{settings_login_done.jpg → settings/login_done.jpg} +0 -0
- themes/default/img/settings/menu_icon_16.png +0 -0
- themes/default/img/settings/squirrly.png +0 -0
- themes/default/img/settings/twitter.png +0 -0
- themes/default/img/settings/twitter_tmb.png +0 -0
- themes/default/img/settings_edit.png +0 -0
- themes/default/img/settings_howto.jpg +0 -0
- themes/default/img/sprite.png +0 -0
- themes/default/img/status/backgroundv2.jpg +0 -0
- themes/default/img/status/squirrly_cheers.png +0 -0
- themes/default/js/sq_blockaudit.js +0 -3
- themes/default/js/sq_blockdashboard.js +26 -0
- themes/default/js/sq_blocklogin.js +230 -23
- themes/default/js/sq_blocksettings.js +58 -0
- themes/default/js/sq_blocksettingsseo.js +302 -0
- themes/default/js/sq_blocksupport.js +240 -15
- themes/default/js/sq_menu.js +344 -37
- themes/default/js/tinymce.js +20 -1
- uninstall.php +0 -1
classes/SQ_Action.php
CHANGED
@@ -35,7 +35,6 @@ class SQ_Action extends SQ_FrontController {
|
|
35 |
if (isset($_SERVER['PHP_SELF']) && strpos($_SERVER['PHP_SELF'], '/admin-ajax.php') !== false) {
|
36 |
return;
|
37 |
}
|
38 |
-
|
39 |
$this->actions = array();
|
40 |
$this->getActions(((isset($_GET['action']) ? $_GET['action'] : (isset($_POST['action']) ? $_POST['action'] : ''))));
|
41 |
}
|
@@ -129,10 +128,9 @@ class SQ_Action extends SQ_FrontController {
|
|
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' =>
|
136 |
'versq' => SQ_VERSION_ID,
|
137 |
'verwp' => WP_VERSION_ID,
|
138 |
'verphp' => PHP_VERSION_ID,
|
@@ -165,7 +163,7 @@ class SQ_Action extends SQ_FrontController {
|
|
165 |
|
166 |
$url = self::cleanUrl(_SQ_API_URL_ . $module . "?" . $parameters);
|
167 |
//SQ_Tools::dump($url);
|
168 |
-
return SQ_Tools::sq_remote_get($url, array('timeout' => $timeout));
|
169 |
}
|
170 |
|
171 |
/**
|
35 |
if (isset($_SERVER['PHP_SELF']) && strpos($_SERVER['PHP_SELF'], '/admin-ajax.php') !== false) {
|
36 |
return;
|
37 |
}
|
|
|
38 |
$this->actions = array();
|
39 |
$this->getActions(((isset($_GET['action']) ? $_GET['action'] : (isset($_POST['action']) ? $_POST['action'] : ''))));
|
40 |
}
|
128 |
if (SQ_Tools::$options['sq_api'] == '' && $module <> 'sq/login' && $module <> 'sq/register') {
|
129 |
return false;
|
130 |
}
|
|
|
131 |
|
132 |
$extra = array('user_url' => urlencode(get_bloginfo('wpurl')),
|
133 |
+
'lang' => (defined('WPLANG') ? WPLANG : 'en_US'),
|
134 |
'versq' => SQ_VERSION_ID,
|
135 |
'verwp' => WP_VERSION_ID,
|
136 |
'verphp' => PHP_VERSION_ID,
|
163 |
|
164 |
$url = self::cleanUrl(_SQ_API_URL_ . $module . "?" . $parameters);
|
165 |
//SQ_Tools::dump($url);
|
166 |
+
return SQ_Tools::sq_remote_get($url, array(), array('timeout' => $timeout));
|
167 |
}
|
168 |
|
169 |
/**
|
classes/SQ_BlockController.php
CHANGED
@@ -56,6 +56,18 @@ class SQ_BlockController {
|
|
56 |
return $this->view->echoBlock($this);
|
57 |
}
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
/**
|
60 |
* This function is called from Ajax class as a wp_ajax_action
|
61 |
*
|
56 |
return $this->view->echoBlock($this);
|
57 |
}
|
58 |
|
59 |
+
public function preloadSettings() {
|
60 |
+
|
61 |
+
echo '<script type="text/javascript">
|
62 |
+
var __blog_url = "' . get_bloginfo('url') . '";
|
63 |
+
var __token = "' . SQ_Tools::$options['sq_api'] . '";
|
64 |
+
var __api_url = "' . _SQ_API_URL_ . '";
|
65 |
+
jQuery(document).ready(function () {
|
66 |
+
sq_getHelp("' . str_replace("sq_block", "", strtolower($this->name)) . '", "content");
|
67 |
+
});
|
68 |
+
</script>';
|
69 |
+
}
|
70 |
+
|
71 |
/**
|
72 |
* This function is called from Ajax class as a wp_ajax_action
|
73 |
*
|
classes/SQ_Error.php
CHANGED
@@ -55,16 +55,24 @@ class SQ_Error extends SQ_FrontController {
|
|
55 |
die();
|
56 |
break;
|
57 |
case 'settings':
|
58 |
-
if (isset(SQ_Tools::$options['ignore_warn']) && SQ_Tools::$options['ignore_warn'] == 1)
|
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(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
break;
|
65 |
default:
|
66 |
|
67 |
-
self::showError(
|
68 |
}
|
69 |
}
|
70 |
self::$errors = array();
|
@@ -75,8 +83,7 @@ class SQ_Error extends SQ_FrontController {
|
|
75 |
*
|
76 |
* @return void
|
77 |
*/
|
78 |
-
public static function showError($message, $id = '') {
|
79 |
-
$type = 'sq_error';
|
80 |
|
81 |
if (file_exists(_SQ_THEME_DIR_ . 'SQ_notices.php')) {
|
82 |
include (_SQ_THEME_DIR_ . 'SQ_notices.php');
|
55 |
die();
|
56 |
break;
|
57 |
case 'settings':
|
|
|
|
|
|
|
58 |
/* switch off option for notifications */
|
59 |
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>";
|
60 |
+
self::showError("<span class='sq_notice_author'>" . _SQ_PLUGIN_NAME_ . "</span> " . $error['text'] . " ", $error['id']);
|
61 |
+
break;
|
62 |
+
|
63 |
+
case 'helpnotice':
|
64 |
+
if (isset(SQ_Tools::$options['ignore_warn']) && SQ_Tools::$options['ignore_warn'] == 1) {
|
65 |
+
break;
|
66 |
+
}
|
67 |
+
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'); } });\" >" . __("Don't bother me!", _SQ_PLUGIN_NAME_) . "</a>";
|
68 |
+
self::showError("<span class='sq_notice_author'>" . _SQ_PLUGIN_NAME_ . "</span> " . $error['text'] . " " . self::$switch_off, $error['id'], 'sq_helpnotice');
|
69 |
+
break;
|
70 |
+
case 'success':
|
71 |
+
self::showError("<span class='sq_notice_author'>" . _SQ_PLUGIN_NAME_ . "</span> " . $error['text'] . " ", $error['id'], 'sq_success');
|
72 |
break;
|
73 |
default:
|
74 |
|
75 |
+
self::showError("<span class='sq_notice_author'>" . _SQ_PLUGIN_NAME_ . "</span> " . $error['text'], $error['id']);
|
76 |
}
|
77 |
}
|
78 |
self::$errors = array();
|
83 |
*
|
84 |
* @return void
|
85 |
*/
|
86 |
+
public static function showError($message, $id = '', $type = 'sq_error') {
|
|
|
87 |
|
88 |
if (file_exists(_SQ_THEME_DIR_ . 'SQ_notices.php')) {
|
89 |
include (_SQ_THEME_DIR_ . 'SQ_notices.php');
|
classes/SQ_FrontController.php
CHANGED
@@ -86,9 +86,6 @@ class SQ_FrontController {
|
|
86 |
|
87 |
/* show the admin menu and post actions */
|
88 |
$this->loadMenu();
|
89 |
-
|
90 |
-
/* Load the Sitemap Generator */
|
91 |
-
SQ_ObjController::getController('SQ_Sitemap', false);
|
92 |
}
|
93 |
|
94 |
/**
|
86 |
|
87 |
/* show the admin menu and post actions */
|
88 |
$this->loadMenu();
|
|
|
|
|
|
|
89 |
}
|
90 |
|
91 |
/**
|
classes/SQ_HookController.php
CHANGED
@@ -14,16 +14,9 @@ class SQ_HookController {
|
|
14 |
$this->admin_hooks = array('init' => 'admin_init',
|
15 |
'head' => 'admin_head',
|
16 |
'footer' => 'admin_footer',
|
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',
|
24 |
'notices' => 'admin_notices',
|
25 |
-
'shutdown' => 'shutdown',
|
26 |
-
'fronttitletheme' => 'thematic_doctitle',
|
27 |
'frontinit' => 'init',
|
28 |
'fronthead' => 'wp_head',
|
29 |
'frontfooter' => 'wp_footer',
|
14 |
$this->admin_hooks = array('init' => 'admin_init',
|
15 |
'head' => 'admin_head',
|
16 |
'footer' => 'admin_footer',
|
|
|
17 |
'menu' => 'admin_menu',
|
|
|
18 |
'preload' => 'template_redirect',
|
|
|
|
|
|
|
19 |
'notices' => 'admin_notices',
|
|
|
|
|
20 |
'frontinit' => 'init',
|
21 |
'fronthead' => 'wp_head',
|
22 |
'frontfooter' => 'wp_footer',
|
classes/SQ_Ranking.php
CHANGED
@@ -170,13 +170,13 @@ class SQ_Ranking extends SQ_FrontController {
|
|
170 |
//check 20 keyword at one time
|
171 |
$sql = "SELECT `post_id`, `meta_value`
|
172 |
FROM `" . $wpdb->postmeta . "`
|
173 |
-
WHERE (`meta_key` = '
|
174 |
ORDER BY `post_id` DESC";
|
175 |
|
176 |
if ($rows = $wpdb->get_results($sql)) {
|
177 |
$count = 0;
|
178 |
foreach ($rows as $row) {
|
179 |
-
if ($count >
|
180 |
break; //check only 10 keywords at the time
|
181 |
}
|
182 |
if ($row->meta_value <> '') {
|
170 |
//check 20 keyword at one time
|
171 |
$sql = "SELECT `post_id`, `meta_value`
|
172 |
FROM `" . $wpdb->postmeta . "`
|
173 |
+
WHERE (`meta_key` = '_sq_post_keyword')
|
174 |
ORDER BY `post_id` DESC";
|
175 |
|
176 |
if ($rows = $wpdb->get_results($sql)) {
|
177 |
$count = 0;
|
178 |
foreach ($rows as $row) {
|
179 |
+
if ($count > SQ_Tools::$options['sq_google_ranksperhour']) {
|
180 |
break; //check only 10 keywords at the time
|
181 |
}
|
182 |
if ($row->meta_value <> '') {
|
classes/SQ_Sitemap.php
DELETED
@@ -1,382 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class for Sitemap Generator
|
5 |
-
*/
|
6 |
-
class SQ_Sitemap extends SQ_FrontController {
|
7 |
-
/* @var string file path */
|
8 |
-
|
9 |
-
var $file;
|
10 |
-
var $opt = array();
|
11 |
-
var $data = array();
|
12 |
-
var $args = array();
|
13 |
-
var $posts_limit = 0;
|
14 |
-
|
15 |
-
public function __construct() {
|
16 |
-
if (!isset(SQ_Tools::$options['sq_use']) || SQ_Tools::$options['sq_use'] == 0)
|
17 |
-
return;
|
18 |
-
if (isset(SQ_Tools::$options['sq_auto_sitemap']) && SQ_Tools::$options['sq_auto_sitemap'] == 0)
|
19 |
-
return;
|
20 |
-
|
21 |
-
$this->filename = 'sitemap.xml';
|
22 |
-
|
23 |
-
$this->file = ABSPATH . $this->filename;
|
24 |
-
//For sitemap ping
|
25 |
-
$this->args['timeout'] = 5;
|
26 |
-
$this->opt = array('home' => array(1, 'daily'),
|
27 |
-
'page' => array(0.6, 'monthly'),
|
28 |
-
'post' => array(0.8, 'weekly'),
|
29 |
-
'static' => array(0.6, 'weekly'),
|
30 |
-
'category' => array(0.4, 'monthly'),
|
31 |
-
'archive' => array(0.3, 'weekly'),
|
32 |
-
'oldarchive' => array(0.3, 'monthly'),
|
33 |
-
'tag' => array(0.3, 'weekly'),
|
34 |
-
'author' => array(0.3, 'monthly'),
|
35 |
-
);
|
36 |
-
|
37 |
-
//Existing posts was deleted
|
38 |
-
add_action('delete_post', array($this, 'generateSitemap'), 9999, 1);
|
39 |
-
//Existing post was published
|
40 |
-
add_action('publish_post', array($this, 'generateSitemap'), 9999, 1);
|
41 |
-
//Existing page was published
|
42 |
-
add_action('publish_page', array($this, 'generateSitemap'), 9999, 1);
|
43 |
-
}
|
44 |
-
|
45 |
-
public function init() {
|
46 |
-
return;
|
47 |
-
}
|
48 |
-
|
49 |
-
public function action() {
|
50 |
-
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Generate the XML sitemap for google
|
55 |
-
*/
|
56 |
-
public function generateSitemap() {
|
57 |
-
global $wpdb, $wp_query, $wp_version;
|
58 |
-
/* get the home url */
|
59 |
-
$home = get_bloginfo('url');
|
60 |
-
$homeID = 0;
|
61 |
-
$wpCompat = (floatval($wp_version) < 2.1);
|
62 |
-
|
63 |
-
/* If the site starts with a page */
|
64 |
-
if (get_option('show_on_front') == 'page' && get_option('page_on_front')) {
|
65 |
-
$page = get_page(get_option('page_on_front'));
|
66 |
-
if ($page) {
|
67 |
-
$homeID = $page->ID;
|
68 |
-
$lastmod = ($page->post_modified_gmt && $page->post_modified_gmt != '0000-00-00 00:00:00' ? $page->post_modified_gmt : $page->post_date_gmt);
|
69 |
-
$this->addLine($home, $this->getTimestamp($lastmod), $this->opt['home'][1], $this->opt['home'][0]);
|
70 |
-
}
|
71 |
-
} else
|
72 |
-
$this->addLine($home, $this->getTimestamp(get_lastpostmodified('GMT')), $this->opt['home'][1], $this->opt['home'][0]);
|
73 |
-
|
74 |
-
/* * ******************************************************************** */
|
75 |
-
//Add the pages
|
76 |
-
$query = array();
|
77 |
-
|
78 |
-
/* CREATE QUERY */
|
79 |
-
$query['what'] = "`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_status`, `post_name`, `post_modified`, `post_modified_gmt`, `post_parent`, `post_type` ";
|
80 |
-
|
81 |
-
/* from */
|
82 |
-
$query['from'] = " `" . $wpdb->posts . "` ";
|
83 |
-
/* where */
|
84 |
-
$query['where'] = '(';
|
85 |
-
|
86 |
-
|
87 |
-
if ($wpCompat)
|
88 |
-
$query['where'] .= "(post_status = 'publish' AND post_date_gmt <= '" . gmdate('Y-m-d H:i:59') . "')";
|
89 |
-
else
|
90 |
-
$query['where'] .= "(post_status = 'publish' AND (post_type = 'post' OR post_type = '')) ";
|
91 |
-
|
92 |
-
$query['where'] .= " OR ";
|
93 |
-
if ($wpCompat)
|
94 |
-
$query['where'] .= " post_status='static' ";
|
95 |
-
else
|
96 |
-
$query['where'] .= " (post_status = 'publish' AND post_type = 'page') ";
|
97 |
-
|
98 |
-
$query['where'] .= ") ";
|
99 |
-
$query['where'] .= " AND post_password=''";
|
100 |
-
/* order */
|
101 |
-
$query['order'] = " ORDER BY post_modified DESC";
|
102 |
-
/* limit */
|
103 |
-
$query['limit'] = ((int) $this->posts_limit > 0) ? " LIMIT 0," . $this->posts_limit : '';
|
104 |
-
|
105 |
-
|
106 |
-
$posts = $wpdb->get_results('SELECT ' . $query['what'] . ' FROM ' . $query['from'] . ' WHERE ' . $query['where'] . ' ' . $query['order'] . ' ' . $query['limit'] . ' ');
|
107 |
-
if (!$posts) {
|
108 |
-
trigger_error(ucfirst(_SQ_PLUGIN_NAME_) . " failed to connect to database: " . mysql_error(), E_USER_NOTICE); //E_USER_NOTICE will be displayed on our debug mode
|
109 |
-
return;
|
110 |
-
}
|
111 |
-
|
112 |
-
/* loop */
|
113 |
-
foreach ($posts as $post) {
|
114 |
-
$out = array();
|
115 |
-
$permalink = get_permalink($post->ID);
|
116 |
-
if ($permalink != $home && $post->ID != $homeID) {
|
117 |
-
|
118 |
-
$isPage = false;
|
119 |
-
if ($wpCompat)
|
120 |
-
$isPage = ($post->post_status == 'static');
|
121 |
-
else
|
122 |
-
$isPage = ($post->post_type == 'page');
|
123 |
-
|
124 |
-
if ($isPage) {
|
125 |
-
$out['priority'] = $this->opt['page'][0];
|
126 |
-
$out['changefreq'] = $this->opt['page'][1];
|
127 |
-
} else {
|
128 |
-
$out['priority'] = $this->opt['post'][0];
|
129 |
-
$out['changefreq'] = $this->opt['post'][1];
|
130 |
-
}
|
131 |
-
$out['lastmod'] = ($post->post_modified_gmt && $post->post_modified_gmt != '0000-00-00 00:00:00' ? $post->post_modified_gmt : $post->post_date_gmt);
|
132 |
-
|
133 |
-
//Add it
|
134 |
-
$this->addLine($permalink, $this->getTimestamp($out['lastmod']), $out['changefreq'], $out['priority']);
|
135 |
-
|
136 |
-
$subPage = '';
|
137 |
-
if (isset($post->postPages) > 0)
|
138 |
-
for ($i = 1; $i <= $post->postPages; $i++) {
|
139 |
-
if (get_option('permalink_structure') == '') {
|
140 |
-
$subPage = $permalink . '&page=' . ($p + 1);
|
141 |
-
} else {
|
142 |
-
$subPage = trailingslashit($permalink) . user_trailingslashit($p + 1, 'single_paged');
|
143 |
-
}
|
144 |
-
|
145 |
-
$this->addLine($subPage, $this->getTimestamp($out['lastmod']), $out['changefreq'], $out['priority']);
|
146 |
-
}
|
147 |
-
}
|
148 |
-
}
|
149 |
-
|
150 |
-
/* * ******************************************************************** */
|
151 |
-
/* Add links ftom categories */
|
152 |
-
if (!$this->IsTaxonomySupported()) {
|
153 |
-
$query = array();
|
154 |
-
|
155 |
-
/* CREATE QUERY */
|
156 |
-
$query['what'] = "c.cat_ID AS ID, MAX(p.post_modified_gmt) AS last_mod";
|
157 |
-
$query['from'] = "`" . $wpdb->categories . "` c, `" . $wpdb->post2cat . "` pc, `" . $wpdb->posts . "` p";
|
158 |
-
$query['where'] = "pc.category_id = c.cat_ID AND p.ID = pc.post_id AND p.post_status = 'publish' AND p.post_type='post'";
|
159 |
-
$query['order'] = "";
|
160 |
-
$query['limit'] = "";
|
161 |
-
$query['group'] = "GROUP BY c.cat_id";
|
162 |
-
|
163 |
-
$categories = $wpdb->get_results("SELECT " . $query['what'] . " FROM " . $query['from'] . " WHERE " . $query['where'] . " " . $query['order'] . " " . $query['group'] . " " . $query['limit'] . "");
|
164 |
-
|
165 |
-
if ($categories) {
|
166 |
-
foreach ($categories as $category) {
|
167 |
-
if ($category && $category->ID && $category->ID > 0) {
|
168 |
-
$this->addLine(get_category_link($category->ID), $this->getTimestamp($category->last_mod), $this->opt['category'][1], $this->opt['category'][0]);
|
169 |
-
}
|
170 |
-
}
|
171 |
-
}
|
172 |
-
} else {
|
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 |
-
}
|
180 |
-
|
181 |
-
/* * ******************************************************************** */
|
182 |
-
//Add the archives
|
183 |
-
$now = current_time('mysql');
|
184 |
-
$query = array();
|
185 |
-
|
186 |
-
/* CREATE QUERY */
|
187 |
-
$query['what'] = 'YEAR(post_date_gmt) AS `year`, MONTH(post_date_gmt) AS `month`, MAX(post_date_gmt) as last_mod, count(ID) as posts';
|
188 |
-
$query['from'] = "`" . $wpdb->posts . "`";
|
189 |
-
$query['where'] = "post_date < '$now' AND post_status = 'publish' AND post_type = 'post' " . (floatval($wp_version) < 2.1 ? "AND {$wpdb->posts}.post_date_gmt <= '" . gmdate('Y-m-d H:i:59') . "'" : "") . "";
|
190 |
-
$query['order'] = "ORDER BY post_date_gmt DESC";
|
191 |
-
$query['limit'] = "";
|
192 |
-
$query['group'] = "GROUP BY YEAR(post_date_gmt),MONTH(post_date_gmt)";
|
193 |
-
|
194 |
-
$archives = $wpdb->get_results("SELECT DISTINCT " . $query['what'] . " FROM " . $query['from'] . " WHERE " . $query['where'] . " " . $query['group'] . " " . $query['order'] . " " . $query['limit'] . "");
|
195 |
-
|
196 |
-
|
197 |
-
if ($archives) {
|
198 |
-
foreach ($archives as $archive) {
|
199 |
-
|
200 |
-
$changeFreq = "";
|
201 |
-
//Archive is the current one
|
202 |
-
if ($archive->month == date("n") && $archive->year == date("Y")) {
|
203 |
-
$changeFreq = $this->opt['archive'][1];
|
204 |
-
} else { // Archive is older
|
205 |
-
$changeFreq = $this->opt['oldarchive'][1];
|
206 |
-
}
|
207 |
-
|
208 |
-
$this->addLine(get_month_link($archive->year, $archive->month), $this->getTimestamp($archive->last_mod), $changeFreq, $this->opt['archive'][0]);
|
209 |
-
}
|
210 |
-
}
|
211 |
-
|
212 |
-
/* * ******************************************************************** */
|
213 |
-
//Add the author pages
|
214 |
-
$linkFunc = null;
|
215 |
-
|
216 |
-
//get_author_link is deprecated in WP 2.1, try to use get_author_posts_url first.
|
217 |
-
if (function_exists('get_author_posts_url'))
|
218 |
-
$linkFunc = 'get_author_posts_url';
|
219 |
-
else if (function_exists('get_author_link'))
|
220 |
-
$linkFunc = 'get_author_link';
|
221 |
-
|
222 |
-
if ($linkFunc !== null) {
|
223 |
-
$query = array();
|
224 |
-
|
225 |
-
/* CREATE QUERY */
|
226 |
-
$query['what'] = 'u.ID, u.user_nicename, MAX(p.post_modified_gmt) AS last_post';
|
227 |
-
$query['from'] = "`" . $wpdb->users . "` u, `" . $wpdb->posts . "` p";
|
228 |
-
$query['where'] = "p.post_author = u.ID AND p.post_status = 'publish' AND p.post_type = 'post' AND p.post_password = '' " . (floatval($wp_version) < 2.1 ? "AND p.post_date_gmt <= '" . gmdate('Y-m-d H:i:59') . "'" : "") . "";
|
229 |
-
$query['order'] = "";
|
230 |
-
$query['limit'] = "";
|
231 |
-
$query['group'] = "GROUP BY u.ID, u.user_nicename";
|
232 |
-
|
233 |
-
$authors = $wpdb->get_results("SELECT DISTINCT " . $query['what'] . " FROM " . $query['from'] . " WHERE " . $query['where'] . " " . $query['order'] . " " . $query['group'] . " " . $query['limit'] . "");
|
234 |
-
|
235 |
-
|
236 |
-
if ($authors && is_array($authors)) {
|
237 |
-
foreach ($authors as $author) {
|
238 |
-
|
239 |
-
$author_url = ($linkFunc == 'get_author_posts_url' ? get_author_posts_url($author->ID, $author->user_nicename) : get_author_link(false, $author->ID, $author->user_nicename));
|
240 |
-
$this->addLine($author_url, $this->getTimestamp($author->last_post), $this->opt['author'][1], $this->opt['author'][0]);
|
241 |
-
}
|
242 |
-
}
|
243 |
-
}
|
244 |
-
|
245 |
-
/* * ******************************************************************** */
|
246 |
-
if ($this->IsTaxonomySupported()) {
|
247 |
-
$count = 0;
|
248 |
-
$tags = get_terms("post_tag", array("hide_empty" => true, "hierarchical" => false));
|
249 |
-
if ($tags && is_array($tags) && count($tags) > 0) {
|
250 |
-
foreach ($tags AS $tag) {
|
251 |
-
if ($count > 3000)
|
252 |
-
break; //not to have a memory break
|
253 |
-
$this->addLine(get_tag_link($tag->term_id), strtotime(get_lastpostmodified()), $this->opt['tag'][1], $this->opt['tag'][0]);
|
254 |
-
$count++;
|
255 |
-
}
|
256 |
-
}
|
257 |
-
}
|
258 |
-
|
259 |
-
return $this->render();
|
260 |
-
}
|
261 |
-
|
262 |
-
/**
|
263 |
-
* Push new info to array
|
264 |
-
*
|
265 |
-
* @param string $link
|
266 |
-
* @param string $timestamp
|
267 |
-
* @param string $changefreq
|
268 |
-
* @param string $priority
|
269 |
-
*/
|
270 |
-
private function addLine($link, $timestamp, $changefreq, $priority) {
|
271 |
-
|
272 |
-
array_push($this->data, array(
|
273 |
-
'loc' => $link,
|
274 |
-
'lastmod' => date('Y-m-d\TH:i:s+00:00', $timestamp),
|
275 |
-
'changefreq' => $changefreq,
|
276 |
-
'priority' => $priority
|
277 |
-
));
|
278 |
-
}
|
279 |
-
|
280 |
-
/**
|
281 |
-
* Create the XML sitemap
|
282 |
-
* @return string
|
283 |
-
*/
|
284 |
-
private function render() {
|
285 |
-
$content = '';
|
286 |
-
try {
|
287 |
-
@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
|
288 |
-
|
289 |
-
$content .= '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
290 |
-
$content .= '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
291 |
-
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
|
292 |
-
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
|
293 |
-
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
|
294 |
-
|
295 |
-
|
296 |
-
if (is_array($this->data) && count($this->data) > 0)
|
297 |
-
foreach ($this->data as $data) {
|
298 |
-
$content .= "\t" . '<url>' . "\n";
|
299 |
-
$content .= "\t\t" . '<loc>' . $data['loc'] . '</loc>' . "\n";
|
300 |
-
$content .= "\t\t" . '<lastmod>' . $data['lastmod'] . '</lastmod>' . "\n";
|
301 |
-
$content .= "\t\t" . '<changefreq>' . $data['changefreq'] . '</changefreq>' . "\n";
|
302 |
-
$content .= "\t\t" . '<priority>' . $data['priority'] . '</priority>' . "\n";
|
303 |
-
$content .= "\t" . '</url>' . "\n";
|
304 |
-
} # end foreach
|
305 |
-
$content .= '</urlset>';
|
306 |
-
} catch (Exception $e) {
|
307 |
-
|
308 |
-
}
|
309 |
-
|
310 |
-
$this->saveSitemap($content);
|
311 |
-
|
312 |
-
return $content;
|
313 |
-
}
|
314 |
-
|
315 |
-
/**
|
316 |
-
* Converts into a unix timestamp
|
317 |
-
*
|
318 |
-
* @param string time
|
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);
|
328 |
-
|
329 |
-
return mktime(intval($hour), intval($min), intval($sec), intval($month), intval($day), intval($year));
|
330 |
-
}
|
331 |
-
|
332 |
-
/**
|
333 |
-
* Function to save the sitemap data to file as either XML or XML.GZ format
|
334 |
-
* @param string $data XML data
|
335 |
-
* @param string $filename file path
|
336 |
-
*
|
337 |
-
* @return boolean
|
338 |
-
*/
|
339 |
-
private function saveSitemap($data) {
|
340 |
-
if (function_exists('gzopen') && function_exists('gzwrite') && function_exists('gzclose')) {
|
341 |
-
if (function_exists('file_exists') && file_exists($this->file . '.gz'))
|
342 |
-
@unlink($this->file . '.gz');
|
343 |
-
|
344 |
-
if (function_exists('file_exists') && !file_exists($this->file . '.gz'))
|
345 |
-
if ($gz = @gzopen($this->file . '.gz', 'wb9')) {
|
346 |
-
@gzwrite($gz, $data);
|
347 |
-
@gzclose($gz);
|
348 |
-
}
|
349 |
-
}
|
350 |
-
|
351 |
-
if (function_exists('fopen'))
|
352 |
-
if ($fp = @fopen($this->file, 'w+')) {
|
353 |
-
fwrite($fp, $data);
|
354 |
-
fclose($fp);
|
355 |
-
return true;
|
356 |
-
}
|
357 |
-
|
358 |
-
return false;
|
359 |
-
}
|
360 |
-
|
361 |
-
/**
|
362 |
-
* Returns the URL for the XML sitemap file
|
363 |
-
*
|
364 |
-
* @return string
|
365 |
-
*/
|
366 |
-
public function getXmlUrl() {
|
367 |
-
return trailingslashit(get_bloginfo('url')) . $this->filename;
|
368 |
-
}
|
369 |
-
|
370 |
-
/**
|
371 |
-
* Returns if this version of WordPress supports the new taxonomy system
|
372 |
-
*
|
373 |
-
* @since 3.0b8
|
374 |
-
* @access private
|
375 |
-
* @author Arne Brachhold
|
376 |
-
* @return true if supported
|
377 |
-
*/
|
378 |
-
private function IsTaxonomySupported() {
|
379 |
-
return (function_exists("get_taxonomy") && function_exists("get_terms"));
|
380 |
-
}
|
381 |
-
|
382 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/SQ_Tools.php
CHANGED
@@ -22,7 +22,7 @@ class SQ_Tools extends SQ_FrontController {
|
|
22 |
|
23 |
self::$options = $this->getOptions();
|
24 |
|
25 |
-
$this->checkDebug(); //
|
26 |
}
|
27 |
|
28 |
public static function getUserID() {
|
@@ -36,7 +36,6 @@ class SQ_Tools extends SQ_FrontController {
|
|
36 |
* @return void
|
37 |
*/
|
38 |
function hookInit() {
|
39 |
-
$this->sq_patch3000(); //Update the older version
|
40 |
//TinyMCE editor required
|
41 |
//set_user_setting('editor', 'tinymce');
|
42 |
|
@@ -55,13 +54,8 @@ class SQ_Tools extends SQ_FrontController {
|
|
55 |
*/
|
56 |
public function hookActionlink($links, $file) {
|
57 |
if ($file == _SQ_PLUGIN_NAME_ . '/squirrly.php') {
|
58 |
-
|
59 |
-
|
60 |
-
array_unshift($links, $link);
|
61 |
-
} elseif (SQ_Tools::$options['sq_api'] <> '') {
|
62 |
-
$link = '<a href="' . admin_url('admin.php?page=sq_dashboard') . '">' . __('Dashboard', _SQ_PLUGIN_NAME_) . '</a>';
|
63 |
-
array_unshift($links, $link);
|
64 |
-
}
|
65 |
}
|
66 |
|
67 |
return $links;
|
@@ -74,17 +68,73 @@ class SQ_Tools extends SQ_FrontController {
|
|
74 |
*/
|
75 |
public static function getOptions() {
|
76 |
$default = array(
|
|
|
77 |
'sq_api' => '',
|
|
|
|
|
78 |
'sq_use' => 0,
|
79 |
-
'
|
|
|
|
|
80 |
// --
|
81 |
'sq_auto_canonical' => 1,
|
82 |
-
'sq_auto_sitemap' =>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
'sq_auto_meta' => 1,
|
84 |
'sq_auto_favicon' => 1,
|
|
|
85 |
'sq_auto_twitter' => 1,
|
86 |
'sq_auto_facebook' => 1,
|
87 |
'sq_twitter_account' => '',
|
|
|
|
|
|
|
88 |
// --
|
89 |
'sq_auto_seo' => 1,
|
90 |
'sq_auto_title' => 1,
|
@@ -93,7 +143,6 @@ class SQ_Tools extends SQ_FrontController {
|
|
93 |
'sq_fp_description' => '',
|
94 |
'sq_fp_keywords' => '',
|
95 |
// --
|
96 |
-
'sq_google_plus' => '',
|
97 |
'sq_google_wt' => '',
|
98 |
'sq_google_analytics' => '',
|
99 |
'sq_facebook_insights' => '',
|
@@ -101,21 +150,21 @@ class SQ_Tools extends SQ_FrontController {
|
|
101 |
'sq_pinterest' => '',
|
102 |
'sq_alexa' => '',
|
103 |
// --
|
|
|
104 |
'ignore_warn' => 0,
|
105 |
'sq_keyword_help' => 1,
|
106 |
'sq_keyword_information' => 0,
|
107 |
//
|
108 |
'sq_google_country' => 'com',
|
109 |
'sq_google_language' => 'en',
|
110 |
-
'sq_google_country_strict' =>
|
|
|
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 |
);
|
@@ -129,6 +178,39 @@ class SQ_Tools extends SQ_FrontController {
|
|
129 |
return $default;
|
130 |
}
|
131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
/**
|
133 |
* Save the Options in user option table in DB
|
134 |
*
|
@@ -150,6 +232,13 @@ class SQ_Tools extends SQ_FrontController {
|
|
150 |
switch ($type) {
|
151 |
case 'json':
|
152 |
header('Content-Type: application/json');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
}
|
154 |
}
|
155 |
|
@@ -161,13 +250,15 @@ class SQ_Tools extends SQ_FrontController {
|
|
161 |
* @param mixed $defaultValue (optional)
|
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 |
|
@@ -213,7 +304,7 @@ class SQ_Tools extends SQ_FrontController {
|
|
213 |
/**
|
214 |
* Connect remote with CURL if exists
|
215 |
*/
|
216 |
-
public static function sq_remote_get($url, $param = array()) {
|
217 |
$parameters = '';
|
218 |
$cookies = array();
|
219 |
$cookie_string = '';
|
@@ -221,13 +312,15 @@ class SQ_Tools extends SQ_FrontController {
|
|
221 |
$url_domain = parse_url($url);
|
222 |
$url_domain = $url_domain['host'];
|
223 |
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
|
|
228 |
if ($parameters <> '')
|
229 |
$url .= ((strpos($url, "?") === false) ? "?" : "&") . $parameters;
|
230 |
|
|
|
231 |
if ($url_domain == $_SERVER['HTTP_HOST'] && strpos($url, 'preview=true') !== false) {
|
232 |
foreach ($_COOKIE as $name => $value) {
|
233 |
if (strpos($name, 'wordpress') !== false || strpos($name, 'wpta') !== false) {
|
@@ -235,16 +328,21 @@ class SQ_Tools extends SQ_FrontController {
|
|
235 |
$cookie_string .= "$name=$value;";
|
236 |
}
|
237 |
}
|
238 |
-
$cookies[] = new WP_Http_Cookie(array('name' => 'sq_snippet', 'value' => 1));
|
239 |
-
$cookie_string .= "sq_snippet=1;";
|
240 |
}
|
241 |
|
242 |
-
$timeout = (isset($
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
|
244 |
if (function_exists('curl_init')) {
|
245 |
-
return self::sq_curl($url,
|
246 |
} else {
|
247 |
-
return self::sq_wpcall($url,
|
248 |
}
|
249 |
}
|
250 |
|
@@ -254,7 +352,7 @@ class SQ_Tools extends SQ_FrontController {
|
|
254 |
* @param array $param
|
255 |
* @return string
|
256 |
*/
|
257 |
-
private static function sq_curl($url, $
|
258 |
|
259 |
$ch = curl_init();
|
260 |
curl_setopt($ch, CURLOPT_URL, $url);
|
@@ -264,23 +362,27 @@ class SQ_Tools extends SQ_FrontController {
|
|
264 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
265 |
//--
|
266 |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
267 |
-
curl_setopt($ch, CURLOPT_TIMEOUT, $
|
268 |
-
|
|
|
|
|
|
|
|
|
269 |
|
270 |
-
if ($
|
271 |
-
curl_setopt($ch, CURLOPT_COOKIE, $
|
272 |
|
273 |
$response = curl_exec($ch);
|
274 |
$response = self::cleanResponce($response);
|
275 |
|
276 |
-
self::dump('CURL', $url, $
|
277 |
|
278 |
if (curl_errno($ch) == 1 || $response === false) { //if protocol not supported
|
279 |
if (curl_errno($ch)) {
|
280 |
self::dump(curl_getinfo($ch), curl_errno($ch), curl_error($ch));
|
281 |
}
|
282 |
curl_close($ch);
|
283 |
-
$response = self::sq_wpcall($url, $
|
284 |
} else {
|
285 |
curl_close($ch);
|
286 |
}
|
@@ -294,10 +396,10 @@ class SQ_Tools extends SQ_FrontController {
|
|
294 |
* @param array $param
|
295 |
* @return string
|
296 |
*/
|
297 |
-
private static function sq_wpcall($url, $
|
298 |
-
$response = wp_remote_get($url, $
|
299 |
$response = self::cleanResponce(wp_remote_retrieve_body($response)); //clear and get the body
|
300 |
-
self::dump('wp_remote_get', $url, $
|
301 |
return $response;
|
302 |
}
|
303 |
|
@@ -346,71 +448,75 @@ class SQ_Tools extends SQ_FrontController {
|
|
346 |
* Check for SEO blog bad settings
|
347 |
*/
|
348 |
public static function checkErrorSettings($count_only = false) {
|
|
|
349 |
|
350 |
-
|
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 |
-
|
362 |
-
|
363 |
-
if ($count_only)
|
364 |
self::$errors_count ++;
|
365 |
-
|
366 |
-
|
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 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
}
|
381 |
|
382 |
/* IF OG DUPLICATES */
|
383 |
if (self::getDuplicateOG()) {
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
}
|
389 |
|
390 |
/* IF TWITTER CARD DUPLICATES */
|
391 |
if (self::getDuplicateTC()) {
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
}
|
397 |
}
|
398 |
-
}
|
399 |
-
|
400 |
-
/* IF SEO INDEX IS OFF */
|
401 |
-
if (self::getPrivateBlog()) {
|
402 |
|
403 |
-
|
|
|
404 |
self::$errors_count++;
|
405 |
-
|
406 |
-
|
407 |
-
|
|
|
408 |
|
409 |
-
|
410 |
-
if ($count_only)
|
411 |
self::$errors_count++;
|
412 |
-
|
413 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
414 |
}
|
415 |
}
|
416 |
|
@@ -495,6 +601,32 @@ class SQ_Tools extends SQ_FrontController {
|
|
495 |
return ($total > 1);
|
496 |
}
|
497 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
498 |
/**
|
499 |
* Check if the blog is in private mode
|
500 |
* @return bool
|
@@ -631,11 +763,7 @@ class SQ_Tools extends SQ_FrontController {
|
|
631 |
'description' => 240,
|
632 |
'url' => 45);
|
633 |
|
634 |
-
|
635 |
-
self::$source_code = self::sq_remote_get($url, array('timeout' => 10));
|
636 |
-
} else {
|
637 |
-
self::$source_code = self::sq_remote_get($url, array('timeout' => 10));
|
638 |
-
}
|
639 |
|
640 |
$title_regex = "/<title[^>]*>([^<>]*)<\/title>/si";
|
641 |
preg_match($title_regex, self::$source_code, $title);
|
@@ -648,7 +776,7 @@ class SQ_Tools extends SQ_FrontController {
|
|
648 |
$description_regex = '/<meta[^<>]*description[^<>]*content="([^"<>]+)"[^<>]*>/si';
|
649 |
preg_match($description_regex, self::$source_code, $description);
|
650 |
if (is_array($description) && count($description) > 0) {
|
651 |
-
$snippet['description'] = trim(strip_tags(
|
652 |
|
653 |
if (strlen($snippet['description']) > $length['description'])
|
654 |
$snippet['description'] = substr($snippet['description'], 0, ($length['description'] - 1)) . '...';
|
@@ -667,18 +795,16 @@ class SQ_Tools extends SQ_FrontController {
|
|
667 |
private function checkDebug() {
|
668 |
//if debug is called
|
669 |
if (self::getIsset('sq_debug')) {
|
670 |
-
|
671 |
-
|
672 |
-
if (self::getValue('sq_debug') == self::$options['sq_api'])
|
673 |
$_GET['sq_debug'] = 'on';
|
674 |
-
|
675 |
-
$_GET['sq_debug'] = 'on';
|
676 |
-
else
|
677 |
$_GET['sq_debug'] = 'off';
|
|
|
678 |
|
679 |
if (self::getValue('sq_debug') === 'on') {
|
680 |
-
if (function_exists('register_shutdown_function'))
|
681 |
register_shutdown_function(array($this, 'showDebug'));
|
|
|
682 |
}
|
683 |
}
|
684 |
}
|
@@ -687,6 +813,10 @@ class SQ_Tools extends SQ_FrontController {
|
|
687 |
* Store the debug for a later view
|
688 |
*/
|
689 |
public static function dump() {
|
|
|
|
|
|
|
|
|
690 |
$output = '';
|
691 |
$callee = array('file' => '', 'line' => '');
|
692 |
if (function_exists('func_get_args')) {
|
@@ -696,12 +826,12 @@ class SQ_Tools extends SQ_FrontController {
|
|
696 |
$arguments = array();
|
697 |
|
698 |
|
699 |
-
|
700 |
if (function_exists('debug_backtrace'))
|
701 |
list( $callee ) = debug_backtrace();
|
702 |
|
703 |
$output .= '<fieldset style="background: #FFFFFF; border: 1px #CCCCCC solid; padding: 5px; font-size: 9pt; margin: 0;">';
|
704 |
-
$output .= '<legend style="background: #EEEEEE; padding: 2px; font-size: 8pt;">' . $callee['file'] . ' @ line: ' . $callee['line']
|
705 |
. '</legend><pre style="margin: 0; font-size: 8pt; text-align: left;">';
|
706 |
|
707 |
$i = 0;
|
@@ -733,8 +863,8 @@ class SQ_Tools extends SQ_FrontController {
|
|
733 |
}
|
734 |
|
735 |
public function sq_activate() {
|
736 |
-
|
737 |
-
set_transient('
|
738 |
}
|
739 |
|
740 |
public function sq_deactivate() {
|
@@ -744,24 +874,10 @@ class SQ_Tools extends SQ_FrontController {
|
|
744 |
$args = array();
|
745 |
$args['type'] = 'deact';
|
746 |
SQ_Action::apiCall('sq/user/log', $args, 5);
|
747 |
-
}
|
748 |
-
|
749 |
-
/**
|
750 |
-
* Update patch for older versions
|
751 |
-
*/
|
752 |
-
public function sq_patch3000() {
|
753 |
-
//Delete the old versions table
|
754 |
-
if (self::$options['sq_dbtables'] == 1) {
|
755 |
-
self::$options['sq_dbtables'] = 0;
|
756 |
-
global $wpdb;
|
757 |
-
|
758 |
-
$ranking = SQ_ObjController::getController('SQ_Ranking', false);
|
759 |
-
$ranking->getKeywordHistory();
|
760 |
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
}
|
765 |
}
|
766 |
|
767 |
public static function emptyCache($post_id = null) {
|
@@ -781,6 +897,18 @@ class SQ_Tools extends SQ_FrontController {
|
|
781 |
}
|
782 |
}
|
783 |
|
784 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
785 |
|
786 |
-
|
|
|
|
|
|
|
|
22 |
|
23 |
self::$options = $this->getOptions();
|
24 |
|
25 |
+
$this->checkDebug(); //dev mode
|
26 |
}
|
27 |
|
28 |
public static function getUserID() {
|
36 |
* @return void
|
37 |
*/
|
38 |
function hookInit() {
|
|
|
39 |
//TinyMCE editor required
|
40 |
//set_user_setting('editor', 'tinymce');
|
41 |
|
54 |
*/
|
55 |
public function hookActionlink($links, $file) {
|
56 |
if ($file == _SQ_PLUGIN_NAME_ . '/squirrly.php') {
|
57 |
+
$link = '<a href="' . admin_url('admin.php?page=sq_dashboard') . '">' . __('Getting started', _SQ_PLUGIN_NAME_) . '</a>';
|
58 |
+
array_unshift($links, $link);
|
|
|
|
|
|
|
|
|
|
|
59 |
}
|
60 |
|
61 |
return $links;
|
68 |
*/
|
69 |
public static function getOptions() {
|
70 |
$default = array(
|
71 |
+
'sq_ver' => 0,
|
72 |
'sq_api' => '',
|
73 |
+
'sq_checkedissues' => 0,
|
74 |
+
'sq_areissues' => 0,
|
75 |
'sq_use' => 0,
|
76 |
+
'sq_post_types' => array(
|
77 |
+
'post', 'page', 'product', 'shopp_page_shopp-products'
|
78 |
+
),
|
79 |
// --
|
80 |
'sq_auto_canonical' => 1,
|
81 |
+
'sq_auto_sitemap' => 1,
|
82 |
+
'sq_auto_jsonld' => 1,
|
83 |
+
'sq_jsonld_type' => 'Organization',
|
84 |
+
'sq_jsonld' => array(
|
85 |
+
'Organization' => array(
|
86 |
+
'name' => '',
|
87 |
+
'logo' => '',
|
88 |
+
'telephone' => '',
|
89 |
+
'contactType' => '',
|
90 |
+
'description' => ''
|
91 |
+
),
|
92 |
+
'Person' => array(
|
93 |
+
'name' => '',
|
94 |
+
'logo' => '',
|
95 |
+
'telephone' => '',
|
96 |
+
'jobTitle' => '',
|
97 |
+
'description' => ''
|
98 |
+
)),
|
99 |
+
'sq_sitemap_ping' => 1,
|
100 |
+
'sq_sitemap_show' => array(
|
101 |
+
'images' => 1,
|
102 |
+
'videos' => 1,
|
103 |
+
),
|
104 |
+
'sq_sitemap_frequency' => 'weekly',
|
105 |
+
'sq_sitemap' => array(
|
106 |
+
'sitemap' => array('sitemap.xml', 1),
|
107 |
+
'sitemap-home' => array('sitemap-home.xml', 1),
|
108 |
+
'sitemap-news' => array('sitemap-news.xml', 1),
|
109 |
+
'sitemap-product' => array('sitemap-product.xml', 1),
|
110 |
+
'sitemap-post' => array('sitemap-posts.xml', 1),
|
111 |
+
'sitemap-page' => array('sitemap-pages.xml', 1),
|
112 |
+
'sitemap-category' => array('sitemap-categories.xml', 1),
|
113 |
+
'sitemap-post_tag' => array('sitemap-tags.xml', 1),
|
114 |
+
'sitemap-archive' => array('sitemap-archives.xml', 1),
|
115 |
+
'sitemap-author' => array('sitemap-authors.xml', 0),
|
116 |
+
'sitemap-custom-tax' => array('sitemap-custom-taxonomies.xml', 0),
|
117 |
+
'sitemap-custom-post' => array('sitemap-custom-posts.xml', 0),
|
118 |
+
),
|
119 |
+
'sq_auto_robots' => 1,
|
120 |
+
'sq_robots_security' => array(
|
121 |
+
'User-agent: *',
|
122 |
+
'Disallow: */trackback/',
|
123 |
+
'Disallow: */xmlrpc.php',
|
124 |
+
'Disallow: /wp-*.php',
|
125 |
+
'Disallow: /cgi-bin/',
|
126 |
+
'Disallow: /wp-admin/',
|
127 |
+
'Disallow: /wp-includes/',
|
128 |
+
'Allow: */wp-content/uploads/'),
|
129 |
'sq_auto_meta' => 1,
|
130 |
'sq_auto_favicon' => 1,
|
131 |
+
'favicon' => '',
|
132 |
'sq_auto_twitter' => 1,
|
133 |
'sq_auto_facebook' => 1,
|
134 |
'sq_twitter_account' => '',
|
135 |
+
'sq_facebook_account' => '',
|
136 |
+
'sq_google_plus' => '',
|
137 |
+
'sq_linkedin_account' => '',
|
138 |
// --
|
139 |
'sq_auto_seo' => 1,
|
140 |
'sq_auto_title' => 1,
|
143 |
'sq_fp_description' => '',
|
144 |
'sq_fp_keywords' => '',
|
145 |
// --
|
|
|
146 |
'sq_google_wt' => '',
|
147 |
'sq_google_analytics' => '',
|
148 |
'sq_facebook_insights' => '',
|
150 |
'sq_pinterest' => '',
|
151 |
'sq_alexa' => '',
|
152 |
// --
|
153 |
+
'active_help' => '',
|
154 |
'ignore_warn' => 0,
|
155 |
'sq_keyword_help' => 1,
|
156 |
'sq_keyword_information' => 0,
|
157 |
//
|
158 |
'sq_google_country' => 'com',
|
159 |
'sq_google_language' => 'en',
|
160 |
+
'sq_google_country_strict' => 0,
|
161 |
+
'sq_google_ranksperhour' => 5,
|
162 |
// --
|
|
|
163 |
'sq_affiliate_link' => '',
|
164 |
'sq_sla' => 1,
|
165 |
'sq_keywordtag' => 1,
|
166 |
'sq_local_images' => 1,
|
167 |
//--
|
|
|
168 |
'sq_dashboard' => 0,
|
169 |
'sq_analytics' => 0,
|
170 |
);
|
178 |
return $default;
|
179 |
}
|
180 |
|
181 |
+
public static function getBriefOptions() {
|
182 |
+
return array(
|
183 |
+
'sq_version' => SQ_VERSION_ID,
|
184 |
+
'sq_use' => SQ_Tools::$options['sq_use'],
|
185 |
+
'sq_checkedissues' => SQ_Tools::$options['sq_checkedissues'],
|
186 |
+
'sq_areissues' => SQ_Tools::$options['sq_areissues'],
|
187 |
+
'sq_auto_canonical' => SQ_Tools::$options['sq_auto_canonical'],
|
188 |
+
'sq_auto_meta' => SQ_Tools::$options['sq_auto_meta'],
|
189 |
+
'sq_auto_sitemap' => SQ_Tools::$options['sq_auto_sitemap'],
|
190 |
+
'sq_auto_jsonld' => (SQ_Tools::$options['sq_auto_jsonld'] && (SQ_Tools::$options['sq_jsonld']['Organization']['name'] <> '' || SQ_Tools::$options['sq_jsonld']['Person']['name'] <> '')),
|
191 |
+
'sq_sitemap_ping' => SQ_Tools::$options['sq_sitemap_ping'],
|
192 |
+
'sq_auto_robots' => SQ_Tools::$options['sq_auto_robots'],
|
193 |
+
'sq_auto_favicon' => (SQ_Tools::$options['sq_auto_favicon'] && SQ_Tools::$options['favicon'] <> ''),
|
194 |
+
'sq_auto_twitter' => SQ_Tools::$options['sq_auto_twitter'],
|
195 |
+
'sq_auto_facebook' => SQ_Tools::$options['sq_auto_facebook'],
|
196 |
+
'sq_auto_seo' => SQ_Tools::$options['sq_auto_seo'],
|
197 |
+
'sq_auto_title' => (int) (SQ_Tools::$options['sq_auto_title'] && SQ_Tools::$options['sq_fp_title'] <> ''),
|
198 |
+
'sq_auto_description' => (int) (SQ_Tools::$options['sq_auto_description'] && SQ_Tools::$options['sq_fp_description'] <> ''),
|
199 |
+
'sq_google_plus' => (int) (SQ_Tools::$options['sq_google_plus'] <> ''),
|
200 |
+
'sq_google_wt' => (int) (SQ_Tools::$options['sq_google_wt'] <> ''),
|
201 |
+
'sq_google_analytics' => (int) (SQ_Tools::$options['sq_google_analytics'] <> ''),
|
202 |
+
'sq_facebook_insights' => (int) (SQ_Tools::$options['sq_facebook_insights'] <> ''),
|
203 |
+
'sq_bing_wt' => (int) (SQ_Tools::$options['sq_bing_wt'] <> ''),
|
204 |
+
'sq_pinterest' => (int) (SQ_Tools::$options['sq_pinterest'] <> ''),
|
205 |
+
'sq_alexa' => (int) (SQ_Tools::$options['sq_alexa'] <> ''),
|
206 |
+
'sq_keyword_help' => SQ_Tools::$options['sq_keyword_help'],
|
207 |
+
'sq_keyword_information' => SQ_Tools::$options['sq_keyword_information'],
|
208 |
+
'sq_google_country_strict' => SQ_Tools::$options['sq_google_country_strict'],
|
209 |
+
'sq_keywordtag' => SQ_Tools::$options['sq_keywordtag'],
|
210 |
+
'sq_local_images' => SQ_Tools::$options['sq_local_images'],
|
211 |
+
);
|
212 |
+
}
|
213 |
+
|
214 |
/**
|
215 |
* Save the Options in user option table in DB
|
216 |
*
|
232 |
switch ($type) {
|
233 |
case 'json':
|
234 |
header('Content-Type: application/json');
|
235 |
+
break;
|
236 |
+
case 'ico':
|
237 |
+
header('Content-Type: image/x-icon');
|
238 |
+
break;
|
239 |
+
case 'png':
|
240 |
+
header('Content-Type: image/png');
|
241 |
+
break;
|
242 |
}
|
243 |
}
|
244 |
|
250 |
* @param mixed $defaultValue (optional)
|
251 |
* @return mixed Value
|
252 |
*/
|
253 |
+
public static function getValue($key, $defaultValue = false, $withcode = false) {
|
254 |
if (!isset($key) OR empty($key) OR ! is_string($key))
|
255 |
return false;
|
256 |
+
$ret = (isset($_POST[$key]) ? $_POST[$key] : (isset($_GET[$key]) ? (is_string($_GET[$key]) ? urldecode($_GET[$key]) : $_GET[$key]) : $defaultValue));
|
257 |
|
258 |
+
if (is_string($ret) === true && $withcode === false) {
|
259 |
$ret = sanitize_text_field($ret);
|
260 |
+
}
|
261 |
+
|
262 |
return !is_string($ret) ? $ret : stripslashes($ret);
|
263 |
}
|
264 |
|
304 |
/**
|
305 |
* Connect remote with CURL if exists
|
306 |
*/
|
307 |
+
public static function sq_remote_get($url, $param = array(), $options = array()) {
|
308 |
$parameters = '';
|
309 |
$cookies = array();
|
310 |
$cookie_string = '';
|
312 |
$url_domain = parse_url($url);
|
313 |
$url_domain = $url_domain['host'];
|
314 |
|
315 |
+
if (isset($param))
|
316 |
+
foreach ($param as $key => $value) {
|
317 |
+
if (isset($key) && $key <> '' && $key <> 'timeout')
|
318 |
+
$parameters .= ($parameters == "" ? "" : "&") . $key . "=" . $value;
|
319 |
+
}
|
320 |
if ($parameters <> '')
|
321 |
$url .= ((strpos($url, "?") === false) ? "?" : "&") . $parameters;
|
322 |
|
323 |
+
//send the cookie for preview
|
324 |
if ($url_domain == $_SERVER['HTTP_HOST'] && strpos($url, 'preview=true') !== false) {
|
325 |
foreach ($_COOKIE as $name => $value) {
|
326 |
if (strpos($name, 'wordpress') !== false || strpos($name, 'wpta') !== false) {
|
328 |
$cookie_string .= "$name=$value;";
|
329 |
}
|
330 |
}
|
|
|
|
|
331 |
}
|
332 |
|
333 |
+
$options['timeout'] = (isset($options['timeout'])) ? $options['timeout'] : 30;
|
334 |
+
if (!isset($options['cookie_string'])) {
|
335 |
+
$options['cookies'] = $cookies;
|
336 |
+
}
|
337 |
+
if (!isset($options['cookie_string'])) {
|
338 |
+
$options['cookie_string'] = $cookie_string;
|
339 |
+
}
|
340 |
+
$options['sslverify'] = false;
|
341 |
|
342 |
if (function_exists('curl_init')) {
|
343 |
+
return self::sq_curl($url, $options);
|
344 |
} else {
|
345 |
+
return self::sq_wpcall($url, $options);
|
346 |
}
|
347 |
}
|
348 |
|
352 |
* @param array $param
|
353 |
* @return string
|
354 |
*/
|
355 |
+
private static function sq_curl($url, $options) {
|
356 |
|
357 |
$ch = curl_init();
|
358 |
curl_setopt($ch, CURLOPT_URL, $url);
|
362 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
363 |
//--
|
364 |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
365 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, $options['timeout']);
|
366 |
+
|
367 |
+
if (isset($options['followlocation'])) {
|
368 |
+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
369 |
+
curl_setopt($ch, CURLOPT_MAXREDIRS, 1);
|
370 |
+
}
|
371 |
|
372 |
+
if ($options['cookie_string'] <> '')
|
373 |
+
curl_setopt($ch, CURLOPT_COOKIE, $options['cookie_string']);
|
374 |
|
375 |
$response = curl_exec($ch);
|
376 |
$response = self::cleanResponce($response);
|
377 |
|
378 |
+
self::dump('CURL', $url, $options, $response); //output debug
|
379 |
|
380 |
if (curl_errno($ch) == 1 || $response === false) { //if protocol not supported
|
381 |
if (curl_errno($ch)) {
|
382 |
self::dump(curl_getinfo($ch), curl_errno($ch), curl_error($ch));
|
383 |
}
|
384 |
curl_close($ch);
|
385 |
+
$response = self::sq_wpcall($url, $options); //use the wordpress call
|
386 |
} else {
|
387 |
curl_close($ch);
|
388 |
}
|
396 |
* @param array $param
|
397 |
* @return string
|
398 |
*/
|
399 |
+
private static function sq_wpcall($url, $options) {
|
400 |
+
$response = wp_remote_get($url, $options);
|
401 |
$response = self::cleanResponce(wp_remote_retrieve_body($response)); //clear and get the body
|
402 |
+
self::dump('wp_remote_get', $url, $options, $response); //output debug
|
403 |
return $response;
|
404 |
}
|
405 |
|
448 |
* Check for SEO blog bad settings
|
449 |
*/
|
450 |
public static function checkErrorSettings($count_only = false) {
|
451 |
+
if (current_user_can('manage_options')) {
|
452 |
|
453 |
+
$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>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
454 |
|
455 |
+
/* IF SEO INDEX IS OFF */
|
456 |
+
if (self::getAutoSeoSquirrly()) {
|
|
|
457 |
self::$errors_count ++;
|
458 |
+
if (!$count_only) {
|
459 |
+
SQ_Error::setError(__('Activate the Squirrly SEO for your blog (recommended)', _SQ_PLUGIN_NAME_) . " <br />" . sprintf($fixit, "jQuery('#sq_use_on').trigger('click');", "sq_fixautoseo") . "", 'settings', 'sq_fix_auto');
|
460 |
+
}
|
461 |
+
}
|
|
|
|
|
|
|
462 |
|
463 |
+
//check only when in seo settings
|
464 |
+
self::$source_code = self::sq_remote_get(get_bloginfo('url'), array(), array('timeout' => 5, 'followlocation' => true));
|
465 |
if (self::$source_code <> '') {
|
466 |
+
/* IF TITLE DUPLICATES */
|
467 |
+
if (self::getDuplicateTitle()) {
|
468 |
+
self::$errors_count ++;
|
469 |
+
if (!$count_only) {
|
470 |
+
SQ_Error::setError(__('You have META Title Duplicates. Disable the Squirrly Title Optimization or disable the other SEO Plugins', _SQ_PLUGIN_NAME_) . " <br />" . sprintf($fixit, "jQuery('#sq_auto_title0').attr('checked', true); jQuery('#sq_automatically').attr('checked', true);", "sq_fix_titleduplicate") . "", 'settings', 'sq_fix_descduplicate');
|
471 |
+
}
|
472 |
+
}
|
473 |
+
|
474 |
/* IF DESCRIPTION DUPLICATES */
|
475 |
if (self::getDuplicateDescription()) {
|
476 |
+
self::$errors_count ++;
|
477 |
+
if (!$count_only) {
|
478 |
+
SQ_Error::setError(__('You have META Description Duplicates. Disable the Squirrly Description Optimization 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');
|
479 |
+
}
|
480 |
}
|
481 |
|
482 |
/* IF OG DUPLICATES */
|
483 |
if (self::getDuplicateOG()) {
|
484 |
+
self::$errors_count ++;
|
485 |
+
if (!$count_only) {
|
486 |
+
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');
|
487 |
+
}
|
488 |
}
|
489 |
|
490 |
/* IF TWITTER CARD DUPLICATES */
|
491 |
if (self::getDuplicateTC()) {
|
492 |
+
self::$errors_count ++;
|
493 |
+
if (!$count_only) {
|
494 |
+
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');
|
495 |
+
}
|
496 |
}
|
497 |
}
|
|
|
|
|
|
|
|
|
498 |
|
499 |
+
/* IF SEO INDEX IS OFF */
|
500 |
+
if (self::getPrivateBlog()) {
|
501 |
self::$errors_count++;
|
502 |
+
if (!$count_only) {
|
503 |
+
SQ_Error::setError(__('You\'re blocking google from indexing your site!', _SQ_PLUGIN_NAME_) . " <br />" . sprintf($fixit, "jQuery('#sq_google_index1').attr('checked',true);", "sq_fixprivate") . "", 'settings', 'sq_fix_private');
|
504 |
+
}
|
505 |
+
}
|
506 |
|
507 |
+
if (self::getBadLinkStructure()) {
|
|
|
508 |
self::$errors_count++;
|
509 |
+
if (!$count_only) {
|
510 |
+
SQ_Error::setError(__('It is highly recommended that you include the %postname% variable in the permalink structure. <br />Go to Settings > Permalinks and add /%postname%/ in Custom Structure', _SQ_PLUGIN_NAME_) . " <br /> ", 'settings');
|
511 |
+
}
|
512 |
+
}
|
513 |
+
|
514 |
+
if (self::$errors_count == 0) {
|
515 |
+
self::saveOptions('sq_areissues', 0);
|
516 |
+
SQ_Error::setError(__('Great! We didn\'t find any issue in your site.', _SQ_PLUGIN_NAME_) . " <br /> ", 'success');
|
517 |
+
} else {
|
518 |
+
self::saveOptions('sq_areissues', 1);
|
519 |
+
}
|
520 |
}
|
521 |
}
|
522 |
|
601 |
return ($total > 1);
|
602 |
}
|
603 |
|
604 |
+
/**
|
605 |
+
* Check for META duplicates
|
606 |
+
* @return boolean
|
607 |
+
*/
|
608 |
+
private static function getDuplicateTitle() {
|
609 |
+
if (!function_exists('preg_match_all')) {
|
610 |
+
return false;
|
611 |
+
}
|
612 |
+
$total = 0;
|
613 |
+
|
614 |
+
if (self::$options['sq_use'] == 1 && self::$options['sq_auto_title'] == 1) {
|
615 |
+
if (self::$source_code <> '') {
|
616 |
+
preg_match_all("/<title[^>]*>(.*)?<\/title>/i", self::$source_code, $out);
|
617 |
+
if (!empty($out) && isset($out[0]) && is_array($out[0])) {
|
618 |
+
$total += sizeof($out[0]);
|
619 |
+
}
|
620 |
+
preg_match_all("/<meta[^>]*name=[\"|\']title[\"|\'][^>]*content=[\"|\']([^>\"]*)[\"|\'][^>]*>/i", self::$source_code, $out);
|
621 |
+
if (!empty($out) && isset($out[0]) && is_array($out[0])) {
|
622 |
+
$total += sizeof($out[0]);
|
623 |
+
}
|
624 |
+
}
|
625 |
+
}
|
626 |
+
|
627 |
+
return ($total > 1);
|
628 |
+
}
|
629 |
+
|
630 |
/**
|
631 |
* Check if the blog is in private mode
|
632 |
* @return bool
|
763 |
'description' => 240,
|
764 |
'url' => 45);
|
765 |
|
766 |
+
self::$source_code = self::sq_remote_get($url, array(), array('timeout' => 10, 'followlocation' => true));
|
|
|
|
|
|
|
|
|
767 |
|
768 |
$title_regex = "/<title[^>]*>([^<>]*)<\/title>/si";
|
769 |
preg_match($title_regex, self::$source_code, $title);
|
776 |
$description_regex = '/<meta[^<>]*description[^<>]*content="([^"<>]+)"[^<>]*>/si';
|
777 |
preg_match($description_regex, self::$source_code, $description);
|
778 |
if (is_array($description) && count($description) > 0) {
|
779 |
+
$snippet['description'] = self::i18n(trim(strip_tags($description[1])));
|
780 |
|
781 |
if (strlen($snippet['description']) > $length['description'])
|
782 |
$snippet['description'] = substr($snippet['description'], 0, ($length['description'] - 1)) . '...';
|
795 |
private function checkDebug() {
|
796 |
//if debug is called
|
797 |
if (self::getIsset('sq_debug')) {
|
798 |
+
if (self::getValue('sq_debug') == self::$options['sq_api']) {
|
|
|
|
|
799 |
$_GET['sq_debug'] = 'on';
|
800 |
+
} else {
|
|
|
|
|
801 |
$_GET['sq_debug'] = 'off';
|
802 |
+
}
|
803 |
|
804 |
if (self::getValue('sq_debug') === 'on') {
|
805 |
+
if (function_exists('register_shutdown_function')) {
|
806 |
register_shutdown_function(array($this, 'showDebug'));
|
807 |
+
}
|
808 |
}
|
809 |
}
|
810 |
}
|
813 |
* Store the debug for a later view
|
814 |
*/
|
815 |
public static function dump() {
|
816 |
+
if (self::getValue('sq_debug') !== 'on') {
|
817 |
+
return;
|
818 |
+
}
|
819 |
+
|
820 |
$output = '';
|
821 |
$callee = array('file' => '', 'line' => '');
|
822 |
if (function_exists('func_get_args')) {
|
826 |
$arguments = array();
|
827 |
|
828 |
|
829 |
+
$run_time = number_format(microtime(true) - REQUEST_TIME, 3);
|
830 |
if (function_exists('debug_backtrace'))
|
831 |
list( $callee ) = debug_backtrace();
|
832 |
|
833 |
$output .= '<fieldset style="background: #FFFFFF; border: 1px #CCCCCC solid; padding: 5px; font-size: 9pt; margin: 0;">';
|
834 |
+
$output .= '<legend style="background: #EEEEEE; padding: 2px; font-size: 8pt;">' . $callee['file'] . ' Time: ' . $run_time . ' @ line: ' . $callee['line']
|
835 |
. '</legend><pre style="margin: 0; font-size: 8pt; text-align: left;">';
|
836 |
|
837 |
$i = 0;
|
863 |
}
|
864 |
|
865 |
public function sq_activate() {
|
866 |
+
set_transient('sq_activate', true);
|
867 |
+
set_transient('sq_rewrite', true);
|
868 |
}
|
869 |
|
870 |
public function sq_deactivate() {
|
874 |
$args = array();
|
875 |
$args['type'] = 'deact';
|
876 |
SQ_Action::apiCall('sq/user/log', $args, 5);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
877 |
|
878 |
+
remove_filter('rewrite_rules_array', array(SQ_ObjController::getBlock('SQ_BlockSettingsSeo'), 'rewrite_rules'), 999, 1);
|
879 |
+
global $wp_rewrite;
|
880 |
+
$wp_rewrite->flush_rules();
|
|
|
881 |
}
|
882 |
|
883 |
public static function emptyCache($post_id = null) {
|
897 |
}
|
898 |
}
|
899 |
|
900 |
+
public static function checkUpgrade() {
|
901 |
+
if (self::$options['sq_ver'] == 0 || self::$options['sq_ver'] < SQ_VERSION_ID) {
|
902 |
+
//Delete the old versions table
|
903 |
+
global $wpdb;
|
904 |
+
$wpdb->query("UPDATE " . $wpdb->postmeta . " SET `meta_key` = '_sq_fp_title' WHERE `meta_key` = 'sq_fp_title'");
|
905 |
+
$wpdb->query("UPDATE " . $wpdb->postmeta . " SET `meta_key` = '_sq_fp_description' WHERE `meta_key` = 'sq_fp_description'");
|
906 |
+
$wpdb->query("UPDATE " . $wpdb->postmeta . " SET `meta_key` = '_sq_fp_ogimage' WHERE `meta_key` = 'sq_fp_ogimage'");
|
907 |
+
$wpdb->query("UPDATE " . $wpdb->postmeta . " SET `meta_key` = '_sq_fp_keywords' WHERE `meta_key` = 'sq_fp_keywords'");
|
908 |
+
$wpdb->query("UPDATE " . $wpdb->postmeta . " SET `meta_key` = '_sq_post_keyword' WHERE `meta_key` = 'sq_post_keyword'");
|
909 |
|
910 |
+
self::saveOptions('sq_ver', SQ_VERSION_ID);
|
911 |
+
}
|
912 |
+
}
|
913 |
+
|
914 |
+
}
|
config/config.php
CHANGED
@@ -5,6 +5,9 @@
|
|
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);
|
@@ -27,5 +30,4 @@ require_once(dirname(__FILE__) . '/paths.php');
|
|
27 |
|
28 |
/* Define the record name in the Option and UserMeta tables */
|
29 |
define('SQ_OPTION', 'sq_options');
|
30 |
-
define('SQ_META', 'sq_plugin_flash');
|
31 |
?>
|
5 |
*/
|
6 |
define('_SQ_SUPPORT_EMAIL_', 'support@squirrly.co');
|
7 |
define('_SQ_NONCE_ID_', NONCE_KEY);
|
8 |
+
define('_SQ_MOBILE_ICON_SIZES', '76,120,152');
|
9 |
+
define('REQUEST_TIME', microtime(true));
|
10 |
+
|
11 |
|
12 |
if (!defined('PHP_VERSION_ID')) {
|
13 |
$version = explode('.', PHP_VERSION);
|
30 |
|
31 |
/* Define the record name in the Option and UserMeta tables */
|
32 |
define('SQ_OPTION', 'sq_options');
|
|
|
33 |
?>
|
controllers/SQ_Frontend.php
CHANGED
@@ -5,11 +5,21 @@ class SQ_Frontend extends SQ_FrontController {
|
|
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() {
|
@@ -29,13 +39,29 @@ class SQ_Frontend extends SQ_FrontController {
|
|
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 |
}
|
40 |
|
41 |
/**
|
@@ -48,11 +74,11 @@ class SQ_Frontend extends SQ_FrontController {
|
|
48 |
echo $this->model->setStart();
|
49 |
|
50 |
if (isset(SQ_Tools::$options['sq_use']) && (int) SQ_Tools::$options['sq_use'] == 1) {
|
51 |
-
|
52 |
-
|
53 |
-
//Use buffer only for meta Title
|
54 |
-
//if(SQ_Tools::$options['sq_auto_title'] == 1)
|
55 |
$this->model->flushHeader();
|
|
|
|
|
|
|
56 |
}
|
57 |
|
58 |
SQ_ObjController::getController('SQ_DisplayController', false)
|
@@ -82,6 +108,20 @@ class SQ_Frontend extends SQ_FrontController {
|
|
82 |
}
|
83 |
}
|
84 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
if (!is_array($urls) || (is_array($urls) && empty($urls)))
|
86 |
return $content;
|
87 |
|
@@ -97,12 +137,41 @@ class SQ_Frontend extends SQ_FrontController {
|
|
97 |
}
|
98 |
|
99 |
/**
|
100 |
-
*
|
|
|
|
|
|
|
|
|
101 |
*/
|
102 |
-
public function
|
103 |
-
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
}
|
107 |
}
|
108 |
|
5 |
public static $options;
|
6 |
|
7 |
public function __construct() {
|
8 |
+
|
9 |
if ($this->_isAjax())
|
10 |
return;
|
11 |
|
12 |
parent::__construct();
|
13 |
SQ_ObjController::getController('SQ_Tools', false);
|
14 |
+
|
15 |
+
/* Check if sitemap is on */
|
16 |
+
if (SQ_Tools::$options['sq_use'] == 1 && SQ_Tools::$options['sq_auto_sitemap'] == 1) {
|
17 |
+
/* Load the Sitemap */
|
18 |
+
SQ_ObjController::getController('SQ_Sitemaps');
|
19 |
+
}
|
20 |
+
|
21 |
+
//validate custom arguments for favicon and sitemap
|
22 |
+
add_filter('query_vars', array($this, 'validateParams'), 1, 1);
|
23 |
}
|
24 |
|
25 |
private function _isAjax() {
|
39 |
SQ_Tools::$options['sq_use'] = 0;
|
40 |
}
|
41 |
|
42 |
+
|
43 |
if (SQ_Tools::$options['sq_use'] == 1) {
|
44 |
+
if ($this->_isAjax()) {
|
45 |
return;
|
46 |
+
}
|
47 |
+
|
48 |
+
add_filter('sq_title', array($this->model, 'clearTitle'));
|
49 |
+
add_filter('sq_description', array($this->model, 'clearDescription'));
|
50 |
+
|
51 |
//Use buffer only for meta Title
|
|
|
52 |
$this->model->startBuffer();
|
53 |
}
|
54 |
+
|
55 |
+
//Check for sitemap and robots
|
56 |
+
if (SQ_Tools::$options['sq_use'] == 1) {
|
57 |
+
if (isset($_SERVER['REQUEST_URI']) && SQ_Tools::$options['sq_auto_robots'] == 1) {
|
58 |
+
if (substr(strrchr($_SERVER['REQUEST_URI'], "/"), 1) == "robots.txt" || $_SERVER['REQUEST_URI'] == "/robots.txt") {
|
59 |
+
$this->model->robots();
|
60 |
+
}
|
61 |
+
}
|
62 |
+
}
|
63 |
+
//check the action call
|
64 |
+
$this->action();
|
65 |
}
|
66 |
|
67 |
/**
|
74 |
echo $this->model->setStart();
|
75 |
|
76 |
if (isset(SQ_Tools::$options['sq_use']) && (int) SQ_Tools::$options['sq_use'] == 1) {
|
77 |
+
//flush the header with the title and removing duplicates
|
|
|
|
|
|
|
78 |
$this->model->flushHeader();
|
79 |
+
|
80 |
+
//show the Squirrly header
|
81 |
+
echo $this->model->setHeader();
|
82 |
}
|
83 |
|
84 |
SQ_ObjController::getController('SQ_DisplayController', false)
|
108 |
}
|
109 |
}
|
110 |
}
|
111 |
+
|
112 |
+
@preg_match_all('/<a[^>]*href="([^"]+)"[^>]*>/i', $content, $out);
|
113 |
+
if (is_array($out)) {
|
114 |
+
if (!is_array($out[1]) || empty($out[1]))
|
115 |
+
return $content;
|
116 |
+
|
117 |
+
foreach ($out[1] as $row) {
|
118 |
+
if (strpos($row, '//') === false) {
|
119 |
+
if (!in_array($row, $urls)) {
|
120 |
+
$urls[] = $row;
|
121 |
+
}
|
122 |
+
}
|
123 |
+
}
|
124 |
+
}
|
125 |
if (!is_array($urls) || (is_array($urls) && empty($urls)))
|
126 |
return $content;
|
127 |
|
137 |
}
|
138 |
|
139 |
/**
|
140 |
+
* Validate the params for getting the basic info from the server
|
141 |
+
* eg favicon.ico
|
142 |
+
*
|
143 |
+
* @param array $vars
|
144 |
+
* @return $vars
|
145 |
*/
|
146 |
+
public function validateParams($vars) {
|
147 |
+
$vars[] = 'sq_get';
|
148 |
+
$vars[] = 'sq_size';
|
149 |
+
return $vars;
|
150 |
+
}
|
151 |
+
|
152 |
+
public function action() {
|
153 |
+
|
154 |
+
switch (get_query_var('sq_get')) {
|
155 |
+
case 'favicon':
|
156 |
+
if (SQ_Tools::$options['favicon'] <> '') {
|
157 |
+
//show the favico file
|
158 |
+
SQ_Tools::setHeader('ico');
|
159 |
+
echo readfile(_SQ_CACHE_DIR_ . SQ_Tools::$options['favicon']);
|
160 |
+
exit();
|
161 |
+
}
|
162 |
+
break;
|
163 |
+
case 'touchicon':
|
164 |
+
$size = get_query_var('sq_size');
|
165 |
+
if (SQ_Tools::$options['favicon'] <> '') {
|
166 |
+
//show the favico file
|
167 |
+
SQ_Tools::setHeader('png');
|
168 |
+
if ($size <> '') {
|
169 |
+
echo readfile(_SQ_CACHE_DIR_ . SQ_Tools::$options['favicon'] . get_query_var('sq_size'));
|
170 |
+
} else {
|
171 |
+
echo readfile(_SQ_CACHE_DIR_ . SQ_Tools::$options['favicon']);
|
172 |
+
}
|
173 |
+
exit();
|
174 |
+
}
|
175 |
}
|
176 |
}
|
177 |
|
controllers/SQ_Menu.php
CHANGED
@@ -8,128 +8,95 @@ class SQ_Menu extends SQ_FrontController {
|
|
8 |
/** @var array snippet */
|
9 |
var $options = array();
|
10 |
|
|
|
|
|
|
|
|
|
|
|
11 |
/**
|
12 |
-
*
|
13 |
-
*
|
14 |
-
* @global type $wpdb
|
15 |
-
* @return type
|
16 |
*/
|
17 |
-
public function
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
22 |
|
23 |
-
|
24 |
-
|
|
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
}
|
34 |
-
|
|
|
|
|
35 |
}
|
36 |
-
exit();
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
* Creates the Setting menu in Wordpress
|
41 |
*/
|
42 |
public function hookMenu() {
|
43 |
-
$first_page = preg_replace('/\s/', '_', _SQ_NAME_);
|
44 |
-
$this->post_type = array('post', 'page', 'movie', 'product', 'download', 'shopp_page_shopp-products');
|
45 |
|
46 |
-
|
47 |
-
if (SQ_Tools::getIsset('post_type')) {
|
48 |
-
if (SQ_Tools::getValue('post_type') <> '') {
|
49 |
-
array_push($this->post_type, SQ_Tools::getValue('post_type'));
|
50 |
-
}
|
51 |
-
} elseif (SQ_Tools::getIsset('post')) {
|
52 |
-
$post = get_post(SQ_Tools::getValue('post'));
|
53 |
-
if (isset($post->post_type)) {
|
54 |
-
array_push($this->post_type, $post->post_type);
|
55 |
-
}
|
56 |
-
} elseif (SQ_Tools::getIsset('id')) {
|
57 |
-
$post = get_post(SQ_Tools::getValue('id'));
|
58 |
-
if (isset($post->post_type)) {
|
59 |
-
array_push($this->post_type, $post->post_type);
|
60 |
-
}
|
61 |
-
}
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
$first_page = 'sq_dashboard';
|
67 |
}
|
68 |
-
|
69 |
-
|
70 |
-
if (current_user_can('manage_options')) {
|
71 |
-
SQ_Tools::checkErrorSettings(true);
|
72 |
-
//check if activated
|
73 |
-
$this->checkActivation();
|
74 |
-
//activate the cron job if not exists
|
75 |
-
if (!wp_get_schedule('sq_processCron')) {
|
76 |
-
wp_schedule_event(time(), 'hourly', 'sq_processCron');
|
77 |
-
}
|
78 |
}
|
79 |
|
80 |
-
//Push the Analytics Check
|
81 |
$analytics_alert = 0;
|
82 |
-
if (SQ_ObjController::getModel('SQ_Post')->countKeywords() > 0) {
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
if (strpos($_SERVER['REQUEST_URI'], '?page=sq_dashboard') !== false) {
|
88 |
-
SQ_Tools::saveOptions('sq_dashboard', 1);
|
89 |
} else {
|
90 |
-
|
91 |
-
|
92 |
-
|
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::$
|
105 |
-
|
|
|
|
|
|
|
106 |
|
107 |
$this->model->addMenu(array(ucfirst(_SQ_NAME_),
|
108 |
'Squirrly' . SQ_Tools::showNotices(SQ_Tools::$errors_count, 'errors_count'),
|
109 |
'edit_posts',
|
110 |
-
|
111 |
null,
|
112 |
-
_SQ_THEME_URL_ . 'img/menu_icon_16.png'
|
113 |
));
|
114 |
-
if (SQ_Tools::$options['sq_api'] == '') {
|
115 |
-
$this->model->addSubmenu(array($first_page,
|
116 |
-
ucfirst(_SQ_NAME_) . __(' getting started', _SQ_PLUGIN_NAME_),
|
117 |
-
__('Getting started', _SQ_PLUGIN_NAME_),
|
118 |
-
'edit_posts',
|
119 |
-
'sq_howto',
|
120 |
-
array(SQ_ObjController::getBlock('SQ_BlockHelp'), 'init')
|
121 |
-
));
|
122 |
-
}
|
123 |
-
if (SQ_Tools::$options['sq_api'] <> '') {
|
124 |
-
$this->model->addSubmenu(array($first_page,
|
125 |
-
ucfirst(_SQ_NAME_) . __(' dashboard', _SQ_PLUGIN_NAME_),
|
126 |
-
__('Dashboard', _SQ_PLUGIN_NAME_),
|
127 |
-
'edit_posts',
|
128 |
-
'sq_dashboard',
|
129 |
-
array(SQ_ObjController::getBlock('SQ_BlockDashboard'), 'init')
|
130 |
-
));
|
131 |
|
132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
ucfirst(_SQ_NAME_) . __(' post list', _SQ_PLUGIN_NAME_),
|
134 |
__('Performance <br />Analytics', _SQ_PLUGIN_NAME_) . SQ_Tools::showNotices($analytics_alert, 'errors_count'),
|
135 |
'edit_posts',
|
@@ -137,26 +104,35 @@ class SQ_Menu extends SQ_FrontController {
|
|
137 |
array(SQ_ObjController::getBlock('SQ_BlockPostsAnalytics'), 'init')
|
138 |
));
|
139 |
|
140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
));
|
147 |
-
|
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 |
-
));
|
155 |
}
|
156 |
|
157 |
-
$this->model->addSubmenu(array(
|
158 |
-
__('
|
159 |
-
__('
|
160 |
'manage_options',
|
161 |
'sq_affiliate',
|
162 |
array(SQ_ObjController::getBlock('SQ_BlockAffiliate'), 'init')
|
@@ -173,172 +149,41 @@ class SQ_Menu extends SQ_FrontController {
|
|
173 |
|
174 |
//Add the Rank in the Posts list
|
175 |
$postlist = SQ_ObjController::getController('SQ_PostsList');
|
176 |
-
if (is_object($postlist))
|
177 |
$postlist->init();
|
178 |
-
|
179 |
-
|
180 |
-
/**
|
181 |
-
* Show the menu content after click event
|
182 |
-
*
|
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();
|
190 |
-
|
191 |
-
|
192 |
-
/* Get the options from Database */
|
193 |
-
$this->options = SQ_Tools::$options;
|
194 |
-
SQ_ObjController::getBlock('SQ_BlockSupport')->init();
|
195 |
|
196 |
-
//
|
197 |
-
|
|
|
|
|
|
|
|
|
198 |
}
|
199 |
|
200 |
/**
|
201 |
-
*
|
|
|
202 |
*
|
203 |
-
* @
|
|
|
|
|
204 |
*/
|
205 |
-
public function
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
SQ_Tools::saveOptions('sq_use', (int) SQ_Tools::getValue('sq_use'));
|
216 |
-
SQ_Tools::saveOptions('sq_auto_title', (int) SQ_Tools::getValue('sq_auto_title'));
|
217 |
-
SQ_Tools::saveOptions('sq_auto_description', (int) SQ_Tools::getValue('sq_auto_description'));
|
218 |
-
SQ_Tools::saveOptions('sq_auto_canonical', (int) SQ_Tools::getValue('sq_auto_canonical'));
|
219 |
-
SQ_Tools::saveOptions('sq_auto_sitemap', (int) SQ_Tools::getValue('sq_auto_sitemap'));
|
220 |
-
SQ_Tools::saveOptions('sq_auto_meta', (int) SQ_Tools::getValue('sq_auto_meta'));
|
221 |
-
SQ_Tools::saveOptions('sq_auto_favicon', (int) SQ_Tools::getValue('sq_auto_favicon'));
|
222 |
-
SQ_Tools::saveOptions('sq_auto_facebook', (int) SQ_Tools::getValue('sq_auto_facebook'));
|
223 |
-
SQ_Tools::saveOptions('sq_auto_twitter', (int) SQ_Tools::getValue('sq_auto_twitter'));
|
224 |
-
|
225 |
-
$sq_twitter_account = SQ_Tools::getValue('sq_twitter_account');
|
226 |
-
if ($sq_twitter_account <> '')
|
227 |
-
if (strpos($sq_twitter_account, '@') === false)
|
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 |
-
|
267 |
-
SQ_Tools::saveOptions('ignore_warn', (int) SQ_Tools::getValue('ignore_warn'));
|
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 |
-
|
276 |
-
/* if there is an icon to upload */
|
277 |
-
if (!empty($_FILES['favicon'])) {
|
278 |
-
|
279 |
-
$return = $this->model->addFavicon($_FILES['favicon']);
|
280 |
-
if ($return['favicon'] <> '')
|
281 |
-
SQ_Tools::saveOptions('favicon', $return['favicon']);
|
282 |
-
if ($return['name'] <> '')
|
283 |
-
SQ_Tools::saveOptions('favicon_tmp', $return['name']);
|
284 |
-
if ($return['message'] <> '')
|
285 |
-
define('SQ_MESSAGE_FAVICON', $return['message']);
|
286 |
-
}
|
287 |
-
|
288 |