Filter
uncanny-automator-pro
uap_option_all_elementor_popups
Filters all Elementor popups for customization before they are displayed.
add_filter( 'uap_option_all_elementor_popups', $callback, 10, 1 );
Description
Filters the list of available Elementor popup options. Developers can use this hook to modify or add to the array of Elementor popups that Uncanny Automator can trigger, offering custom popup selections for automations.
Usage
add_filter( 'uap_option_all_elementor_popups', 'your_function_name', 10, 1 );
Parameters
-
$option(mixed) - This parameter represents the dropdown option being filtered.
Return Value
The filtered value.
Examples
<?php
/**
* Filter to modify the list of Elementor popups available in Uncanny Automator.
*
* This example demonstrates how to conditionally remove a specific Elementor popup
* from the list if it's marked as "deprecated".
*
* @param array $option The array containing the Elementor popups.
* @return array The modified array of Elementor popups.
*/
add_filter( 'uap_option_all_elementor_popups', 'my_custom_remove_deprecated_elementor_popup', 10, 1 );
function my_custom_remove_deprecated_elementor_popup( $option ) {
// Check if the $option is structured as expected and contains 'options'.
if ( ! isset( $option['options'] ) || ! is_array( $option['options'] ) ) {
return $option;
}
$updated_options = [];
foreach ( $option['options'] as $popup_id => $popup_data ) {
// Assuming popup_data is an array and contains a key 'deprecated' which is a boolean.
// This is a hypothetical structure based on the filter's context.
if ( isset( $popup_data['deprecated'] ) && true === $popup_data['deprecated'] ) {
// Skip adding this popup to the updated list if it's deprecated.
continue;
}
$updated_options[$popup_id] = $popup_data;
}
// Update the options array in the original $option.
$option['options'] = $updated_options;
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/elementor/helpers/elementor-pro-helpers.php:184
public function all_elementor_popups( $label = null, $option_code = 'ELEMPOPUPS', $args = array() ) {
if ( ! $label ) {
$label = esc_attr__( 'Popup', 'uncanny-automator-pro' );
}
$any_option = key_exists( 'any_option', $args ) ? $args['any_option'] : false;
$args = array(
'post_type' => 'elementor_library',
'posts_per_page' => 999,
'orderby' => 'title',
'order' => 'ASC',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => '_elementor_template_type',
'value' => 'popup',
'compare' => '=',
),
),
);
$options = Automator()->helpers->recipe->options->wp_query( $args, $any_option, esc_attr__( 'Any popup', 'uncanny-automator-pro' ) );
$option = array(
'option_code' => $option_code,
'label' => $label,
'input_type' => 'select',
'required' => true,
'options' => $options,
'relevant_tokens' => array(
$option_code => esc_attr__( 'Popup title', 'uncanny-automator-pro' ),
),
);
return apply_filters( 'uap_option_all_elementor_popups', $option );
}