Completed
Push — add/sync-status-to-debugger ( 8d9a33...da1c65 )
by
unknown
293:05 queued 282:03
created

class.jetpack-debugger.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
class Jetpack_Debugger {
4
5
	private static function is_jetpack_support_open() {
6
		try {
7
			$url = add_query_arg( 'ver', JETPACK__VERSION, 'https://jetpack.com/is-support-open/' );
8
			$response = wp_remote_request( esc_url_raw( $url ) );
9
			if ( is_wp_error( $response ) ) {
10
				return false;
11
			}
12
			$body = wp_remote_retrieve_body( $response );
13
			$json = json_decode( $body );
14
			return ( ( bool ) $json->is_support_open );
15
		}
16
		catch ( Exception $e ) {
17
			return true;
18
		}
19
	}
20
21
	static function seconds_to_time( $seconds ) {
22
		$units = array(
23
			"week"   => 7*24*3600,
24
			"day"    =>   24*3600,
25
			"hour"   =>      3600,
26
			"minute" =>        60,
27
			"second" =>         1,
28
		);
29
		// specifically handle zero
30
		if ( $seconds == 0 ) return "0 seconds";
31
		$human_readable = "";
32
		foreach ( $units as $name => $divisor ) {
33
			if ( $quot = intval( $seconds / $divisor) ) {
34
				$human_readable .= "$quot $name";
35
				$human_readable .= ( abs( $quot ) > 1 ? "s" : "" ) . ", ";
36
				$seconds -= $quot * $divisor;
37
			}
38
		}
39
		return substr( $human_readable, 0, -2 );
40
	}
41
42
	public static function jetpack_increase_timeout() {
43
		return 30; // seconds
44
	}
45
46
	public static function jetpack_debug_display_handler() {
47
		if ( ! current_user_can( 'manage_options' ) )
48
			wp_die( esc_html__('You do not have sufficient permissions to access this page.', 'jetpack' ) );
49
50
		$current_user = wp_get_current_user();
51
52
		$user_id = get_current_user_id();
53
		$user_tokens = Jetpack_Options::get_option( 'user_tokens' );
54
		if ( is_array( $user_tokens ) && array_key_exists( $user_id, $user_tokens ) ) {
55
			$user_token = $user_tokens[$user_id];
56
		} else {
57
			$user_token = '[this user has no token]';
58
		}
59
		unset( $user_tokens );
60
61
		$debug_info = "\r\n";
62
		foreach ( array(
63
			'CLIENT_ID'   => 'id',
64
			'BLOG_TOKEN'  => 'blog_token',
65
			'MASTER_USER' => 'master_user',
66
			'CERT'        => 'fallback_no_verify_ssl_certs',
67
			'TIME_DIFF'   => 'time_diff',
68
			'VERSION'     => 'version',
69
			'OLD_VERSION' => 'old_version',
70
			'PUBLIC'      => 'public',
71
		) as $label => $option_name ) {
72
			$debug_info .= "\r\n" . esc_html( $label . ": " . Jetpack_Options::get_option( $option_name ) );
73
		}
74
75
		$debug_info .= "\r\n" . esc_html( "USER_ID: " . $user_id );
76
		$debug_info .= "\r\n" . esc_html( "USER_TOKEN: " . $user_token );
77
		$debug_info .= "\r\n" . esc_html( "PHP_VERSION: " . PHP_VERSION );
78
		$debug_info .= "\r\n" . esc_html( "WORDPRESS_VERSION: " . $GLOBALS['wp_version'] );
79
		$debug_info .= "\r\n" . esc_html( "JETPACK__VERSION: " . JETPACK__VERSION );
80
		$debug_info .= "\r\n" . esc_html( "JETPACK__PLUGIN_DIR: " . JETPACK__PLUGIN_DIR );
81
		$debug_info .= "\r\n" . esc_html( "SITE_URL: " . site_url() );
82
		$debug_info .= "\r\n" . esc_html( "HOME_URL: " . home_url() );
83
84
		$debug_info .= "\r\n";
85
		require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-modules.php';
86
		$sync_module = Jetpack_Sync_Modules::get_module( 'full-sync' );
87
88
		$debug_info .= "\r\n". sprintf( esc_html__( 'Jetpack Sync Full Status: `%1$s`', 'jetpack' ), print_r( $sync_module->get_status(), 1 ) );
89
90
		$next_schedules = wp_next_scheduled( 'jetpack_sync_full' );
91
		if( $next_schedules ) {
92
			$debug_info .= "\r\n". sprintf( esc_html__( 'Next Jetpack Full Sync Schedule: `%1$s`', 'jetpack' ), date( 'r', $next_schedules ) );
93
		} else {
94
			$debug_info .= "\r\n". esc_html__( "Next Jetpack Full Sync Schedule: Not Schedules", 'jetpack' );
95
		}
96
97
		require_once JETPACK__PLUGIN_DIR. 'sync/class.jetpack-sync-sender.php';
98
		$queue = Jetpack_Sync_Sender::get_instance()->get_sync_queue();
99
100
		$debug_info .= "\r\n". sprintf( esc_html__( 'Sync Queue size: `%1$s`', 'jetpack' ), $queue->size() );
101
		$debug_info .= "\r\n". sprintf( esc_html__( 'Sync Queue lag: `%1$s`', 'jetpack' ), self::seconds_to_time( $queue->lag() ) );
102
		$debug_info .= "\r\n";
103
		
104
		foreach ( array (
105
					  'HTTP_HOST',
106
					  'SERVER_PORT',
107
					  'HTTPS',
108
					  'GD_PHP_HANDLER',
109
					  'HTTP_AKAMAI_ORIGIN_HOP',
110
					  'HTTP_CF_CONNECTING_IP',
111
					  'HTTP_CLIENT_IP',
112
					  'HTTP_FASTLY_CLIENT_IP',
113
					  'HTTP_FORWARDED',
114
					  'HTTP_FORWARDED_FOR',
115
					  'HTTP_INCAP_CLIENT_IP',
116
					  'HTTP_TRUE_CLIENT_IP',
117
					  'HTTP_X_CLIENTIP',
118
					  'HTTP_X_CLUSTER_CLIENT_IP',
119
					  'HTTP_X_FORWARDED',
120
					  'HTTP_X_FORWARDED_FOR',
121
					  'HTTP_X_IP_TRAIL',
122
					  'HTTP_X_REAL_IP',
123
					  'HTTP_X_VARNISH',
124
					  'REMOTE_ADDR'
125
				  ) as $header ) {
126
			if ( isset( $_SERVER[ $header ] ) ) {
127
				$debug_info .= "\r\n" . esc_html( $header . ": " . $_SERVER[ $header ] );
128
			}
129
		}
130
131
		$debug_info .= "\r\n" . esc_html( "PROTECT_TRUSTED_HEADER: " . json_encode( get_site_option( 'trusted_ip_header' ) ) );
132
133
		$debug_info .= "\r\n\r\nTEST RESULTS:\r\n\r\n";
134
		$debug_raw_info = '';
135
136
137
		$tests = array();
138
139
		$tests['HTTP']['result'] = wp_remote_get( preg_replace( '/^https:/', 'http:', JETPACK__API_BASE ) . 'test/1/' );
140
		$tests['HTTP']['fail_message'] = esc_html__( 'Your site isn’t reaching the Jetpack servers.', 'jetpack' );
141
142
		$tests['HTTPS']['result'] = wp_remote_get( preg_replace( '/^http:/', 'https:', JETPACK__API_BASE ) . 'test/1/' );
143
		$tests['HTTPS']['fail_message'] = esc_html__( 'Your site isn’t securely reaching the Jetpack servers.', 'jetpack' );
144
145
		$identity_crisis_message = '';
146
		if ( $identity_crisis = Jetpack::check_identity_crisis( true ) ) {
147
			foreach( $identity_crisis as $key => $value ) {
148
				$identity_crisis_message .= sprintf( __( 'Your `%1$s` option is set up as `%2$s`, but your WordPress.com connection lists it as `%3$s`!', 'jetpack' ), $key, (string) get_option( $key ), $value ) . "\r\n";
149
			}
150
			$identity_crisis = new WP_Error( 'identity-crisis', $identity_crisis_message, $identity_crisis );
151
		} else {
152
			$identity_crisis = 'PASS';
153
		}
154
		$tests['IDENTITY_CRISIS']['result'] = $identity_crisis;
155
		$tests['IDENTITY_CRISIS']['fail_message'] = esc_html__( 'Something has gotten mixed up in your Jetpack Connection!', 'jetpack' );
156
157
		$self_xml_rpc_url = home_url( 'xmlrpc.php' );
158
159
		$testsite_url = Jetpack::fix_url_for_bad_hosts( JETPACK__API_BASE . 'testsite/1/?url=' );
160
161
		add_filter( 'http_request_timeout', array( 'Jetpack_Debugger', 'jetpack_increase_timeout' ) );
162
163
		$tests['SELF']['result'] = wp_remote_get( $testsite_url . $self_xml_rpc_url );
164
		if ( is_wp_error( $tests['SELF']['result'] ) && 0 == strpos( $tests['SELF']['result']->get_error_message(), 'Operation timed out' ) ){
165
			$tests['SELF']['fail_message'] = esc_html__( 'Your site did not get a response from our debugging service in the expected timeframe. If you are not experiencing other issues, this could be due to a slow connection between your site and our server.', 'jetpack' );
166
		} else {
167
			$tests['SELF']['fail_message'] = esc_html__( 'It looks like your site can not communicate properly with Jetpack.', 'jetpack' );
168
		}
169
170
		remove_filter( 'http_request_timeout', array( 'Jetpack_Debugger', 'jetpack_increase_timeout' ) );
171
172
		?>
173
		<div class="wrap">
174
			<h2><?php esc_html_e( 'Jetpack Debugging Center', 'jetpack' ); ?></h2>
175
			<h3><?php _e( "Testing your site's compatibility with Jetpack...", 'jetpack' ); ?></h3>
176
			<div class="jetpack-debug-test-container">
177
			<?php
178
			ob_start();
179
			foreach ( $tests as $test_name => $test_info ) :
180
				if ( 'PASS' !== $test_info['result'] && ( is_wp_error( $test_info['result'] ) ||
181
					false == ( $response_code = wp_remote_retrieve_response_code( $test_info['result'] ) )  ||
182
					'200' != $response_code ) ) {
0 ignored issues
show
The variable $response_code does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
183
					$debug_info .= $test_name . ": FAIL\r\n";
184
					?>
185
					<div class="jetpack-test-error">
186
						<p>
187
							<a class="jetpack-test-heading" href="#"><?php echo $test_info['fail_message']; ?>
188
							<span class="noticon noticon-collapse"></span>
189
							</a>
190
						</p>
191
						<pre class="jetpack-test-details"><?php echo esc_html( $test_name ); ?>:
192
	<?php echo esc_html( is_wp_error( $test_info['result'] ) ? $test_info['result']->get_error_message() : print_r( $test_info['result'], 1 ) ); ?></pre>
193
					</div><?php
194
				} else {
195
					$debug_info .= $test_name . ": PASS\r\n";
196
				}
197
				$debug_raw_info .= "\r\n\r\n" . $test_name . "\r\n" . esc_html( is_wp_error( $test_info['result'] ) ? $test_info['result']->get_error_message() : print_r( $test_info['result'], 1 ) );
198
				?>
199
			<?php endforeach;
200
			$html = ob_get_clean();
201
202
			if ( '' == trim( $html ) ) {
203
				echo '<div class="jetpack-tests-succed">' . esc_html__( 'Your Jetpack setup looks a-okay!', 'jetpack' ) . '</div>';
204
			}
205
			else {
206
				echo '<h3>' . esc_html__( 'There seems to be a problem with your site’s ability to communicate with Jetpack!', 'jetpack' ) . '</h3>';
207
				echo $html;
208
			}
209
			$debug_info .= "\r\n\r\nRAW TEST RESULTS:" . $debug_raw_info ."\r\n";
210
			?>
211
			</div>
212
			<div class="entry-content">
213
				<h3><?php esc_html_e( 'Trouble with Jetpack?', 'jetpack' ); ?></h3>
214
				<h4><?php esc_html_e( 'It may be caused by one of these issues, which you can diagnose yourself:', 'jetpack' ); ?></h4>
215
				<ol>
216
					<li><b><em><?php esc_html_e( 'A known issue.', 'jetpack' ); ?></em></b>  <?php echo sprintf( __( 'Some themes and plugins have <a href="%1$s" target="_blank">known conflicts</a> with Jetpack – check the <a href="%2$s" target="_blank">list</a>. (You can also browse the <a href="%3$s" target="_blank">Jetpack support pages</a> or <a href="%4$s" target="_blank">Jetpack support forum</a> to see if others have experienced and solved the problem.)', 'jetpack' ), 'http://jetpack.com/support/getting-started-with-jetpack/known-issues/', 'http://jetpack.com/support/getting-started-with-jetpack/known-issues/', 'http://jetpack.com/support/', 'https://wordpress.org/support/plugin/jetpack' ); ?></li>
217
					<li><b><em><?php esc_html_e( 'An incompatible plugin.', 'jetpack' ); ?></em></b>  <?php esc_html_e( "Find out by disabling all plugins except Jetpack. If the problem persists, it's not a plugin issue. If the problem is solved, turn your plugins on one by one until the problem pops up again – there's the culprit! Let us know, and we'll try to help.", 'jetpack' ); ?></li>
218
					<li>
219
						<b><em><?php esc_html_e( 'A theme conflict.', 'jetpack' ); ?></em></b>
220
						<?php
221
							$default_theme = wp_get_theme( WP_DEFAULT_THEME );
222
223
							if ( $default_theme->exists() ) {
224
								echo esc_html( sprintf( __( "If your problem isn't known or caused by a plugin, try activating %s (the default WordPress theme).", 'jetpack' ), $default_theme->get( 'Name' ) ) );
225
							} else {
226
								esc_html_e( "If your problem isn't known or caused by a plugin, try activating the default WordPress theme.", 'jetpack' );
227
							}
228
						?>
229
						<?php esc_html_e( "If this solves the problem, something in your theme is probably broken – let the theme's author know.", 'jetpack' ); ?>
230
					</li>
231
					<li><b><em><?php esc_html_e( 'A problem with your XMLRPC file.', 'jetpack' ); ?></em></b>  <?php echo sprintf( __( 'Load your <a href="%s">XMLRPC file</a>. It should say “XML-RPC server accepts POST requests only.” on a line by itself.', 'jetpack' ), site_url( 'xmlrpc.php' ) ); ?>
232
						<ul>
233
							<li>- <?php esc_html_e( "If it's not by itself, a theme or plugin is displaying extra characters. Try steps 2 and 3.", 'jetpack' ); ?></li>
234
							<li>- <?php esc_html_e( "If you get a 404 message, contact your web host. Their security may block XMLRPC.", 'jetpack' ); ?></li>
235
						</ul>
236
					</li>
237
				</ol>
238
				<?php if ( self::is_jetpack_support_open() ): ?>
239
				<p class="jetpack-show-contact-form"><?php echo sprintf( __( 'If none of these help you find a solution, <a href="%s">click here to contact Jetpack support</a>. Tell us as much as you can about the issue and what steps you\'ve tried to resolve it, and one of our Happiness Engineers will be in touch to help.', 'jetpack' ), Jetpack::admin_url( array( 'page' => 'jetpack-debugger', 'contact' => true ) ) ); ?>
240
				</p>
241
				<?php endif; ?>
242
				<?php if ( Jetpack::is_active() ) : ?>
243
					<hr />
244
					<div id="connected-user-details">
245
						<p><?php printf( __( 'The primary connection is owned by <strong>%s</strong>\'s WordPress.com account.', 'jetpack' ), esc_html( Jetpack::get_master_user_email() ) ); ?></p>
246
					</div>
247
				<?php endif; ?>
248
			</div>
249
			<div id="contact-message" <?php if( ! isset( $_GET['contact'] ) ) {?>  style="display:none" <?php } ?>>
250
			<?php if ( self::is_jetpack_support_open() ): ?>
251
				<form id="contactme" method="post" action="https://jetpack.com/contact-support/">
252
					<input type="hidden" name="action" value="submit">
253
					<input type="hidden" name="jetpack" value="needs-service">
254
255
					<input type="hidden" name="contact_form" id="contact_form" value="1">
256
					<input type="hidden" name="blog_url" id="blog_url" value="<?php echo esc_attr( site_url() ); ?>">
257
					<?php
258
						$subject_line = sprintf(
259
							/* translators: %s is the URL of the site */
260
							_x( 'from: %s Jetpack contact form', 'Support request email subject line', 'jetpack' ),
261
							esc_attr( site_url() )
262
						);
263
264
						if ( Jetpack::is_development_version() ) {
265
							$subject_line = 'BETA ' . $subject_line;
266
						}
267
268
						$subject_line_input = printf(
0 ignored issues
show
$subject_line_input is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
269
							'<input type="hidden" name="subject" id="subject" value="%s"">',
270
							$subject_line
271
						);
272
					?>
273
					<div class="formbox">
274
						<label for="message" class="h"><?php esc_html_e( 'Please describe the problem you are having.', 'jetpack' ); ?></label>
275
						<textarea name="message" cols="40" rows="7" id="did"></textarea>
276
					</div>
277
278
					<div id="name_div" class="formbox">
279
						<label class="h" for="your_name"><?php esc_html_e( 'Name', 'jetpack' ); ?></label>
280
			  			<span class="errormsg"><?php esc_html_e( 'Let us know your name.', 'jetpack' ); ?></span>
281
						<input name="your_name" type="text" id="your_name" value="<?php esc_html_e( $current_user->display_name, 'jetpack'); ?>" size="40">
282
					</div>
283
284
					<div id="email_div" class="formbox">
285
						<label class="h" for="your_email"><?php esc_html_e( 'E-mail', 'jetpack' ); ?></label>
286
			  			<span class="errormsg"><?php esc_html_e( 'Use a valid email address.', 'jetpack' ); ?></span>
287
						<input name="your_email" type="text" id="your_email" value="<?php esc_html_e( $current_user->user_email, 'jetpack'); ?>" size="40">
288
					</div>
289
290
					<div id="toggle_debug_form_info" class="formbox">
291
						<p><?php _e( 'The test results and some other useful debug information will be sent to the support team. Please feel free to <a href="#">review/modify</a> this information.', 'jetpack' ); ?></p>
292
					</div>
293
294
					<div id="debug_info_form_div" class="formbox" style="display:none">
295
						<label class="h" for="debug_info"><?php esc_html_e( 'Debug Info', 'jetpack' ); ?></label>
296
			  			<textarea name="debug_info" cols="40" rows="7" id="debug_form_info"><?php echo esc_attr( $debug_info ); ?></textarea>
297
					</div>
298
299
					<div style="clear: both;"></div>
300
301
					<div id="blog_div" class="formbox">
302
						<div id="submit_div" class="contact-support">
303
						<input type="submit" name="submit" value="<?php esc_html_e( 'Submit &#187;', 'jetpack' ); ?>">
304
						</div>
305
					</div>
306
					<div style="clear: both;"></div>
307
				</form>
308
			<?php endif; ?>
309
		</div> <!-- contact-message, hidden by default. -->
310
		<div id="toggle_debug_info"><a href="#"><?php _e( 'View Advanced Debug Results', 'jetpack' ); ?></a></div>
311
			<div id="debug_info_div" style="display:none">
312
			<h4><?php esc_html_e( 'Debug Info', 'jetpack' ); ?></h4>
313
			<div id="debug_info"><?php echo wpautop( esc_html( $debug_info ) ); ?></div>
314
		</div>
315
		</div>
316
	<?php
317
	}
318
319
	public static function jetpack_debug_admin_head() {
320
		?>
321
		<style type="text/css">
322
323
			.jetpack-debug-test-container {
324
				margin-top: 20px;
325
				margin-bottom: 30px;
326
			}
327
328
			.jetpack-tests-succed {
329
				font-size: large;
330
				color: #8BAB3E;
331
			}
332
333
			.jetpack-test-details {
334
				margin: 4px 6px;
335
				padding: 10px;
336
				overflow: auto;
337
				display: none;
338
			}
339
340
			.jetpack-test-error {
341
				margin-bottom: 10px;
342
				background: #FFEBE8;
343
				border: solid 1px #C00;
344
				border-radius: 3px;
345
			}
346
347
			.jetpack-test-error p {
348
				margin: 0;
349
				padding: 0;
350
			}
351
352
			.jetpack-test-error a.jetpack-test-heading {
353
				padding: 4px 6px;
354
				display: block;
355
				text-decoration: none;
356
				color: inherit;
357
			}
358
359
			.jetpack-test-error .noticon {
360
				float: right;
361
			}
362
363
			form#contactme {
364
				border: 1px solid #dfdfdf;
365
				background: #eaf3fa;
366
				padding: 20px;
367
				margin: 10px;
368
				background-color: #eaf3fa;
369
				border-radius: 5px;
370
				font-size: 15px;
371
			}
372
373
			form#contactme label.h {
374
				color: #444;
375
				display: block;
376
				font-weight: bold;
377
				margin: 0 0 7px 10px;
378
				text-shadow: 1px 1px 0 #fff;
379
			}
380
381
			.formbox {
382
				margin: 0 0 25px 0;
383
			}
384
385
			.formbox input[type="text"], .formbox input[type="email"], .formbox input[type="url"], .formbox textarea, #debug_info_div {
386
				border: 1px solid #e5e5e5;
387
				border-radius: 11px;
388
				box-shadow: inset 0 1px 1px rgba(0,0,0,0.1);
389
				color: #666;
390
				font-size: 14px;
391
				padding: 10px;
392
				width: 97%;
393
			}
394
			.formbox .contact-support input[type="submit"] {
395
				float: right;
396
				margin: 0 !important;
397
				border-radius: 20px !important;
398
				cursor: pointer;
399
				font-size: 13pt !important;
400
				height: auto !important;
401
				margin: 0 0 2em 10px !important;
402
				padding: 8px 16px !important;
403
				background-color: #ddd;
404
				border: 1px solid rgba(0,0,0,0.05);
405
				border-top-color: rgba(255,255,255,0.1);
406
				border-bottom-color: rgba(0,0,0,0.15);
407
				color: #333;
408
				font-weight: 400;
409
				display: inline-block;
410
				text-align: center;
411
				text-decoration: none;
412
			}
413
414
			.formbox span.errormsg {
415
				margin: 0 0 10px 10px;
416
				color: #d00;
417
				display: none;
418
			}
419
420
			.formbox.error span.errormsg {
421
				display: block;
422
			}
423
424
			#contact-message ul {
425
				margin: 0 0 20px 10px;
426
			}
427
428
			#contact-message li {
429
				margin: 0 0 10px 10px;
430
				list-style: disc;
431
				display: list-item;
432
			}
433
434
			#debug_info_div, #toggle_debug_info, #debug_info_div p {
435
				font-size: smaller;
436
			}
437
438
		</style>
439
		<script type="text/javascript">
440
		jQuery( document ).ready( function($) {
441
442
			$( '#debug_info' ).prepend( 'jQuery version: ' + jQuery.fn.jquery + "\r\n" );
443
			$( '#debug_form_info' ).prepend( 'jQuery version: ' + jQuery.fn.jquery + "\r\n" );
444
445
			$( '.jetpack-test-error .jetpack-test-heading' ).on( 'click', function() {
446
				$( this ).parents( '.jetpack-test-error' ).find( '.jetpack-test-details' ).slideToggle();
447
				return false;
448
			} );
449
450
			$( '.jetpack-show-contact-form a' ).on( 'click', function() {
451
				$( '#contact-message' ).slideToggle();
452
				return false;
453
			} );
454
455
			$( '#toggle_debug_info a' ).on( 'click', function() {
456
				$( '#debug_info_div' ).slideToggle();
457
				return false;
458
			} );
459
460
			$( '#toggle_debug_form_info a' ).on( 'click', function() {
461
				$( '#debug_info_form_div' ).slideToggle();
462
				return false;
463
			} );
464
465
			$( 'form#contactme' ).on( "submit", function(e){
466
				var form = $( this );
467
				var message = form.find( '#did' );
468
				var name = form.find( '#your_name' );
469
				var email = form.find( '#your_email' )
470
				var validation_error = false;
471
				if( !name.val() ) {
472
					name.parents( '.formbox' ).addClass( 'error' );
473
					validation_error = true;
474
				}
475
				if( !email.val() ) {
476
					email.parents( '.formbox' ).addClass( 'error' );
477
					validation_error = true;
478
				}
479
				if ( validation_error ) {
480
					return false;
481
				}
482
				message.val( message.val() + "\r\n\r\n----------------------------------------------\r\n\r\nDEBUG INFO:\r\n" + $('#debug_form_info').val()  );
483
				return true;
484
	    	});
485
486
		} );
487
		</script>
488
		<?php
489
	}
490
}
491