PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.7
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.7
16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 All 506 releases
jetpack / modules / wordads / php / class-wordads-formats.php

class-wordads-formats.php in Jetpack – WP Security, Backup, Speed, & Growth 16.3-a.7, at modules/wordads/php/class-wordads-formats.php

51 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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