| @@ -1,0 +1,50 @@ | ||
| 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 | +} | |