xss_register_ad($code, $name, $description, $tab = "custom", $settings = array(), $render = array())

  • $code: unique ad identifier, used to later pull the ad for display.
  • $name: name for the ad space, used only for admin side.
  • $description: description for the ad space, used only for admin side.
  • $tab: tab code where to display ad settings, used only for admin side.
  • $settings: default settings for the ad space.
  • $render: admin side rendering settings for the ad.

Register new ad space for the theme. $code must be unique to identify the ad. It’s best to use some prefix for this name to distinguish it from default ad spaces. Name and description are used to display the ad space settings on the admin side in Ads Manager. Tab is the code of the tab on the Ads Manager to display ad settings into. Default settings will be set to the ad when it’s in the reseted state. Render settings control displaying the ad on the admin side.

To make this call properly, it must be done inside the action handled function. Check example at the bottom for action usage.

$settings array contains the following elements:

  • display: type of ad display: none (ad is not active), code (full ad code), banner (normal image banner), gdac (GD Affiliate Center)
  • code: full ad code, used by Google Adsense or Amazon
  • url: url to be used with banner type of ad
  • alt: alt text for the banner image
  • gdac: filtering ads by the affiliate used with GD Affiliate Center
  • gdac_block: number of ads to get from GD Affiliate Center
  • gdac_size: ad size usid with GD Affiliate Center

$render array contains the following elements:

  • hidden: array with elements to set as hidden on admin side. These elements will use default values.

$tab can have one of the following values identifying the tab on the Ads Manager: misc, single, page, archive, custom. Default is used custom location. This has no bearing on use of ad space, only the location of settings in Ads Manager. I recommend using custom location.

Here is the typical example for registering ad. This is the simples way to do it:

[php]add_action(‘xss_register_ads’, ‘user_register_ads’);

function user_register_ads() {
xss_register_ad(‘custom_my_add_one’, ‘My Custom Ad’, ‘Just an ad example’);

Adding this to functions.php (or PHP code on Advanced tab in settings), will register one add under name ‘custom_my_add_one’. It will be displayed on the Custom tab in Ads Manager.

More complex example bellow will set ad by default to GD Affiliate Center, and will hide the size of ad for GDAC selection.

[php]add_action(‘xss_register_ads’, ‘user_register_ads’);

function user_register_ads() {
xss_register_ad(‘custom_my_add_two’, ‘My Custom Ad 2’, ‘Just an ad example’, ‘custom’, array(‘display’ => ‘gdac’), array(‘hidden’ => array(‘gdac_block’, ‘gdac_size’)));


Leave a Reply