Passed
Push — master ( 3d874b...853cd9 )
by Brian
05:42
created
includes/class-wpinv-notes.php 2 patches
Indentation   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -12,202 +12,202 @@
 block discarded – undo
12 12
  */
13 13
 class WPInv_Notes {
14 14
 
15
-	/**
16
-	 * Class constructor.
17
-	 */
18
-	public function __construct() {
19
-
20
-		// Filter inovice notes.
21
-		add_action( 'pre_get_comments', array( $this, 'set_invoice_note_type' ), 11, 1 );
22
-		add_action( 'comment_feed_where', array( $this, 'wpinv_comment_feed_where' ), 10, 1 );
23
-
24
-		// Delete comments count cache whenever there is a new comment or a comment status changes.
25
-		add_action( 'wp_insert_comment', array( $this, 'delete_comments_count_cache' ) );
26
-		add_action( 'wp_set_comment_status', array( $this, 'delete_comments_count_cache' ) );
27
-
28
-		// Count comments.
29
-		add_filter( 'wp_count_comments', array( $this, 'wp_count_comments' ), 100, 2 );
30
-
31
-		// Fires after notes are loaded.
32
-		do_action( 'wpinv_notes_init', $this );
33
-	}
34
-
35
-	/**
36
-	 * Filters invoice notes query to only include our notes.
37
-	 *
38
-	 * @param WP_Comment_Query $query
39
-	 */
40
-	public function set_invoice_note_type( $query ) {
41
-		$post_id = ! empty( $query->query_vars['post_ID'] ) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
42
-
43
-		if ( $post_id && getpaid_is_invoice_post_type( get_post_type( $post_id ) ) ) {
44
-			$query->query_vars['type'] = 'wpinv_note';
45
-		} else {
46
-
47
-			if ( empty( $query->query_vars['type__not_in'] ) ) {
48
-				$query->query_vars['type__not_in'] = array();
49
-			}
50
-
51
-			$query->query_vars['type__not_in'] = wpinv_parse_list( $query->query_vars['type__not_in'] );
52
-			$query->query_vars['type__not_in'] = array_merge( array( 'wpinv_note' ), $query->query_vars['type__not_in'] );
53
-		}
54
-
55
-		return $query;
56
-	}
57
-
58
-	/**
59
-	 * Exclude notes from the comments feed.
60
-	 */
61
-	function wpinv_comment_feed_where( $where ){
62
-		return $where . ( $where ? ' AND ' : '' ) . " comment_type != 'wpinv_note' ";
63
-	}
64
-
65
-	/**
66
-	 * Delete comments count cache whenever there is
67
-	 * new comment or the status of a comment changes. Cache
68
-	 * will be regenerated next time WPInv_Notes::wp_count_comments()
69
-	 * is called.
70
-	 */
71
-	public function delete_comments_count_cache() {
72
-		delete_transient( 'getpaid_count_comments' );
73
-	}
74
-
75
-	/**
76
-	 * Remove invoice notes from wp_count_comments().
77
-	 *
78
-	 * @since  2.2
79
-	 * @param  object $stats   Comment stats.
80
-	 * @param  int    $post_id Post ID.
81
-	 * @return object
82
-	 */
83
-	public function wp_count_comments( $stats, $post_id ) {
84
-		global $wpdb;
85
-
86
-		if ( empty( $post_id ) ) {
87
-			$stats = get_transient( 'getpaid_count_comments' );
88
-
89
-			if ( ! $stats ) {
90
-				$stats = array(
91
-					'total_comments' => 0,
92
-					'all'            => 0,
93
-				);
94
-
95
-				$count = $wpdb->get_results(
96
-					"
15
+    /**
16
+     * Class constructor.
17
+     */
18
+    public function __construct() {
19
+
20
+        // Filter inovice notes.
21
+        add_action( 'pre_get_comments', array( $this, 'set_invoice_note_type' ), 11, 1 );
22
+        add_action( 'comment_feed_where', array( $this, 'wpinv_comment_feed_where' ), 10, 1 );
23
+
24
+        // Delete comments count cache whenever there is a new comment or a comment status changes.
25
+        add_action( 'wp_insert_comment', array( $this, 'delete_comments_count_cache' ) );
26
+        add_action( 'wp_set_comment_status', array( $this, 'delete_comments_count_cache' ) );
27
+
28
+        // Count comments.
29
+        add_filter( 'wp_count_comments', array( $this, 'wp_count_comments' ), 100, 2 );
30
+
31
+        // Fires after notes are loaded.
32
+        do_action( 'wpinv_notes_init', $this );
33
+    }
34
+
35
+    /**
36
+     * Filters invoice notes query to only include our notes.
37
+     *
38
+     * @param WP_Comment_Query $query
39
+     */
40
+    public function set_invoice_note_type( $query ) {
41
+        $post_id = ! empty( $query->query_vars['post_ID'] ) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
42
+
43
+        if ( $post_id && getpaid_is_invoice_post_type( get_post_type( $post_id ) ) ) {
44
+            $query->query_vars['type'] = 'wpinv_note';
45
+        } else {
46
+
47
+            if ( empty( $query->query_vars['type__not_in'] ) ) {
48
+                $query->query_vars['type__not_in'] = array();
49
+            }
50
+
51
+            $query->query_vars['type__not_in'] = wpinv_parse_list( $query->query_vars['type__not_in'] );
52
+            $query->query_vars['type__not_in'] = array_merge( array( 'wpinv_note' ), $query->query_vars['type__not_in'] );
53
+        }
54
+
55
+        return $query;
56
+    }
57
+
58
+    /**
59
+     * Exclude notes from the comments feed.
60
+     */
61
+    function wpinv_comment_feed_where( $where ){
62
+        return $where . ( $where ? ' AND ' : '' ) . " comment_type != 'wpinv_note' ";
63
+    }
64
+
65
+    /**
66
+     * Delete comments count cache whenever there is
67
+     * new comment or the status of a comment changes. Cache
68
+     * will be regenerated next time WPInv_Notes::wp_count_comments()
69
+     * is called.
70
+     */
71
+    public function delete_comments_count_cache() {
72
+        delete_transient( 'getpaid_count_comments' );
73
+    }
74
+
75
+    /**
76
+     * Remove invoice notes from wp_count_comments().
77
+     *
78
+     * @since  2.2
79
+     * @param  object $stats   Comment stats.
80
+     * @param  int    $post_id Post ID.
81
+     * @return object
82
+     */
83
+    public function wp_count_comments( $stats, $post_id ) {
84
+        global $wpdb;
85
+
86
+        if ( empty( $post_id ) ) {
87
+            $stats = get_transient( 'getpaid_count_comments' );
88
+
89
+            if ( ! $stats ) {
90
+                $stats = array(
91
+                    'total_comments' => 0,
92
+                    'all'            => 0,
93
+                );
94
+
95
+                $count = $wpdb->get_results(
96
+                    "
97 97
 					SELECT comment_approved, COUNT(*) AS num_comments
98 98
 					FROM {$wpdb->comments}
99 99
 					WHERE comment_type NOT IN ('action_log', 'order_note', 'webhook_delivery', 'wpinv_note')
100 100
 					GROUP BY comment_approved
101 101
 					",
102
-					ARRAY_A
103
-				);
104
-
105
-				$approved = array(
106
-					'0'            => 'moderated',
107
-					'1'            => 'approved',
108
-					'spam'         => 'spam',
109
-					'trash'        => 'trash',
110
-					'post-trashed' => 'post-trashed',
111
-				);
112
-
113
-				foreach ( (array) $count as $row ) {
114
-					// Don't count post-trashed toward totals.
115
-					if ( ! in_array( $row['comment_approved'], array( 'post-trashed', 'trash', 'spam' ), true ) ) {
116
-						$stats['all']            += $row['num_comments'];
117
-						$stats['total_comments'] += $row['num_comments'];
118
-					} elseif ( ! in_array( $row['comment_approved'], array( 'post-trashed', 'trash' ), true ) ) {
119
-						$stats['total_comments'] += $row['num_comments'];
120
-					}
121
-					if ( isset( $approved[ $row['comment_approved'] ] ) ) {
122
-						$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
123
-					}
124
-				}
125
-
126
-				foreach ( $approved as $key ) {
127
-					if ( empty( $stats[ $key ] ) ) {
128
-						$stats[ $key ] = 0;
129
-					}
130
-				}
131
-
132
-				$stats = (object) $stats;
133
-				set_transient( 'getpaid_count_comments', $stats );
134
-			}
135
-
136
-		}
137
-
138
-		return $stats;
139
-	}
140
-
141
-	/**
142
-	 * Returns an array of invoice notes.
143
-	 *
144
-	 * @param int $invoice_id The invoice ID whose notes to retrieve.
145
-	 * @param string $type Optional. Pass in customer to only return customer notes.
146
-	 * @return WP_Comment[]
147
-	 */
148
-	public function get_invoice_notes( $invoice_id = 0, $type = 'all' ) {
149
-
150
-		// Default comment args.
151
-		$args = array(
152
-			'post_id'   => $invoice_id,
153
-			'orderby'   => 'comment_ID',
154
-			'order'     => 'ASC',
155
-		);
156
-
157
-		// Maybe only show customer comments.
158
-		if ( $type == 'customer' ) {
159
-			$args['meta_key']   = '_wpi_customer_note';
160
-			$args['meta_value'] = 1;
161
-		}
162
-
163
-		$args = apply_filters( 'wpinv_invoice_notes_args', $args, $this, $invoice_id, $type );
164
-
165
-		return get_comments( $args );
166
-	}
167
-
168
-	/**
169
-	 * Saves an invoice comment.
170
-	 * 
171
-	 * @param WPInv_Invoice $invoice The invoice to add the comment to.
172
-	 * @param string $note The note content.
173
-	 * @param string $note_author The name of the author of the note.
174
-	 * @param bool $for_customer Whether or not this comment is meant to be sent to the customer.
175
-	 * @return int|false The new note's ID on success, false on failure.
176
-	 */
177
-	function add_invoice_note( $invoice, $note, $note_author, $author_email, $for_customer = false ){
178
-
179
-		do_action( 'wpinv_pre_insert_invoice_note', $invoice->get_id(), $note, $for_customer );
180
-
181
-		/**
182
-		 * Insert the comment.
183
-		 */
184
-		$note_id = wp_insert_comment(
185
-			wp_filter_comment(
186
-				array(
187
-					'comment_post_ID'      => $invoice->get_id(),
188
-					'comment_content'      => $note,
189
-					'comment_agent'        => 'Invoicing',
190
-					'user_id'              => get_current_user_id(),
191
-					'comment_author'       => $note_author,
192
-					'comment_author_IP'    => wpinv_get_ip(),
193
-					'comment_author_email' => $author_email,
194
-					'comment_author_url'   => $invoice->get_view_url(),
195
-					'comment_type'         => 'wpinv_note',
196
-				)
197
-			)
198
-		);
199
-
200
-		do_action( 'wpinv_insert_payment_note', $note_id, $invoice->get_id(), $note, $for_customer );
201
-
202
-		// Are we notifying the customer?
203
-		if ( empty( $note_id ) || empty( $for_customer ) ) {
204
-			return $note_id;
205
-		}
206
-
207
-		add_comment_meta( $note_id, '_wpi_customer_note', 1 );
208
-		do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $invoice->get_id(), 'user_note' => $note ) );
209
-		do_action( 'getpaid_new_customer_note', $invoice, $note );
210
-		return $note_id;
211
-	}
102
+                    ARRAY_A
103
+                );
104
+
105
+                $approved = array(
106
+                    '0'            => 'moderated',
107
+                    '1'            => 'approved',
108
+                    'spam'         => 'spam',
109
+                    'trash'        => 'trash',
110
+                    'post-trashed' => 'post-trashed',
111
+                );
112
+
113
+                foreach ( (array) $count as $row ) {
114
+                    // Don't count post-trashed toward totals.
115
+                    if ( ! in_array( $row['comment_approved'], array( 'post-trashed', 'trash', 'spam' ), true ) ) {
116
+                        $stats['all']            += $row['num_comments'];
117
+                        $stats['total_comments'] += $row['num_comments'];
118
+                    } elseif ( ! in_array( $row['comment_approved'], array( 'post-trashed', 'trash' ), true ) ) {
119
+                        $stats['total_comments'] += $row['num_comments'];
120
+                    }
121
+                    if ( isset( $approved[ $row['comment_approved'] ] ) ) {
122
+                        $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
123
+                    }
124
+                }
125
+
126
+                foreach ( $approved as $key ) {
127
+                    if ( empty( $stats[ $key ] ) ) {
128
+                        $stats[ $key ] = 0;
129
+                    }
130
+                }
131
+
132
+                $stats = (object) $stats;
133
+                set_transient( 'getpaid_count_comments', $stats );
134
+            }
135
+
136
+        }
137
+
138
+        return $stats;
139
+    }
140
+
141
+    /**
142
+     * Returns an array of invoice notes.
143
+     *
144
+     * @param int $invoice_id The invoice ID whose notes to retrieve.
145
+     * @param string $type Optional. Pass in customer to only return customer notes.
146
+     * @return WP_Comment[]
147
+     */
148
+    public function get_invoice_notes( $invoice_id = 0, $type = 'all' ) {
149
+
150
+        // Default comment args.
151
+        $args = array(
152
+            'post_id'   => $invoice_id,
153
+            'orderby'   => 'comment_ID',
154
+            'order'     => 'ASC',
155
+        );
156
+
157
+        // Maybe only show customer comments.
158
+        if ( $type == 'customer' ) {
159
+            $args['meta_key']   = '_wpi_customer_note';
160
+            $args['meta_value'] = 1;
161
+        }
162
+
163
+        $args = apply_filters( 'wpinv_invoice_notes_args', $args, $this, $invoice_id, $type );
164
+
165
+        return get_comments( $args );
166
+    }
167
+
168
+    /**
169
+     * Saves an invoice comment.
170
+     * 
171
+     * @param WPInv_Invoice $invoice The invoice to add the comment to.
172
+     * @param string $note The note content.
173
+     * @param string $note_author The name of the author of the note.
174
+     * @param bool $for_customer Whether or not this comment is meant to be sent to the customer.
175
+     * @return int|false The new note's ID on success, false on failure.
176
+     */
177
+    function add_invoice_note( $invoice, $note, $note_author, $author_email, $for_customer = false ){
178
+
179
+        do_action( 'wpinv_pre_insert_invoice_note', $invoice->get_id(), $note, $for_customer );
180
+
181
+        /**
182
+         * Insert the comment.
183
+         */
184
+        $note_id = wp_insert_comment(
185
+            wp_filter_comment(
186
+                array(
187
+                    'comment_post_ID'      => $invoice->get_id(),
188
+                    'comment_content'      => $note,
189
+                    'comment_agent'        => 'Invoicing',
190
+                    'user_id'              => get_current_user_id(),
191
+                    'comment_author'       => $note_author,
192
+                    'comment_author_IP'    => wpinv_get_ip(),
193
+                    'comment_author_email' => $author_email,
194
+                    'comment_author_url'   => $invoice->get_view_url(),
195
+                    'comment_type'         => 'wpinv_note',
196
+                )
197
+            )
198
+        );
199
+
200
+        do_action( 'wpinv_insert_payment_note', $note_id, $invoice->get_id(), $note, $for_customer );
201
+
202
+        // Are we notifying the customer?
203
+        if ( empty( $note_id ) || empty( $for_customer ) ) {
204
+            return $note_id;
205
+        }
206
+
207
+        add_comment_meta( $note_id, '_wpi_customer_note', 1 );
208
+        do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $invoice->get_id(), 'user_note' => $note ) );
209
+        do_action( 'getpaid_new_customer_note', $invoice, $note );
210
+        return $note_id;
211
+    }
212 212
 
213 213
 }
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Handles invoice notes.
@@ -18,18 +18,18 @@  discard block
 block discarded – undo
18 18
 	public function __construct() {
19 19
 
20 20
 		// Filter inovice notes.
21
-		add_action( 'pre_get_comments', array( $this, 'set_invoice_note_type' ), 11, 1 );
22
-		add_action( 'comment_feed_where', array( $this, 'wpinv_comment_feed_where' ), 10, 1 );
21
+		add_action('pre_get_comments', array($this, 'set_invoice_note_type'), 11, 1);
22
+		add_action('comment_feed_where', array($this, 'wpinv_comment_feed_where'), 10, 1);
23 23
 
24 24
 		// Delete comments count cache whenever there is a new comment or a comment status changes.
25
-		add_action( 'wp_insert_comment', array( $this, 'delete_comments_count_cache' ) );
26
-		add_action( 'wp_set_comment_status', array( $this, 'delete_comments_count_cache' ) );
25
+		add_action('wp_insert_comment', array($this, 'delete_comments_count_cache'));
26
+		add_action('wp_set_comment_status', array($this, 'delete_comments_count_cache'));
27 27
 
28 28
 		// Count comments.
29
-		add_filter( 'wp_count_comments', array( $this, 'wp_count_comments' ), 100, 2 );
29
+		add_filter('wp_count_comments', array($this, 'wp_count_comments'), 100, 2);
30 30
 
31 31
 		// Fires after notes are loaded.
32
-		do_action( 'wpinv_notes_init', $this );
32
+		do_action('wpinv_notes_init', $this);
33 33
 	}
34 34
 
35 35
 	/**
@@ -37,19 +37,19 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @param WP_Comment_Query $query
39 39
 	 */
40
-	public function set_invoice_note_type( $query ) {
41
-		$post_id = ! empty( $query->query_vars['post_ID'] ) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
40
+	public function set_invoice_note_type($query) {
41
+		$post_id = !empty($query->query_vars['post_ID']) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
42 42
 
43
-		if ( $post_id && getpaid_is_invoice_post_type( get_post_type( $post_id ) ) ) {
43
+		if ($post_id && getpaid_is_invoice_post_type(get_post_type($post_id))) {
44 44
 			$query->query_vars['type'] = 'wpinv_note';
45 45
 		} else {
46 46
 
47
-			if ( empty( $query->query_vars['type__not_in'] ) ) {
47
+			if (empty($query->query_vars['type__not_in'])) {
48 48
 				$query->query_vars['type__not_in'] = array();
49 49
 			}
50 50
 
51
-			$query->query_vars['type__not_in'] = wpinv_parse_list( $query->query_vars['type__not_in'] );
52
-			$query->query_vars['type__not_in'] = array_merge( array( 'wpinv_note' ), $query->query_vars['type__not_in'] );
51
+			$query->query_vars['type__not_in'] = wpinv_parse_list($query->query_vars['type__not_in']);
52
+			$query->query_vars['type__not_in'] = array_merge(array('wpinv_note'), $query->query_vars['type__not_in']);
53 53
 		}
54 54
 
55 55
 		return $query;
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 	/**
59 59
 	 * Exclude notes from the comments feed.
60 60
 	 */
61
-	function wpinv_comment_feed_where( $where ){
62
-		return $where . ( $where ? ' AND ' : '' ) . " comment_type != 'wpinv_note' ";
61
+	function wpinv_comment_feed_where($where) {
62
+		return $where . ($where ? ' AND ' : '') . " comment_type != 'wpinv_note' ";
63 63
 	}
64 64
 
65 65
 	/**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 * is called.
70 70
 	 */
71 71
 	public function delete_comments_count_cache() {
72
-		delete_transient( 'getpaid_count_comments' );
72
+		delete_transient('getpaid_count_comments');
73 73
 	}
74 74
 
75 75
 	/**
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
 	 * @param  int    $post_id Post ID.
81 81
 	 * @return object
82 82
 	 */
83
-	public function wp_count_comments( $stats, $post_id ) {
83
+	public function wp_count_comments($stats, $post_id) {
84 84
 		global $wpdb;
85 85
 
86
-		if ( empty( $post_id ) ) {
87
-			$stats = get_transient( 'getpaid_count_comments' );
86
+		if (empty($post_id)) {
87
+			$stats = get_transient('getpaid_count_comments');
88 88
 
89
-			if ( ! $stats ) {
89
+			if (!$stats) {
90 90
 				$stats = array(
91 91
 					'total_comments' => 0,
92 92
 					'all'            => 0,
@@ -110,27 +110,27 @@  discard block
 block discarded – undo
110 110
 					'post-trashed' => 'post-trashed',
111 111
 				);
112 112
 
113
-				foreach ( (array) $count as $row ) {
113
+				foreach ((array) $count as $row) {
114 114
 					// Don't count post-trashed toward totals.
115
-					if ( ! in_array( $row['comment_approved'], array( 'post-trashed', 'trash', 'spam' ), true ) ) {
115
+					if (!in_array($row['comment_approved'], array('post-trashed', 'trash', 'spam'), true)) {
116 116
 						$stats['all']            += $row['num_comments'];
117 117
 						$stats['total_comments'] += $row['num_comments'];
118
-					} elseif ( ! in_array( $row['comment_approved'], array( 'post-trashed', 'trash' ), true ) ) {
118
+					} elseif (!in_array($row['comment_approved'], array('post-trashed', 'trash'), true)) {
119 119
 						$stats['total_comments'] += $row['num_comments'];
120 120
 					}
121
-					if ( isset( $approved[ $row['comment_approved'] ] ) ) {
122
-						$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
121
+					if (isset($approved[$row['comment_approved']])) {
122
+						$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
123 123
 					}
124 124
 				}
125 125
 
126
-				foreach ( $approved as $key ) {
127
-					if ( empty( $stats[ $key ] ) ) {
128
-						$stats[ $key ] = 0;
126
+				foreach ($approved as $key) {
127
+					if (empty($stats[$key])) {
128
+						$stats[$key] = 0;
129 129
 					}
130 130
 				}
131 131
 
132 132
 				$stats = (object) $stats;
133
-				set_transient( 'getpaid_count_comments', $stats );
133
+				set_transient('getpaid_count_comments', $stats);
134 134
 			}
135 135
 
136 136
 		}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @param string $type Optional. Pass in customer to only return customer notes.
146 146
 	 * @return WP_Comment[]
147 147
 	 */
148
-	public function get_invoice_notes( $invoice_id = 0, $type = 'all' ) {
148
+	public function get_invoice_notes($invoice_id = 0, $type = 'all') {
149 149
 
150 150
 		// Default comment args.
151 151
 		$args = array(
@@ -155,14 +155,14 @@  discard block
 block discarded – undo
155 155
 		);
156 156
 
157 157
 		// Maybe only show customer comments.
158
-		if ( $type == 'customer' ) {
158
+		if ($type == 'customer') {
159 159
 			$args['meta_key']   = '_wpi_customer_note';
160 160
 			$args['meta_value'] = 1;
161 161
 		}
162 162
 
163
-		$args = apply_filters( 'wpinv_invoice_notes_args', $args, $this, $invoice_id, $type );
163
+		$args = apply_filters('wpinv_invoice_notes_args', $args, $this, $invoice_id, $type);
164 164
 
165
-		return get_comments( $args );
165
+		return get_comments($args);
166 166
 	}
167 167
 
168 168
 	/**
@@ -174,9 +174,9 @@  discard block
 block discarded – undo
174 174
 	 * @param bool $for_customer Whether or not this comment is meant to be sent to the customer.
175 175
 	 * @return int|false The new note's ID on success, false on failure.
176 176
 	 */
177
-	function add_invoice_note( $invoice, $note, $note_author, $author_email, $for_customer = false ){
177
+	function add_invoice_note($invoice, $note, $note_author, $author_email, $for_customer = false) {
178 178
 
179
-		do_action( 'wpinv_pre_insert_invoice_note', $invoice->get_id(), $note, $for_customer );
179
+		do_action('wpinv_pre_insert_invoice_note', $invoice->get_id(), $note, $for_customer);
180 180
 
181 181
 		/**
182 182
 		 * Insert the comment.
@@ -197,16 +197,16 @@  discard block
 block discarded – undo
197 197
 			)
198 198
 		);
199 199
 
200
-		do_action( 'wpinv_insert_payment_note', $note_id, $invoice->get_id(), $note, $for_customer );
200
+		do_action('wpinv_insert_payment_note', $note_id, $invoice->get_id(), $note, $for_customer);
201 201
 
202 202
 		// Are we notifying the customer?
203
-		if ( empty( $note_id ) || empty( $for_customer ) ) {
203
+		if (empty($note_id) || empty($for_customer)) {
204 204
 			return $note_id;
205 205
 		}
206 206
 
207
-		add_comment_meta( $note_id, '_wpi_customer_note', 1 );
208
-		do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $invoice->get_id(), 'user_note' => $note ) );
209
-		do_action( 'getpaid_new_customer_note', $invoice, $note );
207
+		add_comment_meta($note_id, '_wpi_customer_note', 1);
208
+		do_action('wpinv_new_customer_note', array('invoice_id' => $invoice->get_id(), 'user_note' => $note));
209
+		do_action('getpaid_new_customer_note', $invoice, $note);
210 210
 		return $note_id;
211 211
 	}
212 212
 
Please login to merge, or discard this patch.