MP_Addon_API::validate_lead( int $param, WP_REST_Request $request, string $key )

Validate leadID parameter.


Parameters Parameters

$param

(int) (Required) param

$request

(WP_REST_Request) (Required) request

$key

(string) (Required) key


Top ↑

Return Return

(bool|WP_Error)


Top ↑

Source Source

File: calculator-API-add-on/inc/MP_Addon_API.php

	public function validate_lead( $param, $request, $key ) {

		if ( $request->get_method() === 'GET' ) {
			if ( get_post( $param ) && get_post_type( $param ) === MortgagePlatform::$lead ) {

				return is_numeric( $param );

			} else {
				return new \WP_Error( 'rest_no_leads', esc_html__( 'No found lead with ID ', 'CalculatorsAPIAddon' ) . $param, array( 'status' => 404 ) );
			}
		} else {
			return is_string( $param );

		}
	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.