Version Description
- 11/07/2017 =
- Fixed the SEO METAs in frontend for some theme
- Fixed the SEO METAs for Wp Super cache and other cache plugins
- Update Squirrly SEO Snippet Frontend is optional in Squirrly > SEO Settings Advanced
- Fixed the Sitemap to load for all subdirectories
- Fixed compatibility issues with other plugins
Download this release
Release Info
Developer | cifi |
Plugin | SEO SQUIRRLY™ |
Version | 8.2.23 |
Comparing to | |
See all releases |
Code changes from version 8.0.5 to 8.2.23
- classes/{SQ_Action.php → Action.php} +43 -28
- classes/BlockController.php +114 -0
- classes/{SQ_DisplayController.php → DisplayController.php} +31 -41
- classes/{SQ_Error.php → Error.php} +11 -5
- classes/FrontController.php +152 -0
- classes/{SQ_HookController.php → HookController.php} +42 -3
- classes/ObjController.php +200 -0
- classes/{SQ_Ranking.php → Ranking.php} +25 -35
- classes/SQ_BlockController.php +0 -95
- classes/SQ_FrontController.php +0 -123
- classes/SQ_ObjController.php +0 -197
- classes/SQ_Traffic.php +0 -8
- classes/{SQ_Tools.php → Tools.php} +533 -111
- config/config.php +54 -8
- config/paths.php +5 -6
- controllers/Api.php +76 -0
- controllers/Cron.php +29 -0
- controllers/{SQ_Feed.php → Feed.php} +10 -8
- controllers/FrontMenu.php +100 -0
- controllers/Frontend.php +193 -0
- controllers/Menu.php +548 -0
- controllers/{SQ_Post.php → Post.php} +88 -99
- controllers/{SQ_PostsList.php → PostsList.php} +33 -62
- controllers/SQ_Frontend.php +0 -218
- controllers/SQ_Menu.php +0 -247
- controllers/{SQ_Sitemaps.php → Sitemaps.php} +149 -67
- core/{SQ_BlockAccount/SQ_BlockAccount.php → BlockAccount.php} +1 -1
- core/{SQ_BlockAffiliate/SQ_BlockAffiliate.php → BlockAffiliate.php} +4 -4
- core/BlockAnalytics.php +9 -0
- core/{SQ_BlockAudit/SQ_BlockAudit.php → BlockAudit.php} +2 -2
- core/{SQ_BlockLiveAssistant/SQ_BlockLiveAssistant.php → BlockCopyright.php} +1 -1
- core/BlockCustomerService.php +11 -0
- core/{SQ_BlockDashboard/SQ_BlockDashboard.php → BlockDashboard.php} +1 -1
- core/BlockHelp.php +8 -0
- core/BlockImport.php +67 -0
- core/BlockKeywordResearch.php +12 -0
- core/{SQ_BlockCopyright/SQ_BlockCopyright.php → BlockLiveAssistant.php} +1 -1
- core/BlockPatterns.php +49 -0
- core/{SQ_BlockPostsAnalytics/SQ_BlockPostsAnalytics.php → BlockPostsAnalytics.php} +7 -6
- core/BlockSettings.php +76 -0
- core/BlockSettingsSeo.php +538 -0
- core/{SQ_BlockSupport/SQ_BlockSupport.php → BlockSupport.php} +8 -8
- core/BlockToolbar.php +4 -0
- core/{SQ_Blocklogin/SQ_Blocklogin.php → Blocklogin.php} +16 -16
- core/Blockresearch.php +8 -0
- core/Blocksearch.php +41 -0
- core/Blockseo.php +20 -0
- core/Loading.php +105 -0
- core/SQ_BlockAnalytics/SQ_BlockAnalytics.php +0 -9
- core/SQ_BlockCustomerService/SQ_BlockCustomerService.php +0 -11
- core/SQ_BlockHelp/SQ_BlockHelp.php +0 -8
- core/SQ_BlockKeywordResearch/SQ_BlockKeywordResearch.php +0 -11
- core/SQ_BlockSettings/SQ_BlockSettings.php +0 -72
- core/SQ_BlockSettingsSeo/SQ_BlockSettingsSeo.php +0 -382
- core/SQ_Blockresearch/SQ_Blockresearch.php +0 -17
- core/SQ_Blocksearch/SQ_Blocksearch.php +0 -41
- core/SQ_Blockseo/SQ_Blockseo.php +0 -40
- core/SQ_Loading/SQ_Loading.php +0 -74
- core/config.xml +73 -32
- languages/squirrly-seo-de_DE.mo +0 -0
- languages/squirrly-seo-de_DE.po +2186 -915
- languages/squirrly-seo-ro_RO.mo +0 -0
- languages/squirrly-seo-ro_RO.po +2896 -1061
- models/{SQ_BlockPostsAnalytics.php → BlockPostsAnalytics.php} +10 -10
- models/BlockSettingsSeo.php +1026 -0
- models/Blocksearch.php +10 -0
- models/Blockseo.php +29 -0
- models/Frontend.php +812 -0
- models/{SQ_Ico.php → Ico.php} +1 -1
- models/{SQ_Menu.php → Menu.php} +1 -1
- models/{SQ_Post.php → Post.php} +13 -7
- models/{SQ_PostsList.php → PostsList.php} +2 -2
- models/SQ_BlockSettingsSeo.php +0 -355
- models/SQ_Blocksearch.php +0 -10
- models/SQ_Blockseo.php +0 -41
- models/SQ_Frontend.php +0 -2136
- models/SQ_Sitemaps.php +0 -453
- models/Sitemaps.php +495 -0
- models/abstract/Domain.php +457 -0
- models/abstract/Seo.php +194 -0
- models/domain/Patterns.php +366 -0
- models/domain/Post.php +151 -0
- models/domain/Sq.php +146 -0
- models/services/Analytics.php +64 -0
- models/services/Canonical.php +33 -0
- models/services/Description.php +33 -0
- models/services/DublinCore.php +99 -0
- models/services/Favicon.php +71 -0
- models/services/JsonLD.php +264 -50
- models/services/Keywords.php +42 -0
- models/services/Noindex.php +36 -0
- models/services/OpenGraph.php +232 -0
- models/services/Pixel.php +210 -0
- models/services/PrevNext.php +43 -0
- models/services/Publisher.php +84 -0
- models/services/Robots.php +54 -0
- models/services/Sitemap.php +40 -0
- models/services/Title.php +38 -0
- models/services/TwitterCard.php +104 -0
- models/services/Verify.php +49 -0
- readme.txt +68 -3
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
- screenshot-4.png +0 -0
- screenshot-5.png +0 -0
- screenshot-6.png +0 -0
- screenshot-7.png +0 -0
- squirrly.php +19 -17
- themes/default/SQ_BlockAccount.php +0 -35
- themes/default/SQ_BlockAffiliate.php +0 -103
- themes/default/SQ_BlockAudit.php +0 -63
- themes/default/SQ_BlockCopyright.php +0 -31
- themes/default/SQ_BlockDashboard.php +0 -111
- themes/default/SQ_BlockKeywordResearch.php +0 -37
- themes/default/SQ_BlockLiveAssistant.php +0 -36
- themes/default/SQ_BlockPostsAnalytics.php +0 -56
- themes/default/SQ_BlockSettings.php +0 -416
- themes/default/SQ_BlockSettingsSeo.php +0 -775
classes/{SQ_Action.php → Action.php}
RENAMED
@@ -3,7 +3,7 @@
|
|
3 |
/**
|
4 |
* Set the ajax action and call for wordpress
|
5 |
*/
|
6 |
-
class
|
7 |
|
8 |
/** @var array with all form and ajax actions */
|
9 |
var $actions = array();
|
@@ -14,7 +14,7 @@ class SQ_Action extends SQ_FrontController {
|
|
14 |
|
15 |
private function _isAjax() {
|
16 |
$url = (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : false);
|
17 |
-
if ($url && (strpos($url, str_replace(get_bloginfo('url'),'',admin_url('admin-ajax.php', 'relative'))) !== false
|
18 |
return true;
|
19 |
}
|
20 |
|
@@ -59,6 +59,7 @@ class SQ_Action extends SQ_FrontController {
|
|
59 |
echo '<script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
60 |
<script type="text/javascript">
|
61 |
var sqQuery = {
|
|
|
62 |
"ajaxurl": "' . admin_url('admin-ajax.php') . '",
|
63 |
"adminposturl": "' . admin_url('post.php') . '",
|
64 |
"adminlisturl": "' . admin_url('edit.php') . '",
|
@@ -67,6 +68,18 @@ class SQ_Action extends SQ_FrontController {
|
|
67 |
</script>';
|
68 |
}
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
/**
|
71 |
* Get all actions from config.xml in core directory and add them in the WP
|
72 |
*
|
@@ -87,37 +100,37 @@ class SQ_Action extends SQ_FrontController {
|
|
87 |
self::$config = json_decode(json_encode((array)simplexml_load_string($data)), 1);
|
88 |
}
|
89 |
|
90 |
-
if (is_array(self::$config))
|
91 |
foreach (self::$config['block'] as $block) {
|
92 |
-
if ($block['active'] == 1) {
|
93 |
/* if there is a single action */
|
94 |
-
if (isset($block['actions']['action']))
|
95 |
-
if (
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
}
|
100 |
-
} else {
|
101 |
/* if there are more actions for the current block */
|
102 |
-
|
103 |
-
/* add the
|
104 |
-
if ($action == $cur_action)
|
105 |
-
$this->actions[] = array('class' => $block['name']
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
}
|
107 |
}
|
108 |
}
|
109 |
-
|
110 |
}
|
111 |
}
|
112 |
-
|
113 |
|
114 |
/* add the actions in WP */
|
115 |
foreach ($this->actions as $actions) {
|
116 |
-
|
117 |
-
SQ_ObjController::getBlock($actions['class'])->action();
|
118 |
-
} elseif ($actions['path'] == 'controllers') {
|
119 |
-
SQ_ObjController::getController($actions['class'])->action();
|
120 |
-
}
|
121 |
}
|
122 |
}
|
123 |
}
|
@@ -128,20 +141,21 @@ class SQ_Action extends SQ_FrontController {
|
|
128 |
* @param array $args
|
129 |
* @return json | string
|
130 |
*/
|
131 |
-
public
|
|
|
132 |
$parameters = "";
|
133 |
$scheme = "http:";
|
134 |
|
135 |
-
if (
|
136 |
return false;
|
137 |
}
|
138 |
|
139 |
-
$extra = array('user_url' =>
|
140 |
'lang' => (defined('WPLANG') ? WPLANG : 'en_US'),
|
141 |
'versq' => SQ_VERSION_ID,
|
142 |
'verwp' => WP_VERSION_ID,
|
143 |
'verphp' => PHP_VERSION_ID,
|
144 |
-
'token' =>
|
145 |
|
146 |
|
147 |
if (is_array($args)) {
|
@@ -169,7 +183,7 @@ class SQ_Action extends SQ_FrontController {
|
|
169 |
//call it with http to prevent curl issues with ssls
|
170 |
$url = self::cleanUrl($scheme . _SQ_API_URL_ . $module . "?" . $parameters);
|
171 |
//update_option('sq_seopost_log', $url);
|
172 |
-
return
|
173 |
}
|
174 |
|
175 |
/**
|
@@ -177,7 +191,8 @@ class SQ_Action extends SQ_FrontController {
|
|
177 |
* @param string $url
|
178 |
* @return string
|
179 |
*/
|
180 |
-
private
|
|
|
181 |
return str_replace(array(' '), array('+'), $url);
|
182 |
}
|
183 |
|
3 |
/**
|
4 |
* Set the ajax action and call for wordpress
|
5 |
*/
|
6 |
+
class SQ_Classes_Action extends SQ_Classes_FrontController {
|
7 |
|
8 |
/** @var array with all form and ajax actions */
|
9 |
var $actions = array();
|
14 |
|
15 |
private function _isAjax() {
|
16 |
$url = (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : false);
|
17 |
+
if ($url && (strpos($url, str_replace(get_bloginfo('url'), '', admin_url('admin-ajax.php', 'relative'))) !== false)) {
|
18 |
return true;
|
19 |
}
|
20 |
|
59 |
echo '<script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
60 |
<script type="text/javascript">
|
61 |
var sqQuery = {
|
62 |
+
"adminurl": "' . admin_url() . '",
|
63 |
"ajaxurl": "' . admin_url('admin-ajax.php') . '",
|
64 |
"adminposturl": "' . admin_url('post.php') . '",
|
65 |
"adminlisturl": "' . admin_url('edit.php') . '",
|
68 |
</script>';
|
69 |
}
|
70 |
|
71 |
+
public function hookFronthead() {
|
72 |
+
if (is_user_logged_in()) {
|
73 |
+
echo '<script type="text/javascript">
|
74 |
+
var sqQuery = {
|
75 |
+
"adminurl": "' . admin_url() . '",
|
76 |
+
"ajaxurl": "' . admin_url('admin-ajax.php') . '",
|
77 |
+
"nonce": "' . wp_create_nonce(_SQ_NONCE_ID_) . '"
|
78 |
+
}
|
79 |
+
</script>';
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
/**
|
84 |
* Get all actions from config.xml in core directory and add them in the WP
|
85 |
*
|
100 |
self::$config = json_decode(json_encode((array)simplexml_load_string($data)), 1);
|
101 |
}
|
102 |
|
103 |
+
if (is_array(self::$config))
|
104 |
foreach (self::$config['block'] as $block) {
|
105 |
+
if (isset($block['active']) && $block['active'] == 1) {
|
106 |
/* if there is a single action */
|
107 |
+
if (isset($block['actions']['action']))
|
108 |
+
if (isset($block['admin']) &&
|
109 |
+
(($block['admin'] == 1 && is_user_logged_in()) ||
|
110 |
+
$block['admin'] == 0)
|
111 |
+
) {
|
|
|
|
|
112 |
/* if there are more actions for the current block */
|
113 |
+
if (!is_array($block['actions']['action'])) {
|
114 |
+
/* add the action in the actions array */
|
115 |
+
if ($block['actions']['action'] == $cur_action)
|
116 |
+
$this->actions[] = array('class' => $block['name']);
|
117 |
+
} else {
|
118 |
+
/* if there are more actions for the current block */
|
119 |
+
foreach ($block['actions']['action'] as $action) {
|
120 |
+
/* add the actions in the actions array */
|
121 |
+
if ($action == $cur_action)
|
122 |
+
$this->actions[] = array('class' => $block['name']);
|
123 |
}
|
124 |
}
|
125 |
}
|
126 |
+
|
127 |
}
|
128 |
}
|
129 |
+
|
130 |
|
131 |
/* add the actions in WP */
|
132 |
foreach ($this->actions as $actions) {
|
133 |
+
SQ_Classes_ObjController::getClass($actions['class'])->action();
|
|
|
|
|
|
|
|
|
134 |
}
|
135 |
}
|
136 |
}
|
141 |
* @param array $args
|
142 |
* @return json | string
|
143 |
*/
|
144 |
+
public
|
145 |
+
static function apiCall($module, $args = array(), $timeout = 10) {
|
146 |
$parameters = "";
|
147 |
$scheme = "http:";
|
148 |
|
149 |
+
if (SQ_Classes_Tools::getOption('sq_api') == '' && $module <> 'sq/login' && $module <> 'sq/register') {
|
150 |
return false;
|
151 |
}
|
152 |
|
153 |
+
$extra = array('user_url' => home_url(),
|
154 |
'lang' => (defined('WPLANG') ? WPLANG : 'en_US'),
|
155 |
'versq' => SQ_VERSION_ID,
|
156 |
'verwp' => WP_VERSION_ID,
|
157 |
'verphp' => PHP_VERSION_ID,
|
158 |
+
'token' => SQ_Classes_Tools::getOption('sq_api'));
|
159 |
|
160 |
|
161 |
if (is_array($args)) {
|
183 |
//call it with http to prevent curl issues with ssls
|
184 |
$url = self::cleanUrl($scheme . _SQ_API_URL_ . $module . "?" . $parameters);
|
185 |
//update_option('sq_seopost_log', $url);
|
186 |
+
return SQ_Classes_Tools::sq_remote_get($url, array(), array('timeout' => $timeout));
|
187 |
}
|
188 |
|
189 |
/**
|
191 |
* @param string $url
|
192 |
* @return string
|
193 |
*/
|
194 |
+
private
|
195 |
+
static function cleanUrl($url) {
|
196 |
return str_replace(array(' '), array('+'), $url);
|
197 |
}
|
198 |
|
classes/BlockController.php
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The main class for core blocks
|
5 |
+
*
|
6 |
+
*/
|
7 |
+
class SQ_Classes_BlockController {
|
8 |
+
|
9 |
+
/** @var object of the model class */
|
10 |
+
protected $model;
|
11 |
+
|
12 |
+
/** @var boolean */
|
13 |
+
public $flush = true;
|
14 |
+
|
15 |
+
/** @var object of the view class */
|
16 |
+
protected $view;
|
17 |
+
|
18 |
+
/** @var name of the class */
|
19 |
+
private $name;
|
20 |
+
|
21 |
+
public function __construct() {
|
22 |
+
/* get the name of the current class */
|
23 |
+
$this->name = get_class($this);
|
24 |
+
|
25 |
+
/* create the model and view instances */
|
26 |
+
$this->model = SQ_Classes_ObjController::getClass(str_replace('Core', 'Models', $this->name));
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* load sequence of classes
|
31 |
+
*
|
32 |
+
* @return mixed
|
33 |
+
*/
|
34 |
+
public function init() {
|
35 |
+
/* check if there is a hook defined in the block class */
|
36 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_HookController')->setBlockHooks($this);
|
37 |
+
|
38 |
+
if ($this->flush) {
|
39 |
+
$this->hookHead();
|
40 |
+
echo $this->getView();
|
41 |
+
} else {
|
42 |
+
return $this->getView();
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Get the block view
|
49 |
+
*
|
50 |
+
* @param null $view
|
51 |
+
* @return mixed
|
52 |
+
*/
|
53 |
+
public function getView($view = null) {
|
54 |
+
if (!isset($view)) {
|
55 |
+
if ($class = SQ_Classes_ObjController::getClassPath($this->name)) {
|
56 |
+
$view = $class['name'];
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
if (isset($view)) {
|
61 |
+
$this->view = SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController');
|
62 |
+
return $this->view->getView($view, $this);
|
63 |
+
}
|
64 |
+
|
65 |
+
return '';
|
66 |
+
}
|
67 |
+
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Called as menu callback to show the block
|
71 |
+
*
|
72 |
+
*/
|
73 |
+
public function show() {
|
74 |
+
$this->flush = true;
|
75 |
+
echo $this->init();
|
76 |
+
}
|
77 |
+
|
78 |
+
|
79 |
+
public function preloadSettings() {
|
80 |
+
echo '<script type="text/javascript">
|
81 |
+
var __blog_url = "' . get_bloginfo('url') . '";
|
82 |
+
var __token = "' . SQ_Classes_Tools::getOption('sq_api') . '";
|
83 |
+
var __language = "' . get_bloginfo('language') . '";
|
84 |
+
var __api_url = "' . _SQ_API_URL_ . '";
|
85 |
+
jQuery(document).ready(function () {
|
86 |
+
jQuery.sq_getHelp("' . str_replace(array("sq_core_block", "sq_controller_block_"), "", strtolower($this->name)) . '", "content");
|
87 |
+
});
|
88 |
+
</script>';
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* This function is called from Ajax class as a wp_ajax_action
|
93 |
+
*
|
94 |
+
*/
|
95 |
+
protected function action() {
|
96 |
+
// check to see if the submitted nonce matches with the
|
97 |
+
// generated nonce we created
|
98 |
+
if (function_exists('wp_verify_nonce'))
|
99 |
+
if (!wp_verify_nonce(SQ_Classes_Tools::getValue('nonce'), _SQ_NONCE_ID_))
|
100 |
+
die('Invalid request!');
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* This function will load the media in the header for each class
|
105 |
+
*
|
106 |
+
* @return void
|
107 |
+
*/
|
108 |
+
protected function hookHead() {
|
109 |
+
if ($class = SQ_Classes_ObjController::getClassPath($this->name)) {
|
110 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia($class['name']);
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
}
|
classes/{SQ_DisplayController.php → DisplayController.php}
RENAMED
@@ -3,14 +3,13 @@
|
|
3 |
/**
|
4 |
* The class handles the theme part in WP
|
5 |
*/
|
6 |
-
class
|
7 |
|
8 |
-
private static $name;
|
9 |
private static $cache;
|
10 |
|
11 |
public function init() {
|
12 |
/* Load the global CSS file */
|
13 |
-
self::loadMedia('
|
14 |
}
|
15 |
|
16 |
/**
|
@@ -19,7 +18,7 @@ class SQ_DisplayController {
|
|
19 |
*/
|
20 |
private static function _isAjax() {
|
21 |
$url = (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : false);
|
22 |
-
if ($url && (strpos($url, str_replace(get_bloginfo('url'),'',admin_url('admin-ajax.php', 'relative'))) !== false
|
23 |
return true;
|
24 |
}
|
25 |
|
@@ -41,7 +40,7 @@ class SQ_DisplayController {
|
|
41 |
|
42 |
$css_uri = '';
|
43 |
$js_uri = '';
|
44 |
-
|
45 |
if (!isset($params['media'])) {
|
46 |
$params['media'] = 'all';
|
47 |
}
|
@@ -51,13 +50,24 @@ class SQ_DisplayController {
|
|
51 |
self::$cache[$uri] = true;
|
52 |
|
53 |
/* if is a custom css file */
|
54 |
-
if (strpos($uri, '
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
}
|
59 |
-
if (file_exists(_SQ_THEME_DIR_ . 'js/' . $
|
60 |
-
$js_uri = _SQ_THEME_URL_ . 'js/' . $
|
61 |
}
|
62 |
} else {
|
63 |
$name = strtolower(basename($uri));
|
@@ -66,11 +76,9 @@ class SQ_DisplayController {
|
|
66 |
elseif (strpos($uri, '.js') !== FALSE) {
|
67 |
$js_uri = $uri;
|
68 |
}
|
69 |
-
$local = false;
|
70 |
}
|
71 |
|
72 |
|
73 |
-
|
74 |
if ($css_uri <> '') {
|
75 |
if (!wp_style_is($name)) {
|
76 |
wp_enqueue_style($name, $css_uri, null, SQ_VERSION_ID, $params['media']);
|
@@ -83,7 +91,7 @@ class SQ_DisplayController {
|
|
83 |
|
84 |
if ($js_uri <> '') {
|
85 |
if (!wp_script_is($name)) {
|
86 |
-
wp_enqueue_script($name, $js_uri,
|
87 |
}
|
88 |
if (isset($params['trigger']) && $params['trigger'] === true) {
|
89 |
wp_print_scripts(array($name));
|
@@ -91,39 +99,21 @@ class SQ_DisplayController {
|
|
91 |
}
|
92 |
}
|
93 |
|
94 |
-
public function setBlock($block) {
|
95 |
-
self::$name = $block;
|
96 |
-
}
|
97 |
|
98 |
/**
|
99 |
-
*
|
100 |
*
|
101 |
-
* @
|
|
|
|
|
102 |
*/
|
103 |
-
public
|
104 |
-
|
105 |
-
if (file_exists(_SQ_THEME_DIR_ . self::$name . '.php')) {
|
106 |
ob_start();
|
107 |
-
|
108 |
-
|
109 |
-
include(_SQ_THEME_DIR_ . self::$name . '.php');
|
110 |
-
$block_content = ob_get_contents();
|
111 |
-
ob_end_clean();
|
112 |
-
|
113 |
-
return $block_content;
|
114 |
}
|
115 |
-
}
|
116 |
|
117 |
-
|
118 |
-
* Called for any class to show the block content
|
119 |
-
*
|
120 |
-
* @param string $block the name of the block file in theme directory (class name by default)
|
121 |
-
*
|
122 |
-
* @return string of the current class view
|
123 |
-
*/
|
124 |
-
public function output($block, $obj) {
|
125 |
-
self::$name = $block;
|
126 |
-
echo $this->echoBlock($obj);
|
127 |
}
|
128 |
-
|
129 |
}
|
3 |
/**
|
4 |
* The class handles the theme part in WP
|
5 |
*/
|
6 |
+
class SQ_Classes_DisplayController {
|
7 |
|
|
|
8 |
private static $cache;
|
9 |
|
10 |
public function init() {
|
11 |
/* Load the global CSS file */
|
12 |
+
self::loadMedia('global');
|
13 |
}
|
14 |
|
15 |
/**
|
18 |
*/
|
19 |
private static function _isAjax() {
|
20 |
$url = (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : false);
|
21 |
+
if ($url && (strpos($url, str_replace(get_bloginfo('url'), '', admin_url('admin-ajax.php', 'relative'))) !== false)) {
|
22 |
return true;
|
23 |
}
|
24 |
|
40 |
|
41 |
$css_uri = '';
|
42 |
$js_uri = '';
|
43 |
+
|
44 |
if (!isset($params['media'])) {
|
45 |
$params['media'] = 'all';
|
46 |
}
|
50 |
self::$cache[$uri] = true;
|
51 |
|
52 |
/* if is a custom css file */
|
53 |
+
if (strpos($uri, '//') === false) {
|
54 |
+
if (strpos($uri, '.') !== false) {
|
55 |
+
$name = strtolower(_SQ_NAMESPACE_ . substr($uri, 0, strpos($uri, '.')));
|
56 |
+
} else {
|
57 |
+
$name = strtolower(_SQ_NAMESPACE_ . $uri);
|
58 |
+
}
|
59 |
+
if (strpos($uri,'.css') !== false && file_exists(_SQ_THEME_DIR_ . 'css/' . strtolower($uri))) {
|
60 |
+
$css_uri = _SQ_THEME_URL_ . 'css/' . strtolower($uri);
|
61 |
+
}
|
62 |
+
if (strpos($uri,'.js') !== false && file_exists(_SQ_THEME_DIR_ . 'js/' . strtolower($uri))) {
|
63 |
+
$js_uri = _SQ_THEME_URL_ . 'js/' . strtolower($uri);
|
64 |
+
}
|
65 |
+
|
66 |
+
if (file_exists(_SQ_THEME_DIR_ . 'css/' . strtolower($uri) . '.css')) {
|
67 |
+
$css_uri = _SQ_THEME_URL_ . 'css/' . strtolower($uri) . '.css';
|
68 |
}
|
69 |
+
if (file_exists(_SQ_THEME_DIR_ . 'js/' . strtolower($uri) . '.js')) {
|
70 |
+
$js_uri = _SQ_THEME_URL_ . 'js/' . strtolower($uri) . '.js';
|
71 |
}
|
72 |
} else {
|
73 |
$name = strtolower(basename($uri));
|
76 |
elseif (strpos($uri, '.js') !== FALSE) {
|
77 |
$js_uri = $uri;
|
78 |
}
|
|
|
79 |
}
|
80 |
|
81 |
|
|
|
82 |
if ($css_uri <> '') {
|
83 |
if (!wp_style_is($name)) {
|
84 |
wp_enqueue_style($name, $css_uri, null, SQ_VERSION_ID, $params['media']);
|
91 |
|
92 |
if ($js_uri <> '') {
|
93 |
if (!wp_script_is($name)) {
|
94 |
+
wp_enqueue_script($name, $js_uri, array('jquery'), SQ_VERSION_ID);
|
95 |
}
|
96 |
if (isset($params['trigger']) && $params['trigger'] === true) {
|
97 |
wp_print_scripts(array($name));
|
99 |
}
|
100 |
}
|
101 |
|
|
|
|
|
|
|
102 |
|
103 |
/**
|
104 |
+
* return the block content from theme directory
|
105 |
*
|
106 |
+
* @param $block
|
107 |
+
* @param $view
|
108 |
+
* @return bool|string
|
109 |
*/
|
110 |
+
public function getView($block, $view) {
|
111 |
+
if (file_exists(_SQ_THEME_DIR_ . $block . '.php')) {
|
|
|
112 |
ob_start();
|
113 |
+
include(_SQ_THEME_DIR_ . $block . '.php');
|
114 |
+
return ob_get_clean();
|
|
|
|
|
|
|
|
|
|
|
115 |
}
|
|
|
116 |
|
117 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
}
|
|
|
119 |
}
|
classes/{SQ_Error.php → Error.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class
|
4 |
|
5 |
/** @var array */
|
6 |
private static $errors, $switch_off;
|
@@ -42,6 +42,12 @@ class SQ_Error extends SQ_FrontController {
|
|
42 |
'text' => $error);
|
43 |
}
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
/**
|
46 |
* This hook will show the error in WP header
|
47 |
*/
|
@@ -61,7 +67,7 @@ class SQ_Error extends SQ_FrontController {
|
|
61 |
break;
|
62 |
|
63 |
case 'helpnotice':
|
64 |
-
if (
|
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>";
|
@@ -81,12 +87,12 @@ class SQ_Error extends SQ_FrontController {
|
|
81 |
/**
|
82 |
* Show the notices to WP
|
83 |
*
|
84 |
-
* @return
|
85 |
*/
|
86 |
public static function showError($message, $id = '', $type = 'sq_error') {
|
87 |
|
88 |
-
if (file_exists(_SQ_THEME_DIR_ . '
|
89 |
-
include
|
90 |
} else {
|
91 |
echo $message;
|
92 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class SQ_Classes_Error extends SQ_Classes_FrontController {
|
4 |
|
5 |
/** @var array */
|
6 |
private static $errors, $switch_off;
|
42 |
'text' => $error);
|
43 |
}
|
44 |
|
45 |
+
public static function setMessage($message = '', $id = '') {
|
46 |
+
self::$errors[] = array('id' => $id,
|
47 |
+
'type' => 'success',
|
48 |
+
'text' => $message);
|
49 |
+
}
|
50 |
+
|
51 |
/**
|
52 |
* This hook will show the error in WP header
|
53 |
*/
|
67 |
break;
|
68 |
|
69 |
case 'helpnotice':
|
70 |
+
if (SQ_Classes_Tools::getOption('ignore_warn')) {
|
71 |
break;
|
72 |
}
|
73 |
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>";
|
87 |
/**
|
88 |
* Show the notices to WP
|
89 |
*
|
90 |
+
* @return string
|
91 |
*/
|
92 |
public static function showError($message, $id = '', $type = 'sq_error') {
|
93 |
|
94 |
+
if (file_exists(_SQ_THEME_DIR_ . 'Notices.php')) {
|
95 |
+
include(_SQ_THEME_DIR_ . 'Notices.php');
|
96 |
} else {
|
97 |
echo $message;
|
98 |
}
|
classes/FrontController.php
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The main class for controllers
|
5 |
+
*
|
6 |
+
*/
|
7 |
+
class SQ_Classes_FrontController {
|
8 |
+
|
9 |
+
/** @var object of the model class */
|
10 |
+
public $model;
|
11 |
+
|
12 |
+
/** @var boolean */
|
13 |
+
public $flush = true;
|
14 |
+
|
15 |
+
/** @var object of the view class */
|
16 |
+
public $view;
|
17 |
+
|
18 |
+
/** @var name of the class */
|
19 |
+
private $name;
|
20 |
+
|
21 |
+
public function __construct() {
|
22 |
+
|
23 |
+
/* Load error class */
|
24 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_Error');
|
25 |
+
/* Load Tools */
|
26 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_Tools');
|
27 |
+
|
28 |
+
|
29 |
+
/* get the name of the current class */
|
30 |
+
$this->name = get_class($this);
|
31 |
+
|
32 |
+
/* load the model and hooks here for wordpress actions to take efect */
|
33 |
+
/* create the model and view instances */
|
34 |
+
$this->model = SQ_Classes_ObjController::getClass(str_replace('Controllers', 'Models', $this->name));
|
35 |
+
|
36 |
+
//IMPORTANT TO LOAD HOOKS HERE
|
37 |
+
/* check if there is a hook defined in the controller clients class */
|
38 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_HookController')->setHooks($this);
|
39 |
+
|
40 |
+
/* Load the Submit Actions Handler */
|
41 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_Action');
|
42 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController');
|
43 |
+
|
44 |
+
//abstract classes
|
45 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Abstract_Domain');
|
46 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Abstract_Models');
|
47 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Abstract_Seo');
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* load sequence of classes
|
52 |
+
* Function called usualy when the controller is loaded in WP
|
53 |
+
*
|
54 |
+
* @return mixed
|
55 |
+
*/
|
56 |
+
public function init() {
|
57 |
+
/* load the blocks for this controller */
|
58 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_ObjController')->getBlocks($this->name);
|
59 |
+
|
60 |
+
if ($this->flush) {
|
61 |
+
echo $this->getView();
|
62 |
+
} else {
|
63 |
+
return $this->getView();
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Get the block view
|
69 |
+
*
|
70 |
+
* @param null $view
|
71 |
+
* @return mixed
|
72 |
+
*/
|
73 |
+
public function getView($view = null) {
|
74 |
+
if (!isset($view)) {
|
75 |
+
if ($class = SQ_Classes_ObjController::getClassPath($this->name)) {
|
76 |
+
$view = $class['name'];
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
if (isset($view)) {
|
81 |
+
$this->view = SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController');
|
82 |
+
return $this->view->getView($view, $this);
|
83 |
+
}
|
84 |
+
|
85 |
+
return '';
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Called as menu callback to show the block
|
90 |
+
*
|
91 |
+
*/
|
92 |
+
public function show() {
|
93 |
+
$this->flush = true;
|
94 |
+
echo $this->init();
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* initialize settings
|
99 |
+
* Called from index
|
100 |
+
*
|
101 |
+
* @return void
|
102 |
+
*/
|
103 |
+
public function runAdmin() {
|
104 |
+
/* show the admin menu and post actions */
|
105 |
+
SQ_Classes_ObjController::getClass('SQ_Controllers_Menu');
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Run fron frontend
|
110 |
+
*/
|
111 |
+
public function runFrontend() {
|
112 |
+
//Load Frontend only if Squirrly SEO is enabled
|
113 |
+
SQ_Classes_ObjController::getClass('SQ_Controllers_Frontend');
|
114 |
+
|
115 |
+
/* show the topbar admin menu and post actions */
|
116 |
+
SQ_Classes_ObjController::getClass('SQ_Controllers_Menu');
|
117 |
+
|
118 |
+
/* call the API for save posts */
|
119 |
+
SQ_Classes_ObjController::getClass('SQ_Controllers_Api');
|
120 |
+
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* first function call for any class
|
125 |
+
*
|
126 |
+
*/
|
127 |
+
protected function action() {
|
128 |
+
|
129 |
+
// check to see if the submitted nonce matches with the
|
130 |
+
// generated nonce we created
|
131 |
+
if (function_exists('wp_verify_nonce'))
|
132 |
+
if (!wp_verify_nonce(SQ_Classes_Tools::getValue('nonce'), _SQ_NONCE_ID_))
|
133 |
+
die('Invalid request!');
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* This function will load the media in the header for each class
|
138 |
+
*
|
139 |
+
* @return void
|
140 |
+
*/
|
141 |
+
public function hookHead() {
|
142 |
+
if (!is_admin()) {
|
143 |
+
return;
|
144 |
+
}
|
145 |
+
|
146 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->init();
|
147 |
+
if ($class = SQ_Classes_ObjController::getClassPath($this->name)) {
|
148 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_DisplayController')->loadMedia($class['name']);
|
149 |
+
}
|
150 |
+
}
|
151 |
+
|
152 |
+
}
|
classes/{SQ_HookController.php → HookController.php}
RENAMED
@@ -3,26 +3,49 @@
|
|
3 |
/**
|
4 |
* The class handles the actions in WP
|
5 |
*/
|
6 |
-
class
|
7 |
|
8 |
/** @var array the WP actions list from admin */
|
9 |
private $admin_hooks = array();
|
|
|
10 |
private $block_hooks = array();
|
11 |
|
12 |
public function __construct() {
|
13 |
-
$this->admin_hooks = array(
|
|
|
14 |
'head' => 'admin_head',
|
15 |
'footer' => 'admin_footer',
|
16 |
'menu' => 'admin_menu',
|
17 |
-
'preload' => 'template_redirect',
|
18 |
'notices' => 'admin_notices',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
'frontinit' => 'init',
|
20 |
'fronthead' => 'wp_head',
|
21 |
'frontfooter' => 'wp_footer',
|
22 |
);
|
|
|
23 |
$this->block_hooks = array('getContent' => 'getContent');
|
24 |
}
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
/**
|
27 |
* Calls the specified action in WP
|
28 |
* @param object $instance The parent class instance
|
@@ -41,6 +64,22 @@ class SQ_HookController {
|
|
41 |
}
|
42 |
}
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
/**
|
45 |
* Calls the specified action in WP
|
46 |
* @param string $action
|
3 |
/**
|
4 |
* The class handles the actions in WP
|
5 |
*/
|
6 |
+
class SQ_Classes_HookController {
|
7 |
|
8 |
/** @var array the WP actions list from admin */
|
9 |
private $admin_hooks = array();
|
10 |
+
private $front_hooks = array();
|
11 |
private $block_hooks = array();
|
12 |
|
13 |
public function __construct() {
|
14 |
+
$this->admin_hooks = array(
|
15 |
+
'init' => 'admin_init',
|
16 |
'head' => 'admin_head',
|
17 |
'footer' => 'admin_footer',
|
18 |
'menu' => 'admin_menu',
|
|
|
19 |
'notices' => 'admin_notices',
|
20 |
+
);
|
21 |
+
|
22 |
+
//called in frontend
|
23 |
+
$this->front_hooks = array(
|
24 |
+
// --
|
25 |
+
'init' => 'init',
|
26 |
+
'preload' => 'template_redirect',
|
27 |
'frontinit' => 'init',
|
28 |
'fronthead' => 'wp_head',
|
29 |
'frontfooter' => 'wp_footer',
|
30 |
);
|
31 |
+
|
32 |
$this->block_hooks = array('getContent' => 'getContent');
|
33 |
}
|
34 |
|
35 |
+
/**
|
36 |
+
* Calls the specified action in WP
|
37 |
+
* @param object $instance The parent class instance
|
38 |
+
*
|
39 |
+
* @return void
|
40 |
+
*/
|
41 |
+
public function setHooks($instance) {
|
42 |
+
if (is_admin() || is_network_admin()) {
|
43 |
+
$this->setAdminHooks($instance);
|
44 |
+
} else {
|
45 |
+
$this->setFrontHooks($instance);
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
/**
|
50 |
* Calls the specified action in WP
|
51 |
* @param object $instance The parent class instance
|
64 |
}
|
65 |
}
|
66 |
|
67 |
+
/**
|
68 |
+
* Calls the specified action in WP
|
69 |
+
* @param object $instance The parent class instance
|
70 |
+
*
|
71 |
+
* @return void
|
72 |
+
*/
|
73 |
+
public function setFrontHooks($instance) {
|
74 |
+
/* for each admin action check if is defined in class and call it */
|
75 |
+
foreach ($this->front_hooks as $hook => $value) {
|
76 |
+
if (is_callable(array($instance, 'hook' . ucfirst($hook)))) {
|
77 |
+
//call the WP add_action function
|
78 |
+
add_action($value, array($instance, 'hook' . ucfirst($hook)), 5);
|
79 |
+
}
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
/**
|
84 |
* Calls the specified action in WP
|
85 |
* @param string $action
|
classes/ObjController.php
ADDED
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The class creates object for plugin classes
|
5 |
+
*/
|
6 |
+
class SQ_Classes_ObjController {
|
7 |
+
|
8 |
+
/** @var array of instances */
|
9 |
+
public static $instances;
|
10 |
+
|
11 |
+
/** @var array from core config */
|
12 |
+
private static $config;
|
13 |
+
|
14 |
+
|
15 |
+
public static function getClass($className, $args = array()) {
|
16 |
+
|
17 |
+
if ($class = self::getClassPath($className)) {
|
18 |
+
if (!isset(self::$instances[$className])) {
|
19 |
+
/* check if class is already defined */
|
20 |
+
if (!class_exists($className) || $className == get_class()) {
|
21 |
+
self::includeClass($class['dir'], $class['name']);
|
22 |
+
|
23 |
+
//check if abstract
|
24 |
+
$check = new ReflectionClass($className);
|
25 |
+
$abstract = $check->isAbstract();
|
26 |
+
if (!$abstract) {
|
27 |
+
self::$instances[$className] = new $className();
|
28 |
+
if (!empty($args)) {
|
29 |
+
call_user_func_array(array(self::$instances[$className], '__construct'), $args);
|
30 |
+
}
|
31 |
+
return self::$instances[$className];
|
32 |
+
} else {
|
33 |
+
self::$instances[$className] = true;
|
34 |
+
}
|
35 |
+
} else {
|
36 |
+
|
37 |
+
}
|
38 |
+
} else
|
39 |
+
return self::$instances[$className];
|
40 |
+
}
|
41 |
+
return false;
|
42 |
+
}
|
43 |
+
|
44 |
+
private static function includeClass($classDir, $className) {
|
45 |
+
|
46 |
+
if (file_exists($classDir . $className . '.php'))
|
47 |
+
try {
|
48 |
+
include_once($classDir . $className . '.php');
|
49 |
+
} catch (Exception $e) {
|
50 |
+
throw new Exception('Controller Error: ' . $e->getMessage());
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
public static function getDomain($className, $args = array()) {
|
55 |
+
if ($class = self::getClassPath($className)) {
|
56 |
+
|
57 |
+
/* check if class is already defined */
|
58 |
+
// if (!isset(self::$instances[$className])) {
|
59 |
+
//
|
60 |
+
// self::$instances[$className] = new $className($args);
|
61 |
+
// return self::$instances[$className];
|
62 |
+
// }else
|
63 |
+
// return self::$instances[$className];
|
64 |
+
self::includeClass($class['dir'], $class['name']);
|
65 |
+
return new $className($args);
|
66 |
+
}
|
67 |
+
throw new Exception('Could not create domain: ' . $className);
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Check if the class is correctly set
|
73 |
+
*
|
74 |
+
* @param string $className
|
75 |
+
* @return boolean
|
76 |
+
*/
|
77 |
+
private static function checkClassPath($className) {
|
78 |
+
$path = preg_split('/[_]+/', $className);
|
79 |
+
if (is_array($path) && count($path) > 1) {
|
80 |
+
if (in_array(_SQ_NAMESPACE_, $path)) {
|
81 |
+
return true;
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
return false;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Get the path of the class and name of the class
|
90 |
+
*
|
91 |
+
* @param string $className
|
92 |
+
* @return array | boolean
|
93 |
+
* array(
|
94 |
+
* dir - absolute path of the class
|
95 |
+
* name - the name of the file
|
96 |
+
* }
|
97 |
+
*/
|
98 |
+
public static function getClassPath($className) {
|
99 |
+
$dir = '';
|
100 |
+
|
101 |
+
|
102 |
+
if (self::checkClassPath($className)) {
|
103 |
+
$path = preg_split('/[_]+/', $className);
|
104 |
+
for ($i = 1; $i < sizeof($path) - 1; $i++)
|
105 |
+
$dir .= strtolower($path[$i]) . '/';
|
106 |
+
|
107 |
+
$class = array('dir' => _SQ_ROOT_DIR_ . '/' . $dir,
|
108 |
+
'name' => $path[sizeof($path) - 1]);
|
109 |
+
|
110 |
+
if (file_exists($class['dir'] . $class['name'] . '.php')) {
|
111 |
+
return $class;
|
112 |
+
}
|
113 |
+
}
|
114 |
+
return false;
|
115 |
+
}
|
116 |
+
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Deprecated since 8.0.2
|
120 |
+
* Get the instance of the specified class
|
121 |
+
*
|
122 |
+
* @param string $className
|
123 |
+
* @param bool $core TRUE is the class is a core class or FALSE if it is from classes directory
|
124 |
+
*
|
125 |
+
* @return bool|object of the class
|
126 |
+
*/
|
127 |
+
public static function getController($className, $core = true) {
|
128 |
+
if (strpos($className, 'Controllers') === false) {
|
129 |
+
$className = _SQ_NAMESPACE_ . '_Controllers_' . str_replace(_SQ_NAMESPACE_ . '_', '', $className);
|
130 |
+
}
|
131 |
+
return self::getClass($className);
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Deprecated since 8.0.2
|
136 |
+
* Get the instance of the specified model class
|
137 |
+
*
|
138 |
+
* @param string $className
|
139 |
+
*
|
140 |
+
* @return bool|object of the class
|
141 |
+
*/
|
142 |
+
public static function getModel($className) {
|
143 |
+
if (strpos($className, 'Model') === false) {
|
144 |
+
$className = _SQ_NAMESPACE_ . '_Models_' . str_replace(_SQ_NAMESPACE_ . '_', '', $className);
|
145 |
+
}
|
146 |
+
return self::getClass($className);
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Get the instance of the specified block from core directory
|
151 |
+
*
|
152 |
+
* @param string $className
|
153 |
+
*
|
154 |
+
* @return bool|object of the class
|
155 |
+
*/
|
156 |
+
public static function getBlock($className) {
|
157 |
+
if (strpos($className, 'Core') === false) {
|
158 |
+
$className = _SQ_NAMESPACE_ . '_Core_' . str_replace(_SQ_NAMESPACE_ . '_', '', $className);
|
159 |
+
}
|
160 |
+
return self::getClass($className);
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Get all core classes from config.xml in core directory
|
165 |
+
* eg.SQ_Controllers_Post
|
166 |
+
* @param string $for
|
167 |
+
*/
|
168 |
+
public function getBlocks($for) {
|
169 |
+
/* if config allready in cache */
|
170 |
+
if (!isset(self::$config)) {
|
171 |
+
$config_file = _SQ_CORE_DIR_ . 'config.xml';
|
172 |
+
if (!file_exists($config_file))
|
173 |
+
return;
|
174 |
+
|
175 |
+
/* load configuration blocks data from core config files */
|
176 |
+
$data = file_get_contents($config_file);
|
177 |
+
self::$config = json_decode(json_encode((array)simplexml_load_string($data)), 1);;
|
178 |
+
}
|
179 |
+
//print_r(self::$config);
|
180 |
+
if (is_array(self::$config))
|
181 |
+
foreach (self::$config['block'] as $block) {
|
182 |
+
if ($block['active'] == 1)
|
183 |
+
if (isset($block['controllers']['controller']))
|
184 |
+
if (!is_array($block['controllers']['controller'])) {
|
185 |
+
/* if the block should load for the current controller */
|
186 |
+
if ($for == $block['controllers']['controller']) {
|
187 |
+
SQ_Classes_ObjController::getClass($block['name'])->init();
|
188 |
+
}
|
189 |
+
} else {
|
190 |
+
foreach ($block['controllers']['controller'] as $controller) {
|
191 |
+
/* if the block should load for the current controller */
|
192 |
+
if ($for == $controller) {
|
193 |
+
SQ_Classes_ObjController::getClass($block['name'])->init();
|
194 |
+
}
|
195 |
+
}
|
196 |
+
}
|
197 |
+
}
|
198 |
+
}
|
199 |
+
|
200 |
+
}
|
classes/{SQ_Ranking.php → Ranking.php}
RENAMED
@@ -3,23 +3,20 @@
|
|
3 |
/**
|
4 |
* Class for Google Ranking Record
|
5 |
*/
|
6 |
-
class
|
7 |
-
{
|
8 |
private $keyword;
|
9 |
private $post_id;
|
10 |
private $error;
|
11 |
|
12 |
//--
|
13 |
-
public function getCountry()
|
14 |
-
|
15 |
-
|
16 |
-
return SQ_Tools::$options['sq_google_country'];
|
17 |
}
|
18 |
return 'com';
|
19 |
}
|
20 |
|
21 |
-
public function getRefererCountry()
|
22 |
-
{
|
23 |
$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',);
|
24 |
$country = $this->getCountry();
|
25 |
if (array_key_exists($country, $convert_refc)) {
|
@@ -32,10 +29,9 @@ class SQ_Ranking extends SQ_FrontController
|
|
32 |
* Get the google language from settings
|
33 |
* @return string
|
34 |
*/
|
35 |
-
public function getLanguage()
|
36 |
-
|
37 |
-
|
38 |
-
return SQ_Tools::$options['sq_google_language'];
|
39 |
}
|
40 |
return 'en';
|
41 |
}
|
@@ -44,8 +40,7 @@ class SQ_Ranking extends SQ_FrontController
|
|
44 |
* Set the Post id
|
45 |
* @return type
|
46 |
*/
|
47 |
-
public function setPost($post_id)
|
48 |
-
{
|
49 |
$this->post_id = $post_id;
|
50 |
}
|
51 |
|
@@ -53,8 +48,7 @@ class SQ_Ranking extends SQ_FrontController
|
|
53 |
* Get the current keyword
|
54 |
* @param type $keyword
|
55 |
*/
|
56 |
-
public function setKeyword($keyword)
|
57 |
-
{
|
58 |
$this->keyword = str_replace(" ", "+", urlencode(strtolower($keyword)));
|
59 |
}
|
60 |
|
@@ -62,8 +56,7 @@ class SQ_Ranking extends SQ_FrontController
|
|
62 |
* Process Ranking on brief request
|
63 |
* @param type $return
|
64 |
*/
|
65 |
-
public function processRanking($post_id, $keyword)
|
66 |
-
{
|
67 |
$this->setPost($post_id);
|
68 |
$this->setKeyword(trim($keyword));
|
69 |
|
@@ -82,8 +75,7 @@ class SQ_Ranking extends SQ_FrontController
|
|
82 |
* @param string $language : en | local language
|
83 |
* @return boolean|int
|
84 |
*/
|
85 |
-
public function getGoogleRank()
|
86 |
-
{
|
87 |
|
88 |
@ini_set('open_basedir', null);
|
89 |
$this->error = '';
|
@@ -102,7 +94,7 @@ class SQ_Ranking extends SQ_FrontController
|
|
102 |
$arg['hl'] = $this->getLanguage();
|
103 |
//$arg['gl'] = $this->getRefererCountry();
|
104 |
|
105 |
-
if (
|
106 |
$arg['cr'] = 'country' . strtoupper($this->getRefererCountry());
|
107 |
}
|
108 |
$arg['start'] = '0';
|
@@ -212,7 +204,7 @@ class SQ_Ranking extends SQ_FrontController
|
|
212 |
$option['User-Agent'] = $user_agents[mt_rand(0, count($user_agents) - 1)];
|
213 |
$option['followlocation'] = true;
|
214 |
//Grab the remote informations from google
|
215 |
-
$response = utf8_decode(
|
216 |
|
217 |
//Check the values for block IP
|
218 |
if (strpos($response, "</h3>") === false) {
|
@@ -247,18 +239,17 @@ class SQ_Ranking extends SQ_FrontController
|
|
247 |
* Do google rank with cron
|
248 |
* @global type $wpdb
|
249 |
*/
|
250 |
-
public function processCron()
|
251 |
-
{
|
252 |
global $wpdb;
|
253 |
|
254 |
-
if (get_transient('google_blocked') !== false ||
|
255 |
return;
|
256 |
}
|
257 |
|
258 |
set_time_limit(3000);
|
259 |
/* Load the Submit Actions Handler */
|
260 |
-
|
261 |
-
|
262 |
|
263 |
//check 20 keyword at one time
|
264 |
$sql = "SELECT `post_id`, `meta_value`
|
@@ -269,7 +260,7 @@ class SQ_Ranking extends SQ_FrontController
|
|
269 |
if ($rows = $wpdb->get_results($sql)) {
|
270 |
$count = 0;
|
271 |
foreach ($rows as $row) {
|
272 |
-
if ($count >
|
273 |
break; //check only 10 keywords at the time
|
274 |
}
|
275 |
if ($row->meta_value <> '') {
|
@@ -289,7 +280,7 @@ class SQ_Ranking extends SQ_FrontController
|
|
289 |
$json->rank = $rank;
|
290 |
$json->country = $this->getCountry();
|
291 |
$json->language = $this->getLanguage();
|
292 |
-
|
293 |
}
|
294 |
set_transient('sq_rank' . $row->post_id, $rank, (60 * 60 * 24));
|
295 |
//if rank proccess has no error
|
@@ -301,7 +292,7 @@ class SQ_Ranking extends SQ_FrontController
|
|
301 |
$args['country'] = $this->getCountry();
|
302 |
$args['language'] = $this->getLanguage();
|
303 |
|
304 |
-
|
305 |
|
306 |
$count++;
|
307 |
sleep(mt_rand(20, 40));
|
@@ -315,8 +306,7 @@ class SQ_Ranking extends SQ_FrontController
|
|
315 |
* Get keyword from earlier version
|
316 |
*
|
317 |
*/
|
318 |
-
public function getKeywordHistory()
|
319 |
-
{
|
320 |
global $wpdb;
|
321 |
//Check if ranks is saved in database
|
322 |
$sql = "SELECT a.`global_rank`, a.`keyword`, a.`post_id`
|
@@ -325,19 +315,19 @@ class SQ_Ranking extends SQ_FrontController
|
|
325 |
|
326 |
if ($rows = $wpdb->get_results($sql)) {
|
327 |
foreach ($rows as $values) {
|
328 |
-
if ($json =
|
329 |
$json->keyword = urldecode($values->keyword);
|
330 |
if ($values->global_rank > 0) {
|
331 |
$json->rank = $values->global_rank;
|
332 |
}
|
333 |
-
|
334 |
} else {
|
335 |
$args = array();
|
336 |
$args['keyword'] = urldecode($values->keyword);
|
337 |
if ($values->global_rank > 0) {
|
338 |
$json->rank = $values->global_rank;
|
339 |
}
|
340 |
-
|
341 |
}
|
342 |
}
|
343 |
}
|
3 |
/**
|
4 |
* Class for Google Ranking Record
|
5 |
*/
|
6 |
+
class SQ_Classes_Ranking extends SQ_Classes_FrontController {
|
|
|
7 |
private $keyword;
|
8 |
private $post_id;
|
9 |
private $error;
|
10 |
|
11 |
//--
|
12 |
+
public function getCountry() {
|
13 |
+
if (SQ_Classes_Tools::getOption('sq_google_country') <> '') {
|
14 |
+
return SQ_Classes_Tools::getOption('sq_google_country');
|
|
|
15 |
}
|
16 |
return 'com';
|
17 |
}
|
18 |
|
19 |
+
public function getRefererCountry() {
|
|
|
20 |
$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',);
|
21 |
$country = $this->getCountry();
|
22 |
if (array_key_exists($country, $convert_refc)) {
|
29 |
* Get the google language from settings
|
30 |
* @return string
|
31 |
*/
|
32 |
+
public function getLanguage() {
|
33 |
+
if (SQ_Classes_Tools::getOption('sq_google_language') <> '') {
|
34 |
+
return SQ_Classes_Tools::getOption('sq_google_language');
|
|
|
35 |
}
|
36 |
return 'en';
|
37 |
}
|
40 |
* Set the Post id
|
41 |
* @return type
|
42 |
*/
|
43 |
+
public function setPost($post_id) {
|
|
|
44 |
$this->post_id = $post_id;
|
45 |
}
|
46 |
|
48 |
* Get the current keyword
|
49 |
* @param type $keyword
|
50 |
*/
|
51 |
+
public function setKeyword($keyword) {
|
|
|
52 |
$this->keyword = str_replace(" ", "+", urlencode(strtolower($keyword)));
|
53 |
}
|
54 |
|
56 |
* Process Ranking on brief request
|
57 |
* @param type $return
|
58 |
*/
|
59 |
+
public function processRanking($post_id, $keyword) {
|
|
|
60 |
$this->setPost($post_id);
|
61 |
$this->setKeyword(trim($keyword));
|
62 |
|
75 |
* @param string $language : en | local language
|
76 |
* @return boolean|int
|
77 |
*/
|
78 |
+
public function getGoogleRank() {
|
|
|
79 |
|
80 |
@ini_set('open_basedir', null);
|
81 |
$this->error = '';
|
94 |
$arg['hl'] = $this->getLanguage();
|
95 |
//$arg['gl'] = $this->getRefererCountry();
|
96 |
|
97 |
+
if (SQ_Classes_Tools::getOption('sq_google_country_strict')) {
|
98 |
$arg['cr'] = 'country' . strtoupper($this->getRefererCountry());
|
99 |
}
|
100 |
$arg['start'] = '0';
|
204 |
$option['User-Agent'] = $user_agents[mt_rand(0, count($user_agents) - 1)];
|
205 |
$option['followlocation'] = true;
|
206 |
//Grab the remote informations from google
|
207 |
+
$response = utf8_decode(SQ_Classes_Tools::sq_remote_get("https://www.google.$country/search", $arg, $option));
|
208 |
|
209 |
//Check the values for block IP
|
210 |
if (strpos($response, "</h3>") === false) {
|
239 |
* Do google rank with cron
|
240 |
* @global type $wpdb
|
241 |
*/
|
242 |
+
public function processCron() {
|
|
|
243 |
global $wpdb;
|
244 |
|
245 |
+
if (get_transient('google_blocked') !== false || SQ_Classes_Tools::getOption('sq_google_ranksperhour') == 0) {
|
246 |
return;
|
247 |
}
|
248 |
|
249 |
set_time_limit(3000);
|
250 |
/* Load the Submit Actions Handler */
|
251 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_Tools');
|
252 |
+
SQ_Classes_ObjController::getClass('SQ_Classes_Action');
|
253 |
|
254 |
//check 20 keyword at one time
|
255 |
$sql = "SELECT `post_id`, `meta_value`
|
260 |
if ($rows = $wpdb->get_results($sql)) {
|
261 |
$count = 0;
|
262 |
foreach ($rows as $row) {
|
263 |
+
if ($count > SQ_Classes_Tools::getOption('sq_google_ranksperhour')) {
|
264 |
break; //check only 10 keywords at the time
|
265 |
}
|
266 |
if ($row->meta_value <> '') {
|
280 |
$json->rank = $rank;
|
281 |
$json->country = $this->getCountry();
|
282 |
$json->language = $this->getLanguage();
|
283 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Post')->saveKeyword($row->post_id, $json);
|
284 |
}
|
285 |
set_transient('sq_rank' . $row->post_id, $rank, (60 * 60 * 24));
|
286 |
//if rank proccess has no error
|
292 |
$args['country'] = $this->getCountry();
|
293 |
$args['language'] = $this->getLanguage();
|
294 |
|
295 |
+
SQ_Classes_Action::apiCall('sq/user-analytics/saveserp', $args);
|
296 |
|
297 |
$count++;
|
298 |
sleep(mt_rand(20, 40));
|
306 |
* Get keyword from earlier version
|
307 |
*
|
308 |
*/
|
309 |
+
public function getKeywordHistory() {
|
|
|
310 |
global $wpdb;
|
311 |
//Check if ranks is saved in database
|
312 |
$sql = "SELECT a.`global_rank`, a.`keyword`, a.`post_id`
|
315 |
|
316 |
if ($rows = $wpdb->get_results($sql)) {
|
317 |
foreach ($rows as $values) {
|
318 |
+
if ($json = SQ_Classes_ObjController::getClass('SQ_Models_Post')->getKeyword($values->post_id)) {
|
319 |
$json->keyword = urldecode($values->keyword);
|
320 |
if ($values->global_rank > 0) {
|
321 |
$json->rank = $values->global_rank;
|
322 |
}
|
323 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Post')->saveKeyword($values->post_id, $json);
|
324 |
} else {
|
325 |
$args = array();
|
326 |
$args['keyword'] = urldecode($values->keyword);
|
327 |
if ($values->global_rank > 0) {
|
328 |
$json->rank = $values->global_rank;
|
329 |
}
|
330 |
+
SQ_Classes_ObjController::getClass('SQ_Models_Post')->saveKeyword($values->post_id, json_decode(json_encode($args)));
|
331 |
}
|
332 |
}
|
333 |
}
|
classes/SQ_BlockController.php
DELETED
@@ -1,95 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* The main class for core blocks
|
5 |
-
*
|
6 |
-
*/
|
7 |
-
class SQ_BlockController {
|
8 |
-
|
9 |
-
/** @var object of the model class */
|
10 |
-
protected $model;
|
11 |
-
|
12 |
-
/** @var boolean */
|
13 |
-
public $flush = true;
|
14 |
-
|
15 |
-
/** @var object of the view class */
|
16 |
-
protected $view;
|
17 |
-
|
18 |
-
/** @var name of the class */
|
19 |
-
private $name;
|
20 |
-
|
21 |
-
public function __construct() {
|
22 |
-
/** check the admin condition */
|
23 |
-
if (!is_admin())
|
24 |
-
return;
|
25 |
-
|
26 |
-
/* get the name of the current class */
|
27 |
-
$this->name = get_class($this);
|
28 |
-
|
29 |
-
/* create the model and view instances */
|
30 |
-
$this->model = SQ_ObjController::getModel($this->name);
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* load sequence of classes
|
35 |
-
*
|
36 |
-
* @return void
|
37 |
-
*/
|
38 |
-
public function init() {
|
39 |
-
|
40 |
-
$this->view = SQ_ObjController::getController('SQ_DisplayController', false);
|
41 |
-
$this->view->setBlock($this->name);
|
42 |
-
|
43 |
-
/* check if there is a hook defined in the block class */
|
44 |
-
SQ_ObjController::getController('SQ_HookController', false)
|
45 |
-
->setBlockHooks($this);
|
46 |
-
|
47 |
-
if ($this->flush) {
|
48 |
-
echo $this->output();
|
49 |
-
} else {
|
50 |
-
return $this->output();
|
51 |
-
}
|
52 |
-
}
|
53 |
-
|
54 |
-
protected function output() {
|
55 |
-
$this->hookHead();
|
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 |
-
*
|
74 |
-
*/
|
75 |
-
protected function action() {
|
76 |
-
// check to see if the submitted nonce matches with the
|
77 |
-
// generated nonce we created
|
78 |
-
if (function_exists('wp_verify_nonce'))
|
79 |
-
if (!wp_verify_nonce(SQ_Tools::getValue('nonce'), _SQ_NONCE_ID_))
|
80 |
-
die('Invalid request!');
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* This function will load the media in the header for each class
|
85 |
-
*
|
86 |
-
* @return void
|
87 |
-
*/
|
88 |
-
protected function hookHead() {
|
89 |
-
if (!is_admin())
|
90 |
-
return;
|
91 |
-
SQ_ObjController::getController('SQ_DisplayController', false)
|
92 |
-
->loadMedia($this->name);
|
93 |
-
}
|
94 |
-
|
95 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/SQ_FrontController.php
DELETED
@@ -1,123 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* The main class for controllers
|
5 |
-
*
|
6 |
-
*/
|
7 |
-
class SQ_FrontController {
|
8 |
-
|
9 |
-
/** @var object of the model class */
|
10 |
-
public $model;
|
11 |
-
|
12 |
-
/** @var boolean */
|
13 |
-
public $flush = true;
|
14 |
-
|
15 |
-
/** @var object of the view class */
|
16 |
-
public $view;
|
17 |
-
|
18 |
-
/** @var name of the class */
|
19 |
-
private $name;
|
20 |
-
|
21 |
-
public function __construct() {
|
22 |
-
|
23 |
-
/* get the name of the current class */
|
24 |
-
$this->name = get_class($this);
|
25 |
-
|
26 |
-
|
27 |
-
/* load the model and hooks here for wordpress actions to take efect */
|
28 |
-
/* create the model and view instances */
|
29 |
-
$this->model = SQ_ObjController::getModel($this->name);
|
30 |
-
|
31 |
-
//IMPORTANT TO LOAD HOOKS HERE
|
32 |
-
/* check if there is a hook defined in the controller clients class */
|
33 |
-
SQ_ObjController::getController('SQ_HookController', false)->setAdminHooks($this);
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* load sequence of classes
|
38 |
-
* Function called usualy when the controller is loaded in WP
|
39 |
-
*
|
40 |
-
* @return void
|
41 |
-
*/
|
42 |
-
public function init() {
|
43 |
-
|
44 |
-
$this->view = SQ_ObjController::getController('SQ_DisplayController', false);
|
45 |
-
$this->view->setBlock($this->name);
|
46 |
-
|
47 |
-
|
48 |
-
/* load the blocks for this controller */
|
49 |
-
SQ_ObjController::getController('SQ_ObjController', false)->getBlocks($this->name);
|
50 |
-
|
51 |
-
if ($this->flush) {
|
52 |
-
echo $this->output();
|
53 |
-
} else {
|
54 |
-
return $this->output();
|
55 |
-
}
|
56 |
-
}
|
57 |
-
|
58 |
-
protected function output() {
|
59 |
-
$this->hookHead();
|
60 |
-
return $this->view->echoBlock($this);
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* initialize settings
|
65 |
-
* Called from index
|
66 |
-
*
|
67 |
-
* @return void
|
68 |
-
*/
|
69 |
-
public function run() {
|
70 |
-
|
71 |
-
/* Load error class */
|
72 |
-
SQ_ObjController::getController('SQ_Error', false);
|
73 |
-
/* Load Tools */
|
74 |
-
SQ_ObjController::getController('SQ_Tools', false);
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
/* Load the Submit Actions Handler */
|
79 |
-
SQ_ObjController::getController('SQ_Action', false);
|
80 |
-
|
81 |
-
SQ_ObjController::getController('SQ_DisplayController', false);
|
82 |
-
|
83 |
-
/* show the admin menu and post actions */
|
84 |
-
$this->loadMenu();
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* initialize menu
|
89 |
-
*
|
90 |
-
* @return void
|
91 |
-
*/
|
92 |
-
private function loadMenu() {
|
93 |
-
/* get the menu from controller */
|
94 |
-
SQ_ObjController::getController('SQ_Menu');
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* first function call for any class
|
99 |
-
*
|
100 |
-
*/
|
101 |
-
protected function action() {
|
102 |
-
|
103 |
-
// check to see if the submitted nonce matches with the
|
104 |
-
// generated nonce we created
|
105 |
-
if (function_exists('wp_verify_nonce'))
|
106 |
-
if (!wp_verify_nonce(SQ_Tools::getValue('nonce'), _SQ_NONCE_ID_))
|
107 |
-
die('Invalid request!');
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* This function will load the media in the header for each class
|
112 |
-
*
|
113 |
-
* @return void
|
114 |
-
*/
|
115 |
-
public function hookHead() {
|
116 |
-
if (!is_admin())
|
117 |
-
return;
|
118 |
-
SQ_ObjController::getController('SQ_DisplayController', false)->init();
|
119 |
-
SQ_ObjController::getController('SQ_DisplayController', false)
|
120 |
-
->loadMedia($this->name);
|
121 |
-
}
|
122 |
-
|
123 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/SQ_ObjController.php
DELETED
@@ -1,197 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* The class creates object for plugin classes
|
5 |
-
*/
|
6 |
-
class SQ_ObjController {
|
7 |
-
|
8 |
-
/** @var array of instances */
|
9 |
-
public static $instances;
|
10 |
-
|
11 |
-
/** @var array from core config */
|
12 |
-
private static $config;
|
13 |
-
|
14 |
-
private static function includeController($className, $core) {
|
15 |
-
/* check if class is already defined */
|
16 |
-
if (!class_exists($className, false))
|
17 |
-
/* if $core == true then call the class from core directory */
|
18 |
-
try {
|
19 |
-
if (file_exists(($core ? _SQ_CONTROLLER_DIR_ : _SQ_CLASSES_DIR_) . $className . '.php'))
|
20 |
-
include_once(($core ? _SQ_CONTROLLER_DIR_ : _SQ_CLASSES_DIR_) . $className . '.php');
|
21 |
-
} catch (Exception $e) {
|
22 |
-
echo 'Controller Error: ' . $e->getMessage();
|
23 |
-
}
|
24 |
-
}
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Get the instance of the specified class
|
28 |
-
*
|
29 |
-
* @param string $className
|
30 |
-
* @param bool $core TRUE is the class is a core class or FALSE if it is from classes directory
|
31 |
-
*
|
32 |
-
* @return bool|object of the class
|
33 |
-
*/
|
34 |
-
public static function getController($className, $core = true) {
|
35 |
-
if (!isset(self::$instances[$className])) {
|
36 |
-
/* if $core == true then call the class from core directory */
|
37 |
-
self::includeController($className, $core);
|
38 |
-
|
39 |
-
if (class_exists($className)) {
|
40 |
-
self::$instances[$className] = new $className;
|
41 |
-
return self::$instances[$className];
|
42 |
-
}
|
43 |
-
} else
|
44 |
-
return self::$instances[$className];
|
45 |
-
|
46 |
-
return false;
|
47 |
-
}
|
48 |
-
|
49 |
-
private static function includeModel($className) {
|
50 |
-
|
51 |
-
/* check if class is already defined */
|
52 |
-
if (file_exists(_SQ_MODEL_DIR_ . $className . '.php'))
|
53 |
-
try {
|
54 |
-
include_once(_SQ_MODEL_DIR_ . $className . '.php');
|
55 |
-
} catch (Exception $e) {
|
56 |
-
echo 'Model Error: ' . $e->getMessage();
|
57 |
-
}
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Get the instance of the specified model class
|
62 |
-
*
|
63 |
-
* @param string $className
|
64 |
-
*
|
65 |
-
* @return bool|object of the class
|
66 |
-
*/
|
67 |
-
public static function getModel($className) {
|
68 |
-
/* add Model prefix */
|
69 |
-
$prefix = 'Model_';
|
70 |
-
|
71 |
-
if (!isset(self::$instances[$prefix . $className])) {
|
72 |
-
/* if $core == true then call the class from core directory */
|
73 |
-
self::includeModel($className);
|
74 |
-
|
75 |
-
//echo $className . '<br />';
|
76 |
-
if (class_exists($prefix . $className)) {
|
77 |
-
$classModel = $prefix . $className;
|
78 |
-
self::$instances[$prefix . $className] = new $classModel;
|
79 |
-
return self::$instances[$prefix . $className];
|
80 |
-
}
|
81 |
-
} else
|
82 |
-
return self::$instances[$prefix . $className];
|
83 |
-
|
84 |
-
return false;
|
85 |
-
}
|
86 |
-
|
87 |
-
private static function includeModelService($className) {
|
88 |
-
|
89 |
-
/* check if class is already defined */
|
90 |
-
if (file_exists(_SQ_SERVICE_DIR_ . $className . '.php'))
|
91 |
-
try {
|
92 |
-
include_once(_SQ_SERVICE_DIR_ . $className . '.php');
|
93 |
-
} catch (Exception $e) {
|
94 |
-
echo 'Model Service Error: ' . $e->getMessage();
|
95 |
-
}
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* Get the instance of the specified model service class
|
100 |
-
*
|
101 |
-
* @param string $className
|
102 |
-
*
|
103 |
-
* @return bool|object of the class
|
104 |
-
*/
|
105 |
-
public static function getModelService($className) {
|
106 |
-
/* add Model_Service prefix */
|
107 |
-
$prefix = 'Model_Service_';
|
108 |
-
|
109 |
-
if (!isset(self::$instances[$prefix . $className])) {
|
110 |
-
/* if $core == true then call the class from core directory */
|
111 |
-
self::includeModelService($className);
|
112 |
-
|
113 |
-
//echo $className . '<br />';
|
114 |
-
if (class_exists($prefix . $className)) {
|
115 |
-
$classModel = $prefix . $className;
|
116 |
-
self::$instances[$prefix . $className] = new $classModel;
|
117 |
-
return self::$instances[$prefix . $className];
|
118 |
-
}
|
119 |
-
} else
|
120 |
-
return self::$instances[$prefix . $className];
|
121 |
-
|
122 |
-
return false;
|
123 |
-
}
|
124 |
-
|
125 |
-
private static function includeBlock($className) {
|
126 |
-
|
127 |
-
/* check if class is already defined */
|
128 |
-
try {
|
129 |
-
require_once(_SQ_CORE_DIR_ . $className . '/' . $className . '.php');
|
130 |
-
} catch (Exception $e) {
|
131 |
-
echo 'Model Error: ' . $e->getMessage();
|
132 |
-
}
|
133 |
-
}
|
134 |
-
|
135 |
-
/**
|
136 |
-
* Get the instance of the specified block from core directory
|
137 |
-
*
|
138 |
-
* @param string $className
|
139 |
-
*
|
140 |
-
* @return bool|object of the class
|
141 |
-
*/
|
142 |
-
public static function getBlock($className) {
|
143 |
-
|
144 |
-
if (!isset(self::$instances[$className])) {
|
145 |
-
/* if $core == true then call the class from core directory */
|
146 |
-
self::includeBlock($className);
|
147 |
-
|
148 |
-
//echo $className . '<br />';
|
149 |
-
if (class_exists($className)) {
|
150 |
-
self::$instances[$className] = new $className;
|
151 |
-
return self::$instances[$className];
|
152 |
-
} else
|
153 |
-
exit("Block error: Can't call $className class");
|
154 |
-
} else
|
155 |
-
return self::$instances[$className];
|
156 |
-
|
157 |
-
return false;
|
158 |
-
}
|
159 |
-
|
160 |
-
/**
|
161 |
-
* Get all core classes from config.xml in core directory
|
162 |
-
*
|
163 |
-
* @param string $for
|
164 |
-
*/
|
165 |
-
public function getBlocks($for) {
|
166 |
-
/* if config allready in cache */
|
167 |
-
if (!isset(self::$config)) {
|
168 |
-
$config_file = _SQ_CORE_DIR_ . 'config.xml';
|
169 |
-
if (!file_exists($config_file))
|
170 |
-
return;
|
171 |
-
|
172 |
-
/* load configuration blocks data from core config files */
|
173 |
-
$data = file_get_contents($config_file);
|
174 |
-
self::$config = json_decode(json_encode((array)simplexml_load_string($data)), 1);;
|
175 |
-
}
|
176 |
-
//print_r(self::$config);
|
177 |
-
if (is_array(self::$config))
|
178 |
-
foreach (self::$config['block'] as $block) {
|
179 |
-
if ($block['active'] == 1)
|
180 |
-
if (isset($block['controllers']['controller']))
|
181 |
-
if (!is_array($block['controllers']['controller'])) {
|
182 |
-
/* if the block should load for the current controller */
|
183 |
-
if ($for == $block['controllers']['controller']) {
|
184 |
-
SQ_ObjController::getBlock($block['name'])->init();
|
185 |
-
}
|
186 |
-
} else {
|
187 |
-
foreach ($block['controllers']['controller'] as $controller) {
|
188 |
-
/* if the block should load for the current controller */
|
189 |
-
if ($for == $controller) {
|
190 |
-
SQ_ObjController::getBlock($block['name'])->init();
|
191 |
-
}
|
192 |
-
}
|
193 |
-
}
|
194 |
-
}
|
195 |
-
}
|
196 |
-
|
197 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|