| Conditions | 12 |
| Paths | 196 |
| Total Lines | 37 |
| 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 |
||
| 6 | function jetpack_likes_master_iframe() { |
||
| 7 | $version = gmdate( 'YW' ); |
||
| 8 | $in_jetpack = ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ? false : true; |
||
| 9 | |||
| 10 | $_locale = get_locale(); |
||
| 11 | |||
| 12 | // We have to account for w.org vs WP.com locale divergence |
||
| 13 | if ( $in_jetpack ) { |
||
| 14 | if ( ! defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) || ! file_exists( JETPACK__GLOTPRESS_LOCALES_PATH ) ) { |
||
| 15 | return false; |
||
| 16 | } |
||
| 17 | |||
| 18 | require_once JETPACK__GLOTPRESS_LOCALES_PATH; |
||
| 19 | |||
| 20 | $gp_locale = GP_Locales::by_field( 'wp_locale', $_locale ); |
||
| 21 | $_locale = isset( $gp_locale->slug ) ? $gp_locale->slug : ''; |
||
| 22 | } |
||
| 23 | |||
| 24 | $likes_locale = ( '' == $_locale || 'en' == $_locale ) ? '' : '&lang=' . strtolower( $_locale ); |
||
| 25 | |||
| 26 | $protocol = is_ssl() ? 'https' : 'http'; |
||
| 27 | $origin = isset( $_SERVER['HTTP_HOST'] ) ? "$protocol://" . sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : null; |
||
| 28 | |||
| 29 | $src = sprintf( |
||
| 30 | 'https://widgets.wp.com/likes/master.html?ver=%1$s#ver=%1$s%2$s%3$s', |
||
| 31 | $version, |
||
| 32 | $likes_locale, |
||
| 33 | $origin ? '&origin=' . $origin : '' |
||
| 34 | ); |
||
| 35 | |||
| 36 | /* translators: The value of %d is not available at the time of output */ |
||
| 37 | $likersText = wp_kses( __( '<span>%d</span> bloggers like this:', 'jetpack' ), array( 'span' => array() ) ); |
||
| 38 | ?> |
||
| 39 | <iframe src='<?php echo $src; ?>' scrolling='no' id='likes-master' name='likes-master' style='display:none;'></iframe> |
||
| 40 | <div id='likes-other-gravatars'><div class="likes-text"><?php echo $likersText; ?></div><ul class="wpl-avatars sd-like-gravatars"></ul></div> |
||
| 41 | <?php |
||
| 42 | } |
||
| 43 |