JPKCom Disable Comments

Documentation

Table of Contents

Packages

JPKComDisableComments
JPKComDisableCommentsGitUpdate

Namespaces

JPKComDisableCommentsGitUpdate

Constants

JPKCOM_DISABLE_COMMENTS_VERSION  : mixed = '1.0.9'

Functions

jpkcom_disable_comments_close_rest_status()  : mixed
Report comments and pings as closed in a REST post response.

Constants

Functions

jpkcom_disable_comments_close_rest_status()

Report comments and pings as closed in a REST post response.

jpkcom_disable_comments_close_rest_status(mixed $response) : mixed

Removing post type support is not enough for post, page and attachment: WP_REST_Posts_Controller::get_item_schema() carries a hardcoded $fixed_schemas list for those three in which comments is always present - the post_type_supports() check applies only to other post types. The schema therefore keeps comment_status and ping_status, and the response kept reporting the stored value, typically open, on a site that refuses comments.

The fields are rewritten rather than removed, so the block editor and any other consumer keep the response shape they expect.

A REST write can still store comment_status: open - the schema stays writable - but the value is inert: comments_open is filtered to false, and this filter reports the field as closed regardless.

Parameters
$response : mixed

Prepared response, a WP_REST_Response in practice.

Tags
since
1.0.9
Return values
mixed

The response with both status fields set to closed.

Search results