@@ -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 | |
@@ -46,24 +46,24 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @return array $gateway_list All the available gateways |
| 48 | 48 | */ |
| 49 | -function give_get_enabled_payment_gateways( $form_id = 0 ) { |
|
| 49 | +function give_get_enabled_payment_gateways($form_id = 0) { |
|
| 50 | 50 | |
| 51 | 51 | $gateways = give_get_payment_gateways(); |
| 52 | 52 | |
| 53 | - $enabled = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
| 53 | + $enabled = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
| 54 | 54 | |
| 55 | 55 | $gateway_list = array(); |
| 56 | 56 | |
| 57 | - foreach ( $gateways as $key => $gateway ) { |
|
| 58 | - if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) { |
|
| 59 | - $gateway_list[ $key ] = $gateway; |
|
| 57 | + foreach ($gateways as $key => $gateway) { |
|
| 58 | + if (isset($enabled[$key]) && $enabled[$key] == 1) { |
|
| 59 | + $gateway_list[$key] = $gateway; |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Set order of payment gateway in list. |
| 64 | - $gateway_list = give_get_ordered_payment_gateways( $gateway_list ); |
|
| 64 | + $gateway_list = give_get_ordered_payment_gateways($gateway_list); |
|
| 65 | 65 | |
| 66 | - return apply_filters( 'give_enabled_payment_gateways', $gateway_list, $form_id ); |
|
| 66 | + return apply_filters('give_enabled_payment_gateways', $gateway_list, $form_id); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -75,12 +75,12 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @return boolean true if enabled, false otherwise |
| 77 | 77 | */ |
| 78 | -function give_is_gateway_active( $gateway ) { |
|
| 78 | +function give_is_gateway_active($gateway) { |
|
| 79 | 79 | $gateways = give_get_enabled_payment_gateways(); |
| 80 | 80 | |
| 81 | - $ret = array_key_exists( $gateway, $gateways ); |
|
| 81 | + $ret = array_key_exists($gateway, $gateways); |
|
| 82 | 82 | |
| 83 | - return apply_filters( 'give_is_gateway_active', $ret, $gateway, $gateways ); |
|
| 83 | + return apply_filters('give_is_gateway_active', $ret, $gateway, $gateways); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -92,25 +92,25 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return string Gateway ID |
| 94 | 94 | */ |
| 95 | -function give_get_default_gateway( $form_id ) { |
|
| 95 | +function give_get_default_gateway($form_id) { |
|
| 96 | 96 | |
| 97 | - $enabled_gateways = array_keys( give_get_enabled_payment_gateways() ); |
|
| 97 | + $enabled_gateways = array_keys(give_get_enabled_payment_gateways()); |
|
| 98 | 98 | $default_gateway = give_get_option('default_gateway'); |
| 99 | - $default = ! empty( $default_gateway ) && give_is_gateway_active( $default_gateway ) ? $default_gateway : $enabled_gateways[0]; |
|
| 100 | - $form_default = give_get_meta( $form_id, '_give_default_gateway', true ); |
|
| 99 | + $default = ! empty($default_gateway) && give_is_gateway_active($default_gateway) ? $default_gateway : $enabled_gateways[0]; |
|
| 100 | + $form_default = give_get_meta($form_id, '_give_default_gateway', true); |
|
| 101 | 101 | |
| 102 | 102 | // Single Form settings varies compared to the Global default settings. |
| 103 | 103 | if ( |
| 104 | - ! empty( $form_default ) && |
|
| 104 | + ! empty($form_default) && |
|
| 105 | 105 | $form_id !== null && |
| 106 | 106 | $default !== $form_default && |
| 107 | 107 | 'global' !== $form_default && |
| 108 | - give_is_gateway_active( $form_default ) |
|
| 108 | + give_is_gateway_active($form_default) |
|
| 109 | 109 | ) { |
| 110 | 110 | $default = $form_default; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - return apply_filters( 'give_default_gateway', $default ); |
|
| 113 | + return apply_filters('give_default_gateway', $default); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -122,18 +122,18 @@ discard block |
||
| 122 | 122 | * |
| 123 | 123 | * @return string Gateway admin label |
| 124 | 124 | */ |
| 125 | -function give_get_gateway_admin_label( $gateway ) { |
|
| 125 | +function give_get_gateway_admin_label($gateway) { |
|
| 126 | 126 | $gateways = give_get_payment_gateways(); |
| 127 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
| 128 | - $payment = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false; |
|
| 127 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
| 128 | + $payment = isset($_GET['id']) ? absint($_GET['id']) : false; |
|
| 129 | 129 | |
| 130 | - if ( $gateway == 'manual' && $payment ) { |
|
| 131 | - if ( give_donation_amount( $payment ) == 0 ) { |
|
| 132 | - $label = __( 'Test Donation', 'give' ); |
|
| 130 | + if ($gateway == 'manual' && $payment) { |
|
| 131 | + if (give_donation_amount($payment) == 0) { |
|
| 132 | + $label = __('Test Donation', 'give'); |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - return apply_filters( 'give_gateway_admin_label', $label, $gateway ); |
|
| 136 | + return apply_filters('give_gateway_admin_label', $label, $gateway); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -145,15 +145,15 @@ discard block |
||
| 145 | 145 | * |
| 146 | 146 | * @return string Checkout label for the gateway |
| 147 | 147 | */ |
| 148 | -function give_get_gateway_checkout_label( $gateway ) { |
|
| 148 | +function give_get_gateway_checkout_label($gateway) { |
|
| 149 | 149 | $gateways = give_get_payment_gateways(); |
| 150 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
| 150 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
| 151 | 151 | |
| 152 | - if ( $gateway == 'manual' ) { |
|
| 153 | - $label = __( 'Test Donation', 'give' ); |
|
| 152 | + if ($gateway == 'manual') { |
|
| 153 | + $label = __('Test Donation', 'give'); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - return apply_filters( 'give_gateway_checkout_label', $label, $gateway ); |
|
| 156 | + return apply_filters('give_gateway_checkout_label', $label, $gateway); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -165,11 +165,11 @@ discard block |
||
| 165 | 165 | * |
| 166 | 166 | * @return array Options the gateway supports |
| 167 | 167 | */ |
| 168 | -function give_get_gateway_supports( $gateway ) { |
|
| 168 | +function give_get_gateway_supports($gateway) { |
|
| 169 | 169 | $gateways = give_get_enabled_payment_gateways(); |
| 170 | - $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array(); |
|
| 170 | + $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array(); |
|
| 171 | 171 | |
| 172 | - return apply_filters( 'give_gateway_supports', $supports, $gateway ); |
|
| 172 | + return apply_filters('give_gateway_supports', $supports, $gateway); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
@@ -182,9 +182,9 @@ discard block |
||
| 182 | 182 | * |
| 183 | 183 | * @return void |
| 184 | 184 | */ |
| 185 | -function give_send_to_gateway( $gateway, $payment_data ) { |
|
| 185 | +function give_send_to_gateway($gateway, $payment_data) { |
|
| 186 | 186 | |
| 187 | - $payment_data['gateway_nonce'] = wp_create_nonce( 'give-gateway' ); |
|
| 187 | + $payment_data['gateway_nonce'] = wp_create_nonce('give-gateway'); |
|
| 188 | 188 | |
| 189 | 189 | /** |
| 190 | 190 | * Fires while loading payment gateway via AJAX. |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * |
| 196 | 196 | * @param array $payment_data All the payment data to be sent to the gateway. |
| 197 | 197 | */ |
| 198 | - do_action( "give_gateway_{$gateway}", $payment_data ); |
|
| 198 | + do_action("give_gateway_{$gateway}", $payment_data); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | |
@@ -209,34 +209,34 @@ discard block |
||
| 209 | 209 | * |
| 210 | 210 | * @return string $enabled_gateway The slug of the gateway |
| 211 | 211 | */ |
| 212 | -function give_get_chosen_gateway( $form_id ) { |
|
| 212 | +function give_get_chosen_gateway($form_id) { |
|
| 213 | 213 | |
| 214 | - $request_form_id = isset( $_REQUEST['give_form_id'] ) ? $_REQUEST['give_form_id'] : 0; |
|
| 214 | + $request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0; |
|
| 215 | 215 | |
| 216 | 216 | // Back to check if 'form-id' is present. |
| 217 | - if ( empty( $request_form_id ) ) { |
|
| 218 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? $_REQUEST['form-id'] : 0; |
|
| 217 | + if (empty($request_form_id)) { |
|
| 218 | + $request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0; |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - $request_payment_mode = isset( $_REQUEST['payment-mode'] ) ? $_REQUEST['payment-mode'] : ''; |
|
| 221 | + $request_payment_mode = isset($_REQUEST['payment-mode']) ? $_REQUEST['payment-mode'] : ''; |
|
| 222 | 222 | $chosen = false; |
| 223 | 223 | |
| 224 | 224 | // If both 'payment-mode' and 'form-id' then set for only this form. |
| 225 | - if ( ! empty( $request_form_id ) && $form_id == $request_form_id ) { |
|
| 225 | + if ( ! empty($request_form_id) && $form_id == $request_form_id) { |
|
| 226 | 226 | $chosen = $request_payment_mode; |
| 227 | - } elseif ( empty( $request_form_id ) && $request_payment_mode ) { |
|
| 227 | + } elseif (empty($request_form_id) && $request_payment_mode) { |
|
| 228 | 228 | // If no 'form-id' but there is 'payment-mode'. |
| 229 | 229 | $chosen = $request_payment_mode; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | // Get the enable gateway based of chosen var. |
| 233 | - if ( $chosen && give_is_gateway_active( $chosen ) ) { |
|
| 234 | - $enabled_gateway = urldecode( $chosen ); |
|
| 233 | + if ($chosen && give_is_gateway_active($chosen)) { |
|
| 234 | + $enabled_gateway = urldecode($chosen); |
|
| 235 | 235 | } else { |
| 236 | - $enabled_gateway = give_get_default_gateway( $form_id ); |
|
| 236 | + $enabled_gateway = give_get_default_gateway($form_id); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - return apply_filters( 'give_chosen_gateway', $enabled_gateway ); |
|
| 239 | + return apply_filters('give_chosen_gateway', $enabled_gateway); |
|
| 240 | 240 | |
| 241 | 241 | } |
| 242 | 242 | |
@@ -255,8 +255,8 @@ discard block |
||
| 255 | 255 | * |
| 256 | 256 | * @return int ID of the new log entry. |
| 257 | 257 | */ |
| 258 | -function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) { |
|
| 259 | - return Give()->logs->add( $title, $message, $parent, $type ); |
|
| 258 | +function give_record_log($title = '', $message = '', $parent = 0, $type = null) { |
|
| 259 | + return Give()->logs->add($title, $message, $parent, $type); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | /** |
@@ -273,10 +273,10 @@ discard block |
||
| 273 | 273 | * |
| 274 | 274 | * @return int ID of the new log entry |
| 275 | 275 | */ |
| 276 | -function give_record_gateway_error( $title = '', $message = '', $parent = 0 ) { |
|
| 277 | - $title = empty( $title ) ? esc_html__( 'Payment Error', 'give' ) : $title; |
|
| 276 | +function give_record_gateway_error($title = '', $message = '', $parent = 0) { |
|
| 277 | + $title = empty($title) ? esc_html__('Payment Error', 'give') : $title; |
|
| 278 | 278 | |
| 279 | - return give_record_log( $title, $message, $parent, 'gateway_error' ); |
|
| 279 | + return give_record_log($title, $message, $parent, 'gateway_error'); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | /** |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | * |
| 290 | 290 | * @return int |
| 291 | 291 | */ |
| 292 | -function give_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
| 292 | +function give_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
| 293 | 293 | |
| 294 | 294 | $ret = 0; |
| 295 | 295 | $args = array( |
@@ -301,9 +301,9 @@ discard block |
||
| 301 | 301 | 'fields' => 'ids', |
| 302 | 302 | ); |
| 303 | 303 | |
| 304 | - $payments = new WP_Query( $args ); |
|
| 304 | + $payments = new WP_Query($args); |
|
| 305 | 305 | |
| 306 | - if ( $payments ) { |
|
| 306 | + if ($payments) { |
|
| 307 | 307 | $ret = $payments->post_count; |
| 308 | 308 | } |
| 309 | 309 | |
@@ -320,27 +320,27 @@ discard block |
||
| 320 | 320 | * |
| 321 | 321 | * @return array $gateways All the available gateways |
| 322 | 322 | */ |
| 323 | -function give_get_ordered_payment_gateways( $gateways ) { |
|
| 323 | +function give_get_ordered_payment_gateways($gateways) { |
|
| 324 | 324 | |
| 325 | 325 | // Get gateways setting. |
| 326 | - $gateways_setting = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
| 326 | + $gateways_setting = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
| 327 | 327 | |
| 328 | 328 | // Return from here if we do not have gateways setting. |
| 329 | - if ( empty( $gateways_setting ) ) { |
|
| 329 | + if (empty($gateways_setting)) { |
|
| 330 | 330 | return $gateways; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | // Reverse array to order payment gateways. |
| 334 | - $gateways_setting = array_reverse( $gateways_setting ); |
|
| 334 | + $gateways_setting = array_reverse($gateways_setting); |
|
| 335 | 335 | |
| 336 | 336 | // Reorder gateways array |
| 337 | - foreach ( $gateways_setting as $gateway_key => $value ) { |
|
| 337 | + foreach ($gateways_setting as $gateway_key => $value) { |
|
| 338 | 338 | |
| 339 | - $new_gateway_value = isset( $gateways[ $gateway_key ] ) ? $gateways[ $gateway_key ] : ''; |
|
| 340 | - unset( $gateways[ $gateway_key ] ); |
|
| 339 | + $new_gateway_value = isset($gateways[$gateway_key]) ? $gateways[$gateway_key] : ''; |
|
| 340 | + unset($gateways[$gateway_key]); |
|
| 341 | 341 | |
| 342 | - if ( ! empty( $new_gateway_value ) ) { |
|
| 343 | - $gateways = array_merge( array( $gateway_key => $new_gateway_value ), $gateways ); |
|
| 342 | + if ( ! empty($new_gateway_value)) { |
|
| 343 | + $gateways = array_merge(array($gateway_key => $new_gateway_value), $gateways); |
|
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | 346 | |
@@ -351,5 +351,5 @@ discard block |
||
| 351 | 351 | * |
| 352 | 352 | * @param array $gateways All the available gateways |
| 353 | 353 | */ |
| 354 | - return apply_filters( 'give_payment_gateways_order', $gateways ); |
|
| 354 | + return apply_filters('give_payment_gateways_order', $gateways); |
|
| 355 | 355 | } |
| 356 | 356 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @return string Donations dropdown. |
| 37 | 37 | */ |
| 38 | - public function donations_dropdown( $args = array() ) { |
|
| 38 | + public function donations_dropdown($args = array()) { |
|
| 39 | 39 | |
| 40 | 40 | $defaults = array( |
| 41 | 41 | 'name' => 'donations', |
@@ -45,32 +45,32 @@ discard block |
||
| 45 | 45 | 'selected' => 0, |
| 46 | 46 | 'chosen' => false, |
| 47 | 47 | 'number' => 30, |
| 48 | - 'placeholder' => __( 'Select a donation', 'give' ), |
|
| 48 | + 'placeholder' => __('Select a donation', 'give'), |
|
| 49 | 49 | ); |
| 50 | 50 | |
| 51 | - $args = wp_parse_args( $args, $defaults ); |
|
| 51 | + $args = wp_parse_args($args, $defaults); |
|
| 52 | 52 | |
| 53 | - $payments = new Give_Payments_Query( array( |
|
| 53 | + $payments = new Give_Payments_Query(array( |
|
| 54 | 54 | 'number' => $args['number'], |
| 55 | - ) ); |
|
| 55 | + )); |
|
| 56 | 56 | |
| 57 | 57 | $payments = $payments->get_payments(); |
| 58 | 58 | |
| 59 | 59 | $options = array(); |
| 60 | 60 | |
| 61 | 61 | // Provide nice human readable options. |
| 62 | - if ( $payments ) { |
|
| 62 | + if ($payments) { |
|
| 63 | 63 | $options[0] = $args['placeholder']; |
| 64 | - foreach ( $payments as $payment ) { |
|
| 64 | + foreach ($payments as $payment) { |
|
| 65 | 65 | |
| 66 | - $options[ absint( $payment->ID ) ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title ); |
|
| 66 | + $options[absint($payment->ID)] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title); |
|
| 67 | 67 | |
| 68 | 68 | } |
| 69 | 69 | } else { |
| 70 | - $options[0] = __( 'No donations found.', 'give' ); |
|
| 70 | + $options[0] = __('No donations found.', 'give'); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - $output = $this->select( array( |
|
| 73 | + $output = $this->select(array( |
|
| 74 | 74 | 'name' => $args['name'], |
| 75 | 75 | 'selected' => $args['selected'], |
| 76 | 76 | 'id' => $args['id'], |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | 'select_atts' => $args['select_atts'], |
| 83 | 83 | 'show_option_all' => false, |
| 84 | 84 | 'show_option_none' => false, |
| 85 | - ) ); |
|
| 85 | + )); |
|
| 86 | 86 | |
| 87 | 87 | return $output; |
| 88 | 88 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @return string Give forms dropdown. |
| 101 | 101 | */ |
| 102 | - public function forms_dropdown( $args = array() ) { |
|
| 102 | + public function forms_dropdown($args = array()) { |
|
| 103 | 103 | |
| 104 | 104 | $defaults = array( |
| 105 | 105 | 'name' => 'forms', |
@@ -109,13 +109,13 @@ discard block |
||
| 109 | 109 | 'selected' => 0, |
| 110 | 110 | 'chosen' => false, |
| 111 | 111 | 'number' => 30, |
| 112 | - 'placeholder' => esc_attr__( 'All Forms', 'give' ), |
|
| 112 | + 'placeholder' => esc_attr__('All Forms', 'give'), |
|
| 113 | 113 | 'data' => array( |
| 114 | 114 | 'search-type' => 'form', |
| 115 | 115 | ), |
| 116 | 116 | ); |
| 117 | 117 | |
| 118 | - $args = wp_parse_args( $args, $defaults ); |
|
| 118 | + $args = wp_parse_args($args, $defaults); |
|
| 119 | 119 | |
| 120 | 120 | $form_args = array( |
| 121 | 121 | 'post_type' => 'give_forms', |
@@ -124,34 +124,34 @@ discard block |
||
| 124 | 124 | 'posts_per_page' => $args['number'], |
| 125 | 125 | ); |
| 126 | 126 | |
| 127 | - $cache_key = Give_Cache::get_key( 'give_forms', $form_args, false ); |
|
| 127 | + $cache_key = Give_Cache::get_key('give_forms', $form_args, false); |
|
| 128 | 128 | |
| 129 | 129 | // Get forms from cache. |
| 130 | - $forms = Give_Cache::get_db_query( $cache_key ); |
|
| 130 | + $forms = Give_Cache::get_db_query($cache_key); |
|
| 131 | 131 | |
| 132 | - if ( is_null( $forms ) ) { |
|
| 133 | - $forms = get_posts( $form_args ); |
|
| 134 | - Give_Cache::set_db_query( $cache_key, $forms ); |
|
| 132 | + if (is_null($forms)) { |
|
| 133 | + $forms = get_posts($form_args); |
|
| 134 | + Give_Cache::set_db_query($cache_key, $forms); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | $options = array(); |
| 138 | 138 | |
| 139 | 139 | // Ensure the selected. |
| 140 | - if ( false !== $args['selected'] && $args['selected'] !== 0 ) { |
|
| 141 | - $options[ $args['selected'] ] = get_the_title( $args['selected'] ); |
|
| 140 | + if (false !== $args['selected'] && $args['selected'] !== 0) { |
|
| 141 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - if ( $forms ) { |
|
| 144 | + if ($forms) { |
|
| 145 | 145 | $options[0] = $args['placeholder']; |
| 146 | - foreach ( $forms as $form ) { |
|
| 147 | - $form_title = empty( $form->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $form->ID ) : $form->post_title; |
|
| 148 | - $options[ absint( $form->ID ) ] = esc_html( $form_title ); |
|
| 146 | + foreach ($forms as $form) { |
|
| 147 | + $form_title = empty($form->post_title) ? sprintf(__('Untitled (#%s)', 'give'), $form->ID) : $form->post_title; |
|
| 148 | + $options[absint($form->ID)] = esc_html($form_title); |
|
| 149 | 149 | } |
| 150 | 150 | } else { |
| 151 | - $options[0] = esc_html__( 'No forms found.', 'give' ); |
|
| 151 | + $options[0] = esc_html__('No forms found.', 'give'); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - $output = $this->select( array( |
|
| 154 | + $output = $this->select(array( |
|
| 155 | 155 | 'name' => $args['name'], |
| 156 | 156 | 'selected' => $args['selected'], |
| 157 | 157 | 'id' => $args['id'], |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | 'show_option_all' => false, |
| 164 | 164 | 'show_option_none' => false, |
| 165 | 165 | 'data' => $args['data'], |
| 166 | - ) ); |
|
| 166 | + )); |
|
| 167 | 167 | |
| 168 | 168 | return $output; |
| 169 | 169 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * |
| 181 | 181 | * @return string Donors dropdown. |
| 182 | 182 | */ |
| 183 | - public function donor_dropdown( $args = array() ) { |
|
| 183 | + public function donor_dropdown($args = array()) { |
|
| 184 | 184 | |
| 185 | 185 | $defaults = array( |
| 186 | 186 | 'name' => 'donors', |
@@ -189,57 +189,57 @@ discard block |
||
| 189 | 189 | 'multiple' => false, |
| 190 | 190 | 'selected' => 0, |
| 191 | 191 | 'chosen' => true, |
| 192 | - 'placeholder' => esc_attr__( 'Select a Donor', 'give' ), |
|
| 192 | + 'placeholder' => esc_attr__('Select a Donor', 'give'), |
|
| 193 | 193 | 'number' => 30, |
| 194 | 194 | 'data' => array( |
| 195 | 195 | 'search-type' => 'donor', |
| 196 | 196 | ), |
| 197 | 197 | ); |
| 198 | 198 | |
| 199 | - $args = wp_parse_args( $args, $defaults ); |
|
| 199 | + $args = wp_parse_args($args, $defaults); |
|
| 200 | 200 | |
| 201 | - $donors = Give()->donors->get_donors( array( |
|
| 201 | + $donors = Give()->donors->get_donors(array( |
|
| 202 | 202 | 'number' => $args['number'] |
| 203 | - ) ); |
|
| 203 | + )); |
|
| 204 | 204 | |
| 205 | 205 | $options = array(); |
| 206 | 206 | |
| 207 | - if ( $donors ) { |
|
| 208 | - $options[0] = esc_html__( 'No donor attached', 'give' ); |
|
| 209 | - foreach ( $donors as $donor ) { |
|
| 210 | - $options[ absint( $donor->id ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' ); |
|
| 207 | + if ($donors) { |
|
| 208 | + $options[0] = esc_html__('No donor attached', 'give'); |
|
| 209 | + foreach ($donors as $donor) { |
|
| 210 | + $options[absint($donor->id)] = esc_html($donor->name.' ('.$donor->email.')'); |
|
| 211 | 211 | } |
| 212 | 212 | } else { |
| 213 | - $options[0] = esc_html__( 'No donors found.', 'give' ); |
|
| 213 | + $options[0] = esc_html__('No donors found.', 'give'); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - if ( ! empty( $args['selected'] ) ) { |
|
| 216 | + if ( ! empty($args['selected'])) { |
|
| 217 | 217 | |
| 218 | 218 | // If a selected customer has been specified, we need to ensure it's in the initial list of customers displayed. |
| 219 | - if ( ! array_key_exists( $args['selected'], $options ) ) { |
|
| 219 | + if ( ! array_key_exists($args['selected'], $options)) { |
|
| 220 | 220 | |
| 221 | - $donor = new Give_Donor( $args['selected'] ); |
|
| 221 | + $donor = new Give_Donor($args['selected']); |
|
| 222 | 222 | |
| 223 | - if ( $donor ) { |
|
| 223 | + if ($donor) { |
|
| 224 | 224 | |
| 225 | - $options[ absint( $args['selected'] ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' ); |
|
| 225 | + $options[absint($args['selected'])] = esc_html($donor->name.' ('.$donor->email.')'); |
|
| 226 | 226 | |
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - $output = $this->select( array( |
|
| 231 | + $output = $this->select(array( |
|
| 232 | 232 | 'name' => $args['name'], |
| 233 | 233 | 'selected' => $args['selected'], |
| 234 | 234 | 'id' => $args['id'], |
| 235 | - 'class' => $args['class'] . ' give-customer-select', |
|
| 235 | + 'class' => $args['class'].' give-customer-select', |
|
| 236 | 236 | 'options' => $options, |
| 237 | 237 | 'multiple' => $args['multiple'], |
| 238 | 238 | 'chosen' => $args['chosen'], |
| 239 | 239 | 'show_option_all' => false, |
| 240 | 240 | 'show_option_none' => false, |
| 241 | 241 | 'data' => $args['data'], |
| 242 | - ) ); |
|
| 242 | + )); |
|
| 243 | 243 | |
| 244 | 244 | return $output; |
| 245 | 245 | } |
@@ -258,21 +258,21 @@ discard block |
||
| 258 | 258 | * |
| 259 | 259 | * @return string Categories dropdown. |
| 260 | 260 | */ |
| 261 | - public function category_dropdown( $name = 'give_forms_categories', $selected = 0, $args = array() ) { |
|
| 262 | - $categories = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) ); |
|
| 261 | + public function category_dropdown($name = 'give_forms_categories', $selected = 0, $args = array()) { |
|
| 262 | + $categories = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array())); |
|
| 263 | 263 | $options = array(); |
| 264 | 264 | |
| 265 | - foreach ( $categories as $category ) { |
|
| 266 | - $options[ absint( $category->term_id ) ] = esc_html( $category->name ); |
|
| 265 | + foreach ($categories as $category) { |
|
| 266 | + $options[absint($category->term_id)] = esc_html($category->name); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - $output = $this->select( wp_parse_args( $args, array( |
|
| 269 | + $output = $this->select(wp_parse_args($args, array( |
|
| 270 | 270 | 'name' => $name, |
| 271 | 271 | 'selected' => $selected, |
| 272 | 272 | 'options' => $options, |
| 273 | - 'show_option_all' => esc_html__( 'All Categories', 'give' ), |
|
| 273 | + 'show_option_all' => esc_html__('All Categories', 'give'), |
|
| 274 | 274 | 'show_option_none' => false, |
| 275 | - ) ) ); |
|
| 275 | + ))); |
|
| 276 | 276 | |
| 277 | 277 | return $output; |
| 278 | 278 | } |
@@ -291,21 +291,21 @@ discard block |
||
| 291 | 291 | * |
| 292 | 292 | * @return string Tags dropdown. |
| 293 | 293 | */ |
| 294 | - public function tags_dropdown( $name = 'give_forms_tags', $selected = 0, $args = array() ) { |
|
| 295 | - $tags = get_terms( 'give_forms_tag', apply_filters( 'give_forms_tag_dropdown', array() ) ); |
|
| 294 | + public function tags_dropdown($name = 'give_forms_tags', $selected = 0, $args = array()) { |
|
| 295 | + $tags = get_terms('give_forms_tag', apply_filters('give_forms_tag_dropdown', array())); |
|
| 296 | 296 | $options = array(); |
| 297 | 297 | |
| 298 | - foreach ( $tags as $tag ) { |
|
| 299 | - $options[ absint( $tag->term_id ) ] = esc_html( $tag->name ); |
|
| 298 | + foreach ($tags as $tag) { |
|
| 299 | + $options[absint($tag->term_id)] = esc_html($tag->name); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - $output = $this->select( wp_parse_args( $args, array( |
|
| 302 | + $output = $this->select(wp_parse_args($args, array( |
|
| 303 | 303 | 'name' => $name, |
| 304 | 304 | 'selected' => $selected, |
| 305 | 305 | 'options' => $options, |
| 306 | - 'show_option_all' => esc_html__( 'All Tags', 'give' ), |
|
| 306 | + 'show_option_all' => esc_html__('All Tags', 'give'), |
|
| 307 | 307 | 'show_option_none' => false, |
| 308 | - ) ) ); |
|
| 308 | + ))); |
|
| 309 | 309 | |
| 310 | 310 | return $output; |
| 311 | 311 | } |
@@ -325,25 +325,25 @@ discard block |
||
| 325 | 325 | * |
| 326 | 326 | * @return string Years dropdown. |
| 327 | 327 | */ |
| 328 | - public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
| 329 | - $current = date( 'Y' ); |
|
| 330 | - $start_year = $current - absint( $years_before ); |
|
| 331 | - $end_year = $current + absint( $years_after ); |
|
| 332 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
| 328 | + public function year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
| 329 | + $current = date('Y'); |
|
| 330 | + $start_year = $current - absint($years_before); |
|
| 331 | + $end_year = $current + absint($years_after); |
|
| 332 | + $selected = empty($selected) ? date('Y') : $selected; |
|
| 333 | 333 | $options = array(); |
| 334 | 334 | |
| 335 | - while ( $start_year <= $end_year ) { |
|
| 336 | - $options[ absint( $start_year ) ] = $start_year; |
|
| 337 | - $start_year ++; |
|
| 335 | + while ($start_year <= $end_year) { |
|
| 336 | + $options[absint($start_year)] = $start_year; |
|
| 337 | + $start_year++; |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - $output = $this->select( array( |
|
| 340 | + $output = $this->select(array( |
|
| 341 | 341 | 'name' => $name, |
| 342 | 342 | 'selected' => $selected, |
| 343 | 343 | 'options' => $options, |
| 344 | 344 | 'show_option_all' => false, |
| 345 | 345 | 'show_option_none' => false, |
| 346 | - ) ); |
|
| 346 | + )); |
|
| 347 | 347 | |
| 348 | 348 | return $output; |
| 349 | 349 | } |
@@ -361,23 +361,23 @@ discard block |
||
| 361 | 361 | * |
| 362 | 362 | * @return string Months dropdown. |
| 363 | 363 | */ |
| 364 | - public function month_dropdown( $name = 'month', $selected = 0 ) { |
|
| 364 | + public function month_dropdown($name = 'month', $selected = 0) { |
|
| 365 | 365 | $month = 1; |
| 366 | 366 | $options = array(); |
| 367 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
| 367 | + $selected = empty($selected) ? date('n') : $selected; |
|
| 368 | 368 | |
| 369 | - while ( $month <= 12 ) { |
|
| 370 | - $options[ absint( $month ) ] = give_month_num_to_name( $month ); |
|
| 371 | - $month ++; |
|
| 369 | + while ($month <= 12) { |
|
| 370 | + $options[absint($month)] = give_month_num_to_name($month); |
|
| 371 | + $month++; |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - $output = $this->select( array( |
|
| 374 | + $output = $this->select(array( |
|
| 375 | 375 | 'name' => $name, |
| 376 | 376 | 'selected' => $selected, |
| 377 | 377 | 'options' => $options, |
| 378 | 378 | 'show_option_all' => false, |
| 379 | 379 | 'show_option_none' => false, |
| 380 | - ) ); |
|
| 380 | + )); |
|
| 381 | 381 | |
| 382 | 382 | return $output; |
| 383 | 383 | } |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | * |
| 395 | 395 | * @return string The dropdown. |
| 396 | 396 | */ |
| 397 | - public function select( $args = array() ) { |
|
| 397 | + public function select($args = array()) { |
|
| 398 | 398 | $defaults = array( |
| 399 | 399 | 'options' => array(), |
| 400 | 400 | 'name' => null, |
@@ -405,74 +405,74 @@ discard block |
||
| 405 | 405 | 'placeholder' => null, |
| 406 | 406 | 'multiple' => false, |
| 407 | 407 | 'select_atts' => false, |
| 408 | - 'show_option_all' => __( 'All', 'give' ), |
|
| 409 | - 'show_option_none' => __( 'None', 'give' ), |
|
| 408 | + 'show_option_all' => __('All', 'give'), |
|
| 409 | + 'show_option_none' => __('None', 'give'), |
|
| 410 | 410 | 'data' => array(), |
| 411 | 411 | 'readonly' => false, |
| 412 | 412 | 'disabled' => false, |
| 413 | 413 | ); |
| 414 | 414 | |
| 415 | - $args = wp_parse_args( $args, $defaults ); |
|
| 415 | + $args = wp_parse_args($args, $defaults); |
|
| 416 | 416 | |
| 417 | 417 | $data_elements = ''; |
| 418 | - foreach ( $args['data'] as $key => $value ) { |
|
| 419 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
| 418 | + foreach ($args['data'] as $key => $value) { |
|
| 419 | + $data_elements .= ' data-'.esc_attr($key).'="'.esc_attr($value).'"'; |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | $multiple = ''; |
| 423 | - if ( $args['multiple'] ) { |
|
| 423 | + if ($args['multiple']) { |
|
| 424 | 424 | $multiple = 'MULTIPLE'; |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - if ( $args['chosen'] ) { |
|
| 427 | + if ($args['chosen']) { |
|
| 428 | 428 | $args['class'] .= ' give-select-chosen'; |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | $placeholder = ''; |
| 432 | - if ( $args['placeholder'] ) { |
|
| 432 | + if ($args['placeholder']) { |
|
| 433 | 433 | $placeholder = $args['placeholder']; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | $output = sprintf( |
| 437 | 437 | '<select name="%1$s" id="%2$s" class="give-select %3$s" %4$s %5$s placeholder="%6$s" data-placeholder="%6$s" %7$s>', |
| 438 | - esc_attr( $args['name'] ), |
|
| 439 | - esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ), |
|
| 440 | - esc_attr( $args['class'] ), |
|
| 438 | + esc_attr($args['name']), |
|
| 439 | + esc_attr(sanitize_key(str_replace('-', '_', $args['id']))), |
|
| 440 | + esc_attr($args['class']), |
|
| 441 | 441 | $multiple, |
| 442 | 442 | $args['select_atts'], |
| 443 | 443 | $placeholder, |
| 444 | 444 | $data_elements |
| 445 | 445 | ); |
| 446 | 446 | |
| 447 | - if ( $args['show_option_all'] ) { |
|
| 448 | - if ( $args['multiple'] ) { |
|
| 449 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
| 447 | + if ($args['show_option_all']) { |
|
| 448 | + if ($args['multiple']) { |
|
| 449 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
| 450 | 450 | } else { |
| 451 | - $selected = selected( $args['selected'], 0, false ); |
|
| 451 | + $selected = selected($args['selected'], 0, false); |
|
| 452 | 452 | } |
| 453 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
| 453 | + $output .= '<option value="all"'.$selected.'>'.esc_html($args['show_option_all']).'</option>'; |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - if ( ! empty( $args['options'] ) ) { |
|
| 456 | + if ( ! empty($args['options'])) { |
|
| 457 | 457 | |
| 458 | - if ( $args['show_option_none'] ) { |
|
| 459 | - if ( $args['multiple'] ) { |
|
| 460 | - $selected = selected( true, in_array( - 1, $args['selected'] ), false ); |
|
| 458 | + if ($args['show_option_none']) { |
|
| 459 | + if ($args['multiple']) { |
|
| 460 | + $selected = selected(true, in_array( -1, $args['selected'] ), false); |
|
| 461 | 461 | } else { |
| 462 | - $selected = selected( $args['selected'], - 1, false ); |
|
| 462 | + $selected = selected($args['selected'], - 1, false); |
|
| 463 | 463 | } |
| 464 | - $output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
| 464 | + $output .= '<option value="-1"'.$selected.'>'.esc_html($args['show_option_none']).'</option>'; |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | - foreach ( $args['options'] as $key => $option ) { |
|
| 467 | + foreach ($args['options'] as $key => $option) { |
|
| 468 | 468 | |
| 469 | - if ( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
| 470 | - $selected = selected( true, in_array( $key, $args['selected'] ), false ); |
|
| 469 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
| 470 | + $selected = selected(true, in_array($key, $args['selected']), false); |
|
| 471 | 471 | } else { |
| 472 | - $selected = selected( $args['selected'], $key, false ); |
|
| 472 | + $selected = selected($args['selected'], $key, false); |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
| 475 | + $output .= '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option).'</option>'; |
|
| 476 | 476 | } |
| 477 | 477 | } |
| 478 | 478 | |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | * |
| 494 | 494 | * @return string The checkbox. |
| 495 | 495 | */ |
| 496 | - public function checkbox( $args = array() ) { |
|
| 496 | + public function checkbox($args = array()) { |
|
| 497 | 497 | $defaults = array( |
| 498 | 498 | 'name' => null, |
| 499 | 499 | 'current' => null, |
@@ -504,16 +504,16 @@ discard block |
||
| 504 | 504 | ), |
| 505 | 505 | ); |
| 506 | 506 | |
| 507 | - $args = wp_parse_args( $args, $defaults ); |
|
| 507 | + $args = wp_parse_args($args, $defaults); |
|
| 508 | 508 | |
| 509 | 509 | $options = ''; |
| 510 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
| 510 | + if ( ! empty($args['options']['disabled'])) { |
|
| 511 | 511 | $options .= ' disabled="disabled"'; |
| 512 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
| 512 | + } elseif ( ! empty($args['options']['readonly'])) { |
|
| 513 | 513 | $options .= ' readonly'; |
| 514 | 514 | } |
| 515 | 515 | |
| 516 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
| 516 | + $output = '<input type="checkbox"'.$options.' name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].' '.esc_attr($args['name']).'" '.checked(1, $args['current'], false).' />'; |
|
| 517 | 517 | |
| 518 | 518 | return $output; |
| 519 | 519 | } |
@@ -530,22 +530,22 @@ discard block |
||
| 530 | 530 | * |
| 531 | 531 | * @return string The text field. |
| 532 | 532 | */ |
| 533 | - public function text( $args = array() ) { |
|
| 533 | + public function text($args = array()) { |
|
| 534 | 534 | // Backwards compatibility. |
| 535 | - if ( func_num_args() > 1 ) { |
|
| 535 | + if (func_num_args() > 1) { |
|
| 536 | 536 | $args = func_get_args(); |
| 537 | 537 | |
| 538 | 538 | $name = $args[0]; |
| 539 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
| 540 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
| 541 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
| 539 | + $value = isset($args[1]) ? $args[1] : ''; |
|
| 540 | + $label = isset($args[2]) ? $args[2] : ''; |
|
| 541 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | $defaults = array( |
| 545 | - 'name' => isset( $name ) ? $name : 'text', |
|
| 546 | - 'value' => isset( $value ) ? $value : null, |
|
| 547 | - 'label' => isset( $label ) ? $label : null, |
|
| 548 | - 'desc' => isset( $desc ) ? $desc : null, |
|
| 545 | + 'name' => isset($name) ? $name : 'text', |
|
| 546 | + 'value' => isset($value) ? $value : null, |
|
| 547 | + 'label' => isset($label) ? $label : null, |
|
| 548 | + 'desc' => isset($desc) ? $desc : null, |
|
| 549 | 549 | 'placeholder' => '', |
| 550 | 550 | 'class' => 'regular-text', |
| 551 | 551 | 'disabled' => false, |
@@ -553,29 +553,29 @@ discard block |
||
| 553 | 553 | 'data' => false, |
| 554 | 554 | ); |
| 555 | 555 | |
| 556 | - $args = wp_parse_args( $args, $defaults ); |
|
| 556 | + $args = wp_parse_args($args, $defaults); |
|
| 557 | 557 | |
| 558 | 558 | $disabled = ''; |
| 559 | - if ( $args['disabled'] ) { |
|
| 559 | + if ($args['disabled']) { |
|
| 560 | 560 | $disabled = ' disabled="disabled"'; |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | $data = ''; |
| 564 | - if ( ! empty( $args['data'] ) ) { |
|
| 565 | - foreach ( $args['data'] as $key => $value ) { |
|
| 566 | - $data .= 'data-' . $key . '="' . $value . '" '; |
|
| 564 | + if ( ! empty($args['data'])) { |
|
| 565 | + foreach ($args['data'] as $key => $value) { |
|
| 566 | + $data .= 'data-'.$key.'="'.$value.'" '; |
|
| 567 | 567 | } |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 570 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
| 571 | 571 | |
| 572 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 572 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
| 573 | 573 | |
| 574 | - if ( ! empty( $args['desc'] ) ) { |
|
| 575 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 574 | + if ( ! empty($args['desc'])) { |
|
| 575 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>'; |
|
| 578 | + $output .= '<input type="text" name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" autocomplete="'.esc_attr($args['autocomplete']).'" value="'.esc_attr($args['value']).'" placeholder="'.esc_attr($args['placeholder']).'" class="'.$args['class'].'" '.$data.''.$disabled.'/>'; |
|
| 579 | 579 | |
| 580 | 580 | $output .= '</span>'; |
| 581 | 581 | |
@@ -594,15 +594,15 @@ discard block |
||
| 594 | 594 | * |
| 595 | 595 | * @return string The date picker. |
| 596 | 596 | */ |
| 597 | - public function date_field( $args = array() ) { |
|
| 597 | + public function date_field($args = array()) { |
|
| 598 | 598 | |
| 599 | - if ( empty( $args['class'] ) ) { |
|
| 599 | + if (empty($args['class'])) { |
|
| 600 | 600 | $args['class'] = 'give_datepicker'; |
| 601 | - } elseif ( ! strpos( $args['class'], 'give_datepicker' ) ) { |
|
| 601 | + } elseif ( ! strpos($args['class'], 'give_datepicker')) { |
|
| 602 | 602 | $args['class'] .= ' give_datepicker'; |
| 603 | 603 | } |
| 604 | 604 | |
| 605 | - return $this->text( $args ); |
|
| 605 | + return $this->text($args); |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | /** |
@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | * |
| 618 | 618 | * @return string The textarea. |
| 619 | 619 | */ |
| 620 | - public function textarea( $args = array() ) { |
|
| 620 | + public function textarea($args = array()) { |
|
| 621 | 621 | $defaults = array( |
| 622 | 622 | 'name' => 'textarea', |
| 623 | 623 | 'value' => null, |
@@ -627,21 +627,21 @@ discard block |
||
| 627 | 627 | 'disabled' => false, |
| 628 | 628 | ); |
| 629 | 629 | |
| 630 | - $args = wp_parse_args( $args, $defaults ); |
|
| 630 | + $args = wp_parse_args($args, $defaults); |
|
| 631 | 631 | |
| 632 | 632 | $disabled = ''; |
| 633 | - if ( $args['disabled'] ) { |
|
| 633 | + if ($args['disabled']) { |
|
| 634 | 634 | $disabled = ' disabled="disabled"'; |
| 635 | 635 | } |
| 636 | 636 | |
| 637 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 637 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
| 638 | 638 | |
| 639 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 639 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
| 640 | 640 | |
| 641 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
| 641 | + $output .= '<textarea name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].'"'.$disabled.'>'.esc_attr($args['value']).'</textarea>'; |
|
| 642 | 642 | |
| 643 | - if ( ! empty( $args['desc'] ) ) { |
|
| 644 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 643 | + if ( ! empty($args['desc'])) { |
|
| 644 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | $output .= '</span>'; |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | * |
| 662 | 662 | * @return string The text field with ajax search. |
| 663 | 663 | */ |
| 664 | - public function ajax_user_search( $args = array() ) { |
|
| 664 | + public function ajax_user_search($args = array()) { |
|
| 665 | 665 | |
| 666 | 666 | $defaults = array( |
| 667 | 667 | 'name' => 'users', |
@@ -672,13 +672,13 @@ discard block |
||
| 672 | 672 | 'chosen' => true, |
| 673 | 673 | 'number' => 30, |
| 674 | 674 | 'select_atts' => '', |
| 675 | - 'placeholder' => __( 'Select a user', 'give' ), |
|
| 675 | + 'placeholder' => __('Select a user', 'give'), |
|
| 676 | 676 | 'data' => array( |
| 677 | 677 | 'search-type' => 'user', |
| 678 | 678 | ), |
| 679 | 679 | ); |
| 680 | 680 | |
| 681 | - $args = wp_parse_args( $args, $defaults ); |
|
| 681 | + $args = wp_parse_args($args, $defaults); |
|
| 682 | 682 | |
| 683 | 683 | // Set initial args. |
| 684 | 684 | $get_users_args = array( |
@@ -687,31 +687,31 @@ discard block |
||
| 687 | 687 | |
| 688 | 688 | // Ensure selected user is not included in initial query. |
| 689 | 689 | // This is because sites with many users, it's not a guarantee the selected user will be returned. |
| 690 | - if ( ! empty( $args['selected'] ) ) { |
|
| 690 | + if ( ! empty($args['selected'])) { |
|
| 691 | 691 | $get_users_args['exclude'] = $args['selected']; |
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | // Initial users array. |
| 695 | - $users = apply_filters( 'give_ajax_user_search_initial_results', get_users( $get_users_args ), $args ); |
|
| 695 | + $users = apply_filters('give_ajax_user_search_initial_results', get_users($get_users_args), $args); |
|
| 696 | 696 | |
| 697 | 697 | // Now add the selected user to the $users array if the arg is present. |
| 698 | - if ( ! empty( $args['selected'] ) ) { |
|
| 699 | - $selected_user = apply_filters( 'give_ajax_user_search_selected_results', get_users( "include={$args['selected']}" ), $args );; |
|
| 700 | - $users = array_merge( $users, $selected_user ); |
|
| 698 | + if ( ! empty($args['selected'])) { |
|
| 699 | + $selected_user = apply_filters('give_ajax_user_search_selected_results', get_users("include={$args['selected']}"), $args); ; |
|
| 700 | + $users = array_merge($users, $selected_user); |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | $options = array(); |
| 704 | 704 | |
| 705 | - if ( $users ) { |
|
| 705 | + if ($users) { |
|
| 706 | 706 | $options[0] = $args['placeholder']; |
| 707 | - foreach ( $users as $user ) { |
|
| 708 | - $options[ absint( $user->ID ) ] = esc_html( $user->user_login . ' (' . $user->user_email . ')' ); |
|
| 707 | + foreach ($users as $user) { |
|
| 708 | + $options[absint($user->ID)] = esc_html($user->user_login.' ('.$user->user_email.')'); |
|
| 709 | 709 | } |
| 710 | 710 | } else { |
| 711 | - $options[0] = __( 'No users found.', 'give' ); |
|
| 711 | + $options[0] = __('No users found.', 'give'); |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | - $output = $this->select( array( |
|
| 714 | + $output = $this->select(array( |
|
| 715 | 715 | 'name' => $args['name'], |
| 716 | 716 | 'selected' => $args['selected'], |
| 717 | 717 | 'id' => $args['id'], |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | 'show_option_all' => false, |
| 725 | 725 | 'show_option_none' => false, |
| 726 | 726 | 'data' => $args['data'], |
| 727 | - ) ); |
|
| 727 | + )); |
|
| 728 | 728 | |
| 729 | 729 | return $output; |
| 730 | 730 | |
@@ -6,16 +6,16 @@ discard block |
||
| 6 | 6 | * @version 1.0 |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 9 | +if ( ! defined('ABSPATH')) { |
|
| 10 | 10 | exit; |
| 11 | 11 | } // Exit if accessed directly. |
| 12 | 12 | |
| 13 | 13 | // For gmail compatibility, including CSS styles in head/body are stripped out therefore styles need to be inline. These variables contain rules which are added to the template inline. !important; is a gmail hack to prevent styles being stripped if it doesn't like something. |
| 14 | -$body = " |
|
| 14 | +$body = " |
|
| 15 | 15 | background-color: #f6f6f6; |
| 16 | 16 | font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; |
| 17 | 17 | "; |
| 18 | -$wrapper = " |
|
| 18 | +$wrapper = " |
|
| 19 | 19 | width:100%; |
| 20 | 20 | -webkit-text-size-adjust:none !important; |
| 21 | 21 | margin:0; |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | border-radius:3px !important; |
| 30 | 30 | padding: 20px; |
| 31 | 31 | "; |
| 32 | -$template_header = " |
|
| 32 | +$template_header = " |
|
| 33 | 33 | color: #00000; |
| 34 | 34 | border-top-left-radius:3px !important; |
| 35 | 35 | border-top-right-radius:3px !important; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | text-align: center; |
| 40 | 40 | vertical-align:middle; |
| 41 | 41 | "; |
| 42 | -$body_content = " |
|
| 42 | +$body_content = " |
|
| 43 | 43 | border-radius:3px !important; |
| 44 | 44 | font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; |
| 45 | 45 | "; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | line-height:150%; |
| 51 | 51 | text-align:left; |
| 52 | 52 | "; |
| 53 | -$header_content_h1 = " |
|
| 53 | +$header_content_h1 = " |
|
| 54 | 54 | color: #000000; |
| 55 | 55 | margin:0; |
| 56 | 56 | padding: 28px 24px; |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | <html> |
| 66 | 66 | <head> |
| 67 | 67 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> |
| 68 | - <title><?php echo get_bloginfo( 'name' ); ?></title> |
|
| 68 | + <title><?php echo get_bloginfo('name'); ?></title> |
|
| 69 | 69 | </head> |
| 70 | 70 | <body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0" style="<?php echo $body; ?>"> |
| 71 | 71 | <div style="<?php echo $wrapper; ?>"> |
@@ -3,27 +3,27 @@ discard block |
||
| 3 | 3 | * This template is used to display the goal with [give_goal] |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -$form = new Give_Donate_Form( $form_id ); |
|
| 7 | -$goal_option = give_get_meta( $form->ID, '_give_goal_option', true ); |
|
| 6 | +$form = new Give_Donate_Form($form_id); |
|
| 7 | +$goal_option = give_get_meta($form->ID, '_give_goal_option', true); |
|
| 8 | 8 | |
| 9 | 9 | //Sanity check - ensure form has pass all condition to show goal. |
| 10 | 10 | if ( |
| 11 | - ( isset( $args['show_goal'] ) && ! filter_var( $args['show_goal'], FILTER_VALIDATE_BOOLEAN ) ) |
|
| 12 | - || empty( $form->ID ) |
|
| 13 | - || ( is_singular( 'give_forms' ) && ! give_is_setting_enabled( $goal_option ) ) |
|
| 14 | - || ! give_is_setting_enabled( $goal_option ) |
|
| 11 | + (isset($args['show_goal']) && ! filter_var($args['show_goal'], FILTER_VALIDATE_BOOLEAN)) |
|
| 12 | + || empty($form->ID) |
|
| 13 | + || (is_singular('give_forms') && ! give_is_setting_enabled($goal_option)) |
|
| 14 | + || ! give_is_setting_enabled($goal_option) |
|
| 15 | 15 | || 0 === $form->goal |
| 16 | 16 | ) { |
| 17 | 17 | return false; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | -$goal_format = give_get_meta( $form_id, '_give_goal_format', true ); |
|
| 21 | -$price = give_get_meta( $form_id, '_give_set_price', true ); |
|
| 22 | -$color = give_get_meta( $form_id, '_give_goal_color', true ); |
|
| 23 | -$show_text = isset( $args['show_text'] ) ? filter_var( $args['show_text'], FILTER_VALIDATE_BOOLEAN ) : true; |
|
| 24 | -$show_bar = isset( $args['show_bar'] ) ? filter_var( $args['show_bar'], FILTER_VALIDATE_BOOLEAN ) : true; |
|
| 25 | -$donations_goal = give_get_meta( $form_id, '_give_number_of_donation_goal', true ); |
|
| 26 | -$donations_completed = give_get_form_sales_stats( $form_id ); |
|
| 20 | +$goal_format = give_get_meta($form_id, '_give_goal_format', true); |
|
| 21 | +$price = give_get_meta($form_id, '_give_set_price', true); |
|
| 22 | +$color = give_get_meta($form_id, '_give_goal_color', true); |
|
| 23 | +$show_text = isset($args['show_text']) ? filter_var($args['show_text'], FILTER_VALIDATE_BOOLEAN) : true; |
|
| 24 | +$show_bar = isset($args['show_bar']) ? filter_var($args['show_bar'], FILTER_VALIDATE_BOOLEAN) : true; |
|
| 25 | +$donations_goal = give_get_meta($form_id, '_give_number_of_donation_goal', true); |
|
| 26 | +$donations_completed = give_get_form_sales_stats($form_id); |
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -31,14 +31,14 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @since 1.8.8 |
| 33 | 33 | */ |
| 34 | -$income = apply_filters( 'give_goal_amount_raised_output', $form->get_earnings(), $form_id, $form ); |
|
| 34 | +$income = apply_filters('give_goal_amount_raised_output', $form->get_earnings(), $form_id, $form); |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Filter the form |
| 38 | 38 | * |
| 39 | 39 | * @since 1.8.8 |
| 40 | 40 | */ |
| 41 | -$goal = apply_filters( 'give_goal_amount_target_output', $form->goal, $form_id, $form ); |
|
| 41 | +$goal = apply_filters('give_goal_amount_target_output', $form->goal, $form_id, $form); |
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -47,10 +47,9 @@ discard block |
||
| 47 | 47 | * @since 1.8.8 |
| 48 | 48 | */ |
| 49 | 49 | $progress = 'donation' !== $goal_format ? |
| 50 | - round( ( $income / $goal ) * 100, 2 ) : |
|
| 51 | - round( ( $donations_completed / $donations_goal ) * 100, 2 ); |
|
| 50 | + round(($income / $goal) * 100, 2) : round(($donations_completed / $donations_goal) * 100, 2); |
|
| 52 | 51 | |
| 53 | -$progress = apply_filters( 'give_goal_amount_funded_percentage_output', $progress, $form_id, $form ); |
|
| 52 | +$progress = apply_filters('give_goal_amount_funded_percentage_output', $progress, $form_id, $form); |
|
| 54 | 53 | |
| 55 | 54 | |
| 56 | 55 | /** |
@@ -58,55 +57,55 @@ discard block |
||
| 58 | 57 | * |
| 59 | 58 | * @since 1.8.17 |
| 60 | 59 | */ |
| 61 | -$form_currency = apply_filters( 'give_goal_form_currency', give_get_currency( $form_id ), $form_id ); |
|
| 60 | +$form_currency = apply_filters('give_goal_form_currency', give_get_currency($form_id), $form_id); |
|
| 62 | 61 | |
| 63 | 62 | // Set progress to 100 percentage if income > goal or completed donations > donation goal count. |
| 64 | -if ( 'donation' === $goal_format ) { |
|
| 63 | +if ('donation' === $goal_format) { |
|
| 65 | 64 | $progress = $donations_completed >= $donations_goal ? 100 : $progress; |
| 66 | 65 | } else { |
| 67 | 66 | $progress = $income >= $goal ? 100 : $progress; |
| 68 | 67 | } |
| 69 | 68 | ?> |
| 70 | 69 | <div class="give-goal-progress"> |
| 71 | - <?php if ( ! empty( $show_text ) ) : ?> |
|
| 70 | + <?php if ( ! empty($show_text)) : ?> |
|
| 72 | 71 | <div class="raised"> |
| 73 | 72 | <?php |
| 74 | - if ( 'amount' === $goal_format ) : |
|
| 73 | + if ('amount' === $goal_format) : |
|
| 75 | 74 | |
| 76 | 75 | /** |
| 77 | 76 | * Filter the income formatting arguments. |
| 78 | 77 | * |
| 79 | 78 | * @since 1.8.17 |
| 80 | 79 | */ |
| 81 | - $income_format_args = apply_filters( 'give_goal_income_format_args', array( 'sanitize' => false, 'currency' => $form_currency, 'decimal' => false ), $form_id ); |
|
| 80 | + $income_format_args = apply_filters('give_goal_income_format_args', array('sanitize' => false, 'currency' => $form_currency, 'decimal' => false), $form_id); |
|
| 82 | 81 | |
| 83 | 82 | /** |
| 84 | 83 | * Filter the goal formatting arguments. |
| 85 | 84 | * |
| 86 | 85 | * @since 1.8.17 |
| 87 | 86 | */ |
| 88 | - $goal_format_args = apply_filters( 'give_goal_amount_format_args', array( 'sanitize' => false, 'currency' => $form_currency, 'decimal' => false ), $form_id ); |
|
| 87 | + $goal_format_args = apply_filters('give_goal_amount_format_args', array('sanitize' => false, 'currency' => $form_currency, 'decimal' => false), $form_id); |
|
| 89 | 88 | |
| 90 | 89 | // Get formatted amount. |
| 91 | - $income = give_human_format_large_amount( give_format_amount( $income, $income_format_args ), array( 'currency' => $form_currency ) ); |
|
| 92 | - $goal = give_human_format_large_amount( give_format_amount( $goal, $goal_format_args ), array( 'currency' => $form_currency ) ); |
|
| 90 | + $income = give_human_format_large_amount(give_format_amount($income, $income_format_args), array('currency' => $form_currency)); |
|
| 91 | + $goal = give_human_format_large_amount(give_format_amount($goal, $goal_format_args), array('currency' => $form_currency)); |
|
| 93 | 92 | |
| 94 | 93 | echo sprintf( |
| 95 | 94 | /* translators: 1: amount of income raised 2: goal target amount. */ |
| 96 | - __( '<span class="income">%1$s</span> of <span class="goal-text">%2$s</span> raised', 'give' ), |
|
| 97 | - give_currency_filter( $income, array( 'form_id' => $form_id ) ), |
|
| 98 | - give_currency_filter( $goal, array( 'form_id' => $form_id ) ) |
|
| 95 | + __('<span class="income">%1$s</span> of <span class="goal-text">%2$s</span> raised', 'give'), |
|
| 96 | + give_currency_filter($income, array('form_id' => $form_id)), |
|
| 97 | + give_currency_filter($goal, array('form_id' => $form_id)) |
|
| 99 | 98 | ); |
| 100 | 99 | |
| 101 | - elseif ( 'percentage' === $goal_format ) : |
|
| 100 | + elseif ('percentage' === $goal_format) : |
|
| 102 | 101 | |
| 103 | 102 | echo sprintf( |
| 104 | 103 | /* translators: %s: percentage of the amount raised compared to the goal target */ |
| 105 | - __( '<span class="give-percentage">%s%%</span> funded', 'give' ), |
|
| 106 | - round( $progress ) |
|
| 104 | + __('<span class="give-percentage">%s%%</span> funded', 'give'), |
|
| 105 | + round($progress) |
|
| 107 | 106 | ); |
| 108 | 107 | |
| 109 | - elseif ( 'donation' === $goal_format ) : |
|
| 108 | + elseif ('donation' === $goal_format) : |
|
| 110 | 109 | |
| 111 | 110 | echo sprintf( |
| 112 | 111 | /* translators: 1: total number of donations completed 2: total number of donations set as goal */ |
@@ -126,11 +125,11 @@ discard block |
||
| 126 | 125 | <?php endif; ?> |
| 127 | 126 | |
| 128 | 127 | |
| 129 | - <?php if ( ! empty( $show_bar ) ) : ?> |
|
| 128 | + <?php if ( ! empty($show_bar)) : ?> |
|
| 130 | 129 | <div class="give-progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" |
| 131 | - aria-valuenow="<?php echo esc_attr( $progress ); ?>"> |
|
| 132 | - <span style="width: <?php echo esc_attr( $progress ); ?>%;<?php if ( ! empty( $color ) ) { |
|
| 133 | - echo 'background-color:' . $color; |
|
| 130 | + aria-valuenow="<?php echo esc_attr($progress); ?>"> |
|
| 131 | + <span style="width: <?php echo esc_attr($progress); ?>%;<?php if ( ! empty($color)) { |
|
| 132 | + echo 'background-color:'.$color; |
|
| 134 | 133 | } ?>"></span> |
| 135 | 134 | </div><!-- /.give-progress-bar --> |
| 136 | 135 | <?php endif; ?> |
@@ -4,17 +4,17 @@ discard block |
||
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | |
| 7 | -if ( ! is_user_logged_in() ) { |
|
| 7 | +if ( ! is_user_logged_in()) { |
|
| 8 | 8 | |
| 9 | - if ( ! empty( $_GET['payment_key'] ) ) { |
|
| 10 | - $give_login_redirect = add_query_arg( 'payment_key', give_clean( $_GET['payment_key'] ) , give_get_history_page_uri() ); |
|
| 9 | + if ( ! empty($_GET['payment_key'])) { |
|
| 10 | + $give_login_redirect = add_query_arg('payment_key', give_clean($_GET['payment_key']), give_get_history_page_uri()); |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | // Show any error messages after form submission |
| 14 | - Give()->notices->render_frontend_notices( 0 ); ?> |
|
| 14 | + Give()->notices->render_frontend_notices(0); ?> |
|
| 15 | 15 | <form id="give-login-form" class="give-form" action="" method="post"> |
| 16 | 16 | <fieldset> |
| 17 | - <legend><?php _e( 'Log into Your Account', 'give' ); ?></legend> |
|
| 17 | + <legend><?php _e('Log into Your Account', 'give'); ?></legend> |
|
| 18 | 18 | <?php |
| 19 | 19 | /** |
| 20 | 20 | * Fires in the login shortcode, before the login fields. |
@@ -23,27 +23,27 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @since 1.0 |
| 25 | 25 | */ |
| 26 | - do_action( 'give_login_fields_before' ); |
|
| 26 | + do_action('give_login_fields_before'); |
|
| 27 | 27 | ?> |
| 28 | 28 | <div class="give-login-username give-login"> |
| 29 | - <label for="give_user_login"><?php _e( 'Username', 'give' ); ?></label> |
|
| 29 | + <label for="give_user_login"><?php _e('Username', 'give'); ?></label> |
|
| 30 | 30 | <input name="give_user_login" id="give_user_login" class="give-required give-input" type="text" required aria-required="true" /> |
| 31 | 31 | </div> |
| 32 | 32 | |
| 33 | 33 | <div class="give-login-password give-login"> |
| 34 | - <label for="give_user_pass"><?php _e( 'Password', 'give' ); ?></label> |
|
| 34 | + <label for="give_user_pass"><?php _e('Password', 'give'); ?></label> |
|
| 35 | 35 | <input name="give_user_pass" id="give_user_pass" class="give-password give-required give-input" type="password" required aria-required="true" /> |
| 36 | 36 | </div> |
| 37 | 37 | |
| 38 | 38 | <div class="give-login-submit give-login"> |
| 39 | - <input type="hidden" name="give_login_redirect" value="<?php echo esc_url( $give_login_redirect ); ?>" /> |
|
| 40 | - <input type="hidden" name="give_login_nonce" value="<?php echo wp_create_nonce( 'give-login-nonce' ); ?>" /> |
|
| 39 | + <input type="hidden" name="give_login_redirect" value="<?php echo esc_url($give_login_redirect); ?>" /> |
|
| 40 | + <input type="hidden" name="give_login_nonce" value="<?php echo wp_create_nonce('give-login-nonce'); ?>" /> |
|
| 41 | 41 | <input type="hidden" name="give_action" value="user_login" /> |
| 42 | - <input id="give_login_submit" type="submit" class="give_submit" value="<?php _e( 'Log In', 'give' ); ?>" /> |
|
| 42 | + <input id="give_login_submit" type="submit" class="give_submit" value="<?php _e('Log In', 'give'); ?>" /> |
|
| 43 | 43 | </div> |
| 44 | 44 | |
| 45 | 45 | <div class="give-lost-password give-login"> |
| 46 | - <a href="<?php echo wp_lostpassword_url(); ?>"><?php _e( 'Reset Password', 'give' ); ?></a> |
|
| 46 | + <a href="<?php echo wp_lostpassword_url(); ?>"><?php _e('Reset Password', 'give'); ?></a> |
|
| 47 | 47 | </div> |
| 48 | 48 | <?php |
| 49 | 49 | /** |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @since 1.0 |
| 55 | 55 | */ |
| 56 | - do_action( 'give_login_fields_after' ); |
|
| 56 | + do_action('give_login_fields_after'); |
|
| 57 | 57 | ?> |
| 58 | 58 | </fieldset> |
| 59 | 59 | </form> |
| 60 | -<?php } elseif( isset( $_GET['give-login-success'] ) && true === (bool) $_GET['give-login-success'] ) { ?> |
|
| 61 | - <?php Give()->notices->print_frontend_notice( apply_filters('give_successful_login_message', __( 'Login successful. Welcome!', 'give' )), true, 'success' ); ?> |
|
| 60 | +<?php } elseif (isset($_GET['give-login-success']) && true === (bool) $_GET['give-login-success']) { ?> |
|
| 61 | + <?php Give()->notices->print_frontend_notice(apply_filters('give_successful_login_message', __('Login successful. Welcome!', 'give')), true, 'success'); ?> |
|
| 62 | 62 | <?php } else { ?> |
| 63 | - <?php Give()->notices->print_frontend_notice( apply_filters('give_already_logged_in_message', sprintf( __( 'You are already logged in to the site. <a href="%s">Click here</a> to logout.', 'give' ), esc_url( $give_logout_redirect ) ) ), true, 'warning' ); ?> |
|
| 63 | + <?php Give()->notices->print_frontend_notice(apply_filters('give_already_logged_in_message', sprintf(__('You are already logged in to the site. <a href="%s">Click here</a> to logout.', 'give'), esc_url($give_logout_redirect))), true, 'warning'); ?> |
|
| 64 | 64 | <?php } ?> |
| 65 | 65 | \ No newline at end of file |
@@ -6,25 +6,25 @@ discard block |
||
| 6 | 6 | global $give_receipt_args, $payment; |
| 7 | 7 | |
| 8 | 8 | // Validation: Ensure $payment var is set. |
| 9 | -if ( empty( $payment ) ) { |
|
| 10 | - $payment = ! empty( $give_receipt_args['id'] ) ? get_post( $give_receipt_args['id'] ) : 0; |
|
| 9 | +if (empty($payment)) { |
|
| 10 | + $payment = ! empty($give_receipt_args['id']) ? get_post($give_receipt_args['id']) : 0; |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | // Double-Validation: Check for $payment global. |
| 14 | -if ( empty( $payment ) ) { |
|
| 15 | - Give()->notices->print_frontend_notice( __( 'The specified receipt ID appears to be invalid.', 'give' ) ); |
|
| 14 | +if (empty($payment)) { |
|
| 15 | + Give()->notices->print_frontend_notice(__('The specified receipt ID appears to be invalid.', 'give')); |
|
| 16 | 16 | |
| 17 | 17 | return; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | $donation_id = $payment->ID; |
| 21 | -$form_id = give_get_payment_meta( $donation_id, '_give_payment_form_id', true ); |
|
| 22 | -$meta = give_get_payment_meta( $donation_id ); |
|
| 23 | -$donation = give_get_donation_form_title( $donation_id ); |
|
| 24 | -$user = give_get_payment_meta_user_info( $donation_id ); |
|
| 25 | -$email = give_get_payment_user_email( $donation_id ); |
|
| 21 | +$form_id = give_get_payment_meta($donation_id, '_give_payment_form_id', true); |
|
| 22 | +$meta = give_get_payment_meta($donation_id); |
|
| 23 | +$donation = give_get_donation_form_title($donation_id); |
|
| 24 | +$user = give_get_payment_meta_user_info($donation_id); |
|
| 25 | +$email = give_get_payment_user_email($donation_id); |
|
| 26 | 26 | $status = $payment->post_status; |
| 27 | -$status_label = give_get_payment_status( $payment, true ); |
|
| 27 | +$status_label = give_get_payment_status($payment, true); |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Generate Donation Receipt Arguments. |
@@ -35,50 +35,50 @@ discard block |
||
| 35 | 35 | * @since 1.8.8 |
| 36 | 36 | */ |
| 37 | 37 | $give_receipt_args['donation_receipt']['donor'] = array( |
| 38 | - 'name' => __( 'Donor', 'give' ), |
|
| 39 | - 'value' => $user['first_name'] . ' ' . $user['last_name'], |
|
| 38 | + 'name' => __('Donor', 'give'), |
|
| 39 | + 'value' => $user['first_name'].' '.$user['last_name'], |
|
| 40 | 40 | 'display' => $give_receipt_args['donor'], |
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | 43 | $give_receipt_args['donation_receipt']['date'] = array( |
| 44 | - 'name' => __( 'Date', 'give' ), |
|
| 45 | - 'value' => date_i18n( give_date_format(), strtotime( $meta['date'] ) ), |
|
| 44 | + 'name' => __('Date', 'give'), |
|
| 45 | + 'value' => date_i18n(give_date_format(), strtotime($meta['date'])), |
|
| 46 | 46 | 'display' => $give_receipt_args['date'], |
| 47 | 47 | ); |
| 48 | 48 | |
| 49 | 49 | $give_receipt_args['donation_receipt']['total_donation'] = array( |
| 50 | - 'name' => __( 'Total Donation', 'give' ), |
|
| 51 | - 'value' => give_donation_amount( $donation_id, array( 'currency' => true, 'amount' => true, 'type' => 'receipt' ) ), |
|
| 50 | + 'name' => __('Total Donation', 'give'), |
|
| 51 | + 'value' => give_donation_amount($donation_id, array('currency' => true, 'amount' => true, 'type' => 'receipt')), |
|
| 52 | 52 | 'display' => $give_receipt_args['price'], |
| 53 | 53 | ); |
| 54 | 54 | |
| 55 | 55 | $give_receipt_args['donation_receipt']['donation'] = array( |
| 56 | - 'name' => __( 'Donation', 'give' ), |
|
| 56 | + 'name' => __('Donation', 'give'), |
|
| 57 | 57 | 'value' => $donation, |
| 58 | 58 | 'display' => true, |
| 59 | 59 | ); |
| 60 | 60 | |
| 61 | 61 | $give_receipt_args['donation_receipt']['donation_status'] = array( |
| 62 | - 'name' => __( 'Donation Status', 'give' ), |
|
| 63 | - 'value' => esc_attr( $status_label ), |
|
| 62 | + 'name' => __('Donation Status', 'give'), |
|
| 63 | + 'value' => esc_attr($status_label), |
|
| 64 | 64 | 'display' => $give_receipt_args['payment_status'], |
| 65 | 65 | ); |
| 66 | 66 | |
| 67 | 67 | $give_receipt_args['donation_receipt']['donation_id'] = array( |
| 68 | - 'name' => __( 'Donation ID', 'give' ), |
|
| 68 | + 'name' => __('Donation ID', 'give'), |
|
| 69 | 69 | 'value' => $donation_id, |
| 70 | 70 | 'display' => $give_receipt_args['payment_id'], |
| 71 | 71 | ); |
| 72 | 72 | |
| 73 | 73 | $give_receipt_args['donation_receipt']['payment_key'] = array( |
| 74 | - 'name' => __( 'Payment Key', 'give' ), |
|
| 75 | - 'value' => get_post_meta( $donation_id, '_give_payment_purchase_key', true ), |
|
| 74 | + 'name' => __('Payment Key', 'give'), |
|
| 75 | + 'value' => get_post_meta($donation_id, '_give_payment_purchase_key', true), |
|
| 76 | 76 | 'display' => $give_receipt_args['payment_key'], |
| 77 | 77 | ); |
| 78 | 78 | |
| 79 | 79 | $give_receipt_args['donation_receipt']['payment_method'] = array( |
| 80 | - 'name' => __( 'Payment Method', 'give' ), |
|
| 81 | - 'value' => give_get_gateway_checkout_label( give_get_payment_gateway( $donation_id ) ), |
|
| 80 | + 'name' => __('Payment Method', 'give'), |
|
| 81 | + 'value' => give_get_gateway_checkout_label(give_get_payment_gateway($donation_id)), |
|
| 82 | 82 | 'display' => $give_receipt_args['payment_method'], |
| 83 | 83 | ); |
| 84 | 84 | |
@@ -93,10 +93,10 @@ discard block |
||
| 93 | 93 | * |
| 94 | 94 | * @since 1.8.8 |
| 95 | 95 | */ |
| 96 | -$give_receipt_args['donation_receipt'] = apply_filters( 'give_donation_receipt_args', $give_receipt_args['donation_receipt'], $donation_id, $form_id ); |
|
| 96 | +$give_receipt_args['donation_receipt'] = apply_filters('give_donation_receipt_args', $give_receipt_args['donation_receipt'], $donation_id, $form_id); |
|
| 97 | 97 | |
| 98 | 98 | // When the donation were made through offline donation, We won't show receipt and payment status though. |
| 99 | -if ( 'offline' === give_get_payment_gateway( $payment->ID ) && 'pending' === $status ) { |
|
| 99 | +if ('offline' === give_get_payment_gateway($payment->ID) && 'pending' === $status) { |
|
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * Before the offline donation receipt content starts. |
@@ -106,13 +106,13 @@ discard block |
||
| 106 | 106 | * @param Give_Payment $payment Donation payment object. |
| 107 | 107 | * @param array $give_receipt_args Receipt Arguments. |
| 108 | 108 | */ |
| 109 | - do_action( 'give_receipt_before_offline_payment', $payment, $give_receipt_args ); |
|
| 109 | + do_action('give_receipt_before_offline_payment', $payment, $give_receipt_args); |
|
| 110 | 110 | ?> |
| 111 | - <h2><?php echo apply_filters( 'give_receipt_offline_payment_heading', __( 'Your Donation is Almost Complete!', 'give' ) ); ?></h2> |
|
| 112 | - <div id="give_donation_receipt" class="<?php echo esc_attr( apply_filters( 'give_receipt_offline_payment_classes', 'give_receipt_offline_payment' ) ); ?>"> |
|
| 111 | + <h2><?php echo apply_filters('give_receipt_offline_payment_heading', __('Your Donation is Almost Complete!', 'give')); ?></h2> |
|
| 112 | + <div id="give_donation_receipt" class="<?php echo esc_attr(apply_filters('give_receipt_offline_payment_classes', 'give_receipt_offline_payment')); ?>"> |
|
| 113 | 113 | <?php |
| 114 | 114 | // Instruction for offline donation. |
| 115 | - $offline_instruction = give_get_offline_payment_instruction( $form_id, true ); |
|
| 115 | + $offline_instruction = give_get_offline_payment_instruction($form_id, true); |
|
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | 118 | * Instruction for the offline donation. |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * @param Give_Payment $payment Payment object. |
| 124 | 124 | * @param integer $form_id Donation form id. |
| 125 | 125 | */ |
| 126 | - echo apply_filters( 'give_receipt_offline_payment_instruction', $offline_instruction, $payment, $form_id ); |
|
| 126 | + echo apply_filters('give_receipt_offline_payment_instruction', $offline_instruction, $payment, $form_id); |
|
| 127 | 127 | ?> |
| 128 | 128 | </div> |
| 129 | 129 | <?php |
@@ -135,52 +135,52 @@ discard block |
||
| 135 | 135 | * @param Give_Payment $payment Donation payment object. |
| 136 | 136 | * @param array $give_receipt_args Receipt Arguments. |
| 137 | 137 | */ |
| 138 | - do_action( 'give_receipt_after_offline_payment', $payment, $give_receipt_args ); |
|
| 138 | + do_action('give_receipt_after_offline_payment', $payment, $give_receipt_args); |
|
| 139 | 139 | |
| 140 | 140 | return; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | // Show payment status notice based on shortcode attribute. |
| 144 | -if ( filter_var( $give_receipt_args['status_notice'], FILTER_VALIDATE_BOOLEAN ) ) { |
|
| 144 | +if (filter_var($give_receipt_args['status_notice'], FILTER_VALIDATE_BOOLEAN)) { |
|
| 145 | 145 | $notice_message = ''; |
| 146 | 146 | $notice_type = 'warning'; |
| 147 | 147 | |
| 148 | - switch ( $status ) { |
|
| 148 | + switch ($status) { |
|
| 149 | 149 | case 'publish': |
| 150 | - $notice_message = __( 'Payment Complete: Thank you for your donation.', 'give' ); |
|
| 150 | + $notice_message = __('Payment Complete: Thank you for your donation.', 'give'); |
|
| 151 | 151 | $notice_type = 'success'; |
| 152 | 152 | break; |
| 153 | 153 | case 'pending': |
| 154 | - $notice_message = __( 'Payment Pending: Your donation is currently processing.', 'give' ); |
|
| 154 | + $notice_message = __('Payment Pending: Your donation is currently processing.', 'give'); |
|
| 155 | 155 | $notice_type = 'warning'; |
| 156 | 156 | break; |
| 157 | 157 | case 'refunded': |
| 158 | - $notice_message = __( 'Payment Refunded: Your donation has been refunded.', 'give' ); |
|
| 158 | + $notice_message = __('Payment Refunded: Your donation has been refunded.', 'give'); |
|
| 159 | 159 | $notice_type = 'warning'; |
| 160 | 160 | break; |
| 161 | 161 | case 'preapproval': |
| 162 | - $notice_message = __( 'Payment Preapproved: Thank you for your donation.', 'give' ); |
|
| 162 | + $notice_message = __('Payment Preapproved: Thank you for your donation.', 'give'); |
|
| 163 | 163 | $notice_type = 'warning'; |
| 164 | 164 | break; |
| 165 | 165 | case 'failed': |
| 166 | - $notice_message = __( 'Payment Failed: Please contact the site owner for assistance.', 'give' ); |
|
| 166 | + $notice_message = __('Payment Failed: Please contact the site owner for assistance.', 'give'); |
|
| 167 | 167 | $notice_type = 'error'; |
| 168 | 168 | break; |
| 169 | 169 | case 'cancelled': |
| 170 | - $notice_message = __( 'Payment Cancelled: Your donation has been cancelled.', 'give' ); |
|
| 170 | + $notice_message = __('Payment Cancelled: Your donation has been cancelled.', 'give'); |
|
| 171 | 171 | $notice_type = 'error'; |
| 172 | 172 | break; |
| 173 | 173 | case 'abandoned': |
| 174 | - $notice_message = __( 'Payment Abandoned: This donation has not been completed.', 'give' ); |
|
| 174 | + $notice_message = __('Payment Abandoned: This donation has not been completed.', 'give'); |
|
| 175 | 175 | $notice_type = 'error'; |
| 176 | 176 | break; |
| 177 | 177 | case 'revoked': |
| 178 | - $notice_message = __( 'Payment Revoked: Please contact the site owner for assistance.', 'give' ); |
|
| 178 | + $notice_message = __('Payment Revoked: Please contact the site owner for assistance.', 'give'); |
|
| 179 | 179 | $notice_type = 'error'; |
| 180 | 180 | break; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if ( ! empty( $notice_message ) ) { |
|
| 183 | + if ( ! empty($notice_message)) { |
|
| 184 | 184 | /** |
| 185 | 185 | * Filters payment status notice for receipts. |
| 186 | 186 | * |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * @param string $status Payment status. |
| 196 | 196 | * @param array $meta Array of meta data related to the payment. |
| 197 | 197 | */ |
| 198 | - echo apply_filters( 'give_receipt_status_notice', Give()->notices->print_frontend_notice( $notice_message, false, $notice_type ), $id, $status, $meta ); |
|
| 198 | + echo apply_filters('give_receipt_status_notice', Give()->notices->print_frontend_notice($notice_message, false, $notice_type), $id, $status, $meta); |
|
| 199 | 199 | } |
| 200 | 200 | }// End if(). |
| 201 | 201 | |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | * @param object $payment The payment object. |
| 210 | 210 | * @param array $give_receipt_args Receipt_argument. |
| 211 | 211 | */ |
| 212 | -do_action( 'give_payment_receipt_before_table', $payment, $give_receipt_args ); |
|
| 212 | +do_action('give_payment_receipt_before_table', $payment, $give_receipt_args); |
|
| 213 | 213 | ?> |
| 214 | 214 | |
| 215 | 215 | <table id="give_donation_receipt" class="give-table"> |
@@ -225,11 +225,11 @@ discard block |
||
| 225 | 225 | * @param object $payment The payment object. |
| 226 | 226 | * @param array $give_receipt_args Receipt_argument. |
| 227 | 227 | */ |
| 228 | - do_action( 'give_payment_receipt_header_before', $payment, $give_receipt_args ); |
|
| 228 | + do_action('give_payment_receipt_header_before', $payment, $give_receipt_args); |
|
| 229 | 229 | ?> |
| 230 | 230 | <tr> |
| 231 | 231 | <th scope="colgroup" colspan="2"> |
| 232 | - <span class="give-receipt-thead-text"><?php esc_html_e( 'Donation Receipt', 'give' ) ?></span> |
|
| 232 | + <span class="give-receipt-thead-text"><?php esc_html_e('Donation Receipt', 'give') ?></span> |
|
| 233 | 233 | </th> |
| 234 | 234 | </tr> |
| 235 | 235 | <?php |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * @param object $payment The payment object. |
| 244 | 244 | * @param array $give_receipt_args Receipt_argument. |
| 245 | 245 | */ |
| 246 | - do_action( 'give_payment_receipt_header_after', $payment, $give_receipt_args ); |
|
| 246 | + do_action('give_payment_receipt_header_after', $payment, $give_receipt_args); |
|
| 247 | 247 | ?> |
| 248 | 248 | </thead> |
| 249 | 249 | |
@@ -259,11 +259,11 @@ discard block |
||
| 259 | 259 | * @param object $payment The payment object. |
| 260 | 260 | * @param array $give_receipt_args Receipt_argument. |
| 261 | 261 | */ |
| 262 | - do_action( 'give_payment_receipt_before', $payment, $give_receipt_args ); |
|
| 262 | + do_action('give_payment_receipt_before', $payment, $give_receipt_args); |
|
| 263 | 263 | ?> |
| 264 | 264 | |
| 265 | - <?php foreach ( $give_receipt_args['donation_receipt'] as $receipt_item ) { ?> |
|
| 266 | - <?php if ( filter_var( $receipt_item['display'], FILTER_VALIDATE_BOOLEAN ) ) : ?> |
|
| 265 | + <?php foreach ($give_receipt_args['donation_receipt'] as $receipt_item) { ?> |
|
| 266 | + <?php if (filter_var($receipt_item['display'], FILTER_VALIDATE_BOOLEAN)) : ?> |
|
| 267 | 267 | <tr> |
| 268 | 268 | <td scope="row"><strong><?php echo $receipt_item['name']; ?></strong></td> |
| 269 | 269 | <td><?php echo $receipt_item['value']; ?></td> |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * @param object $payment The payment object. |
| 283 | 283 | * @param array $give_receipt_args Receipt_argument. |
| 284 | 284 | */ |
| 285 | - do_action( 'give_payment_receipt_after', $payment, $give_receipt_args ); |
|
| 285 | + do_action('give_payment_receipt_after', $payment, $give_receipt_args); |
|
| 286 | 286 | ?> |
| 287 | 287 | </tbody> |
| 288 | 288 | </table> |
@@ -298,5 +298,5 @@ discard block |
||
| 298 | 298 | * @param object $payment The payment object. |
| 299 | 299 | * @param array $give_receipt_args Receipt_argument. |
| 300 | 300 | */ |
| 301 | -do_action( 'give_payment_receipt_after_table', $payment, $give_receipt_args ); |
|
| 301 | +do_action('give_payment_receipt_after_table', $payment, $give_receipt_args); |
|
| 302 | 302 | ?> |
@@ -10,61 +10,61 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
| 13 | +if ( ! defined('WP_UNINSTALL_PLUGIN')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // Load Give file. |
| 18 | -include_once( 'give.php' ); |
|
| 18 | +include_once('give.php'); |
|
| 19 | 19 | |
| 20 | 20 | global $wpdb, $wp_roles; |
| 21 | 21 | |
| 22 | 22 | |
| 23 | -if ( give_is_setting_enabled( give_get_option( 'uninstall_on_delete' ) ) ) { |
|
| 23 | +if (give_is_setting_enabled(give_get_option('uninstall_on_delete'))) { |
|
| 24 | 24 | |
| 25 | 25 | // Delete All the Custom Post Types. |
| 26 | - $give_taxonomies = array( 'form_category', 'form_tag' ); |
|
| 27 | - $give_post_types = array( 'give_forms', 'give_payment' ); |
|
| 28 | - foreach ( $give_post_types as $post_type ) { |
|
| 26 | + $give_taxonomies = array('form_category', 'form_tag'); |
|
| 27 | + $give_post_types = array('give_forms', 'give_payment'); |
|
| 28 | + foreach ($give_post_types as $post_type) { |
|
| 29 | 29 | |
| 30 | - $give_taxonomies = array_merge( $give_taxonomies, get_object_taxonomies( $post_type ) ); |
|
| 31 | - $items = get_posts( array( |
|
| 30 | + $give_taxonomies = array_merge($give_taxonomies, get_object_taxonomies($post_type)); |
|
| 31 | + $items = get_posts(array( |
|
| 32 | 32 | 'post_type' => $post_type, |
| 33 | 33 | 'post_status' => 'any', |
| 34 | - 'numberposts' => - 1, |
|
| 34 | + 'numberposts' => -1, |
|
| 35 | 35 | 'fields' => 'ids', |
| 36 | - ) ); |
|
| 36 | + )); |
|
| 37 | 37 | |
| 38 | - if ( $items ) { |
|
| 39 | - foreach ( $items as $item ) { |
|
| 40 | - wp_delete_post( $item, true ); |
|
| 38 | + if ($items) { |
|
| 39 | + foreach ($items as $item) { |
|
| 40 | + wp_delete_post($item, true); |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // Delete All the Terms & Taxonomies. |
| 46 | - foreach ( array_unique( array_filter( $give_taxonomies ) ) as $taxonomy ) { |
|
| 46 | + foreach (array_unique(array_filter($give_taxonomies)) as $taxonomy) { |
|
| 47 | 47 | |
| 48 | - $terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy ) ); |
|
| 48 | + $terms = $wpdb->get_results($wpdb->prepare("SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy)); |
|
| 49 | 49 | |
| 50 | 50 | // Delete Terms. |
| 51 | - if ( $terms ) { |
|
| 52 | - foreach ( $terms as $term ) { |
|
| 53 | - $wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $term->term_taxonomy_id ) ); |
|
| 54 | - $wpdb->delete( $wpdb->terms, array( 'term_id' => $term->term_id ) ); |
|
| 51 | + if ($terms) { |
|
| 52 | + foreach ($terms as $term) { |
|
| 53 | + $wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $term->term_taxonomy_id)); |
|
| 54 | + $wpdb->delete($wpdb->terms, array('term_id' => $term->term_id)); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // Delete Taxonomies. |
| 59 | - $wpdb->delete( $wpdb->term_taxonomy, array( 'taxonomy' => $taxonomy ), array( '%s' ) ); |
|
| 59 | + $wpdb->delete($wpdb->term_taxonomy, array('taxonomy' => $taxonomy), array('%s')); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // Delete the Plugin Pages. |
| 63 | - $give_created_pages = array( 'success_page', 'failure_page', 'history_page' ); |
|
| 64 | - foreach ( $give_created_pages as $p ) { |
|
| 65 | - $page = give_get_option( $p, false ); |
|
| 66 | - if ( $page ) { |
|
| 67 | - wp_delete_post( $page, true ); |
|
| 63 | + $give_created_pages = array('success_page', 'failure_page', 'history_page'); |
|
| 64 | + foreach ($give_created_pages as $p) { |
|
| 65 | + $page = give_get_option($p, false); |
|
| 66 | + if ($page) { |
|
| 67 | + wp_delete_post($page, true); |
|
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
@@ -73,26 +73,26 @@ discard block |
||
| 73 | 73 | Give()->roles->remove_caps(); |
| 74 | 74 | |
| 75 | 75 | // Delete the Roles. |
| 76 | - $give_roles = array( 'give_manager', 'give_accountant', 'give_worker', 'give_donor' ); |
|
| 77 | - foreach ( $give_roles as $role ) { |
|
| 78 | - remove_role( $role ); |
|
| 76 | + $give_roles = array('give_manager', 'give_accountant', 'give_worker', 'give_donor'); |
|
| 77 | + foreach ($give_roles as $role) { |
|
| 78 | + remove_role($role); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | // Remove all database tables. |
| 82 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_donors' ); |
|
| 83 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_donormeta' ); |
|
| 84 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customers' ); |
|
| 85 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customermeta' ); |
|
| 86 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_paymentmeta' ); |
|
| 87 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_formmeta' ); |
|
| 88 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_logs' ); |
|
| 89 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_logmeta' ); |
|
| 82 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_donors'); |
|
| 83 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_donormeta'); |
|
| 84 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customers'); |
|
| 85 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customermeta'); |
|
| 86 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_paymentmeta'); |
|
| 87 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_formmeta'); |
|
| 88 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_logs'); |
|
| 89 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_logmeta'); |
|
| 90 | 90 | |
| 91 | 91 | // Cleanup Cron Events. |
| 92 | - wp_clear_scheduled_hook( 'give_daily_scheduled_events' ); |
|
| 93 | - wp_clear_scheduled_hook( 'give_weekly_scheduled_events' ); |
|
| 94 | - wp_clear_scheduled_hook( 'give_daily_cron' ); |
|
| 95 | - wp_clear_scheduled_hook( 'give_weekly_cron' ); |
|
| 92 | + wp_clear_scheduled_hook('give_daily_scheduled_events'); |
|
| 93 | + wp_clear_scheduled_hook('give_weekly_scheduled_events'); |
|
| 94 | + wp_clear_scheduled_hook('give_daily_cron'); |
|
| 95 | + wp_clear_scheduled_hook('give_weekly_cron'); |
|
| 96 | 96 | |
| 97 | 97 | // Get all options. |
| 98 | 98 | $give_option_names = $wpdb->get_col( |
@@ -102,16 +102,16 @@ discard block |
||
| 102 | 102 | ) |
| 103 | 103 | ); |
| 104 | 104 | |
| 105 | - if ( ! empty( $give_option_names ) ) { |
|
| 105 | + if ( ! empty($give_option_names)) { |
|
| 106 | 106 | // Convert option name to transient or option name. |
| 107 | 107 | $new_give_option_names = array(); |
| 108 | 108 | |
| 109 | 109 | // Delete all the Plugin Options. |
| 110 | - foreach ( $give_option_names as $option ) { |
|
| 111 | - if ( false !== strpos( $option, 'give_cache' ) ) { |
|
| 112 | - Give_Cache::delete( $option ); |
|
| 110 | + foreach ($give_option_names as $option) { |
|
| 111 | + if (false !== strpos($option, 'give_cache')) { |
|
| 112 | + Give_Cache::delete($option); |
|
| 113 | 113 | } else { |
| 114 | - delete_option( $option ); |
|
| 114 | + delete_option($option); |
|
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -10,11 +10,11 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if access directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | -if ( ! class_exists( 'Give_New_Donor_Register_Email' ) ) : |
|
| 17 | +if ( ! class_exists('Give_New_Donor_Register_Email')) : |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Give_New_Donor_Register_Email |
@@ -31,34 +31,34 @@ discard block |
||
| 31 | 31 | * @since 2.0 |
| 32 | 32 | */ |
| 33 | 33 | public function init() { |
| 34 | - $this->load( array( |
|
| 34 | + $this->load(array( |
|
| 35 | 35 | 'id' => 'new-donor-register', |
| 36 | - 'label' => __( 'New User Registration', 'give' ), |
|
| 37 | - 'description' => __( 'Sent to designated recipient(s) when a new user registers on the site via a donation form.', 'give' ), |
|
| 36 | + 'label' => __('New User Registration', 'give'), |
|
| 37 | + 'description' => __('Sent to designated recipient(s) when a new user registers on the site via a donation form.', 'give'), |
|
| 38 | 38 | 'has_recipient_field' => true, |
| 39 | 39 | 'notification_status' => 'enabled', |
| 40 | 40 | 'has_preview_header' => true, |
| 41 | - 'email_tag_context' => array( 'donor', 'general' ), |
|
| 41 | + 'email_tag_context' => array('donor', 'general'), |
|
| 42 | 42 | 'form_metabox_setting' => false, |
| 43 | 43 | 'default_email_subject' => sprintf( |
| 44 | 44 | /* translators: %s: site name */ |
| 45 | - esc_attr__( '[%s] New User Registration', 'give' ), |
|
| 46 | - get_bloginfo( 'name' ) |
|
| 45 | + esc_attr__('[%s] New User Registration', 'give'), |
|
| 46 | + get_bloginfo('name') |
|
| 47 | 47 | ), |
| 48 | 48 | 'default_email_message' => $this->get_default_email_message(), |
| 49 | - ) ); |
|
| 49 | + )); |
|
| 50 | 50 | |
| 51 | 51 | // Setup action hook. |
| 52 | 52 | add_action( |
| 53 | 53 | "give_{$this->config['id']}_email_notification", |
| 54 | - array( $this, 'setup_email_notification' ), |
|
| 54 | + array($this, 'setup_email_notification'), |
|
| 55 | 55 | 10, |
| 56 | 56 | 2 |
| 57 | 57 | ); |
| 58 | 58 | |
| 59 | 59 | add_filter( |
| 60 | 60 | 'give_email_preview_header', |
| 61 | - array( $this, 'email_preview_header' ), |
|
| 61 | + array($this, 'email_preview_header'), |
|
| 62 | 62 | 10, |
| 63 | 63 | 2 |
| 64 | 64 | ); |
@@ -73,9 +73,9 @@ discard block |
||
| 73 | 73 | * @return string |
| 74 | 74 | */ |
| 75 | 75 | function get_default_email_message() { |
| 76 | - $message = esc_attr__( 'New user registration on your site {sitename}:', 'give' ) . "\r\n\r\n"; |
|
| 77 | - $message .= esc_attr__( 'Username: {username}', 'give' ) . "\r\n\r\n"; |
|
| 78 | - $message .= esc_attr__( 'Email: {user_email}', 'give' ) . "\r\n"; |
|
| 76 | + $message = esc_attr__('New user registration on your site {sitename}:', 'give')."\r\n\r\n"; |
|
| 77 | + $message .= esc_attr__('Username: {username}', 'give')."\r\n\r\n"; |
|
| 78 | + $message .= esc_attr__('Email: {user_email}', 'give')."\r\n"; |
|
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * Filter the default email message |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @since 2.0 |
| 96 | 96 | */ |
| 97 | 97 | public function setup_email_data() { |
| 98 | - Give()->emails->__set( 'heading', esc_html__( 'New User Registration', 'give' ) ); |
|
| 98 | + Give()->emails->__set('heading', esc_html__('New User Registration', 'give')); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | |
@@ -110,12 +110,12 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @return string |
| 112 | 112 | */ |
| 113 | - public function setup_email_notification( $user_id, $user_data ) { |
|
| 113 | + public function setup_email_notification($user_id, $user_data) { |
|
| 114 | 114 | $this->setup_email_data(); |
| 115 | 115 | |
| 116 | - $this->send_email_notification( array( |
|
| 116 | + $this->send_email_notification(array( |
|
| 117 | 117 | 'user_id' => $user_id, |
| 118 | - ) ); |
|
| 118 | + )); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | |
@@ -129,42 +129,42 @@ discard block |
||
| 129 | 129 | * @param Give_New_Donor_Register_Email $email |
| 130 | 130 | * @return string |
| 131 | 131 | */ |
| 132 | - public function email_preview_header( $email_preview_header, $email ) { |
|
| 132 | + public function email_preview_header($email_preview_header, $email) { |
|
| 133 | 133 | // Bailout. |
| 134 | - if ( $this->config['id'] !== $email->config['id'] ) { |
|
| 134 | + if ($this->config['id'] !== $email->config['id']) { |
|
| 135 | 135 | return $email_preview_header; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | // Payment receipt switcher |
| 139 | - $user_id = give_check_variable( give_clean( $_GET ), 'isset', 0, 'user_id' ); |
|
| 139 | + $user_id = give_check_variable(give_clean($_GET), 'isset', 0, 'user_id'); |
|
| 140 | 140 | |
| 141 | 141 | // Get payments. |
| 142 | 142 | $donors = new Give_API(); |
| 143 | - $donors = give_check_variable( $donors->get_donors(), 'empty', array(), 'donors' ); |
|
| 143 | + $donors = give_check_variable($donors->get_donors(), 'empty', array(), 'donors'); |
|
| 144 | 144 | $options = array(); |
| 145 | 145 | |
| 146 | 146 | // Default option. |
| 147 | - $options[0] = esc_html__( 'No donor(s) found.', 'give' ); |
|
| 147 | + $options[0] = esc_html__('No donor(s) found.', 'give'); |
|
| 148 | 148 | |
| 149 | 149 | // Provide nice human readable options. |
| 150 | - if ( $donors ) { |
|
| 151 | - $options[0] = esc_html__( '- Select a donor -', 'give' ); |
|
| 152 | - foreach ( $donors as $donor ) { |
|
| 150 | + if ($donors) { |
|
| 151 | + $options[0] = esc_html__('- Select a donor -', 'give'); |
|
| 152 | + foreach ($donors as $donor) { |
|
| 153 | 153 | // Exclude customers for which wp user not exist. |
| 154 | - if ( ! $donor['info']['user_id'] ) { |
|
| 154 | + if ( ! $donor['info']['user_id']) { |
|
| 155 | 155 | continue; |
| 156 | 156 | } |
| 157 | - $options[ $donor['info']['user_id'] ] = esc_html( '#' . $donor['info']['donor_id'] . ' - ' . $donor['info']['email'] ); |
|
| 157 | + $options[$donor['info']['user_id']] = esc_html('#'.$donor['info']['donor_id'].' - '.$donor['info']['email']); |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - $request_url_data = wp_parse_url( $_SERVER['REQUEST_URI'] ); |
|
| 161 | + $request_url_data = wp_parse_url($_SERVER['REQUEST_URI']); |
|
| 162 | 162 | $query = $request_url_data['query']; |
| 163 | 163 | |
| 164 | 164 | // Remove user id query param if set from request url. |
| 165 | - $query = remove_query_arg( array( 'user_id' ), $query ); |
|
| 165 | + $query = remove_query_arg(array('user_id'), $query); |
|
| 166 | 166 | |
| 167 | - $request_url = home_url( '/?' . str_replace( '', '', $query ) ); |
|
| 167 | + $request_url = home_url('/?'.str_replace('', '', $query)); |
|
| 168 | 168 | ?> |
| 169 | 169 | <script type="text/javascript"> |
| 170 | 170 | function change_preview() { |
@@ -198,12 +198,12 @@ discard block |
||
| 198 | 198 | <div class="give_preview_email_user_id_main"> |
| 199 | 199 | |
| 200 | 200 | <label for="give_preview_email_user_id" class="give_preview_email_user_id_label"> |
| 201 | - <?php echo esc_html__( 'Preview email with a donor:', 'give' ); ?> |
|
| 201 | + <?php echo esc_html__('Preview email with a donor:', 'give'); ?> |
|
| 202 | 202 | </label> |
| 203 | 203 | |
| 204 | 204 | <?php |
| 205 | 205 | // The select field with 100 latest transactions |
| 206 | - echo Give()->html->select( array( |
|
| 206 | + echo Give()->html->select(array( |
|
| 207 | 207 | 'name' => 'preview_email_user_id', |
| 208 | 208 | 'selected' => $user_id, |
| 209 | 209 | 'id' => 'give_preview_email_user_id', |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | 'select_atts' => 'onchange="change_preview()"', |
| 214 | 214 | 'show_option_all' => false, |
| 215 | 215 | 'show_option_none' => false, |
| 216 | - ) ); |
|
| 216 | + )); |
|
| 217 | 217 | ?> |
| 218 | 218 | <!-- Closing tag--> |
| 219 | 219 | </div> |
@@ -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 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | /* @var WPDB $wpdb */ |
| 36 | 36 | global $wpdb; |
| 37 | 37 | |
| 38 | - $this->table_name = $wpdb->prefix . 'give_logs'; |
|
| 38 | + $this->table_name = $wpdb->prefix.'give_logs'; |
|
| 39 | 39 | $this->primary_key = 'ID'; |
| 40 | 40 | $this->version = '1.0'; |
| 41 | 41 | |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | * @return array Default column values. |
| 74 | 74 | */ |
| 75 | 75 | public function get_column_defaults() { |
| 76 | - $log_create_date = current_time( 'mysql', 0 ); |
|
| 77 | - $log_create_date_gmt = get_gmt_from_date( $log_create_date ); |
|
| 76 | + $log_create_date = current_time('mysql', 0); |
|
| 77 | + $log_create_date_gmt = get_gmt_from_date($log_create_date); |
|
| 78 | 78 | |
| 79 | 79 | return array( |
| 80 | 80 | 'ID' => 0, |
@@ -97,39 +97,39 @@ discard block |
||
| 97 | 97 | * |
| 98 | 98 | * @return bool|int |
| 99 | 99 | */ |
| 100 | - public function add( $data = array() ) { |
|
| 100 | + public function add($data = array()) { |
|
| 101 | 101 | // Valid table columns. |
| 102 | - $table_columns = array_keys( $this->get_columns() ); |
|
| 102 | + $table_columns = array_keys($this->get_columns()); |
|
| 103 | 103 | |
| 104 | 104 | // Filter data. |
| 105 | - foreach ( $data as $table_column => $column_data ) { |
|
| 106 | - if ( ! in_array( $table_column, $table_columns ) ) { |
|
| 107 | - unset( $data[ $table_column ] ); |
|
| 105 | + foreach ($data as $table_column => $column_data) { |
|
| 106 | + if ( ! in_array($table_column, $table_columns)) { |
|
| 107 | + unset($data[$table_column]); |
|
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | // Set default values. |
| 112 | - $current_log_data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
| 112 | + $current_log_data = wp_parse_args($data, $this->get_column_defaults()); |
|
| 113 | 113 | |
| 114 | 114 | // Log parent should be an int. |
| 115 | - $current_log_data['log_parent'] = absint( $current_log_data['log_parent'] ); |
|
| 115 | + $current_log_data['log_parent'] = absint($current_log_data['log_parent']); |
|
| 116 | 116 | |
| 117 | 117 | // Get log. |
| 118 | - $existing_log = $this->get_log_by( $current_log_data['ID'] ); |
|
| 118 | + $existing_log = $this->get_log_by($current_log_data['ID']); |
|
| 119 | 119 | |
| 120 | 120 | // Update an existing log. |
| 121 | - if ( $existing_log ) { |
|
| 121 | + if ($existing_log) { |
|
| 122 | 122 | |
| 123 | 123 | // Create new log data from existing and new log data. |
| 124 | - $current_log_data = array_merge( $current_log_data, $existing_log ); |
|
| 124 | + $current_log_data = array_merge($current_log_data, $existing_log); |
|
| 125 | 125 | |
| 126 | 126 | // Update log data. |
| 127 | - $this->update( $current_log_data['ID'], $current_log_data ); |
|
| 127 | + $this->update($current_log_data['ID'], $current_log_data); |
|
| 128 | 128 | |
| 129 | 129 | $log_id = $current_log_data['ID']; |
| 130 | 130 | |
| 131 | 131 | } else { |
| 132 | - $log_id = $this->insert( $current_log_data, 'log' ); |
|
| 132 | + $log_id = $this->insert($current_log_data, 'log'); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | return $log_id; |
@@ -147,20 +147,20 @@ discard block |
||
| 147 | 147 | * |
| 148 | 148 | * @return bool|null|array |
| 149 | 149 | */ |
| 150 | - public function get_log_by( $log_id = 0, $by = 'id' ) { |
|
| 150 | + public function get_log_by($log_id = 0, $by = 'id') { |
|
| 151 | 151 | /* @var WPDB $wpdb */ |
| 152 | 152 | global $wpdb; |
| 153 | 153 | $log = null; |
| 154 | 154 | |
| 155 | 155 | // Make sure $log_id is int. |
| 156 | - $log_id = absint( $log_id ); |
|
| 156 | + $log_id = absint($log_id); |
|
| 157 | 157 | |
| 158 | 158 | // Bailout. |
| 159 | - if ( empty( $log_id ) ) { |
|
| 159 | + if (empty($log_id)) { |
|
| 160 | 160 | return null; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - switch ( $by ) { |
|
| 163 | + switch ($by) { |
|
| 164 | 164 | case 'id': |
| 165 | 165 | $log = $wpdb->get_row( |
| 166 | 166 | $wpdb->prepare( |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | break; |
| 173 | 173 | |
| 174 | 174 | default: |
| 175 | - $log = apply_filters( "give_get_log_by_{$by}", $log, $log_id ); |
|
| 175 | + $log = apply_filters("give_get_log_by_{$by}", $log, $log_id); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | return $log; |
@@ -188,14 +188,14 @@ discard block |
||
| 188 | 188 | * |
| 189 | 189 | * @return mixed |
| 190 | 190 | */ |
| 191 | - public function get_logs( $args = array() ) { |
|
| 191 | + public function get_logs($args = array()) { |
|
| 192 | 192 | global $wpdb; |
| 193 | - $sql_query = $this->get_sql( $args ); |
|
| 193 | + $sql_query = $this->get_sql($args); |
|
| 194 | 194 | |
| 195 | 195 | // Get log. |
| 196 | - if ( ! ( $logs = Give_Cache::get( 'give_logs', true, $sql_query ) ) ) { |
|
| 197 | - $logs = $wpdb->get_results( $sql_query ); |
|
| 198 | - Give_Cache::set( 'give_logs', $logs, 3600, true, $sql_query ); |
|
| 196 | + if ( ! ($logs = Give_Cache::get('give_logs', true, $sql_query))) { |
|
| 197 | + $logs = $wpdb->get_results($sql_query); |
|
| 198 | + Give_Cache::set('give_logs', $logs, 3600, true, $sql_query); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | return $logs; |
@@ -212,21 +212,21 @@ discard block |
||
| 212 | 212 | * |
| 213 | 213 | * @return int |
| 214 | 214 | */ |
| 215 | - public function count( $args = array() ) { |
|
| 215 | + public function count($args = array()) { |
|
| 216 | 216 | /* @var WPDB $wpdb */ |
| 217 | 217 | global $wpdb; |
| 218 | 218 | $args['number'] = - 1; |
| 219 | 219 | $args['fields'] = 'ID'; |
| 220 | 220 | $args['count'] = true; |
| 221 | 221 | |
| 222 | - $sql_query = $this->get_sql( $args ); |
|
| 222 | + $sql_query = $this->get_sql($args); |
|
| 223 | 223 | |
| 224 | - if ( ! ( $count = Give_Cache::get( 'give_logs_count', true, $sql_query ) ) ) { |
|
| 225 | - $count = $wpdb->get_var( $sql_query ); |
|
| 226 | - Give_Cache::set( 'give_logs_count', $count, 3600, true, $args ); |
|
| 224 | + if ( ! ($count = Give_Cache::get('give_logs_count', true, $sql_query))) { |
|
| 225 | + $count = $wpdb->get_var($sql_query); |
|
| 226 | + Give_Cache::set('give_logs_count', $count, 3600, true, $args); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - return absint( $count ); |
|
| 229 | + return absint($count); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -252,10 +252,10 @@ discard block |
||
| 252 | 252 | PRIMARY KEY (ID) |
| 253 | 253 | ) {$charset_collate};"; |
| 254 | 254 | |
| 255 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 256 | - dbDelta( $sql ); |
|
| 255 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 256 | + dbDelta($sql); |
|
| 257 | 257 | |
| 258 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
| 258 | + update_option($this->table_name.'_db_version', $this->version); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | * |
| 270 | 270 | * @return string |
| 271 | 271 | */ |
| 272 | - public function get_sql( $args = array() ) { |
|
| 272 | + public function get_sql($args = array()) { |
|
| 273 | 273 | /* @var WPDB $wpdb */ |
| 274 | 274 | global $wpdb; |
| 275 | 275 | |
@@ -283,12 +283,12 @@ discard block |
||
| 283 | 283 | 'count' => false, |
| 284 | 284 | ); |
| 285 | 285 | |
| 286 | - $args = wp_parse_args( $args, $defaults ); |
|
| 286 | + $args = wp_parse_args($args, $defaults); |
|
| 287 | 287 | |
| 288 | 288 | // validate params. |
| 289 | - $this->validate_params( $args ); |
|
| 289 | + $this->validate_params($args); |
|
| 290 | 290 | |
| 291 | - if ( $args['number'] < 1 ) { |
|
| 291 | + if ($args['number'] < 1) { |
|
| 292 | 292 | $args['number'] = 99999999999; |
| 293 | 293 | } |
| 294 | 294 | |
@@ -296,78 +296,78 @@ discard block |
||
| 296 | 296 | $where = ''; |
| 297 | 297 | |
| 298 | 298 | // Get sql query for meta. |
| 299 | - if ( ! empty( $args['meta_query'] ) ) { |
|
| 300 | - $meta_query_object = new WP_Meta_Query( $args['meta_query'] ); |
|
| 301 | - $meta_query = $meta_query_object->get_sql( 'log', $this->table_name, 'id' ); |
|
| 302 | - $where = implode( '', $meta_query ); |
|
| 299 | + if ( ! empty($args['meta_query'])) { |
|
| 300 | + $meta_query_object = new WP_Meta_Query($args['meta_query']); |
|
| 301 | + $meta_query = $meta_query_object->get_sql('log', $this->table_name, 'id'); |
|
| 302 | + $where = implode('', $meta_query); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | $where .= ' WHERE 1=1 '; |
| 306 | 306 | |
| 307 | 307 | // Set offset. |
| 308 | - if ( empty( $args['offset'] ) && ( 0 < $args['paged'] ) ) { |
|
| 309 | - $args['offset'] = $args['number'] * ( $args['paged'] - 1 ); |
|
| 308 | + if (empty($args['offset']) && (0 < $args['paged'])) { |
|
| 309 | + $args['offset'] = $args['number'] * ($args['paged'] - 1); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | // Set fields. |
| 313 | 313 | $fields = "{$this->table_name}.*"; |
| 314 | - if ( is_string( $args['fields'] ) && ( 'all' !== $args['fields'] ) ) { |
|
| 314 | + if (is_string($args['fields']) && ('all' !== $args['fields'])) { |
|
| 315 | 315 | $fields = "{$this->table_name}.{$args['fields']}"; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | // Set count. |
| 319 | - if ( $args['count'] ) { |
|
| 319 | + if ($args['count']) { |
|
| 320 | 320 | $fields = "COUNT({$fields})"; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | // Specific logs. |
| 324 | - if ( ! empty( $args['ID'] ) ) { |
|
| 324 | + if ( ! empty($args['ID'])) { |
|
| 325 | 325 | |
| 326 | - if ( ! is_array( $args['ID'] ) ) { |
|
| 327 | - $args['ID'] = explode( ',', $args['ID'] ); |
|
| 326 | + if ( ! is_array($args['ID'])) { |
|
| 327 | + $args['ID'] = explode(',', $args['ID']); |
|
| 328 | 328 | } |
| 329 | - $log_ids = implode( ',', array_map( 'intval', $args['ID'] ) ); |
|
| 329 | + $log_ids = implode(',', array_map('intval', $args['ID'])); |
|
| 330 | 330 | |
| 331 | 331 | $where .= " AND {$this->table_name}.ID IN( {$log_ids} ) "; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | // Logs created for a specific date or in a date range |
| 335 | - if ( ! empty( $args['date_query'] ) ) { |
|
| 336 | - $date_query_object = new WP_Date_Query( $args['date_query'], "{$this->table_name}.log_date" ); |
|
| 337 | - $where .= $date_query_object->get_sql(); |
|
| 335 | + if ( ! empty($args['date_query'])) { |
|
| 336 | + $date_query_object = new WP_Date_Query($args['date_query'], "{$this->table_name}.log_date"); |
|
| 337 | + $where .= $date_query_object->get_sql(); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | // Logs create for specific parent. |
| 341 | - if ( ! empty( $args['log_parent'] ) ) { |
|
| 342 | - if ( ! is_array( $args['log_parent'] ) ) { |
|
| 343 | - $args['log_parent'] = explode( ',', $args['log_parent'] ); |
|
| 341 | + if ( ! empty($args['log_parent'])) { |
|
| 342 | + if ( ! is_array($args['log_parent'])) { |
|
| 343 | + $args['log_parent'] = explode(',', $args['log_parent']); |
|
| 344 | 344 | } |
| 345 | - $parent_ids = implode( ',', array_map( 'intval', $args['log_parent'] ) ); |
|
| 345 | + $parent_ids = implode(',', array_map('intval', $args['log_parent'])); |
|
| 346 | 346 | |
| 347 | 347 | $where .= " AND {$this->table_name}.log_parent IN( {$parent_ids} ) "; |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | // Logs create for specific type. |
| 351 | 351 | // is_array check is for backward compatibility. |
| 352 | - if ( ! empty( $args['log_type'] ) && ! is_array( $args['log_type'] ) ) { |
|
| 353 | - if ( ! is_array( $args['log_type'] ) ) { |
|
| 354 | - $args['log_type'] = explode( ',', $args['log_type'] ); |
|
| 352 | + if ( ! empty($args['log_type']) && ! is_array($args['log_type'])) { |
|
| 353 | + if ( ! is_array($args['log_type'])) { |
|
| 354 | + $args['log_type'] = explode(',', $args['log_type']); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - $log_types = implode( '\',\'', array_map( 'trim', $args['log_type'] ) ); |
|
| 357 | + $log_types = implode('\',\'', array_map('trim', $args['log_type'])); |
|
| 358 | 358 | |
| 359 | 359 | $where .= " AND {$this->table_name}.log_type IN( '{$log_types}' ) "; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - $args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'log_date' : $args['orderby']; |
|
| 362 | + $args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'log_date' : $args['orderby']; |
|
| 363 | 363 | |
| 364 | - $args['orderby'] = esc_sql( $args['orderby'] ); |
|
| 365 | - $args['order'] = esc_sql( $args['order'] ); |
|
| 364 | + $args['orderby'] = esc_sql($args['orderby']); |
|
| 365 | + $args['order'] = esc_sql($args['order']); |
|
| 366 | 366 | |
| 367 | 367 | return $wpdb->prepare( |
| 368 | 368 | "SELECT {$fields} FROM {$this->table_name} {$where} ORDER BY {$this->table_name}.{$args['orderby']} {$args['order']} LIMIT %d,%d;", |
| 369 | - absint( $args['offset'] ), |
|
| 370 | - absint( $args['number'] ) |
|
| 369 | + absint($args['offset']), |
|
| 370 | + absint($args['number']) |
|
| 371 | 371 | ); |
| 372 | 372 | } |
| 373 | 373 | |
@@ -382,13 +382,11 @@ discard block |
||
| 382 | 382 | * |
| 383 | 383 | * @return mixed |
| 384 | 384 | */ |
| 385 | - private function validate_params( &$args ) { |
|
| 385 | + private function validate_params(&$args) { |
|
| 386 | 386 | // fields params |
| 387 | 387 | $args['fields'] = 'ids' === $args['fields'] ? |
| 388 | - 'ID' : |
|
| 389 | - $args['fields']; |
|
| 390 | - $args['fields'] = array_key_exists( $args['fields'], $this->get_columns() ) ? |
|
| 391 | - $args['fields'] : |
|
| 392 | - 'all'; |
|
| 388 | + 'ID' : $args['fields']; |
|
| 389 | + $args['fields'] = array_key_exists($args['fields'], $this->get_columns()) ? |
|
| 390 | + $args['fields'] : 'all'; |
|
| 393 | 391 | } |
| 394 | 392 | } |