rest_comment_trashable

Filters whether a comment can be trashed.

Description

apply_filters( 'rest_comment_trashable', (bool) $empty_trash_days_0, (WP_Post) $comment ); 

Return false to disable trash support for the post.

Parameters (2)

0. $empty_trash_days_0 (bool) => ( EMPTY_TRASH_DAYS > 0 )
Whether the post type support trashing.
1. $comment (WP_Post)
The comment object being considered for trashing support.

Usage

To run the hook, copy the example below.
  1. $empty_trash_days_0 = apply_filters( 'rest_comment_trashable', $empty_trash_days_0, $comment ); 
  2.  
  3. if ( !empty( $empty_trash_days_0 ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the rest_comment_trashable callback 
  2. function filter_rest_comment_trashable( $empty_trash_days_0, $comment ) { 
  3. // make filter magic happen here... 
  4. return $empty_trash_days_0
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'rest_comment_trashable', 'filter_rest_comment_trashable', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'rest_comment_trashable', 'filter_rest_comment_trashable', 10, 2 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php  
  1. $supports_trash = apply_filters( 'rest_comment_trashable', ( EMPTY_TRASH_DAYS > 0 ), $comment );