summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/class.jetpack-debugger.php')
-rw-r--r--plugins/jetpack/class.jetpack-debugger.php155
1 files changed, 119 insertions, 36 deletions
diff --git a/plugins/jetpack/class.jetpack-debugger.php b/plugins/jetpack/class.jetpack-debugger.php
index 7e1fe5b8..db588cfa 100644
--- a/plugins/jetpack/class.jetpack-debugger.php
+++ b/plugins/jetpack/class.jetpack-debugger.php
@@ -49,6 +49,16 @@ class Jetpack_Debugger {
return 30; // seconds
}
+ public static function disconnect_and_redirect() {
+ $can_disconnect = isset( $_GET['disconnect'] ) && $_GET['disconnect'] && isset( $_GET['nonce'] ) && wp_verify_nonce( $_GET['nonce'], 'jp_disconnect' );
+ if ( $can_disconnect ) {
+ if ( Jetpack::is_active() ) {
+ Jetpack::disconnect();
+ wp_redirect( Jetpack::admin_url() );
+ }
+ }
+ }
+
public static function jetpack_debug_display_handler() {
if ( ! current_user_can( 'manage_options' ) )
wp_die( esc_html__('You do not have sufficient permissions to access this page.', 'jetpack' ) );
@@ -188,43 +198,48 @@ class Jetpack_Debugger {
?>
<div class="wrap">
<h2><?php esc_html_e( 'Jetpack Debugging Center', 'jetpack' ); ?></h2>
- <h3><?php _e( "Testing your site's compatibility with Jetpack...", 'jetpack' ); ?></h3>
- <div class="jetpack-debug-test-container">
- <?php
- ob_start();
- foreach ( $tests as $test_name => $test_info ) :
- if ( 'PASS' !== $test_info['result'] && ( is_wp_error( $test_info['result'] ) ||
- false == ( $response_code = wp_remote_retrieve_response_code( $test_info['result'] ) ) ||
- '200' != $response_code ) ) {
- $debug_info .= $test_name . ": FAIL\r\n";
- ?>
- <div class="jetpack-test-error">
- <p>
- <a class="jetpack-test-heading" href="#"><?php echo $test_info['fail_message']; ?>
- <span class="noticon noticon-collapse"></span>
- </a>
- </p>
+ <?php if ( isset( $can_disconnect ) && $can_disconnect ) : ?>
+ <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>
+ <button type="button" class="notice-dismiss"><span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice.', 'jetpack' ); ?></span></button></div>
+ <?php else: ?>
+ <h3><?php _e( "Testing your site's compatibility with Jetpack...", 'jetpack' ); ?></h3>
+ <div class="jetpack-debug-test-container">
+ <?php
+ ob_start();
+ foreach ( $tests as $test_name => $test_info ) :
+ if ( 'PASS' !== $test_info['result'] && ( is_wp_error( $test_info['result'] ) ||
+ false == ( $response_code = wp_remote_retrieve_response_code( $test_info['result'] ) ) ||
+ '200' != $response_code ) ) {
+ $debug_info .= $test_name . ": FAIL\r\n";
+ ?>
+ <div class="jetpack-test-error">
+ <p>
+ <a class="jetpack-test-heading" href="#"><?php echo $test_info['fail_message']; ?>
+ <span class="noticon noticon-collapse"></span>
+ </a>
+ </p>
<pre class="jetpack-test-details"><?php echo esc_html( $test_name ); ?>:
- <?php echo esc_html( is_wp_error( $test_info['result'] ) ? $test_info['result']->get_error_message() : print_r( $test_info['result'], 1 ) ); ?></pre>
- </div><?php
- } else {
- $debug_info .= $test_name . ": PASS\r\n";
- }
- $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 ) );
- ?>
- <?php endforeach;
- $html = ob_get_clean();
+ <?php echo esc_html( is_wp_error( $test_info['result'] ) ? $test_info['result']->get_error_message() : print_r( $test_info['result'], 1 ) ); ?></pre>
+ </div><?php
+ } else {
+ $debug_info .= $test_name . ": PASS\r\n";
+ }
+ $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 ) );
+ ?>
+ <?php endforeach;
+ $html = ob_get_clean();
+
+ if ( '' == trim( $html ) ) {
+ echo '<div class="jetpack-tests-succed">' . esc_html__( 'Your Jetpack setup looks a-okay!', 'jetpack' ) . '</div>';
+ } else {
+ echo '<h3>' . esc_html__( 'There seems to be a problem with your site’s ability to communicate with Jetpack!', 'jetpack' ) . '</h3>';
+ echo $html;
+ }
+ $debug_info .= "\r\n\r\nRAW TEST RESULTS:" . $debug_raw_info ."\r\n";
+ ?>
+ </div>
+ <?php endif; ?>
- if ( '' == trim( $html ) ) {
- echo '<div class="jetpack-tests-succed">' . esc_html__( 'Your Jetpack setup looks a-okay!', 'jetpack' ) . '</div>';
- }
- else {
- echo '<h3>' . esc_html__( 'There seems to be a problem with your site’s ability to communicate with Jetpack!', 'jetpack' ) . '</h3>';
- echo $html;
- }
- $debug_info .= "\r\n\r\nRAW TEST RESULTS:" . $debug_raw_info ."\r\n";
- ?>
- </div>
<div class="entry-content">
<h3><?php esc_html_e( 'Trouble with Jetpack?', 'jetpack' ); ?></h3>
<h4><?php esc_html_e( 'It may be caused by one of these issues, which you can diagnose yourself:', 'jetpack' ); ?></h4>
@@ -251,6 +266,24 @@ class Jetpack_Debugger {
<li>- <?php esc_html_e( "If you get a 404 message, contact your web host. Their security may block XMLRPC.", 'jetpack' ); ?></li>
</ul>
</li>
+ <?php if ( current_user_can( 'jetpack_disconnect' ) && Jetpack::is_active() ) : ?>
+ <li>
+ <strong><em><?php esc_html_e( 'A connection problem with WordPress.com.', 'jetpack' ); ?></em></strong>
+ <?php
+ echo wp_kses(
+ sprintf(
+ __( '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' ),
+ wp_nonce_url(
+ Jetpack::admin_url( array( 'page' => 'jetpack-debugger', 'disconnect' => true ) ),
+ 'jp_disconnect',
+ 'nonce'
+ )
+ ),
+ array( 'a' => array( 'href' => array(), 'class' => array() ) )
+ );
+ ?>
+ </li>
+ <?php endif; ?>
</ol>
<?php if ( self::is_jetpack_support_open() ): ?>
<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 ) ) ); ?>
@@ -259,7 +292,19 @@ class Jetpack_Debugger {
<hr />
<?php if ( Jetpack::is_active() ) : ?>
<div id="connected-user-details">
- <p><?php printf( /* translators: %s is an e-mail address */ __( 'The primary connection is owned by <strong>%s</strong>\'s WordPress.com account.', 'jetpack' ), esc_html( Jetpack::get_master_user_email() ) ); ?></p>
+ <h3><?php esc_html_e( 'More details about your Jetpack settings', 'jetpack' ); ?></h3>
+ <p><?php printf(
+ /* translators: %s is an e-mail address */
+ __( 'The primary connection is owned by <strong>%s</strong>\'s WordPress.com account.', 'jetpack' ),
+ esc_html( Jetpack::get_master_user_email() )
+ ); ?></p>
+ <?php if ( current_user_can( 'jetpack_manage_modules' ) ) {
+ printf(
+ '<p><a href="%1$s">%2$s</a></p>',
+ Jetpack::admin_url( 'page=jetpack_modules' ),
+ esc_html__( 'Access the full list of Jetpack modules available on your site.', 'jetpack' )
+ );
+ } ?>
</div>
<?php else : ?>
<div id="dev-mode-details">
@@ -294,6 +339,39 @@ class Jetpack_Debugger {
$subject_line
);
?>
+ <div id="category_div" class="formbox">
+ <label class="h" for="category"><?php esc_html_e( 'What do you need help with?', 'jetpack' ); ?></label>
+ <ul>
+ <?php
+ /**
+ * Set up an array of ticket categories.
+ * (reasons why a user would contact us.)
+ */
+ $categories = array(
+ 'Connection' => esc_html__( "I'm having trouble connecting Jetpack to WordPress.com", 'jetpack' ),
+ 'Billing' => esc_html__( 'I have a billing or plans question', 'jetpack' ),
+ 'Backups' => esc_html__( 'I need help with backing up or restoring my site', 'jetpack' ),
+ 'Security' => esc_html__( 'I have security concerns / my site is hacked', 'jetpack' ),
+ 'Priority' => esc_html__( "My site is down / I can't access my site", 'jetpack' ),
+ /* translators: Last item in a list of reasons to contact Jetpack support. */
+ 'Other' => esc_html__( 'Something Else', 'jetpack' ),
+ );
+
+ foreach ( $categories as $value => $label ) { ?>
+ <li><label for="<?php echo esc_attr( $value ); ?>">
+ <input
+ id="<?php echo esc_attr( $value ); ?>"
+ name="category"
+ type="radio"
+ value="<?php echo esc_attr( $value ); ?>"
+ <?php checked( esc_attr( $value ), 'Other' ); ?>
+ />
+ <?php echo esc_html( $label ); ?>
+ </label></li>
+ <?php } ?>
+ </ul>
+ </div>
+
<div class="formbox">
<label for="message" class="h"><?php esc_html_e( 'Please describe the problem you are having.', 'jetpack' ); ?></label>
<textarea name="message" cols="40" rows="7" id="did"></textarea>
@@ -331,6 +409,7 @@ class Jetpack_Debugger {
</form>
<?php endif; ?>
</div> <!-- contact-message, hidden by default. -->
+ <hr />
<div id="toggle_debug_info"><a href="#"><?php _e( 'View Advanced Debug Results', 'jetpack' ); ?></a></div>
<div id="debug_info_div" style="display:none">
<h4><?php esc_html_e( 'Debug Info', 'jetpack' ); ?></h4>
@@ -465,6 +544,10 @@ class Jetpack_Debugger {
font-size: 12px;
}
+ #category_div ul li {
+ list-style-type: none;
+ }
+
</style>
<script type="text/javascript">
jQuery( document ).ready( function($) {