WordPress at Your Fingertips
function is not described

WC_Webhook::is_valid_resource() private WC 3.6.0

Checks the resource for this webhook is valid e.g. valid post status.

{} It's a method of the class: WC_Webhook{}

No Hooks.

Return

true|false. True if validation passes.

Usage

// private - for code of main (parent) class only
$result = $this->is_valid_resource( $arg );
$arg(mixed) (required)
First hook argument.

Changelog

Since 3.6.0 Introduced.

Code of WC_Webhook::is_valid_resource() WC 6.1.1

private function is_valid_resource( $arg ) {
	$resource = $this->get_resource();

	if ( in_array( $resource, array( 'order', 'product', 'coupon' ), true ) ) {
		$status = get_post_status( absint( $arg ) );

		// Ignore auto drafts for all resources.
		if ( in_array( $status, array( 'auto-draft', 'new' ), true ) ) {
			return false;
		}

		// Ignore standard drafts for orders.
		if ( 'order' === $resource && 'draft' === $status ) {
			return false;
		}

		// Check registered order types for order types args.
		if ( 'order' === $resource && ! in_array( get_post_type( absint( $arg ) ), wc_get_order_types( 'order-webhooks' ), true ) ) {
			return false;
		}
	}
	return true;
}