| Conditions | 12 |
| Paths | 128 |
| Total Lines | 202 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 51 | public static function jetpack_debug_display_handler() { |
||
| 52 | if ( ! current_user_can( 'manage_options' ) ) { |
||
| 53 | wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'jetpack' ) ); |
||
| 54 | } |
||
| 55 | |||
| 56 | $support_url = Jetpack::is_development_version() |
||
| 57 | ? 'https://jetpack.com/contact-support/beta-group/' |
||
| 58 | : 'https://jetpack.com/contact-support/'; |
||
| 59 | |||
| 60 | $cxntests = new Jetpack_Cxn_Tests(); |
||
| 61 | ?> |
||
| 62 | <div class="wrap"> |
||
| 63 | <h2><?php esc_html_e( 'Debugging Center', 'jetpack' ); ?></h2> |
||
| 64 | <h3><?php esc_html_e( "Testing your site's compatibility with Jetpack...", 'jetpack' ); ?></h3> |
||
| 65 | <div class="jetpack-debug-test-container"> |
||
| 66 | <?php |
||
| 67 | if ( $cxntests->pass() ) { |
||
| 68 | echo '<div class="jetpack-tests-succeed">' . esc_html__( 'Your Jetpack setup looks a-okay!', 'jetpack' ) . '</div>'; |
||
| 69 | } else { |
||
| 70 | $failures = $cxntests->list_fails(); |
||
| 71 | foreach ( $failures as $fail ) { |
||
|
|
|||
| 72 | echo '<div class="jetpack-test-error">'; |
||
| 73 | echo '<p><a class="jetpack-test-heading" href="#">' . esc_html( $fail['message'] ); |
||
| 74 | echo '<span class="noticon noticon-collapse"></span></a></p>'; |
||
| 75 | echo '<p class="jetpack-test-details">' . wp_kses( |
||
| 76 | $fail['resolution'], |
||
| 77 | array( |
||
| 78 | 'a' => array( |
||
| 79 | 'href' => array(), |
||
| 80 | 'target' => array(), |
||
| 81 | 'rel' => array(), |
||
| 82 | ), |
||
| 83 | ) |
||
| 84 | ) . '</p>'; |
||
| 85 | echo '</div>'; |
||
| 86 | } |
||
| 87 | } |
||
| 88 | ?> |
||
| 89 | </div> |
||
| 90 | <div class="entry-content"> |
||
| 91 | <h3><?php esc_html_e( 'Trouble with Jetpack?', 'jetpack' ); ?></h3> |
||
| 92 | <h4><?php esc_html_e( 'It may be caused by one of these issues, which you can diagnose yourself:', 'jetpack' ); ?></h4> |
||
| 93 | <ol> |
||
| 94 | <li><b><em> |
||
| 95 | <?php |
||
| 96 | esc_html_e( 'A known issue.', 'jetpack' ); |
||
| 97 | ?> |
||
| 98 | </em></b> |
||
| 99 | <?php |
||
| 100 | echo sprintf( |
||
| 101 | wp_kses( |
||
| 102 | /* translators: URLs to Jetpack support pages. */ |
||
| 103 | __( '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' ), |
||
| 104 | array( |
||
| 105 | 'a' => array( |
||
| 106 | 'href' => array(), |
||
| 107 | 'target' => array(), |
||
| 108 | ), |
||
| 109 | ) |
||
| 110 | ), |
||
| 111 | 'https://jetpack.com/support/getting-started-with-jetpack/known-issues/', |
||
| 112 | 'https://jetpack.com/support/getting-started-with-jetpack/known-issues/', |
||
| 113 | 'https://jetpack.com/support/', |
||
| 114 | 'https://wordpress.org/support/plugin/jetpack' |
||
| 115 | ); |
||
| 116 | ?> |
||
| 117 | </li> |
||
| 118 | <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> |
||
| 119 | <li> |
||
| 120 | <b><em><?php esc_html_e( 'A theme conflict.', 'jetpack' ); ?></em></b> |
||
| 121 | <?php |
||
| 122 | $default_theme = wp_get_theme( WP_DEFAULT_THEME ); |
||
| 123 | |||
| 124 | if ( $default_theme->exists() ) { |
||
| 125 | /* translators: %s is the name of a theme */ |
||
| 126 | 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' ) ) ); |
||
| 127 | } else { |
||
| 128 | esc_html_e( "If your problem isn't known or caused by a plugin, try activating the default WordPress theme.", 'jetpack' ); |
||
| 129 | } |
||
| 130 | ?> |
||
| 131 | <?php esc_html_e( "If this solves the problem, something in your theme is probably broken – let the theme's author know.", 'jetpack' ); ?> |
||
| 132 | </li> |
||
| 133 | <li><b><em><?php esc_html_e( 'A problem with your XMLRPC file.', 'jetpack' ); ?></em></b> |
||
| 134 | <?php |
||
| 135 | echo sprintf( |
||
| 136 | wp_kses( |
||
| 137 | /* translators: The URL to the site's xmlrpc.php file. */ |
||
| 138 | __( 'Load your <a href="%s">XMLRPC file</a>. It should say “XML-RPC server accepts POST requests only.” on a line by itself.', 'jetpack' ), |
||
| 139 | array( 'a' => array( 'href' => array() ) ) |
||
| 140 | ), |
||
| 141 | esc_attr( site_url( 'xmlrpc.php' ) ) |
||
| 142 | ); |
||
| 143 | ?> |
||
| 144 | <ul> |
||
| 145 | <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> |
||
| 146 | <li>- <?php esc_html_e( 'If you get a 404 message, contact your web host. Their security may block XMLRPC.', 'jetpack' ); ?></li> |
||
| 147 | </ul> |
||
| 148 | </li> |
||
| 149 | <?php if ( current_user_can( 'jetpack_disconnect' ) && Jetpack::is_active() ) : ?> |
||
| 150 | <li> |
||
| 151 | <strong><em><?php esc_html_e( 'A connection problem with WordPress.com.', 'jetpack' ); ?></em></strong> |
||
| 152 | <?php |
||
| 153 | echo sprintf( |
||
| 154 | wp_kses( |
||
| 155 | /* translators: URL to disconnect and reconnect Jetpack. */ |
||
| 156 | __( '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' ), |
||
| 157 | array( |
||
| 158 | 'a' => array( |
||
| 159 | 'href' => array(), |
||
| 160 | 'class' => array(), |
||
| 161 | ), |
||
| 162 | ) |
||
| 163 | ), |
||
| 164 | esc_attr( |
||
| 165 | wp_nonce_url( |
||
| 166 | Jetpack::admin_url( |
||
| 167 | array( |
||
| 168 | 'page' => 'jetpack-debugger', |
||
| 169 | 'disconnect' => true, |
||
| 170 | ) |
||
| 171 | ), |
||
| 172 | 'jp_disconnect', |
||
| 173 | 'nonce' |
||
| 174 | ) |
||
| 175 | ) |
||
| 176 | ); |
||
| 177 | ?> |
||
| 178 | </li> |
||
| 179 | <?php endif; ?> |
||
| 180 | </ol> |
||
| 181 | <h4><?php esc_html_e( 'Still having trouble?', 'jetpack' ); ?></h4> |
||
| 182 | <p><b><em><?php esc_html_e( 'Ask us for help!', 'jetpack' ); ?></em></b> |
||
| 183 | <?php |
||
| 184 | /** |
||
| 185 | * Offload to new WordPress debug data. |
||
| 186 | */ |
||
| 187 | echo sprintf( |
||
| 188 | wp_kses( |
||
| 189 | /* translators: URL for Jetpack support. URL for WordPress's Site Health */ |
||
| 190 | __( '<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' ), |
||
| 191 | array( 'a' => array( 'href' => array() ) ) |
||
| 192 | ), |
||
| 193 | esc_url( $support_url ), |
||
| 194 | esc_url( admin_url() . 'site-health.php?tab=debug' ) |
||
| 195 | ); |
||
| 196 | ?> |
||
| 197 | </p> |
||
| 198 | <hr /> |
||
| 199 | <?php if ( Jetpack::is_active() ) : ?> |
||
| 200 | <div id="connected-user-details"> |
||
| 201 | <h3><?php esc_html_e( 'More details about your Jetpack settings', 'jetpack' ); ?></h3> |
||
| 202 | <p> |
||
| 203 | <?php |
||
| 204 | printf( |
||
| 205 | wp_kses( |
||
| 206 | /* translators: %s is an e-mail address */ |
||
| 207 | __( 'The primary connection is owned by <strong>%s</strong>\'s WordPress.com account.', 'jetpack' ), |
||
| 208 | array( 'strong' => array() ) |
||
| 209 | ), |
||
| 210 | esc_html( Jetpack::get_master_user_email() ) |
||
| 211 | ); |
||
| 212 | ?> |
||
| 213 | </p> |
||
| 214 | </div> |
||
| 215 | <?php else : ?> |
||
| 216 | <div id="dev-mode-details"> |
||
| 217 | <p> |
||
| 218 | <?php |
||
| 219 | printf( |
||
| 220 | wp_kses( |
||
| 221 | /* translators: Link to a Jetpack support page. */ |
||
| 222 | __( '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' ), |
||
| 223 | array( 'a' => array( 'href' => array() ) ) |
||
| 224 | ), |
||
| 225 | 'https://jetpack.com/support/development-mode/' |
||
| 226 | ); |
||
| 227 | ?> |
||
| 228 | </p> |
||
| 229 | </div> |
||
| 230 | <?php endif; ?> |
||
| 231 | <?php |
||
| 232 | if ( |
||
| 233 | current_user_can( 'jetpack_manage_modules' ) |
||
| 234 | && ( Jetpack::is_development_mode() || Jetpack::is_active() ) |
||
| 235 | ) { |
||
| 236 | printf( |
||
| 237 | wp_kses( |
||
| 238 | '<p><a href="%1$s">%2$s</a></p>', |
||
| 239 | array( |
||
| 240 | 'a' => array( 'href' => array() ), |
||
| 241 | 'p' => array(), |
||
| 242 | ) |
||
| 243 | ), |
||
| 244 | esc_attr( Jetpack::admin_url( 'page=jetpack_modules' ) ), |
||
| 245 | esc_html__( 'Access the full list of Jetpack modules available on your site.', 'jetpack' ) |
||
| 246 | ); |
||
| 247 | } |
||
| 248 | ?> |
||
| 249 | </div> |
||
| 250 | </div> |
||
| 251 | <?php |
||
| 252 | } |
||
| 253 | |||
| 382 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.