| Conditions | 5 |
| Paths | 4 |
| Total Lines | 29 |
| Lines | 6 |
| Ratio | 20.69 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | public static function get_srcset( $post_id, $widget_name ) { |
||
| 15 | |||
| 16 | $srcset = array(); |
||
| 17 | $medium = get_the_post_thumbnail_url( $post_id, 'medium' ); |
||
| 18 | $large = get_the_post_thumbnail_url( $post_id, 'large' ); |
||
| 19 | |||
| 20 | View Code Duplication | if ( $medium && $width = self::get_image_width( $post_id, 'medium' ) ) { |
|
|
|
|||
| 21 | $srcset[] = $medium . ' ' . $width . 'w'; |
||
| 22 | } |
||
| 23 | |||
| 24 | View Code Duplication | if ( $large && $width = self::get_image_width( $post_id, 'large' ) ) { |
|
| 25 | $srcset[] = $large . ' ' . $width . 'w'; |
||
| 26 | } |
||
| 27 | |||
| 28 | $srcset_string = join( ",", $srcset ); |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Filter name: wordlift_${widget_name}_thumbnail_srcset |
||
| 32 | * Filters the srcset string supplied to widgets for each post. |
||
| 33 | * |
||
| 34 | * @param $srcset_string string The srcset string |
||
| 35 | * |
||
| 36 | * @since 3.28.0 |
||
| 37 | */ |
||
| 38 | $srcset_string = apply_filters( "wordlift_${widget_name}_thumbnail_srcset", $srcset_string ); |
||
| 39 | |||
| 40 | return $srcset_string; |
||
| 41 | |||
| 42 | } |
||
| 43 | |||
| 59 | } |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.