Passed
Push — master ( 11ea61...3d88bf )
by Brian
05:49
created
includes/gateways/class-getpaid-manual-gateway.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -13,30 +13,30 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Manual_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'manual';
21 21
 
22 22
     /**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27 27
     protected $supports = array( 'subscription' );
28 28
 
29 29
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
34
-	public $order = 11;
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34
+    public $order = 11;
35 35
     
36 36
     /**
37
-	 * Class constructor.
38
-	 */
39
-	public function __construct() {
37
+     * Class constructor.
38
+     */
39
+    public function __construct() {
40 40
         parent::__construct();
41 41
 
42 42
         $this->title        = __( 'Manual Payment', 'invoicing' );
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
     }
47 47
 
48 48
     /**
49
-	 * Process Payment.
50
-	 *
51
-	 *
52
-	 * @param WPInv_Invoice $invoice Invoice.
53
-	 * @param array $submission_data Posted checkout fields.
54
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
55
-	 * @return array
56
-	 */
57
-	public function process_payment( $invoice, $submission_data, $submission ) {
49
+     * Process Payment.
50
+     *
51
+     *
52
+     * @param WPInv_Invoice $invoice Invoice.
53
+     * @param array $submission_data Posted checkout fields.
54
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
55
+     * @return array
56
+     */
57
+    public function process_payment( $invoice, $submission_data, $submission ) {
58 58
 
59 59
         // Mark it as paid.
60 60
         $invoice->mark_paid();
@@ -68,13 +68,13 @@  discard block
 block discarded – undo
68 68
     }
69 69
 
70 70
     /**
71
-	 * (Maybe) renews a manual subscription profile.
72
-	 *
73
-	 *
74
-	 * @param bool $should_expire
71
+     * (Maybe) renews a manual subscription profile.
72
+     *
73
+     *
74
+     * @param bool $should_expire
75 75
      * @param WPInv_Subscription $subscription
76
-	 */
77
-	public function maybe_renew_subscription( $should_expire, $subscription ) {
76
+     */
77
+    public function maybe_renew_subscription( $should_expire, $subscription ) {
78 78
 
79 79
         // Ensure its our subscription && it's active.
80 80
         if ( 'manual' != $subscription->get_gateway() || ! $subscription->has_status( 'active trialling' ) ) {
Please login to merge, or discard this patch.
includes/class-getpaid-notification-email.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -13,36 +13,36 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Notification_Email {
14 14
 
15 15
     /**
16
-	 * Contains the type of this notification email.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Contains the type of this notification email.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id;
21 21
 
22 22
     /**
23
-	 * Contains any object to use in filters.
24
-	 *
25
-	 * @var false|WPInv_Invoice|WPInv_Item|WPInv_Subscription
26
-	 */
23
+     * Contains any object to use in filters.
24
+     *
25
+     * @var false|WPInv_Invoice|WPInv_Item|WPInv_Subscription
26
+     */
27 27
     public $object;
28 28
 
29 29
     /**
30
-	 * Class constructor.
31
-	 *
30
+     * Class constructor.
31
+     *
32 32
      * @param string $id Email Type.
33 33
      * @param mixed $object Optional. Associated object.
34
-	 */
35
-	public function __construct( $id, $object = false ) {
34
+     */
35
+    public function __construct( $id, $object = false ) {
36 36
         $this->id     = $id;
37 37
         $this->object = $object;
38 38
     }
39 39
 
40 40
     /**
41
-	 * Retrieves an option
42
-	 *
41
+     * Retrieves an option
42
+     *
43 43
      * @return mixed
44
-	 */
45
-	public function get_option( $key ) {
44
+     */
45
+    public function get_option( $key ) {
46 46
 
47 47
         $key   = "email_{$this->id}_$key";
48 48
         $value = wpinv_get_option( $key, null );
@@ -60,80 +60,80 @@  discard block
 block discarded – undo
60 60
     }
61 61
 
62 62
     /**
63
-	 * Retrieves the email body.
64
-	 *
63
+     * Retrieves the email body.
64
+     *
65 65
      * @return string
66
-	 */
67
-	public function get_body() {
66
+     */
67
+    public function get_body() {
68 68
         $body = $this->get_option( 'body' );
69 69
         return apply_filters( 'getpaid_get_email_body', $body, $this->id, $this->object );
70 70
     }
71 71
 
72 72
     /**
73
-	 * Retrieves the email subject.
74
-	 *
73
+     * Retrieves the email subject.
74
+     *
75 75
      * @return string
76
-	 */
77
-	public function get_subject() {
76
+     */
77
+    public function get_subject() {
78 78
         $subject = $this->get_option( 'subject' );
79 79
         return apply_filters( 'getpaid_get_email_subject', $subject, $this->id, $this->object );
80 80
     }
81 81
 
82 82
     /**
83
-	 * Retrieves the email heading.
84
-	 *
83
+     * Retrieves the email heading.
84
+     *
85 85
      * @return string
86
-	 */
87
-	public function get_heading() {
86
+     */
87
+    public function get_heading() {
88 88
         $heading = $this->get_option( 'heading' );
89 89
         return apply_filters( 'getpaid_get_email_heading', $heading, $this->id, $this->object );
90 90
     }
91 91
 
92 92
     /**
93
-	 * Checks if an email is active.
94
-	 *
93
+     * Checks if an email is active.
94
+     *
95 95
      * @return bool
96
-	 */
97
-	public function is_active() {
96
+     */
97
+    public function is_active() {
98 98
         $is_active = ! empty( $this->get_option( 'active' ) );
99 99
         return apply_filters( 'getpaid_email_type_is_active', $is_active, $this->id, $this->object );
100 100
     }
101 101
 
102 102
     /**
103
-	 * Checks if the site's admin should receive email notifications.
104
-	 *
103
+     * Checks if the site's admin should receive email notifications.
104
+     *
105 105
      * @return bool
106
-	 */
107
-	public function include_admin_bcc() {
106
+     */
107
+    public function include_admin_bcc() {
108 108
         $include_admin_bcc = ! empty( $this->get_option( 'admin_bcc' ) );
109 109
         return apply_filters( 'getpaid_email_type_include_admin_bcc', $include_admin_bcc, $this->id, $this->object );
110 110
     }
111 111
 
112 112
     /**
113
-	 * Checks whether this email should be sent to the customer or admin.
114
-	 *
113
+     * Checks whether this email should be sent to the customer or admin.
114
+     *
115 115
      * @return bool
116
-	 */
117
-	public function is_admin_email() {
116
+     */
117
+    public function is_admin_email() {
118 118
         $is_admin_email = in_array( $this->id, array( 'new_invoice', 'cancelled_invoice', 'failed_invoice' ) );
119 119
         return apply_filters( 'getpaid_email_type_is_admin_email', $is_admin_email, $this->id, $this->object );
120 120
     }
121 121
 
122 122
     /**
123
-	 * Returns email attachments.
124
-	 *
123
+     * Returns email attachments.
124
+     *
125 125
      * @return array
126
-	 */
127
-	public function get_attachments() {
126
+     */
127
+    public function get_attachments() {
128 128
         return apply_filters( 'getpaid_get_email_attachments', array(), $this->id, $this->object );
129 129
     }
130 130
 
131 131
     /**
132
-	 * Returns an array of merge tags.
133
-	 *
132
+     * Returns an array of merge tags.
133
+     *
134 134
      * @return array
135
-	 */
136
-	public function get_merge_tags() {
135
+     */
136
+    public function get_merge_tags() {
137 137
 
138 138
         $merge_tags = array(
139 139
             '{site_title}' => wpinv_get_blogname(),
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
     }
145 145
 
146 146
     /**
147
-	 * Adds merge tags to a text.
148
-	 *
147
+     * Adds merge tags to a text.
148
+     *
149 149
      * @param string string $text
150 150
      * @param array $merge_tags
151 151
      * @return string
152
-	 */
153
-	public function add_merge_tags( $text, $merge_tags = array() ) {
152
+     */
153
+    public function add_merge_tags( $text, $merge_tags = array() ) {
154 154
 
155 155
         foreach ( $merge_tags as $key => $value ) {
156 156
             $text = str_replace( $key, $value, $text );
@@ -160,13 +160,13 @@  discard block
 block discarded – undo
160 160
     }
161 161
 
162 162
     /**
163
-	 * Returns the email content
164
-	 *
163
+     * Returns the email content
164
+     *
165 165
      * @param array $merge_tags
166 166
      * @param array $extra_args Extra template args
167 167
      * @return string
168
-	 */
169
-	public function get_content( $merge_tags = array(), $extra_args = array() ) {
168
+     */
169
+    public function get_content( $merge_tags = array(), $extra_args = array() ) {
170 170
 
171 171
         $content = wpinv_get_template_html(
172 172
             "emails/wpinv-email-{$this->id}.php",
Please login to merge, or discard this patch.
includes/class-getpaid-subscription-notification-emails.php 1 patch
Indentation   +239 added lines, -239 removed lines patch added patch discarded remove patch
@@ -13,282 +13,282 @@
 block discarded – undo
13 13
 class GetPaid_Subscription_Notification_Emails {
14 14
 
15 15
     /**
16
-	 * The array of subscription email actions.
17
-	 *
18
-	 * @param array
19
-	 */
20
-	public $subscription_actions;
16
+     * The array of subscription email actions.
17
+     *
18
+     * @param array
19
+     */
20
+    public $subscription_actions;
21 21
 
22 22
     /**
23
-	 * Class constructor
23
+     * Class constructor
24 24
      *
25
-	 */
26
-	public function __construct() {
27
-
28
-		$this->subscription_actions = apply_filters(
29
-			'getpaid_notification_email_subscription_triggers',
30
-			array(
31
-				'getpaid_subscription_trialling' => 'subscription_trial',
32
-				'getpaid_subscription_cancelled' => 'subscription_cancelled',
33
-				'getpaid_subscription_expired'   => 'subscription_expired',
34
-				'getpaid_subscription_completed' => 'subscription_complete',
35
-				'getpaid_daily_maintenance'      => 'renewal_reminder',
36
-			)
37
-		);
38
-
39
-		$this->init_hooks();
25
+     */
26
+    public function __construct() {
27
+
28
+        $this->subscription_actions = apply_filters(
29
+            'getpaid_notification_email_subscription_triggers',
30
+            array(
31
+                'getpaid_subscription_trialling' => 'subscription_trial',
32
+                'getpaid_subscription_cancelled' => 'subscription_cancelled',
33
+                'getpaid_subscription_expired'   => 'subscription_expired',
34
+                'getpaid_subscription_completed' => 'subscription_complete',
35
+                'getpaid_daily_maintenance'      => 'renewal_reminder',
36
+            )
37
+        );
38
+
39
+        $this->init_hooks();
40 40
 
41 41
     }
42 42
 
43 43
     /**
44
-	 * Registers email hooks.
45
-	 */
46
-	public function init_hooks() {
47
-
48
-		add_filter( 'getpaid_get_email_merge_tags', array( $this, 'subscription_merge_tags' ), 10, 2 );
49
-		foreach ( $this->subscription_actions as $hook => $email_type ) {
50
-
51
-			$email = new GetPaid_Notification_Email( $email_type );
52
-
53
-			if ( ! $email->is_active() ) {
54
-				continue;
55
-			}
56
-
57
-			if ( method_exists( $this, $email_type ) ) {
58
-				add_action( $hook, array( $this, $email_type ), 100, 2 );
59
-				continue;
60
-			}
61
-
62
-			do_action( 'getpaid_subscription_notification_email_register_hook', $email );
63
-
64
-		}
65
-
66
-	}
67
-
68
-	/**
69
-	 * Filters subscription merge tags.
70
-	 *
71
-	 * @param array $merge_tags
72
-	 * @param mixed|WPInv_Invoice|WPInv_Subscription $object
73
-	 */
74
-	public function subscription_merge_tags( $merge_tags, $object ) {
75
-
76
-		if ( is_a( $object, 'WPInv_Subscription' ) ) {
77
-			$merge_tags = array_merge(
78
-				$merge_tags,
79
-				$this->get_subscription_merge_tags( $object )
80
-			);
81
-		}
82
-
83
-		return $merge_tags;
84
-
85
-	}
86
-
87
-	/**
88
-	 * Generates subscription merge tags.
89
-	 *
90
-	 * @param WPInv_Subscription $subscription
91
-	 * @return array
92
-	 */
93
-	public function get_subscription_merge_tags( $subscription ) {
94
-
95
-		// Abort if it does not exist.
96
-		if ( ! $subscription->get_id() ) {
97
-			return array();
98
-		}
99
-
100
-		$invoice    = $subscription->get_parent_invoice();
101
-		return array(
102
-			'{subscription_renewal_date}'     => getpaid_format_date_value( $subscription->get_next_renewal_date(), __( 'Never', 'invoicing' ) ),
103
-			'{subscription_created}'          => getpaid_format_date_value( $subscription->get_date_created() ),
104
-			'{subscription_status}'           => sanitize_text_field( $subscription->get_status_label() ),
105
-			'{subscription_profile_id}'       => sanitize_text_field( $subscription->get_profile_id() ),
106
-			'{subscription_id}'               => absint( $subscription->get_id() ),
107
-			'{subscription_recurring_amount}' => wpinv_price( wpinv_format_amount( $subscription->get_recurring_amount() ), $invoice->get_currency() ),
108
-			'{subscription_initial_amount}'   => wpinv_price( wpinv_format_amount( $subscription->get_initial_amount() ), $invoice->get_currency() ),
109
-			'{subscription_recurring_period}' => getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ),
110
-			'{subscription_bill_times}'       => $subscription->get_bill_times(),
111
-			'{subscription_url}'              => esc_url( $subscription->get_view_url() ),
112
-		);
113
-
114
-	}
115
-
116
-	/**
117
-	 * Checks if we should send a notification for a subscription.
118
-	 *
119
-	 * @param WPInv_Invoice $invoice
120
-	 * @return bool
121
-	 */
122
-	public function should_send_notification( $invoice ) {
123
-		return 0 != $invoice->get_id();
124
-	}
125
-
126
-	/**
127
-	 * Returns notification recipients.
128
-	 *
129
-	 * @param WPInv_Invoice $invoice
130
-	 * @return array
131
-	 */
132
-	public function get_recipients( $invoice ) {
133
-		$recipients = array( $invoice->get_email() );
134
-
135
-		$cc = $invoice->get_email_cc();
136
-
137
-		if ( ! empty( $cc ) ) {
138
-			$cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
139
-			$recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
140
-		}
141
-
142
-		return $recipients;
143
-	}
144
-
145
-	/**
146
-	 * Helper function to send an email.
147
-	 *
148
-	 * @param WPInv_Subscription $subscription
149
-	 * @param GetPaid_Notification_Email $email
150
-	 * @param string $type
151
-	 * @param array $extra_args Extra template args.
152
-	 */
153
-	public function send_email( $subscription, $email, $type, $extra_args = array() ) {
154
-
155
-		// Abort in case the parent invoice does not exist.
156
-		$invoice = $subscription->get_parent_invoice();
157
-		if ( ! $this->should_send_notification( $invoice ) ) {
158
-			return;
159
-		}
160
-
161
-		do_action( 'getpaid_before_send_subscription_notification', $type, $subscription, $email );
162
-
163
-		$recipients  = $this->get_recipients( $invoice );
164
-		$mailer      = new GetPaid_Notification_Email_Sender();
165
-		$merge_tags  = $email->get_merge_tags();
166
-		$content     = $email->get_content( $merge_tags, $extra_args );
167
-		$subject     = $email->add_merge_tags( $email->get_subject(), $merge_tags );
168
-		$attachments = $email->get_attachments();
169
-
170
-		$result = $mailer->send(
171
-			apply_filters( 'getpaid_subscription_email_recipients', wpinv_parse_list( $recipients ), $email ),
172
-			$subject,
173
-			$content,
174
-			$attachments
175
-		);
176
-
177
-		// Maybe send a copy to the admin.
178
-		if ( $email->include_admin_bcc() ) {
179
-			$mailer->send(
180
-				wpinv_get_admin_email(),
181
-				$subject . __( ' - ADMIN BCC COPY', 'invoicing' ),
182
-				$content,
183
-				$attachments
184
-			);
185
-		}
186
-
187
-		if ( ! $result ) {
188
-			$subscription->get_parent_invoice()->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true );
189
-		}
190
-
191
-		do_action( 'getpaid_after_send_subscription_notification', $type, $subscription, $email );
192
-
193
-	}
44
+     * Registers email hooks.
45
+     */
46
+    public function init_hooks() {
47
+
48
+        add_filter( 'getpaid_get_email_merge_tags', array( $this, 'subscription_merge_tags' ), 10, 2 );
49
+        foreach ( $this->subscription_actions as $hook => $email_type ) {
50
+
51
+            $email = new GetPaid_Notification_Email( $email_type );
52
+
53
+            if ( ! $email->is_active() ) {
54
+                continue;
55
+            }
56
+
57
+            if ( method_exists( $this, $email_type ) ) {
58
+                add_action( $hook, array( $this, $email_type ), 100, 2 );
59
+                continue;
60
+            }
61
+
62
+            do_action( 'getpaid_subscription_notification_email_register_hook', $email );
63
+
64
+        }
65
+
66
+    }
194 67
 
195 68
     /**
196
-	 * Sends a new trial notification.
197
-	 *
198
-	 * @param WPInv_Subscription $subscription
199
-	 */
200
-	public function subscription_trial( $subscription ) {
69
+     * Filters subscription merge tags.
70
+     *
71
+     * @param array $merge_tags
72
+     * @param mixed|WPInv_Invoice|WPInv_Subscription $object
73
+     */
74
+    public function subscription_merge_tags( $merge_tags, $object ) {
201 75
 
202
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
203
-		$this->send_email( $subscription, $email, __FUNCTION__ );
76
+        if ( is_a( $object, 'WPInv_Subscription' ) ) {
77
+            $merge_tags = array_merge(
78
+                $merge_tags,
79
+                $this->get_subscription_merge_tags( $object )
80
+            );
81
+        }
204 82
 
205
-	}
83
+        return $merge_tags;
206 84
 
207
-	/**
208
-	 * Sends a cancelled subscription notification.
209
-	 *
210
-	 * @param WPInv_Subscription $subscription
211
-	 */
212
-	public function subscription_cancelled( $subscription ) {
85
+    }
213 86
 
214
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
215
-		$this->send_email( $subscription, $email, __FUNCTION__ );
87
+    /**
88
+     * Generates subscription merge tags.
89
+     *
90
+     * @param WPInv_Subscription $subscription
91
+     * @return array
92
+     */
93
+    public function get_subscription_merge_tags( $subscription ) {
94
+
95
+        // Abort if it does not exist.
96
+        if ( ! $subscription->get_id() ) {
97
+            return array();
98
+        }
99
+
100
+        $invoice    = $subscription->get_parent_invoice();
101
+        return array(
102
+            '{subscription_renewal_date}'     => getpaid_format_date_value( $subscription->get_next_renewal_date(), __( 'Never', 'invoicing' ) ),
103
+            '{subscription_created}'          => getpaid_format_date_value( $subscription->get_date_created() ),
104
+            '{subscription_status}'           => sanitize_text_field( $subscription->get_status_label() ),
105
+            '{subscription_profile_id}'       => sanitize_text_field( $subscription->get_profile_id() ),
106
+            '{subscription_id}'               => absint( $subscription->get_id() ),
107
+            '{subscription_recurring_amount}' => wpinv_price( wpinv_format_amount( $subscription->get_recurring_amount() ), $invoice->get_currency() ),
108
+            '{subscription_initial_amount}'   => wpinv_price( wpinv_format_amount( $subscription->get_initial_amount() ), $invoice->get_currency() ),
109
+            '{subscription_recurring_period}' => getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ),
110
+            '{subscription_bill_times}'       => $subscription->get_bill_times(),
111
+            '{subscription_url}'              => esc_url( $subscription->get_view_url() ),
112
+        );
216 113
 
217
-	}
114
+    }
218 115
 
219
-	/**
220
-	 * Sends a subscription expired notification.
221
-	 *
222
-	 * @param WPInv_Subscription $subscription
223
-	 */
224
-	public function subscription_expired( $subscription ) {
116
+    /**
117
+     * Checks if we should send a notification for a subscription.
118
+     *
119
+     * @param WPInv_Invoice $invoice
120
+     * @return bool
121
+     */
122
+    public function should_send_notification( $invoice ) {
123
+        return 0 != $invoice->get_id();
124
+    }
225 125
 
226
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
227
-		$this->send_email( $subscription, $email, __FUNCTION__ );
126
+    /**
127
+     * Returns notification recipients.
128
+     *
129
+     * @param WPInv_Invoice $invoice
130
+     * @return array
131
+     */
132
+    public function get_recipients( $invoice ) {
133
+        $recipients = array( $invoice->get_email() );
228 134
 
229
-	}
135
+        $cc = $invoice->get_email_cc();
230 136
 
231
-	/**
232
-	 * Sends a completed subscription notification.
233
-	 *
234
-	 * @param WPInv_Subscription $subscription
235
-	 */
236
-	public function subscription_complete( $subscription ) {
137
+        if ( ! empty( $cc ) ) {
138
+            $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
139
+            $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
140
+        }
237 141
 
238
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
239
-		$this->send_email( $subscription, $email, __FUNCTION__ );
142
+        return $recipients;
143
+    }
240 144
 
241
-	}
145
+    /**
146
+     * Helper function to send an email.
147
+     *
148
+     * @param WPInv_Subscription $subscription
149
+     * @param GetPaid_Notification_Email $email
150
+     * @param string $type
151
+     * @param array $extra_args Extra template args.
152
+     */
153
+    public function send_email( $subscription, $email, $type, $extra_args = array() ) {
154
+
155
+        // Abort in case the parent invoice does not exist.
156
+        $invoice = $subscription->get_parent_invoice();
157
+        if ( ! $this->should_send_notification( $invoice ) ) {
158
+            return;
159
+        }
160
+
161
+        do_action( 'getpaid_before_send_subscription_notification', $type, $subscription, $email );
162
+
163
+        $recipients  = $this->get_recipients( $invoice );
164
+        $mailer      = new GetPaid_Notification_Email_Sender();
165
+        $merge_tags  = $email->get_merge_tags();
166
+        $content     = $email->get_content( $merge_tags, $extra_args );
167
+        $subject     = $email->add_merge_tags( $email->get_subject(), $merge_tags );
168
+        $attachments = $email->get_attachments();
169
+
170
+        $result = $mailer->send(
171
+            apply_filters( 'getpaid_subscription_email_recipients', wpinv_parse_list( $recipients ), $email ),
172
+            $subject,
173
+            $content,
174
+            $attachments
175
+        );
176
+
177
+        // Maybe send a copy to the admin.
178
+        if ( $email->include_admin_bcc() ) {
179
+            $mailer->send(
180
+                wpinv_get_admin_email(),
181
+                $subject . __( ' - ADMIN BCC COPY', 'invoicing' ),
182
+                $content,
183
+                $attachments
184
+            );
185
+        }
186
+
187
+        if ( ! $result ) {
188
+            $subscription->get_parent_invoice()->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true );
189
+        }
190
+
191
+        do_action( 'getpaid_after_send_subscription_notification', $type, $subscription, $email );
242 192
 
243
-	/**
244
-	 * Sends a subscription renewal reminder notification.
245
-	 *
246
-	 */
247
-	public function renewal_reminder() {
193
+    }
248 194
 
249
-		$email = new GetPaid_Notification_Email( __FUNCTION__ );
195
+    /**
196
+     * Sends a new trial notification.
197
+     *
198
+     * @param WPInv_Subscription $subscription
199
+     */
200
+    public function subscription_trial( $subscription ) {
250 201
 
251
-		// Fetch reminder days.
252
-		$reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
202
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
203
+        $this->send_email( $subscription, $email, __FUNCTION__ );
253 204
 
254
-		// Abort if non is set.
255
-		if ( empty( $reminder_days ) ) {
256
-			return;
257
-		}
205
+    }
258 206
 
259
-		// Fetch matching subscriptions.
207
+    /**
208
+     * Sends a cancelled subscription notification.
209
+     *
210
+     * @param WPInv_Subscription $subscription
211
+     */
212
+    public function subscription_cancelled( $subscription ) {
213
+
214
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
215
+        $this->send_email( $subscription, $email, __FUNCTION__ );
216
+
217
+    }
218
+
219
+    /**
220
+     * Sends a subscription expired notification.
221
+     *
222
+     * @param WPInv_Subscription $subscription
223
+     */
224
+    public function subscription_expired( $subscription ) {
225
+
226
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
227
+        $this->send_email( $subscription, $email, __FUNCTION__ );
228
+
229
+    }
230
+
231
+    /**
232
+     * Sends a completed subscription notification.
233
+     *
234
+     * @param WPInv_Subscription $subscription
235
+     */
236
+    public function subscription_complete( $subscription ) {
237
+
238
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
239
+        $this->send_email( $subscription, $email, __FUNCTION__ );
240
+
241
+    }
242
+
243
+    /**
244
+     * Sends a subscription renewal reminder notification.
245
+     *
246
+     */
247
+    public function renewal_reminder() {
248
+
249
+        $email = new GetPaid_Notification_Email( __FUNCTION__ );
250
+
251
+        // Fetch reminder days.
252
+        $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
253
+
254
+        // Abort if non is set.
255
+        if ( empty( $reminder_days ) ) {
256
+            return;
257
+        }
258
+
259
+        // Fetch matching subscriptions.
260 260
         $args  = array(
261 261
             'number'             => -1,
262
-			'count_total'        => false,
263
-			'status'             => 'trialling active',
262
+            'count_total'        => false,
263
+            'status'             => 'trialling active',
264 264
             'date_expires_query' => array(
265
-				'relation'  => 'OR'
265
+                'relation'  => 'OR'
266 266
             ),
267
-		);
267
+        );
268 268
 
269
-		foreach ( $reminder_days as $days ) {
270
-			$date = date_parse( date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) ) );
269
+        foreach ( $reminder_days as $days ) {
270
+            $date = date_parse( date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) ) );
271 271
 
272
-			$args['date_expires_query'][] = array(
273
-				'year'  => $date['year'],
274
-				'month' => $date['month'],
275
-				'day'   => $date['day'],
276
-			);
272
+            $args['date_expires_query'][] = array(
273
+                'year'  => $date['year'],
274
+                'month' => $date['month'],
275
+                'day'   => $date['day'],
276
+            );
277 277
 
278
-		}
278
+        }
279 279
 
280
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
280
+        $subscriptions = new GetPaid_Subscriptions_Query( $args );
281 281
 
282 282
         foreach ( $subscriptions as $subscription ) {
283 283
 
284
-			// Skip packages.
285
-			if ( get_post_meta( $subscription->get_product_id(), '_wpinv_type', true ) != 'package' ) {
286
-				$email->object = $subscription;
287
-            	$this->send_email( $subscription, $email, __FUNCTION__ );
288
-			}
284
+            // Skip packages.
285
+            if ( get_post_meta( $subscription->get_product_id(), '_wpinv_type', true ) != 'package' ) {
286
+                $email->object = $subscription;
287
+                $this->send_email( $subscription, $email, __FUNCTION__ );
288
+            }
289 289
 
290
-		}
290
+        }
291 291
 
292
-	}
292
+    }
293 293
 
294 294
 }
Please login to merge, or discard this patch.
templates/subscriptions/subscriptions-table-row.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -13,38 +13,38 @@
 block discarded – undo
13 13
 
14 14
 foreach ( array_keys( $widget->get_subscriptions_table_columns() ) as $column ) :
15 15
 
16
-	$class = sanitize_html_class( $column );
17
-	echo "<td class='getpaid-subscriptions-table-column-$class'>";
16
+    $class = sanitize_html_class( $column );
17
+    echo "<td class='getpaid-subscriptions-table-column-$class'>";
18 18
 
19
-		do_action( "getpaid_subscriptions_before_frontend_subscription_table_$column", $subscription );
19
+        do_action( "getpaid_subscriptions_before_frontend_subscription_table_$column", $subscription );
20 20
 
21
-		switch( $column ) :
21
+        switch( $column ) :
22 22
 
23
-			case 'subscription':
24
-				$subscription_id = (int) $subscription->get_id();
25
-				$url             = esc_url( $subscription->get_view_url() );
26
-				echo $widget->add_row_actions( "<a href='$url' class='text-decoration-none'>#$subscription_id</a>", $subscription );
27
-				break;
23
+            case 'subscription':
24
+                $subscription_id = (int) $subscription->get_id();
25
+                $url             = esc_url( $subscription->get_view_url() );
26
+                echo $widget->add_row_actions( "<a href='$url' class='text-decoration-none'>#$subscription_id</a>", $subscription );
27
+                break;
28 28
 
29
-			case 'status':
30
-				echo $subscription->get_status_label();
31
-				break;
29
+            case 'status':
30
+                echo $subscription->get_status_label();
31
+                break;
32 32
 
33
-			case 'renewal-date':
34
-				$renewal = getpaid_format_date_value( $subscription->get_next_renewal_date() );
35
-				echo $subscription->is_active() ? $renewal : "&mdash;";
36
-				break;
33
+            case 'renewal-date':
34
+                $renewal = getpaid_format_date_value( $subscription->get_next_renewal_date() );
35
+                echo $subscription->is_active() ? $renewal : "&mdash;";
36
+                break;
37 37
 
38
-			case 'amount':
39
-				$frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
40
-				$amount    = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $subscription->get_recurring_amount() ) ), $subscription->get_parent_payment()->get_currency() );
41
-				echo "<strong style='font-weight: 500;'>$amount</strong> / $frequency";
42
-				break;
38
+            case 'amount':
39
+                $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
40
+                $amount    = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $subscription->get_recurring_amount() ) ), $subscription->get_parent_payment()->get_currency() );
41
+                echo "<strong style='font-weight: 500;'>$amount</strong> / $frequency";
42
+                break;
43 43
 
44
-		endswitch;
44
+        endswitch;
45 45
 
46
-		do_action( "getpaid_subscriptions_frontend_subscription_table_$column", $subscription );
46
+        do_action( "getpaid_subscriptions_frontend_subscription_table_$column", $subscription );
47 47
 
48
-	echo '</td>';
48
+    echo '</td>';
49 49
 
50 50
 endforeach;
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-authorize-net-legacy-gateway.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -15,31 +15,31 @@  discard block
 block discarded – undo
15 15
 abstract class GetPaid_Authorize_Net_Legacy_Gateway extends GetPaid_Payment_Gateway {
16 16
 
17 17
     /**
18
-	 * Class constructor.
19
-	 */
20
-	public function __construct() {
18
+     * Class constructor.
19
+     */
20
+    public function __construct() {
21 21
         parent::__construct();
22 22
     }
23 23
 
24 24
     /**
25
-	 * Returns the API URL.
26
-	 *
27
-	 *
28
-	 * @param WPInv_Invoice $invoice Invoice.
29
-	 * @return string
30
-	 */
31
-	public function get_api_url( $invoice ) {
25
+     * Returns the API URL.
26
+     *
27
+     *
28
+     * @param WPInv_Invoice $invoice Invoice.
29
+     * @return string
30
+     */
31
+    public function get_api_url( $invoice ) {
32 32
         return $this->is_sandbox( $invoice ) ? 'https://apitest.authorize.net/xml/v1/request.api' : 'https://api.authorize.net/xml/v1/request.api';
33 33
     }
34 34
 
35 35
     /**
36
-	 * Communicates with authorize.net
37
-	 *
38
-	 *
39
-	 * @param array $post Data to post.
36
+     * Communicates with authorize.net
37
+     *
38
+     *
39
+     * @param array $post Data to post.
40 40
      * @param WPInv_Invoice $invoice Invoice.
41
-	 * @return stdClass|WP_Error
42
-	 */
41
+     * @return stdClass|WP_Error
42
+     */
43 43
     public function post( $post, $invoice ){
44 44
 
45 45
         $url      = $this->get_api_url( $invoice );
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
     }
82 82
 
83 83
     /**
84
-	 * Returns the API authentication params.
85
-	 *
86
-	 *
87
-	 * @return array
88
-	 */
89
-	public function get_auth_params() {
84
+     * Returns the API authentication params.
85
+     *
86
+     *
87
+     * @return array
88
+     */
89
+    public function get_auth_params() {
90 90
 
91 91
         return array(
92 92
             'name'           => $this->get_option( 'login_id' ),
@@ -96,13 +96,13 @@  discard block
 block discarded – undo
96 96
     }
97 97
 
98 98
     /**
99
-	 * Cancels a subscription remotely
100
-	 *
101
-	 *
102
-	 * @param WPInv_Subscription $subscription Subscription.
99
+     * Cancels a subscription remotely
100
+     *
101
+     *
102
+     * @param WPInv_Subscription $subscription Subscription.
103 103
      * @param WPInv_Invoice $invoice Invoice.
104
-	 */
105
-	public function cancel_subscription( $subscription, $invoice ) {
104
+     */
105
+    public function cancel_subscription( $subscription, $invoice ) {
106 106
 
107 107
         // Backwards compatibility. New version do not use authorize.net subscriptions.
108 108
         $this->post(
@@ -118,17 +118,17 @@  discard block
 block discarded – undo
118 118
     }
119 119
 
120 120
     /**
121
-	 * Processes ipns.
122
-	 *
123
-	 * @return void
124
-	 */
125
-	public function verify_ipn() {
121
+     * Processes ipns.
122
+     *
123
+     * @return void
124
+     */
125
+    public function verify_ipn() {
126 126
 
127 127
         $this->maybe_process_old_ipn();
128 128
 
129 129
         // Validate the IPN.
130 130
         if ( empty( $_POST ) || ! $this->validate_ipn() ) {
131
-		    wp_die( 'Authorize.NET IPN Request Failure', 'Authorize.NET IPN', array( 'response' => 500 ) );
131
+            wp_die( 'Authorize.NET IPN Request Failure', 'Authorize.NET IPN', array( 'response' => 500 ) );
132 132
         }
133 133
 
134 134
         // Event type.
@@ -167,24 +167,24 @@  discard block
 block discarded – undo
167 167
     }
168 168
 
169 169
     /**
170
-	 * Validates IPN invoices.
171
-	 *
170
+     * Validates IPN invoices.
171
+     *
172 172
      * @param WPInv_Invoice $invoice
173 173
      * @param object $payload
174
-	 * @return void
175
-	 */
176
-	public function validate_ipn_invoice( $invoice, $payload ) {
174
+     * @return void
175
+     */
176
+    public function validate_ipn_invoice( $invoice, $payload ) {
177 177
         if ( ! $invoice->exists() || $payload->id != $invoice->get_transaction_id() ) {
178 178
             exit;
179 179
         }
180 180
     }
181 181
 
182 182
     /**
183
-	 * Process subscriptio IPNS.
184
-	 *
185
-	 * @return void
186
-	 */
187
-	public function maybe_process_old_ipn() {
183
+     * Process subscriptio IPNS.
184
+     *
185
+     * @return void
186
+     */
187
+    public function maybe_process_old_ipn() {
188 188
 
189 189
         $data = wp_unslash( $_POST );
190 190
 
@@ -226,11 +226,11 @@  discard block
 block discarded – undo
226 226
     }
227 227
 
228 228
     /**
229
-	 * Validates the old IPN signature.
229
+     * Validates the old IPN signature.
230 230
      *
231 231
      * @param array $posted
232
-	 */
233
-	public function validate_old_ipn_signature( $posted ) {
232
+     */
233
+    public function validate_old_ipn_signature( $posted ) {
234 234
 
235 235
         $signature = $this->get_option( 'signature_key' );
236 236
         if ( ! empty( $signature ) ) {
@@ -249,9 +249,9 @@  discard block
 block discarded – undo
249 249
     }
250 250
 
251 251
     /**
252
-	 * Check Authorize.NET IPN validity.
253
-	 */
254
-	public function validate_ipn() {
252
+     * Check Authorize.NET IPN validity.
253
+     */
254
+    public function validate_ipn() {
255 255
 
256 256
         wpinv_error_log( 'Validating Authorize.NET IPN response' );
257 257
 
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-bank-transfer-gateway.php 1 patch
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -13,23 +13,23 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Bank_Transfer_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'bank_transfer';
21 21
 
22 22
     /**
23
-	 * Payment method order.
24
-	 *
25
-	 * @var int
26
-	 */
27
-	public $order = 8;
23
+     * Payment method order.
24
+     *
25
+     * @var int
26
+     */
27
+    public $order = 8;
28 28
     
29 29
     /**
30
-	 * Class constructor.
31
-	 */
32
-	public function __construct() {
30
+     * Class constructor.
31
+     */
32
+    public function __construct() {
33 33
         parent::__construct();
34 34
 
35 35
         $this->title                = __( 'Direct bank transfer', 'invoicing' );
@@ -37,22 +37,22 @@  discard block
 block discarded – undo
37 37
         $this->checkout_button_text = __( 'Proceed', 'invoicing' );
38 38
         $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
39 39
 
40
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
41
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
42
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
40
+        add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
41
+        add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
42
+        add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
43 43
 
44 44
     }
45 45
 
46 46
     /**
47
-	 * Process Payment.
48
-	 *
49
-	 *
50
-	 * @param WPInv_Invoice $invoice Invoice.
51
-	 * @param array $submission_data Posted checkout fields.
52
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
53
-	 * @return array
54
-	 */
55
-	public function process_payment( $invoice, $submission_data, $submission ) {
47
+     * Process Payment.
48
+     *
49
+     *
50
+     * @param WPInv_Invoice $invoice Invoice.
51
+     * @param array $submission_data Posted checkout fields.
52
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
53
+     * @return array
54
+     */
55
+    public function process_payment( $invoice, $submission_data, $submission ) {
56 56
 
57 57
         // Add a transaction id.
58 58
         $invoice->set_transaction_id( $invoice->generate_key('trans_') );
@@ -73,66 +73,66 @@  discard block
 block discarded – undo
73 73
     }
74 74
 
75 75
     /**
76
-	 * Output for the order received page.
77
-	 *
78
-	 * @param WPInv_Invoice $invoice Invoice.
79
-	 */
80
-	public function thankyou_page( $invoice ) {
76
+     * Output for the order received page.
77
+     *
78
+     * @param WPInv_Invoice $invoice Invoice.
79
+     */
80
+    public function thankyou_page( $invoice ) {
81 81
 
82 82
         if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
83 83
 
84
-			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
84
+            echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
85 85
 
86 86
             if ( ! empty( $this->instructions ) ) {
87 87
                 echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
88
-			}
88
+            }
89 89
 
90
-			$this->bank_details( $invoice );
90
+            $this->bank_details( $invoice );
91 91
 			
92
-			echo '</div>';
92
+            echo '</div>';
93 93
         
94 94
         }
95 95
 
96
-	}
96
+    }
97 97
     
98 98
     /**
99
-	 * Add content to the WPI emails.
100
-	 *
101
-	 * @param WPInv_Invoice $invoice Invoice.
102
-	 * @param string     $email_type Email format: plain text or HTML.
103
-	 * @param bool     $sent_to_admin Sent to admin.
104
-	 */
105
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
99
+     * Add content to the WPI emails.
100
+     *
101
+     * @param WPInv_Invoice $invoice Invoice.
102
+     * @param string     $email_type Email format: plain text or HTML.
103
+     * @param bool     $sent_to_admin Sent to admin.
104
+     */
105
+    public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
106 106
 
107
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
107
+        if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
108 108
 
109
-			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
109
+            echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
110 110
 
111
-			if ( $this->instructions ) {
112
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
111
+            if ( $this->instructions ) {
112
+                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
113 113
             }
114 114
 
115
-			$this->bank_details( $invoice );
115
+            $this->bank_details( $invoice );
116 116
 			
117
-			echo '</div>';
117
+            echo '</div>';
118 118
 
119
-		}
119
+        }
120 120
 
121 121
     }
122 122
     
123 123
     /**
124
-	 * Get bank details and place into a list format.
125
-	 *
126
-	 * @param WPInv_Invoice $invoice Invoice.
127
-	 */
128
-	protected function bank_details( $invoice ) {
124
+     * Get bank details and place into a list format.
125
+     *
126
+     * @param WPInv_Invoice $invoice Invoice.
127
+     */
128
+    protected function bank_details( $invoice ) {
129 129
 
130
-		// Get the invoice country and country $locale.
131
-		$country = $invoice->get_country();
132
-		$locale  = $this->get_country_locale();
130
+        // Get the invoice country and country $locale.
131
+        $country = $invoice->get_country();
132
+        $locale  = $this->get_country_locale();
133 133
 
134
-		// Get sortcode label in the $locale array and use appropriate one.
135
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
134
+        // Get sortcode label in the $locale array and use appropriate one.
135
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
136 136
 
137 137
         $bank_fields = array(
138 138
             'ac_name'     => __( 'Account Name', 'invoicing' ),
@@ -161,144 +161,144 @@  discard block
 block discarded – undo
161 161
             return;
162 162
         }
163 163
 
164
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL;
164
+        echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL;
165 165
 
166
-		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
166
+        echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
167 167
 
168
-		foreach ( $bank_info as $key => $data ) {
168
+        foreach ( $bank_info as $key => $data ) {
169 169
 
170
-			$key   = sanitize_html_class( $key );
171
-			$label = wp_kses_post( $data['label'] );
172
-			$value = wp_kses_post( wptexturize( $data['value'] ) );
170
+            $key   = sanitize_html_class( $key );
171
+            $label = wp_kses_post( $data['label'] );
172
+            $value = wp_kses_post( wptexturize( $data['value'] ) );
173 173
 
174
-			echo "<tr class='getpaid-bank-transfer-$key'><th>$label</th><td>$value</td></tr>" . PHP_EOL;
175
-		}
174
+            echo "<tr class='getpaid-bank-transfer-$key'><th>$label</th><td>$value</td></tr>" . PHP_EOL;
175
+        }
176 176
 
177
-		echo '</table>';
177
+        echo '</table>';
178 178
 
179 179
     }
180 180
     
181 181
     /**
182
-	 * Get country locale if localized.
183
-	 *
184
-	 * @return array
185
-	 */
186
-	public function get_country_locale() {
187
-
188
-		if ( empty( $this->locale ) ) {
189
-
190
-			// Locale information to be used - only those that are not 'Sort Code'.
191
-			$this->locale = apply_filters(
192
-				'getpaid_get_bank_transfer_locale',
193
-				array(
194
-					'AU' => array(
195
-						'sortcode' => array(
196
-							'label' => __( 'BSB', 'invoicing' ),
197
-						),
198
-					),
199
-					'CA' => array(
200
-						'sortcode' => array(
201
-							'label' => __( 'Bank transit number', 'invoicing' ),
202
-						),
203
-					),
204
-					'IN' => array(
205
-						'sortcode' => array(
206
-							'label' => __( 'IFSC', 'invoicing' ),
207
-						),
208
-					),
209
-					'IT' => array(
210
-						'sortcode' => array(
211
-							'label' => __( 'Branch sort', 'invoicing' ),
212
-						),
213
-					),
214
-					'NZ' => array(
215
-						'sortcode' => array(
216
-							'label' => __( 'Bank code', 'invoicing' ),
217
-						),
218
-					),
219
-					'SE' => array(
220
-						'sortcode' => array(
221
-							'label' => __( 'Bank code', 'invoicing' ),
222
-						),
223
-					),
224
-					'US' => array(
225
-						'sortcode' => array(
226
-							'label' => __( 'Routing number', 'invoicing' ),
227
-						),
228
-					),
229
-					'ZA' => array(
230
-						'sortcode' => array(
231
-							'label' => __( 'Branch code', 'invoicing' ),
232
-						),
233
-					),
234
-				)
235
-			);
236
-
237
-		}
238
-
239
-		return $this->locale;
240
-
241
-	}
242
-
243
-	/**
244
-	 * Filters the gateway settings.
245
-	 * 
246
-	 * @param array $admin_settings
247
-	 */
248
-	public function admin_settings( $admin_settings ) {
182
+     * Get country locale if localized.
183
+     *
184
+     * @return array
185
+     */
186
+    public function get_country_locale() {
187
+
188
+        if ( empty( $this->locale ) ) {
189
+
190
+            // Locale information to be used - only those that are not 'Sort Code'.
191
+            $this->locale = apply_filters(
192
+                'getpaid_get_bank_transfer_locale',
193
+                array(
194
+                    'AU' => array(
195
+                        'sortcode' => array(
196
+                            'label' => __( 'BSB', 'invoicing' ),
197
+                        ),
198
+                    ),
199
+                    'CA' => array(
200
+                        'sortcode' => array(
201
+                            'label' => __( 'Bank transit number', 'invoicing' ),
202
+                        ),
203
+                    ),
204
+                    'IN' => array(
205
+                        'sortcode' => array(
206
+                            'label' => __( 'IFSC', 'invoicing' ),
207
+                        ),
208
+                    ),
209
+                    'IT' => array(
210
+                        'sortcode' => array(
211
+                            'label' => __( 'Branch sort', 'invoicing' ),
212
+                        ),
213
+                    ),
214
+                    'NZ' => array(
215
+                        'sortcode' => array(
216
+                            'label' => __( 'Bank code', 'invoicing' ),
217
+                        ),
218
+                    ),
219
+                    'SE' => array(
220
+                        'sortcode' => array(
221
+                            'label' => __( 'Bank code', 'invoicing' ),
222
+                        ),
223
+                    ),
224
+                    'US' => array(
225
+                        'sortcode' => array(
226
+                            'label' => __( 'Routing number', 'invoicing' ),
227
+                        ),
228
+                    ),
229
+                    'ZA' => array(
230
+                        'sortcode' => array(
231
+                            'label' => __( 'Branch code', 'invoicing' ),
232
+                        ),
233
+                    ),
234
+                )
235
+            );
236
+
237
+        }
238
+
239
+        return $this->locale;
240
+
241
+    }
242
+
243
+    /**
244
+     * Filters the gateway settings.
245
+     * 
246
+     * @param array $admin_settings
247
+     */
248
+    public function admin_settings( $admin_settings ) {
249 249
 
250 250
         $admin_settings['worldpay_desc']['std']    = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' );
251
-		$admin_settings['worldpay_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
251
+        $admin_settings['worldpay_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
252 252
 
253
-		$locale  = $this->get_country_locale();
253
+        $locale  = $this->get_country_locale();
254 254
 
255
-		// Get sortcode label in the $locale array and use appropriate one.
256
-		$country  = wpinv_default_billing_country();
257
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
255
+        // Get sortcode label in the $locale array and use appropriate one.
256
+        $country  = wpinv_default_billing_country();
257
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
258 258
 
259
-		$admin_settings['bank_transfer_ac_name'] = array(
259
+        $admin_settings['bank_transfer_ac_name'] = array(
260 260
             'type' => 'text',
261 261
             'id'   => 'bank_transfer_ac_name',
262 262
             'name' => __( 'Account Name', 'invoicing' ),
263
-		);
263
+        );
264 264
 		
265
-		$admin_settings['bank_transfer_ac_no'] = array(
265
+        $admin_settings['bank_transfer_ac_no'] = array(
266 266
             'type' => 'text',
267 267
             'id'   => 'bank_transfer_ac_no',
268 268
             'name' => __( 'Account Number', 'invoicing' ),
269
-		);
269
+        );
270 270
 		
271
-		$admin_settings['bank_transfer_bank_name'] = array(
271
+        $admin_settings['bank_transfer_bank_name'] = array(
272 272
             'type' => 'text',
273 273
             'id'   => 'bank_transfer_bank_name',
274 274
             'name' => __( 'Bank Name', 'invoicing' ),
275
-		);
275
+        );
276 276
 
277
-		$admin_settings['bank_transfer_ifsc'] = array(
277
+        $admin_settings['bank_transfer_ifsc'] = array(
278 278
             'type' => 'text',
279 279
             'id'   => 'bank_transfer_ifsc',
280 280
             'name' => __( 'IFSC Code', 'invoicing' ),
281
-		);
281
+        );
282 282
 
283
-		$admin_settings['bank_transfer_iban'] = array(
283
+        $admin_settings['bank_transfer_iban'] = array(
284 284
             'type' => 'text',
285 285
             'id'   => 'bank_transfer_iban',
286 286
             'name' => __( 'IBAN', 'invoicing' ),
287
-		);
287
+        );
288 288
 
289
-		$admin_settings['bank_transfer_bic'] = array(
289
+        $admin_settings['bank_transfer_bic'] = array(
290 290
             'type' => 'text',
291 291
             'id'   => 'bank_transfer_bic',
292 292
             'name' => __( 'BIC/Swift Code', 'invoicing' ),
293
-		);
293
+        );
294 294
 		
295
-		$admin_settings['bank_transfer_sort_code'] = array(
296
-			'type' => 'text',
297
-			'id'   => 'bank_transfer_sort_code',
298
-			'name' => $sortcode,
299
-		);
295
+        $admin_settings['bank_transfer_sort_code'] = array(
296
+            'type' => 'text',
297
+            'id'   => 'bank_transfer_sort_code',
298
+            'name' => $sortcode,
299
+        );
300 300
 
301
-		$admin_settings['bank_transfer_info'] = array(
301
+        $admin_settings['bank_transfer_info'] = array(
302 302
             'id'   => 'bank_transfer_info',
303 303
             'name' => __( 'Instructions', 'invoicing' ),
304 304
             'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
             'rows' => 5
309 309
         );
310 310
 
311
-		return $admin_settings;
312
-	}
311
+        return $admin_settings;
312
+    }
313 313
 
314 314
 }
Please login to merge, or discard this patch.
includes/class-wpinv-reports.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         $current = 'earnings';
117 117
 
118 118
         if ( isset( $_GET['view'] ) && array_key_exists( $_GET['view'], $views ) )
119
-		$current = $_GET['view'];
119
+        $current = $_GET['view'];
120 120
 
121 121
         ?>
122 122
 	        <form id="wpinv-reports-filter" method="get" class="tablenav">
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	        </form>
135 135
         <?php
136 136
 
137
-	    do_action( 'wpinv_reports_view_' . $current );
137
+        do_action( 'wpinv_reports_view_' . $current );
138 138
 
139 139
     }
140 140
 
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
             $is_writeable   = $is_dir && is_writeable( $this->export_dir );
225 225
 
226 226
             if ( $is_dir && $is_writeable ) {
227
-               return true;
227
+                return true;
228 228
             } else if ( $is_dir && !$is_writeable ) {
229
-               if ( !$this->wp_filesystem->chmod( $this->export_dir, FS_CHMOD_DIR ) ) {
230
-                   return wp_sprintf( __( 'Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing' ), $this->export_dir );
231
-               }
229
+                if ( !$this->wp_filesystem->chmod( $this->export_dir, FS_CHMOD_DIR ) ) {
230
+                    return wp_sprintf( __( 'Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing' ), $this->export_dir );
231
+                }
232 232
 
233
-               return true;
233
+                return true;
234 234
             } else {
235 235
                 if ( !$this->wp_filesystem->mkdir( $this->export_dir, FS_CHMOD_DIR ) ) {
236 236
                     return wp_sprintf( __( 'Filesystem ERROR: Could not create directory %s. This is usually due to inconsistent file permissions.', 'invoicing' ), $this->export_dir );
@@ -325,12 +325,12 @@  discard block
 block discarded – undo
325 325
         $output  = fopen( 'php://output', 'w' ) or die( 'Unsupported server' );
326 326
 
327 327
         // Let the browser know what content we're streaming and how it should save the content.
328
-		$name = time();
329
-		header( "Content-Type:application/csv" );
328
+        $name = time();
329
+        header( "Content-Type:application/csv" );
330 330
         header( "Content-Disposition:attachment;filename=getpaid-discounts-$name.csv" );
331 331
 
332 332
         // Output the csv column headers.
333
-		fputcsv(
333
+        fputcsv(
334 334
             $output,
335 335
             array(
336 336
                 __( 'Discount Id', 'invoicing' ),
@@ -698,12 +698,12 @@  discard block
 block discarded – undo
698 698
         $thirty_days_ago      = date( 'Y-m-d', strtotime( '-30 days', current_time( 'timestamp' ) ) );
699 699
         $first_day_month  	  = date( 'Y-m-1', current_time( 'timestamp' ) );
700 700
         $last_day_month  	  = date( 'Y-m-t', current_time( 'timestamp' ) );
701
-		$first_day_last_month = date( 'Y-m-d', strtotime( 'first day of last month', current_time( 'timestamp' ) ) );
701
+        $first_day_last_month = date( 'Y-m-d', strtotime( 'first day of last month', current_time( 'timestamp' ) ) );
702 702
         $last_day_last_month  = date( 'Y-m-d', strtotime( 'last day of last month', current_time( 'timestamp' ) ) );
703 703
         $first_day_year  	  = date( 'Y-1-1', current_time( 'timestamp' ) );
704 704
         $last_day_year  	  = date( 'Y-12-31', current_time( 'timestamp' ) );
705
-		$first_day_last_year  = date( 'Y-m-d', strtotime( 'first day of last year', current_time( 'timestamp' ) ) );
706
-		$last_day_last_year   = date( 'Y-m-d', strtotime( 'last day of last year', current_time( 'timestamp' ) ) );
705
+        $first_day_last_year  = date( 'Y-m-d', strtotime( 'first day of last year', current_time( 'timestamp' ) ) );
706
+        $last_day_last_year   = date( 'Y-m-d', strtotime( 'last day of last year', current_time( 'timestamp' ) ) );
707 707
 
708 708
         $ranges = array(
709 709
 
Please login to merge, or discard this patch.
includes/wpinv-email-functions.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
     $css = getpaid_get_email_css();
111 111
 
112 112
     // include css inliner
113
-	if ( ! class_exists( 'Emogrifier' ) ) {
114
-		include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
113
+    if ( ! class_exists( 'Emogrifier' ) ) {
114
+        include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
115 115
     }
116 116
 
117 117
     // Inline the css.
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
     $message = wpinv_email_style_body( $message );
191 191
     $to      = array_merge( wpinv_parse_list( $to ), wpinv_parse_list( $cc ) );
192 192
 
193
-	return $mailer->send(
193
+    return $mailer->send(
194 194
         $to,
195 195
         $subject,
196 196
         $message,
Please login to merge, or discard this patch.
includes/wpinv-general-functions.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -31,36 +31,36 @@  discard block
 block discarded – undo
31 31
 }
32 32
 
33 33
 function wpinv_can_checkout() {
34
-	$can_checkout = true; // Always true for now
34
+    $can_checkout = true; // Always true for now
35 35
 
36
-	return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout );
36
+    return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout );
37 37
 }
38 38
 
39 39
 function wpinv_get_success_page_uri() {
40
-	$page_id = wpinv_get_option( 'success_page', 0 );
41
-	$page_id = absint( $page_id );
40
+    $page_id = wpinv_get_option( 'success_page', 0 );
41
+    $page_id = absint( $page_id );
42 42
 
43
-	return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) );
43
+    return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) );
44 44
 }
45 45
 
46 46
 function wpinv_get_history_page_uri() {
47
-	$page_id = wpinv_get_option( 'invoice_history_page', 0 );
48
-	$page_id = absint( $page_id );
47
+    $page_id = wpinv_get_option( 'invoice_history_page', 0 );
48
+    $page_id = absint( $page_id );
49 49
 
50
-	return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) );
50
+    return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) );
51 51
 }
52 52
 
53 53
 function wpinv_is_success_page() {
54
-	$is_success_page = wpinv_get_option( 'success_page', false );
55
-	$is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false;
54
+    $is_success_page = wpinv_get_option( 'success_page', false );
55
+    $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false;
56 56
 
57
-	return apply_filters( 'wpinv_is_success_page', $is_success_page );
57
+    return apply_filters( 'wpinv_is_success_page', $is_success_page );
58 58
 }
59 59
 
60 60
 function wpinv_is_invoice_history_page() {
61
-	$ret = wpinv_get_option( 'invoice_history_page', false );
62
-	$ret = $ret ? is_page( $ret ) : false;
63
-	return apply_filters( 'wpinv_is_invoice_history_page', $ret );
61
+    $ret = wpinv_get_option( 'invoice_history_page', false );
62
+    $ret = $ret ? is_page( $ret ) : false;
63
+    return apply_filters( 'wpinv_is_invoice_history_page', $ret );
64 64
 }
65 65
 
66 66
 function wpinv_is_subscriptions_history_page() {
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 }
84 84
 
85 85
 function wpinv_send_to_failed_page( $args = null ) {
86
-	$redirect = wpinv_get_failed_transaction_uri();
86
+    $redirect = wpinv_get_failed_transaction_uri();
87 87
     
88 88
     if ( !empty( $args ) ) {
89 89
         // Check for backward compatibility
@@ -103,55 +103,55 @@  discard block
 block discarded – undo
103 103
 }
104 104
 
105 105
 function wpinv_get_checkout_uri( $args = array() ) {
106
-	$uri = wpinv_get_option( 'checkout_page', false );
107
-	$uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
106
+    $uri = wpinv_get_option( 'checkout_page', false );
107
+    $uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
108 108
 
109
-	if ( !empty( $args ) ) {
110
-		// Check for backward compatibility
111
-		if ( is_string( $args ) )
112
-			$args = str_replace( '?', '', $args );
109
+    if ( !empty( $args ) ) {
110
+        // Check for backward compatibility
111
+        if ( is_string( $args ) )
112
+            $args = str_replace( '?', '', $args );
113 113
 
114
-		$args = wp_parse_args( $args );
114
+        $args = wp_parse_args( $args );
115 115
 
116
-		$uri = add_query_arg( $args, $uri );
117
-	}
116
+        $uri = add_query_arg( $args, $uri );
117
+    }
118 118
 
119
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
119
+    $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
120 120
 
121
-	$ajax_url = admin_url( 'admin-ajax.php', $scheme );
121
+    $ajax_url = admin_url( 'admin-ajax.php', $scheme );
122 122
 
123
-	if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
124
-		$uri = preg_replace( '/^http:/', 'https:', $uri );
125
-	}
123
+    if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
124
+        $uri = preg_replace( '/^http:/', 'https:', $uri );
125
+    }
126 126
 
127
-	return apply_filters( 'wpinv_get_checkout_uri', $uri );
127
+    return apply_filters( 'wpinv_get_checkout_uri', $uri );
128 128
 }
129 129
 
130 130
 function wpinv_get_success_page_url( $query_string = null ) {
131
-	$success_page = wpinv_get_option( 'success_page', 0 );
132
-	$success_page = get_permalink( $success_page );
131
+    $success_page = wpinv_get_option( 'success_page', 0 );
132
+    $success_page = get_permalink( $success_page );
133 133
 
134
-	if ( $query_string )
135
-		$success_page .= $query_string;
134
+    if ( $query_string )
135
+        $success_page .= $query_string;
136 136
 
137
-	return apply_filters( 'wpinv_success_page_url', $success_page );
137
+    return apply_filters( 'wpinv_success_page_url', $success_page );
138 138
 }
139 139
 
140 140
 function wpinv_get_failed_transaction_uri( $extras = false ) {
141
-	$uri = wpinv_get_option( 'failure_page', '' );
142
-	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
141
+    $uri = wpinv_get_option( 'failure_page', '' );
142
+    $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
143 143
 
144
-	if ( $extras )
145
-		$uri .= $extras;
144
+    if ( $extras )
145
+        $uri .= $extras;
146 146
 
147
-	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
147
+    return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
148 148
 }
149 149
 
150 150
 function wpinv_is_failed_transaction_page() {
151
-	$ret = wpinv_get_option( 'failure_page', false );
152
-	$ret = isset( $ret ) ? is_page( $ret ) : false;
151
+    $ret = wpinv_get_option( 'failure_page', false );
152
+    $ret = isset( $ret ) ? is_page( $ret ) : false;
153 153
 
154
-	return apply_filters( 'wpinv_is_failure_page', $ret );
154
+    return apply_filters( 'wpinv_is_failure_page', $ret );
155 155
 }
156 156
 
157 157
 function wpinv_transaction_query( $type = 'start' ) {
@@ -226,36 +226,36 @@  discard block
 block discarded – undo
226 226
     $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() );
227 227
     
228 228
     if ( $require_billing_details ) {
229
-		if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) {
230
-			$required_fields['first_name'] = array(
231
-				'error_id' => 'invalid_first_name',
232
-				'error_message' => __( 'Please enter your first name', 'invoicing' )
233
-			);
234
-		}
235
-		if ( (bool)wpinv_get_option( 'address_mandatory' ) ) {
236
-			$required_fields['address'] = array(
237
-				'error_id' => 'invalid_address',
238
-				'error_message' => __( 'Please enter your address', 'invoicing' )
239
-			);
240
-		}
241
-		if ( (bool)wpinv_get_option( 'city_mandatory' ) ) {
242
-			$required_fields['city'] = array(
243
-				'error_id' => 'invalid_city',
244
-				'error_message' => __( 'Please enter your billing city', 'invoicing' )
245
-			);
246
-		}
247
-		if ( (bool)wpinv_get_option( 'state_mandatory' ) ) {
248
-			$required_fields['state'] = array(
249
-				'error_id' => 'invalid_state',
250
-				'error_message' => __( 'Please enter billing state / province', 'invoicing' )
251
-			);
252
-		}
253
-		if ( (bool)wpinv_get_option( 'country_mandatory' ) ) {
254
-			$required_fields['country'] = array(
255
-				'error_id' => 'invalid_country',
256
-				'error_message' => __( 'Please select your billing country', 'invoicing' )
257
-			);
258
-		}
229
+        if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) {
230
+            $required_fields['first_name'] = array(
231
+                'error_id' => 'invalid_first_name',
232
+                'error_message' => __( 'Please enter your first name', 'invoicing' )
233
+            );
234
+        }
235
+        if ( (bool)wpinv_get_option( 'address_mandatory' ) ) {
236
+            $required_fields['address'] = array(
237
+                'error_id' => 'invalid_address',
238
+                'error_message' => __( 'Please enter your address', 'invoicing' )
239
+            );
240
+        }
241
+        if ( (bool)wpinv_get_option( 'city_mandatory' ) ) {
242
+            $required_fields['city'] = array(
243
+                'error_id' => 'invalid_city',
244
+                'error_message' => __( 'Please enter your billing city', 'invoicing' )
245
+            );
246
+        }
247
+        if ( (bool)wpinv_get_option( 'state_mandatory' ) ) {
248
+            $required_fields['state'] = array(
249
+                'error_id' => 'invalid_state',
250
+                'error_message' => __( 'Please enter billing state / province', 'invoicing' )
251
+            );
252
+        }
253
+        if ( (bool)wpinv_get_option( 'country_mandatory' ) ) {
254
+            $required_fields['country'] = array(
255
+                'error_id' => 'invalid_country',
256
+                'error_message' => __( 'Please select your billing country', 'invoicing' )
257
+            );
258
+        }
259 259
     }
260 260
 
261 261
     return apply_filters( 'wpinv_checkout_required_fields', $required_fields );
Please login to merge, or discard this patch.