Issues (865)

Security Analysis    4 potential vulnerabilities

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection (1)
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection (2)
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting (1)
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

ayecode-connect-helper/ayecode-connect-helper.php (6 issues)

1
<?php
2
if ( ! defined( 'ABSPATH' ) ) {
3
	exit;
4
}
5
6
if ( ! class_exists( "AyeCode_Connect_Helper" ) ) {
7
	/**
8
	 * Allow the quick setup and connection of our AyeCode Connect plugin.
9
	 *
10
	 * Class AyeCode_Connect_Helper
11
	 */
12
	class AyeCode_Connect_Helper {
13
14
		// Hold the version number
15
		var $version = "1.0.4";
16
17
		// Hold the default strings.
18
		var $strings = array();
19
20
		// Hold the default pages.
21
		var $pages = array();
22
23
		/**
24
		 * The constructor.
25
		 *
26
		 * AyeCode_Connect_Helper constructor.
27
		 *
28
		 * @param array $strings
29
		 * @param array $pages
30
		 */
31
		public function __construct( $strings = array(), $pages = array() ) {
32
			// Only fire if not localhost and the current user has the right permissions.
33
			if ( ! $this->is_localhost() && current_user_can( 'manage_options' ) ) {
34
				// set default strings
35
				$default_strings = array(
36
					'connect_title'     => __( "Thanks for choosing an AyeCode Product!", 'ayecode-connect' ),
37
					'connect_external'  => __( "Please confirm you wish to connect your site?", 'ayecode-connect' ),
38
					'connect'           => wp_sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", 'ayecode-connect' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>" ),
39
					'connect_button'    => __( "Connect Site", 'ayecode-connect' ),
40
					'connecting_button' => __( "Connecting...", 'ayecode-connect' ),
41
					'error_localhost'   => __( "This service will only work with a live domain, not a localhost.", 'ayecode-connect' ),
42
					'error'             => __( "Something went wrong, please refresh and try again.", 'ayecode-connect' ),
43
				);
44
				$this->strings   = array_merge( $default_strings, $strings );
45
46
				// set default pages
47
				$default_pages = array();
48
				$this->pages   = array_merge( $default_pages, $pages );
49
50
				// maybe show connect site notice
51
				add_action( 'admin_notices', array( $this, 'ayecode_connect_install_notice' ) );
52
53
				// add ajax action if not already added
54
				if ( ! has_action( 'wp_ajax_ayecode_connect_helper' ) ) {
55
					add_action( 'wp_ajax_ayecode_connect_helper', array( $this, 'ayecode_connect_install' ) );
56
				}
57
			}
58
59
			// add ajax action if not already added
60
			if ( ! has_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed' ) ) {
61
				add_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed', array( $this, 'ayecode_connect_helper_installed' ) );
62
			}
63
		}
64
65
		/**
66
		 * Give a way to check we can connect via a external redirect.
67
		 */
68
		public function ayecode_connect_helper_installed(){
69
			$active = array(
70
				'gd'    =>  defined('GEODIRECTORY_VERSION') && version_compare(GEODIRECTORY_VERSION,'2.0.0.79','>') ? 1 : 0,
0 ignored issues
show
The constant GEODIRECTORY_VERSION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
71
				'uwp'    =>  defined('USERSWP_VERSION') && version_compare(USERSWP_VERSION,'1.2.1.5','>') ? 1 : 0,
0 ignored issues
show
The constant USERSWP_VERSION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
72
				'wpi'    =>  defined('WPINV_VERSION') && version_compare(WPINV_VERSION,'1.0.14','>') ? 1 : 0,
73
			);
74
			wp_send_json_success( $active );
75
			wp_die();
76
		}
77
78
		/**
79
		 * Get slug from path
80
		 *
81
		 * @param  string $key
82
		 *
83
		 * @return string
84
		 */
85
		private function format_plugin_slug( $key ) {
86
			$slug = explode( '/', $key );
87
			$slug = explode( '.', end( $slug ) );
88
89
			return $slug[0];
90
		}
91
92
		/**
93
		 * Install and activate the AyeCode Connect Plugin
94
		 */
95
		public function ayecode_connect_install() {
96
			// bail if localhost
97
			if ( $this->is_localhost() ) {
98
				wp_send_json_error( $this->strings['error_localhost'] );
99
			}
100
101
			// Explicitly clear the event.
102
			wp_clear_scheduled_hook( 'geodir_plugin_background_installer', func_get_args() );
103
104
			$success     = true;
105
			$plugin_slug = "ayecode-connect";
106
			if ( ! empty( $plugin_slug ) ) {
0 ignored issues
show
The condition empty($plugin_slug) is always false.
Loading history...
107
				require_once( ABSPATH . 'wp-admin/includes/file.php' );
108
				require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
109
				require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
110
				require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
111
112
				WP_Filesystem();
113
114
				$skin              = new Automatic_Upgrader_Skin;
115
				$upgrader          = new WP_Upgrader( $skin );
116
				$installed_plugins = array_map( array( $this, 'format_plugin_slug' ), array_keys( get_plugins() ) );
117
				$plugin_slug       = $plugin_slug;
118
				$plugin            = $plugin_slug . '/' . $plugin_slug . '.php';
119
				$installed         = false;
120
				$activate          = false;
121
122
				// See if the plugin is installed already
123
				if ( in_array( $plugin_slug, $installed_plugins ) ) {
124
					$installed = true;
125
					$activate  = ! is_plugin_active( $plugin );
126
				}
127
128
				// Install this thing!
129
				if ( ! $installed ) {
130
131
					// Suppress feedback
132
					ob_start();
133
134
					try {
135
						$plugin_information = plugins_api( 'plugin_information', array(
136
							'slug'   => $plugin_slug,
137
							'fields' => array(
138
								'short_description' => false,
139
								'sections'          => false,
140
								'requires'          => false,
141
								'rating'            => false,
142
								'ratings'           => false,
143
								'downloaded'        => false,
144
								'last_updated'      => false,
145
								'added'             => false,
146
								'tags'              => false,
147
								'homepage'          => false,
148
								'donate_link'       => false,
149
								'author_profile'    => false,
150
								'author'            => false,
151
							),
152
						) );
153
154
						if ( is_wp_error( $plugin_information ) ) {
155
							throw new Exception( $plugin_information->get_error_message() );
156
						}
157
158
						$package  = $plugin_information->download_link;
0 ignored issues
show
The property download_link does not seem to exist on WP_Error.
Loading history...
159
						$download = $upgrader->download_package( $package );
160
161
						if ( is_wp_error( $download ) ) {
162
							throw new Exception( $download->get_error_message() );
163
						}
164
165
						$working_dir = $upgrader->unpack_package( $download, true );
0 ignored issues
show
It seems like $download can also be of type WP_Error; however, parameter $package of WP_Upgrader::unpack_package() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

165
						$working_dir = $upgrader->unpack_package( /** @scrutinizer ignore-type */ $download, true );
Loading history...
166
167
						if ( is_wp_error( $working_dir ) ) {
168
							throw new Exception( $working_dir->get_error_message() );
169
						}
170
171
						$result = $upgrader->install_package( array(
172
							'source'                      => $working_dir,
173
							'destination'                 => WP_PLUGIN_DIR,
174
							'clear_destination'           => false,
175
							'abort_if_destination_exists' => false,
176
							'clear_working'               => true,
177
							'hook_extra'                  => array(
178
								'type'   => 'plugin',
179
								'action' => 'install',
180
							),
181
						) );
182
183
						if ( is_wp_error( $result ) ) {
184
							throw new Exception( $result->get_error_message() );
185
						}
186
187
						$activate = true;
188
189
					} catch ( Exception $e ) {
190
						$success = false;
191
					}
192
193
					// Discard feedback
194
					ob_end_clean();
195
				}
196
197
				wp_clean_plugins_cache();
198
199
				// Activate this thing
200
				if ( $activate ) {
201
					try {
202
						$result = activate_plugin( $plugin );
203
204
						if ( is_wp_error( $result ) ) {
205
							$success = false;
206
						} else {
207
							$success = true;
208
						}
209
					} catch ( Exception $e ) {
210
						$success = false;
211
					}
212
				}
213
			}
214
215
			if ( $success && function_exists( 'ayecode_connect_args' ) ) {
216
				ayecode_connect();// init
0 ignored issues
show
The function ayecode_connect was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

216
				/** @scrutinizer ignore-call */ 
217
    ayecode_connect();// init
Loading history...
217
				$args        = ayecode_connect_args();
218
				$client      = new AyeCode_Connect( $args );
219
				$redirect_to = ! empty( $_POST['redirect_to'] ) ? esc_url_raw( $_POST['redirect_to'] ) : '';
220
				$redirect    = $client->build_connect_url( $redirect_to );
221
				wp_send_json_success( array( 'connect_url' => $redirect ) );
222
			} else {
223
				wp_send_json_error( $this->strings['error_localhost'] );
224
			}
225
			wp_die();
226
		}
227
228
		/**
229
		 * Check if maybe localhost.
230
		 *
231
		 * @return bool
232
		 */
233
		public function is_localhost() {
234
			$localhost = false;
235
236
			$host              = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '';
237
			$localhost_domains = array(
238
				'localhost',
239
				'localhost.localdomain',
240
				'127.0.0.1',
241
				'::1'
242
			);
243
244
			if ( in_array( $host, $localhost_domains ) ) {
245
				$localhost = true;
246
			}
247
248
			return $localhost;
249
		}
250
251
		/**
252
		 * Show notice to connect site.
253
		 */
254
		public function ayecode_connect_install_notice() {
255
			if ( $this->maybe_show() ) {
256
				$connect_title_string     = $this->strings['connect_title'];
257
				$connect_external_string  = $this->strings['connect_external'];
258
				$connect_string           = $this->strings['connect'];
259
				$connect_button_string    = $this->strings['connect_button'];
260
				$connecting_button_string = $this->strings['connecting_button'];
261
				?>
262
				<div class="notice notice-info acch-notice">
263
					<span class="acch-float-left">
264
						<svg width="61px" height="61px" viewBox="0 0 61 61" version="1.1"
265
						     xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
266
						<defs>
267
							<polygon id="path-1"
268
							         points="4.70437018e-05 0.148846272 60.8504481 0.148846272 60.8504481 61 4.70437018e-05 61"></polygon>
269
						</defs>
270
						<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
271
							<g id="Group-6" transform="translate(-8.000000, -4.000000)">
272
								<g id="Group-5" transform="translate(8.000000, 4.000000)">
273
									<g id="Group-17">
274
										<mask id="mask-2" fill="white">
275
											<use xlink:href="#path-1"></use>
276
										</mask>
277
										<g id="Clip-16"></g>
278
										<path
279
											d="M60.8504481,30.5740468 C60.8504481,47.3793116 47.229101,61.0000314 30.4252476,61.0000314 C13.6215509,61.0000314 4.70437018e-05,47.3793116 4.70437018e-05,30.5740468 C4.70437018e-05,13.7711342 13.6215509,0.148846272 30.4252476,0.148846272 C47.229101,0.148846272 60.8504481,13.7711342 60.8504481,30.5740468"
280
											id="Fill-15" fill="#4C96D7" mask="url(#mask-2)"></path>
281
									</g>
282
									<path
283
										d="M7.34736527,20.4434788 C7.34736527,14.815441 10.231253,12 16,12 L16,16.2224505 C13.1153027,16.2224505 11.6736826,17.6294599 11.6736826,20.4434788 L11.6736826,26.7780236 C11.6736826,28.9016534 10.59182,30.310085 8.42858032,30.9988939 C10.5775721,31.7039788 11.6519871,33.1116203 11.6519871,35.2221344 L11.6519871,41.5566793 C11.6519871,44.3705401 13.0927976,45.7777075 15.9783045,45.7777075 L15.9783045,50 C10.2246148,50 7.34736527,47.184717 7.34736527,41.5566793 L7.34736527,35.2221344 C7.34736527,33.815283 5.89748795,33.1116203 3,33.1116203 L3,28.8883797 C5.89748795,28.8883797 7.34736527,28.185033 7.34736527,26.7780236 L7.34736527,20.4434788 Z"
284
										id="Fill-18" fill="#FFFFFF"></path>
285
									<path
286
										d="M53.6524181,41.5551342 C53.6524181,47.1845707 50.7690344,50 45,50 L45,45.7775671 C47.8841934,45.7775671 49.3266948,44.3691413 49.3266948,41.5551342 L49.3266948,35.2221959 C49.3266948,33.0969947 50.4079637,31.689201 52.5719588,30.9989729 C50.4222123,30.2954711 49.3483914,28.8884675 49.3483914,26.77654 L49.3483914,20.4434437 C49.3483914,17.6281723 47.90589,16.2225909 45.021049,16.2225909 L45.021049,12 C50.7758348,12 53.6524181,14.8140072 53.6524181,20.4434437 L53.6524181,26.77654 C53.6524181,28.1835435 55.1023677,28.8884675 58,28.8884675 L58,33.1116905 C55.1023677,33.1116905 53.6524181,33.8151923 53.6524181,35.2221959 L53.6524181,41.5551342 Z"
287
										id="Fill-20" fill="#FFFFFF"></path>
288
									<path
289
										d="M46.0272652,44 C48.1048141,44 48.9396754,43.2042837 48.9795214,41.1979284 L34.4844624,30.499526 L49,19.7867451 C48.9558678,17.7920822 48.1210065,17 46.0479025,17 L45.8064452,17 L30.9992856,27.9275105 L16.1929198,17 L15.9727348,17 C13.8943922,17 13.0596896,17.7958743 13.0206374,19.8023876 L27.5141088,30.499526 L13,41.2126229 C13.0434972,43.2071278 13.8781998,44 15.9513037,44 L16.1929198,44 L30.9992856,33.0718574 L45.8064452,44 L46.0272652,44 Z"
290
										id="Fill-22" fill="#FFFFFF"></path>
291
								</g>
292
							</g>
293
						</g>
294
					</svg>
295
					</span>
296
					<span class="acch-float-left acch-text">
297
						<h3 class="acch-title"><?php echo esc_attr( $connect_title_string ); ?></h3>
298
					<p><?php echo $connect_string; ?>
299
					</p>
300
					</span>
301
302
					<span class="acch-float-left acch-button">
303
						<button onclick="ayecode_connect_helper(this);" id="gd-connect-site" class="button button-primary" data-connecting="<?php echo esc_attr( $connecting_button_string ); ?>"><?php echo esc_attr( $connect_button_string ) ?></button>
304
					</span>
305
				</div>
306
307
				<?php
308
				// only include the popup HTML if needed.
309
				if ( ! empty( $_REQUEST['external-connect-request'] ) ) {
310
					?>
311
					<div id="ayecode-connect-helper-external-confirm" style="display:none;">
312
						<div class="noticex notice-info acch-notice" style="border: none;">
313
					<span class="acch-float-left">
314
						<svg width="61px" height="61px" viewBox="0 0 61 61" version="1.1"
315
						     xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
316
						<defs>
317
							<polygon id="path-1"
318
							         points="4.70437018e-05 0.148846272 60.8504481 0.148846272 60.8504481 61 4.70437018e-05 61"></polygon>
319
						</defs>
320
						<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
321
							<g id="Group-6" transform="translate(-8.000000, -4.000000)">
322
								<g id="Group-5" transform="translate(8.000000, 4.000000)">
323
									<g id="Group-17">
324
										<mask id="mask-2" fill="white">
325
											<use xlink:href="#path-1"></use>
326
										</mask>
327
										<g id="Clip-16"></g>
328
										<path
329
											d="M60.8504481,30.5740468 C60.8504481,47.3793116 47.229101,61.0000314 30.4252476,61.0000314 C13.6215509,61.0000314 4.70437018e-05,47.3793116 4.70437018e-05,30.5740468 C4.70437018e-05,13.7711342 13.6215509,0.148846272 30.4252476,0.148846272 C47.229101,0.148846272 60.8504481,13.7711342 60.8504481,30.5740468"
330
											id="Fill-15" fill="#4C96D7" mask="url(#mask-2)"></path>
331
									</g>
332
									<path
333
										d="M7.34736527,20.4434788 C7.34736527,14.815441 10.231253,12 16,12 L16,16.2224505 C13.1153027,16.2224505 11.6736826,17.6294599 11.6736826,20.4434788 L11.6736826,26.7780236 C11.6736826,28.9016534 10.59182,30.310085 8.42858032,30.9988939 C10.5775721,31.7039788 11.6519871,33.1116203 11.6519871,35.2221344 L11.6519871,41.5566793 C11.6519871,44.3705401 13.0927976,45.7777075 15.9783045,45.7777075 L15.9783045,50 C10.2246148,50 7.34736527,47.184717 7.34736527,41.5566793 L7.34736527,35.2221344 C7.34736527,33.815283 5.89748795,33.1116203 3,33.1116203 L3,28.8883797 C5.89748795,28.8883797 7.34736527,28.185033 7.34736527,26.7780236 L7.34736527,20.4434788 Z"
334
										id="Fill-18" fill="#FFFFFF"></path>
335
									<path
336
										d="M53.6524181,41.5551342 C53.6524181,47.1845707 50.7690344,50 45,50 L45,45.7775671 C47.8841934,45.7775671 49.3266948,44.3691413 49.3266948,41.5551342 L49.3266948,35.2221959 C49.3266948,33.0969947 50.4079637,31.689201 52.5719588,30.9989729 C50.4222123,30.2954711 49.3483914,28.8884675 49.3483914,26.77654 L49.3483914,20.4434437 C49.3483914,17.6281723 47.90589,16.2225909 45.021049,16.2225909 L45.021049,12 C50.7758348,12 53.6524181,14.8140072 53.6524181,20.4434437 L53.6524181,26.77654 C53.6524181,28.1835435 55.1023677,28.8884675 58,28.8884675 L58,33.1116905 C55.1023677,33.1116905 53.6524181,33.8151923 53.6524181,35.2221959 L53.6524181,41.5551342 Z"
337
										id="Fill-20" fill="#FFFFFF"></path>
338
									<path
339
										d="M46.0272652,44 C48.1048141,44 48.9396754,43.2042837 48.9795214,41.1979284 L34.4844624,30.499526 L49,19.7867451 C48.9558678,17.7920822 48.1210065,17 46.0479025,17 L45.8064452,17 L30.9992856,27.9275105 L16.1929198,17 L15.9727348,17 C13.8943922,17 13.0596896,17.7958743 13.0206374,19.8023876 L27.5141088,30.499526 L13,41.2126229 C13.0434972,43.2071278 13.8781998,44 15.9513037,44 L16.1929198,44 L30.9992856,33.0718574 L45.8064452,44 L46.0272652,44 Z"
340
										id="Fill-22" fill="#FFFFFF"></path>
341
								</g>
342
							</g>
343
						</g>
344
					</svg>
345
					</span>
346
					<span class="acch-float-left acch-text">
347
						<h3 class="acch-title"><?php echo esc_attr( $connect_external_string ); ?></h3>
348
					</span>
349
350
					<span class="acch-float-left acch-button">
351
						<button onclick="ayecode_connect_helper(this);" id="gd-connect-site" class="button button-primary" data-connecting="<?php echo esc_attr( $connecting_button_string ); ?>"><?php echo esc_attr( $connect_button_string ) ?></button>
352
					</span>
353
						</div>
354
					</div>
355
					<?php
356
				}
357
358
				// add required scripts
359
				$this->script();
360
			}
361
		}
362
363
		/**
364
		 * Get the JS Script.
365
		 */
366
		public function script() {
367
368
			// add thickbox if external request is requested
369
			if ( ! empty( $_REQUEST['external-connect-request'] ) ) {
370
				add_thickbox();
371
			}
372
			?>
373
			<style>
374
				.acch-title {
375
					margin: 0;
376
					padding: 0;
377
				}
378
379
				.acch-notice {
380
					display: table;
381
					width: 99%;
382
					position: relative;
383
					margin: 0;
384
					padding: 5px;
385
					border: 1px solid #ccc;
386
					border-radius: 3px;
387
				}
388
389
				.acch-float-left {
390
					display: table-cell;
391
					vertical-align: middle;
392
				}
393
394
				.acch-float-left svg {
395
					vertical-align: middle;
396
				}
397
398
				.acch-button {
399
					zoom: 1.3;
400
				}
401
			</style>
402
			<script>
403
				/**
404
				 * Ajax function to install and activate the AyeCode Connect plugin.
405
				 *
406
				 * @param $this
407
				 */
408
				function ayecode_connect_helper($this) {
409
					$connect_text = jQuery($this).text();
410
					$connecting_text = jQuery($this).data('connecting');
411
					$current_url = window.location.href + "&ayecode-connected=1";
412
					$current_url = $current_url.replace("&external-connect-request=true", ""); // strip external request param
413
					$current_url = $current_url.replace("&external-connect-request=1", ""); // strip external request param
414
415
					jQuery.ajax({
416
						type: "POST",
417
						url: ajaxurl,
418
						data: {
419
							action: 'ayecode_connect_helper',
420
							security: '<?php echo wp_create_nonce( 'ayecode-connect-helper' );?>',
421
							redirect_to: $current_url
422
						},
423
						beforeSend: function () {
424
							jQuery($this).html('<i class="fas fa-circle-notch fa-spin"></i> ' + $connecting_text).prop('disabled', true);// disable submit
425
						},
426
						success: function (data) {
427
							console.log(data);
428
							if (data.success == true && data.data.connect_url) {
429
								window.location.href = data.data.connect_url;
430
							} else if (data.success === false) {
431
								alert(data.data);
432
								jQuery($this).html($connect_text).prop('disabled', false);// enable submit
433
							}
434
						}
435
					});
436
				} 
437
				<?php
438
				// add thickbox if external request is requested
439
				if(! empty( $_REQUEST['external-connect-request'] )) {
440
				?>
441
				jQuery(function () {
442
					setTimeout(function () {
443
						tb_show("AyeCode Connect", "?TB_inline?width=300&height=80&inlineId=ayecode-connect-helper-external-confirm");
444
					}, 200);
445
				});
446
				<?php
447
				}
448
				?>
449
			</script>
450
			<?php
451
		}
452
453
		/**
454
		 * Decide what pages to show on.
455
		 *
456
		 * @return bool
457
		 */
458
		public function maybe_show() {
459
			$show = false;
460
461
			// check if on a page set to show
462
			if ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], $this->pages ) ) {
463
				// check if not active and connected
464
				if ( ! defined( 'AYECODE_CONNECT_VERSION' ) || ! get_option( 'ayecode_connect_blog_token' ) ) {
465
					$show = true;
466
				}
467
			}
468
469
			return $show;
470
		}
471
	}
472
}
473