comment_content ) as $block ) { if ( 'activitypub/image' === $block['blockName'] && Blocks::get_image_url( $block['attrs'] ) === $url ) { return true; } } return false; } /** * Maybe clean up cached images when a comment is no longer approved. * * @param string $new_status The new comment status. * @param string $old_status The old comment status. * @param \WP_Comment $comment The comment. * * @return void */ public static function maybe_cleanup_comment( $new_status, $old_status, $comment ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- Required for action signature. if ( 'approved' !== $new_status ) { self::clear_cached_images( (int) $comment->comment_ID ); } } /** * Remove the cached images of a comment. * * Files are cached lazily, so the next render downloads them again. * * @param int $comment_id The comment ID. * * @return void */ public static function clear_cached_images( $comment_id ) { self::invalidate_entity( $comment_id ); } }