@@ -18,17 +18,17 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @return array |
| 20 | 20 | */ |
| 21 | -function give_offline_register_gateway( $gateways ) { |
|
| 21 | +function give_offline_register_gateway($gateways) { |
|
| 22 | 22 | // Format: ID => Name |
| 23 | 23 | $gateways['offline'] = array( |
| 24 | 24 | 'admin_label' => 'Offline Donation', |
| 25 | - 'checkout_label' => __( 'Offline Donation', 'give' ) |
|
| 25 | + 'checkout_label' => __('Offline Donation', 'give') |
|
| 26 | 26 | ); |
| 27 | 27 | |
| 28 | 28 | return $gateways; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | -add_filter( 'give_payment_gateways', 'give_offline_register_gateway', 1 ); |
|
| 31 | +add_filter('give_payment_gateways', 'give_offline_register_gateway', 1); |
|
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -39,10 +39,10 @@ discard block |
||
| 39 | 39 | * @return void |
| 40 | 40 | */ |
| 41 | 41 | function give_offline_disable_abandoned_orders() { |
| 42 | - remove_action( 'give_weekly_scheduled_events', 'give_mark_abandoned_orders' ); |
|
| 42 | + remove_action('give_weekly_scheduled_events', 'give_mark_abandoned_orders'); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | -add_action( 'plugins_loaded', 'give_offline_disable_abandoned_orders' ); |
|
| 45 | +add_action('plugins_loaded', 'give_offline_disable_abandoned_orders'); |
|
| 46 | 46 | |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -54,48 +54,48 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @return void |
| 56 | 56 | */ |
| 57 | -function give_offline_payment_cc_form( $form_id ) { |
|
| 57 | +function give_offline_payment_cc_form($form_id) { |
|
| 58 | 58 | |
| 59 | - $post_offline_customization_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
| 60 | - $post_offline_instructions = get_post_meta( $form_id, '_give_offline_checkout_notes', true ); |
|
| 61 | - $global_offline_instruction = give_get_option( 'global_offline_donation_content' ); |
|
| 59 | + $post_offline_customization_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
| 60 | + $post_offline_instructions = get_post_meta($form_id, '_give_offline_checkout_notes', true); |
|
| 61 | + $global_offline_instruction = give_get_option('global_offline_donation_content'); |
|
| 62 | 62 | $offline_instructions = $global_offline_instruction; |
| 63 | 63 | |
| 64 | - if ( $post_offline_customization_option == 'yes' ) { |
|
| 64 | + if ($post_offline_customization_option == 'yes') { |
|
| 65 | 65 | $offline_instructions = $post_offline_instructions; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | |
| 69 | 69 | ob_start(); ?> |
| 70 | - <?php do_action( 'give_before_offline_info_fields', $form_id ); ?> |
|
| 70 | + <?php do_action('give_before_offline_info_fields', $form_id); ?> |
|
| 71 | 71 | <fieldset id="give_offline_payment_info"> |
| 72 | 72 | <?php |
| 73 | - $settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' ); |
|
| 74 | - $offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( __( 'Please enter offline donation instructions in the %s.', 'give' ), '<a href="' . $settings_url . '">' . __( 'this form\'s settings', 'give' ) . '</a>' ); |
|
| 75 | - echo wpautop( stripslashes( $offline_instructions ) ); |
|
| 73 | + $settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1'); |
|
| 74 | + $offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(__('Please enter offline donation instructions in the %s.', 'give'), '<a href="'.$settings_url.'">'.__('this form\'s settings', 'give').'</a>'); |
|
| 75 | + echo wpautop(stripslashes($offline_instructions)); |
|
| 76 | 76 | ?> |
| 77 | 77 | </fieldset> |
| 78 | - <?php do_action( 'give_after_offline_info_fields', $form_id ); ?> |
|
| 78 | + <?php do_action('give_after_offline_info_fields', $form_id); ?> |
|
| 79 | 79 | <?php |
| 80 | 80 | echo ob_get_clean(); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | -add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' ); |
|
| 83 | +add_action('give_offline_cc_form', 'give_offline_payment_cc_form'); |
|
| 84 | 84 | |
| 85 | 85 | |
| 86 | 86 | |
| 87 | -function give_offline_billing_fields($form_id){ |
|
| 87 | +function give_offline_billing_fields($form_id) { |
|
| 88 | 88 | //Enable Default CC fields (billing info) |
| 89 | - $post_offline_cc_fields = get_post_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true ); |
|
| 90 | - $global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' ); |
|
| 89 | + $post_offline_cc_fields = get_post_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true); |
|
| 90 | + $global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields'); |
|
| 91 | 91 | |
| 92 | 92 | |
| 93 | - if ( $global_offline_cc_fields == 'on' || $post_offline_cc_fields == 'on' ) { |
|
| 94 | - give_default_cc_address_fields( $form_id ); |
|
| 93 | + if ($global_offline_cc_fields == 'on' || $post_offline_cc_fields == 'on') { |
|
| 94 | + give_default_cc_address_fields($form_id); |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | -add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 ); |
|
| 98 | +add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1); |
|
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * Process the payment |
@@ -103,15 +103,15 @@ discard block |
||
| 103 | 103 | * @since 1.0 |
| 104 | 104 | * @return void |
| 105 | 105 | */ |
| 106 | -function give_offline_process_payment( $purchase_data ) { |
|
| 106 | +function give_offline_process_payment($purchase_data) { |
|
| 107 | 107 | |
| 108 | - $purchase_summary = give_get_purchase_summary( $purchase_data ); |
|
| 108 | + $purchase_summary = give_get_purchase_summary($purchase_data); |
|
| 109 | 109 | |
| 110 | 110 | // setup the payment details |
| 111 | 111 | $payment_data = array( |
| 112 | 112 | 'price' => $purchase_data['price'], |
| 113 | 113 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
| 114 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
| 114 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
| 115 | 115 | 'date' => $purchase_data['date'], |
| 116 | 116 | 'user_email' => $purchase_data['user_email'], |
| 117 | 117 | 'purchase_key' => $purchase_data['purchase_key'], |
@@ -123,20 +123,20 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | |
| 125 | 125 | // record the pending payment |
| 126 | - $payment = give_insert_payment( $payment_data ); |
|
| 126 | + $payment = give_insert_payment($payment_data); |
|
| 127 | 127 | |
| 128 | - if ( $payment ) { |
|
| 129 | - give_offline_send_admin_notice( $payment ); |
|
| 130 | - give_offline_send_donor_instructions( $payment ); |
|
| 128 | + if ($payment) { |
|
| 129 | + give_offline_send_admin_notice($payment); |
|
| 130 | + give_offline_send_donor_instructions($payment); |
|
| 131 | 131 | give_send_to_success_page(); |
| 132 | 132 | } else { |
| 133 | 133 | // if errors are present, send the user back to the donation form so they can be corrected |
| 134 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
| 134 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | -add_action( 'give_gateway_offline', 'give_offline_process_payment' ); |
|
| 139 | +add_action('give_gateway_offline', 'give_offline_process_payment'); |
|
| 140 | 140 | |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -149,47 +149,47 @@ discard block |
||
| 149 | 149 | * @since 1.0 |
| 150 | 150 | * @return void |
| 151 | 151 | */ |
| 152 | -function give_offline_send_donor_instructions( $payment_id = 0 ) { |
|
| 152 | +function give_offline_send_donor_instructions($payment_id = 0) { |
|
| 153 | 153 | |
| 154 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
| 155 | - $post_offline_customization_option = get_post_meta( $payment_data['form_id'], '_give_customize_offline_donations', true ); |
|
| 154 | + $payment_data = give_get_payment_meta($payment_id); |
|
| 155 | + $post_offline_customization_option = get_post_meta($payment_data['form_id'], '_give_customize_offline_donations', true); |
|
| 156 | 156 | |
| 157 | 157 | //Customize email content depending on whether the single form has been customized |
| 158 | - $email_content = give_get_option( 'global_offline_donation_email' ); |
|
| 158 | + $email_content = give_get_option('global_offline_donation_email'); |
|
| 159 | 159 | |
| 160 | - if ( $post_offline_customization_option === 'yes' ) { |
|
| 161 | - $email_content = get_post_meta( $payment_data['form_id'], '_give_offline_donation_email', true ); |
|
| 160 | + if ($post_offline_customization_option === 'yes') { |
|
| 161 | + $email_content = get_post_meta($payment_data['form_id'], '_give_offline_donation_email', true); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
| 165 | - $from_name = apply_filters( 'give_purchase_from_name', $from_name, $payment_id, $payment_data ); |
|
| 164 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
| 165 | + $from_name = apply_filters('give_purchase_from_name', $from_name, $payment_id, $payment_data); |
|
| 166 | 166 | |
| 167 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
| 168 | - $from_email = apply_filters( 'give_purchase_from_address', $from_email, $payment_id, $payment_data ); |
|
| 167 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
| 168 | + $from_email = apply_filters('give_purchase_from_address', $from_email, $payment_id, $payment_data); |
|
| 169 | 169 | |
| 170 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
| 170 | + $to_email = give_get_payment_user_email($payment_id); |
|
| 171 | 171 | |
| 172 | - $subject = give_get_option( 'offline_donation_subject', __( 'Offline Donation Instructions', 'give' ) ); |
|
| 173 | - if ( $post_offline_customization_option === 'yes' ) { |
|
| 174 | - $subject = get_post_meta( $payment_data['form_id'], '_give_offline_donation_subject', true ); |
|
| 172 | + $subject = give_get_option('offline_donation_subject', __('Offline Donation Instructions', 'give')); |
|
| 173 | + if ($post_offline_customization_option === 'yes') { |
|
| 174 | + $subject = get_post_meta($payment_data['form_id'], '_give_offline_donation_subject', true); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - $subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
| 178 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
| 177 | + $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
| 178 | + $subject = give_do_email_tags($subject, $payment_id); |
|
| 179 | 179 | |
| 180 | - $attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data ); |
|
| 181 | - $message = give_do_email_tags( $email_content, $payment_id ); |
|
| 180 | + $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data); |
|
| 181 | + $message = give_do_email_tags($email_content, $payment_id); |
|
| 182 | 182 | |
| 183 | 183 | $emails = Give()->emails; |
| 184 | 184 | |
| 185 | - $emails->__set( 'from_name', $from_name ); |
|
| 186 | - $emails->__set( 'from_email', $from_email ); |
|
| 187 | - $emails->__set( 'heading', __( 'Offline Donation Instructions', 'give' ) ); |
|
| 185 | + $emails->__set('from_name', $from_name); |
|
| 186 | + $emails->__set('from_email', $from_email); |
|
| 187 | + $emails->__set('heading', __('Offline Donation Instructions', 'give')); |
|
| 188 | 188 | |
| 189 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
| 190 | - $emails->__set( 'headers', $headers ); |
|
| 189 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
| 190 | + $emails->__set('headers', $headers); |
|
| 191 | 191 | |
| 192 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
| 192 | + $emails->send($to_email, $subject, $message, $attachments); |
|
| 193 | 193 | |
| 194 | 194 | } |
| 195 | 195 | |
@@ -206,37 +206,37 @@ discard block |
||
| 206 | 206 | * @return void |
| 207 | 207 | * |
| 208 | 208 | */ |
| 209 | -function give_offline_send_admin_notice( $payment_id = 0 ) { |
|
| 209 | +function give_offline_send_admin_notice($payment_id = 0) { |
|
| 210 | 210 | |
| 211 | 211 | /* Send an email notification to the admin */ |
| 212 | 212 | $admin_email = give_get_admin_notice_emails(); |
| 213 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
| 213 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
| 214 | 214 | |
| 215 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
| 216 | - $user_data = get_userdata( $user_info['id'] ); |
|
| 215 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
| 216 | + $user_data = get_userdata($user_info['id']); |
|
| 217 | 217 | $name = $user_data->display_name; |
| 218 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
| 219 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
| 218 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
| 219 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
| 220 | 220 | } else { |
| 221 | 221 | $name = $user_info['email']; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - $amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ); |
|
| 224 | + $amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))); |
|
| 225 | 225 | |
| 226 | - $admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', __( 'New Pending Donation', 'give' ), $payment_id ); |
|
| 226 | + $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', __('New Pending Donation', 'give'), $payment_id); |
|
| 227 | 227 | |
| 228 | - $admin_message = __( 'Dear Admin,', 'give' ) . "\n\n" . __( 'An offline donation has been made', 'give' ) . ".\n\n"; |
|
| 228 | + $admin_message = __('Dear Admin,', 'give')."\n\n".__('An offline donation has been made', 'give').".\n\n"; |
|
| 229 | 229 | |
| 230 | - $order_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ); |
|
| 231 | - $admin_message .= __( 'Donor: ', 'give' ) . " " . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n"; |
|
| 232 | - $admin_message .= __( 'Amount: ', 'give' ) . " " . html_entity_decode( $amount, ENT_COMPAT, 'UTF-8' ) . "\n\n"; |
|
| 233 | - $admin_message .= __( 'This is a pending donation awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n"; |
|
| 234 | - $admin_message .= sprintf( __( 'View Donation Details: %s.', 'give' ), $order_url ) . "\n\n"; |
|
| 235 | - $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
|
| 236 | - $admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id ); |
|
| 237 | - $attachments = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id ); |
|
| 230 | + $order_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment_id); |
|
| 231 | + $admin_message .= __('Donor: ', 'give')." ".html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n"; |
|
| 232 | + $admin_message .= __('Amount: ', 'give')." ".html_entity_decode($amount, ENT_COMPAT, 'UTF-8')."\n\n"; |
|
| 233 | + $admin_message .= __('This is a pending donation awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n"; |
|
| 234 | + $admin_message .= sprintf(__('View Donation Details: %s.', 'give'), $order_url)."\n\n"; |
|
| 235 | + $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id); |
|
| 236 | + $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id); |
|
| 237 | + $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id); |
|
| 238 | 238 | |
| 239 | - wp_mail( $admin_email, $admin_subject, $admin_message, $admin_headers, $attachments ); |
|
| 239 | + wp_mail($admin_email, $admin_subject, $admin_message, $admin_headers, $attachments); |
|
| 240 | 240 | |
| 241 | 241 | } |
| 242 | 242 | |
@@ -247,15 +247,15 @@ discard block |
||
| 247 | 247 | * @since 1.0 |
| 248 | 248 | * @return array |
| 249 | 249 | */ |
| 250 | -function give_offline_add_settings( $settings ) { |
|
| 250 | +function give_offline_add_settings($settings) { |
|
| 251 | 251 | |
| 252 | 252 | //Vars |
| 253 | 253 | $prefix = '_give_'; |
| 254 | 254 | |
| 255 | - $is_gateway_active = give_is_gateway_active( 'offline' ); |
|
| 255 | + $is_gateway_active = give_is_gateway_active('offline'); |
|
| 256 | 256 | |
| 257 | 257 | //this gateway isn't active |
| 258 | - if ( ! $is_gateway_active ) { |
|
| 258 | + if ( ! $is_gateway_active) { |
|
| 259 | 259 | //return settings and bounce |
| 260 | 260 | return $settings; |
| 261 | 261 | } |
@@ -264,27 +264,27 @@ discard block |
||
| 264 | 264 | $check_settings = array( |
| 265 | 265 | |
| 266 | 266 | array( |
| 267 | - 'name' => __( 'Customize Offline Donations', 'give' ), |
|
| 268 | - 'desc' => __( 'If you would like to customize the donation instructions for this specific forms check this option.', 'give' ), |
|
| 269 | - 'id' => $prefix . 'customize_offline_donations', |
|
| 267 | + 'name' => __('Customize Offline Donations', 'give'), |
|
| 268 | + 'desc' => __('If you would like to customize the donation instructions for this specific forms check this option.', 'give'), |
|
| 269 | + 'id' => $prefix.'customize_offline_donations', |
|
| 270 | 270 | 'type' => 'radio_inline', |
| 271 | 271 | 'default' => 'no', |
| 272 | 272 | 'options' => array( |
| 273 | - 'yes' => __( 'Yes', 'give' ), |
|
| 274 | - 'no' => __( 'No', 'give' ), |
|
| 273 | + 'yes' => __('Yes', 'give'), |
|
| 274 | + 'no' => __('No', 'give'), |
|
| 275 | 275 | ), |
| 276 | 276 | ), |
| 277 | 277 | array( |
| 278 | - 'name' => __( 'Request Billing Information', 'give' ), |
|
| 279 | - 'desc' => __( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ), |
|
| 280 | - 'id' => $prefix . 'offline_donation_enable_billing_fields_single', |
|
| 278 | + 'name' => __('Request Billing Information', 'give'), |
|
| 279 | + 'desc' => __('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'), |
|
| 280 | + 'id' => $prefix.'offline_donation_enable_billing_fields_single', |
|
| 281 | 281 | 'row_classes' => 'give-subfield', |
| 282 | 282 | 'type' => 'checkbox' |
| 283 | 283 | ), |
| 284 | 284 | array( |
| 285 | - 'id' => $prefix . 'offline_checkout_notes', |
|
| 286 | - 'name' => __( 'Offline Donation Instructions', 'give' ), |
|
| 287 | - 'desc' => __( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
| 285 | + 'id' => $prefix.'offline_checkout_notes', |
|
| 286 | + 'name' => __('Offline Donation Instructions', 'give'), |
|
| 287 | + 'desc' => __('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
| 288 | 288 | 'default' => give_get_default_offline_donation_content(), |
| 289 | 289 | 'type' => 'wysiwyg', |
| 290 | 290 | 'row_classes' => 'give-subfield', |
@@ -293,17 +293,17 @@ discard block |
||
| 293 | 293 | ) |
| 294 | 294 | ), |
| 295 | 295 | array( |
| 296 | - 'id' => $prefix . 'offline_donation_subject', |
|
| 297 | - 'name' => __( 'Offline Donation Email Instructions Subject', 'give' ), |
|
| 298 | - 'desc' => __( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
| 299 | - 'default' => __( '{donation} - Offline Donation Instructions', 'give' ), |
|
| 296 | + 'id' => $prefix.'offline_donation_subject', |
|
| 297 | + 'name' => __('Offline Donation Email Instructions Subject', 'give'), |
|
| 298 | + 'desc' => __('Enter the subject line for the donation receipt email.', 'give'), |
|
| 299 | + 'default' => __('{donation} - Offline Donation Instructions', 'give'), |
|
| 300 | 300 | 'row_classes' => 'give-subfield', |
| 301 | 301 | 'type' => 'text' |
| 302 | 302 | ), |
| 303 | 303 | array( |
| 304 | - 'id' => $prefix . 'offline_donation_email', |
|
| 305 | - 'name' => __( 'Offline Donation Email Instructions', 'give' ), |
|
| 306 | - 'desc' => __( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
| 304 | + 'id' => $prefix.'offline_donation_email', |
|
| 305 | + 'name' => __('Offline Donation Email Instructions', 'give'), |
|
| 306 | + 'desc' => __('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
| 307 | 307 | 'default' => give_get_default_offline_donation_email_content(), |
| 308 | 308 | 'type' => 'wysiwyg', |
| 309 | 309 | 'row_classes' => 'give-subfield', |
@@ -313,10 +313,10 @@ discard block |
||
| 313 | 313 | ) |
| 314 | 314 | ); |
| 315 | 315 | |
| 316 | - return array_merge( $settings, $check_settings ); |
|
| 316 | + return array_merge($settings, $check_settings); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | -add_filter( 'give_forms_display_options_metabox_fields', 'give_offline_add_settings' ); |
|
| 319 | +add_filter('give_forms_display_options_metabox_fields', 'give_offline_add_settings'); |
|
| 320 | 320 | |
| 321 | 321 | |
| 322 | 322 | /** |
@@ -328,20 +328,20 @@ discard block |
||
| 328 | 328 | */ |
| 329 | 329 | function give_get_default_offline_donation_content() { |
| 330 | 330 | |
| 331 | - $sitename = get_bloginfo( 'sitename' ); |
|
| 331 | + $sitename = get_bloginfo('sitename'); |
|
| 332 | 332 | |
| 333 | - $default_text = '<p>' . __( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
| 333 | + $default_text = '<p>'.__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
| 334 | 334 | $default_text .= '<ol>'; |
| 335 | - $default_text .= '<li>' . _x( 'Make a check payable to ', 'Step 1 for donating offline by check', 'give' ) . '"' . $sitename . '"' . '</li>'; |
|
| 336 | - $default_text .= '<li>' . _x( 'On the memo line of the check, please indicate that the donation is for ', 'Step 2 for donating by check; this explains who the check should be written to', 'give' ) . '"' . $sitename . '"' . '</li>'; |
|
| 337 | - $default_text .= '<li>' . _x( 'Please mail your check to:', 'Step 3; where to mail the check', 'give' ) . '</li>'; |
|
| 335 | + $default_text .= '<li>'._x('Make a check payable to ', 'Step 1 for donating offline by check', 'give').'"'.$sitename.'"'.'</li>'; |
|
| 336 | + $default_text .= '<li>'._x('On the memo line of the check, please indicate that the donation is for ', 'Step 2 for donating by check; this explains who the check should be written to', 'give').'"'.$sitename.'"'.'</li>'; |
|
| 337 | + $default_text .= '<li>'._x('Please mail your check to:', 'Step 3; where to mail the check', 'give').'</li>'; |
|
| 338 | 338 | $default_text .= '</ol>'; |
| 339 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
| 339 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
| 340 | 340 | $default_text .= ' <em>123 G Street </em><br>'; |
| 341 | 341 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
| 342 | - $default_text .= '<p>' . __( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>'; |
|
| 342 | + $default_text .= '<p>'.__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>'; |
|
| 343 | 343 | |
| 344 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
| 344 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
| 345 | 345 | |
| 346 | 346 | } |
| 347 | 347 | |
@@ -354,21 +354,21 @@ discard block |
||
| 354 | 354 | */ |
| 355 | 355 | function give_get_default_offline_donation_email_content() { |
| 356 | 356 | |
| 357 | - $sitename = get_bloginfo( 'sitename' ); |
|
| 358 | - $default_text = '<p>' . __( 'Dear {name},', 'give' ) . '</p>'; |
|
| 359 | - $default_text .= '<p>' . __( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
| 357 | + $sitename = get_bloginfo('sitename'); |
|
| 358 | + $default_text = '<p>'.__('Dear {name},', 'give').'</p>'; |
|
| 359 | + $default_text .= '<p>'.__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
| 360 | 360 | $default_text .= '<ol>'; |
| 361 | - $default_text .= '<li>' . _x( 'Make a check payable to ', 'Step 1 for donating offline by check', 'give' ) . '"' . $sitename . '"' . '</li>'; |
|
| 362 | - $default_text .= '<li>' . _x( 'On the memo line of the check, please indicate that the donation is for ', 'Step 2 for donating by check; this explains who the check should be written to', 'give' ) . '"' . $sitename . '"' . '</li>'; |
|
| 363 | - $default_text .= '<li>' . _x( 'Please mail your check to:', 'Step 3; where to mail the check', 'give' ) . '</li>'; |
|
| 361 | + $default_text .= '<li>'._x('Make a check payable to ', 'Step 1 for donating offline by check', 'give').'"'.$sitename.'"'.'</li>'; |
|
| 362 | + $default_text .= '<li>'._x('On the memo line of the check, please indicate that the donation is for ', 'Step 2 for donating by check; this explains who the check should be written to', 'give').'"'.$sitename.'"'.'</li>'; |
|
| 363 | + $default_text .= '<li>'._x('Please mail your check to:', 'Step 3; where to mail the check', 'give').'</li>'; |
|
| 364 | 364 | $default_text .= '</ol>'; |
| 365 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
| 365 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
| 366 | 366 | $default_text .= ' <em>123 G Street </em><br>'; |
| 367 | 367 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
| 368 | - $default_text .= '<p>' . __( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>'; |
|
| 369 | - $default_text .= '<p>' . __( 'Sincerely,', 'give' ) . '</p>'; |
|
| 370 | - $default_text .= '<p>' . $sitename . '</p>'; |
|
| 368 | + $default_text .= '<p>'.__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>'; |
|
| 369 | + $default_text .= '<p>'.__('Sincerely,', 'give').'</p>'; |
|
| 370 | + $default_text .= '<p>'.$sitename.'</p>'; |
|
| 371 | 371 | |
| 372 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
| 372 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
| 373 | 373 | |
| 374 | 374 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @since 1.0 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @access private |
| 22 | 22 | * @since 1.0 |
| 23 | 23 | */ |
| 24 | -add_action( 'give_paypal_cc_form', '__return_false' ); |
|
| 24 | +add_action('give_paypal_cc_form', '__return_false'); |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * Process PayPal Purchase |
@@ -32,13 +32,13 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | -function give_process_paypal_purchase( $purchase_data ) { |
|
| 35 | +function give_process_paypal_purchase($purchase_data) { |
|
| 36 | 36 | |
| 37 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
| 38 | - wp_die( __( 'Nonce verification has failed', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
| 38 | + wp_die(__('Nonce verification has failed', 'give'), __('Error', 'give'), array('response' => 403)); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - $form_id = intval( $purchase_data['post_data']['give-form-id'] ); |
|
| 41 | + $form_id = intval($purchase_data['post_data']['give-form-id']); |
|
| 42 | 42 | |
| 43 | 43 | // Collect payment data |
| 44 | 44 | $payment_data = array( |
@@ -55,59 +55,59 @@ discard block |
||
| 55 | 55 | ); |
| 56 | 56 | |
| 57 | 57 | // Record the pending payment |
| 58 | - $payment = give_insert_payment( $payment_data ); |
|
| 58 | + $payment = give_insert_payment($payment_data); |
|
| 59 | 59 | |
| 60 | 60 | // Check payment |
| 61 | - if ( ! $payment ) { |
|
| 61 | + if ( ! $payment) { |
|
| 62 | 62 | // Record the error |
| 63 | - give_record_gateway_error( __( 'Payment Error', 'give' ), sprintf( __( 'Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give' ), json_encode( $payment_data ) ), $payment ); |
|
| 63 | + give_record_gateway_error(__('Payment Error', 'give'), sprintf(__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give'), json_encode($payment_data)), $payment); |
|
| 64 | 64 | // Problems? send back |
| 65 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
| 65 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
| 66 | 66 | } else { |
| 67 | 67 | // Only send to PayPal if the pending payment is created successfully |
| 68 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
| 68 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
| 69 | 69 | |
| 70 | 70 | // Get the success url |
| 71 | - $return_url = add_query_arg( array( |
|
| 71 | + $return_url = add_query_arg(array( |
|
| 72 | 72 | 'payment-confirmation' => 'paypal', |
| 73 | 73 | 'payment-id' => $payment |
| 74 | 74 | |
| 75 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
| 75 | + ), get_permalink(give_get_option('success_page'))); |
|
| 76 | 76 | |
| 77 | 77 | // Get the PayPal redirect uri |
| 78 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
| 78 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
| 79 | 79 | |
| 80 | 80 | //Item name - pass level name if variable priced |
| 81 | 81 | $item_name = $purchase_data['post_data']['give-form-title']; |
| 82 | 82 | |
| 83 | 83 | //Verify has variable prices |
| 84 | - if ( give_has_variable_prices( $form_id ) && isset( $purchase_data['post_data']['give-price-id'] ) ) { |
|
| 84 | + if (give_has_variable_prices($form_id) && isset($purchase_data['post_data']['give-price-id'])) { |
|
| 85 | 85 | |
| 86 | - $item_price_level_text = give_get_price_option_name( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
| 86 | + $item_price_level_text = give_get_price_option_name($form_id, $purchase_data['post_data']['give-price-id']); |
|
| 87 | 87 | |
| 88 | - $price_level_amount = give_get_price_option_amount( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
| 88 | + $price_level_amount = give_get_price_option_amount($form_id, $purchase_data['post_data']['give-price-id']); |
|
| 89 | 89 | |
| 90 | 90 | //Donation given doesn't match selected level (must be a custom amount) |
| 91 | - if ( $price_level_amount != give_sanitize_amount( $purchase_data['price'] ) ) { |
|
| 92 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 91 | + if ($price_level_amount != give_sanitize_amount($purchase_data['price'])) { |
|
| 92 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
| 93 | 93 | //user custom amount text if any, fallback to default if not |
| 94 | - $item_name .= ' - ' . (! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' )); |
|
| 94 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give')); |
|
| 95 | 95 | |
| 96 | 96 | } //Is there any donation level text? |
| 97 | - elseif ( ! empty( $item_price_level_text ) ) { |
|
| 98 | - $item_name .= ' - ' . $item_price_level_text; |
|
| 97 | + elseif ( ! empty($item_price_level_text)) { |
|
| 98 | + $item_name .= ' - '.$item_price_level_text; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | } //Single donation: Custom Amount |
| 102 | - elseif ( give_get_form_price( $form_id ) !== give_sanitize_amount( $purchase_data['price'] ) ) { |
|
| 103 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 102 | + elseif (give_get_form_price($form_id) !== give_sanitize_amount($purchase_data['price'])) { |
|
| 103 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
| 104 | 104 | //user custom amount text if any, fallback to default if not |
| 105 | - $item_name .= ' - ' . (! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' )); |
|
| 105 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give')); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | // Setup PayPal arguments |
| 109 | 109 | $paypal_args = array( |
| 110 | - 'business' => give_get_option( 'paypal_email', false ), |
|
| 110 | + 'business' => give_get_option('paypal_email', false), |
|
| 111 | 111 | 'email' => $purchase_data['user_email'], |
| 112 | 112 | 'invoice' => $purchase_data['purchase_key'], |
| 113 | 113 | 'amount' => $purchase_data['price'], |
@@ -118,25 +118,25 @@ discard block |
||
| 118 | 118 | 'shipping' => '0', |
| 119 | 119 | 'no_note' => '1', |
| 120 | 120 | 'currency_code' => give_get_currency(), |
| 121 | - 'charset' => get_bloginfo( 'charset' ), |
|
| 121 | + 'charset' => get_bloginfo('charset'), |
|
| 122 | 122 | 'custom' => $payment, |
| 123 | 123 | 'rm' => '2', |
| 124 | 124 | 'return' => $return_url, |
| 125 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment ), |
|
| 125 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment), |
|
| 126 | 126 | 'notify_url' => $listener_url, |
| 127 | 127 | 'page_style' => give_get_paypal_page_style(), |
| 128 | - 'cbt' => get_bloginfo( 'name' ), |
|
| 128 | + 'cbt' => get_bloginfo('name'), |
|
| 129 | 129 | 'bn' => 'givewp_SP' |
| 130 | 130 | ); |
| 131 | 131 | |
| 132 | - if ( ! empty( $purchase_data['user_info']['address'] ) ) { |
|
| 132 | + if ( ! empty($purchase_data['user_info']['address'])) { |
|
| 133 | 133 | $paypal_args['address1'] = $purchase_data['user_info']['address']['line1']; |
| 134 | 134 | $paypal_args['address2'] = $purchase_data['user_info']['address']['line2']; |
| 135 | 135 | $paypal_args['city'] = $purchase_data['user_info']['address']['city']; |
| 136 | 136 | $paypal_args['country'] = $purchase_data['user_info']['address']['country']; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - if ( give_get_option( 'paypal_button_type' ) === 'standard' ) { |
|
| 139 | + if (give_get_option('paypal_button_type') === 'standard') { |
|
| 140 | 140 | $paypal_extra_args = array( |
| 141 | 141 | 'cmd' => '_xclick', |
| 142 | 142 | ); |
@@ -146,25 +146,25 @@ discard block |
||
| 146 | 146 | ); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - $paypal_args = array_merge( $paypal_extra_args, $paypal_args ); |
|
| 149 | + $paypal_args = array_merge($paypal_extra_args, $paypal_args); |
|
| 150 | 150 | |
| 151 | 151 | |
| 152 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $purchase_data ); |
|
| 152 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $purchase_data); |
|
| 153 | 153 | |
| 154 | 154 | // Build query |
| 155 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
| 155 | + $paypal_redirect .= http_build_query($paypal_args); |
|
| 156 | 156 | |
| 157 | 157 | // Fix for some sites that encode the entities |
| 158 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
| 158 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
| 159 | 159 | |
| 160 | 160 | // Redirect to PayPal |
| 161 | - wp_redirect( $paypal_redirect ); |
|
| 161 | + wp_redirect($paypal_redirect); |
|
| 162 | 162 | exit; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | -add_action( 'give_gateway_paypal', 'give_process_paypal_purchase' ); |
|
| 167 | +add_action('give_gateway_paypal', 'give_process_paypal_purchase'); |
|
| 168 | 168 | |
| 169 | 169 | /** |
| 170 | 170 | * Listens for a PayPal IPN requests and then sends to the processing function |
@@ -174,12 +174,12 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | function give_listen_for_paypal_ipn() { |
| 176 | 176 | // Regular PayPal IPN |
| 177 | - if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] == 'IPN' ) { |
|
| 178 | - do_action( 'give_verify_paypal_ipn' ); |
|
| 177 | + if (isset($_GET['give-listener']) && $_GET['give-listener'] == 'IPN') { |
|
| 178 | + do_action('give_verify_paypal_ipn'); |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
| 182 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
| 183 | 183 | |
| 184 | 184 | /** |
| 185 | 185 | * Process PayPal IPN |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | function give_process_paypal_ipn() { |
| 191 | 191 | |
| 192 | 192 | // Check the request method is POST |
| 193 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
| 193 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') { |
|
| 194 | 194 | return; |
| 195 | 195 | } |
| 196 | 196 | |
@@ -198,11 +198,11 @@ discard block |
||
| 198 | 198 | $post_data = ''; |
| 199 | 199 | |
| 200 | 200 | // Fallback just in case post_max_size is lower than needed |
| 201 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
| 202 | - $post_data = file_get_contents( 'php://input' ); |
|
| 201 | + if (ini_get('allow_url_fopen')) { |
|
| 202 | + $post_data = file_get_contents('php://input'); |
|
| 203 | 203 | } else { |
| 204 | 204 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
| 205 | - ini_set( 'post_max_size', '12M' ); |
|
| 205 | + ini_set('post_max_size', '12M'); |
|
| 206 | 206 | } |
| 207 | 207 | // Start the encoded data collection with notification command |
| 208 | 208 | $encoded_data = 'cmd=_notify-validate'; |
@@ -211,27 +211,27 @@ discard block |
||
| 211 | 211 | $arg_separator = give_get_php_arg_separator_output(); |
| 212 | 212 | |
| 213 | 213 | // Verify there is a post_data |
| 214 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
| 214 | + if ($post_data || strlen($post_data) > 0) { |
|
| 215 | 215 | // Append the data |
| 216 | - $encoded_data .= $arg_separator . $post_data; |
|
| 216 | + $encoded_data .= $arg_separator.$post_data; |
|
| 217 | 217 | } else { |
| 218 | 218 | // Check if POST is empty |
| 219 | - if ( empty( $_POST ) ) { |
|
| 219 | + if (empty($_POST)) { |
|
| 220 | 220 | // Nothing to do |
| 221 | 221 | return; |
| 222 | 222 | } else { |
| 223 | 223 | // Loop through each POST |
| 224 | - foreach ( $_POST as $key => $value ) { |
|
| 224 | + foreach ($_POST as $key => $value) { |
|
| 225 | 225 | // Encode the value and append the data |
| 226 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
| 226 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | // Convert collected post data to an array |
| 232 | - parse_str( $encoded_data, $encoded_data_array ); |
|
| 232 | + parse_str($encoded_data, $encoded_data_array); |
|
| 233 | 233 | |
| 234 | - if ( ! give_get_option( 'disable_paypal_verification' ) ) { |
|
| 234 | + if ( ! give_get_option('disable_paypal_verification')) { |
|
| 235 | 235 | |
| 236 | 236 | // Validate the IPN |
| 237 | 237 | |
@@ -253,16 +253,16 @@ discard block |
||
| 253 | 253 | ); |
| 254 | 254 | |
| 255 | 255 | // Get response |
| 256 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
| 256 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
| 257 | 257 | |
| 258 | - if ( is_wp_error( $api_response ) ) { |
|
| 259 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
| 258 | + if (is_wp_error($api_response)) { |
|
| 259 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response))); |
|
| 260 | 260 | |
| 261 | 261 | return; // Something went wrong |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - if ( $api_response['body'] !== 'VERIFIED' && give_get_option( 'disable_paypal_verification', false ) ) { |
|
| 265 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
| 264 | + if ($api_response['body'] !== 'VERIFIED' && give_get_option('disable_paypal_verification', false)) { |
|
| 265 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response))); |
|
| 266 | 266 | |
| 267 | 267 | return; // Response not okay |
| 268 | 268 | } |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | // Check if $post_data_array has been populated |
| 273 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
| 273 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
| 274 | 274 | return; |
| 275 | 275 | } |
| 276 | 276 | |
@@ -279,21 +279,21 @@ discard block |
||
| 279 | 279 | 'payment_status' => '' |
| 280 | 280 | ); |
| 281 | 281 | |
| 282 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
| 282 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
| 283 | 283 | |
| 284 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
| 284 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
| 285 | 285 | |
| 286 | - if ( has_action( 'give_paypal_' . $encoded_data_array['txn_type'] ) ) { |
|
| 286 | + if (has_action('give_paypal_'.$encoded_data_array['txn_type'])) { |
|
| 287 | 287 | // Allow PayPal IPN types to be processed separately |
| 288 | - do_action( 'give_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $payment_id ); |
|
| 288 | + do_action('give_paypal_'.$encoded_data_array['txn_type'], $encoded_data_array, $payment_id); |
|
| 289 | 289 | } else { |
| 290 | 290 | // Fallback to web accept just in case the txn_type isn't present |
| 291 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
| 291 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
| 292 | 292 | } |
| 293 | 293 | exit; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
| 296 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
| 297 | 297 | |
| 298 | 298 | /** |
| 299 | 299 | * Process web accept (one time) payment IPNs |
@@ -304,185 +304,185 @@ discard block |
||
| 304 | 304 | * |
| 305 | 305 | * @return void |
| 306 | 306 | */ |
| 307 | -function give_process_paypal_web_accept_and_cart( $data, $payment_id ) { |
|
| 307 | +function give_process_paypal_web_accept_and_cart($data, $payment_id) { |
|
| 308 | 308 | |
| 309 | - if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) { |
|
| 309 | + if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') { |
|
| 310 | 310 | return; |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - if ( empty( $payment_id ) ) { |
|
| 313 | + if (empty($payment_id)) { |
|
| 314 | 314 | return; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | // Collect payment details |
| 318 | - $purchase_key = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number']; |
|
| 318 | + $purchase_key = isset($data['invoice']) ? $data['invoice'] : $data['item_number']; |
|
| 319 | 319 | $paypal_amount = $data['mc_gross']; |
| 320 | - $payment_status = strtolower( $data['payment_status'] ); |
|
| 321 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
| 322 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
| 323 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
| 320 | + $payment_status = strtolower($data['payment_status']); |
|
| 321 | + $currency_code = strtolower($data['mc_currency']); |
|
| 322 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
| 323 | + $payment_meta = give_get_payment_meta($payment_id); |
|
| 324 | 324 | |
| 325 | 325 | |
| 326 | - if ( give_get_payment_gateway( $payment_id ) != 'paypal' ) { |
|
| 326 | + if (give_get_payment_gateway($payment_id) != 'paypal') { |
|
| 327 | 327 | return; // this isn't a PayPal standard IPN |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | // Verify payment recipient |
| 331 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) != 0 ) { |
|
| 331 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) != 0) { |
|
| 332 | 332 | |
| 333 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid business email in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
| 334 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 335 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
| 333 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid business email in IPN response. IPN data: %s', 'give'), json_encode($data)), $payment_id); |
|
| 334 | + give_update_payment_status($payment_id, 'failed'); |
|
| 335 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid PayPal business email.', 'give')); |
|
| 336 | 336 | |
| 337 | 337 | return; |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | // Verify payment currency |
| 341 | - if ( $currency_code != strtolower( $payment_meta['currency'] ) ) { |
|
| 341 | + if ($currency_code != strtolower($payment_meta['currency'])) { |
|
| 342 | 342 | |
| 343 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid currency in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
| 344 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 345 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
| 343 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid currency in IPN response. IPN data: %s', 'give'), json_encode($data)), $payment_id); |
|
| 344 | + give_update_payment_status($payment_id, 'failed'); |
|
| 345 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
| 346 | 346 | |
| 347 | 347 | return; |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - if ( ! give_get_payment_user_email( $payment_id ) ) { |
|
| 350 | + if ( ! give_get_payment_user_email($payment_id)) { |
|
| 351 | 351 | |
| 352 | 352 | // No email associated with purchase, so store from PayPal |
| 353 | - give_update_payment_meta( $payment_id, '_give_payment_user_email', $data['payer_email'] ); |
|
| 353 | + give_update_payment_meta($payment_id, '_give_payment_user_email', $data['payer_email']); |
|
| 354 | 354 | |
| 355 | 355 | // Setup and store the donors's details |
| 356 | 356 | $address = array(); |
| 357 | - $address['line1'] = ! empty( $data['address_street'] ) ? sanitize_text_field( $data['address_street'] ) : false; |
|
| 358 | - $address['city'] = ! empty( $data['address_city'] ) ? sanitize_text_field( $data['address_city'] ) : false; |
|
| 359 | - $address['state'] = ! empty( $data['address_state'] ) ? sanitize_text_field( $data['address_state'] ) : false; |
|
| 360 | - $address['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false; |
|
| 361 | - $address['zip'] = ! empty( $data['address_zip'] ) ? sanitize_text_field( $data['address_zip'] ) : false; |
|
| 357 | + $address['line1'] = ! empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false; |
|
| 358 | + $address['city'] = ! empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false; |
|
| 359 | + $address['state'] = ! empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false; |
|
| 360 | + $address['country'] = ! empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false; |
|
| 361 | + $address['zip'] = ! empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false; |
|
| 362 | 362 | |
| 363 | 363 | $user_info = array( |
| 364 | 364 | 'id' => '-1', |
| 365 | - 'email' => sanitize_text_field( $data['payer_email'] ), |
|
| 366 | - 'first_name' => sanitize_text_field( $data['first_name'] ), |
|
| 367 | - 'last_name' => sanitize_text_field( $data['last_name'] ), |
|
| 365 | + 'email' => sanitize_text_field($data['payer_email']), |
|
| 366 | + 'first_name' => sanitize_text_field($data['first_name']), |
|
| 367 | + 'last_name' => sanitize_text_field($data['last_name']), |
|
| 368 | 368 | 'discount' => '', |
| 369 | 369 | 'address' => $address |
| 370 | 370 | ); |
| 371 | 371 | |
| 372 | 372 | $payment_meta['user_info'] = $user_info; |
| 373 | - give_update_payment_meta( $payment_id, '_give_payment_meta', $payment_meta ); |
|
| 373 | + give_update_payment_meta($payment_id, '_give_payment_meta', $payment_meta); |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
| 376 | + if ($payment_status == 'refunded' || $payment_status == 'reversed') { |
|
| 377 | 377 | |
| 378 | 378 | // Process a refund |
| 379 | - give_process_paypal_refund( $data, $payment_id ); |
|
| 379 | + give_process_paypal_refund($data, $payment_id); |
|
| 380 | 380 | |
| 381 | 381 | } else { |
| 382 | 382 | |
| 383 | - if ( get_post_status( $payment_id ) == 'publish' ) { |
|
| 383 | + if (get_post_status($payment_id) == 'publish') { |
|
| 384 | 384 | return; // Only complete payments once |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | // Retrieve the total purchase amount (before PayPal) |
| 388 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 388 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 389 | 389 | |
| 390 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
| 390 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
| 391 | 391 | // The prices don't match |
| 392 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
| 393 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 394 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
| 392 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid payment amount in IPN response. IPN data: %s', 'give'), json_encode($data)), $payment_id); |
|
| 393 | + give_update_payment_status($payment_id, 'failed'); |
|
| 394 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
| 395 | 395 | |
| 396 | 396 | return; |
| 397 | 397 | } |
| 398 | - if ( $purchase_key != give_get_payment_key( $payment_id ) ) { |
|
| 398 | + if ($purchase_key != give_get_payment_key($payment_id)) { |
|
| 399 | 399 | // Purchase keys don't match |
| 400 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( __( 'Invalid purchase key in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
| 401 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 402 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'give' ) ); |
|
| 400 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf(__('Invalid purchase key in IPN response. IPN data: %s', 'give'), json_encode($data)), $payment_id); |
|
| 401 | + give_update_payment_status($payment_id, 'failed'); |
|
| 402 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid purchase key in PayPal IPN.', 'give')); |
|
| 403 | 403 | |
| 404 | 404 | return; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - if ( $payment_status == 'completed' || give_is_test_mode() ) { |
|
| 408 | - give_insert_payment_note( $payment_id, sprintf( __( 'PayPal Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
| 409 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
| 410 | - give_update_payment_status( $payment_id, 'publish' ); |
|
| 411 | - } else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) { |
|
| 407 | + if ($payment_status == 'completed' || give_is_test_mode()) { |
|
| 408 | + give_insert_payment_note($payment_id, sprintf(__('PayPal Transaction ID: %s', 'give'), $data['txn_id'])); |
|
| 409 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
| 410 | + give_update_payment_status($payment_id, 'publish'); |
|
| 411 | + } else if ('pending' == $payment_status && isset($data['pending_reason'])) { |
|
| 412 | 412 | |
| 413 | 413 | // Look for possible pending reasons, such as an echeck |
| 414 | 414 | |
| 415 | 415 | $note = ''; |
| 416 | 416 | |
| 417 | - switch ( strtolower( $data['pending_reason'] ) ) { |
|
| 417 | + switch (strtolower($data['pending_reason'])) { |
|
| 418 | 418 | |
| 419 | 419 | case 'echeck' : |
| 420 | 420 | |
| 421 | - $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'give' ); |
|
| 421 | + $note = __('Payment made via eCheck and will clear automatically in 5-8 days', 'give'); |
|
| 422 | 422 | |
| 423 | 423 | break; |
| 424 | 424 | |
| 425 | 425 | case 'address' : |
| 426 | 426 | |
| 427 | - $note = __( 'Payment requires a confirmed donor address and must be accepted manually through PayPal', 'give' ); |
|
| 427 | + $note = __('Payment requires a confirmed donor address and must be accepted manually through PayPal', 'give'); |
|
| 428 | 428 | |
| 429 | 429 | break; |
| 430 | 430 | |
| 431 | 431 | case 'intl' : |
| 432 | 432 | |
| 433 | - $note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'give' ); |
|
| 433 | + $note = __('Payment must be accepted manually through PayPal due to international account regulations', 'give'); |
|
| 434 | 434 | |
| 435 | 435 | break; |
| 436 | 436 | |
| 437 | 437 | case 'multi-currency' : |
| 438 | 438 | |
| 439 | - $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal', 'give' ); |
|
| 439 | + $note = __('Payment received in non-shop currency and must be accepted manually through PayPal', 'give'); |
|
| 440 | 440 | |
| 441 | 441 | break; |
| 442 | 442 | |
| 443 | 443 | case 'paymentreview' : |
| 444 | 444 | case 'regulatory_review' : |
| 445 | 445 | |
| 446 | - $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'give' ); |
|
| 446 | + $note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'give'); |
|
| 447 | 447 | |
| 448 | 448 | break; |
| 449 | 449 | |
| 450 | 450 | case 'unilateral' : |
| 451 | 451 | |
| 452 | - $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
| 452 | + $note = __('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
| 453 | 453 | |
| 454 | 454 | break; |
| 455 | 455 | |
| 456 | 456 | case 'upgrade' : |
| 457 | 457 | |
| 458 | - $note = __( 'PayPal account must be upgraded before this payment can be accepted', 'give' ); |
|
| 458 | + $note = __('PayPal account must be upgraded before this payment can be accepted', 'give'); |
|
| 459 | 459 | |
| 460 | 460 | break; |
| 461 | 461 | |
| 462 | 462 | case 'verify' : |
| 463 | 463 | |
| 464 | - $note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'give' ); |
|
| 464 | + $note = __('PayPal account is not verified. Verify account in order to accept this payment', 'give'); |
|
| 465 | 465 | |
| 466 | 466 | break; |
| 467 | 467 | |
| 468 | 468 | case 'other' : |
| 469 | 469 | |
| 470 | - $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'give' ); |
|
| 470 | + $note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance', 'give'); |
|
| 471 | 471 | |
| 472 | 472 | break; |
| 473 | 473 | |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | - if ( ! empty( $note ) ) { |
|
| 476 | + if ( ! empty($note)) { |
|
| 477 | 477 | |
| 478 | - give_insert_payment_note( $payment_id, $note ); |
|
| 478 | + give_insert_payment_note($payment_id, $note); |
|
| 479 | 479 | |
| 480 | 480 | } |
| 481 | 481 | } |
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2 ); |
|
| 485 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2); |
|
| 486 | 486 | |
| 487 | 487 | /** |
| 488 | 488 | * Process PayPal IPN Refunds |
@@ -493,32 +493,32 @@ discard block |
||
| 493 | 493 | * |
| 494 | 494 | * @return void |
| 495 | 495 | */ |
| 496 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
| 496 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
| 497 | 497 | |
| 498 | 498 | // Collect payment details |
| 499 | 499 | |
| 500 | - if ( empty( $payment_id ) ) { |
|
| 500 | + if (empty($payment_id)) { |
|
| 501 | 501 | return; |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | - if ( get_post_status( $payment_id ) == 'refunded' ) { |
|
| 504 | + if (get_post_status($payment_id) == 'refunded') { |
|
| 505 | 505 | return; // Only refund payments once |
| 506 | 506 | } |
| 507 | 507 | |
| 508 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 508 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 509 | 509 | $refund_amount = $data['payment_gross'] * - 1; |
| 510 | 510 | |
| 511 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
| 511 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
| 512 | 512 | |
| 513 | - give_insert_payment_note( $payment_id, sprintf( __( 'Partial PayPal refund processed: %s', 'give' ), $data['parent_txn_id'] ) ); |
|
| 513 | + give_insert_payment_note($payment_id, sprintf(__('Partial PayPal refund processed: %s', 'give'), $data['parent_txn_id'])); |
|
| 514 | 514 | |
| 515 | 515 | return; // This is a partial refund |
| 516 | 516 | |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - give_insert_payment_note( $payment_id, sprintf( __( 'PayPal Payment #%s Refunded for reason: %s', 'give' ), $data['parent_txn_id'], $data['reason_code'] ) ); |
|
| 520 | - give_insert_payment_note( $payment_id, sprintf( __( 'PayPal Refund Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
| 521 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
| 519 | + give_insert_payment_note($payment_id, sprintf(__('PayPal Payment #%s Refunded for reason: %s', 'give'), $data['parent_txn_id'], $data['reason_code'])); |
|
| 520 | + give_insert_payment_note($payment_id, sprintf(__('PayPal Refund Transaction ID: %s', 'give'), $data['txn_id'])); |
|
| 521 | + give_update_payment_status($payment_id, 'refunded'); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | /** |
@@ -530,24 +530,24 @@ discard block |
||
| 530 | 530 | * |
| 531 | 531 | * @return string |
| 532 | 532 | */ |
| 533 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
| 533 | +function give_get_paypal_redirect($ssl_check = false) { |
|
| 534 | 534 | |
| 535 | - if ( is_ssl() || ! $ssl_check ) { |
|
| 535 | + if (is_ssl() || ! $ssl_check) { |
|
| 536 | 536 | $protocal = 'https://'; |
| 537 | 537 | } else { |
| 538 | 538 | $protocal = 'http://'; |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | // Check the current payment mode |
| 542 | - if ( give_is_test_mode() ) { |
|
| 542 | + if (give_is_test_mode()) { |
|
| 543 | 543 | // Test mode |
| 544 | - $paypal_uri = $protocal . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
| 544 | + $paypal_uri = $protocal.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
| 545 | 545 | } else { |
| 546 | 546 | // Live mode |
| 547 | - $paypal_uri = $protocal . 'www.paypal.com/cgi-bin/webscr'; |
|
| 547 | + $paypal_uri = $protocal.'www.paypal.com/cgi-bin/webscr'; |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
| 550 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | /** |
@@ -558,9 +558,9 @@ discard block |
||
| 558 | 558 | */ |
| 559 | 559 | function give_get_paypal_page_style() { |
| 560 | 560 | |
| 561 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
| 561 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
| 562 | 562 | |
| 563 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
| 563 | + return apply_filters('give_paypal_page_style', $page_style); |
|
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | /** |
@@ -571,27 +571,27 @@ discard block |
||
| 571 | 571 | * @since 1.0 |
| 572 | 572 | * @return string |
| 573 | 573 | */ |
| 574 | -function give_paypal_success_page_content( $content ) { |
|
| 574 | +function give_paypal_success_page_content($content) { |
|
| 575 | 575 | |
| 576 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
| 576 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
| 577 | 577 | return $content; |
| 578 | 578 | } |
| 579 | 579 | |
| 580 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
| 580 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
| 581 | 581 | |
| 582 | - if ( ! $payment_id ) { |
|
| 582 | + if ( ! $payment_id) { |
|
| 583 | 583 | $session = give_get_purchase_session(); |
| 584 | - $payment_id = give_get_purchase_id_by_key( $session['purchase_key'] ); |
|
| 584 | + $payment_id = give_get_purchase_id_by_key($session['purchase_key']); |
|
| 585 | 585 | } |
| 586 | 586 | |
| 587 | - $payment = get_post( $payment_id ); |
|
| 587 | + $payment = get_post($payment_id); |
|
| 588 | 588 | |
| 589 | - if ( $payment && 'pending' == $payment->post_status ) { |
|
| 589 | + if ($payment && 'pending' == $payment->post_status) { |
|
| 590 | 590 | |
| 591 | 591 | // Payment is still pending so show processing indicator to fix the Race Condition, issue # |
| 592 | 592 | ob_start(); |
| 593 | 593 | |
| 594 | - give_get_template_part( 'payment', 'processing' ); |
|
| 594 | + give_get_template_part('payment', 'processing'); |
|
| 595 | 595 | |
| 596 | 596 | $content = ob_get_clean(); |
| 597 | 597 | |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | |
| 602 | 602 | } |
| 603 | 603 | |
| 604 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
| 604 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
| 605 | 605 | |
| 606 | 606 | /** |
| 607 | 607 | * Given a Payment ID, extract the transaction ID |
@@ -612,22 +612,22 @@ discard block |
||
| 612 | 612 | * |
| 613 | 613 | * @return string Transaction ID |
| 614 | 614 | */ |
| 615 | -function give_paypal_get_payment_transaction_id( $payment_id ) { |
|
| 615 | +function give_paypal_get_payment_transaction_id($payment_id) { |
|
| 616 | 616 | |
| 617 | 617 | $transaction_id = ''; |
| 618 | - $notes = give_get_payment_notes( $payment_id ); |
|
| 618 | + $notes = give_get_payment_notes($payment_id); |
|
| 619 | 619 | |
| 620 | - foreach ( $notes as $note ) { |
|
| 621 | - if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) { |
|
| 620 | + foreach ($notes as $note) { |
|
| 621 | + if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) { |
|
| 622 | 622 | $transaction_id = $match[1]; |
| 623 | 623 | continue; |
| 624 | 624 | } |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | - return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
| 627 | + return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id); |
|
| 628 | 628 | } |
| 629 | 629 | |
| 630 | -add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 ); |
|
| 630 | +add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1); |
|
| 631 | 631 | |
| 632 | 632 | /** |
| 633 | 633 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -639,13 +639,13 @@ discard block |
||
| 639 | 639 | * |
| 640 | 640 | * @return string A link to the PayPal transaction details |
| 641 | 641 | */ |
| 642 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
| 642 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
| 643 | 643 | |
| 644 | 644 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
| 645 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
| 645 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
| 646 | 646 | |
| 647 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
| 647 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
| 648 | 648 | |
| 649 | 649 | } |
| 650 | 650 | |
| 651 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
| 651 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |
|
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -32,25 +32,25 @@ discard block |
||
| 32 | 32 | give_setup_post_types(); |
| 33 | 33 | |
| 34 | 34 | // Clear the permalinks |
| 35 | - flush_rewrite_rules( false ); |
|
| 35 | + flush_rewrite_rules(false); |
|
| 36 | 36 | |
| 37 | 37 | // Add Upgraded From Option |
| 38 | - $current_version = get_option( 'give_version' ); |
|
| 39 | - if ( $current_version ) { |
|
| 40 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
| 38 | + $current_version = get_option('give_version'); |
|
| 39 | + if ($current_version) { |
|
| 40 | + update_option('give_version_upgraded_from', $current_version); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // Setup some default options |
| 44 | 44 | $options = array(); |
| 45 | 45 | |
| 46 | 46 | // Checks if the Success Page option exists AND that the page exists |
| 47 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
| 47 | + if ( ! get_post(give_get_option('success_page'))) { |
|
| 48 | 48 | |
| 49 | 49 | // Purchase Confirmation (Success) Page |
| 50 | 50 | $success = wp_insert_post( |
| 51 | 51 | array( |
| 52 | - 'post_title' => __( 'Donation Confirmation', 'give' ), |
|
| 53 | - 'post_content' => __( 'Thank you for your donation! [give_receipt]', 'give' ), |
|
| 52 | + 'post_title' => __('Donation Confirmation', 'give'), |
|
| 53 | + 'post_content' => __('Thank you for your donation! [give_receipt]', 'give'), |
|
| 54 | 54 | 'post_status' => 'publish', |
| 55 | 55 | 'post_author' => 1, |
| 56 | 56 | 'post_type' => 'page', |
@@ -63,13 +63,13 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // Checks if the Failure Page option exists AND that the page exists |
| 66 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
| 66 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
| 67 | 67 | |
| 68 | 68 | // Failed Purchase Page |
| 69 | 69 | $failed = wp_insert_post( |
| 70 | 70 | array( |
| 71 | - 'post_title' => __( 'Transaction Failed', 'give' ), |
|
| 72 | - 'post_content' => __( 'Your transaction failed, please try again or contact site support.', 'give' ), |
|
| 71 | + 'post_title' => __('Transaction Failed', 'give'), |
|
| 72 | + 'post_content' => __('Your transaction failed, please try again or contact site support.', 'give'), |
|
| 73 | 73 | 'post_status' => 'publish', |
| 74 | 74 | 'post_author' => 1, |
| 75 | 75 | 'post_type' => 'page', |
@@ -81,11 +81,11 @@ discard block |
||
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // Checks if the History Page option exists AND that the page exists |
| 84 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
| 84 | + if ( ! get_post(give_get_option('history_page'))) { |
|
| 85 | 85 | // Purchase History (History) Page |
| 86 | 86 | $history = wp_insert_post( |
| 87 | 87 | array( |
| 88 | - 'post_title' => __( 'Donation History', 'give' ), |
|
| 88 | + 'post_title' => __('Donation History', 'give'), |
|
| 89 | 89 | 'post_content' => '[donation_history]', |
| 90 | 90 | 'post_status' => 'publish', |
| 91 | 91 | 'post_author' => 1, |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency |
| 101 | - if ( empty( $current_version ) ) { |
|
| 101 | + if (empty($current_version)) { |
|
| 102 | 102 | $options['base_country'] = 'US'; |
| 103 | 103 | $options['test_mode'] = 1; |
| 104 | 104 | $options['currency'] = 'USD'; |
@@ -115,12 +115,12 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | // Populate some default values |
| 118 | - update_option( 'give_settings', array_merge( $give_options, $options ) ); |
|
| 119 | - update_option( 'give_version', GIVE_VERSION ); |
|
| 118 | + update_option('give_settings', array_merge($give_options, $options)); |
|
| 119 | + update_option('give_version', GIVE_VERSION); |
|
| 120 | 120 | |
| 121 | 121 | //Update Version Number |
| 122 | - if ( $current_version ) { |
|
| 123 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
| 122 | + if ($current_version) { |
|
| 123 | + update_option('give_version_upgraded_from', $current_version); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // Create Give roles |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | $roles->add_caps(); |
| 130 | 130 | |
| 131 | 131 | $api = new Give_API(); |
| 132 | - update_option( 'give_default_api_version', 'v' . $api->get_version() ); |
|
| 132 | + update_option('give_default_api_version', 'v'.$api->get_version()); |
|
| 133 | 133 | |
| 134 | 134 | // Create the customers database |
| 135 | 135 | @Give()->customers->create_table(); |
@@ -138,32 +138,32 @@ discard block |
||
| 138 | 138 | Give()->session->use_php_sessions(); |
| 139 | 139 | |
| 140 | 140 | // Add a temporary option to note that Give pages have been created |
| 141 | - set_transient( '_give_installed', $options, 30 ); |
|
| 141 | + set_transient('_give_installed', $options, 30); |
|
| 142 | 142 | |
| 143 | 143 | // Bail if activating from network, or bulk |
| 144 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 144 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
| 145 | 145 | return; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - if ( ! $current_version ) { |
|
| 149 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
| 148 | + if ( ! $current_version) { |
|
| 149 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
| 150 | 150 | |
| 151 | 151 | // When new upgrade routines are added, mark them as complete on fresh install |
| 152 | 152 | $upgrade_routines = array( |
| 153 | 153 | 'upgrade_donor_payments_association' |
| 154 | 154 | ); |
| 155 | 155 | |
| 156 | - foreach ( $upgrade_routines as $upgrade ) { |
|
| 157 | - give_set_upgrade_complete( $upgrade ); |
|
| 156 | + foreach ($upgrade_routines as $upgrade) { |
|
| 157 | + give_set_upgrade_complete($upgrade); |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | // Add the transient to redirect |
| 162 | - set_transient( '_give_activation_redirect', true, 30 ); |
|
| 162 | + set_transient('_give_activation_redirect', true, 30); |
|
| 163 | 163 | |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | -register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
| 166 | +register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
| 167 | 167 | |
| 168 | 168 | /** |
| 169 | 169 | * Post-installation |
@@ -175,14 +175,14 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | function give_after_install() { |
| 177 | 177 | |
| 178 | - if ( ! is_admin() ) { |
|
| 178 | + if ( ! is_admin()) { |
|
| 179 | 179 | return; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - $give_options = get_transient( '_give_installed' ); |
|
| 182 | + $give_options = get_transient('_give_installed'); |
|
| 183 | 183 | |
| 184 | 184 | // Exit if not in admin or the transient doesn't exist |
| 185 | - if ( false === $give_options ) { |
|
| 185 | + if (false === $give_options) { |
|
| 186 | 186 | return; |
| 187 | 187 | } |
| 188 | 188 | |
@@ -190,13 +190,13 @@ discard block |
||
| 190 | 190 | @Give()->customers->create_table(); |
| 191 | 191 | |
| 192 | 192 | // Delete the transient |
| 193 | - delete_transient( '_give_installed' ); |
|
| 193 | + delete_transient('_give_installed'); |
|
| 194 | 194 | |
| 195 | - do_action( 'give_after_install', $give_options ); |
|
| 195 | + do_action('give_after_install', $give_options); |
|
| 196 | 196 | |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | -add_action( 'admin_init', 'give_after_install' ); |
|
| 199 | +add_action('admin_init', 'give_after_install'); |
|
| 200 | 200 | |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -211,11 +211,11 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | global $wp_roles; |
| 213 | 213 | |
| 214 | - if ( ! is_object( $wp_roles ) ) { |
|
| 214 | + if ( ! is_object($wp_roles)) { |
|
| 215 | 215 | return; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
| 218 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
| 219 | 219 | |
| 220 | 220 | // Create Give shop roles |
| 221 | 221 | $roles = new Give_Roles; |
@@ -226,4 +226,4 @@ discard block |
||
| 226 | 226 | |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
| 229 | +add_action('admin_init', 'give_install_roles_on_network'); |
|
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -25,10 +25,10 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @return string Login form |
| 27 | 27 | */ |
| 28 | -function give_login_form( $redirect = '' ) { |
|
| 28 | +function give_login_form($redirect = '') { |
|
| 29 | 29 | global $give_options, $give_login_redirect; |
| 30 | 30 | |
| 31 | - if ( empty( $redirect ) ) { |
|
| 31 | + if (empty($redirect)) { |
|
| 32 | 32 | $redirect = give_get_current_page_url(); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | ob_start(); |
| 38 | 38 | |
| 39 | - give_get_template_part( 'shortcode', 'login' ); |
|
| 39 | + give_get_template_part('shortcode', 'login'); |
|
| 40 | 40 | |
| 41 | - return apply_filters( 'give_login_form', ob_get_clean() ); |
|
| 41 | + return apply_filters('give_login_form', ob_get_clean()); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -52,10 +52,10 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return string Register form |
| 54 | 54 | */ |
| 55 | -function give_register_form( $redirect = '' ) { |
|
| 55 | +function give_register_form($redirect = '') { |
|
| 56 | 56 | global $give_options, $give_register_redirect; |
| 57 | 57 | |
| 58 | - if ( empty( $redirect ) ) { |
|
| 58 | + if (empty($redirect)) { |
|
| 59 | 59 | $redirect = give_get_current_page_url(); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | ob_start(); |
| 65 | 65 | |
| 66 | - if ( ! is_user_logged_in() ) { |
|
| 67 | - give_get_template_part( 'shortcode', 'register' ); |
|
| 66 | + if ( ! is_user_logged_in()) { |
|
| 67 | + give_get_template_part('shortcode', 'register'); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - return apply_filters( 'give_register_form', ob_get_clean() ); |
|
| 70 | + return apply_filters('give_register_form', ob_get_clean()); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -79,34 +79,34 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @return void |
| 81 | 81 | */ |
| 82 | -function give_process_login_form( $data ) { |
|
| 83 | - if ( wp_verify_nonce( $data['give_login_nonce'], 'give-login-nonce' ) ) { |
|
| 84 | - $user_data = get_user_by( 'login', $data['give_user_login'] ); |
|
| 85 | - if ( ! $user_data ) { |
|
| 86 | - $user_data = get_user_by( 'email', $data['give_user_login'] ); |
|
| 82 | +function give_process_login_form($data) { |
|
| 83 | + if (wp_verify_nonce($data['give_login_nonce'], 'give-login-nonce')) { |
|
| 84 | + $user_data = get_user_by('login', $data['give_user_login']); |
|
| 85 | + if ( ! $user_data) { |
|
| 86 | + $user_data = get_user_by('email', $data['give_user_login']); |
|
| 87 | 87 | } |
| 88 | - if ( $user_data ) { |
|
| 88 | + if ($user_data) { |
|
| 89 | 89 | $user_ID = $user_data->ID; |
| 90 | 90 | $user_email = $user_data->user_email; |
| 91 | - if ( wp_check_password( $data['give_user_pass'], $user_data->user_pass, $user_data->ID ) ) { |
|
| 92 | - give_log_user_in( $user_data->ID, $data['give_user_login'], $data['give_user_pass'] ); |
|
| 91 | + if (wp_check_password($data['give_user_pass'], $user_data->user_pass, $user_data->ID)) { |
|
| 92 | + give_log_user_in($user_data->ID, $data['give_user_login'], $data['give_user_pass']); |
|
| 93 | 93 | } else { |
| 94 | - give_set_error( 'password_incorrect', __( 'The password you entered is incorrect', 'give' ) ); |
|
| 94 | + give_set_error('password_incorrect', __('The password you entered is incorrect', 'give')); |
|
| 95 | 95 | } |
| 96 | 96 | } else { |
| 97 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist', 'give' ) ); |
|
| 97 | + give_set_error('username_incorrect', __('The username you entered does not exist', 'give')); |
|
| 98 | 98 | } |
| 99 | 99 | // Check for errors and redirect if none present |
| 100 | 100 | $errors = give_get_errors(); |
| 101 | - if ( ! $errors ) { |
|
| 102 | - $redirect = apply_filters( 'give_login_redirect', $data['give_redirect'], $user_ID ); |
|
| 103 | - wp_redirect( $redirect ); |
|
| 101 | + if ( ! $errors) { |
|
| 102 | + $redirect = apply_filters('give_login_redirect', $data['give_redirect'], $user_ID); |
|
| 103 | + wp_redirect($redirect); |
|
| 104 | 104 | give_die(); |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | -add_action( 'give_user_login', 'give_process_login_form' ); |
|
| 109 | +add_action('give_user_login', 'give_process_login_form'); |
|
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | 112 | * Log User In |
@@ -119,15 +119,15 @@ discard block |
||
| 119 | 119 | * |
| 120 | 120 | * @return void |
| 121 | 121 | */ |
| 122 | -function give_log_user_in( $user_id, $user_login, $user_pass ) { |
|
| 123 | - if ( $user_id < 1 ) { |
|
| 122 | +function give_log_user_in($user_id, $user_login, $user_pass) { |
|
| 123 | + if ($user_id < 1) { |
|
| 124 | 124 | return; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - wp_set_auth_cookie( $user_id ); |
|
| 128 | - wp_set_current_user( $user_id, $user_login ); |
|
| 129 | - do_action( 'wp_login', $user_login, get_userdata( $user_id ) ); |
|
| 130 | - do_action( 'give_log_user_in', $user_id, $user_login, $user_pass ); |
|
| 127 | + wp_set_auth_cookie($user_id); |
|
| 128 | + wp_set_current_user($user_id, $user_login); |
|
| 129 | + do_action('wp_login', $user_login, get_userdata($user_id)); |
|
| 130 | + do_action('give_log_user_in', $user_id, $user_login, $user_pass); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
@@ -140,70 +140,70 @@ discard block |
||
| 140 | 140 | * |
| 141 | 141 | * @return void |
| 142 | 142 | */ |
| 143 | -function give_process_register_form( $data ) { |
|
| 143 | +function give_process_register_form($data) { |
|
| 144 | 144 | |
| 145 | - if ( is_user_logged_in() ) { |
|
| 145 | + if (is_user_logged_in()) { |
|
| 146 | 146 | return; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - if ( empty( $_POST['give_register_submit'] ) ) { |
|
| 149 | + if (empty($_POST['give_register_submit'])) { |
|
| 150 | 150 | return; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - do_action( 'give_pre_process_register_form' ); |
|
| 153 | + do_action('give_pre_process_register_form'); |
|
| 154 | 154 | |
| 155 | - if ( empty( $data['give_user_login'] ) ) { |
|
| 156 | - give_set_error( 'empty_username', __( 'Invalid username', 'give' ) ); |
|
| 155 | + if (empty($data['give_user_login'])) { |
|
| 156 | + give_set_error('empty_username', __('Invalid username', 'give')); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if ( username_exists( $data['give_user_login'] ) ) { |
|
| 160 | - give_set_error( 'username_unavailable', __( 'Username already taken', 'give' ) ); |
|
| 159 | + if (username_exists($data['give_user_login'])) { |
|
| 160 | + give_set_error('username_unavailable', __('Username already taken', 'give')); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - if ( ! validate_username( $data['give_user_login'] ) ) { |
|
| 164 | - give_set_error( 'username_invalid', __( 'Invalid username', 'give' ) ); |
|
| 163 | + if ( ! validate_username($data['give_user_login'])) { |
|
| 164 | + give_set_error('username_invalid', __('Invalid username', 'give')); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - if ( email_exists( $data['give_user_email'] ) ) { |
|
| 168 | - give_set_error( 'email_unavailable', __( 'Email address already taken', 'give' ) ); |
|
| 167 | + if (email_exists($data['give_user_email'])) { |
|
| 168 | + give_set_error('email_unavailable', __('Email address already taken', 'give')); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) { |
|
| 172 | - give_set_error( 'email_invalid', __( 'Invalid email', 'give' ) ); |
|
| 171 | + if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) { |
|
| 172 | + give_set_error('email_invalid', __('Invalid email', 'give')); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) { |
|
| 176 | - give_set_error( 'payment_email_invalid', __( 'Invalid payment email', 'give' ) ); |
|
| 175 | + if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) { |
|
| 176 | + give_set_error('payment_email_invalid', __('Invalid payment email', 'give')); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if ( empty( $_POST['give_user_pass'] ) ) { |
|
| 180 | - give_set_error( 'empty_password', __( 'Please enter a password', 'give' ) ); |
|
| 179 | + if (empty($_POST['give_user_pass'])) { |
|
| 180 | + give_set_error('empty_password', __('Please enter a password', 'give')); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) { |
|
| 184 | - give_set_error( 'password_mismatch', __( 'Passwords do not match', 'give' ) ); |
|
| 183 | + if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) { |
|
| 184 | + give_set_error('password_mismatch', __('Passwords do not match', 'give')); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - do_action( 'give_process_register_form' ); |
|
| 187 | + do_action('give_process_register_form'); |
|
| 188 | 188 | |
| 189 | 189 | // Check for errors and redirect if none present |
| 190 | 190 | $errors = give_get_errors(); |
| 191 | 191 | |
| 192 | - if ( empty( $errors ) ) { |
|
| 192 | + if (empty($errors)) { |
|
| 193 | 193 | |
| 194 | - $redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] ); |
|
| 194 | + $redirect = apply_filters('give_register_redirect', $data['give_redirect']); |
|
| 195 | 195 | |
| 196 | - give_register_and_login_new_user( array( |
|
| 196 | + give_register_and_login_new_user(array( |
|
| 197 | 197 | 'user_login' => $data['give_user_login'], |
| 198 | 198 | 'user_pass' => $data['give_user_pass'], |
| 199 | 199 | 'user_email' => $data['give_user_email'], |
| 200 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
| 201 | - 'role' => get_option( 'default_role' ) |
|
| 202 | - ) ); |
|
| 200 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
| 201 | + 'role' => get_option('default_role') |
|
| 202 | + )); |
|
| 203 | 203 | |
| 204 | - wp_redirect( $redirect ); |
|
| 204 | + wp_redirect($redirect); |
|
| 205 | 205 | give_die(); |
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | -add_action( 'give_user_register', 'give_process_register_form' ); |
|
| 210 | 209 | \ No newline at end of file |
| 210 | +add_action('give_user_register', 'give_process_register_form'); |
|
| 211 | 211 | \ No newline at end of file |
@@ -142,8 +142,10 @@ |
||
| 142 | 142 | |
| 143 | 143 | if ( is_front_page() ) : |
| 144 | 144 | $page_url = home_url(); |
| 145 | - else : |
|
| 145 | + else { |
|
| 146 | + : |
|
| 146 | 147 | $page_url = 'http'; |
| 148 | + } |
|
| 147 | 149 | |
| 148 | 150 | if ( isset( $_SERVER["HTTPS"] ) && $_SERVER["HTTPS"] == "on" ) { |
| 149 | 151 | $page_url .= "s"; |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | * Returns the webhost this site is using if possible |
| 336 | 336 | * |
| 337 | 337 | * @since 1.0 |
| 338 | - * @return mixed string $host if detected, false otherwise |
|
| 338 | + * @return string string $host if detected, false otherwise |
|
| 339 | 339 | */ |
| 340 | 340 | function give_get_host() { |
| 341 | 341 | $host = false; |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | * |
| 507 | 507 | * @since 1.0 |
| 508 | 508 | * |
| 509 | - * @param unknown $n |
|
| 509 | + * @param integer $n |
|
| 510 | 510 | * |
| 511 | 511 | * @return string Short month name |
| 512 | 512 | */ |
@@ -636,9 +636,9 @@ discard block |
||
| 636 | 636 | /** |
| 637 | 637 | * Create SVG library function |
| 638 | 638 | * |
| 639 | - * @param $icon |
|
| 639 | + * @param string $icon |
|
| 640 | 640 | * |
| 641 | - * @return mixed |
|
| 641 | + * @return string |
|
| 642 | 642 | */ |
| 643 | 643 | function give_svg_icons( $icon ) { |
| 644 | 644 | |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | * |
| 696 | 696 | * @param array $input A multi-dimensional array (record set) from which to pull |
| 697 | 697 | * a column of values. |
| 698 | - * @param mixed $columnKey The column of values to return. This value may be the |
|
| 698 | + * @param string $columnKey The column of values to return. This value may be the |
|
| 699 | 699 | * integer key of the column you wish to retrieve, or it |
| 700 | 700 | * may be the string key name for an associative array. |
| 701 | 701 | * @param mixed $indexKey (Optional.) The column to use as the index/keys for |
@@ -727,10 +727,10 @@ discard block |
||
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | if ( ! is_int( $params[1] ) |
| 730 | - && ! is_float( $params[1] ) |
|
| 731 | - && ! is_string( $params[1] ) |
|
| 732 | - && $params[1] !== null |
|
| 733 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
| 730 | + && ! is_float( $params[1] ) |
|
| 731 | + && ! is_string( $params[1] ) |
|
| 732 | + && $params[1] !== null |
|
| 733 | + && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
| 734 | 734 | ) { |
| 735 | 735 | trigger_error( 'array_column(): The column key should be either a string or an integer', E_USER_WARNING ); |
| 736 | 736 | |
@@ -738,10 +738,10 @@ discard block |
||
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | if ( isset( $params[2] ) |
| 741 | - && ! is_int( $params[2] ) |
|
| 742 | - && ! is_float( $params[2] ) |
|
| 743 | - && ! is_string( $params[2] ) |
|
| 744 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
| 741 | + && ! is_int( $params[2] ) |
|
| 742 | + && ! is_float( $params[2] ) |
|
| 743 | + && ! is_string( $params[2] ) |
|
| 744 | + && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
| 745 | 745 | ) { |
| 746 | 746 | trigger_error( 'array_column(): The index key should be either a string or an integer', E_USER_WARNING ); |
| 747 | 747 | |
@@ -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,9 +24,9 @@ discard block |
||
| 24 | 24 | function give_is_test_mode() { |
| 25 | 25 | global $give_options; |
| 26 | 26 | |
| 27 | - $ret = ! empty( $give_options['test_mode'] ); |
|
| 27 | + $ret = ! empty($give_options['test_mode']); |
|
| 28 | 28 | |
| 29 | - return (bool) apply_filters( 'give_is_test_mode', $ret ); |
|
| 29 | + return (bool) apply_filters('give_is_test_mode', $ret); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | function give_get_currency() { |
| 39 | 39 | global $give_options; |
| 40 | - $currency = isset( $give_options['currency'] ) ? $give_options['currency'] : 'USD'; |
|
| 40 | + $currency = isset($give_options['currency']) ? $give_options['currency'] : 'USD'; |
|
| 41 | 41 | |
| 42 | - return apply_filters( 'give_currency', $currency ); |
|
| 42 | + return apply_filters('give_currency', $currency); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | |
@@ -51,36 +51,36 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | function give_get_currencies() { |
| 53 | 53 | $currencies = array( |
| 54 | - 'USD' => __( 'US Dollars ($)', 'give' ), |
|
| 55 | - 'EUR' => __( 'Euros (€)', 'give' ), |
|
| 56 | - 'GBP' => __( 'Pounds Sterling (£)', 'give' ), |
|
| 57 | - 'AUD' => __( 'Australian Dollars ($)', 'give' ), |
|
| 58 | - 'BRL' => __( 'Brazilian Real (R$)', 'give' ), |
|
| 59 | - 'CAD' => __( 'Canadian Dollars ($)', 'give' ), |
|
| 60 | - 'CZK' => __( 'Czech Koruna', 'give' ), |
|
| 61 | - 'DKK' => __( 'Danish Krone', 'give' ), |
|
| 62 | - 'HKD' => __( 'Hong Kong Dollar ($)', 'give' ), |
|
| 63 | - 'HUF' => __( 'Hungarian Forint', 'give' ), |
|
| 64 | - 'ILS' => __( 'Israeli Shekel (₪)', 'give' ), |
|
| 65 | - 'JPY' => __( 'Japanese Yen (¥)', 'give' ), |
|
| 66 | - 'MYR' => __( 'Malaysian Ringgits', 'give' ), |
|
| 67 | - 'MXN' => __( 'Mexican Peso ($)', 'give' ), |
|
| 68 | - 'NZD' => __( 'New Zealand Dollar ($)', 'give' ), |
|
| 69 | - 'NOK' => __( 'Norwegian Krone (Kr.)', 'give' ), |
|
| 70 | - 'PHP' => __( 'Philippine Pesos', 'give' ), |
|
| 71 | - 'PLN' => __( 'Polish Zloty', 'give' ), |
|
| 72 | - 'SGD' => __( 'Singapore Dollar ($)', 'give' ), |
|
| 73 | - 'SEK' => __( 'Swedish Krona', 'give' ), |
|
| 74 | - 'CHF' => __( 'Swiss Franc', 'give' ), |
|
| 75 | - 'TWD' => __( 'Taiwan New Dollars', 'give' ), |
|
| 76 | - 'THB' => __( 'Thai Baht (฿)', 'give' ), |
|
| 77 | - 'INR' => __( 'Indian Rupee (₹)', 'give' ), |
|
| 78 | - 'TRY' => __( 'Turkish Lira (₺)', 'give' ), |
|
| 79 | - 'RIAL' => __( 'Iranian Rial (﷼)', 'give' ), |
|
| 80 | - 'RUB' => __( 'Russian Rubles', 'give' ) |
|
| 54 | + 'USD' => __('US Dollars ($)', 'give'), |
|
| 55 | + 'EUR' => __('Euros (€)', 'give'), |
|
| 56 | + 'GBP' => __('Pounds Sterling (£)', 'give'), |
|
| 57 | + 'AUD' => __('Australian Dollars ($)', 'give'), |
|
| 58 | + 'BRL' => __('Brazilian Real (R$)', 'give'), |
|
| 59 | + 'CAD' => __('Canadian Dollars ($)', 'give'), |
|
| 60 | + 'CZK' => __('Czech Koruna', 'give'), |
|
| 61 | + 'DKK' => __('Danish Krone', 'give'), |
|
| 62 | + 'HKD' => __('Hong Kong Dollar ($)', 'give'), |
|
| 63 | + 'HUF' => __('Hungarian Forint', 'give'), |
|
| 64 | + 'ILS' => __('Israeli Shekel (₪)', 'give'), |
|
| 65 | + 'JPY' => __('Japanese Yen (¥)', 'give'), |
|
| 66 | + 'MYR' => __('Malaysian Ringgits', 'give'), |
|
| 67 | + 'MXN' => __('Mexican Peso ($)', 'give'), |
|
| 68 | + 'NZD' => __('New Zealand Dollar ($)', 'give'), |
|
| 69 | + 'NOK' => __('Norwegian Krone (Kr.)', 'give'), |
|
| 70 | + 'PHP' => __('Philippine Pesos', 'give'), |
|
| 71 | + 'PLN' => __('Polish Zloty', 'give'), |
|
| 72 | + 'SGD' => __('Singapore Dollar ($)', 'give'), |
|
| 73 | + 'SEK' => __('Swedish Krona', 'give'), |
|
| 74 | + 'CHF' => __('Swiss Franc', 'give'), |
|
| 75 | + 'TWD' => __('Taiwan New Dollars', 'give'), |
|
| 76 | + 'THB' => __('Thai Baht (฿)', 'give'), |
|
| 77 | + 'INR' => __('Indian Rupee (₹)', 'give'), |
|
| 78 | + 'TRY' => __('Turkish Lira (₺)', 'give'), |
|
| 79 | + 'RIAL' => __('Iranian Rial (﷼)', 'give'), |
|
| 80 | + 'RUB' => __('Russian Rubles', 'give') |
|
| 81 | 81 | ); |
| 82 | 82 | |
| 83 | - return apply_filters( 'give_currencies', $currencies ); |
|
| 83 | + return apply_filters('give_currencies', $currencies); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @return string The symbol to use for the currency |
| 96 | 96 | */ |
| 97 | -function give_currency_symbol( $currency = '' ) { |
|
| 97 | +function give_currency_symbol($currency = '') { |
|
| 98 | 98 | |
| 99 | - if ( empty( $currency ) ) { |
|
| 99 | + if (empty($currency)) { |
|
| 100 | 100 | $currency = give_get_currency(); |
| 101 | 101 | } |
| 102 | - switch ( $currency ) : |
|
| 102 | + switch ($currency) : |
|
| 103 | 103 | case "GBP" : |
| 104 | 104 | $symbol = '£'; |
| 105 | 105 | break; |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | break; |
| 129 | 129 | endswitch; |
| 130 | 130 | |
| 131 | - return apply_filters( 'give_currency_symbol', $symbol, $currency ); |
|
| 131 | + return apply_filters('give_currency_symbol', $symbol, $currency); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | |
@@ -140,25 +140,25 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | function give_get_current_page_url() { |
| 142 | 142 | |
| 143 | - if ( is_front_page() ) : |
|
| 143 | + if (is_front_page()) : |
|
| 144 | 144 | $page_url = home_url(); |
| 145 | 145 | else : |
| 146 | 146 | $page_url = 'http'; |
| 147 | 147 | |
| 148 | - if ( isset( $_SERVER["HTTPS"] ) && $_SERVER["HTTPS"] == "on" ) { |
|
| 148 | + if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") { |
|
| 149 | 149 | $page_url .= "s"; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | $page_url .= "://"; |
| 153 | 153 | |
| 154 | - if ( isset( $_SERVER["SERVER_PORT"] ) && $_SERVER["SERVER_PORT"] != "80" ) { |
|
| 155 | - $page_url .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; |
|
| 154 | + if (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] != "80") { |
|
| 155 | + $page_url .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; |
|
| 156 | 156 | } else { |
| 157 | - $page_url .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; |
|
| 157 | + $page_url .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; |
|
| 158 | 158 | } |
| 159 | 159 | endif; |
| 160 | 160 | |
| 161 | - return apply_filters( 'give_get_current_page_url', esc_url( $page_url ) ); |
|
| 161 | + return apply_filters('give_get_current_page_url', esc_url($page_url)); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | |
@@ -179,15 +179,15 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | $gateways = give_get_enabled_payment_gateways(); |
| 181 | 181 | |
| 182 | - if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) { |
|
| 182 | + if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) { |
|
| 183 | 183 | $ret = true; |
| 184 | - } else if ( count( $gateways ) == 1 ) { |
|
| 184 | + } else if (count($gateways) == 1) { |
|
| 185 | 185 | $ret = false; |
| 186 | - } else if ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) { |
|
| 186 | + } else if (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) { |
|
| 187 | 187 | $ret = false; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - return (bool) apply_filters( 'give_verify_credit_cards', $ret ); |
|
| 190 | + return (bool) apply_filters('give_verify_credit_cards', $ret); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | |
@@ -202,9 +202,9 @@ discard block |
||
| 202 | 202 | |
| 203 | 203 | global $give_options; |
| 204 | 204 | |
| 205 | - $ret = ! empty( $give_options['logged_in_only'] ); |
|
| 205 | + $ret = ! empty($give_options['logged_in_only']); |
|
| 206 | 206 | |
| 207 | - return (bool) apply_filters( 'give_logged_in_only', $ret ); |
|
| 207 | + return (bool) apply_filters('give_logged_in_only', $ret); |
|
| 208 | 208 | |
| 209 | 209 | } |
| 210 | 210 | |
@@ -218,26 +218,26 @@ discard block |
||
| 218 | 218 | function give_get_timezone_id() { |
| 219 | 219 | |
| 220 | 220 | // if site timezone string exists, return it |
| 221 | - if ( $timezone = get_option( 'timezone_string' ) ) { |
|
| 221 | + if ($timezone = get_option('timezone_string')) { |
|
| 222 | 222 | return $timezone; |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | // get UTC offset, if it isn't set return UTC |
| 226 | - if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) { |
|
| 226 | + if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) { |
|
| 227 | 227 | return 'UTC'; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | // attempt to guess the timezone string from the UTC offset |
| 231 | - $timezone = timezone_name_from_abbr( '', $utc_offset ); |
|
| 231 | + $timezone = timezone_name_from_abbr('', $utc_offset); |
|
| 232 | 232 | |
| 233 | 233 | // last try, guess timezone string manually |
| 234 | - if ( $timezone === false ) { |
|
| 234 | + if ($timezone === false) { |
|
| 235 | 235 | |
| 236 | - $is_dst = date( 'I' ); |
|
| 236 | + $is_dst = date('I'); |
|
| 237 | 237 | |
| 238 | - foreach ( timezone_abbreviations_list() as $abbr ) { |
|
| 239 | - foreach ( $abbr as $city ) { |
|
| 240 | - if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) { |
|
| 238 | + foreach (timezone_abbreviations_list() as $abbr) { |
|
| 239 | + foreach ($abbr as $city) { |
|
| 240 | + if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) { |
|
| 241 | 241 | return $city['timezone_id']; |
| 242 | 242 | } |
| 243 | 243 | } |
@@ -261,17 +261,17 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | $ip = '127.0.0.1'; |
| 263 | 263 | |
| 264 | - if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
| 264 | + if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
| 265 | 265 | //check ip from share internet |
| 266 | 266 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
| 267 | - } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
| 267 | + } elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 268 | 268 | //to check ip is pass from proxy |
| 269 | 269 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
| 270 | - } elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
| 270 | + } elseif ( ! empty($_SERVER['REMOTE_ADDR'])) { |
|
| 271 | 271 | $ip = $_SERVER['REMOTE_ADDR']; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - return apply_filters( 'give_get_ip', $ip ); |
|
| 274 | + return apply_filters('give_get_ip', $ip); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | |
@@ -286,8 +286,8 @@ discard block |
||
| 286 | 286 | * |
| 287 | 287 | * @uses Give()->session->set() |
| 288 | 288 | */ |
| 289 | -function give_set_purchase_session( $purchase_data = array() ) { |
|
| 290 | - Give()->session->set( 'give_purchase', $purchase_data ); |
|
| 289 | +function give_set_purchase_session($purchase_data = array()) { |
|
| 290 | + Give()->session->set('give_purchase', $purchase_data); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | /** |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | * @return mixed array | false |
| 302 | 302 | */ |
| 303 | 303 | function give_get_purchase_session() { |
| 304 | - return Give()->session->get( 'give_purchase' ); |
|
| 304 | + return Give()->session->get('give_purchase'); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | /** |
@@ -316,14 +316,14 @@ discard block |
||
| 316 | 316 | * |
| 317 | 317 | * @return string |
| 318 | 318 | */ |
| 319 | -function give_get_purchase_summary( $purchase_data, $email = true ) { |
|
| 319 | +function give_get_purchase_summary($purchase_data, $email = true) { |
|
| 320 | 320 | $summary = ''; |
| 321 | 321 | |
| 322 | - if ( $email ) { |
|
| 323 | - $summary .= $purchase_data['user_email'] . ' - '; |
|
| 322 | + if ($email) { |
|
| 323 | + $summary .= $purchase_data['user_email'].' - '; |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - $summary .= get_the_title( $purchase_data['post_data']['give-form-id'] ); |
|
| 326 | + $summary .= get_the_title($purchase_data['post_data']['give-form-id']); |
|
| 327 | 327 | |
| 328 | 328 | return $summary; |
| 329 | 329 | } |
@@ -340,31 +340,31 @@ discard block |
||
| 340 | 340 | function give_get_host() { |
| 341 | 341 | $host = false; |
| 342 | 342 | |
| 343 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
| 343 | + if (defined('WPE_APIKEY')) { |
|
| 344 | 344 | $host = 'WP Engine'; |
| 345 | - } elseif ( defined( 'PAGELYBIN' ) ) { |
|
| 345 | + } elseif (defined('PAGELYBIN')) { |
|
| 346 | 346 | $host = 'Pagely'; |
| 347 | - } elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
| 347 | + } elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
| 348 | 348 | $host = 'ICDSoft'; |
| 349 | - } elseif ( DB_HOST == 'mysqlv5' ) { |
|
| 349 | + } elseif (DB_HOST == 'mysqlv5') { |
|
| 350 | 350 | $host = 'NetworkSolutions'; |
| 351 | - } elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
| 351 | + } elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
| 352 | 352 | $host = 'iPage'; |
| 353 | - } elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
| 353 | + } elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
| 354 | 354 | $host = 'IPower'; |
| 355 | - } elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
| 355 | + } elseif (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
| 356 | 356 | $host = 'MediaTemple Grid'; |
| 357 | - } elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
| 357 | + } elseif (strpos(DB_HOST, '.pair.com') !== false) { |
|
| 358 | 358 | $host = 'pair Networks'; |
| 359 | - } elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
| 359 | + } elseif (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
| 360 | 360 | $host = 'Rackspace Cloud'; |
| 361 | - } elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
| 361 | + } elseif (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
| 362 | 362 | $host = 'SysFix.eu Power Hosting'; |
| 363 | - } elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
| 363 | + } elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
| 364 | 364 | $host = 'Flywheel'; |
| 365 | 365 | } else { |
| 366 | 366 | // Adding a general fallback for data gathering |
| 367 | - $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME']; |
|
| 367 | + $host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME']; |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | return $host; |
@@ -380,67 +380,67 @@ discard block |
||
| 380 | 380 | * |
| 381 | 381 | * @return bool true if host matches, false if not |
| 382 | 382 | */ |
| 383 | -function give_is_host( $host = false ) { |
|
| 383 | +function give_is_host($host = false) { |
|
| 384 | 384 | |
| 385 | 385 | $return = false; |
| 386 | 386 | |
| 387 | - if ( $host ) { |
|
| 388 | - $host = str_replace( ' ', '', strtolower( $host ) ); |
|
| 387 | + if ($host) { |
|
| 388 | + $host = str_replace(' ', '', strtolower($host)); |
|
| 389 | 389 | |
| 390 | - switch ( $host ) { |
|
| 390 | + switch ($host) { |
|
| 391 | 391 | case 'wpengine': |
| 392 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
| 392 | + if (defined('WPE_APIKEY')) { |
|
| 393 | 393 | $return = true; |
| 394 | 394 | } |
| 395 | 395 | break; |
| 396 | 396 | case 'pagely': |
| 397 | - if ( defined( 'PAGELYBIN' ) ) { |
|
| 397 | + if (defined('PAGELYBIN')) { |
|
| 398 | 398 | $return = true; |
| 399 | 399 | } |
| 400 | 400 | break; |
| 401 | 401 | case 'icdsoft': |
| 402 | - if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
| 402 | + if (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
| 403 | 403 | $return = true; |
| 404 | 404 | } |
| 405 | 405 | break; |
| 406 | 406 | case 'networksolutions': |
| 407 | - if ( DB_HOST == 'mysqlv5' ) { |
|
| 407 | + if (DB_HOST == 'mysqlv5') { |
|
| 408 | 408 | $return = true; |
| 409 | 409 | } |
| 410 | 410 | break; |
| 411 | 411 | case 'ipage': |
| 412 | - if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
| 412 | + if (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
| 413 | 413 | $return = true; |
| 414 | 414 | } |
| 415 | 415 | break; |
| 416 | 416 | case 'ipower': |
| 417 | - if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
| 417 | + if (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
| 418 | 418 | $return = true; |
| 419 | 419 | } |
| 420 | 420 | break; |
| 421 | 421 | case 'mediatemplegrid': |
| 422 | - if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
| 422 | + if (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
| 423 | 423 | $return = true; |
| 424 | 424 | } |
| 425 | 425 | break; |
| 426 | 426 | case 'pairnetworks': |
| 427 | - if ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
| 427 | + if (strpos(DB_HOST, '.pair.com') !== false) { |
|
| 428 | 428 | $return = true; |
| 429 | 429 | } |
| 430 | 430 | break; |
| 431 | 431 | case 'rackspacecloud': |
| 432 | - if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
| 432 | + if (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
| 433 | 433 | $return = true; |
| 434 | 434 | } |
| 435 | 435 | break; |
| 436 | 436 | case 'sysfix.eu': |
| 437 | 437 | case 'sysfix.eupowerhosting': |
| 438 | - if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
| 438 | + if (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
| 439 | 439 | $return = true; |
| 440 | 440 | } |
| 441 | 441 | break; |
| 442 | 442 | case 'flywheel': |
| 443 | - if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
| 443 | + if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
| 444 | 444 | $return = true; |
| 445 | 445 | } |
| 446 | 446 | break; |
@@ -461,8 +461,8 @@ discard block |
||
| 461 | 461 | * @return string $post_id |
| 462 | 462 | */ |
| 463 | 463 | function give_get_admin_post_id() { |
| 464 | - $post_id = isset( $_GET['post'] ) ? $_GET['post'] : null; |
|
| 465 | - if ( ! $post_id && isset( $_POST['post_id'] ) ) { |
|
| 464 | + $post_id = isset($_GET['post']) ? $_GET['post'] : null; |
|
| 465 | + if ( ! $post_id && isset($_POST['post_id'])) { |
|
| 466 | 466 | $post_id = $_POST['post_id']; |
| 467 | 467 | } |
| 468 | 468 | |
@@ -480,11 +480,11 @@ discard block |
||
| 480 | 480 | * |
| 481 | 481 | * @return bool $ret True if guest checkout is enabled, false otherwise |
| 482 | 482 | */ |
| 483 | -function give_no_guest_checkout( $form_id ) { |
|
| 483 | +function give_no_guest_checkout($form_id) { |
|
| 484 | 484 | |
| 485 | - $ret = get_post_meta( $form_id, '_give_logged_in_only', true ); |
|
| 485 | + $ret = get_post_meta($form_id, '_give_logged_in_only', true); |
|
| 486 | 486 | |
| 487 | - return (bool) apply_filters( 'give_no_guest_checkout', $ret ); |
|
| 487 | + return (bool) apply_filters('give_no_guest_checkout', $ret); |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | * @return string Arg separator output |
| 496 | 496 | */ |
| 497 | 497 | function give_get_php_arg_separator_output() { |
| 498 | - return ini_get( 'arg_separator.output' ); |
|
| 498 | + return ini_get('arg_separator.output'); |
|
| 499 | 499 | } |
| 500 | 500 | |
| 501 | 501 | |
@@ -510,10 +510,10 @@ discard block |
||
| 510 | 510 | * |
| 511 | 511 | * @return string Short month name |
| 512 | 512 | */ |
| 513 | -function give_month_num_to_name( $n ) { |
|
| 514 | - $timestamp = mktime( 0, 0, 0, $n, 1, 2005 ); |
|
| 513 | +function give_month_num_to_name($n) { |
|
| 514 | + $timestamp = mktime(0, 0, 0, $n, 1, 2005); |
|
| 515 | 515 | |
| 516 | - return date_i18n( "M", $timestamp ); |
|
| 516 | + return date_i18n("M", $timestamp); |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | |
@@ -526,10 +526,10 @@ discard block |
||
| 526 | 526 | * |
| 527 | 527 | * @return bool Whether or not function is disabled. |
| 528 | 528 | */ |
| 529 | -function give_is_func_disabled( $function ) { |
|
| 530 | - $disabled = explode( ',', ini_get( 'disable_functions' ) ); |
|
| 529 | +function give_is_func_disabled($function) { |
|
| 530 | + $disabled = explode(',', ini_get('disable_functions')); |
|
| 531 | 531 | |
| 532 | - return in_array( $function, $disabled ); |
|
| 532 | + return in_array($function, $disabled); |
|
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | |
| 545 | 545 | <form action="//givewp.us3.list-manage.com/subscribe/post?u=3ccb75d68bda4381e2f45794c&id=12a081aa13" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate> |
| 546 | 546 | <div class="give-newsletter-confirmation"> |
| 547 | - <p><?php _e( 'Thanks for Subscribing!', 'give' ); ?> :)</p> |
|
| 547 | + <p><?php _e('Thanks for Subscribing!', 'give'); ?> :)</p> |
|
| 548 | 548 | </div> |
| 549 | 549 | |
| 550 | 550 | <table class="form-table give-newsletter-form"> |
@@ -640,7 +640,7 @@ discard block |
||
| 640 | 640 | * |
| 641 | 641 | * @return mixed |
| 642 | 642 | */ |
| 643 | -function give_svg_icons( $icon ) { |
|
| 643 | +function give_svg_icons($icon) { |
|
| 644 | 644 | |
| 645 | 645 | // Store your SVGs in an associative array |
| 646 | 646 | $svgs = array( |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | ); |
| 653 | 653 | |
| 654 | 654 | // Return the chosen icon's SVG string |
| 655 | - return $svgs[ $icon ]; |
|
| 655 | + return $svgs[$icon]; |
|
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | /** |
@@ -664,15 +664,15 @@ discard block |
||
| 664 | 664 | * |
| 665 | 665 | * @return mixed |
| 666 | 666 | */ |
| 667 | -function modify_nav_menu_meta_box_object( $post_type ) { |
|
| 668 | - if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) { |
|
| 667 | +function modify_nav_menu_meta_box_object($post_type) { |
|
| 668 | + if (isset($post_type->name) && $post_type->name == 'give_forms') { |
|
| 669 | 669 | $post_type->labels->name = 'Donation Forms'; |
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | return $post_type; |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | -add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' ); |
|
| 675 | +add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object'); |
|
| 676 | 676 | |
| 677 | 677 | |
| 678 | 678 | /** |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | * @license http://opensource.org/licenses/MIT MIT |
| 686 | 686 | */ |
| 687 | 687 | |
| 688 | -if ( ! function_exists( 'array_column' ) ) { |
|
| 688 | +if ( ! function_exists('array_column')) { |
|
| 689 | 689 | /** |
| 690 | 690 | * Returns the values from a single column of the input array, identified by |
| 691 | 691 | * the $columnKey. |
@@ -704,56 +704,56 @@ discard block |
||
| 704 | 704 | * |
| 705 | 705 | * @return array |
| 706 | 706 | */ |
| 707 | - function array_column( $input = null, $columnKey = null, $indexKey = null ) { |
|
| 707 | + function array_column($input = null, $columnKey = null, $indexKey = null) { |
|
| 708 | 708 | // Using func_get_args() in order to check for proper number of |
| 709 | 709 | // parameters and trigger errors exactly as the built-in array_column() |
| 710 | 710 | // does in PHP 5.5. |
| 711 | 711 | $argc = func_num_args(); |
| 712 | 712 | $params = func_get_args(); |
| 713 | 713 | |
| 714 | - if ( $argc < 2 ) { |
|
| 715 | - trigger_error( "array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING ); |
|
| 714 | + if ($argc < 2) { |
|
| 715 | + trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING); |
|
| 716 | 716 | |
| 717 | 717 | return null; |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | - if ( ! is_array( $params[0] ) ) { |
|
| 720 | + if ( ! is_array($params[0])) { |
|
| 721 | 721 | trigger_error( |
| 722 | - 'array_column() expects parameter 1 to be array, ' . gettype( $params[0] ) . ' given', |
|
| 722 | + 'array_column() expects parameter 1 to be array, '.gettype($params[0]).' given', |
|
| 723 | 723 | E_USER_WARNING |
| 724 | 724 | ); |
| 725 | 725 | |
| 726 | 726 | return null; |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | - if ( ! is_int( $params[1] ) |
|
| 730 | - && ! is_float( $params[1] ) |
|
| 731 | - && ! is_string( $params[1] ) |
|
| 729 | + if ( ! is_int($params[1]) |
|
| 730 | + && ! is_float($params[1]) |
|
| 731 | + && ! is_string($params[1]) |
|
| 732 | 732 | && $params[1] !== null |
| 733 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
| 733 | + && ! (is_object($params[1]) && method_exists($params[1], '__toString')) |
|
| 734 | 734 | ) { |
| 735 | - trigger_error( 'array_column(): The column key should be either a string or an integer', E_USER_WARNING ); |
|
| 735 | + trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING); |
|
| 736 | 736 | |
| 737 | 737 | return false; |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | - if ( isset( $params[2] ) |
|
| 741 | - && ! is_int( $params[2] ) |
|
| 742 | - && ! is_float( $params[2] ) |
|
| 743 | - && ! is_string( $params[2] ) |
|
| 744 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
| 740 | + if (isset($params[2]) |
|
| 741 | + && ! is_int($params[2]) |
|
| 742 | + && ! is_float($params[2]) |
|
| 743 | + && ! is_string($params[2]) |
|
| 744 | + && ! (is_object($params[2]) && method_exists($params[2], '__toString')) |
|
| 745 | 745 | ) { |
| 746 | - trigger_error( 'array_column(): The index key should be either a string or an integer', E_USER_WARNING ); |
|
| 746 | + trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING); |
|
| 747 | 747 | |
| 748 | 748 | return false; |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | $paramsInput = $params[0]; |
| 752 | - $paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null; |
|
| 752 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
| 753 | 753 | |
| 754 | 754 | $paramsIndexKey = null; |
| 755 | - if ( isset( $params[2] ) ) { |
|
| 756 | - if ( is_float( $params[2] ) || is_int( $params[2] ) ) { |
|
| 755 | + if (isset($params[2])) { |
|
| 756 | + if (is_float($params[2]) || is_int($params[2])) { |
|
| 757 | 757 | $paramsIndexKey = (int) $params[2]; |
| 758 | 758 | } else { |
| 759 | 759 | $paramsIndexKey = (string) $params[2]; |
@@ -762,26 +762,26 @@ discard block |
||
| 762 | 762 | |
| 763 | 763 | $resultArray = array(); |
| 764 | 764 | |
| 765 | - foreach ( $paramsInput as $row ) { |
|
| 765 | + foreach ($paramsInput as $row) { |
|
| 766 | 766 | $key = $value = null; |
| 767 | 767 | $keySet = $valueSet = false; |
| 768 | 768 | |
| 769 | - if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) { |
|
| 769 | + if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
| 770 | 770 | $keySet = true; |
| 771 | - $key = (string) $row[ $paramsIndexKey ]; |
|
| 771 | + $key = (string) $row[$paramsIndexKey]; |
|
| 772 | 772 | } |
| 773 | 773 | |
| 774 | - if ( $paramsColumnKey === null ) { |
|
| 774 | + if ($paramsColumnKey === null) { |
|
| 775 | 775 | $valueSet = true; |
| 776 | 776 | $value = $row; |
| 777 | - } elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) { |
|
| 777 | + } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
| 778 | 778 | $valueSet = true; |
| 779 | - $value = $row[ $paramsColumnKey ]; |
|
| 779 | + $value = $row[$paramsColumnKey]; |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | - if ( $valueSet ) { |
|
| 783 | - if ( $keySet ) { |
|
| 784 | - $resultArray[ $key ] = $value; |
|
| 782 | + if ($valueSet) { |
|
| 783 | + if ($keySet) { |
|
| 784 | + $resultArray[$key] = $value; |
|
| 785 | 785 | } else { |
| 786 | 786 | $resultArray[] = $value; |
| 787 | 787 | } |
@@ -803,39 +803,39 @@ discard block |
||
| 803 | 803 | * |
| 804 | 804 | * @return bool Whether the receipt is visible or not. |
| 805 | 805 | */ |
| 806 | -function give_can_view_receipt( $payment_key = '' ) { |
|
| 806 | +function give_can_view_receipt($payment_key = '') { |
|
| 807 | 807 | |
| 808 | 808 | $return = false; |
| 809 | 809 | |
| 810 | - if ( empty( $payment_key ) ) { |
|
| 810 | + if (empty($payment_key)) { |
|
| 811 | 811 | return $return; |
| 812 | 812 | } |
| 813 | 813 | |
| 814 | 814 | global $give_receipt_args; |
| 815 | 815 | |
| 816 | - $give_receipt_args['id'] = give_get_purchase_id_by_key( $payment_key ); |
|
| 816 | + $give_receipt_args['id'] = give_get_purchase_id_by_key($payment_key); |
|
| 817 | 817 | |
| 818 | - $user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] ); |
|
| 818 | + $user_id = (int) give_get_payment_user_id($give_receipt_args['id']); |
|
| 819 | 819 | |
| 820 | - $payment_meta = give_get_payment_meta( $give_receipt_args['id'] ); |
|
| 820 | + $payment_meta = give_get_payment_meta($give_receipt_args['id']); |
|
| 821 | 821 | |
| 822 | - if ( is_user_logged_in() ) { |
|
| 823 | - if ( $user_id === (int) get_current_user_id() ) { |
|
| 822 | + if (is_user_logged_in()) { |
|
| 823 | + if ($user_id === (int) get_current_user_id()) { |
|
| 824 | 824 | $return = true; |
| 825 | - } elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) { |
|
| 825 | + } elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) { |
|
| 826 | 826 | $return = true; |
| 827 | - } elseif ( current_user_can( 'view_give_sensitive_data' ) ) { |
|
| 827 | + } elseif (current_user_can('view_give_sensitive_data')) { |
|
| 828 | 828 | $return = true; |
| 829 | 829 | } |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | $session = give_get_purchase_session(); |
| 833 | - if ( ! empty( $session ) && ! is_user_logged_in() ) { |
|
| 834 | - if ( $session['purchase_key'] === $payment_meta['key'] ) { |
|
| 833 | + if ( ! empty($session) && ! is_user_logged_in()) { |
|
| 834 | + if ($session['purchase_key'] === $payment_meta['key']) { |
|
| 835 | 835 | $return = true; |
| 836 | 836 | } |
| 837 | 837 | } |
| 838 | 838 | |
| 839 | - return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key ); |
|
| 839 | + return (bool) apply_filters('give_can_view_receipt', $return, $payment_key); |
|
| 840 | 840 | |
| 841 | 841 | } |
| 842 | 842 | \ 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 | |
@@ -50,50 +50,50 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | |
| 52 | 52 | // https://gist.github.com/justinph/5197810 |
| 53 | - function validate_gravatar( $id_or_email ) { |
|
| 53 | + function validate_gravatar($id_or_email) { |
|
| 54 | 54 | //id or email code borrowed from wp-includes/pluggable.php |
| 55 | 55 | $email = ''; |
| 56 | - if ( is_numeric( $id_or_email ) ) { |
|
| 56 | + if (is_numeric($id_or_email)) { |
|
| 57 | 57 | $id = (int) $id_or_email; |
| 58 | - $user = get_userdata( $id ); |
|
| 59 | - if ( $user ) { |
|
| 58 | + $user = get_userdata($id); |
|
| 59 | + if ($user) { |
|
| 60 | 60 | $email = $user->user_email; |
| 61 | 61 | } |
| 62 | - } elseif ( is_object( $id_or_email ) ) { |
|
| 62 | + } elseif (is_object($id_or_email)) { |
|
| 63 | 63 | // No avatar for pingbacks or trackbacks |
| 64 | - $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); |
|
| 65 | - if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) { |
|
| 64 | + $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment')); |
|
| 65 | + if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) { |
|
| 66 | 66 | return false; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - if ( ! empty( $id_or_email->user_id ) ) { |
|
| 69 | + if ( ! empty($id_or_email->user_id)) { |
|
| 70 | 70 | $id = (int) $id_or_email->user_id; |
| 71 | - $user = get_userdata( $id ); |
|
| 72 | - if ( $user ) { |
|
| 71 | + $user = get_userdata($id); |
|
| 72 | + if ($user) { |
|
| 73 | 73 | $email = $user->user_email; |
| 74 | 74 | } |
| 75 | - } elseif ( ! empty( $id_or_email->comment_author_email ) ) { |
|
| 75 | + } elseif ( ! empty($id_or_email->comment_author_email)) { |
|
| 76 | 76 | $email = $id_or_email->comment_author_email; |
| 77 | 77 | } |
| 78 | 78 | } else { |
| 79 | 79 | $email = $id_or_email; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - $hashkey = md5( strtolower( trim( $email ) ) ); |
|
| 83 | - $uri = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404'; |
|
| 82 | + $hashkey = md5(strtolower(trim($email))); |
|
| 83 | + $uri = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404'; |
|
| 84 | 84 | |
| 85 | - $data = wp_cache_get( $hashkey ); |
|
| 86 | - if ( false === $data ) { |
|
| 87 | - $response = wp_remote_head( $uri ); |
|
| 88 | - if ( is_wp_error( $response ) ) { |
|
| 85 | + $data = wp_cache_get($hashkey); |
|
| 86 | + if (false === $data) { |
|
| 87 | + $response = wp_remote_head($uri); |
|
| 88 | + if (is_wp_error($response)) { |
|
| 89 | 89 | $data = 'not200'; |
| 90 | 90 | } else { |
| 91 | 91 | $data = $response['response']['code']; |
| 92 | 92 | } |
| 93 | - wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 ); |
|
| 93 | + wp_cache_set($hashkey, $data, $group = '', $expire = 60 * 5); |
|
| 94 | 94 | |
| 95 | 95 | } |
| 96 | - if ( $data == '200' ) { |
|
| 96 | + if ($data == '200') { |
|
| 97 | 97 | return true; |
| 98 | 98 | } else { |
| 99 | 99 | return false; |
@@ -108,17 +108,17 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @param int $form_id |
| 110 | 110 | */ |
| 111 | - function get_log_ids( $form_id = '' ) { |
|
| 111 | + function get_log_ids($form_id = '') { |
|
| 112 | 112 | |
| 113 | 113 | // get Give_Logging class |
| 114 | 114 | global $give_logs; |
| 115 | 115 | |
| 116 | 116 | // get log for this form |
| 117 | - $logs = $give_logs->get_logs( $form_id ); |
|
| 117 | + $logs = $give_logs->get_logs($form_id); |
|
| 118 | 118 | |
| 119 | - if ( $logs ) { |
|
| 119 | + if ($logs) { |
|
| 120 | 120 | // make an array with all the donor IDs |
| 121 | - foreach ( $logs as $log ) { |
|
| 121 | + foreach ($logs as $log) { |
|
| 122 | 122 | $log_ids[] = $log->ID; |
| 123 | 123 | } |
| 124 | 124 | |
@@ -135,49 +135,49 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @since 1.0 |
| 137 | 137 | */ |
| 138 | - function get_payment_ids( $form_id = '' ) { |
|
| 138 | + function get_payment_ids($form_id = '') { |
|
| 139 | 139 | |
| 140 | 140 | global $give_options; |
| 141 | 141 | |
| 142 | - $log_ids = $this->get_log_ids( $form_id ); |
|
| 142 | + $log_ids = $this->get_log_ids($form_id); |
|
| 143 | 143 | |
| 144 | - if ( $log_ids ) { |
|
| 144 | + if ($log_ids) { |
|
| 145 | 145 | |
| 146 | 146 | $payment_ids = array(); |
| 147 | 147 | |
| 148 | - foreach ( $log_ids as $id ) { |
|
| 148 | + foreach ($log_ids as $id) { |
|
| 149 | 149 | // get the payment ID for each corresponding log ID |
| 150 | - $payment_ids[] = get_post_meta( $id, '_give_log_payment_id', true ); |
|
| 150 | + $payment_ids[] = get_post_meta($id, '_give_log_payment_id', true); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // remove donors who have purchased more than once so we can have unique avatars |
| 154 | 154 | $unique_emails = array(); |
| 155 | 155 | |
| 156 | - foreach ( $payment_ids as $key => $id ) { |
|
| 156 | + foreach ($payment_ids as $key => $id) { |
|
| 157 | 157 | |
| 158 | - $email = get_post_meta( $id, '_give_payment_user_email', true ); |
|
| 158 | + $email = get_post_meta($id, '_give_payment_user_email', true); |
|
| 159 | 159 | |
| 160 | - if ( isset ( $give_options['give_donators_gravatars_has_gravatar_account'] ) ) { |
|
| 161 | - if ( ! $this->validate_gravatar( $email ) ) { |
|
| 160 | + if (isset ($give_options['give_donators_gravatars_has_gravatar_account'])) { |
|
| 161 | + if ( ! $this->validate_gravatar($email)) { |
|
| 162 | 162 | continue; |
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - $unique_emails[ $id ] = get_post_meta( $id, '_give_payment_user_email', true ); |
|
| 166 | + $unique_emails[$id] = get_post_meta($id, '_give_payment_user_email', true); |
|
| 167 | 167 | |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | // strip duplicate emails |
| 171 | - $unique_emails = array_unique( $unique_emails ); |
|
| 171 | + $unique_emails = array_unique($unique_emails); |
|
| 172 | 172 | |
| 173 | 173 | // convert the unique IDs back into simple array |
| 174 | - foreach ( $unique_emails as $id => $email ) { |
|
| 174 | + foreach ($unique_emails as $id => $email) { |
|
| 175 | 175 | $unique_ids[] = $id; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | // randomize the payment IDs if enabled |
| 179 | - if ( isset( $give_options['give_donators_gravatars_random_gravatars'] ) ) { |
|
| 180 | - shuffle( $unique_ids ); |
|
| 179 | + if (isset($give_options['give_donators_gravatars_random_gravatars'])) { |
|
| 180 | + shuffle($unique_ids); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | // return our unique IDs |
@@ -193,10 +193,10 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | * @since 1.0 |
| 195 | 195 | */ |
| 196 | - function gravatars( $form_id = false, $title = '' ) { |
|
| 196 | + function gravatars($form_id = false, $title = '') { |
|
| 197 | 197 | |
| 198 | 198 | // unique $payment_ids |
| 199 | - $payment_ids = $this->get_payment_ids( $form_id ); |
|
| 199 | + $payment_ids = $this->get_payment_ids($form_id); |
|
| 200 | 200 | |
| 201 | 201 | // var_dump( $payment_ids ); |
| 202 | 202 | // var_dump( $this->get_log_ids( get_the_ID() ) ); |
@@ -204,14 +204,14 @@ discard block |
||
| 204 | 204 | global $give_options; |
| 205 | 205 | |
| 206 | 206 | // return if no ID |
| 207 | - if ( ! $form_id ) { |
|
| 207 | + if ( ! $form_id) { |
|
| 208 | 208 | return; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | // minimum amount of purchases before showing gravatars |
| 212 | 212 | // if the number of items in array is not greater or equal to the number specified, then exit |
| 213 | - if ( isset( $give_options['give_donators_gravatars_min_purchases_required'] ) && '' != $give_options['give_donators_gravatars_min_purchases_required'] ) { |
|
| 214 | - if ( ! ( count( $payment_ids ) >= $give_options['give_donators_gravatars_min_purchases_required'] ) ) { |
|
| 213 | + if (isset($give_options['give_donators_gravatars_min_purchases_required']) && '' != $give_options['give_donators_gravatars_min_purchases_required']) { |
|
| 214 | + if ( ! (count($payment_ids) >= $give_options['give_donators_gravatars_min_purchases_required'])) { |
|
| 215 | 215 | return; |
| 216 | 216 | } |
| 217 | 217 | } |
@@ -222,51 +222,51 @@ discard block |
||
| 222 | 222 | echo '<div id="give-purchase-gravatars">'; |
| 223 | 223 | |
| 224 | 224 | |
| 225 | - if ( isset ( $title ) ) { |
|
| 225 | + if (isset ($title)) { |
|
| 226 | 226 | |
| 227 | - if ( $title ) { |
|
| 228 | - echo apply_filters( 'give_donators_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $title ) . '</h3>' ); |
|
| 229 | - } elseif ( isset( $give_options['give_donators_gravatars_heading'] ) ) { |
|
| 230 | - echo apply_filters( 'give_donators_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $give_options['give_donators_gravatars_heading'] ) . '</h2>' ); |
|
| 227 | + if ($title) { |
|
| 228 | + echo apply_filters('give_donators_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($title).'</h3>'); |
|
| 229 | + } elseif (isset($give_options['give_donators_gravatars_heading'])) { |
|
| 230 | + echo apply_filters('give_donators_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($give_options['give_donators_gravatars_heading']).'</h2>'); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | } |
| 234 | 234 | echo '<ul class="give-purchase-gravatars-list">'; |
| 235 | 235 | $i = 0; |
| 236 | 236 | |
| 237 | - if ( $payment_ids ) { |
|
| 238 | - foreach ( $payment_ids as $id ) { |
|
| 237 | + if ($payment_ids) { |
|
| 238 | + foreach ($payment_ids as $id) { |
|
| 239 | 239 | |
| 240 | 240 | // Give saves a blank option even when the control is turned off, hence the extra check |
| 241 | - if ( isset( $give_options['give_donators_gravatars_maximum_number'] ) && '' != $give_options['give_donators_gravatars_maximum_number'] && $i == $give_options['give_donators_gravatars_maximum_number'] ) { |
|
| 241 | + if (isset($give_options['give_donators_gravatars_maximum_number']) && '' != $give_options['give_donators_gravatars_maximum_number'] && $i == $give_options['give_donators_gravatars_maximum_number']) { |
|
| 242 | 242 | continue; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | // get the payment meta |
| 246 | - $payment_meta = get_post_meta( $id, '_give_payment_meta', true ); |
|
| 246 | + $payment_meta = get_post_meta($id, '_give_payment_meta', true); |
|
| 247 | 247 | |
| 248 | 248 | // unserialize the payment meta |
| 249 | - $user_info = maybe_unserialize( $payment_meta['user_info'] ); |
|
| 249 | + $user_info = maybe_unserialize($payment_meta['user_info']); |
|
| 250 | 250 | |
| 251 | 251 | // get donor's first name |
| 252 | 252 | $name = $user_info['first_name']; |
| 253 | 253 | |
| 254 | 254 | // get donor's email |
| 255 | - $email = get_post_meta( $id, '_give_payment_user_email', true ); |
|
| 255 | + $email = get_post_meta($id, '_give_payment_user_email', true); |
|
| 256 | 256 | |
| 257 | 257 | // set gravatar size and provide filter |
| 258 | - $size = isset( $give_options['give_donators_gravatars_gravatar_size'] ) ? apply_filters( 'give_donators_gravatars_gravatar_size', $give_options['give_donators_gravatars_gravatar_size'] ) : ''; |
|
| 258 | + $size = isset($give_options['give_donators_gravatars_gravatar_size']) ? apply_filters('give_donators_gravatars_gravatar_size', $give_options['give_donators_gravatars_gravatar_size']) : ''; |
|
| 259 | 259 | |
| 260 | 260 | // default image |
| 261 | - $default_image = apply_filters( 'give_donators_gravatars_gravatar_default_image', false ); |
|
| 261 | + $default_image = apply_filters('give_donators_gravatars_gravatar_default_image', false); |
|
| 262 | 262 | |
| 263 | 263 | // assemble output |
| 264 | 264 | $output .= '<li>'; |
| 265 | 265 | |
| 266 | - $output .= get_avatar( $email, $size, $default_image, $name ); |
|
| 266 | + $output .= get_avatar($email, $size, $default_image, $name); |
|
| 267 | 267 | $output .= '</li>'; |
| 268 | 268 | |
| 269 | - $i ++; |
|
| 269 | + $i++; |
|
| 270 | 270 | |
| 271 | 271 | } // end foreach |
| 272 | 272 | } |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | echo '</ul>'; |
| 276 | 276 | echo '</div>'; |
| 277 | 277 | |
| 278 | - return apply_filters( 'give_donators_gravatars', ob_get_clean() ); |
|
| 278 | + return apply_filters('give_donators_gravatars', ob_get_clean()); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | * @since 1.0 |
| 285 | 285 | */ |
| 286 | 286 | function register_widget() { |
| 287 | - register_widget( 'Give_Donators_Gravatars_Widget' ); |
|
| 287 | + register_widget('Give_Donators_Gravatars_Widget'); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
@@ -293,19 +293,19 @@ discard block |
||
| 293 | 293 | * @since 1.0 |
| 294 | 294 | * @todo set the ID to get_the_ID() if ID parameter is not passed through. Otherwise it will incorrectly get other gravatars |
| 295 | 295 | */ |
| 296 | - function shortcode( $atts, $content = null ) { |
|
| 296 | + function shortcode($atts, $content = null) { |
|
| 297 | 297 | |
| 298 | - $atts = shortcode_atts( array( |
|
| 298 | + $atts = shortcode_atts(array( |
|
| 299 | 299 | 'id' => '', |
| 300 | 300 | 'title' => '' |
| 301 | - ), $atts, 'give_donators_gravatars' ); |
|
| 301 | + ), $atts, 'give_donators_gravatars'); |
|
| 302 | 302 | |
| 303 | 303 | // if no ID is passed on single give_forms pages, get the correct ID |
| 304 | - if ( is_singular( 'give_forms' ) ) { |
|
| 304 | + if (is_singular('give_forms')) { |
|
| 305 | 305 | $id = get_the_ID(); |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - $content = $this->gravatars( $atts['id'], $atts['title'] ); |
|
| 308 | + $content = $this->gravatars($atts['id'], $atts['title']); |
|
| 309 | 309 | |
| 310 | 310 | return $content; |
| 311 | 311 | |
@@ -316,56 +316,56 @@ discard block |
||
| 316 | 316 | * |
| 317 | 317 | * @since 1.0 |
| 318 | 318 | */ |
| 319 | - function settings( $settings ) { |
|
| 319 | + function settings($settings) { |
|
| 320 | 320 | |
| 321 | 321 | $give_gravatar_settings = array( |
| 322 | 322 | array( |
| 323 | - 'name' => __( 'Donator Gravatars', 'give' ), |
|
| 323 | + 'name' => __('Donator Gravatars', 'give'), |
|
| 324 | 324 | 'desc' => '<hr>', |
| 325 | 325 | 'id' => 'give_title', |
| 326 | 326 | 'type' => 'give_title' |
| 327 | 327 | ), |
| 328 | 328 | array( |
| 329 | - 'name' => __( 'Heading', 'give' ), |
|
| 330 | - 'desc' => __( 'The heading to display above the Gravatars', 'give' ), |
|
| 329 | + 'name' => __('Heading', 'give'), |
|
| 330 | + 'desc' => __('The heading to display above the Gravatars', 'give'), |
|
| 331 | 331 | 'type' => 'text', |
| 332 | 332 | 'id' => 'give_donators_gravatars_heading' |
| 333 | 333 | ), |
| 334 | 334 | array( |
| 335 | - 'name' => __( 'Gravatar Size', 'give' ), |
|
| 336 | - 'desc' => __( 'The size of each Gravatar in pixels (512px maximum)', 'give' ), |
|
| 335 | + 'name' => __('Gravatar Size', 'give'), |
|
| 336 | + 'desc' => __('The size of each Gravatar in pixels (512px maximum)', 'give'), |
|
| 337 | 337 | 'type' => 'text_small', |
| 338 | 338 | 'id' => 'give_donators_gravatars_gravatar_size', |
| 339 | 339 | 'default' => '64' |
| 340 | 340 | ), |
| 341 | 341 | array( |
| 342 | - 'name' => __( 'Minimum Unique Purchases Required', 'give' ), |
|
| 343 | - 'desc' => sprintf( __( 'The minimum number of unique purchases a %s must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ), strtolower( give_get_forms_label_singular() ) ), |
|
| 342 | + 'name' => __('Minimum Unique Purchases Required', 'give'), |
|
| 343 | + 'desc' => sprintf(__('The minimum number of unique purchases a %s must have before the Gravatars are shown. Leave blank for no minimum.', 'give'), strtolower(give_get_forms_label_singular())), |
|
| 344 | 344 | 'type' => 'text_small', |
| 345 | 345 | 'id' => 'give_donators_gravatars_min_purchases_required', |
| 346 | 346 | ), |
| 347 | 347 | array( |
| 348 | - 'name' => __( 'Maximum Gravatars To Show', 'give' ), |
|
| 349 | - 'desc' => __( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ), |
|
| 348 | + 'name' => __('Maximum Gravatars To Show', 'give'), |
|
| 349 | + 'desc' => __('The maximum number of gravatars to show. Leave blank for no limit.', 'give'), |
|
| 350 | 350 | 'type' => 'text', |
| 351 | 351 | 'id' => 'give_donators_gravatars_maximum_number', |
| 352 | 352 | 'default' => '20', |
| 353 | 353 | ), |
| 354 | 354 | array( |
| 355 | - 'name' => __( 'Gravatar Visibility', 'give' ), |
|
| 356 | - 'desc' => __( 'Only show donators with a Gravatar account', 'give' ), |
|
| 355 | + 'name' => __('Gravatar Visibility', 'give'), |
|
| 356 | + 'desc' => __('Only show donators with a Gravatar account', 'give'), |
|
| 357 | 357 | 'id' => 'give_donators_gravatars_has_gravatar_account', |
| 358 | 358 | 'type' => 'checkbox', |
| 359 | 359 | ), |
| 360 | 360 | array( |
| 361 | - 'name' => __( 'Randomize Gravatars', 'give' ), |
|
| 362 | - 'desc' => __( 'Randomize the Gravatars', 'give' ), |
|
| 361 | + 'name' => __('Randomize Gravatars', 'give'), |
|
| 362 | + 'desc' => __('Randomize the Gravatars', 'give'), |
|
| 363 | 363 | 'id' => 'give_donators_gravatars_random_gravatars', |
| 364 | 364 | 'type' => 'checkbox', |
| 365 | 365 | ), |
| 366 | 366 | ); |
| 367 | 367 | |
| 368 | - return array_merge( $settings, $give_gravatar_settings ); |
|
| 368 | + return array_merge($settings, $give_gravatar_settings); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | } |
@@ -383,12 +383,12 @@ discard block |
||
| 383 | 383 | */ |
| 384 | 384 | function give_donators_gravatars_widget() { |
| 385 | 385 | |
| 386 | - $give_label_singular = function_exists( 'give_get_forms_label_singular' ) ? strtolower( give_get_forms_label_singular() ) : null; |
|
| 386 | + $give_label_singular = function_exists('give_get_forms_label_singular') ? strtolower(give_get_forms_label_singular()) : null; |
|
| 387 | 387 | |
| 388 | 388 | // widget settings |
| 389 | 389 | $widget_ops = array( |
| 390 | 390 | 'classname' => 'give-donators-gravatars', |
| 391 | - 'description' => sprintf( __( 'Displays gravatars of people who have donated using your your %s. Will only show on the single %s page.', 'give' ), $give_label_singular, $give_label_singular ) |
|
| 391 | + 'description' => sprintf(__('Displays gravatars of people who have donated using your your %s. Will only show on the single %s page.', 'give'), $give_label_singular, $give_label_singular) |
|
| 392 | 392 | ); |
| 393 | 393 | |
| 394 | 394 | // widget control settings |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | // create the widget |
| 402 | 402 | $this->WP_Widget( |
| 403 | 403 | 'give_donators_gravatars_widget', |
| 404 | - __( 'Give Donators Gravatars', 'give' ), |
|
| 404 | + __('Give Donators Gravatars', 'give'), |
|
| 405 | 405 | $widget_ops, |
| 406 | 406 | $control_ops |
| 407 | 407 | ); |
@@ -412,29 +412,29 @@ discard block |
||
| 412 | 412 | /* |
| 413 | 413 | * Outputs the content of the widget |
| 414 | 414 | */ |
| 415 | - function widget( $args, $instance ) { |
|
| 415 | + function widget($args, $instance) { |
|
| 416 | 416 | global $give_options; |
| 417 | 417 | |
| 418 | - extract( $args ); |
|
| 418 | + extract($args); |
|
| 419 | 419 | |
| 420 | - if ( ! is_singular( 'give_forms' ) ) { |
|
| 420 | + if ( ! is_singular('give_forms')) { |
|
| 421 | 421 | return; |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | // Variables from widget settings |
| 425 | - $title = apply_filters( 'widget_title', $instance['title'] ); |
|
| 425 | + $title = apply_filters('widget_title', $instance['title']); |
|
| 426 | 426 | |
| 427 | 427 | // Used by themes. Opens the widget |
| 428 | 428 | echo $before_widget; |
| 429 | 429 | |
| 430 | 430 | // Display the widget title |
| 431 | - if ( $title ) { |
|
| 432 | - echo $before_title . $title . $after_title; |
|
| 431 | + if ($title) { |
|
| 432 | + echo $before_title.$title.$after_title; |
|
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | $gravatars = new Give_Donators_Gravatars(); |
| 436 | 436 | |
| 437 | - echo $gravatars->gravatars( get_the_ID(), null ); // remove title |
|
| 437 | + echo $gravatars->gravatars(get_the_ID(), null); // remove title |
|
| 438 | 438 | |
| 439 | 439 | // Used by themes. Closes the widget |
| 440 | 440 | echo $after_widget; |
@@ -444,11 +444,11 @@ discard block |
||
| 444 | 444 | /* |
| 445 | 445 | * Update function. Processes widget options to be saved |
| 446 | 446 | */ |
| 447 | - function update( $new_instance, $old_instance ) { |
|
| 447 | + function update($new_instance, $old_instance) { |
|
| 448 | 448 | |
| 449 | 449 | $instance = $old_instance; |
| 450 | 450 | |
| 451 | - $instance['title'] = strip_tags( $new_instance['title'] ); |
|
| 451 | + $instance['title'] = strip_tags($new_instance['title']); |
|
| 452 | 452 | |
| 453 | 453 | return $instance; |
| 454 | 454 | |
@@ -457,19 +457,19 @@ discard block |
||
| 457 | 457 | /* |
| 458 | 458 | * Form function. Displays the actual form on the widget page |
| 459 | 459 | */ |
| 460 | - function form( $instance ) { |
|
| 460 | + function form($instance) { |
|
| 461 | 461 | |
| 462 | 462 | // Set up some default widget settings. |
| 463 | 463 | $defaults = array( |
| 464 | 464 | 'title' => '', |
| 465 | 465 | ); |
| 466 | 466 | |
| 467 | - $instance = wp_parse_args( (array) $instance, $defaults ); ?> |
|
| 467 | + $instance = wp_parse_args((array) $instance, $defaults); ?> |
|
| 468 | 468 | |
| 469 | 469 | <!-- Title --> |
| 470 | 470 | <p> |
| 471 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'give' ) ?></label> |
|
| 472 | - <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
| 471 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'give') ?></label> |
|
| 472 | + <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
| 473 | 473 | </p> |
| 474 | 474 | |
| 475 | 475 | |
@@ -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 | |
@@ -39,46 +39,46 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @return float|int |
| 41 | 41 | */ |
| 42 | - public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) { |
|
| 42 | + public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') { |
|
| 43 | 43 | |
| 44 | - $this->setup_dates( $start_date, $end_date ); |
|
| 44 | + $this->setup_dates($start_date, $end_date); |
|
| 45 | 45 | |
| 46 | 46 | // Make sure start date is valid |
| 47 | - if ( is_wp_error( $this->start_date ) ) { |
|
| 47 | + if (is_wp_error($this->start_date)) { |
|
| 48 | 48 | return $this->start_date; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | // Make sure end date is valid |
| 52 | - if ( is_wp_error( $this->end_date ) ) { |
|
| 52 | + if (is_wp_error($this->end_date)) { |
|
| 53 | 53 | return $this->end_date; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if ( empty( $form_id ) ) { |
|
| 56 | + if (empty($form_id)) { |
|
| 57 | 57 | |
| 58 | 58 | // Global sale stats |
| 59 | - add_filter( 'give_count_payments_where', array( $this, 'count_where' ) ); |
|
| 59 | + add_filter('give_count_payments_where', array($this, 'count_where')); |
|
| 60 | 60 | |
| 61 | - if ( is_array( $status ) ) { |
|
| 61 | + if (is_array($status)) { |
|
| 62 | 62 | $count = 0; |
| 63 | - foreach ( $status as $payment_status ) { |
|
| 63 | + foreach ($status as $payment_status) { |
|
| 64 | 64 | $count += give_count_payments()->$payment_status; |
| 65 | 65 | } |
| 66 | 66 | } else { |
| 67 | 67 | $count = give_count_payments()->$status; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - remove_filter( 'give_count_payments_where', array( $this, 'count_where' ) ); |
|
| 70 | + remove_filter('give_count_payments_where', array($this, 'count_where')); |
|
| 71 | 71 | |
| 72 | 72 | } else { |
| 73 | 73 | |
| 74 | 74 | // Product specific stats |
| 75 | 75 | global $give_logs; |
| 76 | 76 | |
| 77 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
| 77 | + add_filter('posts_where', array($this, 'payments_where')); |
|
| 78 | 78 | |
| 79 | - $count = $give_logs->get_log_count( $form_id, 'sale' ); |
|
| 79 | + $count = $give_logs->get_log_count($form_id, 'sale'); |
|
| 80 | 80 | |
| 81 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
| 81 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
| 82 | 82 | |
| 83 | 83 | } |
| 84 | 84 | |
@@ -99,31 +99,31 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @return float|int |
| 101 | 101 | */ |
| 102 | - public function get_earnings( $form_id = 0, $start_date = false, $end_date = false ) { |
|
| 102 | + public function get_earnings($form_id = 0, $start_date = false, $end_date = false) { |
|
| 103 | 103 | |
| 104 | 104 | global $wpdb; |
| 105 | 105 | |
| 106 | - $this->setup_dates( $start_date, $end_date ); |
|
| 106 | + $this->setup_dates($start_date, $end_date); |
|
| 107 | 107 | |
| 108 | 108 | // Make sure start date is valid |
| 109 | - if ( is_wp_error( $this->start_date ) ) { |
|
| 109 | + if (is_wp_error($this->start_date)) { |
|
| 110 | 110 | return $this->start_date; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | // Make sure end date is valid |
| 114 | - if ( is_wp_error( $this->end_date ) ) { |
|
| 114 | + if (is_wp_error($this->end_date)) { |
|
| 115 | 115 | return $this->end_date; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
| 118 | + add_filter('posts_where', array($this, 'payments_where')); |
|
| 119 | 119 | |
| 120 | - if ( empty( $form_id ) ) { |
|
| 120 | + if (empty($form_id)) { |
|
| 121 | 121 | |
| 122 | 122 | // Global earning stats |
| 123 | 123 | $args = array( |
| 124 | 124 | 'post_type' => 'give_payment', |
| 125 | 125 | 'nopaging' => true, |
| 126 | - 'post_status' => array( 'publish', 'revoked' ), |
|
| 126 | + 'post_status' => array('publish', 'revoked'), |
|
| 127 | 127 | 'fields' => 'ids', |
| 128 | 128 | 'update_post_term_cache' => false, |
| 129 | 129 | 'suppress_filters' => false, |
@@ -134,19 +134,19 @@ discard block |
||
| 134 | 134 | // This is not a valid query arg, but is used for cache keying |
| 135 | 135 | ); |
| 136 | 136 | |
| 137 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
| 138 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
| 137 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
| 138 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
| 139 | 139 | |
| 140 | - $earnings = get_transient( $key ); |
|
| 141 | - if ( false === $earnings ) { |
|
| 142 | - $sales = get_posts( $args ); |
|
| 140 | + $earnings = get_transient($key); |
|
| 141 | + if (false === $earnings) { |
|
| 142 | + $sales = get_posts($args); |
|
| 143 | 143 | $earnings = 0; |
| 144 | - if ( $sales ) { |
|
| 145 | - $sales = implode( ',', $sales ); |
|
| 146 | - $earnings += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})" ); |
|
| 144 | + if ($sales) { |
|
| 145 | + $sales = implode(',', $sales); |
|
| 146 | + $earnings += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})"); |
|
| 147 | 147 | } |
| 148 | 148 | // Cache the results for one hour |
| 149 | - set_transient( $key, $earnings, HOUR_IN_SECONDS ); |
|
| 149 | + set_transient($key, $earnings, HOUR_IN_SECONDS); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | } else { |
@@ -167,33 +167,33 @@ discard block |
||
| 167 | 167 | // This is not a valid query arg, but is used for cache keying |
| 168 | 168 | ); |
| 169 | 169 | |
| 170 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
| 171 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
| 170 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
| 171 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
| 172 | 172 | //Set transient for faster stats |
| 173 | - $earnings = get_transient( $key ); |
|
| 173 | + $earnings = get_transient($key); |
|
| 174 | 174 | |
| 175 | - if ( false === $earnings ) { |
|
| 175 | + if (false === $earnings) { |
|
| 176 | 176 | |
| 177 | - $log_ids = $give_logs->get_connected_logs( $args, 'sale' ); |
|
| 177 | + $log_ids = $give_logs->get_connected_logs($args, 'sale'); |
|
| 178 | 178 | $earnings = 0; |
| 179 | 179 | |
| 180 | - if ( $log_ids ) { |
|
| 181 | - $log_ids = implode( ',', $log_ids ); |
|
| 182 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);" ); |
|
| 183 | - foreach ( $payment_ids as $payment_id ) { |
|
| 180 | + if ($log_ids) { |
|
| 181 | + $log_ids = implode(',', $log_ids); |
|
| 182 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);"); |
|
| 183 | + foreach ($payment_ids as $payment_id) { |
|
| 184 | 184 | $earnings += give_get_payment_amount($payment_id); |
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | // Cache the results for one hour |
| 189 | - set_transient( $key, $earnings, 60 * 60 ); |
|
| 189 | + set_transient($key, $earnings, 60 * 60); |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | //remove our filter |
| 194 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
| 194 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
| 195 | 195 | //return earnings |
| 196 | - return round( $earnings, give_currency_decimal_filter() ); |
|
| 196 | + return round($earnings, give_currency_decimal_filter()); |
|
| 197 | 197 | |
| 198 | 198 | } |
| 199 | 199 | |
@@ -207,16 +207,16 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | * @return array |
| 209 | 209 | */ |
| 210 | - public function get_best_selling( $number = 10 ) { |
|
| 210 | + public function get_best_selling($number = 10) { |
|
| 211 | 211 | |
| 212 | 212 | global $wpdb; |
| 213 | 213 | |
| 214 | - $give_forms = $wpdb->get_results( $wpdb->prepare( |
|
| 214 | + $give_forms = $wpdb->get_results($wpdb->prepare( |
|
| 215 | 215 | "SELECT post_id as form_id, max(meta_value) as sales |
| 216 | 216 | FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0 |
| 217 | 217 | GROUP BY meta_value+0 |
| 218 | 218 | DESC LIMIT %d;", $number |
| 219 | - ) ); |
|
| 219 | + )); |
|
| 220 | 220 | |
| 221 | 221 | return $give_forms; |
| 222 | 222 | } |
@@ -50,10 +50,10 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @param $args array The array of arguments that can be passed in and used for setting up this payment query. |
| 52 | 52 | */ |
| 53 | - public function __construct( $args = array() ) { |
|
| 53 | + public function __construct($args = array()) { |
|
| 54 | 54 | $defaults = array( |
| 55 | 55 | 'output' => 'payments', // Use 'posts' to get standard post objects |
| 56 | - 'post_type' => array( 'give_payment' ), |
|
| 56 | + 'post_type' => array('give_payment'), |
|
| 57 | 57 | 'start_date' => false, |
| 58 | 58 | 'end_date' => false, |
| 59 | 59 | 'number' => 20, |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | 'give_forms' => null |
| 74 | 74 | ); |
| 75 | 75 | |
| 76 | - $this->args = wp_parse_args( $args, $defaults ); |
|
| 76 | + $this->args = wp_parse_args($args, $defaults); |
|
| 77 | 77 | |
| 78 | 78 | $this->init(); |
| 79 | 79 | } |
@@ -84,11 +84,11 @@ discard block |
||
| 84 | 84 | * @access public |
| 85 | 85 | * @since 1.0 |
| 86 | 86 | */ |
| 87 | - public function __set( $query_var, $value ) { |
|
| 88 | - if ( in_array( $query_var, array( 'meta_query', 'tax_query' ) ) ) { |
|
| 89 | - $this->args[ $query_var ][] = $value; |
|
| 87 | + public function __set($query_var, $value) { |
|
| 88 | + if (in_array($query_var, array('meta_query', 'tax_query'))) { |
|
| 89 | + $this->args[$query_var][] = $value; |
|
| 90 | 90 | } else { |
| 91 | - $this->args[ $query_var ] = $value; |
|
| 91 | + $this->args[$query_var] = $value; |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | * @access public |
| 99 | 99 | * @since 1.0 |
| 100 | 100 | */ |
| 101 | - public function __unset( $query_var ) { |
|
| 102 | - unset( $this->args[ $query_var ] ); |
|
| 101 | + public function __unset($query_var) { |
|
| 102 | + unset($this->args[$query_var]); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -111,19 +111,19 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | public function init() { |
| 113 | 113 | |
| 114 | - add_action( 'give_pre_get_payments', array( $this, 'date_filter_pre' ) ); |
|
| 115 | - add_action( 'give_post_get_payments', array( $this, 'date_filter_post' ) ); |
|
| 116 | - |
|
| 117 | - add_action( 'give_pre_get_payments', array( $this, 'orderby' ) ); |
|
| 118 | - add_action( 'give_pre_get_payments', array( $this, 'status' ) ); |
|
| 119 | - add_action( 'give_pre_get_payments', array( $this, 'month' ) ); |
|
| 120 | - add_action( 'give_pre_get_payments', array( $this, 'per_page' ) ); |
|
| 121 | - add_action( 'give_pre_get_payments', array( $this, 'page' ) ); |
|
| 122 | - add_action( 'give_pre_get_payments', array( $this, 'user' ) ); |
|
| 123 | - add_action( 'give_pre_get_payments', array( $this, 'search' ) ); |
|
| 124 | - add_action( 'give_pre_get_payments', array( $this, 'mode' ) ); |
|
| 125 | - add_action( 'give_pre_get_payments', array( $this, 'children' ) ); |
|
| 126 | - add_action( 'give_pre_get_payments', array( $this, 'give_forms' ) ); |
|
| 114 | + add_action('give_pre_get_payments', array($this, 'date_filter_pre')); |
|
| 115 | + add_action('give_post_get_payments', array($this, 'date_filter_post')); |
|
| 116 | + |
|
| 117 | + add_action('give_pre_get_payments', array($this, 'orderby')); |
|
| 118 | + add_action('give_pre_get_payments', array($this, 'status')); |
|
| 119 | + add_action('give_pre_get_payments', array($this, 'month')); |
|
| 120 | + add_action('give_pre_get_payments', array($this, 'per_page')); |
|
| 121 | + add_action('give_pre_get_payments', array($this, 'page')); |
|
| 122 | + add_action('give_pre_get_payments', array($this, 'user')); |
|
| 123 | + add_action('give_pre_get_payments', array($this, 'search')); |
|
| 124 | + add_action('give_pre_get_payments', array($this, 'mode')); |
|
| 125 | + add_action('give_pre_get_payments', array($this, 'children')); |
|
| 126 | + add_action('give_pre_get_payments', array($this, 'give_forms')); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -139,16 +139,16 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | public function get_payments() { |
| 141 | 141 | |
| 142 | - do_action( 'give_pre_get_payments', $this ); |
|
| 142 | + do_action('give_pre_get_payments', $this); |
|
| 143 | 143 | |
| 144 | - $query = new WP_Query( $this->args ); |
|
| 144 | + $query = new WP_Query($this->args); |
|
| 145 | 145 | |
| 146 | - if ( 'payments' != $this->args['output'] ) { |
|
| 146 | + if ('payments' != $this->args['output']) { |
|
| 147 | 147 | return $query->posts; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - if ( $query->have_posts() ) { |
|
| 151 | - while ( $query->have_posts() ) { |
|
| 150 | + if ($query->have_posts()) { |
|
| 151 | + while ($query->have_posts()) { |
|
| 152 | 152 | $query->the_post(); |
| 153 | 153 | |
| 154 | 154 | $details = new stdClass; |
@@ -158,23 +158,23 @@ discard block |
||
| 158 | 158 | $details->ID = $payment_id; |
| 159 | 159 | $details->date = get_post()->post_date; |
| 160 | 160 | $details->post_status = get_post()->post_status; |
| 161 | - $details->total = give_get_payment_amount( $payment_id ); |
|
| 162 | - $details->fees = give_get_payment_fees( $payment_id ); |
|
| 163 | - $details->key = give_get_payment_key( $payment_id ); |
|
| 164 | - $details->gateway = give_get_payment_gateway( $payment_id ); |
|
| 165 | - $details->user_info = give_get_payment_meta_user_info( $payment_id ); |
|
| 166 | - |
|
| 167 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 168 | - $details->payment_number = give_get_payment_number( $payment_id ); |
|
| 161 | + $details->total = give_get_payment_amount($payment_id); |
|
| 162 | + $details->fees = give_get_payment_fees($payment_id); |
|
| 163 | + $details->key = give_get_payment_key($payment_id); |
|
| 164 | + $details->gateway = give_get_payment_gateway($payment_id); |
|
| 165 | + $details->user_info = give_get_payment_meta_user_info($payment_id); |
|
| 166 | + |
|
| 167 | + if (give_get_option('enable_sequential')) { |
|
| 168 | + $details->payment_number = give_get_payment_number($payment_id); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - $this->payments[] = apply_filters( 'give_payment', $details, $payment_id, $this ); |
|
| 171 | + $this->payments[] = apply_filters('give_payment', $details, $payment_id, $this); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | wp_reset_postdata(); |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - do_action( 'give_post_get_payments', $this ); |
|
| 177 | + do_action('give_post_get_payments', $this); |
|
| 178 | 178 | |
| 179 | 179 | return $this->payments; |
| 180 | 180 | } |
@@ -187,13 +187,13 @@ discard block |
||
| 187 | 187 | * @return void |
| 188 | 188 | */ |
| 189 | 189 | public function date_filter_pre() { |
| 190 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
| 190 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
| 191 | 191 | return; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - $this->setup_dates( $this->args['start_date'], $this->args['end_date'] ); |
|
| 194 | + $this->setup_dates($this->args['start_date'], $this->args['end_date']); |
|
| 195 | 195 | |
| 196 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
| 196 | + add_filter('posts_where', array($this, 'payments_where')); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | /** |
@@ -205,11 +205,11 @@ discard block |
||
| 205 | 205 | * @return void |
| 206 | 206 | */ |
| 207 | 207 | public function date_filter_post() { |
| 208 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
| 208 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
| 209 | 209 | return; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
| 212 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -220,12 +220,12 @@ discard block |
||
| 220 | 220 | * @return void |
| 221 | 221 | */ |
| 222 | 222 | public function status() { |
| 223 | - if ( ! isset ( $this->args['status'] ) ) { |
|
| 223 | + if ( ! isset ($this->args['status'])) { |
|
| 224 | 224 | return; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - $this->__set( 'post_status', $this->args['status'] ); |
|
| 228 | - $this->__unset( 'status' ); |
|
| 227 | + $this->__set('post_status', $this->args['status']); |
|
| 228 | + $this->__unset('status'); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -236,12 +236,12 @@ discard block |
||
| 236 | 236 | * @return void |
| 237 | 237 | */ |
| 238 | 238 | public function page() { |
| 239 | - if ( ! isset ( $this->args['page'] ) ) { |
|
| 239 | + if ( ! isset ($this->args['page'])) { |
|
| 240 | 240 | return; |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - $this->__set( 'paged', $this->args['page'] ); |
|
| 244 | - $this->__unset( 'page' ); |
|
| 243 | + $this->__set('paged', $this->args['page']); |
|
| 244 | + $this->__unset('page'); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
@@ -253,17 +253,17 @@ discard block |
||
| 253 | 253 | */ |
| 254 | 254 | public function per_page() { |
| 255 | 255 | |
| 256 | - if ( ! isset( $this->args['number'] ) ) { |
|
| 256 | + if ( ! isset($this->args['number'])) { |
|
| 257 | 257 | return; |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - if ( $this->args['number'] == - 1 ) { |
|
| 261 | - $this->__set( 'nopaging', true ); |
|
| 260 | + if ($this->args['number'] == - 1) { |
|
| 261 | + $this->__set('nopaging', true); |
|
| 262 | 262 | } else { |
| 263 | - $this->__set( 'posts_per_page', $this->args['number'] ); |
|
| 263 | + $this->__set('posts_per_page', $this->args['number']); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - $this->__unset( 'number' ); |
|
| 266 | + $this->__unset('number'); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -274,12 +274,12 @@ discard block |
||
| 274 | 274 | * @return void |
| 275 | 275 | */ |
| 276 | 276 | public function month() { |
| 277 | - if ( ! isset ( $this->args['month'] ) ) { |
|
| 277 | + if ( ! isset ($this->args['month'])) { |
|
| 278 | 278 | return; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - $this->__set( 'monthnum', $this->args['month'] ); |
|
| 282 | - $this->__unset( 'month' ); |
|
| 281 | + $this->__set('monthnum', $this->args['month']); |
|
| 282 | + $this->__unset('month'); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /** |
@@ -290,13 +290,13 @@ discard block |
||
| 290 | 290 | * @return void |
| 291 | 291 | */ |
| 292 | 292 | public function orderby() { |
| 293 | - switch ( $this->args['orderby'] ) { |
|
| 293 | + switch ($this->args['orderby']) { |
|
| 294 | 294 | case 'amount' : |
| 295 | - $this->__set( 'orderby', 'meta_value_num' ); |
|
| 296 | - $this->__set( 'meta_key', '_give_payment_total' ); |
|
| 295 | + $this->__set('orderby', 'meta_value_num'); |
|
| 296 | + $this->__set('meta_key', '_give_payment_total'); |
|
| 297 | 297 | break; |
| 298 | 298 | default : |
| 299 | - $this->__set( 'orderby', $this->args['orderby'] ); |
|
| 299 | + $this->__set('orderby', $this->args['orderby']); |
|
| 300 | 300 | break; |
| 301 | 301 | } |
| 302 | 302 | } |
@@ -309,20 +309,20 @@ discard block |
||
| 309 | 309 | * @return void |
| 310 | 310 | */ |
| 311 | 311 | public function user() { |
| 312 | - if ( is_null( $this->args['user'] ) ) { |
|
| 312 | + if (is_null($this->args['user'])) { |
|
| 313 | 313 | return; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - if ( is_numeric( $this->args['user'] ) ) { |
|
| 316 | + if (is_numeric($this->args['user'])) { |
|
| 317 | 317 | $user_key = '_give_payment_user_id'; |
| 318 | 318 | } else { |
| 319 | 319 | $user_key = '_give_payment_user_email'; |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - $this->__set( 'meta_query', array( |
|
| 322 | + $this->__set('meta_query', array( |
|
| 323 | 323 | 'key' => $user_key, |
| 324 | 324 | 'value' => $this->args['user'] |
| 325 | - ) ); |
|
| 325 | + )); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | /** |
@@ -334,33 +334,33 @@ discard block |
||
| 334 | 334 | */ |
| 335 | 335 | public function search() { |
| 336 | 336 | |
| 337 | - if ( ! isset( $this->args['s'] ) ) { |
|
| 337 | + if ( ! isset($this->args['s'])) { |
|
| 338 | 338 | return; |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | - $search = trim( $this->args['s'] ); |
|
| 341 | + $search = trim($this->args['s']); |
|
| 342 | 342 | |
| 343 | - if ( empty( $search ) ) { |
|
| 343 | + if (empty($search)) { |
|
| 344 | 344 | return; |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - $is_email = is_email( $search ) || strpos( $search, '@' ) !== false; |
|
| 348 | - $is_user = strpos( $search, strtolower( 'user:' ) ) !== false; |
|
| 347 | + $is_email = is_email($search) || strpos($search, '@') !== false; |
|
| 348 | + $is_user = strpos($search, strtolower('user:')) !== false; |
|
| 349 | 349 | |
| 350 | - if ( ! empty( $this->args['search_in_notes'] ) ) { |
|
| 350 | + if ( ! empty($this->args['search_in_notes'])) { |
|
| 351 | 351 | |
| 352 | - $notes = give_get_payment_notes( 0, $search ); |
|
| 352 | + $notes = give_get_payment_notes(0, $search); |
|
| 353 | 353 | |
| 354 | - if ( ! empty( $notes ) ) { |
|
| 354 | + if ( ! empty($notes)) { |
|
| 355 | 355 | |
| 356 | - $payment_ids = wp_list_pluck( (array) $notes, 'comment_post_ID' ); |
|
| 356 | + $payment_ids = wp_list_pluck((array) $notes, 'comment_post_ID'); |
|
| 357 | 357 | |
| 358 | - $this->__set( 'post__in', $payment_ids ); |
|
| 358 | + $this->__set('post__in', $payment_ids); |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - $this->__unset( 's' ); |
|
| 361 | + $this->__unset('s'); |
|
| 362 | 362 | |
| 363 | - } elseif ( $is_email || strlen( $search ) == 32 ) { |
|
| 363 | + } elseif ($is_email || strlen($search) == 32) { |
|
| 364 | 364 | |
| 365 | 365 | $key = $is_email ? '_give_payment_user_email' : '_give_payment_purchase_key'; |
| 366 | 366 | $search_meta = array( |
@@ -369,19 +369,19 @@ discard block |
||
| 369 | 369 | 'compare' => 'LIKE' |
| 370 | 370 | ); |
| 371 | 371 | |
| 372 | - $this->__set( 'meta_query', $search_meta ); |
|
| 373 | - $this->__unset( 's' ); |
|
| 372 | + $this->__set('meta_query', $search_meta); |
|
| 373 | + $this->__unset('s'); |
|
| 374 | 374 | |
| 375 | - } elseif ( $is_user ) { |
|
| 375 | + } elseif ($is_user) { |
|
| 376 | 376 | |
| 377 | 377 | $search_meta = array( |
| 378 | 378 | 'key' => '_give_payment_user_id', |
| 379 | - 'value' => trim( str_replace( 'user:', '', strtolower( $search ) ) ) |
|
| 379 | + 'value' => trim(str_replace('user:', '', strtolower($search))) |
|
| 380 | 380 | ); |
| 381 | 381 | |
| 382 | - $this->__set( 'meta_query', $search_meta ); |
|
| 382 | + $this->__set('meta_query', $search_meta); |
|
| 383 | 383 | |
| 384 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 384 | + if (give_get_option('enable_sequential')) { |
|
| 385 | 385 | |
| 386 | 386 | $search_meta = array( |
| 387 | 387 | 'key' => '_give_payment_number', |
@@ -389,19 +389,19 @@ discard block |
||
| 389 | 389 | 'compare' => 'LIKE' |
| 390 | 390 | ); |
| 391 | 391 | |
| 392 | - $this->__set( 'meta_query', $search_meta ); |
|
| 392 | + $this->__set('meta_query', $search_meta); |
|
| 393 | 393 | |
| 394 | 394 | $this->args['meta_query']['relation'] = 'OR'; |
| 395 | 395 | |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | - $this->__unset( 's' ); |
|
| 398 | + $this->__unset('s'); |
|
| 399 | 399 | |
| 400 | 400 | } elseif ( |
| 401 | - give_get_option( 'enable_sequential' ) && |
|
| 401 | + give_get_option('enable_sequential') && |
|
| 402 | 402 | ( |
| 403 | - false !== strpos( $search, give_get_option( 'sequential_prefix' ) ) || |
|
| 404 | - false !== strpos( $search, give_get_option( 'sequential_postfix' ) ) |
|
| 403 | + false !== strpos($search, give_get_option('sequential_prefix')) || |
|
| 404 | + false !== strpos($search, give_get_option('sequential_postfix')) |
|
| 405 | 405 | ) |
| 406 | 406 | ) { |
| 407 | 407 | |
@@ -411,28 +411,28 @@ discard block |
||
| 411 | 411 | 'compare' => 'LIKE' |
| 412 | 412 | ); |
| 413 | 413 | |
| 414 | - $this->__set( 'meta_query', $search_meta ); |
|
| 415 | - $this->__unset( 's' ); |
|
| 414 | + $this->__set('meta_query', $search_meta); |
|
| 415 | + $this->__unset('s'); |
|
| 416 | 416 | |
| 417 | - } elseif ( is_numeric( $search ) ) { |
|
| 417 | + } elseif (is_numeric($search)) { |
|
| 418 | 418 | |
| 419 | - $post = get_post( $search ); |
|
| 419 | + $post = get_post($search); |
|
| 420 | 420 | |
| 421 | - if ( is_object( $post ) && $post->post_type == 'give_payment' ) { |
|
| 421 | + if (is_object($post) && $post->post_type == 'give_payment') { |
|
| 422 | 422 | |
| 423 | 423 | $arr = array(); |
| 424 | 424 | $arr[] = $search; |
| 425 | - $this->__set( 'post__in', $arr ); |
|
| 426 | - $this->__unset( 's' ); |
|
| 425 | + $this->__set('post__in', $arr); |
|
| 426 | + $this->__unset('s'); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - } elseif ( '#' == substr( $search, 0, 1 ) ) { |
|
| 429 | + } elseif ('#' == substr($search, 0, 1)) { |
|
| 430 | 430 | |
| 431 | - $this->__set( 'give_forms', str_replace( '#', '', $search ) ); |
|
| 432 | - $this->__unset( 's' ); |
|
| 431 | + $this->__set('give_forms', str_replace('#', '', $search)); |
|
| 432 | + $this->__unset('s'); |
|
| 433 | 433 | |
| 434 | 434 | } else { |
| 435 | - $this->__set( 's', $search ); |
|
| 435 | + $this->__set('s', $search); |
|
| 436 | 436 | |
| 437 | 437 | } |
| 438 | 438 | |
@@ -446,16 +446,16 @@ discard block |
||
| 446 | 446 | * @return void |
| 447 | 447 | */ |
| 448 | 448 | public function mode() { |
| 449 | - if ( empty( $this->args['mode'] ) || $this->args['mode'] == 'all' ) { |
|
| 450 | - $this->__unset( 'mode' ); |
|
| 449 | + if (empty($this->args['mode']) || $this->args['mode'] == 'all') { |
|
| 450 | + $this->__unset('mode'); |
|
| 451 | 451 | |
| 452 | 452 | return; |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - $this->__set( 'meta_query', array( |
|
| 455 | + $this->__set('meta_query', array( |
|
| 456 | 456 | 'key' => '_give_payment_mode', |
| 457 | 457 | 'value' => $this->args['mode'] |
| 458 | - ) ); |
|
| 458 | + )); |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | /** |
@@ -466,10 +466,10 @@ discard block |
||
| 466 | 466 | * @return void |
| 467 | 467 | */ |
| 468 | 468 | public function children() { |
| 469 | - if ( empty( $this->args['children'] ) ) { |
|
| 470 | - $this->__set( 'post_parent', 0 ); |
|
| 469 | + if (empty($this->args['children'])) { |
|
| 470 | + $this->__set('post_parent', 0); |
|
| 471 | 471 | } |
| 472 | - $this->__unset( 'children' ); |
|
| 472 | + $this->__unset('children'); |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | /** |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | */ |
| 482 | 482 | public function give_forms() { |
| 483 | 483 | |
| 484 | - if ( empty( $this->args['give_forms'] ) ) { |
|
| 484 | + if (empty($this->args['give_forms'])) { |
|
| 485 | 485 | return; |
| 486 | 486 | } |
| 487 | 487 | |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | $args = array( |
| 491 | 491 | // 'post_id' => $this->args['give_forms'], |
| 492 | 492 | 'log_type' => 'sale', |
| 493 | - 'post_status' => array( 'publish' ), |
|
| 493 | + 'post_status' => array('publish'), |
|
| 494 | 494 | 'nopaging' => true, |
| 495 | 495 | 'no_found_rows' => true, |
| 496 | 496 | 'update_post_term_cache' => false, |
@@ -499,31 +499,31 @@ discard block |
||
| 499 | 499 | 'fields' => 'ids' |
| 500 | 500 | ); |
| 501 | 501 | |
| 502 | - if ( is_array( $this->args['give_forms'] ) ) { |
|
| 503 | - unset( $args['post_parent'] ); |
|
| 502 | + if (is_array($this->args['give_forms'])) { |
|
| 503 | + unset($args['post_parent']); |
|
| 504 | 504 | $args['post_parent__in'] = $this->args['give_forms']; |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | - $sales = $give_logs->get_connected_logs( $args ); |
|
| 507 | + $sales = $give_logs->get_connected_logs($args); |
|
| 508 | 508 | |
| 509 | - if ( ! empty( $sales ) ) { |
|
| 509 | + if ( ! empty($sales)) { |
|
| 510 | 510 | |
| 511 | 511 | $payments = array(); |
| 512 | 512 | |
| 513 | - foreach ( $sales as $sale ) { |
|
| 514 | - $payments[] = get_post_meta( $sale, '_give_log_payment_id', true ); |
|
| 513 | + foreach ($sales as $sale) { |
|
| 514 | + $payments[] = get_post_meta($sale, '_give_log_payment_id', true); |
|
| 515 | 515 | } |
| 516 | 516 | |
| 517 | - $this->__set( 'post__in', $payments ); |
|
| 517 | + $this->__set('post__in', $payments); |
|
| 518 | 518 | |
| 519 | 519 | } else { |
| 520 | 520 | |
| 521 | 521 | // Set post_parent to something crazy so it doesn't find anything |
| 522 | - $this->__set( 'post_parent', 999999999999999 ); |
|
| 522 | + $this->__set('post_parent', 999999999999999); |
|
| 523 | 523 | |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | - $this->__unset( 'give_forms' ); |
|
| 526 | + $this->__unset('give_forms'); |
|
| 527 | 527 | |
| 528 | 528 | } |
| 529 | 529 | } |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Post Type Functions |
|
| 4 | - * |
|
| 5 | - * @package Give |
|
| 6 | - * @subpackage Functions |
|
| 7 | - * @copyright Copyright (c) 2015, WordImpress |
|
| 8 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
| 9 | - * @since 1.0 |
|
| 10 | - */ |
|
| 3 | + * Post Type Functions |
|
| 4 | + * |
|
| 5 | + * @package Give |
|
| 6 | + * @subpackage Functions |
|
| 7 | + * @copyright Copyright (c) 2015, WordImpress |
|
| 8 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
| 9 | + * @since 1.0 |
|
| 10 | + */ |
|
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -23,40 +23,40 @@ discard block |
||
| 23 | 23 | function give_setup_post_types() { |
| 24 | 24 | |
| 25 | 25 | /** Give Forms Post Type */ |
| 26 | - $give_forms_singular = give_get_option( 'disable_forms_singular' ) !== 'on' ? true : false; |
|
| 26 | + $give_forms_singular = give_get_option('disable_forms_singular') !== 'on' ? true : false; |
|
| 27 | 27 | |
| 28 | - $give_forms_archives = give_get_option( 'disable_forms_archives' ) !== 'on' ? true : false; |
|
| 28 | + $give_forms_archives = give_get_option('disable_forms_archives') !== 'on' ? true : false; |
|
| 29 | 29 | |
| 30 | - $give_forms_slug = defined( 'GIVE_SLUG' ) ? GIVE_SLUG : 'donations'; |
|
| 30 | + $give_forms_slug = defined('GIVE_SLUG') ? GIVE_SLUG : 'donations'; |
|
| 31 | 31 | //support for old 'GIVE_FORMS_SLUG' constant |
| 32 | - if ( defined( 'GIVE_FORMS_SLUG' ) ) { |
|
| 32 | + if (defined('GIVE_FORMS_SLUG')) { |
|
| 33 | 33 | $give_forms_slug = GIVE_FORMS_SLUG; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - $give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
| 36 | + $give_forms_rewrite = defined('GIVE_DISABLE_FORMS_REWRITE') && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
| 37 | 37 | 'slug' => $give_forms_slug, |
| 38 | 38 | 'with_front' => false |
| 39 | 39 | ); |
| 40 | 40 | |
| 41 | - $give_forms_labels = apply_filters( 'give_forms_labels', array( |
|
| 42 | - 'name' => __( 'Donation %2$s', 'give' ), |
|
| 41 | + $give_forms_labels = apply_filters('give_forms_labels', array( |
|
| 42 | + 'name' => __('Donation %2$s', 'give'), |
|
| 43 | 43 | 'singular_name' => '%1$s', |
| 44 | - 'add_new' => __( 'Add %1$s', 'give' ), |
|
| 45 | - 'add_new_item' => __( 'Add New Donation %1$s', 'give' ), |
|
| 46 | - 'edit_item' => __( 'Edit Donation %1$s', 'give' ), |
|
| 47 | - 'new_item' => __( 'New %1$s', 'give' ), |
|
| 48 | - 'all_items' => __( 'All %2$s', 'give' ), |
|
| 49 | - 'view_item' => __( 'View %1$s', 'give' ), |
|
| 50 | - 'search_items' => __( 'Search %2$s', 'give' ), |
|
| 51 | - 'not_found' => __( 'No %2$s found', 'give' ), |
|
| 52 | - 'not_found_in_trash' => __( 'No %2$s found in Trash', 'give' ), |
|
| 44 | + 'add_new' => __('Add %1$s', 'give'), |
|
| 45 | + 'add_new_item' => __('Add New Donation %1$s', 'give'), |
|
| 46 | + 'edit_item' => __('Edit Donation %1$s', 'give'), |
|
| 47 | + 'new_item' => __('New %1$s', 'give'), |
|
| 48 | + 'all_items' => __('All %2$s', 'give'), |
|
| 49 | + 'view_item' => __('View %1$s', 'give'), |
|
| 50 | + 'search_items' => __('Search %2$s', 'give'), |
|
| 51 | + 'not_found' => __('No %2$s found', 'give'), |
|
| 52 | + 'not_found_in_trash' => __('No %2$s found in Trash', 'give'), |
|
| 53 | 53 | 'parent_item_colon' => '', |
| 54 | - 'menu_name' => apply_filters( 'give_menu_name', __( 'Donations', 'give' ) ), |
|
| 55 | - 'name_admin_bar' => apply_filters( 'give_name_admin_bar_name', __( 'Donation Form', 'give' ) ) |
|
| 56 | - ) ); |
|
| 54 | + 'menu_name' => apply_filters('give_menu_name', __('Donations', 'give')), |
|
| 55 | + 'name_admin_bar' => apply_filters('give_name_admin_bar_name', __('Donation Form', 'give')) |
|
| 56 | + )); |
|
| 57 | 57 | |
| 58 | - foreach ( $give_forms_labels as $key => $value ) { |
|
| 59 | - $give_forms_labels[ $key ] = sprintf( $value, give_get_forms_label_singular(), give_get_forms_label_plural() ); |
|
| 58 | + foreach ($give_forms_labels as $key => $value) { |
|
| 59 | + $give_forms_labels[$key] = sprintf($value, give_get_forms_label_singular(), give_get_forms_label_plural()); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | //Default give_forms supports |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | ); |
| 70 | 70 | |
| 71 | 71 | //Has the user disabled the excerpt |
| 72 | - if ( give_get_option( 'disable_forms_excerpt' ) === 'on' ) { |
|
| 73 | - unset( $give_form_supports[2] ); |
|
| 72 | + if (give_get_option('disable_forms_excerpt') === 'on') { |
|
| 73 | + unset($give_form_supports[2]); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | //Has user disabled the featured image? |
| 77 | - if ( give_get_option( 'disable_form_featured_img' ) === 'on' ) { |
|
| 78 | - unset( $give_form_supports[1] ); |
|
| 79 | - remove_action( 'give_before_single_form_summary', 'give_show_form_images' ); |
|
| 77 | + if (give_get_option('disable_form_featured_img') === 'on') { |
|
| 78 | + unset($give_form_supports[1]); |
|
| 79 | + remove_action('give_before_single_form_summary', 'give_show_form_images'); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | $give_forms_args = array( |
@@ -92,36 +92,36 @@ discard block |
||
| 92 | 92 | 'has_archive' => $give_forms_archives, |
| 93 | 93 | 'menu_icon' => 'dashicons-give', |
| 94 | 94 | 'hierarchical' => false, |
| 95 | - 'supports' => apply_filters( 'give_forms_supports', $give_form_supports ), |
|
| 95 | + 'supports' => apply_filters('give_forms_supports', $give_form_supports), |
|
| 96 | 96 | ); |
| 97 | - register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) ); |
|
| 97 | + register_post_type('give_forms', apply_filters('give_forms_post_type_args', $give_forms_args)); |
|
| 98 | 98 | |
| 99 | 99 | |
| 100 | 100 | /** Give Campaigns Post Type */ |
| 101 | - $give_campaigns_archives = defined( 'GIVE_DISABLE_CAMPAIGNS_ARCHIVE' ) && GIVE_DISABLE_CAMPAIGNS_ARCHIVE ? false : true; |
|
| 102 | - $give_campaigns_slug = defined( 'GIVE_CAMPAIGNS_SLUG' ) ? GIVE_CAMPAIGNS_SLUG : 'campaigns'; |
|
| 103 | - $give_campaigns_rewrite = defined( 'GIVE_DISABLE_CAMPAIGNS_REWRITE' ) && GIVE_DISABLE_CAMPAIGNS_REWRITE ? false : array( |
|
| 101 | + $give_campaigns_archives = defined('GIVE_DISABLE_CAMPAIGNS_ARCHIVE') && GIVE_DISABLE_CAMPAIGNS_ARCHIVE ? false : true; |
|
| 102 | + $give_campaigns_slug = defined('GIVE_CAMPAIGNS_SLUG') ? GIVE_CAMPAIGNS_SLUG : 'campaigns'; |
|
| 103 | + $give_campaigns_rewrite = defined('GIVE_DISABLE_CAMPAIGNS_REWRITE') && GIVE_DISABLE_CAMPAIGNS_REWRITE ? false : array( |
|
| 104 | 104 | 'slug' => $give_campaigns_slug, |
| 105 | 105 | 'with_front' => false |
| 106 | 106 | ); |
| 107 | 107 | |
| 108 | - $give_campaigns_labels = apply_filters( 'give_campaign_labels', array( |
|
| 108 | + $give_campaigns_labels = apply_filters('give_campaign_labels', array( |
|
| 109 | 109 | 'name' => '%2$s', |
| 110 | 110 | 'singular_name' => '%1$s', |
| 111 | - 'add_new' => __( 'Add %1$s', 'give' ), |
|
| 112 | - 'add_new_item' => __( 'Add New %1$s', 'give' ), |
|
| 113 | - 'edit_item' => __( 'Edit %1$s', 'give' ), |
|
| 114 | - 'new_item' => __( 'New %1$s', 'give' ), |
|
| 115 | - 'all_items' => __( 'All %2$s', 'give' ), |
|
| 116 | - 'view_item' => __( 'View %1$s', 'give' ), |
|
| 117 | - 'search_items' => __( 'Search %2$s', 'give' ), |
|
| 118 | - 'not_found' => __( 'No %2$s found', 'give' ), |
|
| 119 | - 'not_found_in_trash' => __( 'No %2$s found in Trash', 'give' ), |
|
| 111 | + 'add_new' => __('Add %1$s', 'give'), |
|
| 112 | + 'add_new_item' => __('Add New %1$s', 'give'), |
|
| 113 | + 'edit_item' => __('Edit %1$s', 'give'), |
|
| 114 | + 'new_item' => __('New %1$s', 'give'), |
|
| 115 | + 'all_items' => __('All %2$s', 'give'), |
|
| 116 | + 'view_item' => __('View %1$s', 'give'), |
|
| 117 | + 'search_items' => __('Search %2$s', 'give'), |
|
| 118 | + 'not_found' => __('No %2$s found', 'give'), |
|
| 119 | + 'not_found_in_trash' => __('No %2$s found in Trash', 'give'), |
|
| 120 | 120 | 'parent_item_colon' => '', |
| 121 | - ) ); |
|
| 121 | + )); |
|
| 122 | 122 | |
| 123 | - foreach ( $give_campaigns_labels as $key => $value ) { |
|
| 124 | - $give_campaigns_labels[ $key ] = sprintf( $value, give_get_campaigns_label_singular(), give_get_campaigns_label_plural() ); |
|
| 123 | + foreach ($give_campaigns_labels as $key => $value) { |
|
| 124 | + $give_campaigns_labels[$key] = sprintf($value, give_get_campaigns_label_singular(), give_get_campaigns_label_plural()); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | $give_campaigns_args = array( |
@@ -136,48 +136,48 @@ discard block |
||
| 136 | 136 | 'capability_type' => 'give_campaigns', |
| 137 | 137 | 'has_archive' => $give_campaigns_archives, |
| 138 | 138 | 'hierarchical' => false, |
| 139 | - 'supports' => apply_filters( 'give_campaigns_supports', array( |
|
| 139 | + 'supports' => apply_filters('give_campaigns_supports', array( |
|
| 140 | 140 | 'title', |
| 141 | 141 | 'thumbnail', |
| 142 | 142 | 'excerpt', |
| 143 | 143 | 'revisions', |
| 144 | 144 | 'author' |
| 145 | - ) ), |
|
| 145 | + )), |
|
| 146 | 146 | ); |
| 147 | 147 | // register_post_type( 'give_campaigns', apply_filters( 'give_campaigns_post_type_args', $give_campaigns_args ) ); |
| 148 | 148 | |
| 149 | 149 | /** Payment Post Type */ |
| 150 | 150 | $payment_labels = array( |
| 151 | - 'name' => _x( 'Donations', 'post type general name', 'give' ), |
|
| 152 | - 'singular_name' => _x( 'Donation', 'post type singular name', 'give' ), |
|
| 153 | - 'add_new' => __( 'Add New', 'give' ), |
|
| 154 | - 'add_new_item' => __( 'Add New Donation', 'give' ), |
|
| 155 | - 'edit_item' => __( 'Edit Donation', 'give' ), |
|
| 156 | - 'new_item' => __( 'New Donation', 'give' ), |
|
| 157 | - 'all_items' => __( 'All Donations', 'give' ), |
|
| 158 | - 'view_item' => __( 'View Donation', 'give' ), |
|
| 159 | - 'search_items' => __( 'Search Donations', 'give' ), |
|
| 160 | - 'not_found' => __( 'No Donations found', 'give' ), |
|
| 161 | - 'not_found_in_trash' => __( 'No Donations found in Trash', 'give' ), |
|
| 151 | + 'name' => _x('Donations', 'post type general name', 'give'), |
|
| 152 | + 'singular_name' => _x('Donation', 'post type singular name', 'give'), |
|
| 153 | + 'add_new' => __('Add New', 'give'), |
|
| 154 | + 'add_new_item' => __('Add New Donation', 'give'), |
|
| 155 | + 'edit_item' => __('Edit Donation', 'give'), |
|
| 156 | + 'new_item' => __('New Donation', 'give'), |
|
| 157 | + 'all_items' => __('All Donations', 'give'), |
|
| 158 | + 'view_item' => __('View Donation', 'give'), |
|
| 159 | + 'search_items' => __('Search Donations', 'give'), |
|
| 160 | + 'not_found' => __('No Donations found', 'give'), |
|
| 161 | + 'not_found_in_trash' => __('No Donations found in Trash', 'give'), |
|
| 162 | 162 | 'parent_item_colon' => '', |
| 163 | - 'menu_name' => __( 'Transactions', 'give' ) |
|
| 163 | + 'menu_name' => __('Transactions', 'give') |
|
| 164 | 164 | ); |
| 165 | 165 | |
| 166 | 166 | $payment_args = array( |
| 167 | - 'labels' => apply_filters( 'give_payment_labels', $payment_labels ), |
|
| 167 | + 'labels' => apply_filters('give_payment_labels', $payment_labels), |
|
| 168 | 168 | 'public' => false, |
| 169 | 169 | 'query_var' => false, |
| 170 | 170 | 'rewrite' => false, |
| 171 | 171 | 'map_meta_cap' => true, |
| 172 | 172 | 'capability_type' => 'give_payment', |
| 173 | - 'supports' => array( 'title' ), |
|
| 173 | + 'supports' => array('title'), |
|
| 174 | 174 | 'can_export' => true |
| 175 | 175 | ); |
| 176 | - register_post_type( 'give_payment', $payment_args ); |
|
| 176 | + register_post_type('give_payment', $payment_args); |
|
| 177 | 177 | |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | -add_action( 'init', 'give_setup_post_types', 1 ); |
|
| 180 | +add_action('init', 'give_setup_post_types', 1); |
|
| 181 | 181 | |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -190,30 +190,30 @@ discard block |
||
| 190 | 190 | */ |
| 191 | 191 | function give_setup_taxonomies() { |
| 192 | 192 | |
| 193 | - $slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations'; |
|
| 193 | + $slug = defined('GIVE_FORMS_SLUG') ? GIVE_FORMS_SLUG : 'donations'; |
|
| 194 | 194 | |
| 195 | 195 | /** Categories */ |
| 196 | 196 | $category_labels = array( |
| 197 | - 'name' => sprintf( _x( '%s Categories', 'taxonomy general name', 'give' ), give_get_forms_label_singular() ), |
|
| 198 | - 'singular_name' => _x( 'Category', 'taxonomy singular name', 'give' ), |
|
| 199 | - 'search_items' => __( 'Search Categories', 'give' ), |
|
| 200 | - 'all_items' => __( 'All Categories', 'give' ), |
|
| 201 | - 'parent_item' => __( 'Parent Category', 'give' ), |
|
| 202 | - 'parent_item_colon' => __( 'Parent Category:', 'give' ), |
|
| 203 | - 'edit_item' => __( 'Edit Category', 'give' ), |
|
| 204 | - 'update_item' => __( 'Update Category', 'give' ), |
|
| 205 | - 'add_new_item' => sprintf( __( 'Add New %s Category', 'give' ), give_get_forms_label_singular() ), |
|
| 206 | - 'new_item_name' => __( 'New Category Name', 'give' ), |
|
| 207 | - 'menu_name' => __( 'Categories', 'give' ), |
|
| 197 | + 'name' => sprintf(_x('%s Categories', 'taxonomy general name', 'give'), give_get_forms_label_singular()), |
|
| 198 | + 'singular_name' => _x('Category', 'taxonomy singular name', 'give'), |
|
| 199 | + 'search_items' => __('Search Categories', 'give'), |
|
| 200 | + 'all_items' => __('All Categories', 'give'), |
|
| 201 | + 'parent_item' => __('Parent Category', 'give'), |
|
| 202 | + 'parent_item_colon' => __('Parent Category:', 'give'), |
|
| 203 | + 'edit_item' => __('Edit Category', 'give'), |
|
| 204 | + 'update_item' => __('Update Category', 'give'), |
|
| 205 | + 'add_new_item' => sprintf(__('Add New %s Category', 'give'), give_get_forms_label_singular()), |
|
| 206 | + 'new_item_name' => __('New Category Name', 'give'), |
|
| 207 | + 'menu_name' => __('Categories', 'give'), |
|
| 208 | 208 | ); |
| 209 | 209 | |
| 210 | - $category_args = apply_filters( 'give_forms_category_args', array( |
|
| 210 | + $category_args = apply_filters('give_forms_category_args', array( |
|
| 211 | 211 | 'hierarchical' => true, |
| 212 | - 'labels' => apply_filters( 'give_forms_category_labels', $category_labels ), |
|
| 212 | + 'labels' => apply_filters('give_forms_category_labels', $category_labels), |
|
| 213 | 213 | 'show_ui' => true, |
| 214 | 214 | 'query_var' => 'give_forms_category', |
| 215 | 215 | 'rewrite' => array( |
| 216 | - 'slug' => $slug . '/category', |
|
| 216 | + 'slug' => $slug.'/category', |
|
| 217 | 217 | 'with_front' => false, |
| 218 | 218 | 'hierarchical' => true |
| 219 | 219 | ), |
@@ -227,34 +227,34 @@ discard block |
||
| 227 | 227 | ); |
| 228 | 228 | |
| 229 | 229 | //Does the user want categories? |
| 230 | - if ( give_get_option( 'enable_categories' ) == 'on' ) { |
|
| 231 | - register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args ); |
|
| 232 | - register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' ); |
|
| 230 | + if (give_get_option('enable_categories') == 'on') { |
|
| 231 | + register_taxonomy('give_forms_category', array('give_forms'), $category_args); |
|
| 232 | + register_taxonomy_for_object_type('give_forms_category', 'give_forms'); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | |
| 236 | 236 | /** Tags */ |
| 237 | 237 | $tag_labels = array( |
| 238 | - 'name' => sprintf( _x( '%s Tags', 'taxonomy general name', 'give' ), give_get_forms_label_singular() ), |
|
| 239 | - 'singular_name' => _x( 'Tag', 'taxonomy singular name', 'give' ), |
|
| 240 | - 'search_items' => __( 'Search Tags', 'give' ), |
|
| 241 | - 'all_items' => __( 'All Tags', 'give' ), |
|
| 242 | - 'parent_item' => __( 'Parent Tag', 'give' ), |
|
| 243 | - 'parent_item_colon' => __( 'Parent Tag:', 'give' ), |
|
| 244 | - 'edit_item' => __( 'Edit Tag', 'give' ), |
|
| 245 | - 'update_item' => __( 'Update Tag', 'give' ), |
|
| 246 | - 'add_new_item' => __( 'Add New Tag', 'give' ), |
|
| 247 | - 'new_item_name' => __( 'New Tag Name', 'give' ), |
|
| 248 | - 'menu_name' => __( 'Tags', 'give' ), |
|
| 249 | - 'choose_from_most_used' => sprintf( __( 'Choose from most used %s tags', 'give' ), give_get_forms_label_singular() ), |
|
| 238 | + 'name' => sprintf(_x('%s Tags', 'taxonomy general name', 'give'), give_get_forms_label_singular()), |
|
| 239 | + 'singular_name' => _x('Tag', 'taxonomy singular name', 'give'), |
|
| 240 | + 'search_items' => __('Search Tags', 'give'), |
|
| 241 | + 'all_items' => __('All Tags', 'give'), |
|
| 242 | + 'parent_item' => __('Parent Tag', 'give'), |
|
| 243 | + 'parent_item_colon' => __('Parent Tag:', 'give'), |
|
| 244 | + 'edit_item' => __('Edit Tag', 'give'), |
|
| 245 | + 'update_item' => __('Update Tag', 'give'), |
|
| 246 | + 'add_new_item' => __('Add New Tag', 'give'), |
|
| 247 | + 'new_item_name' => __('New Tag Name', 'give'), |
|
| 248 | + 'menu_name' => __('Tags', 'give'), |
|
| 249 | + 'choose_from_most_used' => sprintf(__('Choose from most used %s tags', 'give'), give_get_forms_label_singular()), |
|
| 250 | 250 | ); |
| 251 | 251 | |
| 252 | - $tag_args = apply_filters( 'give_forms_tag_args', array( |
|
| 252 | + $tag_args = apply_filters('give_forms_tag_args', array( |
|
| 253 | 253 | 'hierarchical' => false, |
| 254 | - 'labels' => apply_filters( 'give_forms_tag_labels', $tag_labels ), |
|
| 254 | + 'labels' => apply_filters('give_forms_tag_labels', $tag_labels), |
|
| 255 | 255 | 'show_ui' => true, |
| 256 | 256 | 'query_var' => 'give_forms_tag', |
| 257 | - 'rewrite' => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ), |
|
| 257 | + 'rewrite' => array('slug' => $slug.'/tag', 'with_front' => false, 'hierarchical' => true), |
|
| 258 | 258 | 'capabilities' => array( |
| 259 | 259 | 'manage_terms' => 'manage_give_forms_terms', |
| 260 | 260 | 'edit_terms' => 'edit_give_forms_terms', |
@@ -265,15 +265,15 @@ discard block |
||
| 265 | 265 | ) |
| 266 | 266 | ); |
| 267 | 267 | |
| 268 | - if ( give_get_option( 'enable_tags' ) == 'on' ) { |
|
| 269 | - register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args ); |
|
| 270 | - register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' ); |
|
| 268 | + if (give_get_option('enable_tags') == 'on') { |
|
| 269 | + register_taxonomy('give_forms_tag', array('give_forms'), $tag_args); |
|
| 270 | + register_taxonomy_for_object_type('give_forms_tag', 'give_forms'); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | -add_action( 'init', 'give_setup_taxonomies', 0 ); |
|
| 276 | +add_action('init', 'give_setup_taxonomies', 0); |
|
| 277 | 277 | |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -284,11 +284,11 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | function give_get_default_form_labels() { |
| 286 | 286 | $defaults = array( |
| 287 | - 'singular' => __( 'Form', 'give' ), |
|
| 288 | - 'plural' => __( 'Forms', 'give' ) |
|
| 287 | + 'singular' => __('Form', 'give'), |
|
| 288 | + 'plural' => __('Forms', 'give') |
|
| 289 | 289 | ); |
| 290 | 290 | |
| 291 | - return apply_filters( 'give_default_form_name', $defaults ); |
|
| 291 | + return apply_filters('give_default_form_name', $defaults); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | /** |
@@ -299,11 +299,11 @@ discard block |
||
| 299 | 299 | */ |
| 300 | 300 | function give_get_default_campaign_labels() { |
| 301 | 301 | $defaults = array( |
| 302 | - 'singular' => __( 'Campaign', 'give' ), |
|
| 303 | - 'plural' => __( 'Campaigns', 'give' ) |
|
| 302 | + 'singular' => __('Campaign', 'give'), |
|
| 303 | + 'plural' => __('Campaigns', 'give') |
|
| 304 | 304 | ); |
| 305 | 305 | |
| 306 | - return apply_filters( 'give_default_campaign_name', $defaults ); |
|
| 306 | + return apply_filters('give_default_campaign_name', $defaults); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | /** |
@@ -315,10 +315,10 @@ discard block |
||
| 315 | 315 | * |
| 316 | 316 | * @return string $defaults['singular'] Singular label |
| 317 | 317 | */ |
| 318 | -function give_get_forms_label_singular( $lowercase = false ) { |
|
| 318 | +function give_get_forms_label_singular($lowercase = false) { |
|
| 319 | 319 | $defaults = give_get_default_form_labels(); |
| 320 | 320 | |
| 321 | - return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular']; |
|
| 321 | + return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular']; |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | /** |
@@ -327,10 +327,10 @@ discard block |
||
| 327 | 327 | * @since 1.0 |
| 328 | 328 | * @return string $defaults['plural'] Plural label |
| 329 | 329 | */ |
| 330 | -function give_get_forms_label_plural( $lowercase = false ) { |
|
| 330 | +function give_get_forms_label_plural($lowercase = false) { |
|
| 331 | 331 | $defaults = give_get_default_form_labels(); |
| 332 | 332 | |
| 333 | - return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural']; |
|
| 333 | + return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural']; |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | /** |
@@ -342,10 +342,10 @@ discard block |
||
| 342 | 342 | * |
| 343 | 343 | * @return string $defaults['singular'] Singular label |
| 344 | 344 | */ |
| 345 | -function give_get_campaigns_label_singular( $lowercase = false ) { |
|
| 345 | +function give_get_campaigns_label_singular($lowercase = false) { |
|
| 346 | 346 | $defaults = give_get_default_campaign_labels(); |
| 347 | 347 | |
| 348 | - return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular']; |
|
| 348 | + return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular']; |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | /** |
@@ -354,10 +354,10 @@ discard block |
||
| 354 | 354 | * @since 1.0 |
| 355 | 355 | * @return string $defaults['plural'] Plural label |
| 356 | 356 | */ |
| 357 | -function give_get_campaigns_label_plural( $lowercase = false ) { |
|
| 357 | +function give_get_campaigns_label_plural($lowercase = false) { |
|
| 358 | 358 | $defaults = give_get_default_campaign_labels(); |
| 359 | 359 | |
| 360 | - return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural']; |
|
| 360 | + return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural']; |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | /** |
@@ -369,26 +369,26 @@ discard block |
||
| 369 | 369 | * |
| 370 | 370 | * @return string $title New placeholder text |
| 371 | 371 | */ |
| 372 | -function give_change_default_title( $title ) { |
|
| 372 | +function give_change_default_title($title) { |
|
| 373 | 373 | // If a frontend plugin uses this filter (check extensions before changing this function) |
| 374 | - if ( ! is_admin() ) { |
|
| 374 | + if ( ! is_admin()) { |
|
| 375 | 375 | $label = give_get_forms_label_singular(); |
| 376 | - $title = sprintf( __( 'Enter %s title here', 'give' ), $label ); |
|
| 376 | + $title = sprintf(__('Enter %s title here', 'give'), $label); |
|
| 377 | 377 | |
| 378 | 378 | return $title; |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | $screen = get_current_screen(); |
| 382 | 382 | |
| 383 | - if ( 'give_forms' == $screen->post_type ) { |
|
| 383 | + if ('give_forms' == $screen->post_type) { |
|
| 384 | 384 | $label = give_get_forms_label_singular(); |
| 385 | - $title = sprintf( __( 'Enter %s title here', 'give' ), $label ); |
|
| 385 | + $title = sprintf(__('Enter %s title here', 'give'), $label); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | return $title; |
| 389 | 389 | } |
| 390 | 390 | |
| 391 | -add_filter( 'enter_title_here', 'give_change_default_title' ); |
|
| 391 | +add_filter('enter_title_here', 'give_change_default_title'); |
|
| 392 | 392 | |
| 393 | 393 | /** |
| 394 | 394 | * Registers Custom Post Statuses which are used by the Payments |
@@ -398,42 +398,42 @@ discard block |
||
| 398 | 398 | */ |
| 399 | 399 | function give_register_post_type_statuses() { |
| 400 | 400 | // Payment Statuses |
| 401 | - register_post_status( 'refunded', array( |
|
| 402 | - 'label' => _x( 'Refunded', 'Refunded payment status', 'give' ), |
|
| 401 | + register_post_status('refunded', array( |
|
| 402 | + 'label' => _x('Refunded', 'Refunded payment status', 'give'), |
|
| 403 | 403 | 'public' => true, |
| 404 | 404 | 'exclude_from_search' => false, |
| 405 | 405 | 'show_in_admin_all_list' => true, |
| 406 | 406 | 'show_in_admin_status_list' => true, |
| 407 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' ) |
|
| 408 | - ) ); |
|
| 409 | - register_post_status( 'failed', array( |
|
| 410 | - 'label' => _x( 'Failed', 'Failed payment status', 'give' ), |
|
| 407 | + 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give') |
|
| 408 | + )); |
|
| 409 | + register_post_status('failed', array( |
|
| 410 | + 'label' => _x('Failed', 'Failed payment status', 'give'), |
|
| 411 | 411 | 'public' => true, |
| 412 | 412 | 'exclude_from_search' => false, |
| 413 | 413 | 'show_in_admin_all_list' => true, |
| 414 | 414 | 'show_in_admin_status_list' => true, |
| 415 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' ) |
|
| 416 | - ) ); |
|
| 417 | - register_post_status( 'revoked', array( |
|
| 418 | - 'label' => _x( 'Revoked', 'Revoked payment status', 'give' ), |
|
| 415 | + 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give') |
|
| 416 | + )); |
|
| 417 | + register_post_status('revoked', array( |
|
| 418 | + 'label' => _x('Revoked', 'Revoked payment status', 'give'), |
|
| 419 | 419 | 'public' => true, |
| 420 | 420 | 'exclude_from_search' => false, |
| 421 | 421 | 'show_in_admin_all_list' => true, |
| 422 | 422 | 'show_in_admin_status_list' => true, |
| 423 | - 'label_count' => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' ) |
|
| 424 | - ) ); |
|
| 425 | - register_post_status( 'abandoned', array( |
|
| 426 | - 'label' => _x( 'Abandoned', 'Abandoned payment status', 'give' ), |
|
| 423 | + 'label_count' => _n_noop('Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give') |
|
| 424 | + )); |
|
| 425 | + register_post_status('abandoned', array( |
|
| 426 | + 'label' => _x('Abandoned', 'Abandoned payment status', 'give'), |
|
| 427 | 427 | 'public' => true, |
| 428 | 428 | 'exclude_from_search' => false, |
| 429 | 429 | 'show_in_admin_all_list' => true, |
| 430 | 430 | 'show_in_admin_status_list' => true, |
| 431 | - 'label_count' => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' ) |
|
| 432 | - ) ); |
|
| 431 | + 'label_count' => _n_noop('Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give') |
|
| 432 | + )); |
|
| 433 | 433 | |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | -add_action( 'init', 'give_register_post_type_statuses' ); |
|
| 436 | +add_action('init', 'give_register_post_type_statuses'); |
|
| 437 | 437 | |
| 438 | 438 | /** |
| 439 | 439 | * Updated Messages |
@@ -446,45 +446,45 @@ discard block |
||
| 446 | 446 | * |
| 447 | 447 | * @return array $messages New post updated messages |
| 448 | 448 | */ |
| 449 | -function give_updated_messages( $messages ) { |
|
| 449 | +function give_updated_messages($messages) { |
|
| 450 | 450 | global $post, $post_ID; |
| 451 | 451 | |
| 452 | - $url1 = '<a href="' . get_permalink( $post_ID ) . '">'; |
|
| 452 | + $url1 = '<a href="'.get_permalink($post_ID).'">'; |
|
| 453 | 453 | $url2 = give_get_forms_label_singular(); |
| 454 | 454 | $url3 = '</a>'; |
| 455 | 455 | |
| 456 | 456 | $messages['give_forms'] = array( |
| 457 | - 1 => sprintf( __( '%2$s updated. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ), |
|
| 458 | - 4 => sprintf( __( '%2$s updated. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ), |
|
| 459 | - 6 => sprintf( __( '%2$s published. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ), |
|
| 460 | - 7 => sprintf( __( '%2$s saved. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ), |
|
| 461 | - 8 => sprintf( __( '%2$s submitted. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ) |
|
| 457 | + 1 => sprintf(__('%2$s updated. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3), |
|
| 458 | + 4 => sprintf(__('%2$s updated. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3), |
|
| 459 | + 6 => sprintf(__('%2$s published. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3), |
|
| 460 | + 7 => sprintf(__('%2$s saved. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3), |
|
| 461 | + 8 => sprintf(__('%2$s submitted. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3) |
|
| 462 | 462 | ); |
| 463 | 463 | |
| 464 | 464 | return $messages; |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | -add_filter( 'post_updated_messages', 'give_updated_messages' ); |
|
| 467 | +add_filter('post_updated_messages', 'give_updated_messages'); |
|
| 468 | 468 | |
| 469 | 469 | |
| 470 | 470 | /** |
| 471 | 471 | * Setup Post Type Images |
| 472 | 472 | */ |
| 473 | -add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 ); |
|
| 474 | -add_action( 'after_setup_theme', 'give_add_image_sizes', 10 ); |
|
| 473 | +add_action('after_setup_theme', 'give_add_thumbnail_support', 10); |
|
| 474 | +add_action('after_setup_theme', 'give_add_image_sizes', 10); |
|
| 475 | 475 | |
| 476 | 476 | /** |
| 477 | 477 | * Ensure post thumbnail support is turned on |
| 478 | 478 | */ |
| 479 | 479 | function give_add_thumbnail_support() { |
| 480 | - if ( give_get_option( 'disable_form_featured_img' ) === 'on' ) { |
|
| 480 | + if (give_get_option('disable_form_featured_img') === 'on') { |
|
| 481 | 481 | return; |
| 482 | 482 | } |
| 483 | - if ( ! current_theme_supports( 'post-thumbnails' ) ) { |
|
| 484 | - add_theme_support( 'post-thumbnails' ); |
|
| 483 | + if ( ! current_theme_supports('post-thumbnails')) { |
|
| 484 | + add_theme_support('post-thumbnails'); |
|
| 485 | 485 | } |
| 486 | - add_post_type_support( 'give_forms', 'thumbnail' ); |
|
| 487 | - add_post_type_support( 'give_campaigns', 'thumbnail' ); |
|
| 486 | + add_post_type_support('give_forms', 'thumbnail'); |
|
| 487 | + add_post_type_support('give_campaigns', 'thumbnail'); |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | /** |
@@ -493,11 +493,11 @@ discard block |
||
| 493 | 493 | * @since 1.0 |
| 494 | 494 | */ |
| 495 | 495 | function give_add_image_sizes() { |
| 496 | - $give_form_thumbnail = give_get_image_size( 'give_form_thumbnail' ); |
|
| 497 | - $give_form_single = give_get_image_size( 'give_form_single' ); |
|
| 496 | + $give_form_thumbnail = give_get_image_size('give_form_thumbnail'); |
|
| 497 | + $give_form_single = give_get_image_size('give_form_single'); |
|
| 498 | 498 | |
| 499 | - add_image_size( 'give_form_thumbnail', $give_form_thumbnail['width'], $give_form_thumbnail['height'], $give_form_thumbnail['crop'] ); |
|
| 500 | - add_image_size( 'give_form_single', $give_form_single['width'], $give_form_single['height'], $give_form_single['crop'] ); |
|
| 499 | + add_image_size('give_form_thumbnail', $give_form_thumbnail['width'], $give_form_thumbnail['height'], $give_form_thumbnail['crop']); |
|
| 500 | + add_image_size('give_form_single', $give_form_single['width'], $give_form_single['height'], $give_form_single['crop']); |
|
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | /** |
@@ -509,19 +509,19 @@ discard block |
||
| 509 | 509 | function give_widgets_init() { |
| 510 | 510 | |
| 511 | 511 | //Single Give Forms (disabled if single turned off in settings) |
| 512 | - if ( give_get_option( 'disable_forms_singular' ) !== 'on' && give_get_option( 'disable_form_sidebar' ) !== 'on' ) { |
|
| 512 | + if (give_get_option('disable_forms_singular') !== 'on' && give_get_option('disable_form_sidebar') !== 'on') { |
|
| 513 | 513 | |
| 514 | - register_sidebar( apply_filters( 'give_forms_single_sidebar', array( |
|
| 515 | - 'name' => __( 'Give Single Form Sidebar', 'give' ), |
|
| 514 | + register_sidebar(apply_filters('give_forms_single_sidebar', array( |
|
| 515 | + 'name' => __('Give Single Form Sidebar', 'give'), |
|
| 516 | 516 | 'id' => 'give-forms-sidebar', |
| 517 | - 'description' => __( 'Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give' ), |
|
| 517 | + 'description' => __('Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give'), |
|
| 518 | 518 | 'before_widget' => '<div id="%1$s" class="widget %2$s">', |
| 519 | 519 | 'after_widget' => '</div>', |
| 520 | 520 | 'before_title' => '<h3 class="widgettitle widget-title">', |
| 521 | 521 | 'after_title' => '</h3>', |
| 522 | - ) ) ); |
|
| 522 | + ))); |
|
| 523 | 523 | |
| 524 | 524 | } |
| 525 | 525 | } |
| 526 | 526 | |
| 527 | -add_action( 'widgets_init', 'give_widgets_init', 999 ); |
|
| 528 | 527 | \ No newline at end of file |
| 528 | +add_action('widgets_init', 'give_widgets_init', 999); |
|
| 529 | 529 | \ No newline at end of file |