networks
5 years ago
class-wordads-admin.php
7 months ago
class-wordads-api.php
7 months ago
class-wordads-array-utils.php
7 months ago
class-wordads-california-privacy.php
6 months ago
class-wordads-ccpa-do-not-sell-link-widget.php
7 months ago
class-wordads-consent-management-provider.php
6 months ago
class-wordads-cron.php
7 months ago
class-wordads-formats.php
7 months ago
class-wordads-params.php
7 months ago
class-wordads-shortcode.php
7 months ago
class-wordads-sidebar-widget.php
7 months ago
class-wordads-smart.php
2 weeks ago
class-wordads-formats.php
51 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WordAds Formats Class file. |
| 4 | * |
| 5 | * This file contains the definition of the WordAds_Formats class, which handles |
| 6 | * determining the appropriate WordAds format slug based on ad slot dimensions. |
| 7 | * |
| 8 | * @package automattic/jetpack |
| 9 | */ |
| 10 | |
| 11 | declare( strict_types = 1 ); |
| 12 | |
| 13 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | exit( 0 ); |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * Class WordAds_Formats |
| 19 | * |
| 20 | * Set of WordAds methods working with formats and Ad dimensions. |
| 21 | */ |
| 22 | class WordAds_Formats { |
| 23 | /** |
| 24 | * Determine the WordAds format based on the ad dimensions. |
| 25 | * |
| 26 | * @param int $width The width of the ad slot. |
| 27 | * @param int $height The height of the ad slot. |
| 28 | * |
| 29 | * @return string WordAds Format enum. |
| 30 | */ |
| 31 | public static function get_format_slug( int $width, int $height ): string { |
| 32 | if ( $width === 300 && $height === 250 ) { |
| 33 | return 'gutenberg_rectangle'; |
| 34 | } |
| 35 | |
| 36 | if ( $width === 728 && $height === 90 ) { |
| 37 | return 'gutenberg_leaderboard'; |
| 38 | } |
| 39 | |
| 40 | if ( $width === 320 && $height === 50 ) { |
| 41 | return 'gutenberg_mobile_leaderboard'; |
| 42 | } |
| 43 | |
| 44 | if ( $width === 160 && $height === 600 ) { |
| 45 | return 'gutenberg_skyscraper'; |
| 46 | } |
| 47 | |
| 48 | return ''; |
| 49 | } |
| 50 | } |
| 51 |