| 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 |
||
| 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 | ? 'https://jetpack.com/contact-support/beta-group/' |
||
| 61 | : 'https://jetpack.com/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 | echo '<div class="jetpack-test-error">'; |
||
| 76 | echo '<p><a class="jetpack-test-heading" href="#">' . esc_html( $fail['message'] ); |
||
| 77 | echo '<span class="noticon noticon-collapse"></span></a></p>'; |
||
| 78 | echo '<p class="jetpack-test-details">' . wp_kses( |
||
| 79 | $fail['resolution'], |
||
| 80 | array( |
||
| 81 | 'a' => array( |
||
| 82 | 'href' => array(), |
||
| 83 | 'target' => array(), |
||
| 84 | 'rel' => array(), |
||
| 85 | ), |
||
| 86 | ) |
||
| 87 | ) . '</p>'; |
||
| 88 | echo '</div>'; |
||
| 89 | } |
||
| 90 | } |
||
| 91 | ?> |
||
| 92 | </div> |
||
| 93 | <div class="entry-content"> |
||
| 94 | <h3><?php esc_html_e( 'Trouble with Jetpack?', 'jetpack' ); ?></h3> |
||
| 95 | <h4><?php esc_html_e( 'It may be caused by one of these issues, which you can diagnose yourself:', 'jetpack' ); ?></h4> |
||
| 96 | <ol> |
||
| 97 | <li><b><em> |
||
| 98 | <?php |
||
| 99 | esc_html_e( 'A known issue.', 'jetpack' ); |
||
| 100 | ?> |
||
| 101 | </em></b> |
||
| 102 | <?php |
||
| 103 | echo sprintf( |
||
| 104 | wp_kses( |
||
| 105 | /* translators: URLs to Jetpack support pages. */ |
||
| 106 | __( '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' ), |
||
| 107 | array( |
||
| 108 | 'a' => array( |
||
| 109 | 'href' => array(), |
||
| 110 | 'target' => array(), |
||
| 111 | ), |
||
| 112 | ) |
||
| 113 | ), |
||
| 114 | 'https://jetpack.com/support/getting-started-with-jetpack/known-issues/', |
||
| 115 | 'https://jetpack.com/support/getting-started-with-jetpack/known-issues/', |
||
| 116 | 'https://jetpack.com/support/', |
||
| 117 | 'https://wordpress.org/support/plugin/jetpack' |
||
| 118 | ); |
||
| 119 | ?> |
||
| 120 | </li> |
||
| 121 | <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> |
||
| 122 | <li> |
||
| 123 | <b><em><?php esc_html_e( 'A theme conflict.', 'jetpack' ); ?></em></b> |
||
| 124 | <?php |
||
| 125 | $default_theme = wp_get_theme( WP_DEFAULT_THEME ); |
||
| 126 | |||
| 127 | if ( $default_theme->exists() ) { |
||
| 128 | /* translators: %s is the name of a theme */ |
||
| 129 | 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' ) ) ); |
||
| 130 | } else { |
||
| 131 | esc_html_e( "If your problem isn't known or caused by a plugin, try activating the default WordPress theme.", 'jetpack' ); |
||
| 132 | } |
||
| 133 | ?> |
||
| 134 | <?php esc_html_e( "If this solves the problem, something in your theme is probably broken – let the theme's author know.", 'jetpack' ); ?> |
||
| 135 | </li> |
||
| 136 | <li><b><em><?php esc_html_e( 'A problem with your XMLRPC file.', 'jetpack' ); ?></em></b> |
||
| 137 | <?php |
||
| 138 | echo sprintf( |
||
| 139 | wp_kses( |
||
| 140 | /* translators: The URL to the site's xmlrpc.php file. */ |
||
| 141 | __( 'Load your <a href="%s">XMLRPC file</a>. It should say “XML-RPC server accepts POST requests only.” on a line by itself.', 'jetpack' ), |
||
| 142 | array( 'a' => array( 'href' => array() ) ) |
||
| 143 | ), |
||
| 144 | esc_attr( site_url( 'xmlrpc.php' ) ) |
||
| 145 | ); |
||
| 146 | ?> |
||
| 147 | <ul> |
||
| 148 | <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> |
||
| 149 | <li>- <?php esc_html_e( 'If you get a 404 message, contact your web host. Their security may block XMLRPC.', 'jetpack' ); ?></li> |
||
| 150 | </ul> |
||
| 151 | </li> |
||
| 152 | <?php if ( current_user_can( 'jetpack_disconnect' ) && Jetpack::is_active() ) : ?> |
||
| 153 | <li> |
||
| 154 | <strong><em><?php esc_html_e( 'A connection problem with WordPress.com.', 'jetpack' ); ?></em></strong> |
||
| 155 | <?php |
||
| 156 | echo sprintf( |
||
| 157 | wp_kses( |
||
| 158 | /* translators: URL to disconnect and reconnect Jetpack. */ |
||
| 159 | __( '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' ), |
||
| 160 | array( |
||
| 161 | 'a' => array( |
||
| 162 | 'href' => array(), |
||
| 163 | 'class' => array(), |
||
| 164 | ), |
||
| 165 | ) |
||
| 166 | ), |
||
| 167 | esc_attr( |
||
| 168 | wp_nonce_url( |
||
| 169 | Jetpack::admin_url( |
||
| 170 | array( |
||
| 171 | 'page' => 'jetpack-debugger', |
||
| 172 | 'disconnect' => true, |
||
| 173 | ) |
||
| 174 | ), |
||
| 175 | 'jp_disconnect', |
||
| 176 | 'nonce' |
||
| 177 | ) |
||
| 178 | ) |
||
| 179 | ); |
||
| 180 | ?> |
||
| 181 | </li> |
||
| 182 | <?php endif; ?> |
||
| 183 | </ol> |
||
| 184 | <h4><?php esc_html_e( 'Still having trouble?', 'jetpack' ); ?></h4> |
||
| 185 | <p><b><em><?php esc_html_e( 'Ask us for help!', 'jetpack' ); ?></em></b> |
||
| 186 | <?php |
||
| 187 | /** |
||
| 188 | * Offload to new WordPress debug data. |
||
| 189 | */ |
||
| 190 | echo sprintf( |
||
| 191 | wp_kses( |
||
| 192 | /* translators: URL for Jetpack support. URL for WordPress's Site Health */ |
||
| 193 | __( '<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' ), |
||
| 194 | array( 'a' => array( 'href' => array() ) ) |
||
| 195 | ), |
||
| 196 | esc_url( $support_url ), |
||
| 197 | esc_url( admin_url() . 'site-health.php?tab=debug' ) |
||
| 198 | ); |
||
| 199 | ?> |
||
| 200 | </p> |
||
| 201 | <hr /> |
||
| 202 | <?php if ( Jetpack::is_active() ) : ?> |
||
| 203 | <div id="connected-user-details"> |
||
| 204 | <h3><?php esc_html_e( 'More details about your Jetpack settings', 'jetpack' ); ?></h3> |
||
| 205 | <p> |
||
| 206 | <?php |
||
| 207 | printf( |
||
| 208 | wp_kses( |
||
| 209 | /* translators: %s is an e-mail address */ |
||
| 210 | __( 'The primary connection is owned by <strong>%s</strong>\'s WordPress.com account.', 'jetpack' ), |
||
| 211 | array( 'strong' => array() ) |
||
| 212 | ), |
||
| 213 | esc_html( Jetpack::get_master_user_email() ) |
||
| 214 | ); |
||
| 215 | ?> |
||
| 216 | </p> |
||
| 217 | </div> |
||
| 218 | <?php else : ?> |
||
| 219 | <div id="dev-mode-details"> |
||
| 220 | <p> |
||
| 221 | <?php |
||
| 222 | printf( |
||
| 223 | wp_kses( |
||
| 224 | /* translators: Link to a Jetpack support page. */ |
||
| 225 | __( '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' ), |
||
| 226 | array( 'a' => array( 'href' => array() ) ) |
||
| 227 | ), |
||
| 228 | 'https://jetpack.com/support/development-mode/' |
||
| 229 | ); |
||
| 230 | ?> |
||
| 231 | </p> |
||
| 232 | </div> |
||
| 233 | <?php endif; ?> |
||
| 234 | <?php |
||
| 235 | if ( |
||
| 236 | current_user_can( 'jetpack_manage_modules' ) |
||
| 237 | && ( ( new Status() )->is_development_mode() || Jetpack::is_active() ) |
||
| 238 | ) { |
||
| 239 | printf( |
||
| 240 | wp_kses( |
||
| 241 | '<p><a href="%1$s">%2$s</a></p>', |
||
| 242 | array( |
||
| 243 | 'a' => array( 'href' => array() ), |
||
| 244 | 'p' => array(), |
||
| 245 | ) |
||
| 246 | ), |
||
| 247 | esc_attr( Jetpack::admin_url( 'page=jetpack_modules' ) ), |
||
| 248 | esc_html__( 'Access the full list of Jetpack modules available on your site.', 'jetpack' ) |
||
| 249 | ); |
||
| 250 | } |
||
| 251 | ?> |
||
| 252 | </div> |
||
| 253 | </div> |
||
| 254 | <?php |
||
| 255 | } |
||
| 256 | |||
| 385 |
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.