Sidekick - Version 2.6.8

Version Description

  • Update to the latest WP version
Download this release

Release Info

Developer damonfp
Plugin Icon 128x128 Sidekick
Version 2.6.8
Comparing to
See all releases

Code changes from version 2.6.7 to 2.6.8

Files changed (5) hide show
  1. libs/admin_page.php +31 -4
  2. libs/licensing.php +2 -7
  3. libs/sk_api.php +16 -6
  4. readme.txt +18 -15
  5. sidekick.php +281 -204
libs/admin_page.php CHANGED
@@ -33,6 +33,36 @@
33
 
34
  <div class="sk_box left">
35
  <div class="wrapper_left">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  <div class="sk_box license">
37
  <div class="well">
38
  <?php if (!$error): ?>
@@ -81,7 +111,7 @@
81
  </tbody>
82
  </table>
83
  <?php submit_button('Update'); ?>
84
- <?php wp_nonce_field( 'update_sk_settings' ); ?>
85
  </form>
86
  <?php endif ?>
87
  </div>
@@ -135,6 +165,3 @@
135
  </div>
136
  </div>
137
  </div>
138
-
139
-
140
-
33
 
34
  <div class="sk_box left">
35
  <div class="wrapper_left">
36
+
37
+ <?php if (defined('SK_PRODUCT_ID') || defined('SK_SUBSCRIPTION_ID')): ?>
38
+ <div class="sk_box envato">
39
+ <div class="well">
40
+
41
+ <h3>Envato Activation</h3>
42
+ <form method="post">
43
+ <p>
44
+ Hey! You've received SIDEKICK as a part of your ThemeForest purchase! To activate SIDEKICK please enter your item purchase code below (this can be found under "Downloads" in your ThemeForest account).
45
+ </p>
46
+ <table class='form-table'>
47
+ <tbody>
48
+ <tr>
49
+ <th>
50
+ Item Purchase Code
51
+ </th>
52
+ <td>
53
+ <input type="text" name="sk_envato_item_purchase_code" class='regular-text' value="<?php echo get_option('sk_envato_item_purchase_code') ?>">
54
+ </td>
55
+ </tr>
56
+ </tbody>
57
+ </table>
58
+ <?php submit_button('Activate'); ?>
59
+ <?php wp_nonce_field( 'activate_envato', 'activate_envato_once' ); ?>
60
+ </form>
61
+ </div>
62
+ </div>
63
+ <?php endif; ?>
64
+
65
+
66
  <div class="sk_box license">
67
  <div class="well">
68
  <?php if (!$error): ?>
111
  </tbody>
112
  </table>
113
  <?php submit_button('Update'); ?>
114
+ <?php wp_nonce_field( 'update_sk_settings', 'update_sk_settings_once' ); ?>
115
  </form>
116
  <?php endif ?>
117
  </div>
165
  </div>
166
  </div>
167
  </div>
 
 
 
libs/licensing.php CHANGED
@@ -11,11 +11,6 @@ if (!class_exists('sidekickMassActivator')) {
11
  var $sites_per_page = 50;
12
  var $offet = 0;
13
 
14
- function log($msg){
15
- error_log($msg);
16
- // file_put_contents('Licensing.log', "$msg\n", FILE_APPEND);
17
- }
18
-
19
  function activate($blog_id, $user_id, $domain, $path) {
20
  // mlog("FUNCTION: activate [$blog_id, $user_id, $domain, $path]");
21
 
@@ -95,7 +90,7 @@ if (!class_exists('sidekickMassActivator')) {
95
  } else {
96
  update_option('sk_auto_activation_error', $result->message);
97
  wp_mail('bart@sidekick.pro', 'Failed Domain Deactivation', json_encode($result));
98
- }
99
 
100
  return $result;
101
  }
@@ -248,4 +243,4 @@ if (!class_exists('sidekickMassActivator')) {
248
  }
249
  }
250
 
251
- // //licensing.php
11
  var $sites_per_page = 50;
12
  var $offet = 0;
13
 
 
 
 
 
 
14
  function activate($blog_id, $user_id, $domain, $path) {
15
  // mlog("FUNCTION: activate [$blog_id, $user_id, $domain, $path]");
16
 
90
  } else {
91
  update_option('sk_auto_activation_error', $result->message);
92
  wp_mail('bart@sidekick.pro', 'Failed Domain Deactivation', json_encode($result));
93
+ }
94
 
95
  return $result;
96
  }
243
  }
244
  }
245
 
246
+ // //licensing.php
libs/sk_api.php CHANGED
@@ -1,6 +1,12 @@
1
- <?php
2
 
3
  class sk_api{
 
 
 
 
 
 
4
  function login_request($data){
5
  $this->log("SEND_LOGIN_REQUEST");
6
 
@@ -21,10 +27,13 @@ class sk_api{
21
 
22
  $result = wp_remote_post(SK_API . '/login' , $args);
23
 
 
 
24
  if ( is_wp_error( $result ) ) {
25
  $error_message = $result->get_error_message();
26
  $this->log("login: error -> $error_message");
27
  } else {
 
28
  return json_decode($result['body']);
29
  }
30
 
@@ -47,6 +56,7 @@ class sk_api{
47
 
48
  $url = SK_API . $end_point;
49
 
 
50
  $args = array(
51
  'timeout' => 15,
52
  'redirection' => 5,
@@ -71,12 +81,12 @@ class sk_api{
71
  $url .= '?' . http_build_query($data);
72
  }
73
 
74
-
75
- $response = wp_remote_post($url, $args);
76
- // mlog('$response',$response);
77
  $this->log("send_request: $url");
78
  $this->log("send_request: RESPONSE");
79
- $this->log("send_request: {$response['response']['message']}");
 
 
 
80
 
81
  if ($response['response']['message'] == 'Unauthorized' && !$second_attempt) {
82
  // var_dump('Getting rid of token and trying again');
@@ -192,4 +202,4 @@ class sk_api{
192
  }
193
 
194
 
195
- }
1
+ <?php
2
 
3
  class sk_api{
4
+
5
+ function log($msg){
6
+ error_log($msg);
7
+ // file_put_contents('Licensing.log', "$msg\n", FILE_APPEND);
8
+ }
9
+
10
  function login_request($data){
11
  $this->log("SEND_LOGIN_REQUEST");
12
 
27
 
28
  $result = wp_remote_post(SK_API . '/login' , $args);
29
 
30
+ // $this->log($result);
31
+
32
  if ( is_wp_error( $result ) ) {
33
  $error_message = $result->get_error_message();
34
  $this->log("login: error -> $error_message");
35
  } else {
36
+ $this->log("Success!");
37
  return json_decode($result['body']);
38
  }
39
 
56
 
57
  $url = SK_API . $end_point;
58
 
59
+
60
  $args = array(
61
  'timeout' => 15,
62
  'redirection' => 5,
81
  $url .= '?' . http_build_query($data);
82
  }
83
 
 
 
 
84
  $this->log("send_request: $url");
85
  $this->log("send_request: RESPONSE");
86
+ $response = wp_remote_post($url, $args);
87
+ // mlog('$response',$response);
88
+
89
+ $this->log("send_request: {$response['response']['message']}");
90
 
91
  if ($response['response']['message'] == 'Unauthorized' && !$second_attempt) {
92
  // var_dump('Getting rid of token and trying again');
202
  }
203
 
204
 
205
+ }
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Sidekick ===
2
- Contributors: raptor235,benfox,bitwit,riavalon
3
  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: 4.1
6
- Tested up to: 4.3.1
7
- Stable tag: 2.6.7
8
  License: GNU Version 2 or Any Later Version
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -18,7 +18,7 @@ Sidekick puts interactive, real-time tutorials (**Walkthroughs**) right inside y
18
 
19
  No more reading documentation or watching videos. **Just Click. Do. Learn.**
20
 
21
- SIDEKICK for WordPress comes with access to 100+ Walkthroughs at no cost. (Including Genesis, WooCommerce, Yoast and more).
22
 
23
  Create your own Walkthroughs and access our entire WordPress Basics library by upgrading for just $5/month. Here’s a complete list of what’s in our [library](http://support.sidekick.pro/article/167-which-walkthroughs-are-included-with-wordpress-basics?utm_source=wordpress.org&utm_medium=plugin_page_description).
24
 
@@ -149,19 +149,22 @@ We read and respond to every piece of feedback we get.
149
 
150
  == Changelog ==
151
 
152
- = 2.6.7 =
 
 
 
153
  * Fixes caching issue of user capabilities
154
 
155
- = 2.6.6 =
156
  * Fixes notice error in multisite management page
157
 
158
  = 2.6.5 =
159
  * Performance improvements to multisite activation screens (Thank You Michael @mgyura)
160
 
161
- = 2.6.4 =
162
  * Added ability to reset activation keys for a full multisite network
163
 
164
- = 2.6.3 =
165
  * Fixes auto start walkthrough selected option box
166
 
167
  = 2.6.2 =
@@ -170,15 +173,15 @@ We read and respond to every piece of feedback we get.
170
  = 2.6.1 =
171
  * Fixes to multsite network activation bug for invalid logins
172
 
173
- = 2.6.0 =
174
- * WordPress 4.3 compatibility
175
  * Upgrade directly from SIDEKICK
176
 
177
  = 2.5.5 =
178
  * Fixes an issue with activation
179
 
180
  = 2.5.5 =
181
- * Clean up of tracking routines
182
  * Additional security around preference saving (Thank You Joost - @yoast)
183
  * Fixes to global CSS rules (Thank You Joost - @yoast)
184
  * Network admin screen has clearler titling for options
@@ -192,12 +195,12 @@ We read and respond to every piece of feedback we get.
192
  * Optimize the multisite admin loading screen
193
  * Fixes just activated setting
194
 
195
- = 2.5.2 =
196
  * Adjust disabled walkthroughs settings
197
  * Filter out non compatible products from settings screen
198
  * Add domain to walkthrough compatibility filter
199
 
200
- = 2.5.0 =
201
  * Sidekick platform major refactoring
202
  * Fixes issues with toggles for taskbar buttons not working
203
 
@@ -207,7 +210,7 @@ We read and respond to every piece of feedback we get.
207
 
208
  = 2.4.0 =
209
  * WordPress Customizer support
210
- * Platform fixes
211
  * Caption display optimizations
212
  * Walkthroughs started in modal windows or customizer will first
213
 
@@ -394,4 +397,4 @@ We read and respond to every piece of feedback we get.
394
  * Fixed Activation Bug
395
 
396
  = 0.70 =
397
- * Initial Beta Release
1
  === Sidekick ===
2
+ Contributors: raptor235,benfox
3
  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: 4.1
6
+ Tested up to: 4.8.2
7
+ Stable tag: 2.6.8
8
  License: GNU Version 2 or Any Later Version
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
18
 
19
  No more reading documentation or watching videos. **Just Click. Do. Learn.**
20
 
21
+ SIDEKICK for WordPress comes with access to 100+ Walkthroughs at no cost. (Including Genesis, WooCommerce, Yoast and more).
22
 
23
  Create your own Walkthroughs and access our entire WordPress Basics library by upgrading for just $5/month. Here’s a complete list of what’s in our [library](http://support.sidekick.pro/article/167-which-walkthroughs-are-included-with-wordpress-basics?utm_source=wordpress.org&utm_medium=plugin_page_description).
24
 
149
 
150
  == Changelog ==
151
 
152
+ = 2.6.8 =
153
+ * Update to the latest WP version
154
+
155
+ = 2.6.7 =
156
  * Fixes caching issue of user capabilities
157
 
158
+ = 2.6.6 =
159
  * Fixes notice error in multisite management page
160
 
161
  = 2.6.5 =
162
  * Performance improvements to multisite activation screens (Thank You Michael @mgyura)
163
 
164
+ = 2.6.4 =
165
  * Added ability to reset activation keys for a full multisite network
166
 
167
+ = 2.6.3 =
168
  * Fixes auto start walkthrough selected option box
169
 
170
  = 2.6.2 =
173
  = 2.6.1 =
174
  * Fixes to multsite network activation bug for invalid logins
175
 
176
+ = 2.6.0 =
177
+ * WordPress 4.3 compatibility
178
  * Upgrade directly from SIDEKICK
179
 
180
  = 2.5.5 =
181
  * Fixes an issue with activation
182
 
183
  = 2.5.5 =
184
+ * Clean up of tracking routines
185
  * Additional security around preference saving (Thank You Joost - @yoast)
186
  * Fixes to global CSS rules (Thank You Joost - @yoast)
187
  * Network admin screen has clearler titling for options
195
  * Optimize the multisite admin loading screen
196
  * Fixes just activated setting
197
 
198
+ = 2.5.2 =
199
  * Adjust disabled walkthroughs settings
200
  * Filter out non compatible products from settings screen
201
  * Add domain to walkthrough compatibility filter
202
 
203
+ = 2.5.0 =
204
  * Sidekick platform major refactoring
205
  * Fixes issues with toggles for taskbar buttons not working
206
 
210
 
211
  = 2.4.0 =
212
  * WordPress Customizer support
213
+ * Platform fixes
214
  * Caption display optimizations
215
  * Walkthroughs started in modal windows or customizer will first
216
 
397
  * Fixed Activation Bug
398
 
399
  = 0.70 =
400
+ * Initial Beta Release
sidekick.php CHANGED
@@ -4,63 +4,74 @@
4
  Plugin Name: Sidekick
5
  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.1
8
- Tested up to: 4.3.1
9
- Version: 2.6.7
10
  Author: Sidekick.pro
11
  Author URI: http://www.sidekick.pro
12
  */
13
 
14
-
15
- if ( ! defined( 'SK_EMBEDDED_PARTNER' ) ) define( 'SK_EMBEDDED_PARTNER', '' );
16
-
17
- if ( ! function_exists('mlog')) {
18
- function mlog(){}
19
  }
20
 
21
- if (!class_exists('Sidekick')){
22
-
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.7'));
 
 
 
 
 
 
 
 
28
  }
29
 
30
- function enqueue_required(){
31
- wp_enqueue_script('jquery' , null );
32
- wp_enqueue_script('underscore' , null, array('underscore'));
33
- wp_enqueue_script('backbone' , null, array('jquery','underscore'));
 
34
  wp_enqueue_script('heartbeat');
35
- wp_enqueue_script('jquery-ui-core' , null, array('jquery') );
36
- wp_enqueue_script('jquery-ui-position' , null, array('jquery-ui-core') );
37
- wp_enqueue_script('jquery-ui-draggable' , null, array('jquery-ui-core') );
38
- wp_enqueue_script('jquery-ui-droppable' , null, array('jquery-ui-core') );
39
- wp_enqueue_script('jquery-effects-scale' , null, array('jquery-ui-core') );
40
- wp_enqueue_script('jquery-effects-highlight' , null, array('jquery-ui-core') );
41
- wp_enqueue_script('sidekick-admin' , '//assets.sidekick.pro/plugin/tag/latest/js/sidekick_admin.js',array( 'jquery' ), null);
42
- wp_enqueue_script('sidekick' ,"//loader.sidekick.pro/platforms/d9993157-d972-4c49-93be-a0c684096961.js", array('backbone','jquery','underscore','jquery-effects-highlight'),null,true);
43
  wp_enqueue_style('wp-pointer');
44
  wp_enqueue_script('wp-pointer');
45
 
46
  do_action('post_enqueue_required');
47
-
48
  }
49
 
50
- function setup_menu(){
51
- add_submenu_page( 'options-general.php', 'Sidekick', 'Sidekick', 'activate_plugins','sidekick', array(&$this,'admin_page'));
 
52
  }
53
 
54
- function activate($return = false){
 
55
  // mlog("activate");
56
  if (isset($_POST['activation_id']) && current_user_can('install_plugins')) {
57
  // mlog("activate2");
58
- update_option('sk_activation_id',$_POST['activation_id']);
 
59
  return true;
60
  }
61
  }
62
 
63
- function upgrade(){
 
64
  // mlog("upgrade");
65
 
66
  if (!isset($_POST['authorization']) || !wp_verify_nonce($_POST['authorization'], 'sk_upgrade')) {
@@ -70,59 +81,125 @@ if (!class_exists('Sidekick')){
70
  return $this->activate();
71
  }
72
 
73
- function admin_page(){
 
 
 
 
 
 
 
 
 
 
74
 
75
- if ( empty( $_POST ) || check_admin_referer( 'update_sk_settings' ) ) {
 
 
76
 
77
  if (isset($_POST['option_page']) && $_POST['option_page'] == 'sk_license') {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
- if (isset($_POST['activation_id']) && $_POST['activation_id'] && strpos($_POST['activation_id'], '-xxxx-xxxx') === false){
 
 
 
 
 
 
 
 
 
 
 
80
  $result = $this->activate(true);
81
- } else if (isset($_POST['activation_id']) && strpos($_POST['activation_id'], '-xxxx-xxxx') === false) {
82
  delete_option('sk_activation_id');
83
  }
84
 
85
  if (isset($_POST['sk_track_data'])) {
86
- update_option( 'sk_track_data', true );
87
  } else {
88
  delete_option('sk_track_data');
89
  }
90
 
91
- update_option( 'sk_activated', true );
92
- die('<script>window.open("' . get_site_url() . '/wp-admin/options-general.php?page=sidekick","_self")</script>');
93
  }
 
94
 
95
  }
96
 
97
- $activation_id = (get_option( "sk_activation_id" ) ? get_option( "sk_activation_id" ) : '');
98
- $sk_track_data = get_option( 'sk_track_data' );
99
-
100
  $sk_hide_composer_taskbar_button = get_option('sk_hide_composer_taskbar_button');
101
- $sk_hide_config_taskbar_button = get_option('sk_hide_config_taskbar_button');
102
  $sk_hide_composer_upgrade_button = get_option('sk_hide_composer_upgrade_button');
103
-
104
- $current_user = wp_get_current_user();
105
- $status = 'Free';
106
- $error = null;
107
- $affiliate_id = $this->getAffiliateId();
108
 
109
  if (isset($SK_PAID_LIBRARY_FILE) && $activation_id) {
110
  $_POST['activation_id'] = $activation_id;
111
- $check_activation = $this->activate(true);
112
  $status = 'Checking...';
113
  }
114
 
115
  global $wp_version;
116
  if (version_compare($wp_version, '3.9', '<=')) {
117
- $error = "Sorry, Sidekick requires WordPress 3.9 or higher to function.";
118
  }
119
 
120
  if (!$activation_id) {
121
  $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.";
122
  }
123
 
124
- if(preg_match('/(?i)msie [6-8]/',$_SERVER['HTTP_USER_AGENT'])){
125
- $error = "Sorry, Sidekick requires Internet Explorer 9 or higher to function.";
126
  }
127
 
128
  ?>
@@ -140,21 +217,21 @@ if (!class_exists('Sidekick')){
140
  <?php include('libs/admin_page.php') ?>
141
  </div>
142
  <?php
143
- }
144
 
145
- function set_disabled_wts(){
146
-
147
- if (isset($_POST['sk_setting_disabled'])){
148
 
 
 
 
149
  if (!check_admin_referer('update_sk_settings')) {
150
- print 'Sorry, your nonce did not verify or you\'re not logged in.';
151
  exit;
152
  }
153
 
154
  if (isset($_POST['disable_wts']) && $_POST['disable_wts']) {
155
- update_option('sk_disabled_wts',json_encode($_POST['disable_wts']));
156
  if (isset($_POST['is_ms_admin']) && $_POST['is_ms_admin']) {
157
- update_site_option('sk_disabled_wts',json_encode($_POST['disable_wts']));
158
  }
159
  } else {
160
  delete_option('sk_disabled_wts');
@@ -163,23 +240,21 @@ if (!class_exists('Sidekick')){
163
  }
164
  }
165
  }
166
-
167
  }
168
 
169
- function set_autostart_wt(){
170
-
171
- if (isset($_POST['sk_setting_autostart'])){
172
-
173
  if (!check_admin_referer('update_sk_settings')) {
174
- print 'Sorry, your nonce did not verify or you\'re not logged in.';
175
  exit;
176
  }
177
 
178
- if (isset($_POST['sk_autostart_walkthrough_id']) && intval($_POST['sk_autostart_walkthrough_id']) > 0){
179
  if (isset($_POST['is_ms_admin']) && $_POST['is_ms_admin']) {
180
- update_site_option('sk_autostart_walkthrough_id',wp_filter_kses($_POST['sk_autostart_walkthrough_id']));
181
  }
182
- update_option('sk_autostart_walkthrough_id',wp_filter_kses($_POST['sk_autostart_walkthrough_id']));
183
  } else {
184
  delete_option('sk_autostart_walkthrough_id');
185
  if (isset($_POST['is_ms_admin']) && $_POST['is_ms_admin']) {
@@ -187,26 +262,24 @@ if (!class_exists('Sidekick')){
187
  }
188
  }
189
  }
190
-
191
  }
192
 
193
- function set_configure_other(){
194
-
195
- if (isset($_POST['sk_setting_other'])){
196
-
197
  if (!check_admin_referer('update_sk_settings')) {
198
- print 'Sorry, your nonce did not verify or you\'re not logged in.';
199
  exit;
200
  }
201
 
202
- $checkboxes = array('sk_hide_composer_taskbar_button','sk_hide_config_taskbar_button','sk_hide_composer_upgrade_button');
203
 
204
  foreach ($checkboxes as $key => $checkbox) {
205
- if (isset($_POST[$checkbox])){
206
  if (isset($_POST['is_ms_admin']) && $_POST['is_ms_admin']) {
207
- update_site_option($checkbox,wp_filter_kses($_POST[$checkbox]));
208
  }
209
- update_option($checkbox,wp_filter_kses($_POST[$checkbox]));
210
  } else {
211
  delete_option($checkbox);
212
  if (isset($_POST['is_ms_admin']) && $_POST['is_ms_admin']) {
@@ -214,145 +287,149 @@ if (!class_exists('Sidekick')){
214
  }
215
  }
216
  }
217
-
218
  }
219
-
220
  }
221
 
222
- function getAffiliateId(){
 
223
  if (defined('SK_AFFILIATE_ID')) {
224
  $affiliate_id = intval(SK_AFFILIATE_ID);
225
- } else if (get_option( "sk_affiliate_id")){
226
- $affiliate_id = intval(get_option( "sk_affiliate_id"));
227
  } else {
228
  $affiliate_id = '';
229
  }
 
230
  return $affiliate_id;
231
  }
232
 
233
- function footer(){
 
234
  global $current_user;
235
 
236
- require_once('libs/sk_config_data.php');
237
 
238
- $sk_config_data = new sk_config_data;
239
- $current_user = (get_option( 'sk_track_data' )) ? wp_get_current_user() : null;
240
- $autostart_network_walkthrough_id = (get_site_option('sk_autostart_walkthrough_id') ? get_site_option('sk_autostart_walkthrough_id') : null );
241
- $autostart_walkthrough_id = (get_option('sk_autostart_walkthrough_id') ? get_option('sk_autostart_walkthrough_id') : $autostart_network_walkthrough_id );
242
- $theme = wp_get_theme();
243
- $installed_plugins = $sk_config_data->get_plugins();
244
- $file_editor_enabled = $sk_config_data->get_file_editor_enabled();
245
- $affiliate_id = $this->getAffiliateId();
246
 
247
  $sk_hide_composer_taskbar_button = false;
248
 
249
- if (get_option( 'sk_hide_composer_taskbar_button' ) || get_site_option( 'sk_hide_composer_taskbar_button' )) {
250
  $sk_hide_composer_taskbar_button = true;
251
  }
252
 
253
  $sk_hide_config_taskbar_button = false;
254
 
255
- if (get_option( 'sk_hide_config_taskbar_button' ) || get_site_option( 'sk_hide_config_taskbar_button' )) {
256
  $sk_hide_config_taskbar_button = true;
257
  }
258
 
259
  $sk_config = array(
260
- "compatibilities" => array(
261
- "comment_count" => $sk_config_data->get_comments(),
262
- "domain" => str_replace("http://","",$_SERVER["SERVER_NAME"]),
263
- "installed_plugins" => (isset($installed_plugins)) ? $installed_plugins : array(),
264
- "installed_theme" => sanitize_title($theme->Name),
265
- "is_multisite" => (is_multisite()) ? true : false,
266
- "main_soft_version" => get_bloginfo("version"),
267
- "number_of_themes" => $sk_config_data->get_themes(),
268
- "page_for_posts" => intval(get_option('page_for_posts')),
269
- "page_on_front" => intval(get_option('page_on_front')),
270
- "plugin_count" => (isset($installed_plugins) && is_array($installed_plugins)) ? count($installed_plugins) : 0,
271
- "role" => $sk_config_data->get_user_role(),
272
- "show_on_front" => get_option('show_on_front'),
273
- "theme_version" => $theme->Version
274
  ),
275
 
276
  // Platform
277
- "baseClientUrl" => site_url(),
278
- "base_url" => site_url(),
279
 
280
  // User Settings
281
- "activation_id" => (get_option( "sk_activation_id" ) ? get_option( "sk_activation_id" ) : ''),
282
- "custom_class" => (get_option( "sk_custom_class" ) ? get_option( "sk_custom_class" ) : ''),
283
- "affiliate_id" => $affiliate_id,
284
- "user_email" => ($current_user) ? $current_user->user_email : '',
285
- "autostart_walkthrough_id" => ($autostart_walkthrough_id) ? $autostart_walkthrough_id : '',
286
- "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
287
- "disable_network_wts" => $sk_config_data->get_disabled_network_wts(), // Copying these to compatibilities, have to update this over time
288
 
289
  // Toggles
290
- "hide_taskbar_composer_button" => $sk_hide_composer_taskbar_button, // hide composer button on the taskbar
291
- "hide_taskbar_config_button" => $sk_hide_config_taskbar_button, // hide settings button on taskbar
292
- "show_login" => (get_option( 'sk_just_activated' )) ? true : false, // open drawer automatically, same as just_activated
293
 
294
  // WordPress
295
- "embed_partner_id" => SK_EMBEDDED_PARTNER, // for tracking purposes if sidekick has been embeded in another WordPress plugin or theme
296
- "plugin_version" => '2.6.7', // WordPress plugin version
297
- "site_url" => $sk_config_data->get_domain(),
298
- "domain" => str_replace("http://","",$_SERVER["SERVER_NAME"]),
299
- "plugin_url" => admin_url("admin.php?page=sidekick"),
300
 
301
  );
302
 
303
  if ($file_editor_enabled) { //
304
- $sk_config["compatibilities"]["file_editor_enabled"] = $file_editor_enabled;
305
  }
306
 
307
- $sk_config['compatibilities'] = array_merge($sk_config['compatibilities'],$sk_config_data->get_post_types());
308
- $sk_config['compatibilities'] = array_merge($sk_config['compatibilities'],$sk_config_data->get_taxonomies());
309
- $sk_config['compatibilities'] = array_merge($sk_config['compatibilities'],$sk_config_data->get_user_data());
310
- $sk_config['compatibilities'] = array_merge($sk_config['compatibilities'],$sk_config_data->get_post_statuses());
311
- $sk_config['compatibilities'] = array_merge($sk_config['compatibilities'],$sk_config_data->get_post_types_and_statuses());
312
- $sk_config['compatibilities'] = array_merge($sk_config['compatibilities'],$sk_config_data->get_framework());
313
- $sk_config = apply_filters('sk_config',$sk_config);
314
 
315
- delete_option( 'sk_just_activated' );
316
 
317
  ?>
318
 
319
  <!-- Old IE Not Supported -->
320
- <?php if (!preg_match('/(?i)msie [6-8]/',$_SERVER['HTTP_USER_AGENT'])): ?>
321
 
322
  <script type="text/preloaded" data-provider="sidekick">
323
  <?php echo json_encode($sk_config) ?>
324
  </script>
325
 
326
  <script type="text/javascript">
327
- var sk_nonce_upgrade = '<?php echo wp_create_nonce('sk_upgrade'); ?>'
 
328
  </script>
329
 
330
  <?php endif ?>
331
 
332
  <?php
 
333
  }
334
 
335
- function activate_plugin(){
336
- update_option( 'sk_firstuse', true );
337
- update_option( 'sk_do_activation_redirect', true );
 
338
  }
339
 
340
- function redirect(){
 
341
  if (get_option('sk_do_activation_redirect', false)) {
342
  delete_option('sk_do_activation_redirect');
343
  $siteurl = get_site_url();
344
- wp_redirect($siteurl . "/wp-admin/options-general.php?page=sidekick");
345
  die();
346
  }
347
  }
348
 
349
- function check_ver(){
350
-
351
- if (isset($_GET['sk_ver_check'])){
352
- $data = json_encode('2.6.7');
353
-
354
- if(array_key_exists('callback', $_GET)){
355
 
 
356
  header('Content-Type: text/javascript; charset=utf8');
357
  header('Access-Control-Allow-Origin: http://www.example.com/');
358
  header('Access-Control-Max-Age: 3628800');
@@ -360,8 +437,7 @@ if (!class_exists('Sidekick')){
360
 
361
  $callback = $_GET['callback'];
362
  echo $callback.'('.$data.');';
363
-
364
- }else{
365
  header('Content-Type: application/json; charset=utf8');
366
 
367
  echo $data;
@@ -369,104 +445,105 @@ if (!class_exists('Sidekick')){
369
 
370
  die();
371
  }
372
-
373
  }
374
 
375
- function admin_notice() {
376
- global $current_user ;
377
- if ( ! get_user_meta($current_user->ID, 'sk_ignore_notice') ) {
378
- printf ('<div class="updated sidekick_welcome">
 
379
  <p>
380
  <b>Need help with WordPress?</b> - You can always find help in the bottom left corner, just click the Help button.</b>
381
  </p>
382
  <p>
383
  <button class="sk_start_intro sk_wp_primary button button-primary">
384
- What\'s Sidekick?
385
- </button>
386
  <a href="%1$s" class="button-secondary button skip">No Thanks</a>
387
  </p>
388
  </div>',
389
- wp_nonce_url('?sk_ignore_notice=1','hide_msg', 'sk_nonce'));
390
  }
391
  }
392
 
393
- function admin_notice_ignore() {
 
394
  global $current_user;
395
 
396
  if (!isset($_GET['sk_nonce']) || !wp_verify_nonce($_GET['sk_nonce'], 'hide_msg')) {
397
  return false;
398
  }
399
 
400
- if ( isset($_GET['sk_ignore_notice'])) {
401
  add_user_meta($current_user->ID, 'sk_ignore_notice', true);
402
  }
403
  }
404
 
405
  // Clear transients for cached sk_config_data
406
 
407
- function delete_sk_get_comments(){
408
- delete_transient('sk_' . SK_CACHE_PREFIX . '_get_comments');
 
409
  }
410
 
411
- function delete_sk_get_post_types(){
412
- delete_transient('sk_' . SK_CACHE_PREFIX . '_get_post_types');
413
- delete_transient('sk_' . SK_CACHE_PREFIX . '_post_statuses');
 
414
  }
415
 
416
- function delete_sk_get_user_data(){
417
- delete_transient('sk_' . SK_CACHE_PREFIX . '_get_user_data');
 
418
  }
419
 
420
- function delete_sk_get_plugins(){
421
- delete_transient('sk_' . SK_CACHE_PREFIX . '_get_plugins');
 
422
  }
423
-
424
  }
425
 
426
- $sidekick = new Sidekick;
427
- register_activation_hook( __FILE__, array($sidekick,'activate_plugin') );
428
-
429
- add_action('admin_init', array($sidekick,'set_disabled_wts'));
430
- add_action('admin_init', array($sidekick,'set_autostart_wt'));
431
- add_action('admin_init', array($sidekick,'set_configure_other'));
432
- add_action('admin_init', array($sidekick,'check_ver'));
433
- add_action('admin_init', array($sidekick,'redirect'));
434
- add_action('admin_init', array($sidekick,'admin_notice_ignore'));
435
- add_action('admin_menu', array($sidekick,'setup_menu'));
436
- add_action('admin_notices', array($sidekick,'admin_notice'));
437
- add_action('admin_footer', array($sidekick,'footer'));
438
- add_action('customize_controls_print_footer_scripts', array($sidekick,'footer'));
439
- add_action('admin_enqueue_scripts', array($sidekick,'enqueue_required'));
440
- add_action('customize_controls_enqueue_scripts', array($sidekick,'enqueue_required'),1000);
441
-
442
- add_action('wp_ajax_sk_upgrade', array($sidekick,'upgrade'));
443
-
444
 
445
  // Reset Transient Cache
446
 
447
- add_action('wp_update_comment_count',array($sidekick,'delete_sk_get_comments'));
448
- add_action('set_user_role',array($sidekick,'delete_sk_get_user_data'));
449
- add_action('edit_user_profile',array($sidekick,'delete_sk_get_user_data'));
450
- add_action('activated_plugin',array($sidekick,'delete_sk_get_plugins'));
451
- add_action('deactivated_plugin',array($sidekick,'delete_sk_get_plugins'));
452
 
453
  // Multisite Licensing
454
 
455
  if (is_multisite()) {
 
 
456
 
457
- require_once('libs/licensing.php');
458
- $sidekickMassActivator = new sidekickMassActivator;
459
-
460
- add_action('network_admin_menu', array($sidekickMassActivator,'setup_menu'));
461
- add_action('wp_ajax_sk_activate_single', array($sidekickMassActivator,'activate_single'));
462
- add_action('wp_ajax_sk_deactivate_single', array($sidekickMassActivator,'deactivate_single'));
463
- add_action('wp_ajax_sk_activate_batch', array($sidekickMassActivator,'activate_batch'));
464
- add_action('wp_ajax_sk_check_batch_status', array($sidekickMassActivator,'check_batch_status'));
465
 
466
- $sk_auto_activations = get_option( 'sk_auto_activations');
467
  if ($sk_auto_activations) {
468
- add_action('wpmu_new_blog',array($sidekickMassActivator,'activate'),10,6);
469
  }
470
  }
471
  }
472
-
4
  Plugin Name: Sidekick
5
  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.4
8
+ Tested up to: 4.6.1
9
+ Version: 2.6.8
10
  Author: Sidekick.pro
11
  Author URI: http://www.sidekick.pro
12
  */
13
 
14
+ if (!defined('SK_EMBEDDED_PARTNER')) {
15
+ define('SK_EMBEDDED_PARTNER', '');
 
 
 
16
  }
17
 
18
+ if (!function_exists('mlog')) {
19
+ function mlog()
20
+ {
21
+ }
22
+ }
23
 
24
+ if (!class_exists('Sidekick')) {
25
+ class Sidekick
26
+ {
27
+ public function __construct()
28
+ {
29
+ if (!defined('SK_API')) {
30
+ define('SK_API', 'https: //apiv2.sidekick.pro');
31
+ }
32
+ if (!defined('SK_CACHE_PREFIX')) {
33
+ define('SK_CACHE_PREFIX', str_replace('.', '_', '2.6.8'));
34
+ }
35
  }
36
 
37
+ public function enqueue_required()
38
+ {
39
+ wp_enqueue_script('jquery', null);
40
+ wp_enqueue_script('underscore', null, array('underscore'));
41
+ wp_enqueue_script('backbone', null, array('jquery', 'underscore'));
42
  wp_enqueue_script('heartbeat');
43
+ wp_enqueue_script('jquery-ui-core', null, array('jquery'));
44
+ wp_enqueue_script('jquery-ui-position', null, array('jquery-ui-core'));
45
+ wp_enqueue_script('jquery-ui-draggable', null, array('jquery-ui-core'));
46
+ wp_enqueue_script('jquery-ui-droppable', null, array('jquery-ui-core'));
47
+ wp_enqueue_script('jquery-effects-scale', null, array('jquery-ui-core'));
48
+ wp_enqueue_script('jquery-effects-highlight', null, array('jquery-ui-core'));
49
+ wp_enqueue_script('sidekick-admin', '//assets.sidekick.pro/plugin/tag/latest/js/sidekick_admin.js', array('jquery'), null);
50
+ wp_enqueue_script('sidekick', '//loader.sidekick.pro/platforms/d9993157-d972-4c49-93be-a0c684096961.js', array('backbone', 'jquery', 'underscore', 'jquery-effects-highlight'), null, true);
51
  wp_enqueue_style('wp-pointer');
52
  wp_enqueue_script('wp-pointer');
53
 
54
  do_action('post_enqueue_required');
 
55
  }
56
 
57
+ public function setup_menu()
58
+ {
59
+ add_submenu_page('options-general.php', 'Sidekick', 'Sidekick', 'activate_plugins', 'sidekick', array(&$this, 'admin_page'));
60
  }
61
 
62
+ public function activate($return = false)
63
+ {
64
  // mlog("activate");
65
  if (isset($_POST['activation_id']) && current_user_can('install_plugins')) {
66
  // mlog("activate2");
67
+ update_option('sk_activation_id', $_POST['activation_id']);
68
+
69
  return true;
70
  }
71
  }
72
 
73
+ public function upgrade()
74
+ {
75
  // mlog("upgrade");
76
 
77
  if (!isset($_POST['authorization']) || !wp_verify_nonce($_POST['authorization'], 'sk_upgrade')) {
81
  return $this->activate();
82
  }
83
 
84
+ public function activate_envato()
85
+ {
86
+ // confirm item purchase id is good /w envato
87
+ // login with author sidekick account and get key
88
+ // save key
89
+
90
+ die('activated');
91
+ }
92
+
93
+ public function admin_page()
94
+ {
95
 
96
+ $error = null;
97
+
98
+ if (empty($_POST)) {
99
 
100
  if (isset($_POST['option_page']) && $_POST['option_page'] == 'sk_license') {
101
+ if (isset($_POST['activation_id']) && $_POST['activation_id'] && strpos($_POST['activation_id'], '-xxxx-xxxx') === false) {
102
+ $result = $this->activate(true);
103
+ } elseif (isset($_POST['activation_id']) && strpos($_POST['activation_id'], '-xxxx-xxxx') === false) {
104
+ delete_option('sk_activation_id');
105
+ }
106
+
107
+ if (isset($_POST['sk_track_data'])) {
108
+ update_option('sk_track_data', true);
109
+ } else {
110
+ delete_option('sk_track_data');
111
+ }
112
+
113
+ update_option('sk_activated', true);
114
+ die('<script>window.open("'.get_site_url().'/wp-admin/options-general.php?page=sidekick","_self")</script>');
115
+ }
116
+ } else {
117
+
118
+ if (isset($_POST['activate_envato_once']) && check_admin_referer('activate_envato', 'activate_envato_once')) {
119
+
120
+ $key = 'hash';
121
+ $decrypted_account = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode(SK_ENVATO_PARTNER), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
122
+ $decrypted_password = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode(SK_ENVATO_SECRET), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
123
+ $encrypted_password = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $decrypted_password, MCRYPT_MODE_CBC, md5(md5($key))));
124
+
125
+ update_option('sk_envato_item_purchase_code', $_POST['sk_envato_item_purchase_code']);
126
+ update_option('sk_account', $decrypted_account);
127
+ update_option('sk_password', $encrypted_password);
128
+
129
+ // activate
130
+ require_once('libs/sk_api.php');
131
+ $sk_api = new sk_api;
132
+
133
+ $sk_api->login();
134
+
135
+ if (defined('SK_SUBSCRIPTION_ID')) {
136
+ $data = array('domainName' => get_site_url(), 'subscriptionId' => SK_SUBSCRIPTION_ID);
137
+ } elseif (defined('SK_PRODUCT_ID')){
138
+ $data = array('domainName' => get_site_url(), 'productId' => SK_PRODUCT_ID);
139
+ } else {
140
+ // Problem there is no sub or product id;
141
+ $error = 'Missing subscriptionId or productId constant';
142
+ }
143
 
144
+ $result = $sk_api->send_request('post', '/domains', $data);
145
+ if (isset($result->success) && $result->success == true && $result->payload->domainKey) {
146
+ // $this->log("activate: success");
147
+ update_option('sk_activation_id', $result->payload->domainKey);
148
+ } else {
149
+ // $this->log("activate: error");
150
+ }
151
+ }
152
+
153
+ if (isset($_POST['update_sk_settings_once']) && check_admin_referer('update_sk_settings', 'update_sk_settings_once')) {
154
+ if (isset($_POST['option_page']) && $_POST['option_page'] == 'sk_license') {
155
+ if (isset($_POST['activation_id']) && $_POST['activation_id'] && strpos($_POST['activation_id'], '-xxxx-xxxx') === false) {
156
  $result = $this->activate(true);
157
+ } elseif (isset($_POST['activation_id']) && strpos($_POST['activation_id'], '-xxxx-xxxx') === false) {
158
  delete_option('sk_activation_id');
159
  }
160
 
161
  if (isset($_POST['sk_track_data'])) {
162
+ update_option('sk_track_data', true);
163
  } else {
164
  delete_option('sk_track_data');
165
  }
166
 
167
+ update_option('sk_activated', true);
168
+ die('<script>window.open("'.get_site_url().'/wp-admin/options-general.php?page=sidekick","_self")</script>');
169
  }
170
+ }
171
 
172
  }
173
 
174
+ $activation_id = (get_option('sk_activation_id') ? get_option('sk_activation_id') : '');
175
+ $sk_track_data = get_option('sk_track_data');
176
+
177
  $sk_hide_composer_taskbar_button = get_option('sk_hide_composer_taskbar_button');
178
+ $sk_hide_config_taskbar_button = get_option('sk_hide_config_taskbar_button');
179
  $sk_hide_composer_upgrade_button = get_option('sk_hide_composer_upgrade_button');
180
+
181
+ $current_user = wp_get_current_user();
182
+ $status = 'Free';
183
+
184
+ $affiliate_id = $this->getAffiliateId();
185
 
186
  if (isset($SK_PAID_LIBRARY_FILE) && $activation_id) {
187
  $_POST['activation_id'] = $activation_id;
188
+ $check_activation = $this->activate(true);
189
  $status = 'Checking...';
190
  }
191
 
192
  global $wp_version;
193
  if (version_compare($wp_version, '3.9', '<=')) {
194
+ $error = 'Sorry, Sidekick requires WordPress 3.9 or higher to function.';
195
  }
196
 
197
  if (!$activation_id) {
198
  $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.";
199
  }
200
 
201
+ if (preg_match('/(?i)msie [6-8]/', $_SERVER['HTTP_USER_AGENT'])) {
202
+ $error = 'Sorry, Sidekick requires Internet Explorer 9 or higher to function.';
203
  }
204
 
205
  ?>
217
  <?php include('libs/admin_page.php') ?>
218
  </div>
219
  <?php
 
220
 
221
+ }
 
 
222
 
223
+ public function set_disabled_wts()
224
+ {
225
+ if (isset($_POST['sk_setting_disabled'])) {
226
  if (!check_admin_referer('update_sk_settings')) {
227
+ echo 'Sorry, your nonce did not verify or you\'re not logged in.';
228
  exit;
229
  }
230
 
231
  if (isset($_POST['disable_wts']) && $_POST['disable_wts']) {
232
+ update_option('sk_disabled_wts', json_encode($_POST['disable_wts']));
233
  if (isset($_POST['is_ms_admin']) && $_POST['is_ms_admin']) {
234
+ update_site_option('sk_disabled_wts', json_encode($_POST['disable_wts']));
235
  }
236
  } else {
237
  delete_option('sk_disabled_wts');
240
  }
241
  }
242
  }
 
243
  }
244
 
245
+ public function set_autostart_wt()
246
+ {
247
+ if (isset($_POST['sk_setting_autostart'])) {
 
248
  if (!check_admin_referer('update_sk_settings')) {
249
+ echo 'Sorry, your nonce did not verify or you\'re not logged in.';
250
  exit;
251
  }
252
 
253
+ if (isset($_POST['sk_autostart_walkthrough_id']) && intval($_POST['sk_autostart_walkthrough_id']) > 0) {
254
  if (isset($_POST['is_ms_admin']) && $_POST['is_ms_admin']) {
255
+ update_site_option('sk_autostart_walkthrough_id', wp_filter_kses($_POST['sk_autostart_walkthrough_id']));
256
  }
257
+ update_option('sk_autostart_walkthrough_id', wp_filter_kses($_POST['sk_autostart_walkthrough_id']));
258
  } else {
259
  delete_option('sk_autostart_walkthrough_id');
260
  if (isset($_POST['is_ms_admin']) && $_POST['is_ms_admin']) {
262
  }
263
  }
264
  }
 
265
  }
266
 
267
+ public function set_configure_other()
268
+ {
269
+ if (isset($_POST['sk_setting_other'])) {
 
270
  if (!check_admin_referer('update_sk_settings')) {
271
+ echo 'Sorry, your nonce did not verify or you\'re not logged in.';
272
  exit;
273
  }
274
 
275
+ $checkboxes = array('sk_hide_composer_taskbar_button', 'sk_hide_config_taskbar_button', 'sk_hide_composer_upgrade_button');
276
 
277
  foreach ($checkboxes as $key => $checkbox) {
278
+ if (isset($_POST[$checkbox])) {
279
  if (isset($_POST['is_ms_admin']) && $_POST['is_ms_admin']) {
280
+ update_site_option($checkbox, wp_filter_kses($_POST[$checkbox]));
281
  }
282
+ update_option($checkbox, wp_filter_kses($_POST[$checkbox]));
283
  } else {
284
  delete_option($checkbox);
285
  if (isset($_POST['is_ms_admin']) && $_POST['is_ms_admin']) {
287
  }
288
  }
289
  }
 
290
  }
 
291
  }
292
 
293
+ public function getAffiliateId()
294
+ {
295
  if (defined('SK_AFFILIATE_ID')) {
296
  $affiliate_id = intval(SK_AFFILIATE_ID);
297
+ } elseif (get_option('sk_affiliate_id')) {
298
+ $affiliate_id = intval(get_option('sk_affiliate_id'));
299
  } else {
300
  $affiliate_id = '';
301
  }
302
+
303
  return $affiliate_id;
304
  }
305
 
306
+ public function footer()
307
+ {
308
  global $current_user;
309
 
310
+ require_once 'libs/sk_config_data.php';
311
 
312
+ $sk_config_data = new sk_config_data();
313
+ $current_user = (get_option('sk_track_data')) ? wp_get_current_user() : null;
314
+ $autostart_network_walkthrough_id = (get_site_option('sk_autostart_walkthrough_id') ? get_site_option('sk_autostart_walkthrough_id') : null);
315
+ $autostart_walkthrough_id = (get_option('sk_autostart_walkthrough_id') ? get_option('sk_autostart_walkthrough_id') : $autostart_network_walkthrough_id);
316
+ $theme = wp_get_theme();
317
+ $installed_plugins = $sk_config_data->get_plugins();
318
+ $file_editor_enabled = $sk_config_data->get_file_editor_enabled();
319
+ $affiliate_id = $this->getAffiliateId();
320
 
321
  $sk_hide_composer_taskbar_button = false;
322
 
323
+ if (get_option('sk_hide_composer_taskbar_button') || get_site_option('sk_hide_composer_taskbar_button')) {
324
  $sk_hide_composer_taskbar_button = true;
325
  }
326
 
327
  $sk_hide_config_taskbar_button = false;
328
 
329
+ if (get_option('sk_hide_config_taskbar_button') || get_site_option('sk_hide_config_taskbar_button')) {
330
  $sk_hide_config_taskbar_button = true;
331
  }
332
 
333
  $sk_config = array(
334
+ 'compatibilities' => array(
335
+ 'comment_count' => $sk_config_data->get_comments(),
336
+ 'domain' => str_replace('http://', '', $_SERVER['SERVER_NAME']),
337
+ 'installed_plugins' => (isset($installed_plugins)) ? $installed_plugins : array(),
338
+ 'installed_theme' => sanitize_title($theme->Name),
339
+ 'is_multisite' => (is_multisite()) ? true : false,
340
+ 'main_soft_version' => get_bloginfo('version'),
341
+ 'number_of_themes' => $sk_config_data->get_themes(),
342
+ 'page_for_posts' => intval(get_option('page_for_posts')),
343
+ 'page_on_front' => intval(get_option('page_on_front')),
344
+ 'plugin_count' => (isset($installed_plugins) && is_array($installed_plugins)) ? count($installed_plugins) : 0,
345
+ 'role' => $sk_config_data->get_user_role(),
346
+ 'show_on_front' => get_option('show_on_front'),
347
+ 'theme_version' => $theme->Version,
348
  ),
349
 
350
  // Platform
351
+ 'baseClientUrl' => site_url(),
352
+ 'base_url' => site_url(),
353
 
354
  // User Settings
355
+ 'activation_id' => (get_option('sk_activation_id') ? get_option('sk_activation_id') : ''),
356
+ 'custom_class' => (get_option('sk_custom_class') ? get_option('sk_custom_class') : ''),
357
+ 'affiliate_id' => $affiliate_id,
358
+ 'user_email' => ($current_user) ? $current_user->user_email : '',
359
+ 'autostart_walkthrough_id' => ($autostart_walkthrough_id) ? $autostart_walkthrough_id : '',
360
+ '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
361
+ 'disable_network_wts' => $sk_config_data->get_disabled_network_wts(), // Copying these to compatibilities, have to update this over time
362
 
363
  // Toggles
364
+ 'hide_taskbar_composer_button' => $sk_hide_composer_taskbar_button, // hide composer button on the taskbar
365
+ 'hide_taskbar_config_button' => $sk_hide_config_taskbar_button, // hide settings button on taskbar
366
+ 'show_login' => (get_option('sk_just_activated')) ? true : false, // open drawer automatically, same as just_activated
367
 
368
  // WordPress
369
+ 'embed_partner_id' => SK_EMBEDDED_PARTNER, // for tracking purposes if sidekick has been embeded in another WordPress plugin or theme
370
+ 'plugin_version' => '2.6.8', // WordPress plugin version
371
+ 'site_url' => $sk_config_data->get_domain(),
372
+ 'domain' => str_replace('http://', '', $_SERVER['SERVER_NAME']),
373
+ 'plugin_url' => admin_url('admin.php?page=sidekick'),
374
 
375
  );
376
 
377
  if ($file_editor_enabled) { //
378
+ $sk_config['compatibilities']['file_editor_enabled'] = $file_editor_enabled;
379
  }
380
 
381
+ $sk_config['compatibilities'] = array_merge($sk_config['compatibilities'], $sk_config_data->get_post_types());
382
+ $sk_config['compatibilities'] = array_merge($sk_config['compatibilities'], $sk_config_data->get_taxonomies());
383
+ $sk_config['compatibilities'] = array_merge($sk_config['compatibilities'], $sk_config_data->get_user_data());
384
+ $sk_config['compatibilities'] = array_merge($sk_config['compatibilities'], $sk_config_data->get_post_statuses());
385
+ $sk_config['compatibilities'] = array_merge($sk_config['compatibilities'], $sk_config_data->get_post_types_and_statuses());
386
+ $sk_config['compatibilities'] = array_merge($sk_config['compatibilities'], $sk_config_data->get_framework());
387
+ $sk_config = apply_filters('sk_config', $sk_config);
388
 
389
+ delete_option('sk_just_activated');
390
 
391
  ?>
392
 
393
  <!-- Old IE Not Supported -->
394
+ <?php if (!preg_match('/(?i)msie [6-8]/', $_SERVER['HTTP_USER_AGENT'])): ?>
395
 
396
  <script type="text/preloaded" data-provider="sidekick">
397
  <?php echo json_encode($sk_config) ?>
398
  </script>
399
 
400
  <script type="text/javascript">
401
+ var sk_nonce_upgrade = '<?php echo wp_create_nonce('sk_upgrade');
402
+ ?>'
403
  </script>
404
 
405
  <?php endif ?>
406
 
407
  <?php
408
+
409
  }
410
 
411
+ public function activate_plugin()
412
+ {
413
+ update_option('sk_firstuse', true);
414
+ update_option('sk_do_activation_redirect', true);
415
  }
416
 
417
+ public function redirect()
418
+ {
419
  if (get_option('sk_do_activation_redirect', false)) {
420
  delete_option('sk_do_activation_redirect');
421
  $siteurl = get_site_url();
422
+ wp_redirect($siteurl.'/wp-admin/options-general.php?page=sidekick');
423
  die();
424
  }
425
  }
426
 
427
+ public function check_ver()
428
+ {
429
+ if (isset($_GET['sk_ver_check'])) {
430
+ $data = json_encode('2.6.8');
 
 
431
 
432
+ if (array_key_exists('callback', $_GET)) {
433
  header('Content-Type: text/javascript; charset=utf8');
434
  header('Access-Control-Allow-Origin: http://www.example.com/');
435
  header('Access-Control-Max-Age: 3628800');
437
 
438
  $callback = $_GET['callback'];
439
  echo $callback.'('.$data.');';
440
+ } else {
 
441
  header('Content-Type: application/json; charset=utf8');
442
 
443
  echo $data;
445
 
446
  die();
447
  }
 
448
  }
449
 
450
+ public function admin_notice()
451
+ {
452
+ global $current_user;
453
+ if (!get_user_meta($current_user->ID, 'sk_ignore_notice')) {
454
+ printf('<div class="updated sidekick_welcome">
455
  <p>
456
  <b>Need help with WordPress?</b> - You can always find help in the bottom left corner, just click the Help button.</b>
457
  </p>
458
  <p>
459
  <button class="sk_start_intro sk_wp_primary button button-primary">
460
+ What\'s Sidekick?
461
+ </button>
462
  <a href="%1$s" class="button-secondary button skip">No Thanks</a>
463
  </p>
464
  </div>',
465
+ wp_nonce_url('?sk_ignore_notice=1', 'hide_msg', 'sk_nonce'));
466
  }
467
  }
468
 
469
+ public function admin_notice_ignore()
470
+ {
471
  global $current_user;
472
 
473
  if (!isset($_GET['sk_nonce']) || !wp_verify_nonce($_GET['sk_nonce'], 'hide_msg')) {
474
  return false;
475
  }
476
 
477
+ if (isset($_GET['sk_ignore_notice'])) {
478
  add_user_meta($current_user->ID, 'sk_ignore_notice', true);
479
  }
480
  }
481
 
482
  // Clear transients for cached sk_config_data
483
 
484
+ public function delete_sk_get_comments()
485
+ {
486
+ delete_transient('sk_'.SK_CACHE_PREFIX.'_get_comments');
487
  }
488
 
489
+ public function delete_sk_get_post_types()
490
+ {
491
+ delete_transient('sk_'.SK_CACHE_PREFIX.'_get_post_types');
492
+ delete_transient('sk_'.SK_CACHE_PREFIX.'_post_statuses');
493
  }
494
 
495
+ public function delete_sk_get_user_data()
496
+ {
497
+ delete_transient('sk_'.SK_CACHE_PREFIX.'_get_user_data');
498
  }
499
 
500
+ public function delete_sk_get_plugins()
501
+ {
502
+ delete_transient('sk_'.SK_CACHE_PREFIX.'_get_plugins');
503
  }
 
504
  }
505
 
506
+ $sidekick = new Sidekick();
507
+ register_activation_hook(__FILE__, array($sidekick, 'activate_plugin'));
508
+
509
+ add_action('admin_init', array($sidekick, 'set_disabled_wts'));
510
+ add_action('admin_init', array($sidekick, 'set_autostart_wt'));
511
+ add_action('admin_init', array($sidekick, 'set_configure_other'));
512
+ add_action('admin_init', array($sidekick, 'check_ver'));
513
+ add_action('admin_init', array($sidekick, 'redirect'));
514
+ add_action('admin_init', array($sidekick, 'admin_notice_ignore'));
515
+ add_action('admin_menu', array($sidekick, 'setup_menu'));
516
+ add_action('admin_notices', array($sidekick, 'admin_notice'));
517
+ add_action('admin_footer', array($sidekick, 'footer'));
518
+ add_action('customize_controls_print_footer_scripts', array($sidekick, 'footer'));
519
+ add_action('admin_enqueue_scripts', array($sidekick, 'enqueue_required'));
520
+ add_action('customize_controls_enqueue_scripts', array($sidekick, 'enqueue_required'), 1000);
521
+
522
+ add_action('wp_ajax_sk_upgrade', array($sidekick, 'upgrade'));
 
523
 
524
  // Reset Transient Cache
525
 
526
+ add_action('wp_update_comment_count', array($sidekick, 'delete_sk_get_comments'));
527
+ add_action('set_user_role', array($sidekick, 'delete_sk_get_user_data'));
528
+ add_action('edit_user_profile', array($sidekick, 'delete_sk_get_user_data'));
529
+ add_action('activated_plugin', array($sidekick, 'delete_sk_get_plugins'));
530
+ add_action('deactivated_plugin', array($sidekick, 'delete_sk_get_plugins'));
531
 
532
  // Multisite Licensing
533
 
534
  if (is_multisite()) {
535
+ require_once 'libs/licensing.php';
536
+ $sidekickMassActivator = new sidekickMassActivator();
537
 
538
+ add_action('network_admin_menu', array($sidekickMassActivator, 'setup_menu'));
539
+ add_action('wp_ajax_sk_activate_single', array($sidekickMassActivator, 'activate_single'));
540
+ add_action('wp_ajax_sk_deactivate_single', array($sidekickMassActivator, 'deactivate_single'));
541
+ add_action('wp_ajax_sk_activate_batch', array($sidekickMassActivator, 'activate_batch'));
542
+ add_action('wp_ajax_sk_check_batch_status', array($sidekickMassActivator, 'check_batch_status'));
 
 
 
543
 
544
+ $sk_auto_activations = get_option('sk_auto_activations');
545
  if ($sk_auto_activations) {
546
+ add_action('wpmu_new_blog', array($sidekickMassActivator, 'activate'), 10, 6);
547
  }
548
  }
549
  }