@@ -50,7 +50,7 @@ |
||
| 50 | 50 | * @since 1.5 |
| 51 | 51 | * @global object $wpdb Used to query the database using the WordPress |
| 52 | 52 | * Database API |
| 53 | - * @return array $data The data for the CSV file |
|
| 53 | + * @return boolean $data The data for the CSV file |
|
| 54 | 54 | */ |
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $wpdb; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -55,22 +55,22 @@ discard block |
||
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $wpdb; |
| 57 | 57 | |
| 58 | - $items = $this->get_stored_data( 'give_temp_reset_ids' ); |
|
| 58 | + $items = $this->get_stored_data('give_temp_reset_ids'); |
|
| 59 | 59 | |
| 60 | - if ( ! is_array( $items ) ) { |
|
| 60 | + if ( ! is_array($items)) { |
|
| 61 | 61 | return false; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
| 65 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
| 64 | + $offset = ($this->step - 1) * $this->per_step; |
|
| 65 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
| 66 | 66 | |
| 67 | - if ( $step_items ) { |
|
| 67 | + if ($step_items) { |
|
| 68 | 68 | |
| 69 | 69 | $step_ids = array( |
| 70 | 70 | 'other' => array(), |
| 71 | 71 | ); |
| 72 | 72 | |
| 73 | - foreach ( $step_items as $item ) { |
|
| 73 | + foreach ($step_items as $item) { |
|
| 74 | 74 | |
| 75 | 75 | $step_ids['other'][] = $item['id']; |
| 76 | 76 | |
@@ -78,15 +78,15 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | $sql = array(); |
| 80 | 80 | |
| 81 | - foreach ( $step_ids as $type => $ids ) { |
|
| 81 | + foreach ($step_ids as $type => $ids) { |
|
| 82 | 82 | |
| 83 | - if ( empty( $ids ) ) { |
|
| 83 | + if (empty($ids)) { |
|
| 84 | 84 | continue; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - $ids = implode( ',', $ids ); |
|
| 87 | + $ids = implode(',', $ids); |
|
| 88 | 88 | |
| 89 | - switch ( $type ) { |
|
| 89 | + switch ($type) { |
|
| 90 | 90 | case 'other': |
| 91 | 91 | $sql[] = "DELETE FROM $wpdb->posts WHERE id IN ($ids)"; |
| 92 | 92 | $sql[] = "DELETE FROM $wpdb->postmeta WHERE post_id IN ($ids)"; |
@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if ( ! empty( $sql ) ) { |
|
| 101 | - foreach ( $sql as $query ) { |
|
| 102 | - $wpdb->query( $query ); |
|
| 100 | + if ( ! empty($sql)) { |
|
| 101 | + foreach ($sql as $query) { |
|
| 102 | + $wpdb->query($query); |
|
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
@@ -119,16 +119,16 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public function get_percentage_complete() { |
| 121 | 121 | |
| 122 | - $items = $this->get_stored_data( 'give_temp_reset_ids', false ); |
|
| 123 | - $total = count( $items ); |
|
| 122 | + $items = $this->get_stored_data('give_temp_reset_ids', false); |
|
| 123 | + $total = count($items); |
|
| 124 | 124 | |
| 125 | 125 | $percentage = 100; |
| 126 | 126 | |
| 127 | - if ( $total > 0 ) { |
|
| 128 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 127 | + if ($total > 0) { |
|
| 128 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if ( $percentage > 100 ) { |
|
| 131 | + if ($percentage > 100) { |
|
| 132 | 132 | $percentage = 100; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * |
| 143 | 143 | * @param array $request The Form Data passed into the batch processing |
| 144 | 144 | */ |
| 145 | - public function set_properties( $request ) { |
|
| 145 | + public function set_properties($request) { |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -153,30 +153,30 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | public function process_step() { |
| 155 | 155 | |
| 156 | - if ( ! $this->can_export() ) { |
|
| 157 | - wp_die( esc_html__( 'You do not have permission to delete test transactions.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 156 | + if ( ! $this->can_export()) { |
|
| 157 | + wp_die(esc_html__('You do not have permission to delete test transactions.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | $had_data = $this->get_data(); |
| 161 | 161 | |
| 162 | - if ( $had_data ) { |
|
| 162 | + if ($had_data) { |
|
| 163 | 163 | $this->done = false; |
| 164 | 164 | |
| 165 | 165 | return true; |
| 166 | 166 | } else { |
| 167 | - update_option( 'give_earnings_total', 0 ); |
|
| 168 | - delete_transient( 'give_earnings_total' ); |
|
| 169 | - delete_transient( 'give_estimated_monthly_stats' . true ); |
|
| 170 | - delete_transient( 'give_estimated_monthly_stats' . false ); |
|
| 171 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
| 167 | + update_option('give_earnings_total', 0); |
|
| 168 | + delete_transient('give_earnings_total'); |
|
| 169 | + delete_transient('give_estimated_monthly_stats'.true); |
|
| 170 | + delete_transient('give_estimated_monthly_stats'.false); |
|
| 171 | + $this->delete_data('give_temp_reset_ids'); |
|
| 172 | 172 | |
| 173 | 173 | // Reset the sequential order numbers |
| 174 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 175 | - delete_option( 'give_last_payment_number' ); |
|
| 174 | + if (give_get_option('enable_sequential')) { |
|
| 175 | + delete_option('give_last_payment_number'); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | $this->done = true; |
| 179 | - $this->message = esc_html__( 'Test transactions successfully deleted.', 'give' ); |
|
| 179 | + $this->message = esc_html__('Test transactions successfully deleted.', 'give'); |
|
| 180 | 180 | |
| 181 | 181 | return false; |
| 182 | 182 | } |
@@ -186,10 +186,10 @@ discard block |
||
| 186 | 186 | * Headers |
| 187 | 187 | */ |
| 188 | 188 | public function headers() { |
| 189 | - ignore_user_abort( true ); |
|
| 189 | + ignore_user_abort(true); |
|
| 190 | 190 | |
| 191 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 192 | - set_time_limit( 0 ); |
|
| 191 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 192 | + set_time_limit(0); |
|
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | |
@@ -213,26 +213,26 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | public function pre_fetch() { |
| 215 | 215 | |
| 216 | - if ( $this->step == 1 ) { |
|
| 217 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
| 216 | + if ($this->step == 1) { |
|
| 217 | + $this->delete_data('give_temp_reset_ids'); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - $items = get_option( 'give_temp_reset_ids', false ); |
|
| 220 | + $items = get_option('give_temp_reset_ids', false); |
|
| 221 | 221 | |
| 222 | - if ( false === $items ) { |
|
| 222 | + if (false === $items) { |
|
| 223 | 223 | $items = array(); |
| 224 | 224 | |
| 225 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
| 225 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
| 226 | 226 | 'post_type' => 'give_payment', |
| 227 | 227 | 'post_status' => 'any', |
| 228 | - 'posts_per_page' => - 1, |
|
| 228 | + 'posts_per_page' => -1, |
|
| 229 | 229 | //ONLY TEST MODE TRANSACTIONS!!! |
| 230 | 230 | 'meta_key' => '_give_payment_mode', |
| 231 | 231 | 'meta_value' => 'test' |
| 232 | - ) ); |
|
| 232 | + )); |
|
| 233 | 233 | |
| 234 | - $posts = get_posts( $args ); |
|
| 235 | - foreach ( $posts as $post ) { |
|
| 234 | + $posts = get_posts($args); |
|
| 235 | + foreach ($posts as $post) { |
|
| 236 | 236 | $items[] = array( |
| 237 | 237 | 'id' => (int) $post->ID, |
| 238 | 238 | 'type' => $post->post_type, |
@@ -241,9 +241,9 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | // Allow filtering of items to remove with an unassociative array for each item |
| 243 | 243 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method |
| 244 | - $items = apply_filters( 'give_reset_store_items', $items ); |
|
| 244 | + $items = apply_filters('give_reset_store_items', $items); |
|
| 245 | 245 | |
| 246 | - $this->store_data( 'give_temp_reset_ids', $items ); |
|
| 246 | + $this->store_data('give_temp_reset_ids', $items); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | } |
@@ -257,11 +257,11 @@ discard block |
||
| 257 | 257 | * |
| 258 | 258 | * @return mixed Returns the data from the database |
| 259 | 259 | */ |
| 260 | - private function get_stored_data( $key ) { |
|
| 260 | + private function get_stored_data($key) { |
|
| 261 | 261 | global $wpdb; |
| 262 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 262 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 263 | 263 | |
| 264 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
| 264 | + return empty($value) ? false : maybe_unserialize($value); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /** |
@@ -274,10 +274,10 @@ discard block |
||
| 274 | 274 | * |
| 275 | 275 | * @return void |
| 276 | 276 | */ |
| 277 | - private function store_data( $key, $value ) { |
|
| 277 | + private function store_data($key, $value) { |
|
| 278 | 278 | global $wpdb; |
| 279 | 279 | |
| 280 | - $value = maybe_serialize( $value ); |
|
| 280 | + $value = maybe_serialize($value); |
|
| 281 | 281 | |
| 282 | 282 | $data = array( |
| 283 | 283 | 'option_name' => $key, |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | '%s', |
| 292 | 292 | ); |
| 293 | 293 | |
| 294 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 294 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /** |
@@ -303,9 +303,9 @@ discard block |
||
| 303 | 303 | * |
| 304 | 304 | * @return void |
| 305 | 305 | */ |
| 306 | - private function delete_data( $key ) { |
|
| 306 | + private function delete_data($key) { |
|
| 307 | 307 | global $wpdb; |
| 308 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 308 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | } |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | * @since 1.5 |
| 51 | 51 | * @global object $wpdb Used to query the database using the WordPress |
| 52 | 52 | * Database API |
| 53 | - * @return array $data The data for the CSV file |
|
| 53 | + * @return boolean $data The data for the CSV file |
|
| 54 | 54 | */ |
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $wpdb; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -55,26 +55,26 @@ discard block |
||
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $give_logs, $wpdb; |
| 57 | 57 | |
| 58 | - $totals = $this->get_stored_data( 'give_temp_recount_all_stats' ); |
|
| 59 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
| 60 | - $processed_payments = $this->get_stored_data( 'give_temp_processed_payments' ); |
|
| 61 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 58 | + $totals = $this->get_stored_data('give_temp_recount_all_stats'); |
|
| 59 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
| 60 | + $processed_payments = $this->get_stored_data('give_temp_processed_payments'); |
|
| 61 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 62 | 62 | |
| 63 | - if ( false === $totals ) { |
|
| 63 | + if (false === $totals) { |
|
| 64 | 64 | $totals = array(); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - if ( false === $payment_items ) { |
|
| 67 | + if (false === $payment_items) { |
|
| 68 | 68 | $payment_items = array(); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if ( false === $processed_payments ) { |
|
| 71 | + if (false === $processed_payments) { |
|
| 72 | 72 | $processed_payments = array(); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - $all_forms = $this->get_stored_data( 'give_temp_form_ids' ); |
|
| 75 | + $all_forms = $this->get_stored_data('give_temp_form_ids'); |
|
| 76 | 76 | |
| 77 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
| 77 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
| 78 | 78 | 'post_parent__in' => $all_forms, |
| 79 | 79 | 'post_type' => 'give_log', |
| 80 | 80 | 'posts_per_page' => $this->per_step, |
@@ -82,73 +82,73 @@ discard block |
||
| 82 | 82 | 'paged' => $this->step, |
| 83 | 83 | 'log_type' => 'sale', |
| 84 | 84 | 'fields' => 'ids', |
| 85 | - ) ); |
|
| 85 | + )); |
|
| 86 | 86 | |
| 87 | - $log_ids = $give_logs->get_connected_logs( $args, 'sale' ); |
|
| 87 | + $log_ids = $give_logs->get_connected_logs($args, 'sale'); |
|
| 88 | 88 | |
| 89 | - if ( $log_ids ) { |
|
| 90 | - $log_ids = implode( ',', $log_ids ); |
|
| 89 | + if ($log_ids) { |
|
| 90 | + $log_ids = implode(',', $log_ids); |
|
| 91 | 91 | |
| 92 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" ); |
|
| 93 | - unset( $log_ids ); |
|
| 92 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)"); |
|
| 93 | + unset($log_ids); |
|
| 94 | 94 | |
| 95 | - $payment_ids = implode( ',', $payment_ids ); |
|
| 96 | - $payments = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" ); |
|
| 97 | - unset( $payment_ids ); |
|
| 95 | + $payment_ids = implode(',', $payment_ids); |
|
| 96 | + $payments = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")"); |
|
| 97 | + unset($payment_ids); |
|
| 98 | 98 | |
| 99 | 99 | //Loop through payments |
| 100 | - foreach ( $payments as $payment ) { |
|
| 100 | + foreach ($payments as $payment) { |
|
| 101 | 101 | |
| 102 | 102 | // Prevent payments that have all ready been retrieved from a previous sales log from counting again. |
| 103 | - if ( in_array( $payment->ID, $processed_payments ) ) { |
|
| 103 | + if (in_array($payment->ID, $processed_payments)) { |
|
| 104 | 104 | continue; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | //Verify accepted status' |
| 108 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
| 108 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
| 109 | 109 | $processed_payments[] = $payment->ID; |
| 110 | 110 | continue; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - $payment_item = $payment_items[ $payment->ID ]; |
|
| 113 | + $payment_item = $payment_items[$payment->ID]; |
|
| 114 | 114 | |
| 115 | 115 | |
| 116 | - $form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : ''; |
|
| 116 | + $form_id = isset($payment_item['id']) ? $payment_item['id'] : ''; |
|
| 117 | 117 | |
| 118 | 118 | //Must have a form ID |
| 119 | - if ( empty( $form_id ) ) { |
|
| 119 | + if (empty($form_id)) { |
|
| 120 | 120 | continue; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | //Form ID must be within $all_forms array to be validated |
| 124 | - if ( ! in_array( $form_id, $all_forms ) ) { |
|
| 124 | + if ( ! in_array($form_id, $all_forms)) { |
|
| 125 | 125 | continue; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | //If array key doesn't exist, create it |
| 129 | - if ( ! array_key_exists( $form_id, $totals ) ) { |
|
| 130 | - $totals[ $form_id ] = array( |
|
| 129 | + if ( ! array_key_exists($form_id, $totals)) { |
|
| 130 | + $totals[$form_id] = array( |
|
| 131 | 131 | 'sales' => (int) 0, |
| 132 | 132 | 'earnings' => (float) 0, |
| 133 | 133 | ); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - $totals[ $form_id ]['sales'] ++; |
|
| 137 | - $totals[ $form_id ]['earnings'] += $payment_item['price']; |
|
| 136 | + $totals[$form_id]['sales']++; |
|
| 137 | + $totals[$form_id]['earnings'] += $payment_item['price']; |
|
| 138 | 138 | |
| 139 | 139 | $processed_payments[] = $payment->ID; |
| 140 | 140 | |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - $this->store_data( 'give_temp_processed_payments', $processed_payments ); |
|
| 144 | - $this->store_data( 'give_temp_recount_all_stats', $totals ); |
|
| 143 | + $this->store_data('give_temp_processed_payments', $processed_payments); |
|
| 144 | + $this->store_data('give_temp_recount_all_stats', $totals); |
|
| 145 | 145 | |
| 146 | 146 | return true; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - foreach ( $totals as $key => $stats ) { |
|
| 150 | - update_post_meta( $key, '_give_form_sales', $stats['sales'] ); |
|
| 151 | - update_post_meta( $key, '_give_form_earnings', $stats['earnings'] ); |
|
| 149 | + foreach ($totals as $key => $stats) { |
|
| 150 | + update_post_meta($key, '_give_form_sales', $stats['sales']); |
|
| 151 | + update_post_meta($key, '_give_form_earnings', $stats['earnings']); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | return false; |
@@ -163,20 +163,20 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | public function get_percentage_complete() { |
| 165 | 165 | |
| 166 | - $total = $this->get_stored_data( 'give_recount_all_total', false ); |
|
| 166 | + $total = $this->get_stored_data('give_recount_all_total', false); |
|
| 167 | 167 | |
| 168 | - if ( false === $total ) { |
|
| 168 | + if (false === $total) { |
|
| 169 | 169 | $this->pre_fetch(); |
| 170 | - $total = $this->get_stored_data( 'give_recount_all_total', 0 ); |
|
| 170 | + $total = $this->get_stored_data('give_recount_all_total', 0); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | $percentage = 100; |
| 174 | 174 | |
| 175 | - if ( $total > 0 ) { |
|
| 176 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 175 | + if ($total > 0) { |
|
| 176 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if ( $percentage > 100 ) { |
|
| 179 | + if ($percentage > 100) { |
|
| 180 | 180 | $percentage = 100; |
| 181 | 181 | } |
| 182 | 182 | |
@@ -190,8 +190,8 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @param array $request The Form Data passed into the batch processing |
| 192 | 192 | */ |
| 193 | - public function set_properties( $request ) { |
|
| 194 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
| 193 | + public function set_properties($request) { |
|
| 194 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -202,34 +202,34 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | public function process_step() { |
| 204 | 204 | |
| 205 | - if ( ! $this->can_export() ) { |
|
| 206 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 205 | + if ( ! $this->can_export()) { |
|
| 206 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | $had_data = $this->get_data(); |
| 210 | 210 | |
| 211 | - if ( $had_data ) { |
|
| 211 | + if ($had_data) { |
|
| 212 | 212 | $this->done = false; |
| 213 | 213 | |
| 214 | 214 | return true; |
| 215 | 215 | } else { |
| 216 | - $this->delete_data( 'give_recount_all_total' ); |
|
| 217 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
| 218 | - $this->delete_data( 'give_temp_payment_items' ); |
|
| 219 | - $this->delete_data( 'give_temp_form_ids' ); |
|
| 220 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
| 216 | + $this->delete_data('give_recount_all_total'); |
|
| 217 | + $this->delete_data('give_temp_recount_all_stats'); |
|
| 218 | + $this->delete_data('give_temp_payment_items'); |
|
| 219 | + $this->delete_data('give_temp_form_ids'); |
|
| 220 | + $this->delete_data('give_temp_processed_payments'); |
|
| 221 | 221 | $this->done = true; |
| 222 | - $this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' ); |
|
| 222 | + $this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give'); |
|
| 223 | 223 | |
| 224 | 224 | return false; |
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | public function headers() { |
| 229 | - ignore_user_abort( true ); |
|
| 229 | + ignore_user_abort(true); |
|
| 230 | 230 | |
| 231 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 232 | - set_time_limit( 0 ); |
|
| 231 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 232 | + set_time_limit(0); |
|
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | |
@@ -258,76 +258,76 @@ discard block |
||
| 258 | 258 | |
| 259 | 259 | global $give_logs, $wpdb; |
| 260 | 260 | |
| 261 | - if ( $this->step == 1 ) { |
|
| 262 | - $this->delete_data( 'give_temp_recount_all_total' ); |
|
| 263 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
| 264 | - $this->delete_data( 'give_temp_payment_items' ); |
|
| 265 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
| 261 | + if ($this->step == 1) { |
|
| 262 | + $this->delete_data('give_temp_recount_all_total'); |
|
| 263 | + $this->delete_data('give_temp_recount_all_stats'); |
|
| 264 | + $this->delete_data('give_temp_payment_items'); |
|
| 265 | + $this->delete_data('give_temp_processed_payments'); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 269 | - $total = $this->get_stored_data( 'give_temp_recount_all_total' ); |
|
| 268 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 269 | + $total = $this->get_stored_data('give_temp_recount_all_total'); |
|
| 270 | 270 | |
| 271 | - if ( false === $total ) { |
|
| 271 | + if (false === $total) { |
|
| 272 | 272 | $total = 0; |
| 273 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
| 273 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
| 274 | 274 | |
| 275 | - if ( false === $payment_items ) { |
|
| 275 | + if (false === $payment_items) { |
|
| 276 | 276 | $payment_items = array(); |
| 277 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
| 277 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - $all_forms = $this->get_stored_data( 'give_temp_form_ids' ); |
|
| 280 | + $all_forms = $this->get_stored_data('give_temp_form_ids'); |
|
| 281 | 281 | |
| 282 | - if ( false === $all_forms ) { |
|
| 282 | + if (false === $all_forms) { |
|
| 283 | 283 | $args = array( |
| 284 | 284 | 'post_status' => 'any', |
| 285 | 285 | 'post_type' => 'give_forms', |
| 286 | - 'posts_per_page' => - 1, |
|
| 286 | + 'posts_per_page' => -1, |
|
| 287 | 287 | 'fields' => 'ids', |
| 288 | 288 | ); |
| 289 | 289 | |
| 290 | - $all_forms = get_posts( $args ); |
|
| 291 | - $this->store_data( 'give_temp_form_ids', $all_forms ); |
|
| 290 | + $all_forms = get_posts($args); |
|
| 291 | + $this->store_data('give_temp_form_ids', $all_forms); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
| 294 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
| 295 | 295 | 'post_parent__in' => $all_forms, |
| 296 | 296 | 'post_type' => 'give_log', |
| 297 | 297 | 'post_status' => 'publish', |
| 298 | 298 | 'log_type' => 'sale', |
| 299 | 299 | 'fields' => 'ids', |
| 300 | 300 | 'nopaging' => true, |
| 301 | - ) ); |
|
| 301 | + )); |
|
| 302 | 302 | |
| 303 | - $all_logs = $give_logs->get_connected_logs( $args, 'sale' ); |
|
| 303 | + $all_logs = $give_logs->get_connected_logs($args, 'sale'); |
|
| 304 | 304 | |
| 305 | - if ( $all_logs ) { |
|
| 306 | - $log_ids = implode( ',', $all_logs ); |
|
| 307 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" ); |
|
| 308 | - unset( $log_ids ); |
|
| 305 | + if ($all_logs) { |
|
| 306 | + $log_ids = implode(',', $all_logs); |
|
| 307 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)"); |
|
| 308 | + unset($log_ids); |
|
| 309 | 309 | |
| 310 | - $payment_ids = implode( ',', $payment_ids ); |
|
| 311 | - $payments = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" ); |
|
| 312 | - unset( $payment_ids ); |
|
| 310 | + $payment_ids = implode(',', $payment_ids); |
|
| 311 | + $payments = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")"); |
|
| 312 | + unset($payment_ids); |
|
| 313 | 313 | |
| 314 | - foreach ( $payments as $payment ) { |
|
| 314 | + foreach ($payments as $payment) { |
|
| 315 | 315 | |
| 316 | - $payment = new Give_Payment( $payment->ID ); |
|
| 316 | + $payment = new Give_Payment($payment->ID); |
|
| 317 | 317 | $form_id = $payment->form_id; |
| 318 | 318 | |
| 319 | 319 | //If for some reason somehow the form_ID isn't set check payment meta |
| 320 | - if ( empty( $payment->form_id ) ) { |
|
| 320 | + if (empty($payment->form_id)) { |
|
| 321 | 321 | $payment_meta = $payment->get_meta(); |
| 322 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
| 322 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
| 325 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
| 326 | 326 | continue; |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - if ( ! array_key_exists( $payment->ID, $payment_items ) ) { |
|
| 330 | - $payment_items[ $payment->ID ] = array( |
|
| 329 | + if ( ! array_key_exists($payment->ID, $payment_items)) { |
|
| 330 | + $payment_items[$payment->ID] = array( |
|
| 331 | 331 | 'id' => $form_id, |
| 332 | 332 | 'payment_id' => $payment->ID, |
| 333 | 333 | 'price' => $payment->total |
@@ -336,11 +336,11 @@ discard block |
||
| 336 | 336 | |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - $total = count( $all_logs ); |
|
| 339 | + $total = count($all_logs); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
| 343 | - $this->store_data( 'give_recount_all_total', $total ); |
|
| 342 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
| 343 | + $this->store_data('give_recount_all_total', $total); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | } |
@@ -354,11 +354,11 @@ discard block |
||
| 354 | 354 | * |
| 355 | 355 | * @return mixed Returns the data from the database |
| 356 | 356 | */ |
| 357 | - private function get_stored_data( $key ) { |
|
| 357 | + private function get_stored_data($key) { |
|
| 358 | 358 | global $wpdb; |
| 359 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 359 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 360 | 360 | |
| 361 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
| 361 | + return empty($value) ? false : maybe_unserialize($value); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | /** |
@@ -371,10 +371,10 @@ discard block |
||
| 371 | 371 | * |
| 372 | 372 | * @return void |
| 373 | 373 | */ |
| 374 | - private function store_data( $key, $value ) { |
|
| 374 | + private function store_data($key, $value) { |
|
| 375 | 375 | global $wpdb; |
| 376 | 376 | |
| 377 | - $value = maybe_serialize( $value ); |
|
| 377 | + $value = maybe_serialize($value); |
|
| 378 | 378 | |
| 379 | 379 | $data = array( |
| 380 | 380 | 'option_name' => $key, |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | '%s', |
| 389 | 389 | ); |
| 390 | 390 | |
| 391 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 391 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | /** |
@@ -400,9 +400,9 @@ discard block |
||
| 400 | 400 | * |
| 401 | 401 | * @return void |
| 402 | 402 | */ |
| 403 | - private function delete_data( $key ) { |
|
| 403 | + private function delete_data($key) { |
|
| 404 | 404 | global $wpdb; |
| 405 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 405 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | } |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | * @since 1.5 |
| 51 | 51 | * @global object $wpdb Used to query the database using the WordPress |
| 52 | 52 | * Database API |
| 53 | - * @return array $data The data for the CSV file |
|
| 53 | + * @return boolean $data The data for the CSV file |
|
| 54 | 54 | */ |
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $wpdb; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -56,32 +56,32 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | $args = array( |
| 58 | 58 | 'number' => $this->per_step, |
| 59 | - 'offset' => $this->per_step * ( $this->step - 1 ), |
|
| 59 | + 'offset' => $this->per_step * ($this->step - 1), |
|
| 60 | 60 | 'orderby' => 'id', |
| 61 | 61 | 'order' => 'DESC', |
| 62 | 62 | ); |
| 63 | 63 | |
| 64 | - $customers = Give()->customers->get_customers( $args ); |
|
| 64 | + $customers = Give()->customers->get_customers($args); |
|
| 65 | 65 | |
| 66 | - if ( $customers ) { |
|
| 66 | + if ($customers) { |
|
| 67 | 67 | |
| 68 | - $allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() ); |
|
| 68 | + $allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys()); |
|
| 69 | 69 | |
| 70 | - foreach ( $customers as $customer ) { |
|
| 70 | + foreach ($customers as $customer) { |
|
| 71 | 71 | |
| 72 | - $attached_payment_ids = explode( ',', $customer->payment_ids ); |
|
| 72 | + $attached_payment_ids = explode(',', $customer->payment_ids); |
|
| 73 | 73 | |
| 74 | 74 | $attached_args = array( |
| 75 | 75 | 'post__in' => $attached_payment_ids, |
| 76 | - 'number' => - 1, |
|
| 76 | + 'number' => -1, |
|
| 77 | 77 | 'status' => $allowed_payment_status, |
| 78 | 78 | ); |
| 79 | 79 | |
| 80 | - $attached_payments = (array) give_get_payments( $attached_args ); |
|
| 80 | + $attached_payments = (array) give_get_payments($attached_args); |
|
| 81 | 81 | |
| 82 | 82 | $unattached_args = array( |
| 83 | 83 | 'post__not_in' => $attached_payment_ids, |
| 84 | - 'number' => - 1, |
|
| 84 | + 'number' => -1, |
|
| 85 | 85 | 'status' => $allowed_payment_status, |
| 86 | 86 | 'meta_query' => array( |
| 87 | 87 | array( |
@@ -92,29 +92,29 @@ discard block |
||
| 92 | 92 | ), |
| 93 | 93 | ); |
| 94 | 94 | |
| 95 | - $unattached_payments = give_get_payments( $unattached_args ); |
|
| 95 | + $unattached_payments = give_get_payments($unattached_args); |
|
| 96 | 96 | |
| 97 | - $payments = array_merge( $attached_payments, $unattached_payments ); |
|
| 97 | + $payments = array_merge($attached_payments, $unattached_payments); |
|
| 98 | 98 | |
| 99 | 99 | $purchase_value = 0.00; |
| 100 | 100 | $purchase_count = 0; |
| 101 | 101 | $payment_ids = array(); |
| 102 | 102 | |
| 103 | - if ( $payments ) { |
|
| 103 | + if ($payments) { |
|
| 104 | 104 | |
| 105 | - foreach ( $payments as $payment ) { |
|
| 105 | + foreach ($payments as $payment) { |
|
| 106 | 106 | |
| 107 | 107 | $should_process_payment = 'publish' == $payment->post_status ? true : false; |
| 108 | - $should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment ); |
|
| 108 | + $should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment); |
|
| 109 | 109 | |
| 110 | - if ( true === $should_process_payment ) { |
|
| 110 | + if (true === $should_process_payment) { |
|
| 111 | 111 | |
| 112 | - if ( apply_filters( 'give_customer_recount_should_increase_value', true, $payment ) ) { |
|
| 113 | - $purchase_value += give_get_payment_amount( $payment->ID ); |
|
| 112 | + if (apply_filters('give_customer_recount_should_increase_value', true, $payment)) { |
|
| 113 | + $purchase_value += give_get_payment_amount($payment->ID); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - if ( apply_filters( 'give_customer_recount_should_increase_count', true, $payment ) ) { |
|
| 117 | - $purchase_count ++; |
|
| 116 | + if (apply_filters('give_customer_recount_should_increase_count', true, $payment)) { |
|
| 117 | + $purchase_count++; |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - $payment_ids = implode( ',', $payment_ids ); |
|
| 127 | + $payment_ids = implode(',', $payment_ids); |
|
| 128 | 128 | |
| 129 | 129 | $customer_update_data = array( |
| 130 | 130 | 'purchase_count' => $purchase_count, |
@@ -132,8 +132,8 @@ discard block |
||
| 132 | 132 | 'payment_ids' => $payment_ids, |
| 133 | 133 | ); |
| 134 | 134 | |
| 135 | - $customer_instance = new Give_Customer( $customer->id ); |
|
| 136 | - $customer_instance->update( $customer_update_data ); |
|
| 135 | + $customer_instance = new Give_Customer($customer->id); |
|
| 136 | + $customer_instance->update($customer_update_data); |
|
| 137 | 137 | |
| 138 | 138 | } |
| 139 | 139 | |
@@ -153,21 +153,21 @@ discard block |
||
| 153 | 153 | public function get_percentage_complete() { |
| 154 | 154 | |
| 155 | 155 | $args = array( |
| 156 | - 'number' => - 1, |
|
| 156 | + 'number' => -1, |
|
| 157 | 157 | 'orderby' => 'id', |
| 158 | 158 | 'order' => 'DESC', |
| 159 | 159 | ); |
| 160 | 160 | |
| 161 | - $customers = Give()->customers->get_customers( $args ); |
|
| 162 | - $total = count( $customers ); |
|
| 161 | + $customers = Give()->customers->get_customers($args); |
|
| 162 | + $total = count($customers); |
|
| 163 | 163 | |
| 164 | 164 | $percentage = 100; |
| 165 | 165 | |
| 166 | - if ( $total > 0 ) { |
|
| 167 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 166 | + if ($total > 0) { |
|
| 167 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if ( $percentage > 100 ) { |
|
| 170 | + if ($percentage > 100) { |
|
| 171 | 171 | $percentage = 100; |
| 172 | 172 | } |
| 173 | 173 | |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * |
| 182 | 182 | * @param array $request The Form Data passed into the batch processing |
| 183 | 183 | */ |
| 184 | - public function set_properties( $request ) { |
|
| 184 | + public function set_properties($request) { |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |
@@ -192,19 +192,19 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | public function process_step() { |
| 194 | 194 | |
| 195 | - if ( ! $this->can_export() ) { |
|
| 196 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 195 | + if ( ! $this->can_export()) { |
|
| 196 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | $had_data = $this->get_data(); |
| 200 | 200 | |
| 201 | - if ( $had_data ) { |
|
| 201 | + if ($had_data) { |
|
| 202 | 202 | $this->done = false; |
| 203 | 203 | |
| 204 | 204 | return true; |
| 205 | 205 | } else { |
| 206 | 206 | $this->done = true; |
| 207 | - $this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' ); |
|
| 207 | + $this->message = esc_html__('Donor stats have been successfully recounted.', 'give'); |
|
| 208 | 208 | |
| 209 | 209 | return false; |
| 210 | 210 | } |
@@ -214,10 +214,10 @@ discard block |
||
| 214 | 214 | * Headers |
| 215 | 215 | */ |
| 216 | 216 | public function headers() { |
| 217 | - ignore_user_abort( true ); |
|
| 217 | + ignore_user_abort(true); |
|
| 218 | 218 | |
| 219 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 220 | - set_time_limit( 0 ); |
|
| 219 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 220 | + set_time_limit(0); |
|
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | * @since 1.5 |
| 51 | 51 | * @global object $wpdb Used to query the database using the WordPress |
| 52 | 52 | * Database API |
| 53 | - * @return array $data The data for the CSV file |
|
| 53 | + * @return boolean $data The data for the CSV file |
|
| 54 | 54 | */ |
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $wpdb; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -62,23 +62,23 @@ discard block |
||
| 62 | 62 | public function get_data() { |
| 63 | 63 | global $give_logs, $wpdb; |
| 64 | 64 | |
| 65 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 65 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 66 | 66 | |
| 67 | - if ( $this->step == 1 ) { |
|
| 68 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
| 67 | + if ($this->step == 1) { |
|
| 68 | + $this->delete_data('give_temp_recount_form_stats'); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - $totals = $this->get_stored_data( 'give_temp_recount_form_stats' ); |
|
| 71 | + $totals = $this->get_stored_data('give_temp_recount_form_stats'); |
|
| 72 | 72 | |
| 73 | - if ( false === $totals ) { |
|
| 73 | + if (false === $totals) { |
|
| 74 | 74 | $totals = array( |
| 75 | 75 | 'earnings' => (float) 0, |
| 76 | 76 | 'sales' => 0, |
| 77 | 77 | ); |
| 78 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
| 78 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
| 81 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
| 82 | 82 | 'post_parent' => $this->form_id, |
| 83 | 83 | 'post_type' => 'give_log', |
| 84 | 84 | 'posts_per_page' => $this->per_step, |
@@ -86,49 +86,49 @@ discard block |
||
| 86 | 86 | 'paged' => $this->step, |
| 87 | 87 | 'log_type' => 'sale', |
| 88 | 88 | 'fields' => 'ids', |
| 89 | - ) ); |
|
| 89 | + )); |
|
| 90 | 90 | |
| 91 | - $log_ids = $give_logs->get_connected_logs( $args, 'sale' ); |
|
| 91 | + $log_ids = $give_logs->get_connected_logs($args, 'sale'); |
|
| 92 | 92 | $this->_log_ids_debug = array(); |
| 93 | 93 | |
| 94 | - if ( $log_ids ) { |
|
| 95 | - $log_ids = implode( ',', $log_ids ); |
|
| 96 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" ); |
|
| 97 | - unset( $log_ids ); |
|
| 94 | + if ($log_ids) { |
|
| 95 | + $log_ids = implode(',', $log_ids); |
|
| 96 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)"); |
|
| 97 | + unset($log_ids); |
|
| 98 | 98 | |
| 99 | - $payment_ids = implode( ',', $payment_ids ); |
|
| 100 | - $payments = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" ); |
|
| 101 | - unset( $payment_ids ); |
|
| 99 | + $payment_ids = implode(',', $payment_ids); |
|
| 100 | + $payments = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")"); |
|
| 101 | + unset($payment_ids); |
|
| 102 | 102 | |
| 103 | - foreach ( $payments as $payment ) { |
|
| 103 | + foreach ($payments as $payment) { |
|
| 104 | 104 | |
| 105 | - $payment = new Give_Payment( $payment->ID ); |
|
| 105 | + $payment = new Give_Payment($payment->ID); |
|
| 106 | 106 | |
| 107 | 107 | //Ensure acceptible status only |
| 108 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
| 108 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
| 109 | 109 | continue; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | //Ensure only payments for this form are counted |
| 113 | - if ( $payment->form_id != $this->form_id ) { |
|
| 113 | + if ($payment->form_id != $this->form_id) { |
|
| 114 | 114 | continue; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | $this->_log_ids_debug[] = $payment->ID; |
| 118 | 118 | |
| 119 | - $totals['sales'] ++; |
|
| 119 | + $totals['sales']++; |
|
| 120 | 120 | $totals['earnings'] += $payment->total; |
| 121 | 121 | |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
| 124 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
| 125 | 125 | |
| 126 | 126 | return true; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | |
| 130 | - update_post_meta( $this->form_id, '_give_form_sales', $totals['sales'] ); |
|
| 131 | - update_post_meta( $this->form_id, '_give_form_earnings', $totals['earnings'] ); |
|
| 130 | + update_post_meta($this->form_id, '_give_form_sales', $totals['sales']); |
|
| 131 | + update_post_meta($this->form_id, '_give_form_earnings', $totals['earnings']); |
|
| 132 | 132 | |
| 133 | 133 | return false; |
| 134 | 134 | |
@@ -143,54 +143,54 @@ discard block |
||
| 143 | 143 | public function get_percentage_complete() { |
| 144 | 144 | global $give_logs, $wpdb; |
| 145 | 145 | |
| 146 | - if ( $this->step == 1 ) { |
|
| 147 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
| 146 | + if ($this->step == 1) { |
|
| 147 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 151 | - $total = $this->get_stored_data( 'give_recount_total_' . $this->form_id ); |
|
| 150 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 151 | + $total = $this->get_stored_data('give_recount_total_'.$this->form_id); |
|
| 152 | 152 | |
| 153 | - if ( false === $total ) { |
|
| 153 | + if (false === $total) { |
|
| 154 | 154 | $total = 0; |
| 155 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
| 155 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
| 156 | 156 | 'post_parent' => $this->form_id, |
| 157 | 157 | 'post_type' => 'give_log', |
| 158 | 158 | 'post_status' => 'publish', |
| 159 | 159 | 'log_type' => 'sale', |
| 160 | 160 | 'fields' => 'ids', |
| 161 | 161 | 'nopaging' => true, |
| 162 | - ) ); |
|
| 162 | + )); |
|
| 163 | 163 | |
| 164 | - $log_ids = $give_logs->get_connected_logs( $args, 'sale' ); |
|
| 164 | + $log_ids = $give_logs->get_connected_logs($args, 'sale'); |
|
| 165 | 165 | |
| 166 | - if ( $log_ids ) { |
|
| 167 | - $log_ids = implode( ',', $log_ids ); |
|
| 168 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" ); |
|
| 169 | - unset( $log_ids ); |
|
| 166 | + if ($log_ids) { |
|
| 167 | + $log_ids = implode(',', $log_ids); |
|
| 168 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)"); |
|
| 169 | + unset($log_ids); |
|
| 170 | 170 | |
| 171 | - $payment_ids = implode( ',', $payment_ids ); |
|
| 172 | - $payments = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" ); |
|
| 173 | - unset( $payment_ids ); |
|
| 171 | + $payment_ids = implode(',', $payment_ids); |
|
| 172 | + $payments = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")"); |
|
| 173 | + unset($payment_ids); |
|
| 174 | 174 | |
| 175 | - foreach ( $payments as $payment ) { |
|
| 176 | - if ( in_array( $payment->post_status, $accepted_statuses ) ) { |
|
| 175 | + foreach ($payments as $payment) { |
|
| 176 | + if (in_array($payment->post_status, $accepted_statuses)) { |
|
| 177 | 177 | continue; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - $total ++; |
|
| 180 | + $total++; |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - $this->store_data( 'give_recount_total_' . $this->form_id, $total ); |
|
| 184 | + $this->store_data('give_recount_total_'.$this->form_id, $total); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | $percentage = 100; |
| 188 | 188 | |
| 189 | - if ( $total > 0 ) { |
|
| 190 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 189 | + if ($total > 0) { |
|
| 190 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - if ( $percentage > 100 ) { |
|
| 193 | + if ($percentage > 100) { |
|
| 194 | 194 | $percentage = 100; |
| 195 | 195 | } |
| 196 | 196 | |
@@ -204,8 +204,8 @@ discard block |
||
| 204 | 204 | * |
| 205 | 205 | * @param array $request The Form Data passed into the batch processing |
| 206 | 206 | */ |
| 207 | - public function set_properties( $request ) { |
|
| 208 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
| 207 | + public function set_properties($request) { |
|
| 208 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -216,31 +216,31 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | public function process_step() { |
| 218 | 218 | |
| 219 | - if ( ! $this->can_export() ) { |
|
| 220 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 219 | + if ( ! $this->can_export()) { |
|
| 220 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | $had_data = $this->get_data(); |
| 224 | 224 | |
| 225 | - if ( $had_data ) { |
|
| 225 | + if ($had_data) { |
|
| 226 | 226 | $this->done = false; |
| 227 | 227 | |
| 228 | 228 | return true; |
| 229 | 229 | } else { |
| 230 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
| 231 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
| 230 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
| 231 | + $this->delete_data('give_temp_recount_form_stats'); |
|
| 232 | 232 | $this->done = true; |
| 233 | - $this->message = sprintf( esc_html__( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) ); |
|
| 233 | + $this->message = sprintf(esc_html__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id)); |
|
| 234 | 234 | |
| 235 | 235 | return false; |
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | public function headers() { |
| 240 | - ignore_user_abort( true ); |
|
| 240 | + ignore_user_abort(true); |
|
| 241 | 241 | |
| 242 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 243 | - set_time_limit( 0 ); |
|
| 242 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 243 | + set_time_limit(0); |
|
| 244 | 244 | } |
| 245 | 245 | } |
| 246 | 246 | |
@@ -268,11 +268,11 @@ discard block |
||
| 268 | 268 | * |
| 269 | 269 | * @return mixed Returns the data from the database |
| 270 | 270 | */ |
| 271 | - private function get_stored_data( $key ) { |
|
| 271 | + private function get_stored_data($key) { |
|
| 272 | 272 | global $wpdb; |
| 273 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 273 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 274 | 274 | |
| 275 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
| 275 | + return empty($value) ? false : maybe_unserialize($value); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
@@ -285,10 +285,10 @@ discard block |
||
| 285 | 285 | * |
| 286 | 286 | * @return void |
| 287 | 287 | */ |
| 288 | - private function store_data( $key, $value ) { |
|
| 288 | + private function store_data($key, $value) { |
|
| 289 | 289 | global $wpdb; |
| 290 | 290 | |
| 291 | - $value = maybe_serialize( $value ); |
|
| 291 | + $value = maybe_serialize($value); |
|
| 292 | 292 | |
| 293 | 293 | $data = array( |
| 294 | 294 | 'option_name' => $key, |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | '%s', |
| 303 | 303 | ); |
| 304 | 304 | |
| 305 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 305 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -314,9 +314,9 @@ discard block |
||
| 314 | 314 | * |
| 315 | 315 | * @return void |
| 316 | 316 | */ |
| 317 | - private function delete_data( $key ) { |
|
| 317 | + private function delete_data($key) { |
|
| 318 | 318 | global $wpdb; |
| 319 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 319 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | } |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | * @since 1.5 |
| 51 | 51 | * @global object $wpdb Used to query the database using the WordPress |
| 52 | 52 | * Database API |
| 53 | - * @return array $data The data for the CSV file |
|
| 53 | + * @return boolean $data The data for the CSV file |
|
| 54 | 54 | */ |
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $wpdb; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -54,50 +54,50 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function get_data() { |
| 56 | 56 | |
| 57 | - if ( $this->step == 1 ) { |
|
| 58 | - $this->delete_data( 'give_temp_recount_income' ); |
|
| 57 | + if ($this->step == 1) { |
|
| 58 | + $this->delete_data('give_temp_recount_income'); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - $total = get_option( 'give_temp_recount_income', false ); |
|
| 61 | + $total = get_option('give_temp_recount_income', false); |
|
| 62 | 62 | |
| 63 | - if ( false === $total ) { |
|
| 63 | + if (false === $total) { |
|
| 64 | 64 | $total = (float) 0; |
| 65 | - $this->store_data( 'give_temp_recount_income', $total ); |
|
| 65 | + $this->store_data('give_temp_recount_income', $total); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 68 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 69 | 69 | |
| 70 | - $args = apply_filters( 'give_recount_income_args', array( |
|
| 70 | + $args = apply_filters('give_recount_income_args', array( |
|
| 71 | 71 | 'number' => $this->per_step, |
| 72 | 72 | 'page' => $this->step, |
| 73 | 73 | 'status' => $accepted_statuses, |
| 74 | 74 | 'fields' => 'ids' |
| 75 | - ) ); |
|
| 75 | + )); |
|
| 76 | 76 | |
| 77 | - $payments = give_get_payments( $args ); |
|
| 77 | + $payments = give_get_payments($args); |
|
| 78 | 78 | |
| 79 | - if ( ! empty( $payments ) ) { |
|
| 79 | + if ( ! empty($payments)) { |
|
| 80 | 80 | |
| 81 | - foreach ( $payments as $payment ) { |
|
| 81 | + foreach ($payments as $payment) { |
|
| 82 | 82 | |
| 83 | - $total += give_get_payment_amount( $payment ); |
|
| 83 | + $total += give_get_payment_amount($payment); |
|
| 84 | 84 | |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if ( $total < 0 ) { |
|
| 87 | + if ($total < 0) { |
|
| 88 | 88 | $totals = 0; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - $total = round( $total, give_currency_decimal_filter() ); |
|
| 91 | + $total = round($total, give_currency_decimal_filter()); |
|
| 92 | 92 | |
| 93 | - $this->store_data( 'give_temp_recount_income', $total ); |
|
| 93 | + $this->store_data('give_temp_recount_income', $total); |
|
| 94 | 94 | |
| 95 | 95 | return true; |
| 96 | 96 | |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - update_option( 'give_income_total', $total ); |
|
| 100 | - set_transient( 'give_income_total', $total, 86400 ); |
|
| 99 | + update_option('give_income_total', $total); |
|
| 100 | + set_transient('give_income_total', $total, 86400); |
|
| 101 | 101 | |
| 102 | 102 | return false; |
| 103 | 103 | |
@@ -111,25 +111,25 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | public function get_percentage_complete() { |
| 113 | 113 | |
| 114 | - $total = $this->get_stored_data( 'give_recount_income_total' ); |
|
| 114 | + $total = $this->get_stored_data('give_recount_income_total'); |
|
| 115 | 115 | |
| 116 | - if ( false === $total ) { |
|
| 117 | - $args = apply_filters( 'give_recount_income_total_args', array() ); |
|
| 116 | + if (false === $total) { |
|
| 117 | + $args = apply_filters('give_recount_income_total_args', array()); |
|
| 118 | 118 | |
| 119 | - $counts = give_count_payments( $args ); |
|
| 120 | - $total = absint( $counts->publish ); |
|
| 121 | - $total = apply_filters( 'give_recount_store_income_total', $total ); |
|
| 119 | + $counts = give_count_payments($args); |
|
| 120 | + $total = absint($counts->publish); |
|
| 121 | + $total = apply_filters('give_recount_store_income_total', $total); |
|
| 122 | 122 | |
| 123 | - $this->store_data( 'give_recount_income_total', $total ); |
|
| 123 | + $this->store_data('give_recount_income_total', $total); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $percentage = 100; |
| 127 | 127 | |
| 128 | - if ( $total > 0 ) { |
|
| 129 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 128 | + if ($total > 0) { |
|
| 129 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - if ( $percentage > 100 ) { |
|
| 132 | + if ($percentage > 100) { |
|
| 133 | 133 | $percentage = 100; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * |
| 144 | 144 | * @param array $request The Form Data passed into the batch processing |
| 145 | 145 | */ |
| 146 | - public function set_properties( $request ) { |
|
| 146 | + public function set_properties($request) { |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
@@ -154,31 +154,31 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | public function process_step() { |
| 156 | 156 | |
| 157 | - if ( ! $this->can_export() ) { |
|
| 158 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 157 | + if ( ! $this->can_export()) { |
|
| 158 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | $had_data = $this->get_data(); |
| 162 | 162 | |
| 163 | - if ( $had_data ) { |
|
| 163 | + if ($had_data) { |
|
| 164 | 164 | $this->done = false; |
| 165 | 165 | |
| 166 | 166 | return true; |
| 167 | 167 | } else { |
| 168 | - $this->delete_data( 'give_recount_income_total' ); |
|
| 169 | - $this->delete_data( 'give_temp_recount_income' ); |
|
| 168 | + $this->delete_data('give_recount_income_total'); |
|
| 169 | + $this->delete_data('give_temp_recount_income'); |
|
| 170 | 170 | $this->done = true; |
| 171 | - $this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' ); |
|
| 171 | + $this->message = esc_html__('Income stats have been successfully recounted.', 'give'); |
|
| 172 | 172 | |
| 173 | 173 | return false; |
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | public function headers() { |
| 178 | - ignore_user_abort( true ); |
|
| 178 | + ignore_user_abort(true); |
|
| 179 | 179 | |
| 180 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 181 | - set_time_limit( 0 ); |
|
| 180 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 181 | + set_time_limit(0); |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
@@ -206,11 +206,11 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @return mixed Returns the data from the database |
| 208 | 208 | */ |
| 209 | - private function get_stored_data( $key ) { |
|
| 209 | + private function get_stored_data($key) { |
|
| 210 | 210 | global $wpdb; |
| 211 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 211 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 212 | 212 | |
| 213 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
| 213 | + return empty($value) ? false : maybe_unserialize($value); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
@@ -223,10 +223,10 @@ discard block |
||
| 223 | 223 | * |
| 224 | 224 | * @return void |
| 225 | 225 | */ |
| 226 | - private function store_data( $key, $value ) { |
|
| 226 | + private function store_data($key, $value) { |
|
| 227 | 227 | global $wpdb; |
| 228 | 228 | |
| 229 | - $value = maybe_serialize( $value ); |
|
| 229 | + $value = maybe_serialize($value); |
|
| 230 | 230 | |
| 231 | 231 | $data = array( |
| 232 | 232 | 'option_name' => $key, |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | '%s', |
| 241 | 241 | ); |
| 242 | 242 | |
| 243 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 243 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -252,9 +252,9 @@ discard block |
||
| 252 | 252 | * |
| 253 | 253 | * @return void |
| 254 | 254 | */ |
| 255 | - private function delete_data( $key ) { |
|
| 255 | + private function delete_data($key) { |
|
| 256 | 256 | global $wpdb; |
| 257 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 257 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | } |
@@ -206,6 +206,7 @@ |
||
| 206 | 206 | * Set Donor Data |
| 207 | 207 | * |
| 208 | 208 | * @param $donor |
| 209 | + * @param integer $i |
|
| 209 | 210 | */ |
| 210 | 211 | private function set_donor_data( $i, $data, $donor ) { |
| 211 | 212 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -46,16 +46,16 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @param array $request The Form Data passed into the batch processing |
| 48 | 48 | */ |
| 49 | - public function set_properties( $request ) { |
|
| 49 | + public function set_properties($request) { |
|
| 50 | 50 | |
| 51 | 51 | //Set data from form submission |
| 52 | - if ( isset( $_POST['form'] ) ) { |
|
| 53 | - parse_str( $_POST['form'], $this->data ); |
|
| 52 | + if (isset($_POST['form'])) { |
|
| 53 | + parse_str($_POST['form'], $this->data); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $this->form = $this->data['forms']; |
| 57 | 57 | |
| 58 | - $this->price_id = ! empty( $request['give_price_option'] ) && 0 !== $request['give_price_option'] ? absint( $request['give_price_option'] ) : null; |
|
| 58 | + $this->price_id = ! empty($request['give_price_option']) && 0 !== $request['give_price_option'] ? absint($request['give_price_option']) : null; |
|
| 59 | 59 | |
| 60 | 60 | } |
| 61 | 61 | |
@@ -70,14 +70,14 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | $cols = array(); |
| 72 | 72 | |
| 73 | - $columns = isset( $this->data['give_export_option'] ) ? $this->data['give_export_option'] : array(); |
|
| 73 | + $columns = isset($this->data['give_export_option']) ? $this->data['give_export_option'] : array(); |
|
| 74 | 74 | |
| 75 | 75 | //We need columns. |
| 76 | - if ( empty( $columns ) ) { |
|
| 76 | + if (empty($columns)) { |
|
| 77 | 77 | return false; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - $cols = $this->get_cols( $columns ); |
|
| 80 | + $cols = $this->get_cols($columns); |
|
| 81 | 81 | |
| 82 | 82 | return $cols; |
| 83 | 83 | } |
@@ -85,38 +85,38 @@ discard block |
||
| 85 | 85 | /** |
| 86 | 86 | * @param $column |
| 87 | 87 | */ |
| 88 | - private function get_cols( $columns ) { |
|
| 88 | + private function get_cols($columns) { |
|
| 89 | 89 | |
| 90 | 90 | $cols = array(); |
| 91 | 91 | |
| 92 | - foreach ( $columns as $key => $value ) { |
|
| 92 | + foreach ($columns as $key => $value) { |
|
| 93 | 93 | |
| 94 | - switch ( $key ) { |
|
| 94 | + switch ($key) { |
|
| 95 | 95 | case 'full_name' : |
| 96 | - $cols['full_name'] = esc_html__( 'Full Name', 'give' ); |
|
| 96 | + $cols['full_name'] = esc_html__('Full Name', 'give'); |
|
| 97 | 97 | break; |
| 98 | 98 | case 'email' : |
| 99 | - $cols['email'] = esc_html__( 'Email Address', 'give' ); |
|
| 99 | + $cols['email'] = esc_html__('Email Address', 'give'); |
|
| 100 | 100 | break; |
| 101 | 101 | case 'address' : |
| 102 | - $cols['address_line1'] = esc_html__( 'Address', 'give' ); |
|
| 103 | - $cols['address_line2'] = esc_html__( 'Address 2', 'give' ); |
|
| 104 | - $cols['address_city'] = esc_html__( 'City', 'give' ); |
|
| 105 | - $cols['address_state'] = esc_html__( 'State', 'give' ); |
|
| 106 | - $cols['address_zip'] = esc_html__( 'Zip', 'give' ); |
|
| 107 | - $cols['address_country'] = esc_html__( 'Country', 'give' ); |
|
| 102 | + $cols['address_line1'] = esc_html__('Address', 'give'); |
|
| 103 | + $cols['address_line2'] = esc_html__('Address 2', 'give'); |
|
| 104 | + $cols['address_city'] = esc_html__('City', 'give'); |
|
| 105 | + $cols['address_state'] = esc_html__('State', 'give'); |
|
| 106 | + $cols['address_zip'] = esc_html__('Zip', 'give'); |
|
| 107 | + $cols['address_country'] = esc_html__('Country', 'give'); |
|
| 108 | 108 | break; |
| 109 | 109 | case 'userid' : |
| 110 | - $cols['userid'] = esc_html__( 'User ID', 'give' ); |
|
| 110 | + $cols['userid'] = esc_html__('User ID', 'give'); |
|
| 111 | 111 | break; |
| 112 | 112 | case 'date_first_donated' : |
| 113 | - $cols['date_first_donated'] = esc_html__( 'First Donation Date', 'give' ); |
|
| 113 | + $cols['date_first_donated'] = esc_html__('First Donation Date', 'give'); |
|
| 114 | 114 | break; |
| 115 | 115 | case 'donations' : |
| 116 | - $cols['donations'] = esc_html__( 'Number of Donations', 'give' ); |
|
| 116 | + $cols['donations'] = esc_html__('Number of Donations', 'give'); |
|
| 117 | 117 | break; |
| 118 | 118 | case 'donation_sum' : |
| 119 | - $cols['donation_sum'] = esc_html__( 'Sum of Donations', 'give' ); |
|
| 119 | + $cols['donation_sum'] = esc_html__('Sum of Donations', 'give'); |
|
| 120 | 120 | break; |
| 121 | 121 | } |
| 122 | 122 | } |
@@ -139,20 +139,20 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | $i = 0; |
| 141 | 141 | |
| 142 | - if ( ! empty( $this->form ) ) { |
|
| 142 | + if ( ! empty($this->form)) { |
|
| 143 | 143 | |
| 144 | 144 | // Export donors of a specific product |
| 145 | 145 | global $give_logs; |
| 146 | 146 | |
| 147 | 147 | $args = array( |
| 148 | - 'post_parent' => absint( $this->form ), |
|
| 148 | + 'post_parent' => absint($this->form), |
|
| 149 | 149 | 'log_type' => 'sale', |
| 150 | 150 | 'posts_per_page' => 30, |
| 151 | 151 | 'paged' => $this->step |
| 152 | 152 | ); |
| 153 | 153 | |
| 154 | 154 | //Check for price option |
| 155 | - if ( null !== $this->price_id ) { |
|
| 155 | + if (null !== $this->price_id) { |
|
| 156 | 156 | $args['meta_query'] = array( |
| 157 | 157 | array( |
| 158 | 158 | 'key' => '_give_log_price_id', |
@@ -161,33 +161,33 @@ discard block |
||
| 161 | 161 | ); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - $logs = $give_logs->get_connected_logs( $args ); |
|
| 164 | + $logs = $give_logs->get_connected_logs($args); |
|
| 165 | 165 | |
| 166 | - if ( $logs ) { |
|
| 167 | - foreach ( $logs as $log ) { |
|
| 168 | - $payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true ); |
|
| 169 | - $payment = new Give_Payment( $payment_id ); |
|
| 170 | - $donor = Give()->customers->get_customer_by( 'id', $payment->customer_id ); |
|
| 171 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
| 172 | - $i ++; |
|
| 166 | + if ($logs) { |
|
| 167 | + foreach ($logs as $log) { |
|
| 168 | + $payment_id = get_post_meta($log->ID, '_give_log_payment_id', true); |
|
| 169 | + $payment = new Give_Payment($payment_id); |
|
| 170 | + $donor = Give()->customers->get_customer_by('id', $payment->customer_id); |
|
| 171 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
| 172 | + $i++; |
|
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | } else { |
| 177 | 177 | |
| 178 | 178 | // Export all customers |
| 179 | - $offset = 30 * ( $this->step - 1 ); |
|
| 180 | - $donors = Give()->customers->get_customers( array( 'number' => 30, 'offset' => $offset ) ); |
|
| 179 | + $offset = 30 * ($this->step - 1); |
|
| 180 | + $donors = Give()->customers->get_customers(array('number' => 30, 'offset' => $offset)); |
|
| 181 | 181 | |
| 182 | - foreach ( $donors as $donor ) { |
|
| 182 | + foreach ($donors as $donor) { |
|
| 183 | 183 | |
| 184 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
| 185 | - $i ++; |
|
| 184 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
| 185 | + $i++; |
|
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
| 190 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
| 189 | + $data = apply_filters('give_export_get_data', $data); |
|
| 190 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
| 191 | 191 | |
| 192 | 192 | return $data; |
| 193 | 193 | } |
@@ -203,19 +203,19 @@ discard block |
||
| 203 | 203 | $percentage = 0; |
| 204 | 204 | |
| 205 | 205 | // We can't count the number when getting them for a specific form |
| 206 | - if ( empty( $this->form ) ) { |
|
| 206 | + if (empty($this->form)) { |
|
| 207 | 207 | |
| 208 | 208 | $total = Give()->customers->count(); |
| 209 | 209 | |
| 210 | - if ( $total > 0 ) { |
|
| 210 | + if ($total > 0) { |
|
| 211 | 211 | |
| 212 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
| 212 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
| 213 | 213 | |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - if ( $percentage > 100 ) { |
|
| 218 | + if ($percentage > 100) { |
|
| 219 | 219 | $percentage = 100; |
| 220 | 220 | } |
| 221 | 221 | |
@@ -227,46 +227,46 @@ discard block |
||
| 227 | 227 | * |
| 228 | 228 | * @param $donor |
| 229 | 229 | */ |
| 230 | - private function set_donor_data( $i, $data, $donor ) { |
|
| 230 | + private function set_donor_data($i, $data, $donor) { |
|
| 231 | 231 | |
| 232 | 232 | $columns = $this->csv_cols(); |
| 233 | 233 | |
| 234 | 234 | //Set address variable |
| 235 | 235 | $address = ''; |
| 236 | - if ( isset( $donor->user_id ) && $donor->user_id > 0 ) { |
|
| 237 | - $address = give_get_donor_address( $donor->user_id ); |
|
| 236 | + if (isset($donor->user_id) && $donor->user_id > 0) { |
|
| 237 | + $address = give_get_donor_address($donor->user_id); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | //Set columns |
| 241 | - if ( ! empty( $columns['full_name'] ) ) { |
|
| 242 | - $data[ $i ]['full_name'] = $donor->name; |
|
| 241 | + if ( ! empty($columns['full_name'])) { |
|
| 242 | + $data[$i]['full_name'] = $donor->name; |
|
| 243 | 243 | } |
| 244 | - if ( ! empty( $columns['email'] ) ) { |
|
| 245 | - $data[ $i ]['email'] = $donor->email; |
|
| 244 | + if ( ! empty($columns['email'])) { |
|
| 245 | + $data[$i]['email'] = $donor->email; |
|
| 246 | 246 | } |
| 247 | - if ( ! empty( $columns['address_line1'] ) ) { |
|
| 248 | - |
|
| 249 | - $data[ $i ]['address_line1'] = isset( $address['line1'] ) ? $address['line1'] : ''; |
|
| 250 | - $data[ $i ]['address_line2'] = isset( $address['line2'] ) ? $address['line2'] : ''; |
|
| 251 | - $data[ $i ]['address_city'] = isset( $address['city'] ) ? $address['city'] : ''; |
|
| 252 | - $data[ $i ]['address_state'] = isset( $address['state'] ) ? $address['state'] : ''; |
|
| 253 | - $data[ $i ]['address_zip'] = isset( $address['zip'] ) ? $address['zip'] : ''; |
|
| 254 | - $data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : ''; |
|
| 247 | + if ( ! empty($columns['address_line1'])) { |
|
| 248 | + |
|
| 249 | + $data[$i]['address_line1'] = isset($address['line1']) ? $address['line1'] : ''; |
|
| 250 | + $data[$i]['address_line2'] = isset($address['line2']) ? $address['line2'] : ''; |
|
| 251 | + $data[$i]['address_city'] = isset($address['city']) ? $address['city'] : ''; |
|
| 252 | + $data[$i]['address_state'] = isset($address['state']) ? $address['state'] : ''; |
|
| 253 | + $data[$i]['address_zip'] = isset($address['zip']) ? $address['zip'] : ''; |
|
| 254 | + $data[$i]['address_country'] = isset($address['country']) ? $address['country'] : ''; |
|
| 255 | 255 | } |
| 256 | - if ( ! empty( $columns['userid'] ) ) { |
|
| 257 | - $data[ $i ]['userid'] = ! empty( $donor->user_id ) ? $donor->user_id : ''; |
|
| 256 | + if ( ! empty($columns['userid'])) { |
|
| 257 | + $data[$i]['userid'] = ! empty($donor->user_id) ? $donor->user_id : ''; |
|
| 258 | 258 | } |
| 259 | - if ( ! empty( $columns['date_first_donated'] ) ) { |
|
| 260 | - $data[ $i ]['date_first_donated'] = date_i18n( give_date_format(), strtotime( $donor->date_created ) ); |
|
| 259 | + if ( ! empty($columns['date_first_donated'])) { |
|
| 260 | + $data[$i]['date_first_donated'] = date_i18n(give_date_format(), strtotime($donor->date_created)); |
|
| 261 | 261 | } |
| 262 | - if ( ! empty( $columns['donations'] ) ) { |
|
| 263 | - $data[ $i ]['donations'] = $donor->purchase_count; |
|
| 262 | + if ( ! empty($columns['donations'])) { |
|
| 263 | + $data[$i]['donations'] = $donor->purchase_count; |
|
| 264 | 264 | } |
| 265 | - if ( ! empty( $columns['donation_sum'] ) ) { |
|
| 266 | - $data[ $i ]['donation_sum'] = give_format_amount( $donor->purchase_value ); |
|
| 265 | + if ( ! empty($columns['donation_sum'])) { |
|
| 266 | + $data[$i]['donation_sum'] = give_format_amount($donor->purchase_value); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - return $data[ $i ]; |
|
| 269 | + return $data[$i]; |
|
| 270 | 270 | |
| 271 | 271 | } |
| 272 | 272 | |
@@ -65,7 +65,7 @@ |
||
| 65 | 65 | * |
| 66 | 66 | * @since 1.0 |
| 67 | 67 | * @uses Give_Session::get() |
| 68 | - * @return mixed array if errors are present, false if none found |
|
| 68 | + * @return string array if errors are present, false if none found |
|
| 69 | 69 | */ |
| 70 | 70 | function give_get_errors() { |
| 71 | 71 | return Give()->session->get( 'give_errors' ); |
@@ -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 | |
@@ -29,33 +29,33 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @return void |
| 31 | 31 | */ |
| 32 | -function give_print_errors( $form_id ) { |
|
| 32 | +function give_print_errors($form_id) { |
|
| 33 | 33 | |
| 34 | 34 | $errors = give_get_errors(); |
| 35 | 35 | |
| 36 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? intval( $_REQUEST['form-id'] ) : 0; |
|
| 36 | + $request_form_id = isset($_REQUEST['form-id']) ? intval($_REQUEST['form-id']) : 0; |
|
| 37 | 37 | |
| 38 | 38 | // Sanity checks first: Ensure that gateway returned errors display on the appropriate form. |
| 39 | - if ( ! isset( $_POST['give_ajax'] ) && $request_form_id !== $form_id ) { |
|
| 39 | + if ( ! isset($_POST['give_ajax']) && $request_form_id !== $form_id) { |
|
| 40 | 40 | return; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - if ( $errors ) { |
|
| 44 | - $classes = apply_filters( 'give_error_class', array( |
|
| 43 | + if ($errors) { |
|
| 44 | + $classes = apply_filters('give_error_class', array( |
|
| 45 | 45 | 'give_errors', |
| 46 | - ) ); |
|
| 47 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
| 46 | + )); |
|
| 47 | + echo '<div class="'.implode(' ', $classes).'">'; |
|
| 48 | 48 | // Loop error codes and display errors. |
| 49 | - foreach ( $errors as $error_id => $error ) { |
|
| 50 | - echo '<div class="give_error" id="give_error_' . $error_id . '"><p><strong>' . esc_html__( 'Error', 'give' ) . '</strong>: ' . $error . '</p></div>'; |
|
| 49 | + foreach ($errors as $error_id => $error) { |
|
| 50 | + echo '<div class="give_error" id="give_error_'.$error_id.'"><p><strong>'.esc_html__('Error', 'give').'</strong>: '.$error.'</p></div>'; |
|
| 51 | 51 | } |
| 52 | 52 | echo '</div>'; |
| 53 | 53 | give_clear_errors(); |
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | -add_action( 'give_donation_form_before_personal_info', 'give_print_errors' ); |
|
| 58 | -add_action( 'give_ajax_donation_errors', 'give_print_errors' ); |
|
| 57 | +add_action('give_donation_form_before_personal_info', 'give_print_errors'); |
|
| 58 | +add_action('give_ajax_donation_errors', 'give_print_errors'); |
|
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * Get Errors |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @return mixed array if errors are present, false if none found |
| 69 | 69 | */ |
| 70 | 70 | function give_get_errors() { |
| 71 | - return Give()->session->get( 'give_errors' ); |
|
| 71 | + return Give()->session->get('give_errors'); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -84,13 +84,13 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @return void |
| 86 | 86 | */ |
| 87 | -function give_set_error( $error_id, $error_message ) { |
|
| 87 | +function give_set_error($error_id, $error_message) { |
|
| 88 | 88 | $errors = give_get_errors(); |
| 89 | - if ( ! $errors ) { |
|
| 89 | + if ( ! $errors) { |
|
| 90 | 90 | $errors = array(); |
| 91 | 91 | } |
| 92 | - $errors[ $error_id ] = $error_message; |
|
| 93 | - Give()->session->set( 'give_errors', $errors ); |
|
| 92 | + $errors[$error_id] = $error_message; |
|
| 93 | + Give()->session->set('give_errors', $errors); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @return void |
| 102 | 102 | */ |
| 103 | 103 | function give_clear_errors() { |
| 104 | - Give()->session->set( 'give_errors', null ); |
|
| 104 | + Give()->session->set('give_errors', null); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @return void |
| 116 | 116 | */ |
| 117 | -function give_unset_error( $error_id ) { |
|
| 117 | +function give_unset_error($error_id) { |
|
| 118 | 118 | $errors = give_get_errors(); |
| 119 | - if ( $errors ) { |
|
| 120 | - unset( $errors[ $error_id ] ); |
|
| 121 | - Give()->session->set( 'give_errors', $errors ); |
|
| 119 | + if ($errors) { |
|
| 120 | + unset($errors[$error_id]); |
|
| 121 | + Give()->session->set('give_errors', $errors); |
|
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @return string|void |
| 130 | 130 | */ |
| 131 | 131 | function _give_die_handler() { |
| 132 | - if ( defined( 'GIVE_UNIT_TESTS' ) ) { |
|
| 132 | + if (defined('GIVE_UNIT_TESTS')) { |
|
| 133 | 133 | return '_give_die_handler'; |
| 134 | 134 | } else { |
| 135 | 135 | die(); |
@@ -149,10 +149,10 @@ discard block |
||
| 149 | 149 | * |
| 150 | 150 | * @return void |
| 151 | 151 | */ |
| 152 | -function give_die( $message = '', $title = '', $status = 400 ) { |
|
| 153 | - add_filter( 'wp_die_ajax_handler', '_give_die_handler', 10, 3 ); |
|
| 154 | - add_filter( 'wp_die_handler', '_give_die_handler', 10, 3 ); |
|
| 155 | - wp_die( $message, $title, array( 'response' => $status ) ); |
|
| 152 | +function give_die($message = '', $title = '', $status = 400) { |
|
| 153 | + add_filter('wp_die_ajax_handler', '_give_die_handler', 10, 3); |
|
| 154 | + add_filter('wp_die_handler', '_give_die_handler', 10, 3); |
|
| 155 | + wp_die($message, $title, array('response' => $status)); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -168,10 +168,10 @@ discard block |
||
| 168 | 168 | * |
| 169 | 169 | * @return string $error |
| 170 | 170 | */ |
| 171 | -function give_output_error( $message, $echo = true, $error_id = 'warning' ) { |
|
| 172 | - $error = '<div class="give_errors" id="give_error_' . $error_id . '"><p class="give_error give_' . $error_id . '">' . $message . '</p></div>'; |
|
| 171 | +function give_output_error($message, $echo = true, $error_id = 'warning') { |
|
| 172 | + $error = '<div class="give_errors" id="give_error_'.$error_id.'"><p class="give_error give_'.$error_id.'">'.$message.'</p></div>'; |
|
| 173 | 173 | |
| 174 | - if ( $echo ) { |
|
| 174 | + if ($echo) { |
|
| 175 | 175 | echo $error; |
| 176 | 176 | } else { |
| 177 | 177 | return $error; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | //validate display_style and float_labels value |
| 93 | 93 | if ( ( $key == 'display_style' && ! in_array( $value, array( 'onpage', 'reveal', 'modal' ) ) ) |
| 94 | - || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) ) |
|
| 94 | + || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) ) |
|
| 95 | 95 | ) { |
| 96 | 96 | |
| 97 | 97 | $atts[ $key ] = ''; |
@@ -169,15 +169,15 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | function give_login_form_shortcode( $atts, $content = null ) { |
| 171 | 171 | $atts = shortcode_atts( array( |
| 172 | - // Add backward compatibility for redirect attribute. |
|
| 173 | - 'redirect' => '', |
|
| 172 | + // Add backward compatibility for redirect attribute. |
|
| 173 | + 'redirect' => '', |
|
| 174 | 174 | |
| 175 | 175 | 'login-redirect' => '', |
| 176 | 176 | 'logout-redirect' => '', |
| 177 | 177 | ), $atts, 'give_login' ); |
| 178 | 178 | |
| 179 | - // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
|
| 180 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' ); |
|
| 179 | + // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
|
| 180 | + $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' ); |
|
| 181 | 181 | |
| 182 | 182 | return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
| 183 | 183 | } |
@@ -425,11 +425,11 @@ |
||
| 425 | 425 | // Make sure email should not be empty. |
| 426 | 426 | give_set_error( 'email_empty', esc_html__( 'The email you entered is empty.', 'give' ) ); |
| 427 | 427 | |
| 428 | - }else if ( ! is_email( $email ) ){ |
|
| 428 | + } else if ( ! is_email( $email ) ){ |
|
| 429 | 429 | // Make sure email should be valid. |
| 430 | 430 | give_set_error( 'email_not_valid', esc_html__( 'The email you entered is not valid. Please use another', 'give' ) ); |
| 431 | 431 | |
| 432 | - }else if ( $email != $old_user_data->user_email ) { |
|
| 432 | + } else if ( $email != $old_user_data->user_email ) { |
|
| 433 | 433 | // Make sure the new email doesn't belong to another user |
| 434 | 434 | if ( email_exists( $email ) ) { |
| 435 | 435 | give_set_error( 'email_exists', esc_html__( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -26,36 +26,36 @@ discard block |
||
| 26 | 26 | function give_donation_history() { |
| 27 | 27 | |
| 28 | 28 | // If payment_key query arg exists, return receipt instead of donation history. |
| 29 | - if ( isset( $_GET['payment_key'] ) ) { |
|
| 29 | + if (isset($_GET['payment_key'])) { |
|
| 30 | 30 | ob_start(); |
| 31 | - echo give_receipt_shortcode( array() ); |
|
| 32 | - echo '<a href="' . esc_url( give_get_history_page_uri() ) . '">« ' . esc_html__( 'Return to All Donations', 'give' ) . '</a>'; |
|
| 31 | + echo give_receipt_shortcode(array()); |
|
| 32 | + echo '<a href="'.esc_url(give_get_history_page_uri()).'">« '.esc_html__('Return to All Donations', 'give').'</a>'; |
|
| 33 | 33 | |
| 34 | 34 | return ob_get_clean(); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - $email_access = give_get_option( 'email_access' ); |
|
| 37 | + $email_access = give_get_option('email_access'); |
|
| 38 | 38 | |
| 39 | 39 | //Is user logged in? Does a session exist? Does an email-access token exist? |
| 40 | - if ( is_user_logged_in() || Give()->session->get_session_expiration() !== false || ( $email_access == 'on' && Give()->email_access->token_exists ) ) { |
|
| 40 | + if (is_user_logged_in() || Give()->session->get_session_expiration() !== false || ($email_access == 'on' && Give()->email_access->token_exists)) { |
|
| 41 | 41 | ob_start(); |
| 42 | - give_get_template_part( 'history', 'donations' ); |
|
| 42 | + give_get_template_part('history', 'donations'); |
|
| 43 | 43 | |
| 44 | 44 | return ob_get_clean(); |
| 45 | 45 | } //Is Email-based access enabled? |
| 46 | - elseif ( $email_access == 'on' ) { |
|
| 46 | + elseif ($email_access == 'on') { |
|
| 47 | 47 | |
| 48 | 48 | ob_start(); |
| 49 | - give_get_template_part( 'email', 'login-form' ); |
|
| 49 | + give_get_template_part('email', 'login-form'); |
|
| 50 | 50 | |
| 51 | 51 | return ob_get_clean(); |
| 52 | 52 | } else { |
| 53 | - $message = esc_html__( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ); |
|
| 54 | - echo apply_filters( 'give_donation_history_nonuser_message', give_output_error( $message, false ), $message ); |
|
| 53 | + $message = esc_html__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'); |
|
| 54 | + echo apply_filters('give_donation_history_nonuser_message', give_output_error($message, false), $message); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | -add_shortcode( 'donation_history', 'give_donation_history' ); |
|
| 58 | +add_shortcode('donation_history', 'give_donation_history'); |
|
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * Donation Form Shortcode |
@@ -68,53 +68,53 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @return string |
| 70 | 70 | */ |
| 71 | -function give_form_shortcode( $atts ) { |
|
| 72 | - $atts = shortcode_atts( array( |
|
| 71 | +function give_form_shortcode($atts) { |
|
| 72 | + $atts = shortcode_atts(array( |
|
| 73 | 73 | 'id' => '', |
| 74 | 74 | 'show_title' => true, |
| 75 | 75 | 'show_goal' => true, |
| 76 | 76 | 'show_content' => '', |
| 77 | 77 | 'float_labels' => '', |
| 78 | 78 | 'display_style' => '', |
| 79 | - ), $atts, 'give_form' ); |
|
| 79 | + ), $atts, 'give_form'); |
|
| 80 | 80 | |
| 81 | - foreach ( $atts as $key => $value ) { |
|
| 81 | + foreach ($atts as $key => $value) { |
|
| 82 | 82 | //convert shortcode_atts values to booleans |
| 83 | - if ( $key == 'show_title' ) { |
|
| 84 | - $atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN ); |
|
| 85 | - } elseif ( $key == 'show_goal' ) { |
|
| 86 | - $atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN ); |
|
| 83 | + if ($key == 'show_title') { |
|
| 84 | + $atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN); |
|
| 85 | + } elseif ($key == 'show_goal') { |
|
| 86 | + $atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | //validate show_content value |
| 90 | - if ( $key == 'show_content' ) { |
|
| 91 | - if ( ! in_array( $value, array( 'none', 'above', 'below' ) ) ) { |
|
| 92 | - $atts[ $key ] = ''; |
|
| 93 | - } else if ( $value == 'above' ) { |
|
| 94 | - $atts[ $key ] = 'give_pre_form'; |
|
| 95 | - } else if ( $value == 'below' ) { |
|
| 96 | - $atts[ $key ] = 'give_post_form'; |
|
| 90 | + if ($key == 'show_content') { |
|
| 91 | + if ( ! in_array($value, array('none', 'above', 'below'))) { |
|
| 92 | + $atts[$key] = ''; |
|
| 93 | + } else if ($value == 'above') { |
|
| 94 | + $atts[$key] = 'give_pre_form'; |
|
| 95 | + } else if ($value == 'below') { |
|
| 96 | + $atts[$key] = 'give_post_form'; |
|
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | //validate display_style and float_labels value |
| 101 | - if ( ( $key == 'display_style' && ! in_array( $value, array( 'onpage', 'reveal', 'modal' ) ) ) |
|
| 102 | - || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) ) |
|
| 101 | + if (($key == 'display_style' && ! in_array($value, array('onpage', 'reveal', 'modal'))) |
|
| 102 | + || ($key == 'float_labels' && ! in_array($value, array('enabled', 'disabled'))) |
|
| 103 | 103 | ) { |
| 104 | 104 | |
| 105 | - $atts[ $key ] = ''; |
|
| 105 | + $atts[$key] = ''; |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | //get the Give Form |
| 110 | 110 | ob_start(); |
| 111 | - give_get_donation_form( $atts ); |
|
| 111 | + give_get_donation_form($atts); |
|
| 112 | 112 | $final_output = ob_get_clean(); |
| 113 | 113 | |
| 114 | - return apply_filters( 'give_donate_form', $final_output, $atts ); |
|
| 114 | + return apply_filters('give_donate_form', $final_output, $atts); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | -add_shortcode( 'give_form', 'give_form_shortcode' ); |
|
| 117 | +add_shortcode('give_form', 'give_form_shortcode'); |
|
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | 120 | * Donation Form Goal Shortcode. |
@@ -127,37 +127,37 @@ discard block |
||
| 127 | 127 | * |
| 128 | 128 | * @return string |
| 129 | 129 | */ |
| 130 | -function give_goal_shortcode( $atts ) { |
|
| 131 | - $atts = shortcode_atts( array( |
|
| 130 | +function give_goal_shortcode($atts) { |
|
| 131 | + $atts = shortcode_atts(array( |
|
| 132 | 132 | 'id' => '', |
| 133 | 133 | 'show_text' => true, |
| 134 | 134 | 'show_bar' => true, |
| 135 | - ), $atts, 'give_goal' ); |
|
| 135 | + ), $atts, 'give_goal'); |
|
| 136 | 136 | |
| 137 | 137 | |
| 138 | 138 | //get the Give Form. |
| 139 | 139 | ob_start(); |
| 140 | 140 | |
| 141 | 141 | //Sanity check 1: ensure there is an ID Provided. |
| 142 | - if ( empty( $atts['id'] ) ) { |
|
| 143 | - give_output_error( esc_html__( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true ); |
|
| 142 | + if (empty($atts['id'])) { |
|
| 143 | + give_output_error(esc_html__('The shortcode is missing Donation Form ID attribute.', 'give'), true); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | //Sanity check 2: Check the form even has Goals enabled. |
| 147 | - $goal_option = get_post_meta( $atts['id'], '_give_goal_option', true ); |
|
| 148 | - if ( empty( $goal_option ) || $goal_option !== 'yes' ) { |
|
| 149 | - give_output_error( esc_html__( 'The form does not have Goals enabled.', 'give' ), true ); |
|
| 147 | + $goal_option = get_post_meta($atts['id'], '_give_goal_option', true); |
|
| 148 | + if (empty($goal_option) || $goal_option !== 'yes') { |
|
| 149 | + give_output_error(esc_html__('The form does not have Goals enabled.', 'give'), true); |
|
| 150 | 150 | } else { |
| 151 | 151 | //Passed all sanity checks: output Goal. |
| 152 | - give_show_goal_progress( $atts['id'], $atts ); |
|
| 152 | + give_show_goal_progress($atts['id'], $atts); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | $final_output = ob_get_clean(); |
| 156 | 156 | |
| 157 | - return apply_filters( 'give_goal_shortcode_output', $final_output, $atts ); |
|
| 157 | + return apply_filters('give_goal_shortcode_output', $final_output, $atts); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | -add_shortcode( 'give_goal', 'give_goal_shortcode' ); |
|
| 160 | +add_shortcode('give_goal', 'give_goal_shortcode'); |
|
| 161 | 161 | |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -174,22 +174,22 @@ discard block |
||
| 174 | 174 | * |
| 175 | 175 | * @return string |
| 176 | 176 | */ |
| 177 | -function give_login_form_shortcode( $atts ) { |
|
| 178 | - $atts = shortcode_atts( array( |
|
| 177 | +function give_login_form_shortcode($atts) { |
|
| 178 | + $atts = shortcode_atts(array( |
|
| 179 | 179 | // Add backward compatibility for redirect attribute. |
| 180 | 180 | 'redirect' => '', |
| 181 | 181 | |
| 182 | 182 | 'login-redirect' => '', |
| 183 | 183 | 'logout-redirect' => '', |
| 184 | - ), $atts, 'give_login' ); |
|
| 184 | + ), $atts, 'give_login'); |
|
| 185 | 185 | |
| 186 | 186 | // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
| 187 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' ); |
|
| 187 | + $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : ''); |
|
| 188 | 188 | |
| 189 | - return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
|
| 189 | + return give_login_form($atts['login-redirect'], $atts['logout-redirect']); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | -add_shortcode( 'give_login', 'give_login_form_shortcode' ); |
|
| 192 | +add_shortcode('give_login', 'give_login_form_shortcode'); |
|
| 193 | 193 | |
| 194 | 194 | /** |
| 195 | 195 | * Register Shortcode. |
@@ -204,15 +204,15 @@ discard block |
||
| 204 | 204 | * |
| 205 | 205 | * @return string |
| 206 | 206 | */ |
| 207 | -function give_register_form_shortcode( $atts ) { |
|
| 208 | - $atts = shortcode_atts( array( |
|
| 207 | +function give_register_form_shortcode($atts) { |
|
| 208 | + $atts = shortcode_atts(array( |
|
| 209 | 209 | 'redirect' => '', |
| 210 | - ), $atts, 'give_register' ); |
|
| 210 | + ), $atts, 'give_register'); |
|
| 211 | 211 | |
| 212 | - return give_register_form( $atts['redirect'] ); |
|
| 212 | + return give_register_form($atts['redirect']); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | -add_shortcode( 'give_register', 'give_register_form_shortcode' ); |
|
| 215 | +add_shortcode('give_register', 'give_register_form_shortcode'); |
|
| 216 | 216 | |
| 217 | 217 | /** |
| 218 | 218 | * Receipt Shortcode. |
@@ -225,12 +225,12 @@ discard block |
||
| 225 | 225 | * |
| 226 | 226 | * @return string |
| 227 | 227 | */ |
| 228 | -function give_receipt_shortcode( $atts ) { |
|
| 228 | +function give_receipt_shortcode($atts) { |
|
| 229 | 229 | |
| 230 | 230 | global $give_receipt_args, $payment; |
| 231 | 231 | |
| 232 | - $give_receipt_args = shortcode_atts( array( |
|
| 233 | - 'error' => esc_html__( 'You are missing the payment key to view this donation receipt.', 'give' ), |
|
| 232 | + $give_receipt_args = shortcode_atts(array( |
|
| 233 | + 'error' => esc_html__('You are missing the payment key to view this donation receipt.', 'give'), |
|
| 234 | 234 | 'price' => true, |
| 235 | 235 | 'donor' => true, |
| 236 | 236 | 'date' => true, |
@@ -239,50 +239,50 @@ discard block |
||
| 239 | 239 | 'payment_id' => true, |
| 240 | 240 | 'payment_status' => false, |
| 241 | 241 | 'status_notice' => true, |
| 242 | - ), $atts, 'give_receipt' ); |
|
| 242 | + ), $atts, 'give_receipt'); |
|
| 243 | 243 | |
| 244 | 244 | //set $session var |
| 245 | 245 | $session = give_get_purchase_session(); |
| 246 | 246 | |
| 247 | 247 | //set payment key var |
| 248 | - if ( isset( $_GET['payment_key'] ) ) { |
|
| 249 | - $payment_key = urldecode( $_GET['payment_key'] ); |
|
| 250 | - } elseif ( $session ) { |
|
| 248 | + if (isset($_GET['payment_key'])) { |
|
| 249 | + $payment_key = urldecode($_GET['payment_key']); |
|
| 250 | + } elseif ($session) { |
|
| 251 | 251 | $payment_key = $session['purchase_key']; |
| 252 | - } elseif ( $give_receipt_args['payment_key'] ) { |
|
| 252 | + } elseif ($give_receipt_args['payment_key']) { |
|
| 253 | 253 | $payment_key = $give_receipt_args['payment_key']; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - $email_access = give_get_option( 'email_access' ); |
|
| 256 | + $email_access = give_get_option('email_access'); |
|
| 257 | 257 | |
| 258 | 258 | // No payment_key found & Email Access is Turned on: |
| 259 | - if ( ! isset( $payment_key ) && $email_access == 'on' && ! Give()->email_access->token_exists ) { |
|
| 259 | + if ( ! isset($payment_key) && $email_access == 'on' && ! Give()->email_access->token_exists) { |
|
| 260 | 260 | |
| 261 | 261 | ob_start(); |
| 262 | 262 | |
| 263 | - give_get_template_part( 'email-login-form' ); |
|
| 263 | + give_get_template_part('email-login-form'); |
|
| 264 | 264 | |
| 265 | 265 | return ob_get_clean(); |
| 266 | 266 | |
| 267 | - } elseif ( ! isset( $payment_key ) ) { |
|
| 267 | + } elseif ( ! isset($payment_key)) { |
|
| 268 | 268 | |
| 269 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
| 269 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
| 270 | 270 | |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - $payment_id = give_get_purchase_id_by_key( $payment_key ); |
|
| 274 | - $user_can_view = give_can_view_receipt( $payment_key ); |
|
| 273 | + $payment_id = give_get_purchase_id_by_key($payment_key); |
|
| 274 | + $user_can_view = give_can_view_receipt($payment_key); |
|
| 275 | 275 | |
| 276 | 276 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt. |
| 277 | - if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists ) { |
|
| 277 | + if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists) { |
|
| 278 | 278 | |
| 279 | 279 | ob_start(); |
| 280 | 280 | |
| 281 | - give_get_template_part( 'email-login-form' ); |
|
| 281 | + give_get_template_part('email-login-form'); |
|
| 282 | 282 | |
| 283 | 283 | return ob_get_clean(); |
| 284 | 284 | |
| 285 | - } elseif ( ! $user_can_view ) { |
|
| 285 | + } elseif ( ! $user_can_view) { |
|
| 286 | 286 | |
| 287 | 287 | global $give_login_redirect; |
| 288 | 288 | |
@@ -290,9 +290,9 @@ discard block |
||
| 290 | 290 | |
| 291 | 291 | ob_start(); |
| 292 | 292 | |
| 293 | - give_output_error( apply_filters( 'give_must_be_logged_in_error_message', esc_html__( 'You must be logged in to view this donation receipt.', 'give' ) ) ); |
|
| 293 | + give_output_error(apply_filters('give_must_be_logged_in_error_message', esc_html__('You must be logged in to view this donation receipt.', 'give'))); |
|
| 294 | 294 | |
| 295 | - give_get_template_part( 'shortcode', 'login' ); |
|
| 295 | + give_get_template_part('shortcode', 'login'); |
|
| 296 | 296 | |
| 297 | 297 | $login_form = ob_get_clean(); |
| 298 | 298 | |
@@ -307,20 +307,20 @@ discard block |
||
| 307 | 307 | * or if user is logged in and the user can view sensitive shop data. |
| 308 | 308 | * |
| 309 | 309 | */ |
| 310 | - if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) { |
|
| 311 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
| 310 | + if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { |
|
| 311 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | ob_start(); |
| 315 | 315 | |
| 316 | - give_get_template_part( 'shortcode', 'receipt' ); |
|
| 316 | + give_get_template_part('shortcode', 'receipt'); |
|
| 317 | 317 | |
| 318 | 318 | $display = ob_get_clean(); |
| 319 | 319 | |
| 320 | 320 | return $display; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | -add_shortcode( 'give_receipt', 'give_receipt_shortcode' ); |
|
| 323 | +add_shortcode('give_receipt', 'give_receipt_shortcode'); |
|
| 324 | 324 | |
| 325 | 325 | /** |
| 326 | 326 | * Profile Editor Shortcode. |
@@ -339,18 +339,18 @@ discard block |
||
| 339 | 339 | * |
| 340 | 340 | * @return string Output generated from the profile editor |
| 341 | 341 | */ |
| 342 | -function give_profile_editor_shortcode( $atts ) { |
|
| 342 | +function give_profile_editor_shortcode($atts) { |
|
| 343 | 343 | |
| 344 | 344 | ob_start(); |
| 345 | 345 | |
| 346 | - give_get_template_part( 'shortcode', 'profile-editor' ); |
|
| 346 | + give_get_template_part('shortcode', 'profile-editor'); |
|
| 347 | 347 | |
| 348 | 348 | $display = ob_get_clean(); |
| 349 | 349 | |
| 350 | 350 | return $display; |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | -add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' ); |
|
| 353 | +add_shortcode('give_profile_editor', 'give_profile_editor_shortcode'); |
|
| 354 | 354 | |
| 355 | 355 | /** |
| 356 | 356 | * Process Profile Updater Form. |
@@ -363,30 +363,30 @@ discard block |
||
| 363 | 363 | * |
| 364 | 364 | * @return bool |
| 365 | 365 | */ |
| 366 | -function give_process_profile_editor_updates( $data ) { |
|
| 366 | +function give_process_profile_editor_updates($data) { |
|
| 367 | 367 | // Profile field change request |
| 368 | - if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) { |
|
| 368 | + if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) { |
|
| 369 | 369 | return false; |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | // Nonce security |
| 373 | - if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) { |
|
| 373 | + if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) { |
|
| 374 | 374 | return false; |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | $user_id = get_current_user_id(); |
| 378 | - $old_user_data = get_userdata( $user_id ); |
|
| 379 | - |
|
| 380 | - $display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name; |
|
| 381 | - $first_name = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name; |
|
| 382 | - $last_name = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name; |
|
| 383 | - $email = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email; |
|
| 384 | - $line1 = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' ); |
|
| 385 | - $line2 = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' ); |
|
| 386 | - $city = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' ); |
|
| 387 | - $state = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' ); |
|
| 388 | - $zip = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' ); |
|
| 389 | - $country = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' ); |
|
| 378 | + $old_user_data = get_userdata($user_id); |
|
| 379 | + |
|
| 380 | + $display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name; |
|
| 381 | + $first_name = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name; |
|
| 382 | + $last_name = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name; |
|
| 383 | + $email = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email; |
|
| 384 | + $line1 = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : ''); |
|
| 385 | + $line2 = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : ''); |
|
| 386 | + $city = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : ''); |
|
| 387 | + $state = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : ''); |
|
| 388 | + $zip = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : ''); |
|
| 389 | + $country = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : ''); |
|
| 390 | 390 | |
| 391 | 391 | $userdata = array( |
| 392 | 392 | 'ID' => $user_id, |
@@ -414,46 +414,46 @@ discard block |
||
| 414 | 414 | * @param int $user_id The ID of the user. |
| 415 | 415 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
| 416 | 416 | */ |
| 417 | - do_action( 'give_pre_update_user_profile', $user_id, $userdata ); |
|
| 417 | + do_action('give_pre_update_user_profile', $user_id, $userdata); |
|
| 418 | 418 | |
| 419 | 419 | // New password |
| 420 | - if ( ! empty( $data['give_new_user_pass1'] ) ) { |
|
| 421 | - if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) { |
|
| 422 | - give_set_error( 'password_mismatch', esc_html__( 'The passwords you entered do not match. Please try again.', 'give' ) ); |
|
| 420 | + if ( ! empty($data['give_new_user_pass1'])) { |
|
| 421 | + if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) { |
|
| 422 | + give_set_error('password_mismatch', esc_html__('The passwords you entered do not match. Please try again.', 'give')); |
|
| 423 | 423 | } else { |
| 424 | 424 | $userdata['user_pass'] = $data['give_new_user_pass1']; |
| 425 | 425 | } |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - if( empty( $email ) ) { |
|
| 428 | + if (empty($email)) { |
|
| 429 | 429 | // Make sure email should not be empty. |
| 430 | - give_set_error( 'email_empty', esc_html__( 'The email you entered is empty.', 'give' ) ); |
|
| 430 | + give_set_error('email_empty', esc_html__('The email you entered is empty.', 'give')); |
|
| 431 | 431 | |
| 432 | - }else if ( ! is_email( $email ) ){ |
|
| 432 | + } else if ( ! is_email($email)) { |
|
| 433 | 433 | // Make sure email should be valid. |
| 434 | - give_set_error( 'email_not_valid', esc_html__( 'The email you entered is not valid. Please use another', 'give' ) ); |
|
| 434 | + give_set_error('email_not_valid', esc_html__('The email you entered is not valid. Please use another', 'give')); |
|
| 435 | 435 | |
| 436 | - }else if ( $email != $old_user_data->user_email ) { |
|
| 436 | + } else if ($email != $old_user_data->user_email) { |
|
| 437 | 437 | // Make sure the new email doesn't belong to another user |
| 438 | - if ( email_exists( $email ) ) { |
|
| 439 | - give_set_error( 'email_exists', esc_html__( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
|
| 438 | + if (email_exists($email)) { |
|
| 439 | + give_set_error('email_exists', esc_html__('The email you entered belongs to another user. Please use another.', 'give')); |
|
| 440 | 440 | } |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | // Check for errors |
| 444 | 444 | $errors = give_get_errors(); |
| 445 | 445 | |
| 446 | - if ( $errors ) { |
|
| 446 | + if ($errors) { |
|
| 447 | 447 | // Send back to the profile editor if there are errors |
| 448 | - wp_redirect( $data['give_redirect'] ); |
|
| 448 | + wp_redirect($data['give_redirect']); |
|
| 449 | 449 | give_die(); |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | // Update the user |
| 453 | - $meta = update_user_meta( $user_id, '_give_user_address', $address ); |
|
| 454 | - $updated = wp_update_user( $userdata ); |
|
| 453 | + $meta = update_user_meta($user_id, '_give_user_address', $address); |
|
| 454 | + $updated = wp_update_user($userdata); |
|
| 455 | 455 | |
| 456 | - if ( $updated ) { |
|
| 456 | + if ($updated) { |
|
| 457 | 457 | |
| 458 | 458 | /** |
| 459 | 459 | * Fires after updating user profile. |
@@ -463,12 +463,12 @@ discard block |
||
| 463 | 463 | * @param int $user_id The ID of the user. |
| 464 | 464 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
| 465 | 465 | */ |
| 466 | - do_action( 'give_user_profile_updated', $user_id, $userdata ); |
|
| 467 | - wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) ); |
|
| 466 | + do_action('give_user_profile_updated', $user_id, $userdata); |
|
| 467 | + wp_redirect(add_query_arg('updated', 'true', $data['give_redirect'])); |
|
| 468 | 468 | give_die(); |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | return false; |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | -add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' ); |
|
| 474 | +add_action('give_edit_user_profile', 'give_process_profile_editor_updates'); |
|
@@ -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,13 +23,13 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return bool true if has variable prices, false otherwise |
| 25 | 25 | */ |
| 26 | -function give_has_variable_prices( $form_id = 0 ) { |
|
| 26 | +function give_has_variable_prices($form_id = 0) { |
|
| 27 | 27 | |
| 28 | - if ( empty( $form_id ) ) { |
|
| 28 | + if (empty($form_id)) { |
|
| 29 | 29 | return false; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - $form = new Give_Donate_Form( $form_id ); |
|
| 32 | + $form = new Give_Donate_Form($form_id); |
|
| 33 | 33 | |
| 34 | 34 | return $form->has_variable_prices(); |
| 35 | 35 | } |
@@ -44,13 +44,13 @@ discard block |
||
| 44 | 44 | * |
| 45 | 45 | * @return array Variable prices |
| 46 | 46 | */ |
| 47 | -function give_get_variable_prices( $form_id = 0 ) { |
|
| 47 | +function give_get_variable_prices($form_id = 0) { |
|
| 48 | 48 | |
| 49 | - if ( empty( $form_id ) ) { |
|
| 49 | + if (empty($form_id)) { |
|
| 50 | 50 | return false; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - $form = new Give_Donate_Form( $form_id ); |
|
| 53 | + $form = new Give_Donate_Form($form_id); |
|
| 54 | 54 | |
| 55 | 55 | return $form->prices; |
| 56 | 56 | |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @return string $default_price |
| 69 | 69 | */ |
| 70 | -function give_get_default_multilevel_amount( $form_id ) { |
|
| 70 | +function give_get_default_multilevel_amount($form_id) { |
|
| 71 | 71 | $default_price = '1.00'; |
| 72 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
| 72 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
| 73 | 73 | |
| 74 | - foreach ( $prices as $price ) { |
|
| 74 | + foreach ($prices as $price) { |
|
| 75 | 75 | |
| 76 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
| 76 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
| 77 | 77 | $default_price = $price['_give_amount']; |
| 78 | 78 | } |
| 79 | 79 | |
@@ -94,15 +94,15 @@ discard block |
||
| 94 | 94 | * @return string $default_price |
| 95 | 95 | * @since 1.0 |
| 96 | 96 | */ |
| 97 | -function give_get_default_form_amount( $form_id ) { |
|
| 97 | +function give_get_default_form_amount($form_id) { |
|
| 98 | 98 | |
| 99 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 99 | + if (give_has_variable_prices($form_id)) { |
|
| 100 | 100 | |
| 101 | - $default_amount = give_get_default_multilevel_amount( $form_id ); |
|
| 101 | + $default_amount = give_get_default_multilevel_amount($form_id); |
|
| 102 | 102 | |
| 103 | 103 | } else { |
| 104 | 104 | |
| 105 | - $default_amount = get_post_meta( $form_id, '_give_set_price', true ); |
|
| 105 | + $default_amount = get_post_meta($form_id, '_give_set_price', true); |
|
| 106 | 106 | |
| 107 | 107 | } |
| 108 | 108 | |
@@ -123,13 +123,13 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @return bool |
| 125 | 125 | */ |
| 126 | -function give_is_custom_price_mode( $form_id = 0 ) { |
|
| 126 | +function give_is_custom_price_mode($form_id = 0) { |
|
| 127 | 127 | |
| 128 | - if ( empty( $form_id ) ) { |
|
| 128 | + if (empty($form_id)) { |
|
| 129 | 129 | return false; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - $form = new Give_Donate_Form( $form_id ); |
|
| 132 | + $form = new Give_Donate_Form($form_id); |
|
| 133 | 133 | |
| 134 | 134 | return $form->is_custom_price_mode(); |
| 135 | 135 | } |
| 136 | 136 | \ No newline at end of file |