/**
  * If note has an email to send, and the user has the right caps, send it
  *
  * @since 1.17
  *
  * @param false|object $note If note was created, object. Otherwise, false.
  * @param array $entry Entry data
  * @param array $data $_POST data
  *
  * @return void Tap in to Gravity Forms' `gform_after_email` action if you want a return result from sending the email.
  */
 private function maybe_send_entry_notes($note = false, $entry, $data)
 {
     if (!$note || !GVCommon::has_cap('gravityview_email_entry_notes')) {
         do_action('gravityview_log_debug', __METHOD__ . ': User doesnt have "gravityview_email_entry_notes" cap, or $note is empty', $note);
         return;
     }
     do_action('gravityview_log_debug', __METHOD__ . ': $data', $data);
     //emailing notes if configured
     if (!empty($data['gv-note-to'])) {
         $default_data = array('gv-note-to' => '', 'gv-note-to-custom' => '', 'gv-note-subject' => '', 'gv-note-content' => '');
         $current_user = wp_get_current_user();
         $email_data = wp_parse_args($data, $default_data);
         $from = $current_user->user_email;
         $to = $email_data['gv-note-to'];
         /**
          * Documented in get_note_email_fields
          * @see get_note_email_fields
          */
         $include_custom = apply_filters('gravityview/field/notes/custom-email', true);
         if ('custom' === $to && $include_custom) {
             $to = $email_data['gv-note-to-custom'];
             do_action('gravityview_log_debug', __METHOD__ . ': Sending note to a custom email address: ' . $to);
         }
         if (!is_email($to)) {
             do_action('gravityview_log_error', __METHOD__ . ': $to not a valid email address: ' . $to, $email_data);
             return;
         }
         $bcc = false;
         $reply_to = $from;
         $subject = trim($email_data['gv-note-subject']);
         // We use empty() here because GF uses empty to check against, too. `0` isn't a valid subject to GF
         $subject = empty($subject) ? self::strings('default-email-subject') : $subject;
         $message = $email_data['gv-note-content'];
         $from_name = $current_user->display_name;
         $message_format = 'html';
         /**
          * @filter `gravityview/field/notes/email_content` Modify the values passed when sending a note email
          * @see GVCommon::send_email
          * @since 1.17
          * @param[in,out] array $email_settings Values being passed to the GVCommon::send_email() method: 'from', 'to', 'bcc', 'reply_to', 'subject', 'message', 'from_name', 'message_format', 'entry'
          */
         $email_content = apply_filters('gravityview/field/notes/email_content', compact('from', 'to', 'bcc', 'reply_to', 'subject', 'message', 'from_name', 'message_format', 'entry'));
         extract($email_content);
         GVCommon::send_email($from, $to, $bcc, $reply_to, $subject, $message, $from_name, $message_format, '', $entry, false);
         $form = isset($entry['form_id']) ? GFAPI::get_form($entry['form_id']) : array();
         /**
          * @see https://www.gravityhelp.com/documentation/article/10146-2/ It's here for compatibility with Gravity Forms
          */
         do_action('gform_post_send_entry_note', __METHOD__, $to, $from, $subject, $message, $form, $entry);
     }
 }