PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 8.9.4
Jetpack – WP Security, Backup, Speed, & Growth v8.9.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 / _inc / lib / debugger / class-jetpack-debugger.php
class-jetpack-debugger.php
388 lines 12.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Jetpack Debugger functionality allowing for self-service diagnostic information via the legacy jetpack debugger.
4 *
5 * @package jetpack
6 */
7
8 use Automattic\Jetpack\Status;
9 use Automattic\Jetpack\Redirect;
10
11 /**
12 * Class Jetpack_Debugger
13 *
14 * A namespacing class for functionality related to the legacy in-plugin diagnostic tooling.
15 */
16 class Jetpack_Debugger {
17 /**
18 * Returns 30 for use with a filter.
19 *
20 * To allow time for WP.com to run upstream testing, this function exists to increase the http_request_timeout value
21 * to 30.
22 *
23 * @deprecated 8.0.0
24 *
25 * @return int 30
26 */
27 public static function jetpack_increase_timeout() {
28 _deprecated_function( __METHOD__, 'jetpack-8.0', 'Jetpack_Cxn_Tests::increase_timeout' );
29 return 30; // seconds.
30 }
31
32 /**
33 * Disconnect Jetpack and redirect user to connection flow.
34 *
35 * Used in class.jetpack-admin.php.
36 */
37 public static function disconnect_and_redirect() {
38 if ( ! ( isset( $_GET['nonce'] ) && wp_verify_nonce( $_GET['nonce'], 'jp_disconnect' ) ) ) {
39 return;
40 }
41
42 if ( isset( $_GET['disconnect'] ) && $_GET['disconnect'] ) {
43 if ( Jetpack::is_active() ) {
44 Jetpack::disconnect();
45 wp_safe_redirect( Jetpack::admin_url() );
46 exit;
47 }
48 }
49 }
50
51 /**
52 * Handles output to the browser for the in-plugin debugger.
53 */
54 public static function jetpack_debug_display_handler() {
55 if ( ! current_user_can( 'manage_options' ) ) {
56 wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'jetpack' ) );
57 }
58
59 $support_url = Jetpack::is_development_version()
60 ? Redirect::get_url( 'jetpack-contact-support-beta-group' )
61 : Redirect::get_url( 'jetpack-contact-support' );
62
63 $cxntests = new Jetpack_Cxn_Tests();
64 ?>
65 <div class="wrap">
66 <h2><?php esc_html_e( 'Debugging Center', 'jetpack' ); ?></h2>
67 <h3><?php esc_html_e( "Testing your site's compatibility with Jetpack...", 'jetpack' ); ?></h3>
68 <div class="jetpack-debug-test-container">
69 <?php
70 if ( $cxntests->pass() ) {
71 echo '<div class="jetpack-tests-succeed">' . esc_html__( 'Your Jetpack setup looks a-okay!', 'jetpack' ) . '</div>';
72 } else {
73 $failures = $cxntests->list_fails();
74 foreach ( $failures as $fail ) {
75 $action_link = $fail['action'];
76 $action_label = $fail['action_label'];
77 $action = ( $action_link ) ? '<a href="' . $action_link . '">' . $action_label . '</a>' : $action_label;
78 echo '<div class="jetpack-test-error">';
79 echo '<p><a class="jetpack-test-heading" href="#">' . esc_html( $fail['short_description'] );
80 echo '<span class="noticon noticon-collapse"></span></a></p>';
81 echo '<p class="jetpack-test-details">' . wp_kses(
82 $action,
83 array(
84 'a' => array(
85 'href' => array(),
86 'target' => array(),
87 'rel' => array(),
88 ),
89 )
90 ) . '</p>';
91 echo '</div>';
92 }
93 }
94 ?>
95 </div>
96 <div class="entry-content">
97 <h3><?php esc_html_e( 'Trouble with Jetpack?', 'jetpack' ); ?></h3>
98 <h4><?php esc_html_e( 'It may be caused by one of these issues, which you can diagnose yourself:', 'jetpack' ); ?></h4>
99 <ol>
100 <li><b><em>
101 <?php
102 esc_html_e( 'A known issue.', 'jetpack' );
103 ?>
104 </em></b>
105 <?php
106 echo sprintf(
107 wp_kses(
108 /* translators: URLs to Jetpack support pages. */
109 __( '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' ),
110 array(
111 'a' => array(
112 'href' => array(),
113 'target' => array(),
114 ),
115 )
116 ),
117 esc_url( Redirect::get_url( 'jetpack-contact-support-known-issues' ) ),
118 esc_url( Redirect::get_url( 'jetpack-contact-support-known-issues' ) ),
119 esc_url( Redirect::get_url( 'jetpack-support' ) ),
120 esc_url( Redirect::get_url( 'wporg-support-plugin-jetpack' ) )
121 );
122 ?>
123 </li>
124 <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>
125 <li>
126 <b><em><?php esc_html_e( 'A theme conflict.', 'jetpack' ); ?></em></b>
127 <?php
128 $default_theme = wp_get_theme( WP_DEFAULT_THEME );
129
130 if ( $default_theme->exists() ) {
131 /* translators: %s is the name of a theme */
132 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' ) ) );
133 } else {
134 esc_html_e( "If your problem isn't known or caused by a plugin, try activating the default WordPress theme.", 'jetpack' );
135 }
136 ?>
137 <?php esc_html_e( "If this solves the problem, something in your theme is probably broken – let the theme's author know.", 'jetpack' ); ?>
138 </li>
139 <li><b><em><?php esc_html_e( 'A problem with your XMLRPC file.', 'jetpack' ); ?></em></b>
140 <?php
141 echo sprintf(
142 wp_kses(
143 /* translators: The URL to the site's xmlrpc.php file. */
144 __( 'Load your <a href="%s">XMLRPC file</a>. It should say “XML-RPC server accepts POST requests only.” on a line by itself.', 'jetpack' ),
145 array( 'a' => array( 'href' => array() ) )
146 ),
147 esc_attr( site_url( 'xmlrpc.php' ) )
148 );
149 ?>
150 <ul>
151 <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>
152 <li>- <?php esc_html_e( 'If you get a 404 message, contact your web host. Their security may block XMLRPC.', 'jetpack' ); ?></li>
153 </ul>
154 </li>
155 <?php if ( current_user_can( 'jetpack_disconnect' ) && Jetpack::is_active() ) : ?>
156 <li>
157 <strong><em><?php esc_html_e( 'A connection problem with WordPress.com.', 'jetpack' ); ?></em></strong>
158 <?php
159 echo sprintf(
160 wp_kses(
161 /* translators: URL to disconnect and reconnect Jetpack. */
162 __( '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' ),
163 array(
164 'a' => array(
165 'href' => array(),
166 'class' => array(),
167 ),
168 )
169 ),
170 esc_attr(
171 wp_nonce_url(
172 Jetpack::admin_url(
173 array(
174 'page' => 'jetpack-debugger',
175 'disconnect' => true,
176 )
177 ),
178 'jp_disconnect',
179 'nonce'
180 )
181 )
182 );
183 ?>
184 </li>
185 <?php endif; ?>
186 </ol>
187 <h4><?php esc_html_e( 'Still having trouble?', 'jetpack' ); ?></h4>
188 <p><b><em><?php esc_html_e( 'Ask us for help!', 'jetpack' ); ?></em></b>
189 <?php
190 /**
191 * Offload to new WordPress debug data.
192 */
193 echo sprintf(
194 wp_kses(
195 /* translators: URL for Jetpack support. URL for WordPress's Site Health */
196 __( '<a href="%1$s">Contact our Happiness team</a>. When you do, please include the <a href="%2$s">full debug information from your site</a>.', 'jetpack' ),
197 array( 'a' => array( 'href' => array() ) )
198 ),
199 esc_url( $support_url ),
200 esc_url( admin_url() . 'site-health.php?tab=debug' )
201 );
202 ?>
203 </p>
204 <hr />
205 <?php if ( Jetpack::is_active() ) : ?>
206 <div id="connected-user-details">
207 <h3><?php esc_html_e( 'More details about your Jetpack settings', 'jetpack' ); ?></h3>
208 <p>
209 <?php
210 printf(
211 wp_kses(
212 /* translators: %s is an e-mail address */
213 __( 'The primary connection is owned by <strong>%s</strong>\'s WordPress.com account.', 'jetpack' ),
214 array( 'strong' => array() )
215 ),
216 esc_html( Jetpack::get_master_user_email() )
217 );
218 ?>
219 </p>
220 </div>
221 <?php else : ?>
222 <div id="dev-mode-details">
223 <p>
224 <?php
225 printf(
226 wp_kses(
227 /* translators: Link to a Jetpack support page. */
228 __( 'Would you like to use Jetpack on your local development site? You can do so thanks to <a href="%s">Jetpack\'s offline mode</a>.', 'jetpack' ),
229 array( 'a' => array( 'href' => array() ) )
230 ),
231 esc_url( Redirect::get_url( 'jetpack-support-development-mode' ) )
232 );
233 ?>
234 </p>
235 </div>
236 <?php endif; ?>
237 <?php
238 if (
239 current_user_can( 'jetpack_manage_modules' )
240 && ( ( new Status() )->is_offline_mode() || Jetpack::is_active() )
241 ) {
242 printf(
243 wp_kses(
244 '<p><a href="%1$s">%2$s</a></p>',
245 array(
246 'a' => array( 'href' => array() ),
247 'p' => array(),
248 )
249 ),
250 esc_attr( Jetpack::admin_url( 'page=jetpack_modules' ) ),
251 esc_html__( 'Access the full list of Jetpack modules available on your site.', 'jetpack' )
252 );
253 }
254 ?>
255 </div>
256 </div>
257 <?php
258 }
259
260 /**
261 * Outputs html needed within the <head> for the in-plugin debugger page.
262 */
263 public static function jetpack_debug_admin_head() {
264
265 Jetpack_Admin_Page::load_wrapper_styles();
266 ?>
267 <style type="text/css">
268
269 .jetpack-debug-test-container {
270 margin-top: 20px;
271 margin-bottom: 30px;
272 }
273
274 .jetpack-tests-succeed {
275 font-size: large;
276 color: #8BAB3E;
277 }
278
279 .jetpack-test-details {
280 margin: 4px 6px;
281 padding: 10px;
282 overflow: auto;
283 display: none;
284 }
285
286 .jetpack-test-error {
287 margin-bottom: 10px;
288 background: #FFEBE8;
289 border: solid 1px #C00;
290 border-radius: 3px;
291 }
292
293 .jetpack-test-error p {
294 margin: 0;
295 padding: 0;
296 }
297
298 p.jetpack-test-details {
299 margin: 4px 6px;
300 padding: 10px;
301 }
302
303 .jetpack-test-error a.jetpack-test-heading {
304 padding: 4px 6px;
305 display: block;
306 text-decoration: none;
307 color: inherit;
308 }
309
310 .jetpack-test-error .noticon {
311 float: right;
312 }
313
314 .formbox {
315 margin: 0 0 25px 0;
316 }
317
318 .formbox input[type="text"], .formbox input[type="email"], .formbox input[type="url"], .formbox textarea, #debug_info_div {
319 border: 1px solid #e5e5e5;
320 border-radius: 11px;
321 box-shadow: inset 0 1px 1px rgba(0,0,0,0.1);
322 color: #666;
323 font-size: 14px;
324 padding: 10px;
325 width: 97%;
326 }
327 #debug_info_div {
328 border-radius: 0;
329 margin-top: 16px;
330 background: #FFF;
331 padding: 16px;
332 }
333 .formbox .contact-support input[type="submit"] {
334 float: right;
335 margin: 0 !important;
336 border-radius: 20px !important;
337 cursor: pointer;
338 font-size: 13pt !important;
339 height: auto !important;
340 margin: 0 0 2em 10px !important;
341 padding: 8px 16px !important;
342 background-color: #ddd;
343 border: 1px solid rgba(0,0,0,0.05);
344 border-top-color: rgba(255,255,255,0.1);
345 border-bottom-color: rgba(0,0,0,0.15);
346 color: #333;
347 font-weight: 400;
348 display: inline-block;
349 text-align: center;
350 text-decoration: none;
351 }
352
353 .formbox span.errormsg {
354 margin: 0 0 10px 10px;
355 color: #d00;
356 display: none;
357 }
358
359 .formbox.error span.errormsg {
360 display: block;
361 }
362
363 #debug_info_div, #toggle_debug_info, #debug_info_div p {
364 font-size: 12px;
365 }
366
367 #category_div ul li {
368 list-style-type: none;
369 }
370
371 </style>
372 <script type="text/javascript">
373 jQuery( document ).ready( function($) {
374
375 $( '#debug_info' ).prepend( 'jQuery version: ' + jQuery.fn.jquery + "\r\n" );
376 $( '#debug_form_info' ).prepend( 'jQuery version: ' + jQuery.fn.jquery + "\r\n" );
377
378 $( '.jetpack-test-error .jetpack-test-heading' ).on( 'click', function() {
379 $( this ).parents( '.jetpack-test-error' ).find( '.jetpack-test-details' ).slideToggle();
380 return false;
381 } );
382
383 } );
384 </script>
385 <?php
386 }
387 }
388