ID, self::VOTERS_SHOWN ); $votes = $voters['user_votes'] + $voters['guest_votes']; printf( '
%s
', /* translators: %s: number of votes. */ esc_html( sprintf( _n( '%s vote', '%s votes', $votes, 'feature-request-system' ), number_format_i18n( $votes ) ) ) ); if ( $voters['users'] ) { echo '' . esc_html( implode( ', ', $more ) ) . '
'; } $followers = SubscriptionRepository::count( $post->ID ); if ( $followers ) { printf( '%s
', /* translators: %s: number of users who follow the request. */ esc_html( sprintf( _n( '%s follower', '%s followers', $followers, 'feature-request-system' ), number_format_i18n( $followers ) ) ) ); } $submitter = self::submitter( $post->ID ); if ( '' !== $submitter ) { /* translators: %s: name of the person who submitted the request, with their email if they gave one. */ printf( '' . esc_html__( 'Submitted by %s', 'feature-request-system' ) . '
', $submitter ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in submitter(). } if ( get_post_meta( $post->ID, RequestPostType::META_FLAGGED_AS_SPAM, true ) ) { echo '' . esc_html__( 'A spam check flagged this request, so it was held for review.', 'feature-request-system' ) . '
'; } } /** * Returns a user's name, linked to their profile for those who may edit it. * * @param int $user_id User ID. */ private static function user( int $user_id ): string { $user = get_userdata( $user_id ); if ( ! $user ) { return esc_html__( 'A user who has since been deleted', 'feature-request-system' ); } $link = get_edit_user_link( $user_id ); return $link ? sprintf( '%2$s', esc_url( $link ), esc_html( $user->display_name ) ) : esc_html( $user->display_name ); } /** * Returns who submitted a request from the front end, or '' for a request written in the admin. * * @param int $request_id Request ID. */ private static function submitter( int $request_id ): string { $user_id = (int) get_post_meta( $request_id, RequestPostType::META_SUBMITTER_ID, true ); if ( $user_id ) { return self::user( $user_id ); } $name = (string) get_post_meta( $request_id, RequestPostType::META_SUBMITTER_NAME, true ); $email = sanitize_email( (string) get_post_meta( $request_id, RequestPostType::META_SUBMITTER_EMAIL, true ) ); $parts = array_filter( [ esc_html( $name ), $email ? sprintf( '%2$s', esc_url( 'mailto:' . $email ), esc_html( $email ) ) : '', ] ); return implode( ', ', $parts ); } }