Filter uncanny-automator

automator_get_recipes_data_limit

Filters the maximum number of recipes retrieved by the Automator.

add_filter( 'automator_get_recipes_data_limit', $callback, 10, 1 );

Description

Filters the maximum number of recipes retrieved by the get_recipes_data function. Developers can use this to override the default limit of 9999, allowing for fetching more or fewer recipes in bulk operations. This filter fires when retrieving multiple recipes.


Usage

add_filter( 'automator_get_recipes_data_limit', 'your_function_name', 10, 1 );

Return Value

The filtered value.


Examples

<?php
/**
 * Example of filtering the 'automator_get_recipes_data_limit' hook.
 * This example reduces the default limit of 9999 to 50, which might be useful
 * for performance testing or if you only expect a small number of recipes.
 */
add_filter( 'automator_get_recipes_data_limit', function( $limit ) {
    // Check if the current limit is greater than our desired maximum.
    // This prevents accidentally setting a higher limit than intended if another plugin
    // already modified it to be less than 50.
    if ( $limit > 50 ) {
        return 50; // Set the new limit to 50 recipes.
    }
    return $limit; // Otherwise, return the existing limit.
}, 10, 1 ); // Priority 10, accepts 1 argument.

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/core/lib/class-automator-functions.php:823

if ( null !== $recipe_id && is_numeric( $recipe_id ) ) {
			return $this->get_recipe_data_by_recipe_id( $recipe_id, $force_new_data_load );
		}

		global $wpdb;

		$recipe_limit = (int) apply_filters( 'automator_get_recipes_data_limit', 9999 );

		$recipes = $wpdb->get_results(
			$wpdb->prepare(
				"SELECT ID, post_title, post_type, post_status, post_parent
					FROM $wpdb->posts
					WHERE post_type = %s
					AND post_status NOT LIKE %s

Scroll to Top