Automator_Get_Data::maybe_get_recipe_id( $id )


Parameters Parameters

$id

(Required)


Top ↑

Return Return

(int)


Source Source

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

	public function maybe_get_recipe_id( $id ) {
		if ( is_object( $id ) ) {
			$id = isset( $id->ID ) ? $id->ID : null;
		}

		if ( is_null( $id ) || ! is_numeric( $id ) ) {
			return 0;
		}

		$allowed_post_types = apply_filters(
			'automator_allowed_post_types',
			array(
				'uo-recipe',
				'uo-trigger',
				'uo-action',
				'uo-closure',
			)
		);

		$post = get_post( $id );

		if ( $post instanceof \WP_Post && 'uo-recipe' === $post->post_type ) {
			return absint( $post->ID );
		}

		if ( $post instanceof \WP_Post && in_array( $post->post_type, $allowed_post_types, true ) ) {
			return absint( $post->post_parent );
		}

		return 0;
	}