482 | 482 | } |
483 | 483 | ); |
484 | 484 | |
485 | 485 | $banner_rtl = $banner_rtl ? array_shift( $banner_rtl ) : false; |
486 | 486 | $banner_2x_rtl = $banner_2x_rtl ? array_shift( $banner_2x_rtl ) : false; |
487 | 487 | } |
488 | 488 | |
489 | 489 | // Resolve the URLs. |
490 | 490 | $banner = $banner ? self::get_asset_url( $plugin, $banner ) : false; |
491 | 491 | $banner_2x = $banner_2x ? self::get_asset_url( $plugin, $banner_2x ) : false; |
492 | 492 | $banner_rtl = $banner_rtl ? self::get_asset_url( $plugin, $banner_rtl ) : false; |
493 | 493 | $banner_2x_rtl = $banner_2x_rtl ? self::get_asset_url( $plugin, $banner_2x_rtl ) : false; |
494 | 494 | |
495 | 495 | switch ( $output ) { |
496 | 496 | case 'html': |
497 | | $id = "plugin-banner-{$plugin->post_name}"; |
498 | | $html = "<style type='text/css'>"; |
499 | | $html .= "#{$id} { background-image: url('{$banner}'); }"; |
500 | | if ( ! empty( $banner_2x ) ) { |
501 | | $html .= "@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 120dpi) { #{$id} { background-image: url('{$banner_2x}'); } }"; |
502 | | } |
503 | | $html .= '</style>'; |
504 | | $html .= "<div class='plugin-banner' id='{$id}'></div>"; |
505 | | |
506 | | return $html; |
| 497 | return sprintf( |
| 498 | '<div class="plugin-banner" id="%1$s"><img decoding="async" fetchpriority="high" src="%2$s" %3$s %4$s></div>', |
| 499 | "plugin-banner-{$plugin->post_name}", |
| 500 | $banner, |
| 501 | ! empty( $banner_2x ) ? "srcset='$banner 772w, $banner_2x 1544w'" : '', |
| 502 | ! empty( $banner_2x ) ? 'sizes="(min-width: 900px) 1544px, 772px"' : '' |
| 503 | ); |