Filter hook 'rest_comment_trashable'

in WP Core File wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php at line 980

View Source

rest_comment_trashable

Filter Hook
Description
Filters whether a comment can be trashed via the REST API. Return false to disable trash support for the comment.

Hook Information

File Location wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php View on GitHub
Hook Type Filter
Line Number 980

Hook Parameters

Type Name Description
bool $supports_trash Whether the comment supports trashing.
WP_Comment $comment The comment object being considered for trashing support.

Usage Examples

Basic Usage
<?php
// Hook into rest_comment_trashable
add_filter('rest_comment_trashable', 'my_custom_filter', 10, 2);

function my_custom_filter($supports_trash, $comment) {
    // Your custom filtering logic here
    return $supports_trash;
}

Source Code Context

wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php:980 - How this hook is used in WordPress core
<?php
 975  		 * @since 4.7.0
 976  		 *
 977  		 * @param bool       $supports_trash Whether the comment supports trashing.
 978  		 * @param WP_Comment $comment        The comment object being considered for trashing support.
 979  		 */
 980  		$supports_trash = apply_filters( 'rest_comment_trashable', ( EMPTY_TRASH_DAYS > 0 ), $comment );
 981  
 982  		$request->set_param( 'context', 'edit' );
 983  
 984  		if ( $force ) {
 985  			$previous = $this->prepare_item_for_response( $comment, $request );

PHP Documentation

<?php
/**
		 * Filters whether a comment can be trashed via the REST API.
		 *
		 * Return false to disable trash support for the comment.
		 *
		 * @since 4.7.0
		 *
		 * @param bool       $supports_trash Whether the comment supports trashing.
		 * @param WP_Comment $comment        The comment object being considered for trashing support.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
Related Hooks

Related hooks will be displayed here in future updates.