Skip to main content

GravityKit\GravityCalendar\Abilities\Refusal

Builds the WP_Error an ability returns, with an HTTP status and a next step in the message.

The reader is an AI model with only the message to go on, so every refusal says what was wrong, what the valid answers are, and which tool to call next. Tool names are written the way the model sees them (gc_calendar_get).

WordPress flattens a permission-callback error to ability_invalid_permissions, so advice for a refused permission goes in the ability's description.

Since: TBD

Source: includes/abilities/Refusal.php:26

Details​

  • Kind: class
  • Namespace: GravityKit\GravityCalendar\Abilities

Methods​

MethodDescription
forbidden()The account may not do this.
conflict()The thing exists, and its current state blocks the request.
not_found()The thing named does not exist.
invalid()The input is well formed and wrong.
invalid_value()A setting or argument value that is not allowed: "param: what was wrong. Valid values: a, b. Call X for details."
show_value()One stored value, shown so the text around it cannot be mistaken for part of it.
list_values()Values as one readable list, cut at {@see self::LIST_LIMIT} with a count of the rest.
advice()What an agent can do about an error the calendar's own code returned, keyed by error code.
for_error()One error with this surface's next step appended once, and an HTTP status attached unless it has one.

Method Reference​

forbidden()​

public static function forbidden( string $code, string $message ): WP_Error

The account may not do this.

Parameters​

NameTypeDefaultDescription
$codestringError code, gk_gravitycalendar_*.
$messagestringWhat is missing and where to see or change it.

Returns​

Since: TBD

Source: includes/abilities/Refusal.php:102

conflict()​

public static function conflict( string $code, string $message, array $extra=[] ): WP_Error

The thing exists, and its current state blocks the request.

Parameters​

NameTypeDefaultDescription
$codestringError code.
$messagestringWhat state blocks the request and which tool changes it.
$extraarray[]Merged into the error data.

Returns​

Since: TBD

Source: includes/abilities/Refusal.php:117

not_found()​

public static function not_found( string $code, string $message, array $extra=[] ): WP_Error

The thing named does not exist.

Parameters​

NameTypeDefaultDescription
$codestringError code.
$messagestringWhat was not found and which tool lists what exists.
$extraarray[]Merged into the error data.

Returns​

Since: TBD

Source: includes/abilities/Refusal.php:132

invalid()​

public static function invalid( string $code, string $message, array $extra=[] ): WP_Error

The input is well formed and wrong.

Parameters​

NameTypeDefaultDescription
$codestringError code.
$messagestringWhat was wrong and how to fix it.
$extraarray[]Merged into the error data.

Returns​

Since: TBD

Source: includes/abilities/Refusal.php:147

invalid_value()​

public static function invalid_value( string $param, string $problem, array $valid=[], string $rule='', $tool_slug='' ): WP_Error

A setting or argument value that is not allowed: "param: what was wrong. Valid values: a, b. Call X for details."

The code is invalid_setting; the data holds setting and valid.

Parameters​

NameTypeDefaultDescription
$paramstringThe dotted path of the input, e.g. settings.layout.
$problemstringWhat was wrong, without a trailing period.
$validarray[]The values that would have been accepted. Empty when the rule is not a list.
$rulestring''Used instead of a list when the allowed values are a rule.
$tool_slugstring | string[]''Ability slug(s) whose tool shows the valid values, or ''.

Returns​

Since: TBD

Source: includes/abilities/Refusal.php:166

show_value()​

public static function show_value( $value ): string

One stored value, shown so the text around it cannot be mistaken for part of it.

A plain value goes in backticks. A value holding a backtick, quote, backslash or anything outside printable ASCII could end the backticks and read as the plugin's own words, so it is shown as a JSON string instead.

Parameters​

NameTypeDefaultDescription
$valuemixedA scalar.

Returns​

  • string

Since: TBD

Source: includes/abilities/Refusal.php:209

list_values()​

public static function list_values( array $values ): string

Values as one readable list, cut at {@see self::LIST_LIMIT} with a count of the rest.

Parameters​

NameTypeDefaultDescription
$valuesarrayScalars. Anything else is skipped.

Returns​

  • string — e.g. "current, past, future".

Since: TBD

Source: includes/abilities/Refusal.php:225

advice()​

public static function advice(): array

What an agent can do about an error the calendar's own code returned, keyed by error code.

The codes are the ones GravityView_Calendar_Ajax refuses an event edit with.

Returns​

  • array<string, — string>

Since: TBD

Source: includes/abilities/Refusal.php:248

for_error()​

public static function for_error( WP_Error $error, int $status=self::INVALID ): WP_Error

One error with this surface's next step appended once, and an HTTP status attached unless it has one.

Parameters​

NameTypeDefaultDescription
$errorWP_ErrorThe error the calendar's code returned.
$statusintself::INVALIDThe status to attach when the error has none.

Returns​

Since: TBD

Source: includes/abilities/Refusal.php:317