Automator_Utilities::recipe_max_times_completed( null $recipe_id = null,  $completed_times )


Parameters Parameters

$recipe_id

(null) (Optional)

Default value: null

$completed_times

(Required)


Top ↑

Return Return

(bool)


Source Source

File: src/core/lib/utilities/class-automator-utilities.php

	public function recipe_max_times_completed( $recipe_id = null, $completed_times = 0 ) {
		if ( is_null( $recipe_id ) ) {
			return false;
		}

		$post_meta = get_post_meta( $recipe_id, 'recipe_max_completions_allowed', true );
		if ( empty( $post_meta ) ) {
			$completions_allowed = '-1';
			// Make sure that the recipe has recipe_completions_allowed saved. @version 3.0
			update_post_meta( $recipe_id, 'recipe_max_completions_allowed', $completions_allowed );
		} else {
			$completions_allowed = $post_meta;
		}

		$return = false;

		if ( intval( '-1' ) === intval( $completions_allowed ) ) {
			$return = false;
		} elseif ( (int) $completed_times >= (int) $completions_allowed ) {
			$return = true;
		}

		return $return;
	}