@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Install Function |
|
4 | - * |
|
5 | - * @package Give |
|
6 | - * @subpackage Functions/Install |
|
7 | - * @copyright Copyright (c) 2015, WordImpress |
|
8 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
9 | - * @since 1.0 |
|
10 | - */ |
|
3 | + * Install Function |
|
4 | + * |
|
5 | + * @package Give |
|
6 | + * @subpackage Functions/Install |
|
7 | + * @copyright Copyright (c) 2015, WordImpress |
|
8 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
9 | + * @since 1.0 |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
@@ -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 | |
@@ -32,25 +32,25 @@ discard block |
||
32 | 32 | give_setup_post_types(); |
33 | 33 | |
34 | 34 | // Clear the permalinks |
35 | - flush_rewrite_rules( false ); |
|
35 | + flush_rewrite_rules(false); |
|
36 | 36 | |
37 | 37 | // Add Upgraded From Option |
38 | - $current_version = get_option( 'give_version' ); |
|
39 | - if ( $current_version ) { |
|
40 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
38 | + $current_version = get_option('give_version'); |
|
39 | + if ($current_version) { |
|
40 | + update_option('give_version_upgraded_from', $current_version); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | // Setup some default options |
44 | 44 | $options = array(); |
45 | 45 | |
46 | 46 | // Checks if the Success Page option exists AND that the page exists |
47 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
47 | + if ( ! get_post(give_get_option('success_page'))) { |
|
48 | 48 | |
49 | 49 | // Purchase Confirmation (Success) Page |
50 | 50 | $success = wp_insert_post( |
51 | 51 | array( |
52 | - 'post_title' => __( 'Donation Confirmation', 'give' ), |
|
53 | - 'post_content' => __( 'Thank you for your donation! [give_receipt]', 'give' ), |
|
52 | + 'post_title' => __('Donation Confirmation', 'give'), |
|
53 | + 'post_content' => __('Thank you for your donation! [give_receipt]', 'give'), |
|
54 | 54 | 'post_status' => 'publish', |
55 | 55 | 'post_author' => 1, |
56 | 56 | 'post_type' => 'page', |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | // Checks if the Failure Page option exists AND that the page exists |
66 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
66 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
67 | 67 | |
68 | 68 | // Failed Purchase Page |
69 | 69 | $failed = wp_insert_post( |
70 | 70 | array( |
71 | - 'post_title' => __( 'Transaction Failed', 'give' ), |
|
72 | - 'post_content' => __( 'Your transaction failed, please try again or contact site support.', 'give' ), |
|
71 | + 'post_title' => __('Transaction Failed', 'give'), |
|
72 | + 'post_content' => __('Your transaction failed, please try again or contact site support.', 'give'), |
|
73 | 73 | 'post_status' => 'publish', |
74 | 74 | 'post_author' => 1, |
75 | 75 | 'post_type' => 'page', |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | // Checks if the History Page option exists AND that the page exists |
84 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
84 | + if ( ! get_post(give_get_option('history_page'))) { |
|
85 | 85 | // Purchase History (History) Page |
86 | 86 | $history = wp_insert_post( |
87 | 87 | array( |
88 | - 'post_title' => __( 'Donation History', 'give' ), |
|
88 | + 'post_title' => __('Donation History', 'give'), |
|
89 | 89 | 'post_content' => '[donation_history]', |
90 | 90 | 'post_status' => 'publish', |
91 | 91 | 'post_author' => 1, |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | } |
99 | 99 | |
100 | 100 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency |
101 | - if ( empty( $current_version ) ) { |
|
101 | + if (empty($current_version)) { |
|
102 | 102 | $options['base_country'] = 'US'; |
103 | 103 | $options['test_mode'] = 1; |
104 | 104 | $options['currency'] = 'USD'; |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | // Populate some default values |
118 | - update_option( 'give_settings', array_merge( $give_options, $options ) ); |
|
119 | - update_option( 'give_version', GIVE_VERSION ); |
|
118 | + update_option('give_settings', array_merge($give_options, $options)); |
|
119 | + update_option('give_version', GIVE_VERSION); |
|
120 | 120 | |
121 | 121 | //Update Version Number |
122 | - if ( $current_version ) { |
|
123 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
122 | + if ($current_version) { |
|
123 | + update_option('give_version_upgraded_from', $current_version); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | // Create Give roles |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $roles->add_caps(); |
130 | 130 | |
131 | 131 | $api = new Give_API(); |
132 | - update_option( 'give_default_api_version', 'v' . $api->get_version() ); |
|
132 | + update_option('give_default_api_version', 'v'.$api->get_version()); |
|
133 | 133 | |
134 | 134 | // Create the customers database |
135 | 135 | @Give()->customers->create_table(); |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | Give()->session->use_php_sessions(); |
139 | 139 | |
140 | 140 | // Add a temporary option to note that Give pages have been created |
141 | - set_transient( '_give_installed', $options, 30 ); |
|
141 | + set_transient('_give_installed', $options, 30); |
|
142 | 142 | |
143 | 143 | |
144 | - if ( ! $current_version ) { |
|
145 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
144 | + if ( ! $current_version) { |
|
145 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
146 | 146 | |
147 | 147 | // When new upgrade routines are added, mark them as complete on fresh install |
148 | 148 | $upgrade_routines = array( |
@@ -150,20 +150,20 @@ discard block |
||
150 | 150 | 'upgrade_give_offline_status' |
151 | 151 | ); |
152 | 152 | |
153 | - foreach ( $upgrade_routines as $upgrade ) { |
|
154 | - give_set_upgrade_complete( $upgrade ); |
|
153 | + foreach ($upgrade_routines as $upgrade) { |
|
154 | + give_set_upgrade_complete($upgrade); |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | // Bail if activating from network, or bulk |
158 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
158 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
159 | 159 | return; |
160 | 160 | } |
161 | 161 | // Add the transient to redirect |
162 | - set_transient( '_give_activation_redirect', true, 30 ); |
|
162 | + set_transient('_give_activation_redirect', true, 30); |
|
163 | 163 | |
164 | 164 | } |
165 | 165 | |
166 | -register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
166 | +register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
167 | 167 | |
168 | 168 | /** |
169 | 169 | * Post-installation |
@@ -175,14 +175,14 @@ discard block |
||
175 | 175 | */ |
176 | 176 | function give_after_install() { |
177 | 177 | |
178 | - if ( ! is_admin() ) { |
|
178 | + if ( ! is_admin()) { |
|
179 | 179 | return; |
180 | 180 | } |
181 | 181 | |
182 | - $give_options = get_transient( '_give_installed' ); |
|
182 | + $give_options = get_transient('_give_installed'); |
|
183 | 183 | |
184 | 184 | // Exit if not in admin or the transient doesn't exist |
185 | - if ( false === $give_options ) { |
|
185 | + if (false === $give_options) { |
|
186 | 186 | return; |
187 | 187 | } |
188 | 188 | |
@@ -190,13 +190,13 @@ discard block |
||
190 | 190 | @Give()->customers->create_table(); |
191 | 191 | |
192 | 192 | // Delete the transient |
193 | - delete_transient( '_give_installed' ); |
|
193 | + delete_transient('_give_installed'); |
|
194 | 194 | |
195 | - do_action( 'give_after_install', $give_options ); |
|
195 | + do_action('give_after_install', $give_options); |
|
196 | 196 | |
197 | 197 | } |
198 | 198 | |
199 | -add_action( 'admin_init', 'give_after_install' ); |
|
199 | +add_action('admin_init', 'give_after_install'); |
|
200 | 200 | |
201 | 201 | |
202 | 202 | /** |
@@ -211,11 +211,11 @@ discard block |
||
211 | 211 | |
212 | 212 | global $wp_roles; |
213 | 213 | |
214 | - if ( ! is_object( $wp_roles ) ) { |
|
214 | + if ( ! is_object($wp_roles)) { |
|
215 | 215 | return; |
216 | 216 | } |
217 | 217 | |
218 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
218 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
219 | 219 | |
220 | 220 | // Create Give shop roles |
221 | 221 | $roles = new Give_Roles; |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | |
227 | 227 | } |
228 | 228 | |
229 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
229 | +add_action('admin_init', 'give_install_roles_on_network'); |
|
230 | 230 | |
231 | 231 | /** |
232 | 232 | * Network Activated New Site Setup |
@@ -242,12 +242,12 @@ discard block |
||
242 | 242 | * @param $site_id |
243 | 243 | * @param $meta |
244 | 244 | */ |
245 | -function on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
246 | - if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) { |
|
247 | - switch_to_blog( $blog_id ); |
|
245 | +function on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
246 | + if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) { |
|
247 | + switch_to_blog($blog_id); |
|
248 | 248 | give_install(); |
249 | 249 | restore_current_blog(); |
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | -add_action( 'wpmu_new_blog', 'on_create_blog', 10, 6 ); |
|
254 | 253 | \ No newline at end of file |
254 | +add_action('wpmu_new_blog', 'on_create_blog', 10, 6); |
|
255 | 255 | \ No newline at end of file |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Upgrade Functions |
|
4 | - * |
|
5 | - * @package Give |
|
6 | - * @subpackage Admin/Upgrades |
|
7 | - * @copyright Copyright (c) 2015, WordImpress |
|
8 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
9 | - * @since 1.0 |
|
10 | - * |
|
11 | - * NOTICE: When adding new upgrade notices, please be sure to put the action into the upgrades array during install: /includes/install.php @ Appox Line 156 |
|
12 | - * |
|
13 | - */ |
|
3 | + * Upgrade Functions |
|
4 | + * |
|
5 | + * @package Give |
|
6 | + * @subpackage Admin/Upgrades |
|
7 | + * @copyright Copyright (c) 2015, WordImpress |
|
8 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
9 | + * @since 1.0 |
|
10 | + * |
|
11 | + * NOTICE: When adding new upgrade notices, please be sure to put the action into the upgrades array during install: /includes/install.php @ Appox Line 156 |
|
12 | + * |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | // Exit if accessed directly |
16 | 16 | if ( ! defined( 'ABSPATH' ) ) { |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | // Exit if accessed directly |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if ( ! defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -25,18 +25,18 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_show_upgrade_notices() { |
27 | 27 | |
28 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-upgrades' ) { |
|
28 | + if (isset($_GET['page']) && $_GET['page'] == 'give-upgrades') { |
|
29 | 29 | return; |
30 | 30 | } // Don't show notices on the upgrades page |
31 | 31 | |
32 | - $give_version = get_option( 'give_version' ); |
|
32 | + $give_version = get_option('give_version'); |
|
33 | 33 | |
34 | - if ( ! $give_version ) { |
|
34 | + if ( ! $give_version) { |
|
35 | 35 | // 1.0 is the first version to use this option so we must add it |
36 | 36 | $give_version = '1.0'; |
37 | 37 | } |
38 | 38 | |
39 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
39 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
40 | 40 | |
41 | 41 | /* |
42 | 42 | * NOTICE: |
@@ -47,18 +47,18 @@ discard block |
||
47 | 47 | */ |
48 | 48 | |
49 | 49 | //v1.3.2 Upgrades |
50 | - if ( version_compare( $give_version, '1.3.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) { |
|
50 | + if (version_compare($give_version, '1.3.2', '<') || ! give_has_upgrade_completed('upgrade_give_payment_customer_id')) { |
|
51 | 51 | printf( |
52 | - '<div class="updated"><p>' . __( 'Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>', |
|
53 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id' ) ) |
|
52 | + '<div class="updated"><p>'.__('Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>', |
|
53 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id')) |
|
54 | 54 | ); |
55 | 55 | } |
56 | 56 | |
57 | 57 | //v1.3.4 Upgrades //ensure the user has gone through 1.3.4 |
58 | - if ( version_compare( $give_version, '1.3.4', '<' ) || ( ! give_has_upgrade_completed( 'upgrade_give_offline_status' ) && give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) ) { |
|
58 | + if (version_compare($give_version, '1.3.4', '<') || ( ! give_has_upgrade_completed('upgrade_give_offline_status') && give_has_upgrade_completed('upgrade_give_payment_customer_id'))) { |
|
59 | 59 | printf( |
60 | - '<div class="updated"><p>' . __( 'Give needs to upgrade the transaction database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>', |
|
61 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status' ) ) |
|
60 | + '<div class="updated"><p>'.__('Give needs to upgrade the transaction database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>', |
|
61 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status')) |
|
62 | 62 | ); |
63 | 63 | } |
64 | 64 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | } |
70 | 70 | |
71 | -add_action( 'admin_notices', 'give_show_upgrade_notices' ); |
|
71 | +add_action('admin_notices', 'give_show_upgrade_notices'); |
|
72 | 72 | |
73 | 73 | /** |
74 | 74 | * Triggers all upgrade functions |
@@ -80,26 +80,26 @@ discard block |
||
80 | 80 | */ |
81 | 81 | function give_trigger_upgrades() { |
82 | 82 | |
83 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
84 | - wp_die( __( 'You do not have permission to do Give upgrades', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
83 | + if ( ! current_user_can('manage_give_settings')) { |
|
84 | + wp_die(__('You do not have permission to do Give upgrades', 'give'), __('Error', 'give'), array('response' => 403)); |
|
85 | 85 | } |
86 | 86 | |
87 | - $give_version = get_option( 'give_version' ); |
|
87 | + $give_version = get_option('give_version'); |
|
88 | 88 | |
89 | - if ( ! $give_version ) { |
|
89 | + if ( ! $give_version) { |
|
90 | 90 | // 1.0 is the first version to use this option so we must add it |
91 | 91 | $give_version = '1.0'; |
92 | - add_option( 'give_version', $give_version ); |
|
92 | + add_option('give_version', $give_version); |
|
93 | 93 | } |
94 | 94 | |
95 | - update_option( 'give_version', GIVE_VERSION ); |
|
95 | + update_option('give_version', GIVE_VERSION); |
|
96 | 96 | |
97 | - if ( DOING_AJAX ) { |
|
98 | - die( 'complete' ); |
|
97 | + if (DOING_AJAX) { |
|
98 | + die('complete'); |
|
99 | 99 | } // Let AJAX know that the upgrade is complete |
100 | 100 | } |
101 | 101 | |
102 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
102 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * Check if the upgrade routine has been run for a specific action |
@@ -110,15 +110,15 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return bool If the action has been added to the completed actions array |
112 | 112 | */ |
113 | -function give_has_upgrade_completed( $upgrade_action = '' ) { |
|
113 | +function give_has_upgrade_completed($upgrade_action = '') { |
|
114 | 114 | |
115 | - if ( empty( $upgrade_action ) ) { |
|
115 | + if (empty($upgrade_action)) { |
|
116 | 116 | return false; |
117 | 117 | } |
118 | 118 | |
119 | 119 | $completed_upgrades = give_get_completed_upgrades(); |
120 | 120 | |
121 | - return in_array( $upgrade_action, $completed_upgrades ); |
|
121 | + return in_array($upgrade_action, $completed_upgrades); |
|
122 | 122 | |
123 | 123 | } |
124 | 124 | |
@@ -131,9 +131,9 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return bool If the function was successfully added |
133 | 133 | */ |
134 | -function give_set_upgrade_complete( $upgrade_action = '' ) { |
|
134 | +function give_set_upgrade_complete($upgrade_action = '') { |
|
135 | 135 | |
136 | - if ( empty( $upgrade_action ) ) { |
|
136 | + if (empty($upgrade_action)) { |
|
137 | 137 | return false; |
138 | 138 | } |
139 | 139 | |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | $completed_upgrades[] = $upgrade_action; |
142 | 142 | |
143 | 143 | // Remove any blanks, and only show uniques |
144 | - $completed_upgrades = array_unique( array_values( $completed_upgrades ) ); |
|
144 | + $completed_upgrades = array_unique(array_values($completed_upgrades)); |
|
145 | 145 | |
146 | - return update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
146 | + return update_option('give_completed_upgrades', $completed_upgrades); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | */ |
155 | 155 | function give_get_completed_upgrades() { |
156 | 156 | |
157 | - $completed_upgrades = get_option( 'give_completed_upgrades' ); |
|
157 | + $completed_upgrades = get_option('give_completed_upgrades'); |
|
158 | 158 | |
159 | - if ( false === $completed_upgrades ) { |
|
159 | + if (false === $completed_upgrades) { |
|
160 | 160 | $completed_upgrades = array(); |
161 | 161 | } |
162 | 162 | |
@@ -175,30 +175,30 @@ discard block |
||
175 | 175 | */ |
176 | 176 | function give_v132_upgrade_give_payment_customer_id() { |
177 | 177 | global $wpdb; |
178 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
179 | - wp_die( __( 'You do not have permission to do Give upgrades', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
178 | + if ( ! current_user_can('manage_give_settings')) { |
|
179 | + wp_die(__('You do not have permission to do Give upgrades', 'give'), __('Error', 'give'), array('response' => 403)); |
|
180 | 180 | } |
181 | 181 | |
182 | - ignore_user_abort( true ); |
|
182 | + ignore_user_abort(true); |
|
183 | 183 | |
184 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
185 | - @set_time_limit( 0 ); |
|
184 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
185 | + @set_time_limit(0); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | //UPDATE DB METAKEYS |
189 | 189 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
190 | - $query = $wpdb->query( $sql ); |
|
190 | + $query = $wpdb->query($sql); |
|
191 | 191 | |
192 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
193 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
194 | - delete_option( 'give_doing_upgrade' ); |
|
195 | - wp_redirect( admin_url() ); |
|
192 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
193 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
194 | + delete_option('give_doing_upgrade'); |
|
195 | + wp_redirect(admin_url()); |
|
196 | 196 | exit; |
197 | 197 | |
198 | 198 | |
199 | 199 | } |
200 | 200 | |
201 | -add_action( 'give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id' ); |
|
201 | +add_action('give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id'); |
|
202 | 202 | |
203 | 203 | /** |
204 | 204 | * Upgrades the Offline Status |
@@ -212,14 +212,14 @@ discard block |
||
212 | 212 | |
213 | 213 | global $wpdb; |
214 | 214 | |
215 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
216 | - wp_die( __( 'You do not have permission to do Give upgrades', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
215 | + if ( ! current_user_can('manage_give_settings')) { |
|
216 | + wp_die(__('You do not have permission to do Give upgrades', 'give'), __('Error', 'give'), array('response' => 403)); |
|
217 | 217 | } |
218 | 218 | |
219 | - ignore_user_abort( true ); |
|
219 | + ignore_user_abort(true); |
|
220 | 220 | |
221 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
222 | - @set_time_limit( 0 ); |
|
221 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
222 | + @set_time_limit(0); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | // Get abandoned offline payments |
@@ -229,32 +229,32 @@ discard block |
||
229 | 229 | $where .= "AND ( p.post_status = 'abandoned' )"; |
230 | 230 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
231 | 231 | |
232 | - $sql = $select . $join . $where; |
|
233 | - $found_payments = $wpdb->get_col( $sql ); |
|
232 | + $sql = $select.$join.$where; |
|
233 | + $found_payments = $wpdb->get_col($sql); |
|
234 | 234 | |
235 | 235 | |
236 | - foreach ( $found_payments as $payment ) { |
|
236 | + foreach ($found_payments as $payment) { |
|
237 | 237 | |
238 | 238 | //Only change ones marked abandoned since our release last week |
239 | 239 | //because the admin may have marked some abandoned themselves |
240 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
240 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
241 | 241 | |
242 | 242 | //1450124863 = 12/10/2015 20:42:25 |
243 | - if ( $modified_time >= 1450124863 ) { |
|
243 | + if ($modified_time >= 1450124863) { |
|
244 | 244 | |
245 | - give_update_payment_status( $payment, 'pending' ); |
|
245 | + give_update_payment_status($payment, 'pending'); |
|
246 | 246 | |
247 | 247 | } |
248 | 248 | |
249 | 249 | } |
250 | 250 | |
251 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
252 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
253 | - delete_option( 'give_doing_upgrade' ); |
|
254 | - wp_redirect( admin_url() ); |
|
251 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
252 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
253 | + delete_option('give_doing_upgrade'); |
|
254 | + wp_redirect(admin_url()); |
|
255 | 255 | exit; |
256 | 256 | |
257 | 257 | |
258 | 258 | } |
259 | 259 | |
260 | -add_action( 'give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status' ); |
|
260 | +add_action('give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status'); |
@@ -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 | |
@@ -28,66 +28,66 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return void |
30 | 30 | */ |
31 | -function give_complete_purchase( $payment_id, $new_status, $old_status ) { |
|
32 | - if ( $old_status == 'publish' || $old_status == 'complete' ) { |
|
31 | +function give_complete_purchase($payment_id, $new_status, $old_status) { |
|
32 | + if ($old_status == 'publish' || $old_status == 'complete') { |
|
33 | 33 | return; |
34 | 34 | } // Make sure that payments are only completed once |
35 | 35 | |
36 | 36 | // Make sure the payment completion is only processed when new status is complete |
37 | - if ( $new_status != 'publish' && $new_status != 'complete' ) { |
|
37 | + if ($new_status != 'publish' && $new_status != 'complete') { |
|
38 | 38 | return; |
39 | 39 | } |
40 | 40 | |
41 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
42 | - $creation_date = get_post_field( 'post_date', $payment_id, 'raw' ); |
|
43 | - $completed_date = give_get_payment_completed_date( $payment_id ); |
|
44 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
45 | - $donor_id = give_get_payment_customer_id( $payment_id ); |
|
46 | - $amount = give_get_payment_amount( $payment_id ); |
|
41 | + $payment_meta = give_get_payment_meta($payment_id); |
|
42 | + $creation_date = get_post_field('post_date', $payment_id, 'raw'); |
|
43 | + $completed_date = give_get_payment_completed_date($payment_id); |
|
44 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
45 | + $donor_id = give_get_payment_customer_id($payment_id); |
|
46 | + $amount = give_get_payment_amount($payment_id); |
|
47 | 47 | |
48 | - do_action( 'give_pre_complete_purchase', $payment_id ); |
|
48 | + do_action('give_pre_complete_purchase', $payment_id); |
|
49 | 49 | |
50 | - $price_id = isset( $_POST['give-price-id'] ) ? (int) $_POST['give-price-id'] : false; |
|
50 | + $price_id = isset($_POST['give-price-id']) ? (int) $_POST['give-price-id'] : false; |
|
51 | 51 | |
52 | 52 | // Ensure these actions only run once, ever |
53 | - if ( empty( $completed_date ) ) { |
|
53 | + if (empty($completed_date)) { |
|
54 | 54 | |
55 | - if ( ! give_is_test_mode() || apply_filters( 'give_log_test_payment_stats', false ) ) { |
|
55 | + if ( ! give_is_test_mode() || apply_filters('give_log_test_payment_stats', false)) { |
|
56 | 56 | |
57 | - give_record_sale_in_log( $payment_meta['form_id'], $payment_id, $price_id, $creation_date ); |
|
58 | - give_increase_purchase_count( $payment_meta['form_id'] ); |
|
59 | - give_increase_earnings( $payment_meta['form_id'], $amount ); |
|
57 | + give_record_sale_in_log($payment_meta['form_id'], $payment_id, $price_id, $creation_date); |
|
58 | + give_increase_purchase_count($payment_meta['form_id']); |
|
59 | + give_increase_earnings($payment_meta['form_id'], $amount); |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | |
63 | - do_action( 'give_complete_form_donation', $payment_meta['form_id'], $payment_id, $payment_meta ); |
|
63 | + do_action('give_complete_form_donation', $payment_meta['form_id'], $payment_id, $payment_meta); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
67 | 67 | // Clear the total earnings cache |
68 | - delete_transient( 'give_earnings_total' ); |
|
68 | + delete_transient('give_earnings_total'); |
|
69 | 69 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
70 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
71 | - delete_transient( md5( 'give_earnings_todaytoday' ) ); |
|
70 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
71 | + delete_transient(md5('give_earnings_todaytoday')); |
|
72 | 72 | |
73 | 73 | |
74 | 74 | // Increase the donor's purchase stats |
75 | - Give()->customers->increment_stats( $donor_id, $amount ); |
|
75 | + Give()->customers->increment_stats($donor_id, $amount); |
|
76 | 76 | |
77 | - give_increase_total_earnings( $amount ); |
|
77 | + give_increase_total_earnings($amount); |
|
78 | 78 | |
79 | 79 | // Ensure this action only runs once ever |
80 | - if ( empty( $completed_date ) ) { |
|
80 | + if (empty($completed_date)) { |
|
81 | 81 | |
82 | 82 | // Save the completed date |
83 | - give_update_payment_meta( $payment_id, '_give_completed_date', current_time( 'mysql' ) ); |
|
83 | + give_update_payment_meta($payment_id, '_give_completed_date', current_time('mysql')); |
|
84 | 84 | |
85 | - do_action( 'give_complete_purchase', $payment_id ); |
|
85 | + do_action('give_complete_purchase', $payment_id); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | } |
89 | 89 | |
90 | -add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 ); |
|
90 | +add_action('give_update_payment_status', 'give_complete_purchase', 100, 3); |
|
91 | 91 | |
92 | 92 | |
93 | 93 | /** |
@@ -101,19 +101,19 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return void |
103 | 103 | */ |
104 | -function give_record_status_change( $payment_id, $new_status, $old_status ) { |
|
104 | +function give_record_status_change($payment_id, $new_status, $old_status) { |
|
105 | 105 | |
106 | 106 | // Get the list of statuses so that status in the payment note can be translated |
107 | 107 | $stati = give_get_payment_statuses(); |
108 | - $old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status; |
|
109 | - $new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status; |
|
108 | + $old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status; |
|
109 | + $new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status; |
|
110 | 110 | |
111 | - $status_change = sprintf( __( 'Status changed from %s to %s', 'give' ), $old_status, $new_status ); |
|
111 | + $status_change = sprintf(__('Status changed from %s to %s', 'give'), $old_status, $new_status); |
|
112 | 112 | |
113 | - give_insert_payment_note( $payment_id, $status_change ); |
|
113 | + give_insert_payment_note($payment_id, $status_change); |
|
114 | 114 | } |
115 | 115 | |
116 | -add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 ); |
|
116 | +add_action('give_update_payment_status', 'give_record_status_change', 100, 3); |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Reduces earnings and donation stats when a donation is refunded |
@@ -126,40 +126,40 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return void |
128 | 128 | */ |
129 | -function give_undo_donation_on_refund( $payment_id, $new_status, $old_status ) { |
|
129 | +function give_undo_donation_on_refund($payment_id, $new_status, $old_status) { |
|
130 | 130 | |
131 | - if ( 'publish' != $old_status && 'revoked' != $old_status ) { |
|
131 | + if ('publish' != $old_status && 'revoked' != $old_status) { |
|
132 | 132 | return; |
133 | 133 | } |
134 | 134 | |
135 | - if ( 'refunded' != $new_status ) { |
|
135 | + if ('refunded' != $new_status) { |
|
136 | 136 | return; |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Set necessary vars |
140 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
141 | - $amount = give_get_payment_amount( $payment_id ); |
|
140 | + $payment_meta = give_get_payment_meta($payment_id); |
|
141 | + $amount = give_get_payment_amount($payment_id); |
|
142 | 142 | |
143 | 143 | // Undo this purchase |
144 | - give_undo_purchase( $payment_meta['form_id'], $payment_id ); |
|
144 | + give_undo_purchase($payment_meta['form_id'], $payment_id); |
|
145 | 145 | |
146 | 146 | // Decrease total earnings |
147 | - give_decrease_total_earnings( $amount ); |
|
147 | + give_decrease_total_earnings($amount); |
|
148 | 148 | |
149 | 149 | // Decrement the stats for the donor |
150 | - $donor_id = give_get_payment_customer_id( $payment_id ); |
|
150 | + $donor_id = give_get_payment_customer_id($payment_id); |
|
151 | 151 | |
152 | - if ( $donor_id ) { |
|
152 | + if ($donor_id) { |
|
153 | 153 | |
154 | - Give()->customers->decrement_stats( $donor_id, $amount ); |
|
154 | + Give()->customers->decrement_stats($donor_id, $amount); |
|
155 | 155 | |
156 | 156 | } |
157 | 157 | |
158 | 158 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
159 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
159 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
160 | 160 | } |
161 | 161 | |
162 | -add_action( 'give_update_payment_status', 'give_undo_donation_on_refund', 100, 3 ); |
|
162 | +add_action('give_update_payment_status', 'give_undo_donation_on_refund', 100, 3); |
|
163 | 163 | |
164 | 164 | |
165 | 165 | /** |
@@ -172,13 +172,13 @@ discard block |
||
172 | 172 | * @param $new_status the status of the payment, probably "publish" |
173 | 173 | * @param $old_status the status of the payment prior to being marked as "complete", probably "pending" |
174 | 174 | */ |
175 | -function give_clear_user_history_cache( $payment_id, $new_status, $old_status ) { |
|
176 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
175 | +function give_clear_user_history_cache($payment_id, $new_status, $old_status) { |
|
176 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
177 | 177 | |
178 | - delete_transient( 'give_user_' . $user_info['id'] . '_purchases' ); |
|
178 | + delete_transient('give_user_'.$user_info['id'].'_purchases'); |
|
179 | 179 | } |
180 | 180 | |
181 | -add_action( 'give_update_payment_status', 'give_clear_user_history_cache', 10, 3 ); |
|
181 | +add_action('give_update_payment_status', 'give_clear_user_history_cache', 10, 3); |
|
182 | 182 | |
183 | 183 | /** |
184 | 184 | * Updates all old payments, prior to 1.2, with new |
@@ -192,32 +192,32 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @return void |
194 | 194 | */ |
195 | -function give_update_old_payments_with_totals( $data ) { |
|
196 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) { |
|
195 | +function give_update_old_payments_with_totals($data) { |
|
196 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) { |
|
197 | 197 | return; |
198 | 198 | } |
199 | 199 | |
200 | - if ( get_option( 'give_payment_totals_upgraded' ) ) { |
|
200 | + if (get_option('give_payment_totals_upgraded')) { |
|
201 | 201 | return; |
202 | 202 | } |
203 | 203 | |
204 | - $payments = give_get_payments( array( |
|
204 | + $payments = give_get_payments(array( |
|
205 | 205 | 'offset' => 0, |
206 | - 'number' => - 1, |
|
206 | + 'number' => -1, |
|
207 | 207 | 'mode' => 'all' |
208 | - ) ); |
|
208 | + )); |
|
209 | 209 | |
210 | - if ( $payments ) { |
|
211 | - foreach ( $payments as $payment ) { |
|
212 | - $meta = give_get_payment_meta( $payment->ID ); |
|
213 | - give_update_payment_meta( $payment->ID, '_give_payment_total', $meta['amount'] ); |
|
210 | + if ($payments) { |
|
211 | + foreach ($payments as $payment) { |
|
212 | + $meta = give_get_payment_meta($payment->ID); |
|
213 | + give_update_payment_meta($payment->ID, '_give_payment_total', $meta['amount']); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
217 | - add_option( 'give_payment_totals_upgraded', 1 ); |
|
217 | + add_option('give_payment_totals_upgraded', 1); |
|
218 | 218 | } |
219 | 219 | |
220 | -add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' ); |
|
220 | +add_action('give_upgrade_payments', 'give_update_old_payments_with_totals'); |
|
221 | 221 | |
222 | 222 | /** |
223 | 223 | * Updates week-old+ 'pending' orders to 'abandoned' |
@@ -226,29 +226,29 @@ discard block |
||
226 | 226 | * @return void |
227 | 227 | */ |
228 | 228 | function give_mark_abandoned_donations() { |
229 | - $args = array( |
|
229 | + $args = array( |
|
230 | 230 | 'status' => 'pending', |
231 | - 'number' => - 1, |
|
231 | + 'number' => -1, |
|
232 | 232 | 'fields' => 'ids' |
233 | 233 | ); |
234 | 234 | |
235 | - add_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
235 | + add_filter('posts_where', 'give_filter_where_older_than_week'); |
|
236 | 236 | |
237 | - $payments = give_get_payments( $args ); |
|
237 | + $payments = give_get_payments($args); |
|
238 | 238 | |
239 | - remove_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
239 | + remove_filter('posts_where', 'give_filter_where_older_than_week'); |
|
240 | 240 | |
241 | - if ( $payments ) { |
|
242 | - foreach ( $payments as $payment ) { |
|
243 | - $gateway = give_get_payment_gateway( $payment ); |
|
241 | + if ($payments) { |
|
242 | + foreach ($payments as $payment) { |
|
243 | + $gateway = give_get_payment_gateway($payment); |
|
244 | 244 | //Skip offline gateway payments |
245 | - if ( $gateway == 'offline' ) { |
|
245 | + if ($gateway == 'offline') { |
|
246 | 246 | continue; |
247 | 247 | } |
248 | 248 | //Non-offline get marked as 'abandoned' |
249 | - give_update_payment_status( $payment, 'abandoned' ); |
|
249 | + give_update_payment_status($payment, 'abandoned'); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
254 | -add_action( 'give_weekly_scheduled_events', 'give_mark_abandoned_donations' ); |
|
255 | 254 | \ No newline at end of file |
255 | +add_action('give_weekly_scheduled_events', 'give_mark_abandoned_donations'); |
|
256 | 256 | \ No newline at end of file |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | function give_system_info_callback() { |
26 | 26 | |
27 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
27 | + if ( ! current_user_can('manage_give_settings')) { |
|
28 | 28 | return; |
29 | 29 | } |
30 | 30 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | <textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" name="give-sysinfo" title="To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac)."><?php echo give_tools_sysinfo_get(); ?></textarea> |
33 | 33 | <p class="submit"> |
34 | 34 | <input type="hidden" name="give-action" value="download_sysinfo" /> |
35 | - <?php submit_button( 'Download System Info File', 'secondary', 'give-download-sysinfo', false ); ?> |
|
35 | + <?php submit_button('Download System Info File', 'secondary', 'give-download-sysinfo', false); ?> |
|
36 | 36 | </p> |
37 | 37 | <style> |
38 | 38 | .give_forms_page_give-settings .give-submit-wrap { |
@@ -55,63 +55,63 @@ discard block |
||
55 | 55 | function give_tools_sysinfo_get() { |
56 | 56 | global $wpdb, $give_options; |
57 | 57 | |
58 | - if ( ! class_exists( 'Browser' ) ) { |
|
59 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/browser.php'; |
|
58 | + if ( ! class_exists('Browser')) { |
|
59 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/browser.php'; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $browser = new Browser(); |
63 | 63 | |
64 | 64 | // Get theme info |
65 | - if ( get_bloginfo( 'version' ) < '3.4' ) { |
|
66 | - $theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' ); |
|
67 | - $theme = $theme_data['Name'] . ' ' . $theme_data['Version']; |
|
65 | + if (get_bloginfo('version') < '3.4') { |
|
66 | + $theme_data = get_theme_data(get_stylesheet_directory().'/style.css'); |
|
67 | + $theme = $theme_data['Name'].' '.$theme_data['Version']; |
|
68 | 68 | } else { |
69 | 69 | $theme_data = wp_get_theme(); |
70 | - $theme = $theme_data->Name . ' ' . $theme_data->Version; |
|
70 | + $theme = $theme_data->Name.' '.$theme_data->Version; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | // Try to identify the hosting provider |
74 | 74 | $host = give_get_host(); |
75 | 75 | |
76 | - $return = '### Begin System Info ###' . "\n\n"; |
|
76 | + $return = '### Begin System Info ###'."\n\n"; |
|
77 | 77 | |
78 | 78 | // Start with the basics... |
79 | - $return .= '-- Site Info' . "\n\n"; |
|
80 | - $return .= 'Site URL: ' . site_url() . "\n"; |
|
81 | - $return .= 'Home URL: ' . home_url() . "\n"; |
|
82 | - $return .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n"; |
|
79 | + $return .= '-- Site Info'."\n\n"; |
|
80 | + $return .= 'Site URL: '.site_url()."\n"; |
|
81 | + $return .= 'Home URL: '.home_url()."\n"; |
|
82 | + $return .= 'Multisite: '.(is_multisite() ? 'Yes' : 'No')."\n"; |
|
83 | 83 | |
84 | - $return = apply_filters( 'give_sysinfo_after_site_info', $return ); |
|
84 | + $return = apply_filters('give_sysinfo_after_site_info', $return); |
|
85 | 85 | |
86 | 86 | // Can we determine the site's host? |
87 | - if ( $host ) { |
|
88 | - $return .= "\n" . '-- Hosting Provider' . "\n\n"; |
|
89 | - $return .= 'Host: ' . $host . "\n"; |
|
87 | + if ($host) { |
|
88 | + $return .= "\n".'-- Hosting Provider'."\n\n"; |
|
89 | + $return .= 'Host: '.$host."\n"; |
|
90 | 90 | |
91 | - $return = apply_filters( 'give_sysinfo_after_host_info', $return ); |
|
91 | + $return = apply_filters('give_sysinfo_after_host_info', $return); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | // The local users' browser information, handled by the Browser class |
95 | - $return .= "\n" . '-- User Browser' . "\n\n"; |
|
95 | + $return .= "\n".'-- User Browser'."\n\n"; |
|
96 | 96 | $return .= $browser; |
97 | 97 | |
98 | - $return = apply_filters( 'give_sysinfo_after_user_browser', $return ); |
|
98 | + $return = apply_filters('give_sysinfo_after_user_browser', $return); |
|
99 | 99 | |
100 | 100 | // WordPress configuration |
101 | - $return .= "\n" . '-- WordPress Configuration' . "\n\n"; |
|
102 | - $return .= 'Version: ' . get_bloginfo( 'version' ) . "\n"; |
|
103 | - $return .= 'Language: ' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ) . "\n"; |
|
104 | - $return .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n"; |
|
105 | - $return .= 'Active Theme: ' . $theme . "\n"; |
|
106 | - $return .= 'Show On Front: ' . get_option( 'show_on_front' ) . "\n"; |
|
101 | + $return .= "\n".'-- WordPress Configuration'."\n\n"; |
|
102 | + $return .= 'Version: '.get_bloginfo('version')."\n"; |
|
103 | + $return .= 'Language: '.(defined('WPLANG') && WPLANG ? WPLANG : 'en_US')."\n"; |
|
104 | + $return .= 'Permalink Structure: '.(get_option('permalink_structure') ? get_option('permalink_structure') : 'Default')."\n"; |
|
105 | + $return .= 'Active Theme: '.$theme."\n"; |
|
106 | + $return .= 'Show On Front: '.get_option('show_on_front')."\n"; |
|
107 | 107 | |
108 | 108 | // Only show page specs if frontpage is set to 'page' |
109 | - if ( get_option( 'show_on_front' ) == 'page' ) { |
|
110 | - $front_page_id = get_option( 'page_on_front' ); |
|
111 | - $blog_page_id = get_option( 'page_for_posts' ); |
|
109 | + if (get_option('show_on_front') == 'page') { |
|
110 | + $front_page_id = get_option('page_on_front'); |
|
111 | + $blog_page_id = get_option('page_for_posts'); |
|
112 | 112 | |
113 | - $return .= 'Page On Front: ' . ( $front_page_id != 0 ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset' ) . "\n"; |
|
114 | - $return .= 'Page For Posts: ' . ( $blog_page_id != 0 ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset' ) . "\n"; |
|
113 | + $return .= 'Page On Front: '.($front_page_id != 0 ? get_the_title($front_page_id).' (#'.$front_page_id.')' : 'Unset')."\n"; |
|
114 | + $return .= 'Page For Posts: '.($blog_page_id != 0 ? get_the_title($blog_page_id).' (#'.$blog_page_id.')' : 'Unset')."\n"; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | // Make sure wp_remote_post() is working |
@@ -120,200 +120,200 @@ discard block |
||
120 | 120 | $params = array( |
121 | 121 | 'sslverify' => false, |
122 | 122 | 'timeout' => 60, |
123 | - 'user-agent' => 'Give/' . GIVE_VERSION, |
|
123 | + 'user-agent' => 'Give/'.GIVE_VERSION, |
|
124 | 124 | 'body' => $request |
125 | 125 | ); |
126 | 126 | |
127 | - $response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params ); |
|
127 | + $response = wp_remote_post('https://www.paypal.com/cgi-bin/webscr', $params); |
|
128 | 128 | |
129 | - if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
129 | + if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) { |
|
130 | 130 | $WP_REMOTE_POST = 'wp_remote_post() works'; |
131 | 131 | } else { |
132 | 132 | $WP_REMOTE_POST = 'wp_remote_post() does not work'; |
133 | 133 | } |
134 | 134 | |
135 | - $return .= 'Remote Post: ' . $WP_REMOTE_POST . "\n"; |
|
136 | - $return .= 'Table Prefix: ' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n"; |
|
137 | - $return .= 'Admin AJAX: ' . ( give_test_ajax_works() ? 'Accessible' : 'Inaccessible' ) . "\n"; |
|
138 | - $return .= 'WP_DEBUG: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n"; |
|
139 | - $return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n"; |
|
140 | - $return .= 'Registered Post Stati: ' . implode( ', ', get_post_stati() ) . "\n"; |
|
135 | + $return .= 'Remote Post: '.$WP_REMOTE_POST."\n"; |
|
136 | + $return .= 'Table Prefix: '.'Length: '.strlen($wpdb->prefix).' Status: '.(strlen($wpdb->prefix) > 16 ? 'ERROR: Too long' : 'Acceptable')."\n"; |
|
137 | + $return .= 'Admin AJAX: '.(give_test_ajax_works() ? 'Accessible' : 'Inaccessible')."\n"; |
|
138 | + $return .= 'WP_DEBUG: '.(defined('WP_DEBUG') ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set')."\n"; |
|
139 | + $return .= 'Memory Limit: '.WP_MEMORY_LIMIT."\n"; |
|
140 | + $return .= 'Registered Post Stati: '.implode(', ', get_post_stati())."\n"; |
|
141 | 141 | |
142 | - $return = apply_filters( 'give_sysinfo_after_wordpress_config', $return ); |
|
142 | + $return = apply_filters('give_sysinfo_after_wordpress_config', $return); |
|
143 | 143 | |
144 | 144 | // GIVE configuration |
145 | - $return .= "\n" . '-- Give Configuration' . "\n\n"; |
|
146 | - $return .= 'Version: ' . GIVE_VERSION . "\n"; |
|
147 | - $return .= 'Upgraded From: ' . get_option( 'give_version_upgraded_from', 'None' ) . "\n"; |
|
148 | - $return .= 'Test Mode: ' . ( give_is_test_mode() ? "Enabled\n" : "Disabled\n" ); |
|
149 | - $return .= 'Currency Code: ' . give_get_currency() . "\n"; |
|
150 | - $return .= 'Currency Position: ' . give_get_option( 'currency_position', 'before' ) . "\n"; |
|
151 | - $return .= 'Decimal Separator: ' . give_get_option( 'decimal_separator', '.' ) . "\n"; |
|
152 | - $return .= 'Thousands Separator: ' . give_get_option( 'thousands_separator', ',' ) . "\n"; |
|
145 | + $return .= "\n".'-- Give Configuration'."\n\n"; |
|
146 | + $return .= 'Version: '.GIVE_VERSION."\n"; |
|
147 | + $return .= 'Upgraded From: '.get_option('give_version_upgraded_from', 'None')."\n"; |
|
148 | + $return .= 'Test Mode: '.(give_is_test_mode() ? "Enabled\n" : "Disabled\n"); |
|
149 | + $return .= 'Currency Code: '.give_get_currency()."\n"; |
|
150 | + $return .= 'Currency Position: '.give_get_option('currency_position', 'before')."\n"; |
|
151 | + $return .= 'Decimal Separator: '.give_get_option('decimal_separator', '.')."\n"; |
|
152 | + $return .= 'Thousands Separator: '.give_get_option('thousands_separator', ',')."\n"; |
|
153 | 153 | |
154 | - $return = apply_filters( 'give_sysinfo_after_give_config', $return ); |
|
154 | + $return = apply_filters('give_sysinfo_after_give_config', $return); |
|
155 | 155 | |
156 | 156 | // GIVE pages |
157 | - $return .= "\n" . '-- Give Page Configuration' . "\n\n"; |
|
158 | - $return .= 'Success Page: ' . ( ! empty( $give_options['success_page'] ) ? get_permalink( $give_options['success_page'] ) . "\n" : "Unset\n" ); |
|
159 | - $return .= 'Failure Page: ' . ( ! empty( $give_options['failure_page'] ) ? get_permalink( $give_options['failure_page'] ) . "\n" : "Unset\n" ); |
|
160 | - $return .= 'Give Forms Slug: ' . ( defined( 'GIVE_SLUG' ) ? '/' . GIVE_SLUG . "\n" : "/donations\n" ); |
|
157 | + $return .= "\n".'-- Give Page Configuration'."\n\n"; |
|
158 | + $return .= 'Success Page: '.( ! empty($give_options['success_page']) ? get_permalink($give_options['success_page'])."\n" : "Unset\n"); |
|
159 | + $return .= 'Failure Page: '.( ! empty($give_options['failure_page']) ? get_permalink($give_options['failure_page'])."\n" : "Unset\n"); |
|
160 | + $return .= 'Give Forms Slug: '.(defined('GIVE_SLUG') ? '/'.GIVE_SLUG."\n" : "/donations\n"); |
|
161 | 161 | |
162 | - $return = apply_filters( 'give_sysinfo_after_give_pages', $return ); |
|
162 | + $return = apply_filters('give_sysinfo_after_give_pages', $return); |
|
163 | 163 | |
164 | 164 | // GIVE gateways |
165 | - $return .= "\n" . '-- Give Gateway Configuration' . "\n\n"; |
|
165 | + $return .= "\n".'-- Give Gateway Configuration'."\n\n"; |
|
166 | 166 | |
167 | 167 | $active_gateways = give_get_enabled_payment_gateways(); |
168 | - if ( $active_gateways ) { |
|
169 | - $default_gateway_is_active = give_is_gateway_active( give_get_default_gateway( null ) ); |
|
170 | - if ( $default_gateway_is_active ) { |
|
171 | - $default_gateway = give_get_default_gateway( null ); |
|
172 | - $default_gateway = $active_gateways[ $default_gateway ]['admin_label']; |
|
168 | + if ($active_gateways) { |
|
169 | + $default_gateway_is_active = give_is_gateway_active(give_get_default_gateway(null)); |
|
170 | + if ($default_gateway_is_active) { |
|
171 | + $default_gateway = give_get_default_gateway(null); |
|
172 | + $default_gateway = $active_gateways[$default_gateway]['admin_label']; |
|
173 | 173 | } else { |
174 | 174 | $default_gateway = 'Test Payment'; |
175 | 175 | } |
176 | 176 | |
177 | 177 | $gateways = array(); |
178 | - foreach ( $active_gateways as $gateway ) { |
|
178 | + foreach ($active_gateways as $gateway) { |
|
179 | 179 | $gateways[] = $gateway['admin_label']; |
180 | 180 | } |
181 | 181 | |
182 | - $return .= 'Enabled Gateways: ' . implode( ', ', $gateways ) . "\n"; |
|
183 | - $return .= 'Default Gateway: ' . $default_gateway . "\n"; |
|
182 | + $return .= 'Enabled Gateways: '.implode(', ', $gateways)."\n"; |
|
183 | + $return .= 'Default Gateway: '.$default_gateway."\n"; |
|
184 | 184 | } else { |
185 | - $return .= 'Enabled Gateways: None' . "\n"; |
|
185 | + $return .= 'Enabled Gateways: None'."\n"; |
|
186 | 186 | } |
187 | 187 | |
188 | - $return = apply_filters( 'give_sysinfo_after_give_gateways', $return ); |
|
188 | + $return = apply_filters('give_sysinfo_after_give_gateways', $return); |
|
189 | 189 | |
190 | 190 | // GIVE Templates |
191 | - $dir = get_stylesheet_directory() . '/give_templates/*'; |
|
192 | - if ( is_dir( $dir ) && ( count( glob( "$dir/*" ) ) !== 0 ) ) { |
|
193 | - $return .= "\n" . '-- Give Template Overrides' . "\n\n"; |
|
191 | + $dir = get_stylesheet_directory().'/give_templates/*'; |
|
192 | + if (is_dir($dir) && (count(glob("$dir/*")) !== 0)) { |
|
193 | + $return .= "\n".'-- Give Template Overrides'."\n\n"; |
|
194 | 194 | |
195 | - foreach ( glob( $dir ) as $file ) { |
|
196 | - $return .= 'Filename: ' . basename( $file ) . "\n"; |
|
195 | + foreach (glob($dir) as $file) { |
|
196 | + $return .= 'Filename: '.basename($file)."\n"; |
|
197 | 197 | } |
198 | 198 | |
199 | - $return = apply_filters( 'give_sysinfo_after_give_templates', $return ); |
|
199 | + $return = apply_filters('give_sysinfo_after_give_templates', $return); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | // Must-use plugins |
203 | 203 | $muplugins = get_mu_plugins(); |
204 | - if ( count( $muplugins > 0 ) ) { |
|
205 | - $return .= "\n" . '-- Must-Use Plugins' . "\n\n"; |
|
204 | + if (count($muplugins > 0)) { |
|
205 | + $return .= "\n".'-- Must-Use Plugins'."\n\n"; |
|
206 | 206 | |
207 | - foreach ( $muplugins as $plugin => $plugin_data ) { |
|
208 | - $return .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n"; |
|
207 | + foreach ($muplugins as $plugin => $plugin_data) { |
|
208 | + $return .= $plugin_data['Name'].': '.$plugin_data['Version']."\n"; |
|
209 | 209 | } |
210 | 210 | |
211 | - $return = apply_filters( 'give_sysinfo_after_wordpress_mu_plugins', $return ); |
|
211 | + $return = apply_filters('give_sysinfo_after_wordpress_mu_plugins', $return); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | // WordPress active plugins |
215 | - $return .= "\n" . '-- WordPress Active Plugins' . "\n\n"; |
|
215 | + $return .= "\n".'-- WordPress Active Plugins'."\n\n"; |
|
216 | 216 | |
217 | 217 | $plugins = get_plugins(); |
218 | - $active_plugins = get_option( 'active_plugins', array() ); |
|
218 | + $active_plugins = get_option('active_plugins', array()); |
|
219 | 219 | |
220 | - foreach ( $plugins as $plugin_path => $plugin ) { |
|
221 | - if ( ! in_array( $plugin_path, $active_plugins ) ) { |
|
220 | + foreach ($plugins as $plugin_path => $plugin) { |
|
221 | + if ( ! in_array($plugin_path, $active_plugins)) { |
|
222 | 222 | continue; |
223 | 223 | } |
224 | 224 | |
225 | - $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; |
|
225 | + $return .= $plugin['Name'].': '.$plugin['Version']."\n"; |
|
226 | 226 | } |
227 | 227 | |
228 | - $return = apply_filters( 'give_sysinfo_after_wordpress_plugins', $return ); |
|
228 | + $return = apply_filters('give_sysinfo_after_wordpress_plugins', $return); |
|
229 | 229 | |
230 | 230 | // WordPress inactive plugins |
231 | - $return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n"; |
|
231 | + $return .= "\n".'-- WordPress Inactive Plugins'."\n\n"; |
|
232 | 232 | |
233 | - foreach ( $plugins as $plugin_path => $plugin ) { |
|
234 | - if ( in_array( $plugin_path, $active_plugins ) ) { |
|
233 | + foreach ($plugins as $plugin_path => $plugin) { |
|
234 | + if (in_array($plugin_path, $active_plugins)) { |
|
235 | 235 | continue; |
236 | 236 | } |
237 | 237 | |
238 | - $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; |
|
238 | + $return .= $plugin['Name'].': '.$plugin['Version']."\n"; |
|
239 | 239 | } |
240 | 240 | |
241 | - $return = apply_filters( 'give_sysinfo_after_wordpress_plugins_inactive', $return ); |
|
241 | + $return = apply_filters('give_sysinfo_after_wordpress_plugins_inactive', $return); |
|
242 | 242 | |
243 | - if ( is_multisite() ) { |
|
243 | + if (is_multisite()) { |
|
244 | 244 | // WordPress Multisite active plugins |
245 | - $return .= "\n" . '-- Network Active Plugins' . "\n\n"; |
|
245 | + $return .= "\n".'-- Network Active Plugins'."\n\n"; |
|
246 | 246 | |
247 | 247 | $plugins = wp_get_active_network_plugins(); |
248 | - $active_plugins = get_site_option( 'active_sitewide_plugins', array() ); |
|
248 | + $active_plugins = get_site_option('active_sitewide_plugins', array()); |
|
249 | 249 | |
250 | - foreach ( $plugins as $plugin_path ) { |
|
251 | - $plugin_base = plugin_basename( $plugin_path ); |
|
250 | + foreach ($plugins as $plugin_path) { |
|
251 | + $plugin_base = plugin_basename($plugin_path); |
|
252 | 252 | |
253 | - if ( ! array_key_exists( $plugin_base, $active_plugins ) ) { |
|
253 | + if ( ! array_key_exists($plugin_base, $active_plugins)) { |
|
254 | 254 | continue; |
255 | 255 | } |
256 | 256 | |
257 | - $plugin = get_plugin_data( $plugin_path ); |
|
258 | - $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; |
|
257 | + $plugin = get_plugin_data($plugin_path); |
|
258 | + $return .= $plugin['Name'].': '.$plugin['Version']."\n"; |
|
259 | 259 | } |
260 | 260 | |
261 | - $return = apply_filters( 'give_sysinfo_after_wordpress_ms_plugins', $return ); |
|
261 | + $return = apply_filters('give_sysinfo_after_wordpress_ms_plugins', $return); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | // Server configuration (really just versioning) |
265 | - $return .= "\n" . '-- Webserver Configuration' . "\n\n"; |
|
266 | - $return .= 'PHP Version: ' . PHP_VERSION . "\n"; |
|
267 | - $return .= 'MySQL Version: ' . $wpdb->db_version() . "\n"; |
|
268 | - $return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "\n"; |
|
265 | + $return .= "\n".'-- Webserver Configuration'."\n\n"; |
|
266 | + $return .= 'PHP Version: '.PHP_VERSION."\n"; |
|
267 | + $return .= 'MySQL Version: '.$wpdb->db_version()."\n"; |
|
268 | + $return .= 'Webserver Info: '.$_SERVER['SERVER_SOFTWARE']."\n"; |
|
269 | 269 | |
270 | - $return = apply_filters( 'give_sysinfo_after_webserver_config', $return ); |
|
270 | + $return = apply_filters('give_sysinfo_after_webserver_config', $return); |
|
271 | 271 | |
272 | 272 | // PHP configs... now we're getting to the important stuff |
273 | - $return .= "\n" . '-- PHP Configuration' . "\n\n"; |
|
274 | - $return .= 'Safe Mode: ' . ( ini_get( 'safe_mode' ) ? 'Enabled' : 'Disabled' . "\n" ); |
|
275 | - $return .= 'Memory Limit: ' . ini_get( 'memory_limit' ) . "\n"; |
|
276 | - $return .= 'Upload Max Size: ' . ini_get( 'upload_max_filesize' ) . "\n"; |
|
277 | - $return .= 'Post Max Size: ' . ini_get( 'post_max_size' ) . "\n"; |
|
278 | - $return .= 'Upload Max Filesize: ' . ini_get( 'upload_max_filesize' ) . "\n"; |
|
279 | - $return .= 'Time Limit: ' . ini_get( 'max_execution_time' ) . "\n"; |
|
280 | - $return .= 'Max Input Vars: ' . ini_get( 'max_input_vars' ) . "\n"; |
|
281 | - $return .= 'Display Errors: ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n"; |
|
282 | - |
|
283 | - $return = apply_filters( 'give_sysinfo_after_php_config', $return ); |
|
273 | + $return .= "\n".'-- PHP Configuration'."\n\n"; |
|
274 | + $return .= 'Safe Mode: '.(ini_get('safe_mode') ? 'Enabled' : 'Disabled'."\n"); |
|
275 | + $return .= 'Memory Limit: '.ini_get('memory_limit')."\n"; |
|
276 | + $return .= 'Upload Max Size: '.ini_get('upload_max_filesize')."\n"; |
|
277 | + $return .= 'Post Max Size: '.ini_get('post_max_size')."\n"; |
|
278 | + $return .= 'Upload Max Filesize: '.ini_get('upload_max_filesize')."\n"; |
|
279 | + $return .= 'Time Limit: '.ini_get('max_execution_time')."\n"; |
|
280 | + $return .= 'Max Input Vars: '.ini_get('max_input_vars')."\n"; |
|
281 | + $return .= 'Display Errors: '.(ini_get('display_errors') ? 'On ('.ini_get('display_errors').')' : 'N/A')."\n"; |
|
282 | + |
|
283 | + $return = apply_filters('give_sysinfo_after_php_config', $return); |
|
284 | 284 | |
285 | 285 | // PHP extensions and such |
286 | - $return .= "\n" . '-- PHP Extensions' . "\n\n"; |
|
287 | - $return .= 'cURL: ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n"; |
|
286 | + $return .= "\n".'-- PHP Extensions'."\n\n"; |
|
287 | + $return .= 'cURL: '.(function_exists('curl_init') ? 'Supported' : 'Not Supported')."\n"; |
|
288 | 288 | |
289 | 289 | //cURL version |
290 | - if ( function_exists( 'curl_init' ) && function_exists( 'curl_version' ) ) { |
|
290 | + if (function_exists('curl_init') && function_exists('curl_version')) { |
|
291 | 291 | $curl_values = curl_version(); |
292 | - $return .= 'cURL Version: ' . $curl_values["version"] . "\n"; |
|
292 | + $return .= 'cURL Version: '.$curl_values["version"]."\n"; |
|
293 | 293 | } |
294 | - $return .= 'fsockopen: ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n"; |
|
295 | - $return .= 'SOAP Client: ' . ( class_exists( 'SoapClient' ) ? 'Installed' : 'Not Installed' ) . "\n"; |
|
296 | - $return .= 'Suhosin: ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n"; |
|
294 | + $return .= 'fsockopen: '.(function_exists('fsockopen') ? 'Supported' : 'Not Supported')."\n"; |
|
295 | + $return .= 'SOAP Client: '.(class_exists('SoapClient') ? 'Installed' : 'Not Installed')."\n"; |
|
296 | + $return .= 'Suhosin: '.(extension_loaded('suhosin') ? 'Installed' : 'Not Installed')."\n"; |
|
297 | 297 | |
298 | - $return = apply_filters( 'give_sysinfo_after_php_ext', $return ); |
|
298 | + $return = apply_filters('give_sysinfo_after_php_ext', $return); |
|
299 | 299 | |
300 | 300 | // Session stuff |
301 | - $return .= "\n" . '-- Session Configuration' . "\n\n"; |
|
302 | - $return .= 'Give Use Sessions: ' . ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ? 'Enforced' : ( Give()->session->use_php_sessions() ? 'Enabled' : 'Disabled' ) ) . "\n"; |
|
303 | - $return .= 'Session: ' . ( isset( $_SESSION ) ? 'Enabled' : 'Disabled' ) . "\n"; |
|
301 | + $return .= "\n".'-- Session Configuration'."\n\n"; |
|
302 | + $return .= 'Give Use Sessions: '.(defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS ? 'Enforced' : (Give()->session->use_php_sessions() ? 'Enabled' : 'Disabled'))."\n"; |
|
303 | + $return .= 'Session: '.(isset($_SESSION) ? 'Enabled' : 'Disabled')."\n"; |
|
304 | 304 | |
305 | 305 | // The rest of this is only relevant is session is enabled |
306 | - if ( isset( $_SESSION ) ) { |
|
307 | - $return .= 'Session Name: ' . esc_html( ini_get( 'session.name' ) ) . "\n"; |
|
308 | - $return .= 'Cookie Path: ' . esc_html( ini_get( 'session.cookie_path' ) ) . "\n"; |
|
309 | - $return .= 'Save Path: ' . esc_html( ini_get( 'session.save_path' ) ) . "\n"; |
|
310 | - $return .= 'Use Cookies: ' . ( ini_get( 'session.use_cookies' ) ? 'On' : 'Off' ) . "\n"; |
|
311 | - $return .= 'Use Only Cookies: ' . ( ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off' ) . "\n"; |
|
306 | + if (isset($_SESSION)) { |
|
307 | + $return .= 'Session Name: '.esc_html(ini_get('session.name'))."\n"; |
|
308 | + $return .= 'Cookie Path: '.esc_html(ini_get('session.cookie_path'))."\n"; |
|
309 | + $return .= 'Save Path: '.esc_html(ini_get('session.save_path'))."\n"; |
|
310 | + $return .= 'Use Cookies: '.(ini_get('session.use_cookies') ? 'On' : 'Off')."\n"; |
|
311 | + $return .= 'Use Only Cookies: '.(ini_get('session.use_only_cookies') ? 'On' : 'Off')."\n"; |
|
312 | 312 | } |
313 | 313 | |
314 | - $return = apply_filters( 'give_sysinfo_after_session_config', $return ); |
|
314 | + $return = apply_filters('give_sysinfo_after_session_config', $return); |
|
315 | 315 | |
316 | - $return .= "\n" . '### End System Info ###'; |
|
316 | + $return .= "\n".'### End System Info ###'; |
|
317 | 317 | |
318 | 318 | return $return; |
319 | 319 | } |
@@ -327,17 +327,17 @@ discard block |
||
327 | 327 | */ |
328 | 328 | function give_tools_sysinfo_download() { |
329 | 329 | |
330 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
330 | + if ( ! current_user_can('manage_give_settings')) { |
|
331 | 331 | return; |
332 | 332 | } |
333 | 333 | |
334 | 334 | nocache_headers(); |
335 | 335 | |
336 | - header( 'Content-Type: text/plain' ); |
|
337 | - header( 'Content-Disposition: attachment; filename="give-system-info.txt"' ); |
|
336 | + header('Content-Type: text/plain'); |
|
337 | + header('Content-Disposition: attachment; filename="give-system-info.txt"'); |
|
338 | 338 | |
339 | - echo wp_strip_all_tags( $_POST['give-sysinfo'] ); |
|
339 | + echo wp_strip_all_tags($_POST['give-sysinfo']); |
|
340 | 340 | give_die(); |
341 | 341 | } |
342 | 342 | |
343 | -add_action( 'give_download_sysinfo', 'give_tools_sysinfo_download' ); |
|
344 | 343 | \ No newline at end of file |
344 | +add_action('give_download_sysinfo', 'give_tools_sysinfo_download'); |
|
345 | 345 | \ No newline at end of file |
@@ -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 | |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | function give_add_ons_page() { |
26 | 26 | ob_start(); ?> |
27 | 27 | <div class="wrap" id="give-add-ons"> |
28 | - <h2><?php _e( 'Give Add-ons', 'give' ); ?> |
|
29 | - — <a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" title="<?php _e( 'Browse All Add-ons', 'give' ); ?>" target="_blank"><?php _e( 'View All Add-ons', 'give' ); ?> |
|
28 | + <h2><?php _e('Give Add-ons', 'give'); ?> |
|
29 | + — <a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" title="<?php _e('Browse All Add-ons', 'give'); ?>" target="_blank"><?php _e('View All Add-ons', 'give'); ?> |
|
30 | 30 | <span class="dashicons dashicons-external"></span></a> |
31 | 31 | </h2> |
32 | 32 | |
33 | - <p><?php _e( 'The following Add-ons extend the functionality of Give.', 'give' ); ?></p> |
|
33 | + <p><?php _e('The following Add-ons extend the functionality of Give.', 'give'); ?></p> |
|
34 | 34 | <?php echo give_add_ons_get_feed(); ?> |
35 | 35 | </div> |
36 | 36 | <?php |
@@ -48,18 +48,18 @@ discard block |
||
48 | 48 | function give_add_ons_get_feed() { |
49 | 49 | |
50 | 50 | $addons_debug = false; //set to true to debug |
51 | - $cache = get_transient( 'give_add_ons_feed' ); |
|
51 | + $cache = get_transient('give_add_ons_feed'); |
|
52 | 52 | |
53 | - if ( $cache === false || $addons_debug === true && WP_DEBUG === true ) { |
|
54 | - $feed = wp_remote_get( 'https://givewp.com/downloads/feed/', array( 'sslverify' => false ) ); |
|
53 | + if ($cache === false || $addons_debug === true && WP_DEBUG === true) { |
|
54 | + $feed = wp_remote_get('https://givewp.com/downloads/feed/', array('sslverify' => false)); |
|
55 | 55 | |
56 | - if ( ! is_wp_error( $feed ) ) { |
|
57 | - if ( isset( $feed['body'] ) && strlen( $feed['body'] ) > 0 ) { |
|
58 | - $cache = wp_remote_retrieve_body( $feed ); |
|
59 | - set_transient( 'give_add_ons_feed', $cache, 3600 ); |
|
56 | + if ( ! is_wp_error($feed)) { |
|
57 | + if (isset($feed['body']) && strlen($feed['body']) > 0) { |
|
58 | + $cache = wp_remote_retrieve_body($feed); |
|
59 | + set_transient('give_add_ons_feed', $cache, 3600); |
|
60 | 60 | } |
61 | 61 | } else { |
62 | - $cache = '<div class="error"><p>' . __( 'There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give' ) . '</div>'; |
|
62 | + $cache = '<div class="error"><p>'.__('There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give').'</div>'; |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 |
@@ -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 | 24 | 'admin_label' => 'Offline Donation', |
25 | - 'checkout_label' => __( 'Offline Donation', 'give' ) |
|
25 | + 'checkout_label' => __('Offline Donation', 'give') |
|
26 | 26 | ); |
27 | 27 | |
28 | 28 | return $gateways; |
29 | 29 | } |
30 | 30 | |
31 | -add_filter( 'give_payment_gateways', 'give_offline_register_gateway', 1 ); |
|
31 | +add_filter('give_payment_gateways', 'give_offline_register_gateway', 1); |
|
32 | 32 | |
33 | 33 | |
34 | 34 | /** |
@@ -40,48 +40,48 @@ 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 | |
54 | 54 | |
55 | 55 | ob_start(); ?> |
56 | - <?php do_action( 'give_before_offline_info_fields', $form_id ); ?> |
|
56 | + <?php do_action('give_before_offline_info_fields', $form_id); ?> |
|
57 | 57 | <fieldset id="give_offline_payment_info"> |
58 | 58 | <?php |
59 | - $settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' ); |
|
60 | - $offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( __( 'Please enter offline donation instructions in the %s.', 'give' ), '<a href="' . $settings_url . '">' . __( 'this form\'s settings', 'give' ) . '</a>' ); |
|
61 | - echo wpautop( stripslashes( $offline_instructions ) ); |
|
59 | + $settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1'); |
|
60 | + $offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(__('Please enter offline donation instructions in the %s.', 'give'), '<a href="'.$settings_url.'">'.__('this form\'s settings', 'give').'</a>'); |
|
61 | + echo wpautop(stripslashes($offline_instructions)); |
|
62 | 62 | ?> |
63 | 63 | </fieldset> |
64 | - <?php do_action( 'give_after_offline_info_fields', $form_id ); ?> |
|
64 | + <?php do_action('give_after_offline_info_fields', $form_id); ?> |
|
65 | 65 | <?php |
66 | 66 | echo ob_get_clean(); |
67 | 67 | } |
68 | 68 | |
69 | -add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' ); |
|
69 | +add_action('give_offline_cc_form', 'give_offline_payment_cc_form'); |
|
70 | 70 | |
71 | 71 | |
72 | 72 | |
73 | -function give_offline_billing_fields($form_id){ |
|
73 | +function give_offline_billing_fields($form_id) { |
|
74 | 74 | //Enable Default CC fields (billing info) |
75 | - $post_offline_cc_fields = get_post_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true ); |
|
76 | - $global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' ); |
|
75 | + $post_offline_cc_fields = get_post_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true); |
|
76 | + $global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields'); |
|
77 | 77 | |
78 | 78 | |
79 | - if ( $global_offline_cc_fields == 'on' || $post_offline_cc_fields == 'on' ) { |
|
80 | - give_default_cc_address_fields( $form_id ); |
|
79 | + if ($global_offline_cc_fields == 'on' || $post_offline_cc_fields == 'on') { |
|
80 | + give_default_cc_address_fields($form_id); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | -add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 ); |
|
84 | +add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1); |
|
85 | 85 | |
86 | 86 | /** |
87 | 87 | * Process the payment |
@@ -89,15 +89,15 @@ discard block |
||
89 | 89 | * @since 1.0 |
90 | 90 | * @return void |
91 | 91 | */ |
92 | -function give_offline_process_payment( $purchase_data ) { |
|
92 | +function give_offline_process_payment($purchase_data) { |
|
93 | 93 | |
94 | - $purchase_summary = give_get_purchase_summary( $purchase_data ); |
|
94 | + $purchase_summary = give_get_purchase_summary($purchase_data); |
|
95 | 95 | |
96 | 96 | // setup the payment details |
97 | 97 | $payment_data = array( |
98 | 98 | 'price' => $purchase_data['price'], |
99 | 99 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
100 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
100 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
101 | 101 | 'date' => $purchase_data['date'], |
102 | 102 | 'user_email' => $purchase_data['user_email'], |
103 | 103 | 'purchase_key' => $purchase_data['purchase_key'], |
@@ -109,20 +109,20 @@ discard block |
||
109 | 109 | |
110 | 110 | |
111 | 111 | // record the pending payment |
112 | - $payment = give_insert_payment( $payment_data ); |
|
112 | + $payment = give_insert_payment($payment_data); |
|
113 | 113 | |
114 | - if ( $payment ) { |
|
115 | - give_offline_send_admin_notice( $payment ); |
|
116 | - give_offline_send_donor_instructions( $payment ); |
|
114 | + if ($payment) { |
|
115 | + give_offline_send_admin_notice($payment); |
|
116 | + give_offline_send_donor_instructions($payment); |
|
117 | 117 | give_send_to_success_page(); |
118 | 118 | } else { |
119 | 119 | // if errors are present, send the user back to the donation form so they can be corrected |
120 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
120 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | } |
124 | 124 | |
125 | -add_action( 'give_gateway_offline', 'give_offline_process_payment' ); |
|
125 | +add_action('give_gateway_offline', 'give_offline_process_payment'); |
|
126 | 126 | |
127 | 127 | |
128 | 128 | /** |
@@ -135,47 +135,47 @@ discard block |
||
135 | 135 | * @since 1.0 |
136 | 136 | * @return void |
137 | 137 | */ |
138 | -function give_offline_send_donor_instructions( $payment_id = 0 ) { |
|
138 | +function give_offline_send_donor_instructions($payment_id = 0) { |
|
139 | 139 | |
140 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
141 | - $post_offline_customization_option = get_post_meta( $payment_data['form_id'], '_give_customize_offline_donations', true ); |
|
140 | + $payment_data = give_get_payment_meta($payment_id); |
|
141 | + $post_offline_customization_option = get_post_meta($payment_data['form_id'], '_give_customize_offline_donations', true); |
|
142 | 142 | |
143 | 143 | //Customize email content depending on whether the single form has been customized |
144 | - $email_content = give_get_option( 'global_offline_donation_email' ); |
|
144 | + $email_content = give_get_option('global_offline_donation_email'); |
|
145 | 145 | |
146 | - if ( $post_offline_customization_option === 'yes' ) { |
|
147 | - $email_content = get_post_meta( $payment_data['form_id'], '_give_offline_donation_email', true ); |
|
146 | + if ($post_offline_customization_option === 'yes') { |
|
147 | + $email_content = get_post_meta($payment_data['form_id'], '_give_offline_donation_email', true); |
|
148 | 148 | } |
149 | 149 | |
150 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
151 | - $from_name = apply_filters( 'give_purchase_from_name', $from_name, $payment_id, $payment_data ); |
|
150 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
151 | + $from_name = apply_filters('give_purchase_from_name', $from_name, $payment_id, $payment_data); |
|
152 | 152 | |
153 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
154 | - $from_email = apply_filters( 'give_purchase_from_address', $from_email, $payment_id, $payment_data ); |
|
153 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
154 | + $from_email = apply_filters('give_purchase_from_address', $from_email, $payment_id, $payment_data); |
|
155 | 155 | |
156 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
156 | + $to_email = give_get_payment_user_email($payment_id); |
|
157 | 157 | |
158 | - $subject = give_get_option( 'offline_donation_subject', __( 'Offline Donation Instructions', 'give' ) ); |
|
159 | - if ( $post_offline_customization_option === 'yes' ) { |
|
160 | - $subject = get_post_meta( $payment_data['form_id'], '_give_offline_donation_subject', true ); |
|
158 | + $subject = give_get_option('offline_donation_subject', __('Offline Donation Instructions', 'give')); |
|
159 | + if ($post_offline_customization_option === 'yes') { |
|
160 | + $subject = get_post_meta($payment_data['form_id'], '_give_offline_donation_subject', true); |
|
161 | 161 | } |
162 | 162 | |
163 | - $subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
164 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
163 | + $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
164 | + $subject = give_do_email_tags($subject, $payment_id); |
|
165 | 165 | |
166 | - $attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data ); |
|
167 | - $message = give_do_email_tags( $email_content, $payment_id ); |
|
166 | + $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data); |
|
167 | + $message = give_do_email_tags($email_content, $payment_id); |
|
168 | 168 | |
169 | 169 | $emails = Give()->emails; |
170 | 170 | |
171 | - $emails->__set( 'from_name', $from_name ); |
|
172 | - $emails->__set( 'from_email', $from_email ); |
|
173 | - $emails->__set( 'heading', __( 'Offline Donation Instructions', 'give' ) ); |
|
171 | + $emails->__set('from_name', $from_name); |
|
172 | + $emails->__set('from_email', $from_email); |
|
173 | + $emails->__set('heading', __('Offline Donation Instructions', 'give')); |
|
174 | 174 | |
175 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
176 | - $emails->__set( 'headers', $headers ); |
|
175 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
176 | + $emails->__set('headers', $headers); |
|
177 | 177 | |
178 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
178 | + $emails->send($to_email, $subject, $message, $attachments); |
|
179 | 179 | |
180 | 180 | } |
181 | 181 | |
@@ -192,37 +192,37 @@ discard block |
||
192 | 192 | * @return void |
193 | 193 | * |
194 | 194 | */ |
195 | -function give_offline_send_admin_notice( $payment_id = 0 ) { |
|
195 | +function give_offline_send_admin_notice($payment_id = 0) { |
|
196 | 196 | |
197 | 197 | /* Send an email notification to the admin */ |
198 | 198 | $admin_email = give_get_admin_notice_emails(); |
199 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
199 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
200 | 200 | |
201 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
202 | - $user_data = get_userdata( $user_info['id'] ); |
|
201 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
202 | + $user_data = get_userdata($user_info['id']); |
|
203 | 203 | $name = $user_data->display_name; |
204 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
205 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
204 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
205 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
206 | 206 | } else { |
207 | 207 | $name = $user_info['email']; |
208 | 208 | } |
209 | 209 | |
210 | - $amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ); |
|
210 | + $amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))); |
|
211 | 211 | |
212 | - $admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', __( 'New Pending Donation', 'give' ), $payment_id ); |
|
212 | + $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', __('New Pending Donation', 'give'), $payment_id); |
|
213 | 213 | |
214 | - $admin_message = __( 'Dear Admin,', 'give' ) . "\n\n" . __( 'An offline donation has been made', 'give' ) . ".\n\n"; |
|
214 | + $admin_message = __('Dear Admin,', 'give')."\n\n".__('An offline donation has been made', 'give').".\n\n"; |
|
215 | 215 | |
216 | - $order_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ); |
|
217 | - $admin_message .= __( 'Donor: ', 'give' ) . " " . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n"; |
|
218 | - $admin_message .= __( 'Amount: ', 'give' ) . " " . html_entity_decode( $amount, ENT_COMPAT, 'UTF-8' ) . "\n\n"; |
|
219 | - $admin_message .= __( 'There is a new pending donation 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"; |
|
220 | - $admin_message .= sprintf( __( 'View Donation Details: %s.', 'give' ), $order_url ) . "\n\n"; |
|
221 | - $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
|
222 | - $admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id ); |
|
223 | - $attachments = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id ); |
|
216 | + $order_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment_id); |
|
217 | + $admin_message .= __('Donor: ', 'give')." ".html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n"; |
|
218 | + $admin_message .= __('Amount: ', 'give')." ".html_entity_decode($amount, ENT_COMPAT, 'UTF-8')."\n\n"; |
|
219 | + $admin_message .= __('There is a new pending donation 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"; |
|
220 | + $admin_message .= sprintf(__('View Donation Details: %s.', 'give'), $order_url)."\n\n"; |
|
221 | + $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id); |
|
222 | + $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id); |
|
223 | + $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id); |
|
224 | 224 | |
225 | - wp_mail( $admin_email, $admin_subject, $admin_message, $admin_headers, $attachments ); |
|
225 | + wp_mail($admin_email, $admin_subject, $admin_message, $admin_headers, $attachments); |
|
226 | 226 | |
227 | 227 | } |
228 | 228 | |
@@ -233,15 +233,15 @@ discard block |
||
233 | 233 | * @since 1.0 |
234 | 234 | * @return array |
235 | 235 | */ |
236 | -function give_offline_add_settings( $settings ) { |
|
236 | +function give_offline_add_settings($settings) { |
|
237 | 237 | |
238 | 238 | //Vars |
239 | 239 | $prefix = '_give_'; |
240 | 240 | |
241 | - $is_gateway_active = give_is_gateway_active( 'offline' ); |
|
241 | + $is_gateway_active = give_is_gateway_active('offline'); |
|
242 | 242 | |
243 | 243 | //this gateway isn't active |
244 | - if ( ! $is_gateway_active ) { |
|
244 | + if ( ! $is_gateway_active) { |
|
245 | 245 | //return settings and bounce |
246 | 246 | return $settings; |
247 | 247 | } |
@@ -250,27 +250,27 @@ discard block |
||
250 | 250 | $check_settings = array( |
251 | 251 | |
252 | 252 | array( |
253 | - 'name' => __( 'Customize Offline Donations', 'give' ), |
|
254 | - 'desc' => __( 'If you would like to customize the donation instructions for this specific forms check this option.', 'give' ), |
|
255 | - 'id' => $prefix . 'customize_offline_donations', |
|
253 | + 'name' => __('Customize Offline Donations', 'give'), |
|
254 | + 'desc' => __('If you would like to customize the donation instructions for this specific forms check this option.', 'give'), |
|
255 | + 'id' => $prefix.'customize_offline_donations', |
|
256 | 256 | 'type' => 'radio_inline', |
257 | 257 | 'default' => 'no', |
258 | 258 | 'options' => array( |
259 | - 'yes' => __( 'Yes', 'give' ), |
|
260 | - 'no' => __( 'No', 'give' ), |
|
259 | + 'yes' => __('Yes', 'give'), |
|
260 | + 'no' => __('No', 'give'), |
|
261 | 261 | ), |
262 | 262 | ), |
263 | 263 | array( |
264 | - 'name' => __( 'Request Billing Information', 'give' ), |
|
265 | - 'desc' => __( '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' ), |
|
266 | - 'id' => $prefix . 'offline_donation_enable_billing_fields_single', |
|
264 | + 'name' => __('Request Billing Information', 'give'), |
|
265 | + 'desc' => __('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'), |
|
266 | + 'id' => $prefix.'offline_donation_enable_billing_fields_single', |
|
267 | 267 | 'row_classes' => 'give-subfield', |
268 | 268 | 'type' => 'checkbox' |
269 | 269 | ), |
270 | 270 | array( |
271 | - 'id' => $prefix . 'offline_checkout_notes', |
|
272 | - 'name' => __( 'Offline Donation Instructions', 'give' ), |
|
273 | - 'desc' => __( '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' ), |
|
271 | + 'id' => $prefix.'offline_checkout_notes', |
|
272 | + 'name' => __('Offline Donation Instructions', 'give'), |
|
273 | + 'desc' => __('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'), |
|
274 | 274 | 'default' => give_get_default_offline_donation_content(), |
275 | 275 | 'type' => 'wysiwyg', |
276 | 276 | 'row_classes' => 'give-subfield', |
@@ -279,17 +279,17 @@ discard block |
||
279 | 279 | ) |
280 | 280 | ), |
281 | 281 | array( |
282 | - 'id' => $prefix . 'offline_donation_subject', |
|
283 | - 'name' => __( 'Offline Donation Email Instructions Subject', 'give' ), |
|
284 | - 'desc' => __( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
285 | - 'default' => __( '{donation} - Offline Donation Instructions', 'give' ), |
|
282 | + 'id' => $prefix.'offline_donation_subject', |
|
283 | + 'name' => __('Offline Donation Email Instructions Subject', 'give'), |
|
284 | + 'desc' => __('Enter the subject line for the donation receipt email.', 'give'), |
|
285 | + 'default' => __('{donation} - Offline Donation Instructions', 'give'), |
|
286 | 286 | 'row_classes' => 'give-subfield', |
287 | 287 | 'type' => 'text' |
288 | 288 | ), |
289 | 289 | array( |
290 | - 'id' => $prefix . 'offline_donation_email', |
|
291 | - 'name' => __( 'Offline Donation Email Instructions', 'give' ), |
|
292 | - 'desc' => __( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
290 | + 'id' => $prefix.'offline_donation_email', |
|
291 | + 'name' => __('Offline Donation Email Instructions', 'give'), |
|
292 | + 'desc' => __('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
293 | 293 | 'default' => give_get_default_offline_donation_email_content(), |
294 | 294 | 'type' => 'wysiwyg', |
295 | 295 | 'row_classes' => 'give-subfield', |
@@ -299,10 +299,10 @@ discard block |
||
299 | 299 | ) |
300 | 300 | ); |
301 | 301 | |
302 | - return array_merge( $settings, $check_settings ); |
|
302 | + return array_merge($settings, $check_settings); |
|
303 | 303 | } |
304 | 304 | |
305 | -add_filter( 'give_forms_display_options_metabox_fields', 'give_offline_add_settings' ); |
|
305 | +add_filter('give_forms_display_options_metabox_fields', 'give_offline_add_settings'); |
|
306 | 306 | |
307 | 307 | |
308 | 308 | /** |
@@ -314,20 +314,20 @@ discard block |
||
314 | 314 | */ |
315 | 315 | function give_get_default_offline_donation_content() { |
316 | 316 | |
317 | - $sitename = get_bloginfo( 'sitename' ); |
|
317 | + $sitename = get_bloginfo('sitename'); |
|
318 | 318 | |
319 | - $default_text = '<p>' . __( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
319 | + $default_text = '<p>'.__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
320 | 320 | $default_text .= '<ol>'; |
321 | - $default_text .= '<li>' . _x( 'Make a check payable to ', 'Step 1 for donating offline by check', 'give' ) . '"' . $sitename . '"' . '</li>'; |
|
322 | - $default_text .= '<li>' . _x( 'On the memo line of the check, please indicate that the donation is for ', 'Step 2 for donating by check; this explains who the check should be written to', 'give' ) . '"' . $sitename . '"' . '</li>'; |
|
323 | - $default_text .= '<li>' . _x( 'Please mail your check to:', 'Step 3; where to mail the check', 'give' ) . '</li>'; |
|
321 | + $default_text .= '<li>'._x('Make a check payable to ', 'Step 1 for donating offline by check', 'give').'"'.$sitename.'"'.'</li>'; |
|
322 | + $default_text .= '<li>'._x('On the memo line of the check, please indicate that the donation is for ', 'Step 2 for donating by check; this explains who the check should be written to', 'give').'"'.$sitename.'"'.'</li>'; |
|
323 | + $default_text .= '<li>'._x('Please mail your check to:', 'Step 3; where to mail the check', 'give').'</li>'; |
|
324 | 324 | $default_text .= '</ol>'; |
325 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
325 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
326 | 326 | $default_text .= ' <em>123 G Street </em><br>'; |
327 | 327 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
328 | - $default_text .= '<p>' . __( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>'; |
|
328 | + $default_text .= '<p>'.__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>'; |
|
329 | 329 | |
330 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
330 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
331 | 331 | |
332 | 332 | } |
333 | 333 | |
@@ -340,21 +340,21 @@ discard block |
||
340 | 340 | */ |
341 | 341 | function give_get_default_offline_donation_email_content() { |
342 | 342 | |
343 | - $sitename = get_bloginfo( 'sitename' ); |
|
344 | - $default_text = '<p>' . __( 'Dear {name},', 'give' ) . '</p>'; |
|
345 | - $default_text .= '<p>' . __( '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>'; |
|
343 | + $sitename = get_bloginfo('sitename'); |
|
344 | + $default_text = '<p>'.__('Dear {name},', 'give').'</p>'; |
|
345 | + $default_text .= '<p>'.__('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>'; |
|
346 | 346 | $default_text .= '<ol>'; |
347 | - $default_text .= '<li>' . _x( 'Make a check payable to ', 'Step 1 for donating offline by check', 'give' ) . '"' . $sitename . '"' . '</li>'; |
|
348 | - $default_text .= '<li>' . _x( 'On the memo line of the check, please indicate that the donation is for ', 'Step 2 for donating by check; this explains who the check should be written to', 'give' ) . '"' . $sitename . '"' . '</li>'; |
|
349 | - $default_text .= '<li>' . _x( 'Please mail your check to:', 'Step 3; where to mail the check', 'give' ) . '</li>'; |
|
347 | + $default_text .= '<li>'._x('Make a check payable to ', 'Step 1 for donating offline by check', 'give').'"'.$sitename.'"'.'</li>'; |
|
348 | + $default_text .= '<li>'._x('On the memo line of the check, please indicate that the donation is for ', 'Step 2 for donating by check; this explains who the check should be written to', 'give').'"'.$sitename.'"'.'</li>'; |
|
349 | + $default_text .= '<li>'._x('Please mail your check to:', 'Step 3; where to mail the check', 'give').'</li>'; |
|
350 | 350 | $default_text .= '</ol>'; |
351 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
351 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
352 | 352 | $default_text .= ' <em>123 G Street </em><br>'; |
353 | 353 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
354 | - $default_text .= '<p>' . __( '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>'; |
|
355 | - $default_text .= '<p>' . __( 'Sincerely,', 'give' ) . '</p>'; |
|
356 | - $default_text .= '<p>' . $sitename . '</p>'; |
|
354 | + $default_text .= '<p>'.__('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>'; |
|
355 | + $default_text .= '<p>'.__('Sincerely,', 'give').'</p>'; |
|
356 | + $default_text .= '<p>'.$sitename.'</p>'; |
|
357 | 357 | |
358 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
358 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
359 | 359 | |
360 | 360 | } |
@@ -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 | |
@@ -28,93 +28,93 @@ discard block |
||
28 | 28 | |
29 | 29 | global $give_options; |
30 | 30 | |
31 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/frontend/'; |
|
32 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
33 | - $scripts_footer = ( give_get_option( 'scripts_footer' ) == 'on' ) ? true : false; |
|
31 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/frontend/'; |
|
32 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
33 | + $scripts_footer = (give_get_option('scripts_footer') == 'on') ? true : false; |
|
34 | 34 | |
35 | 35 | // Use minified libraries if SCRIPT_DEBUG is turned off |
36 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
36 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
37 | 37 | |
38 | 38 | //Localize / PHP to AJAX vars |
39 | - $localize_give_checkout = apply_filters( 'give_global_script_vars', array( |
|
39 | + $localize_give_checkout = apply_filters('give_global_script_vars', array( |
|
40 | 40 | 'ajaxurl' => give_get_ajax_url(), |
41 | - 'checkout_nonce' => wp_create_nonce( 'give_checkout_nonce' ), |
|
42 | - 'currency_sign' => give_currency_filter( '' ), |
|
43 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', |
|
44 | - 'thousands_separator' => isset( $give_options['thousands_separator'] ) ? $give_options['thousands_separator'] : ',', |
|
45 | - 'decimal_separator' => isset( $give_options['decimal_separator'] ) ? $give_options['decimal_separator'] : '.', |
|
46 | - 'no_gateway' => __( 'Please select a payment method', 'give' ), |
|
47 | - 'general_loading' => __( 'Loading...', 'give' ), |
|
48 | - 'purchase_loading' => __( 'Please Wait...', 'give' ), |
|
41 | + 'checkout_nonce' => wp_create_nonce('give_checkout_nonce'), |
|
42 | + 'currency_sign' => give_currency_filter(''), |
|
43 | + 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', |
|
44 | + 'thousands_separator' => isset($give_options['thousands_separator']) ? $give_options['thousands_separator'] : ',', |
|
45 | + 'decimal_separator' => isset($give_options['decimal_separator']) ? $give_options['decimal_separator'] : '.', |
|
46 | + 'no_gateway' => __('Please select a payment method', 'give'), |
|
47 | + 'general_loading' => __('Loading...', 'give'), |
|
48 | + 'purchase_loading' => __('Please Wait...', 'give'), |
|
49 | 49 | 'give_version' => GIVE_VERSION |
50 | - ) ); |
|
51 | - $localize_give_ajax = apply_filters( 'give_global_ajax_vars', array( |
|
50 | + )); |
|
51 | + $localize_give_ajax = apply_filters('give_global_ajax_vars', array( |
|
52 | 52 | 'ajaxurl' => give_get_ajax_url(), |
53 | - 'position_in_cart' => isset( $position ) ? $position : - 1, |
|
54 | - 'loading' => __( 'Loading', 'give' ), |
|
53 | + 'position_in_cart' => isset($position) ? $position : - 1, |
|
54 | + 'loading' => __('Loading', 'give'), |
|
55 | 55 | // General loading message |
56 | - 'select_option' => __( 'Please select an option', 'give' ), |
|
56 | + 'select_option' => __('Please select an option', 'give'), |
|
57 | 57 | // Variable pricing error with multi-purchase option enabled |
58 | - 'default_gateway' => give_get_default_gateway( null ), |
|
59 | - 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', |
|
60 | - 'number_decimals' => apply_filters( 'give_format_amount_decimals', 2 ) |
|
61 | - ) ); |
|
58 | + 'default_gateway' => give_get_default_gateway(null), |
|
59 | + 'permalinks' => get_option('permalink_structure') ? '1' : '0', |
|
60 | + 'number_decimals' => apply_filters('give_format_amount_decimals', 2) |
|
61 | + )); |
|
62 | 62 | |
63 | 63 | //DEBUG is On |
64 | - if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { |
|
64 | + if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) { |
|
65 | 65 | |
66 | - if ( give_is_cc_verify_enabled() ) { |
|
67 | - wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
68 | - wp_enqueue_script( 'give-cc-validator' ); |
|
66 | + if (give_is_cc_verify_enabled()) { |
|
67 | + wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
68 | + wp_enqueue_script('give-cc-validator'); |
|
69 | 69 | } |
70 | 70 | |
71 | - wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
72 | - wp_enqueue_script( 'give-float-labels' ); |
|
71 | + wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
72 | + wp_enqueue_script('give-float-labels'); |
|
73 | 73 | |
74 | - wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
75 | - wp_enqueue_script( 'give-blockui' ); |
|
74 | + wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
75 | + wp_enqueue_script('give-blockui'); |
|
76 | 76 | |
77 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
78 | - wp_enqueue_script( 'give-qtip' ); |
|
77 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
78 | + wp_enqueue_script('give-qtip'); |
|
79 | 79 | |
80 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
81 | - wp_enqueue_script( 'give-accounting' ); |
|
80 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
81 | + wp_enqueue_script('give-accounting'); |
|
82 | 82 | |
83 | - wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
84 | - wp_enqueue_script( 'give-magnific' ); |
|
83 | + wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
84 | + wp_enqueue_script('give-magnific'); |
|
85 | 85 | |
86 | - wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
87 | - wp_enqueue_script( 'give-checkout-global' ); |
|
86 | + wp_register_script('give-checkout-global', $js_dir.'give-checkout-global'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
87 | + wp_enqueue_script('give-checkout-global'); |
|
88 | 88 | |
89 | 89 | //General scripts |
90 | - wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
91 | - wp_enqueue_script( 'give-scripts' ); |
|
90 | + wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
91 | + wp_enqueue_script('give-scripts'); |
|
92 | 92 | |
93 | 93 | // Load AJAX scripts, if enabled |
94 | - wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
95 | - wp_enqueue_script( 'give-ajax' ); |
|
94 | + wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
95 | + wp_enqueue_script('give-ajax'); |
|
96 | 96 | |
97 | 97 | //Localize / Pass AJAX vars from PHP |
98 | - wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_checkout ); |
|
99 | - wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax ); |
|
98 | + wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_checkout); |
|
99 | + wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax); |
|
100 | 100 | |
101 | 101 | |
102 | 102 | } else { |
103 | 103 | |
104 | 104 | //DEBUG is OFF (one JS file to rule them all!) |
105 | - wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
106 | - wp_enqueue_script( 'give' ); |
|
105 | + wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
106 | + wp_enqueue_script('give'); |
|
107 | 107 | |
108 | 108 | //Localize / Pass AJAX vars from PHP |
109 | - wp_localize_script( 'give', 'give_global_vars', $localize_give_checkout ); |
|
110 | - wp_localize_script( 'give', 'give_scripts', $localize_give_ajax ); |
|
109 | + wp_localize_script('give', 'give_global_vars', $localize_give_checkout); |
|
110 | + wp_localize_script('give', 'give_scripts', $localize_give_ajax); |
|
111 | 111 | |
112 | 112 | } |
113 | 113 | |
114 | 114 | |
115 | 115 | } |
116 | 116 | |
117 | -add_action( 'wp_enqueue_scripts', 'give_load_scripts' ); |
|
117 | +add_action('wp_enqueue_scripts', 'give_load_scripts'); |
|
118 | 118 | |
119 | 119 | /** |
120 | 120 | * Register Styles |
@@ -126,47 +126,47 @@ discard block |
||
126 | 126 | */ |
127 | 127 | function give_register_styles() { |
128 | 128 | |
129 | - if ( give_get_option( 'disable_css', false ) ) { |
|
129 | + if (give_get_option('disable_css', false)) { |
|
130 | 130 | return; |
131 | 131 | } |
132 | 132 | |
133 | 133 | // Use minified libraries if SCRIPT_DEBUG is turned off |
134 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
134 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
135 | 135 | |
136 | - $file = 'give' . $suffix . '.css'; |
|
136 | + $file = 'give'.$suffix.'.css'; |
|
137 | 137 | $templates_dir = give_get_theme_template_dir_name(); |
138 | 138 | |
139 | - $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file; |
|
140 | - $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give.css'; |
|
141 | - $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file; |
|
142 | - $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give.css'; |
|
143 | - $give_plugin_style_sheet = trailingslashit( give_get_templates_dir() ) . $file; |
|
139 | + $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()).$templates_dir.$file; |
|
140 | + $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()).$templates_dir.'give.css'; |
|
141 | + $parent_theme_style_sheet = trailingslashit(get_template_directory()).$templates_dir.$file; |
|
142 | + $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give.css'; |
|
143 | + $give_plugin_style_sheet = trailingslashit(give_get_templates_dir()).$file; |
|
144 | 144 | |
145 | 145 | // Look in the child theme directory first, followed by the parent theme, followed by the Give core templates directory |
146 | 146 | // Also look for the min version first, followed by non minified version, even if SCRIPT_DEBUG is not enabled. |
147 | 147 | // This allows users to copy just give.css to their theme |
148 | - if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) { |
|
149 | - if ( ! empty( $nonmin ) ) { |
|
150 | - $url = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give.css'; |
|
148 | + if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) { |
|
149 | + if ( ! empty($nonmin)) { |
|
150 | + $url = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give.css'; |
|
151 | 151 | } else { |
152 | - $url = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file; |
|
152 | + $url = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file; |
|
153 | 153 | } |
154 | - } elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) { |
|
155 | - if ( ! empty( $nonmin ) ) { |
|
156 | - $url = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give.css'; |
|
154 | + } elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) { |
|
155 | + if ( ! empty($nonmin)) { |
|
156 | + $url = trailingslashit(get_template_directory_uri()).$templates_dir.'give.css'; |
|
157 | 157 | } else { |
158 | - $url = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file; |
|
158 | + $url = trailingslashit(get_template_directory_uri()).$templates_dir.$file; |
|
159 | 159 | } |
160 | - } elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) { |
|
161 | - $url = trailingslashit( give_get_templates_url() ) . $file; |
|
160 | + } elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) { |
|
161 | + $url = trailingslashit(give_get_templates_url()).$file; |
|
162 | 162 | } |
163 | 163 | |
164 | - wp_register_style( 'give-styles', $url, array(), GIVE_VERSION, 'all' ); |
|
165 | - wp_enqueue_style( 'give-styles' ); |
|
164 | + wp_register_style('give-styles', $url, array(), GIVE_VERSION, 'all'); |
|
165 | + wp_enqueue_style('give-styles'); |
|
166 | 166 | |
167 | 167 | } |
168 | 168 | |
169 | -add_action( 'wp_enqueue_scripts', 'give_register_styles' ); |
|
169 | +add_action('wp_enqueue_scripts', 'give_register_styles'); |
|
170 | 170 | |
171 | 171 | /** |
172 | 172 | * Load Admin Scripts |
@@ -180,93 +180,93 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return void |
182 | 182 | */ |
183 | -function give_load_admin_scripts( $hook ) { |
|
183 | +function give_load_admin_scripts($hook) { |
|
184 | 184 | |
185 | 185 | global $wp_version, $post, $post_type; |
186 | 186 | |
187 | 187 | //Directories of assets |
188 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
189 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
190 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
188 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
189 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
190 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
191 | 191 | |
192 | 192 | // Use minified libraries if SCRIPT_DEBUG is turned off |
193 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
193 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
194 | 194 | |
195 | 195 | //Global Admin: |
196 | - wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' ); |
|
197 | - wp_enqueue_style( 'give-admin-bar-notification' ); |
|
196 | + wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css'); |
|
197 | + wp_enqueue_style('give-admin-bar-notification'); |
|
198 | 198 | |
199 | 199 | //Give Admin Only: |
200 | - if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) { |
|
200 | + if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { |
|
201 | 201 | return; |
202 | 202 | } |
203 | 203 | |
204 | 204 | //CSS |
205 | - wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' ); |
|
206 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
207 | - wp_register_style( 'give-admin', $css_dir . 'give-admin' . $suffix . '.css', GIVE_VERSION ); |
|
208 | - wp_enqueue_style( 'give-admin' ); |
|
209 | - wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION ); |
|
210 | - wp_enqueue_style( 'jquery-chosen' ); |
|
211 | - wp_enqueue_style( 'thickbox' ); |
|
205 | + wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css'); |
|
206 | + wp_enqueue_style('jquery-ui-css'); |
|
207 | + wp_register_style('give-admin', $css_dir.'give-admin'.$suffix.'.css', GIVE_VERSION); |
|
208 | + wp_enqueue_style('give-admin'); |
|
209 | + wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION); |
|
210 | + wp_enqueue_style('jquery-chosen'); |
|
211 | + wp_enqueue_style('thickbox'); |
|
212 | 212 | |
213 | 213 | //JS |
214 | - wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
215 | - wp_enqueue_script( 'jquery-chosen' ); |
|
214 | + wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
215 | + wp_enqueue_script('jquery-chosen'); |
|
216 | 216 | |
217 | - wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
218 | - wp_enqueue_script( 'give-admin-scripts' ); |
|
217 | + wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
218 | + wp_enqueue_script('give-admin-scripts'); |
|
219 | 219 | |
220 | - wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' ); |
|
221 | - wp_enqueue_script( 'jquery-flot' ); |
|
220 | + wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js'); |
|
221 | + wp_enqueue_script('jquery-flot'); |
|
222 | 222 | |
223 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
224 | - wp_enqueue_script( 'give-qtip' ); |
|
223 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
224 | + wp_enqueue_script('give-qtip'); |
|
225 | 225 | |
226 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
227 | - wp_enqueue_script( 'thickbox' ); |
|
226 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
227 | + wp_enqueue_script('thickbox'); |
|
228 | 228 | |
229 | 229 | //Forms CPT Script |
230 | - if ( $post_type === 'give_forms' ) { |
|
231 | - wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
232 | - wp_enqueue_script( 'give-admin-forms-scripts' ); |
|
230 | + if ($post_type === 'give_forms') { |
|
231 | + wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
232 | + wp_enqueue_script('give-admin-forms-scripts'); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | //Localize strings & variables for JS |
236 | - wp_localize_script( 'give-admin-scripts', 'give_vars', array( |
|
237 | - 'post_id' => isset( $post->ID ) ? $post->ID : null, |
|
236 | + wp_localize_script('give-admin-scripts', 'give_vars', array( |
|
237 | + 'post_id' => isset($post->ID) ? $post->ID : null, |
|
238 | 238 | 'give_version' => GIVE_VERSION, |
239 | - 'quick_edit_warning' => __( 'Sorry, not available for variable priced forms.', 'give' ), |
|
240 | - 'delete_payment' => __( 'Are you sure you wish to delete this payment?', 'give' ), |
|
241 | - 'delete_payment_note' => __( 'Are you sure you wish to delete this note?', 'give' ), |
|
242 | - 'revoke_api_key' => __( 'Are you sure you wish to revoke this API key?', 'give' ), |
|
243 | - 'regenerate_api_key' => __( 'Are you sure you wish to regenerate this API key?', 'give' ), |
|
244 | - 'resend_receipt' => __( 'Are you sure you wish to resend the donation receipt?', 'give' ), |
|
245 | - 'copy_download_link_text' => __( 'Copy these links to your clipboard and give them to your donor', 'give' ), |
|
246 | - 'delete_payment_download' => sprintf( __( 'Are you sure you wish to delete this %s?', 'give' ), give_get_forms_label_singular() ), |
|
247 | - 'one_price_min' => __( 'You must have at least one price', 'give' ), |
|
248 | - 'one_file_min' => __( 'You must have at least one file', 'give' ), |
|
249 | - 'one_field_min' => __( 'You must have at least one field', 'give' ), |
|
250 | - 'one_option' => sprintf( __( 'Choose a %s', 'give' ), give_get_forms_label_singular() ), |
|
251 | - 'one_or_more_option' => sprintf( __( 'Choose one or more %s', 'give' ), give_get_forms_label_plural() ), |
|
252 | - 'numeric_item_price' => __( 'Item price must be numeric', 'give' ), |
|
253 | - 'numeric_quantity' => __( 'Quantity must be numeric', 'give' ), |
|
254 | - 'currency_sign' => give_currency_filter( '' ), |
|
255 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', |
|
239 | + 'quick_edit_warning' => __('Sorry, not available for variable priced forms.', 'give'), |
|
240 | + 'delete_payment' => __('Are you sure you wish to delete this payment?', 'give'), |
|
241 | + 'delete_payment_note' => __('Are you sure you wish to delete this note?', 'give'), |
|
242 | + 'revoke_api_key' => __('Are you sure you wish to revoke this API key?', 'give'), |
|
243 | + 'regenerate_api_key' => __('Are you sure you wish to regenerate this API key?', 'give'), |
|
244 | + 'resend_receipt' => __('Are you sure you wish to resend the donation receipt?', 'give'), |
|
245 | + 'copy_download_link_text' => __('Copy these links to your clipboard and give them to your donor', 'give'), |
|
246 | + 'delete_payment_download' => sprintf(__('Are you sure you wish to delete this %s?', 'give'), give_get_forms_label_singular()), |
|
247 | + 'one_price_min' => __('You must have at least one price', 'give'), |
|
248 | + 'one_file_min' => __('You must have at least one file', 'give'), |
|
249 | + 'one_field_min' => __('You must have at least one field', 'give'), |
|
250 | + 'one_option' => sprintf(__('Choose a %s', 'give'), give_get_forms_label_singular()), |
|
251 | + 'one_or_more_option' => sprintf(__('Choose one or more %s', 'give'), give_get_forms_label_plural()), |
|
252 | + 'numeric_item_price' => __('Item price must be numeric', 'give'), |
|
253 | + 'numeric_quantity' => __('Quantity must be numeric', 'give'), |
|
254 | + 'currency_sign' => give_currency_filter(''), |
|
255 | + 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', |
|
256 | 256 | 'currency_decimals' => give_currency_decimal_filter(), |
257 | - 'new_media_ui' => apply_filters( 'give_use_35_media_ui', 1 ), |
|
258 | - 'remove_text' => __( 'Remove', 'give' ), |
|
259 | - 'type_to_search' => sprintf( __( 'Type to search %s', 'give' ), give_get_forms_label_plural() ), |
|
260 | - ) ); |
|
257 | + 'new_media_ui' => apply_filters('give_use_35_media_ui', 1), |
|
258 | + 'remove_text' => __('Remove', 'give'), |
|
259 | + 'type_to_search' => sprintf(__('Type to search %s', 'give'), give_get_forms_label_plural()), |
|
260 | + )); |
|
261 | 261 | |
262 | - if ( function_exists( 'wp_enqueue_media' ) && version_compare( $wp_version, '3.5', '>=' ) ) { |
|
262 | + if (function_exists('wp_enqueue_media') && version_compare($wp_version, '3.5', '>=')) { |
|
263 | 263 | //call for new media manager |
264 | 264 | wp_enqueue_media(); |
265 | 265 | } |
266 | 266 | |
267 | 267 | } |
268 | 268 | |
269 | -add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 ); |
|
269 | +add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100); |
|
270 | 270 | |
271 | 271 | /** |
272 | 272 | * Admin Give Icon |
@@ -283,14 +283,14 @@ discard block |
||
283 | 283 | ?> |
284 | 284 | <style type="text/css" media="screen"> |
285 | 285 | |
286 | - <?php if( version_compare( $wp_version, '3.8-RC', '>=' ) || version_compare( $wp_version, '3.8', '>=' ) ) { ?> |
|
286 | + <?php if (version_compare($wp_version, '3.8-RC', '>=') || version_compare($wp_version, '3.8', '>=')) { ?> |
|
287 | 287 | @font-face { |
288 | 288 | font-family: 'give-icomoon'; |
289 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?-ngjl88'; ?>'); |
|
290 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'), |
|
291 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'), |
|
292 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.ttf?-ngjl88'; ?>') format('truetype'), |
|
293 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg'); |
|
289 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?-ngjl88'; ?>'); |
|
290 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'), |
|
291 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'), |
|
292 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.ttf?-ngjl88'; ?>') format('truetype'), |
|
293 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg'); |
|
294 | 294 | font-weight: normal; |
295 | 295 | font-style: normal; |
296 | 296 | } |
@@ -309,4 +309,4 @@ discard block |
||
309 | 309 | <?php |
310 | 310 | } |
311 | 311 | |
312 | -add_action( 'admin_head', 'give_admin_icon' ); |
|
312 | +add_action('admin_head', 'give_admin_icon'); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.0 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @access private |
22 | 22 | * @since 1.0 |
23 | 23 | */ |
24 | -add_action( 'give_paypal_cc_form', '__return_false' ); |
|
24 | +add_action('give_paypal_cc_form', '__return_false'); |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Process PayPal Purchase |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return void |
34 | 34 | */ |
35 | -function give_process_paypal_purchase( $purchase_data ) { |
|
35 | +function give_process_paypal_purchase($purchase_data) { |
|
36 | 36 | |
37 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
38 | - wp_die( __( 'Nonce verification has failed', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
38 | + wp_die(__('Nonce verification has failed', 'give'), __('Error', 'give'), array('response' => 403)); |
|
39 | 39 | } |
40 | 40 | |
41 | - $form_id = intval( $purchase_data['post_data']['give-form-id'] ); |
|
41 | + $form_id = intval($purchase_data['post_data']['give-form-id']); |
|
42 | 42 | |
43 | 43 | // Collect payment data |
44 | 44 | $payment_data = array( |
@@ -55,59 +55,59 @@ discard block |
||
55 | 55 | ); |
56 | 56 | |
57 | 57 | // Record the pending payment |
58 | - $payment = give_insert_payment( $payment_data ); |
|
58 | + $payment = give_insert_payment($payment_data); |
|
59 | 59 | |
60 | 60 | // Check payment |
61 | - if ( ! $payment ) { |
|
61 | + if ( ! $payment) { |
|
62 | 62 | // Record the error |
63 | - give_record_gateway_error( __( 'Payment Error', 'give' ), sprintf( __( 'Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give' ), json_encode( $payment_data ) ), $payment ); |
|
63 | + give_record_gateway_error(__('Payment Error', 'give'), sprintf(__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give'), json_encode($payment_data)), $payment); |
|
64 | 64 | // Problems? send back |
65 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
65 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
66 | 66 | } else { |
67 | 67 | // Only send to PayPal if the pending payment is created successfully |
68 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
68 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
69 | 69 | |
70 | 70 | // Get the success url |
71 | - $return_url = add_query_arg( array( |
|
71 | + $return_url = add_query_arg(array( |
|
72 | 72 | 'payment-confirmation' => 'paypal', |
73 | 73 | 'payment-id' => $payment |
74 | 74 | |
75 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
75 | + ), get_permalink(give_get_option('success_page'))); |
|
76 | 76 | |
77 | 77 | // Get the PayPal redirect uri |
78 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
78 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
79 | 79 | |
80 | 80 | //Item name - pass level name if variable priced |
81 | 81 | $item_name = $purchase_data['post_data']['give-form-title']; |
82 | 82 | |
83 | 83 | //Verify has variable prices |
84 | - if ( give_has_variable_prices( $form_id ) && isset( $purchase_data['post_data']['give-price-id'] ) ) { |
|
84 | + if (give_has_variable_prices($form_id) && isset($purchase_data['post_data']['give-price-id'])) { |
|
85 | 85 | |
86 | - $item_price_level_text = give_get_price_option_name( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
86 | + $item_price_level_text = give_get_price_option_name($form_id, $purchase_data['post_data']['give-price-id']); |
|
87 | 87 | |
88 | - $price_level_amount = give_get_price_option_amount( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
88 | + $price_level_amount = give_get_price_option_amount($form_id, $purchase_data['post_data']['give-price-id']); |
|
89 | 89 | |
90 | 90 | //Donation given doesn't match selected level (must be a custom amount) |
91 | - if ( $price_level_amount != give_sanitize_amount( $purchase_data['price'] ) ) { |
|
92 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
91 | + if ($price_level_amount != give_sanitize_amount($purchase_data['price'])) { |
|
92 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
93 | 93 | //user custom amount text if any, fallback to default if not |
94 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' ) ); |
|
94 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give')); |
|
95 | 95 | |
96 | 96 | } //Is there any donation level text? |
97 | - elseif ( ! empty( $item_price_level_text ) ) { |
|
98 | - $item_name .= ' - ' . $item_price_level_text; |
|
97 | + elseif ( ! empty($item_price_level_text)) { |
|
98 | + $item_name .= ' - '.$item_price_level_text; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | } //Single donation: Custom Amount |
102 | - elseif ( give_get_form_price( $form_id ) !== give_sanitize_amount( $purchase_data['price'] ) ) { |
|
103 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
102 | + elseif (give_get_form_price($form_id) !== give_sanitize_amount($purchase_data['price'])) { |
|
103 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
104 | 104 | //user custom amount text if any, fallback to default if not |
105 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' ) ); |
|
105 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give')); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | // Setup PayPal arguments |
109 | 109 | $paypal_args = array( |
110 | - 'business' => give_get_option( 'paypal_email', false ), |
|
110 | + 'business' => give_get_option('paypal_email', false), |
|
111 | 111 | 'email' => $purchase_data['user_email'], |
112 | 112 | 'invoice' => $purchase_data['purchase_key'], |
113 | 113 | 'amount' => $purchase_data['price'], |
@@ -118,25 +118,25 @@ discard block |
||
118 | 118 | 'shipping' => '0', |
119 | 119 | 'no_note' => '1', |
120 | 120 | 'currency_code' => give_get_currency(), |
121 | - 'charset' => get_bloginfo( 'charset' ), |
|
121 | + 'charset' => get_bloginfo('charset'), |
|
122 | 122 | 'custom' => $payment, |
123 | 123 | 'rm' => '2', |
124 | 124 | 'return' => $return_url, |
125 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment ), |
|
125 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment), |
|
126 | 126 | 'notify_url' => $listener_url, |
127 | 127 | 'page_style' => give_get_paypal_page_style(), |
128 | - 'cbt' => get_bloginfo( 'name' ), |
|
128 | + 'cbt' => get_bloginfo('name'), |
|
129 | 129 | 'bn' => 'givewp_SP' |
130 | 130 | ); |
131 | 131 | |
132 | - if ( ! empty( $purchase_data['user_info']['address'] ) ) { |
|
132 | + if ( ! empty($purchase_data['user_info']['address'])) { |
|
133 | 133 | $paypal_args['address1'] = $purchase_data['user_info']['address']['line1']; |
134 | 134 | $paypal_args['address2'] = $purchase_data['user_info']['address']['line2']; |
135 | 135 | $paypal_args['city'] = $purchase_data['user_info']['address']['city']; |
136 | 136 | $paypal_args['country'] = $purchase_data['user_info']['address']['country']; |
137 | 137 | } |
138 | 138 | |
139 | - if ( give_get_option( 'paypal_button_type' ) === 'standard' ) { |
|
139 | + if (give_get_option('paypal_button_type') === 'standard') { |
|
140 | 140 | $paypal_extra_args = array( |
141 | 141 | 'cmd' => '_xclick', |
142 | 142 | ); |
@@ -146,25 +146,25 @@ discard block |
||
146 | 146 | ); |
147 | 147 | } |
148 | 148 | |
149 | - $paypal_args = array_merge( $paypal_extra_args, $paypal_args ); |
|
149 | + $paypal_args = array_merge($paypal_extra_args, $paypal_args); |
|
150 | 150 | |
151 | 151 | |
152 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $purchase_data ); |
|
152 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $purchase_data); |
|
153 | 153 | |
154 | 154 | // Build query |
155 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
155 | + $paypal_redirect .= http_build_query($paypal_args); |
|
156 | 156 | |
157 | 157 | // Fix for some sites that encode the entities |
158 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
158 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
159 | 159 | |
160 | 160 | // Redirect to PayPal |
161 | - wp_redirect( $paypal_redirect ); |
|
161 | + wp_redirect($paypal_redirect); |
|
162 | 162 | exit; |
163 | 163 | } |
164 | 164 | |
165 | 165 | } |
166 | 166 | |
167 | -add_action( 'give_gateway_paypal', 'give_process_paypal_purchase' ); |
|
167 | +add_action('give_gateway_paypal', 'give_process_paypal_purchase'); |
|
168 | 168 | |
169 | 169 | /** |
170 | 170 | * Listens for a PayPal IPN requests and then sends to the processing function |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | */ |
175 | 175 | function give_listen_for_paypal_ipn() { |
176 | 176 | // Regular PayPal IPN |
177 | - if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] == 'IPN' ) { |
|
178 | - do_action( 'give_verify_paypal_ipn' ); |
|
177 | + if (isset($_GET['give-listener']) && $_GET['give-listener'] == 'IPN') { |
|
178 | + do_action('give_verify_paypal_ipn'); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
182 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
183 | 183 | |
184 | 184 | /** |
185 | 185 | * Process PayPal IPN |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | function give_process_paypal_ipn() { |
191 | 191 | |
192 | 192 | // Check the request method is POST |
193 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
193 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') { |
|
194 | 194 | return; |
195 | 195 | } |
196 | 196 | |
@@ -198,11 +198,11 @@ discard block |
||
198 | 198 | $post_data = ''; |
199 | 199 | |
200 | 200 | // Fallback just in case post_max_size is lower than needed |
201 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
202 | - $post_data = file_get_contents( 'php://input' ); |
|
201 | + if (ini_get('allow_url_fopen')) { |
|
202 | + $post_data = file_get_contents('php://input'); |
|
203 | 203 | } else { |
204 | 204 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
205 | - ini_set( 'post_max_size', '12M' ); |
|
205 | + ini_set('post_max_size', '12M'); |
|
206 | 206 | } |
207 | 207 | // Start the encoded data collection with notification command |
208 | 208 | $encoded_data = 'cmd=_notify-validate'; |
@@ -211,27 +211,27 @@ discard block |
||
211 | 211 | $arg_separator = give_get_php_arg_separator_output(); |
212 | 212 | |
213 | 213 | // Verify there is a post_data |
214 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
214 | + if ($post_data || strlen($post_data) > 0) { |
|
215 | 215 | // Append the data |
216 | - $encoded_data .= $arg_separator . $post_data; |
|
216 | + $encoded_data .= $arg_separator.$post_data; |
|
217 | 217 | } else { |
218 | 218 | // Check if POST is empty |
219 | - if ( empty( $_POST ) ) { |
|
219 | + if (empty($_POST)) { |
|
220 | 220 | // Nothing to do |
221 | 221 | return; |
222 | 222 | } else { |
223 | 223 | // Loop through each POST |
224 | - foreach ( $_POST as $key => $value ) { |
|
224 | + foreach ($_POST as $key => $value) { |
|
225 | 225 | // Encode the value and append the data |
226 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
226 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
227 | 227 | } |
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
231 | 231 | // Convert collected post data to an array |
232 | - parse_str( $encoded_data, $encoded_data_array ); |
|
232 | + parse_str($encoded_data, $encoded_data_array); |
|
233 | 233 | |
234 | - if ( ! give_get_option( 'disable_paypal_verification' ) ) { |
|
234 | + if ( ! give_get_option('disable_paypal_verification')) { |
|
235 | 235 | |
236 | 236 | // Validate the IPN |
237 | 237 | |
@@ -253,16 +253,16 @@ discard block |
||
253 | 253 | ); |
254 | 254 | |
255 | 255 | // Get response |
256 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
256 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
257 | 257 | |
258 | - if ( is_wp_error( $api_response ) ) { |
|
259 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
258 | + if (is_wp_error($api_response)) { |
|
259 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response))); |
|
260 | 260 | |
261 | 261 | return; // Something went wrong |
262 | 262 | } |
263 | 263 | |
264 | - if ( $api_response['body'] !== 'VERIFIED' && give_get_option( 'disable_paypal_verification', false ) ) { |
|
265 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
264 | + if ($api_response['body'] !== 'VERIFIED' && give_get_option('disable_paypal_verification', false)) { |
|
265 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response))); |
|
266 | 266 | |
267 | 267 | return; // Response not okay |
268 | 268 | } |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | } |
271 | 271 | |
272 | 272 | // Check if $post_data_array has been populated |
273 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
273 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
274 | 274 | return; |
275 | 275 | } |
276 | 276 | |
@@ -279,21 +279,21 @@ discard block |
||
279 | 279 | 'payment_status' => '' |
280 | 280 | ); |
281 | 281 | |
282 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
282 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
283 | 283 | |
284 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
284 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
285 | 285 | |
286 | - if ( has_action( 'give_paypal_' . $encoded_data_array['txn_type'] ) ) { |
|
286 | + if (has_action('give_paypal_'.$encoded_data_array['txn_type'])) { |
|
287 | 287 | // Allow PayPal IPN types to be processed separately |
288 | - do_action( 'give_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $payment_id ); |
|
288 | + do_action('give_paypal_'.$encoded_data_array['txn_type'], $encoded_data_array, $payment_id); |
|
289 | 289 | } else { |
290 | 290 | // Fallback to web accept just in case the txn_type isn't present |
291 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
291 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
292 | 292 | } |
293 | 293 | exit; |
294 | 294 | } |
295 | 295 | |
296 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
296 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
297 | 297 | |
298 | 298 | /** |
299 | 299 | * Process web accept (one time) payment IPNs |
@@ -304,185 +304,185 @@ discard block |
||
304 | 304 | * |
305 | 305 | * @return void |
306 | 306 | */ |
307 | -function give_process_paypal_web_accept_and_cart( $data, $payment_id ) { |
|
307 | +function give_process_paypal_web_accept_and_cart($data, $payment_id) { |
|
308 | 308 | |
309 | - if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) { |
|
309 | + if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') { |
|
310 | 310 | return; |
311 | 311 | } |
312 | 312 | |
313 | - if ( empty( $payment_id ) ) { |
|
313 | + if (empty($payment_id)) { |
|
314 | 314 | return; |
315 | 315 | } |
316 | 316 | |
317 | 317 | // Collect payment details |
318 | - $purchase_key = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number']; |
|
318 | + $purchase_key = isset($data['invoice']) ? $data['invoice'] : $data['item_number']; |
|
319 | 319 | $paypal_amount = $data['mc_gross']; |
320 | - $payment_status = strtolower( $data['payment_status'] ); |
|
321 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
322 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
323 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
320 | + $payment_status = strtolower($data['payment_status']); |
|
321 | + $currency_code = strtolower($data['mc_currency']); |
|
322 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
323 | + $payment_meta = give_get_payment_meta($payment_id); |
|
324 | 324 | |
325 | 325 | |
326 | - if ( give_get_payment_gateway( $payment_id ) != 'paypal' ) { |
|
326 | + if (give_get_payment_gateway($payment_id) != 'paypal') { |
|
327 | 327 | return; // this isn't a PayPal standard IPN |
328 | 328 | } |
329 | 329 | |
330 | 330 | // Verify payment recipient |
331 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) != 0 ) { |
|
331 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) != 0) { |
|
332 | 332 | |
333 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid business email in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
334 | - give_update_payment_status( $payment_id, 'failed' ); |
|
335 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
333 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid business email in IPN response. IPN data: %s', 'give'), json_encode($data)), $payment_id); |
|
334 | + give_update_payment_status($payment_id, 'failed'); |
|
335 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid PayPal business email.', 'give')); |
|
336 | 336 | |
337 | 337 | return; |
338 | 338 | } |
339 | 339 | |
340 | 340 | // Verify payment currency |
341 | - if ( $currency_code != strtolower( $payment_meta['currency'] ) ) { |
|
341 | + if ($currency_code != strtolower($payment_meta['currency'])) { |
|
342 | 342 | |
343 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid currency in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
344 | - give_update_payment_status( $payment_id, 'failed' ); |
|
345 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
343 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid currency in IPN response. IPN data: %s', 'give'), json_encode($data)), $payment_id); |
|
344 | + give_update_payment_status($payment_id, 'failed'); |
|
345 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
346 | 346 | |
347 | 347 | return; |
348 | 348 | } |
349 | 349 | |
350 | - if ( ! give_get_payment_user_email( $payment_id ) ) { |
|
350 | + if ( ! give_get_payment_user_email($payment_id)) { |
|
351 | 351 | |
352 | 352 | // No email associated with purchase, so store from PayPal |
353 | - give_update_payment_meta( $payment_id, '_give_payment_user_email', $data['payer_email'] ); |
|
353 | + give_update_payment_meta($payment_id, '_give_payment_user_email', $data['payer_email']); |
|
354 | 354 | |
355 | 355 | // Setup and store the donors's details |
356 | 356 | $address = array(); |
357 | - $address['line1'] = ! empty( $data['address_street'] ) ? sanitize_text_field( $data['address_street'] ) : false; |
|
358 | - $address['city'] = ! empty( $data['address_city'] ) ? sanitize_text_field( $data['address_city'] ) : false; |
|
359 | - $address['state'] = ! empty( $data['address_state'] ) ? sanitize_text_field( $data['address_state'] ) : false; |
|
360 | - $address['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false; |
|
361 | - $address['zip'] = ! empty( $data['address_zip'] ) ? sanitize_text_field( $data['address_zip'] ) : false; |
|
357 | + $address['line1'] = ! empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false; |
|
358 | + $address['city'] = ! empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false; |
|
359 | + $address['state'] = ! empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false; |
|
360 | + $address['country'] = ! empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false; |
|
361 | + $address['zip'] = ! empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false; |
|
362 | 362 | |
363 | 363 | $user_info = array( |
364 | 364 | 'id' => '-1', |
365 | - 'email' => sanitize_text_field( $data['payer_email'] ), |
|
366 | - 'first_name' => sanitize_text_field( $data['first_name'] ), |
|
367 | - 'last_name' => sanitize_text_field( $data['last_name'] ), |
|
365 | + 'email' => sanitize_text_field($data['payer_email']), |
|
366 | + 'first_name' => sanitize_text_field($data['first_name']), |
|
367 | + 'last_name' => sanitize_text_field($data['last_name']), |
|
368 | 368 | 'discount' => '', |
369 | 369 | 'address' => $address |
370 | 370 | ); |
371 | 371 | |
372 | 372 | $payment_meta['user_info'] = $user_info; |
373 | - give_update_payment_meta( $payment_id, '_give_payment_meta', $payment_meta ); |
|
373 | + give_update_payment_meta($payment_id, '_give_payment_meta', $payment_meta); |
|
374 | 374 | } |
375 | 375 | |
376 | - if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
376 | + if ($payment_status == 'refunded' || $payment_status == 'reversed') { |
|
377 | 377 | |
378 | 378 | // Process a refund |
379 | - give_process_paypal_refund( $data, $payment_id ); |
|
379 | + give_process_paypal_refund($data, $payment_id); |
|
380 | 380 | |
381 | 381 | } else { |
382 | 382 | |
383 | - if ( get_post_status( $payment_id ) == 'publish' ) { |
|
383 | + if (get_post_status($payment_id) == 'publish') { |
|
384 | 384 | return; // Only complete payments once |
385 | 385 | } |
386 | 386 | |
387 | 387 | // Retrieve the total purchase amount (before PayPal) |
388 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
388 | + $payment_amount = give_get_payment_amount($payment_id); |
|
389 | 389 | |
390 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
390 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
391 | 391 | // The prices don't match |
392 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
393 | - give_update_payment_status( $payment_id, 'failed' ); |
|
394 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
392 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid payment amount in IPN response. IPN data: %s', 'give'), json_encode($data)), $payment_id); |
|
393 | + give_update_payment_status($payment_id, 'failed'); |
|
394 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
395 | 395 | |
396 | 396 | return; |
397 | 397 | } |
398 | - if ( $purchase_key != give_get_payment_key( $payment_id ) ) { |
|
398 | + if ($purchase_key != give_get_payment_key($payment_id)) { |
|
399 | 399 | // Purchase keys don't match |
400 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid purchase key in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
401 | - give_update_payment_status( $payment_id, 'failed' ); |
|
402 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'give' ) ); |
|
400 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid purchase key in IPN response. IPN data: %s', 'give'), json_encode($data)), $payment_id); |
|
401 | + give_update_payment_status($payment_id, 'failed'); |
|
402 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid purchase key in PayPal IPN.', 'give')); |
|
403 | 403 | |
404 | 404 | return; |
405 | 405 | } |
406 | 406 | |
407 | - if ( $payment_status == 'completed' || give_is_test_mode() ) { |
|
408 | - give_insert_payment_note( $payment_id, sprintf( __( 'PayPal Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
409 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
410 | - give_update_payment_status( $payment_id, 'publish' ); |
|
411 | - } else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) { |
|
407 | + if ($payment_status == 'completed' || give_is_test_mode()) { |
|
408 | + give_insert_payment_note($payment_id, sprintf(__('PayPal Transaction ID: %s', 'give'), $data['txn_id'])); |
|
409 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
410 | + give_update_payment_status($payment_id, 'publish'); |
|
411 | + } else if ('pending' == $payment_status && isset($data['pending_reason'])) { |
|
412 | 412 | |
413 | 413 | // Look for possible pending reasons, such as an echeck |
414 | 414 | |
415 | 415 | $note = ''; |
416 | 416 | |
417 | - switch ( strtolower( $data['pending_reason'] ) ) { |
|
417 | + switch (strtolower($data['pending_reason'])) { |
|
418 | 418 | |
419 | 419 | case 'echeck' : |
420 | 420 | |
421 | - $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'give' ); |
|
421 | + $note = __('Payment made via eCheck and will clear automatically in 5-8 days', 'give'); |
|
422 | 422 | |
423 | 423 | break; |
424 | 424 | |
425 | 425 | case 'address' : |
426 | 426 | |
427 | - $note = __( 'Payment requires a confirmed donor address and must be accepted manually through PayPal', 'give' ); |
|
427 | + $note = __('Payment requires a confirmed donor address and must be accepted manually through PayPal', 'give'); |
|
428 | 428 | |
429 | 429 | break; |
430 | 430 | |
431 | 431 | case 'intl' : |
432 | 432 | |
433 | - $note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'give' ); |
|
433 | + $note = __('Payment must be accepted manually through PayPal due to international account regulations', 'give'); |
|
434 | 434 | |
435 | 435 | break; |
436 | 436 | |
437 | 437 | case 'multi-currency' : |
438 | 438 | |
439 | - $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal', 'give' ); |
|
439 | + $note = __('Payment received in non-shop currency and must be accepted manually through PayPal', 'give'); |
|
440 | 440 | |
441 | 441 | break; |
442 | 442 | |
443 | 443 | case 'paymentreview' : |
444 | 444 | case 'regulatory_review' : |
445 | 445 | |
446 | - $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'give' ); |
|
446 | + $note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'give'); |
|
447 | 447 | |
448 | 448 | break; |
449 | 449 | |
450 | 450 | case 'unilateral' : |
451 | 451 | |
452 | - $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
452 | + $note = __('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
453 | 453 | |
454 | 454 | break; |
455 | 455 | |
456 | 456 | case 'upgrade' : |
457 | 457 | |
458 | - $note = __( 'PayPal account must be upgraded before this payment can be accepted', 'give' ); |
|
458 | + $note = __('PayPal account must be upgraded before this payment can be accepted', 'give'); |
|
459 | 459 | |
460 | 460 | break; |
461 | 461 | |
462 | 462 | case 'verify' : |
463 | 463 | |
464 | - $note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'give' ); |
|
464 | + $note = __('PayPal account is not verified. Verify account in order to accept this payment', 'give'); |
|
465 | 465 | |
466 | 466 | break; |
467 | 467 | |
468 | 468 | case 'other' : |
469 | 469 | |
470 | - $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'give' ); |
|
470 | + $note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance', 'give'); |
|
471 | 471 | |
472 | 472 | break; |
473 | 473 | |
474 | 474 | } |
475 | 475 | |
476 | - if ( ! empty( $note ) ) { |
|
476 | + if ( ! empty($note)) { |
|
477 | 477 | |
478 | - give_insert_payment_note( $payment_id, $note ); |
|
478 | + give_insert_payment_note($payment_id, $note); |
|
479 | 479 | |
480 | 480 | } |
481 | 481 | } |
482 | 482 | } |
483 | 483 | } |
484 | 484 | |
485 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2 ); |
|
485 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2); |
|
486 | 486 | |
487 | 487 | /** |
488 | 488 | * Process PayPal IPN Refunds |
@@ -493,32 +493,32 @@ discard block |
||
493 | 493 | * |
494 | 494 | * @return void |
495 | 495 | */ |
496 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
496 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
497 | 497 | |
498 | 498 | // Collect payment details |
499 | 499 | |
500 | - if ( empty( $payment_id ) ) { |
|
500 | + if (empty($payment_id)) { |
|
501 | 501 | return; |
502 | 502 | } |
503 | 503 | |
504 | - if ( get_post_status( $payment_id ) == 'refunded' ) { |
|
504 | + if (get_post_status($payment_id) == 'refunded') { |
|
505 | 505 | return; // Only refund payments once |
506 | 506 | } |
507 | 507 | |
508 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
508 | + $payment_amount = give_get_payment_amount($payment_id); |
|
509 | 509 | $refund_amount = $data['payment_gross'] * - 1; |
510 | 510 | |
511 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
511 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
512 | 512 | |
513 | - give_insert_payment_note( $payment_id, sprintf( __( 'Partial PayPal refund processed: %s', 'give' ), $data['parent_txn_id'] ) ); |
|
513 | + give_insert_payment_note($payment_id, sprintf(__('Partial PayPal refund processed: %s', 'give'), $data['parent_txn_id'])); |
|
514 | 514 | |
515 | 515 | return; // This is a partial refund |
516 | 516 | |
517 | 517 | } |
518 | 518 | |
519 | - give_insert_payment_note( $payment_id, sprintf( __( 'PayPal Payment #%s Refunded for reason: %s', 'give' ), $data['parent_txn_id'], $data['reason_code'] ) ); |
|
520 | - give_insert_payment_note( $payment_id, sprintf( __( 'PayPal Refund Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
521 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
519 | + give_insert_payment_note($payment_id, sprintf(__('PayPal Payment #%s Refunded for reason: %s', 'give'), $data['parent_txn_id'], $data['reason_code'])); |
|
520 | + give_insert_payment_note($payment_id, sprintf(__('PayPal Refund Transaction ID: %s', 'give'), $data['txn_id'])); |
|
521 | + give_update_payment_status($payment_id, 'refunded'); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -530,24 +530,24 @@ discard block |
||
530 | 530 | * |
531 | 531 | * @return string |
532 | 532 | */ |
533 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
533 | +function give_get_paypal_redirect($ssl_check = false) { |
|
534 | 534 | |
535 | - if ( is_ssl() || ! $ssl_check ) { |
|
535 | + if (is_ssl() || ! $ssl_check) { |
|
536 | 536 | $protocal = 'https://'; |
537 | 537 | } else { |
538 | 538 | $protocal = 'http://'; |
539 | 539 | } |
540 | 540 | |
541 | 541 | // Check the current payment mode |
542 | - if ( give_is_test_mode() ) { |
|
542 | + if (give_is_test_mode()) { |
|
543 | 543 | // Test mode |
544 | - $paypal_uri = $protocal . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
544 | + $paypal_uri = $protocal.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
545 | 545 | } else { |
546 | 546 | // Live mode |
547 | - $paypal_uri = $protocal . 'www.paypal.com/cgi-bin/webscr'; |
|
547 | + $paypal_uri = $protocal.'www.paypal.com/cgi-bin/webscr'; |
|
548 | 548 | } |
549 | 549 | |
550 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
550 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | /** |
@@ -558,9 +558,9 @@ discard block |
||
558 | 558 | */ |
559 | 559 | function give_get_paypal_page_style() { |
560 | 560 | |
561 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
561 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
562 | 562 | |
563 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
563 | + return apply_filters('give_paypal_page_style', $page_style); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
@@ -575,29 +575,29 @@ discard block |
||
575 | 575 | * @return string |
576 | 576 | * |
577 | 577 | */ |
578 | -function give_paypal_success_page_content( $content ) { |
|
578 | +function give_paypal_success_page_content($content) { |
|
579 | 579 | |
580 | 580 | global $payment; |
581 | 581 | |
582 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
582 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
583 | 583 | return $content; |
584 | 584 | } |
585 | 585 | |
586 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
586 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
587 | 587 | |
588 | - if ( ! $payment_id ) { |
|
588 | + if ( ! $payment_id) { |
|
589 | 589 | $session = give_get_purchase_session(); |
590 | - $payment_id = give_get_purchase_id_by_key( $session['purchase_key'] ); |
|
590 | + $payment_id = give_get_purchase_id_by_key($session['purchase_key']); |
|
591 | 591 | } |
592 | 592 | |
593 | - $payment = get_post( $payment_id ); |
|
593 | + $payment = get_post($payment_id); |
|
594 | 594 | |
595 | - if ( $payment && 'pending' == $payment->post_status ) { |
|
595 | + if ($payment && 'pending' == $payment->post_status) { |
|
596 | 596 | |
597 | 597 | // Payment is still pending so show processing indicator to fix the Race Condition, issue # |
598 | 598 | ob_start(); |
599 | 599 | |
600 | - give_get_template_part( 'payment', 'processing' ); |
|
600 | + give_get_template_part('payment', 'processing'); |
|
601 | 601 | |
602 | 602 | $content = ob_get_clean(); |
603 | 603 | |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | |
608 | 608 | } |
609 | 609 | |
610 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
610 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
611 | 611 | |
612 | 612 | /** |
613 | 613 | * Given a Payment ID, extract the transaction ID |
@@ -618,22 +618,22 @@ discard block |
||
618 | 618 | * |
619 | 619 | * @return string Transaction ID |
620 | 620 | */ |
621 | -function give_paypal_get_payment_transaction_id( $payment_id ) { |
|
621 | +function give_paypal_get_payment_transaction_id($payment_id) { |
|
622 | 622 | |
623 | 623 | $transaction_id = ''; |
624 | - $notes = give_get_payment_notes( $payment_id ); |
|
624 | + $notes = give_get_payment_notes($payment_id); |
|
625 | 625 | |
626 | - foreach ( $notes as $note ) { |
|
627 | - if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) { |
|
626 | + foreach ($notes as $note) { |
|
627 | + if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) { |
|
628 | 628 | $transaction_id = $match[1]; |
629 | 629 | continue; |
630 | 630 | } |
631 | 631 | } |
632 | 632 | |
633 | - return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
633 | + return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id); |
|
634 | 634 | } |
635 | 635 | |
636 | -add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 ); |
|
636 | +add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1); |
|
637 | 637 | |
638 | 638 | /** |
639 | 639 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -645,13 +645,13 @@ discard block |
||
645 | 645 | * |
646 | 646 | * @return string A link to the PayPal transaction details |
647 | 647 | */ |
648 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
648 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
649 | 649 | |
650 | 650 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
651 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
651 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
652 | 652 | |
653 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
653 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
654 | 654 | |
655 | 655 | } |
656 | 656 | |
657 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
657 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |