Passed
Push — master ( 7ee9b2...f95e54 )
by Brian
05:07
created
includes/class-getpaid-notification-email-sender.php 2 patches
Indentation   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -13,17 +13,17 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Notification_Email_Sender {
14 14
 
15 15
     /**
16
-	 * Whether or not we should inline CSS into the email.
17
-	 */
18
-	public $inline_css = true;
16
+     * Whether or not we should inline CSS into the email.
17
+     */
18
+    public $inline_css = true;
19 19
 
20 20
     /**
21
-	 * The wp_mail() data.
22
-	 */
21
+     * The wp_mail() data.
22
+     */
23 23
     public $wp_mail_data = null;
24 24
 
25 25
     /**
26
-	 * Sends a new email.
26
+     * Sends a new email.
27 27
      * 
28 28
      * @param string|array $to The recipients email or an array of recipient emails.
29 29
      * @param string $subject The email's subject.
@@ -31,49 +31,49 @@  discard block
 block discarded – undo
31 31
      * @param array $attachments The email attachments.
32 32
      * 
33 33
      * @return bool
34
-	 */
35
-	public function send( $to, $subject, $email, $attachments = array() ) {
34
+     */
35
+    public function send( $to, $subject, $email, $attachments = array() ) {
36 36
 
37
-		/*
37
+        /*
38 38
 		 * Allow to filter data on per-email basis.
39 39
 		 */
40
-		$data = apply_filters(
41
-			'getpaid_email_data',
42
-			array(
43
-				'to'          => array_filter( array_unique( wpinv_parse_list( $to ) ) ),
44
-				'subject'     => $subject,
45
-				'email'       => $email,
46
-				'headers'     => $this->get_headers(),
47
-				'attachments' => $attachments,
48
-			),
49
-			$this
50
-		);
40
+        $data = apply_filters(
41
+            'getpaid_email_data',
42
+            array(
43
+                'to'          => array_filter( array_unique( wpinv_parse_list( $to ) ) ),
44
+                'subject'     => $subject,
45
+                'email'       => $email,
46
+                'headers'     => $this->get_headers(),
47
+                'attachments' => $attachments,
48
+            ),
49
+            $this
50
+        );
51 51
 
52 52
         // Remove slashes.
53 53
         $data               = (array) wp_unslash( $data );
54 54
 
55 55
         // Cache it.
56
-		$this->wp_mail_data = $data;
56
+        $this->wp_mail_data = $data;
57 57
 
58
-		// Attach our own hooks.
59
-		$this->before_sending();
58
+        // Attach our own hooks.
59
+        $this->before_sending();
60 60
 
61 61
         $result = false;
62 62
 
63 63
         foreach ( $this->wp_mail_data['to'] as $to ) {
64
-			$result = $this->_send( $to, $data );
64
+            $result = $this->_send( $to, $data );
65 65
         }
66 66
 
67
-		// Remove our hooks.
68
-		$this->after_sending();		
67
+        // Remove our hooks.
68
+        $this->after_sending();		
69 69
 
70
-		$this->wp_mail_data = null;
70
+        $this->wp_mail_data = null;
71 71
 
72
-		return $result;
73
-	}
72
+        return $result;
73
+    }
74 74
 
75
-	/**
76
-	 * Does the actual sending.
75
+    /**
76
+     * Does the actual sending.
77 77
      * 
78 78
      * @param string $to The recipient's email.
79 79
      * @param array $data The email's data.
@@ -81,81 +81,81 @@  discard block
 block discarded – undo
81 81
      * @param array $attachments The email attachments.
82 82
      * 
83 83
      * @return bool
84
-	 */
85
-	protected function _send( $to, $data ) {
86
-
87
-		// Prepare the sending function.
88
-		$sending_function = apply_filters( 'getpaid_email_email_sending_function', 'wp_mail' );
89
-
90
-		// Send the actual email.
91
-		$result = call_user_func(
92
-			$sending_function,
93
-			$to,
94
-			html_entity_decode( $data['subject'], ENT_QUOTES, get_bloginfo( 'charset' ) ),
95
-			$data['email'],
96
-			$data['headers'],
97
-			$data['attachments']
98
-		);
99
-
100
-		if ( ! $result ) {
101
-			$log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), $to, $data['subject'] );
102
-			wpinv_error_log( $log_message, __( 'Email from Invoicing plugin failed to send', 'invoicing' ), __FILE__, __LINE__ );
103
-		}
104
-
105
-		return $result;
106
-	}
84
+     */
85
+    protected function _send( $to, $data ) {
86
+
87
+        // Prepare the sending function.
88
+        $sending_function = apply_filters( 'getpaid_email_email_sending_function', 'wp_mail' );
89
+
90
+        // Send the actual email.
91
+        $result = call_user_func(
92
+            $sending_function,
93
+            $to,
94
+            html_entity_decode( $data['subject'], ENT_QUOTES, get_bloginfo( 'charset' ) ),
95
+            $data['email'],
96
+            $data['headers'],
97
+            $data['attachments']
98
+        );
99
+
100
+        if ( ! $result ) {
101
+            $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), $to, $data['subject'] );
102
+            wpinv_error_log( $log_message, __( 'Email from Invoicing plugin failed to send', 'invoicing' ), __FILE__, __LINE__ );
103
+        }
104
+
105
+        return $result;
106
+    }
107 107
     
108 108
     /**
109
-	 * Retrieves email headers.
110
-	 */
111
-	public function get_headers() {
109
+     * Retrieves email headers.
110
+     */
111
+    public function get_headers() {
112 112
 
113
-		$name       = $this->get_from_name();
114
-		$reply_to   = $this->get_reply_to();
115
-		$headers    = array( "Reply-To:$name <$reply_to>" );
113
+        $name       = $this->get_from_name();
114
+        $reply_to   = $this->get_reply_to();
115
+        $headers    = array( "Reply-To:$name <$reply_to>" );
116 116
 
117
-		return apply_filters( 'getpaid_email_headers',  $headers, $this );
117
+        return apply_filters( 'getpaid_email_headers',  $headers, $this );
118 118
 
119
-	}
119
+    }
120 120
 
121 121
     /**
122
-	 * Fires before an email is sent
123
-	 *
124
-	 * @since 1.0.0
125
-	 */
126
-	public function before_sending() {
122
+     * Fires before an email is sent
123
+     *
124
+     * @since 1.0.0
125
+     */
126
+    public function before_sending() {
127 127
 
128 128
         do_action( 'getpaid_before_send_email', $this );
129
-		add_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 );
130
-		add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 );
131
-		add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 );
132
-		add_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000000 );
129
+        add_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 );
130
+        add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 );
131
+        add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 );
132
+        add_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000000 );
133 133
 
134
-	}
134
+    }
135 135
 
136 136
     /**
137
-	 * Returns the from name.
138
-	 */
139
-	public function get_from_name() {
137
+     * Returns the from name.
138
+     */
139
+    public function get_from_name() {
140 140
 
141 141
         $from_name = wpinv_get_option( 'email_from_name', get_bloginfo( 'name' ) );
142 142
 
143
-		if ( empty( $from_name ) ) {
144
-			$from_name =  get_bloginfo( 'name' );
143
+        if ( empty( $from_name ) ) {
144
+            $from_name =  get_bloginfo( 'name' );
145 145
         }
146 146
 
147
-		return wp_specialchars_decode( $from_name, ENT_QUOTES );
147
+        return wp_specialchars_decode( $from_name, ENT_QUOTES );
148 148
     }
149 149
 
150 150
     /**
151
-	 * Returns the from email.
152
-	 */
153
-	public function get_from_address() {
151
+     * Returns the from email.
152
+     */
153
+    public function get_from_address() {
154 154
 
155 155
         $from_address = wpinv_get_option( 'email_from', $this->default_from_address() );
156 156
 
157
-		if ( ! is_email( $from_address ) ) {
158
-			$from_address =  $this->default_from_address();
157
+        if ( ! is_email( $from_address ) ) {
158
+            $from_address =  $this->default_from_address();
159 159
         }
160 160
         
161 161
         return $from_address;
@@ -163,75 +163,75 @@  discard block
 block discarded – undo
163 163
     }
164 164
 
165 165
     /**
166
-	 * The default emails from address.
167
-	 * 
168
-	 * Defaults to wordpress@$sitename
169
-	 * Some hosts will block outgoing mail from this address if it doesn't exist,
170
-	 * but there's no easy alternative. Defaulting to admin_email might appear to be
171
-	 * another option, but some hosts may refuse to relay mail from an unknown domain.
172
-	 *
173
-	 */
174
-	public function default_from_address() {
175
-
176
-		// Get the site domain and get rid of www.
177
-		$sitename = strtolower( $_SERVER['SERVER_NAME'] );
178
-		if ( substr( $sitename, 0, 4 ) == 'www.' ) {
179
-			$sitename = substr( $sitename, 4 );
180
-		}
181
-
182
-		$from_email = 'wordpress@' . $sitename;
183
-
184
-		return apply_filters( 'getpaid_default_from_address', $from_email );
166
+     * The default emails from address.
167
+     * 
168
+     * Defaults to wordpress@$sitename
169
+     * Some hosts will block outgoing mail from this address if it doesn't exist,
170
+     * but there's no easy alternative. Defaulting to admin_email might appear to be
171
+     * another option, but some hosts may refuse to relay mail from an unknown domain.
172
+     *
173
+     */
174
+    public function default_from_address() {
175
+
176
+        // Get the site domain and get rid of www.
177
+        $sitename = strtolower( $_SERVER['SERVER_NAME'] );
178
+        if ( substr( $sitename, 0, 4 ) == 'www.' ) {
179
+            $sitename = substr( $sitename, 4 );
180
+        }
181
+
182
+        $from_email = 'wordpress@' . $sitename;
183
+
184
+        return apply_filters( 'getpaid_default_from_address', $from_email );
185 185
 
186 186
     }
187 187
     
188 188
     /**
189
-	 * Get the email reply-to.
190
-	 *
191
-	 *
192
-	 * @return string The email reply-to address.
193
-	 */
194
-	public function get_reply_to() {
189
+     * Get the email reply-to.
190
+     *
191
+     *
192
+     * @return string The email reply-to address.
193
+     */
194
+    public function get_reply_to() {
195 195
 
196
-		$reply_to = wpinv_get_admin_email();
196
+        $reply_to = wpinv_get_admin_email();
197 197
 
198
-		if ( ! is_email( $reply_to ) ) {
199
-			$reply_to =  get_option( 'admin_email' );
200
-		}
198
+        if ( ! is_email( $reply_to ) ) {
199
+            $reply_to =  get_option( 'admin_email' );
200
+        }
201 201
 
202
-		return $reply_to;
202
+        return $reply_to;
203 203
     }
204 204
     
205 205
     /**
206
-	 * Get the email content type.
207
-	 *
208
-	 */
209
-	public function get_content_type() {
210
-		return apply_filters( 'getpaid_email_content_type', 'text/html', $this );
206
+     * Get the email content type.
207
+     *
208
+     */
209
+    public function get_content_type() {
210
+        return apply_filters( 'getpaid_email_content_type', 'text/html', $this );
211 211
     }
212 212
     
213 213
     /**
214
-	 * Ensures that our email messages are not messed up by template plugins.
215
-	 *
216
-	 * @return array wp_mail_data.
217
-	 */
218
-	public function ensure_email_content( $args ) {
219
-		$args['message'] = $this->wp_mail_data['email'];
220
-		return $args;
214
+     * Ensures that our email messages are not messed up by template plugins.
215
+     *
216
+     * @return array wp_mail_data.
217
+     */
218
+    public function ensure_email_content( $args ) {
219
+        $args['message'] = $this->wp_mail_data['email'];
220
+        return $args;
221 221
     }
222 222
     
223 223
     /**
224
-	 * A little house keeping after an email is sent.
225
-	 *
226
- 	 */
227
-	public function after_sending() {
224
+     * A little house keeping after an email is sent.
225
+     *
226
+     */
227
+    public function after_sending() {
228 228
 
229 229
         do_action( 'getpaid_after_send_email', $this->wp_mail_data );
230
-		remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 );
231
-		remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 );
232
-		remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 );
233
-		remove_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000000 );
230
+        remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 );
231
+        remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 );
232
+        remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 );
233
+        remove_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000000 );
234 234
 
235
-	}
235
+    }
236 236
 
237 237
 }
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 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
  * This function is responsible for sending emails.
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      * 
33 33
      * @return bool
34 34
 	 */
35
-	public function send( $to, $subject, $email, $attachments = array() ) {
35
+	public function send($to, $subject, $email, $attachments = array()) {
36 36
 
37 37
 		/*
38 38
 		 * Allow to filter data on per-email basis.
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 		$data = apply_filters(
41 41
 			'getpaid_email_data',
42 42
 			array(
43
-				'to'          => array_filter( array_unique( wpinv_parse_list( $to ) ) ),
43
+				'to'          => array_filter(array_unique(wpinv_parse_list($to))),
44 44
 				'subject'     => $subject,
45 45
 				'email'       => $email,
46 46
 				'headers'     => $this->get_headers(),
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		);
51 51
 
52 52
         // Remove slashes.
53
-        $data               = (array) wp_unslash( $data );
53
+        $data = (array) wp_unslash($data);
54 54
 
55 55
         // Cache it.
56 56
 		$this->wp_mail_data = $data;
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 
61 61
         $result = false;
62 62
 
63
-        foreach ( $this->wp_mail_data['to'] as $to ) {
64
-			$result = $this->_send( $to, $data );
63
+        foreach ($this->wp_mail_data['to'] as $to) {
64
+			$result = $this->_send($to, $data);
65 65
         }
66 66
 
67 67
 		// Remove our hooks.
@@ -82,24 +82,24 @@  discard block
 block discarded – undo
82 82
      * 
83 83
      * @return bool
84 84
 	 */
85
-	protected function _send( $to, $data ) {
85
+	protected function _send($to, $data) {
86 86
 
87 87
 		// Prepare the sending function.
88
-		$sending_function = apply_filters( 'getpaid_email_email_sending_function', 'wp_mail' );
88
+		$sending_function = apply_filters('getpaid_email_email_sending_function', 'wp_mail');
89 89
 
90 90
 		// Send the actual email.
91 91
 		$result = call_user_func(
92 92
 			$sending_function,
93 93
 			$to,
94
-			html_entity_decode( $data['subject'], ENT_QUOTES, get_bloginfo( 'charset' ) ),
94
+			html_entity_decode($data['subject'], ENT_QUOTES, get_bloginfo('charset')),
95 95
 			$data['email'],
96 96
 			$data['headers'],
97 97
 			$data['attachments']
98 98
 		);
99 99
 
100
-		if ( ! $result ) {
101
-			$log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), $to, $data['subject'] );
102
-			wpinv_error_log( $log_message, __( 'Email from Invoicing plugin failed to send', 'invoicing' ), __FILE__, __LINE__ );
100
+		if (!$result) {
101
+			$log_message = wp_sprintf(__("\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing'), date_i18n('F j Y H:i:s', current_time('timestamp')), $to, $data['subject']);
102
+			wpinv_error_log($log_message, __('Email from Invoicing plugin failed to send', 'invoicing'), __FILE__, __LINE__);
103 103
 		}
104 104
 
105 105
 		return $result;
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 
113 113
 		$name       = $this->get_from_name();
114 114
 		$reply_to   = $this->get_reply_to();
115
-		$headers    = array( "Reply-To:$name <$reply_to>" );
115
+		$headers    = array("Reply-To:$name <$reply_to>");
116 116
 
117
-		return apply_filters( 'getpaid_email_headers',  $headers, $this );
117
+		return apply_filters('getpaid_email_headers', $headers, $this);
118 118
 
119 119
 	}
120 120
 
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public function before_sending() {
127 127
 
128
-        do_action( 'getpaid_before_send_email', $this );
129
-		add_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 );
130
-		add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 );
131
-		add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 );
132
-		add_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000000 );
128
+        do_action('getpaid_before_send_email', $this);
129
+		add_filter('wp_mail_from', array($this, 'get_from_address'), 1000);
130
+		add_filter('wp_mail_from_name', array($this, 'get_from_name'), 1000);
131
+		add_filter('wp_mail_content_type', array($this, 'get_content_type'), 1000);
132
+		add_filter('wp_mail', array($this, 'ensure_email_content'), 1000000);
133 133
 
134 134
 	}
135 135
 
@@ -138,13 +138,13 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	public function get_from_name() {
140 140
 
141
-        $from_name = wpinv_get_option( 'email_from_name', get_bloginfo( 'name' ) );
141
+        $from_name = wpinv_get_option('email_from_name', get_bloginfo('name'));
142 142
 
143
-		if ( empty( $from_name ) ) {
144
-			$from_name =  get_bloginfo( 'name' );
143
+		if (empty($from_name)) {
144
+			$from_name = get_bloginfo('name');
145 145
         }
146 146
 
147
-		return wp_specialchars_decode( $from_name, ENT_QUOTES );
147
+		return wp_specialchars_decode($from_name, ENT_QUOTES);
148 148
     }
149 149
 
150 150
     /**
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	public function get_from_address() {
154 154
 
155
-        $from_address = wpinv_get_option( 'email_from', $this->default_from_address() );
155
+        $from_address = wpinv_get_option('email_from', $this->default_from_address());
156 156
 
157
-		if ( ! is_email( $from_address ) ) {
158
-			$from_address =  $this->default_from_address();
157
+		if (!is_email($from_address)) {
158
+			$from_address = $this->default_from_address();
159 159
         }
160 160
         
161 161
         return $from_address;
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 	public function default_from_address() {
175 175
 
176 176
 		// Get the site domain and get rid of www.
177
-		$sitename = strtolower( $_SERVER['SERVER_NAME'] );
178
-		if ( substr( $sitename, 0, 4 ) == 'www.' ) {
179
-			$sitename = substr( $sitename, 4 );
177
+		$sitename = strtolower($_SERVER['SERVER_NAME']);
178
+		if (substr($sitename, 0, 4) == 'www.') {
179
+			$sitename = substr($sitename, 4);
180 180
 		}
181 181
 
182 182
 		$from_email = 'wordpress@' . $sitename;
183 183
 
184
-		return apply_filters( 'getpaid_default_from_address', $from_email );
184
+		return apply_filters('getpaid_default_from_address', $from_email);
185 185
 
186 186
     }
187 187
     
@@ -195,8 +195,8 @@  discard block
 block discarded – undo
195 195
 
196 196
 		$reply_to = wpinv_get_admin_email();
197 197
 
198
-		if ( ! is_email( $reply_to ) ) {
199
-			$reply_to =  get_option( 'admin_email' );
198
+		if (!is_email($reply_to)) {
199
+			$reply_to = get_option('admin_email');
200 200
 		}
201 201
 
202 202
 		return $reply_to;
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 *
208 208
 	 */
209 209
 	public function get_content_type() {
210
-		return apply_filters( 'getpaid_email_content_type', 'text/html', $this );
210
+		return apply_filters('getpaid_email_content_type', 'text/html', $this);
211 211
     }
212 212
     
213 213
     /**
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @return array wp_mail_data.
217 217
 	 */
218
-	public function ensure_email_content( $args ) {
218
+	public function ensure_email_content($args) {
219 219
 		$args['message'] = $this->wp_mail_data['email'];
220 220
 		return $args;
221 221
     }
@@ -226,11 +226,11 @@  discard block
 block discarded – undo
226 226
  	 */
227 227
 	public function after_sending() {
228 228
 
229
-        do_action( 'getpaid_after_send_email', $this->wp_mail_data );
230
-		remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 );
231
-		remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 );
232
-		remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 );
233
-		remove_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000000 );
229
+        do_action('getpaid_after_send_email', $this->wp_mail_data);
230
+		remove_filter('wp_mail_from', array($this, 'get_from_address'), 1000);
231
+		remove_filter('wp_mail_from_name', array($this, 'get_from_name'), 1000);
232
+		remove_filter('wp_mail_content_type', array($this, 'get_content_type'), 1000);
233
+		remove_filter('wp_mail', array($this, 'ensure_email_content'), 1000000);
234 234
 
235 235
 	}
236 236
 
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-bank-transfer-gateway.php 1 patch
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -13,23 +13,23 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Bank_Transfer_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'bank_transfer';
21 21
 
22 22
     /**
23
-	 * Payment method order.
24
-	 *
25
-	 * @var int
26
-	 */
27
-	public $order = 8;
23
+     * Payment method order.
24
+     *
25
+     * @var int
26
+     */
27
+    public $order = 8;
28 28
     
29 29
     /**
30
-	 * Class constructor.
31
-	 */
32
-	public function __construct() {
30
+     * Class constructor.
31
+     */
32
+    public function __construct() {
33 33
         parent::__construct();
34 34
 
35 35
         $this->title                = __( 'Direct bank transfer', 'invoicing' );
@@ -37,22 +37,22 @@  discard block
 block discarded – undo
37 37
         $this->checkout_button_text = __( 'Proceed', 'invoicing' );
38 38
         $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
39 39
 
40
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
41
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
42
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
40
+        add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
41
+        add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
42
+        add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
43 43
 
44 44
     }
45 45
 
46 46
     /**
47
-	 * Process Payment.
48
-	 *
49
-	 *
50
-	 * @param WPInv_Invoice $invoice Invoice.
51
-	 * @param array $submission_data Posted checkout fields.
52
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
53
-	 * @return array
54
-	 */
55
-	public function process_payment( $invoice, $submission_data, $submission ) {
47
+     * Process Payment.
48
+     *
49
+     *
50
+     * @param WPInv_Invoice $invoice Invoice.
51
+     * @param array $submission_data Posted checkout fields.
52
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
53
+     * @return array
54
+     */
55
+    public function process_payment( $invoice, $submission_data, $submission ) {
56 56
 
57 57
         // Add a transaction id.
58 58
         $invoice->set_transaction_id( $invoice->generate_key('trans_') );
@@ -73,66 +73,66 @@  discard block
 block discarded – undo
73 73
     }
74 74
 
75 75
     /**
76
-	 * Output for the order received page.
77
-	 *
78
-	 * @param WPInv_Invoice $invoice Invoice.
79
-	 */
80
-	public function thankyou_page( $invoice ) {
76
+     * Output for the order received page.
77
+     *
78
+     * @param WPInv_Invoice $invoice Invoice.
79
+     */
80
+    public function thankyou_page( $invoice ) {
81 81
 
82 82
         if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
83 83
 
84
-			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
84
+            echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
85 85
 
86 86
             if ( ! empty( $this->instructions ) ) {
87 87
                 echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
88
-			}
88
+            }
89 89
 
90
-			$this->bank_details( $invoice );
90
+            $this->bank_details( $invoice );
91 91
 			
92
-			echo '</div>';
92
+            echo '</div>';
93 93
         
94 94
         }
95 95
 
96
-	}
96
+    }
97 97
     
98 98
     /**
99
-	 * Add content to the WPI emails.
100
-	 *
101
-	 * @param WPInv_Invoice $invoice Invoice.
102
-	 * @param string     $email_type Email format: plain text or HTML.
103
-	 * @param bool     $sent_to_admin Sent to admin.
104
-	 */
105
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
99
+     * Add content to the WPI emails.
100
+     *
101
+     * @param WPInv_Invoice $invoice Invoice.
102
+     * @param string     $email_type Email format: plain text or HTML.
103
+     * @param bool     $sent_to_admin Sent to admin.
104
+     */
105
+    public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
106 106
 
107
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
107
+        if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
108 108
 
109
-			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
109
+            echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
110 110
 
111
-			if ( $this->instructions ) {
112
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
111
+            if ( $this->instructions ) {
112
+                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
113 113
             }
114 114
 
115
-			$this->bank_details( $invoice );
115
+            $this->bank_details( $invoice );
116 116
 			
117
-			echo '</div>';
117
+            echo '</div>';
118 118
 
119
-		}
119
+        }
120 120
 
121 121
     }
122 122
     
123 123
     /**
124
-	 * Get bank details and place into a list format.
125
-	 *
126
-	 * @param WPInv_Invoice $invoice Invoice.
127
-	 */
128
-	protected function bank_details( $invoice ) {
124
+     * Get bank details and place into a list format.
125
+     *
126
+     * @param WPInv_Invoice $invoice Invoice.
127
+     */
128
+    protected function bank_details( $invoice ) {
129 129
 
130
-		// Get the invoice country and country $locale.
131
-		$country = $invoice->get_country();
132
-		$locale  = $this->get_country_locale();
130
+        // Get the invoice country and country $locale.
131
+        $country = $invoice->get_country();
132
+        $locale  = $this->get_country_locale();
133 133
 
134
-		// Get sortcode label in the $locale array and use appropriate one.
135
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
134
+        // Get sortcode label in the $locale array and use appropriate one.
135
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
136 136
 
137 137
         $bank_fields = array(
138 138
             'ac_name'     => __( 'Account Name', 'invoicing' ),
@@ -161,144 +161,144 @@  discard block
 block discarded – undo
161 161
             return;
162 162
         }
163 163
 
164
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL;
164
+        echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL;
165 165
 
166
-		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
166
+        echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
167 167
 
168
-		foreach ( $bank_info as $key => $data ) {
168
+        foreach ( $bank_info as $key => $data ) {
169 169
 
170
-			$key   = sanitize_html_class( $key );
171
-			$label = wp_kses_post( $data['label'] );
172
-			$value = wp_kses_post( wptexturize( $data['value'] ) );
170
+            $key   = sanitize_html_class( $key );
171
+            $label = wp_kses_post( $data['label'] );
172
+            $value = wp_kses_post( wptexturize( $data['value'] ) );
173 173
 
174
-			echo "<tr class='getpaid-bank-transfer-$key'><th>$label</th><td>$value</td></tr>" . PHP_EOL;
175
-		}
174
+            echo "<tr class='getpaid-bank-transfer-$key'><th>$label</th><td>$value</td></tr>" . PHP_EOL;
175
+        }
176 176
 
177
-		echo '</table>';
177
+        echo '</table>';
178 178
 
179 179
     }
180 180
     
181 181
     /**
182
-	 * Get country locale if localized.
183
-	 *
184
-	 * @return array
185
-	 */
186
-	public function get_country_locale() {
187
-
188
-		if ( empty( $this->locale ) ) {
189
-
190
-			// Locale information to be used - only those that are not 'Sort Code'.
191
-			$this->locale = apply_filters(
192
-				'getpaid_get_bank_transfer_locale',
193
-				array(
194
-					'AU' => array(
195
-						'sortcode' => array(
196
-							'label' => __( 'BSB', 'invoicing' ),
197
-						),
198
-					),
199
-					'CA' => array(
200
-						'sortcode' => array(
201
-							'label' => __( 'Bank transit number', 'invoicing' ),
202
-						),
203
-					),
204
-					'IN' => array(
205
-						'sortcode' => array(
206
-							'label' => __( 'IFSC', 'invoicing' ),
207
-						),
208
-					),
209
-					'IT' => array(
210
-						'sortcode' => array(
211
-							'label' => __( 'Branch sort', 'invoicing' ),
212
-						),
213
-					),
214
-					'NZ' => array(
215
-						'sortcode' => array(
216
-							'label' => __( 'Bank code', 'invoicing' ),
217
-						),
218
-					),
219
-					'SE' => array(
220
-						'sortcode' => array(
221
-							'label' => __( 'Bank code', 'invoicing' ),
222
-						),
223
-					),
224
-					'US' => array(
225
-						'sortcode' => array(
226
-							'label' => __( 'Routing number', 'invoicing' ),
227
-						),
228
-					),
229
-					'ZA' => array(
230
-						'sortcode' => array(
231
-							'label' => __( 'Branch code', 'invoicing' ),
232
-						),
233
-					),
234
-				)
235
-			);
236
-
237
-		}
238
-
239
-		return $this->locale;
240
-
241
-	}
242
-
243
-	/**
244
-	 * Filters the gateway settings.
245
-	 * 
246
-	 * @param array $admin_settings
247
-	 */
248
-	public function admin_settings( $admin_settings ) {
182
+     * Get country locale if localized.
183
+     *
184
+     * @return array
185
+     */
186
+    public function get_country_locale() {
187
+
188
+        if ( empty( $this->locale ) ) {
189
+
190
+            // Locale information to be used - only those that are not 'Sort Code'.
191
+            $this->locale = apply_filters(
192
+                'getpaid_get_bank_transfer_locale',
193
+                array(
194
+                    'AU' => array(
195
+                        'sortcode' => array(
196
+                            'label' => __( 'BSB', 'invoicing' ),
197
+                        ),
198
+                    ),
199
+                    'CA' => array(
200
+                        'sortcode' => array(
201
+                            'label' => __( 'Bank transit number', 'invoicing' ),
202
+                        ),
203
+                    ),
204
+                    'IN' => array(
205
+                        'sortcode' => array(
206
+                            'label' => __( 'IFSC', 'invoicing' ),
207
+                        ),
208
+                    ),
209
+                    'IT' => array(
210
+                        'sortcode' => array(
211
+                            'label' => __( 'Branch sort', 'invoicing' ),
212
+                        ),
213
+                    ),
214
+                    'NZ' => array(
215
+                        'sortcode' => array(
216
+                            'label' => __( 'Bank code', 'invoicing' ),
217
+                        ),
218
+                    ),
219
+                    'SE' => array(
220
+                        'sortcode' => array(
221
+                            'label' => __( 'Bank code', 'invoicing' ),
222
+                        ),
223
+                    ),
224
+                    'US' => array(
225
+                        'sortcode' => array(
226
+                            'label' => __( 'Routing number', 'invoicing' ),
227
+                        ),
228
+                    ),
229
+                    'ZA' => array(
230
+                        'sortcode' => array(
231
+                            'label' => __( 'Branch code', 'invoicing' ),
232
+                        ),
233
+                    ),
234
+                )
235
+            );
236
+
237
+        }
238
+
239
+        return $this->locale;
240
+
241
+    }
242
+
243
+    /**
244
+     * Filters the gateway settings.
245
+     * 
246
+     * @param array $admin_settings
247
+     */
248
+    public function admin_settings( $admin_settings ) {
249 249
 
250 250
         $admin_settings['worldpay_desc']['std']    = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' );
251
-		$admin_settings['worldpay_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
251
+        $admin_settings['worldpay_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
252 252
 
253
-		$locale  = $this->get_country_locale();
253
+        $locale  = $this->get_country_locale();
254 254
 
255
-		// Get sortcode label in the $locale array and use appropriate one.
256
-		$country  = wpinv_default_billing_country();
257
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
255
+        // Get sortcode label in the $locale array and use appropriate one.
256
+        $country  = wpinv_default_billing_country();
257
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
258 258
 
259
-		$admin_settings['bank_transfer_ac_name'] = array(
259
+        $admin_settings['bank_transfer_ac_name'] = array(
260 260
             'type' => 'text',
261 261
             'id'   => 'bank_transfer_ac_name',
262 262
             'name' => __( 'Account Name', 'invoicing' ),
263
-		);
263
+        );
264 264
 		
265
-		$admin_settings['bank_transfer_ac_no'] = array(
265
+        $admin_settings['bank_transfer_ac_no'] = array(
266 266
             'type' => 'text',
267 267
             'id'   => 'bank_transfer_ac_no',
268 268
             'name' => __( 'Account Number', 'invoicing' ),
269
-		);
269
+        );
270 270
 		
271
-		$admin_settings['bank_transfer_bank_name'] = array(
271
+        $admin_settings['bank_transfer_bank_name'] = array(
272 272
             'type' => 'text',
273 273
             'id'   => 'bank_transfer_bank_name',
274 274
             'name' => __( 'Bank Name', 'invoicing' ),
275
-		);
275
+        );
276 276
 
277
-		$admin_settings['bank_transfer_ifsc'] = array(
277
+        $admin_settings['bank_transfer_ifsc'] = array(
278 278
             'type' => 'text',
279 279
             'id'   => 'bank_transfer_ifsc',
280 280
             'name' => __( 'IFSC Code', 'invoicing' ),
281
-		);
281
+        );
282 282
 
283
-		$admin_settings['bank_transfer_iban'] = array(
283
+        $admin_settings['bank_transfer_iban'] = array(
284 284
             'type' => 'text',
285 285
             'id'   => 'bank_transfer_iban',
286 286
             'name' => __( 'IBAN', 'invoicing' ),
287
-		);
287
+        );
288 288
 
289
-		$admin_settings['bank_transfer_bic'] = array(
289
+        $admin_settings['bank_transfer_bic'] = array(
290 290
             'type' => 'text',
291 291
             'id'   => 'bank_transfer_bic',
292 292
             'name' => __( 'BIC/Swift Code', 'invoicing' ),
293
-		);
293
+        );
294 294
 		
295
-		$admin_settings['bank_transfer_sort_code'] = array(
296
-			'type' => 'text',
297
-			'id'   => 'bank_transfer_sort_code',
298
-			'name' => $sortcode,
299
-		);
295
+        $admin_settings['bank_transfer_sort_code'] = array(
296
+            'type' => 'text',
297
+            'id'   => 'bank_transfer_sort_code',
298
+            'name' => $sortcode,
299
+        );
300 300
 
301
-		$admin_settings['bank_transfer_info'] = array(
301
+        $admin_settings['bank_transfer_info'] = array(
302 302
             'id'   => 'bank_transfer_info',
303 303
             'name' => __( 'Instructions', 'invoicing' ),
304 304
             'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
             'rows' => 5
309 309
         );
310 310
 
311
-		return $admin_settings;
312
-	}
311
+        return $admin_settings;
312
+    }
313 313
 
314 314
 }
Please login to merge, or discard this patch.
includes/class-wpinv-reports.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         $current = 'earnings';
117 117
 
118 118
         if ( isset( $_GET['view'] ) && array_key_exists( $_GET['view'], $views ) )
119
-		$current = $_GET['view'];
119
+        $current = $_GET['view'];
120 120
 
121 121
         ?>
122 122
 	        <form id="wpinv-reports-filter" method="get" class="tablenav">
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	        </form>
135 135
         <?php
136 136
 
137
-	    do_action( 'wpinv_reports_view_' . $current );
137
+        do_action( 'wpinv_reports_view_' . $current );
138 138
 
139 139
     }
140 140
 
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
             $is_writeable   = $is_dir && is_writeable( $this->export_dir );
225 225
 
226 226
             if ( $is_dir && $is_writeable ) {
227
-               return true;
227
+                return true;
228 228
             } else if ( $is_dir && !$is_writeable ) {
229
-               if ( !$this->wp_filesystem->chmod( $this->export_dir, FS_CHMOD_DIR ) ) {
230
-                   return wp_sprintf( __( 'Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing' ), $this->export_dir );
231
-               }
229
+                if ( !$this->wp_filesystem->chmod( $this->export_dir, FS_CHMOD_DIR ) ) {
230
+                    return wp_sprintf( __( 'Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing' ), $this->export_dir );
231
+                }
232 232
 
233
-               return true;
233
+                return true;
234 234
             } else {
235 235
                 if ( !$this->wp_filesystem->mkdir( $this->export_dir, FS_CHMOD_DIR ) ) {
236 236
                     return wp_sprintf( __( 'Filesystem ERROR: Could not create directory %s. This is usually due to inconsistent file permissions.', 'invoicing' ), $this->export_dir );
@@ -325,12 +325,12 @@  discard block
 block discarded – undo
325 325
         $output  = fopen( 'php://output', 'w' ) or die( 'Unsupported server' );
326 326
 
327 327
         // Let the browser know what content we're streaming and how it should save the content.
328
-		$name = time();
329
-		header( "Content-Type:application/csv" );
328
+        $name = time();
329
+        header( "Content-Type:application/csv" );
330 330
         header( "Content-Disposition:attachment;filename=getpaid-discounts-$name.csv" );
331 331
 
332 332
         // Output the csv column headers.
333
-		fputcsv(
333
+        fputcsv(
334 334
             $output,
335 335
             array(
336 336
                 __( 'Discount Id', 'invoicing' ),
@@ -698,12 +698,12 @@  discard block
 block discarded – undo
698 698
         $thirty_days_ago      = date( 'Y-m-d', strtotime( '-30 days', current_time( 'timestamp' ) ) );
699 699
         $first_day_month  	  = date( 'Y-m-1', current_time( 'timestamp' ) );
700 700
         $last_day_month  	  = date( 'Y-m-t', current_time( 'timestamp' ) );
701
-		$first_day_last_month = date( 'Y-m-d', strtotime( 'first day of last month', current_time( 'timestamp' ) ) );
701
+        $first_day_last_month = date( 'Y-m-d', strtotime( 'first day of last month', current_time( 'timestamp' ) ) );
702 702
         $last_day_last_month  = date( 'Y-m-d', strtotime( 'last day of last month', current_time( 'timestamp' ) ) );
703 703
         $first_day_year  	  = date( 'Y-1-1', current_time( 'timestamp' ) );
704 704
         $last_day_year  	  = date( 'Y-12-31', current_time( 'timestamp' ) );
705
-		$first_day_last_year  = date( 'Y-m-d', strtotime( 'first day of last year', current_time( 'timestamp' ) ) );
706
-		$last_day_last_year   = date( 'Y-m-d', strtotime( 'last day of last year', current_time( 'timestamp' ) ) );
705
+        $first_day_last_year  = date( 'Y-m-d', strtotime( 'first day of last year', current_time( 'timestamp' ) ) );
706
+        $last_day_last_year   = date( 'Y-m-d', strtotime( 'last day of last year', current_time( 'timestamp' ) ) );
707 707
 
708 708
         $ranges = array(
709 709
 
Please login to merge, or discard this patch.
Spacing   +335 added lines, -335 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit; // Exit if accessed directly
4 4
 }
5 5
 
@@ -21,79 +21,79 @@  discard block
 block discarded – undo
21 21
     public function init() {
22 22
         global $wp_filesystem;
23 23
 
24
-        if ( empty( $wp_filesystem ) ) {
25
-            require_once( ABSPATH . '/wp-admin/includes/file.php' );
24
+        if (empty($wp_filesystem)) {
25
+            require_once(ABSPATH . '/wp-admin/includes/file.php');
26 26
             WP_Filesystem();
27 27
             global $wp_filesystem;
28 28
         }
29 29
         $this->wp_filesystem    = $wp_filesystem;
30 30
 
31 31
         $this->export_dir       = $this->export_location();
32
-        $this->export_url       = $this->export_location( true );
32
+        $this->export_url       = $this->export_location(true);
33 33
         $this->export           = 'invoicing';
34 34
         $this->filetype         = 'csv';
35 35
         $this->per_page         = 20;
36 36
 
37
-        do_action( 'wpinv_class_reports_init', $this );
37
+        do_action('wpinv_class_reports_init', $this);
38 38
     }
39 39
 
40 40
     public function includes() {
41
-        do_action( 'wpinv_class_reports_includes', $this );
41
+        do_action('wpinv_class_reports_includes', $this);
42 42
     }
43 43
 
44 44
     public function actions() {
45
-        if ( is_admin() ) {
46
-            add_action( 'admin_menu', array( $this, 'add_submenu' ), 20 );
47
-            add_action( 'wpinv_reports_tab_reports', array( $this, 'reports' ) );
48
-            add_action( 'wpinv_reports_tab_export', array( $this, 'export' ) );
49
-            add_action( 'wp_ajax_wpinv_ajax_export', array( $this, 'ajax_export' ) );
50
-            add_action( 'wp_ajax_wpinv_ajax_discount_use_export', array( $this, 'discount_use_export' ) );
45
+        if (is_admin()) {
46
+            add_action('admin_menu', array($this, 'add_submenu'), 20);
47
+            add_action('wpinv_reports_tab_reports', array($this, 'reports'));
48
+            add_action('wpinv_reports_tab_export', array($this, 'export'));
49
+            add_action('wp_ajax_wpinv_ajax_export', array($this, 'ajax_export'));
50
+            add_action('wp_ajax_wpinv_ajax_discount_use_export', array($this, 'discount_use_export'));
51 51
 
52 52
             // Export Invoices.
53
-            add_action( 'wpinv_export_set_params_invoices', array( $this, 'set_invoices_export' ) );
54
-            add_filter( 'wpinv_export_get_columns_invoices', array( $this, 'get_invoices_columns' ) );
55
-            add_filter( 'wpinv_export_get_data_invoices', array( $this, 'get_invoices_data' ) );
56
-            add_filter( 'wpinv_get_export_status_invoices', array( $this, 'invoices_export_status' ) );
53
+            add_action('wpinv_export_set_params_invoices', array($this, 'set_invoices_export'));
54
+            add_filter('wpinv_export_get_columns_invoices', array($this, 'get_invoices_columns'));
55
+            add_filter('wpinv_export_get_data_invoices', array($this, 'get_invoices_data'));
56
+            add_filter('wpinv_get_export_status_invoices', array($this, 'invoices_export_status'));
57 57
 
58 58
             // Reports.
59
-            add_action( 'wpinv_reports_view_earnings', array( $this, 'earnings_report' ) );
60
-            add_action( 'wpinv_reports_view_gateways', array( $this, 'gateways_report' ) );
61
-            add_action( 'wpinv_reports_view_items', array( $this, 'items_report' ) );
62
-            add_action( 'wpinv_reports_view_taxes', array( $this, 'tax_report' ) );
59
+            add_action('wpinv_reports_view_earnings', array($this, 'earnings_report'));
60
+            add_action('wpinv_reports_view_gateways', array($this, 'gateways_report'));
61
+            add_action('wpinv_reports_view_items', array($this, 'items_report'));
62
+            add_action('wpinv_reports_view_taxes', array($this, 'tax_report'));
63 63
         }
64
-        do_action( 'wpinv_class_reports_actions', $this );
64
+        do_action('wpinv_class_reports_actions', $this);
65 65
     }
66 66
 
67 67
     public function add_submenu() {
68 68
         global $wpi_reports_page;
69
-        $wpi_reports_page = add_submenu_page( 'wpinv', __( 'Reports', 'invoicing' ), __( 'Reports', 'invoicing' ), wpinv_get_capability(), 'wpinv-reports', array( $this, 'reports_page' ) );
69
+        $wpi_reports_page = add_submenu_page('wpinv', __('Reports', 'invoicing'), __('Reports', 'invoicing'), wpinv_get_capability(), 'wpinv-reports', array($this, 'reports_page'));
70 70
     }
71 71
 
72 72
     public function reports_page() {
73 73
 
74
-        if ( !wp_script_is( 'postbox', 'enqueued' ) ) {
75
-            wp_enqueue_script( 'postbox' );
74
+        if (!wp_script_is('postbox', 'enqueued')) {
75
+            wp_enqueue_script('postbox');
76 76
         }
77 77
 
78
-        if ( !wp_script_is( 'jquery-ui-datepicker', 'enqueued' ) ) {
79
-            wp_enqueue_script( 'jquery-ui-datepicker' );
78
+        if (!wp_script_is('jquery-ui-datepicker', 'enqueued')) {
79
+            wp_enqueue_script('jquery-ui-datepicker');
80 80
         }
81 81
 
82
-        $current_page = admin_url( 'admin.php?page=wpinv-reports' );
83
-        $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
82
+        $current_page = admin_url('admin.php?page=wpinv-reports');
83
+        $active_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'reports';
84 84
         ?>
85 85
         <div class="wrap wpi-reports-wrap">
86
-            <h1><?php echo esc_html( __( 'Reports', 'invoicing' ) ); ?></h1>
86
+            <h1><?php echo esc_html(__('Reports', 'invoicing')); ?></h1>
87 87
             <h2 class="nav-tab-wrapper wp-clearfix">
88
-                <a href="<?php echo add_query_arg( array( 'tab' => 'reports', 'settings-updated' => false ), $current_page ); ?>" class="nav-tab <?php echo $active_tab == 'reports' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Reports', 'invoicing' ); ?></a>
89
-                <a href="<?php echo add_query_arg( array( 'tab' => 'export', 'settings-updated' => false ), $current_page ); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Export', 'invoicing' ); ?></a>
90
-                <?php do_action( 'wpinv_reports_page_tabs' ); ;?>
88
+                <a href="<?php echo add_query_arg(array('tab' => 'reports', 'settings-updated' => false), $current_page); ?>" class="nav-tab <?php echo $active_tab == 'reports' ? 'nav-tab-active' : ''; ?>"><?php _e('Reports', 'invoicing'); ?></a>
89
+                <a href="<?php echo add_query_arg(array('tab' => 'export', 'settings-updated' => false), $current_page); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php _e('Export', 'invoicing'); ?></a>
90
+                <?php do_action('wpinv_reports_page_tabs'); ;?>
91 91
             </h2>
92
-            <div class="wpi-reports-content wpi-reports-<?php echo esc_attr( $active_tab ); ?>">
92
+            <div class="wpi-reports-content wpi-reports-<?php echo esc_attr($active_tab); ?>">
93 93
             <?php
94
-                do_action( 'wpinv_reports_page_top' );
95
-                do_action( 'wpinv_reports_tab_' . $active_tab );
96
-                do_action( 'wpinv_reports_page_bottom' );
94
+                do_action('wpinv_reports_page_top');
95
+                do_action('wpinv_reports_tab_' . $active_tab);
96
+                do_action('wpinv_reports_page_bottom');
97 97
             ?>
98 98
             </div>
99 99
         </div>
@@ -106,139 +106,139 @@  discard block
 block discarded – undo
106 106
     public function reports() {
107 107
 
108 108
         $views = array(
109
-            'earnings'   => __( 'Earnings', 'invoicing' ),
110
-            'items'      => __( 'Items', 'invoicing' ),
111
-            'gateways'   => __( 'Payment Methods', 'invoicing' ),
112
-            'taxes'      => __( 'Taxes', 'invoicing' ),
109
+            'earnings'   => __('Earnings', 'invoicing'),
110
+            'items'      => __('Items', 'invoicing'),
111
+            'gateways'   => __('Payment Methods', 'invoicing'),
112
+            'taxes'      => __('Taxes', 'invoicing'),
113 113
         );
114 114
 
115
-        $views   = apply_filters( 'wpinv_report_views', $views );
115
+        $views   = apply_filters('wpinv_report_views', $views);
116 116
         $current = 'earnings';
117 117
 
118
-        if ( isset( $_GET['view'] ) && array_key_exists( $_GET['view'], $views ) )
118
+        if (isset($_GET['view']) && array_key_exists($_GET['view'], $views))
119 119
 		$current = $_GET['view'];
120 120
 
121 121
         ?>
122 122
 	        <form id="wpinv-reports-filter" method="get" class="tablenav">
123 123
 		        <select id="wpinv-reports-view" name="view">
124
-			        <option value="-1" disabled><?php _e( 'Report Type', 'invoicing' ); ?></option>
125
-			            <?php foreach ( $views as $view_id => $label ) : ?>
126
-				            <option value="<?php echo esc_attr( $view_id ); ?>" <?php selected( $view_id, $current ); ?>><?php echo $label; ?></option>
124
+			        <option value="-1" disabled><?php _e('Report Type', 'invoicing'); ?></option>
125
+			            <?php foreach ($views as $view_id => $label) : ?>
126
+				            <option value="<?php echo esc_attr($view_id); ?>" <?php selected($view_id, $current); ?>><?php echo $label; ?></option>
127 127
 			            <?php endforeach; ?>
128 128
 		        </select>
129 129
 
130
-		        <?php do_action( 'wpinv_report_view_actions' ); ?>
130
+		        <?php do_action('wpinv_report_view_actions'); ?>
131 131
 
132 132
 		        <input type="hidden" name="page" value="wpinv-reports"/>
133
-		        <?php submit_button( __( 'Show', 'invoicing' ), 'secondary', 'submit', false ); ?>
133
+		        <?php submit_button(__('Show', 'invoicing'), 'secondary', 'submit', false); ?>
134 134
 	        </form>
135 135
         <?php
136 136
 
137
-	    do_action( 'wpinv_reports_view_' . $current );
137
+	    do_action('wpinv_reports_view_' . $current);
138 138
 
139 139
     }
140 140
 
141 141
     public function export() {
142
-        $statuses = wpinv_get_invoice_statuses( true );
143
-        $statuses = array_merge( array( 'any' => __( 'All Statuses', 'invoicing' ) ), $statuses );
142
+        $statuses = wpinv_get_invoice_statuses(true);
143
+        $statuses = array_merge(array('any' => __('All Statuses', 'invoicing')), $statuses);
144 144
         ?>
145 145
         <div class="metabox-holder">
146 146
             <div id="post-body">
147 147
                 <div id="post-body-content">
148
-                    <?php do_action( 'wpinv_reports_tab_export_content_top' ); ?>
148
+                    <?php do_action('wpinv_reports_tab_export_content_top'); ?>
149 149
 
150 150
                     <div class="postbox wpi-export-invoices">
151
-                        <h2 class="hndle ui-sortabled-handle"><span><?php _e( 'Invoices','invoicing' ); ?></span></h2>
151
+                        <h2 class="hndle ui-sortabled-handle"><span><?php _e('Invoices', 'invoicing'); ?></span></h2>
152 152
                         <div class="inside">
153
-                            <p><?php _e( 'Download a CSV of all payment invoices.', 'invoicing' ); ?></p>
153
+                            <p><?php _e('Download a CSV of all payment invoices.', 'invoicing'); ?></p>
154 154
                             <form id="wpi-export-invoices" class="wpi-export-form" method="post">
155
-                                <?php echo wpinv_html_date_field( array(
155
+                                <?php echo wpinv_html_date_field(array(
156 156
                                     'id' => 'wpi_export_from_date',
157 157
                                     'name' => 'from_date',
158 158
                                     'data' => array(
159 159
                                         'dateFormat' => 'yy-mm-dd'
160 160
                                     ),
161
-                                    'placeholder' => __( 'From date', 'invoicing' ) )
161
+                                    'placeholder' => __('From date', 'invoicing') )
162 162
                                 ); ?>
163
-                                <?php echo wpinv_html_date_field( array(
163
+                                <?php echo wpinv_html_date_field(array(
164 164
                                     'id' => 'wpi_export_to_date',
165 165
                                     'name' => 'to_date',
166 166
                                     'data' => array(
167 167
                                         'dateFormat' => 'yy-mm-dd'
168 168
                                     ),
169
-                                    'placeholder' => __( 'To date', 'invoicing' ) )
169
+                                    'placeholder' => __('To date', 'invoicing') )
170 170
                                 ); ?>
171 171
                                 <span id="wpinv-status-wrap">
172
-                                <?php echo wpinv_html_select( array(
172
+                                <?php echo wpinv_html_select(array(
173 173
                                     'options'          => $statuses,
174 174
                                     'name'             => 'status',
175 175
                                     'id'               => 'wpi_export_status',
176 176
                                     'show_option_all'  => false,
177 177
                                     'show_option_none' => false,
178 178
                                     'class'            => 'wpi_select2',
179
-                                ) ); ?>
180
-                                <?php wp_nonce_field( 'wpi_ajax_export', 'wpi_ajax_export' ); ?>
179
+                                )); ?>
180
+                                <?php wp_nonce_field('wpi_ajax_export', 'wpi_ajax_export'); ?>
181 181
                                 </span>
182 182
                                 <span id="wpinv-submit-wrap">
183 183
                                     <input type="hidden" value="invoices" name="export" />
184
-                                    <input type="submit" value="<?php _e( 'Generate CSV', 'invoicing' ); ?>" class="button-primary" />
184
+                                    <input type="submit" value="<?php _e('Generate CSV', 'invoicing'); ?>" class="button-primary" />
185 185
                                 </span>
186 186
                             </form>
187 187
                         </div>
188 188
                     </div>
189 189
 
190 190
                     <div class="postbox wpi-export-discount-uses">
191
-                        <h2 class="hndle ui-sortabled-handle"><span><?php _e( 'Discount Use','invoicing' ); ?></span></h2>
191
+                        <h2 class="hndle ui-sortabled-handle"><span><?php _e('Discount Use', 'invoicing'); ?></span></h2>
192 192
                         <div class="inside">
193
-                            <p><?php _e( 'Download a CSV of discount uses.', 'invoicing' ); ?></p>
194
-                            <a class="button-primary" href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin-ajax.php?action=wpinv_ajax_discount_use_export' ), 'wpi_discount_ajax_export', 'wpi_discount_ajax_export' ) ); ?>"><?php _e( 'Generate CSV', 'invoicing' ); ?></a>
193
+                            <p><?php _e('Download a CSV of discount uses.', 'invoicing'); ?></p>
194
+                            <a class="button-primary" href="<?php echo esc_url(wp_nonce_url(admin_url('admin-ajax.php?action=wpinv_ajax_discount_use_export'), 'wpi_discount_ajax_export', 'wpi_discount_ajax_export')); ?>"><?php _e('Generate CSV', 'invoicing'); ?></a>
195 195
                         </div>
196 196
                     </div>
197 197
 
198
-                    <?php do_action( 'wpinv_reports_tab_export_content_bottom' ); ?>
198
+                    <?php do_action('wpinv_reports_tab_export_content_bottom'); ?>
199 199
                 </div>
200 200
             </div>
201 201
         </div>
202 202
         <?php
203 203
     }
204 204
 
205
-    public function export_location( $relative = false ) {
205
+    public function export_location($relative = false) {
206 206
         $upload_dir         = wp_upload_dir();
207
-        $export_location    = $relative ? trailingslashit( $upload_dir['baseurl'] ) . 'cache' : trailingslashit( $upload_dir['basedir'] ) . 'cache';
208
-        $export_location    = apply_filters( 'wpinv_export_location', $export_location, $relative );
207
+        $export_location    = $relative ? trailingslashit($upload_dir['baseurl']) . 'cache' : trailingslashit($upload_dir['basedir']) . 'cache';
208
+        $export_location    = apply_filters('wpinv_export_location', $export_location, $relative);
209 209
 
210
-        return trailingslashit( $export_location );
210
+        return trailingslashit($export_location);
211 211
     }
212 212
 
213 213
     public function check_export_location() {
214 214
         try {
215
-            if ( empty( $this->wp_filesystem ) ) {
216
-                return __( 'Filesystem ERROR: Could not access filesystem.', 'invoicing' );
215
+            if (empty($this->wp_filesystem)) {
216
+                return __('Filesystem ERROR: Could not access filesystem.', 'invoicing');
217 217
             }
218 218
 
219
-            if ( is_wp_error( $this->wp_filesystem ) ) {
220
-                return __( 'Filesystem ERROR: ' . $this->wp_filesystem->get_error_message(), 'invoicing' );
219
+            if (is_wp_error($this->wp_filesystem)) {
220
+                return __('Filesystem ERROR: ' . $this->wp_filesystem->get_error_message(), 'invoicing');
221 221
             }
222 222
 
223
-            $is_dir         = $this->wp_filesystem->is_dir( $this->export_dir );
224
-            $is_writeable   = $is_dir && is_writeable( $this->export_dir );
223
+            $is_dir         = $this->wp_filesystem->is_dir($this->export_dir);
224
+            $is_writeable   = $is_dir && is_writeable($this->export_dir);
225 225
 
226
-            if ( $is_dir && $is_writeable ) {
226
+            if ($is_dir && $is_writeable) {
227 227
                return true;
228
-            } else if ( $is_dir && !$is_writeable ) {
229
-               if ( !$this->wp_filesystem->chmod( $this->export_dir, FS_CHMOD_DIR ) ) {
230
-                   return wp_sprintf( __( 'Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing' ), $this->export_dir );
228
+            } else if ($is_dir && !$is_writeable) {
229
+               if (!$this->wp_filesystem->chmod($this->export_dir, FS_CHMOD_DIR)) {
230
+                   return wp_sprintf(__('Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing'), $this->export_dir);
231 231
                }
232 232
 
233 233
                return true;
234 234
             } else {
235
-                if ( !$this->wp_filesystem->mkdir( $this->export_dir, FS_CHMOD_DIR ) ) {
236
-                    return wp_sprintf( __( 'Filesystem ERROR: Could not create directory %s. This is usually due to inconsistent file permissions.', 'invoicing' ), $this->export_dir );
235
+                if (!$this->wp_filesystem->mkdir($this->export_dir, FS_CHMOD_DIR)) {
236
+                    return wp_sprintf(__('Filesystem ERROR: Could not create directory %s. This is usually due to inconsistent file permissions.', 'invoicing'), $this->export_dir);
237 237
                 }
238 238
 
239 239
                 return true;
240 240
             }
241
-        } catch ( Exception $e ) {
241
+        } catch (Exception $e) {
242 242
             return $e->getMessage();
243 243
         }
244 244
     }
@@ -246,59 +246,59 @@  discard block
 block discarded – undo
246 246
     public function ajax_export() {
247 247
         $response               = array();
248 248
         $response['success']    = false;
249
-        $response['msg']        = __( 'Invalid export request found.', 'invoicing' );
249
+        $response['msg']        = __('Invalid export request found.', 'invoicing');
250 250
 
251
-        if ( empty( $_POST['data'] ) || ! wpinv_current_user_can_manage_invoicing() ) {
252
-            wp_send_json( $response );
251
+        if (empty($_POST['data']) || !wpinv_current_user_can_manage_invoicing()) {
252
+            wp_send_json($response);
253 253
         }
254 254
 
255
-        parse_str( $_POST['data'], $data );
255
+        parse_str($_POST['data'], $data);
256 256
 
257
-        $data['step']   = !empty( $_POST['step'] ) ? absint( $_POST['step'] ) : 1;
257
+        $data['step'] = !empty($_POST['step']) ? absint($_POST['step']) : 1;
258 258
 
259
-        $_REQUEST = (array)$data;
260
-        if ( !( !empty( $_REQUEST['wpi_ajax_export'] ) && wp_verify_nonce( $_REQUEST['wpi_ajax_export'], 'wpi_ajax_export' ) ) ) {
261
-            $response['msg']    = __( 'Security check failed.', 'invoicing' );
262
-            wp_send_json( $response );
259
+        $_REQUEST = (array) $data;
260
+        if (!(!empty($_REQUEST['wpi_ajax_export']) && wp_verify_nonce($_REQUEST['wpi_ajax_export'], 'wpi_ajax_export'))) {
261
+            $response['msg'] = __('Security check failed.', 'invoicing');
262
+            wp_send_json($response);
263 263
         }
264 264
 
265
-        if ( ( $error = $this->check_export_location( true ) ) !== true ) {
266
-            $response['msg'] = __( 'Filesystem ERROR: ' . $error, 'invoicing' );
267
-            wp_send_json( $response );
265
+        if (($error = $this->check_export_location(true)) !== true) {
266
+            $response['msg'] = __('Filesystem ERROR: ' . $error, 'invoicing');
267
+            wp_send_json($response);
268 268
         }
269 269
 
270
-        $this->set_export_params( $_REQUEST );
270
+        $this->set_export_params($_REQUEST);
271 271
 
272 272
         $return = $this->process_export_step();
273 273
         $done   = $this->get_export_status();
274 274
 
275
-        if ( $return ) {
275
+        if ($return) {
276 276
             $this->step += 1;
277 277
 
278 278
             $response['success']    = true;
279 279
             $response['msg']        = '';
280 280
 
281
-            if ( $done >= 100 ) {
281
+            if ($done >= 100) {
282 282
                 $this->step     = 'done';
283
-                $new_filename   = 'wpi-' . $this->export . '-' . date( 'y-m-d-H-i' ) . '.' . $this->filetype;
283
+                $new_filename   = 'wpi-' . $this->export . '-' . date('y-m-d-H-i') . '.' . $this->filetype;
284 284
                 $new_file       = $this->export_dir . $new_filename;
285 285
 
286
-                if ( file_exists( $this->file ) ) {
287
-                    $this->wp_filesystem->move( $this->file, $new_file, true );
286
+                if (file_exists($this->file)) {
287
+                    $this->wp_filesystem->move($this->file, $new_file, true);
288 288
                 }
289 289
 
290
-                if ( file_exists( $new_file ) ) {
291
-                    $response['data']['file'] = array( 'u' => $this->export_url . $new_filename, 's' => size_format( filesize( $new_file ), 2 ) );
290
+                if (file_exists($new_file)) {
291
+                    $response['data']['file'] = array('u' => $this->export_url . $new_filename, 's' => size_format(filesize($new_file), 2));
292 292
                 }
293 293
             }
294 294
 
295 295
             $response['data']['step']   = $this->step;
296 296
             $response['data']['done']   = $done;
297 297
         } else {
298
-            $response['msg']    = __( 'No data found for export.', 'invoicing' );
298
+            $response['msg'] = __('No data found for export.', 'invoicing');
299 299
         }
300 300
 
301
-        wp_send_json( $response );
301
+        wp_send_json($response);
302 302
     }
303 303
 
304 304
     /**
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
      */
307 307
     public function discount_use_export() {
308 308
 
309
-        if ( ! wp_verify_nonce( $_GET['wpi_discount_ajax_export'], 'wpi_discount_ajax_export' ) || ! wpinv_current_user_can_manage_invoicing() ) {
309
+        if (!wp_verify_nonce($_GET['wpi_discount_ajax_export'], 'wpi_discount_ajax_export') || !wpinv_current_user_can_manage_invoicing()) {
310 310
             wp_die( -1, 403 );
311 311
         }
312 312
 
@@ -316,115 +316,115 @@  discard block
 block discarded – undo
316 316
             'posts_per_page' => -1,
317 317
         );
318 318
 
319
-        $discounts = get_posts( $args );
319
+        $discounts = get_posts($args);
320 320
 
321
-        if ( empty( $discounts ) ) {
322
-            die ( __( 'You have not set up any discounts', 'invoicing' ) );
321
+        if (empty($discounts)) {
322
+            die (__('You have not set up any discounts', 'invoicing'));
323 323
         }
324 324
 
325
-        $output  = fopen( 'php://output', 'w' ) or die( 'Unsupported server' );
325
+        $output = fopen('php://output', 'w') or die('Unsupported server');
326 326
 
327 327
         // Let the browser know what content we're streaming and how it should save the content.
328 328
 		$name = time();
329
-		header( "Content-Type:application/csv" );
330
-        header( "Content-Disposition:attachment;filename=getpaid-discounts-$name.csv" );
329
+		header("Content-Type:application/csv");
330
+        header("Content-Disposition:attachment;filename=getpaid-discounts-$name.csv");
331 331
 
332 332
         // Output the csv column headers.
333 333
 		fputcsv(
334 334
             $output,
335 335
             array(
336
-                __( 'Discount Id', 'invoicing' ),
337
-                __( 'Discount Code', 'invoicing' ),
338
-                __( 'Discount Type', 'invoicing' ),
339
-                __( 'Discount Amount', 'invoicing' ),
340
-                __( 'Uses', 'invoicing' ),
336
+                __('Discount Id', 'invoicing'),
337
+                __('Discount Code', 'invoicing'),
338
+                __('Discount Type', 'invoicing'),
339
+                __('Discount Amount', 'invoicing'),
340
+                __('Uses', 'invoicing'),
341 341
             )
342 342
         );
343 343
 
344
-        foreach ( $discounts as $discount ) {
344
+        foreach ($discounts as $discount) {
345 345
 
346 346
             $discount = (int) $discount;
347 347
             $row      = array(
348 348
                 $discount,
349
-                get_post_meta( $discount, '_wpi_discount_code', true ),
350
-                get_post_meta( $discount, '_wpi_discount_type', true ),
351
-                get_post_meta( $discount, '_wpi_discount_amount', true ),
352
-                (int) get_post_meta( $discount, '_wpi_discount_uses', true )
349
+                get_post_meta($discount, '_wpi_discount_code', true),
350
+                get_post_meta($discount, '_wpi_discount_type', true),
351
+                get_post_meta($discount, '_wpi_discount_amount', true),
352
+                (int) get_post_meta($discount, '_wpi_discount_uses', true)
353 353
             );
354
-            fputcsv( $output, $row );
354
+            fputcsv($output, $row);
355 355
         }
356 356
 
357
-        fclose( $output );
357
+        fclose($output);
358 358
         exit;
359 359
 
360 360
     }
361 361
 
362
-    public function set_export_params( $request ) {
362
+    public function set_export_params($request) {
363 363
         $this->empty    = false;
364
-        $this->step     = !empty( $request['step'] ) ? absint( $request['step'] ) : 1;
365
-        $this->export   = !empty( $request['export'] ) ? $request['export'] : $this->export;
364
+        $this->step     = !empty($request['step']) ? absint($request['step']) : 1;
365
+        $this->export   = !empty($request['export']) ? $request['export'] : $this->export;
366 366
         $this->filename = 'wpi-' . $this->export . '-' . $request['wpi_ajax_export'] . '.' . $this->filetype;
367 367
         $this->file     = $this->export_dir . $this->filename;
368 368
 
369
-        do_action( 'wpinv_export_set_params_' . $this->export, $request );
369
+        do_action('wpinv_export_set_params_' . $this->export, $request);
370 370
     }
371 371
 
372 372
     public function get_columns() {
373 373
         $columns = array();
374 374
 
375
-        return apply_filters( 'wpinv_export_get_columns_' . $this->export, $columns );
375
+        return apply_filters('wpinv_export_get_columns_' . $this->export, $columns);
376 376
     }
377 377
 
378 378
     protected function get_export_file() {
379 379
         $file = '';
380 380
 
381
-        if ( $this->wp_filesystem->exists( $this->file ) ) {
382
-            $file = $this->wp_filesystem->get_contents( $this->file );
381
+        if ($this->wp_filesystem->exists($this->file)) {
382
+            $file = $this->wp_filesystem->get_contents($this->file);
383 383
         } else {
384
-            $this->wp_filesystem->put_contents( $this->file, '' );
384
+            $this->wp_filesystem->put_contents($this->file, '');
385 385
         }
386 386
 
387 387
         return $file;
388 388
     }
389 389
 
390
-    protected function attach_export_data( $data = '' ) {
391
-        $filedata   = $this->get_export_file();
392
-        $filedata   .= $data;
390
+    protected function attach_export_data($data = '') {
391
+        $filedata = $this->get_export_file();
392
+        $filedata .= $data;
393 393
 
394
-        $this->wp_filesystem->put_contents( $this->file, $filedata );
394
+        $this->wp_filesystem->put_contents($this->file, $filedata);
395 395
 
396
-        $rows       = file( $this->file, FILE_SKIP_EMPTY_LINES );
396
+        $rows       = file($this->file, FILE_SKIP_EMPTY_LINES);
397 397
         $columns    = $this->get_columns();
398
-        $columns    = empty( $columns ) ? 0 : 1;
398
+        $columns    = empty($columns) ? 0 : 1;
399 399
 
400
-        $this->empty = count( $rows ) == $columns ? true : false;
400
+        $this->empty = count($rows) == $columns ? true : false;
401 401
     }
402 402
 
403 403
     public function print_columns() {
404 404
         $column_data    = '';
405 405
         $columns        = $this->get_columns();
406 406
         $i              = 1;
407
-        foreach( $columns as $key => $column ) {
408
-            $column_data .= '"' . addslashes( $column ) . '"';
409
-            $column_data .= $i == count( $columns ) ? '' : ',';
407
+        foreach ($columns as $key => $column) {
408
+            $column_data .= '"' . addslashes($column) . '"';
409
+            $column_data .= $i == count($columns) ? '' : ',';
410 410
             $i++;
411 411
         }
412 412
         $column_data .= "\r\n";
413 413
 
414
-        $this->attach_export_data( $column_data );
414
+        $this->attach_export_data($column_data);
415 415
 
416 416
         return $column_data;
417 417
     }
418 418
 
419 419
     public function process_export_step() {
420
-        if ( $this->step < 2 ) {
421
-            /** @scrutinizer ignore-unhandled */ @unlink( $this->file );
420
+        if ($this->step < 2) {
421
+            /** @scrutinizer ignore-unhandled */ @unlink($this->file);
422 422
             $this->print_columns();
423 423
         }
424 424
 
425 425
         $return = $this->print_rows();
426 426
 
427
-        if ( $return ) {
427
+        if ($return) {
428 428
             return true;
429 429
         } else {
430 430
             return false;
@@ -433,14 +433,14 @@  discard block
 block discarded – undo
433 433
 
434 434
     public function get_export_status() {
435 435
         $status = 100;
436
-        return apply_filters( 'wpinv_get_export_status_' . $this->export, $status );
436
+        return apply_filters('wpinv_get_export_status_' . $this->export, $status);
437 437
     }
438 438
 
439 439
     public function get_export_data() {
440 440
         $data = array();
441 441
 
442
-        $data = apply_filters( 'wpinv_export_get_data', $data );
443
-        $data = apply_filters( 'wpinv_export_get_data_' . $this->export, $data );
442
+        $data = apply_filters('wpinv_export_get_data', $data);
443
+        $data = apply_filters('wpinv_export_get_data_' . $this->export, $data);
444 444
 
445 445
         return $data;
446 446
     }
@@ -450,20 +450,20 @@  discard block
 block discarded – undo
450 450
         $data       = $this->get_export_data();
451 451
         $columns    = $this->get_columns();
452 452
 
453
-        if ( $data ) {
454
-            foreach ( $data as $row ) {
453
+        if ($data) {
454
+            foreach ($data as $row) {
455 455
                 $i = 1;
456
-                foreach ( $row as $key => $column ) {
457
-                    if ( array_key_exists( $key, $columns ) ) {
458
-                        $row_data .= '"' . addslashes( preg_replace( "/\"/","'", $column ) ) . '"';
459
-                        $row_data .= $i == count( $columns ) ? '' : ',';
456
+                foreach ($row as $key => $column) {
457
+                    if (array_key_exists($key, $columns)) {
458
+                        $row_data .= '"' . addslashes(preg_replace("/\"/", "'", $column)) . '"';
459
+                        $row_data .= $i == count($columns) ? '' : ',';
460 460
                         $i++;
461 461
                     }
462 462
                 }
463 463
                 $row_data .= "\r\n";
464 464
             }
465 465
 
466
-            $this->attach_export_data( $row_data );
466
+            $this->attach_export_data($row_data);
467 467
 
468 468
             return $row_data;
469 469
         }
@@ -472,48 +472,48 @@  discard block
 block discarded – undo
472 472
     }
473 473
 
474 474
     // Export Invoices.
475
-    public function set_invoices_export( $request ) {
476
-        $this->from_date    = isset( $request['from_date'] ) ? sanitize_text_field( $request['from_date'] ) : '';
477
-        $this->to_date      = isset( $request['to_date'] ) ? sanitize_text_field( $request['to_date'] ) : '';
478
-        $this->status       = isset( $request['status'] ) ? sanitize_text_field( $request['status'] ) : 'publish';
475
+    public function set_invoices_export($request) {
476
+        $this->from_date    = isset($request['from_date']) ? sanitize_text_field($request['from_date']) : '';
477
+        $this->to_date      = isset($request['to_date']) ? sanitize_text_field($request['to_date']) : '';
478
+        $this->status       = isset($request['status']) ? sanitize_text_field($request['status']) : 'publish';
479 479
     }
480 480
 
481
-    public function get_invoices_columns( $columns = array() ) {
481
+    public function get_invoices_columns($columns = array()) {
482 482
         $columns = array(
483
-            'id'            => __( 'ID',   'invoicing' ),
484
-            'number'        => __( 'Number',   'invoicing' ),
485
-            'date'          => __( 'Date', 'invoicing' ),
486
-            'due_date'      => __( 'Due Date', 'invoicing' ),
487
-            'completed_date'=> __( 'Payment Done Date', 'invoicing' ),
488
-            'amount'        => __( 'Amount', 'invoicing' ),
489
-            'currency'      => __( 'Currency', 'invoicing' ),
490
-            'items'        => __( 'Items', 'invoicing' ),
491
-            'status_nicename'  => __( 'Status Nicename', 'invoicing' ),
492
-            'status'        => __( 'Status', 'invoicing' ),
493
-            'tax'           => __( 'Tax', 'invoicing' ),
494
-            'discount'      => __( 'Discount', 'invoicing' ),
495
-            'user_id'       => __( 'User ID', 'invoicing' ),
496
-            'email'         => __( 'Email', 'invoicing' ),
497
-            'first_name'    => __( 'First Name', 'invoicing' ),
498
-            'last_name'     => __( 'Last Name', 'invoicing' ),
499
-            'address'       => __( 'Address', 'invoicing' ),
500
-            'city'          => __( 'City', 'invoicing' ),
501
-            'state'         => __( 'State', 'invoicing' ),
502
-            'country'       => __( 'Country', 'invoicing' ),
503
-            'zip'           => __( 'Zipcode', 'invoicing' ),
504
-            'phone'         => __( 'Phone', 'invoicing' ),
505
-            'company'       => __( 'Company', 'invoicing' ),
506
-            'vat_number'    => __( 'Vat Number', 'invoicing' ),
507
-            'ip'            => __( 'IP', 'invoicing' ),
508
-            'gateway'       => __( 'Gateway', 'invoicing' ),
509
-            'gateway_nicename'       => __( 'Gateway Nicename', 'invoicing' ),
510
-            'transaction_id'=> __( 'Transaction ID', 'invoicing' ),
483
+            'id'            => __('ID', 'invoicing'),
484
+            'number'        => __('Number', 'invoicing'),
485
+            'date'          => __('Date', 'invoicing'),
486
+            'due_date'      => __('Due Date', 'invoicing'),
487
+            'completed_date'=> __('Payment Done Date', 'invoicing'),
488
+            'amount'        => __('Amount', 'invoicing'),
489
+            'currency'      => __('Currency', 'invoicing'),
490
+            'items'        => __('Items', 'invoicing'),
491
+            'status_nicename'  => __('Status Nicename', 'invoicing'),
492
+            'status'        => __('Status', 'invoicing'),
493
+            'tax'           => __('Tax', 'invoicing'),
494
+            'discount'      => __('Discount', 'invoicing'),
495
+            'user_id'       => __('User ID', 'invoicing'),
496
+            'email'         => __('Email', 'invoicing'),
497
+            'first_name'    => __('First Name', 'invoicing'),
498
+            'last_name'     => __('Last Name', 'invoicing'),
499
+            'address'       => __('Address', 'invoicing'),
500
+            'city'          => __('City', 'invoicing'),
501
+            'state'         => __('State', 'invoicing'),
502
+            'country'       => __('Country', 'invoicing'),
503
+            'zip'           => __('Zipcode', 'invoicing'),
504
+            'phone'         => __('Phone', 'invoicing'),
505
+            'company'       => __('Company', 'invoicing'),
506
+            'vat_number'    => __('Vat Number', 'invoicing'),
507
+            'ip'            => __('IP', 'invoicing'),
508
+            'gateway'       => __('Gateway', 'invoicing'),
509
+            'gateway_nicename'       => __('Gateway Nicename', 'invoicing'),
510
+            'transaction_id'=> __('Transaction ID', 'invoicing'),
511 511
         );
512 512
 
513 513
         return $columns;
514 514
     }
515 515
 
516
-    public function get_invoices_data( $response = array() ) {
516
+    public function get_invoices_data($response = array()) {
517 517
         $args = array(
518 518
             'limit'    => $this->per_page,
519 519
             'page'     => $this->step,
@@ -521,42 +521,42 @@  discard block
 block discarded – undo
521 521
             'orderby'  => 'date',
522 522
         );
523 523
 
524
-        if ( $this->status != 'any' ) {
524
+        if ($this->status != 'any') {
525 525
             $args['status'] = $this->status;
526 526
         } else {
527
-            $args['status'] = array_keys( wpinv_get_invoice_statuses( true ) );
527
+            $args['status'] = array_keys(wpinv_get_invoice_statuses(true));
528 528
         }
529 529
 
530
-        if ( !empty( $this->from_date ) || !empty( $this->to_date ) ) {
530
+        if (!empty($this->from_date) || !empty($this->to_date)) {
531 531
             $args['date_query'] = array(
532 532
                 array(
533
-                    'after'     => date( 'Y-n-d 00:00:00', strtotime( $this->from_date ) ),
534
-                    'before'    => date( 'Y-n-d 23:59:59', strtotime( $this->to_date ) ),
533
+                    'after'     => date('Y-n-d 00:00:00', strtotime($this->from_date)),
534
+                    'before'    => date('Y-n-d 23:59:59', strtotime($this->to_date)),
535 535
                     'inclusive' => true
536 536
                 )
537 537
             );
538 538
         }
539 539
 
540
-        $invoices = wpinv_get_invoices( $args );
540
+        $invoices = wpinv_get_invoices($args);
541 541
 
542 542
         $data = array();
543 543
 
544
-        if ( !empty( $invoices ) ) {
545
-            foreach ( $invoices as $invoice ) {
544
+        if (!empty($invoices)) {
545
+            foreach ($invoices as $invoice) {
546 546
                 $items = $this->get_invoice_items($invoice);
547 547
                 $row = array(
548 548
                     'id'            => $invoice->ID,
549 549
                     'number'        => $invoice->get_number(),
550
-                    'date'          => $invoice->get_invoice_date( false ),
551
-                    'due_date'      => $invoice->get_due_date( false ),
550
+                    'date'          => $invoice->get_invoice_date(false),
551
+                    'due_date'      => $invoice->get_due_date(false),
552 552
                     'completed_date'=> $invoice->get_completed_date(),
553
-                    'amount'        => wpinv_round_amount( $invoice->get_total() ),
553
+                    'amount'        => wpinv_round_amount($invoice->get_total()),
554 554
                     'currency'      => $invoice->get_currency(),
555 555
                     'items'         => $items,
556
-                    'status_nicename' => $invoice->get_status( true ),
556
+                    'status_nicename' => $invoice->get_status(true),
557 557
                     'status'        => $invoice->get_status(),
558
-                    'tax'           => $invoice->get_tax() > 0 ? wpinv_round_amount( $invoice->get_tax() ) : '',
559
-                    'discount'      => $invoice->get_discount() > 0 ? wpinv_round_amount( $invoice->get_discount() ) : '',
558
+                    'tax'           => $invoice->get_tax() > 0 ? wpinv_round_amount($invoice->get_tax()) : '',
559
+                    'discount'      => $invoice->get_discount() > 0 ? wpinv_round_amount($invoice->get_discount()) : '',
560 560
                     'user_id'       => $invoice->get_user_id(),
561 561
                     'email'         => $invoice->get_email(),
562 562
                     'first_name'    => $invoice->get_first_name(),
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
                     'transaction_id'=> $invoice->gateway ? $invoice->get_transaction_id() : '',
576 576
                 );
577 577
 
578
-                $data[] = apply_filters( 'wpinv_export_invoice_row', $row, $invoice );
578
+                $data[] = apply_filters('wpinv_export_invoice_row', $row, $invoice);
579 579
             }
580 580
 
581 581
             return $data;
@@ -591,44 +591,44 @@  discard block
 block discarded – undo
591 591
             'return'   => 'ids',
592 592
         );
593 593
 
594
-        if ( $this->status != 'any' ) {
594
+        if ($this->status != 'any') {
595 595
             $args['status'] = $this->status;
596 596
         } else {
597
-            $args['status'] = array_keys( wpinv_get_invoice_statuses( true ) );
597
+            $args['status'] = array_keys(wpinv_get_invoice_statuses(true));
598 598
         }
599 599
 
600
-        if ( !empty( $this->from_date ) || !empty( $this->to_date ) ) {
600
+        if (!empty($this->from_date) || !empty($this->to_date)) {
601 601
             $args['date_query'] = array(
602 602
                 array(
603
-                    'after'     => date( 'Y-n-d 00:00:00', strtotime( $this->from_date ) ),
604
-                    'before'    => date( 'Y-n-d 23:59:59', strtotime( $this->to_date ) ),
603
+                    'after'     => date('Y-n-d 00:00:00', strtotime($this->from_date)),
604
+                    'before'    => date('Y-n-d 23:59:59', strtotime($this->to_date)),
605 605
                     'inclusive' => true
606 606
                 )
607 607
             );
608 608
         }
609 609
 
610
-        $invoices   = wpinv_get_invoices( $args );
611
-        $total      = !empty( $invoices ) ? count( $invoices ) : 0;
610
+        $invoices   = wpinv_get_invoices($args);
611
+        $total      = !empty($invoices) ? count($invoices) : 0;
612 612
         $status     = 100;
613 613
 
614
-        if ( $total > 0 ) {
615
-            $status = ( ( $this->per_page * $this->step ) / $total ) * 100;
614
+        if ($total > 0) {
615
+            $status = (($this->per_page * $this->step) / $total) * 100;
616 616
         }
617 617
 
618
-        if ( $status > 100 ) {
618
+        if ($status > 100) {
619 619
             $status = 100;
620 620
         }
621 621
 
622 622
         return $status;
623 623
     }
624 624
 
625
-    public function get_invoice_items($invoice){
626
-        if(!$invoice){
625
+    public function get_invoice_items($invoice) {
626
+        if (!$invoice) {
627 627
             return '';
628 628
         }
629 629
 
630 630
         $cart_details = $invoice->get_cart_details();
631
-        if(!empty($cart_details)){
631
+        if (!empty($cart_details)) {
632 632
             $cart_details = maybe_serialize($cart_details);
633 633
         } else {
634 634
             $cart_details = '';
@@ -640,14 +640,14 @@  discard block
 block discarded – undo
640 640
     /**
641 641
      * Returns the periods filter.
642 642
      */
643
-    public function period_filter( $args = array() ) {
643
+    public function period_filter($args = array()) {
644 644
 
645 645
         ob_start();
646 646
 
647 647
         echo '<form id="wpinv-graphs-filter" method="get" style="margin-bottom: 10px;" class="tablenav">';
648 648
         echo '<input type="hidden" name="page" value="wpinv-reports">';
649 649
 
650
-        foreach ( $args as $key => $val ) {
650
+        foreach ($args as $key => $val) {
651 651
             $key = esc_attr($key);
652 652
             $val = esc_attr($val);
653 653
             echo "<input type='hidden' name='$key' value='$val'>";
@@ -656,21 +656,21 @@  discard block
 block discarded – undo
656 656
         echo '<select id="wpinv-graphs-date-options" name="range" style="min-width: 200px;" onChange="this.form.submit()">';
657 657
 
658 658
         $ranges = array(
659
-            'today'        => __( 'Today', 'invoicing' ),
660
-            'yesterday'    => __( 'Yesterday', 'invoicing' ),
661
-            'this_week'    => __( 'This Week', 'invoicing' ),
662
-            'last_week'    => __( 'Last Week', 'invoicing' ),
663
-            '7_days_ago'   => __( 'Last 7 Days', 'invoicing' ),
664
-            '30_days_ago'  => __( 'Last 30 Days', 'invoicing' ),
665
-            'this_month'   => __( 'This Month', 'invoicing' ),
666
-            'this_year'    => __( 'This Year', 'invoicing' ),
667
-            'last_year'    => __( 'Last Year', 'invoicing' ),
659
+            'today'        => __('Today', 'invoicing'),
660
+            'yesterday'    => __('Yesterday', 'invoicing'),
661
+            'this_week'    => __('This Week', 'invoicing'),
662
+            'last_week'    => __('Last Week', 'invoicing'),
663
+            '7_days_ago'   => __('Last 7 Days', 'invoicing'),
664
+            '30_days_ago'  => __('Last 30 Days', 'invoicing'),
665
+            'this_month'   => __('This Month', 'invoicing'),
666
+            'this_year'    => __('This Year', 'invoicing'),
667
+            'last_year'    => __('Last Year', 'invoicing'),
668 668
         );
669 669
 
670
-        $range = isset( $_GET['range'] ) && isset( $ranges[ $_GET['range'] ] ) ? $_GET['range'] : '7_days_ago';
670
+        $range = isset($_GET['range']) && isset($ranges[$_GET['range']]) ? $_GET['range'] : '7_days_ago';
671 671
 
672
-        foreach ( $ranges as $val => $label ) {
673
-            $selected = selected( $range, $val, false );
672
+        foreach ($ranges as $val => $label) {
673
+            $selected = selected($range, $val, false);
674 674
             echo "<option value='$val' $selected>$label</option>";
675 675
         }
676 676
 
@@ -682,28 +682,28 @@  discard block
 block discarded – undo
682 682
     /**
683 683
      * Returns the the current date range.
684 684
      */
685
-    public function get_sql_clauses( $range ) {
685
+    public function get_sql_clauses($range) {
686 686
 
687 687
         $date     = 'CAST(meta.completed_date AS DATE)';
688 688
         $datetime = 'meta.completed_date';
689 689
 
690 690
         // Prepare durations.
691
-        $today                = current_time( 'Y-m-d' );
692
-        $yesterday            = date( 'Y-m-d', strtotime( '-1 day', current_time( 'timestamp' ) ) );
693
-        $sunday               = date( 'Y-m-d', strtotime( 'sunday this week', current_time( 'timestamp' ) ) );
694
-        $monday               = date( 'Y-m-d', strtotime( 'monday this week', current_time( 'timestamp' ) ) );
695
-        $last_sunday          = date( 'Y-m-d', strtotime( 'sunday last week', current_time( 'timestamp' ) ) );
696
-        $last_monday          = date( 'Y-m-d', strtotime( 'monday last week', current_time( 'timestamp' ) ) );
697
-        $seven_days_ago       = date( 'Y-m-d', strtotime( '-7 days', current_time( 'timestamp' ) ) );
698
-        $thirty_days_ago      = date( 'Y-m-d', strtotime( '-30 days', current_time( 'timestamp' ) ) );
699
-        $first_day_month  	  = date( 'Y-m-1', current_time( 'timestamp' ) );
700
-        $last_day_month  	  = date( 'Y-m-t', current_time( 'timestamp' ) );
701
-		$first_day_last_month = date( 'Y-m-d', strtotime( 'first day of last month', current_time( 'timestamp' ) ) );
702
-        $last_day_last_month  = date( 'Y-m-d', strtotime( 'last day of last month', current_time( 'timestamp' ) ) );
703
-        $first_day_year  	  = date( 'Y-1-1', current_time( 'timestamp' ) );
704
-        $last_day_year  	  = date( 'Y-12-31', current_time( 'timestamp' ) );
705
-		$first_day_last_year  = date( 'Y-m-d', strtotime( 'first day of last year', current_time( 'timestamp' ) ) );
706
-		$last_day_last_year   = date( 'Y-m-d', strtotime( 'last day of last year', current_time( 'timestamp' ) ) );
691
+        $today                = current_time('Y-m-d');
692
+        $yesterday            = date('Y-m-d', strtotime('-1 day', current_time('timestamp')));
693
+        $sunday               = date('Y-m-d', strtotime('sunday this week', current_time('timestamp')));
694
+        $monday               = date('Y-m-d', strtotime('monday this week', current_time('timestamp')));
695
+        $last_sunday          = date('Y-m-d', strtotime('sunday last week', current_time('timestamp')));
696
+        $last_monday          = date('Y-m-d', strtotime('monday last week', current_time('timestamp')));
697
+        $seven_days_ago       = date('Y-m-d', strtotime('-7 days', current_time('timestamp')));
698
+        $thirty_days_ago      = date('Y-m-d', strtotime('-30 days', current_time('timestamp')));
699
+        $first_day_month = date('Y-m-1', current_time('timestamp'));
700
+        $last_day_month  	  = date('Y-m-t', current_time('timestamp'));
701
+		$first_day_last_month = date('Y-m-d', strtotime('first day of last month', current_time('timestamp')));
702
+        $last_day_last_month = date('Y-m-d', strtotime('last day of last month', current_time('timestamp')));
703
+        $first_day_year  	  = date('Y-1-1', current_time('timestamp'));
704
+        $last_day_year = date('Y-12-31', current_time('timestamp'));
705
+		$first_day_last_year  = date('Y-m-d', strtotime('first day of last year', current_time('timestamp')));
706
+		$last_day_last_year   = date('Y-m-d', strtotime('last day of last year', current_time('timestamp')));
707 707
 
708 708
         $ranges = array(
709 709
 
@@ -759,21 +759,21 @@  discard block
 block discarded – undo
759 759
 
760 760
         );
761 761
 
762
-        if ( ! isset( $ranges[ $range ] ) ) {
762
+        if (!isset($ranges[$range])) {
763 763
             return $ranges['7_days_ago'];
764 764
         }
765
-        return $ranges[ $range ];
765
+        return $ranges[$range];
766 766
 
767 767
     }
768 768
 
769 769
     /**
770 770
      * Returns the the current date ranges results.
771 771
      */
772
-    public function get_report_results( $range ) {
772
+    public function get_report_results($range) {
773 773
         global $wpdb;
774 774
 
775 775
         $table   = $wpdb->prefix . 'getpaid_invoices';
776
-        $clauses = $this->get_sql_clauses( $range );
776
+        $clauses = $this->get_sql_clauses($range);
777 777
         $sql     = "SELECT
778 778
                 {$clauses[0]} AS completed_date,
779 779
                 SUM( meta.total ) AS total,
@@ -789,30 +789,30 @@  discard block
 block discarded – undo
789 789
             GROUP BY {$clauses[0]}
790 790
         ";
791 791
 
792
-        return $wpdb->get_results( $sql );
792
+        return $wpdb->get_results($sql);
793 793
     }
794 794
 
795 795
     /**
796 796
      * Fill nulls.
797 797
      */
798
-    public function fill_nulls( $data, $range ) {
798
+    public function fill_nulls($data, $range) {
799 799
 
800 800
         $return = array();
801 801
         $time   = current_time('timestamp');
802 802
 
803
-        switch ( $range ) {
803
+        switch ($range) {
804 804
             case 'today' :
805 805
             case 'yesterday' :
806
-                $hour  = 0;
806
+                $hour = 0;
807 807
 
808
-                while ( $hour < 23 ) {
808
+                while ($hour < 23) {
809 809
                     $amount = 0;
810
-                    if ( isset( $data[$hour] ) ) {
811
-                        $amount = floatval( $data[$hour] );
810
+                    if (isset($data[$hour])) {
811
+                        $amount = floatval($data[$hour]);
812 812
                     }
813 813
 
814
-                    $time = strtotime( "$range $hour:00:00" ) * 1000;
815
-                    $return[] = array( $time, $amount );
814
+                    $time = strtotime("$range $hour:00:00") * 1000;
815
+                    $return[] = array($time, $amount);
816 816
                     $hour++;
817 817
                 }
818 818
 
@@ -820,24 +820,24 @@  discard block
 block discarded – undo
820 820
 
821 821
             case 'this_month' :
822 822
             case 'last_month' :
823
-                $_range = str_replace( '_', ' ', $range );
824
-                $month  = date( 'n', strtotime( $_range, $time ) );
825
-                $year   = date( 'Y', strtotime( $_range, $time ) );
823
+                $_range = str_replace('_', ' ', $range);
824
+                $month  = date('n', strtotime($_range, $time));
825
+                $year   = date('Y', strtotime($_range, $time));
826 826
                 $days   = cal_days_in_month(
827
-                    defined( 'CAL_GREGORIAN' ) ? CAL_GREGORIAN : 1,
827
+                    defined('CAL_GREGORIAN') ? CAL_GREGORIAN : 1,
828 828
                     $month,
829 829
                     $year
830 830
                 );
831 831
 
832 832
                 $day = 1;
833
-                while ( $days != $day ) {
833
+                while ($days != $day) {
834 834
                     $amount = 0;
835
-                    if ( isset( $data[$day] ) ) {
836
-                        $amount = floatval( $data[$day] );
835
+                    if (isset($data[$day])) {
836
+                        $amount = floatval($data[$day]);
837 837
                     }
838 838
 
839
-                    $time = strtotime( "$year-$month-$day" ) * 1000;
840
-                    $return[] = array( $time, $amount );
839
+                    $time = strtotime("$year-$month-$day") * 1000;
840
+                    $return[] = array($time, $amount);
841 841
                     $day++;
842 842
                 }
843 843
 
@@ -845,52 +845,52 @@  discard block
 block discarded – undo
845 845
 
846 846
             case 'this_week' :
847 847
             case 'last_week' :
848
-                $_range = str_replace( '_', ' ', $range );
849
-                $days   = array( 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday' );
848
+                $_range = str_replace('_', ' ', $range);
849
+                $days   = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday');
850 850
 
851
-                foreach ( $days as $day ) {
851
+                foreach ($days as $day) {
852 852
 
853 853
                     $amount = 0;
854
-                    if ( isset( $data[ ucfirst( $day ) ] ) ) {
855
-                        $amount = floatval( $data[ ucfirst( $day ) ] );
854
+                    if (isset($data[ucfirst($day)])) {
855
+                        $amount = floatval($data[ucfirst($day)]);
856 856
                     }
857 857
 
858
-                    $time = strtotime( "$_range $day" ) * 1000;
859
-                    $return[] = array( $time, $amount );
858
+                    $time = strtotime("$_range $day") * 1000;
859
+                    $return[] = array($time, $amount);
860 860
                 }
861 861
 
862 862
                 break;
863 863
 
864 864
             case 'this_year' :
865 865
             case 'last_year' :
866
-                $_range = str_replace( '_', ' ', $range );
867
-                $year   = date( 'Y', strtotime( $_range, $time ) );
868
-                $months = array( '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12' );
866
+                $_range = str_replace('_', ' ', $range);
867
+                $year   = date('Y', strtotime($_range, $time));
868
+                $months = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12');
869 869
 
870
-                foreach ( $months as $month ) {
870
+                foreach ($months as $month) {
871 871
 
872 872
                     $amount = 0;
873
-                    if ( isset( $data[$month] ) ) {
874
-                        $amount = floatval( $data[$month] );
873
+                    if (isset($data[$month])) {
874
+                        $amount = floatval($data[$month]);
875 875
                     }
876 876
 
877
-                    $_time     = strtotime("$year-$month-01") * 1000;
878
-                    $return[] = array( $_time, $amount );
877
+                    $_time = strtotime("$year-$month-01") * 1000;
878
+                    $return[] = array($_time, $amount);
879 879
                 }
880 880
 
881 881
                 break;
882 882
             case '30_days_ago' :
883 883
                 $days = 30;
884 884
 
885
-                while ( $days > 1 ) {
885
+                while ($days > 1) {
886 886
                     $amount = 0;
887
-                    $date   = date( 'j', strtotime( "-$days days", $time ) );
888
-                    if ( isset( $data[$date] ) ) {
889
-                        $amount = floatval( $data[$date] );
887
+                    $date   = date('j', strtotime("-$days days", $time));
888
+                    if (isset($data[$date])) {
889
+                        $amount = floatval($data[$date]);
890 890
                     }
891 891
 
892
-                    $_time = strtotime( "-$days days", $time ) * 1000;
893
-                    $return[] = array( $_time, $amount );
892
+                    $_time = strtotime("-$days days", $time) * 1000;
893
+                    $return[] = array($_time, $amount);
894 894
                     $days--;
895 895
                 }
896 896
 
@@ -899,15 +899,15 @@  discard block
 block discarded – undo
899 899
             default:
900 900
                 $days = 7;
901 901
 
902
-                while ( $days > 1 ) {
902
+                while ($days > 1) {
903 903
                     $amount = 0;
904
-                    $date   = date( 'j', strtotime( "-$days days", $time ) );
905
-                    if ( isset( $data[$date] ) ) {
906
-                        $amount = floatval( $data[$date] );
904
+                    $date   = date('j', strtotime("-$days days", $time));
905
+                    if (isset($data[$date])) {
906
+                        $amount = floatval($data[$date]);
907 907
                     }
908 908
 
909
-                    $_time = strtotime( "-$days days", $time ) * 1000;
910
-                    $return[] = array( $_time, $amount );
909
+                    $_time = strtotime("-$days days", $time) * 1000;
910
+                    $return[] = array($_time, $amount);
911 911
                     $days--;
912 912
                 }
913 913
 
@@ -922,33 +922,33 @@  discard block
 block discarded – undo
922 922
      * Retrieves the stats.
923 923
      */
924 924
     public function get_stats() {
925
-        $range     = isset( $_GET['range'] ) ? $_GET['range'] : '7_days_ago';
926
-        $results   = $this->get_report_results( $range );
927
-        $earnings  = wp_list_pluck( $results, 'total', 'completed_date' );
928
-        $taxes     = wp_list_pluck( $results, 'tax', 'completed_date' );
929
-        $discounts = wp_list_pluck( $results, 'discount', 'completed_date' );
930
-        $fees      = wp_list_pluck( $results, 'fees_total', 'completed_date' );
925
+        $range     = isset($_GET['range']) ? $_GET['range'] : '7_days_ago';
926
+        $results   = $this->get_report_results($range);
927
+        $earnings  = wp_list_pluck($results, 'total', 'completed_date');
928
+        $taxes     = wp_list_pluck($results, 'tax', 'completed_date');
929
+        $discounts = wp_list_pluck($results, 'discount', 'completed_date');
930
+        $fees      = wp_list_pluck($results, 'fees_total', 'completed_date');
931 931
 
932 932
         return array(
933 933
 
934 934
             array(
935
-                'label' => __( 'Earnings', 'invoicing' ),
936
-                'data'  => $this->fill_nulls( $earnings, $range ),
935
+                'label' => __('Earnings', 'invoicing'),
936
+                'data'  => $this->fill_nulls($earnings, $range),
937 937
             ),
938 938
 
939 939
             array(
940
-                'label' => __( 'Taxes', 'invoicing' ),
941
-                'data'  => $this->fill_nulls( $taxes, $range ),
940
+                'label' => __('Taxes', 'invoicing'),
941
+                'data'  => $this->fill_nulls($taxes, $range),
942 942
             ),
943 943
 
944 944
             array(
945
-                'label' => __( 'Discounts', 'invoicing' ),
946
-                'data'  => $this->fill_nulls( $discounts, $range ),
945
+                'label' => __('Discounts', 'invoicing'),
946
+                'data'  => $this->fill_nulls($discounts, $range),
947 947
             ),
948 948
 
949 949
             array(
950
-                'label' => __( 'Fees', 'invoicing' ),
951
-                'data'  => $this->fill_nulls( $fees, $range ),
950
+                'label' => __('Fees', 'invoicing'),
951
+                'data'  => $this->fill_nulls($fees, $range),
952 952
             )
953 953
         );
954 954
 
@@ -958,34 +958,34 @@  discard block
 block discarded – undo
958 958
      * Retrieves the time format for stats.
959 959
      */
960 960
     public function get_time_format() {
961
-        $range    = isset( $_GET['range'] ) ? $_GET['range'] : '7_days_ago';
961
+        $range = isset($_GET['range']) ? $_GET['range'] : '7_days_ago';
962 962
 
963
-        switch ( $range ) {
963
+        switch ($range) {
964 964
             case 'today' :
965 965
             case 'yesterday' :
966
-                return array( 'hour', '%h %p' );
966
+                return array('hour', '%h %p');
967 967
                 break;
968 968
 
969 969
             case 'this_month' :
970 970
             case 'last_month' :
971
-                return array( 'day', '%b %d' );
971
+                return array('day', '%b %d');
972 972
                 break;
973 973
 
974 974
             case 'this_week' :
975 975
             case 'last_week' :
976
-                return array( 'day', '%b %d' );
976
+                return array('day', '%b %d');
977 977
                 break;
978 978
 
979 979
             case 'this_year' :
980 980
             case 'last_year' :
981
-                return array( 'month', '%b' );
981
+                return array('month', '%b');
982 982
                 break;
983 983
             case '30_days_ago' :
984
-                return array( 'day', '%b %d' );
984
+                return array('day', '%b %d');
985 985
                 break;
986 986
 
987 987
             default:
988
-                return array( 'day', '%b %d' );
988
+                return array('day', '%b %d');
989 989
                 break;
990 990
 
991 991
         }
@@ -996,11 +996,11 @@  discard block
 block discarded – undo
996 996
      */
997 997
     public function earnings_report() {
998 998
 
999
-        $data        = wp_json_encode( $this->get_stats() );
999
+        $data        = wp_json_encode($this->get_stats());
1000 1000
         $time_format = $this->get_time_format();
1001 1001
         echo '
1002 1002
             <div class="wpinv-report-container">
1003
-                <h3><span>' . __( 'Earnings Over Time', 'invoicing' ) .'</span></h3>
1003
+                <h3><span>' . __('Earnings Over Time', 'invoicing') . '</span></h3>
1004 1004
                 ' . $this->period_filter() . '
1005 1005
                 <div id="wpinv_report_graph" style="height: 450px;"></div>
1006 1006
             </div>
@@ -1009,12 +1009,12 @@  discard block
 block discarded – undo
1009 1009
                 jQuery(document).ready( function() {
1010 1010
                     jQuery.plot(
1011 1011
                         jQuery("#wpinv_report_graph"),
1012
-                        ' . $data .',
1012
+                        ' . $data . ',
1013 1013
                         {
1014 1014
                             xaxis:{
1015 1015
                                 mode: "time",
1016
-                                timeformat: "' . $time_format[1] .'",
1017
-                                minTickSize: [0.5, "' . $time_format[0] .'"]
1016
+                                timeformat: "' . $time_format[1] . '",
1017
+                                minTickSize: [0.5, "' . $time_format[0] . '"]
1018 1018
                             },
1019 1019
 
1020 1020
                             yaxis: {
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
      * Displays the gateways report.
1043 1043
      */
1044 1044
     public function gateways_report() {
1045
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-gateways-report-table.php' );
1045
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-gateways-report-table.php');
1046 1046
 
1047 1047
         $table = new WPInv_Gateways_Report_Table();
1048 1048
         $table->prepare_items();
@@ -1053,12 +1053,12 @@  discard block
 block discarded – undo
1053 1053
      * Displays the items report.
1054 1054
      */
1055 1055
     public function items_report() {
1056
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-items-report-table.php' );
1056
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-items-report-table.php');
1057 1057
 
1058 1058
         $table = new WPInv_Items_Report_Table();
1059 1059
         $table->prepare_items();
1060 1060
         $table->display();
1061
-        echo __( '* Items with no sales not shown.', 'invoicing' );
1061
+        echo __('* Items with no sales not shown.', 'invoicing');
1062 1062
     }
1063 1063
 
1064 1064
     /**
@@ -1068,27 +1068,27 @@  discard block
 block discarded – undo
1068 1068
      */
1069 1069
     public function tax_report() {
1070 1070
 
1071
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-taxes-report-table.php' );
1071
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-taxes-report-table.php');
1072 1072
         $table = new WPInv_Taxes_Reports_Table();
1073 1073
         $table->prepare_items();
1074
-        $year = isset( $_GET['year'] ) ? absint( $_GET['year'] ) : date( 'Y' );
1074
+        $year = isset($_GET['year']) ? absint($_GET['year']) : date('Y');
1075 1075
         ?>
1076 1076
 
1077 1077
         <div class="metabox-holder" style="padding-top: 0;">
1078 1078
             <div class="postbox">
1079
-                <h3><span><?php _e('Tax Report','invoicing' ); ?></span></h3>
1079
+                <h3><span><?php _e('Tax Report', 'invoicing'); ?></span></h3>
1080 1080
                 <div class="inside">
1081
-                    <p><?php _e( 'This report shows the total amount collected in sales tax for the given year.', 'invoicing' ); ?></p>
1081
+                    <p><?php _e('This report shows the total amount collected in sales tax for the given year.', 'invoicing'); ?></p>
1082 1082
                     <form method="get">
1083
-                        <span><?php echo $year; ?></span>: <strong><?php echo wpinv_sales_tax_for_year( $year ); ?></strong>&nbsp;&mdash;&nbsp;
1083
+                        <span><?php echo $year; ?></span>: <strong><?php echo wpinv_sales_tax_for_year($year); ?></strong>&nbsp;&mdash;&nbsp;
1084 1084
                         <select name="year">
1085
-                            <?php for ( $i = 2014; $i <= date( 'Y' ); $i++ ) : ?>
1086
-                            <option value="<?php echo $i; ?>"<?php selected( $year, $i ); ?>><?php echo $i; ?></option>
1085
+                            <?php for ($i = 2014; $i <= date('Y'); $i++) : ?>
1086
+                            <option value="<?php echo $i; ?>"<?php selected($year, $i); ?>><?php echo $i; ?></option>
1087 1087
                             <?php endfor; ?>
1088 1088
                         </select>
1089 1089
                         <input type="hidden" name="view" value="taxes" />
1090 1090
                         <input type="hidden" name="page" value="wpinv-reports"/>
1091
-                        <?php submit_button( __( 'Submit', 'invoicing' ), 'secondary', 'submit', false ); ?>
1091
+                        <?php submit_button(__('Submit', 'invoicing'), 'secondary', 'submit', false); ?>
1092 1092
                     </form>
1093 1093
                 </div><!-- .inside -->
1094 1094
             </div><!-- .postbox -->
Please login to merge, or discard this patch.
includes/class-wpinv.php 2 patches
Indentation   +478 added lines, -478 removed lines patch added patch discarded remove patch
@@ -14,421 +14,421 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class WPInv_Plugin {
16 16
 
17
-	/**
18
-	 * GetPaid version.
19
-	 *
20
-	 * @var string
21
-	 */
22
-	public $version;
23
-
24
-	/**
25
-	 * Data container.
26
-	 *
27
-	 * @var array
28
-	 */
29
-	protected $data = array();
30
-
31
-	/**
32
-	 * Form elements instance.
33
-	 *
34
-	 * @var WPInv_Payment_Form_Elements
35
-	 */
36
-	public $form_elements;
37
-
38
-	/**
39
-	 * Tax instance.
40
-	 *
41
-	 * @var WPInv_EUVat
42
-	 */
43
-	public $tax;
44
-
45
-	/**
46
-	 * @param array An array of payment gateways.
47
-	 */
48
-	public $gateways;
49
-
50
-	/**
51
-	 * Class constructor.
52
-	 */
53
-	public function __construct() {
54
-		$this->define_constants();
55
-		$this->includes();
56
-		$this->init_hooks();
57
-		$this->set_properties();
58
-	}
59
-
60
-	/**
61
-	 * Sets a custom data property.
62
-	 * 
63
-	 * @param string $prop The prop to set.
64
-	 * @param mixed $value The value to retrieve.
65
-	 */
66
-	public function set( $prop, $value ) {
67
-		$this->data[ $prop ] = $value;
68
-	}
69
-
70
-	/**
71
-	 * Gets a custom data property.
72
-	 *
73
-	 * @param string $prop The prop to set.
74
-	 * @return mixed The value.
75
-	 */
76
-	public function get( $prop ) {
77
-
78
-		if ( isset( $this->data[ $prop ] ) ) {
79
-			return $this->data[ $prop ];
80
-		}
81
-
82
-		return null;
83
-	}
84
-
85
-	/**
86
-	 * Define class properties.
87
-	 */
88
-	public function set_properties() {
89
-
90
-		// Sessions.
91
-		$this->set( 'session', new WPInv_Session_Handler() );
92
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
93
-		$this->form_elements = new WPInv_Payment_Form_Elements();
94
-		$this->tax           = new WPInv_EUVat();
95
-		$this->tax->init();
96
-		$GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility.
97
-
98
-		// Init other objects.
99
-		$this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor.
100
-		$this->set( 'session', new WPInv_Session_Handler() );
101
-		$this->set( 'notes', new WPInv_Notes() );
102
-		$this->set( 'api', new WPInv_API() );
103
-		$this->set( 'post_types', new GetPaid_Post_Types() );
104
-		$this->set( 'template', new GetPaid_Template() );
105
-		$this->set( 'admin', new GetPaid_Admin() );
106
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
107
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
108
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
109
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
110
-		$this->set( 'payment_forms', new GetPaid_Payment_Forms() );
111
-
112
-	}
113
-
114
-	 /**
115
-	 * Define plugin constants.
116
-	 */
117
-	public function define_constants() {
118
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
119
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
120
-		$this->version = WPINV_VERSION;
121
-	}
122
-
123
-	/**
124
-	 * Hook into actions and filters.
125
-	 *
126
-	 * @since 1.0.19
127
-	 */
128
-	protected function init_hooks() {
129
-		/* Internationalize the text strings used. */
130
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
131
-
132
-		// Init the plugin after WordPress inits.
133
-		add_action( 'init', array( $this, 'init' ), 1 );
134
-		add_action( 'getpaid_init', array( $this, 'maybe_process_ipn' ), 5 );
135
-		add_action( 'init', array( &$this, 'wpinv_actions' ) );
136
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
137
-
138
-		if ( class_exists( 'BuddyPress' ) ) {
139
-			add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
140
-		}
141
-
142
-		add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
143
-		add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
144
-		add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
145
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
146
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
147
-
148
-		// Fires after registering actions.
149
-		do_action( 'wpinv_actions', $this );
150
-		do_action( 'getpaid_actions', $this );
151
-
152
-	}
153
-
154
-	public function plugins_loaded() {
155
-		/* Internationalize the text strings used. */
156
-		$this->load_textdomain();
157
-
158
-		do_action( 'wpinv_loaded' );
159
-
160
-		// Fix oxygen page builder conflict
161
-		if ( function_exists( 'ct_css_output' ) ) {
162
-			wpinv_oxygen_fix_conflict();
163
-		}
164
-	}
165
-
166
-	/**
167
-	 * Load the translation of the plugin.
168
-	 *
169
-	 * @since 1.0
170
-	 */
171
-	public function load_textdomain( $locale = NULL ) {
172
-		if ( empty( $locale ) ) {
173
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
174
-		}
175
-
176
-		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
177
-
178
-		unload_textdomain( 'invoicing' );
179
-		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
180
-		load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
181
-
182
-		/**
183
-		 * Define language constants.
184
-		 */
185
-		require_once( WPINV_PLUGIN_DIR . 'language.php' );
186
-	}
187
-
188
-	/**
189
-	 * Include required core files used in admin and on the frontend.
190
-	 */
191
-	public function includes() {
192
-
193
-		// Start with the settings.
194
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
195
-
196
-		// Packages/libraries.
197
-		require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
198
-		require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
199
-
200
-		// Load functions.
201
-		require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
202
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
203
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
204
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
205
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
206
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
207
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
208
-		require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
209
-		require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
210
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
211
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
212
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
213
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
214
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
215
-		require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
216
-
217
-		// Register autoloader.
218
-		try {
219
-			spl_autoload_register( array( $this, 'autoload' ), true );
220
-		} catch ( Exception $e ) {
221
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
222
-		}
223
-
224
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
225
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
226
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
227
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
228
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
229
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
230
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
231
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
232
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
233
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
234
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
235
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
236
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
237
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
238
-		require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
239
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
240
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
241
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
242
-		require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
243
-		require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
244
-		require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
245
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
246
-
247
-		/**
248
-		 * Load the tax class.
249
-		 */
250
-		if ( ! class_exists( 'WPInv_EUVat' ) ) {
251
-			require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
252
-		}
253
-
254
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
255
-			GetPaid_Post_Types_Admin::init();
256
-
257
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
258
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
259
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
260
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
261
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
262
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
263
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
264
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
265
-			// load the user class only on the users.php page
266
-			global $pagenow;
267
-			if($pagenow=='users.php'){
268
-				new WPInv_Admin_Users();
269
-			}
270
-		}
271
-
272
-		// Register cli commands
273
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
274
-			require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
275
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
276
-		}
277
-
278
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
279
-	}
280
-
281
-	/**
282
-	 * Class autoloader
283
-	 *
284
-	 * @param       string $class_name The name of the class to load.
285
-	 * @access      public
286
-	 * @since       1.0.19
287
-	 * @return      void
288
-	 */
289
-	public function autoload( $class_name ) {
290
-
291
-		// Normalize the class name...
292
-		$class_name  = strtolower( $class_name );
293
-
294
-		// ... and make sure it is our class.
295
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
296
-			return;
297
-		}
298
-
299
-		// Next, prepare the file name from the class.
300
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
301
-
302
-		// Base path of the classes.
303
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
304
-
305
-		// And an array of possible locations in order of importance.
306
-		$locations = array(
307
-			"$plugin_path/includes",
308
-			"$plugin_path/includes/data-stores",
309
-			"$plugin_path/includes/gateways",
310
-			"$plugin_path/includes/api",
311
-			"$plugin_path/includes/admin",
312
-			"$plugin_path/includes/admin/meta-boxes",
313
-		);
314
-
315
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
316
-
317
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
318
-				include trailingslashit( $location ) . $file_name;
319
-				break;
320
-			}
321
-
322
-		}
323
-
324
-	}
325
-
326
-	/**
327
-	 * Inits hooks etc.
328
-	 */
329
-	public function init() {
330
-
331
-		// Fires before getpaid inits.
332
-		do_action( 'before_getpaid_init', $this );
333
-
334
-		// Load default gateways.
335
-		$gateways = apply_filters(
336
-			'getpaid_default_gateways',
337
-			array(
338
-				'manual'        => 'GetPaid_Manual_Gateway',
339
-				'paypal'        => 'GetPaid_Paypal_Gateway',
340
-				'worldpay'      => 'GetPaid_Worldpay_Gateway',
341
-				'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
342
-				'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
343
-			)
344
-		);
345
-
346
-		foreach ( $gateways as $id => $class ) {
347
-			$this->gateways[ $id ] = new $class();
348
-		}
349
-
350
-		// Fires after getpaid inits.
351
-		do_action( 'getpaid_init', $this );
352
-
353
-	}
354
-
355
-	/**
356
-	 * Checks if this is an IPN request and processes it.
357
-	 */
358
-	public function maybe_process_ipn() {
359
-
360
-		// Ensure that this is an IPN request.
361
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
362
-			return;
363
-		}
364
-
365
-		$gateway = wpinv_clean( $_GET['wpi-gateway'] );
366
-
367
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
368
-		do_action( "wpinv_verify_{$gateway}_ipn" );
369
-		exit;
370
-
371
-	}
372
-
373
-	public function enqueue_scripts() {
374
-		$suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
375
-
376
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
377
-		wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
378
-		wp_enqueue_style( 'wpinv_front_style' );
379
-
380
-		// Register scripts
381
-		wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
382
-		wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) );
383
-
384
-		$localize                         = array();
385
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
386
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
387
-		$localize['currency_symbol']      = wpinv_currency_symbol();
388
-		$localize['currency_pos']         = wpinv_currency_position();
389
-		$localize['thousand_sep']         = wpinv_thousands_separator();
390
-		$localize['decimal_sep']          = wpinv_decimal_separator();
391
-		$localize['decimals']             = wpinv_decimals();
392
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
393
-		$localize['UseTaxes']             = wpinv_use_taxes();
394
-		$localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
395
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
396
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
397
-
398
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
399
-
400
-		wp_enqueue_script( 'jquery-blockui' );
401
-		$autofill_api = wpinv_get_option('address_autofill_api');
402
-		$autofill_active = wpinv_get_option('address_autofill_active');
403
-		if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
404
-			if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
405
-				wp_dequeue_script( 'google-maps-api' );
406
-			}
407
-			wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
408
-			wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
409
-		}
410
-
411
-		wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
412
-		wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
413
-
414
-		wp_enqueue_script( 'wpinv-front-script' );
415
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
416
-
417
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
418
-		wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
419
-	}
420
-
421
-	public function wpinv_actions() {
422
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
423
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
424
-		}
425
-	}
426
-
427
-	/**
17
+    /**
18
+     * GetPaid version.
19
+     *
20
+     * @var string
21
+     */
22
+    public $version;
23
+
24
+    /**
25
+     * Data container.
26
+     *
27
+     * @var array
28
+     */
29
+    protected $data = array();
30
+
31
+    /**
32
+     * Form elements instance.
33
+     *
34
+     * @var WPInv_Payment_Form_Elements
35
+     */
36
+    public $form_elements;
37
+
38
+    /**
39
+     * Tax instance.
40
+     *
41
+     * @var WPInv_EUVat
42
+     */
43
+    public $tax;
44
+
45
+    /**
46
+     * @param array An array of payment gateways.
47
+     */
48
+    public $gateways;
49
+
50
+    /**
51
+     * Class constructor.
52
+     */
53
+    public function __construct() {
54
+        $this->define_constants();
55
+        $this->includes();
56
+        $this->init_hooks();
57
+        $this->set_properties();
58
+    }
59
+
60
+    /**
61
+     * Sets a custom data property.
62
+     * 
63
+     * @param string $prop The prop to set.
64
+     * @param mixed $value The value to retrieve.
65
+     */
66
+    public function set( $prop, $value ) {
67
+        $this->data[ $prop ] = $value;
68
+    }
69
+
70
+    /**
71
+     * Gets a custom data property.
72
+     *
73
+     * @param string $prop The prop to set.
74
+     * @return mixed The value.
75
+     */
76
+    public function get( $prop ) {
77
+
78
+        if ( isset( $this->data[ $prop ] ) ) {
79
+            return $this->data[ $prop ];
80
+        }
81
+
82
+        return null;
83
+    }
84
+
85
+    /**
86
+     * Define class properties.
87
+     */
88
+    public function set_properties() {
89
+
90
+        // Sessions.
91
+        $this->set( 'session', new WPInv_Session_Handler() );
92
+        $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
93
+        $this->form_elements = new WPInv_Payment_Form_Elements();
94
+        $this->tax           = new WPInv_EUVat();
95
+        $this->tax->init();
96
+        $GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility.
97
+
98
+        // Init other objects.
99
+        $this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor.
100
+        $this->set( 'session', new WPInv_Session_Handler() );
101
+        $this->set( 'notes', new WPInv_Notes() );
102
+        $this->set( 'api', new WPInv_API() );
103
+        $this->set( 'post_types', new GetPaid_Post_Types() );
104
+        $this->set( 'template', new GetPaid_Template() );
105
+        $this->set( 'admin', new GetPaid_Admin() );
106
+        $this->set( 'subscriptions', new WPInv_Subscriptions() );
107
+        $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
108
+        $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
109
+        $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
110
+        $this->set( 'payment_forms', new GetPaid_Payment_Forms() );
111
+
112
+    }
113
+
114
+        /**
115
+         * Define plugin constants.
116
+         */
117
+    public function define_constants() {
118
+        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
119
+        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
120
+        $this->version = WPINV_VERSION;
121
+    }
122
+
123
+    /**
124
+     * Hook into actions and filters.
125
+     *
126
+     * @since 1.0.19
127
+     */
128
+    protected function init_hooks() {
129
+        /* Internationalize the text strings used. */
130
+        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
131
+
132
+        // Init the plugin after WordPress inits.
133
+        add_action( 'init', array( $this, 'init' ), 1 );
134
+        add_action( 'getpaid_init', array( $this, 'maybe_process_ipn' ), 5 );
135
+        add_action( 'init', array( &$this, 'wpinv_actions' ) );
136
+        add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
137
+
138
+        if ( class_exists( 'BuddyPress' ) ) {
139
+            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
140
+        }
141
+
142
+        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
143
+        add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
144
+        add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
145
+        add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
146
+        add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
147
+
148
+        // Fires after registering actions.
149
+        do_action( 'wpinv_actions', $this );
150
+        do_action( 'getpaid_actions', $this );
151
+
152
+    }
153
+
154
+    public function plugins_loaded() {
155
+        /* Internationalize the text strings used. */
156
+        $this->load_textdomain();
157
+
158
+        do_action( 'wpinv_loaded' );
159
+
160
+        // Fix oxygen page builder conflict
161
+        if ( function_exists( 'ct_css_output' ) ) {
162
+            wpinv_oxygen_fix_conflict();
163
+        }
164
+    }
165
+
166
+    /**
167
+     * Load the translation of the plugin.
168
+     *
169
+     * @since 1.0
170
+     */
171
+    public function load_textdomain( $locale = NULL ) {
172
+        if ( empty( $locale ) ) {
173
+            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
174
+        }
175
+
176
+        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
177
+
178
+        unload_textdomain( 'invoicing' );
179
+        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
180
+        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
181
+
182
+        /**
183
+         * Define language constants.
184
+         */
185
+        require_once( WPINV_PLUGIN_DIR . 'language.php' );
186
+    }
187
+
188
+    /**
189
+     * Include required core files used in admin and on the frontend.
190
+     */
191
+    public function includes() {
192
+
193
+        // Start with the settings.
194
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
195
+
196
+        // Packages/libraries.
197
+        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
198
+        require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
199
+
200
+        // Load functions.
201
+        require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
202
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
203
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
204
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
205
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
206
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
207
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
208
+        require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
209
+        require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
210
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
211
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
212
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
213
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
214
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
215
+        require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
216
+
217
+        // Register autoloader.
218
+        try {
219
+            spl_autoload_register( array( $this, 'autoload' ), true );
220
+        } catch ( Exception $e ) {
221
+            wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
222
+        }
223
+
224
+        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
225
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
226
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
227
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
228
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
229
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
230
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
231
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
232
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
233
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
234
+        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
235
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
236
+        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
237
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
238
+        require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
239
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
240
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
241
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
242
+        require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
243
+        require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
244
+        require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
245
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
246
+
247
+        /**
248
+         * Load the tax class.
249
+         */
250
+        if ( ! class_exists( 'WPInv_EUVat' ) ) {
251
+            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
252
+        }
253
+
254
+        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
255
+            GetPaid_Post_Types_Admin::init();
256
+
257
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
258
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
259
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
260
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
261
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
262
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
263
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
264
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
265
+            // load the user class only on the users.php page
266
+            global $pagenow;
267
+            if($pagenow=='users.php'){
268
+                new WPInv_Admin_Users();
269
+            }
270
+        }
271
+
272
+        // Register cli commands
273
+        if ( defined( 'WP_CLI' ) && WP_CLI ) {
274
+            require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
275
+            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
276
+        }
277
+
278
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
279
+    }
280
+
281
+    /**
282
+     * Class autoloader
283
+     *
284
+     * @param       string $class_name The name of the class to load.
285
+     * @access      public
286
+     * @since       1.0.19
287
+     * @return      void
288
+     */
289
+    public function autoload( $class_name ) {
290
+
291
+        // Normalize the class name...
292
+        $class_name  = strtolower( $class_name );
293
+
294
+        // ... and make sure it is our class.
295
+        if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
296
+            return;
297
+        }
298
+
299
+        // Next, prepare the file name from the class.
300
+        $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
301
+
302
+        // Base path of the classes.
303
+        $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
304
+
305
+        // And an array of possible locations in order of importance.
306
+        $locations = array(
307
+            "$plugin_path/includes",
308
+            "$plugin_path/includes/data-stores",
309
+            "$plugin_path/includes/gateways",
310
+            "$plugin_path/includes/api",
311
+            "$plugin_path/includes/admin",
312
+            "$plugin_path/includes/admin/meta-boxes",
313
+        );
314
+
315
+        foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
316
+
317
+            if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
318
+                include trailingslashit( $location ) . $file_name;
319
+                break;
320
+            }
321
+
322
+        }
323
+
324
+    }
325
+
326
+    /**
327
+     * Inits hooks etc.
328
+     */
329
+    public function init() {
330
+
331
+        // Fires before getpaid inits.
332
+        do_action( 'before_getpaid_init', $this );
333
+
334
+        // Load default gateways.
335
+        $gateways = apply_filters(
336
+            'getpaid_default_gateways',
337
+            array(
338
+                'manual'        => 'GetPaid_Manual_Gateway',
339
+                'paypal'        => 'GetPaid_Paypal_Gateway',
340
+                'worldpay'      => 'GetPaid_Worldpay_Gateway',
341
+                'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
342
+                'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
343
+            )
344
+        );
345
+
346
+        foreach ( $gateways as $id => $class ) {
347
+            $this->gateways[ $id ] = new $class();
348
+        }
349
+
350
+        // Fires after getpaid inits.
351
+        do_action( 'getpaid_init', $this );
352
+
353
+    }
354
+
355
+    /**
356
+     * Checks if this is an IPN request and processes it.
357
+     */
358
+    public function maybe_process_ipn() {
359
+
360
+        // Ensure that this is an IPN request.
361
+        if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
362
+            return;
363
+        }
364
+
365
+        $gateway = wpinv_clean( $_GET['wpi-gateway'] );
366
+
367
+        do_action( 'wpinv_verify_payment_ipn', $gateway );
368
+        do_action( "wpinv_verify_{$gateway}_ipn" );
369
+        exit;
370
+
371
+    }
372
+
373
+    public function enqueue_scripts() {
374
+        $suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
375
+
376
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
377
+        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
378
+        wp_enqueue_style( 'wpinv_front_style' );
379
+
380
+        // Register scripts
381
+        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
382
+        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) );
383
+
384
+        $localize                         = array();
385
+        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
386
+        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
387
+        $localize['currency_symbol']      = wpinv_currency_symbol();
388
+        $localize['currency_pos']         = wpinv_currency_position();
389
+        $localize['thousand_sep']         = wpinv_thousands_separator();
390
+        $localize['decimal_sep']          = wpinv_decimal_separator();
391
+        $localize['decimals']             = wpinv_decimals();
392
+        $localize['txtComplete']          = __( 'Continue', 'invoicing' );
393
+        $localize['UseTaxes']             = wpinv_use_taxes();
394
+        $localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
395
+        $localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
396
+        $localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
397
+
398
+        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
399
+
400
+        wp_enqueue_script( 'jquery-blockui' );
401
+        $autofill_api = wpinv_get_option('address_autofill_api');
402
+        $autofill_active = wpinv_get_option('address_autofill_active');
403
+        if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
404
+            if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
405
+                wp_dequeue_script( 'google-maps-api' );
406
+            }
407
+            wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
408
+            wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
409
+        }
410
+
411
+        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
412
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
413
+
414
+        wp_enqueue_script( 'wpinv-front-script' );
415
+        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
416
+
417
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
418
+        wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
419
+    }
420
+
421
+    public function wpinv_actions() {
422
+        if ( isset( $_REQUEST['wpi_action'] ) ) {
423
+            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
424
+        }
425
+    }
426
+
427
+    /**
428 428
      * Fires an action after verifying that a user can fire them.
429
-	 *
430
-	 * Note: If the action is on an invoice, subscription etc, esure that the
431
-	 * current user owns the invoice/subscription.
429
+     *
430
+     * Note: If the action is on an invoice, subscription etc, esure that the
431
+     * current user owns the invoice/subscription.
432 432
      */
433 433
     public function maybe_do_authenticated_action() {
434 434
 
@@ -439,82 +439,82 @@  discard block
 block discarded – undo
439 439
 
440 440
     }
441 441
 
442
-	public function pre_get_posts( $wp_query ) {
443
-		if ( ! is_admin() && !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
444
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
445
-		}
446
-
447
-		return $wp_query;
448
-	}
449
-
450
-	public function bp_invoicing_init() {
451
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
452
-	}
453
-
454
-	/**
455
-	 * Register widgets
456
-	 *
457
-	 */
458
-	public function register_widgets() {
459
-		$widgets = apply_filters(
460
-			'getpaid_widget_classes',
461
-			array(
462
-				'WPInv_Checkout_Widget',
463
-				'WPInv_History_Widget',
464
-				'WPInv_Receipt_Widget',
465
-				'WPInv_Subscriptions_Widget',
466
-				'WPInv_Buy_Item_Widget',
467
-				'WPInv_Messages_Widget',
468
-				'WPInv_GetPaid_Widget'
469
-			)
470
-		);
471
-
472
-		foreach ( $widgets as $widget ) {
473
-			register_widget( $widget );
474
-		}
442
+    public function pre_get_posts( $wp_query ) {
443
+        if ( ! is_admin() && !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
444
+            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
445
+        }
446
+
447
+        return $wp_query;
448
+    }
449
+
450
+    public function bp_invoicing_init() {
451
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
452
+    }
453
+
454
+    /**
455
+     * Register widgets
456
+     *
457
+     */
458
+    public function register_widgets() {
459
+        $widgets = apply_filters(
460
+            'getpaid_widget_classes',
461
+            array(
462
+                'WPInv_Checkout_Widget',
463
+                'WPInv_History_Widget',
464
+                'WPInv_Receipt_Widget',
465
+                'WPInv_Subscriptions_Widget',
466
+                'WPInv_Buy_Item_Widget',
467
+                'WPInv_Messages_Widget',
468
+                'WPInv_GetPaid_Widget'
469
+            )
470
+        );
471
+
472
+        foreach ( $widgets as $widget ) {
473
+            register_widget( $widget );
474
+        }
475 475
 		
476
-	}
476
+    }
477 477
 
478
-	/**
479
-	 * Remove our pages from yoast sitemaps.
480
-	 *
481
-	 * @since 1.0.19
482
-	 * @param int[] $excluded_posts_ids
483
-	 */
484
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
478
+    /**
479
+     * Remove our pages from yoast sitemaps.
480
+     *
481
+     * @since 1.0.19
482
+     * @param int[] $excluded_posts_ids
483
+     */
484
+    public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
485 485
 
486
-		// Ensure that we have an array.
487
-		if ( ! is_array( $excluded_posts_ids ) ) {
488
-			$excluded_posts_ids = array();
489
-		}
486
+        // Ensure that we have an array.
487
+        if ( ! is_array( $excluded_posts_ids ) ) {
488
+            $excluded_posts_ids = array();
489
+        }
490 490
 
491
-		// Prepare our pages.
492
-		$our_pages = array();
491
+        // Prepare our pages.
492
+        $our_pages = array();
493 493
 
494
-		// Checkout page.
495
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
494
+        // Checkout page.
495
+        $our_pages[] = wpinv_get_option( 'checkout_page', false );
496 496
 
497
-		// Success page.
498
-		$our_pages[] = wpinv_get_option( 'success_page', false );
497
+        // Success page.
498
+        $our_pages[] = wpinv_get_option( 'success_page', false );
499 499
 
500
-		// Failure page.
501
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
500
+        // Failure page.
501
+        $our_pages[] = wpinv_get_option( 'failure_page', false );
502 502
 
503
-		// History page.
504
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
503
+        // History page.
504
+        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
505 505
 
506
-		// Subscriptions page.
507
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
506
+        // Subscriptions page.
507
+        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
508 508
 
509
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
509
+        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
510 510
 
511
-		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
512
-		return array_unique( $excluded_posts_ids );
511
+        $excluded_posts_ids = $excluded_posts_ids + $our_pages;
512
+        return array_unique( $excluded_posts_ids );
513 513
 
514
-	}
514
+    }
515 515
 
516
-	public function wp_footer() {
517
-		echo '
516
+    public function wp_footer() {
517
+        echo '
518 518
 			<div class="bsui">
519 519
 				<div  id="getpaid-payment-modal" class="modal" tabindex="-1" role="dialog">
520 520
 					<div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;">
@@ -525,6 +525,6 @@  discard block
 block discarded – undo
525 525
 				</div>
526 526
 			</div>
527 527
 		';
528
-	}
528
+    }
529 529
 
530 530
 }
Please login to merge, or discard this patch.
Spacing   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   1.0.0
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Main Invoicing class.
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 	 * @param string $prop The prop to set.
64 64
 	 * @param mixed $value The value to retrieve.
65 65
 	 */
66
-	public function set( $prop, $value ) {
67
-		$this->data[ $prop ] = $value;
66
+	public function set($prop, $value) {
67
+		$this->data[$prop] = $value;
68 68
 	}
69 69
 
70 70
 	/**
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
 	 * @param string $prop The prop to set.
74 74
 	 * @return mixed The value.
75 75
 	 */
76
-	public function get( $prop ) {
76
+	public function get($prop) {
77 77
 
78
-		if ( isset( $this->data[ $prop ] ) ) {
79
-			return $this->data[ $prop ];
78
+		if (isset($this->data[$prop])) {
79
+			return $this->data[$prop];
80 80
 		}
81 81
 
82 82
 		return null;
@@ -88,26 +88,26 @@  discard block
 block discarded – undo
88 88
 	public function set_properties() {
89 89
 
90 90
 		// Sessions.
91
-		$this->set( 'session', new WPInv_Session_Handler() );
92
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
91
+		$this->set('session', new WPInv_Session_Handler());
92
+		$GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility.
93 93
 		$this->form_elements = new WPInv_Payment_Form_Elements();
94 94
 		$this->tax           = new WPInv_EUVat();
95 95
 		$this->tax->init();
96 96
 		$GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility.
97 97
 
98 98
 		// Init other objects.
99
-		$this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor.
100
-		$this->set( 'session', new WPInv_Session_Handler() );
101
-		$this->set( 'notes', new WPInv_Notes() );
102
-		$this->set( 'api', new WPInv_API() );
103
-		$this->set( 'post_types', new GetPaid_Post_Types() );
104
-		$this->set( 'template', new GetPaid_Template() );
105
-		$this->set( 'admin', new GetPaid_Admin() );
106
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
107
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
108
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
109
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
110
-		$this->set( 'payment_forms', new GetPaid_Payment_Forms() );
99
+		$this->set('reports', new WPInv_Reports()); // TODO: Refactor.
100
+		$this->set('session', new WPInv_Session_Handler());
101
+		$this->set('notes', new WPInv_Notes());
102
+		$this->set('api', new WPInv_API());
103
+		$this->set('post_types', new GetPaid_Post_Types());
104
+		$this->set('template', new GetPaid_Template());
105
+		$this->set('admin', new GetPaid_Admin());
106
+		$this->set('subscriptions', new WPInv_Subscriptions());
107
+		$this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails());
108
+		$this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails());
109
+		$this->set('daily_maintenace', new GetPaid_Daily_Maintenance());
110
+		$this->set('payment_forms', new GetPaid_Payment_Forms());
111 111
 
112 112
 	}
113 113
 
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 	 * Define plugin constants.
116 116
 	 */
117 117
 	public function define_constants() {
118
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
119
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
118
+		define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
119
+		define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
120 120
 		$this->version = WPINV_VERSION;
121 121
 	}
122 122
 
@@ -127,27 +127,27 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	protected function init_hooks() {
129 129
 		/* Internationalize the text strings used. */
130
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
130
+		add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
131 131
 
132 132
 		// Init the plugin after WordPress inits.
133
-		add_action( 'init', array( $this, 'init' ), 1 );
134
-		add_action( 'getpaid_init', array( $this, 'maybe_process_ipn' ), 5 );
135
-		add_action( 'init', array( &$this, 'wpinv_actions' ) );
136
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
133
+		add_action('init', array($this, 'init'), 1);
134
+		add_action('getpaid_init', array($this, 'maybe_process_ipn'), 5);
135
+		add_action('init', array(&$this, 'wpinv_actions'));
136
+		add_action('init', array($this, 'maybe_do_authenticated_action'), 100);
137 137
 
138
-		if ( class_exists( 'BuddyPress' ) ) {
139
-			add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
138
+		if (class_exists('BuddyPress')) {
139
+			add_action('bp_include', array(&$this, 'bp_invoicing_init'));
140 140
 		}
141 141
 
142
-		add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
143
-		add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
144
-		add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
145
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
146
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
142
+		add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
143
+		add_action('wp_footer', array(&$this, 'wp_footer'));
144
+		add_action('widgets_init', array(&$this, 'register_widgets'));
145
+		add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids'));
146
+		add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
147 147
 
148 148
 		// Fires after registering actions.
149
-		do_action( 'wpinv_actions', $this );
150
-		do_action( 'getpaid_actions', $this );
149
+		do_action('wpinv_actions', $this);
150
+		do_action('getpaid_actions', $this);
151 151
 
152 152
 	}
153 153
 
@@ -155,10 +155,10 @@  discard block
 block discarded – undo
155 155
 		/* Internationalize the text strings used. */
156 156
 		$this->load_textdomain();
157 157
 
158
-		do_action( 'wpinv_loaded' );
158
+		do_action('wpinv_loaded');
159 159
 
160 160
 		// Fix oxygen page builder conflict
161
-		if ( function_exists( 'ct_css_output' ) ) {
161
+		if (function_exists('ct_css_output')) {
162 162
 			wpinv_oxygen_fix_conflict();
163 163
 		}
164 164
 	}
@@ -168,21 +168,21 @@  discard block
 block discarded – undo
168 168
 	 *
169 169
 	 * @since 1.0
170 170
 	 */
171
-	public function load_textdomain( $locale = NULL ) {
172
-		if ( empty( $locale ) ) {
173
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
171
+	public function load_textdomain($locale = NULL) {
172
+		if (empty($locale)) {
173
+			$locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
174 174
 		}
175 175
 
176
-		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
176
+		$locale = apply_filters('plugin_locale', $locale, 'invoicing');
177 177
 
178
-		unload_textdomain( 'invoicing' );
179
-		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
180
-		load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
178
+		unload_textdomain('invoicing');
179
+		load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
180
+		load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
181 181
 
182 182
 		/**
183 183
 		 * Define language constants.
184 184
 		 */
185
-		require_once( WPINV_PLUGIN_DIR . 'language.php' );
185
+		require_once(WPINV_PLUGIN_DIR . 'language.php');
186 186
 	}
187 187
 
188 188
 	/**
@@ -191,91 +191,91 @@  discard block
 block discarded – undo
191 191
 	public function includes() {
192 192
 
193 193
 		// Start with the settings.
194
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
194
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
195 195
 
196 196
 		// Packages/libraries.
197
-		require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
198
-		require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
197
+		require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
198
+		require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php');
199 199
 
200 200
 		// Load functions.
201
-		require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
202
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
203
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
204
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
205
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
206
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
207
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
208
-		require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
209
-		require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
210
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
211
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
212
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
213
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
214
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
215
-		require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
201
+		require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php');
202
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
203
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
204
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
205
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
206
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
207
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
208
+		require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php');
209
+		require_once(WPINV_PLUGIN_DIR . 'includes/subscription-functions.php');
210
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
211
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
212
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
213
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
214
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
215
+		require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php');
216 216
 
217 217
 		// Register autoloader.
218 218
 		try {
219
-			spl_autoload_register( array( $this, 'autoload' ), true );
220
-		} catch ( Exception $e ) {
221
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
219
+			spl_autoload_register(array($this, 'autoload'), true);
220
+		} catch (Exception $e) {
221
+			wpinv_error_log($e->getMessage(), '', __FILE__, 149, true);
222 222
 		}
223 223
 
224
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
225
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
226
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
227
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
228
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
229
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
230
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
231
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
232
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
233
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
234
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
235
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
236
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
237
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
238
-		require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
239
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
240
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
241
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
242
-		require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
243
-		require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
244
-		require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
245
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
224
+		require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php');
225
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php');
226
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
227
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
228
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
229
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
230
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
231
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
232
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
233
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
234
+		require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php');
235
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
236
+		require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php');
237
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php');
238
+		require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php');
239
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php');
240
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php');
241
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php');
242
+		require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php');
243
+		require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php');
244
+		require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php');
245
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php');
246 246
 
247 247
 		/**
248 248
 		 * Load the tax class.
249 249
 		 */
250
-		if ( ! class_exists( 'WPInv_EUVat' ) ) {
251
-			require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
250
+		if (!class_exists('WPInv_EUVat')) {
251
+			require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
252 252
 		}
253 253
 
254
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
254
+		if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
255 255
 			GetPaid_Post_Types_Admin::init();
256 256
 
257
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
258
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
259
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
260
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
261
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
262
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
263
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
264
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
257
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
258
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
259
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php');
260
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
261
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
262
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
263
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
264
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php');
265 265
 			// load the user class only on the users.php page
266 266
 			global $pagenow;
267
-			if($pagenow=='users.php'){
267
+			if ($pagenow == 'users.php') {
268 268
 				new WPInv_Admin_Users();
269 269
 			}
270 270
 		}
271 271
 
272 272
 		// Register cli commands
273
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
274
-			require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
275
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
273
+		if (defined('WP_CLI') && WP_CLI) {
274
+			require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php');
275
+			WP_CLI::add_command('invoicing', 'WPInv_CLI');
276 276
 		}
277 277
 
278
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
278
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
279 279
 	}
280 280
 
281 281
 	/**
@@ -286,21 +286,21 @@  discard block
 block discarded – undo
286 286
 	 * @since       1.0.19
287 287
 	 * @return      void
288 288
 	 */
289
-	public function autoload( $class_name ) {
289
+	public function autoload($class_name) {
290 290
 
291 291
 		// Normalize the class name...
292
-		$class_name  = strtolower( $class_name );
292
+		$class_name = strtolower($class_name);
293 293
 
294 294
 		// ... and make sure it is our class.
295
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
295
+		if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) {
296 296
 			return;
297 297
 		}
298 298
 
299 299
 		// Next, prepare the file name from the class.
300
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
300
+		$file_name = 'class-' . str_replace('_', '-', $class_name) . '.php';
301 301
 
302 302
 		// Base path of the classes.
303
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
303
+		$plugin_path = untrailingslashit(WPINV_PLUGIN_DIR);
304 304
 
305 305
 		// And an array of possible locations in order of importance.
306 306
 		$locations = array(
@@ -312,10 +312,10 @@  discard block
 block discarded – undo
312 312
 			"$plugin_path/includes/admin/meta-boxes",
313 313
 		);
314 314
 
315
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
315
+		foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) {
316 316
 
317
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
318
-				include trailingslashit( $location ) . $file_name;
317
+			if (file_exists(trailingslashit($location) . $file_name)) {
318
+				include trailingslashit($location) . $file_name;
319 319
 				break;
320 320
 			}
321 321
 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 	public function init() {
330 330
 
331 331
 		// Fires before getpaid inits.
332
-		do_action( 'before_getpaid_init', $this );
332
+		do_action('before_getpaid_init', $this);
333 333
 
334 334
 		// Load default gateways.
335 335
 		$gateways = apply_filters(
@@ -343,12 +343,12 @@  discard block
 block discarded – undo
343 343
 			)
344 344
 		);
345 345
 
346
-		foreach ( $gateways as $id => $class ) {
347
-			$this->gateways[ $id ] = new $class();
346
+		foreach ($gateways as $id => $class) {
347
+			$this->gateways[$id] = new $class();
348 348
 		}
349 349
 
350 350
 		// Fires after getpaid inits.
351
-		do_action( 'getpaid_init', $this );
351
+		do_action('getpaid_init', $this);
352 352
 
353 353
 	}
354 354
 
@@ -358,69 +358,69 @@  discard block
 block discarded – undo
358 358
 	public function maybe_process_ipn() {
359 359
 
360 360
 		// Ensure that this is an IPN request.
361
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
361
+		if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) {
362 362
 			return;
363 363
 		}
364 364
 
365
-		$gateway = wpinv_clean( $_GET['wpi-gateway'] );
365
+		$gateway = wpinv_clean($_GET['wpi-gateway']);
366 366
 
367
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
368
-		do_action( "wpinv_verify_{$gateway}_ipn" );
367
+		do_action('wpinv_verify_payment_ipn', $gateway);
368
+		do_action("wpinv_verify_{$gateway}_ipn");
369 369
 		exit;
370 370
 
371 371
 	}
372 372
 
373 373
 	public function enqueue_scripts() {
374
-		$suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
374
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
375 375
 
376
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
377
-		wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
378
-		wp_enqueue_style( 'wpinv_front_style' );
376
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css');
377
+		wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version);
378
+		wp_enqueue_style('wpinv_front_style');
379 379
 
380 380
 		// Register scripts
381
-		wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
382
-		wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) );
381
+		wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
382
+		wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), filemtime(WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js'));
383 383
 
384 384
 		$localize                         = array();
385
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
386
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
385
+		$localize['ajax_url']             = admin_url('admin-ajax.php');
386
+		$localize['nonce']                = wp_create_nonce('wpinv-nonce');
387 387
 		$localize['currency_symbol']      = wpinv_currency_symbol();
388 388
 		$localize['currency_pos']         = wpinv_currency_position();
389 389
 		$localize['thousand_sep']         = wpinv_thousands_separator();
390 390
 		$localize['decimal_sep']          = wpinv_decimal_separator();
391 391
 		$localize['decimals']             = wpinv_decimals();
392
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
392
+		$localize['txtComplete']          = __('Continue', 'invoicing');
393 393
 		$localize['UseTaxes']             = wpinv_use_taxes();
394
-		$localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
395
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
396
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
394
+		$localize['checkoutNonce']        = wp_create_nonce('wpinv_checkout_nonce');
395
+		$localize['formNonce']            = wp_create_nonce('getpaid_form_nonce');
396
+		$localize['connectionError']      = __('Could not establish a connection to the server.', 'invoicing');
397 397
 
398
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
398
+		$localize = apply_filters('wpinv_front_js_localize', $localize);
399 399
 
400
-		wp_enqueue_script( 'jquery-blockui' );
400
+		wp_enqueue_script('jquery-blockui');
401 401
 		$autofill_api = wpinv_get_option('address_autofill_api');
402 402
 		$autofill_active = wpinv_get_option('address_autofill_active');
403
-		if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
404
-			if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
405
-				wp_dequeue_script( 'google-maps-api' );
403
+		if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
404
+			if (wp_script_is('google-maps-api', 'enqueued')) {
405
+				wp_dequeue_script('google-maps-api');
406 406
 			}
407
-			wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
408
-			wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
407
+			wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
408
+			wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
409 409
 		}
410 410
 
411
-		wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
412
-		wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
411
+		wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
412
+		wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
413 413
 
414
-		wp_enqueue_script( 'wpinv-front-script' );
415
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
414
+		wp_enqueue_script('wpinv-front-script');
415
+		wp_localize_script('wpinv-front-script', 'WPInv', $localize);
416 416
 
417
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
418
-		wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
417
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js');
418
+		wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script', 'wp-hooks'), $version, true);
419 419
 	}
420 420
 
421 421
 	public function wpinv_actions() {
422
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
423
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
422
+		if (isset($_REQUEST['wpi_action'])) {
423
+			do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
424 424
 		}
425 425
 	}
426 426
 
@@ -432,23 +432,23 @@  discard block
 block discarded – undo
432 432
      */
433 433
     public function maybe_do_authenticated_action() {
434 434
 
435
-        if ( is_user_logged_in() && isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
436
-            $key = sanitize_key( $_REQUEST['getpaid-action'] );
437
-            do_action( "getpaid_authenticated_action_$key", $_REQUEST );
435
+        if (is_user_logged_in() && isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
436
+            $key = sanitize_key($_REQUEST['getpaid-action']);
437
+            do_action("getpaid_authenticated_action_$key", $_REQUEST);
438 438
         }
439 439
 
440 440
     }
441 441
 
442
-	public function pre_get_posts( $wp_query ) {
443
-		if ( ! is_admin() && !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
444
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
442
+	public function pre_get_posts($wp_query) {
443
+		if (!is_admin() && !empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
444
+			$wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
445 445
 		}
446 446
 
447 447
 		return $wp_query;
448 448
 	}
449 449
 
450 450
 	public function bp_invoicing_init() {
451
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
451
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
452 452
 	}
453 453
 
454 454
 	/**
@@ -469,8 +469,8 @@  discard block
 block discarded – undo
469 469
 			)
470 470
 		);
471 471
 
472
-		foreach ( $widgets as $widget ) {
473
-			register_widget( $widget );
472
+		foreach ($widgets as $widget) {
473
+			register_widget($widget);
474 474
 		}
475 475
 		
476 476
 	}
@@ -481,10 +481,10 @@  discard block
 block discarded – undo
481 481
 	 * @since 1.0.19
482 482
 	 * @param int[] $excluded_posts_ids
483 483
 	 */
484
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
484
+	public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) {
485 485
 
486 486
 		// Ensure that we have an array.
487
-		if ( ! is_array( $excluded_posts_ids ) ) {
487
+		if (!is_array($excluded_posts_ids)) {
488 488
 			$excluded_posts_ids = array();
489 489
 		}
490 490
 
@@ -492,24 +492,24 @@  discard block
 block discarded – undo
492 492
 		$our_pages = array();
493 493
 
494 494
 		// Checkout page.
495
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
495
+		$our_pages[] = wpinv_get_option('checkout_page', false);
496 496
 
497 497
 		// Success page.
498
-		$our_pages[] = wpinv_get_option( 'success_page', false );
498
+		$our_pages[] = wpinv_get_option('success_page', false);
499 499
 
500 500
 		// Failure page.
501
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
501
+		$our_pages[] = wpinv_get_option('failure_page', false);
502 502
 
503 503
 		// History page.
504
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
504
+		$our_pages[] = wpinv_get_option('invoice_history_page', false);
505 505
 
506 506
 		// Subscriptions page.
507
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
507
+		$our_pages[] = wpinv_get_option('invoice_subscription_page', false);
508 508
 
509
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
509
+		$our_pages   = array_map('intval', array_filter($our_pages));
510 510
 
511 511
 		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
512
-		return array_unique( $excluded_posts_ids );
512
+		return array_unique($excluded_posts_ids);
513 513
 
514 514
 	}
515 515
 
Please login to merge, or discard this patch.
includes/wpinv-email-functions.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
     $css = getpaid_get_email_css();
111 111
 
112 112
     // include css inliner
113
-	if ( ! class_exists( 'Emogrifier' ) ) {
114
-		include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
113
+    if ( ! class_exists( 'Emogrifier' ) ) {
114
+        include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
115 115
     }
116 116
 
117 117
     // Inline the css.
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
     $message = wpinv_email_style_body( $message );
191 191
     $to      = array_merge( wpinv_parse_list( $to ), wpinv_parse_list( $cc ) );
192 192
 
193
-	return $mailer->send(
193
+    return $mailer->send(
194 194
         $to,
195 195
         $subject,
196 196
         $message,
Please login to merge, or discard this patch.
Spacing   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * Please use GetPaid_Notification_Email_Sender
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /*
12 12
 |--------------------------------------------------------------------------
@@ -17,19 +17,19 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * Generates the email header.
19 19
  */
20
-function wpinv_email_header( $email_heading ) {
21
-    wpinv_get_template( 'emails/wpinv-email-header.php', compact( 'email_heading' ) );
20
+function wpinv_email_header($email_heading) {
21
+    wpinv_get_template('emails/wpinv-email-header.php', compact('email_heading'));
22 22
 }
23
-add_action( 'wpinv_email_header', 'wpinv_email_header' );
23
+add_action('wpinv_email_header', 'wpinv_email_header');
24 24
 
25 25
 
26 26
 /**
27 27
  * Generates the email footer.
28 28
  */
29 29
 function wpinv_email_footer() {
30
-    wpinv_get_template( 'emails/wpinv-email-footer.php' );
30
+    wpinv_get_template('emails/wpinv-email-footer.php');
31 31
 }
32
-add_action( 'wpinv_email_footer', 'wpinv_email_footer' );
32
+add_action('wpinv_email_footer', 'wpinv_email_footer');
33 33
 
34 34
 
35 35
 /**
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
  * @param string $email_type
40 40
  * @param bool $sent_to_admin
41 41
  */
42
-function wpinv_email_invoice_details( $invoice,  $email_type, $sent_to_admin ) {
42
+function wpinv_email_invoice_details($invoice, $email_type, $sent_to_admin) {
43 43
 
44
-    $args = compact( 'invoice', 'email_type', 'sent_to_admin' );
45
-    wpinv_get_template( 'emails/wpinv-email-invoice-details.php', $args );
44
+    $args = compact('invoice', 'email_type', 'sent_to_admin');
45
+    wpinv_get_template('emails/wpinv-email-invoice-details.php', $args);
46 46
 
47 47
 }
48
-add_action( 'wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3 );
48
+add_action('wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3);
49 49
 
50 50
 
51 51
 /**
@@ -55,17 +55,17 @@  discard block
 block discarded – undo
55 55
  * @param string $email_type
56 56
  * @param bool $sent_to_admin
57 57
  */
58
-function wpinv_email_invoice_items( $invoice, $email_type, $sent_to_admin ) {
58
+function wpinv_email_invoice_items($invoice, $email_type, $sent_to_admin) {
59 59
 
60 60
     // Prepare line items.
61
-    $columns = getpaid_invoice_item_columns( $invoice );
62
-    $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice );
61
+    $columns = getpaid_invoice_item_columns($invoice);
62
+    $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice);
63 63
 
64 64
     // Load the template.
65
-    wpinv_get_template( 'emails/wpinv-email-invoice-items.php', compact( 'invoice', 'columns', 'email_type', 'sent_to_admin' ) );
65
+    wpinv_get_template('emails/wpinv-email-invoice-items.php', compact('invoice', 'columns', 'email_type', 'sent_to_admin'));
66 66
 
67 67
 }
68
-add_action( 'wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3 );
68
+add_action('wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3);
69 69
 
70 70
 
71 71
 /**
@@ -75,13 +75,13 @@  discard block
 block discarded – undo
75 75
  * @param string $email_type
76 76
  * @param bool $sent_to_admin
77 77
  */
78
-function wpinv_email_billing_details( $invoice, $email_type, $sent_to_admin ) {
78
+function wpinv_email_billing_details($invoice, $email_type, $sent_to_admin) {
79 79
 
80
-    $args = compact( 'invoice', 'email_type', 'sent_to_admin' );
81
-    wpinv_get_template( 'emails/wpinv-email-billing-details.php', $args );
80
+    $args = compact('invoice', 'email_type', 'sent_to_admin');
81
+    wpinv_get_template('emails/wpinv-email-billing-details.php', $args);
82 82
 
83 83
 }
84
-add_action( 'wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3 );
84
+add_action('wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3);
85 85
 
86 86
 /**
87 87
  * Returns email css.
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
  */
90 90
 function getpaid_get_email_css() {
91 91
 
92
-    $css = wpinv_get_template_html( 'emails/wpinv-email-styles.php' );
93
-    return apply_filters( 'wpinv_email_styles', $css );
92
+    $css = wpinv_get_template_html('emails/wpinv-email-styles.php');
93
+    return apply_filters('wpinv_email_styles', $css);
94 94
 
95 95
 }
96 96
 
@@ -101,26 +101,26 @@  discard block
 block discarded – undo
101 101
  * @return string
102 102
  * 
103 103
  */
104
-function wpinv_email_style_body( $content ) {
104
+function wpinv_email_style_body($content) {
105 105
 
106
-    if ( ! class_exists( 'DOMDocument' ) ) {
106
+    if (!class_exists('DOMDocument')) {
107 107
         return $content;
108 108
     }
109 109
 
110 110
     $css = getpaid_get_email_css();
111 111
 
112 112
     // include css inliner
113
-	if ( ! class_exists( 'Emogrifier' ) ) {
114
-		include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
113
+	if (!class_exists('Emogrifier')) {
114
+		include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
115 115
     }
116 116
 
117 117
     // Inline the css.
118 118
     try {
119
-        $emogrifier = new Emogrifier( $content, $css );
119
+        $emogrifier = new Emogrifier($content, $css);
120 120
         $_content   = $emogrifier->emogrify();
121 121
         $content    = $_content;
122
-    } catch ( Exception $e ) {
123
-        wpinv_error_log( $e->getMessage(), 'emogrifier' );
122
+    } catch (Exception $e) {
123
+        wpinv_error_log($e->getMessage(), 'emogrifier');
124 124
     }
125 125
 
126 126
     return $content;
@@ -129,37 +129,37 @@  discard block
 block discarded – undo
129 129
 
130 130
 // Backwards compatibility.
131 131
 function wpinv_init_transactional_emails() {
132
-    foreach ( apply_filters( 'wpinv_email_actions', array() ) as $action ) {
133
-        add_action( $action, 'wpinv_send_transactional_email', 10, 10 );
132
+    foreach (apply_filters('wpinv_email_actions', array()) as $action) {
133
+        add_action($action, 'wpinv_send_transactional_email', 10, 10);
134 134
     }
135 135
 }
136
-add_action( 'init', 'wpinv_init_transactional_emails' );
136
+add_action('init', 'wpinv_init_transactional_emails');
137 137
 
138 138
 function wpinv_send_transactional_email() {
139 139
     $args       = func_get_args();
140 140
     $function   = current_filter() . '_notification';
141
-    do_action_ref_array( $function, $args );
141
+    do_action_ref_array($function, $args);
142 142
 }
143 143
 
144 144
 function wpinv_mail_get_from_address() {
145
-    $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) );
146
-    return sanitize_email( $from_address );
145
+    $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from'));
146
+    return sanitize_email($from_address);
147 147
 }
148 148
 
149 149
 function wpinv_mail_get_from_name() {
150
-    $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name' ) );
151
-    return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES );
150
+    $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name'));
151
+    return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES);
152 152
 }
153 153
 
154
-function wpinv_mail_admin_bcc_active( $mail_type = '' ) {
155
-    $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) );
156
-    return ( $active ? true : false );
154
+function wpinv_mail_admin_bcc_active($mail_type = '') {
155
+    $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc'));
156
+    return ($active ? true : false);
157 157
 }
158 158
     
159
-function wpinv_mail_get_content_type(  $content_type = 'text/html', $email_type = 'html' ) {
160
-    $email_type = apply_filters( 'wpinv_mail_content_type', $email_type );
159
+function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') {
160
+    $email_type = apply_filters('wpinv_mail_content_type', $email_type);
161 161
 
162
-    switch ( $email_type ) {
162
+    switch ($email_type) {
163 163
         case 'html' :
164 164
             $content_type = 'text/html';
165 165
             break;
@@ -184,11 +184,11 @@  discard block
 block discarded – undo
184 184
  * @param array        $attachments Any files to attach to the email.
185 185
  * @param string|array $cc An email or array of extra emails to send a copy of the email to.
186 186
  */
187
-function wpinv_mail_send( $to, $subject, $message, $deprecated, $attachments = array(), $cc = array() ) {
187
+function wpinv_mail_send($to, $subject, $message, $deprecated, $attachments = array(), $cc = array()) {
188 188
 
189 189
     $mailer  = new GetPaid_Notification_Email_Sender();
190
-    $message = wpinv_email_style_body( $message );
191
-    $to      = array_merge( wpinv_parse_list( $to ), wpinv_parse_list( $cc ) );
190
+    $message = wpinv_email_style_body($message);
191
+    $to      = array_merge(wpinv_parse_list($to), wpinv_parse_list($cc));
192 192
 
193 193
 	return $mailer->send(
194 194
         $to,
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
  * @return array
206 206
  */
207 207
 function wpinv_get_emails() {
208
-    return apply_filters( 'wpinv_get_emails', wpinv_get_data( 'email-settings' ) );
208
+    return apply_filters('wpinv_get_emails', wpinv_get_data('email-settings'));
209 209
 }
210 210
 
211 211
 /**
@@ -214,172 +214,172 @@  discard block
 block discarded – undo
214 214
  * @param array $settings
215 215
  * @return array
216 216
  */
217
-function wpinv_settings_emails( $settings = array() ) {
218
-    $settings = array_merge( $settings, wpinv_get_emails() );
219
-    return apply_filters( 'wpinv_settings_get_emails', $settings );
217
+function wpinv_settings_emails($settings = array()) {
218
+    $settings = array_merge($settings, wpinv_get_emails());
219
+    return apply_filters('wpinv_settings_get_emails', $settings);
220 220
 }
221
-add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 );
221
+add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1);
222 222
 
223 223
 /**
224 224
  * Filter email section names.
225 225
  * 
226 226
  */
227
-function wpinv_settings_sections_emails( $settings ) {
228
-    foreach  ( wpinv_get_emails() as $key => $email) {
229
-        $settings[$key] = ! empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : strip_tags( $key );
227
+function wpinv_settings_sections_emails($settings) {
228
+    foreach (wpinv_get_emails() as $key => $email) {
229
+        $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : strip_tags($key);
230 230
     }
231 231
 
232 232
     return $settings;    
233 233
 }
234
-add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 );
234
+add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1);
235 235
 
236
-function wpinv_email_is_enabled( $email_type ) {
236
+function wpinv_email_is_enabled($email_type) {
237 237
     $emails = wpinv_get_emails();
238
-    $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false;
238
+    $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false;
239 239
 
240
-    return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type );
240
+    return apply_filters('wpinv_email_is_enabled', $enabled, $email_type);
241 241
 }
242 242
 
243
-function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) {
244
-    switch ( $email_type ) {
243
+function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) {
244
+    switch ($email_type) {
245 245
         case 'new_invoice':
246 246
         case 'cancelled_invoice':
247 247
         case 'failed_invoice':
248 248
             $recipient  = wpinv_get_admin_email();
249 249
         break;
250 250
         default:
251
-            $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
252
-            $recipient  = !empty( $invoice ) ? $invoice->get_email() : '';
251
+            $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
252
+            $recipient  = !empty($invoice) ? $invoice->get_email() : '';
253 253
         break;
254 254
     }
255 255
 
256
-    return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice );
256
+    return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice);
257 257
 }
258 258
 
259 259
 /**
260 260
  * Returns invoice CC recipients
261 261
  */
262
-function wpinv_email_get_cc_recipients( $email_type = '', $invoice_id = 0, $invoice = array() ) {
263
-    switch ( $email_type ) {
262
+function wpinv_email_get_cc_recipients($email_type = '', $invoice_id = 0, $invoice = array()) {
263
+    switch ($email_type) {
264 264
         case 'new_invoice':
265 265
         case 'cancelled_invoice':
266 266
         case 'failed_invoice':
267 267
             return array();
268 268
         break;
269 269
         default:
270
-            $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
271
-            $recipient  = empty( $invoice ) ? '' : get_post_meta( $invoice->ID, 'wpinv_email_cc', true );
272
-            if ( empty( $recipient ) ) {
270
+            $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
271
+            $recipient  = empty($invoice) ? '' : get_post_meta($invoice->ID, 'wpinv_email_cc', true);
272
+            if (empty($recipient)) {
273 273
                 return array();
274 274
             }
275
-            return  array_filter( array_map( 'trim', explode( ',', $recipient ) ) );
275
+            return  array_filter(array_map('trim', explode(',', $recipient)));
276 276
         break;
277 277
     }
278 278
 
279 279
 }
280 280
 
281
-function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) {
282
-    $subject    = wpinv_get_option( 'email_' . $email_type . '_subject' );
283
-    $subject    = __( $subject, 'invoicing' );
281
+function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) {
282
+    $subject    = wpinv_get_option('email_' . $email_type . '_subject');
283
+    $subject    = __($subject, 'invoicing');
284 284
 
285
-    $subject    = wpinv_email_format_text( $subject, $invoice );
285
+    $subject    = wpinv_email_format_text($subject, $invoice);
286 286
 
287
-    return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice );
287
+    return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice);
288 288
 }
289 289
 
290
-function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) {
291
-    $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' );
292
-    $email_heading = __( $email_heading, 'invoicing' );
290
+function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) {
291
+    $email_heading = wpinv_get_option('email_' . $email_type . '_heading');
292
+    $email_heading = __($email_heading, 'invoicing');
293 293
 
294
-    $email_heading = wpinv_email_format_text( $email_heading, $invoice );
294
+    $email_heading = wpinv_email_format_text($email_heading, $invoice);
295 295
 
296
-    return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice );
296
+    return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice);
297 297
 }
298 298
 
299
-function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) {
300
-    $content    = wpinv_get_option( 'email_' . $email_type . '_body' );
301
-    $content    = __( $content, 'invoicing' );
299
+function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) {
300
+    $content    = wpinv_get_option('email_' . $email_type . '_body');
301
+    $content    = __($content, 'invoicing');
302 302
 
303
-    $content    = wpinv_email_format_text( $content, $invoice );
303
+    $content    = wpinv_email_format_text($content, $invoice);
304 304
 
305
-    return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice );
305
+    return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice);
306 306
 }
307 307
 
308
-function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) {
308
+function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) {
309 309
     $from_name = wpinv_mail_get_from_address();
310 310
     $from_email = wpinv_mail_get_from_address();
311 311
     
312
-    $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
312
+    $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
313 313
     
314
-    $headers    = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
315
-    $headers    .= "Reply-To: ". $from_email . "\r\n";
314
+    $headers    = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n";
315
+    $headers    .= "Reply-To: " . $from_email . "\r\n";
316 316
     $headers    .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n";
317 317
     
318
-    return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice );
318
+    return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice);
319 319
 }
320 320
 
321
-function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) {
321
+function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) {
322 322
     $attachments = array();
323 323
     
324
-    return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice );
324
+    return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice);
325 325
 }
326 326
 
327 327
 /**
328 328
  * Searches for and replaces certain placeholders in an email.
329 329
  */
330
-function wpinv_email_format_text( $content, $invoice ) {
330
+function wpinv_email_format_text($content, $invoice) {
331 331
 
332 332
     $replace_array = array(
333 333
         '{site_title}'      => wpinv_get_blogname(),
334
-        '{date}'            => getpaid_format_date( current_time( 'mysql' ) ),
334
+        '{date}'            => getpaid_format_date(current_time('mysql')),
335 335
     );
336 336
 
337
-    $invoice = new WPInv_Invoice( $invoice );
337
+    $invoice = new WPInv_Invoice($invoice);
338 338
 
339
-    if ( $invoice->get_id() ) {
339
+    if ($invoice->get_id()) {
340 340
 
341 341
         $replace_array = array_merge(
342 342
             $replace_array, 
343 343
             array(
344
-                '{name}'            => sanitize_text_field( $invoice->get_user_full_name() ),
345
-                '{full_name}'       => sanitize_text_field( $invoice->get_user_full_name() ),
346
-                '{first_name}'      => sanitize_text_field( $invoice->get_first_name() ),
347
-                '{last_name}'       => sanitize_text_field( $invoice->get_last_name() ),
348
-                '{email}'           => sanitize_email( $invoice->get_email() ),
349
-                '{invoice_number}'  => sanitize_text_field( $invoice->get_number() ),
350
-                '{invoice_total}'   => wpinv_price( wpinv_format_amount( $invoice->get_total( true ) ) ),
351
-                '{invoice_link}'    => esc_url( $invoice->get_view_url() ),
352
-                '{invoice_pay_link}'=> esc_url( $invoice->get_checkout_payment_url() ),
353
-                '{invoice_date}'    => date( get_option( 'date_format' ), strtotime( $invoice->get_date_created(), current_time( 'timestamp' ) ) ),
354
-                '{invoice_due_date}'=> date( get_option( 'date_format' ), strtotime( $invoice->get_due_date(), current_time( 'timestamp' ) ) ),
355
-                '{invoice_quote}'   => sanitize_text_field( $invoice->get_type() ),
356
-                '{invoice_label}'   => sanitize_text_field( ucfirst( $invoice->get_type() ) ),
357
-                '{is_was}'          => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
344
+                '{name}'            => sanitize_text_field($invoice->get_user_full_name()),
345
+                '{full_name}'       => sanitize_text_field($invoice->get_user_full_name()),
346
+                '{first_name}'      => sanitize_text_field($invoice->get_first_name()),
347
+                '{last_name}'       => sanitize_text_field($invoice->get_last_name()),
348
+                '{email}'           => sanitize_email($invoice->get_email()),
349
+                '{invoice_number}'  => sanitize_text_field($invoice->get_number()),
350
+                '{invoice_total}'   => wpinv_price(wpinv_format_amount($invoice->get_total(true))),
351
+                '{invoice_link}'    => esc_url($invoice->get_view_url()),
352
+                '{invoice_pay_link}'=> esc_url($invoice->get_checkout_payment_url()),
353
+                '{invoice_date}'    => date(get_option('date_format'), strtotime($invoice->get_date_created(), current_time('timestamp'))),
354
+                '{invoice_due_date}'=> date(get_option('date_format'), strtotime($invoice->get_due_date(), current_time('timestamp'))),
355
+                '{invoice_quote}'   => sanitize_text_field($invoice->get_type()),
356
+                '{invoice_label}'   => sanitize_text_field(ucfirst($invoice->get_type())),
357
+                '{is_was}'          => strtotime($invoice->get_due_date()) < current_time('timestamp') ? __('was', 'invoicing') : __('is', 'invoicing'),
358 358
             )
359 359
         );
360 360
 
361 361
     }
362 362
 
363 363
     // Let third party plugins filter the arra.
364
-    $replace_array = apply_filters( 'wpinv_email_format_text', $replace_array, $content, $invoice );
364
+    $replace_array = apply_filters('wpinv_email_format_text', $replace_array, $content, $invoice);
365 365
 
366
-    foreach ( $replace_array as $key => $value ) {
367
-        $content = str_replace( $key, $value, $content );
366
+    foreach ($replace_array as $key => $value) {
367
+        $content = str_replace($key, $value, $content);
368 368
     }
369 369
 
370
-    return apply_filters( 'wpinv_email_content_replace', $content );
370
+    return apply_filters('wpinv_email_content_replace', $content);
371 371
 }
372 372
 
373 373
 
374
-function wpinv_email_wrap_message( $message ) {
374
+function wpinv_email_wrap_message($message) {
375 375
     // Buffer
376 376
     ob_start();
377 377
 
378
-    do_action( 'wpinv_email_header' );
378
+    do_action('wpinv_email_header');
379 379
 
380
-    echo wpautop( wptexturize( $message ) );
380
+    echo wpautop(wptexturize($message));
381 381
 
382
-    do_action( 'wpinv_email_footer' );
382
+    do_action('wpinv_email_footer');
383 383
 
384 384
     // Get contents
385 385
     $message = ob_get_clean();
@@ -387,21 +387,21 @@  discard block
 block discarded – undo
387 387
     return $message;
388 388
 }
389 389
 
390
-function wpinv_add_notes_to_invoice_email( $invoice, $email_type ) {
391
-    if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->ID, true ) ) {
392
-        $date_format = get_option( 'date_format' );
393
-        $time_format = get_option( 'time_format' );
390
+function wpinv_add_notes_to_invoice_email($invoice, $email_type) {
391
+    if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->ID, true)) {
392
+        $date_format = get_option('date_format');
393
+        $time_format = get_option('time_format');
394 394
         ?>
395 395
         <div id="wpinv-email-notes">
396
-            <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3>
396
+            <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3>
397 397
             <ol class="wpinv-notes-lists">
398 398
         <?php
399
-        foreach ( $invoice_notes as $note ) {
400
-            $note_time = strtotime( $note->comment_date );
399
+        foreach ($invoice_notes as $note) {
400
+            $note_time = strtotime($note->comment_date);
401 401
             ?>
402 402
             <li class="comment wpinv-note">
403
-            <p class="wpinv-note-date meta"><?php printf( __( '%2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( $date_format, $note_time ), date_i18n( $time_format, $note_time ), $note_time ); ?></p>
404
-            <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div>
403
+            <p class="wpinv-note-date meta"><?php printf(__('%2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n($date_format, $note_time), date_i18n($time_format, $note_time), $note_time); ?></p>
404
+            <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div>
405 405
             </li>
406 406
             <?php
407 407
         }
@@ -410,4 +410,4 @@  discard block
 block discarded – undo
410 410
         <?php
411 411
     }
412 412
 }
413
-add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 );
413
+add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3);
Please login to merge, or discard this patch.