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; } else { return $valid; } if ( empty( $json_params['type'] ) ) { return false; } if ( 'Create' !== $json_params['type'] || 'Update' !== $json_params['type'] || is_wp_error( $request ) ) { return $valid; } $object = $json_params['object']; if ( ! is_array( $object ) ) { return false; } $required = array( 'id', ); // Limit this as a safety measure. add_filter( 'wp_revisions_to_keep', array( 'revisions_to_keep' ) ); if ( array_intersect( $required, array_keys( $object ) ) !== $required ) { return false; } return $valid; } /** * Return the number of revisions to keep. * * @return int The number of revisions to keep. */ public static function revisions_to_keep() { return 3; } }