PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 5.3.4
Jetpack – WP Security, Backup, Speed, & Growth v5.3.4
16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / class.jetpack-debugger.php

class.jetpack-debugger.php in Jetpack – WP Security, Backup, Speed, & Growth 5.3.4, at class.jetpack-debugger.php

619 lines 24.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 private static function what_jetpack_plan() {
22 $plan = Jetpack::get_active_plan();
23 $plan = ! empty( $plan['class'] ) ? $plan['class'] : 'undefined';
24 return 'JetpackPlan' . $plan;
25 }
26
27 static function seconds_to_time( $seconds ) {
28 $units = array(
29 "week" => 7*24*3600,
30 "day" => 24*3600,
31 "hour" => 3600,
32 "minute" => 60,
33 "second" => 1,
34 );
35 // specifically handle zero
36 if ( $seconds == 0 ) return "0 seconds";
37 $human_readable = "";
38 foreach ( $units as $name => $divisor ) {
39 if ( $quot = intval( $seconds / $divisor) ) {
40 $human_readable .= "$quot $name";
41 $human_readable .= ( abs( $quot ) > 1 ? "s" : "" ) . ", ";
42 $seconds -= $quot * $divisor;
43 }
44 }
45 return substr( $human_readable, 0, -2 );
46 }
47
48 public static function jetpack_increase_timeout() {
49 return 30; // seconds
50 }
51
52 public static function disconnect_and_redirect() {
53 $can_disconnect = isset( $_GET['disconnect'] ) && $_GET['disconnect'] && isset( $_GET['nonce'] ) && wp_verify_nonce( $_GET['nonce'], 'jp_disconnect' );
54 if ( $can_disconnect ) {
55 if ( Jetpack::is_active() ) {
56 Jetpack::disconnect();
57 wp_redirect( Jetpack::admin_url() );
58 exit;
59 }
60 }
61 }
62
63 public static function jetpack_debug_display_handler() {
64 if ( ! current_user_can( 'manage_options' ) )
65 wp_die( esc_html__('You do not have sufficient permissions to access this page.', 'jetpack' ) );
66
67 $current_user = wp_get_current_user();
68
69 $user_id = get_current_user_id();
70 $user_tokens = Jetpack_Options::get_option( 'user_tokens' );
71 if ( is_array( $user_tokens ) && array_key_exists( $user_id, $user_tokens ) ) {
72 $user_token = $user_tokens[$user_id];
73 } else {
74 $user_token = '[this user has no token]';
75 }
76 unset( $user_tokens );
77
78 $debug_info = "\r\n";
79 foreach ( array(
80 'CLIENT_ID' => 'id',
81 'BLOG_TOKEN' => 'blog_token',
82 'MASTER_USER' => 'master_user',
83 'CERT' => 'fallback_no_verify_ssl_certs',
84 'TIME_DIFF' => 'time_diff',
85 'VERSION' => 'version',
86 'OLD_VERSION' => 'old_version',
87 'PUBLIC' => 'public',
88 ) as $label => $option_name ) {
89 $debug_info .= "\r\n" . esc_html( $label . ": " . Jetpack_Options::get_option( $option_name ) );
90 }
91
92 $debug_info .= "\r\n" . esc_html( "USER_ID: " . $user_id );
93 $debug_info .= "\r\n" . esc_html( "USER_TOKEN: " . $user_token );
94 $debug_info .= "\r\n" . esc_html( "PHP_VERSION: " . PHP_VERSION );
95 $debug_info .= "\r\n" . esc_html( "WORDPRESS_VERSION: " . $GLOBALS['wp_version'] );
96 $debug_info .= "\r\n" . esc_html( "JETPACK__VERSION: " . JETPACK__VERSION );
97 $debug_info .= "\r\n" . esc_html( "JETPACK__PLUGIN_DIR: " . JETPACK__PLUGIN_DIR );
98 $debug_info .= "\r\n" . esc_html( "SITE_URL: " . site_url() );
99 $debug_info .= "\r\n" . esc_html( "HOME_URL: " . home_url() );
100 $debug_info .= "\r\n" . esc_html( "PLAN: " . self::what_jetpack_plan() );
101
102 $debug_info .= "\r\n";
103 require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-modules.php';
104 $sync_module = Jetpack_Sync_Modules::get_module( 'full-sync' );
105 $sync_statuses = $sync_module->get_status();
106 $human_readable_sync_status = array();
107 foreach( $sync_statuses as $sync_status => $sync_status_value ) {
108 $human_readable_sync_status[ $sync_status ] =
109 in_array( $sync_status, array( 'started', 'queue_finished', 'send_started', 'finished' ) )
110 ? date( 'r', $sync_status_value ) : $sync_status_value ;
111 }
112
113 $debug_info .= "\r\n". sprintf( esc_html__( 'Jetpack Sync Full Status: `%1$s`', 'jetpack' ), print_r( $human_readable_sync_status, 1 ) );
114
115 require_once JETPACK__PLUGIN_DIR. 'sync/class.jetpack-sync-sender.php';
116
117 $queue = Jetpack_Sync_Sender::get_instance()->get_sync_queue();
118
119 $debug_info .= "\r\n". sprintf( esc_html__( 'Sync Queue size: %1$s', 'jetpack' ), $queue->size() );
120 $debug_info .= "\r\n". sprintf( esc_html__( 'Sync Queue lag: %1$s', 'jetpack' ), self::seconds_to_time( $queue->lag() ) );
121
122 $full_sync_queue = Jetpack_Sync_Sender::get_instance()->get_full_sync_queue();
123
124 $debug_info .= "\r\n". sprintf( esc_html__( 'Full Sync Queue size: %1$s', 'jetpack' ), $full_sync_queue->size() );
125 $debug_info .= "\r\n". sprintf( esc_html__( 'Full Sync Queue lag: %1$s', 'jetpack' ), self::seconds_to_time( $full_sync_queue->lag() ) );
126
127 require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-functions.php';
128 $idc_urls = array(
129 'home' => Jetpack_Sync_Functions::home_url(),
130 'siteurl' => Jetpack_Sync_Functions::site_url(),
131 'WP_HOME' => Jetpack_Constants::is_defined( 'WP_HOME' ) ? Jetpack_Constants::get_constant( 'WP_HOME' ) : '',
132 'WP_SITEURL' => Jetpack_Constants::is_defined( 'WP_SITEURL' ) ? Jetpack_Constants::get_constant( 'WP_SITEURL' ) : '',
133 );
134 $debug_info .= "\r\n". esc_html( sprintf( 'Sync IDC URLs: %s', json_encode( $idc_urls ) ) );
135 $debug_info .= "\r\n". esc_html( sprintf( 'Sync error IDC option: %s', json_encode( Jetpack_Options::get_option( 'sync_error_idc' ) ) ) );
136 $debug_info .= "\r\n". esc_html( sprintf( 'Sync IDC Optin: %s', (string) Jetpack::sync_idc_optin() ) );
137
138 $debug_info .= "\r\n";
139
140 foreach ( array (
141 'HTTP_HOST',
142 'SERVER_PORT',
143 'HTTPS',
144 'GD_PHP_HANDLER',
145 'HTTP_AKAMAI_ORIGIN_HOP',
146 'HTTP_CF_CONNECTING_IP',
147 'HTTP_CLIENT_IP',
148 'HTTP_FASTLY_CLIENT_IP',
149 'HTTP_FORWARDED',
150 'HTTP_FORWARDED_FOR',
151 'HTTP_INCAP_CLIENT_IP',
152 'HTTP_TRUE_CLIENT_IP',
153 'HTTP_X_CLIENTIP',
154 'HTTP_X_CLUSTER_CLIENT_IP',
155 'HTTP_X_FORWARDED',
156 'HTTP_X_FORWARDED_FOR',
157 'HTTP_X_IP_TRAIL',
158 'HTTP_X_REAL_IP',
159 'HTTP_X_VARNISH',
160 'REMOTE_ADDR'
161 ) as $header ) {
162 if ( isset( $_SERVER[ $header ] ) ) {
163 $debug_info .= "\r\n" . esc_html( $header . ": " . $_SERVER[ $header ] );
164 }
165 }
166
167 $debug_info .= "\r\n" . esc_html( "PROTECT_TRUSTED_HEADER: " . json_encode( get_site_option( 'trusted_ip_header' ) ) );
168
169 $debug_info .= "\r\n\r\nTEST RESULTS:\r\n\r\n";
170 $debug_raw_info = '';
171
172
173 $tests = array();
174
175 $tests['HTTP']['result'] = wp_remote_get( preg_replace( '/^https:/', 'http:', JETPACK__API_BASE ) . 'test/1/' );
176 $tests['HTTP']['fail_message'] = esc_html__( 'Your site isn’t reaching the Jetpack servers.', 'jetpack' );
177
178 $tests['HTTPS']['result'] = wp_remote_get( preg_replace( '/^http:/', 'https:', JETPACK__API_BASE ) . 'test/1/' );
179 $tests['HTTPS']['fail_message'] = esc_html__( 'Your site isn’t securely reaching the Jetpack servers.', 'jetpack' );
180
181 $identity_crisis_message = '';
182 if ( $identity_crisis = Jetpack::check_identity_crisis() ) {
183 $identity_crisis_message .= sprintf(
184 __( 'Your url is set as `%1$s`, but your WordPress.com connection lists it as `%2$s`!', 'jetpack' ),
185 $identity_crisis['home'],
186 $identity_crisis['wpcom_home']
187 );
188 $identity_crisis = new WP_Error( 'identity-crisis', $identity_crisis_message, $identity_crisis );
189 } else {
190 $identity_crisis = 'PASS';
191 }
192 $tests['IDENTITY_CRISIS']['result'] = $identity_crisis;
193 $tests['IDENTITY_CRISIS']['fail_message'] = esc_html__( 'Something has gotten mixed up in your Jetpack Connection!', 'jetpack' );
194
195 $self_xml_rpc_url = site_url( 'xmlrpc.php' );
196
197 $testsite_url = Jetpack::fix_url_for_bad_hosts( JETPACK__API_BASE . 'testsite/1/?url=' );
198
199 add_filter( 'http_request_timeout', array( 'Jetpack_Debugger', 'jetpack_increase_timeout' ) );
200
201 $tests['SELF']['result'] = wp_remote_get( $testsite_url . $self_xml_rpc_url );
202 if ( is_wp_error( $tests['SELF']['result'] ) && 0 == strpos( $tests['SELF']['result']->get_error_message(), 'Operation timed out' ) ){
203 $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' );
204 } else {
205 $tests['SELF']['fail_message'] = esc_html__( 'It looks like your site can not communicate properly with Jetpack.', 'jetpack' );
206 }
207
208 remove_filter( 'http_request_timeout', array( 'Jetpack_Debugger', 'jetpack_increase_timeout' ) );
209
210 ?>
211 <div class="wrap">
212 <h2><?php esc_html_e( 'Jetpack Debugging Center', 'jetpack' ); ?></h2>
213 <?php if ( isset( $can_disconnect ) && $can_disconnect ) : ?>
214 <div id="message" class="updated notice notice-success is-dismissible"><p><?php esc_html_e( 'This site was successfully disconnected.', 'jetpack' ) ?> <a href="<?php echo esc_url( Jetpack::admin_url() ); ?>"><?php esc_html_e( 'Go to connection screen.', 'jetpack' ); ?></a></p>
215 <button type="button" class="notice-dismiss"><span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice.', 'jetpack' ); ?></span></button></div>
216 <?php else: ?>
217 <h3><?php _e( "Testing your site's compatibility with Jetpack...", 'jetpack' ); ?></h3>
218 <div class="jetpack-debug-test-container">
219 <?php
220 ob_start();
221 foreach ( $tests as $test_name => $test_info ) :
222 if ( 'PASS' !== $test_info['result'] && ( is_wp_error( $test_info['result'] ) ||
223 false == ( $response_code = wp_remote_retrieve_response_code( $test_info['result'] ) ) ||
224 '200' != $response_code ) ) {
225 $debug_info .= $test_name . ": FAIL\r\n";
226 ?>
227 <div class="jetpack-test-error">
228 <p>
229 <a class="jetpack-test-heading" href="#"><?php echo $test_info['fail_message']; ?>
230 <span class="noticon noticon-collapse"></span>
231 </a>
232 </p>
233 <pre class="jetpack-test-details"><?php echo esc_html( $test_name ); ?>:
234 <?php echo esc_html( is_wp_error( $test_info['result'] ) ? $test_info['result']->get_error_message() : print_r( $test_info['result'], 1 ) ); ?></pre>
235 </div><?php
236 } else {
237 $debug_info .= $test_name . ": PASS\r\n";
238 }
239 $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 ) );
240 ?>
241 <?php endforeach;
242 $html = ob_get_clean();
243
244 if ( '' == trim( $html ) ) {
245 echo '<div class="jetpack-tests-succed">' . esc_html__( 'Your Jetpack setup looks a-okay!', 'jetpack' ) . '</div>';
246 } else {
247 echo '<h3>' . esc_html__( 'There seems to be a problem with your site’s ability to communicate with Jetpack!', 'jetpack' ) . '</h3>';
248 echo $html;
249 }
250 $debug_info .= "\r\n\r\nRAW TEST RESULTS:" . $debug_raw_info ."\r\n";
251 ?>
252 </div>
253 <?php endif; ?>
254
255 <div class="entry-content">
256 <h3><?php esc_html_e( 'Trouble with Jetpack?', 'jetpack' ); ?></h3>
257 <h4><?php esc_html_e( 'It may be caused by one of these issues, which you can diagnose yourself:', 'jetpack' ); ?></h4>
258 <ol>
259 <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>
260 <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>
261 <li>
262 <b><em><?php esc_html_e( 'A theme conflict.', 'jetpack' ); ?></em></b>
263 <?php
264 $default_theme = wp_get_theme( WP_DEFAULT_THEME );
265
266 if ( $default_theme->exists() ) {
267 /* translators: %s is the name of a theme */
268 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' ) ) );
269 } else {
270 esc_html_e( "If your problem isn't known or caused by a plugin, try activating the default WordPress theme.", 'jetpack' );
271 }
272 ?>
273 <?php esc_html_e( "If this solves the problem, something in your theme is probably broken – let the theme's author know.", 'jetpack' ); ?>
274 </li>
275 <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' ) ); ?>
276 <ul>
277 <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>
278 <li>- <?php esc_html_e( "If you get a 404 message, contact your web host. Their security may block XMLRPC.", 'jetpack' ); ?></li>
279 </ul>
280 </li>
281 <?php if ( current_user_can( 'jetpack_disconnect' ) && Jetpack::is_active() ) : ?>
282 <li>
283 <strong><em><?php esc_html_e( 'A connection problem with WordPress.com.', 'jetpack' ); ?></em></strong>
284 <?php
285 echo wp_kses(
286 sprintf(
287 __( 'Jetpack works by connecting to WordPress.com for a lot of features. Sometimes, when the connection gets messed up, you need to disconnect and reconnect to get things working properly. <a href="%s">Disconnect from WordPress.com</a>', 'jetpack' ),
288 wp_nonce_url(
289 Jetpack::admin_url( array( 'page' => 'jetpack-debugger', 'disconnect' => true ) ),
290 'jp_disconnect',
291 'nonce'
292 )
293 ),
294 array( 'a' => array( 'href' => array(), 'class' => array() ) )
295 );
296 ?>
297 </li>
298 <?php endif; ?>
299 </ol>
300 <?php if ( self::is_jetpack_support_open() ): ?>
301 <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 ) ) ); ?>
302 </p>
303 <?php endif; ?>
304 <hr />
305 <?php if ( Jetpack::is_active() ) : ?>
306 <div id="connected-user-details">
307 <h3><?php esc_html_e( 'More details about your Jetpack settings', 'jetpack' ); ?></h3>
308 <p><?php printf(
309 /* translators: %s is an e-mail address */
310 __( 'The primary connection is owned by <strong>%s</strong>\'s WordPress.com account.', 'jetpack' ),
311 esc_html( Jetpack::get_master_user_email() )
312 ); ?></p>
313 </div>
314 <?php else : ?>
315 <div id="dev-mode-details">
316 <p><?php printf(
317 __( 'Would you like to use Jetpack on your local development site? You can do so thanks to <a href="%s">Jetpack\'s development mode</a>.', 'jetpack' ),
318 'https://jetpack.com/support/development-mode/'
319 ); ?></p>
320 </div>
321 <?php endif; ?>
322 <?php if (
323 current_user_can( 'jetpack_manage_modules' )
324 && ( Jetpack::is_development_mode() || Jetpack::is_active() )
325 ) {
326 printf(
327 '<p><a href="%1$s">%2$s</a></p>',
328 Jetpack::admin_url( 'page=jetpack_modules' ),
329 esc_html__( 'Access the full list of Jetpack modules available on your site.', 'jetpack' )
330 );
331 } ?>
332 </div>
333 <div id="contact-message" <?php if( ! isset( $_GET['contact'] ) ) {?> style="display:none" <?php } ?>>
334 <?php if ( self::is_jetpack_support_open() ): ?>
335 <form id="contactme" method="post" action="https://jetpack.com/contact-support/">
336 <input type="hidden" name="action" value="submit">
337 <input type="hidden" name="jetpack" value="needs-service">
338
339 <input type="hidden" name="contact_form" id="contact_form" value="1">
340 <input type="hidden" name="blog_url" id="blog_url" value="<?php echo esc_attr( site_url() ); ?>">
341 <?php
342 $subject_line = sprintf(
343 /* translators: %s is the URL of the site */
344 _x( 'from: %s Jetpack contact form', 'Support request email subject line', 'jetpack' ),
345 esc_attr( site_url() )
346 );
347
348 if ( Jetpack::is_development_version() ) {
349 $subject_line = 'BETA ' . $subject_line;
350 }
351
352 $subject_line_input = printf(
353 '<input type="hidden" name="subject" id="subject" value="%s"">',
354 $subject_line
355 );
356 ?>
357 <div id="category_div" class="formbox">
358 <label class="h" for="category"><?php esc_html_e( 'What do you need help with?', 'jetpack' ); ?></label>
359 <ul>
360 <?php
361 /**
362 * Set up an array of ticket categories.
363 * (reasons why a user would contact us.)
364 */
365 $categories = array(
366 'Connection' => esc_html__( "I'm having trouble connecting Jetpack to WordPress.com", 'jetpack' ),
367 'Billing' => esc_html__( 'I have a billing or plans question', 'jetpack' ),
368 'Backups' => esc_html__( 'I need help with backing up or restoring my site', 'jetpack' ),
369 'Security' => esc_html__( 'I have security concerns / my site is hacked', 'jetpack' ),
370 'Priority' => esc_html__( "My site is down / I can't access my site", 'jetpack' ),
371 /* translators: Last item in a list of reasons to contact Jetpack support. */
372 'Other' => esc_html__( 'Something Else', 'jetpack' ),
373 );
374
375 foreach ( $categories as $value => $label ) { ?>
376 <li><label for="<?php echo esc_attr( $value ); ?>">
377 <input
378 id="<?php echo esc_attr( $value ); ?>"
379 name="category"
380 type="radio"
381 value="<?php echo esc_attr( $value ); ?>"
382 <?php checked( esc_attr( $value ), 'Other' ); ?>
383 />
384 <?php echo esc_html( $label ); ?>
385 </label></li>
386 <?php } ?>
387 </ul>
388 </div>
389
390 <div class="formbox">
391 <label for="message" class="h"><?php esc_html_e( 'Please describe the problem you are having.', 'jetpack' ); ?></label>
392 <textarea name="message" cols="40" rows="7" id="did"></textarea>
393 </div>
394
395 <div id="name_div" class="formbox">
396 <label class="h" for="your_name"><?php esc_html_e( 'Name', 'jetpack' ); ?></label>
397 <span class="errormsg"><?php esc_html_e( 'Let us know your name.', 'jetpack' ); ?></span>
398 <input name="your_name" type="text" id="your_name" value="<?php esc_html_e( $current_user->display_name, 'jetpack'); ?>" size="40">
399 </div>
400
401 <div id="email_div" class="formbox">
402 <label class="h" for="your_email"><?php esc_html_e( 'Email', 'jetpack' ); ?></label>
403 <span class="errormsg"><?php esc_html_e( 'Use a valid email address.', 'jetpack' ); ?></span>
404 <input name="your_email" type="text" id="your_email" value="<?php esc_html_e( $current_user->user_email, 'jetpack'); ?>" size="40">
405 </div>
406
407 <div id="toggle_debug_form_info" class="formbox">
408 <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>
409 </div>
410
411 <div id="debug_info_form_div" class="formbox" style="display:none">
412 <label class="h" for="debug_info"><?php esc_html_e( 'Debug Info', 'jetpack' ); ?></label>
413 <textarea name="debug_info" cols="40" rows="7" id="debug_form_info"><?php echo esc_attr( $debug_info ); ?></textarea>
414 </div>
415
416 <div style="clear: both;"></div>
417
418 <div id="blog_div" class="formbox">
419 <div id="submit_div" class="contact-support">
420 <input type="submit" name="submit" value="<?php esc_html_e( 'Submit &#187;', 'jetpack' ); ?>">
421 </div>
422 </div>
423 <div style="clear: both;"></div>
424 </form>
425 <?php endif; ?>
426 </div> <!-- contact-message, hidden by default. -->
427 <hr />
428 <div id="toggle_debug_info"><a href="#"><?php _e( 'View Advanced Debug Results', 'jetpack' ); ?></a></div>
429 <div id="debug_info_div" style="display:none">
430 <h4><?php esc_html_e( 'Debug Info', 'jetpack' ); ?></h4>
431 <div id="debug_info"><pre><?php echo esc_html( $debug_info ) ; ?></pre></div>
432 </div>
433 </div>
434 <?php
435 }
436
437 public static function jetpack_debug_admin_head() {
438 ?>
439 <style type="text/css">
440
441 .jetpack-debug-test-container {
442 margin-top: 20px;
443 margin-bottom: 30px;
444 }
445
446 .jetpack-tests-succed {
447 font-size: large;
448 color: #8BAB3E;
449 }
450
451 .jetpack-test-details {
452 margin: 4px 6px;
453 padding: 10px;
454 overflow: auto;
455 display: none;
456 }
457
458 .jetpack-test-error {
459 margin-bottom: 10px;
460 background: #FFEBE8;
461 border: solid 1px #C00;
462 border-radius: 3px;
463 }
464
465 .jetpack-test-error p {
466 margin: 0;
467 padding: 0;
468 }
469
470 .jetpack-test-error a.jetpack-test-heading {
471 padding: 4px 6px;
472 display: block;
473 text-decoration: none;
474 color: inherit;
475 }
476
477 .jetpack-test-error .noticon {
478 float: right;
479 }
480
481 form#contactme {
482 border: 1px solid #dfdfdf;
483 background: #eaf3fa;
484 padding: 20px;
485 margin: 10px;
486 background-color: #eaf3fa;
487 border-radius: 5px;
488 font-size: 15px;
489 }
490
491 form#contactme label.h {
492 color: #444;
493 display: block;
494 font-weight: bold;
495 margin: 0 0 7px 10px;
496 text-shadow: 1px 1px 0 #fff;
497 }
498
499 .formbox {
500 margin: 0 0 25px 0;
501 }
502
503 .formbox input[type="text"], .formbox input[type="email"], .formbox input[type="url"], .formbox textarea, #debug_info_div {
504 border: 1px solid #e5e5e5;
505 border-radius: 11px;
506 box-shadow: inset 0 1px 1px rgba(0,0,0,0.1);
507 color: #666;
508 font-size: 14px;
509 padding: 10px;
510 width: 97%;
511 }
512 #debug_info_div {
513 border-radius: 0;
514 margin-top: 16px;
515 background: #FFF;
516 padding: 16px;
517 }
518 .formbox .contact-support input[type="submit"] {
519 float: right;
520 margin: 0 !important;
521 border-radius: 20px !important;
522 cursor: pointer;
523 font-size: 13pt !important;
524 height: auto !important;
525 margin: 0 0 2em 10px !important;
526 padding: 8px 16px !important;
527 background-color: #ddd;
528 border: 1px solid rgba(0,0,0,0.05);
529 border-top-color: rgba(255,255,255,0.1);
530 border-bottom-color: rgba(0,0,0,0.15);
531 color: #333;
532 font-weight: 400;
533 display: inline-block;
534 text-align: center;
535 text-decoration: none;
536 }
537
538 .formbox span.errormsg {
539 margin: 0 0 10px 10px;
540 color: #d00;
541 display: none;
542 }
543
544 .formbox.error span.errormsg {
545 display: block;
546 }
547
548 #contact-message ul {
549 margin: 0 0 20px 10px;
550 }
551
552 #contact-message li {
553 margin: 0 0 10px 10px;
554 list-style: disc;
555 display: list-item;
556 }
557
558 #debug_info_div, #toggle_debug_info, #debug_info_div p {
559 font-size: 12px;
560 }
561
562 #category_div ul li {
563 list-style-type: none;
564 }
565
566 </style>
567 <script type="text/javascript">
568 jQuery( document ).ready( function($) {
569
570 $( '#debug_info' ).prepend( 'jQuery version: ' + jQuery.fn.jquery + "\r\n" );
571 $( '#debug_form_info' ).prepend( 'jQuery version: ' + jQuery.fn.jquery + "\r\n" );
572
573 $( '.jetpack-test-error .jetpack-test-heading' ).on( 'click', function() {
574 $( this ).parents( '.jetpack-test-error' ).find( '.jetpack-test-details' ).slideToggle();
575 return false;
576 } );
577
578 $( '.jetpack-show-contact-form a' ).on( 'click', function() {
579 $( '#contact-message' ).slideToggle();
580 return false;
581 } );
582
583 $( '#toggle_debug_info a' ).on( 'click', function() {
584 $( '#debug_info_div' ).slideToggle();
585 return false;
586 } );
587
588 $( '#toggle_debug_form_info a' ).on( 'click', function() {
589 $( '#debug_info_form_div' ).slideToggle();
590 return false;
591 } );
592
593 $( 'form#contactme' ).on( "submit", function(e){
594 var form = $( this );
595 var message = form.find( '#did' );
596 var name = form.find( '#your_name' );
597 var email = form.find( '#your_email' )
598 var validation_error = false;
599 if( !name.val() ) {
600 name.parents( '.formbox' ).addClass( 'error' );
601 validation_error = true;
602 }
603 if( !email.val() ) {
604 email.parents( '.formbox' ).addClass( 'error' );
605 validation_error = true;
606 }
607 if ( validation_error ) {
608 return false;
609 }
610 message.val( message.val() + "\r\n\r\n----------------------------------------------\r\n\r\nDEBUG INFO:\r\n" + $('#debug_form_info').val() );
611 return true;
612 });
613
614 } );
615 </script>
616 <?php
617 }
618 }
619