jpkcom_gutenberg_img_alt_abilities_enabled()
Decide whether the ability should be registered at all.
jpkcom_gutenberg_img_alt_abilities_enabled() : bool
-
since
-
1.1.0
Return values
bool
—
True when registration should proceed.
jpkcom_gutenberg_img_alt_ability_log()
Write a debug line, and only with WP_DEBUG.
jpkcom_gutenberg_img_alt_ability_log(string $message) : void
Parameters
-
$message
: string
-
-
since
-
1.1.0
jpkcom_gutenberg_img_alt_ability_error()
Build a WP_Error carrying an HTTP status.
jpkcom_gutenberg_img_alt_ability_error(string $code, string $message[, int $status = 400 ]) : WP_Error
Without data['status'] rest_ensure_response() defaults to 500, and a 5xx
tells an agent "transient fault, retry unchanged" - the opposite of what a
caller mistake needs to hear.
Parameters
-
$code
: string
-
-
$message
: string
-
-
$status
: int
= 400
-
-
since
-
1.1.0
jpkcom_gutenberg_img_alt_ability_boundary()
Turn a Throwable out of the callback into a WP_Error.
jpkcom_gutenberg_img_alt_ability_boundary(callable $body, string $ability) : array<string, mixed>|WP_Error
Parameters
-
$body
: callable
-
-
$ability
: string
-
-
since
-
1.1.0
Return values
array<string, mixed>|WP_Error
—
jpkcom_gutenberg_img_alt_ability_capability()
Check the capability required to run the ability.
jpkcom_gutenberg_img_alt_ability_capability(string $ability) : bool
upload_files, NOT read like the sibling content plugins. Those publish
content the site already shows to visitors; this enumerates the media
library, where file names and unattached uploads are editorial internals.
The capability that means "works with media" is the honest gate, and it
excludes subscribers.
Parameters
-
$ability
: string
-
-
since
-
1.1.0
Return values
bool
—
True when the current user may run it.
Build the meta array for the ability.
jpkcom_gutenberg_img_alt_ability_meta(string $ability) : array<string, mixed>
All three annotations explicit: they default to null and the REST run
controller derives the HTTP verb from them, so without readonly the run
route would be POST-only.
Parameters
-
$ability
: string
-
-
since
-
1.1.0
Return values
array<string, mixed>
—
Bring the value core hands the callback into array form.
jpkcom_gutenberg_img_alt_ability_normalise_input(mixed $input) : array<string, mixed>|null
normalize_input() substitutes the schema's top-level default when the input
is exactly null, and that default is a stdClass - so the callback receives
an object and must read it. A callback that only accepts an array answers
400 to the most obvious call it has.
Parameters
-
$input
: mixed
-
-
since
-
1.1.0
Return values
array<string, mixed>|null
—
Array form, or null when unusable.
Refuse a top-level input key the ability does not declare.
jpkcom_gutenberg_img_alt_ability_validate_input_keys(array<string, mixed> $input, array<string|int, string> $allowed) : true|WP_Error
Parameters
-
$input
: array<string, mixed>
-
-
$allowed
: array<string|int, string>
-
-
since
-
1.1.0
Return values
true|WP_Error
—
True when every key is declared.
jpkcom_gutenberg_img_alt_would_inject()
Would this plugin's filter inject an alt attribute for this stored value?
jpkcom_gutenberg_img_alt_would_inject(mixed $stored) : bool
THE load-bearing function of this file, and deliberately not a paraphrase
of the rule. The filter gates on ! empty( $alt ) and the replacer then
returns the block unchanged when '' === trim( $alt ). Two consequences
follow that a reasonable-looking check would get wrong:
- An alt of the single character "0" is EMPTY to PHP, so nothing is
injected. A check for
$alt !== '' would call that image supplied.
- An alt of only spaces passes
! empty() but is stopped by the trim in
the replacer. A check that mirrored only the first gate would call that
image supplied too.
Reporting an image as fine when the mechanism has nothing to inject for it
is the one answer this ability must never give, because it is the answer
that stops someone looking.
Parameters
-
$stored
: mixed
-
-
since
-
1.1.0
Return values
bool
—
True when the filter would inject.
jpkcom_gutenberg_img_alt_ability_reason()
Name why the filter would inject nothing, so a fixer knows what is there.
jpkcom_gutenberg_img_alt_ability_reason(mixed $stored, bool $row_found) : string
Parameters
-
$stored
: mixed
-
-
$row_found
: bool
-
Whether a meta row exists at all.
-
since
-
1.1.0
Return values
string
—
One of no_row, empty, zero, whitespace_only.
jpkcom_gutenberg_img_alt_ability_permission()
Permission callback.
jpkcom_gutenberg_img_alt_ability_permission([mixed $input = null ]) : bool
Parameters
-
$input
: mixed
= null
-
-
since
-
1.1.0
Return values
bool
—
True when the current user may run the ability.
jpkcom_gutenberg_img_alt_ability_list_inner()
List the image attachments the filter would find nothing to inject for.
jpkcom_gutenberg_img_alt_ability_list_inner([mixed $input = null ]) : array<string, mixed>|WP_Error
Queried with one statement rather than by walking the library in PHP: the
predicate needs TRIM(), which no meta_query comparison expresses, and a
page-by-page PHP filter would make total a guess.
Parameters
-
$input
: mixed
= null
-
-
since
-
1.1.0
Return values
array<string, mixed>|WP_Error
—
jpkcom_gutenberg_img_alt_ability_list()
Execute callback.
jpkcom_gutenberg_img_alt_ability_list([mixed $input = null ]) : array<string, mixed>|WP_Error
Parameters
-
$input
: mixed
= null
-
-
since
-
1.1.0
Return values
array<string, mixed>|WP_Error
—
jpkcom_gutenberg_img_alt_get_ability_definitions()
Build the registration arguments.
jpkcom_gutenberg_img_alt_get_ability_definitions() : array<string, array<string, mixed>>
Reads no WordPress state and touches no registry, which is what lets the CI
harness assert the shape without a WordPress installation.
-
since
-
1.1.0
Return values
array<string, array<string, mixed>>
—
Ability name => registration args.
jpkcom_gutenberg_img_alt_register_ability_category()
Register the category, unless something already did.
jpkcom_gutenberg_img_alt_register_ability_category() : void
-
since
-
1.1.0
jpkcom_gutenberg_img_alt_register_abilities()
Register the ability.
jpkcom_gutenberg_img_alt_register_abilities() : void
wp_register_ability() returns null on EVERY failure path and reports only
through _doing_it_wrong(), which is silent in production - and so is the
debug log without WP_DEBUG.
-
since
-
1.1.0
jpkcom_gutenberg_img_alt_replace_alt_attribute()
jpkcom_gutenberg_img_alt_replace_alt_attribute(string $block_content, string $alt) : string
Parameters
-
$block_content
: string
-
-
$alt
: string
-