Conditions | 13 |
Paths | 128 |
Total Lines | 21 |
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 |
||
89 | function twentynineteen_override_post_thumbnail( $width ) { |
||
90 | $options = get_theme_support( 'jetpack-content-options' ); |
||
91 | $featured_images = ( ! empty( $options[0]['featured-images'] ) ) ? $options[0]['featured-images'] : null; |
||
92 | |||
93 | $settings = array( |
||
94 | 'post-default' => ( isset( $featured_images['post-default'] ) && false === $featured_images['post-default'] ) ? '' : 1, |
||
95 | 'page-default' => ( isset( $featured_images['page-default'] ) && false === $featured_images['page-default'] ) ? '' : 1, |
||
96 | ); |
||
97 | |||
98 | $settings = array_merge( $settings, array( |
||
99 | 'post-option' => get_option( 'jetpack_content_featured_images_post', $settings['post-default'] ), |
||
100 | 'page-option' => get_option( 'jetpack_content_featured_images_page', $settings['page-default'] ), |
||
101 | ) ); |
||
102 | |||
103 | if ( ( ! $settings['post-option'] && is_single() ) |
||
104 | || ( ! $settings['page-option'] && is_singular() && is_page() ) ) { |
||
105 | return false; |
||
106 | } else { |
||
107 | return ! post_password_required() && ! is_attachment() && has_post_thumbnail(); |
||
108 | } |
||
109 | } |
||
110 | add_filter( 'twentynineteen_can_show_post_thumbnail', 'twentynineteen_override_post_thumbnail', 10, 2 ); |
||
111 |