BuddyPress::notification_new_comment( integer $item_id, integer $secondary_item_id, integer $total_items, string $format, integer $id )

Description #

Format comments notifications.

Parameters #

  • $item_id
    integer (Required) Item id.
  • $secondary_item_id
    integer (Required) Secondary item.
  • $total_items
    integer (Required) Total items.
  • $format
    string (Required) Notification type.
  • $id
    integer (Required) Notification id.

Changelog #

VersionDescription
4.1.8Introduced.

Source #

File: addons/buddypress/buddypress.php

	private function notification_new_comment( $item_id, $secondary_item_id, $total_items, $format, $id ) {
		$comment = get_comment( $item_id );
		$post    = get_post( $comment->comment_post_ID );
		$link    = get_comment_link( $comment );
		$author  = get_comment_author( $comment );
		$type    = 'question' ===	$post->post_type ? __( 'question', 'anspress-question-answer' ) : __( 'answer', 'anspress-question-answer' );

		$title   = substr( strip_tags( $post->post_title ), 0, 35 ) . ( strlen( $post->post_title ) > 35 ? '...' : '' );

		if ( 'string' === $format ) {
			if ( (int) $total_items > 1 ) {
				return '<a href="' . esc_url( $link ) . '">' . sprintf( __( '%1$d comments on your %3$s - %2$s', 'anspress-question-answer' ), (int) $total_items, $title, $type ) . '</a>';
			}

			return '<a href="' . esc_url( $link ) . '">' . sprintf( __( '%1$s commented on your %3$s - %2$s', 'anspress-question-answer' ), $author, $title, $type ) . '</a>';
		}

		return array(
			'link' => $link,
			'text' => $title,
		);
	}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment