Skip to content

Latest commit

 

History

History
236 lines (123 loc) · 6.8 KB

File metadata and controls

236 lines (123 loc) · 6.8 KB

Filters and actions

This page is a reference for the hooks that Co-Authors Plus provides. It is generated by reading the source, so if you find something out of date, grep for apply_filters and do_action in the repo and please open a PR.

File paths are relative to the plugin root.

Display and formatting

coauthors_default_before

Text placed before a list of co-authors. Defaults to 'By '.

  • Type: string
  • Used in: template tags and the Co-Authors block
  • Files: template-tags.php, php/blocks/block-coauthors/class-block-coauthors.php

coauthors_default_between

Separator between co-authors (all but the last). Defaults to ', '.

coauthors_default_between_last

Separator before the final co-author. Defaults to ' and '.

coauthors_default_after

Text placed after a list of co-authors. Defaults to ''.

coauthors_posts_link

Arguments used to render a single co-author's posts-link (text, title, url). Filter the array to customise the markup emitted by coauthors_posts_links().

  • Parameters: array $args, stdClass $author
  • File: template-tags.php

coauthors_wp_list_authors_array

The ordered array of authors before coauthors_wp_list_authors() renders them. Use this to filter the listing rather than post-process the output.

  • File: template-tags.php

get_coauthors

The resolved co-authors for a post. Runs after the plugin's lookup but before any display logic.

  • Parameters: array $coauthors, int $post_id
  • File: template-tags.php

coauthors_open_graph_tags

The Open Graph tags the plugin contributes to the document head.

  • File: php/class-coauthors-plus.php

Post type and taxonomy configuration

coauthors_supported_post_types

Post types that Co-Authors Plus attaches to. Defaults to the list of registered public post types.

  • Parameters: array $post_types
  • File: php/class-coauthors-plus.php

coauthors_count_published_post_types

Post types counted towards a co-author's published post count.

  • Parameters: array $post_types (defaults to [ 'post' ])
  • Files: php/class-coauthors-plus.php (two call sites)

coauthors_default_author

The WP_User used as the default author when a post has none. Defaults to the current user.

coauthors_plus_should_query_post_author

Whether to combine the post_author column query with the taxonomy query. Returning false switches to a simpler taxonomy-only query on sites where post_author isn't reliable.

Permissions

coauthors_plus_edit_authors

Whether the current user can assign co-authors to posts. Defaults to edit_others_posts.

  • File: php/class-coauthors-plus.php

coauthors_edit_author_cap

Capability required to appear in the co-author search results. Defaults to edit_posts.

coauthors_edit_ignored_authors

Array of user logins hidden from the co-author search results.

Guest authors

coauthors_guest_authors_enabled

Whether the guest authors feature is active. Return false to disable entirely.

coauthors_guest_authors_force

Whether to force guest authors even when the feature would otherwise be skipped.

coauthors_guest_author_manage_cap

Capability required to manage guest authors. Defaults to list_users.

coauthors_guest_author_parent_page

Admin menu parent under which the Guest Authors UI appears. Defaults to users.php.

coauthors_guest_author_fields

Array of field definitions rendered on the guest author profile screen.

  • Parameters: array $fields, array $groups
  • File: php/class-coauthors-guest-authors.php

coauthors_guest_author_sortable_columns

Sortable columns in the Guest Authors list table.

coauthors_guest_author_query_args

WP_Query args used to list guest authors in the admin.

coauthors_guest_author_manage_columns

Columns shown on the Guest Authors list table.

coauthors_guest_author_row_actions

Row actions shown below each guest author in the list table.

coauthors_show_create_profile_user_link

Whether to show the "Create profile" link on user edit screens. Defaults to false.

coauthors_guest_author_personal_export_extra_data

Extra data to include when exporting a guest author's personal data (WordPress privacy tools).

coauthors_name_field_type_{$field}

Dynamic filter per name field, used to switch input types on the guest author profile form.

Meta box

coauthors_meta_box_title

Title of the Authors meta box. Defaults to Authors.

coauthors_meta_box_context

Where the meta box appears (normal, side, advanced). Defaults to side.

coauthors_meta_box_priority

Meta box priority. Defaults to high.

Blocks

coauthors_plus_support_blocks

Return false to stop Co-Authors Plus from registering its blocks. Useful when a site wants to hide them from the inserter.

  • File: php/blocks/class-blocks.php

coauthors_blocks_store_data

Server-side example data passed to block editor placeholders when no authors are loaded yet.

co-authors-plus.author-placeholder (JavaScript)

Client-side equivalent of coauthors_blocks_store_data. Applied via @wordpress/hooks.

  • File: src/blocks-store/index.js

REST API

rest_coauthors_item_schema

Schema for a single co-author resource returned by the REST controller.

  • File: php/api/endpoints/class-coauthors-controller.php

rest_prepare_coauthor

The WP_REST_Response for a single co-author, after the default preparation. Use this to add custom fields.

  • Parameters: WP_REST_Response $response, object $author, WP_REST_Request $request

JavaScript filters (@wordpress/hooks)

coAuthors.formatAuthorData.label

Label for an author option in the sidebar autocomplete. Defaults to "{displayName} | {email}".

  • Parameters: string $label, object $author
  • File: src/utils.js

coAuthors.search.threshold

Number of characters before the sidebar autocomplete begins searching. Defaults to 2.

  • File: src/components/co-authors/index.jsx

Actions

cap_guest_author_create

Fires after a guest author is created via the admin UI.

  • File: php/class-coauthors-guest-authors.php

cap_guest_author_del

Fires after a guest author is deleted.

coauthors_guest_author_custom_columns

Fires while rendering a custom column for a guest author row.

  • Parameters: string $column_name, int $author_id
  • File: php/class-coauthors-wp-list-table.php

Deprecated

coauthors_post_list_pluck_field

Deprecated in 4.0 when triggered from a REST save. Use the set_object_terms action on the author taxonomy instead. See Upgrading to 4.0.

coauthors_post_get_coauthor_by_field

Deprecated in 4.0 when triggered from a REST save. Same replacement as above.