Skip to content

Commit

Permalink
Start documenting some of the callbacks.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbillion committed Oct 5, 2024
1 parent c3f988d commit 464f53c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
14 changes: 13 additions & 1 deletion src/register_meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ class register_meta extends Shared\Base {
public $default;

/**
* A function or method to call when sanitizing `$meta_key` data.
* A function or method to call when sanitizing the meta value.
*
* The callback is called via one of:
*
* - The https://developer.wordpress.org/reference/hooks/sanitize_object_type_meta_meta_key_for_object_subtype/ filter
* - The https://developer.wordpress.org/reference/hooks/sanitize_object_type_meta_meta_key/ filter
*
* @var callable
* @phpstan-var (callable(mixed,string,string,string): mixed)|(callable(mixed,string,string): mixed)
Expand All @@ -65,6 +70,11 @@ class register_meta extends Shared\Base {
/**
* A function or method to call when performing `edit_post_meta`, `add_post_meta`, and `delete_post_meta` capability checks.
*
* The callback is called via one of:
*
* - The https://developer.wordpress.org/reference/hooks/auth_object_type_meta_meta_key_for_object_subtype/ filter
* - The https://developer.wordpress.org/reference/hooks/auth_object_type_meta_meta_key/ filter
*
* @var callable
* @phpstan-var (callable(bool,string,string,string): bool)|(callable(bool,string,string): bool)
*/
Expand All @@ -75,6 +85,8 @@ class register_meta extends Shared\Base {
*
* A custom post type must also declare support for custom fields for registered meta to be accessible via REST. When registering complex meta values this argument may optionally be an array with 'schema' or 'prepare_callback' keys instead of a boolean.
*
* If this value is an array with a prepare_callback key, the callback is called here: https://github.com/WordPress/wordpress-develop/blob/6.6.0/src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php#L127
*
* @var bool|array<string, mixed>
* @phpstan-var bool|array{
* schema: array<string,mixed>,
Expand Down
2 changes: 1 addition & 1 deletion src/register_post_type.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class register_post_type extends Shared\Base {
*
* Do `remove_meta_box()` and `add_meta_box()` calls in the callback.
*
* Default null.
* The callback is called via the https://developer.wordpress.org/reference/hooks/add_meta_boxes_post_type/ action.
*
* @var callable
* @phpstan-var callable(\WP_Post): void
Expand Down
6 changes: 5 additions & 1 deletion src/register_rest_field.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ class register_rest_field extends Shared\Base {
*
* Default is 'null', the field will not be returned in the response. The function will be passed the prepared object data.
*
* The callback is called here: https://github.com/WordPress/wordpress-develop/blob/6.6.0/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php#L434-L440
*
* @var callable
* @phpstan-var callable(mixed[],string,\WP_REST_Request): mixed
* @phpstan-var callable(mixed[],string,\WP_REST_Request,string): mixed
*/
public $get_callback;

Expand All @@ -25,6 +27,8 @@ class register_rest_field extends Shared\Base {
*
* Default is 'null', the value cannot be set or updated. The function will be passed the model object, like `WP_Post`.
*
* The callback is called here: https://github.com/WordPress/wordpress-develop/blob/6.6.0/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php#L468-L475
*
* @var callable
* @phpstan-var callable(mixed,object,string,\WP_REST_Request,string): mixed
*/
Expand Down
2 changes: 2 additions & 0 deletions src/register_setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class register_setting extends Shared\Base {
/**
* A callback function that sanitizes the option's value.
*
* The callback is called via the https://developer.wordpress.org/reference/hooks/sanitize_option_option/ filter.
*
* @var callable
* @phpstan-var callable(mixed,string,mixed):mixed
*/
Expand Down
2 changes: 2 additions & 0 deletions src/register_taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ class register_taxonomy extends Shared\Base {
/**
* Provide a callback function for the meta box display. If not set, `post_categories_meta_box()` is used for hierarchical taxonomies, and `post_tags_meta_box()` is used for non-hierarchical. If false, no meta box is shown.
*
* The callback is called in `do_meta_boxes()`: https://github.com/WordPress/wordpress-develop/blob/6.6.0/src/wp-admin/includes/template.php#L1456
*
* @var false|callable
* @phpstan-var false|callable(\WP_Post,mixed[]): void
*/
Expand Down

0 comments on commit 464f53c

Please sign in to comment.