Sidekick - Version 2.6.1

Version Description

  • Fixes to multsite network activation bug for invalid logins
Download this release

Release Info

Developer raptor235
Plugin Icon 128x128 Sidekick
Version 2.6.1
Comparing to
See all releases

Code changes from version 2.6.0 to 2.6.1

Files changed (4) hide show
  1. libs/licensing.php +8 -7
  2. readme.txt +4 -1
  3. sidekick.php +5 -4
  4. sidekick_embed.php +0 -1792
libs/licensing.php CHANGED
@@ -146,13 +146,7 @@ if (!class_exists('sidekickMassActivator')) {
146
 
147
  // var_dump("FUNCTION: send_request [$type] -> $end_point");
148
 
149
- if (strpos($_SERVER['SERVER_PROTOCOL'], 'https') === false) {
150
- $protocol = 'http:';
151
- } else {
152
- $protocol = 'https:';
153
- }
154
-
155
- $url = $protocol . SK_API . $end_point;
156
  $sk_token = get_transient('sk_token');
157
 
158
  if (!$sk_token && $end_point !== '/login') {
@@ -184,6 +178,13 @@ if (!class_exists('sidekickMassActivator')) {
184
 
185
  $result = wp_remote_post($url, $args);
186
 
 
 
 
 
 
 
 
187
  if ($result['response']['message'] == 'Unauthorized' && !$second_attempt) {
188
  // var_dump('Getting rid of token and trying again');
189
  delete_transient('sk_token');
146
 
147
  // var_dump("FUNCTION: send_request [$type] -> $end_point");
148
 
149
+ $url = SK_API . $end_point;
 
 
 
 
 
 
150
  $sk_token = get_transient('sk_token');
151
 
152
  if (!$sk_token && $end_point !== '/login') {
178
 
179
  $result = wp_remote_post($url, $args);
180
 
181
+ if ($end_point == '/login' && $result['response']['message'] == 'Unauthorized') {
182
+ // If tried to login and is unauthorized return;
183
+ update_option('sk_auto_activation_error', $result->message);
184
+ delete_transient('sk_token');
185
+ return array('error' => $result->message);
186
+ }
187
+
188
  if ($result['response']['message'] == 'Unauthorized' && !$second_attempt) {
189
  // var_dump('Getting rid of token and trying again');
190
  delete_transient('sk_token');
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.sidekick.pro
4
  Tags: help, tutorial, tutorials,screencast, self-help, training, learn, learning, sidekick, guide, teach, video, manual, videos, wphelp, support, instructions, question, questions, answers, answer, clippy, q&a, wpuniversity, helper, walkthrough
5
  Requires at least: 3.7
6
  Tested up to: 4.2
7
- Stable tag: 2.6.0
8
  License: GNU Version 2 or Any Later Version
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -145,6 +145,9 @@ We read and respond to every piece of feedback we get.
145
 
146
  == Changelog ==
147
 
 
 
 
148
  = 2.6.0 =
149
  * WordPress 4.3 compatibility
150
  * Upgrade directly from SIDEKICK
4
  Tags: help, tutorial, tutorials,screencast, self-help, training, learn, learning, sidekick, guide, teach, video, manual, videos, wphelp, support, instructions, question, questions, answers, answer, clippy, q&a, wpuniversity, helper, walkthrough
5
  Requires at least: 3.7
6
  Tested up to: 4.2
7
+ Stable tag: 2.6.1
8
  License: GNU Version 2 or Any Later Version
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
145
 
146
  == Changelog ==
147
 
148
+ = 2.6.1 =
149
+ * Fixes to multsite network activation bug for invalid logins
150
+
151
  = 2.6.0 =
152
  * WordPress 4.3 compatibility
153
  * Upgrade directly from SIDEKICK
sidekick.php CHANGED
@@ -6,7 +6,7 @@ Plugin URL: http://wordpress.org/plugins/sidekick/
6
  Description: Adds a real-time WordPress training walkthroughs right in your Dashboard
7
  Requires at least: 4.0
8
  Tested up to: 4.3
9
- Version: 2.6.0
10
  Author: Sidekick.pro
11
  Author URI: http://www.sidekick.pro
12
  */
@@ -23,7 +23,8 @@ if (!class_exists('Sidekick')){
23
  class Sidekick{
24
 
25
  function __construct(){
26
- if (!defined('SK_CACHE_PREFIX')) define('SK_CACHE_PREFIX',str_replace('.', '_', '2.6.0'));
 
27
  }
28
 
29
  function enqueue_required(){
@@ -291,7 +292,7 @@ if (!class_exists('Sidekick')){
291
 
292
  // WordPress
293
  "embed_partner_id" => SK_EMBEDDED_PARTNER, // for tracking purposes if sidekick has been embeded in another WordPress plugin or theme
294
- "plugin_version" => '2.6.0', // WordPress plugin version
295
  "site_url" => $sk_config_data->get_domain(),
296
  "domain" => str_replace("http://","",$_SERVER["SERVER_NAME"]),
297
  "plugin_url" => admin_url("admin.php?page=sidekick"),
@@ -347,7 +348,7 @@ if (!class_exists('Sidekick')){
347
  function check_ver(){
348
 
349
  if (isset($_GET['sk_ver_check'])){
350
- $data = json_encode('2.6.0');
351
 
352
  if(array_key_exists('callback', $_GET)){
353
 
6
  Description: Adds a real-time WordPress training walkthroughs right in your Dashboard
7
  Requires at least: 4.0
8
  Tested up to: 4.3
9
+ Version: 2.6.1
10
  Author: Sidekick.pro
11
  Author URI: http://www.sidekick.pro
12
  */
23
  class Sidekick{
24
 
25
  function __construct(){
26
+ if (!defined('SK_API')) define('SK_API','https: //apiv2.sidekick.pro');
27
+ if (!defined('SK_CACHE_PREFIX')) define('SK_CACHE_PREFIX',str_replace('.', '_', '2.6.1'));
28
  }
29
 
30
  function enqueue_required(){
292
 
293
  // WordPress
294
  "embed_partner_id" => SK_EMBEDDED_PARTNER, // for tracking purposes if sidekick has been embeded in another WordPress plugin or theme
295
+ "plugin_version" => '2.6.1', // WordPress plugin version
296
  "site_url" => $sk_config_data->get_domain(),
297
  "domain" => str_replace("http://","",$_SERVER["SERVER_NAME"]),
298
  "plugin_url" => admin_url("admin.php?page=sidekick"),
348
  function check_ver(){
349
 
350
  if (isset($_GET['sk_ver_check'])){
351
+ $data = json_encode('2.6.1');
352
 
353
  if(array_key_exists('callback', $_GET)){
354
 
sidekick_embed.php DELETED
@@ -1,1792 +0,0 @@
1
- <?php
2
-
3
- /*
4
- SIDEKICK Embed Plugin
5
- Plugin URL: http://wordpress.org/plugins/sidekick/
6
- Description: Adds a real-time WordPress training walkthroughs right in your Dashboard.
7
- This SIDEKICK embed file will enable SIDEKICK as part of your plugin or theme. This is strictly a configuration plugin for the SIDEKICK platform, the actual platform is requested directly from our servers.
8
- We recommend not activating SIDEKICK automatically for people but via an Opt-In process when they configure your own theme or plugin.
9
- Requires at least: 4.0
10
- Tested up to: 4.3
11
- Version: 2.6.0
12
- Author: Sidekick.pro
13
- Author URI: http://www.sidekick.pro
14
- */
15
-
16
-
17
- if ( ! defined( 'SK_EMBEDDED_PARTNER' ) ) define( 'SK_EMBEDDED_PARTNER', '' );
18
-
19
- if ( ! function_exists('mlog')) {
20
- function mlog(){}
21
- }
22
-
23
- $sidekick_active = null;
24
- if (!function_exists('is_plugin_active')) { include_once( ABSPATH . 'wp-admin/includes/plugin.php' );}
25
- if (function_exists('is_plugin_active')) { $sidekick_active = is_plugin_active('sidekick/sidekick.php');}
26
- if (!$sidekick_active && !class_exists('Sidekick')){
27
-
28
- class Sidekick{
29
-
30
- function __construct(){
31
- if (!defined('SK_CACHE_PREFIX')) define('SK_CACHE_PREFIX',str_replace('.', '_', '2.6.0'));
32
- }
33
-
34
- function enqueue_required(){
35
- wp_enqueue_script('jquery' , null );
36
- wp_enqueue_script('underscore' , null, array('underscore'));
37
- wp_enqueue_script('backbone' , null, array('jquery','underscore'));
38
- wp_enqueue_script('jquery-ui-core' , null, array('jquery') );
39
- wp_enqueue_script('jquery-ui-position' , null, array('jquery-ui-core') );
40
- wp_enqueue_script('jquery-ui-draggable' , null, array('jquery-ui-core') );
41
- wp_enqueue_script('jquery-ui-droppable' , null, array('jquery-ui-core') );
42
- wp_enqueue_script('jquery-effects-scale' , null, array('jquery-ui-core') );
43
- wp_enqueue_script('jquery-effects-highlight' , null, array('jquery-ui-core') );
44
- wp_enqueue_script('sidekick-admin' , '//assets.sidekick.pro/plugin/tag/latest/js/sidekick_admin.js',array( 'jquery' ), null);
45
- wp_enqueue_script('sidekick' ,"//loader.sidekick.pro/platforms/d9993157-d972-4c49-93be-a0c684096961.js", array('backbone','jquery','underscore','jquery-effects-highlight'),null,true);
46
- wp_enqueue_style('wp-pointer');
47
- wp_enqueue_script('wp-pointer');
48
-
49
- do_action('post_enqueue_required');
50
-
51
- }
52
-
53
- function setup_menu(){
54
- add_submenu_page( 'options-general.php', 'Sidekick', 'Sidekick', 'activate_plugins','sidekick', array(&$this,'admin_page'));
55
- }
56
-
57
- function activate($return = false){
58
- mlog("activate");
59
- if (isset($_POST['activation_id']) && current_user_can('install_plugins')) {
60
- mlog("activate2");
61
- update_option('sk_activation_id',$_POST['activation_id']);
62
- return true;
63
- }
64
- }
65
-
66
- function upgrade(){
67
- mlog("upgrade");
68
-
69
- if (!isset($_POST['authorization']) || !wp_verify_nonce($_POST['authorization'], 'sk_upgrade')) {
70
- die('-1');
71
- }
72
-
73
- return $this->activate();
74
- }
75
-
76
- function admin_page(){
77
-
78
- if ( empty( $_POST ) || check_admin_referer( 'update_sk_settings' ) ) {
79
-
80
- if (isset($_POST['option_page']) && $_POST['option_page'] == 'sk_license') {
81
-
82
- if (isset($_POST['activation_id']) && $_POST['activation_id'] && strpos($_POST['activation_id'], '-xxxx-xxxx') === false){
83
- $result = $this->activate(true);
84
- } else if (isset($_POST['activation_id']) && strpos($_POST['activation_id'], '-xxxx-xxxx') === false) {
85
- delete_option('sk_activation_id');
86
- }
87
-
88
- if (isset($_POST['sk_track_data'])) {
89
- update_option( 'sk_track_data', true );
90
- } else {
91
- delete_option('sk_track_data');
92
- }
93
-
94
- update_option( 'sk_activated', true );
95
- die('<script>window.open("' . get_site_url() . '/wp-admin/options-general.php?page=sidekick","_self")</script>');
96
- }
97
-
98
- }
99
-
100
- $activation_id = (get_option( "sk_activation_id" ) ? get_option( "sk_activation_id" ) : '');
101
- $sk_track_data = get_option( 'sk_track_data' );
102
-
103
- $sk_hide_composer_taskbar_button = get_option('sk_hide_composer_taskbar_button');
104
- $sk_hide_config_taskbar_button = get_option('sk_hide_config_taskbar_button');
105
- $sk_hide_composer_upgrade_button = get_option('sk_hide_composer_upgrade_button');
106
-
107
- $current_user = wp_get_current_user();
108
- $status = 'Free';
109
- $error = null;
110
- $affiliate_id = $this->getAffiliateId();
111
-
112
- if (isset($SK_PAID_LIBRARY_FILE) && $activation_id) {
113
- $_POST['activation_id'] = $activation_id;
114
- $check_activation = $this->activate(true);
115
- $status = 'Checking...';
116
- }
117
-
118
- global $wp_version;
119
- if (version_compare($wp_version, '3.9', '<=')) {
120
- $error = "Sorry, Sidekick requires WordPress 3.9 or higher to function.";
121
- }
122
-
123
- if (!$activation_id) {
124
- $warn = "You're using the <b>free</b> version of Sidekick, to upgrade or get your license key, visit your <a target='_blank' href='http://www.sidekick.pro/plans/#/login?utm_source=plugin&utm_medium=settings&utm_campaign=upgrade_nag'>account page</a> or <a target='_blank' href='http://www.sidekick.pro/plans/?utm_source=plugin&utm_medium=settings&utm_campaign=upgrade_nag'>sign-up</a> for a paid plan.";
125
- }
126
-
127
- if(preg_match('/(?i)msie [6-8]/',$_SERVER['HTTP_USER_AGENT'])){
128
- $error = "Sorry, Sidekick requires Internet Explorer 9 or higher to function.";
129
- }
130
-
131
- ?>
132
-
133
- <?php if (get_option('sk_firstuse') == true): ?>
134
- <?php delete_option('sk_firstuse') ?>
135
- <script type="text/javascript">
136
- jQuery(document).ready(function($) {
137
- jQuery('#sidekick #logo').trigger('click');
138
- });
139
- </script>
140
- <?php endif ?>
141
-
142
- <div class="wrap">
143
-
144
- <script type="text/javascript">
145
- if (typeof ajax_url === 'undefined') {
146
- ajax_url = '<?php echo admin_url() ?>admin-ajax.php';
147
- }
148
- var last_site_key = null;
149
- var sk_ms_admin = false;
150
-
151
- </script>
152
-
153
- <div class="page-header"><h2><a id="pluginlogo_32" class="header-icon32" href="http://www.sidekick.pro/modules/wordpress-core-module-premium/?utm_source=plugin&utm_medium=settings&utm_campaign=header" target="_blank"></a>Sidekick Dashboard</h2></div>
154
-
155
- <h3>Welcome to the fastest and easiest way to learn WordPress</h3>
156
-
157
- <?php if (isset($error_message) && $error_message): ?>
158
- <div class="error" id="sk_dashboard_message">
159
- <p>There was a problem activating your license. The following error occured <?php echo $error_message ?></p>
160
- </div>
161
- <?php elseif (isset($error) && $error): ?>
162
- <div class="error" id="sk_dashboard_message">
163
- <p><?php echo $error ?></p>
164
- </div>
165
- <?php elseif (isset($warn) && $warn): ?>
166
- <div class="updated" id="sk_dashboard_message">
167
- <p><?php echo $warn ?></p>
168
- </div>
169
- <?php elseif (isset($success) && $success): ?>
170
- <div class="updated" id="sk_dashboard_message">
171
- <p><?php echo $success ?></p>
172
- </div>
173
- <?php endif ?>
174
-
175
- <div class="sidekick_admin">
176
-
177
- <div class="sk_box left">
178
- <div class="wrapper_left">
179
- <div class="sk_box license">
180
- <div class="well">
181
- <?php if (!$error): ?>
182
- <h3>My Sidekick Account</h3>
183
- <form method="post">
184
- <?php settings_fields('sk_license'); ?>
185
- <table class="form-table">
186
- <tbody>
187
- <tr valign="top">
188
- <th scope="row" valign="top">Activation ID</th>
189
- <?php if (is_multisite()): ?>
190
- <?php if (isset($activation_id) && $activation_id): ?>
191
- <td><input class='regular-text' style='color: gray;' type='text' name='activation_id' value='xxxxxxxx-xxxx-xxxx-xxxx-<?php echo substr($activation_id, 25,20) ?>'></input></td>
192
- <?php else: ?>
193
- <td><input class='regular-text' style='color: gray;' type='text' name='activation_id' ></input></td>
194
- <?php endif ?>
195
- <?php else: ?>
196
- <td><input class='regular-text' type='text' name='activation_id' value='<?php echo $activation_id ?>'></input></td>
197
- <?php endif ?>
198
- </tr>
199
-
200
- <tr valign="top">
201
- <th scope="row" valign="top">Status</th>
202
- <td><span style='color: blue' class='sk_license_status'><span><?php echo ucfirst($status) ?></span> <a style='display: none' class='sk_upgrade' href='http://www.sidekick.pro/modules/wordpress-core-module-premium/?utm_source=plugin&utm_medium=settings&utm_campaign=upgrade<?php echo ($affiliate_id) ? '&ref=' . $affiliate_id : '' ?>' target="_blank"> Upgrade Now!</a> </span></td>
203
- </tr>
204
-
205
- <tr valign="top">
206
- <th scope="row" valign="top">
207
- Data Tracking
208
- </th>
209
- <td>
210
- <input name="sk_track_data" type="checkbox" <?php if ($sk_track_data): ?>CHECKED<?php endif ?> />
211
- <input type='hidden' name='status' value='<?php echo $status ?>'/>
212
- <label class="description" for="track_data">Help Sidekick by providing tracking data which will help us build better help tools.</label>
213
- </td>
214
- </tr>
215
-
216
- <tr valign="top">
217
- <th scope="row" valign="top">
218
- Enable Composer Mode
219
- </th>
220
- <td>
221
- <button type='button' class='open_composer'>Open Composer</button>
222
- </td>
223
- </tr>
224
- </tbody>
225
- </table>
226
- <?php submit_button('Update'); ?>
227
- <?php wp_nonce_field( 'update_sk_settings' ); ?>
228
- </form>
229
- <?php endif ?>
230
- </div>
231
- </div>
232
-
233
- <div class="sk_box composer" style='display: none'>
234
- <div class="well">
235
- <h3>Build Your Own Walkthroughs</h3>
236
- <a href='http://www.sidekick.pro/plans/create_wp_walkthroughs/?utm_source=plugin&utm_medium=settings&utm_campaign=composer<?php echo ($affiliate_id) ? '&ref=' . $affiliate_id : '' ?>' target='_blank'><div class='composer_beta_button'>Build Your Own<br/>Walkthroughs</div></a>
237
- <ul>
238
- <li>Get more info about <a href='http://www.sidekick.pro/how-it-works/?utm_source=plugin&utm_medium=settings&utm_campaign=composer<?php echo ($affiliate_id) ? '&ref=' . $affiliate_id : '' ?>' target='_blank'>Custom Walkthroughs</a> now!</li>
239
- <li><a href="http://www.sidekick.pro/plans/create_wp_walkthroughs/?utm_source=plugin&utm_medium=settings&utm_campaign=composer" target="_blank">Check out our custom walkthroughs plans</a></li>
240
- </ul>
241
- </div>
242
- </div>
243
-
244
- <div class="sk_box you_should_know">
245
- <div class="well">
246
- <h3>Few Things you should know:</h3>
247
- <div class="">
248
- <ul>
249
- <li>Clicking the check-box above will allow us to link your email address to the stats we collect so we can contact you if we have a question or notice an issue. It’s not mandatory, but it would help us out.</li>
250
- <li>Your Activation ID is unique and limited to your production, staging, and development urls.</li>
251
- <li>The Sidekick team adheres strictly to CANSPAM. From time to time we may send critical updates (such as security notices) to the email address setup as the Administrator on this site.</li>
252
- <li>If you have any questions, bug reports or feedback, please send them to <a target="_blank" href="mailto:support@sidekick.pro">us</a> </li>
253
- <li>You can find our terms of use <a target="_blank" href="http://www.sidekick.pro/terms-of-use/<?php echo ($affiliate_id) ? '&ref=' . $affiliate_id : '' ?>">here</a></li>
254
- </ul>
255
- </div>
256
- </div>
257
- </div>
258
-
259
- <div class="sk_box advanced">
260
- <div class="well">
261
- <h3>Advanced</h3>
262
- <form method="post">
263
- <table class="form-table">
264
- <tbody>
265
- <tr valign="top">
266
- <th scope="row" valign="top">API</th>
267
- <td>
268
- <select name='sk_api'>
269
- <?php if (get_option('sk_api') == 'production'): ?>
270
- <option value='production' SELECTED>Production</option>
271
- <option value='staging'>Staging</option>
272
- <?php else: ?>
273
- <option value='production' >Production</option>
274
- <option value='staging' SELECTED>Staging</option>
275
- <?php endif ?>
276
- </select>
277
- </td>
278
- </tr>
279
- </tbody>
280
- </table>
281
-
282
- <?php wp_nonce_field( 'update_sk_settings' ); ?>
283
- <input class='button button-primary' type='submit' value='Save'/>
284
- </form>
285
-
286
- </div>
287
- </div>
288
-
289
- </div>
290
- </div>
291
-
292
- <div class="sk_box right">
293
- <div class="wrapper_right">
294
-
295
- <div class="sk_box configure">
296
- <div class="well">
297
- <h3> echo (isset($is_ms_admin)) ? 'Network ' : '' ?>Configure - Auto Start</h3>
298
-
299
- <form method='post'>
300
-
301
- <p>This Walkthrough will be played once for every user that logs into the backend of WordPress.</p>
302
- <select name='sk_autostart_walkthrough_id'>
303
- <option value='0'>No Auto Start</option>
304
- </select>
305
- <input class='button button-primary' type='submit' value='Save'/>
306
- <input type='hidden' name='is_ms_admin' value='<?php echo (isset($is_ms_admin)) ? $is_ms_admin : false ?>'/>
307
- <input type='hidden' name='sk_setting_autostart' value='true'/>
308
-
309
- <?php wp_nonce_field( 'update_sk_settings' ); ?>
310
- </form>
311
- </div>
312
- </div>
313
-
314
- <div class="sk_box configure">
315
- <div class="well">
316
- <h3><?php echo (isset($is_ms_admin)) ? 'Network ' : '' ?>Configure - Other</h3>
317
-
318
- <form method="post">
319
- <?php settings_fields('sk_license'); ?>
320
- <table class="form-table long_label">
321
- <tbody>
322
-
323
- <tr valign="top">
324
- <th scope="row" valign="top">Hide Composer Button in Taskbar</th>
325
- <td>
326
- <input class='checkbox' type='checkbox' name='sk_hide_composer_taskbar_button' <?php echo (isset($sk_hide_composer_taskbar_button) && $sk_hide_composer_taskbar_button) ? 'CHECKED' : '' ?>>
327
- </td>
328
- </tr>
329
- <tr valign="top">
330
- <th scope="row" valign="top">Hide Config Button in Taskbar</th>
331
- <td>
332
- <input class='checkbox' type='checkbox' name='sk_hide_config_taskbar_button' <?php echo (isset($sk_hide_config_taskbar_button) && $sk_hide_config_taskbar_button) ? 'CHECKED' : '' ?>>
333
- </td>
334
- </tr>
335
- <tr valign="top">
336
- <th scope="row" valign="top">Hide Composer Upgrade Button in Drawer</th>
337
- <td>
338
- <input class='checkbox' type='checkbox' name='sk_hide_composer_upgrade_button' <?php echo (isset($sk_hide_composer_upgrade_button) && $sk_hide_composer_upgrade_button) ? 'CHECKED' : '' ?>>
339
- </td>
340
- </tr>
341
- <tr valign="top">
342
- <th scope="row" valign="top"></th>
343
- <td>
344
- <input class='button button-primary' type='submit' value='Save'/>
345
- </td>
346
- </tr>
347
-
348
- <input type='hidden' name='is_ms_admin' value='<?php echo (isset($is_ms_admin)) ? $is_ms_admin : false ?>'/>
349
- <input type='hidden' name='sk_setting_other' value='true'/>
350
-
351
- <?php wp_nonce_field( 'update_sk_settings' ); ?>
352
-
353
- </tbody>
354
- </table>
355
- </form>
356
- </div>
357
- </div>
358
-
359
- <div class="sk_box configure">
360
- <div class="well">
361
- <form method='post'>
362
-
363
- <input class='top-right button button-primary alignright' type='submit' value='Save'/>
364
- <h3><?php echo (isset($is_ms_admin)) ? 'Network ' : '' ?>Configure - Turn Off Walkthroughs</h3>
365
-
366
- <p>Below you can turn off specific Walkthroughs for this website.</p>
367
- <p>Please note, incompatible multisite walkthroughs will be disabled automatically on individual sites already. Here you're being show the raw unfiltered list of all available walkthroughs.</p>
368
- <div class='sk_walkthrough_list wrapper_wts'>
369
- Loading...
370
- </div>
371
- <input class='button button-primary' type='submit' value='Save'/>
372
- <input type='hidden' name='sk_setting_disabled' value='true'/>
373
- <input type='hidden' name='is_ms_admin' value='<?php echo (isset($is_ms_admin)) ? $is_ms_admin : false ?>'/>
374
- <?php wp_nonce_field( 'update_sk_settings' ); ?>
375
- </form>
376
- </div>
377
- </div>
378
-
379
- <div class="sk_box love">
380
- <div class="well">
381
- <h3>Love the Sidekick plugin?</h3>
382
- <ul>
383
- <li>Please help spread the word!</li>
384
- <li><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://sidekick.pro" data-text="I use @sidekickhelps for the fastest and easiest way to learn WordPress." data-via="sidekickhelps" data-size="large">Tweet</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></li>
385
- <li>Like SIDEKICK? Please leave us a 5 star rating on <a href='http://WordPress.org' target='_blank'>WordPress.org</a></li>
386
- <li><a href="http://www.sidekick.pro/plans/wordpress-basics/<?php echo ($affiliate_id) ? '&ref=' . $affiliate_id : '' ?>">Sign up for a full WordPress Basics package</a></li>
387
- <li><a href="http://support.sidekick.pro/collection/50-quick-start-guides" target="_blank"><strong>Visit the SIDEKICK Quick Start guides</strong></a>.</li>
388
- </ul>
389
- </div>
390
- </div>
391
- </div>
392
- </div>
393
-
394
-
395
-
396
-
397
-
398
- </div>
399
- <?php
400
- }
401
-
402
- function set_disabled_wts(){
403
-
404
- if (isset($_POST['sk_setting_disabled'])){
405
-
406
- if (!check_admin_referer('update_sk_settings')) {
407
- print 'Sorry, your nonce did not verify or you\'re not logged in.';
408
- exit;
409
- }
410
-
411
- if (isset($_POST['disable_wts']) && $_POST['disable_wts']) {
412
- update_option('sk_disabled_wts',json_encode($_POST['disable_wts']));
413
- if (isset($_POST['is_ms_admin']) && $_POST['is_ms_admin']) {
414
- update_site_option('sk_disabled_wts',json_encode($_POST['disable_wts']));
415
- }
416
- } else {
417
- delete_option('sk_disabled_wts');
418
- if (isset($_POST['is_ms_admin']) && $_POST['is_ms_admin']) {
419
- delete_site_option('sk_disabled_wts');
420
- }
421
- }
422
- }
423
-
424
- }
425
-
426
- function set_autostart_wt(){
427
-
428
- if (isset($_POST['sk_setting_autostart'])){
429
-
430
- if (!check_admin_referer('update_sk_settings')) {
431
- print 'Sorry, your nonce did not verify or you\'re not logged in.';
432
- exit;
433
- }
434
-
435
- if (isset($_POST['sk_autostart_walkthrough_id']) && intval($_POST['sk_autostart_walkthrough_id']) > 0){
436
- if (isset($_POST['is_ms_admin']) && $_POST['is_ms_admin']) {
437
- update_site_option('sk_autostart_walkthrough_id',wp_filter_kses($_POST['sk_autostart_walkthrough_id']));
438
- }
439
- update_option('sk_autostart_walkthrough_id',wp_filter_kses($_POST['sk_autostart_walkthrough_id']));
440
- } else {
441
- delete_option('sk_autostart_walkthrough_id');
442
- if (isset($_POST['is_ms_admin']) && $_POST['is_ms_admin']) {
443
- delete_site_option('sk_autostart_walkthrough_id');
444
- }
445
- }
446
- }
447
-
448
- }
449
-
450
- function set_configure_other(){
451
-
452
- if (isset($_POST['sk_setting_other'])){
453
-
454
- if (!check_admin_referer('update_sk_settings')) {
455
- print 'Sorry, your nonce did not verify or you\'re not logged in.';
456
- exit;
457
- }
458
-
459
- $checkboxes = array('sk_hide_composer_taskbar_button','sk_hide_config_taskbar_button','sk_hide_composer_upgrade_button');
460
-
461
- foreach ($checkboxes as $key => $checkbox) {
462
- if (isset($_POST[$checkbox])){
463
- if (isset($_POST['is_ms_admin']) && $_POST['is_ms_admin']) {
464
- update_site_option($checkbox,wp_filter_kses($_POST[$checkbox]));
465
- }
466
- update_option($checkbox,wp_filter_kses($_POST[$checkbox]));
467
- } else {
468
- delete_option($checkbox);
469
- if (isset($_POST['is_ms_admin']) && $_POST['is_ms_admin']) {
470
- delete_site_option($checkbox);
471
- }
472
- }
473
- }
474
-
475
- }
476
-
477
- }
478
-
479
- function getAffiliateId(){
480
- if (defined('SK_AFFILIATE_ID')) {
481
- $affiliate_id = intval(SK_AFFILIATE_ID);
482
- } else if (get_option( "sk_affiliate_id")){
483
- $affiliate_id = intval(get_option( "sk_affiliate_id"));
484
- } else {
485
- $affiliate_id = '';
486
- }
487
- return $affiliate_id;
488
- }
489
-
490
- function footer(){
491
- global $current_user;
492
-
493
-
494
-
495
- $sk_config_data = new sk_config_data;
496
- $current_user = (get_option( 'sk_track_data' )) ? wp_get_current_user() : null;
497
- $autostart_network_walkthrough_id = (get_site_option('sk_autostart_walkthrough_id') ? get_site_option('sk_autostart_walkthrough_id') : null );
498
- $autostart_walkthrough_id = (get_option('sk_autostart_walkthrough_id') ? get_option('sk_autostart_walkthrough_id') : $autostart_network_walkthrough_id );
499
- $theme = wp_get_theme();
500
- $installed_plugins = $sk_config_data->get_plugins();
501
- $file_editor_enabled = $sk_config_data->get_file_editor_enabled();
502
- $affiliate_id = $this->getAffiliateId();
503
-
504
- $sk_hide_composer_taskbar_button = false;
505
-
506
- if (get_option( 'sk_hide_composer_taskbar_button' ) || get_site_option( 'sk_hide_composer_taskbar_button' )) {
507
- $sk_hide_composer_taskbar_button = true;
508
- }
509
-
510
- $sk_hide_config_taskbar_button = false;
511
-
512
- if (get_option( 'sk_hide_config_taskbar_button' ) || get_site_option( 'sk_hide_config_taskbar_button' )) {
513
- $sk_hide_config_taskbar_button = true;
514
- }
515
-
516
- $sk_config = array(
517
- "compatibilities" => array(
518
- "comment_count" => $sk_config_data->get_comments(),
519
- "domain" => str_replace("http://","",$_SERVER["SERVER_NAME"]),
520
- "installed_plugins" => (isset($installed_plugins)) ? $installed_plugins : array(),
521
- "installed_theme" => sanitize_title($theme->Name),
522
- "is_multisite" => (is_multisite()) ? true : false,
523
- "main_soft_version" => get_bloginfo("version"),
524
- "number_of_themes" => $sk_config_data->get_themes(),
525
- "page_for_posts" => intval(get_option('page_for_posts')),
526
- "page_on_front" => intval(get_option('page_on_front')),
527
- "plugin_count" => (isset($installed_plugins) && is_array($installed_plugins)) ? count($installed_plugins) : 0,
528
- "role" => $sk_config_data->get_user_role(),
529
- "show_on_front" => get_option('show_on_front'),
530
- "theme_version" => $theme->Version
531
- ),
532
-
533
- // Platform
534
- "baseClientUrl" => site_url(),
535
- "base_url" => site_url(),
536
-
537
- // User Settings
538
- "activation_id" => (get_option( "sk_activation_id" ) ? get_option( "sk_activation_id" ) : ''),
539
- "custom_class" => (get_option( "sk_custom_class" ) ? get_option( "sk_custom_class" ) : ''),
540
- "affiliate_id" => $affiliate_id,
541
- "user_email" => ($current_user) ? $current_user->user_email : '',
542
- "autostart_walkthrough_id" => ($autostart_walkthrough_id) ? $autostart_walkthrough_id : '',
543
- "disable_wts" => ((!isset($_POST['is_ms_admin']) || !$_POST['is_ms_admin'])) ? $sk_config_data->get_disabled_wts() : array(), // Copying these to compatibilities, have to update this over time
544
- "disable_network_wts" => $sk_config_data->get_disabled_network_wts(), // Copying these to compatibilities, have to update this over time
545
-
546
- // Toggles
547
- "hide_taskbar_composer_button" => $sk_hide_composer_taskbar_button, // hide composer button on the taskbar
548
- "hide_taskbar_config_button" => $sk_hide_config_taskbar_button, // hide settings button on taskbar
549
- "show_login" => (get_option( 'sk_just_activated' )) ? true : false, // open drawer automatically, same as just_activated
550
-
551
- // WordPress
552
- "embed_partner_id" => SK_EMBEDDED_PARTNER, // for tracking purposes if sidekick has been embeded in another WordPress plugin or theme
553
- "plugin_version" => '2.6.0', // WordPress plugin version
554
- "site_url" => $sk_config_data->get_domain(),
555
- "domain" => str_replace("http://","",$_SERVER["SERVER_NAME"]),
556
- "plugin_url" => admin_url("admin.php?page=sidekick"),
557
-
558
- );
559
-
560
- if ($file_editor_enabled) { //
561
- $sk_config["compatibilities"]["file_editor_enabled"] = $file_editor_enabled;
562
- }
563
-
564
- $sk_config['compatibilities'] = array_merge($sk_config['compatibilities'],$sk_config_data->get_post_types());
565
- $sk_config['compatibilities'] = array_merge($sk_config['compatibilities'],$sk_config_data->get_taxonomies());
566
- $sk_config['compatibilities'] = array_merge($sk_config['compatibilities'],$sk_config_data->get_user_data());
567
- $sk_config['compatibilities'] = array_merge($sk_config['compatibilities'],$sk_config_data->get_post_statuses());
568
- $sk_config['compatibilities'] = array_merge($sk_config['compatibilities'],$sk_config_data->get_post_types_and_statuses());
569
- $sk_config['compatibilities'] = array_merge($sk_config['compatibilities'],$sk_config_data->get_framework());
570
- $sk_config = apply_filters('sk_config',$sk_config);
571
-
572
- delete_option( 'sk_just_activated' );
573
-
574
- ?>
575
-
576
- <!-- Old IE Not Supported -->
577
- <?php if (!preg_match('/(?i)msie [6-8]/',$_SERVER['HTTP_USER_AGENT'])): ?>
578
-
579
- <script type="text/preloaded" data-provider="sidekick">
580
- <?php echo json_encode($sk_config) ?>
581
- </script>
582
-
583
- <script type="text/javascript">
584
- var sk_nonce_upgrade = '<?php echo wp_create_nonce('sk_upgrade'); ?>'
585
- </script>
586
-
587
- <?php endif ?>
588
-
589
- <?php
590
- }
591
-
592
- function activate_plugin(){
593
- update_option( 'sk_firstuse', true );
594
- update_option( 'sk_do_activation_redirect', true );
595
- }
596
-
597
- function redirect(){
598
- if (get_option('sk_do_activation_redirect', false)) {
599
- delete_option('sk_do_activation_redirect');
600
- $siteurl = get_site_url();
601
- wp_redirect($siteurl . "/wp-admin/options-general.php?page=sidekick");
602
- die();
603
- }
604
- }
605
-
606
- function check_ver(){
607
-
608
- if (isset($_GET['sk_ver_check'])){
609
- $data = json_encode('2.6.0');
610
-
611
- if(array_key_exists('callback', $_GET)){
612
-
613
- header('Content-Type: text/javascript; charset=utf8');
614
- header('Access-Control-Allow-Origin: http://www.example.com/');
615
- header('Access-Control-Max-Age: 3628800');
616
- header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE');
617
-
618
- $callback = $_GET['callback'];
619
- echo $callback.'('.$data.');';
620
-
621
- }else{
622
- header('Content-Type: application/json; charset=utf8');
623
-
624
- echo $data;
625
- }
626
-
627
- die();
628
- }
629
-
630
- }
631
-
632
- function admin_notice() {
633
- global $current_user ;
634
- if ( ! get_user_meta($current_user->ID, 'sk_ignore_notice') ) {
635
- printf ('<div class="updated sidekick_welcome">
636
- <p>
637
- <b>Need help with WordPress?</b> - You can always find help in the bottom left corner, just click the Help button.</b>
638
- </p>
639
- <p>
640
- <a href="javascript: sidekick.play_intro(true); Sidekick.Events.trigger(\'track_play_intro\',{location: \'welcome_header\'})" class="sk_wp_primary button button-primary">
641
- What\'s Sidekick?
642
- </a>
643
- <a href="%1$s" class="button-secondary button skip">No Thanks</a>
644
- </p>
645
- </div>',
646
- wp_nonce_url('?sk_ignore_notice=1','hide_msg', 'sk_nonce'));
647
- }
648
- }
649
-
650
- function admin_notice_ignore() {
651
- global $current_user;
652
-
653
- if (!isset($_GET['sk_nonce']) || !wp_verify_nonce($_GET['sk_nonce'], 'hide_msg')) {
654
- return false;
655
- }
656
-
657
- if ( isset($_GET['sk_ignore_notice'])) {
658
- add_user_meta($current_user->ID, 'sk_ignore_notice', true);
659
- }
660
- }
661
-
662
- // Clear transients for cached sk_config_data
663
-
664
- function delete_sk_get_comments(){
665
- delete_transient('sk_' . SK_CACHE_PREFIX . '_get_comments');
666
- }
667
-
668
- function delete_sk_get_post_types(){
669
- delete_transient('sk_' . SK_CACHE_PREFIX . '_get_post_types');
670
- delete_transient('sk_' . SK_CACHE_PREFIX . '_post_statuses');
671
- }
672
-
673
- function delete_sk_get_user_data(){
674
- delete_transient('sk_' . SK_CACHE_PREFIX . '_get_user_data');
675
- }
676
-
677
- function delete_sk_get_plugins(){
678
- delete_transient('sk_' . SK_CACHE_PREFIX . '_get_plugins');
679
- }
680
-
681
- }
682
-
683
- $sidekick = new Sidekick;
684
- register_activation_hook( __FILE__, array($sidekick,'activate_plugin') );
685
-
686
- add_action('admin_init', array($sidekick,'set_disabled_wts'));
687
- add_action('admin_init', array($sidekick,'set_autostart_wt'));
688
- add_action('admin_init', array($sidekick,'set_configure_other'));
689
- add_action('admin_init', array($sidekick,'check_ver'));
690
- add_action('admin_init', array($sidekick,'redirect'));
691
- add_action('admin_init', array($sidekick,'admin_notice_ignore'));
692
- add_action('admin_menu', array($sidekick,'setup_menu'));
693
- add_action('admin_notices', array($sidekick,'admin_notice'));
694
- add_action('admin_footer', array($sidekick,'footer'));
695
- add_action('customize_controls_print_footer_scripts', array($sidekick,'footer'));
696
- add_action('admin_enqueue_scripts', array($sidekick,'enqueue_required'));
697
- add_action('customize_controls_enqueue_scripts', array($sidekick,'enqueue_required'),1000);
698
-
699
- add_action('wp_ajax_sk_upgrade', array($sidekick,'upgrade'));
700
-
701
-
702
- // Reset Transient Cache
703
-
704
- add_action('wp_update_comment_count',array($sidekick,'delete_sk_get_comments'));
705
- add_action('set_user_role',array($sidekick,'delete_sk_get_user_data'));
706
- add_action('edit_user_profile',array($sidekick,'delete_sk_get_user_data'));
707
- add_action('activated_plugin',array($sidekick,'delete_sk_get_plugins'));
708
- add_action('deactivated_plugin',array($sidekick,'delete_sk_get_plugins'));
709
-
710
- // Multisite Licensing
711
-
712
- if (is_multisite()) {
713
-
714
-
715
- // licensing.php
716
-
717
- if (!$sidekick_active && !class_exists('sidekickMassActivator')) {
718
-
719
- class sidekickMassActivator {
720
-
721
- var $sites_per_page = 25;
722
- var $offet = 0;
723
-
724
- function activate($blog_id, $user_id, $domain, $path) {
725
- mlog("FUNCTION: activate [$blog_id, $user_id, $domain, $path]");
726
-
727
- switch_to_blog($blog_id);
728
- $sk_activation_id = get_option('sk_activation_id');
729
- restore_current_blog();
730
-
731
- $checked_blogs = get_option('sk_checked_blogs');
732
-
733
- if (isset($checked_blogs['active'][$blog_id]) || $sk_activation_id) {
734
- unset($checked_blogs['unactivated'][$blog_id]);
735
- $blog = $this->get_blog_by_id($blog_id);
736
- $checked_blogs['active'][$blog_id] = $blog[0];
737
-
738
- update_option('sk_checked_blogs', $checked_blogs);
739
-
740
- $result = array(
741
- "payload" => array(
742
- "blog" => $blog[0],
743
- "message" => "Already Activated",
744
- ),
745
- );
746
-
747
- return json_encode($result);
748
- }
749
-
750
- $user = get_user_by('id', $user_id);
751
- $email = ($user) ? $user->user_email : 'unknown';
752
- $sk_subscription_id = get_option("sk_subscription_id");
753
- $sk_selected_library = get_option("sk_selected_library");
754
-
755
- if (isset($sk_selected_library) && $sk_selected_library && $sk_selected_library !== -1 && $sk_selected_library !== '-1') {
756
- $data = array('domainName' => $domain . '/' . $path, 'productId' => $sk_selected_library);
757
- } elseif (isset($sk_subscription_id) && intval($sk_subscription_id)) {
758
- $data = array('domainName' => $domain . '/' . $path, 'subscriptionId' => $sk_subscription_id);
759
- } else {
760
- update_option('sk_auto_activation_error', "No selected library or subscriptionId set");
761
-
762
-
763
- return false;
764
- }
765
-
766
- $result = $this->send_request('post', '/domains', $data);
767
-
768
- if (isset($result->success) && $result->success == true && $result->payload->domainKey) {
769
-
770
- $this->setup_super_admin_key($result->payload->domainKey);
771
-
772
- switch_to_blog($blog_id);
773
- update_option('sk_activation_id', $result->payload->domainKey);
774
- update_option('sk_email', $email);
775
- restore_current_blog();
776
-
777
- if (isset($checked_blogs['deactivated'][$blog_id])) {
778
- $checked_blogs['active'][$blog_id] = $checked_blogs['deactivated'][$blog_id];
779
- unset($checked_blogs['deactivated'][$blog_id]);
780
- } else if (isset($checked_blogs['unactivated'][$blog_id])) {
781
- $checked_blogs['active'][$blog_id] = $checked_blogs['unactivated'][$blog_id];
782
- unset($checked_blogs['unactivated'][$blog_id]);
783
- }
784
-
785
- update_option('sk_checked_blogs', $checked_blogs);
786
- update_option('sk_last_setup_blog_id', $blog_id);
787
-
788
- delete_option('sk_auto_activation_error');
789
- } else {
790
-
791
- update_option('sk_auto_activation_error', $result->message);
792
- // wp_mail( 'support@sidekick.pro', 'Failed Mass Domain Add', json_encode($result));
793
- wp_mail('bart@sidekick.pro', 'Failed Mass Domain Add', json_encode($result));
794
- }
795
-
796
- return $result;
797
-
798
- }
799
-
800
- function getAffiliateId(){
801
- if (defined('SK_AFFILIATE_ID')) {
802
- $affiliate_id = intval(SK_AFFILIATE_ID);
803
- } else if (get_option( "sk_affiliate_id")){
804
- $affiliate_id = intval(get_option( "sk_affiliate_id"));
805
- } else {
806
- $affiliate_id = '';
807
- }
808
- return $affiliate_id;
809
- }
810
-
811
- function setup_super_admin_key($domainKey) {
812
- // Use the super admin's site activation key if not set using last activation key
813
- if (!get_option('sk_activation_id')) {
814
- update_option('sk_activation_id', $domainKey);
815
- }
816
- }
817
-
818
- function activate_batch() {
819
- $checked_blogs = get_option('sk_checked_blogs');
820
- $count = 0;
821
-
822
- if (isset($checked_blogs['unactivated']) && is_array($checked_blogs['unactivated'])) {
823
- foreach ($checked_blogs['unactivated'] as $key => $blog) {
824
- if ($count == $this->sites_per_page) {
825
- break;
826
- }
827
- $this->activate($blog->blog_id, $blog->user_id, $blog->domain, $blog->path);
828
- $count++;
829
- }
830
- }
831
- //mlog('$checked_blogs',$checked_blogs);
832
-
833
- $result = array('activated_count' => $count, 'sites_per_page' => $this->sites_per_page, 'unactivated_count' => count($checked_blogs['unactivated']));
834
- die(json_encode($result));
835
- }
836
-
837
- function activate_single() {
838
- $result = $this->activate($_POST['blog_id'], $_POST['user_id'], $_POST['domain'], $_POST['path']);
839
- die(json_encode($result));
840
- }
841
-
842
- function deactivate_single() {
843
-
844
- $checked_blogs = get_option('sk_checked_blogs');
845
- $blog_id = $_POST['blog_id'];
846
-
847
- if (isset($checked_blogs['active'][$_POST['blog_id']])) {
848
- $checked_blogs['deactivated'][$blog_id] = $checked_blogs['active'][$blog_id];
849
- unset($checked_blogs['active'][$blog_id]);
850
- update_option('sk_checked_blogs', $checked_blogs);
851
- die('{"success":1}');
852
- } else {
853
- die('{"payload":{"message":"Error #13"}}');
854
- }
855
- }
856
-
857
- function send_request($type, $end_point, $data = null, $second_attempt = null) {
858
-
859
- // var_dump("FUNCTION: send_request [$type] -> $end_point");
860
-
861
- if (strpos($_SERVER['SERVER_PROTOCOL'], 'https') === false) {
862
- $protocol = 'http:';
863
- } else {
864
- $protocol = 'https:';
865
- }
866
-
867
- $url = $protocol . SK_API . $end_point;
868
- $sk_token = get_transient('sk_token');
869
-
870
- if (!$sk_token && $end_point !== '/login') {
871
- $this->login();
872
- $sk_token = get_transient('sk_token');
873
- }
874
-
875
- $headers = array('Content-Type' => 'application/json');
876
-
877
- if ($sk_token && $end_point !== '/login') {
878
- $headers['Authorization'] = $sk_token;
879
- }
880
-
881
- $args = array(
882
- 'timeout' => 45,
883
- 'redirection' => 5,
884
- 'httpversion' => '1.0',
885
- 'blocking' => true,
886
- 'headers' => $headers
887
- );
888
-
889
- if (isset($type) && $type == 'post') {
890
- $args['method'] = 'POST';
891
- $args['body'] = json_encode($data);
892
- } else if (isset($type) && $type == 'get') {
893
- $args['method'] = 'GET';
894
- $args['body'] = $data;
895
- }
896
-
897
- $result = wp_remote_post($url, $args);
898
-
899
- if ($result['response']['message'] == 'Unauthorized' && !$second_attempt) {
900
- // var_dump('Getting rid of token and trying again');
901
- delete_transient('sk_token');
902
- $this->login();
903
-
904
- return $this->send_request($type, $end_point, $data, true);
905
- }
906
-
907
- return json_decode($result['body']);
908
- }
909
-
910
- function setup_menu() {
911
- add_submenu_page('settings.php', 'Sidekick - Licensing', 'Sidekick - Licensing', 'activate_plugins', 'sidekick-licensing', array(&$this, 'admin_page'));
912
- }
913
-
914
- function login() {
915
- $email = get_option('sk_account');
916
- $password = get_option('sk_password');
917
- delete_option('sk_auto_activation_error');
918
-
919
- if (!$password || !$email) {
920
- return false;
921
- }
922
-
923
- $key = 'hash';
924
- $decrypted_password = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($password), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
925
-
926
- $result = $this->send_request('post', '/login', array('email' => $email, 'password' => $decrypted_password));
927
-
928
- if (!isset($result) || !$result->success) {
929
- delete_option('sk_token');
930
-
931
- return array('error' => $result->message);
932
- } else {
933
- set_transient('sk_token', $result->payload->token->value, 24 * HOUR_IN_SECONDS);
934
- // var_dump($result->payload->token->value);
935
- $this->load_subscriptions($result->payload->token->value);
936
-
937
- return array('success' => true);
938
- }
939
- }
940
-
941
- function load_user_data() {
942
- return $this->send_request('get', '/users/');
943
- }
944
-
945
- function load_subscriptions() {
946
-
947
- $result = $this->send_request('get', '/users/subscriptions');
948
-
949
- if (isset($result->success) && isset($result->payload)) {
950
-
951
- $sub = $result->payload[0];
952
-
953
- if (isset($sub->Plan->CreatableProductType) && $sub->Plan->CreatableProductType->name == 'Public') {
954
- $this->logout();
955
- update_option('sk_auto_activation_error', 'Public accounts are not compatible with MultiSite activations.');
956
-
957
- return false;
958
- }
959
-
960
- update_option('sk_subscription_id', $sub->id);
961
-
962
- $sub->activeDomainCount = 0;
963
-
964
- if (count($sub->Domains) > 0) {
965
- foreach ($sub->Domains as &$domain) {
966
- if (!$domain->end) {
967
- if (isset($sub->activeDomainCount)) {
968
- $sub->activeDomainCount++;
969
- } else {
970
- $sub->activeDomainCount = 1;
971
- }
972
- }
973
- }
974
- }
975
-
976
- $data['subscriptions'] = $result->payload;
977
- $data['libraries'] = $this->load_libraries();
978
-
979
- return $data;
980
- } else if (isset($result->message) && strpos($result->message, 'Invalid Token') !== false) {
981
- $this->logout();
982
- update_option('sk_auto_activation_error', 'Please authorize SIDEKICK by logging in.');
983
- }
984
-
985
- return null;
986
- }
987
-
988
- function get_blog_by_id($id) {
989
- global $wpdb;
990
-
991
- $blogs = $wpdb->get_results($wpdb->prepare("SELECT *
992
- FROM $wpdb->blogs
993
- WHERE blog_id = '%d'
994
- "
995
- , $id));
996
-
997
- return $blogs;
998
- }
999
-
1000
- function get_blogs() {
1001
- global $wpdb;
1002
-
1003
- if (false === ($blogs = get_transient('sk_blog_list'))) {
1004
- $blogs = $wpdb->get_results($wpdb->prepare("SELECT *
1005
- FROM $wpdb->blogs
1006
- WHERE spam = '%d' AND deleted = '%d'
1007
- "
1008
- , 0, 0));
1009
- set_transient('sk_blog_list', $blogs, 24 * HOUR_IN_SECONDS);
1010
- }
1011
-
1012
- return $blogs;
1013
- }
1014
-
1015
- function get_unchecked_blogs($blogs, $checked_blogs) {
1016
- $return = array();
1017
-
1018
- foreach ($blogs as $key => $blog) {
1019
-
1020
- if (isset($checked_blogs['deactivated']) && is_array($checked_blogs['deactivated']) && isset($checked_blogs['deactivated'][$blog->blog_id])) {
1021
- continue;
1022
- }
1023
-
1024
- if (isset($checked_blogs['unactivated']) && is_array($checked_blogs['unactivated']) && isset($checked_blogs['unactivated'][$blog->blog_id])) {
1025
- continue;
1026
- }
1027
-
1028
- if (isset($checked_blogs['active']) && is_array($checked_blogs['active']) && isset($checked_blogs['active'][$blog->blog_id])) {
1029
- continue;
1030
- }
1031
-
1032
- $return[$blog->blog_id] = $blog;
1033
- }
1034
-
1035
- return $return;
1036
- }
1037
-
1038
- function check_statuses() {
1039
- $checked_blogs = get_option('sk_checked_blogs');
1040
- $blogs = $this->get_blogs();
1041
- $unchecked_blogs = $this->get_unchecked_blogs($blogs, $checked_blogs);
1042
- $count = 0;
1043
-
1044
- if (!isset($checked_blogs['unactivated'])) {
1045
- $checked_blogs['unactivated'] = array();
1046
- }
1047
-
1048
- if (!isset($checked_blogs['active'])) {
1049
- $checked_blogs['active'] = array();
1050
- }
1051
-
1052
- if (!isset($checked_blogs['deactivated'])) {
1053
- $checked_blogs['deactivated'] = array();
1054
- }
1055
-
1056
- foreach ($unchecked_blogs as $blog) {
1057
-
1058
- // if ($count > $this->sites_per_page) {
1059
- // break;
1060
- // }
1061
-
1062
- $blog_id = $blog->blog_id;
1063
- $activation_id = null;
1064
- $count++;
1065
-
1066
- switch_to_blog($blog_id);
1067
- if ($user = get_user_by('email', get_option('admin_email'))) {
1068
- $blog->user_id = $user->ID;
1069
- }
1070
- $activation_id = get_site_option('sk_activation_id');
1071
- restore_current_blog();
1072
-
1073
- if ($activation_id) {
1074
- $status = 'active';
1075
- } elseif (isset($checked_blogs['deactivated']) && in_array($blog_id, $checked_blogs['deactivated'])) {
1076
- $status = 'deactivated';
1077
- } else {
1078
- $status = 'unactivated';
1079
- }
1080
-
1081
- $checked_blogs[$status][$blog_id] = $blog;
1082
-
1083
- }
1084
-
1085
- update_option('sk_checked_blogs', $checked_blogs);
1086
-
1087
- return $checked_blogs;
1088
-
1089
- }
1090
-
1091
- function load_sites_by_status() {
1092
- global $wpdb;
1093
-
1094
- $checked_blogs = $this->check_statuses();
1095
- $status = sanitize_text_field($_POST['status']);
1096
- $this->offet = sanitize_text_field($_POST['offset']);
1097
-
1098
- if (isset($checked_blogs[$status]) && is_array($checked_blogs[$status])) {
1099
-
1100
- $return['sites'] = array_slice($checked_blogs[$status], $this->offet, $this->sites_per_page);
1101
- $return['counts']['all_blogs'] = intval($wpdb->get_var($wpdb->prepare("SELECT count(blog_id) as count FROM $wpdb->blogs WHERE spam = '%d' AND deleted = '%d'", 0, 0)));
1102
- $return['counts']['active'] = count($checked_blogs['active']);
1103
- $return['counts']['deactivated'] = count($checked_blogs['deactivated']);
1104
- $return['counts']['unactivated'] = intval($return['counts']['all_blogs']) - intval($return['counts']['active']) - $return['counts']['deactivated'];
1105
-
1106
-
1107
- $currentStatusCount = intval($return['counts'][$status]);
1108
- $return['pages'] = ceil($currentStatusCount / $this->sites_per_page);
1109
-
1110
- // $return['counts'][$status] = count($checked_blogs[$status]);
1111
- } else {
1112
- // $return['counts'][$status] = 0;
1113
- $return[$status]['sites'] = array();
1114
- }
1115
-
1116
- die(json_encode($return));
1117
- }
1118
-
1119
- function logout() {
1120
- delete_option('sk_account');
1121
- delete_option('sk_password');
1122
- delete_option('sk_subscription_id');
1123
- delete_option('sk_selected_library');
1124
- }
1125
-
1126
- function load_libraries() {
1127
- $result = $this->send_request('get', '/products');
1128
- if ($result->success) {
1129
- return $result->payload->products;
1130
- }
1131
-
1132
- return null;
1133
- }
1134
-
1135
- function schedule(){
1136
- if ( ! wp_next_scheduled( array($this,'check_statuses') ) ) {
1137
- wp_schedule_event( time(), 'hourly', array($this,'check_statuses'));
1138
- wp_schedule_event( time(), 'hourly', array($this,'activate_batch'));
1139
- }
1140
-
1141
- }
1142
-
1143
- function admin_page() {
1144
- if (isset($_POST['sk_account'])) {
1145
-
1146
- delete_option('sk_auto_activation_error');
1147
-
1148
- if (isset($_POST['sk_password']) && $_POST['sk_password'] && isset($_POST['sk_account']) && $_POST['sk_account']) {
1149
- $key = 'hash';
1150
- $string = $_POST['sk_password'];
1151
-
1152
- $encrypted_password = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key))));
1153
- $decrypted_password = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($encrypted_password), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
1154
-
1155
- update_option('sk_account', $_POST['sk_account']);
1156
- update_option('sk_password', $encrypted_password);
1157
- $login_status = $this->login();
1158
- delete_option('sk_auto_activation_error');
1159
- }
1160
-
1161
- if (isset($_POST['sk_auto_activations'])) {
1162
- update_option('sk_auto_activations', true);
1163
- } else {
1164
- delete_option('sk_auto_activations');
1165
- }
1166
-
1167
- if (isset($_POST['sk_selected_library'])) {
1168
- update_option('sk_selected_library', $_POST['sk_selected_library']);
1169
- }
1170
-
1171
- }
1172
-
1173
- if (!$sk_token = get_transient('sk_token')) {
1174
- $login_status = $this->login();
1175
- }
1176
-
1177
- $sk_subs = $this->load_subscriptions();
1178
- $user_data = $this->load_user_data();
1179
- $sk_auto_activations = get_option('sk_auto_activations');
1180
- $sk_auto_activation_error = get_option('sk_auto_activation_error');
1181
- $sk_subscription_id = get_option('sk_subscription_id');
1182
- $sk_selected_library = get_option('sk_selected_library');
1183
- $sk_hide_composer_taskbar_button = get_option('sk_hide_composer_taskbar_button');
1184
- $sk_hide_config_taskbar_button = get_option('sk_hide_config_taskbar_button');
1185
- $sk_hide_composer_upgrade_button = get_option('sk_hide_composer_upgrade_button');
1186
- $is_ms_admin = true;
1187
- $affiliate_id = $this->getAffiliateId();
1188
-
1189
- ?>
1190
- ?> <!-- ms_admin_page.php -->
1191
-
1192
- <script type="text/javascript">
1193
- if (typeof ajax_url === 'undefined') {
1194
- ajax_url = '<?php echo admin_url() ?>admin-ajax.php';
1195
- }
1196
- var last_site_key = null;
1197
- var sk_ms_admin = true;
1198
-
1199
- </script>
1200
-
1201
- <div class="page-header"><h2><a id="pluginlogo_32" class="header-icon32" href="http://www.sidekick.pro" target="_blank"></a>Sidekick Licensing</h2></div>
1202
-
1203
- <h3>Welcome to the fastest and easiest way to learn WordPress</h3>
1204
-
1205
- <?php if (isset($error_message) && $error_message): ?>
1206
- <div class="error" id="sk_dashboard_message">
1207
- <p>There was a problem activating your license. The following error occured <?php echo $error_message ?></p>
1208
- </div>
1209
- <?php elseif (isset($error) && $error): ?>
1210
- <div class="error" id="sk_dashboard_message">
1211
- <p><?php echo $error ?></p>
1212
- </div>
1213
- <?php elseif (isset($sk_auto_activation_error) && $sk_auto_activation_error): ?>
1214
- <div class="error" id="sk_dashboard_message">
1215
- <p><?php echo $sk_auto_activation_error ?></p>
1216
- </div>
1217
- <?php elseif (isset($login_status['error']) && $login_status['error']): ?>
1218
- <div class="error" id="sk_dashboard_message">
1219
- <p><?php echo $login_status['error'] ?></p>
1220
- </div>
1221
- <?php elseif (isset($warn) && $warn): ?>
1222
- <div class="updated" id="sk_dashboard_message">
1223
- <p><?php echo $warn ?></p>
1224
- </div>
1225
- <?php elseif (isset($success) && $success): ?>
1226
- <div class="updated" id="sk_dashboard_message">
1227
- <p><?php echo $success ?></p>
1228
- </div>
1229
- <?php elseif (isset($login_status['success']) && $login_status['success']): ?>
1230
- <div class="updated" id="sk_dashboard_message">
1231
- <p>Successful Login!</p>
1232
- </div>
1233
- <?php endif ?>
1234
-
1235
- <div class="sidekick_admin">
1236
-
1237
- <div class="sk_box left">
1238
- <div class="wrapper_left">
1239
- <div class="sk_box license">
1240
- <div class="well">
1241
- <h3>Activate Sidekick Account</h3>
1242
- <p>Please keep this information <b>private</b>.</p>
1243
- <p>Once active every site create on this multisite installation will have Sidekick automatically activted.</p>
1244
- <p><b>Important - </b>Only WordPress basics and Enterprise plans are currently supported. <b>Custom Walkthrough</b> plans will be supported in the near future.</p>
1245
-
1246
- <form method="post">
1247
- <?php settings_fields('sk_license'); ?>
1248
- <table class="form-table">
1249
- <tbody>
1250
- <tr valign="top">
1251
- <th scope="row" valign="top">Account (E-mail)</th>
1252
- <td>
1253
- <input id='<?php echo time() ?>' class='regular-text' type='text' name='sk_account' placeholder='<?php echo get_option('sk_account') ?>'></input>
1254
- </td>
1255
- </tr>
1256
- <tr valign="top">
1257
- <th scope="row" valign="top">Password</th>
1258
- <td>
1259
- <input class='regular-text' type='password' name='sk_password' placeholder='********'></input>
1260
- </td>
1261
- </tr>
1262
-
1263
- <tr valign="top" class='walkthrough_library'>
1264
- <th scope="row" valign="top">Library to Distribute</th>
1265
- <td>
1266
- <select name='sk_selected_library'>
1267
- <?php if (isset($sk_subs['libraries']) && count($sk_subs['libraries']) > 0): ?>
1268
- <?php foreach ($sk_subs['libraries'] as $key => $library): ?>
1269
- <option <?php echo ($sk_selected_library == $library->id) ? 'SELECTED' : '' ?> value='<?php echo $library->id ?>'><?php echo $library->name ?></option>
1270
- <?php endforeach ?>
1271
- <?php endif ?>
1272
- <option <?php echo ($sk_selected_library == -1) ? 'SELECTED' : '' ?> value='-1'>WordPress Basics Only</option>
1273
- </select>
1274
- </td>
1275
- </tr>
1276
-
1277
-
1278
- <tr valign="top">
1279
- <th scope="row" valign="top">Enable Auto-Activations</th>
1280
- <td>
1281
- <input class='checkbox' type='checkbox' name='sk_auto_activations' <?php echo ($sk_auto_activations) ? 'CHECKED' : '' ?>>
1282
- </td>
1283
- </tr>
1284
-
1285
- <?php if (isset($selected_sub) && !isset($no_product)): ?>
1286
- <tr>
1287
- <th scope="row" valign="top">Active Domains</th>
1288
- <td><?php echo $selected_sub->activeDomainCount ?>/ <?php echo ($selected_sub->CurrentTier->numberOfDomains == -1) ? 'Unlimited' : $selected_sub->CurrentTier->numberOfDomains ?> (<a href='https://www.sidekick.pro/profile/#/overview' target='_blank'>Manage</a>)
1289
- </td>
1290
- </tr>
1291
- <?php endif ?>
1292
- <?php if (isset($login_status['error']) && $login_status['error']): ?>
1293
- <tr>
1294
- <th colspan='2'>
1295
- <span class='red'><?php echo $login_status['error'] ?></span>
1296
- </th>
1297
- </tr>
1298
- <?php endif ?>
1299
- <?php if (isset($sk_auto_activation_error) && $sk_auto_activation_error): ?>
1300
- <tr>
1301
- <th scope="row" valign="top">Auto Activation Error</th>
1302
- <td>
1303
- <span class='red'><?php echo $sk_auto_activation_error ?></span>
1304
- </td>
1305
- </tr>
1306
- <?php endif ?>
1307
-
1308
- <?php if (isset($login_status['success']) && $login_status['success']): ?>
1309
- <tr>
1310
- <th colspan='2'>
1311
- <span class='green'>Successful! </span>
1312
- </th>
1313
- </tr>
1314
- <?php endif ?>
1315
- <tr>
1316
- <th></th>
1317
- <td><?php submit_button('Update'); ?></td>
1318
- </tr>
1319
- </tbody>
1320
- </table>
1321
- </form>
1322
- </div>
1323
- </div>
1324
-
1325
- <!-- Sites -->
1326
-
1327
- <div class="sk_box sites">
1328
- <div class="well">
1329
- <h3>Sidekick Network Activations</h3>
1330
-
1331
- <div class='stats'>
1332
- <div class='active' onclick='load_sites_by_status("active",this)'>
1333
- <i>></i>
1334
- <h3>0</h3>
1335
- <span>Active</span>
1336
- </div>
1337
- <div class='unactivated' onclick='load_sites_by_status("unactivated",this)'>
1338
- <i>></i>
1339
- <h3>0</h3>
1340
- <span>Unactivated</span>
1341
- </div>
1342
- <div class='deactivated' onclick='load_sites_by_status("deactivated",this)'>
1343
- <i>></i>
1344
- <h3>0</h3>
1345
- <span>Deactivated</span>
1346
- </div>
1347
- </div>
1348
-
1349
- <div class="status">
1350
-
1351
- </div>
1352
-
1353
- <h2><span>Loading...</span><button class='activate_all'>Activate All<div class="spinner"></div></button></h2>
1354
-
1355
- <div class='action'>
1356
- <div class="pagination">
1357
- <button class='prev'>Prev</button>
1358
- <span>Showing <span class="start">1</span>/<span class='end'>1</span></span>
1359
- <button class='next'>Next</button>
1360
- </div>
1361
- <div class="filter">
1362
- <!-- <input type='text' placeholder='Find'> -->
1363
- </div>
1364
- </div>
1365
-
1366
- <div class="single_activation_error red"></div>
1367
-
1368
- <div class="site_list">
1369
- Loading...
1370
- </div>
1371
-
1372
- </div>
1373
- </div>
1374
-
1375
- </div>
1376
- </div>
1377
-
1378
- <script type="text/javascript">
1379
- last_site_key = '<?php echo (isset($last_key) && $last_key) ? $last_key : '' ?>';
1380
- </script>
1381
-
1382
-
1383
- <div class="sk_box left">
1384
- <div class="wrapper_left">
1385
- <div class="sk_box configure">
1386
- <div class="well">
1387
- <h3> echo (isset($is_ms_admin)) ? 'Network ' : '' ?>Configure - Auto Start</h3>
1388
-
1389
- <form method='post'>
1390
-
1391
- <p>This Walkthrough will be played once for every user that logs into the backend of WordPress.</p>
1392
- <select name='sk_autostart_walkthrough_id'>
1393
- <option value='0'>No Auto Start</option>
1394
- </select>
1395
- <input class='button button-primary' type='submit' value='Save'/>
1396
- <input type='hidden' name='is_ms_admin' value='<?php echo (isset($is_ms_admin)) ? $is_ms_admin : false ?>'/>
1397
- <input type='hidden' name='sk_setting_autostart' value='true'/>
1398
-
1399
- <?php wp_nonce_field( 'update_sk_settings' ); ?>
1400
- </form>
1401
- </div>
1402
- </div>
1403
-
1404
- <div class="sk_box configure">
1405
- <div class="well">
1406
- <h3><?php echo (isset($is_ms_admin)) ? 'Network ' : '' ?>Configure - Other</h3>
1407
-
1408
- <form method="post">
1409
- <?php settings_fields('sk_license'); ?>
1410
- <table class="form-table long_label">
1411
- <tbody>
1412
-
1413
- <tr valign="top">
1414
- <th scope="row" valign="top">Hide Composer Button in Taskbar</th>
1415
- <td>
1416
- <input class='checkbox' type='checkbox' name='sk_hide_composer_taskbar_button' <?php echo (isset($sk_hide_composer_taskbar_button) && $sk_hide_composer_taskbar_button) ? 'CHECKED' : '' ?>>
1417
- </td>
1418
- </tr>
1419
- <tr valign="top">
1420
- <th scope="row" valign="top">Hide Config Button in Taskbar</th>
1421
- <td>
1422
- <input class='checkbox' type='checkbox' name='sk_hide_config_taskbar_button' <?php echo (isset($sk_hide_config_taskbar_button) && $sk_hide_config_taskbar_button) ? 'CHECKED' : '' ?>>
1423
- </td>
1424
- </tr>
1425
- <tr valign="top">
1426
- <th scope="row" valign="top">Hide Composer Upgrade Button in Drawer</th>
1427
- <td>
1428
- <input class='checkbox' type='checkbox' name='sk_hide_composer_upgrade_button' <?php echo (isset($sk_hide_composer_upgrade_button) && $sk_hide_composer_upgrade_button) ? 'CHECKED' : '' ?>>
1429
- </td>
1430
- </tr>
1431
- <tr valign="top">
1432
- <th scope="row" valign="top"></th>
1433
- <td>
1434
- <input class='button button-primary' type='submit' value='Save'/>
1435
- </td>
1436
- </tr>
1437
-
1438
- <input type='hidden' name='is_ms_admin' value='<?php echo (isset($is_ms_admin)) ? $is_ms_admin : false ?>'/>
1439
- <input type='hidden' name='sk_setting_other' value='true'/>
1440
-
1441
- <?php wp_nonce_field( 'update_sk_settings' ); ?>
1442
-
1443
- </tbody>
1444
- </table>
1445
- </form>
1446
- </div>
1447
- </div>
1448
-
1449
- <div class="sk_box configure">
1450
- <div class="well">
1451
- <form method='post'>
1452
-
1453
- <input class='top-right button button-primary alignright' type='submit' value='Save'/>
1454
- <h3><?php echo (isset($is_ms_admin)) ? 'Network ' : '' ?>Configure - Turn Off Walkthroughs</h3>
1455
-
1456
- <p>Below you can turn off specific Walkthroughs for this website.</p>
1457
- <p>Please note, incompatible multisite walkthroughs will be disabled automatically on individual sites already. Here you're being show the raw unfiltered list of all available walkthroughs.</p>
1458
- <div class='sk_walkthrough_list wrapper_wts'>
1459
- Loading...
1460
- </div>
1461
- <input class='button button-primary' type='submit' value='Save'/>
1462
- <input type='hidden' name='sk_setting_disabled' value='true'/>
1463
- <input type='hidden' name='is_ms_admin' value='<?php echo (isset($is_ms_admin)) ? $is_ms_admin : false ?>'/>
1464
- <?php wp_nonce_field( 'update_sk_settings' ); ?>
1465
- </form>
1466
- </div>
1467
- </div>
1468
- </div>
1469
- </div>
1470
-
1471
-
1472
- </div>
1473
-
1474
- <!-- //ms_admin_page.php -->
1475
-
1476
-
1477
- <?php
1478
-
1479
- }
1480
- }
1481
- }
1482
-
1483
- // //licensing.php
1484
- $sidekickMassActivator = new sidekickMassActivator;
1485
-
1486
- add_action('network_admin_menu', array($sidekickMassActivator,'setup_menu'));
1487
- add_action('wp_ajax_sk_activate_single', array($sidekickMassActivator,'activate_single'));
1488
- add_action('wp_ajax_sk_activate_batch', array($sidekickMassActivator,'activate_batch'));
1489
- add_action('wp_ajax_sk_load_sites_by_status', array($sidekickMassActivator,'load_sites_by_status'));
1490
-
1491
- $sk_auto_activations = get_option( 'sk_auto_activations');
1492
- if ($sk_auto_activations) {
1493
- add_action('wpmu_new_blog',array($sidekickMassActivator,'activate'),10,6);
1494
- add_action('sk_hourly_event',array($sidekickMassActivator,'schedule'),10,6);
1495
- }
1496
- }
1497
- }
1498
-
1499
-
1500
- // sk_config_data.php
1501
-
1502
- if (!$sidekick_active && !class_exists('sk_config_data')) {
1503
-
1504
- class sk_config_data{
1505
-
1506
- var $cache_time = 43200; // 12 Hours
1507
-
1508
- function get_domain(){
1509
- $site_url = get_site_url();
1510
- if(substr($site_url, -1) == '/') {
1511
- $site_url = substr($site_url, 0, -1);
1512
- }
1513
- $site_url = str_replace(array("http://","https://"),array(""),$site_url);
1514
- return $site_url;
1515
- }
1516
-
1517
- // Return list of post types registered in WordPress
1518
- // Transients cleared on post type update, create, delete
1519
-
1520
- function get_post_types(){
1521
- global $wpdb;
1522
-
1523
- if ( false === ( $result = get_transient( 'sk_' . SK_CACHE_PREFIX . '_get_post_types' ) ) ) {
1524
-
1525
- $query = "SELECT post_type, count(distinct ID) as count from {$wpdb->prefix}posts group by post_type";
1526
- $counts = $wpdb->get_results($query);
1527
- $result = array();
1528
-
1529
- foreach ($counts as $key => $type) {
1530
- $type->post_type = str_replace('-', '_', $type->post_type);
1531
- $result["post_type_{$type->post_type}"] = intval($type->count);
1532
- }
1533
- set_transient( 'sk_' . SK_CACHE_PREFIX . '_get_post_types', $result, $this->cache_time );
1534
- }
1535
-
1536
- return $result;
1537
- }
1538
-
1539
- function get_file_editor_enabled(){
1540
- if (defined('GD_SYSTEM_PLUGIN_DIR')) {
1541
- // Only check this file editor setting for GoDaddy Themes
1542
- $gd_file_editor_enabled = get_site_option( 'gd_file_editor_enabled', null );
1543
- if (isset($gd_file_editor_enabled) && $gd_file_editor_enabled) {
1544
- $gd_file_editor_enabled = 'true';
1545
- } else {
1546
- $gd_file_editor_enabled = 'false';
1547
- }
1548
- }
1549
- return (isset($gd_file_editor_enabled)) ? $gd_file_editor_enabled : null;
1550
- }
1551
-
1552
- function get_themes(){
1553
- if ( false === ( $result = get_transient( 'sk_' . SK_CACHE_PREFIX . '_get_themes' ) ) ) {
1554
- $result = wp_get_themes( array( 'allowed' => true ) );
1555
- set_transient( 'sk_' . SK_CACHE_PREFIX . '_get_themes', $result, $this->cache_time );
1556
- }
1557
-
1558
- return count($result);
1559
- }
1560
-
1561
- function get_post_types_and_statuses(){
1562
- global $wpdb;
1563
-
1564
- // Can't find a good method to clear cache for newly registered post types that fires once
1565
- // if ( false === ( $result = get_transient( 'sk_' . SK_CACHE_PREFIX . '_get_post_types_and_statuses' ) ) ) {
1566
- $query = "SELECT post_type, post_status, count(distinct ID) as count from {$wpdb->prefix}posts group by post_type, post_status";
1567
- $counts = $wpdb->get_results($query);
1568
- $result = array();
1569
-
1570
- foreach ($counts as $key => $type) {
1571
- $type->post_type = str_replace('-', '_', $type->post_type);
1572
- $type->post_status = str_replace('-', '_', $type->post_status);
1573
-
1574
- $result["post_type_{$type->post_type}_{$type->post_status}"] = intval($type->count);
1575
- }
1576
- set_transient( 'sk_' . SK_CACHE_PREFIX . '_get_post_types_and_statuses', $result, $this->cache_time );
1577
- // }
1578
-
1579
- return $result;
1580
- }
1581
-
1582
- function get_taxonomies(){
1583
- global $wpdb;
1584
-
1585
- // if ( false === ( $result = get_transient( 'sk_' . SK_CACHE_PREFIX . '_get_taxonomies' ) ) ) {
1586
- $query = "SELECT count(distinct term_taxonomy_id) as count, taxonomy from {$wpdb->prefix}term_taxonomy group by taxonomy";
1587
- $counts = $wpdb->get_results($query);
1588
-
1589
- foreach ($counts as $key => $taxonomy) {
1590
- $taxonomy->taxonomy = str_replace('-', '_', $taxonomy->taxonomy);
1591
- $result["taxonomy_{$taxonomy->taxonomy}"] = intval($taxonomy->count);
1592
- }
1593
- set_transient( 'sk_' . SK_CACHE_PREFIX . '_get_taxonomies', $result, $this->cache_time );
1594
- // }
1595
-
1596
- return $result;
1597
- }
1598
-
1599
- function get_comments(){
1600
- global $wpdb;
1601
-
1602
- if ( false === ( $counts = get_transient( 'sk_' . SK_CACHE_PREFIX . '_get_comments' ) ) ) {
1603
- $query = "SELECT count(distinct comment_ID) as count from {$wpdb->prefix}comments";
1604
- $counts = $wpdb->get_var($query);
1605
- if (!$counts) $counts = 0;
1606
- set_transient( 'sk_' . SK_CACHE_PREFIX . '_get_comments', $counts, $this->cache_time );
1607
- }
1608
-
1609
- return intval($counts);
1610
- }
1611
-
1612
- function get_post_statuses(){
1613
- global $wpdb;
1614
-
1615
- if ( false === ( $result = get_transient( 'sk_' . SK_CACHE_PREFIX . '_post_statuses' ) ) ) {
1616
- $query = "SELECT post_status, count(ID) as count from {$wpdb->prefix}posts group by post_status";
1617
- $counts = $wpdb->get_results($query);
1618
- $result = array();
1619
-
1620
- foreach ($counts as $key => $type) {
1621
- $type->post_status = str_replace('-', '_', $type->post_status);
1622
- $result["post_status_{$type->post_status}"] = intval($type->count);
1623
- }
1624
- set_transient( 'sk_' . SK_CACHE_PREFIX . '_post_statuses', $result, $this->cache_time );
1625
- }
1626
-
1627
- return $result;
1628
- }
1629
-
1630
- function get_user_data(){
1631
- global $current_user;
1632
-
1633
- if ( false === ( $result = get_transient( 'sk_' . SK_CACHE_PREFIX . '_get_user_data' ) ) ) {
1634
- $data = get_userdata($current_user->ID);
1635
- $result = array("user_id" => $current_user->ID);
1636
-
1637
- foreach ($data->allcaps as $cap => $val) {
1638
- $cap = sanitize_title($cap);
1639
- $cap = str_replace('-', '_', $cap);
1640
- if (!$val) $val = 0;
1641
- $result["cap_{$cap}"] = $val;
1642
- }
1643
- set_transient( 'sk_' . SK_CACHE_PREFIX . '_get_user_data', $result, $this->cache_time );
1644
- }
1645
-
1646
- return $result;
1647
- }
1648
-
1649
- function get_framework(){
1650
- global $current_user;
1651
-
1652
- $frameworks = array('genesis');
1653
-
1654
- $result = array("theme_framework" => false);
1655
-
1656
- foreach ($frameworks as $framework) {
1657
- switch ($framework) {
1658
- case 'genesis':
1659
- if (function_exists( 'genesis' ) ) { //
1660
- if (defined('PARENT_THEME_VERSION')) {
1661
- $result["theme_framework"] = array(
1662
- "name" => $framework,
1663
- "version" => PARENT_THEME_VERSION
1664
- );
1665
- }
1666
- }
1667
- break;
1668
- }
1669
- }
1670
- return $result;
1671
- }
1672
-
1673
- function get_current_url() {
1674
- if (isset($_SERVER['REQUEST_URI'])) {
1675
- return 'http'.(empty($_SERVER['HTTPS'])?'':'s').'://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
1676
- } else if (isset($_SERVER['PATH_INFO'])) {
1677
- return $_SERVER['PATH_INFO'];
1678
- } else {
1679
- $host = $_SERVER['HTTP_HOST'];
1680
- $port = $_SERVER['SERVER_PORT'];
1681
- $request = $_SERVER['PHP_SELF'];
1682
- $query = isset($_SERVER['argv']) ? substr($_SERVER['argv'][0], strpos($_SERVER['argv'][0], ';') + 1) : '';
1683
- $toret = $protocol . '://' . $host . ($port == $protocol_port ? '' : ':' . $port) . $request . (empty($query) ? '' : '?' . $query);
1684
- return $toret;
1685
- }
1686
- }
1687
-
1688
- function get_disabled_wts(){
1689
- $wts = str_replace('"', '', get_option('sk_disabled_wts'));
1690
- $wts = json_decode($wts);
1691
- if ($wts) {
1692
- return $wts;
1693
- }
1694
- return 'false';
1695
- }
1696
-
1697
- function get_disabled_network_wts(){
1698
- if (is_multisite()) {
1699
- $wts = str_replace('"', '', get_site_option('sk_disabled_wts'));
1700
- $wts = json_decode($wts);
1701
- if ($wts) {
1702
- return $wts;
1703
- }
1704
- }
1705
- return 'false';
1706
- }
1707
-
1708
- function get_plugins(){
1709
-
1710
- if ( false === ( $result = get_transient( 'sk_' . SK_CACHE_PREFIX . '_get_plugins' ) ) ) {
1711
- $active_plugins = wp_get_active_and_valid_plugins();
1712
- $mu_plugins = get_mu_plugins();
1713
- $result = array();
1714
-
1715
- if (is_array($active_plugins)) {
1716
- foreach ($active_plugins as $plugins_key => $plugin) {
1717
- $data = get_plugin_data( $plugin, false, false );
1718
- $slug = explode('/',plugin_basename($plugin));
1719
- $slug = str_replace('.php', '', $slug[1]);
1720
- if ($data['Version']) {
1721
- $result[$slug] = $data['Version'];
1722
- } else {
1723
- $result[$slug] = '1.0.0';
1724
- }
1725
- }
1726
- }
1727
-
1728
- if (is_array($mu_plugins)) {
1729
- foreach ($mu_plugins as $plugins_key => $plugin) {
1730
- $data = get_plugin_data( WPMU_PLUGIN_DIR . '/' . $plugins_key, false, false );
1731
- $slug = explode('/',plugin_basename($plugins_key));
1732
- $slug = str_replace('.php', '', $slug[0]);
1733
- if ($data['Version']) {
1734
- $result[$slug] = $data['Version'];
1735
- } else {
1736
- $result[$slug] = '1.0.0';
1737
- }
1738
- }
1739
- }
1740
-
1741
-
1742
- if ( is_multisite() ){
1743
- $plugins = get_site_option( 'active_sitewide_plugins');
1744
- foreach ($plugins as $plugins_key => $plugin) {
1745
- $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugins_key, false, false );
1746
- $slug = explode('/',plugin_basename($plugins_key));
1747
- $slug = str_replace('.php', '', $slug[1]);
1748
- if ($data['Version']) {
1749
- $result[$slug] = $data['Version'];
1750
- } else {
1751
- $result[$slug] = '1.0.0';
1752
- }
1753
- }
1754
- }
1755
-
1756
- set_transient( 'sk_' . SK_CACHE_PREFIX . '_get_plugins', $result, $this->cache_time );
1757
- }
1758
-
1759
- return $result;
1760
- }
1761
-
1762
- function get_user_role(){
1763
- $wp_roles;
1764
-
1765
- $current_user = wp_get_current_user();
1766
-
1767
- if (is_super_admin($current_user->ID)) {
1768
- return 'administrator';
1769
- }
1770
-
1771
- if(!isset($current_user->caps) || count($current_user->caps) < 1){
1772
- // In MS in some specific pages current user is returning empty caps so this is a work around for that case.
1773
- if (current_user_can('activate_plugins')){
1774
- return 'administrator';
1775
- }
1776
- }
1777
- if (isset($wp_roles) && $wp_roles) {
1778
- foreach($wp_roles->role_names as $role => $Role) {
1779
- if (array_key_exists($role, $current_user->caps)){
1780
- $user_role = $role;
1781
- break;
1782
- }
1783
- }
1784
- return $user_role;
1785
- }
1786
- return 'n/a';
1787
- }
1788
-
1789
- }
1790
- }
1791
-
1792
- // //sk_config_data.php