You are here

public static function SearchAdBase::adsenseAdFormats in Google AdSense integration 8

This is the array that holds all ad formats.

All it has is a multi-dimensional array indexed by a key, containing the ad type and the description.

To add a new code:

  • Make sure the key is not in use by a different format
  • Go to Google AdSense . Get the dimensions . Get the description

Parameters

string $key: Ad key for which the format is needed (optional).

Return value

array if no key is provided: array of supported ad formats as an array (type, description). if a key is provided, the array containing the ad format for that key, or NULL if there is no ad with that key.

Overrides AdsenseAdInterface::adsenseAdFormats

File

src/SearchAdBase.php, line 305

Class

SearchAdBase
Base class for search AdsenseAd plugins.

Namespace

Drupal\adsense

Code

public static function adsenseAdFormats($key = NULL) {
  $ads = [
    'Search Box' => [
      'desc' => t('Search Box'),
    ],
    'Search Box v2' => [
      'desc' => t('Search Box v2'),
    ],
  ];
  if (!empty($key)) {
    return array_key_exists($key, $ads) ? $ads[$key] : NULL;
  }
  else {
    return $ads;
  }
}