Passed
Branch master (50908e)
by Stiofan
07:01
created
includes/gateways/authorizenet/anet_php_sdk/lib/AuthorizeNetCIM.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -316,9 +316,9 @@
 block discarded – undo
316 316
         return $this->_sendRequest();
317 317
     }
318 318
     
319
-     /**
320
-     * @return string
321
-     */
319
+        /**
320
+         * @return string
321
+         */
322 322
     protected function _getPostUrl()
323 323
     {
324 324
         return ($this->_sandbox ? self::SANDBOX_URL : self::LIVE_URL);
Please login to merge, or discard this patch.
includes/gateways/authorizenet/anet_php_sdk/lib/AuthorizeNetDPM.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
             }
77 77
             else
78 78
             {
79
-              echo "Sorry, an error occurred: " . htmlentities($_GET['response_reason_text']);
79
+                echo "Sorry, an error occurred: " . htmlentities($_GET['response_reason_text']);
80 80
             }
81 81
         }
82 82
     }
Please login to merge, or discard this patch.
templates/wpinv-invoice-history.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 if ( !( $user_id = get_current_user_id() ) ) {
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
 		<tbody>
32 32
 			<?php foreach ( $user_invoices->invoices as $invoice ) {
33
-				?>
33
+                ?>
34 34
 				<tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
35 35
 					<?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
36 36
 						<td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>">
@@ -53,31 +53,31 @@  discard block
 block discarded – undo
53 53
 
54 54
 							<?php elseif ( 'invoice-actions' === $column_id ) : ?>
55 55
 								<?php
56
-									$actions = array(
57
-										'pay'    => array(
58
-											'url'  => $invoice->get_checkout_payment_url(),
59
-											'name' => __( 'Pay Now', 'invoicing' ),
56
+                                    $actions = array(
57
+                                        'pay'    => array(
58
+                                            'url'  => $invoice->get_checkout_payment_url(),
59
+                                            'name' => __( 'Pay Now', 'invoicing' ),
60 60
                                             'class' => 'btn-success'
61
-										),
61
+                                        ),
62 62
                                         'print'   => array(
63
-											'url'  => $invoice->get_view_url(),
64
-											'name' => __( 'Print', 'invoicing' ),
63
+                                            'url'  => $invoice->get_view_url(),
64
+                                            'name' => __( 'Print', 'invoicing' ),
65 65
                                             'class' => 'btn-primary',
66 66
                                             'attrs' => 'target="_blank"'
67
-										)
68
-									);
67
+                                        )
68
+                                    );
69 69
 
70
-									if ( ! $invoice->needs_payment() ) {
71
-										unset( $actions['pay'] );
72
-									}
70
+                                    if ( ! $invoice->needs_payment() ) {
71
+                                        unset( $actions['pay'] );
72
+                                    }
73 73
 
74
-									if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) {
75
-										foreach ( $actions as $key => $action ) {
76
-											$class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
74
+                                    if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) {
75
+                                        foreach ( $actions as $key => $action ) {
76
+                                            $class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
77 77
                                             echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
78
-										}
79
-									}
80
-								?>
78
+                                        }
79
+                                    }
80
+                                ?>
81 81
 							<?php endif; ?>
82 82
 						</td>
83 83
 					<?php endforeach; ?>
@@ -91,22 +91,22 @@  discard block
 block discarded – undo
91 91
 	<?php if ( 1 < $user_invoices->max_num_pages ) : ?>
92 92
 		<div class="invoicing-Pagination">
93 93
 			<?php
94
-			$big = 999999;
95
-
96
-			if (get_query_var('paged'))
97
-				$current_page = get_query_var('paged');
98
-			elseif (get_query_var('page'))
99
-				$current_page = get_query_var('page');
100
-			else
101
-				$current_page = 1;
102
-
103
-			echo paginate_links( array(
104
-				'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
105
-				'format'  => '?paged=%#%',
106
-				'current' => max( 1, $current_page ),
107
-				'total'   => $user_invoices->max_num_pages,
108
-			) );
109
-			?>
94
+            $big = 999999;
95
+
96
+            if (get_query_var('paged'))
97
+                $current_page = get_query_var('paged');
98
+            elseif (get_query_var('page'))
99
+                $current_page = get_query_var('page');
100
+            else
101
+                $current_page = 1;
102
+
103
+            echo paginate_links( array(
104
+                'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
105
+                'format'  => '?paged=%#%',
106
+                'current' => max( 1, $current_page ),
107
+                'total'   => $user_invoices->max_num_pages,
108
+            ) );
109
+            ?>
110 110
 		</div>
111 111
 	<?php endif; ?>
112 112
 
Please login to merge, or discard this patch.
includes/class-wpinv-db.php 1 patch
Indentation   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -5,237 +5,237 @@
 block discarded – undo
5 5
 
6 6
 abstract class Wpinv_DB {
7 7
 
8
-	/**
9
-	 * The name of our database table
10
-	 *
11
-	 * @access  public
12
-	 * @since   1.0.0
13
-	 */
14
-	public $table_name;
15
-
16
-	/**
17
-	 * The version of our database table
18
-	 *
19
-	 * @access  public
20
-	 * @since   1.0.0
21
-	 */
22
-	public $version;
23
-
24
-	/**
25
-	 * The name of the primary column
26
-	 *
27
-	 * @access  public
28
-	 * @since   1.0.0
29
-	 */
30
-	public $primary_key;
31
-
32
-	/**
33
-	 * Get things started
34
-	 *
35
-	 * @access  public
36
-	 * @since   1.0.0
37
-	 */
38
-	public function __construct() {}
39
-
40
-	/**
41
-	 * Whitelist of columns
42
-	 *
43
-	 * @access  public
44
-	 * @since   1.0.0
45
-	 * @return  array
46
-	 */
47
-	public function get_columns() {
48
-		return array();
49
-	}
50
-
51
-	/**
52
-	 * Default column values
53
-	 *
54
-	 * @access  public
55
-	 * @since   1.0.0
56
-	 * @return  array
57
-	 */
58
-	public function get_column_defaults() {
59
-		return array();
60
-	}
61
-
62
-	/**
63
-	 * Retrieve a row by the primary key
64
-	 *
65
-	 * @access  public
66
-	 * @since   1.0.0
67
-	 * @return  object
68
-	 */
69
-	public function get( $row_id ) {
70
-		global $wpdb;
71
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
72
-	}
73
-
74
-	/**
75
-	 * Retrieve a row by a specific column / value
76
-	 *
77
-	 * @access  public
78
-	 * @since   1.0.0
79
-	 * @return  object
80
-	 */
81
-	public function get_by( $column, $row_id ) {
82
-		global $wpdb;
83
-		$column = esc_sql( $column );
84
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) );
85
-	}
86
-
87
-	/**
88
-	 * Retrieve a specific column's value by the primary key
89
-	 *
90
-	 * @access  public
91
-	 * @since   1.0.0
92
-	 * @return  string
93
-	 */
94
-	public function get_column( $column, $row_id ) {
95
-		global $wpdb;
96
-		$column = esc_sql( $column );
97
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
98
-	}
99
-
100
-	/**
101
-	 * Retrieve a specific column's value by the the specified column / value
102
-	 *
103
-	 * @access  public
104
-	 * @since   1.0.0
105
-	 * @return  string
106
-	 */
107
-	public function get_column_by( $column, $column_where, $column_value ) {
108
-		global $wpdb;
109
-		$column_where = esc_sql( $column_where );
110
-		$column       = esc_sql( $column );
111
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) );
112
-	}
113
-
114
-	/**
115
-	 * Insert a new row
116
-	 *
117
-	 * @access  public
118
-	 * @since   1.0.0
119
-	 * @return  int
120
-	 */
121
-	public function insert( $data, $type = '' ) {
122
-		global $wpdb;
123
-
124
-		// Set default values
125
-		$data = wp_parse_args( $data, $this->get_column_defaults() );
126
-
127
-		do_action( 'wpinv_pre_insert_' . $type, $data );
128
-
129
-		// Initialise column format array
130
-		$column_formats = $this->get_columns();
131
-
132
-		// Force fields to lower case
133
-		$data = array_change_key_case( $data );
134
-
135
-		// White list columns
136
-		$data = array_intersect_key( $data, $column_formats );
137
-
138
-		// Reorder $column_formats to match the order of columns given in $data
139
-		$data_keys = array_keys( $data );
140
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
141
-
142
-		$wpdb->insert( $this->table_name, $data, $column_formats );
143
-		$wpdb_insert_id = $wpdb->insert_id;
144
-
145
-		do_action( 'wpinv_post_insert_' . $type, $wpdb_insert_id, $data );
146
-
147
-		return $wpdb_insert_id;
148
-	}
149
-
150
-	/**
151
-	 * Update a row
152
-	 *
153
-	 * @access  public
154
-	 * @since   1.0.0
155
-	 * @return  bool
156
-	 */
157
-	public function update( $row_id, $data = array(), $where = '' ) {
158
-
159
-		global $wpdb;
160
-
161
-		// Row ID must be positive integer
162
-		$row_id = absint( $row_id );
163
-
164
-		if( empty( $row_id ) ) {
165
-			return false;
166
-		}
167
-
168
-		if( empty( $where ) ) {
169
-			$where = $this->primary_key;
170
-		}
171
-
172
-		// Initialise column format array
173
-		$column_formats = $this->get_columns();
174
-
175
-		// Force fields to lower case
176
-		$data = array_change_key_case( $data );
177
-
178
-		// White list columns
179
-		$data = array_intersect_key( $data, $column_formats );
180
-
181
-		// Reorder $column_formats to match the order of columns given in $data
182
-		$data_keys = array_keys( $data );
183
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
184
-
185
-		if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) {
186
-			return false;
187
-		}
188
-
189
-		return true;
190
-	}
191
-
192
-	/**
193
-	 * Delete a row identified by the primary key
194
-	 *
195
-	 * @access  public
196
-	 * @since   1.0.0
197
-	 * @return  bool
198
-	 */
199
-	public function delete( $row_id = 0 ) {
200
-
201
-		global $wpdb;
202
-
203
-		// Row ID must be positive integer
204
-		$row_id = absint( $row_id );
205
-
206
-		if( empty( $row_id ) ) {
207
-			return false;
208
-		}
209
-
210
-		if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) {
211
-			return false;
212
-		}
213
-
214
-		return true;
215
-	}
216
-
217
-	/**
218
-	 * Check if the given table exists
219
-	 *
220
-	 * @since  2.4
221
-	 * @param  string $table The table name
222
-	 * @return bool          If the table name exists
223
-	 */
224
-	public function table_exists( $table ) {
225
-		global $wpdb;
226
-		$table = sanitize_text_field( $table );
227
-
228
-		return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table;
229
-	}
230
-
231
-	/**
232
-	 * Check if the table was ever installed
233
-	 *
234
-	 * @since  2.4
235
-	 * @return bool Returns if the customers table was installed and upgrade routine run
236
-	 */
237
-	public function installed() {
238
-		return $this->table_exists( $this->table_name );
239
-	}
8
+    /**
9
+     * The name of our database table
10
+     *
11
+     * @access  public
12
+     * @since   1.0.0
13
+     */
14
+    public $table_name;
15
+
16
+    /**
17
+     * The version of our database table
18
+     *
19
+     * @access  public
20
+     * @since   1.0.0
21
+     */
22
+    public $version;
23
+
24
+    /**
25
+     * The name of the primary column
26
+     *
27
+     * @access  public
28
+     * @since   1.0.0
29
+     */
30
+    public $primary_key;
31
+
32
+    /**
33
+     * Get things started
34
+     *
35
+     * @access  public
36
+     * @since   1.0.0
37
+     */
38
+    public function __construct() {}
39
+
40
+    /**
41
+     * Whitelist of columns
42
+     *
43
+     * @access  public
44
+     * @since   1.0.0
45
+     * @return  array
46
+     */
47
+    public function get_columns() {
48
+        return array();
49
+    }
50
+
51
+    /**
52
+     * Default column values
53
+     *
54
+     * @access  public
55
+     * @since   1.0.0
56
+     * @return  array
57
+     */
58
+    public function get_column_defaults() {
59
+        return array();
60
+    }
61
+
62
+    /**
63
+     * Retrieve a row by the primary key
64
+     *
65
+     * @access  public
66
+     * @since   1.0.0
67
+     * @return  object
68
+     */
69
+    public function get( $row_id ) {
70
+        global $wpdb;
71
+        return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
72
+    }
73
+
74
+    /**
75
+     * Retrieve a row by a specific column / value
76
+     *
77
+     * @access  public
78
+     * @since   1.0.0
79
+     * @return  object
80
+     */
81
+    public function get_by( $column, $row_id ) {
82
+        global $wpdb;
83
+        $column = esc_sql( $column );
84
+        return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) );
85
+    }
86
+
87
+    /**
88
+     * Retrieve a specific column's value by the primary key
89
+     *
90
+     * @access  public
91
+     * @since   1.0.0
92
+     * @return  string
93
+     */
94
+    public function get_column( $column, $row_id ) {
95
+        global $wpdb;
96
+        $column = esc_sql( $column );
97
+        return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
98
+    }
99
+
100
+    /**
101
+     * Retrieve a specific column's value by the the specified column / value
102
+     *
103
+     * @access  public
104
+     * @since   1.0.0
105
+     * @return  string
106
+     */
107
+    public function get_column_by( $column, $column_where, $column_value ) {
108
+        global $wpdb;
109
+        $column_where = esc_sql( $column_where );
110
+        $column       = esc_sql( $column );
111
+        return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) );
112
+    }
113
+
114
+    /**
115
+     * Insert a new row
116
+     *
117
+     * @access  public
118
+     * @since   1.0.0
119
+     * @return  int
120
+     */
121
+    public function insert( $data, $type = '' ) {
122
+        global $wpdb;
123
+
124
+        // Set default values
125
+        $data = wp_parse_args( $data, $this->get_column_defaults() );
126
+
127
+        do_action( 'wpinv_pre_insert_' . $type, $data );
128
+
129
+        // Initialise column format array
130
+        $column_formats = $this->get_columns();
131
+
132
+        // Force fields to lower case
133
+        $data = array_change_key_case( $data );
134
+
135
+        // White list columns
136
+        $data = array_intersect_key( $data, $column_formats );
137
+
138
+        // Reorder $column_formats to match the order of columns given in $data
139
+        $data_keys = array_keys( $data );
140
+        $column_formats = array_merge( array_flip( $data_keys ), $column_formats );
141
+
142
+        $wpdb->insert( $this->table_name, $data, $column_formats );
143
+        $wpdb_insert_id = $wpdb->insert_id;
144
+
145
+        do_action( 'wpinv_post_insert_' . $type, $wpdb_insert_id, $data );
146
+
147
+        return $wpdb_insert_id;
148
+    }
149
+
150
+    /**
151
+     * Update a row
152
+     *
153
+     * @access  public
154
+     * @since   1.0.0
155
+     * @return  bool
156
+     */
157
+    public function update( $row_id, $data = array(), $where = '' ) {
158
+
159
+        global $wpdb;
160
+
161
+        // Row ID must be positive integer
162
+        $row_id = absint( $row_id );
163
+
164
+        if( empty( $row_id ) ) {
165
+            return false;
166
+        }
167
+
168
+        if( empty( $where ) ) {
169
+            $where = $this->primary_key;
170
+        }
171
+
172
+        // Initialise column format array
173
+        $column_formats = $this->get_columns();
174
+
175
+        // Force fields to lower case
176
+        $data = array_change_key_case( $data );
177
+
178
+        // White list columns
179
+        $data = array_intersect_key( $data, $column_formats );
180
+
181
+        // Reorder $column_formats to match the order of columns given in $data
182
+        $data_keys = array_keys( $data );
183
+        $column_formats = array_merge( array_flip( $data_keys ), $column_formats );
184
+
185
+        if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) {
186
+            return false;
187
+        }
188
+
189
+        return true;
190
+    }
191
+
192
+    /**
193
+     * Delete a row identified by the primary key
194
+     *
195
+     * @access  public
196
+     * @since   1.0.0
197
+     * @return  bool
198
+     */
199
+    public function delete( $row_id = 0 ) {
200
+
201
+        global $wpdb;
202
+
203
+        // Row ID must be positive integer
204
+        $row_id = absint( $row_id );
205
+
206
+        if( empty( $row_id ) ) {
207
+            return false;
208
+        }
209
+
210
+        if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) {
211
+            return false;
212
+        }
213
+
214
+        return true;
215
+    }
216
+
217
+    /**
218
+     * Check if the given table exists
219
+     *
220
+     * @since  2.4
221
+     * @param  string $table The table name
222
+     * @return bool          If the table name exists
223
+     */
224
+    public function table_exists( $table ) {
225
+        global $wpdb;
226
+        $table = sanitize_text_field( $table );
227
+
228
+        return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table;
229
+    }
230
+
231
+    /**
232
+     * Check if the table was ever installed
233
+     *
234
+     * @since  2.4
235
+     * @return bool Returns if the customers table was installed and upgrade routine run
236
+     */
237
+    public function installed() {
238
+        return $this->table_exists( $this->table_name );
239
+    }
240 240
 
241 241
 }
Please login to merge, or discard this patch.
includes/gateways/paypal.php 1 patch
Indentation   +255 added lines, -255 removed lines patch added patch discarded remove patch
@@ -218,262 +218,262 @@  discard block
 block discarded – undo
218 218
 add_filter( 'wpinv_paypal_args', 'wpinv_get_paypal_recurring_args', 10, 3 );
219 219
 
220 220
 function wpinv_process_paypal_ipn() {
221
-	// Check the request method is POST
222
-	if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
223
-		return;
224
-	}
225
-
226
-	// Set initial post data to empty string
227
-	$post_data = '';
228
-
229
-	// Fallback just in case post_max_size is lower than needed
230
-	if ( ini_get( 'allow_url_fopen' ) ) {
231
-		$post_data = file_get_contents( 'php://input' );
232
-	} else {
233
-		// If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
234
-		ini_set( 'post_max_size', '12M' );
235
-	}
236
-	// Start the encoded data collection with notification command
237
-	$encoded_data = 'cmd=_notify-validate';
238
-
239
-	// Get current arg separator
240
-	$arg_separator = wpinv_get_php_arg_separator_output();
241
-
242
-	// Verify there is a post_data
243
-	if ( $post_data || strlen( $post_data ) > 0 ) {
244
-		// Append the data
245
-		$encoded_data .= $arg_separator.$post_data;
246
-	} else {
247
-		// Check if POST is empty
248
-		if ( empty( $_POST ) ) {
249
-			// Nothing to do
250
-			return;
251
-		} else {
252
-			// Loop through each POST
253
-			foreach ( $_POST as $key => $value ) {
254
-				// Encode the value and append the data
255
-				$encoded_data .= $arg_separator."$key=" . urlencode( $value );
256
-			}
257
-		}
258
-	}
259
-
260
-	// Convert collected post data to an array
261
-	parse_str( $encoded_data, $encoded_data_array );
262
-
263
-	foreach ( $encoded_data_array as $key => $value ) {
264
-		if ( false !== strpos( $key, 'amp;' ) ) {
265
-			$new_key = str_replace( '&amp;', '&', $key );
266
-			$new_key = str_replace( 'amp;', '&' , $new_key );
267
-
268
-			unset( $encoded_data_array[ $key ] );
269
-			$encoded_data_array[ $new_key ] = $value;
270
-		}
271
-	}
272
-
273
-	// Get the PayPal redirect uri
274
-	$paypal_redirect = wpinv_get_paypal_redirect( true );
275
-
276
-	if ( !wpinv_get_option( 'disable_paypal_verification', false ) ) {
277
-		// Validate the IPN
278
-
279
-		$remote_post_vars      = array(
280
-			'method'           => 'POST',
281
-			'timeout'          => 45,
282
-			'redirection'      => 5,
283
-			'httpversion'      => '1.1',
284
-			'blocking'         => true,
285
-			'headers'          => array(
286
-				'host'         => 'www.paypal.com',
287
-				'connection'   => 'close',
288
-				'content-type' => 'application/x-www-form-urlencoded',
289
-				'post'         => '/cgi-bin/webscr HTTP/1.1',
290
-
291
-			),
292
-			'sslverify'        => false,
293
-			'body'             => $encoded_data_array
294
-		);
295
-
296
-		// Get response
297
-		$api_response = wp_remote_post( wpinv_get_paypal_redirect(), $remote_post_vars );
298
-
299
-		if ( is_wp_error( $api_response ) ) {
300
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) );
301
-			return; // Something went wrong
302
-		}
303
-
304
-		if ( $api_response['body'] !== 'VERIFIED' && wpinv_get_option( 'disable_paypal_verification', false ) ) {
305
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) );
306
-			return; // Response not okay
307
-		}
308
-	}
309
-
310
-	// Check if $post_data_array has been populated
311
-	if ( !is_array( $encoded_data_array ) && !empty( $encoded_data_array ) )
312
-		return;
313
-
314
-	$defaults = array(
315
-		'txn_type'       => '',
316
-		'payment_status' => ''
317
-	);
318
-
319
-	$encoded_data_array = wp_parse_args( $encoded_data_array, $defaults );
320
-
321
-	$invoice_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0;
221
+    // Check the request method is POST
222
+    if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
223
+        return;
224
+    }
225
+
226
+    // Set initial post data to empty string
227
+    $post_data = '';
228
+
229
+    // Fallback just in case post_max_size is lower than needed
230
+    if ( ini_get( 'allow_url_fopen' ) ) {
231
+        $post_data = file_get_contents( 'php://input' );
232
+    } else {
233
+        // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
234
+        ini_set( 'post_max_size', '12M' );
235
+    }
236
+    // Start the encoded data collection with notification command
237
+    $encoded_data = 'cmd=_notify-validate';
238
+
239
+    // Get current arg separator
240
+    $arg_separator = wpinv_get_php_arg_separator_output();
241
+
242
+    // Verify there is a post_data
243
+    if ( $post_data || strlen( $post_data ) > 0 ) {
244
+        // Append the data
245
+        $encoded_data .= $arg_separator.$post_data;
246
+    } else {
247
+        // Check if POST is empty
248
+        if ( empty( $_POST ) ) {
249
+            // Nothing to do
250
+            return;
251
+        } else {
252
+            // Loop through each POST
253
+            foreach ( $_POST as $key => $value ) {
254
+                // Encode the value and append the data
255
+                $encoded_data .= $arg_separator."$key=" . urlencode( $value );
256
+            }
257
+        }
258
+    }
259
+
260
+    // Convert collected post data to an array
261
+    parse_str( $encoded_data, $encoded_data_array );
262
+
263
+    foreach ( $encoded_data_array as $key => $value ) {
264
+        if ( false !== strpos( $key, 'amp;' ) ) {
265
+            $new_key = str_replace( '&amp;', '&', $key );
266
+            $new_key = str_replace( 'amp;', '&' , $new_key );
267
+
268
+            unset( $encoded_data_array[ $key ] );
269
+            $encoded_data_array[ $new_key ] = $value;
270
+        }
271
+    }
272
+
273
+    // Get the PayPal redirect uri
274
+    $paypal_redirect = wpinv_get_paypal_redirect( true );
275
+
276
+    if ( !wpinv_get_option( 'disable_paypal_verification', false ) ) {
277
+        // Validate the IPN
278
+
279
+        $remote_post_vars      = array(
280
+            'method'           => 'POST',
281
+            'timeout'          => 45,
282
+            'redirection'      => 5,
283
+            'httpversion'      => '1.1',
284
+            'blocking'         => true,
285
+            'headers'          => array(
286
+                'host'         => 'www.paypal.com',
287
+                'connection'   => 'close',
288
+                'content-type' => 'application/x-www-form-urlencoded',
289
+                'post'         => '/cgi-bin/webscr HTTP/1.1',
290
+
291
+            ),
292
+            'sslverify'        => false,
293
+            'body'             => $encoded_data_array
294
+        );
295
+
296
+        // Get response
297
+        $api_response = wp_remote_post( wpinv_get_paypal_redirect(), $remote_post_vars );
298
+
299
+        if ( is_wp_error( $api_response ) ) {
300
+            wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) );
301
+            return; // Something went wrong
302
+        }
303
+
304
+        if ( $api_response['body'] !== 'VERIFIED' && wpinv_get_option( 'disable_paypal_verification', false ) ) {
305
+            wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) );
306
+            return; // Response not okay
307
+        }
308
+    }
309
+
310
+    // Check if $post_data_array has been populated
311
+    if ( !is_array( $encoded_data_array ) && !empty( $encoded_data_array ) )
312
+        return;
313
+
314
+    $defaults = array(
315
+        'txn_type'       => '',
316
+        'payment_status' => ''
317
+    );
318
+
319
+    $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults );
320
+
321
+    $invoice_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0;
322 322
     
323
-	wpinv_error_log( $encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__ );
324
-	wpinv_error_log( $encoded_data_array, 'PayPal IPN response', __FILE__, __LINE__ );
325
-
326
-	if ( has_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'] ) ) {
327
-		// Allow PayPal IPN types to be processed separately
328
-		do_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id );
329
-	} else {
330
-		// Fallback to web accept just in case the txn_type isn't present
331
-		do_action( 'wpinv_paypal_web_accept', $encoded_data_array, $invoice_id );
332
-	}
333
-	exit;
323
+    wpinv_error_log( $encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__ );
324
+    wpinv_error_log( $encoded_data_array, 'PayPal IPN response', __FILE__, __LINE__ );
325
+
326
+    if ( has_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'] ) ) {
327
+        // Allow PayPal IPN types to be processed separately
328
+        do_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id );
329
+    } else {
330
+        // Fallback to web accept just in case the txn_type isn't present
331
+        do_action( 'wpinv_paypal_web_accept', $encoded_data_array, $invoice_id );
332
+    }
333
+    exit;
334 334
 }
335 335
 add_action( 'wpinv_verify_paypal_ipn', 'wpinv_process_paypal_ipn' );
336 336
 
337 337
 function wpinv_process_paypal_web_accept_and_cart( $data, $invoice_id ) {
338
-	if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) {
339
-		return;
340
-	}
341
-
342
-	if( empty( $invoice_id ) ) {
343
-		return;
344
-	}
345
-
346
-	// Collect payment details
347
-	$purchase_key   = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number'];
348
-	$paypal_amount  = $data['mc_gross'];
349
-	$payment_status = strtolower( $data['payment_status'] );
350
-	$currency_code  = strtolower( $data['mc_currency'] );
351
-	$business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] );
352
-	$payment_meta   = wpinv_get_invoice_meta( $invoice_id );
353
-
354
-	if ( wpinv_get_payment_gateway( $invoice_id ) != 'paypal' ) {
355
-		return; // this isn't a PayPal standard IPN
356
-	}
357
-
358
-	// Verify payment recipient
359
-	if ( strcasecmp( $business_email, trim( wpinv_get_option( 'paypal_email', false ) ) ) != 0 ) {
360
-		wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid business email in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
361
-		wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
362
-		wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid PayPal business email.', 'invoicing' ), '', '', true );
363
-		return;
364
-	}
365
-
366
-	// Verify payment currency
367
-	if ( $currency_code != strtolower( $payment_meta['currency'] ) ) {
368
-		wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
369
-		wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
370
-		wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'invoicing' ), '', '', true );
371
-		return;
372
-	}
373
-
374
-	if ( !wpinv_get_payment_user_email( $invoice_id ) ) {
375
-		// This runs when a Buy Now purchase was made. It bypasses checkout so no personal info is collected until PayPal
376
-		// No email associated with purchase, so store from PayPal
377
-		wpinv_update_invoice_meta( $invoice_id, '_wpinv_email', $data['payer_email'] );
378
-
379
-		// Setup and store the customer's details
380
-		$user_info = array(
381
-			'user_id'    => '-1',
382
-			'email'      => sanitize_text_field( $data['payer_email'] ),
383
-			'first_name' => sanitize_text_field( $data['first_name'] ),
384
-			'last_name'  => sanitize_text_field( $data['last_name'] ),
385
-			'discount'   => '',
386
-		);
387
-		$user_info['address'] = ! empty( $data['address_street']       ) ? sanitize_text_field( $data['address_street'] )       : false;
388
-		$user_info['city']    = ! empty( $data['address_city']         ) ? sanitize_text_field( $data['address_city'] )         : false;
389
-		$user_info['state']   = ! empty( $data['address_state']        ) ? sanitize_text_field( $data['address_state'] )        : false;
390
-		$user_info['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false;
391
-		$user_info['zip']     = ! empty( $data['address_zip']          ) ? sanitize_text_field( $data['address_zip'] )          : false;
392
-
393
-		$payment_meta['user_info'] = $user_info;
394
-		wpinv_update_invoice_meta( $invoice_id, '_wpinv_payment_meta', $payment_meta );
395
-	}
396
-
397
-	if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
398
-		// Process a refund
399
-		wpinv_process_paypal_refund( $data, $invoice_id );
400
-	} else {
401
-		if ( get_post_status( $invoice_id ) == 'publish' ) {
402
-			return; // Only paid payments once
403
-		}
404
-
405
-		// Retrieve the total purchase amount (before PayPal)
406
-		$payment_amount = wpinv_payment_total( $invoice_id );
407
-
408
-		if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
409
-			// The prices don't match
410
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid payment amount in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
411
-			wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
412
-			wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'invoicing' ), '', '', true );
413
-			return;
414
-		}
415
-		if ( $purchase_key != wpinv_get_payment_key( $invoice_id ) ) {
416
-			// Purchase keys don't match
417
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid purchase key in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
418
-			wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
419
-			wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing' ), '', '', true );
420
-			return;
421
-		}
422
-
423
-		if ( 'complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode( 'paypal' ) ) {
424
-			wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $data['txn_id'] ), '', '', true );
425
-			wpinv_set_payment_transaction_id( $invoice_id, $data['txn_id'] );
426
-			wpinv_update_payment_status( $invoice_id, 'publish' );
427
-		} else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) {
428
-			// Look for possible pending reasons, such as an echeck
429
-			$note = '';
430
-
431
-			switch( strtolower( $data['pending_reason'] ) ) {
432
-				case 'echeck' :
433
-					$note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing' );
434
-					break;
338
+    if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) {
339
+        return;
340
+    }
341
+
342
+    if( empty( $invoice_id ) ) {
343
+        return;
344
+    }
345
+
346
+    // Collect payment details
347
+    $purchase_key   = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number'];
348
+    $paypal_amount  = $data['mc_gross'];
349
+    $payment_status = strtolower( $data['payment_status'] );
350
+    $currency_code  = strtolower( $data['mc_currency'] );
351
+    $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] );
352
+    $payment_meta   = wpinv_get_invoice_meta( $invoice_id );
353
+
354
+    if ( wpinv_get_payment_gateway( $invoice_id ) != 'paypal' ) {
355
+        return; // this isn't a PayPal standard IPN
356
+    }
357
+
358
+    // Verify payment recipient
359
+    if ( strcasecmp( $business_email, trim( wpinv_get_option( 'paypal_email', false ) ) ) != 0 ) {
360
+        wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid business email in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
361
+        wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
362
+        wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid PayPal business email.', 'invoicing' ), '', '', true );
363
+        return;
364
+    }
365
+
366
+    // Verify payment currency
367
+    if ( $currency_code != strtolower( $payment_meta['currency'] ) ) {
368
+        wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
369
+        wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
370
+        wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'invoicing' ), '', '', true );
371
+        return;
372
+    }
373
+
374
+    if ( !wpinv_get_payment_user_email( $invoice_id ) ) {
375
+        // This runs when a Buy Now purchase was made. It bypasses checkout so no personal info is collected until PayPal
376
+        // No email associated with purchase, so store from PayPal
377
+        wpinv_update_invoice_meta( $invoice_id, '_wpinv_email', $data['payer_email'] );
378
+
379
+        // Setup and store the customer's details
380
+        $user_info = array(
381
+            'user_id'    => '-1',
382
+            'email'      => sanitize_text_field( $data['payer_email'] ),
383
+            'first_name' => sanitize_text_field( $data['first_name'] ),
384
+            'last_name'  => sanitize_text_field( $data['last_name'] ),
385
+            'discount'   => '',
386
+        );
387
+        $user_info['address'] = ! empty( $data['address_street']       ) ? sanitize_text_field( $data['address_street'] )       : false;
388
+        $user_info['city']    = ! empty( $data['address_city']         ) ? sanitize_text_field( $data['address_city'] )         : false;
389
+        $user_info['state']   = ! empty( $data['address_state']        ) ? sanitize_text_field( $data['address_state'] )        : false;
390
+        $user_info['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false;
391
+        $user_info['zip']     = ! empty( $data['address_zip']          ) ? sanitize_text_field( $data['address_zip'] )          : false;
392
+
393
+        $payment_meta['user_info'] = $user_info;
394
+        wpinv_update_invoice_meta( $invoice_id, '_wpinv_payment_meta', $payment_meta );
395
+    }
396
+
397
+    if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
398
+        // Process a refund
399
+        wpinv_process_paypal_refund( $data, $invoice_id );
400
+    } else {
401
+        if ( get_post_status( $invoice_id ) == 'publish' ) {
402
+            return; // Only paid payments once
403
+        }
404
+
405
+        // Retrieve the total purchase amount (before PayPal)
406
+        $payment_amount = wpinv_payment_total( $invoice_id );
407
+
408
+        if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
409
+            // The prices don't match
410
+            wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid payment amount in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
411
+            wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
412
+            wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'invoicing' ), '', '', true );
413
+            return;
414
+        }
415
+        if ( $purchase_key != wpinv_get_payment_key( $invoice_id ) ) {
416
+            // Purchase keys don't match
417
+            wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid purchase key in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
418
+            wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
419
+            wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing' ), '', '', true );
420
+            return;
421
+        }
422
+
423
+        if ( 'complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode( 'paypal' ) ) {
424
+            wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $data['txn_id'] ), '', '', true );
425
+            wpinv_set_payment_transaction_id( $invoice_id, $data['txn_id'] );
426
+            wpinv_update_payment_status( $invoice_id, 'publish' );
427
+        } else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) {
428
+            // Look for possible pending reasons, such as an echeck
429
+            $note = '';
430
+
431
+            switch( strtolower( $data['pending_reason'] ) ) {
432
+                case 'echeck' :
433
+                    $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing' );
434
+                    break;
435 435
 				
436 436
                 case 'address' :
437
-					$note = __( 'Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing' );
438
-					break;
437
+                    $note = __( 'Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing' );
438
+                    break;
439 439
 				
440 440
                 case 'intl' :
441
-					$note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'invoicing' );
442
-					break;
441
+                    $note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'invoicing' );
442
+                    break;
443 443
 				
444 444
                 case 'multi-currency' :
445
-					$note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing' );
446
-					break;
445
+                    $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing' );
446
+                    break;
447 447
 				
448 448
                 case 'paymentreview' :
449 449
                 case 'regulatory_review' :
450
-					$note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing' );
451
-					break;
450
+                    $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing' );
451
+                    break;
452 452
 				
453 453
                 case 'unilateral' :
454
-					$note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'invoicing' );
455
-					break;
454
+                    $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'invoicing' );
455
+                    break;
456 456
 				
457 457
                 case 'upgrade' :
458
-					$note = __( 'PayPal account must be upgraded before this payment can be accepted', 'invoicing' );
459
-					break;
458
+                    $note = __( 'PayPal account must be upgraded before this payment can be accepted', 'invoicing' );
459
+                    break;
460 460
 				
461 461
                 case 'verify' :
462
-					$note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'invoicing' );
463
-					break;
464
-
465
-				case 'other' :
466
-					$note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing' );
467
-					break;
468
-			}
469
-
470
-			if ( ! empty( $note ) ) {
471
-				wpinv_insert_payment_note( $invoice_id, $note, '', '', true );
472
-			}
473
-		} else {
474
-			wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal IPN has been received with invalid payment status: %s', 'invoicing' ), $payment_status ), '', '', true );
475
-		}
476
-	}
462
+                    $note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'invoicing' );
463
+                    break;
464
+
465
+                case 'other' :
466
+                    $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing' );
467
+                    break;
468
+            }
469
+
470
+            if ( ! empty( $note ) ) {
471
+                wpinv_insert_payment_note( $invoice_id, $note, '', '', true );
472
+            }
473
+        } else {
474
+            wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal IPN has been received with invalid payment status: %s', 'invoicing' ), $payment_status ), '', '', true );
475
+        }
476
+    }
477 477
 }
478 478
 add_action( 'wpinv_paypal_web_accept', 'wpinv_process_paypal_web_accept_and_cart', 10, 2 );
479 479
 
@@ -661,34 +661,34 @@  discard block
 block discarded – undo
661 661
 }
662 662
 
663 663
 function wpinv_process_paypal_refund( $data, $invoice_id = 0 ) {
664
-	// Collect payment details
664
+    // Collect payment details
665 665
 
666
-	if( empty( $invoice_id ) ) {
667
-		return;
668
-	}
666
+    if( empty( $invoice_id ) ) {
667
+        return;
668
+    }
669 669
 
670
-	if ( get_post_status( $invoice_id ) == 'wpi-refunded' ) {
671
-		return; // Only refund payments once
672
-	}
670
+    if ( get_post_status( $invoice_id ) == 'wpi-refunded' ) {
671
+        return; // Only refund payments once
672
+    }
673 673
 
674
-	$payment_amount = wpinv_payment_total( $invoice_id );
675
-	$refund_amount  = $data['mc_gross'] * -1;
674
+    $payment_amount = wpinv_payment_total( $invoice_id );
675
+    $refund_amount  = $data['mc_gross'] * -1;
676 676
 
677
-	do_action( 'wpinv_paypal_refund_request', $data, $invoice_id );
677
+    do_action( 'wpinv_paypal_refund_request', $data, $invoice_id );
678 678
 
679
-	if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
680
-		wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal partial refund of %s processed for transaction #%s for reason: %s', 'invoicing' ), (float)$refund_amount . ' '. $data['mc_currency'], $data['parent_txn_id'], $data['reason_code'] ), '', '', true );
679
+    if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
680
+        wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal partial refund of %s processed for transaction #%s for reason: %s', 'invoicing' ), (float)$refund_amount . ' '. $data['mc_currency'], $data['parent_txn_id'], $data['reason_code'] ), '', '', true );
681 681
 
682
-		do_action( 'wpinv_paypal_invoice_partially_refunded', $data, $invoice_id, $refund_amount );
682
+        do_action( 'wpinv_paypal_invoice_partially_refunded', $data, $invoice_id, $refund_amount );
683 683
 
684
-		return; // This is a partial refund
685
-	}
684
+        return; // This is a partial refund
685
+    }
686 686
 
687
-	wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Payment #%s Refunded for reason: %s', 'invoicing' ), $data['parent_txn_id'], $data['reason_code'] ), '', '', true );
688
-	wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Refund Transaction ID: %s', 'invoicing' ), $data['txn_id'] ), '', '', true );
689
-	wpinv_update_payment_status( $invoice_id, 'wpi-refunded' );
687
+    wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Payment #%s Refunded for reason: %s', 'invoicing' ), $data['parent_txn_id'], $data['reason_code'] ), '', '', true );
688
+    wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Refund Transaction ID: %s', 'invoicing' ), $data['txn_id'] ), '', '', true );
689
+    wpinv_update_payment_status( $invoice_id, 'wpi-refunded' );
690 690
 
691
-	do_action( 'wpinv_paypal_invoice_fully_refunded', $data, $invoice_id );
691
+    do_action( 'wpinv_paypal_invoice_fully_refunded', $data, $invoice_id );
692 692
 }
693 693
 
694 694
 function wpinv_get_paypal_redirect( $ssl_check = false ) {
Please login to merge, or discard this patch.
includes/wpinv-subscription.php 1 patch
Indentation   +454 added lines, -454 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 // Exit if accessed directly
4 4
 if ( ! defined( 'ABSPATH' ) ) {
5
-	exit;
5
+    exit;
6 6
 }
7 7
 
8 8
 
@@ -13,183 +13,183 @@  discard block
 block discarded – undo
13 13
  */
14 14
 class WPInv_Subscription {
15 15
 
16
-	private $subs_db;
16
+    private $subs_db;
17
+
18
+    public $id                = 0;
19
+    public $customer_id       = 0;
20
+    public $period            = '';
21
+    public $initial_amount    = '';
22
+    public $recurring_amount  = '';
23
+    public $bill_times        = 0;
24
+    public $transaction_id    = '';
25
+    public $parent_payment_id = 0;
26
+    public $product_id        = 0;
27
+    public $created           = '0000-00-00 00:00:00';
28
+    public $expiration        = '0000-00-00 00:00:00';
29
+    public $trial_period      = '';
30
+    public $status            = 'pending';
31
+    public $profile_id        = '';
32
+    public $gateway           = '';
33
+    public $customer;
17 34
 
18
-	public $id                = 0;
19
-	public $customer_id       = 0;
20
-	public $period            = '';
21
-	public $initial_amount    = '';
22
-	public $recurring_amount  = '';
23
-	public $bill_times        = 0;
24
-	public $transaction_id    = '';
25
-	public $parent_payment_id = 0;
26
-	public $product_id        = 0;
27
-	public $created           = '0000-00-00 00:00:00';
28
-	public $expiration        = '0000-00-00 00:00:00';
29
-	public $trial_period      = '';
30
-	public $status            = 'pending';
31
-	public $profile_id        = '';
32
-	public $gateway           = '';
33
-	public $customer;
34
-
35
-	/**
36
-	 * Get us started
37
-	 *
38
-	 * @since  1.0.0
39
-	 * @return void
40
-	 */
41
-	function __construct( $_id_or_object = 0, $_by_profile_id = false ) {
35
+    /**
36
+     * Get us started
37
+     *
38
+     * @since  1.0.0
39
+     * @return void
40
+     */
41
+    function __construct( $_id_or_object = 0, $_by_profile_id = false ) {
42 42
 
43
-		$this->subs_db = new WPInv_Subscriptions_DB;
43
+        $this->subs_db = new WPInv_Subscriptions_DB;
44 44
 
45
-		if( $_by_profile_id ) {
45
+        if( $_by_profile_id ) {
46 46
 
47
-			$_sub = $this->subs_db->get_by( 'profile_id', $_id_or_object );
47
+            $_sub = $this->subs_db->get_by( 'profile_id', $_id_or_object );
48 48
 
49
-			if( empty( $_sub ) ) {
50
-				return false;
51
-			}
49
+            if( empty( $_sub ) ) {
50
+                return false;
51
+            }
52 52
 
53
-			$_id_or_object = $_sub;
53
+            $_id_or_object = $_sub;
54 54
 
55
-		}
55
+        }
56 56
 
57
-		return $this->setup_subscription( $_id_or_object );
58
-	}
57
+        return $this->setup_subscription( $_id_or_object );
58
+    }
59 59
 
60
-	/**
61
-	 * Setup the subscription object
62
-	 *
63
-	 * @since  1.0.0
64
-	 * @return void
65
-	 */
66
-	private function setup_subscription( $id_or_object = 0 ) {
60
+    /**
61
+     * Setup the subscription object
62
+     *
63
+     * @since  1.0.0
64
+     * @return void
65
+     */
66
+    private function setup_subscription( $id_or_object = 0 ) {
67 67
 
68
-		if( empty( $id_or_object ) ) {
69
-			return false;
70
-		}
68
+        if( empty( $id_or_object ) ) {
69
+            return false;
70
+        }
71 71
 
72
-		if( is_numeric( $id_or_object ) ) {
72
+        if( is_numeric( $id_or_object ) ) {
73 73
 
74
-			$sub = $this->subs_db->get( $id_or_object );
74
+            $sub = $this->subs_db->get( $id_or_object );
75 75
 
76
-		} elseif( is_object( $id_or_object ) ) {
76
+        } elseif( is_object( $id_or_object ) ) {
77 77
 
78
-			$sub = $id_or_object;
78
+            $sub = $id_or_object;
79 79
 
80
-		}
80
+        }
81 81
 
82
-		if( empty( $sub ) ) {
83
-			return false;
84
-		}
82
+        if( empty( $sub ) ) {
83
+            return false;
84
+        }
85 85
 
86
-		foreach( $sub as $key => $value ) {
87
-			$this->$key = $value;
88
-		}
86
+        foreach( $sub as $key => $value ) {
87
+            $this->$key = $value;
88
+        }
89 89
 
90
-		$this->customer = get_userdata( $this->customer_id );
91
-		$this->gateway  = wpinv_get_payment_gateway( $this->parent_payment_id );
90
+        $this->customer = get_userdata( $this->customer_id );
91
+        $this->gateway  = wpinv_get_payment_gateway( $this->parent_payment_id );
92 92
 
93
-		do_action( 'wpinv_recurring_setup_subscription', $this );
93
+        do_action( 'wpinv_recurring_setup_subscription', $this );
94 94
 
95
-		return $this;
96
-	}
95
+        return $this;
96
+    }
97 97
 
98
-	/**
99
-	 * Magic __get function to dispatch a call to retrieve a private property
100
-	 *
101
-	 * @since 1.0.0
102
-	 */
103
-	public function __get( $key ) {
98
+    /**
99
+     * Magic __get function to dispatch a call to retrieve a private property
100
+     *
101
+     * @since 1.0.0
102
+     */
103
+    public function __get( $key ) {
104 104
 
105
-		if( method_exists( $this, 'get_' . $key ) ) {
105
+        if( method_exists( $this, 'get_' . $key ) ) {
106 106
 
107
-			return call_user_func( array( $this, 'get_' . $key ) );
107
+            return call_user_func( array( $this, 'get_' . $key ) );
108 108
 
109
-		} else {
109
+        } else {
110 110
 
111
-			return new WP_Error( 'wpinv-subscription-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) );
111
+            return new WP_Error( 'wpinv-subscription-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) );
112 112
 
113
-		}
113
+        }
114 114
 
115
-	}
115
+    }
116 116
 
117
-	/**
118
-	 * Creates a subscription
119
-	 *
120
-	 * @since  1.0.0
121
-	 * @param  array  $data Array of attributes for a subscription
122
-	 * @return mixed  false if data isn't passed and class not instantiated for creation
123
-	 */
124
-	public function create( $data = array() ) {
117
+    /**
118
+     * Creates a subscription
119
+     *
120
+     * @since  1.0.0
121
+     * @param  array  $data Array of attributes for a subscription
122
+     * @return mixed  false if data isn't passed and class not instantiated for creation
123
+     */
124
+    public function create( $data = array() ) {
125 125
 
126
-		if ( $this->id != 0 ) {
127
-			return false;
128
-		}
126
+        if ( $this->id != 0 ) {
127
+            return false;
128
+        }
129 129
 
130
-		$defaults = array(
131
-			'customer_id'       => 0,
132
-			'frequency'         => '',
133
-			'period'            => '',
134
-			'initial_amount'    => '',
135
-			'recurring_amount'  => '',
136
-			'bill_times'        => 0,
137
-			'parent_payment_id' => 0,
138
-			'product_id'        => 0,
139
-			'created'           => '',
140
-			'expiration'        => '',
141
-			'status'            => '',
142
-			'profile_id'        => '',
143
-		);
130
+        $defaults = array(
131
+            'customer_id'       => 0,
132
+            'frequency'         => '',
133
+            'period'            => '',
134
+            'initial_amount'    => '',
135
+            'recurring_amount'  => '',
136
+            'bill_times'        => 0,
137
+            'parent_payment_id' => 0,
138
+            'product_id'        => 0,
139
+            'created'           => '',
140
+            'expiration'        => '',
141
+            'status'            => '',
142
+            'profile_id'        => '',
143
+        );
144 144
 
145
-		$args = wp_parse_args( $data, $defaults );
145
+        $args = wp_parse_args( $data, $defaults );
146 146
 
147
-		if( $args['expiration'] && strtotime( 'NOW', current_time( 'timestamp' ) ) > strtotime( $args['expiration'], current_time( 'timestamp' ) ) ) {
147
+        if( $args['expiration'] && strtotime( 'NOW', current_time( 'timestamp' ) ) > strtotime( $args['expiration'], current_time( 'timestamp' ) ) ) {
148 148
 
149
-			if( 'active' == $args['status'] || 'trialling' == $args['status'] ) {
149
+            if( 'active' == $args['status'] || 'trialling' == $args['status'] ) {
150 150
 
151
-				// Force an active subscription to expired if expiration date is in the past
152
-				$args['status'] = 'expired';
151
+                // Force an active subscription to expired if expiration date is in the past
152
+                $args['status'] = 'expired';
153 153
 
154
-			}
155
-		}
154
+            }
155
+        }
156 156
 
157
-		do_action( 'wpinv_subscription_pre_create', $args );
157
+        do_action( 'wpinv_subscription_pre_create', $args );
158 158
 
159
-		$id = $this->subs_db->insert( $args, 'subscription' );
159
+        $id = $this->subs_db->insert( $args, 'subscription' );
160 160
 
161
-		do_action( 'wpinv_subscription_post_create', $id, $args );
161
+        do_action( 'wpinv_subscription_post_create', $id, $args );
162 162
 
163
-		return $this->setup_subscription( $id );
163
+        return $this->setup_subscription( $id );
164 164
 
165
-	}
165
+    }
166 166
 
167
-	/**
168
-	 * Updates a subscription
169
-	 *
170
-	 * @since  1.0.0
171
-	 * @param  array $args Array of fields to update
172
-	 * @return bool
173
-	 */
174
-	public function update( $args = array() ) {
167
+    /**
168
+     * Updates a subscription
169
+     *
170
+     * @since  1.0.0
171
+     * @param  array $args Array of fields to update
172
+     * @return bool
173
+     */
174
+    public function update( $args = array() ) {
175 175
 
176
-		$ret = $this->subs_db->update( $this->id, $args );
176
+        $ret = $this->subs_db->update( $this->id, $args );
177 177
 
178
-		do_action( 'wpinv_recurring_update_subscription', $this->id, $args, $this );
178
+        do_action( 'wpinv_recurring_update_subscription', $this->id, $args, $this );
179 179
 
180
-		return $ret;
180
+        return $ret;
181 181
 
182
-	}
182
+    }
183 183
 
184
-	/**
185
-	 * Delete the subscription
186
-	 *
187
-	 * @since  1.0.0
188
-	 * @return bool
189
-	 */
190
-	public function delete() {
191
-		return $this->subs_db->delete( $this->id );
192
-	}
184
+    /**
185
+     * Delete the subscription
186
+     *
187
+     * @since  1.0.0
188
+     * @return bool
189
+     */
190
+    public function delete() {
191
+        return $this->subs_db->delete( $this->id );
192
+    }
193 193
 
194 194
     /**
195 195
      * Retrieves the parent payment ID
@@ -366,185 +366,185 @@  discard block
 block discarded – undo
366 366
         return false;
367 367
     }
368 368
 
369
-	/**
370
-	 * Retrieves the transaction ID from the subscription
371
-	 *
372
-	 * @since  1.0.0
373
-	 * @return bool
374
-	 */
375
-	public function get_transaction_id() {
369
+    /**
370
+     * Retrieves the transaction ID from the subscription
371
+     *
372
+     * @since  1.0.0
373
+     * @return bool
374
+     */
375
+    public function get_transaction_id() {
376 376
 
377
-		if( empty( $this->transaction_id ) ) {
377
+        if( empty( $this->transaction_id ) ) {
378 378
 
379
-			$txn_id = wpinv_get_payment_transaction_id( $this->parent_payment_id );
379
+            $txn_id = wpinv_get_payment_transaction_id( $this->parent_payment_id );
380 380
 
381
-			if( ! empty( $txn_id ) && (int) $this->parent_payment_id !== (int) $txn_id ) {
382
-				$this->set_transaction_id( $txn_id );
383
-			}
381
+            if( ! empty( $txn_id ) && (int) $this->parent_payment_id !== (int) $txn_id ) {
382
+                $this->set_transaction_id( $txn_id );
383
+            }
384 384
 
385
-		}
385
+        }
386 386
 
387
-		return $this->transaction_id;
387
+        return $this->transaction_id;
388 388
 
389
-	}
389
+    }
390 390
 
391
-	/**
392
-	 * Stores the transaction ID for the subscription purchase
393
-	 *
394
-	 * @since  1.0.0.4
395
-	 * @return bool
396
-	 */
397
-	public function set_transaction_id( $txn_id = '' ) {
398
-		$this->update( array( 'transaction_id' => $txn_id ) );
399
-		$this->transaction_id = $txn_id;
400
-	}
391
+    /**
392
+     * Stores the transaction ID for the subscription purchase
393
+     *
394
+     * @since  1.0.0.4
395
+     * @return bool
396
+     */
397
+    public function set_transaction_id( $txn_id = '' ) {
398
+        $this->update( array( 'transaction_id' => $txn_id ) );
399
+        $this->transaction_id = $txn_id;
400
+    }
401 401
 
402
-	/**
403
-	 * Renews a subscription
404
-	 *
405
-	 * @since  1.0.0
406
-	 * @return bool
407
-	 */
408
-	public function renew() {
402
+    /**
403
+     * Renews a subscription
404
+     *
405
+     * @since  1.0.0
406
+     * @return bool
407
+     */
408
+    public function renew() {
409 409
 
410
-		$expires = $this->get_expiration_time();
410
+        $expires = $this->get_expiration_time();
411 411
 
412 412
 
413
-		// Determine what date to use as the start for the new expiration calculation
414
-		if( $expires > current_time( 'timestamp' ) && $this->is_active() ) {
413
+        // Determine what date to use as the start for the new expiration calculation
414
+        if( $expires > current_time( 'timestamp' ) && $this->is_active() ) {
415 415
 
416
-			$base_date  = $expires;
416
+            $base_date  = $expires;
417 417
 
418
-		} else {
418
+        } else {
419 419
 
420
-			$base_date  = current_time( 'timestamp' );
420
+            $base_date  = current_time( 'timestamp' );
421 421
 
422
-		}
422
+        }
423 423
 
424
-		$last_day = wpinv_cal_days_in_month( CAL_GREGORIAN, date( 'n', $base_date ), date( 'Y', $base_date ) );
424
+        $last_day = wpinv_cal_days_in_month( CAL_GREGORIAN, date( 'n', $base_date ), date( 'Y', $base_date ) );
425 425
 
426 426
 
427
-		$frequency = isset($this->frequency) ? $this->frequency : 1;
428
-		$expiration = date( 'Y-m-d H:i:s', strtotime( '+' . $frequency . ' ' . $this->period  . ' 23:59:59', $base_date ) );
427
+        $frequency = isset($this->frequency) ? $this->frequency : 1;
428
+        $expiration = date( 'Y-m-d H:i:s', strtotime( '+' . $frequency . ' ' . $this->period  . ' 23:59:59', $base_date ) );
429 429
 
430
-		if( date( 'j', $base_date ) == $last_day && 'day' != $this->period ) {
431
-			$expiration = date( 'Y-m-d H:i:s', strtotime( $expiration . ' +2 days' ) );
432
-		}
430
+        if( date( 'j', $base_date ) == $last_day && 'day' != $this->period ) {
431
+            $expiration = date( 'Y-m-d H:i:s', strtotime( $expiration . ' +2 days' ) );
432
+        }
433 433
 
434
-		$expiration  = apply_filters( 'wpinv_subscription_renewal_expiration', $expiration, $this->id, $this );
434
+        $expiration  = apply_filters( 'wpinv_subscription_renewal_expiration', $expiration, $this->id, $this );
435 435
 
436
-		do_action( 'wpinv_subscription_pre_renew', $this->id, $expiration, $this );
436
+        do_action( 'wpinv_subscription_pre_renew', $this->id, $expiration, $this );
437 437
 
438
-		$this->status = 'active';
439
-		$times_billed = $this->get_times_billed();
438
+        $this->status = 'active';
439
+        $times_billed = $this->get_times_billed();
440 440
 
441
-		// Complete subscription if applicable
442
-		if ( $this->bill_times > 0 && $times_billed >= $this->bill_times ) {
443
-			$this->complete();
444
-			$this->status = 'completed';
445
-		}
441
+        // Complete subscription if applicable
442
+        if ( $this->bill_times > 0 && $times_billed >= $this->bill_times ) {
443
+            $this->complete();
444
+            $this->status = 'completed';
445
+        }
446 446
 
447
-		$args = array(
448
-			'expiration' => $expiration,
449
-			'status'     => $this->status,
450
-		);
447
+        $args = array(
448
+            'expiration' => $expiration,
449
+            'status'     => $this->status,
450
+        );
451 451
 
452 452
         $this->subs_db->update( $this->id, $args );
453 453
 
454
-		do_action( 'wpinv_subscription_post_renew', $this->id, $expiration, $this );
455
-		do_action( 'wpinv_recurring_set_subscription_status', $this->id, $this->status, $this );
454
+        do_action( 'wpinv_subscription_post_renew', $this->id, $expiration, $this );
455
+        do_action( 'wpinv_recurring_set_subscription_status', $this->id, $this->status, $this );
456 456
 
457
-	}
457
+    }
458 458
 
459
-	/**
460
-	 * Marks a subscription as completed
461
-	 *
462
-	 * Subscription is completed when the number of payments matches the billing_times field
463
-	 *
464
-	 * @since  1.0.0
465
-	 * @return void
466
-	 */
467
-	public function complete() {
459
+    /**
460
+     * Marks a subscription as completed
461
+     *
462
+     * Subscription is completed when the number of payments matches the billing_times field
463
+     *
464
+     * @since  1.0.0
465
+     * @return void
466
+     */
467
+    public function complete() {
468 468
 
469
-		// Only mark a subscription as complete if it's not already cancelled.
470
-		if ( 'cancelled' === $this->status ) {
471
-			return;
472
-		}
469
+        // Only mark a subscription as complete if it's not already cancelled.
470
+        if ( 'cancelled' === $this->status ) {
471
+            return;
472
+        }
473 473
 
474
-		$args = array(
475
-			'status' => 'completed'
476
-		);
474
+        $args = array(
475
+            'status' => 'completed'
476
+        );
477 477
 
478
-		if( $this->subs_db->update( $this->id, $args ) ) {
478
+        if( $this->subs_db->update( $this->id, $args ) ) {
479 479
 
480
-			$this->status = 'completed';
480
+            $this->status = 'completed';
481 481
 
482
-			do_action( 'wpinv_subscription_completed', $this->id, $this );
482
+            do_action( 'wpinv_subscription_completed', $this->id, $this );
483 483
 
484
-		}
484
+        }
485 485
 
486
-	}
486
+    }
487 487
 
488
-	/**
489
-	 * Marks a subscription as expired
490
-	 *
491
-	 * Subscription is completed when the billing times is reached
492
-	 *
493
-	 * @since  1.0.0
494
-	 * @param  $check_expiration bool True if expiration date should be checked with merchant processor before expiring
495
-	 * @return void
496
-	 */
497
-	public function expire( $check_expiration = false ) {
488
+    /**
489
+     * Marks a subscription as expired
490
+     *
491
+     * Subscription is completed when the billing times is reached
492
+     *
493
+     * @since  1.0.0
494
+     * @param  $check_expiration bool True if expiration date should be checked with merchant processor before expiring
495
+     * @return void
496
+     */
497
+    public function expire( $check_expiration = false ) {
498 498
 
499
-		$expiration = $this->expiration;
499
+        $expiration = $this->expiration;
500 500
 
501
-		if( $check_expiration ) {
501
+        if( $check_expiration ) {
502 502
 
503
-			// check_expiration() updates $this->expiration so compare to $expiration above
503
+            // check_expiration() updates $this->expiration so compare to $expiration above
504 504
 
505
-			if( $expiration < $this->get_expiration() && current_time( 'timestamp' ) < $this->get_expiration_time() ) {
505
+            if( $expiration < $this->get_expiration() && current_time( 'timestamp' ) < $this->get_expiration_time() ) {
506 506
 
507
-				return false; // Do not mark as expired since real expiration date is in the future
508
-			}
507
+                return false; // Do not mark as expired since real expiration date is in the future
508
+            }
509 509
 
510
-		}
510
+        }
511 511
 
512
-		$args = array(
513
-			'status' => 'expired'
514
-		);
512
+        $args = array(
513
+            'status' => 'expired'
514
+        );
515 515
 
516
-		if( $this->subs_db->update( $this->id, $args ) ) {
516
+        if( $this->subs_db->update( $this->id, $args ) ) {
517 517
 
518
-			$this->status = 'expired';
518
+            $this->status = 'expired';
519 519
 
520
-			do_action( 'wpinv_subscription_expired', $this->id, $this );
520
+            do_action( 'wpinv_subscription_expired', $this->id, $this );
521 521
 
522
-		}
522
+        }
523 523
 
524
-	}
524
+    }
525 525
 
526
-	/**
527
-	 * Marks a subscription as failing
528
-	 *
529
-	 * @since  2.4.2
530
-	 * @return void
531
-	 */
532
-	public function failing() {
526
+    /**
527
+     * Marks a subscription as failing
528
+     *
529
+     * @since  2.4.2
530
+     * @return void
531
+     */
532
+    public function failing() {
533 533
 
534
-		$args = array(
535
-			'status' => 'failing'
536
-		);
534
+        $args = array(
535
+            'status' => 'failing'
536
+        );
537 537
 
538
-		if( $this->subs_db->update( $this->id, $args ) ) {
538
+        if( $this->subs_db->update( $this->id, $args ) ) {
539 539
 
540
-			$this->status = 'failing';
540
+            $this->status = 'failing';
541 541
 
542
-			do_action( 'wpinv_subscription_failing', $this->id, $this );
542
+            do_action( 'wpinv_subscription_failing', $this->id, $this );
543 543
 
544 544
 
545
-		}
545
+        }
546 546
 
547
-	}
547
+    }
548 548
 
549 549
     /**
550 550
      * Marks a subscription as cancelled
@@ -578,22 +578,22 @@  discard block
 block discarded – undo
578 578
         }
579 579
     }
580 580
 
581
-	/**
582
-	 * Determines if subscription can be cancelled
583
-	 *
584
-	 * This method is filtered by payment gateways in order to return true on subscriptions
585
-	 * that can be cancelled with a profile ID through the merchant processor
586
-	 *
587
-	 * @since  1.0.0
588
-	 * @return bool
589
-	 */
590
-	public function can_cancel() {
581
+    /**
582
+     * Determines if subscription can be cancelled
583
+     *
584
+     * This method is filtered by payment gateways in order to return true on subscriptions
585
+     * that can be cancelled with a profile ID through the merchant processor
586
+     *
587
+     * @since  1.0.0
588
+     * @return bool
589
+     */
590
+    public function can_cancel() {
591 591
         $ret = false;
592
-	    if( $this->gateway === 'manual' || in_array( $this->status, $this->get_cancellable_statuses() ) ) {
592
+        if( $this->gateway === 'manual' || in_array( $this->status, $this->get_cancellable_statuses() ) ) {
593 593
             $ret = true;
594 594
         }
595
-		return apply_filters( 'wpinv_subscription_can_cancel', $ret, $this );
596
-	}
595
+        return apply_filters( 'wpinv_subscription_can_cancel', $ret, $this );
596
+    }
597 597
 
598 598
     /**
599 599
      * Returns an array of subscription statuses that can be cancelled
@@ -606,197 +606,197 @@  discard block
 block discarded – undo
606 606
         return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) );
607 607
     }
608 608
 
609
-	/**
610
-	 * Retrieves the URL to cancel subscription
611
-	 *
612
-	 * @since  1.0.0
613
-	 * @return string
614
-	 */
615
-	public function get_cancel_url() {
609
+    /**
610
+     * Retrieves the URL to cancel subscription
611
+     *
612
+     * @since  1.0.0
613
+     * @return string
614
+     */
615
+    public function get_cancel_url() {
616 616
 
617
-		$url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'cancel_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-cancel' );
617
+        $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'cancel_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-cancel' );
618 618
 
619
-		return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
620
-	}
619
+        return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
620
+    }
621 621
 
622
-	/**
623
-	 * Determines if subscription can be manually renewed
624
-	 *
625
-	 * This method is filtered by payment gateways in order to return true on subscriptions
626
-	 * that can be renewed manually
627
-	 *
628
-	 * @since  2.5
629
-	 * @return bool
630
-	 */
631
-	public function can_renew() {
622
+    /**
623
+     * Determines if subscription can be manually renewed
624
+     *
625
+     * This method is filtered by payment gateways in order to return true on subscriptions
626
+     * that can be renewed manually
627
+     *
628
+     * @since  2.5
629
+     * @return bool
630
+     */
631
+    public function can_renew() {
632 632
 
633
-		return apply_filters( 'wpinv_subscription_can_renew', true, $this );
634
-	}
635
-
636
-	/**
637
-	 * Retrieves the URL to renew a subscription
638
-	 *
639
-	 * @since  2.5
640
-	 * @return string
641
-	 */
642
-	public function get_renew_url() {
643
-
644
-		$url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'renew_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-renew' );
645
-
646
-		return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
647
-	}
648
-
649
-	/**
650
-	 * Determines if subscription can have their payment method updated
651
-	 *
652
-	 * @since  1.0.0
653
-	 * @return bool
654
-	 */
655
-	public function can_update() {
656
-		return apply_filters( 'wpinv_subscription_can_update', false, $this );
657
-	}
658
-
659
-	/**
660
-	 * Retrieves the URL to update subscription
661
-	 *
662
-	 * @since  1.0.0
663
-	 * @return void
664
-	 */
665
-	public function get_update_url() {
666
-
667
-		$url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->id ) );
668
-
669
-		return apply_filters( 'wpinv_subscription_update_url', $url, $this );
670
-	}
671
-
672
-	/**
673
-	 * Determines if subscription is active
674
-	 *
675
-	 * @since  1.0.0
676
-	 * @return void
677
-	 */
678
-	public function is_active() {
679
-
680
-		$ret = false;
681
-
682
-		if( ! $this->is_expired() && ( $this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling' ) ) {
683
-			$ret = true;
684
-		}
685
-
686
-		return apply_filters( 'wpinv_subscription_is_active', $ret, $this->id, $this );
687
-
688
-	}
689
-
690
-	/**
691
-	 * Determines if subscription is expired
692
-	 *
693
-	 * @since  1.0.0
694
-	 * @return void
695
-	 */
696
-	public function is_expired() {
697
-
698
-		$ret = false;
699
-
700
-		if ( $this->status == 'expired' ) {
701
-
702
-			$ret = true;
703
-
704
-		} elseif( 'active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling'  ) {
705
-
706
-			$ret        = false;
707
-			$expiration = $this->get_expiration_time();
708
-
709
-			if( $expiration && strtotime( 'NOW', current_time( 'timestamp' ) ) > $expiration ) {
710
-				$ret = true;
711
-
712
-				if ( 'active' === $this->status || $this->status == 'trialling'  ) {
713
-					$this->expire();
714
-				}
715
-			}
716
-
717
-		}
718
-
719
-		return apply_filters( 'wpinv_subscription_is_expired', $ret, $this->id, $this );
720
-
721
-	}
722
-
723
-	/**
724
-	 * Retrieves the expiration date
725
-	 *
726
-	 * @since  1.0.0
727
-	 * @return string
728
-	 */
729
-	public function get_expiration() {
730
-		return $this->expiration;
731
-	}
732
-
733
-	/**
734
-	 * Retrieves the expiration date in a timestamp
735
-	 *
736
-	 * @since  1.0.0
737
-	 * @return int
738
-	 */
739
-	public function get_expiration_time() {
740
-		return strtotime( $this->expiration, current_time( 'timestamp' ) );
741
-	}
742
-
743
-	/**
744
-	 * Retrieves the subscription status
745
-	 *
746
-	 * @since  1.0.0
747
-	 * @return int
748
-	 */
749
-	public function get_status() {
750
-
751
-		// Monitor for page load delays on pages with large subscription lists (IE: Subscriptions table in admin)
752
-		$this->is_expired();
753
-		return $this->status;
754
-	}
755
-
756
-	/**
757
-	 * Retrieves the subscription status label
758
-	 *
759
-	 * @since  1.0.0
760
-	 * @return int
761
-	 */
762
-	public function get_status_label() {
763
-
764
-		switch( $this->get_status() ) {
765
-			case 'active' :
766
-				$status = __( 'Active', 'invoicing' );
767
-				break;
768
-
769
-			case 'cancelled' :
770
-				$status = __( 'Cancelled', 'invoicing' );
771
-				break;
772
-
773
-			case 'expired' :
774
-				$status = __( 'Expired', 'invoicing' );
775
-				break;
776
-
777
-			case 'pending' :
778
-				$status = __( 'Pending', 'invoicing' );
779
-				break;
780
-
781
-			case 'failing' :
782
-				$status = __( 'Failing', 'invoicing' );
783
-				break;
784
-
785
-			case 'trialling' :
786
-				$status = __( 'Trialling', 'invoicing' );
787
-				break;
788
-
789
-			case 'completed' :
790
-				$status = __( 'Completed', 'invoicing' );
791
-				break;
792
-
793
-			default:
794
-				$status = ucfirst( $this->get_status() );
795
-				break;
796
-		}
797
-
798
-		return $status;
799
-	}
633
+        return apply_filters( 'wpinv_subscription_can_renew', true, $this );
634
+    }
635
+
636
+    /**
637
+     * Retrieves the URL to renew a subscription
638
+     *
639
+     * @since  2.5
640
+     * @return string
641
+     */
642
+    public function get_renew_url() {
643
+
644
+        $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'renew_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-renew' );
645
+
646
+        return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
647
+    }
648
+
649
+    /**
650
+     * Determines if subscription can have their payment method updated
651
+     *
652
+     * @since  1.0.0
653
+     * @return bool
654
+     */
655
+    public function can_update() {
656
+        return apply_filters( 'wpinv_subscription_can_update', false, $this );
657
+    }
658
+
659
+    /**
660
+     * Retrieves the URL to update subscription
661
+     *
662
+     * @since  1.0.0
663
+     * @return void
664
+     */
665
+    public function get_update_url() {
666
+
667
+        $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->id ) );
668
+
669
+        return apply_filters( 'wpinv_subscription_update_url', $url, $this );
670
+    }
671
+
672
+    /**
673
+     * Determines if subscription is active
674
+     *
675
+     * @since  1.0.0
676
+     * @return void
677
+     */
678
+    public function is_active() {
679
+
680
+        $ret = false;
681
+
682
+        if( ! $this->is_expired() && ( $this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling' ) ) {
683
+            $ret = true;
684
+        }
685
+
686
+        return apply_filters( 'wpinv_subscription_is_active', $ret, $this->id, $this );
687
+
688
+    }
689
+
690
+    /**
691
+     * Determines if subscription is expired
692
+     *
693
+     * @since  1.0.0
694
+     * @return void
695
+     */
696
+    public function is_expired() {
697
+
698
+        $ret = false;
699
+
700
+        if ( $this->status == 'expired' ) {
701
+
702
+            $ret = true;
703
+
704
+        } elseif( 'active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling'  ) {
705
+
706
+            $ret        = false;
707
+            $expiration = $this->get_expiration_time();
708
+
709
+            if( $expiration && strtotime( 'NOW', current_time( 'timestamp' ) ) > $expiration ) {
710
+                $ret = true;
711
+
712
+                if ( 'active' === $this->status || $this->status == 'trialling'  ) {
713
+                    $this->expire();
714
+                }
715
+            }
716
+
717
+        }
718
+
719
+        return apply_filters( 'wpinv_subscription_is_expired', $ret, $this->id, $this );
720
+
721
+    }
722
+
723
+    /**
724
+     * Retrieves the expiration date
725
+     *
726
+     * @since  1.0.0
727
+     * @return string
728
+     */
729
+    public function get_expiration() {
730
+        return $this->expiration;
731
+    }
732
+
733
+    /**
734
+     * Retrieves the expiration date in a timestamp
735
+     *
736
+     * @since  1.0.0
737
+     * @return int
738
+     */
739
+    public function get_expiration_time() {
740
+        return strtotime( $this->expiration, current_time( 'timestamp' ) );
741
+    }
742
+
743
+    /**
744
+     * Retrieves the subscription status
745
+     *
746
+     * @since  1.0.0
747
+     * @return int
748
+     */
749
+    public function get_status() {
750
+
751
+        // Monitor for page load delays on pages with large subscription lists (IE: Subscriptions table in admin)
752
+        $this->is_expired();
753
+        return $this->status;
754
+    }
755
+
756
+    /**
757
+     * Retrieves the subscription status label
758
+     *
759
+     * @since  1.0.0
760
+     * @return int
761
+     */
762
+    public function get_status_label() {
763
+
764
+        switch( $this->get_status() ) {
765
+            case 'active' :
766
+                $status = __( 'Active', 'invoicing' );
767
+                break;
768
+
769
+            case 'cancelled' :
770
+                $status = __( 'Cancelled', 'invoicing' );
771
+                break;
772
+
773
+            case 'expired' :
774
+                $status = __( 'Expired', 'invoicing' );
775
+                break;
776
+
777
+            case 'pending' :
778
+                $status = __( 'Pending', 'invoicing' );
779
+                break;
780
+
781
+            case 'failing' :
782
+                $status = __( 'Failing', 'invoicing' );
783
+                break;
784
+
785
+            case 'trialling' :
786
+                $status = __( 'Trialling', 'invoicing' );
787
+                break;
788
+
789
+            case 'completed' :
790
+                $status = __( 'Completed', 'invoicing' );
791
+                break;
792
+
793
+            default:
794
+                $status = ucfirst( $this->get_status() );
795
+                break;
796
+        }
797
+
798
+        return $status;
799
+    }
800 800
 
801 801
     /**
802 802
      * Retrieves the subscription status label
Please login to merge, or discard this patch.
includes/admin/class-wpinv-subscriptions-list-table.php 1 patch
Indentation   +349 added lines, -349 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 // Load WP_List_Table if not loaded
15 15
 if( ! class_exists( 'WP_List_Table' ) ) {
16
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
16
+    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
17 17
 }
18 18
 
19 19
 /**
@@ -23,102 +23,102 @@  discard block
 block discarded – undo
23 23
  */
24 24
 class WPInv_Subscription_Reports_Table extends WP_List_Table {
25 25
 
26
-	/**
27
-	 * Number of results to show per page
28
-	 *
29
-	 * @since       1.0.0
30
-	 */
31
-
32
-	public $per_page        = 20;
33
-	public $total_count     = 0;
34
-	public $active_count    = 0;
35
-	public $pending_count   = 0;
36
-	public $expired_count   = 0;
37
-	public $completed_count = 0;
38
-	public $trialling_count  = 0;
39
-	public $cancelled_count = 0;
40
-	public $failing_count   = 0;
41
-
42
-	/**
43
-	 * Get things started
44
-	 *
45
-	 * @access      private
46
-	 * @since       1.0.0
47
-	 * @return      void
48
-	 */
49
-	function __construct(){
50
-		global $status, $page;
51
-
52
-		// Set parent defaults
53
-		parent::__construct( array(
54
-			'singular'  => 'subscription',
55
-			'plural'    => 'subscriptions',
56
-			'ajax'      => false
57
-		) );
58
-
59
-		$this->get_subscription_counts();
60
-
61
-	}
62
-
63
-	/**
64
-	 * Retrieve the view types
65
-	 *
66
-	 * @access public
67
-	 * @since 1.0.0
68
-	 * @return array $views All the views available
69
-	 */
70
-	public function get_views() {
71
-
72
-		$current         = isset( $_GET['status'] ) ? $_GET['status'] : '';
73
-		$total_count     = '&nbsp;<span class="count">(' . $this->total_count    . ')</span>';
74
-		$active_count    = '&nbsp;<span class="count">(' . $this->active_count . ')</span>';
75
-		$pending_count   = '&nbsp;<span class="count">(' . $this->pending_count . ')</span>';
76
-		$expired_count   = '&nbsp;<span class="count">(' . $this->expired_count  . ')</span>';
77
-		$completed_count = '&nbsp;<span class="count">(' . $this->completed_count . ')</span>';
78
-		$trialling_count  = '&nbsp;<span class="count">(' . $this->trialling_count   . ')</span>';
79
-		$cancelled_count = '&nbsp;<span class="count">(' . $this->cancelled_count   . ')</span>';
80
-		$failing_count   = '&nbsp;<span class="count">(' . $this->failing_count   . ')</span>';
81
-
82
-		$views = array(
83
-			'all'       => sprintf( '<a href="%s"%s>%s</a>', remove_query_arg( array( 'status', 'paged' ) ), $current === 'all' || $current == '' ? ' class="current"' : '', __('All','invoicing' ) . $total_count ),
84
-			'active'    => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'active', 'paged' => FALSE ) ), $current === 'active' ? ' class="current"' : '', __('Active','invoicing' ) . $active_count ),
85
-			'pending'   => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'pending', 'paged' => FALSE ) ), $current === 'pending' ? ' class="current"' : '', __('Pending','invoicing' ) . $pending_count ),
86
-			'expired'   => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'expired', 'paged' => FALSE ) ), $current === 'expired' ? ' class="current"' : '', __('Expired','invoicing' ) . $expired_count ),
87
-			'completed' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'completed', 'paged' => FALSE ) ), $current === 'completed' ? ' class="current"' : '', __('Completed','invoicing' ) . $completed_count ),
88
-			'trialling'  => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'trialling', 'paged' => FALSE ) ), $current === 'trialling' ? ' class="current"' : '', __('Trialling','invoicing' ) . $trialling_count ),
89
-			'cancelled' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'cancelled', 'paged' => FALSE ) ), $current === 'cancelled' ? ' class="current"' : '', __('Cancelled','invoicing' ) . $cancelled_count ),
90
-			'failing'   => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'failing', 'paged' => FALSE ) ), $current === 'failing' ? ' class="current"' : '', __('Failing','invoicing' ) . $failing_count ),
91
-		);
92
-
93
-		return apply_filters( 'wpinv_recurring_subscriptions_table_views', $views );
94
-	}
95
-
96
-	/**
97
-	 * Show the search field
98
-	 *
99
-	 * @since 2.5
100
-	 * @access public
101
-	 *
102
-	 * @param string $text Label for the search box
103
-	 * @param string $input_id ID of the search box
104
-	 *
105
-	 * @return void
106
-	 */
107
-	public function search_box( $text, $input_id ) {
108
-
109
-		if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) {
110
-			return;
111
-		}
112
-
113
-		$input_id = $input_id . '-search-input';
114
-
115
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
116
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
117
-		}
118
-
119
-		if ( ! empty( $_REQUEST['order'] ) ) {
120
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
121
-		}
26
+    /**
27
+     * Number of results to show per page
28
+     *
29
+     * @since       1.0.0
30
+     */
31
+
32
+    public $per_page        = 20;
33
+    public $total_count     = 0;
34
+    public $active_count    = 0;
35
+    public $pending_count   = 0;
36
+    public $expired_count   = 0;
37
+    public $completed_count = 0;
38
+    public $trialling_count  = 0;
39
+    public $cancelled_count = 0;
40
+    public $failing_count   = 0;
41
+
42
+    /**
43
+     * Get things started
44
+     *
45
+     * @access      private
46
+     * @since       1.0.0
47
+     * @return      void
48
+     */
49
+    function __construct(){
50
+        global $status, $page;
51
+
52
+        // Set parent defaults
53
+        parent::__construct( array(
54
+            'singular'  => 'subscription',
55
+            'plural'    => 'subscriptions',
56
+            'ajax'      => false
57
+        ) );
58
+
59
+        $this->get_subscription_counts();
60
+
61
+    }
62
+
63
+    /**
64
+     * Retrieve the view types
65
+     *
66
+     * @access public
67
+     * @since 1.0.0
68
+     * @return array $views All the views available
69
+     */
70
+    public function get_views() {
71
+
72
+        $current         = isset( $_GET['status'] ) ? $_GET['status'] : '';
73
+        $total_count     = '&nbsp;<span class="count">(' . $this->total_count    . ')</span>';
74
+        $active_count    = '&nbsp;<span class="count">(' . $this->active_count . ')</span>';
75
+        $pending_count   = '&nbsp;<span class="count">(' . $this->pending_count . ')</span>';
76
+        $expired_count   = '&nbsp;<span class="count">(' . $this->expired_count  . ')</span>';
77
+        $completed_count = '&nbsp;<span class="count">(' . $this->completed_count . ')</span>';
78
+        $trialling_count  = '&nbsp;<span class="count">(' . $this->trialling_count   . ')</span>';
79
+        $cancelled_count = '&nbsp;<span class="count">(' . $this->cancelled_count   . ')</span>';
80
+        $failing_count   = '&nbsp;<span class="count">(' . $this->failing_count   . ')</span>';
81
+
82
+        $views = array(
83
+            'all'       => sprintf( '<a href="%s"%s>%s</a>', remove_query_arg( array( 'status', 'paged' ) ), $current === 'all' || $current == '' ? ' class="current"' : '', __('All','invoicing' ) . $total_count ),
84
+            'active'    => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'active', 'paged' => FALSE ) ), $current === 'active' ? ' class="current"' : '', __('Active','invoicing' ) . $active_count ),
85
+            'pending'   => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'pending', 'paged' => FALSE ) ), $current === 'pending' ? ' class="current"' : '', __('Pending','invoicing' ) . $pending_count ),
86
+            'expired'   => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'expired', 'paged' => FALSE ) ), $current === 'expired' ? ' class="current"' : '', __('Expired','invoicing' ) . $expired_count ),
87
+            'completed' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'completed', 'paged' => FALSE ) ), $current === 'completed' ? ' class="current"' : '', __('Completed','invoicing' ) . $completed_count ),
88
+            'trialling'  => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'trialling', 'paged' => FALSE ) ), $current === 'trialling' ? ' class="current"' : '', __('Trialling','invoicing' ) . $trialling_count ),
89
+            'cancelled' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'cancelled', 'paged' => FALSE ) ), $current === 'cancelled' ? ' class="current"' : '', __('Cancelled','invoicing' ) . $cancelled_count ),
90
+            'failing'   => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'failing', 'paged' => FALSE ) ), $current === 'failing' ? ' class="current"' : '', __('Failing','invoicing' ) . $failing_count ),
91
+        );
92
+
93
+        return apply_filters( 'wpinv_recurring_subscriptions_table_views', $views );
94
+    }
95
+
96
+    /**
97
+     * Show the search field
98
+     *
99
+     * @since 2.5
100
+     * @access public
101
+     *
102
+     * @param string $text Label for the search box
103
+     * @param string $input_id ID of the search box
104
+     *
105
+     * @return void
106
+     */
107
+    public function search_box( $text, $input_id ) {
108
+
109
+        if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) {
110
+            return;
111
+        }
112
+
113
+        $input_id = $input_id . '-search-input';
114
+
115
+        if ( ! empty( $_REQUEST['orderby'] ) ) {
116
+            echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
117
+        }
118
+
119
+        if ( ! empty( $_REQUEST['order'] ) ) {
120
+            echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
121
+        }
122 122
 ?>
123 123
 		<p class="search-box">
124 124
 			<?php do_action( 'wpinv_recurring_subscription_search_box' ); ?>
@@ -127,18 +127,18 @@  discard block
 block discarded – undo
127 127
 			<?php submit_button( $text, 'button', false, false, array('ID' => 'search-submit') ); ?><br/>
128 128
 		</p>
129 129
 <?php
130
-	}
131
-
132
-	/**
133
-	 * Render most columns
134
-	 *
135
-	 * @access      private
136
-	 * @since       1.0.0
137
-	 * @return      string
138
-	 */
139
-	function column_default( $item, $column_name ) {
140
-		return $item->$column_name;
141
-	}
130
+    }
131
+
132
+    /**
133
+     * Render most columns
134
+     *
135
+     * @access      private
136
+     * @since       1.0.0
137
+     * @return      string
138
+     */
139
+    function column_default( $item, $column_name ) {
140
+        return $item->$column_name;
141
+    }
142 142
 
143 143
     /**
144 144
      * Subscription id column
@@ -151,244 +151,244 @@  discard block
 block discarded – undo
151 151
         return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" target="_blank">' . $item->id . '</a>';
152 152
     }
153 153
 
154
-	/**
155
-	 * Customer column
156
-	 *
157
-	 * @access      private
158
-	 * @since       1.0.0
159
-	 * @return      string
160
-	 */
161
-	function column_customer_id( $item ) {
162
-		$subscriber = get_userdata( $item->customer_id );
163
-		$customer   = ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email;
164
-
165
-		return '<a href="' . esc_url( get_edit_user_link( $item->customer_id ) ) . '" target="_blank">' . $customer . '</a>';
166
-	}
167
-
168
-	/**
169
-	 * Status column
170
-	 *
171
-	 * @access      private
172
-	 * @since       1.0.0
173
-	 * @return      string
174
-	 */
175
-	function column_status( $item ) {
176
-		return $item->get_status_label();
177
-	}
178
-
179
-	/**
180
-	 * Period column
181
-	 *
182
-	 * @access      private
183
-	 * @since       1.0.0
184
-	 * @return      string
185
-	 */
186
-	function column_period( $item ) {
187
-
188
-		$period = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->period,$item->frequency );
189
-
190
-		return wpinv_price( wpinv_format_amount( $item->recurring_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ) . ' / ' . $period;
191
-	}
192
-
193
-	/**
194
-	 * Billing Times column
195
-	 *
196
-	 * @access      private
197
-	 * @since       1.0.0
198
-	 * @return      string
199
-	 */
200
-	function column_bill_times( $item ) {
201
-		return $item->get_times_billed() . ' / ' . ( ( $item->bill_times == 0 ) ? 'Until Cancelled' : $item->bill_times );
202
-	}
203
-
204
-	/**
205
-	 * Initial Amount column
206
-	 *
207
-	 * @access      private
208
-	 * @since       1.0.0
209
-	 * @return      string
210
-	 */
211
-	function column_initial_amount( $item ) {
212
-		return wpinv_price( wpinv_format_amount( $item->initial_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) );
213
-	}
214
-
215
-	/**
216
-	 * Renewal date column
217
-	 *
218
-	 * @access      private
219
-	 * @since       1.0.0
220
-	 * @return      string
221
-	 */
222
-	function column_renewal_date( $item ) {
223
-		return $renewal_date = ! empty( $item->expiration ) ? date_i18n( get_option( 'date_format' ), strtotime( $item->expiration ) ) : __( 'N/A', 'invoicing' );
224
-	}
225
-
226
-	/**
227
-	 * Payment column
228
-	 *
229
-	 * @access      private
230
-	 * @since       1.0.0
231
-	 * @return      string
232
-	 */
233
-	function column_parent_payment_id( $item ) {
234
-		return '<a href="' . get_edit_post_link( $item->parent_payment_id ) . '" target="_blank">' . wpinv_get_invoice_number( $item->parent_payment_id ) . '</a>';
235
-	}
236
-
237
-	/**
238
-	 * Product ID column
239
-	 *
240
-	 * @access      private
241
-	 * @since       1.0.0
242
-	 * @return      string
243
-	 */
244
-	function column_product_id( $item ) {
245
-		return '<a href="' . esc_url( admin_url( 'post.php?action=edit&post=' . $item->product_id ) ) . '" target="_blank">' . get_the_title( $item->product_id ) . '</a>';
246
-	}
247
-
248
-	/**
249
-	 * Render the edit column
250
-	 *
251
-	 * @access      private
252
-	 * @since       2.0
253
-	 * @return      string
254
-	 */
255
-	function column_actions( $item ) {
256
-		return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" title="' . esc_attr( __( 'View or edit subscription', 'invoicing' ) ) . '" target="_blank">' . __( 'View', 'invoicing' ) . '</a>';
257
-	}
258
-
259
-
260
-	/**
261
-	 * Retrieve the table columns
262
-	 *
263
-	 * @access      private
264
-	 * @since       1.0.0
265
-	 * @return      array
266
-	 */
267
-
268
-	function get_columns(){
269
-		$columns = array(
270
-			'sub_id'            => __( 'ID', 'invoicing' ),
271
-			'customer_id'       => __( 'Customer', 'invoicing' ),
272
-			'status'            => __( 'Status', 'invoicing' ),
273
-			'period'            => __( 'Billing Cycle', 'invoicing' ),
274
-			'initial_amount'    => __( 'Initial Amount', 'invoicing' ),
275
-			'bill_times'        => __( 'Times Billed', 'invoicing' ),
276
-			'renewal_date'      => __( 'Renewal Date', 'invoicing' ),
277
-			'parent_payment_id' => __( 'Invoice', 'invoicing' ),
278
-			'product_id'        => __( 'Item', 'invoicing' ),
279
-			'actions'           => __( 'Actions', 'invoicing' ),
280
-		);
281
-
282
-		return apply_filters( 'wpinv_report_subscription_columns', $columns );
283
-	}
284
-
285
-	/**
286
-	 * Retrieve the current page number
287
-	 *
288
-	 * @access      private
289
-	 * @since       1.0.0
290
-	 * @return      int
291
-	 */
292
-	function get_paged() {
293
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
294
-	}
295
-
296
-	/**
297
-	 * Retrieve the subscription counts
298
-	 *
299
-	 * @access public
300
-	 * @since 1.4
301
-	 * @return void
302
-	 */
303
-	public function get_subscription_counts() {
304
-
305
-		global $wp_query;
306
-
307
-		$db = new WPInv_Subscriptions_DB;
308
-
309
-		$search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : '';
310
-
311
-		$this->total_count     = $db->count();
312
-		$this->active_count    = $db->count( array( 'status' => 'active', 'search' => $search ) );
313
-		$this->pending_count   = $db->count( array( 'status' => 'pending', 'search' => $search ) );
314
-		$this->expired_count   = $db->count( array( 'status' => 'expired', 'search' => $search ) );
315
-		$this->trialling_count  = $db->count( array( 'status' => 'trialling', 'search' => $search ) );
316
-		$this->cancelled_count = $db->count( array( 'status' => 'cancelled', 'search' => $search ) );
317
-		$this->completed_count = $db->count( array( 'status' => 'completed', 'search' => $search ) );
318
-		$this->failing_count   = $db->count( array( 'status' => 'failing', 'search' => $search ) );
319
-
320
-	}
321
-
322
-	/**
323
-	 * Setup the final data for the table
324
-	 *
325
-	 * @access      private
326
-	 * @since       1.0.0
327
-	 * @uses        $this->_column_headers
328
-	 * @uses        $this->items
329
-	 * @uses        $this->get_columns()
330
-	 * @uses        $this->get_sortable_columns()
331
-	 * @uses        $this->get_pagenum()
332
-	 * @uses        $this->set_pagination_args()
333
-	 * @return      array
334
-	 */
335
-	function prepare_items() {
336
-
337
-		$columns  = $this->get_columns();
338
-		$hidden   = array(); // No hidden columns
339
-		$status   = isset( $_GET['status'] ) ? $_GET['status'] : 'any';
340
-		$sortable = $this->get_sortable_columns();
341
-
342
-		$this->_column_headers = array( $columns, $hidden, $sortable );
343
-
344
-		$current_page = $this->get_pagenum();
345
-
346
-		$db     = new WPInv_Subscriptions_DB;
347
-		$search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : '';
348
-		$args   = array(
349
-			'number' => $this->per_page,
350
-			'offset' => $this->per_page * ( $this->get_paged() - 1 ),
351
-			'search' => $search
352
-		);
353
-
354
-		if ( 'any' !== $status ) {
355
-			$args['status'] = $status;
356
-		}
357
-
358
-		$this->items = $db->get_subscriptions( $args );
359
-
360
-		switch ( $status ) {
361
-			case 'active':
362
-				$total_items = $this->active_count;
363
-				break;
364
-			case 'pending':
365
-				$total_items = $this->pending_count;
366
-				break;
367
-			case 'expired':
368
-				$total_items = $this->expired_count;
369
-				break;
370
-			case 'cancelled':
371
-				$total_items = $this->cancelled_count;
372
-				break;
373
-			case 'failing':
374
-				$total_items = $this->failing_count;
375
-				break;
376
-			case 'trialling':
377
-				$total_items = $this->trialling_count;
378
-				break;
379
-			case 'completed':
380
-				$total_items = $this->completed_count;
381
-				break;
382
-			case 'any':
383
-			default:
384
-				$total_items = $this->total_count;
385
-				break;
386
-		}
387
-
388
-		$this->set_pagination_args( array(
389
-			'total_items' => $total_items,
390
-			'per_page'    => $this->per_page,
391
-			'total_pages' => ceil( $total_items / $this->per_page )
392
-		) );
393
-	}
154
+    /**
155
+     * Customer column
156
+     *
157
+     * @access      private
158
+     * @since       1.0.0
159
+     * @return      string
160
+     */
161
+    function column_customer_id( $item ) {
162
+        $subscriber = get_userdata( $item->customer_id );
163
+        $customer   = ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email;
164
+
165
+        return '<a href="' . esc_url( get_edit_user_link( $item->customer_id ) ) . '" target="_blank">' . $customer . '</a>';
166
+    }
167
+
168
+    /**
169
+     * Status column
170
+     *
171
+     * @access      private
172
+     * @since       1.0.0
173
+     * @return      string
174
+     */
175
+    function column_status( $item ) {
176
+        return $item->get_status_label();
177
+    }
178
+
179
+    /**
180
+     * Period column
181
+     *
182
+     * @access      private
183
+     * @since       1.0.0
184
+     * @return      string
185
+     */
186
+    function column_period( $item ) {
187
+
188
+        $period = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->period,$item->frequency );
189
+
190
+        return wpinv_price( wpinv_format_amount( $item->recurring_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ) . ' / ' . $period;
191
+    }
192
+
193
+    /**
194
+     * Billing Times column
195
+     *
196
+     * @access      private
197
+     * @since       1.0.0
198
+     * @return      string
199
+     */
200
+    function column_bill_times( $item ) {
201
+        return $item->get_times_billed() . ' / ' . ( ( $item->bill_times == 0 ) ? 'Until Cancelled' : $item->bill_times );
202
+    }
203
+
204
+    /**
205
+     * Initial Amount column
206
+     *
207
+     * @access      private
208
+     * @since       1.0.0
209
+     * @return      string
210
+     */
211
+    function column_initial_amount( $item ) {
212
+        return wpinv_price( wpinv_format_amount( $item->initial_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) );
213
+    }
214
+
215
+    /**
216
+     * Renewal date column
217
+     *
218
+     * @access      private
219
+     * @since       1.0.0
220
+     * @return      string
221
+     */
222
+    function column_renewal_date( $item ) {
223
+        return $renewal_date = ! empty( $item->expiration ) ? date_i18n( get_option( 'date_format' ), strtotime( $item->expiration ) ) : __( 'N/A', 'invoicing' );
224
+    }
225
+
226
+    /**
227
+     * Payment column
228
+     *
229
+     * @access      private
230
+     * @since       1.0.0
231
+     * @return      string
232
+     */
233
+    function column_parent_payment_id( $item ) {
234
+        return '<a href="' . get_edit_post_link( $item->parent_payment_id ) . '" target="_blank">' . wpinv_get_invoice_number( $item->parent_payment_id ) . '</a>';
235
+    }
236
+
237
+    /**
238
+     * Product ID column
239
+     *
240
+     * @access      private
241
+     * @since       1.0.0
242
+     * @return      string
243
+     */
244
+    function column_product_id( $item ) {
245
+        return '<a href="' . esc_url( admin_url( 'post.php?action=edit&post=' . $item->product_id ) ) . '" target="_blank">' . get_the_title( $item->product_id ) . '</a>';
246
+    }
247
+
248
+    /**
249
+     * Render the edit column
250
+     *
251
+     * @access      private
252
+     * @since       2.0
253
+     * @return      string
254
+     */
255
+    function column_actions( $item ) {
256
+        return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" title="' . esc_attr( __( 'View or edit subscription', 'invoicing' ) ) . '" target="_blank">' . __( 'View', 'invoicing' ) . '</a>';
257
+    }
258
+
259
+
260
+    /**
261
+     * Retrieve the table columns
262
+     *
263
+     * @access      private
264
+     * @since       1.0.0
265
+     * @return      array
266
+     */
267
+
268
+    function get_columns(){
269
+        $columns = array(
270
+            'sub_id'            => __( 'ID', 'invoicing' ),
271
+            'customer_id'       => __( 'Customer', 'invoicing' ),
272
+            'status'            => __( 'Status', 'invoicing' ),
273
+            'period'            => __( 'Billing Cycle', 'invoicing' ),
274
+            'initial_amount'    => __( 'Initial Amount', 'invoicing' ),
275
+            'bill_times'        => __( 'Times Billed', 'invoicing' ),
276
+            'renewal_date'      => __( 'Renewal Date', 'invoicing' ),
277
+            'parent_payment_id' => __( 'Invoice', 'invoicing' ),
278
+            'product_id'        => __( 'Item', 'invoicing' ),
279
+            'actions'           => __( 'Actions', 'invoicing' ),
280
+        );
281
+
282
+        return apply_filters( 'wpinv_report_subscription_columns', $columns );
283
+    }
284
+
285
+    /**
286
+     * Retrieve the current page number
287
+     *
288
+     * @access      private
289
+     * @since       1.0.0
290
+     * @return      int
291
+     */
292
+    function get_paged() {
293
+        return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
294
+    }
295
+
296
+    /**
297
+     * Retrieve the subscription counts
298
+     *
299
+     * @access public
300
+     * @since 1.4
301
+     * @return void
302
+     */
303
+    public function get_subscription_counts() {
304
+
305
+        global $wp_query;
306
+
307
+        $db = new WPInv_Subscriptions_DB;
308
+
309
+        $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : '';
310
+
311
+        $this->total_count     = $db->count();
312
+        $this->active_count    = $db->count( array( 'status' => 'active', 'search' => $search ) );
313
+        $this->pending_count   = $db->count( array( 'status' => 'pending', 'search' => $search ) );
314
+        $this->expired_count   = $db->count( array( 'status' => 'expired', 'search' => $search ) );
315
+        $this->trialling_count  = $db->count( array( 'status' => 'trialling', 'search' => $search ) );
316
+        $this->cancelled_count = $db->count( array( 'status' => 'cancelled', 'search' => $search ) );
317
+        $this->completed_count = $db->count( array( 'status' => 'completed', 'search' => $search ) );
318
+        $this->failing_count   = $db->count( array( 'status' => 'failing', 'search' => $search ) );
319
+
320
+    }
321
+
322
+    /**
323
+     * Setup the final data for the table
324
+     *
325
+     * @access      private
326
+     * @since       1.0.0
327
+     * @uses        $this->_column_headers
328
+     * @uses        $this->items
329
+     * @uses        $this->get_columns()
330
+     * @uses        $this->get_sortable_columns()
331
+     * @uses        $this->get_pagenum()
332
+     * @uses        $this->set_pagination_args()
333
+     * @return      array
334
+     */
335
+    function prepare_items() {
336
+
337
+        $columns  = $this->get_columns();
338
+        $hidden   = array(); // No hidden columns
339
+        $status   = isset( $_GET['status'] ) ? $_GET['status'] : 'any';
340
+        $sortable = $this->get_sortable_columns();
341
+
342
+        $this->_column_headers = array( $columns, $hidden, $sortable );
343
+
344
+        $current_page = $this->get_pagenum();
345
+
346
+        $db     = new WPInv_Subscriptions_DB;
347
+        $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : '';
348
+        $args   = array(
349
+            'number' => $this->per_page,
350
+            'offset' => $this->per_page * ( $this->get_paged() - 1 ),
351
+            'search' => $search
352
+        );
353
+
354
+        if ( 'any' !== $status ) {
355
+            $args['status'] = $status;
356
+        }
357
+
358
+        $this->items = $db->get_subscriptions( $args );
359
+
360
+        switch ( $status ) {
361
+            case 'active':
362
+                $total_items = $this->active_count;
363
+                break;
364
+            case 'pending':
365
+                $total_items = $this->pending_count;
366
+                break;
367
+            case 'expired':
368
+                $total_items = $this->expired_count;
369
+                break;
370
+            case 'cancelled':
371
+                $total_items = $this->cancelled_count;
372
+                break;
373
+            case 'failing':
374
+                $total_items = $this->failing_count;
375
+                break;
376
+            case 'trialling':
377
+                $total_items = $this->trialling_count;
378
+                break;
379
+            case 'completed':
380
+                $total_items = $this->completed_count;
381
+                break;
382
+            case 'any':
383
+            default:
384
+                $total_items = $this->total_count;
385
+                break;
386
+        }
387
+
388
+        $this->set_pagination_args( array(
389
+            'total_items' => $total_items,
390
+            'per_page'    => $this->per_page,
391
+            'total_pages' => ceil( $total_items / $this->per_page )
392
+        ) );
393
+    }
394 394
 }
Please login to merge, or discard this patch.
includes/admin/subscriptions.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -8,23 +8,23 @@  discard block
 block discarded – undo
8 8
  */
9 9
 function wpinv_subscriptions_page() {
10 10
 
11
-	if ( ! empty( $_GET['id'] ) ) {
11
+    if ( ! empty( $_GET['id'] ) ) {
12 12
 
13 13
         wpinv_recurring_subscription_details();
14 14
 
15
-		return;
15
+        return;
16 16
 
17
-	}
18
-	?>
17
+    }
18
+    ?>
19 19
 	<div class="wrap">
20 20
 
21 21
 		<h1>
22 22
 			<?php _e( 'Subscriptions', 'invoicing' ); ?>
23 23
 		</h1>
24 24
 		<?php
25
-		$subscribers_table = new WPInv_Subscription_Reports_Table();
26
-		$subscribers_table->prepare_items();
27
-		?>
25
+        $subscribers_table = new WPInv_Subscription_Reports_Table();
26
+        $subscribers_table->prepare_items();
27
+        ?>
28 28
 
29 29
 		<form id="subscribers-filter" method="get">
30 30
 
@@ -47,24 +47,24 @@  discard block
 block discarded – undo
47 47
  */
48 48
 function wpinv_recurring_subscription_details() {
49 49
 
50
-	$render = true;
50
+    $render = true;
51 51
 
52
-	if ( ! current_user_can( 'manage_invoicing' ) ) {
53
-		die( __( 'You are not permitted to view this data.', 'invoicing' ) );
54
-	}
52
+    if ( ! current_user_can( 'manage_invoicing' ) ) {
53
+        die( __( 'You are not permitted to view this data.', 'invoicing' ) );
54
+    }
55 55
 
56
-	if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
56
+    if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
57 57
         die( __( 'Invalid subscription ID Provided.', 'invoicing' ) );
58
-	}
58
+    }
59 59
 
60
-	$sub_id  = (int) $_GET['id'];
61
-	$sub     = new WPInv_Subscription( $sub_id );
60
+    $sub_id  = (int) $_GET['id'];
61
+    $sub     = new WPInv_Subscription( $sub_id );
62 62
 
63
-	if ( empty( $sub ) ) {
64
-		die( __( 'Invalid subscription ID Provided.', 'invoicing' ) );
65
-	}
63
+    if ( empty( $sub ) ) {
64
+        die( __( 'Invalid subscription ID Provided.', 'invoicing' ) );
65
+    }
66 66
 
67
-	?>
67
+    ?>
68 68
 	<div class="wrap">
69 69
 		<h2><?php _e( 'Subscription Details', 'invoicing' ); ?></h2>
70 70
 
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
 										</td>
89 89
 										<td>
90 90
 											<?php
91
-											$frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency );
92
-											$billing   = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency;
93
-											$initial   = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) );
94
-											printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing );
95
-											?>
91
+                                            $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency );
92
+                                            $billing   = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency;
93
+                                            $initial   = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) );
94
+                                            printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing );
95
+                                            ?>
96 96
 										</td>
97 97
 									</tr>
98 98
 									<tr>
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
 
135 135
                                             ?>
136 136
 											<a href="<?php echo esc_url( add_query_arg( array(
137
-													'post'   => $sub->product_id,
138
-													'action' => 'edit'
139
-												), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a>
137
+                                                    'post'   => $sub->product_id,
138
+                                                    'action' => 'edit'
139
+                                                ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a>
140 140
 										</td>
141 141
 									</tr>
142 142
 									<tr>
@@ -299,56 +299,56 @@  discard block
 block discarded – undo
299 299
  */
300 300
 function wpinv_recurring_process_subscription_update() {
301 301
 
302
-	if( empty( $_POST['sub_id'] ) ) {
303
-		return;
304
-	}
302
+    if( empty( $_POST['sub_id'] ) ) {
303
+        return;
304
+    }
305 305
 
306
-	if( empty( $_POST['wpinv_update_subscription'] ) ) {
307
-		return;
308
-	}
306
+    if( empty( $_POST['wpinv_update_subscription'] ) ) {
307
+        return;
308
+    }
309 309
 
310
-	if( ! current_user_can( 'manage_invoicing') ) {
311
-		return;
312
-	}
310
+    if( ! current_user_can( 'manage_invoicing') ) {
311
+        return;
312
+    }
313 313
 
314
-	if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) {
315
-		wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
316
-	}
314
+    if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) {
315
+        wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
316
+    }
317 317
 
318
-	$profile_id      = sanitize_text_field( $_POST['profile_id'] );
319
-	$transaction_id  = sanitize_text_field( $_POST['transaction_id'] );
320
-	$product_id      = absint( $_POST['product_id'] );
321
-	$subscription    = new WPInv_Subscription( absint( $_POST['sub_id'] ) );
322
-	$subscription->update( array(
323
-		'status'         => sanitize_text_field( $_POST['status'] ),
324
-		'profile_id'     => $profile_id,
325
-		'product_id'     => $product_id,
326
-		'transaction_id' => $transaction_id,
327
-	) );
318
+    $profile_id      = sanitize_text_field( $_POST['profile_id'] );
319
+    $transaction_id  = sanitize_text_field( $_POST['transaction_id'] );
320
+    $product_id      = absint( $_POST['product_id'] );
321
+    $subscription    = new WPInv_Subscription( absint( $_POST['sub_id'] ) );
322
+    $subscription->update( array(
323
+        'status'         => sanitize_text_field( $_POST['status'] ),
324
+        'profile_id'     => $profile_id,
325
+        'product_id'     => $product_id,
326
+        'transaction_id' => $transaction_id,
327
+    ) );
328 328
 
329
-	$status = sanitize_text_field( $_POST['status'] );
329
+    $status = sanitize_text_field( $_POST['status'] );
330 330
 
331
-	switch( $status ) {
331
+    switch( $status ) {
332 332
 
333
-		case 'cancelled' :
333
+        case 'cancelled' :
334 334
 
335
-			$subscription->cancel();
336
-			break;
335
+            $subscription->cancel();
336
+            break;
337 337
 
338
-		case 'expired' :
338
+        case 'expired' :
339 339
 
340
-			$subscription->expire();
341
-			break;
340
+            $subscription->expire();
341
+            break;
342 342
 
343
-		case 'completed' :
343
+        case 'completed' :
344 344
 
345
-			$subscription->complete();
346
-			break;
345
+            $subscription->complete();
346
+            break;
347 347
 
348
-	}
348
+    }
349 349
 
350
-	wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) );
351
-	exit;
350
+    wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) );
351
+    exit;
352 352
 
353 353
 }
354 354
 add_action( 'admin_init', 'wpinv_recurring_process_subscription_update', 1 );
@@ -362,30 +362,30 @@  discard block
 block discarded – undo
362 362
  */
363 363
 function wpinv_recurring_process_subscription_deletion() {
364 364
 
365
-	if( empty( $_POST['sub_id'] ) ) {
366
-		return;
367
-	}
365
+    if( empty( $_POST['sub_id'] ) ) {
366
+        return;
367
+    }
368 368
 
369
-	if( empty( $_POST['wpinv_delete_subscription'] ) ) {
370
-		return;
371
-	}
369
+    if( empty( $_POST['wpinv_delete_subscription'] ) ) {
370
+        return;
371
+    }
372 372
 
373
-	if( ! current_user_can( 'manage_invoicing') ) {
374
-		return;
375
-	}
373
+    if( ! current_user_can( 'manage_invoicing') ) {
374
+        return;
375
+    }
376 376
 
377
-	if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) {
378
-		wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
379
-	}
377
+    if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) {
378
+        wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
379
+    }
380 380
 
381
-	$subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) );
381
+    $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) );
382 382
 
383
-	delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' );
383
+    delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' );
384 384
 
385
-	$subscription->delete();
385
+    $subscription->delete();
386 386
 
387
-	wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) );
388
-	exit;
387
+    wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) );
388
+    exit;
389 389
 
390 390
 }
391 391
 add_action( 'admin_init', 'wpinv_recurring_process_subscription_deletion', 2 );
Please login to merge, or discard this patch.
includes/class-wpinv-privacy.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -31,27 +31,27 @@
 block discarded – undo
31 31
     public function get_privacy_message() {
32 32
 
33 33
         $content = '<h2>' . __( 'Invoices and checkout', 'invoicing' ) . '</h2>' .
34
-                   '<div contenteditable="false">' .
35
-                   '<p class="wp-policy-help">' . __( 'Example privacy texts.', 'invoicing' ) . '</p>' .
36
-                   '</div>' .
37
-                   '<p>' . __( 'We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing' ) . '</p>' .
38
-                   '<p>' . __( 'Handling this data also allows us to:', 'invoicing' ) . '</p>' .
39
-                   '<ul>' .
40
-                   '<li>' . __( '- Send you important account/order/service information.', 'invoicing' ) . '</li>' .
41
-                   '<li>' . __( '- Estimate taxes based on your location.', 'invoicing' ) . '</li>' .
42
-                   '<li>' . __( '- Respond to your queries or complaints.', 'invoicing' ) . '</li>' .
43
-                   '<li>' . __( '- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
44
-                   '<li>' . __( '- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing' ) . '</li>' .
45
-                   '<li>' . __( '- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
46
-                   '</ul>' .
47
-                   '<p>' . __( 'In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing' ) . '</p>' .
48
-                   '<h2>' . __( 'What we share with others', 'invoicing' ) . '</h2>' .
49
-                   '<p>' . __( 'We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing' ) . '</p>' .
50
-                   '<div contenteditable="false">' .
51
-                   '<p class="wp-policy-help">' . __( 'In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing' ) . '</p>' .
52
-                   '</div>' .
53
-                   '<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing' ) . '</p>' .
54
-                   '<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing' ) . '</p>';
34
+                    '<div contenteditable="false">' .
35
+                    '<p class="wp-policy-help">' . __( 'Example privacy texts.', 'invoicing' ) . '</p>' .
36
+                    '</div>' .
37
+                    '<p>' . __( 'We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing' ) . '</p>' .
38
+                    '<p>' . __( 'Handling this data also allows us to:', 'invoicing' ) . '</p>' .
39
+                    '<ul>' .
40
+                    '<li>' . __( '- Send you important account/order/service information.', 'invoicing' ) . '</li>' .
41
+                    '<li>' . __( '- Estimate taxes based on your location.', 'invoicing' ) . '</li>' .
42
+                    '<li>' . __( '- Respond to your queries or complaints.', 'invoicing' ) . '</li>' .
43
+                    '<li>' . __( '- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
44
+                    '<li>' . __( '- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing' ) . '</li>' .
45
+                    '<li>' . __( '- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
46
+                    '</ul>' .
47
+                    '<p>' . __( 'In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing' ) . '</p>' .
48
+                    '<h2>' . __( 'What we share with others', 'invoicing' ) . '</h2>' .
49
+                    '<p>' . __( 'We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing' ) . '</p>' .
50
+                    '<div contenteditable="false">' .
51
+                    '<p class="wp-policy-help">' . __( 'In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing' ) . '</p>' .
52
+                    '</div>' .
53
+                    '<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing' ) . '</p>' .
54
+                    '<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing' ) . '</p>';
55 55
 
56 56
 
57 57
 
Please login to merge, or discard this patch.