Filter
uncanny-automator-pro
uap_option_ad_types
Filters the available ad types for Advanced Ads, allowing modification before they are displayed.
add_filter( 'uap_option_ad_types', $callback, 10, 1 );
Description
Fires when generating the ad type selection for Uncanny Automator's Advanced Ads integration. Developers can filter the `$option` array to modify the available ad types, their IDs, or add custom options for ad selection within Uncanny Automator recipes. This hook runs during recipe creation or editing.
Usage
add_filter( 'uap_option_ad_types', 'your_function_name', 10, 1 );
Parameters
-
$option(mixed) - This parameter contains the current value of the `$option` being filtered.
Return Value
The filtered value.
Examples
<?php
/**
* Modify the available ad types for the Advanced Ads integration.
*
* This example demonstrates how to remove a specific ad type (e.g., 'group')
* from the list of available ad types when setting up an Uncanny Automator Pro
* recipe that integrates with Advanced Ads.
*
* @param array $option The array of ad type options.
* @return array The modified array of ad type options.
*/
add_filter( 'uap_option_ad_types', 'my_custom_uap_ad_types', 10, 1 );
function my_custom_uap_ad_types( $option ) {
// Check if the 'options' key exists and is an array
if ( isset( $option['options'] ) && is_array( $option['options'] ) ) {
// Example: Remove 'group' ad type if it exists
if ( array_key_exists( 'group', $option['options'] ) ) {
unset( $option['options']['group'] );
}
// Example: Add a custom description to an existing ad type
if ( isset( $option['options']['single'] ) ) {
$option['options']['single'] = 'My Custom Single Ad Description';
}
}
return $option;
}
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
uncanny-automator-pro/src/integrations/advanced-ads/helpers/advanced-ads-pro-helpers.php:43
public function ad_types( $option_code, $is_any = false, $label = null, $tokens = array() ) {
$get_types = Advanced_Ads::get_instance()->ad_types;
$types = array();
foreach ( $get_types as $key => $type ) {
if ( false === strpos( $key, 'upgrade' ) ) {
$types[ $type->ID ] = __( $type->title, 'uncanny-automator-pro' );
}
}
if ( true === $is_any ) {
$types = array( '-1' => __( 'Any type', 'uncanny-automator' ) ) + $types;
}
$option = array(
'option_code' => $option_code,
'label' => ( empty( $label ) ) ? esc_attr__( 'Type', 'uncanny-automator' ) : $label,
'input_type' => 'select',
'required' => true,
'options_show_id' => true,
'relevant_tokens' => $tokens,
'options' => $types,
);
return apply_filters( 'uap_option_ad_types', $option );
}