ID ); // A moderator who approves their own request knows about it. if ( $submitter && get_current_user_id() !== $submitter && Subscriptions::enabled() && Subscriptions::is_following( $post->ID, $submitter ) ) { Queue::schedule( time(), self::HOOK, [ $post->ID ] ); } } /** * Sends the email, unless the request was unpublished or the submitter stopped following it meanwhile. * * @param int $request_id Request ID. */ public static function send( int $request_id ): void { $request = get_post( $request_id ); $submitter = self::submitter( $request_id ); $subscription = $submitter ? SubscriptionRepository::find( $request_id, $submitter ) : null; if ( ! $request || 'publish' !== $request->post_status || ! $subscription || ! Subscriptions::enabled() ) { return; } Mailer::send( $subscription, 'request-approved', static function ( WP_Post $request ): array { return [ 'subject' => sprintf( /* translators: 1: site name, 2: request title. */ __( '[%1$s] Your feature request was approved: %2$s', 'feature-request-system' ), Mailer::plain( (string) get_bloginfo( 'name' ) ), Mailer::plain( $request->post_title ) ), 'args' => [], ]; } ); } /** * Returns the ID of the user who suggested a request, or 0. * * @param int $request_id Request ID. */ private static function submitter( int $request_id ): int { return (int) get_post_meta( $request_id, RequestPostType::META_SUBMITTER_ID, true ); } }