create(); } /** * Validate the object. * * @param bool $valid The validation state. * @param string $param The object parameter. * @param \WP_REST_Request $request The request object. * * @return bool The validation state: true if valid, false if not. */ public static function validate_object( $valid, $param, $request ) { $json_params = $request->get_json_params(); if ( isset( $json_params['object']['type'] ) && 'Event' === $json_params['object']['type'] ) { $valid = true; } if ( empty( $json_params['type'] ) ) { return false; } if ( 'Create' !== $json_params['type'] || is_wp_error( $request ) ) { return $valid; } $object = $json_params['object']; if ( ! is_array( $object ) ) { return false; } $required = array( 'id', ); if ( array_intersect( $required, array_keys( $object ) ) !== $required ) { return false; } return $valid; } }