@@ -97,10 +97,10 @@ |
||
| 97 | 97 | |
| 98 | 98 | //Single Form settings varies compared to the Global default settings |
| 99 | 99 | if ( ! empty( $form_default ) && |
| 100 | - $form_id !== null && |
|
| 101 | - $default !== $form_default && |
|
| 102 | - $form_default !== 'global' && |
|
| 103 | - give_is_gateway_active( $form_default ) |
|
| 100 | + $form_id !== null && |
|
| 101 | + $default !== $form_default && |
|
| 102 | + $form_default !== 'global' && |
|
| 103 | + give_is_gateway_active( $form_default ) |
|
| 104 | 104 | ) { |
| 105 | 105 | $default = $form_default; |
| 106 | 106 | } |
@@ -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 | |
@@ -24,16 +24,16 @@ discard block |
||
| 24 | 24 | // Default, built-in gateways |
| 25 | 25 | $gateways = array( |
| 26 | 26 | 'paypal' => array( |
| 27 | - 'admin_label' => __( 'PayPal Standard', 'give' ), |
|
| 28 | - 'checkout_label' => __( 'PayPal', 'give' ), |
|
| 27 | + 'admin_label' => __('PayPal Standard', 'give'), |
|
| 28 | + 'checkout_label' => __('PayPal', 'give'), |
|
| 29 | 29 | ), |
| 30 | 30 | 'manual' => array( |
| 31 | - 'admin_label' => __( 'Test Donation', 'give' ), |
|
| 32 | - 'checkout_label' => __( 'Test Donation', 'give' ) |
|
| 31 | + 'admin_label' => __('Test Donation', 'give'), |
|
| 32 | + 'checkout_label' => __('Test Donation', 'give') |
|
| 33 | 33 | ), |
| 34 | 34 | ); |
| 35 | 35 | |
| 36 | - return apply_filters( 'give_payment_gateways', $gateways ); |
|
| 36 | + return apply_filters('give_payment_gateways', $gateways); |
|
| 37 | 37 | |
| 38 | 38 | } |
| 39 | 39 | |
@@ -47,20 +47,20 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | $gateways = give_get_payment_gateways(); |
| 49 | 49 | |
| 50 | - $enabled = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
| 50 | + $enabled = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
| 51 | 51 | |
| 52 | 52 | $gateway_list = array(); |
| 53 | 53 | |
| 54 | - foreach ( $gateways as $key => $gateway ) { |
|
| 55 | - if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) { |
|
| 56 | - $gateway_list[ $key ] = $gateway; |
|
| 54 | + foreach ($gateways as $key => $gateway) { |
|
| 55 | + if (isset($enabled[$key]) && $enabled[$key] == 1) { |
|
| 56 | + $gateway_list[$key] = $gateway; |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // Set order of payment gateway in list. |
| 61 | - $gateway_list = give_get_ordered_payment_gateways( $gateway_list ); |
|
| 61 | + $gateway_list = give_get_ordered_payment_gateways($gateway_list); |
|
| 62 | 62 | |
| 63 | - return apply_filters( 'give_enabled_payment_gateways', $gateway_list ); |
|
| 63 | + return apply_filters('give_enabled_payment_gateways', $gateway_list); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -72,12 +72,12 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @return boolean true if enabled, false otherwise |
| 74 | 74 | */ |
| 75 | -function give_is_gateway_active( $gateway ) { |
|
| 75 | +function give_is_gateway_active($gateway) { |
|
| 76 | 76 | $gateways = give_get_enabled_payment_gateways(); |
| 77 | 77 | |
| 78 | - $ret = array_key_exists( $gateway, $gateways ); |
|
| 78 | + $ret = array_key_exists($gateway, $gateways); |
|
| 79 | 79 | |
| 80 | - return apply_filters( 'give_is_gateway_active', $ret, $gateway, $gateways ); |
|
| 80 | + return apply_filters('give_is_gateway_active', $ret, $gateway, $gateways); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -89,23 +89,23 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @return string Gateway ID |
| 91 | 91 | */ |
| 92 | -function give_get_default_gateway( $form_id ) { |
|
| 92 | +function give_get_default_gateway($form_id) { |
|
| 93 | 93 | |
| 94 | 94 | $give_options = give_get_settings(); |
| 95 | - $default = isset( $give_options['default_gateway'] ) && give_is_gateway_active( $give_options['default_gateway'] ) ? $give_options['default_gateway'] : 'paypal'; |
|
| 96 | - $form_default = get_post_meta( $form_id, '_give_default_gateway', true ); |
|
| 95 | + $default = isset($give_options['default_gateway']) && give_is_gateway_active($give_options['default_gateway']) ? $give_options['default_gateway'] : 'paypal'; |
|
| 96 | + $form_default = get_post_meta($form_id, '_give_default_gateway', true); |
|
| 97 | 97 | |
| 98 | 98 | //Single Form settings varies compared to the Global default settings. |
| 99 | - if ( ! empty( $form_default ) && |
|
| 99 | + if ( ! empty($form_default) && |
|
| 100 | 100 | $form_id !== null && |
| 101 | 101 | $default !== $form_default && |
| 102 | 102 | $form_default !== 'global' && |
| 103 | - give_is_gateway_active( $form_default ) |
|
| 103 | + give_is_gateway_active($form_default) |
|
| 104 | 104 | ) { |
| 105 | 105 | $default = $form_default; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - return apply_filters( 'give_default_gateway', $default ); |
|
| 108 | + return apply_filters('give_default_gateway', $default); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -117,18 +117,18 @@ discard block |
||
| 117 | 117 | * |
| 118 | 118 | * @return string Gateway admin label |
| 119 | 119 | */ |
| 120 | -function give_get_gateway_admin_label( $gateway ) { |
|
| 120 | +function give_get_gateway_admin_label($gateway) { |
|
| 121 | 121 | $gateways = give_get_payment_gateways(); |
| 122 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
| 123 | - $payment = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false; |
|
| 122 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
| 123 | + $payment = isset($_GET['id']) ? absint($_GET['id']) : false; |
|
| 124 | 124 | |
| 125 | - if ( $gateway == 'manual' && $payment ) { |
|
| 126 | - if ( give_get_payment_amount( $payment ) == 0 ) { |
|
| 127 | - $label = __( 'Test Donation', 'give' ); |
|
| 125 | + if ($gateway == 'manual' && $payment) { |
|
| 126 | + if (give_get_payment_amount($payment) == 0) { |
|
| 127 | + $label = __('Test Donation', 'give'); |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - return apply_filters( 'give_gateway_admin_label', $label, $gateway ); |
|
| 131 | + return apply_filters('give_gateway_admin_label', $label, $gateway); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -140,15 +140,15 @@ discard block |
||
| 140 | 140 | * |
| 141 | 141 | * @return string Checkout label for the gateway |
| 142 | 142 | */ |
| 143 | -function give_get_gateway_checkout_label( $gateway ) { |
|
| 143 | +function give_get_gateway_checkout_label($gateway) { |
|
| 144 | 144 | $gateways = give_get_payment_gateways(); |
| 145 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
| 145 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
| 146 | 146 | |
| 147 | - if ( $gateway == 'manual' ) { |
|
| 148 | - $label = __( 'Test Donation', 'give' ); |
|
| 147 | + if ($gateway == 'manual') { |
|
| 148 | + $label = __('Test Donation', 'give'); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - return apply_filters( 'give_gateway_checkout_label', $label, $gateway ); |
|
| 151 | + return apply_filters('give_gateway_checkout_label', $label, $gateway); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -160,11 +160,11 @@ discard block |
||
| 160 | 160 | * |
| 161 | 161 | * @return array Options the gateway supports |
| 162 | 162 | */ |
| 163 | -function give_get_gateway_supports( $gateway ) { |
|
| 163 | +function give_get_gateway_supports($gateway) { |
|
| 164 | 164 | $gateways = give_get_enabled_payment_gateways(); |
| 165 | - $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array(); |
|
| 165 | + $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array(); |
|
| 166 | 166 | |
| 167 | - return apply_filters( 'give_gateway_supports', $supports, $gateway ); |
|
| 167 | + return apply_filters('give_gateway_supports', $supports, $gateway); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -177,9 +177,9 @@ discard block |
||
| 177 | 177 | * |
| 178 | 178 | * @return void |
| 179 | 179 | */ |
| 180 | -function give_send_to_gateway( $gateway, $payment_data ) { |
|
| 180 | +function give_send_to_gateway($gateway, $payment_data) { |
|
| 181 | 181 | |
| 182 | - $payment_data['gateway_nonce'] = wp_create_nonce( 'give-gateway' ); |
|
| 182 | + $payment_data['gateway_nonce'] = wp_create_nonce('give-gateway'); |
|
| 183 | 183 | |
| 184 | 184 | /** |
| 185 | 185 | * Fires while loading payment gateway via AJAX. |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @param array $payment_data All the payment data to be sent to the gateway. |
| 192 | 192 | */ |
| 193 | - do_action( "give_gateway_{$gateway}", $payment_data ); |
|
| 193 | + do_action("give_gateway_{$gateway}", $payment_data); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | |
@@ -204,34 +204,34 @@ discard block |
||
| 204 | 204 | * |
| 205 | 205 | * @return string $enabled_gateway The slug of the gateway |
| 206 | 206 | */ |
| 207 | -function give_get_chosen_gateway( $form_id ) { |
|
| 207 | +function give_get_chosen_gateway($form_id) { |
|
| 208 | 208 | |
| 209 | - $request_form_id = isset( $_REQUEST['give_form_id'] ) ? $_REQUEST['give_form_id'] : 0; |
|
| 209 | + $request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0; |
|
| 210 | 210 | |
| 211 | 211 | //Back to check if 'form-id' is present. |
| 212 | - if ( empty( $request_form_id ) ) { |
|
| 213 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? $_REQUEST['form-id'] : 0; |
|
| 212 | + if (empty($request_form_id)) { |
|
| 213 | + $request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - $request_payment_mode = isset( $_REQUEST['payment-mode'] ) ? $_REQUEST['payment-mode'] : ''; |
|
| 216 | + $request_payment_mode = isset($_REQUEST['payment-mode']) ? $_REQUEST['payment-mode'] : ''; |
|
| 217 | 217 | $chosen = false; |
| 218 | 218 | |
| 219 | 219 | //If both 'payment-mode' and 'form-id' then set for only this form. |
| 220 | - if ( ! empty( $request_form_id ) && $form_id == $request_form_id ) { |
|
| 220 | + if ( ! empty($request_form_id) && $form_id == $request_form_id) { |
|
| 221 | 221 | $chosen = $request_payment_mode; |
| 222 | - } elseif ( empty( $request_form_id ) && $request_payment_mode ) { |
|
| 222 | + } elseif (empty($request_form_id) && $request_payment_mode) { |
|
| 223 | 223 | //If no 'form-id' but there is 'payment-mode'. |
| 224 | 224 | $chosen = $request_payment_mode; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | // Get the enable gateway based of chosen var. |
| 228 | - if ( $chosen && give_is_gateway_active( $chosen ) ) { |
|
| 229 | - $enabled_gateway = urldecode( $chosen ); |
|
| 228 | + if ($chosen && give_is_gateway_active($chosen)) { |
|
| 229 | + $enabled_gateway = urldecode($chosen); |
|
| 230 | 230 | } else { |
| 231 | - $enabled_gateway = give_get_default_gateway( $form_id ); |
|
| 231 | + $enabled_gateway = give_get_default_gateway($form_id); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - return apply_filters( 'give_chosen_gateway', $enabled_gateway ); |
|
| 234 | + return apply_filters('give_chosen_gateway', $enabled_gateway); |
|
| 235 | 235 | |
| 236 | 236 | } |
| 237 | 237 | |
@@ -249,8 +249,8 @@ discard block |
||
| 249 | 249 | * |
| 250 | 250 | * @return int ID of the new log entry |
| 251 | 251 | */ |
| 252 | -function give_record_gateway_error( $title = '', $message = '', $parent = 0 ) { |
|
| 253 | - return give_record_log( $title, $message, $parent, 'gateway_error' ); |
|
| 252 | +function give_record_gateway_error($title = '', $message = '', $parent = 0) { |
|
| 253 | + return give_record_log($title, $message, $parent, 'gateway_error'); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | * |
| 264 | 264 | * @return int |
| 265 | 265 | */ |
| 266 | -function give_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
| 266 | +function give_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
| 267 | 267 | |
| 268 | 268 | $ret = 0; |
| 269 | 269 | $args = array( |
@@ -275,9 +275,9 @@ discard block |
||
| 275 | 275 | 'fields' => 'ids' |
| 276 | 276 | ); |
| 277 | 277 | |
| 278 | - $payments = new WP_Query( $args ); |
|
| 278 | + $payments = new WP_Query($args); |
|
| 279 | 279 | |
| 280 | - if ( $payments ) { |
|
| 280 | + if ($payments) { |
|
| 281 | 281 | $ret = $payments->post_count; |
| 282 | 282 | } |
| 283 | 283 | |
@@ -294,27 +294,27 @@ discard block |
||
| 294 | 294 | * |
| 295 | 295 | * @return array $gateways All the available gateways |
| 296 | 296 | */ |
| 297 | -function give_get_ordered_payment_gateways( $gateways ) { |
|
| 297 | +function give_get_ordered_payment_gateways($gateways) { |
|
| 298 | 298 | |
| 299 | 299 | // Get gateways setting. |
| 300 | - $gateways_setting = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
| 300 | + $gateways_setting = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
| 301 | 301 | |
| 302 | 302 | // Return from here if we do not have gateways setting. |
| 303 | - if ( empty( $gateways_setting ) ) { |
|
| 303 | + if (empty($gateways_setting)) { |
|
| 304 | 304 | return $gateways; |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | // Reverse array to order payment gateways. |
| 308 | - $gateways_setting = array_reverse( $gateways_setting ); |
|
| 308 | + $gateways_setting = array_reverse($gateways_setting); |
|
| 309 | 309 | |
| 310 | 310 | // Reorder gateways array |
| 311 | - foreach ( $gateways_setting as $gateway_key => $value ) { |
|
| 311 | + foreach ($gateways_setting as $gateway_key => $value) { |
|
| 312 | 312 | |
| 313 | - $new_gateway_value = isset( $gateways[ $gateway_key ] ) ? $gateways[ $gateway_key ] : ''; |
|
| 314 | - unset( $gateways[ $gateway_key ] ); |
|
| 313 | + $new_gateway_value = isset($gateways[$gateway_key]) ? $gateways[$gateway_key] : ''; |
|
| 314 | + unset($gateways[$gateway_key]); |
|
| 315 | 315 | |
| 316 | - if ( ! empty( $new_gateway_value ) ) { |
|
| 317 | - $gateways = array_merge( array( $gateway_key => $new_gateway_value ), $gateways ); |
|
| 316 | + if ( ! empty($new_gateway_value)) { |
|
| 317 | + $gateways = array_merge(array($gateway_key => $new_gateway_value), $gateways); |
|
| 318 | 318 | } |
| 319 | 319 | } |
| 320 | 320 | |
@@ -325,5 +325,5 @@ discard block |
||
| 325 | 325 | * |
| 326 | 326 | * @param array $gateways All the available gateways |
| 327 | 327 | */ |
| 328 | - return apply_filters( 'give_payment_gateways_order', $gateways ); |
|
| 328 | + return apply_filters('give_payment_gateways_order', $gateways); |
|
| 329 | 329 | } |
| 330 | 330 | \ No newline at end of file |
@@ -117,8 +117,8 @@ |
||
| 117 | 117 | $shortcode_button_pages = array( 'post.php', 'page.php', 'post-new.php', 'post-edit.php' ); |
| 118 | 118 | // Only run in admin post/page creation and edit screens |
| 119 | 119 | if ( in_array( $pagenow, $shortcode_button_pages ) |
| 120 | - && apply_filters( 'give_shortcode_button_condition', true ) |
|
| 121 | - && ! empty( self::$shortcodes ) |
|
| 120 | + && apply_filters( 'give_shortcode_button_condition', true ) |
|
| 121 | + && ! empty( self::$shortcodes ) |
|
| 122 | 122 | ) { |
| 123 | 123 | |
| 124 | 124 | $shortcodes = array(); |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly. |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -33,16 +33,16 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public function __construct() { |
| 35 | 35 | |
| 36 | - if ( is_admin() ) { |
|
| 37 | - add_filter( 'mce_external_plugins', array( $this, 'mce_external_plugins' ), 15 ); |
|
| 36 | + if (is_admin()) { |
|
| 37 | + add_filter('mce_external_plugins', array($this, 'mce_external_plugins'), 15); |
|
| 38 | 38 | |
| 39 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_assets' ) ); |
|
| 40 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_localize_scripts' ), 13 ); |
|
| 41 | - add_action( 'media_buttons', array( $this, 'shortcode_button' ) ); |
|
| 39 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_assets')); |
|
| 40 | + add_action('admin_enqueue_scripts', array($this, 'admin_localize_scripts'), 13); |
|
| 41 | + add_action('media_buttons', array($this, 'shortcode_button')); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - add_action( "wp_ajax_give_shortcode", array( $this, 'shortcode_ajax' ) ); |
|
| 45 | - add_action( "wp_ajax_nopriv_give_shortcode", array( $this, 'shortcode_ajax' ) ); |
|
| 44 | + add_action("wp_ajax_give_shortcode", array($this, 'shortcode_ajax')); |
|
| 45 | + add_action("wp_ajax_nopriv_give_shortcode", array($this, 'shortcode_ajax')); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -54,15 +54,15 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @since 1.0 |
| 56 | 56 | */ |
| 57 | - public function mce_external_plugins( $plugin_array ) { |
|
| 57 | + public function mce_external_plugins($plugin_array) { |
|
| 58 | 58 | |
| 59 | - if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) { |
|
| 59 | + if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages')) { |
|
| 60 | 60 | return false; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
| 63 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 64 | 64 | |
| 65 | - $plugin_array['give_shortcode'] = GIVE_PLUGIN_URL . 'assets/js/admin/tinymce/mce-plugin' . $suffix . '.js'; |
|
| 65 | + $plugin_array['give_shortcode'] = GIVE_PLUGIN_URL.'assets/js/admin/tinymce/mce-plugin'.$suffix.'.js'; |
|
| 66 | 66 | |
| 67 | 67 | return $plugin_array; |
| 68 | 68 | } |
@@ -76,12 +76,12 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function admin_enqueue_assets() { |
| 78 | 78 | |
| 79 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
| 79 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 80 | 80 | |
| 81 | 81 | wp_enqueue_script( |
| 82 | 82 | 'give_shortcode', |
| 83 | - GIVE_PLUGIN_URL . 'assets/js/admin/admin-shortcodes' . $suffix . '.js', |
|
| 84 | - array( 'jquery' ), |
|
| 83 | + GIVE_PLUGIN_URL.'assets/js/admin/admin-shortcodes'.$suffix.'.js', |
|
| 84 | + array('jquery'), |
|
| 85 | 85 | GIVE_VERSION, |
| 86 | 86 | true |
| 87 | 87 | ); |
@@ -96,17 +96,17 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | public function admin_localize_scripts() { |
| 98 | 98 | |
| 99 | - if ( ! empty( self::$shortcodes ) ) { |
|
| 99 | + if ( ! empty(self::$shortcodes)) { |
|
| 100 | 100 | |
| 101 | 101 | $variables = array(); |
| 102 | 102 | |
| 103 | - foreach ( self::$shortcodes as $shortcode => $values ) { |
|
| 104 | - if ( ! empty( $values['required'] ) ) { |
|
| 105 | - $variables[ $shortcode ] = $values['required']; |
|
| 103 | + foreach (self::$shortcodes as $shortcode => $values) { |
|
| 104 | + if ( ! empty($values['required'])) { |
|
| 105 | + $variables[$shortcode] = $values['required']; |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - wp_localize_script( 'give_shortcode', 'scShortcodes', $variables ); |
|
| 109 | + wp_localize_script('give_shortcode', 'scShortcodes', $variables); |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | |
@@ -121,33 +121,33 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | $screen = get_current_screen(); |
| 123 | 123 | |
| 124 | - $shortcode_button_pages = apply_filters( 'give_shortcode_button_pages', array( |
|
| 124 | + $shortcode_button_pages = apply_filters('give_shortcode_button_pages', array( |
|
| 125 | 125 | 'post.php', |
| 126 | 126 | 'page.php', |
| 127 | 127 | 'post-new.php', |
| 128 | 128 | 'post-edit.php', |
| 129 | 129 | 'edit.php', |
| 130 | 130 | 'edit.php?post_type=page', |
| 131 | - ) ); |
|
| 131 | + )); |
|
| 132 | 132 | |
| 133 | 133 | // Only run in admin post/page creation and edit screens |
| 134 | - if ( in_array( $screen->parent_file, $shortcode_button_pages ) |
|
| 135 | - && apply_filters( 'give_shortcode_button_condition', true ) |
|
| 136 | - && ! empty( self::$shortcodes ) |
|
| 134 | + if (in_array($screen->parent_file, $shortcode_button_pages) |
|
| 135 | + && apply_filters('give_shortcode_button_condition', true) |
|
| 136 | + && ! empty(self::$shortcodes) |
|
| 137 | 137 | ) { |
| 138 | 138 | |
| 139 | 139 | $shortcodes = array(); |
| 140 | 140 | |
| 141 | - foreach ( self::$shortcodes as $shortcode => $values ) { |
|
| 141 | + foreach (self::$shortcodes as $shortcode => $values) { |
|
| 142 | 142 | |
| 143 | 143 | /** |
| 144 | 144 | * Filters the condition for including the current shortcode |
| 145 | 145 | * |
| 146 | 146 | * @since 1.0 |
| 147 | 147 | */ |
| 148 | - if ( apply_filters( sanitize_title( $shortcode ) . '_condition', true ) ) { |
|
| 148 | + if (apply_filters(sanitize_title($shortcode).'_condition', true)) { |
|
| 149 | 149 | |
| 150 | - $shortcodes[ $shortcode ] = sprintf( |
|
| 150 | + $shortcodes[$shortcode] = sprintf( |
|
| 151 | 151 | '<div class="sc-shortcode mce-menu-item give-shortcode-item-%1$s" data-shortcode="%s">%s</div>', |
| 152 | 152 | $shortcode, |
| 153 | 153 | $values['label'], |
@@ -156,37 +156,37 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if ( ! empty( $shortcodes ) ) { |
|
| 159 | + if ( ! empty($shortcodes)) { |
|
| 160 | 160 | |
| 161 | 161 | // check current WP version |
| 162 | - $img = ( version_compare( get_bloginfo( 'version' ), '3.5', '<' ) ) |
|
| 163 | - ? '<img src="' . GIVE_PLUGIN_URL . 'assets/images/give-media.png" />' |
|
| 164 | - : '<span class="wp-media-buttons-icon" id="give-media-button" style="background-image: url(' . give_svg_icons( 'give_grey' ) . ');"></span>'; |
|
| 162 | + $img = (version_compare(get_bloginfo('version'), '3.5', '<')) |
|
| 163 | + ? '<img src="'.GIVE_PLUGIN_URL.'assets/images/give-media.png" />' |
|
| 164 | + : '<span class="wp-media-buttons-icon" id="give-media-button" style="background-image: url('.give_svg_icons('give_grey').');"></span>'; |
|
| 165 | 165 | |
| 166 | - reset( $shortcodes ); |
|
| 166 | + reset($shortcodes); |
|
| 167 | 167 | |
| 168 | - if ( count( $shortcodes ) == 1 ) { |
|
| 168 | + if (count($shortcodes) == 1) { |
|
| 169 | 169 | |
| 170 | - $shortcode = key( $shortcodes ); |
|
| 170 | + $shortcode = key($shortcodes); |
|
| 171 | 171 | |
| 172 | 172 | printf( |
| 173 | 173 | '<button class="button sc-shortcode" data-shortcode="%s">%s</button>', |
| 174 | 174 | $shortcode, |
| 175 | - sprintf( '%s %s %s', |
|
| 175 | + sprintf('%s %s %s', |
|
| 176 | 176 | $img, |
| 177 | - esc_html__( 'Insert', 'give' ), |
|
| 178 | - self::$shortcodes[ $shortcode ]['label'] |
|
| 177 | + esc_html__('Insert', 'give'), |
|
| 178 | + self::$shortcodes[$shortcode]['label'] |
|
| 179 | 179 | ) |
| 180 | 180 | ); |
| 181 | 181 | } else { |
| 182 | 182 | printf( |
| 183 | - '<div class="sc-wrap">' . |
|
| 184 | - '<button class="button sc-button">%s %s</button>' . |
|
| 185 | - '<div class="sc-menu mce-menu">%s</div>' . |
|
| 183 | + '<div class="sc-wrap">'. |
|
| 184 | + '<button class="button sc-button">%s %s</button>'. |
|
| 185 | + '<div class="sc-menu mce-menu">%s</div>'. |
|
| 186 | 186 | '</div>', |
| 187 | 187 | $img, |
| 188 | - esc_html__( 'Give Shortcodes', 'give' ), |
|
| 189 | - implode( '', array_values( $shortcodes ) ) |
|
| 188 | + esc_html__('Give Shortcodes', 'give'), |
|
| 189 | + implode('', array_values($shortcodes)) |
|
| 190 | 190 | ); |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -202,15 +202,15 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | public function shortcode_ajax() { |
| 204 | 204 | |
| 205 | - $shortcode = isset( $_POST['shortcode'] ) ? $_POST['shortcode'] : false; |
|
| 205 | + $shortcode = isset($_POST['shortcode']) ? $_POST['shortcode'] : false; |
|
| 206 | 206 | $response = false; |
| 207 | 207 | |
| 208 | - if ( $shortcode && array_key_exists( $shortcode, self::$shortcodes ) ) { |
|
| 208 | + if ($shortcode && array_key_exists($shortcode, self::$shortcodes)) { |
|
| 209 | 209 | |
| 210 | - $data = self::$shortcodes[ $shortcode ]; |
|
| 210 | + $data = self::$shortcodes[$shortcode]; |
|
| 211 | 211 | |
| 212 | - if ( ! empty( $data['errors'] ) ) { |
|
| 213 | - $data['btn_okay'] = array( esc_html__( 'Okay', 'give' ) ); |
|
| 212 | + if ( ! empty($data['errors'])) { |
|
| 213 | + $data['btn_okay'] = array(esc_html__('Okay', 'give')); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | $response = array( |
@@ -222,10 +222,10 @@ discard block |
||
| 222 | 222 | ); |
| 223 | 223 | } else { |
| 224 | 224 | // todo: handle error |
| 225 | - error_log( print_r( 'AJAX error!', 1 ) ); |
|
| 225 | + error_log(print_r('AJAX error!', 1)); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - wp_send_json( $response ); |
|
| 228 | + wp_send_json($response); |
|
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | |
@@ -727,10 +727,10 @@ discard block |
||
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | if ( ! is_int( $params[1] ) |
| 730 | - && ! is_float( $params[1] ) |
|
| 731 | - && ! is_string( $params[1] ) |
|
| 732 | - && $params[1] !== null |
|
| 733 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
| 730 | + && ! is_float( $params[1] ) |
|
| 731 | + && ! is_string( $params[1] ) |
|
| 732 | + && $params[1] !== null |
|
| 733 | + && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
| 734 | 734 | ) { |
| 735 | 735 | trigger_error( 'array_column(): The column key should be either a string or an integer', E_USER_WARNING ); |
| 736 | 736 | |
@@ -738,10 +738,10 @@ discard block |
||
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | if ( isset( $params[2] ) |
| 741 | - && ! is_int( $params[2] ) |
|
| 742 | - && ! is_float( $params[2] ) |
|
| 743 | - && ! is_string( $params[2] ) |
|
| 744 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
| 741 | + && ! is_int( $params[2] ) |
|
| 742 | + && ! is_float( $params[2] ) |
|
| 743 | + && ! is_string( $params[2] ) |
|
| 744 | + && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
| 745 | 745 | ) { |
| 746 | 746 | trigger_error( 'array_column(): The index key should be either a string or an integer', E_USER_WARNING ); |
| 747 | 747 | |
@@ -337,7 +337,7 @@ |
||
| 337 | 337 | * |
| 338 | 338 | * @since 1.0 |
| 339 | 339 | * @uses Give()->session->get() |
| 340 | - * @return mixed array | false |
|
| 340 | + * @return string array | false |
|
| 341 | 341 | */ |
| 342 | 342 | function give_get_purchase_session() { |
| 343 | 343 | return Give()->session->get( 'give_purchase' ); |
@@ -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,7 +25,7 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | $ret = give_get_option('test_mode', false); |
| 27 | 27 | |
| 28 | - return (bool) apply_filters( 'give_is_test_mode', $ret ); |
|
| 28 | + return (bool) apply_filters('give_is_test_mode', $ret); |
|
| 29 | 29 | |
| 30 | 30 | } |
| 31 | 31 | |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | function give_get_currency() { |
| 39 | 39 | |
| 40 | - $currency = give_get_option( 'currency', 'USD' ); |
|
| 40 | + $currency = give_get_option('currency', 'USD'); |
|
| 41 | 41 | |
| 42 | - return apply_filters( 'give_currency', $currency ); |
|
| 42 | + return apply_filters('give_currency', $currency); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | function give_get_currency_position() { |
| 53 | 53 | |
| 54 | - $currency_pos = give_get_option( 'currency_position', 'before' ); |
|
| 54 | + $currency_pos = give_get_option('currency_position', 'before'); |
|
| 55 | 55 | |
| 56 | - return apply_filters( 'give_currency_position', $currency_pos ); |
|
| 56 | + return apply_filters('give_currency_position', $currency_pos); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | |
@@ -66,39 +66,39 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | function give_get_currencies() { |
| 68 | 68 | $currencies = array( |
| 69 | - 'USD' => esc_html__( 'US Dollars ($)', 'give' ), |
|
| 70 | - 'EUR' => esc_html__( 'Euros (€)', 'give' ), |
|
| 71 | - 'GBP' => esc_html__( 'Pounds Sterling (£)', 'give' ), |
|
| 72 | - 'AUD' => esc_html__( 'Australian Dollars ($)', 'give' ), |
|
| 73 | - 'BRL' => esc_html__( 'Brazilian Real (R$)', 'give' ), |
|
| 74 | - 'CAD' => esc_html__( 'Canadian Dollars ($)', 'give' ), |
|
| 75 | - 'CZK' => esc_html__( 'Czech Koruna (Kč)', 'give' ), |
|
| 76 | - 'DKK' => esc_html__( 'Danish Krone (kr)', 'give' ), |
|
| 77 | - 'HKD' => esc_html__( 'Hong Kong Dollar ($)', 'give' ), |
|
| 78 | - 'HUF' => esc_html__( 'Hungarian Forint (Ft)', 'give' ), |
|
| 79 | - 'ILS' => esc_html__( 'Israeli Shekel (₪)', 'give' ), |
|
| 80 | - 'JPY' => esc_html__( 'Japanese Yen (¥)', 'give' ), |
|
| 81 | - 'MYR' => esc_html__( 'Malaysian Ringgits (RM)', 'give' ), |
|
| 82 | - 'MXN' => esc_html__( 'Mexican Peso ($)', 'give' ), |
|
| 83 | - 'MAD' => esc_html__( 'Moroccan Dirham (.د.م)', 'give' ), |
|
| 84 | - 'NZD' => esc_html__( 'New Zealand Dollar ($)', 'give' ), |
|
| 85 | - 'NOK' => esc_html__( 'Norwegian Krone (Kr.)', 'give' ), |
|
| 86 | - 'PHP' => esc_html__( 'Philippine Pesos (₱)', 'give' ), |
|
| 87 | - 'PLN' => esc_html__( 'Polish Zloty (zł)', 'give' ), |
|
| 88 | - 'SGD' => esc_html__( 'Singapore Dollar ($)', 'give' ), |
|
| 89 | - 'KRW' => esc_html__( 'South Korean Won (₩)', 'give' ), |
|
| 90 | - 'ZAR' => esc_html__( 'South African Rand (R)', 'give' ), |
|
| 91 | - 'SEK' => esc_html__( 'Swedish Krona (kr)', 'give' ), |
|
| 92 | - 'CHF' => esc_html__( 'Swiss Franc (CHF)', 'give' ), |
|
| 93 | - 'TWD' => esc_html__( 'Taiwan New Dollars (NT$)', 'give' ), |
|
| 94 | - 'THB' => esc_html__( 'Thai Baht (฿)', 'give' ), |
|
| 95 | - 'INR' => esc_html__( 'Indian Rupee (₹)', 'give' ), |
|
| 96 | - 'TRY' => esc_html__( 'Turkish Lira (₺)', 'give' ), |
|
| 97 | - 'RIAL' => esc_html__( 'Iranian Rial (﷼)', 'give' ), |
|
| 98 | - 'RUB' => esc_html__( 'Russian Rubles (руб)', 'give' ) |
|
| 69 | + 'USD' => esc_html__('US Dollars ($)', 'give'), |
|
| 70 | + 'EUR' => esc_html__('Euros (€)', 'give'), |
|
| 71 | + 'GBP' => esc_html__('Pounds Sterling (£)', 'give'), |
|
| 72 | + 'AUD' => esc_html__('Australian Dollars ($)', 'give'), |
|
| 73 | + 'BRL' => esc_html__('Brazilian Real (R$)', 'give'), |
|
| 74 | + 'CAD' => esc_html__('Canadian Dollars ($)', 'give'), |
|
| 75 | + 'CZK' => esc_html__('Czech Koruna (Kč)', 'give'), |
|
| 76 | + 'DKK' => esc_html__('Danish Krone (kr)', 'give'), |
|
| 77 | + 'HKD' => esc_html__('Hong Kong Dollar ($)', 'give'), |
|
| 78 | + 'HUF' => esc_html__('Hungarian Forint (Ft)', 'give'), |
|
| 79 | + 'ILS' => esc_html__('Israeli Shekel (₪)', 'give'), |
|
| 80 | + 'JPY' => esc_html__('Japanese Yen (¥)', 'give'), |
|
| 81 | + 'MYR' => esc_html__('Malaysian Ringgits (RM)', 'give'), |
|
| 82 | + 'MXN' => esc_html__('Mexican Peso ($)', 'give'), |
|
| 83 | + 'MAD' => esc_html__('Moroccan Dirham (.د.م)', 'give'), |
|
| 84 | + 'NZD' => esc_html__('New Zealand Dollar ($)', 'give'), |
|
| 85 | + 'NOK' => esc_html__('Norwegian Krone (Kr.)', 'give'), |
|
| 86 | + 'PHP' => esc_html__('Philippine Pesos (₱)', 'give'), |
|
| 87 | + 'PLN' => esc_html__('Polish Zloty (zł)', 'give'), |
|
| 88 | + 'SGD' => esc_html__('Singapore Dollar ($)', 'give'), |
|
| 89 | + 'KRW' => esc_html__('South Korean Won (₩)', 'give'), |
|
| 90 | + 'ZAR' => esc_html__('South African Rand (R)', 'give'), |
|
| 91 | + 'SEK' => esc_html__('Swedish Krona (kr)', 'give'), |
|
| 92 | + 'CHF' => esc_html__('Swiss Franc (CHF)', 'give'), |
|
| 93 | + 'TWD' => esc_html__('Taiwan New Dollars (NT$)', 'give'), |
|
| 94 | + 'THB' => esc_html__('Thai Baht (฿)', 'give'), |
|
| 95 | + 'INR' => esc_html__('Indian Rupee (₹)', 'give'), |
|
| 96 | + 'TRY' => esc_html__('Turkish Lira (₺)', 'give'), |
|
| 97 | + 'RIAL' => esc_html__('Iranian Rial (﷼)', 'give'), |
|
| 98 | + 'RUB' => esc_html__('Russian Rubles (руб)', 'give') |
|
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | - return apply_filters( 'give_currencies', $currencies ); |
|
| 101 | + return apply_filters('give_currencies', $currencies); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | |
@@ -113,12 +113,12 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @return string The symbol to use for the currency |
| 115 | 115 | */ |
| 116 | -function give_currency_symbol( $currency = '' ) { |
|
| 116 | +function give_currency_symbol($currency = '') { |
|
| 117 | 117 | |
| 118 | - if ( empty( $currency ) ) { |
|
| 118 | + if (empty($currency)) { |
|
| 119 | 119 | $currency = give_get_currency(); |
| 120 | 120 | } |
| 121 | - switch ( $currency ) : |
|
| 121 | + switch ($currency) : |
|
| 122 | 122 | case 'GBP' : |
| 123 | 123 | $symbol = '£'; |
| 124 | 124 | break; |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | endswitch; |
| 198 | 198 | |
| 199 | 199 | |
| 200 | - return apply_filters( 'give_currency_symbol', $symbol, $currency ); |
|
| 200 | + return apply_filters('give_currency_symbol', $symbol, $currency); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | |
@@ -209,15 +209,15 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | function give_get_current_page_url() { |
| 211 | 211 | |
| 212 | - if ( is_front_page() ) { |
|
| 213 | - $current_url = home_url( '/' ); |
|
| 212 | + if (is_front_page()) { |
|
| 213 | + $current_url = home_url('/'); |
|
| 214 | 214 | } else { |
| 215 | - $http_host = sanitize_text_field( $_SERVER['HTTP_HOST'] ); |
|
| 216 | - $request_uri = sanitize_text_field( $_SERVER['REQUEST_URI'] ); |
|
| 217 | - $current_url = set_url_scheme( 'http://' . $http_host . untrailingslashit( $request_uri ) ); |
|
| 215 | + $http_host = sanitize_text_field($_SERVER['HTTP_HOST']); |
|
| 216 | + $request_uri = sanitize_text_field($_SERVER['REQUEST_URI']); |
|
| 217 | + $current_url = set_url_scheme('http://'.$http_host.untrailingslashit($request_uri)); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - return apply_filters( 'give_get_current_page_url', $current_url ); |
|
| 220 | + return apply_filters('give_get_current_page_url', $current_url); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | |
@@ -238,15 +238,15 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | $gateways = give_get_enabled_payment_gateways(); |
| 240 | 240 | |
| 241 | - if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) { |
|
| 241 | + if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) { |
|
| 242 | 242 | $ret = true; |
| 243 | - } else if ( count( $gateways ) == 1 ) { |
|
| 243 | + } else if (count($gateways) == 1) { |
|
| 244 | 244 | $ret = false; |
| 245 | - } else if ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) { |
|
| 245 | + } else if (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) { |
|
| 246 | 246 | $ret = false; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - return (bool) apply_filters( 'give_verify_credit_cards', $ret ); |
|
| 249 | + return (bool) apply_filters('give_verify_credit_cards', $ret); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -258,26 +258,26 @@ discard block |
||
| 258 | 258 | function give_get_timezone_id() { |
| 259 | 259 | |
| 260 | 260 | // if site timezone string exists, return it |
| 261 | - if ( $timezone = get_option( 'timezone_string' ) ) { |
|
| 261 | + if ($timezone = get_option('timezone_string')) { |
|
| 262 | 262 | return $timezone; |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | // get UTC offset, if it isn't set return UTC |
| 266 | - if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) { |
|
| 266 | + if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) { |
|
| 267 | 267 | return 'UTC'; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | // attempt to guess the timezone string from the UTC offset |
| 271 | - $timezone = timezone_name_from_abbr( '', $utc_offset ); |
|
| 271 | + $timezone = timezone_name_from_abbr('', $utc_offset); |
|
| 272 | 272 | |
| 273 | 273 | // last try, guess timezone string manually |
| 274 | - if ( $timezone === false ) { |
|
| 274 | + if ($timezone === false) { |
|
| 275 | 275 | |
| 276 | - $is_dst = date( 'I' ); |
|
| 276 | + $is_dst = date('I'); |
|
| 277 | 277 | |
| 278 | - foreach ( timezone_abbreviations_list() as $abbr ) { |
|
| 279 | - foreach ( $abbr as $city ) { |
|
| 280 | - if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) { |
|
| 278 | + foreach (timezone_abbreviations_list() as $abbr) { |
|
| 279 | + foreach ($abbr as $city) { |
|
| 280 | + if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) { |
|
| 281 | 281 | return $city['timezone_id']; |
| 282 | 282 | } |
| 283 | 283 | } |
@@ -301,17 +301,17 @@ discard block |
||
| 301 | 301 | |
| 302 | 302 | $ip = '127.0.0.1'; |
| 303 | 303 | |
| 304 | - if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
| 304 | + if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
| 305 | 305 | //check ip from share internet |
| 306 | 306 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
| 307 | - } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
| 307 | + } elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 308 | 308 | //to check ip is pass from proxy |
| 309 | 309 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
| 310 | - } elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
| 310 | + } elseif ( ! empty($_SERVER['REMOTE_ADDR'])) { |
|
| 311 | 311 | $ip = $_SERVER['REMOTE_ADDR']; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - return apply_filters( 'give_get_ip', $ip ); |
|
| 314 | + return apply_filters('give_get_ip', $ip); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | |
@@ -326,9 +326,9 @@ discard block |
||
| 326 | 326 | * |
| 327 | 327 | * @uses Give()->session->set() |
| 328 | 328 | */ |
| 329 | -function give_set_purchase_session( $purchase_data = array() ) { |
|
| 330 | - Give()->session->set( 'give_purchase', $purchase_data ); |
|
| 331 | - Give()->session->set( 'give_email', $purchase_data['user_email'] ); |
|
| 329 | +function give_set_purchase_session($purchase_data = array()) { |
|
| 330 | + Give()->session->set('give_purchase', $purchase_data); |
|
| 331 | + Give()->session->set('give_email', $purchase_data['user_email']); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | /** |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | * @return mixed array | false |
| 343 | 343 | */ |
| 344 | 344 | function give_get_purchase_session() { |
| 345 | - return Give()->session->get( 'give_purchase' ); |
|
| 345 | + return Give()->session->get('give_purchase'); |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | /** |
@@ -357,14 +357,14 @@ discard block |
||
| 357 | 357 | * |
| 358 | 358 | * @return string |
| 359 | 359 | */ |
| 360 | -function give_get_purchase_summary( $purchase_data, $email = true ) { |
|
| 360 | +function give_get_purchase_summary($purchase_data, $email = true) { |
|
| 361 | 361 | $summary = ''; |
| 362 | 362 | |
| 363 | - if ( $email ) { |
|
| 364 | - $summary .= $purchase_data['user_email'] . ' - '; |
|
| 363 | + if ($email) { |
|
| 364 | + $summary .= $purchase_data['user_email'].' - '; |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - $summary .= get_the_title( $purchase_data['post_data']['give-form-id'] ); |
|
| 367 | + $summary .= get_the_title($purchase_data['post_data']['give-form-id']); |
|
| 368 | 368 | |
| 369 | 369 | return $summary; |
| 370 | 370 | } |
@@ -381,31 +381,31 @@ discard block |
||
| 381 | 381 | function give_get_host() { |
| 382 | 382 | $host = false; |
| 383 | 383 | |
| 384 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
| 384 | + if (defined('WPE_APIKEY')) { |
|
| 385 | 385 | $host = 'WP Engine'; |
| 386 | - } elseif ( defined( 'PAGELYBIN' ) ) { |
|
| 386 | + } elseif (defined('PAGELYBIN')) { |
|
| 387 | 387 | $host = 'Pagely'; |
| 388 | - } elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
| 388 | + } elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
| 389 | 389 | $host = 'ICDSoft'; |
| 390 | - } elseif ( DB_HOST == 'mysqlv5' ) { |
|
| 390 | + } elseif (DB_HOST == 'mysqlv5') { |
|
| 391 | 391 | $host = 'NetworkSolutions'; |
| 392 | - } elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
| 392 | + } elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
| 393 | 393 | $host = 'iPage'; |
| 394 | - } elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
| 394 | + } elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
| 395 | 395 | $host = 'IPower'; |
| 396 | - } elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
| 396 | + } elseif (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
| 397 | 397 | $host = 'MediaTemple Grid'; |
| 398 | - } elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
| 398 | + } elseif (strpos(DB_HOST, '.pair.com') !== false) { |
|
| 399 | 399 | $host = 'pair Networks'; |
| 400 | - } elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
| 400 | + } elseif (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
| 401 | 401 | $host = 'Rackspace Cloud'; |
| 402 | - } elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
| 402 | + } elseif (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
| 403 | 403 | $host = 'SysFix.eu Power Hosting'; |
| 404 | - } elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
| 404 | + } elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
| 405 | 405 | $host = 'Flywheel'; |
| 406 | 406 | } else { |
| 407 | 407 | // Adding a general fallback for data gathering |
| 408 | - $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME']; |
|
| 408 | + $host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME']; |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | return $host; |
@@ -421,67 +421,67 @@ discard block |
||
| 421 | 421 | * |
| 422 | 422 | * @return bool true if host matches, false if not |
| 423 | 423 | */ |
| 424 | -function give_is_host( $host = false ) { |
|
| 424 | +function give_is_host($host = false) { |
|
| 425 | 425 | |
| 426 | 426 | $return = false; |
| 427 | 427 | |
| 428 | - if ( $host ) { |
|
| 429 | - $host = str_replace( ' ', '', strtolower( $host ) ); |
|
| 428 | + if ($host) { |
|
| 429 | + $host = str_replace(' ', '', strtolower($host)); |
|
| 430 | 430 | |
| 431 | - switch ( $host ) { |
|
| 431 | + switch ($host) { |
|
| 432 | 432 | case 'wpengine': |
| 433 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
| 433 | + if (defined('WPE_APIKEY')) { |
|
| 434 | 434 | $return = true; |
| 435 | 435 | } |
| 436 | 436 | break; |
| 437 | 437 | case 'pagely': |
| 438 | - if ( defined( 'PAGELYBIN' ) ) { |
|
| 438 | + if (defined('PAGELYBIN')) { |
|
| 439 | 439 | $return = true; |
| 440 | 440 | } |
| 441 | 441 | break; |
| 442 | 442 | case 'icdsoft': |
| 443 | - if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
| 443 | + if (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
| 444 | 444 | $return = true; |
| 445 | 445 | } |
| 446 | 446 | break; |
| 447 | 447 | case 'networksolutions': |
| 448 | - if ( DB_HOST == 'mysqlv5' ) { |
|
| 448 | + if (DB_HOST == 'mysqlv5') { |
|
| 449 | 449 | $return = true; |
| 450 | 450 | } |
| 451 | 451 | break; |
| 452 | 452 | case 'ipage': |
| 453 | - if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
| 453 | + if (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
| 454 | 454 | $return = true; |
| 455 | 455 | } |
| 456 | 456 | break; |
| 457 | 457 | case 'ipower': |
| 458 | - if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
| 458 | + if (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
| 459 | 459 | $return = true; |
| 460 | 460 | } |
| 461 | 461 | break; |
| 462 | 462 | case 'mediatemplegrid': |
| 463 | - if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
| 463 | + if (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
| 464 | 464 | $return = true; |
| 465 | 465 | } |
| 466 | 466 | break; |
| 467 | 467 | case 'pairnetworks': |
| 468 | - if ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
| 468 | + if (strpos(DB_HOST, '.pair.com') !== false) { |
|
| 469 | 469 | $return = true; |
| 470 | 470 | } |
| 471 | 471 | break; |
| 472 | 472 | case 'rackspacecloud': |
| 473 | - if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
| 473 | + if (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
| 474 | 474 | $return = true; |
| 475 | 475 | } |
| 476 | 476 | break; |
| 477 | 477 | case 'sysfix.eu': |
| 478 | 478 | case 'sysfix.eupowerhosting': |
| 479 | - if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
| 479 | + if (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
| 480 | 480 | $return = true; |
| 481 | 481 | } |
| 482 | 482 | break; |
| 483 | 483 | case 'flywheel': |
| 484 | - if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
| 484 | + if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
| 485 | 485 | $return = true; |
| 486 | 486 | } |
| 487 | 487 | break; |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | * @param string $replacement Optional. The function that should have been called. |
| 515 | 515 | * @param array $backtrace Optional. Contains stack backtrace of deprecated function. |
| 516 | 516 | */ |
| 517 | -function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) { |
|
| 517 | +function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) { |
|
| 518 | 518 | |
| 519 | 519 | /** |
| 520 | 520 | * Fires while give deprecated function call occurs. |
@@ -527,19 +527,19 @@ discard block |
||
| 527 | 527 | * @param string $replacement Optional. The function that should have been called. |
| 528 | 528 | * @param string $version The plugin version that deprecated the function. |
| 529 | 529 | */ |
| 530 | - do_action( 'give_deprecated_function_run', $function, $replacement, $version ); |
|
| 530 | + do_action('give_deprecated_function_run', $function, $replacement, $version); |
|
| 531 | 531 | |
| 532 | - $show_errors = current_user_can( 'manage_options' ); |
|
| 532 | + $show_errors = current_user_can('manage_options'); |
|
| 533 | 533 | |
| 534 | 534 | // Allow plugin to filter the output error trigger |
| 535 | - if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) { |
|
| 536 | - if ( ! is_null( $replacement ) ) { |
|
| 537 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) ); |
|
| 538 | - trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
| 535 | + if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) { |
|
| 536 | + if ( ! is_null($replacement)) { |
|
| 537 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement)); |
|
| 538 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
| 539 | 539 | // Alternatively we could dump this to a file. |
| 540 | 540 | } else { |
| 541 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) ); |
|
| 542 | - trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
| 541 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version)); |
|
| 542 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
| 543 | 543 | // Alternatively we could dump this to a file. |
| 544 | 544 | } |
| 545 | 545 | } |
@@ -553,8 +553,8 @@ discard block |
||
| 553 | 553 | * @return string $post_id |
| 554 | 554 | */ |
| 555 | 555 | function give_get_admin_post_id() { |
| 556 | - $post_id = isset( $_GET['post'] ) ? $_GET['post'] : null; |
|
| 557 | - if ( ! $post_id && isset( $_POST['post_id'] ) ) { |
|
| 556 | + $post_id = isset($_GET['post']) ? $_GET['post'] : null; |
|
| 557 | + if ( ! $post_id && isset($_POST['post_id'])) { |
|
| 558 | 558 | $post_id = $_POST['post_id']; |
| 559 | 559 | } |
| 560 | 560 | |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | * @return string Arg separator output |
| 569 | 569 | */ |
| 570 | 570 | function give_get_php_arg_separator_output() { |
| 571 | - return ini_get( 'arg_separator.output' ); |
|
| 571 | + return ini_get('arg_separator.output'); |
|
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | |
@@ -583,10 +583,10 @@ discard block |
||
| 583 | 583 | * |
| 584 | 584 | * @return string Short month name |
| 585 | 585 | */ |
| 586 | -function give_month_num_to_name( $n ) { |
|
| 587 | - $timestamp = mktime( 0, 0, 0, $n, 1, 2005 ); |
|
| 586 | +function give_month_num_to_name($n) { |
|
| 587 | + $timestamp = mktime(0, 0, 0, $n, 1, 2005); |
|
| 588 | 588 | |
| 589 | - return date_i18n( "M", $timestamp ); |
|
| 589 | + return date_i18n("M", $timestamp); |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | |
@@ -599,10 +599,10 @@ discard block |
||
| 599 | 599 | * |
| 600 | 600 | * @return bool Whether or not function is disabled. |
| 601 | 601 | */ |
| 602 | -function give_is_func_disabled( $function ) { |
|
| 603 | - $disabled = explode( ',', ini_get( 'disable_functions' ) ); |
|
| 602 | +function give_is_func_disabled($function) { |
|
| 603 | + $disabled = explode(',', ini_get('disable_functions')); |
|
| 604 | 604 | |
| 605 | - return in_array( $function, $disabled ); |
|
| 605 | + return in_array($function, $disabled); |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | |
@@ -613,31 +613,31 @@ discard block |
||
| 613 | 613 | */ |
| 614 | 614 | function give_get_newsletter() { ?> |
| 615 | 615 | |
| 616 | - <p class="newsletter-intro"><?php esc_html_e( 'Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give' ); ?></p> |
|
| 616 | + <p class="newsletter-intro"><?php esc_html_e('Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give'); ?></p> |
|
| 617 | 617 | |
| 618 | 618 | <div class="give-newsletter-form-wrap"> |
| 619 | 619 | |
| 620 | 620 | <form action="//givewp.us3.list-manage.com/subscribe/post?u=3ccb75d68bda4381e2f45794c&id=12a081aa13" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate> |
| 621 | 621 | <div class="give-newsletter-confirmation"> |
| 622 | - <p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p> |
|
| 622 | + <p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p> |
|
| 623 | 623 | </div> |
| 624 | 624 | |
| 625 | 625 | <table class="form-table give-newsletter-form"> |
| 626 | 626 | <tr valign="middle"> |
| 627 | 627 | <td> |
| 628 | - <label for="mce-EMAIL" class="screen-reader-text"><?php esc_html_e( 'Email Address (required)', 'give' ); ?></label> |
|
| 629 | - <input type="email" name="EMAIL" id="mce-EMAIL" placeholder="<?php esc_attr_e( 'Email Address (required)', 'give' ); ?>" class="required email" value=""> |
|
| 628 | + <label for="mce-EMAIL" class="screen-reader-text"><?php esc_html_e('Email Address (required)', 'give'); ?></label> |
|
| 629 | + <input type="email" name="EMAIL" id="mce-EMAIL" placeholder="<?php esc_attr_e('Email Address (required)', 'give'); ?>" class="required email" value=""> |
|
| 630 | 630 | </td> |
| 631 | 631 | <td> |
| 632 | - <label for="mce-FNAME" class="screen-reader-text"><?php esc_html_e( 'First Name', 'give' ); ?></label> |
|
| 633 | - <input type="text" name="FNAME" id="mce-FNAME" placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" class="" value=""> |
|
| 632 | + <label for="mce-FNAME" class="screen-reader-text"><?php esc_html_e('First Name', 'give'); ?></label> |
|
| 633 | + <input type="text" name="FNAME" id="mce-FNAME" placeholder="<?php esc_attr_e('First Name', 'give'); ?>" class="" value=""> |
|
| 634 | 634 | </td> |
| 635 | 635 | <td> |
| 636 | - <label for="mce-LNAME" class="screen-reader-text"><?php esc_html_e( 'Last Name', 'give' ); ?></label> |
|
| 637 | - <input type="text" name="LNAME" id="mce-LNAME" placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" class="" value=""> |
|
| 636 | + <label for="mce-LNAME" class="screen-reader-text"><?php esc_html_e('Last Name', 'give'); ?></label> |
|
| 637 | + <input type="text" name="LNAME" id="mce-LNAME" placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" class="" value=""> |
|
| 638 | 638 | </td> |
| 639 | 639 | <td> |
| 640 | - <input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button" value="<?php esc_attr_e( 'Subscribe', 'give' ); ?>"> |
|
| 640 | + <input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button" value="<?php esc_attr_e('Subscribe', 'give'); ?>"> |
|
| 641 | 641 | </td> |
| 642 | 642 | </tr> |
| 643 | 643 | </table> |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | <a href="https://twitter.com/givewp" class="twitter-follow-button" data-show-count="false"><?php |
| 699 | 699 | printf( |
| 700 | 700 | /* translators: %s: Give twitter user @givewp */ |
| 701 | - esc_html_e( 'Follow %s', 'give' ), |
|
| 701 | + esc_html_e('Follow %s', 'give'), |
|
| 702 | 702 | '@givewp' |
| 703 | 703 | ); |
| 704 | 704 | ?></a> |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | * |
| 728 | 728 | * @return string |
| 729 | 729 | */ |
| 730 | -function give_svg_icons( $icon ) { |
|
| 730 | +function give_svg_icons($icon) { |
|
| 731 | 731 | |
| 732 | 732 | // Store your SVGs in an associative array |
| 733 | 733 | $svgs = array( |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | ); |
| 740 | 740 | |
| 741 | 741 | // Return the chosen icon's SVG string |
| 742 | - return $svgs[ $icon ]; |
|
| 742 | + return $svgs[$icon]; |
|
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | /** |
@@ -751,15 +751,15 @@ discard block |
||
| 751 | 751 | * |
| 752 | 752 | * @return mixed |
| 753 | 753 | */ |
| 754 | -function modify_nav_menu_meta_box_object( $post_type ) { |
|
| 755 | - if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) { |
|
| 756 | - $post_type->labels->name = esc_html__( 'Donation Forms', 'give' ); |
|
| 754 | +function modify_nav_menu_meta_box_object($post_type) { |
|
| 755 | + if (isset($post_type->name) && $post_type->name == 'give_forms') { |
|
| 756 | + $post_type->labels->name = esc_html__('Donation Forms', 'give'); |
|
| 757 | 757 | } |
| 758 | 758 | |
| 759 | 759 | return $post_type; |
| 760 | 760 | } |
| 761 | 761 | |
| 762 | -add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' ); |
|
| 762 | +add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object'); |
|
| 763 | 763 | |
| 764 | 764 | |
| 765 | 765 | /** |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | * @license https://opensource.org/licenses/MIT MIT |
| 774 | 774 | */ |
| 775 | 775 | |
| 776 | -if ( ! function_exists( 'array_column' ) ) { |
|
| 776 | +if ( ! function_exists('array_column')) { |
|
| 777 | 777 | /** |
| 778 | 778 | * Returns the values from a single column of the input array, identified by |
| 779 | 779 | * the $columnKey. |
@@ -792,53 +792,53 @@ discard block |
||
| 792 | 792 | * |
| 793 | 793 | * @return array |
| 794 | 794 | */ |
| 795 | - function array_column( $input = null, $columnKey = null, $indexKey = null ) { |
|
| 795 | + function array_column($input = null, $columnKey = null, $indexKey = null) { |
|
| 796 | 796 | // Using func_get_args() in order to check for proper number of |
| 797 | 797 | // parameters and trigger errors exactly as the built-in array_column() |
| 798 | 798 | // does in PHP 5.5. |
| 799 | 799 | $argc = func_num_args(); |
| 800 | 800 | $params = func_get_args(); |
| 801 | 801 | |
| 802 | - if ( $argc < 2 ) { |
|
| 803 | - trigger_error( sprintf( esc_html__( 'array_column() expects at least 2 parameters, %s given.', 'give' ), $argc ), E_USER_WARNING ); |
|
| 802 | + if ($argc < 2) { |
|
| 803 | + trigger_error(sprintf(esc_html__('array_column() expects at least 2 parameters, %s given.', 'give'), $argc), E_USER_WARNING); |
|
| 804 | 804 | |
| 805 | 805 | return null; |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | - if ( ! is_array( $params[0] ) ) { |
|
| 809 | - trigger_error( sprintf( esc_html__( 'array_column() expects parameter 1 to be array, %s given.', 'give' ), gettype( $params[0] ) ), E_USER_WARNING ); |
|
| 808 | + if ( ! is_array($params[0])) { |
|
| 809 | + trigger_error(sprintf(esc_html__('array_column() expects parameter 1 to be array, %s given.', 'give'), gettype($params[0])), E_USER_WARNING); |
|
| 810 | 810 | |
| 811 | 811 | return null; |
| 812 | 812 | } |
| 813 | 813 | |
| 814 | - if ( ! is_int( $params[1] ) |
|
| 815 | - && ! is_float( $params[1] ) |
|
| 816 | - && ! is_string( $params[1] ) |
|
| 814 | + if ( ! is_int($params[1]) |
|
| 815 | + && ! is_float($params[1]) |
|
| 816 | + && ! is_string($params[1]) |
|
| 817 | 817 | && $params[1] !== null |
| 818 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
| 818 | + && ! (is_object($params[1]) && method_exists($params[1], '__toString')) |
|
| 819 | 819 | ) { |
| 820 | - trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
| 820 | + trigger_error(esc_html__('array_column(): The column key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
| 821 | 821 | |
| 822 | 822 | return false; |
| 823 | 823 | } |
| 824 | 824 | |
| 825 | - if ( isset( $params[2] ) |
|
| 826 | - && ! is_int( $params[2] ) |
|
| 827 | - && ! is_float( $params[2] ) |
|
| 828 | - && ! is_string( $params[2] ) |
|
| 829 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
| 825 | + if (isset($params[2]) |
|
| 826 | + && ! is_int($params[2]) |
|
| 827 | + && ! is_float($params[2]) |
|
| 828 | + && ! is_string($params[2]) |
|
| 829 | + && ! (is_object($params[2]) && method_exists($params[2], '__toString')) |
|
| 830 | 830 | ) { |
| 831 | - trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
| 831 | + trigger_error(esc_html__('array_column(): The index key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
| 832 | 832 | |
| 833 | 833 | return false; |
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | $paramsInput = $params[0]; |
| 837 | - $paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null; |
|
| 837 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
| 838 | 838 | |
| 839 | 839 | $paramsIndexKey = null; |
| 840 | - if ( isset( $params[2] ) ) { |
|
| 841 | - if ( is_float( $params[2] ) || is_int( $params[2] ) ) { |
|
| 840 | + if (isset($params[2])) { |
|
| 841 | + if (is_float($params[2]) || is_int($params[2])) { |
|
| 842 | 842 | $paramsIndexKey = (int) $params[2]; |
| 843 | 843 | } else { |
| 844 | 844 | $paramsIndexKey = (string) $params[2]; |
@@ -847,26 +847,26 @@ discard block |
||
| 847 | 847 | |
| 848 | 848 | $resultArray = array(); |
| 849 | 849 | |
| 850 | - foreach ( $paramsInput as $row ) { |
|
| 850 | + foreach ($paramsInput as $row) { |
|
| 851 | 851 | $key = $value = null; |
| 852 | 852 | $keySet = $valueSet = false; |
| 853 | 853 | |
| 854 | - if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) { |
|
| 854 | + if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
| 855 | 855 | $keySet = true; |
| 856 | - $key = (string) $row[ $paramsIndexKey ]; |
|
| 856 | + $key = (string) $row[$paramsIndexKey]; |
|
| 857 | 857 | } |
| 858 | 858 | |
| 859 | - if ( $paramsColumnKey === null ) { |
|
| 859 | + if ($paramsColumnKey === null) { |
|
| 860 | 860 | $valueSet = true; |
| 861 | 861 | $value = $row; |
| 862 | - } elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) { |
|
| 862 | + } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
| 863 | 863 | $valueSet = true; |
| 864 | - $value = $row[ $paramsColumnKey ]; |
|
| 864 | + $value = $row[$paramsColumnKey]; |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | - if ( $valueSet ) { |
|
| 868 | - if ( $keySet ) { |
|
| 869 | - $resultArray[ $key ] = $value; |
|
| 867 | + if ($valueSet) { |
|
| 868 | + if ($keySet) { |
|
| 869 | + $resultArray[$key] = $value; |
|
| 870 | 870 | } else { |
| 871 | 871 | $resultArray[] = $value; |
| 872 | 872 | } |
@@ -888,40 +888,40 @@ discard block |
||
| 888 | 888 | * |
| 889 | 889 | * @return bool Whether the receipt is visible or not. |
| 890 | 890 | */ |
| 891 | -function give_can_view_receipt( $payment_key = '' ) { |
|
| 891 | +function give_can_view_receipt($payment_key = '') { |
|
| 892 | 892 | |
| 893 | 893 | $return = false; |
| 894 | 894 | |
| 895 | - if ( empty( $payment_key ) ) { |
|
| 895 | + if (empty($payment_key)) { |
|
| 896 | 896 | return $return; |
| 897 | 897 | } |
| 898 | 898 | |
| 899 | 899 | global $give_receipt_args; |
| 900 | 900 | |
| 901 | - $give_receipt_args['id'] = give_get_purchase_id_by_key( $payment_key ); |
|
| 901 | + $give_receipt_args['id'] = give_get_purchase_id_by_key($payment_key); |
|
| 902 | 902 | |
| 903 | - $user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] ); |
|
| 903 | + $user_id = (int) give_get_payment_user_id($give_receipt_args['id']); |
|
| 904 | 904 | |
| 905 | - $payment_meta = give_get_payment_meta( $give_receipt_args['id'] ); |
|
| 905 | + $payment_meta = give_get_payment_meta($give_receipt_args['id']); |
|
| 906 | 906 | |
| 907 | - if ( is_user_logged_in() ) { |
|
| 908 | - if ( $user_id === (int) get_current_user_id() ) { |
|
| 907 | + if (is_user_logged_in()) { |
|
| 908 | + if ($user_id === (int) get_current_user_id()) { |
|
| 909 | 909 | $return = true; |
| 910 | - } elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) { |
|
| 910 | + } elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) { |
|
| 911 | 911 | $return = true; |
| 912 | - } elseif ( current_user_can( 'view_give_sensitive_data' ) ) { |
|
| 912 | + } elseif (current_user_can('view_give_sensitive_data')) { |
|
| 913 | 913 | $return = true; |
| 914 | 914 | } |
| 915 | 915 | } |
| 916 | 916 | |
| 917 | 917 | $session = give_get_purchase_session(); |
| 918 | - if ( ! empty( $session ) && ! is_user_logged_in() ) { |
|
| 919 | - if ( $session['purchase_key'] === $payment_meta['key'] ) { |
|
| 918 | + if ( ! empty($session) && ! is_user_logged_in()) { |
|
| 919 | + if ($session['purchase_key'] === $payment_meta['key']) { |
|
| 920 | 920 | $return = true; |
| 921 | 921 | } |
| 922 | 922 | } |
| 923 | 923 | |
| 924 | - return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key ); |
|
| 924 | + return (bool) apply_filters('give_can_view_receipt', $return, $payment_key); |
|
| 925 | 925 | |
| 926 | 926 | } |
| 927 | 927 | |
@@ -930,7 +930,7 @@ discard block |
||
| 930 | 930 | * |
| 931 | 931 | * Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar |
| 932 | 932 | */ |
| 933 | -if ( ! function_exists( 'cal_days_in_month' ) ) { |
|
| 933 | +if ( ! function_exists('cal_days_in_month')) { |
|
| 934 | 934 | /** |
| 935 | 935 | * cal_days_in_month |
| 936 | 936 | * |
@@ -940,7 +940,7 @@ discard block |
||
| 940 | 940 | * |
| 941 | 941 | * @return bool|string |
| 942 | 942 | */ |
| 943 | - function cal_days_in_month( $calendar, $month, $year ) { |
|
| 944 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
| 943 | + function cal_days_in_month($calendar, $month, $year) { |
|
| 944 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
| 945 | 945 | } |
| 946 | 946 | } |
@@ -19,6 +19,6 @@ |
||
| 19 | 19 | * @return void |
| 20 | 20 | */ |
| 21 | 21 | function give_disable_mandrill_nl2br() { |
| 22 | - add_filter( 'mandrill_nl2br', '__return_false' ); |
|
| 22 | + add_filter('mandrill_nl2br', '__return_false'); |
|
| 23 | 23 | } |
| 24 | -add_action( 'give_email_send_before', 'give_disable_mandrill_nl2br'); |
|
| 24 | +add_action('give_email_send_before', 'give_disable_mandrill_nl2br'); |
|
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | * |
| 50 | 50 | * @since: 1.4 |
| 51 | 51 | * |
| 52 | - * @return bool |
|
| 52 | + * @return boolean|null |
|
| 53 | 53 | */ |
| 54 | 54 | function give_allow_sessions_for_sysinfo() { |
| 55 | 55 | if ( is_admin() && ( isset( $_GET['page'] ) && isset( $_GET['tab'] ) ) && ( $_GET['tab'] == 'system_info' && $_GET['page'] == 'give-settings' ) ) { |
@@ -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,14 +24,14 @@ 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 | ?> |
| 31 | - <textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" name="give-sysinfo" aria-label="<?php esc_attr_e( 'To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'give' ); ?>"><?php echo give_tools_sysinfo_get(); ?></textarea> |
|
| 31 | + <textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" name="give-sysinfo" aria-label="<?php esc_attr_e('To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'give'); ?>"><?php echo give_tools_sysinfo_get(); ?></textarea> |
|
| 32 | 32 | <p class="submit"> |
| 33 | 33 | <input type="hidden" name="give-action" value="download_sysinfo"/> |
| 34 | - <?php submit_button( esc_html__( 'Download System Info File', 'give' ), 'secondary', 'give-download-sysinfo', false ); ?> |
|
| 34 | + <?php submit_button(esc_html__('Download System Info File', 'give'), 'secondary', 'give-download-sysinfo', false); ?> |
|
| 35 | 35 | </p> |
| 36 | 36 | <?php |
| 37 | 37 | } |
@@ -47,12 +47,12 @@ discard block |
||
| 47 | 47 | * @return bool |
| 48 | 48 | */ |
| 49 | 49 | function give_allow_sessions_for_sysinfo() { |
| 50 | - if ( is_admin() && ( isset( $_GET['page'] ) && isset( $_GET['tab'] ) ) && ( $_GET['tab'] == 'system_info' && $_GET['page'] == 'give-settings' ) ) { |
|
| 50 | + if (is_admin() && (isset($_GET['page']) && isset($_GET['tab'])) && ($_GET['tab'] == 'system_info' && $_GET['page'] == 'give-settings')) { |
|
| 51 | 51 | return true; |
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | -add_filter( 'give_start_session', 'give_allow_sessions_for_sysinfo' ); |
|
| 55 | +add_filter('give_start_session', 'give_allow_sessions_for_sysinfo'); |
|
| 56 | 56 | |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -67,63 +67,63 @@ discard block |
||
| 67 | 67 | function give_tools_sysinfo_get() { |
| 68 | 68 | global $wpdb, $give_options; |
| 69 | 69 | |
| 70 | - if ( ! class_exists( 'Browser' ) ) { |
|
| 71 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/browser.php'; |
|
| 70 | + if ( ! class_exists('Browser')) { |
|
| 71 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/browser.php'; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | $browser = new Browser(); |
| 75 | 75 | |
| 76 | 76 | // Get theme info |
| 77 | - if ( get_bloginfo( 'version' ) < '3.4' ) { |
|
| 78 | - $theme_data = wp_get_theme( get_stylesheet_directory() . '/style.css' ); |
|
| 79 | - $theme = $theme_data['Name'] . ' ' . $theme_data['Version']; |
|
| 77 | + if (get_bloginfo('version') < '3.4') { |
|
| 78 | + $theme_data = wp_get_theme(get_stylesheet_directory().'/style.css'); |
|
| 79 | + $theme = $theme_data['Name'].' '.$theme_data['Version']; |
|
| 80 | 80 | } else { |
| 81 | 81 | $theme_data = wp_get_theme(); |
| 82 | - $theme = $theme_data->Name . ' ' . $theme_data->Version; |
|
| 82 | + $theme = $theme_data->Name.' '.$theme_data->Version; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // Try to identify the hosting provider |
| 86 | 86 | $host = give_get_host(); |
| 87 | 87 | |
| 88 | - $return = '### Begin System Info ###' . "\n\n"; |
|
| 88 | + $return = '### Begin System Info ###'."\n\n"; |
|
| 89 | 89 | |
| 90 | 90 | // Start with the basics... |
| 91 | - $return .= '-- Site Info' . "\n\n"; |
|
| 92 | - $return .= 'Site URL: ' . site_url() . "\n"; |
|
| 93 | - $return .= 'Home URL: ' . home_url() . "\n"; |
|
| 94 | - $return .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n"; |
|
| 91 | + $return .= '-- Site Info'."\n\n"; |
|
| 92 | + $return .= 'Site URL: '.site_url()."\n"; |
|
| 93 | + $return .= 'Home URL: '.home_url()."\n"; |
|
| 94 | + $return .= 'Multisite: '.(is_multisite() ? 'Yes' : 'No')."\n"; |
|
| 95 | 95 | |
| 96 | - $return = apply_filters( 'give_sysinfo_after_site_info', $return ); |
|
| 96 | + $return = apply_filters('give_sysinfo_after_site_info', $return); |
|
| 97 | 97 | |
| 98 | 98 | // Can we determine the site's host? |
| 99 | - if ( $host ) { |
|
| 100 | - $return .= "\n" . '-- Hosting Provider' . "\n\n"; |
|
| 101 | - $return .= 'Host: ' . $host . "\n"; |
|
| 99 | + if ($host) { |
|
| 100 | + $return .= "\n".'-- Hosting Provider'."\n\n"; |
|
| 101 | + $return .= 'Host: '.$host."\n"; |
|
| 102 | 102 | |
| 103 | - $return = apply_filters( 'give_sysinfo_after_host_info', $return ); |
|
| 103 | + $return = apply_filters('give_sysinfo_after_host_info', $return); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | // The local users' browser information, handled by the Browser class |
| 107 | - $return .= "\n" . '-- User Browser' . "\n\n"; |
|
| 107 | + $return .= "\n".'-- User Browser'."\n\n"; |
|
| 108 | 108 | $return .= $browser; |
| 109 | 109 | |
| 110 | - $return = apply_filters( 'give_sysinfo_after_user_browser', $return ); |
|
| 110 | + $return = apply_filters('give_sysinfo_after_user_browser', $return); |
|
| 111 | 111 | |
| 112 | 112 | // WordPress configuration |
| 113 | - $return .= "\n" . '-- WordPress Configuration' . "\n\n"; |
|
| 114 | - $return .= 'Version: ' . get_bloginfo( 'version' ) . "\n"; |
|
| 115 | - $return .= 'Language: ' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ) . "\n"; |
|
| 116 | - $return .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n"; |
|
| 117 | - $return .= 'Active Theme: ' . $theme . "\n"; |
|
| 118 | - $return .= 'Show On Front: ' . get_option( 'show_on_front' ) . "\n"; |
|
| 113 | + $return .= "\n".'-- WordPress Configuration'."\n\n"; |
|
| 114 | + $return .= 'Version: '.get_bloginfo('version')."\n"; |
|
| 115 | + $return .= 'Language: '.(defined('WPLANG') && WPLANG ? WPLANG : 'en_US')."\n"; |
|
| 116 | + $return .= 'Permalink Structure: '.(get_option('permalink_structure') ? get_option('permalink_structure') : 'Default')."\n"; |
|
| 117 | + $return .= 'Active Theme: '.$theme."\n"; |
|
| 118 | + $return .= 'Show On Front: '.get_option('show_on_front')."\n"; |
|
| 119 | 119 | |
| 120 | 120 | // Only show page specs if frontpage is set to 'page' |
| 121 | - if ( get_option( 'show_on_front' ) == 'page' ) { |
|
| 122 | - $front_page_id = get_option( 'page_on_front' ); |
|
| 123 | - $blog_page_id = get_option( 'page_for_posts' ); |
|
| 121 | + if (get_option('show_on_front') == 'page') { |
|
| 122 | + $front_page_id = get_option('page_on_front'); |
|
| 123 | + $blog_page_id = get_option('page_for_posts'); |
|
| 124 | 124 | |
| 125 | - $return .= 'Page On Front: ' . ( $front_page_id != 0 ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset' ) . "\n"; |
|
| 126 | - $return .= 'Page For Posts: ' . ( $blog_page_id != 0 ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset' ) . "\n"; |
|
| 125 | + $return .= 'Page On Front: '.($front_page_id != 0 ? get_the_title($front_page_id).' (#'.$front_page_id.')' : 'Unset')."\n"; |
|
| 126 | + $return .= 'Page For Posts: '.($blog_page_id != 0 ? get_the_title($blog_page_id).' (#'.$blog_page_id.')' : 'Unset')."\n"; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | // Make sure wp_remote_post() is working |
@@ -132,205 +132,205 @@ discard block |
||
| 132 | 132 | $params = array( |
| 133 | 133 | 'sslverify' => false, |
| 134 | 134 | 'timeout' => 60, |
| 135 | - 'user-agent' => 'Give/' . GIVE_VERSION, |
|
| 135 | + 'user-agent' => 'Give/'.GIVE_VERSION, |
|
| 136 | 136 | 'body' => $request |
| 137 | 137 | ); |
| 138 | 138 | |
| 139 | - $response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params ); |
|
| 139 | + $response = wp_remote_post('https://www.paypal.com/cgi-bin/webscr', $params); |
|
| 140 | 140 | |
| 141 | - if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
| 141 | + if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) { |
|
| 142 | 142 | $WP_REMOTE_POST = 'wp_remote_post() works'; |
| 143 | 143 | } else { |
| 144 | 144 | $WP_REMOTE_POST = 'wp_remote_post() does not work'; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - $return .= 'Remote Post: ' . $WP_REMOTE_POST . "\n"; |
|
| 148 | - $return .= 'Table Prefix: ' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n"; |
|
| 149 | - $return .= 'Admin AJAX: ' . ( give_test_ajax_works() ? 'Accessible' : 'Inaccessible' ) . "\n"; |
|
| 150 | - $return .= 'WP_DEBUG: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n"; |
|
| 151 | - $return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n"; |
|
| 152 | - $return .= 'Registered Post Stati: ' . implode( ', ', get_post_stati() ) . "\n"; |
|
| 147 | + $return .= 'Remote Post: '.$WP_REMOTE_POST."\n"; |
|
| 148 | + $return .= 'Table Prefix: '.'Length: '.strlen($wpdb->prefix).' Status: '.(strlen($wpdb->prefix) > 16 ? 'ERROR: Too long' : 'Acceptable')."\n"; |
|
| 149 | + $return .= 'Admin AJAX: '.(give_test_ajax_works() ? 'Accessible' : 'Inaccessible')."\n"; |
|
| 150 | + $return .= 'WP_DEBUG: '.(defined('WP_DEBUG') ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set')."\n"; |
|
| 151 | + $return .= 'Memory Limit: '.WP_MEMORY_LIMIT."\n"; |
|
| 152 | + $return .= 'Registered Post Stati: '.implode(', ', get_post_stati())."\n"; |
|
| 153 | 153 | |
| 154 | - $return = apply_filters( 'give_sysinfo_after_wordpress_config', $return ); |
|
| 154 | + $return = apply_filters('give_sysinfo_after_wordpress_config', $return); |
|
| 155 | 155 | |
| 156 | 156 | // GIVE configuration |
| 157 | - $return .= "\n" . '-- Give Configuration' . "\n\n"; |
|
| 158 | - $return .= 'Version: ' . GIVE_VERSION . "\n"; |
|
| 159 | - $return .= 'Upgraded From: ' . get_option( 'give_version_upgraded_from', 'None' ) . "\n"; |
|
| 160 | - $return .= 'Test Mode: ' . ( give_is_test_mode() ? "Enabled\n" : "Disabled\n" ); |
|
| 161 | - $return .= 'Currency Code: ' . give_get_currency() . "\n"; |
|
| 162 | - $return .= 'Currency Position: ' . give_get_option( 'currency_position', 'before' ) . "\n"; |
|
| 163 | - $return .= 'Decimal Separator: ' . give_get_option( 'decimal_separator', '.' ) . "\n"; |
|
| 164 | - $return .= 'Thousands Separator: ' . give_get_option( 'thousands_separator', ',' ) . "\n"; |
|
| 157 | + $return .= "\n".'-- Give Configuration'."\n\n"; |
|
| 158 | + $return .= 'Version: '.GIVE_VERSION."\n"; |
|
| 159 | + $return .= 'Upgraded From: '.get_option('give_version_upgraded_from', 'None')."\n"; |
|
| 160 | + $return .= 'Test Mode: '.(give_is_test_mode() ? "Enabled\n" : "Disabled\n"); |
|
| 161 | + $return .= 'Currency Code: '.give_get_currency()."\n"; |
|
| 162 | + $return .= 'Currency Position: '.give_get_option('currency_position', 'before')."\n"; |
|
| 163 | + $return .= 'Decimal Separator: '.give_get_option('decimal_separator', '.')."\n"; |
|
| 164 | + $return .= 'Thousands Separator: '.give_get_option('thousands_separator', ',')."\n"; |
|
| 165 | 165 | |
| 166 | - $return = apply_filters( 'give_sysinfo_after_give_config', $return ); |
|
| 166 | + $return = apply_filters('give_sysinfo_after_give_config', $return); |
|
| 167 | 167 | |
| 168 | 168 | // GIVE pages |
| 169 | - $return .= "\n" . '-- Give Page Configuration' . "\n\n"; |
|
| 170 | - $return .= 'Success Page: ' . ( ! empty( $give_options['success_page'] ) ? get_permalink( $give_options['success_page'] ) . "\n" : "Unset\n" ); |
|
| 171 | - $return .= 'Failure Page: ' . ( ! empty( $give_options['failure_page'] ) ? get_permalink( $give_options['failure_page'] ) . "\n" : "Unset\n" ); |
|
| 172 | - $return .= 'Give Forms Slug: ' . ( defined( 'GIVE_SLUG' ) ? '/' . GIVE_SLUG . "\n" : "/donations\n" ); |
|
| 169 | + $return .= "\n".'-- Give Page Configuration'."\n\n"; |
|
| 170 | + $return .= 'Success Page: '.( ! empty($give_options['success_page']) ? get_permalink($give_options['success_page'])."\n" : "Unset\n"); |
|
| 171 | + $return .= 'Failure Page: '.( ! empty($give_options['failure_page']) ? get_permalink($give_options['failure_page'])."\n" : "Unset\n"); |
|
| 172 | + $return .= 'Give Forms Slug: '.(defined('GIVE_SLUG') ? '/'.GIVE_SLUG."\n" : "/donations\n"); |
|
| 173 | 173 | |
| 174 | - $return = apply_filters( 'give_sysinfo_after_give_pages', $return ); |
|
| 174 | + $return = apply_filters('give_sysinfo_after_give_pages', $return); |
|
| 175 | 175 | |
| 176 | 176 | // GIVE gateways |
| 177 | - $return .= "\n" . '-- Give Gateway Configuration' . "\n\n"; |
|
| 177 | + $return .= "\n".'-- Give Gateway Configuration'."\n\n"; |
|
| 178 | 178 | |
| 179 | 179 | $active_gateways = give_get_enabled_payment_gateways(); |
| 180 | - if ( $active_gateways ) { |
|
| 181 | - $default_gateway_is_active = give_is_gateway_active( give_get_default_gateway( null ) ); |
|
| 182 | - if ( $default_gateway_is_active ) { |
|
| 183 | - $default_gateway = give_get_default_gateway( null ); |
|
| 184 | - $default_gateway = $active_gateways[ $default_gateway ]['admin_label']; |
|
| 180 | + if ($active_gateways) { |
|
| 181 | + $default_gateway_is_active = give_is_gateway_active(give_get_default_gateway(null)); |
|
| 182 | + if ($default_gateway_is_active) { |
|
| 183 | + $default_gateway = give_get_default_gateway(null); |
|
| 184 | + $default_gateway = $active_gateways[$default_gateway]['admin_label']; |
|
| 185 | 185 | } else { |
| 186 | 186 | $default_gateway = 'Test Donation'; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | $gateways = array(); |
| 190 | - foreach ( $active_gateways as $gateway ) { |
|
| 190 | + foreach ($active_gateways as $gateway) { |
|
| 191 | 191 | $gateways[] = $gateway['admin_label']; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - $return .= 'Enabled Gateways: ' . implode( ', ', $gateways ) . "\n"; |
|
| 195 | - $return .= 'Default Gateway: ' . $default_gateway . "\n"; |
|
| 194 | + $return .= 'Enabled Gateways: '.implode(', ', $gateways)."\n"; |
|
| 195 | + $return .= 'Default Gateway: '.$default_gateway."\n"; |
|
| 196 | 196 | } else { |
| 197 | - $return .= 'Enabled Gateways: None' . "\n"; |
|
| 197 | + $return .= 'Enabled Gateways: None'."\n"; |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - $return = apply_filters( 'give_sysinfo_after_give_gateways', $return ); |
|
| 200 | + $return = apply_filters('give_sysinfo_after_give_gateways', $return); |
|
| 201 | 201 | |
| 202 | 202 | // GIVE Templates |
| 203 | - $dir = get_stylesheet_directory() . '/give_templates/*'; |
|
| 204 | - if ( is_dir( $dir ) && ( count( glob( "$dir/*" ) ) !== 0 ) ) { |
|
| 205 | - $return .= "\n" . '-- Give Template Overrides' . "\n\n"; |
|
| 203 | + $dir = get_stylesheet_directory().'/give_templates/*'; |
|
| 204 | + if (is_dir($dir) && (count(glob("$dir/*")) !== 0)) { |
|
| 205 | + $return .= "\n".'-- Give Template Overrides'."\n\n"; |
|
| 206 | 206 | |
| 207 | - foreach ( glob( $dir ) as $file ) { |
|
| 208 | - $return .= 'Filename: ' . basename( $file ) . "\n"; |
|
| 207 | + foreach (glob($dir) as $file) { |
|
| 208 | + $return .= 'Filename: '.basename($file)."\n"; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - $return = apply_filters( 'give_sysinfo_after_give_templates', $return ); |
|
| 211 | + $return = apply_filters('give_sysinfo_after_give_templates', $return); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | // Must-use plugins |
| 215 | 215 | $muplugins = get_mu_plugins(); |
| 216 | - if ( count( $muplugins > 0 ) ) { |
|
| 217 | - $return .= "\n" . '-- Must-Use Plugins' . "\n\n"; |
|
| 216 | + if (count($muplugins > 0)) { |
|
| 217 | + $return .= "\n".'-- Must-Use Plugins'."\n\n"; |
|
| 218 | 218 | |
| 219 | - foreach ( $muplugins as $plugin => $plugin_data ) { |
|
| 220 | - $return .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n"; |
|
| 219 | + foreach ($muplugins as $plugin => $plugin_data) { |
|
| 220 | + $return .= $plugin_data['Name'].': '.$plugin_data['Version']."\n"; |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - $return = apply_filters( 'give_sysinfo_after_wordpress_mu_plugins', $return ); |
|
| 223 | + $return = apply_filters('give_sysinfo_after_wordpress_mu_plugins', $return); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | // WordPress active plugins |
| 227 | - $return .= "\n" . '-- WordPress Active Plugins' . "\n\n"; |
|
| 227 | + $return .= "\n".'-- WordPress Active Plugins'."\n\n"; |
|
| 228 | 228 | |
| 229 | 229 | $plugins = get_plugins(); |
| 230 | - $active_plugins = get_option( 'active_plugins', array() ); |
|
| 230 | + $active_plugins = get_option('active_plugins', array()); |
|
| 231 | 231 | |
| 232 | - foreach ( $plugins as $plugin_path => $plugin ) { |
|
| 233 | - if ( ! in_array( $plugin_path, $active_plugins ) ) { |
|
| 232 | + foreach ($plugins as $plugin_path => $plugin) { |
|
| 233 | + if ( ! in_array($plugin_path, $active_plugins)) { |
|
| 234 | 234 | continue; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; |
|
| 237 | + $return .= $plugin['Name'].': '.$plugin['Version']."\n"; |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - $return = apply_filters( 'give_sysinfo_after_wordpress_plugins', $return ); |
|
| 240 | + $return = apply_filters('give_sysinfo_after_wordpress_plugins', $return); |
|
| 241 | 241 | |
| 242 | 242 | // WordPress inactive plugins |
| 243 | - $return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n"; |
|
| 243 | + $return .= "\n".'-- WordPress Inactive Plugins'."\n\n"; |
|
| 244 | 244 | |
| 245 | - foreach ( $plugins as $plugin_path => $plugin ) { |
|
| 246 | - if ( in_array( $plugin_path, $active_plugins ) ) { |
|
| 245 | + foreach ($plugins as $plugin_path => $plugin) { |
|
| 246 | + if (in_array($plugin_path, $active_plugins)) { |
|
| 247 | 247 | continue; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; |
|
| 250 | + $return .= $plugin['Name'].': '.$plugin['Version']."\n"; |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - $return = apply_filters( 'give_sysinfo_after_wordpress_plugins_inactive', $return ); |
|
| 253 | + $return = apply_filters('give_sysinfo_after_wordpress_plugins_inactive', $return); |
|
| 254 | 254 | |
| 255 | - if ( is_multisite() ) { |
|
| 255 | + if (is_multisite()) { |
|
| 256 | 256 | // WordPress Multisite active plugins |
| 257 | - $return .= "\n" . '-- Network Active Plugins' . "\n\n"; |
|
| 257 | + $return .= "\n".'-- Network Active Plugins'."\n\n"; |
|
| 258 | 258 | |
| 259 | 259 | $plugins = wp_get_active_network_plugins(); |
| 260 | - $active_plugins = get_site_option( 'active_sitewide_plugins', array() ); |
|
| 260 | + $active_plugins = get_site_option('active_sitewide_plugins', array()); |
|
| 261 | 261 | |
| 262 | - foreach ( $plugins as $plugin_path ) { |
|
| 263 | - $plugin_base = plugin_basename( $plugin_path ); |
|
| 262 | + foreach ($plugins as $plugin_path) { |
|
| 263 | + $plugin_base = plugin_basename($plugin_path); |
|
| 264 | 264 | |
| 265 | - if ( ! array_key_exists( $plugin_base, $active_plugins ) ) { |
|
| 265 | + if ( ! array_key_exists($plugin_base, $active_plugins)) { |
|
| 266 | 266 | continue; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - $plugin = get_plugin_data( $plugin_path ); |
|
| 270 | - $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; |
|
| 269 | + $plugin = get_plugin_data($plugin_path); |
|
| 270 | + $return .= $plugin['Name'].': '.$plugin['Version']."\n"; |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - $return = apply_filters( 'give_sysinfo_after_wordpress_ms_plugins', $return ); |
|
| 273 | + $return = apply_filters('give_sysinfo_after_wordpress_ms_plugins', $return); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | // Server configuration (really just versioning) |
| 277 | - $return .= "\n" . '-- Webserver Configuration' . "\n\n"; |
|
| 278 | - $return .= 'PHP Version: ' . PHP_VERSION . "\n"; |
|
| 279 | - $return .= 'MySQL Version: ' . $wpdb->db_version() . "\n"; |
|
| 280 | - $return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "\n"; |
|
| 277 | + $return .= "\n".'-- Webserver Configuration'."\n\n"; |
|
| 278 | + $return .= 'PHP Version: '.PHP_VERSION."\n"; |
|
| 279 | + $return .= 'MySQL Version: '.$wpdb->db_version()."\n"; |
|
| 280 | + $return .= 'Webserver Info: '.$_SERVER['SERVER_SOFTWARE']."\n"; |
|
| 281 | 281 | |
| 282 | - $return = apply_filters( 'give_sysinfo_after_webserver_config', $return ); |
|
| 282 | + $return = apply_filters('give_sysinfo_after_webserver_config', $return); |
|
| 283 | 283 | |
| 284 | 284 | // PHP configs... now we're getting to the important stuff |
| 285 | - $return .= "\n" . '-- PHP Configuration' . "\n\n"; |
|
| 286 | - $return .= 'Safe Mode: ' . ( ini_get( 'safe_mode' ) ? 'Enabled' : 'Disabled' . "\n" ); |
|
| 287 | - $return .= 'Memory Limit: ' . ini_get( 'memory_limit' ) . "\n"; |
|
| 288 | - $return .= 'Upload Max Size: ' . ini_get( 'upload_max_filesize' ) . "\n"; |
|
| 289 | - $return .= 'Post Max Size: ' . ini_get( 'post_max_size' ) . "\n"; |
|
| 290 | - $return .= 'Upload Max Filesize: ' . ini_get( 'upload_max_filesize' ) . "\n"; |
|
| 291 | - $return .= 'Time Limit: ' . ini_get( 'max_execution_time' ) . "\n"; |
|
| 292 | - $return .= 'Max Input Vars: ' . ini_get( 'max_input_vars' ) . "\n"; |
|
| 293 | - $return .= 'URL-aware fopen: ' . ( ini_get( 'allow_url_fopen' ) ? 'On (' . ini_get( 'allow_url_fopen' ) . ')' : 'N/A' ) . "\n"; |
|
| 294 | - $return .= 'Display Errors: ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n"; |
|
| 295 | - |
|
| 296 | - $return = apply_filters( 'give_sysinfo_after_php_config', $return ); |
|
| 285 | + $return .= "\n".'-- PHP Configuration'."\n\n"; |
|
| 286 | + $return .= 'Safe Mode: '.(ini_get('safe_mode') ? 'Enabled' : 'Disabled'."\n"); |
|
| 287 | + $return .= 'Memory Limit: '.ini_get('memory_limit')."\n"; |
|
| 288 | + $return .= 'Upload Max Size: '.ini_get('upload_max_filesize')."\n"; |
|
| 289 | + $return .= 'Post Max Size: '.ini_get('post_max_size')."\n"; |
|
| 290 | + $return .= 'Upload Max Filesize: '.ini_get('upload_max_filesize')."\n"; |
|
| 291 | + $return .= 'Time Limit: '.ini_get('max_execution_time')."\n"; |
|
| 292 | + $return .= 'Max Input Vars: '.ini_get('max_input_vars')."\n"; |
|
| 293 | + $return .= 'URL-aware fopen: '.(ini_get('allow_url_fopen') ? 'On ('.ini_get('allow_url_fopen').')' : 'N/A')."\n"; |
|
| 294 | + $return .= 'Display Errors: '.(ini_get('display_errors') ? 'On ('.ini_get('display_errors').')' : 'N/A')."\n"; |
|
| 295 | + |
|
| 296 | + $return = apply_filters('give_sysinfo_after_php_config', $return); |
|
| 297 | 297 | |
| 298 | 298 | // PHP extensions and such |
| 299 | - $return .= "\n" . '-- PHP Extensions' . "\n\n"; |
|
| 300 | - $return .= 'cURL: ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n"; |
|
| 299 | + $return .= "\n".'-- PHP Extensions'."\n\n"; |
|
| 300 | + $return .= 'cURL: '.(function_exists('curl_init') ? 'Supported' : 'Not Supported')."\n"; |
|
| 301 | 301 | |
| 302 | 302 | //cURL version |
| 303 | - if ( function_exists( 'curl_init' ) && function_exists( 'curl_version' ) ) { |
|
| 303 | + if (function_exists('curl_init') && function_exists('curl_version')) { |
|
| 304 | 304 | $curl_values = curl_version(); |
| 305 | - $return .= 'cURL Version: ' . $curl_values["version"] . "\n"; |
|
| 305 | + $return .= 'cURL Version: '.$curl_values["version"]."\n"; |
|
| 306 | 306 | } |
| 307 | - $return .= 'zlib: ' . ( function_exists( 'gzcompress' ) ? 'Supported' : 'Not Supported' ) . "\n"; |
|
| 308 | - $return .= 'GD: ' . ( ( extension_loaded( 'gd' ) && function_exists( 'gd_info' ) ) ? 'Supported' : 'Not Supported' ) . "\n"; |
|
| 309 | - $return .= 'fsockopen: ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n"; |
|
| 310 | - $return .= 'SOAP Client: ' . ( class_exists( 'SoapClient' ) ? 'Installed' : 'Not Installed' ) . "\n"; |
|
| 311 | - $return .= 'Suhosin: ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n"; |
|
| 312 | - $return .= 'DOM: ' . ( extension_loaded( 'dom' ) ? 'Installed' : 'Not Installed' ) . "\n"; |
|
| 313 | - $return .= 'MBString: ' . ( extension_loaded( 'mbstring' ) ? 'Installed' : 'Not Installed' ) . "\n"; |
|
| 307 | + $return .= 'zlib: '.(function_exists('gzcompress') ? 'Supported' : 'Not Supported')."\n"; |
|
| 308 | + $return .= 'GD: '.((extension_loaded('gd') && function_exists('gd_info')) ? 'Supported' : 'Not Supported')."\n"; |
|
| 309 | + $return .= 'fsockopen: '.(function_exists('fsockopen') ? 'Supported' : 'Not Supported')."\n"; |
|
| 310 | + $return .= 'SOAP Client: '.(class_exists('SoapClient') ? 'Installed' : 'Not Installed')."\n"; |
|
| 311 | + $return .= 'Suhosin: '.(extension_loaded('suhosin') ? 'Installed' : 'Not Installed')."\n"; |
|
| 312 | + $return .= 'DOM: '.(extension_loaded('dom') ? 'Installed' : 'Not Installed')."\n"; |
|
| 313 | + $return .= 'MBString: '.(extension_loaded('mbstring') ? 'Installed' : 'Not Installed')."\n"; |
|
| 314 | 314 | |
| 315 | - $return = apply_filters( 'give_sysinfo_after_php_ext', $return ); |
|
| 315 | + $return = apply_filters('give_sysinfo_after_php_ext', $return); |
|
| 316 | 316 | |
| 317 | 317 | // Session stuff |
| 318 | - $return .= "\n" . '-- Session Configuration' . "\n\n"; |
|
| 319 | - $return .= 'Give Use Sessions: ' . ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ? 'Enforced' : ( Give()->session->use_php_sessions() ? 'Enabled' : 'Disabled' ) ) . "\n"; |
|
| 320 | - $return .= 'Session: ' . ( isset( $_SESSION ) ? 'Enabled' : 'Disabled' ) . "\n"; |
|
| 318 | + $return .= "\n".'-- Session Configuration'."\n\n"; |
|
| 319 | + $return .= 'Give Use Sessions: '.(defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS ? 'Enforced' : (Give()->session->use_php_sessions() ? 'Enabled' : 'Disabled'))."\n"; |
|
| 320 | + $return .= 'Session: '.(isset($_SESSION) ? 'Enabled' : 'Disabled')."\n"; |
|
| 321 | 321 | |
| 322 | 322 | // The rest of this is only relevant is session is enabled |
| 323 | - if ( isset( $_SESSION ) ) { |
|
| 324 | - $return .= 'Session Name: ' . esc_html( ini_get( 'session.name' ) ) . "\n"; |
|
| 325 | - $return .= 'Cookie Path: ' . esc_html( ini_get( 'session.cookie_path' ) ) . "\n"; |
|
| 326 | - $return .= 'Save Path: ' . esc_html( ini_get( 'session.save_path' ) ) . "\n"; |
|
| 327 | - $return .= 'Use Cookies: ' . ( ini_get( 'session.use_cookies' ) ? 'On' : 'Off' ) . "\n"; |
|
| 328 | - $return .= 'Use Only Cookies: ' . ( ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off' ) . "\n"; |
|
| 323 | + if (isset($_SESSION)) { |
|
| 324 | + $return .= 'Session Name: '.esc_html(ini_get('session.name'))."\n"; |
|
| 325 | + $return .= 'Cookie Path: '.esc_html(ini_get('session.cookie_path'))."\n"; |
|
| 326 | + $return .= 'Save Path: '.esc_html(ini_get('session.save_path'))."\n"; |
|
| 327 | + $return .= 'Use Cookies: '.(ini_get('session.use_cookies') ? 'On' : 'Off')."\n"; |
|
| 328 | + $return .= 'Use Only Cookies: '.(ini_get('session.use_only_cookies') ? 'On' : 'Off')."\n"; |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - $return = apply_filters( 'give_sysinfo_after_session_config', $return ); |
|
| 331 | + $return = apply_filters('give_sysinfo_after_session_config', $return); |
|
| 332 | 332 | |
| 333 | - $return .= "\n" . '### End System Info ###'; |
|
| 333 | + $return .= "\n".'### End System Info ###'; |
|
| 334 | 334 | |
| 335 | 335 | return $return; |
| 336 | 336 | } |
@@ -344,17 +344,17 @@ discard block |
||
| 344 | 344 | */ |
| 345 | 345 | function give_tools_sysinfo_download() { |
| 346 | 346 | |
| 347 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 347 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 348 | 348 | return; |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | nocache_headers(); |
| 352 | 352 | |
| 353 | - header( 'Content-Type: text/plain' ); |
|
| 354 | - header( 'Content-Disposition: attachment; filename="give-system-info.txt"' ); |
|
| 353 | + header('Content-Type: text/plain'); |
|
| 354 | + header('Content-Disposition: attachment; filename="give-system-info.txt"'); |
|
| 355 | 355 | |
| 356 | - echo wp_strip_all_tags( $_POST['give-sysinfo'] ); |
|
| 356 | + echo wp_strip_all_tags($_POST['give-sysinfo']); |
|
| 357 | 357 | give_die(); |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | -add_action( 'give_download_sysinfo', 'give_tools_sysinfo_download' ); |
|
| 361 | 360 | \ No newline at end of file |
| 361 | +add_action('give_download_sysinfo', 'give_tools_sysinfo_download'); |
|
| 362 | 362 | \ No newline at end of file |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | * @since 1.5 |
| 51 | 51 | * @global object $wpdb Used to query the database using the WordPress |
| 52 | 52 | * Database API |
| 53 | - * @return array $data The data for the CSV file |
|
| 53 | + * @return boolean $data The data for the CSV file |
|
| 54 | 54 | */ |
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $wpdb; |
@@ -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 | |
@@ -55,16 +55,16 @@ discard block |
||
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $wpdb; |
| 57 | 57 | |
| 58 | - $items = $this->get_stored_data( 'give_temp_reset_ids' ); |
|
| 58 | + $items = $this->get_stored_data('give_temp_reset_ids'); |
|
| 59 | 59 | |
| 60 | - if ( ! is_array( $items ) ) { |
|
| 60 | + if ( ! is_array($items)) { |
|
| 61 | 61 | return false; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
| 65 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
| 64 | + $offset = ($this->step - 1) * $this->per_step; |
|
| 65 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
| 66 | 66 | |
| 67 | - if ( $step_items ) { |
|
| 67 | + if ($step_items) { |
|
| 68 | 68 | |
| 69 | 69 | $step_ids = array( |
| 70 | 70 | 'customers' => array(), |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | 'other' => array(), |
| 73 | 73 | ); |
| 74 | 74 | |
| 75 | - foreach ( $step_items as $item ) { |
|
| 75 | + foreach ($step_items as $item) { |
|
| 76 | 76 | |
| 77 | - switch ( $item['type'] ) { |
|
| 77 | + switch ($item['type']) { |
|
| 78 | 78 | case 'customer': |
| 79 | 79 | $step_ids['customers'][] = $item['id']; |
| 80 | 80 | break; |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | $step_ids['give_forms'][] = $item['id']; |
| 83 | 83 | break; |
| 84 | 84 | default: |
| 85 | - $item_type = apply_filters( 'give_reset_item_type', 'other', $item ); |
|
| 86 | - $step_ids[ $item_type ][] = $item['id']; |
|
| 85 | + $item_type = apply_filters('give_reset_item_type', 'other', $item); |
|
| 86 | + $step_ids[$item_type][] = $item['id']; |
|
| 87 | 87 | break; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -91,17 +91,17 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | $sql = array(); |
| 93 | 93 | |
| 94 | - foreach ( $step_ids as $type => $ids ) { |
|
| 94 | + foreach ($step_ids as $type => $ids) { |
|
| 95 | 95 | |
| 96 | - if ( empty( $ids ) ) { |
|
| 96 | + if (empty($ids)) { |
|
| 97 | 97 | continue; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - $ids = implode( ',', $ids ); |
|
| 100 | + $ids = implode(',', $ids); |
|
| 101 | 101 | |
| 102 | - switch ( $type ) { |
|
| 102 | + switch ($type) { |
|
| 103 | 103 | case 'customers': |
| 104 | - $table_name = $wpdb->prefix . 'give_customers'; |
|
| 104 | + $table_name = $wpdb->prefix.'give_customers'; |
|
| 105 | 105 | $sql[] = "DELETE FROM $table_name WHERE id IN ($ids)"; |
| 106 | 106 | break; |
| 107 | 107 | case 'forms': |
@@ -116,18 +116,18 @@ discard block |
||
| 116 | 116 | break; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - if ( ! in_array( $type, array( 'customers', 'forms', 'other' ) ) ) { |
|
| 119 | + if ( ! in_array($type, array('customers', 'forms', 'other'))) { |
|
| 120 | 120 | // Allows other types of custom post types to filter on their own post_type |
| 121 | 121 | // and add items to the query list, for the IDs found in their post type. |
| 122 | - $sql = apply_filters( "give_reset_add_queries_{$type}", $sql, $ids ); |
|
| 122 | + $sql = apply_filters("give_reset_add_queries_{$type}", $sql, $ids); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - if ( ! empty( $sql ) ) { |
|
| 129 | - foreach ( $sql as $query ) { |
|
| 130 | - $wpdb->query( $query ); |
|
| 128 | + if ( ! empty($sql)) { |
|
| 129 | + foreach ($sql as $query) { |
|
| 130 | + $wpdb->query($query); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
@@ -147,16 +147,16 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public function get_percentage_complete() { |
| 149 | 149 | |
| 150 | - $items = $this->get_stored_data( 'give_temp_reset_ids', false ); |
|
| 151 | - $total = count( $items ); |
|
| 150 | + $items = $this->get_stored_data('give_temp_reset_ids', false); |
|
| 151 | + $total = count($items); |
|
| 152 | 152 | |
| 153 | 153 | $percentage = 100; |
| 154 | 154 | |
| 155 | - if ( $total > 0 ) { |
|
| 156 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 155 | + if ($total > 0) { |
|
| 156 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if ( $percentage > 100 ) { |
|
| 159 | + if ($percentage > 100) { |
|
| 160 | 160 | $percentage = 100; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * |
| 171 | 171 | * @param array $request The Form Data passed into the batch processing |
| 172 | 172 | */ |
| 173 | - public function set_properties( $request ) { |
|
| 173 | + public function set_properties($request) { |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -181,30 +181,30 @@ discard block |
||
| 181 | 181 | */ |
| 182 | 182 | public function process_step() { |
| 183 | 183 | |
| 184 | - if ( ! $this->can_export() ) { |
|
| 185 | - wp_die( esc_html__( 'You do not have permission to reset data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 184 | + if ( ! $this->can_export()) { |
|
| 185 | + wp_die(esc_html__('You do not have permission to reset data.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | $had_data = $this->get_data(); |
| 189 | 189 | |
| 190 | - if ( $had_data ) { |
|
| 190 | + if ($had_data) { |
|
| 191 | 191 | $this->done = false; |
| 192 | 192 | |
| 193 | 193 | return true; |
| 194 | 194 | } else { |
| 195 | - update_option( 'give_earnings_total', 0 ); |
|
| 196 | - delete_transient( 'give_earnings_total' ); |
|
| 197 | - delete_transient( 'give_estimated_monthly_stats' . true ); |
|
| 198 | - delete_transient( 'give_estimated_monthly_stats' . false ); |
|
| 199 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
| 195 | + update_option('give_earnings_total', 0); |
|
| 196 | + delete_transient('give_earnings_total'); |
|
| 197 | + delete_transient('give_estimated_monthly_stats'.true); |
|
| 198 | + delete_transient('give_estimated_monthly_stats'.false); |
|
| 199 | + $this->delete_data('give_temp_reset_ids'); |
|
| 200 | 200 | |
| 201 | 201 | // Reset the sequential order numbers |
| 202 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 203 | - delete_option( 'give_last_payment_number' ); |
|
| 202 | + if (give_get_option('enable_sequential')) { |
|
| 203 | + delete_option('give_last_payment_number'); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | $this->done = true; |
| 207 | - $this->message = esc_html__( 'Donation forms, income, donations counts, and logs successfully reset.', 'give' ); |
|
| 207 | + $this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give'); |
|
| 208 | 208 | |
| 209 | 209 | return false; |
| 210 | 210 | } |
@@ -214,10 +214,10 @@ discard block |
||
| 214 | 214 | * Headers |
| 215 | 215 | */ |
| 216 | 216 | public function headers() { |
| 217 | - ignore_user_abort( true ); |
|
| 217 | + ignore_user_abort(true); |
|
| 218 | 218 | |
| 219 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 220 | - set_time_limit( 0 ); |
|
| 219 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 220 | + set_time_limit(0); |
|
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | |
@@ -241,35 +241,35 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | public function pre_fetch() { |
| 243 | 243 | |
| 244 | - if ( $this->step == 1 ) { |
|
| 245 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
| 244 | + if ($this->step == 1) { |
|
| 245 | + $this->delete_data('give_temp_reset_ids'); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - $items = get_option( 'give_temp_reset_ids', false ); |
|
| 248 | + $items = get_option('give_temp_reset_ids', false); |
|
| 249 | 249 | |
| 250 | - if ( false === $items ) { |
|
| 250 | + if (false === $items) { |
|
| 251 | 251 | $items = array(); |
| 252 | 252 | |
| 253 | - $give_types_for_reset = array( 'give_forms', 'give_log', 'give_payment' ); |
|
| 254 | - $give_types_for_reset = apply_filters( 'give_reset_store_post_types', $give_types_for_reset ); |
|
| 253 | + $give_types_for_reset = array('give_forms', 'give_log', 'give_payment'); |
|
| 254 | + $give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset); |
|
| 255 | 255 | |
| 256 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
| 256 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
| 257 | 257 | 'post_type' => $give_types_for_reset, |
| 258 | 258 | 'post_status' => 'any', |
| 259 | - 'posts_per_page' => - 1, |
|
| 260 | - ) ); |
|
| 259 | + 'posts_per_page' => -1, |
|
| 260 | + )); |
|
| 261 | 261 | |
| 262 | - $posts = get_posts( $args ); |
|
| 263 | - foreach ( $posts as $post ) { |
|
| 262 | + $posts = get_posts($args); |
|
| 263 | + foreach ($posts as $post) { |
|
| 264 | 264 | $items[] = array( |
| 265 | 265 | 'id' => (int) $post->ID, |
| 266 | 266 | 'type' => $post->post_type, |
| 267 | 267 | ); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - $customer_args = array( 'number' => - 1 ); |
|
| 271 | - $customers = Give()->customers->get_customers( $customer_args ); |
|
| 272 | - foreach ( $customers as $customer ) { |
|
| 270 | + $customer_args = array('number' => -1); |
|
| 271 | + $customers = Give()->customers->get_customers($customer_args); |
|
| 272 | + foreach ($customers as $customer) { |
|
| 273 | 273 | $items[] = array( |
| 274 | 274 | 'id' => (int) $customer->id, |
| 275 | 275 | 'type' => 'customer', |
@@ -278,9 +278,9 @@ discard block |
||
| 278 | 278 | |
| 279 | 279 | // Allow filtering of items to remove with an unassociative array for each item |
| 280 | 280 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method |
| 281 | - $items = apply_filters( 'give_reset_items', $items ); |
|
| 281 | + $items = apply_filters('give_reset_items', $items); |
|
| 282 | 282 | |
| 283 | - $this->store_data( 'give_temp_reset_ids', $items ); |
|
| 283 | + $this->store_data('give_temp_reset_ids', $items); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | } |
@@ -294,11 +294,11 @@ discard block |
||
| 294 | 294 | * |
| 295 | 295 | * @return mixed Returns the data from the database. |
| 296 | 296 | */ |
| 297 | - private function get_stored_data( $key ) { |
|
| 297 | + private function get_stored_data($key) { |
|
| 298 | 298 | global $wpdb; |
| 299 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 299 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 300 | 300 | |
| 301 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
| 301 | + return empty($value) ? false : maybe_unserialize($value); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
@@ -311,10 +311,10 @@ discard block |
||
| 311 | 311 | * |
| 312 | 312 | * @return void |
| 313 | 313 | */ |
| 314 | - private function store_data( $key, $value ) { |
|
| 314 | + private function store_data($key, $value) { |
|
| 315 | 315 | global $wpdb; |
| 316 | 316 | |
| 317 | - $value = maybe_serialize( $value ); |
|
| 317 | + $value = maybe_serialize($value); |
|
| 318 | 318 | |
| 319 | 319 | $data = array( |
| 320 | 320 | 'option_name' => $key, |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | '%s', |
| 329 | 329 | ); |
| 330 | 330 | |
| 331 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 331 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | /** |
@@ -340,9 +340,9 @@ discard block |
||
| 340 | 340 | * |
| 341 | 341 | * @return void |
| 342 | 342 | */ |
| 343 | - private function delete_data( $key ) { |
|
| 343 | + private function delete_data($key) { |
|
| 344 | 344 | global $wpdb; |
| 345 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 345 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | } |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | * |
| 294 | 294 | * @param int $payment_id A given payment |
| 295 | 295 | * |
| 296 | - * @return mixed void|false |
|
| 296 | + * @return false|null void|false |
|
| 297 | 297 | */ |
| 298 | 298 | public function __construct( $payment_id = false ) { |
| 299 | 299 | |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | * |
| 362 | 362 | * @param string $name The attribute to get |
| 363 | 363 | * |
| 364 | - * @return boolean If the item is set or not |
|
| 364 | + * @return boolean|null If the item is set or not |
|
| 365 | 365 | */ |
| 366 | 366 | public function __isset( $name ) { |
| 367 | 367 | if ( property_exists( $this, $name ) ) { |
@@ -1149,7 +1149,7 @@ discard block |
||
| 1149 | 1149 | * |
| 1150 | 1150 | * @param string $note The note to add |
| 1151 | 1151 | * |
| 1152 | - * @return void |
|
| 1152 | + * @return false|null |
|
| 1153 | 1153 | */ |
| 1154 | 1154 | public function add_note( $note = false ) { |
| 1155 | 1155 | // Bail if no note specified |
@@ -899,7 +899,7 @@ |
||
| 899 | 899 | //Find a match between price_id and level_id |
| 900 | 900 | //First verify array keys exists THEN make the match |
| 901 | 901 | if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) ) |
| 902 | - && $args['price_id'] == $price['_give_id']['level_id'] |
|
| 902 | + && $args['price_id'] == $price['_give_id']['level_id'] |
|
| 903 | 903 | ) { |
| 904 | 904 | $item_price = $price['_give_amount']; |
| 905 | 905 | } |
@@ -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 | |
@@ -392,13 +392,13 @@ discard block |
||
| 392 | 392 | * |
| 393 | 393 | * @return mixed void|false |
| 394 | 394 | */ |
| 395 | - public function __construct( $payment_id = false ) { |
|
| 395 | + public function __construct($payment_id = false) { |
|
| 396 | 396 | |
| 397 | - if ( empty( $payment_id ) ) { |
|
| 397 | + if (empty($payment_id)) { |
|
| 398 | 398 | return false; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - $this->setup_payment( $payment_id ); |
|
| 401 | + $this->setup_payment($payment_id); |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | /** |
@@ -411,11 +411,11 @@ discard block |
||
| 411 | 411 | * |
| 412 | 412 | * @return mixed The value. |
| 413 | 413 | */ |
| 414 | - public function __get( $key ) { |
|
| 414 | + public function __get($key) { |
|
| 415 | 415 | |
| 416 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
| 416 | + if (method_exists($this, 'get_'.$key)) { |
|
| 417 | 417 | |
| 418 | - $value = call_user_func( array( $this, 'get_' . $key ) ); |
|
| 418 | + $value = call_user_func(array($this, 'get_'.$key)); |
|
| 419 | 419 | |
| 420 | 420 | } else { |
| 421 | 421 | |
@@ -437,18 +437,18 @@ discard block |
||
| 437 | 437 | * @param string $key The property name |
| 438 | 438 | * @param mixed $value The value of the property |
| 439 | 439 | */ |
| 440 | - public function __set( $key, $value ) { |
|
| 441 | - $ignore = array( '_ID' ); |
|
| 440 | + public function __set($key, $value) { |
|
| 441 | + $ignore = array('_ID'); |
|
| 442 | 442 | |
| 443 | - if ( $key === 'status' ) { |
|
| 443 | + if ($key === 'status') { |
|
| 444 | 444 | $this->old_status = $this->status; |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - if ( ! in_array( $key, $ignore ) ) { |
|
| 448 | - $this->pending[ $key ] = $value; |
|
| 447 | + if ( ! in_array($key, $ignore)) { |
|
| 448 | + $this->pending[$key] = $value; |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | - if ( '_ID' !== $key ) { |
|
| 451 | + if ('_ID' !== $key) { |
|
| 452 | 452 | $this->$key = $value; |
| 453 | 453 | } |
| 454 | 454 | } |
@@ -463,9 +463,9 @@ discard block |
||
| 463 | 463 | * |
| 464 | 464 | * @return boolean If the item is set or not |
| 465 | 465 | */ |
| 466 | - public function __isset( $name ) { |
|
| 467 | - if ( property_exists( $this, $name ) ) { |
|
| 468 | - return false === empty( $this->$name ); |
|
| 466 | + public function __isset($name) { |
|
| 467 | + if (property_exists($this, $name)) { |
|
| 468 | + return false === empty($this->$name); |
|
| 469 | 469 | } else { |
| 470 | 470 | return null; |
| 471 | 471 | } |
@@ -481,20 +481,20 @@ discard block |
||
| 481 | 481 | * |
| 482 | 482 | * @return bool If the setup was successful or not |
| 483 | 483 | */ |
| 484 | - private function setup_payment( $payment_id ) { |
|
| 484 | + private function setup_payment($payment_id) { |
|
| 485 | 485 | $this->pending = array(); |
| 486 | 486 | |
| 487 | - if ( empty( $payment_id ) ) { |
|
| 487 | + if (empty($payment_id)) { |
|
| 488 | 488 | return false; |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | - $payment = get_post( $payment_id ); |
|
| 491 | + $payment = get_post($payment_id); |
|
| 492 | 492 | |
| 493 | - if ( ! $payment || is_wp_error( $payment ) ) { |
|
| 493 | + if ( ! $payment || is_wp_error($payment)) { |
|
| 494 | 494 | return false; |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | - if ( 'give_payment' !== $payment->post_type ) { |
|
| 497 | + if ('give_payment' !== $payment->post_type) { |
|
| 498 | 498 | return false; |
| 499 | 499 | } |
| 500 | 500 | |
@@ -508,13 +508,13 @@ discard block |
||
| 508 | 508 | * @param Give_Payment $this Payment object. |
| 509 | 509 | * @param int $payment_id The ID of the payment. |
| 510 | 510 | */ |
| 511 | - do_action( 'give_pre_setup_payment', $this, $payment_id ); |
|
| 511 | + do_action('give_pre_setup_payment', $this, $payment_id); |
|
| 512 | 512 | |
| 513 | 513 | // Primary Identifier. |
| 514 | - $this->ID = absint( $payment_id ); |
|
| 514 | + $this->ID = absint($payment_id); |
|
| 515 | 515 | |
| 516 | 516 | // Protected ID that can never be changed. |
| 517 | - $this->_ID = absint( $payment_id ); |
|
| 517 | + $this->_ID = absint($payment_id); |
|
| 518 | 518 | |
| 519 | 519 | // We have a payment, get the generic payment_meta item to reduce calls to it. |
| 520 | 520 | $this->payment_meta = $this->get_meta(); |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | $this->parent_payment = $payment->post_parent; |
| 530 | 530 | |
| 531 | 531 | $all_payment_statuses = give_get_payment_statuses(); |
| 532 | - $this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status ); |
|
| 532 | + $this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status); |
|
| 533 | 533 | |
| 534 | 534 | // Items. |
| 535 | 535 | $this->fees = $this->setup_fees(); |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | * @param Give_Payment $this Payment object. |
| 572 | 572 | * @param int $payment_id The ID of the payment. |
| 573 | 573 | */ |
| 574 | - do_action( 'give_setup_payment', $this, $payment_id ); |
|
| 574 | + do_action('give_setup_payment', $this, $payment_id); |
|
| 575 | 575 | |
| 576 | 576 | return true; |
| 577 | 577 | } |
@@ -589,8 +589,8 @@ discard block |
||
| 589 | 589 | * |
| 590 | 590 | * @return void |
| 591 | 591 | */ |
| 592 | - public function update_payment_setup( $payment_id ) { |
|
| 593 | - $this->setup_payment( $payment_id ); |
|
| 592 | + public function update_payment_setup($payment_id) { |
|
| 593 | + $this->setup_payment($payment_id); |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | /** |
@@ -605,24 +605,24 @@ discard block |
||
| 605 | 605 | |
| 606 | 606 | // Construct the payment title. |
| 607 | 607 | $payment_title = ''; |
| 608 | - if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) { |
|
| 609 | - $payment_title = $this->first_name . ' ' . $this->last_name; |
|
| 610 | - } elseif ( ! empty( $this->first_name ) && empty( $this->last_name ) ) { |
|
| 608 | + if ( ! empty($this->first_name) && ! empty($this->last_name)) { |
|
| 609 | + $payment_title = $this->first_name.' '.$this->last_name; |
|
| 610 | + } elseif ( ! empty($this->first_name) && empty($this->last_name)) { |
|
| 611 | 611 | $payment_title = $this->first_name; |
| 612 | - } elseif ( ! empty( $this->email ) && is_email( $this->email ) ) { |
|
| 612 | + } elseif ( ! empty($this->email) && is_email($this->email)) { |
|
| 613 | 613 | $payment_title = $this->email; |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | // Set Key. |
| 617 | - if ( empty( $this->key ) ) { |
|
| 617 | + if (empty($this->key)) { |
|
| 618 | 618 | |
| 619 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 620 | - $this->key = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); // Unique key |
|
| 619 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 620 | + $this->key = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key |
|
| 621 | 621 | $this->pending['key'] = $this->key; |
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | // Set IP. |
| 625 | - if ( empty( $this->ip ) ) { |
|
| 625 | + if (empty($this->ip)) { |
|
| 626 | 626 | |
| 627 | 627 | $this->ip = give_get_ip(); |
| 628 | 628 | $this->pending['ip'] = $this->ip; |
@@ -649,63 +649,63 @@ discard block |
||
| 649 | 649 | 'fees' => $this->fees, |
| 650 | 650 | ); |
| 651 | 651 | |
| 652 | - $args = apply_filters( 'give_insert_payment_args', array( |
|
| 652 | + $args = apply_filters('give_insert_payment_args', array( |
|
| 653 | 653 | 'post_title' => $payment_title, |
| 654 | 654 | 'post_status' => $this->status, |
| 655 | 655 | 'post_type' => 'give_payment', |
| 656 | - 'post_date' => ! empty( $this->date ) ? $this->date : null, |
|
| 657 | - 'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null, |
|
| 656 | + 'post_date' => ! empty($this->date) ? $this->date : null, |
|
| 657 | + 'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null, |
|
| 658 | 658 | 'post_parent' => $this->parent_payment, |
| 659 | - ), $payment_data ); |
|
| 659 | + ), $payment_data); |
|
| 660 | 660 | |
| 661 | 661 | // Create a blank payment |
| 662 | - $payment_id = wp_insert_post( $args ); |
|
| 662 | + $payment_id = wp_insert_post($args); |
|
| 663 | 663 | |
| 664 | - if ( ! empty( $payment_id ) ) { |
|
| 664 | + if ( ! empty($payment_id)) { |
|
| 665 | 665 | |
| 666 | 666 | $this->ID = $payment_id; |
| 667 | 667 | $this->_ID = $payment_id; |
| 668 | 668 | |
| 669 | 669 | $customer = new stdClass; |
| 670 | 670 | |
| 671 | - if ( did_action( 'give_pre_process_donation' ) && is_user_logged_in() ) { |
|
| 672 | - $customer = new Give_Customer( get_current_user_id(), true ); |
|
| 671 | + if (did_action('give_pre_process_donation') && is_user_logged_in()) { |
|
| 672 | + $customer = new Give_Customer(get_current_user_id(), true); |
|
| 673 | 673 | |
| 674 | 674 | // Customer is logged in but used a different email to purchase with so assign to their customer record |
| 675 | - if ( ! empty( $customer->id ) && $this->email != $customer->email ) { |
|
| 676 | - $customer->add_email( $this->email ); |
|
| 675 | + if ( ! empty($customer->id) && $this->email != $customer->email) { |
|
| 676 | + $customer->add_email($this->email); |
|
| 677 | 677 | } |
| 678 | 678 | } |
| 679 | 679 | |
| 680 | - if ( empty( $customer->id ) ) { |
|
| 681 | - $customer = new Give_Customer( $this->email ); |
|
| 680 | + if (empty($customer->id)) { |
|
| 681 | + $customer = new Give_Customer($this->email); |
|
| 682 | 682 | } |
| 683 | 683 | |
| 684 | - if ( empty( $customer->id ) ) { |
|
| 684 | + if (empty($customer->id)) { |
|
| 685 | 685 | |
| 686 | 686 | $customer_data = array( |
| 687 | - 'name' => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '', |
|
| 687 | + 'name' => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '', |
|
| 688 | 688 | 'email' => $this->email, |
| 689 | 689 | 'user_id' => $this->user_id, |
| 690 | 690 | ); |
| 691 | 691 | |
| 692 | - $customer->create( $customer_data ); |
|
| 692 | + $customer->create($customer_data); |
|
| 693 | 693 | |
| 694 | 694 | } |
| 695 | 695 | |
| 696 | 696 | $this->customer_id = $customer->id; |
| 697 | 697 | $this->pending['customer_id'] = $this->customer_id; |
| 698 | - $customer->attach_payment( $this->ID, false ); |
|
| 698 | + $customer->attach_payment($this->ID, false); |
|
| 699 | 699 | |
| 700 | - $this->payment_meta = apply_filters( 'give_payment_meta', $this->payment_meta, $payment_data ); |
|
| 701 | - if ( ! empty( $this->payment_meta['fees'] ) ) { |
|
| 702 | - $this->fees = array_merge( $this->fees, $this->payment_meta['fees'] ); |
|
| 703 | - foreach ( $this->fees as $fee ) { |
|
| 704 | - $this->increase_fees( $fee['amount'] ); |
|
| 700 | + $this->payment_meta = apply_filters('give_payment_meta', $this->payment_meta, $payment_data); |
|
| 701 | + if ( ! empty($this->payment_meta['fees'])) { |
|
| 702 | + $this->fees = array_merge($this->fees, $this->payment_meta['fees']); |
|
| 703 | + foreach ($this->fees as $fee) { |
|
| 704 | + $this->increase_fees($fee['amount']); |
|
| 705 | 705 | } |
| 706 | 706 | } |
| 707 | 707 | |
| 708 | - $this->update_meta( '_give_payment_meta', $this->payment_meta ); |
|
| 708 | + $this->update_meta('_give_payment_meta', $this->payment_meta); |
|
| 709 | 709 | $this->new = true; |
| 710 | 710 | } |
| 711 | 711 | |
@@ -727,11 +727,11 @@ discard block |
||
| 727 | 727 | $saved = false; |
| 728 | 728 | |
| 729 | 729 | // Must have an ID. |
| 730 | - if ( empty( $this->ID ) ) { |
|
| 730 | + if (empty($this->ID)) { |
|
| 731 | 731 | |
| 732 | 732 | $payment_id = $this->insert_payment(); |
| 733 | 733 | |
| 734 | - if ( false === $payment_id ) { |
|
| 734 | + if (false === $payment_id) { |
|
| 735 | 735 | $saved = false; |
| 736 | 736 | } else { |
| 737 | 737 | $this->ID = $payment_id; |
@@ -739,48 +739,48 @@ discard block |
||
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | // Set ID if not matching. |
| 742 | - if ( $this->ID !== $this->_ID ) { |
|
| 742 | + if ($this->ID !== $this->_ID) { |
|
| 743 | 743 | $this->ID = $this->_ID; |
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | // If we have something pending, let's save it. |
| 747 | - if ( ! empty( $this->pending ) ) { |
|
| 747 | + if ( ! empty($this->pending)) { |
|
| 748 | 748 | |
| 749 | 749 | $total_increase = 0; |
| 750 | 750 | $total_decrease = 0; |
| 751 | 751 | |
| 752 | - foreach ( $this->pending as $key => $value ) { |
|
| 752 | + foreach ($this->pending as $key => $value) { |
|
| 753 | 753 | |
| 754 | - switch ( $key ) { |
|
| 754 | + switch ($key) { |
|
| 755 | 755 | |
| 756 | 756 | case 'donations': |
| 757 | 757 | // Update totals for pending donations. |
| 758 | - foreach ( $this->pending[ $key ] as $item ) { |
|
| 758 | + foreach ($this->pending[$key] as $item) { |
|
| 759 | 759 | |
| 760 | - $quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1; |
|
| 761 | - $price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0; |
|
| 760 | + $quantity = isset($item['quantity']) ? $item['quantity'] : 1; |
|
| 761 | + $price_id = isset($item['price_id']) ? $item['price_id'] : 0; |
|
| 762 | 762 | |
| 763 | - switch ( $item['action'] ) { |
|
| 763 | + switch ($item['action']) { |
|
| 764 | 764 | |
| 765 | 765 | case 'add': |
| 766 | 766 | |
| 767 | 767 | $price = $item['price']; |
| 768 | 768 | |
| 769 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
| 769 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
| 770 | 770 | |
| 771 | 771 | // Add sales logs. |
| 772 | - $log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) ); |
|
| 772 | + $log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp')); |
|
| 773 | 773 | |
| 774 | 774 | $y = 0; |
| 775 | - while ( $y < $quantity ) { |
|
| 775 | + while ($y < $quantity) { |
|
| 776 | 776 | |
| 777 | - give_record_sale_in_log( $item['id'], $this->ID, $price_id, $log_date ); |
|
| 778 | - $y ++; |
|
| 777 | + give_record_sale_in_log($item['id'], $this->ID, $price_id, $log_date); |
|
| 778 | + $y++; |
|
| 779 | 779 | } |
| 780 | 780 | |
| 781 | - $form = new Give_Donate_Form( $item['id'] ); |
|
| 782 | - $form->increase_sales( $quantity ); |
|
| 783 | - $form->increase_earnings( $price ); |
|
| 781 | + $form = new Give_Donate_Form($item['id']); |
|
| 782 | + $form->increase_sales($quantity); |
|
| 783 | + $form->increase_earnings($price); |
|
| 784 | 784 | |
| 785 | 785 | $total_increase += $price; |
| 786 | 786 | } |
@@ -805,15 +805,15 @@ discard block |
||
| 805 | 805 | ), |
| 806 | 806 | ); |
| 807 | 807 | |
| 808 | - $found_logs = get_posts( $log_args ); |
|
| 809 | - foreach ( $found_logs as $log ) { |
|
| 810 | - wp_delete_post( $log->ID, true ); |
|
| 808 | + $found_logs = get_posts($log_args); |
|
| 809 | + foreach ($found_logs as $log) { |
|
| 810 | + wp_delete_post($log->ID, true); |
|
| 811 | 811 | } |
| 812 | 812 | |
| 813 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
| 814 | - $form = new Give_Donate_Form( $item['id'] ); |
|
| 815 | - $form->decrease_sales( $quantity ); |
|
| 816 | - $form->decrease_earnings( $item['amount'] ); |
|
| 813 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
| 814 | + $form = new Give_Donate_Form($item['id']); |
|
| 815 | + $form->decrease_sales($quantity); |
|
| 816 | + $form->decrease_earnings($item['amount']); |
|
| 817 | 817 | |
| 818 | 818 | $total_decrease += $item['amount']; |
| 819 | 819 | } |
@@ -825,17 +825,17 @@ discard block |
||
| 825 | 825 | |
| 826 | 826 | case 'fees': |
| 827 | 827 | |
| 828 | - if ( 'publish' !== $this->status && 'complete' !== $this->status ) { |
|
| 828 | + if ('publish' !== $this->status && 'complete' !== $this->status) { |
|
| 829 | 829 | break; |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | - if ( empty( $this->pending[ $key ] ) ) { |
|
| 832 | + if (empty($this->pending[$key])) { |
|
| 833 | 833 | break; |
| 834 | 834 | } |
| 835 | 835 | |
| 836 | - foreach ( $this->pending[ $key ] as $fee ) { |
|
| 836 | + foreach ($this->pending[$key] as $fee) { |
|
| 837 | 837 | |
| 838 | - switch ( $fee['action'] ) { |
|
| 838 | + switch ($fee['action']) { |
|
| 839 | 839 | |
| 840 | 840 | case 'add': |
| 841 | 841 | $total_increase += $fee['amount']; |
@@ -851,43 +851,43 @@ discard block |
||
| 851 | 851 | break; |
| 852 | 852 | |
| 853 | 853 | case 'status': |
| 854 | - $this->update_status( $this->status ); |
|
| 854 | + $this->update_status($this->status); |
|
| 855 | 855 | break; |
| 856 | 856 | |
| 857 | 857 | case 'gateway': |
| 858 | - $this->update_meta( '_give_payment_gateway', $this->gateway ); |
|
| 858 | + $this->update_meta('_give_payment_gateway', $this->gateway); |
|
| 859 | 859 | break; |
| 860 | 860 | |
| 861 | 861 | case 'mode': |
| 862 | - $this->update_meta( '_give_payment_mode', $this->mode ); |
|
| 862 | + $this->update_meta('_give_payment_mode', $this->mode); |
|
| 863 | 863 | break; |
| 864 | 864 | |
| 865 | 865 | case 'transaction_id': |
| 866 | - $this->update_meta( '_give_payment_transaction_id', $this->transaction_id ); |
|
| 866 | + $this->update_meta('_give_payment_transaction_id', $this->transaction_id); |
|
| 867 | 867 | break; |
| 868 | 868 | |
| 869 | 869 | case 'ip': |
| 870 | - $this->update_meta( '_give_payment_user_ip', $this->ip ); |
|
| 870 | + $this->update_meta('_give_payment_user_ip', $this->ip); |
|
| 871 | 871 | break; |
| 872 | 872 | |
| 873 | 873 | case 'customer_id': |
| 874 | - $this->update_meta( '_give_payment_customer_id', $this->customer_id ); |
|
| 874 | + $this->update_meta('_give_payment_customer_id', $this->customer_id); |
|
| 875 | 875 | break; |
| 876 | 876 | |
| 877 | 877 | case 'user_id': |
| 878 | - $this->update_meta( '_give_payment_user_id', $this->user_id ); |
|
| 878 | + $this->update_meta('_give_payment_user_id', $this->user_id); |
|
| 879 | 879 | break; |
| 880 | 880 | |
| 881 | 881 | case 'form_title': |
| 882 | - $this->update_meta( '_give_payment_form_title', $this->form_title ); |
|
| 882 | + $this->update_meta('_give_payment_form_title', $this->form_title); |
|
| 883 | 883 | break; |
| 884 | 884 | |
| 885 | 885 | case 'form_id': |
| 886 | - $this->update_meta( '_give_payment_form_id', $this->form_id ); |
|
| 886 | + $this->update_meta('_give_payment_form_id', $this->form_id); |
|
| 887 | 887 | break; |
| 888 | 888 | |
| 889 | 889 | case 'price_id': |
| 890 | - $this->update_meta( '_give_payment_price_id', $this->price_id ); |
|
| 890 | + $this->update_meta('_give_payment_price_id', $this->price_id); |
|
| 891 | 891 | break; |
| 892 | 892 | |
| 893 | 893 | case 'first_name': |
@@ -903,15 +903,15 @@ discard block |
||
| 903 | 903 | break; |
| 904 | 904 | |
| 905 | 905 | case 'email': |
| 906 | - $this->update_meta( '_give_payment_user_email', $this->email ); |
|
| 906 | + $this->update_meta('_give_payment_user_email', $this->email); |
|
| 907 | 907 | break; |
| 908 | 908 | |
| 909 | 909 | case 'key': |
| 910 | - $this->update_meta( '_give_payment_purchase_key', $this->key ); |
|
| 910 | + $this->update_meta('_give_payment_purchase_key', $this->key); |
|
| 911 | 911 | break; |
| 912 | 912 | |
| 913 | 913 | case 'number': |
| 914 | - $this->update_meta( '_give_payment_number', $this->number ); |
|
| 914 | + $this->update_meta('_give_payment_number', $this->number); |
|
| 915 | 915 | break; |
| 916 | 916 | |
| 917 | 917 | case 'date': |
@@ -921,11 +921,11 @@ discard block |
||
| 921 | 921 | 'edit_date' => true, |
| 922 | 922 | ); |
| 923 | 923 | |
| 924 | - wp_update_post( $args ); |
|
| 924 | + wp_update_post($args); |
|
| 925 | 925 | break; |
| 926 | 926 | |
| 927 | 927 | case 'completed_date': |
| 928 | - $this->update_meta( '_give_completed_date', $this->completed_date ); |
|
| 928 | + $this->update_meta('_give_completed_date', $this->completed_date); |
|
| 929 | 929 | break; |
| 930 | 930 | |
| 931 | 931 | case 'parent_payment': |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | 'post_parent' => $this->parent_payment, |
| 935 | 935 | ); |
| 936 | 936 | |
| 937 | - wp_update_post( $args ); |
|
| 937 | + wp_update_post($args); |
|
| 938 | 938 | break; |
| 939 | 939 | |
| 940 | 940 | default: |
@@ -945,33 +945,33 @@ discard block |
||
| 945 | 945 | * |
| 946 | 946 | * @param Give_Payment $this Payment object. |
| 947 | 947 | */ |
| 948 | - do_action( 'give_payment_save', $this, $key ); |
|
| 948 | + do_action('give_payment_save', $this, $key); |
|
| 949 | 949 | break; |
| 950 | 950 | } |
| 951 | 951 | } |
| 952 | 952 | |
| 953 | - if ( 'pending' !== $this->status ) { |
|
| 953 | + if ('pending' !== $this->status) { |
|
| 954 | 954 | |
| 955 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 955 | + $customer = new Give_Customer($this->customer_id); |
|
| 956 | 956 | |
| 957 | 957 | $total_change = $total_increase - $total_decrease; |
| 958 | - if ( $total_change < 0 ) { |
|
| 958 | + if ($total_change < 0) { |
|
| 959 | 959 | |
| 960 | - $total_change = - ( $total_change ); |
|
| 960 | + $total_change = - ($total_change); |
|
| 961 | 961 | // Decrease the customer's donation stats. |
| 962 | - $customer->decrease_value( $total_change ); |
|
| 963 | - give_decrease_total_earnings( $total_change ); |
|
| 962 | + $customer->decrease_value($total_change); |
|
| 963 | + give_decrease_total_earnings($total_change); |
|
| 964 | 964 | |
| 965 | - } elseif ( $total_change > 0 ) { |
|
| 965 | + } elseif ($total_change > 0) { |
|
| 966 | 966 | |
| 967 | 967 | // Increase the customer's donation stats. |
| 968 | - $customer->increase_value( $total_change ); |
|
| 969 | - give_increase_total_earnings( $total_change ); |
|
| 968 | + $customer->increase_value($total_change); |
|
| 969 | + give_increase_total_earnings($total_change); |
|
| 970 | 970 | |
| 971 | 971 | } |
| 972 | 972 | } |
| 973 | 973 | |
| 974 | - $this->update_meta( '_give_payment_total', $this->total ); |
|
| 974 | + $this->update_meta('_give_payment_total', $this->total); |
|
| 975 | 975 | |
| 976 | 976 | $new_meta = array( |
| 977 | 977 | 'form_title' => $this->form_title, |
@@ -983,12 +983,12 @@ discard block |
||
| 983 | 983 | ); |
| 984 | 984 | |
| 985 | 985 | $meta = $this->get_meta(); |
| 986 | - $merged_meta = array_merge( $meta, $new_meta ); |
|
| 986 | + $merged_meta = array_merge($meta, $new_meta); |
|
| 987 | 987 | |
| 988 | 988 | // Only save the payment meta if it's changed. |
| 989 | - if ( md5( serialize( $meta ) ) !== md5( serialize( $merged_meta ) ) ) { |
|
| 990 | - $updated = $this->update_meta( '_give_payment_meta', $merged_meta ); |
|
| 991 | - if ( false !== $updated ) { |
|
| 989 | + if (md5(serialize($meta)) !== md5(serialize($merged_meta))) { |
|
| 990 | + $updated = $this->update_meta('_give_payment_meta', $merged_meta); |
|
| 991 | + if (false !== $updated) { |
|
| 992 | 992 | $saved = true; |
| 993 | 993 | } |
| 994 | 994 | } |
@@ -997,8 +997,8 @@ discard block |
||
| 997 | 997 | $saved = true; |
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | - if ( true === $saved ) { |
|
| 1001 | - $this->setup_payment( $this->ID ); |
|
| 1000 | + if (true === $saved) { |
|
| 1001 | + $this->setup_payment($this->ID); |
|
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | 1004 | return $saved; |
@@ -1016,12 +1016,12 @@ discard block |
||
| 1016 | 1016 | * |
| 1017 | 1017 | * @return bool True when successful, false otherwise |
| 1018 | 1018 | */ |
| 1019 | - public function add_donation( $form_id = 0, $args = array(), $options = array() ) { |
|
| 1019 | + public function add_donation($form_id = 0, $args = array(), $options = array()) { |
|
| 1020 | 1020 | |
| 1021 | - $donation = new Give_Donate_Form( $form_id ); |
|
| 1021 | + $donation = new Give_Donate_Form($form_id); |
|
| 1022 | 1022 | |
| 1023 | 1023 | // Bail if this post isn't a give donation form. |
| 1024 | - if ( ! $donation || $donation->post_type !== 'give_forms' ) { |
|
| 1024 | + if ( ! $donation || $donation->post_type !== 'give_forms') { |
|
| 1025 | 1025 | return false; |
| 1026 | 1026 | } |
| 1027 | 1027 | |
@@ -1032,59 +1032,59 @@ discard block |
||
| 1032 | 1032 | 'fees' => array(), |
| 1033 | 1033 | ); |
| 1034 | 1034 | |
| 1035 | - $args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults ); |
|
| 1035 | + $args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults); |
|
| 1036 | 1036 | |
| 1037 | 1037 | // Allow overriding the price. |
| 1038 | - if ( false !== $args['price'] ) { |
|
| 1038 | + if (false !== $args['price']) { |
|
| 1039 | 1039 | $item_price = $args['price']; |
| 1040 | 1040 | } else { |
| 1041 | 1041 | |
| 1042 | 1042 | // Deal with variable pricing. |
| 1043 | - if ( give_has_variable_prices( $donation->ID ) ) { |
|
| 1044 | - $prices = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) ); |
|
| 1043 | + if (give_has_variable_prices($donation->ID)) { |
|
| 1044 | + $prices = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true)); |
|
| 1045 | 1045 | $item_price = ''; |
| 1046 | 1046 | // Loop through prices. |
| 1047 | - foreach ( $prices as $price ) { |
|
| 1047 | + foreach ($prices as $price) { |
|
| 1048 | 1048 | // Find a match between price_id and level_id. |
| 1049 | 1049 | // First verify array keys exists THEN make the match. |
| 1050 | - if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) ) |
|
| 1050 | + if ((isset($args['price_id']) && isset($price['_give_id']['level_id'])) |
|
| 1051 | 1051 | && $args['price_id'] == $price['_give_id']['level_id'] |
| 1052 | 1052 | ) { |
| 1053 | 1053 | $item_price = $price['_give_amount']; |
| 1054 | 1054 | } |
| 1055 | 1055 | } |
| 1056 | 1056 | // Fallback to the lowest price point. |
| 1057 | - if ( $item_price == '' ) { |
|
| 1058 | - $item_price = give_get_lowest_price_option( $donation->ID ); |
|
| 1059 | - $args['price_id'] = give_get_lowest_price_id( $donation->ID ); |
|
| 1057 | + if ($item_price == '') { |
|
| 1058 | + $item_price = give_get_lowest_price_option($donation->ID); |
|
| 1059 | + $args['price_id'] = give_get_lowest_price_id($donation->ID); |
|
| 1060 | 1060 | } |
| 1061 | 1061 | } else { |
| 1062 | 1062 | // Simple form price. |
| 1063 | - $item_price = give_get_form_price( $donation->ID ); |
|
| 1063 | + $item_price = give_get_form_price($donation->ID); |
|
| 1064 | 1064 | } |
| 1065 | 1065 | } |
| 1066 | 1066 | |
| 1067 | 1067 | // Sanitizing the price here so we don't have a dozen calls later. |
| 1068 | - $item_price = give_sanitize_amount( $item_price ); |
|
| 1069 | - $total = round( $item_price, give_currency_decimal_filter() ); |
|
| 1068 | + $item_price = give_sanitize_amount($item_price); |
|
| 1069 | + $total = round($item_price, give_currency_decimal_filter()); |
|
| 1070 | 1070 | |
| 1071 | 1071 | // Add Options. |
| 1072 | 1072 | $default_options = array(); |
| 1073 | - if ( false !== $args['price_id'] ) { |
|
| 1073 | + if (false !== $args['price_id']) { |
|
| 1074 | 1074 | $default_options['price_id'] = (int) $args['price_id']; |
| 1075 | 1075 | } |
| 1076 | - $options = wp_parse_args( $options, $default_options ); |
|
| 1076 | + $options = wp_parse_args($options, $default_options); |
|
| 1077 | 1077 | |
| 1078 | 1078 | // Do not allow totals to go negative. |
| 1079 | - if ( $total < 0 ) { |
|
| 1079 | + if ($total < 0) { |
|
| 1080 | 1080 | $total = 0; |
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | 1083 | $donation = array( |
| 1084 | 1084 | 'name' => $donation->post_title, |
| 1085 | 1085 | 'id' => $donation->ID, |
| 1086 | - 'price' => round( $total, give_currency_decimal_filter() ), |
|
| 1087 | - 'subtotal' => round( $total, give_currency_decimal_filter() ), |
|
| 1086 | + 'price' => round($total, give_currency_decimal_filter()), |
|
| 1087 | + 'subtotal' => round($total, give_currency_decimal_filter()), |
|
| 1088 | 1088 | 'fees' => $args['fees'], |
| 1089 | 1089 | 'price_id' => $args['price_id'], |
| 1090 | 1090 | 'action' => 'add', |
@@ -1093,7 +1093,7 @@ discard block |
||
| 1093 | 1093 | |
| 1094 | 1094 | $this->pending['donations'][] = $donation; |
| 1095 | 1095 | |
| 1096 | - $this->increase_subtotal( $total ); |
|
| 1096 | + $this->increase_subtotal($total); |
|
| 1097 | 1097 | |
| 1098 | 1098 | return true; |
| 1099 | 1099 | |
@@ -1110,7 +1110,7 @@ discard block |
||
| 1110 | 1110 | * |
| 1111 | 1111 | * @return bool If the item was removed or not |
| 1112 | 1112 | */ |
| 1113 | - public function remove_donation( $form_id, $args = array() ) { |
|
| 1113 | + public function remove_donation($form_id, $args = array()) { |
|
| 1114 | 1114 | |
| 1115 | 1115 | // Set some defaults. |
| 1116 | 1116 | $defaults = array( |
@@ -1118,12 +1118,12 @@ discard block |
||
| 1118 | 1118 | 'price' => false, |
| 1119 | 1119 | 'price_id' => false, |
| 1120 | 1120 | ); |
| 1121 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1121 | + $args = wp_parse_args($args, $defaults); |
|
| 1122 | 1122 | |
| 1123 | - $form = new Give_Donate_Form( $form_id ); |
|
| 1123 | + $form = new Give_Donate_Form($form_id); |
|
| 1124 | 1124 | |
| 1125 | 1125 | // Bail if this post isn't a valid give donation form. |
| 1126 | - if ( ! $form || $form->post_type !== 'give_forms' ) { |
|
| 1126 | + if ( ! $form || $form->post_type !== 'give_forms') { |
|
| 1127 | 1127 | return false; |
| 1128 | 1128 | } |
| 1129 | 1129 | |
@@ -1136,7 +1136,7 @@ discard block |
||
| 1136 | 1136 | |
| 1137 | 1137 | $this->pending['donations'][] = $pending_args; |
| 1138 | 1138 | |
| 1139 | - $this->decrease_subtotal( $this->total ); |
|
| 1139 | + $this->decrease_subtotal($this->total); |
|
| 1140 | 1140 | |
| 1141 | 1141 | return true; |
| 1142 | 1142 | } |
@@ -1152,7 +1152,7 @@ discard block |
||
| 1152 | 1152 | * |
| 1153 | 1153 | * @return bool If the fee was added |
| 1154 | 1154 | */ |
| 1155 | - public function add_fee( $args, $global = true ) { |
|
| 1155 | + public function add_fee($args, $global = true) { |
|
| 1156 | 1156 | |
| 1157 | 1157 | $default_args = array( |
| 1158 | 1158 | 'label' => '', |
@@ -1162,15 +1162,15 @@ discard block |
||
| 1162 | 1162 | 'price_id' => 0, |
| 1163 | 1163 | ); |
| 1164 | 1164 | |
| 1165 | - $fee = wp_parse_args( $args, $default_args ); |
|
| 1165 | + $fee = wp_parse_args($args, $default_args); |
|
| 1166 | 1166 | $this->fees[] = $fee; |
| 1167 | 1167 | |
| 1168 | 1168 | $added_fee = $fee; |
| 1169 | 1169 | $added_fee['action'] = 'add'; |
| 1170 | 1170 | $this->pending['fees'][] = $added_fee; |
| 1171 | - reset( $this->fees ); |
|
| 1171 | + reset($this->fees); |
|
| 1172 | 1172 | |
| 1173 | - $this->increase_fees( $fee['amount'] ); |
|
| 1173 | + $this->increase_fees($fee['amount']); |
|
| 1174 | 1174 | |
| 1175 | 1175 | return true; |
| 1176 | 1176 | } |
@@ -1185,11 +1185,11 @@ discard block |
||
| 1185 | 1185 | * |
| 1186 | 1186 | * @return bool If the fee was removed successfully |
| 1187 | 1187 | */ |
| 1188 | - public function remove_fee( $key ) { |
|
| 1188 | + public function remove_fee($key) { |
|
| 1189 | 1189 | $removed = false; |
| 1190 | 1190 | |
| 1191 | - if ( is_numeric( $key ) ) { |
|
| 1192 | - $removed = $this->remove_fee_by( 'index', $key ); |
|
| 1191 | + if (is_numeric($key)) { |
|
| 1192 | + $removed = $this->remove_fee_by('index', $key); |
|
| 1193 | 1193 | } |
| 1194 | 1194 | |
| 1195 | 1195 | return $removed; |
@@ -1208,55 +1208,55 @@ discard block |
||
| 1208 | 1208 | * |
| 1209 | 1209 | * @return boolean If the item is removed |
| 1210 | 1210 | */ |
| 1211 | - public function remove_fee_by( $key, $value, $global = false ) { |
|
| 1211 | + public function remove_fee_by($key, $value, $global = false) { |
|
| 1212 | 1212 | |
| 1213 | - $allowed_fee_keys = apply_filters( 'give_payment_fee_keys', array( |
|
| 1213 | + $allowed_fee_keys = apply_filters('give_payment_fee_keys', array( |
|
| 1214 | 1214 | 'index', |
| 1215 | 1215 | 'label', |
| 1216 | 1216 | 'amount', |
| 1217 | 1217 | 'type', |
| 1218 | - ) ); |
|
| 1218 | + )); |
|
| 1219 | 1219 | |
| 1220 | - if ( ! in_array( $key, $allowed_fee_keys ) ) { |
|
| 1220 | + if ( ! in_array($key, $allowed_fee_keys)) { |
|
| 1221 | 1221 | return false; |
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | 1224 | $removed = false; |
| 1225 | - if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) { |
|
| 1225 | + if ('index' === $key && array_key_exists($value, $this->fees)) { |
|
| 1226 | 1226 | |
| 1227 | - $removed_fee = $this->fees[ $value ]; |
|
| 1227 | + $removed_fee = $this->fees[$value]; |
|
| 1228 | 1228 | $removed_fee['action'] = 'remove'; |
| 1229 | 1229 | $this->pending['fees'][] = $removed_fee; |
| 1230 | 1230 | |
| 1231 | - $this->decrease_fees( $removed_fee['amount'] ); |
|
| 1231 | + $this->decrease_fees($removed_fee['amount']); |
|
| 1232 | 1232 | |
| 1233 | - unset( $this->fees[ $value ] ); |
|
| 1233 | + unset($this->fees[$value]); |
|
| 1234 | 1234 | $removed = true; |
| 1235 | 1235 | |
| 1236 | - } elseif ( 'index' !== $key ) { |
|
| 1236 | + } elseif ('index' !== $key) { |
|
| 1237 | 1237 | |
| 1238 | - foreach ( $this->fees as $index => $fee ) { |
|
| 1238 | + foreach ($this->fees as $index => $fee) { |
|
| 1239 | 1239 | |
| 1240 | - if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) { |
|
| 1240 | + if (isset($fee[$key]) && $fee[$key] == $value) { |
|
| 1241 | 1241 | |
| 1242 | 1242 | $removed_fee = $fee; |
| 1243 | 1243 | $removed_fee['action'] = 'remove'; |
| 1244 | 1244 | $this->pending['fees'][] = $removed_fee; |
| 1245 | 1245 | |
| 1246 | - $this->decrease_fees( $removed_fee['amount'] ); |
|
| 1246 | + $this->decrease_fees($removed_fee['amount']); |
|
| 1247 | 1247 | |
| 1248 | - unset( $this->fees[ $index ] ); |
|
| 1248 | + unset($this->fees[$index]); |
|
| 1249 | 1249 | $removed = true; |
| 1250 | 1250 | |
| 1251 | - if ( false === $global ) { |
|
| 1251 | + if (false === $global) { |
|
| 1252 | 1252 | break; |
| 1253 | 1253 | } |
| 1254 | 1254 | } |
| 1255 | 1255 | } |
| 1256 | 1256 | } |
| 1257 | 1257 | |
| 1258 | - if ( true === $removed ) { |
|
| 1259 | - $this->fees = array_values( $this->fees ); |
|
| 1258 | + if (true === $removed) { |
|
| 1259 | + $this->fees = array_values($this->fees); |
|
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | 1262 | return $removed; |
@@ -1272,14 +1272,14 @@ discard block |
||
| 1272 | 1272 | * |
| 1273 | 1273 | * @return array The Fees for the type specified |
| 1274 | 1274 | */ |
| 1275 | - public function get_fees( $type = 'all' ) { |
|
| 1275 | + public function get_fees($type = 'all') { |
|
| 1276 | 1276 | $fees = array(); |
| 1277 | 1277 | |
| 1278 | - if ( ! empty( $this->fees ) && is_array( $this->fees ) ) { |
|
| 1278 | + if ( ! empty($this->fees) && is_array($this->fees)) { |
|
| 1279 | 1279 | |
| 1280 | - foreach ( $this->fees as $fee_id => $fee ) { |
|
| 1280 | + foreach ($this->fees as $fee_id => $fee) { |
|
| 1281 | 1281 | |
| 1282 | - if ( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) { |
|
| 1282 | + if ('all' != $type && ! empty($fee['type']) && $type != $fee['type']) { |
|
| 1283 | 1283 | continue; |
| 1284 | 1284 | } |
| 1285 | 1285 | |
@@ -1289,7 +1289,7 @@ discard block |
||
| 1289 | 1289 | } |
| 1290 | 1290 | } |
| 1291 | 1291 | |
| 1292 | - return apply_filters( 'give_get_payment_fees', $fees, $this->ID, $this ); |
|
| 1292 | + return apply_filters('give_get_payment_fees', $fees, $this->ID, $this); |
|
| 1293 | 1293 | } |
| 1294 | 1294 | |
| 1295 | 1295 | /** |
@@ -1302,13 +1302,13 @@ discard block |
||
| 1302 | 1302 | * |
| 1303 | 1303 | * @return void |
| 1304 | 1304 | */ |
| 1305 | - public function add_note( $note = false ) { |
|
| 1305 | + public function add_note($note = false) { |
|
| 1306 | 1306 | // Bail if no note specified. |
| 1307 | - if ( ! $note ) { |
|
| 1307 | + if ( ! $note) { |
|
| 1308 | 1308 | return false; |
| 1309 | 1309 | } |
| 1310 | 1310 | |
| 1311 | - give_insert_payment_note( $this->ID, $note ); |
|
| 1311 | + give_insert_payment_note($this->ID, $note); |
|
| 1312 | 1312 | } |
| 1313 | 1313 | |
| 1314 | 1314 | /** |
@@ -1321,7 +1321,7 @@ discard block |
||
| 1321 | 1321 | * |
| 1322 | 1322 | * @return void |
| 1323 | 1323 | */ |
| 1324 | - private function increase_subtotal( $amount = 0.00 ) { |
|
| 1324 | + private function increase_subtotal($amount = 0.00) { |
|
| 1325 | 1325 | $amount = (float) $amount; |
| 1326 | 1326 | $this->subtotal += $amount; |
| 1327 | 1327 | |
@@ -1338,11 +1338,11 @@ discard block |
||
| 1338 | 1338 | * |
| 1339 | 1339 | * @return void |
| 1340 | 1340 | */ |
| 1341 | - private function decrease_subtotal( $amount = 0.00 ) { |
|
| 1341 | + private function decrease_subtotal($amount = 0.00) { |
|
| 1342 | 1342 | $amount = (float) $amount; |
| 1343 | 1343 | $this->subtotal -= $amount; |
| 1344 | 1344 | |
| 1345 | - if ( $this->subtotal < 0 ) { |
|
| 1345 | + if ($this->subtotal < 0) { |
|
| 1346 | 1346 | $this->subtotal = 0; |
| 1347 | 1347 | } |
| 1348 | 1348 | |
@@ -1359,7 +1359,7 @@ discard block |
||
| 1359 | 1359 | * |
| 1360 | 1360 | * @return void |
| 1361 | 1361 | */ |
| 1362 | - private function increase_fees( $amount = 0.00 ) { |
|
| 1362 | + private function increase_fees($amount = 0.00) { |
|
| 1363 | 1363 | $amount = (float) $amount; |
| 1364 | 1364 | $this->fees_total += $amount; |
| 1365 | 1365 | |
@@ -1376,11 +1376,11 @@ discard block |
||
| 1376 | 1376 | * |
| 1377 | 1377 | * @return void |
| 1378 | 1378 | */ |
| 1379 | - private function decrease_fees( $amount = 0.00 ) { |
|
| 1379 | + private function decrease_fees($amount = 0.00) { |
|
| 1380 | 1380 | $amount = (float) $amount; |
| 1381 | 1381 | $this->fees_total -= $amount; |
| 1382 | 1382 | |
| 1383 | - if ( $this->fees_total < 0 ) { |
|
| 1383 | + if ($this->fees_total < 0) { |
|
| 1384 | 1384 | $this->fees_total = 0; |
| 1385 | 1385 | } |
| 1386 | 1386 | |
@@ -1409,24 +1409,24 @@ discard block |
||
| 1409 | 1409 | * |
| 1410 | 1410 | * @return bool $updated Returns if the status was successfully updated. |
| 1411 | 1411 | */ |
| 1412 | - public function update_status( $status = false ) { |
|
| 1412 | + public function update_status($status = false) { |
|
| 1413 | 1413 | |
| 1414 | 1414 | // standardize the 'complete(d)' status. |
| 1415 | - if ( $status == 'completed' || $status == 'complete' ) { |
|
| 1415 | + if ($status == 'completed' || $status == 'complete') { |
|
| 1416 | 1416 | $status = 'publish'; |
| 1417 | 1417 | } |
| 1418 | 1418 | |
| 1419 | - $old_status = ! empty( $this->old_status ) ? $this->old_status : false; |
|
| 1419 | + $old_status = ! empty($this->old_status) ? $this->old_status : false; |
|
| 1420 | 1420 | |
| 1421 | - if ( $old_status === $status ) { |
|
| 1421 | + if ($old_status === $status) { |
|
| 1422 | 1422 | return false; // Don't permit status changes that aren't changes. |
| 1423 | 1423 | } |
| 1424 | 1424 | |
| 1425 | - $do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status ); |
|
| 1425 | + $do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status); |
|
| 1426 | 1426 | |
| 1427 | 1427 | $updated = false; |
| 1428 | 1428 | |
| 1429 | - if ( $do_change ) { |
|
| 1429 | + if ($do_change) { |
|
| 1430 | 1430 | |
| 1431 | 1431 | /** |
| 1432 | 1432 | * Fires before changing payment status. |
@@ -1437,21 +1437,21 @@ discard block |
||
| 1437 | 1437 | * @param string $status The new status. |
| 1438 | 1438 | * @param string $old_status The old status. |
| 1439 | 1439 | */ |
| 1440 | - do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status ); |
|
| 1440 | + do_action('give_before_payment_status_change', $this->ID, $status, $old_status); |
|
| 1441 | 1441 | |
| 1442 | 1442 | $update_fields = array( |
| 1443 | 1443 | 'ID' => $this->ID, |
| 1444 | 1444 | 'post_status' => $status, |
| 1445 | - 'edit_date' => current_time( 'mysql' ), |
|
| 1445 | + 'edit_date' => current_time('mysql'), |
|
| 1446 | 1446 | ); |
| 1447 | 1447 | |
| 1448 | - $updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) ); |
|
| 1448 | + $updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields)); |
|
| 1449 | 1449 | |
| 1450 | 1450 | $all_payment_statuses = give_get_payment_statuses(); |
| 1451 | - $this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status ); |
|
| 1451 | + $this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status); |
|
| 1452 | 1452 | |
| 1453 | 1453 | // Process any specific status functions. |
| 1454 | - switch ( $status ) { |
|
| 1454 | + switch ($status) { |
|
| 1455 | 1455 | case 'refunded': |
| 1456 | 1456 | $this->process_refund(); |
| 1457 | 1457 | break; |
@@ -1478,7 +1478,7 @@ discard block |
||
| 1478 | 1478 | * @param string $status The new status. |
| 1479 | 1479 | * @param string $old_status The old status. |
| 1480 | 1480 | */ |
| 1481 | - do_action( 'give_update_payment_status', $this->ID, $status, $old_status ); |
|
| 1481 | + do_action('give_update_payment_status', $this->ID, $status, $old_status); |
|
| 1482 | 1482 | |
| 1483 | 1483 | } |
| 1484 | 1484 | |
@@ -1513,32 +1513,32 @@ discard block |
||
| 1513 | 1513 | * |
| 1514 | 1514 | * @return mixed The value from the post meta |
| 1515 | 1515 | */ |
| 1516 | - public function get_meta( $meta_key = '_give_payment_meta', $single = true ) { |
|
| 1516 | + public function get_meta($meta_key = '_give_payment_meta', $single = true) { |
|
| 1517 | 1517 | |
| 1518 | - $meta = get_post_meta( $this->ID, $meta_key, $single ); |
|
| 1518 | + $meta = get_post_meta($this->ID, $meta_key, $single); |
|
| 1519 | 1519 | |
| 1520 | - if ( $meta_key === '_give_payment_meta' ) { |
|
| 1520 | + if ($meta_key === '_give_payment_meta') { |
|
| 1521 | 1521 | |
| 1522 | - if ( empty( $meta['key'] ) ) { |
|
| 1522 | + if (empty($meta['key'])) { |
|
| 1523 | 1523 | $meta['key'] = $this->setup_payment_key(); |
| 1524 | 1524 | } |
| 1525 | 1525 | |
| 1526 | - if ( empty( $meta['form_title'] ) ) { |
|
| 1526 | + if (empty($meta['form_title'])) { |
|
| 1527 | 1527 | $meta['form_title'] = $this->setup_form_title(); |
| 1528 | 1528 | } |
| 1529 | 1529 | |
| 1530 | - if ( empty( $meta['email'] ) ) { |
|
| 1530 | + if (empty($meta['email'])) { |
|
| 1531 | 1531 | $meta['email'] = $this->setup_email(); |
| 1532 | 1532 | } |
| 1533 | 1533 | |
| 1534 | - if ( empty( $meta['date'] ) ) { |
|
| 1535 | - $meta['date'] = get_post_field( 'post_date', $this->ID ); |
|
| 1534 | + if (empty($meta['date'])) { |
|
| 1535 | + $meta['date'] = get_post_field('post_date', $this->ID); |
|
| 1536 | 1536 | } |
| 1537 | 1537 | } |
| 1538 | 1538 | |
| 1539 | - $meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID ); |
|
| 1539 | + $meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID); |
|
| 1540 | 1540 | |
| 1541 | - return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key ); |
|
| 1541 | + return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key); |
|
| 1542 | 1542 | } |
| 1543 | 1543 | |
| 1544 | 1544 | /** |
@@ -1553,23 +1553,23 @@ discard block |
||
| 1553 | 1553 | * |
| 1554 | 1554 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure |
| 1555 | 1555 | */ |
| 1556 | - public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
| 1557 | - if ( empty( $meta_key ) ) { |
|
| 1556 | + public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') { |
|
| 1557 | + if (empty($meta_key)) { |
|
| 1558 | 1558 | return false; |
| 1559 | 1559 | } |
| 1560 | 1560 | |
| 1561 | - if ( $meta_key == 'key' || $meta_key == 'date' ) { |
|
| 1561 | + if ($meta_key == 'key' || $meta_key == 'date') { |
|
| 1562 | 1562 | |
| 1563 | 1563 | $current_meta = $this->get_meta(); |
| 1564 | - $current_meta[ $meta_key ] = $meta_value; |
|
| 1564 | + $current_meta[$meta_key] = $meta_value; |
|
| 1565 | 1565 | |
| 1566 | 1566 | $meta_key = '_give_payment_meta'; |
| 1567 | 1567 | $meta_value = $current_meta; |
| 1568 | 1568 | |
| 1569 | - } elseif ( $meta_key == 'email' || $meta_key == '_give_payment_user_email' ) { |
|
| 1569 | + } elseif ($meta_key == 'email' || $meta_key == '_give_payment_user_email') { |
|
| 1570 | 1570 | |
| 1571 | - $meta_value = apply_filters( "give_give_update_payment_meta_{$meta_key}", $meta_value, $this->ID ); |
|
| 1572 | - update_post_meta( $this->ID, '_give_payment_user_email', $meta_value ); |
|
| 1571 | + $meta_value = apply_filters("give_give_update_payment_meta_{$meta_key}", $meta_value, $this->ID); |
|
| 1572 | + update_post_meta($this->ID, '_give_payment_user_email', $meta_value); |
|
| 1573 | 1573 | |
| 1574 | 1574 | $current_meta = $this->get_meta(); |
| 1575 | 1575 | $current_meta['user_info']['email'] = $meta_value; |
@@ -1579,9 +1579,9 @@ discard block |
||
| 1579 | 1579 | |
| 1580 | 1580 | } |
| 1581 | 1581 | |
| 1582 | - $meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID ); |
|
| 1582 | + $meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID); |
|
| 1583 | 1583 | |
| 1584 | - return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value ); |
|
| 1584 | + return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value); |
|
| 1585 | 1585 | } |
| 1586 | 1586 | |
| 1587 | 1587 | /** |
@@ -1596,14 +1596,14 @@ discard block |
||
| 1596 | 1596 | $process_refund = true; |
| 1597 | 1597 | |
| 1598 | 1598 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented. |
| 1599 | - if ( 'publish' != $this->old_status || 'refunded' != $this->status ) { |
|
| 1599 | + if ('publish' != $this->old_status || 'refunded' != $this->status) { |
|
| 1600 | 1600 | $process_refund = false; |
| 1601 | 1601 | } |
| 1602 | 1602 | |
| 1603 | 1603 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
| 1604 | - $process_refund = apply_filters( 'give_should_process_refund', $process_refund, $this ); |
|
| 1604 | + $process_refund = apply_filters('give_should_process_refund', $process_refund, $this); |
|
| 1605 | 1605 | |
| 1606 | - if ( false === $process_refund ) { |
|
| 1606 | + if (false === $process_refund) { |
|
| 1607 | 1607 | return; |
| 1608 | 1608 | } |
| 1609 | 1609 | |
@@ -1614,17 +1614,17 @@ discard block |
||
| 1614 | 1614 | * |
| 1615 | 1615 | * @param Give_Payment $this Payment object. |
| 1616 | 1616 | */ |
| 1617 | - do_action( 'give_pre_refund_payment', $this ); |
|
| 1617 | + do_action('give_pre_refund_payment', $this); |
|
| 1618 | 1618 | |
| 1619 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_refund', true, $this ); |
|
| 1620 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_refund', true, $this ); |
|
| 1621 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_refund', true, $this ); |
|
| 1619 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_refund', true, $this); |
|
| 1620 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_refund', true, $this); |
|
| 1621 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_refund', true, $this); |
|
| 1622 | 1622 | |
| 1623 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
| 1623 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
| 1624 | 1624 | $this->delete_sales_logs(); |
| 1625 | 1625 | |
| 1626 | 1626 | // Clear the This Month earnings (this_monththis_month is NOT a typo). |
| 1627 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
| 1627 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
| 1628 | 1628 | |
| 1629 | 1629 | /** |
| 1630 | 1630 | * Fires after refunding payment. |
@@ -1633,7 +1633,7 @@ discard block |
||
| 1633 | 1633 | * |
| 1634 | 1634 | * @param Give_Payment $this Payment object. |
| 1635 | 1635 | */ |
| 1636 | - do_action( 'give_post_refund_payment', $this ); |
|
| 1636 | + do_action('give_post_refund_payment', $this); |
|
| 1637 | 1637 | } |
| 1638 | 1638 | |
| 1639 | 1639 | /** |
@@ -1660,29 +1660,29 @@ discard block |
||
| 1660 | 1660 | $process_pending = true; |
| 1661 | 1661 | |
| 1662 | 1662 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented. |
| 1663 | - if ( 'publish' != $this->old_status || 'pending' != $this->status ) { |
|
| 1663 | + if ('publish' != $this->old_status || 'pending' != $this->status) { |
|
| 1664 | 1664 | $process_pending = false; |
| 1665 | 1665 | } |
| 1666 | 1666 | |
| 1667 | 1667 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
| 1668 | - $process_pending = apply_filters( 'give_should_process_pending', $process_pending, $this ); |
|
| 1668 | + $process_pending = apply_filters('give_should_process_pending', $process_pending, $this); |
|
| 1669 | 1669 | |
| 1670 | - if ( false === $process_pending ) { |
|
| 1670 | + if (false === $process_pending) { |
|
| 1671 | 1671 | return; |
| 1672 | 1672 | } |
| 1673 | 1673 | |
| 1674 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_pending', true, $this ); |
|
| 1675 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_pending', true, $this ); |
|
| 1676 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_pending', true, $this ); |
|
| 1674 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_pending', true, $this); |
|
| 1675 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_pending', true, $this); |
|
| 1676 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_pending', true, $this); |
|
| 1677 | 1677 | |
| 1678 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
| 1678 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
| 1679 | 1679 | $this->delete_sales_logs(); |
| 1680 | 1680 | |
| 1681 | 1681 | $this->completed_date = false; |
| 1682 | - $this->update_meta( '_give_completed_date', '' ); |
|
| 1682 | + $this->update_meta('_give_completed_date', ''); |
|
| 1683 | 1683 | |
| 1684 | 1684 | // Clear the This Month earnings (this_monththis_month is NOT a typo). |
| 1685 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
| 1685 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
| 1686 | 1686 | } |
| 1687 | 1687 | |
| 1688 | 1688 | /** |
@@ -1697,29 +1697,29 @@ discard block |
||
| 1697 | 1697 | $process_cancelled = true; |
| 1698 | 1698 | |
| 1699 | 1699 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented. |
| 1700 | - if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) { |
|
| 1700 | + if ('publish' != $this->old_status || 'cancelled' != $this->status) { |
|
| 1701 | 1701 | $process_cancelled = false; |
| 1702 | 1702 | } |
| 1703 | 1703 | |
| 1704 | 1704 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
| 1705 | - $process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this ); |
|
| 1705 | + $process_cancelled = apply_filters('give_should_process_cancelled', $process_cancelled, $this); |
|
| 1706 | 1706 | |
| 1707 | - if ( false === $process_cancelled ) { |
|
| 1707 | + if (false === $process_cancelled) { |
|
| 1708 | 1708 | return; |
| 1709 | 1709 | } |
| 1710 | 1710 | |
| 1711 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_cancelled', true, $this ); |
|
| 1712 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_cancelled', true, $this ); |
|
| 1713 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_cancelled', true, $this ); |
|
| 1711 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_cancelled', true, $this); |
|
| 1712 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_cancelled', true, $this); |
|
| 1713 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_cancelled', true, $this); |
|
| 1714 | 1714 | |
| 1715 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
| 1715 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
| 1716 | 1716 | $this->delete_sales_logs(); |
| 1717 | 1717 | |
| 1718 | 1718 | $this->completed_date = false; |
| 1719 | - $this->update_meta( '_give_completed_date', '' ); |
|
| 1719 | + $this->update_meta('_give_completed_date', ''); |
|
| 1720 | 1720 | |
| 1721 | 1721 | // Clear the This Month earnings (this_monththis_month is NOT a typo). |
| 1722 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
| 1722 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
| 1723 | 1723 | } |
| 1724 | 1724 | |
| 1725 | 1725 | /** |
@@ -1732,29 +1732,29 @@ discard block |
||
| 1732 | 1732 | $process_revoked = true; |
| 1733 | 1733 | |
| 1734 | 1734 | // If the payment was not in publish, don't decrement stats as they were never incremented. |
| 1735 | - if ( 'publish' != $this->old_status || 'revoked' != $this->status ) { |
|
| 1735 | + if ('publish' != $this->old_status || 'revoked' != $this->status) { |
|
| 1736 | 1736 | $process_revoked = false; |
| 1737 | 1737 | } |
| 1738 | 1738 | |
| 1739 | 1739 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
| 1740 | - $process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this ); |
|
| 1740 | + $process_revoked = apply_filters('give_should_process_revoked', $process_revoked, $this); |
|
| 1741 | 1741 | |
| 1742 | - if ( false === $process_revoked ) { |
|
| 1742 | + if (false === $process_revoked) { |
|
| 1743 | 1743 | return; |
| 1744 | 1744 | } |
| 1745 | 1745 | |
| 1746 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_revoked', true, $this ); |
|
| 1747 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_revoked', true, $this ); |
|
| 1748 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_revoked', true, $this ); |
|
| 1746 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_revoked', true, $this); |
|
| 1747 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_revoked', true, $this); |
|
| 1748 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_revoked', true, $this); |
|
| 1749 | 1749 | |
| 1750 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
| 1750 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
| 1751 | 1751 | $this->delete_sales_logs(); |
| 1752 | 1752 | |
| 1753 | 1753 | $this->completed_date = false; |
| 1754 | - $this->update_meta( '_give_completed_date', '' ); |
|
| 1754 | + $this->update_meta('_give_completed_date', ''); |
|
| 1755 | 1755 | |
| 1756 | 1756 | // Clear the This Month earnings (this_monththis_month is NOT a typo). |
| 1757 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
| 1757 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
| 1758 | 1758 | } |
| 1759 | 1759 | |
| 1760 | 1760 | /** |
@@ -1769,25 +1769,25 @@ discard block |
||
| 1769 | 1769 | * |
| 1770 | 1770 | * @return void |
| 1771 | 1771 | */ |
| 1772 | - private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) { |
|
| 1772 | + private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) { |
|
| 1773 | 1773 | |
| 1774 | - give_undo_purchase( false, $this->ID ); |
|
| 1774 | + give_undo_purchase(false, $this->ID); |
|
| 1775 | 1775 | |
| 1776 | 1776 | // Decrease store earnings. |
| 1777 | - if ( true === $alter_store_earnings ) { |
|
| 1778 | - give_decrease_total_earnings( $this->total ); |
|
| 1777 | + if (true === $alter_store_earnings) { |
|
| 1778 | + give_decrease_total_earnings($this->total); |
|
| 1779 | 1779 | } |
| 1780 | 1780 | |
| 1781 | 1781 | // Decrement the stats for the customer. |
| 1782 | - if ( ! empty( $this->customer_id ) ) { |
|
| 1782 | + if ( ! empty($this->customer_id)) { |
|
| 1783 | 1783 | |
| 1784 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 1784 | + $customer = new Give_Customer($this->customer_id); |
|
| 1785 | 1785 | |
| 1786 | - if ( true === $alter_customer_value ) { |
|
| 1787 | - $customer->decrease_value( $this->total ); |
|
| 1786 | + if (true === $alter_customer_value) { |
|
| 1787 | + $customer->decrease_value($this->total); |
|
| 1788 | 1788 | } |
| 1789 | 1789 | |
| 1790 | - if ( true === $alter_customer_purchase_count ) { |
|
| 1790 | + if (true === $alter_customer_purchase_count) { |
|
| 1791 | 1791 | $customer->decrease_purchase_count(); |
| 1792 | 1792 | } |
| 1793 | 1793 | } |
@@ -1836,13 +1836,13 @@ discard block |
||
| 1836 | 1836 | * @return string The date the payment was completed |
| 1837 | 1837 | */ |
| 1838 | 1838 | private function setup_completed_date() { |
| 1839 | - $payment = get_post( $this->ID ); |
|
| 1839 | + $payment = get_post($this->ID); |
|
| 1840 | 1840 | |
| 1841 | - if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) { |
|
| 1841 | + if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) { |
|
| 1842 | 1842 | return false; // This payment was never completed. |
| 1843 | 1843 | } |
| 1844 | 1844 | |
| 1845 | - $date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date; |
|
| 1845 | + $date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date; |
|
| 1846 | 1846 | |
| 1847 | 1847 | return $date; |
| 1848 | 1848 | } |
@@ -1856,7 +1856,7 @@ discard block |
||
| 1856 | 1856 | * @return string The payment mode |
| 1857 | 1857 | */ |
| 1858 | 1858 | private function setup_mode() { |
| 1859 | - return $this->get_meta( '_give_payment_mode' ); |
|
| 1859 | + return $this->get_meta('_give_payment_mode'); |
|
| 1860 | 1860 | } |
| 1861 | 1861 | |
| 1862 | 1862 | /** |
@@ -1868,13 +1868,13 @@ discard block |
||
| 1868 | 1868 | * @return float The payment total |
| 1869 | 1869 | */ |
| 1870 | 1870 | private function setup_total() { |
| 1871 | - $amount = $this->get_meta( '_give_payment_total', true ); |
|
| 1871 | + $amount = $this->get_meta('_give_payment_total', true); |
|
| 1872 | 1872 | |
| 1873 | - if ( empty( $amount ) && '0.00' != $amount ) { |
|
| 1874 | - $meta = $this->get_meta( '_give_payment_meta', true ); |
|
| 1875 | - $meta = maybe_unserialize( $meta ); |
|
| 1873 | + if (empty($amount) && '0.00' != $amount) { |
|
| 1874 | + $meta = $this->get_meta('_give_payment_meta', true); |
|
| 1875 | + $meta = maybe_unserialize($meta); |
|
| 1876 | 1876 | |
| 1877 | - if ( isset( $meta['amount'] ) ) { |
|
| 1877 | + if (isset($meta['amount'])) { |
|
| 1878 | 1878 | $amount = $meta['amount']; |
| 1879 | 1879 | } |
| 1880 | 1880 | } |
@@ -1907,9 +1907,9 @@ discard block |
||
| 1907 | 1907 | private function setup_fees_total() { |
| 1908 | 1908 | $fees_total = (float) 0.00; |
| 1909 | 1909 | |
| 1910 | - $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array(); |
|
| 1911 | - if ( ! empty( $payment_fees ) ) { |
|
| 1912 | - foreach ( $payment_fees as $fee ) { |
|
| 1910 | + $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array(); |
|
| 1911 | + if ( ! empty($payment_fees)) { |
|
| 1912 | + foreach ($payment_fees as $fee) { |
|
| 1913 | 1913 | $fees_total += (float) $fee['amount']; |
| 1914 | 1914 | } |
| 1915 | 1915 | } |
@@ -1927,7 +1927,7 @@ discard block |
||
| 1927 | 1927 | * @return string The currency for the payment |
| 1928 | 1928 | */ |
| 1929 | 1929 | private function setup_currency() { |
| 1930 | - $currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'give_payment_currency_default', give_get_currency(), $this ); |
|
| 1930 | + $currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('give_payment_currency_default', give_get_currency(), $this); |
|
| 1931 | 1931 | |
| 1932 | 1932 | return $currency; |
| 1933 | 1933 | } |
@@ -1941,7 +1941,7 @@ discard block |
||
| 1941 | 1941 | * @return array The Fees |
| 1942 | 1942 | */ |
| 1943 | 1943 | private function setup_fees() { |
| 1944 | - $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array(); |
|
| 1944 | + $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array(); |
|
| 1945 | 1945 | |
| 1946 | 1946 | return $payment_fees; |
| 1947 | 1947 | } |
@@ -1955,7 +1955,7 @@ discard block |
||
| 1955 | 1955 | * @return string The gateway |
| 1956 | 1956 | */ |
| 1957 | 1957 | private function setup_gateway() { |
| 1958 | - $gateway = $this->get_meta( '_give_payment_gateway', true ); |
|
| 1958 | + $gateway = $this->get_meta('_give_payment_gateway', true); |
|
| 1959 | 1959 | |
| 1960 | 1960 | return $gateway; |
| 1961 | 1961 | } |
@@ -1969,12 +1969,12 @@ discard block |
||
| 1969 | 1969 | * @return string The donation ID |
| 1970 | 1970 | */ |
| 1971 | 1971 | private function setup_transaction_id() { |
| 1972 | - $transaction_id = $this->get_meta( '_give_payment_transaction_id', true ); |
|
| 1972 | + $transaction_id = $this->get_meta('_give_payment_transaction_id', true); |
|
| 1973 | 1973 | |
| 1974 | - if ( empty( $transaction_id ) || (int) $transaction_id === (int) $this->ID ) { |
|
| 1974 | + if (empty($transaction_id) || (int) $transaction_id === (int) $this->ID) { |
|
| 1975 | 1975 | |
| 1976 | 1976 | $gateway = $this->gateway; |
| 1977 | - $transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID ); |
|
| 1977 | + $transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID); |
|
| 1978 | 1978 | |
| 1979 | 1979 | } |
| 1980 | 1980 | |
@@ -1990,7 +1990,7 @@ discard block |
||
| 1990 | 1990 | * @return string The IP address for the payment |
| 1991 | 1991 | */ |
| 1992 | 1992 | private function setup_ip() { |
| 1993 | - $ip = $this->get_meta( '_give_payment_user_ip', true ); |
|
| 1993 | + $ip = $this->get_meta('_give_payment_user_ip', true); |
|
| 1994 | 1994 | |
| 1995 | 1995 | return $ip; |
| 1996 | 1996 | } |
@@ -2004,7 +2004,7 @@ discard block |
||
| 2004 | 2004 | * @return int The Customer ID |
| 2005 | 2005 | */ |
| 2006 | 2006 | private function setup_customer_id() { |
| 2007 | - $customer_id = $this->get_meta( '_give_payment_customer_id', true ); |
|
| 2007 | + $customer_id = $this->get_meta('_give_payment_customer_id', true); |
|
| 2008 | 2008 | |
| 2009 | 2009 | return $customer_id; |
| 2010 | 2010 | } |
@@ -2018,7 +2018,7 @@ discard block |
||
| 2018 | 2018 | * @return int The User ID |
| 2019 | 2019 | */ |
| 2020 | 2020 | private function setup_user_id() { |
| 2021 | - $user_id = $this->get_meta( '_give_payment_user_id', true ); |
|
| 2021 | + $user_id = $this->get_meta('_give_payment_user_id', true); |
|
| 2022 | 2022 | |
| 2023 | 2023 | return $user_id; |
| 2024 | 2024 | } |
@@ -2032,10 +2032,10 @@ discard block |
||
| 2032 | 2032 | * @return string The email address for the payment |
| 2033 | 2033 | */ |
| 2034 | 2034 | private function setup_email() { |
| 2035 | - $email = $this->get_meta( '_give_payment_user_email', true ); |
|
| 2035 | + $email = $this->get_meta('_give_payment_user_email', true); |
|
| 2036 | 2036 | |
| 2037 | - if ( empty( $email ) ) { |
|
| 2038 | - $email = Give()->customers->get_column( 'email', $this->customer_id ); |
|
| 2037 | + if (empty($email)) { |
|
| 2038 | + $email = Give()->customers->get_column('email', $this->customer_id); |
|
| 2039 | 2039 | } |
| 2040 | 2040 | |
| 2041 | 2041 | return $email; |
@@ -2055,15 +2055,15 @@ discard block |
||
| 2055 | 2055 | 'last_name' => $this->last_name, |
| 2056 | 2056 | ); |
| 2057 | 2057 | |
| 2058 | - $user_info = isset( $this->payment_meta['user_info'] ) ? maybe_unserialize( $this->payment_meta['user_info'] ) : array(); |
|
| 2059 | - $user_info = wp_parse_args( $user_info, $defaults ); |
|
| 2058 | + $user_info = isset($this->payment_meta['user_info']) ? maybe_unserialize($this->payment_meta['user_info']) : array(); |
|
| 2059 | + $user_info = wp_parse_args($user_info, $defaults); |
|
| 2060 | 2060 | |
| 2061 | - if ( empty( $user_info ) ) { |
|
| 2061 | + if (empty($user_info)) { |
|
| 2062 | 2062 | // Get the customer, but only if it's been created. |
| 2063 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 2063 | + $customer = new Give_Customer($this->customer_id); |
|
| 2064 | 2064 | |
| 2065 | - if ( $customer->id > 0 ) { |
|
| 2066 | - $name = explode( ' ', $customer->name, 2 ); |
|
| 2065 | + if ($customer->id > 0) { |
|
| 2066 | + $name = explode(' ', $customer->name, 2); |
|
| 2067 | 2067 | $user_info = array( |
| 2068 | 2068 | 'first_name' => $name[0], |
| 2069 | 2069 | 'last_name' => $name[1], |
@@ -2073,29 +2073,29 @@ discard block |
||
| 2073 | 2073 | } |
| 2074 | 2074 | } else { |
| 2075 | 2075 | // Get the customer, but only if it's been created. |
| 2076 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 2077 | - if ( $customer->id > 0 ) { |
|
| 2078 | - foreach ( $user_info as $key => $value ) { |
|
| 2079 | - if ( ! empty( $value ) ) { |
|
| 2076 | + $customer = new Give_Customer($this->customer_id); |
|
| 2077 | + if ($customer->id > 0) { |
|
| 2078 | + foreach ($user_info as $key => $value) { |
|
| 2079 | + if ( ! empty($value)) { |
|
| 2080 | 2080 | continue; |
| 2081 | 2081 | } |
| 2082 | 2082 | |
| 2083 | - switch ( $key ) { |
|
| 2083 | + switch ($key) { |
|
| 2084 | 2084 | case 'first_name': |
| 2085 | - $name = explode( ' ', $customer->name, 2 ); |
|
| 2085 | + $name = explode(' ', $customer->name, 2); |
|
| 2086 | 2086 | |
| 2087 | - $user_info[ $key ] = $name[0]; |
|
| 2087 | + $user_info[$key] = $name[0]; |
|
| 2088 | 2088 | break; |
| 2089 | 2089 | |
| 2090 | 2090 | case 'last_name': |
| 2091 | - $name = explode( ' ', $customer->name, 2 ); |
|
| 2092 | - $last_name = ! empty( $name[1] ) ? $name[1] : ''; |
|
| 2091 | + $name = explode(' ', $customer->name, 2); |
|
| 2092 | + $last_name = ! empty($name[1]) ? $name[1] : ''; |
|
| 2093 | 2093 | |
| 2094 | - $user_info[ $key ] = $last_name; |
|
| 2094 | + $user_info[$key] = $last_name; |
|
| 2095 | 2095 | break; |
| 2096 | 2096 | |
| 2097 | 2097 | case 'email': |
| 2098 | - $user_info[ $key ] = $customer->email; |
|
| 2098 | + $user_info[$key] = $customer->email; |
|
| 2099 | 2099 | break; |
| 2100 | 2100 | } |
| 2101 | 2101 | } |
@@ -2116,7 +2116,7 @@ discard block |
||
| 2116 | 2116 | */ |
| 2117 | 2117 | private function setup_address() { |
| 2118 | 2118 | |
| 2119 | - $address = ! empty( $this->payment_meta['user_info']['address'] ) ? $this->payment_meta['user_info']['address'] : array( |
|
| 2119 | + $address = ! empty($this->payment_meta['user_info']['address']) ? $this->payment_meta['user_info']['address'] : array( |
|
| 2120 | 2120 | 'line1' => '', |
| 2121 | 2121 | 'line2' => '', |
| 2122 | 2122 | 'city' => '', |
@@ -2138,7 +2138,7 @@ discard block |
||
| 2138 | 2138 | */ |
| 2139 | 2139 | private function setup_form_title() { |
| 2140 | 2140 | |
| 2141 | - $form_id = $this->get_meta( '_give_payment_form_title', true ); |
|
| 2141 | + $form_id = $this->get_meta('_give_payment_form_title', true); |
|
| 2142 | 2142 | |
| 2143 | 2143 | return $form_id; |
| 2144 | 2144 | } |
@@ -2153,7 +2153,7 @@ discard block |
||
| 2153 | 2153 | */ |
| 2154 | 2154 | private function setup_form_id() { |
| 2155 | 2155 | |
| 2156 | - $form_id = $this->get_meta( '_give_payment_form_id', true ); |
|
| 2156 | + $form_id = $this->get_meta('_give_payment_form_id', true); |
|
| 2157 | 2157 | |
| 2158 | 2158 | return $form_id; |
| 2159 | 2159 | } |
@@ -2167,7 +2167,7 @@ discard block |
||
| 2167 | 2167 | * @return int The Form Price ID |
| 2168 | 2168 | */ |
| 2169 | 2169 | private function setup_price_id() { |
| 2170 | - $price_id = $this->get_meta( '_give_payment_price_id', true ); |
|
| 2170 | + $price_id = $this->get_meta('_give_payment_price_id', true); |
|
| 2171 | 2171 | |
| 2172 | 2172 | return $price_id; |
| 2173 | 2173 | } |
@@ -2181,7 +2181,7 @@ discard block |
||
| 2181 | 2181 | * @return string The Payment Key |
| 2182 | 2182 | */ |
| 2183 | 2183 | private function setup_payment_key() { |
| 2184 | - $key = $this->get_meta( '_give_payment_purchase_key', true ); |
|
| 2184 | + $key = $this->get_meta('_give_payment_purchase_key', true); |
|
| 2185 | 2185 | |
| 2186 | 2186 | return $key; |
| 2187 | 2187 | } |
@@ -2197,11 +2197,11 @@ discard block |
||
| 2197 | 2197 | private function setup_payment_number() { |
| 2198 | 2198 | $number = $this->ID; |
| 2199 | 2199 | |
| 2200 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 2200 | + if (give_get_option('enable_sequential')) { |
|
| 2201 | 2201 | |
| 2202 | - $number = $this->get_meta( '_give_payment_number', true ); |
|
| 2202 | + $number = $this->get_meta('_give_payment_number', true); |
|
| 2203 | 2203 | |
| 2204 | - if ( ! $number ) { |
|
| 2204 | + if ( ! $number) { |
|
| 2205 | 2205 | |
| 2206 | 2206 | $number = $this->ID; |
| 2207 | 2207 | |
@@ -2219,7 +2219,7 @@ discard block |
||
| 2219 | 2219 | * @return array The payment object as an array |
| 2220 | 2220 | */ |
| 2221 | 2221 | public function array_convert() { |
| 2222 | - return get_object_vars( $this ); |
|
| 2222 | + return get_object_vars($this); |
|
| 2223 | 2223 | } |
| 2224 | 2224 | |
| 2225 | 2225 | /** |
@@ -2231,7 +2231,7 @@ discard block |
||
| 2231 | 2231 | * @return string Date payment was completed |
| 2232 | 2232 | */ |
| 2233 | 2233 | private function get_completed_date() { |
| 2234 | - return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this ); |
|
| 2234 | + return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this); |
|
| 2235 | 2235 | } |
| 2236 | 2236 | |
| 2237 | 2237 | /** |
@@ -2243,7 +2243,7 @@ discard block |
||
| 2243 | 2243 | * @return float Payment subtotal |
| 2244 | 2244 | */ |
| 2245 | 2245 | private function get_subtotal() { |
| 2246 | - return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this ); |
|
| 2246 | + return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this); |
|
| 2247 | 2247 | } |
| 2248 | 2248 | |
| 2249 | 2249 | /** |
@@ -2255,7 +2255,7 @@ discard block |
||
| 2255 | 2255 | * @return string Payment currency code |
| 2256 | 2256 | */ |
| 2257 | 2257 | private function get_currency() { |
| 2258 | - return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this ); |
|
| 2258 | + return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this); |
|
| 2259 | 2259 | } |
| 2260 | 2260 | |
| 2261 | 2261 | /** |
@@ -2267,7 +2267,7 @@ discard block |
||
| 2267 | 2267 | * @return string Gateway used |
| 2268 | 2268 | */ |
| 2269 | 2269 | private function get_gateway() { |
| 2270 | - return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this ); |
|
| 2270 | + return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this); |
|
| 2271 | 2271 | } |
| 2272 | 2272 | |
| 2273 | 2273 | /** |
@@ -2279,7 +2279,7 @@ discard block |
||
| 2279 | 2279 | * @return string Donation ID from merchant processor |
| 2280 | 2280 | */ |
| 2281 | 2281 | private function get_transaction_id() { |
| 2282 | - return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this ); |
|
| 2282 | + return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this); |
|
| 2283 | 2283 | } |
| 2284 | 2284 | |
| 2285 | 2285 | /** |
@@ -2291,7 +2291,7 @@ discard block |
||
| 2291 | 2291 | * @return string Payment IP address |
| 2292 | 2292 | */ |
| 2293 | 2293 | private function get_ip() { |
| 2294 | - return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this ); |
|
| 2294 | + return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this); |
|
| 2295 | 2295 | } |
| 2296 | 2296 | |
| 2297 | 2297 | /** |
@@ -2303,7 +2303,7 @@ discard block |
||
| 2303 | 2303 | * @return int Payment customer ID |
| 2304 | 2304 | */ |
| 2305 | 2305 | private function get_customer_id() { |
| 2306 | - return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this ); |
|
| 2306 | + return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this); |
|
| 2307 | 2307 | } |
| 2308 | 2308 | |
| 2309 | 2309 | /** |
@@ -2315,7 +2315,7 @@ discard block |
||
| 2315 | 2315 | * @return int Payment user ID |
| 2316 | 2316 | */ |
| 2317 | 2317 | private function get_user_id() { |
| 2318 | - return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this ); |
|
| 2318 | + return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this); |
|
| 2319 | 2319 | } |
| 2320 | 2320 | |
| 2321 | 2321 | /** |
@@ -2327,7 +2327,7 @@ discard block |
||
| 2327 | 2327 | * @return string Payment customer email |
| 2328 | 2328 | */ |
| 2329 | 2329 | private function get_email() { |
| 2330 | - return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this ); |
|
| 2330 | + return apply_filters('give_payment_user_email', $this->email, $this->ID, $this); |
|
| 2331 | 2331 | } |
| 2332 | 2332 | |
| 2333 | 2333 | /** |
@@ -2339,7 +2339,7 @@ discard block |
||
| 2339 | 2339 | * @return array Payment user info |
| 2340 | 2340 | */ |
| 2341 | 2341 | private function get_user_info() { |
| 2342 | - return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this ); |
|
| 2342 | + return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this); |
|
| 2343 | 2343 | } |
| 2344 | 2344 | |
| 2345 | 2345 | /** |
@@ -2351,7 +2351,7 @@ discard block |
||
| 2351 | 2351 | * @return array Payment billing address |
| 2352 | 2352 | */ |
| 2353 | 2353 | private function get_address() { |
| 2354 | - return apply_filters( 'give_payment_address', $this->address, $this->ID, $this ); |
|
| 2354 | + return apply_filters('give_payment_address', $this->address, $this->ID, $this); |
|
| 2355 | 2355 | } |
| 2356 | 2356 | |
| 2357 | 2357 | /** |
@@ -2363,7 +2363,7 @@ discard block |
||
| 2363 | 2363 | * @return string Payment key |
| 2364 | 2364 | */ |
| 2365 | 2365 | private function get_key() { |
| 2366 | - return apply_filters( 'give_payment_key', $this->key, $this->ID, $this ); |
|
| 2366 | + return apply_filters('give_payment_key', $this->key, $this->ID, $this); |
|
| 2367 | 2367 | } |
| 2368 | 2368 | |
| 2369 | 2369 | /** |
@@ -2375,7 +2375,7 @@ discard block |
||
| 2375 | 2375 | * @return string Payment form id |
| 2376 | 2376 | */ |
| 2377 | 2377 | private function get_form_id() { |
| 2378 | - return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this ); |
|
| 2378 | + return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this); |
|
| 2379 | 2379 | } |
| 2380 | 2380 | |
| 2381 | 2381 | /** |
@@ -2387,7 +2387,7 @@ discard block |
||
| 2387 | 2387 | * @return int|string Payment number |
| 2388 | 2388 | */ |
| 2389 | 2389 | private function get_number() { |
| 2390 | - return apply_filters( 'give_payment_number', $this->number, $this->ID, $this ); |
|
| 2390 | + return apply_filters('give_payment_number', $this->number, $this->ID, $this); |
|
| 2391 | 2391 | } |
| 2392 | 2392 | |
| 2393 | 2393 | } |
@@ -188,8 +188,8 @@ |
||
| 188 | 188 | |
| 189 | 189 | $payment_ids = implode( ',', $payment_ids ); |
| 190 | 190 | $customer->update( array( 'payment_ids' => $payment_ids, |
| 191 | - 'purchase_count' => $purchase_count, |
|
| 192 | - 'purchase_value' => $pending_total |
|
| 191 | + 'purchase_count' => $purchase_count, |
|
| 192 | + 'purchase_value' => $pending_total |
|
| 193 | 193 | ) ); |
| 194 | 194 | |
| 195 | 195 | $this->done = true; |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | * @since 1.5 |
| 51 | 51 | * @global object $wpdb Used to query the database using the WordPress |
| 52 | 52 | * Database API |
| 53 | - * @return array $data The data for the CSV file |
|
| 53 | + * @return boolean $data The data for the CSV file |
|
| 54 | 54 | */ |
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $wpdb; |
@@ -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 | |
@@ -54,39 +54,39 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function get_data() { |
| 56 | 56 | |
| 57 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 58 | - $payments = $this->get_stored_data( 'give_recount_customer_payments_' . $customer->id, array() ); |
|
| 57 | + $customer = new Give_Customer($this->customer_id); |
|
| 58 | + $payments = $this->get_stored_data('give_recount_customer_payments_'.$customer->id, array()); |
|
| 59 | 59 | |
| 60 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
| 61 | - $step_items = array_slice( $payments, $offset, $this->per_step ); |
|
| 60 | + $offset = ($this->step - 1) * $this->per_step; |
|
| 61 | + $step_items = array_slice($payments, $offset, $this->per_step); |
|
| 62 | 62 | |
| 63 | - if ( count( $step_items ) > 0 ) { |
|
| 64 | - $pending_total = (float) $this->get_stored_data( 'give_stats_customer_pending_total' . $customer->id, 0 ); |
|
| 63 | + if (count($step_items) > 0) { |
|
| 64 | + $pending_total = (float) $this->get_stored_data('give_stats_customer_pending_total'.$customer->id, 0); |
|
| 65 | 65 | $step_total = 0; |
| 66 | 66 | |
| 67 | - $found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $customer->id, array() ); |
|
| 67 | + $found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$customer->id, array()); |
|
| 68 | 68 | |
| 69 | - foreach ( $step_items as $payment ) { |
|
| 70 | - $payment = get_post( $payment->ID ); |
|
| 69 | + foreach ($step_items as $payment) { |
|
| 70 | + $payment = get_post($payment->ID); |
|
| 71 | 71 | |
| 72 | - if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) { |
|
| 72 | + if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) { |
|
| 73 | 73 | |
| 74 | - $missing_payments = $this->get_stored_data( 'give_stats_missing_payments' . $customer->id, array() ); |
|
| 74 | + $missing_payments = $this->get_stored_data('give_stats_missing_payments'.$customer->id, array()); |
|
| 75 | 75 | $missing_payments[] = $payment->ID; |
| 76 | - $this->store_data( 'give_stats_missing_payments' . $customer->id, $missing_payments ); |
|
| 76 | + $this->store_data('give_stats_missing_payments'.$customer->id, $missing_payments); |
|
| 77 | 77 | |
| 78 | 78 | continue; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | $should_process_payment = 'publish' == $payment->post_status ? true : false; |
| 82 | - $should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment ); |
|
| 82 | + $should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment); |
|
| 83 | 83 | |
| 84 | - if ( true === $should_process_payment ) { |
|
| 84 | + if (true === $should_process_payment) { |
|
| 85 | 85 | |
| 86 | 86 | $found_payment_ids[] = $payment->ID; |
| 87 | 87 | |
| 88 | - if ( apply_filters( 'give_customer_recount_sholud_increase_value', true, $payment ) ) { |
|
| 89 | - $payment_amount = give_get_payment_amount( $payment->ID ); |
|
| 88 | + if (apply_filters('give_customer_recount_sholud_increase_value', true, $payment)) { |
|
| 89 | + $payment_amount = give_get_payment_amount($payment->ID); |
|
| 90 | 90 | $step_total += $payment_amount; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | $updated_total = $pending_total + $step_total; |
| 98 | - $this->store_data( 'give_stats_customer_pending_total' . $customer->id, $updated_total ); |
|
| 99 | - $this->store_data( 'give_stats_found_payments_' . $customer->id, $found_payment_ids ); |
|
| 98 | + $this->store_data('give_stats_customer_pending_total'.$customer->id, $updated_total); |
|
| 99 | + $this->store_data('give_stats_found_payments_'.$customer->id, $found_payment_ids); |
|
| 100 | 100 | |
| 101 | 101 | return true; |
| 102 | 102 | } |
@@ -113,16 +113,16 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function get_percentage_complete() { |
| 115 | 115 | |
| 116 | - $payments = $this->get_stored_data( 'give_recount_customer_payments_' . $this->customer_id ); |
|
| 117 | - $total = count( $payments ); |
|
| 116 | + $payments = $this->get_stored_data('give_recount_customer_payments_'.$this->customer_id); |
|
| 117 | + $total = count($payments); |
|
| 118 | 118 | |
| 119 | 119 | $percentage = 100; |
| 120 | 120 | |
| 121 | - if ( $total > 0 ) { |
|
| 122 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 121 | + if ($total > 0) { |
|
| 122 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - if ( $percentage > 100 ) { |
|
| 125 | + if ($percentage > 100) { |
|
| 126 | 126 | $percentage = 100; |
| 127 | 127 | } |
| 128 | 128 | |
@@ -136,8 +136,8 @@ discard block |
||
| 136 | 136 | * |
| 137 | 137 | * @param array $request The Form Data passed into the batch processing |
| 138 | 138 | */ |
| 139 | - public function set_properties( $request ) { |
|
| 140 | - $this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false; |
|
| 139 | + public function set_properties($request) { |
|
| 140 | + $this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -148,62 +148,62 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public function process_step() { |
| 150 | 150 | |
| 151 | - if ( ! $this->can_export() ) { |
|
| 152 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 151 | + if ( ! $this->can_export()) { |
|
| 152 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | $had_data = $this->get_data(); |
| 156 | 156 | |
| 157 | - if ( $had_data ) { |
|
| 157 | + if ($had_data) { |
|
| 158 | 158 | $this->done = false; |
| 159 | 159 | |
| 160 | 160 | return true; |
| 161 | 161 | } else { |
| 162 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 163 | - $payment_ids = get_option( 'give_stats_found_payments_' . $customer->id, array() ); |
|
| 164 | - $this->delete_data( 'give_stats_found_payments_' . $customer->id ); |
|
| 162 | + $customer = new Give_Customer($this->customer_id); |
|
| 163 | + $payment_ids = get_option('give_stats_found_payments_'.$customer->id, array()); |
|
| 164 | + $this->delete_data('give_stats_found_payments_'.$customer->id); |
|
| 165 | 165 | |
| 166 | - $removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $customer->id, array() ) ); |
|
| 166 | + $removed_payments = array_unique(get_option('give_stats_missing_payments'.$customer->id, array())); |
|
| 167 | 167 | |
| 168 | 168 | // Find non-existing payments (deleted) and total up the donation count |
| 169 | 169 | $purchase_count = 0; |
| 170 | - foreach ( $payment_ids as $key => $payment_id ) { |
|
| 171 | - if ( in_array( $payment_id, $removed_payments ) ) { |
|
| 172 | - unset( $payment_ids[ $key ] ); |
|
| 170 | + foreach ($payment_ids as $key => $payment_id) { |
|
| 171 | + if (in_array($payment_id, $removed_payments)) { |
|
| 172 | + unset($payment_ids[$key]); |
|
| 173 | 173 | continue; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - $payment = get_post( $payment_id ); |
|
| 177 | - if ( apply_filters( 'give_customer_recount_should_increase_count', true, $payment ) ) { |
|
| 178 | - $purchase_count ++; |
|
| 176 | + $payment = get_post($payment_id); |
|
| 177 | + if (apply_filters('give_customer_recount_should_increase_count', true, $payment)) { |
|
| 178 | + $purchase_count++; |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - $this->delete_data( 'give_stats_missing_payments' . $customer->id ); |
|
| 182 | + $this->delete_data('give_stats_missing_payments'.$customer->id); |
|
| 183 | 183 | |
| 184 | - $pending_total = $this->get_stored_data( 'give_stats_customer_pending_total' . $customer->id, 0 ); |
|
| 185 | - $this->delete_data( 'give_stats_customer_pending_total' . $customer->id ); |
|
| 186 | - $this->delete_data( 'give_recount_customer_stats_' . $customer->id ); |
|
| 187 | - $this->delete_data( 'give_recount_customer_payments_' . $this->customer_id ); |
|
| 184 | + $pending_total = $this->get_stored_data('give_stats_customer_pending_total'.$customer->id, 0); |
|
| 185 | + $this->delete_data('give_stats_customer_pending_total'.$customer->id); |
|
| 186 | + $this->delete_data('give_recount_customer_stats_'.$customer->id); |
|
| 187 | + $this->delete_data('give_recount_customer_payments_'.$this->customer_id); |
|
| 188 | 188 | |
| 189 | - $payment_ids = implode( ',', $payment_ids ); |
|
| 190 | - $customer->update( array( 'payment_ids' => $payment_ids, |
|
| 189 | + $payment_ids = implode(',', $payment_ids); |
|
| 190 | + $customer->update(array('payment_ids' => $payment_ids, |
|
| 191 | 191 | 'purchase_count' => $purchase_count, |
| 192 | 192 | 'purchase_value' => $pending_total |
| 193 | - ) ); |
|
| 193 | + )); |
|
| 194 | 194 | |
| 195 | 195 | $this->done = true; |
| 196 | - $this->message = esc_html__( 'Donor stats successfully recounted.', 'give' ); |
|
| 196 | + $this->message = esc_html__('Donor stats successfully recounted.', 'give'); |
|
| 197 | 197 | |
| 198 | 198 | return false; |
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | public function headers() { |
| 203 | - ignore_user_abort( true ); |
|
| 203 | + ignore_user_abort(true); |
|
| 204 | 204 | |
| 205 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 206 | - set_time_limit( 0 ); |
|
| 205 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 206 | + set_time_limit(0); |
|
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | 209 | |
@@ -230,26 +230,26 @@ discard block |
||
| 230 | 230 | * @return void |
| 231 | 231 | */ |
| 232 | 232 | public function pre_fetch() { |
| 233 | - if ( $this->step === 1 ) { |
|
| 234 | - $allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() ); |
|
| 233 | + if ($this->step === 1) { |
|
| 234 | + $allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys()); |
|
| 235 | 235 | |
| 236 | 236 | // Before we start, let's zero out the customer's data |
| 237 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 238 | - $customer->update( array( 'purchase_value' => give_format_amount( 0 ), 'purchase_count' => 0 ) ); |
|
| 237 | + $customer = new Give_Customer($this->customer_id); |
|
| 238 | + $customer->update(array('purchase_value' => give_format_amount(0), 'purchase_count' => 0)); |
|
| 239 | 239 | |
| 240 | - $attached_payment_ids = explode( ',', $customer->payment_ids ); |
|
| 240 | + $attached_payment_ids = explode(',', $customer->payment_ids); |
|
| 241 | 241 | |
| 242 | 242 | $attached_args = array( |
| 243 | 243 | 'post__in' => $attached_payment_ids, |
| 244 | - 'number' => - 1, |
|
| 244 | + 'number' => -1, |
|
| 245 | 245 | 'status' => $allowed_payment_status, |
| 246 | 246 | ); |
| 247 | 247 | |
| 248 | - $attached_payments = give_get_payments( $attached_args ); |
|
| 248 | + $attached_payments = give_get_payments($attached_args); |
|
| 249 | 249 | |
| 250 | 250 | $unattached_args = array( |
| 251 | 251 | 'post__not_in' => $attached_payment_ids, |
| 252 | - 'number' => - 1, |
|
| 252 | + 'number' => -1, |
|
| 253 | 253 | 'status' => $allowed_payment_status, |
| 254 | 254 | 'meta_query' => array( |
| 255 | 255 | array( |
@@ -259,11 +259,11 @@ discard block |
||
| 259 | 259 | ), |
| 260 | 260 | ); |
| 261 | 261 | |
| 262 | - $unattached_payments = give_get_payments( $unattached_args ); |
|
| 262 | + $unattached_payments = give_get_payments($unattached_args); |
|
| 263 | 263 | |
| 264 | - $payments = array_merge( $attached_payments, $unattached_payments ); |
|
| 264 | + $payments = array_merge($attached_payments, $unattached_payments); |
|
| 265 | 265 | |
| 266 | - $this->store_data( 'give_recount_customer_payments_' . $customer->id, $payments ); |
|
| 266 | + $this->store_data('give_recount_customer_payments_'.$customer->id, $payments); |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | |
@@ -276,11 +276,11 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | * @return mixed Returns the data from the database |
| 278 | 278 | */ |
| 279 | - private function get_stored_data( $key ) { |
|
| 279 | + private function get_stored_data($key) { |
|
| 280 | 280 | global $wpdb; |
| 281 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 281 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 282 | 282 | |
| 283 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
| 283 | + return empty($value) ? false : maybe_unserialize($value); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
@@ -293,10 +293,10 @@ discard block |
||
| 293 | 293 | * |
| 294 | 294 | * @return void |
| 295 | 295 | */ |
| 296 | - private function store_data( $key, $value ) { |
|
| 296 | + private function store_data($key, $value) { |
|
| 297 | 297 | global $wpdb; |
| 298 | 298 | |
| 299 | - $value = maybe_serialize( $value ); |
|
| 299 | + $value = maybe_serialize($value); |
|
| 300 | 300 | |
| 301 | 301 | $data = array( |
| 302 | 302 | 'option_name' => $key, |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | '%s', |
| 311 | 311 | ); |
| 312 | 312 | |
| 313 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 313 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
@@ -322,9 +322,9 @@ discard block |
||
| 322 | 322 | * |
| 323 | 323 | * @return void |
| 324 | 324 | */ |
| 325 | - private function delete_data( $key ) { |
|
| 325 | + private function delete_data($key) { |
|
| 326 | 326 | global $wpdb; |
| 327 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 327 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -19,10 +19,10 @@ discard block |
||
| 19 | 19 | * @since 1.5 |
| 20 | 20 | */ |
| 21 | 21 | function give_register_batch_recount_store_earnings_tool() { |
| 22 | - add_action( 'give_batch_export_class_include', 'give_include_recount_income_tool_batch_processor', 10, 1 ); |
|
| 22 | + add_action('give_batch_export_class_include', 'give_include_recount_income_tool_batch_processor', 10, 1); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -add_action( 'give_register_batch_exporter', 'give_register_batch_recount_store_earnings_tool', 10 ); |
|
| 25 | +add_action('give_register_batch_exporter', 'give_register_batch_recount_store_earnings_tool', 10); |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * Loads the tools batch processing class for recounting store earnings |
@@ -33,11 +33,11 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @return void |
| 35 | 35 | */ |
| 36 | -function give_include_recount_income_tool_batch_processor( $class ) { |
|
| 36 | +function give_include_recount_income_tool_batch_processor($class) { |
|
| 37 | 37 | |
| 38 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-income.php'; |
|
| 38 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-income.php'; |
|
| 39 | 39 | |
| 40 | - if ( 'Give_Tools_Recount_Income' === $class && file_exists( $file_path ) ) { |
|
| 40 | + if ('Give_Tools_Recount_Income' === $class && file_exists($file_path)) { |
|
| 41 | 41 | require_once $file_path; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -49,10 +49,10 @@ discard block |
||
| 49 | 49 | * @since 1.5 |
| 50 | 50 | */ |
| 51 | 51 | function give_register_batch_recount_form_tool() { |
| 52 | - add_action( 'give_batch_export_class_include', 'give_include_recount_form_tool_batch_processor', 10, 1 ); |
|
| 52 | + add_action('give_batch_export_class_include', 'give_include_recount_form_tool_batch_processor', 10, 1); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | -add_action( 'give_register_batch_exporter', 'give_register_batch_recount_form_tool', 10 ); |
|
| 55 | +add_action('give_register_batch_exporter', 'give_register_batch_recount_form_tool', 10); |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * Loads the tools batch processing class for recounting download stats |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @return void |
| 65 | 65 | */ |
| 66 | -function give_include_recount_form_tool_batch_processor( $class ) { |
|
| 66 | +function give_include_recount_form_tool_batch_processor($class) { |
|
| 67 | 67 | |
| 68 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-form-stats.php'; |
|
| 68 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-form-stats.php'; |
|
| 69 | 69 | |
| 70 | - if ( 'Give_Tools_Recount_Form_Stats' === $class && file_exists( $file_path ) ) { |
|
| 70 | + if ('Give_Tools_Recount_Form_Stats' === $class && file_exists($file_path)) { |
|
| 71 | 71 | require_once $file_path; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -78,10 +78,10 @@ discard block |
||
| 78 | 78 | * @since 1.5 |
| 79 | 79 | */ |
| 80 | 80 | function give_register_batch_recount_all_tool() { |
| 81 | - add_action( 'give_batch_export_class_include', 'give_include_recount_all_tool_batch_processor', 10, 1 ); |
|
| 81 | + add_action('give_batch_export_class_include', 'give_include_recount_all_tool_batch_processor', 10, 1); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | -add_action( 'give_register_batch_exporter', 'give_register_batch_recount_all_tool', 10 ); |
|
| 84 | +add_action('give_register_batch_exporter', 'give_register_batch_recount_all_tool', 10); |
|
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | 87 | * Loads the tools batch processing class for recounting all stats |
@@ -92,9 +92,9 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return void |
| 94 | 94 | */ |
| 95 | -function give_include_recount_all_tool_batch_processor( $class ) { |
|
| 96 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-all-stats.php'; |
|
| 97 | - if ( 'Give_Tools_Recount_All_Stats' === $class && file_exists( $file_path ) ) { |
|
| 95 | +function give_include_recount_all_tool_batch_processor($class) { |
|
| 96 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-all-stats.php'; |
|
| 97 | + if ('Give_Tools_Recount_All_Stats' === $class && file_exists($file_path)) { |
|
| 98 | 98 | require_once $file_path; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -106,10 +106,10 @@ discard block |
||
| 106 | 106 | * @since 1.5 |
| 107 | 107 | */ |
| 108 | 108 | function give_register_batch_reset_tool() { |
| 109 | - add_action( 'give_batch_export_class_include', 'give_include_reset_tool_batch_processor', 10, 1 ); |
|
| 109 | + add_action('give_batch_export_class_include', 'give_include_reset_tool_batch_processor', 10, 1); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | -add_action( 'give_register_batch_exporter', 'give_register_batch_reset_tool', 10 ); |
|
| 112 | +add_action('give_register_batch_exporter', 'give_register_batch_reset_tool', 10); |
|
| 113 | 113 | |
| 114 | 114 | /** |
| 115 | 115 | * Loads the tools batch processing class for resetting store and product earnings |
@@ -120,11 +120,11 @@ discard block |
||
| 120 | 120 | * |
| 121 | 121 | * @return void |
| 122 | 122 | */ |
| 123 | -function give_include_reset_tool_batch_processor( $class ) { |
|
| 123 | +function give_include_reset_tool_batch_processor($class) { |
|
| 124 | 124 | |
| 125 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-reset-stats.php'; |
|
| 125 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-reset-stats.php'; |
|
| 126 | 126 | |
| 127 | - if ( 'Give_Tools_Reset_Stats' === $class && file_exists( $file_path ) ) { |
|
| 127 | + if ('Give_Tools_Reset_Stats' === $class && file_exists($file_path)) { |
|
| 128 | 128 | require_once $file_path; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -135,10 +135,10 @@ discard block |
||
| 135 | 135 | * @since 1.5 |
| 136 | 136 | */ |
| 137 | 137 | function give_register_batch_customer_recount_tool() { |
| 138 | - add_action( 'give_batch_export_class_include', 'give_include_customer_recount_tool_batch_processor', 10, 1 ); |
|
| 138 | + add_action('give_batch_export_class_include', 'give_include_customer_recount_tool_batch_processor', 10, 1); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | -add_action( 'give_register_batch_exporter', 'give_register_batch_customer_recount_tool', 10 ); |
|
| 141 | +add_action('give_register_batch_exporter', 'give_register_batch_customer_recount_tool', 10); |
|
| 142 | 142 | |
| 143 | 143 | /** |
| 144 | 144 | * Loads the tools batch processing class for resetting all customer stats |
@@ -149,11 +149,11 @@ discard block |
||
| 149 | 149 | * |
| 150 | 150 | * @return void |
| 151 | 151 | */ |
| 152 | -function give_include_customer_recount_tool_batch_processor( $class ) { |
|
| 152 | +function give_include_customer_recount_tool_batch_processor($class) { |
|
| 153 | 153 | |
| 154 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-customer-stats.php'; |
|
| 154 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-customer-stats.php'; |
|
| 155 | 155 | |
| 156 | - if ( 'Give_Tools_Recount_Customer_Stats' === $class && file_exists( $file_path ) ) { |
|
| 156 | + if ('Give_Tools_Recount_Customer_Stats' === $class && file_exists($file_path)) { |
|
| 157 | 157 | require_once $file_path; |
| 158 | 158 | } |
| 159 | 159 | |
@@ -164,10 +164,10 @@ discard block |
||
| 164 | 164 | * @since 1.5 |
| 165 | 165 | */ |
| 166 | 166 | function give_register_batch_delete_test_transactions_tool() { |
| 167 | - add_action( 'give_batch_export_class_include', 'give_include_delete_test_transactions_batch_processor', 10, 1 ); |
|
| 167 | + add_action('give_batch_export_class_include', 'give_include_delete_test_transactions_batch_processor', 10, 1); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | -add_action( 'give_register_batch_exporter', 'give_register_batch_delete_test_transactions_tool', 10 ); |
|
| 170 | +add_action('give_register_batch_exporter', 'give_register_batch_delete_test_transactions_tool', 10); |
|
| 171 | 171 | |
| 172 | 172 | /** |
| 173 | 173 | * Loads the tools batch processing class for resetting all customer stats |
@@ -178,11 +178,11 @@ discard block |
||
| 178 | 178 | * |
| 179 | 179 | * @return void |
| 180 | 180 | */ |
| 181 | -function give_include_delete_test_transactions_batch_processor( $class ) { |
|
| 181 | +function give_include_delete_test_transactions_batch_processor($class) { |
|
| 182 | 182 | |
| 183 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-delete-test-transactions.php'; |
|
| 183 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-delete-test-transactions.php'; |
|
| 184 | 184 | |
| 185 | - if ( 'Give_Tools_Delete_Test_Transactions' === $class && file_exists( $file_path ) ) { |
|
| 185 | + if ('Give_Tools_Delete_Test_Transactions' === $class && file_exists($file_path)) { |
|
| 186 | 186 | require_once $file_path; |
| 187 | 187 | } |
| 188 | 188 | |