automator_select_all_posts_limit
Filters the maximum number of posts retrieved by the Advanced Ads integration for the Automator plugin.
add_filter( 'automator_select_all_posts_limit', $callback, 10, 1 );
Description
Filters the maximum number of posts to retrieve and the post types to include when fetching all posts. Useful for controlling the scope of post selections in automations, especially for integrations like Advanced Ads. Defaults to 999 posts of type 'post'.
Usage
add_filter( 'automator_select_all_posts_limit', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Example of how to use the 'automator_select_all_posts_limit' filter.
* This example limits the number of posts fetched to 100,
* overriding the default of 999 for 'post' post types.
*/
add_filter( 'automator_select_all_posts_limit', function( $limit, $post_type ) {
// Only apply this limit to the 'post' post type.
if ( 'post' === $post_type ) {
return 100; // Set a custom limit of 100 posts.
}
// For any other post type, return the original limit.
return $limit;
}, 10, 2 ); // Priority 10, accepts 2 arguments.
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
src/integrations/advanced-ads/helpers/advanced-ads-helpers.php:28
src/integrations/thrive-quiz-builder/helpers/thrive-quiz-builder-helpers.php:39
src/integrations/wp/helpers/wp-helpers.php:167
src/integrations/wpcode/helpers/wpcode-helpers.php:34
uncanny-automator-pro/src/integrations/memberpress/helpers/memberpress-pro-helpers.php:277
public function get_all_ads( $option_code, $is_any = false, $all_option = false, $label = null ) {
$options = array();
$args = array(
// phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_posts_per_page
'posts_per_page' => apply_filters( 'automator_select_all_posts_limit', 999, 'post' ),
'orderby' => 'title',
'order' => 'DESC',
'post_type' => 'advanced_ads',
'post_status' => array( 'publish', 'draft' ),
);
if ( true === $all_option ) {
$all_ads = Automator()->helpers->recipe->options->wp_query( $args, $all_option, esc_html__( 'All ads', 'uncanny-automator' ) );
} else {
$all_ads = Automator()->helpers->recipe->options->wp_query( $args, $is_any, esc_html__( 'Any ad', 'uncanny-automator' ) );
}
foreach ( $all_ads as $ad_id => $title ) {
if ( empty( $title ) ) {
// translators: 1: Ad ID
$title = sprintf( esc_attr__( 'ID: %1$s (no title)', 'uncanny-automator' ), $ad_id );
}
$options[ $ad_id ] = $title;
}
if ( $label === null ) {
$label = esc_attr__( 'Ad', 'uncanny-automator' );
}
$option = array(
'input_type' => 'select',
'option_code' => $option_code,
/* translators: HTTP request method */
'label' => $label,
'required' => true,
'supports_custom_value' => true,
'relevant_tokens' => array(),
'options' => $options,
);
return apply_filters( 'uap_option_get_all_ads', $option );
}