Completed
Pull Request — master (#740)
by
unknown
16:38
created
includes/admin/EDD_SL_Plugin_Updater.php 2 patches
Indentation   +255 added lines, -255 removed lines patch added patch discarded remove patch
@@ -13,328 +13,328 @@
 block discarded – undo
13 13
  * @version 1.6
14 14
  */
15 15
 class EDD_SL_Plugin_Updater {
16
-    private $api_url   = '';
17
-    private $api_data  = array();
18
-    private $name      = '';
19
-    private $slug      = '';
20
-
21
-    /**
22
-     * Class constructor.
23
-     *
24
-     * @uses plugin_basename()
25
-     * @uses hook()
26
-     *
27
-     * @param string  $_api_url     The URL pointing to the custom API endpoint.
28
-     * @param string  $_plugin_file Path to the plugin file.
29
-     * @param array   $_api_data    Optional data to send with API calls.
30
-     * @return void
31
-     */
32
-    function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
33
-        $this->api_url  = trailingslashit( $_api_url );
34
-        $this->api_data = $_api_data;
35
-        $this->name     = plugin_basename( $_plugin_file );
36
-        $this->slug     = basename( $_plugin_file, '.php' );
37
-        $this->version  = $_api_data['version'];
38
-
39
-        // Set up hooks.
40
-        $this->init();
41
-        add_action( 'admin_init', array( $this, 'show_changelog' ) );
42
-    }
43
-
44
-    /**
45
-     * Set up WordPress filters to hook into WP's update process.
46
-     *
47
-     * @uses add_filter()
48
-     *
49
-     * @return void
50
-     */
51
-    public function init() {
16
+	private $api_url   = '';
17
+	private $api_data  = array();
18
+	private $name      = '';
19
+	private $slug      = '';
20
+
21
+	/**
22
+	 * Class constructor.
23
+	 *
24
+	 * @uses plugin_basename()
25
+	 * @uses hook()
26
+	 *
27
+	 * @param string  $_api_url     The URL pointing to the custom API endpoint.
28
+	 * @param string  $_plugin_file Path to the plugin file.
29
+	 * @param array   $_api_data    Optional data to send with API calls.
30
+	 * @return void
31
+	 */
32
+	function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
33
+		$this->api_url  = trailingslashit( $_api_url );
34
+		$this->api_data = $_api_data;
35
+		$this->name     = plugin_basename( $_plugin_file );
36
+		$this->slug     = basename( $_plugin_file, '.php' );
37
+		$this->version  = $_api_data['version'];
38
+
39
+		// Set up hooks.
40
+		$this->init();
41
+		add_action( 'admin_init', array( $this, 'show_changelog' ) );
42
+	}
43
+
44
+	/**
45
+	 * Set up WordPress filters to hook into WP's update process.
46
+	 *
47
+	 * @uses add_filter()
48
+	 *
49
+	 * @return void
50
+	 */
51
+	public function init() {
52 52
 
53
-        add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
54
-        add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
53
+		add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
54
+		add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
55 55
 
56
-        add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
57
-    }
56
+		add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
57
+	}
58 58
 
59
-    /**
60
-     * Check for Updates at the defined API endpoint and modify the update array.
61
-     *
62
-     * This function dives into the update API just when WordPress creates its update array,
63
-     * then adds a custom API call and injects the custom plugin data retrieved from the API.
64
-     * It is reassembled from parts of the native WordPress plugin update code.
65
-     * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
66
-     *
67
-     * @uses api_request()
68
-     *
69
-     * @param array   $_transient_data Update array build by WordPress.
70
-     * @return array Modified update array with custom plugin data.
71
-     */
72
-    function check_update( $_transient_data ) {
59
+	/**
60
+	 * Check for Updates at the defined API endpoint and modify the update array.
61
+	 *
62
+	 * This function dives into the update API just when WordPress creates its update array,
63
+	 * then adds a custom API call and injects the custom plugin data retrieved from the API.
64
+	 * It is reassembled from parts of the native WordPress plugin update code.
65
+	 * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
66
+	 *
67
+	 * @uses api_request()
68
+	 *
69
+	 * @param array   $_transient_data Update array build by WordPress.
70
+	 * @return array Modified update array with custom plugin data.
71
+	 */
72
+	function check_update( $_transient_data ) {
73 73
 
74
-        global $pagenow;
74
+		global $pagenow;
75 75
 
76
-        if( ! is_object( $_transient_data ) ) {
77
-            $_transient_data = new stdClass;
78
-        }
76
+		if( ! is_object( $_transient_data ) ) {
77
+			$_transient_data = new stdClass;
78
+		}
79 79
 
80
-        if( 'plugins.php' == $pagenow && is_multisite() ) {
81
-            return $_transient_data;
82
-        }
80
+		if( 'plugins.php' == $pagenow && is_multisite() ) {
81
+			return $_transient_data;
82
+		}
83 83
 
84
-        if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) {
84
+		if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) {
85 85
 
86
-            $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
86
+			$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
87 87
 
88
-            if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
88
+			if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
89 89
 
90
-                $this->did_check = true;
90
+				$this->did_check = true;
91 91
 
92
-                if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
92
+				if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
93 93
 
94
-                    $_transient_data->response[ $this->name ] = $version_info;
94
+					$_transient_data->response[ $this->name ] = $version_info;
95 95
 
96
-                }
96
+				}
97 97
 
98
-                $_transient_data->last_checked = time();
99
-                $_transient_data->checked[ $this->name ] = $this->version;
98
+				$_transient_data->last_checked = time();
99
+				$_transient_data->checked[ $this->name ] = $this->version;
100 100
 
101
-            }
101
+			}
102 102
 
103
-        }
103
+		}
104 104
 
105
-        return $_transient_data;
106
-    }
105
+		return $_transient_data;
106
+	}
107 107
 
108
-    /**
109
-     * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
110
-     *
111
-     * @param string  $file
112
-     * @param array   $plugin
113
-     */
114
-    public function show_update_notification( $file, $plugin ) {
108
+	/**
109
+	 * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
110
+	 *
111
+	 * @param string  $file
112
+	 * @param array   $plugin
113
+	 */
114
+	public function show_update_notification( $file, $plugin ) {
115 115
 
116
-        if( ! current_user_can( 'update_plugins' ) ) {
117
-            return;
118
-        }
116
+		if( ! current_user_can( 'update_plugins' ) ) {
117
+			return;
118
+		}
119 119
 
120
-        if( ! is_multisite() ) {
121
-            return;
122
-        }
120
+		if( ! is_multisite() ) {
121
+			return;
122
+		}
123 123
 
124
-        if ( $this->name != $file ) {
125
-            return;
126
-        }
124
+		if ( $this->name != $file ) {
125
+			return;
126
+		}
127 127
 
128
-        // Remove our filter on the site transient
129
-        remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
128
+		// Remove our filter on the site transient
129
+		remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
130 130
 
131
-        $update_cache = get_site_transient( 'update_plugins' );
131
+		$update_cache = get_site_transient( 'update_plugins' );
132 132
 
133
-        if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
133
+		if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
134 134
 
135
-            $cache_key    = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' );
136
-            $version_info = get_transient( $cache_key );
135
+			$cache_key    = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' );
136
+			$version_info = get_transient( $cache_key );
137 137
 
138
-            if( false === $version_info ) {
138
+			if( false === $version_info ) {
139 139
 
140
-                $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
140
+				$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
141 141
 
142
-                set_transient( $cache_key, $version_info, 3600 );
143
-            }
142
+				set_transient( $cache_key, $version_info, 3600 );
143
+			}
144 144
 
145 145
 
146
-            if( ! is_object( $version_info ) ) {
147
-                return;
148
-            }
146
+			if( ! is_object( $version_info ) ) {
147
+				return;
148
+			}
149 149
 
150
-            if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
150
+			if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
151 151
 
152
-                $update_cache->response[ $this->name ] = $version_info;
152
+				$update_cache->response[ $this->name ] = $version_info;
153 153
 
154
-            }
154
+			}
155 155
 
156
-            $update_cache->last_checked = time();
157
-            $update_cache->checked[ $this->name ] = $this->version;
156
+			$update_cache->last_checked = time();
157
+			$update_cache->checked[ $this->name ] = $this->version;
158 158
 
159
-            set_site_transient( 'update_plugins', $update_cache );
159
+			set_site_transient( 'update_plugins', $update_cache );
160 160
 
161
-        } else {
161
+		} else {
162 162
 
163
-            $version_info = $update_cache->response[ $this->name ];
163
+			$version_info = $update_cache->response[ $this->name ];
164 164
 
165
-        }
165
+		}
166 166
 
167
-        // Restore our filter
168
-        add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
167
+		// Restore our filter
168
+		add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
169 169
 
170
-        if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
170
+		if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
171 171
 
172
-            // build a plugin list row, with update notification
173
-            $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
174
-            echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
172
+			// build a plugin list row, with update notification
173
+			$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
174
+			echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
175 175
 
176
-            $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
176
+			$changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
177 177
 
178
-            if ( empty( $version_info->download_link ) ) {
179
-                printf(
180
-                    __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ),
181
-                    esc_html( $version_info->name ),
182
-                    esc_url( $changelog_link ),
183
-                    esc_html( $version_info->new_version )
184
-                );
185
-            } else {
186
-                printf(
187
-                    __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd' ),
188
-                    esc_html( $version_info->name ),
189
-                    esc_url( $changelog_link ),
190
-                    esc_html( $version_info->new_version ),
191
-                    esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) )
192
-                );
193
-            }
178
+			if ( empty( $version_info->download_link ) ) {
179
+				printf(
180
+					__( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ),
181
+					esc_html( $version_info->name ),
182
+					esc_url( $changelog_link ),
183
+					esc_html( $version_info->new_version )
184
+				);
185
+			} else {
186
+				printf(
187
+					__( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd' ),
188
+					esc_html( $version_info->name ),
189
+					esc_url( $changelog_link ),
190
+					esc_html( $version_info->new_version ),
191
+					esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) )
192
+				);
193
+			}
194 194
 
195
-            echo '</div></td></tr>';
196
-        }
197
-    }
195
+			echo '</div></td></tr>';
196
+		}
197
+	}
198 198
 
199 199
 
200
-    /**
201
-     * Updates information on the "View version x.x details" page with custom data.
202
-     *
203
-     * @uses api_request()
204
-     *
205
-     * @param mixed   $_data
206
-     * @param string  $_action
207
-     * @param object  $_args
208
-     * @return object $_data
209
-     */
210
-    function plugins_api_filter( $_data, $_action = '', $_args = null ) {
200
+	/**
201
+	 * Updates information on the "View version x.x details" page with custom data.
202
+	 *
203
+	 * @uses api_request()
204
+	 *
205
+	 * @param mixed   $_data
206
+	 * @param string  $_action
207
+	 * @param object  $_args
208
+	 * @return object $_data
209
+	 */
210
+	function plugins_api_filter( $_data, $_action = '', $_args = null ) {
211 211
 
212 212
 
213
-        if ( $_action != 'plugin_information' ) {
213
+		if ( $_action != 'plugin_information' ) {
214 214
 
215
-            return $_data;
215
+			return $_data;
216 216
 
217
-        }
217
+		}
218 218
 
219
-        if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
219
+		if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
220 220
 
221
-            return $_data;
221
+			return $_data;
222 222
 
223
-        }
223
+		}
224 224
 
225
-        $to_send = array(
226
-            'slug'   => $this->slug,
227
-            'is_ssl' => is_ssl(),
228
-            'fields' => array(
229
-                'banners' => false, // These will be supported soon hopefully
230
-                'reviews' => false
231
-            )
232
-        );
225
+		$to_send = array(
226
+			'slug'   => $this->slug,
227
+			'is_ssl' => is_ssl(),
228
+			'fields' => array(
229
+				'banners' => false, // These will be supported soon hopefully
230
+				'reviews' => false
231
+			)
232
+		);
233 233
 
234
-        $api_response = $this->api_request( 'plugin_information', $to_send );
234
+		$api_response = $this->api_request( 'plugin_information', $to_send );
235 235
 
236
-        if ( false !== $api_response ) {
237
-            $_data = $api_response;
238
-        }
236
+		if ( false !== $api_response ) {
237
+			$_data = $api_response;
238
+		}
239 239
 
240
-        return $_data;
241
-    }
240
+		return $_data;
241
+	}
242 242
 
243 243
 
244
-    /**
245
-     * Disable SSL verification in order to prevent download update failures
246
-     *
247
-     * @param array   $args
248
-     * @param string  $url
249
-     * @return object $array
250
-     */
251
-    function http_request_args( $args, $url ) {
252
-        // If it is an https request and we are performing a package download, disable ssl verification
253
-        if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
254
-            $args['sslverify'] = false;
255
-        }
256
-        return $args;
257
-    }
244
+	/**
245
+	 * Disable SSL verification in order to prevent download update failures
246
+	 *
247
+	 * @param array   $args
248
+	 * @param string  $url
249
+	 * @return object $array
250
+	 */
251
+	function http_request_args( $args, $url ) {
252
+		// If it is an https request and we are performing a package download, disable ssl verification
253
+		if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
254
+			$args['sslverify'] = false;
255
+		}
256
+		return $args;
257
+	}
258 258
 
259
-    /**
260
-     * Calls the API and, if successfull, returns the object delivered by the API.
261
-     *
262
-     * @uses get_bloginfo()
263
-     * @uses wp_remote_post()
264
-     * @uses is_wp_error()
265
-     *
266
-     * @param string  $_action The requested action.
267
-     * @param array   $_data   Parameters for the API action.
268
-     * @return false||object
269
-     */
270
-    private function api_request( $_action, $_data ) {
271
-
272
-        global $wp_version;
273
-
274
-        $data = array_merge( $this->api_data, $_data );
275
-
276
-        if ( $data['slug'] != $this->slug )
277
-            return;
278
-
279
-        if ( empty( $data['license'] ) )
280
-            return;
281
-
282
-        if( $this->api_url == home_url() ) {
283
-            return false; // Don't allow a plugin to ping itself
284
-        }
285
-
286
-        $api_params = array(
287
-            'edd_action' => 'get_version',
288
-            'license'    => $data['license'],
289
-            'item_name'  => isset( $data['item_name'] ) ? $data['item_name'] : false,
290
-            'item_id'    => isset( $data['item_id'] ) ? $data['item_id'] : false,
291
-            'slug'       => $data['slug'],
292
-            'author'     => $data['author'],
293
-            'url'        => home_url()
294
-        );
259
+	/**
260
+	 * Calls the API and, if successfull, returns the object delivered by the API.
261
+	 *
262
+	 * @uses get_bloginfo()
263
+	 * @uses wp_remote_post()
264
+	 * @uses is_wp_error()
265
+	 *
266
+	 * @param string  $_action The requested action.
267
+	 * @param array   $_data   Parameters for the API action.
268
+	 * @return false||object
269
+	 */
270
+	private function api_request( $_action, $_data ) {
271
+
272
+		global $wp_version;
273
+
274
+		$data = array_merge( $this->api_data, $_data );
275
+
276
+		if ( $data['slug'] != $this->slug )
277
+			return;
278
+
279
+		if ( empty( $data['license'] ) )
280
+			return;
281
+
282
+		if( $this->api_url == home_url() ) {
283
+			return false; // Don't allow a plugin to ping itself
284
+		}
285
+
286
+		$api_params = array(
287
+			'edd_action' => 'get_version',
288
+			'license'    => $data['license'],
289
+			'item_name'  => isset( $data['item_name'] ) ? $data['item_name'] : false,
290
+			'item_id'    => isset( $data['item_id'] ) ? $data['item_id'] : false,
291
+			'slug'       => $data['slug'],
292
+			'author'     => $data['author'],
293
+			'url'        => home_url()
294
+		);
295 295
 
296
-        $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
296
+		$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
297 297
 
298
-        if ( ! is_wp_error( $request ) ) {
299
-            $request = json_decode( wp_remote_retrieve_body( $request ) );
300
-        }
298
+		if ( ! is_wp_error( $request ) ) {
299
+			$request = json_decode( wp_remote_retrieve_body( $request ) );
300
+		}
301 301
 
302
-        if ( $request && isset( $request->sections ) ) {
303
-            $request->sections = maybe_unserialize( $request->sections );
304
-        } else {
305
-            $request = false;
306
-        }
302
+		if ( $request && isset( $request->sections ) ) {
303
+			$request->sections = maybe_unserialize( $request->sections );
304
+		} else {
305
+			$request = false;
306
+		}
307 307
 
308
-        return $request;
309
-    }
308
+		return $request;
309
+	}
310 310
 
311
-    public function show_changelog() {
311
+	public function show_changelog() {
312 312
 
313 313
 
314
-        if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
315
-            return;
316
-        }
314
+		if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
315
+			return;
316
+		}
317 317
 
318
-        if( empty( $_REQUEST['plugin'] ) ) {
319
-            return;
320
-        }
321
-
322
-        if( empty( $_REQUEST['slug'] ) ) {
323
-            return;
324
-        }
325
-
326
-        if( ! current_user_can( 'update_plugins' ) ) {
327
-            wp_die( __( 'You do not have permission to install plugin updates.', 'edd' ), __( 'Error', 'edd' ), array( 'response' => 403 ) );
328
-        }
329
-
330
-        $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) );
331
-
332
-        if( $response && isset( $response->sections['changelog'] ) ) {
333
-            echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
334
-        }
335
-
336
-
337
-        exit;
338
-    }
318
+		if( empty( $_REQUEST['plugin'] ) ) {
319
+			return;
320
+		}
321
+
322
+		if( empty( $_REQUEST['slug'] ) ) {
323
+			return;
324
+		}
325
+
326
+		if( ! current_user_can( 'update_plugins' ) ) {
327
+			wp_die( __( 'You do not have permission to install plugin updates.', 'edd' ), __( 'Error', 'edd' ), array( 'response' => 403 ) );
328
+		}
329
+
330
+		$response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) );
331
+
332
+		if( $response && isset( $response->sections['changelog'] ) ) {
333
+			echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
334
+		}
335
+
336
+
337
+		exit;
338
+	}
339 339
 
340 340
 }
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 //set_site_transient( 'update_plugins', null );
5 5
 
6 6
 // Exit if accessed directly
7
-if ( ! defined( 'ABSPATH' ) ) exit;
7
+if ( ! defined('ABSPATH')) exit;
8 8
 
9 9
 /**
10 10
  * Allows plugins to use their own update API.
@@ -29,16 +29,16 @@  discard block
 block discarded – undo
29 29
      * @param array   $_api_data    Optional data to send with API calls.
30 30
      * @return void
31 31
      */
32
-    function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
33
-        $this->api_url  = trailingslashit( $_api_url );
32
+    function __construct($_api_url, $_plugin_file, $_api_data = null) {
33
+        $this->api_url  = trailingslashit($_api_url);
34 34
         $this->api_data = $_api_data;
35
-        $this->name     = plugin_basename( $_plugin_file );
36
-        $this->slug     = basename( $_plugin_file, '.php' );
35
+        $this->name     = plugin_basename($_plugin_file);
36
+        $this->slug     = basename($_plugin_file, '.php');
37 37
         $this->version  = $_api_data['version'];
38 38
 
39 39
         // Set up hooks.
40 40
         $this->init();
41
-        add_action( 'admin_init', array( $this, 'show_changelog' ) );
41
+        add_action('admin_init', array($this, 'show_changelog'));
42 42
     }
43 43
 
44 44
     /**
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function init() {
52 52
 
53
-        add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
54
-        add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
53
+        add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
54
+        add_filter('plugins_api', array($this, 'plugins_api_filter'), 10, 3);
55 55
 
56
-        add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
56
+        add_action('after_plugin_row_'.$this->name, array($this, 'show_update_notification'), 10, 2);
57 57
     }
58 58
 
59 59
     /**
@@ -69,34 +69,34 @@  discard block
 block discarded – undo
69 69
      * @param array   $_transient_data Update array build by WordPress.
70 70
      * @return array Modified update array with custom plugin data.
71 71
      */
72
-    function check_update( $_transient_data ) {
72
+    function check_update($_transient_data) {
73 73
 
74 74
         global $pagenow;
75 75
 
76
-        if( ! is_object( $_transient_data ) ) {
76
+        if ( ! is_object($_transient_data)) {
77 77
             $_transient_data = new stdClass;
78 78
         }
79 79
 
80
-        if( 'plugins.php' == $pagenow && is_multisite() ) {
80
+        if ('plugins.php' == $pagenow && is_multisite()) {
81 81
             return $_transient_data;
82 82
         }
83 83
 
84
-        if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) {
84
+        if (empty($_transient_data->response) || empty($_transient_data->response[$this->name])) {
85 85
 
86
-            $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
86
+            $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug));
87 87
 
88
-            if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
88
+            if (false !== $version_info && is_object($version_info) && isset($version_info->new_version)) {
89 89
 
90 90
                 $this->did_check = true;
91 91
 
92
-                if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
92
+                if (version_compare($this->version, $version_info->new_version, '<')) {
93 93
 
94
-                    $_transient_data->response[ $this->name ] = $version_info;
94
+                    $_transient_data->response[$this->name] = $version_info;
95 95
 
96 96
                 }
97 97
 
98 98
                 $_transient_data->last_checked = time();
99
-                $_transient_data->checked[ $this->name ] = $this->version;
99
+                $_transient_data->checked[$this->name] = $this->version;
100 100
 
101 101
             }
102 102
 
@@ -111,84 +111,84 @@  discard block
 block discarded – undo
111 111
      * @param string  $file
112 112
      * @param array   $plugin
113 113
      */
114
-    public function show_update_notification( $file, $plugin ) {
114
+    public function show_update_notification($file, $plugin) {
115 115
 
116
-        if( ! current_user_can( 'update_plugins' ) ) {
116
+        if ( ! current_user_can('update_plugins')) {
117 117
             return;
118 118
         }
119 119
 
120
-        if( ! is_multisite() ) {
120
+        if ( ! is_multisite()) {
121 121
             return;
122 122
         }
123 123
 
124
-        if ( $this->name != $file ) {
124
+        if ($this->name != $file) {
125 125
             return;
126 126
         }
127 127
 
128 128
         // Remove our filter on the site transient
129
-        remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
129
+        remove_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'), 10);
130 130
 
131
-        $update_cache = get_site_transient( 'update_plugins' );
131
+        $update_cache = get_site_transient('update_plugins');
132 132
 
133
-        if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
133
+        if ( ! is_object($update_cache) || empty($update_cache->response) || empty($update_cache->response[$this->name])) {
134 134
 
135
-            $cache_key    = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' );
136
-            $version_info = get_transient( $cache_key );
135
+            $cache_key    = md5('edd_plugin_'.sanitize_key($this->name).'_version_info');
136
+            $version_info = get_transient($cache_key);
137 137
 
138
-            if( false === $version_info ) {
138
+            if (false === $version_info) {
139 139
 
140
-                $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
140
+                $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug));
141 141
 
142
-                set_transient( $cache_key, $version_info, 3600 );
142
+                set_transient($cache_key, $version_info, 3600);
143 143
             }
144 144
 
145 145
 
146
-            if( ! is_object( $version_info ) ) {
146
+            if ( ! is_object($version_info)) {
147 147
                 return;
148 148
             }
149 149
 
150
-            if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
150
+            if (version_compare($this->version, $version_info->new_version, '<')) {
151 151
 
152
-                $update_cache->response[ $this->name ] = $version_info;
152
+                $update_cache->response[$this->name] = $version_info;
153 153
 
154 154
             }
155 155
 
156 156
             $update_cache->last_checked = time();
157
-            $update_cache->checked[ $this->name ] = $this->version;
157
+            $update_cache->checked[$this->name] = $this->version;
158 158
 
159
-            set_site_transient( 'update_plugins', $update_cache );
159
+            set_site_transient('update_plugins', $update_cache);
160 160
 
161 161
         } else {
162 162
 
163
-            $version_info = $update_cache->response[ $this->name ];
163
+            $version_info = $update_cache->response[$this->name];
164 164
 
165 165
         }
166 166
 
167 167
         // Restore our filter
168
-        add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
168
+        add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
169 169
 
170
-        if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
170
+        if ( ! empty($update_cache->response[$this->name]) && version_compare($this->version, $version_info->new_version, '<')) {
171 171
 
172 172
             // build a plugin list row, with update notification
173
-            $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
174
-            echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
173
+            $wp_list_table = _get_list_table('WP_Plugins_List_Table');
174
+            echo '<tr class="plugin-update-tr"><td colspan="'.$wp_list_table->get_column_count().'" class="plugin-update colspanchange"><div class="update-message">';
175 175
 
176
-            $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
176
+            $changelog_link = self_admin_url('index.php?edd_sl_action=view_plugin_changelog&plugin='.$this->name.'&slug='.$this->slug.'&TB_iframe=true&width=772&height=911');
177 177
 
178
-            if ( empty( $version_info->download_link ) ) {
178
+            if (empty($version_info->download_link)) {
179 179
                 printf(
180
-                    __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ),
181
-                    esc_html( $version_info->name ),
182
-                    esc_url( $changelog_link ),
183
-                    esc_html( $version_info->new_version )
180
+                    __('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd'),
181
+                    esc_html($version_info->name),
182
+                    esc_url($changelog_link),
183
+                    esc_html($version_info->new_version)
184 184
                 );
185 185
             } else {
186 186
                 printf(
187
-                    __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd' ),
188
-                    esc_html( $version_info->name ),
189
-                    esc_url( $changelog_link ),
190
-                    esc_html( $version_info->new_version ),
191
-                    esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) )
187
+                    __('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd'),
188
+                    esc_html($version_info->name),
189
+                    esc_url($changelog_link),
190
+                    esc_html($version_info->new_version),
191
+                    esc_url(wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$this->name, 'upgrade-plugin_'.$this->name))
192 192
                 );
193 193
             }
194 194
 
@@ -207,16 +207,16 @@  discard block
 block discarded – undo
207 207
      * @param object  $_args
208 208
      * @return object $_data
209 209
      */
210
-    function plugins_api_filter( $_data, $_action = '', $_args = null ) {
210
+    function plugins_api_filter($_data, $_action = '', $_args = null) {
211 211
 
212 212
 
213
-        if ( $_action != 'plugin_information' ) {
213
+        if ($_action != 'plugin_information') {
214 214
 
215 215
             return $_data;
216 216
 
217 217
         }
218 218
 
219
-        if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
219
+        if ( ! isset($_args->slug) || ($_args->slug != $this->slug)) {
220 220
 
221 221
             return $_data;
222 222
 
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
             )
232 232
         );
233 233
 
234
-        $api_response = $this->api_request( 'plugin_information', $to_send );
234
+        $api_response = $this->api_request('plugin_information', $to_send);
235 235
 
236
-        if ( false !== $api_response ) {
236
+        if (false !== $api_response) {
237 237
             $_data = $api_response;
238 238
         }
239 239
 
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
      * @param string  $url
249 249
      * @return object $array
250 250
      */
251
-    function http_request_args( $args, $url ) {
251
+    function http_request_args($args, $url) {
252 252
         // If it is an https request and we are performing a package download, disable ssl verification
253
-        if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
253
+        if (strpos($url, 'https://') !== false && strpos($url, 'edd_action=package_download')) {
254 254
             $args['sslverify'] = false;
255 255
         }
256 256
         return $args;
@@ -267,40 +267,40 @@  discard block
 block discarded – undo
267 267
      * @param array   $_data   Parameters for the API action.
268 268
      * @return false||object
269 269
      */
270
-    private function api_request( $_action, $_data ) {
270
+    private function api_request($_action, $_data) {
271 271
 
272 272
         global $wp_version;
273 273
 
274
-        $data = array_merge( $this->api_data, $_data );
274
+        $data = array_merge($this->api_data, $_data);
275 275
 
276
-        if ( $data['slug'] != $this->slug )
276
+        if ($data['slug'] != $this->slug)
277 277
             return;
278 278
 
279
-        if ( empty( $data['license'] ) )
279
+        if (empty($data['license']))
280 280
             return;
281 281
 
282
-        if( $this->api_url == home_url() ) {
282
+        if ($this->api_url == home_url()) {
283 283
             return false; // Don't allow a plugin to ping itself
284 284
         }
285 285
 
286 286
         $api_params = array(
287 287
             'edd_action' => 'get_version',
288 288
             'license'    => $data['license'],
289
-            'item_name'  => isset( $data['item_name'] ) ? $data['item_name'] : false,
290
-            'item_id'    => isset( $data['item_id'] ) ? $data['item_id'] : false,
289
+            'item_name'  => isset($data['item_name']) ? $data['item_name'] : false,
290
+            'item_id'    => isset($data['item_id']) ? $data['item_id'] : false,
291 291
             'slug'       => $data['slug'],
292 292
             'author'     => $data['author'],
293 293
             'url'        => home_url()
294 294
         );
295 295
 
296
-        $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
296
+        $request = wp_remote_post($this->api_url, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params));
297 297
 
298
-        if ( ! is_wp_error( $request ) ) {
299
-            $request = json_decode( wp_remote_retrieve_body( $request ) );
298
+        if ( ! is_wp_error($request)) {
299
+            $request = json_decode(wp_remote_retrieve_body($request));
300 300
         }
301 301
 
302
-        if ( $request && isset( $request->sections ) ) {
303
-            $request->sections = maybe_unserialize( $request->sections );
302
+        if ($request && isset($request->sections)) {
303
+            $request->sections = maybe_unserialize($request->sections);
304 304
         } else {
305 305
             $request = false;
306 306
         }
@@ -311,26 +311,26 @@  discard block
 block discarded – undo
311 311
     public function show_changelog() {
312 312
 
313 313
 
314
-        if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
314
+        if (empty($_REQUEST['edd_sl_action']) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action']) {
315 315
             return;
316 316
         }
317 317
 
318
-        if( empty( $_REQUEST['plugin'] ) ) {
318
+        if (empty($_REQUEST['plugin'])) {
319 319
             return;
320 320
         }
321 321
 
322
-        if( empty( $_REQUEST['slug'] ) ) {
322
+        if (empty($_REQUEST['slug'])) {
323 323
             return;
324 324
         }
325 325
 
326
-        if( ! current_user_can( 'update_plugins' ) ) {
327
-            wp_die( __( 'You do not have permission to install plugin updates.', 'edd' ), __( 'Error', 'edd' ), array( 'response' => 403 ) );
326
+        if ( ! current_user_can('update_plugins')) {
327
+            wp_die(__('You do not have permission to install plugin updates.', 'edd'), __('Error', 'edd'), array('response' => 403));
328 328
         }
329 329
 
330
-        $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) );
330
+        $response = $this->api_request('plugin_latest_version', array('slug' => $_REQUEST['slug']));
331 331
 
332
-        if( $response && isset( $response->sections['changelog'] ) ) {
333
-            echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
332
+        if ($response && isset($response->sections['changelog'])) {
333
+            echo '<div style="background:#fff;padding:10px;">'.$response->sections['changelog'].'</div>';
334 334
         }
335 335
 
336 336
 
Please login to merge, or discard this patch.
includes/admin/class-admin-notices.php 1 patch
Spacing   +49 added lines, -49 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,9 +27,9 @@  discard block
 block discarded – undo
27 27
 	 * @since 1.0
28 28
 	 */
29 29
 	public function __construct() {
30
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
31
-		add_action( 'give_dismiss_notices', array( $this, 'dismiss_notices' ) );
32
-		add_action( 'admin_bar_menu', array( $this, 'give_admin_bar_menu' ), 1000 );
30
+		add_action('admin_notices', array($this, 'show_notices'));
31
+		add_action('give_dismiss_notices', array($this, 'dismiss_notices'));
32
+		add_action('admin_bar_menu', array($this, 'give_admin_bar_menu'), 1000);
33 33
 	}
34 34
 
35 35
 
@@ -42,18 +42,18 @@  discard block
 block discarded – undo
42 42
 	public function give_admin_bar_menu() {
43 43
 		global $wp_admin_bar;
44 44
 
45
-		if ( ! give_is_test_mode() || ! current_user_can( 'view_give_reports' ) ) {
45
+		if ( ! give_is_test_mode() || ! current_user_can('view_give_reports')) {
46 46
 			return false;
47 47
 		}
48 48
 
49 49
 		//Add the main siteadmin menu item
50
-		$wp_admin_bar->add_menu( array(
50
+		$wp_admin_bar->add_menu(array(
51 51
 			'id'     => 'give-test-notice',
52
-			'href'   => admin_url() . 'edit.php?post_type=give_forms&page=give-settings&tab=gateways',
52
+			'href'   => admin_url().'edit.php?post_type=give_forms&page=give-settings&tab=gateways',
53 53
 			'parent' => 'top-secondary',
54
-			'title'  => __( 'Give Test Mode Active', 'give' ),
55
-			'meta'   => array( 'class' => 'give-test-mode-active' ),
56
-		) );
54
+			'title'  => __('Give Test Mode Active', 'give'),
55
+			'meta'   => array('class' => 'give-test-mode-active'),
56
+		));
57 57
 
58 58
 	}
59 59
 
@@ -68,97 +68,97 @@  discard block
 block discarded – undo
68 68
 			'error'   => array()
69 69
 		);
70 70
 
71
-		if ( ! give_test_ajax_works() && ! get_user_meta( get_current_user_id(), '_give_admin_ajax_inaccessible_dismissed', true ) && current_user_can( 'manage_give_settings' ) ) {
71
+		if ( ! give_test_ajax_works() && ! get_user_meta(get_current_user_id(), '_give_admin_ajax_inaccessible_dismissed', true) && current_user_can('manage_give_settings')) {
72 72
 			echo '<div class="error">';
73
-			echo '<p>' . __( 'Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give' ) . '</p>';
74
-			echo '<p>' . sprintf( esc_attr__( 'Please see %1$sthis reference%2$s for possible solutions.', 'give' ), '<a href="https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/" target="_blank">', '</a>' ) . '</p>';
75
-			echo '<p><a href="' . add_query_arg( array(
73
+			echo '<p>'.__('Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give').'</p>';
74
+			echo '<p>'.sprintf(esc_attr__('Please see %1$sthis reference%2$s for possible solutions.', 'give'), '<a href="https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/" target="_blank">', '</a>').'</p>';
75
+			echo '<p><a href="'.add_query_arg(array(
76 76
 					'give_action' => 'dismiss_notices',
77 77
 					'give_notice' => 'admin_ajax_inaccessible'
78
-				) ) . '">' . esc_attr__( 'Dismiss Notice', 'give' ) . '</a></p>';
78
+				)).'">'.esc_attr__('Dismiss Notice', 'give').'</a></p>';
79 79
 			echo '</div>';
80 80
 		}
81 81
 
82 82
 
83
-		if ( isset( $_GET['give-message'] ) ) {
83
+		if (isset($_GET['give-message'])) {
84 84
 
85 85
 			// Donation reports errors
86
-			if ( current_user_can( 'view_give_reports' ) ) {
87
-				switch ( $_GET['give-message'] ) {
86
+			if (current_user_can('view_give_reports')) {
87
+				switch ($_GET['give-message']) {
88 88
 					case 'payment_deleted' :
89
-						$notices['updated']['give-payment-deleted'] = esc_attr__( 'The payment has been deleted.', 'give' );
89
+						$notices['updated']['give-payment-deleted'] = esc_attr__('The payment has been deleted.', 'give');
90 90
 						break;
91 91
 					case 'email_sent' :
92
-						$notices['updated']['give-payment-sent'] = esc_attr__( 'The donation receipt has been resent.', 'give' );
92
+						$notices['updated']['give-payment-sent'] = esc_attr__('The donation receipt has been resent.', 'give');
93 93
 						break;
94 94
 					case 'refreshed-reports' :
95
-						$notices['updated']['give-refreshed-reports'] = esc_attr__( 'The reports cache has been cleared.', 'give' );
95
+						$notices['updated']['give-refreshed-reports'] = esc_attr__('The reports cache has been cleared.', 'give');
96 96
 						break;
97 97
 					case 'payment-note-deleted' :
98
-						$notices['updated']['give-payment-note-deleted'] = esc_attr__( 'The payment note has been deleted.', 'give' );
98
+						$notices['updated']['give-payment-note-deleted'] = esc_attr__('The payment note has been deleted.', 'give');
99 99
 						break;
100 100
 				}
101 101
 			}
102 102
 
103 103
 			// Give settings notices and errors
104
-			if ( current_user_can( 'manage_give_settings' ) ) {
105
-				switch ( $_GET['give-message'] ) {
104
+			if (current_user_can('manage_give_settings')) {
105
+				switch ($_GET['give-message']) {
106 106
 					case 'settings-imported' :
107
-						$notices['updated']['give-settings-imported'] = esc_attr__( 'The settings have been imported.', 'give' );
107
+						$notices['updated']['give-settings-imported'] = esc_attr__('The settings have been imported.', 'give');
108 108
 						break;
109 109
 					case 'api-key-generated' :
110
-						$notices['updated']['give-api-key-generated'] = esc_attr__( 'API keys successfully generated.', 'give' );
110
+						$notices['updated']['give-api-key-generated'] = esc_attr__('API keys successfully generated.', 'give');
111 111
 						break;
112 112
 					case 'api-key-exists' :
113
-						$notices['error']['give-api-key-exists'] = esc_attr__( 'The specified user already has API keys.', 'give' );
113
+						$notices['error']['give-api-key-exists'] = esc_attr__('The specified user already has API keys.', 'give');
114 114
 						break;
115 115
 					case 'api-key-regenerated' :
116
-						$notices['updated']['give-api-key-regenerated'] = esc_attr__( 'API keys successfully regenerated.', 'give' );
116
+						$notices['updated']['give-api-key-regenerated'] = esc_attr__('API keys successfully regenerated.', 'give');
117 117
 						break;
118 118
 					case 'api-key-revoked' :
119
-						$notices['updated']['give-api-key-revoked'] = esc_attr__( 'API keys successfully revoked.', 'give' );
119
+						$notices['updated']['give-api-key-revoked'] = esc_attr__('API keys successfully revoked.', 'give');
120 120
 						break;
121 121
 					case 'sent-test-email' :
122
-						$notices['updated']['give-sent-test-email'] = esc_attr__( 'The test email has been sent.', 'give' );
122
+						$notices['updated']['give-sent-test-email'] = esc_attr__('The test email has been sent.', 'give');
123 123
 						break;
124 124
 				}
125 125
 			}
126 126
 			// Payments errors
127
-			if ( current_user_can( 'edit_give_payments' ) ) {
128
-				switch ( $_GET['give-message'] ) {
127
+			if (current_user_can('edit_give_payments')) {
128
+				switch ($_GET['give-message']) {
129 129
 					case 'note-added' :
130
-						$notices['updated']['give-note-added'] = esc_attr__( 'The payment note has been added successfully.', 'give' );
130
+						$notices['updated']['give-note-added'] = esc_attr__('The payment note has been added successfully.', 'give');
131 131
 						break;
132 132
 					case 'payment-updated' :
133
-						$notices['updated']['give-payment-updated'] = esc_attr__( 'The payment has been successfully updated.', 'give' );
133
+						$notices['updated']['give-payment-updated'] = esc_attr__('The payment has been successfully updated.', 'give');
134 134
 						break;
135 135
 				}
136 136
 			}
137 137
 
138 138
 			// Customer Notices
139
-			if ( current_user_can( 'edit_give_payments' ) ) {
140
-				switch ( $_GET['give-message'] ) {
139
+			if (current_user_can('edit_give_payments')) {
140
+				switch ($_GET['give-message']) {
141 141
 					case 'customer-deleted' :
142
-						$notices['updated']['give-customer-deleted'] = esc_attr__( 'Donor successfully deleted.', 'give' );
142
+						$notices['updated']['give-customer-deleted'] = esc_attr__('Donor successfully deleted.', 'give');
143 143
 						break;
144 144
 				}
145 145
 			}
146 146
 
147 147
 		}
148 148
 
149
-		if ( count( $notices['updated'] ) > 0 ) {
150
-			foreach ( $notices['updated'] as $notice => $message ) {
151
-				add_settings_error( 'give-notices', $notice, $message, 'updated' );
149
+		if (count($notices['updated']) > 0) {
150
+			foreach ($notices['updated'] as $notice => $message) {
151
+				add_settings_error('give-notices', $notice, $message, 'updated');
152 152
 			}
153 153
 		}
154 154
 
155
-		if ( count( $notices['error'] ) > 0 ) {
156
-			foreach ( $notices['error'] as $notice => $message ) {
157
-				add_settings_error( 'give-notices', $notice, $message, 'error' );
155
+		if (count($notices['error']) > 0) {
156
+			foreach ($notices['error'] as $notice => $message) {
157
+				add_settings_error('give-notices', $notice, $message, 'error');
158 158
 			}
159 159
 		}
160 160
 
161
-		settings_errors( 'give-notices' );
161
+		settings_errors('give-notices');
162 162
 
163 163
 	}
164 164
 
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 	 * @return void
171 171
 	 */
172 172
 	function give_admin_addons_notices() {
173
-		add_settings_error( 'give-notices', 'give-addons-feed-error', esc_attr__( 'There seems to be an issue with the server. Please try again in a few minutes.', 'give' ), 'error' );
174
-		settings_errors( 'give-notices' );
173
+		add_settings_error('give-notices', 'give-addons-feed-error', esc_attr__('There seems to be an issue with the server. Please try again in a few minutes.', 'give'), 'error');
174
+		settings_errors('give-notices');
175 175
 	}
176 176
 
177 177
 
@@ -182,9 +182,9 @@  discard block
 block discarded – undo
182 182
 	 * @return void
183 183
 	 */
184 184
 	function dismiss_notices() {
185
-		if ( isset( $_GET['give_notice'] ) ) {
186
-			update_user_meta( get_current_user_id(), '_give_' . $_GET['give_notice'] . '_dismissed', 1 );
187
-			wp_redirect( remove_query_arg( array( 'give_action', 'give_notice' ) ) );
185
+		if (isset($_GET['give_notice'])) {
186
+			update_user_meta(get_current_user_id(), '_give_'.$_GET['give_notice'].'_dismissed', 1);
187
+			wp_redirect(remove_query_arg(array('give_action', 'give_notice')));
188 188
 			exit;
189 189
 		}
190 190
 	}
Please login to merge, or discard this patch.
includes/admin/class-give-settings.php 1 patch
Spacing   +311 added lines, -311 removed lines patch added patch discarded remove patch
@@ -49,26 +49,26 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	public function __construct() {
51 51
 
52
-		add_action( 'admin_init', array( $this, 'init' ) );
52
+		add_action('admin_init', array($this, 'init'));
53 53
 
54 54
 		//Customize CMB2 URL
55
-		add_filter( 'cmb2_meta_box_url', array( $this, 'give_update_cmb_meta_box_url' ) );
55
+		add_filter('cmb2_meta_box_url', array($this, 'give_update_cmb_meta_box_url'));
56 56
 
57 57
 		//Custom CMB2 Settings Fields
58
-		add_action( 'cmb2_render_give_title', 'give_title_callback', 10, 5 );
59
-		add_action( 'cmb2_render_give_description', 'give_description_callback', 10, 5 );
60
-		add_action( 'cmb2_render_enabled_gateways', 'give_enabled_gateways_callback', 10, 5 );
61
-		add_action( 'cmb2_render_default_gateway', 'give_default_gateway_callback', 10, 5 );
62
-		add_action( 'cmb2_render_email_preview_buttons', 'give_email_preview_buttons_callback', 10, 5 );
63
-		add_action( 'cmb2_render_system_info', 'give_system_info_callback', 10, 5 );
64
-		add_action( 'cmb2_render_api', 'give_api_callback', 10, 5 );
65
-		add_action( 'cmb2_render_license_key', 'give_license_key_callback', 10, 5 );
66
-		add_action( 'admin_notices', array( $this, 'settings_notices' ) );
58
+		add_action('cmb2_render_give_title', 'give_title_callback', 10, 5);
59
+		add_action('cmb2_render_give_description', 'give_description_callback', 10, 5);
60
+		add_action('cmb2_render_enabled_gateways', 'give_enabled_gateways_callback', 10, 5);
61
+		add_action('cmb2_render_default_gateway', 'give_default_gateway_callback', 10, 5);
62
+		add_action('cmb2_render_email_preview_buttons', 'give_email_preview_buttons_callback', 10, 5);
63
+		add_action('cmb2_render_system_info', 'give_system_info_callback', 10, 5);
64
+		add_action('cmb2_render_api', 'give_api_callback', 10, 5);
65
+		add_action('cmb2_render_license_key', 'give_license_key_callback', 10, 5);
66
+		add_action('admin_notices', array($this, 'settings_notices'));
67 67
 
68 68
 		// Include CMB CSS in the head to avoid FOUC
69
-		add_action( 'admin_print_styles-give_forms_page_give-settings', array( 'CMB2_hookup', 'enqueue_cmb_css' ) );
69
+		add_action('admin_print_styles-give_forms_page_give-settings', array('CMB2_hookup', 'enqueue_cmb_css'));
70 70
 
71
-		add_filter( 'cmb2_get_metabox_form_format', array( $this, 'give_modify_cmb2_form_output' ), 10, 3 );
71
+		add_filter('cmb2_get_metabox_form_format', array($this, 'give_modify_cmb2_form_output'), 10, 3);
72 72
 
73 73
 	}
74 74
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @since  1.0
79 79
 	 */
80 80
 	public function init() {
81
-		register_setting( $this->key, $this->key );
81
+		register_setting($this->key, $this->key);
82 82
 
83 83
 	}
84 84
 
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return mixed
94 94
 	 */
95
-	public function give_update_cmb_meta_box_url( $url ) {
95
+	public function give_update_cmb_meta_box_url($url) {
96 96
 		//Path to Give's CMB
97
-		return GIVE_PLUGIN_URL . '/includes/libraries/cmb2';
97
+		return GIVE_PLUGIN_URL.'/includes/libraries/cmb2';
98 98
 	}
99 99
 
100 100
 
@@ -106,27 +106,27 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	public function give_get_settings_tabs() {
108 108
 
109
-		$settings = $this->give_settings( null );
109
+		$settings = $this->give_settings(null);
110 110
 
111 111
 		$tabs             = array();
112
-		$tabs['general']  = __( 'General', 'give' );
113
-		$tabs['gateways'] = __( 'Payment Gateways', 'give' );
114
-		$tabs['display']  = __( 'Display Options', 'give' );
115
-		$tabs['emails']   = __( 'Emails', 'give' );
112
+		$tabs['general']  = __('General', 'give');
113
+		$tabs['gateways'] = __('Payment Gateways', 'give');
114
+		$tabs['display']  = __('Display Options', 'give');
115
+		$tabs['emails']   = __('Emails', 'give');
116 116
 
117
-		if ( ! empty( $settings['addons']['fields'] ) ) {
118
-			$tabs['addons'] = __( 'Add-ons', 'give' );
117
+		if ( ! empty($settings['addons']['fields'])) {
118
+			$tabs['addons'] = __('Add-ons', 'give');
119 119
 		}
120 120
 
121
-		if ( ! empty( $settings['licenses']['fields'] ) ) {
122
-			$tabs['licenses'] = __( 'Licenses', 'give' );
121
+		if ( ! empty($settings['licenses']['fields'])) {
122
+			$tabs['licenses'] = __('Licenses', 'give');
123 123
 		}
124 124
 
125
-		$tabs['advanced']    = __( 'Advanced', 'give' );
126
-		$tabs['api']         = __( 'API', 'give' );
127
-		$tabs['system_info'] = __( 'System Info', 'give' );
125
+		$tabs['advanced']    = __('Advanced', 'give');
126
+		$tabs['api']         = __('API', 'give');
127
+		$tabs['system_info'] = __('System Info', 'give');
128 128
 
129
-		return apply_filters( 'give_settings_tabs', $tabs );
129
+		return apply_filters('give_settings_tabs', $tabs);
130 130
 	}
131 131
 
132 132
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 */
137 137
 	public function admin_page_display() {
138 138
 
139
-		$active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $this->give_get_settings_tabs() ) ? $_GET['tab'] : 'general';
139
+		$active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $this->give_get_settings_tabs()) ? $_GET['tab'] : 'general';
140 140
 
141 141
 		?>
142 142
 
@@ -144,20 +144,20 @@  discard block
 block discarded – undo
144 144
 
145 145
 			<h1 class="nav-tab-wrapper">
146 146
 				<?php
147
-				foreach ( $this->give_get_settings_tabs() as $tab_id => $tab_name ) {
147
+				foreach ($this->give_get_settings_tabs() as $tab_id => $tab_name) {
148 148
 
149 149
 					//Support legacy tab creation conditions based off $_GET parameter
150 150
 					//We pass the $_GET['tab'] to conditions executed later
151 151
 					$_GET['tab'] = $tab_id;
152 152
 
153
-					$tab_url = esc_url( add_query_arg( array(
153
+					$tab_url = esc_url(add_query_arg(array(
154 154
 						'settings-updated' => false,
155 155
 						'tab'              => $tab_id
156
-					) ) );
156
+					)));
157 157
 
158
-					$active       = $active_tab == $tab_id ? ' nav-tab-active' : '';
158
+					$active = $active_tab == $tab_id ? ' nav-tab-active' : '';
159 159
 
160
-					echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '" id="tab-' . $tab_id . '">' . esc_html( $tab_name ) . '</a>';
160
+					echo '<a href="'.esc_url($tab_url).'" title="'.esc_attr($tab_name).'" class="nav-tab'.$active.'" id="tab-'.$tab_id.'">'.esc_html($tab_name).'</a>';
161 161
 
162 162
 				}
163 163
 				?>
@@ -165,20 +165,20 @@  discard block
 block discarded – undo
165 165
 
166 166
 			<?php
167 167
 			//Loop through and output settings
168
-			foreach ( $this->give_get_settings_tabs() as $tab_id => $tab_name ) {
168
+			foreach ($this->give_get_settings_tabs() as $tab_id => $tab_name) {
169 169
 
170 170
 				//Support legacy tab creation conditions based off $_GET parameter
171 171
 				//We 'trick' the conditions into thinking this is the tab
172 172
 				$_GET['tab'] = $tab_id;
173 173
 
174
-				$tab_settings = $this->give_settings( $tab_id );
174
+				$tab_settings = $this->give_settings($tab_id);
175 175
 
176 176
 				//Pass active tab within $tab_settings so we can hide with CSS via PHP
177
-				if ( $active_tab == $tab_id ) {
177
+				if ($active_tab == $tab_id) {
178 178
 					$tab_settings['active_tab'] = true;
179 179
 				}
180 180
 
181
-				cmb2_metabox_form( $tab_settings, $this->key );
181
+				cmb2_metabox_form($tab_settings, $this->key);
182 182
 
183 183
 			} ?>
184 184
 
@@ -196,34 +196,34 @@  discard block
 block discarded – undo
196 196
 	 * @since 1.5 Modified to CSS hide non-active tabs
197 197
 	 * @since 1.0
198 198
 	 */
199
-	function give_modify_cmb2_form_output( $form_format, $object_id, $cmb ) {
199
+	function give_modify_cmb2_form_output($form_format, $object_id, $cmb) {
200 200
 
201 201
 
202
-		$pagenow = isset( $_GET['page'] ) ? $_GET['page'] : '';
202
+		$pagenow = isset($_GET['page']) ? $_GET['page'] : '';
203 203
 
204 204
 		//only modify the give settings form
205
-		if ( 'give_settings' == $object_id && $pagenow == 'give-settings' ) {
205
+		if ('give_settings' == $object_id && $pagenow == 'give-settings') {
206 206
 
207 207
 			$style = '';
208
-			if ( ! isset( $cmb->meta_box['active_tab'] ) ) {
208
+			if ( ! isset($cmb->meta_box['active_tab'])) {
209 209
 				$style = 'style="display:none;"';
210 210
 			}
211 211
 
212 212
 			//Set ID based off tab name - protects backwards compatibility
213
-			$tab_id = isset( $_GET['tab'] ) ? $_GET['tab'] : $cmb->meta_box['id'];
213
+			$tab_id = isset($_GET['tab']) ? $_GET['tab'] : $cmb->meta_box['id'];
214 214
 
215
-			$save_button = apply_filters( 'give_save_button_markup', '<div class="give-submit-wrap"><input type="submit" name="submit-cmb" value="' . __( 'Save Settings', 'give' ) . '" class="button-primary"></div>' );
215
+			$save_button = apply_filters('give_save_button_markup', '<div class="give-submit-wrap"><input type="submit" name="submit-cmb" value="'.__('Save Settings', 'give').'" class="button-primary"></div>');
216 216
 
217 217
 			//Filter so some tabs won't have save settings
218
-			$no_save_button = apply_filters( 'give_settings_no_save_output', array(
218
+			$no_save_button = apply_filters('give_settings_no_save_output', array(
219 219
 				'system_info'
220
-			) );
220
+			));
221 221
 
222
-			if ( in_array( $tab_id, $no_save_button ) ) {
222
+			if (in_array($tab_id, $no_save_button)) {
223 223
 				$save_button = '';
224 224
 			}
225 225
 
226
-			$form_format = '<form class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data" ' . $style . ' data-tab="' . $tab_id . '"><input type="hidden" name="give_settings_saved" value="true"><input type="hidden" name="object_id" value="%2$s">%3$s' . $save_button . '</form>';
226
+			$form_format = '<form class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data" '.$style.' data-tab="'.$tab_id.'"><input type="hidden" name="give_settings_saved" value="true"><input type="hidden" name="object_id" value="%2$s">%3$s'.$save_button.'</form>';
227 227
 
228 228
 		}
229 229
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	 *
241 241
 	 * @return array
242 242
 	 */
243
-	public function give_settings( $active_tab ) {
243
+	public function give_settings($active_tab) {
244 244
 
245 245
 		$give_settings = array(
246 246
 			/**
@@ -248,60 +248,60 @@  discard block
 block discarded – undo
248 248
 			 */
249 249
 			'general'     => array(
250 250
 				'id'         => 'general_settings',
251
-				'give_title' => __( 'General Settings', 'give' ),
252
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key, ), ),
253
-				'fields'     => apply_filters( 'give_settings_general', array(
251
+				'give_title' => __('General Settings', 'give'),
252
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key,),),
253
+				'fields'     => apply_filters('give_settings_general', array(
254 254
 						array(
255
-							'name' => __( 'General Settings', 'give' ),
255
+							'name' => __('General Settings', 'give'),
256 256
 							'desc' => '',
257 257
 							'type' => 'give_title',
258 258
 							'id'   => 'give_title_general_settings_1'
259 259
 						),
260 260
 						array(
261
-							'name'    => __( 'Success Page', 'give' ),
262
-							'desc'    => sprintf( __( 'This is the page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give' ), '<code>[give_receipt]</code>' ),
261
+							'name'    => __('Success Page', 'give'),
262
+							'desc'    => sprintf(__('This is the page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give'), '<code>[give_receipt]</code>'),
263 263
 							'id'      => 'success_page',
264 264
 							'type'    => 'select',
265
-							'options' => give_cmb2_get_post_options( array(
265
+							'options' => give_cmb2_get_post_options(array(
266 266
 								'post_type'   => 'page',
267
-								'numberposts' => - 1
268
-							) ),
267
+								'numberposts' => -1
268
+							)),
269 269
 						),
270 270
 						array(
271
-							'name'    => __( 'Failed Transaction Page', 'give' ),
272
-							'desc'    => __( 'This is the page donors are sent to if their transaction is cancelled or fails.', 'give' ),
271
+							'name'    => __('Failed Transaction Page', 'give'),
272
+							'desc'    => __('This is the page donors are sent to if their transaction is cancelled or fails.', 'give'),
273 273
 							'id'      => 'failure_page',
274 274
 							'type'    => 'select',
275
-							'options' => give_cmb2_get_post_options( array(
275
+							'options' => give_cmb2_get_post_options(array(
276 276
 								'post_type'   => 'page',
277
-								'numberposts' => - 1
278
-							) ),
277
+								'numberposts' => -1
278
+							)),
279 279
 						),
280 280
 						array(
281
-							'name'    => __( 'Donation History Page', 'give' ),
282
-							'desc'    => sprintf( __( 'This page shows a complete donation history for the current user. The %s shortcode should be on this page.', 'give' ), '<code>[donation_history]</code>' ),
281
+							'name'    => __('Donation History Page', 'give'),
282
+							'desc'    => sprintf(__('This page shows a complete donation history for the current user. The %s shortcode should be on this page.', 'give'), '<code>[donation_history]</code>'),
283 283
 							'id'      => 'history_page',
284 284
 							'type'    => 'select',
285
-							'options' => give_cmb2_get_post_options( array(
285
+							'options' => give_cmb2_get_post_options(array(
286 286
 								'post_type'   => 'page',
287
-								'numberposts' => - 1
288
-							) ),
287
+								'numberposts' => -1
288
+							)),
289 289
 						),
290 290
 						array(
291
-							'name'    => __( 'Base Country', 'give' ),
292
-							'desc'    => __( 'Where does your site operate from?', 'give' ),
291
+							'name'    => __('Base Country', 'give'),
292
+							'desc'    => __('Where does your site operate from?', 'give'),
293 293
 							'id'      => 'base_country',
294 294
 							'type'    => 'select',
295 295
 							'options' => give_get_country_list(),
296 296
 						),
297 297
 						array(
298
-							'name' => __( 'Currency Settings', 'give' ),
298
+							'name' => __('Currency Settings', 'give'),
299 299
 							'desc' => '',
300 300
 							'type' => 'give_title',
301 301
 							'id'   => 'give_title_general_settings_2'
302 302
 						),
303 303
 						array(
304
-							'name'    => __( 'Currency', 'give' ),
304
+							'name'    => __('Currency', 'give'),
305 305
 							'desc'    => 'Choose your currency. Note that some payment gateways have currency restrictions.',
306 306
 							'id'      => 'currency',
307 307
 							'type'    => 'select',
@@ -309,26 +309,26 @@  discard block
 block discarded – undo
309 309
 							'default' => 'USD',
310 310
 						),
311 311
 						array(
312
-							'name'    => __( 'Currency Position', 'give' ),
312
+							'name'    => __('Currency Position', 'give'),
313 313
 							'desc'    => 'Choose the position of the currency sign.',
314 314
 							'id'      => 'currency_position',
315 315
 							'type'    => 'select',
316 316
 							'options' => array(
317
-								'before' => sprintf( __( 'Before - %s10', 'give' ), give_currency_symbol( give_get_currency() ) ),
318
-								'after'  => sprintf( __( 'After - 10%s', 'give' ), give_currency_symbol( give_get_currency() ) )
317
+								'before' => sprintf(__('Before - %s10', 'give'), give_currency_symbol(give_get_currency())),
318
+								'after'  => sprintf(__('After - 10%s', 'give'), give_currency_symbol(give_get_currency()))
319 319
 							),
320 320
 							'default' => 'before',
321 321
 						),
322 322
 						array(
323
-							'name'    => __( 'Thousands Separator', 'give' ),
324
-							'desc'    => __( 'The symbol (typically , or .) to separate thousands.', 'give' ),
323
+							'name'    => __('Thousands Separator', 'give'),
324
+							'desc'    => __('The symbol (typically , or .) to separate thousands.', 'give'),
325 325
 							'id'      => 'thousands_separator',
326 326
 							'type'    => 'text_small',
327 327
 							'default' => ',',
328 328
 						),
329 329
 						array(
330
-							'name'    => __( 'Decimal Separator', 'give' ),
331
-							'desc'    => __( 'The symbol (usually , or .) to separate decimal points.', 'give' ),
330
+							'name'    => __('Decimal Separator', 'give'),
331
+							'desc'    => __('The symbol (usually , or .) to separate decimal points.', 'give'),
332 332
 							'id'      => 'decimal_separator',
333 333
 							'type'    => 'text_small',
334 334
 							'default' => '.',
@@ -341,83 +341,83 @@  discard block
 block discarded – undo
341 341
 			 */
342 342
 			'gateways'    => array(
343 343
 				'id'         => 'payment_gateways',
344
-				'give_title' => __( 'Payment Gateways', 'give' ),
345
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key, ), ),
346
-				'fields'     => apply_filters( 'give_settings_gateways', array(
344
+				'give_title' => __('Payment Gateways', 'give'),
345
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key,),),
346
+				'fields'     => apply_filters('give_settings_gateways', array(
347 347
 						array(
348
-							'name' => __( 'Gateways Settings', 'give' ),
348
+							'name' => __('Gateways Settings', 'give'),
349 349
 							'desc' => '',
350 350
 							'id'   => 'give_title_gateway_settings_1',
351 351
 							'type' => 'give_title'
352 352
 						),
353 353
 						array(
354
-							'name' => __( 'Test Mode', 'give' ),
355
-							'desc' => __( 'While in test mode no live transactions are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give' ),
354
+							'name' => __('Test Mode', 'give'),
355
+							'desc' => __('While in test mode no live transactions are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give'),
356 356
 							'id'   => 'test_mode',
357 357
 							'type' => 'checkbox'
358 358
 						),
359 359
 						array(
360
-							'name' => __( 'Enabled Gateways', 'give' ),
361
-							'desc' => __( 'Choose the payment gateways you would like enabled. You can drag-and-drop payment gateways to reorder them.', 'give' ),
360
+							'name' => __('Enabled Gateways', 'give'),
361
+							'desc' => __('Choose the payment gateways you would like enabled. You can drag-and-drop payment gateways to reorder them.', 'give'),
362 362
 							'id'   => 'gateways',
363 363
 							'type' => 'enabled_gateways'
364 364
 						),
365 365
 						array(
366
-							'name' => __( 'Default Gateway', 'give' ),
367
-							'desc' => __( 'This is the gateway that will be selected by default.', 'give' ),
366
+							'name' => __('Default Gateway', 'give'),
367
+							'desc' => __('This is the gateway that will be selected by default.', 'give'),
368 368
 							'id'   => 'default_gateway',
369 369
 							'type' => 'default_gateway'
370 370
 						),
371 371
 						array(
372
-							'name' => __( 'PayPal Standard', 'give' ),
372
+							'name' => __('PayPal Standard', 'give'),
373 373
 							'desc' => '',
374 374
 							'type' => 'give_title',
375 375
 							'id'   => 'give_title_gateway_settings_2',
376 376
 						),
377 377
 						array(
378
-							'name' => __( 'PayPal Email', 'give' ),
379
-							'desc' => __( 'Enter your PayPal account\'s email.', 'give' ),
378
+							'name' => __('PayPal Email', 'give'),
379
+							'desc' => __('Enter your PayPal account\'s email.', 'give'),
380 380
 							'id'   => 'paypal_email',
381 381
 							'type' => 'text_email',
382 382
 						),
383 383
 						array(
384
-							'name' => __( 'PayPal Page Style', 'give' ),
385
-							'desc' => __( 'Enter the name of the page style to use, or leave blank to use the default.', 'give' ),
384
+							'name' => __('PayPal Page Style', 'give'),
385
+							'desc' => __('Enter the name of the page style to use, or leave blank to use the default.', 'give'),
386 386
 							'id'   => 'paypal_page_style',
387 387
 							'type' => 'text',
388 388
 						),
389 389
 						array(
390
-							'name'    => __( 'PayPal Transaction Type', 'give' ),
391
-							'desc'    => __( 'Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give' ),
390
+							'name'    => __('PayPal Transaction Type', 'give'),
391
+							'desc'    => __('Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give'),
392 392
 							'id'      => 'paypal_button_type',
393 393
 							'type'    => 'radio_inline',
394 394
 							'options' => array(
395
-								'donation' => __( 'Donation', 'give' ),
396
-								'standard' => __( 'Standard Transaction', 'give' )
395
+								'donation' => __('Donation', 'give'),
396
+								'standard' => __('Standard Transaction', 'give')
397 397
 							),
398 398
 							'default' => 'donation',
399 399
 						),
400 400
 						array(
401
-							'name' => __( 'Disable PayPal IPN Verification', 'give' ),
402
-							'desc' => __( 'If donations are not getting marked as complete, then check this box. This forces the site to use a slightly less secure method of verifying donations.', 'give' ),
401
+							'name' => __('Disable PayPal IPN Verification', 'give'),
402
+							'desc' => __('If donations are not getting marked as complete, then check this box. This forces the site to use a slightly less secure method of verifying donations.', 'give'),
403 403
 							'id'   => 'disable_paypal_verification',
404 404
 							'type' => 'checkbox'
405 405
 						),
406 406
 						array(
407
-							'name' => __( 'Offline Donations', 'give' ),
407
+							'name' => __('Offline Donations', 'give'),
408 408
 							'desc' => '',
409 409
 							'type' => 'give_title',
410 410
 							'id'   => 'give_title_gateway_settings_3',
411 411
 						),
412 412
 						array(
413
-							'name' => __( 'Collect Billing Details', 'give' ),
414
-							'desc' => __( 'This option will enable the billing details section for offline donations. The fieldset will appear above the offline donation instructions. Note: You may customize this option per form as needed.', 'give' ),
413
+							'name' => __('Collect Billing Details', 'give'),
414
+							'desc' => __('This option will enable the billing details section for offline donations. The fieldset will appear above the offline donation instructions. Note: You may customize this option per form as needed.', 'give'),
415 415
 							'id'   => 'give_offline_donation_enable_billing_fields',
416 416
 							'type' => 'checkbox'
417 417
 						),
418 418
 						array(
419
-							'name'    => __( 'Offline Donation Instructions', 'give' ),
420
-							'desc'    => __( 'The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give' ),
419
+							'name'    => __('Offline Donation Instructions', 'give'),
420
+							'desc'    => __('The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give'),
421 421
 							'id'      => 'global_offline_donation_content',
422 422
 							'default' => give_get_default_offline_donation_content(),
423 423
 							'type'    => 'wysiwyg',
@@ -426,15 +426,15 @@  discard block
 block discarded – undo
426 426
 							)
427 427
 						),
428 428
 						array(
429
-							'name'    => __( 'Offline Donation Email Instructions Subject', 'give' ),
430
-							'desc'    => __( 'Enter the subject line for the donation receipt email.', 'give' ),
429
+							'name'    => __('Offline Donation Email Instructions Subject', 'give'),
430
+							'desc'    => __('Enter the subject line for the donation receipt email.', 'give'),
431 431
 							'id'      => 'offline_donation_subject',
432
-							'default' => __( '{donation} - Offline Donation Instructions', 'give' ),
432
+							'default' => __('{donation} - Offline Donation Instructions', 'give'),
433 433
 							'type'    => 'text'
434 434
 						),
435 435
 						array(
436
-							'name'    => __( 'Offline Donation Email Instructions', 'give' ),
437
-							'desc'    => __( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ),
436
+							'name'    => __('Offline Donation Email Instructions', 'give'),
437
+							'desc'    => __('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give'),
438 438
 							'id'      => 'global_offline_donation_email',
439 439
 							'default' => give_get_default_offline_donation_email_content(),
440 440
 							'type'    => 'wysiwyg',
@@ -448,93 +448,93 @@  discard block
 block discarded – undo
448 448
 			/** Display Settings */
449 449
 			'display'     => array(
450 450
 				'id'         => 'display_settings',
451
-				'give_title' => __( 'Display Settings', 'give' ),
452
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key, ), ),
453
-				'fields'     => apply_filters( 'give_settings_display', array(
451
+				'give_title' => __('Display Settings', 'give'),
452
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key,),),
453
+				'fields'     => apply_filters('give_settings_display', array(
454 454
 						array(
455
-							'name' => __( 'Display Settings', 'give' ),
455
+							'name' => __('Display Settings', 'give'),
456 456
 							'desc' => '',
457 457
 							'id'   => 'give_title_display_settings_1',
458 458
 							'type' => 'give_title'
459 459
 						),
460 460
 						array(
461
-							'name' => __( 'Disable CSS', 'give' ),
462
-							'desc' => __( 'Enable this option if you would like to disable all of Give\'s included CSS stylesheets.', 'give' ),
461
+							'name' => __('Disable CSS', 'give'),
462
+							'desc' => __('Enable this option if you would like to disable all of Give\'s included CSS stylesheets.', 'give'),
463 463
 							'id'   => 'disable_css',
464 464
 							'type' => 'checkbox'
465 465
 						),
466 466
 						array(
467
-							'name' => __( 'Enable Floating Labels', 'give' ),
468
-							'desc' => sprintf( esc_html__( 'Enable this option if you would like to enable %1$sfloating labels%2$s in Give\'s donation forms. %3$sBe aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give' ), '<a href="' . esc_url( "http://bradfrost.com/blog/post/float-label-pattern/" ) . '" target="_blank">', '</a>', '<br />' ),
467
+							'name' => __('Enable Floating Labels', 'give'),
468
+							'desc' => sprintf(esc_html__('Enable this option if you would like to enable %1$sfloating labels%2$s in Give\'s donation forms. %3$sBe aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), '<a href="'.esc_url("http://bradfrost.com/blog/post/float-label-pattern/").'" target="_blank">', '</a>', '<br />'),
469 469
 							'id'   => 'enable_floatlabels',
470 470
 							'type' => 'checkbox'
471 471
 						),
472 472
 						array(
473
-							'name' => __( 'Disable Welcome Screen', 'give' ),
474
-							'desc' => sprintf( esc_html__( 'Enable this option if you would like to disable the Give Welcome screen every time Give is activated and/or updated. You can always access the <a href="%s">Welcome Screen</a> if you want in the future.', 'give' ), esc_url( admin_url( 'index.php?page=give-about' ) ) ),
473
+							'name' => __('Disable Welcome Screen', 'give'),
474
+							'desc' => sprintf(esc_html__('Enable this option if you would like to disable the Give Welcome screen every time Give is activated and/or updated. You can always access the <a href="%s">Welcome Screen</a> if you want in the future.', 'give'), esc_url(admin_url('index.php?page=give-about'))),
475 475
 							'id'   => 'disable_welcome',
476 476
 							'type' => 'checkbox'
477 477
 						),
478 478
 						array(
479
-							'name' => __( 'Post Types', 'give' ),
479
+							'name' => __('Post Types', 'give'),
480 480
 							'desc' => '',
481 481
 							'id'   => 'give_title_display_settings_2',
482 482
 							'type' => 'give_title'
483 483
 						),
484 484
 						array(
485
-							'name' => __( 'Disable Form Single Views', 'give' ),
486
-							'desc' => __( 'By default, all forms have single views enabled which create a specific URL on your website for that form. This option disables the singular and archive views from being publicly viewable. Note: you will need to embed forms using a shortcode or widget if enabled.', 'give' ),
485
+							'name' => __('Disable Form Single Views', 'give'),
486
+							'desc' => __('By default, all forms have single views enabled which create a specific URL on your website for that form. This option disables the singular and archive views from being publicly viewable. Note: you will need to embed forms using a shortcode or widget if enabled.', 'give'),
487 487
 							'id'   => 'disable_forms_singular',
488 488
 							'type' => 'checkbox'
489 489
 						),
490 490
 						array(
491
-							'name' => __( 'Disable Form Archives', 'give' ),
492
-							'desc' => __( 'Archives pages list all the forms you have created. This option will disable only the form\'s archive page(s). The single form\'s view will remain in place. Note: you will need to refresh your permalinks after this option has been enabled.', 'give' ),
491
+							'name' => __('Disable Form Archives', 'give'),
492
+							'desc' => __('Archives pages list all the forms you have created. This option will disable only the form\'s archive page(s). The single form\'s view will remain in place. Note: you will need to refresh your permalinks after this option has been enabled.', 'give'),
493 493
 							'id'   => 'disable_forms_archives',
494 494
 							'type' => 'checkbox'
495 495
 						),
496 496
 						array(
497
-							'name' => __( 'Disable Form Excerpts', 'give' ),
498
-							'desc' => __( 'The excerpt is an optional summary or description of a donation form; in short, a summary as to why the user should give.', 'give' ),
497
+							'name' => __('Disable Form Excerpts', 'give'),
498
+							'desc' => __('The excerpt is an optional summary or description of a donation form; in short, a summary as to why the user should give.', 'give'),
499 499
 							'id'   => 'disable_forms_excerpt',
500 500
 							'type' => 'checkbox'
501 501
 						),
502 502
 
503 503
 						array(
504
-							'name'    => __( 'Featured Image Size', 'give' ),
505
-							'desc'    => __( 'The Featured Image is an image that is chosen as the representative image for a donation form. Some themes may have custom featured image sizes. Please select the size you would like to display for your single donation forms\' featured image.', 'give' ),
504
+							'name'    => __('Featured Image Size', 'give'),
505
+							'desc'    => __('The Featured Image is an image that is chosen as the representative image for a donation form. Some themes may have custom featured image sizes. Please select the size you would like to display for your single donation forms\' featured image.', 'give'),
506 506
 							'id'      => 'featured_image_size',
507 507
 							'type'    => 'select',
508 508
 							'default' => 'large',
509 509
 							'options' => give_get_featured_image_sizes()
510 510
 						),
511 511
 						array(
512
-							'name' => __( 'Disable Form Featured Image', 'give' ),
513
-							'desc' => __( 'If you do not wish to use the featured image functionality you can disable it using this option and it will not be displayed for single donation forms.', 'give' ),
512
+							'name' => __('Disable Form Featured Image', 'give'),
513
+							'desc' => __('If you do not wish to use the featured image functionality you can disable it using this option and it will not be displayed for single donation forms.', 'give'),
514 514
 							'id'   => 'disable_form_featured_img',
515 515
 							'type' => 'checkbox'
516 516
 						),
517 517
 						array(
518
-							'name' => __( 'Disable Single Form Sidebar', 'give' ),
519
-							'desc' => __( 'The sidebar allows you to add additional widget to the Give single form view. If you don\'t plan on using the sidebar you may disable it with this option.', 'give' ),
518
+							'name' => __('Disable Single Form Sidebar', 'give'),
519
+							'desc' => __('The sidebar allows you to add additional widget to the Give single form view. If you don\'t plan on using the sidebar you may disable it with this option.', 'give'),
520 520
 							'id'   => 'disable_form_sidebar',
521 521
 							'type' => 'checkbox'
522 522
 						),
523 523
 						array(
524
-							'name' => __( 'Taxonomies', 'give' ),
524
+							'name' => __('Taxonomies', 'give'),
525 525
 							'desc' => '',
526 526
 							'id'   => 'give_title_display_settings_3',
527 527
 							'type' => 'give_title'
528 528
 						),
529 529
 						array(
530
-							'name' => __( 'Enable Form Categories', 'give' ),
531
-							'desc' => __( 'Check this option if you would like to categorize your donation forms. This option enables the form\'s category taxonomy.', 'give' ),
530
+							'name' => __('Enable Form Categories', 'give'),
531
+							'desc' => __('Check this option if you would like to categorize your donation forms. This option enables the form\'s category taxonomy.', 'give'),
532 532
 							'id'   => 'enable_categories',
533 533
 							'type' => 'checkbox'
534 534
 						),
535 535
 						array(
536
-							'name' => __( 'Enable Form Tags', 'give' ),
537
-							'desc' => __( 'Check this option if you would like to tag your donation forms. This option enables the form\'s tag taxonomy.', 'give' ),
536
+							'name' => __('Enable Form Tags', 'give'),
537
+							'desc' => __('Check this option if you would like to tag your donation forms. This option enables the form\'s tag taxonomy.', 'give'),
538 538
 							'id'   => 'enable_tags',
539 539
 							'type' => 'checkbox'
540 540
 						),
@@ -547,93 +547,93 @@  discard block
 block discarded – undo
547 547
 			 */
548 548
 			'emails'      => array(
549 549
 				'id'         => 'email_settings',
550
-				'give_title' => __( 'Email Settings', 'give' ),
551
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key, ), ),
552
-				'fields'     => apply_filters( 'give_settings_emails', array(
550
+				'give_title' => __('Email Settings', 'give'),
551
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key,),),
552
+				'fields'     => apply_filters('give_settings_emails', array(
553 553
 						array(
554
-							'name' => __( 'Email Settings', 'give' ),
554
+							'name' => __('Email Settings', 'give'),
555 555
 							'desc' => '',
556 556
 							'id'   => 'give_title_email_settings_1',
557 557
 							'type' => 'give_title'
558 558
 						),
559 559
 						array(
560 560
 							'id'      => 'email_template',
561
-							'name'    => __( 'Email Template', 'give' ),
562
-							'desc'    => __( 'Choose a template. Click "Save Changes" then "Preview Donation Receipt" to see the new template.', 'give' ),
561
+							'name'    => __('Email Template', 'give'),
562
+							'desc'    => __('Choose a template. Click "Save Changes" then "Preview Donation Receipt" to see the new template.', 'give'),
563 563
 							'type'    => 'select',
564 564
 							'options' => give_get_email_templates()
565 565
 						),
566 566
 						array(
567 567
 							'id'   => 'email_logo',
568
-							'name' => __( 'Logo', 'give' ),
569
-							'desc' => __( 'Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give' ),
568
+							'name' => __('Logo', 'give'),
569
+							'desc' => __('Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give'),
570 570
 							'type' => 'file'
571 571
 						),
572 572
 						array(
573 573
 							'id'      => 'from_name',
574
-							'name'    => __( 'From Name', 'give' ),
575
-							'desc'    => __( 'The name donation receipts are said to come from. This should probably be your site or shop name.', 'give' ),
576
-							'default' => get_bloginfo( 'name' ),
574
+							'name'    => __('From Name', 'give'),
575
+							'desc'    => __('The name donation receipts are said to come from. This should probably be your site or shop name.', 'give'),
576
+							'default' => get_bloginfo('name'),
577 577
 							'type'    => 'text'
578 578
 						),
579 579
 						array(
580 580
 							'id'      => 'from_email',
581
-							'name'    => __( 'From Email', 'give' ),
582
-							'desc'    => __( 'Email to send donation receipts from. This will act as the "from" and "reply-to" address.', 'give' ),
583
-							'default' => get_bloginfo( 'admin_email' ),
581
+							'name'    => __('From Email', 'give'),
582
+							'desc'    => __('Email to send donation receipts from. This will act as the "from" and "reply-to" address.', 'give'),
583
+							'default' => get_bloginfo('admin_email'),
584 584
 							'type'    => 'text'
585 585
 						),
586 586
 						array(
587
-							'name' => __( 'Donation Receipt', 'give' ),
587
+							'name' => __('Donation Receipt', 'give'),
588 588
 							'desc' => '',
589 589
 							'id'   => 'give_title_email_settings_2',
590 590
 							'type' => 'give_title'
591 591
 						),
592 592
 						array(
593 593
 							'id'      => 'donation_subject',
594
-							'name'    => __( 'Donation Email Subject', 'give' ),
595
-							'desc'    => __( 'Enter the subject line for the donation receipt email.', 'give' ),
596
-							'default' => __( 'Donation Receipt', 'give' ),
594
+							'name'    => __('Donation Email Subject', 'give'),
595
+							'desc'    => __('Enter the subject line for the donation receipt email.', 'give'),
596
+							'default' => __('Donation Receipt', 'give'),
597 597
 							'type'    => 'text'
598 598
 						),
599 599
 						array(
600 600
 							'id'      => 'donation_receipt',
601
-							'name'    => __( 'Donation Receipt', 'give' ),
602
-							'desc'    => __( 'Enter the email that is sent to users after completing a successful donation. HTML is accepted. Available template tags:', 'give' ) . '<br/>' . give_get_emails_tags_list(),
601
+							'name'    => __('Donation Receipt', 'give'),
602
+							'desc'    => __('Enter the email that is sent to users after completing a successful donation. HTML is accepted. Available template tags:', 'give').'<br/>'.give_get_emails_tags_list(),
603 603
 							'type'    => 'wysiwyg',
604 604
 							'default' => give_get_default_donation_receipt_email()
605 605
 						),
606 606
 						array(
607
-							'name' => __( 'New Donation Notification', 'give' ),
607
+							'name' => __('New Donation Notification', 'give'),
608 608
 							'desc' => '',
609 609
 							'id'   => 'give_title_email_settings_3',
610 610
 							'type' => 'give_title'
611 611
 						),
612 612
 						array(
613 613
 							'id'      => 'donation_notification_subject',
614
-							'name'    => __( 'Donation Notification Subject', 'give' ),
615
-							'desc'    => __( 'Enter the subject line for the donation notification email.', 'give' ),
614
+							'name'    => __('Donation Notification Subject', 'give'),
615
+							'desc'    => __('Enter the subject line for the donation notification email.', 'give'),
616 616
 							'type'    => 'text',
617
-							'default' => __( 'New Donation - #{payment_id}', 'give' )
617
+							'default' => __('New Donation - #{payment_id}', 'give')
618 618
 						),
619 619
 						array(
620 620
 							'id'      => 'donation_notification',
621
-							'name'    => __( 'Donation Notification', 'give' ),
622
-							'desc'    => __( 'Enter the email that is sent to donation notification emails after completion of a donation. HTML is accepted. Available template tags:', 'give' ) . '<br/>' . give_get_emails_tags_list(),
621
+							'name'    => __('Donation Notification', 'give'),
622
+							'desc'    => __('Enter the email that is sent to donation notification emails after completion of a donation. HTML is accepted. Available template tags:', 'give').'<br/>'.give_get_emails_tags_list(),
623 623
 							'type'    => 'wysiwyg',
624 624
 							'default' => give_get_default_donation_notification_email()
625 625
 						),
626 626
 						array(
627 627
 							'id'      => 'admin_notice_emails',
628
-							'name'    => __( 'Donation Notification Emails', 'give' ),
629
-							'desc'    => sprintf( __( 'Enter the email address(es) that should receive a notification anytime a donation is made, please only enter %1$sone email address per line%2$s and not separated by commas.', 'give' ), '<span class="give-underline">', '</span>' ),
628
+							'name'    => __('Donation Notification Emails', 'give'),
629
+							'desc'    => sprintf(__('Enter the email address(es) that should receive a notification anytime a donation is made, please only enter %1$sone email address per line%2$s and not separated by commas.', 'give'), '<span class="give-underline">', '</span>'),
630 630
 							'type'    => 'textarea',
631
-							'default' => get_bloginfo( 'admin_email' )
631
+							'default' => get_bloginfo('admin_email')
632 632
 						),
633 633
 						array(
634 634
 							'id'   => 'disable_admin_notices',
635
-							'name' => __( 'Disable Admin Notifications', 'give' ),
636
-							'desc' => __( 'Check this box if you do not want to receive emails when new donations are made.', 'give' ),
635
+							'name' => __('Disable Admin Notifications', 'give'),
636
+							'desc' => __('Check this box if you do not want to receive emails when new donations are made.', 'give'),
637 637
 							'type' => 'checkbox'
638 638
 						)
639 639
 					)
@@ -642,96 +642,96 @@  discard block
 block discarded – undo
642 642
 			/** Extension Settings */
643 643
 			'addons'      => array(
644 644
 				'id'         => 'addons',
645
-				'give_title' => __( 'Give Add-ons Settings', 'give' ),
646
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key, ), ),
647
-				'fields'     => apply_filters( 'give_settings_addons', array()
645
+				'give_title' => __('Give Add-ons Settings', 'give'),
646
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key,),),
647
+				'fields'     => apply_filters('give_settings_addons', array()
648 648
 				)
649 649
 			),
650 650
 			/** Licenses Settings */
651 651
 			'licenses'    => array(
652 652
 				'id'         => 'licenses',
653
-				'give_title' => __( 'Give Licenses', 'give' ),
654
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key, ), ),
655
-				'fields'     => apply_filters( 'give_settings_licenses', array()
653
+				'give_title' => __('Give Licenses', 'give'),
654
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key,),),
655
+				'fields'     => apply_filters('give_settings_licenses', array()
656 656
 				)
657 657
 			),
658 658
 			/** Advanced Options */
659 659
 			'advanced'    => array(
660 660
 				'id'         => 'advanced_options',
661
-				'give_title' => __( 'Advanced Options', 'give' ),
662
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key, ), ),
663
-				'fields'     => apply_filters( 'give_settings_advanced', array(
661
+				'give_title' => __('Advanced Options', 'give'),
662
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key,),),
663
+				'fields'     => apply_filters('give_settings_advanced', array(
664 664
 						array(
665
-							'name' => __( 'Access Control', 'give' ),
665
+							'name' => __('Access Control', 'give'),
666 666
 							'desc' => '',
667 667
 							'id'   => 'give_title_session_control_1',
668 668
 							'type' => 'give_title'
669 669
 						),
670 670
 						array(
671 671
 							'id'      => 'session_lifetime',
672
-							'name'    => __( 'Session Lifetime', 'give' ),
673
-							'desc'    => __( 'Give will start a new session per user once they have donated. This option controls the lifetime a user\'s session is kept alive. An active session allows users to view donation receipts on your site without having to be logged in as long as they are using the same browser they used when donating.', 'give' ),
672
+							'name'    => __('Session Lifetime', 'give'),
673
+							'desc'    => __('Give will start a new session per user once they have donated. This option controls the lifetime a user\'s session is kept alive. An active session allows users to view donation receipts on your site without having to be logged in as long as they are using the same browser they used when donating.', 'give'),
674 674
 							'type'    => 'select',
675 675
 							'options' => array(
676
-								'86400'  => __( '24 Hours', 'give' ),
677
-								'172800' => __( '48 Hours', 'give' ),
678
-								'259200' => __( '72 Hours', 'give' ),
679
-								'604800' => __( '1 Week', 'give' ),
676
+								'86400'  => __('24 Hours', 'give'),
677
+								'172800' => __('48 Hours', 'give'),
678
+								'259200' => __('72 Hours', 'give'),
679
+								'604800' => __('1 Week', 'give'),
680 680
 							)
681 681
 						),
682 682
 						array(
683
-							'name' => __( 'Email Access', 'give' ),
684
-							'desc' => __( 'Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give' ),
683
+							'name' => __('Email Access', 'give'),
684
+							'desc' => __('Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give'),
685 685
 							'id'   => 'email_access',
686 686
 							'type' => 'checkbox',
687 687
 						),
688 688
 						array(
689 689
 							'id'      => 'recaptcha_key',
690
-							'name'    => __( 'reCAPTCHA Site Key', 'give' ),
691
-							'desc'    => sprintf( __( 'If you would like to prevent spam on the email access form navigate to %1$sthe reCAPTCHA website%2$s and sign up for an API key. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give' ), '<a href="https://www.google.com/recaptcha/" target="_blank">', '</a>' ),
690
+							'name'    => __('reCAPTCHA Site Key', 'give'),
691
+							'desc'    => sprintf(__('If you would like to prevent spam on the email access form navigate to %1$sthe reCAPTCHA website%2$s and sign up for an API key. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give'), '<a href="https://www.google.com/recaptcha/" target="_blank">', '</a>'),
692 692
 							'default' => '',
693 693
 							'type'    => 'text'
694 694
 						),
695 695
 						array(
696 696
 							'id'      => 'recaptcha_secret',
697
-							'name'    => __( 'reCAPTCHA Secret Key', 'give' ),
698
-							'desc'    => __( 'Please paste the reCAPTCHA secret key here from your manage reCAPTCHA API Keys panel.', 'give' ),
697
+							'name'    => __('reCAPTCHA Secret Key', 'give'),
698
+							'desc'    => __('Please paste the reCAPTCHA secret key here from your manage reCAPTCHA API Keys panel.', 'give'),
699 699
 							'default' => '',
700 700
 							'type'    => 'text'
701 701
 						),
702 702
 						array(
703
-							'name' => __( 'Data Control', 'give' ),
703
+							'name' => __('Data Control', 'give'),
704 704
 							'desc' => '',
705 705
 							'id'   => 'give_title_data_control_2',
706 706
 							'type' => 'give_title'
707 707
 						),
708 708
 						array(
709
-							'name' => __( 'Remove All Data on Uninstall?', 'give' ),
710
-							'desc' => __( 'Check this box if you would like Give to completely remove all of its data when the plugin is deleted.', 'give' ),
709
+							'name' => __('Remove All Data on Uninstall?', 'give'),
710
+							'desc' => __('Check this box if you would like Give to completely remove all of its data when the plugin is deleted.', 'give'),
711 711
 							'id'   => 'uninstall_on_delete',
712 712
 							'type' => 'checkbox'
713 713
 						),
714 714
 						array(
715
-							'name' => __( 'Filter Control', 'give' ),
715
+							'name' => __('Filter Control', 'give'),
716 716
 							'desc' => '',
717 717
 							'id'   => 'give_title_filter_control',
718 718
 							'type' => 'give_title'
719 719
 						),
720 720
 						array(
721
-							'name' => sprintf( __( 'Disable %s filter', 'give' ), '<code>the_content</code>' ),
722
-							'desc' => sprintf( __( 'If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give' ), esc_url( 'https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content' ), '<code>the_content</code>' ),
721
+							'name' => sprintf(__('Disable %s filter', 'give'), '<code>the_content</code>'),
722
+							'desc' => sprintf(__('If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give'), esc_url('https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content'), '<code>the_content</code>'),
723 723
 							'id'   => 'disable_the_content_filter',
724 724
 							'type' => 'checkbox'
725 725
 						),
726 726
 						array(
727
-							'name' => __( 'Script Loading', 'give' ),
727
+							'name' => __('Script Loading', 'give'),
728 728
 							'desc' => '',
729 729
 							'id'   => 'give_title_script_control',
730 730
 							'type' => 'give_title'
731 731
 						),
732 732
 						array(
733
-							'name' => __( 'Load Scripts in Footer?', 'give' ),
734
-							'desc' => __( 'Check this box if you would like Give to load all frontend JavaScript files in the footer.', 'give' ),
733
+							'name' => __('Load Scripts in Footer?', 'give'),
734
+							'desc' => __('Check this box if you would like Give to load all frontend JavaScript files in the footer.', 'give'),
735 735
 							'id'   => 'scripts_footer',
736 736
 							'type' => 'checkbox'
737 737
 						)
@@ -741,13 +741,13 @@  discard block
 block discarded – undo
741 741
 			/** API Settings */
742 742
 			'api'         => array(
743 743
 				'id'         => 'api',
744
-				'give_title' => __( 'API', 'give' ),
745
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key, ), ),
744
+				'give_title' => __('API', 'give'),
745
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key,),),
746 746
 				'show_names' => false, // Hide field names on the left
747
-				'fields'     => apply_filters( 'give_settings_system', array(
747
+				'fields'     => apply_filters('give_settings_system', array(
748 748
 						array(
749 749
 							'id'   => 'api',
750
-							'name' => __( 'API', 'give' ),
750
+							'name' => __('API', 'give'),
751 751
 							'type' => 'api'
752 752
 						)
753 753
 					)
@@ -756,13 +756,13 @@  discard block
 block discarded – undo
756 756
 			/** Licenses Settings */
757 757
 			'system_info' => array(
758 758
 				'id'         => 'system_info',
759
-				'give_title' => __( 'System Info', 'give' ),
760
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key, ), ),
761
-				'fields'     => apply_filters( 'give_settings_system', array(
759
+				'give_title' => __('System Info', 'give'),
760
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key,),),
761
+				'fields'     => apply_filters('give_settings_system', array(
762 762
 						array(
763 763
 							'id'   => 'system_info',
764
-							'name' => __( 'System Info', 'give' ),
765
-							'desc' => __( 'Please copy and paste this information in your ticket when contacting support.', 'give' ),
764
+							'name' => __('System Info', 'give'),
765
+							'desc' => __('Please copy and paste this information in your ticket when contacting support.', 'give'),
766 766
 							'type' => 'system_info'
767 767
 						)
768 768
 					)
@@ -771,15 +771,15 @@  discard block
 block discarded – undo
771 771
 		);
772 772
 
773 773
 		//Return all settings array if no active tab
774
-		if ( $active_tab === null || ! isset( $give_settings[ $active_tab ] ) ) {
774
+		if ($active_tab === null || ! isset($give_settings[$active_tab])) {
775 775
 
776
-			return apply_filters( 'give_registered_settings', $give_settings );
776
+			return apply_filters('give_registered_settings', $give_settings);
777 777
 			
778 778
 		}
779 779
 
780 780
 
781 781
 		// Add other tabs and settings fields as needed
782
-		return apply_filters( 'give_registered_settings', $give_settings[ $active_tab ] );
782
+		return apply_filters('give_registered_settings', $give_settings[$active_tab]);
783 783
 
784 784
 	}
785 785
 
@@ -788,11 +788,11 @@  discard block
 block discarded – undo
788 788
 	 */
789 789
 	public function settings_notices() {
790 790
 
791
-		if ( ! isset( $_POST['give_settings_saved'] ) ) {
791
+		if ( ! isset($_POST['give_settings_saved'])) {
792 792
 			return;
793 793
 		}
794 794
 
795
-		add_settings_error( 'give-notices', 'global-settings-updated', __( 'Settings updated.', 'give' ), 'updated' );
795
+		add_settings_error('give-notices', 'global-settings-updated', __('Settings updated.', 'give'), 'updated');
796 796
 
797 797
 	}
798 798
 
@@ -806,17 +806,17 @@  discard block
 block discarded – undo
806 806
 	 *
807 807
 	 * @return mixed          Field value or exception is thrown
808 808
 	 */
809
-	public function __get( $field ) {
809
+	public function __get($field) {
810 810
 
811 811
 		// Allowed fields to retrieve
812
-		if ( in_array( $field, array( 'key', 'fields', 'give_title', 'options_page' ), true ) ) {
812
+		if (in_array($field, array('key', 'fields', 'give_title', 'options_page'), true)) {
813 813
 			return $this->{$field};
814 814
 		}
815
-		if ( 'option_metabox' === $field ) {
815
+		if ('option_metabox' === $field) {
816 816
 			return $this->option_metabox();
817 817
 		}
818 818
 
819
-		throw new Exception( 'Invalid property: ' . $field );
819
+		throw new Exception('Invalid property: '.$field);
820 820
 	}
821 821
 
822 822
 
@@ -833,12 +833,12 @@  discard block
 block discarded – undo
833 833
  *
834 834
  * @return mixed        Option value
835 835
  */
836
-function give_get_option( $key = '', $default = false ) {
836
+function give_get_option($key = '', $default = false) {
837 837
 	global $give_options;
838
-	$value = ! empty( $give_options[ $key ] ) ? $give_options[ $key ] : $default;
839
-	$value = apply_filters( 'give_get_option', $value, $key, $default );
838
+	$value = ! empty($give_options[$key]) ? $give_options[$key] : $default;
839
+	$value = apply_filters('give_get_option', $value, $key, $default);
840 840
 
841
-	return apply_filters( 'give_get_option_' . $key, $value, $key, $default );
841
+	return apply_filters('give_get_option_'.$key, $value, $key, $default);
842 842
 }
843 843
 
844 844
 
@@ -856,33 +856,33 @@  discard block
 block discarded – undo
856 856
  *
857 857
  * @return boolean True if updated, false if not.
858 858
  */
859
-function give_update_option( $key = '', $value = false ) {
859
+function give_update_option($key = '', $value = false) {
860 860
 
861 861
 	// If no key, exit
862
-	if ( empty( $key ) ) {
862
+	if (empty($key)) {
863 863
 		return false;
864 864
 	}
865 865
 
866
-	if ( empty( $value ) ) {
867
-		$remove_option = give_delete_option( $key );
866
+	if (empty($value)) {
867
+		$remove_option = give_delete_option($key);
868 868
 
869 869
 		return $remove_option;
870 870
 	}
871 871
 
872 872
 	// First let's grab the current settings
873
-	$options = get_option( 'give_settings' );
873
+	$options = get_option('give_settings');
874 874
 
875 875
 	// Let's let devs alter that value coming in
876
-	$value = apply_filters( 'give_update_option', $value, $key );
876
+	$value = apply_filters('give_update_option', $value, $key);
877 877
 
878 878
 	// Next let's try to update the value
879
-	$options[ $key ] = $value;
880
-	$did_update      = update_option( 'give_settings', $options );
879
+	$options[$key] = $value;
880
+	$did_update      = update_option('give_settings', $options);
881 881
 
882 882
 	// If it updated, let's update the global variable
883
-	if ( $did_update ) {
883
+	if ($did_update) {
884 884
 		global $give_options;
885
-		$give_options[ $key ] = $value;
885
+		$give_options[$key] = $value;
886 886
 	}
887 887
 
888 888
 	return $did_update;
@@ -899,27 +899,27 @@  discard block
 block discarded – undo
899 899
  *
900 900
  * @return boolean True if updated, false if not.
901 901
  */
902
-function give_delete_option( $key = '' ) {
902
+function give_delete_option($key = '') {
903 903
 
904 904
 	// If no key, exit
905
-	if ( empty( $key ) ) {
905
+	if (empty($key)) {
906 906
 		return false;
907 907
 	}
908 908
 
909 909
 	// First let's grab the current settings
910
-	$options = get_option( 'give_settings' );
910
+	$options = get_option('give_settings');
911 911
 
912 912
 	// Next let's try to update the value
913
-	if ( isset( $options[ $key ] ) ) {
913
+	if (isset($options[$key])) {
914 914
 
915
-		unset( $options[ $key ] );
915
+		unset($options[$key]);
916 916
 
917 917
 	}
918 918
 
919
-	$did_update = update_option( 'give_settings', $options );
919
+	$did_update = update_option('give_settings', $options);
920 920
 
921 921
 	// If it updated, let's update the global variable
922
-	if ( $did_update ) {
922
+	if ($did_update) {
923 923
 		global $give_options;
924 924
 		$give_options = $options;
925 925
 	}
@@ -938,9 +938,9 @@  discard block
 block discarded – undo
938 938
  */
939 939
 function give_get_settings() {
940 940
 
941
-	$settings = get_option( 'give_settings' );
941
+	$settings = get_option('give_settings');
942 942
 
943
-	return (array) apply_filters( 'give_get_settings', $settings );
943
+	return (array) apply_filters('give_get_settings', $settings);
944 944
 
945 945
 }
946 946
 
@@ -958,25 +958,25 @@  discard block
 block discarded – undo
958 958
  *
959 959
  * @return array
960 960
  */
961
-function give_settings_array_insert( $array, $position, $insert ) {
962
-	if ( is_int( $position ) ) {
963
-		array_splice( $array, $position, 0, $insert );
961
+function give_settings_array_insert($array, $position, $insert) {
962
+	if (is_int($position)) {
963
+		array_splice($array, $position, 0, $insert);
964 964
 	} else {
965 965
 
966
-		foreach ( $array as $index => $subarray ) {
967
-			if ( isset( $subarray['id'] ) && $subarray['id'] == $position ) {
966
+		foreach ($array as $index => $subarray) {
967
+			if (isset($subarray['id']) && $subarray['id'] == $position) {
968 968
 				$pos = $index;
969 969
 			}
970 970
 		}
971 971
 
972
-		if ( ! isset( $pos ) ) {
972
+		if ( ! isset($pos)) {
973 973
 			return $array;
974 974
 		}
975 975
 
976 976
 		$array = array_merge(
977
-			array_slice( $array, 0, $pos ),
977
+			array_slice($array, 0, $pos),
978 978
 			$insert,
979
-			array_slice( $array, $pos )
979
+			array_slice($array, $pos)
980 980
 		);
981 981
 	}
982 982
 
@@ -999,31 +999,31 @@  discard block
 block discarded – undo
999 999
  *
1000 1000
  * @return void
1001 1001
  */
1002
-function give_enabled_gateways_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) {
1002
+function give_enabled_gateways_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) {
1003 1003
 
1004 1004
 	$id                = $field_type_object->field->args['id'];
1005 1005
 	$field_description = $field_type_object->field->args['desc'];
1006
-	$gateways          = give_get_ordered_payment_gateways( give_get_payment_gateways() );
1006
+	$gateways          = give_get_ordered_payment_gateways(give_get_payment_gateways());
1007 1007
 
1008 1008
 	echo '<ul class="cmb2-checkbox-list cmb2-list">';
1009 1009
 
1010
-	foreach ( $gateways as $key => $option ) :
1010
+	foreach ($gateways as $key => $option) :
1011 1011
 
1012
-		if ( is_array( $escaped_value ) && array_key_exists( $key, $escaped_value ) ) {
1012
+		if (is_array($escaped_value) && array_key_exists($key, $escaped_value)) {
1013 1013
 			$enabled = '1';
1014 1014
 		} else {
1015 1015
 			$enabled = null;
1016 1016
 		}
1017 1017
 
1018
-		echo '<li><span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span><input name="' . $id . '[' . $key . ']" id="' . $id . '[' . $key . ']" type="checkbox" value="1" ' . checked( '1', $enabled, false ) . '/>&nbsp;';
1019
-		echo '<label for="' . $id . '[' . $key . ']">' . $option['admin_label'] . '</label></li>';
1018
+		echo '<li><span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span><input name="'.$id.'['.$key.']" id="'.$id.'['.$key.']" type="checkbox" value="1" '.checked('1', $enabled, false).'/>&nbsp;';
1019
+		echo '<label for="'.$id.'['.$key.']">'.$option['admin_label'].'</label></li>';
1020 1020
 
1021 1021
 	endforeach;
1022 1022
 
1023 1023
 	echo '</ul>';
1024 1024
 
1025
-	if ( $field_description ) {
1026
-		echo '<p class="cmb2-metabox-description">' . $field_description . '</p>';
1025
+	if ($field_description) {
1026
+		echo '<p class="cmb2-metabox-description">'.$field_description.'</p>';
1027 1027
 	}
1028 1028
 
1029 1029
 }
@@ -1039,31 +1039,31 @@  discard block
 block discarded – undo
1039 1039
  *
1040 1040
  * @return void
1041 1041
  */
1042
-function give_default_gateway_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) {
1042
+function give_default_gateway_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) {
1043 1043
 
1044 1044
 	$id                = $field_type_object->field->args['id'];
1045 1045
 	$field_description = $field_type_object->field->args['desc'];
1046 1046
 	$gateways          = give_get_enabled_payment_gateways();
1047 1047
 
1048
-	echo '<select class="cmb2_select" name="' . $id . '" id="' . $id . '">';
1048
+	echo '<select class="cmb2_select" name="'.$id.'" id="'.$id.'">';
1049 1049
 
1050 1050
 	//Add a field to the Give Form admin single post view of this field
1051
-	if ( $field_type_object->field->object_type === 'post' ) {
1052
-		echo '<option value="global">' . __( 'Global Default', 'give' ) . '</option>';
1051
+	if ($field_type_object->field->object_type === 'post') {
1052
+		echo '<option value="global">'.__('Global Default', 'give').'</option>';
1053 1053
 	}
1054 1054
 
1055
-	foreach ( $gateways as $key => $option ) :
1055
+	foreach ($gateways as $key => $option) :
1056 1056
 
1057
-		$selected = isset( $escaped_value ) ? selected( $key, $escaped_value, false ) : '';
1057
+		$selected = isset($escaped_value) ? selected($key, $escaped_value, false) : '';
1058 1058
 
1059 1059
 
1060
-		echo '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
1060
+		echo '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option['admin_label']).'</option>';
1061 1061
 
1062 1062
 	endforeach;
1063 1063
 
1064 1064
 	echo '</select>';
1065 1065
 
1066
-	echo '<p class="cmb2-metabox-description">' . $field_description . '</p>';
1066
+	echo '<p class="cmb2-metabox-description">'.$field_description.'</p>';
1067 1067
 
1068 1068
 }
1069 1069
 
@@ -1078,13 +1078,13 @@  discard block
 block discarded – undo
1078 1078
  *
1079 1079
  * @return void
1080 1080
  */
1081
-function give_title_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) {
1081
+function give_title_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) {
1082 1082
 
1083 1083
 	$id                = $field_type_object->field->args['id'];
1084 1084
 	$title             = $field_type_object->field->args['name'];
1085 1085
 	$field_description = $field_type_object->field->args['desc'];
1086 1086
 
1087
-	echo '<hr>' . $field_description;
1087
+	echo '<hr>'.$field_description;
1088 1088
 
1089 1089
 }
1090 1090
 
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
  *
1100 1100
  * @return void
1101 1101
  */
1102
-function give_description_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) {
1102
+function give_description_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) {
1103 1103
 
1104 1104
 	$id                = $field_type_object->field->args['id'];
1105 1105
 	$title             = $field_type_object->field->args['name'];
@@ -1119,25 +1119,25 @@  discard block
 block discarded – undo
1119 1119
  * @see: https://github.com/WebDevStudios/CMB2/wiki/Adding-your-own-field-types
1120 1120
  * @return array An array of options that matches the CMB2 options array
1121 1121
  */
1122
-function give_cmb2_get_post_options( $query_args, $force = false ) {
1122
+function give_cmb2_get_post_options($query_args, $force = false) {
1123 1123
 
1124
-	$post_options = array( '' => '' ); // Blank option
1124
+	$post_options = array('' => ''); // Blank option
1125 1125
 
1126
-	if ( ( ! isset( $_GET['page'] ) || 'give-settings' != $_GET['page'] ) && ! $force ) {
1126
+	if (( ! isset($_GET['page']) || 'give-settings' != $_GET['page']) && ! $force) {
1127 1127
 		return $post_options;
1128 1128
 	}
1129 1129
 
1130
-	$args = wp_parse_args( $query_args, array(
1130
+	$args = wp_parse_args($query_args, array(
1131 1131
 		'post_type'   => 'page',
1132 1132
 		'numberposts' => 10,
1133
-	) );
1133
+	));
1134 1134
 
1135
-	$posts = get_posts( $args );
1135
+	$posts = get_posts($args);
1136 1136
 
1137
-	if ( $posts ) {
1138
-		foreach ( $posts as $post ) {
1137
+	if ($posts) {
1138
+		foreach ($posts as $post) {
1139 1139
 
1140
-			$post_options[ $post->ID ] = $post->post_title;
1140
+			$post_options[$post->ID] = $post->post_title;
1141 1141
 
1142 1142
 		}
1143 1143
 	}
@@ -1157,17 +1157,17 @@  discard block
 block discarded – undo
1157 1157
 	global $_wp_additional_image_sizes;
1158 1158
 	$sizes = array();
1159 1159
 
1160
-	foreach ( get_intermediate_image_sizes() as $_size ) {
1160
+	foreach (get_intermediate_image_sizes() as $_size) {
1161 1161
 
1162
-		if ( in_array( $_size, array( 'thumbnail', 'medium', 'medium_large', 'large' ) ) ) {
1163
-			$sizes[ $_size ] = $_size . ' - ' . get_option( "{$_size}_size_w" ) . 'x' . get_option( "{$_size}_size_h" );
1164
-		} elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
1165
-			$sizes[ $_size ] = $_size . ' - ' . $_wp_additional_image_sizes[ $_size ]['width'] . 'x' . $_wp_additional_image_sizes[ $_size ]['height'];
1162
+		if (in_array($_size, array('thumbnail', 'medium', 'medium_large', 'large'))) {
1163
+			$sizes[$_size] = $_size.' - '.get_option("{$_size}_size_w").'x'.get_option("{$_size}_size_h");
1164
+		} elseif (isset($_wp_additional_image_sizes[$_size])) {
1165
+			$sizes[$_size] = $_size.' - '.$_wp_additional_image_sizes[$_size]['width'].'x'.$_wp_additional_image_sizes[$_size]['height'];
1166 1166
 		}
1167 1167
 
1168 1168
 	}
1169 1169
 
1170
-	return apply_filters( 'give_get_featured_image_sizes', $sizes );
1170
+	return apply_filters('give_get_featured_image_sizes', $sizes);
1171 1171
 }
1172 1172
 
1173 1173
 
@@ -1181,34 +1181,34 @@  discard block
 block discarded – undo
1181 1181
  *
1182 1182
  * @return void
1183 1183
  */
1184
-function give_license_key_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) {
1184
+function give_license_key_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) {
1185 1185
 
1186 1186
 	$id                = $field_type_object->field->args['id'];
1187 1187
 	$field_description = $field_type_object->field->args['desc'];
1188
-	$license_status    = get_option( $field_type_object->field->args['options']['is_valid_license_option'] );
1188
+	$license_status    = get_option($field_type_object->field->args['options']['is_valid_license_option']);
1189 1189
 	$field_classes     = 'regular-text give-license-field';
1190
-	$type              = empty( $escaped_value ) ? 'text' : 'password';
1190
+	$type              = empty($escaped_value) ? 'text' : 'password';
1191 1191
 
1192
-	if ( $license_status === 'valid' ) {
1192
+	if ($license_status === 'valid') {
1193 1193
 		$field_classes .= ' give-license-active';
1194 1194
 	}
1195 1195
 
1196
-	$html = $field_type_object->input( array(
1196
+	$html = $field_type_object->input(array(
1197 1197
 		'class' => $field_classes,
1198 1198
 		'type'  => $type
1199
-	) );
1199
+	));
1200 1200
 
1201 1201
 	//License is active so show deactivate button
1202
-	if ( $license_status === 'valid' ) {
1203
-		$html .= '<input type="submit" class="button-secondary give-license-deactivate" name="' . $id . '_deactivate" value="' . __( 'Deactivate License', 'give' ) . '"/>';
1202
+	if ($license_status === 'valid') {
1203
+		$html .= '<input type="submit" class="button-secondary give-license-deactivate" name="'.$id.'_deactivate" value="'.__('Deactivate License', 'give').'"/>';
1204 1204
 	} else {
1205 1205
 		//This license is not valid so delete it
1206
-		give_delete_option( $id );
1206
+		give_delete_option($id);
1207 1207
 	}
1208 1208
 
1209
-	$html .= '<label for="give_settings[' . $id . ']"> ' . $field_description . '</label>';
1209
+	$html .= '<label for="give_settings['.$id.']"> '.$field_description.'</label>';
1210 1210
 
1211
-	wp_nonce_field( $id . '-nonce', $id . '-nonce' );
1211
+	wp_nonce_field($id.'-nonce', $id.'-nonce');
1212 1212
 
1213 1213
 	echo $html;
1214 1214
 }
@@ -1222,13 +1222,13 @@  discard block
 block discarded – undo
1222 1222
  */
1223 1223
 function give_api_callback() {
1224 1224
 
1225
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
1225
+	if ( ! current_user_can('manage_give_settings')) {
1226 1226
 		return;
1227 1227
 	}
1228 1228
 
1229
-	do_action( 'give_tools_api_keys_before' );
1229
+	do_action('give_tools_api_keys_before');
1230 1230
 
1231
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php';
1231
+	require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php';
1232 1232
 
1233 1233
 	$api_keys_table = new Give_API_Keys_Table();
1234 1234
 	$api_keys_table->prepare_items();
@@ -1236,17 +1236,17 @@  discard block
 block discarded – undo
1236 1236
 	?>
1237 1237
 	<span class="cmb2-metabox-description api-description">
1238 1238
 		<?php echo sprintf(
1239
-			__( 'You can create API keys for individual users within their profile edit screen. API keys allow users to use the <a href="%1$s" target="_blank">Give REST API</a> to retrieve donation data in JSON or XML for external applications or devices, such as <a href="%2$s" target="_blank">Zapier</a>.', 'give' ),
1240
-			esc_url( 'https://givewp.com/documentation/give-api-reference/' ),
1241
-			esc_url( 'https://givewp.com/addons/zapier/' )
1239
+			__('You can create API keys for individual users within their profile edit screen. API keys allow users to use the <a href="%1$s" target="_blank">Give REST API</a> to retrieve donation data in JSON or XML for external applications or devices, such as <a href="%2$s" target="_blank">Zapier</a>.', 'give'),
1240
+			esc_url('https://givewp.com/documentation/give-api-reference/'),
1241
+			esc_url('https://givewp.com/addons/zapier/')
1242 1242
 		); ?>
1243 1243
 	</span>
1244 1244
 	<?php
1245 1245
 
1246
-	do_action( 'give_tools_api_keys_after' );
1246
+	do_action('give_tools_api_keys_after');
1247 1247
 }
1248 1248
 
1249
-add_action( 'give_settings_tab_api_keys', 'give_api_callback' );
1249
+add_action('give_settings_tab_api_keys', 'give_api_callback');
1250 1250
 
1251 1251
 /**
1252 1252
  * Hook Callback
@@ -1259,8 +1259,8 @@  discard block
 block discarded – undo
1259 1259
  *
1260 1260
  * @return void
1261 1261
  */
1262
-function give_hook_callback( $args ) {
1263
-	do_action( 'give_' . $args['id'] );
1262
+function give_hook_callback($args) {
1263
+	do_action('give_'.$args['id']);
1264 1264
 }
1265 1265
 
1266 1266
 /**
@@ -1270,10 +1270,10 @@  discard block
 block discarded – undo
1270 1270
  *
1271 1271
  */
1272 1272
 
1273
-if ( file_exists( WP_PLUGIN_DIR . '/cmb2/init.php' ) && ! defined( 'CMB2_LOADED' ) ) {
1274
-	require_once WP_PLUGIN_DIR . '/cmb2/init.php';
1275
-} elseif ( file_exists( GIVE_PLUGIN_DIR . '/includes/libraries/cmb2/init.php' ) && ! defined( 'CMB2_LOADED' ) ) {
1276
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/cmb2/init.php';
1277
-} elseif ( file_exists( GIVE_PLUGIN_DIR . '/includes/libraries/CMB2/init.php' ) && ! defined( 'CMB2_LOADED' ) ) {
1278
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/CMB2/init.php';
1273
+if (file_exists(WP_PLUGIN_DIR.'/cmb2/init.php') && ! defined('CMB2_LOADED')) {
1274
+	require_once WP_PLUGIN_DIR.'/cmb2/init.php';
1275
+} elseif (file_exists(GIVE_PLUGIN_DIR.'/includes/libraries/cmb2/init.php') && ! defined('CMB2_LOADED')) {
1276
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/cmb2/init.php';
1277
+} elseif (file_exists(GIVE_PLUGIN_DIR.'/includes/libraries/CMB2/init.php') && ! defined('CMB2_LOADED')) {
1278
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/CMB2/init.php';
1279 1279
 }
1280 1280
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/reporting/export/export-functions.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
18
-require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export.php';
19
-require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/export-actions.php';
18
+require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export.php';
19
+require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/export-actions.php';
20 20
 
21 21
 /**
22 22
  * Process batch exports via ajax
@@ -26,79 +26,79 @@  discard block
 block discarded – undo
26 26
  */
27 27
 function give_do_ajax_export() {
28 28
 
29
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php';
29
+	require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export.php';
30 30
 
31
-	parse_str( $_POST['form'], $form );
31
+	parse_str($_POST['form'], $form);
32 32
 
33 33
 	$_REQUEST = $form = (array) $form;
34 34
 
35
-	if ( ! wp_verify_nonce( $_REQUEST['give_ajax_export'], 'give_ajax_export' ) ) {
36
-		die( '-2' );
35
+	if ( ! wp_verify_nonce($_REQUEST['give_ajax_export'], 'give_ajax_export')) {
36
+		die('-2');
37 37
 	}
38 38
 
39
-	do_action( 'give_batch_export_class_include', $form['give-export-class'] );
39
+	do_action('give_batch_export_class_include', $form['give-export-class']);
40 40
 
41
-	$step   = absint( $_POST['step'] );
42
-	$class  = sanitize_text_field( $form['give-export-class'] );
41
+	$step   = absint($_POST['step']);
42
+	$class  = sanitize_text_field($form['give-export-class']);
43 43
 
44
-	$export = new $class( $step );
44
+	$export = new $class($step);
45 45
 
46
-	if ( ! $export->can_export() ) {
47
-		die( '-1' );
46
+	if ( ! $export->can_export()) {
47
+		die('-1');
48 48
 	}
49 49
 
50
-	if ( ! $export->is_writable ) {
50
+	if ( ! $export->is_writable) {
51 51
 		$json_args = array(
52 52
 			'error'   => true,
53
-			'message' => __( 'Export location or file not writable.', 'give' )
53
+			'message' => __('Export location or file not writable.', 'give')
54 54
 		);
55 55
 		echo json_encode($json_args);
56 56
 		exit;
57 57
 	}
58 58
 
59
-	$export->set_properties( $_REQUEST );
59
+	$export->set_properties($_REQUEST);
60 60
 
61 61
 	$export->pre_fetch();
62 62
 
63
-	$ret = $export->process_step( $step );
63
+	$ret = $export->process_step($step);
64 64
 
65 65
 	$percentage = $export->get_percentage_complete();
66 66
 
67
-	if ( $ret ) {
67
+	if ($ret) {
68 68
 
69 69
 		$step += 1;
70
-		echo json_encode( array( 'step' => $step, 'percentage' => $percentage ) );
70
+		echo json_encode(array('step' => $step, 'percentage' => $percentage));
71 71
 		exit;
72 72
 
73
-	} elseif ( true === $export->is_empty ) {
73
+	} elseif (true === $export->is_empty) {
74 74
 
75
-		echo json_encode( array(
75
+		echo json_encode(array(
76 76
 			'error'   => true,
77
-			'message' => __( 'No data found for export parameters.', 'give' )
78
-		) );
77
+			'message' => __('No data found for export parameters.', 'give')
78
+		));
79 79
 		exit;
80 80
 
81
-	} elseif ( true === $export->done && true === $export->is_void ) {
81
+	} elseif (true === $export->done && true === $export->is_void) {
82 82
 
83
-		$message = ! empty( $export->message ) ? $export->message : __( 'Batch Processing Complete', 'give' );
84
-		echo json_encode( array( 'success' => true, 'message' => $message ) );
83
+		$message = ! empty($export->message) ? $export->message : __('Batch Processing Complete', 'give');
84
+		echo json_encode(array('success' => true, 'message' => $message));
85 85
 		exit;
86 86
 
87 87
 	} else {
88 88
 		
89
-		$args = array_merge( $_REQUEST, array(
89
+		$args = array_merge($_REQUEST, array(
90 90
 			'step'        => $step,
91 91
 			'class'       => $class,
92
-			'nonce'       => wp_create_nonce( 'give-batch-export' ),
92
+			'nonce'       => wp_create_nonce('give-batch-export'),
93 93
 			'give_action' => 'form_batch_export',
94
-		) );
94
+		));
95 95
 
96
-		$download_url = add_query_arg( $args, admin_url() );
96
+		$download_url = add_query_arg($args, admin_url());
97 97
 
98
-		echo json_encode( array( 'step' => 'done', 'url' => $download_url ) );
98
+		echo json_encode(array('step' => 'done', 'url' => $download_url));
99 99
 		exit;
100 100
 
101 101
 	}
102 102
 }
103 103
 
104
-add_action( 'wp_ajax_give_do_ajax_export', 'give_do_ajax_export' );
104
+add_action('wp_ajax_give_do_ajax_export', 'give_do_ajax_export');
Please login to merge, or discard this patch.
includes/admin/reporting/export/export-actions.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
11 11
  */
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -22,20 +22,20 @@  discard block
 block discarded – undo
22 22
  */
23 23
 function give_process_batch_export_form() {
24 24
 
25
-	if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'give-batch-export' ) ) {
26
-		wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
25
+	if ( ! wp_verify_nonce($_REQUEST['nonce'], 'give-batch-export')) {
26
+		wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403));
27 27
 	}
28 28
 
29
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php';
29
+	require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export.php';
30 30
 
31
-	do_action( 'give_batch_export_class_include', $_REQUEST['class'] );
31
+	do_action('give_batch_export_class_include', $_REQUEST['class']);
32 32
 
33 33
 	$export = new $_REQUEST['class'];
34 34
 	$export->export();
35 35
 
36 36
 }
37 37
 
38
-add_action( 'give_form_batch_export', 'give_process_batch_export_form' );
38
+add_action('give_form_batch_export', 'give_process_batch_export_form');
39 39
 
40 40
 /**
41 41
  * Exports earnings for a specified time period
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
  * @return void
47 47
  */
48 48
 function give_export_earnings() {
49
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-earnings.php';
49
+	require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-earnings.php';
50 50
 
51 51
 	$earnings_export = new Give_Earnings_Export();
52 52
 
53 53
 	$earnings_export->export();
54 54
 }
55 55
 
56
-add_action( 'give_earnings_export', 'give_export_earnings' );
56
+add_action('give_earnings_export', 'give_export_earnings');
57 57
 
58 58
 
59 59
 /**
@@ -66,14 +66,14 @@  discard block
 block discarded – undo
66 66
  * @return void
67 67
  */
68 68
 function give_export_all_customers() {
69
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-customers.php';
69
+	require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-customers.php';
70 70
 
71 71
 	$customer_export = new Give_Donors_Export();
72 72
 
73 73
 	$customer_export->export();
74 74
 }
75 75
 
76
-add_action( 'give_email_export', 'give_export_all_customers' );
76
+add_action('give_email_export', 'give_export_all_customers');
77 77
 
78 78
 /**
79 79
  * Add a hook allowing extensions to register a hook on the batch export process
@@ -82,22 +82,22 @@  discard block
 block discarded – undo
82 82
  * @return void
83 83
  */
84 84
 function give_register_batch_exporters() {
85
-	if ( is_admin() ) {
86
-		do_action( 'give_register_batch_exporter' );
85
+	if (is_admin()) {
86
+		do_action('give_register_batch_exporter');
87 87
 	}
88 88
 }
89 89
 
90
-add_action( 'plugins_loaded', 'give_register_batch_exporters' );
90
+add_action('plugins_loaded', 'give_register_batch_exporters');
91 91
 
92 92
 /**
93 93
  * Register the payments batch exporter
94 94
  * @since  1.5
95 95
  */
96 96
 function give_register_payments_batch_export() {
97
-	add_action( 'give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1 );
97
+	add_action('give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1);
98 98
 }
99 99
 
100
-add_action( 'give_register_batch_exporter', 'give_register_payments_batch_export', 10 );
100
+add_action('give_register_batch_exporter', 'give_register_payments_batch_export', 10);
101 101
 
102 102
 /**
103 103
  * Loads the payments batch process if needed
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
  *
109 109
  * @return void
110 110
  */
111
-function give_include_payments_batch_processor( $class ) {
111
+function give_include_payments_batch_processor($class) {
112 112
 
113
-	if ( 'Give_Batch_Payments_Export' === $class ) {
114
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-payments.php';
113
+	if ('Give_Batch_Payments_Export' === $class) {
114
+		require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-payments.php';
115 115
 	}
116 116
 
117 117
 }
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
  * @since  1.5.2
122 122
  */
123 123
 function give_register_customers_batch_export() {
124
-	add_action( 'give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1 );
124
+	add_action('give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1);
125 125
 }
126 126
 
127
-add_action( 'give_register_batch_exporter', 'give_register_customers_batch_export', 10 );
127
+add_action('give_register_batch_exporter', 'give_register_customers_batch_export', 10);
128 128
 
129 129
 /**
130 130
  * Loads the customers batch process if needed
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
  *
136 136
  * @return void
137 137
  */
138
-function give_include_customers_batch_processor( $class ) {
138
+function give_include_customers_batch_processor($class) {
139 139
 
140
-	if ( 'Give_Batch_Customers_Export' === $class ) {
141
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-customers.php';
140
+	if ('Give_Batch_Customers_Export' === $class) {
141
+		require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-customers.php';
142 142
 	}
143 143
 
144 144
 }
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
  * @since  1.5
150 150
  */
151 151
 function give_register_forms_batch_export() {
152
-	add_action( 'give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1 );
152
+	add_action('give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1);
153 153
 }
154 154
 
155
-add_action( 'give_register_batch_exporter', 'give_register_forms_batch_export', 10 );
155
+add_action('give_register_batch_exporter', 'give_register_forms_batch_export', 10);
156 156
 
157 157
 /**
158 158
  * Loads the file downloads batch process if needed
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
  *
164 164
  * @return void
165 165
  */
166
-function give_include_forms_batch_processor( $class ) {
166
+function give_include_forms_batch_processor($class) {
167 167
 
168
-	if ( 'Give_Batch_Forms_Export' === $class ) {
169
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-forms.php';
168
+	if ('Give_Batch_Forms_Export' === $class) {
169
+		require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-forms.php';
170 170
 	}
171 171
 
172 172
 }
173 173
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/reporting/pdf-reports.php 1 patch
Spacing   +144 added lines, -144 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
 
@@ -25,75 +25,75 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * @uses   give_pdf
27 27
  */
28
-function give_generate_pdf( $data ) {
28
+function give_generate_pdf($data) {
29 29
 
30
-	if ( ! current_user_can( 'view_give_reports' ) ) {
31
-		wp_die( __( 'You do not have permission to generate PDF sales reports.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
30
+	if ( ! current_user_can('view_give_reports')) {
31
+		wp_die(__('You do not have permission to generate PDF sales reports.', 'give'), __('Error', 'give'), array('response' => 403));
32 32
 	}
33 33
 
34
-	if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'give_generate_pdf' ) ) {
35
-		wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
34
+	if ( ! wp_verify_nonce($_GET['_wpnonce'], 'give_generate_pdf')) {
35
+		wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403));
36 36
 	}
37 37
 
38
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/fpdf.php';
39
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/give_pdf.php';
38
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/fpdf/fpdf.php';
39
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/fpdf/give_pdf.php';
40 40
 
41
-	$daterange = date_i18n( get_option( 'date_format' ), mktime( 0, 0, 0, 1, 1, date( 'Y' ) ) ) . ' ' . utf8_decode( __( 'to', 'give' ) ) . ' ' . date_i18n( get_option( 'date_format' ) );
41
+	$daterange = date_i18n(get_option('date_format'), mktime(0, 0, 0, 1, 1, date('Y'))).' '.utf8_decode(__('to', 'give')).' '.date_i18n(get_option('date_format'));
42 42
 
43 43
 	$pdf = new give_pdf();
44
-	$pdf->AddPage( 'L', 'A4' );
44
+	$pdf->AddPage('L', 'A4');
45 45
 
46
-	$pdf->SetTitle( utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ) );
47
-	$pdf->SetAuthor( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) );
48
-	$pdf->SetCreator( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) );
46
+	$pdf->SetTitle(utf8_decode(__('Donation report for the current year for all forms', 'give')));
47
+	$pdf->SetAuthor(utf8_decode(__('Give - Democratizing Generosity', 'give')));
48
+	$pdf->SetCreator(utf8_decode(__('Give - Democratizing Generosity', 'give')));
49 49
 
50
-	$pdf->Image( GIVE_PLUGIN_URL . 'assets/images/give-logo-small.png', 247, 8 );
50
+	$pdf->Image(GIVE_PLUGIN_URL.'assets/images/give-logo-small.png', 247, 8);
51 51
 
52
-	$pdf->SetMargins( 8, 8, 8 );
53
-	$pdf->SetX( 8 );
52
+	$pdf->SetMargins(8, 8, 8);
53
+	$pdf->SetX(8);
54 54
 
55
-	$pdf->SetFont( 'Helvetica', '', 16 );
56
-	$pdf->SetTextColor( 50, 50, 50 );
57
-	$pdf->Cell( 0, 3, utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ), 0, 2, 'L', false );
55
+	$pdf->SetFont('Helvetica', '', 16);
56
+	$pdf->SetTextColor(50, 50, 50);
57
+	$pdf->Cell(0, 3, utf8_decode(__('Donation report for the current year for all forms', 'give')), 0, 2, 'L', false);
58 58
 
59
-	$pdf->SetFont( 'Helvetica', '', 13 );
59
+	$pdf->SetFont('Helvetica', '', 13);
60 60
 	$pdf->Ln();
61
-	$pdf->SetTextColor( 150, 150, 150 );
62
-	$pdf->Cell( 0, 6, utf8_decode( __( 'Date Range: ', 'give' ) ) . $daterange, 0, 2, 'L', false );
61
+	$pdf->SetTextColor(150, 150, 150);
62
+	$pdf->Cell(0, 6, utf8_decode(__('Date Range: ', 'give')).$daterange, 0, 2, 'L', false);
63 63
 	$pdf->Ln();
64
-	$pdf->SetTextColor( 50, 50, 50 );
65
-	$pdf->SetFont( 'Helvetica', '', 14 );
66
-	$pdf->Cell( 0, 10, utf8_decode( __( 'Table View', 'give' ) ), 0, 2, 'L', false );
67
-	$pdf->SetFont( 'Helvetica', '', 12 );
64
+	$pdf->SetTextColor(50, 50, 50);
65
+	$pdf->SetFont('Helvetica', '', 14);
66
+	$pdf->Cell(0, 10, utf8_decode(__('Table View', 'give')), 0, 2, 'L', false);
67
+	$pdf->SetFont('Helvetica', '', 12);
68 68
 
69
-	$pdf->SetFillColor( 238, 238, 238 );
70
-	$pdf->Cell( 70, 6, utf8_decode( __( 'Form Name', 'give' ) ), 1, 0, 'L', true );
71
-	$pdf->Cell( 30, 6, utf8_decode( __( 'Price', 'give' ) ), 1, 0, 'L', true );
72
-	$pdf->Cell( 50, 6, utf8_decode( __( 'Categories', 'give' ) ), 1, 0, 'L', true );
73
-	$pdf->Cell( 50, 6, utf8_decode( __( 'Tags', 'give' ) ), 1, 0, 'L', true );
74
-	$pdf->Cell( 45, 6, utf8_decode( __( 'Number of Donations', 'give' ) ), 1, 0, 'L', true );
75
-	$pdf->Cell( 35, 6, utf8_decode( __( 'Income to Date', 'give' ) ), 1, 1, 'L', true );
69
+	$pdf->SetFillColor(238, 238, 238);
70
+	$pdf->Cell(70, 6, utf8_decode(__('Form Name', 'give')), 1, 0, 'L', true);
71
+	$pdf->Cell(30, 6, utf8_decode(__('Price', 'give')), 1, 0, 'L', true);
72
+	$pdf->Cell(50, 6, utf8_decode(__('Categories', 'give')), 1, 0, 'L', true);
73
+	$pdf->Cell(50, 6, utf8_decode(__('Tags', 'give')), 1, 0, 'L', true);
74
+	$pdf->Cell(45, 6, utf8_decode(__('Number of Donations', 'give')), 1, 0, 'L', true);
75
+	$pdf->Cell(35, 6, utf8_decode(__('Income to Date', 'give')), 1, 1, 'L', true);
76 76
 
77
-	$year       = date( 'Y' );
78
-	$give_forms = get_posts( array( 'post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => - 1 ) );
77
+	$year       = date('Y');
78
+	$give_forms = get_posts(array('post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => -1));
79 79
 
80
-	if ( $give_forms ):
81
-		$pdf->SetWidths( array( 70, 30, 50, 50, 45, 35 ) );
80
+	if ($give_forms):
81
+		$pdf->SetWidths(array(70, 30, 50, 50, 45, 35));
82 82
 
83
-		foreach ( $give_forms as $form ):
84
-			$pdf->SetFillColor( 255, 255, 255 );
83
+		foreach ($give_forms as $form):
84
+			$pdf->SetFillColor(255, 255, 255);
85 85
 
86 86
 			$title = $form->post_title;
87 87
 
88
-			if ( give_has_variable_prices( $form->ID ) ) {
88
+			if (give_has_variable_prices($form->ID)) {
89 89
 
90
-				$prices = give_get_variable_prices( $form->ID );
90
+				$prices = give_get_variable_prices($form->ID);
91 91
 
92 92
 				$first = $prices[0]['_give_amount'];
93
-				$last  = array_pop( $prices );
93
+				$last  = array_pop($prices);
94 94
 				$last  = $last['_give_amount'];
95 95
 
96
-				if ( $first < $last ) {
96
+				if ($first < $last) {
97 97
 					$min = $first;
98 98
 					$max = $last;
99 99
 				} else {
@@ -101,51 +101,51 @@  discard block
 block discarded – undo
101 101
 					$max = $first;
102 102
 				}
103 103
 
104
-				$price = html_entity_decode( give_currency_filter( give_format_amount( $min ) ) . ' - ' . give_currency_filter( give_format_amount( $max ) ) );
104
+				$price = html_entity_decode(give_currency_filter(give_format_amount($min)).' - '.give_currency_filter(give_format_amount($max)));
105 105
 			} else {
106
-				$price = html_entity_decode( give_currency_filter( give_get_form_price( $form->ID ) ) );
106
+				$price = html_entity_decode(give_currency_filter(give_get_form_price($form->ID)));
107 107
 			}
108 108
 
109
-			$categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' );
110
-			$categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : '';
109
+			$categories = get_the_term_list($form->ID, 'give_forms_category', '', ', ', '');
110
+			$categories = ! is_wp_error($categories) ? strip_tags($categories) : '';
111 111
 
112
-			$tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' );
113
-			$tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : '';
112
+			$tags = get_the_term_list($form->ID, 'give_forms_tag', '', ', ', '');
113
+			$tags = ! is_wp_error($tags) ? strip_tags($tags) : '';
114 114
 
115
-			$sales    = give_get_form_sales_stats( $form->ID );
116
-			$link     = get_permalink( $form->ID );
117
-			$earnings = html_entity_decode( give_currency_filter( give_get_form_earnings_stats( $form->ID ) ) );
115
+			$sales    = give_get_form_sales_stats($form->ID);
116
+			$link     = get_permalink($form->ID);
117
+			$earnings = html_entity_decode(give_currency_filter(give_get_form_earnings_stats($form->ID)));
118 118
 
119
-			if ( function_exists( 'iconv' ) ) {
119
+			if (function_exists('iconv')) {
120 120
 				// Ensure characters like euro; are properly converted.
121
-				$price    = iconv( 'UTF-8', 'windows-1252', utf8_encode( $price ) );
122
-				$earnings = iconv( 'UTF-8', 'windows-1252', utf8_encode( $earnings ) );
121
+				$price    = iconv('UTF-8', 'windows-1252', utf8_encode($price));
122
+				$earnings = iconv('UTF-8', 'windows-1252', utf8_encode($earnings));
123 123
 			}
124 124
 
125
-			$pdf->Row( array( $title, $price, $categories, $tags, $sales, $earnings ) );
125
+			$pdf->Row(array($title, $price, $categories, $tags, $sales, $earnings));
126 126
 		endforeach;
127 127
 	else:
128
-		$pdf->SetWidths( array( 280 ) );
129
-		$title = utf8_decode( sprintf( __( 'No %s found.', 'give' ), give_get_forms_label_plural() ) );
130
-		$pdf->Row( array( $title ) );
128
+		$pdf->SetWidths(array(280));
129
+		$title = utf8_decode(sprintf(__('No %s found.', 'give'), give_get_forms_label_plural()));
130
+		$pdf->Row(array($title));
131 131
 	endif;
132 132
 
133 133
 	$pdf->Ln();
134
-	$pdf->SetTextColor( 50, 50, 50 );
135
-	$pdf->SetFont( 'Helvetica', '', 14 );
136
-	$pdf->Cell( 0, 10, utf8_decode( __( 'Graph View', 'give' ) ), 0, 2, 'L', false );
137
-	$pdf->SetFont( 'Helvetica', '', 12 );
138
-
139
-	$image = html_entity_decode( urldecode( give_draw_chart_image() ) );
140
-	$image = str_replace( ' ', '%20', $image );
141
-
142
-	$pdf->SetX( 25 );
143
-	$pdf->Image( $image . '&file=.png' );
144
-	$pdf->Ln( 7 );
145
-	$pdf->Output( apply_filters( 'give_sales_earnings_pdf_export_filename', 'give-report-' . date_i18n( 'Y-m-d' ) ) . '.pdf', 'D' );
134
+	$pdf->SetTextColor(50, 50, 50);
135
+	$pdf->SetFont('Helvetica', '', 14);
136
+	$pdf->Cell(0, 10, utf8_decode(__('Graph View', 'give')), 0, 2, 'L', false);
137
+	$pdf->SetFont('Helvetica', '', 12);
138
+
139
+	$image = html_entity_decode(urldecode(give_draw_chart_image()));
140
+	$image = str_replace(' ', '%20', $image);
141
+
142
+	$pdf->SetX(25);
143
+	$pdf->Image($image.'&file=.png');
144
+	$pdf->Ln(7);
145
+	$pdf->Output(apply_filters('give_sales_earnings_pdf_export_filename', 'give-report-'.date_i18n('Y-m-d')).'.pdf', 'D');
146 146
 }
147 147
 
148
-add_action( 'give_generate_pdf', 'give_generate_pdf' );
148
+add_action('give_generate_pdf', 'give_generate_pdf');
149 149
 
150 150
 /**
151 151
  * Draws Chart for PDF Report
@@ -162,38 +162,38 @@  discard block
 block discarded – undo
162 162
  * @return string $chart->getUrl() URL for the Google Chart
163 163
  */
164 164
 function give_draw_chart_image() {
165
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/GoogleChart.php';
166
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php';
167
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php';
165
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/GoogleChart.php';
166
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php';
167
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php';
168 168
 
169
-	$chart = new GoogleChart( 'lc', 900, 330 );
169
+	$chart = new GoogleChart('lc', 900, 330);
170 170
 
171 171
 	$i        = 1;
172 172
 	$earnings = "";
173 173
 	$sales    = "";
174 174
 
175
-	while ( $i <= 12 ) :
176
-		$earnings .= give_get_earnings_by_date( null, $i, date( 'Y' ) ) . ",";
177
-		$sales .= give_get_sales_by_date( null, $i, date( 'Y' ) ) . ",";
178
-		$i ++;
175
+	while ($i <= 12) :
176
+		$earnings .= give_get_earnings_by_date(null, $i, date('Y')).",";
177
+		$sales .= give_get_sales_by_date(null, $i, date('Y')).",";
178
+		$i++;
179 179
 	endwhile;
180 180
 
181
-	$earnings_array = explode( ",", $earnings );
182
-	$sales_array    = explode( ",", $sales );
181
+	$earnings_array = explode(",", $earnings);
182
+	$sales_array    = explode(",", $sales);
183 183
 
184 184
 	$i = 0;
185
-	while ( $i <= 11 ) {
186
-		if ( empty( $sales_array[ $i ] ) ) {
187
-			$sales_array[ $i ] = 0;
185
+	while ($i <= 11) {
186
+		if (empty($sales_array[$i])) {
187
+			$sales_array[$i] = 0;
188 188
 		}
189
-		$i ++;
189
+		$i++;
190 190
 	}
191 191
 
192 192
 	$min_earnings   = 0;
193
-	$max_earnings   = max( $earnings_array );
194
-	$earnings_scale = round( $max_earnings, - 1 );
193
+	$max_earnings   = max($earnings_array);
194
+	$earnings_scale = round($max_earnings, - 1);
195 195
 
196
-	$data = new GoogleChartData( array(
196
+	$data = new GoogleChartData(array(
197 197
 		$earnings_array[0],
198 198
 		$earnings_array[1],
199 199
 		$earnings_array[2],
@@ -206,25 +206,25 @@  discard block
 block discarded – undo
206 206
 		$earnings_array[9],
207 207
 		$earnings_array[10],
208 208
 		$earnings_array[11]
209
-	) );
209
+	));
210 210
 
211
-	$data->setLegend( __( 'Income', 'give' ) );
212
-	$data->setColor( '1b58a3' );
213
-	$chart->addData( $data );
211
+	$data->setLegend(__('Income', 'give'));
212
+	$data->setColor('1b58a3');
213
+	$chart->addData($data);
214 214
 
215
-	$shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE );
216
-	$shape_marker->setColor( '000000' );
217
-	$shape_marker->setSize( 7 );
218
-	$shape_marker->setBorder( 2 );
219
-	$shape_marker->setData( $data );
220
-	$chart->addMarker( $shape_marker );
215
+	$shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE);
216
+	$shape_marker->setColor('000000');
217
+	$shape_marker->setSize(7);
218
+	$shape_marker->setBorder(2);
219
+	$shape_marker->setData($data);
220
+	$chart->addMarker($shape_marker);
221 221
 
222
-	$value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE );
223
-	$value_marker->setColor( '000000' );
224
-	$value_marker->setData( $data );
225
-	$chart->addMarker( $value_marker );
222
+	$value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE);
223
+	$value_marker->setColor('000000');
224
+	$value_marker->setData($data);
225
+	$chart->addMarker($value_marker);
226 226
 
227
-	$data = new GoogleChartData( array(
227
+	$data = new GoogleChartData(array(
228 228
 		$sales_array[0],
229 229
 		$sales_array[1],
230 230
 		$sales_array[2],
@@ -237,46 +237,46 @@  discard block
 block discarded – undo
237 237
 		$sales_array[9],
238 238
 		$sales_array[10],
239 239
 		$sales_array[11]
240
-	) );
241
-	$data->setLegend( __( 'Donations', 'give' ) );
242
-	$data->setColor( 'ff6c1c' );
243
-	$chart->addData( $data );
244
-
245
-	$chart->setTitle( __( 'Donations by Month for all Give Forms', 'give' ), '336699', 18 );
246
-
247
-	$chart->setScale( 0, $max_earnings );
248
-
249
-	$y_axis = new GoogleChartAxis( 'y' );
250
-	$y_axis->setDrawTickMarks( true )->setLabels( array( 0, $max_earnings ) );
251
-	$chart->addAxis( $y_axis );
252
-
253
-	$x_axis = new GoogleChartAxis( 'x' );
254
-	$x_axis->setTickMarks( 5 );
255
-	$x_axis->setLabels( array(
256
-		__( 'Jan', 'give' ),
257
-		__( 'Feb', 'give' ),
258
-		__( 'Mar', 'give' ),
259
-		__( 'Apr', 'give' ),
260
-		__( 'May', 'give' ),
261
-		__( 'June', 'give' ),
262
-		__( 'July', 'give' ),
263
-		__( 'Aug', 'give' ),
264
-		__( 'Sept', 'give' ),
265
-		__( 'Oct', 'give' ),
266
-		__( 'Nov', 'give' ),
267
-		__( 'Dec', 'give' )
268
-	) );
269
-	$chart->addAxis( $x_axis );
270
-
271
-	$shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE );
272
-	$shape_marker->setSize( 6 );
273
-	$shape_marker->setBorder( 2 );
274
-	$shape_marker->setData( $data );
275
-	$chart->addMarker( $shape_marker );
276
-
277
-	$value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE );
278
-	$value_marker->setData( $data );
279
-	$chart->addMarker( $value_marker );
240
+	));
241
+	$data->setLegend(__('Donations', 'give'));
242
+	$data->setColor('ff6c1c');
243
+	$chart->addData($data);
244
+
245
+	$chart->setTitle(__('Donations by Month for all Give Forms', 'give'), '336699', 18);
246
+
247
+	$chart->setScale(0, $max_earnings);
248
+
249
+	$y_axis = new GoogleChartAxis('y');
250
+	$y_axis->setDrawTickMarks(true)->setLabels(array(0, $max_earnings));
251
+	$chart->addAxis($y_axis);
252
+
253
+	$x_axis = new GoogleChartAxis('x');
254
+	$x_axis->setTickMarks(5);
255
+	$x_axis->setLabels(array(
256
+		__('Jan', 'give'),
257
+		__('Feb', 'give'),
258
+		__('Mar', 'give'),
259
+		__('Apr', 'give'),
260
+		__('May', 'give'),
261
+		__('June', 'give'),
262
+		__('July', 'give'),
263
+		__('Aug', 'give'),
264
+		__('Sept', 'give'),
265
+		__('Oct', 'give'),
266
+		__('Nov', 'give'),
267
+		__('Dec', 'give')
268
+	));
269
+	$chart->addAxis($x_axis);
270
+
271
+	$shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE);
272
+	$shape_marker->setSize(6);
273
+	$shape_marker->setBorder(2);
274
+	$shape_marker->setData($data);
275
+	$chart->addMarker($shape_marker);
276
+
277
+	$value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE);
278
+	$value_marker->setData($data);
279
+	$chart->addMarker($value_marker);
280 280
 
281 281
 	return $chart->getUrl();
282 282
 }
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' => __( 'The name of completed donation form and the donation level chosen if applicable.', 'give' ),
275
+			'description' => __('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' => __( 'The donor\'s first name.', 'give' ),
280
+			'description' => __('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' => __( 'The donor\'s full name, first and last.', 'give' ),
285
+			'description' => __('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' => __( 'The donor\'s user name on the site, if they registered an account.', 'give' ),
290
+			'description' => __('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' => __( 'The donor\'s email address.', 'give' ),
295
+			'description' => __('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' => __( 'The donor\'s billing address.', 'give' ),
300
+			'description' => __('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' => __( 'The date of the donation.', 'give' ),
305
+			'description' => __('The date of the donation.', 'give'),
306 306
 			'function'    => 'give_email_tag_date'
307 307
 		),
308 308
 		array(
309 309
 			'tag'         => 'price',
310
-			'description' => __( 'The total price of the donation.', 'give' ),
310
+			'description' => __('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' => __( 'The unique ID number for this donation.', 'give' ),
315
+			'description' => __('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' => __( 'The unique ID number for this donation receipt.', 'give' ),
320
+			'description' => __('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' => __( 'The method of payment used for this donation.', 'give' ),
325
+			'description' => __('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' => __( 'Your site name', 'give' ),
330
+			'description' => __('Your site name', 'give'),
331 331
 			'function'    => 'give_email_tag_sitename'
332 332
 		),
333 333
 		array(
334 334
 			'tag'         => 'receipt_link',
335
-			'description' => __( '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' => __('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 = 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 = give_get_payment_form_title($payment->meta, false, '-');
529 529
 
530
-	return ! empty( $form_title ) ? $form_title : __( 'There was an error retrieving this donation title.', 'give' );
530
+	return ! empty($form_title) ? $form_title : __('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
-		__( 'View it in your browser', 'give' )
578
+		__('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/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' => __( 'Default Template', 'give' ),
164
-			'none'    => __( 'No template, plain text only', 'give' )
163
+			'default' => __('Default Template', 'give'),
164
+			'none'    => __('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__, __( '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__, __('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/api/class-give-api.php 1 patch
Spacing   +478 added lines, -478 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
 
@@ -139,27 +139,27 @@  discard block
 block discarded – undo
139 139
 			'v1' => 'GIVE_API_V1',
140 140
 		);
141 141
 
142
-		foreach ( $this->get_versions() as $version => $class ) {
143
-			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php';
142
+		foreach ($this->get_versions() as $version => $class) {
143
+			require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php';
144 144
 		}
145 145
 
146
-		add_action( 'init', array( $this, 'add_endpoint' ) );
147
-		add_action( 'wp', array( $this, 'process_query' ), - 1 );
148
-		add_filter( 'query_vars', array( $this, 'query_vars' ) );
149
-		add_action( 'show_user_profile', array( $this, 'user_key_field' ) );
150
-		add_action( 'edit_user_profile', array( $this, 'user_key_field' ) );
151
-		add_action( 'personal_options_update', array( $this, 'update_key' ) );
152
-		add_action( 'edit_user_profile_update', array( $this, 'update_key' ) );
153
-		add_action( 'give_process_api_key', array( $this, 'process_api_key' ) );
146
+		add_action('init', array($this, 'add_endpoint'));
147
+		add_action('wp', array($this, 'process_query'), - 1);
148
+		add_filter('query_vars', array($this, 'query_vars'));
149
+		add_action('show_user_profile', array($this, 'user_key_field'));
150
+		add_action('edit_user_profile', array($this, 'user_key_field'));
151
+		add_action('personal_options_update', array($this, 'update_key'));
152
+		add_action('edit_user_profile_update', array($this, 'update_key'));
153
+		add_action('give_process_api_key', array($this, 'process_api_key'));
154 154
 
155 155
 		// Setup a backwards compatibility check for user API Keys
156
-		add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 );
156
+		add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4);
157 157
 
158 158
 		// Determine if JSON_PRETTY_PRINT is available
159
-		$this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null;
159
+		$this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null;
160 160
 
161 161
 		// Allow API request logging to be turned off
162
-		$this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests );
162
+		$this->log_requests = apply_filters('give_api_log_requests', $this->log_requests);
163 163
 
164 164
 		// Setup Give_Payment_Stats instance
165 165
 		$this->stats = new Give_Payment_Stats;
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 	 *
176 176
 	 * @since  1.1
177 177
 	 */
178
-	public function add_endpoint( $rewrite_rules ) {
179
-		add_rewrite_endpoint( 'give-api', EP_ALL );
178
+	public function add_endpoint($rewrite_rules) {
179
+		add_rewrite_endpoint('give-api', EP_ALL);
180 180
 	}
181 181
 
182 182
 	/**
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 *
190 190
 	 * @return string[] $vars New query vars
191 191
 	 */
192
-	public function query_vars( $vars ) {
192
+	public function query_vars($vars) {
193 193
 
194 194
 		$vars[] = 'token';
195 195
 		$vars[] = 'key';
@@ -240,11 +240,11 @@  discard block
 block discarded – undo
240 240
 	 */
241 241
 	public function get_default_version() {
242 242
 
243
-		$version = get_option( 'give_default_api_version' );
243
+		$version = get_option('give_default_api_version');
244 244
 
245
-		if ( defined( 'GIVE_API_VERSION' ) ) {
245
+		if (defined('GIVE_API_VERSION')) {
246 246
 			$version = GIVE_API_VERSION;
247
-		} elseif ( ! $version ) {
247
+		} elseif ( ! $version) {
248 248
 			$version = 'v1';
249 249
 		}
250 250
 
@@ -265,14 +265,14 @@  discard block
 block discarded – undo
265 265
 
266 266
 		$version = $wp_query->query_vars['give-api'];
267 267
 
268
-		if ( strpos( $version, '/' ) ) {
268
+		if (strpos($version, '/')) {
269 269
 
270
-			$version = explode( '/', $version );
271
-			$version = strtolower( $version[0] );
270
+			$version = explode('/', $version);
271
+			$version = strtolower($version[0]);
272 272
 
273
-			$wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] );
273
+			$wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']);
274 274
 
275
-			if ( array_key_exists( $version, $this->versions ) ) {
275
+			if (array_key_exists($version, $this->versions)) {
276 276
 
277 277
 				$this->queried_version = $version;
278 278
 
@@ -309,32 +309,32 @@  discard block
 block discarded – undo
309 309
 		$this->override = false;
310 310
 
311 311
 		// Make sure we have both user and api key
312
-		if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] != 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) {
312
+		if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] != 'forms' || ! empty($wp_query->query_vars['token']))) {
313 313
 
314
-			if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) {
314
+			if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) {
315 315
 				$this->missing_auth();
316 316
 			}
317 317
 
318 318
 			// Retrieve the user by public API key and ensure they exist
319
-			if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) {
319
+			if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) {
320 320
 
321 321
 				$this->invalid_key();
322 322
 
323 323
 			} else {
324 324
 
325
-				$token  = urldecode( $wp_query->query_vars['token'] );
326
-				$secret = $this->get_user_secret_key( $user );
327
-				$public = urldecode( $wp_query->query_vars['key'] );
325
+				$token  = urldecode($wp_query->query_vars['token']);
326
+				$secret = $this->get_user_secret_key($user);
327
+				$public = urldecode($wp_query->query_vars['key']);
328 328
 
329
-				if ( hash_equals( md5( $secret . $public ), $token ) ) {
329
+				if (hash_equals(md5($secret.$public), $token)) {
330 330
 					$this->is_valid_request = true;
331 331
 				} else {
332 332
 					$this->invalid_auth();
333 333
 				}
334 334
 			}
335
-		} elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] == 'forms' ) {
335
+		} elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] == 'forms') {
336 336
 			$this->is_valid_request = true;
337
-			$wp_query->set( 'key', 'public' );
337
+			$wp_query->set('key', 'public');
338 338
 		}
339 339
 	}
340 340
 
@@ -350,25 +350,25 @@  discard block
 block discarded – undo
350 350
 	 *
351 351
 	 * @return bool if user ID is found, false otherwise
352 352
 	 */
353
-	public function get_user( $key = '' ) {
353
+	public function get_user($key = '') {
354 354
 		global $wpdb, $wp_query;
355 355
 
356
-		if ( empty( $key ) ) {
357
-			$key = urldecode( $wp_query->query_vars['key'] );
356
+		if (empty($key)) {
357
+			$key = urldecode($wp_query->query_vars['key']);
358 358
 		}
359 359
 
360
-		if ( empty( $key ) ) {
360
+		if (empty($key)) {
361 361
 			return false;
362 362
 		}
363 363
 
364
-		$user = get_transient( md5( 'give_api_user_' . $key ) );
364
+		$user = get_transient(md5('give_api_user_'.$key));
365 365
 
366
-		if ( false === $user ) {
367
-			$user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) );
368
-			set_transient( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS );
366
+		if (false === $user) {
367
+			$user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key));
368
+			set_transient(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS);
369 369
 		}
370 370
 
371
-		if ( $user != null ) {
371
+		if ($user != null) {
372 372
 			$this->user_id = $user;
373 373
 
374 374
 			return $user;
@@ -377,37 +377,37 @@  discard block
 block discarded – undo
377 377
 		return false;
378 378
 	}
379 379
 
380
-	public function get_user_public_key( $user_id = 0 ) {
380
+	public function get_user_public_key($user_id = 0) {
381 381
 		global $wpdb;
382 382
 
383
-		if ( empty( $user_id ) ) {
383
+		if (empty($user_id)) {
384 384
 			return '';
385 385
 		}
386 386
 
387
-		$cache_key       = md5( 'give_api_user_public_key' . $user_id );
388
-		$user_public_key = get_transient( $cache_key );
387
+		$cache_key       = md5('give_api_user_public_key'.$user_id);
388
+		$user_public_key = get_transient($cache_key);
389 389
 
390
-		if ( empty( $user_public_key ) ) {
391
-			$user_public_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id ) );
392
-			set_transient( $cache_key, $user_public_key, HOUR_IN_SECONDS );
390
+		if (empty($user_public_key)) {
391
+			$user_public_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id));
392
+			set_transient($cache_key, $user_public_key, HOUR_IN_SECONDS);
393 393
 		}
394 394
 
395 395
 		return $user_public_key;
396 396
 	}
397 397
 
398
-	public function get_user_secret_key( $user_id = 0 ) {
398
+	public function get_user_secret_key($user_id = 0) {
399 399
 		global $wpdb;
400 400
 
401
-		if ( empty( $user_id ) ) {
401
+		if (empty($user_id)) {
402 402
 			return '';
403 403
 		}
404 404
 
405
-		$cache_key       = md5( 'give_api_user_secret_key' . $user_id );
406
-		$user_secret_key = get_transient( $cache_key );
405
+		$cache_key       = md5('give_api_user_secret_key'.$user_id);
406
+		$user_secret_key = get_transient($cache_key);
407 407
 
408
-		if ( empty( $user_secret_key ) ) {
409
-			$user_secret_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id ) );
410
-			set_transient( $cache_key, $user_secret_key, HOUR_IN_SECONDS );
408
+		if (empty($user_secret_key)) {
409
+			$user_secret_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id));
410
+			set_transient($cache_key, $user_secret_key, HOUR_IN_SECONDS);
411 411
 		}
412 412
 
413 413
 		return $user_secret_key;
@@ -423,10 +423,10 @@  discard block
 block discarded – undo
423 423
 	 */
424 424
 	private function missing_auth() {
425 425
 		$error          = array();
426
-		$error['error'] = esc_attr__( 'You must specify both a token and API key!', 'give' );
426
+		$error['error'] = esc_attr__('You must specify both a token and API key!', 'give');
427 427
 
428 428
 		$this->data = $error;
429
-		$this->output( 401 );
429
+		$this->output(401);
430 430
 	}
431 431
 
432 432
 	/**
@@ -440,10 +440,10 @@  discard block
 block discarded – undo
440 440
 	 */
441 441
 	private function invalid_auth() {
442 442
 		$error          = array();
443
-		$error['error'] = esc_attr__( 'Your request could not be authenticated!', 'give' );
443
+		$error['error'] = esc_attr__('Your request could not be authenticated!', 'give');
444 444
 
445 445
 		$this->data = $error;
446
-		$this->output( 403 );
446
+		$this->output(403);
447 447
 	}
448 448
 
449 449
 	/**
@@ -457,10 +457,10 @@  discard block
 block discarded – undo
457 457
 	 */
458 458
 	private function invalid_key() {
459 459
 		$error          = array();
460
-		$error['error'] = esc_attr__( 'Invalid API key!', 'give' );
460
+		$error['error'] = esc_attr__('Invalid API key!', 'give');
461 461
 
462 462
 		$this->data = $error;
463
-		$this->output( 403 );
463
+		$this->output(403);
464 464
 	}
465 465
 
466 466
 	/**
@@ -473,10 +473,10 @@  discard block
 block discarded – undo
473 473
 	 */
474 474
 	private function invalid_version() {
475 475
 		$error          = array();
476
-		$error['error'] = esc_attr__( 'Invalid API version!', 'give' );
476
+		$error['error'] = esc_attr__('Invalid API version!', 'give');
477 477
 
478 478
 		$this->data = $error;
479
-		$this->output( 404 );
479
+		$this->output(404);
480 480
 	}
481 481
 
482 482
 	/**
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
 		global $wp_query;
493 493
 
494 494
 		// Start logging how long the request takes for logging
495
-		$before = microtime( true );
495
+		$before = microtime(true);
496 496
 
497 497
 		// Check for give-api var. Get out if not present
498
-		if ( empty( $wp_query->query_vars['give-api'] ) ) {
498
+		if (empty($wp_query->query_vars['give-api'])) {
499 499
 			return;
500 500
 		}
501 501
 
@@ -509,45 +509,45 @@  discard block
 block discarded – undo
509 509
 		$this->validate_request();
510 510
 
511 511
 		// Only proceed if no errors have been noted
512
-		if ( ! $this->is_valid_request ) {
512
+		if ( ! $this->is_valid_request) {
513 513
 			return;
514 514
 		}
515 515
 
516
-		if ( ! defined( 'GIVE_DOING_API' ) ) {
517
-			define( 'GIVE_DOING_API', true );
516
+		if ( ! defined('GIVE_DOING_API')) {
517
+			define('GIVE_DOING_API', true);
518 518
 		}
519 519
 
520 520
 		$data         = array();
521 521
 		$this->routes = new $this->versions[$this->get_queried_version()];
522 522
 		$this->routes->validate_request();
523 523
 
524
-		switch ( $this->endpoint ) :
524
+		switch ($this->endpoint) :
525 525
 
526 526
 			case 'stats' :
527 527
 
528
-				$data = $this->routes->get_stats( array(
529
-					'type'      => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
530
-					'form'      => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
531
-					'date'      => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
532
-					'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
533
-					'enddate'   => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null
534
-				) );
528
+				$data = $this->routes->get_stats(array(
529
+					'type'      => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
530
+					'form'      => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
531
+					'date'      => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
532
+					'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
533
+					'enddate'   => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null
534
+				));
535 535
 
536 536
 				break;
537 537
 
538 538
 			case 'forms' :
539 539
 
540
-				$form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null;
540
+				$form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null;
541 541
 
542
-				$data = $this->routes->get_forms( $form );
542
+				$data = $this->routes->get_forms($form);
543 543
 
544 544
 				break;
545 545
 
546 546
 			case 'donors' :
547 547
 
548
-				$customer = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null;
548
+				$customer = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null;
549 549
 
550
-				$data = $this->routes->get_customers( $customer );
550
+				$data = $this->routes->get_customers($customer);
551 551
 
552 552
 				break;
553 553
 
@@ -560,14 +560,14 @@  discard block
 block discarded – undo
560 560
 		endswitch;
561 561
 
562 562
 		// Allow extensions to setup their own return data
563
-		$this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this );
563
+		$this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this);
564 564
 
565
-		$after                       = microtime( true );
566
-		$request_time                = ( $after - $before );
565
+		$after                       = microtime(true);
566
+		$request_time                = ($after - $before);
567 567
 		$this->data['request_speed'] = $request_time;
568 568
 
569 569
 		// Log this API request, if enabled. We log it here because we have access to errors.
570
-		$this->log_request( $this->data );
570
+		$this->log_request($this->data);
571 571
 
572 572
 		// Send out data to the output function
573 573
 		$this->output();
@@ -597,25 +597,25 @@  discard block
 block discarded – undo
597 597
 		global $wp_query;
598 598
 
599 599
 		// Whitelist our query options
600
-		$accepted = apply_filters( 'give_api_valid_query_modes', array(
600
+		$accepted = apply_filters('give_api_valid_query_modes', array(
601 601
 			'stats',
602 602
 			'forms',
603 603
 			'donors',
604 604
 			'donations'
605
-		) );
605
+		));
606 606
 
607
-		$query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null;
608
-		$query = str_replace( $this->queried_version . '/', '', $query );
607
+		$query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null;
608
+		$query = str_replace($this->queried_version.'/', '', $query);
609 609
 
610 610
 		$error = array();
611 611
 
612 612
 		// Make sure our query is valid
613
-		if ( ! in_array( $query, $accepted ) ) {
614
-			$error['error'] = __( 'Invalid query!', 'give' );
613
+		if ( ! in_array($query, $accepted)) {
614
+			$error['error'] = __('Invalid query!', 'give');
615 615
 
616 616
 			$this->data = $error;
617 617
 			// 400 is Bad Request
618
-			$this->output( 400 );
618
+			$this->output(400);
619 619
 		}
620 620
 
621 621
 		$this->endpoint = $query;
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 	public function get_paged() {
633 633
 		global $wp_query;
634 634
 
635
-		return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1;
635
+		return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1;
636 636
 	}
637 637
 
638 638
 
@@ -647,13 +647,13 @@  discard block
 block discarded – undo
647 647
 	public function per_page() {
648 648
 		global $wp_query;
649 649
 
650
-		$per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10;
650
+		$per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10;
651 651
 
652
-		if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) {
652
+		if ($per_page < 0 && $this->get_query_mode() == 'donors') {
653 653
 			$per_page = 99999999;
654 654
 		} // Customers query doesn't support -1
655 655
 
656
-		return apply_filters( 'give_api_results_per_page', $per_page );
656
+		return apply_filters('give_api_results_per_page', $per_page);
657 657
 	}
658 658
 
659 659
 	/**
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 	 *
667 667
 	 * @return array $dates
668 668
 	 */
669
-	public function get_dates( $args = array() ) {
669
+	public function get_dates($args = array()) {
670 670
 		$dates = array();
671 671
 
672 672
 		$defaults = array(
@@ -677,60 +677,60 @@  discard block
 block discarded – undo
677 677
 			'enddate'   => null
678 678
 		);
679 679
 
680
-		$args = wp_parse_args( $args, $defaults );
680
+		$args = wp_parse_args($args, $defaults);
681 681
 
682
-		$current_time = current_time( 'timestamp' );
682
+		$current_time = current_time('timestamp');
683 683
 
684
-		if ( 'range' === $args['date'] ) {
685
-			$startdate          = strtotime( $args['startdate'] );
686
-			$enddate            = strtotime( $args['enddate'] );
687
-			$dates['day_start'] = date( 'd', $startdate );
688
-			$dates['day_end']   = date( 'd', $enddate );
689
-			$dates['m_start']   = date( 'n', $startdate );
690
-			$dates['m_end']     = date( 'n', $enddate );
691
-			$dates['year']      = date( 'Y', $startdate );
692
-			$dates['year_end']  = date( 'Y', $enddate );
684
+		if ('range' === $args['date']) {
685
+			$startdate          = strtotime($args['startdate']);
686
+			$enddate            = strtotime($args['enddate']);
687
+			$dates['day_start'] = date('d', $startdate);
688
+			$dates['day_end']   = date('d', $enddate);
689
+			$dates['m_start']   = date('n', $startdate);
690
+			$dates['m_end']     = date('n', $enddate);
691
+			$dates['year']      = date('Y', $startdate);
692
+			$dates['year_end']  = date('Y', $enddate);
693 693
 		} else {
694 694
 			// Modify dates based on predefined ranges
695
-			switch ( $args['date'] ) :
695
+			switch ($args['date']) :
696 696
 
697 697
 				case 'this_month' :
698 698
 					$dates['day']     = null;
699
-					$dates['m_start'] = date( 'n', $current_time );
700
-					$dates['m_end']   = date( 'n', $current_time );
701
-					$dates['year']    = date( 'Y', $current_time );
699
+					$dates['m_start'] = date('n', $current_time);
700
+					$dates['m_end']   = date('n', $current_time);
701
+					$dates['year']    = date('Y', $current_time);
702 702
 					break;
703 703
 
704 704
 				case 'last_month' :
705 705
 					$dates['day']     = null;
706
-					$dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1;
706
+					$dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1;
707 707
 					$dates['m_end']   = $dates['m_start'];
708
-					$dates['year']    = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time );
708
+					$dates['year']    = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time);
709 709
 					break;
710 710
 
711 711
 				case 'today' :
712
-					$dates['day']     = date( 'd', $current_time );
713
-					$dates['m_start'] = date( 'n', $current_time );
714
-					$dates['m_end']   = date( 'n', $current_time );
715
-					$dates['year']    = date( 'Y', $current_time );
712
+					$dates['day']     = date('d', $current_time);
713
+					$dates['m_start'] = date('n', $current_time);
714
+					$dates['m_end']   = date('n', $current_time);
715
+					$dates['year']    = date('Y', $current_time);
716 716
 					break;
717 717
 
718 718
 				case 'yesterday' :
719 719
 
720
-					$year  = date( 'Y', $current_time );
721
-					$month = date( 'n', $current_time );
722
-					$day   = date( 'd', $current_time );
720
+					$year  = date('Y', $current_time);
721
+					$month = date('n', $current_time);
722
+					$day   = date('d', $current_time);
723 723
 
724
-					if ( $month == 1 && $day == 1 ) {
724
+					if ($month == 1 && $day == 1) {
725 725
 
726 726
 						$year -= 1;
727 727
 						$month = 12;
728
-						$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
728
+						$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
729 729
 
730
-					} elseif ( $month > 1 && $day == 1 ) {
730
+					} elseif ($month > 1 && $day == 1) {
731 731
 
732 732
 						$month -= 1;
733
-						$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
733
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
734 734
 
735 735
 					} else {
736 736
 
@@ -746,65 +746,65 @@  discard block
 block discarded – undo
746 746
 					break;
747 747
 
748 748
 				case 'this_quarter' :
749
-					$month_now = date( 'n', $current_time );
749
+					$month_now = date('n', $current_time);
750 750
 
751 751
 					$dates['day'] = null;
752 752
 
753
-					if ( $month_now <= 3 ) {
753
+					if ($month_now <= 3) {
754 754
 
755 755
 						$dates['m_start'] = 1;
756 756
 						$dates['m_end']   = 3;
757
-						$dates['year']    = date( 'Y', $current_time );
757
+						$dates['year']    = date('Y', $current_time);
758 758
 
759
-					} else if ( $month_now <= 6 ) {
759
+					} else if ($month_now <= 6) {
760 760
 
761 761
 						$dates['m_start'] = 4;
762 762
 						$dates['m_end']   = 6;
763
-						$dates['year']    = date( 'Y', $current_time );
763
+						$dates['year']    = date('Y', $current_time);
764 764
 
765
-					} else if ( $month_now <= 9 ) {
765
+					} else if ($month_now <= 9) {
766 766
 
767 767
 						$dates['m_start'] = 7;
768 768
 						$dates['m_end']   = 9;
769
-						$dates['year']    = date( 'Y', $current_time );
769
+						$dates['year']    = date('Y', $current_time);
770 770
 
771 771
 					} else {
772 772
 
773 773
 						$dates['m_start'] = 10;
774 774
 						$dates['m_end']   = 12;
775
-						$dates['year']    = date( 'Y', $current_time );
775
+						$dates['year']    = date('Y', $current_time);
776 776
 
777 777
 					}
778 778
 					break;
779 779
 
780 780
 				case 'last_quarter' :
781
-					$month_now = date( 'n', $current_time );
781
+					$month_now = date('n', $current_time);
782 782
 
783 783
 					$dates['day'] = null;
784 784
 
785
-					if ( $month_now <= 3 ) {
785
+					if ($month_now <= 3) {
786 786
 
787 787
 						$dates['m_start'] = 10;
788 788
 						$dates['m_end']   = 12;
789
-						$dates['year']    = date( 'Y', $current_time ) - 1; // Previous year
789
+						$dates['year']    = date('Y', $current_time) - 1; // Previous year
790 790
 
791
-					} else if ( $month_now <= 6 ) {
791
+					} else if ($month_now <= 6) {
792 792
 
793 793
 						$dates['m_start'] = 1;
794 794
 						$dates['m_end']   = 3;
795
-						$dates['year']    = date( 'Y', $current_time );
795
+						$dates['year']    = date('Y', $current_time);
796 796
 
797
-					} else if ( $month_now <= 9 ) {
797
+					} else if ($month_now <= 9) {
798 798
 
799 799
 						$dates['m_start'] = 4;
800 800
 						$dates['m_end']   = 6;
801
-						$dates['year']    = date( 'Y', $current_time );
801
+						$dates['year']    = date('Y', $current_time);
802 802
 
803 803
 					} else {
804 804
 
805 805
 						$dates['m_start'] = 7;
806 806
 						$dates['m_end']   = 9;
807
-						$dates['year']    = date( 'Y', $current_time );
807
+						$dates['year']    = date('Y', $current_time);
808 808
 
809 809
 					}
810 810
 					break;
@@ -813,14 +813,14 @@  discard block
 block discarded – undo
813 813
 					$dates['day']     = null;
814 814
 					$dates['m_start'] = null;
815 815
 					$dates['m_end']   = null;
816
-					$dates['year']    = date( 'Y', $current_time );
816
+					$dates['year']    = date('Y', $current_time);
817 817
 					break;
818 818
 
819 819
 				case 'last_year' :
820 820
 					$dates['day']     = null;
821 821
 					$dates['m_start'] = null;
822 822
 					$dates['m_end']   = null;
823
-					$dates['year']    = date( 'Y', $current_time ) - 1;
823
+					$dates['year']    = date('Y', $current_time) - 1;
824 824
 					break;
825 825
 
826 826
 			endswitch;
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 		 * @param object $dates The dates used for retreiving earnings/donations
835 835
 		 */
836 836
 
837
-		return apply_filters( 'give_api_stat_dates', $dates );
837
+		return apply_filters('give_api_stat_dates', $dates);
838 838
 	}
839 839
 
840 840
 	/**
@@ -849,11 +849,11 @@  discard block
 block discarded – undo
849 849
 	 *
850 850
 	 * @return array $customers Multidimensional array of the customers
851 851
 	 */
852
-	public function get_customers( $customer = null ) {
852
+	public function get_customers($customer = null) {
853 853
 
854 854
 		$customers = array();
855 855
 		$error     = array();
856
-		if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) {
856
+		if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) {
857 857
 			return $customers;
858 858
 		}
859 859
 
@@ -861,68 +861,68 @@  discard block
 block discarded – undo
861 861
 
862 862
 		$paged    = $this->get_paged();
863 863
 		$per_page = $this->per_page();
864
-		$offset   = $per_page * ( $paged - 1 );
864
+		$offset   = $per_page * ($paged - 1);
865 865
 
866
-		if ( is_numeric( $customer ) ) {
866
+		if (is_numeric($customer)) {
867 867
 			$field = 'id';
868 868
 		} else {
869 869
 			$field = 'email';
870 870
 		}
871 871
 
872
-		$customer_query = Give()->customers->get_customers( array(
872
+		$customer_query = Give()->customers->get_customers(array(
873 873
 			'number' => $per_page,
874 874
 			'offset' => $offset,
875 875
 			$field   => $customer
876
-		) );
876
+		));
877 877
 		$customer_count = 0;
878 878
 
879
-		if ( $customer_query ) {
879
+		if ($customer_query) {
880 880
 
881
-			foreach ( $customer_query as $customer_obj ) {
881
+			foreach ($customer_query as $customer_obj) {
882 882
 
883
-				$names      = explode( ' ', $customer_obj->name );
884
-				$first_name = ! empty( $names[0] ) ? $names[0] : '';
883
+				$names      = explode(' ', $customer_obj->name);
884
+				$first_name = ! empty($names[0]) ? $names[0] : '';
885 885
 				$last_name  = '';
886
-				if ( ! empty( $names[1] ) ) {
887
-					unset( $names[0] );
888
-					$last_name = implode( ' ', $names );
886
+				if ( ! empty($names[1])) {
887
+					unset($names[0]);
888
+					$last_name = implode(' ', $names);
889 889
 				}
890 890
 
891
-				$customers['donors'][ $customer_count ]['info']['user_id']      = '';
892
-				$customers['donors'][ $customer_count ]['info']['username']     = '';
893
-				$customers['donors'][ $customer_count ]['info']['display_name'] = '';
894
-				$customers['donors'][ $customer_count ]['info']['customer_id']  = $customer_obj->id;
895
-				$customers['donors'][ $customer_count ]['info']['first_name']   = $first_name;
896
-				$customers['donors'][ $customer_count ]['info']['last_name']    = $last_name;
897
-				$customers['donors'][ $customer_count ]['info']['email']        = $customer_obj->email;
891
+				$customers['donors'][$customer_count]['info']['user_id']      = '';
892
+				$customers['donors'][$customer_count]['info']['username']     = '';
893
+				$customers['donors'][$customer_count]['info']['display_name'] = '';
894
+				$customers['donors'][$customer_count]['info']['customer_id']  = $customer_obj->id;
895
+				$customers['donors'][$customer_count]['info']['first_name']   = $first_name;
896
+				$customers['donors'][$customer_count]['info']['last_name']    = $last_name;
897
+				$customers['donors'][$customer_count]['info']['email']        = $customer_obj->email;
898 898
 
899
-				if ( ! empty( $customer_obj->user_id ) ) {
899
+				if ( ! empty($customer_obj->user_id)) {
900 900
 
901
-					$user_data = get_userdata( $customer_obj->user_id );
901
+					$user_data = get_userdata($customer_obj->user_id);
902 902
 
903 903
 					// Customer with registered account
904
-					$customers['donors'][ $customer_count ]['info']['user_id']      = $customer_obj->user_id;
905
-					$customers['donors'][ $customer_count ]['info']['username']     = $user_data->user_login;
906
-					$customers['donors'][ $customer_count ]['info']['display_name'] = $user_data->display_name;
904
+					$customers['donors'][$customer_count]['info']['user_id']      = $customer_obj->user_id;
905
+					$customers['donors'][$customer_count]['info']['username']     = $user_data->user_login;
906
+					$customers['donors'][$customer_count]['info']['display_name'] = $user_data->display_name;
907 907
 
908 908
 				}
909 909
 
910
-				$customers['donors'][ $customer_count ]['stats']['total_donations'] = $customer_obj->purchase_count;
911
-				$customers['donors'][ $customer_count ]['stats']['total_spent']     = $customer_obj->purchase_value;
910
+				$customers['donors'][$customer_count]['stats']['total_donations'] = $customer_obj->purchase_count;
911
+				$customers['donors'][$customer_count]['stats']['total_spent']     = $customer_obj->purchase_value;
912 912
 
913
-				$customer_count ++;
913
+				$customer_count++;
914 914
 
915 915
 			}
916 916
 
917
-		} elseif ( $customer ) {
917
+		} elseif ($customer) {
918 918
 
919
-			$error['error'] = sprintf( __( 'Donor %s not found!', 'give' ), $customer );
919
+			$error['error'] = sprintf(__('Donor %s not found!', 'give'), $customer);
920 920
 
921 921
 			return $error;
922 922
 
923 923
 		} else {
924 924
 
925
-			$error['error'] = __( 'No donors found!', 'give' );
925
+			$error['error'] = __('No donors found!', 'give');
926 926
 
927 927
 			return $error;
928 928
 
@@ -941,36 +941,36 @@  discard block
 block discarded – undo
941 941
 	 *
942 942
 	 * @return array $customers Multidimensional array of the forms
943 943
 	 */
944
-	public function get_forms( $form = null ) {
944
+	public function get_forms($form = null) {
945 945
 
946 946
 		$forms = array();
947 947
 		$error = array();
948 948
 
949
-		if ( $form == null ) {
949
+		if ($form == null) {
950 950
 			$forms['forms'] = array();
951 951
 
952
-			$form_list = get_posts( array(
952
+			$form_list = get_posts(array(
953 953
 				'post_type'        => 'give_forms',
954 954
 				'posts_per_page'   => $this->per_page(),
955 955
 				'suppress_filters' => true,
956 956
 				'paged'            => $this->get_paged()
957
-			) );
957
+			));
958 958
 
959
-			if ( $form_list ) {
959
+			if ($form_list) {
960 960
 				$i = 0;
961
-				foreach ( $form_list as $form_info ) {
962
-					$forms['forms'][ $i ] = $this->get_form_data( $form_info );
963
-					$i ++;
961
+				foreach ($form_list as $form_info) {
962
+					$forms['forms'][$i] = $this->get_form_data($form_info);
963
+					$i++;
964 964
 				}
965 965
 			}
966 966
 		} else {
967
-			if ( get_post_type( $form ) == 'give_forms' ) {
968
-				$form_info = get_post( $form );
967
+			if (get_post_type($form) == 'give_forms') {
968
+				$form_info = get_post($form);
969 969
 
970
-				$forms['forms'][0] = $this->get_form_data( $form_info );
970
+				$forms['forms'][0] = $this->get_form_data($form_info);
971 971
 
972 972
 			} else {
973
-				$error['error'] = sprintf( __( 'Form %s not found!', 'give' ), $form );
973
+				$error['error'] = sprintf(__('Form %s not found!', 'give'), $form);
974 974
 
975 975
 				return $error;
976 976
 			}
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
 	 *
989 989
 	 * @return array                Array of post data to return back in the API
990 990
 	 */
991
-	private function get_form_data( $form_info ) {
991
+	private function get_form_data($form_info) {
992 992
 
993 993
 		$form = array();
994 994
 
@@ -998,46 +998,46 @@  discard block
 block discarded – undo
998 998
 		$form['info']['create_date']   = $form_info->post_date;
999 999
 		$form['info']['modified_date'] = $form_info->post_modified;
1000 1000
 		$form['info']['status']        = $form_info->post_status;
1001
-		$form['info']['link']          = html_entity_decode( $form_info->guid );
1002
-		$form['info']['content']       = get_post_meta( $form_info->ID, '_give_form_content', true );
1003
-		$form['info']['thumbnail']     = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) );
1001
+		$form['info']['link']          = html_entity_decode($form_info->guid);
1002
+		$form['info']['content']       = get_post_meta($form_info->ID, '_give_form_content', true);
1003
+		$form['info']['thumbnail']     = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID));
1004 1004
 
1005
-		if ( give_get_option( 'enable_categories' ) == 'on' ) {
1006
-			$form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' );
1007
-			$form['info']['tags']     = get_the_terms( $form_info, 'give_forms_tag' );
1005
+		if (give_get_option('enable_categories') == 'on') {
1006
+			$form['info']['category'] = get_the_terms($form_info, 'give_forms_category');
1007
+			$form['info']['tags']     = get_the_terms($form_info, 'give_forms_tag');
1008 1008
 		}
1009
-		if ( give_get_option( 'enable_tags' ) == 'on' ) {
1010
-			$form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' );
1009
+		if (give_get_option('enable_tags') == 'on') {
1010
+			$form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag');
1011 1011
 		}
1012 1012
 
1013
-		if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) {
1014
-			$form['stats']['total']['donations']           = give_get_form_sales_stats( $form_info->ID );
1015
-			$form['stats']['total']['earnings']            = give_get_form_earnings_stats( $form_info->ID );
1016
-			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID );
1017
-			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings( $form_info->ID );
1013
+		if (user_can($this->user_id, 'view_give_reports') || $this->override) {
1014
+			$form['stats']['total']['donations']           = give_get_form_sales_stats($form_info->ID);
1015
+			$form['stats']['total']['earnings']            = give_get_form_earnings_stats($form_info->ID);
1016
+			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID);
1017
+			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings($form_info->ID);
1018 1018
 		}
1019 1019
 
1020 1020
 		$counter = 0;
1021
-		if ( give_has_variable_prices( $form_info->ID ) ) {
1022
-			foreach ( give_get_variable_prices( $form_info->ID ) as $price ) {
1023
-				$counter ++;
1021
+		if (give_has_variable_prices($form_info->ID)) {
1022
+			foreach (give_get_variable_prices($form_info->ID) as $price) {
1023
+				$counter++;
1024 1024
 				//muli-level item
1025
-				$level                                     = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter;
1026
-				$form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount'];
1025
+				$level                                     = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter;
1026
+				$form['pricing'][sanitize_key($level)] = $price['_give_amount'];
1027 1027
 
1028 1028
 			}
1029 1029
 		} else {
1030
-			$form['pricing']['amount'] = give_get_form_price( $form_info->ID );
1030
+			$form['pricing']['amount'] = give_get_form_price($form_info->ID);
1031 1031
 		}
1032 1032
 
1033
-		if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) {
1033
+		if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) {
1034 1034
 
1035 1035
 			//Sensitive data here
1036
-			do_action( 'give_api_sensitive_data' );
1036
+			do_action('give_api_sensitive_data');
1037 1037
 
1038 1038
 		}
1039 1039
 
1040
-		return apply_filters( 'give_api_forms_form', $form );
1040
+		return apply_filters('give_api_forms_form', $form);
1041 1041
 
1042 1042
 	}
1043 1043
 
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
 	 *
1053 1053
 	 * @return array
1054 1054
 	 */
1055
-	public function get_stats( $args = array() ) {
1055
+	public function get_stats($args = array()) {
1056 1056
 		$defaults = array(
1057 1057
 			'type'      => null,
1058 1058
 			'form'      => null,
@@ -1061,9 +1061,9 @@  discard block
 block discarded – undo
1061 1061
 			'enddate'   => null
1062 1062
 		);
1063 1063
 
1064
-		$args = wp_parse_args( $args, $defaults );
1064
+		$args = wp_parse_args($args, $defaults);
1065 1065
 
1066
-		$dates = $this->get_dates( $args );
1066
+		$dates = $this->get_dates($args);
1067 1067
 
1068 1068
 		$stats    = array();
1069 1069
 		$earnings = array(
@@ -1074,41 +1074,41 @@  discard block
 block discarded – undo
1074 1074
 		);
1075 1075
 		$error    = array();
1076 1076
 
1077
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1077
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1078 1078
 			return $stats;
1079 1079
 		}
1080 1080
 
1081
-		if ( $args['type'] == 'donations' ) {
1081
+		if ($args['type'] == 'donations') {
1082 1082
 
1083
-			if ( $args['form'] == null ) {
1084
-				if ( $args['date'] == null ) {
1083
+			if ($args['form'] == null) {
1084
+				if ($args['date'] == null) {
1085 1085
 					$sales = $this->get_default_sales_stats();
1086
-				} elseif ( $args['date'] === 'range' ) {
1086
+				} elseif ($args['date'] === 'range') {
1087 1087
 					// Return sales for a date range
1088 1088
 
1089 1089
 					// Ensure the end date is later than the start date
1090
-					if ( $args['enddate'] < $args['startdate'] ) {
1091
-						$error['error'] = __( 'The end date must be later than the start date!', 'give' );
1090
+					if ($args['enddate'] < $args['startdate']) {
1091
+						$error['error'] = __('The end date must be later than the start date!', 'give');
1092 1092
 					}
1093 1093
 
1094 1094
 					// Ensure both the start and end date are specified
1095
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1096
-						$error['error'] = __( 'Invalid or no date range specified!', 'give' );
1095
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1096
+						$error['error'] = __('Invalid or no date range specified!', 'give');
1097 1097
 					}
1098 1098
 
1099 1099
 					$total = 0;
1100 1100
 
1101 1101
 					// Loop through the years
1102 1102
 					$y = $dates['year'];
1103
-					while ( $y <= $dates['year_end'] ) :
1103
+					while ($y <= $dates['year_end']) :
1104 1104
 
1105
-						if ( $dates['year'] == $dates['year_end'] ) {
1105
+						if ($dates['year'] == $dates['year_end']) {
1106 1106
 							$month_start = $dates['m_start'];
1107 1107
 							$month_end   = $dates['m_end'];
1108
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1108
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1109 1109
 							$month_start = $dates['m_start'];
1110 1110
 							$month_end   = 12;
1111
-						} elseif ( $y == $dates['year_end'] ) {
1111
+						} elseif ($y == $dates['year_end']) {
1112 1112
 							$month_start = 1;
1113 1113
 							$month_end   = $dates['m_end'];
1114 1114
 						} else {
@@ -1117,109 +1117,109 @@  discard block
 block discarded – undo
1117 1117
 						}
1118 1118
 
1119 1119
 						$i = $month_start;
1120
-						while ( $i <= $month_end ) :
1120
+						while ($i <= $month_end) :
1121 1121
 
1122
-							if ( $i == $dates['m_start'] ) {
1122
+							if ($i == $dates['m_start']) {
1123 1123
 								$d = $dates['day_start'];
1124 1124
 							} else {
1125 1125
 								$d = 1;
1126 1126
 							}
1127 1127
 
1128
-							if ( $i == $dates['m_end'] ) {
1128
+							if ($i == $dates['m_end']) {
1129 1129
 								$num_of_days = $dates['day_end'];
1130 1130
 							} else {
1131
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1131
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1132 1132
 							}
1133 1133
 
1134
-							while ( $d <= $num_of_days ) :
1135
-								$sale_count = give_get_sales_by_date( $d, $i, $y );
1136
-								$date_key   = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1137
-								if ( ! isset( $sales['sales'][ $date_key ] ) ) {
1138
-									$sales['sales'][ $date_key ] = 0;
1134
+							while ($d <= $num_of_days) :
1135
+								$sale_count = give_get_sales_by_date($d, $i, $y);
1136
+								$date_key   = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1137
+								if ( ! isset($sales['sales'][$date_key])) {
1138
+									$sales['sales'][$date_key] = 0;
1139 1139
 								}
1140
-								$sales['sales'][ $date_key ] += $sale_count;
1140
+								$sales['sales'][$date_key] += $sale_count;
1141 1141
 								$total += $sale_count;
1142
-								$d ++;
1142
+								$d++;
1143 1143
 							endwhile;
1144
-							$i ++;
1144
+							$i++;
1145 1145
 						endwhile;
1146 1146
 
1147
-						$y ++;
1147
+						$y++;
1148 1148
 					endwhile;
1149 1149
 
1150 1150
 					$sales['totals'] = $total;
1151 1151
 				} else {
1152
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1152
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1153 1153
 						$sales_count = 0;
1154 1154
 
1155 1155
 						// Loop through the months
1156 1156
 						$month = $dates['m_start'];
1157 1157
 
1158
-						while ( $month <= $dates['m_end'] ) :
1159
-							$sales_count += give_get_sales_by_date( null, $month, $dates['year'] );
1160
-							$month ++;
1158
+						while ($month <= $dates['m_end']) :
1159
+							$sales_count += give_get_sales_by_date(null, $month, $dates['year']);
1160
+							$month++;
1161 1161
 						endwhile;
1162 1162
 
1163
-						$sales['donations'][ $args['date'] ] = $sales_count;
1163
+						$sales['donations'][$args['date']] = $sales_count;
1164 1164
 					} else {
1165
-						$sales['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1165
+						$sales['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']);
1166 1166
 					}
1167 1167
 				}
1168
-			} elseif ( $args['form'] == 'all' ) {
1169
-				$forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) );
1168
+			} elseif ($args['form'] == 'all') {
1169
+				$forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true));
1170 1170
 				$i     = 0;
1171
-				foreach ( $forms as $form_info ) {
1172
-					$sales['donations'][ $i ] = array( $form_info->post_name => give_get_form_sales_stats( $form_info->ID ) );
1173
-					$i ++;
1171
+				foreach ($forms as $form_info) {
1172
+					$sales['donations'][$i] = array($form_info->post_name => give_get_form_sales_stats($form_info->ID));
1173
+					$i++;
1174 1174
 				}
1175 1175
 			} else {
1176
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1177
-					$form_info             = get_post( $args['form'] );
1178
-					$sales['donations'][0] = array( $form_info->post_name => give_get_form_sales_stats( $args['form'] ) );
1176
+				if (get_post_type($args['form']) == 'give_forms') {
1177
+					$form_info             = get_post($args['form']);
1178
+					$sales['donations'][0] = array($form_info->post_name => give_get_form_sales_stats($args['form']));
1179 1179
 				} else {
1180
-					$error['error'] = sprintf( __( 'Product %s not found!', 'give' ), $args['form'] );
1180
+					$error['error'] = sprintf(__('Product %s not found!', 'give'), $args['form']);
1181 1181
 				}
1182 1182
 			}
1183 1183
 
1184
-			if ( ! empty( $error ) ) {
1184
+			if ( ! empty($error)) {
1185 1185
 				return $error;
1186 1186
 			}
1187 1187
 
1188 1188
 			return $sales;
1189 1189
 
1190
-		} elseif ( $args['type'] == 'earnings' ) {
1191
-			if ( $args['form'] == null ) {
1192
-				if ( $args['date'] == null ) {
1190
+		} elseif ($args['type'] == 'earnings') {
1191
+			if ($args['form'] == null) {
1192
+				if ($args['date'] == null) {
1193 1193
 					$earnings = $this->get_default_earnings_stats();
1194
-				} elseif ( $args['date'] === 'range' ) {
1194
+				} elseif ($args['date'] === 'range') {
1195 1195
 					// Return sales for a date range
1196 1196
 
1197 1197
 					// Ensure the end date is later than the start date
1198
-					if ( $args['enddate'] < $args['startdate'] ) {
1199
-						$error['error'] = __( 'The end date must be later than the start date!', 'give' );
1198
+					if ($args['enddate'] < $args['startdate']) {
1199
+						$error['error'] = __('The end date must be later than the start date!', 'give');
1200 1200
 					}
1201 1201
 
1202 1202
 					// Ensure both the start and end date are specified
1203
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1204
-						$error['error'] = __( 'Invalid or no date range specified!', 'give' );
1203
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1204
+						$error['error'] = __('Invalid or no date range specified!', 'give');
1205 1205
 					}
1206 1206
 
1207 1207
 					$total = (float) 0.00;
1208 1208
 
1209 1209
 					// Loop through the years
1210 1210
 					$y = $dates['year'];
1211
-					if ( ! isset( $earnings['earnings'] ) ) {
1211
+					if ( ! isset($earnings['earnings'])) {
1212 1212
 						$earnings['earnings'] = array();
1213 1213
 					}
1214
-					while ( $y <= $dates['year_end'] ) :
1214
+					while ($y <= $dates['year_end']) :
1215 1215
 
1216
-						if ( $dates['year'] == $dates['year_end'] ) {
1216
+						if ($dates['year'] == $dates['year_end']) {
1217 1217
 							$month_start = $dates['m_start'];
1218 1218
 							$month_end   = $dates['m_end'];
1219
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1219
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1220 1220
 							$month_start = $dates['m_start'];
1221 1221
 							$month_end   = 12;
1222
-						} elseif ( $y == $dates['year_end'] ) {
1222
+						} elseif ($y == $dates['year_end']) {
1223 1223
 							$month_start = 1;
1224 1224
 							$month_end   = $dates['m_end'];
1225 1225
 						} else {
@@ -1228,88 +1228,88 @@  discard block
 block discarded – undo
1228 1228
 						}
1229 1229
 
1230 1230
 						$i = $month_start;
1231
-						while ( $i <= $month_end ) :
1231
+						while ($i <= $month_end) :
1232 1232
 
1233
-							if ( $i == $dates['m_start'] ) {
1233
+							if ($i == $dates['m_start']) {
1234 1234
 								$d = $dates['day_start'];
1235 1235
 							} else {
1236 1236
 								$d = 1;
1237 1237
 							}
1238 1238
 
1239
-							if ( $i == $dates['m_end'] ) {
1239
+							if ($i == $dates['m_end']) {
1240 1240
 								$num_of_days = $dates['day_end'];
1241 1241
 							} else {
1242
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1242
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1243 1243
 							}
1244 1244
 
1245
-							while ( $d <= $num_of_days ) :
1246
-								$earnings_stat = give_get_earnings_by_date( $d, $i, $y );
1247
-								$date_key      = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1248
-								if ( ! isset( $earnings['earnings'][ $date_key ] ) ) {
1249
-									$earnings['earnings'][ $date_key ] = 0;
1245
+							while ($d <= $num_of_days) :
1246
+								$earnings_stat = give_get_earnings_by_date($d, $i, $y);
1247
+								$date_key      = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1248
+								if ( ! isset($earnings['earnings'][$date_key])) {
1249
+									$earnings['earnings'][$date_key] = 0;
1250 1250
 								}
1251
-								$earnings['earnings'][ $date_key ] += $earnings_stat;
1251
+								$earnings['earnings'][$date_key] += $earnings_stat;
1252 1252
 								$total += $earnings_stat;
1253
-								$d ++;
1253
+								$d++;
1254 1254
 							endwhile;
1255 1255
 
1256
-							$i ++;
1256
+							$i++;
1257 1257
 						endwhile;
1258 1258
 
1259
-						$y ++;
1259
+						$y++;
1260 1260
 					endwhile;
1261 1261
 
1262 1262
 					$earnings['totals'] = $total;
1263 1263
 				} else {
1264
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1264
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1265 1265
 						$earnings_count = (float) 0.00;
1266 1266
 
1267 1267
 						// Loop through the months
1268 1268
 						$month = $dates['m_start'];
1269 1269
 
1270
-						while ( $month <= $dates['m_end'] ) :
1271
-							$earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] );
1272
-							$month ++;
1270
+						while ($month <= $dates['m_end']) :
1271
+							$earnings_count += give_get_earnings_by_date(null, $month, $dates['year']);
1272
+							$month++;
1273 1273
 						endwhile;
1274 1274
 
1275
-						$earnings['earnings'][ $args['date'] ] = $earnings_count;
1275
+						$earnings['earnings'][$args['date']] = $earnings_count;
1276 1276
 					} else {
1277
-						$earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1277
+						$earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']);
1278 1278
 					}
1279 1279
 				}
1280
-			} elseif ( $args['form'] == 'all' ) {
1281
-				$forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) );
1280
+			} elseif ($args['form'] == 'all') {
1281
+				$forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true));
1282 1282
 
1283 1283
 				$i = 0;
1284
-				foreach ( $forms as $form_info ) {
1285
-					$earnings['earnings'][ $i ] = array( $form_info->post_name => give_get_form_earnings_stats( $form_info->ID ) );
1286
-					$i ++;
1284
+				foreach ($forms as $form_info) {
1285
+					$earnings['earnings'][$i] = array($form_info->post_name => give_get_form_earnings_stats($form_info->ID));
1286
+					$i++;
1287 1287
 				}
1288 1288
 			} else {
1289
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1290
-					$form_info               = get_post( $args['form'] );
1291
-					$earnings['earnings'][0] = array( $form_info->post_name => give_get_form_earnings_stats( $args['form'] ) );
1289
+				if (get_post_type($args['form']) == 'give_forms') {
1290
+					$form_info               = get_post($args['form']);
1291
+					$earnings['earnings'][0] = array($form_info->post_name => give_get_form_earnings_stats($args['form']));
1292 1292
 				} else {
1293
-					$error['error'] = sprintf( __( 'Form %s not found!', 'give' ), $args['form'] );
1293
+					$error['error'] = sprintf(__('Form %s not found!', 'give'), $args['form']);
1294 1294
 				}
1295 1295
 			}
1296 1296
 
1297
-			if ( ! empty( $error ) ) {
1297
+			if ( ! empty($error)) {
1298 1298
 				return $error;
1299 1299
 			}
1300 1300
 
1301 1301
 			return $earnings;
1302
-		} elseif ( $args['type'] == 'donors' ) {
1302
+		} elseif ($args['type'] == 'donors') {
1303 1303
 			$customers                          = new Give_DB_Customers();
1304 1304
 			$stats['donations']['total_donors'] = $customers->count();
1305 1305
 
1306 1306
 			return $stats;
1307 1307
 
1308
-		} elseif ( empty( $args['type'] ) ) {
1309
-			$stats = array_merge( $stats, $this->get_default_sales_stats() );
1310
-			$stats = array_merge( $stats, $this->get_default_earnings_stats() );
1308
+		} elseif (empty($args['type'])) {
1309
+			$stats = array_merge($stats, $this->get_default_sales_stats());
1310
+			$stats = array_merge($stats, $this->get_default_earnings_stats());
1311 1311
 
1312
-			return array( 'stats' => $stats );
1312
+			return array('stats' => $stats);
1313 1313
 		}
1314 1314
 	}
1315 1315
 
@@ -1325,18 +1325,18 @@  discard block
 block discarded – undo
1325 1325
 
1326 1326
 		$sales = array();
1327 1327
 
1328
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1328
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1329 1329
 			return $sales;
1330 1330
 		}
1331 1331
 
1332
-		if ( isset( $wp_query->query_vars['id'] ) ) {
1332
+		if (isset($wp_query->query_vars['id'])) {
1333 1333
 			$query   = array();
1334
-			$query[] = new Give_Payment( $wp_query->query_vars['id'] );
1335
-		} elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) {
1334
+			$query[] = new Give_Payment($wp_query->query_vars['id']);
1335
+		} elseif (isset($wp_query->query_vars['purchasekey'])) {
1336 1336
 			$query   = array();
1337
-			$query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] );
1338
-		} elseif ( isset( $wp_query->query_vars['email'] ) ) {
1339
-			$args  = array(
1337
+			$query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']);
1338
+		} elseif (isset($wp_query->query_vars['email'])) {
1339
+			$args = array(
1340 1340
 				'fields'     => 'ids',
1341 1341
 				'meta_key'   => '_give_payment_user_email',
1342 1342
 				'meta_value' => $wp_query->query_vars['email'],
@@ -1344,7 +1344,7 @@  discard block
 block discarded – undo
1344 1344
 				'page'       => $this->get_paged(),
1345 1345
 				'status'     => 'publish'
1346 1346
 			);
1347
-			$query = give_get_payments( $args );
1347
+			$query = give_get_payments($args);
1348 1348
 		} else {
1349 1349
 			$args  = array(
1350 1350
 				'fields' => 'ids',
@@ -1352,14 +1352,14 @@  discard block
 block discarded – undo
1352 1352
 				'page'   => $this->get_paged(),
1353 1353
 				'status' => 'publish'
1354 1354
 			);
1355
-			$query = give_get_payments( $args );
1355
+			$query = give_get_payments($args);
1356 1356
 		}
1357
-		if ( $query ) {
1357
+		if ($query) {
1358 1358
 			$i = 0;
1359
-			foreach ( $query as $payment ) {
1359
+			foreach ($query as $payment) {
1360 1360
 
1361
-				if ( is_numeric( $payment ) ) {
1362
-					$payment      = new Give_Payment( $payment );
1361
+				if (is_numeric($payment)) {
1362
+					$payment      = new Give_Payment($payment);
1363 1363
 					$payment_meta = $payment->get_meta();
1364 1364
 					$user_info    = $payment->user_info;
1365 1365
 				} else {
@@ -1369,40 +1369,40 @@  discard block
 block discarded – undo
1369 1369
 				$payment_meta = $payment->get_meta();
1370 1370
 				$user_info    = $payment->user_info;
1371 1371
 
1372
-				$first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : '';
1373
-				$last_name  = isset( $user_info['last_name'] ) ? $user_info['last_name'] : '';
1374
-
1375
-				$sales['donations'][ $i ]['ID']             = $payment->number;
1376
-				$sales['donations'][ $i ]['transaction_id'] = $payment->transaction_id;
1377
-				$sales['donations'][ $i ]['key']            = $payment->key;
1378
-				$sales['donations'][ $i ]['total']          = $payment->total;
1379
-				$sales['donations'][ $i ]['gateway']        = $payment->gateway;
1380
-				$sales['donations'][ $i ]['name']           = $first_name . ' ' . $last_name;
1381
-				$sales['donations'][ $i ]['fname']          = $first_name;
1382
-				$sales['donations'][ $i ]['lname']          = $last_name;
1383
-				$sales['donations'][ $i ]['email']          = $payment->email;
1384
-				$sales['donations'][ $i ]['date']           = $payment->date;
1385
-
1386
-				$form_id  = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta;
1387
-				$price    = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false;
1388
-				$price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1389
-
1390
-				$sales['donations'][ $i ]['form']['id']    = $form_id;
1391
-				$sales['donations'][ $i ]['form']['name']  = get_the_title( $payment_meta['form_id'] );
1392
-				$sales['donations'][ $i ]['form']['price'] = $price;
1393
-
1394
-				if ( give_has_variable_prices( $form_id ) ) {
1395
-					if ( isset( $payment_meta['price_id'] ) ) {
1396
-						$price_name                                     = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID );
1397
-						$sales['donations'][ $i ]['form']['price_name'] = $price_name;
1398
-						$sales['donations'][ $i ]['form']['price_id']   = $price_id;
1399
-						$sales['donations'][ $i ]['form']['price']      = give_get_price_option_amount( $form_id, $price_id );
1372
+				$first_name = isset($user_info['first_name']) ? $user_info['first_name'] : '';
1373
+				$last_name  = isset($user_info['last_name']) ? $user_info['last_name'] : '';
1374
+
1375
+				$sales['donations'][$i]['ID']             = $payment->number;
1376
+				$sales['donations'][$i]['transaction_id'] = $payment->transaction_id;
1377
+				$sales['donations'][$i]['key']            = $payment->key;
1378
+				$sales['donations'][$i]['total']          = $payment->total;
1379
+				$sales['donations'][$i]['gateway']        = $payment->gateway;
1380
+				$sales['donations'][$i]['name']           = $first_name.' '.$last_name;
1381
+				$sales['donations'][$i]['fname']          = $first_name;
1382
+				$sales['donations'][$i]['lname']          = $last_name;
1383
+				$sales['donations'][$i]['email']          = $payment->email;
1384
+				$sales['donations'][$i]['date']           = $payment->date;
1385
+
1386
+				$form_id  = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta;
1387
+				$price    = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false;
1388
+				$price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1389
+
1390
+				$sales['donations'][$i]['form']['id']    = $form_id;
1391
+				$sales['donations'][$i]['form']['name']  = get_the_title($payment_meta['form_id']);
1392
+				$sales['donations'][$i]['form']['price'] = $price;
1393
+
1394
+				if (give_has_variable_prices($form_id)) {
1395
+					if (isset($payment_meta['price_id'])) {
1396
+						$price_name                                     = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID);
1397
+						$sales['donations'][$i]['form']['price_name'] = $price_name;
1398
+						$sales['donations'][$i]['form']['price_id']   = $price_id;
1399
+						$sales['donations'][$i]['form']['price']      = give_get_price_option_amount($form_id, $price_id);
1400 1400
 
1401 1401
 					}
1402 1402
 				}
1403 1403
 
1404 1404
 				//Add custom meta to API
1405
-				foreach ( $payment_meta as $meta_key => $meta_value ) {
1405
+				foreach ($payment_meta as $meta_key => $meta_value) {
1406 1406
 
1407 1407
 					$exceptions = array(
1408 1408
 						'form_title',
@@ -1415,19 +1415,19 @@  discard block
 block discarded – undo
1415 1415
 					);
1416 1416
 
1417 1417
 					//Don't clutter up results with dupes
1418
-					if ( in_array( $meta_key, $exceptions ) ) {
1418
+					if (in_array($meta_key, $exceptions)) {
1419 1419
 						continue;
1420 1420
 					}
1421 1421
 
1422
-					$sales['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value;
1422
+					$sales['donations'][$i]['payment_meta'][$meta_key] = $meta_value;
1423 1423
 
1424 1424
 				}
1425 1425
 
1426
-				$i ++;
1426
+				$i++;
1427 1427
 			}
1428 1428
 		}
1429 1429
 
1430
-		return apply_filters( 'give_api_donations_endpoint', $sales );
1430
+		return apply_filters('give_api_donations_endpoint', $sales);
1431 1431
 	}
1432 1432
 
1433 1433
 	/**
@@ -1442,9 +1442,9 @@  discard block
 block discarded – undo
1442 1442
 	public function get_output_format() {
1443 1443
 		global $wp_query;
1444 1444
 
1445
-		$format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json';
1445
+		$format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json';
1446 1446
 
1447
-		return apply_filters( 'give_api_output_format', $format );
1447
+		return apply_filters('give_api_output_format', $format);
1448 1448
 	}
1449 1449
 
1450 1450
 
@@ -1460,8 +1460,8 @@  discard block
 block discarded – undo
1460 1460
 	 *
1461 1461
 	 * @return void
1462 1462
 	 */
1463
-	private function log_request( $data = array() ) {
1464
-		if ( ! $this->log_requests ) {
1463
+	private function log_request($data = array()) {
1464
+		if ( ! $this->log_requests) {
1465 1465
 			return;
1466 1466
 		}
1467 1467
 
@@ -1469,36 +1469,36 @@  discard block
 block discarded – undo
1469 1469
 
1470 1470
 		$query = array(
1471 1471
 			'give-api'    => $wp_query->query_vars['give-api'],
1472
-			'key'         => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1473
-			'token'       => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1474
-			'query'       => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null,
1475
-			'type'        => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
1476
-			'form'        => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
1477
-			'customer'    => isset( $wp_query->query_vars['customer'] ) ? $wp_query->query_vars['customer'] : null,
1478
-			'date'        => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
1479
-			'startdate'   => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
1480
-			'enddate'     => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
1481
-			'id'          => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null,
1482
-			'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null,
1483
-			'email'       => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null,
1472
+			'key'         => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1473
+			'token'       => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1474
+			'query'       => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null,
1475
+			'type'        => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
1476
+			'form'        => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
1477
+			'customer'    => isset($wp_query->query_vars['customer']) ? $wp_query->query_vars['customer'] : null,
1478
+			'date'        => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
1479
+			'startdate'   => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
1480
+			'enddate'     => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
1481
+			'id'          => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null,
1482
+			'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null,
1483
+			'email'       => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null,
1484 1484
 		);
1485 1485
 
1486 1486
 		$log_data = array(
1487 1487
 			'log_type'     => 'api_request',
1488
-			'post_excerpt' => http_build_query( $query ),
1489
-			'post_content' => ! empty( $data['error'] ) ? $data['error'] : '',
1488
+			'post_excerpt' => http_build_query($query),
1489
+			'post_content' => ! empty($data['error']) ? $data['error'] : '',
1490 1490
 		);
1491 1491
 
1492 1492
 		$log_meta = array(
1493 1493
 			'request_ip' => give_get_ip(),
1494 1494
 			'user'       => $this->user_id,
1495
-			'key'        => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1496
-			'token'      => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1495
+			'key'        => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1496
+			'token'      => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1497 1497
 			'time'       => $data['request_speed'],
1498 1498
 			'version'    => $this->get_queried_version()
1499 1499
 		);
1500 1500
 
1501
-		$give_logs->insert_log( $log_data, $log_meta );
1501
+		$give_logs->insert_log($log_data, $log_meta);
1502 1502
 	}
1503 1503
 
1504 1504
 
@@ -1522,32 +1522,32 @@  discard block
 block discarded – undo
1522 1522
 	 *
1523 1523
 	 * @param int $status_code
1524 1524
 	 */
1525
-	public function output( $status_code = 200 ) {
1525
+	public function output($status_code = 200) {
1526 1526
 		global $wp_query;
1527 1527
 
1528 1528
 		$format = $this->get_output_format();
1529 1529
 
1530
-		status_header( $status_code );
1530
+		status_header($status_code);
1531 1531
 
1532
-		do_action( 'give_api_output_before', $this->data, $this, $format );
1532
+		do_action('give_api_output_before', $this->data, $this, $format);
1533 1533
 
1534
-		switch ( $format ) :
1534
+		switch ($format) :
1535 1535
 
1536 1536
 			case 'xml' :
1537 1537
 
1538
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php';
1539
-				$xml = Array2XML::createXML( 'give', $this->data );
1538
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php';
1539
+				$xml = Array2XML::createXML('give', $this->data);
1540 1540
 				echo $xml->saveXML();
1541 1541
 
1542 1542
 				break;
1543 1543
 
1544 1544
 			case 'json' :
1545 1545
 
1546
-				header( 'Content-Type: application/json' );
1547
-				if ( ! empty( $this->pretty_print ) ) {
1548
-					echo json_encode( $this->data, $this->pretty_print );
1546
+				header('Content-Type: application/json');
1547
+				if ( ! empty($this->pretty_print)) {
1548
+					echo json_encode($this->data, $this->pretty_print);
1549 1549
 				} else {
1550
-					echo json_encode( $this->data );
1550
+					echo json_encode($this->data);
1551 1551
 				}
1552 1552
 
1553 1553
 				break;
@@ -1556,13 +1556,13 @@  discard block
 block discarded – undo
1556 1556
 			default :
1557 1557
 
1558 1558
 				// Allow other formats to be added via extensions
1559
-				do_action( 'give_api_output_' . $format, $this->data, $this );
1559
+				do_action('give_api_output_'.$format, $this->data, $this);
1560 1560
 
1561 1561
 				break;
1562 1562
 
1563 1563
 		endswitch;
1564 1564
 
1565
-		do_action( 'give_api_output_after', $this->data, $this, $format );
1565
+		do_action('give_api_output_after', $this->data, $this, $format);
1566 1566
 
1567 1567
 		give_die();
1568 1568
 	}
@@ -1579,37 +1579,37 @@  discard block
 block discarded – undo
1579 1579
 	 *
1580 1580
 	 * @return void
1581 1581
 	 */
1582
-	function user_key_field( $user ) {
1582
+	function user_key_field($user) {
1583 1583
 
1584
-		if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) {
1585
-			$user = get_userdata( $user->ID );
1584
+		if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) {
1585
+			$user = get_userdata($user->ID);
1586 1586
 			?>
1587 1587
 			<table class="form-table">
1588 1588
 				<tbody>
1589 1589
 				<tr>
1590 1590
 					<th>
1591
-						<?php esc_attr_e( 'Give API Keys', 'give' ); ?>
1591
+						<?php esc_attr_e('Give API Keys', 'give'); ?>
1592 1592
 					</th>
1593 1593
 					<td>
1594 1594
 						<?php
1595
-						$public_key = $this->get_user_public_key( $user->ID );
1596
-						$secret_key = $this->get_user_secret_key( $user->ID );
1595
+						$public_key = $this->get_user_public_key($user->ID);
1596
+						$secret_key = $this->get_user_secret_key($user->ID);
1597 1597
 						?>
1598
-						<?php if ( empty( $user->give_user_public_key ) ) { ?>
1598
+						<?php if (empty($user->give_user_public_key)) { ?>
1599 1599
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/>
1600
-							<span class="description"><?php esc_attr_e( 'Generate API Key', 'give' ); ?></span>
1600
+							<span class="description"><?php esc_attr_e('Generate API Key', 'give'); ?></span>
1601 1601
 						<?php } else { ?>
1602
-							<strong style="display:inline-block; width: 125px;"><?php _e( 'Public key:', 'give' ); ?>&nbsp;</strong>
1603
-							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>"/>
1602
+							<strong style="display:inline-block; width: 125px;"><?php _e('Public key:', 'give'); ?>&nbsp;</strong>
1603
+							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>"/>
1604 1604
 							<br/>
1605
-							<strong style="display:inline-block; width: 125px;"><?php esc_attr_e( 'Secret key:', 'give' ); ?>&nbsp;</strong>
1606
-							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>"/>
1605
+							<strong style="display:inline-block; width: 125px;"><?php esc_attr_e('Secret key:', 'give'); ?>&nbsp;</strong>
1606
+							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>"/>
1607 1607
 							<br/>
1608
-							<strong style="display:inline-block; width: 125px;"><?php esc_attr_e( 'Token:', 'give' ); ?>&nbsp;</strong>
1609
-							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>"/>
1608
+							<strong style="display:inline-block; width: 125px;"><?php esc_attr_e('Token:', 'give'); ?>&nbsp;</strong>
1609
+							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>"/>
1610 1610
 							<br/>
1611 1611
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/>
1612
-							<span class="description"><label for="give_set_api_key"><?php esc_attr_e( 'Revoke API Keys', 'give' ); ?></label></span>
1612
+							<span class="description"><label for="give_set_api_key"><?php esc_attr_e('Revoke API Keys', 'give'); ?></label></span>
1613 1613
 						<?php } ?>
1614 1614
 					</td>
1615 1615
 				</tr>
@@ -1628,53 +1628,53 @@  discard block
 block discarded – undo
1628 1628
 	 *
1629 1629
 	 * @return void
1630 1630
 	 */
1631
-	public function process_api_key( $args ) {
1631
+	public function process_api_key($args) {
1632 1632
 
1633
-		if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) {
1633
+		if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) {
1634 1634
 
1635
-			wp_die( esc_attr__( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
1635
+			wp_die(esc_attr__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403));
1636 1636
 
1637 1637
 		}
1638 1638
 
1639
-		if ( empty( $args['user_id'] ) ) {
1640
-			wp_die( esc_attr__( 'User ID Required.', 'give' ), esc_attr__( 'Error', 'give' ), array( 'response' => 401 ) );
1639
+		if (empty($args['user_id'])) {
1640
+			wp_die(esc_attr__('User ID Required.', 'give'), esc_attr__('Error', 'give'), array('response' => 401));
1641 1641
 		}
1642 1642
 
1643
-		if ( is_numeric( $args['user_id'] ) ) {
1644
-			$user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id();
1643
+		if (is_numeric($args['user_id'])) {
1644
+			$user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id();
1645 1645
 		} else {
1646
-			$userdata = get_user_by( 'login', $args['user_id'] );
1646
+			$userdata = get_user_by('login', $args['user_id']);
1647 1647
 			$user_id  = $userdata->ID;
1648 1648
 		}
1649
-		$process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false;
1649
+		$process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false;
1650 1650
 
1651
-		if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) {
1652
-			wp_die( sprintf( __( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), __( 'Error', 'give' ), array( 'response' => 403 ) );
1653
-		} elseif ( ! current_user_can( 'manage_give_settings' ) ) {
1654
-			wp_die( sprintf( __( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), __( 'Error', 'give' ), array( 'response' => 403 ) );
1651
+		if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) {
1652
+			wp_die(sprintf(__('You do not have permission to %s API keys for this user.', 'give'), $process), __('Error', 'give'), array('response' => 403));
1653
+		} elseif ( ! current_user_can('manage_give_settings')) {
1654
+			wp_die(sprintf(__('You do not have permission to %s API keys for this user.', 'give'), $process), __('Error', 'give'), array('response' => 403));
1655 1655
 		}
1656 1656
 
1657
-		switch ( $process ) {
1657
+		switch ($process) {
1658 1658
 			case 'generate':
1659
-				if ( $this->generate_api_key( $user_id ) ) {
1660
-					delete_transient( 'give-total-api-keys' );
1661
-					wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1659
+				if ($this->generate_api_key($user_id)) {
1660
+					delete_transient('give-total-api-keys');
1661
+					wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1662 1662
 					exit();
1663 1663
 				} else {
1664
-					wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1664
+					wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1665 1665
 					exit();
1666 1666
 				}
1667 1667
 				break;
1668 1668
 			case 'regenerate':
1669
-				$this->generate_api_key( $user_id, true );
1670
-				delete_transient( 'give-total-api-keys' );
1671
-				wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1669
+				$this->generate_api_key($user_id, true);
1670
+				delete_transient('give-total-api-keys');
1671
+				wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1672 1672
 				exit();
1673 1673
 				break;
1674 1674
 			case 'revoke':
1675
-				$this->revoke_api_key( $user_id );
1676
-				delete_transient( 'give-total-api-keys' );
1677
-				wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1675
+				$this->revoke_api_key($user_id);
1676
+				delete_transient('give-total-api-keys');
1677
+				wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1678 1678
 				exit();
1679 1679
 				break;
1680 1680
 			default;
@@ -1693,34 +1693,34 @@  discard block
 block discarded – undo
1693 1693
 	 *
1694 1694
 	 * @return boolean True if (re)generated succesfully, false otherwise.
1695 1695
 	 */
1696
-	public function generate_api_key( $user_id = 0, $regenerate = false ) {
1696
+	public function generate_api_key($user_id = 0, $regenerate = false) {
1697 1697
 
1698
-		if ( empty( $user_id ) ) {
1698
+		if (empty($user_id)) {
1699 1699
 			return false;
1700 1700
 		}
1701 1701
 
1702
-		$user = get_userdata( $user_id );
1702
+		$user = get_userdata($user_id);
1703 1703
 
1704
-		if ( ! $user ) {
1704
+		if ( ! $user) {
1705 1705
 			return false;
1706 1706
 		}
1707 1707
 
1708
-		$public_key = $this->get_user_public_key( $user_id );
1709
-		$secret_key = $this->get_user_secret_key( $user_id );
1708
+		$public_key = $this->get_user_public_key($user_id);
1709
+		$secret_key = $this->get_user_secret_key($user_id);
1710 1710
 
1711
-		if ( empty( $public_key ) || $regenerate == true ) {
1712
-			$new_public_key = $this->generate_public_key( $user->user_email );
1713
-			$new_secret_key = $this->generate_private_key( $user->ID );
1711
+		if (empty($public_key) || $regenerate == true) {
1712
+			$new_public_key = $this->generate_public_key($user->user_email);
1713
+			$new_secret_key = $this->generate_private_key($user->ID);
1714 1714
 		} else {
1715 1715
 			return false;
1716 1716
 		}
1717 1717
 
1718
-		if ( $regenerate == true ) {
1719
-			$this->revoke_api_key( $user->ID );
1718
+		if ($regenerate == true) {
1719
+			$this->revoke_api_key($user->ID);
1720 1720
 		}
1721 1721
 
1722
-		update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1723
-		update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1722
+		update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1723
+		update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1724 1724
 
1725 1725
 		return true;
1726 1726
 	}
@@ -1735,26 +1735,26 @@  discard block
 block discarded – undo
1735 1735
 	 *
1736 1736
 	 * @return string
1737 1737
 	 */
1738
-	public function revoke_api_key( $user_id = 0 ) {
1738
+	public function revoke_api_key($user_id = 0) {
1739 1739
 
1740
-		if ( empty( $user_id ) ) {
1740
+		if (empty($user_id)) {
1741 1741
 			return false;
1742 1742
 		}
1743 1743
 
1744
-		$user = get_userdata( $user_id );
1744
+		$user = get_userdata($user_id);
1745 1745
 
1746
-		if ( ! $user ) {
1746
+		if ( ! $user) {
1747 1747
 			return false;
1748 1748
 		}
1749 1749
 
1750
-		$public_key = $this->get_user_public_key( $user_id );
1751
-		$secret_key = $this->get_user_secret_key( $user_id );
1752
-		if ( ! empty( $public_key ) ) {
1753
-			delete_transient( md5( 'give_api_user_' . $public_key ) );
1754
-			delete_transient( md5( 'give_api_user_public_key' . $user_id ) );
1755
-			delete_transient( md5( 'give_api_user_secret_key' . $user_id ) );
1756
-			delete_user_meta( $user_id, $public_key );
1757
-			delete_user_meta( $user_id, $secret_key );
1750
+		$public_key = $this->get_user_public_key($user_id);
1751
+		$secret_key = $this->get_user_secret_key($user_id);
1752
+		if ( ! empty($public_key)) {
1753
+			delete_transient(md5('give_api_user_'.$public_key));
1754
+			delete_transient(md5('give_api_user_public_key'.$user_id));
1755
+			delete_transient(md5('give_api_user_secret_key'.$user_id));
1756
+			delete_user_meta($user_id, $public_key);
1757
+			delete_user_meta($user_id, $secret_key);
1758 1758
 		} else {
1759 1759
 			return false;
1760 1760
 		}
@@ -1779,22 +1779,22 @@  discard block
 block discarded – undo
1779 1779
 	 *
1780 1780
 	 * @return void
1781 1781
 	 */
1782
-	public function update_key( $user_id ) {
1783
-		if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST['give_set_api_key'] ) ) {
1782
+	public function update_key($user_id) {
1783
+		if (current_user_can('edit_user', $user_id) && isset($_POST['give_set_api_key'])) {
1784 1784
 
1785
-			$user = get_userdata( $user_id );
1785
+			$user = get_userdata($user_id);
1786 1786
 
1787
-			$public_key = $this->get_user_public_key( $user_id );
1788
-			$secret_key = $this->get_user_secret_key( $user_id );
1787
+			$public_key = $this->get_user_public_key($user_id);
1788
+			$secret_key = $this->get_user_secret_key($user_id);
1789 1789
 
1790
-			if ( empty( $public_key ) ) {
1791
-				$new_public_key = $this->generate_public_key( $user->user_email );
1792
-				$new_secret_key = $this->generate_private_key( $user->ID );
1790
+			if (empty($public_key)) {
1791
+				$new_public_key = $this->generate_public_key($user->user_email);
1792
+				$new_secret_key = $this->generate_private_key($user->ID);
1793 1793
 
1794
-				update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1795
-				update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1794
+				update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1795
+				update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1796 1796
 			} else {
1797
-				$this->revoke_api_key( $user_id );
1797
+				$this->revoke_api_key($user_id);
1798 1798
 			}
1799 1799
 		}
1800 1800
 	}
@@ -1809,9 +1809,9 @@  discard block
 block discarded – undo
1809 1809
 	 *
1810 1810
 	 * @return string
1811 1811
 	 */
1812
-	private function generate_public_key( $user_email = '' ) {
1813
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1814
-		$public   = hash( 'md5', $user_email . $auth_key . date( 'U' ) );
1812
+	private function generate_public_key($user_email = '') {
1813
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1814
+		$public   = hash('md5', $user_email.$auth_key.date('U'));
1815 1815
 
1816 1816
 		return $public;
1817 1817
 	}
@@ -1826,9 +1826,9 @@  discard block
 block discarded – undo
1826 1826
 	 *
1827 1827
 	 * @return string
1828 1828
 	 */
1829
-	private function generate_private_key( $user_id = 0 ) {
1830
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1831
-		$secret   = hash( 'md5', $user_id . $auth_key . date( 'U' ) );
1829
+	private function generate_private_key($user_id = 0) {
1830
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1831
+		$secret   = hash('md5', $user_id.$auth_key.date('U'));
1832 1832
 
1833 1833
 		return $secret;
1834 1834
 	}
@@ -1843,8 +1843,8 @@  discard block
 block discarded – undo
1843 1843
 	 *
1844 1844
 	 * @return string
1845 1845
 	 */
1846
-	public function get_token( $user_id = 0 ) {
1847
-		return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) );
1846
+	public function get_token($user_id = 0) {
1847
+		return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id));
1848 1848
 	}
1849 1849
 
1850 1850
 	/**
@@ -1858,9 +1858,9 @@  discard block
 block discarded – undo
1858 1858
 
1859 1859
 		// Default sales return
1860 1860
 		$sales                               = array();
1861
-		$sales['donations']['today']         = $this->stats->get_sales( 0, 'today' );
1862
-		$sales['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' );
1863
-		$sales['donations']['last_month']    = $this->stats->get_sales( 0, 'last_month' );
1861
+		$sales['donations']['today']         = $this->stats->get_sales(0, 'today');
1862
+		$sales['donations']['current_month'] = $this->stats->get_sales(0, 'this_month');
1863
+		$sales['donations']['last_month']    = $this->stats->get_sales(0, 'last_month');
1864 1864
 		$sales['donations']['totals']        = give_get_total_sales();
1865 1865
 
1866 1866
 		return $sales;
@@ -1877,9 +1877,9 @@  discard block
 block discarded – undo
1877 1877
 
1878 1878
 		// Default earnings return
1879 1879
 		$earnings                              = array();
1880
-		$earnings['earnings']['today']         = $this->stats->get_earnings( 0, 'today' );
1881
-		$earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' );
1882
-		$earnings['earnings']['last_month']    = $this->stats->get_earnings( 0, 'last_month' );
1880
+		$earnings['earnings']['today']         = $this->stats->get_earnings(0, 'today');
1881
+		$earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month');
1882
+		$earnings['earnings']['last_month']    = $this->stats->get_earnings(0, 'last_month');
1883 1883
 		$earnings['earnings']['totals']        = give_get_total_earnings();
1884 1884
 
1885 1885
 		return $earnings;
@@ -1899,25 +1899,25 @@  discard block
 block discarded – undo
1899 1899
 	 *
1900 1900
 	 * @return string            The API key/secret for the user supplied
1901 1901
 	 */
1902
-	public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) {
1902
+	public function api_key_backwards_compat($check, $object_id, $meta_key, $single) {
1903 1903
 
1904
-		if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) {
1904
+		if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') {
1905 1905
 			return $check;
1906 1906
 		}
1907 1907
 
1908 1908
 		$return = $check;
1909 1909
 
1910
-		switch ( $meta_key ) {
1910
+		switch ($meta_key) {
1911 1911
 			case 'give_user_public_key':
1912
-				$return = Give()->api->get_user_public_key( $object_id );
1912
+				$return = Give()->api->get_user_public_key($object_id);
1913 1913
 				break;
1914 1914
 			case 'give_user_secret_key':
1915
-				$return = Give()->api->get_user_secret_key( $object_id );
1915
+				$return = Give()->api->get_user_secret_key($object_id);
1916 1916
 				break;
1917 1917
 		}
1918 1918
 
1919
-		if ( ! $single ) {
1920
-			$return = array( $return );
1919
+		if ( ! $single) {
1920
+			$return = array($return);
1921 1921
 		}
1922 1922
 
1923 1923
 		return $return;
Please login to merge, or discard this patch.