Filter uncanny-automator

automator_review_get_completed_recipe_count

Filters the total count of completed recipes for the Automator plugin.

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

Description

Filters the count of completed recipes before it's returned. Developers can modify this number to display custom counts, perhaps excluding specific recipe types or statuses, for review prompts. The original count is passed for reference.


Usage

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

Parameters

$this (mixed)
This parameter contains the total count of completed recipes, cast as an absolute integer.

Return Value

The filtered value.


Examples

add_filter( 'automator_review_get_completed_recipe_count', 'my_custom_completed_recipes_filter', 10, 2 );

/**
 * Custom filter to adjust the completed recipe count for the Automator review.
 *
 * This example demonstrates how to conditionally increase the reported completed
 * recipe count if a specific user role is detected. This could be used for
 * testing or to highlight specific content during internal reviews.
 *
 * @param int $count The original count of completed recipes.
 * @param Automator_Review $this_object The instance of the Automator_Review class.
 * @return int The potentially modified count of completed recipes.
 */
function my_custom_completed_recipes_filter( $count, $this_object ) {
    // Check if the current user is an administrator.
    if ( current_user_can( 'manage_options' ) ) {
        // For administrators, let's artificially inflate the count by 5.
        // This is purely for demonstration purposes.
        $count = $count + 5;
    }

    // Always return the count, whether modified or not.
    return $count;
}

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/admin/class-automator-review.php:1072

public function get_completed_recipes_count() {

		return apply_filters( 'automator_review_get_completed_recipe_count', absint( Automator()->get->completed_recipes_count() ), $this );
	}


Scroll to Top