| 1 |
<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 |
/** |
| 3 |
* Jetpack Debugger functionality allowing for self-service diagnostic information. |
| 4 |
* |
| 5 |
* @package jetpack |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Class Jetpack_Debugger |
| 10 |
* |
| 11 |
* A namespacing class for functionality related to the in-plugin diagnostic tooling. |
| 12 |
*/ |
| 13 |
class Jetpack_Debugger { |
| 14 |
|
| 15 |
/** |
| 16 |
* Determine the active plan and normalize it for the debugger results. |
| 17 |
* |
| 18 |
* @return string The plan slug prepended with "JetpackPlan" |
| 19 |
*/ |
| 20 |
private static function what_jetpack_plan() { |
| 21 |
$plan = Jetpack::get_active_plan(); |
| 22 |
$plan = ! empty( $plan['class'] ) ? $plan['class'] : 'undefined'; |
| 23 |
return 'JetpackPlan' . $plan; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Convert seconds to human readable time. |
| 28 |
* |
| 29 |
* A dedication function instead of using Core functionality to allow for output in seconds. |
| 30 |
* |
| 31 |
* @param int $seconds Number of seconds to convert to human time. |
| 32 |
* |
| 33 |
* @return string Human readable time. |
| 34 |
*/ |
| 35 |
public static function seconds_to_time( $seconds ) { |
| 36 |
$seconds = intval( $seconds ); |
| 37 |
$units = array( |
| 38 |
'week' => WEEK_IN_SECONDS, |
| 39 |
'day' => DAY_IN_SECONDS, |
| 40 |
'hour' => HOUR_IN_SECONDS, |
| 41 |
'minute' => MINUTE_IN_SECONDS, |
| 42 |
'second' => 1, |
| 43 |
); |
| 44 |
// specifically handle zero. |
| 45 |
if ( 0 === $seconds ) { |
| 46 |
return '0 seconds'; |
| 47 |
} |
| 48 |
$human_readable = ''; |
| 49 |
foreach ( $units as $name => $divisor ) { |
| 50 |
$quot = intval( $seconds / $divisor ); |
| 51 |
if ( $quot ) { |
| 52 |
$human_readable .= "$quot $name"; |
| 53 |
$human_readable .= ( abs( $quot ) > 1 ? 's' : '' ) . ', '; |
| 54 |
$seconds -= $quot * $divisor; |
| 55 |
} |
| 56 |
} |
| 57 |
return substr( $human_readable, 0, -2 ); |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Returns 30 for use with a filter. |
| 62 |
* |
| 63 |
* To allow time for WP.com to run upstream testing, this function exists to increase the http_request_timeout value |
| 64 |
* to 30. |
| 65 |
* |
| 66 |
* @return int 30 |
| 67 |
*/ |
| 68 |
public static function jetpack_increase_timeout() { |
| 69 |
return 30; // seconds. |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* Disconnect Jetpack and redirect user to connection flow. |
| 74 |
*/ |
| 75 |
public static function disconnect_and_redirect() { |
| 76 |
if ( ! ( isset( $_GET['nonce'] ) && wp_verify_nonce( $_GET['nonce'], 'jp_disconnect' ) ) ) { |
| 77 |
return; |
| 78 |
} |
| 79 |
|
| 80 |
if ( isset( $_GET['disconnect'] ) && $_GET['disconnect'] ) { |
| 81 |
if ( Jetpack::is_active() ) { |
| 82 |
Jetpack::disconnect(); |
| 83 |
wp_safe_redirect( Jetpack::admin_url() ); |
| 84 |
exit; |
| 85 |
} |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
/** |
| 90 |
* Calls to WP.com to run the connection diagnostic testing suite. |
| 91 |
* |
| 92 |
* @return array|WP_Error Standard WP_HTTP return array: 'headers', 'body', 'response', 'cookies', 'filename' on success. |
| 93 |
*/ |
| 94 |
public static function run_self_test() { |
| 95 |
$self_xml_rpc_url = site_url( 'xmlrpc.php' ); |
| 96 |
|
| 97 |
$testsite_url = Jetpack::fix_url_for_bad_hosts( JETPACK__API_BASE . 'testsite/1/?url=' ); |
| 98 |
|
| 99 |
add_filter( 'http_request_timeout', array( 'Jetpack_Debugger', 'jetpack_increase_timeout' ) ); |
| 100 |
|
| 101 |
$response = wp_remote_get( $testsite_url . $self_xml_rpc_url ); |
| 102 |
|
| 103 |
remove_filter( 'http_request_timeout', array( 'Jetpack_Debugger', 'jetpack_increase_timeout' ) ); |
| 104 |
|
| 105 |
return $response; |
| 106 |
|
| 107 |
} |
| 108 |
|
| 109 |
/** |
| 110 |
* Handles output to the browser for the in-plugin debugger. |
| 111 |
*/ |
| 112 |
public static function jetpack_debug_display_handler() { |
| 113 |
if ( ! current_user_can( 'manage_options' ) ) { |
| 114 |
wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'jetpack' ) ); |
| 115 |
} |
| 116 |
|
| 117 |
$user_id = get_current_user_id(); |
| 118 |
$user_tokens = Jetpack_Options::get_option( 'user_tokens' ); |
| 119 |
if ( is_array( $user_tokens ) && array_key_exists( $user_id, $user_tokens ) ) { |
| 120 |
$user_token = $user_tokens[ $user_id ]; |
| 121 |
} else { |
| 122 |
$user_token = '[this user has no token]'; |
| 123 |
} |
| 124 |
unset( $user_tokens ); |
| 125 |
|
| 126 |
$debug_info = "\r\n"; |
| 127 |
foreach ( array( |
| 128 |
'CLIENT_ID' => 'id', |
| 129 |
'BLOG_TOKEN' => 'blog_token', |
| 130 |
'MASTER_USER' => 'master_user', |
| 131 |
'CERT' => 'fallback_no_verify_ssl_certs', |
| 132 |
'TIME_DIFF' => 'time_diff', |
| 133 |
'VERSION' => 'version', |
| 134 |
'OLD_VERSION' => 'old_version', |
| 135 |
'PUBLIC' => 'public', |
| 136 |
) as $label => $option_name ) { |
| 137 |
$debug_info .= "\r\n" . esc_html( $label . ': ' . Jetpack_Options::get_option( $option_name ) ); |
| 138 |
} |
| 139 |
|
| 140 |
$debug_info .= "\r\n" . esc_html( 'USER_ID: ' . $user_id ); |
| 141 |
$debug_info .= "\r\n" . esc_html( 'USER_TOKEN: ' . $user_token ); |
| 142 |
$debug_info .= "\r\n" . esc_html( 'PHP_VERSION: ' . PHP_VERSION ); |
| 143 |
$debug_info .= "\r\n" . esc_html( 'WORDPRESS_VERSION: ' . $GLOBALS['wp_version'] ); |
| 144 |
$debug_info .= "\r\n" . esc_html( 'JETPACK__VERSION: ' . JETPACK__VERSION ); |
| 145 |
$debug_info .= "\r\n" . esc_html( 'JETPACK__PLUGIN_DIR: ' . JETPACK__PLUGIN_DIR ); |
| 146 |
$debug_info .= "\r\n" . esc_html( 'SITE_URL: ' . site_url() ); |
| 147 |
$debug_info .= "\r\n" . esc_html( 'HOME_URL: ' . home_url() ); |
| 148 |
$debug_info .= "\r\n" . esc_html( 'PLAN: ' . self::what_jetpack_plan() ); |
| 149 |
|
| 150 |
$debug_info .= "\r\n"; |
| 151 |
|
| 152 |
$debug_info .= "\r\n" . '-- SYNC Status -- '; |
| 153 |
require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-modules.php'; |
| 154 |
$sync_module = Jetpack_Sync_Modules::get_module( 'full-sync' ); |
| 155 |
if ( $sync_module ) { |
| 156 |
$sync_statuses = $sync_module->get_status(); |
| 157 |
$human_readable_sync_status = array(); |
| 158 |
foreach ( $sync_statuses as $sync_status => $sync_status_value ) { |
| 159 |
$human_readable_sync_status[ $sync_status ] = |
| 160 |
in_array( $sync_status, array( 'started', 'queue_finished', 'send_started', 'finished' ), true ) |
| 161 |
? date( 'r', $sync_status_value ) : $sync_status_value; |
| 162 |
} |
| 163 |
/* translators: A string reporting status. Example: "started" */ |
| 164 |
$debug_info .= "\r\n" . sprintf( esc_html__( 'Jetpack Sync Full Status: `%1$s`', 'jetpack' ), print_r( $human_readable_sync_status, 1 ) ); //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r |
| 165 |
} |
| 166 |
|
| 167 |
require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-sender.php'; |
| 168 |
|
| 169 |
$queue = Jetpack_Sync_Sender::get_instance()->get_sync_queue(); |
| 170 |
|
| 171 |
/* translators: The number of items waiting to be synced. */ |
| 172 |
$debug_info .= "\r\n" . sprintf( esc_html__( 'Sync Queue size: %1$s', 'jetpack' ), $queue->size() ); |
| 173 |
/* translators: Human-readable time since the oldest item in the sync queue. */ |
| 174 |
$debug_info .= "\r\n" . sprintf( esc_html__( 'Sync Queue lag: %1$s', 'jetpack' ), self::seconds_to_time( $queue->lag() ) ); |
| 175 |
|
| 176 |
$full_sync_queue = Jetpack_Sync_Sender::get_instance()->get_full_sync_queue(); |
| 177 |
|
| 178 |
/* translators: The number of items waiting to be synced. */ |
| 179 |
$debug_info .= "\r\n" . sprintf( esc_html__( 'Full Sync Queue size: %1$s', 'jetpack' ), $full_sync_queue->size() ); |
| 180 |
/* translators: Human-readable time since the oldest item in the sync queue. */ |
| 181 |
$debug_info .= "\r\n" . sprintf( esc_html__( 'Full Sync Queue lag: %1$s', 'jetpack' ), self::seconds_to_time( $full_sync_queue->lag() ) ); |
| 182 |
|
| 183 |
require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-functions.php'; |
| 184 |
$idc_urls = array( |
| 185 |
'home' => Jetpack_Sync_Functions::home_url(), |
| 186 |
'siteurl' => Jetpack_Sync_Functions::site_url(), |
| 187 |
'WP_HOME' => Jetpack_Constants::is_defined( 'WP_HOME' ) ? Jetpack_Constants::get_constant( 'WP_HOME' ) : '', |
| 188 |
'WP_SITEURL' => Jetpack_Constants::is_defined( 'WP_SITEURL' ) ? Jetpack_Constants::get_constant( 'WP_SITEURL' ) : '', |
| 189 |
); |
| 190 |
/* translators: List of URLs. */ |
| 191 |
$debug_info .= "\r\n" . esc_html( sprintf( 'Sync IDC URLs: %s', wp_json_encode( $idc_urls ) ) ); |
| 192 |
/* translators: String of a current option. */ |
| 193 |
$debug_info .= "\r\n" . esc_html( sprintf( 'Sync error IDC option: %s', wp_json_encode( Jetpack_Options::get_option( 'sync_error_idc' ) ) ) ); |
| 194 |
/* translators: String of a current option. */ |
| 195 |
$debug_info .= "\r\n" . esc_html( sprintf( 'Sync IDC Optin: %s', (string) Jetpack::sync_idc_optin() ) ); |
| 196 |
|
| 197 |
$debug_info .= "\r\n"; |
| 198 |
|
| 199 |
foreach ( array( |
| 200 |
'HTTP_HOST', |
| 201 |
'SERVER_PORT', |
| 202 |
'HTTPS', |
| 203 |
'GD_PHP_HANDLER', |
| 204 |
'HTTP_AKAMAI_ORIGIN_HOP', |
| 205 |
'HTTP_CF_CONNECTING_IP', |
| 206 |
'HTTP_CLIENT_IP', |
| 207 |
'HTTP_FASTLY_CLIENT_IP', |
| 208 |
'HTTP_FORWARDED', |
| 209 |
'HTTP_FORWARDED_FOR', |
| 210 |
'HTTP_INCAP_CLIENT_IP', |
| 211 |
'HTTP_TRUE_CLIENT_IP', |
| 212 |
'HTTP_X_CLIENTIP', |
| 213 |
'HTTP_X_CLUSTER_CLIENT_IP', |
| 214 |
'HTTP_X_FORWARDED', |
| 215 |
'HTTP_X_FORWARDED_FOR', |
| 216 |
'HTTP_X_IP_TRAIL', |
| 217 |
'HTTP_X_REAL_IP', |
| 218 |
'HTTP_X_VARNISH', |
| 219 |
'REMOTE_ADDR', |
| 220 |
) as $header ) { |
| 221 |
if ( isset( $_SERVER[ $header ] ) ) { |
| 222 |
$debug_info .= "\r\n" . esc_html( $header . ': ' . $_SERVER[ $header ] ); |
| 223 |
} |
| 224 |
} |
| 225 |
|
| 226 |
$debug_info .= "\r\n" . esc_html( 'PROTECT_TRUSTED_HEADER: ' . wp_json_encode( get_site_option( 'trusted_ip_header' ) ) ); |
| 227 |
|
| 228 |
$debug_info .= "\r\n\r\nTEST RESULTS:\r\n\r\n"; |
| 229 |
$debug_raw_info = ''; |
| 230 |
|
| 231 |
$tests = array(); |
| 232 |
|
| 233 |
$tests['XML']['result'] = ( function_exists( 'xml_parser_create' ) ) ? 'PASS' : false; |
| 234 |
/* translators: Link to Jetpack Hosting support page. */ |
| 235 |
$tests['XML']['fail_message'] = esc_html__( 'Jetpack can not load necessary XML manipulation libraries. Please ask your hosting provider to refer to our server requirements at https://jetpack.com/support/server-requirements/ .', 'jetpack' ); |
| 236 |
|
| 237 |
$tests['HTTP']['result'] = wp_remote_get( preg_replace( '/^https:/', 'http:', JETPACK__API_BASE ) . 'test/1/' ); |
| 238 |
$tests['HTTP']['fail_message'] = esc_html__( 'Your site isn’t reaching the Jetpack servers.', 'jetpack' ); |
| 239 |
|
| 240 |
$tests['HTTPS']['result'] = wp_remote_get( preg_replace( '/^http:/', 'https:', JETPACK__API_BASE ) . 'test/1/' ); |
| 241 |
$tests['HTTPS']['fail_message'] = esc_html__( 'Your site isn’t securely reaching the Jetpack servers.', 'jetpack' ); |
| 242 |
|
| 243 |
$identity_crisis_message = ''; |
| 244 |
$identity_crisis = Jetpack::check_identity_crisis(); |
| 245 |
if ( $identity_crisis ) { |
| 246 |
$identity_crisis_message .= sprintf( |
| 247 |
/* translators: Two URLs. The first is the locally-recorded value, the second is the value as recorded on WP.com. */ |
| 248 |
__( 'Your url is set as `%1$s`, but your WordPress.com connection lists it as `%2$s`!', 'jetpack' ), |
| 249 |
$identity_crisis['home'], |
| 250 |
$identity_crisis['wpcom_home'] |
| 251 |
); |
| 252 |
$identity_crisis = new WP_Error( 'identity-crisis', $identity_crisis_message, $identity_crisis ); |
| 253 |
} else { |
| 254 |
$identity_crisis = 'PASS'; |
| 255 |
} |
| 256 |
$tests['IDENTITY_CRISIS']['result'] = $identity_crisis; |
| 257 |
$tests['IDENTITY_CRISIS']['fail_message'] = esc_html__( 'Something has gotten mixed up in your Jetpack Connection!', 'jetpack' ); |
| 258 |
|
| 259 |
$tests['SELF']['result'] = self::run_self_test(); |
| 260 |
|
| 261 |
if ( is_wp_error( $tests['SELF']['result'] ) && 0 == strpos( $tests['SELF']['result']->get_error_message(), 'Operation timed out' ) ) { |
| 262 |
$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' ); |
| 263 |
} else { |
| 264 |
$tests['SELF']['fail_message'] = esc_html__( 'It looks like your site can not communicate properly with Jetpack.', 'jetpack' ); |
| 265 |
} |
| 266 |
|
| 267 |
?> |
| 268 |
<div class="wrap"> |
| 269 |
<h2><?php esc_html_e( 'Debugging Center', 'jetpack' ); ?></h2> |
| 270 |
<h3><?php esc_html_e( "Testing your site's compatibility with Jetpack...", 'jetpack' ); ?></h3> |
| 271 |
<div class="jetpack-debug-test-container"> |
| 272 |
<?php |
| 273 |
ob_start(); |
| 274 |
foreach ( $tests as $test_name => $test_info ) : |
| 275 |
$response_code = wp_remote_retrieve_response_code( $test_info['result'] ); |
| 276 |
if ( 'PASS' !== $test_info['result'] && ( is_wp_error( $test_info['result'] ) || |
| 277 |
false === ( $response_code ) || |
| 278 |
200 !== intval( $response_code ) ) ) { |
| 279 |
$debug_info .= $test_name . ": FAIL\r\n"; |
| 280 |
?> |
| 281 |
<div class="jetpack-test-error"> |
| 282 |
<p> |
| 283 |
<a class="jetpack-test-heading" href="#"><?php echo esc_html( $test_info['fail_message'] ); ?> |
| 284 |
<span class="noticon noticon-collapse"></span> |
| 285 |
</a> |
| 286 |
</p> |
| 287 |
<pre class="jetpack-test-details"><?php echo esc_html( $test_name ); ?>: |
| 288 |
<?php echo esc_html( is_wp_error( $test_info['result'] ) ? $test_info['result']->get_error_message() : print_r( $test_info['result'], 1 ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r ?></pre> |
| 289 |
</div> |
| 290 |
<?php |
| 291 |
} else { |
| 292 |
$debug_info .= $test_name . ": PASS\r\n"; |
| 293 |
} |
| 294 |
$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 ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r |
| 295 |
?> |
| 296 |
<?php |
| 297 |
endforeach; |
| 298 |
$html = ob_get_clean(); |
| 299 |
|
| 300 |
if ( '' === trim( $html ) ) { |
| 301 |
echo '<div class="jetpack-tests-succed">' . esc_html__( 'Your Jetpack setup looks a-okay!', 'jetpack' ) . '</div>'; |
| 302 |
} else { |
| 303 |
echo '<h3>' . esc_html__( 'There seems to be a problem with your site’s ability to communicate with Jetpack!', 'jetpack' ) . '</h3>'; |
| 304 |
echo $html; |
| 305 |
} |
| 306 |
$debug_info .= "\r\n\r\nRAW TEST RESULTS:" . $debug_raw_info . "\r\n"; |
| 307 |
?> |
| 308 |
</div> |
| 309 |
|
| 310 |
<div class="entry-content"> |
| 311 |
<h3><?php esc_html_e( 'Trouble with Jetpack?', 'jetpack' ); ?></h3> |
| 312 |
<h4><?php esc_html_e( 'It may be caused by one of these issues, which you can diagnose yourself:', 'jetpack' ); ?></h4> |
| 313 |
<ol> |
| 314 |
<?php /* translators: URLs to Jetpack support pages. */ ?> |
| 315 |
<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> |
| 316 |
<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> |
| 317 |
<li> |
| 318 |
<b><em><?php esc_html_e( 'A theme conflict.', 'jetpack' ); ?></em></b> |
| 319 |
<?php |
| 320 |
$default_theme = wp_get_theme( WP_DEFAULT_THEME ); |
| 321 |
|
| 322 |
if ( $default_theme->exists() ) { |
| 323 |
/* translators: %s is the name of a theme */ |
| 324 |
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' ) ) ); |
| 325 |
} else { |
| 326 |
esc_html_e( "If your problem isn't known or caused by a plugin, try activating the default WordPress theme.", 'jetpack' ); |
| 327 |
} |
| 328 |
?> |
| 329 |
<?php esc_html_e( "If this solves the problem, something in your theme is probably broken – let the theme's author know.", 'jetpack' ); ?> |
| 330 |
</li> |
| 331 |
<?php /* translators: The URL to the site's xmlrpc.php file. */ ?> |
| 332 |
<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' ) ); ?> |
| 333 |
<ul> |
| 334 |
<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> |
| 335 |
<li>- <?php esc_html_e( 'If you get a 404 message, contact your web host. Their security may block XMLRPC.', 'jetpack' ); ?></li> |
| 336 |
</ul> |
| 337 |
</li> |
| 338 |
<?php if ( current_user_can( 'jetpack_disconnect' ) && Jetpack::is_active() ) : ?> |
| 339 |
<li> |
| 340 |
<strong><em><?php esc_html_e( 'A connection problem with WordPress.com.', 'jetpack' ); ?></em></strong> |
| 341 |
<?php |
| 342 |
echo wp_kses( |
| 343 |
sprintf( |
| 344 |
/* translators: URL to disconnect and reconnect Jetpack. */ |
| 345 |
__( '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' ), |
| 346 |
wp_nonce_url( |
| 347 |
Jetpack::admin_url( |
| 348 |
array( |
| 349 |
'page' => 'jetpack-debugger', |
| 350 |
'disconnect' => true, |
| 351 |
) |
| 352 |
), |
| 353 |
'jp_disconnect', |
| 354 |
'nonce' |
| 355 |
) |
| 356 |
), |
| 357 |
array( |
| 358 |
'a' => array( |
| 359 |
'href' => array(), |
| 360 |
'class' => array(), |
| 361 |
), |
| 362 |
) |
| 363 |
); |
| 364 |
?> |
| 365 |
</li> |
| 366 |
<?php endif; ?> |
| 367 |
</ol> |
| 368 |
<h4><?php esc_html_e( 'Still having trouble?', 'jetpack' ); ?></h4> |
| 369 |
<?php /* translators: URL for Jetpack support. */ ?> |
| 370 |
<p><b><em><?php esc_html_e( 'Ask us for help!', 'jetpack' ); ?></em></b> <?php echo sprintf( __( '<a href="%s">Contact our Happiness team</a>. When you do, please include the full debug information below.', 'jetpack' ), 'https://jetpack.com/contact-support/' ); ?></p> |
| 371 |
<hr /> |
| 372 |
<?php if ( Jetpack::is_active() ) : ?> |
| 373 |
<div id="connected-user-details"> |
| 374 |
<h3><?php esc_html_e( 'More details about your Jetpack settings', 'jetpack' ); ?></h3> |
| 375 |
<p> |
| 376 |
<?php |
| 377 |
printf( |
| 378 |
/* translators: %s is an e-mail address */ |
| 379 |
__( 'The primary connection is owned by <strong>%s</strong>\'s WordPress.com account.', 'jetpack' ), |
| 380 |
esc_html( Jetpack::get_master_user_email() ) |
| 381 |
); |
| 382 |
?> |
| 383 |
</p> |
| 384 |
</div> |
| 385 |
<?php else : ?> |
| 386 |
<div id="dev-mode-details"> |
| 387 |
<p> |
| 388 |
<?php |
| 389 |
printf( |
| 390 |
/* translators: Link to a Jetpack support page. */ |
| 391 |
__( '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' ), |
| 392 |
'https://jetpack.com/support/development-mode/' |
| 393 |
); |
| 394 |
?> |
| 395 |
</p> |
| 396 |
</div> |
| 397 |
<?php endif; ?> |
| 398 |
<?php |
| 399 |
if ( |
| 400 |
current_user_can( 'jetpack_manage_modules' ) |
| 401 |
&& ( Jetpack::is_development_mode() || Jetpack::is_active() ) |
| 402 |
) { |
| 403 |
printf( |
| 404 |
'<p><a href="%1$s">%2$s</a></p>', |
| 405 |
Jetpack::admin_url( 'page=jetpack_modules' ), |
| 406 |
esc_html__( 'Access the full list of Jetpack modules available on your site.', 'jetpack' ) |
| 407 |
); |
| 408 |
} |
| 409 |
?> |
| 410 |
</div> |
| 411 |
<hr /> |
| 412 |
<div id="toggle_debug_info"><?php esc_html_e( 'Advanced Debug Results', 'jetpack' ); ?></div> |
| 413 |
<div id="debug_info_div"> |
| 414 |
<h4><?php esc_html_e( 'Debug Info', 'jetpack' ); ?></h4> |
| 415 |
<div id="debug_info"><pre><?php echo esc_html( $debug_info ); ?></pre></div> |
| 416 |
</div> |
| 417 |
</div> |
| 418 |
<?php |
| 419 |
} |
| 420 |
|
| 421 |
/** |
| 422 |
* Outputs html needed within the <head> for the in-plugin debugger page. |
| 423 |
*/ |
| 424 |
public static function jetpack_debug_admin_head() { |
| 425 |
|
| 426 |
Jetpack_Admin_Page::load_wrapper_styles(); |
| 427 |
?> |
| 428 |
<style type="text/css"> |
| 429 |
|
| 430 |
.jetpack-debug-test-container { |
| 431 |
margin-top: 20px; |
| 432 |
margin-bottom: 30px; |
| 433 |
} |
| 434 |
|
| 435 |
.jetpack-tests-succed { |
| 436 |
font-size: large; |
| 437 |
color: #8BAB3E; |
| 438 |
} |
| 439 |
|
| 440 |
.jetpack-test-details { |
| 441 |
margin: 4px 6px; |
| 442 |
padding: 10px; |
| 443 |
overflow: auto; |
| 444 |
display: none; |
| 445 |
} |
| 446 |
|
| 447 |
.jetpack-test-error { |
| 448 |
margin-bottom: 10px; |
| 449 |
background: #FFEBE8; |
| 450 |
border: solid 1px #C00; |
| 451 |
border-radius: 3px; |
| 452 |
} |
| 453 |
|
| 454 |
.jetpack-test-error p { |
| 455 |
margin: 0; |
| 456 |
padding: 0; |
| 457 |
} |
| 458 |
|
| 459 |
.jetpack-test-error a.jetpack-test-heading { |
| 460 |
padding: 4px 6px; |
| 461 |
display: block; |
| 462 |
text-decoration: none; |
| 463 |
color: inherit; |
| 464 |
} |
| 465 |
|
| 466 |
.jetpack-test-error .noticon { |
| 467 |
float: right; |
| 468 |
} |
| 469 |
|
| 470 |
.formbox { |
| 471 |
margin: 0 0 25px 0; |
| 472 |
} |
| 473 |
|
| 474 |
.formbox input[type="text"], .formbox input[type="email"], .formbox input[type="url"], .formbox textarea, #debug_info_div { |
| 475 |
border: 1px solid #e5e5e5; |
| 476 |
border-radius: 11px; |
| 477 |
box-shadow: inset 0 1px 1px rgba(0,0,0,0.1); |
| 478 |
color: #666; |
| 479 |
font-size: 14px; |
| 480 |
padding: 10px; |
| 481 |
width: 97%; |
| 482 |
} |
| 483 |
#debug_info_div { |
| 484 |
border-radius: 0; |
| 485 |
margin-top: 16px; |
| 486 |
background: #FFF; |
| 487 |
padding: 16px; |
| 488 |
} |
| 489 |
.formbox .contact-support input[type="submit"] { |
| 490 |
float: right; |
| 491 |
margin: 0 !important; |
| 492 |
border-radius: 20px !important; |
| 493 |
cursor: pointer; |
| 494 |
font-size: 13pt !important; |
| 495 |
height: auto !important; |
| 496 |
margin: 0 0 2em 10px !important; |
| 497 |
padding: 8px 16px !important; |
| 498 |
background-color: #ddd; |
| 499 |
border: 1px solid rgba(0,0,0,0.05); |
| 500 |
border-top-color: rgba(255,255,255,0.1); |
| 501 |
border-bottom-color: rgba(0,0,0,0.15); |
| 502 |
color: #333; |
| 503 |
font-weight: 400; |
| 504 |
display: inline-block; |
| 505 |
text-align: center; |
| 506 |
text-decoration: none; |
| 507 |
} |
| 508 |
|
| 509 |
.formbox span.errormsg { |
| 510 |
margin: 0 0 10px 10px; |
| 511 |
color: #d00; |
| 512 |
display: none; |
| 513 |
} |
| 514 |
|
| 515 |
.formbox.error span.errormsg { |
| 516 |
display: block; |
| 517 |
} |
| 518 |
|
| 519 |
#debug_info_div, #toggle_debug_info, #debug_info_div p { |
| 520 |
font-size: 12px; |
| 521 |
} |
| 522 |
|
| 523 |
#category_div ul li { |
| 524 |
list-style-type: none; |
| 525 |
} |
| 526 |
|
| 527 |
</style> |
| 528 |
<script type="text/javascript"> |
| 529 |
jQuery( document ).ready( function($) { |
| 530 |
|
| 531 |
$( '#debug_info' ).prepend( 'jQuery version: ' + jQuery.fn.jquery + "\r\n" ); |
| 532 |
$( '#debug_form_info' ).prepend( 'jQuery version: ' + jQuery.fn.jquery + "\r\n" ); |
| 533 |
|
| 534 |
$( '.jetpack-test-error .jetpack-test-heading' ).on( 'click', function() { |
| 535 |
$( this ).parents( '.jetpack-test-error' ).find( '.jetpack-test-details' ).slideToggle(); |
| 536 |
return false; |
| 537 |
} ); |
| 538 |
|
| 539 |
} ); |
| 540 |
</script> |
| 541 |
<?php |
| 542 |
} |
| 543 |
} |
| 544 |
|