@@ -10,61 +10,61 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
13 | +if ( ! defined('WP_UNINSTALL_PLUGIN')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | 17 | // Load Give file. |
18 | -include_once( 'give.php' ); |
|
18 | +include_once('give.php'); |
|
19 | 19 | |
20 | 20 | global $wpdb, $wp_roles; |
21 | 21 | |
22 | 22 | |
23 | -if ( give_get_option( 'uninstall_on_delete' ) === 'on' ) { |
|
23 | +if (give_get_option('uninstall_on_delete') === 'on') { |
|
24 | 24 | |
25 | 25 | // Delete All the Custom Post Types. |
26 | - $give_taxonomies = array( 'form_category', 'form_tag', 'give_log_type' ); |
|
27 | - $give_post_types = array( 'give_forms', 'give_payment', 'give_log' ); |
|
28 | - foreach ( $give_post_types as $post_type ) { |
|
26 | + $give_taxonomies = array('form_category', 'form_tag', 'give_log_type'); |
|
27 | + $give_post_types = array('give_forms', 'give_payment', 'give_log'); |
|
28 | + foreach ($give_post_types as $post_type) { |
|
29 | 29 | |
30 | - $give_taxonomies = array_merge( $give_taxonomies, get_object_taxonomies( $post_type ) ); |
|
31 | - $items = get_posts( array( |
|
30 | + $give_taxonomies = array_merge($give_taxonomies, get_object_taxonomies($post_type)); |
|
31 | + $items = get_posts(array( |
|
32 | 32 | 'post_type' => $post_type, |
33 | 33 | 'post_status' => 'any', |
34 | - 'numberposts' => - 1, |
|
34 | + 'numberposts' => -1, |
|
35 | 35 | 'fields' => 'ids', |
36 | - ) ); |
|
36 | + )); |
|
37 | 37 | |
38 | - if ( $items ) { |
|
39 | - foreach ( $items as $item ) { |
|
40 | - wp_delete_post( $item, true ); |
|
38 | + if ($items) { |
|
39 | + foreach ($items as $item) { |
|
40 | + wp_delete_post($item, true); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | 45 | // Delete All the Terms & Taxonomies. |
46 | - foreach ( array_unique( array_filter( $give_taxonomies ) ) as $taxonomy ) { |
|
46 | + foreach (array_unique(array_filter($give_taxonomies)) as $taxonomy) { |
|
47 | 47 | |
48 | - $terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy ) ); |
|
48 | + $terms = $wpdb->get_results($wpdb->prepare("SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy)); |
|
49 | 49 | |
50 | 50 | // Delete Terms. |
51 | - if ( $terms ) { |
|
52 | - foreach ( $terms as $term ) { |
|
53 | - $wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $term->term_taxonomy_id ) ); |
|
54 | - $wpdb->delete( $wpdb->terms, array( 'term_id' => $term->term_id ) ); |
|
51 | + if ($terms) { |
|
52 | + foreach ($terms as $term) { |
|
53 | + $wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $term->term_taxonomy_id)); |
|
54 | + $wpdb->delete($wpdb->terms, array('term_id' => $term->term_id)); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Delete Taxonomies. |
59 | - $wpdb->delete( $wpdb->term_taxonomy, array( 'taxonomy' => $taxonomy ), array( '%s' ) ); |
|
59 | + $wpdb->delete($wpdb->term_taxonomy, array('taxonomy' => $taxonomy), array('%s')); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | // Delete the Plugin Pages. |
63 | - $give_created_pages = array( 'success_page', 'failure_page', 'history_page' ); |
|
64 | - foreach ( $give_created_pages as $p ) { |
|
65 | - $page = give_get_option( $p, false ); |
|
66 | - if ( $page ) { |
|
67 | - wp_delete_post( $page, true ); |
|
63 | + $give_created_pages = array('success_page', 'failure_page', 'history_page'); |
|
64 | + foreach ($give_created_pages as $p) { |
|
65 | + $page = give_get_option($p, false); |
|
66 | + if ($page) { |
|
67 | + wp_delete_post($page, true); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
@@ -72,20 +72,20 @@ discard block |
||
72 | 72 | Give()->roles->remove_caps(); |
73 | 73 | |
74 | 74 | // Delete the Roles. |
75 | - $give_roles = array( 'give_manager', 'give_accountant', 'give_worker' ); |
|
76 | - foreach ( $give_roles as $role ) { |
|
77 | - remove_role( $role ); |
|
75 | + $give_roles = array('give_manager', 'give_accountant', 'give_worker'); |
|
76 | + foreach ($give_roles as $role) { |
|
77 | + remove_role($role); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | // Remove all database tables. |
81 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_donors' ); |
|
82 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customers' ); |
|
83 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customermeta' ); |
|
81 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_donors'); |
|
82 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customers'); |
|
83 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customermeta'); |
|
84 | 84 | |
85 | 85 | // Cleanup Cron Events. |
86 | - wp_clear_scheduled_hook( 'give_daily_scheduled_events' ); |
|
87 | - wp_clear_scheduled_hook( 'give_daily_cron' ); |
|
88 | - wp_clear_scheduled_hook( 'give_weekly_cron' ); |
|
86 | + wp_clear_scheduled_hook('give_daily_scheduled_events'); |
|
87 | + wp_clear_scheduled_hook('give_daily_cron'); |
|
88 | + wp_clear_scheduled_hook('give_weekly_cron'); |
|
89 | 89 | |
90 | 90 | // Get all options. |
91 | 91 | $give_option_names = $wpdb->get_results( |
@@ -96,24 +96,24 @@ discard block |
||
96 | 96 | ARRAY_A |
97 | 97 | ); |
98 | 98 | |
99 | - if ( ! empty( $give_option_names ) ) { |
|
99 | + if ( ! empty($give_option_names)) { |
|
100 | 100 | // Convert option name to transient or option name. |
101 | 101 | $new_give_option_names = array(); |
102 | 102 | |
103 | - foreach ( $give_option_names as $option ) { |
|
104 | - $new_give_option_names[] = ( false !== strpos( $option['option_name'], '_transient_' ) ) |
|
105 | - ? str_replace( '_transient_', '', $option['option_name'] ) |
|
103 | + foreach ($give_option_names as $option) { |
|
104 | + $new_give_option_names[] = (false !== strpos($option['option_name'], '_transient_')) |
|
105 | + ? str_replace('_transient_', '', $option['option_name']) |
|
106 | 106 | : $option['option_name']; |
107 | 107 | } |
108 | 108 | |
109 | 109 | $give_option_names = $new_give_option_names; |
110 | 110 | |
111 | 111 | // Delete all the Plugin Options. |
112 | - foreach ( $give_option_names as $option ) { |
|
113 | - if ( false !== strpos( $option, '_transient_' ) ) { |
|
114 | - delete_transient( $option ); |
|
112 | + foreach ($give_option_names as $option) { |
|
113 | + if (false !== strpos($option, '_transient_')) { |
|
114 | + delete_transient($option); |
|
115 | 115 | } else { |
116 | - delete_option( $option ); |
|
116 | + delete_option($option); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @access private |
182 | 182 | * @global array $give_options |
183 | - * @return bool |
|
183 | + * @return false|null |
|
184 | 184 | */ |
185 | 185 | public function auto_updater() { |
186 | 186 | |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | * @since 1.7 |
768 | 768 | * @access private |
769 | 769 | * |
770 | - * @return void|bool |
|
770 | + * @return false|null |
|
771 | 771 | */ |
772 | 772 | private function __remove_license_key_from_subscriptions(){ |
773 | 773 | $subscriptions = get_option( 'give_subscriptions', array() ); |
@@ -8,11 +8,11 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | // Exit if accessed directly |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
15 | -if ( ! class_exists( 'Give_License' ) ) : |
|
15 | +if ( ! class_exists('Give_License')) : |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Give_License Class |
@@ -108,19 +108,19 @@ discard block |
||
108 | 108 | * @param string $_checkout_url |
109 | 109 | * @param string $_account_url |
110 | 110 | */ |
111 | - public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) { |
|
111 | + public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) { |
|
112 | 112 | global $give_options; |
113 | 113 | |
114 | 114 | $this->file = $_file; |
115 | 115 | $this->item_name = $_item_name; |
116 | - $this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) ); |
|
116 | + $this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name))); |
|
117 | 117 | $this->version = $_version; |
118 | - $this->license = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : ''; |
|
119 | - $this->license_data = get_option( $this->item_shortname . '_license_active' ); |
|
118 | + $this->license = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : ''; |
|
119 | + $this->license_data = get_option($this->item_shortname.'_license_active'); |
|
120 | 120 | $this->author = $_author; |
121 | - $this->api_url = is_null( $_api_url ) ? $this->api_url : $_api_url; |
|
122 | - $this->checkout_url = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url; |
|
123 | - $this->account_url = is_null( $_account_url ) ? $this->account_url : $_account_url; |
|
121 | + $this->api_url = is_null($_api_url) ? $this->api_url : $_api_url; |
|
122 | + $this->checkout_url = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url; |
|
123 | + $this->account_url = is_null($_account_url) ? $this->account_url : $_account_url; |
|
124 | 124 | |
125 | 125 | // Setup hooks |
126 | 126 | $this->includes(); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @return void |
139 | 139 | */ |
140 | 140 | private function includes() { |
141 | - if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
141 | + if ( ! class_exists('EDD_SL_Plugin_Updater')) { |
|
142 | 142 | require_once 'admin/EDD_SL_Plugin_Updater.php'; |
143 | 143 | } |
144 | 144 | } |
@@ -155,24 +155,24 @@ discard block |
||
155 | 155 | private function hooks() { |
156 | 156 | |
157 | 157 | // Register settings |
158 | - add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 ); |
|
158 | + add_filter('give_settings_licenses', array($this, 'settings'), 1); |
|
159 | 159 | |
160 | 160 | // Activate license key on settings save |
161 | - add_action( 'admin_init', array( $this, 'activate_license' ) ); |
|
161 | + add_action('admin_init', array($this, 'activate_license')); |
|
162 | 162 | |
163 | 163 | // Deactivate license key |
164 | - add_action( 'admin_init', array( $this, 'deactivate_license' ) ); |
|
164 | + add_action('admin_init', array($this, 'deactivate_license')); |
|
165 | 165 | |
166 | 166 | // Updater |
167 | - add_action( 'admin_init', array( $this, 'auto_updater' ), 0 ); |
|
167 | + add_action('admin_init', array($this, 'auto_updater'), 0); |
|
168 | 168 | |
169 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
169 | + add_action('admin_notices', array($this, 'notices')); |
|
170 | 170 | |
171 | 171 | // Check license weekly. |
172 | - add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_license_check' ) ); |
|
172 | + add_action('give_weekly_scheduled_events', array($this, 'weekly_license_check')); |
|
173 | 173 | |
174 | 174 | // Check subscription weekly. |
175 | - add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_subscription_check' ) ); |
|
175 | + add_action('give_weekly_scheduled_events', array($this, 'weekly_subscription_check')); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function auto_updater() { |
186 | 186 | |
187 | - if ( ! $this->is_valid_license() ) { |
|
187 | + if ( ! $this->is_valid_license()) { |
|
188 | 188 | return false; |
189 | 189 | } |
190 | 190 | |
@@ -212,16 +212,16 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @return array License settings. |
214 | 214 | */ |
215 | - public function settings( $settings ) { |
|
215 | + public function settings($settings) { |
|
216 | 216 | |
217 | 217 | $give_license_settings = array( |
218 | 218 | array( |
219 | 219 | 'name' => $this->item_name, |
220 | - 'id' => $this->item_shortname . '_license_key', |
|
220 | + 'id' => $this->item_shortname.'_license_key', |
|
221 | 221 | 'desc' => '', |
222 | 222 | 'type' => 'license_key', |
223 | 223 | 'options' => array( |
224 | - 'license' => get_option( $this->item_shortname . '_license_active' ), |
|
224 | + 'license' => get_option($this->item_shortname.'_license_active'), |
|
225 | 225 | 'shortname' => $this->item_shortname, |
226 | 226 | 'item_name' => $this->item_name, |
227 | 227 | 'api_url' => $this->api_url, |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | ) |
233 | 233 | ); |
234 | 234 | |
235 | - return array_merge( $settings, $give_license_settings ); |
|
235 | + return array_merge($settings, $give_license_settings); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -246,18 +246,18 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @return array License settings content. |
248 | 248 | */ |
249 | - public function license_settings_content( $settings ) { |
|
249 | + public function license_settings_content($settings) { |
|
250 | 250 | |
251 | 251 | $give_license_settings = array( |
252 | 252 | array( |
253 | - 'name' => esc_html__( 'Add-on Licenses', 'give' ), |
|
253 | + 'name' => esc_html__('Add-on Licenses', 'give'), |
|
254 | 254 | 'desc' => '<hr>', |
255 | 255 | 'type' => 'give_title', |
256 | 256 | 'id' => 'give_title' |
257 | 257 | ), |
258 | 258 | ); |
259 | 259 | |
260 | - return array_merge( $settings, $give_license_settings ); |
|
260 | + return array_merge($settings, $give_license_settings); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -271,37 +271,37 @@ discard block |
||
271 | 271 | */ |
272 | 272 | public function activate_license() { |
273 | 273 | // Bailout: Check if license key set of not. |
274 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
274 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
275 | 275 | return; |
276 | 276 | } |
277 | 277 | |
278 | 278 | // Security check. |
279 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
279 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
280 | 280 | |
281 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
281 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
282 | 282 | |
283 | 283 | } |
284 | 284 | |
285 | 285 | // Check if user have correct permissions. |
286 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
286 | + if ( ! current_user_can('manage_give_settings')) { |
|
287 | 287 | return; |
288 | 288 | } |
289 | 289 | |
290 | 290 | // Allow third party addon developers to handle license activation. |
291 | - if( $this->__is_third_party_addon() ){ |
|
292 | - do_action( 'give_activate_license', $this ); |
|
291 | + if ($this->__is_third_party_addon()) { |
|
292 | + do_action('give_activate_license', $this); |
|
293 | 293 | return; |
294 | 294 | } |
295 | 295 | |
296 | 296 | // Delete previous license setting if a empty license key submitted. |
297 | - if ( empty( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
298 | - delete_option( $this->item_shortname . '_license_active' ); |
|
297 | + if (empty($_POST[$this->item_shortname.'_license_key'])) { |
|
298 | + delete_option($this->item_shortname.'_license_active'); |
|
299 | 299 | return; |
300 | 300 | } |
301 | 301 | |
302 | 302 | // Do not simultaneously activate any addon if user want to deactivate any addon. |
303 | - foreach ( $_POST as $key => $value ) { |
|
304 | - if ( false !== strpos( $key, 'license_key_deactivate' ) ) { |
|
303 | + foreach ($_POST as $key => $value) { |
|
304 | + if (false !== strpos($key, 'license_key_deactivate')) { |
|
305 | 305 | // Don't activate a key when deactivating a different key |
306 | 306 | return; |
307 | 307 | } |
@@ -309,15 +309,15 @@ discard block |
||
309 | 309 | |
310 | 310 | |
311 | 311 | // Check if plugin previously installed. |
312 | - if ( $this->is_valid_license() ) { |
|
312 | + if ($this->is_valid_license()) { |
|
313 | 313 | return; |
314 | 314 | } |
315 | 315 | |
316 | 316 | // Get license key. |
317 | - $license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] ); |
|
317 | + $license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']); |
|
318 | 318 | |
319 | 319 | // Bailout. |
320 | - if( empty( $license ) ) { |
|
320 | + if (empty($license)) { |
|
321 | 321 | return; |
322 | 322 | } |
323 | 323 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | $api_params = array( |
329 | 329 | 'edd_action' => 'activate_license', //never change from "edd_" to "give_"! |
330 | 330 | 'license' => $license, |
331 | - 'item_name' => urlencode( $this->item_name ), |
|
331 | + 'item_name' => urlencode($this->item_name), |
|
332 | 332 | 'url' => home_url() |
333 | 333 | ); |
334 | 334 | |
@@ -343,16 +343,16 @@ discard block |
||
343 | 343 | ); |
344 | 344 | |
345 | 345 | // Make sure there are no errors |
346 | - if ( is_wp_error( $response ) ) { |
|
346 | + if (is_wp_error($response)) { |
|
347 | 347 | return; |
348 | 348 | } |
349 | 349 | |
350 | 350 | // Tell WordPress to look for updates |
351 | - set_site_transient( 'update_plugins', null ); |
|
351 | + set_site_transient('update_plugins', null); |
|
352 | 352 | |
353 | 353 | // Decode license data |
354 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
355 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
354 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
355 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
356 | 356 | |
357 | 357 | // Check subscription for license key and store this to db (if any). |
358 | 358 | $this->__single_subscription_check(); |
@@ -369,34 +369,34 @@ discard block |
||
369 | 369 | */ |
370 | 370 | public function deactivate_license() { |
371 | 371 | |
372 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
372 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
373 | 373 | return; |
374 | 374 | } |
375 | 375 | |
376 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
376 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
377 | 377 | |
378 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
378 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
379 | 379 | |
380 | 380 | } |
381 | 381 | |
382 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
382 | + if ( ! current_user_can('manage_give_settings')) { |
|
383 | 383 | return; |
384 | 384 | } |
385 | 385 | |
386 | 386 | // Allow third party addon developers to handle license deactivation. |
387 | - if( $this->__is_third_party_addon() ){ |
|
388 | - do_action( 'give_deactivate_license', $this ); |
|
387 | + if ($this->__is_third_party_addon()) { |
|
388 | + do_action('give_deactivate_license', $this); |
|
389 | 389 | return; |
390 | 390 | } |
391 | 391 | |
392 | 392 | // Run on deactivate button press |
393 | - if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) { |
|
393 | + if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) { |
|
394 | 394 | |
395 | 395 | // Data to send to the API |
396 | 396 | $api_params = array( |
397 | 397 | 'edd_action' => 'deactivate_license', //never change from "edd_" to "give_"! |
398 | 398 | 'license' => $this->license, |
399 | - 'item_name' => urlencode( $this->item_name ), |
|
399 | + 'item_name' => urlencode($this->item_name), |
|
400 | 400 | 'url' => home_url() |
401 | 401 | ); |
402 | 402 | |
@@ -412,16 +412,16 @@ discard block |
||
412 | 412 | |
413 | 413 | |
414 | 414 | // Make sure there are no errors |
415 | - if ( is_wp_error( $response ) ) { |
|
415 | + if (is_wp_error($response)) { |
|
416 | 416 | return; |
417 | 417 | } |
418 | 418 | |
419 | 419 | // Decode the license data |
420 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
420 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
421 | 421 | |
422 | 422 | |
423 | 423 | // Remove license data. |
424 | - delete_option( $this->item_shortname . '_license_active' ); |
|
424 | + delete_option($this->item_shortname.'_license_active'); |
|
425 | 425 | |
426 | 426 | // Remove license key from subscriptions if exist. |
427 | 427 | $this->__remove_license_key_from_subscriptions(); |
@@ -439,18 +439,18 @@ discard block |
||
439 | 439 | */ |
440 | 440 | public function weekly_license_check() { |
441 | 441 | |
442 | - if( ! empty( $_POST['give_settings'] ) ) { |
|
442 | + if ( ! empty($_POST['give_settings'])) { |
|
443 | 443 | // Don't fire when saving settings |
444 | 444 | return false; |
445 | 445 | } |
446 | 446 | |
447 | - if( empty( $this->license ) ) { |
|
447 | + if (empty($this->license)) { |
|
448 | 448 | return false; |
449 | 449 | } |
450 | 450 | |
451 | 451 | // Allow third party addon developers to handle there license check. |
452 | - if( $this->__is_third_party_addon() ){ |
|
453 | - do_action( 'give_weekly_license_check', $this ); |
|
452 | + if ($this->__is_third_party_addon()) { |
|
453 | + do_action('give_weekly_license_check', $this); |
|
454 | 454 | return false; |
455 | 455 | } |
456 | 456 | |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | $api_params = array( |
459 | 459 | 'edd_action'=> 'check_license', |
460 | 460 | 'license' => $this->license, |
461 | - 'item_name' => urlencode( $this->item_name ), |
|
461 | + 'item_name' => urlencode($this->item_name), |
|
462 | 462 | 'url' => home_url() |
463 | 463 | ); |
464 | 464 | |
@@ -473,12 +473,12 @@ discard block |
||
473 | 473 | ); |
474 | 474 | |
475 | 475 | // Make sure the response came back okay. |
476 | - if ( is_wp_error( $response ) ) { |
|
476 | + if (is_wp_error($response)) { |
|
477 | 477 | return false; |
478 | 478 | } |
479 | 479 | |
480 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
481 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
480 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
481 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | |
@@ -492,24 +492,24 @@ discard block |
||
492 | 492 | */ |
493 | 493 | public function weekly_subscription_check() { |
494 | 494 | |
495 | - if( ! empty( $_POST['give_settings'] ) ) { |
|
495 | + if ( ! empty($_POST['give_settings'])) { |
|
496 | 496 | // Don't fire when saving settings |
497 | 497 | return false; |
498 | 498 | } |
499 | 499 | |
500 | 500 | // Remove old subscription data. |
501 | - if( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp' , 1 ) ){ |
|
502 | - delete_option( 'give_subscriptions' ); |
|
503 | - update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp' , 1 ) ) ); |
|
501 | + if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) { |
|
502 | + delete_option('give_subscriptions'); |
|
503 | + update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1))); |
|
504 | 504 | } |
505 | 505 | |
506 | - if( empty( $this->license ) ) { |
|
506 | + if (empty($this->license)) { |
|
507 | 507 | return false; |
508 | 508 | } |
509 | 509 | |
510 | 510 | // Allow third party addon developers to handle there subscription check. |
511 | - if( $this->__is_third_party_addon() ){ |
|
512 | - do_action( 'give_weekly_subscription_check', $this ); |
|
511 | + if ($this->__is_third_party_addon()) { |
|
512 | + do_action('give_weekly_subscription_check', $this); |
|
513 | 513 | return false; |
514 | 514 | } |
515 | 515 | |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | // This is custom feature to check subscriptions. |
524 | 524 | 'edd_action'=> 'check_subscription', |
525 | 525 | 'license' => $this->license, |
526 | - 'item_name' => urlencode( $this->item_name ), |
|
526 | + 'item_name' => urlencode($this->item_name), |
|
527 | 527 | 'url' => home_url() |
528 | 528 | ); |
529 | 529 | |
@@ -538,27 +538,27 @@ discard block |
||
538 | 538 | ); |
539 | 539 | |
540 | 540 | // Make sure the response came back okay. |
541 | - if ( is_wp_error( $response ) ) { |
|
541 | + if (is_wp_error($response)) { |
|
542 | 542 | return false; |
543 | 543 | } |
544 | 544 | |
545 | - $subscription_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
545 | + $subscription_data = json_decode(wp_remote_retrieve_body($response), true); |
|
546 | 546 | |
547 | - if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
548 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
547 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
548 | + $subscriptions = get_option('give_subscriptions', array()); |
|
549 | 549 | |
550 | 550 | // Update subscription data only if subscription does not exist already. |
551 | - if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) { |
|
552 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
553 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
551 | + if ( ! array_key_exists($subscription_data['id'], $subscriptions)) { |
|
552 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
553 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | // Store licenses for subscription. |
557 | - if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
558 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
557 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
558 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
559 | 559 | } |
560 | 560 | |
561 | - update_option( 'give_subscriptions', $subscriptions ); |
|
561 | + update_option('give_subscriptions', $subscriptions); |
|
562 | 562 | } |
563 | 563 | } |
564 | 564 | |
@@ -573,11 +573,11 @@ discard block |
||
573 | 573 | */ |
574 | 574 | private function __single_subscription_check() { |
575 | 575 | // Do not fire if license key is not set. |
576 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
576 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
577 | 577 | return false; |
578 | 578 | } |
579 | 579 | |
580 | - if( empty( $this->license ) ) { |
|
580 | + if (empty($this->license)) { |
|
581 | 581 | return false; |
582 | 582 | } |
583 | 583 | |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | // This is custom feature to check subscriptions. |
589 | 589 | 'edd_action'=> 'check_subscription', |
590 | 590 | 'license' => $this->license, |
591 | - 'item_name' => urlencode( $this->item_name ), |
|
591 | + 'item_name' => urlencode($this->item_name), |
|
592 | 592 | 'url' => home_url() |
593 | 593 | ); |
594 | 594 | |
@@ -603,27 +603,27 @@ discard block |
||
603 | 603 | ); |
604 | 604 | |
605 | 605 | // Make sure the response came back okay. |
606 | - if ( is_wp_error( $response ) ) { |
|
606 | + if (is_wp_error($response)) { |
|
607 | 607 | return false; |
608 | 608 | } |
609 | 609 | |
610 | - $subscription_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
610 | + $subscription_data = json_decode(wp_remote_retrieve_body($response), true); |
|
611 | 611 | |
612 | - if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
613 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
612 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
613 | + $subscriptions = get_option('give_subscriptions', array()); |
|
614 | 614 | |
615 | 615 | // Update subscription data only if subscription does not exist already. |
616 | - if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) { |
|
617 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
618 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
616 | + if ( ! array_key_exists($subscription_data['id'], $subscriptions)) { |
|
617 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
618 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | // Store licenses for subscription. |
622 | - if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
623 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
622 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
623 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
624 | 624 | } |
625 | 625 | |
626 | - update_option( 'give_subscriptions', $subscriptions ); |
|
626 | + update_option('give_subscriptions', $subscriptions); |
|
627 | 627 | } |
628 | 628 | } |
629 | 629 | |
@@ -641,89 +641,89 @@ discard block |
||
641 | 641 | static $addon_license_key_in_subscriptions; |
642 | 642 | |
643 | 643 | // Set default value. |
644 | - $addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array(); |
|
644 | + $addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array(); |
|
645 | 645 | |
646 | - if( empty( $this->license ) ) { |
|
646 | + if (empty($this->license)) { |
|
647 | 647 | return; |
648 | 648 | } |
649 | 649 | |
650 | - if( ! current_user_can( 'manage_shop_settings' ) ) { |
|
650 | + if ( ! current_user_can('manage_shop_settings')) { |
|
651 | 651 | return; |
652 | 652 | } |
653 | 653 | |
654 | 654 | // Do not show licenses notices on license tab. |
655 | - if( ! empty( $_GET['tab'] ) && 'licenses' === $_GET['tab'] ) { |
|
655 | + if ( ! empty($_GET['tab']) && 'licenses' === $_GET['tab']) { |
|
656 | 656 | return; |
657 | 657 | } |
658 | 658 | |
659 | 659 | $messages = array(); |
660 | 660 | |
661 | 661 | // Get subscriptions. |
662 | - $subscriptions = get_option( 'give_subscriptions' ); |
|
662 | + $subscriptions = get_option('give_subscriptions'); |
|
663 | 663 | |
664 | 664 | |
665 | 665 | // Show subscription messages. |
666 | - if( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) { |
|
666 | + if ( ! empty($subscriptions) && ! $showed_subscriptions_message) { |
|
667 | 667 | |
668 | - foreach ( $subscriptions as $subscription ) { |
|
668 | + foreach ($subscriptions as $subscription) { |
|
669 | 669 | // Subscription expires timestamp. |
670 | - $subscription_expires = strtotime( $subscription['expires'] ); |
|
670 | + $subscription_expires = strtotime($subscription['expires']); |
|
671 | 671 | |
672 | 672 | // Start showing subscriptions message before one week of renewal date. |
673 | - if( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) { |
|
673 | + if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) { |
|
674 | 674 | continue; |
675 | 675 | } |
676 | 676 | |
677 | 677 | // Check if subscription message already exist in messages. |
678 | - if( array_key_exists( $subscription['id'], $messages ) ) { |
|
678 | + if (array_key_exists($subscription['id'], $messages)) { |
|
679 | 679 | continue; |
680 | 680 | } |
681 | 681 | |
682 | - if( ( ! $this->__is_notice_dismissed( $subscription['id'] ) && 'active' !== $subscription['status'] ) ) { |
|
682 | + if (( ! $this->__is_notice_dismissed($subscription['id']) && 'active' !== $subscription['status'])) { |
|
683 | 683 | |
684 | - if( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {// Check if license already expired. |
|
684 | + if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {// Check if license already expired. |
|
685 | 685 | $messages[$subscription['id']] = sprintf( |
686 | - __( 'You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
|
687 | - urldecode( $subscription['invoice_url'] ), |
|
686 | + __('You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'), |
|
687 | + urldecode($subscription['invoice_url']), |
|
688 | 688 | $subscription['payment_id'], |
689 | 689 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
690 | - esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
|
690 | + esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'])) |
|
691 | 691 | ); |
692 | - }else{ |
|
692 | + } else { |
|
693 | 693 | $messages[$subscription['id']] = sprintf( |
694 | - __( 'You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
|
695 | - human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ), |
|
696 | - urldecode( $subscription['invoice_url'] ), |
|
694 | + __('You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'), |
|
695 | + human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])), |
|
696 | + urldecode($subscription['invoice_url']), |
|
697 | 697 | $subscription['payment_id'], |
698 | 698 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
699 | - esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
|
699 | + esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'])) |
|
700 | 700 | ); |
701 | 701 | } |
702 | 702 | } |
703 | 703 | |
704 | 704 | // Stop validation for these licencse keys. |
705 | - $addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] ); |
|
705 | + $addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']); |
|
706 | 706 | } |
707 | 707 | $showed_subscriptions_message = true; |
708 | 708 | } |
709 | 709 | |
710 | 710 | |
711 | 711 | // Show non subscription addon messages. |
712 | - if( ! in_array( $this->license, $addon_license_key_in_subscriptions ) && ! $this->__is_notice_dismissed( 'general' ) && ! $this->is_valid_license() && empty( $showed_invalid_message ) ) { |
|
712 | + if ( ! in_array($this->license, $addon_license_key_in_subscriptions) && ! $this->__is_notice_dismissed('general') && ! $this->is_valid_license() && empty($showed_invalid_message)) { |
|
713 | 713 | |
714 | 714 | $messages['general'] = sprintf( |
715 | - __( 'You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">Licenses page</a> to correct this issue.', 'give' ), |
|
716 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) |
|
715 | + __('You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">Licenses page</a> to correct this issue.', 'give'), |
|
716 | + admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses') |
|
717 | 717 | ); |
718 | 718 | $showed_invalid_message = true; |
719 | 719 | |
720 | 720 | } |
721 | 721 | |
722 | 722 | // Print messages. |
723 | - if( ! empty( $messages ) ) { |
|
724 | - foreach( $messages as $notice_id => $message ) { |
|
725 | - echo '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="' . esc_url( add_query_arg( '_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'] ) ) . '">'; |
|
726 | - echo '<p>' . $message . '</p>'; |
|
723 | + if ( ! empty($messages)) { |
|
724 | + foreach ($messages as $notice_id => $message) { |
|
725 | + echo '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="'.esc_url(add_query_arg('_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'])).'">'; |
|
726 | + echo '<p>'.$message.'</p>'; |
|
727 | 727 | echo '</div>'; |
728 | 728 | } |
729 | 729 | } |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | * @return bool |
739 | 739 | */ |
740 | 740 | public function is_valid_license() { |
741 | - if( apply_filters( 'give_is_valid_license' , ( is_object( $this->license_data ) && ! empty( $this->license_data ) && property_exists( $this->license_data, 'license' )&& 'valid' === $this->license_data->license ) ) ) { |
|
741 | + if (apply_filters('give_is_valid_license', (is_object($this->license_data) && ! empty($this->license_data) && property_exists($this->license_data, 'license') && 'valid' === $this->license_data->license))) { |
|
742 | 742 | return true; |
743 | 743 | } |
744 | 744 | |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | * @return bool |
755 | 755 | */ |
756 | 756 | private function __is_third_party_addon() { |
757 | - return ( false === strpos( $this->api_url, 'givewp.com/' ) ); |
|
757 | + return (false === strpos($this->api_url, 'givewp.com/')); |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | |
@@ -769,26 +769,26 @@ discard block |
||
769 | 769 | * |
770 | 770 | * @return void|bool |
771 | 771 | */ |
772 | - private function __remove_license_key_from_subscriptions(){ |
|
773 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
772 | + private function __remove_license_key_from_subscriptions() { |
|
773 | + $subscriptions = get_option('give_subscriptions', array()); |
|
774 | 774 | |
775 | 775 | // Bailout. |
776 | - if( empty( $this->license ) ) { |
|
776 | + if (empty($this->license)) { |
|
777 | 777 | return false; |
778 | 778 | } |
779 | 779 | |
780 | - if( ! empty( $subscriptions ) ) { |
|
781 | - foreach ( $subscriptions as $subscription_id => $subscription ) { |
|
782 | - $license_index = array_search( $this->license, $subscription['licenses'] ); |
|
783 | - if( false !== $license_index ) { |
|
780 | + if ( ! empty($subscriptions)) { |
|
781 | + foreach ($subscriptions as $subscription_id => $subscription) { |
|
782 | + $license_index = array_search($this->license, $subscription['licenses']); |
|
783 | + if (false !== $license_index) { |
|
784 | 784 | // Remove license key. |
785 | - unset( $subscriptions[ $subscription_id ]['licenses'][$license_index] ); |
|
785 | + unset($subscriptions[$subscription_id]['licenses'][$license_index]); |
|
786 | 786 | |
787 | 787 | // Rearrange license keys. |
788 | - $subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] ); |
|
788 | + $subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']); |
|
789 | 789 | |
790 | 790 | // Update subscription information. |
791 | - update_option( 'give_subscriptions', $subscriptions ); |
|
791 | + update_option('give_subscriptions', $subscriptions); |
|
792 | 792 | break; |
793 | 793 | } |
794 | 794 | } |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | * |
804 | 804 | * @return void |
805 | 805 | */ |
806 | - private function __remove_license_notices_show_blocker(){ |
|
806 | + private function __remove_license_notices_show_blocker() { |
|
807 | 807 | global $wpdb; |
808 | 808 | |
809 | 809 | // Delete permanent notice blocker. |
@@ -841,18 +841,18 @@ discard block |
||
841 | 841 | * |
842 | 842 | * @return bool |
843 | 843 | */ |
844 | - private function __is_notice_dismissed( $notice_id ){ |
|
844 | + private function __is_notice_dismissed($notice_id) { |
|
845 | 845 | global $current_user; |
846 | 846 | $is_notice_dismissed = false; |
847 | 847 | |
848 | 848 | // Ge is notice dismissed permanently. |
849 | - $already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) ) |
|
849 | + $already_dismiss_notices = ($already_dismiss_notices = get_user_meta($current_user->ID, '_give_hide_license_notices_permanently', true)) |
|
850 | 850 | ? $already_dismiss_notices |
851 | 851 | : array(); |
852 | 852 | |
853 | 853 | |
854 | - if( in_array( $notice_id, $already_dismiss_notices ) || get_transient( "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}" ) ) { |
|
855 | - $is_notice_dismissed = true; |
|
854 | + if (in_array($notice_id, $already_dismiss_notices) || get_transient("_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}")) { |
|
855 | + $is_notice_dismissed = true; |
|
856 | 856 | } |
857 | 857 | |
858 | 858 | return $is_notice_dismissed; |
@@ -689,7 +689,7 @@ |
||
689 | 689 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
690 | 690 | esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
691 | 691 | ); |
692 | - }else{ |
|
692 | + } else{ |
|
693 | 693 | $messages[$subscription['id']] = sprintf( |
694 | 694 | __( 'You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
695 | 695 | human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ), |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -30,36 +30,36 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool|object List of all user donations |
32 | 32 | */ |
33 | -function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
33 | +function give_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
34 | 34 | |
35 | - if ( empty( $user ) ) { |
|
35 | + if (empty($user)) { |
|
36 | 36 | $user = get_current_user_id(); |
37 | 37 | } |
38 | 38 | |
39 | - if ( 0 === $user && ! Give()->email_access->token_exists ) { |
|
39 | + if (0 === $user && ! Give()->email_access->token_exists) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | 43 | $status = $status === 'complete' ? 'publish' : $status; |
44 | 44 | |
45 | - if ( $pagination ) { |
|
46 | - if ( get_query_var( 'paged' ) ) { |
|
47 | - $paged = get_query_var( 'paged' ); |
|
48 | - } else if ( get_query_var( 'page' ) ) { |
|
49 | - $paged = get_query_var( 'page' ); |
|
45 | + if ($pagination) { |
|
46 | + if (get_query_var('paged')) { |
|
47 | + $paged = get_query_var('paged'); |
|
48 | + } else if (get_query_var('page')) { |
|
49 | + $paged = get_query_var('page'); |
|
50 | 50 | } else { |
51 | 51 | $paged = 1; |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - $args = apply_filters( 'give_get_users_purchases_args', array( |
|
55 | + $args = apply_filters('give_get_users_purchases_args', array( |
|
56 | 56 | 'user' => $user, |
57 | 57 | 'number' => $number, |
58 | 58 | 'status' => $status, |
59 | 59 | 'orderby' => 'date' |
60 | - ) ); |
|
60 | + )); |
|
61 | 61 | |
62 | - if ( $pagination ) { |
|
62 | + if ($pagination) { |
|
63 | 63 | |
64 | 64 | $args['page'] = $paged; |
65 | 65 | |
@@ -69,20 +69,20 @@ discard block |
||
69 | 69 | |
70 | 70 | } |
71 | 71 | |
72 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
73 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
72 | + $by_user_id = is_numeric($user) ? true : false; |
|
73 | + $customer = new Give_Customer($user, $by_user_id); |
|
74 | 74 | |
75 | - if ( ! empty( $customer->payment_ids ) ) { |
|
75 | + if ( ! empty($customer->payment_ids)) { |
|
76 | 76 | |
77 | - unset( $args['user'] ); |
|
78 | - $args['post__in'] = array_map( 'absint', explode( ',', $customer->payment_ids ) ); |
|
77 | + unset($args['user']); |
|
78 | + $args['post__in'] = array_map('absint', explode(',', $customer->payment_ids)); |
|
79 | 79 | |
80 | 80 | } |
81 | 81 | |
82 | - $purchases = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) ); |
|
82 | + $purchases = give_get_payments(apply_filters('give_get_users_donations_args', $args)); |
|
83 | 83 | |
84 | 84 | // No donations |
85 | - if ( ! $purchases ) { |
|
85 | + if ( ! $purchases) { |
|
86 | 86 | return false; |
87 | 87 | } |
88 | 88 | |
@@ -101,65 +101,65 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return bool|object List of unique forms donated by user |
103 | 103 | */ |
104 | -function give_get_users_completed_donations( $user = 0, $status = 'complete' ) { |
|
105 | - if ( empty( $user ) ) { |
|
104 | +function give_get_users_completed_donations($user = 0, $status = 'complete') { |
|
105 | + if (empty($user)) { |
|
106 | 106 | $user = get_current_user_id(); |
107 | 107 | } |
108 | 108 | |
109 | - if ( empty( $user ) ) { |
|
109 | + if (empty($user)) { |
|
110 | 110 | return false; |
111 | 111 | } |
112 | 112 | |
113 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
113 | + $by_user_id = is_numeric($user) ? true : false; |
|
114 | 114 | |
115 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
115 | + $customer = new Give_Customer($user, $by_user_id); |
|
116 | 116 | |
117 | - if ( empty( $customer->payment_ids ) ) { |
|
117 | + if (empty($customer->payment_ids)) { |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | |
121 | 121 | // Get all the items donated |
122 | - $payment_ids = array_reverse( explode( ',', $customer->payment_ids ) ); |
|
123 | - $limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 ); |
|
124 | - if ( ! empty( $limit_payments ) ) { |
|
125 | - $payment_ids = array_slice( $payment_ids, 0, $limit_payments ); |
|
122 | + $payment_ids = array_reverse(explode(',', $customer->payment_ids)); |
|
123 | + $limit_payments = apply_filters('give_users_completed_donations_payments', 50); |
|
124 | + if ( ! empty($limit_payments)) { |
|
125 | + $payment_ids = array_slice($payment_ids, 0, $limit_payments); |
|
126 | 126 | } |
127 | 127 | $donation_data = array(); |
128 | - foreach ( $payment_ids as $payment_id ) { |
|
129 | - $donation_data[] = give_get_payment_meta( $payment_id ); |
|
128 | + foreach ($payment_ids as $payment_id) { |
|
129 | + $donation_data[] = give_get_payment_meta($payment_id); |
|
130 | 130 | } |
131 | 131 | |
132 | - if ( empty( $donation_data ) ) { |
|
132 | + if (empty($donation_data)) { |
|
133 | 133 | return false; |
134 | 134 | } |
135 | 135 | |
136 | 136 | // Grab only the post ids "form_id" of the forms donated on this order |
137 | 137 | $completed_donations_ids = array(); |
138 | - foreach ( $donation_data as $purchase_meta ) { |
|
138 | + foreach ($donation_data as $purchase_meta) { |
|
139 | 139 | $completed_donations_ids[] = isset($purchase_meta['form_id']) ? $purchase_meta['form_id'] : ''; |
140 | 140 | } |
141 | 141 | |
142 | - if ( empty( $completed_donations_ids ) ) { |
|
142 | + if (empty($completed_donations_ids)) { |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Only include each donation once |
147 | - $form_ids = array_unique( $completed_donations_ids ); |
|
147 | + $form_ids = array_unique($completed_donations_ids); |
|
148 | 148 | |
149 | 149 | // Make sure we still have some products and a first item |
150 | - if ( empty ( $form_ids ) || ! isset( $form_ids[0] ) ) { |
|
150 | + if (empty ($form_ids) || ! isset($form_ids[0])) { |
|
151 | 151 | return false; |
152 | 152 | } |
153 | 153 | |
154 | - $post_type = get_post_type( $form_ids[0] ); |
|
154 | + $post_type = get_post_type($form_ids[0]); |
|
155 | 155 | |
156 | - $args = apply_filters( 'give_get_users_completed_donations_args', array( |
|
156 | + $args = apply_filters('give_get_users_completed_donations_args', array( |
|
157 | 157 | 'include' => $form_ids, |
158 | 158 | 'post_type' => $post_type, |
159 | - 'posts_per_page' => - 1 |
|
160 | - ) ); |
|
159 | + 'posts_per_page' => -1 |
|
160 | + )); |
|
161 | 161 | |
162 | - return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) ); |
|
162 | + return apply_filters('give_users_completed_donations_list', get_posts($args)); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return bool - true if has donated, false other wise. |
177 | 177 | */ |
178 | -function give_has_purchases( $user_id = null ) { |
|
179 | - if ( empty( $user_id ) ) { |
|
178 | +function give_has_purchases($user_id = null) { |
|
179 | + if (empty($user_id)) { |
|
180 | 180 | $user_id = get_current_user_id(); |
181 | 181 | } |
182 | 182 | |
183 | - if ( give_get_users_purchases( $user_id, 1 ) ) { |
|
183 | + if (give_get_users_purchases($user_id, 1)) { |
|
184 | 184 | return true; // User has at least one donation |
185 | 185 | } |
186 | 186 | |
@@ -200,27 +200,27 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return array |
202 | 202 | */ |
203 | -function give_get_purchase_stats_by_user( $user = '' ) { |
|
203 | +function give_get_purchase_stats_by_user($user = '') { |
|
204 | 204 | |
205 | - if ( is_email( $user ) ) { |
|
205 | + if (is_email($user)) { |
|
206 | 206 | |
207 | 207 | $field = 'email'; |
208 | 208 | |
209 | - } elseif ( is_numeric( $user ) ) { |
|
209 | + } elseif (is_numeric($user)) { |
|
210 | 210 | |
211 | 211 | $field = 'user_id'; |
212 | 212 | |
213 | 213 | } |
214 | 214 | |
215 | 215 | $stats = array(); |
216 | - $customer = Give()->customers->get_customer_by( $field, $user ); |
|
216 | + $customer = Give()->customers->get_customer_by($field, $user); |
|
217 | 217 | |
218 | - if ( $customer ) { |
|
218 | + if ($customer) { |
|
219 | 219 | |
220 | - $customer = new Give_Customer( $customer->id ); |
|
220 | + $customer = new Give_Customer($customer->id); |
|
221 | 221 | |
222 | - $stats['purchases'] = absint( $customer->purchase_count ); |
|
223 | - $stats['total_spent'] = give_sanitize_amount( $customer->purchase_value ); |
|
222 | + $stats['purchases'] = absint($customer->purchase_count); |
|
223 | + $stats['total_spent'] = give_sanitize_amount($customer->purchase_value); |
|
224 | 224 | |
225 | 225 | } |
226 | 226 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @since 1.7 |
231 | 231 | */ |
232 | - $stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user ); |
|
232 | + $stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user); |
|
233 | 233 | |
234 | 234 | return $stats; |
235 | 235 | } |
@@ -247,22 +247,22 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return int - the total number of donations |
249 | 249 | */ |
250 | -function give_count_purchases_of_customer( $user = null ) { |
|
250 | +function give_count_purchases_of_customer($user = null) { |
|
251 | 251 | |
252 | 252 | //Logged in? |
253 | - if ( empty( $user ) ) { |
|
253 | + if (empty($user)) { |
|
254 | 254 | $user = get_current_user_id(); |
255 | 255 | } |
256 | 256 | |
257 | 257 | //Email access? |
258 | - if ( empty( $user ) && Give()->email_access->token_email ) { |
|
258 | + if (empty($user) && Give()->email_access->token_email) { |
|
259 | 259 | $user = Give()->email_access->token_email; |
260 | 260 | } |
261 | 261 | |
262 | 262 | |
263 | - $stats = ! empty( $user ) ? give_get_purchase_stats_by_user( $user ) : false; |
|
263 | + $stats = ! empty($user) ? give_get_purchase_stats_by_user($user) : false; |
|
264 | 264 | |
265 | - return isset( $stats['purchases'] ) ? $stats['purchases'] : 0; |
|
265 | + return isset($stats['purchases']) ? $stats['purchases'] : 0; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @return float - the total amount the user has spent |
277 | 277 | */ |
278 | -function give_purchase_total_of_user( $user = null ) { |
|
278 | +function give_purchase_total_of_user($user = null) { |
|
279 | 279 | |
280 | - $stats = give_get_purchase_stats_by_user( $user ); |
|
280 | + $stats = give_get_purchase_stats_by_user($user); |
|
281 | 281 | |
282 | 282 | return $stats['total_spent']; |
283 | 283 | } |
@@ -293,11 +293,11 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @return bool |
295 | 295 | */ |
296 | -function give_validate_username( $username ) { |
|
297 | - $sanitized = sanitize_user( $username, false ); |
|
298 | - $valid = ( $sanitized == $username ); |
|
296 | +function give_validate_username($username) { |
|
297 | + $sanitized = sanitize_user($username, false); |
|
298 | + $valid = ($sanitized == $username); |
|
299 | 299 | |
300 | - return (bool) apply_filters( 'give_validate_username', $valid, $username ); |
|
300 | + return (bool) apply_filters('give_validate_username', $valid, $username); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -314,32 +314,32 @@ discard block |
||
314 | 314 | * |
315 | 315 | * @return void |
316 | 316 | */ |
317 | -function give_add_past_purchases_to_new_user( $user_id ) { |
|
317 | +function give_add_past_purchases_to_new_user($user_id) { |
|
318 | 318 | |
319 | - $email = get_the_author_meta( 'user_email', $user_id ); |
|
319 | + $email = get_the_author_meta('user_email', $user_id); |
|
320 | 320 | |
321 | - $payments = give_get_payments( array( 's' => $email ) ); |
|
321 | + $payments = give_get_payments(array('s' => $email)); |
|
322 | 322 | |
323 | - if ( $payments ) { |
|
324 | - foreach ( $payments as $payment ) { |
|
325 | - if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) { |
|
323 | + if ($payments) { |
|
324 | + foreach ($payments as $payment) { |
|
325 | + if (intval(give_get_payment_user_id($payment->ID)) > 0) { |
|
326 | 326 | continue; |
327 | 327 | } // This payment already associated with an account |
328 | 328 | |
329 | - $meta = give_get_payment_meta( $payment->ID ); |
|
330 | - $meta['user_info'] = maybe_unserialize( $meta['user_info'] ); |
|
329 | + $meta = give_get_payment_meta($payment->ID); |
|
330 | + $meta['user_info'] = maybe_unserialize($meta['user_info']); |
|
331 | 331 | $meta['user_info']['id'] = $user_id; |
332 | 332 | $meta['user_info'] = $meta['user_info']; |
333 | 333 | |
334 | 334 | // Store the updated user ID in the payment meta |
335 | - give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta ); |
|
336 | - give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id ); |
|
335 | + give_update_payment_meta($payment->ID, '_give_payment_meta', $meta); |
|
336 | + give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id); |
|
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | 340 | } |
341 | 341 | |
342 | -add_action( 'user_register', 'give_add_past_purchases_to_new_user' ); |
|
342 | +add_action('user_register', 'give_add_past_purchases_to_new_user'); |
|
343 | 343 | |
344 | 344 | |
345 | 345 | /** |
@@ -361,34 +361,34 @@ discard block |
||
361 | 361 | * @since 1.0 |
362 | 362 | * @return array - The donor's address, if any |
363 | 363 | */ |
364 | -function give_get_donor_address( $user_id = 0 ) { |
|
365 | - if ( empty( $user_id ) ) { |
|
364 | +function give_get_donor_address($user_id = 0) { |
|
365 | + if (empty($user_id)) { |
|
366 | 366 | $user_id = get_current_user_id(); |
367 | 367 | } |
368 | 368 | |
369 | - $address = get_user_meta( $user_id, '_give_user_address', true ); |
|
369 | + $address = get_user_meta($user_id, '_give_user_address', true); |
|
370 | 370 | |
371 | - if ( ! isset( $address['line1'] ) ) { |
|
371 | + if ( ! isset($address['line1'])) { |
|
372 | 372 | $address['line1'] = ''; |
373 | 373 | } |
374 | 374 | |
375 | - if ( ! isset( $address['line2'] ) ) { |
|
375 | + if ( ! isset($address['line2'])) { |
|
376 | 376 | $address['line2'] = ''; |
377 | 377 | } |
378 | 378 | |
379 | - if ( ! isset( $address['city'] ) ) { |
|
379 | + if ( ! isset($address['city'])) { |
|
380 | 380 | $address['city'] = ''; |
381 | 381 | } |
382 | 382 | |
383 | - if ( ! isset( $address['zip'] ) ) { |
|
383 | + if ( ! isset($address['zip'])) { |
|
384 | 384 | $address['zip'] = ''; |
385 | 385 | } |
386 | 386 | |
387 | - if ( ! isset( $address['country'] ) ) { |
|
387 | + if ( ! isset($address['country'])) { |
|
388 | 388 | $address['country'] = ''; |
389 | 389 | } |
390 | 390 | |
391 | - if ( ! isset( $address['state'] ) ) { |
|
391 | + if ( ! isset($address['state'])) { |
|
392 | 392 | $address['state'] = ''; |
393 | 393 | } |
394 | 394 | |
@@ -408,42 +408,42 @@ discard block |
||
408 | 408 | * |
409 | 409 | * @return void |
410 | 410 | */ |
411 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { |
|
411 | +function give_new_user_notification($user_id = 0, $user_data = array()) { |
|
412 | 412 | |
413 | - if ( empty( $user_id ) || empty( $user_data ) ) { |
|
413 | + if (empty($user_id) || empty($user_data)) { |
|
414 | 414 | return; |
415 | 415 | } |
416 | - $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
416 | + $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
417 | 417 | |
418 | 418 | /* translators: %s: site name */ |
419 | - $message = sprintf( esc_attr__( 'New user registration on your site %s:', 'give' ), $blogname ) . "\r\n\r\n"; |
|
419 | + $message = sprintf(esc_attr__('New user registration on your site %s:', 'give'), $blogname)."\r\n\r\n"; |
|
420 | 420 | /* translators: %s: user login */ |
421 | - $message .= sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n\r\n"; |
|
421 | + $message .= sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n\r\n"; |
|
422 | 422 | /* translators: %s: user email */ |
423 | - $message .= sprintf( esc_attr__( 'E-mail: %s', 'give' ), $user_data['user_email'] ) . "\r\n"; |
|
423 | + $message .= sprintf(esc_attr__('E-mail: %s', 'give'), $user_data['user_email'])."\r\n"; |
|
424 | 424 | |
425 | 425 | @wp_mail( |
426 | - get_option( 'admin_email' ), |
|
426 | + get_option('admin_email'), |
|
427 | 427 | sprintf( |
428 | 428 | /* translators: %s: site name */ |
429 | - esc_attr__( '[%s] New User Registration', 'give' ), |
|
429 | + esc_attr__('[%s] New User Registration', 'give'), |
|
430 | 430 | $blogname |
431 | 431 | ), |
432 | 432 | $message |
433 | 433 | ); |
434 | 434 | |
435 | 435 | /* translators: %s: user login */ |
436 | - $message = sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n"; |
|
436 | + $message = sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n"; |
|
437 | 437 | /* translators: %s: paswword */ |
438 | - $message .= sprintf( esc_attr__( 'Password: %s', 'give' ), esc_attr__( '[Password entered during donation]', 'give' ) ) . "\r\n"; |
|
438 | + $message .= sprintf(esc_attr__('Password: %s', 'give'), esc_attr__('[Password entered during donation]', 'give'))."\r\n"; |
|
439 | 439 | |
440 | - $message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Login »', 'give' ) . '</a>' . "\r\n"; |
|
440 | + $message .= '<a href="'.wp_login_url().'"> '.esc_attr__('Click Here to Login »', 'give').'</a>'."\r\n"; |
|
441 | 441 | |
442 | 442 | wp_mail( |
443 | 443 | $user_data['user_email'], |
444 | 444 | sprintf( |
445 | 445 | /* translators: %s: site name */ |
446 | - esc_attr__( '[%s] Your username and password', 'give' ), |
|
446 | + esc_attr__('[%s] Your username and password', 'give'), |
|
447 | 447 | $blogname |
448 | 448 | ), |
449 | 449 | $message |
@@ -451,4 +451,4 @@ discard block |
||
451 | 451 | |
452 | 452 | } |
453 | 453 | |
454 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
454 | +add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
@@ -10,7 +10,7 @@ discard block |
||
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 | |
@@ -26,50 +26,50 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_email_donation_receipt( $payment_id, $admin_notice = true ) { |
|
29 | +function give_email_donation_receipt($payment_id, $admin_notice = true) { |
|
30 | 30 | |
31 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
31 | + $payment_data = give_get_payment_meta($payment_id); |
|
32 | 32 | |
33 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
33 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Filters the from name. |
37 | 37 | * |
38 | 38 | * @since 1.7 |
39 | 39 | */ |
40 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
40 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
41 | 41 | |
42 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
42 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * Filters the from email. |
46 | 46 | * |
47 | 47 | * @since 1.7 |
48 | 48 | */ |
49 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
49 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
50 | 50 | |
51 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
51 | + $to_email = give_get_payment_user_email($payment_id); |
|
52 | 52 | |
53 | - $subject = give_get_option( 'donation_subject', esc_html__( 'Donation Receipt', 'give' ) ); |
|
54 | - $subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
55 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
53 | + $subject = give_get_option('donation_subject', esc_html__('Donation Receipt', 'give')); |
|
54 | + $subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
55 | + $subject = give_do_email_tags($subject, $payment_id); |
|
56 | 56 | |
57 | - $attachments = apply_filters( 'give_receipt_attachments', array(), $payment_id, $payment_data ); |
|
58 | - $message = give_do_email_tags( give_get_email_body_content( $payment_id, $payment_data ), $payment_id ); |
|
57 | + $attachments = apply_filters('give_receipt_attachments', array(), $payment_id, $payment_data); |
|
58 | + $message = give_do_email_tags(give_get_email_body_content($payment_id, $payment_data), $payment_id); |
|
59 | 59 | |
60 | 60 | $emails = Give()->emails; |
61 | 61 | |
62 | - $emails->__set( 'from_name', $from_name ); |
|
63 | - $emails->__set( 'from_email', $from_email ); |
|
64 | - $emails->__set( 'heading', esc_html__( 'Donation Receipt', 'give' ) ); |
|
62 | + $emails->__set('from_name', $from_name); |
|
63 | + $emails->__set('from_email', $from_email); |
|
64 | + $emails->__set('heading', esc_html__('Donation Receipt', 'give')); |
|
65 | 65 | |
66 | 66 | |
67 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
68 | - $emails->__set( 'headers', $headers ); |
|
67 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
68 | + $emails->__set('headers', $headers); |
|
69 | 69 | |
70 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
70 | + $emails->send($to_email, $subject, $message, $attachments); |
|
71 | 71 | |
72 | - if ( $admin_notice && ! give_admin_notices_disabled( $payment_id ) ) { |
|
72 | + if ($admin_notice && ! give_admin_notices_disabled($payment_id)) { |
|
73 | 73 | /** |
74 | 74 | * Fires in the email donation receipt. |
75 | 75 | * |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param int $payment_id Payment id. |
81 | 81 | * @param mixed $payment_data Payment meta data. |
82 | 82 | */ |
83 | - do_action( 'give_admin_sale_notice', $payment_id, $payment_data ); |
|
83 | + do_action('give_admin_sale_notice', $payment_id, $payment_data); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
@@ -93,41 +93,41 @@ discard block |
||
93 | 93 | */ |
94 | 94 | function give_email_test_donation_receipt() { |
95 | 95 | |
96 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
96 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Filters the from name. |
100 | 100 | * |
101 | 101 | * @since 1.7 |
102 | 102 | */ |
103 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, 0, array() ); |
|
103 | + $from_name = apply_filters('give_donation_from_name', $from_name, 0, array()); |
|
104 | 104 | |
105 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
105 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Filters the from email. |
109 | 109 | * |
110 | 110 | * @since 1.7 |
111 | 111 | */ |
112 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, 0, array() ); |
|
112 | + $from_email = apply_filters('give_donation_from_address', $from_email, 0, array()); |
|
113 | 113 | |
114 | - $subject = give_get_option( 'donation_subject', esc_html__( 'Donation Receipt', 'give' ) ); |
|
115 | - $subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), 0 ); |
|
116 | - $subject = give_do_email_tags( $subject, 0 ); |
|
114 | + $subject = give_get_option('donation_subject', esc_html__('Donation Receipt', 'give')); |
|
115 | + $subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), 0); |
|
116 | + $subject = give_do_email_tags($subject, 0); |
|
117 | 117 | |
118 | - $attachments = apply_filters( 'give_receipt_attachments', array(), 0, array() ); |
|
118 | + $attachments = apply_filters('give_receipt_attachments', array(), 0, array()); |
|
119 | 119 | |
120 | - $message = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) ); |
|
120 | + $message = give_email_preview_template_tags(give_get_email_body_content(0, array())); |
|
121 | 121 | |
122 | 122 | $emails = Give()->emails; |
123 | - $emails->__set( 'from_name', $from_name ); |
|
124 | - $emails->__set( 'from_email', $from_email ); |
|
125 | - $emails->__set( 'heading', esc_html__( 'Donation Receipt', 'give' ) ); |
|
123 | + $emails->__set('from_name', $from_name); |
|
124 | + $emails->__set('from_email', $from_email); |
|
125 | + $emails->__set('heading', esc_html__('Donation Receipt', 'give')); |
|
126 | 126 | |
127 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), 0, array() ); |
|
128 | - $emails->__set( 'headers', $headers ); |
|
127 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), 0, array()); |
|
128 | + $emails->__set('headers', $headers); |
|
129 | 129 | |
130 | - $emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments ); |
|
130 | + $emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments); |
|
131 | 131 | |
132 | 132 | } |
133 | 133 | |
@@ -141,62 +141,62 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @return void |
143 | 143 | */ |
144 | -function give_admin_email_notice( $payment_id = 0, $payment_data = array() ) { |
|
144 | +function give_admin_email_notice($payment_id = 0, $payment_data = array()) { |
|
145 | 145 | |
146 | - $payment_id = absint( $payment_id ); |
|
146 | + $payment_id = absint($payment_id); |
|
147 | 147 | |
148 | - if ( empty( $payment_id ) ) { |
|
148 | + if (empty($payment_id)) { |
|
149 | 149 | return; |
150 | 150 | } |
151 | 151 | |
152 | - if ( ! give_get_payment_by( 'id', $payment_id ) ) { |
|
152 | + if ( ! give_get_payment_by('id', $payment_id)) { |
|
153 | 153 | return; |
154 | 154 | } |
155 | 155 | |
156 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
156 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
157 | 157 | |
158 | 158 | /** |
159 | 159 | * Filters the from name. |
160 | 160 | * |
161 | 161 | * @since 1.7 |
162 | 162 | */ |
163 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
163 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
164 | 164 | |
165 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
165 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
166 | 166 | |
167 | 167 | /** |
168 | 168 | * Filters the from email. |
169 | 169 | * |
170 | 170 | * @since 1.7 |
171 | 171 | */ |
172 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
172 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
173 | 173 | |
174 | 174 | /* translators: %s: payment id */ |
175 | - $subject = give_get_option( 'donation_notification_subject', sprintf( esc_html__( 'New Donation - Payment #%s', 'give' ), $payment_id ) ); |
|
176 | - $subject = apply_filters( 'give_admin_donation_notification_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
177 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
175 | + $subject = give_get_option('donation_notification_subject', sprintf(esc_html__('New Donation - Payment #%s', 'give'), $payment_id)); |
|
176 | + $subject = apply_filters('give_admin_donation_notification_subject', wp_strip_all_tags($subject), $payment_id); |
|
177 | + $subject = give_do_email_tags($subject, $payment_id); |
|
178 | 178 | |
179 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
180 | - $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
179 | + $headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n"; |
|
180 | + $headers .= "Reply-To: ".$from_email."\r\n"; |
|
181 | 181 | //$headers .= "MIME-Version: 1.0\r\n"; |
182 | 182 | $headers .= "Content-Type: text/html; charset=utf-8\r\n"; |
183 | - $headers = apply_filters( 'give_admin_donation_notification_headers', $headers, $payment_id, $payment_data ); |
|
183 | + $headers = apply_filters('give_admin_donation_notification_headers', $headers, $payment_id, $payment_data); |
|
184 | 184 | |
185 | - $attachments = apply_filters( 'give_admin_donation_notification_attachments', array(), $payment_id, $payment_data ); |
|
185 | + $attachments = apply_filters('give_admin_donation_notification_attachments', array(), $payment_id, $payment_data); |
|
186 | 186 | |
187 | - $message = give_get_donation_notification_body_content( $payment_id, $payment_data ); |
|
187 | + $message = give_get_donation_notification_body_content($payment_id, $payment_data); |
|
188 | 188 | |
189 | 189 | $emails = Give()->emails; |
190 | - $emails->__set( 'from_name', $from_name ); |
|
191 | - $emails->__set( 'from_email', $from_email ); |
|
192 | - $emails->__set( 'headers', $headers ); |
|
193 | - $emails->__set( 'heading', esc_html__( 'New Donation!', 'give' ) ); |
|
190 | + $emails->__set('from_name', $from_name); |
|
191 | + $emails->__set('from_email', $from_email); |
|
192 | + $emails->__set('headers', $headers); |
|
193 | + $emails->__set('heading', esc_html__('New Donation!', 'give')); |
|
194 | 194 | |
195 | - $emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments ); |
|
195 | + $emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments); |
|
196 | 196 | |
197 | 197 | } |
198 | 198 | |
199 | -add_action( 'give_admin_sale_notice', 'give_admin_email_notice', 10, 2 ); |
|
199 | +add_action('give_admin_sale_notice', 'give_admin_email_notice', 10, 2); |
|
200 | 200 | |
201 | 201 | /** |
202 | 202 | * Retrieves the emails for which admin notifications are sent to (these can be changed in the Give Settings). |
@@ -208,10 +208,10 @@ discard block |
||
208 | 208 | |
209 | 209 | $email_option = give_get_option('admin_notice_emails'); |
210 | 210 | |
211 | - $emails = !empty( $email_option ) && strlen( trim( $email_option ) ) > 0 ? $email_option : get_bloginfo( 'admin_email' ); |
|
212 | - $emails = array_map( 'trim', explode( "\n", $emails ) ); |
|
211 | + $emails = ! empty($email_option) && strlen(trim($email_option)) > 0 ? $email_option : get_bloginfo('admin_email'); |
|
212 | + $emails = array_map('trim', explode("\n", $emails)); |
|
213 | 213 | |
214 | - return apply_filters( 'give_admin_notice_emails', $emails ); |
|
214 | + return apply_filters('give_admin_notice_emails', $emails); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -223,11 +223,11 @@ discard block |
||
223 | 223 | * |
224 | 224 | * @return mixed |
225 | 225 | */ |
226 | -function give_admin_notices_disabled( $payment_id = 0 ) { |
|
226 | +function give_admin_notices_disabled($payment_id = 0) { |
|
227 | 227 | |
228 | - $retval = give_get_option( 'disable_admin_notices' ); |
|
228 | + $retval = give_get_option('disable_admin_notices'); |
|
229 | 229 | |
230 | - return apply_filters( 'give_admin_notices_disabled', $retval, $payment_id ); |
|
230 | + return apply_filters('give_admin_notices_disabled', $retval, $payment_id); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -240,19 +240,19 @@ discard block |
||
240 | 240 | */ |
241 | 241 | function give_get_default_donation_notification_email() { |
242 | 242 | |
243 | - $default_email_body = esc_html__( 'Hi there,', 'give' ) . "\n\n"; |
|
244 | - $default_email_body .= esc_html__( 'This email is to inform you that a new donation has been made on your website:', 'give' ) . ' <a href="' . get_bloginfo( 'url' ) . '" target="_blank">' . get_bloginfo( 'url' ) . '</a>' . ".\n\n"; |
|
245 | - $default_email_body .= '<strong>' . esc_html__( 'Donor:', 'give' ) . '</strong> {name}' . "\n"; |
|
246 | - $default_email_body .= '<strong>' . esc_html__( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
247 | - $default_email_body .= '<strong>' . esc_html__( 'Amount:', 'give' ) . '</strong> {price}' . "\n"; |
|
248 | - $default_email_body .= '<strong>' . esc_html__( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n\n"; |
|
249 | - $default_email_body .= esc_html__( 'Thank you,', 'give' ) . "\n\n"; |
|
250 | - $default_email_body .= '{sitename}' . "\n"; |
|
243 | + $default_email_body = esc_html__('Hi there,', 'give')."\n\n"; |
|
244 | + $default_email_body .= esc_html__('This email is to inform you that a new donation has been made on your website:', 'give').' <a href="'.get_bloginfo('url').'" target="_blank">'.get_bloginfo('url').'</a>'.".\n\n"; |
|
245 | + $default_email_body .= '<strong>'.esc_html__('Donor:', 'give').'</strong> {name}'."\n"; |
|
246 | + $default_email_body .= '<strong>'.esc_html__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
247 | + $default_email_body .= '<strong>'.esc_html__('Amount:', 'give').'</strong> {price}'."\n"; |
|
248 | + $default_email_body .= '<strong>'.esc_html__('Payment Method:', 'give').'</strong> {payment_method}'."\n\n"; |
|
249 | + $default_email_body .= esc_html__('Thank you,', 'give')."\n\n"; |
|
250 | + $default_email_body .= '{sitename}'."\n"; |
|
251 | 251 | |
252 | - $custom_message = give_get_option( 'donation_notification' ); |
|
253 | - $message = ! empty( $custom_message ) ? $custom_message : $default_email_body; |
|
252 | + $custom_message = give_get_option('donation_notification'); |
|
253 | + $message = ! empty($custom_message) ? $custom_message : $default_email_body; |
|
254 | 254 | |
255 | - return apply_filters( 'give_default_donation_notification_email', $message ); |
|
255 | + return apply_filters('give_default_donation_notification_email', $message); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | |
@@ -266,25 +266,25 @@ discard block |
||
266 | 266 | */ |
267 | 267 | function give_get_default_donation_receipt_email() { |
268 | 268 | |
269 | - $default_email_body = esc_html__( 'Dear', 'give' ) . " {name},\n\n"; |
|
270 | - $default_email_body .= esc_html__( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n"; |
|
271 | - $default_email_body .= '<strong>' . esc_html__( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
272 | - $default_email_body .= '<strong>' . esc_html__( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
273 | - $default_email_body .= '<strong>' . esc_html__( 'Donation Date:', 'give' ) . '</strong> {date}' . "\n"; |
|
274 | - $default_email_body .= '<strong>' . esc_html__( 'Amount:', 'give' ) . '</strong> {price}' . "\n"; |
|
275 | - $default_email_body .= '<strong>' . esc_html__( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n"; |
|
276 | - $default_email_body .= '<strong>' . esc_html__( 'Payment ID:', 'give' ) . '</strong> {payment_id}' . "\n"; |
|
277 | - $default_email_body .= '<strong>' . esc_html__( 'Receipt ID:', 'give' ) . '</strong> {receipt_id}' . "\n\n"; |
|
278 | - $default_email_body .= '{receipt_link}' . "\n\n"; |
|
269 | + $default_email_body = esc_html__('Dear', 'give')." {name},\n\n"; |
|
270 | + $default_email_body .= esc_html__('Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give')."\n\n"; |
|
271 | + $default_email_body .= '<strong>'.esc_html__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
272 | + $default_email_body .= '<strong>'.esc_html__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
273 | + $default_email_body .= '<strong>'.esc_html__('Donation Date:', 'give').'</strong> {date}'."\n"; |
|
274 | + $default_email_body .= '<strong>'.esc_html__('Amount:', 'give').'</strong> {price}'."\n"; |
|
275 | + $default_email_body .= '<strong>'.esc_html__('Payment Method:', 'give').'</strong> {payment_method}'."\n"; |
|
276 | + $default_email_body .= '<strong>'.esc_html__('Payment ID:', 'give').'</strong> {payment_id}'."\n"; |
|
277 | + $default_email_body .= '<strong>'.esc_html__('Receipt ID:', 'give').'</strong> {receipt_id}'."\n\n"; |
|
278 | + $default_email_body .= '{receipt_link}'."\n\n"; |
|
279 | 279 | $default_email_body .= "\n\n"; |
280 | - $default_email_body .= esc_html__( 'Sincerely,', 'give' ) . "\n"; |
|
281 | - $default_email_body .= '{sitename}' . "\n"; |
|
280 | + $default_email_body .= esc_html__('Sincerely,', 'give')."\n"; |
|
281 | + $default_email_body .= '{sitename}'."\n"; |
|
282 | 282 | |
283 | - $custom_message = give_get_option( 'donation_receipt' ); |
|
283 | + $custom_message = give_get_option('donation_receipt'); |
|
284 | 284 | |
285 | - $message = ! empty( $custom_message ) ? $custom_message : $default_email_body; |
|
285 | + $message = ! empty($custom_message) ? $custom_message : $default_email_body; |
|
286 | 286 | |
287 | - return apply_filters( 'give_default_donation_receipt_email', $message ); |
|
287 | + return apply_filters('give_default_donation_receipt_email', $message); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -296,19 +296,19 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @return array $email_names |
298 | 298 | */ |
299 | -function give_get_email_names( $user_info ) { |
|
299 | +function give_get_email_names($user_info) { |
|
300 | 300 | $email_names = array(); |
301 | - $user_info = maybe_unserialize( $user_info ); |
|
301 | + $user_info = maybe_unserialize($user_info); |
|
302 | 302 | |
303 | 303 | $email_names['fullname'] = ''; |
304 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) { |
|
305 | - $user_data = get_userdata( $user_info['id'] ); |
|
304 | + if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) { |
|
305 | + $user_data = get_userdata($user_info['id']); |
|
306 | 306 | $email_names['name'] = $user_info['first_name']; |
307 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
307 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
308 | 308 | $email_names['username'] = $user_data->user_login; |
309 | - } elseif ( isset( $user_info['first_name'] ) ) { |
|
309 | + } elseif (isset($user_info['first_name'])) { |
|
310 | 310 | $email_names['name'] = $user_info['first_name']; |
311 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
311 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
312 | 312 | $email_names['username'] = $user_info['first_name']; |
313 | 313 | } else { |
314 | 314 | $email_names['name'] = $user_info['email']; |
@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return array |
20 | 20 | */ |
21 | -function give_offline_register_gateway( $gateways ) { |
|
21 | +function give_offline_register_gateway($gateways) { |
|
22 | 22 | // Format: ID => Name |
23 | 23 | $gateways['offline'] = array( |
24 | - 'admin_label' => esc_attr__( 'Offline Donation', 'give' ), |
|
25 | - 'checkout_label' => esc_attr__( 'Offline Donation', 'give' ) |
|
24 | + 'admin_label' => esc_attr__('Offline Donation', 'give'), |
|
25 | + 'checkout_label' => esc_attr__('Offline Donation', 'give') |
|
26 | 26 | ); |
27 | 27 | |
28 | 28 | return $gateways; |
29 | 29 | } |
30 | 30 | |
31 | -add_filter( 'give_donation_gateways', 'give_offline_register_gateway', 1 ); |
|
31 | +add_filter('give_donation_gateways', 'give_offline_register_gateway', 1); |
|
32 | 32 | |
33 | 33 | |
34 | 34 | /** |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return void |
42 | 42 | */ |
43 | -function give_offline_payment_cc_form( $form_id ) { |
|
43 | +function give_offline_payment_cc_form($form_id) { |
|
44 | 44 | |
45 | - $post_offline_customization_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
46 | - $post_offline_instructions = get_post_meta( $form_id, '_give_offline_checkout_notes', true ); |
|
47 | - $global_offline_instruction = give_get_option( 'global_offline_donation_content' ); |
|
45 | + $post_offline_customization_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
46 | + $post_offline_instructions = get_post_meta($form_id, '_give_offline_checkout_notes', true); |
|
47 | + $global_offline_instruction = give_get_option('global_offline_donation_content'); |
|
48 | 48 | $offline_instructions = $global_offline_instruction; |
49 | 49 | |
50 | - if ( $post_offline_customization_option == 'yes' ) { |
|
50 | + if ($post_offline_customization_option == 'yes') { |
|
51 | 51 | $offline_instructions = $post_offline_instructions; |
52 | 52 | } |
53 | 53 | |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @param int $form_id Give form id. |
62 | 62 | */ |
63 | - do_action( 'give_before_offline_info_fields', $form_id ); |
|
63 | + do_action('give_before_offline_info_fields', $form_id); |
|
64 | 64 | ?> |
65 | 65 | <fieldset id="give_offline_payment_info"> |
66 | 66 | <?php |
67 | - $settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' ); |
|
67 | + $settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1'); |
|
68 | 68 | /* translators: %s: form settings url */ |
69 | - $offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( __( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), $settings_url ); |
|
70 | - echo wpautop( stripslashes( $offline_instructions ) ); |
|
69 | + $offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(__('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), $settings_url); |
|
70 | + echo wpautop(stripslashes($offline_instructions)); |
|
71 | 71 | ?> |
72 | 72 | </fieldset> |
73 | 73 | <?php |
@@ -78,34 +78,34 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @param int $form_id Give form id. |
80 | 80 | */ |
81 | - do_action( 'give_after_offline_info_fields', $form_id ); |
|
81 | + do_action('give_after_offline_info_fields', $form_id); |
|
82 | 82 | |
83 | 83 | echo ob_get_clean(); |
84 | 84 | } |
85 | 85 | |
86 | -add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' ); |
|
86 | +add_action('give_offline_cc_form', 'give_offline_payment_cc_form'); |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * Give Offline Billing Field |
90 | 90 | * |
91 | 91 | * @param $form_id |
92 | 92 | */ |
93 | -function give_offline_billing_fields( $form_id ) { |
|
93 | +function give_offline_billing_fields($form_id) { |
|
94 | 94 | //Enable Default CC fields (billing info) |
95 | - $post_offline_cc_fields = get_post_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true ); |
|
96 | - $post_offline_customize_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
95 | + $post_offline_cc_fields = get_post_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true); |
|
96 | + $post_offline_customize_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
97 | 97 | |
98 | - $global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' ); |
|
98 | + $global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields'); |
|
99 | 99 | |
100 | 100 | //Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options |
101 | - if ( $global_offline_cc_fields == 'on' && $post_offline_customize_option !== 'yes' ) { |
|
102 | - give_default_cc_address_fields( $form_id ); |
|
103 | - } elseif($post_offline_customize_option == 'yes' && $post_offline_cc_fields == 'on') { |
|
104 | - give_default_cc_address_fields( $form_id ); |
|
101 | + if ($global_offline_cc_fields == 'on' && $post_offline_customize_option !== 'yes') { |
|
102 | + give_default_cc_address_fields($form_id); |
|
103 | + } elseif ($post_offline_customize_option == 'yes' && $post_offline_cc_fields == 'on') { |
|
104 | + give_default_cc_address_fields($form_id); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
108 | -add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 ); |
|
108 | +add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1); |
|
109 | 109 | |
110 | 110 | /** |
111 | 111 | * Process the payment |
@@ -116,16 +116,16 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @return void |
118 | 118 | */ |
119 | -function give_offline_process_payment( $purchase_data ) { |
|
119 | +function give_offline_process_payment($purchase_data) { |
|
120 | 120 | |
121 | - $purchase_summary = give_get_purchase_summary( $purchase_data ); |
|
121 | + $purchase_summary = give_get_purchase_summary($purchase_data); |
|
122 | 122 | |
123 | 123 | // setup the payment details |
124 | 124 | $payment_data = array( |
125 | 125 | 'price' => $purchase_data['price'], |
126 | 126 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
127 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
128 | - 'give_price_id' => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '', |
|
127 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
128 | + 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
|
129 | 129 | 'date' => $purchase_data['date'], |
130 | 130 | 'user_email' => $purchase_data['user_email'], |
131 | 131 | 'purchase_key' => $purchase_data['purchase_key'], |
@@ -137,20 +137,20 @@ discard block |
||
137 | 137 | |
138 | 138 | |
139 | 139 | // record the pending payment |
140 | - $payment = give_insert_payment( $payment_data ); |
|
140 | + $payment = give_insert_payment($payment_data); |
|
141 | 141 | |
142 | - if ( $payment ) { |
|
143 | - give_offline_send_admin_notice( $payment ); |
|
144 | - give_offline_send_donor_instructions( $payment ); |
|
142 | + if ($payment) { |
|
143 | + give_offline_send_admin_notice($payment); |
|
144 | + give_offline_send_donor_instructions($payment); |
|
145 | 145 | give_send_to_success_page(); |
146 | 146 | } else { |
147 | 147 | // if errors are present, send the user back to the donation form so they can be corrected |
148 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
148 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | } |
152 | 152 | |
153 | -add_action( 'give_gateway_offline', 'give_offline_process_payment' ); |
|
153 | +add_action('give_gateway_offline', 'give_offline_process_payment'); |
|
154 | 154 | |
155 | 155 | |
156 | 156 | /** |
@@ -163,59 +163,59 @@ discard block |
||
163 | 163 | * @since 1.0 |
164 | 164 | * @return void |
165 | 165 | */ |
166 | -function give_offline_send_donor_instructions( $payment_id = 0 ) { |
|
166 | +function give_offline_send_donor_instructions($payment_id = 0) { |
|
167 | 167 | |
168 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
169 | - $post_offline_customization_option = get_post_meta( $payment_data['form_id'], '_give_customize_offline_donations', true ); |
|
168 | + $payment_data = give_get_payment_meta($payment_id); |
|
169 | + $post_offline_customization_option = get_post_meta($payment_data['form_id'], '_give_customize_offline_donations', true); |
|
170 | 170 | |
171 | 171 | //Customize email content depending on whether the single form has been customized |
172 | - $email_content = give_get_option( 'global_offline_donation_email' ); |
|
172 | + $email_content = give_get_option('global_offline_donation_email'); |
|
173 | 173 | |
174 | - if ( $post_offline_customization_option === 'yes' ) { |
|
175 | - $email_content = get_post_meta( $payment_data['form_id'], '_give_offline_donation_email', true ); |
|
174 | + if ($post_offline_customization_option === 'yes') { |
|
175 | + $email_content = get_post_meta($payment_data['form_id'], '_give_offline_donation_email', true); |
|
176 | 176 | } |
177 | 177 | |
178 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
178 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
179 | 179 | |
180 | 180 | /** |
181 | 181 | * Filters the from name. |
182 | 182 | * |
183 | 183 | * @since 1.7 |
184 | 184 | */ |
185 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
185 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
186 | 186 | |
187 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
187 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
188 | 188 | |
189 | 189 | /** |
190 | 190 | * Filters the from email. |
191 | 191 | * |
192 | 192 | * @since 1.7 |
193 | 193 | */ |
194 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
194 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
195 | 195 | |
196 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
196 | + $to_email = give_get_payment_user_email($payment_id); |
|
197 | 197 | |
198 | - $subject = give_get_option( 'offline_donation_subject', esc_html__( 'Offline Donation Instructions', 'give' ) ); |
|
199 | - if ( $post_offline_customization_option === 'yes' ) { |
|
200 | - $subject = get_post_meta( $payment_data['form_id'], '_give_offline_donation_subject', true ); |
|
198 | + $subject = give_get_option('offline_donation_subject', esc_html__('Offline Donation Instructions', 'give')); |
|
199 | + if ($post_offline_customization_option === 'yes') { |
|
200 | + $subject = get_post_meta($payment_data['form_id'], '_give_offline_donation_subject', true); |
|
201 | 201 | } |
202 | 202 | |
203 | - $subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
204 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
203 | + $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
204 | + $subject = give_do_email_tags($subject, $payment_id); |
|
205 | 205 | |
206 | - $attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data ); |
|
207 | - $message = give_do_email_tags( $email_content, $payment_id ); |
|
206 | + $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data); |
|
207 | + $message = give_do_email_tags($email_content, $payment_id); |
|
208 | 208 | |
209 | 209 | $emails = Give()->emails; |
210 | 210 | |
211 | - $emails->__set( 'from_name', $from_name ); |
|
212 | - $emails->__set( 'from_email', $from_email ); |
|
213 | - $emails->__set( 'heading', esc_html__( 'Offline Donation Instructions', 'give' ) ); |
|
211 | + $emails->__set('from_name', $from_name); |
|
212 | + $emails->__set('from_email', $from_email); |
|
213 | + $emails->__set('heading', esc_html__('Offline Donation Instructions', 'give')); |
|
214 | 214 | |
215 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
216 | - $emails->__set( 'headers', $headers ); |
|
215 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
216 | + $emails->__set('headers', $headers); |
|
217 | 217 | |
218 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
218 | + $emails->send($to_email, $subject, $message, $attachments); |
|
219 | 219 | |
220 | 220 | } |
221 | 221 | |
@@ -232,52 +232,52 @@ discard block |
||
232 | 232 | * @return void |
233 | 233 | * |
234 | 234 | */ |
235 | -function give_offline_send_admin_notice( $payment_id = 0 ) { |
|
235 | +function give_offline_send_admin_notice($payment_id = 0) { |
|
236 | 236 | |
237 | 237 | /* Send an email notification to the admin */ |
238 | 238 | $admin_email = give_get_admin_notice_emails(); |
239 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
239 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
240 | 240 | |
241 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
242 | - $user_data = get_userdata( $user_info['id'] ); |
|
241 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
242 | + $user_data = get_userdata($user_info['id']); |
|
243 | 243 | $name = $user_data->display_name; |
244 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
245 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
244 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
245 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
246 | 246 | } else { |
247 | 247 | $name = $user_info['email']; |
248 | 248 | } |
249 | 249 | |
250 | - $amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ); |
|
250 | + $amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))); |
|
251 | 251 | |
252 | - $admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', esc_attr__( 'New Pending Donation', 'give' ), $payment_id ); |
|
252 | + $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', esc_attr__('New Pending Donation', 'give'), $payment_id); |
|
253 | 253 | |
254 | - $admin_message = esc_attr__( 'Dear Admin,', 'give' ) . "\n\n"; |
|
255 | - $admin_message .= esc_attr__( 'An offline donation has been made on your website:', 'give' ) . ' ' . get_bloginfo( 'name' ) . ' '; |
|
256 | - $admin_message .= esc_attr__( 'Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n"; |
|
254 | + $admin_message = esc_attr__('Dear Admin,', 'give')."\n\n"; |
|
255 | + $admin_message .= esc_attr__('An offline donation has been made on your website:', 'give').' '.get_bloginfo('name').' '; |
|
256 | + $admin_message .= esc_attr__('Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n"; |
|
257 | 257 | |
258 | 258 | |
259 | - $admin_message .= '<strong>' . esc_attr__( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
260 | - $admin_message .= '<strong>' . esc_attr__( 'Amount:', 'give' ) . '</strong> {price}' . "\n\n"; |
|
259 | + $admin_message .= '<strong>'.esc_attr__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
260 | + $admin_message .= '<strong>'.esc_attr__('Amount:', 'give').'</strong> {price}'."\n\n"; |
|
261 | 261 | |
262 | 262 | $admin_message .= sprintf( |
263 | 263 | '<a href="%1$s">%2$s</a>', |
264 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ), |
|
265 | - esc_html__( 'Click Here to View and/or Update Donation Details', 'give' ) |
|
266 | - ) . "\n\n"; |
|
264 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment_id), |
|
265 | + esc_html__('Click Here to View and/or Update Donation Details', 'give') |
|
266 | + )."\n\n"; |
|
267 | 267 | |
268 | - $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
|
269 | - $admin_message = give_do_email_tags( $admin_message, $payment_id ); |
|
268 | + $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id); |
|
269 | + $admin_message = give_do_email_tags($admin_message, $payment_id); |
|
270 | 270 | |
271 | - $attachments = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id ); |
|
272 | - $admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id ); |
|
271 | + $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id); |
|
272 | + $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id); |
|
273 | 273 | |
274 | 274 | //Send Email |
275 | 275 | $emails = Give()->emails; |
276 | - if ( ! empty( $admin_headers ) ) { |
|
277 | - $emails->__set( 'headers', $admin_headers ); |
|
276 | + if ( ! empty($admin_headers)) { |
|
277 | + $emails->__set('headers', $admin_headers); |
|
278 | 278 | } |
279 | 279 | |
280 | - $emails->send( $admin_email, $admin_subject, $admin_message, $attachments ); |
|
280 | + $emails->send($admin_email, $admin_subject, $admin_message, $attachments); |
|
281 | 281 | |
282 | 282 | } |
283 | 283 | |
@@ -288,15 +288,15 @@ discard block |
||
288 | 288 | * @since 1.0 |
289 | 289 | * @return array |
290 | 290 | */ |
291 | -function give_offline_add_settings( $settings ) { |
|
291 | +function give_offline_add_settings($settings) { |
|
292 | 292 | |
293 | 293 | //Vars |
294 | 294 | $prefix = '_give_'; |
295 | 295 | |
296 | - $is_gateway_active = give_is_gateway_active( 'offline' ); |
|
296 | + $is_gateway_active = give_is_gateway_active('offline'); |
|
297 | 297 | |
298 | 298 | //this gateway isn't active |
299 | - if ( ! $is_gateway_active ) { |
|
299 | + if ( ! $is_gateway_active) { |
|
300 | 300 | //return settings and bounce |
301 | 301 | return $settings; |
302 | 302 | } |
@@ -305,27 +305,27 @@ discard block |
||
305 | 305 | $check_settings = array( |
306 | 306 | |
307 | 307 | array( |
308 | - 'name' => esc_attr__( 'Customize Offline Donations', 'give' ), |
|
309 | - 'desc' => esc_attr__( 'If you would like to customize the donation instructions for this specific forms check this option.', 'give' ), |
|
310 | - 'id' => $prefix . 'customize_offline_donations', |
|
308 | + 'name' => esc_attr__('Customize Offline Donations', 'give'), |
|
309 | + 'desc' => esc_attr__('If you would like to customize the donation instructions for this specific forms check this option.', 'give'), |
|
310 | + 'id' => $prefix.'customize_offline_donations', |
|
311 | 311 | 'type' => 'radio_inline', |
312 | 312 | 'default' => 'no', |
313 | 313 | 'options' => array( |
314 | - 'yes' => esc_attr__( 'Yes', 'give' ), |
|
315 | - 'no' => esc_attr__( 'No', 'give' ), |
|
314 | + 'yes' => esc_attr__('Yes', 'give'), |
|
315 | + 'no' => esc_attr__('No', 'give'), |
|
316 | 316 | ), |
317 | 317 | ), |
318 | 318 | array( |
319 | - 'name' => esc_attr__( 'Request Billing Information', 'give' ), |
|
320 | - 'desc' => esc_attr__( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ), |
|
321 | - 'id' => $prefix . 'offline_donation_enable_billing_fields_single', |
|
319 | + 'name' => esc_attr__('Request Billing Information', 'give'), |
|
320 | + 'desc' => esc_attr__('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'), |
|
321 | + 'id' => $prefix.'offline_donation_enable_billing_fields_single', |
|
322 | 322 | 'row_classes' => 'give-subfield', |
323 | 323 | 'type' => 'checkbox' |
324 | 324 | ), |
325 | 325 | array( |
326 | - 'id' => $prefix . 'offline_checkout_notes', |
|
327 | - 'name' => esc_attr__( 'Offline Donation Instructions', 'give' ), |
|
328 | - 'desc' => esc_attr__( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
326 | + 'id' => $prefix.'offline_checkout_notes', |
|
327 | + 'name' => esc_attr__('Offline Donation Instructions', 'give'), |
|
328 | + 'desc' => esc_attr__('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
329 | 329 | 'default' => give_get_default_offline_donation_content(), |
330 | 330 | 'type' => 'wysiwyg', |
331 | 331 | 'row_classes' => 'give-subfield', |
@@ -334,17 +334,17 @@ discard block |
||
334 | 334 | ) |
335 | 335 | ), |
336 | 336 | array( |
337 | - 'id' => $prefix . 'offline_donation_subject', |
|
338 | - 'name' => esc_attr__( 'Offline Donation Email Instructions Subject', 'give' ), |
|
339 | - 'desc' => esc_attr__( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
340 | - 'default' => esc_attr__( '{donation} - Offline Donation Instructions', 'give' ), |
|
337 | + 'id' => $prefix.'offline_donation_subject', |
|
338 | + 'name' => esc_attr__('Offline Donation Email Instructions Subject', 'give'), |
|
339 | + 'desc' => esc_attr__('Enter the subject line for the donation receipt email.', 'give'), |
|
340 | + 'default' => esc_attr__('{donation} - Offline Donation Instructions', 'give'), |
|
341 | 341 | 'row_classes' => 'give-subfield', |
342 | 342 | 'type' => 'text' |
343 | 343 | ), |
344 | 344 | array( |
345 | - 'id' => $prefix . 'offline_donation_email', |
|
346 | - 'name' => esc_attr__( 'Offline Donation Email Instructions', 'give' ), |
|
347 | - 'desc' => esc_attr__( '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' ), |
|
345 | + 'id' => $prefix.'offline_donation_email', |
|
346 | + 'name' => esc_attr__('Offline Donation Email Instructions', 'give'), |
|
347 | + 'desc' => esc_attr__('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'), |
|
348 | 348 | 'default' => give_get_default_offline_donation_email_content(), |
349 | 349 | 'type' => 'wysiwyg', |
350 | 350 | 'row_classes' => 'give-subfield', |
@@ -354,10 +354,10 @@ discard block |
||
354 | 354 | ) |
355 | 355 | ); |
356 | 356 | |
357 | - return array_merge( $settings, $check_settings ); |
|
357 | + return array_merge($settings, $check_settings); |
|
358 | 358 | } |
359 | 359 | |
360 | -add_filter( 'give_forms_display_options_metabox_fields', 'give_offline_add_settings' ); |
|
360 | +add_filter('give_forms_display_options_metabox_fields', 'give_offline_add_settings'); |
|
361 | 361 | |
362 | 362 | |
363 | 363 | /** |
@@ -369,32 +369,32 @@ discard block |
||
369 | 369 | */ |
370 | 370 | function give_get_default_offline_donation_content() { |
371 | 371 | |
372 | - $sitename = get_bloginfo( 'sitename' ); |
|
372 | + $sitename = get_bloginfo('sitename'); |
|
373 | 373 | |
374 | - $default_text = '<p>' . esc_attr__( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
374 | + $default_text = '<p>'.esc_attr__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
375 | 375 | $default_text .= '<ol>'; |
376 | 376 | $default_text .= '<li>'; |
377 | 377 | $default_text .= sprintf( |
378 | 378 | /* translators: %s: site name */ |
379 | - esc_html__( 'Make a check payable to "%s"', 'give' ), |
|
379 | + esc_html__('Make a check payable to "%s"', 'give'), |
|
380 | 380 | $sitename |
381 | 381 | ); |
382 | 382 | $default_text .= '</li>'; |
383 | 383 | $default_text .= '<li>'; |
384 | 384 | $default_text .= sprintf( |
385 | 385 | /* translators: %s: site name */ |
386 | - esc_html__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
386 | + esc_html__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
387 | 387 | $sitename |
388 | 388 | ); |
389 | 389 | $default_text .= '</li>'; |
390 | - $default_text .= '<li>' . esc_html__( 'Please mail your check to:', 'give' ) . '</li>'; |
|
390 | + $default_text .= '<li>'.esc_html__('Please mail your check to:', 'give').'</li>'; |
|
391 | 391 | $default_text .= '</ol>'; |
392 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
392 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
393 | 393 | $default_text .= ' <em>123 G Street </em><br>'; |
394 | 394 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
395 | - $default_text .= '<p>' . esc_attr__( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>'; |
|
395 | + $default_text .= '<p>'.esc_attr__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>'; |
|
396 | 396 | |
397 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
397 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
398 | 398 | |
399 | 399 | } |
400 | 400 | |
@@ -407,33 +407,33 @@ discard block |
||
407 | 407 | */ |
408 | 408 | function give_get_default_offline_donation_email_content() { |
409 | 409 | |
410 | - $sitename = get_bloginfo( 'sitename' ); |
|
411 | - $default_text = '<p>' . esc_html__( 'Dear {name},', 'give' ) . '</p>'; |
|
412 | - $default_text .= '<p>' . esc_html__( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give' ) . '</p>'; |
|
410 | + $sitename = get_bloginfo('sitename'); |
|
411 | + $default_text = '<p>'.esc_html__('Dear {name},', 'give').'</p>'; |
|
412 | + $default_text .= '<p>'.esc_html__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give').'</p>'; |
|
413 | 413 | $default_text .= '<ol>'; |
414 | 414 | $default_text .= '<li>'; |
415 | 415 | $default_text .= sprintf( |
416 | 416 | /* translators: %s: site name */ |
417 | - esc_html__( 'Make a check payable to "%s"', 'give' ), |
|
417 | + esc_html__('Make a check payable to "%s"', 'give'), |
|
418 | 418 | $sitename |
419 | 419 | ); |
420 | 420 | $default_text .= '</li>'; |
421 | 421 | $default_text .= '<li>'; |
422 | 422 | $default_text .= sprintf( |
423 | 423 | /* translators: %s: site name */ |
424 | - esc_html__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
424 | + esc_html__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
425 | 425 | $sitename |
426 | 426 | ); |
427 | 427 | $default_text .= '</li>'; |
428 | - $default_text .= '<li>' . esc_html__( 'Please mail your check to:', 'give' ) . '</li>'; |
|
428 | + $default_text .= '<li>'.esc_html__('Please mail your check to:', 'give').'</li>'; |
|
429 | 429 | $default_text .= '</ol>'; |
430 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
430 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
431 | 431 | $default_text .= ' <em>123 G Street </em><br>'; |
432 | 432 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
433 | - $default_text .= '<p>' . esc_html__( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>'; |
|
434 | - $default_text .= '<p>' . esc_html__( 'Sincerely,', 'give' ) . '</p>'; |
|
435 | - $default_text .= '<p>' . $sitename . '</p>'; |
|
433 | + $default_text .= '<p>'.esc_html__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>'; |
|
434 | + $default_text .= '<p>'.esc_html__('Sincerely,', 'give').'</p>'; |
|
435 | + $default_text .= '<p>'.$sitename.'</p>'; |
|
436 | 436 | |
437 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
437 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
438 | 438 | |
439 | 439 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param $data |
23 | 23 | */ |
24 | -function give_process_gateway_select( $data ) { |
|
25 | - if ( isset( $_POST['gateway_submit'] ) ) { |
|
26 | - wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) ); |
|
24 | +function give_process_gateway_select($data) { |
|
25 | + if (isset($_POST['gateway_submit'])) { |
|
26 | + wp_redirect(esc_url(add_query_arg('payment-mode', $_POST['payment-mode']))); |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | -add_action( 'give_gateway_select', 'give_process_gateway_select' ); |
|
31 | +add_action('give_gateway_select', 'give_process_gateway_select'); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Loads a payment gateway via AJAX |
@@ -38,20 +38,20 @@ discard block |
||
38 | 38 | * @return void |
39 | 39 | */ |
40 | 40 | function give_load_ajax_gateway() { |
41 | - if ( isset( $_POST['give_payment_mode'] ) ) { |
|
41 | + if (isset($_POST['give_payment_mode'])) { |
|
42 | 42 | /** |
43 | 43 | * Fire to render donation form. |
44 | 44 | * |
45 | 45 | * @since 1.7 |
46 | 46 | */ |
47 | - do_action( 'give_donation_form', $_POST['give_form_id'] ); |
|
47 | + do_action('give_donation_form', $_POST['give_form_id']); |
|
48 | 48 | |
49 | 49 | exit(); |
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | -add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' ); |
|
54 | -add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' ); |
|
53 | +add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway'); |
|
54 | +add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway'); |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Sets an error on checkout if no gateways are enabled |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | function give_no_gateway_error() { |
64 | 64 | $gateways = give_get_enabled_payment_gateways(); |
65 | 65 | |
66 | - if ( empty( $gateways ) ) { |
|
67 | - give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) ); |
|
66 | + if (empty($gateways)) { |
|
67 | + give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give')); |
|
68 | 68 | } else { |
69 | - give_unset_error( 'no_gateways' ); |
|
69 | + give_unset_error('no_gateways'); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | -add_action( 'init', 'give_no_gateway_error' ); |
|
73 | +add_action('init', 'give_no_gateway_error'); |
@@ -10,7 +10,7 @@ discard block |
||
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 | |
@@ -38,35 +38,35 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return float|int Total amount of donations based on the passed arguments. |
40 | 40 | */ |
41 | - public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) { |
|
41 | + public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') { |
|
42 | 42 | |
43 | - $this->setup_dates( $start_date, $end_date ); |
|
43 | + $this->setup_dates($start_date, $end_date); |
|
44 | 44 | |
45 | 45 | // Make sure start date is valid |
46 | - if ( is_wp_error( $this->start_date ) ) { |
|
46 | + if (is_wp_error($this->start_date)) { |
|
47 | 47 | return $this->start_date; |
48 | 48 | } |
49 | 49 | |
50 | 50 | // Make sure end date is valid |
51 | - if ( is_wp_error( $this->end_date ) ) { |
|
51 | + if (is_wp_error($this->end_date)) { |
|
52 | 52 | return $this->end_date; |
53 | 53 | } |
54 | 54 | |
55 | - if ( empty( $form_id ) ) { |
|
55 | + if (empty($form_id)) { |
|
56 | 56 | |
57 | 57 | // Global sale stats |
58 | - add_filter( 'give_count_payments_where', array( $this, 'count_where' ) ); |
|
58 | + add_filter('give_count_payments_where', array($this, 'count_where')); |
|
59 | 59 | |
60 | - if ( is_array( $status ) ) { |
|
60 | + if (is_array($status)) { |
|
61 | 61 | $count = 0; |
62 | - foreach ( $status as $payment_status ) { |
|
62 | + foreach ($status as $payment_status) { |
|
63 | 63 | $count += give_count_payments()->$payment_status; |
64 | 64 | } |
65 | 65 | } else { |
66 | 66 | $count = give_count_payments()->$status; |
67 | 67 | } |
68 | 68 | |
69 | - remove_filter( 'give_count_payments_where', array( $this, 'count_where' ) ); |
|
69 | + remove_filter('give_count_payments_where', array($this, 'count_where')); |
|
70 | 70 | |
71 | 71 | } else { |
72 | 72 | |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | // Product specific stats |
76 | 76 | global $give_logs; |
77 | 77 | |
78 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
78 | + add_filter('posts_where', array($this, 'payments_where')); |
|
79 | 79 | |
80 | - $count = $give_logs->get_log_count( $form_id, 'sale' ); |
|
80 | + $count = $give_logs->get_log_count($form_id, 'sale'); |
|
81 | 81 | |
82 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
82 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
83 | 83 | |
84 | 84 | } |
85 | 85 | |
@@ -101,31 +101,31 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return float|int Total amount of donations based on the passed arguments. |
103 | 103 | */ |
104 | - public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
|
104 | + public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) { |
|
105 | 105 | |
106 | 106 | global $wpdb; |
107 | 107 | |
108 | - $this->setup_dates( $start_date, $end_date ); |
|
108 | + $this->setup_dates($start_date, $end_date); |
|
109 | 109 | |
110 | 110 | // Make sure start date is valid |
111 | - if ( is_wp_error( $this->start_date ) ) { |
|
111 | + if (is_wp_error($this->start_date)) { |
|
112 | 112 | return $this->start_date; |
113 | 113 | } |
114 | 114 | |
115 | 115 | // Make sure end date is valid |
116 | - if ( is_wp_error( $this->end_date ) ) { |
|
116 | + if (is_wp_error($this->end_date)) { |
|
117 | 117 | return $this->end_date; |
118 | 118 | } |
119 | 119 | |
120 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
120 | + add_filter('posts_where', array($this, 'payments_where')); |
|
121 | 121 | |
122 | - if ( empty( $form_id ) ) { |
|
122 | + if (empty($form_id)) { |
|
123 | 123 | |
124 | 124 | // Global earning stats |
125 | 125 | $args = array( |
126 | 126 | 'post_type' => 'give_payment', |
127 | 127 | 'nopaging' => true, |
128 | - 'post_status' => array( 'publish' ), |
|
128 | + 'post_status' => array('publish'), |
|
129 | 129 | 'fields' => 'ids', |
130 | 130 | 'update_post_term_cache' => false, |
131 | 131 | 'suppress_filters' => false, |
@@ -137,24 +137,24 @@ discard block |
||
137 | 137 | ); |
138 | 138 | |
139 | 139 | //Filter by Gateway ID meta_key |
140 | - if ( $gateway_id !== false ) { |
|
140 | + if ($gateway_id !== false) { |
|
141 | 141 | $args['meta_key'] = '_give_payment_gateway'; |
142 | 142 | $args['meta_value'] = $gateway_id; |
143 | 143 | } |
144 | 144 | |
145 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
146 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
147 | - $earnings = get_transient( $key ); |
|
145 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
146 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
147 | + $earnings = get_transient($key); |
|
148 | 148 | |
149 | - if ( false === $earnings ) { |
|
150 | - $sales = get_posts( $args ); |
|
149 | + if (false === $earnings) { |
|
150 | + $sales = get_posts($args); |
|
151 | 151 | $earnings = 0; |
152 | - if ( $sales ) { |
|
153 | - $sales = implode( ',', array_map('intval', $sales ) ); |
|
154 | - $earnings += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})" ); |
|
152 | + if ($sales) { |
|
153 | + $sales = implode(',', array_map('intval', $sales)); |
|
154 | + $earnings += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})"); |
|
155 | 155 | } |
156 | 156 | // Cache the results for one hour |
157 | - set_transient( $key, $earnings, HOUR_IN_SECONDS ); |
|
157 | + set_transient($key, $earnings, HOUR_IN_SECONDS); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | } else { |
@@ -174,37 +174,37 @@ discard block |
||
174 | 174 | 'give_transient_type' => 'give_earnings', |
175 | 175 | // This is not a valid query arg, but is used for cache keying |
176 | 176 | ); |
177 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
178 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
177 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
178 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
179 | 179 | //Set transient for faster stats |
180 | - $earnings = get_transient( $key ); |
|
180 | + $earnings = get_transient($key); |
|
181 | 181 | |
182 | - if ( false === $earnings ) { |
|
182 | + if (false === $earnings) { |
|
183 | 183 | |
184 | 184 | $this->timestamp = false; |
185 | - $log_ids = $give_logs->get_connected_logs( $args, 'sale' ); |
|
185 | + $log_ids = $give_logs->get_connected_logs($args, 'sale'); |
|
186 | 186 | $earnings = 0; |
187 | 187 | |
188 | - if ( $log_ids ) { |
|
189 | - $log_ids = implode( ',', array_map('intval', $log_ids ) ); |
|
190 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);" ); |
|
188 | + if ($log_ids) { |
|
189 | + $log_ids = implode(',', array_map('intval', $log_ids)); |
|
190 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);"); |
|
191 | 191 | |
192 | - foreach ( $payment_ids as $payment_id ) { |
|
193 | - $earnings += give_get_payment_amount( $payment_id ); |
|
192 | + foreach ($payment_ids as $payment_id) { |
|
193 | + $earnings += give_get_payment_amount($payment_id); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | } |
197 | 197 | |
198 | 198 | // Cache the results for one hour |
199 | - set_transient( $key, $earnings, 60 * 60 ); |
|
199 | + set_transient($key, $earnings, 60 * 60); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | 203 | //remove our filter |
204 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
204 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
205 | 205 | |
206 | 206 | //return earnings |
207 | - return round( $earnings, give_currency_decimal_filter() ); |
|
207 | + return round($earnings, give_currency_decimal_filter()); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
@@ -221,29 +221,29 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return float|int Total amount of donations based on the passed arguments. |
223 | 223 | */ |
224 | - public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
|
224 | + public function get_earnings_cache_key($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) { |
|
225 | 225 | |
226 | - $this->setup_dates( $start_date, $end_date ); |
|
226 | + $this->setup_dates($start_date, $end_date); |
|
227 | 227 | |
228 | 228 | // Make sure start date is valid |
229 | - if ( is_wp_error( $this->start_date ) ) { |
|
229 | + if (is_wp_error($this->start_date)) { |
|
230 | 230 | return $this->start_date; |
231 | 231 | } |
232 | 232 | |
233 | 233 | // Make sure end date is valid |
234 | - if ( is_wp_error( $this->end_date ) ) { |
|
234 | + if (is_wp_error($this->end_date)) { |
|
235 | 235 | return $this->end_date; |
236 | 236 | } |
237 | 237 | |
238 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
238 | + add_filter('posts_where', array($this, 'payments_where')); |
|
239 | 239 | |
240 | - if ( empty( $form_id ) ) { |
|
240 | + if (empty($form_id)) { |
|
241 | 241 | |
242 | 242 | // Global earning stats |
243 | 243 | $args = array( |
244 | 244 | 'post_type' => 'give_payment', |
245 | 245 | 'nopaging' => true, |
246 | - 'post_status' => array( 'publish' ), |
|
246 | + 'post_status' => array('publish'), |
|
247 | 247 | 'fields' => 'ids', |
248 | 248 | 'update_post_term_cache' => false, |
249 | 249 | 'suppress_filters' => false, |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | ); |
256 | 256 | |
257 | 257 | //Filter by Gateway ID meta_key |
258 | - if ( $gateway_id !== false ) { |
|
258 | + if ($gateway_id !== false) { |
|
259 | 259 | $args['meta_key'] = '_give_payment_gateway'; |
260 | 260 | $args['meta_value'] = $gateway_id; |
261 | 261 | } |
262 | 262 | |
263 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
264 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
263 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
264 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
265 | 265 | |
266 | 266 | } else { |
267 | 267 | |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | 'give_transient_type' => 'give_earnings', |
281 | 281 | // This is not a valid query arg, but is used for cache keying |
282 | 282 | ); |
283 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
284 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
283 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
284 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | //remove our filter |
288 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
288 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
289 | 289 | |
290 | 290 | //return earnings |
291 | 291 | return $key; |
@@ -302,16 +302,16 @@ discard block |
||
302 | 302 | * |
303 | 303 | * @return array Best selling forms |
304 | 304 | */ |
305 | - public function get_best_selling( $number = 10 ) { |
|
305 | + public function get_best_selling($number = 10) { |
|
306 | 306 | |
307 | 307 | global $wpdb; |
308 | 308 | |
309 | - $give_forms = $wpdb->get_results( $wpdb->prepare( |
|
309 | + $give_forms = $wpdb->get_results($wpdb->prepare( |
|
310 | 310 | "SELECT post_id as form_id, max(meta_value) as sales |
311 | 311 | FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0 |
312 | 312 | GROUP BY meta_value+0 |
313 | 313 | DESC LIMIT %d;", $number |
314 | - ) ); |
|
314 | + )); |
|
315 | 315 | |
316 | 316 | return $give_forms; |
317 | 317 | } |
@@ -10,7 +10,7 @@ discard block |
||
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 | |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @param $args array The array of arguments that can be passed in and used for setting up this payment query. |
58 | 58 | */ |
59 | - public function __construct( $args = array() ) { |
|
59 | + public function __construct($args = array()) { |
|
60 | 60 | $defaults = array( |
61 | 61 | 'output' => 'payments', // Use 'posts' to get standard post objects |
62 | - 'post_type' => array( 'give_payment' ), |
|
62 | + 'post_type' => array('give_payment'), |
|
63 | 63 | 'start_date' => false, |
64 | 64 | 'end_date' => false, |
65 | 65 | 'number' => 20, |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | 'give_forms' => null |
80 | 80 | ); |
81 | 81 | |
82 | - $this->args = wp_parse_args( $args, $defaults ); |
|
82 | + $this->args = wp_parse_args($args, $defaults); |
|
83 | 83 | |
84 | 84 | $this->init(); |
85 | 85 | } |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | * @since 1.0 |
91 | 91 | * @access public |
92 | 92 | */ |
93 | - public function __set( $query_var, $value ) { |
|
94 | - if ( in_array( $query_var, array( 'meta_query', 'tax_query' ) ) ) { |
|
95 | - $this->args[ $query_var ][] = $value; |
|
93 | + public function __set($query_var, $value) { |
|
94 | + if (in_array($query_var, array('meta_query', 'tax_query'))) { |
|
95 | + $this->args[$query_var][] = $value; |
|
96 | 96 | } else { |
97 | - $this->args[ $query_var ] = $value; |
|
97 | + $this->args[$query_var] = $value; |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @since 1.0 |
105 | 105 | * @access public |
106 | 106 | */ |
107 | - public function __unset( $query_var ) { |
|
108 | - unset( $this->args[ $query_var ] ); |
|
107 | + public function __unset($query_var) { |
|
108 | + unset($this->args[$query_var]); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -118,19 +118,19 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function init() { |
120 | 120 | |
121 | - add_action( 'give_pre_get_payments', array( $this, 'date_filter_pre' ) ); |
|
122 | - add_action( 'give_post_get_payments', array( $this, 'date_filter_post' ) ); |
|
123 | - |
|
124 | - add_action( 'give_pre_get_payments', array( $this, 'orderby' ) ); |
|
125 | - add_action( 'give_pre_get_payments', array( $this, 'status' ) ); |
|
126 | - add_action( 'give_pre_get_payments', array( $this, 'month' ) ); |
|
127 | - add_action( 'give_pre_get_payments', array( $this, 'per_page' ) ); |
|
128 | - add_action( 'give_pre_get_payments', array( $this, 'page' ) ); |
|
129 | - add_action( 'give_pre_get_payments', array( $this, 'user' ) ); |
|
130 | - add_action( 'give_pre_get_payments', array( $this, 'search' ) ); |
|
131 | - add_action( 'give_pre_get_payments', array( $this, 'mode' ) ); |
|
132 | - add_action( 'give_pre_get_payments', array( $this, 'children' ) ); |
|
133 | - add_action( 'give_pre_get_payments', array( $this, 'give_forms' ) ); |
|
121 | + add_action('give_pre_get_payments', array($this, 'date_filter_pre')); |
|
122 | + add_action('give_post_get_payments', array($this, 'date_filter_post')); |
|
123 | + |
|
124 | + add_action('give_pre_get_payments', array($this, 'orderby')); |
|
125 | + add_action('give_pre_get_payments', array($this, 'status')); |
|
126 | + add_action('give_pre_get_payments', array($this, 'month')); |
|
127 | + add_action('give_pre_get_payments', array($this, 'per_page')); |
|
128 | + add_action('give_pre_get_payments', array($this, 'page')); |
|
129 | + add_action('give_pre_get_payments', array($this, 'user')); |
|
130 | + add_action('give_pre_get_payments', array($this, 'search')); |
|
131 | + add_action('give_pre_get_payments', array($this, 'mode')); |
|
132 | + add_action('give_pre_get_payments', array($this, 'children')); |
|
133 | + add_action('give_pre_get_payments', array($this, 'give_forms')); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -154,27 +154,27 @@ discard block |
||
154 | 154 | * |
155 | 155 | * @param Give_Payments_Query $this Payments query object. |
156 | 156 | */ |
157 | - do_action( 'give_pre_get_payments', $this ); |
|
157 | + do_action('give_pre_get_payments', $this); |
|
158 | 158 | |
159 | - $query = new WP_Query( $this->args ); |
|
159 | + $query = new WP_Query($this->args); |
|
160 | 160 | |
161 | 161 | $custom_output = array( |
162 | 162 | 'payments', |
163 | 163 | 'give_payments', |
164 | 164 | ); |
165 | 165 | |
166 | - if ( ! in_array( $this->args['output'], $custom_output ) ) { |
|
166 | + if ( ! in_array($this->args['output'], $custom_output)) { |
|
167 | 167 | return $query->posts; |
168 | 168 | } |
169 | 169 | |
170 | - if ( $query->have_posts() ) { |
|
171 | - while ( $query->have_posts() ) { |
|
170 | + if ($query->have_posts()) { |
|
171 | + while ($query->have_posts()) { |
|
172 | 172 | $query->the_post(); |
173 | 173 | |
174 | 174 | $payment_id = get_post()->ID; |
175 | - $payment = new Give_Payment( $payment_id ); |
|
175 | + $payment = new Give_Payment($payment_id); |
|
176 | 176 | |
177 | - $this->payments[] = apply_filters( 'give_donation', $payment, $payment_id, $this ); |
|
177 | + $this->payments[] = apply_filters('give_donation', $payment, $payment_id, $this); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | wp_reset_postdata(); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @param Give_Payments_Query $this Payments query object. |
189 | 189 | */ |
190 | - do_action( 'give_post_get_payments', $this ); |
|
190 | + do_action('give_post_get_payments', $this); |
|
191 | 191 | |
192 | 192 | return $this->payments; |
193 | 193 | } |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | * @return void |
202 | 202 | */ |
203 | 203 | public function date_filter_pre() { |
204 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
204 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
205 | 205 | return; |
206 | 206 | } |
207 | 207 | |
208 | - $this->setup_dates( $this->args['start_date'], $this->args['end_date'] ); |
|
208 | + $this->setup_dates($this->args['start_date'], $this->args['end_date']); |
|
209 | 209 | |
210 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
210 | + add_filter('posts_where', array($this, 'payments_where')); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -220,11 +220,11 @@ discard block |
||
220 | 220 | * @return void |
221 | 221 | */ |
222 | 222 | public function date_filter_post() { |
223 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
223 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
224 | 224 | return; |
225 | 225 | } |
226 | 226 | |
227 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
227 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -236,12 +236,12 @@ discard block |
||
236 | 236 | * @return void |
237 | 237 | */ |
238 | 238 | public function status() { |
239 | - if ( ! isset ( $this->args['status'] ) ) { |
|
239 | + if ( ! isset ($this->args['status'])) { |
|
240 | 240 | return; |
241 | 241 | } |
242 | 242 | |
243 | - $this->__set( 'post_status', $this->args['status'] ); |
|
244 | - $this->__unset( 'status' ); |
|
243 | + $this->__set('post_status', $this->args['status']); |
|
244 | + $this->__unset('status'); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -253,12 +253,12 @@ discard block |
||
253 | 253 | * @return void |
254 | 254 | */ |
255 | 255 | public function page() { |
256 | - if ( ! isset ( $this->args['page'] ) ) { |
|
256 | + if ( ! isset ($this->args['page'])) { |
|
257 | 257 | return; |
258 | 258 | } |
259 | 259 | |
260 | - $this->__set( 'paged', $this->args['page'] ); |
|
261 | - $this->__unset( 'page' ); |
|
260 | + $this->__set('paged', $this->args['page']); |
|
261 | + $this->__unset('page'); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -271,17 +271,17 @@ discard block |
||
271 | 271 | */ |
272 | 272 | public function per_page() { |
273 | 273 | |
274 | - if ( ! isset( $this->args['number'] ) ) { |
|
274 | + if ( ! isset($this->args['number'])) { |
|
275 | 275 | return; |
276 | 276 | } |
277 | 277 | |
278 | - if ( $this->args['number'] == - 1 ) { |
|
279 | - $this->__set( 'nopaging', true ); |
|
278 | + if ($this->args['number'] == - 1) { |
|
279 | + $this->__set('nopaging', true); |
|
280 | 280 | } else { |
281 | - $this->__set( 'posts_per_page', $this->args['number'] ); |
|
281 | + $this->__set('posts_per_page', $this->args['number']); |
|
282 | 282 | } |
283 | 283 | |
284 | - $this->__unset( 'number' ); |
|
284 | + $this->__unset('number'); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -293,12 +293,12 @@ discard block |
||
293 | 293 | * @return void |
294 | 294 | */ |
295 | 295 | public function month() { |
296 | - if ( ! isset ( $this->args['month'] ) ) { |
|
296 | + if ( ! isset ($this->args['month'])) { |
|
297 | 297 | return; |
298 | 298 | } |
299 | 299 | |
300 | - $this->__set( 'monthnum', $this->args['month'] ); |
|
301 | - $this->__unset( 'month' ); |
|
300 | + $this->__set('monthnum', $this->args['month']); |
|
301 | + $this->__unset('month'); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | * @return void |
311 | 311 | */ |
312 | 312 | public function orderby() { |
313 | - switch ( $this->args['orderby'] ) { |
|
313 | + switch ($this->args['orderby']) { |
|
314 | 314 | case 'amount' : |
315 | - $this->__set( 'orderby', 'meta_value_num' ); |
|
316 | - $this->__set( 'meta_key', '_give_payment_total' ); |
|
315 | + $this->__set('orderby', 'meta_value_num'); |
|
316 | + $this->__set('meta_key', '_give_payment_total'); |
|
317 | 317 | break; |
318 | 318 | default : |
319 | - $this->__set( 'orderby', $this->args['orderby'] ); |
|
319 | + $this->__set('orderby', $this->args['orderby']); |
|
320 | 320 | break; |
321 | 321 | } |
322 | 322 | } |
@@ -330,20 +330,20 @@ discard block |
||
330 | 330 | * @return void |
331 | 331 | */ |
332 | 332 | public function user() { |
333 | - if ( is_null( $this->args['user'] ) ) { |
|
333 | + if (is_null($this->args['user'])) { |
|
334 | 334 | return; |
335 | 335 | } |
336 | 336 | |
337 | - if ( is_numeric( $this->args['user'] ) ) { |
|
337 | + if (is_numeric($this->args['user'])) { |
|
338 | 338 | $user_key = '_give_payment_user_id'; |
339 | 339 | } else { |
340 | 340 | $user_key = '_give_payment_user_email'; |
341 | 341 | } |
342 | 342 | |
343 | - $this->__set( 'meta_query', array( |
|
343 | + $this->__set('meta_query', array( |
|
344 | 344 | 'key' => $user_key, |
345 | 345 | 'value' => $this->args['user'] |
346 | - ) ); |
|
346 | + )); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
@@ -356,33 +356,33 @@ discard block |
||
356 | 356 | */ |
357 | 357 | public function search() { |
358 | 358 | |
359 | - if ( ! isset( $this->args['s'] ) ) { |
|
359 | + if ( ! isset($this->args['s'])) { |
|
360 | 360 | return; |
361 | 361 | } |
362 | 362 | |
363 | - $search = trim( $this->args['s'] ); |
|
363 | + $search = trim($this->args['s']); |
|
364 | 364 | |
365 | - if ( empty( $search ) ) { |
|
365 | + if (empty($search)) { |
|
366 | 366 | return; |
367 | 367 | } |
368 | 368 | |
369 | - $is_email = is_email( $search ) || strpos( $search, '@' ) !== false; |
|
370 | - $is_user = strpos( $search, strtolower( 'user:' ) ) !== false; |
|
369 | + $is_email = is_email($search) || strpos($search, '@') !== false; |
|
370 | + $is_user = strpos($search, strtolower('user:')) !== false; |
|
371 | 371 | |
372 | - if ( ! empty( $this->args['search_in_notes'] ) ) { |
|
372 | + if ( ! empty($this->args['search_in_notes'])) { |
|
373 | 373 | |
374 | - $notes = give_get_payment_notes( 0, $search ); |
|
374 | + $notes = give_get_payment_notes(0, $search); |
|
375 | 375 | |
376 | - if ( ! empty( $notes ) ) { |
|
376 | + if ( ! empty($notes)) { |
|
377 | 377 | |
378 | - $payment_ids = wp_list_pluck( (array) $notes, 'comment_post_ID' ); |
|
378 | + $payment_ids = wp_list_pluck((array) $notes, 'comment_post_ID'); |
|
379 | 379 | |
380 | - $this->__set( 'post__in', $payment_ids ); |
|
380 | + $this->__set('post__in', $payment_ids); |
|
381 | 381 | } |
382 | 382 | |
383 | - $this->__unset( 's' ); |
|
383 | + $this->__unset('s'); |
|
384 | 384 | |
385 | - } elseif ( $is_email || strlen( $search ) == 32 ) { |
|
385 | + } elseif ($is_email || strlen($search) == 32) { |
|
386 | 386 | |
387 | 387 | $key = $is_email ? '_give_payment_user_email' : '_give_payment_purchase_key'; |
388 | 388 | $search_meta = array( |
@@ -391,19 +391,19 @@ discard block |
||
391 | 391 | 'compare' => 'LIKE' |
392 | 392 | ); |
393 | 393 | |
394 | - $this->__set( 'meta_query', $search_meta ); |
|
395 | - $this->__unset( 's' ); |
|
394 | + $this->__set('meta_query', $search_meta); |
|
395 | + $this->__unset('s'); |
|
396 | 396 | |
397 | - } elseif ( $is_user ) { |
|
397 | + } elseif ($is_user) { |
|
398 | 398 | |
399 | 399 | $search_meta = array( |
400 | 400 | 'key' => '_give_payment_user_id', |
401 | - 'value' => trim( str_replace( 'user:', '', strtolower( $search ) ) ) |
|
401 | + 'value' => trim(str_replace('user:', '', strtolower($search))) |
|
402 | 402 | ); |
403 | 403 | |
404 | - $this->__set( 'meta_query', $search_meta ); |
|
404 | + $this->__set('meta_query', $search_meta); |
|
405 | 405 | |
406 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
406 | + if (give_get_option('enable_sequential')) { |
|
407 | 407 | |
408 | 408 | $search_meta = array( |
409 | 409 | 'key' => '_give_payment_number', |
@@ -411,19 +411,19 @@ discard block |
||
411 | 411 | 'compare' => 'LIKE' |
412 | 412 | ); |
413 | 413 | |
414 | - $this->__set( 'meta_query', $search_meta ); |
|
414 | + $this->__set('meta_query', $search_meta); |
|
415 | 415 | |
416 | 416 | $this->args['meta_query']['relation'] = 'OR'; |
417 | 417 | |
418 | 418 | } |
419 | 419 | |
420 | - $this->__unset( 's' ); |
|
420 | + $this->__unset('s'); |
|
421 | 421 | |
422 | 422 | } elseif ( |
423 | - give_get_option( 'enable_sequential' ) && |
|
423 | + give_get_option('enable_sequential') && |
|
424 | 424 | ( |
425 | - false !== strpos( $search, give_get_option( 'sequential_prefix' ) ) || |
|
426 | - false !== strpos( $search, give_get_option( 'sequential_postfix' ) ) |
|
425 | + false !== strpos($search, give_get_option('sequential_prefix')) || |
|
426 | + false !== strpos($search, give_get_option('sequential_postfix')) |
|
427 | 427 | ) |
428 | 428 | ) { |
429 | 429 | |
@@ -433,30 +433,30 @@ discard block |
||
433 | 433 | 'compare' => 'LIKE' |
434 | 434 | ); |
435 | 435 | |
436 | - $this->__set( 'meta_query', $search_meta ); |
|
437 | - $this->__unset( 's' ); |
|
436 | + $this->__set('meta_query', $search_meta); |
|
437 | + $this->__unset('s'); |
|
438 | 438 | |
439 | - } elseif ( is_numeric( $search ) ) { |
|
439 | + } elseif (is_numeric($search)) { |
|
440 | 440 | |
441 | - $post = get_post( $search ); |
|
441 | + $post = get_post($search); |
|
442 | 442 | |
443 | - if ( is_object( $post ) && $post->post_type == 'give_payment' ) { |
|
443 | + if (is_object($post) && $post->post_type == 'give_payment') { |
|
444 | 444 | |
445 | 445 | $arr = array(); |
446 | 446 | $arr[] = $search; |
447 | - $this->__set( 'post__in', $arr ); |
|
448 | - $this->__unset( 's' ); |
|
447 | + $this->__set('post__in', $arr); |
|
448 | + $this->__unset('s'); |
|
449 | 449 | } |
450 | 450 | |
451 | - } elseif ( '#' == substr( $search, 0, 1 ) ) { |
|
451 | + } elseif ('#' == substr($search, 0, 1)) { |
|
452 | 452 | |
453 | - $search = str_replace( '#:', '', $search ); |
|
454 | - $search = str_replace( '#', '', $search ); |
|
455 | - $this->__set( 'give_forms', $search ); |
|
456 | - $this->__unset( 's' ); |
|
453 | + $search = str_replace('#:', '', $search); |
|
454 | + $search = str_replace('#', '', $search); |
|
455 | + $this->__set('give_forms', $search); |
|
456 | + $this->__unset('s'); |
|
457 | 457 | |
458 | 458 | } else { |
459 | - $this->__set( 's', $search ); |
|
459 | + $this->__set('s', $search); |
|
460 | 460 | |
461 | 461 | } |
462 | 462 | |
@@ -471,16 +471,16 @@ discard block |
||
471 | 471 | * @return void |
472 | 472 | */ |
473 | 473 | public function mode() { |
474 | - if ( empty( $this->args['mode'] ) || $this->args['mode'] == 'all' ) { |
|
475 | - $this->__unset( 'mode' ); |
|
474 | + if (empty($this->args['mode']) || $this->args['mode'] == 'all') { |
|
475 | + $this->__unset('mode'); |
|
476 | 476 | |
477 | 477 | return; |
478 | 478 | } |
479 | 479 | |
480 | - $this->__set( 'meta_query', array( |
|
480 | + $this->__set('meta_query', array( |
|
481 | 481 | 'key' => '_give_payment_mode', |
482 | 482 | 'value' => $this->args['mode'] |
483 | - ) ); |
|
483 | + )); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | /** |
@@ -492,10 +492,10 @@ discard block |
||
492 | 492 | * @return void |
493 | 493 | */ |
494 | 494 | public function children() { |
495 | - if ( empty( $this->args['children'] ) ) { |
|
496 | - $this->__set( 'post_parent', 0 ); |
|
495 | + if (empty($this->args['children'])) { |
|
496 | + $this->__set('post_parent', 0); |
|
497 | 497 | } |
498 | - $this->__unset( 'children' ); |
|
498 | + $this->__unset('children'); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | /** |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | */ |
509 | 509 | public function give_forms() { |
510 | 510 | |
511 | - if ( empty( $this->args['give_forms'] ) ) { |
|
511 | + if (empty($this->args['give_forms'])) { |
|
512 | 512 | return; |
513 | 513 | } |
514 | 514 | |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | $args = array( |
518 | 518 | 'post_parent' => $this->args['give_forms'], |
519 | 519 | 'log_type' => 'sale', |
520 | - 'post_status' => array( 'publish' ), |
|
520 | + 'post_status' => array('publish'), |
|
521 | 521 | 'nopaging' => true, |
522 | 522 | 'no_found_rows' => true, |
523 | 523 | 'update_post_term_cache' => false, |
@@ -526,31 +526,31 @@ discard block |
||
526 | 526 | 'fields' => 'ids' |
527 | 527 | ); |
528 | 528 | |
529 | - if ( is_array( $this->args['give_forms'] ) ) { |
|
530 | - unset( $args['post_parent'] ); |
|
529 | + if (is_array($this->args['give_forms'])) { |
|
530 | + unset($args['post_parent']); |
|
531 | 531 | $args['post_parent__in'] = $this->args['give_forms']; |
532 | 532 | } |
533 | 533 | |
534 | - $sales = $give_logs->get_connected_logs( $args ); |
|
534 | + $sales = $give_logs->get_connected_logs($args); |
|
535 | 535 | |
536 | - if ( ! empty( $sales ) ) { |
|
536 | + if ( ! empty($sales)) { |
|
537 | 537 | |
538 | 538 | $payments = array(); |
539 | 539 | |
540 | - foreach ( $sales as $sale ) { |
|
541 | - $payments[] = get_post_meta( $sale, '_give_log_payment_id', true ); |
|
540 | + foreach ($sales as $sale) { |
|
541 | + $payments[] = get_post_meta($sale, '_give_log_payment_id', true); |
|
542 | 542 | } |
543 | 543 | |
544 | - $this->__set( 'post__in', $payments ); |
|
544 | + $this->__set('post__in', $payments); |
|
545 | 545 | |
546 | 546 | } else { |
547 | 547 | |
548 | 548 | // Set post_parent to something crazy so it doesn't find anything |
549 | - $this->__set( 'post_parent', 999999999999999 ); |
|
549 | + $this->__set('post_parent', 999999999999999); |
|
550 | 550 | |
551 | 551 | } |
552 | 552 | |
553 | - $this->__unset( 'give_forms' ); |
|
553 | + $this->__unset('give_forms'); |
|
554 | 554 | |
555 | 555 | } |
556 | 556 |
@@ -12,7 +12,7 @@ discard block |
||
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 | |
@@ -41,20 +41,20 @@ discard block |
||
41 | 41 | public function csv_cols() { |
42 | 42 | |
43 | 43 | $cols = array( |
44 | - 'ID' => esc_html__( 'ID', 'give' ), |
|
45 | - 'post_name' => esc_html__( 'Slug', 'give' ), |
|
46 | - 'post_title' => esc_html__( 'Name', 'give' ), |
|
47 | - 'post_date' => esc_html__( 'Date Created', 'give' ), |
|
48 | - 'post_author' => esc_html__( 'Author', 'give' ), |
|
49 | - 'post_content' => esc_html__( 'Description', 'give' ), |
|
50 | - 'post_excerpt' => esc_html__( 'Excerpt', 'give' ), |
|
51 | - 'post_status' => esc_html__( 'Status', 'give' ), |
|
52 | - 'categories' => esc_html__( 'Categories', 'give' ), |
|
53 | - 'tags' => esc_html__( 'Tags', 'give' ), |
|
54 | - 'give_price' => esc_html__( 'Price', 'give' ), |
|
55 | - '_thumbnail_id' => esc_html__( 'Featured Image', 'give' ), |
|
56 | - '_give_form_sales' => esc_html__( 'Donations', 'give' ), |
|
57 | - '_give_download_earnings' => esc_html__( 'Income', 'give' ), |
|
44 | + 'ID' => esc_html__('ID', 'give'), |
|
45 | + 'post_name' => esc_html__('Slug', 'give'), |
|
46 | + 'post_title' => esc_html__('Name', 'give'), |
|
47 | + 'post_date' => esc_html__('Date Created', 'give'), |
|
48 | + 'post_author' => esc_html__('Author', 'give'), |
|
49 | + 'post_content' => esc_html__('Description', 'give'), |
|
50 | + 'post_excerpt' => esc_html__('Excerpt', 'give'), |
|
51 | + 'post_status' => esc_html__('Status', 'give'), |
|
52 | + 'categories' => esc_html__('Categories', 'give'), |
|
53 | + 'tags' => esc_html__('Tags', 'give'), |
|
54 | + 'give_price' => esc_html__('Price', 'give'), |
|
55 | + '_thumbnail_id' => esc_html__('Featured Image', 'give'), |
|
56 | + '_give_form_sales' => esc_html__('Donations', 'give'), |
|
57 | + '_give_download_earnings' => esc_html__('Income', 'give'), |
|
58 | 58 | ); |
59 | 59 | |
60 | 60 | return $cols; |
@@ -86,43 +86,43 @@ discard block |
||
86 | 86 | 'paged' => $this->step |
87 | 87 | ); |
88 | 88 | |
89 | - $downloads = new WP_Query( $args ); |
|
89 | + $downloads = new WP_Query($args); |
|
90 | 90 | |
91 | - if ( $downloads->posts ) { |
|
92 | - foreach ( $downloads->posts as $download ) { |
|
91 | + if ($downloads->posts) { |
|
92 | + foreach ($downloads->posts as $download) { |
|
93 | 93 | |
94 | 94 | $row = array(); |
95 | 95 | |
96 | - foreach ( $this->csv_cols() as $key => $value ) { |
|
96 | + foreach ($this->csv_cols() as $key => $value) { |
|
97 | 97 | |
98 | 98 | // Setup default value |
99 | - $row[ $key ] = ''; |
|
99 | + $row[$key] = ''; |
|
100 | 100 | |
101 | - if ( in_array( $key, $meta ) ) { |
|
101 | + if (in_array($key, $meta)) { |
|
102 | 102 | |
103 | - switch ( $key ) { |
|
103 | + switch ($key) { |
|
104 | 104 | |
105 | 105 | case '_thumbnail_id' : |
106 | 106 | |
107 | - $image_id = get_post_thumbnail_id( $download->ID ); |
|
108 | - $row[ $key ] = wp_get_attachment_url( $image_id ); |
|
107 | + $image_id = get_post_thumbnail_id($download->ID); |
|
108 | + $row[$key] = wp_get_attachment_url($image_id); |
|
109 | 109 | |
110 | 110 | break; |
111 | 111 | |
112 | 112 | case 'give_price' : |
113 | 113 | |
114 | - if ( give_has_variable_prices( $download->ID ) ) { |
|
114 | + if (give_has_variable_prices($download->ID)) { |
|
115 | 115 | |
116 | 116 | $prices = array(); |
117 | - foreach ( give_get_variable_prices( $download->ID ) as $price ) { |
|
118 | - $prices[] = $price['name'] . ': ' . $price['amount']; |
|
117 | + foreach (give_get_variable_prices($download->ID) as $price) { |
|
118 | + $prices[] = $price['name'].': '.$price['amount']; |
|
119 | 119 | } |
120 | 120 | |
121 | - $row[ $key ] = implode( ' | ', $prices ); |
|
121 | + $row[$key] = implode(' | ', $prices); |
|
122 | 122 | |
123 | 123 | } else { |
124 | 124 | |
125 | - $row[ $key ] = give_get_download_price( $download->ID ); |
|
125 | + $row[$key] = give_get_download_price($download->ID); |
|
126 | 126 | |
127 | 127 | } |
128 | 128 | |
@@ -132,54 +132,54 @@ discard block |
||
132 | 132 | |
133 | 133 | |
134 | 134 | $files = array(); |
135 | - foreach ( give_get_download_files( $download->ID ) as $file ) { |
|
135 | + foreach (give_get_download_files($download->ID) as $file) { |
|
136 | 136 | $files[] = $file['file']; |
137 | 137 | } |
138 | 138 | |
139 | - $row[ $key ] = implode( ' | ', $files ); |
|
139 | + $row[$key] = implode(' | ', $files); |
|
140 | 140 | |
141 | 141 | break; |
142 | 142 | |
143 | 143 | default : |
144 | 144 | |
145 | - $row[ $key ] = get_post_meta( $download->ID, $key, true ); |
|
145 | + $row[$key] = get_post_meta($download->ID, $key, true); |
|
146 | 146 | |
147 | 147 | break; |
148 | 148 | |
149 | 149 | } |
150 | 150 | |
151 | - } elseif ( isset( $download->$key ) ) { |
|
151 | + } elseif (isset($download->$key)) { |
|
152 | 152 | |
153 | - switch ( $key ) { |
|
153 | + switch ($key) { |
|
154 | 154 | |
155 | 155 | case 'post_author' : |
156 | 156 | |
157 | - $row[ $key ] = get_the_author_meta( 'user_login', $download->post_author ); |
|
157 | + $row[$key] = get_the_author_meta('user_login', $download->post_author); |
|
158 | 158 | |
159 | 159 | break; |
160 | 160 | |
161 | 161 | default : |
162 | 162 | |
163 | - $row[ $key ] = $download->$key; |
|
163 | + $row[$key] = $download->$key; |
|
164 | 164 | |
165 | 165 | break; |
166 | 166 | } |
167 | 167 | |
168 | - } elseif ( 'tags' == $key ) { |
|
168 | + } elseif ('tags' == $key) { |
|
169 | 169 | |
170 | - $terms = get_the_terms( $download->ID, 'download_tag' ); |
|
171 | - if ( $terms ) { |
|
172 | - $terms = wp_list_pluck( $terms, 'name' ); |
|
173 | - $row[ $key ] = implode( ' | ', $terms ); |
|
170 | + $terms = get_the_terms($download->ID, 'download_tag'); |
|
171 | + if ($terms) { |
|
172 | + $terms = wp_list_pluck($terms, 'name'); |
|
173 | + $row[$key] = implode(' | ', $terms); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | |
177 | - } elseif ( 'categories' == $key ) { |
|
177 | + } elseif ('categories' == $key) { |
|
178 | 178 | |
179 | - $terms = get_the_terms( $download->ID, 'download_category' ); |
|
180 | - if ( $terms ) { |
|
181 | - $terms = wp_list_pluck( $terms, 'name' ); |
|
182 | - $row[ $key ] = implode( ' | ', $terms ); |
|
179 | + $terms = get_the_terms($download->ID, 'download_category'); |
|
180 | + if ($terms) { |
|
181 | + $terms = wp_list_pluck($terms, 'name'); |
|
182 | + $row[$key] = implode(' | ', $terms); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | } |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | |
191 | 191 | } |
192 | 192 | |
193 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
194 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
193 | + $data = apply_filters('give_export_get_data', $data); |
|
194 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
195 | 195 | |
196 | 196 | return $data; |
197 | 197 | } |
@@ -210,20 +210,20 @@ discard block |
||
210 | 210 | |
211 | 211 | $args = array( |
212 | 212 | 'post_type' => 'give_forms', |
213 | - 'posts_per_page' => - 1, |
|
213 | + 'posts_per_page' => -1, |
|
214 | 214 | 'post_status' => 'any', |
215 | 215 | 'fields' => 'ids', |
216 | 216 | ); |
217 | 217 | |
218 | - $downloads = new WP_Query( $args ); |
|
218 | + $downloads = new WP_Query($args); |
|
219 | 219 | $total = (int) $downloads->post_count; |
220 | 220 | $percentage = 100; |
221 | 221 | |
222 | - if ( $total > 0 ) { |
|
223 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
222 | + if ($total > 0) { |
|
223 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
224 | 224 | } |
225 | 225 | |
226 | - if ( $percentage > 100 ) { |
|
226 | + if ($percentage > 100) { |
|
227 | 227 | $percentage = 100; |
228 | 228 | } |
229 | 229 |