PHP code example of shortlist-digital / agreable-advert-plugin

1. Go to this page and download the library: Download shortlist-digital/agreable-advert-plugin library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

shortlist-digital / agreable-advert-plugin example snippets


<!-- Twig function -->
{{ get_advert_data(post, 'horizontal', [{'pos': 'top'}]) }}

<!-- Outputs -->
{
  'type': 'horizontal',
  'key-values': [{'pos': 'top'}],
  'devices': {
    'desktop': {
      'creative-sizes': [[970, 250], [728, 90]]
    }, 
    'tablet': {
      'creative-sizes': [[728, 90]]
    }, 
    'mobile': {
      'creative-sizes': [[320, 50]]
    }
  }
}

$advert_data = AgreableAdvertPlugin\Services\AdvertSlotGenerator::get_advert_data($post, 'horizontal', ['pos' => 'top']);
var_dump($advert_data);
// Outputs
{
  'type': 'horizontal',
  'key-values': [{'pos': 'top'}],
  'devices': {
    'desktop': {
      'creative-sizes': [[970, 250], [728, 90]]
    }, 
    'tablet': {
      'creative-sizes': [[728, 90]]
    }, 
    'mobile': {
      'creative-sizes': [[320, 50]]
    }
  }
}

/advert/{post_id}/{post_type}/{key_values}
/advert/2074/horizontal/pos=top,another_key=value

{
  'type': 'in-article (tbc)',
  'key-values': [{'pos': 'top|2'}],
  'devices': {
    'desktop': {
      'creative-sizes': [[300, 600], [300, 250]]
    }, 
    'tablet': {
      'creative-sizes': [[300, 600], [300, 250]]
    }, 
    'mobile': {
      'creative-sizes': [[300, 250]]
    }
  }
}