Completed
Pull Request — master (#857)
by
unknown
16:49
created
includes/admin/class-addon-activation-banner.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 // Exit if accessed directly
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @param $_banner_details
28 28
 	 */
29
-	function __construct( $_banner_details ) {
29
+	function __construct($_banner_details) {
30 30
 
31 31
 		global $current_user;
32 32
 		$this->banner_details = $_banner_details;
33
-		$this->test_mode      = ( $this->banner_details['testing'] == 'true' ) ? true : false;
34
-		$this->nag_meta_key   = 'give_addon_activation_ignore_' . sanitize_title( $this->banner_details['name'] );
33
+		$this->test_mode      = ($this->banner_details['testing'] == 'true') ? true : false;
34
+		$this->nag_meta_key   = 'give_addon_activation_ignore_'.sanitize_title($this->banner_details['name']);
35 35
 
36 36
 		//Get current user
37 37
 		$this->user_id = $current_user->ID;
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
 	public function init() {
51 51
 
52 52
 		//Testing?
53
-		if ( $this->test_mode ) {
54
-			delete_user_meta( $this->user_id, $this->nag_meta_key );
53
+		if ($this->test_mode) {
54
+			delete_user_meta($this->user_id, $this->nag_meta_key);
55 55
 		}
56 56
 
57 57
 		//Get the current page to add the notice to
58
-		add_action( 'current_screen', array( $this, 'give_addon_notice_ignore' ) );
59
-		add_action( 'admin_notices', array( $this, 'give_addon_activation_admin_notice' ) );
58
+		add_action('current_screen', array($this, 'give_addon_notice_ignore'));
59
+		add_action('admin_notices', array($this, 'give_addon_activation_admin_notice'));
60 60
 
61 61
 
62 62
 	}
@@ -71,13 +71,13 @@  discard block
 block discarded – undo
71 71
 		global $pagenow;
72 72
 
73 73
 		//Make sure we're on the plugins page.
74
-		if ( $pagenow !== 'plugins.php' ) {
74
+		if ($pagenow !== 'plugins.php') {
75 75
 			return false;
76 76
 		}
77 77
 
78 78
 		// If the user hasn't already dismissed our alert,
79 79
 		// Output the activation banner
80
-		if ( ! get_user_meta( $this->user_id, $this->nag_meta_key ) ) { ?>
80
+		if ( ! get_user_meta($this->user_id, $this->nag_meta_key)) { ?>
81 81
 
82 82
 			<!-- * I output inline styles here
83 83
 				 * because there's no reason to keep these
@@ -157,15 +157,15 @@  discard block
 block discarded – undo
157 157
 				<h3><?php
158 158
 					printf(
159 159
 						/* translators: %s: Add-on name */
160
-						esc_html__( "Thank you for installing Give's %s Add-on!", 'give' ),
161
-						'<span>' . $this->banner_details['name'] . '</span>'
160
+						esc_html__("Thank you for installing Give's %s Add-on!", 'give'),
161
+						'<span>'.$this->banner_details['name'].'</span>'
162 162
 					);
163 163
 				?></h3>
164 164
 
165 165
 				<a href="<?php
166 166
 				//The Dismiss Button
167
-				$nag_admin_dismiss_url = 'plugins.php?' . $this->nag_meta_key . '=0';
168
-				echo admin_url( $nag_admin_dismiss_url ); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a>
167
+				$nag_admin_dismiss_url = 'plugins.php?'.$this->nag_meta_key.'=0';
168
+				echo admin_url($nag_admin_dismiss_url); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a>
169 169
 
170 170
 				<!-- * Now we output a few "actions"
171 171
 					 * that the user can take from here -->
@@ -173,21 +173,21 @@  discard block
 block discarded – undo
173 173
 				<div class="alert-actions">
174 174
 
175 175
 					<?php //Point them to your settings page
176
-					if ( isset( $this->banner_details['settings_url'] ) ) { ?>
176
+					if (isset($this->banner_details['settings_url'])) { ?>
177 177
 						<a href="<?php echo $this->banner_details['settings_url']; ?>">
178
-							<span class="dashicons dashicons-admin-settings"></span><?php esc_html_e( 'Go to Settings', 'give' ); ?>
178
+							<span class="dashicons dashicons-admin-settings"></span><?php esc_html_e('Go to Settings', 'give'); ?>
179 179
 						</a>
180 180
 					<?php } ?>
181 181
 
182 182
 					<?php
183 183
 					// Show them how to configure the Addon
184
-					if ( isset( $this->banner_details['documentation_url'] ) ) { ?>
184
+					if (isset($this->banner_details['documentation_url'])) { ?>
185 185
 						<a href="<?php echo $this->banner_details['documentation_url'] ?>" target="_blank">
186 186
 							<span class="dashicons dashicons-media-text"></span>
187 187
 							<?php
188 188
 								printf(
189 189
 									/* translators: %s: Add-on name */
190
-									esc_html__( 'Documentation: %s Add-on', 'give' ),
190
+									esc_html__('Documentation: %s Add-on', 'give'),
191 191
 									$this->banner_details['name']
192 192
 								);
193 193
 							?>
@@ -195,10 +195,10 @@  discard block
 block discarded – undo
195 195
 					<?php } ?>
196 196
 					<?php
197 197
 					//Let them signup for plugin updates
198
-					if ( isset( $this->banner_details['support_url'] ) ) { ?>
198
+					if (isset($this->banner_details['support_url'])) { ?>
199 199
 
200 200
 						<a href="<?php echo $this->banner_details['support_url'] ?>" target="_blank">
201
-							<span class="dashicons dashicons-sos"></span><?php esc_html_e( 'Get Support', 'give' ); ?>
201
+							<span class="dashicons dashicons-sos"></span><?php esc_html_e('Get Support', 'give'); ?>
202 202
 						</a>
203 203
 
204 204
 					<?php } ?>
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
 		/* If user clicks to ignore the notice, add that to their user meta the banner then checks whether this tag exists already or not.
221 221
 		 * See here: http://codex.wordpress.org/Function_Reference/add_user_meta
222 222
 		 */
223
-		if ( isset( $_GET[ $this->nag_meta_key ] ) && '0' == $_GET[ $this->nag_meta_key ] ) {
223
+		if (isset($_GET[$this->nag_meta_key]) && '0' == $_GET[$this->nag_meta_key]) {
224 224
 
225 225
 			//Get the global user
226 226
 			global $current_user;
227 227
 			$user_id = $current_user->ID;
228 228
 
229
-			add_user_meta( $user_id, $this->nag_meta_key, 'true', true );
229
+			add_user_meta($user_id, $this->nag_meta_key, 'true', true);
230 230
 		}
231 231
 	}
232 232
 
Please login to merge, or discard this patch.
includes/admin/admin-pages.php 1 patch
Spacing   +65 added lines, -65 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
 
@@ -29,31 +29,31 @@  discard block
 block discarded – undo
29 29
 	global $give_settings_page, $give_payments_page, $give_reports_page, $give_add_ons_page, $give_upgrades_screen, $give_donors_page;
30 30
 
31 31
 	//Payments
32
-	$give_payment       = get_post_type_object( 'give_payment' );
33
-	$give_payments_page = add_submenu_page( 'edit.php?post_type=give_forms', $give_payment->labels->name, $give_payment->labels->menu_name, 'edit_give_payments', 'give-payment-history', 'give_payment_history_page' );
32
+	$give_payment       = get_post_type_object('give_payment');
33
+	$give_payments_page = add_submenu_page('edit.php?post_type=give_forms', $give_payment->labels->name, $give_payment->labels->menu_name, 'edit_give_payments', 'give-payment-history', 'give_payment_history_page');
34 34
 
35 35
 	//Donors
36
-	$give_donors_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Donors', 'give' ), esc_html__( 'Donors', 'give' ), 'view_give_reports', 'give-donors', 'give_customers_page' );
36
+	$give_donors_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Donors', 'give'), esc_html__('Donors', 'give'), 'view_give_reports', 'give-donors', 'give_customers_page');
37 37
 
38 38
 	//Reports`
39
-	$give_reports_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Donation Reports', 'give' ), esc_html__( 'Reports', 'give' ), 'view_give_reports', 'give-reports', 'give_reports_page' );
39
+	$give_reports_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Donation Reports', 'give'), esc_html__('Reports', 'give'), 'view_give_reports', 'give-reports', 'give_reports_page');
40 40
 
41 41
 	//Settings
42
-	$give_settings_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Give Settings', 'give' ), esc_html__( 'Settings', 'give' ), 'manage_give_settings', 'give-settings', array(
42
+	$give_settings_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Give Settings', 'give'), esc_html__('Settings', 'give'), 'manage_give_settings', 'give-settings', array(
43 43
 		Give()->give_settings,
44 44
 		'admin_page_display'
45
-	) );
45
+	));
46 46
 
47 47
 	//Add-ons
48
-	$give_add_ons_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Give Add-ons', 'give' ), esc_html__( 'Add-ons', 'give' ), 'install_plugins', 'give-addons', 'give_add_ons_page' );
48
+	$give_add_ons_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Give Add-ons', 'give'), esc_html__('Add-ons', 'give'), 'install_plugins', 'give-addons', 'give_add_ons_page');
49 49
 
50 50
 	//Upgrades
51
-	$give_upgrades_screen = add_submenu_page( null, esc_html__( 'Give Upgrades', 'give' ), esc_html__( 'Give Upgrades', 'give' ), 'manage_give_settings', 'give-upgrades', 'give_upgrades_screen' );
51
+	$give_upgrades_screen = add_submenu_page(null, esc_html__('Give Upgrades', 'give'), esc_html__('Give Upgrades', 'give'), 'manage_give_settings', 'give-upgrades', 'give_upgrades_screen');
52 52
 
53 53
 
54 54
 }
55 55
 
56
-add_action( 'admin_menu', 'give_add_options_links', 10 );
56
+add_action('admin_menu', 'give_add_options_links', 10);
57 57
 
58 58
 /**
59 59
  *  Determines whether the current admin page is a Give admin page.
@@ -68,224 +68,224 @@  discard block
 block discarded – undo
68 68
  *
69 69
  * @return bool True if Give admin page.
70 70
  */
71
-function give_is_admin_page( $passed_page = '', $passed_view = '' ) {
71
+function give_is_admin_page($passed_page = '', $passed_view = '') {
72 72
 
73 73
 	global $pagenow, $typenow;
74 74
 
75 75
 	$found     = false;
76
-	$post_type = isset( $_GET['post_type'] ) ? strtolower( $_GET['post_type'] ) : false;
77
-	$action    = isset( $_GET['action'] ) ? strtolower( $_GET['action'] ) : false;
78
-	$taxonomy  = isset( $_GET['taxonomy'] ) ? strtolower( $_GET['taxonomy'] ) : false;
79
-	$page      = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
80
-	$view      = isset( $_GET['view'] ) ? strtolower( $_GET['view'] ) : false;
81
-	$tab       = isset( $_GET['tab'] ) ? strtolower( $_GET['tab'] ) : false;
76
+	$post_type = isset($_GET['post_type']) ? strtolower($_GET['post_type']) : false;
77
+	$action    = isset($_GET['action']) ? strtolower($_GET['action']) : false;
78
+	$taxonomy  = isset($_GET['taxonomy']) ? strtolower($_GET['taxonomy']) : false;
79
+	$page      = isset($_GET['page']) ? strtolower($_GET['page']) : false;
80
+	$view      = isset($_GET['view']) ? strtolower($_GET['view']) : false;
81
+	$tab       = isset($_GET['tab']) ? strtolower($_GET['tab']) : false;
82 82
 
83
-	switch ( $passed_page ) {
83
+	switch ($passed_page) {
84 84
 		case 'give_forms':
85
-			switch ( $passed_view ) {
85
+			switch ($passed_view) {
86 86
 				case 'list-table':
87
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' ) {
87
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php') {
88 88
 						$found = true;
89 89
 					}
90 90
 					break;
91 91
 				case 'edit':
92
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'post.php' ) {
92
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'post.php') {
93 93
 						$found = true;
94 94
 					}
95 95
 					break;
96 96
 				case 'new':
97
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'post-new.php' ) {
97
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'post-new.php') {
98 98
 						$found = true;
99 99
 					}
100 100
 					break;
101 101
 				default:
102
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) || 'give_forms' === $post_type || ( 'post-new.php' == $pagenow && 'give_forms' === $post_type ) ) {
102
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) || 'give_forms' === $post_type || ('post-new.php' == $pagenow && 'give_forms' === $post_type)) {
103 103
 						$found = true;
104 104
 					}
105 105
 					break;
106 106
 			}
107 107
 			break;
108 108
 		case 'categories':
109
-			switch ( $passed_view ) {
109
+			switch ($passed_view) {
110 110
 				case 'list-table':
111 111
 				case 'new':
112
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_category' === $taxonomy ) {
112
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_category' === $taxonomy) {
113 113
 						$found = true;
114 114
 					}
115 115
 					break;
116 116
 				case 'edit':
117
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_category' === $taxonomy ) {
117
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_category' === $taxonomy) {
118 118
 						$found = true;
119 119
 					}
120 120
 					break;
121 121
 				default:
122
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'give_forms_category' === $taxonomy ) {
122
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'give_forms_category' === $taxonomy) {
123 123
 						$found = true;
124 124
 					}
125 125
 					break;
126 126
 			}
127 127
 			break;
128 128
 		case 'tags':
129
-			switch ( $passed_view ) {
129
+			switch ($passed_view) {
130 130
 				case 'list-table':
131 131
 				case 'new':
132
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_tag' === $taxonomy ) {
132
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_tag' === $taxonomy) {
133 133
 						$found = true;
134 134
 					}
135 135
 					break;
136 136
 				case 'edit':
137
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_tag' === $taxonomy ) {
137
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_tag' === $taxonomy) {
138 138
 						$found = true;
139 139
 					}
140 140
 					break;
141 141
 				default:
142
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'give_forms_tag' === $taxonomy ) {
142
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'give_forms_tag' === $taxonomy) {
143 143
 						$found = true;
144 144
 					}
145 145
 					break;
146 146
 			}
147 147
 			break;
148 148
 		case 'payments':
149
-			switch ( $passed_view ) {
149
+			switch ($passed_view) {
150 150
 				case 'list-table':
151
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page && false === $view ) {
151
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page && false === $view) {
152 152
 						$found = true;
153 153
 					}
154 154
 					break;
155 155
 				case 'edit':
156
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page && 'view-order-details' === $view ) {
156
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page && 'view-order-details' === $view) {
157 157
 						$found = true;
158 158
 					}
159 159
 					break;
160 160
 				default:
161
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page ) {
161
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page) {
162 162
 						$found = true;
163 163
 					}
164 164
 					break;
165 165
 			}
166 166
 			break;
167 167
 		case 'reports':
168
-			switch ( $passed_view ) {
168
+			switch ($passed_view) {
169 169
 				// If you want to do something like enqueue a script on a particular report's duration, look at $_GET[ 'range' ]
170 170
 				case 'earnings':
171
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && ( 'earnings' === $view || '-1' === $view || false === $view ) ) {
171
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && ('earnings' === $view || '-1' === $view || false === $view)) {
172 172
 						$found = true;
173 173
 					}
174 174
 					break;
175 175
 				case 'donors':
176
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'customers' === $view ) {
176
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'customers' === $view) {
177 177
 						$found = true;
178 178
 					}
179 179
 					break;
180 180
 				case 'gateways':
181
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'gateways' === $view ) {
181
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'gateways' === $view) {
182 182
 						$found = true;
183 183
 					}
184 184
 					break;
185 185
 				case 'export':
186
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'export' === $view ) {
186
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'export' === $view) {
187 187
 						$found = true;
188 188
 					}
189 189
 					break;
190 190
 				case 'logs':
191
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'logs' === $view ) {
191
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'logs' === $view) {
192 192
 						$found = true;
193 193
 					}
194 194
 					break;
195 195
 				default:
196
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page ) {
196
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page) {
197 197
 						$found = true;
198 198
 					}
199 199
 					break;
200 200
 			}
201 201
 			break;
202 202
 		case 'settings':
203
-			switch ( $passed_view ) {
203
+			switch ($passed_view) {
204 204
 				case 'general':
205
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && ( 'general' === $tab || false === $tab ) ) {
205
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && ('general' === $tab || false === $tab)) {
206 206
 						$found = true;
207 207
 					}
208 208
 					break;
209 209
 				case 'gateways':
210
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'gateways' === $tab ) {
210
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'gateways' === $tab) {
211 211
 						$found = true;
212 212
 					}
213 213
 					break;
214 214
 				case 'emails':
215
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'emails' === $tab ) {
215
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'emails' === $tab) {
216 216
 						$found = true;
217 217
 					}
218 218
 					break;
219 219
 				case 'display':
220
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'display' === $tab ) {
220
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'display' === $tab) {
221 221
 						$found = true;
222 222
 					}
223 223
 					break;
224 224
 				case 'licenses':
225
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'licenses' === $tab ) {
225
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'licenses' === $tab) {
226 226
 						$found = true;
227 227
 					}
228 228
 					break;
229 229
 				case 'api':
230
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'api' === $tab ) {
230
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'api' === $tab) {
231 231
 						$found = true;
232 232
 					}
233 233
 					break;
234 234
 				case 'advanced':
235
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'advanced' === $tab ) {
235
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'advanced' === $tab) {
236 236
 						$found = true;
237 237
 					}
238 238
 					break;
239 239
 				case 'system_info':
240
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'system_info' === $tab ) {
240
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'system_info' === $tab) {
241 241
 						$found = true;
242 242
 					}
243 243
 					break;
244 244
 				default:
245
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page ) {
245
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page) {
246 246
 						$found = true;
247 247
 					}
248 248
 					break;
249 249
 			}
250 250
 			break;
251 251
 		case 'addons':
252
-			if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-addons' === $page ) {
252
+			if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-addons' === $page) {
253 253
 				$found = true;
254 254
 			}
255 255
 			break;
256 256
 		case 'donors':
257
-			switch ( $passed_view ) {
257
+			switch ($passed_view) {
258 258
 				case 'list-table':
259
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && false === $view ) {
259
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && false === $view) {
260 260
 						$found = true;
261 261
 					}
262 262
 					break;
263 263
 				case 'overview':
264
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && 'overview' === $view ) {
264
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && 'overview' === $view) {
265 265
 						$found = true;
266 266
 					}
267 267
 					break;
268 268
 				case 'notes':
269
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && 'notes' === $view ) {
269
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && 'notes' === $view) {
270 270
 						$found = true;
271 271
 					}
272 272
 					break;
273 273
 				default:
274
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page ) {
274
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page) {
275 275
 						$found = true;
276 276
 					}
277 277
 					break;
278 278
 			}
279 279
 			break;
280 280
 		case 'reports':
281
-			if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page ) {
281
+			if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page) {
282 282
 				$found = true;
283 283
 			}
284 284
 			break;
285 285
 		default:
286 286
 			global $give_payments_page, $give_settings_page, $give_reports_page, $give_system_info_page, $give_add_ons_page, $give_settings_export, $give_upgrades_screen, $give_customers_page;
287 287
 
288
-			$admin_pages = apply_filters( 'give_admin_pages', array(
288
+			$admin_pages = apply_filters('give_admin_pages', array(
289 289
 				$give_payments_page,
290 290
 				$give_settings_page,
291 291
 				$give_reports_page,
@@ -294,18 +294,18 @@  discard block
 block discarded – undo
294 294
 				$give_upgrades_screen,
295 295
 				$give_settings_export,
296 296
 				$give_customers_page
297
-			) );
298
-			if ( 'give_forms' == $typenow || 'index.php' == $pagenow || 'post-new.php' == $pagenow || 'post.php' == $pagenow ) {
297
+			));
298
+			if ('give_forms' == $typenow || 'index.php' == $pagenow || 'post-new.php' == $pagenow || 'post.php' == $pagenow) {
299 299
 				$found = true;
300
-				if ( 'give-upgrades' === $page ) {
300
+				if ('give-upgrades' === $page) {
301 301
 					$found = false;
302 302
 				}
303
-			} elseif ( in_array( $pagenow, $admin_pages ) ) {
303
+			} elseif (in_array($pagenow, $admin_pages)) {
304 304
 				$found = true;
305 305
 			}
306 306
 			break;
307 307
 	}
308 308
 
309
-	return (bool) apply_filters( 'give_is_admin_page', $found, $page, $view, $passed_page, $passed_view );
309
+	return (bool) apply_filters('give_is_admin_page', $found, $page, $view, $passed_page, $passed_view);
310 310
 
311 311
 }
312 312
\ 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,36 +205,36 @@  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
 		ob_start();
217 217
 
218
-		give_get_template_part( 'emails/header', $this->get_template(), true );
218
+		give_get_template_part('emails/header', $this->get_template(), true);
219 219
 
220
-		do_action( 'give_email_header', $this );
220
+		do_action('give_email_header', $this);
221 221
 
222
-		if ( has_action( 'give_email_template_' . $this->get_template() ) ) {
223
-			do_action( 'give_email_template_' . $this->get_template() );
222
+		if (has_action('give_email_template_'.$this->get_template())) {
223
+			do_action('give_email_template_'.$this->get_template());
224 224
 		} else {
225
-			give_get_template_part( 'emails/body', $this->get_template(), true );
225
+			give_get_template_part('emails/body', $this->get_template(), true);
226 226
 		}
227 227
 
228
-		do_action( 'give_email_body', $this );
228
+		do_action('give_email_body', $this);
229 229
 
230
-		give_get_template_part( 'emails/footer', $this->get_template(), true );
230
+		give_get_template_part('emails/footer', $this->get_template(), true);
231 231
 
232
-		do_action( 'give_email_footer', $this );
232
+		do_action('give_email_footer', $this);
233 233
 
234 234
 		$body    = ob_get_clean();
235
-		$message = str_replace( '{email}', $message, $body );
235
+		$message = str_replace('{email}', $message, $body);
236 236
 
237
-		return apply_filters( 'give_email_message', $message, $this );
237
+		return apply_filters('give_email_message', $message, $this);
238 238
 	}
239 239
 
240 240
 	/**
@@ -247,26 +247,26 @@  discard block
 block discarded – undo
247 247
 	 *
248 248
 	 * @return bool
249 249
 	 */
250
-	public function send( $to, $subject, $message, $attachments = '' ) {
250
+	public function send($to, $subject, $message, $attachments = '') {
251 251
 
252
-		if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) {
253
-			_doing_it_wrong( __FUNCTION__, esc_html__( 'You cannot send email with Give_Emails until init/admin_init has been reached.', 'give' ), null );
252
+		if ( ! did_action('init') && ! did_action('admin_init')) {
253
+			_doing_it_wrong(__FUNCTION__, esc_html__('You cannot send email with Give_Emails until init/admin_init has been reached.', 'give'), null);
254 254
 
255 255
 			return false;
256 256
 		}
257 257
 
258
-		do_action( 'give_email_send_before', $this );
258
+		do_action('give_email_send_before', $this);
259 259
 
260
-		$subject = $this->parse_tags( $subject );
261
-		$message = $this->parse_tags( $message );
260
+		$subject = $this->parse_tags($subject);
261
+		$message = $this->parse_tags($message);
262 262
 
263
-		$message = $this->build_email( $message );
263
+		$message = $this->build_email($message);
264 264
 
265
-		$attachments = apply_filters( 'give_email_attachments', $attachments, $this );
265
+		$attachments = apply_filters('give_email_attachments', $attachments, $this);
266 266
 
267
-		$sent = wp_mail( $to, $subject, $message, $this->get_headers(), $attachments );
267
+		$sent = wp_mail($to, $subject, $message, $this->get_headers(), $attachments);
268 268
 
269
-		do_action( 'give_email_send_after', $this );
269
+		do_action('give_email_send_after', $this);
270 270
 
271 271
 		return $sent;
272 272
 
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
 	 * @since 1.0
279 279
 	 */
280 280
 	public function send_before() {
281
-		add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
282
-		add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
283
-		add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
281
+		add_filter('wp_mail_from', array($this, 'get_from_address'));
282
+		add_filter('wp_mail_from_name', array($this, 'get_from_name'));
283
+		add_filter('wp_mail_content_type', array($this, 'get_content_type'));
284 284
 	}
285 285
 
286 286
 	/**
@@ -289,9 +289,9 @@  discard block
 block discarded – undo
289 289
 	 * @since 1.0
290 290
 	 */
291 291
 	public function send_after() {
292
-		remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
293
-		remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
294
-		remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
292
+		remove_filter('wp_mail_from', array($this, 'get_from_address'));
293
+		remove_filter('wp_mail_from_name', array($this, 'get_from_name'));
294
+		remove_filter('wp_mail_content_type', array($this, 'get_content_type'));
295 295
 
296 296
 		// Reset heading to an empty string
297 297
 		$this->heading = '';
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
 	 *
303 303
 	 * @since 1.0
304 304
 	 */
305
-	public function text_to_html( $message ) {
305
+	public function text_to_html($message) {
306 306
 
307
-		if ( 'text/html' == $this->content_type || true === $this->html ) {
308
-			$message = wpautop( $message );
307
+		if ('text/html' == $this->content_type || true === $this->html) {
308
+			$message = wpautop($message);
309 309
 		}
310 310
 
311 311
 		return $message;
Please login to merge, or discard this patch.
includes/emails/actions.php 1 patch
Spacing   +18 added lines, -18 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,17 +23,17 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return void
25 25
  */
26
-function give_trigger_donation_receipt( $payment_id ) {
26
+function give_trigger_donation_receipt($payment_id) {
27 27
 	// Make sure we don't send a purchase receipt while editing a payment
28
-	if ( isset( $_POST['give-action'] ) && 'edit_payment' == $_POST['give-action'] ) {
28
+	if (isset($_POST['give-action']) && 'edit_payment' == $_POST['give-action']) {
29 29
 		return;
30 30
 	}
31 31
 
32 32
 	// Send email
33
-	give_email_donation_receipt( $payment_id );
33
+	give_email_donation_receipt($payment_id);
34 34
 }
35 35
 
36
-add_action( 'give_complete_purchase', 'give_trigger_donation_receipt', 999, 1 );
36
+add_action('give_complete_purchase', 'give_trigger_donation_receipt', 999, 1);
37 37
 
38 38
 /**
39 39
  * Resend the Email Purchase Receipt. (This can be done from the Payment History page)
@@ -44,29 +44,29 @@  discard block
 block discarded – undo
44 44
  *
45 45
  * @return void
46 46
  */
47
-function give_resend_donation_receipt( $data ) {
47
+function give_resend_donation_receipt($data) {
48 48
 
49
-	$purchase_id = absint( $data['purchase_id'] );
49
+	$purchase_id = absint($data['purchase_id']);
50 50
 
51
-	if ( empty( $purchase_id ) ) {
51
+	if (empty($purchase_id)) {
52 52
 		return;
53 53
 	}
54 54
 
55
-	if ( ! current_user_can( 'edit_give_payments', $purchase_id ) ) {
56
-		wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
55
+	if ( ! current_user_can('edit_give_payments', $purchase_id)) {
56
+		wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
57 57
 	}
58 58
 
59
-	give_email_donation_receipt( $purchase_id, false );
59
+	give_email_donation_receipt($purchase_id, false);
60 60
 
61
-	wp_redirect( add_query_arg( array(
61
+	wp_redirect(add_query_arg(array(
62 62
 		'give-message' => 'email_sent',
63 63
 		'give-action'  => false,
64 64
 		'purchase_id'  => false
65
-	) ) );
65
+	)));
66 66
 	exit;
67 67
 }
68 68
 
69
-add_action( 'give_email_links', 'give_resend_donation_receipt' );
69
+add_action('give_email_links', 'give_resend_donation_receipt');
70 70
 
71 71
 /**
72 72
  * Trigger the sending of a Test Email
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
  *
78 78
  * @return void
79 79
  */
80
-function give_send_test_email( $data ) {
81
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give-test-email' ) ) {
80
+function give_send_test_email($data) {
81
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give-test-email')) {
82 82
 		return;
83 83
 	}
84 84
 
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 	give_email_test_donation_receipt();
87 87
 
88 88
 	// Remove the test email query arg
89
-	wp_redirect( remove_query_arg( 'give_action' ) );
89
+	wp_redirect(remove_query_arg('give_action'));
90 90
 	exit;
91 91
 }
92 92
 
93
-add_action( 'give_send_test_email', 'give_send_test_email' );
93
+add_action('give_send_test_email', 'give_send_test_email');
Please login to merge, or discard this patch.
includes/emails/class-give-email-tags.php 1 patch
Spacing   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  */
24 24
 
25 25
 // Exit if accessed directly
26
-if ( ! defined( 'ABSPATH' ) ) {
26
+if ( ! defined('ABSPATH')) {
27 27
 	exit;
28 28
 }
29 29
 
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
 	 * @param string $tag Email tag to be replace in email
55 55
 	 * @param callable $func Hook to run when email tag is found
56 56
 	 */
57
-	public function add( $tag, $description, $func ) {
58
-		if ( is_callable( $func ) ) {
59
-			$this->tags[ $tag ] = array(
57
+	public function add($tag, $description, $func) {
58
+		if (is_callable($func)) {
59
+			$this->tags[$tag] = array(
60 60
 				'tag'         => $tag,
61 61
 				'description' => $description,
62 62
 				'func'        => $func
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @param string $tag Email tag to remove hook from
73 73
 	 */
74
-	public function remove( $tag ) {
75
-		unset( $this->tags[ $tag ] );
74
+	public function remove($tag) {
75
+		unset($this->tags[$tag]);
76 76
 	}
77 77
 
78 78
 	/**
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 	 *
85 85
 	 * @return bool
86 86
 	 */
87
-	public function email_tag_exists( $tag ) {
88
-		return array_key_exists( $tag, $this->tags );
87
+	public function email_tag_exists($tag) {
88
+		return array_key_exists($tag, $this->tags);
89 89
 	}
90 90
 
91 91
 	/**
@@ -109,16 +109,16 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @return string Content with email tags filtered out.
111 111
 	 */
112
-	public function do_tags( $content, $payment_id ) {
112
+	public function do_tags($content, $payment_id) {
113 113
 
114 114
 		// Check if there is atleast one tag added
115
-		if ( empty( $this->tags ) || ! is_array( $this->tags ) ) {
115
+		if (empty($this->tags) || ! is_array($this->tags)) {
116 116
 			return $content;
117 117
 		}
118 118
 
119 119
 		$this->payment_id = $payment_id;
120 120
 
121
-		$new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content );
121
+		$new_content = preg_replace_callback("/{([A-z0-9\-\_]+)}/s", array($this, 'do_tag'), $content);
122 122
 
123 123
 		$this->payment_id = null;
124 124
 
@@ -134,17 +134,17 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @return mixed
136 136
 	 */
137
-	public function do_tag( $m ) {
137
+	public function do_tag($m) {
138 138
 
139 139
 		// Get tag
140 140
 		$tag = $m[1];
141 141
 
142 142
 		// Return tag if tag not set
143
-		if ( ! $this->email_tag_exists( $tag ) ) {
143
+		if ( ! $this->email_tag_exists($tag)) {
144 144
 			return $m[0];
145 145
 		}
146 146
 
147
-		return call_user_func( $this->tags[ $tag ]['func'], $this->payment_id, $tag );
147
+		return call_user_func($this->tags[$tag]['func'], $this->payment_id, $tag);
148 148
 	}
149 149
 
150 150
 }
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
  * @param string $description Description of the email tag added
159 159
  * @param callable $func Hook to run when email tag is found
160 160
  */
161
-function give_add_email_tag( $tag, $description, $func ) {
162
-	Give()->email_tags->add( $tag, $description, $func );
161
+function give_add_email_tag($tag, $description, $func) {
162
+	Give()->email_tags->add($tag, $description, $func);
163 163
 }
164 164
 
165 165
 /**
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
  *
170 170
  * @param string $tag Email tag to remove hook from
171 171
  */
172
-function give_remove_email_tag( $tag ) {
173
-	Give()->email_tags->remove( $tag );
172
+function give_remove_email_tag($tag) {
173
+	Give()->email_tags->remove($tag);
174 174
 }
175 175
 
176 176
 /**
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
  *
183 183
  * @return bool
184 184
  */
185
-function give_email_tag_exists( $tag ) {
186
-	return Give()->email_tags->email_tag_exists( $tag );
185
+function give_email_tag_exists($tag) {
186
+	return Give()->email_tags->email_tag_exists($tag);
187 187
 }
188 188
 
189 189
 /**
@@ -212,13 +212,13 @@  discard block
 block discarded – undo
212 212
 	$email_tags = give_get_email_tags();
213 213
 
214 214
 	// Check
215
-	if ( count( $email_tags ) > 0 ) {
215
+	if (count($email_tags) > 0) {
216 216
 
217 217
 		// Loop
218
-		foreach ( $email_tags as $email_tag ) {
218
+		foreach ($email_tags as $email_tag) {
219 219
 
220 220
 			// Add email tag to list
221
-			$list .= '<code>{' . $email_tag['tag'] . '}</code> - ' . $email_tag['description'] . '<br/>';
221
+			$list .= '<code>{'.$email_tag['tag'].'}</code> - '.$email_tag['description'].'<br/>';
222 222
 
223 223
 		}
224 224
 
@@ -238,13 +238,13 @@  discard block
 block discarded – undo
238 238
  *
239 239
  * @return string Content with email tags filtered out.
240 240
  */
241
-function give_do_email_tags( $content, $payment_id ) {
241
+function give_do_email_tags($content, $payment_id) {
242 242
 
243 243
 	// Replace all tags
244
-	$content = Give()->email_tags->do_tags( $content, $payment_id );
244
+	$content = Give()->email_tags->do_tags($content, $payment_id);
245 245
 
246 246
 	// Maintaining backwards compatibility
247
-	$content = apply_filters( 'give_email_template_tags', $content, give_get_payment_meta( $payment_id ), $payment_id );
247
+	$content = apply_filters('give_email_template_tags', $content, give_get_payment_meta($payment_id), $payment_id);
248 248
 
249 249
 	// Return content
250 250
 	return $content;
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
  * @since 1.0
257 257
  */
258 258
 function give_load_email_tags() {
259
-	do_action( 'give_add_email_tags' );
259
+	do_action('give_add_email_tags');
260 260
 }
261 261
 
262
-add_action( 'init', 'give_load_email_tags', - 999 );
262
+add_action('init', 'give_load_email_tags', - 999);
263 263
 
264 264
 /**
265 265
  * Add default Give email template tags
@@ -272,82 +272,82 @@  discard block
 block discarded – undo
272 272
 	$email_tags = array(
273 273
 		array(
274 274
 			'tag'         => 'donation',
275
-			'description' => esc_html__( 'The name of completed donation form and the donation level chosen if applicable.', 'give' ),
275
+			'description' => esc_html__('The name of completed donation form and the donation level chosen if applicable.', 'give'),
276 276
 			'function'    => 'give_email_tag_donation'
277 277
 		),
278 278
 		array(
279 279
 			'tag'         => 'name',
280
-			'description' => esc_html__( 'The donor\'s first name.', 'give' ),
280
+			'description' => esc_html__('The donor\'s first name.', 'give'),
281 281
 			'function'    => 'give_email_tag_first_name'
282 282
 		),
283 283
 		array(
284 284
 			'tag'         => 'fullname',
285
-			'description' => esc_html__( 'The donor\'s full name, first and last.', 'give' ),
285
+			'description' => esc_html__('The donor\'s full name, first and last.', 'give'),
286 286
 			'function'    => 'give_email_tag_fullname'
287 287
 		),
288 288
 		array(
289 289
 			'tag'         => 'username',
290
-			'description' => esc_html__( 'The donor\'s user name on the site, if they registered an account.', 'give' ),
290
+			'description' => esc_html__('The donor\'s user name on the site, if they registered an account.', 'give'),
291 291
 			'function'    => 'give_email_tag_username'
292 292
 		),
293 293
 		array(
294 294
 			'tag'         => 'user_email',
295
-			'description' => esc_html__( 'The donor\'s email address.', 'give' ),
295
+			'description' => esc_html__('The donor\'s email address.', 'give'),
296 296
 			'function'    => 'give_email_tag_user_email'
297 297
 		),
298 298
 		array(
299 299
 			'tag'         => 'billing_address',
300
-			'description' => esc_html__( 'The donor\'s billing address.', 'give' ),
300
+			'description' => esc_html__('The donor\'s billing address.', 'give'),
301 301
 			'function'    => 'give_email_tag_billing_address'
302 302
 		),
303 303
 		array(
304 304
 			'tag'         => 'date',
305
-			'description' => esc_html__( 'The date of the donation.', 'give' ),
305
+			'description' => esc_html__('The date of the donation.', 'give'),
306 306
 			'function'    => 'give_email_tag_date'
307 307
 		),
308 308
 		array(
309 309
 			'tag'         => 'price',
310
-			'description' => esc_html__( 'The total price of the donation.', 'give' ),
310
+			'description' => esc_html__('The total price of the donation.', 'give'),
311 311
 			'function'    => 'give_email_tag_price'
312 312
 		),
313 313
 		array(
314 314
 			'tag'         => 'payment_id',
315
-			'description' => esc_html__( 'The unique ID number for this donation.', 'give' ),
315
+			'description' => esc_html__('The unique ID number for this donation.', 'give'),
316 316
 			'function'    => 'give_email_tag_payment_id'
317 317
 		),
318 318
 		array(
319 319
 			'tag'         => 'receipt_id',
320
-			'description' => esc_html__( 'The unique ID number for this donation receipt.', 'give' ),
320
+			'description' => esc_html__('The unique ID number for this donation receipt.', 'give'),
321 321
 			'function'    => 'give_email_tag_receipt_id'
322 322
 		),
323 323
 		array(
324 324
 			'tag'         => 'payment_method',
325
-			'description' => esc_html__( 'The method of payment used for this donation.', 'give' ),
325
+			'description' => esc_html__('The method of payment used for this donation.', 'give'),
326 326
 			'function'    => 'give_email_tag_payment_method'
327 327
 		),
328 328
 		array(
329 329
 			'tag'         => 'sitename',
330
-			'description' => esc_html__( 'Your site name', 'give' ),
330
+			'description' => esc_html__('Your site name', 'give'),
331 331
 			'function'    => 'give_email_tag_sitename'
332 332
 		),
333 333
 		array(
334 334
 			'tag'         => 'receipt_link',
335
-			'description' => esc_html__( 'Adds a link so users can view their receipt directly on your website if they are unable to view it in the browser correctly.', 'give' ),
335
+			'description' => esc_html__('Adds a link so users can view their receipt directly on your website if they are unable to view it in the browser correctly.', 'give'),
336 336
 			'function'    => 'give_email_tag_receipt_link'
337 337
 		),
338 338
 	);
339 339
 
340 340
 	// Apply give_email_tags filter
341
-	$email_tags = apply_filters( 'give_email_tags', $email_tags );
341
+	$email_tags = apply_filters('give_email_tags', $email_tags);
342 342
 
343 343
 	// Add email tags
344
-	foreach ( $email_tags as $email_tag ) {
345
-		give_add_email_tag( $email_tag['tag'], $email_tag['description'], $email_tag['function'] );
344
+	foreach ($email_tags as $email_tag) {
345
+		give_add_email_tag($email_tag['tag'], $email_tag['description'], $email_tag['function']);
346 346
 	}
347 347
 
348 348
 }
349 349
 
350
-add_action( 'give_add_email_tags', 'give_setup_email_tags' );
350
+add_action('give_add_email_tags', 'give_setup_email_tags');
351 351
 
352 352
 
353 353
 /**
@@ -358,15 +358,15 @@  discard block
 block discarded – undo
358 358
  *
359 359
  * @return string name
360 360
  */
361
-function give_email_tag_first_name( $payment_id ) {
362
-	$payment   = new Give_Payment( $payment_id );
361
+function give_email_tag_first_name($payment_id) {
362
+	$payment   = new Give_Payment($payment_id);
363 363
 	$user_info = $payment->user_info;
364 364
 
365
-	if ( empty( $user_info ) ) {
365
+	if (empty($user_info)) {
366 366
 		return '';
367 367
 	}
368 368
 
369
-	$email_name = give_get_email_names( $user_info );
369
+	$email_name = give_get_email_names($user_info);
370 370
 
371 371
 	return $email_name['name'];
372 372
 }
@@ -379,15 +379,15 @@  discard block
 block discarded – undo
379 379
  *
380 380
  * @return string fullname
381 381
  */
382
-function give_email_tag_fullname( $payment_id ) {
383
-	$payment   = new Give_Payment( $payment_id );
382
+function give_email_tag_fullname($payment_id) {
383
+	$payment   = new Give_Payment($payment_id);
384 384
 	$user_info = $payment->user_info;
385 385
 
386
-	if ( empty( $user_info ) ) {
386
+	if (empty($user_info)) {
387 387
 		return '';
388 388
 	}
389 389
 
390
-	$email_name = give_get_email_names( $user_info );
390
+	$email_name = give_get_email_names($user_info);
391 391
 
392 392
 	return $email_name['fullname'];
393 393
 }
@@ -400,15 +400,15 @@  discard block
 block discarded – undo
400 400
  *
401 401
  * @return string username
402 402
  */
403
-function give_email_tag_username( $payment_id ) {
404
-	$payment   = new Give_Payment( $payment_id );
403
+function give_email_tag_username($payment_id) {
404
+	$payment   = new Give_Payment($payment_id);
405 405
 	$user_info = $payment->user_info;
406 406
 
407
-	if ( empty( $user_info ) ) {
407
+	if (empty($user_info)) {
408 408
 		return '';
409 409
 	}
410 410
 
411
-	$email_name = give_get_email_names( $user_info );
411
+	$email_name = give_get_email_names($user_info);
412 412
 
413 413
 	return $email_name['username'];
414 414
 }
@@ -421,8 +421,8 @@  discard block
 block discarded – undo
421 421
  *
422 422
  * @return string user_email
423 423
  */
424
-function give_email_tag_user_email( $payment_id ) {
425
-	$payment = new Give_Payment( $payment_id );
424
+function give_email_tag_user_email($payment_id) {
425
+	$payment = new Give_Payment($payment_id);
426 426
 
427 427
 	return $payment->email;
428 428
 }
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
  *
436 436
  * @return string billing_address
437 437
  */
438
-function give_email_tag_billing_address( $payment_id ) {
438
+function give_email_tag_billing_address($payment_id) {
439 439
 
440
-	$user_info    = give_get_payment_meta_user_info( $payment_id );
441
-	$user_address = ! empty( $user_info['address'] ) ? $user_info['address'] : array(
440
+	$user_info    = give_get_payment_meta_user_info($payment_id);
441
+	$user_address = ! empty($user_info['address']) ? $user_info['address'] : array(
442 442
 		'line1'   => '',
443 443
 		'line2'   => '',
444 444
 		'city'    => '',
@@ -447,11 +447,11 @@  discard block
 block discarded – undo
447 447
 		'zip'     => ''
448 448
 	);
449 449
 
450
-	$return = $user_address['line1'] . "\n";
451
-	if ( ! empty( $user_address['line2'] ) ) {
452
-		$return .= $user_address['line2'] . "\n";
450
+	$return = $user_address['line1']."\n";
451
+	if ( ! empty($user_address['line2'])) {
452
+		$return .= $user_address['line2']."\n";
453 453
 	}
454
-	$return .= $user_address['city'] . ' ' . $user_address['zip'] . ' ' . $user_address['state'] . "\n";
454
+	$return .= $user_address['city'].' '.$user_address['zip'].' '.$user_address['state']."\n";
455 455
 	$return .= $user_address['country'];
456 456
 
457 457
 	return $return;
@@ -465,10 +465,10 @@  discard block
 block discarded – undo
465 465
  *
466 466
  * @return string date
467 467
  */
468
-function give_email_tag_date( $payment_id ) {
469
-	$payment = new Give_Payment( $payment_id );
468
+function give_email_tag_date($payment_id) {
469
+	$payment = new Give_Payment($payment_id);
470 470
 
471
-	return date_i18n( get_option( 'date_format' ), strtotime( $payment->date ) );
471
+	return date_i18n(get_option('date_format'), strtotime($payment->date));
472 472
 }
473 473
 
474 474
 /**
@@ -479,11 +479,11 @@  discard block
 block discarded – undo
479 479
  *
480 480
  * @return string price
481 481
  */
482
-function give_email_tag_price( $payment_id ) {
483
-	$payment = new Give_Payment( $payment_id );
484
-	$price   = give_currency_filter( give_format_amount( $payment->total ), $payment->currency );
482
+function give_email_tag_price($payment_id) {
483
+	$payment = new Give_Payment($payment_id);
484
+	$price   = give_currency_filter(give_format_amount($payment->total), $payment->currency);
485 485
 
486
-	return html_entity_decode( $price, ENT_COMPAT, 'UTF-8' );
486
+	return html_entity_decode($price, ENT_COMPAT, 'UTF-8');
487 487
 }
488 488
 
489 489
 /**
@@ -494,8 +494,8 @@  discard block
 block discarded – undo
494 494
  *
495 495
  * @return int payment_id
496 496
  */
497
-function give_email_tag_payment_id( $payment_id ) {
498
-	$payment = new Give_Payment( $payment_id );
497
+function give_email_tag_payment_id($payment_id) {
498
+	$payment = new Give_Payment($payment_id);
499 499
 
500 500
 	return $payment->number;
501 501
 }
@@ -508,8 +508,8 @@  discard block
 block discarded – undo
508 508
  *
509 509
  * @return string receipt_id
510 510
  */
511
-function give_email_tag_receipt_id( $payment_id ) {
512
-	$payment = new Give_Payment( $payment_id );
511
+function give_email_tag_receipt_id($payment_id) {
512
+	$payment = new Give_Payment($payment_id);
513 513
 
514 514
 	return $payment->key;
515 515
 }
@@ -523,11 +523,11 @@  discard block
 block discarded – undo
523 523
  *
524 524
  * @return string $form_title
525 525
  */
526
-function give_email_tag_donation( $payment_id ) {
527
-	$payment    = new Give_Payment( $payment_id );
528
-	$form_title = strip_tags( give_get_payment_form_title( $payment->meta, false, '-' ) );
526
+function give_email_tag_donation($payment_id) {
527
+	$payment    = new Give_Payment($payment_id);
528
+	$form_title = strip_tags(give_get_payment_form_title($payment->meta, false, '-'));
529 529
 
530
-	return ! empty( $form_title ) ? $form_title : esc_html__( 'There was an error retrieving this donation title.', 'give' );
530
+	return ! empty($form_title) ? $form_title : esc_html__('There was an error retrieving this donation title.', 'give');
531 531
 
532 532
 }
533 533
 
@@ -539,10 +539,10 @@  discard block
 block discarded – undo
539 539
  *
540 540
  * @return string gateway
541 541
  */
542
-function give_email_tag_payment_method( $payment_id ) {
543
-	$payment = new Give_Payment( $payment_id );
542
+function give_email_tag_payment_method($payment_id) {
543
+	$payment = new Give_Payment($payment_id);
544 544
 
545
-	return give_get_gateway_checkout_label( $payment->gateway );
545
+	return give_get_gateway_checkout_label($payment->gateway);
546 546
 }
547 547
 
548 548
 /**
@@ -553,8 +553,8 @@  discard block
 block discarded – undo
553 553
  *
554 554
  * @return string sitename
555 555
  */
556
-function give_email_tag_sitename( $payment_id ) {
557
-	return wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
556
+function give_email_tag_sitename($payment_id) {
557
+	return wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
558 558
 }
559 559
 
560 560
 /**
@@ -566,19 +566,19 @@  discard block
 block discarded – undo
566 566
  *
567 567
  * @return string receipt_link
568 568
  */
569
-function give_email_tag_receipt_link( $payment_id ) {
569
+function give_email_tag_receipt_link($payment_id) {
570 570
 
571
-	$receipt_url = esc_url( add_query_arg( array(
572
-		'payment_key' => give_get_payment_key( $payment_id ),
571
+	$receipt_url = esc_url(add_query_arg(array(
572
+		'payment_key' => give_get_payment_key($payment_id),
573 573
 		'give_action' => 'view_receipt'
574
-	), home_url() ) );
575
-	$formatted   = sprintf(
574
+	), home_url()));
575
+	$formatted = sprintf(
576 576
 		'<a href="%1$s">%2$s</a>',
577 577
 		$receipt_url,
578
-		esc_html__( 'View it in your browser', 'give' )
578
+		esc_html__('View it in your browser', 'give')
579 579
 	);
580 580
 
581
-	if ( give_get_option( 'email_template' ) !== 'none' ) {
581
+	if (give_get_option('email_template') !== 'none') {
582 582
 		return $formatted;
583 583
 	} else {
584 584
 		return $receipt_url;
Please login to merge, or discard this patch.
includes/class-give-license-handler.php 1 patch
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -8,11 +8,11 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 // Exit if accessed directly
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
15
-if ( ! class_exists( 'Give_License' ) ) :
15
+if ( ! class_exists('Give_License')) :
16 16
 
17 17
 	/**
18 18
 	 * Give_License Class
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
 		 * @param string  $_optname
39 39
 		 * @param string  $_api_url
40 40
 		 */
41
-		public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null ) {
41
+		public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null) {
42 42
 			global $give_options;
43 43
 
44 44
 			$this->file           = $_file;
45 45
 			$this->item_name      = $_item_name;
46
-			$this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) );
46
+			$this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name)));
47 47
 			$this->version        = $_version;
48
-			$this->license        = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : '';
48
+			$this->license        = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : '';
49 49
 			$this->author         = $_author;
50
-			$this->api_url        = is_null( $_api_url ) ? $this->api_url : $_api_url;
50
+			$this->api_url        = is_null($_api_url) ? $this->api_url : $_api_url;
51 51
 
52 52
 
53 53
 			// Setup hooks
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		 * @return  void
64 64
 		 */
65 65
 		private function includes() {
66
-			if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
66
+			if ( ! class_exists('EDD_SL_Plugin_Updater')) {
67 67
 				require_once 'admin/EDD_SL_Plugin_Updater.php';
68 68
 			}
69 69
 		}
@@ -77,18 +77,18 @@  discard block
 block discarded – undo
77 77
 		private function hooks() {
78 78
 
79 79
 			// Register settings
80
-			add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 );
80
+			add_filter('give_settings_licenses', array($this, 'settings'), 1);
81 81
 
82 82
 			// Activate license key on settings save
83
-			add_action( 'admin_init', array( $this, 'activate_license' ) );
83
+			add_action('admin_init', array($this, 'activate_license'));
84 84
 
85 85
 			// Deactivate license key
86
-			add_action( 'admin_init', array( $this, 'deactivate_license' ) );
86
+			add_action('admin_init', array($this, 'deactivate_license'));
87 87
 
88 88
 			// Updater
89
-			add_action( 'admin_init', array( $this, 'auto_updater' ), 0 );
89
+			add_action('admin_init', array($this, 'auto_updater'), 0);
90 90
 
91
-			add_action( 'admin_notices', array( $this, 'notices' ) );
91
+			add_action('admin_notices', array($this, 'notices'));
92 92
 		}
93 93
 
94 94
 		/**
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 		 */
101 101
 		public function auto_updater() {
102 102
 
103
-			if ( 'valid' !== get_option( $this->item_shortname . '_license_active' ) ) {
103
+			if ('valid' !== get_option($this->item_shortname.'_license_active')) {
104 104
 				return;
105 105
 			}
106 106
 
@@ -127,20 +127,20 @@  discard block
 block discarded – undo
127 127
 		 *
128 128
 		 * @return  array
129 129
 		 */
130
-		public function settings( $settings ) {
130
+		public function settings($settings) {
131 131
 
132 132
 			$give_license_settings = array(
133 133
 				array(
134 134
 					'name'    => $this->item_name,
135
-					'id'      => $this->item_shortname . '_license_key',
135
+					'id'      => $this->item_shortname.'_license_key',
136 136
 					'desc'    => '',
137 137
 					'type'    => 'license_key',
138
-					'options' => array( 'is_valid_license_option' => $this->item_shortname . '_license_active' ),
138
+					'options' => array('is_valid_license_option' => $this->item_shortname.'_license_active'),
139 139
 					'size'    => 'regular'
140 140
 				)
141 141
 			);
142 142
 
143
-			return array_merge( $settings, $give_license_settings );
143
+			return array_merge($settings, $give_license_settings);
144 144
 		}
145 145
 
146 146
 		/**
@@ -152,18 +152,18 @@  discard block
 block discarded – undo
152 152
 		 *
153 153
 		 * @return  array
154 154
 		 */
155
-		public function license_settings_content( $settings ) {
155
+		public function license_settings_content($settings) {
156 156
 
157 157
 			$give_license_settings = array(
158 158
 				array(
159
-					'name' => esc_html__( 'Add-on Licenses', 'give' ),
159
+					'name' => esc_html__('Add-on Licenses', 'give'),
160 160
 					'desc' => '<hr>',
161 161
 					'type' => 'give_title',
162 162
 					'id'   => 'give_title'
163 163
 				),
164 164
 			);
165 165
 
166
-			return array_merge( $settings, $give_license_settings );
166
+			return array_merge($settings, $give_license_settings);
167 167
 		}
168 168
 
169 169
 
@@ -175,34 +175,34 @@  discard block
 block discarded – undo
175 175
 		 */
176 176
 		public function activate_license() {
177 177
 
178
-			if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
178
+			if ( ! isset($_POST[$this->item_shortname.'_license_key'])) {
179 179
 				return;
180 180
 			}
181 181
 
182
-			foreach ( $_POST as $key => $value ) {
183
-				if ( false !== strpos( $key, 'license_key_deactivate' ) ) {
182
+			foreach ($_POST as $key => $value) {
183
+				if (false !== strpos($key, 'license_key_deactivate')) {
184 184
 					// Don't activate a key when deactivating a different key
185 185
 					return;
186 186
 				}
187 187
 			}
188 188
 
189
-			if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) {
189
+			if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) {
190 190
 
191
-				wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
191
+				wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
192 192
 
193 193
 			}
194 194
 
195
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
195
+			if ( ! current_user_can('manage_give_settings')) {
196 196
 				return;
197 197
 			}
198 198
 
199
-			if ( 'valid' === get_option( $this->item_shortname . '_license_active' ) ) {
199
+			if ('valid' === get_option($this->item_shortname.'_license_active')) {
200 200
 				return;
201 201
 			}
202 202
 
203
-			$license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] );
203
+			$license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']);
204 204
 
205
-			if ( empty( $license ) ) {
205
+			if (empty($license)) {
206 206
 				return;
207 207
 			}
208 208
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 			$api_params = array(
211 211
 				'edd_action' => 'activate_license', //never change from "edd_" to "give_"!
212 212
 				'license'    => $license,
213
-				'item_name'  => urlencode( $this->item_name ),
213
+				'item_name'  => urlencode($this->item_name),
214 214
 				'url'        => home_url()
215 215
 			);
216 216
 
@@ -225,22 +225,22 @@  discard block
 block discarded – undo
225 225
 			);
226 226
 
227 227
 			// Make sure there are no errors
228
-			if ( is_wp_error( $response ) ) {
228
+			if (is_wp_error($response)) {
229 229
 				return;
230 230
 			}
231 231
 
232 232
 			// Tell WordPress to look for updates
233
-			set_site_transient( 'update_plugins', null );
233
+			set_site_transient('update_plugins', null);
234 234
 
235 235
 			// Decode license data
236
-			$license_data = json_decode( wp_remote_retrieve_body( $response ) );
236
+			$license_data = json_decode(wp_remote_retrieve_body($response));
237 237
 
238
-			update_option( $this->item_shortname . '_license_active', $license_data->license );
238
+			update_option($this->item_shortname.'_license_active', $license_data->license);
239 239
 
240
-			if ( ! (bool) $license_data->success ) {
241
-				set_transient( 'give_license_error', $license_data, 1000 );
240
+			if ( ! (bool) $license_data->success) {
241
+				set_transient('give_license_error', $license_data, 1000);
242 242
 			} else {
243
-				delete_transient( 'give_license_error' );
243
+				delete_transient('give_license_error');
244 244
 			}
245 245
 		}
246 246
 
@@ -253,28 +253,28 @@  discard block
 block discarded – undo
253 253
 		 */
254 254
 		public function deactivate_license() {
255 255
 
256
-			if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
256
+			if ( ! isset($_POST[$this->item_shortname.'_license_key'])) {
257 257
 				return;
258 258
 			}
259 259
 
260
-			if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) {
260
+			if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) {
261 261
 
262
-				wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
262
+				wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
263 263
 
264 264
 			}
265 265
 
266
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
266
+			if ( ! current_user_can('manage_give_settings')) {
267 267
 				return;
268 268
 			}
269 269
 
270 270
 			// Run on deactivate button press
271
-			if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) {
271
+			if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) {
272 272
 
273 273
 				// Data to send to the API
274 274
 				$api_params = array(
275 275
 					'edd_action' => 'deactivate_license', //never change from "edd_" to "give_"!
276 276
 					'license'    => $this->license,
277
-					'item_name'  => urlencode( $this->item_name ),
277
+					'item_name'  => urlencode($this->item_name),
278 278
 					'url'        => home_url()
279 279
 				);
280 280
 
@@ -290,19 +290,19 @@  discard block
 block discarded – undo
290 290
 
291 291
 
292 292
 				// Make sure there are no errors
293
-				if ( is_wp_error( $response ) ) {
293
+				if (is_wp_error($response)) {
294 294
 					return;
295 295
 				}
296 296
 
297 297
 				// Decode the license data
298
-				$license_data = json_decode( wp_remote_retrieve_body( $response ) );
298
+				$license_data = json_decode(wp_remote_retrieve_body($response));
299 299
 
300
-				delete_option( $this->item_shortname . '_license_active' );
300
+				delete_option($this->item_shortname.'_license_active');
301 301
 
302
-				if ( ! (bool) $license_data->success ) {
303
-					set_transient( 'give_license_error', $license_data, 1000 );
302
+				if ( ! (bool) $license_data->success) {
303
+					set_transient('give_license_error', $license_data, 1000);
304 304
 				} else {
305
-					delete_transient( 'give_license_error' );
305
+					delete_transient('give_license_error');
306 306
 				}
307 307
 			}
308 308
 		}
@@ -316,44 +316,44 @@  discard block
 block discarded – undo
316 316
 		 */
317 317
 		public function notices() {
318 318
 
319
-			if ( ! isset( $_GET['page'] ) || 'give-settings' !== $_GET['page'] ) {
319
+			if ( ! isset($_GET['page']) || 'give-settings' !== $_GET['page']) {
320 320
 				return;
321 321
 			}
322 322
 
323
-			if ( ! isset( $_GET['tab'] ) || 'licenses' !== $_GET['tab'] ) {
323
+			if ( ! isset($_GET['tab']) || 'licenses' !== $_GET['tab']) {
324 324
 				return;
325 325
 			}
326 326
 
327
-			$license_error = get_transient( 'give_license_error' );
327
+			$license_error = get_transient('give_license_error');
328 328
 
329
-			if ( false === $license_error ) {
329
+			if (false === $license_error) {
330 330
 				return;
331 331
 			}
332 332
 
333
-			if ( ! empty( $license_error->error ) ) {
333
+			if ( ! empty($license_error->error)) {
334 334
 
335
-				switch ( $license_error->error ) {
335
+				switch ($license_error->error) {
336 336
 
337 337
 					case 'item_name_mismatch' :
338 338
 
339
-						$message = esc_html__( 'This license does not belong to the product you have entered it for.', 'give' );
339
+						$message = esc_html__('This license does not belong to the product you have entered it for.', 'give');
340 340
 						break;
341 341
 
342 342
 					case 'no_activations_left' :
343 343
 
344
-						$message = esc_html__( 'This license does not have any activations left.', 'give' );
344
+						$message = esc_html__('This license does not have any activations left.', 'give');
345 345
 						break;
346 346
 
347 347
 					case 'expired' :
348 348
 
349
-						$message = esc_html__( 'This license key is expired. Please renew it.', 'give' );
349
+						$message = esc_html__('This license key is expired. Please renew it.', 'give');
350 350
 						break;
351 351
 
352 352
 					default :
353 353
 
354 354
 						$message = sprintf(
355 355
 							/* translators: %s: license error */
356
-							esc_html__( 'There was a problem activating your license key, please try again or contact support. Error code: %s', 'give' ),
356
+							esc_html__('There was a problem activating your license key, please try again or contact support. Error code: %s', 'give'),
357 357
 							$license_error->error
358 358
 						);
359 359
 						break;
@@ -362,15 +362,15 @@  discard block
 block discarded – undo
362 362
 
363 363
 			}
364 364
 
365
-			if ( ! empty( $message ) ) {
365
+			if ( ! empty($message)) {
366 366
 
367 367
 				echo '<div class="error">';
368
-				echo '<p>' . $message . '</p>';
368
+				echo '<p>'.$message.'</p>';
369 369
 				echo '</div>';
370 370
 
371 371
 			}
372 372
 
373
-			delete_transient( 'give_license_error' );
373
+			delete_transient('give_license_error');
374 374
 
375 375
 		}
376 376
 	}
Please login to merge, or discard this patch.
includes/admin/shortcodes/shortcode-give-login.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -42,16 +42,16 @@
 block discarded – undo
42 42
 				'minWidth' => 320,
43 43
 				'tooltip'  => esc_attr__( 'Enter an URL here to redirect to after login.', 'give' ),
44 44
 			),
45
-            array(
46
-                'type' => 'container',
47
-                'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Logout Redirect URL (optional):', 'give' ) ),
48
-            ),
49
-            array(
50
-                'type'     => 'textbox',
51
-                'name'     => 'logout-redirect',
52
-                'minWidth' => 320,
53
-                'tooltip'  => esc_attr__( 'Enter an URL here to redirect to after logout.', 'give' ),
54
-            ),
45
+			array(
46
+				'type' => 'container',
47
+				'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Logout Redirect URL (optional):', 'give' ) ),
48
+			),
49
+			array(
50
+				'type'     => 'textbox',
51
+				'name'     => 'logout-redirect',
52
+				'minWidth' => 320,
53
+				'tooltip'  => esc_attr__( 'Enter an URL here to redirect to after logout.', 'give' ),
54
+			),
55 55
 		);
56 56
 	}
57 57
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @since       1.3.0
10 10
  */
11 11
 
12
-defined( 'ABSPATH' ) or exit;
12
+defined('ABSPATH') or exit;
13 13
 
14 14
 class Give_Shortcode_Login extends Give_Shortcode_Generator {
15 15
 
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
 	 */
19 19
 	public function __construct() {
20 20
 
21
-		$this->shortcode['title'] = esc_html__( 'Login', 'give' );
22
-		$this->shortcode['label'] = esc_html__( 'Login', 'give' );
21
+		$this->shortcode['title'] = esc_html__('Login', 'give');
22
+		$this->shortcode['label'] = esc_html__('Login', 'give');
23 23
 
24
-		parent::__construct( 'give_login' );
24
+		parent::__construct('give_login');
25 25
 	}
26 26
 
27 27
 	/**
@@ -34,23 +34,23 @@  discard block
 block discarded – undo
34 34
 		return array(
35 35
 			array(
36 36
 				'type' => 'container',
37
-				'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Login Redirect URL (optional):', 'give' ) ),
37
+				'html' => sprintf('<p class="no-margin">%s</p>', esc_html__('Login Redirect URL (optional):', 'give')),
38 38
 			),
39 39
 			array(
40 40
 				'type'     => 'textbox',
41 41
 				'name'     => 'login-redirect',
42 42
 				'minWidth' => 320,
43
-				'tooltip'  => esc_attr__( 'Enter an URL here to redirect to after login.', 'give' ),
43
+				'tooltip'  => esc_attr__('Enter an URL here to redirect to after login.', 'give'),
44 44
 			),
45 45
             array(
46 46
                 'type' => 'container',
47
-                'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Logout Redirect URL (optional):', 'give' ) ),
47
+                'html' => sprintf('<p class="no-margin">%s</p>', esc_html__('Logout Redirect URL (optional):', 'give')),
48 48
             ),
49 49
             array(
50 50
                 'type'     => 'textbox',
51 51
                 'name'     => 'logout-redirect',
52 52
                 'minWidth' => 320,
53
-                'tooltip'  => esc_attr__( 'Enter an URL here to redirect to after logout.', 'give' ),
53
+                'tooltip'  => esc_attr__('Enter an URL here to redirect to after logout.', 'give'),
54 54
             ),
55 55
 		);
56 56
 	}
Please login to merge, or discard this patch.
includes/admin/shortcodes/abstract-shortcode-generator.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -248,8 +248,8 @@
 block discarded – undo
248 248
 
249 249
 			// do not reindex array!
250 250
 			$field['options'] = array(
251
-				                    '' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ),
252
-			                    ) + $field['options'];
251
+									'' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ),
252
+								) + $field['options'];
253 253
 
254 254
 			foreach ( $field['options'] as $value => $text ) {
255 255
 				$new_listbox['values'][] = array(
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @since       1.3.0
12 12
  */
13 13
 
14
-defined( 'ABSPATH' ) or exit;
14
+defined('ABSPATH') or exit;
15 15
 
16 16
 abstract class Give_Shortcode_Generator {
17 17
 
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
 	 *
58 58
 	 * @since 1.0
59 59
 	 */
60
-	public function __construct( $shortcode ) {
60
+	public function __construct($shortcode) {
61 61
 
62 62
 
63 63
 		$this->shortcode_tag = $shortcode;
64 64
 
65
-		add_action( 'admin_init', array( $this, 'init' ) );
65
+		add_action('admin_init', array($this, 'init'));
66 66
 
67 67
 	}
68 68
 
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	public function init() {
75 75
 
76
-		if ( $this->shortcode_tag ) {
76
+		if ($this->shortcode_tag) {
77 77
 
78
-			$this->self = get_class( $this );
78
+			$this->self = get_class($this);
79 79
 
80 80
 			$this->errors   = array();
81 81
 			$this->required = array();
@@ -84,18 +84,18 @@  discard block
 block discarded – undo
84 84
 			$fields = $this->get_fields();
85 85
 
86 86
 			$defaults = array(
87
-				'btn_close' => esc_html__( 'Close', 'give' ),
88
-				'btn_okay'  => esc_html__( 'Insert Shortcode', 'give' ),
87
+				'btn_close' => esc_html__('Close', 'give'),
88
+				'btn_okay'  => esc_html__('Insert Shortcode', 'give'),
89 89
 				'errors'    => $this->errors,
90 90
 				'fields'    => $fields,
91
-				'label'     => '[' . $this->shortcode_tag . ']',
91
+				'label'     => '['.$this->shortcode_tag.']',
92 92
 				'required'  => $this->required,
93
-				'title'     => esc_html__( 'Insert Shortcode', 'give' ),
93
+				'title'     => esc_html__('Insert Shortcode', 'give'),
94 94
 			);
95 95
 
96
-			if ( user_can_richedit() && current_user_can('edit_give_forms') ) {
96
+			if (user_can_richedit() && current_user_can('edit_give_forms')) {
97 97
 
98
-				Give_Shortcode_Button::$shortcodes[ $this->shortcode_tag ] = wp_parse_args( $this->shortcode, $defaults );
98
+				Give_Shortcode_Button::$shortcodes[$this->shortcode_tag] = wp_parse_args($this->shortcode, $defaults);
99 99
 
100 100
 			}
101 101
 		}
@@ -124,13 +124,13 @@  discard block
 block discarded – undo
124 124
 	 *
125 125
 	 * @since 1.0
126 126
 	 */
127
-	protected function generate_fields( $defined_fields ) {
127
+	protected function generate_fields($defined_fields) {
128 128
 
129 129
 		$fields = array();
130 130
 
131
-		if ( is_array( $defined_fields ) ) {
131
+		if (is_array($defined_fields)) {
132 132
 
133
-			foreach ( $defined_fields as $field ) {
133
+			foreach ($defined_fields as $field) {
134 134
 
135 135
 				$defaults = array(
136 136
 					'label'       => false,
@@ -141,14 +141,14 @@  discard block
 block discarded – undo
141 141
 					'type'        => '',
142 142
 				);
143 143
 
144
-				$field  = wp_parse_args( (array) $field, $defaults );
145
-				$method = 'generate_' . strtolower( $field['type'] );
144
+				$field  = wp_parse_args((array) $field, $defaults);
145
+				$method = 'generate_'.strtolower($field['type']);
146 146
 
147
-				if ( method_exists( $this, $method ) ) {
147
+				if (method_exists($this, $method)) {
148 148
 
149
-					$field = call_user_func( array( $this, $method ), $field );
149
+					$field = call_user_func(array($this, $method), $field);
150 150
 
151
-					if ( $field ) {
151
+					if ($field) {
152 152
 						$fields[] = $field;
153 153
 					}
154 154
 				}
@@ -168,22 +168,22 @@  discard block
 block discarded – undo
168 168
 	protected function get_fields() {
169 169
 
170 170
 		$defined_fields   = $this->define_fields();
171
-		$generated_fields = $this->generate_fields( $defined_fields );
171
+		$generated_fields = $this->generate_fields($defined_fields);
172 172
 
173 173
 		$errors = array();
174 174
 
175
-		if ( ! empty( $this->errors ) ) {
176
-			foreach ( $this->required as $name => $alert ) {
177
-				if ( false === array_search( $name, array_column( $generated_fields, 'name' ) ) ) {
175
+		if ( ! empty($this->errors)) {
176
+			foreach ($this->required as $name => $alert) {
177
+				if (false === array_search($name, array_column($generated_fields, 'name'))) {
178 178
 
179
-					$errors[] = $this->errors[ $name ];
179
+					$errors[] = $this->errors[$name];
180 180
 				}
181 181
 			}
182 182
 
183 183
 			$this->errors = $errors;
184 184
 		}
185 185
 
186
-		if ( ! empty( $errors ) ) {
186
+		if ( ! empty($errors)) {
187 187
 
188 188
 			return $errors;
189 189
 		}
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
 	 *
201 201
 	 * @since 1.0
202 202
 	 */
203
-	protected function generate_container( $field ) {
203
+	protected function generate_container($field) {
204 204
 
205
-		if ( array_key_exists( 'html', $field ) ) {
205
+		if (array_key_exists('html', $field)) {
206 206
 
207 207
 			return array(
208 208
 				'type' => $field['type'],
@@ -222,36 +222,36 @@  discard block
 block discarded – undo
222 222
 	 *
223 223
 	 * @since 1.0
224 224
 	 */
225
-	protected function generate_listbox( $field ) {
225
+	protected function generate_listbox($field) {
226 226
 
227
-		$listbox = shortcode_atts( array(
227
+		$listbox = shortcode_atts(array(
228 228
 			'label'    => '',
229 229
 			'minWidth' => '',
230 230
 			'name'     => false,
231 231
 			'tooltip'  => '',
232 232
 			'type'     => '',
233 233
 			'value'    => '',
234
-		), $field );
234
+		), $field);
235 235
 
236
-		if ( $this->validate( $field ) ) {
236
+		if ($this->validate($field)) {
237 237
 
238 238
 			$new_listbox = array();
239 239
 
240
-			foreach ( $listbox as $key => $value ) {
240
+			foreach ($listbox as $key => $value) {
241 241
 
242
-				if ( $key == 'value' && empty( $value ) ) {
243
-					$new_listbox[ $key ] = $listbox['name'];
244
-				} else if ( $value ) {
245
-					$new_listbox[ $key ] = $value;
242
+				if ($key == 'value' && empty($value)) {
243
+					$new_listbox[$key] = $listbox['name'];
244
+				} else if ($value) {
245
+					$new_listbox[$key] = $value;
246 246
 				}
247 247
 			}
248 248
 
249 249
 			// do not reindex array!
250 250
 			$field['options'] = array(
251
-				                    '' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ),
251
+				                    '' => ($field['placeholder'] ? $field['placeholder'] : esc_attr__('- Select -', 'give')),
252 252
 			                    ) + $field['options'];
253 253
 
254
-			foreach ( $field['options'] as $value => $text ) {
254
+			foreach ($field['options'] as $value => $text) {
255 255
 				$new_listbox['values'][] = array(
256 256
 					'text'  => $text,
257 257
 					'value' => $value,
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	 *
274 274
 	 * @since 1.0
275 275
 	 */
276
-	protected function generate_post( $field ) {
276
+	protected function generate_post($field) {
277 277
 
278 278
 		$args = array(
279 279
 			'post_type'      => 'post',
@@ -282,23 +282,23 @@  discard block
 block discarded – undo
282 282
 			'posts_per_page' => 30,
283 283
 		);
284 284
 
285
-		$args    = wp_parse_args( (array) $field['query_args'], $args );
286
-		$posts   = get_posts( $args );
285
+		$args    = wp_parse_args((array) $field['query_args'], $args);
286
+		$posts   = get_posts($args);
287 287
 		$options = array();
288 288
 
289
-		if ( $posts ) {
290
-			foreach ( $posts as $post ) {
291
-				$options[ absint( $post->ID ) ] = esc_html( $post->post_title );
289
+		if ($posts) {
290
+			foreach ($posts as $post) {
291
+				$options[absint($post->ID)] = esc_html($post->post_title);
292 292
 			}
293 293
 
294 294
 			$field['type']    = 'listbox';
295 295
 			$field['options'] = $options;
296 296
 
297
-			return $this->generate_listbox( $field );
297
+			return $this->generate_listbox($field);
298 298
 		}
299 299
 
300 300
 		// perform validation here before returning false
301
-		$this->validate( $field );
301
+		$this->validate($field);
302 302
 
303 303
 		return false;
304 304
 	}
@@ -312,9 +312,9 @@  discard block
 block discarded – undo
312 312
 	 *
313 313
 	 * @since 1.0
314 314
 	 */
315
-	protected function generate_textbox( $field ) {
315
+	protected function generate_textbox($field) {
316 316
 
317
-		$textbox = shortcode_atts( array(
317
+		$textbox = shortcode_atts(array(
318 318
 			'label'     => '',
319 319
 			'maxLength' => '',
320 320
 			'minHeight' => '',
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
 			'tooltip'   => '',
325 325
 			'type'      => '',
326 326
 			'value'     => '',
327
-		), $field );
327
+		), $field);
328 328
 
329
-		if ( $this->validate( $field ) ) {
330
-			return array_filter( $textbox, array( $this, 'return_textbox_value' ) );
329
+		if ($this->validate($field)) {
330
+			return array_filter($textbox, array($this, 'return_textbox_value'));
331 331
 		}
332 332
 
333 333
 		return false;
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	 *
341 341
 	 * @return bool
342 342
 	 */
343
-	function return_textbox_value( $value ) {
343
+	function return_textbox_value($value) {
344 344
 		return $value !== '';
345 345
 	}
346 346
 
@@ -356,9 +356,9 @@  discard block
 block discarded – undo
356 356
 	 *
357 357
 	 * @since 1.0
358 358
 	 */
359
-	protected function validate( $field ) {
359
+	protected function validate($field) {
360 360
 
361
-		extract( shortcode_atts(
361
+		extract(shortcode_atts(
362 362
 				array(
363 363
 					'name'     => false,
364 364
 					'required' => false,
@@ -366,36 +366,36 @@  discard block
 block discarded – undo
366 366
 				), $field )
367 367
 		);
368 368
 
369
-		if ( $name ) {
369
+		if ($name) {
370 370
 
371
-			if ( isset( $required['error'] ) ) {
371
+			if (isset($required['error'])) {
372 372
 
373 373
 				$error = array(
374 374
 					'type' => 'container',
375 375
 					'html' => $required['error'],
376 376
 				);
377 377
 
378
-				$this->errors[ $name ] = $this->generate_container( $error );
378
+				$this->errors[$name] = $this->generate_container($error);
379 379
 			}
380 380
 
381
-			if ( ! ! $required || is_array( $required ) ) {
381
+			if ( ! ! $required || is_array($required)) {
382 382
 
383
-				$alert = esc_html__( 'Some of the Shortcode options are required.', 'give' );
383
+				$alert = esc_html__('Some of the Shortcode options are required.', 'give');
384 384
 
385
-				if ( isset( $required['alert'] ) ) {
385
+				if (isset($required['alert'])) {
386 386
 
387 387
 					$alert = $required['alert'];
388 388
 
389
-				} else if ( ! empty( $label ) ) {
389
+				} else if ( ! empty($label)) {
390 390
 
391 391
 					$alert = sprintf(
392 392
 						/* translators: %s: option lable */
393
-						esc_html__( 'The "%s" option is required.', 'give' ),
394
-						str_replace( ':', '', $label )
393
+						esc_html__('The "%s" option is required.', 'give'),
394
+						str_replace(':', '', $label)
395 395
 					);
396 396
 				}
397 397
 
398
-				$this->required[ $name ] = $alert;
398
+				$this->required[$name] = $alert;
399 399
 			}
400 400
 
401 401
 			return true;
Please login to merge, or discard this patch.
includes/admin/forms/dashboard-columns.php 1 patch
Spacing   +83 added lines, -83 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
 
@@ -27,34 +27,34 @@  discard block
 block discarded – undo
27 27
  * @return array $form_columns Updated array of forms columns
28 28
  *  Post Type List Table
29 29
  */
30
-function give_form_columns( $give_form_columns ) {
30
+function give_form_columns($give_form_columns) {
31 31
 
32 32
 	//Standard columns
33 33
 	$give_form_columns = array(
34 34
 		'cb'            => '<input type="checkbox"/>',
35
-		'title'         => esc_html__( 'Name', 'give' ),
36
-		'form_category' => esc_html__( 'Categories', 'give' ),
37
-		'form_tag'      => esc_html__( 'Tags', 'give' ),
38
-		'price'         => esc_html__( 'Price', 'give' ),
39
-		'goal'          => esc_html__( 'Goal', 'give' ),
40
-		'donations'     => esc_html__( 'Donations', 'give' ),
41
-		'earnings'      => esc_html__( 'Income', 'give' ),
42
-		'shortcode'     => esc_html__( 'Shortcode', 'give' ),
43
-		'date'          => esc_html__( 'Date', 'give' )
35
+		'title'         => esc_html__('Name', 'give'),
36
+		'form_category' => esc_html__('Categories', 'give'),
37
+		'form_tag'      => esc_html__('Tags', 'give'),
38
+		'price'         => esc_html__('Price', 'give'),
39
+		'goal'          => esc_html__('Goal', 'give'),
40
+		'donations'     => esc_html__('Donations', 'give'),
41
+		'earnings'      => esc_html__('Income', 'give'),
42
+		'shortcode'     => esc_html__('Shortcode', 'give'),
43
+		'date'          => esc_html__('Date', 'give')
44 44
 	);
45 45
 
46 46
 	//Does the user want categories / tags?
47
-	if ( give_get_option( 'enable_categories' ) !== 'on' ) {
48
-		unset( $give_form_columns['form_category'] );
47
+	if (give_get_option('enable_categories') !== 'on') {
48
+		unset($give_form_columns['form_category']);
49 49
 	}
50
-	if ( give_get_option( 'enable_tags' ) !== 'on' ) {
51
-		unset( $give_form_columns['form_tag'] );
50
+	if (give_get_option('enable_tags') !== 'on') {
51
+		unset($give_form_columns['form_tag']);
52 52
 	}
53 53
 
54
-	return apply_filters( 'give_forms_columns', $give_form_columns );
54
+	return apply_filters('give_forms_columns', $give_form_columns);
55 55
 }
56 56
 
57
-add_filter( 'manage_edit-give_forms_columns', 'give_form_columns' );
57
+add_filter('manage_edit-give_forms_columns', 'give_form_columns');
58 58
 
59 59
 /**
60 60
  * Render Give Form Columns
@@ -66,67 +66,67 @@  discard block
 block discarded – undo
66 66
  *
67 67
  * @return void
68 68
  */
69
-function give_render_form_columns( $column_name, $post_id ) {
70
-	if ( get_post_type( $post_id ) == 'give_forms' ) {
69
+function give_render_form_columns($column_name, $post_id) {
70
+	if (get_post_type($post_id) == 'give_forms') {
71 71
 		global $give_options;
72 72
 
73
-		$style = isset( $give_options['button_style'] ) ? $give_options['button_style'] : 'button';
74
-		$color = isset( $give_options['checkout_color'] ) ? $give_options['checkout_color'] : 'blue';
75
-		$color = ( $color == 'inherit' ) ? '' : $color;
73
+		$style = isset($give_options['button_style']) ? $give_options['button_style'] : 'button';
74
+		$color = isset($give_options['checkout_color']) ? $give_options['checkout_color'] : 'blue';
75
+		$color = ($color == 'inherit') ? '' : $color;
76 76
 
77
-		$purchase_text = ! empty( $give_options['add_to_cart_text'] ) ? $give_options['add_to_cart_text'] : esc_html__( 'Purchase', 'give' );
77
+		$purchase_text = ! empty($give_options['add_to_cart_text']) ? $give_options['add_to_cart_text'] : esc_html__('Purchase', 'give');
78 78
 
79
-		switch ( $column_name ) {
79
+		switch ($column_name) {
80 80
 			case 'form_category':
81
-				echo get_the_term_list( $post_id, 'give_forms_category', '', ', ', '' );
81
+				echo get_the_term_list($post_id, 'give_forms_category', '', ', ', '');
82 82
 				break;
83 83
 			case 'form_tag':
84
-				echo get_the_term_list( $post_id, 'give_forms_tag', '', ', ', '' );
84
+				echo get_the_term_list($post_id, 'give_forms_tag', '', ', ', '');
85 85
 				break;
86 86
 			case 'price':
87
-				if ( give_has_variable_prices( $post_id ) ) {
88
-					echo give_price_range( $post_id );
87
+				if (give_has_variable_prices($post_id)) {
88
+					echo give_price_range($post_id);
89 89
 				} else {
90
-					echo give_price( $post_id, false );
91
-					echo '<input type="hidden" class="formprice-' . $post_id . '" value="' . give_get_form_price( $post_id ) . '" />';
90
+					echo give_price($post_id, false);
91
+					echo '<input type="hidden" class="formprice-'.$post_id.'" value="'.give_get_form_price($post_id).'" />';
92 92
 				}
93 93
 				break;
94 94
 			case 'goal':
95
-				$goal_option = get_post_meta( $post_id, '_give_goal_option', true );
96
-				if ( ! empty( $goal_option ) && $goal_option === 'yes' ) {
97
-					echo give_goal( $post_id, false );
95
+				$goal_option = get_post_meta($post_id, '_give_goal_option', true);
96
+				if ( ! empty($goal_option) && $goal_option === 'yes') {
97
+					echo give_goal($post_id, false);
98 98
 				} else {
99
-					echo esc_html__( 'No Goal Set', 'give' );
99
+					echo esc_html__('No Goal Set', 'give');
100 100
 				}
101 101
 
102
-				echo '<input type="hidden" class="formgoal-' . $post_id . '" value="' . give_get_form_goal( $post_id ) . '" />';
102
+				echo '<input type="hidden" class="formgoal-'.$post_id.'" value="'.give_get_form_goal($post_id).'" />';
103 103
 				break;
104 104
 			case 'donations':
105
-				if ( current_user_can( 'view_give_forms_stats', $post_id ) ) {
106
-					echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=logs&view=sales&form=' . $post_id ) ) . '">';
107
-					echo give_get_form_sales_stats( $post_id );
105
+				if (current_user_can('view_give_forms_stats', $post_id)) {
106
+					echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&tab=logs&view=sales&form='.$post_id)).'">';
107
+					echo give_get_form_sales_stats($post_id);
108 108
 					echo '</a>';
109 109
 				} else {
110 110
 					echo '-';
111 111
 				}
112 112
 				break;
113 113
 			case 'earnings':
114
-				if ( current_user_can( 'view_give_forms_stats', $post_id ) ) {
115
-					echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=forms&form-id=' . $post_id ) ) . '">';
116
-					echo give_currency_filter( give_format_amount( give_get_form_earnings_stats( $post_id ) ) );
114
+				if (current_user_can('view_give_forms_stats', $post_id)) {
115
+					echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&view=forms&form-id='.$post_id)).'">';
116
+					echo give_currency_filter(give_format_amount(give_get_form_earnings_stats($post_id)));
117 117
 					echo '</a>';
118 118
 				} else {
119 119
 					echo '-';
120 120
 				}
121 121
 				break;
122 122
 			case 'shortcode':
123
-				echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id=&#34;' . absint( $post_id ) . '&#34;]">';
123
+				echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id=&#34;'.absint($post_id).'&#34;]">';
124 124
 				break;
125 125
 		}
126 126
 	}
127 127
 }
128 128
 
129
-add_action( 'manage_posts_custom_column', 'give_render_form_columns', 10, 2 );
129
+add_action('manage_posts_custom_column', 'give_render_form_columns', 10, 2);
130 130
 
131 131
 /**
132 132
  * Registers the sortable columns in the list table
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
  *
138 138
  * @return array $columns Array of sortable columns
139 139
  */
140
-function give_sortable_form_columns( $columns ) {
140
+function give_sortable_form_columns($columns) {
141 141
 	$columns['price']    = 'price';
142 142
 	$columns['sales']    = 'sales';
143 143
 	$columns['earnings'] = 'earnings';
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	return $columns;
147 147
 }
148 148
 
149
-add_filter( 'manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns' );
149
+add_filter('manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns');
150 150
 
151 151
 /**
152 152
  * Sorts Columns in the Forms List Table
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
  *
158 158
  * @return array $vars Array of all the sort variables
159 159
  */
160
-function give_sort_forms( $vars ) {
160
+function give_sort_forms($vars) {
161 161
 	// Check if we're viewing the "give_forms" post type
162
-	if ( isset( $vars['post_type'] ) && 'give_forms' == $vars['post_type'] ) {
162
+	if (isset($vars['post_type']) && 'give_forms' == $vars['post_type']) {
163 163
 		// Check if 'orderby' is set to "sales"
164
-		if ( isset( $vars['orderby'] ) && 'sales' == $vars['orderby'] ) {
164
+		if (isset($vars['orderby']) && 'sales' == $vars['orderby']) {
165 165
 			$vars = array_merge(
166 166
 				$vars,
167 167
 				array(
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 		}
173 173
 
174 174
 		// Check if "orderby" is set to "earnings"
175
-		if ( isset( $vars['orderby'] ) && 'earnings' == $vars['orderby'] ) {
175
+		if (isset($vars['orderby']) && 'earnings' == $vars['orderby']) {
176 176
 			$vars = array_merge(
177 177
 				$vars,
178 178
 				array(
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 		}
184 184
 
185 185
 		// Check if "orderby" is set to "price"
186
-		if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) {
186
+		if (isset($vars['orderby']) && 'price' == $vars['orderby']) {
187 187
 			$vars = array_merge(
188 188
 				$vars,
189 189
 				array(
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 		}
195 195
 
196 196
 		// Check if "orderby" is set to "goal"
197
-		if ( isset( $vars['orderby'] ) && 'goal' == $vars['orderby'] ) {
197
+		if (isset($vars['orderby']) && 'goal' == $vars['orderby']) {
198 198
 			$vars = array_merge(
199 199
 				$vars,
200 200
 				array(
@@ -217,16 +217,16 @@  discard block
 block discarded – undo
217 217
  *
218 218
  * @return array       Array of all sort variables
219 219
  */
220
-function give_filter_forms( $vars ) {
221
-	if ( isset( $vars['post_type'] ) && 'give_forms' == $vars['post_type'] ) {
220
+function give_filter_forms($vars) {
221
+	if (isset($vars['post_type']) && 'give_forms' == $vars['post_type']) {
222 222
 
223 223
 		// If an author ID was passed, use it
224
-		if ( isset( $_REQUEST['author'] ) && ! current_user_can( 'view_give_reports' ) ) {
224
+		if (isset($_REQUEST['author']) && ! current_user_can('view_give_reports')) {
225 225
 
226 226
 			$author_id = $_REQUEST['author'];
227
-			if ( (int) $author_id !== get_current_user_id() ) {
227
+			if ((int) $author_id !== get_current_user_id()) {
228 228
 				// Tried to view the products of another person, sorry
229
-				wp_die( esc_html__( 'You do not have permission to view this data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
229
+				wp_die(esc_html__('You do not have permission to view this data.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
230 230
 			}
231 231
 			$vars = array_merge(
232 232
 				$vars,
@@ -251,11 +251,11 @@  discard block
 block discarded – undo
251 251
  * @return void
252 252
  */
253 253
 function give_forms_load() {
254
-	add_filter( 'request', 'give_sort_forms' );
255
-	add_filter( 'request', 'give_filter_forms' );
254
+	add_filter('request', 'give_sort_forms');
255
+	add_filter('request', 'give_filter_forms');
256 256
 }
257 257
 
258
-add_action( 'load-edit.php', 'give_forms_load', 9999 );
258
+add_action('load-edit.php', 'give_forms_load', 9999);
259 259
 
260 260
 /**
261 261
  * Remove Forms Month Filter
@@ -269,17 +269,17 @@  discard block
 block discarded – undo
269 269
  * @global      $typenow The post type we are viewing
270 270
  * @return array Empty array disables the dropdown
271 271
  */
272
-function give_remove_month_filter( $dates ) {
272
+function give_remove_month_filter($dates) {
273 273
 	global $typenow;
274 274
 
275
-	if ( $typenow == 'give_forms' ) {
275
+	if ($typenow == 'give_forms') {
276 276
 		$dates = array();
277 277
 	}
278 278
 
279 279
 	return $dates;
280 280
 }
281 281
 
282
-add_filter( 'months_dropdown_results', 'give_remove_month_filter', 99 );
282
+add_filter('months_dropdown_results', 'give_remove_month_filter', 99);
283 283
 
284 284
 /**
285 285
  * Adds price field to Quick Edit options
@@ -291,8 +291,8 @@  discard block
 block discarded – undo
291 291
  *
292 292
  * @return void
293 293
  */
294
-function give_price_field_quick_edit( $column_name, $post_type ) {
295
-	if ( $column_name != 'price' || $post_type != 'give_forms' ) {
294
+function give_price_field_quick_edit($column_name, $post_type) {
295
+	if ($column_name != 'price' || $post_type != 'give_forms') {
296 296
 		return;
297 297
 	}
298 298
 	?>
@@ -301,12 +301,12 @@  discard block
 block discarded – undo
301 301
 			<h4><?php 
302 302
 				printf(
303 303
 					/* translators: %s: forms singular label */
304
-					esc_html__( '%s Configuration', 'give' ),
304
+					esc_html__('%s Configuration', 'give'),
305 305
 					give_get_forms_label_singular()
306 306
 				);
307 307
 			?></h4>
308 308
 			<label>
309
-				<span class="title"><?php esc_html_e( 'Price', 'give' ); ?></span>
309
+				<span class="title"><?php esc_html_e('Price', 'give'); ?></span>
310 310
 				<span class="input-text-wrap">
311 311
 					<input type="text" name="_give_regprice" class="text regprice" />
312 312
 				</span>
@@ -317,8 +317,8 @@  discard block
 block discarded – undo
317 317
 	<?php
318 318
 }
319 319
 
320
-add_action( 'quick_edit_custom_box', 'give_price_field_quick_edit', 10, 2 );
321
-add_action( 'bulk_edit_custom_box', 'give_price_field_quick_edit', 10, 2 );
320
+add_action('quick_edit_custom_box', 'give_price_field_quick_edit', 10, 2);
321
+add_action('bulk_edit_custom_box', 'give_price_field_quick_edit', 10, 2);
322 322
 
323 323
 /**
324 324
  * Updates price when saving post
@@ -329,23 +329,23 @@  discard block
 block discarded – undo
329 329
  *
330 330
  * @return void
331 331
  */
332
-function give_price_save_quick_edit( $post_id ) {
333
-	if ( ! isset( $_POST['post_type'] ) || 'give_forms' !== $_POST['post_type'] ) {
332
+function give_price_save_quick_edit($post_id) {
333
+	if ( ! isset($_POST['post_type']) || 'give_forms' !== $_POST['post_type']) {
334 334
 		return;
335 335
 	}
336
-	if ( ! current_user_can( 'edit_post', $post_id ) ) {
336
+	if ( ! current_user_can('edit_post', $post_id)) {
337 337
 		return $post_id;
338 338
 	}
339
-	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
339
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
340 340
 		return $post_id;
341 341
 	}
342 342
 
343
-	if ( isset( $_REQUEST['_give_regprice'] ) ) {
344
-		update_post_meta( $post_id, '_give_set_price', strip_tags( stripslashes( $_REQUEST['_give_regprice'] ) ) );
343
+	if (isset($_REQUEST['_give_regprice'])) {
344
+		update_post_meta($post_id, '_give_set_price', strip_tags(stripslashes($_REQUEST['_give_regprice'])));
345 345
 	}
346 346
 }
347 347
 
348
-add_action( 'save_post', 'give_price_save_quick_edit' );
348
+add_action('save_post', 'give_price_save_quick_edit');
349 349
 
350 350
 /**
351 351
  * Process bulk edit actions via AJAX
@@ -355,18 +355,18 @@  discard block
 block discarded – undo
355 355
  */
356 356
 function give_save_bulk_edit() {
357 357
 
358
-	$post_ids = ( isset( $_POST['post_ids'] ) && ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array();
358
+	$post_ids = (isset($_POST['post_ids']) && ! empty($_POST['post_ids'])) ? $_POST['post_ids'] : array();
359 359
 
360
-	if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
361
-		$price = isset( $_POST['price'] ) ? strip_tags( stripslashes( $_POST['price'] ) ) : 0;
362
-		foreach ( $post_ids as $post_id ) {
360
+	if ( ! empty($post_ids) && is_array($post_ids)) {
361
+		$price = isset($_POST['price']) ? strip_tags(stripslashes($_POST['price'])) : 0;
362
+		foreach ($post_ids as $post_id) {
363 363
 
364
-			if ( ! current_user_can( 'edit_post', $post_id ) ) {
364
+			if ( ! current_user_can('edit_post', $post_id)) {
365 365
 				continue;
366 366
 			}
367 367
 
368
-			if ( ! empty( $price ) ) {
369
-				update_post_meta( $post_id, '_give_set_price', give_sanitize_amount( $price ) );
368
+			if ( ! empty($price)) {
369
+				update_post_meta($post_id, '_give_set_price', give_sanitize_amount($price));
370 370
 			}
371 371
 		}
372 372
 	}
@@ -374,4 +374,4 @@  discard block
 block discarded – undo
374 374
 	die();
375 375
 }
376 376
 
377
-add_action( 'wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit' );
377
+add_action('wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit');
Please login to merge, or discard this patch.