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

Description #

Format answer 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_answer( $item_id, $secondary_item_id, $total_items, $format, $id ) {
		$post   = get_post( $item_id );
		$link   = get_permalink( $post );
		$author = bp_core_get_user_displayname( $secondary_item_id );
		$title  = substr( wp_strip_all_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(
					// translators: First placeholder is total count and second is question title.
					__( '%1$d answers on your question - %2$s', 'anspress-question-answer' ),
					(int) $total_items,
					$title
				) . '</a>';
			}

			// translators: First placeholder is total count and second is question title.
			return '<a href="' . esc_url( $link ) . '">' . sprintf( __( '%1$s answered on your question - %2$s', 'anspress-question-answer' ), $author, $title ) . '</a>';
		}

		return array(
			'link' => $link,
			// translators: placeholder contains question title.
			'text' => sprintf( __( 'New answer on %s', 'anspress-question-answer' ), $title ),
		);
	}

Leave a Reply

Your email address will not be published.

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

Add your comment