Completed
Pull Request — master (#1203)
by Devin
20:46
created
includes/gateways/manual.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  * @since 1.0
21 21
  * @return void
22 22
  */
23
-add_action( 'give_manual_cc_form', '__return_false' );
23
+add_action('give_manual_cc_form', '__return_false');
24 24
 
25 25
 /**
26 26
  * Processes the purchase data and uses the Manual Payment gateway to record
@@ -32,17 +32,17 @@  discard block
 block discarded – undo
32 32
  *
33 33
  * @return void
34 34
  */
35
-function give_manual_payment( $purchase_data ) {
35
+function give_manual_payment($purchase_data) {
36 36
 
37
-	if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) {
38
-		wp_die( esc_html__( 'Nonce verification has failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
37
+	if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) {
38
+		wp_die(esc_html__('Nonce verification has failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
39 39
 	}
40 40
 	
41 41
 	//Create payment_data array
42 42
 	$payment_data = array(
43 43
 		'price'           => $purchase_data['price'],
44 44
 		'give_form_title' => $purchase_data['post_data']['give-form-title'],
45
-		'give_form_id'    => intval( $purchase_data['post_data']['give-form-id'] ),
45
+		'give_form_id'    => intval($purchase_data['post_data']['give-form-id']),
46 46
 		'give_price_id'   => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '',
47 47
 		'date'            => $purchase_data['date'],
48 48
 		'user_email'      => $purchase_data['user_email'],
@@ -52,24 +52,24 @@  discard block
 block discarded – undo
52 52
 		'status'          => 'pending'
53 53
 	);
54 54
 	// Record the pending payment
55
-	$payment = give_insert_payment( $payment_data );
55
+	$payment = give_insert_payment($payment_data);
56 56
 
57
-	if ( $payment ) {
58
-		give_update_payment_status( $payment, 'publish' );
57
+	if ($payment) {
58
+		give_update_payment_status($payment, 'publish');
59 59
 		give_send_to_success_page();
60 60
 	} else {
61 61
 		give_record_gateway_error(
62
-			esc_html__( 'Payment Error', 'give' ),
62
+			esc_html__('Payment Error', 'give'),
63 63
 			sprintf(
64 64
 				/* translators: %s: payment data */
65
-				esc_html__( 'The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give' ),
66
-				json_encode( $payment_data )
65
+				esc_html__('The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give'),
66
+				json_encode($payment_data)
67 67
 			),
68 68
 			$payment
69 69
 		);
70 70
 		// If errors are present, send the user back to the purchase page so they can be corrected
71
-		give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] );
71
+		give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']);
72 72
 	}
73 73
 }
74 74
 
75
-add_action( 'give_gateway_manual', 'give_manual_payment' );
75
+add_action('give_gateway_manual', 'give_manual_payment');
Please login to merge, or discard this patch.
includes/admin/reporting/class-gateways-reports-table.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17 17
 // Load WP_List_Table if not loaded
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
 		global $status, $page;
46 46
 
47 47
 		// Set parent defaults
48
-		parent::__construct( array(
49
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records
50
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records
48
+		parent::__construct(array(
49
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records
50
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records
51 51
 			'ajax'     => false                        // Does this table support ajax?
52
-		) );
52
+		));
53 53
 
54 54
 	}
55 55
 
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return string Column Name
66 66
 	 */
67
-	public function column_default( $item, $column_name ) {
68
-		switch ( $column_name ) {
67
+	public function column_default($item, $column_name) {
68
+		switch ($column_name) {
69 69
 			default:
70
-				return $item[ $column_name ];
70
+				return $item[$column_name];
71 71
 		}
72 72
 	}
73 73
 
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function get_columns() {
82 82
 		$columns = array(
83
-			'label'           => esc_attr__( 'Gateway', 'give' ),
84
-			'complete_sales'  => esc_attr__( 'Complete Transactions', 'give' ),
85
-			'pending_sales'   => esc_attr__( 'Pending / Failed Transactions', 'give' ),
86
-			'total_sales'     => esc_attr__( 'Total Transactions', 'give' ),
87
-			'total_donations' => esc_attr__( 'Total Donations', 'give' )
83
+			'label'           => esc_attr__('Gateway', 'give'),
84
+			'complete_sales'  => esc_attr__('Complete Transactions', 'give'),
85
+			'pending_sales'   => esc_attr__('Pending / Failed Transactions', 'give'),
86
+			'total_sales'     => esc_attr__('Total Transactions', 'give'),
87
+			'total_donations' => esc_attr__('Total Donations', 'give')
88 88
 		);
89 89
 
90 90
 		return $columns;
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 * @return int Current page number
100 100
 	 */
101 101
 	public function get_paged() {
102
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
102
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
103 103
 	}
104 104
 
105 105
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 * @since  1.0
111 111
 	 * @return void
112 112
 	 */
113
-	public function bulk_actions( $which = '' ) {
113
+	public function bulk_actions($which = '') {
114 114
 		// These aren't really bulk actions but this outputs the markup in the right place
115 115
 		give_report_views();
116 116
 	}
@@ -123,23 +123,23 @@  discard block
 block discarded – undo
123 123
 	 *
124 124
 	 * @param string $which
125 125
 	 */
126
-	protected function display_tablenav( $which ) {
126
+	protected function display_tablenav($which) {
127 127
 
128
-		if ( 'top' == $which ) {
129
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
128
+		if ('top' == $which) {
129
+			wp_nonce_field('bulk-'.$this->_args['plural']);
130 130
 		}
131 131
 		?>
132
-		<div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr( $which ); ?>">
132
+		<div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr($which); ?>">
133 133
 
134
-			<h3 class="alignleft reports-earnings-title"><span><?php esc_html_e( 'Donation Methods Report', 'give' ); ?></span></h3>
134
+			<h3 class="alignleft reports-earnings-title"><span><?php esc_html_e('Donation Methods Report', 'give'); ?></span></h3>
135 135
 
136 136
 			<div class="alignright tablenav-right">
137 137
 				<div class="actions bulkactions">
138
-					<?php $this->bulk_actions( $which ); ?>
138
+					<?php $this->bulk_actions($which); ?>
139 139
 				</div>
140 140
 				<?php
141
-				$this->extra_tablenav( $which );
142
-				$this->pagination( $which );
141
+				$this->extra_tablenav($which);
142
+				$this->pagination($which);
143 143
 				?>
144 144
 			</div>
145 145
 
@@ -164,18 +164,18 @@  discard block
 block discarded – undo
164 164
 		$gateways     = give_get_payment_gateways();
165 165
 		$stats        = new Give_Payment_Stats();
166 166
 
167
-		foreach ( $gateways as $gateway_id => $gateway ) {
167
+		foreach ($gateways as $gateway_id => $gateway) {
168 168
 
169
-			$complete_count = give_count_sales_by_gateway( $gateway_id, 'publish' );
170
-			$pending_count  = give_count_sales_by_gateway( $gateway_id, array( 'pending', 'failed' ) );
169
+			$complete_count = give_count_sales_by_gateway($gateway_id, 'publish');
170
+			$pending_count  = give_count_sales_by_gateway($gateway_id, array('pending', 'failed'));
171 171
 
172 172
 			$reports_data[] = array(
173 173
 				'ID'              => $gateway_id,
174 174
 				'label'           => $gateway['admin_label'],
175
-				'complete_sales'  => give_format_amount( $complete_count, false ),
176
-				'pending_sales'   => give_format_amount( $pending_count, false ),
177
-				'total_sales'     => give_format_amount( $complete_count + $pending_count, false ),
178
-				'total_donations' => give_currency_filter( give_format_amount( $stats->get_earnings( 0, 0, 0, $gateway_id ) ) )
175
+				'complete_sales'  => give_format_amount($complete_count, false),
176
+				'pending_sales'   => give_format_amount($pending_count, false),
177
+				'total_sales'     => give_format_amount($complete_count + $pending_count, false),
178
+				'total_donations' => give_currency_filter(give_format_amount($stats->get_earnings(0, 0, 0, $gateway_id)))
179 179
 			);
180 180
 		}
181 181
 
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 		$columns               = $this->get_columns();
198 198
 		$hidden                = array(); // No hidden columns
199 199
 		$sortable              = $this->get_sortable_columns();
200
-		$this->_column_headers = array( $columns, $hidden, $sortable );
200
+		$this->_column_headers = array($columns, $hidden, $sortable);
201 201
 		$this->items           = $this->reports_data();
202 202
 
203 203
 	}
Please login to merge, or discard this patch.
includes/admin/reporting/export/export-actions.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
11 11
  */
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
  */
23 23
 function give_process_batch_export_form() {
24 24
 
25
-	if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'give-batch-export' ) ) {
26
-		wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
25
+	if ( ! wp_verify_nonce($_REQUEST['nonce'], 'give-batch-export')) {
26
+		wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
27 27
 	}
28 28
 
29
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php';
29
+	require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export.php';
30 30
 
31 31
 	/**
32 32
 	 * Fires before batch export.
@@ -35,14 +35,14 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @param atring $class Export class.
37 37
 	 */
38
-	do_action( 'give_batch_export_class_include', $_REQUEST['class'] );
38
+	do_action('give_batch_export_class_include', $_REQUEST['class']);
39 39
 
40 40
 	$export = new $_REQUEST['class'];
41 41
 	$export->export();
42 42
 
43 43
 }
44 44
 
45
-add_action( 'give_form_batch_export', 'give_process_batch_export_form' );
45
+add_action('give_form_batch_export', 'give_process_batch_export_form');
46 46
 
47 47
 /**
48 48
  * Exports earnings for a specified time period
@@ -53,14 +53,14 @@  discard block
 block discarded – undo
53 53
  * @return void
54 54
  */
55 55
 function give_export_earnings() {
56
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-earnings.php';
56
+	require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-earnings.php';
57 57
 
58 58
 	$earnings_export = new Give_Earnings_Export();
59 59
 
60 60
 	$earnings_export->export();
61 61
 }
62 62
 
63
-add_action( 'give_earnings_export', 'give_export_earnings' );
63
+add_action('give_earnings_export', 'give_export_earnings');
64 64
 
65 65
 
66 66
 /**
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
  * @return void
74 74
  */
75 75
 function give_export_all_customers() {
76
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-customers.php';
76
+	require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-customers.php';
77 77
 
78 78
 	$customer_export = new Give_Donors_Export();
79 79
 
80 80
 	$customer_export->export();
81 81
 }
82 82
 
83
-add_action( 'give_email_export', 'give_export_all_customers' );
83
+add_action('give_email_export', 'give_export_all_customers');
84 84
 
85 85
 /**
86 86
  * Add a hook allowing extensions to register a hook on the batch export process
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
  * @return void
90 90
  */
91 91
 function give_register_batch_exporters() {
92
-	if ( is_admin() ) {
92
+	if (is_admin()) {
93 93
 		/**
94 94
 		 * Fires in the admin, while plugins loaded.
95 95
 		 *
@@ -99,21 +99,21 @@  discard block
 block discarded – undo
99 99
 		 *
100 100
 		 * @param string $class Export class.
101 101
 		 */
102
-		do_action( 'give_register_batch_exporter' );
102
+		do_action('give_register_batch_exporter');
103 103
 	}
104 104
 }
105 105
 
106
-add_action( 'plugins_loaded', 'give_register_batch_exporters' );
106
+add_action('plugins_loaded', 'give_register_batch_exporters');
107 107
 
108 108
 /**
109 109
  * Register the payments batch exporter
110 110
  * @since  1.5
111 111
  */
112 112
 function give_register_payments_batch_export() {
113
-	add_action( 'give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1 );
113
+	add_action('give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1);
114 114
 }
115 115
 
116
-add_action( 'give_register_batch_exporter', 'give_register_payments_batch_export', 10 );
116
+add_action('give_register_batch_exporter', 'give_register_payments_batch_export', 10);
117 117
 
118 118
 /**
119 119
  * Loads the payments batch process if needed
@@ -124,10 +124,10 @@  discard block
 block discarded – undo
124 124
  *
125 125
  * @return void
126 126
  */
127
-function give_include_payments_batch_processor( $class ) {
127
+function give_include_payments_batch_processor($class) {
128 128
 
129
-	if ( 'Give_Batch_Payments_Export' === $class ) {
130
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-payments.php';
129
+	if ('Give_Batch_Payments_Export' === $class) {
130
+		require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-payments.php';
131 131
 	}
132 132
 
133 133
 }
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
  * @since  1.5.2
138 138
  */
139 139
 function give_register_customers_batch_export() {
140
-	add_action( 'give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1 );
140
+	add_action('give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1);
141 141
 }
142 142
 
143
-add_action( 'give_register_batch_exporter', 'give_register_customers_batch_export', 10 );
143
+add_action('give_register_batch_exporter', 'give_register_customers_batch_export', 10);
144 144
 
145 145
 /**
146 146
  * Loads the customers batch process if needed
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
  *
152 152
  * @return void
153 153
  */
154
-function give_include_customers_batch_processor( $class ) {
154
+function give_include_customers_batch_processor($class) {
155 155
 
156
-	if ( 'Give_Batch_Customers_Export' === $class ) {
157
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-customers.php';
156
+	if ('Give_Batch_Customers_Export' === $class) {
157
+		require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-customers.php';
158 158
 	}
159 159
 
160 160
 }
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
  * @since  1.5
166 166
  */
167 167
 function give_register_forms_batch_export() {
168
-	add_action( 'give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1 );
168
+	add_action('give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1);
169 169
 }
170 170
 
171
-add_action( 'give_register_batch_exporter', 'give_register_forms_batch_export', 10 );
171
+add_action('give_register_batch_exporter', 'give_register_forms_batch_export', 10);
172 172
 
173 173
 /**
174 174
  * Loads the file downloads batch process if needed
@@ -179,10 +179,10 @@  discard block
 block discarded – undo
179 179
  *
180 180
  * @return void
181 181
  */
182
-function give_include_forms_batch_processor( $class ) {
182
+function give_include_forms_batch_processor($class) {
183 183
 
184
-	if ( 'Give_Batch_Forms_Export' === $class ) {
185
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-forms.php';
184
+	if ('Give_Batch_Forms_Export' === $class) {
185
+		require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-forms.php';
186 186
 	}
187 187
 
188 188
 }
189 189
\ No newline at end of file
Please login to merge, or discard this patch.
includes/emails/class-give-emails.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function __construct() {
81 81
 
82
-		if ( 'none' === $this->get_template() ) {
82
+		if ('none' === $this->get_template()) {
83 83
 			$this->html = false;
84 84
 		}
85 85
 
86
-		add_action( 'give_email_send_before', array( $this, 'send_before' ) );
87
-		add_action( 'give_email_send_after', array( $this, 'send_after' ) );
86
+		add_action('give_email_send_before', array($this, 'send_before'));
87
+		add_action('give_email_send_after', array($this, 'send_after'));
88 88
 
89 89
 	}
90 90
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 *
94 94
 	 * @since 1.0
95 95
 	 */
96
-	public function __set( $key, $value ) {
96
+	public function __set($key, $value) {
97 97
 		$this->$key = $value;
98 98
 	}
99 99
 
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
 	 * @since 1.0
104 104
 	 */
105 105
 	public function get_from_name() {
106
-		if ( ! $this->from_name ) {
107
-			$this->from_name = give_get_option( 'from_name', get_bloginfo( 'name' ) );
106
+		if ( ! $this->from_name) {
107
+			$this->from_name = give_get_option('from_name', get_bloginfo('name'));
108 108
 		}
109 109
 
110
-		return apply_filters( 'give_email_from_name', wp_specialchars_decode( $this->from_name ), $this );
110
+		return apply_filters('give_email_from_name', wp_specialchars_decode($this->from_name), $this);
111 111
 	}
112 112
 
113 113
 	/**
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 	 * @since 1.0
117 117
 	 */
118 118
 	public function get_from_address() {
119
-		if ( ! $this->from_address ) {
120
-			$this->from_address = give_get_option( 'from_email', get_option( 'admin_email' ) );
119
+		if ( ! $this->from_address) {
120
+			$this->from_address = give_get_option('from_email', get_option('admin_email'));
121 121
 		}
122 122
 
123
-		return apply_filters( 'give_email_from_address', $this->from_address, $this );
123
+		return apply_filters('give_email_from_address', $this->from_address, $this);
124 124
 	}
125 125
 
126 126
 	/**
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
 	 * @since 1.0
130 130
 	 */
131 131
 	public function get_content_type() {
132
-		if ( ! $this->content_type && $this->html ) {
133
-			$this->content_type = apply_filters( 'give_email_default_content_type', 'text/html', $this );
134
-		} else if ( ! $this->html ) {
132
+		if ( ! $this->content_type && $this->html) {
133
+			$this->content_type = apply_filters('give_email_default_content_type', 'text/html', $this);
134
+		} else if ( ! $this->html) {
135 135
 			$this->content_type = 'text/plain';
136 136
 		}
137 137
 
138
-		return apply_filters( 'give_email_content_type', $this->content_type, $this );
138
+		return apply_filters('give_email_content_type', $this->content_type, $this);
139 139
 	}
140 140
 
141 141
 	/**
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
 	 * @since 1.0
145 145
 	 */
146 146
 	public function get_headers() {
147
-		if ( ! $this->headers ) {
147
+		if ( ! $this->headers) {
148 148
 			$this->headers = "From: {$this->get_from_name()} <{$this->get_from_address()}>\r\n";
149 149
 			$this->headers .= "Reply-To: {$this->get_from_address()}\r\n";
150 150
 			$this->headers .= "Content-Type: {$this->get_content_type()}; charset=utf-8\r\n";
151 151
 		}
152 152
 
153
-		return apply_filters( 'give_email_headers', $this->headers, $this );
153
+		return apply_filters('give_email_headers', $this->headers, $this);
154 154
 	}
155 155
 
156 156
 	/**
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function get_templates() {
162 162
 		$templates = array(
163
-			'default' => esc_html__( 'Default Template', 'give' ),
164
-			'none'    => esc_html__( 'No template, plain text only', 'give' )
163
+			'default' => esc_html__('Default Template', 'give'),
164
+			'none'    => esc_html__('No template, plain text only', 'give')
165 165
 		);
166 166
 
167
-		return apply_filters( 'give_email_templates', $templates );
167
+		return apply_filters('give_email_templates', $templates);
168 168
 	}
169 169
 
170 170
 	/**
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
 	 * @since 1.0
174 174
 	 */
175 175
 	public function get_template() {
176
-		if ( ! $this->template ) {
177
-			$this->template = give_get_option( 'email_template', 'default' );
176
+		if ( ! $this->template) {
177
+			$this->template = give_get_option('email_template', 'default');
178 178
 		}
179 179
 
180
-		return apply_filters( 'give_email_template', $this->template );
180
+		return apply_filters('give_email_template', $this->template);
181 181
 	}
182 182
 
183 183
 	/**
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 * @since 1.0
187 187
 	 */
188 188
 	public function get_heading() {
189
-		return apply_filters( 'give_email_heading', $this->heading );
189
+		return apply_filters('give_email_heading', $this->heading);
190 190
 	}
191 191
 
192 192
 	/**
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 *
197 197
 	 * @return mixed
198 198
 	 */
199
-	public function parse_tags( $content ) {
199
+	public function parse_tags($content) {
200 200
 		return $content;
201 201
 	}
202 202
 
@@ -205,19 +205,19 @@  discard block
 block discarded – undo
205 205
 	 *
206 206
 	 * @since 1.0
207 207
 	 */
208
-	public function build_email( $message ) {
208
+	public function build_email($message) {
209 209
 
210
-		if ( false === $this->html ) {
211
-			return apply_filters( 'give_email_message', wp_strip_all_tags( $message ), $this );
210
+		if (false === $this->html) {
211
+			return apply_filters('give_email_message', wp_strip_all_tags($message), $this);
212 212
 		}
213 213
 
214
-		$message = $this->text_to_html( $message );
214
+		$message = $this->text_to_html($message);
215 215
 
216 216
 		$template = $this->get_template();
217 217
 
218 218
 		ob_start();
219 219
 
220
-		give_get_template_part( 'emails/header', $template, true );
220
+		give_get_template_part('emails/header', $template, true);
221 221
 
222 222
 		/**
223 223
 		 * Fires in the email head.
@@ -226,17 +226,17 @@  discard block
 block discarded – undo
226 226
 		 *
227 227
 		 * @param Give_Emails $this The email object.
228 228
 		 */
229
-		do_action( 'give_email_header', $this );
229
+		do_action('give_email_header', $this);
230 230
 
231
-		if ( has_action( 'give_email_template_' . $template ) ) {
231
+		if (has_action('give_email_template_'.$template)) {
232 232
 			/**
233 233
 			 * Fires in a specific email template.
234 234
 			 *
235 235
 			 * @since 1.0
236 236
 			 */
237
-			do_action( "give_email_template_{$template}" );
237
+			do_action("give_email_template_{$template}");
238 238
 		} else {
239
-			give_get_template_part( 'emails/body', $template, true );
239
+			give_get_template_part('emails/body', $template, true);
240 240
 		}
241 241
 
242 242
 		/**
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
 		 *
247 247
 		 * @param Give_Emails $this The email object.
248 248
 		 */
249
-		do_action( 'give_email_body', $this );
249
+		do_action('give_email_body', $this);
250 250
 
251
-		give_get_template_part( 'emails/footer', $template, true );
251
+		give_get_template_part('emails/footer', $template, true);
252 252
 
253 253
 		/**
254 254
 		 * Fires in the email footer.
@@ -257,12 +257,12 @@  discard block
 block discarded – undo
257 257
 		 *
258 258
 		 * @param Give_Emails $this The email object.
259 259
 		 */
260
-		do_action( 'give_email_footer', $this );
260
+		do_action('give_email_footer', $this);
261 261
 
262 262
 		$body    = ob_get_clean();
263
-		$message = str_replace( '{email}', $message, $body );
263
+		$message = str_replace('{email}', $message, $body);
264 264
 
265
-		return apply_filters( 'give_email_message', $message, $this );
265
+		return apply_filters('give_email_message', $message, $this);
266 266
 	}
267 267
 
268 268
 	/**
@@ -275,10 +275,10 @@  discard block
 block discarded – undo
275 275
 	 *
276 276
 	 * @return bool
277 277
 	 */
278
-	public function send( $to, $subject, $message, $attachments = '' ) {
278
+	public function send($to, $subject, $message, $attachments = '') {
279 279
 
280
-		if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) {
281
-			_doing_it_wrong( __FUNCTION__, esc_html__( 'You cannot send email with Give_Emails until init/admin_init has been reached.', 'give' ), null );
280
+		if ( ! did_action('init') && ! did_action('admin_init')) {
281
+			_doing_it_wrong(__FUNCTION__, esc_html__('You cannot send email with Give_Emails until init/admin_init has been reached.', 'give'), null);
282 282
 
283 283
 			return false;
284 284
 		}
@@ -290,16 +290,16 @@  discard block
 block discarded – undo
290 290
 		 *
291 291
 		 * @param Give_Emails $this The email object.
292 292
 		 */
293
-		do_action( 'give_email_send_before', $this );
293
+		do_action('give_email_send_before', $this);
294 294
 
295
-		$subject = $this->parse_tags( $subject );
296
-		$message = $this->parse_tags( $message );
295
+		$subject = $this->parse_tags($subject);
296
+		$message = $this->parse_tags($message);
297 297
 
298
-		$message = $this->build_email( $message );
298
+		$message = $this->build_email($message);
299 299
 
300
-		$attachments = apply_filters( 'give_email_attachments', $attachments, $this );
300
+		$attachments = apply_filters('give_email_attachments', $attachments, $this);
301 301
 
302
-		$sent = wp_mail( $to, $subject, $message, $this->get_headers(), $attachments );
302
+		$sent = wp_mail($to, $subject, $message, $this->get_headers(), $attachments);
303 303
 
304 304
 		/**
305 305
 		 * Fires after sending an email.
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 		 *
309 309
 		 * @param Give_Emails $this The email object.
310 310
 		 */
311
-		do_action( 'give_email_send_after', $this );
311
+		do_action('give_email_send_after', $this);
312 312
 
313 313
 		return $sent;
314 314
 
@@ -320,9 +320,9 @@  discard block
 block discarded – undo
320 320
 	 * @since 1.0
321 321
 	 */
322 322
 	public function send_before() {
323
-		add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
324
-		add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
325
-		add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
323
+		add_filter('wp_mail_from', array($this, 'get_from_address'));
324
+		add_filter('wp_mail_from_name', array($this, 'get_from_name'));
325
+		add_filter('wp_mail_content_type', array($this, 'get_content_type'));
326 326
 	}
327 327
 
328 328
 	/**
@@ -331,9 +331,9 @@  discard block
 block discarded – undo
331 331
 	 * @since 1.0
332 332
 	 */
333 333
 	public function send_after() {
334
-		remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
335
-		remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
336
-		remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
334
+		remove_filter('wp_mail_from', array($this, 'get_from_address'));
335
+		remove_filter('wp_mail_from_name', array($this, 'get_from_name'));
336
+		remove_filter('wp_mail_content_type', array($this, 'get_content_type'));
337 337
 
338 338
 		// Reset heading to an empty string
339 339
 		$this->heading = '';
@@ -344,10 +344,10 @@  discard block
 block discarded – undo
344 344
 	 *
345 345
 	 * @since 1.0
346 346
 	 */
347
-	public function text_to_html( $message ) {
347
+	public function text_to_html($message) {
348 348
 
349
-		if ( 'text/html' == $this->content_type || true === $this->html ) {
350
-			$message = wpautop( $message );
349
+		if ('text/html' == $this->content_type || true === $this->html) {
350
+			$message = wpautop($message);
351 351
 		}
352 352
 
353 353
 		return $message;
Please login to merge, or discard this patch.
uninstall.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -10,61 +10,61 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
13
+if ( ! defined('WP_UNINSTALL_PLUGIN')) {
14 14
 	exit;
15 15
 }
16 16
 
17 17
 // Load Give file.
18
-include_once( 'give.php' );
18
+include_once('give.php');
19 19
 
20 20
 global $wpdb, $wp_roles;
21 21
 
22 22
 
23
-if ( give_get_option( 'uninstall_on_delete' ) === 'on' ) {
23
+if (give_get_option('uninstall_on_delete') === 'on') {
24 24
 
25 25
 	// Delete All the Custom Post Types.
26
-	$give_taxonomies = array( 'form_category', 'form_tag', 'give_log_type' );
27
-	$give_post_types = array( 'give_forms', 'give_payment', 'give_log' );
28
-	foreach ( $give_post_types as $post_type ) {
26
+	$give_taxonomies = array('form_category', 'form_tag', 'give_log_type');
27
+	$give_post_types = array('give_forms', 'give_payment', 'give_log');
28
+	foreach ($give_post_types as $post_type) {
29 29
 
30
-		$give_taxonomies = array_merge( $give_taxonomies, get_object_taxonomies( $post_type ) );
31
-		$items           = get_posts( array(
30
+		$give_taxonomies = array_merge($give_taxonomies, get_object_taxonomies($post_type));
31
+		$items           = get_posts(array(
32 32
 			'post_type'   => $post_type,
33 33
 			'post_status' => 'any',
34
-			'numberposts' => - 1,
34
+			'numberposts' => -1,
35 35
 			'fields'      => 'ids',
36
-		) );
36
+		));
37 37
 
38
-		if ( $items ) {
39
-			foreach ( $items as $item ) {
40
-				wp_delete_post( $item, true );
38
+		if ($items) {
39
+			foreach ($items as $item) {
40
+				wp_delete_post($item, true);
41 41
 			}
42 42
 		}
43 43
 	}
44 44
 
45 45
 	// Delete All the Terms & Taxonomies.
46
-	foreach ( array_unique( array_filter( $give_taxonomies ) ) as $taxonomy ) {
46
+	foreach (array_unique(array_filter($give_taxonomies)) as $taxonomy) {
47 47
 
48
-		$terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy ) );
48
+		$terms = $wpdb->get_results($wpdb->prepare("SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy));
49 49
 
50 50
 		// Delete Terms.
51
-		if ( $terms ) {
52
-			foreach ( $terms as $term ) {
53
-				$wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $term->term_taxonomy_id ) );
54
-				$wpdb->delete( $wpdb->terms, array( 'term_id' => $term->term_id ) );
51
+		if ($terms) {
52
+			foreach ($terms as $term) {
53
+				$wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $term->term_taxonomy_id));
54
+				$wpdb->delete($wpdb->terms, array('term_id' => $term->term_id));
55 55
 			}
56 56
 		}
57 57
 
58 58
 		// Delete Taxonomies.
59
-		$wpdb->delete( $wpdb->term_taxonomy, array( 'taxonomy' => $taxonomy ), array( '%s' ) );
59
+		$wpdb->delete($wpdb->term_taxonomy, array('taxonomy' => $taxonomy), array('%s'));
60 60
 	}
61 61
 
62 62
 	// Delete the Plugin Pages.
63
-	$give_created_pages = array( 'success_page', 'failure_page', 'history_page' );
64
-	foreach ( $give_created_pages as $p ) {
65
-		$page = give_get_option( $p, false );
66
-		if ( $page ) {
67
-			wp_delete_post( $page, true );
63
+	$give_created_pages = array('success_page', 'failure_page', 'history_page');
64
+	foreach ($give_created_pages as $p) {
65
+		$page = give_get_option($p, false);
66
+		if ($page) {
67
+			wp_delete_post($page, true);
68 68
 		}
69 69
 	}
70 70
 
@@ -72,20 +72,20 @@  discard block
 block discarded – undo
72 72
 	Give()->roles->remove_caps();
73 73
 
74 74
 	// Delete the Roles.
75
-	$give_roles = array( 'give_manager', 'give_accountant', 'give_worker' );
76
-	foreach ( $give_roles as $role ) {
77
-		remove_role( $role );
75
+	$give_roles = array('give_manager', 'give_accountant', 'give_worker');
76
+	foreach ($give_roles as $role) {
77
+		remove_role($role);
78 78
 	}
79 79
 
80 80
 	// Remove all database tables.
81
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_donors' );
82
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customers' );
83
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customermeta' );
81
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_donors');
82
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customers');
83
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customermeta');
84 84
 
85 85
 	// Cleanup Cron Events.
86
-	wp_clear_scheduled_hook( 'give_daily_scheduled_events' );
87
-	wp_clear_scheduled_hook( 'give_daily_cron' );
88
-	wp_clear_scheduled_hook( 'give_weekly_cron' );
86
+	wp_clear_scheduled_hook('give_daily_scheduled_events');
87
+	wp_clear_scheduled_hook('give_daily_cron');
88
+	wp_clear_scheduled_hook('give_weekly_cron');
89 89
 
90 90
 	// Get all options.
91 91
 	$give_option_names = $wpdb->get_results(
@@ -96,24 +96,24 @@  discard block
 block discarded – undo
96 96
 		ARRAY_A
97 97
 	);
98 98
 
99
-	if ( ! empty( $give_option_names ) ) {
99
+	if ( ! empty($give_option_names)) {
100 100
 		// Convert option name to transient or option name.
101 101
 		$new_give_option_names = array();
102 102
 
103
-		foreach ( $give_option_names as $option ) {
104
-			$new_give_option_names[] = ( false !== strpos( $option['option_name'], '_transient_' ) )
105
-				? str_replace( '_transient_', '', $option['option_name'] )
103
+		foreach ($give_option_names as $option) {
104
+			$new_give_option_names[] = (false !== strpos($option['option_name'], '_transient_'))
105
+				? str_replace('_transient_', '', $option['option_name'])
106 106
 				: $option['option_name'];
107 107
 		}
108 108
 
109 109
 		$give_option_names = $new_give_option_names;
110 110
 
111 111
 		// Delete all the Plugin Options.
112
-		foreach ( $give_option_names as $option ) {
113
-			if ( false !== strpos( $option, '_transient_' ) ) {
114
-				delete_transient( $option );
112
+		foreach ($give_option_names as $option) {
113
+			if (false !== strpos($option, '_transient_')) {
114
+				delete_transient($option);
115 115
 			} else {
116
-				delete_option( $option );
116
+				delete_option($option);
117 117
 			}
118 118
 		}
119 119
 	}
Please login to merge, or discard this patch.
includes/formatting.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
  * @param $field_args
226 226
  * @param $field
227 227
  *
228
- * @return bool
228
+ * @return false|null
229 229
  */
230 230
 function give_format_admin_multilevel_amount( $field_args, $field ) {
231 231
 
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
  * @param   array  $field_args
376 376
  * @param   object $field
377 377
  *
378
- * @return mixed
378
+ * @return string
379 379
  */
380 380
 function give_sanitize_thousand_separator( $value, $field_args, $field ){
381 381
     return stripslashes( $value );
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
  * @param   array  $field_args
409 409
  * @param   object $field
410 410
  *
411
- * @return  mixed
411
+ * @return  string
412 412
  */
413 413
 function give_sanitize_price_field_value( $value, $field_args, $field ){
414 414
     return give_sanitize_amount( $value );
Please login to merge, or discard this patch.
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -258,50 +258,50 @@
 block discarded – undo
258 258
 	$negative = $price < 0;
259 259
 
260 260
 	if ( $negative ) {
261
-        // Remove proceeding "-".
261
+		// Remove proceeding "-".
262 262
 		$price = substr( $price, 1 );
263 263
 	}
264 264
 
265 265
 	$symbol = give_currency_symbol( $currency );
266 266
 
267
-    switch ( $currency ):
268
-        case 'GBP' :
269
-        case 'BRL' :
270
-        case 'EUR' :
271
-        case 'USD' :
272
-        case 'AUD' :
273
-        case 'CAD' :
274
-        case 'HKD' :
275
-        case 'MXN' :
276
-        case 'NZD' :
277
-        case 'SGD' :
278
-        case 'JPY' :
279
-        case 'THB' :
280
-        case 'INR' :
281
-        case 'RIAL' :
282
-        case 'TRY' :
283
-        case 'RUB' :
284
-        case 'SEK' :
285
-        case 'PLN' :
286
-        case 'PHP' :
287
-        case 'TWD' :
288
-        case 'MYR' :
289
-        case 'CZK' :
290
-        case 'DKK' :
291
-        case 'HUF' :
292
-        case 'ILS' :
293
-        case 'MAD' :
294
-        case 'KRW' :
295
-        case 'ZAR' :
296
-            $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol );
297
-            break;
298
-        case 'NOK' :
299
-            $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol );
300
-            break;
301
-        default :
302
-            $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency );
303
-            break;
304
-    endswitch;
267
+	switch ( $currency ):
268
+		case 'GBP' :
269
+		case 'BRL' :
270
+		case 'EUR' :
271
+		case 'USD' :
272
+		case 'AUD' :
273
+		case 'CAD' :
274
+		case 'HKD' :
275
+		case 'MXN' :
276
+		case 'NZD' :
277
+		case 'SGD' :
278
+		case 'JPY' :
279
+		case 'THB' :
280
+		case 'INR' :
281
+		case 'RIAL' :
282
+		case 'TRY' :
283
+		case 'RUB' :
284
+		case 'SEK' :
285
+		case 'PLN' :
286
+		case 'PHP' :
287
+		case 'TWD' :
288
+		case 'MYR' :
289
+		case 'CZK' :
290
+		case 'DKK' :
291
+		case 'HUF' :
292
+		case 'ILS' :
293
+		case 'MAD' :
294
+		case 'KRW' :
295
+		case 'ZAR' :
296
+			$formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol );
297
+			break;
298
+		case 'NOK' :
299
+			$formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol );
300
+			break;
301
+		default :
302
+			$formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency );
303
+			break;
304
+	endswitch;
305 305
 
306 306
 	/**
307 307
 	 * Filter formatted amount with currency
Please login to merge, or discard this patch.
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @return mixed
24 24
  */
25 25
 function give_get_price_decimals() {
26
-	return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) );
26
+	return apply_filters('give_sanitize_amount_decimals', give_get_option('number_decimals', 0));
27 27
 }
28 28
 
29 29
 /**
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  * @return mixed
35 35
  */
36 36
 function give_get_price_thousand_separator() {
37
-	return give_get_option( 'thousands_separator', ',' );
37
+	return give_get_option('thousands_separator', ',');
38 38
 }
39 39
 
40 40
 /**
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
  * @return mixed
46 46
  */
47 47
 function give_get_price_decimal_separator() {
48
-	return give_get_option( 'decimal_separator', '.' );
48
+	return give_get_option('decimal_separator', '.');
49 49
 }
50 50
 
51 51
 /**
@@ -62,67 +62,67 @@  discard block
 block discarded – undo
62 62
  *
63 63
  * @return string $amount Newly sanitized amount
64 64
  */
65
-function give_sanitize_amount( $number, $dp = false, $trim_zeros = false ) {
65
+function give_sanitize_amount($number, $dp = false, $trim_zeros = false) {
66 66
 
67 67
 	// Bailout.
68
-	if ( empty( $number ) ) {
68
+	if (empty($number)) {
69 69
 		return $number;
70 70
 	}
71 71
 
72 72
 	// Remove slash from amount.
73 73
 	// If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number.
74 74
 	// To prevent notices and warning remove slash from amount/number.
75
-	$number = wp_unslash( $number );
75
+	$number = wp_unslash($number);
76 76
 
77 77
 	$thousand_separator = give_get_price_thousand_separator();
78 78
 
79 79
 	$locale   = localeconv();
80
-	$decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] );
80
+	$decimals = array(give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point']);
81 81
 
82 82
 	// Remove locale from string
83
-	if ( ! is_float( $number ) ) {
84
-		$number = str_replace( $decimals, '.', $number );
83
+	if ( ! is_float($number)) {
84
+		$number = str_replace($decimals, '.', $number);
85 85
 	}
86 86
 
87 87
 	// Remove thousand amount formatting if amount has.
88 88
 	// This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db.
89 89
 	// Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code.
90
-	if ( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) {
91
-		$number = str_replace( $thousand_separator, '', $number );
92
-	} elseif ( in_array( $thousand_separator, $decimals ) ) {
93
-		$number = preg_replace( '/\.(?=.*\.)/', '', $number );
90
+	if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) {
91
+		$number = str_replace($thousand_separator, '', $number);
92
+	} elseif (in_array($thousand_separator, $decimals)) {
93
+		$number = preg_replace('/\.(?=.*\.)/', '', $number);
94 94
 	}
95 95
 
96 96
 	// Remove non numeric entity before decimal separator.
97
-	$number     = preg_replace( '/[^0-9\.]/', '', $number );
97
+	$number     = preg_replace('/[^0-9\.]/', '', $number);
98 98
 	$default_dp = give_get_price_decimals();
99 99
 
100 100
 	// Reset negative amount to zero.
101
-	if ( 0 > $number ) {
102
-		$number = number_format( 0, $default_dp, '.' );
101
+	if (0 > $number) {
102
+		$number = number_format(0, $default_dp, '.');
103 103
 	}
104 104
 
105 105
 	// If number does not have decimal then add number of decimals to it.
106 106
 	if (
107
-		false === strpos( $number, '.' )
108
-		|| ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) )
107
+		false === strpos($number, '.')
108
+		|| ($default_dp > strlen(substr($number, strpos($number, '.') + 1)))
109 109
 	) {
110
-		$number = number_format( $number, $default_dp, '.', '' );
110
+		$number = number_format($number, $default_dp, '.', '');
111 111
 	}
112 112
 
113 113
 	// Format number by custom number of decimals.
114
-	if ( false !== $dp ) {
115
-		$dp     = intval( empty( $dp ) ? $default_dp : $dp );
116
-		$dp     = apply_filters( 'give_sanitize_amount_decimals', $dp, $number );
117
-		$number = number_format( floatval( $number ), $dp, '.', '' );
114
+	if (false !== $dp) {
115
+		$dp     = intval(empty($dp) ? $default_dp : $dp);
116
+		$dp     = apply_filters('give_sanitize_amount_decimals', $dp, $number);
117
+		$number = number_format(floatval($number), $dp, '.', '');
118 118
 	}
119 119
 
120 120
 	// Trim zeros.
121
-	if ( $trim_zeros && strstr( $number, '.' ) ) {
122
-		$number = rtrim( rtrim( $number, '0' ), '.' );
121
+	if ($trim_zeros && strstr($number, '.')) {
122
+		$number = rtrim(rtrim($number, '0'), '.');
123 123
 	}
124 124
 
125
-	return apply_filters( 'give_sanitize_amount', $number );
125
+	return apply_filters('give_sanitize_amount', $number);
126 126
 }
127 127
 
128 128
 /**
@@ -135,22 +135,22 @@  discard block
 block discarded – undo
135 135
  *
136 136
  * @return string $amount   Newly formatted amount or Price Not Available
137 137
  */
138
-function give_format_amount( $amount, $decimals = true ) {
139
-	$thousands_sep = give_get_option( 'thousands_separator', ',' );
140
-	$decimal_sep   = give_get_option( 'decimal_separator', '.' );
138
+function give_format_amount($amount, $decimals = true) {
139
+	$thousands_sep = give_get_option('thousands_separator', ',');
140
+	$decimal_sep   = give_get_option('decimal_separator', '.');
141 141
 
142
-	if ( empty( $amount ) ) {
142
+	if (empty($amount)) {
143 143
 		$amount = 0;
144 144
 	} else {
145 145
 		// Sanitize amount before formatting.
146
-		$amount = give_sanitize_amount( $amount );
146
+		$amount = give_sanitize_amount($amount);
147 147
 	}
148 148
 
149 149
 	$decimals = $decimals ? give_get_price_decimals() : 0;
150 150
 
151
-	$formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
151
+	$formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep);
152 152
 
153
-	return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep );
153
+	return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep);
154 154
 }
155 155
 
156 156
 
@@ -167,33 +167,33 @@  discard block
 block discarded – undo
167 167
  *
168 168
  * @return float|string  formatted amount number with large number names.
169 169
  */
170
-function give_human_format_large_amount( $amount ) {
170
+function give_human_format_large_amount($amount) {
171 171
 
172 172
 	// Get thousand separator.
173 173
 	$thousands_sep = give_get_price_thousand_separator();
174 174
 
175 175
 	// Sanitize amount.
176
-	$sanitize_amount = give_sanitize_amount( $amount );
176
+	$sanitize_amount = give_sanitize_amount($amount);
177 177
 
178 178
 	// Explode amount to calculate name of large numbers.
179
-	$amount_array = explode( $thousands_sep, $amount );
179
+	$amount_array = explode($thousands_sep, $amount);
180 180
 
181 181
 	// Calculate amount parts count.
182
-	$amount_count_parts = count( $amount_array );
182
+	$amount_count_parts = count($amount_array);
183 183
 
184 184
 	// Human format amount (default).
185 185
 	$human_format_amount = $amount;
186 186
 
187 187
 	// Calculate large number formatted amount.
188
-	if ( 4 < $amount_count_parts ) {
189
-		$human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) );
190
-	} elseif ( 3 < $amount_count_parts ) {
191
-		$human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) );
192
-	} elseif ( 2 < $amount_count_parts ) {
193
-		$human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) );
188
+	if (4 < $amount_count_parts) {
189
+		$human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2));
190
+	} elseif (3 < $amount_count_parts) {
191
+		$human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2));
192
+	} elseif (2 < $amount_count_parts) {
193
+		$human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2));
194 194
 	}
195 195
 
196
-	return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount );
196
+	return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount);
197 197
 }
198 198
 
199 199
 /**
@@ -206,15 +206,15 @@  discard block
 block discarded – undo
206 206
  *
207 207
  * @return string $amount Newly formatted amount or Price Not Available
208 208
  */
209
-function give_format_decimal( $amount, $dp = false ) {
209
+function give_format_decimal($amount, $dp = false) {
210 210
 	$decimal_separator = give_get_price_decimal_separator();
211
-	$formatted_amount  = give_sanitize_amount( $amount, $dp );
211
+	$formatted_amount  = give_sanitize_amount($amount, $dp);
212 212
 
213
-	if ( false !== strpos( $formatted_amount, '.' ) ) {
214
-		$formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount );
213
+	if (false !== strpos($formatted_amount, '.')) {
214
+		$formatted_amount = str_replace('.', $decimal_separator, $formatted_amount);
215 215
 	}
216 216
 
217
-	return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator );
217
+	return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator);
218 218
 }
219 219
 
220 220
 
@@ -228,13 +228,13 @@  discard block
 block discarded – undo
228 228
  *
229 229
  * @return bool
230 230
  */
231
-function give_format_admin_multilevel_amount( $field_args, $field ) {
231
+function give_format_admin_multilevel_amount($field_args, $field) {
232 232
 
233
-	if ( empty( $field->value ) ) {
233
+	if (empty($field->value)) {
234 234
 		return false;
235 235
 	}
236 236
 
237
-	$field->value = give_format_decimal( $field->value );
237
+	$field->value = give_format_decimal($field->value);
238 238
 }
239 239
 
240 240
 /**
@@ -247,24 +247,24 @@  discard block
 block discarded – undo
247 247
  *
248 248
  * @return mixed|string|void
249 249
  */
250
-function give_currency_filter( $price = '', $currency = '' ) {
250
+function give_currency_filter($price = '', $currency = '') {
251 251
 
252
-	if ( empty( $currency ) ) {
252
+	if (empty($currency)) {
253 253
 		$currency = give_get_currency();
254 254
 	}
255 255
 
256
-	$position = give_get_option( 'currency_position', 'before' );
256
+	$position = give_get_option('currency_position', 'before');
257 257
 
258 258
 	$negative = $price < 0;
259 259
 
260
-	if ( $negative ) {
260
+	if ($negative) {
261 261
         // Remove proceeding "-".
262
-		$price = substr( $price, 1 );
262
+		$price = substr($price, 1);
263 263
 	}
264 264
 
265
-	$symbol = give_currency_symbol( $currency );
265
+	$symbol = give_currency_symbol($currency);
266 266
 
267
-    switch ( $currency ):
267
+    switch ($currency):
268 268
         case 'GBP' :
269 269
         case 'BRL' :
270 270
         case 'EUR' :
@@ -293,13 +293,13 @@  discard block
 block discarded – undo
293 293
         case 'MAD' :
294 294
         case 'KRW' :
295 295
         case 'ZAR' :
296
-            $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol );
296
+            $formatted = ('before' === $position ? $symbol.$price : $price.$symbol);
297 297
             break;
298 298
         case 'NOK' :
299
-            $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol );
299
+            $formatted = ('before' === $position ? $symbol.' '.$price : $price.' '.$symbol);
300 300
             break;
301 301
         default :
302
-            $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency );
302
+            $formatted = ('before' === $position ? $currency.' '.$price : $price.' '.$currency);
303 303
             break;
304 304
     endswitch;
305 305
 
@@ -315,11 +315,11 @@  discard block
 block discarded – undo
315 315
 	 *           filter name will be give_usd_currency_filter_after
316 316
 	 *
317 317
 	 */
318
-	$formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price );
318
+	$formatted = apply_filters('give_'.strtolower($currency)."_currency_filter_{$position}", $formatted, $currency, $price);
319 319
 
320
-	if ( $negative ) {
320
+	if ($negative) {
321 321
 		// Prepend the minus sign before the currency sign.
322
-		$formatted = '-' . $formatted;
322
+		$formatted = '-'.$formatted;
323 323
 	}
324 324
 
325 325
 	return $formatted;
@@ -335,22 +335,22 @@  discard block
 block discarded – undo
335 335
  */
336 336
 function give_currency_decimal_filter() {
337 337
 
338
-	remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
338
+	remove_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
339 339
 
340 340
 	// Set default number of decimals.
341 341
 	$decimals = give_get_price_decimals();
342 342
 
343
-	add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
343
+	add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
344 344
 
345 345
 
346 346
 	// Get number of decimals with backward compatibility ( version < 1.6 )
347
-	if ( 1 <= func_num_args() ) {
348
-		$decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) );
347
+	if (1 <= func_num_args()) {
348
+		$decimals = (false === func_get_arg(0) ? $decimals : absint(func_get_arg(0)));
349 349
 	}
350 350
 
351 351
 	$currency = give_get_currency();
352 352
 
353
-	switch ( $currency ) {
353
+	switch ($currency) {
354 354
 		case 'RIAL' :
355 355
 		case 'JPY' :
356 356
 		case 'TWD' :
@@ -360,11 +360,11 @@  discard block
 block discarded – undo
360 360
 			break;
361 361
 	}
362 362
 
363
-	return apply_filters( 'give_currency_decimal_count', $decimals, $currency );
363
+	return apply_filters('give_currency_decimal_count', $decimals, $currency);
364 364
 }
365 365
 
366
-add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
367
-add_filter( 'give_format_amount_decimals', 'give_currency_decimal_filter' );
366
+add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
367
+add_filter('give_format_amount_decimals', 'give_currency_decimal_filter');
368 368
 
369 369
 /**
370 370
  * Sanitize thousand separator
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
  *
379 379
  * @return mixed
380 380
  */
381
-function give_sanitize_thousand_separator( $value, $field_args, $field ) {
382
-	return stripslashes( $value );
381
+function give_sanitize_thousand_separator($value, $field_args, $field) {
382
+	return stripslashes($value);
383 383
 }
384 384
 
385 385
 
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
  *
396 396
  * @return  mixed
397 397
  */
398
-function give_sanitize_number_decimals( $value, $field_args, $field ) {
399
-	return absint( $value );
398
+function give_sanitize_number_decimals($value, $field_args, $field) {
399
+	return absint($value);
400 400
 }
401 401
 
402 402
 /**
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
  *
412 412
  * @return  mixed
413 413
  */
414
-function give_sanitize_price_field_value( $value, $field_args, $field ) {
415
-	return give_sanitize_amount( $value );
414
+function give_sanitize_price_field_value($value, $field_args, $field) {
415
+	return give_sanitize_amount($value);
416 416
 }
417 417
 
418 418
 
@@ -426,29 +426,29 @@  discard block
 block discarded – undo
426 426
  *
427 427
  * @return void
428 428
  */
429
-function give_cmb_amount_field_render_row_cb( $field_args, $field ) {
429
+function give_cmb_amount_field_render_row_cb($field_args, $field) {
430 430
 
431 431
 	// Get args.
432
-	$id                = $field->args( 'id' );
433
-	$label             = $field->args( 'name' );
434
-	$name              = $field->args( '_name' );
435
-	$description       = $field->args( 'description' );
436
-	$attributes        = $field->args( 'attributes' );
432
+	$id                = $field->args('id');
433
+	$label             = $field->args('name');
434
+	$name              = $field->args('_name');
435
+	$description       = $field->args('description');
436
+	$attributes        = $field->args('attributes');
437 437
 	$attributes_string = '';
438 438
 	$row_class         = $field->row_classes();
439 439
 
440 440
 	// Get attributes.
441
-	if ( ! empty( $attributes ) ) {
442
-		foreach ( $attributes as $attribute_name => $attribute_val ) {
441
+	if ( ! empty($attributes)) {
442
+		foreach ($attributes as $attribute_name => $attribute_val) {
443 443
 			$attributes_string[] = "$attribute_name=\"$attribute_val\"";
444 444
 		}
445 445
 
446
-		$attributes_string = implode( ' ', $attributes_string );
446
+		$attributes_string = implode(' ', $attributes_string);
447 447
 	}
448 448
 
449 449
 	// Get row class.
450
-	if ( ! empty( $row_class ) && is_array( $row_class ) ) {
451
-		$row_class = implode( ' ', $row_class );
450
+	if ( ! empty($row_class) && is_array($row_class)) {
451
+		$row_class = implode(' ', $row_class);
452 452
 	}
453 453
 	?>
454 454
 	<div class="cmb-row <?php echo $row_class; ?>">
@@ -456,9 +456,9 @@  discard block
 block discarded – undo
456 456
 			<label for="<?php echo $id; ?>"><?php echo $label; ?></label>
457 457
 		</div>
458 458
 		<div class="cmb-td">
459
-			<?php echo( give_get_option( 'currency_position' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '' ); ?>
459
+			<?php echo(give_get_option('currency_position') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">'.give_currency_symbol().'</span>' : ''); ?>
460 460
 			<input id="<?php echo $id; ?>" type="text" name="<?php echo $name; ?>" <?php echo $attributes_string ?>/>
461
-			<?php echo( give_get_option( 'currency_position' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '' ); ?>
461
+			<?php echo(give_get_option('currency_position') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">'.give_currency_symbol().'</span>' : ''); ?>
462 462
 
463 463
 			<span class="cmb2-metabox-description"><?php echo $description; ?></span>
464 464
 		</div>
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
  *
478 478
  * @return string                  Date format string
479 479
  */
480
-function give_date_format ( $date_context = '' ) {
480
+function give_date_format($date_context = '') {
481 481
 	/**
482 482
 	 * Filter the date context
483 483
 	 *
@@ -498,20 +498,20 @@  discard block
 block discarded – undo
498 498
 	 *
499 499
 	 *    }
500 500
 	 */
501
-	$date_format_contexts = apply_filters( 'give_date_format_contexts', array() );
501
+	$date_format_contexts = apply_filters('give_date_format_contexts', array());
502 502
 
503 503
 	// Set date format to default date format.
504 504
 	$date_format = get_option('date_format');
505 505
 
506 506
 
507 507
 	// Update date format if we have non empty date format context array and non empty date format string for that context.
508
-	if( $date_context &&  ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) {
509
-		$date_format = ! empty( $date_format_contexts[ $date_context ] )
510
-			? $date_format_contexts[ $date_context ]
508
+	if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) {
509
+		$date_format = ! empty($date_format_contexts[$date_context])
510
+			? $date_format_contexts[$date_context]
511 511
 			: $date_format;
512 512
 	}
513 513
 
514
-	return apply_filters( 'give_date_format', $date_format );
514
+	return apply_filters('give_date_format', $date_format);
515 515
 }
516 516
 
517 517
 /**
@@ -522,10 +522,10 @@  discard block
 block discarded – undo
522 522
  * @param  string|array $var
523 523
  * @return string|array
524 524
  */
525
-function give_clean( $var ) {
526
-	if ( is_array( $var ) ) {
527
-		return array_map( 'give_clean', $var );
525
+function give_clean($var) {
526
+	if (is_array($var)) {
527
+		return array_map('give_clean', $var);
528 528
 	} else {
529
-		return is_scalar( $var ) ? sanitize_text_field( $var ) : $var;
529
+		return is_scalar($var) ? sanitize_text_field($var) : $var;
530 530
 	}
531 531
 }
532 532
\ No newline at end of file
Please login to merge, or discard this patch.
includes/user-functions.php 1 patch
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -30,36 +30,36 @@  discard block
 block discarded – undo
30 30
  *
31 31
  * @return bool|object List of all user donations
32 32
  */
33
-function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) {
33
+function give_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') {
34 34
 
35
-	if ( empty( $user ) ) {
35
+	if (empty($user)) {
36 36
 		$user = get_current_user_id();
37 37
 	}
38 38
 
39
-	if ( 0 === $user && ! Give()->email_access->token_exists ) {
39
+	if (0 === $user && ! Give()->email_access->token_exists) {
40 40
 		return false;
41 41
 	}
42 42
 
43 43
 	$status = $status === 'complete' ? 'publish' : $status;
44 44
 
45
-	if ( $pagination ) {
46
-		if ( get_query_var( 'paged' ) ) {
47
-			$paged = get_query_var( 'paged' );
48
-		} else if ( get_query_var( 'page' ) ) {
49
-			$paged = get_query_var( 'page' );
45
+	if ($pagination) {
46
+		if (get_query_var('paged')) {
47
+			$paged = get_query_var('paged');
48
+		} else if (get_query_var('page')) {
49
+			$paged = get_query_var('page');
50 50
 		} else {
51 51
 			$paged = 1;
52 52
 		}
53 53
 	}
54 54
 
55
-	$args = apply_filters( 'give_get_users_purchases_args', array(
55
+	$args = apply_filters('give_get_users_purchases_args', array(
56 56
 		'user'    => $user,
57 57
 		'number'  => $number,
58 58
 		'status'  => $status,
59 59
 		'orderby' => 'date'
60
-	) );
60
+	));
61 61
 
62
-	if ( $pagination ) {
62
+	if ($pagination) {
63 63
 
64 64
 		$args['page'] = $paged;
65 65
 
@@ -69,20 +69,20 @@  discard block
 block discarded – undo
69 69
 
70 70
 	}
71 71
 
72
-	$by_user_id = is_numeric( $user ) ? true : false;
73
-	$customer   = new Give_Customer( $user, $by_user_id );
72
+	$by_user_id = is_numeric($user) ? true : false;
73
+	$customer   = new Give_Customer($user, $by_user_id);
74 74
 
75
-	if ( ! empty( $customer->payment_ids ) ) {
75
+	if ( ! empty($customer->payment_ids)) {
76 76
 
77
-		unset( $args['user'] );
78
-		$args['post__in'] = array_map( 'absint', explode( ',', $customer->payment_ids ) );
77
+		unset($args['user']);
78
+		$args['post__in'] = array_map('absint', explode(',', $customer->payment_ids));
79 79
 
80 80
 	}
81 81
 
82
-	$purchases = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) );
82
+	$purchases = give_get_payments(apply_filters('give_get_users_donations_args', $args));
83 83
 
84 84
 	// No donations
85
-	if ( ! $purchases ) {
85
+	if ( ! $purchases) {
86 86
 		return false;
87 87
 	}
88 88
 
@@ -101,65 +101,65 @@  discard block
 block discarded – undo
101 101
  *
102 102
  * @return bool|object List of unique forms donated by user
103 103
  */
104
-function give_get_users_completed_donations( $user = 0, $status = 'complete' ) {
105
-	if ( empty( $user ) ) {
104
+function give_get_users_completed_donations($user = 0, $status = 'complete') {
105
+	if (empty($user)) {
106 106
 		$user = get_current_user_id();
107 107
 	}
108 108
 
109
-	if ( empty( $user ) ) {
109
+	if (empty($user)) {
110 110
 		return false;
111 111
 	}
112 112
 
113
-	$by_user_id = is_numeric( $user ) ? true : false;
113
+	$by_user_id = is_numeric($user) ? true : false;
114 114
 
115
-	$customer = new Give_Customer( $user, $by_user_id );
115
+	$customer = new Give_Customer($user, $by_user_id);
116 116
 
117
-	if ( empty( $customer->payment_ids ) ) {
117
+	if (empty($customer->payment_ids)) {
118 118
 		return false;
119 119
 	}
120 120
 
121 121
 	// Get all the items donated
122
-	$payment_ids    = array_reverse( explode( ',', $customer->payment_ids ) );
123
-	$limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 );
124
-	if ( ! empty( $limit_payments ) ) {
125
-		$payment_ids = array_slice( $payment_ids, 0, $limit_payments );
122
+	$payment_ids    = array_reverse(explode(',', $customer->payment_ids));
123
+	$limit_payments = apply_filters('give_users_completed_donations_payments', 50);
124
+	if ( ! empty($limit_payments)) {
125
+		$payment_ids = array_slice($payment_ids, 0, $limit_payments);
126 126
 	}
127 127
 	$donation_data = array();
128
-	foreach ( $payment_ids as $payment_id ) {
129
-		$donation_data[] = give_get_payment_meta( $payment_id );
128
+	foreach ($payment_ids as $payment_id) {
129
+		$donation_data[] = give_get_payment_meta($payment_id);
130 130
 	}
131 131
 
132
-	if ( empty( $donation_data ) ) {
132
+	if (empty($donation_data)) {
133 133
 		return false;
134 134
 	}
135 135
 
136 136
 	// Grab only the post ids "form_id" of the forms donated on this order
137 137
 	$completed_donations_ids = array();
138
-	foreach ( $donation_data as $purchase_meta ) {
138
+	foreach ($donation_data as $purchase_meta) {
139 139
 		$completed_donations_ids[] = isset($purchase_meta['form_id']) ? $purchase_meta['form_id'] : '';
140 140
 	}
141 141
 
142
-	if ( empty( $completed_donations_ids ) ) {
142
+	if (empty($completed_donations_ids)) {
143 143
 		return false;
144 144
 	}
145 145
 
146 146
 	// Only include each donation once
147
-	$form_ids = array_unique( $completed_donations_ids );
147
+	$form_ids = array_unique($completed_donations_ids);
148 148
 
149 149
 	// Make sure we still have some products and a first item
150
-	if ( empty ( $form_ids ) || ! isset( $form_ids[0] ) ) {
150
+	if (empty ($form_ids) || ! isset($form_ids[0])) {
151 151
 		return false;
152 152
 	}
153 153
 
154
-	$post_type = get_post_type( $form_ids[0] );
154
+	$post_type = get_post_type($form_ids[0]);
155 155
 
156
-	$args = apply_filters( 'give_get_users_completed_donations_args', array(
156
+	$args = apply_filters('give_get_users_completed_donations_args', array(
157 157
 		'include'        => $form_ids,
158 158
 		'post_type'      => $post_type,
159
-		'posts_per_page' => - 1
160
-	) );
159
+		'posts_per_page' => -1
160
+	));
161 161
 
162
-	return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) );
162
+	return apply_filters('give_users_completed_donations_list', get_posts($args));
163 163
 }
164 164
 
165 165
 
@@ -175,12 +175,12 @@  discard block
 block discarded – undo
175 175
  *
176 176
  * @return      bool - true if has donated, false other wise.
177 177
  */
178
-function give_has_purchases( $user_id = null ) {
179
-	if ( empty( $user_id ) ) {
178
+function give_has_purchases($user_id = null) {
179
+	if (empty($user_id)) {
180 180
 		$user_id = get_current_user_id();
181 181
 	}
182 182
 
183
-	if ( give_get_users_purchases( $user_id, 1 ) ) {
183
+	if (give_get_users_purchases($user_id, 1)) {
184 184
 		return true; // User has at least one donation
185 185
 	}
186 186
 
@@ -200,27 +200,27 @@  discard block
 block discarded – undo
200 200
  *
201 201
  * @return      array
202 202
  */
203
-function give_get_purchase_stats_by_user( $user = '' ) {
203
+function give_get_purchase_stats_by_user($user = '') {
204 204
 
205
-	if ( is_email( $user ) ) {
205
+	if (is_email($user)) {
206 206
 
207 207
 		$field = 'email';
208 208
 
209
-	} elseif ( is_numeric( $user ) ) {
209
+	} elseif (is_numeric($user)) {
210 210
 
211 211
 		$field = 'user_id';
212 212
 
213 213
 	}
214 214
 
215 215
 	$stats    = array();
216
-	$customer = Give()->customers->get_customer_by( $field, $user );
216
+	$customer = Give()->customers->get_customer_by($field, $user);
217 217
 
218
-	if ( $customer ) {
218
+	if ($customer) {
219 219
 
220
-		$customer = new Give_Customer( $customer->id );
220
+		$customer = new Give_Customer($customer->id);
221 221
 
222
-		$stats['purchases']   = absint( $customer->purchase_count );
223
-		$stats['total_spent'] = give_sanitize_amount( $customer->purchase_value );
222
+		$stats['purchases']   = absint($customer->purchase_count);
223
+		$stats['total_spent'] = give_sanitize_amount($customer->purchase_value);
224 224
 
225 225
 	}
226 226
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	 *
230 230
 	 * @since 1.7
231 231
 	 */
232
-	$stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user );
232
+	$stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user);
233 233
 
234 234
 	return $stats;
235 235
 }
@@ -247,22 +247,22 @@  discard block
 block discarded – undo
247 247
  *
248 248
  * @return      int - the total number of donations
249 249
  */
250
-function give_count_purchases_of_customer( $user = null ) {
250
+function give_count_purchases_of_customer($user = null) {
251 251
 
252 252
 	//Logged in?
253
-	if ( empty( $user ) ) {
253
+	if (empty($user)) {
254 254
 		$user = get_current_user_id();
255 255
 	}
256 256
 
257 257
 	//Email access?
258
-	if ( empty( $user ) && Give()->email_access->token_email ) {
258
+	if (empty($user) && Give()->email_access->token_email) {
259 259
 		$user = Give()->email_access->token_email;
260 260
 	}
261 261
 
262 262
 
263
-	$stats = ! empty( $user ) ? give_get_purchase_stats_by_user( $user ) : false;
263
+	$stats = ! empty($user) ? give_get_purchase_stats_by_user($user) : false;
264 264
 
265
-	return isset( $stats['purchases'] ) ? $stats['purchases'] : 0;
265
+	return isset($stats['purchases']) ? $stats['purchases'] : 0;
266 266
 }
267 267
 
268 268
 /**
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
  *
276 276
  * @return      float - the total amount the user has spent
277 277
  */
278
-function give_purchase_total_of_user( $user = null ) {
278
+function give_purchase_total_of_user($user = null) {
279 279
 
280
-	$stats = give_get_purchase_stats_by_user( $user );
280
+	$stats = give_get_purchase_stats_by_user($user);
281 281
 
282 282
 	return $stats['total_spent'];
283 283
 }
@@ -293,11 +293,11 @@  discard block
 block discarded – undo
293 293
  *
294 294
  * @return      bool
295 295
  */
296
-function give_validate_username( $username ) {
297
-	$sanitized = sanitize_user( $username, false );
298
-	$valid     = ( $sanitized == $username );
296
+function give_validate_username($username) {
297
+	$sanitized = sanitize_user($username, false);
298
+	$valid     = ($sanitized == $username);
299 299
 
300
-	return (bool) apply_filters( 'give_validate_username', $valid, $username );
300
+	return (bool) apply_filters('give_validate_username', $valid, $username);
301 301
 }
302 302
 
303 303
 
@@ -314,32 +314,32 @@  discard block
 block discarded – undo
314 314
  *
315 315
  * @return      void
316 316
  */
317
-function give_add_past_purchases_to_new_user( $user_id ) {
317
+function give_add_past_purchases_to_new_user($user_id) {
318 318
 
319
-	$email = get_the_author_meta( 'user_email', $user_id );
319
+	$email = get_the_author_meta('user_email', $user_id);
320 320
 
321
-	$payments = give_get_payments( array( 's' => $email ) );
321
+	$payments = give_get_payments(array('s' => $email));
322 322
 
323
-	if ( $payments ) {
324
-		foreach ( $payments as $payment ) {
325
-			if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) {
323
+	if ($payments) {
324
+		foreach ($payments as $payment) {
325
+			if (intval(give_get_payment_user_id($payment->ID)) > 0) {
326 326
 				continue;
327 327
 			} // This payment already associated with an account
328 328
 
329
-			$meta                    = give_get_payment_meta( $payment->ID );
330
-			$meta['user_info']       = maybe_unserialize( $meta['user_info'] );
329
+			$meta                    = give_get_payment_meta($payment->ID);
330
+			$meta['user_info']       = maybe_unserialize($meta['user_info']);
331 331
 			$meta['user_info']['id'] = $user_id;
332 332
 			$meta['user_info']       = $meta['user_info'];
333 333
 
334 334
 			// Store the updated user ID in the payment meta
335
-			give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta );
336
-			give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id );
335
+			give_update_payment_meta($payment->ID, '_give_payment_meta', $meta);
336
+			give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id);
337 337
 		}
338 338
 	}
339 339
 
340 340
 }
341 341
 
342
-add_action( 'user_register', 'give_add_past_purchases_to_new_user' );
342
+add_action('user_register', 'give_add_past_purchases_to_new_user');
343 343
 
344 344
 
345 345
 /**
@@ -361,34 +361,34 @@  discard block
 block discarded – undo
361 361
  * @since         1.0
362 362
  * @return        array - The donor's address, if any
363 363
  */
364
-function give_get_donor_address( $user_id = 0 ) {
365
-	if ( empty( $user_id ) ) {
364
+function give_get_donor_address($user_id = 0) {
365
+	if (empty($user_id)) {
366 366
 		$user_id = get_current_user_id();
367 367
 	}
368 368
 
369
-	$address = get_user_meta( $user_id, '_give_user_address', true );
369
+	$address = get_user_meta($user_id, '_give_user_address', true);
370 370
 
371
-	if ( ! isset( $address['line1'] ) ) {
371
+	if ( ! isset($address['line1'])) {
372 372
 		$address['line1'] = '';
373 373
 	}
374 374
 
375
-	if ( ! isset( $address['line2'] ) ) {
375
+	if ( ! isset($address['line2'])) {
376 376
 		$address['line2'] = '';
377 377
 	}
378 378
 
379
-	if ( ! isset( $address['city'] ) ) {
379
+	if ( ! isset($address['city'])) {
380 380
 		$address['city'] = '';
381 381
 	}
382 382
 
383
-	if ( ! isset( $address['zip'] ) ) {
383
+	if ( ! isset($address['zip'])) {
384 384
 		$address['zip'] = '';
385 385
 	}
386 386
 
387
-	if ( ! isset( $address['country'] ) ) {
387
+	if ( ! isset($address['country'])) {
388 388
 		$address['country'] = '';
389 389
 	}
390 390
 
391
-	if ( ! isset( $address['state'] ) ) {
391
+	if ( ! isset($address['state'])) {
392 392
 		$address['state'] = '';
393 393
 	}
394 394
 
@@ -408,42 +408,42 @@  discard block
 block discarded – undo
408 408
  *
409 409
  * @return        void
410 410
  */
411
-function give_new_user_notification( $user_id = 0, $user_data = array() ) {
411
+function give_new_user_notification($user_id = 0, $user_data = array()) {
412 412
 
413
-	if ( empty( $user_id ) || empty( $user_data ) ) {
413
+	if (empty($user_id) || empty($user_data)) {
414 414
 		return;
415 415
 	}
416
-	$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
416
+	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
417 417
 
418 418
 	/* translators: %s: site name */
419
-	$message  = sprintf( esc_attr__( 'New user registration on your site %s:', 'give' ), $blogname ) . "\r\n\r\n";
419
+	$message  = sprintf(esc_attr__('New user registration on your site %s:', 'give'), $blogname)."\r\n\r\n";
420 420
 	/* translators: %s: user login */
421
-	$message .= sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n\r\n";
421
+	$message .= sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n\r\n";
422 422
 	/* translators: %s: user email */
423
-	$message .= sprintf( esc_attr__( 'E-mail: %s', 'give' ), $user_data['user_email'] ) . "\r\n";
423
+	$message .= sprintf(esc_attr__('E-mail: %s', 'give'), $user_data['user_email'])."\r\n";
424 424
 
425 425
 	@wp_mail(
426
-		get_option( 'admin_email' ),
426
+		get_option('admin_email'),
427 427
 		sprintf(
428 428
 			/* translators: %s: site name */
429
-			esc_attr__( '[%s] New User Registration', 'give' ),
429
+			esc_attr__('[%s] New User Registration', 'give'),
430 430
 			$blogname
431 431
 		),
432 432
 		$message
433 433
 	);
434 434
 
435 435
 	/* translators: %s: user login */
436
-	$message  = sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n";
436
+	$message  = sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n";
437 437
 	/* translators: %s: paswword */
438
-	$message .= sprintf( esc_attr__( 'Password: %s', 'give' ), esc_attr__( '[Password entered during donation]', 'give' ) ) . "\r\n";
438
+	$message .= sprintf(esc_attr__('Password: %s', 'give'), esc_attr__('[Password entered during donation]', 'give'))."\r\n";
439 439
 
440
-	$message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Login &raquo;', 'give' ) . '</a>' . "\r\n";
440
+	$message .= '<a href="'.wp_login_url().'"> '.esc_attr__('Click Here to Login &raquo;', 'give').'</a>'."\r\n";
441 441
 
442 442
 	wp_mail(
443 443
 		$user_data['user_email'],
444 444
 		sprintf(
445 445
 			/* translators: %s: site name */
446
-			esc_attr__( '[%s] Your username and password', 'give' ),
446
+			esc_attr__('[%s] Your username and password', 'give'),
447 447
 			$blogname
448 448
 		),
449 449
 		$message
@@ -451,4 +451,4 @@  discard block
 block discarded – undo
451 451
 
452 452
 }
453 453
 
454
-add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 );
454
+add_action('give_insert_user', 'give_new_user_notification', 10, 2);
Please login to merge, or discard this patch.
includes/class-give-license-handler.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -689,7 +689,7 @@
 block discarded – undo
689 689
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
690 690
 								esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) )
691 691
 							);
692
-						}else{
692
+						} else{
693 693
 							$messages[$subscription['id']] = sprintf(
694 694
 								__( 'You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ),
695 695
 								human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ),
Please login to merge, or discard this patch.
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 		 * @access private
220 220
 		 * @since  1.0
221 221
 		 *
222
-		 * @return bool
222
+		 * @return false|null
223 223
 		 */
224 224
 		public function auto_updater() {
225 225
 
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 		 * @access public
476 476
 		 * @since  1.7
477 477
 		 *
478
-		 * @return bool|void
478
+		 * @return false|null
479 479
 		 */
480 480
 		public function weekly_license_check() {
481 481
 
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 		 * @access public
528 528
 		 * @since  1.7
529 529
 		 *
530
-		 * @return bool|void
530
+		 * @return false|null
531 531
 		 */
532 532
 		public function weekly_subscription_check() {
533 533
 
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 		 * @access private
608 608
 		 * @since  1.7
609 609
 		 *
610
-		 * @return bool|void
610
+		 * @return false|null
611 611
 		 */
612 612
 		private function __single_subscription_check() {
613 613
 			// Do not fire if license key is not set.
@@ -802,7 +802,7 @@  discard block
 block discarded – undo
802 802
 		 * @access private
803 803
 		 * @since  1.7
804 804
 		 *
805
-		 * @return void|bool
805
+		 * @return false|null
806 806
 		 */
807 807
 		private function __remove_license_key_from_subscriptions(){
808 808
 			$subscriptions = get_option( 'give_subscriptions', array() );
Please login to merge, or discard this patch.
Spacing   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17
-if ( ! class_exists( 'Give_License' ) ) :
17
+if ( ! class_exists('Give_License')) :
18 18
 
19 19
 	/**
20 20
 	 * Give_License Class
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 		 *
104 104
 		 * @var    string
105 105
 		 */
106
-		private $api_url      = 'https://givewp.com/edd-sl-api/';
106
+		private $api_url = 'https://givewp.com/edd-sl-api/';
107 107
 
108 108
 		/**
109 109
 		 * Account URL
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		 *
114 114
 		 * @var null|string
115 115
 		 */
116
-		private $account_url  = 'https://givewp.com/my-account/';
116
+		private $account_url = 'https://givewp.com/my-account/';
117 117
 
118 118
 		/**
119 119
 		 * Ccheckout URL
@@ -142,19 +142,19 @@  discard block
 block discarded – undo
142 142
 		 * @param string  $_checkout_url
143 143
 		 * @param string  $_account_url
144 144
 		 */
145
-		public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) {
145
+		public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) {
146 146
 			$give_options = give_get_settings();
147 147
 
148 148
 			$this->file           = $_file;
149 149
 			$this->item_name      = $_item_name;
150
-			$this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) );
150
+			$this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name)));
151 151
 			$this->version        = $_version;
152
-			$this->license        = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : '';
153
-			$this->license_data   = get_option( $this->item_shortname . '_license_active' );
152
+			$this->license        = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : '';
153
+			$this->license_data   = get_option($this->item_shortname.'_license_active');
154 154
 			$this->author         = $_author;
155
-			$this->api_url        = is_null( $_api_url ) ? $this->api_url : $_api_url;
156
-			$this->checkout_url   = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url;
157
-			$this->account_url    = is_null( $_account_url ) ? $this->account_url : $_account_url;
155
+			$this->api_url        = is_null($_api_url) ? $this->api_url : $_api_url;
156
+			$this->checkout_url   = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url;
157
+			$this->account_url    = is_null($_account_url) ? $this->account_url : $_account_url;
158 158
 
159 159
 			// Setup hooks
160 160
 			$this->includes();
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 		 * @return void
174 174
 		 */
175 175
 		private function includes() {
176
-			if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
176
+			if ( ! class_exists('EDD_SL_Plugin_Updater')) {
177 177
 				require_once 'admin/EDD_SL_Plugin_Updater.php';
178 178
 			}
179 179
 		}
@@ -191,26 +191,26 @@  discard block
 block discarded – undo
191 191
 		private function hooks() {
192 192
 
193 193
 			// Register settings
194
-			add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 );
194
+			add_filter('give_settings_licenses', array($this, 'settings'), 1);
195 195
 
196 196
 			// Activate license key on settings save
197
-			add_action( 'admin_init', array( $this, 'activate_license' ) );
197
+			add_action('admin_init', array($this, 'activate_license'));
198 198
 
199 199
 			// Deactivate license key
200
-			add_action( 'admin_init', array( $this, 'deactivate_license' ) );
200
+			add_action('admin_init', array($this, 'deactivate_license'));
201 201
 
202 202
 			// Updater
203
-			add_action( 'admin_init', array( $this, 'auto_updater' ), 0 );
203
+			add_action('admin_init', array($this, 'auto_updater'), 0);
204 204
 
205
-			add_action( 'admin_notices', array( $this, 'notices' ) );
205
+			add_action('admin_notices', array($this, 'notices'));
206 206
 
207 207
 			// Check license weekly.
208
-			add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_license_check' ) );
209
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_license_check' ) );
208
+			add_action('give_weekly_scheduled_events', array($this, 'weekly_license_check'));
209
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_license_check'));
210 210
 
211 211
 			// Check subscription weekly.
212
-			add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_subscription_check' ) );
213
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_subscription_check' ) );
212
+			add_action('give_weekly_scheduled_events', array($this, 'weekly_subscription_check'));
213
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_subscription_check'));
214 214
 		}
215 215
 
216 216
 		/**
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 		 */
224 224
 		public function auto_updater() {
225 225
 
226
-			if ( ! $this->is_valid_license() ) {
226
+			if ( ! $this->is_valid_license()) {
227 227
 				return false;
228 228
 			}
229 229
 
@@ -252,16 +252,16 @@  discard block
 block discarded – undo
252 252
 		 *
253 253
 		 * @return array           License settings.
254 254
 		 */
255
-		public function settings( $settings ) {
255
+		public function settings($settings) {
256 256
 
257 257
 			$give_license_settings = array(
258 258
 				array(
259 259
 					'name'    => $this->item_name,
260
-					'id'      => $this->item_shortname . '_license_key',
260
+					'id'      => $this->item_shortname.'_license_key',
261 261
 					'desc'    => '',
262 262
 					'type'    => 'license_key',
263 263
 					'options' => array(
264
-						'license'       => get_option( $this->item_shortname . '_license_active' ),
264
+						'license'       => get_option($this->item_shortname.'_license_active'),
265 265
 						'shortname'     => $this->item_shortname,
266 266
 						'item_name'     => $this->item_name,
267 267
 						'api_url'       => $this->api_url,
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 				)
273 273
 			);
274 274
 
275
-			return array_merge( $settings, $give_license_settings );
275
+			return array_merge($settings, $give_license_settings);
276 276
 		}
277 277
 
278 278
 		/**
@@ -287,18 +287,18 @@  discard block
 block discarded – undo
287 287
 		 *
288 288
 		 * @return array           License settings content.
289 289
 		 */
290
-		public function license_settings_content( $settings ) {
290
+		public function license_settings_content($settings) {
291 291
 
292 292
 			$give_license_settings = array(
293 293
 				array(
294
-					'name' => esc_html__( 'Add-on Licenses', 'give' ),
294
+					'name' => esc_html__('Add-on Licenses', 'give'),
295 295
 					'desc' => '<hr>',
296 296
 					'type' => 'give_title',
297 297
 					'id'   => 'give_title'
298 298
 				),
299 299
 			);
300 300
 
301
-			return array_merge( $settings, $give_license_settings );
301
+			return array_merge($settings, $give_license_settings);
302 302
 		}
303 303
 
304 304
 		/**
@@ -313,37 +313,37 @@  discard block
 block discarded – undo
313 313
 		 */
314 314
 		public function activate_license() {
315 315
 			// Bailout: Check if license key set of not.
316
-			if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
316
+			if ( ! isset($_POST[$this->item_shortname.'_license_key'])) {
317 317
 				return;
318 318
 			}
319 319
 
320 320
 			// Security check.
321
-			if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) {
321
+			if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) {
322 322
 
323
-				wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
323
+				wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
324 324
 
325 325
 			}
326 326
 
327 327
 			// Check if user have correct permissions.
328
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
328
+			if ( ! current_user_can('manage_give_settings')) {
329 329
 				return;
330 330
 			}
331 331
 
332 332
 			// Allow third party addon developers to handle license activation.
333
-			if( $this->__is_third_party_addon() ){
334
-				do_action( 'give_activate_license', $this );
333
+			if ($this->__is_third_party_addon()) {
334
+				do_action('give_activate_license', $this);
335 335
 				return;
336 336
 			}
337 337
 
338 338
 			// Delete previous license setting if a empty license key submitted.
339
-			if ( empty( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
340
-				delete_option( $this->item_shortname . '_license_active' );
339
+			if (empty($_POST[$this->item_shortname.'_license_key'])) {
340
+				delete_option($this->item_shortname.'_license_active');
341 341
 				return;
342 342
 			}
343 343
 
344 344
 			// Do not simultaneously activate any addon if user want to deactivate any addon.
345
-			foreach ( $_POST as $key => $value ) {
346
-				if ( false !== strpos( $key, 'license_key_deactivate' ) ) {
345
+			foreach ($_POST as $key => $value) {
346
+				if (false !== strpos($key, 'license_key_deactivate')) {
347 347
 					// Don't activate a key when deactivating a different key
348 348
 					return;
349 349
 				}
@@ -351,15 +351,15 @@  discard block
 block discarded – undo
351 351
 
352 352
 
353 353
 			// Check if plugin previously installed.
354
-			if ( $this->is_valid_license() ) {
354
+			if ($this->is_valid_license()) {
355 355
 				return;
356 356
 			}
357 357
 
358 358
 			// Get license key.
359
-			$license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] );
359
+			$license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']);
360 360
 
361 361
 			// Bailout.
362
-			if( empty( $license ) ) {
362
+			if (empty($license)) {
363 363
 				return;
364 364
 			}
365 365
 
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 			$api_params = array(
371 371
 				'edd_action' => 'activate_license', //never change from "edd_" to "give_"!
372 372
 				'license'    => $license,
373
-				'item_name'  => urlencode( $this->item_name ),
373
+				'item_name'  => urlencode($this->item_name),
374 374
 				'url'        => home_url()
375 375
 			);
376 376
 
@@ -385,16 +385,16 @@  discard block
 block discarded – undo
385 385
 			);
386 386
 
387 387
 			// Make sure there are no errors
388
-			if ( is_wp_error( $response ) ) {
388
+			if (is_wp_error($response)) {
389 389
 				return;
390 390
 			}
391 391
 
392 392
 			// Tell WordPress to look for updates
393
-			set_site_transient( 'update_plugins', null );
393
+			set_site_transient('update_plugins', null);
394 394
 
395 395
 			// Decode license data
396
-			$license_data = json_decode( wp_remote_retrieve_body( $response ) );
397
-			update_option( $this->item_shortname . '_license_active', $license_data );
396
+			$license_data = json_decode(wp_remote_retrieve_body($response));
397
+			update_option($this->item_shortname.'_license_active', $license_data);
398 398
 
399 399
 			// Check subscription for license key and store this to db (if any).
400 400
 			$this->__single_subscription_check();
@@ -412,34 +412,34 @@  discard block
 block discarded – undo
412 412
 		 */
413 413
 		public function deactivate_license() {
414 414
 
415
-			if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
415
+			if ( ! isset($_POST[$this->item_shortname.'_license_key'])) {
416 416
 				return;
417 417
 			}
418 418
 
419
-			if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) {
419
+			if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) {
420 420
 
421
-				wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
421
+				wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
422 422
 
423 423
 			}
424 424
 
425
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
425
+			if ( ! current_user_can('manage_give_settings')) {
426 426
 				return;
427 427
 			}
428 428
 
429 429
 			// Allow third party addon developers to handle license deactivation.
430
-			if( $this->__is_third_party_addon() ){
431
-				do_action( 'give_deactivate_license', $this );
430
+			if ($this->__is_third_party_addon()) {
431
+				do_action('give_deactivate_license', $this);
432 432
 				return;
433 433
 			}
434 434
 
435 435
 			// Run on deactivate button press
436
-			if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) {
436
+			if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) {
437 437
 
438 438
 				// Data to send to the API
439 439
 				$api_params = array(
440 440
 					'edd_action' => 'deactivate_license', //never change from "edd_" to "give_"!
441 441
 					'license'    => $this->license,
442
-					'item_name'  => urlencode( $this->item_name ),
442
+					'item_name'  => urlencode($this->item_name),
443 443
 					'url'        => home_url()
444 444
 				);
445 445
 
@@ -454,15 +454,15 @@  discard block
 block discarded – undo
454 454
 				);
455 455
 
456 456
 				// Make sure there are no errors
457
-				if ( is_wp_error( $response ) ) {
457
+				if (is_wp_error($response)) {
458 458
 					return;
459 459
 				}
460 460
 
461 461
 				// Decode the license data
462
-				$license_data = json_decode( wp_remote_retrieve_body( $response ) );
462
+				$license_data = json_decode(wp_remote_retrieve_body($response));
463 463
 
464 464
 				// Remove license data.
465
-				delete_option( $this->item_shortname . '_license_active' );
465
+				delete_option($this->item_shortname.'_license_active');
466 466
 
467 467
 				// Remove license key from subscriptions if exist.
468 468
 				$this->__remove_license_key_from_subscriptions();
@@ -479,18 +479,18 @@  discard block
 block discarded – undo
479 479
 		 */
480 480
 		public function weekly_license_check() {
481 481
 
482
-			if( ! empty( $_POST['give_settings'] ) ) {
482
+			if ( ! empty($_POST['give_settings'])) {
483 483
 				// Don't fire when saving settings
484 484
 				return false;
485 485
 			}
486 486
 
487
-			if( empty( $this->license ) ) {
487
+			if (empty($this->license)) {
488 488
 				return false;
489 489
 			}
490 490
 
491 491
 			// Allow third party addon developers to handle their license check.
492
-			if( $this->__is_third_party_addon() ){
493
-				do_action( 'give_weekly_license_check', $this );
492
+			if ($this->__is_third_party_addon()) {
493
+				do_action('give_weekly_license_check', $this);
494 494
 				return false;
495 495
 			}
496 496
 
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 			$api_params = array(
499 499
 				'edd_action'=> 'check_license',
500 500
 				'license' 	=> $this->license,
501
-				'item_name' => urlencode( $this->item_name ),
501
+				'item_name' => urlencode($this->item_name),
502 502
 				'url'       => home_url()
503 503
 			);
504 504
 
@@ -513,12 +513,12 @@  discard block
 block discarded – undo
513 513
 			);
514 514
 
515 515
 			// Make sure the response came back okay.
516
-			if ( is_wp_error( $response ) ) {
516
+			if (is_wp_error($response)) {
517 517
 				return false;
518 518
 			}
519 519
 
520
-			$license_data = json_decode( wp_remote_retrieve_body( $response ) );
521
-			update_option( $this->item_shortname . '_license_active', $license_data );
520
+			$license_data = json_decode(wp_remote_retrieve_body($response));
521
+			update_option($this->item_shortname.'_license_active', $license_data);
522 522
 		}
523 523
 
524 524
 		/**
@@ -531,24 +531,24 @@  discard block
 block discarded – undo
531 531
 		 */
532 532
 		public function weekly_subscription_check() {
533 533
 
534
-			if( ! empty( $_POST['give_settings'] ) ) {
534
+			if ( ! empty($_POST['give_settings'])) {
535 535
 				// Don't fire when saving settings
536 536
 				return false;
537 537
 			}
538 538
 
539 539
 			// Remove old subscription data.
540
-			if( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp' , 1 ) ){
541
-				delete_option( 'give_subscriptions' );
542
-				update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp' , 1 ) ) );
540
+			if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) {
541
+				delete_option('give_subscriptions');
542
+				update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1)));
543 543
 			}
544 544
 
545
-			if( empty( $this->license ) ) {
545
+			if (empty($this->license)) {
546 546
 				return false;
547 547
 			}
548 548
 
549 549
 			// Allow third party addon developers to handle there subscription check.
550
-			if( $this->__is_third_party_addon() ){
551
-				do_action( 'give_weekly_subscription_check', $this );
550
+			if ($this->__is_third_party_addon()) {
551
+				do_action('give_weekly_subscription_check', $this);
552 552
 				return false;
553 553
 			}
554 554
 
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 				// This is custom feature to check subscriptions.
563 563
 				'edd_action'=> 'check_subscription',
564 564
 				'license' 	=> $this->license,
565
-				'item_name' => urlencode( $this->item_name ),
565
+				'item_name' => urlencode($this->item_name),
566 566
 				'url'       => home_url()
567 567
 			);
568 568
 
@@ -577,27 +577,27 @@  discard block
 block discarded – undo
577 577
 			);
578 578
 
579 579
 			// Make sure the response came back okay.
580
-			if ( is_wp_error( $response ) ) {
580
+			if (is_wp_error($response)) {
581 581
 				return false;
582 582
 			}
583 583
 
584
-			$subscription_data = json_decode( wp_remote_retrieve_body( $response ), true );
584
+			$subscription_data = json_decode(wp_remote_retrieve_body($response), true);
585 585
 
586
-			if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) {
587
-				$subscriptions = get_option( 'give_subscriptions', array() );
586
+			if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) {
587
+				$subscriptions = get_option('give_subscriptions', array());
588 588
 
589 589
 				// Update subscription data only if subscription does not exist already.
590
-				if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) {
591
-					$subscriptions[ $subscription_data['id'] ] = $subscription_data;
592
-					$subscriptions[ $subscription_data['id'] ]['licenses'] = array();
590
+				if ( ! array_key_exists($subscription_data['id'], $subscriptions)) {
591
+					$subscriptions[$subscription_data['id']] = $subscription_data;
592
+					$subscriptions[$subscription_data['id']]['licenses'] = array();
593 593
 				}
594 594
 
595 595
 				// Store licenses for subscription.
596
-				if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
597
-					$subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license;
596
+				if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) {
597
+					$subscriptions[$subscription_data['id']]['licenses'][] = $this->license;
598 598
 				}
599 599
 
600
-				update_option( 'give_subscriptions', $subscriptions );
600
+				update_option('give_subscriptions', $subscriptions);
601 601
 			}
602 602
 		}
603 603
 
@@ -611,11 +611,11 @@  discard block
 block discarded – undo
611 611
 		 */
612 612
 		private function __single_subscription_check() {
613 613
 			// Do not fire if license key is not set.
614
-			if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
614
+			if ( ! isset($_POST[$this->item_shortname.'_license_key'])) {
615 615
 				return false;
616 616
 			}
617 617
 
618
-			if( empty( $this->license ) ) {
618
+			if (empty($this->license)) {
619 619
 				return false;
620 620
 			}
621 621
 
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 				// This is custom feature to check subscriptions.
627 627
 				'edd_action'=> 'check_subscription',
628 628
 				'license' 	=> $this->license,
629
-				'item_name' => urlencode( $this->item_name ),
629
+				'item_name' => urlencode($this->item_name),
630 630
 				'url'       => home_url()
631 631
 			);
632 632
 
@@ -641,27 +641,27 @@  discard block
 block discarded – undo
641 641
 			);
642 642
 
643 643
 			// Make sure the response came back okay.
644
-			if ( is_wp_error( $response ) ) {
644
+			if (is_wp_error($response)) {
645 645
 				return false;
646 646
 			}
647 647
 
648
-			$subscription_data = json_decode( wp_remote_retrieve_body( $response ), true );
648
+			$subscription_data = json_decode(wp_remote_retrieve_body($response), true);
649 649
 
650
-			if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) {
651
-				$subscriptions = get_option( 'give_subscriptions', array() );
650
+			if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) {
651
+				$subscriptions = get_option('give_subscriptions', array());
652 652
 
653 653
 				// Update subscription data only if subscription does not exist already.
654
-				if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) {
655
-					$subscriptions[ $subscription_data['id'] ] = $subscription_data;
656
-					$subscriptions[ $subscription_data['id'] ]['licenses'] = array();
654
+				if ( ! array_key_exists($subscription_data['id'], $subscriptions)) {
655
+					$subscriptions[$subscription_data['id']] = $subscription_data;
656
+					$subscriptions[$subscription_data['id']]['licenses'] = array();
657 657
 				}
658 658
 
659 659
 				// Store licenses for subscription.
660
-				if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
661
-					$subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license;
660
+				if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) {
661
+					$subscriptions[$subscription_data['id']]['licenses'][] = $this->license;
662 662
 				}
663 663
 
664
-				update_option( 'give_subscriptions', $subscriptions );
664
+				update_option('give_subscriptions', $subscriptions);
665 665
 			}
666 666
 		}
667 667
 
@@ -679,87 +679,87 @@  discard block
 block discarded – undo
679 679
 			static $addon_license_key_in_subscriptions;
680 680
 
681 681
 			// Set default value.
682
-			$addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array();
682
+			$addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array();
683 683
 
684
-			if( empty( $this->license ) ) {
684
+			if (empty($this->license)) {
685 685
 				return;
686 686
 			}
687 687
 
688
-			if( ! current_user_can( 'manage_shop_settings' ) ) {
688
+			if ( ! current_user_can('manage_shop_settings')) {
689 689
 				return;
690 690
 			}
691 691
 
692 692
 			// Do not show licenses notices on license tab.
693
-			if( ! empty( $_GET['tab'] ) && 'licenses' === $_GET['tab'] ) {
693
+			if ( ! empty($_GET['tab']) && 'licenses' === $_GET['tab']) {
694 694
 				return;
695 695
 			}
696 696
 
697 697
 			$messages = array();
698 698
 
699 699
 			// Get subscriptions.
700
-			$subscriptions = get_option( 'give_subscriptions' );
700
+			$subscriptions = get_option('give_subscriptions');
701 701
 
702 702
 			// Show subscription messages.
703
-			if( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) {
703
+			if ( ! empty($subscriptions) && ! $showed_subscriptions_message) {
704 704
 
705
-				foreach ( $subscriptions as $subscription ) {
705
+				foreach ($subscriptions as $subscription) {
706 706
 					// Subscription expires timestamp.
707
-					$subscription_expires = strtotime( $subscription['expires'] );
707
+					$subscription_expires = strtotime($subscription['expires']);
708 708
 
709 709
 					// Start showing subscriptions message before one week of renewal date.
710
-					if( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) {
710
+					if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) {
711 711
 						continue;
712 712
 					}
713 713
 
714 714
 					// Check if subscription message already exist in messages.
715
-					if( array_key_exists( $subscription['id'], $messages ) ) {
715
+					if (array_key_exists($subscription['id'], $messages)) {
716 716
 						continue;
717 717
 					}
718 718
 
719
-					if( ( ! $this->__is_notice_dismissed( $subscription['id'] ) && 'active' !== $subscription['status'] ) ) {
719
+					if (( ! $this->__is_notice_dismissed($subscription['id']) && 'active' !== $subscription['status'])) {
720 720
 
721
-						if( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {// Check if license already expired.
721
+						if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {// Check if license already expired.
722 722
 							$messages[$subscription['id']] = sprintf(
723
-								__( 'You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ),
724
-								urldecode( $subscription['invoice_url'] ),
723
+								__('You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'),
724
+								urldecode($subscription['invoice_url']),
725 725
 								$subscription['payment_id'],
726 726
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
727
-								esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) )
727
+								esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI']))
728 728
 							);
729
-						}else{
729
+						} else {
730 730
 							$messages[$subscription['id']] = sprintf(
731
-								__( 'You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ),
732
-								human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ),
733
-								urldecode( $subscription['invoice_url'] ),
731
+								__('You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'),
732
+								human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])),
733
+								urldecode($subscription['invoice_url']),
734 734
 								$subscription['payment_id'],
735 735
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
736
-								esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) )
736
+								esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI']))
737 737
 							);
738 738
 						}
739 739
 					}
740 740
 
741 741
 					// Stop validation for these licencse keys.
742
-					$addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] );
742
+					$addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']);
743 743
 				}
744 744
 				$showed_subscriptions_message = true;
745 745
 			}
746 746
 
747 747
 			// Show non subscription addon messages.
748
-			if( ! in_array( $this->license, $addon_license_key_in_subscriptions ) && ! $this->__is_notice_dismissed( 'general' ) && ! $this->is_valid_license() && empty( $showed_invalid_message ) ) {
748
+			if ( ! in_array($this->license, $addon_license_key_in_subscriptions) && ! $this->__is_notice_dismissed('general') && ! $this->is_valid_license() && empty($showed_invalid_message)) {
749 749
 
750 750
 				$messages['general'] = sprintf(
751
-					__( 'You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ),
752
-					admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
751
+					__('You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'),
752
+					admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
753 753
 				);
754 754
 				$showed_invalid_message = true;
755 755
 
756 756
 			}
757 757
 
758 758
 			// Print messages.
759
-			if( ! empty( $messages ) ) {
760
-				foreach( $messages as $notice_id => $message ) {
761
-					echo '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="' . esc_url( add_query_arg( '_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'] ) ) . '">';
762
-					echo '<p>' . $message . '</p>';
759
+			if ( ! empty($messages)) {
760
+				foreach ($messages as $notice_id => $message) {
761
+					echo '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="'.esc_url(add_query_arg('_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'])).'">';
762
+					echo '<p>'.$message.'</p>';
763 763
 					echo '</div>';
764 764
 				}
765 765
 			}
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 		 * @return bool
775 775
 		 */
776 776
 		public function is_valid_license() {
777
-			if( apply_filters( 'give_is_valid_license' , ( is_object( $this->license_data ) && ! empty( $this->license_data ) &&  property_exists( $this->license_data, 'license' )&& 'valid' === $this->license_data->license ) ) ) {
777
+			if (apply_filters('give_is_valid_license', (is_object($this->license_data) && ! empty($this->license_data) && property_exists($this->license_data, 'license') && 'valid' === $this->license_data->license))) {
778 778
 				return true;
779 779
 			}
780 780
 
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 		 * @return bool
791 791
 		 */
792 792
 		private function __is_third_party_addon() {
793
-			return ( false === strpos( $this->api_url, 'givewp.com/' ) );
793
+			return (false === strpos($this->api_url, 'givewp.com/'));
794 794
 		}
795 795
 
796 796
 		/**
@@ -804,26 +804,26 @@  discard block
 block discarded – undo
804 804
 		 *
805 805
 		 * @return void|bool
806 806
 		 */
807
-		private function __remove_license_key_from_subscriptions(){
808
-			$subscriptions = get_option( 'give_subscriptions', array() );
807
+		private function __remove_license_key_from_subscriptions() {
808
+			$subscriptions = get_option('give_subscriptions', array());
809 809
 
810 810
 			// Bailout.
811
-			if( empty( $this->license ) ) {
811
+			if (empty($this->license)) {
812 812
 				return false;
813 813
 			}
814 814
 
815
-			if( ! empty( $subscriptions ) ) {
816
-				foreach ( $subscriptions as $subscription_id => $subscription ) {
817
-					$license_index = array_search( $this->license, $subscription['licenses'] );
818
-					if( false !== $license_index ) {
815
+			if ( ! empty($subscriptions)) {
816
+				foreach ($subscriptions as $subscription_id => $subscription) {
817
+					$license_index = array_search($this->license, $subscription['licenses']);
818
+					if (false !== $license_index) {
819 819
 						// Remove license key.
820
-						unset( $subscriptions[ $subscription_id ]['licenses'][$license_index] );
820
+						unset($subscriptions[$subscription_id]['licenses'][$license_index]);
821 821
 
822 822
 						// Rearrange license keys.
823
-						$subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] );
823
+						$subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']);
824 824
 
825 825
 						// Update subscription information.
826
-						update_option( 'give_subscriptions', $subscriptions );
826
+						update_option('give_subscriptions', $subscriptions);
827 827
 						break;
828 828
 					}
829 829
 				}
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 		 *
839 839
 		 * @return void
840 840
 		 */
841
-		private function __remove_license_notices_show_blocker(){
841
+		private function __remove_license_notices_show_blocker() {
842 842
 			global $wpdb;
843 843
 
844 844
 			// Delete permanent notice blocker.
@@ -876,18 +876,18 @@  discard block
 block discarded – undo
876 876
 		 *
877 877
 		 * @return bool
878 878
 		 */
879
-		private function __is_notice_dismissed( $notice_id ){
879
+		private function __is_notice_dismissed($notice_id) {
880 880
 			$current_user = wp_get_current_user();
881 881
 			$is_notice_dismissed = false;
882 882
 
883 883
 			// Ge is notice dismissed permanently.
884
-			$already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) )
884
+			$already_dismiss_notices = ($already_dismiss_notices = get_user_meta($current_user->ID, '_give_hide_license_notices_permanently', true))
885 885
 				? $already_dismiss_notices
886 886
 				: array();
887 887
 
888 888
 
889
-			if( in_array( $notice_id, $already_dismiss_notices ) || get_transient( "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}" ) ) {
890
-				$is_notice_dismissed =  true;
889
+			if (in_array($notice_id, $already_dismiss_notices) || get_transient("_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}")) {
890
+				$is_notice_dismissed = true;
891 891
 			}
892 892
 
893 893
 			return $is_notice_dismissed;
Please login to merge, or discard this patch.
includes/gateways/actions.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * @param $data
23 23
  */
24
-function give_process_gateway_select( $data ) {
25
-	if ( isset( $_POST['gateway_submit'] ) ) {
26
-		wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) );
24
+function give_process_gateway_select($data) {
25
+	if (isset($_POST['gateway_submit'])) {
26
+		wp_redirect(esc_url(add_query_arg('payment-mode', $_POST['payment-mode'])));
27 27
 		exit;
28 28
 	}
29 29
 }
30 30
 
31
-add_action( 'give_gateway_select', 'give_process_gateway_select' );
31
+add_action('give_gateway_select', 'give_process_gateway_select');
32 32
 
33 33
 /**
34 34
  * Loads a payment gateway via AJAX
@@ -38,20 +38,20 @@  discard block
 block discarded – undo
38 38
  * @return void
39 39
  */
40 40
 function give_load_ajax_gateway() {
41
-	if ( isset( $_POST['give_payment_mode'] ) ) {
41
+	if (isset($_POST['give_payment_mode'])) {
42 42
 		/**
43 43
 		 * Fire to render donation form.
44 44
 		 *
45 45
 		 * @since 1.7
46 46
 		 */
47
-		do_action( 'give_donation_form', $_POST['give_form_id'] );
47
+		do_action('give_donation_form', $_POST['give_form_id']);
48 48
 
49 49
 		exit();
50 50
 	}
51 51
 }
52 52
 
53
-add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' );
54
-add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' );
53
+add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway');
54
+add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway');
55 55
 
56 56
 /**
57 57
  * Sets an error on checkout if no gateways are enabled
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 function give_no_gateway_error() {
64 64
 	$gateways = give_get_enabled_payment_gateways();
65 65
 
66
-	if ( empty( $gateways ) ) {
67
-		give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) );
66
+	if (empty($gateways)) {
67
+		give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give'));
68 68
 	} else {
69
-		give_unset_error( 'no_gateways' );
69
+		give_unset_error('no_gateways');
70 70
 	}
71 71
 }
72 72
 
73
-add_action( 'init', 'give_no_gateway_error' );
73
+add_action('init', 'give_no_gateway_error');
Please login to merge, or discard this patch.