@@ -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 | |
@@ -41,20 +41,20 @@ discard block |
||
| 41 | 41 | public function csv_cols() { |
| 42 | 42 | |
| 43 | 43 | $cols = array( |
| 44 | - 'ID' => __( 'ID', 'give' ), |
|
| 45 | - 'post_name' => __( 'Slug', 'give' ), |
|
| 46 | - 'post_title' => __( 'Name', 'give' ), |
|
| 47 | - 'post_date' => __( 'Date Created', 'give' ), |
|
| 48 | - 'post_author' => __( 'Author', 'give' ), |
|
| 49 | - 'post_content' => __( 'Description', 'give' ), |
|
| 50 | - 'post_excerpt' => __( 'Excerpt', 'give' ), |
|
| 51 | - 'post_status' => __( 'Status', 'give' ), |
|
| 52 | - 'categories' => __( 'Categories', 'give' ), |
|
| 53 | - 'tags' => __( 'Tags', 'give' ), |
|
| 54 | - 'give_price' => __( 'Price', 'give' ), |
|
| 55 | - '_thumbnail_id' => __( 'Featured Image', 'give' ), |
|
| 56 | - '_give_form_sales' => __( 'Donations', 'give' ), |
|
| 57 | - '_give_download_earnings' => __( 'Income', 'give' ), |
|
| 44 | + 'ID' => __('ID', 'give'), |
|
| 45 | + 'post_name' => __('Slug', 'give'), |
|
| 46 | + 'post_title' => __('Name', 'give'), |
|
| 47 | + 'post_date' => __('Date Created', 'give'), |
|
| 48 | + 'post_author' => __('Author', 'give'), |
|
| 49 | + 'post_content' => __('Description', 'give'), |
|
| 50 | + 'post_excerpt' => __('Excerpt', 'give'), |
|
| 51 | + 'post_status' => __('Status', 'give'), |
|
| 52 | + 'categories' => __('Categories', 'give'), |
|
| 53 | + 'tags' => __('Tags', 'give'), |
|
| 54 | + 'give_price' => __('Price', 'give'), |
|
| 55 | + '_thumbnail_id' => __('Featured Image', 'give'), |
|
| 56 | + '_give_form_sales' => __('Donations', 'give'), |
|
| 57 | + '_give_download_earnings' => __('Income', 'give'), |
|
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | 60 | return $cols; |
@@ -86,43 +86,43 @@ discard block |
||
| 86 | 86 | 'paged' => $this->step |
| 87 | 87 | ); |
| 88 | 88 | |
| 89 | - $downloads = new WP_Query( $args ); |
|
| 89 | + $downloads = new WP_Query($args); |
|
| 90 | 90 | |
| 91 | - if ( $downloads->posts ) { |
|
| 92 | - foreach ( $downloads->posts as $download ) { |
|
| 91 | + if ($downloads->posts) { |
|
| 92 | + foreach ($downloads->posts as $download) { |
|
| 93 | 93 | |
| 94 | 94 | $row = array(); |
| 95 | 95 | |
| 96 | - foreach ( $this->csv_cols() as $key => $value ) { |
|
| 96 | + foreach ($this->csv_cols() as $key => $value) { |
|
| 97 | 97 | |
| 98 | 98 | // Setup default value |
| 99 | - $row[ $key ] = ''; |
|
| 99 | + $row[$key] = ''; |
|
| 100 | 100 | |
| 101 | - if ( in_array( $key, $meta ) ) { |
|
| 101 | + if (in_array($key, $meta)) { |
|
| 102 | 102 | |
| 103 | - switch ( $key ) { |
|
| 103 | + switch ($key) { |
|
| 104 | 104 | |
| 105 | 105 | case '_thumbnail_id' : |
| 106 | 106 | |
| 107 | - $image_id = get_post_thumbnail_id( $download->ID ); |
|
| 108 | - $row[ $key ] = wp_get_attachment_url( $image_id ); |
|
| 107 | + $image_id = get_post_thumbnail_id($download->ID); |
|
| 108 | + $row[$key] = wp_get_attachment_url($image_id); |
|
| 109 | 109 | |
| 110 | 110 | break; |
| 111 | 111 | |
| 112 | 112 | case 'give_price' : |
| 113 | 113 | |
| 114 | - if ( give_has_variable_prices( $download->ID ) ) { |
|
| 114 | + if (give_has_variable_prices($download->ID)) { |
|
| 115 | 115 | |
| 116 | 116 | $prices = array(); |
| 117 | - foreach ( give_get_variable_prices( $download->ID ) as $price ) { |
|
| 118 | - $prices[] = $price['name'] . ': ' . $price['amount']; |
|
| 117 | + foreach (give_get_variable_prices($download->ID) as $price) { |
|
| 118 | + $prices[] = $price['name'].': '.$price['amount']; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - $row[ $key ] = implode( ' | ', $prices ); |
|
| 121 | + $row[$key] = implode(' | ', $prices); |
|
| 122 | 122 | |
| 123 | 123 | } else { |
| 124 | 124 | |
| 125 | - $row[ $key ] = give_get_download_price( $download->ID ); |
|
| 125 | + $row[$key] = give_get_download_price($download->ID); |
|
| 126 | 126 | |
| 127 | 127 | } |
| 128 | 128 | |
@@ -132,54 +132,54 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | |
| 134 | 134 | $files = array(); |
| 135 | - foreach ( give_get_download_files( $download->ID ) as $file ) { |
|
| 135 | + foreach (give_get_download_files($download->ID) as $file) { |
|
| 136 | 136 | $files[] = $file['file']; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - $row[ $key ] = implode( ' | ', $files ); |
|
| 139 | + $row[$key] = implode(' | ', $files); |
|
| 140 | 140 | |
| 141 | 141 | break; |
| 142 | 142 | |
| 143 | 143 | default : |
| 144 | 144 | |
| 145 | - $row[ $key ] = get_post_meta( $download->ID, $key, true ); |
|
| 145 | + $row[$key] = get_post_meta($download->ID, $key, true); |
|
| 146 | 146 | |
| 147 | 147 | break; |
| 148 | 148 | |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - } elseif ( isset( $download->$key ) ) { |
|
| 151 | + } elseif (isset($download->$key)) { |
|
| 152 | 152 | |
| 153 | - switch ( $key ) { |
|
| 153 | + switch ($key) { |
|
| 154 | 154 | |
| 155 | 155 | case 'post_author' : |
| 156 | 156 | |
| 157 | - $row[ $key ] = get_the_author_meta( 'user_login', $download->post_author ); |
|
| 157 | + $row[$key] = get_the_author_meta('user_login', $download->post_author); |
|
| 158 | 158 | |
| 159 | 159 | break; |
| 160 | 160 | |
| 161 | 161 | default : |
| 162 | 162 | |
| 163 | - $row[ $key ] = $download->$key; |
|
| 163 | + $row[$key] = $download->$key; |
|
| 164 | 164 | |
| 165 | 165 | break; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - } elseif ( 'tags' == $key ) { |
|
| 168 | + } elseif ('tags' == $key) { |
|
| 169 | 169 | |
| 170 | - $terms = get_the_terms( $download->ID, 'download_tag' ); |
|
| 171 | - if ( $terms ) { |
|
| 172 | - $terms = wp_list_pluck( $terms, 'name' ); |
|
| 173 | - $row[ $key ] = implode( ' | ', $terms ); |
|
| 170 | + $terms = get_the_terms($download->ID, 'download_tag'); |
|
| 171 | + if ($terms) { |
|
| 172 | + $terms = wp_list_pluck($terms, 'name'); |
|
| 173 | + $row[$key] = implode(' | ', $terms); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | |
| 177 | - } elseif ( 'categories' == $key ) { |
|
| 177 | + } elseif ('categories' == $key) { |
|
| 178 | 178 | |
| 179 | - $terms = get_the_terms( $download->ID, 'download_category' ); |
|
| 180 | - if ( $terms ) { |
|
| 181 | - $terms = wp_list_pluck( $terms, 'name' ); |
|
| 182 | - $row[ $key ] = implode( ' | ', $terms ); |
|
| 179 | + $terms = get_the_terms($download->ID, 'download_category'); |
|
| 180 | + if ($terms) { |
|
| 181 | + $terms = wp_list_pluck($terms, 'name'); |
|
| 182 | + $row[$key] = implode(' | ', $terms); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | } |
@@ -190,8 +190,8 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
| 194 | - $data = apply_filters( 'give_export_get_data_' . $this->export_type, $data ); |
|
| 193 | + $data = apply_filters('give_export_get_data', $data); |
|
| 194 | + $data = apply_filters('give_export_get_data_'.$this->export_type, $data); |
|
| 195 | 195 | |
| 196 | 196 | return $data; |
| 197 | 197 | } |
@@ -210,20 +210,20 @@ discard block |
||
| 210 | 210 | |
| 211 | 211 | $args = array( |
| 212 | 212 | 'post_type' => 'give_forms', |
| 213 | - 'posts_per_page' => - 1, |
|
| 213 | + 'posts_per_page' => -1, |
|
| 214 | 214 | 'post_status' => 'any', |
| 215 | 215 | 'fields' => 'ids', |
| 216 | 216 | ); |
| 217 | 217 | |
| 218 | - $downloads = new WP_Query( $args ); |
|
| 218 | + $downloads = new WP_Query($args); |
|
| 219 | 219 | $total = (int) $downloads->post_count; |
| 220 | 220 | $percentage = 100; |
| 221 | 221 | |
| 222 | - if ( $total > 0 ) { |
|
| 223 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
| 222 | + if ($total > 0) { |
|
| 223 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - if ( $percentage > 100 ) { |
|
| 226 | + if ($percentage > 100) { |
|
| 227 | 227 | $percentage = 100; |
| 228 | 228 | } |
| 229 | 229 | |
@@ -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 | |
@@ -39,29 +39,29 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function csv_cols() { |
| 41 | 41 | $cols = array( |
| 42 | - 'id' => __( 'ID', 'give' ), // unaltered payment ID (use for querying) |
|
| 43 | - 'seq_id' => __( 'Payment Number', 'give' ), // sequential payment ID |
|
| 44 | - 'email' => __( 'Email', 'give' ), |
|
| 45 | - 'first' => __( 'First Name', 'give' ), |
|
| 46 | - 'last' => __( 'Last Name', 'give' ), |
|
| 47 | - 'address1' => __( 'Address', 'give' ), |
|
| 48 | - 'address2' => __( 'Address (Line 2)', 'give' ), |
|
| 49 | - 'city' => __( 'City', 'give' ), |
|
| 50 | - 'state' => __( 'State', 'give' ), |
|
| 51 | - 'country' => __( 'Country', 'give' ), |
|
| 52 | - 'zip' => __( 'Zip / Postal Code', 'give' ), |
|
| 53 | - 'products' => __( 'Products', 'give' ), |
|
| 54 | - 'amount' => __( 'Amount', 'give' ) . ' (' . html_entity_decode( give_currency_filter( '' ) ) . ')', |
|
| 55 | - 'gateway' => __( 'Payment Method', 'give' ), |
|
| 56 | - 'trans_id' => __( 'Transaction ID', 'give' ), |
|
| 57 | - 'key' => __( 'Purchase Key', 'give' ), |
|
| 58 | - 'date' => __( 'Date', 'give' ), |
|
| 59 | - 'user' => __( 'User', 'give' ), |
|
| 60 | - 'status' => __( 'Status', 'give' ) |
|
| 42 | + 'id' => __('ID', 'give'), // unaltered payment ID (use for querying) |
|
| 43 | + 'seq_id' => __('Payment Number', 'give'), // sequential payment ID |
|
| 44 | + 'email' => __('Email', 'give'), |
|
| 45 | + 'first' => __('First Name', 'give'), |
|
| 46 | + 'last' => __('Last Name', 'give'), |
|
| 47 | + 'address1' => __('Address', 'give'), |
|
| 48 | + 'address2' => __('Address (Line 2)', 'give'), |
|
| 49 | + 'city' => __('City', 'give'), |
|
| 50 | + 'state' => __('State', 'give'), |
|
| 51 | + 'country' => __('Country', 'give'), |
|
| 52 | + 'zip' => __('Zip / Postal Code', 'give'), |
|
| 53 | + 'products' => __('Products', 'give'), |
|
| 54 | + 'amount' => __('Amount', 'give').' ('.html_entity_decode(give_currency_filter('')).')', |
|
| 55 | + 'gateway' => __('Payment Method', 'give'), |
|
| 56 | + 'trans_id' => __('Transaction ID', 'give'), |
|
| 57 | + 'key' => __('Purchase Key', 'give'), |
|
| 58 | + 'date' => __('Date', 'give'), |
|
| 59 | + 'user' => __('User', 'give'), |
|
| 60 | + 'status' => __('Status', 'give') |
|
| 61 | 61 | ); |
| 62 | 62 | |
| 63 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
| 64 | - unset( $cols['seq_id'] ); |
|
| 63 | + if ( ! give_get_option('enable_sequential')) { |
|
| 64 | + unset($cols['seq_id']); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | return $cols; |
@@ -87,12 +87,12 @@ discard block |
||
| 87 | 87 | 'status' => $this->status |
| 88 | 88 | ); |
| 89 | 89 | |
| 90 | - if ( ! empty( $this->start ) || ! empty( $this->end ) ) { |
|
| 90 | + if ( ! empty($this->start) || ! empty($this->end)) { |
|
| 91 | 91 | |
| 92 | 92 | $args['date_query'] = array( |
| 93 | 93 | array( |
| 94 | - 'after' => date( 'Y-n-d 00:00:00', strtotime( $this->start ) ), |
|
| 95 | - 'before' => date( 'Y-n-d 23:59:59', strtotime( $this->end ) ), |
|
| 94 | + 'after' => date('Y-n-d 00:00:00', strtotime($this->start)), |
|
| 95 | + 'before' => date('Y-n-d 23:59:59', strtotime($this->end)), |
|
| 96 | 96 | 'inclusive' => true |
| 97 | 97 | ) |
| 98 | 98 | ); |
@@ -101,104 +101,104 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | //echo json_encode($args ); exit; |
| 103 | 103 | |
| 104 | - $payments = give_get_payments( $args ); |
|
| 104 | + $payments = give_get_payments($args); |
|
| 105 | 105 | |
| 106 | - if ( $payments ) { |
|
| 106 | + if ($payments) { |
|
| 107 | 107 | |
| 108 | - foreach ( $payments as $payment ) { |
|
| 109 | - $payment_meta = give_get_payment_meta( $payment->ID ); |
|
| 110 | - $user_info = give_get_payment_meta_user_info( $payment->ID ); |
|
| 111 | - $total = give_get_payment_amount( $payment->ID ); |
|
| 112 | - $user_id = isset( $user_info['id'] ) && $user_info['id'] != - 1 ? $user_info['id'] : $user_info['email']; |
|
| 108 | + foreach ($payments as $payment) { |
|
| 109 | + $payment_meta = give_get_payment_meta($payment->ID); |
|
| 110 | + $user_info = give_get_payment_meta_user_info($payment->ID); |
|
| 111 | + $total = give_get_payment_amount($payment->ID); |
|
| 112 | + $user_id = isset($user_info['id']) && $user_info['id'] != - 1 ? $user_info['id'] : $user_info['email']; |
|
| 113 | 113 | $products = ''; |
| 114 | 114 | $skus = ''; |
| 115 | 115 | |
| 116 | - if ( $downloads ) { |
|
| 117 | - foreach ( $downloads as $key => $download ) { |
|
| 116 | + if ($downloads) { |
|
| 117 | + foreach ($downloads as $key => $download) { |
|
| 118 | 118 | |
| 119 | 119 | // Form ID |
| 120 | - $id = isset( $payment_meta['cart_details'] ) ? $download['id'] : $download; |
|
| 121 | - $qty = isset( $download['quantity'] ) ? $download['quantity'] : 1; |
|
| 120 | + $id = isset($payment_meta['cart_details']) ? $download['id'] : $download; |
|
| 121 | + $qty = isset($download['quantity']) ? $download['quantity'] : 1; |
|
| 122 | 122 | |
| 123 | - if ( isset( $download['price'] ) ) { |
|
| 123 | + if (isset($download['price'])) { |
|
| 124 | 124 | $price = $download['price']; |
| 125 | 125 | } else { |
| 126 | 126 | // If the download has variable prices, override the default price |
| 127 | - $price_override = isset( $payment_meta['cart_details'] ) ? $download['price'] : null; |
|
| 128 | - $price = give_get_download_final_price( $id, $user_info, $price_override ); |
|
| 127 | + $price_override = isset($payment_meta['cart_details']) ? $download['price'] : null; |
|
| 128 | + $price = give_get_download_final_price($id, $user_info, $price_override); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | |
| 132 | 132 | // Display the Downoad Name |
| 133 | - $products .= html_entity_decode( get_the_title( $id ) ); |
|
| 133 | + $products .= html_entity_decode(get_the_title($id)); |
|
| 134 | 134 | |
| 135 | - if ( $qty > 1 ) { |
|
| 136 | - $products .= html_entity_decode( ' (' . $qty . ')' ); |
|
| 135 | + if ($qty > 1) { |
|
| 136 | + $products .= html_entity_decode(' ('.$qty.')'); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | $products .= ' - '; |
| 140 | 140 | |
| 141 | - if ( give_use_skus() ) { |
|
| 142 | - $sku = give_get_download_sku( $id ); |
|
| 141 | + if (give_use_skus()) { |
|
| 142 | + $sku = give_get_download_sku($id); |
|
| 143 | 143 | |
| 144 | - if ( ! empty( $sku ) ) { |
|
| 144 | + if ( ! empty($sku)) { |
|
| 145 | 145 | $skus .= $sku; |
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - if ( isset( $downloads[ $key ]['item_number'] ) && isset( $downloads[ $key ]['item_number']['options'] ) ) { |
|
| 150 | - $price_options = $downloads[ $key ]['item_number']['options']; |
|
| 149 | + if (isset($downloads[$key]['item_number']) && isset($downloads[$key]['item_number']['options'])) { |
|
| 150 | + $price_options = $downloads[$key]['item_number']['options']; |
|
| 151 | 151 | |
| 152 | - if ( isset( $price_options['price_id'] ) ) { |
|
| 153 | - $products .= html_entity_decode( give_get_price_option_name( $id, $price_options['price_id'], $payment->ID ) ) . ' - '; |
|
| 152 | + if (isset($price_options['price_id'])) { |
|
| 153 | + $products .= html_entity_decode(give_get_price_option_name($id, $price_options['price_id'], $payment->ID)).' - '; |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - $products .= html_entity_decode( give_currency_filter( give_format_amount( $price ) ) ); |
|
| 157 | + $products .= html_entity_decode(give_currency_filter(give_format_amount($price))); |
|
| 158 | 158 | |
| 159 | - if ( $key != ( count( $downloads ) - 1 ) ) { |
|
| 159 | + if ($key != (count($downloads) - 1)) { |
|
| 160 | 160 | $products .= ' / '; |
| 161 | 161 | |
| 162 | - if ( give_use_skus() ) { |
|
| 162 | + if (give_use_skus()) { |
|
| 163 | 163 | $skus .= ' / '; |
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if ( is_numeric( $user_id ) ) { |
|
| 170 | - $user = get_userdata( $user_id ); |
|
| 169 | + if (is_numeric($user_id)) { |
|
| 170 | + $user = get_userdata($user_id); |
|
| 171 | 171 | } else { |
| 172 | 172 | $user = false; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | $data[] = array( |
| 176 | 176 | 'id' => $payment->ID, |
| 177 | - 'seq_id' => give_get_payment_number( $payment->ID ), |
|
| 177 | + 'seq_id' => give_get_payment_number($payment->ID), |
|
| 178 | 178 | 'email' => $payment_meta['email'], |
| 179 | 179 | 'first' => $user_info['first_name'], |
| 180 | 180 | 'last' => $user_info['last_name'], |
| 181 | - 'address1' => isset( $user_info['address']['line1'] ) ? $user_info['address']['line1'] : '', |
|
| 182 | - 'address2' => isset( $user_info['address']['line2'] ) ? $user_info['address']['line2'] : '', |
|
| 183 | - 'city' => isset( $user_info['address']['city'] ) ? $user_info['address']['city'] : '', |
|
| 184 | - 'state' => isset( $user_info['address']['state'] ) ? $user_info['address']['state'] : '', |
|
| 185 | - 'country' => isset( $user_info['address']['country'] ) ? $user_info['address']['country'] : '', |
|
| 186 | - 'zip' => isset( $user_info['address']['zip'] ) ? $user_info['address']['zip'] : '', |
|
| 181 | + 'address1' => isset($user_info['address']['line1']) ? $user_info['address']['line1'] : '', |
|
| 182 | + 'address2' => isset($user_info['address']['line2']) ? $user_info['address']['line2'] : '', |
|
| 183 | + 'city' => isset($user_info['address']['city']) ? $user_info['address']['city'] : '', |
|
| 184 | + 'state' => isset($user_info['address']['state']) ? $user_info['address']['state'] : '', |
|
| 185 | + 'country' => isset($user_info['address']['country']) ? $user_info['address']['country'] : '', |
|
| 186 | + 'zip' => isset($user_info['address']['zip']) ? $user_info['address']['zip'] : '', |
|
| 187 | 187 | 'products' => $products, |
| 188 | 188 | 'skus' => $skus, |
| 189 | - 'amount' => html_entity_decode( give_format_amount( $total ) ), |
|
| 190 | - 'gateway' => give_get_gateway_admin_label( get_post_meta( $payment->ID, '_give_payment_gateway', true ) ), |
|
| 191 | - 'trans_id' => give_get_payment_transaction_id( $payment->ID ), |
|
| 189 | + 'amount' => html_entity_decode(give_format_amount($total)), |
|
| 190 | + 'gateway' => give_get_gateway_admin_label(get_post_meta($payment->ID, '_give_payment_gateway', true)), |
|
| 191 | + 'trans_id' => give_get_payment_transaction_id($payment->ID), |
|
| 192 | 192 | 'key' => $payment_meta['key'], |
| 193 | 193 | 'date' => $payment->post_date, |
| 194 | - 'user' => $user ? $user->display_name : __( 'guest', 'give' ), |
|
| 195 | - 'status' => give_get_payment_status( $payment, true ) |
|
| 194 | + 'user' => $user ? $user->display_name : __('guest', 'give'), |
|
| 195 | + 'status' => give_get_payment_status($payment, true) |
|
| 196 | 196 | ); |
| 197 | 197 | |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
| 201 | - $data = apply_filters( 'give_export_get_data_' . $this->export_type, $data ); |
|
| 200 | + $data = apply_filters('give_export_get_data', $data); |
|
| 201 | + $data = apply_filters('give_export_get_data_'.$this->export_type, $data); |
|
| 202 | 202 | |
| 203 | 203 | return $data; |
| 204 | 204 | |
@@ -218,27 +218,27 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | $status = $this->status; |
| 220 | 220 | $args = array( |
| 221 | - 'start-date' => date( 'n/d/Y', strtotime( $this->start ) ), |
|
| 222 | - 'end-date' => date( 'n/d/Y', strtotime( $this->end ) ), |
|
| 221 | + 'start-date' => date('n/d/Y', strtotime($this->start)), |
|
| 222 | + 'end-date' => date('n/d/Y', strtotime($this->end)), |
|
| 223 | 223 | ); |
| 224 | 224 | |
| 225 | - if ( 'any' == $status ) { |
|
| 225 | + if ('any' == $status) { |
|
| 226 | 226 | |
| 227 | - $total = array_sum( (array) give_count_payments( $args ) ); |
|
| 227 | + $total = array_sum((array) give_count_payments($args)); |
|
| 228 | 228 | |
| 229 | 229 | } else { |
| 230 | 230 | |
| 231 | - $total = give_count_payments( $args )->$status; |
|
| 231 | + $total = give_count_payments($args)->$status; |
|
| 232 | 232 | |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | $percentage = 100; |
| 236 | 236 | |
| 237 | - if ( $total > 0 ) { |
|
| 238 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
| 237 | + if ($total > 0) { |
|
| 238 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - if ( $percentage > 100 ) { |
|
| 241 | + if ($percentage > 100) { |
|
| 242 | 242 | $percentage = 100; |
| 243 | 243 | } |
| 244 | 244 | |
@@ -252,9 +252,9 @@ discard block |
||
| 252 | 252 | * |
| 253 | 253 | * @param array $request The Form Data passed into the batch processing |
| 254 | 254 | */ |
| 255 | - public function set_properties( $request ) { |
|
| 256 | - $this->start = isset( $request['start'] ) ? sanitize_text_field( $request['start'] ) : ''; |
|
| 257 | - $this->end = isset( $request['end'] ) ? sanitize_text_field( $request['end'] ) : ''; |
|
| 258 | - $this->status = isset( $request['status'] ) ? sanitize_text_field( $request['status'] ) : 'complete'; |
|
| 255 | + public function set_properties($request) { |
|
| 256 | + $this->start = isset($request['start']) ? sanitize_text_field($request['start']) : ''; |
|
| 257 | + $this->end = isset($request['end']) ? sanitize_text_field($request['end']) : ''; |
|
| 258 | + $this->status = isset($request['status']) ? sanitize_text_field($request['status']) : 'complete'; |
|
| 259 | 259 | } |
| 260 | 260 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly |
| 15 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 15 | +if ( ! defined('ABSPATH')) exit; |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Give_Batch_Export Class |
@@ -104,14 +104,14 @@ discard block |
||
| 104 | 104 | * @param $_step int The step to process |
| 105 | 105 | * @since 1.5 |
| 106 | 106 | */ |
| 107 | - public function __construct( $_step = 1 ) { |
|
| 107 | + public function __construct($_step = 1) { |
|
| 108 | 108 | |
| 109 | 109 | $upload_dir = wp_upload_dir(); |
| 110 | 110 | $this->filetype = '.csv'; |
| 111 | - $this->filename = 'give-' . $this->export_type . $this->filetype; |
|
| 112 | - $this->file = trailingslashit( $upload_dir['basedir'] ) . $this->filename; |
|
| 111 | + $this->filename = 'give-'.$this->export_type.$this->filetype; |
|
| 112 | + $this->file = trailingslashit($upload_dir['basedir']).$this->filename; |
|
| 113 | 113 | |
| 114 | - if ( ! is_writeable( $upload_dir['basedir'] ) ) { |
|
| 114 | + if ( ! is_writeable($upload_dir['basedir'])) { |
|
| 115 | 115 | $this->is_writable = false; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -127,20 +127,20 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function process_step() { |
| 129 | 129 | |
| 130 | - if ( ! $this->can_export() ) { |
|
| 131 | - wp_die( __( 'You do not have permission to export data.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 130 | + if ( ! $this->can_export()) { |
|
| 131 | + wp_die(__('You do not have permission to export data.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - if( $this->step < 2 ) { |
|
| 134 | + if ($this->step < 2) { |
|
| 135 | 135 | |
| 136 | 136 | // Make sure we start with a fresh file on step 1 |
| 137 | - @unlink( $this->file ); |
|
| 137 | + @unlink($this->file); |
|
| 138 | 138 | $this->print_csv_cols(); |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $rows = $this->print_csv_rows(); |
| 142 | 142 | |
| 143 | - if( $rows ) { |
|
| 143 | + if ($rows) { |
|
| 144 | 144 | return true; |
| 145 | 145 | } else { |
| 146 | 146 | return false; |
@@ -160,14 +160,14 @@ discard block |
||
| 160 | 160 | $col_data = ''; |
| 161 | 161 | $cols = $this->get_csv_cols(); |
| 162 | 162 | $i = 1; |
| 163 | - foreach( $cols as $col_id => $column ) { |
|
| 164 | - $col_data .= '"' . addslashes( $column ) . '"'; |
|
| 165 | - $col_data .= $i == count( $cols ) ? '' : ','; |
|
| 163 | + foreach ($cols as $col_id => $column) { |
|
| 164 | + $col_data .= '"'.addslashes($column).'"'; |
|
| 165 | + $col_data .= $i == count($cols) ? '' : ','; |
|
| 166 | 166 | $i++; |
| 167 | 167 | } |
| 168 | 168 | $col_data .= "\r\n"; |
| 169 | 169 | |
| 170 | - $this->stash_step_data( $col_data ); |
|
| 170 | + $this->stash_step_data($col_data); |
|
| 171 | 171 | |
| 172 | 172 | return $col_data; |
| 173 | 173 | |
@@ -186,23 +186,23 @@ discard block |
||
| 186 | 186 | $data = $this->get_data(); |
| 187 | 187 | $cols = $this->get_csv_cols(); |
| 188 | 188 | |
| 189 | - if( $data ) { |
|
| 189 | + if ($data) { |
|
| 190 | 190 | |
| 191 | 191 | // Output each row |
| 192 | - foreach ( $data as $row ) { |
|
| 192 | + foreach ($data as $row) { |
|
| 193 | 193 | $i = 1; |
| 194 | - foreach ( $row as $col_id => $column ) { |
|
| 194 | + foreach ($row as $col_id => $column) { |
|
| 195 | 195 | // Make sure the column is valid |
| 196 | - if ( array_key_exists( $col_id, $cols ) ) { |
|
| 197 | - $row_data .= '"' . addslashes( preg_replace( "/\"/","'", $column ) ) . '"'; |
|
| 198 | - $row_data .= $i == count( $cols ) ? '' : ','; |
|
| 196 | + if (array_key_exists($col_id, $cols)) { |
|
| 197 | + $row_data .= '"'.addslashes(preg_replace("/\"/", "'", $column)).'"'; |
|
| 198 | + $row_data .= $i == count($cols) ? '' : ','; |
|
| 199 | 199 | $i++; |
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | $row_data .= "\r\n"; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - $this->stash_step_data( $row_data ); |
|
| 205 | + $this->stash_step_data($row_data); |
|
| 206 | 206 | |
| 207 | 207 | return $row_data; |
| 208 | 208 | } |
@@ -230,18 +230,18 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | $file = ''; |
| 232 | 232 | |
| 233 | - if ( @file_exists( $this->file ) ) { |
|
| 233 | + if (@file_exists($this->file)) { |
|
| 234 | 234 | |
| 235 | - if ( ! is_writeable( $this->file ) ) { |
|
| 235 | + if ( ! is_writeable($this->file)) { |
|
| 236 | 236 | $this->is_writable = false; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - $file = @file_get_contents( $this->file ); |
|
| 239 | + $file = @file_get_contents($this->file); |
|
| 240 | 240 | |
| 241 | 241 | } else { |
| 242 | 242 | |
| 243 | - @file_put_contents( $this->file, '' ); |
|
| 244 | - @chmod( $this->file, 0664 ); |
|
| 243 | + @file_put_contents($this->file, ''); |
|
| 244 | + @chmod($this->file, 0664); |
|
| 245 | 245 | |
| 246 | 246 | } |
| 247 | 247 | |
@@ -255,18 +255,18 @@ discard block |
||
| 255 | 255 | * @param $data string The data to add to the file |
| 256 | 256 | * @return void |
| 257 | 257 | */ |
| 258 | - protected function stash_step_data( $data = '' ) { |
|
| 258 | + protected function stash_step_data($data = '') { |
|
| 259 | 259 | |
| 260 | 260 | $file = $this->get_file(); |
| 261 | 261 | $file .= $data; |
| 262 | - @file_put_contents( $this->file, $file ); |
|
| 262 | + @file_put_contents($this->file, $file); |
|
| 263 | 263 | |
| 264 | 264 | // If we have no rows after this step, mark it as an empty export |
| 265 | - $file_rows = file( $this->file, FILE_SKIP_EMPTY_LINES); |
|
| 265 | + $file_rows = file($this->file, FILE_SKIP_EMPTY_LINES); |
|
| 266 | 266 | $default_cols = $this->get_csv_cols(); |
| 267 | - $default_cols = empty( $default_cols ) ? 0 : 1; |
|
| 267 | + $default_cols = empty($default_cols) ? 0 : 1; |
|
| 268 | 268 | |
| 269 | - $this->is_empty = count( $file_rows ) == $default_cols ? true : false; |
|
| 269 | + $this->is_empty = count($file_rows) == $default_cols ? true : false; |
|
| 270 | 270 | |
| 271 | 271 | } |
| 272 | 272 | |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | |
| 285 | 285 | $file = $this->get_file(); |
| 286 | 286 | |
| 287 | - @unlink( $this->file ); |
|
| 287 | + @unlink($this->file); |
|
| 288 | 288 | |
| 289 | 289 | echo $file; |
| 290 | 290 | |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | * @since 1.5 |
| 298 | 298 | * @param array $request The Form Data passed into the batch processing |
| 299 | 299 | */ |
| 300 | - public function set_properties( $request ) {} |
|
| 300 | + public function set_properties($request) {} |
|
| 301 | 301 | |
| 302 | 302 | /** |
| 303 | 303 | * Allow for prefetching of data for the remainder of the exporter |
@@ -10,7 +10,9 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 13 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | + exit; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | /** |
| 16 | 18 | * Give_API_V1 Class |
@@ -11,12 +11,12 @@ 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 | |
| 18 | -require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export.php'; |
|
| 19 | -require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/export-actions.php'; |
|
| 18 | +require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export.php'; |
|
| 19 | +require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/export-actions.php'; |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Process batch exports via ajax |
@@ -26,79 +26,79 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | function give_do_ajax_export() { |
| 28 | 28 | |
| 29 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php'; |
|
| 29 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export.php'; |
|
| 30 | 30 | |
| 31 | - parse_str( $_POST['form'], $form ); |
|
| 31 | + parse_str($_POST['form'], $form); |
|
| 32 | 32 | |
| 33 | 33 | $_REQUEST = $form = (array) $form; |
| 34 | 34 | |
| 35 | - if ( ! wp_verify_nonce( $_REQUEST['give_ajax_export'], 'give_ajax_export' ) ) { |
|
| 36 | - die( '-2' ); |
|
| 35 | + if ( ! wp_verify_nonce($_REQUEST['give_ajax_export'], 'give_ajax_export')) { |
|
| 36 | + die('-2'); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - do_action( 'give_batch_export_class_include', $form['give-export-class'] ); |
|
| 39 | + do_action('give_batch_export_class_include', $form['give-export-class']); |
|
| 40 | 40 | |
| 41 | - $step = absint( $_POST['step'] ); |
|
| 42 | - $class = sanitize_text_field( $form['give-export-class'] ); |
|
| 41 | + $step = absint($_POST['step']); |
|
| 42 | + $class = sanitize_text_field($form['give-export-class']); |
|
| 43 | 43 | |
| 44 | - $export = new $class( $step ); |
|
| 44 | + $export = new $class($step); |
|
| 45 | 45 | |
| 46 | - if ( ! $export->can_export() ) { |
|
| 47 | - die( '-1' ); |
|
| 46 | + if ( ! $export->can_export()) { |
|
| 47 | + die('-1'); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if ( ! $export->is_writable ) { |
|
| 50 | + if ( ! $export->is_writable) { |
|
| 51 | 51 | $json_args = array( |
| 52 | 52 | 'error' => true, |
| 53 | - 'message' => __( 'Export location or file not writable', 'give' ) |
|
| 53 | + 'message' => __('Export location or file not writable', 'give') |
|
| 54 | 54 | ); |
| 55 | 55 | echo json_encode($json_args); |
| 56 | 56 | exit; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - $export->set_properties( $_REQUEST ); |
|
| 59 | + $export->set_properties($_REQUEST); |
|
| 60 | 60 | |
| 61 | 61 | $export->pre_fetch(); |
| 62 | 62 | |
| 63 | - $ret = $export->process_step( $step ); |
|
| 63 | + $ret = $export->process_step($step); |
|
| 64 | 64 | |
| 65 | 65 | $percentage = $export->get_percentage_complete(); |
| 66 | 66 | |
| 67 | - if ( $ret ) { |
|
| 67 | + if ($ret) { |
|
| 68 | 68 | |
| 69 | 69 | $step += 1; |
| 70 | - echo json_encode( array( 'step' => $step, 'percentage' => $percentage ) ); |
|
| 70 | + echo json_encode(array('step' => $step, 'percentage' => $percentage)); |
|
| 71 | 71 | exit; |
| 72 | 72 | |
| 73 | - } elseif ( true === $export->is_empty ) { |
|
| 73 | + } elseif (true === $export->is_empty) { |
|
| 74 | 74 | |
| 75 | - echo json_encode( array( |
|
| 75 | + echo json_encode(array( |
|
| 76 | 76 | 'error' => true, |
| 77 | - 'message' => __( 'No data found for export parameters', 'give' ) |
|
| 78 | - ) ); |
|
| 77 | + 'message' => __('No data found for export parameters', 'give') |
|
| 78 | + )); |
|
| 79 | 79 | exit; |
| 80 | 80 | |
| 81 | - } elseif ( true === $export->done && true === $export->is_void ) { |
|
| 81 | + } elseif (true === $export->done && true === $export->is_void) { |
|
| 82 | 82 | |
| 83 | - $message = ! empty( $export->message ) ? $export->message : __( 'Batch Processing Complete', 'give' ); |
|
| 84 | - echo json_encode( array( 'success' => true, 'message' => $message ) ); |
|
| 83 | + $message = ! empty($export->message) ? $export->message : __('Batch Processing Complete', 'give'); |
|
| 84 | + echo json_encode(array('success' => true, 'message' => $message)); |
|
| 85 | 85 | exit; |
| 86 | 86 | |
| 87 | 87 | } else { |
| 88 | 88 | |
| 89 | - $args = array_merge( $_REQUEST, array( |
|
| 89 | + $args = array_merge($_REQUEST, array( |
|
| 90 | 90 | 'step' => $step, |
| 91 | 91 | 'class' => $class, |
| 92 | - 'nonce' => wp_create_nonce( 'give-batch-export' ), |
|
| 92 | + 'nonce' => wp_create_nonce('give-batch-export'), |
|
| 93 | 93 | 'give_action' => 'form_batch_export', |
| 94 | - ) ); |
|
| 94 | + )); |
|
| 95 | 95 | |
| 96 | - $download_url = add_query_arg( $args, admin_url() ); |
|
| 96 | + $download_url = add_query_arg($args, admin_url()); |
|
| 97 | 97 | |
| 98 | - echo json_encode( array( 'step' => 'done', 'url' => $download_url ) ); |
|
| 98 | + echo json_encode(array('step' => 'done', 'url' => $download_url)); |
|
| 99 | 99 | exit; |
| 100 | 100 | |
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | -add_action( 'wp_ajax_give_do_ajax_export', 'give_do_ajax_export' ); |
|
| 104 | +add_action('wp_ajax_give_do_ajax_export', 'give_do_ajax_export'); |
|
@@ -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 | |
@@ -22,68 +22,68 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | function give_tools_recount_stats_display() { |
| 24 | 24 | |
| 25 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 25 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 26 | 26 | return; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - do_action( 'give_tools_recount_stats_before' ); |
|
| 29 | + do_action('give_tools_recount_stats_before'); |
|
| 30 | 30 | ?> |
| 31 | 31 | <div id="poststuff"> |
| 32 | 32 | <div class="postbox"> |
| 33 | 33 | |
| 34 | - <h2 class="hndle ui-sortable-handle"><span><?php _e( 'Recount Stats', 'give' ); ?></span></h2> |
|
| 34 | + <h2 class="hndle ui-sortable-handle"><span><?php _e('Recount Stats', 'give'); ?></span></h2> |
|
| 35 | 35 | |
| 36 | 36 | <div class="inside recount-stats-controls"> |
| 37 | - <p><?php _e( 'Use these tools to recount stats, delete test transactions, or reset stats.', 'give' ); ?></p> |
|
| 37 | + <p><?php _e('Use these tools to recount stats, delete test transactions, or reset stats.', 'give'); ?></p> |
|
| 38 | 38 | <form method="post" id="give-tools-recount-form" class="give-export-form"> |
| 39 | 39 | |
| 40 | - <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?> |
|
| 40 | + <?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?> |
|
| 41 | 41 | |
| 42 | 42 | <select name="give-export-class" id="recount-stats-type"> |
| 43 | - <option value="0" selected="selected" disabled="disabled"><?php _e( 'Please select an option', 'give' ); ?></option> |
|
| 44 | - <option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php _e( 'Recalculate Total Donation Income Amount', 'give' ); ?></option> |
|
| 45 | - <option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php _e( 'Recalculate Income Amount and Donation Counts for a Form', 'give' ); ?></option> |
|
| 46 | - <option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php _e( 'Recalculate Income Amount and Donation Counts for All Forms', 'give' ); ?></option> |
|
| 47 | - <option data-type="recount-customer-stats" value="Give_Tools_Recount_Customer_Stats"><?php _e( 'Recalculate Donor Statistics', 'give' ); ?></option> |
|
| 48 | - <option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php _e( 'Delete Test Transactions', 'give' ); ?></option> |
|
| 49 | - <option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php _e( 'Delete All Data', 'give' ); ?></option> |
|
| 50 | - <?php do_action( 'give_recount_tool_options' ); ?> |
|
| 43 | + <option value="0" selected="selected" disabled="disabled"><?php _e('Please select an option', 'give'); ?></option> |
|
| 44 | + <option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php _e('Recalculate Total Donation Income Amount', 'give'); ?></option> |
|
| 45 | + <option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php _e('Recalculate Income Amount and Donation Counts for a Form', 'give'); ?></option> |
|
| 46 | + <option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php _e('Recalculate Income Amount and Donation Counts for All Forms', 'give'); ?></option> |
|
| 47 | + <option data-type="recount-customer-stats" value="Give_Tools_Recount_Customer_Stats"><?php _e('Recalculate Donor Statistics', 'give'); ?></option> |
|
| 48 | + <option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php _e('Delete Test Transactions', 'give'); ?></option> |
|
| 49 | + <option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php _e('Delete All Data', 'give'); ?></option> |
|
| 50 | + <?php do_action('give_recount_tool_options'); ?> |
|
| 51 | 51 | </select> |
| 52 | 52 | |
| 53 | 53 | <span id="tools-form-dropdown" style="display: none"> |
| 54 | 54 | <?php |
| 55 | 55 | $args = array( |
| 56 | 56 | 'name' => 'form_id', |
| 57 | - 'number' => - 1, |
|
| 57 | + 'number' => -1, |
|
| 58 | 58 | 'chosen' => true, |
| 59 | 59 | ); |
| 60 | - echo Give()->html->forms_dropdown( $args ); |
|
| 60 | + echo Give()->html->forms_dropdown($args); |
|
| 61 | 61 | ?> |
| 62 | 62 | </span> |
| 63 | 63 | |
| 64 | - <input type="submit" id="recount-stats-submit" value="<?php _e( 'Submit', 'give' ); ?>" class="button-secondary"/> |
|
| 64 | + <input type="submit" id="recount-stats-submit" value="<?php _e('Submit', 'give'); ?>" class="button-secondary"/> |
|
| 65 | 65 | |
| 66 | 66 | <br/> |
| 67 | 67 | |
| 68 | 68 | <span class="give-recount-stats-descriptions"> |
| 69 | - <span id="recount-stats"><?php _e( 'Recalculates the overall donation income amount.', 'give' ); ?></span> |
|
| 70 | - <span id="recount-form"><?php printf( __( 'Recalculates the donation and income stats for a specific %s.', 'give' ), give_get_forms_label_singular( true ) ); ?></span> |
|
| 71 | - <span id="recount-all"><?php printf( __( 'Recalculates the earnings and sales stats for all %s.', 'give' ), give_get_forms_label_plural( true ) ); ?></span> |
|
| 72 | - <span id="recount-customer-stats"><?php _e( 'Recalculates the lifetime value and donation counts for all donors.', 'give' ); ?></span> |
|
| 73 | - <?php do_action( 'give_recount_tool_descriptions' ); ?> |
|
| 74 | - <span id="delete-test-transactions"><?php _e( '<strong>Deletes</strong> all TEST payment records, donors, and related log entries.', 'give' ); ?></span> |
|
| 75 | - <span id="reset-stats"><?php _e( '<strong>Deletes</strong> ALL transaction records, donors, and related log entries regardless of test or live mode.', 'give' ); ?></span> |
|
| 69 | + <span id="recount-stats"><?php _e('Recalculates the overall donation income amount.', 'give'); ?></span> |
|
| 70 | + <span id="recount-form"><?php printf(__('Recalculates the donation and income stats for a specific %s.', 'give'), give_get_forms_label_singular(true)); ?></span> |
|
| 71 | + <span id="recount-all"><?php printf(__('Recalculates the earnings and sales stats for all %s.', 'give'), give_get_forms_label_plural(true)); ?></span> |
|
| 72 | + <span id="recount-customer-stats"><?php _e('Recalculates the lifetime value and donation counts for all donors.', 'give'); ?></span> |
|
| 73 | + <?php do_action('give_recount_tool_descriptions'); ?> |
|
| 74 | + <span id="delete-test-transactions"><?php _e('<strong>Deletes</strong> all TEST payment records, donors, and related log entries.', 'give'); ?></span> |
|
| 75 | + <span id="reset-stats"><?php _e('<strong>Deletes</strong> ALL transaction records, donors, and related log entries regardless of test or live mode.', 'give'); ?></span> |
|
| 76 | 76 | </span> |
| 77 | 77 | |
| 78 | 78 | <span class="spinner"></span> |
| 79 | 79 | |
| 80 | 80 | </form> |
| 81 | - <?php do_action( 'give_tools_recount_forms' ); ?> |
|
| 81 | + <?php do_action('give_tools_recount_forms'); ?> |
|
| 82 | 82 | </div><!-- .inside --> |
| 83 | 83 | </div><!-- .postbox --> |
| 84 | 84 | </div><!-- #poststuff --> |
| 85 | 85 | <?php |
| 86 | - do_action( 'give_tools_recount_stats_after' ); |
|
| 86 | + do_action('give_tools_recount_stats_after'); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | -add_action( 'give_reports_tab_tools', 'give_tools_recount_stats_display' ); |
|
| 89 | +add_action('give_reports_tab_tools', 'give_tools_recount_stats_display'); |
|
@@ -188,8 +188,8 @@ |
||
| 188 | 188 | |
| 189 | 189 | $payment_ids = implode( ',', $payment_ids ); |
| 190 | 190 | $customer->update( array( 'payment_ids' => $payment_ids, |
| 191 | - 'purchase_count' => $purchase_count, |
|
| 192 | - 'purchase_value' => $pending_total |
|
| 191 | + 'purchase_count' => $purchase_count, |
|
| 192 | + 'purchase_value' => $pending_total |
|
| 193 | 193 | ) ); |
| 194 | 194 | |
| 195 | 195 | $this->done = true; |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | * @since 1.5 |
| 51 | 51 | * @global object $wpdb Used to query the database using the WordPress |
| 52 | 52 | * Database API |
| 53 | - * @return array $data The data for the CSV file |
|
| 53 | + * @return boolean $data The data for the CSV file |
|
| 54 | 54 | */ |
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $wpdb; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -54,39 +54,39 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function get_data() { |
| 56 | 56 | |
| 57 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 58 | - $payments = $this->get_stored_data( 'give_recount_customer_payments_' . $customer->id, array() ); |
|
| 57 | + $customer = new Give_Customer($this->customer_id); |
|
| 58 | + $payments = $this->get_stored_data('give_recount_customer_payments_'.$customer->id, array()); |
|
| 59 | 59 | |
| 60 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
| 61 | - $step_items = array_slice( $payments, $offset, $this->per_step ); |
|
| 60 | + $offset = ($this->step - 1) * $this->per_step; |
|
| 61 | + $step_items = array_slice($payments, $offset, $this->per_step); |
|
| 62 | 62 | |
| 63 | - if ( count( $step_items ) > 0 ) { |
|
| 64 | - $pending_total = (float) $this->get_stored_data( 'give_stats_customer_pending_total' . $customer->id, 0 ); |
|
| 63 | + if (count($step_items) > 0) { |
|
| 64 | + $pending_total = (float) $this->get_stored_data('give_stats_customer_pending_total'.$customer->id, 0); |
|
| 65 | 65 | $step_total = 0; |
| 66 | 66 | |
| 67 | - $found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $customer->id, array() ); |
|
| 67 | + $found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$customer->id, array()); |
|
| 68 | 68 | |
| 69 | - foreach ( $step_items as $payment ) { |
|
| 70 | - $payment = get_post( $payment->ID ); |
|
| 69 | + foreach ($step_items as $payment) { |
|
| 70 | + $payment = get_post($payment->ID); |
|
| 71 | 71 | |
| 72 | - if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) { |
|
| 72 | + if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) { |
|
| 73 | 73 | |
| 74 | - $missing_payments = $this->get_stored_data( 'give_stats_missing_payments' . $customer->id, array() ); |
|
| 74 | + $missing_payments = $this->get_stored_data('give_stats_missing_payments'.$customer->id, array()); |
|
| 75 | 75 | $missing_payments[] = $payment->ID; |
| 76 | - $this->store_data( 'give_stats_missing_payments' . $customer->id, $missing_payments ); |
|
| 76 | + $this->store_data('give_stats_missing_payments'.$customer->id, $missing_payments); |
|
| 77 | 77 | |
| 78 | 78 | continue; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | $should_process_payment = 'publish' == $payment->post_status || 'revoked' == $payment->post_status ? true : false; |
| 82 | - $should_process_payment = apply_filters( 'give_customer_recount_should_process_payment', $should_process_payment, $payment ); |
|
| 82 | + $should_process_payment = apply_filters('give_customer_recount_should_process_payment', $should_process_payment, $payment); |
|
| 83 | 83 | |
| 84 | - if ( true === $should_process_payment ) { |
|
| 84 | + if (true === $should_process_payment) { |
|
| 85 | 85 | |
| 86 | 86 | $found_payment_ids[] = $payment->ID; |
| 87 | 87 | |
| 88 | - if ( apply_filters( 'give_customer_recount_sholud_increase_value', true, $payment ) ) { |
|
| 89 | - $payment_amount = give_get_payment_amount( $payment->ID ); |
|
| 88 | + if (apply_filters('give_customer_recount_sholud_increase_value', true, $payment)) { |
|
| 89 | + $payment_amount = give_get_payment_amount($payment->ID); |
|
| 90 | 90 | $step_total += $payment_amount; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | $updated_total = $pending_total + $step_total; |
| 98 | - $this->store_data( 'give_stats_customer_pending_total' . $customer->id, $updated_total ); |
|
| 99 | - $this->store_data( 'give_stats_found_payments_' . $customer->id, $found_payment_ids ); |
|
| 98 | + $this->store_data('give_stats_customer_pending_total'.$customer->id, $updated_total); |
|
| 99 | + $this->store_data('give_stats_found_payments_'.$customer->id, $found_payment_ids); |
|
| 100 | 100 | |
| 101 | 101 | return true; |
| 102 | 102 | } |
@@ -113,16 +113,16 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function get_percentage_complete() { |
| 115 | 115 | |
| 116 | - $payments = $this->get_stored_data( 'give_recount_customer_payments_' . $this->customer_id ); |
|
| 117 | - $total = count( $payments ); |
|
| 116 | + $payments = $this->get_stored_data('give_recount_customer_payments_'.$this->customer_id); |
|
| 117 | + $total = count($payments); |
|
| 118 | 118 | |
| 119 | 119 | $percentage = 100; |
| 120 | 120 | |
| 121 | - if ( $total > 0 ) { |
|
| 122 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 121 | + if ($total > 0) { |
|
| 122 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - if ( $percentage > 100 ) { |
|
| 125 | + if ($percentage > 100) { |
|
| 126 | 126 | $percentage = 100; |
| 127 | 127 | } |
| 128 | 128 | |
@@ -136,8 +136,8 @@ discard block |
||
| 136 | 136 | * |
| 137 | 137 | * @param array $request The Form Data passed into the batch processing |
| 138 | 138 | */ |
| 139 | - public function set_properties( $request ) { |
|
| 140 | - $this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false; |
|
| 139 | + public function set_properties($request) { |
|
| 140 | + $this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -148,62 +148,62 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public function process_step() { |
| 150 | 150 | |
| 151 | - if ( ! $this->can_export() ) { |
|
| 152 | - wp_die( __( 'You do not have permission to recount stats.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 151 | + if ( ! $this->can_export()) { |
|
| 152 | + wp_die(__('You do not have permission to recount stats.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | $had_data = $this->get_data(); |
| 156 | 156 | |
| 157 | - if ( $had_data ) { |
|
| 157 | + if ($had_data) { |
|
| 158 | 158 | $this->done = false; |
| 159 | 159 | |
| 160 | 160 | return true; |
| 161 | 161 | } else { |
| 162 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 163 | - $payment_ids = get_option( 'give_stats_found_payments_' . $customer->id, array() ); |
|
| 164 | - $this->delete_data( 'give_stats_found_payments_' . $customer->id ); |
|
| 162 | + $customer = new Give_Customer($this->customer_id); |
|
| 163 | + $payment_ids = get_option('give_stats_found_payments_'.$customer->id, array()); |
|
| 164 | + $this->delete_data('give_stats_found_payments_'.$customer->id); |
|
| 165 | 165 | |
| 166 | - $removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $customer->id, array() ) ); |
|
| 166 | + $removed_payments = array_unique(get_option('give_stats_missing_payments'.$customer->id, array())); |
|
| 167 | 167 | |
| 168 | 168 | // Find non-existing payments (deleted) and total up the purchase count |
| 169 | 169 | $purchase_count = 0; |
| 170 | - foreach ( $payment_ids as $key => $payment_id ) { |
|
| 171 | - if ( in_array( $payment_id, $removed_payments ) ) { |
|
| 172 | - unset( $payment_ids[ $key ] ); |
|
| 170 | + foreach ($payment_ids as $key => $payment_id) { |
|
| 171 | + if (in_array($payment_id, $removed_payments)) { |
|
| 172 | + unset($payment_ids[$key]); |
|
| 173 | 173 | continue; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - $payment = get_post( $payment_id ); |
|
| 177 | - if ( apply_filters( 'give_customer_recount_should_increase_count', true, $payment ) ) { |
|
| 178 | - $purchase_count ++; |
|
| 176 | + $payment = get_post($payment_id); |
|
| 177 | + if (apply_filters('give_customer_recount_should_increase_count', true, $payment)) { |
|
| 178 | + $purchase_count++; |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - $this->delete_data( 'give_stats_missing_payments' . $customer->id ); |
|
| 182 | + $this->delete_data('give_stats_missing_payments'.$customer->id); |
|
| 183 | 183 | |
| 184 | - $pending_total = $this->get_stored_data( 'give_stats_customer_pending_total' . $customer->id, 0 ); |
|
| 185 | - $this->delete_data( 'give_stats_customer_pending_total' . $customer->id ); |
|
| 186 | - $this->delete_data( 'give_recount_customer_stats_' . $customer->id ); |
|
| 187 | - $this->delete_data( 'give_recount_customer_payments_' . $this->customer_id ); |
|
| 184 | + $pending_total = $this->get_stored_data('give_stats_customer_pending_total'.$customer->id, 0); |
|
| 185 | + $this->delete_data('give_stats_customer_pending_total'.$customer->id); |
|
| 186 | + $this->delete_data('give_recount_customer_stats_'.$customer->id); |
|
| 187 | + $this->delete_data('give_recount_customer_payments_'.$this->customer_id); |
|
| 188 | 188 | |
| 189 | - $payment_ids = implode( ',', $payment_ids ); |
|
| 190 | - $customer->update( array( 'payment_ids' => $payment_ids, |
|
| 189 | + $payment_ids = implode(',', $payment_ids); |
|
| 190 | + $customer->update(array('payment_ids' => $payment_ids, |
|
| 191 | 191 | 'purchase_count' => $purchase_count, |
| 192 | 192 | 'purchase_value' => $pending_total |
| 193 | - ) ); |
|
| 193 | + )); |
|
| 194 | 194 | |
| 195 | 195 | $this->done = true; |
| 196 | - $this->message = __( 'Donor stats successfully recounted.', 'give' ); |
|
| 196 | + $this->message = __('Donor stats successfully recounted.', 'give'); |
|
| 197 | 197 | |
| 198 | 198 | return false; |
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | public function headers() { |
| 203 | - ignore_user_abort( true ); |
|
| 203 | + ignore_user_abort(true); |
|
| 204 | 204 | |
| 205 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 206 | - set_time_limit( 0 ); |
|
| 205 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 206 | + set_time_limit(0); |
|
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | 209 | |
@@ -230,26 +230,26 @@ discard block |
||
| 230 | 230 | * @return void |
| 231 | 231 | */ |
| 232 | 232 | public function pre_fetch() { |
| 233 | - if ( $this->step === 1 ) { |
|
| 234 | - $allowed_payment_status = apply_filters( 'give_recount_customer_payment_statuses', give_get_payment_status_keys() ); |
|
| 233 | + if ($this->step === 1) { |
|
| 234 | + $allowed_payment_status = apply_filters('give_recount_customer_payment_statuses', give_get_payment_status_keys()); |
|
| 235 | 235 | |
| 236 | 236 | // Before we start, let's zero out the customer's data |
| 237 | - $customer = new Give_Customer( $this->customer_id ); |
|
| 238 | - $customer->update( array( 'purchase_value' => give_format_amount( 0 ), 'purchase_count' => 0 ) ); |
|
| 237 | + $customer = new Give_Customer($this->customer_id); |
|
| 238 | + $customer->update(array('purchase_value' => give_format_amount(0), 'purchase_count' => 0)); |
|
| 239 | 239 | |
| 240 | - $attached_payment_ids = explode( ',', $customer->payment_ids ); |
|
| 240 | + $attached_payment_ids = explode(',', $customer->payment_ids); |
|
| 241 | 241 | |
| 242 | 242 | $attached_args = array( |
| 243 | 243 | 'post__in' => $attached_payment_ids, |
| 244 | - 'number' => - 1, |
|
| 244 | + 'number' => -1, |
|
| 245 | 245 | 'status' => $allowed_post_status, |
| 246 | 246 | ); |
| 247 | 247 | |
| 248 | - $attached_payments = give_get_payments( $attached_args ); |
|
| 248 | + $attached_payments = give_get_payments($attached_args); |
|
| 249 | 249 | |
| 250 | 250 | $unattached_args = array( |
| 251 | 251 | 'post__not_in' => $attached_payment_ids, |
| 252 | - 'number' => - 1, |
|
| 252 | + 'number' => -1, |
|
| 253 | 253 | 'status' => $allowed_post_status, |
| 254 | 254 | 'meta_query' => array( |
| 255 | 255 | array( |
@@ -259,11 +259,11 @@ discard block |
||
| 259 | 259 | ), |
| 260 | 260 | ); |
| 261 | 261 | |
| 262 | - $unattached_payments = give_get_payments( $unattached_args ); |
|
| 262 | + $unattached_payments = give_get_payments($unattached_args); |
|
| 263 | 263 | |
| 264 | - $payments = array_merge( $attached_payments, $unattached_payments ); |
|
| 264 | + $payments = array_merge($attached_payments, $unattached_payments); |
|
| 265 | 265 | |
| 266 | - $this->store_data( 'give_recount_customer_payments_' . $customer->id, $payments ); |
|
| 266 | + $this->store_data('give_recount_customer_payments_'.$customer->id, $payments); |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | |
@@ -276,11 +276,11 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | * @return mixed Returns the data from the database |
| 278 | 278 | */ |
| 279 | - private function get_stored_data( $key ) { |
|
| 279 | + private function get_stored_data($key) { |
|
| 280 | 280 | global $wpdb; |
| 281 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 281 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 282 | 282 | |
| 283 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
| 283 | + return empty($value) ? false : maybe_unserialize($value); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
@@ -293,10 +293,10 @@ discard block |
||
| 293 | 293 | * |
| 294 | 294 | * @return void |
| 295 | 295 | */ |
| 296 | - private function store_data( $key, $value ) { |
|
| 296 | + private function store_data($key, $value) { |
|
| 297 | 297 | global $wpdb; |
| 298 | 298 | |
| 299 | - $value = maybe_serialize( $value ); |
|
| 299 | + $value = maybe_serialize($value); |
|
| 300 | 300 | |
| 301 | 301 | $data = array( |
| 302 | 302 | 'option_name' => $key, |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | '%s', |
| 311 | 311 | ); |
| 312 | 312 | |
| 313 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 313 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
@@ -322,9 +322,9 @@ discard block |
||
| 322 | 322 | * |
| 323 | 323 | * @return void |
| 324 | 324 | */ |
| 325 | - private function delete_data( $key ) { |
|
| 325 | + private function delete_data($key) { |
|
| 326 | 326 | global $wpdb; |
| 327 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 327 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | } |
@@ -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_customer_payment_statuses', give_get_payment_status_keys() ); |
|
| 68 | + $allowed_payment_status = apply_filters('give_recount_customer_payment_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 || 'revoked' == $payment->post_status ? true : false; |
| 108 | - $should_process_payment = apply_filters( 'give_customer_recount_should_process_payment', $should_process_payment, $payment ); |
|
| 108 | + $should_process_payment = apply_filters('give_customer_recount_should_process_payment', $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( __( 'You do not have permission to export data.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 195 | + if ( ! $this->can_export()) { |
|
| 196 | + wp_die(__('You do not have permission to export data.', 'give'), __('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 = __( 'Donor stats successfully recounted.', 'give' ); |
|
| 207 | + $this->message = __('Donor stats 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; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -19,10 +19,10 @@ discard block |
||
| 19 | 19 | * @since 1.5 |
| 20 | 20 | */ |
| 21 | 21 | function give_register_batch_recount_store_earnings_tool() { |
| 22 | - add_action( 'give_batch_export_class_include', 'give_include_recount_income_tool_batch_processor', 10, 1 ); |
|
| 22 | + add_action('give_batch_export_class_include', 'give_include_recount_income_tool_batch_processor', 10, 1); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -add_action( 'give_register_batch_exporter', 'give_register_batch_recount_store_earnings_tool', 10 ); |
|
| 25 | +add_action('give_register_batch_exporter', 'give_register_batch_recount_store_earnings_tool', 10); |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * Loads the tools batch processing class for recounting store earnings |
@@ -33,11 +33,11 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @return void |
| 35 | 35 | */ |
| 36 | -function give_include_recount_income_tool_batch_processor( $class ) { |
|
| 36 | +function give_include_recount_income_tool_batch_processor($class) { |
|
| 37 | 37 | |
| 38 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-income.php'; |
|
| 38 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-income.php'; |
|
| 39 | 39 | |
| 40 | - if ( 'Give_Tools_Recount_Income' === $class && file_exists( $file_path ) ) { |
|
| 40 | + if ('Give_Tools_Recount_Income' === $class && file_exists($file_path)) { |
|
| 41 | 41 | require_once $file_path; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -49,10 +49,10 @@ discard block |
||
| 49 | 49 | * @since 1.5 |
| 50 | 50 | */ |
| 51 | 51 | function give_register_batch_recount_form_tool() { |
| 52 | - add_action( 'give_batch_export_class_include', 'give_include_recount_form_tool_batch_processor', 10, 1 ); |
|
| 52 | + add_action('give_batch_export_class_include', 'give_include_recount_form_tool_batch_processor', 10, 1); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | -add_action( 'give_register_batch_exporter', 'give_register_batch_recount_form_tool', 10 ); |
|
| 55 | +add_action('give_register_batch_exporter', 'give_register_batch_recount_form_tool', 10); |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * Loads the tools batch processing class for recounting download stats |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @return void |
| 65 | 65 | */ |
| 66 | -function give_include_recount_form_tool_batch_processor( $class ) { |
|
| 66 | +function give_include_recount_form_tool_batch_processor($class) { |
|
| 67 | 67 | |
| 68 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-form-stats.php'; |
|
| 68 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-form-stats.php'; |
|
| 69 | 69 | |
| 70 | - if ( 'Give_Tools_Recount_Form_Stats' === $class && file_exists( $file_path ) ) { |
|
| 70 | + if ('Give_Tools_Recount_Form_Stats' === $class && file_exists($file_path)) { |
|
| 71 | 71 | require_once $file_path; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -78,10 +78,10 @@ discard block |
||
| 78 | 78 | * @since 1.5 |
| 79 | 79 | */ |
| 80 | 80 | function give_register_batch_recount_all_tool() { |
| 81 | - add_action( 'give_batch_export_class_include', 'give_include_recount_all_tool_batch_processor', 10, 1 ); |
|
| 81 | + add_action('give_batch_export_class_include', 'give_include_recount_all_tool_batch_processor', 10, 1); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | -add_action( 'give_register_batch_exporter', 'give_register_batch_recount_all_tool', 10 ); |
|
| 84 | +add_action('give_register_batch_exporter', 'give_register_batch_recount_all_tool', 10); |
|
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | 87 | * Loads the tools batch processing class for recounting all stats |
@@ -92,9 +92,9 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return void |
| 94 | 94 | */ |
| 95 | -function give_include_recount_all_tool_batch_processor( $class ) { |
|
| 96 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-all-stats.php'; |
|
| 97 | - if ( 'Give_Tools_Recount_All_Stats' === $class && file_exists( $file_path ) ) { |
|
| 95 | +function give_include_recount_all_tool_batch_processor($class) { |
|
| 96 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-all-stats.php'; |
|
| 97 | + if ('Give_Tools_Recount_All_Stats' === $class && file_exists($file_path)) { |
|
| 98 | 98 | require_once $file_path; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -106,10 +106,10 @@ discard block |
||
| 106 | 106 | * @since 1.5 |
| 107 | 107 | */ |
| 108 | 108 | function give_register_batch_reset_tool() { |
| 109 | - add_action( 'give_batch_export_class_include', 'give_include_reset_tool_batch_processor', 10, 1 ); |
|
| 109 | + add_action('give_batch_export_class_include', 'give_include_reset_tool_batch_processor', 10, 1); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | -add_action( 'give_register_batch_exporter', 'give_register_batch_reset_tool', 10 ); |
|
| 112 | +add_action('give_register_batch_exporter', 'give_register_batch_reset_tool', 10); |
|
| 113 | 113 | |
| 114 | 114 | /** |
| 115 | 115 | * Loads the tools batch processing class for resetting store and product earnings |
@@ -120,11 +120,11 @@ discard block |
||
| 120 | 120 | * |
| 121 | 121 | * @return void |
| 122 | 122 | */ |
| 123 | -function give_include_reset_tool_batch_processor( $class ) { |
|
| 123 | +function give_include_reset_tool_batch_processor($class) { |
|
| 124 | 124 | |
| 125 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-reset-stats.php'; |
|
| 125 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-reset-stats.php'; |
|
| 126 | 126 | |
| 127 | - if ( 'Give_Tools_Reset_Stats' === $class && file_exists( $file_path ) ) { |
|
| 127 | + if ('Give_Tools_Reset_Stats' === $class && file_exists($file_path)) { |
|
| 128 | 128 | require_once $file_path; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -135,10 +135,10 @@ discard block |
||
| 135 | 135 | * @since 1.5 |
| 136 | 136 | */ |
| 137 | 137 | function give_register_batch_customer_recount_tool() { |
| 138 | - add_action( 'give_batch_export_class_include', 'give_include_customer_recount_tool_batch_processor', 10, 1 ); |
|
| 138 | + add_action('give_batch_export_class_include', 'give_include_customer_recount_tool_batch_processor', 10, 1); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | -add_action( 'give_register_batch_exporter', 'give_register_batch_customer_recount_tool', 10 ); |
|
| 141 | +add_action('give_register_batch_exporter', 'give_register_batch_customer_recount_tool', 10); |
|
| 142 | 142 | |
| 143 | 143 | /** |
| 144 | 144 | * Loads the tools batch processing class for resetting all customer stats |
@@ -149,11 +149,11 @@ discard block |
||
| 149 | 149 | * |
| 150 | 150 | * @return void |
| 151 | 151 | */ |
| 152 | -function give_include_customer_recount_tool_batch_processor( $class ) { |
|
| 152 | +function give_include_customer_recount_tool_batch_processor($class) { |
|
| 153 | 153 | |
| 154 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-customer-stats.php'; |
|
| 154 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-customer-stats.php'; |
|
| 155 | 155 | |
| 156 | - if ( 'Give_Tools_Recount_Customer_Stats' === $class && file_exists( $file_path ) ) { |
|
| 156 | + if ('Give_Tools_Recount_Customer_Stats' === $class && file_exists($file_path)) { |
|
| 157 | 157 | require_once $file_path; |
| 158 | 158 | } |
| 159 | 159 | |
@@ -164,10 +164,10 @@ discard block |
||
| 164 | 164 | * @since 1.5 |
| 165 | 165 | */ |
| 166 | 166 | function give_register_batch_delete_test_transactions_tool() { |
| 167 | - add_action( 'give_batch_export_class_include', 'give_include_delete_test_transactions_batch_processor', 10, 1 ); |
|
| 167 | + add_action('give_batch_export_class_include', 'give_include_delete_test_transactions_batch_processor', 10, 1); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | -add_action( 'give_register_batch_exporter', 'give_register_batch_delete_test_transactions_tool', 10 ); |
|
| 170 | +add_action('give_register_batch_exporter', 'give_register_batch_delete_test_transactions_tool', 10); |
|
| 171 | 171 | |
| 172 | 172 | /** |
| 173 | 173 | * Loads the tools batch processing class for resetting all customer stats |
@@ -178,11 +178,11 @@ discard block |
||
| 178 | 178 | * |
| 179 | 179 | * @return void |
| 180 | 180 | */ |
| 181 | -function give_include_delete_test_transactions_batch_processor( $class ) { |
|
| 181 | +function give_include_delete_test_transactions_batch_processor($class) { |
|
| 182 | 182 | |
| 183 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-delete-test-transactions.php'; |
|
| 183 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-delete-test-transactions.php'; |
|
| 184 | 184 | |
| 185 | - if ( 'Give_Tools_Delete_Test_Transactions' === $class && file_exists( $file_path ) ) { |
|
| 185 | + if ('Give_Tools_Delete_Test_Transactions' === $class && file_exists($file_path)) { |
|
| 186 | 186 | require_once $file_path; |
| 187 | 187 | } |
| 188 | 188 | |
@@ -10,13 +10,13 @@ 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 | |
| 17 | 17 | // Load WP_List_Table if not loaded |
| 18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
| 19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
| 18 | +if ( ! class_exists('WP_List_Table')) { |
|
| 19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -50,13 +50,13 @@ discard block |
||
| 50 | 50 | global $status, $page; |
| 51 | 51 | |
| 52 | 52 | // Set parent defaults |
| 53 | - parent::__construct( array( |
|
| 54 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
| 55 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
| 53 | + parent::__construct(array( |
|
| 54 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
| 55 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
| 56 | 56 | 'ajax' => false // Does this table support ajax? |
| 57 | - ) ); |
|
| 57 | + )); |
|
| 58 | 58 | |
| 59 | - add_action( 'give_report_view_actions', array( $this, 'category_filter' ) ); |
|
| 59 | + add_action('give_report_view_actions', array($this, 'category_filter')); |
|
| 60 | 60 | $this->query(); |
| 61 | 61 | |
| 62 | 62 | } |
@@ -72,18 +72,18 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @return string Column Name |
| 74 | 74 | */ |
| 75 | - public function column_default( $item, $column_name ) { |
|
| 76 | - switch ( $column_name ) { |
|
| 75 | + public function column_default($item, $column_name) { |
|
| 76 | + switch ($column_name) { |
|
| 77 | 77 | case 'earnings' : |
| 78 | - return give_currency_filter( give_format_amount( $item[ $column_name ] ) ); |
|
| 78 | + return give_currency_filter(give_format_amount($item[$column_name])); |
|
| 79 | 79 | case 'average_sales' : |
| 80 | - return round( $item[ $column_name ] ); |
|
| 80 | + return round($item[$column_name]); |
|
| 81 | 81 | case 'average_earnings' : |
| 82 | - return give_currency_filter( give_format_amount( $item[ $column_name ] ) ); |
|
| 82 | + return give_currency_filter(give_format_amount($item[$column_name])); |
|
| 83 | 83 | case 'details' : |
| 84 | - return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=forms&form-id=' . $item['ID'] ) . '">' . __( 'View Detailed Report', 'give' ) . '</a>'; |
|
| 84 | + return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-reports&view=forms&form-id='.$item['ID']).'">'.__('View Detailed Report', 'give').'</a>'; |
|
| 85 | 85 | default: |
| 86 | - return $item[ $column_name ]; |
|
| 86 | + return $item[$column_name]; |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | public function get_columns() { |
| 98 | 98 | $columns = array( |
| 99 | 99 | 'title' => give_get_forms_label_singular(), |
| 100 | - 'sales' => __( 'Donations', 'give' ), |
|
| 101 | - 'earnings' => __( 'Income', 'give' ), |
|
| 102 | - 'average_sales' => __( 'Monthly Average Donations', 'give' ), |
|
| 103 | - 'average_earnings' => __( 'Monthly Average Income', 'give' ), |
|
| 104 | - 'details' => __( 'Detailed Report', 'give' ) |
|
| 100 | + 'sales' => __('Donations', 'give'), |
|
| 101 | + 'earnings' => __('Income', 'give'), |
|
| 102 | + 'average_sales' => __('Monthly Average Donations', 'give'), |
|
| 103 | + 'average_earnings' => __('Monthly Average Income', 'give'), |
|
| 104 | + 'details' => __('Detailed Report', 'give') |
|
| 105 | 105 | ); |
| 106 | 106 | |
| 107 | 107 | return $columns; |
@@ -116,9 +116,9 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function get_sortable_columns() { |
| 118 | 118 | return array( |
| 119 | - 'title' => array( 'title', true ), |
|
| 120 | - 'sales' => array( 'sales', false ), |
|
| 121 | - 'earnings' => array( 'earnings', false ), |
|
| 119 | + 'title' => array('title', true), |
|
| 120 | + 'sales' => array('sales', false), |
|
| 121 | + 'earnings' => array('earnings', false), |
|
| 122 | 122 | ); |
| 123 | 123 | } |
| 124 | 124 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * @return int Current page number |
| 131 | 131 | */ |
| 132 | 132 | public function get_paged() { |
| 133 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
| 133 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @return int Category ID |
| 143 | 143 | */ |
| 144 | 144 | public function get_category() { |
| 145 | - return isset( $_GET['category'] ) ? absint( $_GET['category'] ) : 0; |
|
| 145 | + return isset($_GET['category']) ? absint($_GET['category']) : 0; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | |
@@ -155,8 +155,8 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | public function get_total_forms() { |
| 157 | 157 | $total = 0; |
| 158 | - $counts = wp_count_posts( 'give_forms', 'readable' ); |
|
| 159 | - foreach ( $counts as $status => $count ) { |
|
| 158 | + $counts = wp_count_posts('give_forms', 'readable'); |
|
| 159 | + foreach ($counts as $status => $count) { |
|
| 160 | 160 | $total += $count; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * @since 1.0 |
| 171 | 171 | * @return void |
| 172 | 172 | */ |
| 173 | - public function bulk_actions( $which = '' ) { |
|
| 173 | + public function bulk_actions($which = '') { |
|
| 174 | 174 | // These aren't really bulk actions but this outputs the markup in the right place |
| 175 | 175 | give_report_views(); |
| 176 | 176 | } |
@@ -183,23 +183,23 @@ discard block |
||
| 183 | 183 | * |
| 184 | 184 | * @param string $which |
| 185 | 185 | */ |
| 186 | - protected function display_tablenav( $which ) { |
|
| 186 | + protected function display_tablenav($which) { |
|
| 187 | 187 | |
| 188 | - if ( 'top' == $which ) { |
|
| 189 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
| 188 | + if ('top' == $which) { |
|
| 189 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
| 190 | 190 | } |
| 191 | 191 | ?> |
| 192 | - <div class="tablenav give-clearfix <?php echo esc_attr( $which ); ?>"> |
|
| 192 | + <div class="tablenav give-clearfix <?php echo esc_attr($which); ?>"> |
|
| 193 | 193 | |
| 194 | - <h3 class="alignleft reports-earnings-title"><span><?php _e( 'Donation Forms Report', 'give' ); ?></span></h3> |
|
| 194 | + <h3 class="alignleft reports-earnings-title"><span><?php _e('Donation Forms Report', 'give'); ?></span></h3> |
|
| 195 | 195 | |
| 196 | 196 | <div class="alignright tablenav-right"> |
| 197 | 197 | <div class="actions bulkactions"> |
| 198 | - <?php $this->bulk_actions( $which ); ?> |
|
| 198 | + <?php $this->bulk_actions($which); ?> |
|
| 199 | 199 | </div> |
| 200 | 200 | <?php |
| 201 | - $this->extra_tablenav( $which ); |
|
| 202 | - $this->pagination( $which ); |
|
| 201 | + $this->extra_tablenav($which); |
|
| 202 | + $this->pagination($which); |
|
| 203 | 203 | ?> |
| 204 | 204 | </div> |
| 205 | 205 | |
@@ -219,9 +219,9 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | public function category_filter() { |
| 221 | 221 | |
| 222 | - $categories = get_terms( 'form_category' ); |
|
| 223 | - if ( $categories && ! is_wp_error( $categories ) ) { |
|
| 224 | - echo Give()->html->category_dropdown( 'category', $this->get_category() ); |
|
| 222 | + $categories = get_terms('form_category'); |
|
| 223 | + if ($categories && ! is_wp_error($categories)) { |
|
| 224 | + echo Give()->html->category_dropdown('category', $this->get_category()); |
|
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | |
@@ -235,8 +235,8 @@ discard block |
||
| 235 | 235 | */ |
| 236 | 236 | public function query() { |
| 237 | 237 | |
| 238 | - $orderby = isset( $_GET['orderby'] ) ? $_GET['orderby'] : 'title'; |
|
| 239 | - $order = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC'; |
|
| 238 | + $orderby = isset($_GET['orderby']) ? $_GET['orderby'] : 'title'; |
|
| 239 | + $order = isset($_GET['order']) ? $_GET['order'] : 'DESC'; |
|
| 240 | 240 | $category = $this->get_category(); |
| 241 | 241 | |
| 242 | 242 | $args = array( |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | 'suppress_filters' => true |
| 250 | 250 | ); |
| 251 | 251 | |
| 252 | - if ( ! empty( $category ) ) { |
|
| 252 | + if ( ! empty($category)) { |
|
| 253 | 253 | $args['tax_query'] = array( |
| 254 | 254 | array( |
| 255 | 255 | 'taxonomy' => 'form_category', |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | ); |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - switch ( $orderby ) : |
|
| 261 | + switch ($orderby) : |
|
| 262 | 262 | case 'title' : |
| 263 | 263 | $args['orderby'] = 'title'; |
| 264 | 264 | break; |
@@ -274,9 +274,9 @@ discard block |
||
| 274 | 274 | break; |
| 275 | 275 | endswitch; |
| 276 | 276 | |
| 277 | - $args = apply_filters( 'give_form_reports_prepare_items_args', $args, $this ); |
|
| 277 | + $args = apply_filters('give_form_reports_prepare_items_args', $args, $this); |
|
| 278 | 278 | |
| 279 | - $this->products = new WP_Query( $args ); |
|
| 279 | + $this->products = new WP_Query($args); |
|
| 280 | 280 | |
| 281 | 281 | } |
| 282 | 282 | |
@@ -292,15 +292,15 @@ discard block |
||
| 292 | 292 | |
| 293 | 293 | $give_forms = $this->products->posts; |
| 294 | 294 | |
| 295 | - if ( $give_forms ) { |
|
| 296 | - foreach ( $give_forms as $form ) { |
|
| 295 | + if ($give_forms) { |
|
| 296 | + foreach ($give_forms as $form) { |
|
| 297 | 297 | $reports_data[] = array( |
| 298 | 298 | 'ID' => $form, |
| 299 | - 'title' => get_the_title( $form ), |
|
| 300 | - 'sales' => give_get_form_sales_stats( $form ), |
|
| 301 | - 'earnings' => give_get_form_earnings_stats( $form ), |
|
| 302 | - 'average_sales' => give_get_average_monthly_form_sales( $form ), |
|
| 303 | - 'average_earnings' => give_get_average_monthly_form_earnings( $form ) |
|
| 299 | + 'title' => get_the_title($form), |
|
| 300 | + 'sales' => give_get_form_sales_stats($form), |
|
| 301 | + 'earnings' => give_get_form_earnings_stats($form), |
|
| 302 | + 'average_sales' => give_get_average_monthly_form_sales($form), |
|
| 303 | + 'average_earnings' => give_get_average_monthly_form_earnings($form) |
|
| 304 | 304 | ); |
| 305 | 305 | } |
| 306 | 306 | } |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | |
| 329 | 329 | $sortable = $this->get_sortable_columns(); |
| 330 | 330 | |
| 331 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
| 331 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
| 332 | 332 | |
| 333 | 333 | $data = $this->reports_data(); |
| 334 | 334 | |
@@ -336,10 +336,10 @@ discard block |
||
| 336 | 336 | |
| 337 | 337 | $this->items = $data; |
| 338 | 338 | |
| 339 | - $this->set_pagination_args( array( |
|
| 339 | + $this->set_pagination_args(array( |
|
| 340 | 340 | 'total_items' => $total_items, |
| 341 | 341 | 'per_page' => $this->per_page, |
| 342 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
| 342 | + 'total_pages' => ceil($total_items / $this->per_page) |
|
| 343 | 343 | ) |
| 344 | 344 | ); |
| 345 | 345 | } |