Make WordPress Core


Ignore:
Timestamp:
12/11/2025 01:53:26 AM (3 months ago)
Author:
westonruter
Message:

Export: Update export_wp() to handle get_comment() returning null due to filter.

The get_comment filter now explicitly documents returning null in addition to a WP_Comment object. This allows the filter to be used to exclude comments from an export. The get_comment() function already supported returning null.

Developed in https://github.com/WordPress/wordpress-develop/pull/8383

Props abcd95, WPExplorer, desrosj, mukesh27, westonruter, SirLouen, lbones, mdibrahimk48, audrasjb, jorbin, wildworks, hellofromTonya, saurabh.dhariwal, mabfahad.
Fixes #61244.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment.php

    r61336 r61369  
    241241     * @since 2.3.0
    242242     *
    243      * @param WP_Comment $_comment Comment data.
     243     * @param WP_Comment|null $_comment Comment data.
    244244     */
    245245    $_comment = apply_filters( 'get_comment', $_comment );
     246    if ( ! ( $_comment instanceof WP_Comment ) ) {
     247        return null;
     248    }
    246249
    247250    if ( OBJECT === $output ) {
Note: See TracChangeset for help on using the changeset viewer.