@@ -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' => esc_html__( 'Export location or file not writable.', 'give' ) |
|
53 | + 'message' => esc_html__('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' => esc_html__( 'No data found for export parameters.', 'give' ) |
|
78 | - ) ); |
|
77 | + 'message' => esc_html__('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 : esc_html__( 'Batch Processing Complete', 'give' ); |
|
84 | - echo json_encode( array( 'success' => true, 'message' => $message ) ); |
|
83 | + $message = ! empty($export->message) ? $export->message : esc_html__('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 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
11 | 11 | */ |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -22,20 +22,20 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function give_process_batch_export_form() { |
24 | 24 | |
25 | - if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'give-batch-export' ) ) { |
|
26 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
25 | + if ( ! wp_verify_nonce($_REQUEST['nonce'], 'give-batch-export')) { |
|
26 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
27 | 27 | } |
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 | - do_action( 'give_batch_export_class_include', $_REQUEST['class'] ); |
|
31 | + do_action('give_batch_export_class_include', $_REQUEST['class']); |
|
32 | 32 | |
33 | 33 | $export = new $_REQUEST['class']; |
34 | 34 | $export->export(); |
35 | 35 | |
36 | 36 | } |
37 | 37 | |
38 | -add_action( 'give_form_batch_export', 'give_process_batch_export_form' ); |
|
38 | +add_action('give_form_batch_export', 'give_process_batch_export_form'); |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Exports earnings for a specified time period |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | * @return void |
47 | 47 | */ |
48 | 48 | function give_export_earnings() { |
49 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-earnings.php'; |
|
49 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-earnings.php'; |
|
50 | 50 | |
51 | 51 | $earnings_export = new Give_Earnings_Export(); |
52 | 52 | |
53 | 53 | $earnings_export->export(); |
54 | 54 | } |
55 | 55 | |
56 | -add_action( 'give_earnings_export', 'give_export_earnings' ); |
|
56 | +add_action('give_earnings_export', 'give_export_earnings'); |
|
57 | 57 | |
58 | 58 | |
59 | 59 | /** |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | * @return void |
67 | 67 | */ |
68 | 68 | function give_export_all_customers() { |
69 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-customers.php'; |
|
69 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-customers.php'; |
|
70 | 70 | |
71 | 71 | $customer_export = new Give_Donors_Export(); |
72 | 72 | |
73 | 73 | $customer_export->export(); |
74 | 74 | } |
75 | 75 | |
76 | -add_action( 'give_email_export', 'give_export_all_customers' ); |
|
76 | +add_action('give_email_export', 'give_export_all_customers'); |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Add a hook allowing extensions to register a hook on the batch export process |
@@ -82,22 +82,22 @@ discard block |
||
82 | 82 | * @return void |
83 | 83 | */ |
84 | 84 | function give_register_batch_exporters() { |
85 | - if ( is_admin() ) { |
|
86 | - do_action( 'give_register_batch_exporter' ); |
|
85 | + if (is_admin()) { |
|
86 | + do_action('give_register_batch_exporter'); |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | -add_action( 'plugins_loaded', 'give_register_batch_exporters' ); |
|
90 | +add_action('plugins_loaded', 'give_register_batch_exporters'); |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Register the payments batch exporter |
94 | 94 | * @since 1.5 |
95 | 95 | */ |
96 | 96 | function give_register_payments_batch_export() { |
97 | - add_action( 'give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1 ); |
|
97 | + add_action('give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1); |
|
98 | 98 | } |
99 | 99 | |
100 | -add_action( 'give_register_batch_exporter', 'give_register_payments_batch_export', 10 ); |
|
100 | +add_action('give_register_batch_exporter', 'give_register_payments_batch_export', 10); |
|
101 | 101 | |
102 | 102 | /** |
103 | 103 | * Loads the payments batch process if needed |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return void |
110 | 110 | */ |
111 | -function give_include_payments_batch_processor( $class ) { |
|
111 | +function give_include_payments_batch_processor($class) { |
|
112 | 112 | |
113 | - if ( 'Give_Batch_Payments_Export' === $class ) { |
|
114 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-payments.php'; |
|
113 | + if ('Give_Batch_Payments_Export' === $class) { |
|
114 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-payments.php'; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | } |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | * @since 1.5.2 |
122 | 122 | */ |
123 | 123 | function give_register_customers_batch_export() { |
124 | - add_action( 'give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1 ); |
|
124 | + add_action('give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1); |
|
125 | 125 | } |
126 | 126 | |
127 | -add_action( 'give_register_batch_exporter', 'give_register_customers_batch_export', 10 ); |
|
127 | +add_action('give_register_batch_exporter', 'give_register_customers_batch_export', 10); |
|
128 | 128 | |
129 | 129 | /** |
130 | 130 | * Loads the customers batch process if needed |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return void |
137 | 137 | */ |
138 | -function give_include_customers_batch_processor( $class ) { |
|
138 | +function give_include_customers_batch_processor($class) { |
|
139 | 139 | |
140 | - if ( 'Give_Batch_Customers_Export' === $class ) { |
|
141 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-customers.php'; |
|
140 | + if ('Give_Batch_Customers_Export' === $class) { |
|
141 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-customers.php'; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | } |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | * @since 1.5 |
150 | 150 | */ |
151 | 151 | function give_register_forms_batch_export() { |
152 | - add_action( 'give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1 ); |
|
152 | + add_action('give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1); |
|
153 | 153 | } |
154 | 154 | |
155 | -add_action( 'give_register_batch_exporter', 'give_register_forms_batch_export', 10 ); |
|
155 | +add_action('give_register_batch_exporter', 'give_register_forms_batch_export', 10); |
|
156 | 156 | |
157 | 157 | /** |
158 | 158 | * Loads the file downloads batch process if needed |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return void |
165 | 165 | */ |
166 | -function give_include_forms_batch_processor( $class ) { |
|
166 | +function give_include_forms_batch_processor($class) { |
|
167 | 167 | |
168 | - if ( 'Give_Batch_Forms_Export' === $class ) { |
|
169 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-forms.php'; |
|
168 | + if ('Give_Batch_Forms_Export' === $class) { |
|
169 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-forms.php'; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | } |
173 | 173 | \ No newline at end of file |
@@ -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' => esc_html__( 'ID', 'give' ), |
|
45 | - 'post_name' => esc_html__( 'Slug', 'give' ), |
|
46 | - 'post_title' => esc_html__( 'Name', 'give' ), |
|
47 | - 'post_date' => esc_html__( 'Date Created', 'give' ), |
|
48 | - 'post_author' => esc_html__( 'Author', 'give' ), |
|
49 | - 'post_content' => esc_html__( 'Description', 'give' ), |
|
50 | - 'post_excerpt' => esc_html__( 'Excerpt', 'give' ), |
|
51 | - 'post_status' => esc_html__( 'Status', 'give' ), |
|
52 | - 'categories' => esc_html__( 'Categories', 'give' ), |
|
53 | - 'tags' => esc_html__( 'Tags', 'give' ), |
|
54 | - 'give_price' => esc_html__( 'Price', 'give' ), |
|
55 | - '_thumbnail_id' => esc_html__( 'Featured Image', 'give' ), |
|
56 | - '_give_form_sales' => esc_html__( 'Donations', 'give' ), |
|
57 | - '_give_download_earnings' => esc_html__( 'Income', 'give' ), |
|
44 | + 'ID' => esc_html__('ID', 'give'), |
|
45 | + 'post_name' => esc_html__('Slug', 'give'), |
|
46 | + 'post_title' => esc_html__('Name', 'give'), |
|
47 | + 'post_date' => esc_html__('Date Created', 'give'), |
|
48 | + 'post_author' => esc_html__('Author', 'give'), |
|
49 | + 'post_content' => esc_html__('Description', 'give'), |
|
50 | + 'post_excerpt' => esc_html__('Excerpt', 'give'), |
|
51 | + 'post_status' => esc_html__('Status', 'give'), |
|
52 | + 'categories' => esc_html__('Categories', 'give'), |
|
53 | + 'tags' => esc_html__('Tags', 'give'), |
|
54 | + 'give_price' => esc_html__('Price', 'give'), |
|
55 | + '_thumbnail_id' => esc_html__('Featured Image', 'give'), |
|
56 | + '_give_form_sales' => esc_html__('Donations', 'give'), |
|
57 | + '_give_download_earnings' => esc_html__('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 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @return bool Whether we can export or not |
38 | 38 | */ |
39 | 39 | public function can_export() { |
40 | - return (bool) apply_filters( 'give_export_capability', current_user_can( 'export_give_reports' ) ); |
|
40 | + return (bool) apply_filters('give_export_capability', current_user_can('export_give_reports')); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -48,16 +48,16 @@ discard block |
||
48 | 48 | * @return void |
49 | 49 | */ |
50 | 50 | public function headers() { |
51 | - ignore_user_abort( true ); |
|
51 | + ignore_user_abort(true); |
|
52 | 52 | |
53 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
54 | - set_time_limit( 0 ); |
|
53 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
54 | + set_time_limit(0); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | nocache_headers(); |
58 | - header( 'Content-Type: text/csv; charset=utf-8' ); |
|
59 | - header( 'Content-Disposition: attachment; filename=give-export-' . $this->export_type . '-' . date( 'm-d-Y' ) . '.csv' ); |
|
60 | - header( "Expires: 0" ); |
|
58 | + header('Content-Type: text/csv; charset=utf-8'); |
|
59 | + header('Content-Disposition: attachment; filename=give-export-'.$this->export_type.'-'.date('m-d-Y').'.csv'); |
|
60 | + header("Expires: 0"); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function csv_cols() { |
71 | 71 | $cols = array( |
72 | - 'id' => esc_html__( 'ID', 'give' ), |
|
73 | - 'date' => esc_html__( 'Date', 'give' ) |
|
72 | + 'id' => esc_html__('ID', 'give'), |
|
73 | + 'date' => esc_html__('Date', 'give') |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | return $cols; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | public function get_csv_cols() { |
87 | 87 | $cols = $this->csv_cols(); |
88 | 88 | |
89 | - return apply_filters( 'give_export_csv_cols_' . $this->export_type, $cols ); |
|
89 | + return apply_filters('give_export_csv_cols_'.$this->export_type, $cols); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | public function csv_cols_out() { |
101 | 101 | $cols = $this->get_csv_cols(); |
102 | 102 | $i = 1; |
103 | - foreach ( $cols as $col_id => $column ) { |
|
104 | - echo '"' . addslashes( $column ) . '"'; |
|
105 | - echo $i == count( $cols ) ? '' : ','; |
|
106 | - $i ++; |
|
103 | + foreach ($cols as $col_id => $column) { |
|
104 | + echo '"'.addslashes($column).'"'; |
|
105 | + echo $i == count($cols) ? '' : ','; |
|
106 | + $i++; |
|
107 | 107 | } |
108 | 108 | echo "\r\n"; |
109 | 109 | } |
@@ -120,16 +120,16 @@ discard block |
||
120 | 120 | $data = array( |
121 | 121 | 0 => array( |
122 | 122 | 'id' => '', |
123 | - 'data' => date( 'F j, Y' ) |
|
123 | + 'data' => date('F j, Y') |
|
124 | 124 | ), |
125 | 125 | 1 => array( |
126 | 126 | 'id' => '', |
127 | - 'data' => date( 'F j, Y' ) |
|
127 | + 'data' => date('F j, Y') |
|
128 | 128 | ) |
129 | 129 | ); |
130 | 130 | |
131 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
132 | - $data = apply_filters( 'give_export_get_data_' . $this->export_type, $data ); |
|
131 | + $data = apply_filters('give_export_get_data', $data); |
|
132 | + $data = apply_filters('give_export_get_data_'.$this->export_type, $data); |
|
133 | 133 | |
134 | 134 | return $data; |
135 | 135 | } |
@@ -147,14 +147,14 @@ discard block |
||
147 | 147 | $cols = $this->get_csv_cols(); |
148 | 148 | |
149 | 149 | // Output each row |
150 | - foreach ( $data as $row ) { |
|
150 | + foreach ($data as $row) { |
|
151 | 151 | $i = 1; |
152 | - foreach ( $row as $col_id => $column ) { |
|
152 | + foreach ($row as $col_id => $column) { |
|
153 | 153 | // Make sure the column is valid |
154 | - if ( array_key_exists( $col_id, $cols ) ) { |
|
155 | - echo '"' . addslashes( $column ) . '"'; |
|
156 | - echo $i == count( $cols ) ? '' : ','; |
|
157 | - $i ++; |
|
154 | + if (array_key_exists($col_id, $cols)) { |
|
155 | + echo '"'.addslashes($column).'"'; |
|
156 | + echo $i == count($cols) ? '' : ','; |
|
157 | + $i++; |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | echo "\r\n"; |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | * @return void |
174 | 174 | */ |
175 | 175 | public function export() { |
176 | - if ( ! $this->can_export() ) { |
|
177 | - wp_die( esc_html__( 'You do not have permission to export data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
176 | + if ( ! $this->can_export()) { |
|
177 | + wp_die(esc_html__('You do not have permission to export data.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | // Set headers |
@@ -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( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
151 | + if ( ! $this->can_export()) { |
|
152 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | $had_data = $this->get_data(); |
156 | 156 | |
157 | - if ( $had_data ) { |
|
157 | + if ($had_data) { |
|
158 | 158 | $this->done = false; |
159 | 159 | |
160 | 160 | return true; |
161 | 161 | } else { |
162 | - $customer = new Give_Customer( $this->customer_id ); |
|
163 | - $payment_ids = get_option( 'give_stats_found_payments_' . $customer->id, array() ); |
|
164 | - $this->delete_data( 'give_stats_found_payments_' . $customer->id ); |
|
162 | + $customer = new Give_Customer($this->customer_id); |
|
163 | + $payment_ids = get_option('give_stats_found_payments_'.$customer->id, array()); |
|
164 | + $this->delete_data('give_stats_found_payments_'.$customer->id); |
|
165 | 165 | |
166 | - $removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $customer->id, array() ) ); |
|
166 | + $removed_payments = array_unique(get_option('give_stats_missing_payments'.$customer->id, array())); |
|
167 | 167 | |
168 | 168 | // Find non-existing payments (deleted) and total up the 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 = esc_html__( 'Donor stats successfully recounted.', 'give' ); |
|
196 | + $this->message = esc_html__('Donor stats successfully recounted.', 'give'); |
|
197 | 197 | |
198 | 198 | return false; |
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
202 | 202 | public function headers() { |
203 | - ignore_user_abort( true ); |
|
203 | + ignore_user_abort(true); |
|
204 | 204 | |
205 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
206 | - set_time_limit( 0 ); |
|
205 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
206 | + set_time_limit(0); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -230,26 +230,26 @@ discard block |
||
230 | 230 | * @return void |
231 | 231 | */ |
232 | 232 | public function pre_fetch() { |
233 | - if ( $this->step === 1 ) { |
|
234 | - $allowed_payment_status = apply_filters( 'give_recount_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 | |
@@ -55,16 +55,16 @@ discard block |
||
55 | 55 | public function get_data() { |
56 | 56 | global $wpdb; |
57 | 57 | |
58 | - $items = $this->get_stored_data( 'give_temp_reset_ids' ); |
|
58 | + $items = $this->get_stored_data('give_temp_reset_ids'); |
|
59 | 59 | |
60 | - if ( ! is_array( $items ) ) { |
|
60 | + if ( ! is_array($items)) { |
|
61 | 61 | return false; |
62 | 62 | } |
63 | 63 | |
64 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
65 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
64 | + $offset = ($this->step - 1) * $this->per_step; |
|
65 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
66 | 66 | |
67 | - if ( $step_items ) { |
|
67 | + if ($step_items) { |
|
68 | 68 | |
69 | 69 | $step_ids = array( |
70 | 70 | 'customers' => array(), |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | 'other' => array(), |
73 | 73 | ); |
74 | 74 | |
75 | - foreach ( $step_items as $item ) { |
|
75 | + foreach ($step_items as $item) { |
|
76 | 76 | |
77 | - switch ( $item['type'] ) { |
|
77 | + switch ($item['type']) { |
|
78 | 78 | case 'customer': |
79 | 79 | $step_ids['customers'][] = $item['id']; |
80 | 80 | break; |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | $step_ids['give_forms'][] = $item['id']; |
83 | 83 | break; |
84 | 84 | default: |
85 | - $item_type = apply_filters( 'give_reset_item_type', 'other', $item ); |
|
86 | - $step_ids[ $item_type ][] = $item['id']; |
|
85 | + $item_type = apply_filters('give_reset_item_type', 'other', $item); |
|
86 | + $step_ids[$item_type][] = $item['id']; |
|
87 | 87 | break; |
88 | 88 | } |
89 | 89 | |
@@ -91,17 +91,17 @@ discard block |
||
91 | 91 | |
92 | 92 | $sql = array(); |
93 | 93 | |
94 | - foreach ( $step_ids as $type => $ids ) { |
|
94 | + foreach ($step_ids as $type => $ids) { |
|
95 | 95 | |
96 | - if ( empty( $ids ) ) { |
|
96 | + if (empty($ids)) { |
|
97 | 97 | continue; |
98 | 98 | } |
99 | 99 | |
100 | - $ids = implode( ',', $ids ); |
|
100 | + $ids = implode(',', $ids); |
|
101 | 101 | |
102 | - switch ( $type ) { |
|
102 | + switch ($type) { |
|
103 | 103 | case 'customers': |
104 | - $table_name = $wpdb->prefix . 'give_customers'; |
|
104 | + $table_name = $wpdb->prefix.'give_customers'; |
|
105 | 105 | $sql[] = "DELETE FROM $table_name WHERE id IN ($ids)"; |
106 | 106 | break; |
107 | 107 | case 'forms': |
@@ -116,18 +116,18 @@ discard block |
||
116 | 116 | break; |
117 | 117 | } |
118 | 118 | |
119 | - if ( ! in_array( $type, array( 'customers', 'forms', 'other' ) ) ) { |
|
119 | + if ( ! in_array($type, array('customers', 'forms', 'other'))) { |
|
120 | 120 | // Allows other types of custom post types to filter on their own post_type |
121 | 121 | // and add items to the query list, for the IDs found in their post type. |
122 | - $sql = apply_filters( 'give_reset_add_queries_' . $type, $sql, $ids ); |
|
122 | + $sql = apply_filters('give_reset_add_queries_'.$type, $sql, $ids); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | |
126 | 126 | } |
127 | 127 | |
128 | - if ( ! empty( $sql ) ) { |
|
129 | - foreach ( $sql as $query ) { |
|
130 | - $wpdb->query( $query ); |
|
128 | + if ( ! empty($sql)) { |
|
129 | + foreach ($sql as $query) { |
|
130 | + $wpdb->query($query); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
@@ -147,16 +147,16 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function get_percentage_complete() { |
149 | 149 | |
150 | - $items = $this->get_stored_data( 'give_temp_reset_ids', false ); |
|
151 | - $total = count( $items ); |
|
150 | + $items = $this->get_stored_data('give_temp_reset_ids', false); |
|
151 | + $total = count($items); |
|
152 | 152 | |
153 | 153 | $percentage = 100; |
154 | 154 | |
155 | - if ( $total > 0 ) { |
|
156 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
155 | + if ($total > 0) { |
|
156 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
157 | 157 | } |
158 | 158 | |
159 | - if ( $percentage > 100 ) { |
|
159 | + if ($percentage > 100) { |
|
160 | 160 | $percentage = 100; |
161 | 161 | } |
162 | 162 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @param array $request The Form Data passed into the batch processing |
172 | 172 | */ |
173 | - public function set_properties( $request ) { |
|
173 | + public function set_properties($request) { |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -181,30 +181,30 @@ discard block |
||
181 | 181 | */ |
182 | 182 | public function process_step() { |
183 | 183 | |
184 | - if ( ! $this->can_export() ) { |
|
185 | - wp_die( esc_html__( 'You do not have permission to export data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
184 | + if ( ! $this->can_export()) { |
|
185 | + wp_die(esc_html__('You do not have permission to export data.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | $had_data = $this->get_data(); |
189 | 189 | |
190 | - if ( $had_data ) { |
|
190 | + if ($had_data) { |
|
191 | 191 | $this->done = false; |
192 | 192 | |
193 | 193 | return true; |
194 | 194 | } else { |
195 | - update_option( 'give_earnings_total', 0 ); |
|
196 | - delete_transient( 'give_earnings_total' ); |
|
197 | - delete_transient( 'give_estimated_monthly_stats' . true ); |
|
198 | - delete_transient( 'give_estimated_monthly_stats' . false ); |
|
199 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
195 | + update_option('give_earnings_total', 0); |
|
196 | + delete_transient('give_earnings_total'); |
|
197 | + delete_transient('give_estimated_monthly_stats'.true); |
|
198 | + delete_transient('give_estimated_monthly_stats'.false); |
|
199 | + $this->delete_data('give_temp_reset_ids'); |
|
200 | 200 | |
201 | 201 | // Reset the sequential order numbers |
202 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
203 | - delete_option( 'give_last_payment_number' ); |
|
202 | + if (give_get_option('enable_sequential')) { |
|
203 | + delete_option('give_last_payment_number'); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | $this->done = true; |
207 | - $this->message = esc_html__( 'Donation forms, income, donations counts, and logs successfully reset.', 'give' ); |
|
207 | + $this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give'); |
|
208 | 208 | |
209 | 209 | return false; |
210 | 210 | } |
@@ -214,10 +214,10 @@ discard block |
||
214 | 214 | * Headers |
215 | 215 | */ |
216 | 216 | public function headers() { |
217 | - ignore_user_abort( true ); |
|
217 | + ignore_user_abort(true); |
|
218 | 218 | |
219 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
220 | - set_time_limit( 0 ); |
|
219 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
220 | + set_time_limit(0); |
|
221 | 221 | } |
222 | 222 | } |
223 | 223 | |
@@ -241,35 +241,35 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function pre_fetch() { |
243 | 243 | |
244 | - if ( $this->step == 1 ) { |
|
245 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
244 | + if ($this->step == 1) { |
|
245 | + $this->delete_data('give_temp_reset_ids'); |
|
246 | 246 | } |
247 | 247 | |
248 | - $items = get_option( 'give_temp_reset_ids', false ); |
|
248 | + $items = get_option('give_temp_reset_ids', false); |
|
249 | 249 | |
250 | - if ( false === $items ) { |
|
250 | + if (false === $items) { |
|
251 | 251 | $items = array(); |
252 | 252 | |
253 | - $give_types_for_reset = array( 'give_forms', 'give_log', 'give_payment' ); |
|
254 | - $give_types_for_reset = apply_filters( 'give_reset_store_post_types', $give_types_for_reset ); |
|
253 | + $give_types_for_reset = array('give_forms', 'give_log', 'give_payment'); |
|
254 | + $give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset); |
|
255 | 255 | |
256 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
256 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
257 | 257 | 'post_type' => $give_types_for_reset, |
258 | 258 | 'post_status' => 'any', |
259 | - 'posts_per_page' => - 1, |
|
260 | - ) ); |
|
259 | + 'posts_per_page' => -1, |
|
260 | + )); |
|
261 | 261 | |
262 | - $posts = get_posts( $args ); |
|
263 | - foreach ( $posts as $post ) { |
|
262 | + $posts = get_posts($args); |
|
263 | + foreach ($posts as $post) { |
|
264 | 264 | $items[] = array( |
265 | 265 | 'id' => (int) $post->ID, |
266 | 266 | 'type' => $post->post_type, |
267 | 267 | ); |
268 | 268 | } |
269 | 269 | |
270 | - $customer_args = array( 'number' => - 1 ); |
|
271 | - $customers = Give()->customers->get_customers( $customer_args ); |
|
272 | - foreach ( $customers as $customer ) { |
|
270 | + $customer_args = array('number' => -1); |
|
271 | + $customers = Give()->customers->get_customers($customer_args); |
|
272 | + foreach ($customers as $customer) { |
|
273 | 273 | $items[] = array( |
274 | 274 | 'id' => (int) $customer->id, |
275 | 275 | 'type' => 'customer', |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | |
279 | 279 | // Allow filtering of items to remove with an unassociative array for each item |
280 | 280 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method |
281 | - $items = apply_filters( 'give_reset_store_items', $items ); |
|
281 | + $items = apply_filters('give_reset_store_items', $items); |
|
282 | 282 | |
283 | - $this->store_data( 'give_temp_reset_ids', $items ); |
|
283 | + $this->store_data('give_temp_reset_ids', $items); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | } |
@@ -294,11 +294,11 @@ discard block |
||
294 | 294 | * |
295 | 295 | * @return mixed Returns the data from the database |
296 | 296 | */ |
297 | - private function get_stored_data( $key ) { |
|
297 | + private function get_stored_data($key) { |
|
298 | 298 | global $wpdb; |
299 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
299 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
300 | 300 | |
301 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
301 | + return empty($value) ? false : maybe_unserialize($value); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -311,10 +311,10 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @return void |
313 | 313 | */ |
314 | - private function store_data( $key, $value ) { |
|
314 | + private function store_data($key, $value) { |
|
315 | 315 | global $wpdb; |
316 | 316 | |
317 | - $value = maybe_serialize( $value ); |
|
317 | + $value = maybe_serialize($value); |
|
318 | 318 | |
319 | 319 | $data = array( |
320 | 320 | 'option_name' => $key, |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | '%s', |
329 | 329 | ); |
330 | 330 | |
331 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
331 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | * |
341 | 341 | * @return void |
342 | 342 | */ |
343 | - private function delete_data( $key ) { |
|
343 | + private function delete_data($key) { |
|
344 | 344 | global $wpdb; |
345 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
345 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | } |
@@ -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( esc_html__( 'You do not have permission to export data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
195 | + if ( ! $this->can_export()) { |
|
196 | + wp_die(esc_html__('You do not have permission to export data.', '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 successfully recounted.', 'give' ); |
|
207 | + $this->message = esc_html__('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 |
@@ -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 | } |
@@ -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,80 +22,80 @@ 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 esc_html_e( 'Recount Stats', 'give' ); ?></span></h2> |
|
34 | + <h2 class="hndle ui-sortable-handle"><span><?php esc_html_e('Recount Stats', 'give'); ?></span></h2> |
|
35 | 35 | |
36 | 36 | <div class="inside recount-stats-controls"> |
37 | - <p><?php esc_html_e( 'Use these tools to recount stats, delete test transactions, or reset stats.', 'give' ); ?></p> |
|
37 | + <p><?php esc_html_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 esc_html_e( 'Please select an option', 'give' ); ?></option> |
|
44 | - <option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e( 'Recalculate Total Donation Income Amount', 'give' ); ?></option> |
|
45 | - <option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_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 esc_html_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 esc_html_e( 'Recalculate Donor Statistics', 'give' ); ?></option> |
|
48 | - <option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e( 'Delete Test Transactions', 'give' ); ?></option> |
|
49 | - <option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e( 'Delete All Data', 'give' ); ?></option> |
|
50 | - <?php do_action( 'give_recount_tool_options' ); ?> |
|
43 | + <option value="0" selected="selected" disabled="disabled"><?php esc_html_e('Please select an option', 'give'); ?></option> |
|
44 | + <option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e('Recalculate Total Donation Income Amount', 'give'); ?></option> |
|
45 | + <option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_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 esc_html_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 esc_html_e('Recalculate Donor Statistics', 'give'); ?></option> |
|
48 | + <option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e('Delete Test Transactions', 'give'); ?></option> |
|
49 | + <option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_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 esc_attr_e( 'Submit', 'give' ); ?>" class="button-secondary"/> |
|
64 | + <input type="submit" id="recount-stats-submit" value="<?php esc_attr_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 esc_html_e( 'Recalculates the overall donation income amount.', 'give' ); ?></span> |
|
69 | + <span id="recount-stats"><?php esc_html_e('Recalculates the overall donation income amount.', 'give'); ?></span> |
|
70 | 70 | <span id="recount-form"><?php |
71 | 71 | printf( |
72 | 72 | /* translators: %s: form singular label */ |
73 | - esc_html__( 'Recalculates the donation and income stats for a specific %s.', 'give' ), |
|
74 | - give_get_forms_label_singular( true ) |
|
73 | + esc_html__('Recalculates the donation and income stats for a specific %s.', 'give'), |
|
74 | + give_get_forms_label_singular(true) |
|
75 | 75 | ); |
76 | 76 | ?></span> |
77 | 77 | <span id="recount-all"><?php |
78 | 78 | printf( |
79 | 79 | /* translators: %s: form plural label */ |
80 | - esc_html__( 'Recalculates the earnings and sales stats for all %s.', 'give' ), |
|
81 | - give_get_forms_label_plural( true ) |
|
80 | + esc_html__('Recalculates the earnings and sales stats for all %s.', 'give'), |
|
81 | + give_get_forms_label_plural(true) |
|
82 | 82 | ); |
83 | 83 | ?></span> |
84 | - <span id="recount-customer-stats"><?php esc_html_e( 'Recalculates the lifetime value and donation counts for all donors.', 'give' ); ?></span> |
|
85 | - <?php do_action( 'give_recount_tool_descriptions' ); ?> |
|
86 | - <span id="delete-test-transactions"><?php _e( '<strong>Deletes</strong> all TEST payment records, donors, and related log entries.', 'give' ); ?></span> |
|
87 | - <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> |
|
84 | + <span id="recount-customer-stats"><?php esc_html_e('Recalculates the lifetime value and donation counts for all donors.', 'give'); ?></span> |
|
85 | + <?php do_action('give_recount_tool_descriptions'); ?> |
|
86 | + <span id="delete-test-transactions"><?php _e('<strong>Deletes</strong> all TEST payment records, donors, and related log entries.', 'give'); ?></span> |
|
87 | + <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> |
|
88 | 88 | </span> |
89 | 89 | |
90 | 90 | <span class="spinner"></span> |
91 | 91 | |
92 | 92 | </form> |
93 | - <?php do_action( 'give_tools_recount_forms' ); ?> |
|
93 | + <?php do_action('give_tools_recount_forms'); ?> |
|
94 | 94 | </div><!-- .inside --> |
95 | 95 | </div><!-- .postbox --> |
96 | 96 | </div><!-- #poststuff --> |
97 | 97 | <?php |
98 | - do_action( 'give_tools_recount_stats_after' ); |
|
98 | + do_action('give_tools_recount_stats_after'); |
|
99 | 99 | } |
100 | 100 | |
101 | -add_action( 'give_reports_tab_tools', 'give_tools_recount_stats_display' ); |
|
101 | +add_action('give_reports_tab_tools', 'give_tools_recount_stats_display'); |