| Conditions | 5 |
| Paths | 3 |
| Total Lines | 72 |
| 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 |
||
| 103 | function jetpack_the_site_logo() { |
||
| 104 | $size = site_logo()->theme_size(); |
||
| 105 | |||
| 106 | // If no logo is set, but we're in the Customizer, leave a placeholder (needed for the live preview). |
||
| 107 | if ( |
||
| 108 | ! jetpack_has_site_logo() |
||
| 109 | && jetpack_is_customize_preview() |
||
| 110 | ) { |
||
| 111 | /* |
||
| 112 | * Reason: the output is escaped in the sprintf. |
||
| 113 | * phpcs:disable WordPress.Security.EscapeOutput |
||
| 114 | */ |
||
| 115 | /** This filter is documented in modules/theme-tools/site-logo/inc/functions.php */ |
||
| 116 | echo apply_filters( |
||
| 117 | 'jetpack_the_site_logo', |
||
| 118 | sprintf( |
||
| 119 | '<a href="%1$s" class="site-logo-link" style="display:none;"><img class="site-logo" data-size="%2$s" /></a>', |
||
| 120 | esc_url( home_url( '/' ) ), |
||
| 121 | esc_attr( $size ) |
||
| 122 | ), |
||
| 123 | array(), |
||
| 124 | $size |
||
| 125 | ); |
||
| 126 | /* phpcs:enable WordPress.Security.EscapeOutput */ |
||
| 127 | return; |
||
| 128 | } |
||
| 129 | |||
| 130 | // Check for WP 4.5 Site Logo and Jetpack logo. |
||
| 131 | $logo_id = get_theme_mod( 'custom_logo' ); |
||
| 132 | $jetpack_logo = site_logo()->logo; |
||
| 133 | |||
| 134 | // Use WP Core logo if present, otherwise use Jetpack's. |
||
| 135 | if ( ! $logo_id && isset( $jetpack_logo['id'] ) ) { |
||
| 136 | $logo_id = $jetpack_logo['id']; |
||
| 137 | } |
||
| 138 | |||
| 139 | /* |
||
| 140 | * Reason: the output is escaped in the sprintf. |
||
| 141 | * phpcs:disable WordPress.Security.EscapeOutput |
||
| 142 | */ |
||
| 143 | /** |
||
| 144 | * Filter the Site Logo output. |
||
| 145 | * |
||
| 146 | * @module theme-tools |
||
| 147 | * |
||
| 148 | * @since 3.2.0 |
||
| 149 | * |
||
| 150 | * @param string $html Site Logo HTML output. |
||
| 151 | * @param array $jetpack_logo Array of Site Logo details. |
||
| 152 | * @param string $size Size specified in add_theme_support declaration, or 'thumbnail' default. |
||
| 153 | */ |
||
| 154 | echo apply_filters( |
||
| 155 | 'jetpack_the_site_logo', |
||
| 156 | sprintf( |
||
| 157 | '<a href="%1$s" class="site-logo-link" rel="home" itemprop="url">%2$s</a>', |
||
| 158 | esc_url( home_url( '/' ) ), |
||
| 159 | wp_get_attachment_image( |
||
| 160 | $logo_id, |
||
| 161 | $size, |
||
| 162 | false, |
||
| 163 | array( |
||
| 164 | 'class' => "site-logo attachment-$size", |
||
| 165 | 'data-size' => $size, |
||
| 166 | 'itemprop' => 'logo', |
||
| 167 | ) |
||
| 168 | ) |
||
| 169 | ), |
||
| 170 | $jetpack_logo, |
||
| 171 | $size |
||
| 172 | ); |
||
| 173 | /* phpcs:enable WordPress.Security.EscapeOutput */ |
||
| 174 | } |
||
| 175 | |||
| 200 |